wpseek.com
A WordPress-centric search engine for devs and theme authors



sort_menu › WordPress Function

Sincen/a
Deprecatedn/a
sort_menu ( $a, $b )
Parameters: (2)
  • (array) $a
    Required: Yes
  • (array) $b
    Required: Yes
Returns:
  • (int)
Defined at:
Codex:

No description yet.



Source

function sort_menu( $a, $b ) {
		global $menu_order, $default_menu_order;

		$a = $a[2];
		$b = $b[2];

		if ( isset( $menu_order[ $a ] ) && ! isset( $menu_order[ $b ] ) ) {
			return -1;
		} elseif ( ! isset( $menu_order[ $a ] ) && isset( $menu_order[ $b ] ) ) {
			return 1;
		} elseif ( isset( $menu_order[ $a ] ) && isset( $menu_order[ $b ] ) ) {
			if ( $menu_order[ $a ] === $menu_order[ $b ] ) {
				return 0;
			}
			return ( $menu_order[ $a ] < $menu_order[ $b ] ) ? -1 : 1;
		} else {
			return ( $default_menu_order[ $a ] <= $default_menu_order[ $b ] ) ? -1 : 1;
		}
	}

	usort( $menu, 'sort_menu' );
	unset( $menu_order, $default_menu_order );
}