From d651f599bf6091bc15aa3ebbaf29e9088b3965ae Mon Sep 17 00:00:00 2001 From: Helen Hou-Sandi Date: Tue, 14 Jul 2015 16:17:06 +0000 Subject: [PATCH] List tables: Even more robust fallback for the primary column. Since `WP_List_Table::get_default_primary_column()` can be overridden in a subclass and columns can be further filtered, it is possible to end up with a primary column that no longer exists. This is particularly evident in list tables for custom post types that have been altered via filter. props ocean90. fixes #32996. git-svn-id: https://develop.svn.wordpress.org/trunk@33266 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/class-wp-list-table.php | 6 ++++++ src/wp-admin/includes/class-wp-posts-list-table.php | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/wp-admin/includes/class-wp-list-table.php b/src/wp-admin/includes/class-wp-list-table.php index 7188ebc44c..e7a7855e8a 100644 --- a/src/wp-admin/includes/class-wp-list-table.php +++ b/src/wp-admin/includes/class-wp-list-table.php @@ -887,6 +887,12 @@ class WP_List_Table { $columns = $this->get_columns(); $default = $this->get_default_primary_column_name(); + // If the primary column doesn't exist fall back to the + // first non-checkbox column. + if ( ! isset( $columns[ $default ] ) ) { + $default = WP_List_Table::get_default_primary_column_name(); + } + /** * Filter the name of the primary column for the current list table. * diff --git a/src/wp-admin/includes/class-wp-posts-list-table.php b/src/wp-admin/includes/class-wp-posts-list-table.php index 7c9ae710ef..571ad8a54e 100644 --- a/src/wp-admin/includes/class-wp-posts-list-table.php +++ b/src/wp-admin/includes/class-wp-posts-list-table.php @@ -1069,7 +1069,7 @@ class WP_Posts_List_Table extends WP_List_Table { * @return string Name of the default primary column, in this case, 'title'. */ protected function get_default_primary_column_name() { - return( 'title' ); + return 'title'; } /**