Changeset 33488
- Timestamp:
- 07/29/2015 04:02:08 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/js/customize-nav-menus.js
r33483 r33488 958 958 api.Control.prototype.initialize.call( control, id, options ); 959 959 control.active.validate = function() { 960 return api.section( control.section() ).active(); 960 var value, section = api.section( control.section() ); 961 if ( section ) { 962 value = section.active(); 963 } else { 964 value = false; 965 } 966 return value; 961 967 }; 962 968 }, … … 1605 1611 */ 1606 1612 control.active.validate = function() { 1607 return api.section( control.section() ).active(); 1613 var value, section = api.section( control.section() ); 1614 if ( section ) { 1615 value = section.active(); 1616 } else { 1617 value = false; 1618 } 1619 return value; 1608 1620 }; 1609 1621 … … 1651 1663 */ 1652 1664 control.active.validate = function() { 1653 return api.section( control.section() ).active(); 1665 var value, section = api.section( control.section() ); 1666 if ( section ) { 1667 value = section.active(); 1668 } else { 1669 value = false; 1670 } 1671 return value; 1654 1672 }; 1655 1673 … … 1694 1712 menuId = control.params.menu_id, 1695 1713 menu = control.setting(), 1696 name; 1714 name, 1715 widgetTemplate, 1716 select; 1697 1717 1698 1718 if ( 'undefined' === typeof this.params.menu_id ) { … … 1706 1726 */ 1707 1727 control.active.validate = function() { 1708 return api.section( control.section() ).active(); 1728 var value, section = api.section( control.section() ); 1729 if ( section ) { 1730 value = section.active(); 1731 } else { 1732 value = false; 1733 } 1734 return value; 1709 1735 }; 1710 1736 … … 1728 1754 name = displayNavMenuName( menu.name ); 1729 1755 1756 // Add the menu to the existing controls. 1730 1757 api.control.each( function( widgetControl ) { 1731 1758 if ( ! widgetControl.extended( api.controlConstructor.widget_form ) || 'nav_menu' !== widgetControl.params.widget_id_base ) { 1732 1759 return; 1733 1760 } 1734 var select = widgetControl.container.find( 'select' ); 1735 if ( select.find( 'option[value=' + String( menuId ) + ']' ).length === 0 ) { 1761 widgetControl.container.find( '.nav-menu-widget-form-controls:first' ).show(); 1762 widgetControl.container.find( '.nav-menu-widget-no-menus-message:first' ).hide(); 1763 1764 select = widgetControl.container.find( 'select' ); 1765 if ( 0 === select.find( 'option[value=' + String( menuId ) + ']' ).length ) { 1736 1766 select.append( new Option( name, menuId ) ); 1737 1767 } 1738 1768 } ); 1739 $( '#available-widgets-list .widget-inside:has(input.id_base[value=nav_menu]) select:first' ).append( new Option( name, menuId ) ); 1769 1770 // Add the menu to the widget template. 1771 widgetTemplate = $( '#available-widgets-list .widget-tpl:has( input.id_base[ value=nav_menu ] )' ); 1772 widgetTemplate.find( '.nav-menu-widget-form-controls:first' ).show(); 1773 widgetTemplate.find( '.nav-menu-widget-no-menus-message:first' ).hide(); 1774 select = widgetTemplate.find( '.widget-inside select:first' ); 1775 if ( 0 === select.find( 'option[value=' + String( menuId ) + ']' ).length ) { 1776 select.append( new Option( name, menuId ) ); 1777 } 1740 1778 } 1741 1779 }, … … 1762 1800 select.find( 'option[value=' + String( menuId ) + ']' ).text( name ); 1763 1801 }); 1764 $( '#available-widgets-list .widget-inside:has(input.id_base[value=nav_menu]) select:first option[value=' + String( menuId ) + ']' ).text( name );1765 1802 } 1766 1803 } ); … … 1834 1871 }); 1835 1872 }); 1836 }); 1837 1873 1874 }); 1838 1875 control.isReordering = false; 1839 1876 … … 1872 1909 section, 1873 1910 menuId = control.params.menu_id, 1874 removeSection; 1911 removeSection, 1912 widgetTemplate, 1913 navMenuCount = 0; 1875 1914 section = api.section( control.section() ); 1876 1915 removeSection = function() { … … 1891 1930 } 1892 1931 1932 api.each(function( setting ) { 1933 if ( /^nav_menu\[/.test( setting.id ) && false !== setting() ) { 1934 navMenuCount += 1; 1935 } 1936 }); 1937 1893 1938 // Remove the menu from any Custom Menu widgets. 1894 1939 api.control.each(function( widgetControl ) { … … 1900 1945 select.prop( 'selectedIndex', 0 ).trigger( 'change' ); 1901 1946 } 1902 select.find( 'option[value=' + String( menuId ) + ']' ).remove(); 1903 }); 1904 $( '#available-widgets-list .widget-inside:has(input.id_base[value=nav_menu]) select:first option[value=' + String( menuId ) + ']' ).remove(); 1947 1948 widgetControl.container.find( '.nav-menu-widget-form-controls:first' ).toggle( 0 !== navMenuCount ); 1949 widgetControl.container.find( '.nav-menu-widget-no-menus-message:first' ).toggle( 0 === navMenuCount ); 1950 widgetControl.container.find( 'option[value=' + String( menuId ) + ']' ).remove(); 1951 }); 1952 1953 // Remove the menu to the nav menu widget template. 1954 widgetTemplate = $( '#available-widgets-list .widget-tpl:has( input.id_base[ value=nav_menu ] )' ); 1955 widgetTemplate.find( '.nav-menu-widget-form-controls:first' ).toggle( 0 !== navMenuCount ); 1956 widgetTemplate.find( '.nav-menu-widget-no-menus-message:first' ).toggle( 0 === navMenuCount ); 1957 widgetTemplate.find( 'option[value=' + String( menuId ) + ']' ).remove(); 1905 1958 }, 1906 1959 … … 2295 2348 // Focus on the new menu section. 2296 2349 api.section( customizeId ).focus(); // @todo should we focus on the new menu's control and open the add-items panel? Thinking user flow... 2350 2351 // Fix an issue with extra space at top immediately after creating new menu. 2352 $( '#menu-to-edit' ).css( 'margin-top', 0 ); 2297 2353 } 2298 2354 }); … … 2360 2416 2361 2417 _( data.nav_menu_updates ).each(function( update ) { 2362 var oldCustomizeId, newCustomizeId, customizeId, oldSetting, newSetting, setting, settingValue, oldSection, newSection, wasSaved ;2418 var oldCustomizeId, newCustomizeId, customizeId, oldSetting, newSetting, setting, settingValue, oldSection, newSection, wasSaved, widgetTemplate, navMenuCount; 2363 2419 if ( 'inserted' === update.status ) { 2364 2420 if ( ! update.previous_term_id ) { … … 2410 2466 } ); 2411 2467 2412 // Remove old setting and control. 2413 oldSection.container.remove(); 2414 api.section.remove( oldCustomizeId ); 2415 2416 // Add new control to take its place. 2468 // Add new control for the new menu. 2417 2469 api.section.add( newCustomizeId, newSection ); 2418 2470 2419 // Delete the placeholder and preview the new setting. 2471 // Update the values for nav menus in Custom Menu controls. 2472 api.control.each( function( setting ) { 2473 if ( ! setting.extended( api.controlConstructor.widget_form ) || 'nav_menu' !== setting.params.widget_id_base ) { 2474 return; 2475 } 2476 var select, oldMenuOption, newMenuOption; 2477 select = setting.container.find( 'select' ); 2478 oldMenuOption = select.find( 'option[value=' + String( update.previous_term_id ) + ']' ); 2479 newMenuOption = select.find( 'option[value=' + String( update.term_id ) + ']' ); 2480 newMenuOption.prop( 'selected', oldMenuOption.prop( 'selected' ) ); 2481 oldMenuOption.remove(); 2482 } ); 2483 2484 // Delete the old placeholder nav_menu. 2420 2485 oldSetting.callbacks.disable(); // Prevent setting triggering Customizer dirty state when set. 2421 2486 oldSetting.set( false ); 2422 2487 oldSetting.preview(); 2423 2488 newSetting.preview(); 2489 oldSetting._dirty = false; 2490 2491 // Remove nav_menu section. 2492 oldSection.container.remove(); 2493 api.section.remove( oldCustomizeId ); 2494 2495 // Remove the menu to the nav menu widget template. 2496 navMenuCount = 0; 2497 api.each(function( setting ) { 2498 if ( /^nav_menu\[/.test( setting.id ) && false !== setting() ) { 2499 navMenuCount += 1; 2500 } 2501 }); 2502 widgetTemplate = $( '#available-widgets-list .widget-tpl:has( input.id_base[ value=nav_menu ] )' ); 2503 widgetTemplate.find( '.nav-menu-widget-form-controls:first' ).toggle( 0 !== navMenuCount ); 2504 widgetTemplate.find( '.nav-menu-widget-no-menus-message:first' ).toggle( 0 === navMenuCount ); 2505 widgetTemplate.find( 'option[value=' + String( update.previous_term_id ) + ']' ).remove(); 2424 2506 2425 2507 // Update nav_menu_locations to reference the new ID. … … 2438 2520 newSection.expand(); 2439 2521 } 2440 2441 // @todo Update the Custom Menu selects, ensuring the newly-inserted IDs are used for any that have selected a placeholder menu.2442 2522 } else if ( 'updated' === update.status ) { 2443 2523 customizeId = 'nav_menu[' + String( update.term_id ) + ']'; … … 2511 2591 } ); 2512 2592 2513 // Remove old setting andcontrol.2593 // Remove old control. 2514 2594 oldControl.container.remove(); 2515 2595 api.control.remove( oldCustomizeId ); … … 2523 2603 oldSetting.preview(); 2524 2604 newSetting.preview(); 2605 oldSetting._dirty = false; 2525 2606 2526 2607 newControl.container.toggleClass( 'menu-item-edit-inactive', oldControl.container.hasClass( 'menu-item-edit-inactive' ) ); … … 2528 2609 }); 2529 2610 2530 // @todo trigger change event for each Custom Menu widget that was modified. 2611 /* 2612 * Update the settings for any nav_menu widgets that had selected a placeholder ID. 2613 */ 2614 _.each( data.widget_nav_menu_updates, function( widgetSettingValue, widgetSettingId ) { 2615 var setting = api( widgetSettingId ); 2616 if ( setting ) { 2617 setting._value = widgetSettingValue; 2618 setting.preview(); // Send to the preview now so that menu refresh will use the inserted menu. 2619 } 2620 }); 2531 2621 }; 2532 2622 -
trunk/src/wp-admin/js/customize-widgets.js
r32689 r33488 787 787 // Handle widgets that support live previews 788 788 $widgetContent.on( 'change input propertychange', ':input', function( e ) { 789 if ( self.liveUpdateMode ) { 790 if ( e.type === 'change' ) { 791 self.updateWidget(); 792 } else if ( this.checkValidity && this.checkValidity() ) { 793 updateWidgetDebounced(); 794 } 789 if ( ! self.liveUpdateMode ) { 790 return; 791 } 792 if ( e.type === 'change' || ( this.checkValidity && this.checkValidity() ) ) { 793 updateWidgetDebounced(); 795 794 } 796 795 } ); … … 1042 1041 params.nonce = api.Widgets.data.nonce; 1043 1042 params.theme = api.settings.theme.stylesheet; 1043 params.customized = wp.customize.previewer.query().customized; 1044 1044 1045 1045 data = $.param( params ); -
trunk/src/wp-includes/class-wp-customize-setting.php
r33427 r33488 1626 1626 $this->_previewed_blog_id = get_current_blog_id(); 1627 1627 1628 add_filter( 'wp_get_nav_menus', array( $this, 'filter_wp_get_nav_menus' ), 10, 2 ); 1628 1629 add_filter( 'wp_get_nav_menu_object', array( $this, 'filter_wp_get_nav_menu_object' ), 10, 2 ); 1629 1630 add_filter( 'default_option_nav_menu_options', array( $this, 'filter_nav_menu_options' ) ); 1630 1631 add_filter( 'option_nav_menu_options', array( $this, 'filter_nav_menu_options' ) ); 1632 } 1633 1634 /** 1635 * Filter the wp_get_nav_menus() result to ensure the inserted menu object is included, and the deleted one is removed. 1636 * 1637 * @since 4.3.0 1638 * @access public 1639 * 1640 * @see wp_get_nav_menus() 1641 * 1642 * @param array $menus An array of menu objects. 1643 * @param array $args An array of arguments used to retrieve menu objects. 1644 * @return array 1645 */ 1646 public function filter_wp_get_nav_menus( $menus, $args ) { 1647 if ( get_current_blog_id() !== $this->_previewed_blog_id ) { 1648 return $menus; 1649 } 1650 1651 $setting_value = $this->value(); 1652 $is_delete = ( false === $setting_value ); 1653 $index = -1; 1654 1655 // Find the existing menu item's position in the list. 1656 foreach ( $menus as $i => $menu ) { 1657 if ( (int) $this->term_id === (int) $menu->term_id || (int) $this->previous_term_id === (int) $menu->term_id ) { 1658 $index = $i; 1659 break; 1660 } 1661 } 1662 1663 if ( $is_delete ) { 1664 // Handle deleted menu by removing it from the list. 1665 if ( -1 !== $index ) { 1666 array_splice( $menus, $index, 1 ); 1667 } 1668 } else { 1669 // Handle menus being updated or inserted. 1670 $menu_obj = (object) array_merge( array( 1671 'term_id' => $this->term_id, 1672 'term_taxonomy_id' => $this->term_id, 1673 'slug' => sanitize_title( $setting_value['name'] ), 1674 'count' => 0, 1675 'term_group' => 0, 1676 'taxonomy' => self::TAXONOMY, 1677 'filter' => 'raw', 1678 ), $setting_value ); 1679 1680 array_splice( $menus, $index, ( -1 === $index ? 0 : 1 ), array( $menu_obj ) ); 1681 } 1682 1683 // Make sure the menu objects get re-sorted after an update/insert. 1684 if ( ! $is_delete && ! empty( $args['orderby'] ) ) { 1685 $this->_current_menus_sort_orderby = $args['orderby']; 1686 usort( $menus, array( $this, '_sort_menus_by_orderby' ) ); 1687 } 1688 // @todo add support for $args['hide_empty'] === true 1689 1690 return $menus; 1691 } 1692 1693 /** 1694 * Temporary non-closure passing of orderby value to function. 1695 * 1696 * @since 4.3.0 1697 * @access protected 1698 * @var string 1699 * 1700 * @see WP_Customize_Nav_Menu_Setting::filter_wp_get_nav_menus() 1701 * @see WP_Customize_Nav_Menu_Setting::_sort_menus_by_orderby() 1702 */ 1703 protected $_current_menus_sort_orderby; 1704 1705 /** 1706 * Sort menu objects by the class-supplied orderby property. 1707 * 1708 * This is a workaround for a lack of closures. 1709 * 1710 * @since 4.3.0 1711 * @access protected 1712 * @param object $menu1 1713 * @param object $menu2 1714 * @return int 1715 * 1716 * @see WP_Customize_Nav_Menu_Setting::filter_wp_get_nav_menus() 1717 */ 1718 protected function _sort_menus_by_orderby( $menu1, $menu2 ) { 1719 $key = $this->_current_menus_sort_orderby; 1720 return strcmp( $menu1->$key, $menu2->$key ); 1631 1721 } 1632 1722 … … 1753 1843 1754 1844 /** 1845 * Storage for data to be sent back to client in customize_save_response filter. 1846 * 1847 * @access protected 1848 * @since 4.3.0 1849 * @var array 1850 * 1851 * @see WP_Customize_Nav_Menu_Setting::amend_customize_save_response() 1852 */ 1853 protected $_widget_nav_menu_updates = array(); 1854 1855 /** 1755 1856 * Create/update the nav_menu term for this setting. 1756 1857 * … … 1762 1863 * 1763 1864 * @since 4.3.0 1764 * @access p ublic1865 * @access protected 1765 1866 * 1766 1867 * @see wp_update_nav_menu_object() … … 1845 1946 } 1846 1947 1847 // Make sure that new menus assigned to nav menu locations use their new IDs.1848 1948 if ( 'inserted' === $this->update_status ) { 1949 // Make sure that new menus assigned to nav menu locations use their new IDs. 1849 1950 foreach ( $this->manager->settings() as $setting ) { 1850 1951 if ( ! preg_match( '/^nav_menu_locations\[/', $setting->id ) ) { … … 1858 1959 } 1859 1960 } 1961 1962 // Make sure that any nav_menu widgets referencing the placeholder nav menu get updated and sent back to client. 1963 foreach ( array_keys( $this->manager->unsanitized_post_values() ) as $setting_id ) { 1964 $nav_menu_widget_setting = $this->manager->get_setting( $setting_id ); 1965 if ( ! $nav_menu_widget_setting || ! preg_match( '/^widget_nav_menu\[/', $nav_menu_widget_setting->id ) ) { 1966 continue; 1967 } 1968 1969 $widget_instance = $nav_menu_widget_setting->post_value(); // Note that this calls WP_Customize_Widgets::sanitize_widget_instance(). 1970 if ( empty( $widget_instance['nav_menu'] ) || intval( $widget_instance['nav_menu'] ) !== $this->previous_term_id ) { 1971 continue; 1972 } 1973 1974 $widget_instance['nav_menu'] = $this->term_id; 1975 $updated_widget_instance = $this->manager->widgets->sanitize_widget_js_instance( $widget_instance ); 1976 $this->manager->set_post_value( $nav_menu_widget_setting->id, $updated_widget_instance ); 1977 $nav_menu_widget_setting->save(); 1978 1979 $this->_widget_nav_menu_updates[ $nav_menu_widget_setting->id ] = $updated_widget_instance; 1980 } 1860 1981 } 1861 1982 } … … 1865 1986 * 1866 1987 * @since 4.3.0 1867 * @access p ublic1988 * @access protected 1868 1989 * 1869 1990 * @see WP_Customize_Nav_Menu_Setting::filter_nav_menu_options() … … 1905 2026 if ( ! isset( $data['nav_menu_updates'] ) ) { 1906 2027 $data['nav_menu_updates'] = array(); 2028 } 2029 if ( ! isset( $data['widget_nav_menu_updates'] ) ) { 2030 $data['widget_nav_menu_updates'] = array(); 1907 2031 } 1908 2032 … … 1915 2039 ); 1916 2040 2041 $data['widget_nav_menu_updates'] = array_merge( 2042 $data['widget_nav_menu_updates'], 2043 $this->_widget_nav_menu_updates 2044 ); 2045 $this->_widget_nav_menu_updates = array(); 2046 1917 2047 return $data; 1918 2048 } -
trunk/src/wp-includes/class-wp-customize-widgets.php
r32964 r33488 1242 1242 global $wp_registered_widget_updates, $wp_registered_widget_controls; 1243 1243 1244 $setting_id = $this->get_setting_id( $widget_id ); 1245 1246 /* 1247 * Make sure that other setting changes have previewed since this widget 1248 * may depend on them (e.g. Menus being present for Custom Menu widget). 1249 */ 1250 if ( ! did_action( 'customize_preview_init' ) ) { 1251 foreach ( $this->manager->settings() as $setting ) { 1252 if ( $setting->id !== $setting_id ) { 1253 $setting->preview(); 1254 } 1255 } 1256 } 1257 1244 1258 $this->start_capturing_option_updates(); 1245 1259 $parsed_id = $this->parse_widget_id( $widget_id ); … … 1322 1336 * instead of the default widget instance value (an empty array). 1323 1337 */ 1324 $setting_id = $this->get_setting_id( $widget_id );1325 1338 $this->manager->set_post_value( $setting_id, $instance ); 1326 1339 -
trunk/src/wp-includes/default-widgets.php
r32907 r33488 1571 1571 1572 1572 // If no menus exists, direct the user to go and create some. 1573 if ( !$menus ) {1574 echo '<p>'. sprintf( __('No menus have been created yet. <a href="%s">Create some</a>.'), admin_url('nav-menus.php') ) .'</p>';1575 return;1576 }1577 1573 ?> 1578 <p> 1579 <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:') ?></label> 1580 <input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo $title; ?>" /> 1574 <p class="nav-menu-widget-no-menus-message" <?php if ( ! empty( $menus ) ) { echo ' style="display:none" '; } ?>> 1575 <?php 1576 if ( isset( $GLOBALS['wp_customize'] ) && $GLOBALS['wp_customize'] instanceof WP_Customize_Manager ) { 1577 // @todo When expanding a panel, the JS should be smart enough to collapse any existing panels and sections. 1578 $url = 'javascript: wp.customize.section.each(function( section ){ section.collapse(); }); wp.customize.panel( "nav_menus" ).focus();'; 1579 } else { 1580 $url = admin_url( 'nav-menus.php' ); 1581 } 1582 ?> 1583 <?php echo sprintf( __( 'No menus have been created yet. <a href="%s">Create some</a>.' ), esc_attr( $url ) ); ?> 1581 1584 </p> 1582 <p> 1583 <label for="<?php echo $this->get_field_id('nav_menu'); ?>"><?php _e('Select Menu:'); ?></label> 1584 <select id="<?php echo $this->get_field_id('nav_menu'); ?>" name="<?php echo $this->get_field_name('nav_menu'); ?>"> 1585 <option value="0"><?php _e( '— Select —' ) ?></option> 1586 <?php 1587 foreach ( $menus as $menu ) { 1588 echo '<option value="' . $menu->term_id . '"' 1589 . selected( $nav_menu, $menu->term_id, false ) 1590 . '>'. esc_html( $menu->name ) . '</option>'; 1591 } 1592 ?> 1593 </select> 1594 </p> 1585 <div class="nav-menu-widget-form-controls" <?php if ( empty( $menus ) ) { echo ' style="display:none" '; } ?>> 1586 <p> 1587 <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ) ?></label> 1588 <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo esc_attr( $title ); ?>"/> 1589 </p> 1590 <p> 1591 <label for="<?php echo $this->get_field_id( 'nav_menu' ); ?>"><?php _e( 'Select Menu:' ); ?></label> 1592 <select id="<?php echo $this->get_field_id( 'nav_menu' ); ?>" name="<?php echo $this->get_field_name( 'nav_menu' ); ?>"> 1593 <option value="0"><?php _e( '— Select —' ); ?></option> 1594 <?php foreach ( $menus as $menu ) : ?> 1595 <option value="<?php echo esc_attr( $menu->term_id ); ?>" <?php selected( $nav_menu, $menu->term_id ); ?>> 1596 <?php echo esc_html( $menu->name ); ?> 1597 </option> 1598 <?php endforeach; ?> 1599 </select> 1600 </p> 1601 </div> 1595 1602 <?php 1596 1603 } -
trunk/src/wp-includes/nav-menu.php
r33427 r33488 13 13 * @since 3.0.0 14 14 * 15 * @param string $menu Menu ID, slug, or name .15 * @param string $menu Menu ID, slug, or name - or the menu object. 16 16 * @return object|false False if $menu param isn't supplied or term does not exist, menu object if successful. 17 17 */ 18 18 function wp_get_nav_menu_object( $menu ) { 19 19 $menu_obj = false; 20 if ( $menu ) { 20 21 if ( is_object( $menu ) ) { 22 $menu_obj = $menu; 23 } 24 25 if ( $menu && ! $menu_obj ) { 21 26 $menu_obj = get_term( $menu, 'nav_menu' ); 22 27 -
trunk/tests/phpunit/tests/customize/nav-menu-setting.php
r33071 r33488 212 212 $nav_menu_options = get_option( 'nav_menu_options', array( 'auto_add' => array() ) ); 213 213 $this->assertContains( $menu_id, $nav_menu_options['auto_add'] ); 214 215 $menus = wp_get_nav_menus(); 216 $menus_ids = wp_list_pluck( $menus, 'term_id' ); 217 $i = array_search( $menu_id, $menus_ids ); 218 $this->assertNotFalse( $i, 'Update-previewed menu does not appear in wp_get_nav_menus()' ); 219 $filtered_menu = $menus[ $i ]; 220 $this->assertEquals( 'Name 2', $filtered_menu->name ); 214 221 } 215 222 … … 250 257 $nav_menu_options = $this->get_nav_menu_items_option(); 251 258 $this->assertNotContains( $menu_id, $nav_menu_options['auto_add'] ); 259 260 $menus = wp_get_nav_menus(); 261 $menus_ids = wp_list_pluck( $menus, 'term_id' ); 262 $i = array_search( $menu_id, $menus_ids ); 263 $this->assertNotFalse( $i, 'Insert-previewed menu was not injected into wp_get_nav_menus()' ); 264 $filtered_menu = $menus[ $i ]; 265 $this->assertEquals( 'New Menu Name 1', $filtered_menu->name ); 252 266 } 253 267
Note: See TracChangeset
for help on using the changeset viewer.