Changeset 35302
- Timestamp:
- 10/20/2015 07:07:58 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/js/customize-nav-menus.js
r34834 r35302 1251 1251 } 1252 1252 1253 var titleEl = control.container.find( '.menu-item-title' ); 1253 var titleEl = control.container.find( '.menu-item-title' ), 1254 titleText = item.title || api.Menus.data.l10n.untitled; 1255 1256 if ( item._invalid ) { 1257 titleText = api.Menus.data.l10n.invalidTitleTpl.replace( '%s', titleText ); 1258 } 1254 1259 1255 1260 // Don't update to an empty title. 1256 1261 if ( item.title ) { 1257 1262 titleEl 1258 .text( item.title)1263 .text( titleText ) 1259 1264 .removeClass( 'no-title' ); 1260 1265 } else { 1261 1266 titleEl 1262 .text( api.Menus.data.l10n.untitled)1267 .text( titleText ) 1263 1268 .addClass( 'no-title' ); 1264 1269 } … … 1304 1309 ]; 1305 1310 1306 if ( settingValue. invalid ) {1307 containerClasses.push( ' invalid' );1308 control.params.title = api.Menus.data. invalidTitleTpl.replace( '%s', control.params.title );1311 if ( settingValue._invalid ) { 1312 containerClasses.push( 'menu-item-invalid' ); 1313 control.params.title = api.Menus.data.l10n.invalidTitleTpl.replace( '%s', control.params.title ); 1309 1314 } else if ( 'draft' === settingValue.status ) { 1310 1315 containerClasses.push( 'pending' ); -
trunk/src/wp-includes/class-wp-customize-setting.php
r35007 r35302 886 886 'original_title' => '', 887 887 'nav_menu_term_id' => 0, // This will be supplied as the $menu_id arg for wp_update_nav_menu_item(). 888 // @todo also expose invalid?888 '_invalid' => false, 889 889 ); 890 890 … … 1143 1143 $this->value[ $key ] = intval( $this->value[ $key ] ); 1144 1144 } 1145 } 1146 1147 if ( ! isset( $this->value['_invalid'] ) ) { 1148 $this->value['_invalid'] = ( 1149 ( 'post_type' === $this->value['type'] && ! post_type_exists( $this->value['object'] ) ) 1150 || 1151 ( 'taxonomy' === $this->value['type'] && ! taxonomy_exists( $this->value['object'] ) ) 1152 ); 1145 1153 } 1146 1154 … … 1247 1255 false === $this_item 1248 1256 || 1257 true === $this_item['_invalid'] 1258 || 1249 1259 ( 1250 1260 $this->original_nav_menu_term_id === $menu->term_id … … 1418 1428 'original_title' => '', 1419 1429 'nav_menu_term_id' => 0, 1430 '_invalid' => false, 1420 1431 ); 1421 1432 $menu_item_value = array_merge( $default, $menu_item_value ); … … 1449 1460 $menu_item_value['status'] = 'publish'; 1450 1461 } 1462 1463 $menu_item_value['_invalid'] = (bool) $menu_item_value['_invalid']; 1451 1464 1452 1465 /** This filter is documented in wp-includes/class-wp-customize-setting.php */ -
trunk/tests/phpunit/tests/customize/nav-menu-item-setting.php
r35242 r35302 93 93 'original_title' => '', 94 94 'nav_menu_term_id' => 0, 95 '_invalid' => false, 95 96 ); 96 97 $this->assertEquals( $default, $setting->default ); … … 459 460 'original_title' => 'Hi<script>alert(1)</script>', 460 461 'nav_menu_term_id' => 'heilo', 462 '_invalid' => false, 461 463 ); 462 464 … … 665 667 } 666 668 669 /** 670 * @ticket 33665 671 */ 672 function test_invalid_nav_menu_item() { 673 $menu_id = wp_create_nav_menu( 'Primary' ); 674 register_post_type( 'poem', array( 675 'public' => true, 676 ) ); 677 678 $post_id = self::factory()->post->create( array( 'post_type' => 'poem', 'post_title' => 'Code is poetry.' ) ); 679 $post = get_post( $post_id ); 680 $item_id = wp_update_nav_menu_item( $menu_id, 0, array( 681 'menu-item-type' => 'post_type', 682 'menu-item-object' => 'poem', 683 'menu-item-object-id' => $post_id, 684 'menu-item-title' => $post->post_title, 685 'menu-item-status' => 'publish', 686 'menu-item-position' => 1, 687 ) ); 688 $setting_id = "nav_menu_item[$item_id]"; 689 690 do_action( 'customize_register', $this->wp_customize ); 691 $setting = $this->wp_customize->get_setting( $setting_id ); 692 $this->assertNotEmpty( $setting ); 693 $value = $setting->value(); 694 $this->assertFalse( $value['_invalid'] ); 695 $value_object = $setting->value_as_wp_post_nav_menu_item(); 696 $this->assertFalse( $value_object->_invalid ); 697 698 $setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, $setting_id ); 699 $value = $setting->value(); 700 $this->assertFalse( $value['_invalid'] ); 701 $value_object = $setting->value_as_wp_post_nav_menu_item(); 702 $this->assertFalse( $value_object->_invalid ); 703 704 _unregister_post_type( 'poem' ); 705 $setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, $setting_id ); 706 $value = $setting->value(); 707 $this->assertTrue( $value['_invalid'] ); 708 $value_object = $setting->value_as_wp_post_nav_menu_item(); 709 $this->assertTrue( $value_object->_invalid ); 710 } 711 667 712 }
Note: See TracChangeset
for help on using the changeset viewer.