Docs: Add full documentation for arguments accepted by wp_get_nav_menu_items().

Also provide differentiation between arguments as passed to `get_posts()` vs used for ordering outputted menu items.

By and large, arguments in the `$args` array are intended to directly affect how nav_menu_item posts are retrieved. When the default ARRAY_A is used for 'output', the 'order' and 'orderby' arguments are essentially ignored, instead giving preference to a hard-coded order of 'ASC' and an orderby value derived from the non-get_posts() argument 'output_key'.

Fixes #15533.


git-svn-id: https://develop.svn.wordpress.org/trunk@40942 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Drew Jaynes 2017-06-25 19:36:45 +00:00
parent f25d9d7909
commit 9b91a663df

View File

@ -574,7 +574,12 @@ function _is_valid_nav_menu_item( $item ) {
}
/**
* Return all menu items of a navigation menu.
* Retrieves all menu items of a navigation menu.
*
* Note: Most arguments passed to the `$args` parameter save for 'output_key' are
* specifically for retrieving nav_menu_item posts from get_posts() and may only
* indirectly affect the ultimate ordering and content of the resulting nav menu
* items that get returned from this function.
*
* @since 3.0.0
*
@ -582,7 +587,22 @@ function _is_valid_nav_menu_item( $item ) {
* @staticvar array $fetched
*
* @param string $menu Menu name, ID, or slug.
* @param array $args Optional. Arguments to pass to get_posts().
* @param array $args {
* Optional. Arguments to pass to get_posts().
*
* @type string $order How to order nav menu items as queried with get_posts(). Will be ignored
* if 'output' is ARRAY_A. Default 'ASC'.
* @type string $orderby Field to order menu items by as retrieved from get_posts(). Supply an orderby
* field via 'output_key' to affect the output order of nav menu items.
* Default 'menu_order'.
* @type string $post_type Menu items post type. Default 'nav_menu_item'.
* @type string $post_status Menu items post status. Default 'publish'.
* @type string $output How to order outputted menu items. Default ARRAY_A.
* @type string $output_key Key to use for ordering the actual menu items that get returned. Note that
* that is not a get_posts() argument and will only affect output of menu items
* processed in this function. Default 'menu_order'.
* @type bool $nopaging Whether to retrieve all menu items (true) or paginate (false). Default true.
* }
* @return false|array $items Array of menu items, otherwise false.
*/
function wp_get_nav_menu_items( $menu, $args = array() ) {