[wp-trac] [WordPress Trac] #47901: Admin menu variable is not always considered as global

WordPress Trac noreply at wordpress.org
Tue Aug 20 07:56:15 UTC 2019


#47901: Admin menu variable is not always considered as global
-------------------------------------------------+-------------------------
 Reporter:  philippevienne                       |      Owner:  (none)
     Type:  defect (bug)                         |     Status:  new
 Priority:  normal                               |  Milestone:  Awaiting
                                                 |  Review
Component:  Administration                       |    Version:  5.2.2
 Severity:  normal                               |   Keywords:
  Focuses:  ui, administration, coding-          |
  standards                                      |
-------------------------------------------------+-------------------------
 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
 <?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
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/47901>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list