WordPress.org

Make WordPress Core

Ticket #32630: 32630.diff

File 32630.diff, 1.0 KB (added by westonruter, 6 years ago)

Source: https://github.com/xwp/wordpress-develop/pull/91/files#diff-8ffabe2d2470a815389fd77c045d2c7fL148

  • src/wp-includes/nav-menu.php

     
    146146 * @return bool Whether location has a menu.
    147147 */
    148148function has_nav_menu( $location ) {
     149        $has_nav_menu = false;
     150
    149151        $registered_nav_menus = get_registered_nav_menus();
    150         if ( ! isset( $registered_nav_menus[ $location ] ) ) {
    151                 return false;
     152        if ( isset( $registered_nav_menus[ $location ] ) ) {
     153                $locations = get_nav_menu_locations();
     154                $has_nav_menu = ( ! empty( $locations[ $location ] ) );
    152155        }
    153156
    154         $locations = get_nav_menu_locations();
    155         return ( ! empty( $locations[ $location ] ) );
     157        /**
     158         * Filter whether a nav menu is assigned to the specified location.
     159         *
     160         * @since 4.3.0
     161         *
     162         * @param bool   $has_nav_menu Whether there is a menu assigned to a location.
     163         * @param string $location     Menu location.
     164         */
     165        $has_nav_menu = apply_filters( 'has_nav_menu', $has_nav_menu, $location );
     166
     167        return $has_nav_menu;
    156168}
    157169
    158170/**