*
* @since 3.0.0
*
- * @uses get_term
- * @uses get_term_by
- *
* @param string $menu Menu ID, slug, or name.
* @return mixed false if $menu param isn't supplied or term does not exist, menu object if successful.
*/
/**
* Unregisters a navigation menu for a theme.
*
- * @param array $location the menu location identifier
- *
+ * @param string $location The menu location identifier.
* @return bool True on success, false on failure.
*/
function unregister_nav_menu( $location ) {
* @return bool Whether location has a menu.
*/
function has_nav_menu( $location ) {
- global $_wp_registered_nav_menus;
-
- if ( ! isset( $_wp_registered_nav_menus[ $location ] ) ) {
+ $registered_nav_menus = get_registered_nav_menus();
+ if ( ! isset( $registered_nav_menus[ $location ] ) ) {
return false;
}
* Returns all navigation menu objects.
*
* @since 3.0.0
+ * @since 4.1.0 Default value of the 'orderby' argument was changed from 'none'
+ * to 'name'.
*
- * @param array $args Array of arguments passed on to get_terms().
- * @return array menu objects
+ * @param array $args Optional. Array of arguments passed on to {@see get_terms()}.
+ * Default empty array.
+ * @return array Menu objects.
*/
function wp_get_nav_menus( $args = array() ) {
- $defaults = array( 'hide_empty' => false, 'orderby' => 'none' );
+ $defaults = array( 'hide_empty' => false, 'orderby' => 'name' );
$args = wp_parse_args( $args, $defaults );
/**
}
/**
- * Returns if a menu item is valid. Bug #13958
+ * Return if a menu item is valid.
+ *
+ * @link https://core.trac.wordpress.org/ticket/13958
*
* @since 3.2.0
* @access private
*
- * @param object $menu_item The menu item to check
- * @return bool false if invalid, else true.
+ * @param object $item The menu item to check.
+ * @return bool False if invalid, otherwise true.
*/
function _is_valid_nav_menu_item( $item ) {
if ( ! empty( $item->_invalid ) )
}
/**
- * Returns all menu items of a navigation menu.
+ * Return all menu items of a navigation menu.
*
* @since 3.0.0
*
- * @param string $menu menu name, id, or slug
- * @param string $args
- * @return mixed $items array of menu items, else false.
+ * @param string $menu Menu name, ID, or slug.
+ * @param array $args Optional. Arguments to pass to {@see get_posts()}.
+ * @return mixed $items Array of menu items, otherwise false.
*/
function wp_get_nav_menu_items( $menu, $args = array() ) {
$menu = wp_get_nav_menu_object( $menu );
$original_object = get_post( $menu_item->object_id );
$original_title = $original_object->post_title;
+
+ if ( '' === $original_title ) {
+ $original_title = sprintf( __( '#%d (no title)' ), $original_object->ID );
+ }
+
$menu_item->title = '' == $menu_item->post_title ? $original_title : $menu_item->post_title;
} elseif ( 'taxonomy' == $menu_item->type ) {