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.

Built from https://develop.svn.wordpress.org/trunk@39502


git-svn-id: http://core.svn.wordpress.org/trunk@39442 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter 2016-12-05 16:47:41 +00:00
parent c9b8a5dbbb
commit 97f4180916
3 changed files with 16 additions and 9 deletions

View File

@ -80,8 +80,6 @@
}); });
api.Menus.availableMenuItems = new api.Menus.AvailableItemCollection( api.Menus.data.availableMenuItems ); api.Menus.availableMenuItems = new api.Menus.AvailableItemCollection( api.Menus.data.availableMenuItems );
api.Menus.insertedAutoDrafts = [];
/** /**
* Insert a new `auto-draft` post. * Insert a new `auto-draft` post.
* *
@ -104,8 +102,9 @@
request.done( function( response ) { request.done( function( response ) {
if ( response.post_id ) { if ( response.post_id ) {
api.Menus.insertedAutoDrafts.push( response.post_id ); api( 'nav_menus_created_posts' ).set(
api( 'nav_menus_created_posts' ).set( _.clone( api.Menus.insertedAutoDrafts ) ); api( 'nav_menus_created_posts' ).get().concat( [ response.post_id ] )
);
if ( 'page' === params.post_type ) { if ( 'page' === params.post_type ) {
@ -2797,9 +2796,17 @@
if ( data.nav_menu_updates || data.nav_menu_item_updates ) { if ( data.nav_menu_updates || data.nav_menu_item_updates ) {
api.Menus.applySavedData( data ); api.Menus.applySavedData( data );
} }
} );
// Reset list of inserted auto draft post IDs. /*
api.Menus.insertedAutoDrafts = []; * Reset the list of posts created in the customizer once published.
* The setting is updated quietly (bypassing events being triggered)
* so that the customized state doesn't become immediately dirty.
*/
api.state( 'changesetStatus' ).bind( function( status ) {
if ( 'publish' === status ) {
api( 'nav_menus_created_posts' )._value = [];
}
} ); } );
// Open and focus menu control. // Open and focus menu control.

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.8-alpha-39499'; $wp_version = '4.8-alpha-39502';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.