_sort_nav_menu_items

Sort menu items by the desired key.

Description

(int) _sort_nav_menu_items( (object) $a, (object) $b ); 

Returns (int)

-1, 0, or 1 if $a is considered to be respectively less than, equal to, or greater than $b.

Parameters (2)

0. $a (object)
The first object to compare
1. $b (object)
The second object to compare

Usage

  1. if ( !function_exists( '_sort_nav_menu_items' ) ) { 
  2. require_once ABSPATH . WPINC . '/deprecated.php'; 
  3.  
  4. // The first object to compare 
  5. $a = null; 
  6.  
  7. // The second object to compare 
  8. $b = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = _sort_nav_menu_items($a, $b); 
  12.  

Defined (1)

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

/wp-includes/deprecated.php  
  1. function _sort_nav_menu_items( $a, $b ) { 
  2. global $_menu_item_sort_prop; 
  3.  
  4. _deprecated_function( __FUNCTION__, '4.7.0', 'wp_list_sort' ); 
  5.  
  6. if ( empty( $_menu_item_sort_prop ) ) 
  7. return 0; 
  8.  
  9. if ( ! isset( $a->$_menu_item_sort_prop ) || ! isset( $b->$_menu_item_sort_prop ) ) 
  10. return 0; 
  11.  
  12. $_a = (int) $a->$_menu_item_sort_prop; 
  13. $_b = (int) $b->$_menu_item_sort_prop; 
  14.  
  15. if ( $a->$_menu_item_sort_prop == $b->$_menu_item_sort_prop ) 
  16. return 0; 
  17. elseif ( $_a == $a->$_menu_item_sort_prop && $_b == $b->$_menu_item_sort_prop ) 
  18. return $_a < $_b ? -1 : 1; 
  19. else 
  20. return strcmp( $a->$_menu_item_sort_prop, $b->$_menu_item_sort_prop );