1
|
|
|
<?php |
|
|
|
|
2
|
|
|
/** |
3
|
|
|
* Deprecated functions |
4
|
|
|
* |
5
|
|
|
* Where functions come to die. |
6
|
|
|
* |
7
|
|
|
* @author WooThemes |
8
|
|
|
* @category Core |
9
|
|
|
* @package WooCommerce/Functions |
10
|
|
|
* @version 2.1.0 |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
14
|
|
|
exit; // Exit if accessed directly |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @deprecated |
19
|
|
|
*/ |
20
|
|
|
function woocommerce_show_messages() { |
21
|
|
|
_deprecated_function( 'woocommerce_show_messages', '2.1', 'wc_print_notices' ); |
22
|
|
|
wc_print_notices(); |
23
|
|
|
} |
24
|
|
|
/** |
25
|
|
|
* @deprecated |
26
|
|
|
*/ |
27
|
|
|
function woocommerce_weekend_area_js() { |
28
|
|
|
_deprecated_function( 'woocommerce_weekend_area_js', '2.1', '' ); |
29
|
|
|
} |
30
|
|
|
/** |
31
|
|
|
* @deprecated |
32
|
|
|
*/ |
33
|
|
|
function woocommerce_tooltip_js() { |
34
|
|
|
_deprecated_function( 'woocommerce_tooltip_js', '2.1', '' ); |
35
|
|
|
} |
36
|
|
|
/** |
37
|
|
|
* @deprecated |
38
|
|
|
*/ |
39
|
|
|
function woocommerce_datepicker_js() { |
40
|
|
|
_deprecated_function( 'woocommerce_datepicker_js', '2.1', '' ); |
41
|
|
|
} |
42
|
|
|
/** |
43
|
|
|
* @deprecated |
44
|
|
|
*/ |
45
|
|
|
function woocommerce_admin_scripts() { |
46
|
|
|
_deprecated_function( 'woocommerce_admin_scripts', '2.1', '' ); |
47
|
|
|
} |
48
|
|
|
/** |
49
|
|
|
* @deprecated |
50
|
|
|
*/ |
51
|
|
|
function woocommerce_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) { |
52
|
|
|
_deprecated_function( 'woocommerce_create_page', '2.1', 'wc_create_page' ); |
53
|
|
|
return wc_create_page( $slug, $option, $page_title, $page_content, $post_parent ); |
54
|
|
|
} |
55
|
|
|
/** |
56
|
|
|
* @deprecated |
57
|
|
|
*/ |
58
|
|
|
function woocommerce_readfile_chunked( $file, $retbytes = true ) { |
|
|
|
|
59
|
|
|
_deprecated_function( 'woocommerce_readfile_chunked', '2.1', 'WC_Download_Handler::readfile_chunked()' ); |
60
|
|
|
return WC_Download_Handler::readfile_chunked( $file ); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Formal total costs - format to the number of decimal places for the base currency. |
65
|
|
|
* |
66
|
|
|
* @access public |
67
|
|
|
* @param mixed $number |
68
|
|
|
* @deprecated 2.1 |
69
|
|
|
* @return string |
70
|
|
|
*/ |
71
|
|
|
function woocommerce_format_total( $number ) { |
72
|
|
|
_deprecated_function( __FUNCTION__, '2.1', 'wc_format_decimal()' ); |
73
|
|
|
return wc_format_decimal( $number, wc_get_price_decimals(), false ); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Get product name with extra details such as SKU price and attributes. Used within admin. |
78
|
|
|
* |
79
|
|
|
* @access public |
80
|
|
|
* @param WC_Product $product |
81
|
|
|
* @deprecated 2.1 |
82
|
|
|
* @return string |
83
|
|
|
*/ |
84
|
|
|
function woocommerce_get_formatted_product_name( $product ) { |
85
|
|
|
_deprecated_function( __FUNCTION__, '2.1', 'WC_Product::get_formatted_name()' ); |
86
|
|
|
return $product->get_formatted_name(); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Handle IPN requests for the legacy paypal gateway by calling gateways manually if needed. |
91
|
|
|
* |
92
|
|
|
* @access public |
93
|
|
|
*/ |
94
|
|
|
function woocommerce_legacy_paypal_ipn() { |
95
|
|
|
if ( ! empty( $_GET['paypalListener'] ) && $_GET['paypalListener'] == 'paypal_standard_IPN' ) { |
96
|
|
|
|
97
|
|
|
WC()->payment_gateways(); |
98
|
|
|
|
99
|
|
|
do_action( 'woocommerce_api_wc_gateway_paypal' ); |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
add_action( 'init', 'woocommerce_legacy_paypal_ipn' ); |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* get_product soft deprecated for wc_get_product. |
106
|
|
|
* |
107
|
|
|
* @deprecated |
108
|
|
|
*/ |
109
|
|
|
function get_product( $the_product = false, $args = array() ) { |
110
|
|
|
return wc_get_product( $the_product, $args ); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* Cart functions (soft deprecated). |
115
|
|
|
*/ |
116
|
|
|
/** |
117
|
|
|
* @deprecated |
118
|
|
|
*/ |
119
|
|
|
function woocommerce_protected_product_add_to_cart( $passed, $product_id ) { |
120
|
|
|
return wc_protected_product_add_to_cart( $passed, $product_id ); |
121
|
|
|
} |
122
|
|
|
/** |
123
|
|
|
* @deprecated |
124
|
|
|
*/ |
125
|
|
|
function woocommerce_empty_cart() { |
126
|
|
|
wc_empty_cart(); |
127
|
|
|
} |
128
|
|
|
/** |
129
|
|
|
* @deprecated |
130
|
|
|
*/ |
131
|
|
|
function woocommerce_load_persistent_cart( $user_login, $user = 0 ) { |
132
|
|
|
return wc_load_persistent_cart( $user_login, $user ); |
|
|
|
|
133
|
|
|
} |
134
|
|
|
/** |
135
|
|
|
* @deprecated |
136
|
|
|
*/ |
137
|
|
|
function woocommerce_add_to_cart_message( $product_id ) { |
138
|
|
|
wc_add_to_cart_message( $product_id ); |
139
|
|
|
} |
140
|
|
|
/** |
141
|
|
|
* @deprecated |
142
|
|
|
*/ |
143
|
|
|
function woocommerce_clear_cart_after_payment() { |
144
|
|
|
wc_clear_cart_after_payment(); |
145
|
|
|
} |
146
|
|
|
/** |
147
|
|
|
* @deprecated |
148
|
|
|
*/ |
149
|
|
|
function woocommerce_cart_totals_subtotal_html() { |
150
|
|
|
wc_cart_totals_subtotal_html(); |
151
|
|
|
} |
152
|
|
|
/** |
153
|
|
|
* @deprecated |
154
|
|
|
*/ |
155
|
|
|
function woocommerce_cart_totals_shipping_html() { |
156
|
|
|
wc_cart_totals_shipping_html(); |
157
|
|
|
} |
158
|
|
|
/** |
159
|
|
|
* @deprecated |
160
|
|
|
*/ |
161
|
|
|
function woocommerce_cart_totals_coupon_html( $coupon ) { |
162
|
|
|
wc_cart_totals_coupon_html( $coupon ); |
163
|
|
|
} |
164
|
|
|
/** |
165
|
|
|
* @deprecated |
166
|
|
|
*/ |
167
|
|
|
function woocommerce_cart_totals_order_total_html() { |
168
|
|
|
wc_cart_totals_order_total_html(); |
169
|
|
|
} |
170
|
|
|
/** |
171
|
|
|
* @deprecated |
172
|
|
|
*/ |
173
|
|
|
function woocommerce_cart_totals_fee_html( $fee ) { |
174
|
|
|
wc_cart_totals_fee_html( $fee ); |
175
|
|
|
} |
176
|
|
|
/** |
177
|
|
|
* @deprecated |
178
|
|
|
*/ |
179
|
|
|
function woocommerce_cart_totals_shipping_method_label( $method ) { |
180
|
|
|
return wc_cart_totals_shipping_method_label( $method ); |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* Core functions (soft deprecated). |
185
|
|
|
*/ |
186
|
|
|
/** |
187
|
|
|
* @deprecated |
188
|
|
|
*/ |
189
|
|
|
function woocommerce_get_template_part( $slug, $name = '' ) { |
190
|
|
|
wc_get_template_part( $slug, $name ); |
191
|
|
|
} |
192
|
|
|
/** |
193
|
|
|
* @deprecated |
194
|
|
|
*/ |
195
|
|
|
function woocommerce_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
196
|
|
|
wc_get_template( $template_name, $args, $template_path, $default_path ); |
197
|
|
|
} |
198
|
|
|
/** |
199
|
|
|
* @deprecated |
200
|
|
|
*/ |
201
|
|
|
function woocommerce_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
202
|
|
|
return wc_locate_template( $template_name, $template_path, $default_path ); |
203
|
|
|
} |
204
|
|
|
/** |
205
|
|
|
* @deprecated |
206
|
|
|
*/ |
207
|
|
|
function woocommerce_mail( $to, $subject, $message, $headers = "Content-Type: text/html\r\n", $attachments = "" ) { |
208
|
|
|
wc_mail( $to, $subject, $message, $headers, $attachments ); |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
/** |
212
|
|
|
* Customer functions (soft deprecated). |
213
|
|
|
*/ |
214
|
|
|
/** |
215
|
|
|
* @deprecated |
216
|
|
|
*/ |
217
|
|
|
function woocommerce_disable_admin_bar( $show_admin_bar ) { |
218
|
|
|
return wc_disable_admin_bar( $show_admin_bar ); |
219
|
|
|
} |
220
|
|
|
/** |
221
|
|
|
* @deprecated |
222
|
|
|
*/ |
223
|
|
|
function woocommerce_create_new_customer( $email, $username = '', $password = '' ) { |
224
|
|
|
return wc_create_new_customer( $email, $username, $password ); |
225
|
|
|
} |
226
|
|
|
/** |
227
|
|
|
* @deprecated |
228
|
|
|
*/ |
229
|
|
|
function woocommerce_set_customer_auth_cookie( $customer_id ) { |
230
|
|
|
wc_set_customer_auth_cookie( $customer_id ); |
231
|
|
|
} |
232
|
|
|
/** |
233
|
|
|
* @deprecated |
234
|
|
|
*/ |
235
|
|
|
function woocommerce_update_new_customer_past_orders( $customer_id ) { |
236
|
|
|
return wc_update_new_customer_past_orders( $customer_id ); |
237
|
|
|
} |
238
|
|
|
/** |
239
|
|
|
* @deprecated |
240
|
|
|
*/ |
241
|
|
|
function woocommerce_paying_customer( $order_id ) { |
242
|
|
|
wc_paying_customer( $order_id ); |
243
|
|
|
} |
244
|
|
|
/** |
245
|
|
|
* @deprecated |
246
|
|
|
*/ |
247
|
|
|
function woocommerce_customer_bought_product( $customer_email, $user_id, $product_id ) { |
248
|
|
|
return wc_customer_bought_product( $customer_email, $user_id, $product_id ); |
249
|
|
|
} |
250
|
|
|
/** |
251
|
|
|
* @deprecated |
252
|
|
|
*/ |
253
|
|
|
function woocommerce_customer_has_capability( $allcaps, $caps, $args ) { |
254
|
|
|
return wc_customer_has_capability( $allcaps, $caps, $args ); |
255
|
|
|
} |
256
|
|
|
|
257
|
|
|
/** |
258
|
|
|
* Formatting functions (soft deprecated). |
259
|
|
|
*/ |
260
|
|
|
/** |
261
|
|
|
* @deprecated |
262
|
|
|
*/ |
263
|
|
|
function woocommerce_sanitize_taxonomy_name( $taxonomy ) { |
264
|
|
|
return wc_sanitize_taxonomy_name( $taxonomy ); |
265
|
|
|
} |
266
|
|
|
/** |
267
|
|
|
* @deprecated |
268
|
|
|
*/ |
269
|
|
|
function woocommerce_get_filename_from_url( $file_url ) { |
270
|
|
|
return wc_get_filename_from_url( $file_url ); |
271
|
|
|
} |
272
|
|
|
/** |
273
|
|
|
* @deprecated |
274
|
|
|
*/ |
275
|
|
|
function woocommerce_get_dimension( $dim, $to_unit ) { |
276
|
|
|
return wc_get_dimension( $dim, $to_unit ); |
277
|
|
|
} |
278
|
|
|
/** |
279
|
|
|
* @deprecated |
280
|
|
|
*/ |
281
|
|
|
function woocommerce_get_weight( $weight, $to_unit ) { |
282
|
|
|
return wc_get_weight( $weight, $to_unit ); |
283
|
|
|
} |
284
|
|
|
/** |
285
|
|
|
* @deprecated |
286
|
|
|
*/ |
287
|
|
|
function woocommerce_trim_zeros( $price ) { |
288
|
|
|
return wc_trim_zeros( $price ); |
289
|
|
|
} |
290
|
|
|
/** |
291
|
|
|
* @deprecated |
292
|
|
|
*/ |
293
|
|
|
function woocommerce_round_tax_total( $tax ) { |
294
|
|
|
return wc_round_tax_total( $tax ); |
295
|
|
|
} |
296
|
|
|
/** |
297
|
|
|
* @deprecated |
298
|
|
|
*/ |
299
|
|
|
function woocommerce_format_decimal( $number, $dp = false, $trim_zeros = false ) { |
300
|
|
|
return wc_format_decimal( $number, $dp, $trim_zeros ); |
301
|
|
|
} |
302
|
|
|
/** |
303
|
|
|
* @deprecated |
304
|
|
|
*/ |
305
|
|
|
function woocommerce_clean( $var ) { |
306
|
|
|
return wc_clean( $var ); |
307
|
|
|
} |
308
|
|
|
/** |
309
|
|
|
* @deprecated |
310
|
|
|
*/ |
311
|
|
|
function woocommerce_array_overlay( $a1, $a2 ) { |
312
|
|
|
return wc_array_overlay( $a1, $a2 ); |
313
|
|
|
} |
314
|
|
|
/** |
315
|
|
|
* @deprecated |
316
|
|
|
*/ |
317
|
|
|
function woocommerce_price( $price, $args = array() ) { |
318
|
|
|
return wc_price( $price, $args ); |
319
|
|
|
} |
320
|
|
|
/** |
321
|
|
|
* @deprecated |
322
|
|
|
*/ |
323
|
|
|
function woocommerce_let_to_num( $size ) { |
324
|
|
|
return wc_let_to_num( $size ); |
325
|
|
|
} |
326
|
|
|
|
327
|
|
|
/** |
328
|
|
|
* @return string |
329
|
|
|
*/ |
330
|
|
|
/** |
331
|
|
|
* @deprecated |
332
|
|
|
*/ |
333
|
|
|
function woocommerce_date_format() { |
334
|
|
|
return wc_date_format(); |
335
|
|
|
} |
336
|
|
|
/** |
337
|
|
|
* @deprecated |
338
|
|
|
*/ |
339
|
|
|
function woocommerce_time_format() { |
340
|
|
|
return wc_time_format(); |
341
|
|
|
} |
342
|
|
|
/** |
343
|
|
|
* @deprecated |
344
|
|
|
*/ |
345
|
|
|
function woocommerce_timezone_string() { |
346
|
|
|
return wc_timezone_string(); |
347
|
|
|
} |
348
|
|
|
if ( ! function_exists( 'woocommerce_rgb_from_hex' ) ) { |
349
|
|
|
/** |
350
|
|
|
* @deprecated |
351
|
|
|
*/ |
352
|
|
|
function woocommerce_rgb_from_hex( $color ) { |
353
|
|
|
return wc_rgb_from_hex( $color ); |
354
|
|
|
} |
355
|
|
|
} |
356
|
|
|
if ( ! function_exists( 'woocommerce_hex_darker' ) ) { |
357
|
|
|
/** |
358
|
|
|
* @deprecated |
359
|
|
|
*/ |
360
|
|
|
function woocommerce_hex_darker( $color, $factor = 30 ) { |
361
|
|
|
return wc_hex_darker( $color, $factor ); |
362
|
|
|
} |
363
|
|
|
} |
364
|
|
|
if ( ! function_exists( 'woocommerce_hex_lighter' ) ) { |
365
|
|
|
/** |
366
|
|
|
* @deprecated |
367
|
|
|
*/ |
368
|
|
|
function woocommerce_hex_lighter( $color, $factor = 30 ) { |
369
|
|
|
return wc_hex_lighter( $color, $factor ); |
370
|
|
|
} |
371
|
|
|
} |
372
|
|
|
if ( ! function_exists( 'woocommerce_light_or_dark' ) ) { |
373
|
|
|
/** |
374
|
|
|
* @deprecated |
375
|
|
|
*/ |
376
|
|
|
function woocommerce_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) { |
377
|
|
|
return wc_light_or_dark( $color, $dark, $light ); |
378
|
|
|
} |
379
|
|
|
} |
380
|
|
|
if ( ! function_exists( 'woocommerce_format_hex' ) ) { |
381
|
|
|
/** |
382
|
|
|
* @deprecated |
383
|
|
|
*/ |
384
|
|
|
function woocommerce_format_hex( $hex ) { |
385
|
|
|
return wc_format_hex( $hex ); |
386
|
|
|
} |
387
|
|
|
} |
388
|
|
|
|
389
|
|
|
/** |
390
|
|
|
* Order functions (soft deprecated). |
391
|
|
|
*/ |
392
|
|
|
/** |
393
|
|
|
* @deprecated |
394
|
|
|
*/ |
395
|
|
|
function woocommerce_get_order_id_by_order_key( $order_key ) { |
396
|
|
|
return wc_get_order_id_by_order_key( $order_key ); |
397
|
|
|
} |
398
|
|
|
/** |
399
|
|
|
* @deprecated |
400
|
|
|
*/ |
401
|
|
|
function woocommerce_downloadable_file_permission( $download_id, $product_id, $order ) { |
402
|
|
|
return wc_downloadable_file_permission( $download_id, $product_id, $order ); |
403
|
|
|
} |
404
|
|
|
/** |
405
|
|
|
* @deprecated |
406
|
|
|
*/ |
407
|
|
|
function woocommerce_downloadable_product_permissions( $order_id ) { |
408
|
|
|
wc_downloadable_product_permissions( $order_id ); |
409
|
|
|
} |
410
|
|
|
/** |
411
|
|
|
* @deprecated |
412
|
|
|
*/ |
413
|
|
|
function woocommerce_add_order_item( $order_id, $item ) { |
414
|
|
|
return wc_add_order_item( $order_id, $item ); |
415
|
|
|
} |
416
|
|
|
/** |
417
|
|
|
* @deprecated |
418
|
|
|
*/ |
419
|
|
|
function woocommerce_delete_order_item( $item_id ) { |
420
|
|
|
return wc_delete_order_item( $item_id ); |
421
|
|
|
} |
422
|
|
|
/** |
423
|
|
|
* @deprecated |
424
|
|
|
*/ |
425
|
|
|
function woocommerce_update_order_item_meta( $item_id, $meta_key, $meta_value, $prev_value = '' ) { |
426
|
|
|
return wc_update_order_item_meta( $item_id, $meta_key, $meta_value, $prev_value ); |
427
|
|
|
} |
428
|
|
|
/** |
429
|
|
|
* @deprecated |
430
|
|
|
*/ |
431
|
|
|
function woocommerce_add_order_item_meta( $item_id, $meta_key, $meta_value, $unique = false ) { |
432
|
|
|
return wc_add_order_item_meta( $item_id, $meta_key, $meta_value, $unique ); |
433
|
|
|
} |
434
|
|
|
/** |
435
|
|
|
* @deprecated |
436
|
|
|
*/ |
437
|
|
|
function woocommerce_delete_order_item_meta( $item_id, $meta_key, $meta_value = '', $delete_all = false ) { |
438
|
|
|
return wc_delete_order_item_meta( $item_id, $meta_key, $meta_value, $delete_all ); |
439
|
|
|
} |
440
|
|
|
/** |
441
|
|
|
* @deprecated |
442
|
|
|
*/ |
443
|
|
|
function woocommerce_get_order_item_meta( $item_id, $key, $single = true ) { |
444
|
|
|
return wc_get_order_item_meta( $item_id, $key, $single ); |
445
|
|
|
} |
446
|
|
|
/** |
447
|
|
|
* @deprecated |
448
|
|
|
*/ |
449
|
|
|
function woocommerce_cancel_unpaid_orders() { |
450
|
|
|
wc_cancel_unpaid_orders(); |
451
|
|
|
} |
452
|
|
|
/** |
453
|
|
|
* @deprecated |
454
|
|
|
*/ |
455
|
|
|
function woocommerce_processing_order_count() { |
456
|
|
|
return wc_processing_order_count(); |
457
|
|
|
} |
458
|
|
|
|
459
|
|
|
/** |
460
|
|
|
* Page functions (soft deprecated). |
461
|
|
|
*/ |
462
|
|
|
/** |
463
|
|
|
* @deprecated |
464
|
|
|
*/ |
465
|
|
|
function woocommerce_get_page_id( $page ) { |
466
|
|
|
return wc_get_page_id( $page ); |
467
|
|
|
} |
468
|
|
|
/** |
469
|
|
|
* @deprecated |
470
|
|
|
*/ |
471
|
|
|
function woocommerce_get_endpoint_url( $endpoint, $value = '', $permalink = '' ) { |
472
|
|
|
return wc_get_endpoint_url( $endpoint, $value, $permalink ); |
473
|
|
|
} |
474
|
|
|
/** |
475
|
|
|
* @deprecated |
476
|
|
|
*/ |
477
|
|
|
function woocommerce_lostpassword_url( $url ) { |
478
|
|
|
return wc_lostpassword_url( $url ); |
479
|
|
|
} |
480
|
|
|
/** |
481
|
|
|
* @deprecated |
482
|
|
|
*/ |
483
|
|
|
function woocommerce_customer_edit_account_url() { |
484
|
|
|
return wc_customer_edit_account_url(); |
485
|
|
|
} |
486
|
|
|
/** |
487
|
|
|
* @deprecated |
488
|
|
|
*/ |
489
|
|
|
function woocommerce_nav_menu_items( $items, $args ) { |
|
|
|
|
490
|
|
|
return wc_nav_menu_items( $items ); |
491
|
|
|
} |
492
|
|
|
/** |
493
|
|
|
* @deprecated |
494
|
|
|
*/ |
495
|
|
|
function woocommerce_nav_menu_item_classes( $menu_items, $args ) { |
|
|
|
|
496
|
|
|
return wc_nav_menu_item_classes( $menu_items ); |
497
|
|
|
} |
498
|
|
|
/** |
499
|
|
|
* @deprecated |
500
|
|
|
*/ |
501
|
|
|
function woocommerce_list_pages( $pages ) { |
502
|
|
|
return wc_list_pages( $pages ); |
503
|
|
|
} |
504
|
|
|
|
505
|
|
|
/** |
506
|
|
|
* Handle renamed filters. |
507
|
|
|
*/ |
508
|
|
|
global $wc_map_deprecated_filters; |
509
|
|
|
|
510
|
|
|
$wc_map_deprecated_filters = array( |
511
|
|
|
'woocommerce_add_to_cart_fragments' => 'add_to_cart_fragments', |
512
|
|
|
'woocommerce_add_to_cart_redirect' => 'add_to_cart_redirect' |
513
|
|
|
); |
514
|
|
|
|
515
|
|
|
foreach ( $wc_map_deprecated_filters as $new => $old ) { |
516
|
|
|
add_filter( $new, 'woocommerce_deprecated_filter_mapping' ); |
517
|
|
|
} |
518
|
|
|
|
519
|
|
|
function woocommerce_deprecated_filter_mapping( $data, $arg_1 = '', $arg_2 = '', $arg_3 = '' ) { |
520
|
|
|
global $wc_map_deprecated_filters; |
521
|
|
|
|
522
|
|
|
$filter = current_filter(); |
523
|
|
|
|
524
|
|
|
if ( isset( $wc_map_deprecated_filters[ $filter ] ) ) { |
525
|
|
|
if ( has_filter( $wc_map_deprecated_filters[ $filter ] ) ) { |
526
|
|
|
$data = apply_filters( $wc_map_deprecated_filters[ $filter ], $data, $arg_1, $arg_2, $arg_3 ); |
527
|
|
|
if ( ! is_ajax() ) { |
528
|
|
|
_deprecated_function( 'The ' . $wc_map_deprecated_filters[ $filter ] . ' filter', '', $filter ); |
529
|
|
|
} |
530
|
|
|
} |
531
|
|
|
} |
532
|
|
|
|
533
|
|
|
return $data; |
534
|
|
|
} |
535
|
|
|
|
536
|
|
|
/** |
537
|
|
|
* Alias functions/soft-deprecated function names (moving from woocommerce_ to wc_). These will be deprecated with notices in future updates. |
538
|
|
|
*/ |
539
|
|
|
|
540
|
|
|
/** |
541
|
|
|
* Attribute functions - soft deprecated. |
542
|
|
|
*/ |
543
|
|
|
/** |
544
|
|
|
* @deprecated |
545
|
|
|
*/ |
546
|
|
|
function woocommerce_product_dropdown_categories( $args = array(), $deprecated_hierarchical = 1, $deprecated_show_uncategorized = 1, $deprecated_orderby = '' ) { |
547
|
|
|
return wc_product_dropdown_categories( $args, $deprecated_hierarchical, $deprecated_show_uncategorized, $deprecated_orderby ); |
548
|
|
|
} |
549
|
|
|
/** |
550
|
|
|
* @deprecated |
551
|
|
|
*/ |
552
|
|
|
function woocommerce_walk_category_dropdown_tree( $a1 = '', $a2 = '', $a3 = '' ) { |
553
|
|
|
return wc_walk_category_dropdown_tree( $a1, $a2, $a3 ); |
554
|
|
|
} |
555
|
|
|
/** |
556
|
|
|
* @deprecated |
557
|
|
|
*/ |
558
|
|
|
function woocommerce_taxonomy_metadata_wpdbfix() {} |
559
|
|
|
/** |
560
|
|
|
* @deprecated |
561
|
|
|
*/ |
562
|
|
|
function wc_taxonomy_metadata_wpdbfix() {} |
563
|
|
|
/** |
564
|
|
|
* @deprecated |
565
|
|
|
*/ |
566
|
|
|
function woocommerce_order_terms( $the_term, $next_id, $taxonomy, $index = 0, $terms = null ) { |
567
|
|
|
return wc_reorder_terms( $the_term, $next_id, $taxonomy, $index, $terms ); |
568
|
|
|
} |
569
|
|
|
/** |
570
|
|
|
* @deprecated |
571
|
|
|
*/ |
572
|
|
|
function woocommerce_set_term_order( $term_id, $index, $taxonomy, $recursive = false ) { |
573
|
|
|
return wc_set_term_order( $term_id, $index, $taxonomy, $recursive ); |
574
|
|
|
} |
575
|
|
|
/** |
576
|
|
|
* @deprecated |
577
|
|
|
*/ |
578
|
|
|
function woocommerce_terms_clauses( $clauses, $taxonomies, $args ) { |
579
|
|
|
return wc_terms_clauses( $clauses, $taxonomies, $args ); |
580
|
|
|
} |
581
|
|
|
/** |
582
|
|
|
* @deprecated |
583
|
|
|
*/ |
584
|
|
|
function _woocommerce_term_recount( $terms, $taxonomy, $callback, $terms_are_term_taxonomy_ids ) { |
585
|
|
|
return _wc_term_recount( $terms, $taxonomy, $callback, $terms_are_term_taxonomy_ids ); |
586
|
|
|
} |
587
|
|
|
/** |
588
|
|
|
* @deprecated |
589
|
|
|
*/ |
590
|
|
|
function woocommerce_recount_after_stock_change( $product_id ) { |
591
|
|
|
return wc_recount_after_stock_change( $product_id ); |
592
|
|
|
} |
593
|
|
|
/** |
594
|
|
|
* @deprecated |
595
|
|
|
*/ |
596
|
|
|
function woocommerce_change_term_counts( $terms, $taxonomies, $args ) { |
|
|
|
|
597
|
|
|
return wc_change_term_counts( $terms, $taxonomies ); |
598
|
|
|
} |
599
|
|
|
|
600
|
|
|
/** |
601
|
|
|
* Product functions - soft deprecated. |
602
|
|
|
*/ |
603
|
|
|
/** |
604
|
|
|
* @deprecated |
605
|
|
|
*/ |
606
|
|
|
function woocommerce_get_product_ids_on_sale() { |
607
|
|
|
return wc_get_product_ids_on_sale(); |
608
|
|
|
} |
609
|
|
|
/** |
610
|
|
|
* @deprecated |
611
|
|
|
*/ |
612
|
|
|
function woocommerce_get_featured_product_ids() { |
613
|
|
|
return wc_get_featured_product_ids(); |
614
|
|
|
} |
615
|
|
|
/** |
616
|
|
|
* @deprecated |
617
|
|
|
*/ |
618
|
|
|
function woocommerce_get_product_terms( $object_id, $taxonomy, $fields = 'all' ) { |
619
|
|
|
return wc_get_product_terms( $object_id, $taxonomy, array( 'fields' => $fields ) ); |
620
|
|
|
} |
621
|
|
|
/** |
622
|
|
|
* @deprecated |
623
|
|
|
*/ |
624
|
|
|
function woocommerce_product_post_type_link( $permalink, $post ) { |
625
|
|
|
return wc_product_post_type_link( $permalink, $post ); |
626
|
|
|
} |
627
|
|
|
/** |
628
|
|
|
* @deprecated |
629
|
|
|
*/ |
630
|
|
|
function woocommerce_placeholder_img_src() { |
631
|
|
|
return wc_placeholder_img_src(); |
632
|
|
|
} |
633
|
|
|
/** |
634
|
|
|
* @deprecated |
635
|
|
|
*/ |
636
|
|
|
function woocommerce_placeholder_img( $size = 'shop_thumbnail' ) { |
637
|
|
|
return wc_placeholder_img( $size ); |
638
|
|
|
} |
639
|
|
|
/** |
640
|
|
|
* @deprecated |
641
|
|
|
*/ |
642
|
|
|
function woocommerce_get_formatted_variation( $variation = '', $flat = false ) { |
643
|
|
|
return wc_get_formatted_variation( $variation, $flat ); |
644
|
|
|
} |
645
|
|
|
/** |
646
|
|
|
* @deprecated |
647
|
|
|
*/ |
648
|
|
|
function woocommerce_scheduled_sales() { |
649
|
|
|
return wc_scheduled_sales(); |
650
|
|
|
} |
651
|
|
|
/** |
652
|
|
|
* @deprecated |
653
|
|
|
*/ |
654
|
|
|
function woocommerce_get_attachment_image_attributes( $attr ) { |
655
|
|
|
return wc_get_attachment_image_attributes( $attr ); |
656
|
|
|
} |
657
|
|
|
/** |
658
|
|
|
* @deprecated |
659
|
|
|
*/ |
660
|
|
|
function woocommerce_prepare_attachment_for_js( $response ) { |
661
|
|
|
return wc_prepare_attachment_for_js( $response ); |
662
|
|
|
} |
663
|
|
|
/** |
664
|
|
|
* @deprecated |
665
|
|
|
*/ |
666
|
|
|
function woocommerce_track_product_view() { |
667
|
|
|
return wc_track_product_view(); |
668
|
|
|
} |
669
|
|
|
|
670
|
|
|
/** |
671
|
|
|
* Shop order status. |
672
|
|
|
* |
673
|
|
|
* @since 2.2 |
674
|
|
|
* @param WP_Query $q |
675
|
|
|
*/ |
676
|
|
|
function wc_shop_order_status_backwards_compatibility( $q ) { |
677
|
|
|
if ( $q->is_main_query() ) { |
678
|
|
|
return; |
679
|
|
|
} |
680
|
|
|
|
681
|
|
|
if ( |
682
|
|
|
isset( $q->query_vars['post_type'] ) && 'shop_order' == $q->query_vars['post_type'] |
683
|
|
|
&& isset( $q->query_vars['post_status'] ) && 'publish' == $q->query_vars['post_status'] |
684
|
|
|
) { |
685
|
|
|
$tax_query = isset( $q->query_vars['tax_query'] ) ? $q->query_vars['tax_query'] : array(); |
686
|
|
|
$order_status = array(); |
687
|
|
|
$tax_key = ''; |
688
|
|
|
|
689
|
|
|
// Look for shop_order_status taxonomy and get the terms |
690
|
|
|
foreach ( $tax_query as $key => $tax ) { |
691
|
|
|
if ( 'shop_order_status' == $tax['taxonomy'] ) { |
692
|
|
|
$tax_key = $key; |
693
|
|
|
$order_status = $tax['terms']; |
694
|
|
|
break; |
695
|
|
|
} |
696
|
|
|
} |
697
|
|
|
|
698
|
|
|
if ( $order_status ) { |
699
|
|
|
// Remove old tax_query |
700
|
|
|
unset( $tax_query[ $tax_key ] ); |
701
|
|
|
|
702
|
|
|
// Set the new order status |
703
|
|
|
$order_status = is_array( $order_status ) ? 'wc-' . implode( ',wc-', $order_status ) : 'wc-' . $order_status; |
704
|
|
|
|
705
|
|
|
$q->set( 'post_status', $order_status ); |
706
|
|
|
$q->set( 'tax_query', $tax_query ); |
707
|
|
|
|
708
|
|
|
_doing_it_wrong( 'WP_Query', sprintf( __( 'The shop_order_status taxonomy is no more in WooCommerce 2.2! You should use the new WooCommerce post_status instead, <a href="%s">read more...</a>', 'woocommerce' ), 'https://woocommerce.wordpress.com/2014/08/wc-2-2-order-statuses-plugin-compatibility/' ), 'WooCommerce 2.2' ); |
709
|
|
|
} else { |
710
|
|
|
$q->set( 'post_status', array_keys( wc_get_order_statuses() ) ); |
711
|
|
|
|
712
|
|
|
_doing_it_wrong( 'WP_Query', sprintf( __( 'The "publish" order status is no more in WooCommerce 2.2! You should use the new WooCommerce post_status instead, <a href="%s">read more...</a>', 'woocommerce' ), 'https://woocommerce.wordpress.com/2014/08/wc-2-2-order-statuses-plugin-compatibility/' ), 'WooCommerce 2.2' ); |
713
|
|
|
} |
714
|
|
|
} |
715
|
|
|
} |
716
|
|
|
|
717
|
|
|
add_action( 'pre_get_posts', 'wc_shop_order_status_backwards_compatibility' ); |
718
|
|
|
|
719
|
|
|
/** |
720
|
|
|
* @since 2.3 |
721
|
|
|
* @deprecated has no replacement |
722
|
|
|
*/ |
723
|
|
|
function woocommerce_compile_less_styles() { |
724
|
|
|
_deprecated_function( 'woocommerce_compile_less_styles', '2.3' ); |
725
|
|
|
} |
726
|
|
|
|
727
|
|
|
/** |
728
|
|
|
* woocommerce_calc_shipping was an option used to determine if shipping was enabled prior to version 2.6.0. This has since been replaced with wc_shipping_enabled() function and |
729
|
|
|
* the woocommerce_ship_to_countries setting. |
730
|
|
|
* @since 2.6.0 |
731
|
|
|
* @return string |
732
|
|
|
*/ |
733
|
|
|
function woocommerce_calc_shipping_backwards_compatibility( $value ) { |
734
|
|
|
if ( defined( 'WC_UPDATING' ) ) { |
735
|
|
|
return $value; |
736
|
|
|
} |
737
|
|
|
return 'disabled' === get_option( 'woocommerce_ship_to_countries' ) ? 'no' : 'yes'; |
738
|
|
|
} |
739
|
|
|
|
740
|
|
|
add_filter( 'pre_option_woocommerce_calc_shipping', 'woocommerce_calc_shipping_backwards_compatibility' ); |
741
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.