Make WordPress Core

Changeset 21914


Ignore:
Timestamp:
09/19/2012 12:43:31 PM (11 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

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

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/ajax-actions.php

    r21866 r21914  
    3030 */
    3131function wp_ajax_fetch_list() {
    32     global $current_screen, $wp_list_table;
     32    global $wp_list_table;
    3333
    3434    $list_class = $_GET['list_args']['class'];
    3535    check_ajax_referer( "fetch-list-$list_class", '_ajax_fetch_list_nonce' );
    3636
    37     $current_screen = convert_to_screen( $_GET['list_args']['screen']['id'] );
    38 
    39     define( 'WP_NETWORK_ADMIN', $current_screen->is_network );
    40     define( 'WP_USER_ADMIN', $current_screen->is_user );
    41 
    42     $wp_list_table = _get_list_table( $list_class );
     37    $wp_list_table = _get_list_table( $list_class, array( 'screen' => $_GET['list_args']['screen']['id'] ) );
    4338    if ( ! $wp_list_table )
    4439        wp_die( 0 );
     
    616611    }
    617612
    618     set_current_screen( $_POST['screen'] );
    619 
    620     $wp_list_table = _get_list_table('WP_Terms_List_Table');
     613    $wp_list_table = _get_list_table( 'WP_Terms_List_Table', array( 'screen' => $_POST['screen'] ) );
    621614
    622615    $level = 0;
     
    687680    check_ajax_referer( $action );
    688681
    689     set_current_screen( 'edit-comments' );
    690 
    691     $wp_list_table = _get_list_table('WP_Post_Comments_List_Table');
     682    $wp_list_table = _get_list_table( 'WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) );
    692683
    693684    if ( !current_user_can( 'edit_post', $post_id ) )
     
    723714
    724715    check_ajax_referer( $action, '_ajax_nonce-replyto-comment' );
    725 
    726     set_current_screen( 'edit-comments' );
    727716
    728717    $comment_post_ID = (int) $_POST['comment_post_ID'];
     
    783772        } else {
    784773            if ( 'single' == $_REQUEST['mode'] ) {
    785                 $wp_list_table = _get_list_table('WP_Post_Comments_List_Table');
     774                $wp_list_table = _get_list_table('WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) );
    786775            } else {
    787                 $wp_list_table = _get_list_table('WP_Comments_List_Table');
     776                $wp_list_table = _get_list_table('WP_Comments_List_Table', array( 'screen' => 'edit-comments' ) );
    788777            }
    789778            $wp_list_table->single_row( $comment );
     
    812801    check_ajax_referer( 'replyto-comment', '_ajax_nonce-replyto-comment' );
    813802
    814     set_current_screen( 'edit-comments' );
    815 
    816803    $comment_id = (int) $_POST['comment_ID'];
    817804    if ( ! current_user_can( 'edit_comment', $comment_id ) )
     
    828815
    829816    $checkbox = ( isset($_POST['checkbox']) && true == $_POST['checkbox'] ) ? 1 : 0;
    830     $wp_list_table = _get_list_table( $checkbox ? 'WP_Comments_List_Table' : 'WP_Post_Comments_List_Table' );
     817    $wp_list_table = _get_list_table( $checkbox ? 'WP_Comments_List_Table' : 'WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) );
    831818
    832819    $comment = get_comment( $comment_id );
     
    13311318    }
    13321319
    1333     set_current_screen( $_POST['screen'] );
    1334 
    13351320    if ( $last = wp_check_post_lock( $post_ID ) ) {
    13361321        $last_user = get_userdata( $last );
     
    13681353    edit_post();
    13691354
    1370     $wp_list_table = _get_list_table('WP_Posts_List_Table');
     1355    $wp_list_table = _get_list_table( 'WP_Posts_List_Table', array( 'screen' => $_POST['screen'] ) );
    13711356
    13721357    $mode = $_POST['post_view'];
     
    14001385        wp_die( -1 );
    14011386
    1402     set_current_screen( 'edit-' . $taxonomy );
    1403 
    1404     $wp_list_table = _get_list_table('WP_Terms_List_Table');
     1387    $wp_list_table = _get_list_table( 'WP_Terms_List_Table', array( 'screen' => 'edit-' . $taxonomy ) );
    14051388
    14061389    if ( ! isset($_POST['tax_ID']) || ! ( $id = (int) $_POST['tax_ID'] ) )
  • trunk/wp-admin/includes/class-wp-links-list-table.php

    r21789 r21914  
    1010class WP_Links_List_Table extends WP_List_Table {
    1111
    12     function __construct() {
     12    function __construct( $args = array() ) {
    1313        parent::__construct( array(
    1414            'plural' => 'bookmarks',
     15            'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
    1516        ) );
    1617    }
  • trunk/wp-admin/includes/class-wp-list-table.php

    r21789 r21914  
    8282            'plural' => '',
    8383            'singular' => '',
    84             'ajax' => false
     84            'ajax' => false,
     85            'screen' => null,
    8586        ) );
    8687
    87         $screen = get_current_screen();
    88 
    89         add_filter( "manage_{$screen->id}_columns", array( &$this, 'get_columns' ), 0 );
     88        $this->screen = convert_to_screen( $args['screen'] );
     89
     90        add_filter( "manage_{$this->screen->id}_columns", array( &$this, 'get_columns' ), 0 );
    9091
    9192        if ( !$args['plural'] )
    92             $args['plural'] = $screen->base;
     93            $args['plural'] = $this->screen->base;
    9394
    9495        $args['plural'] = sanitize_key( $args['plural'] );
     
    243244     */
    244245    function views() {
    245         $screen = get_current_screen();
    246 
    247246        $views = $this->get_views();
    248         $views = apply_filters( 'views_' . $screen->id, $views );
     247        $views = apply_filters( 'views_' . $this->screen->id, $views );
    249248
    250249        if ( empty( $views ) )
     
    279278     */
    280279    function bulk_actions() {
    281         $screen = get_current_screen();
    282 
    283280        if ( is_null( $this->_actions ) ) {
    284281            $no_new_actions = $this->_actions = $this->get_bulk_actions();
    285282            // This filter can currently only be used to remove actions.
    286             $this->_actions = apply_filters( 'bulk_actions-' . $screen->id, $this->_actions );
     283            $this->_actions = apply_filters( 'bulk_actions-' . $this->screen->id, $this->_actions );
    287284            $this->_actions = array_intersect_assoc( $this->_actions, $no_new_actions );
    288285            $two = '';
     
    605602            return $this->_column_headers;
    606603
    607         $screen = get_current_screen();
    608 
    609         $columns = get_column_headers( $screen );
    610         $hidden = get_hidden_columns( $screen );
    611 
    612         $_sortable = apply_filters( "manage_{$screen->id}_sortable_columns", $this->get_sortable_columns() );
     604        $columns = get_column_headers( $this->screen );
     605        $hidden = get_hidden_columns( $this->screen );
     606
     607        $_sortable = apply_filters( "manage_{$this->screen->id}_sortable_columns", $this->get_sortable_columns() );
    613608
    614609        $sortable = array();
     
    652647     */
    653648    function print_column_headers( $with_id = true ) {
    654         $screen = get_current_screen();
    655 
    656649        list( $columns, $hidden, $sortable ) = $this->get_column_info();
    657650
     
    915908     */
    916909    function _js_vars() {
    917         $current_screen = get_current_screen();
    918 
    919910        $args = array(
    920911            'class'  => get_class( $this ),
    921912            'screen' => array(
    922                 'id'   => $current_screen->id,
    923                 'base' => $current_screen->base,
     913                'id'   => $this->screen->id,
     914                'base' => $this->screen->base,
    924915            )
    925916        );
  • trunk/wp-admin/includes/class-wp-media-list-table.php

    r21880 r21914  
    1010class WP_Media_List_Table extends WP_List_Table {
    1111
    12     function __construct() {
     12    function __construct( $args = array() ) {
    1313        $this->detached = isset( $_REQUEST['detached'] ) || isset( $_REQUEST['find_detached'] );
    1414
    1515        parent::__construct( array(
    16             'plural' => 'media'
     16            'plural' => 'media',
     17            'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
    1718        ) );
    1819    }
  • trunk/wp-admin/includes/class-wp-ms-sites-list-table.php

    r21414 r21914  
    1010class WP_MS_Sites_List_Table extends WP_List_Table {
    1111
    12     function __construct() {
     12    function __construct( $args = array() ) {
    1313        parent::__construct( array(
    1414            'plural' => 'sites',
     15            'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
    1516        ) );
    1617    }
  • trunk/wp-admin/includes/class-wp-ms-themes-list-table.php

    r21755 r21914  
    1313    var $is_site_themes;
    1414
    15     function __construct() {
     15    function __construct( $args = array() ) {
    1616        global $status, $page;
     17
     18        parent::__construct( array(
     19            'plural' => 'themes',
     20            'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
     21        ) );
    1722
    1823        $status = isset( $_REQUEST['theme_status'] ) ? $_REQUEST['theme_status'] : 'all';
     
    2227        $page = $this->get_pagenum();
    2328
    24         $screen = get_current_screen();
    25         $this->is_site_themes = ( 'site-themes-network' == $screen->id ) ? true : false;
     29        $this->is_site_themes = ( 'site-themes-network' == $this->screen->id ) ? true : false;
    2630
    2731        if ( $this->is_site_themes )
    2832            $this->site_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
    29 
    30         parent::__construct( array(
    31             'plural' => 'themes'
    32         ) );
    3333    }
    3434
  • 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
  • trunk/wp-admin/includes/class-wp-posts-list-table.php

    r21806 r21914  
    4646    var $sticky_posts_count = 0;
    4747
    48     function __construct() {
     48    function __construct( $args = array() ) {
    4949        global $post_type_object, $wpdb;
    5050
    51         $post_type = get_current_screen()->post_type;
     51        parent::__construct( array(
     52            'plural' => 'posts',
     53            'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
     54        ) );
     55
     56        $post_type = $this->screen->post_type;
    5257        $post_type_object = get_post_type_object( $post_type );
    5358
     
    6772            $this->sticky_posts_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( 1 ) FROM $wpdb->posts WHERE post_type = %s AND post_status != 'trash' AND ID IN ($sticky_posts)", $post_type ) );
    6873        }
    69 
    70         parent::__construct( array(
    71             'plural' => 'posts',
    72         ) );
    7374    }
    7475
    7576    function ajax_user_can() {
    76         global $post_type_object;
    77 
    78         return current_user_can( $post_type_object->cap->edit_posts );
     77        return current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_posts );
    7978    }
    8079
    8180    function prepare_items() {
    82         global $post_type_object, $avail_post_stati, $wp_query, $per_page, $mode;
     81        global $avail_post_stati, $wp_query, $per_page, $mode;
    8382
    8483        $avail_post_stati = wp_edit_posts_query();
    8584
    86         $this->hierarchical_display = ( $post_type_object->hierarchical && 'menu_order title' == $wp_query->query['orderby'] );
     85        $this->hierarchical_display = ( is_post_type_hierarchical( $this->screen->post_type ) && 'menu_order title' == $wp_query->query['orderby'] );
    8786
    8887        $total_items = $this->hierarchical_display ? $wp_query->post_count : $wp_query->found_posts;
    8988
    90         $post_type = $post_type_object->name;
     89        $post_type = $this->screen->post_type;
    9190        $per_page = $this->get_items_per_page( 'edit_' . $post_type . '_per_page' );
    9291        $per_page = apply_filters( 'edit_posts_per_page', $per_page, $post_type );
     
    113112
    114113    function no_items() {
    115         global $post_type_object;
    116 
    117114        if ( isset( $_REQUEST['post_status'] ) && 'trash' == $_REQUEST['post_status'] )
    118             echo $post_type_object->labels->not_found_in_trash;
     115            echo get_post_type_object( $this->screen->post_type )->labels->not_found_in_trash;
    119116        else
    120             echo $post_type_object->labels->not_found;
     117            echo get_post_type_object( $this->screen->post_type )->labels->not_found;
    121118    }
    122119
    123120    function get_views() {
    124         global $post_type_object, $locked_post_status, $avail_post_stati;
    125 
    126         $post_type = $post_type_object->name;
     121        global $locked_post_status, $avail_post_stati;
     122
     123        $post_type = $this->screen->post_type;
    127124
    128125        if ( !empty($locked_post_status) )
     
    199196
    200197    function extra_tablenav( $which ) {
    201         global $post_type_object, $cat;
     198        global $cat;
    202199?>
    203200        <div class="alignleft actions">
     
    205202        if ( 'top' == $which && !is_singular() ) {
    206203
    207             $this->months_dropdown( $post_type_object->name );
    208 
    209             if ( is_object_in_taxonomy( $post_type_object->name, 'category' ) ) {
     204            $this->months_dropdown( $this->screen->post_type );
     205
     206            if ( is_object_in_taxonomy( $this->screen->post_type, 'category' ) ) {
    210207                $dropdown_options = array(
    211208                    'show_option_all' => __( 'View all categories' ),
     
    222219        }
    223220
    224         if ( $this->is_trash && current_user_can( $post_type_object->cap->edit_others_posts ) ) {
     221        if ( $this->is_trash && current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_others_posts ) ) {
    225222            submit_button( __( 'Empty Trash' ), 'small apply', 'delete_all', false );
    226223        }
     
    238235
    239236    function pagination( $which ) {
    240         global $post_type_object, $mode;
     237        global $mode;
    241238
    242239        parent::pagination( $which );
    243240
    244         if ( 'top' == $which && !$post_type_object->hierarchical )
     241        if ( 'top' == $which && ! is_post_type_hierarchical( $this->screen->post_type ) )
    245242            $this->view_switcher( $mode );
    246243    }
    247244
    248245    function get_table_classes() {
    249         global $post_type_object;
    250 
    251         return array( 'widefat', 'fixed', $post_type_object->hierarchical ? 'pages' : 'posts' );
     246        return array( 'widefat', 'fixed', is_post_type_hierarchical( $this->screen->post_type ) ? 'pages' : 'posts' );
    252247    }
    253248
    254249    function get_columns() {
    255         $screen = get_current_screen();
    256 
    257         if ( empty( $screen ) )
    258             $post_type = 'post';
    259         else
    260             $post_type = $screen->post_type;
     250        $post_type = $this->screen->post_type;
    261251
    262252        $posts_columns = array();
     
    314304
    315305    function display_rows( $posts = array(), $level = 0 ) {
    316         global $wp_query, $post_type_object, $per_page;
     306        global $wp_query, $per_page;
    317307
    318308        if ( empty( $posts ) )
     
    702692        global $mode;
    703693
    704         $screen = get_current_screen();
     694        $screen = $this->screen;
    705695
    706696        $post = get_default_post_to_edit( $screen->post_type );
     
    734724        while ( $bulk < 2 ) { ?>
    735725
    736         <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$hclass inline-edit-$screen->post_type ";
    737             echo $bulk ? "bulk-edit-row bulk-edit-row-$hclass bulk-edit-$screen->post_type" : "quick-edit-row quick-edit-row-$hclass inline-edit-$screen->post_type";
     726        <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$hclass inline-edit-" . $screen->post_type;
     727            echo $bulk ? "bulk-edit-row bulk-edit-row-$hclass bulk-edit-{$screen->post_type}" : "quick-edit-row quick-edit-row-$hclass inline-edit-{$screen->post_type}";
    738728        ?>" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange">
    739729
  • trunk/wp-admin/includes/class-wp-terms-list-table.php

    r21323 r21914  
    1212    var $callback_args;
    1313
    14     function __construct() {
    15         global $post_type, $taxonomy, $tax;
    16 
    17         wp_reset_vars( array( 'action', 'taxonomy', 'post_type' ) );
    18 
    19         if ( empty( $taxonomy ) )
    20             $taxonomy = 'post_tag';
    21 
    22         if ( !taxonomy_exists( $taxonomy ) )
    23             wp_die( __( 'Invalid taxonomy' ) );
    24 
    25         $tax = get_taxonomy( $taxonomy );
    26 
    27         if ( empty( $post_type ) || !in_array( $post_type, get_post_types( array( 'show_ui' => true ) ) ) )
    28             $post_type = 'post';
     14    function __construct( $args = array() ) {
     15        global $post_type, $taxonomy, $action, $tax;
    2916
    3017        parent::__construct( array(
    3118            'plural' => 'tags',
    3219            'singular' => 'tag',
     20            'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
    3321        ) );
     22
     23        $action    = $this->screen->action;
     24        $post_type = $this->screen->post_type;
     25        $taxonomy  = $this->screen->taxonomy;
     26
     27        if ( empty( $taxonomy ) )
     28            $taxonomy = 'post_tag';
     29
     30        if ( ! taxonomy_exists( $taxonomy ) )
     31            wp_die( __( 'Invalid taxonomy' ) );
     32
     33        $tax = get_taxonomy( $taxonomy );
     34
     35        // @todo Still needed? Maybe just the show_ui part.
     36        if ( empty( $post_type ) || !in_array( $post_type, get_post_types( array( 'show_ui' => true ) ) ) )
     37            $post_type = 'post';
     38
    3439    }
    3540
    3641    function ajax_user_can() {
    37         global $tax;
    38 
    39         return current_user_can( $tax->cap->manage_terms );
     42        return current_user_can( get_taxonomy( $this->screen->taxonomy )->cap->manage_terms );
    4043    }
    4144
    4245    function prepare_items() {
    43         global $taxonomy;
    44 
    45         $tags_per_page = $this->get_items_per_page( 'edit_' . $taxonomy . '_per_page' );
    46 
    47         if ( 'post_tag' == $taxonomy ) {
     46        $tags_per_page = $this->get_items_per_page( 'edit_' . $this->screen->taxonomy . '_per_page' );
     47
     48        if ( 'post_tag' == $this->screen->taxonomy ) {
    4849            $tags_per_page = apply_filters( 'edit_tags_per_page', $tags_per_page );
    4950            $tags_per_page = apply_filters( 'tagsperpage', $tags_per_page ); // Old filter
    50         } elseif ( 'category' == $taxonomy ) {
     51        } elseif ( 'category' == $this->screen->taxonomy ) {
    5152            $tags_per_page = apply_filters( 'edit_categories_per_page', $tags_per_page ); // Old filter
    5253        }
     
    6970
    7071        $this->set_pagination_args( array(
    71             'total_items' => wp_count_terms( $taxonomy, compact( 'search' ) ),
     72            'total_items' => wp_count_terms( $this->screen->taxonomy, compact( 'search' ) ),
    7273            'per_page' => $tags_per_page,
    7374        ) );
     
    9495
    9596    function get_columns() {
    96         global $taxonomy, $post_type;
    97 
    9897        $columns = array(
    9998            'cb'          => '<input type="checkbox" />',
     
    103102        );
    104103
    105         if ( 'link_category' == $taxonomy ) {
     104        if ( 'link_category' == $this->screen->taxonomy ) {
    106105            $columns['links'] = __( 'Links' );
    107106        } else {
    108             $post_type_object = get_post_type_object( $post_type );
     107            $post_type_object = get_post_type_object( $this->screen->post_type );
    109108            $columns['posts'] = $post_type_object ? $post_type_object->labels->name : __( 'Posts' );
    110109        }
     
    124123
    125124    function display_rows_or_placeholder() {
    126         global $taxonomy;
     125        $taxonomy = $this->screen->taxonomy;
    127126
    128127        $args = wp_parse_args( $this->callback_args, array(
     
    232231
    233232    function column_cb( $tag ) {
    234         global $taxonomy, $tax;
    235 
    236         $default_term = get_option( 'default_' . $taxonomy );
    237 
    238         if ( current_user_can( $tax->cap->delete_terms ) && $tag->term_id != $default_term )
     233        $default_term = get_option( 'default_' . $this->screen->taxonomy );
     234
     235        if ( current_user_can( get_taxonomy( $this->screen->taxonomy )->cap->delete_terms ) && $tag->term_id != $default_term )
    239236            return '<label class="screen-reader-text" for="cb-select-' . $tag->term_id . '">' . sprintf( __( 'Select %s' ), $tag->name ) . '</label>'
    240237                . '<input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" id="cb-select-' . $tag->term_id . '" />';
     
    244241
    245242    function column_name( $tag ) {
    246         global $taxonomy, $tax, $post_type;
     243        $taxonomy = $this->screen->taxonomy;
     244        $tax = get_taxonomy( $taxonomy );
    247245
    248246        $default_term = get_option( 'default_' . $taxonomy );
     
    251249        $name = apply_filters( 'term_name', $pad . ' ' . $tag->name, $tag );
    252250        $qe_data = get_term( $tag->term_id, $taxonomy, OBJECT, 'edit' );
    253         $edit_link = esc_url( get_edit_term_link( $tag->term_id, $taxonomy, $post_type ) );
     251        $edit_link = esc_url( get_edit_term_link( $tag->term_id, $taxonomy, $this->screen->post_type ) );
    254252
    255253        $out = '<strong><a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $name ) ) . '">' . $name . '</a></strong><br />';
     
    285283
    286284    function column_posts( $tag ) {
    287         global $taxonomy, $post_type;
    288 
    289285        $count = number_format_i18n( $tag->count );
    290286
    291         $tax = get_taxonomy( $taxonomy );
    292 
    293         $ptype_object = get_post_type_object( $post_type );
     287        $tax = get_taxonomy( $this->screen->taxonomy );
     288
     289        $ptype_object = get_post_type_object( $this->screen->post_type );
    294290        if ( ! $ptype_object->show_ui )
    295291            return $count;
     
    301297        }
    302298
    303         if ( 'post' != $post_type )
    304             $args['post_type'] = $post_type;
     299        if ( 'post' != $this->screen->post_type )
     300            $args['post_type'] = $this->screen->post_type;
    305301
    306302        return "<a href='" . esc_url ( add_query_arg( $args, 'edit.php' ) ) . "'>$count</a>";
     
    315311
    316312    function column_default( $tag, $column_name ) {
    317         $screen = get_current_screen();
    318 
    319         return apply_filters( "manage_{$screen->taxonomy}_custom_column", '', $column_name, $tag->term_id );
     313        return apply_filters( "manage_{$this->screen->taxonomy}_custom_column", '', $column_name, $tag->term_id );
    320314    }
    321315
     
    326320     */
    327321    function inline_edit() {
    328         global $post_type, $tax;
     322        $tax = get_taxonomy( $this->screen->taxonomy );
    329323
    330324        if ( ! current_user_can( $tax->cap->edit_terms ) )
     
    359353                continue;
    360354
    361             do_action( 'quick_edit_custom_box', $column_name, 'edit-tags', $tax->name );
     355            do_action( 'quick_edit_custom_box', $column_name, 'edit-tags', $this->screen->taxonomy );
    362356        }
    363357
     
    371365            <span class="error" style="display:none;"></span>
    372366            <?php wp_nonce_field( 'taxinlineeditnonce', '_inline_edit', false ); ?>
    373             <input type="hidden" name="taxonomy" value="<?php echo esc_attr( $tax->name ); ?>" />
    374             <input type="hidden" name="post_type" value="<?php echo esc_attr( $post_type ); ?>" />
     367            <input type="hidden" name="taxonomy" value="<?php echo esc_attr( $this->screen->taxonomy ); ?>" />
     368            <input type="hidden" name="post_type" value="<?php echo esc_attr( $this->screen->post_type ); ?>" />
    375369            <br class="clear" />
    376370        </p>
  • trunk/wp-admin/includes/class-wp-themes-list-table.php

    r21816 r21914  
    1313    var $features = array();
    1414
    15     function __construct() {
     15    function __construct( $args = array() ) {
    1616        parent::__construct( array(
    1717            'ajax' => true,
     18            'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
    1819        ) );
    1920    }
  • trunk/wp-admin/includes/class-wp-users-list-table.php

    r21864 r21914  
    1313    var $is_site_users;
    1414
    15     function __construct() {
    16         $screen = get_current_screen();
    17         $this->is_site_users = 'site-users-network' == $screen->id;
    18 
    19         if ( $this->is_site_users )
    20             $this->site_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
    21 
     15    function __construct( $args = array() ) {
    2216        parent::__construct( array(
    2317            'singular' => 'user',
    24             'plural'   => 'users'
     18            'plural'   => 'users',
     19            'screen'   => isset( $args['screen'] ) ? $args['screen'] : null,
    2520        ) );
     21
     22        $this->is_site_users = 'site-users-network' == $this->screen->id;
     23
     24        if ( $this->is_site_users )
     25            $this->site_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
    2626    }
    2727
  • trunk/wp-admin/includes/list-table.php

    r20094 r21914  
    1515 *
    1616 * @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'.
    1718 * @return object|bool Object on success, false if the class does not exist.
    1819 */
    19 function _get_list_table( $class ) {
     20function _get_list_table( $class, $args = array() ) {
    2021    $core_classes = array(
    2122        //Site Admin
     
    4041        foreach ( (array) $core_classes[ $class ] as $required )
    4142            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        else
     47            $args['screen'] = get_current_screen();
     48
     49        return new $class( $args );
    4350    }
    4451
Note: See TracChangeset for help on using the changeset viewer.