Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post Status Control #152

Merged
merged 37 commits into from Jun 1, 2016

Conversation

Projects
None yet
2 participants
@valendesigns
Copy link
Member

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 );
} );

This comment has been minimized.

Copy link
@westonruter

westonruter May 31, 2016

Contributor

@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();
} );

This comment has been minimized.

Copy link
@valendesigns

valendesigns May 31, 2016

Author Member

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.

This comment has been minimized.

Copy link
@westonruter

westonruter May 31, 2016

Contributor

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

@@ -179,6 +179,9 @@
if ( postTypeObj.supports.title || postTypeObj.supports.slug ) {
section.addSlugControl();
}

section.addPostStatusControl();

This comment has been minimized.

Copy link
@westonruter

westonruter May 31, 2016

Contributor

@valendesigns since sync isn't supported yet, maybe we should just skip adding the post_status control altogether if EditPostPreviewCustomize is defined?

This comment has been minimized.

Copy link
@valendesigns

valendesigns May 31, 2016

Author Member

Sounds good. How do we access that from customize-post-section.js

This comment has been minimized.

Copy link
@westonruter

westonruter May 31, 2016

Contributor

Just check if typeof EditPostPreviewCustomize !== 'undefined'.

} );

/**
* Update the UI when a post is trasitioned from/to trash.

This comment has been minimized.

Copy link
@westonruter

westonruter May 31, 2016

Contributor

Typo s/trasitioned/transitioned/

/**
* Update the UI when a post is trasitioned from/to trash.
*
* @param {bool} trashed - Whether or not the post_status is 'trash'.

This comment has been minimized.

Copy link
@westonruter

westonruter May 31, 2016

Contributor

s/bool/boolean/ PhpStorm likes boolean over bool. It looks like bool is just for PHP. It's not mentioned in JSDoc: http://usejsdoc.org/tags-type.html

$result = is_wp_error( $r );
if ( $result && $is_trashed ) {
$result = wp_trash_post( $is_trashed );

This comment has been minimized.

Copy link
@westonruter

westonruter Jun 1, 2016

Contributor

This needs to be:

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

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
@westonruter

westonruter Jun 1, 2016

Contributor

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

3 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
coverage/coveralls Coverage decreased (-0.3%) to 95.465%
Details

@valendesigns valendesigns deleted the feature/post_status branch Jun 1, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.