Changeset 38392
- Timestamp:
- 08/26/2016 10:22:58 PM (9 years ago)
- Location:
- trunk/src/wp-admin/includes
- Files:
-
- 2 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/admin.php
r36915 r38392 62 62 /** WordPress List Table Administration API and base class */ 63 63 require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php'); 64 require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table-compat.php'); 64 65 require_once(ABSPATH . 'wp-admin/includes/list-table.php'); 65 66 -
trunk/src/wp-admin/includes/class-wp-list-table-compat.php
r38384 r38392 5 5 * @package WordPress 6 6 * @subpackage List_Table 7 * @since 3.1.07 * @since 4.7.0 8 8 */ 9 10 /**11 * Fetch an instance of a WP_List_Table class.12 *13 * @access private14 * @since 3.1.015 *16 * @global string $hook_suffix17 *18 * @param string $class The type of the list table, which is the class name.19 * @param array $args Optional. Arguments to pass to the class. Accepts 'screen'.20 * @return object|bool Object on success, false if the class does not exist.21 */22 function _get_list_table( $class, $args = array() ) {23 $core_classes = array(24 //Site Admin25 'WP_Posts_List_Table' => 'posts',26 'WP_Media_List_Table' => 'media',27 'WP_Terms_List_Table' => 'terms',28 'WP_Users_List_Table' => 'users',29 'WP_Comments_List_Table' => 'comments',30 'WP_Post_Comments_List_Table' => array( 'comments', 'post-comments' ),31 'WP_Links_List_Table' => 'links',32 'WP_Plugin_Install_List_Table' => 'plugin-install',33 'WP_Themes_List_Table' => 'themes',34 'WP_Theme_Install_List_Table' => array( 'themes', 'theme-install' ),35 'WP_Plugins_List_Table' => 'plugins',36 // Network Admin37 'WP_MS_Sites_List_Table' => 'ms-sites',38 'WP_MS_Users_List_Table' => 'ms-users',39 'WP_MS_Themes_List_Table' => 'ms-themes',40 );41 42 if ( isset( $core_classes[ $class ] ) ) {43 foreach ( (array) $core_classes[ $class ] as $required )44 require_once( ABSPATH . 'wp-admin/includes/class-wp-' . $required . '-list-table.php' );45 46 if ( isset( $args['screen'] ) )47 $args['screen'] = convert_to_screen( $args['screen'] );48 elseif ( isset( $GLOBALS['hook_suffix'] ) )49 $args['screen'] = get_current_screen();50 else51 $args['screen'] = null;52 53 return new $class( $args );54 }55 56 return false;57 }58 59 /**60 * Register column headers for a particular screen.61 *62 * @since 2.7.063 *64 * @param string $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions.65 * @param array $columns An array of columns with column IDs as the keys and translated column names as the values66 * @see get_column_headers(), print_column_headers(), get_hidden_columns()67 */68 function register_column_headers($screen, $columns) {69 $wp_list_table = new _WP_List_Table_Compat($screen, $columns);70 }71 72 /**73 * Prints column headers for a particular screen.74 *75 * @since 2.7.076 *77 * @param string|WP_Screen $screen The screen hook name or screen object.78 * @param bool $with_id Whether to set the id attribute or not.79 */80 function print_column_headers( $screen, $with_id = true ) {81 $wp_list_table = new _WP_List_Table_Compat($screen);82 83 $wp_list_table->print_column_headers( $with_id );84 }85 9 86 10 /** -
trunk/src/wp-admin/includes/list-table.php
r36232 r38392 83 83 $wp_list_table->print_column_headers( $with_id ); 84 84 } 85 86 /**87 * Helper class to be used only by back compat functions88 *89 * @since 3.1.090 */91 class _WP_List_Table_Compat extends WP_List_Table {92 public $_screen;93 public $_columns;94 95 public function __construct( $screen, $columns = array() ) {96 if ( is_string( $screen ) )97 $screen = convert_to_screen( $screen );98 99 $this->_screen = $screen;100 101 if ( !empty( $columns ) ) {102 $this->_columns = $columns;103 add_filter( 'manage_' . $screen->id . '_columns', array( $this, 'get_columns' ), 0 );104 }105 }106 107 /**108 * @access protected109 *110 * @return array111 */112 protected function get_column_info() {113 $columns = get_column_headers( $this->_screen );114 $hidden = get_hidden_columns( $this->_screen );115 $sortable = array();116 $primary = $this->get_default_primary_column_name();117 118 return array( $columns, $hidden, $sortable, $primary );119 }120 121 /**122 * @access public123 *124 * @return array125 */126 public function get_columns() {127 return $this->_columns;128 }129 }
Note: See TracChangeset
for help on using the changeset viewer.