WordPress.org

Make WordPress Core

Ticket #39352: 39352.diff

File 39352.diff, 866 bytes (added by sirbrillig, 4 years ago)

Prevent adding edit shortcut for nav menus inside widgets

  • src/wp-includes/js/customize-selective-refresh.js

    diff --git src/wp-includes/js/customize-selective-refresh.js src/wp-includes/js/customize-selective-refresh.js
    index 0735b23..0bf22e1 100644
    wp.customize.selectiveRefresh = ( function( $, api ) { 
    120120                        if ( ! $placementContainer.length || $placementContainer.is( illegalContainerSelector ) || $placementContainer.closest( illegalAncestorSelector ).length ) {
    121121                                return;
    122122                        }
     123                        // Prevent nav_menu widgets from getting an edit shortcut for the nav_menu in addition to the widget shortcut
     124                        if ( 'nav_menu' === partial.getType() && $placementContainer.closest( '.widget_nav_menu' ).length ) {
     125                                return;
     126                        }
    123127                        $shortcut = partial.createEditShortcut();
    124128                        $shortcut.on( 'click', function( event ) {
    125129                                event.preventDefault();