WordPress.org

Make WordPress Core

Changeset 32746


Ignore:
Timestamp:
06/13/2015 02:14:42 PM (6 years ago)
Author:
ocean90
Message:

Nav menu: Introduce a has_nav_menu filter in has_nav_menu() to filter whether a nav menu is assigned to a specified location.

props westonruter.
fixes #32630.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/nav-menu.php

    r32612 r32746  
    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     }
    153 
    154     $locations = get_nav_menu_locations();
    155     return ( ! empty( $locations[ $location ] ) );
     152    if ( isset( $registered_nav_menus[ $location ] ) ) {
     153        $locations = get_nav_menu_locations();
     154        $has_nav_menu = ! empty( $locations[ $location ] );
     155    }
     156
     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    return apply_filters( 'has_nav_menu', $has_nav_menu, $location );
    156166}
    157167
Note: See TracChangeset for help on using the changeset viewer.