equal
deleted
inserted
replaced
12 * |
12 * |
13 * @access private |
13 * @access private |
14 * @since 3.1.0 |
14 * @since 3.1.0 |
15 * |
15 * |
16 * @param string $class The type of the list table, which is the class name. |
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'. |
17 * @return object|bool Object on success, false if the class does not exist. |
18 * @return object|bool Object on success, false if the class does not exist. |
18 */ |
19 */ |
19 function _get_list_table( $class ) { |
20 function _get_list_table( $class, $args = array() ) { |
20 $core_classes = array( |
21 $core_classes = array( |
21 //Site Admin |
22 //Site Admin |
22 'WP_Posts_List_Table' => 'posts', |
23 'WP_Posts_List_Table' => 'posts', |
23 'WP_Media_List_Table' => 'media', |
24 'WP_Media_List_Table' => 'media', |
24 'WP_Terms_List_Table' => 'terms', |
25 'WP_Terms_List_Table' => 'terms', |
37 ); |
38 ); |
38 |
39 |
39 if ( isset( $core_classes[ $class ] ) ) { |
40 if ( isset( $core_classes[ $class ] ) ) { |
40 foreach ( (array) $core_classes[ $class ] as $required ) |
41 foreach ( (array) $core_classes[ $class ] as $required ) |
41 require_once( ABSPATH . 'wp-admin/includes/class-wp-' . $required . '-list-table.php' ); |
42 require_once( ABSPATH . 'wp-admin/includes/class-wp-' . $required . '-list-table.php' ); |
42 return new $class; |
43 |
|
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(); |
|
48 else |
|
49 $args['screen'] = null; |
|
50 |
|
51 return new $class( $args ); |
43 } |
52 } |
44 |
53 |
45 return false; |
54 return false; |
46 } |
55 } |
47 |
56 |