WordPress.org

Make WordPress Core

Changeset 32762


Ignore:
Timestamp:
06/14/2015 10:52:35 AM (5 years ago)
Author:
ocean90
Message:

Nav Menus: Update wp_setup_nav_menu_item() to stop overriding empty properties from supplied $menu_item.

Update docs for WP_Post constructor to indicate that WP_Post|object can be the supplied param, as opposed to just WP_Post.

props westonruter.
fixes #32632.

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/nav-menu.php

    r32748 r32762  
    672672        if ( 'nav_menu_item' == $menu_item->post_type ) {
    673673            $menu_item->db_id = (int) $menu_item->ID;
    674             $menu_item->menu_item_parent = empty( $menu_item->menu_item_parent ) ? get_post_meta( $menu_item->ID, '_menu_item_menu_item_parent', true ) : $menu_item->menu_item_parent;
    675             $menu_item->object_id = empty( $menu_item->object_id ) ? get_post_meta( $menu_item->ID, '_menu_item_object_id', true ) : $menu_item->object_id;
    676             $menu_item->object = empty( $menu_item->object ) ? get_post_meta( $menu_item->ID, '_menu_item_object', true ) : $menu_item->object;
    677             $menu_item->type = empty( $menu_item->type ) ? get_post_meta( $menu_item->ID, '_menu_item_type', true ) : $menu_item->type;
     674            $menu_item->menu_item_parent = ! isset( $menu_item->menu_item_parent ) ? get_post_meta( $menu_item->ID, '_menu_item_menu_item_parent', true ) : $menu_item->menu_item_parent;
     675            $menu_item->object_id = ! isset( $menu_item->object_id ) ? get_post_meta( $menu_item->ID, '_menu_item_object_id', true ) : $menu_item->object_id;
     676            $menu_item->object = ! isset( $menu_item->object ) ? get_post_meta( $menu_item->ID, '_menu_item_object', true ) : $menu_item->object;
     677            $menu_item->type = ! isset( $menu_item->type ) ? get_post_meta( $menu_item->ID, '_menu_item_type', true ) : $menu_item->type;
    678678
    679679            if ( 'post_type' == $menu_item->type ) {
     
    717717                $menu_item->type_label = __('Custom Link');
    718718                $menu_item->title = $menu_item->post_title;
    719                 $menu_item->url = empty( $menu_item->url ) ? get_post_meta( $menu_item->ID, '_menu_item_url', true ) : $menu_item->url;
     719                $menu_item->url = ! isset( $menu_item->url ) ? get_post_meta( $menu_item->ID, '_menu_item_url', true ) : $menu_item->url;
    720720            }
    721721
    722             $menu_item->target = empty( $menu_item->target ) ? get_post_meta( $menu_item->ID, '_menu_item_target', true ) : $menu_item->target;
     722            $menu_item->target = ! isset( $menu_item->target ) ? get_post_meta( $menu_item->ID, '_menu_item_target', true ) : $menu_item->target;
    723723
    724724            /**
     
    729729             * @param string $item_title The menu item title attribute.
    730730             */
    731             $menu_item->attr_title = empty( $menu_item->attr_title ) ? apply_filters( 'nav_menu_attr_title', $menu_item->post_excerpt ) : $menu_item->attr_title;
    732 
    733             if ( empty( $menu_item->description ) ) {
     731            $menu_item->attr_title = ! isset( $menu_item->attr_title ) ? apply_filters( 'nav_menu_attr_title', $menu_item->post_excerpt ) : $menu_item->attr_title;
     732
     733            if ( ! isset( $menu_item->description ) ) {
    734734                /**
    735735                 * Filter a navigation menu item's description.
     
    742742            }
    743743
    744             $menu_item->classes = empty( $menu_item->classes ) ? (array) get_post_meta( $menu_item->ID, '_menu_item_classes', true ) : $menu_item->classes;
    745             $menu_item->xfn = empty( $menu_item->xfn ) ? get_post_meta( $menu_item->ID, '_menu_item_xfn', true ) : $menu_item->xfn;
     744            $menu_item->classes = ! isset( $menu_item->classes ) ? (array) get_post_meta( $menu_item->ID, '_menu_item_classes', true ) : $menu_item->classes;
     745            $menu_item->xfn = ! isset( $menu_item->xfn ) ? get_post_meta( $menu_item->ID, '_menu_item_xfn', true ) : $menu_item->xfn;
    746746        } else {
    747747            $menu_item->db_id = 0;
  • trunk/src/wp-includes/post.php

    r32729 r32762  
    682682     * Constructor.
    683683     *
    684      * @param WP_Post $post Post object.
     684     * @param WP_Post|object $post Post object.
    685685     */
    686686    public function __construct( $post ) {
Note: See TracChangeset for help on using the changeset viewer.