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