Remove AJAX from list tables. first pass. see #16262.

git-svn-id: http://svn.automattic.com/wordpress/trunk@17322 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2011-01-16 21:47:24 +00:00
parent 94eb65baa0
commit 37075f7f71
34 changed files with 60 additions and 79 deletions

View File

@ -11,7 +11,7 @@ require_once('./admin.php');
if ( !current_user_can('edit_posts') )
wp_die(__('Cheatin’ uh?'));
$wp_list_table = get_list_table('WP_Comments_List_Table');
$wp_list_table = _get_list_table('WP_Comments_List_Table');
$pagenum = $wp_list_table->get_pagenum();
$doaction = $wp_list_table->current_action();

View File

@ -12,7 +12,7 @@ $tax = get_taxonomy( $taxnow );
if ( !current_user_can( $tax->cap->manage_terms ) )
wp_die( __( 'Cheatin’ uh?' ) );
$wp_list_table = get_list_table('WP_Terms_List_Table');
$wp_list_table = _get_list_table('WP_Terms_List_Table');
$title = $tax->labels->name;

View File

@ -23,7 +23,7 @@ $post_type_object = get_post_type_object( $post_type );
if ( !current_user_can($post_type_object->cap->edit_posts) )
wp_die(__('Cheatin’ uh?'));
$wp_list_table = get_list_table('WP_Posts_List_Table');
$wp_list_table = _get_list_table('WP_Posts_List_Table');
$pagenum = $wp_list_table->get_pagenum();
// Back-compat for viewing comments of an entry

View File

