diff -r c7c34916027a -r 177826044cd9 wp/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php --- a/wp/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php Mon Oct 14 18:06:33 2019 +0200 +++ b/wp/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php Mon Oct 14 18:28:13 2019 +0200 @@ -233,7 +233,7 @@ $post = get_post( $this->post_id ); if ( $post && self::POST_TYPE === $post->post_type ) { $is_title_empty = empty( $post->post_title ); - $value = (array) wp_setup_nav_menu_item( $post ); + $value = (array) wp_setup_nav_menu_item( $post ); if ( $is_title_empty ) { $value['title'] = ''; } @@ -352,9 +352,13 @@ } if ( ! isset( $this->value['nav_menu_term_id'] ) && $this->post_id > 0 ) { - $menus = wp_get_post_terms( $this->post_id, WP_Customize_Nav_Menu_Setting::TAXONOMY, array( - 'fields' => 'ids', - ) ); + $menus = wp_get_post_terms( + $this->post_id, + WP_Customize_Nav_Menu_Setting::TAXONOMY, + array( + 'fields' => 'ids', + ) + ); if ( ! empty( $menus ) ) { $this->value['nav_menu_term_id'] = array_shift( $menus ); } else { @@ -379,7 +383,7 @@ if ( ! isset( $this->value['_invalid'] ) ) { $this->value['_invalid'] = false; - $is_known_invalid = ( + $is_known_invalid = ( ( ( 'post_type' === $this->value['type'] || 'post_type_archive' === $this->value['type'] ) && ! post_type_exists( $this->value['object'] ) ) || ( 'taxonomy' === $this->value['type'] && ! taxonomy_exists( $this->value['object'] ) ) @@ -435,9 +439,9 @@ return false; } - $undefined = new stdClass(); + $undefined = new stdClass(); $is_placeholder = ( $this->post_id < 0 ); - $is_dirty = ( $undefined !== $this->post_value( $undefined ) ); + $is_dirty = ( $undefined !== $this->post_value( $undefined ) ); if ( ! $is_placeholder && ! $is_dirty ) { return false; } @@ -466,13 +470,13 @@ * * @see wp_get_nav_menu_items() * - * @param array $items An array of menu item post objects. - * @param object $menu The menu object. - * @param array $args An array of arguments used to retrieve menu item objects. - * @return array Array of menu items, + * @param WP_Post[] $items An array of menu item post objects. + * @param WP_Term $menu The menu object. + * @param array $args An array of arguments used to retrieve menu item objects. + * @return WP_Post[] Array of menu item objects. */ public function filter_wp_get_nav_menu_items( $items, $menu, $args ) { - $this_item = $this->value(); + $this_item = $this->value(); $current_nav_menu_term_id = $this_item['nav_menu_term_id']; unset( $this_item['nav_menu_term_id'] ); @@ -507,7 +511,7 @@ return $filtered_items; } - $mutated = false; + $mutated = false; $should_update = ( is_array( $this_item ) && @@ -536,14 +540,13 @@ * Re-apply the tail logic also applied on $items by wp_get_nav_menu_items(). * * @since 4.3.0 - * @static * * @see wp_get_nav_menu_items() * - * @param array $items An array of menu item post objects. - * @param object $menu The menu object. - * @param array $args An array of arguments used to retrieve menu item objects. - * @return array Array of menu items, + * @param WP_Post[] $items An array of menu item post objects. + * @param WP_Term $menu The menu object. + * @param array $args An array of arguments used to retrieve menu item objects. + * @return WP_Post[] Array of menu item objects. */ public static function sort_wp_get_nav_menu_items( $items, $menu, $args ) { // @todo We should probably re-apply some constraints imposed by $args. @@ -555,10 +558,13 @@ } if ( ARRAY_A === $args['output'] ) { - $items = wp_list_sort( $items, array( - $args['output_key'] => 'ASC', - ) ); - $i = 1; + $items = wp_list_sort( + $items, + array( + $args['output_key'] => 'ASC', + ) + ); + $i = 1; foreach ( $items as $k => $item ) { $items[ $k ]->{$args['output_key']} = $i++; @@ -582,7 +588,7 @@ $item->post_status = $item->status; unset( $item->status ); - $item->post_type = 'nav_menu_item'; + $item->post_type = 'nav_menu_item'; $item->menu_order = $item->position; unset( $item->position ); @@ -596,9 +602,9 @@ $item->post_title = $item->title; } - $item->ID = $this->post_id; + $item->ID = $this->post_id; $item->db_id = $this->post_id; - $post = new WP_Post( (object) $item ); + $post = new WP_Post( (object) $item ); if ( empty( $post->post_author ) ) { $post->post_author = get_current_user_id(); @@ -655,7 +661,7 @@ return null; } - $default = array( + $default = array( 'object_id' => 0, 'object' => '', 'menu_item_parent' => 0, @@ -673,8 +679,8 @@ 'nav_menu_term_id' => 0, '_invalid' => false, ); - $menu_item_value = array_merge( $default, $menu_item_value ); - $menu_item_value = wp_array_slice_assoc( $menu_item_value, array_keys( $default ) ); + $menu_item_value = array_merge( $default, $menu_item_value ); + $menu_item_value = wp_array_slice_assoc( $menu_item_value, array_keys( $default ) ); $menu_item_value['position'] = intval( $menu_item_value['position'] ); foreach ( array( 'object_id', 'menu_item_parent', 'nav_menu_term_id' ) as $key ) { @@ -849,12 +855,12 @@ if ( is_wp_error( $r ) ) { $this->update_status = 'error'; - $this->update_error = $r; + $this->update_error = $r; } else { if ( $is_placeholder ) { $this->previous_post_id = $this->post_id; - $this->post_id = $r; - $this->update_status = 'inserted'; + $this->post_id = $r; + $this->update_status = 'inserted'; } else { $this->update_status = 'updated'; }