1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
<?php /** * WooCommerce Onboarding Jetpack */
namespace Automattic\WooCommerce\Internal\Admin\Onboarding;
/** * Contains logic around Jetpack setup during onboarding. */ class OnboardingJetpack { /** * Class instance. * * @var OnboardingJetpack instance */ private static $instance = null;
/** * Get class instance. */ final public static function instance() { if ( ! static::$instance ) { static::$instance = new static(); } return static::$instance; }
/** * Init. */ public function init() { add_action( 'woocommerce_admin_plugins_pre_activate', array( $this, 'activate_and_install_jetpack_ahead_of_wcpay' ) ); add_action( 'woocommerce_admin_plugins_pre_install', array( $this, 'activate_and_install_jetpack_ahead_of_wcpay' ) );
// Always hook into Jetpack connection even if outside of admin. add_action( 'jetpack_site_registered', array( $this, 'set_woocommerce_setup_jetpack_opted_in' ) ); }
/** * Sets the woocommerce_setup_jetpack_opted_in to true when Jetpack connects to WPCOM. */ public function set_woocommerce_setup_jetpack_opted_in() { update_option( 'woocommerce_setup_jetpack_opted_in', true ); }
/** * Ensure that Jetpack gets installed and activated ahead of WooCommerce Payments * if both are being installed/activated at the same time. * * See: https://github.com/Automattic/woocommerce-payments/issues/1663 * See: https://github.com/Automattic/jetpack/issues/19624 * * @param array $plugins A list of plugins to install or activate. * * @return array */ public function activate_and_install_jetpack_ahead_of_wcpay( $plugins ) { if ( in_array( 'jetpack', $plugins, true ) && in_array( 'woocommerce-payments', $plugins, true ) ) { array_unshift( $plugins, 'jetpack' ); $plugins = array_unique( $plugins ); } return $plugins; }
}
|