|
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
|
|
|
* Holds the singleton instance of this class. |
|
16
|
|
|
* |
|
17
|
|
|
* @var Jetpack_Sync_Main |
|
18
|
|
|
*/ |
|
19
|
|
|
private static $instance; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* The connection manager object. |
|
23
|
|
|
* |
|
24
|
|
|
* @var Connection_Manager |
|
25
|
|
|
*/ |
|
26
|
|
|
private $connection_manager; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Singleton initializator. |
|
30
|
|
|
* |
|
31
|
|
|
* @static |
|
32
|
|
|
* @access public |
|
33
|
|
|
* |
|
34
|
|
|
* @return Jetpack_Sync_Main The singleton instance of this class. |
|
35
|
|
|
*/ |
|
36
|
|
|
public static function init() { |
|
37
|
|
|
if ( ! self::$instance ) { |
|
38
|
|
|
self::$instance = new self(); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
return self::$instance; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Constructor. Initializes the main sync hooks. |
|
46
|
|
|
* |
|
47
|
|
|
* @access private |
|
48
|
|
|
*/ |
|
49
|
|
|
private function __construct() { |
|
50
|
|
|
// Check for WooCommerce support. |
|
51
|
|
|
add_action( 'plugins_loaded', array( 'Jetpack_Sync_Actions', 'initialize_woocommerce' ), 5 ); |
|
52
|
|
|
|
|
53
|
|
|
// Check for WP Super Cache. |
|
54
|
|
|
add_action( 'plugins_loaded', array( 'Jetpack_Sync_Actions', 'initialize_wp_super_cache' ), 5 ); |
|
55
|
|
|
|
|
56
|
|
|
/* |
|
57
|
|
|
* Init after plugins loaded and before the `init` action. This helps with issues where plugins init |
|
58
|
|
|
* with a high priority or sites that use alternate cron. |
|
59
|
|
|
*/ |
|
60
|
|
|
add_action( 'plugins_loaded', array( 'Jetpack_Sync_Actions', 'init' ), 90 ); |
|
61
|
|
|
|
|
62
|
|
|
// We need to define this here so that it's hooked before `updating_jetpack_version` is called. |
|
63
|
|
|
add_action( 'updating_jetpack_version', array( 'Jetpack_Sync_Actions', 'cleanup_on_upgrade' ), 10, 2 ); |
|
64
|
|
|
add_action( 'jetpack_user_authorized', array( 'Jetpack_Sync_Actions', 'do_initial_sync' ), 10, 0 ); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Set the connection manager object. |
|
69
|
|
|
* |
|
70
|
|
|
* @param Connection_Manager $connection_manager The connection manager object. |
|
71
|
|
|
*/ |
|
72
|
|
|
public function set_connection_manager( Connection_Manager $connection_manager ) { |
|
73
|
|
|
$this->connection_manager = $connection_manager; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* Set the connection manager object. |
|
78
|
|
|
* |
|
79
|
|
|
* @return Connection_Manager $connection_manager The connection manager object. |
|
80
|
|
|
*/ |
|
81
|
|
|
public function get_connection_manager() { |
|
82
|
|
|
return $this->connection_manager; |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
|