Make WordPress Core

Ticket #14579: 14579-rework-get_list_table.3.diff

File 14579-rework-get_list_table.3.diff, 11.5 KB (added by scribu, 14 years ago)
  • wp-admin/users.php

     
    1212/** WordPress Registration API */
    1313require_once( ABSPATH . WPINC . '/registration.php');
    1414
    15 $wp_list_table = get_list_table('users');
     15$wp_list_table = get_list_table('WP_Users_Table');
    1616$wp_list_table->check_permissions();
    1717
    1818$title = __('Users');
  • wp-admin/edit-comments.php

     
    99/** WordPress Administration Bootstrap */
    1010require_once('./admin.php');
    1111
    12 $wp_list_table = get_list_table('comments');
     12$wp_list_table = get_list_table('WP_Comments_Table');
    1313$wp_list_table->check_permissions();
    1414
    1515$doaction = $wp_list_table->current_action();
  • wp-admin/admin-ajax.php

     
    5151if ( isset( $_GET['action'] ) ) :
    5252switch ( $action = $_GET['action'] ) :
    5353case 'fetch-list' :
    54         require_once( ABSPATH . '/wp-admin/includes/default-list-tables.php' );
    55         // Temp
    56         require_once( ABSPATH . '/wp-admin/includes/list-table-posts.php' );
    5754
    58         $class = $_GET['list_args']['class'];
     55        $wp_list_table = get_list_table( $_GET['list_args']['class'] );
     56        if ( ! $wp_list_table )
     57                die( '0' );
    5958
    60         if ( class_exists( $class ) ) {
    61                 $current_screen = (object) $_GET['list_args']['screen'];
    62                 $wp_list_table = new $class;
    63                 $wp_list_table->ajax_response();
    64         }
     59        $current_screen = (object) $_GET['list_args']['screen'];
     60        $wp_list_table->ajax_response();
    6561
    66         die('0');
    6762        break;
    6863case 'ajax-tag-search' :
    6964        if ( !current_user_can( 'edit_posts' ) )
     
    558553        if ( isset($_POST['screen']) )
    559554                set_current_screen($_POST['screen']);
    560555
    561         $wp_list_table = get_list_table('terms');
     556        $wp_list_table = get_list_table('WP_Terms_Table');
    562557
    563558        $level = 0;
    564559        if ( is_taxonomy_hierarchical($taxonomy) ) {
     
    622617        if ( !current_user_can( 'edit_posts' ) )
    623618                die('-1');
    624619
    625         $wp_list_table = get_list_table('comments');
     620        $wp_list_table = get_list_table('WP_Comments_Table');
    626621        $wp_list_table->from_ajax = true;
    627622
    628623        $wp_list_table->prepare_items();
     
    651646        if ( !current_user_can( 'edit_post', $post_ID ) )
    652647                die('-1');
    653648
    654         $wp_list_table = get_list_table('post-comments');
     649        $wp_list_table = get_list_table('WP_Post_Comments_Table');
    655650
    656651        $wp_list_table->prepare_items();
    657652
     
    676671case 'replyto-comment' :
    677672        check_ajax_referer( $action, '_ajax_nonce-replyto-comment' );
    678673
    679         $wp_list_table = get_list_table('comments');
     674        $wp_list_table = get_list_table('WP_Comments_Table');
    680675        $wp_list_table->checkbox = ( isset($_POST['checkbox']) && true == $_POST['checkbox'] ) ? 1 : 0;
    681676
    682677        $comment_post_ID = (int) $_POST['comment_post_ID'];
     
    757752        $comments_status = isset($_POST['comments_listing']) ? $_POST['comments_listing'] : '';
    758753
    759754        $checkbox = ( isset($_POST['checkbox']) && true == $_POST['checkbox'] ) ? 1 : 0;
    760         $wp_list_table = get_list_table( $checkbox ? 'comments' : 'post-comments' );
     755        $wp_list_table = get_list_table( $checkbox ? 'WP_Comments_Table' : 'WP_Post_Comments_Table' );
    761756
    762757        ob_start();
    763758                $wp_list_table->single_row( get_comment( $comment_id ) );
     
    905900        }
    906901        $user_object = new WP_User( $user_id );
    907902
    908         $wp_list_table = get_list_table('users');
     903        $wp_list_table = get_list_table('WP_Users_Table');
    909904
    910905        $x = new WP_Ajax_Response( array(
    911906                'what' => 'user',
     
    12041199        // update the post
    12051200        edit_post();
    12061201
    1207         $wp_list_table = get_list_table('posts');
     1202        $wp_list_table = get_list_table('WP_Posts_Table');
    12081203
    12091204        $mode = $_POST['post_view'];
    12101205        $wp_list_table->display_rows( array( get_post( $_POST['post_ID'] ) ) );
     
    12141209case 'inline-save-tax':
    12151210        check_ajax_referer( 'taxinlineeditnonce', '_inline_edit' );
    12161211
    1217         $wp_list_table = get_list_table('terms');
     1212        $wp_list_table = get_list_table('WP_Terms_Table');
    12181213
    12191214        $wp_list_table->check_permissions('edit');
    12201215
  • wp-admin/includes/class-wp-list-table.php

     
    815815 *
    816816 * @since 3.1.0
    817817 *
    818  * @param string $type The type of the list table
    819  * @return object
     818 * @param string $class The type of the list table, which is the class name except for core list tables.
     819 * @return object|bool Object on success, false if the class does not exist.
    820820 */
    821 function get_list_table( $type ) {
     821function get_list_table( $class ) {
    822822        require_once( ABSPATH . '/wp-admin/includes/default-list-tables.php' );
    823         // Temp
    824         require_once( ABSPATH . '/wp-admin/includes/list-table-posts.php' );
    825823
    826         $class = 'WP_' . strtr( ucwords( strtr( $type, '-', ' ') ), ' ', '_' ) . '_Table';
    827         $class = apply_filters( "get_list_table_$type", $class );
     824        $class = apply_filters( 'get_list_table', $class );
    828825
    829         return new $class;
     826        require_list_table( $class );
     827
     828        if ( class_exists( $class ) )
     829                return new $class;
     830        return false;
    830831}
    831832
     833/**
     834 * Include the proper file for a core list table.
     835 *
     836 * Useful for extending a core class that would not otherwise be required.
     837 *
     838 * @since 3.1.0
     839 * @uses do_action() Calls 'require_list_table_$class' if not a core class to allow
     840 *      a plugin to conditionally include a class when needed.
     841 *
     842 * @param string $table The core table to include.
     843 */
     844function require_list_table( $class ) {
     845        $core_classes = array( 'WP_Posts_Table', 'WP_Media_Table', 'WP_Terms_Table', 'WP_Users_Table',
     846                'WP_Comments_Table', 'WP_Post_Comments_Table', 'WP_Links_Table', 'WP_Sites_Table', 'WP_MS_Users_Table',
     847                'WP_Plugins_Table', 'WP_Plugin_Install_Table', 'WP_Themes_Table', 'WP_Theme_Install_Table' );
     848
     849        if ( in_array( $class, $core_classes ) ) {
     850                $class = strtolower( str_replace( '_', '-', substr( $class, 3, -6 ) ) );
     851                require_once( ABSPATH . '/wp-admin/includes/list-table-' . $class . '.php' );
     852        } else {
     853                do_action( "require_list_table_$class" );
     854        }
     855}
     856
     857?>
  • wp-admin/includes/meta-boxes.php

     
    461461
    462462        wp_nonce_field( 'get-comments', 'add_comment_nonce', false );
    463463
    464         $wp_list_table = get_list_table('post-comments');
     464        $wp_list_table = get_list_table('WP_Post_Comments_Table');
    465465?>
    466466
    467467<table class="widefat comments-box fixed" cellspacing="0" style="display:none;">
  • wp-admin/includes/template.php

     
    329329                return;
    330330        }
    331331
    332         $wp_list_table = get_list_table('comments');
     332        $wp_list_table = get_list_table('WP_Comments_Table');
    333333
    334334        list ( $columns, $hidden ) = $wp_list_table->get_column_info();
    335335        $hidden = array_intersect( array_keys( $columns ), array_filter( $hidden ) );
  • wp-admin/edit-tags.php

     
    99/** WordPress Administration Bootstrap */
    1010require_once('./admin.php');
    1111
    12 $wp_list_table = get_list_table('terms');
     12$wp_list_table = get_list_table('WP_Terms_Table');
    1313$wp_list_table->check_permissions();
    1414
    1515$title = $tax->labels->name;
  • wp-admin/upload.php

     
    99/** WordPress Administration Bootstrap */
    1010require_once( './admin.php' );
    1111
    12 $wp_list_table = get_list_table('media');
     12$wp_list_table = get_list_table('WP_Media_Table');
    1313$wp_list_table->check_permissions();
    1414
    1515// Handle bulk actions
  • wp-admin/plugin-install.php

     
    99/** WordPress Administration Bootstrap */
    1010require_once('./admin.php');
    1111
    12 $wp_list_table = get_list_table('plugin-install');
     12$wp_list_table = get_list_table('WP_Plugin_Install_Table');
    1313$wp_list_table->check_permissions();
    1414$wp_list_table->prepare_items();
    1515
  • wp-admin/network/users.php

     
    99
    1010require_once( './admin.php' );
    1111
    12 $wp_list_table = get_list_table('ms-users');
     12$wp_list_table = get_list_table('WP_MS_Users_Table');
    1313$wp_list_table->check_permissions();
    1414$wp_list_table->prepare_items();
    1515
  • wp-admin/network/sites.php

     
    1212if ( ! is_multisite() )
    1313        wp_die( __( 'Multisite support is not enabled.' ) );
    1414
    15 $wp_list_table = get_list_table('sites');
     15$wp_list_table = get_list_table('WP_Sites_Table');
    1616$wp_list_table->check_permissions();
    1717
    1818$title = __( 'Sites' );
  • wp-admin/plugins.php

     
    99/** WordPress Administration Bootstrap */
    1010require_once('./admin.php');
    1111
    12 $wp_list_table = get_list_table('plugins');
     12$wp_list_table = get_list_table('WP_Plugins_Table');
    1313$wp_list_table->check_permissions();
    1414
    1515$action = $wp_list_table->current_action();
  • wp-admin/edit.php

     
    99/** WordPress Administration Bootstrap */
    1010require_once( './admin.php' );
    1111
    12 $wp_list_table = get_list_table('posts');
     12$wp_list_table = get_list_table('WP_Posts_Table');
    1313$wp_list_table->check_permissions();
    1414
    1515// Back-compat for viewing comments of an entry
  • wp-admin/link-manager.php

     
    99/** Load WordPress Administration Bootstrap */
    1010require_once ('admin.php');
    1111
    12 $wp_list_table = get_list_table('links');
     12$wp_list_table = get_list_table('WP_Links_Table');
    1313$wp_list_table->check_permissions();
    1414
    1515// Handle bulk deletes
  • wp-admin/theme-install.php

     
    99/** WordPress Administration Bootstrap */
    1010require_once('./admin.php');
    1111
    12 $wp_list_table = get_list_table('theme-install');
     12$wp_list_table = get_list_table('WP_Theme_Install_Table');
    1313$wp_list_table->check_permissions();
    1414$wp_list_table->prepare_items();
    1515
  • wp-admin/themes.php

     
    99/** WordPress Administration Bootstrap */
    1010require_once('./admin.php');
    1111
    12 $wp_list_table = get_list_table('themes');
     12$wp_list_table = get_list_table('WP_Themes_Table');
    1313$wp_list_table->check_permissions();
    1414
    1515if ( current_user_can('switch_themes') && isset($_GET['action']) ) {