Make WordPress Core

Opened 7 years ago

Closed 14 months ago

Last modified 14 months ago

#47901 closed defect (bug) (invalid)

Admin menu variable is not always considered as global

Reported by: philippevienne Owned by:
Priority: normal Milestone:
Component: Administration Version:
Severity: normal Keywords:
Cc: Focuses: administration, coding-standards

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 (4)

#1 @mukesh27
7 years ago

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

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
7 years 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 7 years ago by itowhid06 (previous) (diff)

#3 @mindctrl
14 months ago

  • Keywords 2nd-opinion removed
  • Resolutioninvalid
  • Status newclosed

Hi all,

It's been 6+ years since this was opened and we've seen no other requests for it. I'm going to close this ticket to help clean up Trac. Feel free to reopen if more info comes to light that describes a bug that should be fixed.

#4 @peterwilsoncc
14 months ago

  • Milestone Awaiting Review
Note: See TracTickets for help on using tickets.