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.
Built from https://develop.svn.wordpress.org/trunk@32762


git-svn-id: http://core.svn.wordpress.org/trunk@32733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dominik Schilling 2015-06-14 10:53:25 +00:00
parent 8daec04557
commit 55f3b68c75
3 changed files with 12 additions and 12 deletions

View File

@ -671,10 +671,10 @@ function wp_setup_nav_menu_item( $menu_item ) {
if ( isset( $menu_item->post_type ) ) {
if ( 'nav_menu_item' == $menu_item->post_type ) {
$menu_item->db_id = (int) $menu_item->ID;
$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;
$menu_item->object_id = empty( $menu_item->object_id ) ? get_post_meta( $menu_item->ID, '_menu_item_object_id', true ) : $menu_item->object_id;
$menu_item->object = empty( $menu_item->object ) ? get_post_meta( $menu_item->ID, '_menu_item_object', true ) : $menu_item->object;
$menu_item->type = empty( $menu_item->type ) ? get_post_meta( $menu_item->ID, '_menu_item_type', true ) : $menu_item->type;
$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;
$menu_item->object_id = ! isset( $menu_item->object_id ) ? get_post_meta( $menu_item->ID, '_menu_item_object_id', true ) : $menu_item->object_id;
$menu_item->object = ! isset( $menu_item->object ) ? get_post_meta( $menu_item->ID, '_menu_item_object', true ) : $menu_item->object;
$menu_item->type = ! isset( $menu_item->type ) ? get_post_meta( $menu_item->ID, '_menu_item_type', true ) : $menu_item->type;
if ( 'post_type' == $menu_item->type ) {
$object = get_post_type_object( $menu_item->object );
@ -716,10 +716,10 @@ function wp_setup_nav_menu_item( $menu_item ) {
} else {
$menu_item->type_label = __('Custom Link');
$menu_item->title = $menu_item->post_title;
$menu_item->url = empty( $menu_item->url ) ? get_post_meta( $menu_item->ID, '_menu_item_url', true ) : $menu_item->url;
$menu_item->url = ! isset( $menu_item->url ) ? get_post_meta( $menu_item->ID, '_menu_item_url', true ) : $menu_item->url;
}
$menu_item->target = empty( $menu_item->target ) ? get_post_meta( $menu_item->ID, '_menu_item_target', true ) : $menu_item->target;
$menu_item->target = ! isset( $menu_item->target ) ? get_post_meta( $menu_item->ID, '_menu_item_target', true ) : $menu_item->target;
/**
* Filter a navigation menu item's title attribute.
@ -728,9 +728,9 @@ function wp_setup_nav_menu_item( $menu_item ) {
*
* @param string $item_title The menu item title attribute.
*/
$menu_item->attr_title = empty( $menu_item->attr_title ) ? apply_filters( 'nav_menu_attr_title', $menu_item->post_excerpt ) : $menu_item->attr_title;
$menu_item->attr_title = ! isset( $menu_item->attr_title ) ? apply_filters( 'nav_menu_attr_title', $menu_item->post_excerpt ) : $menu_item->attr_title;
if ( empty( $menu_item->description ) ) {
if ( ! isset( $menu_item->description ) ) {
/**
* Filter a navigation menu item's description.
*
@ -741,8 +741,8 @@ function wp_setup_nav_menu_item( $menu_item ) {
$menu_item->description = apply_filters( 'nav_menu_description', wp_trim_words( $menu_item->post_content, 200 ) );
}
$menu_item->classes = empty( $menu_item->classes ) ? (array) get_post_meta( $menu_item->ID, '_menu_item_classes', true ) : $menu_item->classes;
$menu_item->xfn = empty( $menu_item->xfn ) ? get_post_meta( $menu_item->ID, '_menu_item_xfn', true ) : $menu_item->xfn;
$menu_item->classes = ! isset( $menu_item->classes ) ? (array) get_post_meta( $menu_item->ID, '_menu_item_classes', true ) : $menu_item->classes;
$menu_item->xfn = ! isset( $menu_item->xfn ) ? get_post_meta( $menu_item->ID, '_menu_item_xfn', true ) : $menu_item->xfn;
} else {
$menu_item->db_id = 0;
$menu_item->menu_item_parent = 0;

View File

@ -681,7 +681,7 @@ final class WP_Post {
/**
* Constructor.
*
* @param WP_Post $post Post object.
* @param WP_Post|object $post Post object.
*/
public function __construct( $post ) {
foreach ( get_object_vars( $post ) as $key => $value )

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.3-alpha-32761';
$wp_version = '4.3-alpha-32762';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.