wp/wp-admin/includes/class-wp-theme-install-list-table.php
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
child 22 8c2e4d02f4ef
equal deleted inserted replaced
20:7b1b88e27a20 21:48c4eec2b7e6
     9 
     9 
    10 /**
    10 /**
    11  * Core class used to implement displaying themes to install in a list table.
    11  * Core class used to implement displaying themes to install in a list table.
    12  *
    12  *
    13  * @since 3.1.0
    13  * @since 3.1.0
    14  * @access private
       
    15  *
    14  *
    16  * @see WP_Themes_List_Table
    15  * @see WP_Themes_List_Table
    17  */
    16  */
    18 class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
    17 class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
    19 
    18 
    35 	 */
    34 	 */
    36 	public function prepare_items() {
    35 	public function prepare_items() {
    37 		require ABSPATH . 'wp-admin/includes/theme-install.php';
    36 		require ABSPATH . 'wp-admin/includes/theme-install.php';
    38 
    37 
    39 		global $tabs, $tab, $paged, $type, $theme_field_defaults;
    38 		global $tabs, $tab, $paged, $type, $theme_field_defaults;
    40 		wp_reset_vars( array( 'tab' ) );
    39 
       
    40 		$tab = ! empty( $_REQUEST['tab'] ) ? sanitize_text_field( $_REQUEST['tab'] ) : '';
    41 
    41 
    42 		$search_terms  = array();
    42 		$search_terms  = array();
    43 		$search_string = '';
    43 		$search_string = '';
    44 		if ( ! empty( $_REQUEST['s'] ) ) {
    44 		if ( ! empty( $_REQUEST['s'] ) ) {
    45 			$search_string = strtolower( wp_unslash( $_REQUEST['s'] ) );
    45 			$search_string = strtolower( wp_unslash( $_REQUEST['s'] ) );
   184 	protected function get_views() {
   184 	protected function get_views() {
   185 		global $tabs, $tab;
   185 		global $tabs, $tab;
   186 
   186 
   187 		$display_tabs = array();
   187 		$display_tabs = array();
   188 		foreach ( (array) $tabs as $action => $text ) {
   188 		foreach ( (array) $tabs as $action => $text ) {
   189 			$current_link_attributes                    = ( $action === $tab ) ? ' class="current" aria-current="page"' : '';
   189 			$display_tabs[ 'theme-install-' . $action ] = array(
   190 			$href                                       = self_admin_url( 'theme-install.php?tab=' . $action );
   190 				'url'     => self_admin_url( 'theme-install.php?tab=' . $action ),
   191 			$display_tabs[ 'theme-install-' . $action ] = "<a href='$href'$current_link_attributes>$text</a>";
   191 				'label'   => $text,
   192 		}
   192 				'current' => $action === $tab,
   193 
   193 			);
   194 		return $display_tabs;
   194 		}
       
   195 
       
   196 		return $this->get_views_links( $display_tabs );
   195 	}
   197 	}
   196 
   198 
   197 	/**
   199 	/**
   198 	 * Displays the theme install table.
   200 	 * Displays the theme install table.
   199 	 *
   201 	 *
   330 				$actions[] = sprintf(
   332 				$actions[] = sprintf(
   331 					'<a class="install-now" href="%s" title="%s">%s</a>',
   333 					'<a class="install-now" href="%s" title="%s">%s</a>',
   332 					esc_url( wp_nonce_url( $install_url, 'install-theme_' . $theme->slug ) ),
   334 					esc_url( wp_nonce_url( $install_url, 'install-theme_' . $theme->slug ) ),
   333 					/* translators: %s: Theme name. */
   335 					/* translators: %s: Theme name. */
   334 					esc_attr( sprintf( _x( 'Install %s', 'theme' ), $name ) ),
   336 					esc_attr( sprintf( _x( 'Install %s', 'theme' ), $name ) ),
   335 					__( 'Install Now' )
   337 					_x( 'Install Now', 'theme' )
   336 				);
   338 				);
   337 				break;
   339 				break;
   338 		}
   340 		}
   339 
   341 
   340 		$actions[] = sprintf(
   342 		$actions[] = sprintf(
   541 		global $tab, $type;
   543 		global $tab, $type;
   542 		parent::_js_vars( compact( 'tab', 'type' ) );
   544 		parent::_js_vars( compact( 'tab', 'type' ) );
   543 	}
   545 	}
   544 
   546 
   545 	/**
   547 	/**
   546 	 * Check to see if the theme is already installed.
   548 	 * Checks to see if the theme is already installed.
   547 	 *
   549 	 *
   548 	 * @since 3.4.0
   550 	 * @since 3.4.0
   549 	 *
   551 	 *
   550 	 * @param stdClass $theme A WordPress.org Theme API object.
   552 	 * @param stdClass $theme A WordPress.org Theme API object.
   551 	 * @return string Theme status.
   553 	 * @return string Theme status.