WordPress.org

Make WordPress Core

Ticket #20956: 20956.2.patch

File 20956.2.patch, 818 bytes (added by martythornley, 6 years ago)

Adds filter and new array to allow changes to $menu

  • wp-admin/includes/menu.php

     
    1515        do_action('_admin_menu');
    1616
    1717// Create list of page plugin hook names.
    18 foreach ($menu as $menu_page) {
     18foreach ($menu as $id=>$menu_page) {
    1919        if ( false !== $pos = strpos($menu_page[2], '?') ) {
    2020                // Handle post_type=post|page|foo pages.
    2121                $hook_name = substr($menu_page[2], 0, $pos);
     
    3636                $hook_name = $compat[$hook_name];
    3737        elseif ( !$hook_name )
    3838                continue;
    39 
     39        $menu_pages[$menu_page[2]] = $id;
    4040        $admin_page_hooks[$menu_page[2]] = $hook_name;
    4141}
     42
     43$menu = apply_filters( 'menu_items' , $menu , $menu_pages );
     44
    4245unset($menu_page, $compat);
    4346
    4447$_wp_submenu_nopriv = array();