summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/sync/class.jetpack-sync-module-posts.php')
-rw-r--r--plugins/jetpack/sync/class.jetpack-sync-module-posts.php25
1 files changed, 22 insertions, 3 deletions
diff --git a/plugins/jetpack/sync/class.jetpack-sync-module-posts.php b/plugins/jetpack/sync/class.jetpack-sync-module-posts.php
index 8c68b167..13210ac6 100644
--- a/plugins/jetpack/sync/class.jetpack-sync-module-posts.php
+++ b/plugins/jetpack/sync/class.jetpack-sync-module-posts.php
@@ -59,8 +59,8 @@ class Jetpack_Sync_Module_Posts extends Jetpack_Sync_Module {
*
* @module sync
*
- * $param array $feedback_ids feedback post IDs
- * $param string $meta_key to be deleted
+ * @param array $feedback_ids feedback post IDs
+ * @param string $meta_key to be deleted
*/
do_action( 'jetpack_post_meta_batch_delete', $feedback_ids, '_feedback_akismet_values');
}
@@ -280,6 +280,24 @@ class Jetpack_Sync_Module_Posts extends Jetpack_Sync_Module {
$this->previous_status[ $post->ID ] = $old_status;
}
+ /*
+ * When publishing or updating a post, the Gutenberg editor sends two requests:
+ * 1. sent to WP REST API endpoint `wp-json/wp/v2/posts/$id`
+ * 2. sent to wp-admin/post.php `?post=$id&action=edit&classic-editor=1&meta_box=1`
+ *
+ * The 2nd request is to update post meta, which is not supported on WP REST API.
+ * When syncing post data, we will include if this was a meta box update.
+ */
+ public function is_gutenberg_meta_box_update() {
+ return (
+ isset( $_POST['action'], $_GET['classic-editor'], $_GET['meta_box'] ) &&
+ 'editpost' === $_POST['action'] &&
+ '1' === $_GET['classic-editor'] &&
+ '1' === $_GET['meta_box'] &&
+ Jetpack_Gutenberg::is_gutenberg_available()
+ );
+ }
+
public function wp_insert_post( $post_ID, $post = null, $update = null ) {
if ( ! is_numeric( $post_ID ) || is_null( $post ) ) {
return;
@@ -301,7 +319,8 @@ class Jetpack_Sync_Module_Posts extends Jetpack_Sync_Module {
$state = array(
'is_auto_save' => (bool) Jetpack_Constants::get_constant( 'DOING_AUTOSAVE' ),
'previous_status' => $previous_status,
- 'just_published' => $just_published
+ 'just_published' => $just_published,
+ 'is_gutenberg_meta_box_update' => $this->is_gutenberg_meta_box_update(),
);
/**
* Filter that is used to add to the post flags ( meta data ) when a post gets published