Ticket #32814: 32814.8.diff
File 32814.8.diff, 4.9 KB (added by , 10 years ago) |
---|
-
wp-admin/js/customize-nav-menus.js
1647 1647 return; 1648 1648 } 1649 1649 var select = widgetControl.container.find( 'select' ); 1650 if ( select.find( 'option[value=' + String( menuId ) + ']' ).length === 0) {1650 if ( 0 === select.find( 'option[value=' + String( menuId ) + ']' ).length ) { 1651 1651 select.append( new Option( name, menuId ) ); 1652 1652 } 1653 1653 } ); 1654 $( '#available-widgets-list .widget-inside:has(input.id_base[value=nav_menu]) select:first' ).append( new Option( name, menuId ) ); 1654 // Add to any already present widgets. 1655 //$( '#available-widgets-list .widget-inside:has(input.id_base[value=nav_menu]) select:first' ).append( new Option( name, menuId ) ); 1656 1657 // Add the menu to the widget template. 1658 // @todo Not this only works of the widget area already has a 1659 // select element, add coverage for no menus case. 1660 var template = $( '#available-widgets-list .widget-inside:has( input.id_base[ value=nav_menu ] ) select:first' ); 1661 1662 // Avoid duplicate insertion. 1663 if ( 0 === template.find( 'option[value=' + String( menuId ) + ']' ).length ) { 1664 template.append( new Option( name, menuId ) ); 1665 } 1655 1666 } 1656 1667 }, 1657 1668 … … 1695 1706 var select = widgetControl.container.find( 'select' ); 1696 1707 select.find( 'option[value=' + String( menuId ) + ']' ).text( name ); 1697 1708 }); 1698 $( '#available-widgets-list .widget-inside:has(input.id_base[value=nav_menu]) select:first option[value=' + String( menuId ) + ']' ).text( name );1699 1709 } 1700 1710 } ); 1701 1711 … … 1767 1777 menuItemControl.setting.set( setting ); 1768 1778 }); 1769 1779 }); 1780 1770 1781 }); 1771 1772 1782 control.isReordering = false; 1773 1783 1774 1784 /** … … 1835 1845 } 1836 1846 select.find( 'option[value=' + String( menuId ) + ']' ).remove(); 1837 1847 }); 1838 $( '#available-widgets-list .widget-inside:has(input.id_base[value=nav_menu]) select:first option[value=' + String( menuId ) + ']' ).remove(); 1848 1839 1849 }, 1840 1850 1841 1851 // Setup theme location checkboxes. … … 2232 2242 2233 2243 // Focus on the new menu section. 2234 2244 api.section( customizeId ).focus(); // @todo should we focus on the new menu's control and open the add-items panel? Thinking user flow... 2245 2246 // Fix an issue with extra space at top immediately after creating new menu. 2247 $( '#menu-to-edit' ).css( 'margin-top', 0 ); 2235 2248 } 2236 2249 }); 2237 2250 … … 2370 2383 } 2371 2384 } ); 2372 2385 2386 /** 2387 * Update the saved menu in any custom menu widgets. 2388 * If the previous_term_id item is selected, reselect the 2389 * item with the updated term_id. 2390 */ 2391 api.control.each( function( setting ) { 2392 // Only act on nav_menu widgets. 2393 if ( ! setting.extended( api.controlConstructor.widget_form ) || 2394 'nav_menu' !== setting.params.widget_id_base ) { 2395 return; 2396 } 2397 var select, oldMenuOption, oldMenuSelected, newMenuOption; 2398 select = setting.container.find( 'select' ); 2399 oldMenuOption = select.find( 'option[value=' + String( update.previous_term_id ) + ']' ); 2400 oldMenuSelected = select.find( 'option[value=' + String( update.previous_term_id ) + ']:selected' ); 2401 newMenuOption = select.find( 'option[value=' + String( update.term_id ) + ']' ); 2402 2403 // Adjust menu options matching the old ID, setting them to the new ID. 2404 if ( oldMenuSelected.length !== 0 && newMenuOption !== 0 ) { 2405 // Remove the old option. 2406 oldMenuOption.remove(); 2407 // Select the new option. 2408 newMenuOption.attr( 'selected', true ).trigger( 'change' ); 2409 } 2410 2411 2412 } ); 2413 2373 2414 if ( oldSection.expanded.get() ) { 2374 2415 // @todo This doesn't seem to be working. 2375 2416 newSection.expand(); -
wp-admin/js/customize-widgets.js
1041 1041 params.wp_customize = 'on'; 1042 1042 params.nonce = api.Widgets.data.nonce; 1043 1043 params.theme = api.settings.theme.stylesheet; 1044 params.customized = wp.customize.previewer.query().customized; 1044 1045 1045 1046 data = $.param( params ); 1046 1047 $inputs = this._getInputs( $widgetContent ); -
wp-includes/nav-menu.php
12 12 * 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 23 28 if ( ! $menu_obj ) {