wp_nav_menu_disabled_check() WordPress Function

The wp_nav_menu_disabled_check() function is used to check whether a navigation menu is disabled. If a menu is disabled, its items will not be displayed. This function is typically used by plugin developers to disable menus when their plugin is deactivated.

wp_nav_menu_disabled_check( int|string $nav_menu_selected_id, bool $display = true ) #

Check whether to disable the Menu Locations meta box submit button and inputs.


Parameters

$nav_menu_selected_id

(int|string)(Required)ID, name, or slug of the currently selected menu.

$display

(bool)(Optional)Whether to display or just return the string.

Default value: true


Top ↑

Return

(string|false) Disabled attribute if at least one menu exists, false if not.


Top ↑

Source

File: wp-admin/includes/nav-menu.php

function wp_nav_menu_disabled_check( $nav_menu_selected_id, $display = true ) {
	global $one_theme_location_no_menus;

	if ( $one_theme_location_no_menus ) {
		return false;
	}

	return disabled( $nav_menu_selected_id, 0, $display );
}


Top ↑

Changelog

Changelog
VersionDescription
5.3.1The $display parameter was added.
3.6.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.