Make WordPress Core

Changeset 39503


Ignore:
Timestamp:
12/05/2016 04:48:16 PM (10 years 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.
Merges [39502] onto 4.7 branch.
Fixes #39071 for 4.7.

Location:
branches/4.7
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.7

  • branches/4.7/src/wp-admin/js/customize-nav-menus.js

    r39379 r39503  
    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.