has_nav_menu

The timeline below displays how wordpress function has_nav_menu has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 4.6

/**
 * Determines whether a registered nav menu location has a menu assigned to it.
 *
 * @since 3.0.0
 *
 * @param string $location Menu location identifier.
 * @return bool Whether location has a menu.
 */
function has_nav_menu($location)
{
    $has_nav_menu = false;
    $registered_nav_menus = get_registered_nav_menus();
    if (isset($registered_nav_menus[$location])) {
        $locations = get_nav_menu_locations();
        $has_nav_menu = !empty($locations[$location]);
    }
    /**
     * Filters whether a nav menu is assigned to the specified location.
     *
     * @since 4.3.0
     *
     * @param bool   $has_nav_menu Whether there is a menu assigned to a location.
     * @param string $location     Menu location.
     */
    return apply_filters('has_nav_menu', $has_nav_menu, $location);
}

WordPress Version: 4.5

/**
 * Determines whether a registered nav menu location has a menu assigned to it.
 *
 * @since 3.0.0
 *
 * @param string $location Menu location identifier.
 * @return bool Whether location has a menu.
 */
function has_nav_menu($location)
{
    $has_nav_menu = false;
    $registered_nav_menus = get_registered_nav_menus();
    if (isset($registered_nav_menus[$location])) {
        $locations = get_nav_menu_locations();
        $has_nav_menu = !empty($locations[$location]);
    }
    /**
     * Filter whether a nav menu is assigned to the specified location.
     *
     * @since 4.3.0
     *
     * @param bool   $has_nav_menu Whether there is a menu assigned to a location.
     * @param string $location     Menu location.
     */
    return apply_filters('has_nav_menu', $has_nav_menu, $location);
}

WordPress Version: 4.3

/**
 * Whether a registered nav menu location has a menu assigned to it.
 *
 * @since 3.0.0
 *
 * @param string $location Menu location identifier.
 * @return bool Whether location has a menu.
 */
function has_nav_menu($location)
{
    $has_nav_menu = false;
    $registered_nav_menus = get_registered_nav_menus();
    if (isset($registered_nav_menus[$location])) {
        $locations = get_nav_menu_locations();
        $has_nav_menu = !empty($locations[$location]);
    }
    /**
     * Filter whether a nav menu is assigned to the specified location.
     *
     * @since 4.3.0
     *
     * @param bool   $has_nav_menu Whether there is a menu assigned to a location.
     * @param string $location     Menu location.
     */
    return apply_filters('has_nav_menu', $has_nav_menu, $location);
}

WordPress Version: 4.1

/**
 * Whether a registered nav menu location has a menu assigned to it.
 *
 * @since 3.0.0
 * @param string $location Menu location identifier.
 * @return bool Whether location has a menu.
 */
function has_nav_menu($location)
{
    $registered_nav_menus = get_registered_nav_menus();
    if (!isset($registered_nav_menus[$location])) {
        return false;
    }
    $locations = get_nav_menu_locations();
    return !empty($locations[$location]);
}

WordPress Version: 4.0

/**
 * Whether a registered nav menu location has a menu assigned to it.
 *
 * @since 3.0.0
 * @param string $location Menu location identifier.
 * @return bool Whether location has a menu.
 */
function has_nav_menu($location)
{
    global $_wp_registered_nav_menus;
    if (!isset($_wp_registered_nav_menus[$location])) {
        return false;
    }
    $locations = get_nav_menu_locations();
    return !empty($locations[$location]);
}

WordPress Version: 3.7

/**
 * Whether a registered nav menu location has a menu assigned to it.
 *
 * @since 3.0.0
 * @param string $location Menu location identifier.
 * @return bool Whether location has a menu.
 */
function has_nav_menu($location)
{
    $locations = get_nav_menu_locations();
    return !empty($locations[$location]);
}