Make WordPress Core

Opened 6 years ago

Closed 5 months ago

Last modified 5 months ago

#47901 closed defect (bug) (invalid)

Admin menu variable is not always considered as global

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

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

#3 @mindctrl
5 months ago

  • Keywords 2nd-opinion removed
  • Resolution set to invalid
  • Status changed from new to closed

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
5 months ago

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