Make WordPress Core


Ignore:
Timestamp:
09/19/2012 12:43:31 PM (14 years ago)
Author:
ryan
Message:

Reduce reliance on global variables in the list tables. Allow passing a screen ID to the list tables so that ajax handlers can set the needed screen.

Props nacin
fixes #21871

File:
1 edited

Legend:

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

    r21789 r21914  
    1010class WP_Plugins_List_Table extends WP_List_Table {
    1111
    12         function __construct() {
     12        function __construct( $args = array() ) {
    1313                global $status, $page;
     14
     15                parent::__construct( array(
     16                        'plural' => 'plugins',
     17                        'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
     18                ) );
    1419
    1520                $status = 'all';
     
    2126
    2227                $page = $this->get_pagenum();
    23 
    24                 parent::__construct( array(
    25                         'plural' => 'plugins',
    26                 ) );
    2728        }
    2829
     
    5152                );
    5253
    53                 $screen = get_current_screen();
     54                $screen = $this->screen;
    5455
    5556                if ( ! is_multisite() || ( $screen->is_network && current_user_can('manage_network_plugins') ) ) {
     
    9293                                $plugins['active'][ $plugin_file ] = $plugin_data;
    9394                        } else {
    94                                 if ( !$screen->is_network && isset( $recently_activated[ $plugin_file ] ) ) // Was the plugin recently activated?
     95                                if ( ! $screen->is_network && isset( $recently_activated[ $plugin_file ] ) ) // Was the plugin recently activated?
    9596                                        $plugins['recently_activated'][ $plugin_file ] = $plugin_data;
    9697                                $plugins['inactive'][ $plugin_file ] = $plugin_data;
     
    237238                $actions = array();
    238239
    239                 $screen = get_current_screen();
    240 
    241240                if ( 'active' != $status )
    242                         $actions['activate-selected'] = $screen->is_network ? __( 'Network Activate' ) : __( 'Activate' );
     241                        $actions['activate-selected'] = $this->screen->is_network ? __( 'Network Activate' ) : __( 'Activate' );
    243242
    244243                if ( 'inactive' != $status && 'recent' != $status )
    245                         $actions['deactivate-selected'] = $screen->is_network ? __( 'Network Deactivate' ) : __( 'Deactivate' );
    246 
    247                 if ( !is_multisite() || $screen->is_network ) {
     244                        $actions['deactivate-selected'] = $this->screen->is_network ? __( 'Network Deactivate' ) : __( 'Deactivate' );
     245
     246                if ( !is_multisite() || $this->screen->is_network ) {
    248247                        if ( current_user_can( 'update_plugins' ) )
    249248                                $actions['update-selected'] = __( 'Update' );
     
    272271                echo '<div class="alignleft actions">';
    273272
    274                 $screen = get_current_screen();
    275 
    276                 if ( ! $screen->is_network && 'recently_activated' == $status )
     273                if ( ! $this->screen->is_network && 'recently_activated' == $status )
    277274                        submit_button( __( 'Clear List' ), 'small', 'clear-recent-list', false );
    278275                elseif ( 'top' == $which && 'mustuse' == $status )
     
    294291                global $status;
    295292
    296                 $screen = get_current_screen();
    297 
    298                 if ( is_multisite() && !$screen->is_network && in_array( $status, array( 'mustuse', 'dropins' ) ) )
     293                if ( is_multisite() && ! $this->screen->is_network && in_array( $status, array( 'mustuse', 'dropins' ) ) )
    299294                        return;
    300295
     
    307302
    308303                $context = $status;
    309 
    310                 $screen = get_current_screen();
     304                $screen = $this->screen;
    311305
    312306                // preorder
Note: See TracChangeset for help on using the changeset viewer.