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' ) ) exit; // Exit if accessed directly
 14 
 15 function woocommerce_show_messages() {
 16     _deprecated_function( 'woocommerce_show_messages', '2.1', 'wc_print_notices' );
 17     wc_print_notices();
 18 }
 19 function woocommerce_weekend_area_js() {
 20     _deprecated_function( 'woocommerce_weekend_area_js', '2.1', '' );
 21 }
 22 function woocommerce_tooltip_js() {
 23     _deprecated_function( 'woocommerce_tooltip_js', '2.1', '' );
 24 }
 25 function woocommerce_datepicker_js() {
 26     _deprecated_function( 'woocommerce_datepicker_js', '2.1', '' );
 27 }
 28 function woocommerce_admin_scripts() {
 29     _deprecated_function( 'woocommerce_admin_scripts', '2.1', '' );
 30 }
 31 function woocommerce_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) {
 32     _deprecated_function( 'woocommerce_create_page', '2.1', 'wc_create_page' );
 33     return wc_create_page( $slug, $option, $page_title, $page_content, $post_parent );
 34 }
 35 function woocommerce_readfile_chunked( $file, $retbytes = true ) {
 36     _deprecated_function( 'woocommerce_readfile_chunked', '2.1', 'WC_Download_Handler::readfile_chunked()' );
 37     return WC_Download_Handler::readfile_chunked( $file, $retbytes );
 38 }
 39 
 40 /**
 41  * Formal total costs - format to the number of decimal places for the base currency.
 42  *
 43  * @access public
 44  * @param mixed $number
 45  * @deprecated 2.1
 46  * @return string
 47  */
 48 function woocommerce_format_total( $number ) {
 49     _deprecated_function( __FUNCTION__, '2.1', 'wc_format_decimal()' );
 50     return wc_format_decimal( $number, get_option( 'woocommerce_price_num_decimals' ), false );
 51 }
 52 
 53 /**
 54  * Get product name with extra details such as SKU price and attributes. Used within admin.
 55  *
 56  * @access public
 57  * @param WC_Product $product
 58  * @deprecated 2.1
 59  * @return string
 60  */
 61 function woocommerce_get_formatted_product_name( $product ) {
 62     _deprecated_function( __FUNCTION__, '2.1', 'WC_Product::get_formatted_name()' );
 63     return $product->get_formatted_name();
 64 }
 65 
 66 /**
 67  * Handle IPN requests for the legacy paypal gateway by calling gateways manually if needed.
 68  *
 69  * @access public
 70  * @return void
 71  */
 72 function woocommerce_legacy_paypal_ipn() {
 73     if ( ! empty( $_GET['paypalListener'] ) && $_GET['paypalListener'] == 'paypal_standard_IPN' ) {
 74 
 75         WC()->payment_gateways();
 76 
 77         do_action( 'woocommerce_api_wc_gateway_paypal' );
 78     }
 79 }
 80 add_action( 'init', 'woocommerce_legacy_paypal_ipn' );
 81 
 82 /**
 83  * Cart functions (soft deprecated)
 84  */
 85 function woocommerce_protected_product_add_to_cart( $passed, $product_id ) {
 86     return wc_protected_product_add_to_cart( $passed, $product_id );
 87 }
 88 function woocommerce_empty_cart() {
 89     wc_empty_cart();
 90 }
 91 function woocommerce_load_persistent_cart( $user_login, $user = 0 ) {
 92     return wc_load_persistent_cart( $user_login, $user );
 93 }
 94 function woocommerce_add_to_cart_message( $product_id ) {
 95     wc_add_to_cart_message( $product_id );
 96 }
 97 function woocommerce_clear_cart_after_payment() {
 98     wc_clear_cart_after_payment();
 99 }
