WordPress.org

Make WordPress Core

Ticket #27120: 27120.patch

File 27120.patch, 1.0 KB (added by Clorith, 6 years ago)
  • nav-menu-template.php

     
    250250        }
    251251
    252252        // If the menu exists, get its items.
    253         if ( $menu && ! is_wp_error($menu) && !isset($menu_items) )
    254                 $menu_items = wp_get_nav_menu_items( $menu->term_id, array( 'update_post_term_cache' => false ) );
     253        if ( $menu && ! is_wp_error( $menu ) && ! isset( $menu_items ) ) {
     254                // Check if we have a cache of this menus items first
     255        $menu_items = wp_cache_get( 'wp_nav_menu_' . $args->theme_location );
    255256
     257                // If no cache exists for this menu, fetch it and set the cache in case of repeat use
     258        if ( ! $menu_items ) {
     259            $menu_items = wp_get_nav_menu_items( $menu->term_id, array( 'update_post_term_cache' => false ) );
     260            wp_cache_set( 'wp_nav_menu_' . $args->theme_location, $menu_items );
     261        }
     262    }
     263
    256264        /*
    257265         * If no menu was found:
    258266         *  - Fall back (if one was specified), or bail.