Skip to content

Commit

Permalink
Check value to determine if we should enable sync after an action enq…
Browse files Browse the repository at this point in the history
…ueuement. (#17404)
  • Loading branch information
mdbitz authored Nov 20, 2020
1 parent 3ae959f commit 9f5dd37
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion packages/sync/src/class-actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,16 @@ public static function should_initialize_sender() {
* @access public
* @static
*
* @param bool $enable Should we initilize sender.
* @return bool
*/
public static function should_initialize_sender_enqueue() {
public static function should_initialize_sender_enqueue( $enable ) {

// If $enabled is false don't modify it, only check cron if enabled.
if ( false === $enable ) {
return $enable;
}

if ( Constants::is_true( 'DOING_CRON' ) ) {
return self::sync_via_cron_allowed();
}
Expand Down
2 changes: 1 addition & 1 deletion packages/sync/src/class-listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ public function enqueue_action( $current_filter, $args, $queue ) {

// since we've added some items, let's try to load the sender so we can send them as quickly as possible.
if ( ! Actions::$sender ) {
add_filter( 'jetpack_sync_sender_should_load', __NAMESPACE__ . '\Actions::should_initialize_sender_enqueue' );
add_filter( 'jetpack_sync_sender_should_load', __NAMESPACE__ . '\Actions::should_initialize_sender_enqueue', 10, 1 );
if ( did_action( 'init' ) ) {
Actions::add_sender_shutdown();
}
Expand Down

0 comments on commit 9f5dd37

Please sign in to comment.