@ -13,6 +13,7 @@
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
* @access private
*/
class WP_Comments_List_Table extends WP_List_Table {
@ -266,7 +267,7 @@ class WP_Comments_List_Table extends WP_List_Table {
function display() {
extract( $this->_args );
wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' );
// wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' );
$this->display_tablenav( 'top' );
@ -509,6 +510,7 @@ class WP_Comments_List_Table extends WP_List_Table {
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
* @access private
*
* @see WP_Comments_Table
*/
@ -536,7 +538,7 @@ class WP_Post_Comments_List_Table extends WP_Comments_List_Table {
function display( $output_empty = false ) {
extract( $this->_args );
wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' );
// wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' );
?>
<table class="<?php echo implode( ' ', $this->get_table_classes() ); ?>" cellspacing="0" style="display:none;">
<tbody id="the-comment-list"<?php if ( $singular ) echo " class='list:$singular'"; ?>>

View File

@ -5,6 +5,7 @@
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
* @access private
*/
class WP_Links_List_Table extends WP_List_Table {

View File

@ -13,6 +13,7 @@
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
* @access private
*/
class WP_List_Table {
@ -92,10 +93,10 @@ class WP_List_Table {
$this->_args = $args;
if ( $args['ajax'] ) {
wp_enqueue_script( 'list-table' );
add_action( 'admin_footer', array( &$this, '_js_vars' ) );
}
// if ( $args['ajax'] ) {
// wp_enqueue_script( 'list-table' );
// add_action( 'admin_footer', array( &$this, '_js_vars' ) );
// }
}
/**
@ -199,9 +200,8 @@ class WP_List_Table {
<p class="search-box">
<label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label>
<input type="text" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" />
<?php submit_button( $text, 'button', 'submit', false, array('id' => 'search-submit') ); ?>
<?php submit_button( $text, 'button', false, false, array('id' => 'search-submit') ); ?>
</p>
<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-loading list-ajax-loading" alt="" />
<?php
}
@ -467,12 +467,7 @@ class WP_List_Table {
* @since 3.1.0
* @access protected
*/
function pagination() {
if ( $this->_pagination ) {
echo $this->_pagination;
return;
}
function pagination( $which ) {
if ( empty( $this->_pagination_args ) )
return;
@ -506,12 +501,16 @@ class WP_List_Table {
'&lsaquo;'
);
if ( 'bottom' == $which )
$html_current_page = $current;
else
$html_current_page = sprintf( "<input class='current-page' title='%s' type='text' name='%s' value='%s' size='%d' />",
esc_attr__( 'Current page' ),
esc_attr( 'paged' ),
number_format_i18n( $current ),
$current,
strlen( $total_pages )
);
$html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );
$page_links[] = '<span class="paging-input">' . sprintf( _x( '%1$s of %2$s', 'paging' ), $html_current_page, $html_total_pages ) . '</span>';
@ -633,6 +632,7 @@ class WP_List_Table {
list( $columns, $hidden, $sortable ) = $this->get_column_info();
$current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$current_url = remove_query_arg( 'paged', $current_url );
if ( isset( $_GET['orderby'] ) )
$current_orderby = $_GET['orderby'];
@ -692,8 +692,6 @@ class WP_List_Table {
function display() {
extract( $this->_args );
wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' );
$this->display_tablenav( 'top' );
?>
@ -748,11 +746,7 @@ class WP_List_Table {
<?php
$this->extra_tablenav( $which );
$this->pagination( $which );
if ( 'bottom' == $which ) {
?>
<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-loading list-ajax-loading" alt="" />
<?php } ?>
<br class="clear" />
</div>

View File

@ -5,6 +5,7 @@
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
* @access private
*/
class WP_Media_List_Table extends WP_List_Table {

View File

@ -5,6 +5,7 @@
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
* @access private
*/
class WP_MS_Sites_List_Table extends WP_List_Table {

View File

@ -5,6 +5,7 @@
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
* @access private
*/
class WP_MS_Themes_List_Table extends WP_List_Table {

View File

@ -5,6 +5,7 @@
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
* @access private
*/
class WP_MS_Users_List_Table extends WP_List_Table {

View File

@ -5,6 +5,7 @@
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
* @access private
*/
class WP_Plugin_Install_List_Table extends WP_List_Table {

View File

@ -5,6 +5,7 @@
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
* @access private
*/
class WP_Plugins_List_Table extends WP_List_Table {

View File

@ -5,6 +5,7 @@
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
* @access private
*/
class WP_Posts_List_Table extends WP_List_Table {

View File

@ -5,6 +5,7 @@
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
* @access private
*/
class WP_Terms_List_Table extends WP_List_Table {

View File

@ -5,6 +5,7 @@
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
* @access private
*/
class WP_Theme_Install_List_Table extends WP_List_Table {
@ -127,7 +128,7 @@ class WP_Theme_Install_List_Table extends WP_List_Table {
function display() {
wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' );
// wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' );
?>
<div class="tablenav top">
<div class="alignleft actions">

View File

@ -5,6 +5,7 @@
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
* @access private
*/
class WP_Themes_List_Table extends WP_List_Table {
@ -101,7 +102,7 @@ class WP_Themes_List_Table extends WP_List_Table {
}
function display() {
wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' );
// wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' );
?>
<?php $this->tablenav( 'top' ); ?>

View File

@ -5,6 +5,7 @@
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
* @access private
*/
class WP_Users_List_Table extends WP_List_Table {

View File

@ -10,32 +10,13 @@
/**
* Fetch an instance of a WP_List_Table class.
*
* @access private
* @since 3.1.0
*
* @param string $class The type of the list table, which is the class name except for core list tables.
* @param string $class The type of the list table, which is the class name.
* @return object|bool Object on success, false if the class does not exist.
*/
function get_list_table( $class ) {
$class = apply_filters( "get_list_table_$class", $class );
require_list_table( $class );
if ( class_exists( $class ) )
return new $class;
return false;
}
/**
* Include the proper file for a core list table.
*
* Useful for extending a core class that would not otherwise be required.
*
* @since 3.1.0
*
* @param string $table The core table to include.
* @return bool True on success, false on failure.
*/
function require_list_table( $class ) {
function _get_list_table( $class ) {
$core_classes = array(
//Site Admin
'WP_Posts_List_Table' => 'posts',
@ -57,7 +38,7 @@ function require_list_table( $class ) {
if ( isset( $core_classes[ $class ] ) ) {
require_once( ABSPATH . 'wp-admin/includes/class-wp-' . $core_classes[ $class ] . '-list-table.php' );
return true;
return new $class;
}
return false;

View File

@ -484,7 +484,7 @@ function post_comment_meta_box($post) {
wp_nonce_field( 'get-comments', 'add_comment_nonce', false );
$wp_list_table = get_list_table('WP_Post_Comments_List_Table');
$wp_list_table = _get_list_table('WP_Post_Comments_List_Table');
$wp_list_table->display( true );
?>
<p class="hide-if-no-js"><a href="#commentstatusdiv" id="show-comments" onclick="commentsBox.get(<?php echo $total; ?>);return false;"><?php _e('Show comments'); ?></a> <img class="waiting" style="display:none;" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" /></p>

View File

@ -332,9 +332,9 @@ function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single',
}
if ( $mode == 'single' ) {
$wp_list_table = get_list_table('WP_Post_Comments_List_Table');
$wp_list_table = _get_list_table('WP_Post_Comments_List_Table');
} else {
$wp_list_table = get_list_table('WP_Comments_List_Table');
$wp_list_table = _get_list_table('WP_Comments_List_Table');
}
?>

View File

@ -194,7 +194,7 @@ function wp_plugin_update_row( $file, $plugin_data ) {
$details_url = self_admin_url('plugin-install.php?tab=plugin-information&plugin=' . $r->slug . '&TB_iframe=true&width=600&height=800');
$wp_list_table = get_list_table('WP_Plugins_List_Table');
$wp_list_table = _get_list_table('WP_Plugins_List_Table');
if ( is_network_admin() || !is_multisite() ) {
echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">';
@ -270,7 +270,7 @@ function wp_theme_update_row( $theme_key, $theme ) {
$details_url = self_admin_url("theme-install.php?tab=theme-information&theme=$theme_key&TB_iframe=true&width=600&height=400");
$wp_list_table = get_list_table('WP_MS_Themes_List_Table');
$wp_list_table = _get_list_table('WP_MS_Themes_List_Table');
echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">';
if ( ! current_user_can('update_themes') )

View File

@ -11,7 +11,7 @@ require_once ('admin.php');
if ( ! current_user_can( 'manage_links' ) )
wp_die( __( 'You do not have sufficient permissions to edit the links for this site.' ) );
$wp_list_table = get_list_table('WP_Links_List_Table');
$wp_list_table = _get_list_table('WP_Links_List_Table');
// Handle bulk deletes
$doaction = $wp_list_table->current_action();

View File

@ -32,7 +32,7 @@ add_contextual_help($current_screen,
'<p>' . __('<a href="http://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>'
);
$wp_list_table = get_list_table('WP_MS_Themes_List_Table');
$wp_list_table = _get_list_table('WP_MS_Themes_List_Table');
$action = $wp_list_table->current_action();

View File

@ -16,7 +16,7 @@ if ( ! is_multisite() )
if ( ! current_user_can('manage_sites') )
wp_die(__('You do not have sufficient permissions to edit this site.'));
$wp_list_table = get_list_table('WP_Users_List_Table');
$wp_list_table = _get_list_table('WP_Users_List_Table');
$wp_list_table->prepare_items();
$action = $wp_list_table->current_action();

View File

@ -16,7 +16,7 @@ if ( ! is_multisite() )
if ( ! current_user_can( 'manage_sites' ) )
wp_die( __( 'You do not have permission to access this page.' ) );
$wp_list_table = get_list_table('WP_MS_Sites_List_Table');
$wp_list_table = _get_list_table('WP_MS_Sites_List_Table');
$pagenum = $wp_list_table->get_pagenum();
$title = __( 'Sites' );

View File

@ -21,7 +21,7 @@ if ( empty( $menu_perms['themes'] ) && ! is_super_admin() )
if ( !current_user_can('manage_network_themes') )
wp_die( __( 'You do not have sufficient permissions to manage network themes.' ) );
$wp_list_table = get_list_table('WP_MS_Themes_List_Table');
$wp_list_table = _get_list_table('WP_MS_Themes_List_Table');
$pagenum = $wp_list_table->get_pagenum();
$action = $wp_list_table->current_action();

View File

@ -16,7 +16,7 @@ if ( ! is_multisite() )
if ( ! current_user_can( 'manage_network_users' ) )
wp_die( __( 'You do not have permission to access this page.' ) );
$wp_list_table = get_list_table('WP_MS_Users_List_Table');
$wp_list_table = _get_list_table('WP_MS_Users_List_Table');
$wp_list_table->prepare_items();
$title = __( 'Users' );

View File

@ -20,7 +20,7 @@ if ( is_multisite() && ! is_network_admin() ) {
exit();
}
$wp_list_table = get_list_table('WP_Plugin_Install_List_Table');
$wp_list_table = _get_list_table('WP_Plugin_Install_List_Table');
$pagenum = $wp_list_table->get_pagenum();
$wp_list_table->prepare_items();
$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );

View File

@ -19,7 +19,7 @@ if ( is_multisite() ) {
if ( !current_user_can('activate_plugins') )
wp_die( __( 'You do not have sufficient permissions to manage plugins for this site.' ) );
$wp_list_table = get_list_table('WP_Plugins_List_Table');
$wp_list_table = _get_list_table('WP_Plugins_List_Table');
$pagenum = $wp_list_table->get_pagenum();
$action = $wp_list_table->current_action();

View File

@ -20,7 +20,7 @@ if ( is_multisite() && ! is_network_admin() ) {
exit();
}
$wp_list_table = get_list_table('WP_Theme_Install_List_Table');
$wp_list_table = _get_list_table('WP_Theme_Install_List_Table');
$pagenum = $wp_list_table->get_pagenum();
$wp_list_table->prepare_items();
$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );

View File

@ -12,7 +12,7 @@ require_once('./admin.php');
if ( !current_user_can('switch_themes') && !current_user_can('edit_theme_options') )
wp_die( __( 'Cheatin&#8217; uh?' ) );
$wp_list_table = get_list_table('WP_Themes_List_Table');
$wp_list_table = _get_list_table('WP_Themes_List_Table');
if ( current_user_can( 'switch_themes' ) && isset($_GET['action'] ) ) {
if ( 'activate' == $_GET['action'] ) {

View File

@ -12,7 +12,7 @@ require_once( './admin.php' );
if ( !current_user_can('upload_files') )
wp_die( __( 'You do not have permission to upload files.' ) );
$wp_list_table = get_list_table('WP_Media_List_Table');
$wp_list_table = _get_list_table('WP_Media_List_Table');
$pagenum = $wp_list_table->get_pagenum();
// Handle bulk actions

View File

@ -12,7 +12,7 @@ require_once( './admin.php' );
if ( ! current_user_can( 'list_users' ) )
wp_die( __( 'Cheatin&#8217; uh?' ) );
$wp_list_table = get_list_table('WP_Users_List_Table');
$wp_list_table = _get_list_table('WP_Users_List_Table');
$title = __('Users');
$parent_file = 'users.php';

View File

@ -299,14 +299,6 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'admin-custom-fields', "/wp-admin/js/custom-fields$suffix.js", array('wp-lists'), '20090106' );
$scripts->add_data( 'admin-custom-fields', 'group', 1 );
$scripts->add( 'list-table', "/wp-admin/js/list-table$suffix.js", array( 'jquery-query', 'jquery-serialize-object' ), '20110111a' );
$scripts->add_data( 'list-table', 'group', 1 );
$scripts->localize( 'list-table', 'listTableL10n', array(
'error' => __('An error has occurred while loading the items.'),
'search' => __('Search results for &#8220;%s&#8221;'),
'l10n_print_after' => 'try{convertEntities(listTableL10n);}catch(e){};'
) );
$scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array('wp-lists', 'list-table', 'jquery-ui-resizable', 'quicktags'), '20101223' );
$scripts->add_data( 'admin-comments', 'group', 1 );
$scripts->localize( 'admin-comments', 'adminCommentsL10n', array(