WP_Customize_Nav_Menu_Item_Setting::sort_wp_get_nav_menu_items( array $items, object $menu, array $args )

Re-apply the tail logic also applied on $items by wp_get_nav_menu_items().


Description

See also


Parameters

$items

(Required) An array of menu item post objects.

$menu

(Required) The menu object.

$args

(Required) An array of arguments used to retrieve menu item objects.


Return

(array) Array of menu items,


Source

File: wp-includes/customize/class-wp-customize-nav-menu-item-setting.php

	public static function sort_wp_get_nav_menu_items( $items, $menu, $args ) {
		// @todo We should probably re-apply some constraints imposed by $args.
		unset( $args['include'] );

		// Remove invalid items only in front end.
		if ( ! is_admin() ) {
			$items = array_filter( $items, '_is_valid_nav_menu_item' );
		}

		if ( ARRAY_A === $args['output'] ) {
			$items = wp_list_sort( $items, array(
				$args['output_key'] => 'ASC',
			) );
			$i = 1;

			foreach ( $items as $k => $item ) {
				$items[ $k ]->{$args['output_key']} = $i++;
			}
		}

		return $items;
	}


Changelog

Changelog
Version Description
WP-4.3.0 Introduced.