Passed
Push — main ( aaef5c...e4c121 )
by TARIQ
71:39
created
plugins/woocommerce/includes/admin/class-wc-admin-dashboard-setup.php 2 patches
Indentation   +180 added lines, -180 removed lines patch added patch discarded remove patch
@@ -11,190 +11,190 @@
 block discarded – undo
11 11
 use Automattic\WooCommerce\Admin\Features\OnboardingTasks\TaskLists;
12 12
 
13 13
 if ( ! defined( 'ABSPATH' ) ) {
14
-	exit; // Exit if accessed directly.
14
+    exit; // Exit if accessed directly.
15 15
 }
16 16
 
17 17
 if ( ! class_exists( 'WC_Admin_Dashboard_Setup', false ) ) :
18 18
 
19
-	/**
20
-	 * WC_Admin_Dashboard_Setup Class.
21
-	 */
22
-	class WC_Admin_Dashboard_Setup {
23
-
24
-		/**
25
-		 * Check for task list initialization.
26
-		 */
27
-		private $initalized = false;
28
-
29
-		/**
30
-		 * The task list.
31
-		 */
32
-		private $task_list = null;
33
-
34
-		/**
35
-		 * The tasks.
36
-		 */
37
-		private $tasks = null;
38
-
39
-		/**
40
-		 * # of completed tasks.
41
-		 *
42
-		 * @var int
43
-		 */
44
-		private $completed_tasks_count = 0;
45
-
46
-		/**
47
-		 * WC_Admin_Dashboard_Setup constructor.
48
-		 */
49
-		public function __construct() {
50
-			if ( $this->should_display_widget() ) {
51
-				add_meta_box(
52
-					'wc_admin_dashboard_setup',
53
-					__( 'WooCommerce Setup', 'woocommerce' ),
54
-					array( $this, 'render' ),
55
-					'dashboard',
56
-					'normal',
57
-					'high'
58
-				);
59
-			}
60
-		}
61
-
62
-		/**
63
-		 * Render meta box output.
64
-		 */
65
-		public function render() {
66
-			$version = Constants::get_constant( 'WC_VERSION' );
67
-			wp_enqueue_style( 'wc-dashboard-setup', WC()->plugin_url() . '/assets/css/dashboard-setup.css', array(), $version );
68
-
69
-			$task = $this->get_next_task();
70
-			if ( ! $task ) {
71
-				return;
72
-			}
73
-
74
-			$button_link           = $this->get_button_link( $task );
75
-			$completed_tasks_count = $this->get_completed_tasks_count();
76
-			$step_number           = $this->get_completed_tasks_count() + 1;
77
-			$tasks_count           = count( $this->get_tasks() );
78
-
79
-			// Given 'r' (circle element's r attr), dashoffset = ((100-$desired_percentage)/100) * PI * (r*2).
80
-			$progress_percentage = ( $completed_tasks_count / $tasks_count ) * 100;
81
-			$circle_r            = 6.5;
82
-			$circle_dashoffset   = ( ( 100 - $progress_percentage ) / 100 ) * ( pi() * ( $circle_r * 2 ) );
83
-
84
-			include __DIR__ . '/views/html-admin-dashboard-setup.php';
85
-		}
86
-
87
-		/**
88
-		 * Get the button link for a given task.
89
-		 *
90
-		 * @param Task $task Task.
91
-		 * @return string
92
-		 */
93
-		public function get_button_link( $task ) {
94
-			$url = $task->get_json()['actionUrl'];
95
-
96
-			if ( substr( $url, 0, 4 ) === 'http' ) {
97
-				return $url;
98
-			} elseif ( $url ) {
99
-				return wc_admin_url( '&path=' . $url );
100
-			}
101
-
102
-			return admin_url( 'admin.php?page=wc-admin&task=' . $task->get_id() );
103
-		}
104
-
105
-		/**
106
-		 * Get the task list.
107
-		 *
108
-		 * @return array
109
-		 */
110
-		public function get_task_list() {
111
-			if ( $this->task_list || $this->initalized ) {
112
-				return $this->task_list;
113
-			}
114
-
115
-			$this->set_task_list( TaskLists::get_list( 'setup' ) );
116
-			$this->initalized = true;
117
-			return $this->task_list;
118
-		}
119
-
120
-		/**
121
-		 * Set the task list.
122
-		 */
123
-		public function set_task_list( $task_list ) {
124
-			return $this->task_list = $task_list;
125
-		}
126
-
127
-		/**
128
-		 * Get the tasks.
129
-		 *
130
-		 * @return array
131
-		 */
132
-		public function get_tasks() {
133
-			if ( $this->tasks ) {
134
-				return $this->tasks;
135
-			}
136
-
137
-			$this->tasks = $this->get_task_list()->get_viewable_tasks();
138
-			return $this->tasks;
139
-		}
140
-
141
-		/**
142
-		 * Return # of completed tasks
143
-		 *
144
-		 * @return integer
145
-		 */
146
-		public function get_completed_tasks_count() {
147
-			$completed_tasks = array_filter(
148
-				$this->get_tasks(),
149
-				function( $task ) {
150
-					return $task->is_complete();
151
-				}
152
-			);
153
-
154
-			return count( $completed_tasks );
155
-		}
156
-
157
-		/**
158
-		 * Get the next task.
159
-		 *
160
-		 * @return array|null
161
-		 */
162
-		private function get_next_task() {
163
-			foreach ( $this->get_tasks() as $task ) {
164
-				if ( false === $task->is_complete() ) {
165
-					return $task;
166
-				}
167
-			}
168
-
169
-			return null;
170
-		}
171
-
172
-		/**
173
-		 * Check to see if we should display the widget
174
-		 *
175
-		 * @return bool
176
-		 */
177
-		public function should_display_widget() {
178
-			if ( ! class_exists( 'Automattic\WooCommerce\Admin\Features\Features' ) || ! class_exists( 'Automattic\WooCommerce\Admin\Features\OnboardingTasks\TaskLists' ) ) {
179
-				return false;
180
-			}
181
-
182
-			if ( ! Features::is_enabled( 'onboarding' ) || ! WC()->is_wc_admin_active() ) {
183
-				return false;
184
-			}
185
-
186
-			if ( ! current_user_can( 'manage_woocommerce' ) ) {
187
-				return false;
188
-			}
189
-
190
-			if ( ! $this->get_task_list() || $this->get_task_list()->is_complete() || $this->get_task_list()->is_hidden() ) {
191
-				return false;
192
-			}
193
-
194
-			return true;
195
-		}
196
-
197
-	}
19
+    /**
20
+     * WC_Admin_Dashboard_Setup Class.
21
+     */
22
+    class WC_Admin_Dashboard_Setup {
23
+
24
+        /**
25
+         * Check for task list initialization.
26
+         */
27
+        private $initalized = false;
28
+
29
+        /**
30
+         * The task list.
31
+         */
32
+        private $task_list = null;
33
+
34
+        /**
35
+         * The tasks.
36
+         */
37
+        private $tasks = null;
38
+
39
+        /**
40
+         * # of completed tasks.
41
+         *
42
+         * @var int
43
+         */
44
+        private $completed_tasks_count = 0;
45
+
46
+        /**
47
+         * WC_Admin_Dashboard_Setup constructor.
48
+         */
49
+        public function __construct() {
50
+            if ( $this->should_display_widget() ) {
51
+                add_meta_box(
52
+                    'wc_admin_dashboard_setup',
53
+                    __( 'WooCommerce Setup', 'woocommerce' ),
54
+                    array( $this, 'render' ),
55
+                    'dashboard',
56
+                    'normal',
57
+                    'high'
58
+                );
59
+            }
60
+        }
61
+
62
+        /**
63
+         * Render meta box output.
64
+         */
65
+        public function render() {
66
+            $version = Constants::get_constant( 'WC_VERSION' );
67
+            wp_enqueue_style( 'wc-dashboard-setup', WC()->plugin_url() . '/assets/css/dashboard-setup.css', array(), $version );
68
+
69
+            $task = $this->get_next_task();
70
+            if ( ! $task ) {
71
+                return;
72
+            }
73
+
74
+            $button_link           = $this->get_button_link( $task );
75
+            $completed_tasks_count = $this->get_completed_tasks_count();
76
+            $step_number           = $this->get_completed_tasks_count() + 1;
77
+            $tasks_count           = count( $this->get_tasks() );
78
+
79
+            // Given 'r' (circle element's r attr), dashoffset = ((100-$desired_percentage)/100) * PI * (r*2).
80
+            $progress_percentage = ( $completed_tasks_count / $tasks_count ) * 100;
81
+            $circle_r            = 6.5;
82
+            $circle_dashoffset   = ( ( 100 - $progress_percentage ) / 100 ) * ( pi() * ( $circle_r * 2 ) );
83
+
84
+            include __DIR__ . '/views/html-admin-dashboard-setup.php';
85
+        }
86
+
87
+        /**
88
+         * Get the button link for a given task.
89
+         *
90
+         * @param Task $task Task.
91
+         * @return string
92
+         */
93
+        public function get_button_link( $task ) {
94
+            $url = $task->get_json()['actionUrl'];
95
+
96
+            if ( substr( $url, 0, 4 ) === 'http' ) {
97
+                return $url;
98
+            } elseif ( $url ) {
99
+                return wc_admin_url( '&path=' . $url );
100
+            }
101
+
102
+            return admin_url( 'admin.php?page=wc-admin&task=' . $task->get_id() );
103
+        }
104
+
105
+        /**
106
+         * Get the task list.
107
+         *
108
+         * @return array
109
+         */
110
+        public function get_task_list() {
111
+            if ( $this->task_list || $this->initalized ) {
112
+                return $this->task_list;
113
+            }
114
+
115
+            $this->set_task_list( TaskLists::get_list( 'setup' ) );
116
+            $this->initalized = true;
117
+            return $this->task_list;
118
+        }
119
+
120
+        /**
121
+         * Set the task list.
122
+         */
123
+        public function set_task_list( $task_list ) {
124
+            return $this->task_list = $task_list;
125
+        }
126
+
127
+        /**
128
+         * Get the tasks.
129
+         *
130
+         * @return array
131
+         */
132
+        public function get_tasks() {
133
+            if ( $this->tasks ) {
134
+                return $this->tasks;
135
+            }
136
+
137
+            $this->tasks = $this->get_task_list()->get_viewable_tasks();
138
+            return $this->tasks;
139
+        }
140
+
141
+        /**
142
+         * Return # of completed tasks
143
+         *
144
+         * @return integer
145
+         */
146
+        public function get_completed_tasks_count() {
147
+            $completed_tasks = array_filter(
148
+                $this->get_tasks(),
149
+                function( $task ) {
150
+                    return $task->is_complete();
151
+                }
152
+            );
153
+
154
+            return count( $completed_tasks );
155
+        }
156
+
157
+        /**
158
+         * Get the next task.
159
+         *
160
+         * @return array|null
161
+         */
162
+        private function get_next_task() {
163
+            foreach ( $this->get_tasks() as $task ) {
164
+                if ( false === $task->is_complete() ) {
165
+                    return $task;
166
+                }
167
+            }
168
+
169
+            return null;
170
+        }
171
+
172
+        /**
173
+         * Check to see if we should display the widget
174
+         *
175
+         * @return bool
176
+         */
177
+        public function should_display_widget() {
178
+            if ( ! class_exists( 'Automattic\WooCommerce\Admin\Features\Features' ) || ! class_exists( 'Automattic\WooCommerce\Admin\Features\OnboardingTasks\TaskLists' ) ) {
179
+                return false;
180
+            }
181
+
182
+            if ( ! Features::is_enabled( 'onboarding' ) || ! WC()->is_wc_admin_active() ) {
183
+                return false;
184
+            }
185
+
186
+            if ( ! current_user_can( 'manage_woocommerce' ) ) {
187
+                return false;
188
+            }
189
+
190
+            if ( ! $this->get_task_list() || $this->get_task_list()->is_complete() || $this->get_task_list()->is_hidden() ) {
191
+                return false;
192
+            }
193
+
194
+            return true;
195
+        }
196
+
197
+    }
198 198
 
199 199
 endif;
200 200
 
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -10,11 +10,11 @@  discard block
 block discarded – undo
10 10
 use Automattic\WooCommerce\Admin\Features\Features;
11 11
 use Automattic\WooCommerce\Admin\Features\OnboardingTasks\TaskLists;
12 12
 
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if (!defined('ABSPATH')) {
14 14
 	exit; // Exit if accessed directly.
15 15
 }
16 16
 
17
-if ( ! class_exists( 'WC_Admin_Dashboard_Setup', false ) ) :
17
+if (!class_exists('WC_Admin_Dashboard_Setup', false)) :
18 18
 
19 19
 	/**
20 20
 	 * WC_Admin_Dashboard_Setup Class.
@@ -47,11 +47,11 @@  discard block
 block discarded – undo
47 47
 		 * WC_Admin_Dashboard_Setup constructor.
48 48
 		 */
49 49
 		public function __construct() {
50
-			if ( $this->should_display_widget() ) {
50
+			if ($this->should_display_widget()) {
51 51
 				add_meta_box(
52 52
 					'wc_admin_dashboard_setup',
53
-					__( 'WooCommerce Setup', 'woocommerce' ),
54
-					array( $this, 'render' ),
53
+					__('WooCommerce Setup', 'woocommerce'),
54
+					array($this, 'render'),
55 55
 					'dashboard',
56 56
 					'normal',
57 57
 					'high'
@@ -63,23 +63,23 @@  discard block
 block discarded – undo
63 63
 		 * Render meta box output.
64 64
 		 */
65 65
 		public function render() {
66
-			$version = Constants::get_constant( 'WC_VERSION' );
67
-			wp_enqueue_style( 'wc-dashboard-setup', WC()->plugin_url() . '/assets/css/dashboard-setup.css', array(), $version );
66
+			$version = Constants::get_constant('WC_VERSION');
67
+			wp_enqueue_style('wc-dashboard-setup', WC()->plugin_url() . '/assets/css/dashboard-setup.css', array(), $version);
68 68
 
69 69
 			$task = $this->get_next_task();
70
-			if ( ! $task ) {
70
+			if (!$task) {
71 71
 				return;
72 72
 			}
73 73
 
74
-			$button_link           = $this->get_button_link( $task );
74
+			$button_link           = $this->get_button_link($task);
75 75
 			$completed_tasks_count = $this->get_completed_tasks_count();
76 76
 			$step_number           = $this->get_completed_tasks_count() + 1;
77
-			$tasks_count           = count( $this->get_tasks() );
77
+			$tasks_count           = count($this->get_tasks());
78 78
 
79 79
 			// Given 'r' (circle element's r attr), dashoffset = ((100-$desired_percentage)/100) * PI * (r*2).
80
-			$progress_percentage = ( $completed_tasks_count / $tasks_count ) * 100;
80
+			$progress_percentage = ($completed_tasks_count / $tasks_count) * 100;
81 81
 			$circle_r            = 6.5;
82
-			$circle_dashoffset   = ( ( 100 - $progress_percentage ) / 100 ) * ( pi() * ( $circle_r * 2 ) );
82
+			$circle_dashoffset   = ((100 - $progress_percentage) / 100) * (pi() * ($circle_r * 2));
83 83
 
84 84
 			include __DIR__ . '/views/html-admin-dashboard-setup.php';
85 85
 		}
@@ -90,16 +90,16 @@  discard block
 block discarded – undo
90 90
 		 * @param Task $task Task.
91 91
 		 * @return string
92 92
 		 */
93
-		public function get_button_link( $task ) {
93
+		public function get_button_link($task) {
94 94
 			$url = $task->get_json()['actionUrl'];
95 95
 
96
-			if ( substr( $url, 0, 4 ) === 'http' ) {
96
+			if (substr($url, 0, 4) === 'http') {
97 97
 				return $url;
98
-			} elseif ( $url ) {
99
-				return wc_admin_url( '&path=' . $url );
98
+			} elseif ($url) {
99
+				return wc_admin_url('&path=' . $url);
100 100
 			}
101 101
 
102
-			return admin_url( 'admin.php?page=wc-admin&task=' . $task->get_id() );
102
+			return admin_url('admin.php?page=wc-admin&task=' . $task->get_id());
103 103
 		}
104 104
 
105 105
 		/**
@@ -108,11 +108,11 @@  discard block
 block discarded – undo
108 108
 		 * @return array
109 109
 		 */
110 110
 		public function get_task_list() {
111
-			if ( $this->task_list || $this->initalized ) {
111
+			if ($this->task_list || $this->initalized) {
112 112
 				return $this->task_list;
113 113
 			}
114 114
 
115
-			$this->set_task_list( TaskLists::get_list( 'setup' ) );
115
+			$this->set_task_list(TaskLists::get_list('setup'));
116 116
 			$this->initalized = true;
117 117
 			return $this->task_list;
118 118
 		}
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 		/**
121 121
 		 * Set the task list.
122 122
 		 */
123
-		public function set_task_list( $task_list ) {
123
+		public function set_task_list($task_list) {
124 124
 			return $this->task_list = $task_list;
125 125
 		}
126 126
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 		 * @return array
131 131
 		 */
132 132
 		public function get_tasks() {
133
-			if ( $this->tasks ) {
133
+			if ($this->tasks) {
134 134
 				return $this->tasks;
135 135
 			}
136 136
 
@@ -146,12 +146,12 @@  discard block
 block discarded – undo
146 146
 		public function get_completed_tasks_count() {
147 147
 			$completed_tasks = array_filter(
148 148
 				$this->get_tasks(),
149
-				function( $task ) {
149
+				function($task) {
150 150
 					return $task->is_complete();
151 151
 				}
152 152
 			);
153 153
 
154
-			return count( $completed_tasks );
154
+			return count($completed_tasks);
155 155
 		}
156 156
 
157 157
 		/**
@@ -160,8 +160,8 @@  discard block
 block discarded – undo
160 160
 		 * @return array|null
161 161
 		 */
162 162
 		private function get_next_task() {
163
-			foreach ( $this->get_tasks() as $task ) {
164
-				if ( false === $task->is_complete() ) {
163
+			foreach ($this->get_tasks() as $task) {
164
+				if (false === $task->is_complete()) {
165 165
 					return $task;
166 166
 				}
167 167
 			}
@@ -175,19 +175,19 @@  discard block
 block discarded – undo
175 175
 		 * @return bool
176 176
 		 */
177 177
 		public function should_display_widget() {
178
-			if ( ! class_exists( 'Automattic\WooCommerce\Admin\Features\Features' ) || ! class_exists( 'Automattic\WooCommerce\Admin\Features\OnboardingTasks\TaskLists' ) ) {
178
+			if (!class_exists('Automattic\WooCommerce\Admin\Features\Features') || !class_exists('Automattic\WooCommerce\Admin\Features\OnboardingTasks\TaskLists')) {
179 179
 				return false;
180 180
 			}
181 181
 
182
-			if ( ! Features::is_enabled( 'onboarding' ) || ! WC()->is_wc_admin_active() ) {
182
+			if (!Features::is_enabled('onboarding') || !WC()->is_wc_admin_active()) {
183 183
 				return false;
184 184
 			}
185 185
 
186
-			if ( ! current_user_can( 'manage_woocommerce' ) ) {
186
+			if (!current_user_can('manage_woocommerce')) {
187 187
 				return false;
188 188
 			}
189 189
 
190
-			if ( ! $this->get_task_list() || $this->get_task_list()->is_complete() || $this->get_task_list()->is_hidden() ) {
190
+			if (!$this->get_task_list() || $this->get_task_list()->is_complete() || $this->get_task_list()->is_hidden()) {
191 191
 				return false;
192 192
 			}
193 193
 
Please login to merge, or discard this patch.
plugins/woocommerce/includes/admin/class-wc-admin-webhooks.php 2 patches
Indentation   +355 added lines, -355 removed lines patch added patch discarded remove patch
@@ -13,365 +13,365 @@
 block discarded – undo
13 13
  */
14 14
 class WC_Admin_Webhooks {
15 15
 
16
-	/**
17
-	 * Initialize the webhooks admin actions.
18
-	 */
19
-	public function __construct() {
20
-		add_action( 'admin_init', array( $this, 'actions' ) );
21
-		add_action( 'woocommerce_settings_page_init', array( $this, 'screen_option' ) );
22
-		add_filter( 'woocommerce_save_settings_advanced_webhooks', array( $this, 'allow_save_settings' ) );
23
-	}
24
-
25
-	/**
26
-	 * Check if should allow save settings.
27
-	 * This prevents "Your settings have been saved." notices on the table list.
28
-	 *
29
-	 * @param  bool $allow If allow save settings.
30
-	 * @return bool
31
-	 */
32
-	public function allow_save_settings( $allow ) {
33
-		// phpcs:ignore WordPress.Security.NonceVerification.Recommended
34
-		if ( ! isset( $_GET['edit-webhook'] ) ) {
35
-			return false;
36
-		}
37
-
38
-		return $allow;
39
-	}
40
-
41
-	/**
42
-	 * Check if is webhook settings page.
43
-	 *
44
-	 * @return bool
45
-	 */
46
-	private function is_webhook_settings_page() {
47
-		// phpcs:ignore WordPress.Security.NonceVerification.Recommended
48
-		return isset( $_GET['page'], $_GET['tab'], $_GET['section'] ) && 'wc-settings' === $_GET['page'] && 'advanced' === $_GET['tab'] && 'webhooks' === $_GET['section'];
49
-	}
50
-
51
-	/**
52
-	 * Save method.
53
-	 */
54
-	private function save() {
55
-		check_admin_referer( 'woocommerce-settings' );
56
-
57
-		if ( ! current_user_can( 'manage_woocommerce' ) ) {
58
-			wp_die( esc_html__( 'You do not have permission to update Webhooks', 'woocommerce' ) );
59
-		}
60
-
61
-		$errors = array();
62
-		// phpcs:ignore WordPress.Security.NonceVerification.Recommended
63
-		$webhook_id = isset( $_POST['webhook_id'] ) ? absint( $_POST['webhook_id'] ) : 0;
64
-		$webhook    = new WC_Webhook( $webhook_id );
65
-
66
-		// Name.
67
-		// phpcs:ignore WordPress.Security.NonceVerification.Recommended
68
-		if ( ! empty( $_POST['webhook_name'] ) ) {
69
-			// phpcs:ignore WordPress.Security.NonceVerification.Recommended
70
-			$name = sanitize_text_field( wp_unslash( $_POST['webhook_name'] ) );
71
-		} else {
72
-			$name = sprintf(
73
-				/* translators: %s: date */
74
-				__( 'Webhook created on %s', 'woocommerce' ),
75
-				// @codingStandardsIgnoreStart
76
-				(new DateTime('now'))->format( _x( 'M d, Y @ h:i A', 'Webhook created on date parsed by DateTime::format', 'woocommerce' ) )
77
-				// @codingStandardsIgnoreEnd
78
-			);
79
-		}
80
-
81
-		$webhook->set_name( $name );
82
-
83
-		if ( ! $webhook->get_user_id() ) {
84
-			$webhook->set_user_id( get_current_user_id() );
85
-		}
86
-
87
-		// Status.
88
-		// phpcs:ignore WordPress.Security.NonceVerification.Recommended
89
-		$webhook->set_status( ! empty( $_POST['webhook_status'] ) ? sanitize_text_field( wp_unslash( $_POST['webhook_status'] ) ) : 'disabled' );
90
-
91
-		// Delivery URL.
92
-		// phpcs:ignore WordPress.Security.NonceVerification.Recommended
93
-		$delivery_url = ! empty( $_POST['webhook_delivery_url'] ) ? esc_url_raw( wp_unslash( $_POST['webhook_delivery_url'] ) ) : '';
94
-
95
-		if ( wc_is_valid_url( $delivery_url ) ) {
96
-			$webhook->set_delivery_url( $delivery_url );
97
-		}
98
-
99
-		// Secret.
100
-		// phpcs:ignore WordPress.Security.NonceVerification.Recommended
101
-		$secret = ! empty( $_POST['webhook_secret'] ) ? sanitize_text_field( wp_unslash( $_POST['webhook_secret'] ) ) : wp_generate_password( 50, true, true );
102
-		$webhook->set_secret( $secret );
103
-
104
-		// Topic.
105
-		// phpcs:ignore WordPress.Security.NonceVerification.Recommended
106
-		if ( ! empty( $_POST['webhook_topic'] ) ) {
107
-			$resource = '';
108
-			$event    = '';
109
-
110
-			// phpcs:ignore WordPress.Security.NonceVerification.Recommended
111
-			switch ( $_POST['webhook_topic'] ) {
112
-				case 'action':
113
-					$resource = 'action';
114
-					// phpcs:ignore WordPress.Security.NonceVerification.Recommended
115
-					$event = ! empty( $_POST['webhook_action_event'] ) ? sanitize_text_field( wp_unslash( $_POST['webhook_action_event'] ) ) : '';
116
-					break;
117
-
118
-				default:
119
-					// phpcs:ignore WordPress.Security.NonceVerification.Recommended
120
-					list( $resource, $event ) = explode( '.', sanitize_text_field( wp_unslash( $_POST['webhook_topic'] ) ) );
121
-					break;
122
-			}
123
-
124
-			$topic = $resource . '.' . $event;
125
-
126
-			if ( wc_is_webhook_valid_topic( $topic ) ) {
127
-				$webhook->set_topic( $topic );
128
-			} else {
129
-				$errors[] = __( 'Webhook topic unknown. Please select a valid topic.', 'woocommerce' );
130
-			}
131
-		}
132
-
133
-		// API version.
134
-		$rest_api_versions = wc_get_webhook_rest_api_versions();
135
-		// phpcs:ignore WordPress.Security.NonceVerification.Recommended
136
-		$webhook->set_api_version( ! empty( $_POST['webhook_api_version'] ) ? sanitize_text_field( wp_unslash( $_POST['webhook_api_version'] ) ) : end( $rest_api_versions ) );
137
-
138
-		$webhook->save();
139
-
140
-		// Run actions.
141
-		do_action( 'woocommerce_webhook_options_save', $webhook->get_id() );
142
-		if ( $errors ) {
143
-			// Redirect to webhook edit page to avoid settings save actions.
144
-			wp_safe_redirect( admin_url( 'admin.php?page=wc-settings&tab=advanced&section=webhooks&edit-webhook=' . $webhook->get_id() . '&error=' . rawurlencode( implode( '|', $errors ) ) ) );
145
-			exit();
146
-			// phpcs:ignore WordPress.Security.NonceVerification.Recommended
147
-		} elseif ( isset( $_POST['webhook_status'] ) && 'active' === $_POST['webhook_status'] && $webhook->get_pending_delivery() ) {
148
-			// Ping the webhook at the first time that is activated.
149
-			$result = $webhook->deliver_ping();
150
-
151
-			if ( is_wp_error( $result ) ) {
152
-				// Redirect to webhook edit page to avoid settings save actions.
153
-				wp_safe_redirect( admin_url( 'admin.php?page=wc-settings&tab=advanced&section=webhooks&edit-webhook=' . $webhook->get_id() . '&error=' . rawurlencode( $result->get_error_message() ) ) );
154
-				exit();
155
-			}
156
-		}
157
-
158
-		// Redirect to webhook edit page to avoid settings save actions.
159
-		wp_safe_redirect( admin_url( 'admin.php?page=wc-settings&tab=advanced&section=webhooks&edit-webhook=' . $webhook->get_id() . '&updated=1' ) );
160
-		exit();
161
-	}
162
-
163
-	/**
164
-	 * Bulk delete.
165
-	 *
166
-	 * @param array $webhooks List of webhooks IDs.
167
-	 */
168
-	public static function bulk_delete( $webhooks ) {
169
-		foreach ( $webhooks as $webhook_id ) {
170
-			$webhook = new WC_Webhook( (int) $webhook_id );
171
-			$webhook->delete( true );
172
-		}
173
-
174
-		$qty = count( $webhooks );
175
-		// phpcs:ignore WordPress.Security.NonceVerification.Recommended
176
-		$status = isset( $_GET['status'] ) ? '&status=' . sanitize_text_field( wp_unslash( $_GET['status'] ) ) : '';
177
-
178
-		// Redirect to webhooks page.
179
-		wp_safe_redirect( admin_url( 'admin.php?page=wc-settings&tab=advanced&section=webhooks' . $status . '&deleted=' . $qty ) );
180
-		exit();
181
-	}
182
-
183
-	/**
184
-	 * Delete webhook.
185
-	 */
186
-	private function delete() {
187
-		check_admin_referer( 'delete-webhook' );
188
-
189
-		// phpcs:ignore WordPress.Security.NonceVerification.Recommended
190
-		if ( isset( $_GET['delete'] ) ) {
191
-			// phpcs:ignore WordPress.Security.NonceVerification.Recommended
192
-			$webhook_id = absint( $_GET['delete'] );
193
-
194
-			if ( $webhook_id ) {
195
-				$this->bulk_delete( array( $webhook_id ) );
196
-			}
197
-		}
198
-	}
199
-
200
-	/**
201
-	 * Webhooks admin actions.
202
-	 */
203
-	public function actions() {
204
-		if ( $this->is_webhook_settings_page() ) {
205
-			// Save.
206
-			// phpcs:ignore WordPress.Security.NonceVerification.Missing
207
-			if ( isset( $_POST['save'] ) && isset( $_POST['webhook_id'] ) ) {
208
-				$this->save();
209
-			}
210
-
211
-			// Delete webhook.
212
-			// phpcs:ignore WordPress.Security.NonceVerification.Recommended
213
-			if ( isset( $_GET['delete'] ) ) {
214
-				$this->delete();
215
-			}
216
-		}
217
-	}
218
-
219
-	/**
220
-	 * Page output.
221
-	 */
222
-	public static function page_output() {
223
-		// Hide the save button.
224
-		$GLOBALS['hide_save_button'] = true;
225
-
226
-		// phpcs:ignore WordPress.Security.NonceVerification.Recommended
227
-		if ( isset( $_GET['edit-webhook'] ) ) {
228
-			// phpcs:ignore WordPress.Security.NonceVerification.Recommended
229
-			$webhook_id = absint( $_GET['edit-webhook'] );
230
-			$webhook    = new WC_Webhook( $webhook_id );
231
-
232
-			include __DIR__ . '/settings/views/html-webhooks-edit.php';
233
-			return;
234
-		}
235
-
236
-		self::table_list_output();
237
-	}
238
-
239
-	/**
240
-	 * Notices.
241
-	 */
242
-	public static function notices() {
243
-		// phpcs:ignore WordPress.Security.NonceVerification.Recommended
244
-		if ( isset( $_GET['deleted'] ) ) {
245
-			// phpcs:ignore WordPress.Security.NonceVerification.Recommended
246
-			$deleted = absint( $_GET['deleted'] );
247
-
248
-			/* translators: %d: count */
249
-			WC_Admin_Settings::add_message( sprintf( _n( '%d webhook permanently deleted.', '%d webhooks permanently deleted.', $deleted, 'woocommerce' ), $deleted ) );
250
-		}
251
-
252
-		// phpcs:ignore WordPress.Security.NonceVerification.Recommended
253
-		if ( isset( $_GET['updated'] ) ) {
254
-			WC_Admin_Settings::add_message( __( 'Webhook updated successfully.', 'woocommerce' ) );
255
-		}
256
-
257
-		// phpcs:ignore WordPress.Security.NonceVerification.Recommended
258
-		if ( isset( $_GET['created'] ) ) {
259
-			WC_Admin_Settings::add_message( __( 'Webhook created successfully.', 'woocommerce' ) );
260
-		}
261
-
262
-		// phpcs:ignore WordPress.Security.NonceVerification.Recommended
263
-		if ( isset( $_GET['error'] ) ) {
264
-			// phpcs:ignore WordPress.Security.NonceVerification.Recommended
265
-			foreach ( explode( '|', sanitize_text_field( wp_unslash( $_GET['error'] ) ) ) as $message ) {
266
-				WC_Admin_Settings::add_error( trim( $message ) );
267
-			}
268
-		}
269
-	}
270
-
271
-	/**
272
-	 * Add screen option.
273
-	 */
274
-	public function screen_option() {
275
-		global $webhooks_table_list;
276
-
277
-		// phpcs:ignore WordPress.Security.NonceVerification.Recommended
278
-		if ( ! isset( $_GET['edit-webhook'] ) && $this->is_webhook_settings_page() ) {
279
-			$webhooks_table_list = new WC_Admin_Webhooks_Table_List();
280
-
281
-			// Add screen option.
282
-			add_screen_option(
283
-				'per_page',
284
-				array(
285
-					'default' => 10,
286
-					'option'  => 'woocommerce_webhooks_per_page',
287
-				)
288
-			);
289
-		}
290
-	}
291
-
292
-	/**
293
-	 * Table list output.
294
-	 */
295
-	private static function table_list_output() {
296
-		global $webhooks_table_list;
297
-
298
-		echo '<h2 class="wc-table-list-header">' . esc_html__( 'Webhooks', 'woocommerce' ) . ' <a href="' . esc_url( admin_url( 'admin.php?page=wc-settings&tab=advanced&section=webhooks&edit-webhook=0' ) ) . '" class="add-new-h2">' . esc_html__( 'Add webhook', 'woocommerce' ) . '</a></h2>';
299
-
300
-		// Get the webhooks count.
301
-		$data_store   = WC_Data_Store::load( 'webhook' );
302
-		$num_webhooks = $data_store->get_count_webhooks_by_status();
303
-		$count        = array_sum( $num_webhooks );
304
-
305
-		if ( 0 < $count ) {
306
-			$webhooks_table_list->process_bulk_action();
307
-			$webhooks_table_list->prepare_items();
308
-
309
-			echo '<input type="hidden" name="page" value="wc-settings" />';
310
-			echo '<input type="hidden" name="tab" value="advanced" />';
311
-			echo '<input type="hidden" name="section" value="webhooks" />';
312
-
313
-			$webhooks_table_list->views();
314
-			$webhooks_table_list->search_box( __( 'Search webhooks', 'woocommerce' ), 'webhook' );
315
-			$webhooks_table_list->display();
316
-		} else {
317
-			echo '<div class="woocommerce-BlankState woocommerce-BlankState--webhooks">';
318
-			?>
16
+    /**
17
+     * Initialize the webhooks admin actions.
18
+     */
19
+    public function __construct() {
20
+        add_action( 'admin_init', array( $this, 'actions' ) );
21
+        add_action( 'woocommerce_settings_page_init', array( $this, 'screen_option' ) );
22
+        add_filter( 'woocommerce_save_settings_advanced_webhooks', array( $this, 'allow_save_settings' ) );
23
+    }
24
+
25
+    /**
26
+     * Check if should allow save settings.
27
+     * This prevents "Your settings have been saved." notices on the table list.
28
+     *
29
+     * @param  bool $allow If allow save settings.
30
+     * @return bool
31
+     */
32
+    public function allow_save_settings( $allow ) {
33
+        // phpcs:ignore WordPress.Security.NonceVerification.Recommended
34
+        if ( ! isset( $_GET['edit-webhook'] ) ) {
35
+            return false;
36
+        }
37
+
38
+        return $allow;
39
+    }
40
+
41
+    /**
42
+     * Check if is webhook settings page.
43
+     *
44
+     * @return bool
45
+     */
46
+    private function is_webhook_settings_page() {
47
+        // phpcs:ignore WordPress.Security.NonceVerification.Recommended
48
+        return isset( $_GET['page'], $_GET['tab'], $_GET['section'] ) && 'wc-settings' === $_GET['page'] && 'advanced' === $_GET['tab'] && 'webhooks' === $_GET['section'];
49
+    }
50
+
51
+    /**
52
+     * Save method.
53
+     */
54
+    private function save() {
55
+        check_admin_referer( 'woocommerce-settings' );
56
+
57
+        if ( ! current_user_can( 'manage_woocommerce' ) ) {
58
+            wp_die( esc_html__( 'You do not have permission to update Webhooks', 'woocommerce' ) );
59
+        }
60
+
61
+        $errors = array();
62
+        // phpcs:ignore WordPress.Security.NonceVerification.Recommended
63
+        $webhook_id = isset( $_POST['webhook_id'] ) ? absint( $_POST['webhook_id'] ) : 0;
64
+        $webhook    = new WC_Webhook( $webhook_id );
65
+
66
+        // Name.
67
+        // phpcs:ignore WordPress.Security.NonceVerification.Recommended
68
+        if ( ! empty( $_POST['webhook_name'] ) ) {
69
+            // phpcs:ignore WordPress.Security.NonceVerification.Recommended
70
+            $name = sanitize_text_field( wp_unslash( $_POST['webhook_name'] ) );
71
+        } else {
72
+            $name = sprintf(
73
+                /* translators: %s: date */
74
+                __( 'Webhook created on %s', 'woocommerce' ),
75
+                // @codingStandardsIgnoreStart
76
+                (new DateTime('now'))->format( _x( 'M d, Y @ h:i A', 'Webhook created on date parsed by DateTime::format', 'woocommerce' ) )
77
+                // @codingStandardsIgnoreEnd
78
+            );
79
+        }
80
+
81
+        $webhook->set_name( $name );
82
+
83
+        if ( ! $webhook->get_user_id() ) {
84
+            $webhook->set_user_id( get_current_user_id() );
85
+        }
86
+
87
+        // Status.
88
+        // phpcs:ignore WordPress.Security.NonceVerification.Recommended
89
+        $webhook->set_status( ! empty( $_POST['webhook_status'] ) ? sanitize_text_field( wp_unslash( $_POST['webhook_status'] ) ) : 'disabled' );
90
+
91
+        // Delivery URL.
92
+        // phpcs:ignore WordPress.Security.NonceVerification.Recommended
93
+        $delivery_url = ! empty( $_POST['webhook_delivery_url'] ) ? esc_url_raw( wp_unslash( $_POST['webhook_delivery_url'] ) ) : '';
94
+
95
+        if ( wc_is_valid_url( $delivery_url ) ) {
96
+            $webhook->set_delivery_url( $delivery_url );
97
+        }
98
+
99
+        // Secret.
100
+        // phpcs:ignore WordPress.Security.NonceVerification.Recommended
101
+        $secret = ! empty( $_POST['webhook_secret'] ) ? sanitize_text_field( wp_unslash( $_POST['webhook_secret'] ) ) : wp_generate_password( 50, true, true );
102
+        $webhook->set_secret( $secret );
103
+
104
+        // Topic.
105
+        // phpcs:ignore WordPress.Security.NonceVerification.Recommended
106
+        if ( ! empty( $_POST['webhook_topic'] ) ) {
107
+            $resource = '';
108
+            $event    = '';
109
+
110
+            // phpcs:ignore WordPress.Security.NonceVerification.Recommended
111
+            switch ( $_POST['webhook_topic'] ) {
112
+                case 'action':
113
+                    $resource = 'action';
114
+                    // phpcs:ignore WordPress.Security.NonceVerification.Recommended
115
+                    $event = ! empty( $_POST['webhook_action_event'] ) ? sanitize_text_field( wp_unslash( $_POST['webhook_action_event'] ) ) : '';
116
+                    break;
117
+
118
+                default:
119
+                    // phpcs:ignore WordPress.Security.NonceVerification.Recommended
120
+                    list( $resource, $event ) = explode( '.', sanitize_text_field( wp_unslash( $_POST['webhook_topic'] ) ) );
121
+                    break;
122
+            }
123
+
124
+            $topic = $resource . '.' . $event;
125
+
126
+            if ( wc_is_webhook_valid_topic( $topic ) ) {
127
+                $webhook->set_topic( $topic );
128
+            } else {
129
+                $errors[] = __( 'Webhook topic unknown. Please select a valid topic.', 'woocommerce' );
130
+            }
131
+        }
132
+
133
+        // API version.
134
+        $rest_api_versions = wc_get_webhook_rest_api_versions();
135
+        // phpcs:ignore WordPress.Security.NonceVerification.Recommended
136
+        $webhook->set_api_version( ! empty( $_POST['webhook_api_version'] ) ? sanitize_text_field( wp_unslash( $_POST['webhook_api_version'] ) ) : end( $rest_api_versions ) );
137
+
138
+        $webhook->save();
139
+
140
+        // Run actions.
141
+        do_action( 'woocommerce_webhook_options_save', $webhook->get_id() );
142
+        if ( $errors ) {
143
+            // Redirect to webhook edit page to avoid settings save actions.
144
+            wp_safe_redirect( admin_url( 'admin.php?page=wc-settings&tab=advanced&section=webhooks&edit-webhook=' . $webhook->get_id() . '&error=' . rawurlencode( implode( '|', $errors ) ) ) );
145
+            exit();
146
+            // phpcs:ignore WordPress.Security.NonceVerification.Recommended
147
+        } elseif ( isset( $_POST['webhook_status'] ) && 'active' === $_POST['webhook_status'] && $webhook->get_pending_delivery() ) {
148
+            // Ping the webhook at the first time that is activated.
149
+            $result = $webhook->deliver_ping();
150
+
151
+            if ( is_wp_error( $result ) ) {
152
+                // Redirect to webhook edit page to avoid settings save actions.
153
+                wp_safe_redirect( admin_url( 'admin.php?page=wc-settings&tab=advanced&section=webhooks&edit-webhook=' . $webhook->get_id() . '&error=' . rawurlencode( $result->get_error_message() ) ) );
154
+                exit();
155
+            }
156
+        }
157
+
158
+        // Redirect to webhook edit page to avoid settings save actions.
159
+        wp_safe_redirect( admin_url( 'admin.php?page=wc-settings&tab=advanced&section=webhooks&edit-webhook=' . $webhook->get_id() . '&updated=1' ) );
160
+        exit();
161
+    }
162
+
163
+    /**
164
+     * Bulk delete.
165
+     *
166
+     * @param array $webhooks List of webhooks IDs.
167
+     */
168
+    public static function bulk_delete( $webhooks ) {
169
+        foreach ( $webhooks as $webhook_id ) {
170
+            $webhook = new WC_Webhook( (int) $webhook_id );
171
+            $webhook->delete( true );
172
+        }
173
+
174
+        $qty = count( $webhooks );
175
+        // phpcs:ignore WordPress.Security.NonceVerification.Recommended
176
+        $status = isset( $_GET['status'] ) ? '&status=' . sanitize_text_field( wp_unslash( $_GET['status'] ) ) : '';
177
+
178
+        // Redirect to webhooks page.
179
+        wp_safe_redirect( admin_url( 'admin.php?page=wc-settings&tab=advanced&section=webhooks' . $status . '&deleted=' . $qty ) );
180
+        exit();
181
+    }
182
+
183
+    /**
184
+     * Delete webhook.
185
+     */
186
+    private function delete() {
187
+        check_admin_referer( 'delete-webhook' );
188
+
189
+        // phpcs:ignore WordPress.Security.NonceVerification.Recommended
190
+        if ( isset( $_GET['delete'] ) ) {
191
+            // phpcs:ignore WordPress.Security.NonceVerification.Recommended
192
+            $webhook_id = absint( $_GET['delete'] );
193
+
194
+            if ( $webhook_id ) {
195
+                $this->bulk_delete( array( $webhook_id ) );
196
+            }
197
+        }
198
+    }
199
+
200
+    /**
201
+     * Webhooks admin actions.
202
+     */
203
+    public function actions() {
204
+        if ( $this->is_webhook_settings_page() ) {
205
+            // Save.
206
+            // phpcs:ignore WordPress.Security.NonceVerification.Missing
207
+            if ( isset( $_POST['save'] ) && isset( $_POST['webhook_id'] ) ) {
208
+                $this->save();
209
+            }
210
+
211
+            // Delete webhook.
212
+            // phpcs:ignore WordPress.Security.NonceVerification.Recommended
213
+            if ( isset( $_GET['delete'] ) ) {
214
+                $this->delete();
215
+            }
216
+        }
217
+    }
218
+
219
+    /**
220
+     * Page output.
221
+     */
222
+    public static function page_output() {
223
+        // Hide the save button.
224
+        $GLOBALS['hide_save_button'] = true;
225
+
226
+        // phpcs:ignore WordPress.Security.NonceVerification.Recommended
227
+        if ( isset( $_GET['edit-webhook'] ) ) {
228
+            // phpcs:ignore WordPress.Security.NonceVerification.Recommended
229
+            $webhook_id = absint( $_GET['edit-webhook'] );
230
+            $webhook    = new WC_Webhook( $webhook_id );
231
+
232
+            include __DIR__ . '/settings/views/html-webhooks-edit.php';
233
+            return;
234
+        }
235
+
236
+        self::table_list_output();
237
+    }
238
+
239
+    /**
240
+     * Notices.
241
+     */
242
+    public static function notices() {
243
+        // phpcs:ignore WordPress.Security.NonceVerification.Recommended
244
+        if ( isset( $_GET['deleted'] ) ) {
245
+            // phpcs:ignore WordPress.Security.NonceVerification.Recommended
246
+            $deleted = absint( $_GET['deleted'] );
247
+
248
+            /* translators: %d: count */
249
+            WC_Admin_Settings::add_message( sprintf( _n( '%d webhook permanently deleted.', '%d webhooks permanently deleted.', $deleted, 'woocommerce' ), $deleted ) );
250
+        }
251
+
252
+        // phpcs:ignore WordPress.Security.NonceVerification.Recommended
253
+        if ( isset( $_GET['updated'] ) ) {
254
+            WC_Admin_Settings::add_message( __( 'Webhook updated successfully.', 'woocommerce' ) );
255
+        }
256
+
257
+        // phpcs:ignore WordPress.Security.NonceVerification.Recommended
258
+        if ( isset( $_GET['created'] ) ) {
259
+            WC_Admin_Settings::add_message( __( 'Webhook created successfully.', 'woocommerce' ) );
260
+        }
261
+
262
+        // phpcs:ignore WordPress.Security.NonceVerification.Recommended
263
+        if ( isset( $_GET['error'] ) ) {
264
+            // phpcs:ignore WordPress.Security.NonceVerification.Recommended
265
+            foreach ( explode( '|', sanitize_text_field( wp_unslash( $_GET['error'] ) ) ) as $message ) {
266
+                WC_Admin_Settings::add_error( trim( $message ) );
267
+            }
268
+        }
269
+    }
270
+
271
+    /**
272
+     * Add screen option.
273
+     */
274
+    public function screen_option() {
275
+        global $webhooks_table_list;
276
+
277
+        // phpcs:ignore WordPress.Security.NonceVerification.Recommended
278
+        if ( ! isset( $_GET['edit-webhook'] ) && $this->is_webhook_settings_page() ) {
279
+            $webhooks_table_list = new WC_Admin_Webhooks_Table_List();
280
+
281
+            // Add screen option.
282
+            add_screen_option(
283
+                'per_page',
284
+                array(
285
+                    'default' => 10,
286
+                    'option'  => 'woocommerce_webhooks_per_page',
287
+                )
288
+            );
289
+        }
290
+    }
291
+
292
+    /**
293
+     * Table list output.
294
+     */
295
+    private static function table_list_output() {
296
+        global $webhooks_table_list;
297
+
298
+        echo '<h2 class="wc-table-list-header">' . esc_html__( 'Webhooks', 'woocommerce' ) . ' <a href="' . esc_url( admin_url( 'admin.php?page=wc-settings&tab=advanced&section=webhooks&edit-webhook=0' ) ) . '" class="add-new-h2">' . esc_html__( 'Add webhook', 'woocommerce' ) . '</a></h2>';
299
+
300
+        // Get the webhooks count.
301
+        $data_store   = WC_Data_Store::load( 'webhook' );
302
+        $num_webhooks = $data_store->get_count_webhooks_by_status();
303
+        $count        = array_sum( $num_webhooks );
304
+
305
+        if ( 0 < $count ) {
306
+            $webhooks_table_list->process_bulk_action();
307
+            $webhooks_table_list->prepare_items();
308
+
309
+            echo '<input type="hidden" name="page" value="wc-settings" />';
310
+            echo '<input type="hidden" name="tab" value="advanced" />';
311
+            echo '<input type="hidden" name="section" value="webhooks" />';
312
+
313
+            $webhooks_table_list->views();
314
+            $webhooks_table_list->search_box( __( 'Search webhooks', 'woocommerce' ), 'webhook' );
315
+            $webhooks_table_list->display();
316
+        } else {
317
+            echo '<div class="woocommerce-BlankState woocommerce-BlankState--webhooks">';
318
+            ?>
319 319
 			<h2 class="woocommerce-BlankState-message"><?php esc_html_e( 'Webhooks are event notifications sent to URLs of your choice. They can be used to integrate with third-party services which support them.', 'woocommerce' ); ?></h2>
320 320
 			<a class="woocommerce-BlankState-cta button-primary button" href="<?php echo esc_url( admin_url( 'admin.php?page=wc-settings&tab=advanced&section=webhooks&edit-webhook=0' ) ); ?>"><?php esc_html_e( 'Create a new webhook', 'woocommerce' ); ?></a>
321 321
 			<style type="text/css">#posts-filter .wp-list-table, #posts-filter .tablenav.top, .tablenav.bottom .actions { display: none; }</style>
322 322
 			<?php
323
-		}
324
-	}
325
-
326
-	/**
327
-	 * Logs output.
328
-	 *
329
-	 * @deprecated 3.3.0
330
-	 * @param WC_Webhook $webhook Deprecated.
331
-	 */
332
-	public static function logs_output( $webhook = 'deprecated' ) {
333
-		wc_deprecated_function( 'WC_Admin_Webhooks::logs_output', '3.3' );
334
-	}
335
-
336
-	/**
337
-	 * Get the webhook topic data.
338
-	 *
339
-	 * @param WC_Webhook $webhook Webhook instance.
340
-	 *
341
-	 * @return array
342
-	 */
343
-	public static function get_topic_data( $webhook ) {
344
-		$topic    = $webhook->get_topic();
345
-		$event    = '';
346
-		$resource = '';
347
-
348
-		if ( $topic ) {
349
-			list( $resource, $event ) = explode( '.', $topic );
350
-
351
-			if ( 'action' === $resource ) {
352
-				$topic = 'action';
353
-			} elseif ( ! in_array( $resource, array( 'coupon', 'customer', 'order', 'product' ), true ) ) {
354
-				$topic = 'custom';
355
-			}
356
-		}
357
-
358
-		return array(
359
-			'topic'    => $topic,
360
-			'event'    => $event,
361
-			'resource' => $resource,
362
-		);
363
-	}
364
-
365
-	/**
366
-	 * Get the logs navigation.
367
-	 *
368
-	 * @deprecated 3.3.0
369
-	 * @param int        $total Deprecated.
370
-	 * @param WC_Webhook $webhook Deprecated.
371
-	 */
372
-	public static function get_logs_navigation( $total, $webhook ) {
373
-		wc_deprecated_function( 'WC_Admin_Webhooks::get_logs_navigation', '3.3' );
374
-	}
323
+        }
324
+    }
325
+
326
+    /**
327
+     * Logs output.
328
+     *
329
+     * @deprecated 3.3.0
330
+     * @param WC_Webhook $webhook Deprecated.
331
+     */
332
+    public static function logs_output( $webhook = 'deprecated' ) {
333
+        wc_deprecated_function( 'WC_Admin_Webhooks::logs_output', '3.3' );
334
+    }
335
+
336
+    /**
337
+     * Get the webhook topic data.
338
+     *
339
+     * @param WC_Webhook $webhook Webhook instance.
340
+     *
341
+     * @return array
342
+     */
343
+    public static function get_topic_data( $webhook ) {
344
+        $topic    = $webhook->get_topic();
345
+        $event    = '';
346
+        $resource = '';
347
+
348
+        if ( $topic ) {
349
+            list( $resource, $event ) = explode( '.', $topic );
350
+
351
+            if ( 'action' === $resource ) {
352
+                $topic = 'action';
353
+            } elseif ( ! in_array( $resource, array( 'coupon', 'customer', 'order', 'product' ), true ) ) {
354
+                $topic = 'custom';
355
+            }
356
+        }
357
+
358
+        return array(
359
+            'topic'    => $topic,
360
+            'event'    => $event,
361
+            'resource' => $resource,
362
+        );
363
+    }
364
+
365
+    /**
366
+     * Get the logs navigation.
367
+     *
368
+     * @deprecated 3.3.0
369
+     * @param int        $total Deprecated.
370
+     * @param WC_Webhook $webhook Deprecated.
371
+     */
372
+    public static function get_logs_navigation( $total, $webhook ) {
373
+        wc_deprecated_function( 'WC_Admin_Webhooks::get_logs_navigation', '3.3' );
374
+    }
375 375
 }
376 376
 
377 377
 new WC_Admin_Webhooks();
Please login to merge, or discard this patch.
Spacing   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @version 3.3.0
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * WC_Admin_Webhooks.
@@ -17,9 +17,9 @@  discard block
 block discarded – undo
17 17
 	 * Initialize the webhooks admin actions.
18 18
 	 */
19 19
 	public function __construct() {
20
-		add_action( 'admin_init', array( $this, 'actions' ) );
21
-		add_action( 'woocommerce_settings_page_init', array( $this, 'screen_option' ) );
22
-		add_filter( 'woocommerce_save_settings_advanced_webhooks', array( $this, 'allow_save_settings' ) );
20
+		add_action('admin_init', array($this, 'actions'));
21
+		add_action('woocommerce_settings_page_init', array($this, 'screen_option'));
22
+		add_filter('woocommerce_save_settings_advanced_webhooks', array($this, 'allow_save_settings'));
23 23
 	}
24 24
 
25 25
 	/**
@@ -29,9 +29,9 @@  discard block
 block discarded – undo
29 29
 	 * @param  bool $allow If allow save settings.
30 30
 	 * @return bool
31 31
 	 */
32
-	public function allow_save_settings( $allow ) {
32
+	public function allow_save_settings($allow) {
33 33
 		// phpcs:ignore WordPress.Security.NonceVerification.Recommended
34
-		if ( ! isset( $_GET['edit-webhook'] ) ) {
34
+		if (!isset($_GET['edit-webhook'])) {
35 35
 			return false;
36 36
 		}
37 37
 
@@ -45,118 +45,118 @@  discard block
 block discarded – undo
45 45
 	 */
46 46
 	private function is_webhook_settings_page() {
47 47
 		// phpcs:ignore WordPress.Security.NonceVerification.Recommended
48
-		return isset( $_GET['page'], $_GET['tab'], $_GET['section'] ) && 'wc-settings' === $_GET['page'] && 'advanced' === $_GET['tab'] && 'webhooks' === $_GET['section'];
48
+		return isset($_GET['page'], $_GET['tab'], $_GET['section']) && 'wc-settings' === $_GET['page'] && 'advanced' === $_GET['tab'] && 'webhooks' === $_GET['section'];
49 49
 	}
50 50
 
51 51
 	/**
52 52
 	 * Save method.
53 53
 	 */
54 54
 	private function save() {
55
-		check_admin_referer( 'woocommerce-settings' );
55
+		check_admin_referer('woocommerce-settings');
56 56
 
57
-		if ( ! current_user_can( 'manage_woocommerce' ) ) {
58
-			wp_die( esc_html__( 'You do not have permission to update Webhooks', 'woocommerce' ) );
57
+		if (!current_user_can('manage_woocommerce')) {
58
+			wp_die(esc_html__('You do not have permission to update Webhooks', 'woocommerce'));
59 59
 		}
60 60
 
61 61
 		$errors = array();
62 62
 		// phpcs:ignore WordPress.Security.NonceVerification.Recommended
63
-		$webhook_id = isset( $_POST['webhook_id'] ) ? absint( $_POST['webhook_id'] ) : 0;
64
-		$webhook    = new WC_Webhook( $webhook_id );
63
+		$webhook_id = isset($_POST['webhook_id']) ? absint($_POST['webhook_id']) : 0;
64
+		$webhook    = new WC_Webhook($webhook_id);
65 65
 
66 66
 		// Name.
67 67
 		// phpcs:ignore WordPress.Security.NonceVerification.Recommended
68
-		if ( ! empty( $_POST['webhook_name'] ) ) {
68
+		if (!empty($_POST['webhook_name'])) {
69 69
 			// phpcs:ignore WordPress.Security.NonceVerification.Recommended
70
-			$name = sanitize_text_field( wp_unslash( $_POST['webhook_name'] ) );
70
+			$name = sanitize_text_field(wp_unslash($_POST['webhook_name']));
71 71
 		} else {
72 72
 			$name = sprintf(
73 73
 				/* translators: %s: date */
74
-				__( 'Webhook created on %s', 'woocommerce' ),
74
+				__('Webhook created on %s', 'woocommerce'),
75 75
 				// @codingStandardsIgnoreStart
76
-				(new DateTime('now'))->format( _x( 'M d, Y @ h:i A', 'Webhook created on date parsed by DateTime::format', 'woocommerce' ) )
76
+				(new DateTime('now'))->format(_x('M d, Y @ h:i A', 'Webhook created on date parsed by DateTime::format', 'woocommerce'))
77 77
 				// @codingStandardsIgnoreEnd
78 78
 			);
79 79
 		}
80 80
 
81
-		$webhook->set_name( $name );
81
+		$webhook->set_name($name);
82 82
 
83
-		if ( ! $webhook->get_user_id() ) {
84
-			$webhook->set_user_id( get_current_user_id() );
83
+		if (!$webhook->get_user_id()) {
84
+			$webhook->set_user_id(get_current_user_id());
85 85
 		}
86 86
 
87 87
 		// Status.
88 88
 		// phpcs:ignore WordPress.Security.NonceVerification.Recommended
89
-		$webhook->set_status( ! empty( $_POST['webhook_status'] ) ? sanitize_text_field( wp_unslash( $_POST['webhook_status'] ) ) : 'disabled' );
89
+		$webhook->set_status(!empty($_POST['webhook_status']) ? sanitize_text_field(wp_unslash($_POST['webhook_status'])) : 'disabled');
90 90
 
91 91
 		// Delivery URL.
92 92
 		// phpcs:ignore WordPress.Security.NonceVerification.Recommended
93
-		$delivery_url = ! empty( $_POST['webhook_delivery_url'] ) ? esc_url_raw( wp_unslash( $_POST['webhook_delivery_url'] ) ) : '';
93
+		$delivery_url = !empty($_POST['webhook_delivery_url']) ? esc_url_raw(wp_unslash($_POST['webhook_delivery_url'])) : '';
94 94
 
95
-		if ( wc_is_valid_url( $delivery_url ) ) {
96
-			$webhook->set_delivery_url( $delivery_url );
95
+		if (wc_is_valid_url($delivery_url)) {
96
+			$webhook->set_delivery_url($delivery_url);
97 97
 		}
98 98
 
99 99
 		// Secret.
100 100
 		// phpcs:ignore WordPress.Security.NonceVerification.Recommended
101
-		$secret = ! empty( $_POST['webhook_secret'] ) ? sanitize_text_field( wp_unslash( $_POST['webhook_secret'] ) ) : wp_generate_password( 50, true, true );
102
-		$webhook->set_secret( $secret );
101
+		$secret = !empty($_POST['webhook_secret']) ? sanitize_text_field(wp_unslash($_POST['webhook_secret'])) : wp_generate_password(50, true, true);
102
+		$webhook->set_secret($secret);
103 103
 
104 104
 		// Topic.
105 105
 		// phpcs:ignore WordPress.Security.NonceVerification.Recommended
106
-		if ( ! empty( $_POST['webhook_topic'] ) ) {
106
+		if (!empty($_POST['webhook_topic'])) {
107 107
 			$resource = '';
108 108
 			$event    = '';
109 109
 
110 110
 			// phpcs:ignore WordPress.Security.NonceVerification.Recommended
111
-			switch ( $_POST['webhook_topic'] ) {
111
+			switch ($_POST['webhook_topic']) {
112 112
 				case 'action':
113 113
 					$resource = 'action';
114 114
 					// phpcs:ignore WordPress.Security.NonceVerification.Recommended
115
-					$event = ! empty( $_POST['webhook_action_event'] ) ? sanitize_text_field( wp_unslash( $_POST['webhook_action_event'] ) ) : '';
115
+					$event = !empty($_POST['webhook_action_event']) ? sanitize_text_field(wp_unslash($_POST['webhook_action_event'])) : '';
116 116
 					break;
117 117
 
118 118
 				default:
119 119
 					// phpcs:ignore WordPress.Security.NonceVerification.Recommended
120
-					list( $resource, $event ) = explode( '.', sanitize_text_field( wp_unslash( $_POST['webhook_topic'] ) ) );
120
+					list($resource, $event) = explode('.', sanitize_text_field(wp_unslash($_POST['webhook_topic'])));
121 121
 					break;
122 122
 			}
123 123
 
124 124
 			$topic = $resource . '.' . $event;
125 125
 
126
-			if ( wc_is_webhook_valid_topic( $topic ) ) {
127
-				$webhook->set_topic( $topic );
126
+			if (wc_is_webhook_valid_topic($topic)) {
127
+				$webhook->set_topic($topic);
128 128
 			} else {
129
-				$errors[] = __( 'Webhook topic unknown. Please select a valid topic.', 'woocommerce' );
129
+				$errors[] = __('Webhook topic unknown. Please select a valid topic.', 'woocommerce');
130 130
 			}
131 131
 		}
132 132
 
133 133
 		// API version.
134 134
 		$rest_api_versions = wc_get_webhook_rest_api_versions();
135 135
 		// phpcs:ignore WordPress.Security.NonceVerification.Recommended
136
-		$webhook->set_api_version( ! empty( $_POST['webhook_api_version'] ) ? sanitize_text_field( wp_unslash( $_POST['webhook_api_version'] ) ) : end( $rest_api_versions ) );
136
+		$webhook->set_api_version(!empty($_POST['webhook_api_version']) ? sanitize_text_field(wp_unslash($_POST['webhook_api_version'])) : end($rest_api_versions));
137 137
 
138 138
 		$webhook->save();
139 139
 
140 140
 		// Run actions.
141
-		do_action( 'woocommerce_webhook_options_save', $webhook->get_id() );
142
-		if ( $errors ) {
141
+		do_action('woocommerce_webhook_options_save', $webhook->get_id());
142
+		if ($errors) {
143 143
 			// Redirect to webhook edit page to avoid settings save actions.
144
-			wp_safe_redirect( admin_url( 'admin.php?page=wc-settings&tab=advanced&section=webhooks&edit-webhook=' . $webhook->get_id() . '&error=' . rawurlencode( implode( '|', $errors ) ) ) );
144
+			wp_safe_redirect(admin_url('admin.php?page=wc-settings&tab=advanced&section=webhooks&edit-webhook=' . $webhook->get_id() . '&error=' . rawurlencode(implode('|', $errors))));
145 145
 			exit();
146 146
 			// phpcs:ignore WordPress.Security.NonceVerification.Recommended
147
-		} elseif ( isset( $_POST['webhook_status'] ) && 'active' === $_POST['webhook_status'] && $webhook->get_pending_delivery() ) {
147
+		} elseif (isset($_POST['webhook_status']) && 'active' === $_POST['webhook_status'] && $webhook->get_pending_delivery()) {
148 148
 			// Ping the webhook at the first time that is activated.
149 149
 			$result = $webhook->deliver_ping();
150 150
 
151
-			if ( is_wp_error( $result ) ) {
151
+			if (is_wp_error($result)) {
152 152
 				// Redirect to webhook edit page to avoid settings save actions.
153
-				wp_safe_redirect( admin_url( 'admin.php?page=wc-settings&tab=advanced&section=webhooks&edit-webhook=' . $webhook->get_id() . '&error=' . rawurlencode( $result->get_error_message() ) ) );
153
+				wp_safe_redirect(admin_url('admin.php?page=wc-settings&tab=advanced&section=webhooks&edit-webhook=' . $webhook->get_id() . '&error=' . rawurlencode($result->get_error_message())));
154 154
 				exit();
155 155
 			}
156 156
 		}
157 157
 
158 158
 		// Redirect to webhook edit page to avoid settings save actions.
159
-		wp_safe_redirect( admin_url( 'admin.php?page=wc-settings&tab=advanced&section=webhooks&edit-webhook=' . $webhook->get_id() . '&updated=1' ) );
159
+		wp_safe_redirect(admin_url('admin.php?page=wc-settings&tab=advanced&section=webhooks&edit-webhook=' . $webhook->get_id() . '&updated=1'));
160 160
 		exit();
161 161
 	}
162 162
 
@@ -165,18 +165,18 @@  discard block
 block discarded – undo
165 165
 	 *
166 166
 	 * @param array $webhooks List of webhooks IDs.
167 167
 	 */
168
-	public static function bulk_delete( $webhooks ) {
169
-		foreach ( $webhooks as $webhook_id ) {
170
-			$webhook = new WC_Webhook( (int) $webhook_id );
171
-			$webhook->delete( true );
168
+	public static function bulk_delete($webhooks) {
169
+		foreach ($webhooks as $webhook_id) {
170
+			$webhook = new WC_Webhook((int) $webhook_id);
171
+			$webhook->delete(true);
172 172
 		}
173 173
 
174
-		$qty = count( $webhooks );
174
+		$qty = count($webhooks);
175 175
 		// phpcs:ignore WordPress.Security.NonceVerification.Recommended
176
-		$status = isset( $_GET['status'] ) ? '&status=' . sanitize_text_field( wp_unslash( $_GET['status'] ) ) : '';
176
+		$status = isset($_GET['status']) ? '&status=' . sanitize_text_field(wp_unslash($_GET['status'])) : '';
177 177
 
178 178
 		// Redirect to webhooks page.
179
-		wp_safe_redirect( admin_url( 'admin.php?page=wc-settings&tab=advanced&section=webhooks' . $status . '&deleted=' . $qty ) );
179
+		wp_safe_redirect(admin_url('admin.php?page=wc-settings&tab=advanced&section=webhooks' . $status . '&deleted=' . $qty));
180 180
 		exit();
181 181
 	}
182 182
 
@@ -184,15 +184,15 @@  discard block
 block discarded – undo
184 184
 	 * Delete webhook.
185 185
 	 */
186 186
 	private function delete() {
187
-		check_admin_referer( 'delete-webhook' );
187
+		check_admin_referer('delete-webhook');
188 188
 
189 189
 		// phpcs:ignore WordPress.Security.NonceVerification.Recommended
190
-		if ( isset( $_GET['delete'] ) ) {
190
+		if (isset($_GET['delete'])) {
191 191
 			// phpcs:ignore WordPress.Security.NonceVerification.Recommended
192
-			$webhook_id = absint( $_GET['delete'] );
192
+			$webhook_id = absint($_GET['delete']);
193 193
 
194
-			if ( $webhook_id ) {
195
-				$this->bulk_delete( array( $webhook_id ) );
194
+			if ($webhook_id) {
195
+				$this->bulk_delete(array($webhook_id));
196 196
 			}
197 197
 		}
198 198
 	}
@@ -201,16 +201,16 @@  discard block
 block discarded – undo
201 201
 	 * Webhooks admin actions.
202 202
 	 */
203 203
 	public function actions() {
204
-		if ( $this->is_webhook_settings_page() ) {
204
+		if ($this->is_webhook_settings_page()) {
205 205
 			// Save.
206 206
 			// phpcs:ignore WordPress.Security.NonceVerification.Missing
207
-			if ( isset( $_POST['save'] ) && isset( $_POST['webhook_id'] ) ) {
207
+			if (isset($_POST['save']) && isset($_POST['webhook_id'])) {
208 208
 				$this->save();
209 209
 			}
210 210
 
211 211
 			// Delete webhook.
212 212
 			// phpcs:ignore WordPress.Security.NonceVerification.Recommended
213
-			if ( isset( $_GET['delete'] ) ) {
213
+			if (isset($_GET['delete'])) {
214 214
 				$this->delete();
215 215
 			}
216 216
 		}
@@ -224,10 +224,10 @@  discard block
 block discarded – undo
224 224
 		$GLOBALS['hide_save_button'] = true;
225 225
 
226 226
 		// phpcs:ignore WordPress.Security.NonceVerification.Recommended
227
-		if ( isset( $_GET['edit-webhook'] ) ) {
227
+		if (isset($_GET['edit-webhook'])) {
228 228
 			// phpcs:ignore WordPress.Security.NonceVerification.Recommended
229
-			$webhook_id = absint( $_GET['edit-webhook'] );
230
-			$webhook    = new WC_Webhook( $webhook_id );
229
+			$webhook_id = absint($_GET['edit-webhook']);
230
+			$webhook    = new WC_Webhook($webhook_id);
231 231
 
232 232
 			include __DIR__ . '/settings/views/html-webhooks-edit.php';
233 233
 			return;
@@ -241,29 +241,29 @@  discard block
 block discarded – undo
241 241
 	 */
242 242
 	public static function notices() {
243 243
 		// phpcs:ignore WordPress.Security.NonceVerification.Recommended
244
-		if ( isset( $_GET['deleted'] ) ) {
244
+		if (isset($_GET['deleted'])) {
245 245
 			// phpcs:ignore WordPress.Security.NonceVerification.Recommended
246
-			$deleted = absint( $_GET['deleted'] );
246
+			$deleted = absint($_GET['deleted']);
247 247
 
248 248
 			/* translators: %d: count */
249
-			WC_Admin_Settings::add_message( sprintf( _n( '%d webhook permanently deleted.', '%d webhooks permanently deleted.', $deleted, 'woocommerce' ), $deleted ) );
249
+			WC_Admin_Settings::add_message(sprintf(_n('%d webhook permanently deleted.', '%d webhooks permanently deleted.', $deleted, 'woocommerce'), $deleted));
250 250
 		}
251 251
 
252 252
 		// phpcs:ignore WordPress.Security.NonceVerification.Recommended
253
-		if ( isset( $_GET['updated'] ) ) {
254
-			WC_Admin_Settings::add_message( __( 'Webhook updated successfully.', 'woocommerce' ) );
253
+		if (isset($_GET['updated'])) {
254
+			WC_Admin_Settings::add_message(__('Webhook updated successfully.', 'woocommerce'));
255 255
 		}
256 256
 
257 257
 		// phpcs:ignore WordPress.Security.NonceVerification.Recommended
258
-		if ( isset( $_GET['created'] ) ) {
259
-			WC_Admin_Settings::add_message( __( 'Webhook created successfully.', 'woocommerce' ) );
258
+		if (isset($_GET['created'])) {
259
+			WC_Admin_Settings::add_message(__('Webhook created successfully.', 'woocommerce'));
260 260
 		}
261 261
 
262 262
 		// phpcs:ignore WordPress.Security.NonceVerification.Recommended
263
-		if ( isset( $_GET['error'] ) ) {
263
+		if (isset($_GET['error'])) {
264 264
 			// phpcs:ignore WordPress.Security.NonceVerification.Recommended
265
-			foreach ( explode( '|', sanitize_text_field( wp_unslash( $_GET['error'] ) ) ) as $message ) {
266
-				WC_Admin_Settings::add_error( trim( $message ) );
265
+			foreach (explode('|', sanitize_text_field(wp_unslash($_GET['error']))) as $message) {
266
+				WC_Admin_Settings::add_error(trim($message));
267 267
 			}
268 268
 		}
269 269
 	}
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 		global $webhooks_table_list;
276 276
 
277 277
 		// phpcs:ignore WordPress.Security.NonceVerification.Recommended
278
-		if ( ! isset( $_GET['edit-webhook'] ) && $this->is_webhook_settings_page() ) {
278
+		if (!isset($_GET['edit-webhook']) && $this->is_webhook_settings_page()) {
279 279
 			$webhooks_table_list = new WC_Admin_Webhooks_Table_List();
280 280
 
281 281
 			// Add screen option.
@@ -295,14 +295,14 @@  discard block
 block discarded – undo
295 295
 	private static function table_list_output() {
296 296
 		global $webhooks_table_list;
297 297
 
298
-		echo '<h2 class="wc-table-list-header">' . esc_html__( 'Webhooks', 'woocommerce' ) . ' <a href="' . esc_url( admin_url( 'admin.php?page=wc-settings&tab=advanced&section=webhooks&edit-webhook=0' ) ) . '" class="add-new-h2">' . esc_html__( 'Add webhook', 'woocommerce' ) . '</a></h2>';
298
+		echo '<h2 class="wc-table-list-header">' . esc_html__('Webhooks', 'woocommerce') . ' <a href="' . esc_url(admin_url('admin.php?page=wc-settings&tab=advanced&section=webhooks&edit-webhook=0')) . '" class="add-new-h2">' . esc_html__('Add webhook', 'woocommerce') . '</a></h2>';
299 299
 
300 300
 		// Get the webhooks count.
301
-		$data_store   = WC_Data_Store::load( 'webhook' );
301
+		$data_store   = WC_Data_Store::load('webhook');
302 302
 		$num_webhooks = $data_store->get_count_webhooks_by_status();
303
-		$count        = array_sum( $num_webhooks );
303
+		$count        = array_sum($num_webhooks);
304 304
 
305
-		if ( 0 < $count ) {
305
+		if (0 < $count) {
306 306
 			$webhooks_table_list->process_bulk_action();
307 307
 			$webhooks_table_list->prepare_items();
308 308
 
@@ -311,13 +311,13 @@  discard block
 block discarded – undo
311 311
 			echo '<input type="hidden" name="section" value="webhooks" />';
312 312
 
313 313
 			$webhooks_table_list->views();
314
-			$webhooks_table_list->search_box( __( 'Search webhooks', 'woocommerce' ), 'webhook' );
314
+			$webhooks_table_list->search_box(__('Search webhooks', 'woocommerce'), 'webhook');
315 315
 			$webhooks_table_list->display();
316 316
 		} else {
317 317
 			echo '<div class="woocommerce-BlankState woocommerce-BlankState--webhooks">';
318 318
 			?>
319
-			<h2 class="woocommerce-BlankState-message"><?php esc_html_e( 'Webhooks are event notifications sent to URLs of your choice. They can be used to integrate with third-party services which support them.', 'woocommerce' ); ?></h2>
320
-			<a class="woocommerce-BlankState-cta button-primary button" href="<?php echo esc_url( admin_url( 'admin.php?page=wc-settings&tab=advanced&section=webhooks&edit-webhook=0' ) ); ?>"><?php esc_html_e( 'Create a new webhook', 'woocommerce' ); ?></a>
319
+			<h2 class="woocommerce-BlankState-message"><?php esc_html_e('Webhooks are event notifications sent to URLs of your choice. They can be used to integrate with third-party services which support them.', 'woocommerce'); ?></h2>
320
+			<a class="woocommerce-BlankState-cta button-primary button" href="<?php echo esc_url(admin_url('admin.php?page=wc-settings&tab=advanced&section=webhooks&edit-webhook=0')); ?>"><?php esc_html_e('Create a new webhook', 'woocommerce'); ?></a>
321 321
 			<style type="text/css">#posts-filter .wp-list-table, #posts-filter .tablenav.top, .tablenav.bottom .actions { display: none; }</style>
322 322
 			<?php
323 323
 		}
@@ -329,8 +329,8 @@  discard block
 block discarded – undo
329 329
 	 * @deprecated 3.3.0
330 330
 	 * @param WC_Webhook $webhook Deprecated.
331 331
 	 */
332
-	public static function logs_output( $webhook = 'deprecated' ) {
333
-		wc_deprecated_function( 'WC_Admin_Webhooks::logs_output', '3.3' );
332
+	public static function logs_output($webhook = 'deprecated') {
333
+		wc_deprecated_function('WC_Admin_Webhooks::logs_output', '3.3');
334 334
 	}
335 335
 
336 336
 	/**
@@ -340,17 +340,17 @@  discard block
 block discarded – undo
340 340
 	 *
341 341
 	 * @return array
342 342
 	 */
343
-	public static function get_topic_data( $webhook ) {
343
+	public static function get_topic_data($webhook) {
344 344
 		$topic    = $webhook->get_topic();
345 345
 		$event    = '';
346 346
 		$resource = '';
347 347
 
348
-		if ( $topic ) {
349
-			list( $resource, $event ) = explode( '.', $topic );
348
+		if ($topic) {
349
+			list($resource, $event) = explode('.', $topic);
350 350
 
351
-			if ( 'action' === $resource ) {
351
+			if ('action' === $resource) {
352 352
 				$topic = 'action';
353
-			} elseif ( ! in_array( $resource, array( 'coupon', 'customer', 'order', 'product' ), true ) ) {
353
+			} elseif (!in_array($resource, array('coupon', 'customer', 'order', 'product'), true)) {
354 354
 				$topic = 'custom';
355 355
 			}
356 356
 		}
@@ -369,8 +369,8 @@  discard block
 block discarded – undo
369 369
 	 * @param int        $total Deprecated.
370 370
 	 * @param WC_Webhook $webhook Deprecated.
371 371
 	 */
372
-	public static function get_logs_navigation( $total, $webhook ) {
373
-		wc_deprecated_function( 'WC_Admin_Webhooks::get_logs_navigation', '3.3' );
372
+	public static function get_logs_navigation($total, $webhook) {
373
+		wc_deprecated_function('WC_Admin_Webhooks::get_logs_navigation', '3.3');
374 374
 	}
375 375
 }
376 376
 
Please login to merge, or discard this patch.
plugins/woocommerce/includes/admin/class-wc-admin-menus.php 2 patches
Indentation   +369 added lines, -369 removed lines patch added patch discarded remove patch
@@ -13,349 +13,349 @@  discard block
 block discarded – undo
13 13
 defined( 'ABSPATH' ) || exit;
14 14
 
15 15
 if ( class_exists( 'WC_Admin_Menus', false ) ) {
16
-	return new WC_Admin_Menus();
16
+    return new WC_Admin_Menus();
17 17
 }
18 18
 
19 19
 /**
20 20
  * WC_Admin_Menus Class.
21 21
  */
22 22
 class WC_Admin_Menus {
23
-	/**
24
-	 * @var Custom_Orders_List_Table
25
-	 */
26
-	private $orders_list_table;
27
-
28
-	/**
29
-	 * Hook in tabs.
30
-	 */
31
-	public function __construct() {
32
-		// Add menus.
33
-		add_action( 'admin_menu', array( $this, 'menu_highlight' ) );
34
-		add_action( 'admin_menu', array( $this, 'menu_order_count' ) );
35
-		add_action( 'admin_menu', array( $this, 'admin_menu' ), 9 );
36
-		add_action( 'admin_menu', array( $this, 'orders_menu' ), 9 );
37
-		add_action( 'admin_menu', array( $this, 'reports_menu' ), 20 );
38
-		add_action( 'admin_menu', array( $this, 'settings_menu' ), 50 );
39
-		add_action( 'admin_menu', array( $this, 'status_menu' ), 60 );
40
-
41
-		if ( apply_filters( 'woocommerce_show_addons_page', true ) ) {
42
-			add_action( 'admin_menu', array( $this, 'addons_menu' ), 70 );
43
-		}
44
-
45
-		add_filter( 'menu_order', array( $this, 'menu_order' ) );
46
-		add_filter( 'custom_menu_order', array( $this, 'custom_menu_order' ) );
47
-		add_filter( 'set-screen-option', array( $this, 'set_screen_option' ), 10, 3 );
48
-
49
-		// Add endpoints custom URLs in Appearance > Menus > Pages.
50
-		add_action( 'admin_head-nav-menus.php', array( $this, 'add_nav_menu_meta_boxes' ) );
51
-
52
-		// Admin bar menus.
53
-		if ( apply_filters( 'woocommerce_show_admin_bar_visit_store', true ) ) {
54
-			add_action( 'admin_bar_menu', array( $this, 'admin_bar_menus' ), 31 );
55
-		}
56
-
57
-		// Handle saving settings earlier than load-{page} hook to avoid race conditions in conditional menus.
58
-		add_action( 'wp_loaded', array( $this, 'save_settings' ) );
59
-	}
60
-
61
-	/**
62
-	 * Add menu items.
63
-	 */
64
-	public function admin_menu() {
65
-		global $menu;
66
-
67
-		$woocommerce_icon = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDI0IDEwMjQiPjxwYXRoIGZpbGw9IiNhMmFhYjIiIGQ9Ik02MTIuMTkyIDQyNi4zMzZjMC02Ljg5Ni0zLjEzNi01MS42LTI4LTUxLjYtMzcuMzYgMC00Ni43MDQgNzIuMjU2LTQ2LjcwNCA4Mi42MjQgMCAzLjQwOCAzLjE1MiA1OC40OTYgMjguMDMyIDU4LjQ5NiAzNC4xOTItLjAzMiA0Ni42NzItNzIuMjg4IDQ2LjY3Mi04OS41MnptMjAyLjE5MiAwYzAtNi44OTYtMy4xNTItNTEuNi0yOC4wMzItNTEuNi0zNy4yOCAwLTQ2LjYwOCA3Mi4yNTYtNDYuNjA4IDgyLjYyNCAwIDMuNDA4IDMuMDcyIDU4LjQ5NiAyNy45NTIgNTguNDk2IDM0LjE5Mi0uMDMyIDQ2LjY4OC03Mi4yODggNDYuNjg4LTg5LjUyek0xNDEuMjk2Ljc2OGMtNjguMjI0IDAtMTIzLjUwNCA1NS40ODgtMTIzLjUwNCAxMjMuOTJ2NjUwLjcyYzAgNjguNDMyIDU1LjI5NiAxMjMuOTIgMTIzLjUwNCAxMjMuOTJoMzM5LjgwOGwxMjMuNTA0IDEyMy45MzZWODk5LjMyOGgyNzguMDQ4YzY4LjIyNCAwIDEyMy41Mi01NS40NzIgMTIzLjUyLTEyMy45MnYtNjUwLjcyYzAtNjguNDMyLTU1LjI5Ni0xMjMuOTItMTIzLjUyLTEyMy45MmgtNzQxLjM2em01MjYuODY0IDQyMi4xNmMwIDU1LjA4OC0zMS4wODggMTU0Ljg4LTEwMi42NCAxNTQuODgtNi4yMDggMC0xOC40OTYtMy42MTYtMjUuNDI0LTYuMDE2LTMyLjUxMi0xMS4xNjgtNTAuMTkyLTQ5LjY5Ni01Mi4zNTItNjYuMjU2IDAgMC0zLjA3Mi0xNy43OTItMy4wNzItNDAuNzUyIDAtMjIuOTkyIDMuMDcyLTQ1LjMyOCAzLjA3Mi00NS4zMjggMTUuNTUyLTc1LjcyOCA0My41NTItMTA2LjczNiA5Ni40NDgtMTA2LjczNiA1OS4wNzItLjAzMiA4My45NjggNTguNTI4IDgzLjk2OCAxMTAuMjA4ek00ODYuNDk2IDMwMi40YzAgMy4zOTItNDMuNTUyIDE0MS4xNjgtNDMuNTUyIDIxMy40MjR2NzUuNzEyYy0yLjU5MiAxMi4wOC00LjE2IDI0LjE0NC0yMS44MjQgMjQuMTQ0LTQ2LjYwOCAwLTg4Ljg4LTE1MS40NzItOTIuMDE2LTE2MS44NC02LjIwOCA2Ljg5Ni02Mi4yNCAxNjEuODQtOTYuNDQ4IDE2MS44NC0yNC44NjQgMC00My41NTItMTEzLjY0OC00Ni42MDgtMTIzLjkzNkMxNzYuNzA0IDQzNi42NzIgMTYwIDMzNC4yMjQgMTYwIDMyNy4zMjhjMC0yMC42NzIgMS4xNTItMzguNzM2IDI2LjA0OC0zOC43MzYgNi4yMDggMCAyMS42IDYuMDY0IDIzLjcxMiAxNy4xNjggMTEuNjQ4IDYyLjAzMiAxNi42ODggMTIwLjUxMiAyOS4xNjggMTg1Ljk2OCAxLjg1NiAyLjkyOCAxLjUwNCA3LjAwOCA0LjU2IDEwLjQzMiAzLjE1Mi0xMC4yODggNjYuOTI4LTE2OC43ODQgOTQuOTYtMTY4Ljc4NCAyMi41NDQgMCAzMC40IDQ0LjU5MiAzMy41MzYgNjEuODI0IDYuMjA4IDIwLjY1NiAxMy4wODggNTUuMjE2IDIyLjQxNiA4Mi43NTIgMC0xMy43NzYgMTIuNDgtMjAzLjEyIDY1LjM5Mi0yMDMuMTIgMTguNTkyLjAzMiAyNi43MDQgNi45MjggMjYuNzA0IDI3LjU2OHpNODcwLjMyIDQyMi45MjhjMCA1NS4wODgtMzEuMDg4IDE1NC44OC0xMDIuNjQgMTU0Ljg4LTYuMTkyIDAtMTguNDQ4LTMuNjE2LTI1LjQyNC02LjAxNi0zMi40MzItMTEuMTY4LTUwLjE3Ni00OS42OTYtNTIuMjg4LTY2LjI1NiAwIDAtMy44ODgtMTcuOTItMy44ODgtNDAuODk2czMuODg4LTQ1LjE4NCAzLjg4OC00NS4xODRjMTUuNTUyLTc1LjcyOCA0My40ODgtMTA2LjczNiA5Ni4zODQtMTA2LjczNiA1OS4xMDQtLjAzMiA4My45NjggNTguNTI4IDgzLjk2OCAxMTAuMjA4eiIvPjwvc3ZnPg==';
68
-
69
-		if ( self::can_view_woocommerce_menu_item() ) {
70
-			$menu[] = array( '', 'read', 'separator-woocommerce', '', 'wp-menu-separator woocommerce' ); // WPCS: override ok.
71
-		}
72
-
73
-		add_menu_page( __( 'WooCommerce', 'woocommerce' ), __( 'WooCommerce', 'woocommerce' ), 'edit_others_shop_orders', 'woocommerce', null, $woocommerce_icon, '55.5' );
74
-
75
-		add_submenu_page( 'edit.php?post_type=product', __( 'Attributes', 'woocommerce' ), __( 'Attributes', 'woocommerce' ), 'manage_product_terms', 'product_attributes', array( $this, 'attributes_page' ) );
76
-	}
77
-
78
-	/**
79
-	 * Add menu item.
80
-	 */
81
-	public function reports_menu() {
82
-		if ( self::can_view_woocommerce_menu_item() ) {
83
-			add_submenu_page( 'woocommerce', __( 'Reports', 'woocommerce' ), __( 'Reports', 'woocommerce' ), 'view_woocommerce_reports', 'wc-reports', array( $this, 'reports_page' ) );
84
-		} else {
85
-			add_menu_page( __( 'Sales reports', 'woocommerce' ), __( 'Sales reports', 'woocommerce' ), 'view_woocommerce_reports', 'wc-reports', array( $this, 'reports_page' ), 'dashicons-chart-bar', '55.6' );
86
-		}
87
-	}
88
-
89
-	/**
90
-	 * Add menu item.
91
-	 */
92
-	public function settings_menu() {
93
-		$settings_page = add_submenu_page( 'woocommerce', __( 'WooCommerce settings', 'woocommerce' ), __( 'Settings', 'woocommerce' ), 'manage_woocommerce', 'wc-settings', array( $this, 'settings_page' ) );
94
-
95
-		add_action( 'load-' . $settings_page, array( $this, 'settings_page_init' ) );
96
-	}
97
-
98
-	/**
99
-	 * Check if the user can access the top-level WooCommerce item.
100
-	 */
101
-	public static function can_view_woocommerce_menu_item() {
102
-		return current_user_can( 'edit_others_shop_orders' );
103
-	}
104
-
105
-	/**
106
-	 * Loads gateways and shipping methods into memory for use within settings.
107
-	 */
108
-	public function settings_page_init() {
109
-		WC()->payment_gateways();
110
-		WC()->shipping();
111
-
112
-		// Include settings pages.
113
-		WC_Admin_Settings::get_settings_pages();
114
-
115
-		// Add any posted messages.
116
-		if ( ! empty( $_GET['wc_error'] ) ) { // WPCS: input var okay, CSRF ok.
117
-			WC_Admin_Settings::add_error( wp_kses_post( wp_unslash( $_GET['wc_error'] ) ) ); // WPCS: input var okay, CSRF ok.
118
-		}
119
-
120
-		if ( ! empty( $_GET['wc_message'] ) ) { // WPCS: input var okay, CSRF ok.
121
-			WC_Admin_Settings::add_message( wp_kses_post( wp_unslash( $_GET['wc_message'] ) ) ); // WPCS: input var okay, CSRF ok.
122
-		}
123
-
124
-		do_action( 'woocommerce_settings_page_init' );
125
-	}
126
-
127
-	/**
128
-	 * Handle saving of settings.
129
-	 *
130
-	 * @return void
131
-	 */
132
-	public function save_settings() {
133
-		global $current_tab, $current_section;
134
-
135
-		// We should only save on the settings page.
136
-		if ( ! is_admin() || ! isset( $_GET['page'] ) || 'wc-settings' !== $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
137
-			return;
138
-		}
139
-
140
-		// Include settings pages.
141
-		WC_Admin_Settings::get_settings_pages();
142
-
143
-		// Get current tab/section.
144
-		$current_tab     = empty( $_GET['tab'] ) ? 'general' : sanitize_title( wp_unslash( $_GET['tab'] ) ); // WPCS: input var okay, CSRF ok.
145
-		$current_section = empty( $_REQUEST['section'] ) ? '' : sanitize_title( wp_unslash( $_REQUEST['section'] ) ); // WPCS: input var okay, CSRF ok.
146
-
147
-		// Save settings if data has been posted.
148
-		if ( '' !== $current_section && apply_filters( "woocommerce_save_settings_{$current_tab}_{$current_section}", ! empty( $_POST['save'] ) ) ) { // WPCS: input var okay, CSRF ok.
149
-			WC_Admin_Settings::save();
150
-		} elseif ( '' === $current_section && apply_filters( "woocommerce_save_settings_{$current_tab}", ! empty( $_POST['save'] ) ) ) { // WPCS: input var okay, CSRF ok.
151
-			WC_Admin_Settings::save();
152
-		}
153
-	}
154
-
155
-	/**
156
-	 * Add menu item.
157
-	 */
158
-	public function status_menu() {
159
-		add_submenu_page( 'woocommerce', __( 'WooCommerce status', 'woocommerce' ), __( 'Status', 'woocommerce' ), 'manage_woocommerce', 'wc-status', array( $this, 'status_page' ) );
160
-	}
161
-
162
-	/**
163
-	 * Addons menu item.
164
-	 */
165
-	public function addons_menu() {
166
-		$count_html = WC_Helper_Updater::get_updates_count_html();
167
-		/* translators: %s: extensions count */
168
-		$menu_title = sprintf( __( 'Extensions %s', 'woocommerce' ), $count_html );
169
-		add_submenu_page( 'woocommerce', __( 'WooCommerce extensions', 'woocommerce' ), $menu_title, 'manage_woocommerce', 'wc-addons', array( $this, 'addons_page' ) );
170
-	}
171
-
172
-	/**
173
-	 * Highlights the correct top level admin menu item for post type add screens.
174
-	 */
175
-	public function menu_highlight() {
176
-		global $parent_file, $submenu_file, $post_type;
177
-
178
-		switch ( $post_type ) {
179
-			case 'shop_order':
180
-			case 'shop_coupon':
181
-				$parent_file = 'woocommerce'; // WPCS: override ok.
182
-				break;
183
-			case 'product':
184
-				$screen = get_current_screen();
185
-				if ( $screen && taxonomy_is_product_attribute( $screen->taxonomy ) ) {
186
-					$submenu_file = 'product_attributes'; // WPCS: override ok.
187
-					$parent_file  = 'edit.php?post_type=product'; // WPCS: override ok.
188
-				}
189
-				break;
190
-		}
191
-	}
192
-
193
-	/**
194
-	 * Adds the order processing count to the menu.
195
-	 */
196
-	public function menu_order_count() {
197
-		global $submenu;
198
-
199
-		if ( isset( $submenu['woocommerce'] ) ) {
200
-			// Remove 'WooCommerce' sub menu item.
201
-			unset( $submenu['woocommerce'][0] );
202
-
203
-			// Add count if user has access.
204
-			if ( apply_filters( 'woocommerce_include_processing_order_count_in_menu', true ) && current_user_can( 'edit_others_shop_orders' ) ) {
205
-				$order_count = apply_filters( 'woocommerce_menu_order_count', wc_processing_order_count() );
206
-
207
-				if ( $order_count ) {
208
-					foreach ( $submenu['woocommerce'] as $key => $menu_item ) {
209
-						if ( 0 === strpos( $menu_item[0], _x( 'Orders', 'Admin menu name', 'woocommerce' ) ) ) {
210
-							$submenu['woocommerce'][ $key ][0] .= ' <span class="awaiting-mod update-plugins count-' . esc_attr( $order_count ) . '"><span class="processing-count">' . number_format_i18n( $order_count ) . '</span></span>'; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
211
-							break;
212
-						}
213
-					}
214
-				}
215
-			}
216
-		}
217
-	}
218
-
219
-	/**
220
-	 * Reorder the WC menu items in admin.
221
-	 *
222
-	 * @param int $menu_order Menu order.
223
-	 * @return array
224
-	 */
225
-	public function menu_order( $menu_order ) {
226
-		// Initialize our custom order array.
227
-		$woocommerce_menu_order = array();
228
-
229
-		// Get the index of our custom separator.
230
-		$woocommerce_separator = array_search( 'separator-woocommerce', $menu_order, true );
231
-
232
-		// Get index of product menu.
233
-		$woocommerce_product = array_search( 'edit.php?post_type=product', $menu_order, true );
234
-
235
-		// Loop through menu order and do some rearranging.
236
-		foreach ( $menu_order as $index => $item ) {
237
-
238
-			if ( 'woocommerce' === $item ) {
239
-				$woocommerce_menu_order[] = 'separator-woocommerce';
240
-				$woocommerce_menu_order[] = $item;
241
-				$woocommerce_menu_order[] = 'edit.php?post_type=product';
242
-				unset( $menu_order[ $woocommerce_separator ] );
243
-				unset( $menu_order[ $woocommerce_product ] );
244
-			} elseif ( ! in_array( $item, array( 'separator-woocommerce' ), true ) ) {
245
-				$woocommerce_menu_order[] = $item;
246
-			}
247
-		}
248
-
249
-		// Return order.
250
-		return $woocommerce_menu_order;
251
-	}
252
-
253
-	/**
254
-	 * Custom menu order.
255
-	 *
256
-	 * @param bool $enabled Whether custom menu ordering is already enabled.
257
-	 * @return bool
258
-	 */
259
-	public function custom_menu_order( $enabled ) {
260
-		return $enabled || self::can_view_woocommerce_menu_item();
261
-	}
262
-
263
-	/**
264
-	 * Validate screen options on update.
265
-	 *
266
-	 * @param bool|int $status Screen option value. Default false to skip.
267
-	 * @param string   $option The option name.
268
-	 * @param int      $value  The number of rows to use.
269
-	 */
270
-	public function set_screen_option( $status, $option, $value ) {
271
-		if ( in_array( $option, array( 'woocommerce_keys_per_page', 'woocommerce_webhooks_per_page' ), true ) ) {
272
-			return $value;
273
-		}
274
-
275
-		return $status;
276
-	}
277
-
278
-	/**
279
-	 * Init the reports page.
280
-	 */
281
-	public function reports_page() {
282
-		WC_Admin_Reports::output();
283
-	}
284
-
285
-	/**
286
-	 * Init the settings page.
287
-	 */
288
-	public function settings_page() {
289
-		WC_Admin_Settings::output();
290
-	}
291
-
292
-	/**
293
-	 * Init the attributes page.
294
-	 */
295
-	public function attributes_page() {
296
-		WC_Admin_Attributes::output();
297
-	}
298
-
299
-	/**
300
-	 * Init the status page.
301
-	 */
302
-	public function status_page() {
303
-		WC_Admin_Status::output();
304
-	}
305
-
306
-	/**
307
-	 * Init the addons page.
308
-	 */
309
-	public function addons_page() {
310
-		WC_Admin_Addons::output();
311
-	}
312
-
313
-	/**
314
-	 * Link to the order admin list table from the main WooCommerce menu.
315
-	 *
316
-	 * @return void
317
-	 */
318
-	public function orders_menu(): void {
319
-		if ( wc_get_container()->get( CustomOrdersTableController::class )->custom_orders_table_usage_is_enabled() ) {
320
-			$this->orders_page_controller = new Custom_Orders_PageController();
321
-			$this->orders_page_controller->setup();
322
-		}
323
-	}
324
-
325
-	/**
326
-	 * Add custom nav meta box.
327
-	 *
328
-	 * Adapted from http://www.johnmorrisonline.com/how-to-add-a-fully-functional-custom-meta-box-to-wordpress-navigation-menus/.
329
-	 */
330
-	public function add_nav_menu_meta_boxes() {
331
-		add_meta_box( 'woocommerce_endpoints_nav_link', __( 'WooCommerce endpoints', 'woocommerce' ), array( $this, 'nav_menu_links' ), 'nav-menus', 'side', 'low' );
332
-	}
333
-
334
-	/**
335
-	 * Output menu links.
336
-	 */
337
-	public function nav_menu_links() {
338
-		// Get items from account menu.
339
-		$endpoints = wc_get_account_menu_items();
340
-
341
-		// Remove dashboard item.
342
-		if ( isset( $endpoints['dashboard'] ) ) {
343
-			unset( $endpoints['dashboard'] );
344
-		}
345
-
346
-		// Include missing lost password.
347
-		$endpoints['lost-password'] = __( 'Lost password', 'woocommerce' );
348
-
349
-		$endpoints = apply_filters( 'woocommerce_custom_nav_menu_items', $endpoints );
350
-
351
-		?>
23
+    /**
24
+     * @var Custom_Orders_List_Table
25
+     */
26
+    private $orders_list_table;
27
+
28
+    /**
29
+     * Hook in tabs.
30
+     */
31
+    public function __construct() {
32
+        // Add menus.
33
+        add_action( 'admin_menu', array( $this, 'menu_highlight' ) );
34
+        add_action( 'admin_menu', array( $this, 'menu_order_count' ) );
35
+        add_action( 'admin_menu', array( $this, 'admin_menu' ), 9 );
36
+        add_action( 'admin_menu', array( $this, 'orders_menu' ), 9 );
37
+        add_action( 'admin_menu', array( $this, 'reports_menu' ), 20 );
38
+        add_action( 'admin_menu', array( $this, 'settings_menu' ), 50 );
39
+        add_action( 'admin_menu', array( $this, 'status_menu' ), 60 );
40
+
41
+        if ( apply_filters( 'woocommerce_show_addons_page', true ) ) {
42
+            add_action( 'admin_menu', array( $this, 'addons_menu' ), 70 );
43
+        }
44
+
45
+        add_filter( 'menu_order', array( $this, 'menu_order' ) );
46
+        add_filter( 'custom_menu_order', array( $this, 'custom_menu_order' ) );
47
+        add_filter( 'set-screen-option', array( $this, 'set_screen_option' ), 10, 3 );
48
+
49
+        // Add endpoints custom URLs in Appearance > Menus > Pages.
50
+        add_action( 'admin_head-nav-menus.php', array( $this, 'add_nav_menu_meta_boxes' ) );
51
+
52
+        // Admin bar menus.
53
+        if ( apply_filters( 'woocommerce_show_admin_bar_visit_store', true ) ) {
54
+            add_action( 'admin_bar_menu', array( $this, 'admin_bar_menus' ), 31 );
55
+        }
56
+
57
+        // Handle saving settings earlier than load-{page} hook to avoid race conditions in conditional menus.
58
+        add_action( 'wp_loaded', array( $this, 'save_settings' ) );
59
+    }
60
+
61
+    /**
62
+     * Add menu items.
63
+     */
64
+    public function admin_menu() {
65
+        global $menu;
66
+
67
+        $woocommerce_icon = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDI0IDEwMjQiPjxwYXRoIGZpbGw9IiNhMmFhYjIiIGQ9Ik02MTIuMTkyIDQyNi4zMzZjMC02Ljg5Ni0zLjEzNi01MS42LTI4LTUxLjYtMzcuMzYgMC00Ni43MDQgNzIuMjU2LTQ2LjcwNCA4Mi42MjQgMCAzLjQwOCAzLjE1MiA1OC40OTYgMjguMDMyIDU4LjQ5NiAzNC4xOTItLjAzMiA0Ni42NzItNzIuMjg4IDQ2LjY3Mi04OS41MnptMjAyLjE5MiAwYzAtNi44OTYtMy4xNTItNTEuNi0yOC4wMzItNTEuNi0zNy4yOCAwLTQ2LjYwOCA3Mi4yNTYtNDYuNjA4IDgyLjYyNCAwIDMuNDA4IDMuMDcyIDU4LjQ5NiAyNy45NTIgNTguNDk2IDM0LjE5Mi0uMDMyIDQ2LjY4OC03Mi4yODggNDYuNjg4LTg5LjUyek0xNDEuMjk2Ljc2OGMtNjguMjI0IDAtMTIzLjUwNCA1NS40ODgtMTIzLjUwNCAxMjMuOTJ2NjUwLjcyYzAgNjguNDMyIDU1LjI5NiAxMjMuOTIgMTIzLjUwNCAxMjMuOTJoMzM5LjgwOGwxMjMuNTA0IDEyMy45MzZWODk5LjMyOGgyNzguMDQ4YzY4LjIyNCAwIDEyMy41Mi01NS40NzIgMTIzLjUyLTEyMy45MnYtNjUwLjcyYzAtNjguNDMyLTU1LjI5Ni0xMjMuOTItMTIzLjUyLTEyMy45MmgtNzQxLjM2em01MjYuODY0IDQyMi4xNmMwIDU1LjA4OC0zMS4wODggMTU0Ljg4LTEwMi42NCAxNTQuODgtNi4yMDggMC0xOC40OTYtMy42MTYtMjUuNDI0LTYuMDE2LTMyLjUxMi0xMS4xNjgtNTAuMTkyLTQ5LjY5Ni01Mi4zNTItNjYuMjU2IDAgMC0zLjA3Mi0xNy43OTItMy4wNzItNDAuNzUyIDAtMjIuOTkyIDMuMDcyLTQ1LjMyOCAzLjA3Mi00NS4zMjggMTUuNTUyLTc1LjcyOCA0My41NTItMTA2LjczNiA5Ni40NDgtMTA2LjczNiA1OS4wNzItLjAzMiA4My45NjggNTguNTI4IDgzLjk2OCAxMTAuMjA4ek00ODYuNDk2IDMwMi40YzAgMy4zOTItNDMuNTUyIDE0MS4xNjgtNDMuNTUyIDIxMy40MjR2NzUuNzEyYy0yLjU5MiAxMi4wOC00LjE2IDI0LjE0NC0yMS44MjQgMjQuMTQ0LTQ2LjYwOCAwLTg4Ljg4LTE1MS40NzItOTIuMDE2LTE2MS44NC02LjIwOCA2Ljg5Ni02Mi4yNCAxNjEuODQtOTYuNDQ4IDE2MS44NC0yNC44NjQgMC00My41NTItMTEzLjY0OC00Ni42MDgtMTIzLjkzNkMxNzYuNzA0IDQzNi42NzIgMTYwIDMzNC4yMjQgMTYwIDMyNy4zMjhjMC0yMC42NzIgMS4xNTItMzguNzM2IDI2LjA0OC0zOC43MzYgNi4yMDggMCAyMS42IDYuMDY0IDIzLjcxMiAxNy4xNjggMTEuNjQ4IDYyLjAzMiAxNi42ODggMTIwLjUxMiAyOS4xNjggMTg1Ljk2OCAxLjg1NiAyLjkyOCAxLjUwNCA3LjAwOCA0LjU2IDEwLjQzMiAzLjE1Mi0xMC4yODggNjYuOTI4LTE2OC43ODQgOTQuOTYtMTY4Ljc4NCAyMi41NDQgMCAzMC40IDQ0LjU5MiAzMy41MzYgNjEuODI0IDYuMjA4IDIwLjY1NiAxMy4wODggNTUuMjE2IDIyLjQxNiA4Mi43NTIgMC0xMy43NzYgMTIuNDgtMjAzLjEyIDY1LjM5Mi0yMDMuMTIgMTguNTkyLjAzMiAyNi43MDQgNi45MjggMjYuNzA0IDI3LjU2OHpNODcwLjMyIDQyMi45MjhjMCA1NS4wODgtMzEuMDg4IDE1NC44OC0xMDIuNjQgMTU0Ljg4LTYuMTkyIDAtMTguNDQ4LTMuNjE2LTI1LjQyNC02LjAxNi0zMi40MzItMTEuMTY4LTUwLjE3Ni00OS42OTYtNTIuMjg4LTY2LjI1NiAwIDAtMy44ODgtMTcuOTItMy44ODgtNDAuODk2czMuODg4LTQ1LjE4NCAzLjg4OC00NS4xODRjMTUuNTUyLTc1LjcyOCA0My40ODgtMTA2LjczNiA5Ni4zODQtMTA2LjczNiA1OS4xMDQtLjAzMiA4My45NjggNTguNTI4IDgzLjk2OCAxMTAuMjA4eiIvPjwvc3ZnPg==';
68
+
69
+        if ( self::can_view_woocommerce_menu_item() ) {
70
+            $menu[] = array( '', 'read', 'separator-woocommerce', '', 'wp-menu-separator woocommerce' ); // WPCS: override ok.
71
+        }
72
+
73
+        add_menu_page( __( 'WooCommerce', 'woocommerce' ), __( 'WooCommerce', 'woocommerce' ), 'edit_others_shop_orders', 'woocommerce', null, $woocommerce_icon, '55.5' );
74
+
75
+        add_submenu_page( 'edit.php?post_type=product', __( 'Attributes', 'woocommerce' ), __( 'Attributes', 'woocommerce' ), 'manage_product_terms', 'product_attributes', array( $this, 'attributes_page' ) );
76
+    }
77
+
78
+    /**
79
+     * Add menu item.
80
+     */
81
+    public function reports_menu() {
82
+        if ( self::can_view_woocommerce_menu_item() ) {
83
+            add_submenu_page( 'woocommerce', __( 'Reports', 'woocommerce' ), __( 'Reports', 'woocommerce' ), 'view_woocommerce_reports', 'wc-reports', array( $this, 'reports_page' ) );
84
+        } else {
85
+            add_menu_page( __( 'Sales reports', 'woocommerce' ), __( 'Sales reports', 'woocommerce' ), 'view_woocommerce_reports', 'wc-reports', array( $this, 'reports_page' ), 'dashicons-chart-bar', '55.6' );
86
+        }
87
+    }
88
+
89
+    /**
90
+     * Add menu item.
91
+     */
92
+    public function settings_menu() {
93
+        $settings_page = add_submenu_page( 'woocommerce', __( 'WooCommerce settings', 'woocommerce' ), __( 'Settings', 'woocommerce' ), 'manage_woocommerce', 'wc-settings', array( $this, 'settings_page' ) );
94
+
95
+        add_action( 'load-' . $settings_page, array( $this, 'settings_page_init' ) );
96
+    }
97
+
98
+    /**
99
+     * Check if the user can access the top-level WooCommerce item.
100
+     */
101
+    public static function can_view_woocommerce_menu_item() {
102
+        return current_user_can( 'edit_others_shop_orders' );
103
+    }
104
+
105
+    /**
106
+     * Loads gateways and shipping methods into memory for use within settings.
107
+     */
108
+    public function settings_page_init() {
109
+        WC()->payment_gateways();
110
+        WC()->shipping();
111
+
112
+        // Include settings pages.
113
+        WC_Admin_Settings::get_settings_pages();
114
+
115
+        // Add any posted messages.
116
+        if ( ! empty( $_GET['wc_error'] ) ) { // WPCS: input var okay, CSRF ok.
117
+            WC_Admin_Settings::add_error( wp_kses_post( wp_unslash( $_GET['wc_error'] ) ) ); // WPCS: input var okay, CSRF ok.
118
+        }
119
+
120
+        if ( ! empty( $_GET['wc_message'] ) ) { // WPCS: input var okay, CSRF ok.
121
+            WC_Admin_Settings::add_message( wp_kses_post( wp_unslash( $_GET['wc_message'] ) ) ); // WPCS: input var okay, CSRF ok.
122
+        }
123
+
124
+        do_action( 'woocommerce_settings_page_init' );
125
+    }
126
+
127
+    /**
128
+     * Handle saving of settings.
129
+     *
130
+     * @return void
131
+     */
132
+    public function save_settings() {
133
+        global $current_tab, $current_section;
134
+
135
+        // We should only save on the settings page.
136
+        if ( ! is_admin() || ! isset( $_GET['page'] ) || 'wc-settings' !== $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
137
+            return;
138
+        }
139
+
140
+        // Include settings pages.
141
+        WC_Admin_Settings::get_settings_pages();
142
+
143
+        // Get current tab/section.
144
+        $current_tab     = empty( $_GET['tab'] ) ? 'general' : sanitize_title( wp_unslash( $_GET['tab'] ) ); // WPCS: input var okay, CSRF ok.
145
+        $current_section = empty( $_REQUEST['section'] ) ? '' : sanitize_title( wp_unslash( $_REQUEST['section'] ) ); // WPCS: input var okay, CSRF ok.
146
+
147
+        // Save settings if data has been posted.
148
+        if ( '' !== $current_section && apply_filters( "woocommerce_save_settings_{$current_tab}_{$current_section}", ! empty( $_POST['save'] ) ) ) { // WPCS: input var okay, CSRF ok.
149
+            WC_Admin_Settings::save();
150
+        } elseif ( '' === $current_section && apply_filters( "woocommerce_save_settings_{$current_tab}", ! empty( $_POST['save'] ) ) ) { // WPCS: input var okay, CSRF ok.
151
+            WC_Admin_Settings::save();
152
+        }
153
+    }
154
+
155
+    /**
156
+     * Add menu item.
157
+     */
158
+    public function status_menu() {
159
+        add_submenu_page( 'woocommerce', __( 'WooCommerce status', 'woocommerce' ), __( 'Status', 'woocommerce' ), 'manage_woocommerce', 'wc-status', array( $this, 'status_page' ) );
160
+    }
161
+
162
+    /**
163
+     * Addons menu item.
164
+     */
165
+    public function addons_menu() {
166
+        $count_html = WC_Helper_Updater::get_updates_count_html();
167
+        /* translators: %s: extensions count */
168
+        $menu_title = sprintf( __( 'Extensions %s', 'woocommerce' ), $count_html );
169
+        add_submenu_page( 'woocommerce', __( 'WooCommerce extensions', 'woocommerce' ), $menu_title, 'manage_woocommerce', 'wc-addons', array( $this, 'addons_page' ) );
170
+    }
171
+
172
+    /**
173
+     * Highlights the correct top level admin menu item for post type add screens.
174
+     */
175
+    public function menu_highlight() {
176
+        global $parent_file, $submenu_file, $post_type;
177
+
178
+        switch ( $post_type ) {
179
+            case 'shop_order':
180
+            case 'shop_coupon':
181
+                $parent_file = 'woocommerce'; // WPCS: override ok.
182
+                break;
183
+            case 'product':
184
+                $screen = get_current_screen();
185
+                if ( $screen && taxonomy_is_product_attribute( $screen->taxonomy ) ) {
186
+                    $submenu_file = 'product_attributes'; // WPCS: override ok.
187
+                    $parent_file  = 'edit.php?post_type=product'; // WPCS: override ok.
188
+                }
189
+                break;
190
+        }
191
+    }
192
+
193
+    /**
194
+     * Adds the order processing count to the menu.
195
+     */
196
+    public function menu_order_count() {
197
+        global $submenu;
198
+
199
+        if ( isset( $submenu['woocommerce'] ) ) {
200
+            // Remove 'WooCommerce' sub menu item.
201
+            unset( $submenu['woocommerce'][0] );
202
+
203
+            // Add count if user has access.
204
+            if ( apply_filters( 'woocommerce_include_processing_order_count_in_menu', true ) && current_user_can( 'edit_others_shop_orders' ) ) {
205
+                $order_count = apply_filters( 'woocommerce_menu_order_count', wc_processing_order_count() );
206
+
207
+                if ( $order_count ) {
208
+                    foreach ( $submenu['woocommerce'] as $key => $menu_item ) {
209
+                        if ( 0 === strpos( $menu_item[0], _x( 'Orders', 'Admin menu name', 'woocommerce' ) ) ) {
210
+                            $submenu['woocommerce'][ $key ][0] .= ' <span class="awaiting-mod update-plugins count-' . esc_attr( $order_count ) . '"><span class="processing-count">' . number_format_i18n( $order_count ) . '</span></span>'; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
211
+                            break;
212
+                        }
213
+                    }
214
+                }
215
+            }
216
+        }
217
+    }
218
+
219
+    /**
220
+     * Reorder the WC menu items in admin.
221
+     *
222
+     * @param int $menu_order Menu order.
223
+     * @return array
224
+     */
225
+    public function menu_order( $menu_order ) {
226
+        // Initialize our custom order array.
227
+        $woocommerce_menu_order = array();
228
+
229
+        // Get the index of our custom separator.
230
+        $woocommerce_separator = array_search( 'separator-woocommerce', $menu_order, true );
231
+
232
+        // Get index of product menu.
233
+        $woocommerce_product = array_search( 'edit.php?post_type=product', $menu_order, true );
234
+
235
+        // Loop through menu order and do some rearranging.
236
+        foreach ( $menu_order as $index => $item ) {
237
+
238
+            if ( 'woocommerce' === $item ) {
239
+                $woocommerce_menu_order[] = 'separator-woocommerce';
240
+                $woocommerce_menu_order[] = $item;
241
+                $woocommerce_menu_order[] = 'edit.php?post_type=product';
242
+                unset( $menu_order[ $woocommerce_separator ] );
243
+                unset( $menu_order[ $woocommerce_product ] );
244
+            } elseif ( ! in_array( $item, array( 'separator-woocommerce' ), true ) ) {
245
+                $woocommerce_menu_order[] = $item;
246
+            }
247
+        }
248
+
249
+        // Return order.
250
+        return $woocommerce_menu_order;
251
+    }
252
+
253
+    /**
254
+     * Custom menu order.
255
+     *
256
+     * @param bool $enabled Whether custom menu ordering is already enabled.
257
+     * @return bool
258
+     */
259
+    public function custom_menu_order( $enabled ) {
260
+        return $enabled || self::can_view_woocommerce_menu_item();
261
+    }
262
+
263
+    /**
264
+     * Validate screen options on update.
265
+     *
266
+     * @param bool|int $status Screen option value. Default false to skip.
267
+     * @param string   $option The option name.
268
+     * @param int      $value  The number of rows to use.
269
+     */
270
+    public function set_screen_option( $status, $option, $value ) {
271
+        if ( in_array( $option, array( 'woocommerce_keys_per_page', 'woocommerce_webhooks_per_page' ), true ) ) {
272
+            return $value;
273
+        }
274
+
275
+        return $status;
276
+    }
277
+
278
+    /**
279
+     * Init the reports page.
280
+     */
281
+    public function reports_page() {
282
+        WC_Admin_Reports::output();
283
+    }
284
+
285
+    /**
286
+     * Init the settings page.
287
+     */
288
+    public function settings_page() {
289
+        WC_Admin_Settings::output();
290
+    }
291
+
292
+    /**
293
+     * Init the attributes page.
294
+     */
295
+    public function attributes_page() {
296
+        WC_Admin_Attributes::output();
297
+    }
298
+
299
+    /**
300
+     * Init the status page.
301
+     */
302
+    public function status_page() {
303
+        WC_Admin_Status::output();
304
+    }
305
+
306
+    /**
307
+     * Init the addons page.
308
+     */
309
+    public function addons_page() {
310
+        WC_Admin_Addons::output();
311
+    }
312
+
313
+    /**
314
+     * Link to the order admin list table from the main WooCommerce menu.
315
+     *
316
+     * @return void
317
+     */
318
+    public function orders_menu(): void {
319
+        if ( wc_get_container()->get( CustomOrdersTableController::class )->custom_orders_table_usage_is_enabled() ) {
320
+            $this->orders_page_controller = new Custom_Orders_PageController();
321
+            $this->orders_page_controller->setup();
322
+        }
323
+    }
324
+
325
+    /**
326
+     * Add custom nav meta box.
327
+     *
328
+     * Adapted from http://www.johnmorrisonline.com/how-to-add-a-fully-functional-custom-meta-box-to-wordpress-navigation-menus/.
329
+     */
330
+    public function add_nav_menu_meta_boxes() {
331
+        add_meta_box( 'woocommerce_endpoints_nav_link', __( 'WooCommerce endpoints', 'woocommerce' ), array( $this, 'nav_menu_links' ), 'nav-menus', 'side', 'low' );
332
+    }
333
+
334
+    /**
335
+     * Output menu links.
336
+     */
337
+    public function nav_menu_links() {
338
+        // Get items from account menu.
339
+        $endpoints = wc_get_account_menu_items();
340
+
341
+        // Remove dashboard item.
342
+        if ( isset( $endpoints['dashboard'] ) ) {
343
+            unset( $endpoints['dashboard'] );
344
+        }
345
+
346
+        // Include missing lost password.
347
+        $endpoints['lost-password'] = __( 'Lost password', 'woocommerce' );
348
+
349
+        $endpoints = apply_filters( 'woocommerce_custom_nav_menu_items', $endpoints );
350
+
351
+        ?>
352 352
 		<div id="posttype-woocommerce-endpoints" class="posttypediv">
353 353
 			<div id="tabs-panel-woocommerce-endpoints" class="tabs-panel tabs-panel-active">
354 354
 				<ul id="woocommerce-endpoints-checklist" class="categorychecklist form-no-clear">
355 355
 					<?php
356
-					$i = -1;
357
-					foreach ( $endpoints as $key => $value ) :
358
-						?>
356
+                    $i = -1;
357
+                    foreach ( $endpoints as $key => $value ) :
358
+                        ?>
359 359
 						<li>
360 360
 							<label class="menu-item-title">
361 361
 								<input type="checkbox" class="menu-item-checkbox" name="menu-item[<?php echo esc_attr( $i ); ?>][menu-item-object-id]" value="<?php echo esc_attr( $i ); ?>" /> <?php echo esc_html( $value ); ?>
@@ -366,9 +366,9 @@  discard block
 block discarded – undo
366 366
 							<input type="hidden" class="menu-item-classes" name="menu-item[<?php echo esc_attr( $i ); ?>][menu-item-classes]" />
367 367
 						</li>
368 368
 						<?php
369
-						$i--;
370
-					endforeach;
371
-					?>
369
+                        $i--;
370
+                    endforeach;
371
+                    ?>
372 372
 				</ul>
373 373
 			</div>
374 374
 			<p class="button-controls">
@@ -382,39 +382,39 @@  discard block
 block discarded – undo
382 382
 			</p>
383 383
 		</div>
384 384
 		<?php
385
-	}
386
-
387
-	/**
388
-	 * Add the "Visit Store" link in admin bar main menu.
389
-	 *
390
-	 * @since 2.4.0
391
-	 * @param WP_Admin_Bar $wp_admin_bar Admin bar instance.
392
-	 */
393
-	public function admin_bar_menus( $wp_admin_bar ) {
394
-		if ( ! is_admin() || ! is_admin_bar_showing() ) {
395
-			return;
396
-		}
397
-
398
-		// Show only when the user is a member of this site, or they're a super admin.
399
-		if ( ! is_user_member_of_blog() && ! is_super_admin() ) {
400
-			return;
401
-		}
402
-
403
-		// Don't display when shop page is the same of the page on front.
404
-		if ( intval( get_option( 'page_on_front' ) ) === wc_get_page_id( 'shop' ) ) {
405
-			return;
406
-		}
407
-
408
-		// Add an option to visit the store.
409
-		$wp_admin_bar->add_node(
410
-			array(
411
-				'parent' => 'site-name',
412
-				'id'     => 'view-store',
413
-				'title'  => __( 'Visit Store', 'woocommerce' ),
414
-				'href'   => wc_get_page_permalink( 'shop' ),
415
-			)
416
-		);
417
-	}
385
+    }
386
+
387
+    /**
388
+     * Add the "Visit Store" link in admin bar main menu.
389
+     *
390
+     * @since 2.4.0
391
+     * @param WP_Admin_Bar $wp_admin_bar Admin bar instance.
392
+     */
393
+    public function admin_bar_menus( $wp_admin_bar ) {
394
+        if ( ! is_admin() || ! is_admin_bar_showing() ) {
395
+            return;
396
+        }
397
+
398
+        // Show only when the user is a member of this site, or they're a super admin.
399
+        if ( ! is_user_member_of_blog() && ! is_super_admin() ) {
400
+            return;
401
+        }
402
+
403
+        // Don't display when shop page is the same of the page on front.
404
+        if ( intval( get_option( 'page_on_front' ) ) === wc_get_page_id( 'shop' ) ) {
405
+            return;
406
+        }
407
+
408
+        // Add an option to visit the store.
409
+        $wp_admin_bar->add_node(
410
+            array(
411
+                'parent' => 'site-name',
412
+                'id'     => 'view-store',
413
+                'title'  => __( 'Visit Store', 'woocommerce' ),
414
+                'href'   => wc_get_page_permalink( 'shop' ),
415
+            )
416
+        );
417
+    }
418 418
 
419 419
 }
420 420
 
Please login to merge, or discard this patch.
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -10,9 +10,9 @@  discard block
 block discarded – undo
10 10
 use Automattic\WooCommerce\Internal\Admin\Orders\PageController as Custom_Orders_PageController;
11 11
 use Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController;
12 12
 
13
-defined( 'ABSPATH' ) || exit;
13
+defined('ABSPATH') || exit;
14 14
 
15
-if ( class_exists( 'WC_Admin_Menus', false ) ) {
15
+if (class_exists('WC_Admin_Menus', false)) {
16 16
 	return new WC_Admin_Menus();
17 17
 }
18 18
 
@@ -30,32 +30,32 @@  discard block
 block discarded – undo
30 30
 	 */
31 31
 	public function __construct() {
32 32
 		// Add menus.
33
-		add_action( 'admin_menu', array( $this, 'menu_highlight' ) );
34
-		add_action( 'admin_menu', array( $this, 'menu_order_count' ) );
35
-		add_action( 'admin_menu', array( $this, 'admin_menu' ), 9 );
36
-		add_action( 'admin_menu', array( $this, 'orders_menu' ), 9 );
37
-		add_action( 'admin_menu', array( $this, 'reports_menu' ), 20 );
38
-		add_action( 'admin_menu', array( $this, 'settings_menu' ), 50 );
39
-		add_action( 'admin_menu', array( $this, 'status_menu' ), 60 );
40
-
41
-		if ( apply_filters( 'woocommerce_show_addons_page', true ) ) {
42
-			add_action( 'admin_menu', array( $this, 'addons_menu' ), 70 );
33
+		add_action('admin_menu', array($this, 'menu_highlight'));
34
+		add_action('admin_menu', array($this, 'menu_order_count'));
35
+		add_action('admin_menu', array($this, 'admin_menu'), 9);
36
+		add_action('admin_menu', array($this, 'orders_menu'), 9);
37
+		add_action('admin_menu', array($this, 'reports_menu'), 20);
38
+		add_action('admin_menu', array($this, 'settings_menu'), 50);
39
+		add_action('admin_menu', array($this, 'status_menu'), 60);
40
+
41
+		if (apply_filters('woocommerce_show_addons_page', true)) {
42
+			add_action('admin_menu', array($this, 'addons_menu'), 70);
43 43
 		}
44 44
 
45
-		add_filter( 'menu_order', array( $this, 'menu_order' ) );
46
-		add_filter( 'custom_menu_order', array( $this, 'custom_menu_order' ) );
47
-		add_filter( 'set-screen-option', array( $this, 'set_screen_option' ), 10, 3 );
45
+		add_filter('menu_order', array($this, 'menu_order'));
46
+		add_filter('custom_menu_order', array($this, 'custom_menu_order'));
47
+		add_filter('set-screen-option', array($this, 'set_screen_option'), 10, 3);
48 48
 
49 49
 		// Add endpoints custom URLs in Appearance > Menus > Pages.
50
-		add_action( 'admin_head-nav-menus.php', array( $this, 'add_nav_menu_meta_boxes' ) );
50
+		add_action('admin_head-nav-menus.php', array($this, 'add_nav_menu_meta_boxes'));
51 51
 
52 52
 		// Admin bar menus.
53
-		if ( apply_filters( 'woocommerce_show_admin_bar_visit_store', true ) ) {
54
-			add_action( 'admin_bar_menu', array( $this, 'admin_bar_menus' ), 31 );
53
+		if (apply_filters('woocommerce_show_admin_bar_visit_store', true)) {
54
+			add_action('admin_bar_menu', array($this, 'admin_bar_menus'), 31);
55 55
 		}
56 56
 
57 57
 		// Handle saving settings earlier than load-{page} hook to avoid race conditions in conditional menus.
58
-		add_action( 'wp_loaded', array( $this, 'save_settings' ) );
58
+		add_action('wp_loaded', array($this, 'save_settings'));
59 59
 	}
60 60
 
61 61
 	/**
@@ -66,23 +66,23 @@  discard block
 block discarded – undo
66 66
 
67 67
 		$woocommerce_icon = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDI0IDEwMjQiPjxwYXRoIGZpbGw9IiNhMmFhYjIiIGQ9Ik02MTIuMTkyIDQyNi4zMzZjMC02Ljg5Ni0zLjEzNi01MS42LTI4LTUxLjYtMzcuMzYgMC00Ni43MDQgNzIuMjU2LTQ2LjcwNCA4Mi42MjQgMCAzLjQwOCAzLjE1MiA1OC40OTYgMjguMDMyIDU4LjQ5NiAzNC4xOTItLjAzMiA0Ni42NzItNzIuMjg4IDQ2LjY3Mi04OS41MnptMjAyLjE5MiAwYzAtNi44OTYtMy4xNTItNTEuNi0yOC4wMzItNTEuNi0zNy4yOCAwLTQ2LjYwOCA3Mi4yNTYtNDYuNjA4IDgyLjYyNCAwIDMuNDA4IDMuMDcyIDU4LjQ5NiAyNy45NTIgNTguNDk2IDM0LjE5Mi0uMDMyIDQ2LjY4OC03Mi4yODggNDYuNjg4LTg5LjUyek0xNDEuMjk2Ljc2OGMtNjguMjI0IDAtMTIzLjUwNCA1NS40ODgtMTIzLjUwNCAxMjMuOTJ2NjUwLjcyYzAgNjguNDMyIDU1LjI5NiAxMjMuOTIgMTIzLjUwNCAxMjMuOTJoMzM5LjgwOGwxMjMuNTA0IDEyMy45MzZWODk5LjMyOGgyNzguMDQ4YzY4LjIyNCAwIDEyMy41Mi01NS40NzIgMTIzLjUyLTEyMy45MnYtNjUwLjcyYzAtNjguNDMyLTU1LjI5Ni0xMjMuOTItMTIzLjUyLTEyMy45MmgtNzQxLjM2em01MjYuODY0IDQyMi4xNmMwIDU1LjA4OC0zMS4wODggMTU0Ljg4LTEwMi42NCAxNTQuODgtNi4yMDggMC0xOC40OTYtMy42MTYtMjUuNDI0LTYuMDE2LTMyLjUxMi0xMS4xNjgtNTAuMTkyLTQ5LjY5Ni01Mi4zNTItNjYuMjU2IDAgMC0zLjA3Mi0xNy43OTItMy4wNzItNDAuNzUyIDAtMjIuOTkyIDMuMDcyLTQ1LjMyOCAzLjA3Mi00NS4zMjggMTUuNTUyLTc1LjcyOCA0My41NTItMTA2LjczNiA5Ni40NDgtMTA2LjczNiA1OS4wNzItLjAzMiA4My45NjggNTguNTI4IDgzLjk2OCAxMTAuMjA4ek00ODYuNDk2IDMwMi40YzAgMy4zOTItNDMuNTUyIDE0MS4xNjgtNDMuNTUyIDIxMy40MjR2NzUuNzEyYy0yLjU5MiAxMi4wOC00LjE2IDI0LjE0NC0yMS44MjQgMjQuMTQ0LTQ2LjYwOCAwLTg4Ljg4LTE1MS40NzItOTIuMDE2LTE2MS44NC02LjIwOCA2Ljg5Ni02Mi4yNCAxNjEuODQtOTYuNDQ4IDE2MS44NC0yNC44NjQgMC00My41NTItMTEzLjY0OC00Ni42MDgtMTIzLjkzNkMxNzYuNzA0IDQzNi42NzIgMTYwIDMzNC4yMjQgMTYwIDMyNy4zMjhjMC0yMC42NzIgMS4xNTItMzguNzM2IDI2LjA0OC0zOC43MzYgNi4yMDggMCAyMS42IDYuMDY0IDIzLjcxMiAxNy4xNjggMTEuNjQ4IDYyLjAzMiAxNi42ODggMTIwLjUxMiAyOS4xNjggMTg1Ljk2OCAxLjg1NiAyLjkyOCAxLjUwNCA3LjAwOCA0LjU2IDEwLjQzMiAzLjE1Mi0xMC4yODggNjYuOTI4LTE2OC43ODQgOTQuOTYtMTY4Ljc4NCAyMi41NDQgMCAzMC40IDQ0LjU5MiAzMy41MzYgNjEuODI0IDYuMjA4IDIwLjY1NiAxMy4wODggNTUuMjE2IDIyLjQxNiA4Mi43NTIgMC0xMy43NzYgMTIuNDgtMjAzLjEyIDY1LjM5Mi0yMDMuMTIgMTguNTkyLjAzMiAyNi43MDQgNi45MjggMjYuNzA0IDI3LjU2OHpNODcwLjMyIDQyMi45MjhjMCA1NS4wODgtMzEuMDg4IDE1NC44OC0xMDIuNjQgMTU0Ljg4LTYuMTkyIDAtMTguNDQ4LTMuNjE2LTI1LjQyNC02LjAxNi0zMi40MzItMTEuMTY4LTUwLjE3Ni00OS42OTYtNTIuMjg4LTY2LjI1NiAwIDAtMy44ODgtMTcuOTItMy44ODgtNDAuODk2czMuODg4LTQ1LjE4NCAzLjg4OC00NS4xODRjMTUuNTUyLTc1LjcyOCA0My40ODgtMTA2LjczNiA5Ni4zODQtMTA2LjczNiA1OS4xMDQtLjAzMiA4My45NjggNTguNTI4IDgzLjk2OCAxMTAuMjA4eiIvPjwvc3ZnPg==';
68 68
 
69
-		if ( self::can_view_woocommerce_menu_item() ) {
70
-			$menu[] = array( '', 'read', 'separator-woocommerce', '', 'wp-menu-separator woocommerce' ); // WPCS: override ok.
69
+		if (self::can_view_woocommerce_menu_item()) {
70
+			$menu[] = array('', 'read', 'separator-woocommerce', '', 'wp-menu-separator woocommerce'); // WPCS: override ok.
71 71
 		}
72 72
 
73
-		add_menu_page( __( 'WooCommerce', 'woocommerce' ), __( 'WooCommerce', 'woocommerce' ), 'edit_others_shop_orders', 'woocommerce', null, $woocommerce_icon, '55.5' );
73
+		add_menu_page(__('WooCommerce', 'woocommerce'), __('WooCommerce', 'woocommerce'), 'edit_others_shop_orders', 'woocommerce', null, $woocommerce_icon, '55.5');
74 74
 
75
-		add_submenu_page( 'edit.php?post_type=product', __( 'Attributes', 'woocommerce' ), __( 'Attributes', 'woocommerce' ), 'manage_product_terms', 'product_attributes', array( $this, 'attributes_page' ) );
75
+		add_submenu_page('edit.php?post_type=product', __('Attributes', 'woocommerce'), __('Attributes', 'woocommerce'), 'manage_product_terms', 'product_attributes', array($this, 'attributes_page'));
76 76
 	}
77 77
 
78 78
 	/**
79 79
 	 * Add menu item.
80 80
 	 */
81 81
 	public function reports_menu() {
82
-		if ( self::can_view_woocommerce_menu_item() ) {
83
-			add_submenu_page( 'woocommerce', __( 'Reports', 'woocommerce' ), __( 'Reports', 'woocommerce' ), 'view_woocommerce_reports', 'wc-reports', array( $this, 'reports_page' ) );
82
+		if (self::can_view_woocommerce_menu_item()) {
83
+			add_submenu_page('woocommerce', __('Reports', 'woocommerce'), __('Reports', 'woocommerce'), 'view_woocommerce_reports', 'wc-reports', array($this, 'reports_page'));
84 84
 		} else {
85
-			add_menu_page( __( 'Sales reports', 'woocommerce' ), __( 'Sales reports', 'woocommerce' ), 'view_woocommerce_reports', 'wc-reports', array( $this, 'reports_page' ), 'dashicons-chart-bar', '55.6' );
85
+			add_menu_page(__('Sales reports', 'woocommerce'), __('Sales reports', 'woocommerce'), 'view_woocommerce_reports', 'wc-reports', array($this, 'reports_page'), 'dashicons-chart-bar', '55.6');
86 86
 		}
87 87
 	}
88 88
 
@@ -90,16 +90,16 @@  discard block
 block discarded – undo
90 90
 	 * Add menu item.
91 91
 	 */
92 92
 	public function settings_menu() {
93
-		$settings_page = add_submenu_page( 'woocommerce', __( 'WooCommerce settings', 'woocommerce' ), __( 'Settings', 'woocommerce' ), 'manage_woocommerce', 'wc-settings', array( $this, 'settings_page' ) );
93
+		$settings_page = add_submenu_page('woocommerce', __('WooCommerce settings', 'woocommerce'), __('Settings', 'woocommerce'), 'manage_woocommerce', 'wc-settings', array($this, 'settings_page'));
94 94
 
95
-		add_action( 'load-' . $settings_page, array( $this, 'settings_page_init' ) );
95
+		add_action('load-' . $settings_page, array($this, 'settings_page_init'));
96 96
 	}
97 97
 
98 98
 	/**
99 99
 	 * Check if the user can access the top-level WooCommerce item.
100 100
 	 */
101 101
 	public static function can_view_woocommerce_menu_item() {
102
-		return current_user_can( 'edit_others_shop_orders' );
102
+		return current_user_can('edit_others_shop_orders');
103 103
 	}
104 104
 
105 105
 	/**
@@ -113,15 +113,15 @@  discard block
 block discarded – undo
113 113
 		WC_Admin_Settings::get_settings_pages();
114 114
 
115 115
 		// Add any posted messages.
116
-		if ( ! empty( $_GET['wc_error'] ) ) { // WPCS: input var okay, CSRF ok.
117
-			WC_Admin_Settings::add_error( wp_kses_post( wp_unslash( $_GET['wc_error'] ) ) ); // WPCS: input var okay, CSRF ok.
116
+		if (!empty($_GET['wc_error'])) { // WPCS: input var okay, CSRF ok.
117
+			WC_Admin_Settings::add_error(wp_kses_post(wp_unslash($_GET['wc_error']))); // WPCS: input var okay, CSRF ok.
118 118
 		}
119 119
 
120
-		if ( ! empty( $_GET['wc_message'] ) ) { // WPCS: input var okay, CSRF ok.
121
-			WC_Admin_Settings::add_message( wp_kses_post( wp_unslash( $_GET['wc_message'] ) ) ); // WPCS: input var okay, CSRF ok.
120
+		if (!empty($_GET['wc_message'])) { // WPCS: input var okay, CSRF ok.
121
+			WC_Admin_Settings::add_message(wp_kses_post(wp_unslash($_GET['wc_message']))); // WPCS: input var okay, CSRF ok.
122 122
 		}
123 123
 
124
-		do_action( 'woocommerce_settings_page_init' );
124
+		do_action('woocommerce_settings_page_init');
125 125
 	}
126 126
 
127 127
 	/**
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 		global $current_tab, $current_section;
134 134
 
135 135
 		// We should only save on the settings page.
136
-		if ( ! is_admin() || ! isset( $_GET['page'] ) || 'wc-settings' !== $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
136
+		if (!is_admin() || !isset($_GET['page']) || 'wc-settings' !== $_GET['page']) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
137 137
 			return;
138 138
 		}
139 139
 
@@ -141,13 +141,13 @@  discard block
 block discarded – undo
141 141
 		WC_Admin_Settings::get_settings_pages();
142 142
 
143 143
 		// Get current tab/section.
144
-		$current_tab     = empty( $_GET['tab'] ) ? 'general' : sanitize_title( wp_unslash( $_GET['tab'] ) ); // WPCS: input var okay, CSRF ok.
145
-		$current_section = empty( $_REQUEST['section'] ) ? '' : sanitize_title( wp_unslash( $_REQUEST['section'] ) ); // WPCS: input var okay, CSRF ok.
144
+		$current_tab     = empty($_GET['tab']) ? 'general' : sanitize_title(wp_unslash($_GET['tab'])); // WPCS: input var okay, CSRF ok.
145
+		$current_section = empty($_REQUEST['section']) ? '' : sanitize_title(wp_unslash($_REQUEST['section'])); // WPCS: input var okay, CSRF ok.
146 146
 
147 147
 		// Save settings if data has been posted.
148
-		if ( '' !== $current_section && apply_filters( "woocommerce_save_settings_{$current_tab}_{$current_section}", ! empty( $_POST['save'] ) ) ) { // WPCS: input var okay, CSRF ok.
148
+		if ('' !== $current_section && apply_filters("woocommerce_save_settings_{$current_tab}_{$current_section}", !empty($_POST['save']))) { // WPCS: input var okay, CSRF ok.
149 149
 			WC_Admin_Settings::save();
150
-		} elseif ( '' === $current_section && apply_filters( "woocommerce_save_settings_{$current_tab}", ! empty( $_POST['save'] ) ) ) { // WPCS: input var okay, CSRF ok.
150
+		} elseif ('' === $current_section && apply_filters("woocommerce_save_settings_{$current_tab}", !empty($_POST['save']))) { // WPCS: input var okay, CSRF ok.
151 151
 			WC_Admin_Settings::save();
152 152
 		}
153 153
 	}
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 	 * Add menu item.
157 157
 	 */
158 158
 	public function status_menu() {
159
-		add_submenu_page( 'woocommerce', __( 'WooCommerce status', 'woocommerce' ), __( 'Status', 'woocommerce' ), 'manage_woocommerce', 'wc-status', array( $this, 'status_page' ) );
159
+		add_submenu_page('woocommerce', __('WooCommerce status', 'woocommerce'), __('Status', 'woocommerce'), 'manage_woocommerce', 'wc-status', array($this, 'status_page'));
160 160
 	}
161 161
 
162 162
 	/**
@@ -165,8 +165,8 @@  discard block
 block discarded – undo
165 165
 	public function addons_menu() {
166 166
 		$count_html = WC_Helper_Updater::get_updates_count_html();
167 167
 		/* translators: %s: extensions count */
168
-		$menu_title = sprintf( __( 'Extensions %s', 'woocommerce' ), $count_html );
169
-		add_submenu_page( 'woocommerce', __( 'WooCommerce extensions', 'woocommerce' ), $menu_title, 'manage_woocommerce', 'wc-addons', array( $this, 'addons_page' ) );
168
+		$menu_title = sprintf(__('Extensions %s', 'woocommerce'), $count_html);
169
+		add_submenu_page('woocommerce', __('WooCommerce extensions', 'woocommerce'), $menu_title, 'manage_woocommerce', 'wc-addons', array($this, 'addons_page'));
170 170
 	}
171 171
 
172 172
 	/**
@@ -175,14 +175,14 @@  discard block
 block discarded – undo
175 175
 	public function menu_highlight() {
176 176
 		global $parent_file, $submenu_file, $post_type;
177 177
 
178
-		switch ( $post_type ) {
178
+		switch ($post_type) {
179 179
 			case 'shop_order':
180 180
 			case 'shop_coupon':
181 181
 				$parent_file = 'woocommerce'; // WPCS: override ok.
182 182
 				break;
183 183
 			case 'product':
184 184
 				$screen = get_current_screen();
185
-				if ( $screen && taxonomy_is_product_attribute( $screen->taxonomy ) ) {
185
+				if ($screen && taxonomy_is_product_attribute($screen->taxonomy)) {
186 186
 					$submenu_file = 'product_attributes'; // WPCS: override ok.
187 187
 					$parent_file  = 'edit.php?post_type=product'; // WPCS: override ok.
188 188
 				}
@@ -196,18 +196,18 @@  discard block
 block discarded – undo
196 196
 	public function menu_order_count() {
197 197
 		global $submenu;
198 198
 
199
-		if ( isset( $submenu['woocommerce'] ) ) {
199
+		if (isset($submenu['woocommerce'])) {
200 200
 			// Remove 'WooCommerce' sub menu item.
201
-			unset( $submenu['woocommerce'][0] );
201
+			unset($submenu['woocommerce'][0]);
202 202
 
203 203
 			// Add count if user has access.
204
-			if ( apply_filters( 'woocommerce_include_processing_order_count_in_menu', true ) && current_user_can( 'edit_others_shop_orders' ) ) {
205
-				$order_count = apply_filters( 'woocommerce_menu_order_count', wc_processing_order_count() );
204
+			if (apply_filters('woocommerce_include_processing_order_count_in_menu', true) && current_user_can('edit_others_shop_orders')) {
205
+				$order_count = apply_filters('woocommerce_menu_order_count', wc_processing_order_count());
206 206
 
207
-				if ( $order_count ) {
208
-					foreach ( $submenu['woocommerce'] as $key => $menu_item ) {
209
-						if ( 0 === strpos( $menu_item[0], _x( 'Orders', 'Admin menu name', 'woocommerce' ) ) ) {
210
-							$submenu['woocommerce'][ $key ][0] .= ' <span class="awaiting-mod update-plugins count-' . esc_attr( $order_count ) . '"><span class="processing-count">' . number_format_i18n( $order_count ) . '</span></span>'; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
207
+				if ($order_count) {
208
+					foreach ($submenu['woocommerce'] as $key => $menu_item) {
209
+						if (0 === strpos($menu_item[0], _x('Orders', 'Admin menu name', 'woocommerce'))) {
210
+							$submenu['woocommerce'][$key][0] .= ' <span class="awaiting-mod update-plugins count-' . esc_attr($order_count) . '"><span class="processing-count">' . number_format_i18n($order_count) . '</span></span>'; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
211 211
 							break;
212 212
 						}
213 213
 					}
@@ -222,26 +222,26 @@  discard block
 block discarded – undo
222 222
 	 * @param int $menu_order Menu order.
223 223
 	 * @return array
224 224
 	 */
225
-	public function menu_order( $menu_order ) {
225
+	public function menu_order($menu_order) {
226 226
 		// Initialize our custom order array.
227 227
 		$woocommerce_menu_order = array();
228 228
 
229 229
 		// Get the index of our custom separator.
230
-		$woocommerce_separator = array_search( 'separator-woocommerce', $menu_order, true );
230
+		$woocommerce_separator = array_search('separator-woocommerce', $menu_order, true);
231 231
 
232 232
 		// Get index of product menu.
233
-		$woocommerce_product = array_search( 'edit.php?post_type=product', $menu_order, true );
233
+		$woocommerce_product = array_search('edit.php?post_type=product', $menu_order, true);
234 234
 
235 235
 		// Loop through menu order and do some rearranging.
236
-		foreach ( $menu_order as $index => $item ) {
236
+		foreach ($menu_order as $index => $item) {
237 237
 
238
-			if ( 'woocommerce' === $item ) {
238
+			if ('woocommerce' === $item) {
239 239
 				$woocommerce_menu_order[] = 'separator-woocommerce';
240 240
 				$woocommerce_menu_order[] = $item;
241 241
 				$woocommerce_menu_order[] = 'edit.php?post_type=product';
242
-				unset( $menu_order[ $woocommerce_separator ] );
243
-				unset( $menu_order[ $woocommerce_product ] );
244
-			} elseif ( ! in_array( $item, array( 'separator-woocommerce' ), true ) ) {
242
+				unset($menu_order[$woocommerce_separator]);
243
+				unset($menu_order[$woocommerce_product]);
244
+			} elseif (!in_array($item, array('separator-woocommerce'), true)) {
245 245
 				$woocommerce_menu_order[] = $item;
246 246
 			}
247 247
 		}
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 	 * @param bool $enabled Whether custom menu ordering is already enabled.
257 257
 	 * @return bool
258 258
 	 */
259
-	public function custom_menu_order( $enabled ) {
259
+	public function custom_menu_order($enabled) {
260 260
 		return $enabled || self::can_view_woocommerce_menu_item();
261 261
 	}
262 262
 
@@ -267,8 +267,8 @@  discard block
 block discarded – undo
267 267
 	 * @param string   $option The option name.
268 268
 	 * @param int      $value  The number of rows to use.
269 269
 	 */
270
-	public function set_screen_option( $status, $option, $value ) {
271
-		if ( in_array( $option, array( 'woocommerce_keys_per_page', 'woocommerce_webhooks_per_page' ), true ) ) {
270
+	public function set_screen_option($status, $option, $value) {
271
+		if (in_array($option, array('woocommerce_keys_per_page', 'woocommerce_webhooks_per_page'), true)) {
272 272
 			return $value;
273 273
 		}
274 274
 
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 	 * @return void
317 317
 	 */
318 318
 	public function orders_menu(): void {
319
-		if ( wc_get_container()->get( CustomOrdersTableController::class )->custom_orders_table_usage_is_enabled() ) {
319
+		if (wc_get_container()->get(CustomOrdersTableController::class)->custom_orders_table_usage_is_enabled()) {
320 320
 			$this->orders_page_controller = new Custom_Orders_PageController();
321 321
 			$this->orders_page_controller->setup();
322 322
 		}
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 	 * Adapted from http://www.johnmorrisonline.com/how-to-add-a-fully-functional-custom-meta-box-to-wordpress-navigation-menus/.
329 329
 	 */
330 330
 	public function add_nav_menu_meta_boxes() {
331
-		add_meta_box( 'woocommerce_endpoints_nav_link', __( 'WooCommerce endpoints', 'woocommerce' ), array( $this, 'nav_menu_links' ), 'nav-menus', 'side', 'low' );
331
+		add_meta_box('woocommerce_endpoints_nav_link', __('WooCommerce endpoints', 'woocommerce'), array($this, 'nav_menu_links'), 'nav-menus', 'side', 'low');
332 332
 	}
333 333
 
334 334
 	/**
@@ -339,14 +339,14 @@  discard block
 block discarded – undo
339 339
 		$endpoints = wc_get_account_menu_items();
340 340
 
341 341
 		// Remove dashboard item.
342
-		if ( isset( $endpoints['dashboard'] ) ) {
343
-			unset( $endpoints['dashboard'] );
342
+		if (isset($endpoints['dashboard'])) {
343
+			unset($endpoints['dashboard']);
344 344
 		}
345 345
 
346 346
 		// Include missing lost password.
347
-		$endpoints['lost-password'] = __( 'Lost password', 'woocommerce' );
347
+		$endpoints['lost-password'] = __('Lost password', 'woocommerce');
348 348
 
349
-		$endpoints = apply_filters( 'woocommerce_custom_nav_menu_items', $endpoints );
349
+		$endpoints = apply_filters('woocommerce_custom_nav_menu_items', $endpoints);
350 350
 
351 351
 		?>
352 352
 		<div id="posttype-woocommerce-endpoints" class="posttypediv">
@@ -354,16 +354,16 @@  discard block
 block discarded – undo
354 354
 				<ul id="woocommerce-endpoints-checklist" class="categorychecklist form-no-clear">
355 355
 					<?php
356 356
 					$i = -1;
357
-					foreach ( $endpoints as $key => $value ) :
357
+					foreach ($endpoints as $key => $value) :
358 358
 						?>
359 359
 						<li>
360 360
 							<label class="menu-item-title">
361
-								<input type="checkbox" class="menu-item-checkbox" name="menu-item[<?php echo esc_attr( $i ); ?>][menu-item-object-id]" value="<?php echo esc_attr( $i ); ?>" /> <?php echo esc_html( $value ); ?>
361
+								<input type="checkbox" class="menu-item-checkbox" name="menu-item[<?php echo esc_attr($i); ?>][menu-item-object-id]" value="<?php echo esc_attr($i); ?>" /> <?php echo esc_html($value); ?>
362 362
 							</label>
363
-							<input type="hidden" class="menu-item-type" name="menu-item[<?php echo esc_attr( $i ); ?>][menu-item-type]" value="custom" />
364
-							<input type="hidden" class="menu-item-title" name="menu-item[<?php echo esc_attr( $i ); ?>][menu-item-title]" value="<?php echo esc_attr( $value ); ?>" />
365
-							<input type="hidden" class="menu-item-url" name="menu-item[<?php echo esc_attr( $i ); ?>][menu-item-url]" value="<?php echo esc_url( wc_get_account_endpoint_url( $key ) ); ?>" />
366
-							<input type="hidden" class="menu-item-classes" name="menu-item[<?php echo esc_attr( $i ); ?>][menu-item-classes]" />
363
+							<input type="hidden" class="menu-item-type" name="menu-item[<?php echo esc_attr($i); ?>][menu-item-type]" value="custom" />
364
+							<input type="hidden" class="menu-item-title" name="menu-item[<?php echo esc_attr($i); ?>][menu-item-title]" value="<?php echo esc_attr($value); ?>" />
365
+							<input type="hidden" class="menu-item-url" name="menu-item[<?php echo esc_attr($i); ?>][menu-item-url]" value="<?php echo esc_url(wc_get_account_endpoint_url($key)); ?>" />
366
+							<input type="hidden" class="menu-item-classes" name="menu-item[<?php echo esc_attr($i); ?>][menu-item-classes]" />
367 367
 						</li>
368 368
 						<?php
369 369
 						$i--;
@@ -373,10 +373,10 @@  discard block
 block discarded – undo
373 373
 			</div>
374 374
 			<p class="button-controls">
375 375
 				<span class="list-controls">
376
-					<a href="<?php echo esc_url( admin_url( 'nav-menus.php?page-tab=all&selectall=1#posttype-woocommerce-endpoints' ) ); ?>" class="select-all"><?php esc_html_e( 'Select all', 'woocommerce' ); ?></a>
376
+					<a href="<?php echo esc_url(admin_url('nav-menus.php?page-tab=all&selectall=1#posttype-woocommerce-endpoints')); ?>" class="select-all"><?php esc_html_e('Select all', 'woocommerce'); ?></a>
377 377
 				</span>
378 378
 				<span class="add-to-menu">
379
-					<button type="submit" class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to menu', 'woocommerce' ); ?>" name="add-post-type-menu-item" id="submit-posttype-woocommerce-endpoints"><?php esc_html_e( 'Add to menu', 'woocommerce' ); ?></button>
379
+					<button type="submit" class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to menu', 'woocommerce'); ?>" name="add-post-type-menu-item" id="submit-posttype-woocommerce-endpoints"><?php esc_html_e('Add to menu', 'woocommerce'); ?></button>
380 380
 					<span class="spinner"></span>
381 381
 				</span>
382 382
 			</p>
@@ -390,18 +390,18 @@  discard block
 block discarded – undo
390 390
 	 * @since 2.4.0
391 391
 	 * @param WP_Admin_Bar $wp_admin_bar Admin bar instance.
392 392
 	 */
393
-	public function admin_bar_menus( $wp_admin_bar ) {
394
-		if ( ! is_admin() || ! is_admin_bar_showing() ) {
393
+	public function admin_bar_menus($wp_admin_bar) {
394
+		if (!is_admin() || !is_admin_bar_showing()) {
395 395
 			return;
396 396
 		}
397 397
 
398 398
 		// Show only when the user is a member of this site, or they're a super admin.
399
-		if ( ! is_user_member_of_blog() && ! is_super_admin() ) {
399
+		if (!is_user_member_of_blog() && !is_super_admin()) {
400 400
 			return;
401 401
 		}
402 402
 
403 403
 		// Don't display when shop page is the same of the page on front.
404
-		if ( intval( get_option( 'page_on_front' ) ) === wc_get_page_id( 'shop' ) ) {
404
+		if (intval(get_option('page_on_front')) === wc_get_page_id('shop')) {
405 405
 			return;
406 406
 		}
407 407
 
@@ -410,8 +410,8 @@  discard block
 block discarded – undo
410 410
 			array(
411 411
 				'parent' => 'site-name',
412 412
 				'id'     => 'view-store',
413
-				'title'  => __( 'Visit Store', 'woocommerce' ),
414
-				'href'   => wc_get_page_permalink( 'shop' ),
413
+				'title'  => __('Visit Store', 'woocommerce'),
414
+				'href'   => wc_get_page_permalink('shop'),
415 415
 			)
416 416
 		);
417 417
 	}
Please login to merge, or discard this patch.
plugins/woocommerce/includes/admin/class-wc-admin-addons.php 3 patches
Indentation   +1172 added lines, -1172 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 use Automattic\WooCommerce\Admin\RemoteInboxNotifications as PromotionRuleEngine;
11 11
 
12 12
 if ( ! defined( 'ABSPATH' ) ) {
13
-	exit;
13
+    exit;
14 14
 }
15 15
 
16 16
 /**
@@ -18,323 +18,323 @@  discard block
 block discarded – undo
18 18
  */
19 19
 class WC_Admin_Addons {
20 20
 
21
-	/**
22
-	 * Get featured for the addons screen
23
-	 *
24
-	 * @deprecated 5.9.0 No longer used in In-App Marketplace
25
-	 *
26
-	 * @return array of objects
27
-	 */
28
-	public static function get_featured() {
29
-		$featured = get_transient( 'wc_addons_featured_2' );
30
-		if ( false === $featured ) {
31
-			$headers = array();
32
-			$auth    = WC_Helper_Options::get( 'auth' );
33
-
34
-			if ( ! empty( $auth['access_token'] ) ) {
35
-				$headers['Authorization'] = 'Bearer ' . $auth['access_token'];
36
-			}
37
-
38
-			$raw_featured = wp_safe_remote_get(
39
-				'https://woocommerce.com/wp-json/wccom-extensions/1.0/featured',
40
-				array(
41
-					'headers' => $headers,
42
-				)
43
-			);
44
-
45
-			if ( ! is_wp_error( $raw_featured ) ) {
46
-				$featured = json_decode( wp_remote_retrieve_body( $raw_featured ) );
47
-				if ( $featured ) {
48
-					set_transient( 'wc_addons_featured_2', $featured, DAY_IN_SECONDS );
49
-				}
50
-			}
51
-		}
52
-
53
-		if ( is_object( $featured ) ) {
54
-			self::output_featured_sections( $featured->sections );
55
-			return $featured;
56
-		}
57
-	}
58
-
59
-	/**
60
-	 * Render featured products and banners using WCCOM's the Featured 2.0 Endpoint
61
-	 *
62
-	 * @return void
63
-	 */
64
-	public static function render_featured() {
65
-		$featured = get_transient( 'wc_addons_featured' );
66
-		if ( false === $featured ) {
67
-			$headers = array();
68
-			$auth    = WC_Helper_Options::get( 'auth' );
69
-
70
-			if ( ! empty( $auth['access_token'] ) ) {
71
-				$headers['Authorization'] = 'Bearer ' . $auth['access_token'];
72
-			}
73
-
74
-			$parameter_string = '';
75
-			$country          = WC()->countries->get_base_country();
76
-			if ( ! empty( $country ) ) {
77
-				$parameter_string = '?' . http_build_query( array( 'country' => $country ) );
78
-			}
79
-
80
-			// Important: WCCOM Extensions API v2.0 is used.
81
-			$raw_featured = wp_safe_remote_get(
82
-				'https://woocommerce.com/wp-json/wccom-extensions/2.0/featured' . $parameter_string,
83
-				array(
84
-					'headers' => $headers,
85
-				)
86
-			);
87
-
88
-			if ( is_wp_error( $raw_featured ) ) {
89
-				do_action( 'woocommerce_page_wc-addons_connection_error', $raw_featured->get_error_message() );
90
-
91
-				$message = self::is_ssl_error( $raw_featured->get_error_message() )
92
-					? __( 'We encountered an SSL error. Please ensure your site supports TLS version 1.2 or above.', 'woocommerce' )
93
-					: $raw_featured->get_error_message();
94
-
95
-				self::output_empty( $message );
96
-
97
-				return;
98
-			}
99
-
100
-			$response_code = (int) wp_remote_retrieve_response_code( $raw_featured );
101
-			if ( 200 !== $response_code ) {
102
-				do_action( 'woocommerce_page_wc-addons_connection_error', $response_code );
103
-
104
-				/* translators: %d: HTTP error code. */
105
-				$message = sprintf(
106
-					esc_html(
107
-						/* translators: Error code  */
108
-						__(
109
-							'Our request to the featured API got error code %d.',
110
-							'woocommerce'
111
-						)
112
-					),
113
-					$response_code
114
-				);
115
-
116
-				self::output_empty( $message );
117
-
118
-				return;
119
-			}
120
-
121
-			$featured      = json_decode( wp_remote_retrieve_body( $raw_featured ) );
122
-			if ( empty( $featured ) || ! is_array( $featured ) ) {
123
-				do_action( 'woocommerce_page_wc-addons_connection_error', 'Empty or malformed response' );
124
-				$message = __( 'Our request to the featured API got a malformed response.', 'woocommerce' );
125
-				self::output_empty( $message );
126
-
127
-				return;
128
-			}
129
-
130
-			if ( $featured ) {
131
-				set_transient( 'wc_addons_featured', $featured, DAY_IN_SECONDS );
132
-			}
133
-		}
134
-
135
-		self::output_featured( $featured );
136
-	}
137
-
138
-	/**
139
-	 * Check if the error is due to an SSL error
140
-	 *
141
-	 * @param string $error_message Error message.
142
-	 *
143
-	 * @return bool True if SSL error, false otherwise
144
-	 */
145
-	public static function is_ssl_error( $error_message ) {
146
-		return false !== stripos( $error_message, 'cURL error 35' );
147
-	}
148
-
149
-	/**
150
-	 * Build url parameter string
151
-	 *
152
-	 * @param  string $category Addon (sub) category.
153
-	 * @param  string $term     Search terms.
154
-	 * @param  string $country  Store country.
155
-	 *
156
-	 * @return string url parameter string
157
-	 */
158
-	public static function build_parameter_string( $category, $term, $country ) {
159
-
160
-		$parameters = array(
161
-			'category' => $category,
162
-			'term'     => $term,
163
-			'country'  => $country,
164
-		);
165
-
166
-		return '?' . http_build_query( $parameters );
167
-	}
168
-
169
-	/**
170
-	 * Call API to get extensions
171
-	 *
172
-	 * @param  string $category Addon (sub) category.
173
-	 * @param  string $term     Search terms.
174
-	 * @param  string $country  Store country.
175
-	 *
176
-	 * @return object|WP_Error  Object with products and promotions properties, or WP_Error
177
-	 */
178
-	public static function get_extension_data( $category, $term, $country ) {
179
-		$parameters = self::build_parameter_string( $category, $term, $country );
180
-
181
-		$headers = array();
182
-		$auth    = WC_Helper_Options::get( 'auth' );
183
-
184
-		if ( ! empty( $auth['access_token'] ) ) {
185
-			$headers['Authorization'] = 'Bearer ' . $auth['access_token'];
186
-		}
187
-
188
-		$raw_extensions = wp_safe_remote_get(
189
-			'https://woocommerce.com/wp-json/wccom-extensions/1.0/search' . $parameters,
190
-			array( 'headers' => $headers )
191
-		);
192
-
193
-		if ( is_wp_error( $raw_extensions ) ) {
194
-			do_action( 'woocommerce_page_wc-addons_connection_error', $raw_extensions->get_error_message() );
195
-			return $raw_extensions;
196
-		}
197
-
198
-		$response_code = (int) wp_remote_retrieve_response_code( $raw_extensions );
199
-		if ( 200 !== $response_code ) {
200
-			do_action( 'woocommerce_page_wc-addons_connection_error', $response_code );
201
-			return new WP_Error(
202
-				'error',
203
-				sprintf(
204
-					esc_html(
205
-						/* translators: Error code  */
206
-						__( 'Our request to the search API got response code %s.', 'woocommerce' )
207
-					),
208
-					$response_code
209
-				)
210
-			);
211
-		}
212
-
213
-		$addons = json_decode( wp_remote_retrieve_body( $raw_extensions ) );
214
-
215
-		if ( ! is_object( $addons ) || ! isset( $addons->products ) ) {
216
-			do_action( 'woocommerce_page_wc-addons_connection_error', 'Empty or malformed response' );
217
-			return new WP_Error( 'error', __( 'Our request to the search API got a malformed response.', 'woocommerce' ) );
218
-		}
219
-
220
-		return $addons;
221
-	}
222
-
223
-	/**
224
-	 * Get sections for the addons screen
225
-	 *
226
-	 * @return array of objects
227
-	 */
228
-	public static function get_sections() {
229
-		$addon_sections = get_transient( 'wc_addons_sections' );
230
-		if ( false === ( $addon_sections ) ) {
231
-			$raw_sections = wp_safe_remote_get(
232
-				'https://woocommerce.com/wp-json/wccom-extensions/1.0/categories'
233
-			);
234
-			if ( ! is_wp_error( $raw_sections ) ) {
235
-				$addon_sections = json_decode( wp_remote_retrieve_body( $raw_sections ) );
236
-				if ( $addon_sections ) {
237
-					set_transient( 'wc_addons_sections', $addon_sections, WEEK_IN_SECONDS );
238
-				}
239
-			}
240
-		}
241
-		return apply_filters( 'woocommerce_addons_sections', $addon_sections );
242
-	}
243
-
244
-	/**
245
-	 * Get section for the addons screen.
246
-	 *
247
-	 * @param  string $section_id Required section ID.
248
-	 *
249
-	 * @return object|bool
250
-	 */
251
-	public static function get_section( $section_id ) {
252
-		$sections = self::get_sections();
253
-		if ( isset( $sections[ $section_id ] ) ) {
254
-			return $sections[ $section_id ];
255
-		}
256
-		return false;
257
-	}
258
-
259
-
260
-	/**
261
-	 * Get section content for the addons screen.
262
-	 *
263
-	 * @deprecated 5.9.0 No longer used in In-App Marketplace
264
-	 *
265
-	 * @param  string $section_id Required section ID.
266
-	 *
267
-	 * @return array
268
-	 */
269
-	public static function get_section_data( $section_id ) {
270
-		$section      = self::get_section( $section_id );
271
-		$section_data = '';
272
-
273
-		if ( ! empty( $section->endpoint ) ) {
274
-			$section_data = get_transient( 'wc_addons_section_' . $section_id );
275
-			if ( false === $section_data ) {
276
-				$raw_section = wp_safe_remote_get( esc_url_raw( $section->endpoint ) );
277
-
278
-				if ( ! is_wp_error( $raw_section ) ) {
279
-					$section_data = json_decode( wp_remote_retrieve_body( $raw_section ) );
280
-
281
-					if ( ! empty( $section_data->products ) ) {
282
-						set_transient( 'wc_addons_section_' . $section_id, $section_data, WEEK_IN_SECONDS );
283
-					}
284
-				}
285
-			}
286
-		}
287
-
288
-		return apply_filters( 'woocommerce_addons_section_data', $section_data->products, $section_id );
289
-	}
290
-
291
-	/**
292
-	 * Handles the outputting of a contextually aware Storefront link (points to child themes if Storefront is already active).
293
-	 *
294
-	 * @deprecated 5.9.0 No longer used in In-App Marketplace
295
-	 */
296
-	public static function output_storefront_button() {
297
-		$template   = get_option( 'template' );
298
-		$stylesheet = get_option( 'stylesheet' );
299
-
300
-		if ( 'storefront' === $template ) {
301
-			if ( 'storefront' === $stylesheet ) {
302
-				$url         = 'https://woocommerce.com/product-category/themes/storefront-child-theme-themes/';
303
-				$text        = __( 'Need a fresh look? Try Storefront child themes', 'woocommerce' );
304
-				$utm_content = 'nostorefrontchildtheme';
305
-			} else {
306
-				$url         = 'https://woocommerce.com/product-category/themes/storefront-child-theme-themes/';
307
-				$text        = __( 'View more Storefront child themes', 'woocommerce' );
308
-				$utm_content = 'hasstorefrontchildtheme';
309
-			}
310
-		} else {
311
-			$url         = 'https://woocommerce.com/storefront/';
312
-			$text        = __( 'Need a theme? Try Storefront', 'woocommerce' );
313
-			$utm_content = 'nostorefront';
314
-		}
315
-
316
-		$url = add_query_arg(
317
-			array(
318
-				'utm_source'   => 'addons',
319
-				'utm_medium'   => 'product',
320
-				'utm_campaign' => 'woocommerceplugin',
321
-				'utm_content'  => $utm_content,
322
-			),
323
-			$url
324
-		);
325
-
326
-		echo '<a href="' . esc_url( $url ) . '" class="add-new-h2">' . esc_html( $text ) . '</a>' . "\n";
327
-	}
328
-
329
-	/**
330
-	 * Handles the outputting of a banner block.
331
-	 *
332
-	 * @deprecated 5.9.0 No longer used in In-App Marketplace
333
-	 *
334
-	 * @param object $block Banner data.
335
-	 */
336
-	public static function output_banner_block( $block ) {
337
-		?>
21
+    /**
22
+     * Get featured for the addons screen
23
+     *
24
+     * @deprecated 5.9.0 No longer used in In-App Marketplace
25
+     *
26
+     * @return array of objects
27
+     */
28
+    public static function get_featured() {
29
+        $featured = get_transient( 'wc_addons_featured_2' );
30
+        if ( false === $featured ) {
31
+            $headers = array();
32
+            $auth    = WC_Helper_Options::get( 'auth' );
33
+
34
+            if ( ! empty( $auth['access_token'] ) ) {
35
+                $headers['Authorization'] = 'Bearer ' . $auth['access_token'];
36
+            }
37
+
38
+            $raw_featured = wp_safe_remote_get(
39
+                'https://woocommerce.com/wp-json/wccom-extensions/1.0/featured',
40
+                array(
41
+                    'headers' => $headers,
42
+                )
43
+            );
44
+
45
+            if ( ! is_wp_error( $raw_featured ) ) {
46
+                $featured = json_decode( wp_remote_retrieve_body( $raw_featured ) );
47
+                if ( $featured ) {
48
+                    set_transient( 'wc_addons_featured_2', $featured, DAY_IN_SECONDS );
49
+                }
50
+            }
51
+        }
52
+
53
+        if ( is_object( $featured ) ) {
54
+            self::output_featured_sections( $featured->sections );
55
+            return $featured;
56
+        }
57
+    }
58
+
59
+    /**
60
+     * Render featured products and banners using WCCOM's the Featured 2.0 Endpoint
61
+     *
62
+     * @return void
63
+     */
64
+    public static function render_featured() {
65
+        $featured = get_transient( 'wc_addons_featured' );
66
+        if ( false === $featured ) {
67
+            $headers = array();
68
+            $auth    = WC_Helper_Options::get( 'auth' );
69
+
70
+            if ( ! empty( $auth['access_token'] ) ) {
71
+                $headers['Authorization'] = 'Bearer ' . $auth['access_token'];
72
+            }
73
+
74
+            $parameter_string = '';
75
+            $country          = WC()->countries->get_base_country();
76
+            if ( ! empty( $country ) ) {
77
+                $parameter_string = '?' . http_build_query( array( 'country' => $country ) );
78
+            }
79
+
80
+            // Important: WCCOM Extensions API v2.0 is used.
81
+            $raw_featured = wp_safe_remote_get(
82
+                'https://woocommerce.com/wp-json/wccom-extensions/2.0/featured' . $parameter_string,
83
+                array(
84
+                    'headers' => $headers,
85
+                )
86
+            );
87
+
88
+            if ( is_wp_error( $raw_featured ) ) {
89
+                do_action( 'woocommerce_page_wc-addons_connection_error', $raw_featured->get_error_message() );
90
+
91
+                $message = self::is_ssl_error( $raw_featured->get_error_message() )
92
+                    ? __( 'We encountered an SSL error. Please ensure your site supports TLS version 1.2 or above.', 'woocommerce' )
93
+                    : $raw_featured->get_error_message();
94
+
95
+                self::output_empty( $message );
96
+
97
+                return;
98
+            }
99
+
100
+            $response_code = (int) wp_remote_retrieve_response_code( $raw_featured );
101
+            if ( 200 !== $response_code ) {
102
+                do_action( 'woocommerce_page_wc-addons_connection_error', $response_code );
103
+
104
+                /* translators: %d: HTTP error code. */
105
+                $message = sprintf(
106
+                    esc_html(
107
+                        /* translators: Error code  */
108
+                        __(
109
+                            'Our request to the featured API got error code %d.',
110
+                            'woocommerce'
111
+                        )
112
+                    ),
113
+                    $response_code
114
+                );
115
+
116
+                self::output_empty( $message );
117
+
118
+                return;
119
+            }
120
+
121
+            $featured      = json_decode( wp_remote_retrieve_body( $raw_featured ) );
122
+            if ( empty( $featured ) || ! is_array( $featured ) ) {
123
+                do_action( 'woocommerce_page_wc-addons_connection_error', 'Empty or malformed response' );
124
+                $message = __( 'Our request to the featured API got a malformed response.', 'woocommerce' );
125
+                self::output_empty( $message );
126
+
127
+                return;
128
+            }
129
+
130
+            if ( $featured ) {
131
+                set_transient( 'wc_addons_featured', $featured, DAY_IN_SECONDS );
132
+            }
133
+        }
134
+
135
+        self::output_featured( $featured );
136
+    }
137
+
138
+    /**
139
+     * Check if the error is due to an SSL error
140
+     *
141
+     * @param string $error_message Error message.
142
+     *
143
+     * @return bool True if SSL error, false otherwise
144
+     */
145
+    public static function is_ssl_error( $error_message ) {
146
+        return false !== stripos( $error_message, 'cURL error 35' );
147
+    }
148
+
149
+    /**
150
+     * Build url parameter string
151
+     *
152
+     * @param  string $category Addon (sub) category.
153
+     * @param  string $term     Search terms.
154
+     * @param  string $country  Store country.
155
+     *
156
+     * @return string url parameter string
157
+     */
158
+    public static function build_parameter_string( $category, $term, $country ) {
159
+
160
+        $parameters = array(
161
+            'category' => $category,
162
+            'term'     => $term,
163
+            'country'  => $country,
164
+        );
165
+
166
+        return '?' . http_build_query( $parameters );
167
+    }
168
+
169
+    /**
170
+     * Call API to get extensions
171
+     *
172
+     * @param  string $category Addon (sub) category.
173
+     * @param  string $term     Search terms.
174
+     * @param  string $country  Store country.
175
+     *
176
+     * @return object|WP_Error  Object with products and promotions properties, or WP_Error
177
+     */
178
+    public static function get_extension_data( $category, $term, $country ) {
179
+        $parameters = self::build_parameter_string( $category, $term, $country );
180
+
181
+        $headers = array();
182
+        $auth    = WC_Helper_Options::get( 'auth' );
183
+
184
+        if ( ! empty( $auth['access_token'] ) ) {
185
+            $headers['Authorization'] = 'Bearer ' . $auth['access_token'];
186
+        }
187
+
188
+        $raw_extensions = wp_safe_remote_get(
189
+            'https://woocommerce.com/wp-json/wccom-extensions/1.0/search' . $parameters,
190
+            array( 'headers' => $headers )
191
+        );
192
+
193
+        if ( is_wp_error( $raw_extensions ) ) {
194
+            do_action( 'woocommerce_page_wc-addons_connection_error', $raw_extensions->get_error_message() );
195
+            return $raw_extensions;
196
+        }
197
+
198
+        $response_code = (int) wp_remote_retrieve_response_code( $raw_extensions );
199
+        if ( 200 !== $response_code ) {
200
+            do_action( 'woocommerce_page_wc-addons_connection_error', $response_code );
201
+            return new WP_Error(
202
+                'error',
203
+                sprintf(
204
+                    esc_html(
205
+                        /* translators: Error code  */
206
+                        __( 'Our request to the search API got response code %s.', 'woocommerce' )
207
+                    ),
208
+                    $response_code
209
+                )
210
+            );
211
+        }
212
+
213
+        $addons = json_decode( wp_remote_retrieve_body( $raw_extensions ) );
214
+
215
+        if ( ! is_object( $addons ) || ! isset( $addons->products ) ) {
216
+            do_action( 'woocommerce_page_wc-addons_connection_error', 'Empty or malformed response' );
217
+            return new WP_Error( 'error', __( 'Our request to the search API got a malformed response.', 'woocommerce' ) );
218
+        }
219
+
220
+        return $addons;
221
+    }
222
+
223
+    /**
224
+     * Get sections for the addons screen
225
+     *
226
+     * @return array of objects
227
+     */
228
+    public static function get_sections() {
229
+        $addon_sections = get_transient( 'wc_addons_sections' );
230
+        if ( false === ( $addon_sections ) ) {
231
+            $raw_sections = wp_safe_remote_get(
232
+                'https://woocommerce.com/wp-json/wccom-extensions/1.0/categories'
233
+            );
234
+            if ( ! is_wp_error( $raw_sections ) ) {
235
+                $addon_sections = json_decode( wp_remote_retrieve_body( $raw_sections ) );
236
+                if ( $addon_sections ) {
237
+                    set_transient( 'wc_addons_sections', $addon_sections, WEEK_IN_SECONDS );
238
+                }
239
+            }
240
+        }
241
+        return apply_filters( 'woocommerce_addons_sections', $addon_sections );
242
+    }
243
+
244
+    /**
245
+     * Get section for the addons screen.
246
+     *
247
+     * @param  string $section_id Required section ID.
248
+     *
249
+     * @return object|bool
250
+     */
251
+    public static function get_section( $section_id ) {
252
+        $sections = self::get_sections();
253
+        if ( isset( $sections[ $section_id ] ) ) {
254
+            return $sections[ $section_id ];
255
+        }
256
+        return false;
257
+    }
258
+
259
+
260
+    /**
261
+     * Get section content for the addons screen.
262
+     *
263
+     * @deprecated 5.9.0 No longer used in In-App Marketplace
264
+     *
265
+     * @param  string $section_id Required section ID.
266
+     *
267
+     * @return array
268
+     */
269
+    public static function get_section_data( $section_id ) {
270
+        $section      = self::get_section( $section_id );
271
+        $section_data = '';
272
+
273
+        if ( ! empty( $section->endpoint ) ) {
274
+            $section_data = get_transient( 'wc_addons_section_' . $section_id );
275
+            if ( false === $section_data ) {
276
+                $raw_section = wp_safe_remote_get( esc_url_raw( $section->endpoint ) );
277
+
278
+                if ( ! is_wp_error( $raw_section ) ) {
279
+                    $section_data = json_decode( wp_remote_retrieve_body( $raw_section ) );
280
+
281
+                    if ( ! empty( $section_data->products ) ) {
282
+                        set_transient( 'wc_addons_section_' . $section_id, $section_data, WEEK_IN_SECONDS );
283
+                    }
284
+                }
285
+            }
286
+        }
287
+
288
+        return apply_filters( 'woocommerce_addons_section_data', $section_data->products, $section_id );
289
+    }
290
+
291
+    /**
292
+     * Handles the outputting of a contextually aware Storefront link (points to child themes if Storefront is already active).
293
+     *
294
+     * @deprecated 5.9.0 No longer used in In-App Marketplace
295
+     */
296
+    public static function output_storefront_button() {
297
+        $template   = get_option( 'template' );
298
+        $stylesheet = get_option( 'stylesheet' );
299
+
300
+        if ( 'storefront' === $template ) {
301
+            if ( 'storefront' === $stylesheet ) {
302
+                $url         = 'https://woocommerce.com/product-category/themes/storefront-child-theme-themes/';
303
+                $text        = __( 'Need a fresh look? Try Storefront child themes', 'woocommerce' );
304
+                $utm_content = 'nostorefrontchildtheme';
305
+            } else {
306
+                $url         = 'https://woocommerce.com/product-category/themes/storefront-child-theme-themes/';
307
+                $text        = __( 'View more Storefront child themes', 'woocommerce' );
308
+                $utm_content = 'hasstorefrontchildtheme';
309
+            }
310
+        } else {
311
+            $url         = 'https://woocommerce.com/storefront/';
312
+            $text        = __( 'Need a theme? Try Storefront', 'woocommerce' );
313
+            $utm_content = 'nostorefront';
314
+        }
315
+
316
+        $url = add_query_arg(
317
+            array(
318
+                'utm_source'   => 'addons',
319
+                'utm_medium'   => 'product',
320
+                'utm_campaign' => 'woocommerceplugin',
321
+                'utm_content'  => $utm_content,
322
+            ),
323
+            $url
324
+        );
325
+
326
+        echo '<a href="' . esc_url( $url ) . '" class="add-new-h2">' . esc_html( $text ) . '</a>' . "\n";
327
+    }
328
+
329
+    /**
330
+     * Handles the outputting of a banner block.
331
+     *
332
+     * @deprecated 5.9.0 No longer used in In-App Marketplace
333
+     *
334
+     * @param object $block Banner data.
335
+     */
336
+    public static function output_banner_block( $block ) {
337
+        ?>
338 338
 		<div class="addons-banner-block">
339 339
 			<h1><?php echo esc_html( $block->title ); ?></h1>
340 340
 			<p><?php echo esc_html( $block->description ); ?></p>
@@ -349,13 +349,13 @@  discard block
 block discarded – undo
349 349
 								<h3><?php echo esc_html( $item->title ); ?></h3>
350 350
 								<p><?php echo esc_html( $item->description ); ?></p>
351 351
 								<?php
352
-									self::output_button(
353
-										$item->href,
354
-										$item->button,
355
-										'addons-button-solid',
356
-										$item->plugin
357
-									);
358
-								?>
352
+                                    self::output_button(
353
+                                        $item->href,
354
+                                        $item->button,
355
+                                        'addons-button-solid',
356
+                                        $item->plugin
357
+                                    );
358
+                                ?>
359 359
 							</div>
360 360
 						</div>
361 361
 					<?php endif; ?>
@@ -363,46 +363,46 @@  discard block
 block discarded – undo
363 363
 			</div>
364 364
 		</div>
365 365
 		<?php
366
-	}
367
-
368
-	/**
369
-	 * Handles the outputting of a column.
370
-	 *
371
-	 * @deprecated 5.9.0 No longer used in In-App Marketplace
372
-	 *
373
-	 * @param object $block Column data.
374
-	 */
375
-	public static function output_column( $block ) {
376
-		if ( isset( $block->container ) && 'column_container_start' === $block->container ) {
377
-			?>
366
+    }
367
+
368
+    /**
369
+     * Handles the outputting of a column.
370
+     *
371
+     * @deprecated 5.9.0 No longer used in In-App Marketplace
372
+     *
373
+     * @param object $block Column data.
374
+     */
375
+    public static function output_column( $block ) {
376
+        if ( isset( $block->container ) && 'column_container_start' === $block->container ) {
377
+            ?>
378 378
 			<div class="addons-column-section">
379 379
 			<?php
380
-		}
381
-		if ( 'column_start' === $block->module ) {
382
-			?>
380
+        }
381
+        if ( 'column_start' === $block->module ) {
382
+            ?>
383 383
 			<div class="addons-column">
384 384
 			<?php
385
-		} else {
386
-			?>
385
+        } else {
386
+            ?>
387 387
 			</div>
388 388
 			<?php
389
-		}
390
-		if ( isset( $block->container ) && 'column_container_end' === $block->container ) {
391
-			?>
389
+        }
390
+        if ( isset( $block->container ) && 'column_container_end' === $block->container ) {
391
+            ?>
392 392
 			</div>
393 393
 			<?php
394
-		}
395
-	}
396
-
397
-	/**
398
-	 * Handles the outputting of a column block.
399
-	 *
400
-	 * @deprecated 5.9.0 No longer used in In-App Marketplace
401
-	 *
402
-	 * @param object $block Column block data.
403
-	 */
404
-	public static function output_column_block( $block ) {
405
-		?>
394
+        }
395
+    }
396
+
397
+    /**
398
+     * Handles the outputting of a column block.
399
+     *
400
+     * @deprecated 5.9.0 No longer used in In-App Marketplace
401
+     *
402
+     * @param object $block Column block data.
403
+     */
404
+    public static function output_column_block( $block ) {
405
+        ?>
406 406
 		<div class="addons-column-block">
407 407
 			<h1><?php echo esc_html( $block->title ); ?></h1>
408 408
 			<p><?php echo esc_html( $block->description ); ?></p>
@@ -415,13 +415,13 @@  discard block
 block discarded – undo
415 415
 						<div class="addons-column-block-item-content">
416 416
 							<h2><?php echo esc_html( $item->title ); ?></h2>
417 417
 							<?php
418
-								self::output_button(
419
-									$item->href,
420
-									$item->button,
421
-									'addons-button-solid',
422
-									$item->plugin
423
-								);
424
-							?>
418
+                                self::output_button(
419
+                                    $item->href,
420
+                                    $item->button,
421
+                                    'addons-button-solid',
422
+                                    $item->plugin
423
+                                );
424
+                            ?>
425 425
 							<p><?php echo esc_html( $item->description ); ?></p>
426 426
 						</div>
427 427
 					</div>
@@ -430,17 +430,17 @@  discard block
 block discarded – undo
430 430
 		</div>
431 431
 
432 432
 		<?php
433
-	}
434
-
435
-	/**
436
-	 * Handles the outputting of a small light block.
437
-	 *
438
-	 * @deprecated 5.9.0 No longer used in In-App Marketplace
439
-	 *
440
-	 * @param object $block Block data.
441
-	 */
442
-	public static function output_small_light_block( $block ) {
443
-		?>
433
+    }
434
+
435
+    /**
436
+     * Handles the outputting of a small light block.
437
+     *
438
+     * @deprecated 5.9.0 No longer used in In-App Marketplace
439
+     *
440
+     * @param object $block Block data.
441
+     */
442
+    public static function output_small_light_block( $block ) {
443
+        ?>
444 444
 		<div class="addons-small-light-block">
445 445
 			<img class="addons-img" src="<?php echo esc_url( $block->image ); ?>" />
446 446
 			<div class="addons-small-light-block-content">
@@ -449,28 +449,28 @@  discard block
 block discarded – undo
449 449
 				<div class="addons-small-light-block-buttons">
450 450
 					<?php foreach ( $block->buttons as $button ) : ?>
451 451
 						<?php
452
-							self::output_button(
453
-								$button->href,
454
-								$button->text,
455
-								'addons-button-solid'
456
-							);
457
-						?>
452
+                            self::output_button(
453
+                                $button->href,
454
+                                $button->text,
455
+                                'addons-button-solid'
456
+                            );
457
+                        ?>
458 458
 					<?php endforeach; ?>
459 459
 				</div>
460 460
 			</div>
461 461
 		</div>
462 462
 		<?php
463
-	}
464
-
465
-	/**
466
-	 * Handles the outputting of a small dark block.
467
-	 *
468
-	 * @deprecated 5.9.0 No longer used in In-App Marketplace
469
-	 *
470
-	 * @param object $block Block data.
471
-	 */
472
-	public static function output_small_dark_block( $block ) {
473
-		?>
463
+    }
464
+
465
+    /**
466
+     * Handles the outputting of a small dark block.
467
+     *
468
+     * @deprecated 5.9.0 No longer used in In-App Marketplace
469
+     *
470
+     * @param object $block Block data.
471
+     */
472
+    public static function output_small_dark_block( $block ) {
473
+        ?>
474 474
 		<div class="addons-small-dark-block">
475 475
 			<h1><?php echo esc_html( $block->title ); ?></h1>
476 476
 			<p><?php echo esc_html( $block->description ); ?></p>
@@ -483,82 +483,82 @@  discard block
 block discarded – undo
483 483
 							</div>
484 484
 						<?php endif; ?>
485 485
 						<?php
486
-							self::output_button(
487
-								$item->href,
488
-								$item->button,
489
-								'addons-button-outline-white'
490
-							);
491
-						?>
486
+                            self::output_button(
487
+                                $item->href,
488
+                                $item->button,
489
+                                'addons-button-outline-white'
490
+                            );
491
+                        ?>
492 492
 					</div>
493 493
 				<?php endforeach; ?>
494 494
 			</div>
495 495
 		</div>
496 496
 		<?php
497
-	}
498
-
499
-	/**
500
-	 * Handles the outputting of the WooCommerce Services banner block.
501
-	 *
502
-	 * @deprecated 5.9.0 No longer used in In-App Marketplace
503
-	 *
504
-	 * @param object $block Block data.
505
-	 */
506
-	public static function output_wcs_banner_block( $block = array() ) {
507
-		$is_active = is_plugin_active( 'woocommerce-services/woocommerce-services.php' );
508
-		$location  = wc_get_base_location();
509
-
510
-		if (
511
-			! in_array( $location['country'], array( 'US' ), true ) ||
512
-			$is_active ||
513
-			! current_user_can( 'install_plugins' ) ||
514
-			! current_user_can( 'activate_plugins' )
515
-		) {
516
-			return;
517
-		}
518
-
519
-		$button_url = wp_nonce_url(
520
-			add_query_arg(
521
-				array(
522
-					'install-addon' => 'woocommerce-services',
523
-				)
524
-			),
525
-			'install-addon_woocommerce-services'
526
-		);
527
-
528
-		$defaults = array(
529
-			'image'       => WC()->plugin_url() . '/assets/images/wcs-extensions-banner-3x.jpg',
530
-			'image_alt'   => __( 'WooCommerce Shipping', 'woocommerce' ),
531
-			'title'       => __( 'Save time and money with WooCommerce Shipping', 'woocommerce' ),
532
-			'description' => __( 'Print discounted USPS and DHL labels straight from your WooCommerce dashboard and save on shipping.', 'woocommerce' ),
533
-			'button'      => __( 'Free - Install now', 'woocommerce' ),
534
-			'href'        => $button_url,
535
-			'logos'       => array(),
536
-		);
537
-
538
-		switch ( $location['country'] ) {
539
-			case 'US':
540
-				$local_defaults = array(
541
-					'logos' => array_merge(
542
-						$defaults['logos'],
543
-						array(
544
-							array(
545
-								'link' => WC()->plugin_url() . '/assets/images/wcs-usps-logo.png',
546
-								'alt'  => 'USPS logo',
547
-							),
548
-							array(
549
-								'link' => WC()->plugin_url() . '/assets/images/wcs-dhlexpress-logo.png',
550
-								'alt'  => 'DHL Express logo',
551
-							),
552
-						)
553
-					),
554
-				);
555
-				break;
556
-			default:
557
-				$local_defaults = array();
558
-		}
559
-
560
-		$block_data = array_merge( $defaults, $local_defaults, $block );
561
-		?>
497
+    }
498
+
499
+    /**
500
+     * Handles the outputting of the WooCommerce Services banner block.
501
+     *
502
+     * @deprecated 5.9.0 No longer used in In-App Marketplace
503
+     *
504
+     * @param object $block Block data.
505
+     */
506
+    public static function output_wcs_banner_block( $block = array() ) {
507
+        $is_active = is_plugin_active( 'woocommerce-services/woocommerce-services.php' );
508
+        $location  = wc_get_base_location();
509
+
510
+        if (
511
+            ! in_array( $location['country'], array( 'US' ), true ) ||
512
+            $is_active ||
513
+            ! current_user_can( 'install_plugins' ) ||
514
+            ! current_user_can( 'activate_plugins' )
515
+        ) {
516
+            return;
517
+        }
518
+
519
+        $button_url = wp_nonce_url(
520
+            add_query_arg(
521
+                array(
522
+                    'install-addon' => 'woocommerce-services',
523
+                )
524
+            ),
525
+            'install-addon_woocommerce-services'
526
+        );
527
+
528
+        $defaults = array(
529
+            'image'       => WC()->plugin_url() . '/assets/images/wcs-extensions-banner-3x.jpg',
530
+            'image_alt'   => __( 'WooCommerce Shipping', 'woocommerce' ),
531
+            'title'       => __( 'Save time and money with WooCommerce Shipping', 'woocommerce' ),
532
+            'description' => __( 'Print discounted USPS and DHL labels straight from your WooCommerce dashboard and save on shipping.', 'woocommerce' ),
533
+            'button'      => __( 'Free - Install now', 'woocommerce' ),
534
+            'href'        => $button_url,
535
+            'logos'       => array(),
536
+        );
537
+
538
+        switch ( $location['country'] ) {
539
+            case 'US':
540
+                $local_defaults = array(
541
+                    'logos' => array_merge(
542
+                        $defaults['logos'],
543
+                        array(
544
+                            array(
545
+                                'link' => WC()->plugin_url() . '/assets/images/wcs-usps-logo.png',
546
+                                'alt'  => 'USPS logo',
547
+                            ),
548
+                            array(
549
+                                'link' => WC()->plugin_url() . '/assets/images/wcs-dhlexpress-logo.png',
550
+                                'alt'  => 'DHL Express logo',
551
+                            ),
552
+                        )
553
+                    ),
554
+                );
555
+                break;
556
+            default:
557
+                $local_defaults = array();
558
+        }
559
+
560
+        $block_data = array_merge( $defaults, $local_defaults, $block );
561
+        ?>
562 562
 		<div class="addons-wcs-banner-block">
563 563
 			<div class="addons-wcs-banner-block-image is-full-image">
564 564
 				<img
@@ -582,58 +582,58 @@  discard block
 block discarded – undo
582 582
 					<?php endforeach; ?>
583 583
 				</ul>
584 584
 				<?php
585
-					self::output_button(
586
-						$block_data['href'],
587
-						$block_data['button'],
588
-						'addons-button-outline-purple'
589
-					);
590
-				?>
585
+                    self::output_button(
586
+                        $block_data['href'],
587
+                        $block_data['button'],
588
+                        'addons-button-outline-purple'
589
+                    );
590
+                ?>
591 591
 			</div>
592 592
 		</div>
593 593
 		<?php
594
-	}
595
-
596
-	/**
597
-	 * Handles the outputting of the WooCommerce Pay banner block.
598
-	 *
599
-	 * @deprecated 5.9.0 No longer used in In-App Marketplace
600
-	 *
601
-	 * @param object $block Block data.
602
-	 */
603
-	public static function output_wcpay_banner_block( $block = array() ) {
604
-		$is_active = is_plugin_active( 'woocommerce-payments/woocommerce-payments.php' );
605
-		$location  = wc_get_base_location();
606
-
607
-		if (
608
-			! in_array( $location['country'], array( 'US' ), true ) ||
609
-			$is_active ||
610
-			! current_user_can( 'install_plugins' ) ||
611
-			! current_user_can( 'activate_plugins' )
612
-		) {
613
-			return;
614
-		}
615
-
616
-		$button_url = wp_nonce_url(
617
-			add_query_arg(
618
-				array(
619
-					'install-addon' => 'woocommerce-payments',
620
-				)
621
-			),
622
-			'install-addon_woocommerce-payments'
623
-		);
624
-
625
-		$defaults = array(
626
-			'image'       => WC()->plugin_url() . '/assets/images/wcpayments-icon-secure.png',
627
-			'image_alt'   => __( 'WooCommerce Payments', 'woocommerce' ),
628
-			'title'       => __( 'Payments made simple, with no monthly fees &mdash; exclusively for WooCommerce stores.', 'woocommerce' ),
629
-			'description' => __( 'Securely accept cards in your store. See payments, track cash flow into your bank account, and stay on top of disputes – right from your dashboard.', 'woocommerce' ),
630
-			'button'      => __( 'Free - Install now', 'woocommerce' ),
631
-			'href'        => $button_url,
632
-			'logos'       => array(),
633
-		);
634
-
635
-		$block_data = array_merge( $defaults, $block );
636
-		?>
594
+    }
595
+
596
+    /**
597
+     * Handles the outputting of the WooCommerce Pay banner block.
598
+     *
599
+     * @deprecated 5.9.0 No longer used in In-App Marketplace
600
+     *
601
+     * @param object $block Block data.
602
+     */
603
+    public static function output_wcpay_banner_block( $block = array() ) {
604
+        $is_active = is_plugin_active( 'woocommerce-payments/woocommerce-payments.php' );
605
+        $location  = wc_get_base_location();
606
+
607
+        if (
608
+            ! in_array( $location['country'], array( 'US' ), true ) ||
609
+            $is_active ||
610
+            ! current_user_can( 'install_plugins' ) ||
611
+            ! current_user_can( 'activate_plugins' )
612
+        ) {
613
+            return;
614
+        }
615
+
616
+        $button_url = wp_nonce_url(
617
+            add_query_arg(
618
+                array(
619
+                    'install-addon' => 'woocommerce-payments',
620
+                )
621
+            ),
622
+            'install-addon_woocommerce-payments'
623
+        );
624
+
625
+        $defaults = array(
626
+            'image'       => WC()->plugin_url() . '/assets/images/wcpayments-icon-secure.png',
627
+            'image_alt'   => __( 'WooCommerce Payments', 'woocommerce' ),
628
+            'title'       => __( 'Payments made simple, with no monthly fees &mdash; exclusively for WooCommerce stores.', 'woocommerce' ),
629
+            'description' => __( 'Securely accept cards in your store. See payments, track cash flow into your bank account, and stay on top of disputes – right from your dashboard.', 'woocommerce' ),
630
+            'button'      => __( 'Free - Install now', 'woocommerce' ),
631
+            'href'        => $button_url,
632
+            'logos'       => array(),
633
+        );
634
+
635
+        $block_data = array_merge( $defaults, $block );
636
+        ?>
637 637
 		<div class="addons-wcs-banner-block">
638 638
 			<div class="addons-wcs-banner-block-image">
639 639
 				<img
@@ -646,26 +646,26 @@  discard block
 block discarded – undo
646 646
 				<h1><?php echo esc_html( $block_data['title'] ); ?></h1>
647 647
 				<p><?php echo esc_html( $block_data['description'] ); ?></p>
648 648
 				<?php
649
-					self::output_button(
650
-						$block_data['href'],
651
-						$block_data['button'],
652
-						'addons-button-outline-purple'
653
-					);
654
-				?>
649
+                    self::output_button(
650
+                        $block_data['href'],
651
+                        $block_data['button'],
652
+                        'addons-button-outline-purple'
653
+                    );
654
+                ?>
655 655
 			</div>
656 656
 		</div>
657 657
 		<?php
658
-	}
658
+    }
659 659
 
660 660
 
661
-	/**
662
-	 * Output the HTML for the promotion block.
663
-	 *
664
-	 * @param array $promotion Array of promotion block data.
665
-	 * @return void
666
-	 */
667
-	public static function output_search_promotion_block( array $promotion ) {
668
-		?>
661
+    /**
662
+     * Output the HTML for the promotion block.
663
+     *
664
+     * @param array $promotion Array of promotion block data.
665
+     * @return void
666
+     */
667
+    public static function output_search_promotion_block( array $promotion ) {
668
+        ?>
669 669
 		<div class="addons-wcs-banner-block">
670 670
 			<div class="addons-wcs-banner-block-image">
671 671
 				<img
@@ -678,48 +678,48 @@  discard block
 block discarded – undo
678 678
 				<h1><?php echo esc_html( $promotion['title'] ); ?></h1>
679 679
 				<p><?php echo esc_html( $promotion['description'] ); ?></p>
680 680
 				<?php
681
-				if ( ! empty( $promotion['actions'] ) ) {
682
-					foreach ( $promotion['actions'] as $action ) {
683
-						self::output_promotion_action( $action );
684
-					}
685
-				}
686
-				?>
681
+                if ( ! empty( $promotion['actions'] ) ) {
682
+                    foreach ( $promotion['actions'] as $action ) {
683
+                        self::output_promotion_action( $action );
684
+                    }
685
+                }
686
+                ?>
687 687
 			</div>
688 688
 		</div>
689 689
 		<?php
690
-	}
691
-
692
-
693
-	/**
694
-	 * Handles the output of a full-width block.
695
-	 *
696
-	 * @deprecated 5.9.0 No longer used in In-App Marketplace
697
-	 *
698
-	 * @param array $section Section data.
699
-	 */
700
-	public static function output_promotion_block( $section ) {
701
-		if (
702
-			! current_user_can( 'install_plugins' ) ||
703
-			! current_user_can( 'activate_plugins' )
704
-		) {
705
-			return;
706
-		}
707
-
708
-		$section_object = (object) $section;
709
-
710
-		if ( ! empty( $section_object->geowhitelist ) ) {
711
-			$section_object->geowhitelist = explode( ',', $section_object->geowhitelist );
712
-		}
713
-
714
-		if ( ! empty( $section_object->geoblacklist ) ) {
715
-			$section_object->geoblacklist = explode( ',', $section_object->geoblacklist );
716
-		}
717
-
718
-		if ( ! self::show_extension( $section_object ) ) {
719
-			return;
720
-		}
721
-
722
-		?>
690
+    }
691
+
692
+
693
+    /**
694
+     * Handles the output of a full-width block.
695
+     *
696
+     * @deprecated 5.9.0 No longer used in In-App Marketplace
697
+     *
698
+     * @param array $section Section data.
699
+     */
700
+    public static function output_promotion_block( $section ) {
701
+        if (
702
+            ! current_user_can( 'install_plugins' ) ||
703
+            ! current_user_can( 'activate_plugins' )
704
+        ) {
705
+            return;
706
+        }
707
+
708
+        $section_object = (object) $section;
709
+
710
+        if ( ! empty( $section_object->geowhitelist ) ) {
711
+            $section_object->geowhitelist = explode( ',', $section_object->geowhitelist );
712
+        }
713
+
714
+        if ( ! empty( $section_object->geoblacklist ) ) {
715
+            $section_object->geoblacklist = explode( ',', $section_object->geoblacklist );
716
+        }
717
+
718
+        if ( ! self::show_extension( $section_object ) ) {
719
+            return;
720
+        }
721
+
722
+        ?>
723 723
 		<div class="addons-banner-block addons-promotion-block">
724 724
 			<img
725 725
 				class="addons-img"
@@ -733,100 +733,100 @@  discard block
 block discarded – undo
733 733
 				</div>
734 734
 				<div class="addons-promotion-block-buttons">
735 735
 					<?php
736
-					if ( $section['button_1'] ) {
737
-						self::output_button(
738
-							$section['button_1_href'],
739
-							$section['button_1'],
740
-							'addons-button-expandable addons-button-solid',
741
-							$section['plugin']
742
-						);
743
-					}
744
-
745
-					if ( $section['button_2'] ) {
746
-						self::output_button(
747
-							$section['button_2_href'],
748
-							$section['button_2'],
749
-							'addons-button-expandable addons-button-outline-purple',
750
-							$section['plugin']
751
-						);
752
-					}
753
-					?>
736
+                    if ( $section['button_1'] ) {
737
+                        self::output_button(
738
+                            $section['button_1_href'],
739
+                            $section['button_1'],
740
+                            'addons-button-expandable addons-button-solid',
741
+                            $section['plugin']
742
+                        );
743
+                    }
744
+
745
+                    if ( $section['button_2'] ) {
746
+                        self::output_button(
747
+                            $section['button_2_href'],
748
+                            $section['button_2'],
749
+                            'addons-button-expandable addons-button-outline-purple',
750
+                            $section['plugin']
751
+                        );
752
+                    }
753
+                    ?>
754 754
 				</div>
755 755
 			</div>
756 756
 		</div>
757 757
 		<?php
758
-	}
759
-
760
-	/**
761
-	 * Handles the outputting of featured sections
762
-	 *
763
-	 * @param array $sections Section data.
764
-	 */
765
-	public static function output_featured_sections( $sections ) {
766
-		foreach ( $sections as $section ) {
767
-			switch ( $section->module ) {
768
-				case 'banner_block':
769
-					self::output_banner_block( $section );
770
-					break;
771
-				case 'column_start':
772
-					self::output_column( $section );
773
-					break;
774
-				case 'column_end':
775
-					self::output_column( $section );
776
-					break;
777
-				case 'column_block':
778
-					self::output_column_block( $section );
779
-					break;
780
-				case 'small_light_block':
781
-					self::output_small_light_block( $section );
782
-					break;
783
-				case 'small_dark_block':
784
-					self::output_small_dark_block( $section );
785
-					break;
786
-				case 'wcs_banner_block':
787
-					self::output_wcs_banner_block( (array) $section );
788
-					break;
789
-				case 'wcpay_banner_block':
790
-					self::output_wcpay_banner_block( (array) $section );
791
-					break;
792
-				case 'promotion_block':
793
-					self::output_promotion_block( (array) $section );
794
-					break;
795
-			}
796
-		}
797
-	}
798
-
799
-	/**
800
-	 * Handles the outputting of featured page
801
-	 *
802
-	 * @param array $blocks Featured page's blocks.
803
-	 */
804
-	private static function output_featured( $blocks ) {
805
-		foreach ( $blocks as $block ) {
806
-			$block_type = $block->type ?? null;
807
-			switch ( $block_type ) {
808
-				case 'group':
809
-					self::output_group( $block );
810
-					break;
811
-				case 'banner':
812
-					self::output_banner( $block );
813
-					break;
814
-			}
815
-		}
816
-	}
817
-
818
-	/**
819
-	 * Render a group block including products
820
-	 *
821
-	 * @param mixed $block Block of the page for rendering.
822
-	 *
823
-	 * @return void
824
-	 */
825
-	private static function output_group( $block ) {
826
-		$capacity             = $block->capacity ?? 3;
827
-		$product_list_classes = 3 === $capacity ? 'three-column' : 'two-column';
828
-		$product_list_classes = 'products addons-products-' . $product_list_classes;
829
-		?>
758
+    }
759
+
760
+    /**
761
+     * Handles the outputting of featured sections
762
+     *
763
+     * @param array $sections Section data.
764
+     */
765
+    public static function output_featured_sections( $sections ) {
766
+        foreach ( $sections as $section ) {
767
+            switch ( $section->module ) {
768
+                case 'banner_block':
769
+                    self::output_banner_block( $section );
770
+                    break;
771
+                case 'column_start':
772
+                    self::output_column( $section );
773
+                    break;
774
+                case 'column_end':
775
+                    self::output_column( $section );
776
+                    break;
777
+                case 'column_block':
778
+                    self::output_column_block( $section );
779
+                    break;
780
+                case 'small_light_block':
781
+                    self::output_small_light_block( $section );
782
+                    break;
783
+                case 'small_dark_block':
784
+                    self::output_small_dark_block( $section );
785
+                    break;
786
+                case 'wcs_banner_block':
787
+                    self::output_wcs_banner_block( (array) $section );
788
+                    break;
789
+                case 'wcpay_banner_block':
790
+                    self::output_wcpay_banner_block( (array) $section );
791
+                    break;
792
+                case 'promotion_block':
793
+                    self::output_promotion_block( (array) $section );
794
+                    break;
795
+            }
796
+        }
797
+    }
798
+
799
+    /**
800
+     * Handles the outputting of featured page
801
+     *
802
+     * @param array $blocks Featured page's blocks.
803
+     */
804
+    private static function output_featured( $blocks ) {
805
+        foreach ( $blocks as $block ) {
806
+            $block_type = $block->type ?? null;
807
+            switch ( $block_type ) {
808
+                case 'group':
809
+                    self::output_group( $block );
810
+                    break;
811
+                case 'banner':
812
+                    self::output_banner( $block );
813
+                    break;
814
+            }
815
+        }
816
+    }
817
+
818
+    /**
819
+     * Render a group block including products
820
+     *
821
+     * @param mixed $block Block of the page for rendering.
822
+     *
823
+     * @return void
824
+     */
825
+    private static function output_group( $block ) {
826
+        $capacity             = $block->capacity ?? 3;
827
+        $product_list_classes = 3 === $capacity ? 'three-column' : 'two-column';
828
+        $product_list_classes = 'products addons-products-' . $product_list_classes;
829
+        ?>
830 830
 			<section class="addon-product-group">
831 831
 				<h2 class="addon-product-group-title"><?php echo esc_html( $block->title ); ?></h2>
832 832
 				<div class="addon-product-group-description-container">
@@ -844,35 +844,35 @@  discard block
 block discarded – undo
844 844
 				<div class="addon-product-group__items">
845 845
 					<ul class="<?php echo esc_attr( $product_list_classes ); ?>">
846 846
 					<?php
847
-					$products = array_slice( $block->items, 0, $capacity );
848
-					foreach ( $products as $item ) {
849
-						self::render_product_card( $item );
850
-					}
851
-					?>
847
+                    $products = array_slice( $block->items, 0, $capacity );
848
+                    foreach ( $products as $item ) {
849
+                        self::render_product_card( $item );
850
+                    }
851
+                    ?>
852 852
 					</ul>
853 853
 				<div>
854 854
 			</section>
855 855
 		<?php
856
-	}
857
-
858
-	/**
859
-	 * Render a banner contains a product
860
-	 *
861
-	 * @param mixed $block Block of the page for rendering.
862
-	 *
863
-	 * @return void
864
-	 */
865
-	private static function output_banner( $block ) {
866
-		if ( empty( $block->buttons ) ) {
867
-			// Render a product-like banner.
868
-			?>
856
+    }
857
+
858
+    /**
859
+     * Render a banner contains a product
860
+     *
861
+     * @param mixed $block Block of the page for rendering.
862
+     *
863
+     * @return void
864
+     */
865
+    private static function output_banner( $block ) {
866
+        if ( empty( $block->buttons ) ) {
867
+            // Render a product-like banner.
868
+            ?>
869 869
 			<ul class="products">
870 870
 				<?php self::render_product_card( $block, $block->type ); ?>
871 871
 			</ul>
872 872
 			<?php
873
-		} else {
874
-			// Render a banner with buttons.
875
-			?>
873
+        } else {
874
+            // Render a banner with buttons.
875
+            ?>
876 876
 			<ul class="products">
877 877
 				<li class="product addons-buttons-banner">
878 878
 					<div class="addons-buttons-banner-image"
@@ -885,13 +885,13 @@  discard block
 block discarded – undo
885 885
 						</div>
886 886
 						<div class="addons-buttons-banner-button-container">
887 887
 						<?php
888
-						foreach ( $block->buttons as $button ) {
889
-							$button_classes = array( 'button', 'addons-buttons-banner-button' );
890
-							$type           = $button->type ?? null;
891
-							if ( 'primary' === $type ) {
892
-								$button_classes[] = 'addons-buttons-banner-button-primary';
893
-							}
894
-							?>
888
+                        foreach ( $block->buttons as $button ) {
889
+                            $button_classes = array( 'button', 'addons-buttons-banner-button' );
890
+                            $type           = $button->type ?? null;
891
+                            if ( 'primary' === $type ) {
892
+                                $button_classes[] = 'addons-buttons-banner-button-primary';
893
+                            }
894
+                            ?>
895 895
 							<a class="<?php echo esc_attr( implode( ' ', $button_classes ) ); ?>"
896 896
 								href="<?php echo esc_url( $button->href ); ?>">
897 897
 								<?php echo esc_html( $button->title ); ?>
@@ -902,91 +902,91 @@  discard block
 block discarded – undo
902 902
 				</li>
903 903
 			</ul>
904 904
 			<?php
905
-		}
906
-	}
907
-
908
-	/**
909
-	 * Returns in-app-purchase URL params.
910
-	 */
911
-	public static function get_in_app_purchase_url_params() {
912
-		// Get url (from path onward) for the current page,
913
-		// so WCCOM "back" link returns user to where they were.
914
-		$back_admin_path = add_query_arg( array() );
915
-		return array(
916
-			'wccom-site'          => site_url(),
917
-			'wccom-back'          => rawurlencode( $back_admin_path ),
918
-			'wccom-woo-version'   => Constants::get_constant( 'WC_VERSION' ),
919
-			'wccom-connect-nonce' => wp_create_nonce( 'connect' ),
920
-		);
921
-	}
922
-
923
-	/**
924
-	 * Add in-app-purchase URL params to link.
925
-	 *
926
-	 * Adds various url parameters to a url to support a streamlined
927
-	 * flow for obtaining and setting up WooCommerce extensons.
928
-	 *
929
-	 * @param string $url    Destination URL.
930
-	 */
931
-	public static function add_in_app_purchase_url_params( $url ) {
932
-		return add_query_arg(
933
-			self::get_in_app_purchase_url_params(),
934
-			$url
935
-		);
936
-	}
937
-
938
-	/**
939
-	 * Outputs a button.
940
-	 *
941
-	 * @param string $url    Destination URL.
942
-	 * @param string $text   Button label text.
943
-	 * @param string $style  Button style class.
944
-	 * @param string $plugin The plugin the button is promoting.
945
-	 */
946
-	public static function output_button( $url, $text, $style, $plugin = '' ) {
947
-		$style = __( 'Free', 'woocommerce' ) === $text ? 'addons-button-outline-purple' : $style;
948
-		$style = is_plugin_active( $plugin ) ? 'addons-button-installed' : $style;
949
-		$text  = is_plugin_active( $plugin ) ? __( 'Installed', 'woocommerce' ) : $text;
950
-		$url   = self::add_in_app_purchase_url_params( $url );
951
-		?>
905
+        }
906
+    }
907
+
908
+    /**
909
+     * Returns in-app-purchase URL params.
910
+     */
911
+    public static function get_in_app_purchase_url_params() {
912
+        // Get url (from path onward) for the current page,
913
+        // so WCCOM "back" link returns user to where they were.
914
+        $back_admin_path = add_query_arg( array() );
915
+        return array(
916
+            'wccom-site'          => site_url(),
917
+            'wccom-back'          => rawurlencode( $back_admin_path ),
918
+            'wccom-woo-version'   => Constants::get_constant( 'WC_VERSION' ),
919
+            'wccom-connect-nonce' => wp_create_nonce( 'connect' ),
920
+        );
921
+    }
922
+
923
+    /**
924
+     * Add in-app-purchase URL params to link.
925
+     *
926
+     * Adds various url parameters to a url to support a streamlined
927
+     * flow for obtaining and setting up WooCommerce extensons.
928
+     *
929
+     * @param string $url    Destination URL.
930
+     */
931
+    public static function add_in_app_purchase_url_params( $url ) {
932
+        return add_query_arg(
933
+            self::get_in_app_purchase_url_params(),
934
+            $url
935
+        );
936
+    }
937
+
938
+    /**
939
+     * Outputs a button.
940
+     *
941
+     * @param string $url    Destination URL.
942
+     * @param string $text   Button label text.
943
+     * @param string $style  Button style class.
944
+     * @param string $plugin The plugin the button is promoting.
945
+     */
946
+    public static function output_button( $url, $text, $style, $plugin = '' ) {
947
+        $style = __( 'Free', 'woocommerce' ) === $text ? 'addons-button-outline-purple' : $style;
948
+        $style = is_plugin_active( $plugin ) ? 'addons-button-installed' : $style;
949
+        $text  = is_plugin_active( $plugin ) ? __( 'Installed', 'woocommerce' ) : $text;
950
+        $url   = self::add_in_app_purchase_url_params( $url );
951
+        ?>
952 952
 		<a
953 953
 			class="addons-button <?php echo esc_attr( $style ); ?>"
954 954
 			href="<?php echo esc_url( $url ); ?>">
955 955
 			<?php echo esc_html( $text ); ?>
956 956
 		</a>
957 957
 		<?php
958
-	}
959
-
960
-	/**
961
-	 * Output HTML for a promotion action.
962
-	 *
963
-	 * @param array $action Array of action properties.
964
-	 *
965
-	 * @return void
966
-	 */
967
-	public static function output_promotion_action( array $action ) {
968
-		if ( empty( $action ) ) {
969
-			return;
970
-		}
971
-		$style = ( ! empty( $action['primary'] ) && $action['primary'] ) ? 'addons-button-solid' : 'addons-button-outline-purple';
972
-		?>
958
+    }
959
+
960
+    /**
961
+     * Output HTML for a promotion action.
962
+     *
963
+     * @param array $action Array of action properties.
964
+     *
965
+     * @return void
966
+     */
967
+    public static function output_promotion_action( array $action ) {
968
+        if ( empty( $action ) ) {
969
+            return;
970
+        }
971
+        $style = ( ! empty( $action['primary'] ) && $action['primary'] ) ? 'addons-button-solid' : 'addons-button-outline-purple';
972
+        ?>
973 973
 		<a
974 974
 			class="addons-button <?php echo esc_attr( $style ); ?>"
975 975
 			href="<?php echo esc_url( $action['url'] ); ?>">
976 976
 			<?php echo esc_html( $action['label'] ); ?>
977 977
 		</a>
978 978
 		<?php
979
-	}
980
-
981
-	/**
982
-	 * Output HTML for a promotion action if data couldn't be fetched.
983
-	 *
984
-	 * @param string $message Error message.
985
-	 *
986
-	 * @return void
987
-	 */
988
-	public static function output_empty( $message = '' ) {
989
-		?>
979
+    }
980
+
981
+    /**
982
+     * Output HTML for a promotion action if data couldn't be fetched.
983
+     *
984
+     * @param string $message Error message.
985
+     *
986
+     * @return void
987
+     */
988
+    public static function output_empty( $message = '' ) {
989
+        ?>
990 990
 		<div class="wc-addons__empty">
991 991
 			<h2><?php echo wp_kses_post( __( 'Oh no! We\'re having trouble connecting to the extensions catalog right now.', 'woocommerce' ) ); ?></h2>
992 992
 			<?php if ( ! empty( $message ) ) : ?>
@@ -994,383 +994,383 @@  discard block
 block discarded – undo
994 994
 			<?php endif; ?>
995 995
 			<p>
996 996
 				<?php
997
-				printf(
998
-					wp_kses_post(
999
-						/* translators: a url */
1000
-						__(
1001
-							'To start growing your business, head over to <a href="%s">WooCommerce.com</a>, where you\'ll find the most popular WooCommerce extensions.',
1002
-							'woocommerce'
1003
-						)
1004
-					),
1005
-					'https://woocommerce.com/products/?utm_source=extensionsscreen&utm_medium=product&utm_campaign=connectionerror'
1006
-				);
1007
-				?>
997
+                printf(
998
+                    wp_kses_post(
999
+                        /* translators: a url */
1000
+                        __(
1001
+                            'To start growing your business, head over to <a href="%s">WooCommerce.com</a>, where you\'ll find the most popular WooCommerce extensions.',
1002
+                            'woocommerce'
1003
+                        )
1004
+                    ),
1005
+                    'https://woocommerce.com/products/?utm_source=extensionsscreen&utm_medium=product&utm_campaign=connectionerror'
1006
+                );
1007
+                ?>
1008 1008
 			</p>
1009 1009
 		</div>
1010 1010
 		<?php
1011
-	}
1012
-
1013
-
1014
-	/**
1015
-	 * Handles output of the addons page in admin.
1016
-	 */
1017
-	public static function output() {
1018
-		$section = isset( $_GET['section'] ) ? sanitize_text_field( wp_unslash( $_GET['section'] ) ) : '_featured';
1019
-		$search  = isset( $_GET['search'] ) ? sanitize_text_field( wp_unslash( $_GET['search'] ) ) : '';
1020
-
1021
-		if ( isset( $_GET['section'] ) && 'helper' === $_GET['section'] ) {
1022
-			do_action( 'woocommerce_helper_output' );
1023
-			return;
1024
-		}
1025
-
1026
-		if ( isset( $_GET['install-addon'] ) ) {
1027
-			switch ( $_GET['install-addon'] ) {
1028
-				case 'woocommerce-services':
1029
-					self::install_woocommerce_services_addon();
1030
-					break;
1031
-				case 'woocommerce-payments':
1032
-					self::install_woocommerce_payments_addon( $section );
1033
-					break;
1034
-				default:
1035
-					// Do nothing.
1036
-					break;
1037
-			}
1038
-		}
1039
-
1040
-		$sections        = self::get_sections();
1041
-		$theme           = wp_get_theme();
1042
-		$current_section = isset( $_GET['section'] ) ? $section : '_featured';
1043
-		$promotions      = array();
1044
-		$addons          = array();
1045
-
1046
-		if ( '_featured' !== $current_section ) {
1047
-			$category       = $section ? $section : null;
1048
-			$term           = $search ? $search : null;
1049
-			$country        = WC()->countries->get_base_country();
1050
-			$extension_data = self::get_extension_data( $category, $term, $country );
1051
-			$addons         = is_wp_error( $extension_data ) ? $extension_data : $extension_data->products;
1052
-			$promotions     = ! empty( $extension_data->promotions ) ? $extension_data->promotions : array();
1053
-		}
1054
-
1055
-		// We need Automattic\WooCommerce\Admin\RemoteInboxNotifications for the next part, if not remove all promotions.
1056
-		if ( ! WC()->is_wc_admin_active() ) {
1057
-			$promotions = array();
1058
-		}
1059
-		// Check for existence of promotions and evaluate out if we should show them.
1060
-		if ( ! empty( $promotions ) ) {
1061
-			foreach ( $promotions as $promo_id => $promotion ) {
1062
-				$evaluator = new PromotionRuleEngine\RuleEvaluator();
1063
-				$passed    = $evaluator->evaluate( $promotion->rules );
1064
-				if ( ! $passed ) {
1065
-					unset( $promotions[ $promo_id ] );
1066
-				}
1067
-			}
1068
-			// Transform promotions to the correct format ready for output.
1069
-			$promotions = self::format_promotions( $promotions );
1070
-		}
1071
-
1072
-		/**
1073
-		 * Addon page view.
1074
-		 *
1075
-		 * @uses $addons
1076
-		 * @uses $search
1077
-		 * @uses $sections
1078
-		 * @uses $theme
1079
-		 * @uses $current_section
1080
-		 */
1081
-		include_once dirname( __FILE__ ) . '/views/html-admin-page-addons.php';
1082
-	}
1083
-
1084
-	/**
1085
-	 * Install WooCommerce Services from Extensions screens.
1086
-	 */
1087
-	public static function install_woocommerce_services_addon() {
1088
-		check_admin_referer( 'install-addon_woocommerce-services' );
1089
-
1090
-		$services_plugin_id = 'woocommerce-services';
1091
-		$services_plugin    = array(
1092
-			'name'      => __( 'WooCommerce Services', 'woocommerce' ),
1093
-			'repo-slug' => 'woocommerce-services',
1094
-		);
1095
-
1096
-		WC_Install::background_installer( $services_plugin_id, $services_plugin );
1097
-
1098
-		wp_safe_redirect( remove_query_arg( array( 'install-addon', '_wpnonce' ) ) );
1099
-		exit;
1100
-	}
1101
-
1102
-	/**
1103
-	 * Install WooCommerce Payments from the Extensions screens.
1104
-	 *
1105
-	 * @param string $section Optional. Extenstions tab.
1106
-	 *
1107
-	 * @return void
1108
-	 */
1109
-	public static function install_woocommerce_payments_addon( $section = '_featured' ) {
1110
-		check_admin_referer( 'install-addon_woocommerce-payments' );
1111
-
1112
-		$wcpay_plugin_id = 'woocommerce-payments';
1113
-		$wcpay_plugin    = array(
1114
-			'name'      => __( 'WooCommerce Payments', 'woocommerce' ),
1115
-			'repo-slug' => 'woocommerce-payments',
1116
-		);
1117
-
1118
-		WC_Install::background_installer( $wcpay_plugin_id, $wcpay_plugin );
1119
-
1120
-		do_action( 'woocommerce_addon_installed', $wcpay_plugin_id, $section );
1121
-
1122
-		wp_safe_redirect( remove_query_arg( array( 'install-addon', '_wpnonce' ) ) );
1123
-		exit;
1124
-	}
1125
-
1126
-	/**
1127
-	 * We're displaying page=wc-addons and page=wc-addons&section=helper as two separate pages.
1128
-	 * When we're on those pages, add body classes to distinguishe them.
1129
-	 *
1130
-	 * @param string $admin_body_class Unfiltered body class.
1131
-	 *
1132
-	 * @return string Body class with added class for Marketplace or My Subscriptions page.
1133
-	 */
1134
-	public static function filter_admin_body_classes( string $admin_body_class = '' ): string {
1135
-		if ( isset( $_GET['section'] ) && 'helper' === $_GET['section'] ) {
1136
-			return " $admin_body_class woocommerce-page-wc-subscriptions ";
1137
-		}
1138
-
1139
-		return " $admin_body_class woocommerce-page-wc-marketplace ";
1140
-	}
1141
-
1142
-	/**
1143
-	 * Determine which class should be used for a rating star:
1144
-	 * - golden
1145
-	 * - half-filled (50/50 golden and gray)
1146
-	 * - gray
1147
-	 *
1148
-	 * Consider ratings from 3.0 to 4.0 as an example
1149
-	 * 3.0 will produce 3 stars
1150
-	 * 3.1 to 3.5 will produce 3 stars and a half star
1151
-	 * 3.6 to 4.0 will product 4 stars
1152
-	 *
1153
-	 * @param float $rating Rating of a product.
1154
-	 * @param int   $index  Index of a star in a row.
1155
-	 *
1156
-	 * @return string CSS class to use.
1157
-	 */
1158
-	public static function get_star_class( $rating, $index ) {
1159
-		if ( $rating >= $index ) {
1160
-			// Rating more that current star to show.
1161
-			return 'fill';
1162
-		} elseif (
1163
-			abs( $index - 1 - floor( $rating ) ) < 0.0000001 &&
1164
-			0 < ( $rating - floor( $rating ) )
1165
-		) {
1166
-			// For rating more than x.0 and less than x.5 or equal it will show a half star.
1167
-			return 50 >= floor( ( $rating - floor( $rating ) ) * 100 )
1168
-				? 'half-fill'
1169
-				: 'fill';
1170
-		}
1171
-
1172
-		// Don't show a golden star otherwise.
1173
-		return 'no-fill';
1174
-	}
1175
-
1176
-	/**
1177
-	 * Take an action object and return the URL based on properties of the action.
1178
-	 *
1179
-	 * @param object $action Action object.
1180
-	 * @return string URL.
1181
-	 */
1182
-	public static function get_action_url( $action ): string {
1183
-		if ( ! isset( $action->url ) ) {
1184
-			return '';
1185
-		}
1186
-
1187
-		if ( isset( $action->url_is_admin_query ) && $action->url_is_admin_query ) {
1188
-			return wc_admin_url( $action->url );
1189
-		}
1190
-
1191
-		if ( isset( $action->url_is_admin_nonce_query ) && $action->url_is_admin_nonce_query ) {
1192
-			if ( empty( $action->nonce ) ) {
1193
-				return '';
1194
-			}
1195
-			return wp_nonce_url(
1196
-				admin_url( $action->url ),
1197
-				$action->nonce
1198
-			);
1199
-		}
1200
-
1201
-		return $action->url;
1202
-	}
1203
-
1204
-	/**
1205
-	 * Format the promotion data ready for display, ie fetch locales and actions.
1206
-	 *
1207
-	 * @param array $promotions Array of promotoin objects.
1208
-	 * @return array Array of formatted promotions ready for output.
1209
-	 */
1210
-	public static function format_promotions( array $promotions ): array {
1211
-		$formatted_promotions = array();
1212
-		foreach ( $promotions as $promotion ) {
1213
-			// Get the matching locale or fall back to en-US.
1214
-			$locale = PromotionRuleEngine\SpecRunner::get_locale( $promotion->locales );
1215
-			if ( null === $locale ) {
1216
-				continue;
1217
-			}
1218
-
1219
-			$promotion_actions = array();
1220
-			if ( ! empty( $promotion->actions ) ) {
1221
-				foreach ( $promotion->actions as $action ) {
1222
-					$action_locale = PromotionRuleEngine\SpecRunner::get_action_locale( $action->locales );
1223
-					$url           = self::get_action_url( $action );
1224
-
1225
-					$promotion_actions[] = array(
1226
-						'name'    => $action->name,
1227
-						'label'   => $action_locale->label,
1228
-						'url'     => $url,
1229
-						'primary' => isset( $action->is_primary ) ? $action->is_primary : false,
1230
-					);
1231
-				}
1232
-			}
1233
-
1234
-			$formatted_promotions[] = array(
1235
-				'title'       => $locale->title,
1236
-				'description' => $locale->description,
1237
-				'image'       => ( 'http' === substr( $locale->image, 0, 4 ) ) ? $locale->image : WC()->plugin_url() . $locale->image,
1238
-				'image_alt'   => $locale->image_alt,
1239
-				'actions'     => $promotion_actions,
1240
-			);
1241
-		}
1242
-		return $formatted_promotions;
1243
-	}
1244
-
1245
-	/**
1246
-	 * Map data from different endpoints to a universal format
1247
-	 *
1248
-	 * Search and featured products has a slightly different products' field names.
1249
-	 * Mapping converts different data structures into a universal one for further processing.
1250
-	 *
1251
-	 * @param mixed $data Product Card Data.
1252
-	 *
1253
-	 * @return object Converted data.
1254
-	 */
1255
-	public static function map_product_card_data( $data ) {
1256
-		$mapped = (object) null;
1257
-
1258
-		$type = $data->type ?? null;
1259
-
1260
-		// Icon.
1261
-		$mapped->icon = $data->icon ?? null;
1262
-		if ( null === $mapped->icon && 'banner' === $type ) {
1263
-			// For product-related banners icon is a product's image.
1264
-			$mapped->icon = $data->image ?? null;
1265
-		}
1266
-
1267
-		// URL.
1268
-		$mapped->url = $data->link ?? null;
1269
-		if ( empty( $mapped->url ) ) {
1270
-			$mapped->url = $data->url ?? null;
1271
-		}
1272
-
1273
-		// Title.
1274
-		$mapped->title = $data->title ?? null;
1275
-
1276
-		// Vendor Name.
1277
-		$mapped->vendor_name = $data->vendor_name ?? null;
1278
-		if ( empty( $mapped->vendor_name ) ) {
1279
-			$mapped->vendor_name = $data->vendorName ?? null; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
1280
-		}
1281
-
1282
-		// Vendor URL.
1283
-		$mapped->vendor_url = $data->vendor_url ?? null;
1284
-		if ( empty( $mapped->vendor_url ) ) {
1285
-			$mapped->vendor_url = $data->vendorUrl ?? null; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
1286
-		}
1287
-
1288
-		// Description.
1289
-		$mapped->description = $data->excerpt ?? null;
1290
-		if ( empty( $mapped->description ) ) {
1291
-			$mapped->description = $data->description ?? null;
1292
-		}
1293
-
1294
-		$has_currency = ! empty( $data->currency ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
1295
-
1296
-		// Is Free.
1297
-		if ( $has_currency ) {
1298
-			$mapped->is_free = 0 === (int) $data->price;
1299
-		} else {
1300
-			$mapped->is_free = '&#36;0.00' === $data->price;
1301
-		}
1302
-
1303
-		// Price.
1304
-		if ( $has_currency ) {
1305
-			$mapped->price = wc_price( $data->price, array( 'currency' => $data->currency ) );
1306
-		} else {
1307
-			$mapped->price = $data->price;
1308
-		}
1309
-
1310
-		// Price suffix, e.g. "per month".
1311
-		$mapped->price_suffix = $data->price_suffix ?? null;
1312
-
1313
-		// Rating.
1314
-		$mapped->rating = $data->rating ?? null;
1315
-		if ( null === $mapped->rating ) {
1316
-			$mapped->rating = $data->averageRating ?? null; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
1317
-		}
1318
-
1319
-		// Reviews Count.
1320
-		$mapped->reviews_count = $data->reviews_count ?? null;
1321
-		if ( null === $mapped->reviews_count ) {
1322
-			$mapped->reviews_count = $data->reviewsCount ?? null; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
1323
-		}
1324
-		// Featured & Promoted product card.
1325
-		// Label.
1326
-		$mapped->label = $data->label ?? null;
1327
-		// Primary color.
1328
-		$mapped->primary_color = $data->primary_color ?? null;
1329
-		// Text color.
1330
-		$mapped->text_color = $data->text_color ?? null;
1331
-		// Button text.
1332
-		$mapped->button = $data->button ?? null;
1333
-
1334
-		return $mapped;
1335
-	}
1336
-
1337
-	/**
1338
-	 * Render a product card
1339
-	 *
1340
-	 * There's difference in data structure (e.g. field names) between endpoints such as search and
1341
-	 * featured. Inner mapping helps to use universal field names for further work.
1342
-	 *
1343
-	 * @param mixed  $data       Product data.
1344
-	 * @param string $block_type Block type that's different from the default product card, e.g. a banner.
1345
-	 *
1346
-	 * @return void
1347
-	 */
1348
-	public static function render_product_card( $data, $block_type = null ) {
1349
-		$mapped      = self::map_product_card_data( $data );
1350
-		$product_url = self::add_in_app_purchase_url_params( $mapped->url );
1351
-		$class_names = array( 'product' );
1352
-		// Specify a class name according to $block_type (if it's specified).
1353
-		if ( null !== $block_type ) {
1354
-			$class_names[] = 'addons-product-' . $block_type;
1355
-		}
1356
-
1357
-		$product_details_classes = 'product-details';
1358
-		if ( 'banner' === $block_type ) {
1359
-			$product_details_classes .= ' addon-product-banner-details';
1360
-		}
1361
-
1362
-		if ( isset( $mapped->label ) && 'promoted' === $mapped->label ) {
1363
-			$product_details_classes .= ' promoted';
1364
-		} elseif ( isset( $mapped->label ) && 'featured' === $mapped->label ) {
1365
-			$product_details_classes .= ' featured';
1366
-		}
1367
-
1368
-		if ( 'promoted' === $mapped->label
1369
-			&& ! empty( $mapped->primary_color )
1370
-			&& ! empty( $mapped->text_color )
1371
-			&& ! empty( $mapped->button ) ) {
1372
-			// Promoted product card.
1373
-			?>
1011
+    }
1012
+
1013
+
1014
+    /**
1015
+     * Handles output of the addons page in admin.
1016
+     */
1017
+    public static function output() {
1018
+        $section = isset( $_GET['section'] ) ? sanitize_text_field( wp_unslash( $_GET['section'] ) ) : '_featured';
1019
+        $search  = isset( $_GET['search'] ) ? sanitize_text_field( wp_unslash( $_GET['search'] ) ) : '';
1020
+
1021
+        if ( isset( $_GET['section'] ) && 'helper' === $_GET['section'] ) {
1022
+            do_action( 'woocommerce_helper_output' );
1023
+            return;
1024
+        }
1025
+
1026
+        if ( isset( $_GET['install-addon'] ) ) {
1027
+            switch ( $_GET['install-addon'] ) {
1028
+                case 'woocommerce-services':
1029
+                    self::install_woocommerce_services_addon();
1030
+                    break;
1031
+                case 'woocommerce-payments':
1032
+                    self::install_woocommerce_payments_addon( $section );
1033
+                    break;
1034
+                default:
1035
+                    // Do nothing.
1036
+                    break;
1037
+            }
1038
+        }
1039
+
1040
+        $sections        = self::get_sections();
1041
+        $theme           = wp_get_theme();
1042
+        $current_section = isset( $_GET['section'] ) ? $section : '_featured';
1043
+        $promotions      = array();
1044
+        $addons          = array();
1045
+
1046
+        if ( '_featured' !== $current_section ) {
1047
+            $category       = $section ? $section : null;
1048
+            $term           = $search ? $search : null;
1049
+            $country        = WC()->countries->get_base_country();
1050
+            $extension_data = self::get_extension_data( $category, $term, $country );
1051
+            $addons         = is_wp_error( $extension_data ) ? $extension_data : $extension_data->products;
1052
+            $promotions     = ! empty( $extension_data->promotions ) ? $extension_data->promotions : array();
1053
+        }
1054
+
1055
+        // We need Automattic\WooCommerce\Admin\RemoteInboxNotifications for the next part, if not remove all promotions.
1056
+        if ( ! WC()->is_wc_admin_active() ) {
1057
+            $promotions = array();
1058
+        }
1059
+        // Check for existence of promotions and evaluate out if we should show them.
1060
+        if ( ! empty( $promotions ) ) {
1061
+            foreach ( $promotions as $promo_id => $promotion ) {
1062
+                $evaluator = new PromotionRuleEngine\RuleEvaluator();
1063
+                $passed    = $evaluator->evaluate( $promotion->rules );
1064
+                if ( ! $passed ) {
1065
+                    unset( $promotions[ $promo_id ] );
1066
+                }
1067
+            }
1068
+            // Transform promotions to the correct format ready for output.
1069
+            $promotions = self::format_promotions( $promotions );
1070
+        }
1071
+
1072
+        /**
1073
+         * Addon page view.
1074
+         *
1075
+         * @uses $addons
1076
+         * @uses $search
1077
+         * @uses $sections
1078
+         * @uses $theme
1079
+         * @uses $current_section
1080
+         */
1081
+        include_once dirname( __FILE__ ) . '/views/html-admin-page-addons.php';
1082
+    }
1083
+
1084
+    /**
1085
+     * Install WooCommerce Services from Extensions screens.
1086
+     */
1087
+    public static function install_woocommerce_services_addon() {
1088
+        check_admin_referer( 'install-addon_woocommerce-services' );
1089
+
1090
+        $services_plugin_id = 'woocommerce-services';
1091
+        $services_plugin    = array(
1092
+            'name'      => __( 'WooCommerce Services', 'woocommerce' ),
1093
+            'repo-slug' => 'woocommerce-services',
1094
+        );
1095
+
1096
+        WC_Install::background_installer( $services_plugin_id, $services_plugin );
1097
+
1098
+        wp_safe_redirect( remove_query_arg( array( 'install-addon', '_wpnonce' ) ) );
1099
+        exit;
1100
+    }
1101
+
1102
+    /**
1103
+     * Install WooCommerce Payments from the Extensions screens.
1104
+     *
1105
+     * @param string $section Optional. Extenstions tab.
1106
+     *
1107
+     * @return void
1108
+     */
1109
+    public static function install_woocommerce_payments_addon( $section = '_featured' ) {
1110
+        check_admin_referer( 'install-addon_woocommerce-payments' );
1111
+
1112
+        $wcpay_plugin_id = 'woocommerce-payments';
1113
+        $wcpay_plugin    = array(
1114
+            'name'      => __( 'WooCommerce Payments', 'woocommerce' ),
1115
+            'repo-slug' => 'woocommerce-payments',
1116
+        );
1117
+
1118
+        WC_Install::background_installer( $wcpay_plugin_id, $wcpay_plugin );
1119
+
1120
+        do_action( 'woocommerce_addon_installed', $wcpay_plugin_id, $section );
1121
+
1122
+        wp_safe_redirect( remove_query_arg( array( 'install-addon', '_wpnonce' ) ) );
1123
+        exit;
1124
+    }
1125
+
1126
+    /**
1127
+     * We're displaying page=wc-addons and page=wc-addons&section=helper as two separate pages.
1128
+     * When we're on those pages, add body classes to distinguishe them.
1129
+     *
1130
+     * @param string $admin_body_class Unfiltered body class.
1131
+     *
1132
+     * @return string Body class with added class for Marketplace or My Subscriptions page.
1133
+     */
1134
+    public static function filter_admin_body_classes( string $admin_body_class = '' ): string {
1135
+        if ( isset( $_GET['section'] ) && 'helper' === $_GET['section'] ) {
1136
+            return " $admin_body_class woocommerce-page-wc-subscriptions ";
1137
+        }
1138
+
1139
+        return " $admin_body_class woocommerce-page-wc-marketplace ";
1140
+    }
1141
+
1142
+    /**
1143
+     * Determine which class should be used for a rating star:
1144
+     * - golden
1145
+     * - half-filled (50/50 golden and gray)
1146
+     * - gray
1147
+     *
1148
+     * Consider ratings from 3.0 to 4.0 as an example
1149
+     * 3.0 will produce 3 stars
1150
+     * 3.1 to 3.5 will produce 3 stars and a half star
1151
+     * 3.6 to 4.0 will product 4 stars
1152
+     *
1153
+     * @param float $rating Rating of a product.
1154
+     * @param int   $index  Index of a star in a row.
1155
+     *
1156
+     * @return string CSS class to use.
1157
+     */
1158
+    public static function get_star_class( $rating, $index ) {
1159
+        if ( $rating >= $index ) {
1160
+            // Rating more that current star to show.
1161
+            return 'fill';
1162
+        } elseif (
1163
+            abs( $index - 1 - floor( $rating ) ) < 0.0000001 &&
1164
+            0 < ( $rating - floor( $rating ) )
1165
+        ) {
1166
+            // For rating more than x.0 and less than x.5 or equal it will show a half star.
1167
+            return 50 >= floor( ( $rating - floor( $rating ) ) * 100 )
1168
+                ? 'half-fill'
1169
+                : 'fill';
1170
+        }
1171
+
1172
+        // Don't show a golden star otherwise.
1173
+        return 'no-fill';
1174
+    }
1175
+
1176
+    /**
1177
+     * Take an action object and return the URL based on properties of the action.
1178
+     *
1179
+     * @param object $action Action object.
1180
+     * @return string URL.
1181
+     */
1182
+    public static function get_action_url( $action ): string {
1183
+        if ( ! isset( $action->url ) ) {
1184
+            return '';
1185
+        }
1186
+
1187
+        if ( isset( $action->url_is_admin_query ) && $action->url_is_admin_query ) {
1188
+            return wc_admin_url( $action->url );
1189
+        }
1190
+
1191
+        if ( isset( $action->url_is_admin_nonce_query ) && $action->url_is_admin_nonce_query ) {
1192
+            if ( empty( $action->nonce ) ) {
1193
+                return '';
1194
+            }
1195
+            return wp_nonce_url(
1196
+                admin_url( $action->url ),
1197
+                $action->nonce
1198
+            );
1199
+        }
1200
+
1201
+        return $action->url;
1202
+    }
1203
+
1204
+    /**
1205
+     * Format the promotion data ready for display, ie fetch locales and actions.
1206
+     *
1207
+     * @param array $promotions Array of promotoin objects.
1208
+     * @return array Array of formatted promotions ready for output.
1209
+     */
1210
+    public static function format_promotions( array $promotions ): array {
1211
+        $formatted_promotions = array();
1212
+        foreach ( $promotions as $promotion ) {
1213
+            // Get the matching locale or fall back to en-US.
1214
+            $locale = PromotionRuleEngine\SpecRunner::get_locale( $promotion->locales );
1215
+            if ( null === $locale ) {
1216
+                continue;
1217
+            }
1218
+
1219
+            $promotion_actions = array();
1220
+            if ( ! empty( $promotion->actions ) ) {
1221
+                foreach ( $promotion->actions as $action ) {
1222
+                    $action_locale = PromotionRuleEngine\SpecRunner::get_action_locale( $action->locales );
1223
+                    $url           = self::get_action_url( $action );
1224
+
1225
+                    $promotion_actions[] = array(
1226
+                        'name'    => $action->name,
1227
+                        'label'   => $action_locale->label,
1228
+                        'url'     => $url,
1229
+                        'primary' => isset( $action->is_primary ) ? $action->is_primary : false,
1230
+                    );
1231
+                }
1232
+            }
1233
+
1234
+            $formatted_promotions[] = array(
1235
+                'title'       => $locale->title,
1236
+                'description' => $locale->description,
1237
+                'image'       => ( 'http' === substr( $locale->image, 0, 4 ) ) ? $locale->image : WC()->plugin_url() . $locale->image,
1238
+                'image_alt'   => $locale->image_alt,
1239
+                'actions'     => $promotion_actions,
1240
+            );
1241
+        }
1242
+        return $formatted_promotions;
1243
+    }
1244
+
1245
+    /**
1246
+     * Map data from different endpoints to a universal format
1247
+     *
1248
+     * Search and featured products has a slightly different products' field names.
1249
+     * Mapping converts different data structures into a universal one for further processing.
1250
+     *
1251
+     * @param mixed $data Product Card Data.
1252
+     *
1253
+     * @return object Converted data.
1254
+     */
1255
+    public static function map_product_card_data( $data ) {
1256
+        $mapped = (object) null;
1257
+
1258
+        $type = $data->type ?? null;
1259
+
1260
+        // Icon.
1261
+        $mapped->icon = $data->icon ?? null;
1262
+        if ( null === $mapped->icon && 'banner' === $type ) {
1263
+            // For product-related banners icon is a product's image.
1264
+            $mapped->icon = $data->image ?? null;
1265
+        }
1266
+
1267
+        // URL.
1268
+        $mapped->url = $data->link ?? null;
1269
+        if ( empty( $mapped->url ) ) {
1270
+            $mapped->url = $data->url ?? null;
1271
+        }
1272
+
1273
+        // Title.
1274
+        $mapped->title = $data->title ?? null;
1275
+
1276
+        // Vendor Name.
1277
+        $mapped->vendor_name = $data->vendor_name ?? null;
1278
+        if ( empty( $mapped->vendor_name ) ) {
1279
+            $mapped->vendor_name = $data->vendorName ?? null; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
1280
+        }
1281
+
1282
+        // Vendor URL.
1283
+        $mapped->vendor_url = $data->vendor_url ?? null;
1284
+        if ( empty( $mapped->vendor_url ) ) {
1285
+            $mapped->vendor_url = $data->vendorUrl ?? null; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
1286
+        }
1287
+
1288
+        // Description.
1289
+        $mapped->description = $data->excerpt ?? null;
1290
+        if ( empty( $mapped->description ) ) {
1291
+            $mapped->description = $data->description ?? null;
1292
+        }
1293
+
1294
+        $has_currency = ! empty( $data->currency ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
1295
+
1296
+        // Is Free.
1297
+        if ( $has_currency ) {
1298
+            $mapped->is_free = 0 === (int) $data->price;
1299
+        } else {
1300
+            $mapped->is_free = '&#36;0.00' === $data->price;
1301
+        }
1302
+
1303
+        // Price.
1304
+        if ( $has_currency ) {
1305
+            $mapped->price = wc_price( $data->price, array( 'currency' => $data->currency ) );
1306
+        } else {
1307
+            $mapped->price = $data->price;
1308
+        }
1309
+
1310
+        // Price suffix, e.g. "per month".
1311
+        $mapped->price_suffix = $data->price_suffix ?? null;
1312
+
1313
+        // Rating.
1314
+        $mapped->rating = $data->rating ?? null;
1315
+        if ( null === $mapped->rating ) {
1316
+            $mapped->rating = $data->averageRating ?? null; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
1317
+        }
1318
+
1319
+        // Reviews Count.
1320
+        $mapped->reviews_count = $data->reviews_count ?? null;
1321
+        if ( null === $mapped->reviews_count ) {
1322
+            $mapped->reviews_count = $data->reviewsCount ?? null; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
1323
+        }
1324
+        // Featured & Promoted product card.
1325
+        // Label.
1326
+        $mapped->label = $data->label ?? null;
1327
+        // Primary color.
1328
+        $mapped->primary_color = $data->primary_color ?? null;
1329
+        // Text color.
1330
+        $mapped->text_color = $data->text_color ?? null;
1331
+        // Button text.
1332
+        $mapped->button = $data->button ?? null;
1333
+
1334
+        return $mapped;
1335
+    }
1336
+
1337
+    /**
1338
+     * Render a product card
1339
+     *
1340
+     * There's difference in data structure (e.g. field names) between endpoints such as search and
1341
+     * featured. Inner mapping helps to use universal field names for further work.
1342
+     *
1343
+     * @param mixed  $data       Product data.
1344
+     * @param string $block_type Block type that's different from the default product card, e.g. a banner.
1345
+     *
1346
+     * @return void
1347
+     */
1348
+    public static function render_product_card( $data, $block_type = null ) {
1349
+        $mapped      = self::map_product_card_data( $data );
1350
+        $product_url = self::add_in_app_purchase_url_params( $mapped->url );
1351
+        $class_names = array( 'product' );
1352
+        // Specify a class name according to $block_type (if it's specified).
1353
+        if ( null !== $block_type ) {
1354
+            $class_names[] = 'addons-product-' . $block_type;
1355
+        }
1356
+
1357
+        $product_details_classes = 'product-details';
1358
+        if ( 'banner' === $block_type ) {
1359
+            $product_details_classes .= ' addon-product-banner-details';
1360
+        }
1361
+
1362
+        if ( isset( $mapped->label ) && 'promoted' === $mapped->label ) {
1363
+            $product_details_classes .= ' promoted';
1364
+        } elseif ( isset( $mapped->label ) && 'featured' === $mapped->label ) {
1365
+            $product_details_classes .= ' featured';
1366
+        }
1367
+
1368
+        if ( 'promoted' === $mapped->label
1369
+            && ! empty( $mapped->primary_color )
1370
+            && ! empty( $mapped->text_color )
1371
+            && ! empty( $mapped->button ) ) {
1372
+            // Promoted product card.
1373
+            ?>
1374 1374
 			<li class="product">
1375 1375
 				<div class="<?php echo esc_attr( $product_details_classes ); ?>" style="border-top: 5px  solid <?php echo esc_html( $mapped->primary_color ); ?>;">
1376 1376
 					<span class="label promoted"><?php esc_attr_e( 'Promoted', 'woocommerce' ); ?></span>
@@ -1387,9 +1387,9 @@  discard block
 block discarded – undo
1387 1387
 				</div>
1388 1388
 			</li>
1389 1389
 			<?php
1390
-		} else {
1391
-			// Normal or "featured" product card.
1392
-			?>
1390
+        } else {
1391
+            // Normal or "featured" product card.
1392
+            ?>
1393 1393
 			<li class="<?php echo esc_attr( implode( ' ', $class_names ) ); ?>">
1394 1394
 				<div class="<?php echo esc_attr( $product_details_classes ); ?>">
1395 1395
 					<div class="product-text-container">
@@ -1402,26 +1402,26 @@  discard block
 block discarded – undo
1402 1402
 						<?php if ( ! empty( $mapped->vendor_name ) && ! empty( $mapped->vendor_url ) ) : ?>
1403 1403
 							<div class="product-developed-by">
1404 1404
 								<?php
1405
-								$vendor_url = add_query_arg(
1406
-									array(
1407
-										'utm_source'   => 'extensionsscreen',
1408
-										'utm_medium'   => 'product',
1409
-										'utm_campaign' => 'wcaddons',
1410
-										'utm_content'  => 'devpartner',
1411
-									),
1412
-									$mapped->vendor_url
1413
-								);
1414
-
1415
-								printf(
1416
-								/* translators: %s vendor link */
1417
-									esc_html__( 'Developed by %s', 'woocommerce' ),
1418
-									sprintf(
1419
-										'<a class="product-vendor-link" href="%1$s" target="_blank">%2$s</a>',
1420
-										esc_url_raw( $vendor_url ),
1421
-										esc_html( $mapped->vendor_name )
1422
-									)
1423
-								);
1424
-								?>
1405
+                                $vendor_url = add_query_arg(
1406
+                                    array(
1407
+                                        'utm_source'   => 'extensionsscreen',
1408
+                                        'utm_medium'   => 'product',
1409
+                                        'utm_campaign' => 'wcaddons',
1410
+                                        'utm_content'  => 'devpartner',
1411
+                                    ),
1412
+                                    $mapped->vendor_url
1413
+                                );
1414
+
1415
+                                printf(
1416
+                                /* translators: %s vendor link */
1417
+                                    esc_html__( 'Developed by %s', 'woocommerce' ),
1418
+                                    sprintf(
1419
+                                        '<a class="product-vendor-link" href="%1$s" target="_blank">%2$s</a>',
1420
+                                        esc_url_raw( $vendor_url ),
1421
+                                        esc_html( $mapped->vendor_name )
1422
+                                    )
1423
+                                );
1424
+                                ?>
1425 1425
 							</div>
1426 1426
 						<?php endif; ?>
1427 1427
 						<p><?php echo wp_kses_post( $mapped->description ); ?></p>
@@ -1441,25 +1441,25 @@  discard block
 block discarded – undo
1441 1441
 							<?php else : ?>
1442 1442
 								<span class="price">
1443 1443
 									<?php
1444
-									echo wp_kses(
1445
-										$mapped->price,
1446
-										array(
1447
-											'span' => array(
1448
-												'class' => array(),
1449
-											),
1450
-											'bdi'  => array(),
1451
-										)
1452
-									);
1453
-									?>
1444
+                                    echo wp_kses(
1445
+                                        $mapped->price,
1446
+                                        array(
1447
+                                            'span' => array(
1448
+                                                'class' => array(),
1449
+                                            ),
1450
+                                            'bdi'  => array(),
1451
+                                        )
1452
+                                    );
1453
+                                    ?>
1454 1454
 								</span>
1455 1455
 								<span class="price-suffix">
1456 1456
 									<?php
1457
-									$price_suffix = __( 'per year', 'woocommerce' );
1458
-									if ( ! empty( $mapped->price_suffix ) ) {
1459
-										$price_suffix = $mapped->price_suffix;
1460
-									}
1461
-									echo esc_html( $price_suffix );
1462
-									?>
1457
+                                    $price_suffix = __( 'per year', 'woocommerce' );
1458
+                                    if ( ! empty( $mapped->price_suffix ) ) {
1459
+                                        $price_suffix = $mapped->price_suffix;
1460
+                                    }
1461
+                                    echo esc_html( $price_suffix );
1462
+                                    ?>
1463 1463
 								</span>
1464 1464
 							<?php endif; ?>
1465 1465
 						</div>
@@ -1480,6 +1480,6 @@  discard block
 block discarded – undo
1480 1480
 				</div>
1481 1481
 			</li>
1482 1482
 			<?php
1483
-		}
1484
-	}
1483
+        }
1484
+    }
1485 1485
 }
Please login to merge, or discard this patch.
Spacing   +341 added lines, -341 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 use Automattic\Jetpack\Constants;
10 10
 use Automattic\WooCommerce\Admin\RemoteInboxNotifications as PromotionRuleEngine;
11 11
 
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if (!defined('ABSPATH')) {
13 13
 	exit;
14 14
 }
15 15
 
@@ -26,12 +26,12 @@  discard block
 block discarded – undo
26 26
 	 * @return array of objects
27 27
 	 */
28 28
 	public static function get_featured() {
29
-		$featured = get_transient( 'wc_addons_featured_2' );
30
-		if ( false === $featured ) {
29
+		$featured = get_transient('wc_addons_featured_2');
30
+		if (false === $featured) {
31 31
 			$headers = array();
32
-			$auth    = WC_Helper_Options::get( 'auth' );
32
+			$auth    = WC_Helper_Options::get('auth');
33 33
 
34
-			if ( ! empty( $auth['access_token'] ) ) {
34
+			if (!empty($auth['access_token'])) {
35 35
 				$headers['Authorization'] = 'Bearer ' . $auth['access_token'];
36 36
 			}
37 37
 
@@ -42,16 +42,16 @@  discard block
 block discarded – undo
42 42
 				)
43 43
 			);
44 44
 
45
-			if ( ! is_wp_error( $raw_featured ) ) {
46
-				$featured = json_decode( wp_remote_retrieve_body( $raw_featured ) );
47
-				if ( $featured ) {
48
-					set_transient( 'wc_addons_featured_2', $featured, DAY_IN_SECONDS );
45
+			if (!is_wp_error($raw_featured)) {
46
+				$featured = json_decode(wp_remote_retrieve_body($raw_featured));
47
+				if ($featured) {
48
+					set_transient('wc_addons_featured_2', $featured, DAY_IN_SECONDS);
49 49
 				}
50 50
 			}
51 51
 		}
52 52
 
53
-		if ( is_object( $featured ) ) {
54
-			self::output_featured_sections( $featured->sections );
53
+		if (is_object($featured)) {
54
+			self::output_featured_sections($featured->sections);
55 55
 			return $featured;
56 56
 		}
57 57
 	}
@@ -62,19 +62,19 @@  discard block
 block discarded – undo
62 62
 	 * @return void
63 63
 	 */
64 64
 	public static function render_featured() {
65
-		$featured = get_transient( 'wc_addons_featured' );
66
-		if ( false === $featured ) {
65
+		$featured = get_transient('wc_addons_featured');
66
+		if (false === $featured) {
67 67
 			$headers = array();
68
-			$auth    = WC_Helper_Options::get( 'auth' );
68
+			$auth    = WC_Helper_Options::get('auth');
69 69
 
70
-			if ( ! empty( $auth['access_token'] ) ) {
70
+			if (!empty($auth['access_token'])) {
71 71
 				$headers['Authorization'] = 'Bearer ' . $auth['access_token'];
72 72
 			}
73 73
 
74 74
 			$parameter_string = '';
75 75
 			$country          = WC()->countries->get_base_country();
76
-			if ( ! empty( $country ) ) {
77
-				$parameter_string = '?' . http_build_query( array( 'country' => $country ) );
76
+			if (!empty($country)) {
77
+				$parameter_string = '?' . http_build_query(array('country' => $country));
78 78
 			}
79 79
 
80 80
 			// Important: WCCOM Extensions API v2.0 is used.
@@ -85,21 +85,21 @@  discard block
 block discarded – undo
85 85
 				)
86 86
 			);
87 87
 
88
-			if ( is_wp_error( $raw_featured ) ) {
89
-				do_action( 'woocommerce_page_wc-addons_connection_error', $raw_featured->get_error_message() );
88
+			if (is_wp_error($raw_featured)) {
89
+				do_action('woocommerce_page_wc-addons_connection_error', $raw_featured->get_error_message());
90 90
 
91
-				$message = self::is_ssl_error( $raw_featured->get_error_message() )
92
-					? __( 'We encountered an SSL error. Please ensure your site supports TLS version 1.2 or above.', 'woocommerce' )
91
+				$message = self::is_ssl_error($raw_featured->get_error_message())
92
+					? __('We encountered an SSL error. Please ensure your site supports TLS version 1.2 or above.', 'woocommerce')
93 93
 					: $raw_featured->get_error_message();
94 94
 
95
-				self::output_empty( $message );
95
+				self::output_empty($message);
96 96
 
97 97
 				return;
98 98
 			}
99 99
 
100
-			$response_code = (int) wp_remote_retrieve_response_code( $raw_featured );
101
-			if ( 200 !== $response_code ) {
102
-				do_action( 'woocommerce_page_wc-addons_connection_error', $response_code );
100
+			$response_code = (int) wp_remote_retrieve_response_code($raw_featured);
101
+			if (200 !== $response_code) {
102
+				do_action('woocommerce_page_wc-addons_connection_error', $response_code);
103 103
 
104 104
 				/* translators: %d: HTTP error code. */
105 105
 				$message = sprintf(
@@ -113,26 +113,26 @@  discard block
 block discarded – undo
113 113
 					$response_code
114 114
 				);
115 115
 
116
-				self::output_empty( $message );
116
+				self::output_empty($message);
117 117
 
118 118
 				return;
119 119
 			}
120 120
 
121
-			$featured      = json_decode( wp_remote_retrieve_body( $raw_featured ) );
122
-			if ( empty( $featured ) || ! is_array( $featured ) ) {
123
-				do_action( 'woocommerce_page_wc-addons_connection_error', 'Empty or malformed response' );
124
-				$message = __( 'Our request to the featured API got a malformed response.', 'woocommerce' );
125
-				self::output_empty( $message );
121
+			$featured = json_decode(wp_remote_retrieve_body($raw_featured));
122
+			if (empty($featured) || !is_array($featured)) {
123
+				do_action('woocommerce_page_wc-addons_connection_error', 'Empty or malformed response');
124
+				$message = __('Our request to the featured API got a malformed response.', 'woocommerce');
125
+				self::output_empty($message);
126 126
 
127 127
 				return;
128 128
 			}
129 129
 
130
-			if ( $featured ) {
131
-				set_transient( 'wc_addons_featured', $featured, DAY_IN_SECONDS );
130
+			if ($featured) {
131
+				set_transient('wc_addons_featured', $featured, DAY_IN_SECONDS);
132 132
 			}
133 133
 		}
134 134
 
135
-		self::output_featured( $featured );
135
+		self::output_featured($featured);
136 136
 	}
137 137
 
138 138
 	/**
@@ -142,8 +142,8 @@  discard block
 block discarded – undo
142 142
 	 *
143 143
 	 * @return bool True if SSL error, false otherwise
144 144
 	 */
145
-	public static function is_ssl_error( $error_message ) {
146
-		return false !== stripos( $error_message, 'cURL error 35' );
145
+	public static function is_ssl_error($error_message) {
146
+		return false !== stripos($error_message, 'cURL error 35');
147 147
 	}
148 148
 
149 149
 	/**
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	 *
156 156
 	 * @return string url parameter string
157 157
 	 */
158
-	public static function build_parameter_string( $category, $term, $country ) {
158
+	public static function build_parameter_string($category, $term, $country) {
159 159
 
160 160
 		$parameters = array(
161 161
 			'category' => $category,
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 			'country'  => $country,
164 164
 		);
165 165
 
166
-		return '?' . http_build_query( $parameters );
166
+		return '?' . http_build_query($parameters);
167 167
 	}
168 168
 
169 169
 	/**
@@ -175,46 +175,46 @@  discard block
 block discarded – undo
175 175
 	 *
176 176
 	 * @return object|WP_Error  Object with products and promotions properties, or WP_Error
177 177
 	 */
178
-	public static function get_extension_data( $category, $term, $country ) {
179
-		$parameters = self::build_parameter_string( $category, $term, $country );
178
+	public static function get_extension_data($category, $term, $country) {
179
+		$parameters = self::build_parameter_string($category, $term, $country);
180 180
 
181 181
 		$headers = array();
182
-		$auth    = WC_Helper_Options::get( 'auth' );
182
+		$auth    = WC_Helper_Options::get('auth');
183 183
 
184
-		if ( ! empty( $auth['access_token'] ) ) {
184
+		if (!empty($auth['access_token'])) {
185 185
 			$headers['Authorization'] = 'Bearer ' . $auth['access_token'];
186 186
 		}
187 187
 
188 188
 		$raw_extensions = wp_safe_remote_get(
189 189
 			'https://woocommerce.com/wp-json/wccom-extensions/1.0/search' . $parameters,
190
-			array( 'headers' => $headers )
190
+			array('headers' => $headers)
191 191
 		);
192 192
 
193
-		if ( is_wp_error( $raw_extensions ) ) {
194
-			do_action( 'woocommerce_page_wc-addons_connection_error', $raw_extensions->get_error_message() );
193
+		if (is_wp_error($raw_extensions)) {
194
+			do_action('woocommerce_page_wc-addons_connection_error', $raw_extensions->get_error_message());
195 195
 			return $raw_extensions;
196 196
 		}
197 197
 
198
-		$response_code = (int) wp_remote_retrieve_response_code( $raw_extensions );
199
-		if ( 200 !== $response_code ) {
200
-			do_action( 'woocommerce_page_wc-addons_connection_error', $response_code );
198
+		$response_code = (int) wp_remote_retrieve_response_code($raw_extensions);
199
+		if (200 !== $response_code) {
200
+			do_action('woocommerce_page_wc-addons_connection_error', $response_code);
201 201
 			return new WP_Error(
202 202
 				'error',
203 203
 				sprintf(
204 204
 					esc_html(
205 205
 						/* translators: Error code  */
206
-						__( 'Our request to the search API got response code %s.', 'woocommerce' )
206
+						__('Our request to the search API got response code %s.', 'woocommerce')
207 207
 					),
208 208
 					$response_code
209 209
 				)
210 210
 			);
211 211
 		}
212 212
 
213
-		$addons = json_decode( wp_remote_retrieve_body( $raw_extensions ) );
213
+		$addons = json_decode(wp_remote_retrieve_body($raw_extensions));
214 214
 
215
-		if ( ! is_object( $addons ) || ! isset( $addons->products ) ) {
216
-			do_action( 'woocommerce_page_wc-addons_connection_error', 'Empty or malformed response' );
217
-			return new WP_Error( 'error', __( 'Our request to the search API got a malformed response.', 'woocommerce' ) );
215
+		if (!is_object($addons) || !isset($addons->products)) {
216
+			do_action('woocommerce_page_wc-addons_connection_error', 'Empty or malformed response');
217
+			return new WP_Error('error', __('Our request to the search API got a malformed response.', 'woocommerce'));
218 218
 		}
219 219
 
220 220
 		return $addons;
@@ -226,19 +226,19 @@  discard block
 block discarded – undo
226 226
 	 * @return array of objects
227 227
 	 */
228 228
 	public static function get_sections() {
229
-		$addon_sections = get_transient( 'wc_addons_sections' );
230
-		if ( false === ( $addon_sections ) ) {
229
+		$addon_sections = get_transient('wc_addons_sections');
230
+		if (false === ($addon_sections)) {
231 231
 			$raw_sections = wp_safe_remote_get(
232 232
 				'https://woocommerce.com/wp-json/wccom-extensions/1.0/categories'
233 233
 			);
234
-			if ( ! is_wp_error( $raw_sections ) ) {
235
-				$addon_sections = json_decode( wp_remote_retrieve_body( $raw_sections ) );
236
-				if ( $addon_sections ) {
237
-					set_transient( 'wc_addons_sections', $addon_sections, WEEK_IN_SECONDS );
234
+			if (!is_wp_error($raw_sections)) {
235
+				$addon_sections = json_decode(wp_remote_retrieve_body($raw_sections));
236
+				if ($addon_sections) {
237
+					set_transient('wc_addons_sections', $addon_sections, WEEK_IN_SECONDS);
238 238
 				}
239 239
 			}
240 240
 		}
241
-		return apply_filters( 'woocommerce_addons_sections', $addon_sections );
241
+		return apply_filters('woocommerce_addons_sections', $addon_sections);
242 242
 	}
243 243
 
244 244
 	/**
@@ -248,10 +248,10 @@  discard block
 block discarded – undo
248 248
 	 *
249 249
 	 * @return object|bool
250 250
 	 */
251
-	public static function get_section( $section_id ) {
251
+	public static function get_section($section_id) {
252 252
 		$sections = self::get_sections();
253
-		if ( isset( $sections[ $section_id ] ) ) {
254
-			return $sections[ $section_id ];
253
+		if (isset($sections[$section_id])) {
254
+			return $sections[$section_id];
255 255
 		}
256 256
 		return false;
257 257
 	}
@@ -266,26 +266,26 @@  discard block
 block discarded – undo
266 266
 	 *
267 267
 	 * @return array
268 268
 	 */
269
-	public static function get_section_data( $section_id ) {
270
-		$section      = self::get_section( $section_id );
269
+	public static function get_section_data($section_id) {
270
+		$section      = self::get_section($section_id);
271 271
 		$section_data = '';
272 272
 
273
-		if ( ! empty( $section->endpoint ) ) {
274
-			$section_data = get_transient( 'wc_addons_section_' . $section_id );
275
-			if ( false === $section_data ) {
276
-				$raw_section = wp_safe_remote_get( esc_url_raw( $section->endpoint ) );
273
+		if (!empty($section->endpoint)) {
274
+			$section_data = get_transient('wc_addons_section_' . $section_id);
275
+			if (false === $section_data) {
276
+				$raw_section = wp_safe_remote_get(esc_url_raw($section->endpoint));
277 277
 
278
-				if ( ! is_wp_error( $raw_section ) ) {
279
-					$section_data = json_decode( wp_remote_retrieve_body( $raw_section ) );
278
+				if (!is_wp_error($raw_section)) {
279
+					$section_data = json_decode(wp_remote_retrieve_body($raw_section));
280 280
 
281
-					if ( ! empty( $section_data->products ) ) {
282
-						set_transient( 'wc_addons_section_' . $section_id, $section_data, WEEK_IN_SECONDS );
281
+					if (!empty($section_data->products)) {
282
+						set_transient('wc_addons_section_' . $section_id, $section_data, WEEK_IN_SECONDS);
283 283
 					}
284 284
 				}
285 285
 			}
286 286
 		}
287 287
 
288
-		return apply_filters( 'woocommerce_addons_section_data', $section_data->products, $section_id );
288
+		return apply_filters('woocommerce_addons_section_data', $section_data->products, $section_id);
289 289
 	}
290 290
 
291 291
 	/**
@@ -294,22 +294,22 @@  discard block
 block discarded – undo
294 294
 	 * @deprecated 5.9.0 No longer used in In-App Marketplace
295 295
 	 */
296 296
 	public static function output_storefront_button() {
297
-		$template   = get_option( 'template' );
298
-		$stylesheet = get_option( 'stylesheet' );
297
+		$template   = get_option('template');
298
+		$stylesheet = get_option('stylesheet');
299 299
 
300
-		if ( 'storefront' === $template ) {
301
-			if ( 'storefront' === $stylesheet ) {
300
+		if ('storefront' === $template) {
301
+			if ('storefront' === $stylesheet) {
302 302
 				$url         = 'https://woocommerce.com/product-category/themes/storefront-child-theme-themes/';
303
-				$text        = __( 'Need a fresh look? Try Storefront child themes', 'woocommerce' );
303
+				$text        = __('Need a fresh look? Try Storefront child themes', 'woocommerce');
304 304
 				$utm_content = 'nostorefrontchildtheme';
305 305
 			} else {
306 306
 				$url         = 'https://woocommerce.com/product-category/themes/storefront-child-theme-themes/';
307
-				$text        = __( 'View more Storefront child themes', 'woocommerce' );
307
+				$text        = __('View more Storefront child themes', 'woocommerce');
308 308
 				$utm_content = 'hasstorefrontchildtheme';
309 309
 			}
310 310
 		} else {
311 311
 			$url         = 'https://woocommerce.com/storefront/';
312
-			$text        = __( 'Need a theme? Try Storefront', 'woocommerce' );
312
+			$text        = __('Need a theme? Try Storefront', 'woocommerce');
313 313
 			$utm_content = 'nostorefront';
314 314
 		}
315 315
 
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 			$url
324 324
 		);
325 325
 
326
-		echo '<a href="' . esc_url( $url ) . '" class="add-new-h2">' . esc_html( $text ) . '</a>' . "\n";
326
+		echo '<a href="' . esc_url($url) . '" class="add-new-h2">' . esc_html($text) . '</a>' . "\n";
327 327
 	}
328 328
 
329 329
 	/**
@@ -333,21 +333,21 @@  discard block
 block discarded – undo
333 333
 	 *
334 334
 	 * @param object $block Banner data.
335 335
 	 */
336
-	public static function output_banner_block( $block ) {
336
+	public static function output_banner_block($block) {
337 337
 		?>
338 338
 		<div class="addons-banner-block">
339
-			<h1><?php echo esc_html( $block->title ); ?></h1>
340
-			<p><?php echo esc_html( $block->description ); ?></p>
339
+			<h1><?php echo esc_html($block->title); ?></h1>
340
+			<p><?php echo esc_html($block->description); ?></p>
341 341
 			<div class="addons-banner-block-items">
342
-				<?php foreach ( $block->items as $item ) : ?>
343
-					<?php if ( self::show_extension( $item ) ) : ?>
342
+				<?php foreach ($block->items as $item) : ?>
343
+					<?php if (self::show_extension($item)) : ?>
344 344
 						<div class="addons-banner-block-item">
345 345
 							<div class="addons-banner-block-item-icon">
346
-								<img class="addons-img" src="<?php echo esc_url( $item->image ); ?>" />
346
+								<img class="addons-img" src="<?php echo esc_url($item->image); ?>" />
347 347
 							</div>
348 348
 							<div class="addons-banner-block-item-content">
349
-								<h3><?php echo esc_html( $item->title ); ?></h3>
350
-								<p><?php echo esc_html( $item->description ); ?></p>
349
+								<h3><?php echo esc_html($item->title); ?></h3>
350
+								<p><?php echo esc_html($item->description); ?></p>
351 351
 								<?php
352 352
 									self::output_button(
353 353
 										$item->href,
@@ -372,13 +372,13 @@  discard block
 block discarded – undo
372 372
 	 *
373 373
 	 * @param object $block Column data.
374 374
 	 */
375
-	public static function output_column( $block ) {
376
-		if ( isset( $block->container ) && 'column_container_start' === $block->container ) {
375
+	public static function output_column($block) {
376
+		if (isset($block->container) && 'column_container_start' === $block->container) {
377 377
 			?>
378 378
 			<div class="addons-column-section">
379 379
 			<?php
380 380
 		}
381
-		if ( 'column_start' === $block->module ) {
381
+		if ('column_start' === $block->module) {
382 382
 			?>
383 383
 			<div class="addons-column">
384 384
 			<?php
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 			</div>
388 388
 			<?php
389 389
 		}
390
-		if ( isset( $block->container ) && 'column_container_end' === $block->container ) {
390
+		if (isset($block->container) && 'column_container_end' === $block->container) {
391 391
 			?>
392 392
 			</div>
393 393
 			<?php
@@ -401,19 +401,19 @@  discard block
 block discarded – undo
401 401
 	 *
402 402
 	 * @param object $block Column block data.
403 403
 	 */
404
-	public static function output_column_block( $block ) {
404
+	public static function output_column_block($block) {
405 405
 		?>
406 406
 		<div class="addons-column-block">
407
-			<h1><?php echo esc_html( $block->title ); ?></h1>
408
-			<p><?php echo esc_html( $block->description ); ?></p>
409
-			<?php foreach ( $block->items as $item ) : ?>
410
-				<?php if ( self::show_extension( $item ) ) : ?>
407
+			<h1><?php echo esc_html($block->title); ?></h1>
408
+			<p><?php echo esc_html($block->description); ?></p>
409
+			<?php foreach ($block->items as $item) : ?>
410
+				<?php if (self::show_extension($item)) : ?>
411 411
 					<div class="addons-column-block-item">
412 412
 						<div class="addons-column-block-item-icon">
413
-							<img class="addons-img" src="<?php echo esc_url( $item->image ); ?>" />
413
+							<img class="addons-img" src="<?php echo esc_url($item->image); ?>" />
414 414
 						</div>
415 415
 						<div class="addons-column-block-item-content">
416
-							<h2><?php echo esc_html( $item->title ); ?></h2>
416
+							<h2><?php echo esc_html($item->title); ?></h2>
417 417
 							<?php
418 418
 								self::output_button(
419 419
 									$item->href,
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 									$item->plugin
423 423
 								);
424 424
 							?>
425
-							<p><?php echo esc_html( $item->description ); ?></p>
425
+							<p><?php echo esc_html($item->description); ?></p>
426 426
 						</div>
427 427
 					</div>
428 428
 				<?php endif; ?>
@@ -439,15 +439,15 @@  discard block
 block discarded – undo
439 439
 	 *
440 440
 	 * @param object $block Block data.
441 441
 	 */
442
-	public static function output_small_light_block( $block ) {
442
+	public static function output_small_light_block($block) {
443 443
 		?>
444 444
 		<div class="addons-small-light-block">
445
-			<img class="addons-img" src="<?php echo esc_url( $block->image ); ?>" />
445
+			<img class="addons-img" src="<?php echo esc_url($block->image); ?>" />
446 446
 			<div class="addons-small-light-block-content">
447
-				<h1><?php echo esc_html( $block->title ); ?></h1>
448
-				<p><?php echo esc_html( $block->description ); ?></p>
447
+				<h1><?php echo esc_html($block->title); ?></h1>
448
+				<p><?php echo esc_html($block->description); ?></p>
449 449
 				<div class="addons-small-light-block-buttons">
450
-					<?php foreach ( $block->buttons as $button ) : ?>
450
+					<?php foreach ($block->buttons as $button) : ?>
451 451
 						<?php
452 452
 							self::output_button(
453 453
 								$button->href,
@@ -469,17 +469,17 @@  discard block
 block discarded – undo
469 469
 	 *
470 470
 	 * @param object $block Block data.
471 471
 	 */
472
-	public static function output_small_dark_block( $block ) {
472
+	public static function output_small_dark_block($block) {
473 473
 		?>
474 474
 		<div class="addons-small-dark-block">
475
-			<h1><?php echo esc_html( $block->title ); ?></h1>
476
-			<p><?php echo esc_html( $block->description ); ?></p>
475
+			<h1><?php echo esc_html($block->title); ?></h1>
476
+			<p><?php echo esc_html($block->description); ?></p>
477 477
 			<div class="addons-small-dark-items">
478
-				<?php foreach ( $block->items as $item ) : ?>
478
+				<?php foreach ($block->items as $item) : ?>
479 479
 					<div class="addons-small-dark-item">
480
-						<?php if ( ! empty( $item->image ) ) : ?>
480
+						<?php if (!empty($item->image)) : ?>
481 481
 							<div class="addons-small-dark-item-icon">
482
-								<img class="addons-img" src="<?php echo esc_url( $item->image ); ?>" />
482
+								<img class="addons-img" src="<?php echo esc_url($item->image); ?>" />
483 483
 							</div>
484 484
 						<?php endif; ?>
485 485
 						<?php
@@ -503,15 +503,15 @@  discard block
 block discarded – undo
503 503
 	 *
504 504
 	 * @param object $block Block data.
505 505
 	 */
506
-	public static function output_wcs_banner_block( $block = array() ) {
507
-		$is_active = is_plugin_active( 'woocommerce-services/woocommerce-services.php' );
506
+	public static function output_wcs_banner_block($block = array()) {
507
+		$is_active = is_plugin_active('woocommerce-services/woocommerce-services.php');
508 508
 		$location  = wc_get_base_location();
509 509
 
510 510
 		if (
511
-			! in_array( $location['country'], array( 'US' ), true ) ||
511
+			!in_array($location['country'], array('US'), true) ||
512 512
 			$is_active ||
513
-			! current_user_can( 'install_plugins' ) ||
514
-			! current_user_can( 'activate_plugins' )
513
+			!current_user_can('install_plugins') ||
514
+			!current_user_can('activate_plugins')
515 515
 		) {
516 516
 			return;
517 517
 		}
@@ -527,15 +527,15 @@  discard block
 block discarded – undo
527 527
 
528 528
 		$defaults = array(
529 529
 			'image'       => WC()->plugin_url() . '/assets/images/wcs-extensions-banner-3x.jpg',
530
-			'image_alt'   => __( 'WooCommerce Shipping', 'woocommerce' ),
531
-			'title'       => __( 'Save time and money with WooCommerce Shipping', 'woocommerce' ),
532
-			'description' => __( 'Print discounted USPS and DHL labels straight from your WooCommerce dashboard and save on shipping.', 'woocommerce' ),
533
-			'button'      => __( 'Free - Install now', 'woocommerce' ),
530
+			'image_alt'   => __('WooCommerce Shipping', 'woocommerce'),
531
+			'title'       => __('Save time and money with WooCommerce Shipping', 'woocommerce'),
532
+			'description' => __('Print discounted USPS and DHL labels straight from your WooCommerce dashboard and save on shipping.', 'woocommerce'),
533
+			'button'      => __('Free - Install now', 'woocommerce'),
534 534
 			'href'        => $button_url,
535 535
 			'logos'       => array(),
536 536
 		);
537 537
 
538
-		switch ( $location['country'] ) {
538
+		switch ($location['country']) {
539 539
 			case 'US':
540 540
 				$local_defaults = array(
541 541
 					'logos' => array_merge(
@@ -557,26 +557,26 @@  discard block
 block discarded – undo
557 557
 				$local_defaults = array();
558 558
 		}
559 559
 
560
-		$block_data = array_merge( $defaults, $local_defaults, $block );
560
+		$block_data = array_merge($defaults, $local_defaults, $block);
561 561
 		?>
562 562
 		<div class="addons-wcs-banner-block">
563 563
 			<div class="addons-wcs-banner-block-image is-full-image">
564 564
 				<img
565 565
 					class="addons-img"
566
-					src="<?php echo esc_url( $block_data['image'] ); ?>"
567
-					alt="<?php echo esc_attr( $block_data['image_alt'] ); ?>"
566
+					src="<?php echo esc_url($block_data['image']); ?>"
567
+					alt="<?php echo esc_attr($block_data['image_alt']); ?>"
568 568
 				/>
569 569
 			</div>
570 570
 			<div class="addons-wcs-banner-block-content">
571
-				<h1><?php echo esc_html( $block_data['title'] ); ?></h1>
572
-				<p><?php echo esc_html( $block_data['description'] ); ?></p>
571
+				<h1><?php echo esc_html($block_data['title']); ?></h1>
572
+				<p><?php echo esc_html($block_data['description']); ?></p>
573 573
 				<ul class="wcs-logos-container">
574
-					<?php foreach ( $block_data['logos'] as $logo ) : ?>
574
+					<?php foreach ($block_data['logos'] as $logo) : ?>
575 575
 						<li>
576 576
 							<img
577
-								alt="<?php echo esc_attr( $logo['alt'] ); ?>"
577
+								alt="<?php echo esc_attr($logo['alt']); ?>"
578 578
 								class="wcs-service-logo"
579
-								src="<?php echo esc_url( $logo['link'] ); ?>"
579
+								src="<?php echo esc_url($logo['link']); ?>"
580 580
 							>
581 581
 						</li>
582 582
 					<?php endforeach; ?>
@@ -600,15 +600,15 @@  discard block
 block discarded – undo
600 600
 	 *
601 601
 	 * @param object $block Block data.
602 602
 	 */
603
-	public static function output_wcpay_banner_block( $block = array() ) {
604
-		$is_active = is_plugin_active( 'woocommerce-payments/woocommerce-payments.php' );
603
+	public static function output_wcpay_banner_block($block = array()) {
604
+		$is_active = is_plugin_active('woocommerce-payments/woocommerce-payments.php');
605 605
 		$location  = wc_get_base_location();
606 606
 
607 607
 		if (
608
-			! in_array( $location['country'], array( 'US' ), true ) ||
608
+			!in_array($location['country'], array('US'), true) ||
609 609
 			$is_active ||
610
-			! current_user_can( 'install_plugins' ) ||
611
-			! current_user_can( 'activate_plugins' )
610
+			!current_user_can('install_plugins') ||
611
+			!current_user_can('activate_plugins')
612 612
 		) {
613 613
 			return;
614 614
 		}
@@ -624,27 +624,27 @@  discard block
 block discarded – undo
624 624
 
625 625
 		$defaults = array(
626 626
 			'image'       => WC()->plugin_url() . '/assets/images/wcpayments-icon-secure.png',
627
-			'image_alt'   => __( 'WooCommerce Payments', 'woocommerce' ),
628
-			'title'       => __( 'Payments made simple, with no monthly fees &mdash; exclusively for WooCommerce stores.', 'woocommerce' ),
629
-			'description' => __( 'Securely accept cards in your store. See payments, track cash flow into your bank account, and stay on top of disputes – right from your dashboard.', 'woocommerce' ),
630
-			'button'      => __( 'Free - Install now', 'woocommerce' ),
627
+			'image_alt'   => __('WooCommerce Payments', 'woocommerce'),
628
+			'title'       => __('Payments made simple, with no monthly fees &mdash; exclusively for WooCommerce stores.', 'woocommerce'),
629
+			'description' => __('Securely accept cards in your store. See payments, track cash flow into your bank account, and stay on top of disputes – right from your dashboard.', 'woocommerce'),
630
+			'button'      => __('Free - Install now', 'woocommerce'),
631 631
 			'href'        => $button_url,
632 632
 			'logos'       => array(),
633 633
 		);
634 634
 
635
-		$block_data = array_merge( $defaults, $block );
635
+		$block_data = array_merge($defaults, $block);
636 636
 		?>
637 637
 		<div class="addons-wcs-banner-block">
638 638
 			<div class="addons-wcs-banner-block-image">
639 639
 				<img
640 640
 					class="addons-img"
641
-					src="<?php echo esc_url( $block_data['image'] ); ?>"
642
-					alt="<?php echo esc_attr( $block_data['image_alt'] ); ?>"
641
+					src="<?php echo esc_url($block_data['image']); ?>"
642
+					alt="<?php echo esc_attr($block_data['image_alt']); ?>"
643 643
 				/>
644 644
 			</div>
645 645
 			<div class="addons-wcs-banner-block-content">
646
-				<h1><?php echo esc_html( $block_data['title'] ); ?></h1>
647
-				<p><?php echo esc_html( $block_data['description'] ); ?></p>
646
+				<h1><?php echo esc_html($block_data['title']); ?></h1>
647
+				<p><?php echo esc_html($block_data['description']); ?></p>
648 648
 				<?php
649 649
 					self::output_button(
650 650
 						$block_data['href'],
@@ -664,23 +664,23 @@  discard block
 block discarded – undo
664 664
 	 * @param array $promotion Array of promotion block data.
665 665
 	 * @return void
666 666
 	 */
667
-	public static function output_search_promotion_block( array $promotion ) {
667
+	public static function output_search_promotion_block(array $promotion) {
668 668
 		?>
669 669
 		<div class="addons-wcs-banner-block">
670 670
 			<div class="addons-wcs-banner-block-image">
671 671
 				<img
672 672
 					class="addons-img"
673
-					src="<?php echo esc_url( $promotion['image'] ); ?>"
674
-					alt="<?php echo esc_attr( $promotion['image_alt'] ); ?>"
673
+					src="<?php echo esc_url($promotion['image']); ?>"
674
+					alt="<?php echo esc_attr($promotion['image_alt']); ?>"
675 675
 				/>
676 676
 			</div>
677 677
 			<div class="addons-wcs-banner-block-content">
678
-				<h1><?php echo esc_html( $promotion['title'] ); ?></h1>
679
-				<p><?php echo esc_html( $promotion['description'] ); ?></p>
678
+				<h1><?php echo esc_html($promotion['title']); ?></h1>
679
+				<p><?php echo esc_html($promotion['description']); ?></p>
680 680
 				<?php
681
-				if ( ! empty( $promotion['actions'] ) ) {
682
-					foreach ( $promotion['actions'] as $action ) {
683
-						self::output_promotion_action( $action );
681
+				if (!empty($promotion['actions'])) {
682
+					foreach ($promotion['actions'] as $action) {
683
+						self::output_promotion_action($action);
684 684
 					}
685 685
 				}
686 686
 				?>
@@ -697,25 +697,25 @@  discard block
 block discarded – undo
697 697
 	 *
698 698
 	 * @param array $section Section data.
699 699
 	 */
700
-	public static function output_promotion_block( $section ) {
700
+	public static function output_promotion_block($section) {
701 701
 		if (
702
-			! current_user_can( 'install_plugins' ) ||
703
-			! current_user_can( 'activate_plugins' )
702
+			!current_user_can('install_plugins') ||
703
+			!current_user_can('activate_plugins')
704 704
 		) {
705 705
 			return;
706 706
 		}
707 707
 
708 708
 		$section_object = (object) $section;
709 709
 
710
-		if ( ! empty( $section_object->geowhitelist ) ) {
711
-			$section_object->geowhitelist = explode( ',', $section_object->geowhitelist );
710
+		if (!empty($section_object->geowhitelist)) {
711
+			$section_object->geowhitelist = explode(',', $section_object->geowhitelist);
712 712
 		}
713 713
 
714
-		if ( ! empty( $section_object->geoblacklist ) ) {
715
-			$section_object->geoblacklist = explode( ',', $section_object->geoblacklist );
714
+		if (!empty($section_object->geoblacklist)) {
715
+			$section_object->geoblacklist = explode(',', $section_object->geoblacklist);
716 716
 		}
717 717
 
718
-		if ( ! self::show_extension( $section_object ) ) {
718
+		if (!self::show_extension($section_object)) {
719 719
 			return;
720 720
 		}
721 721
 
@@ -723,17 +723,17 @@  discard block
 block discarded – undo
723 723
 		<div class="addons-banner-block addons-promotion-block">
724 724
 			<img
725 725
 				class="addons-img"
726
-				src="<?php echo esc_url( $section['image'] ); ?>"
727
-				alt="<?php echo esc_attr( $section['image_alt'] ); ?>"
726
+				src="<?php echo esc_url($section['image']); ?>"
727
+				alt="<?php echo esc_attr($section['image_alt']); ?>"
728 728
 			/>
729 729
 			<div class="addons-promotion-block-content">
730
-				<h1 class="addons-promotion-block-title"><?php echo esc_html( $section['title'] ); ?></h1>
730
+				<h1 class="addons-promotion-block-title"><?php echo esc_html($section['title']); ?></h1>
731 731
 				<div class="addons-promotion-block-description">
732
-					<?php echo wp_kses_post( $section['description'] ); ?>
732
+					<?php echo wp_kses_post($section['description']); ?>
733 733
 				</div>
734 734
 				<div class="addons-promotion-block-buttons">
735 735
 					<?php
736
-					if ( $section['button_1'] ) {
736
+					if ($section['button_1']) {
737 737
 						self::output_button(
738 738
 							$section['button_1_href'],
739 739
 							$section['button_1'],
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
 						);
743 743
 					}
744 744
 
745
-					if ( $section['button_2'] ) {
745
+					if ($section['button_2']) {
746 746
 						self::output_button(
747 747
 							$section['button_2_href'],
748 748
 							$section['button_2'],
@@ -762,35 +762,35 @@  discard block
 block discarded – undo
762 762
 	 *
763 763
 	 * @param array $sections Section data.
764 764
 	 */
765
-	public static function output_featured_sections( $sections ) {
766
-		foreach ( $sections as $section ) {
767
-			switch ( $section->module ) {
765
+	public static function output_featured_sections($sections) {
766
+		foreach ($sections as $section) {
767
+			switch ($section->module) {
768 768
 				case 'banner_block':
769
-					self::output_banner_block( $section );
769
+					self::output_banner_block($section);
770 770
 					break;
771 771
 				case 'column_start':
772
-					self::output_column( $section );
772
+					self::output_column($section);
773 773
 					break;
774 774
 				case 'column_end':
775
-					self::output_column( $section );
775
+					self::output_column($section);
776 776
 					break;
777 777
 				case 'column_block':
778
-					self::output_column_block( $section );
778
+					self::output_column_block($section);
779 779
 					break;
780 780
 				case 'small_light_block':
781
-					self::output_small_light_block( $section );
781
+					self::output_small_light_block($section);
782 782
 					break;
783 783
 				case 'small_dark_block':
784
-					self::output_small_dark_block( $section );
784
+					self::output_small_dark_block($section);
785 785
 					break;
786 786
 				case 'wcs_banner_block':
787
-					self::output_wcs_banner_block( (array) $section );
787
+					self::output_wcs_banner_block((array) $section);
788 788
 					break;
789 789
 				case 'wcpay_banner_block':
790
-					self::output_wcpay_banner_block( (array) $section );
790
+					self::output_wcpay_banner_block((array) $section);
791 791
 					break;
792 792
 				case 'promotion_block':
793
-					self::output_promotion_block( (array) $section );
793
+					self::output_promotion_block((array) $section);
794 794
 					break;
795 795
 			}
796 796
 		}
@@ -801,15 +801,15 @@  discard block
 block discarded – undo
801 801
 	 *
802 802
 	 * @param array $blocks Featured page's blocks.
803 803
 	 */
804
-	private static function output_featured( $blocks ) {
805
-		foreach ( $blocks as $block ) {
804
+	private static function output_featured($blocks) {
805
+		foreach ($blocks as $block) {
806 806
 			$block_type = $block->type ?? null;
807
-			switch ( $block_type ) {
807
+			switch ($block_type) {
808 808
 				case 'group':
809
-					self::output_group( $block );
809
+					self::output_group($block);
810 810
 					break;
811 811
 				case 'banner':
812
-					self::output_banner( $block );
812
+					self::output_banner($block);
813 813
 					break;
814 814
 			}
815 815
 		}
@@ -822,31 +822,31 @@  discard block
 block discarded – undo
822 822
 	 *
823 823
 	 * @return void
824 824
 	 */
825
-	private static function output_group( $block ) {
825
+	private static function output_group($block) {
826 826
 		$capacity             = $block->capacity ?? 3;
827 827
 		$product_list_classes = 3 === $capacity ? 'three-column' : 'two-column';
828 828
 		$product_list_classes = 'products addons-products-' . $product_list_classes;
829 829
 		?>
830 830
 			<section class="addon-product-group">
831
-				<h2 class="addon-product-group-title"><?php echo esc_html( $block->title ); ?></h2>
831
+				<h2 class="addon-product-group-title"><?php echo esc_html($block->title); ?></h2>
832 832
 				<div class="addon-product-group-description-container">
833
-					<?php if ( ! empty( $block->description ) ) : ?>
833
+					<?php if (!empty($block->description)) : ?>
834 834
 					<div class="addon-product-group-description">
835
-						<?php echo esc_html( $block->description ); ?>
835
+						<?php echo esc_html($block->description); ?>
836 836
 					</div>
837 837
 					<?php endif; ?>
838
-					<?php if ( null !== $block->url ) : ?>
839
-					<a class="addon-product-group-see-more" href="<?php echo esc_url( $block->url ); ?>">
840
-						<?php esc_html_e( 'See more', 'woocommerce' ); ?>
838
+					<?php if (null !== $block->url) : ?>
839
+					<a class="addon-product-group-see-more" href="<?php echo esc_url($block->url); ?>">
840
+						<?php esc_html_e('See more', 'woocommerce'); ?>
841 841
 					</a>
842 842
 					<?php endif; ?>
843 843
 				</div>
844 844
 				<div class="addon-product-group__items">
845
-					<ul class="<?php echo esc_attr( $product_list_classes ); ?>">
845
+					<ul class="<?php echo esc_attr($product_list_classes); ?>">
846 846
 					<?php
847
-					$products = array_slice( $block->items, 0, $capacity );
848
-					foreach ( $products as $item ) {
849
-						self::render_product_card( $item );
847
+					$products = array_slice($block->items, 0, $capacity);
848
+					foreach ($products as $item) {
849
+						self::render_product_card($item);
850 850
 					}
851 851
 					?>
852 852
 					</ul>
@@ -862,12 +862,12 @@  discard block
 block discarded – undo
862 862
 	 *
863 863
 	 * @return void
864 864
 	 */
865
-	private static function output_banner( $block ) {
866
-		if ( empty( $block->buttons ) ) {
865
+	private static function output_banner($block) {
866
+		if (empty($block->buttons)) {
867 867
 			// Render a product-like banner.
868 868
 			?>
869 869
 			<ul class="products">
870
-				<?php self::render_product_card( $block, $block->type ); ?>
870
+				<?php self::render_product_card($block, $block->type); ?>
871 871
 			</ul>
872 872
 			<?php
873 873
 		} else {
@@ -876,25 +876,25 @@  discard block
 block discarded – undo
876 876
 			<ul class="products">
877 877
 				<li class="product addons-buttons-banner">
878 878
 					<div class="addons-buttons-banner-image"
879
-						style="background-image:url(<?php echo esc_url( $block->image ); ?>)"
880
-						title="<?php echo esc_attr( $block->image_alt ); ?>"></div>
879
+						style="background-image:url(<?php echo esc_url($block->image); ?>)"
880
+						title="<?php echo esc_attr($block->image_alt); ?>"></div>
881 881
 					<div class="product-details addons-buttons-banner-details-container">
882 882
 						<div class="addons-buttons-banner-details">
883
-							<h2><?php echo esc_html( $block->title ); ?></h2>
884
-							<p><?php echo wp_kses( $block->description, array() ); ?></p>
883
+							<h2><?php echo esc_html($block->title); ?></h2>
884
+							<p><?php echo wp_kses($block->description, array()); ?></p>
885 885
 						</div>
886 886
 						<div class="addons-buttons-banner-button-container">
887 887
 						<?php
888
-						foreach ( $block->buttons as $button ) {
889
-							$button_classes = array( 'button', 'addons-buttons-banner-button' );
888
+						foreach ($block->buttons as $button) {
889
+							$button_classes = array('button', 'addons-buttons-banner-button');
890 890
 							$type           = $button->type ?? null;
891
-							if ( 'primary' === $type ) {
891
+							if ('primary' === $type) {
892 892
 								$button_classes[] = 'addons-buttons-banner-button-primary';
893 893
 							}
894 894
 							?>
895
-							<a class="<?php echo esc_attr( implode( ' ', $button_classes ) ); ?>"
896
-								href="<?php echo esc_url( $button->href ); ?>">
897
-								<?php echo esc_html( $button->title ); ?>
895
+							<a class="<?php echo esc_attr(implode(' ', $button_classes)); ?>"
896
+								href="<?php echo esc_url($button->href); ?>">
897
+								<?php echo esc_html($button->title); ?>
898 898
 							</a>
899 899
 						<?php } ?>
900 900
 						</div>
@@ -911,12 +911,12 @@  discard block
 block discarded – undo
911 911
 	public static function get_in_app_purchase_url_params() {
912 912
 		// Get url (from path onward) for the current page,
913 913
 		// so WCCOM "back" link returns user to where they were.
914
-		$back_admin_path = add_query_arg( array() );
914
+		$back_admin_path = add_query_arg(array());
915 915
 		return array(
916 916
 			'wccom-site'          => site_url(),
917
-			'wccom-back'          => rawurlencode( $back_admin_path ),
918
-			'wccom-woo-version'   => Constants::get_constant( 'WC_VERSION' ),
919
-			'wccom-connect-nonce' => wp_create_nonce( 'connect' ),
917
+			'wccom-back'          => rawurlencode($back_admin_path),
918
+			'wccom-woo-version'   => Constants::get_constant('WC_VERSION'),
919
+			'wccom-connect-nonce' => wp_create_nonce('connect'),
920 920
 		);
921 921
 	}
922 922
 
@@ -928,7 +928,7 @@  discard block
 block discarded – undo
928 928
 	 *
929 929
 	 * @param string $url    Destination URL.
930 930
 	 */
931
-	public static function add_in_app_purchase_url_params( $url ) {
931
+	public static function add_in_app_purchase_url_params($url) {
932 932
 		return add_query_arg(
933 933
 			self::get_in_app_purchase_url_params(),
934 934
 			$url
@@ -943,16 +943,16 @@  discard block
 block discarded – undo
943 943
 	 * @param string $style  Button style class.
944 944
 	 * @param string $plugin The plugin the button is promoting.
945 945
 	 */
946
-	public static function output_button( $url, $text, $style, $plugin = '' ) {
947
-		$style = __( 'Free', 'woocommerce' ) === $text ? 'addons-button-outline-purple' : $style;
948
-		$style = is_plugin_active( $plugin ) ? 'addons-button-installed' : $style;
949
-		$text  = is_plugin_active( $plugin ) ? __( 'Installed', 'woocommerce' ) : $text;
950
-		$url   = self::add_in_app_purchase_url_params( $url );
946
+	public static function output_button($url, $text, $style, $plugin = '') {
947
+		$style = __('Free', 'woocommerce') === $text ? 'addons-button-outline-purple' : $style;
948
+		$style = is_plugin_active($plugin) ? 'addons-button-installed' : $style;
949
+		$text  = is_plugin_active($plugin) ? __('Installed', 'woocommerce') : $text;
950
+		$url   = self::add_in_app_purchase_url_params($url);
951 951
 		?>
952 952
 		<a
953
-			class="addons-button <?php echo esc_attr( $style ); ?>"
954
-			href="<?php echo esc_url( $url ); ?>">
955
-			<?php echo esc_html( $text ); ?>
953
+			class="addons-button <?php echo esc_attr($style); ?>"
954
+			href="<?php echo esc_url($url); ?>">
955
+			<?php echo esc_html($text); ?>
956 956
 		</a>
957 957
 		<?php
958 958
 	}
@@ -964,16 +964,16 @@  discard block
 block discarded – undo
964 964
 	 *
965 965
 	 * @return void
966 966
 	 */
967
-	public static function output_promotion_action( array $action ) {
968
-		if ( empty( $action ) ) {
967
+	public static function output_promotion_action(array $action) {
968
+		if (empty($action)) {
969 969
 			return;
970 970
 		}
971
-		$style = ( ! empty( $action['primary'] ) && $action['primary'] ) ? 'addons-button-solid' : 'addons-button-outline-purple';
971
+		$style = (!empty($action['primary']) && $action['primary']) ? 'addons-button-solid' : 'addons-button-outline-purple';
972 972
 		?>
973 973
 		<a
974
-			class="addons-button <?php echo esc_attr( $style ); ?>"
975
-			href="<?php echo esc_url( $action['url'] ); ?>">
976
-			<?php echo esc_html( $action['label'] ); ?>
974
+			class="addons-button <?php echo esc_attr($style); ?>"
975
+			href="<?php echo esc_url($action['url']); ?>">
976
+			<?php echo esc_html($action['label']); ?>
977 977
 		</a>
978 978
 		<?php
979 979
 	}
@@ -985,12 +985,12 @@  discard block
 block discarded – undo
985 985
 	 *
986 986
 	 * @return void
987 987
 	 */
988
-	public static function output_empty( $message = '' ) {
988
+	public static function output_empty($message = '') {
989 989
 		?>
990 990
 		<div class="wc-addons__empty">
991
-			<h2><?php echo wp_kses_post( __( 'Oh no! We\'re having trouble connecting to the extensions catalog right now.', 'woocommerce' ) ); ?></h2>
992
-			<?php if ( ! empty( $message ) ) : ?>
993
-				<p><?php echo esc_html( $message ); ?></p>
991
+			<h2><?php echo wp_kses_post(__('Oh no! We\'re having trouble connecting to the extensions catalog right now.', 'woocommerce')); ?></h2>
992
+			<?php if (!empty($message)) : ?>
993
+				<p><?php echo esc_html($message); ?></p>
994 994
 			<?php endif; ?>
995 995
 			<p>
996 996
 				<?php
@@ -1015,21 +1015,21 @@  discard block
 block discarded – undo
1015 1015
 	 * Handles output of the addons page in admin.
1016 1016
 	 */
1017 1017
 	public static function output() {
1018
-		$section = isset( $_GET['section'] ) ? sanitize_text_field( wp_unslash( $_GET['section'] ) ) : '_featured';
1019
-		$search  = isset( $_GET['search'] ) ? sanitize_text_field( wp_unslash( $_GET['search'] ) ) : '';
1018
+		$section = isset($_GET['section']) ? sanitize_text_field(wp_unslash($_GET['section'])) : '_featured';
1019
+		$search  = isset($_GET['search']) ? sanitize_text_field(wp_unslash($_GET['search'])) : '';
1020 1020
 
1021
-		if ( isset( $_GET['section'] ) && 'helper' === $_GET['section'] ) {
1022
-			do_action( 'woocommerce_helper_output' );
1021
+		if (isset($_GET['section']) && 'helper' === $_GET['section']) {
1022
+			do_action('woocommerce_helper_output');
1023 1023
 			return;
1024 1024
 		}
1025 1025
 
1026
-		if ( isset( $_GET['install-addon'] ) ) {
1027
-			switch ( $_GET['install-addon'] ) {
1026
+		if (isset($_GET['install-addon'])) {
1027
+			switch ($_GET['install-addon']) {
1028 1028
 				case 'woocommerce-services':
1029 1029
 					self::install_woocommerce_services_addon();
1030 1030
 					break;
1031 1031
 				case 'woocommerce-payments':
1032
-					self::install_woocommerce_payments_addon( $section );
1032
+					self::install_woocommerce_payments_addon($section);
1033 1033
 					break;
1034 1034
 				default:
1035 1035
 					// Do nothing.
@@ -1039,34 +1039,34 @@  discard block
 block discarded – undo
1039 1039
 
1040 1040
 		$sections        = self::get_sections();
1041 1041
 		$theme           = wp_get_theme();
1042
-		$current_section = isset( $_GET['section'] ) ? $section : '_featured';
1042
+		$current_section = isset($_GET['section']) ? $section : '_featured';
1043 1043
 		$promotions      = array();
1044 1044
 		$addons          = array();
1045 1045
 
1046
-		if ( '_featured' !== $current_section ) {
1046
+		if ('_featured' !== $current_section) {
1047 1047
 			$category       = $section ? $section : null;
1048 1048
 			$term           = $search ? $search : null;
1049 1049
 			$country        = WC()->countries->get_base_country();
1050
-			$extension_data = self::get_extension_data( $category, $term, $country );
1051
-			$addons         = is_wp_error( $extension_data ) ? $extension_data : $extension_data->products;
1052
-			$promotions     = ! empty( $extension_data->promotions ) ? $extension_data->promotions : array();
1050
+			$extension_data = self::get_extension_data($category, $term, $country);
1051
+			$addons         = is_wp_error($extension_data) ? $extension_data : $extension_data->products;
1052
+			$promotions     = !empty($extension_data->promotions) ? $extension_data->promotions : array();
1053 1053
 		}
1054 1054
 
1055 1055
 		// We need Automattic\WooCommerce\Admin\RemoteInboxNotifications for the next part, if not remove all promotions.
1056
-		if ( ! WC()->is_wc_admin_active() ) {
1056
+		if (!WC()->is_wc_admin_active()) {
1057 1057
 			$promotions = array();
1058 1058
 		}
1059 1059
 		// Check for existence of promotions and evaluate out if we should show them.
1060
-		if ( ! empty( $promotions ) ) {
1061
-			foreach ( $promotions as $promo_id => $promotion ) {
1060
+		if (!empty($promotions)) {
1061
+			foreach ($promotions as $promo_id => $promotion) {
1062 1062
 				$evaluator = new PromotionRuleEngine\RuleEvaluator();
1063
-				$passed    = $evaluator->evaluate( $promotion->rules );
1064
-				if ( ! $passed ) {
1065
-					unset( $promotions[ $promo_id ] );
1063
+				$passed    = $evaluator->evaluate($promotion->rules);
1064
+				if (!$passed) {
1065
+					unset($promotions[$promo_id]);
1066 1066
 				}
1067 1067
 			}
1068 1068
 			// Transform promotions to the correct format ready for output.
1069
-			$promotions = self::format_promotions( $promotions );
1069
+			$promotions = self::format_promotions($promotions);
1070 1070
 		}
1071 1071
 
1072 1072
 		/**
@@ -1078,24 +1078,24 @@  discard block
 block discarded – undo
1078 1078
 		 * @uses $theme
1079 1079
 		 * @uses $current_section
1080 1080
 		 */
1081
-		include_once dirname( __FILE__ ) . '/views/html-admin-page-addons.php';
1081
+		include_once dirname(__FILE__) . '/views/html-admin-page-addons.php';
1082 1082
 	}
1083 1083
 
1084 1084
 	/**
1085 1085
 	 * Install WooCommerce Services from Extensions screens.
1086 1086
 	 */
1087 1087
 	public static function install_woocommerce_services_addon() {
1088
-		check_admin_referer( 'install-addon_woocommerce-services' );
1088
+		check_admin_referer('install-addon_woocommerce-services');
1089 1089
 
1090 1090
 		$services_plugin_id = 'woocommerce-services';
1091 1091
 		$services_plugin    = array(
1092
-			'name'      => __( 'WooCommerce Services', 'woocommerce' ),
1092
+			'name'      => __('WooCommerce Services', 'woocommerce'),
1093 1093
 			'repo-slug' => 'woocommerce-services',
1094 1094
 		);
1095 1095
 
1096
-		WC_Install::background_installer( $services_plugin_id, $services_plugin );
1096
+		WC_Install::background_installer($services_plugin_id, $services_plugin);
1097 1097
 
1098
-		wp_safe_redirect( remove_query_arg( array( 'install-addon', '_wpnonce' ) ) );
1098
+		wp_safe_redirect(remove_query_arg(array('install-addon', '_wpnonce')));
1099 1099
 		exit;
1100 1100
 	}
1101 1101
 
@@ -1106,20 +1106,20 @@  discard block
 block discarded – undo
1106 1106
 	 *
1107 1107
 	 * @return void
1108 1108
 	 */
1109
-	public static function install_woocommerce_payments_addon( $section = '_featured' ) {
1110
-		check_admin_referer( 'install-addon_woocommerce-payments' );
1109
+	public static function install_woocommerce_payments_addon($section = '_featured') {
1110
+		check_admin_referer('install-addon_woocommerce-payments');
1111 1111
 
1112 1112
 		$wcpay_plugin_id = 'woocommerce-payments';
1113 1113
 		$wcpay_plugin    = array(
1114
-			'name'      => __( 'WooCommerce Payments', 'woocommerce' ),
1114
+			'name'      => __('WooCommerce Payments', 'woocommerce'),
1115 1115
 			'repo-slug' => 'woocommerce-payments',
1116 1116
 		);
1117 1117
 
1118
-		WC_Install::background_installer( $wcpay_plugin_id, $wcpay_plugin );
1118
+		WC_Install::background_installer($wcpay_plugin_id, $wcpay_plugin);
1119 1119
 
1120
-		do_action( 'woocommerce_addon_installed', $wcpay_plugin_id, $section );
1120
+		do_action('woocommerce_addon_installed', $wcpay_plugin_id, $section);
1121 1121
 
1122
-		wp_safe_redirect( remove_query_arg( array( 'install-addon', '_wpnonce' ) ) );
1122
+		wp_safe_redirect(remove_query_arg(array('install-addon', '_wpnonce')));
1123 1123
 		exit;
1124 1124
 	}
1125 1125
 
@@ -1131,8 +1131,8 @@  discard block
 block discarded – undo
1131 1131
 	 *
1132 1132
 	 * @return string Body class with added class for Marketplace or My Subscriptions page.
1133 1133
 	 */
1134
-	public static function filter_admin_body_classes( string $admin_body_class = '' ): string {
1135
-		if ( isset( $_GET['section'] ) && 'helper' === $_GET['section'] ) {
1134
+	public static function filter_admin_body_classes(string $admin_body_class = ''): string {
1135
+		if (isset($_GET['section']) && 'helper' === $_GET['section']) {
1136 1136
 			return " $admin_body_class woocommerce-page-wc-subscriptions ";
1137 1137
 		}
1138 1138
 
@@ -1155,16 +1155,16 @@  discard block
 block discarded – undo
1155 1155
 	 *
1156 1156
 	 * @return string CSS class to use.
1157 1157
 	 */
1158
-	public static function get_star_class( $rating, $index ) {
1159
-		if ( $rating >= $index ) {
1158
+	public static function get_star_class($rating, $index) {
1159
+		if ($rating >= $index) {
1160 1160
 			// Rating more that current star to show.
1161 1161
 			return 'fill';
1162 1162
 		} elseif (
1163
-			abs( $index - 1 - floor( $rating ) ) < 0.0000001 &&
1164
-			0 < ( $rating - floor( $rating ) )
1163
+			abs($index - 1 - floor($rating)) < 0.0000001 &&
1164
+			0 < ($rating - floor($rating))
1165 1165
 		) {
1166 1166
 			// For rating more than x.0 and less than x.5 or equal it will show a half star.
1167
-			return 50 >= floor( ( $rating - floor( $rating ) ) * 100 )
1167
+			return 50 >= floor(($rating - floor($rating)) * 100)
1168 1168
 				? 'half-fill'
1169 1169
 				: 'fill';
1170 1170
 		}
@@ -1179,21 +1179,21 @@  discard block
 block discarded – undo
1179 1179
 	 * @param object $action Action object.
1180 1180
 	 * @return string URL.
1181 1181
 	 */
1182
-	public static function get_action_url( $action ): string {
1183
-		if ( ! isset( $action->url ) ) {
1182
+	public static function get_action_url($action): string {
1183
+		if (!isset($action->url)) {
1184 1184
 			return '';
1185 1185
 		}
1186 1186
 
1187
-		if ( isset( $action->url_is_admin_query ) && $action->url_is_admin_query ) {
1188
-			return wc_admin_url( $action->url );
1187
+		if (isset($action->url_is_admin_query) && $action->url_is_admin_query) {
1188
+			return wc_admin_url($action->url);
1189 1189
 		}
1190 1190
 
1191
-		if ( isset( $action->url_is_admin_nonce_query ) && $action->url_is_admin_nonce_query ) {
1192
-			if ( empty( $action->nonce ) ) {
1191
+		if (isset($action->url_is_admin_nonce_query) && $action->url_is_admin_nonce_query) {
1192
+			if (empty($action->nonce)) {
1193 1193
 				return '';
1194 1194
 			}
1195 1195
 			return wp_nonce_url(
1196
-				admin_url( $action->url ),
1196
+				admin_url($action->url),
1197 1197
 				$action->nonce
1198 1198
 			);
1199 1199
 		}
@@ -1207,26 +1207,26 @@  discard block
 block discarded – undo
1207 1207
 	 * @param array $promotions Array of promotoin objects.
1208 1208
 	 * @return array Array of formatted promotions ready for output.
1209 1209
 	 */
1210
-	public static function format_promotions( array $promotions ): array {
1210
+	public static function format_promotions(array $promotions): array {
1211 1211
 		$formatted_promotions = array();
1212
-		foreach ( $promotions as $promotion ) {
1212
+		foreach ($promotions as $promotion) {
1213 1213
 			// Get the matching locale or fall back to en-US.
1214
-			$locale = PromotionRuleEngine\SpecRunner::get_locale( $promotion->locales );
1215
-			if ( null === $locale ) {
1214
+			$locale = PromotionRuleEngine\SpecRunner::get_locale($promotion->locales);
1215
+			if (null === $locale) {
1216 1216
 				continue;
1217 1217
 			}
1218 1218
 
1219 1219
 			$promotion_actions = array();
1220
-			if ( ! empty( $promotion->actions ) ) {
1221
-				foreach ( $promotion->actions as $action ) {
1222
-					$action_locale = PromotionRuleEngine\SpecRunner::get_action_locale( $action->locales );
1223
-					$url           = self::get_action_url( $action );
1220
+			if (!empty($promotion->actions)) {
1221
+				foreach ($promotion->actions as $action) {
1222
+					$action_locale = PromotionRuleEngine\SpecRunner::get_action_locale($action->locales);
1223
+					$url           = self::get_action_url($action);
1224 1224
 
1225 1225
 					$promotion_actions[] = array(
1226 1226
 						'name'    => $action->name,
1227 1227
 						'label'   => $action_locale->label,
1228 1228
 						'url'     => $url,
1229
-						'primary' => isset( $action->is_primary ) ? $action->is_primary : false,
1229
+						'primary' => isset($action->is_primary) ? $action->is_primary : false,
1230 1230
 					);
1231 1231
 				}
1232 1232
 			}
@@ -1234,7 +1234,7 @@  discard block
 block discarded – undo
1234 1234
 			$formatted_promotions[] = array(
1235 1235
 				'title'       => $locale->title,
1236 1236
 				'description' => $locale->description,
1237
-				'image'       => ( 'http' === substr( $locale->image, 0, 4 ) ) ? $locale->image : WC()->plugin_url() . $locale->image,
1237
+				'image'       => ('http' === substr($locale->image, 0, 4)) ? $locale->image : WC()->plugin_url() . $locale->image,
1238 1238
 				'image_alt'   => $locale->image_alt,
1239 1239
 				'actions'     => $promotion_actions,
1240 1240
 			);
@@ -1252,21 +1252,21 @@  discard block
 block discarded – undo
1252 1252
 	 *
1253 1253
 	 * @return object Converted data.
1254 1254
 	 */
1255
-	public static function map_product_card_data( $data ) {
1255
+	public static function map_product_card_data($data) {
1256 1256
 		$mapped = (object) null;
1257 1257
 
1258 1258
 		$type = $data->type ?? null;
1259 1259
 
1260 1260
 		// Icon.
1261 1261
 		$mapped->icon = $data->icon ?? null;
1262
-		if ( null === $mapped->icon && 'banner' === $type ) {
1262
+		if (null === $mapped->icon && 'banner' === $type) {
1263 1263
 			// For product-related banners icon is a product's image.
1264 1264
 			$mapped->icon = $data->image ?? null;
1265 1265
 		}
1266 1266
 
1267 1267
 		// URL.
1268 1268
 		$mapped->url = $data->link ?? null;
1269
-		if ( empty( $mapped->url ) ) {
1269
+		if (empty($mapped->url)) {
1270 1270
 			$mapped->url = $data->url ?? null;
1271 1271
 		}
1272 1272
 
@@ -1275,34 +1275,34 @@  discard block
 block discarded – undo
1275 1275
 
1276 1276
 		// Vendor Name.
1277 1277
 		$mapped->vendor_name = $data->vendor_name ?? null;
1278
-		if ( empty( $mapped->vendor_name ) ) {
1278
+		if (empty($mapped->vendor_name)) {
1279 1279
 			$mapped->vendor_name = $data->vendorName ?? null; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
1280 1280
 		}
1281 1281
 
1282 1282
 		// Vendor URL.
1283 1283
 		$mapped->vendor_url = $data->vendor_url ?? null;
1284
-		if ( empty( $mapped->vendor_url ) ) {
1284
+		if (empty($mapped->vendor_url)) {
1285 1285
 			$mapped->vendor_url = $data->vendorUrl ?? null; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
1286 1286
 		}
1287 1287
 
1288 1288
 		// Description.
1289 1289
 		$mapped->description = $data->excerpt ?? null;
1290
-		if ( empty( $mapped->description ) ) {
1290
+		if (empty($mapped->description)) {
1291 1291
 			$mapped->description = $data->description ?? null;
1292 1292
 		}
1293 1293
 
1294
-		$has_currency = ! empty( $data->currency ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
1294
+		$has_currency = !empty($data->currency); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
1295 1295
 
1296 1296
 		// Is Free.
1297
-		if ( $has_currency ) {
1297
+		if ($has_currency) {
1298 1298
 			$mapped->is_free = 0 === (int) $data->price;
1299 1299
 		} else {
1300 1300
 			$mapped->is_free = '&#36;0.00' === $data->price;
1301 1301
 		}
1302 1302
 
1303 1303
 		// Price.
1304
-		if ( $has_currency ) {
1305
-			$mapped->price = wc_price( $data->price, array( 'currency' => $data->currency ) );
1304
+		if ($has_currency) {
1305
+			$mapped->price = wc_price($data->price, array('currency' => $data->currency));
1306 1306
 		} else {
1307 1307
 			$mapped->price = $data->price;
1308 1308
 		}
@@ -1312,13 +1312,13 @@  discard block
 block discarded – undo
1312 1312
 
1313 1313
 		// Rating.
1314 1314
 		$mapped->rating = $data->rating ?? null;
1315
-		if ( null === $mapped->rating ) {
1315
+		if (null === $mapped->rating) {
1316 1316
 			$mapped->rating = $data->averageRating ?? null; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
1317 1317
 		}
1318 1318
 
1319 1319
 		// Reviews Count.
1320 1320
 		$mapped->reviews_count = $data->reviews_count ?? null;
1321
-		if ( null === $mapped->reviews_count ) {
1321
+		if (null === $mapped->reviews_count) {
1322 1322
 			$mapped->reviews_count = $data->reviewsCount ?? null; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
1323 1323
 		}
1324 1324
 		// Featured & Promoted product card.
@@ -1345,44 +1345,44 @@  discard block
 block discarded – undo
1345 1345
 	 *
1346 1346
 	 * @return void
1347 1347
 	 */
1348
-	public static function render_product_card( $data, $block_type = null ) {
1349
-		$mapped      = self::map_product_card_data( $data );
1350
-		$product_url = self::add_in_app_purchase_url_params( $mapped->url );
1351
-		$class_names = array( 'product' );
1348
+	public static function render_product_card($data, $block_type = null) {
1349
+		$mapped      = self::map_product_card_data($data);
1350
+		$product_url = self::add_in_app_purchase_url_params($mapped->url);
1351
+		$class_names = array('product');
1352 1352
 		// Specify a class name according to $block_type (if it's specified).
1353
-		if ( null !== $block_type ) {
1353
+		if (null !== $block_type) {
1354 1354
 			$class_names[] = 'addons-product-' . $block_type;
1355 1355
 		}
1356 1356
 
1357 1357
 		$product_details_classes = 'product-details';
1358
-		if ( 'banner' === $block_type ) {
1358
+		if ('banner' === $block_type) {
1359 1359
 			$product_details_classes .= ' addon-product-banner-details';
1360 1360
 		}
1361 1361
 
1362
-		if ( isset( $mapped->label ) && 'promoted' === $mapped->label ) {
1362
+		if (isset($mapped->label) && 'promoted' === $mapped->label) {
1363 1363
 			$product_details_classes .= ' promoted';
1364
-		} elseif ( isset( $mapped->label ) && 'featured' === $mapped->label ) {
1364
+		} elseif (isset($mapped->label) && 'featured' === $mapped->label) {
1365 1365
 			$product_details_classes .= ' featured';
1366 1366
 		}
1367 1367
 
1368
-		if ( 'promoted' === $mapped->label
1369
-			&& ! empty( $mapped->primary_color )
1370
-			&& ! empty( $mapped->text_color )
1371
-			&& ! empty( $mapped->button ) ) {
1368
+		if ('promoted' === $mapped->label
1369
+			&& !empty($mapped->primary_color)
1370
+			&& !empty($mapped->text_color)
1371
+			&& !empty($mapped->button)) {
1372 1372
 			// Promoted product card.
1373 1373
 			?>
1374 1374
 			<li class="product">
1375
-				<div class="<?php echo esc_attr( $product_details_classes ); ?>" style="border-top: 5px  solid <?php echo esc_html( $mapped->primary_color ); ?>;">
1376
-					<span class="label promoted"><?php esc_attr_e( 'Promoted', 'woocommerce' ); ?></span>
1377
-					<a href="<?php echo esc_url( $product_url ); ?>">
1378
-						<h2><?php echo esc_html( $mapped->title ); ?></h2>
1375
+				<div class="<?php echo esc_attr($product_details_classes); ?>" style="border-top: 5px  solid <?php echo esc_html($mapped->primary_color); ?>;">
1376
+					<span class="label promoted"><?php esc_attr_e('Promoted', 'woocommerce'); ?></span>
1377
+					<a href="<?php echo esc_url($product_url); ?>">
1378
+						<h2><?php echo esc_html($mapped->title); ?></h2>
1379 1379
 					</a>
1380
-					<p><?php echo wp_kses_post( $mapped->description ); ?></p>
1380
+					<p><?php echo wp_kses_post($mapped->description); ?></p>
1381 1381
 				</div>
1382 1382
 				<div class="product-footer-promoted">
1383
-					<span class="icon"><img src="<?php echo esc_url( $mapped->icon ); ?>" /></span>
1384
-					<a class="addons-button addons-button-promoted" style="background: <?php echo esc_html( $mapped->primary_color ); ?>; color: <?php echo esc_html( $mapped->text_color ); ?>;" href="<?php echo esc_url( $product_url ); ?>">
1385
-						<?php echo esc_html( $mapped->button ); ?>
1383
+					<span class="icon"><img src="<?php echo esc_url($mapped->icon); ?>" /></span>
1384
+					<a class="addons-button addons-button-promoted" style="background: <?php echo esc_html($mapped->primary_color); ?>; color: <?php echo esc_html($mapped->text_color); ?>;" href="<?php echo esc_url($product_url); ?>">
1385
+						<?php echo esc_html($mapped->button); ?>
1386 1386
 					</a>
1387 1387
 				</div>
1388 1388
 			</li>
@@ -1390,16 +1390,16 @@  discard block
 block discarded – undo
1390 1390
 		} else {
1391 1391
 			// Normal or "featured" product card.
1392 1392
 			?>
1393
-			<li class="<?php echo esc_attr( implode( ' ', $class_names ) ); ?>">
1394
-				<div class="<?php echo esc_attr( $product_details_classes ); ?>">
1393
+			<li class="<?php echo esc_attr(implode(' ', $class_names)); ?>">
1394
+				<div class="<?php echo esc_attr($product_details_classes); ?>">
1395 1395
 					<div class="product-text-container">
1396
-						<?php if ( isset( $mapped->label ) && 'featured' === $mapped->label ) { ?>
1397
-							<span class="label featured"><?php esc_attr_e( 'Featured', 'woocommerce' ); ?></span>
1396
+						<?php if (isset($mapped->label) && 'featured' === $mapped->label) { ?>
1397
+							<span class="label featured"><?php esc_attr_e('Featured', 'woocommerce'); ?></span>
1398 1398
 						<?php } ?>
1399
-						<a href="<?php echo esc_url( $product_url ); ?>">
1400
-							<h2><?php echo esc_html( $mapped->title ); ?></h2>
1399
+						<a href="<?php echo esc_url($product_url); ?>">
1400
+							<h2><?php echo esc_html($mapped->title); ?></h2>
1401 1401
 						</a>
1402
-						<?php if ( ! empty( $mapped->vendor_name ) && ! empty( $mapped->vendor_url ) ) : ?>
1402
+						<?php if (!empty($mapped->vendor_name) && !empty($mapped->vendor_url)) : ?>
1403 1403
 							<div class="product-developed-by">
1404 1404
 								<?php
1405 1405
 								$vendor_url = add_query_arg(
@@ -1414,30 +1414,30 @@  discard block
 block discarded – undo
1414 1414
 
1415 1415
 								printf(
1416 1416
 								/* translators: %s vendor link */
1417
-									esc_html__( 'Developed by %s', 'woocommerce' ),
1417
+									esc_html__('Developed by %s', 'woocommerce'),
1418 1418
 									sprintf(
1419 1419
 										'<a class="product-vendor-link" href="%1$s" target="_blank">%2$s</a>',
1420
-										esc_url_raw( $vendor_url ),
1421
-										esc_html( $mapped->vendor_name )
1420
+										esc_url_raw($vendor_url),
1421
+										esc_html($mapped->vendor_name)
1422 1422
 									)
1423 1423
 								);
1424 1424
 								?>
1425 1425
 							</div>
1426 1426
 						<?php endif; ?>
1427
-						<p><?php echo wp_kses_post( $mapped->description ); ?></p>
1427
+						<p><?php echo wp_kses_post($mapped->description); ?></p>
1428 1428
 					</div>
1429
-					<?php if ( ! empty( $mapped->icon ) ) : ?>
1429
+					<?php if (!empty($mapped->icon)) : ?>
1430 1430
 						<span class="product-img-wrap">
1431 1431
 							<?php /* Show an icon if it exists */ ?>
1432
-							<img src="<?php echo esc_url( $mapped->icon ); ?>" />
1432
+							<img src="<?php echo esc_url($mapped->icon); ?>" />
1433 1433
 						</span>
1434 1434
 					<?php endif; ?>
1435 1435
 				</div>
1436 1436
 				<div class="product-footer">
1437 1437
 					<div class="product-price-and-reviews-container">
1438 1438
 						<div class="product-price-block">
1439
-							<?php if ( $mapped->is_free ) : ?>
1440
-								<span class="price"><?php esc_html_e( 'Free', 'woocommerce' ); ?></span>
1439
+							<?php if ($mapped->is_free) : ?>
1440
+								<span class="price"><?php esc_html_e('Free', 'woocommerce'); ?></span>
1441 1441
 							<?php else : ?>
1442 1442
 								<span class="price">
1443 1443
 									<?php
@@ -1454,28 +1454,28 @@  discard block
 block discarded – undo
1454 1454
 								</span>
1455 1455
 								<span class="price-suffix">
1456 1456
 									<?php
1457
-									$price_suffix = __( 'per year', 'woocommerce' );
1458
-									if ( ! empty( $mapped->price_suffix ) ) {
1457
+									$price_suffix = __('per year', 'woocommerce');
1458
+									if (!empty($mapped->price_suffix)) {
1459 1459
 										$price_suffix = $mapped->price_suffix;
1460 1460
 									}
1461
-									echo esc_html( $price_suffix );
1461
+									echo esc_html($price_suffix);
1462 1462
 									?>
1463 1463
 								</span>
1464 1464
 							<?php endif; ?>
1465 1465
 						</div>
1466
-						<?php if ( ! empty( $mapped->reviews_count ) && ! empty( $mapped->rating ) ) : ?>
1466
+						<?php if (!empty($mapped->reviews_count) && !empty($mapped->rating)) : ?>
1467 1467
 							<?php /* Show rating and the number of reviews */ ?>
1468 1468
 							<div class="product-reviews-block">
1469
-								<?php for ( $index = 1; $index <= 5; ++$index ) : ?>
1470
-									<?php $rating_star_class = 'product-rating-star product-rating-star__' . self::get_star_class( $mapped->rating, $index ); ?>
1471
-									<div class="<?php echo esc_attr( $rating_star_class ); ?>"></div>
1469
+								<?php for ($index = 1; $index <= 5; ++$index) : ?>
1470
+									<?php $rating_star_class = 'product-rating-star product-rating-star__' . self::get_star_class($mapped->rating, $index); ?>
1471
+									<div class="<?php echo esc_attr($rating_star_class); ?>"></div>
1472 1472
 								<?php endfor; ?>
1473 1473
 								<span class="product-reviews-count">(<?php echo (int) $mapped->reviews_count; ?>)</span>
1474 1474
 							</div>
1475 1475
 						<?php endif; ?>
1476 1476
 					</div>
1477
-					<a class="button" href="<?php echo esc_url( $product_url ); ?>">
1478
-						<?php esc_html_e( 'View details', 'woocommerce' ); ?>
1477
+					<a class="button" href="<?php echo esc_url($product_url); ?>">
1478
+						<?php esc_html_e('View details', 'woocommerce'); ?>
1479 1479
 					</a>
1480 1480
 				</div>
1481 1481
 			</li>
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1438,7 +1438,8 @@  discard block
 block discarded – undo
1438 1438
 						<div class="product-price-block">
1439 1439
 							<?php if ( $mapped->is_free ) : ?>
1440 1440
 								<span class="price"><?php esc_html_e( 'Free', 'woocommerce' ); ?></span>
1441
-							<?php else : ?>
1441
+							<?php else {
1442
+    : ?>
1442 1443
 								<span class="price">
1443 1444
 									<?php
1444 1445
 									echo wp_kses(
@@ -1450,6 +1451,7 @@  discard block
 block discarded – undo
1450 1451
 											'bdi'  => array(),
1451 1452
 										)
1452 1453
 									);
1454
+}
1453 1455
 									?>
1454 1456
 								</span>
1455 1457
 								<span class="price-suffix">
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-wc-meta-box-product-short-description.php 2 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -15,23 +15,23 @@
 block discarded – undo
15 15
  */
16 16
 class WC_Meta_Box_Product_Short_Description {
17 17
 
18
-	/**
19
-	 * Output the metabox.
20
-	 *
21
-	 * @param WP_Post $post Post object.
22
-	 */
23
-	public static function output( $post ) {
18
+    /**
19
+     * Output the metabox.
20
+     *
21
+     * @param WP_Post $post Post object.
22
+     */
23
+    public static function output( $post ) {
24 24
 
25
-		$settings = array(
26
-			'textarea_name' => 'excerpt',
27
-			'quicktags'     => array( 'buttons' => 'em,strong,link' ),
28
-			'tinymce'       => array(
29
-				'theme_advanced_buttons1' => 'bold,italic,strikethrough,separator,bullist,numlist,separator,blockquote,separator,justifyleft,justifycenter,justifyright,separator,link,unlink,separator,undo,redo,separator',
30
-				'theme_advanced_buttons2' => '',
31
-			),
32
-			'editor_css'    => '<style>#wp-excerpt-editor-container .wp-editor-area{height:175px; width:100%;}</style>',
33
-		);
25
+        $settings = array(
26
+            'textarea_name' => 'excerpt',
27
+            'quicktags'     => array( 'buttons' => 'em,strong,link' ),
28
+            'tinymce'       => array(
29
+                'theme_advanced_buttons1' => 'bold,italic,strikethrough,separator,bullist,numlist,separator,blockquote,separator,justifyleft,justifycenter,justifyright,separator,link,unlink,separator,undo,redo,separator',
30
+                'theme_advanced_buttons2' => '',
31
+            ),
32
+            'editor_css'    => '<style>#wp-excerpt-editor-container .wp-editor-area{height:175px; width:100%;}</style>',
33
+        );
34 34
 
35
-		wp_editor( htmlspecialchars_decode( $post->post_excerpt, ENT_QUOTES ), 'excerpt', apply_filters( 'woocommerce_product_short_description_editor_settings', $settings ) );
36
-	}
35
+        wp_editor( htmlspecialchars_decode( $post->post_excerpt, ENT_QUOTES ), 'excerpt', apply_filters( 'woocommerce_product_short_description_editor_settings', $settings ) );
36
+    }
37 37
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @version     2.1.0
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 /**
14 14
  * WC_Meta_Box_Product_Short_Description Class.
@@ -20,11 +20,11 @@  discard block
 block discarded – undo
20 20
 	 *
21 21
 	 * @param WP_Post $post Post object.
22 22
 	 */
23
-	public static function output( $post ) {
23
+	public static function output($post) {
24 24
 
25 25
 		$settings = array(
26 26
 			'textarea_name' => 'excerpt',
27
-			'quicktags'     => array( 'buttons' => 'em,strong,link' ),
27
+			'quicktags'     => array('buttons' => 'em,strong,link'),
28 28
 			'tinymce'       => array(
29 29
 				'theme_advanced_buttons1' => 'bold,italic,strikethrough,separator,bullist,numlist,separator,blockquote,separator,justifyleft,justifycenter,justifyright,separator,link,unlink,separator,undo,redo,separator',
30 30
 				'theme_advanced_buttons2' => '',
@@ -32,6 +32,6 @@  discard block
 block discarded – undo
32 32
 			'editor_css'    => '<style>#wp-excerpt-editor-container .wp-editor-area{height:175px; width:100%;}</style>',
33 33
 		);
34 34
 
35
-		wp_editor( htmlspecialchars_decode( $post->post_excerpt, ENT_QUOTES ), 'excerpt', apply_filters( 'woocommerce_product_short_description_editor_settings', $settings ) );
35
+		wp_editor(htmlspecialchars_decode($post->post_excerpt, ENT_QUOTES), 'excerpt', apply_filters('woocommerce_product_short_description_editor_settings', $settings));
36 36
 	}
37 37
 }
Please login to merge, or discard this patch.
woocommerce/includes/admin/meta-boxes/class-wc-meta-box-order-actions.php 2 patches
Indentation   +131 added lines, -131 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  */
10 10
 
11 11
 if ( ! defined( 'ABSPATH' ) ) {
12
-	exit; // Exit if accessed directly.
12
+    exit; // Exit if accessed directly.
13 13
 }
14 14
 
15 15
 /**
@@ -17,23 +17,23 @@  discard block
 block discarded – undo
17 17
  */
18 18
 class WC_Meta_Box_Order_Actions {
19 19
 
20
-	/**
21
-	 * Output the metabox.
22
-	 *
23
-	 * @param WP_Post $post Post object.
24
-	 */
25
-	public static function output( $post ) {
26
-		global $theorder;
27
-
28
-		// This is used by some callbacks attached to hooks such as woocommerce_order_actions which rely on the global to determine if actions should be displayed for certain orders.
29
-		// Avoid using this global with the `woocommerce_order_actions` filter, instead use the $order filter arg.
30
-		if ( ! is_object( $theorder ) ) {
31
-			$theorder = wc_get_order( $post->ID );
32
-		}
33
-
34
-		$theorder = $theorder instanceof WC_Order ? $theorder : null;
35
-		$order_actions = self::get_available_order_actions_for_order( $theorder );
36
-		?>
20
+    /**
21
+     * Output the metabox.
22
+     *
23
+     * @param WP_Post $post Post object.
24
+     */
25
+    public static function output( $post ) {
26
+        global $theorder;
27
+
28
+        // This is used by some callbacks attached to hooks such as woocommerce_order_actions which rely on the global to determine if actions should be displayed for certain orders.
29
+        // Avoid using this global with the `woocommerce_order_actions` filter, instead use the $order filter arg.
30
+        if ( ! is_object( $theorder ) ) {
31
+            $theorder = wc_get_order( $post->ID );
32
+        }
33
+
34
+        $theorder = $theorder instanceof WC_Order ? $theorder : null;
35
+        $order_actions = self::get_available_order_actions_for_order( $theorder );
36
+        ?>
37 37
 		<ul class="order_actions submitbox">
38 38
 
39 39
 			<?php do_action( 'woocommerce_order_actions_start', $post->ID ); ?>
@@ -51,18 +51,18 @@  discard block
 block discarded – undo
51 51
 			<li class="wide">
52 52
 				<div id="delete-action">
53 53
 					<?php
54
-					if ( current_user_can( 'delete_post', $post->ID ) ) {
55
-
56
-						if ( ! EMPTY_TRASH_DAYS ) {
57
-							$delete_text = __( 'Delete permanently', 'woocommerce' );
58
-						} else {
59
-							$delete_text = __( 'Move to Trash', 'woocommerce' );
60
-						}
61
-						?>
54
+                    if ( current_user_can( 'delete_post', $post->ID ) ) {
55
+
56
+                        if ( ! EMPTY_TRASH_DAYS ) {
57
+                            $delete_text = __( 'Delete permanently', 'woocommerce' );
58
+                        } else {
59
+                            $delete_text = __( 'Move to Trash', 'woocommerce' );
60
+                        }
61
+                        ?>
62 62
 						<a class="submitdelete deletion" href="<?php echo esc_url( get_delete_post_link( $post->ID ) ); ?>"><?php echo esc_html( $delete_text ); ?></a>
63 63
 						<?php
64
-					}
65
-					?>
64
+                    }
65
+                    ?>
66 66
 				</div>
67 67
 
68 68
 				<button type="submit" class="button save_order button-primary" name="save" value="<?php echo 'auto-draft' === $post->post_status ? esc_attr__( 'Create', 'woocommerce' ) : esc_attr__( 'Update', 'woocommerce' ); ?>"><?php echo 'auto-draft' === $post->post_status ? esc_html__( 'Create', 'woocommerce' ) : esc_html__( 'Update', 'woocommerce' ); ?></button>
@@ -72,107 +72,107 @@  discard block
 block discarded – undo
72 72
 
73 73
 		</ul>
74 74
 		<?php
75
-	}
76
-
77
-	/**
78
-	 * Save meta box data.
79
-	 *
80
-	 * @param int     $post_id Post ID.
81
-	 * @param WP_Post $post Post Object.
82
-	 */
83
-	public static function save( $post_id, $post ) {
84
-		// Order data saved, now get it so we can manipulate status.
85
-		$order = wc_get_order( $post_id );
86
-
87
-		// Handle button actions.
88
-		if ( ! empty( $_POST['wc_order_action'] ) ) { // @codingStandardsIgnoreLine
89
-
90
-			$action = wc_clean( wp_unslash( $_POST['wc_order_action'] ) ); // @codingStandardsIgnoreLine
91
-
92
-			if ( 'send_order_details' === $action ) {
93
-				do_action( 'woocommerce_before_resend_order_emails', $order, 'customer_invoice' );
94
-
95
-				// Send the customer invoice email.
96
-				WC()->payment_gateways();
97
-				WC()->shipping();
98
-				WC()->mailer()->customer_invoice( $order );
99
-
100
-				// Note the event.
101
-				$order->add_order_note( __( 'Order details manually sent to customer.', 'woocommerce' ), false, true );
102
-
103
-				do_action( 'woocommerce_after_resend_order_email', $order, 'customer_invoice' );
104
-
105
-				// Change the post saved message.
106
-				add_filter( 'redirect_post_location', array( __CLASS__, 'set_email_sent_message' ) );
107
-
108
-			} elseif ( 'send_order_details_admin' === $action ) {
109
-
110
-				do_action( 'woocommerce_before_resend_order_emails', $order, 'new_order' );
111
-
112
-				WC()->payment_gateways();
113
-				WC()->shipping();
114
-				add_filter( 'woocommerce_new_order_email_allows_resend', '__return_true' );
115
-				WC()->mailer()->emails['WC_Email_New_Order']->trigger( $order->get_id(), $order, true );
116
-				remove_filter( 'woocommerce_new_order_email_allows_resend', '__return_true' );
117
-
118
-				do_action( 'woocommerce_after_resend_order_email', $order, 'new_order' );
119
-
120
-				// Change the post saved message.
121
-				add_filter( 'redirect_post_location', array( __CLASS__, 'set_email_sent_message' ) );
122
-
123
-			} elseif ( 'regenerate_download_permissions' === $action ) {
124
-
125
-				$data_store = WC_Data_Store::load( 'customer-download' );
126
-				$data_store->delete_by_order_id( $post_id );
127
-				wc_downloadable_product_permissions( $post_id, true );
128
-
129
-			} else {
130
-
131
-				if ( ! did_action( 'woocommerce_order_action_' . sanitize_title( $action ) ) ) {
132
-					do_action( 'woocommerce_order_action_' . sanitize_title( $action ), $order );
133
-				}
134
-			}
135
-		}
136
-	}
137
-
138
-	/**
139
-	 * Set the correct message ID.
140
-	 *
141
-	 * @param string $location Location.
142
-	 * @since  2.3.0
143
-	 * @static
144
-	 * @return string
145
-	 */
146
-	public static function set_email_sent_message( $location ) {
147
-		return add_query_arg( 'message', 11, $location );
148
-	}
149
-
150
-	/**
151
-	 * Get the available order actions for a given order.
152
-	 *
153
-	 * @since 5.8.0
154
-	 *
155
-	 * @param WC_Order|null $order The order object or null if no order is available.
156
-	 *
157
-	 * @return array
158
-	 */
159
-	private static function get_available_order_actions_for_order( $order ) {
160
-		$actions = array(
161
-			'send_order_details'              => __( 'Email invoice / order details to customer', 'woocommerce' ),
162
-			'send_order_details_admin'        => __( 'Resend new order notification', 'woocommerce' ),
163
-			'regenerate_download_permissions' => __( 'Regenerate download permissions', 'woocommerce' ),
164
-		);
165
-
166
-		/**
167
-		 * Filter: woocommerce_order_actions
168
-		 * Allows filtering of the available order actions for an order.
169
-		 *
170
-		 * @since 2.1.0 Filter was added.
171
-		 * @since 5.8.0 The $order param was added.
172
-		 *
173
-		 * @param array         $actions The available order actions for the order.
174
-		 * @param WC_Order|null $order   The order object or null if no order is available.
175
-		 */
176
-		return apply_filters( 'woocommerce_order_actions', $actions, $order );
177
-	}
75
+    }
76
+
77
+    /**
78
+     * Save meta box data.
79
+     *
80
+     * @param int     $post_id Post ID.
81
+     * @param WP_Post $post Post Object.
82
+     */
83
+    public static function save( $post_id, $post ) {
84
+        // Order data saved, now get it so we can manipulate status.
85
+        $order = wc_get_order( $post_id );
86
+
87
+        // Handle button actions.
88
+        if ( ! empty( $_POST['wc_order_action'] ) ) { // @codingStandardsIgnoreLine
89
+
90
+            $action = wc_clean( wp_unslash( $_POST['wc_order_action'] ) ); // @codingStandardsIgnoreLine
91
+
92
+            if ( 'send_order_details' === $action ) {
93
+                do_action( 'woocommerce_before_resend_order_emails', $order, 'customer_invoice' );
94
+
95
+                // Send the customer invoice email.
96
+                WC()->payment_gateways();
97
+                WC()->shipping();
98
+                WC()->mailer()->customer_invoice( $order );
99
+
100
+                // Note the event.
101
+                $order->add_order_note( __( 'Order details manually sent to customer.', 'woocommerce' ), false, true );
102
+
103
+                do_action( 'woocommerce_after_resend_order_email', $order, 'customer_invoice' );
104
+
105
+                // Change the post saved message.
106
+                add_filter( 'redirect_post_location', array( __CLASS__, 'set_email_sent_message' ) );
107
+
108
+            } elseif ( 'send_order_details_admin' === $action ) {
109
+
110
+                do_action( 'woocommerce_before_resend_order_emails', $order, 'new_order' );
111
+
112
+                WC()->payment_gateways();
113
+                WC()->shipping();
114
+                add_filter( 'woocommerce_new_order_email_allows_resend', '__return_true' );
115
+                WC()->mailer()->emails['WC_Email_New_Order']->trigger( $order->get_id(), $order, true );
116
+                remove_filter( 'woocommerce_new_order_email_allows_resend', '__return_true' );
117
+
118
+                do_action( 'woocommerce_after_resend_order_email', $order, 'new_order' );
119
+
120
+                // Change the post saved message.
121
+                add_filter( 'redirect_post_location', array( __CLASS__, 'set_email_sent_message' ) );
122
+
123
+            } elseif ( 'regenerate_download_permissions' === $action ) {
124
+
125
+                $data_store = WC_Data_Store::load( 'customer-download' );
126
+                $data_store->delete_by_order_id( $post_id );
127
+                wc_downloadable_product_permissions( $post_id, true );
128
+
129
+            } else {
130
+
131
+                if ( ! did_action( 'woocommerce_order_action_' . sanitize_title( $action ) ) ) {
132
+                    do_action( 'woocommerce_order_action_' . sanitize_title( $action ), $order );
133
+                }
134
+            }
135
+        }
136
+    }
137
+
138
+    /**
139
+     * Set the correct message ID.
140
+     *
141
+     * @param string $location Location.
142
+     * @since  2.3.0
143
+     * @static
144
+     * @return string
145
+     */
146
+    public static function set_email_sent_message( $location ) {
147
+        return add_query_arg( 'message', 11, $location );
148
+    }
149
+
150
+    /**
151
+     * Get the available order actions for a given order.
152
+     *
153
+     * @since 5.8.0
154
+     *
155
+     * @param WC_Order|null $order The order object or null if no order is available.
156
+     *
157
+     * @return array
158
+     */
159
+    private static function get_available_order_actions_for_order( $order ) {
160
+        $actions = array(
161
+            'send_order_details'              => __( 'Email invoice / order details to customer', 'woocommerce' ),
162
+            'send_order_details_admin'        => __( 'Resend new order notification', 'woocommerce' ),
163
+            'regenerate_download_permissions' => __( 'Regenerate download permissions', 'woocommerce' ),
164
+        );
165
+
166
+        /**
167
+         * Filter: woocommerce_order_actions
168
+         * Allows filtering of the available order actions for an order.
169
+         *
170
+         * @since 2.1.0 Filter was added.
171
+         * @since 5.8.0 The $order param was added.
172
+         *
173
+         * @param array         $actions The available order actions for the order.
174
+         * @param WC_Order|null $order   The order object or null if no order is available.
175
+         */
176
+        return apply_filters( 'woocommerce_order_actions', $actions, $order );
177
+    }
178 178
 }
Please login to merge, or discard this patch.
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @version     2.1.0
9 9
  */
10 10
 
11
-if ( ! defined( 'ABSPATH' ) ) {
11
+if (!defined('ABSPATH')) {
12 12
 	exit; // Exit if accessed directly.
13 13
 }
14 14
 
@@ -22,53 +22,53 @@  discard block
 block discarded – undo
22 22
 	 *
23 23
 	 * @param WP_Post $post Post object.
24 24
 	 */
25
-	public static function output( $post ) {
25
+	public static function output($post) {
26 26
 		global $theorder;
27 27
 
28 28
 		// This is used by some callbacks attached to hooks such as woocommerce_order_actions which rely on the global to determine if actions should be displayed for certain orders.
29 29
 		// Avoid using this global with the `woocommerce_order_actions` filter, instead use the $order filter arg.
30
-		if ( ! is_object( $theorder ) ) {
31
-			$theorder = wc_get_order( $post->ID );
30
+		if (!is_object($theorder)) {
31
+			$theorder = wc_get_order($post->ID);
32 32
 		}
33 33
 
34 34
 		$theorder = $theorder instanceof WC_Order ? $theorder : null;
35
-		$order_actions = self::get_available_order_actions_for_order( $theorder );
35
+		$order_actions = self::get_available_order_actions_for_order($theorder);
36 36
 		?>
37 37
 		<ul class="order_actions submitbox">
38 38
 
39
-			<?php do_action( 'woocommerce_order_actions_start', $post->ID ); ?>
39
+			<?php do_action('woocommerce_order_actions_start', $post->ID); ?>
40 40
 
41 41
 			<li class="wide" id="actions">
42 42
 				<select name="wc_order_action">
43
-					<option value=""><?php esc_html_e( 'Choose an action...', 'woocommerce' ); ?></option>
44
-					<?php foreach ( $order_actions as $action => $title ) { ?>
45
-						<option value="<?php echo esc_attr( $action ); ?>"><?php echo esc_html( $title ); ?></option>
43
+					<option value=""><?php esc_html_e('Choose an action...', 'woocommerce'); ?></option>
44
+					<?php foreach ($order_actions as $action => $title) { ?>
45
+						<option value="<?php echo esc_attr($action); ?>"><?php echo esc_html($title); ?></option>
46 46
 					<?php } ?>
47 47
 				</select>
48
-				<button class="button wc-reload"><span><?php esc_html_e( 'Apply', 'woocommerce' ); ?></span></button>
48
+				<button class="button wc-reload"><span><?php esc_html_e('Apply', 'woocommerce'); ?></span></button>
49 49
 			</li>
50 50
 
51 51
 			<li class="wide">
52 52
 				<div id="delete-action">
53 53
 					<?php
54
-					if ( current_user_can( 'delete_post', $post->ID ) ) {
54
+					if (current_user_can('delete_post', $post->ID)) {
55 55
 
56
-						if ( ! EMPTY_TRASH_DAYS ) {
57
-							$delete_text = __( 'Delete permanently', 'woocommerce' );
56
+						if (!EMPTY_TRASH_DAYS) {
57
+							$delete_text = __('Delete permanently', 'woocommerce');
58 58
 						} else {
59
-							$delete_text = __( 'Move to Trash', 'woocommerce' );
59
+							$delete_text = __('Move to Trash', 'woocommerce');
60 60
 						}
61 61
 						?>
62
-						<a class="submitdelete deletion" href="<?php echo esc_url( get_delete_post_link( $post->ID ) ); ?>"><?php echo esc_html( $delete_text ); ?></a>
62
+						<a class="submitdelete deletion" href="<?php echo esc_url(get_delete_post_link($post->ID)); ?>"><?php echo esc_html($delete_text); ?></a>
63 63
 						<?php
64 64
 					}
65 65
 					?>
66 66
 				</div>
67 67
 
68
-				<button type="submit" class="button save_order button-primary" name="save" value="<?php echo 'auto-draft' === $post->post_status ? esc_attr__( 'Create', 'woocommerce' ) : esc_attr__( 'Update', 'woocommerce' ); ?>"><?php echo 'auto-draft' === $post->post_status ? esc_html__( 'Create', 'woocommerce' ) : esc_html__( 'Update', 'woocommerce' ); ?></button>
68
+				<button type="submit" class="button save_order button-primary" name="save" value="<?php echo 'auto-draft' === $post->post_status ? esc_attr__('Create', 'woocommerce') : esc_attr__('Update', 'woocommerce'); ?>"><?php echo 'auto-draft' === $post->post_status ? esc_html__('Create', 'woocommerce') : esc_html__('Update', 'woocommerce'); ?></button>
69 69
 			</li>
70 70
 
71
-			<?php do_action( 'woocommerce_order_actions_end', $post->ID ); ?>
71
+			<?php do_action('woocommerce_order_actions_end', $post->ID); ?>
72 72
 
73 73
 		</ul>
74 74
 		<?php
@@ -80,56 +80,56 @@  discard block
 block discarded – undo
80 80
 	 * @param int     $post_id Post ID.
81 81
 	 * @param WP_Post $post Post Object.
82 82
 	 */
83
-	public static function save( $post_id, $post ) {
83
+	public static function save($post_id, $post) {
84 84
 		// Order data saved, now get it so we can manipulate status.
85
-		$order = wc_get_order( $post_id );
85
+		$order = wc_get_order($post_id);
86 86
 
87 87
 		// Handle button actions.
88
-		if ( ! empty( $_POST['wc_order_action'] ) ) { // @codingStandardsIgnoreLine
88
+		if (!empty($_POST['wc_order_action'])) { // @codingStandardsIgnoreLine
89 89
 
90
-			$action = wc_clean( wp_unslash( $_POST['wc_order_action'] ) ); // @codingStandardsIgnoreLine
90
+			$action = wc_clean(wp_unslash($_POST['wc_order_action'])); // @codingStandardsIgnoreLine
91 91
 
92
-			if ( 'send_order_details' === $action ) {
93
-				do_action( 'woocommerce_before_resend_order_emails', $order, 'customer_invoice' );
92
+			if ('send_order_details' === $action) {
93
+				do_action('woocommerce_before_resend_order_emails', $order, 'customer_invoice');
94 94
 
95 95
 				// Send the customer invoice email.
96 96
 				WC()->payment_gateways();
97 97
 				WC()->shipping();
98
-				WC()->mailer()->customer_invoice( $order );
98
+				WC()->mailer()->customer_invoice($order);
99 99
 
100 100
 				// Note the event.
101
-				$order->add_order_note( __( 'Order details manually sent to customer.', 'woocommerce' ), false, true );
101
+				$order->add_order_note(__('Order details manually sent to customer.', 'woocommerce'), false, true);
102 102
 
103
-				do_action( 'woocommerce_after_resend_order_email', $order, 'customer_invoice' );
103
+				do_action('woocommerce_after_resend_order_email', $order, 'customer_invoice');
104 104
 
105 105
 				// Change the post saved message.
106
-				add_filter( 'redirect_post_location', array( __CLASS__, 'set_email_sent_message' ) );
106
+				add_filter('redirect_post_location', array(__CLASS__, 'set_email_sent_message'));
107 107
 
108
-			} elseif ( 'send_order_details_admin' === $action ) {
108
+			} elseif ('send_order_details_admin' === $action) {
109 109
 
110
-				do_action( 'woocommerce_before_resend_order_emails', $order, 'new_order' );
110
+				do_action('woocommerce_before_resend_order_emails', $order, 'new_order');
111 111
 
112 112
 				WC()->payment_gateways();
113 113
 				WC()->shipping();
114
-				add_filter( 'woocommerce_new_order_email_allows_resend', '__return_true' );
115
-				WC()->mailer()->emails['WC_Email_New_Order']->trigger( $order->get_id(), $order, true );
116
-				remove_filter( 'woocommerce_new_order_email_allows_resend', '__return_true' );
114
+				add_filter('woocommerce_new_order_email_allows_resend', '__return_true');
115
+				WC()->mailer()->emails['WC_Email_New_Order']->trigger($order->get_id(), $order, true);
116
+				remove_filter('woocommerce_new_order_email_allows_resend', '__return_true');
117 117
 
118
-				do_action( 'woocommerce_after_resend_order_email', $order, 'new_order' );
118
+				do_action('woocommerce_after_resend_order_email', $order, 'new_order');
119 119
 
120 120
 				// Change the post saved message.
121
-				add_filter( 'redirect_post_location', array( __CLASS__, 'set_email_sent_message' ) );
121
+				add_filter('redirect_post_location', array(__CLASS__, 'set_email_sent_message'));
122 122
 
123
-			} elseif ( 'regenerate_download_permissions' === $action ) {
123
+			} elseif ('regenerate_download_permissions' === $action) {
124 124
 
125
-				$data_store = WC_Data_Store::load( 'customer-download' );
126
-				$data_store->delete_by_order_id( $post_id );
127
-				wc_downloadable_product_permissions( $post_id, true );
125
+				$data_store = WC_Data_Store::load('customer-download');
126
+				$data_store->delete_by_order_id($post_id);
127
+				wc_downloadable_product_permissions($post_id, true);
128 128
 
129 129
 			} else {
130 130
 
131
-				if ( ! did_action( 'woocommerce_order_action_' . sanitize_title( $action ) ) ) {
132
-					do_action( 'woocommerce_order_action_' . sanitize_title( $action ), $order );
131
+				if (!did_action('woocommerce_order_action_' . sanitize_title($action))) {
132
+					do_action('woocommerce_order_action_' . sanitize_title($action), $order);
133 133
 				}
134 134
 			}
135 135
 		}
@@ -143,8 +143,8 @@  discard block
 block discarded – undo
143 143
 	 * @static
144 144
 	 * @return string
145 145
 	 */
146
-	public static function set_email_sent_message( $location ) {
147
-		return add_query_arg( 'message', 11, $location );
146
+	public static function set_email_sent_message($location) {
147
+		return add_query_arg('message', 11, $location);
148 148
 	}
149 149
 
150 150
 	/**
@@ -156,11 +156,11 @@  discard block
 block discarded – undo
156 156
 	 *
157 157
 	 * @return array
158 158
 	 */
159
-	private static function get_available_order_actions_for_order( $order ) {
159
+	private static function get_available_order_actions_for_order($order) {
160 160
 		$actions = array(
161
-			'send_order_details'              => __( 'Email invoice / order details to customer', 'woocommerce' ),
162
-			'send_order_details_admin'        => __( 'Resend new order notification', 'woocommerce' ),
163
-			'regenerate_download_permissions' => __( 'Regenerate download permissions', 'woocommerce' ),
161
+			'send_order_details'              => __('Email invoice / order details to customer', 'woocommerce'),
162
+			'send_order_details_admin'        => __('Resend new order notification', 'woocommerce'),
163
+			'regenerate_download_permissions' => __('Regenerate download permissions', 'woocommerce'),
164 164
 		);
165 165
 
166 166
 		/**
@@ -173,6 +173,6 @@  discard block
 block discarded – undo
173 173
 		 * @param array         $actions The available order actions for the order.
174 174
 		 * @param WC_Order|null $order   The order object or null if no order is available.
175 175
 		 */
176
-		return apply_filters( 'woocommerce_order_actions', $actions, $order );
176
+		return apply_filters('woocommerce_order_actions', $actions, $order);
177 177
 	}
178 178
 }
Please login to merge, or discard this patch.
woocommerce/includes/admin/meta-boxes/class-wc-meta-box-order-data.php 2 patches
Indentation   +505 added lines, -505 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 if ( ! defined( 'ABSPATH' ) ) {
14
-	exit; // Exit if accessed directly
14
+    exit; // Exit if accessed directly
15 15
 }
16 16
 
17 17
 /**
@@ -19,154 +19,154 @@  discard block
 block discarded – undo
19 19
  */
20 20
 class WC_Meta_Box_Order_Data {
21 21
 
22
-	/**
23
-	 * Billing fields.
24
-	 *
25
-	 * @var array
26
-	 */
27
-	protected static $billing_fields = array();
28
-
29
-	/**
30
-	 * Shipping fields.
31
-	 *
32
-	 * @var array
33
-	 */
34
-	protected static $shipping_fields = array();
35
-
36
-	/**
37
-	 * Init billing and shipping fields we display + save.
38
-	 */
39
-	public static function init_address_fields() {
40
-
41
-		self::$billing_fields = apply_filters(
42
-			'woocommerce_admin_billing_fields',
43
-			array(
44
-				'first_name' => array(
45
-					'label' => __( 'First name', 'woocommerce' ),
46
-					'show'  => false,
47
-				),
48
-				'last_name'  => array(
49
-					'label' => __( 'Last name', 'woocommerce' ),
50
-					'show'  => false,
51
-				),
52
-				'company'    => array(
53
-					'label' => __( 'Company', 'woocommerce' ),
54
-					'show'  => false,
55
-				),
56
-				'address_1'  => array(
57
-					'label' => __( 'Address line 1', 'woocommerce' ),
58
-					'show'  => false,
59
-				),
60
-				'address_2'  => array(
61
-					'label' => __( 'Address line 2', 'woocommerce' ),
62
-					'show'  => false,
63
-				),
64
-				'city'       => array(
65
-					'label' => __( 'City', 'woocommerce' ),
66
-					'show'  => false,
67
-				),
68
-				'postcode'   => array(
69
-					'label' => __( 'Postcode / ZIP', 'woocommerce' ),
70
-					'show'  => false,
71
-				),
72
-				'country'    => array(
73
-					'label'   => __( 'Country / Region', 'woocommerce' ),
74
-					'show'    => false,
75
-					'class'   => 'js_field-country select short',
76
-					'type'    => 'select',
77
-					'options' => array( '' => __( 'Select a country / region&hellip;', 'woocommerce' ) ) + WC()->countries->get_allowed_countries(),
78
-				),
79
-				'state'      => array(
80
-					'label' => __( 'State / County', 'woocommerce' ),
81
-					'class' => 'js_field-state select short',
82
-					'show'  => false,
83
-				),
84
-				'email'      => array(
85
-					'label' => __( 'Email address', 'woocommerce' ),
86
-				),
87
-				'phone'      => array(
88
-					'label' => __( 'Phone', 'woocommerce' ),
89
-				),
90
-			)
91
-		);
92
-
93
-		self::$shipping_fields = apply_filters(
94
-			'woocommerce_admin_shipping_fields',
95
-			array(
96
-				'first_name' => array(
97
-					'label' => __( 'First name', 'woocommerce' ),
98
-					'show'  => false,
99
-				),
100
-				'last_name'  => array(
101
-					'label' => __( 'Last name', 'woocommerce' ),
102
-					'show'  => false,
103
-				),
104
-				'company'    => array(
105
-					'label' => __( 'Company', 'woocommerce' ),
106
-					'show'  => false,
107
-				),
108
-				'address_1'  => array(
109
-					'label' => __( 'Address line 1', 'woocommerce' ),
110
-					'show'  => false,
111
-				),
112
-				'address_2'  => array(
113
-					'label' => __( 'Address line 2', 'woocommerce' ),
114
-					'show'  => false,
115
-				),
116
-				'city'       => array(
117
-					'label' => __( 'City', 'woocommerce' ),
118
-					'show'  => false,
119
-				),
120
-				'postcode'   => array(
121
-					'label' => __( 'Postcode / ZIP', 'woocommerce' ),
122
-					'show'  => false,
123
-				),
124
-				'country'    => array(
125
-					'label'   => __( 'Country / Region', 'woocommerce' ),
126
-					'show'    => false,
127
-					'type'    => 'select',
128
-					'class'   => 'js_field-country select short',
129
-					'options' => array( '' => __( 'Select a country / region&hellip;', 'woocommerce' ) ) + WC()->countries->get_shipping_countries(),
130
-				),
131
-				'state'      => array(
132
-					'label' => __( 'State / County', 'woocommerce' ),
133
-					'class' => 'js_field-state select short',
134
-					'show'  => false,
135
-				),
136
-				'phone'      => array(
137
-					'label' => __( 'Phone', 'woocommerce' ),
138
-				),
139
-			)
140
-		);
141
-	}
142
-
143
-	/**
144
-	 * Output the metabox.
145
-	 *
146
-	 * @param WP_Post $post
147
-	 */
148
-	public static function output( $post ) {
149
-		global $theorder;
150
-
151
-		if ( ! is_object( $theorder ) ) {
152
-			$theorder = wc_get_order( $post->ID );
153
-		}
154
-
155
-		$order = $theorder;
156
-
157
-		self::init_address_fields();
158
-
159
-		if ( WC()->payment_gateways() ) {
160
-			$payment_gateways = WC()->payment_gateways->payment_gateways();
161
-		} else {
162
-			$payment_gateways = array();
163
-		}
164
-
165
-		$payment_method = $order->get_payment_method();
166
-
167
-		$order_type_object = get_post_type_object( $post->post_type );
168
-		wp_nonce_field( 'woocommerce_save_data', 'woocommerce_meta_nonce' );
169
-		?>
22
+    /**
23
+     * Billing fields.
24
+     *
25
+     * @var array
26
+     */
27
+    protected static $billing_fields = array();
28
+
29
+    /**
30
+     * Shipping fields.
31
+     *
32
+     * @var array
33
+     */
34
+    protected static $shipping_fields = array();
35
+
36
+    /**
37
+     * Init billing and shipping fields we display + save.
38
+     */
39
+    public static function init_address_fields() {
40
+
41
+        self::$billing_fields = apply_filters(
42
+            'woocommerce_admin_billing_fields',
43
+            array(
44
+                'first_name' => array(
45
+                    'label' => __( 'First name', 'woocommerce' ),
46
+                    'show'  => false,
47
+                ),
48
+                'last_name'  => array(
49
+                    'label' => __( 'Last name', 'woocommerce' ),
50
+                    'show'  => false,
51
+                ),
52
+                'company'    => array(
53
+                    'label' => __( 'Company', 'woocommerce' ),
54
+                    'show'  => false,
55
+                ),
56
+                'address_1'  => array(
57
+                    'label' => __( 'Address line 1', 'woocommerce' ),
58
+                    'show'  => false,
59
+                ),
60
+                'address_2'  => array(
61
+                    'label' => __( 'Address line 2', 'woocommerce' ),
62
+                    'show'  => false,
63
+                ),
64
+                'city'       => array(
65
+                    'label' => __( 'City', 'woocommerce' ),
66
+                    'show'  => false,
67
+                ),
68
+                'postcode'   => array(
69
+                    'label' => __( 'Postcode / ZIP', 'woocommerce' ),
70
+                    'show'  => false,
71
+                ),
72
+                'country'    => array(
73
+                    'label'   => __( 'Country / Region', 'woocommerce' ),
74
+                    'show'    => false,
75
+                    'class'   => 'js_field-country select short',
76
+                    'type'    => 'select',
77
+                    'options' => array( '' => __( 'Select a country / region&hellip;', 'woocommerce' ) ) + WC()->countries->get_allowed_countries(),
78
+                ),
79
+                'state'      => array(
80
+                    'label' => __( 'State / County', 'woocommerce' ),
81
+                    'class' => 'js_field-state select short',
82
+                    'show'  => false,
83
+                ),
84
+                'email'      => array(
85
+                    'label' => __( 'Email address', 'woocommerce' ),
86
+                ),
87
+                'phone'      => array(
88
+                    'label' => __( 'Phone', 'woocommerce' ),
89
+                ),
90
+            )
91
+        );
92
+
93
+        self::$shipping_fields = apply_filters(
94
+            'woocommerce_admin_shipping_fields',
95
+            array(
96
+                'first_name' => array(
97
+                    'label' => __( 'First name', 'woocommerce' ),
98
+                    'show'  => false,
99
+                ),
100
+                'last_name'  => array(
101
+                    'label' => __( 'Last name', 'woocommerce' ),
102
+                    'show'  => false,
103
+                ),
104
+                'company'    => array(
105
+                    'label' => __( 'Company', 'woocommerce' ),
106
+                    'show'  => false,
107
+                ),
108
+                'address_1'  => array(
109
+                    'label' => __( 'Address line 1', 'woocommerce' ),
110
+                    'show'  => false,
111
+                ),
112
+                'address_2'  => array(
113
+                    'label' => __( 'Address line 2', 'woocommerce' ),
114
+                    'show'  => false,
115
+                ),
116
+                'city'       => array(
117
+                    'label' => __( 'City', 'woocommerce' ),
118
+                    'show'  => false,
119
+                ),
120
+                'postcode'   => array(
121
+                    'label' => __( 'Postcode / ZIP', 'woocommerce' ),
122
+                    'show'  => false,
123
+                ),
124
+                'country'    => array(
125
+                    'label'   => __( 'Country / Region', 'woocommerce' ),
126
+                    'show'    => false,
127
+                    'type'    => 'select',
128
+                    'class'   => 'js_field-country select short',
129
+                    'options' => array( '' => __( 'Select a country / region&hellip;', 'woocommerce' ) ) + WC()->countries->get_shipping_countries(),
130
+                ),
131
+                'state'      => array(
132
+                    'label' => __( 'State / County', 'woocommerce' ),
133
+                    'class' => 'js_field-state select short',
134
+                    'show'  => false,
135
+                ),
136
+                'phone'      => array(
137
+                    'label' => __( 'Phone', 'woocommerce' ),
138
+                ),
139
+            )
140
+        );
141
+    }
142
+
143
+    /**
144
+     * Output the metabox.
145
+     *
146
+     * @param WP_Post $post
147
+     */
148
+    public static function output( $post ) {
149
+        global $theorder;
150
+
151
+        if ( ! is_object( $theorder ) ) {
152
+            $theorder = wc_get_order( $post->ID );
153
+        }
154
+
155
+        $order = $theorder;
156
+
157
+        self::init_address_fields();
158
+
159
+        if ( WC()->payment_gateways() ) {
160
+            $payment_gateways = WC()->payment_gateways->payment_gateways();
161
+        } else {
162
+            $payment_gateways = array();
163
+        }
164
+
165
+        $payment_method = $order->get_payment_method();
166
+
167
+        $order_type_object = get_post_type_object( $post->post_type );
168
+        wp_nonce_field( 'woocommerce_save_data', 'woocommerce_meta_nonce' );
169
+        ?>
170 170
 		<style type="text/css">
171 171
 			#post-body-content, #titlediv { display:none }
172 172
 		</style>
@@ -177,58 +177,58 @@  discard block
 block discarded – undo
177 177
 				<h2 class="woocommerce-order-data__heading">
178 178
 					<?php
179 179
 
180
-					/* translators: 1: order type 2: order number */
181
-					printf(
182
-						esc_html__( '%1$s #%2$s details', 'woocommerce' ),
183
-						esc_html( $order_type_object->labels->singular_name ),
184
-						esc_html( $order->get_order_number() )
185
-					);
180
+                    /* translators: 1: order type 2: order number */
181
+                    printf(
182
+                        esc_html__( '%1$s #%2$s details', 'woocommerce' ),
183
+                        esc_html( $order_type_object->labels->singular_name ),
184
+                        esc_html( $order->get_order_number() )
185
+                    );
186 186
 
187
-					?>
187
+                    ?>
188 188
 				</h2>
189 189
 				<p class="woocommerce-order-data__meta order_number">
190 190
 					<?php
191 191
 
192
-					$meta_list = array();
193
-
194
-					if ( $payment_method && 'other' !== $payment_method ) {
195
-						/* translators: %s: payment method */
196
-						$payment_method_string = sprintf(
197
-							__( 'Payment via %s', 'woocommerce' ),
198
-							esc_html( isset( $payment_gateways[ $payment_method ] ) ? $payment_gateways[ $payment_method ]->get_title() : $payment_method )
199
-						);
200
-
201
-						if ( $transaction_id = $order->get_transaction_id() ) {
202
-							if ( isset( $payment_gateways[ $payment_method ] ) && ( $url = $payment_gateways[ $payment_method ]->get_transaction_url( $order ) ) ) {
203
-								$payment_method_string .= ' (<a href="' . esc_url( $url ) . '" target="_blank">' . esc_html( $transaction_id ) . '</a>)';
204
-							} else {
205
-								$payment_method_string .= ' (' . esc_html( $transaction_id ) . ')';
206
-							}
207
-						}
208
-
209
-						$meta_list[] = $payment_method_string;
210
-					}
211
-
212
-					if ( $order->get_date_paid() ) {
213
-						/* translators: 1: date 2: time */
214
-						$meta_list[] = sprintf(
215
-							__( 'Paid on %1$s @ %2$s', 'woocommerce' ),
216
-							wc_format_datetime( $order->get_date_paid() ),
217
-							wc_format_datetime( $order->get_date_paid(), get_option( 'time_format' ) )
218
-						);
219
-					}
220
-
221
-					if ( $ip_address = $order->get_customer_ip_address() ) {
222
-						/* translators: %s: IP address */
223
-						$meta_list[] = sprintf(
224
-							__( 'Customer IP: %s', 'woocommerce' ),
225
-							'<span class="woocommerce-Order-customerIP">' . esc_html( $ip_address ) . '</span>'
226
-						);
227
-					}
228
-
229
-					echo wp_kses_post( implode( '. ', $meta_list ) );
230
-
231
-					?>
192
+                    $meta_list = array();
193
+
194
+                    if ( $payment_method && 'other' !== $payment_method ) {
195
+                        /* translators: %s: payment method */
196
+                        $payment_method_string = sprintf(
197
+                            __( 'Payment via %s', 'woocommerce' ),
198
+                            esc_html( isset( $payment_gateways[ $payment_method ] ) ? $payment_gateways[ $payment_method ]->get_title() : $payment_method )
199
+                        );
200
+
201
+                        if ( $transaction_id = $order->get_transaction_id() ) {
202
+                            if ( isset( $payment_gateways[ $payment_method ] ) && ( $url = $payment_gateways[ $payment_method ]->get_transaction_url( $order ) ) ) {
203
+                                $payment_method_string .= ' (<a href="' . esc_url( $url ) . '" target="_blank">' . esc_html( $transaction_id ) . '</a>)';
204
+                            } else {
205
+                                $payment_method_string .= ' (' . esc_html( $transaction_id ) . ')';
206
+                            }
207
+                        }
208
+
209
+                        $meta_list[] = $payment_method_string;
210
+                    }
211
+
212
+                    if ( $order->get_date_paid() ) {
213
+                        /* translators: 1: date 2: time */
214
+                        $meta_list[] = sprintf(
215
+                            __( 'Paid on %1$s @ %2$s', 'woocommerce' ),
216
+                            wc_format_datetime( $order->get_date_paid() ),
217
+                            wc_format_datetime( $order->get_date_paid(), get_option( 'time_format' ) )
218
+                        );
219
+                    }
220
+
221
+                    if ( $ip_address = $order->get_customer_ip_address() ) {
222
+                        /* translators: %s: IP address */
223
+                        $meta_list[] = sprintf(
224
+                            __( 'Customer IP: %s', 'woocommerce' ),
225
+                            '<span class="woocommerce-Order-customerIP">' . esc_html( $ip_address ) . '</span>'
226
+                        );
227
+                    }
228
+
229
+                    echo wp_kses_post( implode( '. ', $meta_list ) );
230
+
231
+                    ?>
232 232
 				</p>
233 233
 				<div class="order_data_column_container">
234 234
 					<div class="order_data_column">
@@ -246,23 +246,23 @@  discard block
 block discarded – undo
246 246
 						<p class="form-field form-field-wide wc-order-status">
247 247
 							<label for="order_status">
248 248
 								<?php
249
-								_e( 'Status:', 'woocommerce' );
250
-								if ( $order->needs_payment() ) {
251
-									printf(
252
-										'<a href="%s">%s</a>',
253
-										esc_url( $order->get_checkout_payment_url() ),
254
-										__( 'Customer payment page &rarr;', 'woocommerce' )
255
-									);
256
-								}
257
-								?>
249
+                                _e( 'Status:', 'woocommerce' );
250
+                                if ( $order->needs_payment() ) {
251
+                                    printf(
252
+                                        '<a href="%s">%s</a>',
253
+                                        esc_url( $order->get_checkout_payment_url() ),
254
+                                        __( 'Customer payment page &rarr;', 'woocommerce' )
255
+                                    );
256
+                                }
257
+                                ?>
258 258
 							</label>
259 259
 							<select id="order_status" name="order_status" class="wc-enhanced-select">
260 260
 								<?php
261
-								$statuses = wc_get_order_statuses();
262
-								foreach ( $statuses as $status => $status_name ) {
263
-									echo '<option value="' . esc_attr( $status ) . '" ' . selected( $status, 'wc-' . $order->get_status( 'edit' ), false ) . '>' . esc_html( $status_name ) . '</option>';
264
-								}
265
-								?>
261
+                                $statuses = wc_get_order_statuses();
262
+                                foreach ( $statuses as $status => $status_name ) {
263
+                                    echo '<option value="' . esc_attr( $status ) . '" ' . selected( $status, 'wc-' . $order->get_status( 'edit' ), false ) . '>' . esc_html( $status_name ) . '</option>';
264
+                                }
265
+                                ?>
266 266
 							</select>
267 267
 						</p>
268 268
 
@@ -270,41 +270,41 @@  discard block
 block discarded – undo
270 270
 							<!--email_off--> <!-- Disable CloudFlare email obfuscation -->
271 271
 							<label for="customer_user">
272 272
 								<?php
273
-								_e( 'Customer:', 'woocommerce' );
274
-								if ( $order->get_user_id( 'edit' ) ) {
275
-									$args = array(
276
-										'post_status'    => 'all',
277
-										'post_type'      => 'shop_order',
278
-										'_customer_user' => $order->get_user_id( 'edit' ),
279
-									);
280
-									printf(
281
-										'<a href="%s">%s</a>',
282
-										esc_url( add_query_arg( $args, admin_url( 'edit.php' ) ) ),
283
-										' ' . __( 'View other orders &rarr;', 'woocommerce' )
284
-									);
285
-									printf(
286
-										'<a href="%s">%s</a>',
287
-										esc_url( add_query_arg( 'user_id', $order->get_user_id( 'edit' ), admin_url( 'user-edit.php' ) ) ),
288
-										' ' . __( 'Profile &rarr;', 'woocommerce' )
289
-									);
290
-								}
291
-								?>
273
+                                _e( 'Customer:', 'woocommerce' );
274
+                                if ( $order->get_user_id( 'edit' ) ) {
275
+                                    $args = array(
276
+                                        'post_status'    => 'all',
277
+                                        'post_type'      => 'shop_order',
278
+                                        '_customer_user' => $order->get_user_id( 'edit' ),
279
+                                    );
280
+                                    printf(
281
+                                        '<a href="%s">%s</a>',
282
+                                        esc_url( add_query_arg( $args, admin_url( 'edit.php' ) ) ),
283
+                                        ' ' . __( 'View other orders &rarr;', 'woocommerce' )
284
+                                    );
285
+                                    printf(
286
+                                        '<a href="%s">%s</a>',
287
+                                        esc_url( add_query_arg( 'user_id', $order->get_user_id( 'edit' ), admin_url( 'user-edit.php' ) ) ),
288
+                                        ' ' . __( 'Profile &rarr;', 'woocommerce' )
289
+                                    );
290
+                                }
291
+                                ?>
292 292
 							</label>
293 293
 							<?php
294
-							$user_string = '';
295
-							$user_id     = '';
296
-							if ( $order->get_user_id() ) {
297
-								$user_id = absint( $order->get_user_id() );
298
-								$user    = get_user_by( 'id', $user_id );
299
-								/* translators: 1: user display name 2: user ID 3: user email */
300
-								$user_string = sprintf(
301
-									esc_html__( '%1$s (#%2$s &ndash; %3$s)', 'woocommerce' ),
302
-									$user->display_name,
303
-									absint( $user->ID ),
304
-									$user->user_email
305
-								);
306
-							}
307
-							?>
294
+                            $user_string = '';
295
+                            $user_id     = '';
296
+                            if ( $order->get_user_id() ) {
297
+                                $user_id = absint( $order->get_user_id() );
298
+                                $user    = get_user_by( 'id', $user_id );
299
+                                /* translators: 1: user display name 2: user ID 3: user email */
300
+                                $user_string = sprintf(
301
+                                    esc_html__( '%1$s (#%2$s &ndash; %3$s)', 'woocommerce' ),
302
+                                    $user->display_name,
303
+                                    absint( $user->ID ),
304
+                                    $user->user_email
305
+                                );
306
+                            }
307
+                            ?>
308 308
 							<select class="wc-customer-search" id="customer_user" name="customer_user" data-placeholder="<?php esc_attr_e( 'Guest', 'woocommerce' ); ?>" data-allow_clear="true">
309 309
 								<option value="<?php echo esc_attr( $user_id ); ?>" selected="selected"><?php echo htmlspecialchars( wp_kses_post( $user_string ) ); // htmlspecialchars to prevent XSS when rendered by selectWoo. ?></option>
310 310
 							</select>
@@ -323,109 +323,109 @@  discard block
 block discarded – undo
323 323
 						<div class="address">
324 324
 							<?php
325 325
 
326
-							// Display values.
327
-							if ( $order->get_formatted_billing_address() ) {
328
-								echo '<p>' . wp_kses( $order->get_formatted_billing_address(), array( 'br' => array() ) ) . '</p>';
329
-							} else {
330
-								echo '<p class="none_set"><strong>' . __( 'Address:', 'woocommerce' ) . '</strong> ' . __( 'No billing address set.', 'woocommerce' ) . '</p>';
331
-							}
332
-
333
-							foreach ( self::$billing_fields as $key => $field ) {
334
-								if ( isset( $field['show'] ) && false === $field['show'] ) {
335
-									continue;
336
-								}
337
-
338
-								$field_name = 'billing_' . $key;
339
-
340
-								if ( isset( $field['value'] ) ) {
341
-									$field_value = $field['value'];
342
-								} elseif ( is_callable( array( $order, 'get_' . $field_name ) ) ) {
343
-									$field_value = $order->{"get_$field_name"}( 'edit' );
344
-								} else {
345
-									$field_value = $order->get_meta( '_' . $field_name );
346
-								}
347
-
348
-								if ( 'billing_phone' === $field_name ) {
349
-									$field_value = wc_make_phone_clickable( $field_value );
350
-								} elseif ( 'billing_email' === $field_name ) {
351
-									$field_value = '<a href="' . esc_url( 'mailto:' . $field_value ) . '">' . $field_value . '</a>';
352
-								} else {
353
-									$field_value = make_clickable( esc_html( $field_value ) );
354
-								}
355
-
356
-								if ( $field_value ) {
357
-									echo '<p><strong>' . esc_html( $field['label'] ) . ':</strong> ' . wp_kses_post( $field_value ) . '</p>';
358
-								}
359
-							}
360
-							?>
326
+                            // Display values.
327
+                            if ( $order->get_formatted_billing_address() ) {
328
+                                echo '<p>' . wp_kses( $order->get_formatted_billing_address(), array( 'br' => array() ) ) . '</p>';
329
+                            } else {
330
+                                echo '<p class="none_set"><strong>' . __( 'Address:', 'woocommerce' ) . '</strong> ' . __( 'No billing address set.', 'woocommerce' ) . '</p>';
331
+                            }
332
+
333
+                            foreach ( self::$billing_fields as $key => $field ) {
334
+                                if ( isset( $field['show'] ) && false === $field['show'] ) {
335
+                                    continue;
336
+                                }
337
+
338
+                                $field_name = 'billing_' . $key;
339
+
340
+                                if ( isset( $field['value'] ) ) {
341
+                                    $field_value = $field['value'];
342
+                                } elseif ( is_callable( array( $order, 'get_' . $field_name ) ) ) {
343
+                                    $field_value = $order->{"get_$field_name"}( 'edit' );
344
+                                } else {
345
+                                    $field_value = $order->get_meta( '_' . $field_name );
346
+                                }
347
+
348
+                                if ( 'billing_phone' === $field_name ) {
349
+                                    $field_value = wc_make_phone_clickable( $field_value );
350
+                                } elseif ( 'billing_email' === $field_name ) {
351
+                                    $field_value = '<a href="' . esc_url( 'mailto:' . $field_value ) . '">' . $field_value . '</a>';
352
+                                } else {
353
+                                    $field_value = make_clickable( esc_html( $field_value ) );
354
+                                }
355
+
356
+                                if ( $field_value ) {
357
+                                    echo '<p><strong>' . esc_html( $field['label'] ) . ':</strong> ' . wp_kses_post( $field_value ) . '</p>';
358
+                                }
359
+                            }
360
+                            ?>
361 361
 						</div>
362 362
 
363 363
 						<div class="edit_address">
364 364
 							<?php
365 365
 
366
-							// Display form.
367
-							foreach ( self::$billing_fields as $key => $field ) {
368
-								if ( ! isset( $field['type'] ) ) {
369
-									$field['type'] = 'text';
370
-								}
371
-								if ( ! isset( $field['id'] ) ) {
372
-									$field['id'] = '_billing_' . $key;
373
-								}
374
-
375
-								$field_name = 'billing_' . $key;
376
-
377
-								if ( ! isset( $field['value'] ) ) {
378
-									if ( is_callable( array( $order, 'get_' . $field_name ) ) ) {
379
-										$field['value'] = $order->{"get_$field_name"}( 'edit' );
380
-									} else {
381
-										$field['value'] = $order->get_meta( '_' . $field_name );
382
-									}
383
-								}
384
-
385
-								switch ( $field['type'] ) {
386
-									case 'select':
387
-										woocommerce_wp_select( $field );
388
-										break;
389
-									default:
390
-										woocommerce_wp_text_input( $field );
391
-										break;
392
-								}
393
-							}
394
-							?>
366
+                            // Display form.
367
+                            foreach ( self::$billing_fields as $key => $field ) {
368
+                                if ( ! isset( $field['type'] ) ) {
369
+                                    $field['type'] = 'text';
370
+                                }
371
+                                if ( ! isset( $field['id'] ) ) {
372
+                                    $field['id'] = '_billing_' . $key;
373
+                                }
374
+
375
+                                $field_name = 'billing_' . $key;
376
+
377
+                                if ( ! isset( $field['value'] ) ) {
378
+                                    if ( is_callable( array( $order, 'get_' . $field_name ) ) ) {
379
+                                        $field['value'] = $order->{"get_$field_name"}( 'edit' );
380
+                                    } else {
381
+                                        $field['value'] = $order->get_meta( '_' . $field_name );
382
+                                    }
383
+                                }
384
+
385
+                                switch ( $field['type'] ) {
386
+                                    case 'select':
387
+                                        woocommerce_wp_select( $field );
388
+                                        break;
389
+                                    default:
390
+                                        woocommerce_wp_text_input( $field );
391
+                                        break;
392
+                                }
393
+                            }
394
+                            ?>
395 395
 							<p class="form-field form-field-wide">
396 396
 								<label><?php esc_html_e( 'Payment method:', 'woocommerce' ); ?></label>
397 397
 								<select name="_payment_method" id="_payment_method" class="first">
398 398
 									<option value=""><?php esc_html_e( 'N/A', 'woocommerce' ); ?></option>
399 399
 									<?php
400
-									$found_method = false;
401
-
402
-									foreach ( $payment_gateways as $gateway ) {
403
-										if ( 'yes' === $gateway->enabled ) {
404
-											echo '<option value="' . esc_attr( $gateway->id ) . '" ' . selected( $payment_method, $gateway->id, false ) . '>' . esc_html( $gateway->get_title() ) . '</option>';
405
-											if ( $payment_method == $gateway->id ) {
406
-												$found_method = true;
407
-											}
408
-										}
409
-									}
410
-
411
-									if ( ! $found_method && ! empty( $payment_method ) ) {
412
-										echo '<option value="' . esc_attr( $payment_method ) . '" selected="selected">' . esc_html__( 'Other', 'woocommerce' ) . '</option>';
413
-									} else {
414
-										echo '<option value="other">' . esc_html__( 'Other', 'woocommerce' ) . '</option>';
415
-									}
416
-									?>
400
+                                    $found_method = false;
401
+
402
+                                    foreach ( $payment_gateways as $gateway ) {
403
+                                        if ( 'yes' === $gateway->enabled ) {
404
+                                            echo '<option value="' . esc_attr( $gateway->id ) . '" ' . selected( $payment_method, $gateway->id, false ) . '>' . esc_html( $gateway->get_title() ) . '</option>';
405
+                                            if ( $payment_method == $gateway->id ) {
406
+                                                $found_method = true;
407
+                                            }
408
+                                        }
409
+                                    }
410
+
411
+                                    if ( ! $found_method && ! empty( $payment_method ) ) {
412
+                                        echo '<option value="' . esc_attr( $payment_method ) . '" selected="selected">' . esc_html__( 'Other', 'woocommerce' ) . '</option>';
413
+                                    } else {
414
+                                        echo '<option value="other">' . esc_html__( 'Other', 'woocommerce' ) . '</option>';
415
+                                    }
416
+                                    ?>
417 417
 								</select>
418 418
 							</p>
419 419
 							<?php
420 420
 
421
-							woocommerce_wp_text_input(
422
-								array(
423
-									'id'    => '_transaction_id',
424
-									'label' => __( 'Transaction ID', 'woocommerce' ),
425
-									'value' => $order->get_transaction_id( 'edit' ),
426
-								)
427
-							);
428
-							?>
421
+                            woocommerce_wp_text_input(
422
+                                array(
423
+                                    'id'    => '_transaction_id',
424
+                                    'label' => __( 'Transaction ID', 'woocommerce' ),
425
+                                    'value' => $order->get_transaction_id( 'edit' ),
426
+                                )
427
+                            );
428
+                            ?>
429 429
 
430 430
 						</div>
431 431
 						<?php do_action( 'woocommerce_admin_order_data_after_billing_address', $order ); ?>
@@ -442,76 +442,76 @@  discard block
 block discarded – undo
442 442
 						<div class="address">
443 443
 							<?php
444 444
 
445
-							// Display values.
446
-							if ( $order->get_formatted_shipping_address() ) {
447
-								echo '<p>' . wp_kses( $order->get_formatted_shipping_address(), array( 'br' => array() ) ) . '</p>';
448
-							} else {
449
-								echo '<p class="none_set"><strong>' . __( 'Address:', 'woocommerce' ) . '</strong> ' . __( 'No shipping address set.', 'woocommerce' ) . '</p>';
450
-							}
451
-
452
-							if ( ! empty( self::$shipping_fields ) ) {
453
-								foreach ( self::$shipping_fields as $key => $field ) {
454
-									if ( isset( $field['show'] ) && false === $field['show'] ) {
455
-										continue;
456
-									}
457
-
458
-									$field_name = 'shipping_' . $key;
459
-
460
-									if ( is_callable( array( $order, 'get_' . $field_name ) ) ) {
461
-										$field_value = $order->{"get_$field_name"}( 'edit' );
462
-									} else {
463
-										$field_value = $order->get_meta( '_' . $field_name );
464
-									}
465
-
466
-									if ( 'shipping_phone' === $field_name ) {
467
-										$field_value = wc_make_phone_clickable( $field_value );
468
-									}
469
-
470
-									if ( $field_value ) {
471
-										echo '<p><strong>' . esc_html( $field['label'] ) . ':</strong> ' . wp_kses_post( $field_value ) . '</p>';
472
-									}
473
-								}
474
-							}
475
-
476
-							if ( apply_filters( 'woocommerce_enable_order_notes_field', 'yes' == get_option( 'woocommerce_enable_order_comments', 'yes' ) ) && $post->post_excerpt ) {
477
-								echo '<p class="order_note"><strong>' . __( 'Customer provided note:', 'woocommerce' ) . '</strong> ' . nl2br( esc_html( $post->post_excerpt ) ) . '</p>';
478
-							}
479
-							?>
445
+                            // Display values.
446
+                            if ( $order->get_formatted_shipping_address() ) {
447
+                                echo '<p>' . wp_kses( $order->get_formatted_shipping_address(), array( 'br' => array() ) ) . '</p>';
448
+                            } else {
449
+                                echo '<p class="none_set"><strong>' . __( 'Address:', 'woocommerce' ) . '</strong> ' . __( 'No shipping address set.', 'woocommerce' ) . '</p>';
450
+                            }
451
+
452
+                            if ( ! empty( self::$shipping_fields ) ) {
453
+                                foreach ( self::$shipping_fields as $key => $field ) {
454
+                                    if ( isset( $field['show'] ) && false === $field['show'] ) {
455
+                                        continue;
456
+                                    }
457
+
458
+                                    $field_name = 'shipping_' . $key;
459
+
460
+                                    if ( is_callable( array( $order, 'get_' . $field_name ) ) ) {
461
+                                        $field_value = $order->{"get_$field_name"}( 'edit' );
462
+                                    } else {
463
+                                        $field_value = $order->get_meta( '_' . $field_name );
464
+                                    }
465
+
466
+                                    if ( 'shipping_phone' === $field_name ) {
467
+                                        $field_value = wc_make_phone_clickable( $field_value );
468
+                                    }
469
+
470
+                                    if ( $field_value ) {
471
+                                        echo '<p><strong>' . esc_html( $field['label'] ) . ':</strong> ' . wp_kses_post( $field_value ) . '</p>';
472
+                                    }
473
+                                }
474
+                            }
475
+
476
+                            if ( apply_filters( 'woocommerce_enable_order_notes_field', 'yes' == get_option( 'woocommerce_enable_order_comments', 'yes' ) ) && $post->post_excerpt ) {
477
+                                echo '<p class="order_note"><strong>' . __( 'Customer provided note:', 'woocommerce' ) . '</strong> ' . nl2br( esc_html( $post->post_excerpt ) ) . '</p>';
478
+                            }
479
+                            ?>
480 480
 						</div>
481 481
 						<div class="edit_address">
482 482
 							<?php
483 483
 
484
-							// Display form.
485
-							if ( ! empty( self::$shipping_fields ) ) {
486
-								foreach ( self::$shipping_fields as $key => $field ) {
487
-									if ( ! isset( $field['type'] ) ) {
488
-										$field['type'] = 'text';
489
-									}
490
-									if ( ! isset( $field['id'] ) ) {
491
-										$field['id'] = '_shipping_' . $key;
492
-									}
493
-
494
-									$field_name = 'shipping_' . $key;
495
-
496
-									if ( is_callable( array( $order, 'get_' . $field_name ) ) ) {
497
-										$field['value'] = $order->{"get_$field_name"}( 'edit' );
498
-									} else {
499
-										$field['value'] = $order->get_meta( '_' . $field_name );
500
-									}
501
-
502
-									switch ( $field['type'] ) {
503
-										case 'select':
504
-											woocommerce_wp_select( $field );
505
-											break;
506
-										default:
507
-											woocommerce_wp_text_input( $field );
508
-											break;
509
-									}
510
-								}
511
-							}
512
-
513
-							if ( apply_filters( 'woocommerce_enable_order_notes_field', 'yes' == get_option( 'woocommerce_enable_order_comments', 'yes' ) ) ) :
514
-								?>
484
+                            // Display form.
485
+                            if ( ! empty( self::$shipping_fields ) ) {
486
+                                foreach ( self::$shipping_fields as $key => $field ) {
487
+                                    if ( ! isset( $field['type'] ) ) {
488
+                                        $field['type'] = 'text';
489
+                                    }
490
+                                    if ( ! isset( $field['id'] ) ) {
491
+                                        $field['id'] = '_shipping_' . $key;
492
+                                    }
493
+
494
+                                    $field_name = 'shipping_' . $key;
495
+
496
+                                    if ( is_callable( array( $order, 'get_' . $field_name ) ) ) {
497
+                                        $field['value'] = $order->{"get_$field_name"}( 'edit' );
498
+                                    } else {
499
+                                        $field['value'] = $order->get_meta( '_' . $field_name );
500
+                                    }
501
+
502
+                                    switch ( $field['type'] ) {
503
+                                        case 'select':
504
+                                            woocommerce_wp_select( $field );
505
+                                            break;
506
+                                        default:
507
+                                            woocommerce_wp_text_input( $field );
508
+                                            break;
509
+                                    }
510
+                                }
511
+                            }
512
+
513
+                            if ( apply_filters( 'woocommerce_enable_order_notes_field', 'yes' == get_option( 'woocommerce_enable_order_comments', 'yes' ) ) ) :
514
+                                ?>
515 515
 								<p class="form-field form-field-wide">
516 516
 									<label for="excerpt"><?php _e( 'Customer provided note', 'woocommerce' ); ?>:</label>
517 517
 									<textarea rows="1" cols="40" name="excerpt" tabindex="6" id="excerpt" placeholder="<?php esc_attr_e( 'Customer notes about the order', 'woocommerce' ); ?>"><?php echo wp_kses_post( $post->post_excerpt ); ?></textarea>
@@ -526,112 +526,112 @@  discard block
 block discarded – undo
526 526
 			</div>
527 527
 		</div>
528 528
 		<?php
529
-	}
530
-
531
-	/**
532
-	 * Save meta box data.
533
-	 *
534
-	 * @param int $order_id Order ID.
535
-	 */
536
-	public static function save( $order_id ) {
537
-		self::init_address_fields();
538
-
539
-		// Ensure gateways are loaded in case they need to insert data into the emails.
540
-		WC()->payment_gateways();
541
-		WC()->shipping();
542
-
543
-		// Get order object.
544
-		$order = wc_get_order( $order_id );
545
-		$props = array();
546
-
547
-		// Create order key.
548
-		if ( ! $order->get_order_key() ) {
549
-			$props['order_key'] = wc_generate_order_key();
550
-		}
551
-
552
-		// Update customer.
553
-		$customer_id = isset( $_POST['customer_user'] ) ? absint( $_POST['customer_user'] ) : 0;
554
-		if ( $customer_id !== $order->get_customer_id() ) {
555
-			$props['customer_id'] = $customer_id;
556
-		}
557
-
558
-		// Update billing fields.
559
-		if ( ! empty( self::$billing_fields ) ) {
560
-			foreach ( self::$billing_fields as $key => $field ) {
561
-				if ( ! isset( $field['id'] ) ) {
562
-					$field['id'] = '_billing_' . $key;
563
-				}
564
-
565
-				if ( ! isset( $_POST[ $field['id'] ] ) ) {
566
-					continue;
567
-				}
568
-
569
-				if ( is_callable( array( $order, 'set_billing_' . $key ) ) ) {
570
-					$props[ 'billing_' . $key ] = wc_clean( wp_unslash( $_POST[ $field['id'] ] ) );
571
-				} else {
572
-					$order->update_meta_data( $field['id'], wc_clean( wp_unslash( $_POST[ $field['id'] ] ) ) );
573
-				}
574
-			}
575
-		}
576
-
577
-		// Update shipping fields.
578
-		if ( ! empty( self::$shipping_fields ) ) {
579
-			foreach ( self::$shipping_fields as $key => $field ) {
580
-				if ( ! isset( $field['id'] ) ) {
581
-					$field['id'] = '_shipping_' . $key;
582
-				}
583
-
584
-				if ( ! isset( $_POST[ $field['id'] ] ) ) {
585
-					continue;
586
-				}
587
-
588
-				if ( is_callable( array( $order, 'set_shipping_' . $key ) ) ) {
589
-					$props[ 'shipping_' . $key ] = wc_clean( wp_unslash( $_POST[ $field['id'] ] ) );
590
-				} else {
591
-					$order->update_meta_data( $field['id'], wc_clean( wp_unslash( $_POST[ $field['id'] ] ) ) );
592
-				}
593
-			}
594
-		}
595
-
596
-		if ( isset( $_POST['_transaction_id'] ) ) {
597
-			$props['transaction_id'] = wc_clean( wp_unslash( $_POST['_transaction_id'] ) );
598
-		}
599
-
600
-		// Payment method handling.
601
-		if ( $order->get_payment_method() !== wp_unslash( $_POST['_payment_method'] ) ) {
602
-			$methods              = WC()->payment_gateways->payment_gateways();
603
-			$payment_method       = wc_clean( wp_unslash( $_POST['_payment_method'] ) );
604
-			$payment_method_title = $payment_method;
605
-
606
-			if ( isset( $methods ) && isset( $methods[ $payment_method ] ) ) {
607
-				$payment_method_title = $methods[ $payment_method ]->get_title();
608
-			}
609
-
610
-			if ( $payment_method == 'other') {
611
-				$payment_method_title = esc_html__( 'Other', 'woocommerce' );
612
-			}
529
+    }
530
+
531
+    /**
532
+     * Save meta box data.
533
+     *
534
+     * @param int $order_id Order ID.
535
+     */
536
+    public static function save( $order_id ) {
537
+        self::init_address_fields();
538
+
539
+        // Ensure gateways are loaded in case they need to insert data into the emails.
540
+        WC()->payment_gateways();
541
+        WC()->shipping();
542
+
543
+        // Get order object.
544
+        $order = wc_get_order( $order_id );
545
+        $props = array();
546
+
547
+        // Create order key.
548
+        if ( ! $order->get_order_key() ) {
549
+            $props['order_key'] = wc_generate_order_key();
550
+        }
551
+
552
+        // Update customer.
553
+        $customer_id = isset( $_POST['customer_user'] ) ? absint( $_POST['customer_user'] ) : 0;
554
+        if ( $customer_id !== $order->get_customer_id() ) {
555
+            $props['customer_id'] = $customer_id;
556
+        }
557
+
558
+        // Update billing fields.
559
+        if ( ! empty( self::$billing_fields ) ) {
560
+            foreach ( self::$billing_fields as $key => $field ) {
561
+                if ( ! isset( $field['id'] ) ) {
562
+                    $field['id'] = '_billing_' . $key;
563
+                }
564
+
565
+                if ( ! isset( $_POST[ $field['id'] ] ) ) {
566
+                    continue;
567
+                }
568
+
569
+                if ( is_callable( array( $order, 'set_billing_' . $key ) ) ) {
570
+                    $props[ 'billing_' . $key ] = wc_clean( wp_unslash( $_POST[ $field['id'] ] ) );
571
+                } else {
572
+                    $order->update_meta_data( $field['id'], wc_clean( wp_unslash( $_POST[ $field['id'] ] ) ) );
573
+                }
574
+            }
575
+        }
576
+
577
+        // Update shipping fields.
578
+        if ( ! empty( self::$shipping_fields ) ) {
579
+            foreach ( self::$shipping_fields as $key => $field ) {
580
+                if ( ! isset( $field['id'] ) ) {
581
+                    $field['id'] = '_shipping_' . $key;
582
+                }
583
+
584
+                if ( ! isset( $_POST[ $field['id'] ] ) ) {
585
+                    continue;
586
+                }
587
+
588
+                if ( is_callable( array( $order, 'set_shipping_' . $key ) ) ) {
589
+                    $props[ 'shipping_' . $key ] = wc_clean( wp_unslash( $_POST[ $field['id'] ] ) );
590
+                } else {
591
+                    $order->update_meta_data( $field['id'], wc_clean( wp_unslash( $_POST[ $field['id'] ] ) ) );
592
+                }
593
+            }
594
+        }
595
+
596
+        if ( isset( $_POST['_transaction_id'] ) ) {
597
+            $props['transaction_id'] = wc_clean( wp_unslash( $_POST['_transaction_id'] ) );
598
+        }
599
+
600
+        // Payment method handling.
601
+        if ( $order->get_payment_method() !== wp_unslash( $_POST['_payment_method'] ) ) {
602
+            $methods              = WC()->payment_gateways->payment_gateways();
603
+            $payment_method       = wc_clean( wp_unslash( $_POST['_payment_method'] ) );
604
+            $payment_method_title = $payment_method;
605
+
606
+            if ( isset( $methods ) && isset( $methods[ $payment_method ] ) ) {
607
+                $payment_method_title = $methods[ $payment_method ]->get_title();
608
+            }
609
+
610
+            if ( $payment_method == 'other') {
611
+                $payment_method_title = esc_html__( 'Other', 'woocommerce' );
612
+            }
613 613
 			
614
-			$props['payment_method']       = $payment_method;
615
-			$props['payment_method_title'] = $payment_method_title;
616
-		}
617
-
618
-		// Update date.
619
-		if ( empty( $_POST['order_date'] ) ) {
620
-			$date = time();
621
-		} else {
622
-			$date = gmdate( 'Y-m-d H:i:s', strtotime( $_POST['order_date'] . ' ' . (int) $_POST['order_date_hour'] . ':' . (int) $_POST['order_date_minute'] . ':' . (int) $_POST['order_date_second'] ) );
623
-		}
624
-
625
-		$props['date_created'] = $date;
626
-
627
-		// Set created via prop if new post.
628
-		if ( isset( $_POST['original_post_status'] ) && $_POST['original_post_status'] === 'auto-draft' ) {
629
-			$props['created_via'] = 'admin';
630
-		}
631
-
632
-		// Save order data.
633
-		$order->set_props( $props );
634
-		$order->set_status( wc_clean( wp_unslash( $_POST['order_status'] ) ), '', true );
635
-		$order->save();
636
-	}
614
+            $props['payment_method']       = $payment_method;
615
+            $props['payment_method_title'] = $payment_method_title;
616
+        }
617
+
618
+        // Update date.
619
+        if ( empty( $_POST['order_date'] ) ) {
620
+            $date = time();
621
+        } else {
622
+            $date = gmdate( 'Y-m-d H:i:s', strtotime( $_POST['order_date'] . ' ' . (int) $_POST['order_date_hour'] . ':' . (int) $_POST['order_date_minute'] . ':' . (int) $_POST['order_date_second'] ) );
623
+        }
624
+
625
+        $props['date_created'] = $date;
626
+
627
+        // Set created via prop if new post.
628
+        if ( isset( $_POST['original_post_status'] ) && $_POST['original_post_status'] === 'auto-draft' ) {
629
+            $props['created_via'] = 'admin';
630
+        }
631
+
632
+        // Save order data.
633
+        $order->set_props( $props );
634
+        $order->set_status( wc_clean( wp_unslash( $_POST['order_status'] ) ), '', true );
635
+        $order->save();
636
+    }
637 637
 }
Please login to merge, or discard this patch.
Spacing   +183 added lines, -183 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  * @version     2.2.0
11 11
  */
12 12
 
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if (!defined('ABSPATH')) {
14 14
 	exit; // Exit if accessed directly
15 15
 }
16 16
 
@@ -42,50 +42,50 @@  discard block
 block discarded – undo
42 42
 			'woocommerce_admin_billing_fields',
43 43
 			array(
44 44
 				'first_name' => array(
45
-					'label' => __( 'First name', 'woocommerce' ),
45
+					'label' => __('First name', 'woocommerce'),
46 46
 					'show'  => false,
47 47
 				),
48 48
 				'last_name'  => array(
49
-					'label' => __( 'Last name', 'woocommerce' ),
49
+					'label' => __('Last name', 'woocommerce'),
50 50
 					'show'  => false,
51 51
 				),
52 52
 				'company'    => array(
53
-					'label' => __( 'Company', 'woocommerce' ),
53
+					'label' => __('Company', 'woocommerce'),
54 54
 					'show'  => false,
55 55
 				),
56 56
 				'address_1'  => array(
57
-					'label' => __( 'Address line 1', 'woocommerce' ),
57
+					'label' => __('Address line 1', 'woocommerce'),
58 58
 					'show'  => false,
59 59
 				),
60 60
 				'address_2'  => array(
61
-					'label' => __( 'Address line 2', 'woocommerce' ),
61
+					'label' => __('Address line 2', 'woocommerce'),
62 62
 					'show'  => false,
63 63
 				),
64 64
 				'city'       => array(
65
-					'label' => __( 'City', 'woocommerce' ),
65
+					'label' => __('City', 'woocommerce'),
66 66
 					'show'  => false,
67 67
 				),
68 68
 				'postcode'   => array(
69
-					'label' => __( 'Postcode / ZIP', 'woocommerce' ),
69
+					'label' => __('Postcode / ZIP', 'woocommerce'),
70 70
 					'show'  => false,
71 71
 				),
72 72
 				'country'    => array(
73
-					'label'   => __( 'Country / Region', 'woocommerce' ),
73
+					'label'   => __('Country / Region', 'woocommerce'),
74 74
 					'show'    => false,
75 75
 					'class'   => 'js_field-country select short',
76 76
 					'type'    => 'select',
77
-					'options' => array( '' => __( 'Select a country / region&hellip;', 'woocommerce' ) ) + WC()->countries->get_allowed_countries(),
77
+					'options' => array('' => __('Select a country / region&hellip;', 'woocommerce')) + WC()->countries->get_allowed_countries(),
78 78
 				),
79 79
 				'state'      => array(
80
-					'label' => __( 'State / County', 'woocommerce' ),
80
+					'label' => __('State / County', 'woocommerce'),
81 81
 					'class' => 'js_field-state select short',
82 82
 					'show'  => false,
83 83
 				),
84 84
 				'email'      => array(
85
-					'label' => __( 'Email address', 'woocommerce' ),
85
+					'label' => __('Email address', 'woocommerce'),
86 86
 				),
87 87
 				'phone'      => array(
88
-					'label' => __( 'Phone', 'woocommerce' ),
88
+					'label' => __('Phone', 'woocommerce'),
89 89
 				),
90 90
 			)
91 91
 		);
@@ -94,47 +94,47 @@  discard block
 block discarded – undo
94 94
 			'woocommerce_admin_shipping_fields',
95 95
 			array(
96 96
 				'first_name' => array(
97
-					'label' => __( 'First name', 'woocommerce' ),
97
+					'label' => __('First name', 'woocommerce'),
98 98
 					'show'  => false,
99 99
 				),
100 100
 				'last_name'  => array(
101
-					'label' => __( 'Last name', 'woocommerce' ),
101
+					'label' => __('Last name', 'woocommerce'),
102 102
 					'show'  => false,
103 103
 				),
104 104
 				'company'    => array(
105
-					'label' => __( 'Company', 'woocommerce' ),
105
+					'label' => __('Company', 'woocommerce'),
106 106
 					'show'  => false,
107 107
 				),
108 108
 				'address_1'  => array(
109
-					'label' => __( 'Address line 1', 'woocommerce' ),
109
+					'label' => __('Address line 1', 'woocommerce'),
110 110
 					'show'  => false,
111 111
 				),
112 112
 				'address_2'  => array(
113
-					'label' => __( 'Address line 2', 'woocommerce' ),
113
+					'label' => __('Address line 2', 'woocommerce'),
114 114
 					'show'  => false,
115 115
 				),
116 116
 				'city'       => array(
117
-					'label' => __( 'City', 'woocommerce' ),
117
+					'label' => __('City', 'woocommerce'),
118 118
 					'show'  => false,
119 119
 				),
120 120
 				'postcode'   => array(
121
-					'label' => __( 'Postcode / ZIP', 'woocommerce' ),
121
+					'label' => __('Postcode / ZIP', 'woocommerce'),
122 122
 					'show'  => false,
123 123
 				),
124 124
 				'country'    => array(
125
-					'label'   => __( 'Country / Region', 'woocommerce' ),
125
+					'label'   => __('Country / Region', 'woocommerce'),
126 126
 					'show'    => false,
127 127
 					'type'    => 'select',
128 128
 					'class'   => 'js_field-country select short',
129
-					'options' => array( '' => __( 'Select a country / region&hellip;', 'woocommerce' ) ) + WC()->countries->get_shipping_countries(),
129
+					'options' => array('' => __('Select a country / region&hellip;', 'woocommerce')) + WC()->countries->get_shipping_countries(),
130 130
 				),
131 131
 				'state'      => array(
132
-					'label' => __( 'State / County', 'woocommerce' ),
132
+					'label' => __('State / County', 'woocommerce'),
133 133
 					'class' => 'js_field-state select short',
134 134
 					'show'  => false,
135 135
 				),
136 136
 				'phone'      => array(
137
-					'label' => __( 'Phone', 'woocommerce' ),
137
+					'label' => __('Phone', 'woocommerce'),
138 138
 				),
139 139
 			)
140 140
 		);
@@ -145,18 +145,18 @@  discard block
 block discarded – undo
145 145
 	 *
146 146
 	 * @param WP_Post $post
147 147
 	 */
148
-	public static function output( $post ) {
148
+	public static function output($post) {
149 149
 		global $theorder;
150 150
 
151
-		if ( ! is_object( $theorder ) ) {
152
-			$theorder = wc_get_order( $post->ID );
151
+		if (!is_object($theorder)) {
152
+			$theorder = wc_get_order($post->ID);
153 153
 		}
154 154
 
155 155
 		$order = $theorder;
156 156
 
157 157
 		self::init_address_fields();
158 158
 
159
-		if ( WC()->payment_gateways() ) {
159
+		if (WC()->payment_gateways()) {
160 160
 			$payment_gateways = WC()->payment_gateways->payment_gateways();
161 161
 		} else {
162 162
 			$payment_gateways = array();
@@ -164,24 +164,24 @@  discard block
 block discarded – undo
164 164
 
165 165
 		$payment_method = $order->get_payment_method();
166 166
 
167
-		$order_type_object = get_post_type_object( $post->post_type );
168
-		wp_nonce_field( 'woocommerce_save_data', 'woocommerce_meta_nonce' );
167
+		$order_type_object = get_post_type_object($post->post_type);
168
+		wp_nonce_field('woocommerce_save_data', 'woocommerce_meta_nonce');
169 169
 		?>
170 170
 		<style type="text/css">
171 171
 			#post-body-content, #titlediv { display:none }
172 172
 		</style>
173 173
 		<div class="panel-wrap woocommerce">
174
-			<input name="post_title" type="hidden" value="<?php echo empty( $post->post_title ) ? __( 'Order', 'woocommerce' ) : esc_attr( $post->post_title ); ?>" />
175
-			<input name="post_status" type="hidden" value="<?php echo esc_attr( $post->post_status ); ?>" />
174
+			<input name="post_title" type="hidden" value="<?php echo empty($post->post_title) ? __('Order', 'woocommerce') : esc_attr($post->post_title); ?>" />
175
+			<input name="post_status" type="hidden" value="<?php echo esc_attr($post->post_status); ?>" />
176 176
 			<div id="order_data" class="panel woocommerce-order-data">
177 177
 				<h2 class="woocommerce-order-data__heading">
178 178
 					<?php
179 179
 
180 180
 					/* translators: 1: order type 2: order number */
181 181
 					printf(
182
-						esc_html__( '%1$s #%2$s details', 'woocommerce' ),
183
-						esc_html( $order_type_object->labels->singular_name ),
184
-						esc_html( $order->get_order_number() )
182
+						esc_html__('%1$s #%2$s details', 'woocommerce'),
183
+						esc_html($order_type_object->labels->singular_name),
184
+						esc_html($order->get_order_number())
185 185
 					);
186 186
 
187 187
 					?>
@@ -191,67 +191,67 @@  discard block
 block discarded – undo
191 191
 
192 192
 					$meta_list = array();
193 193
 
194
-					if ( $payment_method && 'other' !== $payment_method ) {
194
+					if ($payment_method && 'other' !== $payment_method) {
195 195
 						/* translators: %s: payment method */
196 196
 						$payment_method_string = sprintf(
197
-							__( 'Payment via %s', 'woocommerce' ),
198
-							esc_html( isset( $payment_gateways[ $payment_method ] ) ? $payment_gateways[ $payment_method ]->get_title() : $payment_method )
197
+							__('Payment via %s', 'woocommerce'),
198
+							esc_html(isset($payment_gateways[$payment_method]) ? $payment_gateways[$payment_method]->get_title() : $payment_method)
199 199
 						);
200 200
 
201
-						if ( $transaction_id = $order->get_transaction_id() ) {
202
-							if ( isset( $payment_gateways[ $payment_method ] ) && ( $url = $payment_gateways[ $payment_method ]->get_transaction_url( $order ) ) ) {
203
-								$payment_method_string .= ' (<a href="' . esc_url( $url ) . '" target="_blank">' . esc_html( $transaction_id ) . '</a>)';
201
+						if ($transaction_id = $order->get_transaction_id()) {
202
+							if (isset($payment_gateways[$payment_method]) && ($url = $payment_gateways[$payment_method]->get_transaction_url($order))) {
203
+								$payment_method_string .= ' (<a href="' . esc_url($url) . '" target="_blank">' . esc_html($transaction_id) . '</a>)';
204 204
 							} else {
205
-								$payment_method_string .= ' (' . esc_html( $transaction_id ) . ')';
205
+								$payment_method_string .= ' (' . esc_html($transaction_id) . ')';
206 206
 							}
207 207
 						}
208 208
 
209 209
 						$meta_list[] = $payment_method_string;
210 210
 					}
211 211
 
212
-					if ( $order->get_date_paid() ) {
212
+					if ($order->get_date_paid()) {
213 213
 						/* translators: 1: date 2: time */
214 214
 						$meta_list[] = sprintf(
215
-							__( 'Paid on %1$s @ %2$s', 'woocommerce' ),
216
-							wc_format_datetime( $order->get_date_paid() ),
217
-							wc_format_datetime( $order->get_date_paid(), get_option( 'time_format' ) )
215
+							__('Paid on %1$s @ %2$s', 'woocommerce'),
216
+							wc_format_datetime($order->get_date_paid()),
217
+							wc_format_datetime($order->get_date_paid(), get_option('time_format'))
218 218
 						);
219 219
 					}
220 220
 
221
-					if ( $ip_address = $order->get_customer_ip_address() ) {
221
+					if ($ip_address = $order->get_customer_ip_address()) {
222 222
 						/* translators: %s: IP address */
223 223
 						$meta_list[] = sprintf(
224
-							__( 'Customer IP: %s', 'woocommerce' ),
225
-							'<span class="woocommerce-Order-customerIP">' . esc_html( $ip_address ) . '</span>'
224
+							__('Customer IP: %s', 'woocommerce'),
225
+							'<span class="woocommerce-Order-customerIP">' . esc_html($ip_address) . '</span>'
226 226
 						);
227 227
 					}
228 228
 
229
-					echo wp_kses_post( implode( '. ', $meta_list ) );
229
+					echo wp_kses_post(implode('. ', $meta_list));
230 230
 
231 231
 					?>
232 232
 				</p>
233 233
 				<div class="order_data_column_container">
234 234
 					<div class="order_data_column">
235
-						<h3><?php esc_html_e( 'General', 'woocommerce' ); ?></h3>
235
+						<h3><?php esc_html_e('General', 'woocommerce'); ?></h3>
236 236
 
237 237
 						<p class="form-field form-field-wide">
238
-							<label for="order_date"><?php _e( 'Date created:', 'woocommerce' ); ?></label>
239
-							<input type="text" class="date-picker" name="order_date" maxlength="10" value="<?php echo esc_attr( date_i18n( 'Y-m-d', strtotime( $post->post_date ) ) ); ?>" pattern="<?php echo esc_attr( apply_filters( 'woocommerce_date_input_html_pattern', '[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])' ) ); ?>" />@
238
+							<label for="order_date"><?php _e('Date created:', 'woocommerce'); ?></label>
239
+							<input type="text" class="date-picker" name="order_date" maxlength="10" value="<?php echo esc_attr(date_i18n('Y-m-d', strtotime($post->post_date))); ?>" pattern="<?php echo esc_attr(apply_filters('woocommerce_date_input_html_pattern', '[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])')); ?>" />@
240 240
 							&lrm;
241
-							<input type="number" class="hour" placeholder="<?php esc_attr_e( 'h', 'woocommerce' ); ?>" name="order_date_hour" min="0" max="23" step="1" value="<?php echo esc_attr( date_i18n( 'H', strtotime( $post->post_date ) ) ); ?>" pattern="([01]?[0-9]{1}|2[0-3]{1})" />:
242
-							<input type="number" class="minute" placeholder="<?php esc_attr_e( 'm', 'woocommerce' ); ?>" name="order_date_minute" min="0" max="59" step="1" value="<?php echo esc_attr( date_i18n( 'i', strtotime( $post->post_date ) ) ); ?>" pattern="[0-5]{1}[0-9]{1}" />
243
-							<input type="hidden" name="order_date_second" value="<?php echo esc_attr( date_i18n( 's', strtotime( $post->post_date ) ) ); ?>" />
241
+							<input type="number" class="hour" placeholder="<?php esc_attr_e('h', 'woocommerce'); ?>" name="order_date_hour" min="0" max="23" step="1" value="<?php echo esc_attr(date_i18n('H', strtotime($post->post_date))); ?>" pattern="([01]?[0-9]{1}|2[0-3]{1})" />:
242
+							<input type="number" class="minute" placeholder="<?php esc_attr_e('m', 'woocommerce'); ?>" name="order_date_minute" min="0" max="59" step="1" value="<?php echo esc_attr(date_i18n('i', strtotime($post->post_date))); ?>" pattern="[0-5]{1}[0-9]{1}" />
243
+							<input type="hidden" name="order_date_second" value="<?php echo esc_attr(date_i18n('s', strtotime($post->post_date))); ?>" />
244 244
 						</p>
245 245
 
246 246
 						<p class="form-field form-field-wide wc-order-status">
247 247
 							<label for="order_status">
248 248
 								<?php
249
-								_e( 'Status:', 'woocommerce' );
250
-								if ( $order->needs_payment() ) {
249
+								_e('Status:', 'woocommerce');
250
+								if ($order->needs_payment()) {
251 251
 									printf(
252 252
 										'<a href="%s">%s</a>',
253
-										esc_url( $order->get_checkout_payment_url() ),
254
-										__( 'Customer payment page &rarr;', 'woocommerce' )
253
+										esc_url($order->get_checkout_payment_url()),
254
+										__('Customer payment page &rarr;', 'woocommerce')
255 255
 									);
256 256
 								}
257 257
 								?>
@@ -259,8 +259,8 @@  discard block
 block discarded – undo
259 259
 							<select id="order_status" name="order_status" class="wc-enhanced-select">
260 260
 								<?php
261 261
 								$statuses = wc_get_order_statuses();
262
-								foreach ( $statuses as $status => $status_name ) {
263
-									echo '<option value="' . esc_attr( $status ) . '" ' . selected( $status, 'wc-' . $order->get_status( 'edit' ), false ) . '>' . esc_html( $status_name ) . '</option>';
262
+								foreach ($statuses as $status => $status_name) {
263
+									echo '<option value="' . esc_attr($status) . '" ' . selected($status, 'wc-' . $order->get_status('edit'), false) . '>' . esc_html($status_name) . '</option>';
264 264
 								}
265 265
 								?>
266 266
 							</select>
@@ -270,22 +270,22 @@  discard block
 block discarded – undo
270 270
 							<!--email_off--> <!-- Disable CloudFlare email obfuscation -->
271 271
 							<label for="customer_user">
272 272
 								<?php
273
-								_e( 'Customer:', 'woocommerce' );
274
-								if ( $order->get_user_id( 'edit' ) ) {
273
+								_e('Customer:', 'woocommerce');
274
+								if ($order->get_user_id('edit')) {
275 275
 									$args = array(
276 276
 										'post_status'    => 'all',
277 277
 										'post_type'      => 'shop_order',
278
-										'_customer_user' => $order->get_user_id( 'edit' ),
278
+										'_customer_user' => $order->get_user_id('edit'),
279 279
 									);
280 280
 									printf(
281 281
 										'<a href="%s">%s</a>',
282
-										esc_url( add_query_arg( $args, admin_url( 'edit.php' ) ) ),
283
-										' ' . __( 'View other orders &rarr;', 'woocommerce' )
282
+										esc_url(add_query_arg($args, admin_url('edit.php'))),
283
+										' ' . __('View other orders &rarr;', 'woocommerce')
284 284
 									);
285 285
 									printf(
286 286
 										'<a href="%s">%s</a>',
287
-										esc_url( add_query_arg( 'user_id', $order->get_user_id( 'edit' ), admin_url( 'user-edit.php' ) ) ),
288
-										' ' . __( 'Profile &rarr;', 'woocommerce' )
287
+										esc_url(add_query_arg('user_id', $order->get_user_id('edit'), admin_url('user-edit.php'))),
288
+										' ' . __('Profile &rarr;', 'woocommerce')
289 289
 									);
290 290
 								}
291 291
 								?>
@@ -293,68 +293,68 @@  discard block
 block discarded – undo
293 293
 							<?php
294 294
 							$user_string = '';
295 295
 							$user_id     = '';
296
-							if ( $order->get_user_id() ) {
297
-								$user_id = absint( $order->get_user_id() );
298
-								$user    = get_user_by( 'id', $user_id );
296
+							if ($order->get_user_id()) {
297
+								$user_id = absint($order->get_user_id());
298
+								$user    = get_user_by('id', $user_id);
299 299
 								/* translators: 1: user display name 2: user ID 3: user email */
300 300
 								$user_string = sprintf(
301
-									esc_html__( '%1$s (#%2$s &ndash; %3$s)', 'woocommerce' ),
301
+									esc_html__('%1$s (#%2$s &ndash; %3$s)', 'woocommerce'),
302 302
 									$user->display_name,
303
-									absint( $user->ID ),
303
+									absint($user->ID),
304 304
 									$user->user_email
305 305
 								);
306 306
 							}
307 307
 							?>
308
-							<select class="wc-customer-search" id="customer_user" name="customer_user" data-placeholder="<?php esc_attr_e( 'Guest', 'woocommerce' ); ?>" data-allow_clear="true">
309
-								<option value="<?php echo esc_attr( $user_id ); ?>" selected="selected"><?php echo htmlspecialchars( wp_kses_post( $user_string ) ); // htmlspecialchars to prevent XSS when rendered by selectWoo. ?></option>
308
+							<select class="wc-customer-search" id="customer_user" name="customer_user" data-placeholder="<?php esc_attr_e('Guest', 'woocommerce'); ?>" data-allow_clear="true">
309
+								<option value="<?php echo esc_attr($user_id); ?>" selected="selected"><?php echo htmlspecialchars(wp_kses_post($user_string)); // htmlspecialchars to prevent XSS when rendered by selectWoo. ?></option>
310 310
 							</select>
311 311
 							<!--/email_off-->
312 312
 						</p>
313
-						<?php do_action( 'woocommerce_admin_order_data_after_order_details', $order ); ?>
313
+						<?php do_action('woocommerce_admin_order_data_after_order_details', $order); ?>
314 314
 					</div>
315 315
 					<div class="order_data_column">
316 316
 						<h3>
317
-							<?php esc_html_e( 'Billing', 'woocommerce' ); ?>
318
-							<a href="#" class="edit_address"><?php esc_html_e( 'Edit', 'woocommerce' ); ?></a>
317
+							<?php esc_html_e('Billing', 'woocommerce'); ?>
318
+							<a href="#" class="edit_address"><?php esc_html_e('Edit', 'woocommerce'); ?></a>
319 319
 							<span>
320
-								<a href="#" class="load_customer_billing" style="display:none;"><?php esc_html_e( 'Load billing address', 'woocommerce' ); ?></a>
320
+								<a href="#" class="load_customer_billing" style="display:none;"><?php esc_html_e('Load billing address', 'woocommerce'); ?></a>
321 321
 							</span>
322 322
 						</h3>
323 323
 						<div class="address">
324 324
 							<?php
325 325
 
326 326
 							// Display values.
327
-							if ( $order->get_formatted_billing_address() ) {
328
-								echo '<p>' . wp_kses( $order->get_formatted_billing_address(), array( 'br' => array() ) ) . '</p>';
327
+							if ($order->get_formatted_billing_address()) {
328
+								echo '<p>' . wp_kses($order->get_formatted_billing_address(), array('br' => array())) . '</p>';
329 329
 							} else {
330
-								echo '<p class="none_set"><strong>' . __( 'Address:', 'woocommerce' ) . '</strong> ' . __( 'No billing address set.', 'woocommerce' ) . '</p>';
330
+								echo '<p class="none_set"><strong>' . __('Address:', 'woocommerce') . '</strong> ' . __('No billing address set.', 'woocommerce') . '</p>';
331 331
 							}
332 332
 
333
-							foreach ( self::$billing_fields as $key => $field ) {
334
-								if ( isset( $field['show'] ) && false === $field['show'] ) {
333
+							foreach (self::$billing_fields as $key => $field) {
334
+								if (isset($field['show']) && false === $field['show']) {
335 335
 									continue;
336 336
 								}
337 337
 
338 338
 								$field_name = 'billing_' . $key;
339 339
 
340
-								if ( isset( $field['value'] ) ) {
340
+								if (isset($field['value'])) {
341 341
 									$field_value = $field['value'];
342
-								} elseif ( is_callable( array( $order, 'get_' . $field_name ) ) ) {
343
-									$field_value = $order->{"get_$field_name"}( 'edit' );
342
+								} elseif (is_callable(array($order, 'get_' . $field_name))) {
343
+									$field_value = $order->{"get_$field_name"}('edit');
344 344
 								} else {
345
-									$field_value = $order->get_meta( '_' . $field_name );
345
+									$field_value = $order->get_meta('_' . $field_name);
346 346
 								}
347 347
 
348
-								if ( 'billing_phone' === $field_name ) {
349
-									$field_value = wc_make_phone_clickable( $field_value );
350
-								} elseif ( 'billing_email' === $field_name ) {
351
-									$field_value = '<a href="' . esc_url( 'mailto:' . $field_value ) . '">' . $field_value . '</a>';
348
+								if ('billing_phone' === $field_name) {
349
+									$field_value = wc_make_phone_clickable($field_value);
350
+								} elseif ('billing_email' === $field_name) {
351
+									$field_value = '<a href="' . esc_url('mailto:' . $field_value) . '">' . $field_value . '</a>';
352 352
 								} else {
353
-									$field_value = make_clickable( esc_html( $field_value ) );
353
+									$field_value = make_clickable(esc_html($field_value));
354 354
 								}
355 355
 
356
-								if ( $field_value ) {
357
-									echo '<p><strong>' . esc_html( $field['label'] ) . ':</strong> ' . wp_kses_post( $field_value ) . '</p>';
356
+								if ($field_value) {
357
+									echo '<p><strong>' . esc_html($field['label']) . ':</strong> ' . wp_kses_post($field_value) . '</p>';
358 358
 								}
359 359
 							}
360 360
 							?>
@@ -364,54 +364,54 @@  discard block
 block discarded – undo
364 364
 							<?php
365 365
 
366 366
 							// Display form.
367
-							foreach ( self::$billing_fields as $key => $field ) {
368
-								if ( ! isset( $field['type'] ) ) {
367
+							foreach (self::$billing_fields as $key => $field) {
368
+								if (!isset($field['type'])) {
369 369
 									$field['type'] = 'text';
370 370
 								}
371
-								if ( ! isset( $field['id'] ) ) {
371
+								if (!isset($field['id'])) {
372 372
 									$field['id'] = '_billing_' . $key;
373 373
 								}
374 374
 
375 375
 								$field_name = 'billing_' . $key;
376 376
 
377
-								if ( ! isset( $field['value'] ) ) {
378
-									if ( is_callable( array( $order, 'get_' . $field_name ) ) ) {
379
-										$field['value'] = $order->{"get_$field_name"}( 'edit' );
377
+								if (!isset($field['value'])) {
378
+									if (is_callable(array($order, 'get_' . $field_name))) {
379
+										$field['value'] = $order->{"get_$field_name"}('edit');
380 380
 									} else {
381
-										$field['value'] = $order->get_meta( '_' . $field_name );
381
+										$field['value'] = $order->get_meta('_' . $field_name);
382 382
 									}
383 383
 								}
384 384
 
385
-								switch ( $field['type'] ) {
385
+								switch ($field['type']) {
386 386
 									case 'select':
387
-										woocommerce_wp_select( $field );
387
+										woocommerce_wp_select($field);
388 388
 										break;
389 389
 									default:
390
-										woocommerce_wp_text_input( $field );
390
+										woocommerce_wp_text_input($field);
391 391
 										break;
392 392
 								}
393 393
 							}
394 394
 							?>
395 395
 							<p class="form-field form-field-wide">
396
-								<label><?php esc_html_e( 'Payment method:', 'woocommerce' ); ?></label>
396
+								<label><?php esc_html_e('Payment method:', 'woocommerce'); ?></label>
397 397
 								<select name="_payment_method" id="_payment_method" class="first">
398
-									<option value=""><?php esc_html_e( 'N/A', 'woocommerce' ); ?></option>
398
+									<option value=""><?php esc_html_e('N/A', 'woocommerce'); ?></option>
399 399
 									<?php
400 400
 									$found_method = false;
401 401
 
402
-									foreach ( $payment_gateways as $gateway ) {
403
-										if ( 'yes' === $gateway->enabled ) {
404
-											echo '<option value="' . esc_attr( $gateway->id ) . '" ' . selected( $payment_method, $gateway->id, false ) . '>' . esc_html( $gateway->get_title() ) . '</option>';
405
-											if ( $payment_method == $gateway->id ) {
402
+									foreach ($payment_gateways as $gateway) {
403
+										if ('yes' === $gateway->enabled) {
404
+											echo '<option value="' . esc_attr($gateway->id) . '" ' . selected($payment_method, $gateway->id, false) . '>' . esc_html($gateway->get_title()) . '</option>';
405
+											if ($payment_method == $gateway->id) {
406 406
 												$found_method = true;
407 407
 											}
408 408
 										}
409 409
 									}
410 410
 
411
-									if ( ! $found_method && ! empty( $payment_method ) ) {
412
-										echo '<option value="' . esc_attr( $payment_method ) . '" selected="selected">' . esc_html__( 'Other', 'woocommerce' ) . '</option>';
411
+									if (!$found_method && !empty($payment_method)) {
412
+										echo '<option value="' . esc_attr($payment_method) . '" selected="selected">' . esc_html__('Other', 'woocommerce') . '</option>';
413 413
 									} else {
414
-										echo '<option value="other">' . esc_html__( 'Other', 'woocommerce' ) . '</option>';
414
+										echo '<option value="other">' . esc_html__('Other', 'woocommerce') . '</option>';
415 415
 									}
416 416
 									?>
417 417
 								</select>
@@ -421,60 +421,60 @@  discard block
 block discarded – undo
421 421
 							woocommerce_wp_text_input(
422 422
 								array(
423 423
 									'id'    => '_transaction_id',
424
-									'label' => __( 'Transaction ID', 'woocommerce' ),
425
-									'value' => $order->get_transaction_id( 'edit' ),
424
+									'label' => __('Transaction ID', 'woocommerce'),
425
+									'value' => $order->get_transaction_id('edit'),
426 426
 								)
427 427
 							);
428 428
 							?>
429 429
 
430 430
 						</div>
431
-						<?php do_action( 'woocommerce_admin_order_data_after_billing_address', $order ); ?>
431
+						<?php do_action('woocommerce_admin_order_data_after_billing_address', $order); ?>
432 432
 					</div>
433 433
 					<div class="order_data_column">
434 434
 						<h3>
435
-							<?php esc_html_e( 'Shipping', 'woocommerce' ); ?>
436
-							<a href="#" class="edit_address"><?php esc_html_e( 'Edit', 'woocommerce' ); ?></a>
435
+							<?php esc_html_e('Shipping', 'woocommerce'); ?>
436
+							<a href="#" class="edit_address"><?php esc_html_e('Edit', 'woocommerce'); ?></a>
437 437
 							<span>
438
-								<a href="#" class="load_customer_shipping" style="display:none;"><?php esc_html_e( 'Load shipping address', 'woocommerce' ); ?></a>
439
-								<a href="#" class="billing-same-as-shipping" style="display:none;"><?php esc_html_e( 'Copy billing address', 'woocommerce' ); ?></a>
438
+								<a href="#" class="load_customer_shipping" style="display:none;"><?php esc_html_e('Load shipping address', 'woocommerce'); ?></a>
439
+								<a href="#" class="billing-same-as-shipping" style="display:none;"><?php esc_html_e('Copy billing address', 'woocommerce'); ?></a>
440 440
 							</span>
441 441
 						</h3>
442 442
 						<div class="address">
443 443
 							<?php
444 444
 
445 445
 							// Display values.
446
-							if ( $order->get_formatted_shipping_address() ) {
447
-								echo '<p>' . wp_kses( $order->get_formatted_shipping_address(), array( 'br' => array() ) ) . '</p>';
446
+							if ($order->get_formatted_shipping_address()) {
447
+								echo '<p>' . wp_kses($order->get_formatted_shipping_address(), array('br' => array())) . '</p>';
448 448
 							} else {
449
-								echo '<p class="none_set"><strong>' . __( 'Address:', 'woocommerce' ) . '</strong> ' . __( 'No shipping address set.', 'woocommerce' ) . '</p>';
449
+								echo '<p class="none_set"><strong>' . __('Address:', 'woocommerce') . '</strong> ' . __('No shipping address set.', 'woocommerce') . '</p>';
450 450
 							}
451 451
 
452
-							if ( ! empty( self::$shipping_fields ) ) {
453
-								foreach ( self::$shipping_fields as $key => $field ) {
454
-									if ( isset( $field['show'] ) && false === $field['show'] ) {
452
+							if (!empty(self::$shipping_fields)) {
453
+								foreach (self::$shipping_fields as $key => $field) {
454
+									if (isset($field['show']) && false === $field['show']) {
455 455
 										continue;
456 456
 									}
457 457
 
458 458
 									$field_name = 'shipping_' . $key;
459 459
 
460
-									if ( is_callable( array( $order, 'get_' . $field_name ) ) ) {
461
-										$field_value = $order->{"get_$field_name"}( 'edit' );
460
+									if (is_callable(array($order, 'get_' . $field_name))) {
461
+										$field_value = $order->{"get_$field_name"}('edit');
462 462
 									} else {
463
-										$field_value = $order->get_meta( '_' . $field_name );
463
+										$field_value = $order->get_meta('_' . $field_name);
464 464
 									}
465 465
 
466
-									if ( 'shipping_phone' === $field_name ) {
467
-										$field_value = wc_make_phone_clickable( $field_value );
466
+									if ('shipping_phone' === $field_name) {
467
+										$field_value = wc_make_phone_clickable($field_value);
468 468
 									}
469 469
 
470
-									if ( $field_value ) {
471
-										echo '<p><strong>' . esc_html( $field['label'] ) . ':</strong> ' . wp_kses_post( $field_value ) . '</p>';
470
+									if ($field_value) {
471
+										echo '<p><strong>' . esc_html($field['label']) . ':</strong> ' . wp_kses_post($field_value) . '</p>';
472 472
 									}
473 473
 								}
474 474
 							}
475 475
 
476
-							if ( apply_filters( 'woocommerce_enable_order_notes_field', 'yes' == get_option( 'woocommerce_enable_order_comments', 'yes' ) ) && $post->post_excerpt ) {
477
-								echo '<p class="order_note"><strong>' . __( 'Customer provided note:', 'woocommerce' ) . '</strong> ' . nl2br( esc_html( $post->post_excerpt ) ) . '</p>';
476
+							if (apply_filters('woocommerce_enable_order_notes_field', 'yes' == get_option('woocommerce_enable_order_comments', 'yes')) && $post->post_excerpt) {
477
+								echo '<p class="order_note"><strong>' . __('Customer provided note:', 'woocommerce') . '</strong> ' . nl2br(esc_html($post->post_excerpt)) . '</p>';
478 478
 							}
479 479
 							?>
480 480
 						</div>
@@ -482,44 +482,44 @@  discard block
 block discarded – undo
482 482
 							<?php
483 483
 
484 484
 							// Display form.
485
-							if ( ! empty( self::$shipping_fields ) ) {
486
-								foreach ( self::$shipping_fields as $key => $field ) {
487
-									if ( ! isset( $field['type'] ) ) {
485
+							if (!empty(self::$shipping_fields)) {
486
+								foreach (self::$shipping_fields as $key => $field) {
487
+									if (!isset($field['type'])) {
488 488
 										$field['type'] = 'text';
489 489
 									}
490
-									if ( ! isset( $field['id'] ) ) {
490
+									if (!isset($field['id'])) {
491 491
 										$field['id'] = '_shipping_' . $key;
492 492
 									}
493 493
 
494 494
 									$field_name = 'shipping_' . $key;
495 495
 
496
-									if ( is_callable( array( $order, 'get_' . $field_name ) ) ) {
497
-										$field['value'] = $order->{"get_$field_name"}( 'edit' );
496
+									if (is_callable(array($order, 'get_' . $field_name))) {
497
+										$field['value'] = $order->{"get_$field_name"}('edit');
498 498
 									} else {
499
-										$field['value'] = $order->get_meta( '_' . $field_name );
499
+										$field['value'] = $order->get_meta('_' . $field_name);
500 500
 									}
501 501
 
502
-									switch ( $field['type'] ) {
502
+									switch ($field['type']) {
503 503
 										case 'select':
504
-											woocommerce_wp_select( $field );
504
+											woocommerce_wp_select($field);
505 505
 											break;
506 506
 										default:
507
-											woocommerce_wp_text_input( $field );
507
+											woocommerce_wp_text_input($field);
508 508
 											break;
509 509
 									}
510 510
 								}
511 511
 							}
512 512
 
513
-							if ( apply_filters( 'woocommerce_enable_order_notes_field', 'yes' == get_option( 'woocommerce_enable_order_comments', 'yes' ) ) ) :
513
+							if (apply_filters('woocommerce_enable_order_notes_field', 'yes' == get_option('woocommerce_enable_order_comments', 'yes'))) :
514 514
 								?>
515 515
 								<p class="form-field form-field-wide">
516
-									<label for="excerpt"><?php _e( 'Customer provided note', 'woocommerce' ); ?>:</label>
517
-									<textarea rows="1" cols="40" name="excerpt" tabindex="6" id="excerpt" placeholder="<?php esc_attr_e( 'Customer notes about the order', 'woocommerce' ); ?>"><?php echo wp_kses_post( $post->post_excerpt ); ?></textarea>
516
+									<label for="excerpt"><?php _e('Customer provided note', 'woocommerce'); ?>:</label>
517
+									<textarea rows="1" cols="40" name="excerpt" tabindex="6" id="excerpt" placeholder="<?php esc_attr_e('Customer notes about the order', 'woocommerce'); ?>"><?php echo wp_kses_post($post->post_excerpt); ?></textarea>
518 518
 								</p>
519 519
 							<?php endif; ?>
520 520
 						</div>
521 521
 
522
-						<?php do_action( 'woocommerce_admin_order_data_after_shipping_address', $order ); ?>
522
+						<?php do_action('woocommerce_admin_order_data_after_shipping_address', $order); ?>
523 523
 					</div>
524 524
 				</div>
525 525
 				<div class="clear"></div>
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
 	 *
534 534
 	 * @param int $order_id Order ID.
535 535
 	 */
536
-	public static function save( $order_id ) {
536
+	public static function save($order_id) {
537 537
 		self::init_address_fields();
538 538
 
539 539
 		// Ensure gateways are loaded in case they need to insert data into the emails.
@@ -541,74 +541,74 @@  discard block
 block discarded – undo
541 541
 		WC()->shipping();
542 542
 
543 543
 		// Get order object.
544
-		$order = wc_get_order( $order_id );
544
+		$order = wc_get_order($order_id);
545 545
 		$props = array();
546 546
 
547 547
 		// Create order key.
548
-		if ( ! $order->get_order_key() ) {
548
+		if (!$order->get_order_key()) {
549 549
 			$props['order_key'] = wc_generate_order_key();
550 550
 		}
551 551
 
552 552
 		// Update customer.
553
-		$customer_id = isset( $_POST['customer_user'] ) ? absint( $_POST['customer_user'] ) : 0;
554
-		if ( $customer_id !== $order->get_customer_id() ) {
553
+		$customer_id = isset($_POST['customer_user']) ? absint($_POST['customer_user']) : 0;
554
+		if ($customer_id !== $order->get_customer_id()) {
555 555
 			$props['customer_id'] = $customer_id;
556 556
 		}
557 557
 
558 558
 		// Update billing fields.
559
-		if ( ! empty( self::$billing_fields ) ) {
560
-			foreach ( self::$billing_fields as $key => $field ) {
561
-				if ( ! isset( $field['id'] ) ) {
559
+		if (!empty(self::$billing_fields)) {
560
+			foreach (self::$billing_fields as $key => $field) {
561
+				if (!isset($field['id'])) {
562 562
 					$field['id'] = '_billing_' . $key;
563 563
 				}
564 564
 
565
-				if ( ! isset( $_POST[ $field['id'] ] ) ) {
565
+				if (!isset($_POST[$field['id']])) {
566 566
 					continue;
567 567
 				}
568 568
 
569
-				if ( is_callable( array( $order, 'set_billing_' . $key ) ) ) {
570
-					$props[ 'billing_' . $key ] = wc_clean( wp_unslash( $_POST[ $field['id'] ] ) );
569
+				if (is_callable(array($order, 'set_billing_' . $key))) {
570
+					$props['billing_' . $key] = wc_clean(wp_unslash($_POST[$field['id']]));
571 571
 				} else {
572
-					$order->update_meta_data( $field['id'], wc_clean( wp_unslash( $_POST[ $field['id'] ] ) ) );
572
+					$order->update_meta_data($field['id'], wc_clean(wp_unslash($_POST[$field['id']])));
573 573
 				}
574 574
 			}
575 575
 		}
576 576
 
577 577
 		// Update shipping fields.
578
-		if ( ! empty( self::$shipping_fields ) ) {
579
-			foreach ( self::$shipping_fields as $key => $field ) {
580
-				if ( ! isset( $field['id'] ) ) {
578
+		if (!empty(self::$shipping_fields)) {
579
+			foreach (self::$shipping_fields as $key => $field) {
580
+				if (!isset($field['id'])) {
581 581
 					$field['id'] = '_shipping_' . $key;
582 582
 				}
583 583
 
584
-				if ( ! isset( $_POST[ $field['id'] ] ) ) {
584
+				if (!isset($_POST[$field['id']])) {
585 585
 					continue;
586 586
 				}
587 587
 
588
-				if ( is_callable( array( $order, 'set_shipping_' . $key ) ) ) {
589
-					$props[ 'shipping_' . $key ] = wc_clean( wp_unslash( $_POST[ $field['id'] ] ) );
588
+				if (is_callable(array($order, 'set_shipping_' . $key))) {
589
+					$props['shipping_' . $key] = wc_clean(wp_unslash($_POST[$field['id']]));
590 590
 				} else {
591
-					$order->update_meta_data( $field['id'], wc_clean( wp_unslash( $_POST[ $field['id'] ] ) ) );
591
+					$order->update_meta_data($field['id'], wc_clean(wp_unslash($_POST[$field['id']])));
592 592
 				}
593 593
 			}
594 594
 		}
595 595
 
596
-		if ( isset( $_POST['_transaction_id'] ) ) {
597
-			$props['transaction_id'] = wc_clean( wp_unslash( $_POST['_transaction_id'] ) );
596
+		if (isset($_POST['_transaction_id'])) {
597
+			$props['transaction_id'] = wc_clean(wp_unslash($_POST['_transaction_id']));
598 598
 		}
599 599
 
600 600
 		// Payment method handling.
601
-		if ( $order->get_payment_method() !== wp_unslash( $_POST['_payment_method'] ) ) {
601
+		if ($order->get_payment_method() !== wp_unslash($_POST['_payment_method'])) {
602 602
 			$methods              = WC()->payment_gateways->payment_gateways();
603
-			$payment_method       = wc_clean( wp_unslash( $_POST['_payment_method'] ) );
603
+			$payment_method       = wc_clean(wp_unslash($_POST['_payment_method']));
604 604
 			$payment_method_title = $payment_method;
605 605
 
606
-			if ( isset( $methods ) && isset( $methods[ $payment_method ] ) ) {
607
-				$payment_method_title = $methods[ $payment_method ]->get_title();
606
+			if (isset($methods) && isset($methods[$payment_method])) {
607
+				$payment_method_title = $methods[$payment_method]->get_title();
608 608
 			}
609 609
 
610
-			if ( $payment_method == 'other') {
611
-				$payment_method_title = esc_html__( 'Other', 'woocommerce' );
610
+			if ($payment_method == 'other') {
611
+				$payment_method_title = esc_html__('Other', 'woocommerce');
612 612
 			}
613 613
 			
614 614
 			$props['payment_method']       = $payment_method;
@@ -616,22 +616,22 @@  discard block
 block discarded – undo
616 616
 		}
617 617
 
618 618
 		// Update date.
619
-		if ( empty( $_POST['order_date'] ) ) {
619
+		if (empty($_POST['order_date'])) {
620 620
 			$date = time();
621 621
 		} else {
622
-			$date = gmdate( 'Y-m-d H:i:s', strtotime( $_POST['order_date'] . ' ' . (int) $_POST['order_date_hour'] . ':' . (int) $_POST['order_date_minute'] . ':' . (int) $_POST['order_date_second'] ) );
622
+			$date = gmdate('Y-m-d H:i:s', strtotime($_POST['order_date'] . ' ' . (int) $_POST['order_date_hour'] . ':' . (int) $_POST['order_date_minute'] . ':' . (int) $_POST['order_date_second']));
623 623
 		}
624 624
 
625 625
 		$props['date_created'] = $date;
626 626
 
627 627
 		// Set created via prop if new post.
628
-		if ( isset( $_POST['original_post_status'] ) && $_POST['original_post_status'] === 'auto-draft' ) {
628
+		if (isset($_POST['original_post_status']) && $_POST['original_post_status'] === 'auto-draft') {
629 629
 			$props['created_via'] = 'admin';
630 630
 		}
631 631
 
632 632
 		// Save order data.
633
-		$order->set_props( $props );
634
-		$order->set_status( wc_clean( wp_unslash( $_POST['order_status'] ) ), '', true );
633
+		$order->set_props($props);
634
+		$order->set_status(wc_clean(wp_unslash($_POST['order_status'])), '', true);
635 635
 		$order->save();
636 636
 	}
637 637
 }
Please login to merge, or discard this patch.
woocommerce/includes/admin/meta-boxes/class-wc-meta-box-product-reviews.php 2 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -14,47 +14,47 @@
 block discarded – undo
14 14
  */
15 15
 class WC_Meta_Box_Product_Reviews {
16 16
 
17
-	/**
18
-	 * Output the metabox.
19
-	 *
20
-	 * @param object $comment Comment being shown.
21
-	 */
22
-	public static function output( $comment ) {
23
-		wp_nonce_field( 'woocommerce_save_data', 'woocommerce_meta_nonce' );
24
-
25
-		$current = get_comment_meta( $comment->comment_ID, 'rating', true );
26
-		?>
17
+    /**
18
+     * Output the metabox.
19
+     *
20
+     * @param object $comment Comment being shown.
21
+     */
22
+    public static function output( $comment ) {
23
+        wp_nonce_field( 'woocommerce_save_data', 'woocommerce_meta_nonce' );
24
+
25
+        $current = get_comment_meta( $comment->comment_ID, 'rating', true );
26
+        ?>
27 27
 		<select name="rating" id="rating">
28 28
 			<?php
29
-			for ( $rating = 1; $rating <= 5; $rating ++ ) {
30
-				printf( '<option value="%1$s"%2$s>%1$s</option>', $rating, selected( $current, $rating, false ) ); // WPCS: XSS ok.
31
-			}
32
-			?>
29
+            for ( $rating = 1; $rating <= 5; $rating ++ ) {
30
+                printf( '<option value="%1$s"%2$s>%1$s</option>', $rating, selected( $current, $rating, false ) ); // WPCS: XSS ok.
31
+            }
32
+            ?>
33 33
 		</select>
34 34
 		<?php
35
-	}
36
-
37
-	/**
38
-	 * Save meta box data
39
-	 *
40
-	 * @param mixed $data Data to save.
41
-	 * @return mixed
42
-	 */
43
-	public static function save( $data ) {
44
-		// Not allowed, return regular value without updating meta.
45
-		if ( ! isset( $_POST['woocommerce_meta_nonce'], $_POST['rating'] ) || ! wp_verify_nonce( wp_unslash( $_POST['woocommerce_meta_nonce'] ), 'woocommerce_save_data' ) ) { // WPCS: input var ok, sanitization ok.
46
-			return $data;
47
-		}
48
-
49
-		if ( $_POST['rating'] > 5 || $_POST['rating'] < 0 ) { // WPCS: input var ok.
50
-			return $data;
51
-		}
52
-
53
-		$comment_id = $data['comment_ID'];
54
-
55
-		update_comment_meta( $comment_id, 'rating', intval( wp_unslash( $_POST['rating'] ) ) ); // WPCS: input var ok.
56
-
57
-		// Return regular value after updating.
58
-		return $data;
59
-	}
35
+    }
36
+
37
+    /**
38
+     * Save meta box data
39
+     *
40
+     * @param mixed $data Data to save.
41
+     * @return mixed
42
+     */
43
+    public static function save( $data ) {
44
+        // Not allowed, return regular value without updating meta.
45
+        if ( ! isset( $_POST['woocommerce_meta_nonce'], $_POST['rating'] ) || ! wp_verify_nonce( wp_unslash( $_POST['woocommerce_meta_nonce'] ), 'woocommerce_save_data' ) ) { // WPCS: input var ok, sanitization ok.
46
+            return $data;
47
+        }
48
+
49
+        if ( $_POST['rating'] > 5 || $_POST['rating'] < 0 ) { // WPCS: input var ok.
50
+            return $data;
51
+        }
52
+
53
+        $comment_id = $data['comment_ID'];
54
+
55
+        update_comment_meta( $comment_id, 'rating', intval( wp_unslash( $_POST['rating'] ) ) ); // WPCS: input var ok.
56
+
57
+        // Return regular value after updating.
58
+        return $data;
59
+    }
60 60
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * @package WooCommerce\Admin\Meta Boxes
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 /**
13 13
  * WC_Meta_Box_Product_Reviews
@@ -19,15 +19,15 @@  discard block
 block discarded – undo
19 19
 	 *
20 20
 	 * @param object $comment Comment being shown.
21 21
 	 */
22
-	public static function output( $comment ) {
23
-		wp_nonce_field( 'woocommerce_save_data', 'woocommerce_meta_nonce' );
22
+	public static function output($comment) {
23
+		wp_nonce_field('woocommerce_save_data', 'woocommerce_meta_nonce');
24 24
 
25
-		$current = get_comment_meta( $comment->comment_ID, 'rating', true );
25
+		$current = get_comment_meta($comment->comment_ID, 'rating', true);
26 26
 		?>
27 27
 		<select name="rating" id="rating">
28 28
 			<?php
29
-			for ( $rating = 1; $rating <= 5; $rating ++ ) {
30
-				printf( '<option value="%1$s"%2$s>%1$s</option>', $rating, selected( $current, $rating, false ) ); // WPCS: XSS ok.
29
+			for ($rating = 1; $rating <= 5; $rating++) {
30
+				printf('<option value="%1$s"%2$s>%1$s</option>', $rating, selected($current, $rating, false)); // WPCS: XSS ok.
31 31
 			}
32 32
 			?>
33 33
 		</select>
@@ -40,19 +40,19 @@  discard block
 block discarded – undo
40 40
 	 * @param mixed $data Data to save.
41 41
 	 * @return mixed
42 42
 	 */
43
-	public static function save( $data ) {
43
+	public static function save($data) {
44 44
 		// Not allowed, return regular value without updating meta.
45
-		if ( ! isset( $_POST['woocommerce_meta_nonce'], $_POST['rating'] ) || ! wp_verify_nonce( wp_unslash( $_POST['woocommerce_meta_nonce'] ), 'woocommerce_save_data' ) ) { // WPCS: input var ok, sanitization ok.
45
+		if (!isset($_POST['woocommerce_meta_nonce'], $_POST['rating']) || !wp_verify_nonce(wp_unslash($_POST['woocommerce_meta_nonce']), 'woocommerce_save_data')) { // WPCS: input var ok, sanitization ok.
46 46
 			return $data;
47 47
 		}
48 48
 
49
-		if ( $_POST['rating'] > 5 || $_POST['rating'] < 0 ) { // WPCS: input var ok.
49
+		if ($_POST['rating'] > 5 || $_POST['rating'] < 0) { // WPCS: input var ok.
50 50
 			return $data;
51 51
 		}
52 52
 
53 53
 		$comment_id = $data['comment_ID'];
54 54
 
55
-		update_comment_meta( $comment_id, 'rating', intval( wp_unslash( $_POST['rating'] ) ) ); // WPCS: input var ok.
55
+		update_comment_meta($comment_id, 'rating', intval(wp_unslash($_POST['rating']))); // WPCS: input var ok.
56 56
 
57 57
 		// Return regular value after updating.
58 58
 		return $data;
Please login to merge, or discard this patch.
woocommerce/includes/admin/meta-boxes/class-wc-meta-box-order-downloads.php 2 patches
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  */
10 10
 
11 11
 if ( ! defined( 'ABSPATH' ) ) {
12
-	exit; // Exit if accessed directly
12
+    exit; // Exit if accessed directly
13 13
 }
14 14
 
15 15
 /**
@@ -17,52 +17,52 @@  discard block
 block discarded – undo
17 17
  */
18 18
 class WC_Meta_Box_Order_Downloads {
19 19
 
20
-	/**
21
-	 * Output the metabox.
22
-	 *
23
-	 * @param WP_Post $post
24
-	 */
25
-	public static function output( $post ) {
26
-		?>
20
+    /**
21
+     * Output the metabox.
22
+     *
23
+     * @param WP_Post $post
24
+     */
25
+    public static function output( $post ) {
26
+        ?>
27 27
 		<div class="order_download_permissions wc-metaboxes-wrapper">
28 28
 
29 29
 			<div class="wc-metaboxes">
30 30
 				<?php
31
-				$data_store           = WC_Data_Store::load( 'customer-download' );
32
-				$download_permissions = $data_store->get_downloads(
33
-					array(
34
-						'order_id' => $post->ID,
35
-						'orderby'  => 'product_id',
36
-					)
37
-				);
31
+                $data_store           = WC_Data_Store::load( 'customer-download' );
32
+                $download_permissions = $data_store->get_downloads(
33
+                    array(
34
+                        'order_id' => $post->ID,
35
+                        'orderby'  => 'product_id',
36
+                    )
37
+                );
38 38
 
39
-				$product      = null;
40
-				$loop         = 0;
41
-				$file_counter = 1;
39
+                $product      = null;
40
+                $loop         = 0;
41
+                $file_counter = 1;
42 42
 
43
-				if ( $download_permissions && sizeof( $download_permissions ) > 0 ) {
44
-					foreach ( $download_permissions as $download ) {
45
-						if ( ! $product || $product->get_id() !== $download->get_product_id() ) {
46
-							$product      = wc_get_product( $download->get_product_id() );
47
-							$file_counter = 1;
48
-						}
43
+                if ( $download_permissions && sizeof( $download_permissions ) > 0 ) {
44
+                    foreach ( $download_permissions as $download ) {
45
+                        if ( ! $product || $product->get_id() !== $download->get_product_id() ) {
46
+                            $product      = wc_get_product( $download->get_product_id() );
47
+                            $file_counter = 1;
48
+                        }
49 49
 
50
-						// don't show permissions to files that have since been removed.
51
-						if ( ! $product || ! $product->exists() || ! $product->has_file( $download->get_download_id() ) ) {
52
-							continue;
53
-						}
50
+                        // don't show permissions to files that have since been removed.
51
+                        if ( ! $product || ! $product->exists() || ! $product->has_file( $download->get_download_id() ) ) {
52
+                            continue;
53
+                        }
54 54
 
55
-						// Show file title instead of count if set.
56
-						$file       = $product->get_file( $download->get_download_id() );
57
-						$file_count = isset( $file['name'] ) ? $file['name'] : sprintf( __( 'File %d', 'woocommerce' ), $file_counter );
55
+                        // Show file title instead of count if set.
56
+                        $file       = $product->get_file( $download->get_download_id() );
57
+                        $file_count = isset( $file['name'] ) ? $file['name'] : sprintf( __( 'File %d', 'woocommerce' ), $file_counter );
58 58
 
59
-						include __DIR__ . '/views/html-order-download-permission.php';
59
+                        include __DIR__ . '/views/html-order-download-permission.php';
60 60
 
61
-						$loop++;
62
-						$file_counter++;
63
-					}
64
-				}
65
-				?>
61
+                        $loop++;
62
+                        $file_counter++;
63
+                    }
64
+                }
65
+                ?>
66 66
 			</div>
67 67
 
68 68
 			<div class="toolbar">
@@ -77,30 +77,30 @@  discard block
 block discarded – undo
77 77
 
78 78
 		</div>
79 79
 		<?php
80
-	}
80
+    }
81 81
 
82
-	/**
83
-	 * Save meta box data.
84
-	 *
85
-	 * @param int     $post_id
86
-	 * @param WP_Post $post
87
-	 */
88
-	public static function save( $post_id, $post ) {
89
-		if ( isset( $_POST['permission_id'] ) ) {
90
-			$permission_ids      = $_POST['permission_id'];
91
-			$downloads_remaining = $_POST['downloads_remaining'];
92
-			$access_expires      = $_POST['access_expires'];
93
-			$max                 = max( array_keys( $permission_ids ) );
82
+    /**
83
+     * Save meta box data.
84
+     *
85
+     * @param int     $post_id
86
+     * @param WP_Post $post
87
+     */
88
+    public static function save( $post_id, $post ) {
89
+        if ( isset( $_POST['permission_id'] ) ) {
90
+            $permission_ids      = $_POST['permission_id'];
91
+            $downloads_remaining = $_POST['downloads_remaining'];
92
+            $access_expires      = $_POST['access_expires'];
93
+            $max                 = max( array_keys( $permission_ids ) );
94 94
 
95
-			for ( $i = 0; $i <= $max; $i ++ ) {
96
-				if ( ! isset( $permission_ids[ $i ] ) ) {
97
-					continue;
98
-				}
99
-				$download = new WC_Customer_Download( $permission_ids[ $i ] );
100
-				$download->set_downloads_remaining( wc_clean( $downloads_remaining[ $i ] ) );
101
-				$download->set_access_expires( array_key_exists( $i, $access_expires ) && '' !== $access_expires[ $i ] ? strtotime( $access_expires[ $i ] ) : '' );
102
-				$download->save();
103
-			}
104
-		}
105
-	}
95
+            for ( $i = 0; $i <= $max; $i ++ ) {
96
+                if ( ! isset( $permission_ids[ $i ] ) ) {
97
+                    continue;
98
+                }
99
+                $download = new WC_Customer_Download( $permission_ids[ $i ] );
100
+                $download->set_downloads_remaining( wc_clean( $downloads_remaining[ $i ] ) );
101
+                $download->set_access_expires( array_key_exists( $i, $access_expires ) && '' !== $access_expires[ $i ] ? strtotime( $access_expires[ $i ] ) : '' );
102
+                $download->save();
103
+            }
104
+        }
105
+    }
106 106
 }
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @version     2.1.0
9 9
  */
10 10
 
11
-if ( ! defined( 'ABSPATH' ) ) {
11
+if (!defined('ABSPATH')) {
12 12
 	exit; // Exit if accessed directly
13 13
 }
14 14
 
@@ -22,13 +22,13 @@  discard block
 block discarded – undo
22 22
 	 *
23 23
 	 * @param WP_Post $post
24 24
 	 */
25
-	public static function output( $post ) {
25
+	public static function output($post) {
26 26
 		?>
27 27
 		<div class="order_download_permissions wc-metaboxes-wrapper">
28 28
 
29 29
 			<div class="wc-metaboxes">
30 30
 				<?php
31
-				$data_store           = WC_Data_Store::load( 'customer-download' );
31
+				$data_store           = WC_Data_Store::load('customer-download');
32 32
 				$download_permissions = $data_store->get_downloads(
33 33
 					array(
34 34
 						'order_id' => $post->ID,
@@ -40,21 +40,21 @@  discard block
 block discarded – undo
40 40
 				$loop         = 0;
41 41
 				$file_counter = 1;
42 42
 
43
-				if ( $download_permissions && sizeof( $download_permissions ) > 0 ) {
44
-					foreach ( $download_permissions as $download ) {
45
-						if ( ! $product || $product->get_id() !== $download->get_product_id() ) {
46
-							$product      = wc_get_product( $download->get_product_id() );
43
+				if ($download_permissions && sizeof($download_permissions) > 0) {
44
+					foreach ($download_permissions as $download) {
45
+						if (!$product || $product->get_id() !== $download->get_product_id()) {
46
+							$product      = wc_get_product($download->get_product_id());
47 47
 							$file_counter = 1;
48 48
 						}
49 49
 
50 50
 						// don't show permissions to files that have since been removed.
51
-						if ( ! $product || ! $product->exists() || ! $product->has_file( $download->get_download_id() ) ) {
51
+						if (!$product || !$product->exists() || !$product->has_file($download->get_download_id())) {
52 52
 							continue;
53 53
 						}
54 54
 
55 55
 						// Show file title instead of count if set.
56
-						$file       = $product->get_file( $download->get_download_id() );
57
-						$file_count = isset( $file['name'] ) ? $file['name'] : sprintf( __( 'File %d', 'woocommerce' ), $file_counter );
56
+						$file       = $product->get_file($download->get_download_id());
57
+						$file_count = isset($file['name']) ? $file['name'] : sprintf(__('File %d', 'woocommerce'), $file_counter);
58 58
 
59 59
 						include __DIR__ . '/views/html-order-download-permission.php';
60 60
 
@@ -67,9 +67,9 @@  discard block
 block discarded – undo
67 67
 
68 68
 			<div class="toolbar">
69 69
 				<p class="buttons">
70
-					<select id="grant_access_id" class="wc-product-search" name="grant_access_id[]" multiple="multiple" style="width: 400px;" data-placeholder="<?php esc_attr_e( 'Search for a downloadable product&hellip;', 'woocommerce' ); ?>" data-action="woocommerce_json_search_downloadable_products_and_variations"></select>
70
+					<select id="grant_access_id" class="wc-product-search" name="grant_access_id[]" multiple="multiple" style="width: 400px;" data-placeholder="<?php esc_attr_e('Search for a downloadable product&hellip;', 'woocommerce'); ?>" data-action="woocommerce_json_search_downloadable_products_and_variations"></select>
71 71
 					<button type="button" class="button grant_access">
72
-						<?php _e( 'Grant access', 'woocommerce' ); ?>
72
+						<?php _e('Grant access', 'woocommerce'); ?>
73 73
 					</button>
74 74
 				</p>
75 75
 				<div class="clear"></div>
@@ -85,20 +85,20 @@  discard block
 block discarded – undo
85 85
 	 * @param int     $post_id
86 86
 	 * @param WP_Post $post
87 87
 	 */
88
-	public static function save( $post_id, $post ) {
89
-		if ( isset( $_POST['permission_id'] ) ) {
88
+	public static function save($post_id, $post) {
89
+		if (isset($_POST['permission_id'])) {
90 90
 			$permission_ids      = $_POST['permission_id'];
91 91
 			$downloads_remaining = $_POST['downloads_remaining'];
92 92
 			$access_expires      = $_POST['access_expires'];
93
-			$max                 = max( array_keys( $permission_ids ) );
93
+			$max                 = max(array_keys($permission_ids));
94 94
 
95
-			for ( $i = 0; $i <= $max; $i ++ ) {
96
-				if ( ! isset( $permission_ids[ $i ] ) ) {
95
+			for ($i = 0; $i <= $max; $i++) {
96
+				if (!isset($permission_ids[$i])) {
97 97
 					continue;
98 98
 				}
99
-				$download = new WC_Customer_Download( $permission_ids[ $i ] );
100
-				$download->set_downloads_remaining( wc_clean( $downloads_remaining[ $i ] ) );
101
-				$download->set_access_expires( array_key_exists( $i, $access_expires ) && '' !== $access_expires[ $i ] ? strtotime( $access_expires[ $i ] ) : '' );
99
+				$download = new WC_Customer_Download($permission_ids[$i]);
100
+				$download->set_downloads_remaining(wc_clean($downloads_remaining[$i]));
101
+				$download->set_access_expires(array_key_exists($i, $access_expires) && '' !== $access_expires[$i] ? strtotime($access_expires[$i]) : '');
102 102
 				$download->save();
103 103
 			}
104 104
 		}
Please login to merge, or discard this patch.