Problem
One day I noticed that the Aliases settings tab was missing in network site settings. I traced the problem to The Events Calendar PRO plugin. When that plugin was activated, the tab disappeared, and when I deactivated it, the tab re-appeared.
In my understanding, the problem is in the following lines of code:
|
if ( $GLOBALS['parent_file'] !== 'sites.php' || $GLOBALS['submenu_file'] !== 'sites.php' ) { |
|
return; |
|
} |
For some reason, I don't know why, when TEC plugin is activated, $GLOBALS['submenu_file'] value is NULL, when it should be sites.php.
Versions
- WordPress: 5.9.3
- The Events Calendar PRO: 5.14.0.1
- Mercator: 1.0.3
Possible fix (POC)
There's a proper way of getting current admin screen instead of reading globals. My suggestion would be to replace these lines:
|
if ( $GLOBALS['parent_file'] !== 'sites.php' || $GLOBALS['submenu_file'] !== 'sites.php' ) { |
|
return; |
|
} |
with:
$current_screen = get_current_screen();
if ( empty($current_screen->id) || ($current_screen->id !== 'site-info-network' && $current_screen->id !== 'admin-network' ) ) {
return;
}
Problem
One day I noticed that the
Aliasessettings tab was missing in network site settings. I traced the problem toThe Events Calendar PROplugin. When that plugin was activated, the tab disappeared, and when I deactivated it, the tab re-appeared.In my understanding, the problem is in the following lines of code:
Mercator/admin.php
Lines 64 to 66 in 9240e7c
For some reason, I don't know why, when TEC plugin is activated,
$GLOBALS['submenu_file']value isNULL, when it should besites.php.Versions
Possible fix (POC)
There's a proper way of getting current admin screen instead of reading globals. My suggestion would be to replace these lines:
Mercator/admin.php
Lines 64 to 66 in 9240e7c
with: