replace $table with $wp_list_table. See #14651

git-svn-id: https://develop.svn.wordpress.org/trunk@15519 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
scribu 2010-08-22 11:22:46 +00:00
parent b96c92620d
commit 1c4aeef40e
18 changed files with 111 additions and 112 deletions

View File

@ -58,8 +58,8 @@ case 'fetch-list' :
if ( class_exists( $class ) ) {
global $current_screen;
$current_screen = (object) $_GET['list_args']['screen'];
$table = new $class;
$table->ajax_response();
$wp_list_table = new $class;
$wp_list_table->ajax_response();
}
die('0');
@ -558,7 +558,7 @@ case 'add-tag' :
set_current_screen($_POST['screen']);
require_once( './includes/default-list-tables.php' );
$table = new WP_Terms_Table();
$wp_list_table = new WP_Terms_Table();
$level = 0;
$tag_full_name = false;
@ -570,10 +570,10 @@ case 'add-tag' :
$tag_full_name = $_tag->name . ' — ' . $tag_full_name;
$level++;
}
$noparents = $table->single_row( $tag, $level, $taxonomy );
$noparents = $wp_list_table->single_row( $tag, $level, $taxonomy );
}
$tag->name = $tag_full_name;
$parents = $table->single_row( $tag, 0, $taxonomy);
$parents = $wp_list_table->single_row( $tag, 0, $taxonomy);
$x->add( array(
'what' => 'taxonomy',
@ -626,17 +626,17 @@ case 'add-comment' :
die('-1');
require_once( './includes/default-list-tables.php' );
$table = new WP_Comments_Table();
$table->prepare_items();
$wp_list_table = new WP_Comments_Table();
$wp_list_table->prepare_items();
if ( !$table->has_items() )
if ( !$wp_list_table->has_items() )
die('1');
$x = new WP_Ajax_Response();
foreach ( $table->items as $comment ) {
foreach ( $wp_list_table->items as $comment ) {
get_comment( $comment );
ob_start();
$table->single_row( $comment->comment_ID, $mode, $comment_status, true, true );
$wp_list_table->single_row( $comment->comment_ID, $mode, $comment_status, true, true );
$comment_list_item = ob_get_contents();
ob_end_clean();
$x->add( array(
@ -655,18 +655,18 @@ case 'get-comments' :
die('-1');
require_once( './includes/default-list-tables.php' );
$table = new WP_Comments_Table();
$table->prepare_items();
$wp_list_table = new WP_Comments_Table();
$wp_list_table->prepare_items();
if ( !$table->has_items() )
if ( !$wp_list_table->has_items() )
die('1');
$comment_list_item = '';
$x = new WP_Ajax_Response();
foreach ( $table->items as $comment ) {
foreach ( $wp_list_table->items as $comment ) {
get_comment( $comment );
ob_start();
$table->single_row( $comment->comment_ID, 'single', false, false );
$wp_list_table->single_row( $comment->comment_ID, 'single', false, false );
$comment_list_item .= ob_get_contents();
ob_end_clean();
}
@ -680,7 +680,7 @@ case 'replyto-comment' :
check_ajax_referer( $action, '_ajax_nonce-replyto-comment' );
require_once( './includes/default-list-tables.php' );
$table = new WP_Comments_Table();
$wp_list_table = new WP_Comments_Table();
$comment_post_ID = (int) $_POST['comment_post_ID'];
if ( !current_user_can( 'edit_post', $comment_post_ID ) )
@ -729,7 +729,7 @@ case 'replyto-comment' :
require_once( ABSPATH . 'wp-admin/includes/dashboard.php' );
_wp_dashboard_recent_comments_row( $comment, false );
} else {
$table->single_row( $comment->comment_ID, $mode, false, $checkbox );
$wp_list_table->single_row( $comment->comment_ID, $mode, false, $checkbox );
}
$comment_list_item = ob_get_contents();
ob_end_clean();
@ -762,10 +762,10 @@ case 'edit-comment' :
$comments_listing = isset($_POST['comments_listing']) ? $_POST['comments_listing'] : '';
require_once( './includes/default-list-tables.php' );
$table = new WP_Comments_Table();
$wp_list_table = new WP_Comments_Table();
ob_start();
$table->single_row( $comment_id, $mode, $comments_listing, $checkbox );
$wp_list_table->single_row( $comment_id, $mode, $comments_listing, $checkbox );
$comment_list_item = ob_get_contents();
ob_end_clean();
@ -911,12 +911,12 @@ case 'add-user' :
$user_object = new WP_User( $user_id );
require_once( './includes/default-list-tables.php' );
$table = new WP_Users_Table();
$wp_list_table = new WP_Users_Table();
$x = new WP_Ajax_Response( array(
'what' => 'user',
'id' => $user_id,
'data' => $table->single_row( $user_object, '', $user_object->roles[0] ),
'data' => $wp_list_table->single_row( $user_object, '', $user_object->roles[0] ),
'supplemental' => array(
'show-link' => sprintf(__( 'User <a href="#%s">%s</a> added' ), "user-$user_id", $user_object->user_login),
'role' => $user_object->roles[0]
@ -1204,10 +1204,10 @@ case 'inline-save':
edit_post();
require_once( './includes/default-list-tables.php' );
$table = new WP_Posts_Table();
$wp_list_table = new WP_Posts_Table();
$mode = $_POST['post_view'];
$table->display_rows( array( get_post( $_POST['post_ID'] ) ) );
$wp_list_table->display_rows( array( get_post( $_POST['post_ID'] ) ) );
exit;
break;
@ -1215,9 +1215,9 @@ case 'inline-save-tax':
check_ajax_referer( 'taxinlineeditnonce', '_inline_edit' );
require_once( './includes/default-list-tables.php' );
$table = new WP_Terms_Table();
$wp_list_table = new WP_Terms_Table();
$table->check_permissions('edit');
$wp_list_table->check_permissions('edit');
if ( ! isset($_POST['tax_ID']) || ! ( $id = (int) $_POST['tax_ID'] ) )
die(-1);
@ -1234,7 +1234,7 @@ case 'inline-save-tax':
die( __('Item not updated.') );
}
echo $table->single_row( $tag, 0, $taxonomy );
echo $wp_list_table->single_row( $tag, 0, $taxonomy );
} else {
if ( is_wp_error($updated) && $updated->get_error_message() )
die( $updated->get_error_message() );

View File

@ -11,8 +11,8 @@ require_once('./admin.php');
require_once( './includes/default-list-tables.php' );
$table = new WP_Comments_Table;
$table->check_permissions();
$wp_list_table = new WP_Comments_Table;
$wp_list_table->check_permissions();
if ( isset( $_REQUEST['doaction'] ) || isset( $_REQUEST['doaction2'] ) || isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) {
check_admin_referer( 'bulk-comments' );
@ -97,7 +97,7 @@ if ( isset( $_REQUEST['doaction'] ) || isset( $_REQUEST['doaction2'] ) || isset
exit;
}
$table->prepare_items();
$wp_list_table->prepare_items();
wp_enqueue_script('admin-comments');
enqueue_comment_hotkeys_js();
@ -257,17 +257,17 @@ unset($status_links);
<input type="hidden" name="comment_status" value="<?php echo esc_attr($comment_status); ?>" />
<input type="hidden" name="pagegen_timestamp" value="<?php echo esc_attr(current_time('mysql', 1)); ?>" />
<input type="hidden" name="_total" value="<?php echo esc_attr( $table->get_pagination_arg('total_items') ); ?>" />
<input type="hidden" name="_per_page" value="<?php echo esc_attr( $table->get_pagination_arg('per_page') ); ?>" />
<input type="hidden" name="_page" value="<?php echo esc_attr( $table->get_pagination_arg('page') ); ?>" />
<input type="hidden" name="_total" value="<?php echo esc_attr( $wp_list_table->get_pagination_arg('total_items') ); ?>" />
<input type="hidden" name="_per_page" value="<?php echo esc_attr( $wp_list_table->get_pagination_arg('per_page') ); ?>" />
<input type="hidden" name="_page" value="<?php echo esc_attr( $wp_list_table->get_pagination_arg('page') ); ?>" />
<?php if ( isset($_REQUEST['paged']) ) { ?>
<input type="hidden" name="paged" value="<?php echo esc_attr( absint( $_REQUEST['paged'] ) ); ?>" />
<?php } ?>
<?php if ( $table->has_items() ) { ?>
<?php if ( $wp_list_table->has_items() ) { ?>
<?php $table->display_table(); ?>
<?php $wp_list_table->display_table(); ?>
<br class="clear" />
</div>

View File

@ -11,8 +11,8 @@ require_once('./admin.php');
require_once( './includes/default-list-tables.php' );
$table = new WP_Terms_Table;
$table->check_permissions();
$wp_list_table = new WP_Terms_Table;
$wp_list_table->check_permissions();
$title = $tax->labels->name;
@ -152,7 +152,7 @@ if ( ! empty($_REQUEST['_wp_http_referer']) ) {
exit;
}
$table->prepare_items();
$wp_list_table->prepare_items();
wp_enqueue_script('admin-tags');
if ( current_user_can($tax->cap->edit_terms) )
@ -241,7 +241,7 @@ endif; ?>
<input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); ?>" />
<input type="hidden" name="post_type" value="<?php echo esc_attr($post_type); ?>" />
<?php $table->display_table(); ?>
<?php $wp_list_table->display_table(); ?>
<br class="clear" />
</form>
@ -351,7 +351,7 @@ do_action($taxonomy . '_add_form', $taxonomy);
</div><!-- /col-container -->
</div><!-- /wrap -->
<?php $table->inline_edit(); ?>
<?php $wp_list_table->inline_edit(); ?>
<?php
break;

View File

@ -11,8 +11,8 @@ require_once( './admin.php' );
require_once( './includes/default-list-tables.php' );
$table = new WP_Posts_Table;
$table->check_permissions();
$wp_list_table = new WP_Posts_Table;
$wp_list_table->check_permissions();
// Back-compat for viewing comments of an entry
if ( $_redirect = intval( max( @$_REQUEST['p'], @$_REQUEST['attachment_id'], @$_REQUEST['page_id'] ) ) ) {
@ -119,7 +119,7 @@ if ( 'post' != $post_type ) {
$post_new_file = 'post-new.php';
}
$table->prepare_items();
$wp_list_table->prepare_items();
wp_enqueue_script('inline-edit-post');
@ -280,11 +280,11 @@ endif;
<input type="hidden" name="post_status" class="post_status_page" value="<?php echo !empty($_REQUEST['post_status']) ? esc_attr($_REQUEST['post_status']) : 'all'; ?>" />
<input type="hidden" name="post_type" class="post_type_page" value="<?php echo $post_type; ?>" />
<?php $table->display(); ?>
<?php $wp_list_table->display(); ?>
</form>
<?php $table->inline_edit(); ?>
<?php $wp_list_table->inline_edit(); ?>
<div id="ajax-response"></div>
<br class="clear" />

View File

@ -211,15 +211,10 @@ function use_codepress() {
function register_column_headers($screen, $columns) {
_deprecated_function( __FUNCTION__, '3.1', 'WP_List_Table' );
global $_wp_column_headers;
global $wp_list_table;
if ( is_string($screen) )
$screen = convert_to_screen($screen);
if ( !isset($_wp_column_headers) )
$_wp_column_headers = array();
$_wp_column_headers[$screen->id] = $columns;
$wp_list_table = new _WP_List_Table_Compat($screen);
$wp_list_table->_columns = $columns;
}
/**
@ -235,8 +230,11 @@ function register_column_headers($screen, $columns) {
function get_column_headers($screen) {
_deprecated_function( __FUNCTION__, '3.1', 'WP_List_Table' );
$table = new _WP_List_Table_Compat($screen);
list( $columns ) = $table->get_column_headers();
global $wp_list_table;
if ( !is_a($wp_list_table, 'WP_List_Table') )
$wp_list_table = new _WP_List_Table_Compat($screen);
list( $columns ) = $wp_list_table->get_column_headers();
return $columns;
}
@ -251,9 +249,11 @@ function get_column_headers($screen) {
function print_column_headers($screen, $id = true) {
_deprecated_function( __FUNCTION__, '3.1', 'WP_List_Table' );
$table = new _WP_List_Table_Compat($screen);
global $wp_list_table;
if ( !is_a($wp_list_table, 'WP_List_Table') )
$wp_list_table = new _WP_List_Table_Compat($screen);
$table->print_column_headers($id);
$wp_list_table->print_column_headers($id);
}
/**
@ -269,14 +269,18 @@ function print_column_headers($screen, $id = true) {
function get_hidden_columns($screen) {
_deprecated_function( __FUNCTION__, '3.1', 'WP_List_Table' );
$table = new _WP_List_Table_Compat($screen);
global $wp_list_table;
if ( !is_a($wp_list_table, 'WP_List_Table') )
$wp_list_table = new _WP_List_Table_Compat($screen);
return $table->get_hidden_columns();
return $wp_list_table->get_hidden_columns();
}
// Helper class to be used only by deprecated functions
class _WP_List_Table_Compat extends WP_List_Table {
var $_columns = array();
function _WP_List_Table_Compat( $screen) {
parent::WP_List_Table( array(
'screen' => $screen,
@ -285,12 +289,7 @@ class _WP_List_Table_Compat extends WP_List_Table {
}
function get_columns() {
global $_wp_column_headers;
if ( isset($_wp_column_headers[$this->_screen->id]) )
return $_wp_column_headers[$this->_screen->id];
return array();
return $this->_columns;
}
}

View File

@ -463,12 +463,12 @@ function post_comment_meta_box($post) {
add_filter('manage_edit-comments_sortable_columns', create_function('', 'return array();'), 8);
require_once( './includes/default-list-tables.php' );
$table = new WP_Comments_Table;
$wp_list_table = new WP_Comments_Table;
?>
<table class="widefat comments-box fixed" cellspacing="0" style="display:none;">
<thead><tr>
<?php $table->print_column_headers(); ?>
<?php $wp_list_table->print_column_headers(); ?>
</tr></thead>
<tbody id="the-comment-list" class="list:comment"></tbody>
</table>

View File

@ -162,9 +162,9 @@ add_action('install_plugins_upload', 'install_plugins_upload', 10, 1);
* @param int $total_plugins Number of plugins.
*/
function display_plugins_table() {
global $table;
global $wp_list_table;
$table->display();
$wp_list_table->display();
}
add_action('install_plugins_search', 'display_plugins_table');
add_action('install_plugins_featured', 'display_plugins_table');

View File

@ -294,10 +294,10 @@ function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single',
}
require_once( './includes/default-list-tables.php' );
$table = new WP_Comments_Table( 'reply' );
$wp_list_table = new WP_Comments_Table( 'reply' );
$columns = $table->get_column_headers();
$hidden = array_intersect( array_keys( $columns ), array_filter( $table->get_hidden_columns() ) );
$columns = $wp_list_table->get_column_headers();
$hidden = array_intersect( array_keys( $columns ), array_filter( $wp_list_table->get_hidden_columns() ) );
$col_count = count($columns) - count($hidden);
?>
@ -1293,9 +1293,9 @@ function settings_errors ( $setting = '', $sanitize = FALSE, $hide_on_update = F
* @param unknown_type $page
*/
function manage_columns_prefs( $page ) {
global $table;
global $wp_list_table;
list( $columns, $hidden ) = $table->get_column_headers();
list( $columns, $hidden ) = $wp_list_table->get_column_headers();
$special = array('_title', 'cb', 'comment', 'media', 'name', 'title', 'username');
@ -1629,13 +1629,13 @@ function convert_to_screen( $screen ) {
}
function screen_meta($screen) {
global $wp_meta_boxes, $_wp_contextual_help, $title, $table;
global $wp_meta_boxes, $_wp_contextual_help, $title, $wp_list_table;
if ( is_string($screen) )
$screen = convert_to_screen($screen);
if ( is_a($table, 'WP_List_Table') )
list( $screen_columns ) = $table->get_column_headers();
if ( is_a($wp_list_table, 'WP_List_Table') )
list( $screen_columns ) = $wp_list_table->get_column_headers();
$meta_screens = array('index' => 'dashboard');
if ( isset($meta_screens[$screen->id]) ) {

View File

@ -261,9 +261,9 @@ function display_theme($theme, $actions = null, $show_details = true) {
* @since 2.8.0
*/
function display_themes() {
global $table;
global $wp_list_table;
$table->display();
$wp_list_table->display();
}
add_action('install_themes_search', 'display_themes');
add_action('install_themes_featured', 'display_themes');

View File

@ -11,8 +11,8 @@ require_once ('admin.php');
require_once( './includes/default-list-tables.php' );
$table = new WP_Links_Table;
$table->check_permissions();
$wp_list_table = new WP_Links_Table;
$wp_list_table->check_permissions();
// Handle bulk deletes
if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['linkcheck'] ) ) {
@ -35,7 +35,7 @@ if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['linkcheck'] ) ) {
exit;
}
$table->prepare_items();
$wp_list_table->prepare_items();
$title = __('Links');
$this_file = $parent_file = 'link-manager.php';
@ -84,7 +84,7 @@ if ( isset($_REQUEST['deleted']) ) {
<br class="clear" />
<form id="posts-filter" action="" method="post">
<?php $table->display(); ?>
<?php $wp_list_table->display(); ?>
<div id="ajax-response"></div>
</form>

View File

@ -14,8 +14,8 @@ if ( ! is_multisite() )
require_once( '../includes/default-list-tables.php' );
$table = new WP_Sites_Table;
$table->check_permissions();
$wp_list_table = new WP_Sites_Table;
$wp_list_table->check_permissions();
$title = __( 'Sites' );
$parent_file = 'sites.php';
@ -350,7 +350,7 @@ switch ( $action ) {
// List sites
case 'list':
default:
$table->prepare_items();
$wp_list_table->prepare_items();
require_once( '../admin-header.php' );
?>
@ -378,7 +378,7 @@ switch ( $action ) {
</form>
<form id="form-site-list" action="edit.php?action=allblogs" method="post">
<?php $table->display(); ?>
<?php $wp_list_table->display(); ?>
</form>
</div>

View File

@ -11,9 +11,9 @@ require_once( './admin.php' );
require_once( '../includes/default-list-tables.php' );
$table = new WP_MS_Users_Table;
$table->check_permissions();
$table->prepare_items();
$wp_list_table = new WP_MS_Users_Table;
$wp_list_table->check_permissions();
$wp_list_table->prepare_items();
$title = __( 'Users' );
$parent_file = 'users.php';
@ -78,7 +78,7 @@ if ( isset( $_REQUEST['updated'] ) && $_REQUEST['updated'] == 'true' && ! empty(
</form>
<form id="form-user-list" action='edit.php?action=allusers' method='post'>
<?php $table->display(); ?>
<?php $wp_list_table->display(); ?>
</form>
</div>

View File

@ -11,9 +11,9 @@ require_once('./admin.php');
require_once( './includes/default-list-tables.php' );
$table = new WP_Plugin_Install_Table;
$table->check_permissions();
$table->prepare_items();
$wp_list_table = new WP_Plugin_Install_Table;
$wp_list_table->check_permissions();
$wp_list_table->prepare_items();
$title = __('Install Plugins');
$parent_file = 'plugins.php';

View File

@ -11,8 +11,8 @@ require_once('./admin.php');
require_once( ABSPATH . 'wp-admin/includes/default-list-tables.php' );
$table = new WP_Plugins_Table;
$table->check_permissions();
$wp_list_table = new WP_Plugins_Table;
$wp_list_table->check_permissions();
if ( isset($_POST['clear-recent-list']) )
$action = 'clear-recent-list';
@ -302,7 +302,7 @@ if ( !in_array( $status, array( 'all', 'active', 'inactive', 'recently_activated
if ( $status != $default_status && 'search' != $status )
update_user_meta( get_current_user_id(), 'plugins_last_view', $status );
$table->prepare_items();
$wp_list_table->prepare_items();
wp_enqueue_script('plugin-install');
add_thickbox();
@ -438,7 +438,7 @@ elseif ( 'dropins' == $status )
echo '<br class="clear"><p>' . __( 'Drop-ins are advanced plugins in the <code>/wp-content</code> directory that replace WordPress functionality when present.' ) . '</p>';
?>
<?php $table->display(); ?>
<?php $wp_list_table->display(); ?>
</form>
</div>

View File

@ -11,9 +11,9 @@ require_once('./admin.php');
require_once( './includes/default-list-tables.php' );
$table = new WP_Theme_Install_Table;
$table->check_permissions();
$table->prepare_items();
$wp_list_table = new WP_Theme_Install_Table;
$wp_list_table->check_permissions();
$wp_list_table->prepare_items();
$title = __('Install Themes');
$parent_file = 'themes.php';

View File

@ -11,8 +11,8 @@ require_once('./admin.php');
require_once( './includes/default-list-tables.php' );
$table = new WP_Themes_Table;
$table->check_permissions();
$wp_list_table = new WP_Themes_Table;
$wp_list_table->check_permissions();
if ( current_user_can('switch_themes') && isset($_GET['action']) ) {
if ( 'activate' == $_GET['action'] ) {
@ -30,7 +30,7 @@ if ( current_user_can('switch_themes') && isset($_GET['action']) ) {
}
}
$table->prepare_items();
$wp_list_table->prepare_items();
$title = __('Manage Themes');
$parent_file = 'themes.php';
@ -105,7 +105,7 @@ if ( ! current_user_can( 'switch_themes' ) ) {
?>
<h3><?php _e('Available Themes'); ?></h3>
<?php $table->display(); ?>
<?php $wp_list_table->display(); ?>
<br class="clear" />

View File

@ -11,8 +11,8 @@ require_once( './admin.php' );
require_once( './includes/default-list-tables.php' );
$table = new WP_Media_Table;
$table->check_permissions();
$wp_list_table = new WP_Media_Table;
$wp_list_table->check_permissions();
// Handle bulk actions
if ( isset($_REQUEST['find_detached']) ) {
@ -130,7 +130,7 @@ if ( isset($_REQUEST['find_detached']) ) {
exit;
}
$table->prepare_items();
$wp_list_table->prepare_items();
$title = __('Media Library');
$parent_file = 'upload.php';
@ -247,7 +247,7 @@ unset($type_links);
</form>
<form id="posts-filter" action="" method="post">
<?php $table->display(); ?>
<?php $wp_list_table->display(); ?>
<div id="ajax-response"></div>
<?php find_posts_div(); ?>
<br class="clear" />

View File

@ -14,8 +14,8 @@ require_once( ABSPATH . WPINC . '/registration.php');
require_once( './includes/default-list-tables.php' );
$table = new WP_Users_Table;
$table->check_permissions();
$wp_list_table = new WP_Users_Table;
$wp_list_table->check_permissions();
$title = __('Users');
$parent_file = 'users.php';
@ -308,7 +308,7 @@ default:
exit;
}
$table->prepare_items();
$wp_list_table->prepare_items();
include('./admin-header.php');
@ -412,7 +412,7 @@ unset($role_links);
</form>
<form id="posts-filter" action="" method="post">
<?php $table->display(); ?>
<?php $wp_list_table->display(); ?>
</form>
<?php