Default to get_current_screen() in list table classes. See #14579

git-svn-id: http://svn.automattic.com/wordpress/trunk@16182 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
scribu 2010-11-04 15:00:55 +00:00
parent 20181ba697
commit c5a9fd309d
14 changed files with 20 additions and 58 deletions

View File

@ -30,7 +30,6 @@ class WP_Comments_List_Table extends WP_List_Table {
add_filter( 'comment_author', 'floated_admin_avatar' );
parent::WP_List_Table( array(
'screen' => 'edit-comments',
'plural' => 'comments'
) );
}

View File

@ -10,7 +10,6 @@ class WP_Links_List_Table extends WP_List_Table {
function WP_Links_List_Table() {
parent::WP_List_Table( array(
'screen' => 'link-manager',
'plural' => 'bookmarks',
) );
}
@ -189,4 +188,4 @@ class WP_Links_List_Table extends WP_List_Table {
}
}
?>
?>

View File

@ -76,9 +76,9 @@ class WP_List_Table {
* @param array $args An associative array with information about the current table
* @access protected
*/
function WP_List_Table( $args ) {
function WP_List_Table( $args = array() ) {
$args = wp_parse_args( $args, array(
'screen' => '',
'screen' => get_current_screen(),
'plural' => '',
'singular' => '',
'ajax' => true
@ -632,9 +632,7 @@ class WP_List_Table {
* @return array
*/
function get_table_classes() {
extract( $this->_args );
return array( 'widefat', 'fixed', $plural );
return array( 'widefat', 'fixed', $this->_args['plural'] );
}
/**
@ -807,13 +805,12 @@ class WP_List_Table {
* @access private
*/
function _js_vars() {
extract( $this->_args );
$class = get_class( $this );
printf( "<script type='text/javascript'>list_args = %s;</script>\n",
json_encode( compact( 'screen', 'class' ) )
$args = array(
'class' => get_class( $this ),
'screen' => $this->_screen
);
printf( "<script type='text/javascript'>list_args = %s;</script>\n", json_encode( $args ) );
}
}
?>

View File

@ -10,7 +10,6 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
function WP_MS_Sites_List_Table() {
parent::WP_List_Table( array(
'screen' => 'sites-network',
'plural' => 'sites',
) );
}
@ -330,4 +329,4 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
}
}
?>
?>

View File

@ -23,7 +23,6 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
$page = $this->get_pagenum();
parent::WP_List_Table( array(
'screen' => 'themes',
'plural' => 'plugins', // @todo replace with themes and add css
) );
}

View File

@ -10,7 +10,7 @@ class WP_MS_Users_List_Table extends WP_List_Table {
function WP_MS_Users_List_Table() {
parent::WP_List_Table( array(
'screen' => 'users-network',
'plural' => 'users'
) );
}
@ -234,4 +234,4 @@ class WP_MS_Users_List_Table extends WP_List_Table {
}
}
?>
?>

View File

@ -8,12 +8,6 @@
*/
class WP_Plugin_Install_List_Table extends WP_List_Table {
function WP_Plugin_Install_List_Table() {
parent::WP_List_Table( array(
'screen' => 'plugin-install',
) );
}
function check_permissions() {
if ( ! current_user_can('install_plugins') )
wp_die(__('You do not have sufficient permissions to install plugins on this site.'));
@ -231,4 +225,4 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
}
}
?>
?>

View File

@ -23,7 +23,6 @@ class WP_Plugins_List_Table extends WP_List_Table {
$page = $this->get_pagenum();
parent::WP_List_Table( array(
'screen' => 'plugins',
'plural' => 'plugins',
) );
}

View File

@ -45,7 +45,7 @@ class WP_Posts_List_Table extends WP_List_Table {
var $sticky_posts_count = 0;
function WP_Posts_List_Table() {
global $post_type_object, $post_type, $current_screen, $wpdb;
global $post_type_object, $post_type, $wpdb;
if ( !isset( $_REQUEST['post_type'] ) )
$post_type = 'post';
@ -74,7 +74,6 @@ class WP_Posts_List_Table extends WP_List_Table {
}
parent::WP_List_Table( array(
'screen' => $current_screen,
'plural' => 'posts',
) );
}

View File

@ -11,7 +11,7 @@ class WP_Terms_List_Table extends WP_List_Table {
var $callback_args;
function WP_Terms_List_Table() {
global $post_type, $taxonomy, $tax, $current_screen;
global $post_type, $taxonomy, $tax;
wp_reset_vars( array( 'action', 'taxonomy', 'post_type' ) );
@ -26,11 +26,7 @@ class WP_Terms_List_Table extends WP_List_Table {
if ( empty( $post_type ) || !in_array( $post_type, get_post_types( array( 'public' => true ) ) ) )
$post_type = 'post';
if ( !isset( $current_screen ) )
set_current_screen( 'edit-' . $taxonomy );
parent::WP_List_Table( array(
'screen' => $current_screen,
'plural' => 'tags',
'singular' => 'tag',
) );
@ -362,4 +358,4 @@ class WP_Terms_List_Table extends WP_List_Table {
}
}
?>
?>

View File

@ -8,12 +8,6 @@
*/
class WP_Theme_Install_List_Table extends WP_List_Table {
function WP_Theme_Install_List_Table() {
parent::WP_List_Table( array(
'screen' => 'theme-install',
) );
}
function check_permissions() {
if ( ! current_user_can('install_themes') )
wp_die( __( 'You do not have sufficient permissions to install themes on this site.' ) );
@ -184,4 +178,4 @@ class WP_Theme_Install_List_Table extends WP_List_Table {
}
}
?>
?>

View File

@ -11,12 +11,6 @@ class WP_Themes_List_Table extends WP_List_Table {
var $search = array();
var $features = array();
function WP_Themes_List_Table() {
parent::__construct( array(
'screen' => 'themes',
) );
}
function check_permissions() {
if ( !current_user_can('switch_themes') && !current_user_can('edit_theme_options') )
wp_die( __( 'Cheatin&#8217; uh?' ) );
@ -216,4 +210,4 @@ foreach ( $cols as $col => $theme_name ) {
}
}
?>
?>

View File

@ -8,13 +8,6 @@
*/
class WP_Users_List_Table extends WP_List_Table {
function WP_Users_List_Table() {
parent::WP_List_Table( array(
'screen' => 'users',
'plural' => 'users'
) );
}
function check_permissions() {
if ( !current_user_can('list_users') )
wp_die(__('Cheatin&#8217; uh?'));
@ -275,4 +268,4 @@ class WP_Users_List_Table extends WP_List_Table {
}
}
?>
?>

View File

@ -731,7 +731,7 @@ class _WP_List_Table_Compat extends WP_List_Table {
var $_columns = array();
function _WP_List_Table_Compat( $screen) {
function _WP_List_Table_Compat( $screen ) {
parent::WP_List_Table( array(
'screen' => $screen,
'ajax' => false