Skip to content

Commit

Permalink
Merge pull request #5157 from Automattic/fix/sync-alternate-cron
Browse files Browse the repository at this point in the history
Sync: Fix issue where listener/sender not loading for alternate cron
  • Loading branch information
ebinnion authored Sep 14, 2016
2 parents 098b8d6 + e74daef commit 764a699
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions sync/class.jetpack-sync-actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

0 comments on commit 764a699

Please sign in to comment.