diff --git a/packages/sync/src/class-actions.php b/packages/sync/src/class-actions.php index 443a77feac330..6411bbe93bf54 100644 --- a/packages/sync/src/class-actions.php +++ b/packages/sync/src/class-actions.php @@ -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(); } diff --git a/packages/sync/src/class-listener.php b/packages/sync/src/class-listener.php index 9c193b8db78ea..ad217f25b1c36 100644 --- a/packages/sync/src/class-listener.php +++ b/packages/sync/src/class-listener.php @@ -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(); }