_nav_menu_item_id_use_once

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

Description

(string) _nav_menu_item_id_use_once( (string) $id, (object) $item ); 

Returns (string)

Parameters (2)

0. $id (string)
The id.
1. $item (object)
The item.

Usage

  1. if ( !function_exists( '_nav_menu_item_id_use_once' ) ) { 
  2. require_once ABSPATH . WPINC . '/nav-menu-template.php'; 
  3.  
  4. // The id. 
  5. $id = ''; 
  6.  
  7. // The item. 
  8. $item = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = _nav_menu_item_id_use_once($id, $item); 
  12.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/nav-menu-template.php  
  1. function _nav_menu_item_id_use_once( $id, $item ) { 
  2. static $_used_ids = array(); 
  3. if ( in_array( $item->ID, $_used_ids ) ) { 
  4. return ''; 
  5. $_used_ids[] = $item->ID; 
  6. return $id;