1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* WooCommerce advanced settings |
4
|
|
|
* |
5
|
|
|
* @package WooCommerce/Admin |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
defined( 'ABSPATH' ) || exit; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Settings for API. |
12
|
|
|
*/ |
13
|
|
|
if ( class_exists( 'WC_Settings_Advanced', false ) ) { |
14
|
|
|
return new WC_Settings_Advanced(); |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* WC_Settings_Advanced. |
19
|
|
|
*/ |
20
|
|
|
class WC_Settings_Advanced extends WC_Settings_Page { |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Constructor. |
24
|
|
|
*/ |
25
|
|
|
public function __construct() { |
26
|
|
|
$this->id = 'advanced'; |
27
|
|
|
$this->label = __( 'Advanced', 'woocommerce' ); |
28
|
|
|
|
29
|
|
|
parent::__construct(); |
30
|
|
|
$this->notices(); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Get sections. |
35
|
|
|
* |
36
|
|
|
* @return array |
37
|
|
|
*/ |
38
|
2 |
|
public function get_sections() { |
39
|
|
|
$sections = array( |
40
|
2 |
|
'' => __( 'Page setup', 'woocommerce' ), |
41
|
2 |
|
'keys' => __( 'REST API', 'woocommerce' ), |
42
|
2 |
|
'webhooks' => __( 'Webhooks', 'woocommerce' ), |
43
|
2 |
|
'legacy_api' => __( 'Legacy API', 'woocommerce' ), |
44
|
2 |
|
'woocommerce_com' => __( 'WooCommerce.com', 'woocommerce' ), |
45
|
|
|
); |
46
|
|
|
|
47
|
2 |
|
return apply_filters( 'woocommerce_get_sections_' . $this->id, $sections ); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Get settings array. |
52
|
|
|
* |
53
|
|
|
* @param string $current_section Current section slug. |
54
|
|
|
* |
55
|
|
|
* @return array |
56
|
|
|
*/ |
57
|
2 |
|
public function get_settings( $current_section = '' ) { |
58
|
2 |
|
$settings = array(); |
59
|
|
|
|
60
|
2 |
|
if ( '' === $current_section ) { |
61
|
2 |
|
$settings = apply_filters( |
62
|
2 |
|
'woocommerce_settings_pages', |
63
|
|
|
array( |
64
|
|
|
|
65
|
|
|
array( |
66
|
2 |
|
'title' => __( 'Page setup', 'woocommerce' ), |
67
|
2 |
|
'desc' => __( 'These pages need to be set so that WooCommerce knows where to send users to checkout.', 'woocommerce' ), |
68
|
2 |
|
'type' => 'title', |
69
|
2 |
|
'id' => 'advanced_page_options', |
70
|
|
|
), |
71
|
|
|
|
72
|
|
|
array( |
73
|
2 |
|
'title' => __( 'Cart page', 'woocommerce' ), |
74
|
|
|
/* Translators: %s Page contents. */ |
75
|
2 |
|
'desc' => sprintf( __( 'Page contents: [%s]', 'woocommerce' ), apply_filters( 'woocommerce_cart_shortcode_tag', 'woocommerce_cart' ) ), |
76
|
2 |
|
'id' => 'woocommerce_cart_page_id', |
77
|
2 |
|
'type' => 'single_select_page', |
78
|
2 |
|
'default' => '', |
79
|
2 |
|
'class' => 'wc-enhanced-select-nostd', |
80
|
2 |
|
'css' => 'min-width:300px;', |
81
|
|
|
'args' => array( |
82
|
|
|
'exclude' => |
83
|
|
|
array( |
84
|
2 |
|
wc_get_page_id( 'checkout' ), |
85
|
2 |
|
wc_get_page_id( 'myaccount' ), |
86
|
|
|
), |
87
|
|
|
), |
88
|
|
|
'desc_tip' => true, |
89
|
|
|
'autoload' => false, |
90
|
|
|
), |
91
|
|
|
|
92
|
|
|
array( |
93
|
2 |
|
'title' => __( 'Checkout page', 'woocommerce' ), |
94
|
|
|
/* Translators: %s Page contents. */ |
95
|
2 |
|
'desc' => sprintf( __( 'Page contents: [%s]', 'woocommerce' ), apply_filters( 'woocommerce_checkout_shortcode_tag', 'woocommerce_checkout' ) ), |
96
|
2 |
|
'id' => 'woocommerce_checkout_page_id', |
97
|
2 |
|
'type' => 'single_select_page', |
98
|
2 |
|
'default' => '', |
99
|
2 |
|
'class' => 'wc-enhanced-select-nostd', |
100
|
2 |
|
'css' => 'min-width:300px;', |
101
|
|
|
'args' => array( |
102
|
|
|
'exclude' => |
103
|
|
|
array( |
104
|
2 |
|
wc_get_page_id( 'cart' ), |
105
|
2 |
|
wc_get_page_id( 'myaccount' ), |
106
|
|
|
), |
107
|
|
|
), |
108
|
|
|
'desc_tip' => true, |
109
|
|
|
'autoload' => false, |
110
|
|
|
), |
111
|
|
|
|
112
|
|
|
array( |
113
|
2 |
|
'title' => __( 'My account page', 'woocommerce' ), |
114
|
|
|
/* Translators: %s Page contents. */ |
115
|
2 |
|
'desc' => sprintf( __( 'Page contents: [%s]', 'woocommerce' ), apply_filters( 'woocommerce_my_account_shortcode_tag', 'woocommerce_my_account' ) ), |
116
|
2 |
|
'id' => 'woocommerce_myaccount_page_id', |
117
|
2 |
|
'type' => 'single_select_page', |
118
|
2 |
|
'default' => '', |
119
|
2 |
|
'class' => 'wc-enhanced-select-nostd', |
120
|
2 |
|
'css' => 'min-width:300px;', |
121
|
|
|
'args' => array( |
122
|
|
|
'exclude' => |
123
|
|
|
array( |
124
|
2 |
|
wc_get_page_id( 'cart' ), |
125
|
2 |
|
wc_get_page_id( 'checkout' ), |
126
|
|
|
), |
127
|
|
|
), |
128
|
|
|
'desc_tip' => true, |
129
|
|
|
'autoload' => false, |
130
|
|
|
), |
131
|
|
|
|
132
|
|
|
array( |
133
|
2 |
|
'title' => __( 'Terms and conditions', 'woocommerce' ), |
134
|
2 |
|
'desc' => __( 'If you define a "Terms" page the customer will be asked if they accept them when checking out.', 'woocommerce' ), |
135
|
2 |
|
'id' => 'woocommerce_terms_page_id', |
136
|
2 |
|
'default' => '', |
137
|
2 |
|
'class' => 'wc-enhanced-select-nostd', |
138
|
2 |
|
'css' => 'min-width:300px;', |
139
|
2 |
|
'type' => 'single_select_page', |
140
|
2 |
|
'args' => array( 'exclude' => wc_get_page_id( 'checkout' ) ), |
141
|
|
|
'desc_tip' => true, |
142
|
|
|
'autoload' => false, |
143
|
|
|
), |
144
|
|
|
|
145
|
|
|
array( |
146
|
|
|
'type' => 'sectionend', |
147
|
|
|
'id' => 'advanced_page_options', |
148
|
|
|
), |
149
|
|
|
|
150
|
|
|
array( |
151
|
|
|
'title' => '', |
152
|
|
|
'type' => 'title', |
153
|
|
|
'id' => 'checkout_process_options', |
154
|
|
|
), |
155
|
|
|
|
156
|
|
|
'force_ssl_checkout' => array( |
157
|
2 |
|
'title' => __( 'Secure checkout', 'woocommerce' ), |
158
|
2 |
|
'desc' => __( 'Force secure checkout', 'woocommerce' ), |
159
|
2 |
|
'id' => 'woocommerce_force_ssl_checkout', |
160
|
2 |
|
'default' => 'no', |
161
|
2 |
|
'type' => 'checkbox', |
162
|
2 |
|
'checkboxgroup' => 'start', |
163
|
2 |
|
'show_if_checked' => 'option', |
164
|
|
|
/* Translators: %s Docs URL. */ |
165
|
2 |
|
'desc_tip' => sprintf( __( 'Force SSL (HTTPS) on the checkout pages (<a href="%s" target="_blank">an SSL Certificate is required</a>).', 'woocommerce' ), 'https://docs.woocommerce.com/document/ssl-and-https/#section-3' ), |
166
|
|
|
), |
167
|
|
|
|
168
|
|
|
'unforce_ssl_checkout' => array( |
169
|
2 |
|
'desc' => __( 'Force HTTP when leaving the checkout', 'woocommerce' ), |
170
|
2 |
|
'id' => 'woocommerce_unforce_ssl_checkout', |
171
|
2 |
|
'default' => 'no', |
172
|
2 |
|
'type' => 'checkbox', |
173
|
2 |
|
'checkboxgroup' => 'end', |
174
|
2 |
|
'show_if_checked' => 'yes', |
175
|
|
|
), |
176
|
|
|
|
177
|
|
|
array( |
178
|
|
|
'type' => 'sectionend', |
179
|
|
|
'id' => 'checkout_process_options', |
180
|
|
|
), |
181
|
|
|
|
182
|
|
|
array( |
183
|
2 |
|
'title' => __( 'Checkout endpoints', 'woocommerce' ), |
184
|
2 |
|
'type' => 'title', |
185
|
2 |
|
'desc' => __( 'Endpoints are appended to your page URLs to handle specific actions during the checkout process. They should be unique.', 'woocommerce' ), |
186
|
2 |
|
'id' => 'account_endpoint_options', |
187
|
|
|
), |
188
|
|
|
|
189
|
|
|
array( |
190
|
2 |
|
'title' => __( 'Pay', 'woocommerce' ), |
191
|
2 |
|
'desc' => __( 'Endpoint for the "Checkout → Pay" page.', 'woocommerce' ), |
192
|
2 |
|
'id' => 'woocommerce_checkout_pay_endpoint', |
193
|
2 |
|
'type' => 'text', |
194
|
2 |
|
'default' => 'order-pay', |
195
|
|
|
'desc_tip' => true, |
196
|
|
|
), |
197
|
|
|
|
198
|
|
|
array( |
199
|
2 |
|
'title' => __( 'Order received', 'woocommerce' ), |
200
|
2 |
|
'desc' => __( 'Endpoint for the "Checkout → Order received" page.', 'woocommerce' ), |
201
|
2 |
|
'id' => 'woocommerce_checkout_order_received_endpoint', |
202
|
2 |
|
'type' => 'text', |
203
|
2 |
|
'default' => 'order-received', |
204
|
|
|
'desc_tip' => true, |
205
|
|
|
), |
206
|
|
|
|
207
|
|
|
array( |
208
|
2 |
|
'title' => __( 'Add payment method', 'woocommerce' ), |
209
|
2 |
|
'desc' => __( 'Endpoint for the "Checkout → Add payment method" page.', 'woocommerce' ), |
210
|
2 |
|
'id' => 'woocommerce_myaccount_add_payment_method_endpoint', |
211
|
2 |
|
'type' => 'text', |
212
|
2 |
|
'default' => 'add-payment-method', |
213
|
|
|
'desc_tip' => true, |
214
|
|
|
), |
215
|
|
|
|
216
|
|
|
array( |
217
|
2 |
|
'title' => __( 'Delete payment method', 'woocommerce' ), |
218
|
2 |
|
'desc' => __( 'Endpoint for the delete payment method page.', 'woocommerce' ), |
219
|
2 |
|
'id' => 'woocommerce_myaccount_delete_payment_method_endpoint', |
220
|
2 |
|
'type' => 'text', |
221
|
2 |
|
'default' => 'delete-payment-method', |
222
|
|
|
'desc_tip' => true, |
223
|
|
|
), |
224
|
|
|
|
225
|
|
|
array( |
226
|
2 |
|
'title' => __( 'Set default payment method', 'woocommerce' ), |
227
|
2 |
|
'desc' => __( 'Endpoint for the setting a default payment method page.', 'woocommerce' ), |
228
|
2 |
|
'id' => 'woocommerce_myaccount_set_default_payment_method_endpoint', |
229
|
2 |
|
'type' => 'text', |
230
|
2 |
|
'default' => 'set-default-payment-method', |
231
|
|
|
'desc_tip' => true, |
232
|
|
|
), |
233
|
|
|
|
234
|
|
|
array( |
235
|
|
|
'type' => 'sectionend', |
236
|
|
|
'id' => 'checkout_endpoint_options', |
237
|
|
|
), |
238
|
|
|
|
239
|
|
|
array( |
240
|
2 |
|
'title' => __( 'Account endpoints', 'woocommerce' ), |
241
|
2 |
|
'type' => 'title', |
242
|
2 |
|
'desc' => __( 'Endpoints are appended to your page URLs to handle specific actions on the accounts pages. They should be unique and can be left blank to disable the endpoint.', 'woocommerce' ), |
243
|
2 |
|
'id' => 'account_endpoint_options', |
244
|
|
|
), |
245
|
|
|
|
246
|
|
|
array( |
247
|
2 |
|
'title' => __( 'Orders', 'woocommerce' ), |
248
|
2 |
|
'desc' => __( 'Endpoint for the "My account → Orders" page.', 'woocommerce' ), |
249
|
2 |
|
'id' => 'woocommerce_myaccount_orders_endpoint', |
250
|
2 |
|
'type' => 'text', |
251
|
2 |
|
'default' => 'orders', |
252
|
|
|
'desc_tip' => true, |
253
|
|
|
), |
254
|
|
|
|
255
|
|
|
array( |
256
|
2 |
|
'title' => __( 'View order', 'woocommerce' ), |
257
|
2 |
|
'desc' => __( 'Endpoint for the "My account → View order" page.', 'woocommerce' ), |
258
|
2 |
|
'id' => 'woocommerce_myaccount_view_order_endpoint', |
259
|
2 |
|
'type' => 'text', |
260
|
2 |
|
'default' => 'view-order', |
261
|
|
|
'desc_tip' => true, |
262
|
|
|
), |
263
|
|
|
|
264
|
|
|
array( |
265
|
2 |
|
'title' => __( 'Downloads', 'woocommerce' ), |
266
|
2 |
|
'desc' => __( 'Endpoint for the "My account → Downloads" page.', 'woocommerce' ), |
267
|
2 |
|
'id' => 'woocommerce_myaccount_downloads_endpoint', |
268
|
2 |
|
'type' => 'text', |
269
|
2 |
|
'default' => 'downloads', |
270
|
|
|
'desc_tip' => true, |
271
|
|
|
), |
272
|
|
|
|
273
|
|
|
array( |
274
|
2 |
|
'title' => __( 'Edit account', 'woocommerce' ), |
275
|
2 |
|
'desc' => __( 'Endpoint for the "My account → Edit account" page.', 'woocommerce' ), |
276
|
2 |
|
'id' => 'woocommerce_myaccount_edit_account_endpoint', |
277
|
2 |
|
'type' => 'text', |
278
|
2 |
|
'default' => 'edit-account', |
279
|
|
|
'desc_tip' => true, |
280
|
|
|
), |
281
|
|
|
|
282
|
|
|
array( |
283
|
2 |
|
'title' => __( 'Addresses', 'woocommerce' ), |
284
|
2 |
|
'desc' => __( 'Endpoint for the "My account → Addresses" page.', 'woocommerce' ), |
285
|
2 |
|
'id' => 'woocommerce_myaccount_edit_address_endpoint', |
286
|
2 |
|
'type' => 'text', |
287
|
2 |
|
'default' => 'edit-address', |
288
|
|
|
'desc_tip' => true, |
289
|
|
|
), |
290
|
|
|
|
291
|
|
|
array( |
292
|
2 |
|
'title' => __( 'Payment methods', 'woocommerce' ), |
293
|
2 |
|
'desc' => __( 'Endpoint for the "My account → Payment methods" page.', 'woocommerce' ), |
294
|
2 |
|
'id' => 'woocommerce_myaccount_payment_methods_endpoint', |
295
|
2 |
|
'type' => 'text', |
296
|
2 |
|
'default' => 'payment-methods', |
297
|
|
|
'desc_tip' => true, |
298
|
|
|
), |
299
|
|
|
|
300
|
|
|
array( |
301
|
2 |
|
'title' => __( 'Lost password', 'woocommerce' ), |
302
|
2 |
|
'desc' => __( 'Endpoint for the "My account → Lost password" page.', 'woocommerce' ), |
303
|
2 |
|
'id' => 'woocommerce_myaccount_lost_password_endpoint', |
304
|
2 |
|
'type' => 'text', |
305
|
2 |
|
'default' => 'lost-password', |
306
|
|
|
'desc_tip' => true, |
307
|
|
|
), |
308
|
|
|
|
309
|
|
|
array( |
310
|
2 |
|
'title' => __( 'Logout', 'woocommerce' ), |
311
|
2 |
|
'desc' => __( 'Endpoint for the triggering logout. You can add this to your menus via a custom link: yoursite.com/?customer-logout=true', 'woocommerce' ), |
312
|
2 |
|
'id' => 'woocommerce_logout_endpoint', |
313
|
2 |
|
'type' => 'text', |
314
|
2 |
|
'default' => 'customer-logout', |
315
|
|
|
'desc_tip' => true, |
316
|
|
|
), |
317
|
|
|
|
318
|
|
|
array( |
319
|
|
|
'type' => 'sectionend', |
320
|
|
|
'id' => 'account_endpoint_options', |
321
|
|
|
), |
322
|
|
|
) |
323
|
|
|
); |
324
|
|
|
|
325
|
2 |
|
if ( wc_site_is_https() ) { |
326
|
2 |
|
unset( $settings['unforce_ssl_checkout'], $settings['force_ssl_checkout'] ); |
327
|
|
|
} |
328
|
2 |
|
} elseif ( 'woocommerce_com' === $current_section ) { |
329
|
2 |
|
$tracking_info_text = sprintf( '<a href="%s" target="_blank">%s</a>', 'https://woocommerce.com/usage-tracking', esc_html__( 'WooCommerce.com Usage Tracking Documentation', 'woocommerce' ) ); |
330
|
|
|
|
331
|
2 |
|
$settings = apply_filters( |
332
|
2 |
|
'woocommerce_com_integration_settings', |
333
|
|
|
array( |
334
|
|
|
array( |
335
|
2 |
|
'title' => esc_html__( 'Usage Tracking', 'woocommerce' ), |
336
|
2 |
|
'type' => 'title', |
337
|
2 |
|
'id' => 'tracking_options', |
338
|
2 |
|
'desc' => __( 'Gathering usage data allows us to make WooCommerce better — your store will be considered as we evaluate new features, judge the quality of an update, or determine if an improvement makes sense.', 'woocommerce' ), |
339
|
|
|
), |
340
|
|
|
array( |
341
|
2 |
|
'title' => __( 'Enable tracking', 'woocommerce' ), |
342
|
2 |
|
'desc' => __( 'Allow usage of WooCommerce to be tracked', 'woocommerce' ), |
343
|
|
|
/* Translators: %s URL to tracking info screen. */ |
344
|
2 |
|
'desc_tip' => sprintf( esc_html__( 'To opt out, leave this box unticked. Your store remains untracked, and no data will be collected. Read about what usage data is tracked at: %s.', 'woocommerce' ), $tracking_info_text ), |
345
|
2 |
|
'id' => 'woocommerce_allow_tracking', |
346
|
2 |
|
'type' => 'checkbox', |
347
|
2 |
|
'checkboxgroup' => 'start', |
348
|
2 |
|
'default' => 'no', |
349
|
|
|
'autoload' => false, |
350
|
|
|
), |
351
|
|
|
array( |
352
|
|
|
'type' => 'sectionend', |
353
|
|
|
'id' => 'tracking_options', |
354
|
|
|
), |
355
|
|
|
array( |
356
|
2 |
|
'title' => esc_html__( 'Marketplace suggestions', 'woocommerce' ), |
357
|
2 |
|
'type' => 'title', |
358
|
2 |
|
'id' => 'marketplace_suggestions', |
359
|
2 |
|
'desc' => __( 'We show contextual suggestions for official extensions that may be helpful to your store.', 'woocommerce' ), |
360
|
|
|
), |
361
|
|
|
array( |
362
|
2 |
|
'title' => __( 'Show Suggestions', 'woocommerce' ), |
363
|
2 |
|
'desc' => __( 'Display suggestions within WooCommerce', 'woocommerce' ), |
364
|
2 |
|
'desc_tip' => esc_html__( 'Leave this box unchecked if you do not want to see suggested extensions.', 'woocommerce' ), |
365
|
2 |
|
'id' => 'woocommerce_show_marketplace_suggestions', |
366
|
2 |
|
'type' => 'checkbox', |
367
|
2 |
|
'checkboxgroup' => 'start', |
368
|
2 |
|
'default' => 'yes', |
369
|
|
|
'autoload' => false, |
370
|
|
|
), |
371
|
|
|
array( |
372
|
|
|
'type' => 'sectionend', |
373
|
|
|
'id' => 'marketplace_suggestions', |
374
|
|
|
), |
375
|
|
|
) |
376
|
|
|
); |
377
|
2 |
|
} elseif ( 'legacy_api' === $current_section ) { |
378
|
2 |
|
$settings = apply_filters( |
379
|
2 |
|
'woocommerce_settings_rest_api', |
380
|
|
|
array( |
381
|
|
|
array( |
382
|
2 |
|
'title' => '', |
383
|
|
|
'type' => 'title', |
384
|
|
|
'desc' => '', |
385
|
|
|
'id' => 'legacy_api_options', |
386
|
|
|
), |
387
|
|
|
array( |
388
|
2 |
|
'title' => __( 'Legacy API', 'woocommerce' ), |
389
|
2 |
|
'desc' => __( 'Enable the legacy REST API', 'woocommerce' ), |
390
|
2 |
|
'id' => 'woocommerce_api_enabled', |
391
|
2 |
|
'type' => 'checkbox', |
392
|
2 |
|
'default' => 'no', |
393
|
|
|
), |
394
|
|
|
array( |
395
|
|
|
'type' => 'sectionend', |
396
|
|
|
'id' => 'legacy_api_options', |
397
|
|
|
), |
398
|
|
|
) |
399
|
|
|
); |
400
|
|
|
} |
401
|
|
|
|
402
|
2 |
|
return apply_filters( 'woocommerce_get_settings_' . $this->id, $settings, $current_section ); |
403
|
|
|
} |
404
|
|
|
|
405
|
|
|
/** |
406
|
|
|
* Form method. |
407
|
|
|
* |
408
|
|
|
* @deprecated 3.4.4 |
409
|
|
|
* |
410
|
|
|
* @param string $method Method name. |
411
|
|
|
* |
412
|
|
|
* @return string |
413
|
|
|
*/ |
414
|
|
|
public function form_method( $method ) { |
|
|
|
|
415
|
|
|
return 'post'; |
416
|
|
|
} |
417
|
|
|
|
418
|
|
|
/** |
419
|
|
|
* Notices. |
420
|
|
|
*/ |
421
|
|
|
private function notices() { |
422
|
|
|
if ( isset( $_GET['section'] ) && 'webhooks' === $_GET['section'] ) { // WPCS: input var okay, CSRF ok. |
423
|
|
|
WC_Admin_Webhooks::notices(); |
424
|
|
|
} |
425
|
|
|
if ( isset( $_GET['section'] ) && 'keys' === $_GET['section'] ) { // WPCS: input var okay, CSRF ok. |
426
|
|
|
WC_Admin_API_Keys::notices(); |
427
|
|
|
} |
428
|
|
|
} |
429
|
|
|
|
430
|
|
|
/** |
431
|
|
|
* Output the settings. |
432
|
|
|
*/ |
433
|
|
|
public function output() { |
434
|
|
|
global $current_section; |
435
|
|
|
|
436
|
|
|
if ( 'webhooks' === $current_section ) { |
437
|
|
|
WC_Admin_Webhooks::page_output(); |
438
|
|
|
} elseif ( 'keys' === $current_section ) { |
439
|
|
|
WC_Admin_API_Keys::page_output(); |
440
|
|
|
} else { |
441
|
|
|
$settings = $this->get_settings( $current_section ); |
442
|
|
|
WC_Admin_Settings::output_fields( $settings ); |
443
|
|
|
} |
444
|
|
|
} |
445
|
|
|
|
446
|
|
|
/** |
447
|
|
|
* Save settings. |
448
|
|
|
*/ |
449
|
|
|
public function save() { |
450
|
|
|
global $current_section; |
451
|
|
|
|
452
|
|
|
if ( apply_filters( 'woocommerce_rest_api_valid_to_save', ! in_array( $current_section, array( 'keys', 'webhooks' ), true ) ) ) { |
453
|
|
|
$settings = $this->get_settings( $current_section ); |
454
|
|
|
|
455
|
|
|
// Prevent the T&Cs and checkout page from being set to the same page. |
456
|
|
|
if ( isset( $_POST['woocommerce_terms_page_id'], $_POST['woocommerce_checkout_page_id'] ) && $_POST['woocommerce_terms_page_id'] === $_POST['woocommerce_checkout_page_id'] ) { // WPCS: input var ok, CSRF ok. |
457
|
|
|
$_POST['woocommerce_terms_page_id'] = ''; |
458
|
|
|
} |
459
|
|
|
|
460
|
|
|
// Prevent the Cart, checkout and my account page from being set to the same page. |
461
|
|
|
if ( isset( $_POST['woocommerce_cart_page_id'], $_POST['woocommerce_checkout_page_id'], $_POST['woocommerce_myaccount_page_id'] ) ) { // WPCS: input var ok, CSRF ok. |
462
|
|
|
if ( $_POST['woocommerce_cart_page_id'] === $_POST['woocommerce_checkout_page_id'] ) { // WPCS: input var ok, CSRF ok. |
463
|
|
|
$_POST['woocommerce_checkout_page_id'] = ''; |
464
|
|
|
} |
465
|
|
|
if ( $_POST['woocommerce_cart_page_id'] === $_POST['woocommerce_myaccount_page_id'] ) { // WPCS: input var ok, CSRF ok. |
466
|
|
|
$_POST['woocommerce_myaccount_page_id'] = ''; |
467
|
|
|
} |
468
|
|
|
if ( $_POST['woocommerce_checkout_page_id'] === $_POST['woocommerce_myaccount_page_id'] ) { // WPCS: input var ok, CSRF ok. |
469
|
|
|
$_POST['woocommerce_myaccount_page_id'] = ''; |
470
|
|
|
} |
471
|
|
|
} |
472
|
|
|
|
473
|
|
|
WC_Admin_Settings::save_fields( $settings ); |
474
|
|
|
|
475
|
|
|
if ( $current_section ) { |
476
|
|
|
do_action( 'woocommerce_update_options_' . $this->id . '_' . $current_section ); |
477
|
|
|
} |
478
|
|
|
} |
479
|
|
|
} |
480
|
|
|
} |
481
|
|
|
|
482
|
|
|
/** |
483
|
|
|
* WC_Settings_Rest_API class. |
484
|
|
|
* |
485
|
|
|
* @deprecated 3.4 in favour of WC_Settings_Advanced. |
486
|
|
|
* @todo remove in 4.0. |
487
|
|
|
*/ |
488
|
|
|
class WC_Settings_Rest_API extends WC_Settings_Advanced { |
489
|
|
|
} // @codingStandardsIgnoreLine. |
490
|
|
|
|
491
|
|
|
return new WC_Settings_Advanced(); |
492
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.