100 function woocommerce_cart_totals_subtotal_html() {
101     wc_cart_totals_subtotal_html();
102 }
103 function woocommerce_cart_totals_shipping_html() {
104     wc_cart_totals_shipping_html();
105 }
106 function woocommerce_cart_totals_coupon_html( $coupon ) {
107     wc_cart_totals_coupon_html( $coupon );
108 }
109 function woocommerce_cart_totals_order_total_html() {
110     wc_cart_totals_order_total_html();
111 }
112 function woocommerce_cart_totals_fee_html( $fee ) {
113     wc_cart_totals_fee_html( $fee );
114 }
115 function woocommerce_cart_totals_shipping_method_label( $method ) {
116     return wc_cart_totals_shipping_method_label( $method );
117 }
118 
119 /**
120  * Core functions (soft deprecated)
121  */
122 function woocommerce_get_template_part( $slug, $name = '' ) {
123     wc_get_template_part( $slug, $name );
124 }
125 function woocommerce_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
126     wc_get_template( $template_name, $args, $template_path, $default_path );
127 }
128 function woocommerce_locate_template( $template_name, $template_path = '', $default_path = '' ) {
129     return wc_locate_template( $template_name, $template_path, $default_path );
130 }
131 function woocommerce_mail( $to, $subject, $message, $headers = "Content-Type: text/html\r\n", $attachments = "" ) {
132     wc_mail( $to, $subject, $message, $headers, $attachments );
133 }
134 
135 /**
136  * Customer functions (soft deprecated)
137  */
138 function woocommerce_disable_admin_bar( $show_admin_bar ) {
139     return wc_disable_admin_bar( $show_admin_bar );
140 }
141 function woocommerce_create_new_customer( $email, $username = '', $password = '' ) {
142     return wc_create_new_customer( $email, $username, $password );
143 }
144 function woocommerce_set_customer_auth_cookie( $customer_id ) {
145     wc_set_customer_auth_cookie( $customer_id );
146 }
147 function woocommerce_update_new_customer_past_orders( $customer_id ) {
148     return wc_update_new_customer_past_orders( $customer_id );
149 }
150 function woocommerce_paying_customer( $order_id ) {
151     wc_paying_customer( $order_id );
152 }
153 function woocommerce_customer_bought_product( $customer_email, $user_id, $product_id ) {
154     return wc_customer_bought_product( $customer_email, $user_id, $product_id );
155 }
156 function woocommerce_customer_has_capability( $allcaps, $caps, $args ) {
157     return wc_customer_has_capability( $allcaps, $caps, $args );
158 }
159 
160 /**
161  * Formatting functions (soft deprecated)
162  */
163 function woocommerce_sanitize_taxonomy_name( $taxonomy ) {
164     return wc_sanitize_taxonomy_name( $taxonomy );
165 }
166 function woocommerce_get_filename_from_url( $file_url ) {
167     return wc_get_filename_from_url( $file_url );
168 }
169 function woocommerce_get_dimension( $dim, $to_unit ) {
170     return wc_get_dimension( $dim, $to_unit );
171 }
172 function woocommerce_get_weight( $weight, $to_unit ) {
173     return wc_get_weight( $weight, $to_unit );
174 }
175 function woocommerce_trim_zeros( $price ) {
176     return wc_trim_zeros( $price );
177 }
178 function woocommerce_round_tax_total( $tax ) {
179     return wc_round_tax_total( $tax );
180 }
181 function woocommerce_format_decimal( $number, $dp = false, $trim_zeros = false ) {
182     return wc_format_decimal( $number, $dp, $trim_zeros );
183 }
184 function woocommerce_clean( $var ) {
185     return wc_clean( $var );
186 }
187 function woocommerce_array_overlay( $a1, $a2 ) {
188     return wc_array_overlay( $a1, $a2 );
189 }
190 function woocommerce_price( $price, $args = array() ) {
191     return wc_price( $price, $args );
192 }
193 function woocommerce_let_to_num( $size ) {
194     return wc_let_to_num( $size );
195 }
196 
197 /**
198  * @return string
199  */
200 function woocommerce_date_format() {
201     return wc_date_format();
202 }
203 function woocommerce_time_format() {
204     return wc_time_format();
205 }
206 function woocommerce_timezone_string() {
207     return wc_timezone_string();
208 }
209 if ( ! function_exists( 'woocommerce_rgb_from_hex' ) ) {
210     function woocommerce_rgb_from_hex( $color ) {
211         return wc_rgb_from_hex( $color );
212     }
213 }
214 if ( ! function_exists( 'woocommerce_hex_darker' ) ) {
215     function woocommerce_hex_darker( $color, $factor = 30 ) {
216         return wc_hex_darker( $color, $factor );
217     }
218 }
219 if ( ! function_exists( 'woocommerce_hex_lighter' ) ) {
220     function woocommerce_hex_lighter( $color, $factor = 30 ) {
221         return wc_hex_lighter( $color, $factor );
222     }
223 }
224 if ( ! function_exists( 'woocommerce_light_or_dark' ) ) {
225     function woocommerce_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) {
226         return wc_light_or_dark( $color, $dark, $light );
227     }
228 }
229 if ( ! function_exists( 'woocommerce_format_hex' ) ) {
230     function woocommerce_format_hex( $hex ) {
231         return wc_format_hex( $hex );
232     }
233 }
234 
235 /**
236  * Order functions (soft deprecated)
237  */
238 function woocommerce_get_order_id_by_order_key( $order_key ) {
239     return wc_get_order_id_by_order_key( $order_key );
240 }
241 function woocommerce_downloadable_file_permission( $download_id, $product_id, $order ) {
242     return wc_downloadable_file_permission( $download_id, $product_id, $order );
243 }
244 function woocommerce_downloadable_product_permissions( $order_id ) {
245     wc_downloadable_product_permissions( $order_id );
246 }
247 function woocommerce_add_order_item( $order_id, $item ) {
248     return wc_add_order_item( $order_id, $item );
249 }
250 function woocommerce_delete_order_item( $item_id ) {
251     return wc_delete_order_item( $item_id );
252 }
253 function woocommerce_update_order_item_meta( $item_id, $meta_key, $meta_value, $prev_value = '' ) {
254     return wc_update_order_item_meta( $item_id, $meta_key, $meta_value, $prev_value );
255 }
256 function woocommerce_add_order_item_meta( $item_id, $meta_key, $meta_value, $unique = false ) {
257     return wc_add_order_item_meta( $item_id, $meta_key, $meta_value, $unique );
258 }
259 function woocommerce_delete_order_item_meta( $item_id, $meta_key, $meta_value = '', $delete_all = false ) {
260     return wc_delete_order_item_meta( $item_id, $meta_key, $meta_value, $delete_all );
261 }
262 function woocommerce_get_order_item_meta( $item_id, $key, $single = true ) {
263     return wc_get_order_item_meta( $item_id, $key, $single );
264 }
265 function woocommerce_cancel_unpaid_orders() {
266     wc_cancel_unpaid_orders();
267 }
268 function woocommerce_processing_order_count() {
269     return wc_processing_order_count();
270 }
271 
272 /**
273  * Page functions (soft deprecated)
274  */
275 function woocommerce_get_page_id( $page ) {
276     return wc_get_page_id( $page );
277 }
278 function woocommerce_get_endpoint_url( $endpoint, $value = '', $permalink = '' ) {
279     return wc_get_endpoint_url( $endpoint, $value, $permalink );
280 }
281 function woocommerce_lostpassword_url( $url ) {
282     return wc_lostpassword_url( $url );
283 }
284 function woocommerce_customer_edit_account_url() {
285     return wc_customer_edit_account_url();
286 }
287 function woocommerce_nav_menu_items( $items, $args ) {
288     return wc_nav_menu_items( $items, $args );
289 }
290 function woocommerce_nav_menu_item_classes( $menu_items, $args ) {
291     return wc_nav_menu_item_classes( $menu_items, $args );
292 }
293 function woocommerce_list_pages( $pages ) {
294     return wc_list_pages( $pages );
295 }
296 
297 /**
298  * Handle renamed filters
299  */
300 global $wc_map_deprecated_filters;
301 
302 $wc_map_deprecated_filters = array(
303     'woocommerce_cart_item_class'       => 'woocommerce_cart_table_item_class',
304     'woocommerce_cart_item_product_id'  => 'hook_woocommerce_in_cart_product_id',
305     'woocommerce_cart_item_thumbnail'   => 'hook_woocommerce_in_cart_product_thumbnail',
306     'woocommerce_cart_item_price'       => 'woocommerce_cart_item_price_html',
307     'woocommerce_cart_item_name'        => 'woocommerce_in_cart_product_title',
308     'woocommerce_order_item_class'      => 'woocommerce_order_table_item_class',
309     'woocommerce_order_item_name'       => 'woocommerce_order_table_product_title',
310     'woocommerce_order_amount_shipping' => 'woocommerce_order_amount_total_shipping',
311     'woocommerce_package_rates'         => 'woocommerce_available_shipping_methods'
312 );
313 
314 foreach ( $wc_map_deprecated_filters as $new => $old )
315     add_filter( $new, 'woocommerce_deprecated_filter_mapping' );
316 
317 function woocommerce_deprecated_filter_mapping( $data, $arg_1 = '', $arg_2 = '', $arg_3 = '' ) {
318     global $wc_map_deprecated_filters;
319 
320     $filter = current_filter();
321 
322     if ( isset( $wc_map_deprecated_filters[ $filter ] ) )
323         if ( has_filter( $wc_map_deprecated_filters[ $filter ] ) ) {
324             $data = apply_filters( $wc_map_deprecated_filters[ $filter ], $data, $arg_1, $arg_2, $arg_3 );
325             _deprecated_function( 'The ' . $wc_map_deprecated_filters[ $filter ] . ' filter', '2.1', $filter );
326         }
327 
328     return $data;
329 }
330 
331 /**
332  * Alias functions/soft-deprecated function names (moving from woocommerce_ to wc_). These will be deprecated with notices in future updates.
333  */
334 
335 /**
336  * Attribute functions - soft deprecated
337  */
338 function woocommerce_product_dropdown_categories( $args = array(), $deprecated_hierarchical = 1, $deprecated_show_uncategorized = 1, $deprecated_orderby = '' ) {
339     return wc_product_dropdown_categories( $args, $deprecated_hierarchical, $deprecated_show_uncategorized, $deprecated_orderby );
340 }
341 function woocommerce_walk_category_dropdown_tree( $a1 = '', $a2 = '', $a3 = '' ) {
342     return wc_walk_category_dropdown_tree( $a1, $a2, $a3 );
343 }
344 function woocommerce_taxonomy_metadata_wpdbfix() {
345     return wc_taxonomy_metadata_wpdbfix();
346 }
347 function woocommerce_order_terms( $the_term, $next_id, $taxonomy, $index = 0, $terms = null ) {
348     return wc_reorder_terms( $the_term, $next_id, $taxonomy, $index, $terms );
349 }
350 function woocommerce_set_term_order( $term_id, $index, $taxonomy, $recursive = false ) {
351     return wc_set_term_order( $term_id, $index, $taxonomy, $recursive );
352 }
353 function woocommerce_terms_clauses( $clauses, $taxonomies, $args ) {
354     return wc_terms_clauses( $clauses, $taxonomies, $args );
355 }
356 function _woocommerce_term_recount( $terms, $taxonomy, $callback, $terms_are_term_taxonomy_ids ) {
357     return _wc_term_recount( $terms, $taxonomy, $callback, $terms_are_term_taxonomy_ids );
358 }
359 function woocommerce_recount_after_stock_change( $product_id ) {
360     return wc_recount_after_stock_change( $product_id );
361 }
362 function woocommerce_change_term_counts( $terms, $taxonomies, $args ) {
363     return wc_change_term_counts( $terms, $taxonomies, $args );
364 }
365 
366 /**
367  * Product functions - soft deprecated
368  */
369 function woocommerce_get_product_ids_on_sale() {
370     return wc_get_product_ids_on_sale();
371 }
372 function woocommerce_get_featured_product_ids() {
373     return wc_get_featured_product_ids();
374 }
375 function woocommerce_get_product_terms( $object_id, $taxonomy, $fields = 'all' ) {
376     return wc_get_product_terms( $object_id, $taxonomy, array( 'fields' => $fields ) );
377 }
378 function woocommerce_product_post_type_link( $permalink, $post ) {
379     return wc_product_post_type_link( $permalink, $post );
380 }
381 function woocommerce_placeholder_img_src() {
382     return wc_placeholder_img_src();
383 }
384 function woocommerce_placeholder_img( $size = 'shop_thumbnail' ) {
385     return wc_placeholder_img( $size );
386 }
387 function woocommerce_get_formatted_variation( $variation = '', $flat = false ) {
388     return wc_get_formatted_variation( $variation, $flat );
389 }
390 function woocommerce_scheduled_sales() {
391     return wc_scheduled_sales();
392 }
393 function woocommerce_get_attachment_image_attributes( $attr ) {
394     return wc_get_attachment_image_attributes( $attr );
395 }
396 function woocommerce_prepare_attachment_for_js( $response ) {
397     return wc_prepare_attachment_for_js( $response );
398 }
399 function woocommerce_track_product_view() {
400     return wc_track_product_view();
401 }
402 
WooCommerce API documentation generated by ApiGen 2.8.0