List Tables: Fix PHP error notice when `$columns` is `null`

Use of `register_column_headers()` and `print_column_headers()` creates a `_WP_List_Table_Compat` without any columns. When the List Table object doesn't have any columns, there's naturally no primary column.

Props danielbachhuber.
Fixes #34148.


git-svn-id: https://develop.svn.wordpress.org/trunk@35698 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor 2015-11-18 23:00:55 +00:00
parent 01a6fe13f9
commit 328a6b21c0
1 changed files with 4 additions and 0 deletions

View File

@ -902,6 +902,10 @@ class WP_List_Table {
$columns = $this->get_columns();
$column = '';
if ( empty( $columns ) ) {
return $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 ) {