- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php
r41894 r42343 234 234 if ( $post && self::POST_TYPE === $post->post_type ) { 235 235 $is_title_empty = empty( $post->post_title ); 236 $value = (array) wp_setup_nav_menu_item( $post );236 $value = (array) wp_setup_nav_menu_item( $post ); 237 237 if ( $is_title_empty ) { 238 238 $value['title'] = ''; … … 353 353 354 354 if ( ! isset( $this->value['nav_menu_term_id'] ) && $this->post_id > 0 ) { 355 $menus = wp_get_post_terms( $this->post_id, WP_Customize_Nav_Menu_Setting::TAXONOMY, array( 356 'fields' => 'ids', 357 ) ); 355 $menus = wp_get_post_terms( 356 $this->post_id, WP_Customize_Nav_Menu_Setting::TAXONOMY, array( 357 'fields' => 'ids', 358 ) 359 ); 358 360 if ( ! empty( $menus ) ) { 359 361 $this->value['nav_menu_term_id'] = array_shift( $menus ); … … 380 382 if ( ! isset( $this->value['_invalid'] ) ) { 381 383 $this->value['_invalid'] = false; 382 $is_known_invalid = (384 $is_known_invalid = ( 383 385 ( ( 'post_type' === $this->value['type'] || 'post_type_archive' === $this->value['type'] ) && ! post_type_exists( $this->value['object'] ) ) 384 386 || … … 436 438 } 437 439 438 $undefined = new stdClass();440 $undefined = new stdClass(); 439 441 $is_placeholder = ( $this->post_id < 0 ); 440 $is_dirty = ( $undefined !== $this->post_value( $undefined ) );442 $is_dirty = ( $undefined !== $this->post_value( $undefined ) ); 441 443 if ( ! $is_placeholder && ! $is_dirty ) { 442 444 return false; … … 473 475 */ 474 476 public function filter_wp_get_nav_menu_items( $items, $menu, $args ) { 475 $this_item = $this->value();477 $this_item = $this->value(); 476 478 $current_nav_menu_term_id = $this_item['nav_menu_term_id']; 477 479 unset( $this_item['nav_menu_term_id'] ); … … 508 510 } 509 511 510 $mutated = false;512 $mutated = false; 511 513 $should_update = ( 512 514 is_array( $this_item ) … … 556 558 557 559 if ( ARRAY_A === $args['output'] ) { 558 $items = wp_list_sort( $items, array( 559 $args['output_key'] => 'ASC', 560 ) ); 561 $i = 1; 560 $items = wp_list_sort( 561 $items, array( 562 $args['output_key'] => 'ASC', 563 ) 564 ); 565 $i = 1; 562 566 563 567 foreach ( $items as $k => $item ) { … … 583 587 unset( $item->status ); 584 588 585 $item->post_type = 'nav_menu_item';589 $item->post_type = 'nav_menu_item'; 586 590 $item->menu_order = $item->position; 587 591 unset( $item->position ); … … 597 601 } 598 602 599 $item->ID = $this->post_id;603 $item->ID = $this->post_id; 600 604 $item->db_id = $this->post_id; 601 $post = new WP_Post( (object) $item );605 $post = new WP_Post( (object) $item ); 602 606 603 607 if ( empty( $post->post_author ) ) { … … 656 660 } 657 661 658 $default = array(662 $default = array( 659 663 'object_id' => 0, 660 664 'object' => '', … … 674 678 '_invalid' => false, 675 679 ); 676 $menu_item_value = array_merge( $default, $menu_item_value );677 $menu_item_value = wp_array_slice_assoc( $menu_item_value, array_keys( $default ) );680 $menu_item_value = array_merge( $default, $menu_item_value ); 681 $menu_item_value = wp_array_slice_assoc( $menu_item_value, array_keys( $default ) ); 678 682 $menu_item_value['position'] = intval( $menu_item_value['position'] ); 679 683 … … 850 854 if ( is_wp_error( $r ) ) { 851 855 $this->update_status = 'error'; 852 $this->update_error = $r;856 $this->update_error = $r; 853 857 } else { 854 858 if ( $is_placeholder ) { 855 859 $this->previous_post_id = $this->post_id; 856 $this->post_id = $r;857 $this->update_status = 'inserted';860 $this->post_id = $r; 861 $this->update_status = 'inserted'; 858 862 } else { 859 863 $this->update_status = 'updated';
Note: See TracChangeset
for help on using the changeset viewer.