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

Sync: do not sync comments made via Action Scheduler #13355

Merged
merged 1 commit into from
Sep 19, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions packages/sync/src/modules/WooCommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ public function __construct() {
add_filter( 'jetpack_sync_before_enqueue_woocommerce_new_order_item', array( $this, 'filter_order_item' ) );
add_filter( 'jetpack_sync_before_enqueue_woocommerce_update_order_item', array( $this, 'filter_order_item' ) );
add_filter( 'jetpack_sync_whitelisted_comment_types', array( $this, 'add_review_comment_types' ) );

// Blacklist Action Scheduler comment types.
add_filter( 'jetpack_sync_prevent_sending_comment_data', array( $this, 'filter_action_scheduler_comments' ), 10, 2 );
}

/**
Expand Down Expand Up @@ -326,6 +329,24 @@ public function add_review_comment_types( $comment_types ) {
return $comment_types;
}

/**
* Stop comments from the Action Scheduler from being synced.
* https://github.com/woocommerce/woocommerce/tree/e7762627c37ec1f7590e6cac4218ba0c6a20024d/includes/libraries/action-scheduler
*
* @since 7.7.0
*
* @param boolean $can_sync Should we prevent comment data from bing synced to WordPress.com.
* @param mixed $comment WP_COMMENT object.
*
* @return bool
*/
public function filter_action_scheduler_comments( $can_sync, $comment ) {
if ( isset( $comment->comment_agent ) && 'ActionScheduler' === $comment->comment_agent ) {
return true;
}
return $can_sync;
}

/**
* Whitelist for options we are interested to sync.
*
Expand Down