|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This class hooks the main sync actions. |
|
4
|
|
|
* |
|
5
|
|
|
* @package jetpack-sync |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
use Automattic\Jetpack\Connection\Manager as Connection_Manager; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Jetpack Sync main class. |
|
12
|
|
|
*/ |
|
13
|
|
|
class Jetpack_Sync_Main { |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* The connection manager object. |
|
17
|
|
|
* |
|
18
|
|
|
* @var Connection_Manager |
|
19
|
|
|
*/ |
|
20
|
|
|
private $connection_manager; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Constructor. Initializes the main sync hooks. |
|
24
|
|
|
* |
|
25
|
|
|
* @access private |
|
26
|
|
|
*/ |
|
27
|
|
|
public function __construct( Connection_Manager $connection ) { |
|
28
|
|
|
$this->connection_manager = $connection; |
|
29
|
|
|
|
|
30
|
|
|
// Check for WooCommerce support. |
|
31
|
|
|
add_action( 'plugins_loaded', array( 'Jetpack_Sync_Actions', 'initialize_woocommerce' ), 5 ); |
|
32
|
|
|
|
|
33
|
|
|
// Check for WP Super Cache. |
|
34
|
|
|
add_action( 'plugins_loaded', array( 'Jetpack_Sync_Actions', 'initialize_wp_super_cache' ), 5 ); |
|
35
|
|
|
|
|
36
|
|
|
/* |
|
37
|
|
|
* Init after plugins loaded and before the `init` action. This helps with issues where plugins init |
|
38
|
|
|
* with a high priority or sites that use alternate cron. |
|
39
|
|
|
*/ |
|
40
|
|
|
add_action( 'plugins_loaded', array( $this, 'initialize_actions' ), 90 ); |
|
41
|
|
|
|
|
42
|
|
|
// We need to define this here so that it's hooked before `updating_jetpack_version` is called. |
|
43
|
|
|
add_action( 'updating_jetpack_version', array( 'Jetpack_Sync_Actions', 'cleanup_on_upgrade' ), 10, 2 ); |
|
44
|
|
|
add_action( 'jetpack_user_authorized', array( 'Jetpack_Sync_Actions', 'do_initial_sync' ), 10, 0 ); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
public function initialize_actions() { |
|
48
|
|
|
new Jetpack_Sync_Actions( $this->connection_manager ); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Set the connection manager object. |
|
53
|
|
|
* |
|
54
|
|
|
* @return Connection_Manager $connection_manager The connection manager object. |
|
55
|
|
|
*/ |
|
56
|
|
|
public function get_connection_manager() { |
|
57
|
|
|
return $this->connection_manager; |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|