Skip to content
This repository was archived by the owner on Dec 16, 2022. It is now read-only.

Post Status Control #152

Merged
merged 37 commits into from
Jun 1, 2016
Merged

Post Status Control #152

merged 37 commits into from
Jun 1, 2016

Conversation

valendesigns
Copy link
Contributor

@valendesigns valendesigns commented May 28, 2016

Fixes #40, fixes #137

@@ -150,6 +150,10 @@
};

api.bind( 'preview-ready', function() {
api.bind( 'saved', function() {
api.preview.send( 'customized-posts-purge-trash', api.previewPosts.data.isSingular );
} );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@valendesigns I think this isn't right. The saved event is triggered on the api inside the controls itself. Why send this customized-posts-purge-trash message from the preview?

Why not just do in customize-posts.js:

api.bind( 'saved', function() {
    component.purgeTrash();
} );

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_singular() always returned false when called from the pane. So I needed access to that value to force the preview to reload the archive.

Copy link
Contributor

@westonruter westonruter May 31, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to keep track of whatever the last data sent from customized-posts was instead.

component.previewedQuery = new api.Value( {} );
api.previewer.bind( 'customized-posts', function ( data ) {
    var query = {};
    _.each( [ 'isSingular', 'isPostPreview', 'queriedPostId' ] ).each( function( key ) {
        query[ key ] = data[ key ];
    } );
    component.previewedQuery.set( query );
} );

Then at any time you can access whether the preview isSingular via query.previewedQuery.get().isSingular.

This would be a basic implementation of https://core.trac.wordpress.org/ticket/36582

$result = is_wp_error( $r );

if ( $result && $is_trashed ) {
$result = wp_trash_post( $is_trashed );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be:

$result = wp_trash_post( $this->post_id );

@westonruter
Copy link
Contributor

westonruter commented Jun 1, 2016

  • Add test to ensure a post with an empty title, content, and excerpt can be trashed.
  • Add test to ensure inserted auto-draft post has the expected guid.
  • Add test for filter_customize_save_response_to_export_saved_values.

@@ -307,15 +306,15 @@ public function sanitize( $post_data, $strict = false ) {
$post_data = sanitize_post( $post_data, 'db' );
$initial_sanitized_post_data = $post_data;

$maybe_empty = 'attachment' !== $this->post_type
$maybe_empty = 'trash' !== $post_data['post_status'] && 'attachment' !== $this->post_type
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is wrong. We should instead be doing this change below:

if ( 'trash' !== $post_data['post_status'] && apply_filters( 'wp_insert_post_empty_content', $maybe_empty, $post_data ) ) {

@valendesigns valendesigns merged commit d75de18 into develop Jun 1, 2016
@valendesigns valendesigns deleted the feature/post_status branch June 1, 2016 06:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Delete a post whilst in the Customizer Add post status dropdown selection control and preview
2 participants