From 81c2f541b04452b4b60bc71fa3e1b166ebc18245 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Helen=20Hou-Sand=C3=AD?= Date: Tue, 7 Jul 2015 15:12:27 +0000 Subject: [PATCH] List tables: Add a fallback for the primary column. Without a primary column defined, nothing shows in the responsive view at all, which is bad. props mordauk. see #25408. Built from https://develop.svn.wordpress.org/trunk@33104 git-svn-id: http://core.svn.wordpress.org/trunk@33075 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/class-wp-list-table.php | 18 ++++++++++++++++-- wp-includes/version.php | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/wp-admin/includes/class-wp-list-table.php b/wp-admin/includes/class-wp-list-table.php index 76fea0096c..9ec1bcee24 100644 --- a/wp-admin/includes/class-wp-list-table.php +++ b/wp-admin/includes/class-wp-list-table.php @@ -832,7 +832,21 @@ class WP_List_Table { * @return string Name of the default primary column, in this case, an empty string. */ protected function get_default_primary_column_name() { - return ''; + $columns = $this->get_columns(); + $column = ''; + + // We need a primary defined so responsive views show something, + // so let's fall back to the first non-checkbox column. + foreach( $columns as $col => $column_name ) { + if ( 'cb' === $col ) { + continue; + } + + $column = $col; + break; + } + + return $column; } /** @@ -878,7 +892,7 @@ class WP_List_Table { if ( isset( $this->_column_headers ) && is_array( $this->_column_headers ) ) { // Back-compat for list tables that have been manually setting $_column_headers for horse reasons. // In 4.3, we added a fourth argument for primary column. - $column_headers = array( array(), array(), array(), '' ); + $column_headers = array( array(), array(), array(), $this->get_primary_column_name() ); foreach ( $this->_column_headers as $key => $value ) { $column_headers[ $key ] = $value; } diff --git a/wp-includes/version.php b/wp-includes/version.php index 5eee1d187b..8b01b44d6d 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.3-beta1-33103'; +$wp_version = '4.3-beta1-33104'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.