Make WordPress Core


Ignore:
Timestamp:
09/19/2012 12:43:31 PM (13 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-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        );
Note: See TracChangeset for help on using the changeset viewer.