Customize: Allow post/page stubs to be edited in WP Admin as "customization drafts" when changeset is saved as draft or scheduled.

* Update stubs to have draft status when changeset is saved as draft, instead of preventing auto-draft garbage collection by giving them a far-future `post_date`.
* Show notice in publish metabox when editing a customization draft indicating that it will be published automatically with its changeset; a link to Customizer is included.
* Include a new "Customization Draft" display post state in the post list table.
* Disconnect stubs from their changesets when they are updated with a status other than "Draft".
* Trash customization drafts when their related changeset is trashed or deleted.
* Add a `_customize_changeset_uuid` postmeta to stubs to link them with their associated changeset.
* Include `customize_changeset_uuid` as context when requesting to insert a new auto-draft.

Props westonruter, melchoyce.
See #39896, #39752, #34923.
Fixes #42220.


git-svn-id: https://develop.svn.wordpress.org/trunk@41887 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Weston Ruter
2017-10-17 20:14:56 +00:00
parent ee678ee1f5
commit ce7a93c235
11 changed files with 225 additions and 41 deletions

View File

@@ -964,6 +964,11 @@ th.action-links {
text-align: right;
}
#misc-publishing-actions .notice {
margin-left: 10px;
margin-right: 10px;
}
/* Filter bar */
.wp-filter {
display: inline-block;

View File

@@ -223,6 +223,26 @@ if ( $can_publish ) : // Contributors don't get to choose the date of publish ?>
</div><?php // /misc-pub-section ?>
<?php endif; ?>
<?php if ( 'draft' === $post->post_status && get_post_meta( $post->ID, '_customize_changeset_uuid', true ) ) : ?>
<div class="notice notice-info notice-alt inline">
<p>
<?php
echo sprintf(
/* translators: %s is the URL to the Customizer */
__( 'This draft comes from your <a href="%s">unpublished customization changes</a>. You can edit, but there&#8217;s no need to publish now. It will be published automatically with those changes.' ),
esc_url(
add_query_arg(
'changeset_uuid',
rawurlencode( get_post_meta( $post->ID, '_customize_changeset_uuid', true ) ),
admin_url( 'customize.php' )
)
)
);
?>
</p>
</div>
<?php endif; ?>
<?php
/**
* Fires after the post time/date setting in the Publish meta box.

View File

@@ -1736,8 +1736,15 @@ function _post_states($post) {
$post_states['protected'] = __('Password protected');
if ( 'private' == $post->post_status && 'private' != $post_status )
$post_states['private'] = __('Private');
if ( 'draft' == $post->post_status && 'draft' != $post_status )
$post_states['draft'] = __('Draft');
if ( 'draft' === $post->post_status ) {
if ( get_post_meta( $post->ID, '_customize_changeset_uuid', true ) ) {
$post_states[] = __( 'Customization Draft' );
} elseif ( 'draft' !== $post_status ) {
$post_states['draft'] = __( 'Draft' );
}
} elseif ( 'trash' === $post->post_status && get_post_meta( $post->ID, '_customize_changeset_uuid', true ) ) {
$post_states[] = __( 'Customization Draft' );
}
if ( 'pending' == $post->post_status && 'pending' != $post_status )
$post_states['pending'] = _x('Pending', 'post status');
if ( is_sticky($post->ID) )

View File

@@ -97,6 +97,7 @@
request = wp.ajax.post( 'customize-nav-menus-insert-auto-draft', {
'customize-menus-nonce': api.settings.nonce['customize-menus'],
'wp_customize': 'on',
'customize_changeset_uuid': api.settings.changeset.uuid,
'params': params
} );