summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/json-endpoints/class.wpcom-json-api-update-post-endpoint.php')
-rw-r--r--plugins/jetpack/json-endpoints/class.wpcom-json-api-update-post-endpoint.php11
1 files changed, 10 insertions, 1 deletions
diff --git a/plugins/jetpack/json-endpoints/class.wpcom-json-api-update-post-endpoint.php b/plugins/jetpack/json-endpoints/class.wpcom-json-api-update-post-endpoint.php
index 43d6fe11..07adba9e 100644
--- a/plugins/jetpack/json-endpoints/class.wpcom-json-api-update-post-endpoint.php
+++ b/plugins/jetpack/json-endpoints/class.wpcom-json-api-update-post-endpoint.php
@@ -301,6 +301,16 @@ class WPCOM_JSON_API_Update_Post_Endpoint extends WPCOM_JSON_API_Post_Endpoint {
if ( 'publish' === $new_status && 'draft' === $last_status && ! isset( $input['date_gmt'] ) && $date_in_past ) {
$input['date_gmt'] = gmdate( 'Y-m-d H:i:s' );
}
+
+ // Untrash a post so that the proper hooks get called as well as the comments get untrashed.
+ if ( 'trash' === $last_status && 'trash' !== $new_status && isset( $post->ID ) ) {
+ wp_untrash_post( $post->ID );
+ $untashed_post = get_post( $post->ID );
+ // Lets make sure that we use the revert the slug.
+ if ( isset( $untashed_post->post_name ) && $untashed_post->post_name . '__trashed' === $input['slug'] ) {
+ unset( $input['slug'] );
+ }
+ }
}
if ( function_exists( 'wpcom_switch_to_locale' ) ) {
@@ -705,7 +715,6 @@ class WPCOM_JSON_API_Update_Post_Endpoint extends WPCOM_JSON_API_Post_Endpoint {
$meta = (object) $meta;
- // Custom meta description can only be set on sites that have a business subscription.
if ( Jetpack_SEO_Posts::DESCRIPTION_META_KEY == $meta->key && ! Jetpack_SEO_Utils::is_enabled_jetpack_seo() ) {
return new WP_Error( 'unauthorized', __( 'SEO tools are not enabled for this site.', 'jetpack' ), 403 );
}