WordPress.org

Make WordPress Core


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

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

File:
1 edited

Legend:

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

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