WordPress.org

Make WordPress Core

Opened 3 months ago

Last modified 3 months ago

#47901 new defect (bug)

Admin menu variable is not always considered as global

Reported by: philippevienne Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Administration Keywords: 2nd-opinion
Focuses: administration, coding-standards Cc:
PR Number:

Description

In "wp-admin/menu.php", the variable $menu is used as global but never declared as global, this cause issue if you are displaying admin from a router script in PHP by using a require_once.

Bug can be solved by adding to "wp-admin/menu.php"

<?php
/**
 * Build Administration Menu.
 *
 * @package WordPress
 * @subpackage Administration
 */

/**
 * Constructs the admin menu.
 *
 * The elements in the array are :
 *     0: Menu item name
 *     1: Minimum level or capability required.
 *     2: The URL of the item's file
 *     3: Class
 *     4: ID
 *     5: Icon for top level menu
 *
 * @global array $menu
 */

global $menu; // <- This line

Change History (2)

#1 @mukesh27
3 months ago

  • Focuses ui removed
  • Keywords 2nd-opinion added
  • Version 5.2.2 deleted

Hi @philippevienne,

Welcome to WordPress Trac! Thanks for the ticket.

If we consider the $menu for global variable then the same way we have to consider $submenu for global also.

#2 @itowhid06
3 months ago

I believe there are also $menu_order & $default_menu_order in 'wp-admin/includes/menu.php' if we consider explicitly declaring them as global.

Last edited 3 months ago by itowhid06 (previous) (diff)
Note: See TracTickets for help on using tickets.