Completed
Push — renovate/slack-web-api-5.x ( f1014a...4f2b74 )
by
unknown
30:35 queued 23:31
created

Main::init()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 17
rs 9.7
c 0
b 0
f 0

1 Method

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