-
Notifications
You must be signed in to change notification settings - Fork 38
Conversation
…nto feature/trac-34893-validation
… posted value is invalid
…nto feature/trac-34893-validation
@@ -150,6 +150,10 @@ | |||
}; | |||
|
|||
api.bind( 'preview-ready', function() { | |||
api.bind( 'saved', function() { | |||
api.preview.send( 'customized-posts-purge-trash', api.previewPosts.data.isSingular ); | |||
} ); |
There was a problem hiding this comment.
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();
} );
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ); |
There was a problem hiding this comment.
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 );
|
@@ -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 |
There was a problem hiding this comment.
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 ) ) {
Fixes #40, fixes #137