WordPress.org

Make WordPress Core

Changeset 39502


Ignore:
Timestamp:
12/05/16 16:46:59 (15 months ago)
Author:
westonruter
Message:

Customize: Prevent posts/pages imported via starter content from being dropped when adding post/page stubs via nav menus and the dropdown-pages control.

Props westonruter, dlh for testing.
See #38114, #34923.
Fixes #39071.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/customize-nav-menus.js

    r39378 r39502  
    8080    }); 
    8181    api.Menus.availableMenuItems = new api.Menus.AvailableItemCollection( api.Menus.data.availableMenuItems ); 
    82  
    83     api.Menus.insertedAutoDrafts = []; 
    8482 
    8583    /** 
     
    105103        request.done( function( response ) { 
    106104            if ( response.post_id ) { 
    107                 api.Menus.insertedAutoDrafts.push( response.post_id ); 
    108                 api( 'nav_menus_created_posts' ).set( _.clone( api.Menus.insertedAutoDrafts ) ); 
     105                api( 'nav_menus_created_posts' ).set( 
     106                    api( 'nav_menus_created_posts' ).get().concat( [ response.post_id ] ) 
     107                ); 
    109108 
    110109                if ( 'page' === params.post_type ) { 
     
    27982797                api.Menus.applySavedData( data ); 
    27992798            } 
    2800  
    2801             // Reset list of inserted auto draft post IDs. 
    2802             api.Menus.insertedAutoDrafts = []; 
     2799        } ); 
     2800 
     2801        /* 
     2802         * Reset the list of posts created in the customizer once published. 
     2803         * The setting is updated quietly (bypassing events being triggered) 
     2804         * so that the customized state doesn't become immediately dirty. 
     2805         */ 
     2806        api.state( 'changesetStatus' ).bind( function( status ) { 
     2807            if ( 'publish' === status ) { 
     2808                api( 'nav_menus_created_posts' )._value = []; 
     2809            } 
    28032810        } ); 
    28042811 
Note: See TracChangeset for help on using the changeset viewer.