[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

title

Body

[close]

/wp-includes/ -> nav-menu.php (summary)

Navigation Menu functions

File Size: 1227 lines (41 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 25 functions

  wp_get_nav_menu_object()
  is_nav_menu()
  register_nav_menus()
  unregister_nav_menu()
  register_nav_menu()
  get_registered_nav_menus()
  get_nav_menu_locations()
  has_nav_menu()
  wp_get_nav_menu_name()
  is_nav_menu_item()
  wp_create_nav_menu()
  wp_delete_nav_menu()
  wp_update_nav_menu_object()
  wp_update_nav_menu_item()
  wp_get_nav_menus()
  _is_valid_nav_menu_item()
  wp_get_nav_menu_items()
  wp_setup_nav_menu_item()
  wp_get_associated_nav_menu_items()
  _wp_delete_post_menu_item()
  _wp_delete_tax_menu_item()
  _wp_auto_add_pages_to_menu()
  _wp_delete_customize_changeset_dependent_auto_drafts()
  _wp_menus_changed()
  wp_map_nav_menu_locations()

Functions
Functions that are not part of a class:

wp_get_nav_menu_object( $menu )   X-Ref
Returns a navigation menu object.

return: WP_Term|false False if $menu param isn't supplied or term does not exist, menu object if successful.
param: int|string|WP_Term $menu Menu ID, slug, name, or object.

is_nav_menu( $menu )   X-Ref
Check if the given ID is a navigation menu.

Returns true if it is; false otherwise.

return: bool Whether the menu exists.
param: int|string|WP_Term $menu Menu ID, slug, name, or object of menu to check.

register_nav_menus( $locations = array()   X-Ref
Registers navigation menu locations for a theme.

param: array $locations Associative array of menu location identifiers (like a slug) and descriptive text.

unregister_nav_menu( $location )   X-Ref
Unregisters a navigation menu location for a theme.

return: bool True on success, false on failure.
param: string $location The menu location identifier.

register_nav_menu( $location, $description )   X-Ref
Registers a navigation menu location for a theme.

param: string $location    Menu location identifier, like a slug.
param: string $description Menu location descriptive text.

get_registered_nav_menus()   X-Ref
Retrieves all registered navigation menu locations in a theme.

return: array Registered navigation menu locations. If none are registered, an empty array.

get_nav_menu_locations()   X-Ref
Retrieves all registered navigation menu locations and the menus assigned to them.

return: array Registered navigation menu locations and the menus assigned them.

has_nav_menu( $location )   X-Ref
Determines whether a registered nav menu location has a menu assigned to it.

return: bool Whether location has a menu.
param: string $location Menu location identifier.

wp_get_nav_menu_name( $location )   X-Ref
Returns the name of a navigation menu.

return: string Menu name.
param: string $location Menu location identifier.

is_nav_menu_item( $menu_item_id = 0 )   X-Ref
Determines whether the given ID is a nav menu item.

return: bool Whether the given ID is that of a nav menu item.
param: int $menu_item_id The ID of the potential nav menu item.

wp_create_nav_menu( $menu_name )   X-Ref
Creates a navigation menu.

Note that `$menu_name` is expected to be pre-slashed.

return: int|WP_Error Menu ID on success, WP_Error object on failure.
param: string $menu_name Menu name.

wp_delete_nav_menu( $menu )   X-Ref
Delete a Navigation Menu.

return: bool|WP_Error True on success, false or WP_Error object on failure.
param: int|string|WP_Term $menu Menu ID, slug, name, or object.

wp_update_nav_menu_object( $menu_id = 0, $menu_data = array()   X-Ref
Save the properties of a menu or create a new menu with those properties.

Note that `$menu_data` is expected to be pre-slashed.

return: int|WP_Error Menu ID on success, WP_Error object on failure.
param: int   $menu_id   The ID of the menu or "0" to create a new menu.
param: array $menu_data The array of menu data.

wp_update_nav_menu_item( $menu_id = 0, $menu_item_db_id = 0, $menu_item_data = array()   X-Ref
Save the properties of a menu item or create a new one.

The menu-item-title, menu-item-description, and menu-item-attr-title are expected
to be pre-slashed since they are passed directly into `wp_insert_post()`.

return: int|WP_Error The menu item's database ID or WP_Error object on failure.
param: int   $menu_id         The ID of the menu. Required. If "0", makes the menu item a draft orphan.
param: int   $menu_item_db_id The ID of the menu item. If "0", creates a new menu item.
param: array $menu_item_data  The menu item's data.

wp_get_nav_menus( $args = array()   X-Ref
Returns all navigation menu objects.

return: array Menu objects.
param: array $args Optional. Array of arguments passed on to get_terms().

_is_valid_nav_menu_item( $item )   X-Ref
Return if a menu item is valid.

return: bool False if invalid, otherwise true.
param: object $item The menu item to check.

wp_get_nav_menu_items( $menu, $args = array()   X-Ref
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.

return: false|array $items Array of menu items, otherwise false.
param: int|string|WP_Term $menu Menu ID, slug, name, or object.
param: array              $args {

wp_setup_nav_menu_item( $menu_item )   X-Ref
Decorates a menu item object with the shared navigation menu item properties.

Properties:
- ID:               The term_id if the menu item represents a taxonomy term.
- attr_title:       The title attribute of the link element for this menu item.
- classes:          The array of class attribute values for the link element of this menu item.
- db_id:            The DB ID of this item as a nav_menu_item object, if it exists (0 if it doesn't exist).
- description:      The description of this menu item.
- menu_item_parent: The DB ID of the nav_menu_item that is this item's menu parent, if any. 0 otherwise.
- object:           The type of object originally represented, such as "category," "post", or "attachment."
- object_id:        The DB ID of the original object this menu item represents, e.g. ID for posts and term_id for categories.
- post_parent:      The DB ID of the original object's parent object, if any (0 otherwise).
- post_title:       A "no title" label if menu item represents a post that lacks a title.
- target:           The target attribute of the link element for this menu item.
- title:            The title of this menu item.
- type:             The family of objects originally represented, such as "post_type" or "taxonomy."
- type_label:       The singular label used to describe this type of menu item.
- url:              The URL to which this menu item points.
- xfn:              The XFN relationship expressed in the link of this menu item.
- _invalid:         Whether the menu item represents an object that no longer exists.

return: object $menu_item The menu item with standard menu item properties.
param: object $menu_item The menu item to modify.

wp_get_associated_nav_menu_items( $object_id = 0, $object_type = 'post_type', $taxonomy = '' )   X-Ref
Get the menu items associated with a particular object.

return: array The array of menu item IDs; empty array if none;
param: int    $object_id   The ID of the original object.
param: string $object_type The type of object, such as "taxonomy" or "post_type."
param: string $taxonomy    If $object_type is "taxonomy", $taxonomy is the name of the tax that $object_id belongs to

_wp_delete_post_menu_item( $object_id = 0 )   X-Ref
Callback for handling a menu item when its original object is deleted.

param: int $object_id The ID of the original object being trashed.

_wp_delete_tax_menu_item( $object_id = 0, $tt_id, $taxonomy )   X-Ref
Serves as a callback for handling a menu item when its original object is deleted.

param: int    $object_id Optional. The ID of the original object being trashed. Default 0.
param: int    $tt_id     Term taxonomy ID. Unused.
param: string $taxonomy  Taxonomy slug.

_wp_auto_add_pages_to_menu( $new_status, $old_status, $post )   X-Ref
Automatically add newly published page objects to menus with that as an option.

param: string $new_status The new status of the post object.
param: string $old_status The old status of the post object.
param: object $post       The post object being transitioned from one status to another.

_wp_delete_customize_changeset_dependent_auto_drafts( $post_id )   X-Ref
Delete auto-draft posts associated with the supplied changeset.

param: int $post_id Post ID for the customize_changeset.

_wp_menus_changed()   X-Ref
Handle menu config after theme change.


wp_map_nav_menu_locations( $new_nav_menu_locations, $old_nav_menu_locations )   X-Ref
Maps nav menu locations according to assignments in previously active theme.

return: array Nav menus mapped to new nav menu locations.
param: array $new_nav_menu_locations New nav menu locations assignments.
param: array $old_nav_menu_locations Old nav menu locations assignments.



Generated: Sat Feb 16 08:20:01 2019 Cross-referenced by PHPXref 0.7