diff --git a/sync/class.jetpack-sync-actions.php b/sync/class.jetpack-sync-actions.php index 8f4cb4910f3ab..ac28c2954f4ae 100644 --- a/sync/class.jetpack-sync-actions.php +++ b/sync/class.jetpack-sync-actions.php @@ -317,9 +317,18 @@ static function initialize_sender() { } } -// Allow other plugins to add filters before we initialize the actions. -// Load the listeners if before modules get loaded so that we can capture version changes etc. -add_action( 'init', array( 'Jetpack_Sync_Actions', 'init' ), 90 ); +/** + * If the site is using alternate cron, we need to init the listener and sender before cron + * runs. So, we init at a priority of 9. + * + * If the site is using a regular cron job, we init at a priority of 90 which gives plugins a chance + * to add filters before we initialize. + */ +if ( defined( 'ALTERNATE_WP_CRON' ) && ALTERNATE_WP_CRON ) { + add_action( 'init', array( 'Jetpack_Sync_Actions', 'init' ), 9 ); +} else { + add_action( 'init', array( 'Jetpack_Sync_Actions', 'init' ), 90 ); +} // We need to define this here so that it's hooked before `updating_jetpack_version` is called add_action( 'updating_jetpack_version', array( 'Jetpack_Sync_Actions', 'schedule_initial_sync' ), 10, 2 );