wp/wp-admin/includes/class-wp-ms-themes-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 in a list table for the network admin.
    11  * Core class used to implement displaying themes in a list table for the network admin.
    12  *
    12  *
    13  * @since 3.1.0
    13  * @since 3.1.0
    14  * @access private
       
    15  *
    14  *
    16  * @see WP_List_Table
    15  * @see WP_List_Table
    17  */
    16  */
    18 class WP_MS_Themes_List_Table extends WP_List_Table {
    17 class WP_MS_Themes_List_Table extends WP_List_Table {
    19 
    18 
    98 	 * @global string $s
    97 	 * @global string $s
    99 	 */
    98 	 */
   100 	public function prepare_items() {
    99 	public function prepare_items() {
   101 		global $status, $totals, $page, $orderby, $order, $s;
   100 		global $status, $totals, $page, $orderby, $order, $s;
   102 
   101 
   103 		wp_reset_vars( array( 'orderby', 'order', 's' ) );
   102 		$orderby = ! empty( $_REQUEST['orderby'] ) ? sanitize_text_field( $_REQUEST['orderby'] ) : '';
       
   103 		$order   = ! empty( $_REQUEST['order'] ) ? sanitize_text_field( $_REQUEST['order'] ) : '';
       
   104 		$s       = ! empty( $_REQUEST['s'] ) ? sanitize_text_field( $_REQUEST['s'] ) : '';
   104 
   105 
   105 		$themes = array(
   106 		$themes = array(
   106 			/**
   107 			/**
   107 			 * Filters the full array of WP_Theme objects to list in the Multisite
   108 			 * Filters the full array of WP_Theme objects to list in the Multisite
   108 			 * themes list table.
   109 			 * themes list table.
   321 			_e( 'No themes are currently available.' );
   322 			_e( 'No themes are currently available.' );
   322 		}
   323 		}
   323 	}
   324 	}
   324 
   325 
   325 	/**
   326 	/**
   326 	 * @return array
   327 	 * @return string[] Array of column titles keyed by their column name.
   327 	 */
   328 	 */
   328 	public function get_columns() {
   329 	public function get_columns() {
   329 		$columns = array(
   330 		$columns = array(
   330 			'cb'          => '<input type="checkbox" />',
   331 			'cb'          => '<input type="checkbox" />',
   331 			'name'        => __( 'Theme' ),
   332 			'name'        => __( 'Theme' ),
   342 	/**
   343 	/**
   343 	 * @return array
   344 	 * @return array
   344 	 */
   345 	 */
   345 	protected function get_sortable_columns() {
   346 	protected function get_sortable_columns() {
   346 		return array(
   347 		return array(
   347 			'name' => 'name',
   348 			'name' => array( 'name', false, __( 'Theme' ), __( 'Table ordered by Theme Name.' ), 'asc' ),
   348 		);
   349 		);
   349 	}
   350 	}
   350 
   351 
   351 	/**
   352 	/**
   352 	 * Gets the name of the primary column.
   353 	 * Gets the name of the primary column.
   442 			} else {
   443 			} else {
   443 				$url = 'themes.php';
   444 				$url = 'themes.php';
   444 			}
   445 			}
   445 
   446 
   446 			if ( 'search' !== $type ) {
   447 			if ( 'search' !== $type ) {
   447 				$status_links[ $type ] = sprintf(
   448 				$status_links[ $type ] = array(
   448 					"<a href='%s'%s>%s</a>",
   449 					'url'     => esc_url( add_query_arg( 'theme_status', $type, $url ) ),
   449 					esc_url( add_query_arg( 'theme_status', $type, $url ) ),
   450 					'label'   => sprintf( $text, number_format_i18n( $count ) ),
   450 					( $type === $status ) ? ' class="current" aria-current="page"' : '',
   451 					'current' => $type === $status,
   451 					sprintf( $text, number_format_i18n( $count ) )
       
   452 				);
   452 				);
   453 			}
   453 			}
   454 		}
   454 		}
   455 
   455 
   456 		return $status_links;
   456 		return $this->get_views_links( $status_links );
   457 	}
   457 	}
   458 
   458 
   459 	/**
   459 	/**
   460 	 * @global string $status
   460 	 * @global string $status
   461 	 *
   461 	 *
   509 	 *
   509 	 *
   510 	 * @param WP_Theme $item The current WP_Theme object.
   510 	 * @param WP_Theme $item The current WP_Theme object.
   511 	 */
   511 	 */
   512 	public function column_cb( $item ) {
   512 	public function column_cb( $item ) {
   513 		// Restores the more descriptive, specific name for use within this method.
   513 		// Restores the more descriptive, specific name for use within this method.
   514 		$theme       = $item;
   514 		$theme = $item;
       
   515 
   515 		$checkbox_id = 'checkbox_' . md5( $theme->get( 'Name' ) );
   516 		$checkbox_id = 'checkbox_' . md5( $theme->get( 'Name' ) );
   516 		?>
   517 		?>
   517 		<input type="checkbox" name="checked[]" value="<?php echo esc_attr( $theme->get_stylesheet() ); ?>" id="<?php echo $checkbox_id; ?>" />
   518 		<input type="checkbox" name="checked[]" value="<?php echo esc_attr( $theme->get_stylesheet() ); ?>" id="<?php echo $checkbox_id; ?>" />
   518 		<label class="screen-reader-text" for="<?php echo $checkbox_id; ?>" ><?php _e( 'Select' ); ?>  <?php echo $theme->display( 'Name' ); ?></label>
   519 		<label for="<?php echo $checkbox_id; ?>" >
       
   520 			<span class="screen-reader-text">
       
   521 			<?php
       
   522 			printf(
       
   523 				/* translators: Hidden accessibility text. %s: Theme name */
       
   524 				__( 'Select %s' ),
       
   525 				$theme->display( 'Name' )
       
   526 			);
       
   527 			?>
       
   528 			</span>
       
   529 		</label>
   519 		<?php
   530 		<?php
   520 	}
   531 	}
   521 
   532 
   522 	/**
   533 	/**
   523 	 * Handles the name column output.
   534 	 * Handles the name column output.
   849 		 * @param string   $stylesheet Directory name of the theme.
   860 		 * @param string   $stylesheet Directory name of the theme.
   850 		 * @param WP_Theme $theme      WP_Theme object.
   861 		 * @param WP_Theme $theme      WP_Theme object.
   851 		 */
   862 		 */
   852 		echo apply_filters( 'theme_auto_update_setting_html', $html, $stylesheet, $theme );
   863 		echo apply_filters( 'theme_auto_update_setting_html', $html, $stylesheet, $theme );
   853 
   864 
   854 		echo '<div class="notice notice-error notice-alt inline hidden"><p></p></div>';
   865 		wp_admin_notice(
       
   866 			'',
       
   867 			array(
       
   868 				'type'               => 'error',
       
   869 				'additional_classes' => array( 'notice-alt', 'inline', 'hidden' ),
       
   870 			)
       
   871 		);
   855 	}
   872 	}
   856 
   873 
   857 	/**
   874 	/**
   858 	 * Handles default column output.
   875 	 * Handles default column output.
   859 	 *
   876 	 *
   862 	 *
   879 	 *
   863 	 * @param WP_Theme $item        The current WP_Theme object.
   880 	 * @param WP_Theme $item        The current WP_Theme object.
   864 	 * @param string   $column_name The current column name.
   881 	 * @param string   $column_name The current column name.
   865 	 */
   882 	 */
   866 	public function column_default( $item, $column_name ) {
   883 	public function column_default( $item, $column_name ) {
       
   884 		// Restores the more descriptive, specific name for use within this method.
       
   885 		$theme = $item;
       
   886 
       
   887 		$stylesheet = $theme->get_stylesheet();
       
   888 
   867 		/**
   889 		/**
   868 		 * Fires inside each custom column of the Multisite themes list table.
   890 		 * Fires inside each custom column of the Multisite themes list table.
   869 		 *
   891 		 *
   870 		 * @since 3.1.0
   892 		 * @since 3.1.0
   871 		 *
   893 		 *
   872 		 * @param string   $column_name Name of the column.
   894 		 * @param string   $column_name Name of the column.
   873 		 * @param string   $stylesheet  Directory name of the theme.
   895 		 * @param string   $stylesheet  Directory name of the theme.
   874 		 * @param WP_Theme $theme       Current WP_Theme object.
   896 		 * @param WP_Theme $theme       Current WP_Theme object.
   875 		 */
   897 		 */
   876 		do_action(
   898 		do_action( 'manage_themes_custom_column', $column_name, $stylesheet, $theme );
   877 			'manage_themes_custom_column',
       
   878 			$column_name,
       
   879 			$item->get_stylesheet(), // Directory name of the theme.
       
   880 			$item // Theme object.
       
   881 		);
       
   882 	}
   899 	}
   883 
   900 
   884 	/**
   901 	/**
   885 	 * Handles the output for a single table row.
   902 	 * Handles the output for a single table row.
   886 	 *
   903 	 *