Make WordPress Core

Ticket #32814: 32814.8.diff

File 32814.8.diff, 4.9 KB (added by adamsilverstein, 10 years ago)
  • wp-admin/js/customize-nav-menus.js

     
    16471647                                                return;
    16481648                                        }
    16491649                                        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 ) {
    16511651                                                select.append( new Option( name, menuId ) );
    16521652                                        }
    16531653                                } );
    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                                }
    16551666                        }
    16561667                },
    16571668
     
    16951706                                                var select = widgetControl.container.find( 'select' );
    16961707                                                select.find( 'option[value=' + String( menuId ) + ']' ).text( name );
    16971708                                        });
    1698                                         $( '#available-widgets-list .widget-inside:has(input.id_base[value=nav_menu]) select:first option[value=' + String( menuId ) + ']' ).text( name );
    16991709                                }
    17001710                        } );
    17011711
     
    17671777                                                menuItemControl.setting.set( setting );
    17681778                                        });
    17691779                                });
     1780
    17701781                        });
    1771 
    17721782                        control.isReordering = false;
    17731783
    17741784                        /**
     
    18351845                                }
    18361846                                select.find( 'option[value=' + String( menuId ) + ']' ).remove();
    18371847                        });
    1838                         $( '#available-widgets-list .widget-inside:has(input.id_base[value=nav_menu]) select:first option[value=' + String( menuId ) + ']' ).remove();
     1848
    18391849                },
    18401850
    18411851                // Setup theme location checkboxes.
     
    22322242
    22332243                        // Focus on the new menu section.
    22342244                        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 );
    22352248                }
    22362249        });
    22372250
     
    23702383                                        }
    23712384                                } );
    23722385
     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
    23732414                                if ( oldSection.expanded.get() ) {
    23742415                                        // @todo This doesn't seem to be working.
    23752416                                        newSection.expand();
  • wp-admin/js/customize-widgets.js

     
    10411041                        params.wp_customize = 'on';
    10421042                        params.nonce = api.Widgets.data.nonce;
    10431043                        params.theme = api.settings.theme.stylesheet;
     1044                        params.customized = wp.customize.previewer.query().customized;
    10441045
    10451046                        data = $.param( params );
    10461047                        $inputs = this._getInputs( $widgetContent );
  • wp-includes/nav-menu.php

     
    1212 *
    1313 * @since 3.0.0
    1414 *
    15  * @param string $menu Menu ID, slug, or name.
     15 * @param string $menu Menu ID, slug, or name - or the menu object.
    1616 * @return object|false False if $menu param isn't supplied or term does not exist, menu object if successful.
    1717 */
    1818function wp_get_nav_menu_object( $menu ) {
    1919        $menu_obj = false;
    20         if ( $menu ) {
     20
     21        if ( is_object( $menu ) ) {
     22                $menu_obj = $menu;
     23        }
     24
     25        if ( $menu && ! $menu_obj ) {
    2126                $menu_obj = get_term( $menu, 'nav_menu' );
    2227
    2328                if ( ! $menu_obj ) {