From 328a6b21c0460ee916ea9ae118e2df25c1c5cc94 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Wed, 18 Nov 2015 23:00:55 +0000 Subject: [PATCH] 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 --- src/wp-admin/includes/class-wp-list-table.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/wp-admin/includes/class-wp-list-table.php b/src/wp-admin/includes/class-wp-list-table.php index d1b89c7bad..6467280fb3 100644 --- a/src/wp-admin/includes/class-wp-list-table.php +++ b/src/wp-admin/includes/class-wp-list-table.php @@ -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 ) {