Skip to content

Commit

Permalink
Fix undefined screen for WP_List_Table in WP < 6.1
Browse files Browse the repository at this point in the history
Signed-off-by: Giuseppe Foti <[email protected]>
  • Loading branch information
MocioF committed Feb 7, 2024
1 parent 99a6607 commit 148a6ce
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ phpcs.xml
node_modules
npm-debug.log
docs
coverage
coverage-html
.sass-cache
/.phpunit.result.cache
.phpunit.result.cache
tests/phpunit/.phpunit.result.cache
phpstan.neon
16 changes: 15 additions & 1 deletion admin/includes/class-gcmi-remote-files-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,24 @@
*/
class Gcmi_Remote_Files_List extends WP_List_Table {

/** Class constructor */
/**
* Class constructor
*/
public function __construct() {
// necessario per WP < 6.1, see: https://core.trac.wordpress.org/changeset/54414 .
if ( is_null( get_current_screen() ) ) {
set_current_screen( 'admin.php' );
}
$screen = get_current_screen();
if ( ! is_null( $screen ) ) {
$screen_id = $screen->id;
} else {
$screen_id = 'admin.php';
}
parent::__construct(
array(
// necessario per WP < 6.1 .
'screen' => $screen_id,
'singular' => 'fname', // singular name of the listed records.
'plural' => 'fnames', // plural name of the listed records.
'ajax' => false, // should this table support ajax?
Expand Down

0 comments on commit 148a6ce

Please sign in to comment.