From a41a7b5b5bd637fb426ea7653e865e83d524daa0 Mon Sep 17 00:00:00 2001 From: scribu Date: Sun, 14 Nov 2010 18:00:09 +0000 Subject: [PATCH] Introduce WP_List_Table::get_column_count() and take care of update notice . Props ocean90 for initial patch. Fixes #15318 git-svn-id: http://svn.automattic.com/wordpress/trunk@16368 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/class-wp-list-table.php | 14 ++++++++++++++ wp-admin/includes/class-wp-posts-list-table.php | 9 +++------ wp-admin/includes/class-wp-terms-list-table.php | 11 ++++------- wp-admin/includes/template.php | 6 +----- wp-admin/includes/update.php | 8 ++++++-- wp-admin/js/common.dev.js | 10 ++++++++++ wp-admin/js/common.js | 2 +- wp-includes/script-loader.php | 2 +- 8 files changed, 40 insertions(+), 22 deletions(-) diff --git a/wp-admin/includes/class-wp-list-table.php b/wp-admin/includes/class-wp-list-table.php index db9d07eba3..c1b7c19874 100644 --- a/wp-admin/includes/class-wp-list-table.php +++ b/wp-admin/includes/class-wp-list-table.php @@ -549,6 +549,20 @@ class WP_List_Table { return $this->_column_headers; } + /** + * Return number of visible columns + * + * @since 3.1.0 + * @access public + * + * @return int + */ + function get_column_count() { + list ( $columns, $hidden ) = $this->get_column_info(); + $hidden = array_intersect( array_keys( $columns ), array_filter( $hidden ) ); + return count( $columns ) - count( $hidden ); + } + /** * Print column headers, accounting for hidden and sortable columns. * diff --git a/wp-admin/includes/class-wp-posts-list-table.php b/wp-admin/includes/class-wp-posts-list-table.php index 7c4a3ea7cb..d46f129536 100644 --- a/wp-admin/includes/class-wp-posts-list-table.php +++ b/wp-admin/includes/class-wp-posts-list-table.php @@ -703,9 +703,6 @@ class WP_Posts_List_Table extends WP_List_Table { $flat_taxonomies[] = $taxonomy; } - list( $columns, $hidden ) = $this->get_column_info(); - - $col_count = count( $columns ) - count( $hidden ); $m = ( isset( $mode ) && 'excerpt' == $mode ) ? 'excerpt' : 'list'; $can_publish = current_user_can( $post_type_object->cap->publish_posts ); $core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true ); @@ -720,12 +717,10 @@ class WP_Posts_List_Table extends WP_List_Table { post_type "; echo $bulk ? "bulk-edit-row bulk-edit-row-$hclass bulk-edit-$screen->post_type" : "quick-edit-row quick-edit-row-$hclass inline-edit-$screen->post_type"; - ?>" style="display: none"> + ?>" style="display: none">

- - post_type, 'title' ) ) : @@ -976,6 +971,8 @@ class WP_Posts_List_Table extends WP_List_Table {
get_column_info(); + foreach ( $columns as $column_name => $column_display_name ) { if ( isset( $core_columns[$column_name] ) ) continue; diff --git a/wp-admin/includes/class-wp-terms-list-table.php b/wp-admin/includes/class-wp-terms-list-table.php index a7afa04cdb..c21e7abd6e 100644 --- a/wp-admin/includes/class-wp-terms-list-table.php +++ b/wp-admin/includes/class-wp-terms-list-table.php @@ -308,14 +308,10 @@ class WP_Terms_List_Table extends WP_List_Table { if ( ! current_user_can( $tax->cap->edit_terms ) ) return; - - list( $columns, $hidden ) = $this->get_column_info(); - - $col_count = count( $columns ) - count( $hidden ); - ?> +?>
-