WordPress.org

Make WordPress Core


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