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
|
|
|
if ( Actions::sync_allowed() ) { |
24
|
|
|
add_action( 'plugins_loaded', array( __CLASS__, 'on_plugins_loaded_early' ), 5 ); |
25
|
|
|
add_action( 'plugins_loaded', array( __CLASS__, 'on_plugins_loaded_late' ), 90 ); |
26
|
|
|
} |
27
|
|
|
// Any hooks below are special cases that need to be declared even if Sync is not allowed. |
28
|
|
|
add_action( 'jetpack_user_authorized', array( 'Automattic\\Jetpack\\Sync\\Actions', 'do_initial_sync' ), 10, 0 ); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Initialize the main sync actions. |
33
|
|
|
* |
34
|
|
|
* @action plugins_loaded |
35
|
|
|
*/ |
36
|
|
|
public static function on_plugins_loaded_early() { |
37
|
|
|
/** |
38
|
|
|
* Additional Sync modules can be carried out into their own packages and they |
39
|
|
|
* will get their own config settings. |
40
|
|
|
* |
41
|
|
|
* For now additional modules are enabled based on whether the third party plugin |
42
|
|
|
* class exists or not. |
43
|
|
|
*/ |
44
|
|
|
Sync_Actions::initialize_woocommerce(); |
45
|
|
|
Sync_Actions::initialize_wp_super_cache(); |
46
|
|
|
|
47
|
|
|
// We need to define this here so that it's hooked before `updating_jetpack_version` is called. |
48
|
|
|
add_action( 'updating_jetpack_version', array( 'Automattic\\Jetpack\\Sync\\Actions', 'cleanup_on_upgrade' ), 10, 2 ); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Runs after most of plugins_loaded hook functions have been run. |
53
|
|
|
* |
54
|
|
|
* @action plugins_loaded |
55
|
|
|
*/ |
56
|
|
|
public static function on_plugins_loaded_late() { |
57
|
|
|
/* |
58
|
|
|
* Init after plugins loaded and before the `init` action. This helps with issues where plugins init |
59
|
|
|
* with a high priority or sites that use alternate cron. |
60
|
|
|
*/ |
61
|
|
|
Sync_Actions::init(); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
|
65
|
|
|
} |
66
|
|
|
|