~canonical-sysadmins/wordpress/4.1.3

« back to all changes in this revision

Viewing changes to wp-includes/nav-menu.php

  • Committer: Nick Moffitt
  • Date: 2015-01-15 11:05:37 UTC
  • mfrom: (1.1.1 wp4-upstream)
  • Revision ID: nick.moffitt@canonical.com-20150115110537-8bp1y42eyg0jsa7c
Tags: 4.1
MergeĀ upstreamĀ versionĀ 4.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
 *
13
13
 * @since 3.0.0
14
14
 *
15
 
 * @uses get_term
16
 
 * @uses get_term_by
17
 
 *
18
15
 * @param string $menu Menu ID, slug, or name.
19
16
 * @return mixed false if $menu param isn't supplied or term does not exist, menu object if successful.
20
17
 */
81
78
/**
82
79
 * Unregisters a navigation menu for a theme.
83
80
 *
84
 
 * @param array $location the menu location identifier
85
 
 *
 
81
 * @param string $location The menu location identifier.
86
82
 * @return bool True on success, false on failure.
87
83
 */
88
84
function unregister_nav_menu( $location ) {
142
138
 * @return bool Whether location has a menu.
143
139
 */
144
140
function has_nav_menu( $location ) {
145
 
        global $_wp_registered_nav_menus;
146
 
 
147
 
        if ( ! isset( $_wp_registered_nav_menus[ $location ] ) ) {
 
141
        $registered_nav_menus = get_registered_nav_menus();
 
142
        if ( ! isset( $registered_nav_menus[ $location ] ) ) {
148
143
                return false;
149
144
        }
150
145
 
461
456
 * Returns all navigation menu objects.
462
457
 *
463
458
 * @since 3.0.0
 
459
 * @since 4.1.0 Default value of the 'orderby' argument was changed from 'none'
 
460
 *              to 'name'.
464
461
 *
465
 
 * @param array $args Array of arguments passed on to get_terms().
466
 
 * @return array menu objects
 
462
 * @param array $args Optional. Array of arguments passed on to {@see get_terms()}.
 
463
 *                    Default empty array.
 
464
 * @return array Menu objects.
467
465
 */
468
466
function wp_get_nav_menus( $args = array() ) {
469
 
        $defaults = array( 'hide_empty' => false, 'orderby' => 'none' );
 
467
        $defaults = array( 'hide_empty' => false, 'orderby' => 'name' );
470
468
        $args = wp_parse_args( $args, $defaults );
471
469
 
472
470
        /**
513
511
}
514
512
 
515
513
/**
516
 
 * Returns if a menu item is valid. Bug #13958
 
514
 * Return if a menu item is valid.
 
515
 *
 
516
 * @link https://core.trac.wordpress.org/ticket/13958
517
517
 *
518
518
 * @since 3.2.0
519
519
 * @access private
520
520
 *
521
 
 * @param object $menu_item The menu item to check
522
 
 * @return bool false if invalid, else true.
 
521
 * @param object $item The menu item to check.
 
522
 * @return bool False if invalid, otherwise true.
523
523
 */
524
524
function _is_valid_nav_menu_item( $item ) {
525
525
        if ( ! empty( $item->_invalid ) )
529
529
}
530
530
 
531
531
/**
532
 
 * Returns all menu items of a navigation menu.
 
532
 * Return all menu items of a navigation menu.
533
533
 *
534
534
 * @since 3.0.0
535
535
 *
536
 
 * @param string $menu menu name, id, or slug
537
 
 * @param string $args
538
 
 * @return mixed $items array of menu items, else false.
 
536
 * @param string $menu Menu name, ID, or slug.
 
537
 * @param array  $args Optional. Arguments to pass to {@see get_posts()}.
 
538
 * @return mixed $items Array of menu items, otherwise false.
539
539
 */
540
540
function wp_get_nav_menu_items( $menu, $args = array() ) {
541
541
        $menu = wp_get_nav_menu_object( $menu );
663
663
 
664
664
                                $original_object = get_post( $menu_item->object_id );
665
665
                                $original_title = $original_object->post_title;
 
666
 
 
667
                                if ( '' === $original_title ) {
 
668
                                        $original_title = sprintf( __( '#%d (no title)' ), $original_object->ID );
 
669
                                }
 
670
 
666
671
                                $menu_item->title = '' == $menu_item->post_title ? $original_title : $menu_item->post_title;
667
672
 
668
673
                        } elseif ( 'taxonomy' == $menu_item->type ) {