From e74daefebd7be988746a1b81e1ec0e51d1eb7caf Mon Sep 17 00:00:00 2001 From: Eric Binnion Date: Fri, 9 Sep 2016 12:09:59 -0500 Subject: [PATCH] Sync: Fix issue where listener/sender not loading for alternate cron --- sync/class.jetpack-sync-actions.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/sync/class.jetpack-sync-actions.php b/sync/class.jetpack-sync-actions.php index 62a1b9a18c48d..7e06933e2119e 100644 --- a/sync/class.jetpack-sync-actions.php +++ b/sync/class.jetpack-sync-actions.php @@ -283,9 +283,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 );