3
* Helper functions for displaying a list of items in an ajaxified HTML table.
6
* @subpackage List_Table
11
* Fetch an instance of a WP_List_Table class.
16
* @param string $class The type of the list table, which is the class name.
17
* @param array $args Optional. Arguments to pass to the class. Accepts 'screen'.
18
* @return object|bool Object on success, false if the class does not exist.
20
function _get_list_table( $class, $args = array() ) {
21
$core_classes = array(
23
'WP_Posts_List_Table' => 'posts',
24
'WP_Media_List_Table' => 'media',
25
'WP_Terms_List_Table' => 'terms',
26
'WP_Users_List_Table' => 'users',
27
'WP_Comments_List_Table' => 'comments',
28
'WP_Post_Comments_List_Table' => 'comments',
29
'WP_Links_List_Table' => 'links',
30
'WP_Plugin_Install_List_Table' => 'plugin-install',
31
'WP_Themes_List_Table' => 'themes',
32
'WP_Theme_Install_List_Table' => array( 'themes', 'theme-install' ),
33
'WP_Plugins_List_Table' => 'plugins',
35
'WP_MS_Sites_List_Table' => 'ms-sites',
36
'WP_MS_Users_List_Table' => 'ms-users',
37
'WP_MS_Themes_List_Table' => 'ms-themes',
40
if ( isset( $core_classes[ $class ] ) ) {
41
foreach ( (array) $core_classes[ $class ] as $required )
42
require_once( ABSPATH . 'wp-admin/includes/class-wp-' . $required . '-list-table.php' );
44
if ( isset( $args['screen'] ) )
45
$args['screen'] = convert_to_screen( $args['screen'] );
46
elseif ( isset( $GLOBALS['hook_suffix'] ) )
47
$args['screen'] = get_current_screen();
49
$args['screen'] = null;
51
return new $class( $args );
58
* Register column headers for a particular screen.
62
* @param string $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions.
63
* @param array $columns An array of columns with column IDs as the keys and translated column names as the values
64
* @see get_column_headers(), print_column_headers(), get_hidden_columns()
66
function register_column_headers($screen, $columns) {
67
$wp_list_table = new _WP_List_Table_Compat($screen, $columns);
71
* Prints column headers for a particular screen.
75
function print_column_headers($screen, $id = true) {
76
$wp_list_table = new _WP_List_Table_Compat($screen);
78
$wp_list_table->print_column_headers($id);
82
* Helper class to be used only by back compat functions
86
class _WP_List_Table_Compat extends WP_List_Table {
90
public function __construct( $screen, $columns = array() ) {
91
if ( is_string( $screen ) )
92
$screen = convert_to_screen( $screen );
94
$this->_screen = $screen;
96
if ( !empty( $columns ) ) {
97
$this->_columns = $columns;
98
add_filter( 'manage_' . $screen->id . '_columns', array( $this, 'get_columns' ), 0 );
102
protected function get_column_info() {
103
$columns = get_column_headers( $this->_screen );
104
$hidden = get_hidden_columns( $this->_screen );
107
return array( $columns, $hidden, $sortable );
110
public function get_columns() {
111
return $this->_columns;