Make WordPress Core

Changeset 15528


Ignore:
Timestamp:
08/25/2010 12:51:44 AM (14 years ago)
Author:
scribu
Message:

Introduce get_list_table(). See #14579

Location:
trunk/wp-admin
Files:
16 edited

Legend:

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

    r15519 r15528  
    5252switch ( $action = $_GET['action'] ) :
    5353case 'fetch-list' :
    54     require_once( './includes/default-list-tables.php' );
     54    require_once( ABSPATH . '/wp-admin/includes/default-list-tables.php' );
    5555
    5656    $class = $_GET['list_args']['class'];
    5757
    5858    if ( class_exists( $class ) ) {
    59         global $current_screen;
    6059        $current_screen = (object) $_GET['list_args']['screen'];
    6160        $wp_list_table = new $class;
     
    558557        set_current_screen($_POST['screen']);
    559558
    560     require_once( './includes/default-list-tables.php' );
    561     $wp_list_table = new WP_Terms_Table();
     559    $wp_list_table = get_list_table('terms');
    562560
    563561    $level = 0;
     
    626624        die('-1');
    627625
    628     require_once( './includes/default-list-tables.php' );
    629     $wp_list_table = new WP_Comments_Table();
     626    $wp_list_table = get_list_table('comments');
    630627    $wp_list_table->prepare_items();
    631628
     
    655652        die('-1');
    656653
    657     require_once( './includes/default-list-tables.php' );
    658     $wp_list_table = new WP_Comments_Table();
     654    $wp_list_table = get_list_table('comments');
    659655    $wp_list_table->prepare_items();
    660656
     
    680676    check_ajax_referer( $action, '_ajax_nonce-replyto-comment' );
    681677
    682     require_once( './includes/default-list-tables.php' );
    683     $wp_list_table = new WP_Comments_Table();
     678    $wp_list_table = get_list_table('comments');
    684679
    685680    $comment_post_ID = (int) $_POST['comment_post_ID'];
     
    762757    $comments_listing = isset($_POST['comments_listing']) ? $_POST['comments_listing'] : '';
    763758
    764     require_once( './includes/default-list-tables.php' );
    765     $wp_list_table = new WP_Comments_Table();
     759    $wp_list_table = get_list_table('comments');
    766760
    767761    ob_start();
     
    911905    $user_object = new WP_User( $user_id );
    912906
    913     require_once( './includes/default-list-tables.php' );
    914     $wp_list_table = new WP_Users_Table();
     907    $wp_list_table = get_list_table('users');
    915908
    916909    $x = new WP_Ajax_Response( array(
     
    12041197    edit_post();
    12051198
    1206     require_once( './includes/default-list-tables.php' );
    1207     $wp_list_table = new WP_Posts_Table();
     1199    $wp_list_table = get_list_table('posts');
    12081200
    12091201    $mode = $_POST['post_view'];
     
    12151207    check_ajax_referer( 'taxinlineeditnonce', '_inline_edit' );
    12161208
    1217     require_once( './includes/default-list-tables.php' );
    1218     $wp_list_table = new WP_Terms_Table();
     1209    $wp_list_table = get_list_table('terms');
    12191210
    12201211    $wp_list_table->check_permissions('edit');
  • trunk/wp-admin/edit-comments.php

    r15519 r15528  
    1010require_once('./admin.php');
    1111
    12 require_once( './includes/default-list-tables.php' );
    13 
    14 $wp_list_table = new WP_Comments_Table;
     12$wp_list_table = get_list_table('comments');
    1513$wp_list_table->check_permissions();
    1614
  • trunk/wp-admin/edit-tags.php

    r15519 r15528  
    1010require_once('./admin.php');
    1111
    12 require_once( './includes/default-list-tables.php' );
    13 
    14 $wp_list_table = new WP_Terms_Table;
     12$wp_list_table = get_list_table('terms');
    1513$wp_list_table->check_permissions();
    1614
  • trunk/wp-admin/edit.php

    r15523 r15528  
    1010require_once( './admin.php' );
    1111
    12 require_once( './includes/default-list-tables.php' );
    13 
    14 $wp_list_table = new WP_Posts_Table;
     12$wp_list_table = get_list_table('posts');
    1513$wp_list_table->check_permissions();
    1614
  • trunk/wp-admin/includes/list-table.php

    r15517 r15528  
    629629
    630630    /**
    631      * Handle an incoming ajax request ( called from admin-ajax.php )
    632      *
     631     * Handle an incoming ajax request (called from admin-ajax.php)
     632     *
     633     * @since 3.1.0
    633634     * @access public
    634635     */
     
    666667    }
    667668}
     669
     670/**
     671 * Fetch an instance of a WP_List_Table class
     672 *
     673 * @since 3.1.0
     674 *
     675 * @param string $type The type of the list table
     676 * @return object
     677 */
     678function get_list_table( $type ) {
     679    require_once( ABSPATH . '/wp-admin/includes/default-list-tables.php' );
     680
     681    $type = strtr( ucwords( strtr( $type, '-', ' ') ), ' ', '_' );
     682
     683    $class = "WP_{$type}_Table";
     684    $class = apply_filters( "get_list_table_$type", $class );
     685
     686    return new $class;
     687}
     688
  • trunk/wp-admin/includes/meta-boxes.php

    r15519 r15528  
    463463    add_filter('manage_edit-comments_sortable_columns', create_function('', 'return array();'), 8);
    464464
    465     require_once( './includes/default-list-tables.php' );
    466     $wp_list_table = new WP_Comments_Table;
     465    $wp_list_table = get_list_table('comments');
    467466?>
    468467
  • trunk/wp-admin/includes/template.php

    r15519 r15528  
    294294    }
    295295
    296     require_once( './includes/default-list-tables.php' );
    297     $wp_list_table = new WP_Comments_Table( 'reply' );
     296    $wp_list_table = get_list_table('comments');
    298297
    299298    $columns = $wp_list_table->get_column_headers();
  • trunk/wp-admin/link-manager.php

    r15519 r15528  
    1010require_once ('admin.php');
    1111
    12 require_once( './includes/default-list-tables.php' );
    13 
    14 $wp_list_table = new WP_Links_Table;
     12$wp_list_table = get_list_table('links');
    1513$wp_list_table->check_permissions();
    1614
  • trunk/wp-admin/network/sites.php

    r15519 r15528  
    1313    wp_die( __( 'Multisite support is not enabled.' ) );
    1414
    15 require_once( '../includes/default-list-tables.php' );
    16 
    17 $wp_list_table = new WP_Sites_Table;
     15$wp_list_table = get_list_table('sites');
    1816$wp_list_table->check_permissions();
    1917
  • trunk/wp-admin/network/users.php

    r15519 r15528  
    1010require_once( './admin.php' );
    1111
    12 require_once( '../includes/default-list-tables.php' );
    13 
    14 $wp_list_table = new WP_MS_Users_Table;
     12$wp_list_table = get_list_table('ms-users');
    1513$wp_list_table->check_permissions();
    1614$wp_list_table->prepare_items();
  • trunk/wp-admin/plugin-install.php

    r15519 r15528  
    1010require_once('./admin.php');
    1111
    12 require_once( './includes/default-list-tables.php' );
    13 
    14 $wp_list_table = new WP_Plugin_Install_Table;
     12$wp_list_table = get_list_table('plugin-install');
    1513$wp_list_table->check_permissions();
    1614$wp_list_table->prepare_items();
  • trunk/wp-admin/plugins.php

    r15527 r15528  
    1010require_once('./admin.php');
    1111
    12 require_once( ABSPATH . 'wp-admin/includes/default-list-tables.php' );
    13 
    14 $wp_list_table = new WP_Plugins_Table;
     12$wp_list_table = get_list_table('plugins');
    1513$wp_list_table->check_permissions();
    1614
  • trunk/wp-admin/theme-install.php

    r15519 r15528  
    1010require_once('./admin.php');
    1111
    12 require_once( './includes/default-list-tables.php' );
    13 
    14 $wp_list_table = new WP_Theme_Install_Table;
     12$wp_list_table = get_list_table('theme-install');
    1513$wp_list_table->check_permissions();
    1614$wp_list_table->prepare_items();
  • trunk/wp-admin/themes.php

    r15519 r15528  
    1010require_once('./admin.php');
    1111
    12 require_once( './includes/default-list-tables.php' );
    13 
    14 $wp_list_table = new WP_Themes_Table;
     12$wp_list_table = get_list_table('themes');
    1513$wp_list_table->check_permissions();
    1614
  • trunk/wp-admin/upload.php

    r15519 r15528  
    1010require_once( './admin.php' );
    1111
    12 require_once( './includes/default-list-tables.php' );
    13 
    14 $wp_list_table = new WP_Media_Table;
     12$wp_list_table = get_list_table('media');
    1513$wp_list_table->check_permissions();
    1614
  • trunk/wp-admin/users.php

    r15519 r15528  
    1313require_once( ABSPATH . WPINC . '/registration.php');
    1414
    15 require_once( './includes/default-list-tables.php' );
    16 
    17 $wp_list_table = new WP_Users_Table;
     15$wp_list_table = get_list_table('users');
    1816$wp_list_table->check_permissions();
    1917
Note: See TracChangeset for help on using the changeset viewer.