Passed
Push — main ( aaef5c...e4c121 )
by TARIQ
71:39
created
plugins/woocommerce/packages/woocommerce-blocks/src/Domain/Package.php 2 patches
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -13,109 +13,109 @@
 block discarded – undo
13 13
  */
14 14
 class Package {
15 15
 
16
-	/**
17
-	 * Holds the current version of the blocks plugin.
18
-	 *
19
-	 * @var string
20
-	 */
21
-	private $version;
16
+    /**
17
+     * Holds the current version of the blocks plugin.
18
+     *
19
+     * @var string
20
+     */
21
+    private $version;
22 22
 
23
-	/**
24
-	 * Holds the main path to the blocks plugin directory.
25
-	 *
26
-	 * @var string
27
-	 */
28
-	private $path;
23
+    /**
24
+     * Holds the main path to the blocks plugin directory.
25
+     *
26
+     * @var string
27
+     */
28
+    private $path;
29 29
 
30
-	/**
31
-	 * Holds locally the plugin_dir_url to avoid recomputing it.
32
-	 *
33
-	 * @var string
34
-	 */
35
-	private $plugin_dir_url;
30
+    /**
31
+     * Holds locally the plugin_dir_url to avoid recomputing it.
32
+     *
33
+     * @var string
34
+     */
35
+    private $plugin_dir_url;
36 36
 
37
-	/**
38
-	 * Holds the feature gating class instance.
39
-	 *
40
-	 * @var FeatureGating
41
-	 */
42
-	private $feature_gating;
37
+    /**
38
+     * Holds the feature gating class instance.
39
+     *
40
+     * @var FeatureGating
41
+     */
42
+    private $feature_gating;
43 43
 
44
-	/**
45
-	 * Constructor
46
-	 *
47
-	 * @param string        $version        Version of the plugin.
48
-	 * @param string        $plugin_path    Path to the main plugin file.
49
-	 * @param FeatureGating $feature_gating Feature gating class instance.
50
-	 */
51
-	public function __construct( $version, $plugin_path, FeatureGating $feature_gating ) {
52
-		$this->version        = $version;
53
-		$this->path           = $plugin_path;
54
-		$this->feature_gating = $feature_gating;
55
-	}
44
+    /**
45
+     * Constructor
46
+     *
47
+     * @param string        $version        Version of the plugin.
48
+     * @param string        $plugin_path    Path to the main plugin file.
49
+     * @param FeatureGating $feature_gating Feature gating class instance.
50
+     */
51
+    public function __construct( $version, $plugin_path, FeatureGating $feature_gating ) {
52
+        $this->version        = $version;
53
+        $this->path           = $plugin_path;
54
+        $this->feature_gating = $feature_gating;
55
+    }
56 56
 
57
-	/**
58
-	 * Returns the version of the plugin.
59
-	 *
60
-	 * @return string
61
-	 */
62
-	public function get_version() {
63
-		return $this->version;
64
-	}
57
+    /**
58
+     * Returns the version of the plugin.
59
+     *
60
+     * @return string
61
+     */
62
+    public function get_version() {
63
+        return $this->version;
64
+    }
65 65
 
66
-	/**
67
-	 * Returns the path to the plugin directory.
68
-	 *
69
-	 * @param string $relative_path  If provided, the relative path will be
70
-	 *                               appended to the plugin path.
71
-	 *
72
-	 * @return string
73
-	 */
74
-	public function get_path( $relative_path = '' ) {
75
-		return trailingslashit( $this->path ) . $relative_path;
76
-	}
66
+    /**
67
+     * Returns the path to the plugin directory.
68
+     *
69
+     * @param string $relative_path  If provided, the relative path will be
70
+     *                               appended to the plugin path.
71
+     *
72
+     * @return string
73
+     */
74
+    public function get_path( $relative_path = '' ) {
75
+        return trailingslashit( $this->path ) . $relative_path;
76
+    }
77 77
 
78
-	/**
79
-	 * Returns the url to the blocks plugin directory.
80
-	 *
81
-	 * @param string $relative_url If provided, the relative url will be
82
-	 *                             appended to the plugin url.
83
-	 *
84
-	 * @return string
85
-	 */
86
-	public function get_url( $relative_url = '' ) {
87
-		if ( ! $this->plugin_dir_url ) {
88
-			// Append index.php so WP does not return the parent directory.
89
-			$this->plugin_dir_url = plugin_dir_url( $this->path . '/index.php' );
90
-		}
78
+    /**
79
+     * Returns the url to the blocks plugin directory.
80
+     *
81
+     * @param string $relative_url If provided, the relative url will be
82
+     *                             appended to the plugin url.
83
+     *
84
+     * @return string
85
+     */
86
+    public function get_url( $relative_url = '' ) {
87
+        if ( ! $this->plugin_dir_url ) {
88
+            // Append index.php so WP does not return the parent directory.
89
+            $this->plugin_dir_url = plugin_dir_url( $this->path . '/index.php' );
90
+        }
91 91
 
92
-		return $this->plugin_dir_url . $relative_url;
93
-	}
92
+        return $this->plugin_dir_url . $relative_url;
93
+    }
94 94
 
95
-	/**
96
-	 * Returns an instance of the the FeatureGating class.
97
-	 *
98
-	 * @return FeatureGating
99
-	 */
100
-	public function feature() {
101
-		return $this->feature_gating;
102
-	}
95
+    /**
96
+     * Returns an instance of the the FeatureGating class.
97
+     *
98
+     * @return FeatureGating
99
+     */
100
+    public function feature() {
101
+        return $this->feature_gating;
102
+    }
103 103
 
104
-	/**
105
-	 * Checks if we're executing the code in an experimental build mode.
106
-	 *
107
-	 * @return boolean
108
-	 */
109
-	public function is_experimental_build() {
110
-		return $this->feature()->is_experimental_build();
111
-	}
104
+    /**
105
+     * Checks if we're executing the code in an experimental build mode.
106
+     *
107
+     * @return boolean
108
+     */
109
+    public function is_experimental_build() {
110
+        return $this->feature()->is_experimental_build();
111
+    }
112 112
 
113
-	/**
114
-	 * Checks if we're executing the code in an feature plugin or experimental build mode.
115
-	 *
116
-	 * @return boolean
117
-	 */
118
-	public function is_feature_plugin_build() {
119
-		return $this->feature()->is_feature_plugin_build();
120
-	}
113
+    /**
114
+     * Checks if we're executing the code in an feature plugin or experimental build mode.
115
+     *
116
+     * @return boolean
117
+     */
118
+    public function is_feature_plugin_build() {
119
+        return $this->feature()->is_feature_plugin_build();
120
+    }
121 121
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 * @param string        $plugin_path    Path to the main plugin file.
49 49
 	 * @param FeatureGating $feature_gating Feature gating class instance.
50 50
 	 */
51
-	public function __construct( $version, $plugin_path, FeatureGating $feature_gating ) {
51
+	public function __construct($version, $plugin_path, FeatureGating $feature_gating) {
52 52
 		$this->version        = $version;
53 53
 		$this->path           = $plugin_path;
54 54
 		$this->feature_gating = $feature_gating;
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
 	 *
72 72
 	 * @return string
73 73
 	 */
74
-	public function get_path( $relative_path = '' ) {
75
-		return trailingslashit( $this->path ) . $relative_path;
74
+	public function get_path($relative_path = '') {
75
+		return trailingslashit($this->path) . $relative_path;
76 76
 	}
77 77
 
78 78
 	/**
@@ -83,10 +83,10 @@  discard block
 block discarded – undo
83 83
 	 *
84 84
 	 * @return string
85 85
 	 */
86
-	public function get_url( $relative_url = '' ) {
87
-		if ( ! $this->plugin_dir_url ) {
86
+	public function get_url($relative_url = '') {
87
+		if (!$this->plugin_dir_url) {
88 88
 			// Append index.php so WP does not return the parent directory.
89
-			$this->plugin_dir_url = plugin_dir_url( $this->path . '/index.php' );
89
+			$this->plugin_dir_url = plugin_dir_url($this->path . '/index.php');
90 90
 		}
91 91
 
92 92
 		return $this->plugin_dir_url . $relative_url;
Please login to merge, or discard this patch.
packages/woocommerce-blocks/src/Domain/Services/CreateAccount.php 2 patches
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -8,80 +8,80 @@
 block discarded – undo
8 8
  * Service class implementing new create account emails used for order processing via the Block Based Checkout.
9 9
  */
10 10
 class CreateAccount {
11
-	/**
12
-	 * Reference to the Package instance
13
-	 *
14
-	 * @var Package
15
-	 */
16
-	private $package;
11
+    /**
12
+     * Reference to the Package instance
13
+     *
14
+     * @var Package
15
+     */
16
+    private $package;
17 17
 
18
-	/**
19
-	 * Constructor.
20
-	 *
21
-	 * @param Package $package An instance of (Woo Blocks) Package.
22
-	 */
23
-	public function __construct( Package $package ) {
24
-		$this->package = $package;
25
-	}
18
+    /**
19
+     * Constructor.
20
+     *
21
+     * @param Package $package An instance of (Woo Blocks) Package.
22
+     */
23
+    public function __construct( Package $package ) {
24
+        $this->package = $package;
25
+    }
26 26
 
27
-	/**
28
-	 * Feature gating. This feature is only enabled when using the feature plugin/checkout block.
29
-	 *
30
-	 * @return boolean
31
-	 */
32
-	private function is_feature_enabled() {
33
-		return $this->package->feature()->is_feature_plugin_build();
34
-	}
27
+    /**
28
+     * Feature gating. This feature is only enabled when using the feature plugin/checkout block.
29
+     *
30
+     * @return boolean
31
+     */
32
+    private function is_feature_enabled() {
33
+        return $this->package->feature()->is_feature_plugin_build();
34
+    }
35 35
 
36
-	/**
37
-	 * Init - register handlers for WooCommerce core email hooks.
38
-	 */
39
-	public function init() {
40
-		if ( ! self::is_feature_enabled() ) {
41
-			return;
42
-		}
36
+    /**
37
+     * Init - register handlers for WooCommerce core email hooks.
38
+     */
39
+    public function init() {
40
+        if ( ! self::is_feature_enabled() ) {
41
+            return;
42
+        }
43 43
 
44
-		// Override core email handlers to add our new improved "new account" email.
45
-		add_action(
46
-			'woocommerce_email',
47
-			function ( $wc_emails_instance ) {
48
-				// Remove core "new account" handler; we are going to replace it.
49
-				remove_action( 'woocommerce_created_customer_notification', array( $wc_emails_instance, 'customer_new_account' ), 10, 3 );
44
+        // Override core email handlers to add our new improved "new account" email.
45
+        add_action(
46
+            'woocommerce_email',
47
+            function ( $wc_emails_instance ) {
48
+                // Remove core "new account" handler; we are going to replace it.
49
+                remove_action( 'woocommerce_created_customer_notification', array( $wc_emails_instance, 'customer_new_account' ), 10, 3 );
50 50
 
51
-				// Add custom "new account" handler.
52
-				add_action(
53
-					'woocommerce_created_customer_notification',
54
-					function( $customer_id, $new_customer_data = array(), $password_generated = false ) use ( $wc_emails_instance ) {
55
-						// If this is a block-based signup, send a new email with password reset link (no password in email).
56
-						if ( isset( $new_customer_data['source'] ) && 'store-api' === $new_customer_data['source'] ) {
57
-							$this->customer_new_account( $customer_id, $new_customer_data );
58
-							return;
59
-						}
51
+                // Add custom "new account" handler.
52
+                add_action(
53
+                    'woocommerce_created_customer_notification',
54
+                    function( $customer_id, $new_customer_data = array(), $password_generated = false ) use ( $wc_emails_instance ) {
55
+                        // If this is a block-based signup, send a new email with password reset link (no password in email).
56
+                        if ( isset( $new_customer_data['source'] ) && 'store-api' === $new_customer_data['source'] ) {
57
+                            $this->customer_new_account( $customer_id, $new_customer_data );
58
+                            return;
59
+                        }
60 60
 
61
-						// Otherwise, trigger the existing legacy email (with new password inline).
62
-						$wc_emails_instance->customer_new_account( $customer_id, $new_customer_data, $password_generated );
63
-					},
64
-					10,
65
-					3
66
-				);
67
-			}
68
-		);
69
-	}
61
+                        // Otherwise, trigger the existing legacy email (with new password inline).
62
+                        $wc_emails_instance->customer_new_account( $customer_id, $new_customer_data, $password_generated );
63
+                    },
64
+                    10,
65
+                    3
66
+                );
67
+            }
68
+        );
69
+    }
70 70
 
71
-	/**
72
-	 * Trigger new account email.
73
-	 * This is intended as a replacement to WC_Emails::customer_new_account(),
74
-	 * with a set password link instead of emailing the new password in email
75
-	 * content.
76
-	 *
77
-	 * @param int   $customer_id       The ID of the new customer account.
78
-	 * @param array $new_customer_data Assoc array of data for the new account.
79
-	 */
80
-	public function customer_new_account( $customer_id = 0, array $new_customer_data = array() ) {
81
-		if ( ! self::is_feature_enabled() || ! $customer_id ) {
82
-			return;
83
-		}
84
-		$new_account_email = new CustomerNewAccount( $this->package );
85
-		$new_account_email->trigger( $customer_id, $new_customer_data );
86
-	}
71
+    /**
72
+     * Trigger new account email.
73
+     * This is intended as a replacement to WC_Emails::customer_new_account(),
74
+     * with a set password link instead of emailing the new password in email
75
+     * content.
76
+     *
77
+     * @param int   $customer_id       The ID of the new customer account.
78
+     * @param array $new_customer_data Assoc array of data for the new account.
79
+     */
80
+    public function customer_new_account( $customer_id = 0, array $new_customer_data = array() ) {
81
+        if ( ! self::is_feature_enabled() || ! $customer_id ) {
82
+            return;
83
+        }
84
+        $new_account_email = new CustomerNewAccount( $this->package );
85
+        $new_account_email->trigger( $customer_id, $new_customer_data );
86
+    }
87 87
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	 *
21 21
 	 * @param Package $package An instance of (Woo Blocks) Package.
22 22
 	 */
23
-	public function __construct( Package $package ) {
23
+	public function __construct(Package $package) {
24 24
 		$this->package = $package;
25 25
 	}
26 26
 
@@ -37,29 +37,29 @@  discard block
 block discarded – undo
37 37
 	 * Init - register handlers for WooCommerce core email hooks.
38 38
 	 */
39 39
 	public function init() {
40
-		if ( ! self::is_feature_enabled() ) {
40
+		if (!self::is_feature_enabled()) {
41 41
 			return;
42 42
 		}
43 43
 
44 44
 		// Override core email handlers to add our new improved "new account" email.
45 45
 		add_action(
46 46
 			'woocommerce_email',
47
-			function ( $wc_emails_instance ) {
47
+			function($wc_emails_instance) {
48 48
 				// Remove core "new account" handler; we are going to replace it.
49
-				remove_action( 'woocommerce_created_customer_notification', array( $wc_emails_instance, 'customer_new_account' ), 10, 3 );
49
+				remove_action('woocommerce_created_customer_notification', array($wc_emails_instance, 'customer_new_account'), 10, 3);
50 50
 
51 51
 				// Add custom "new account" handler.
52 52
 				add_action(
53 53
 					'woocommerce_created_customer_notification',
54
-					function( $customer_id, $new_customer_data = array(), $password_generated = false ) use ( $wc_emails_instance ) {
54
+					function($customer_id, $new_customer_data = array(), $password_generated = false) use ($wc_emails_instance) {
55 55
 						// If this is a block-based signup, send a new email with password reset link (no password in email).
56
-						if ( isset( $new_customer_data['source'] ) && 'store-api' === $new_customer_data['source'] ) {
57
-							$this->customer_new_account( $customer_id, $new_customer_data );
56
+						if (isset($new_customer_data['source']) && 'store-api' === $new_customer_data['source']) {
57
+							$this->customer_new_account($customer_id, $new_customer_data);
58 58
 							return;
59 59
 						}
60 60
 
61 61
 						// Otherwise, trigger the existing legacy email (with new password inline).
62
-						$wc_emails_instance->customer_new_account( $customer_id, $new_customer_data, $password_generated );
62
+						$wc_emails_instance->customer_new_account($customer_id, $new_customer_data, $password_generated);
63 63
 					},
64 64
 					10,
65 65
 					3
@@ -77,11 +77,11 @@  discard block
 block discarded – undo
77 77
 	 * @param int   $customer_id       The ID of the new customer account.
78 78
 	 * @param array $new_customer_data Assoc array of data for the new account.
79 79
 	 */
80
-	public function customer_new_account( $customer_id = 0, array $new_customer_data = array() ) {
81
-		if ( ! self::is_feature_enabled() || ! $customer_id ) {
80
+	public function customer_new_account($customer_id = 0, array $new_customer_data = array()) {
81
+		if (!self::is_feature_enabled() || !$customer_id) {
82 82
 			return;
83 83
 		}
84
-		$new_account_email = new CustomerNewAccount( $this->package );
85
-		$new_account_email->trigger( $customer_id, $new_customer_data );
84
+		$new_account_email = new CustomerNewAccount($this->package);
85
+		$new_account_email->trigger($customer_id, $new_customer_data);
86 86
 	}
87 87
 }
Please login to merge, or discard this patch.
packages/woocommerce-blocks/src/Domain/Services/GoogleAnalytics.php 2 patches
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -8,107 +8,107 @@
 block discarded – undo
8 8
  * Service class to integrate Blocks with the Google Analytics extension,
9 9
  */
10 10
 class GoogleAnalytics {
11
-	/**
12
-	 * Instance of the asset API.
13
-	 *
14
-	 * @var AssetApi
15
-	 */
16
-	protected $asset_api;
11
+    /**
12
+     * Instance of the asset API.
13
+     *
14
+     * @var AssetApi
15
+     */
16
+    protected $asset_api;
17 17
 
18
-	/**
19
-	 * Constructor.
20
-	 *
21
-	 * @param AssetApi $asset_api Instance of the asset API.
22
-	 */
23
-	public function __construct( AssetApi $asset_api ) {
24
-		$this->asset_api = $asset_api;
25
-		$this->init();
26
-	}
18
+    /**
19
+     * Constructor.
20
+     *
21
+     * @param AssetApi $asset_api Instance of the asset API.
22
+     */
23
+    public function __construct( AssetApi $asset_api ) {
24
+        $this->asset_api = $asset_api;
25
+        $this->init();
26
+    }
27 27
 
28
-	/**
29
-	 * Hook into WP.
30
-	 */
31
-	protected function init() {
32
-		add_action( 'init', array( $this, 'register_assets' ) );
33
-		add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
34
-		add_filter( 'script_loader_tag', array( $this, 'async_script_loader_tags' ), 10, 3 );
35
-	}
28
+    /**
29
+     * Hook into WP.
30
+     */
31
+    protected function init() {
32
+        add_action( 'init', array( $this, 'register_assets' ) );
33
+        add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
34
+        add_filter( 'script_loader_tag', array( $this, 'async_script_loader_tags' ), 10, 3 );
35
+    }
36 36
 
37
-	/**
38
-	 * Register scripts.
39
-	 */
40
-	public function register_assets() {
41
-		$this->asset_api->register_script( 'wc-blocks-google-analytics', 'build/wc-blocks-google-analytics.js', [ 'google-tag-manager' ] );
42
-	}
37
+    /**
38
+     * Register scripts.
39
+     */
40
+    public function register_assets() {
41
+        $this->asset_api->register_script( 'wc-blocks-google-analytics', 'build/wc-blocks-google-analytics.js', [ 'google-tag-manager' ] );
42
+    }
43 43
 
44
-	/**
45
-	 * Enqueue the Google Tag Manager script if prerequisites are met.
46
-	 */
47
-	public function enqueue_scripts() {
48
-		$settings = $this->get_google_analytics_settings();
44
+    /**
45
+     * Enqueue the Google Tag Manager script if prerequisites are met.
46
+     */
47
+    public function enqueue_scripts() {
48
+        $settings = $this->get_google_analytics_settings();
49 49
 
50
-		// Require tracking to be enabled with a valid GA ID.
51
-		if ( ! stristr( $settings['ga_id'], 'G-' ) ) {
52
-			return;
53
-		}
50
+        // Require tracking to be enabled with a valid GA ID.
51
+        if ( ! stristr( $settings['ga_id'], 'G-' ) ) {
52
+            return;
53
+        }
54 54
 
55
-		/**
56
-		 * Filter to disable Google Analytics tracking.
57
-		 *
58
-		 * @internal Matches filter name in GA extension.
59
-		 *
60
-		 * @param boolean $disable_tracking If true, tracking will be disabled.
61
-		 */
62
-		if ( ! stristr( $settings['ga_id'], 'G-' ) || apply_filters( 'woocommerce_ga_disable_tracking', ! wc_string_to_bool( $settings['ga_event_tracking_enabled'] ) ) ) {
63
-			return;
64
-		}
55
+        /**
56
+         * Filter to disable Google Analytics tracking.
57
+         *
58
+         * @internal Matches filter name in GA extension.
59
+         *
60
+         * @param boolean $disable_tracking If true, tracking will be disabled.
61
+         */
62
+        if ( ! stristr( $settings['ga_id'], 'G-' ) || apply_filters( 'woocommerce_ga_disable_tracking', ! wc_string_to_bool( $settings['ga_event_tracking_enabled'] ) ) ) {
63
+            return;
64
+        }
65 65
 
66
-		if ( ! wp_script_is( 'google-tag-manager', 'registered' ) ) {
67
-			// phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
68
-			wp_register_script( 'google-tag-manager', 'https://www.googletagmanager.com/gtag/js?id=' . $settings['ga_id'], [], null, false );
69
-			wp_add_inline_script(
70
-				'google-tag-manager',
71
-				"
66
+        if ( ! wp_script_is( 'google-tag-manager', 'registered' ) ) {
67
+            // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
68
+            wp_register_script( 'google-tag-manager', 'https://www.googletagmanager.com/gtag/js?id=' . $settings['ga_id'], [], null, false );
69
+            wp_add_inline_script(
70
+                'google-tag-manager',
71
+                "
72 72
 	window.dataLayer = window.dataLayer || [];
73 73
 	function gtag(){dataLayer.push(arguments);}
74 74
 	gtag('js', new Date());
75 75
 	gtag('config', '" . esc_js( $settings['ga_id'] ) . "', { 'send_page_view': false });"
76
-			);
77
-		}
78
-		wp_enqueue_script( 'wc-blocks-google-analytics' );
79
-	}
76
+            );
77
+        }
78
+        wp_enqueue_script( 'wc-blocks-google-analytics' );
79
+    }
80 80
 
81
-	/**
82
-	 * Get settings from the GA integration extension.
83
-	 *
84
-	 * @return array
85
-	 */
86
-	private function get_google_analytics_settings() {
87
-		return wp_parse_args(
88
-			get_option( 'woocommerce_google_analytics_settings' ),
89
-			[
90
-				'ga_id'                     => '',
91
-				'ga_event_tracking_enabled' => 'no',
92
-			]
93
-		);
94
-	}
81
+    /**
82
+     * Get settings from the GA integration extension.
83
+     *
84
+     * @return array
85
+     */
86
+    private function get_google_analytics_settings() {
87
+        return wp_parse_args(
88
+            get_option( 'woocommerce_google_analytics_settings' ),
89
+            [
90
+                'ga_id'                     => '',
91
+                'ga_event_tracking_enabled' => 'no',
92
+            ]
93
+        );
94
+    }
95 95
 
96
-	/**
97
-	 * Add async to script tags with defined handles.
98
-	 *
99
-	 * @param string $tag HTML for the script tag.
100
-	 * @param string $handle Handle of script.
101
-	 * @param string $src Src of script.
102
-	 * @return string
103
-	 */
104
-	public function async_script_loader_tags( $tag, $handle, $src ) {
105
-		if ( ! in_array( $handle, array( 'google-tag-manager' ), true ) ) {
106
-			return $tag;
107
-		}
108
-		// If script was output manually in wp_head, abort.
109
-		if ( did_action( 'woocommerce_gtag_snippet' ) ) {
110
-			return '';
111
-		}
112
-		return str_replace( '<script src', '<script async src', $tag );
113
-	}
96
+    /**
97
+     * Add async to script tags with defined handles.
98
+     *
99
+     * @param string $tag HTML for the script tag.
100
+     * @param string $handle Handle of script.
101
+     * @param string $src Src of script.
102
+     * @return string
103
+     */
104
+    public function async_script_loader_tags( $tag, $handle, $src ) {
105
+        if ( ! in_array( $handle, array( 'google-tag-manager' ), true ) ) {
106
+            return $tag;
107
+        }
108
+        // If script was output manually in wp_head, abort.
109
+        if ( did_action( 'woocommerce_gtag_snippet' ) ) {
110
+            return '';
111
+        }
112
+        return str_replace( '<script src', '<script async src', $tag );
113
+    }
114 114
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	 *
21 21
 	 * @param AssetApi $asset_api Instance of the asset API.
22 22
 	 */
23
-	public function __construct( AssetApi $asset_api ) {
23
+	public function __construct(AssetApi $asset_api) {
24 24
 		$this->asset_api = $asset_api;
25 25
 		$this->init();
26 26
 	}
@@ -29,16 +29,16 @@  discard block
 block discarded – undo
29 29
 	 * Hook into WP.
30 30
 	 */
31 31
 	protected function init() {
32
-		add_action( 'init', array( $this, 'register_assets' ) );
33
-		add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
34
-		add_filter( 'script_loader_tag', array( $this, 'async_script_loader_tags' ), 10, 3 );
32
+		add_action('init', array($this, 'register_assets'));
33
+		add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'));
34
+		add_filter('script_loader_tag', array($this, 'async_script_loader_tags'), 10, 3);
35 35
 	}
36 36
 
37 37
 	/**
38 38
 	 * Register scripts.
39 39
 	 */
40 40
 	public function register_assets() {
41
-		$this->asset_api->register_script( 'wc-blocks-google-analytics', 'build/wc-blocks-google-analytics.js', [ 'google-tag-manager' ] );
41
+		$this->asset_api->register_script('wc-blocks-google-analytics', 'build/wc-blocks-google-analytics.js', ['google-tag-manager']);
42 42
 	}
43 43
 
44 44
 	/**
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 		$settings = $this->get_google_analytics_settings();
49 49
 
50 50
 		// Require tracking to be enabled with a valid GA ID.
51
-		if ( ! stristr( $settings['ga_id'], 'G-' ) ) {
51
+		if (!stristr($settings['ga_id'], 'G-')) {
52 52
 			return;
53 53
 		}
54 54
 
@@ -59,23 +59,23 @@  discard block
 block discarded – undo
59 59
 		 *
60 60
 		 * @param boolean $disable_tracking If true, tracking will be disabled.
61 61
 		 */
62
-		if ( ! stristr( $settings['ga_id'], 'G-' ) || apply_filters( 'woocommerce_ga_disable_tracking', ! wc_string_to_bool( $settings['ga_event_tracking_enabled'] ) ) ) {
62
+		if (!stristr($settings['ga_id'], 'G-') || apply_filters('woocommerce_ga_disable_tracking', !wc_string_to_bool($settings['ga_event_tracking_enabled']))) {
63 63
 			return;
64 64
 		}
65 65
 
66
-		if ( ! wp_script_is( 'google-tag-manager', 'registered' ) ) {
66
+		if (!wp_script_is('google-tag-manager', 'registered')) {
67 67
 			// phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
68
-			wp_register_script( 'google-tag-manager', 'https://www.googletagmanager.com/gtag/js?id=' . $settings['ga_id'], [], null, false );
68
+			wp_register_script('google-tag-manager', 'https://www.googletagmanager.com/gtag/js?id=' . $settings['ga_id'], [], null, false);
69 69
 			wp_add_inline_script(
70 70
 				'google-tag-manager',
71 71
 				"
72 72
 	window.dataLayer = window.dataLayer || [];
73 73
 	function gtag(){dataLayer.push(arguments);}
74 74
 	gtag('js', new Date());
75
-	gtag('config', '" . esc_js( $settings['ga_id'] ) . "', { 'send_page_view': false });"
75
+	gtag('config', '" . esc_js($settings['ga_id']) . "', { 'send_page_view': false });"
76 76
 			);
77 77
 		}
78
-		wp_enqueue_script( 'wc-blocks-google-analytics' );
78
+		wp_enqueue_script('wc-blocks-google-analytics');
79 79
 	}
80 80
 
81 81
 	/**
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 */
86 86
 	private function get_google_analytics_settings() {
87 87
 		return wp_parse_args(
88
-			get_option( 'woocommerce_google_analytics_settings' ),
88
+			get_option('woocommerce_google_analytics_settings'),
89 89
 			[
90 90
 				'ga_id'                     => '',
91 91
 				'ga_event_tracking_enabled' => 'no',
@@ -101,14 +101,14 @@  discard block
 block discarded – undo
101 101
 	 * @param string $src Src of script.
102 102
 	 * @return string
103 103
 	 */
104
-	public function async_script_loader_tags( $tag, $handle, $src ) {
105
-		if ( ! in_array( $handle, array( 'google-tag-manager' ), true ) ) {
104
+	public function async_script_loader_tags($tag, $handle, $src) {
105
+		if (!in_array($handle, array('google-tag-manager'), true)) {
106 106
 			return $tag;
107 107
 		}
108 108
 		// If script was output manually in wp_head, abort.
109
-		if ( did_action( 'woocommerce_gtag_snippet' ) ) {
109
+		if (did_action('woocommerce_gtag_snippet')) {
110 110
 			return '';
111 111
 		}
112
-		return str_replace( '<script src', '<script async src', $tag );
112
+		return str_replace('<script src', '<script async src', $tag);
113 113
 	}
114 114
 }
Please login to merge, or discard this patch.
woocommerce-blocks/src/Domain/Services/Email/CustomerNewAccount.php 2 patches
Indentation   +156 added lines, -156 removed lines patch added patch discarded remove patch
@@ -15,160 +15,160 @@
 block discarded – undo
15 15
  */
16 16
 class CustomerNewAccount extends \WC_Email {
17 17
 
18
-	/**
19
-	 * User login name.
20
-	 *
21
-	 * @var string
22
-	 */
23
-	public $user_login;
24
-
25
-	/**
26
-	 * User email.
27
-	 *
28
-	 * @var string
29
-	 */
30
-	public $user_email;
31
-
32
-	/**
33
-	 * Magic link to set initial password.
34
-	 *
35
-	 * @var string
36
-	 */
37
-	public $set_password_url;
38
-
39
-	/**
40
-	 * Override (force) default template path
41
-	 *
42
-	 * @var string
43
-	 */
44
-	public $default_template_path;
45
-
46
-	/**
47
-	 * Constructor.
48
-	 *
49
-	 * @param Package $package An instance of (Woo Blocks) Package.
50
-	 */
51
-	public function __construct( Package $package ) {
52
-		// Note - we're using the same ID as the real email.
53
-		// This ensures that any merchant tweaks (Settings > Emails)
54
-		// apply to this email (consistent with the core email).
55
-		$this->id                    = 'customer_new_account';
56
-		$this->customer_email        = true;
57
-		$this->title                 = __( 'New account', 'woocommerce' );
58
-		$this->description           = __( 'Customer "new account" emails are sent to the customer when a customer signs up via checkout or account blocks.', 'woocommerce' );
59
-		$this->template_html         = 'emails/customer-new-account-blocks.php';
60
-		$this->template_plain        = 'emails/plain/customer-new-account-blocks.php';
61
-		$this->default_template_path = $package->get_path( '/templates/' );
62
-
63
-		// Call parent constructor.
64
-		parent::__construct();
65
-	}
66
-
67
-	/**
68
-	 * Get email subject.
69
-	 *
70
-	 * @since  3.1.0
71
-	 * @return string
72
-	 */
73
-	public function get_default_subject() {
74
-		return __( 'Your {site_title} account has been created!', 'woocommerce' );
75
-	}
76
-
77
-	/**
78
-	 * Get email heading.
79
-	 *
80
-	 * @since  3.1.0
81
-	 * @return string
82
-	 */
83
-	public function get_default_heading() {
84
-		return __( 'Welcome to {site_title}', 'woocommerce' );
85
-	}
86
-
87
-	/**
88
-	 * Trigger.
89
-	 *
90
-	 * @param int    $user_id User ID.
91
-	 * @param string $user_pass User password.
92
-	 * @param bool   $password_generated Whether the password was generated automatically or not.
93
-	 */
94
-	public function trigger( $user_id, $user_pass = '', $password_generated = false ) {
95
-		$this->setup_locale();
96
-
97
-		if ( $user_id ) {
98
-			$this->object = new \WP_User( $user_id );
99
-
100
-			// Generate a magic link so user can set initial password.
101
-			$key = get_password_reset_key( $this->object );
102
-			if ( ! is_wp_error( $key ) ) {
103
-				$action                 = 'newaccount';
104
-				$this->set_password_url = wc_get_account_endpoint_url( 'lost-password' ) . "?action=$action&key=$key&login=" . rawurlencode( $this->object->user_login );
105
-			}
106
-
107
-			$this->user_login = stripslashes( $this->object->user_login );
108
-			$this->user_email = stripslashes( $this->object->user_email );
109
-			$this->recipient  = $this->user_email;
110
-		}
111
-
112
-		if ( $this->is_enabled() && $this->get_recipient() ) {
113
-			$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments(), $this->set_password_url );
114
-		}
115
-
116
-		$this->restore_locale();
117
-	}
118
-
119
-	/**
120
-	 * Get content html.
121
-	 *
122
-	 * @return string
123
-	 */
124
-	public function get_content_html() {
125
-		return wc_get_template_html(
126
-			$this->template_html,
127
-			array(
128
-				'email_heading'      => $this->get_heading(),
129
-				'additional_content' => $this->get_additional_content(),
130
-				'user_login'         => $this->user_login,
131
-				'blogname'           => $this->get_blogname(),
132
-				'set_password_url'   => $this->set_password_url,
133
-				'sent_to_admin'      => false,
134
-				'plain_text'         => false,
135
-				'email'              => $this,
136
-			),
137
-			'',
138
-			$this->default_template_path
139
-		);
140
-	}
141
-
142
-	/**
143
-	 * Get content plain.
144
-	 *
145
-	 * @return string
146
-	 */
147
-	public function get_content_plain() {
148
-		return wc_get_template_html(
149
-			$this->template_plain,
150
-			array(
151
-				'email_heading'      => $this->get_heading(),
152
-				'additional_content' => $this->get_additional_content(),
153
-				'user_login'         => $this->user_login,
154
-				'blogname'           => $this->get_blogname(),
155
-				'set_password_url'   => $this->set_password_url,
156
-				'sent_to_admin'      => false,
157
-				'plain_text'         => true,
158
-				'email'              => $this,
159
-			),
160
-			'',
161
-			$this->default_template_path
162
-		);
163
-	}
164
-
165
-	/**
166
-	 * Default content to show below main email content.
167
-	 *
168
-	 * @since 3.7.0
169
-	 * @return string
170
-	 */
171
-	public function get_default_additional_content() {
172
-		return __( 'We look forward to seeing you soon.', 'woocommerce' );
173
-	}
18
+    /**
19
+     * User login name.
20
+     *
21
+     * @var string
22
+     */
23
+    public $user_login;
24
+
25
+    /**
26
+     * User email.
27
+     *
28
+     * @var string
29
+     */
30
+    public $user_email;
31
+
32
+    /**
33
+     * Magic link to set initial password.
34
+     *
35
+     * @var string
36
+     */
37
+    public $set_password_url;
38
+
39
+    /**
40
+     * Override (force) default template path
41
+     *
42
+     * @var string
43
+     */
44
+    public $default_template_path;
45
+
46
+    /**
47
+     * Constructor.
48
+     *
49
+     * @param Package $package An instance of (Woo Blocks) Package.
50
+     */
51
+    public function __construct( Package $package ) {
52
+        // Note - we're using the same ID as the real email.
53
+        // This ensures that any merchant tweaks (Settings > Emails)
54
+        // apply to this email (consistent with the core email).
55
+        $this->id                    = 'customer_new_account';
56
+        $this->customer_email        = true;
57
+        $this->title                 = __( 'New account', 'woocommerce' );
58
+        $this->description           = __( 'Customer "new account" emails are sent to the customer when a customer signs up via checkout or account blocks.', 'woocommerce' );
59
+        $this->template_html         = 'emails/customer-new-account-blocks.php';
60
+        $this->template_plain        = 'emails/plain/customer-new-account-blocks.php';
61
+        $this->default_template_path = $package->get_path( '/templates/' );
62
+
63
+        // Call parent constructor.
64
+        parent::__construct();
65
+    }
66
+
67
+    /**
68
+     * Get email subject.
69
+     *
70
+     * @since  3.1.0
71
+     * @return string
72
+     */
73
+    public function get_default_subject() {
74
+        return __( 'Your {site_title} account has been created!', 'woocommerce' );
75
+    }
76
+
77
+    /**
78
+     * Get email heading.
79
+     *
80
+     * @since  3.1.0
81
+     * @return string
82
+     */
83
+    public function get_default_heading() {
84
+        return __( 'Welcome to {site_title}', 'woocommerce' );
85
+    }
86
+
87
+    /**
88
+     * Trigger.
89
+     *
90
+     * @param int    $user_id User ID.
91
+     * @param string $user_pass User password.
92
+     * @param bool   $password_generated Whether the password was generated automatically or not.
93
+     */
94
+    public function trigger( $user_id, $user_pass = '', $password_generated = false ) {
95
+        $this->setup_locale();
96
+
97
+        if ( $user_id ) {
98
+            $this->object = new \WP_User( $user_id );
99
+
100
+            // Generate a magic link so user can set initial password.
101
+            $key = get_password_reset_key( $this->object );
102
+            if ( ! is_wp_error( $key ) ) {
103
+                $action                 = 'newaccount';
104
+                $this->set_password_url = wc_get_account_endpoint_url( 'lost-password' ) . "?action=$action&key=$key&login=" . rawurlencode( $this->object->user_login );
105
+            }
106
+
107
+            $this->user_login = stripslashes( $this->object->user_login );
108
+            $this->user_email = stripslashes( $this->object->user_email );
109
+            $this->recipient  = $this->user_email;
110
+        }
111
+
112
+        if ( $this->is_enabled() && $this->get_recipient() ) {
113
+            $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments(), $this->set_password_url );
114
+        }
115
+
116
+        $this->restore_locale();
117
+    }
118
+
119
+    /**
120
+     * Get content html.
121
+     *
122
+     * @return string
123
+     */
124
+    public function get_content_html() {
125
+        return wc_get_template_html(
126
+            $this->template_html,
127
+            array(
128
+                'email_heading'      => $this->get_heading(),
129
+                'additional_content' => $this->get_additional_content(),
130
+                'user_login'         => $this->user_login,
131
+                'blogname'           => $this->get_blogname(),
132
+                'set_password_url'   => $this->set_password_url,
133
+                'sent_to_admin'      => false,
134
+                'plain_text'         => false,
135
+                'email'              => $this,
136
+            ),
137
+            '',
138
+            $this->default_template_path
139
+        );
140
+    }
141
+
142
+    /**
143
+     * Get content plain.
144
+     *
145
+     * @return string
146
+     */
147
+    public function get_content_plain() {
148
+        return wc_get_template_html(
149
+            $this->template_plain,
150
+            array(
151
+                'email_heading'      => $this->get_heading(),
152
+                'additional_content' => $this->get_additional_content(),
153
+                'user_login'         => $this->user_login,
154
+                'blogname'           => $this->get_blogname(),
155
+                'set_password_url'   => $this->set_password_url,
156
+                'sent_to_admin'      => false,
157
+                'plain_text'         => true,
158
+                'email'              => $this,
159
+            ),
160
+            '',
161
+            $this->default_template_path
162
+        );
163
+    }
164
+
165
+    /**
166
+     * Default content to show below main email content.
167
+     *
168
+     * @since 3.7.0
169
+     * @return string
170
+     */
171
+    public function get_default_additional_content() {
172
+        return __( 'We look forward to seeing you soon.', 'woocommerce' );
173
+    }
174 174
 }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -48,17 +48,17 @@  discard block
 block discarded – undo
48 48
 	 *
49 49
 	 * @param Package $package An instance of (Woo Blocks) Package.
50 50
 	 */
51
-	public function __construct( Package $package ) {
51
+	public function __construct(Package $package) {
52 52
 		// Note - we're using the same ID as the real email.
53 53
 		// This ensures that any merchant tweaks (Settings > Emails)
54 54
 		// apply to this email (consistent with the core email).
55 55
 		$this->id                    = 'customer_new_account';
56 56
 		$this->customer_email        = true;
57
-		$this->title                 = __( 'New account', 'woocommerce' );
58
-		$this->description           = __( 'Customer "new account" emails are sent to the customer when a customer signs up via checkout or account blocks.', 'woocommerce' );
57
+		$this->title                 = __('New account', 'woocommerce');
58
+		$this->description           = __('Customer "new account" emails are sent to the customer when a customer signs up via checkout or account blocks.', 'woocommerce');
59 59
 		$this->template_html         = 'emails/customer-new-account-blocks.php';
60 60
 		$this->template_plain        = 'emails/plain/customer-new-account-blocks.php';
61
-		$this->default_template_path = $package->get_path( '/templates/' );
61
+		$this->default_template_path = $package->get_path('/templates/');
62 62
 
63 63
 		// Call parent constructor.
64 64
 		parent::__construct();
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 * @return string
72 72
 	 */
73 73
 	public function get_default_subject() {
74
-		return __( 'Your {site_title} account has been created!', 'woocommerce' );
74
+		return __('Your {site_title} account has been created!', 'woocommerce');
75 75
 	}
76 76
 
77 77
 	/**
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	 * @return string
82 82
 	 */
83 83
 	public function get_default_heading() {
84
-		return __( 'Welcome to {site_title}', 'woocommerce' );
84
+		return __('Welcome to {site_title}', 'woocommerce');
85 85
 	}
86 86
 
87 87
 	/**
@@ -91,26 +91,26 @@  discard block
 block discarded – undo
91 91
 	 * @param string $user_pass User password.
92 92
 	 * @param bool   $password_generated Whether the password was generated automatically or not.
93 93
 	 */
94
-	public function trigger( $user_id, $user_pass = '', $password_generated = false ) {
94
+	public function trigger($user_id, $user_pass = '', $password_generated = false) {
95 95
 		$this->setup_locale();
96 96
 
97
-		if ( $user_id ) {
98
-			$this->object = new \WP_User( $user_id );
97
+		if ($user_id) {
98
+			$this->object = new \WP_User($user_id);
99 99
 
100 100
 			// Generate a magic link so user can set initial password.
101
-			$key = get_password_reset_key( $this->object );
102
-			if ( ! is_wp_error( $key ) ) {
101
+			$key = get_password_reset_key($this->object);
102
+			if (!is_wp_error($key)) {
103 103
 				$action                 = 'newaccount';
104
-				$this->set_password_url = wc_get_account_endpoint_url( 'lost-password' ) . "?action=$action&key=$key&login=" . rawurlencode( $this->object->user_login );
104
+				$this->set_password_url = wc_get_account_endpoint_url('lost-password') . "?action=$action&key=$key&login=" . rawurlencode($this->object->user_login);
105 105
 			}
106 106
 
107
-			$this->user_login = stripslashes( $this->object->user_login );
108
-			$this->user_email = stripslashes( $this->object->user_email );
107
+			$this->user_login = stripslashes($this->object->user_login);
108
+			$this->user_email = stripslashes($this->object->user_email);
109 109
 			$this->recipient  = $this->user_email;
110 110
 		}
111 111
 
112
-		if ( $this->is_enabled() && $this->get_recipient() ) {
113
-			$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments(), $this->set_password_url );
112
+		if ($this->is_enabled() && $this->get_recipient()) {
113
+			$this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments(), $this->set_password_url);
114 114
 		}
115 115
 
116 116
 		$this->restore_locale();
@@ -169,6 +169,6 @@  discard block
 block discarded – undo
169 169
 	 * @return string
170 170
 	 */
171 171
 	public function get_default_additional_content() {
172
-		return __( 'We look forward to seeing you soon.', 'woocommerce' );
172
+		return __('We look forward to seeing you soon.', 'woocommerce');
173 173
 	}
174 174
 }
Please login to merge, or discard this patch.
woocommerce/packages/woocommerce-blocks/src/Domain/Services/DraftOrders.php 2 patches
Indentation   +217 added lines, -219 removed lines patch added patch discarded remove patch
@@ -14,223 +14,221 @@
 block discarded – undo
14 14
  */
15 15
 class DraftOrders {
16 16
 
17
-	const DB_STATUS = 'wc-checkout-draft';
18
-	const STATUS    = 'checkout-draft';
19
-
20
-	/**
21
-	 * Holds the Package instance
22
-	 *
23
-	 * @var Package
24
-	 */
25
-	private $package;
26
-
27
-	/**
28
-	 * Constructor
29
-	 *
30
-	 * @param Package $package An instance of the package class.
31
-	 */
32
-	public function __construct( Package $package ) {
33
-		$this->package = $package;
34
-	}
35
-
36
-	/**
37
-	 * Set all hooks related to adding Checkout Draft order functionality to Woo Core.
38
-	 */
39
-	public function init() {
40
-		add_filter( 'wc_order_statuses', [ $this, 'register_draft_order_status' ] );
41
-		add_filter( 'woocommerce_register_shop_order_post_statuses', [ $this, 'register_draft_order_post_status' ] );
42
-		add_filter( 'woocommerce_analytics_excluded_order_statuses', [ $this, 'append_draft_order_post_status' ] );
43
-		add_filter( 'woocommerce_valid_order_statuses_for_payment', [ $this, 'append_draft_order_post_status' ] );
44
-		add_filter( 'woocommerce_valid_order_statuses_for_payment_complete', [ $this, 'append_draft_order_post_status' ] );
45
-		// Hook into the query to retrieve My Account orders so draft status is excluded.
46
-		add_action( 'woocommerce_my_account_my_orders_query', [ $this, 'delete_draft_order_post_status_from_args' ] );
47
-		add_action( 'woocommerce_cleanup_draft_orders', [ $this, 'delete_expired_draft_orders' ] );
48
-		add_action( 'admin_init', [ $this, 'install' ] );
49
-	}
50
-
51
-	/**
52
-	 * Installation related logic for Draft order functionality.
53
-	 *
54
-	 * @internal
55
-	 */
56
-	public function install() {
57
-		$this->maybe_create_cronjobs();
58
-	}
59
-
60
-	/**
61
-	 * Maybe create cron events.
62
-	 */
63
-	protected function maybe_create_cronjobs() {
64
-		if ( function_exists( 'as_next_scheduled_action' ) && false === as_next_scheduled_action( 'woocommerce_cleanup_draft_orders' ) ) {
65
-			as_schedule_recurring_action( strtotime( 'midnight tonight' ), DAY_IN_SECONDS, 'woocommerce_cleanup_draft_orders' );
66
-		}
67
-	}
68
-
69
-	/**
70
-	 * Register custom order status for orders created via the API during checkout.
71
-	 *
72
-	 * Draft order status is used before payment is attempted, during checkout, when a cart is converted to an order.
73
-	 *
74
-	 * @param array $statuses Array of statuses.
75
-	 * @internal
76
-	 * @return array
77
-	 */
78
-	public function register_draft_order_status( array $statuses ) {
79
-		$statuses[ self::DB_STATUS ] = _x( 'Draft', 'Order status', 'woocommerce' );
80
-		return $statuses;
81
-	}
82
-
83
-	/**
84
-	 * Register custom order post status for orders created via the API during checkout.
85
-	 *
86
-	 * @param array $statuses Array of statuses.
87
-	 * @internal
88
-
89
-	 * @return array
90
-	 */
91
-	public function register_draft_order_post_status( array $statuses ) {
92
-		$statuses[ self::DB_STATUS ] = $this->get_post_status_properties();
93
-		return $statuses;
94
-	}
95
-
96
-	/**
97
-	 * Returns the properties of this post status for registration.
98
-	 *
99
-	 * @return array
100
-	 */
101
-	private function get_post_status_properties() {
102
-		return [
103
-			'label'                     => _x( 'Draft', 'Order status', 'woocommerce' ),
104
-			'public'                    => false,
105
-			'exclude_from_search'       => false,
106
-			'show_in_admin_all_list'    => false,
107
-			'show_in_admin_status_list' => true,
108
-			/* translators: %s: number of orders */
109
-			'label_count'               => _n_noop( 'Drafts <span class="count">(%s)</span>', 'Drafts <span class="count">(%s)</span>', 'woocommerce' ),
110
-		];
111
-	}
112
-
113
-	/**
114
-	 * Remove draft status from the 'status' argument of an $args array.
115
-	 *
116
-	 * @param array $args Array of arguments containing statuses in the status key.
117
-	 * @internal
118
-	 * @return array
119
-	 */
120
-	public function delete_draft_order_post_status_from_args( $args ) {
121
-		if ( ! array_key_exists( 'status', $args ) ) {
122
-			$statuses = [];
123
-			foreach ( wc_get_order_statuses() as $key => $label ) {
124
-				if ( self::DB_STATUS !== $key ) {
125
-					$statuses[] = str_replace( 'wc-', '', $key );
126
-				}
127
-			}
128
-			$args['status'] = $statuses;
129
-		} elseif ( self::DB_STATUS === $args['status'] ) {
130
-			$args['status'] = '';
131
-		} elseif ( is_array( $args['status'] ) ) {
132
-			$args['status'] = array_diff_key( $args['status'], array( self::STATUS => null ) );
133
-		}
134
-
135
-		return $args;
136
-	}
137
-
138
-	/**
139
-	 * Append draft status to a list of statuses.
140
-	 *
141
-	 * @param array $statuses Array of statuses.
142
-	 * @internal
143
-
144
-	 * @return array
145
-	 */
146
-	public function append_draft_order_post_status( $statuses ) {
147
-		$statuses[] = self::STATUS;
148
-		return $statuses;
149
-	}
150
-
151
-	/**
152
-	 * Delete draft orders older than a day in batches of 20.
153
-	 *
154
-	 * Ran on a daily cron schedule.
155
-	 *
156
-	 * @internal
157
-	 */
158
-	public function delete_expired_draft_orders() {
159
-		$count      = 0;
160
-		$batch_size = 20;
161
-		$this->ensure_draft_status_registered();
162
-		$orders = wc_get_orders(
163
-			[
164
-				'date_modified' => '<=' . strtotime( '-1 DAY' ),
165
-				'limit'         => $batch_size,
166
-				'status'        => self::DB_STATUS,
167
-				'type'          => 'shop_order',
168
-			]
169
-		);
170
-
171
-		// do we bail because the query results are unexpected?
172
-		try {
173
-			$this->assert_order_results( $orders, $batch_size );
174
-			if ( $orders ) {
175
-				foreach ( $orders as $order ) {
176
-					$order->delete( true );
177
-					$count ++;
178
-				}
179
-			}
180
-			if ( $batch_size === $count && function_exists( 'as_enqueue_async_action' ) ) {
181
-				as_enqueue_async_action( 'woocommerce_cleanup_draft_orders' );
182
-			}
183
-		} catch ( Exception $error ) {
184
-			wc_caught_exception( $error, __METHOD__ );
185
-		}
186
-	}
187
-
188
-	/**
189
-	 * Since it's possible for third party code to clobber the `$wp_post_statuses` global,
190
-	 * we need to do a final check here to make sure the draft post status is
191
-	 * registered with the global so that it is not removed by WP_Query status
192
-	 * validation checks.
193
-	 */
194
-	private function ensure_draft_status_registered() {
195
-		$is_registered = get_post_stati( [ 'name' => self::DB_STATUS ] );
196
-		if ( empty( $is_registered ) ) {
197
-			register_post_status(
198
-				self::DB_STATUS,
199
-				$this->get_post_status_properties()
200
-			);
201
-		}
202
-	}
203
-
204
-	/**
205
-	 * Asserts whether incoming order results are expected given the query
206
-	 * this service class executes.
207
-	 *
208
-	 * @param WC_Order[] $order_results The order results being asserted.
209
-	 * @param int        $expected_batch_size The expected batch size for the results.
210
-	 * @throws Exception If any assertions fail, an exception is thrown.
211
-	 */
212
-	private function assert_order_results( $order_results, $expected_batch_size ) {
213
-		// if not an array, then just return because it won't get handled
214
-		// anyways.
215
-		if ( ! is_array( $order_results ) ) {
216
-			return;
217
-		}
218
-
219
-		$suffix = ' This is an indicator that something is filtering WooCommerce or WordPress queries and modifying the query parameters.';
220
-
221
-		// if count is greater than our expected batch size, then that's a problem.
222
-		if ( count( $order_results ) > 20 ) {
223
-			throw new Exception( 'There are an unexpected number of results returned from the query.' . $suffix );
224
-		}
225
-
226
-		// if any of the returned orders are not draft (or not a WC_Order), then that's a problem.
227
-		foreach ( $order_results as $order ) {
228
-			if ( ! ( $order instanceof WC_Order ) ) {
229
-				throw new Exception( 'The returned results contain a value that is not a WC_Order.' . $suffix );
230
-			}
231
-			if ( ! $order->has_status( self::STATUS ) ) {
232
-				throw new Exception( 'The results contain an order that is not a `wc-checkout-draft` status in the results.' . $suffix );
233
-			}
234
-		}
235
-	}
17
+    const DB_STATUS = 'wc-checkout-draft';
18
+    const STATUS    = 'checkout-draft';
19
+
20
+    /**
21
+     * Holds the Package instance
22
+     *
23
+     * @var Package
24
+     */
25
+    private $package;
26
+
27
+    /**
28
+     * Constructor
29
+     *
30
+     * @param Package $package An instance of the package class.
31
+     */
32
+    public function __construct( Package $package ) {
33
+        $this->package = $package;
34
+    }
35
+
36
+    /**
37
+     * Set all hooks related to adding Checkout Draft order functionality to Woo Core.
38
+     */
39
+    public function init() {
40
+        add_filter( 'wc_order_statuses', [ $this, 'register_draft_order_status' ] );
41
+        add_filter( 'woocommerce_register_shop_order_post_statuses', [ $this, 'register_draft_order_post_status' ] );
42
+        add_filter( 'woocommerce_analytics_excluded_order_statuses', [ $this, 'append_draft_order_post_status' ] );
43
+        add_filter( 'woocommerce_valid_order_statuses_for_payment', [ $this, 'append_draft_order_post_status' ] );
44
+        add_filter( 'woocommerce_valid_order_statuses_for_payment_complete', [ $this, 'append_draft_order_post_status' ] );
45
+        // Hook into the query to retrieve My Account orders so draft status is excluded.
46
+        add_action( 'woocommerce_my_account_my_orders_query', [ $this, 'delete_draft_order_post_status_from_args' ] );
47
+        add_action( 'woocommerce_cleanup_draft_orders', [ $this, 'delete_expired_draft_orders' ] );
48
+        add_action( 'admin_init', [ $this, 'install' ] );
49
+    }
50
+
51
+    /**
52
+     * Installation related logic for Draft order functionality.
53
+     *
54
+     * @internal
55
+     */
56
+    public function install() {
57
+        $this->maybe_create_cronjobs();
58
+    }
59
+
60
+    /**
61
+     * Maybe create cron events.
62
+     */
63
+    protected function maybe_create_cronjobs() {
64
+        if ( function_exists( 'as_next_scheduled_action' ) && false === as_next_scheduled_action( 'woocommerce_cleanup_draft_orders' ) ) {
65
+            as_schedule_recurring_action( strtotime( 'midnight tonight' ), DAY_IN_SECONDS, 'woocommerce_cleanup_draft_orders' );
66
+        }
67
+    }
68
+
69
+    /**
70
+     * Register custom order status for orders created via the API during checkout.
71
+     *
72
+     * Draft order status is used before payment is attempted, during checkout, when a cart is converted to an order.
73
+     *
74
+     * @param array $statuses Array of statuses.
75
+     * @internal
76
+     * @return array
77
+     */
78
+    public function register_draft_order_status( array $statuses ) {
79
+        $statuses[ self::DB_STATUS ] = _x( 'Draft', 'Order status', 'woocommerce' );
80
+        return $statuses;
81
+    }
82
+
83
+    /**
84
+     * Register custom order post status for orders created via the API during checkout.
85
+     *
86
+     * @param array $statuses Array of statuses.
87
+     * @internal
88
+     * @return array
89
+     */
90
+    public function register_draft_order_post_status( array $statuses ) {
91
+        $statuses[ self::DB_STATUS ] = $this->get_post_status_properties();
92
+        return $statuses;
93
+    }
94
+
95
+    /**
96
+     * Returns the properties of this post status for registration.
97
+     *
98
+     * @return array
99
+     */
100
+    private function get_post_status_properties() {
101
+        return [
102
+            'label'                     => _x( 'Draft', 'Order status', 'woocommerce' ),
103
+            'public'                    => false,
104
+            'exclude_from_search'       => false,
105
+            'show_in_admin_all_list'    => false,
106
+            'show_in_admin_status_list' => true,
107
+            /* translators: %s: number of orders */
108
+            'label_count'               => _n_noop( 'Drafts <span class="count">(%s)</span>', 'Drafts <span class="count">(%s)</span>', 'woocommerce' ),
109
+        ];
110
+    }
111
+
112
+    /**
113
+     * Remove draft status from the 'status' argument of an $args array.
114
+     *
115
+     * @param array $args Array of arguments containing statuses in the status key.
116
+     * @internal
117
+     * @return array
118
+     */
119
+    public function delete_draft_order_post_status_from_args( $args ) {
120
+        if ( ! array_key_exists( 'status', $args ) ) {
121
+            $statuses = [];
122
+            foreach ( wc_get_order_statuses() as $key => $label ) {
123
+                if ( self::DB_STATUS !== $key ) {
124
+                    $statuses[] = str_replace( 'wc-', '', $key );
125
+                }
126
+            }
127
+            $args['status'] = $statuses;
128
+        } elseif ( self::DB_STATUS === $args['status'] ) {
129
+            $args['status'] = '';
130
+        } elseif ( is_array( $args['status'] ) ) {
131
+            $args['status'] = array_diff_key( $args['status'], array( self::STATUS => null ) );
132
+        }
133
+
134
+        return $args;
135
+    }
136
+
137
+    /**
138
+     * Append draft status to a list of statuses.
139
+     *
140
+     * @param array $statuses Array of statuses.
141
+     * @internal
142
+     * @return array
143
+     */
144
+    public function append_draft_order_post_status( $statuses ) {
145
+        $statuses[] = self::STATUS;
146
+        return $statuses;
147
+    }
148
+
149
+    /**
150
+     * Delete draft orders older than a day in batches of 20.
151
+     *
152
+     * Ran on a daily cron schedule.
153
+     *
154
+     * @internal
155
+     */
156
+    public function delete_expired_draft_orders() {
157
+        $count      = 0;
158
+        $batch_size = 20;
159
+        $this->ensure_draft_status_registered();
160
+        $orders = wc_get_orders(
161
+            [
162
+                'date_modified' => '<=' . strtotime( '-1 DAY' ),
163
+                'limit'         => $batch_size,
164
+                'status'        => self::DB_STATUS,
165
+                'type'          => 'shop_order',
166
+            ]
167
+        );
168
+
169
+        // do we bail because the query results are unexpected?
170
+        try {
171
+            $this->assert_order_results( $orders, $batch_size );
172
+            if ( $orders ) {
173
+                foreach ( $orders as $order ) {
174
+                    $order->delete( true );
175
+                    $count ++;
176
+                }
177
+            }
178
+            if ( $batch_size === $count && function_exists( 'as_enqueue_async_action' ) ) {
179
+                as_enqueue_async_action( 'woocommerce_cleanup_draft_orders' );
180
+            }
181
+        } catch ( Exception $error ) {
182
+            wc_caught_exception( $error, __METHOD__ );
183
+        }
184
+    }
185
+
186
+    /**
187
+     * Since it's possible for third party code to clobber the `$wp_post_statuses` global,
188
+     * we need to do a final check here to make sure the draft post status is
189
+     * registered with the global so that it is not removed by WP_Query status
190
+     * validation checks.
191
+     */
192
+    private function ensure_draft_status_registered() {
193
+        $is_registered = get_post_stati( [ 'name' => self::DB_STATUS ] );
194
+        if ( empty( $is_registered ) ) {
195
+            register_post_status(
196
+                self::DB_STATUS,
197
+                $this->get_post_status_properties()
198
+            );
199
+        }
200
+    }
201
+
202
+    /**
203
+     * Asserts whether incoming order results are expected given the query
204
+     * this service class executes.
205
+     *
206
+     * @param WC_Order[] $order_results The order results being asserted.
207
+     * @param int        $expected_batch_size The expected batch size for the results.
208
+     * @throws Exception If any assertions fail, an exception is thrown.
209
+     */
210
+    private function assert_order_results( $order_results, $expected_batch_size ) {
211
+        // if not an array, then just return because it won't get handled
212
+        // anyways.
213
+        if ( ! is_array( $order_results ) ) {
214
+            return;
215
+        }
216
+
217
+        $suffix = ' This is an indicator that something is filtering WooCommerce or WordPress queries and modifying the query parameters.';
218
+
219
+        // if count is greater than our expected batch size, then that's a problem.
220
+        if ( count( $order_results ) > 20 ) {
221
+            throw new Exception( 'There are an unexpected number of results returned from the query.' . $suffix );
222
+        }
223
+
224
+        // if any of the returned orders are not draft (or not a WC_Order), then that's a problem.
225
+        foreach ( $order_results as $order ) {
226
+            if ( ! ( $order instanceof WC_Order ) ) {
227
+                throw new Exception( 'The returned results contain a value that is not a WC_Order.' . $suffix );
228
+            }
229
+            if ( ! $order->has_status( self::STATUS ) ) {
230
+                throw new Exception( 'The results contain an order that is not a `wc-checkout-draft` status in the results.' . $suffix );
231
+            }
232
+        }
233
+    }
236 234
 }
Please login to merge, or discard this patch.
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 *
30 30
 	 * @param Package $package An instance of the package class.
31 31
 	 */
32
-	public function __construct( Package $package ) {
32
+	public function __construct(Package $package) {
33 33
 		$this->package = $package;
34 34
 	}
35 35
 
@@ -37,15 +37,15 @@  discard block
 block discarded – undo
37 37
 	 * Set all hooks related to adding Checkout Draft order functionality to Woo Core.
38 38
 	 */
39 39
 	public function init() {
40
-		add_filter( 'wc_order_statuses', [ $this, 'register_draft_order_status' ] );
41
-		add_filter( 'woocommerce_register_shop_order_post_statuses', [ $this, 'register_draft_order_post_status' ] );
42
-		add_filter( 'woocommerce_analytics_excluded_order_statuses', [ $this, 'append_draft_order_post_status' ] );
43
-		add_filter( 'woocommerce_valid_order_statuses_for_payment', [ $this, 'append_draft_order_post_status' ] );
44
-		add_filter( 'woocommerce_valid_order_statuses_for_payment_complete', [ $this, 'append_draft_order_post_status' ] );
40
+		add_filter('wc_order_statuses', [$this, 'register_draft_order_status']);
41
+		add_filter('woocommerce_register_shop_order_post_statuses', [$this, 'register_draft_order_post_status']);
42
+		add_filter('woocommerce_analytics_excluded_order_statuses', [$this, 'append_draft_order_post_status']);
43
+		add_filter('woocommerce_valid_order_statuses_for_payment', [$this, 'append_draft_order_post_status']);
44
+		add_filter('woocommerce_valid_order_statuses_for_payment_complete', [$this, 'append_draft_order_post_status']);
45 45
 		// Hook into the query to retrieve My Account orders so draft status is excluded.
46
-		add_action( 'woocommerce_my_account_my_orders_query', [ $this, 'delete_draft_order_post_status_from_args' ] );
47
-		add_action( 'woocommerce_cleanup_draft_orders', [ $this, 'delete_expired_draft_orders' ] );
48
-		add_action( 'admin_init', [ $this, 'install' ] );
46
+		add_action('woocommerce_my_account_my_orders_query', [$this, 'delete_draft_order_post_status_from_args']);
47
+		add_action('woocommerce_cleanup_draft_orders', [$this, 'delete_expired_draft_orders']);
48
+		add_action('admin_init', [$this, 'install']);
49 49
 	}
50 50
 
51 51
 	/**
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
 	 * Maybe create cron events.
62 62
 	 */
63 63
 	protected function maybe_create_cronjobs() {
64
-		if ( function_exists( 'as_next_scheduled_action' ) && false === as_next_scheduled_action( 'woocommerce_cleanup_draft_orders' ) ) {
65
-			as_schedule_recurring_action( strtotime( 'midnight tonight' ), DAY_IN_SECONDS, 'woocommerce_cleanup_draft_orders' );
64
+		if (function_exists('as_next_scheduled_action') && false === as_next_scheduled_action('woocommerce_cleanup_draft_orders')) {
65
+			as_schedule_recurring_action(strtotime('midnight tonight'), DAY_IN_SECONDS, 'woocommerce_cleanup_draft_orders');
66 66
 		}
67 67
 	}
68 68
 
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
 	 * @internal
76 76
 	 * @return array
77 77
 	 */
78
-	public function register_draft_order_status( array $statuses ) {
79
-		$statuses[ self::DB_STATUS ] = _x( 'Draft', 'Order status', 'woocommerce' );
78
+	public function register_draft_order_status(array $statuses) {
79
+		$statuses[self::DB_STATUS] = _x('Draft', 'Order status', 'woocommerce');
80 80
 		return $statuses;
81 81
 	}
82 82
 
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
 
89 89
 	 * @return array
90 90
 	 */
91
-	public function register_draft_order_post_status( array $statuses ) {
92
-		$statuses[ self::DB_STATUS ] = $this->get_post_status_properties();
91
+	public function register_draft_order_post_status(array $statuses) {
92
+		$statuses[self::DB_STATUS] = $this->get_post_status_properties();
93 93
 		return $statuses;
94 94
 	}
95 95
 
@@ -100,13 +100,13 @@  discard block
 block discarded – undo
100 100
 	 */
101 101
 	private function get_post_status_properties() {
102 102
 		return [
103
-			'label'                     => _x( 'Draft', 'Order status', 'woocommerce' ),
103
+			'label'                     => _x('Draft', 'Order status', 'woocommerce'),
104 104
 			'public'                    => false,
105 105
 			'exclude_from_search'       => false,
106 106
 			'show_in_admin_all_list'    => false,
107 107
 			'show_in_admin_status_list' => true,
108 108
 			/* translators: %s: number of orders */
109
-			'label_count'               => _n_noop( 'Drafts <span class="count">(%s)</span>', 'Drafts <span class="count">(%s)</span>', 'woocommerce' ),
109
+			'label_count'               => _n_noop('Drafts <span class="count">(%s)</span>', 'Drafts <span class="count">(%s)</span>', 'woocommerce'),
110 110
 		];
111 111
 	}
112 112
 
@@ -117,19 +117,19 @@  discard block
 block discarded – undo
117 117
 	 * @internal
118 118
 	 * @return array
119 119
 	 */
120
-	public function delete_draft_order_post_status_from_args( $args ) {
121
-		if ( ! array_key_exists( 'status', $args ) ) {
120
+	public function delete_draft_order_post_status_from_args($args) {
121
+		if (!array_key_exists('status', $args)) {
122 122
 			$statuses = [];
123
-			foreach ( wc_get_order_statuses() as $key => $label ) {
124
-				if ( self::DB_STATUS !== $key ) {
125
-					$statuses[] = str_replace( 'wc-', '', $key );
123
+			foreach (wc_get_order_statuses() as $key => $label) {
124
+				if (self::DB_STATUS !== $key) {
125
+					$statuses[] = str_replace('wc-', '', $key);
126 126
 				}
127 127
 			}
128 128
 			$args['status'] = $statuses;
129
-		} elseif ( self::DB_STATUS === $args['status'] ) {
129
+		} elseif (self::DB_STATUS === $args['status']) {
130 130
 			$args['status'] = '';
131
-		} elseif ( is_array( $args['status'] ) ) {
132
-			$args['status'] = array_diff_key( $args['status'], array( self::STATUS => null ) );
131
+		} elseif (is_array($args['status'])) {
132
+			$args['status'] = array_diff_key($args['status'], array(self::STATUS => null));
133 133
 		}
134 134
 
135 135
 		return $args;
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 
144 144
 	 * @return array
145 145
 	 */
146
-	public function append_draft_order_post_status( $statuses ) {
146
+	public function append_draft_order_post_status($statuses) {
147 147
 		$statuses[] = self::STATUS;
148 148
 		return $statuses;
149 149
 	}
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 		$this->ensure_draft_status_registered();
162 162
 		$orders = wc_get_orders(
163 163
 			[
164
-				'date_modified' => '<=' . strtotime( '-1 DAY' ),
164
+				'date_modified' => '<=' . strtotime('-1 DAY'),
165 165
 				'limit'         => $batch_size,
166 166
 				'status'        => self::DB_STATUS,
167 167
 				'type'          => 'shop_order',
@@ -170,18 +170,18 @@  discard block
 block discarded – undo
170 170
 
171 171
 		// do we bail because the query results are unexpected?
172 172
 		try {
173
-			$this->assert_order_results( $orders, $batch_size );
174
-			if ( $orders ) {
175
-				foreach ( $orders as $order ) {
176
-					$order->delete( true );
177
-					$count ++;
173
+			$this->assert_order_results($orders, $batch_size);
174
+			if ($orders) {
175
+				foreach ($orders as $order) {
176
+					$order->delete(true);
177
+					$count++;
178 178
 				}
179 179
 			}
180
-			if ( $batch_size === $count && function_exists( 'as_enqueue_async_action' ) ) {
181
-				as_enqueue_async_action( 'woocommerce_cleanup_draft_orders' );
180
+			if ($batch_size === $count && function_exists('as_enqueue_async_action')) {
181
+				as_enqueue_async_action('woocommerce_cleanup_draft_orders');
182 182
 			}
183
-		} catch ( Exception $error ) {
184
-			wc_caught_exception( $error, __METHOD__ );
183
+		} catch (Exception $error) {
184
+			wc_caught_exception($error, __METHOD__);
185 185
 		}
186 186
 	}
187 187
 
@@ -192,8 +192,8 @@  discard block
 block discarded – undo
192 192
 	 * validation checks.
193 193
 	 */
194 194
 	private function ensure_draft_status_registered() {
195
-		$is_registered = get_post_stati( [ 'name' => self::DB_STATUS ] );
196
-		if ( empty( $is_registered ) ) {
195
+		$is_registered = get_post_stati(['name' => self::DB_STATUS]);
196
+		if (empty($is_registered)) {
197 197
 			register_post_status(
198 198
 				self::DB_STATUS,
199 199
 				$this->get_post_status_properties()
@@ -209,27 +209,27 @@  discard block
 block discarded – undo
209 209
 	 * @param int        $expected_batch_size The expected batch size for the results.
210 210
 	 * @throws Exception If any assertions fail, an exception is thrown.
211 211
 	 */
212
-	private function assert_order_results( $order_results, $expected_batch_size ) {
212
+	private function assert_order_results($order_results, $expected_batch_size) {
213 213
 		// if not an array, then just return because it won't get handled
214 214
 		// anyways.
215
-		if ( ! is_array( $order_results ) ) {
215
+		if (!is_array($order_results)) {
216 216
 			return;
217 217
 		}
218 218
 
219 219
 		$suffix = ' This is an indicator that something is filtering WooCommerce or WordPress queries and modifying the query parameters.';
220 220
 
221 221
 		// if count is greater than our expected batch size, then that's a problem.
222
-		if ( count( $order_results ) > 20 ) {
223
-			throw new Exception( 'There are an unexpected number of results returned from the query.' . $suffix );
222
+		if (count($order_results) > 20) {
223
+			throw new Exception('There are an unexpected number of results returned from the query.' . $suffix);
224 224
 		}
225 225
 
226 226
 		// if any of the returned orders are not draft (or not a WC_Order), then that's a problem.
227
-		foreach ( $order_results as $order ) {
228
-			if ( ! ( $order instanceof WC_Order ) ) {
229
-				throw new Exception( 'The returned results contain a value that is not a WC_Order.' . $suffix );
227
+		foreach ($order_results as $order) {
228
+			if (!($order instanceof WC_Order)) {
229
+				throw new Exception('The returned results contain a value that is not a WC_Order.' . $suffix);
230 230
 			}
231
-			if ( ! $order->has_status( self::STATUS ) ) {
232
-				throw new Exception( 'The results contain an order that is not a `wc-checkout-draft` status in the results.' . $suffix );
231
+			if (!$order->has_status(self::STATUS)) {
232
+				throw new Exception('The results contain an order that is not a `wc-checkout-draft` status in the results.' . $suffix);
233 233
 			}
234 234
 		}
235 235
 	}
Please login to merge, or discard this patch.
packages/woocommerce-blocks/src/Domain/Services/FeatureGating.php 2 patches
Indentation   +156 added lines, -156 removed lines patch added patch discarded remove patch
@@ -8,161 +8,161 @@
 block discarded – undo
8 8
  */
9 9
 class FeatureGating {
10 10
 
11
-	/**
12
-	 * Current flag value.
13
-	 *
14
-	 * @var int
15
-	 */
16
-	private $flag;
17
-
18
-	const EXPERIMENTAL_FLAG   = 3;
19
-	const FEATURE_PLUGIN_FLAG = 2;
20
-	const CORE_FLAG           = 1;
21
-
22
-	/**
23
-	 * Current environment
24
-	 *
25
-	 * @var string
26
-	 */
27
-	private $environment;
28
-
29
-	const PRODUCTION_ENVIRONMENT  = 'production';
30
-	const DEVELOPMENT_ENVIRONMENT = 'development';
31
-	const TEST_ENVIRONMENT        = 'test';
32
-
33
-	/**
34
-	 * Constructor
35
-	 *
36
-	 * @param int    $flag        Hardcoded flag value. Useful for tests.
37
-	 * @param string $environment Hardcoded environment value. Useful for tests.
38
-	 */
39
-	public function __construct( $flag = 0, $environment = 'unset' ) {
40
-		$this->flag        = $flag;
41
-		$this->environment = $environment;
42
-		$this->load_flag();
43
-		$this->load_environment();
44
-	}
45
-
46
-	/**
47
-	 * Set correct flag.
48
-	 */
49
-	public function load_flag() {
50
-		if ( 0 === $this->flag ) {
51
-			$default_flag = defined( 'WC_BLOCKS_IS_FEATURE_PLUGIN' ) ? self::FEATURE_PLUGIN_FLAG : self::CORE_FLAG;
52
-
53
-			if ( file_exists( __DIR__ . '/../../../blocks.ini' ) ) {
54
-				$allowed_flags = [ self::EXPERIMENTAL_FLAG, self::FEATURE_PLUGIN_FLAG, self::CORE_FLAG ];
55
-				$woo_options   = parse_ini_file( __DIR__ . '/../../../blocks.ini' );
56
-				$this->flag    = is_array( $woo_options ) && in_array( intval( $woo_options['woocommerce_blocks_phase'] ), $allowed_flags, true ) ? $woo_options['woocommerce_blocks_phase'] : $default_flag;
57
-			} else {
58
-				$this->flag = $default_flag;
59
-			}
60
-		}
61
-	}
62
-
63
-		/**
64
-		 * Set correct environment.
65
-		 */
66
-	public function load_environment() {
67
-		if ( 'unset' === $this->environment ) {
68
-			if ( file_exists( __DIR__ . '/../../../blocks.ini' ) ) {
69
-				$allowed_environments = [ self::PRODUCTION_ENVIRONMENT, self::DEVELOPMENT_ENVIRONMENT, self::TEST_ENVIRONMENT ];
70
-				$woo_options          = parse_ini_file( __DIR__ . '/../../../blocks.ini' );
71
-				$this->environment    = is_array( $woo_options ) && in_array( $woo_options['woocommerce_blocks_env'], $allowed_environments, true ) ? $woo_options['woocommerce_blocks_env'] : self::PRODUCTION_ENVIRONMENT;
72
-			} else {
73
-				$this->environment = self::PRODUCTION_ENVIRONMENT;
74
-			}
75
-		}
76
-	}
77
-
78
-	/**
79
-	 * Returns the current flag value.
80
-	 *
81
-	 * @return int
82
-	 */
83
-	public function get_flag() {
84
-		return $this->flag;
85
-	}
86
-
87
-	/**
88
-	 * Checks if we're executing the code in an experimental build mode.
89
-	 *
90
-	 * @return boolean
91
-	 */
92
-	public function is_experimental_build() {
93
-		return $this->flag >= self::EXPERIMENTAL_FLAG;
94
-	}
95
-
96
-	/**
97
-	 * Checks if we're executing the code in an feature plugin or experimental build mode.
98
-	 *
99
-	 * @return boolean
100
-	 */
101
-	public function is_feature_plugin_build() {
102
-		return $this->flag >= self::FEATURE_PLUGIN_FLAG;
103
-	}
104
-
105
-		/**
106
-		 * Returns the current environment value.
107
-		 *
108
-		 * @return string
109
-		 */
110
-	public function get_environment() {
111
-		return $this->environment;
112
-	}
113
-
114
-	/**
115
-	 * Checks if we're executing the code in an development environment.
116
-	 *
117
-	 * @return boolean
118
-	 */
119
-	public function is_development_environment() {
120
-		return self::DEVELOPMENT_ENVIRONMENT === $this->environment;
121
-	}
122
-
123
-	/**
124
-	 * Checks if we're executing the code in a production environment.
125
-	 *
126
-	 * @return boolean
127
-	 */
128
-	public function is_production_environment() {
129
-		return self::PRODUCTION_ENVIRONMENT === $this->environment;
130
-	}
131
-
132
-	/**
133
-	 * Checks if we're executing the code in a test environment.
134
-	 *
135
-	 * @return boolean
136
-	 */
137
-	public function is_test_environment() {
138
-		return self::TEST_ENVIRONMENT === $this->environment;
139
-	}
140
-
141
-	/**
142
-	 * Returns core flag value.
143
-	 *
144
-	 * @return number
145
-	 */
146
-	public static function get_core_flag() {
147
-		return self::CORE_FLAG;
148
-	}
149
-
150
-	/**
151
-	 * Returns feature plugin flag value.
152
-	 *
153
-	 * @return number
154
-	 */
155
-	public static function get_feature_plugin_flag() {
156
-		return self::FEATURE_PLUGIN_FLAG;
157
-	}
158
-
159
-	/**
160
-	 * Returns experimental flag value.
161
-	 *
162
-	 * @return number
163
-	 */
164
-	public static function get_experimental_flag() {
165
-		return self::EXPERIMENTAL_FLAG;
166
-	}
11
+    /**
12
+     * Current flag value.
13
+     *
14
+     * @var int
15
+     */
16
+    private $flag;
17
+
18
+    const EXPERIMENTAL_FLAG   = 3;
19
+    const FEATURE_PLUGIN_FLAG = 2;
20
+    const CORE_FLAG           = 1;
21
+
22
+    /**
23
+     * Current environment
24
+     *
25
+     * @var string
26
+     */
27
+    private $environment;
28
+
29
+    const PRODUCTION_ENVIRONMENT  = 'production';
30
+    const DEVELOPMENT_ENVIRONMENT = 'development';
31
+    const TEST_ENVIRONMENT        = 'test';
32
+
33
+    /**
34
+     * Constructor
35
+     *
36
+     * @param int    $flag        Hardcoded flag value. Useful for tests.
37
+     * @param string $environment Hardcoded environment value. Useful for tests.
38
+     */
39
+    public function __construct( $flag = 0, $environment = 'unset' ) {
40
+        $this->flag        = $flag;
41
+        $this->environment = $environment;
42
+        $this->load_flag();
43
+        $this->load_environment();
44
+    }
45
+
46
+    /**
47
+     * Set correct flag.
48
+     */
49
+    public function load_flag() {
50
+        if ( 0 === $this->flag ) {
51
+            $default_flag = defined( 'WC_BLOCKS_IS_FEATURE_PLUGIN' ) ? self::FEATURE_PLUGIN_FLAG : self::CORE_FLAG;
52
+
53
+            if ( file_exists( __DIR__ . '/../../../blocks.ini' ) ) {
54
+                $allowed_flags = [ self::EXPERIMENTAL_FLAG, self::FEATURE_PLUGIN_FLAG, self::CORE_FLAG ];
55
+                $woo_options   = parse_ini_file( __DIR__ . '/../../../blocks.ini' );
56
+                $this->flag    = is_array( $woo_options ) && in_array( intval( $woo_options['woocommerce_blocks_phase'] ), $allowed_flags, true ) ? $woo_options['woocommerce_blocks_phase'] : $default_flag;
57
+            } else {
58
+                $this->flag = $default_flag;
59
+            }
60
+        }
61
+    }
62
+
63
+        /**
64
+         * Set correct environment.
65
+         */
66
+    public function load_environment() {
67
+        if ( 'unset' === $this->environment ) {
68
+            if ( file_exists( __DIR__ . '/../../../blocks.ini' ) ) {
69
+                $allowed_environments = [ self::PRODUCTION_ENVIRONMENT, self::DEVELOPMENT_ENVIRONMENT, self::TEST_ENVIRONMENT ];
70
+                $woo_options          = parse_ini_file( __DIR__ . '/../../../blocks.ini' );
71
+                $this->environment    = is_array( $woo_options ) && in_array( $woo_options['woocommerce_blocks_env'], $allowed_environments, true ) ? $woo_options['woocommerce_blocks_env'] : self::PRODUCTION_ENVIRONMENT;
72
+            } else {
73
+                $this->environment = self::PRODUCTION_ENVIRONMENT;
74
+            }
75
+        }
76
+    }
77
+
78
+    /**
79
+     * Returns the current flag value.
80
+     *
81
+     * @return int
82
+     */
83
+    public function get_flag() {
84
+        return $this->flag;
85
+    }
86
+
87
+    /**
88
+     * Checks if we're executing the code in an experimental build mode.
89
+     *
90
+     * @return boolean
91
+     */
92
+    public function is_experimental_build() {
93
+        return $this->flag >= self::EXPERIMENTAL_FLAG;
94
+    }
95
+
96
+    /**
97
+     * Checks if we're executing the code in an feature plugin or experimental build mode.
98
+     *
99
+     * @return boolean
100
+     */
101
+    public function is_feature_plugin_build() {
102
+        return $this->flag >= self::FEATURE_PLUGIN_FLAG;
103
+    }
104
+
105
+        /**
106
+         * Returns the current environment value.
107
+         *
108
+         * @return string
109
+         */
110
+    public function get_environment() {
111
+        return $this->environment;
112
+    }
113
+
114
+    /**
115
+     * Checks if we're executing the code in an development environment.
116
+     *
117
+     * @return boolean
118
+     */
119
+    public function is_development_environment() {
120
+        return self::DEVELOPMENT_ENVIRONMENT === $this->environment;
121
+    }
122
+
123
+    /**
124
+     * Checks if we're executing the code in a production environment.
125
+     *
126
+     * @return boolean
127
+     */
128
+    public function is_production_environment() {
129
+        return self::PRODUCTION_ENVIRONMENT === $this->environment;
130
+    }
131
+
132
+    /**
133
+     * Checks if we're executing the code in a test environment.
134
+     *
135
+     * @return boolean
136
+     */
137
+    public function is_test_environment() {
138
+        return self::TEST_ENVIRONMENT === $this->environment;
139
+    }
140
+
141
+    /**
142
+     * Returns core flag value.
143
+     *
144
+     * @return number
145
+     */
146
+    public static function get_core_flag() {
147
+        return self::CORE_FLAG;
148
+    }
149
+
150
+    /**
151
+     * Returns feature plugin flag value.
152
+     *
153
+     * @return number
154
+     */
155
+    public static function get_feature_plugin_flag() {
156
+        return self::FEATURE_PLUGIN_FLAG;
157
+    }
158
+
159
+    /**
160
+     * Returns experimental flag value.
161
+     *
162
+     * @return number
163
+     */
164
+    public static function get_experimental_flag() {
165
+        return self::EXPERIMENTAL_FLAG;
166
+    }
167 167
 
168 168
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	 * @param int    $flag        Hardcoded flag value. Useful for tests.
37 37
 	 * @param string $environment Hardcoded environment value. Useful for tests.
38 38
 	 */
39
-	public function __construct( $flag = 0, $environment = 'unset' ) {
39
+	public function __construct($flag = 0, $environment = 'unset') {
40 40
 		$this->flag        = $flag;
41 41
 		$this->environment = $environment;
42 42
 		$this->load_flag();
@@ -47,13 +47,13 @@  discard block
 block discarded – undo
47 47
 	 * Set correct flag.
48 48
 	 */
49 49
 	public function load_flag() {
50
-		if ( 0 === $this->flag ) {
51
-			$default_flag = defined( 'WC_BLOCKS_IS_FEATURE_PLUGIN' ) ? self::FEATURE_PLUGIN_FLAG : self::CORE_FLAG;
50
+		if (0 === $this->flag) {
51
+			$default_flag = defined('WC_BLOCKS_IS_FEATURE_PLUGIN') ? self::FEATURE_PLUGIN_FLAG : self::CORE_FLAG;
52 52
 
53
-			if ( file_exists( __DIR__ . '/../../../blocks.ini' ) ) {
54
-				$allowed_flags = [ self::EXPERIMENTAL_FLAG, self::FEATURE_PLUGIN_FLAG, self::CORE_FLAG ];
55
-				$woo_options   = parse_ini_file( __DIR__ . '/../../../blocks.ini' );
56
-				$this->flag    = is_array( $woo_options ) && in_array( intval( $woo_options['woocommerce_blocks_phase'] ), $allowed_flags, true ) ? $woo_options['woocommerce_blocks_phase'] : $default_flag;
53
+			if (file_exists(__DIR__ . '/../../../blocks.ini')) {
54
+				$allowed_flags = [self::EXPERIMENTAL_FLAG, self::FEATURE_PLUGIN_FLAG, self::CORE_FLAG];
55
+				$woo_options   = parse_ini_file(__DIR__ . '/../../../blocks.ini');
56
+				$this->flag    = is_array($woo_options) && in_array(intval($woo_options['woocommerce_blocks_phase']), $allowed_flags, true) ? $woo_options['woocommerce_blocks_phase'] : $default_flag;
57 57
 			} else {
58 58
 				$this->flag = $default_flag;
59 59
 			}
@@ -64,11 +64,11 @@  discard block
 block discarded – undo
64 64
 		 * Set correct environment.
65 65
 		 */
66 66
 	public function load_environment() {
67
-		if ( 'unset' === $this->environment ) {
68
-			if ( file_exists( __DIR__ . '/../../../blocks.ini' ) ) {
69
-				$allowed_environments = [ self::PRODUCTION_ENVIRONMENT, self::DEVELOPMENT_ENVIRONMENT, self::TEST_ENVIRONMENT ];
70
-				$woo_options          = parse_ini_file( __DIR__ . '/../../../blocks.ini' );
71
-				$this->environment    = is_array( $woo_options ) && in_array( $woo_options['woocommerce_blocks_env'], $allowed_environments, true ) ? $woo_options['woocommerce_blocks_env'] : self::PRODUCTION_ENVIRONMENT;
67
+		if ('unset' === $this->environment) {
68
+			if (file_exists(__DIR__ . '/../../../blocks.ini')) {
69
+				$allowed_environments = [self::PRODUCTION_ENVIRONMENT, self::DEVELOPMENT_ENVIRONMENT, self::TEST_ENVIRONMENT];
70
+				$woo_options          = parse_ini_file(__DIR__ . '/../../../blocks.ini');
71
+				$this->environment    = is_array($woo_options) && in_array($woo_options['woocommerce_blocks_env'], $allowed_environments, true) ? $woo_options['woocommerce_blocks_env'] : self::PRODUCTION_ENVIRONMENT;
72 72
 			} else {
73 73
 				$this->environment = self::PRODUCTION_ENVIRONMENT;
74 74
 			}
Please login to merge, or discard this patch.
plugins/woocommerce/packages/woocommerce-blocks/src/Domain/Bootstrap.php 2 patches
Indentation   +339 added lines, -339 removed lines patch added patch discarded remove patch
@@ -32,366 +32,366 @@
 block discarded – undo
32 32
  */
33 33
 class Bootstrap {
34 34
 
35
-	/**
36
-	 * Holds the Dependency Injection Container
37
-	 *
38
-	 * @var Container
39
-	 */
40
-	private $container;
35
+    /**
36
+     * Holds the Dependency Injection Container
37
+     *
38
+     * @var Container
39
+     */
40
+    private $container;
41 41
 
42
-	/**
43
-	 * Holds the Package instance
44
-	 *
45
-	 * @var Package
46
-	 */
47
-	private $package;
42
+    /**
43
+     * Holds the Package instance
44
+     *
45
+     * @var Package
46
+     */
47
+    private $package;
48 48
 
49
-	/**
50
-	 * Constructor
51
-	 *
52
-	 * @param Container $container  The Dependency Injection Container.
53
-	 */
54
-	public function __construct( Container $container ) {
55
-		$this->container = $container;
56
-		$this->package   = $container->get( Package::class );
57
-		if ( $this->has_core_dependencies() ) {
58
-			$this->init();
59
-			/**
60
-			 * Fires after WooCommerce Blocks plugin has loaded.
61
-			 *
62
-			 * This hook is intended to be used as a safe event hook for when the plugin has been loaded, and all
63
-			 * dependency requirements have been met.
64
-			 */
65
-			do_action( 'woocommerce_blocks_loaded' );
66
-		}
67
-	}
49
+    /**
50
+     * Constructor
51
+     *
52
+     * @param Container $container  The Dependency Injection Container.
53
+     */
54
+    public function __construct( Container $container ) {
55
+        $this->container = $container;
56
+        $this->package   = $container->get( Package::class );
57
+        if ( $this->has_core_dependencies() ) {
58
+            $this->init();
59
+            /**
60
+             * Fires after WooCommerce Blocks plugin has loaded.
61
+             *
62
+             * This hook is intended to be used as a safe event hook for when the plugin has been loaded, and all
63
+             * dependency requirements have been met.
64
+             */
65
+            do_action( 'woocommerce_blocks_loaded' );
66
+        }
67
+    }
68 68
 
69
-	/**
70
-	 * Init the package - load the blocks library and define constants.
71
-	 */
72
-	protected function init() {
73
-		$this->register_dependencies();
74
-		$this->register_payment_methods();
69
+    /**
70
+     * Init the package - load the blocks library and define constants.
71
+     */
72
+    protected function init() {
73
+        $this->register_dependencies();
74
+        $this->register_payment_methods();
75 75
 
76
-		add_action(
77
-			'admin_init',
78
-			function() {
79
-				InboxNotifications::create_surface_cart_checkout_blocks_notification();
80
-			},
81
-			10,
82
-			0
83
-		);
76
+        add_action(
77
+            'admin_init',
78
+            function() {
79
+                InboxNotifications::create_surface_cart_checkout_blocks_notification();
80
+            },
81
+            10,
82
+            0
83
+        );
84 84
 
85
-		$is_rest = wc()->is_rest_api_request();
85
+        $is_rest = wc()->is_rest_api_request();
86 86
 
87
-		// Load assets in admin and on the frontend.
88
-		if ( ! $is_rest ) {
89
-			$this->add_build_notice();
90
-			$this->container->get( AssetDataRegistry::class );
91
-			$this->container->get( Installer::class );
92
-			$this->container->get( AssetsController::class );
93
-		}
94
-		$this->container->get( DraftOrders::class )->init();
95
-		$this->container->get( CreateAccount::class )->init();
96
-		$this->container->get( StoreApi::class )->init();
97
-		$this->container->get( GoogleAnalytics::class );
98
-		$this->container->get( BlockTypesController::class );
99
-		$this->container->get( BlockTemplatesController::class );
100
-		$this->container->get( ProductSearchResultsTemplate::class );
101
-		$this->container->get( ClassicTemplatesCompatibility::class );
102
-		if ( $this->package->feature()->is_feature_plugin_build() ) {
103
-			$this->container->get( PaymentsApi::class );
104
-		}
105
-	}
87
+        // Load assets in admin and on the frontend.
88
+        if ( ! $is_rest ) {
89
+            $this->add_build_notice();
90
+            $this->container->get( AssetDataRegistry::class );
91
+            $this->container->get( Installer::class );
92
+            $this->container->get( AssetsController::class );
93
+        }
94
+        $this->container->get( DraftOrders::class )->init();
95
+        $this->container->get( CreateAccount::class )->init();
96
+        $this->container->get( StoreApi::class )->init();
97
+        $this->container->get( GoogleAnalytics::class );
98
+        $this->container->get( BlockTypesController::class );
99
+        $this->container->get( BlockTemplatesController::class );
100
+        $this->container->get( ProductSearchResultsTemplate::class );
101
+        $this->container->get( ClassicTemplatesCompatibility::class );
102
+        if ( $this->package->feature()->is_feature_plugin_build() ) {
103
+            $this->container->get( PaymentsApi::class );
104
+        }
105
+    }
106 106
 
107
-	/**
108
-	 * Check core dependencies exist.
109
-	 *
110
-	 * @return boolean
111
-	 */
112
-	protected function has_core_dependencies() {
113
-		$has_needed_dependencies = class_exists( 'WooCommerce', false );
114
-		if ( $has_needed_dependencies ) {
115
-			$plugin_data = \get_file_data(
116
-				$this->package->get_path( 'woocommerce-gutenberg-products-block.php' ),
117
-				[
118
-					'RequiredWCVersion' => 'WC requires at least',
119
-				]
120
-			);
121
-			if ( isset( $plugin_data['RequiredWCVersion'] ) && version_compare( \WC()->version, $plugin_data['RequiredWCVersion'], '<' ) ) {
122
-				$has_needed_dependencies = false;
123
-				add_action(
124
-					'admin_notices',
125
-					function() {
126
-						if ( should_display_compatibility_notices() ) {
127
-							?>
107
+    /**
108
+     * Check core dependencies exist.
109
+     *
110
+     * @return boolean
111
+     */
112
+    protected function has_core_dependencies() {
113
+        $has_needed_dependencies = class_exists( 'WooCommerce', false );
114
+        if ( $has_needed_dependencies ) {
115
+            $plugin_data = \get_file_data(
116
+                $this->package->get_path( 'woocommerce-gutenberg-products-block.php' ),
117
+                [
118
+                    'RequiredWCVersion' => 'WC requires at least',
119
+                ]
120
+            );
121
+            if ( isset( $plugin_data['RequiredWCVersion'] ) && version_compare( \WC()->version, $plugin_data['RequiredWCVersion'], '<' ) ) {
122
+                $has_needed_dependencies = false;
123
+                add_action(
124
+                    'admin_notices',
125
+                    function() {
126
+                        if ( should_display_compatibility_notices() ) {
127
+                            ?>
128 128
 							<div class="notice notice-error">
129 129
 								<p><?php esc_html_e( 'The WooCommerce Blocks feature plugin requires a more recent version of WooCommerce and has been paused. Please update WooCommerce to the latest version to continue enjoying WooCommerce Blocks.', 'woocommerce' ); ?></p>
130 130
 							</div>
131 131
 							<?php
132
-						}
133
-					}
134
-				);
135
-			}
136
-		}
137
-		return $has_needed_dependencies;
138
-	}
132
+                        }
133
+                    }
134
+                );
135
+            }
136
+        }
137
+        return $has_needed_dependencies;
138
+    }
139 139
 
140
-	/**
141
-	 * See if files have been built or not.
142
-	 *
143
-	 * @return bool
144
-	 */
145
-	protected function is_built() {
146
-		return file_exists(
147
-			$this->package->get_path( 'build/featured-product.js' )
148
-		);
149
-	}
140
+    /**
141
+     * See if files have been built or not.
142
+     *
143
+     * @return bool
144
+     */
145
+    protected function is_built() {
146
+        return file_exists(
147
+            $this->package->get_path( 'build/featured-product.js' )
148
+        );
149
+    }
150 150
 
151
-	/**
152
-	 * Add a notice stating that the build has not been done yet.
153
-	 */
154
-	protected function add_build_notice() {
155
-		if ( $this->is_built() ) {
156
-			return;
157
-		}
158
-		add_action(
159
-			'admin_notices',
160
-			function() {
161
-				echo '<div class="error"><p>';
162
-				printf(
163
-					/* translators: %1$s is the install command, %2$s is the build command, %3$s is the watch command. */
164
-					esc_html__( 'WooCommerce Blocks development mode requires files to be built. From the plugin directory, run %1$s to install dependencies, %2$s to build the files or %3$s to build the files and watch for changes.', 'woocommerce' ),
165
-					'<code>npm install</code>',
166
-					'<code>npm run build</code>',
167
-					'<code>npm start</code>'
168
-				);
169
-				echo '</p></div>';
170
-			}
171
-		);
172
-	}
151
+    /**
152
+     * Add a notice stating that the build has not been done yet.
153
+     */
154
+    protected function add_build_notice() {
155
+        if ( $this->is_built() ) {
156
+            return;
157
+        }
158
+        add_action(
159
+            'admin_notices',
160
+            function() {
161
+                echo '<div class="error"><p>';
162
+                printf(
163
+                    /* translators: %1$s is the install command, %2$s is the build command, %3$s is the watch command. */
164
+                    esc_html__( 'WooCommerce Blocks development mode requires files to be built. From the plugin directory, run %1$s to install dependencies, %2$s to build the files or %3$s to build the files and watch for changes.', 'woocommerce' ),
165
+                    '<code>npm install</code>',
166
+                    '<code>npm run build</code>',
167
+                    '<code>npm start</code>'
168
+                );
169
+                echo '</p></div>';
170
+            }
171
+        );
172
+    }
173 173
 
174
-	/**
175
-	 * Register core dependencies with the container.
176
-	 */
177
-	protected function register_dependencies() {
178
-		$this->container->register(
179
-			FeatureGating::class,
180
-			function () {
181
-				return new FeatureGating();
182
-			}
183
-		);
184
-		$this->container->register(
185
-			AssetApi::class,
186
-			function ( Container $container ) {
187
-				return new AssetApi( $container->get( Package::class ) );
188
-			}
189
-		);
190
-		$this->container->register(
191
-			AssetDataRegistry::class,
192
-			function( Container $container ) {
193
-				return new AssetDataRegistry( $container->get( AssetApi::class ) );
194
-			}
195
-		);
196
-		$this->container->register(
197
-			AssetsController::class,
198
-			function( Container $container ) {
199
-				return new AssetsController( $container->get( AssetApi::class ) );
200
-			}
201
-		);
202
-		$this->container->register(
203
-			PaymentMethodRegistry::class,
204
-			function() {
205
-				return new PaymentMethodRegistry();
206
-			}
207
-		);
208
-		$this->container->register(
209
-			Installer::class,
210
-			function () {
211
-				return new Installer();
212
-			}
213
-		);
214
-		$this->container->register(
215
-			BlockTypesController::class,
216
-			function ( Container $container ) {
217
-				$asset_api           = $container->get( AssetApi::class );
218
-				$asset_data_registry = $container->get( AssetDataRegistry::class );
219
-				return new BlockTypesController( $asset_api, $asset_data_registry );
220
-			}
221
-		);
222
-		$this->container->register(
223
-			BlockTemplatesController::class,
224
-			function () {
225
-				return new BlockTemplatesController();
226
-			}
227
-		);
228
-		$this->container->register(
229
-			ProductSearchResultsTemplate::class,
230
-			function () {
231
-				return new ProductSearchResultsTemplate();
232
-			}
233
-		);
234
-		$this->container->register(
235
-			ClassicTemplatesCompatibility::class,
236
-			function ( Container $container ) {
237
-				$asset_data_registry = $container->get( AssetDataRegistry::class );
238
-				return new ClassicTemplatesCompatibility( $asset_data_registry );
239
-			}
240
-		);
241
-		$this->container->register(
242
-			DraftOrders::class,
243
-			function( Container $container ) {
244
-				return new DraftOrders( $container->get( Package::class ) );
245
-			}
246
-		);
247
-		$this->container->register(
248
-			CreateAccount::class,
249
-			function( Container $container ) {
250
-				return new CreateAccount( $container->get( Package::class ) );
251
-			}
252
-		);
253
-		$this->container->register(
254
-			GoogleAnalytics::class,
255
-			function( Container $container ) {
256
-				// Require Google Analytics Integration to be activated.
257
-				if ( ! class_exists( 'WC_Google_Analytics_Integration', false ) ) {
258
-					return;
259
-				}
260
-				$asset_api = $container->get( AssetApi::class );
261
-				return new GoogleAnalytics( $asset_api );
262
-			}
263
-		);
264
-		if ( $this->package->feature()->is_feature_plugin_build() ) {
265
-			$this->container->register(
266
-				PaymentsApi::class,
267
-				function ( Container $container ) {
268
-					$payment_method_registry = $container->get( PaymentMethodRegistry::class );
269
-					$asset_data_registry     = $container->get( AssetDataRegistry::class );
270
-					return new PaymentsApi( $payment_method_registry, $asset_data_registry );
271
-				}
272
-			);
273
-		}
274
-		$this->container->register(
275
-			StoreApi::class,
276
-			function () {
277
-				return new StoreApi();
278
-			}
279
-		);
280
-		// Maintains backwards compatibility with previous Store API namespace.
281
-		$this->container->register(
282
-			'Automattic\WooCommerce\Blocks\StoreApi\Formatters',
283
-			function( Container $container ) {
284
-				$this->deprecated_dependency( 'Automattic\WooCommerce\Blocks\StoreApi\Formatters', '7.2.0', 'Automattic\WooCommerce\StoreApi\Formatters', '7.4.0' );
285
-				return $container->get( StoreApi::class )::container()->get( \Automattic\WooCommerce\StoreApi\Formatters::class );
286
-			}
287
-		);
288
-		$this->container->register(
289
-			'Automattic\WooCommerce\Blocks\Domain\Services\ExtendRestApi',
290
-			function( Container $container ) {
291
-				$this->deprecated_dependency( 'Automattic\WooCommerce\Blocks\Domain\Services\ExtendRestApi', '7.2.0', 'Automattic\WooCommerce\StoreApi\Schemas\ExtendSchema', '7.4.0' );
292
-				return $container->get( StoreApi::class )::container()->get( \Automattic\WooCommerce\StoreApi\Schemas\ExtendSchema::class );
293
-			}
294
-		);
295
-		$this->container->register(
296
-			'Automattic\WooCommerce\Blocks\StoreApi\SchemaController',
297
-			function( Container $container ) {
298
-				$this->deprecated_dependency( 'Automattic\WooCommerce\Blocks\StoreApi\SchemaController', '7.2.0', 'Automattic\WooCommerce\StoreApi\SchemaController', '7.4.0' );
299
-				return $container->get( StoreApi::class )::container()->get( SchemaController::class );
300
-			}
301
-		);
302
-		$this->container->register(
303
-			'Automattic\WooCommerce\Blocks\StoreApi\RoutesController',
304
-			function( Container $container ) {
305
-				$this->deprecated_dependency( 'Automattic\WooCommerce\Blocks\StoreApi\RoutesController', '7.2.0', 'Automattic\WooCommerce\StoreApi\RoutesController', '7.4.0' );
306
-				return $container->get( StoreApi::class )::container()->get( RoutesController::class );
307
-			}
308
-		);
309
-	}
174
+    /**
175
+     * Register core dependencies with the container.
176
+     */
177
+    protected function register_dependencies() {
178
+        $this->container->register(
179
+            FeatureGating::class,
180
+            function () {
181
+                return new FeatureGating();
182
+            }
183
+        );
184
+        $this->container->register(
185
+            AssetApi::class,
186
+            function ( Container $container ) {
187
+                return new AssetApi( $container->get( Package::class ) );
188
+            }
189
+        );
190
+        $this->container->register(
191
+            AssetDataRegistry::class,
192
+            function( Container $container ) {
193
+                return new AssetDataRegistry( $container->get( AssetApi::class ) );
194
+            }
195
+        );
196
+        $this->container->register(
197
+            AssetsController::class,
198
+            function( Container $container ) {
199
+                return new AssetsController( $container->get( AssetApi::class ) );
200
+            }
201
+        );
202
+        $this->container->register(
203
+            PaymentMethodRegistry::class,
204
+            function() {
205
+                return new PaymentMethodRegistry();
206
+            }
207
+        );
208
+        $this->container->register(
209
+            Installer::class,
210
+            function () {
211
+                return new Installer();
212
+            }
213
+        );
214
+        $this->container->register(
215
+            BlockTypesController::class,
216
+            function ( Container $container ) {
217
+                $asset_api           = $container->get( AssetApi::class );
218
+                $asset_data_registry = $container->get( AssetDataRegistry::class );
219
+                return new BlockTypesController( $asset_api, $asset_data_registry );
220
+            }
221
+        );
222
+        $this->container->register(
223
+            BlockTemplatesController::class,
224
+            function () {
225
+                return new BlockTemplatesController();
226
+            }
227
+        );
228
+        $this->container->register(
229
+            ProductSearchResultsTemplate::class,
230
+            function () {
231
+                return new ProductSearchResultsTemplate();
232
+            }
233
+        );
234
+        $this->container->register(
235
+            ClassicTemplatesCompatibility::class,
236
+            function ( Container $container ) {
237
+                $asset_data_registry = $container->get( AssetDataRegistry::class );
238
+                return new ClassicTemplatesCompatibility( $asset_data_registry );
239
+            }
240
+        );
241
+        $this->container->register(
242
+            DraftOrders::class,
243
+            function( Container $container ) {
244
+                return new DraftOrders( $container->get( Package::class ) );
245
+            }
246
+        );
247
+        $this->container->register(
248
+            CreateAccount::class,
249
+            function( Container $container ) {
250
+                return new CreateAccount( $container->get( Package::class ) );
251
+            }
252
+        );
253
+        $this->container->register(
254
+            GoogleAnalytics::class,
255
+            function( Container $container ) {
256
+                // Require Google Analytics Integration to be activated.
257
+                if ( ! class_exists( 'WC_Google_Analytics_Integration', false ) ) {
258
+                    return;
259
+                }
260
+                $asset_api = $container->get( AssetApi::class );
261
+                return new GoogleAnalytics( $asset_api );
262
+            }
263
+        );
264
+        if ( $this->package->feature()->is_feature_plugin_build() ) {
265
+            $this->container->register(
266
+                PaymentsApi::class,
267
+                function ( Container $container ) {
268
+                    $payment_method_registry = $container->get( PaymentMethodRegistry::class );
269
+                    $asset_data_registry     = $container->get( AssetDataRegistry::class );
270
+                    return new PaymentsApi( $payment_method_registry, $asset_data_registry );
271
+                }
272
+            );
273
+        }
274
+        $this->container->register(
275
+            StoreApi::class,
276
+            function () {
277
+                return new StoreApi();
278
+            }
279
+        );
280
+        // Maintains backwards compatibility with previous Store API namespace.
281
+        $this->container->register(
282
+            'Automattic\WooCommerce\Blocks\StoreApi\Formatters',
283
+            function( Container $container ) {
284
+                $this->deprecated_dependency( 'Automattic\WooCommerce\Blocks\StoreApi\Formatters', '7.2.0', 'Automattic\WooCommerce\StoreApi\Formatters', '7.4.0' );
285
+                return $container->get( StoreApi::class )::container()->get( \Automattic\WooCommerce\StoreApi\Formatters::class );
286
+            }
287
+        );
288
+        $this->container->register(
289
+            'Automattic\WooCommerce\Blocks\Domain\Services\ExtendRestApi',
290
+            function( Container $container ) {
291
+                $this->deprecated_dependency( 'Automattic\WooCommerce\Blocks\Domain\Services\ExtendRestApi', '7.2.0', 'Automattic\WooCommerce\StoreApi\Schemas\ExtendSchema', '7.4.0' );
292
+                return $container->get( StoreApi::class )::container()->get( \Automattic\WooCommerce\StoreApi\Schemas\ExtendSchema::class );
293
+            }
294
+        );
295
+        $this->container->register(
296
+            'Automattic\WooCommerce\Blocks\StoreApi\SchemaController',
297
+            function( Container $container ) {
298
+                $this->deprecated_dependency( 'Automattic\WooCommerce\Blocks\StoreApi\SchemaController', '7.2.0', 'Automattic\WooCommerce\StoreApi\SchemaController', '7.4.0' );
299
+                return $container->get( StoreApi::class )::container()->get( SchemaController::class );
300
+            }
301
+        );
302
+        $this->container->register(
303
+            'Automattic\WooCommerce\Blocks\StoreApi\RoutesController',
304
+            function( Container $container ) {
305
+                $this->deprecated_dependency( 'Automattic\WooCommerce\Blocks\StoreApi\RoutesController', '7.2.0', 'Automattic\WooCommerce\StoreApi\RoutesController', '7.4.0' );
306
+                return $container->get( StoreApi::class )::container()->get( RoutesController::class );
307
+            }
308
+        );
309
+    }
310 310
 
311
-	/**
312
-	 * Throws a deprecation notice for a dependency without breaking requests.
313
-	 *
314
-	 * @param string $function Class or function being deprecated.
315
-	 * @param string $version Version in which it was deprecated.
316
-	 * @param string $replacement Replacement class or function, if applicable.
317
-	 * @param string $trigger_error_version Optional version to start surfacing this as a PHP error rather than a log. Defaults to $version.
318
-	 */
319
-	protected function deprecated_dependency( $function, $version, $replacement = '', $trigger_error_version = '' ) {
320
-		if ( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) {
321
-			return;
322
-		}
311
+    /**
312
+     * Throws a deprecation notice for a dependency without breaking requests.
313
+     *
314
+     * @param string $function Class or function being deprecated.
315
+     * @param string $version Version in which it was deprecated.
316
+     * @param string $replacement Replacement class or function, if applicable.
317
+     * @param string $trigger_error_version Optional version to start surfacing this as a PHP error rather than a log. Defaults to $version.
318
+     */
319
+    protected function deprecated_dependency( $function, $version, $replacement = '', $trigger_error_version = '' ) {
320
+        if ( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) {
321
+            return;
322
+        }
323 323
 
324
-		$trigger_error_version = $trigger_error_version ? $trigger_error_version : $version;
325
-		$error_message         = $replacement ? sprintf(
326
-			'%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.',
327
-			$function,
328
-			$version,
329
-			$replacement
330
-		) : sprintf(
331
-			'%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.',
332
-			$function,
333
-			$version
334
-		);
324
+        $trigger_error_version = $trigger_error_version ? $trigger_error_version : $version;
325
+        $error_message         = $replacement ? sprintf(
326
+            '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.',
327
+            $function,
328
+            $version,
329
+            $replacement
330
+        ) : sprintf(
331
+            '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.',
332
+            $function,
333
+            $version
334
+        );
335 335
 
336
-		do_action( 'deprecated_function_run', $function, $replacement, $version );
336
+        do_action( 'deprecated_function_run', $function, $replacement, $version );
337 337
 
338
-		$log_error = false;
338
+        $log_error = false;
339 339
 
340
-		// If headers have not been sent yet, log to avoid breaking the request.
341
-		if ( ! headers_sent() ) {
342
-			$log_error = true;
343
-		}
340
+        // If headers have not been sent yet, log to avoid breaking the request.
341
+        if ( ! headers_sent() ) {
342
+            $log_error = true;
343
+        }
344 344
 
345
-		// If the $trigger_error_version was not yet reached, only log the error.
346
-		if ( version_compare( $this->package->get_version(), $trigger_error_version, '<' ) ) {
347
-			$log_error = true;
348
-		}
345
+        // If the $trigger_error_version was not yet reached, only log the error.
346
+        if ( version_compare( $this->package->get_version(), $trigger_error_version, '<' ) ) {
347
+            $log_error = true;
348
+        }
349 349
 
350
-		// Apply same filter as WP core.
351
-		if ( ! apply_filters( 'deprecated_function_trigger_error', true ) ) {
352
-			$log_error = true;
353
-		}
350
+        // Apply same filter as WP core.
351
+        if ( ! apply_filters( 'deprecated_function_trigger_error', true ) ) {
352
+            $log_error = true;
353
+        }
354 354
 
355
-		if ( $log_error ) {
356
-			// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
357
-			error_log( $error_message );
358
-		} else {
359
-			// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
360
-			trigger_error( $error_message, E_USER_DEPRECATED );
361
-		}
362
-	}
355
+        if ( $log_error ) {
356
+            // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
357
+            error_log( $error_message );
358
+        } else {
359
+            // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
360
+            trigger_error( $error_message, E_USER_DEPRECATED );
361
+        }
362
+    }
363 363
 
364
-	/**
365
-	 * Register payment method integrations with the container.
366
-	 */
367
-	protected function register_payment_methods() {
368
-		$this->container->register(
369
-			Cheque::class,
370
-			function( Container $container ) {
371
-				$asset_api = $container->get( AssetApi::class );
372
-				return new Cheque( $asset_api );
373
-			}
374
-		);
375
-		$this->container->register(
376
-			PayPal::class,
377
-			function( Container $container ) {
378
-				$asset_api = $container->get( AssetApi::class );
379
-				return new PayPal( $asset_api );
380
-			}
381
-		);
382
-		$this->container->register(
383
-			BankTransfer::class,
384
-			function( Container $container ) {
385
-				$asset_api = $container->get( AssetApi::class );
386
-				return new BankTransfer( $asset_api );
387
-			}
388
-		);
389
-		$this->container->register(
390
-			CashOnDelivery::class,
391
-			function( Container $container ) {
392
-				$asset_api = $container->get( AssetApi::class );
393
-				return new CashOnDelivery( $asset_api );
394
-			}
395
-		);
396
-	}
364
+    /**
365
+     * Register payment method integrations with the container.
366
+     */
367
+    protected function register_payment_methods() {
368
+        $this->container->register(
369
+            Cheque::class,
370
+            function( Container $container ) {
371
+                $asset_api = $container->get( AssetApi::class );
372
+                return new Cheque( $asset_api );
373
+            }
374
+        );
375
+        $this->container->register(
376
+            PayPal::class,
377
+            function( Container $container ) {
378
+                $asset_api = $container->get( AssetApi::class );
379
+                return new PayPal( $asset_api );
380
+            }
381
+        );
382
+        $this->container->register(
383
+            BankTransfer::class,
384
+            function( Container $container ) {
385
+                $asset_api = $container->get( AssetApi::class );
386
+                return new BankTransfer( $asset_api );
387
+            }
388
+        );
389
+        $this->container->register(
390
+            CashOnDelivery::class,
391
+            function( Container $container ) {
392
+                $asset_api = $container->get( AssetApi::class );
393
+                return new CashOnDelivery( $asset_api );
394
+            }
395
+        );
396
+    }
397 397
 }
Please login to merge, or discard this patch.
Spacing   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -51,10 +51,10 @@  discard block
 block discarded – undo
51 51
 	 *
52 52
 	 * @param Container $container  The Dependency Injection Container.
53 53
 	 */
54
-	public function __construct( Container $container ) {
54
+	public function __construct(Container $container) {
55 55
 		$this->container = $container;
56
-		$this->package   = $container->get( Package::class );
57
-		if ( $this->has_core_dependencies() ) {
56
+		$this->package   = $container->get(Package::class);
57
+		if ($this->has_core_dependencies()) {
58 58
 			$this->init();
59 59
 			/**
60 60
 			 * Fires after WooCommerce Blocks plugin has loaded.
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 			 * This hook is intended to be used as a safe event hook for when the plugin has been loaded, and all
63 63
 			 * dependency requirements have been met.
64 64
 			 */
65
-			do_action( 'woocommerce_blocks_loaded' );
65
+			do_action('woocommerce_blocks_loaded');
66 66
 		}
67 67
 	}
68 68
 
@@ -85,22 +85,22 @@  discard block
 block discarded – undo
85 85
 		$is_rest = wc()->is_rest_api_request();
86 86
 
87 87
 		// Load assets in admin and on the frontend.
88
-		if ( ! $is_rest ) {
88
+		if (!$is_rest) {
89 89
 			$this->add_build_notice();
90
-			$this->container->get( AssetDataRegistry::class );
91
-			$this->container->get( Installer::class );
92
-			$this->container->get( AssetsController::class );
90
+			$this->container->get(AssetDataRegistry::class);
91
+			$this->container->get(Installer::class);
92
+			$this->container->get(AssetsController::class);
93 93
 		}
94
-		$this->container->get( DraftOrders::class )->init();
95
-		$this->container->get( CreateAccount::class )->init();
96
-		$this->container->get( StoreApi::class )->init();
97
-		$this->container->get( GoogleAnalytics::class );
98
-		$this->container->get( BlockTypesController::class );
99
-		$this->container->get( BlockTemplatesController::class );
100
-		$this->container->get( ProductSearchResultsTemplate::class );
101
-		$this->container->get( ClassicTemplatesCompatibility::class );
102
-		if ( $this->package->feature()->is_feature_plugin_build() ) {
103
-			$this->container->get( PaymentsApi::class );
94
+		$this->container->get(DraftOrders::class)->init();
95
+		$this->container->get(CreateAccount::class)->init();
96
+		$this->container->get(StoreApi::class)->init();
97
+		$this->container->get(GoogleAnalytics::class);
98
+		$this->container->get(BlockTypesController::class);
99
+		$this->container->get(BlockTemplatesController::class);
100
+		$this->container->get(ProductSearchResultsTemplate::class);
101
+		$this->container->get(ClassicTemplatesCompatibility::class);
102
+		if ($this->package->feature()->is_feature_plugin_build()) {
103
+			$this->container->get(PaymentsApi::class);
104 104
 		}
105 105
 	}
106 106
 
@@ -110,23 +110,23 @@  discard block
 block discarded – undo
110 110
 	 * @return boolean
111 111
 	 */
112 112
 	protected function has_core_dependencies() {
113
-		$has_needed_dependencies = class_exists( 'WooCommerce', false );
114
-		if ( $has_needed_dependencies ) {
113
+		$has_needed_dependencies = class_exists('WooCommerce', false);
114
+		if ($has_needed_dependencies) {
115 115
 			$plugin_data = \get_file_data(
116
-				$this->package->get_path( 'woocommerce-gutenberg-products-block.php' ),
116
+				$this->package->get_path('woocommerce-gutenberg-products-block.php'),
117 117
 				[
118 118
 					'RequiredWCVersion' => 'WC requires at least',
119 119
 				]
120 120
 			);
121
-			if ( isset( $plugin_data['RequiredWCVersion'] ) && version_compare( \WC()->version, $plugin_data['RequiredWCVersion'], '<' ) ) {
121
+			if (isset($plugin_data['RequiredWCVersion']) && version_compare(\WC()->version, $plugin_data['RequiredWCVersion'], '<')) {
122 122
 				$has_needed_dependencies = false;
123 123
 				add_action(
124 124
 					'admin_notices',
125 125
 					function() {
126
-						if ( should_display_compatibility_notices() ) {
126
+						if (should_display_compatibility_notices()) {
127 127
 							?>
128 128
 							<div class="notice notice-error">
129
-								<p><?php esc_html_e( 'The WooCommerce Blocks feature plugin requires a more recent version of WooCommerce and has been paused. Please update WooCommerce to the latest version to continue enjoying WooCommerce Blocks.', 'woocommerce' ); ?></p>
129
+								<p><?php esc_html_e('The WooCommerce Blocks feature plugin requires a more recent version of WooCommerce and has been paused. Please update WooCommerce to the latest version to continue enjoying WooCommerce Blocks.', 'woocommerce'); ?></p>
130 130
 							</div>
131 131
 							<?php
132 132
 						}
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	 */
145 145
 	protected function is_built() {
146 146
 		return file_exists(
147
-			$this->package->get_path( 'build/featured-product.js' )
147
+			$this->package->get_path('build/featured-product.js')
148 148
 		);
149 149
 	}
150 150
 
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	 * Add a notice stating that the build has not been done yet.
153 153
 	 */
154 154
 	protected function add_build_notice() {
155
-		if ( $this->is_built() ) {
155
+		if ($this->is_built()) {
156 156
 			return;
157 157
 		}
158 158
 		add_action(
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 				echo '<div class="error"><p>';
162 162
 				printf(
163 163
 					/* translators: %1$s is the install command, %2$s is the build command, %3$s is the watch command. */
164
-					esc_html__( 'WooCommerce Blocks development mode requires files to be built. From the plugin directory, run %1$s to install dependencies, %2$s to build the files or %3$s to build the files and watch for changes.', 'woocommerce' ),
164
+					esc_html__('WooCommerce Blocks development mode requires files to be built. From the plugin directory, run %1$s to install dependencies, %2$s to build the files or %3$s to build the files and watch for changes.', 'woocommerce'),
165 165
 					'<code>npm install</code>',
166 166
 					'<code>npm run build</code>',
167 167
 					'<code>npm start</code>'
@@ -177,26 +177,26 @@  discard block
 block discarded – undo
177 177
 	protected function register_dependencies() {
178 178
 		$this->container->register(
179 179
 			FeatureGating::class,
180
-			function () {
180
+			function() {
181 181
 				return new FeatureGating();
182 182
 			}
183 183
 		);
184 184
 		$this->container->register(
185 185
 			AssetApi::class,
186
-			function ( Container $container ) {
187
-				return new AssetApi( $container->get( Package::class ) );
186
+			function(Container $container) {
187
+				return new AssetApi($container->get(Package::class));
188 188
 			}
189 189
 		);
190 190
 		$this->container->register(
191 191
 			AssetDataRegistry::class,
192
-			function( Container $container ) {
193
-				return new AssetDataRegistry( $container->get( AssetApi::class ) );
192
+			function(Container $container) {
193
+				return new AssetDataRegistry($container->get(AssetApi::class));
194 194
 			}
195 195
 		);
196 196
 		$this->container->register(
197 197
 			AssetsController::class,
198
-			function( Container $container ) {
199
-				return new AssetsController( $container->get( AssetApi::class ) );
198
+			function(Container $container) {
199
+				return new AssetsController($container->get(AssetApi::class));
200 200
 			}
201 201
 		);
202 202
 		$this->container->register(
@@ -207,103 +207,103 @@  discard block
 block discarded – undo
207 207
 		);
208 208
 		$this->container->register(
209 209
 			Installer::class,
210
-			function () {
210
+			function() {
211 211
 				return new Installer();
212 212
 			}
213 213
 		);
214 214
 		$this->container->register(
215 215
 			BlockTypesController::class,
216
-			function ( Container $container ) {
217
-				$asset_api           = $container->get( AssetApi::class );
218
-				$asset_data_registry = $container->get( AssetDataRegistry::class );
219
-				return new BlockTypesController( $asset_api, $asset_data_registry );
216
+			function(Container $container) {
217
+				$asset_api           = $container->get(AssetApi::class);
218
+				$asset_data_registry = $container->get(AssetDataRegistry::class);
219
+				return new BlockTypesController($asset_api, $asset_data_registry);
220 220
 			}
221 221
 		);
222 222
 		$this->container->register(
223 223
 			BlockTemplatesController::class,
224
-			function () {
224
+			function() {
225 225
 				return new BlockTemplatesController();
226 226
 			}
227 227
 		);
228 228
 		$this->container->register(
229 229
 			ProductSearchResultsTemplate::class,
230
-			function () {
230
+			function() {
231 231
 				return new ProductSearchResultsTemplate();
232 232
 			}
233 233
 		);
234 234
 		$this->container->register(
235 235
 			ClassicTemplatesCompatibility::class,
236
-			function ( Container $container ) {
237
-				$asset_data_registry = $container->get( AssetDataRegistry::class );
238
-				return new ClassicTemplatesCompatibility( $asset_data_registry );
236
+			function(Container $container) {
237
+				$asset_data_registry = $container->get(AssetDataRegistry::class);
238
+				return new ClassicTemplatesCompatibility($asset_data_registry);
239 239
 			}
240 240
 		);
241 241
 		$this->container->register(
242 242
 			DraftOrders::class,
243
-			function( Container $container ) {
244
-				return new DraftOrders( $container->get( Package::class ) );
243
+			function(Container $container) {
244
+				return new DraftOrders($container->get(Package::class));
245 245
 			}
246 246
 		);
247 247
 		$this->container->register(
248 248
 			CreateAccount::class,
249
-			function( Container $container ) {
250
-				return new CreateAccount( $container->get( Package::class ) );
249
+			function(Container $container) {
250
+				return new CreateAccount($container->get(Package::class));
251 251
 			}
252 252
 		);
253 253
 		$this->container->register(
254 254
 			GoogleAnalytics::class,
255
-			function( Container $container ) {
255
+			function(Container $container) {
256 256
 				// Require Google Analytics Integration to be activated.
257
-				if ( ! class_exists( 'WC_Google_Analytics_Integration', false ) ) {
257
+				if (!class_exists('WC_Google_Analytics_Integration', false)) {
258 258
 					return;
259 259
 				}
260
-				$asset_api = $container->get( AssetApi::class );
261
-				return new GoogleAnalytics( $asset_api );
260
+				$asset_api = $container->get(AssetApi::class);
261
+				return new GoogleAnalytics($asset_api);
262 262
 			}
263 263
 		);
264
-		if ( $this->package->feature()->is_feature_plugin_build() ) {
264
+		if ($this->package->feature()->is_feature_plugin_build()) {
265 265
 			$this->container->register(
266 266
 				PaymentsApi::class,
267
-				function ( Container $container ) {
268
-					$payment_method_registry = $container->get( PaymentMethodRegistry::class );
269
-					$asset_data_registry     = $container->get( AssetDataRegistry::class );
270
-					return new PaymentsApi( $payment_method_registry, $asset_data_registry );
267
+				function(Container $container) {
268
+					$payment_method_registry = $container->get(PaymentMethodRegistry::class);
269
+					$asset_data_registry     = $container->get(AssetDataRegistry::class);
270
+					return new PaymentsApi($payment_method_registry, $asset_data_registry);
271 271
 				}
272 272
 			);
273 273
 		}
274 274
 		$this->container->register(
275 275
 			StoreApi::class,
276
-			function () {
276
+			function() {
277 277
 				return new StoreApi();
278 278
 			}
279 279
 		);
280 280
 		// Maintains backwards compatibility with previous Store API namespace.
281 281
 		$this->container->register(
282 282
 			'Automattic\WooCommerce\Blocks\StoreApi\Formatters',
283
-			function( Container $container ) {
284
-				$this->deprecated_dependency( 'Automattic\WooCommerce\Blocks\StoreApi\Formatters', '7.2.0', 'Automattic\WooCommerce\StoreApi\Formatters', '7.4.0' );
285
-				return $container->get( StoreApi::class )::container()->get( \Automattic\WooCommerce\StoreApi\Formatters::class );
283
+			function(Container $container) {
284
+				$this->deprecated_dependency('Automattic\WooCommerce\Blocks\StoreApi\Formatters', '7.2.0', 'Automattic\WooCommerce\StoreApi\Formatters', '7.4.0');
285
+				return $container->get(StoreApi::class)::container()->get(\Automattic\WooCommerce\StoreApi\Formatters::class);
286 286
 			}
287 287
 		);
288 288
 		$this->container->register(
289 289
 			'Automattic\WooCommerce\Blocks\Domain\Services\ExtendRestApi',
290
-			function( Container $container ) {
291
-				$this->deprecated_dependency( 'Automattic\WooCommerce\Blocks\Domain\Services\ExtendRestApi', '7.2.0', 'Automattic\WooCommerce\StoreApi\Schemas\ExtendSchema', '7.4.0' );
292
-				return $container->get( StoreApi::class )::container()->get( \Automattic\WooCommerce\StoreApi\Schemas\ExtendSchema::class );
290
+			function(Container $container) {
291
+				$this->deprecated_dependency('Automattic\WooCommerce\Blocks\Domain\Services\ExtendRestApi', '7.2.0', 'Automattic\WooCommerce\StoreApi\Schemas\ExtendSchema', '7.4.0');
292
+				return $container->get(StoreApi::class)::container()->get(\Automattic\WooCommerce\StoreApi\Schemas\ExtendSchema::class);
293 293
 			}
294 294
 		);
295 295
 		$this->container->register(
296 296
 			'Automattic\WooCommerce\Blocks\StoreApi\SchemaController',
297
-			function( Container $container ) {
298
-				$this->deprecated_dependency( 'Automattic\WooCommerce\Blocks\StoreApi\SchemaController', '7.2.0', 'Automattic\WooCommerce\StoreApi\SchemaController', '7.4.0' );
299
-				return $container->get( StoreApi::class )::container()->get( SchemaController::class );
297
+			function(Container $container) {
298
+				$this->deprecated_dependency('Automattic\WooCommerce\Blocks\StoreApi\SchemaController', '7.2.0', 'Automattic\WooCommerce\StoreApi\SchemaController', '7.4.0');
299
+				return $container->get(StoreApi::class)::container()->get(SchemaController::class);
300 300
 			}
301 301
 		);
302 302
 		$this->container->register(
303 303
 			'Automattic\WooCommerce\Blocks\StoreApi\RoutesController',
304
-			function( Container $container ) {
305
-				$this->deprecated_dependency( 'Automattic\WooCommerce\Blocks\StoreApi\RoutesController', '7.2.0', 'Automattic\WooCommerce\StoreApi\RoutesController', '7.4.0' );
306
-				return $container->get( StoreApi::class )::container()->get( RoutesController::class );
304
+			function(Container $container) {
305
+				$this->deprecated_dependency('Automattic\WooCommerce\Blocks\StoreApi\RoutesController', '7.2.0', 'Automattic\WooCommerce\StoreApi\RoutesController', '7.4.0');
306
+				return $container->get(StoreApi::class)::container()->get(RoutesController::class);
307 307
 			}
308 308
 		);
309 309
 	}
@@ -316,8 +316,8 @@  discard block
 block discarded – undo
316 316
 	 * @param string $replacement Replacement class or function, if applicable.
317 317
 	 * @param string $trigger_error_version Optional version to start surfacing this as a PHP error rather than a log. Defaults to $version.
318 318
 	 */
319
-	protected function deprecated_dependency( $function, $version, $replacement = '', $trigger_error_version = '' ) {
320
-		if ( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) {
319
+	protected function deprecated_dependency($function, $version, $replacement = '', $trigger_error_version = '') {
320
+		if (!defined('WP_DEBUG') || !WP_DEBUG) {
321 321
 			return;
322 322
 		}
323 323
 
@@ -333,31 +333,31 @@  discard block
 block discarded – undo
333 333
 			$version
334 334
 		);
335 335
 
336
-		do_action( 'deprecated_function_run', $function, $replacement, $version );
336
+		do_action('deprecated_function_run', $function, $replacement, $version);
337 337
 
338 338
 		$log_error = false;
339 339
 
340 340
 		// If headers have not been sent yet, log to avoid breaking the request.
341
-		if ( ! headers_sent() ) {
341
+		if (!headers_sent()) {
342 342
 			$log_error = true;
343 343
 		}
344 344
 
345 345
 		// If the $trigger_error_version was not yet reached, only log the error.
346
-		if ( version_compare( $this->package->get_version(), $trigger_error_version, '<' ) ) {
346
+		if (version_compare($this->package->get_version(), $trigger_error_version, '<')) {
347 347
 			$log_error = true;
348 348
 		}
349 349
 
350 350
 		// Apply same filter as WP core.
351
-		if ( ! apply_filters( 'deprecated_function_trigger_error', true ) ) {
351
+		if (!apply_filters('deprecated_function_trigger_error', true)) {
352 352
 			$log_error = true;
353 353
 		}
354 354
 
355
-		if ( $log_error ) {
355
+		if ($log_error) {
356 356
 			// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
357
-			error_log( $error_message );
357
+			error_log($error_message);
358 358
 		} else {
359 359
 			// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
360
-			trigger_error( $error_message, E_USER_DEPRECATED );
360
+			trigger_error($error_message, E_USER_DEPRECATED);
361 361
 		}
362 362
 	}
363 363
 
@@ -367,30 +367,30 @@  discard block
 block discarded – undo
367 367
 	protected function register_payment_methods() {
368 368
 		$this->container->register(
369 369
 			Cheque::class,
370
-			function( Container $container ) {
371
-				$asset_api = $container->get( AssetApi::class );
372
-				return new Cheque( $asset_api );
370
+			function(Container $container) {
371
+				$asset_api = $container->get(AssetApi::class);
372
+				return new Cheque($asset_api);
373 373
 			}
374 374
 		);
375 375
 		$this->container->register(
376 376
 			PayPal::class,
377
-			function( Container $container ) {
378
-				$asset_api = $container->get( AssetApi::class );
379
-				return new PayPal( $asset_api );
377
+			function(Container $container) {
378
+				$asset_api = $container->get(AssetApi::class);
379
+				return new PayPal($asset_api);
380 380
 			}
381 381
 		);
382 382
 		$this->container->register(
383 383
 			BankTransfer::class,
384
-			function( Container $container ) {
385
-				$asset_api = $container->get( AssetApi::class );
386
-				return new BankTransfer( $asset_api );
384
+			function(Container $container) {
385
+				$asset_api = $container->get(AssetApi::class);
386
+				return new BankTransfer($asset_api);
387 387
 			}
388 388
 		);
389 389
 		$this->container->register(
390 390
 			CashOnDelivery::class,
391
-			function( Container $container ) {
392
-				$asset_api = $container->get( AssetApi::class );
393
-				return new CashOnDelivery( $asset_api );
391
+			function(Container $container) {
392
+				$asset_api = $container->get(AssetApi::class);
393
+				return new CashOnDelivery($asset_api);
394 394
 			}
395 395
 		);
396 396
 	}
Please login to merge, or discard this patch.
packages/woocommerce-blocks/src/Payments/Integrations/Cheque.php 2 patches
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -10,68 +10,68 @@
 block discarded – undo
10 10
  * @since 2.6.0
11 11
  */
12 12
 final class Cheque extends AbstractPaymentMethodType {
13
-	/**
14
-	 * Payment method name defined by payment methods extending this class.
15
-	 *
16
-	 * @var string
17
-	 */
18
-	protected $name = 'cheque';
13
+    /**
14
+     * Payment method name defined by payment methods extending this class.
15
+     *
16
+     * @var string
17
+     */
18
+    protected $name = 'cheque';
19 19
 
20
-	/**
21
-	 * An instance of the Asset Api
22
-	 *
23
-	 * @var Api
24
-	 */
25
-	private $asset_api;
20
+    /**
21
+     * An instance of the Asset Api
22
+     *
23
+     * @var Api
24
+     */
25
+    private $asset_api;
26 26
 
27
-	/**
28
-	 * Constructor
29
-	 *
30
-	 * @param Api $asset_api An instance of Api.
31
-	 */
32
-	public function __construct( Api $asset_api ) {
33
-		$this->asset_api = $asset_api;
34
-	}
27
+    /**
28
+     * Constructor
29
+     *
30
+     * @param Api $asset_api An instance of Api.
31
+     */
32
+    public function __construct( Api $asset_api ) {
33
+        $this->asset_api = $asset_api;
34
+    }
35 35
 
36
-	/**
37
-	 * Initializes the payment method type.
38
-	 */
39
-	public function initialize() {
40
-		$this->settings = get_option( 'woocommerce_cheque_settings', [] );
41
-	}
36
+    /**
37
+     * Initializes the payment method type.
38
+     */
39
+    public function initialize() {
40
+        $this->settings = get_option( 'woocommerce_cheque_settings', [] );
41
+    }
42 42
 
43
-	/**
44
-	 * Returns if this payment method should be active. If false, the scripts will not be enqueued.
45
-	 *
46
-	 * @return boolean
47
-	 */
48
-	public function is_active() {
49
-		return filter_var( $this->get_setting( 'enabled', false ), FILTER_VALIDATE_BOOLEAN );
50
-	}
43
+    /**
44
+     * Returns if this payment method should be active. If false, the scripts will not be enqueued.
45
+     *
46
+     * @return boolean
47
+     */
48
+    public function is_active() {
49
+        return filter_var( $this->get_setting( 'enabled', false ), FILTER_VALIDATE_BOOLEAN );
50
+    }
51 51
 
52
-	/**
53
-	 * Returns an array of scripts/handles to be registered for this payment method.
54
-	 *
55
-	 * @return array
56
-	 */
57
-	public function get_payment_method_script_handles() {
58
-		$this->asset_api->register_script(
59
-			'wc-payment-method-cheque',
60
-			'build/wc-payment-method-cheque.js'
61
-		);
62
-		return [ 'wc-payment-method-cheque' ];
63
-	}
52
+    /**
53
+     * Returns an array of scripts/handles to be registered for this payment method.
54
+     *
55
+     * @return array
56
+     */
57
+    public function get_payment_method_script_handles() {
58
+        $this->asset_api->register_script(
59
+            'wc-payment-method-cheque',
60
+            'build/wc-payment-method-cheque.js'
61
+        );
62
+        return [ 'wc-payment-method-cheque' ];
63
+    }
64 64
 
65
-	/**
66
-	 * Returns an array of key=>value pairs of data made available to the payment methods script.
67
-	 *
68
-	 * @return array
69
-	 */
70
-	public function get_payment_method_data() {
71
-		return [
72
-			'title'       => $this->get_setting( 'title' ),
73
-			'description' => $this->get_setting( 'description' ),
74
-			'supports'    => $this->get_supported_features(),
75
-		];
76
-	}
65
+    /**
66
+     * Returns an array of key=>value pairs of data made available to the payment methods script.
67
+     *
68
+     * @return array
69
+     */
70
+    public function get_payment_method_data() {
71
+        return [
72
+            'title'       => $this->get_setting( 'title' ),
73
+            'description' => $this->get_setting( 'description' ),
74
+            'supports'    => $this->get_supported_features(),
75
+        ];
76
+    }
77 77
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 *
30 30
 	 * @param Api $asset_api An instance of Api.
31 31
 	 */
32
-	public function __construct( Api $asset_api ) {
32
+	public function __construct(Api $asset_api) {
33 33
 		$this->asset_api = $asset_api;
34 34
 	}
35 35
 
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 * Initializes the payment method type.
38 38
 	 */
39 39
 	public function initialize() {
40
-		$this->settings = get_option( 'woocommerce_cheque_settings', [] );
40
+		$this->settings = get_option('woocommerce_cheque_settings', []);
41 41
 	}
42 42
 
43 43
 	/**
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	 * @return boolean
47 47
 	 */
48 48
 	public function is_active() {
49
-		return filter_var( $this->get_setting( 'enabled', false ), FILTER_VALIDATE_BOOLEAN );
49
+		return filter_var($this->get_setting('enabled', false), FILTER_VALIDATE_BOOLEAN);
50 50
 	}
51 51
 
52 52
 	/**
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 			'wc-payment-method-cheque',
60 60
 			'build/wc-payment-method-cheque.js'
61 61
 		);
62
-		return [ 'wc-payment-method-cheque' ];
62
+		return ['wc-payment-method-cheque'];
63 63
 	}
64 64
 
65 65
 	/**
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	public function get_payment_method_data() {
71 71
 		return [
72
-			'title'       => $this->get_setting( 'title' ),
73
-			'description' => $this->get_setting( 'description' ),
72
+			'title'       => $this->get_setting('title'),
73
+			'description' => $this->get_setting('description'),
74 74
 			'supports'    => $this->get_supported_features(),
75 75
 		];
76 76
 	}
Please login to merge, or discard this patch.
woocommerce-blocks/src/Payments/Integrations/AbstractPaymentMethodType.php 2 patches
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -9,116 +9,116 @@
 block discarded – undo
9 9
  * @since 2.6.0
10 10
  */
11 11
 abstract class AbstractPaymentMethodType implements PaymentMethodTypeInterface {
12
-	/**
13
-	 * Payment method name defined by payment methods extending this class.
14
-	 *
15
-	 * @var string
16
-	 */
17
-	protected $name = '';
12
+    /**
13
+     * Payment method name defined by payment methods extending this class.
14
+     *
15
+     * @var string
16
+     */
17
+    protected $name = '';
18 18
 
19
-	/**
20
-	 * Settings from the WP options table
21
-	 *
22
-	 * @var array
23
-	 */
24
-	protected $settings = [];
19
+    /**
20
+     * Settings from the WP options table
21
+     *
22
+     * @var array
23
+     */
24
+    protected $settings = [];
25 25
 
26
-	/**
27
-	 * Get a setting from the settings array if set.
28
-	 *
29
-	 * @param string $name Setting name.
30
-	 * @param mixed  $default Value that is returned if the setting does not exist.
31
-	 * @return mixed
32
-	 */
33
-	protected function get_setting( $name, $default = '' ) {
34
-		return isset( $this->settings[ $name ] ) ? $this->settings[ $name ] : $default;
35
-	}
26
+    /**
27
+     * Get a setting from the settings array if set.
28
+     *
29
+     * @param string $name Setting name.
30
+     * @param mixed  $default Value that is returned if the setting does not exist.
31
+     * @return mixed
32
+     */
33
+    protected function get_setting( $name, $default = '' ) {
34
+        return isset( $this->settings[ $name ] ) ? $this->settings[ $name ] : $default;
35
+    }
36 36
 
37
-	/**
38
-	 * Returns the name of the payment method.
39
-	 */
40
-	public function get_name() {
41
-		return $this->name;
42
-	}
37
+    /**
38
+     * Returns the name of the payment method.
39
+     */
40
+    public function get_name() {
41
+        return $this->name;
42
+    }
43 43
 
44
-	/**
45
-	 * Returns if this payment method should be active. If false, the scripts will not be enqueued.
46
-	 *
47
-	 * @return boolean
48
-	 */
49
-	public function is_active() {
50
-		return true;
51
-	}
44
+    /**
45
+     * Returns if this payment method should be active. If false, the scripts will not be enqueued.
46
+     *
47
+     * @return boolean
48
+     */
49
+    public function is_active() {
50
+        return true;
51
+    }
52 52
 
53
-	/**
54
-	 * Returns an array of script handles to enqueue for this payment method in
55
-	 * the frontend context
56
-	 *
57
-	 * @return string[]
58
-	 */
59
-	public function get_payment_method_script_handles() {
60
-		return [];
61
-	}
53
+    /**
54
+     * Returns an array of script handles to enqueue for this payment method in
55
+     * the frontend context
56
+     *
57
+     * @return string[]
58
+     */
59
+    public function get_payment_method_script_handles() {
60
+        return [];
61
+    }
62 62
 
63
-	/**
64
-	 * Returns an array of script handles to enqueue for this payment method in
65
-	 * the admin context
66
-	 *
67
-	 * @return string[]
68
-	 */
69
-	public function get_payment_method_script_handles_for_admin() {
70
-		return $this->get_payment_method_script_handles();
71
-	}
63
+    /**
64
+     * Returns an array of script handles to enqueue for this payment method in
65
+     * the admin context
66
+     *
67
+     * @return string[]
68
+     */
69
+    public function get_payment_method_script_handles_for_admin() {
70
+        return $this->get_payment_method_script_handles();
71
+    }
72 72
 
73
-	/**
74
-	 * Returns an array of supported features.
75
-	 *
76
-	 * @return string[]
77
-	 */
78
-	public function get_supported_features() {
79
-		return [ 'products' ];
80
-	}
73
+    /**
74
+     * Returns an array of supported features.
75
+     *
76
+     * @return string[]
77
+     */
78
+    public function get_supported_features() {
79
+        return [ 'products' ];
80
+    }
81 81
 
82
-	/**
83
-	 * An array of key, value pairs of data made available to payment methods
84
-	 * client side.
85
-	 *
86
-	 * @return array
87
-	 */
88
-	public function get_payment_method_data() {
89
-		return [];
90
-	}
82
+    /**
83
+     * An array of key, value pairs of data made available to payment methods
84
+     * client side.
85
+     *
86
+     * @return array
87
+     */
88
+    public function get_payment_method_data() {
89
+        return [];
90
+    }
91 91
 
92
-	/**
93
-	 * Returns an array of script handles to enqueue in the frontend context.
94
-	 *
95
-	 * Alias of get_payment_method_script_handles. Defined by IntegrationInterface.
96
-	 *
97
-	 * @return string[]
98
-	 */
99
-	public function get_script_handles() {
100
-		return $this->get_payment_method_script_handles();
101
-	}
92
+    /**
93
+     * Returns an array of script handles to enqueue in the frontend context.
94
+     *
95
+     * Alias of get_payment_method_script_handles. Defined by IntegrationInterface.
96
+     *
97
+     * @return string[]
98
+     */
99
+    public function get_script_handles() {
100
+        return $this->get_payment_method_script_handles();
101
+    }
102 102
 
103
-	/**
104
-	 * Returns an array of script handles to enqueue in the admin context.
105
-	 *
106
-	 * Alias of get_payment_method_script_handles_for_admin. Defined by IntegrationInterface.
107
-	 *
108
-	 * @return string[]
109
-	 */
110
-	public function get_editor_script_handles() {
111
-		return $this->get_payment_method_script_handles_for_admin();
112
-	}
103
+    /**
104
+     * Returns an array of script handles to enqueue in the admin context.
105
+     *
106
+     * Alias of get_payment_method_script_handles_for_admin. Defined by IntegrationInterface.
107
+     *
108
+     * @return string[]
109
+     */
110
+    public function get_editor_script_handles() {
111
+        return $this->get_payment_method_script_handles_for_admin();
112
+    }
113 113
 
114
-	/**
115
-	 * An array of key, value pairs of data made available to the block on the client side.
116
-	 *
117
-	 * Alias of get_payment_method_data. Defined by IntegrationInterface.
118
-	 *
119
-	 * @return array
120
-	 */
121
-	public function get_script_data() {
122
-		return $this->get_payment_method_data();
123
-	}
114
+    /**
115
+     * An array of key, value pairs of data made available to the block on the client side.
116
+     *
117
+     * Alias of get_payment_method_data. Defined by IntegrationInterface.
118
+     *
119
+     * @return array
120
+     */
121
+    public function get_script_data() {
122
+        return $this->get_payment_method_data();
123
+    }
124 124
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
 	 * @param mixed  $default Value that is returned if the setting does not exist.
31 31
 	 * @return mixed
32 32
 	 */
33
-	protected function get_setting( $name, $default = '' ) {
34
-		return isset( $this->settings[ $name ] ) ? $this->settings[ $name ] : $default;
33
+	protected function get_setting($name, $default = '') {
34
+		return isset($this->settings[$name]) ? $this->settings[$name] : $default;
35 35
 	}
36 36
 
37 37
 	/**
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 * @return string[]
77 77
 	 */
78 78
 	public function get_supported_features() {
79
-		return [ 'products' ];
79
+		return ['products'];
80 80
 	}
81 81
 
82 82
 	/**
Please login to merge, or discard this patch.