Make WordPress Core

Ticket #21742: 21742.5.diff

File 21742.5.diff, 38.1 KB (added by nacin, 12 years ago)
  • class-wp-ms-sites-list-table.php

     
    99 */
    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        }
    1718
  • class-wp-posts-list-table.php

     
    4545         */
    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
    5459                if ( !current_user_can( $post_type_object->cap->edit_others_posts ) ) {
     
    6671                        $sticky_posts = implode( ', ', array_map( 'absint', (array) $sticky_posts ) );
    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 );
    9392
     
    112111        }
    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;
     121                global $locked_post_status, $avail_post_stati;
    125122
    126                 $post_type = $post_type_object->name;
     123                $post_type = $this->screen->post_type;
    127124
    128125                if ( !empty($locked_post_status) )
    129126                        return array();
     
    198195        }
    199196
    200197        function extra_tablenav( $which ) {
    201                 global $post_type_object, $cat;
     198                global $cat;
    202199?>
    203200                <div class="alignleft actions">
    204201<?php
    205202                if ( 'top' == $which && !is_singular() ) {
    206203
    207                         $this->months_dropdown( $post_type_object->name );
     204                        $this->months_dropdown( $this->screen->post_type );
    208205
    209                         if ( is_object_in_taxonomy( $post_type_object->name, 'category' ) ) {
     206                        if ( is_object_in_taxonomy( $this->screen->post_type, 'category' ) ) {
    210207                                $dropdown_options = array(
    211208                                        'show_option_all' => __( 'View all categories' ),
    212209                                        'hide_empty' => 0,
     
    221218                        submit_button( __( 'Filter' ), 'secondary', false, false, array( 'id' => 'post-query-submit' ) );
    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( $post_type )->cap->edit_others_posts ) ) {
    225222                        submit_button( __( 'Empty Trash' ), 'button-secondary apply', 'delete_all', false );
    226223                }
    227224?>
     
    237234        }
    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();
     250                $post_type = $this->screen->post_type;
    256251
    257                 if ( empty( $screen ) )
    258                         $post_type = 'post';
    259                 else
    260                         $post_type = $screen->post_type;
    261 
    262252                $posts_columns = array();
    263253
    264254                $posts_columns['cb'] = '<input type="checkbox" />';
     
    301291        }
    302292
    303293        function display_rows( $posts = array(), $level = 0 ) {
    304                 global $wp_query, $post_type_object, $per_page;
     294                global $wp_query, $per_page;
    305295
    306296                if ( empty( $posts ) )
    307297                        $posts = $wp_query->posts;
     
    529519                                }
    530520                                else {
    531521                                        $attributes = 'class="post-title page-title column-title"' . $style;
    532                                        
     522
    533523                                        $pad = str_repeat( '&#8212; ', $level );
    534524?>
    535525                        <td <?php echo $attributes ?>><strong><?php if ( $can_edit_post && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $title ) ); ?>"><?php echo $pad; echo $title ?></a><?php } else { echo $pad; echo $title; }; _post_states( $post ); ?></strong>
     
    695685        function inline_edit() {
    696686                global $mode;
    697687
    698                 $screen = get_current_screen();
     688                $post = get_default_post_to_edit( $this->screen->post_type );
     689                $post_type_object = get_post_type_object( $this->screen->post_type );
    699690
    700                 $post = get_default_post_to_edit( $screen->post_type );
    701                 $post_type_object = get_post_type_object( $screen->post_type );
    702 
    703                 $taxonomy_names = get_object_taxonomies( $screen->post_type );
     691                $taxonomy_names = get_object_taxonomies( $this->screen->post_type );
    704692                $hierarchical_taxonomies = array();
    705693                $flat_taxonomies = array();
    706694                foreach ( $taxonomy_names as $taxonomy_name ) {
     
    727715                $bulk = 0;
    728716                while ( $bulk < 2 ) { ?>
    729717
    730                 <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$hclass inline-edit-$screen->post_type ";
    731                         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";
     718                <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$hclass inline-edit-$this->screen->post_type ";
     719                        echo $bulk ? "bulk-edit-row bulk-edit-row-$hclass bulk-edit-$this->screen->post_type" : "quick-edit-row quick-edit-row-$hclass inline-edit-$this->screen->post_type";
    732720                ?>" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange">
    733721
    734722                <fieldset class="inline-edit-col-left"><div class="inline-edit-col">
    735723                        <h4><?php echo $bulk ? __( 'Bulk Edit' ) : __( 'Quick Edit' ); ?></h4>
    736724        <?php
    737725
    738         if ( post_type_supports( $screen->post_type, 'title' ) ) :
     726        if ( post_type_supports( $this->screen->post_type, 'title' ) ) :
    739727                if ( $bulk ) : ?>
    740728                        <div id="bulk-title-div">
    741729                                <div id="bulk-titles"></div>
     
    764752                        <br class="clear" />
    765753        <?php endif; // $bulk
    766754
    767                 if ( post_type_supports( $screen->post_type, 'author' ) ) :
     755                if ( post_type_supports( $this->screen->post_type, 'author' ) ) :
    768756                        $authors_dropdown = '';
    769757
    770758                        if ( is_super_admin() || current_user_can( $post_type_object->cap->edit_others_posts ) ) :
     
    840828                <fieldset class="inline-edit-col-right"><div class="inline-edit-col">
    841829
    842830        <?php
    843                 if ( post_type_supports( $screen->post_type, 'author' ) && $bulk )
     831                if ( post_type_supports( $this->screen->post_type, 'author' ) && $bulk )
    844832                        echo $authors_dropdown;
    845833
    846                 if ( post_type_supports( $screen->post_type, 'page-attributes' ) ) :
     834                if ( post_type_supports( $this->screen->post_type, 'page-attributes' ) ) :
    847835
    848836                        if ( $post_type_object->hierarchical ) :
    849837                ?>
     
    878866
    879867        <?php   endif; // !$bulk
    880868
    881                         if ( 'page' == $screen->post_type ) :
     869                        if ( 'page' == $this->screen->post_type ) :
    882870        ?>
    883871
    884872                        <label>
     
    911899
    912900        <?php endif; // count( $flat_taxonomies ) && !$bulk  ?>
    913901
    914         <?php if ( post_type_supports( $screen->post_type, 'comments' ) || post_type_supports( $screen->post_type, 'trackbacks' ) ) :
     902        <?php if ( post_type_supports( $this->screen->post_type, 'comments' ) || post_type_supports( $this->screen->post_type, 'trackbacks' ) ) :
    915903                if ( $bulk ) : ?>
    916904
    917905                        <div class="inline-edit-group">
    918                 <?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?>
     906                <?php if ( post_type_supports( $this->screen->post_type, 'comments' ) ) : ?>
    919907                        <label class="alignleft">
    920908                                <span class="title"><?php _e( 'Comments' ); ?></span>
    921909                                <select name="comment_status">
     
    924912                                        <option value="closed"><?php _e( 'Do not allow' ); ?></option>
    925913                                </select>
    926914                        </label>
    927                 <?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?>
     915                <?php endif; if ( post_type_supports( $this->screen->post_type, 'trackbacks' ) ) : ?>
    928916                        <label class="alignright">
    929917                                <span class="title"><?php _e( 'Pings' ); ?></span>
    930918                                <select name="ping_status">
     
    939927        <?php else : // $bulk ?>
    940928
    941929                        <div class="inline-edit-group">
    942                         <?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?>
     930                        <?php if ( post_type_supports( $this->screen->post_type, 'comments' ) ) : ?>
    943931                                <label class="alignleft">
    944932                                        <input type="checkbox" name="comment_status" value="open" />
    945933                                        <span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span>
    946934                                </label>
    947                         <?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?>
     935                        <?php endif; if ( post_type_supports( $this->screen->post_type, 'trackbacks' ) ) : ?>
    948936                                <label class="alignleft">
    949937                                        <input type="checkbox" name="ping_status" value="open" />
    950938                                        <span class="checkbox-title"><?php _e( 'Allow Pings' ); ?></span>
     
    974962                                        </select>
    975963                                </label>
    976964
    977         <?php if ( 'post' == $screen->post_type && $can_publish && current_user_can( $post_type_object->cap->edit_others_posts ) ) : ?>
     965        <?php if ( 'post' == $this->screen->post_type && $can_publish && current_user_can( $post_type_object->cap->edit_others_posts ) ) : ?>
    978966
    979967        <?php   if ( $bulk ) : ?>
    980968
     
    1000988
    1001989                        </div>
    1002990
    1003         <?php if ( post_type_supports( $screen->post_type, 'post-formats' ) && current_theme_supports( 'post-formats' ) ) :
     991        <?php if ( post_type_supports( $this->screen->post_type, 'post-formats' ) && current_theme_supports( 'post-formats' ) ) :
    1004992                $post_formats = get_theme_support( 'post-formats' );
    1005993                if ( isset( $post_formats[0] ) && is_array( $post_formats[0] ) ) :
    1006994                        $all_post_formats = get_post_format_strings();
     
    10331021                foreach ( $columns as $column_name => $column_display_name ) {
    10341022                        if ( isset( $core_columns[$column_name] ) )
    10351023                                continue;
    1036                         do_action( $bulk ? 'bulk_edit_custom_box' : 'quick_edit_custom_box', $column_name, $screen->post_type );
     1024                        do_action( $bulk ? 'bulk_edit_custom_box' : 'quick_edit_custom_box', $column_name, $this->screen->post_type );
    10371025                }
    10381026        ?>
    10391027                <p class="submit inline-edit-save">
     
    10481036                                submit_button( __( 'Update' ), 'button-primary alignright', 'bulk_edit', false, array( 'accesskey' => 's' ) );
    10491037                        } ?>
    10501038                        <input type="hidden" name="post_view" value="<?php echo esc_attr( $m ); ?>" />
    1051                         <input type="hidden" name="screen" value="<?php echo esc_attr( $screen->id ); ?>" />
     1039                        <input type="hidden" name="screen" value="<?php echo esc_attr( $this->screen->id ); ?>" />
    10521040                        <span class="error" style="display:none"></span>
    10531041                        <br class="clear" />
    10541042                </p>
  • list-table.php

     
    1414 * @since 3.1.0
    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
    2223                'WP_Posts_List_Table' => 'posts',
     
    3940        if ( isset( $core_classes[ $class ] ) ) {
    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
    4552        return false;
  • class-wp-media-list-table.php

     
    99 */
    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        }
    1920
  • class-wp-links-list-table.php

     
    99 */
    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        }
    1718
  • class-wp-terms-list-table.php

     
    1111
    1212        var $callback_args;
    1313
    14         function __construct() {
    15                 global $post_type, $taxonomy, $tax;
     14        function __construct( $args = array() ) {
     15                global $post_type, $taxonomy, $action, $tax;
    1616
    17                 wp_reset_vars( array( 'action', 'taxonomy', 'post_type' ) );
     17                parent::__construct( array(
     18                        'plural' => 'tags',
     19                        'singular' => 'tag',
     20                        'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
     21                ) );
    1822
     23                $action    = $this->screen->action;
     24                $post_type = $this->screen->post_type;
     25                $taxonomy  = $this->screen->taxonomy;
     26
     27                // @todo Still needed? Not sure if WP_Screen allows 'taxonomy' to be empty.
    1928                if ( empty( $taxonomy ) )
    2029                        $taxonomy = 'post_tag';
    2130
    22                 if ( !taxonomy_exists( $taxonomy ) )
     31                // @todo Still needed? Not sure if WP_Screen allows for 'taxonomy' to be invalid.
     32                if ( ! taxonomy_exists( $taxonomy ) )
    2333                        wp_die( __( 'Invalid taxonomy' ) );
    2434
    2535                $tax = get_taxonomy( $taxonomy );
    2636
     37                // @todo Still needed? Maybe just the show_ui part.
    2738                if ( empty( $post_type ) || !in_array( $post_type, get_post_types( array( 'show_ui' => true ) ) ) )
    2839                        $post_type = 'post';
    2940
    30                 parent::__construct( array(
    31                         'plural' => 'tags',
    32                         'singular' => 'tag',
    33                 ) );
    3441        }
    3542
    3643        function ajax_user_can() {
    37                 global $tax;
    38 
    39                 return current_user_can( $tax->cap->manage_terms );
     44                return current_user_can( get_taxonomy( $this->screen->taxonomy )->cap->manage_terms );
    4045        }
    4146
    4247        function prepare_items() {
    43                 global $taxonomy;
     48                $tags_per_page = $this->get_items_per_page( 'edit_' . $this->screen->taxonomy . '_per_page' );
    4449
    45                 $tags_per_page = $this->get_items_per_page( 'edit_' . $taxonomy . '_per_page' );
    46 
    47                 if ( 'post_tag' == $taxonomy ) {
     50                if ( 'post_tag' == $this->screen->taxonomy ) {
    4851                        $tags_per_page = apply_filters( 'edit_tags_per_page', $tags_per_page );
    4952                        $tags_per_page = apply_filters( 'tagsperpage', $tags_per_page ); // Old filter
    50                 } elseif ( 'category' == $taxonomy ) {
     53                } elseif ( 'category' == $this->screen->taxonomy ) {
    5154                        $tags_per_page = apply_filters( 'edit_categories_per_page', $tags_per_page ); // Old filter
    5255                }
    5356
     
    6871                $this->callback_args = $args;
    6972
    7073                $this->set_pagination_args( array(
    71                         'total_items' => wp_count_terms( $taxonomy, compact( 'search' ) ),
     74                        'total_items' => wp_count_terms( $this->screen->taxonomy, compact( 'search' ) ),
    7275                        'per_page' => $tags_per_page,
    7376                ) );
    7477        }
     
    9396        }
    9497
    9598        function get_columns() {
    96                 global $taxonomy, $post_type;
    97 
    9899                $columns = array(
    99100                        'cb'          => '<input type="checkbox" />',
    100101                        'name'        => _x( 'Name', 'term name' ),
     
    102103                        'slug'        => __( 'Slug' ),
    103104                );
    104105
    105                 if ( 'link_category' == $taxonomy ) {
     106                if ( 'link_category' == $this->screen->taxonomy ) {
    106107                        $columns['links'] = __( 'Links' );
    107108                } else {
    108                         $post_type_object = get_post_type_object( $post_type );
     109                        $post_type_object = get_post_type_object( $this->screen->post_type );
    109110                        $columns['posts'] = $post_type_object ? $post_type_object->labels->name : __( 'Posts' );
    110111                }
    111112
     
    123124        }
    124125
    125126        function display_rows_or_placeholder() {
    126                 global $taxonomy;
     127                $taxonomy = $this->screen->taxonomy;
    127128
    128129                $args = wp_parse_args( $this->callback_args, array(
    129130                        'page' => 1,
     
    231232        }
    232233
    233234        function column_cb( $tag ) {
    234                 global $taxonomy, $tax;
     235                $default_term = get_option( 'default_' . $this->screen->taxonomy );
    235236
    236                 $default_term = get_option( 'default_' . $taxonomy );
    237 
    238                 if ( current_user_can( $tax->cap->delete_terms ) && $tag->term_id != $default_term )
     237                if ( current_user_can( get_taxonomy( $this->screen->taxonomy )->cap->delete_terms ) && $tag->term_id != $default_term )
    239238                        return '<label class="screen-reader-text" for="cb-select-' . $tag->term_id . '">' . sprintf( __( 'Select %s' ), $tag->name ) . '</label>'
    240239                                . '<input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" id="cb-select-' . $tag->term_id . '" />';
    241240
     
    243242        }
    244243
    245244        function column_name( $tag ) {
    246                 global $taxonomy, $tax, $post_type;
     245                $taxonomy = $this->screen->taxonomy;
     246                $tax = get_taxonomy( $taxonomy );
    247247
    248248                $default_term = get_option( 'default_' . $taxonomy );
    249249
    250250                $pad = str_repeat( '&#8212; ', max( 0, $this->level ) );
    251251                $name = apply_filters( 'term_name', $pad . ' ' . $tag->name, $tag );
    252252                $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 ) );
     253                $edit_link = esc_url( get_edit_term_link( $tag->term_id, $taxonomy, $this->screen->post_type ) );
    254254
    255255                $out = '<strong><a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $name ) ) . '">' . $name . '</a></strong><br />';
    256256
     
    284284        }
    285285
    286286        function column_posts( $tag ) {
    287                 global $taxonomy, $post_type;
    288 
    289287                $count = number_format_i18n( $tag->count );
    290288
    291                 $tax = get_taxonomy( $taxonomy );
     289                $tax = get_taxonomy( $this->screen->taxonomy );
    292290
    293                 $ptype_object = get_post_type_object( $post_type );
     291                $ptype_object = get_post_type_object( $this->screen->post_type );
    294292                if ( ! $ptype_object->show_ui )
    295293                        return $count;
    296294
     
    300298                        $args = array( 'taxonomy' => $tax->name, 'term' => $tag->slug );
    301299                }
    302300
    303                 if ( 'post' != $post_type )
    304                         $args['post_type'] = $post_type;
     301                if ( 'post' != $this->screen->post_type )
     302                        $args['post_type'] = $this->screen->post_type;
    305303
    306304                return "<a href='" . esc_url ( add_query_arg( $args, 'edit.php' ) ) . "'>$count</a>";
    307305        }
     
    314312        }
    315313
    316314        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 );
     315                return apply_filters( "manage_{$this->screen->taxonomy}_custom_column", '', $column_name, $tag->term_id );
    320316        }
    321317
    322318        /**
     
    325321         * @since 3.1.0
    326322         */
    327323        function inline_edit() {
    328                 global $post_type, $tax;
     324                $tax = get_taxonomy( $this->screen->taxonomy );
    329325
    330326                if ( ! current_user_can( $tax->cap->edit_terms ) )
    331327                        return;
     
    358354                        if ( isset( $core_columns[$column_name] ) )
    359355                                continue;
    360356
    361                         do_action( 'quick_edit_custom_box', $column_name, 'edit-tags', $tax->name );
     357                        do_action( 'quick_edit_custom_box', $column_name, 'edit-tags', $this->screen->taxonomy );
    362358                }
    363359
    364360        ?>
     
    370366                        <img class="waiting" style="display:none;" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
    371367                        <span class="error" style="display:none;"></span>
    372368                        <?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 ); ?>" />
     369                        <input type="hidden" name="taxonomy" value="<?php echo esc_attr( $this->screen->taxonomy ); ?>" />
     370                        <input type="hidden" name="post_type" value="<?php echo esc_attr( $this->screen->post_type ); ?>" />
    375371                        <br class="clear" />
    376372                </p>
    377373                </td></tr>
  • ajax-actions.php

     
    2929 * GET-based Ajax handlers.
    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 );
    4540
     
    615610                $x->send();
    616611        }
    617612
    618         set_current_screen( $_POST['screen'] );
     613        $wp_list_table = _get_list_table( 'WP_Terms_List_Table', array( 'screen' => $_POST['screen'] ) );
    619614
    620         $wp_list_table = _get_list_table('WP_Terms_List_Table');
    621 
    622615        $level = 0;
    623616        if ( is_taxonomy_hierarchical($taxonomy) ) {
    624617                $level = count( get_ancestors( $tag->term_id, $taxonomy ) );
     
    686679
    687680        check_ajax_referer( $action );
    688681
    689         set_current_screen( 'edit-comments' );
     682        $wp_list_table = _get_list_table( 'WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) );
    690683
    691         $wp_list_table = _get_list_table('WP_Post_Comments_List_Table');
    692 
    693684        if ( !current_user_can( 'edit_post', $post_id ) )
    694685                wp_die( -1 );
    695686
     
    723714
    724715        check_ajax_referer( $action, '_ajax_nonce-replyto-comment' );
    725716
    726         set_current_screen( 'edit-comments' );
    727 
    728717        $comment_post_ID = (int) $_POST['comment_post_ID'];
    729718        if ( !current_user_can( 'edit_post', $comment_post_ID ) )
    730719                wp_die( -1 );
     
    782771                        _wp_dashboard_recent_comments_row( $comment );
    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 );
    790779                }
     
    811800
    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 ) )
    818805                wp_die( -1 );
     
    827814        $comments_status = isset($_POST['comments_listing']) ? $_POST['comments_listing'] : '';
    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 );
    833820
     
    13281315                        wp_die( __( 'You are not allowed to edit this post.' ) );
    13291316        }
    13301317
    1331         set_current_screen( $_POST['screen'] );
    1332 
    13331318        if ( $last = wp_check_post_lock( $post_ID ) ) {
    13341319                $last_user = get_userdata( $last );
    13351320                $last_user_name = $last_user ? $last_user->display_name : __( 'Someone' );
     
    13651350        // update the post
    13661351        edit_post();
    13671352
    1368         $wp_list_table = _get_list_table('WP_Posts_List_Table');
     1353        $wp_list_table = _get_list_table( 'WP_Posts_List_Table', array( 'screen' => $_POST['screen'] ) );
    13691354
    13701355        $mode = $_POST['post_view'];
    13711356
     
    13971382        if ( ! current_user_can( $tax->cap->edit_terms ) )
    13981383                wp_die( -1 );
    13991384
    1400         set_current_screen( 'edit-' . $taxonomy );
     1385        $wp_list_table = _get_list_table( 'WP_Terms_List_Table', array( 'screen' => 'edit-' . $taxonomy ) );
    14011386
    1402         $wp_list_table = _get_list_table('WP_Terms_List_Table');
    1403 
    14041387        if ( ! isset($_POST['tax_ID']) || ! ( $id = (int) $_POST['tax_ID'] ) )
    14051388                wp_die( -1 );
    14061389
  • class-wp-users-list-table.php

     
    1212        var $site_id;
    1313        var $is_site_users;
    1414
    15         function __construct() {
    16                 $screen = get_current_screen();
    17                 $this->is_site_users = 'site-users-network' == $screen->id;
     15        function __construct( $args = array() ) {
     16                parent::__construct( array(
     17                        'singular' => 'user',
     18                        'plural'   => 'users',
     19                        'screen'   => isset( $args['screen'] ) ? $args['screen'] : null,
     20                ) );
    1821
     22                $this->is_site_users = 'site-users-network' == $this->screen->id;
     23
    1924                if ( $this->is_site_users )
    2025                        $this->site_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
    21 
    22                 parent::__construct( array(
    23                         'singular' => 'user',
    24                         'plural'   => 'users'
    25                 ) );
    2626        }
    2727
    2828        function ajax_user_can() {
  • class-wp-list-table.php

     
    8181                $args = wp_parse_args( $args, array(
    8282                        'plural' => '',
    8383                        'singular' => '',
    84                         'ajax' => false
     84                        'ajax' => false,
     85                        'screen' => null,
    8586                ) );
    8687
    87                 $screen = get_current_screen();
     88                $this->screen = convert_to_screen( $args['screen'] );
    8889
    89                 add_filter( "manage_{$screen->id}_columns", array( &$this, 'get_columns' ), 0 );
     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'] );
    9596                $args['singular'] = sanitize_key( $args['singular'] );
     
    238239         * @access public
    239240         */
    240241        function views() {
    241                 $screen = get_current_screen();
    242 
    243242                $views = $this->get_views();
    244                 $views = apply_filters( 'views_' . $screen->id, $views );
     243                $views = apply_filters( 'views_' . $this->screen->id, $views );
    245244
    246245                if ( empty( $views ) )
    247246                        return;
     
    274273         * @access public
    275274         */
    276275        function bulk_actions() {
    277                 $screen = get_current_screen();
    278 
    279276                if ( is_null( $this->_actions ) ) {
    280277                        $no_new_actions = $this->_actions = $this->get_bulk_actions();
    281278                        // This filter can currently only be used to remove actions.
    282                         $this->_actions = apply_filters( 'bulk_actions-' . $screen->id, $this->_actions );
     279                        $this->_actions = apply_filters( 'bulk_actions-' . $this->screen->id, $this->_actions );
    283280                        $this->_actions = array_intersect_assoc( $this->_actions, $no_new_actions );
    284281                        $two = '';
    285282                } else {
     
    600597                if ( isset( $this->_column_headers ) )
    601598                        return $this->_column_headers;
    602599
    603                 $screen = get_current_screen();
     600                $columns = get_column_headers( $this->screen );
     601                $hidden = get_hidden_columns( $this->screen );
    604602
    605                 $columns = get_column_headers( $screen );
    606                 $hidden = get_hidden_columns( $screen );
     603                $_sortable = apply_filters( "manage_{$this->screen->id}_sortable_columns", $this->get_sortable_columns() );
    607604
    608                 $_sortable = apply_filters( "manage_{$screen->id}_sortable_columns", $this->get_sortable_columns() );
    609 
    610605                $sortable = array();
    611606                foreach ( $_sortable as $id => $data ) {
    612607                        if ( empty( $data ) )
     
    647642         * @param bool $with_id Whether to set the id attribute or not
    648643         */
    649644        function print_column_headers( $with_id = true ) {
    650                 $screen = get_current_screen();
    651 
    652645                list( $columns, $hidden, $sortable ) = $this->get_column_info();
    653646
    654647                $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
     
    910903         * @access private
    911904         */
    912905        function _js_vars() {
    913                 $current_screen = get_current_screen();
    914 
    915906                $args = array(
    916907                        'class'  => get_class( $this ),
    917908                        'screen' => array(
    918                                 'id'   => $current_screen->id,
    919                                 'base' => $current_screen->base,
     909                                'id'   => $this->screen->id,
     910                                'base' => $this->screen->base,
    920911                        )
    921912                );
    922913
  • class-wp-ms-themes-list-table.php

     
    1212        var $site_id;
    1313        var $is_site_themes;
    1414
    15         function __construct() {
     15        function __construct( $args = array() ) {
    1616                global $status, $page;
    1717
     18                parent::__construct( array(
     19                        'plural' => 'themes',
     20                        'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
     21                ) );
     22
    1823                $status = isset( $_REQUEST['theme_status'] ) ? $_REQUEST['theme_status'] : 'all';
    1924                if ( !in_array( $status, array( 'all', 'enabled', 'disabled', 'upgrade', 'search', 'broken' ) ) )
    2025                        $status = 'all';
    2126
    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
    3535        function get_table_classes() {
  • class-wp-plugins-list-table.php

     
    99 */
    1010class WP_Plugins_List_Table extends WP_List_Table {
    1111
    12         function __construct() {
     12        function __construct( $args = array() ) {
    1313                global $status, $page;
    1414
     15                parent::__construct( array(
     16                        'plural' => 'plugins',
     17                        'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
     18                ) );
     19
    1520                $status = 'all';
    1621                if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], array( 'active', 'inactive', 'recently_activated', 'upgrade', 'mustuse', 'dropins', 'search' ) ) )
    1722                        $status = $_REQUEST['plugin_status'];
     
    2025                        $_SERVER['REQUEST_URI'] = add_query_arg('s', stripslashes($_REQUEST['s']) );
    2126
    2227                $page = $this->get_pagenum();
    23 
    24                 parent::__construct( array(
    25                         'plural' => 'plugins',
    26                 ) );
    2728        }
    2829
    2930        function get_table_classes() {
     
    5051                        'dropins' => array()
    5152                );
    5253
    53                 $screen = get_current_screen();
    54 
    55                 if ( ! is_multisite() || ( $screen->is_network && current_user_can('manage_network_plugins') ) ) {
     54                if ( ! is_multisite() || ( $this->screen->is_network && current_user_can('manage_network_plugins') ) ) {
    5655                        if ( apply_filters( 'show_advanced_plugins', true, 'mustuse' ) )
    5756                                $plugins['mustuse'] = get_mu_plugins();
    5857                        if ( apply_filters( 'show_advanced_plugins', true, 'dropins' ) )
     
    7170
    7271                set_transient( 'plugin_slugs', array_keys( $plugins['all'] ), 86400 );
    7372
    74                 if ( ! $screen->is_network ) {
     73                if ( ! $this->screen->is_network ) {
    7574                        $recently_activated = get_option( 'recently_activated', array() );
    7675
    7776                        $one_week = 7*24*60*60;
     
    8382
    8483                foreach ( (array) $plugins['all'] as $plugin_file => $plugin_data ) {
    8584                        // Filter into individual sections
    86                         if ( ! $screen->is_network && is_plugin_active_for_network( $plugin_file ) ) {
     85                        if ( ! $this->screen->is_network && is_plugin_active_for_network( $plugin_file ) ) {
    8786                                unset( $plugins['all'][ $plugin_file ] );
    88                         } elseif ( ( ! $screen->is_network && is_plugin_active( $plugin_file ) )
    89                                 || ( $screen->is_network && is_plugin_active_for_network( $plugin_file ) ) ) {
     87                        } elseif ( ( ! $this->screen->is_network && is_plugin_active( $plugin_file ) )
     88                                || ( $this->screen->is_network && is_plugin_active_for_network( $plugin_file ) ) ) {
    9089                                $plugins['active'][ $plugin_file ] = $plugin_data;
    9190                        } else {
    92                                 if ( !$screen->is_network && isset( $recently_activated[ $plugin_file ] ) ) // Was the plugin recently activated?
     91                                if ( !$this->screen->is_network && isset( $recently_activated[ $plugin_file ] ) ) // Was the plugin recently activated?
    9392                                        $plugins['recently_activated'][ $plugin_file ] = $plugin_data;
    9493                                $plugins['inactive'][ $plugin_file ] = $plugin_data;
    9594                        }
     
    122121                        uasort( $this->items, array( &$this, '_order_callback' ) );
    123122                }
    124123
    125                 $plugins_per_page = $this->get_items_per_page( str_replace( '-', '_', $screen->id . '_per_page' ), 999 );
     124                $plugins_per_page = $this->get_items_per_page( str_replace( '-', '_', $this->screen->id . '_per_page' ), 999 );
    126125
    127126                $start = ( $page - 1 ) * $plugins_per_page;
    128127
     
    234233
    235234                $actions = array();
    236235
    237                 $screen = get_current_screen();
    238 
    239236                if ( 'active' != $status )
    240                         $actions['activate-selected'] = $screen->is_network ? __( 'Network Activate' ) : __( 'Activate' );
     237                        $actions['activate-selected'] = $this->screen->is_network ? __( 'Network Activate' ) : __( 'Activate' );
    241238
    242239                if ( 'inactive' != $status && 'recent' != $status )
    243                         $actions['deactivate-selected'] = $screen->is_network ? __( 'Network Deactivate' ) : __( 'Deactivate' );
     240                        $actions['deactivate-selected'] = $this->screen->is_network ? __( 'Network Deactivate' ) : __( 'Deactivate' );
    244241
    245                 if ( !is_multisite() || $screen->is_network ) {
     242                if ( !is_multisite() || $this->screen->is_network ) {
    246243                        if ( current_user_can( 'update_plugins' ) )
    247244                                $actions['update-selected'] = __( 'Update' );
    248245                        if ( current_user_can( 'delete_plugins' ) && ( 'active' != $status ) )
     
    269266
    270267                echo '<div class="alignleft actions">';
    271268
    272                 $screen = get_current_screen();
    273 
    274                 if ( ! $screen->is_network && 'recently_activated' == $status )
     269                if ( ! $this->screen->is_network && 'recently_activated' == $status )
    275270                        submit_button( __( 'Clear List' ), 'secondary', 'clear-recent-list', false );
    276271                elseif ( 'top' == $which && 'mustuse' == $status )
    277272                        echo '<p>' . sprintf( __( 'Files in the <code>%s</code> directory are executed automatically.' ), str_replace( ABSPATH, '/', WPMU_PLUGIN_DIR ) ) . '</p>';
     
    291286        function display_rows() {
    292287                global $status;
    293288
    294                 $screen = get_current_screen();
    295 
    296                 if ( is_multisite() && !$screen->is_network && in_array( $status, array( 'mustuse', 'dropins' ) ) )
     289                if ( is_multisite() && ! $this->screen->is_network && in_array( $status, array( 'mustuse', 'dropins' ) ) )
    297290                        return;
    298291
    299292                foreach ( $this->items as $plugin_file => $plugin_data )
     
    305298
    306299                $context = $status;
    307300
    308                 $screen = get_current_screen();
    309 
    310301                // preorder
    311302                $actions = array(
    312303                        'deactivate' => '',
     
    335326                        if ( $plugin_data['Description'] )
    336327                                $description .= '<p>' . $plugin_data['Description'] . '</p>';
    337328                } else {
    338                         if ( $screen->is_network )
     329                        if ( $this->screen->is_network )
    339330                                $is_active = is_plugin_active_for_network( $plugin_file );
    340331                        else
    341332                                $is_active = is_plugin_active( $plugin_file );
    342333
    343                         if ( $screen->is_network ) {
     334                        if ( $this->screen->is_network ) {
    344335                                if ( $is_active ) {
    345336                                        if ( current_user_can( 'manage_network_plugins' ) )
    346337                                                $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="' . esc_attr__('Deactivate this plugin') . '">' . __('Network Deactivate') . '</a>';
     
    359350                                        if ( ! is_multisite() && current_user_can('delete_plugins') )
    360351                                                $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="' . esc_attr__('Delete this plugin') . '" class="delete">' . __('Delete') . '</a>';
    361352                                } // end if $is_active
    362                          } // end if $screen->is_network
     353                         } // end if $this->screen->is_network
    363354
    364                         if ( ( ! is_multisite() || $screen->is_network ) && current_user_can('edit_plugins') && is_writable(WP_PLUGIN_DIR . '/' . $plugin_file) )
     355                        if ( ( ! is_multisite() || $this->screen->is_network ) && current_user_can('edit_plugins') && is_writable(WP_PLUGIN_DIR . '/' . $plugin_file) )
    365356                                $actions['edit'] = '<a href="plugin-editor.php?file=' . $plugin_file . '" title="' . esc_attr__('Open this file in the Plugin Editor') . '" class="edit">' . __('Edit') . '</a>';
    366357                } // end if $context
    367358
    368                 $prefix = $screen->is_network ? 'network_admin_' : '';
     359                $prefix = $this->screen->is_network ? 'network_admin_' : '';
    369360                $actions = apply_filters( $prefix . 'plugin_action_links', array_filter( $actions ), $plugin_file, $plugin_data, $context );
    370361                $actions = apply_filters( $prefix . "plugin_action_links_$plugin_file", $actions, $plugin_file, $plugin_data, $context );
    371362
  • class-wp-themes-list-table.php

     
    1212        protected $search_terms = array();
    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        }
    2021