Skip to content

Commit

Permalink
fix PHP notice "Trying to access array offset on null"
Browse files Browse the repository at this point in the history
Fix PHP notice "Trying to access array offset on null" when doing a wp-admin request with CLI since we are in eval() and the variables are therefore not in global context

Fix https://core.trac.wordpress.org/ticket/62286
  • Loading branch information
kkmuffme committed Oct 22, 2024
1 parent 194277a commit e8c4357
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/wp-admin/includes/menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ function add_menu_classes( $menu ) {
* @param bool $custom Whether custom ordering is enabled. Default false.
*/
if ( apply_filters( 'custom_menu_order', false ) ) {
// this might not be in global context if it's called from outside of global context or with eval()
global $menu_order, $default_menu_order;
$menu_order = array();

foreach ( $menu as $menu_item ) {
Expand Down

0 comments on commit e8c4357

Please sign in to comment.