Completed
Push — update/change_endpoint_load_or... ( 37d16d...ab8b71 )
by
unknown
06:41
created

Main::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * This class hooks the main sync actions.
4
 *
5
 * @package automattic/jetpack-sync
6
 */
7
8
namespace Automattic\Jetpack\Sync;
9
10
use Automattic\Jetpack\Sync\Actions as Sync_Actions;
11
12
/**
13
 * Jetpack Sync main class.
14
 */
15
class Main {
16
17
	/**
18
	 * Sets up event handlers for the Sync package. Is used from the Config package.
19
	 *
20
	 * @action plugins_loaded
21
	 */
22
	public static function configure() {
23
		add_action( 'plugins_loaded', array( __CLASS__, 'on_plugins_loaded_early' ), 5 );
24
		add_action( 'plugins_loaded', array( __CLASS__, 'on_plugins_loaded_late' ), 90 );
25
	}
26
27
	/**
28
	 * Initialize the main sync actions.
29
	 *
30
	 * @action plugins_loaded
31
	 */
32
	public static function on_plugins_loaded_early() {
33
		/**
34
		 * Additional Sync modules can be carried out into their own packages and they
35
		 * will get their own config settings.
36
		 *
37
		 * For now additional modules are enabled based on whether the third party plugin
38
		 * class exists or not.
39
		 */
40
		Sync_Actions::initialize_woocommerce();
41
		Sync_Actions::initialize_wp_super_cache();
42
43
		// We need to define this here so that it's hooked before `updating_jetpack_version` is called.
44
		add_action( 'updating_jetpack_version', array( 'Automattic\\Jetpack\\Sync\\Actions', 'cleanup_on_upgrade' ), 10, 2 );
45
		add_action( 'jetpack_user_authorized', array( 'Automattic\\Jetpack\\Sync\\Actions', 'do_initial_sync' ), 10, 0 );
46
	}
47
48
	/**
49
	 * Runs after most of plugins_loaded hook functions have been run.
50
	 *
51
	 * @action plugins_loaded
52
	 */
53
	public static function on_plugins_loaded_late() {
54
		/*
55
		 * Init after plugins loaded and before the `init` action. This helps with issues where plugins init
56
		 * with a high priority or sites that use alternate cron.
57
		 */
58
		Sync_Actions::init();
59
	}
60
61
62
}
63