Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

_nav_menu_item_id_use_once() WordPress Function

The nav_menu_item_id_use_once() function is used to check if a given menu item ID is currently in use. This can be useful when you need to make sure that a given menu item is only used once.

_nav_menu_item_id_use_once( string $id, object $item ) #

Prevents a menu item ID from being used more than once.


Parameters

$id

(string)(Required)

$item

(object)(Required)


Top ↑

Return

(string)


Top ↑

Source

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

function _nav_menu_item_id_use_once( $id, $item ) {
	static $_used_ids = array();

	if ( in_array( $item->ID, $_used_ids, true ) ) {
		return '';
	}

	$_used_ids[] = $item->ID;

	return $id;
}

Top ↑

Changelog

Changelog
VersionDescription
3.0.1Introduced.

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.