summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/vendor/automattic/jetpack-sync/src/class-main.php')
-rw-r--r--plugins/jetpack/vendor/automattic/jetpack-sync/src/class-main.php51
1 files changed, 41 insertions, 10 deletions
diff --git a/plugins/jetpack/vendor/automattic/jetpack-sync/src/class-main.php b/plugins/jetpack/vendor/automattic/jetpack-sync/src/class-main.php
index 2e1c3cbd..ac552008 100644
--- a/plugins/jetpack/vendor/automattic/jetpack-sync/src/class-main.php
+++ b/plugins/jetpack/vendor/automattic/jetpack-sync/src/class-main.php
@@ -7,28 +7,59 @@
namespace Automattic\Jetpack\Sync;
+use Automattic\Jetpack\Sync\Actions as Sync_Actions;
+
/**
* Jetpack Sync main class.
*/
class Main {
+
+ /**
+ * Sets up event handlers for the Sync package. Is used from the Config package.
+ *
+ * @action plugins_loaded
+ */
+ public static function configure() {
+ if ( Actions::sync_allowed() ) {
+ add_action( 'plugins_loaded', array( __CLASS__, 'on_plugins_loaded_early' ), 5 );
+ add_action( 'plugins_loaded', array( __CLASS__, 'on_plugins_loaded_late' ), 90 );
+ }
+ // Any hooks below are special cases that need to be declared even if Sync is not allowed.
+ add_action( 'jetpack_user_authorized', array( 'Automattic\\Jetpack\\Sync\\Actions', 'do_initial_sync' ), 10, 0 );
+ }
+
/**
* Initialize the main sync actions.
+ *
+ * @action plugins_loaded
*/
- public static function init() {
- // Check for WooCommerce support.
- add_action( 'plugins_loaded', array( 'Automattic\\Jetpack\\Sync\\Actions', 'initialize_woocommerce' ), 5 );
+ public static function on_plugins_loaded_early() {
+ /**
+ * Additional Sync modules can be carried out into their own packages and they
+ * will get their own config settings.
+ *
+ * For now additional modules are enabled based on whether the third party plugin
+ * class exists or not.
+ */
+ Sync_Actions::initialize_woocommerce();
+ Sync_Actions::initialize_wp_super_cache();
- // Check for WP Super Cache.
- add_action( 'plugins_loaded', array( 'Automattic\\Jetpack\\Sync\\Actions', 'initialize_wp_super_cache' ), 5 );
+ // We need to define this here so that it's hooked before `updating_jetpack_version` is called.
+ add_action( 'updating_jetpack_version', array( 'Automattic\\Jetpack\\Sync\\Actions', 'cleanup_on_upgrade' ), 10, 2 );
+ }
+ /**
+ * Runs after most of plugins_loaded hook functions have been run.
+ *
+ * @action plugins_loaded
+ */
+ public static function on_plugins_loaded_late() {
/*
* Init after plugins loaded and before the `init` action. This helps with issues where plugins init
* with a high priority or sites that use alternate cron.
*/
- add_action( 'plugins_loaded', array( 'Automattic\\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( 'Automattic\\Jetpack\\Sync\\Actions', 'cleanup_on_upgrade' ), 10, 2 );
- add_action( 'jetpack_user_authorized', array( 'Automattic\\Jetpack\\Sync\\Actions', 'do_initial_sync' ), 10, 0 );
+ Sync_Actions::init();
}
+
+
}