Make WordPress Core

Changeset 16235


Ignore:
Timestamp:
11/08/2010 03:43:44 PM (15 years ago)
Author:
scribu
Message:

Use get_current_screen() in list table classes. Fixes #15338

Location:
trunk/wp-admin/includes
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/class-wp-comments-list-table.php

    r16205 r16235  
    3131
    3232        parent::WP_List_Table( array(
    33             'screen' => 'edit-comments',
    3433            'plural' => 'comments'
    3534        ) );
  • trunk/wp-admin/includes/class-wp-list-table.php

    r16226 r16235  
    7979    function WP_List_Table( $args = array() ) {
    8080        $args = wp_parse_args( $args, array(
    81             'screen' => get_current_screen(),
    8281            'plural' => '',
    8382            'singular' => '',
     
    8584        ) );
    8685
    87         $this->screen = $args['screen'];
    88 
    89         if ( is_string( $this->screen ) )
    90             $this->screen = convert_to_screen( $this->screen );
    91 
    92         add_filter( 'manage_' . $this->screen->id . '_columns', array( &$this, 'get_columns' ), 0 );
     86        $screen = get_current_screen();
     87
     88        add_filter( "manage_{$screen->id}_columns", array( &$this, 'get_columns' ), 0 );
    9389
    9490        if ( !$args['plural'] )
    95             $args['plural'] = $this->screen->base;
     91            $args['plural'] = $screen->base;
    9692
    9793        $this->_args = $args;
     
    204200     */
    205201    function views() {
     202        $screen = get_current_screen();
     203
    206204        $views = $this->get_views();
    207         $views = apply_filters( 'views_' . $this->screen->id, $views );
     205        $views = apply_filters( 'views_' . $screen->id, $views );
    208206
    209207        if ( empty( $views ) )
     
    238236     */
    239237    function bulk_actions() {
     238        $screen = get_current_screen();
    240239
    241240        if ( is_null( $this->_actions ) ) {
    242241            $this->_actions = $this->get_bulk_actions();
    243             $this->_actions = apply_filters( 'bulk_actions-' . $this->screen->id, $this->_actions );
     242            $this->_actions = apply_filters( 'bulk_actions-' . $screen->id, $this->_actions );
    244243            $two = '';
    245244        }
     
    539538    function get_column_info() {
    540539        if ( !isset( $this->_column_headers ) ) {
    541             $columns = get_column_headers( $this->screen );
    542             $hidden = get_hidden_columns( $this->screen );
    543             $sortable = apply_filters( 'manage_' . $this->screen->id . '_sortable_columns', $this->get_sortable_columns() );
     540            $screen = get_current_screen();
     541
     542            $columns = get_column_headers( $screen );
     543            $hidden = get_hidden_columns( $screen );
     544            $sortable = apply_filters( "manage_{$screen->id}_sortable_columns", $this->get_sortable_columns() );
    544545
    545546            $this->_column_headers = array( $columns, $hidden, $sortable );
     
    558559     */
    559560    function print_column_headers( $with_id = true ) {
    560         $screen = $this->screen;
     561        $screen = get_current_screen();
    561562
    562563        list( $columns, $hidden, $sortable ) = $this->get_column_info();
     
    811812        $args = array(
    812813            'class' => get_class( $this ),
    813             'screen' => $this->screen
     814            'screen' => get_current_screen()
    814815        );
    815816
  • trunk/wp-admin/includes/class-wp-plugins-list-table.php

    r16205 r16235  
    5858        );
    5959
    60         if ( ! is_multisite() || ( $this->screen->is_network && current_user_can('manage_network_plugins') ) ) {
     60        $screen = get_current_screen();
     61
     62        if ( ! is_multisite() || ( $screen->is_network && current_user_can('manage_network_plugins') ) ) {
    6163            if ( apply_filters( 'show_advanced_plugins', true, 'mustuse' ) )
    6264                $plugins['mustuse'] = get_mu_plugins();
     
    8688        foreach ( (array) $plugins['all'] as $plugin_file => $plugin_data ) {
    8789            // Filter into individual sections
    88             if ( is_plugin_active_for_network($plugin_file) && !$this->screen->is_network ) {
     90            if ( is_plugin_active_for_network($plugin_file) && !$screen->is_network ) {
    8991                unset( $plugins['all'][ $plugin_file ] );
    9092                continue;
    9193            } elseif ( is_multisite() && is_network_only_plugin( $plugin_file ) && !current_user_can( 'manage_network_plugins' ) ) {
    9294                $plugins['network'][ $plugin_file ] = $plugin_data;
    93             } elseif ( ( !$this->screen->is_network && is_plugin_active( $plugin_file ) )
    94                 || ( $this->screen->is_network && is_plugin_active_for_network( $plugin_file ) ) ) {
     95            } elseif ( ( !$screen->is_network && is_plugin_active( $plugin_file ) )
     96                || ( $screen->is_network && is_plugin_active_for_network( $plugin_file ) ) ) {
    9597                $plugins['active'][ $plugin_file ] = $plugin_data;
    9698            } else {
    97                 if ( !$this->screen->is_network && isset( $recently_activated[ $plugin_file ] ) ) // Was the plugin recently activated?
     99                if ( !$screen->is_network && isset( $recently_activated[ $plugin_file ] ) ) // Was the plugin recently activated?
    98100                    $plugins['recently_activated'][ $plugin_file ] = $plugin_data;
    99101                $plugins['inactive'][ $plugin_file ] = $plugin_data;
     
    129131        }
    130132
    131         $plugins_per_page = $this->get_items_per_page( str_replace( '-', '_', "{$this->screen->id}_per_page" ) );
     133        $plugins_per_page = $this->get_items_per_page( str_replace( '-', '_', $screen->id . '_per_page' ) );
    132134
    133135        $start = ( $page - 1 ) * $plugins_per_page;
     
    254256        $actions = array();
    255257
     258        $screen = get_current_screen();
     259
    256260        if ( 'active' != $status ) {
    257             $action = $this->screen->is_network ? 'network-activate-selected' : 'activate-selected';
     261            $action = $screen->is_network ? 'network-activate-selected' : 'activate-selected';
    258262            $actions[ $action ] = __( 'Activate' );
    259263        }
     
    262266            $actions['deactivate-selected'] = __( 'Deactivate' );
    263267
    264         if ( !is_multisite() || $this->screen->is_network ) {
     268        if ( !is_multisite() || $screen->is_network ) {
    265269            if ( current_user_can( 'update_plugins' ) )
    266270                $actions['update-selected'] = __( 'Update' );
     
    302306
    303307        $context = $status;
     308
     309        $screen = get_current_screen();
    304310
    305311        foreach ( $this->items as $plugin_file => $plugin_data ) {
     
    314320
    315321            if ( 'mustuse' == $context ) {
    316                 if ( is_multisite() && !$this->screen->is_network )
     322                if ( is_multisite() && !$screen->is_network )
    317323                    continue;
    318324                $is_active = true;
    319325            } elseif ( 'dropins' == $context ) {
    320                 if ( is_multisite() && !$this->screen->is_network )
     326                if ( is_multisite() && !$screen->is_network )
    321327                    continue;
    322328                $dropins = _get_dropins();
     
    338344            } else {
    339345                $is_active_for_network = is_plugin_active_for_network($plugin_file);
    340                 if ( $this->screen->is_network )
     346                if ( $screen->is_network )
    341347                    $is_active = $is_active_for_network;
    342348                else
    343349                    $is_active = is_plugin_active( $plugin_file );
    344350
    345                 if ( $is_active_for_network && !is_super_admin() && !$this->screen->is_network )
     351                if ( $is_active_for_network && !is_super_admin() && !$screen->is_network )
    346352                    continue;
    347353
    348                 if ( $this->screen->is_network ) {
     354                if ( $screen->is_network ) {
    349355                    if ( $is_active_for_network ) {
    350356                        if ( current_user_can( 'manage_network_plugins' ) )
     
    360366                        $actions['deactivate'] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'deactivate-plugin_' . $plugin_file) . '" title="' . __('Deactivate this plugin') . '">' . __('Deactivate') . '</a>';
    361367                    } else {
    362                         if ( is_network_only_plugin( $plugin_file ) && !$this->screen->is_network )
     368                        if ( is_network_only_plugin( $plugin_file ) && !$screen->is_network )
    363369                            continue;
    364370
     
    368374                            $actions['delete'] = '<a href="' . wp_nonce_url('plugins.php?action=delete-selected&amp;checked[]=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'bulk-plugins') . '" title="' . __('Delete this plugin') . '" class="delete">' . __('Delete') . '</a>';
    369375                    } // end if $is_active
    370                  } // end if $this->screen->is_network
     376                 } // end if $screen->is_network
    371377
    372378                if ( current_user_can('edit_plugins') && is_writable(WP_PLUGIN_DIR . '/' . $plugin_file) )
  • trunk/wp-admin/includes/class-wp-posts-list-table.php

    r16212 r16235  
    257257
    258258    function get_columns() {
    259         $screen = $this->screen;
     259        $screen = get_current_screen();
    260260
    261261        if ( empty( $screen ) )
     
    682682        global $mode;
    683683
    684         $screen = $this->screen;
     684        $screen = get_current_screen();
    685685
    686686        $post = get_default_post_to_edit( $screen->post_type );
  • trunk/wp-admin/includes/class-wp-terms-list-table.php

    r16214 r16235  
    291291
    292292    function column_default( $tag, $column_name ) {
    293         return apply_filters( "manage_{$this->screen->taxonomy}_custom_column", '', $column_name, $tag->term_id );
     293        $screen = get_current_screen();
     294
     295        return apply_filters( "manage_{$screen->taxonomy}_custom_column", '', $column_name, $tag->term_id );
    294296    }
    295297
  • trunk/wp-admin/includes/deprecated.php

    r16182 r16235  
    704704    _deprecated_function( __FUNCTION__, '3.1', 'WP_List_Table' );
    705705
    706     global $wp_list_table;
    707 
    708     $wp_list_table = new _WP_List_Table_Compat($screen);
    709     $wp_list_table->_columns = $columns;
     706    $wp_list_table = new _WP_List_Table_Compat($screen, $columns);
    710707}
    711708
     
    720717    _deprecated_function( __FUNCTION__, '3.1', 'WP_List_Table' );
    721718
    722     global $wp_list_table;
    723     if ( !is_a($wp_list_table, 'WP_List_Table') )
    724         $wp_list_table = new _WP_List_Table_Compat($screen);
     719    $wp_list_table = new _WP_List_Table_Compat($screen);
    725720
    726721    $wp_list_table->print_column_headers($id);
     
    729724// Helper class to be used only by deprecated functions
    730725class _WP_List_Table_Compat extends WP_List_Table {
    731 
    732     var $_columns = array();
    733 
    734     function _WP_List_Table_Compat( $screen ) {
    735         parent::WP_List_Table( array(
    736             'screen' => $screen,
    737             'ajax' => false
    738         ) );
     726    var $_screen;
     727    var $_columns;
     728
     729    function _WP_List_Table_Compat( $screen, $columns = array() ) {
     730        if ( is_string( $screen ) )
     731            $screen = convert_to_screen( $screen );
     732
     733        $this->_screen = $screen;
     734
     735        if ( !empty( $columns ) ) {
     736            $this->_columns = $columns;
     737            add_filter( 'manage_' . $screen->id . '_columns', array( &$this, 'get_columns' ), 0 );
     738        }
     739    }
     740
     741    function get_column_info() {
     742        $columns = get_column_headers( $this->_screen );
     743        $hidden = get_hidden_columns( $this->_screen );
     744        $sortable = array();
     745
     746        return array( $columns, $hidden, $sortable );
    739747    }
    740748
Note: See TracChangeset for help on using the changeset viewer.