Skip to content

Commit

Permalink
Remove AJAX from list tables. first pass. see #16262.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.automattic.com/wordpress/trunk@17322 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
nacin committed Jan 16, 2011
1 parent 94eb65b commit 37075f7
Show file tree
Hide file tree
Showing 34 changed files with 60 additions and 79 deletions.
2 changes: 1 addition & 1 deletion wp-admin/edit-comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
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();
Expand Down
2 changes: 1 addition & 1 deletion wp-admin/edit-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
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;

Expand Down
2 changes: 1 addition & 1 deletion wp-admin/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
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
Expand Down
6 changes: 4 additions & 2 deletions wp-admin/includes/class-wp-comments-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
* @access private
*/
class WP_Comments_List_Table extends WP_List_Table {

Expand Down Expand Up @@ -266,7 +267,7 @@ function get_sortable_columns() {
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' );

Expand Down Expand Up @@ -509,6 +510,7 @@ function column_default( $comment, $column_name ) {
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
* @access private
*
* @see WP_Comments_Table
*/
Expand Down Expand Up @@ -536,7 +538,7 @@ function get_table_classes() {
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'"; ?>>
Expand Down
1 change: 1 addition & 0 deletions wp-admin/includes/class-wp-links-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
* @access private
*/
class WP_Links_List_Table extends WP_List_Table {

Expand Down
42 changes: 18 additions & 24 deletions wp-admin/includes/class-wp-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
* @access private
*/
class WP_List_Table {

Expand Down Expand Up @@ -92,10 +93,10 @@ function WP_List_Table( $args = array() ) {

$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' ) );
// }
}

/**
Expand Down Expand Up @@ -199,9 +200,8 @@ function search_box( $text, $input_id ) {
<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
}

Expand Down Expand Up @@ -467,12 +467,7 @@ function get_items_per_page( $option, $default = 20 ) {
* @since 3.1.0
* @access protected
*/
function pagination() {
if ( $this->_pagination ) {
echo $this->_pagination;
return;
}

function pagination( $which ) {
if ( empty( $this->_pagination_args ) )
return;

Expand Down Expand Up @@ -506,12 +501,16 @@ function pagination() {
'&lsaquo;'
);

$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 ),
strlen( $total_pages )
);
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' ),
$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>';

Expand Down Expand Up @@ -633,6 +632,7 @@ function print_column_headers( $with_id = true ) {
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'];
Expand Down Expand Up @@ -692,8 +692,6 @@ function print_column_headers( $with_id = true ) {
function display() {
extract( $this->_args );

wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' );

$this->display_tablenav( 'top' );

?>
Expand Down Expand Up @@ -748,11 +746,7 @@ function display_tablenav( $which ) {
<?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>
Expand Down
1 change: 1 addition & 0 deletions wp-admin/includes/class-wp-media-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
* @access private
*/
class WP_Media_List_Table extends WP_List_Table {

Expand Down
1 change: 1 addition & 0 deletions wp-admin/includes/class-wp-ms-sites-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
1 change: 1 addition & 0 deletions wp-admin/includes/class-wp-ms-themes-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
1 change: 1 addition & 0 deletions wp-admin/includes/class-wp-ms-users-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
1 change: 1 addition & 0 deletions wp-admin/includes/class-wp-plugin-install-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
1 change: 1 addition & 0 deletions wp-admin/includes/class-wp-plugins-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
* @access private
*/
class WP_Plugins_List_Table extends WP_List_Table {

Expand Down
1 change: 1 addition & 0 deletions wp-admin/includes/class-wp-posts-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
* @access private
*/
class WP_Posts_List_Table extends WP_List_Table {

Expand Down
1 change: 1 addition & 0 deletions wp-admin/includes/class-wp-terms-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
* @access private
*/
class WP_Terms_List_Table extends WP_List_Table {

Expand Down
3 changes: 2 additions & 1 deletion wp-admin/includes/class-wp-theme-install-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -127,7 +128,7 @@ function get_columns() {

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">
Expand Down
3 changes: 2 additions & 1 deletion wp-admin/includes/class-wp-themes-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
* @access private
*/
class WP_Themes_List_Table extends WP_List_Table {

Expand Down Expand Up @@ -101,7 +102,7 @@ function tablenav( $which = 'top' ) {
}

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' ); ?>

Expand Down
1 change: 1 addition & 0 deletions wp-admin/includes/class-wp-users-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
* @access private
*/
class WP_Users_List_Table extends WP_List_Table {

Expand Down
27 changes: 4 additions & 23 deletions wp-admin/includes/list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion wp-admin/includes/meta-boxes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
4 changes: 2 additions & 2 deletions wp-admin/includes/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

?>
Expand Down
4 changes: 2 additions & 2 deletions wp-admin/includes/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -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">';
Expand Down Expand Up @@ -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') )
Expand Down
2 changes: 1 addition & 1 deletion wp-admin/link-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
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();
Expand Down
2 changes: 1 addition & 1 deletion wp-admin/network/site-themes.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
'<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();

Expand Down
2 changes: 1 addition & 1 deletion wp-admin/network/site-users.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
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();
Expand Down
2 changes: 1 addition & 1 deletion wp-admin/network/sites.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
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' );
Expand Down
Loading

0 comments on commit 37075f7

Please sign in to comment.