abstracts
4 years ago
admin
4 years ago
blocks
5 years ago
cli
4 years ago
customizer
4 years ago
data-stores
4 years ago
emails
4 years ago
export
4 years ago
gateways
4 years ago
import
4 years ago
integrations
5 years ago
interfaces
4 years ago
legacy
5 years ago
libraries
6 years ago
log-handlers
5 years ago
payment-tokens
5 years ago
queue
5 years ago
rest-api
4 years ago
shipping
5 years ago
shortcodes
5 years ago
theme-support
5 years ago
tracks
4 years ago
traits
5 years ago
walkers
5 years ago
wccom-site
5 years ago
widgets
4 years ago
class-wc-ajax.php
4 years ago
class-wc-api.php
5 years ago
class-wc-auth.php
5 years ago
class-wc-autoloader.php
5 years ago
class-wc-background-emailer.php
5 years ago
class-wc-background-updater.php
5 years ago
class-wc-breadcrumb.php
5 years ago
class-wc-cache-helper.php
4 years ago
class-wc-cart-fees.php
5 years ago
class-wc-cart-session.php
5 years ago
class-wc-cart-totals.php
4 years ago
class-wc-cart.php
5 years ago
class-wc-checkout.php
4 years ago
class-wc-cli.php
4 years ago
class-wc-comments.php
5 years ago
class-wc-countries.php
4 years ago
class-wc-coupon.php
5 years ago
class-wc-customer-download-log.php
5 years ago
class-wc-customer-download.php
5 years ago
class-wc-customer.php
4 years ago
class-wc-data-exception.php
8 years ago
class-wc-data-store.php
6 years ago
class-wc-datetime.php
5 years ago
class-wc-deprecated-action-hooks.php
8 years ago
class-wc-deprecated-filter-hooks.php
7 years ago
class-wc-discounts.php
4 years ago
class-wc-download-handler.php
4 years ago
class-wc-emails.php
5 years ago
class-wc-embed.php
5 years ago
class-wc-form-handler.php
5 years ago
class-wc-frontend-scripts.php
4 years ago
class-wc-geo-ip.php
5 years ago
class-wc-geolite-integration.php
6 years ago
class-wc-geolocation.php
4 years ago
class-wc-https.php
5 years ago
class-wc-install.php
4 years ago
class-wc-integrations.php
5 years ago
class-wc-log-levels.php
5 years ago
class-wc-logger.php
5 years ago
class-wc-meta-data.php
7 years ago
class-wc-order-factory.php
5 years ago
class-wc-order-item-coupon.php
5 years ago
class-wc-order-item-fee.php
5 years ago
class-wc-order-item-meta.php
5 years ago
class-wc-order-item-product.php
5 years ago
class-wc-order-item-shipping.php
5 years ago
class-wc-order-item-tax.php
5 years ago
class-wc-order-item.php
5 years ago
class-wc-order-query.php
4 years ago
class-wc-order-refund.php
5 years ago
class-wc-order.php
4 years ago
class-wc-payment-gateways.php
4 years ago
class-wc-payment-tokens.php
5 years ago
class-wc-post-data.php
4 years ago
class-wc-post-types.php
4 years ago
class-wc-privacy-background-process.php
5 years ago
class-wc-privacy-erasers.php
4 years ago
class-wc-privacy-exporters.php
4 years ago
class-wc-privacy.php
4 years ago
class-wc-product-attribute.php
5 years ago
class-wc-product-download.php
4 years ago
class-wc-product-external.php
5 years ago
class-wc-product-factory.php
5 years ago
class-wc-product-grouped.php
8 years ago
class-wc-product-query.php
5 years ago
class-wc-product-simple.php
5 years ago
class-wc-product-variable.php
4 years ago
class-wc-product-variation.php
4 years ago
class-wc-query.php
4 years ago
class-wc-rate-limiter.php
5 years ago
class-wc-regenerate-images-request.php
5 years ago
class-wc-regenerate-images.php
5 years ago
class-wc-register-wp-admin-settings.php
4 years ago
class-wc-rest-authentication.php
5 years ago
class-wc-rest-exception.php
5 years ago
class-wc-session-handler.php
5 years ago
class-wc-shipping-rate.php
5 years ago
class-wc-shipping-zone.php
5 years ago
class-wc-shipping-zones.php
5 years ago
class-wc-shipping.php
5 years ago
class-wc-shortcodes.php
5 years ago
class-wc-structured-data.php
5 years ago
class-wc-tax.php
5 years ago
class-wc-template-loader.php
4 years ago
class-wc-tracker.php
4 years ago
class-wc-validation.php
5 years ago
class-wc-webhook.php
5 years ago
class-woocommerce.php
3 months ago
wc-account-functions.php
5 years ago
wc-attribute-functions.php
5 years ago
wc-cart-functions.php
5 years ago
wc-conditional-functions.php
5 years ago
wc-core-functions.php
4 years ago
wc-coupon-functions.php
5 years ago
wc-deprecated-functions.php
5 years ago
wc-formatting-functions.php
4 years ago
wc-notice-functions.php
5 years ago
wc-order-functions.php
4 years ago
wc-order-item-functions.php
5 years ago
wc-page-functions.php
5 years ago
wc-product-functions.php
4 years ago
wc-rest-functions.php
5 years ago
wc-stock-functions.php
5 years ago
wc-template-functions.php
4 years ago
wc-template-hooks.php
5 years ago
wc-term-functions.php
5 years ago
wc-update-functions.php
4 years ago
wc-user-functions.php
5 years ago
wc-webhook-functions.php
5 years ago
wc-widget-functions.php
5 years ago
wc-deprecated-functions.php
1126 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Deprecated functions |
| 4 | * |
| 5 | * Where functions come to die. |
| 6 | * |
| 7 | * @author Automattic |
| 8 | * @category Core |
| 9 | * @package WooCommerce\Functions |
| 10 | * @version 3.3.0 |
| 11 | */ |
| 12 | |
| 13 | use Automattic\Jetpack\Constants; |
| 14 | |
| 15 | if ( ! defined( 'ABSPATH' ) ) { |
| 16 | exit; |
| 17 | } |
| 18 | |
| 19 | /** |
| 20 | * Runs a deprecated action with notice only if used. |
| 21 | * |
| 22 | * @since 3.0.0 |
| 23 | * @param string $tag The name of the action hook. |
| 24 | * @param array $args Array of additional function arguments to be passed to do_action(). |
| 25 | * @param string $version The version of WooCommerce that deprecated the hook. |
| 26 | * @param string $replacement The hook that should have been used. |
| 27 | * @param string $message A message regarding the change. |
| 28 | */ |
| 29 | function wc_do_deprecated_action( $tag, $args, $version, $replacement = null, $message = null ) { |
| 30 | if ( ! has_action( $tag ) ) { |
| 31 | return; |
| 32 | } |
| 33 | |
| 34 | wc_deprecated_hook( $tag, $version, $replacement, $message ); |
| 35 | do_action_ref_array( $tag, $args ); |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Wrapper for deprecated functions so we can apply some extra logic. |
| 40 | * |
| 41 | * @since 3.0.0 |
| 42 | * @param string $function Function used. |
| 43 | * @param string $version Version the message was added in. |
| 44 | * @param string $replacement Replacement for the called function. |
| 45 | */ |
| 46 | function wc_deprecated_function( $function, $version, $replacement = null ) { |
| 47 | // @codingStandardsIgnoreStart |
| 48 | if ( is_ajax() || WC()->is_rest_api_request() ) { |
| 49 | do_action( 'deprecated_function_run', $function, $replacement, $version ); |
| 50 | $log_string = "The {$function} function is deprecated since version {$version}."; |
| 51 | $log_string .= $replacement ? " Replace with {$replacement}." : ''; |
| 52 | error_log( $log_string ); |
| 53 | } else { |
| 54 | _deprecated_function( $function, $version, $replacement ); |
| 55 | } |
| 56 | // @codingStandardsIgnoreEnd |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Wrapper for deprecated hook so we can apply some extra logic. |
| 61 | * |
| 62 | * @since 3.3.0 |
| 63 | * @param string $hook The hook that was used. |
| 64 | * @param string $version The version of WordPress that deprecated the hook. |
| 65 | * @param string $replacement The hook that should have been used. |
| 66 | * @param string $message A message regarding the change. |
| 67 | */ |
| 68 | function wc_deprecated_hook( $hook, $version, $replacement = null, $message = null ) { |
| 69 | // @codingStandardsIgnoreStart |
| 70 | if ( is_ajax() || WC()->is_rest_api_request() ) { |
| 71 | do_action( 'deprecated_hook_run', $hook, $replacement, $version, $message ); |
| 72 | |
| 73 | $message = empty( $message ) ? '' : ' ' . $message; |
| 74 | $log_string = "{$hook} is deprecated since version {$version}"; |
| 75 | $log_string .= $replacement ? "! Use {$replacement} instead." : ' with no alternative available.'; |
| 76 | |
| 77 | error_log( $log_string . $message ); |
| 78 | } else { |
| 79 | _deprecated_hook( $hook, $version, $replacement, $message ); |
| 80 | } |
| 81 | // @codingStandardsIgnoreEnd |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * When catching an exception, this allows us to log it if unexpected. |
| 86 | * |
| 87 | * @since 3.3.0 |
| 88 | * @param Exception $exception_object The exception object. |
| 89 | * @param string $function The function which threw exception. |
| 90 | * @param array $args The args passed to the function. |
| 91 | */ |
| 92 | function wc_caught_exception( $exception_object, $function = '', $args = array() ) { |
| 93 | // @codingStandardsIgnoreStart |
| 94 | $message = $exception_object->getMessage(); |
| 95 | $message .= '. Args: ' . print_r( $args, true ) . '.'; |
| 96 | |
| 97 | do_action( 'woocommerce_caught_exception', $exception_object, $function, $args ); |
| 98 | error_log( "Exception caught in {$function}. {$message}." ); |
| 99 | // @codingStandardsIgnoreEnd |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * Wrapper for _doing_it_wrong(). |
| 104 | * |
| 105 | * @since 3.0.0 |
| 106 | * @param string $function Function used. |
| 107 | * @param string $message Message to log. |
| 108 | * @param string $version Version the message was added in. |
| 109 | */ |
| 110 | function wc_doing_it_wrong( $function, $message, $version ) { |
| 111 | // @codingStandardsIgnoreStart |
| 112 | $message .= ' Backtrace: ' . wp_debug_backtrace_summary(); |
| 113 | |
| 114 | if ( is_ajax() || WC()->is_rest_api_request() ) { |
| 115 | do_action( 'doing_it_wrong_run', $function, $message, $version ); |
| 116 | error_log( "{$function} was called incorrectly. {$message}. This message was added in version {$version}." ); |
| 117 | } else { |
| 118 | _doing_it_wrong( $function, $message, $version ); |
| 119 | } |
| 120 | // @codingStandardsIgnoreEnd |
| 121 | } |
| 122 | |
| 123 | /** |
| 124 | * Wrapper for deprecated arguments so we can apply some extra logic. |
| 125 | * |
| 126 | * @since 3.0.0 |
| 127 | * @param string $argument |
| 128 | * @param string $version |
| 129 | * @param string $replacement |
| 130 | */ |
| 131 | function wc_deprecated_argument( $argument, $version, $message = null ) { |
| 132 | if ( is_ajax() || WC()->is_rest_api_request() ) { |
| 133 | do_action( 'deprecated_argument_run', $argument, $message, $version ); |
| 134 | error_log( "The {$argument} argument is deprecated since version {$version}. {$message}" ); |
| 135 | } else { |
| 136 | _deprecated_argument( $argument, $version, $message ); |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | /** |
| 141 | * @deprecated 2.1 |
| 142 | */ |
| 143 | function woocommerce_show_messages() { |
| 144 | wc_deprecated_function( 'woocommerce_show_messages', '2.1', 'wc_print_notices' ); |
| 145 | wc_print_notices(); |
| 146 | } |
| 147 | |
| 148 | /** |
| 149 | * @deprecated 2.1 |
| 150 | */ |
| 151 | function woocommerce_weekend_area_js() { |
| 152 | wc_deprecated_function( 'woocommerce_weekend_area_js', '2.1' ); |
| 153 | } |
| 154 | |
| 155 | /** |
| 156 | * @deprecated 2.1 |
| 157 | */ |
| 158 | function woocommerce_tooltip_js() { |
| 159 | wc_deprecated_function( 'woocommerce_tooltip_js', '2.1' ); |
| 160 | } |
| 161 | |
| 162 | /** |
| 163 | * @deprecated 2.1 |
| 164 | */ |
| 165 | function woocommerce_datepicker_js() { |
| 166 | wc_deprecated_function( 'woocommerce_datepicker_js', '2.1' ); |
| 167 | } |
| 168 | |
| 169 | /** |
| 170 | * @deprecated 2.1 |
| 171 | */ |
| 172 | function woocommerce_admin_scripts() { |
| 173 | wc_deprecated_function( 'woocommerce_admin_scripts', '2.1' ); |
| 174 | } |
| 175 | |
| 176 | /** |
| 177 | * @deprecated 2.1 |
| 178 | */ |
| 179 | function woocommerce_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) { |
| 180 | wc_deprecated_function( 'woocommerce_create_page', '2.1', 'wc_create_page' ); |
| 181 | return wc_create_page( $slug, $option, $page_title, $page_content, $post_parent ); |
| 182 | } |
| 183 | |
| 184 | /** |
| 185 | * @deprecated 2.1 |
| 186 | */ |
| 187 | function woocommerce_readfile_chunked( $file, $retbytes = true ) { |
| 188 | wc_deprecated_function( 'woocommerce_readfile_chunked', '2.1', 'WC_Download_Handler::readfile_chunked()' ); |
| 189 | return WC_Download_Handler::readfile_chunked( $file ); |
| 190 | } |
| 191 | |
| 192 | /** |
| 193 | * Formal total costs - format to the number of decimal places for the base currency. |
| 194 | * |
| 195 | * @access public |
| 196 | * @param mixed $number |
| 197 | * @deprecated 2.1 |
| 198 | * @return string |
| 199 | */ |
| 200 | function woocommerce_format_total( $number ) { |
| 201 | wc_deprecated_function( __FUNCTION__, '2.1', 'wc_format_decimal()' ); |
| 202 | return wc_format_decimal( $number, wc_get_price_decimals(), false ); |
| 203 | } |
| 204 | |
| 205 | /** |
| 206 | * Get product name with extra details such as SKU price and attributes. Used within admin. |
| 207 | * |
| 208 | * @access public |
| 209 | * @param WC_Product $product |
| 210 | * @deprecated 2.1 |
| 211 | * @return string |
| 212 | */ |
| 213 | function woocommerce_get_formatted_product_name( $product ) { |
| 214 | wc_deprecated_function( __FUNCTION__, '2.1', 'WC_Product::get_formatted_name()' ); |
| 215 | return $product->get_formatted_name(); |
| 216 | } |
| 217 | |
| 218 | /** |
| 219 | * Handle IPN requests for the legacy paypal gateway by calling gateways manually if needed. |
| 220 | * |
| 221 | * @access public |
| 222 | */ |
| 223 | function woocommerce_legacy_paypal_ipn() { |
| 224 | if ( ! empty( $_GET['paypalListener'] ) && 'paypal_standard_IPN' === $_GET['paypalListener'] ) { |
| 225 | WC()->payment_gateways(); |
| 226 | do_action( 'woocommerce_api_wc_gateway_paypal' ); |
| 227 | } |
| 228 | } |
| 229 | add_action( 'init', 'woocommerce_legacy_paypal_ipn' ); |
| 230 | |
| 231 | /** |
| 232 | * @deprecated 3.0 |
| 233 | */ |
| 234 | function get_product( $the_product = false, $args = array() ) { |
| 235 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_product' ); |
| 236 | return wc_get_product( $the_product, $args ); |
| 237 | } |
| 238 | |
| 239 | /** |
| 240 | * @deprecated 3.0 |
| 241 | */ |
| 242 | function woocommerce_protected_product_add_to_cart( $passed, $product_id ) { |
| 243 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_protected_product_add_to_cart' ); |
| 244 | return wc_protected_product_add_to_cart( $passed, $product_id ); |
| 245 | } |
| 246 | |
| 247 | /** |
| 248 | * @deprecated 3.0 |
| 249 | */ |
| 250 | function woocommerce_empty_cart() { |
| 251 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_empty_cart' ); |
| 252 | wc_empty_cart(); |
| 253 | } |
| 254 | |
| 255 | /** |
| 256 | * @deprecated 3.0 |
| 257 | */ |
| 258 | function woocommerce_load_persistent_cart( $user_login, $user = 0 ) { |
| 259 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_load_persistent_cart' ); |
| 260 | return wc_load_persistent_cart( $user_login, $user ); |
| 261 | } |
| 262 | |
| 263 | /** |
| 264 | * @deprecated 3.0 |
| 265 | */ |
| 266 | function woocommerce_add_to_cart_message( $product_id ) { |
| 267 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_add_to_cart_message' ); |
| 268 | wc_add_to_cart_message( $product_id ); |
| 269 | } |
| 270 | |
| 271 | /** |
| 272 | * @deprecated 3.0 |
| 273 | */ |
| 274 | function woocommerce_clear_cart_after_payment() { |
| 275 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_clear_cart_after_payment' ); |
| 276 | wc_clear_cart_after_payment(); |
| 277 | } |
| 278 | |
| 279 | /** |
| 280 | * @deprecated 3.0 |
| 281 | */ |
| 282 | function woocommerce_cart_totals_subtotal_html() { |
| 283 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_cart_totals_subtotal_html' ); |
| 284 | wc_cart_totals_subtotal_html(); |
| 285 | } |
| 286 | |
| 287 | /** |
| 288 | * @deprecated 3.0 |
| 289 | */ |
| 290 | function woocommerce_cart_totals_shipping_html() { |
| 291 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_cart_totals_shipping_html' ); |
| 292 | wc_cart_totals_shipping_html(); |
| 293 | } |
| 294 | |
| 295 | /** |
| 296 | * @deprecated 3.0 |
| 297 | */ |
| 298 | function woocommerce_cart_totals_coupon_html( $coupon ) { |
| 299 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_cart_totals_coupon_html' ); |
| 300 | wc_cart_totals_coupon_html( $coupon ); |
| 301 | } |
| 302 | |
| 303 | /** |
| 304 | * @deprecated 3.0 |
| 305 | */ |
| 306 | function woocommerce_cart_totals_order_total_html() { |
| 307 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_cart_totals_order_total_html' ); |
| 308 | wc_cart_totals_order_total_html(); |
| 309 | } |
| 310 | |
| 311 | /** |
| 312 | * @deprecated 3.0 |
| 313 | */ |
| 314 | function woocommerce_cart_totals_fee_html( $fee ) { |
| 315 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_cart_totals_fee_html' ); |
| 316 | wc_cart_totals_fee_html( $fee ); |
| 317 | } |
| 318 | |
| 319 | /** |
| 320 | * @deprecated 3.0 |
| 321 | */ |
| 322 | function woocommerce_cart_totals_shipping_method_label( $method ) { |
| 323 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_cart_totals_shipping_method_label' ); |
| 324 | return wc_cart_totals_shipping_method_label( $method ); |
| 325 | } |
| 326 | |
| 327 | /** |
| 328 | * @deprecated 3.0 |
| 329 | */ |
| 330 | function woocommerce_get_template_part( $slug, $name = '' ) { |
| 331 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_template_part' ); |
| 332 | wc_get_template_part( $slug, $name ); |
| 333 | } |
| 334 | |
| 335 | /** |
| 336 | * @deprecated 3.0 |
| 337 | */ |
| 338 | function woocommerce_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
| 339 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_template' ); |
| 340 | wc_get_template( $template_name, $args, $template_path, $default_path ); |
| 341 | } |
| 342 | |
| 343 | /** |
| 344 | * @deprecated 3.0 |
| 345 | */ |
| 346 | function woocommerce_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
| 347 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_locate_template' ); |
| 348 | return wc_locate_template( $template_name, $template_path, $default_path ); |
| 349 | } |
| 350 | |
| 351 | /** |
| 352 | * @deprecated 3.0 |
| 353 | */ |
| 354 | function woocommerce_mail( $to, $subject, $message, $headers = "Content-Type: text/html\r\n", $attachments = "" ) { |
| 355 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_mail' ); |
| 356 | wc_mail( $to, $subject, $message, $headers, $attachments ); |
| 357 | } |
| 358 | |
| 359 | /** |
| 360 | * @deprecated 3.0 |
| 361 | */ |
| 362 | function woocommerce_disable_admin_bar( $show_admin_bar ) { |
| 363 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_disable_admin_bar' ); |
| 364 | return wc_disable_admin_bar( $show_admin_bar ); |
| 365 | } |
| 366 | |
| 367 | /** |
| 368 | * @deprecated 3.0 |
| 369 | */ |
| 370 | function woocommerce_create_new_customer( $email, $username = '', $password = '' ) { |
| 371 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_create_new_customer' ); |
| 372 | return wc_create_new_customer( $email, $username, $password ); |
| 373 | } |
| 374 | |
| 375 | /** |
| 376 | * @deprecated 3.0 |
| 377 | */ |
| 378 | function woocommerce_set_customer_auth_cookie( $customer_id ) { |
| 379 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_set_customer_auth_cookie' ); |
| 380 | wc_set_customer_auth_cookie( $customer_id ); |
| 381 | } |
| 382 | |
| 383 | /** |
| 384 | * @deprecated 3.0 |
| 385 | */ |
| 386 | function woocommerce_update_new_customer_past_orders( $customer_id ) { |
| 387 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_update_new_customer_past_orders' ); |
| 388 | return wc_update_new_customer_past_orders( $customer_id ); |
| 389 | } |
| 390 | |
| 391 | /** |
| 392 | * @deprecated 3.0 |
| 393 | */ |
| 394 | function woocommerce_paying_customer( $order_id ) { |
| 395 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_paying_customer' ); |
| 396 | wc_paying_customer( $order_id ); |
| 397 | } |
| 398 | |
| 399 | /** |
| 400 | * @deprecated 3.0 |
| 401 | */ |
| 402 | function woocommerce_customer_bought_product( $customer_email, $user_id, $product_id ) { |
| 403 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_customer_bought_product' ); |
| 404 | return wc_customer_bought_product( $customer_email, $user_id, $product_id ); |
| 405 | } |
| 406 | |
| 407 | /** |
| 408 | * @deprecated 3.0 |
| 409 | */ |
| 410 | function woocommerce_customer_has_capability( $allcaps, $caps, $args ) { |
| 411 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_customer_has_capability' ); |
| 412 | return wc_customer_has_capability( $allcaps, $caps, $args ); |
| 413 | } |
| 414 | |
| 415 | /** |
| 416 | * @deprecated 3.0 |
| 417 | */ |
| 418 | function woocommerce_sanitize_taxonomy_name( $taxonomy ) { |
| 419 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_sanitize_taxonomy_name' ); |
| 420 | return wc_sanitize_taxonomy_name( $taxonomy ); |
| 421 | } |
| 422 | |
| 423 | /** |
| 424 | * @deprecated 3.0 |
| 425 | */ |
| 426 | function woocommerce_get_filename_from_url( $file_url ) { |
| 427 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_filename_from_url' ); |
| 428 | return wc_get_filename_from_url( $file_url ); |
| 429 | } |
| 430 | |
| 431 | /** |
| 432 | * @deprecated 3.0 |
| 433 | */ |
| 434 | function woocommerce_get_dimension( $dim, $to_unit ) { |
| 435 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_dimension' ); |
| 436 | return wc_get_dimension( $dim, $to_unit ); |
| 437 | } |
| 438 | |
| 439 | /** |
| 440 | * @deprecated 3.0 |
| 441 | */ |
| 442 | function woocommerce_get_weight( $weight, $to_unit ) { |
| 443 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_weight' ); |
| 444 | return wc_get_weight( $weight, $to_unit ); |
| 445 | } |
| 446 | |
| 447 | /** |
| 448 | * @deprecated 3.0 |
| 449 | */ |
| 450 | function woocommerce_trim_zeros( $price ) { |
| 451 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_trim_zeros' ); |
| 452 | return wc_trim_zeros( $price ); |
| 453 | } |
| 454 | |
| 455 | /** |
| 456 | * @deprecated 3.0 |
| 457 | */ |
| 458 | function woocommerce_round_tax_total( $tax ) { |
| 459 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_round_tax_total' ); |
| 460 | return wc_round_tax_total( $tax ); |
| 461 | } |
| 462 | |
| 463 | /** |
| 464 | * @deprecated 3.0 |
| 465 | */ |
| 466 | function woocommerce_format_decimal( $number, $dp = false, $trim_zeros = false ) { |
| 467 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_format_decimal' ); |
| 468 | return wc_format_decimal( $number, $dp, $trim_zeros ); |
| 469 | } |
| 470 | |
| 471 | /** |
| 472 | * @deprecated 3.0 |
| 473 | */ |
| 474 | function woocommerce_clean( $var ) { |
| 475 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_clean' ); |
| 476 | return wc_clean( $var ); |
| 477 | } |
| 478 | |
| 479 | /** |
| 480 | * @deprecated 3.0 |
| 481 | */ |
| 482 | function woocommerce_array_overlay( $a1, $a2 ) { |
| 483 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_array_overlay' ); |
| 484 | return wc_array_overlay( $a1, $a2 ); |
| 485 | } |
| 486 | |
| 487 | /** |
| 488 | * @deprecated 3.0 |
| 489 | */ |
| 490 | function woocommerce_price( $price, $args = array() ) { |
| 491 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_price' ); |
| 492 | return wc_price( $price, $args ); |
| 493 | } |
| 494 | |
| 495 | /** |
| 496 | * @deprecated 3.0 |
| 497 | */ |
| 498 | function woocommerce_let_to_num( $size ) { |
| 499 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_let_to_num' ); |
| 500 | return wc_let_to_num( $size ); |
| 501 | } |
| 502 | |
| 503 | /** |
| 504 | * @deprecated 3.0 |
| 505 | */ |
| 506 | function woocommerce_date_format() { |
| 507 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_date_format' ); |
| 508 | return wc_date_format(); |
| 509 | } |
| 510 | |
| 511 | /** |
| 512 | * @deprecated 3.0 |
| 513 | */ |
| 514 | function woocommerce_time_format() { |
| 515 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_time_format' ); |
| 516 | return wc_time_format(); |
| 517 | } |
| 518 | |
| 519 | /** |
| 520 | * @deprecated 3.0 |
| 521 | */ |
| 522 | function woocommerce_timezone_string() { |
| 523 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_timezone_string' ); |
| 524 | return wc_timezone_string(); |
| 525 | } |
| 526 | |
| 527 | if ( ! function_exists( 'woocommerce_rgb_from_hex' ) ) { |
| 528 | /** |
| 529 | * @deprecated 3.0 |
| 530 | */ |
| 531 | function woocommerce_rgb_from_hex( $color ) { |
| 532 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_rgb_from_hex' ); |
| 533 | return wc_rgb_from_hex( $color ); |
| 534 | } |
| 535 | } |
| 536 | |
| 537 | if ( ! function_exists( 'woocommerce_hex_darker' ) ) { |
| 538 | /** |
| 539 | * @deprecated 3.0 |
| 540 | */ |
| 541 | function woocommerce_hex_darker( $color, $factor = 30 ) { |
| 542 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_hex_darker' ); |
| 543 | return wc_hex_darker( $color, $factor ); |
| 544 | } |
| 545 | } |
| 546 | |
| 547 | if ( ! function_exists( 'woocommerce_hex_lighter' ) ) { |
| 548 | /** |
| 549 | * @deprecated 3.0 |
| 550 | */ |
| 551 | function woocommerce_hex_lighter( $color, $factor = 30 ) { |
| 552 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_hex_lighter' ); |
| 553 | return wc_hex_lighter( $color, $factor ); |
| 554 | } |
| 555 | } |
| 556 | |
| 557 | if ( ! function_exists( 'woocommerce_light_or_dark' ) ) { |
| 558 | /** |
| 559 | * @deprecated 3.0 |
| 560 | */ |
| 561 | function woocommerce_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) { |
| 562 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_light_or_dark' ); |
| 563 | return wc_light_or_dark( $color, $dark, $light ); |
| 564 | } |
| 565 | } |
| 566 | |
| 567 | if ( ! function_exists( 'woocommerce_format_hex' ) ) { |
| 568 | /** |
| 569 | * @deprecated 3.0 |
| 570 | */ |
| 571 | function woocommerce_format_hex( $hex ) { |
| 572 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_format_hex' ); |
| 573 | return wc_format_hex( $hex ); |
| 574 | } |
| 575 | } |
| 576 | |
| 577 | /** |
| 578 | * @deprecated 3.0 |
| 579 | */ |
| 580 | function woocommerce_get_order_id_by_order_key( $order_key ) { |
| 581 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_order_id_by_order_key' ); |
| 582 | return wc_get_order_id_by_order_key( $order_key ); |
| 583 | } |
| 584 | |
| 585 | /** |
| 586 | * @deprecated 3.0 |
| 587 | */ |
| 588 | function woocommerce_downloadable_file_permission( $download_id, $product_id, $order ) { |
| 589 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_downloadable_file_permission' ); |
| 590 | return wc_downloadable_file_permission( $download_id, $product_id, $order ); |
| 591 | } |
| 592 | |
| 593 | /** |
| 594 | * @deprecated 3.0 |
| 595 | */ |
| 596 | function woocommerce_downloadable_product_permissions( $order_id ) { |
| 597 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_downloadable_product_permissions' ); |
| 598 | wc_downloadable_product_permissions( $order_id ); |
| 599 | } |
| 600 | |
| 601 | /** |
| 602 | * @deprecated 3.0 |
| 603 | */ |
| 604 | function woocommerce_add_order_item( $order_id, $item ) { |
| 605 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_add_order_item' ); |
| 606 | return wc_add_order_item( $order_id, $item ); |
| 607 | } |
| 608 | |
| 609 | /** |
| 610 | * @deprecated 3.0 |
| 611 | */ |
| 612 | function woocommerce_delete_order_item( $item_id ) { |
| 613 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_delete_order_item' ); |
| 614 | return wc_delete_order_item( $item_id ); |
| 615 | } |
| 616 | |
| 617 | /** |
| 618 | * @deprecated 3.0 |
| 619 | */ |
| 620 | function woocommerce_update_order_item_meta( $item_id, $meta_key, $meta_value, $prev_value = '' ) { |
| 621 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_update_order_item_meta' ); |
| 622 | return wc_update_order_item_meta( $item_id, $meta_key, $meta_value, $prev_value ); |
| 623 | } |
| 624 | |
| 625 | /** |
| 626 | * @deprecated 3.0 |
| 627 | */ |
| 628 | function woocommerce_add_order_item_meta( $item_id, $meta_key, $meta_value, $unique = false ) { |
| 629 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_add_order_item_meta' ); |
| 630 | return wc_add_order_item_meta( $item_id, $meta_key, $meta_value, $unique ); |
| 631 | } |
| 632 | |
| 633 | /** |
| 634 | * @deprecated 3.0 |
| 635 | */ |
| 636 | function woocommerce_delete_order_item_meta( $item_id, $meta_key, $meta_value = '', $delete_all = false ) { |
| 637 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_delete_order_item_meta' ); |
| 638 | return wc_delete_order_item_meta( $item_id, $meta_key, $meta_value, $delete_all ); |
| 639 | } |
| 640 | |
| 641 | /** |
| 642 | * @deprecated 3.0 |
| 643 | */ |
| 644 | function woocommerce_get_order_item_meta( $item_id, $key, $single = true ) { |
| 645 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_order_item_meta' ); |
| 646 | return wc_get_order_item_meta( $item_id, $key, $single ); |
| 647 | } |
| 648 | |
| 649 | /** |
| 650 | * @deprecated 3.0 |
| 651 | */ |
| 652 | function woocommerce_cancel_unpaid_orders() { |
| 653 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_cancel_unpaid_orders' ); |
| 654 | wc_cancel_unpaid_orders(); |
| 655 | } |
| 656 | |
| 657 | /** |
| 658 | * @deprecated 3.0 |
| 659 | */ |
| 660 | function woocommerce_processing_order_count() { |
| 661 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_processing_order_count' ); |
| 662 | return wc_processing_order_count(); |
| 663 | } |
| 664 | |
| 665 | /** |
| 666 | * @deprecated 3.0 |
| 667 | */ |
| 668 | function woocommerce_get_page_id( $page ) { |
| 669 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_page_id' ); |
| 670 | return wc_get_page_id( $page ); |
| 671 | } |
| 672 | |
| 673 | /** |
| 674 | * @deprecated 3.0 |
| 675 | */ |
| 676 | function woocommerce_get_endpoint_url( $endpoint, $value = '', $permalink = '' ) { |
| 677 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_endpoint_url' ); |
| 678 | return wc_get_endpoint_url( $endpoint, $value, $permalink ); |
| 679 | } |
| 680 | |
| 681 | /** |
| 682 | * @deprecated 3.0 |
| 683 | */ |
| 684 | function woocommerce_lostpassword_url( $url ) { |
| 685 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_lostpassword_url' ); |
| 686 | return wc_lostpassword_url( $url ); |
| 687 | } |
| 688 | |
| 689 | /** |
| 690 | * @deprecated 3.0 |
| 691 | */ |
| 692 | function woocommerce_customer_edit_account_url() { |
| 693 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_customer_edit_account_url' ); |
| 694 | return wc_customer_edit_account_url(); |
| 695 | } |
| 696 | |
| 697 | /** |
| 698 | * @deprecated 3.0 |
| 699 | */ |
| 700 | function woocommerce_nav_menu_items( $items, $args ) { |
| 701 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_nav_menu_items' ); |
| 702 | return wc_nav_menu_items( $items ); |
| 703 | } |
| 704 | |
| 705 | /** |
| 706 | * @deprecated 3.0 |
| 707 | */ |
| 708 | function woocommerce_nav_menu_item_classes( $menu_items, $args ) { |
| 709 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_nav_menu_item_classes' ); |
| 710 | return wc_nav_menu_item_classes( $menu_items ); |
| 711 | } |
| 712 | |
| 713 | /** |
| 714 | * @deprecated 3.0 |
| 715 | */ |
| 716 | function woocommerce_list_pages( $pages ) { |
| 717 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_list_pages' ); |
| 718 | return wc_list_pages( $pages ); |
| 719 | } |
| 720 | |
| 721 | /** |
| 722 | * @deprecated 3.0 |
| 723 | */ |
| 724 | function woocommerce_product_dropdown_categories( $args = array(), $deprecated_hierarchical = 1, $deprecated_show_uncategorized = 1, $deprecated_orderby = '' ) { |
| 725 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_product_dropdown_categories' ); |
| 726 | return wc_product_dropdown_categories( $args, $deprecated_hierarchical, $deprecated_show_uncategorized, $deprecated_orderby ); |
| 727 | } |
| 728 | |
| 729 | /** |
| 730 | * @deprecated 3.0 |
| 731 | */ |
| 732 | function woocommerce_walk_category_dropdown_tree( $a1 = '', $a2 = '', $a3 = '' ) { |
| 733 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_walk_category_dropdown_tree' ); |
| 734 | return wc_walk_category_dropdown_tree( $a1, $a2, $a3 ); |
| 735 | } |
| 736 | |
| 737 | /** |
| 738 | * @deprecated 3.0 |
| 739 | */ |
| 740 | function woocommerce_taxonomy_metadata_wpdbfix() { |
| 741 | wc_deprecated_function( __FUNCTION__, '3.0' ); |
| 742 | } |
| 743 | |
| 744 | /** |
| 745 | * @deprecated 3.0 |
| 746 | */ |
| 747 | function wc_taxonomy_metadata_wpdbfix() { |
| 748 | wc_deprecated_function( __FUNCTION__, '3.0' ); |
| 749 | } |
| 750 | |
| 751 | /** |
| 752 | * @deprecated 3.0 |
| 753 | */ |
| 754 | function woocommerce_order_terms( $the_term, $next_id, $taxonomy, $index = 0, $terms = null ) { |
| 755 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_reorder_terms' ); |
| 756 | return wc_reorder_terms( $the_term, $next_id, $taxonomy, $index, $terms ); |
| 757 | } |
| 758 | |
| 759 | /** |
| 760 | * @deprecated 3.0 |
| 761 | */ |
| 762 | function woocommerce_set_term_order( $term_id, $index, $taxonomy, $recursive = false ) { |
| 763 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_set_term_order' ); |
| 764 | return wc_set_term_order( $term_id, $index, $taxonomy, $recursive ); |
| 765 | } |
| 766 | |
| 767 | /** |
| 768 | * @deprecated 3.0 |
| 769 | */ |
| 770 | function woocommerce_terms_clauses( $clauses, $taxonomies, $args ) { |
| 771 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_terms_clauses' ); |
| 772 | return wc_terms_clauses( $clauses, $taxonomies, $args ); |
| 773 | } |
| 774 | |
| 775 | /** |
| 776 | * @deprecated 3.0 |
| 777 | */ |
| 778 | function _woocommerce_term_recount( $terms, $taxonomy, $callback, $terms_are_term_taxonomy_ids ) { |
| 779 | wc_deprecated_function( __FUNCTION__, '3.0', '_wc_term_recount' ); |
| 780 | return _wc_term_recount( $terms, $taxonomy, $callback, $terms_are_term_taxonomy_ids ); |
| 781 | } |
| 782 | |
| 783 | /** |
| 784 | * @deprecated 3.0 |
| 785 | */ |
| 786 | function woocommerce_recount_after_stock_change( $product_id ) { |
| 787 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_recount_after_stock_change' ); |
| 788 | return wc_recount_after_stock_change( $product_id ); |
| 789 | } |
| 790 | |
| 791 | /** |
| 792 | * @deprecated 3.0 |
| 793 | */ |
| 794 | function woocommerce_change_term_counts( $terms, $taxonomies, $args ) { |
| 795 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_change_term_counts' ); |
| 796 | return wc_change_term_counts( $terms, $taxonomies ); |
| 797 | } |
| 798 | |
| 799 | /** |
| 800 | * @deprecated 3.0 |
| 801 | */ |
| 802 | function woocommerce_get_product_ids_on_sale() { |
| 803 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_product_ids_on_sale' ); |
| 804 | return wc_get_product_ids_on_sale(); |
| 805 | } |
| 806 | |
| 807 | /** |
| 808 | * @deprecated 3.0 |
| 809 | */ |
| 810 | function woocommerce_get_featured_product_ids() { |
| 811 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_featured_product_ids' ); |
| 812 | return wc_get_featured_product_ids(); |
| 813 | } |
| 814 | |
| 815 | /** |
| 816 | * @deprecated 3.0 |
| 817 | */ |
| 818 | function woocommerce_get_product_terms( $object_id, $taxonomy, $fields = 'all' ) { |
| 819 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_product_terms' ); |
| 820 | return wc_get_product_terms( $object_id, $taxonomy, array( 'fields' => $fields ) ); |
| 821 | } |
| 822 | |
| 823 | /** |
| 824 | * @deprecated 3.0 |
| 825 | */ |
| 826 | function woocommerce_product_post_type_link( $permalink, $post ) { |
| 827 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_product_post_type_link' ); |
| 828 | return wc_product_post_type_link( $permalink, $post ); |
| 829 | } |
| 830 | |
| 831 | /** |
| 832 | * @deprecated 3.0 |
| 833 | */ |
| 834 | function woocommerce_placeholder_img_src() { |
| 835 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_placeholder_img_src' ); |
| 836 | return wc_placeholder_img_src(); |
| 837 | } |
| 838 | |
| 839 | /** |
| 840 | * @deprecated 3.0 |
| 841 | */ |
| 842 | function woocommerce_placeholder_img( $size = 'woocommerce_thumbnail' ) { |
| 843 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_placeholder_img' ); |
| 844 | return wc_placeholder_img( $size ); |
| 845 | } |
| 846 | |
| 847 | /** |
| 848 | * @deprecated 3.0 |
| 849 | */ |
| 850 | function woocommerce_get_formatted_variation( $variation = '', $flat = false ) { |
| 851 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_formatted_variation' ); |
| 852 | return wc_get_formatted_variation( $variation, $flat ); |
| 853 | } |
| 854 | |
| 855 | /** |
| 856 | * @deprecated 3.0 |
| 857 | */ |
| 858 | function woocommerce_scheduled_sales() { |
| 859 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_scheduled_sales' ); |
| 860 | return wc_scheduled_sales(); |
| 861 | } |
| 862 | |
| 863 | /** |
| 864 | * @deprecated 3.0 |
| 865 | */ |
| 866 | function woocommerce_get_attachment_image_attributes( $attr ) { |
| 867 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_attachment_image_attributes' ); |
| 868 | return wc_get_attachment_image_attributes( $attr ); |
| 869 | } |
| 870 | |
| 871 | /** |
| 872 | * @deprecated 3.0 |
| 873 | */ |
| 874 | function woocommerce_prepare_attachment_for_js( $response ) { |
| 875 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_prepare_attachment_for_js' ); |
| 876 | return wc_prepare_attachment_for_js( $response ); |
| 877 | } |
| 878 | |
| 879 | /** |
| 880 | * @deprecated 3.0 |
| 881 | */ |
| 882 | function woocommerce_track_product_view() { |
| 883 | wc_deprecated_function( __FUNCTION__, '3.0', 'wc_track_product_view' ); |
| 884 | return wc_track_product_view(); |
| 885 | } |
| 886 | |
| 887 | /** |
| 888 | * @deprecated 2.3 has no replacement |
| 889 | */ |
| 890 | function woocommerce_compile_less_styles() { |
| 891 | wc_deprecated_function( 'woocommerce_compile_less_styles', '2.3' ); |
| 892 | } |
| 893 | |
| 894 | /** |
| 895 | * 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 |
| 896 | * the woocommerce_ship_to_countries setting. |
| 897 | * @deprecated 2.6.0 |
| 898 | * @return string |
| 899 | */ |
| 900 | function woocommerce_calc_shipping_backwards_compatibility( $value ) { |
| 901 | if ( Constants::is_defined( 'WC_UPDATING' ) ) { |
| 902 | return $value; |
| 903 | } |
| 904 | return 'disabled' === get_option( 'woocommerce_ship_to_countries' ) ? 'no' : 'yes'; |
| 905 | } |
| 906 | add_filter( 'pre_option_woocommerce_calc_shipping', 'woocommerce_calc_shipping_backwards_compatibility' ); |
| 907 | |
| 908 | /** |
| 909 | * @deprecated 3.0.0 |
| 910 | * @see WC_Structured_Data class |
| 911 | * |
| 912 | * @return string |
| 913 | */ |
| 914 | function woocommerce_get_product_schema() { |
| 915 | wc_deprecated_function( 'woocommerce_get_product_schema', '3.0' ); |
| 916 | |
| 917 | global $product; |
| 918 | |
| 919 | $schema = "Product"; |
| 920 | |
| 921 | // Downloadable product schema handling |
| 922 | if ( $product->is_downloadable() ) { |
| 923 | switch ( $product->download_type ) { |
| 924 | case 'application' : |
| 925 | $schema = "SoftwareApplication"; |
| 926 | break; |
| 927 | case 'music' : |
| 928 | $schema = "MusicAlbum"; |
| 929 | break; |
| 930 | default : |
| 931 | $schema = "Product"; |
| 932 | break; |
| 933 | } |
| 934 | } |
| 935 | |
| 936 | return 'http://schema.org/' . $schema; |
| 937 | } |
| 938 | |
| 939 | /** |
| 940 | * Save product price. |
| 941 | * |
| 942 | * This is a private function (internal use ONLY) used until a data manipulation api is built. |
| 943 | * |
| 944 | * @deprecated 3.0.0 |
| 945 | * @param int $product_id |
| 946 | * @param float $regular_price |
| 947 | * @param float $sale_price |
| 948 | * @param string $date_from |
| 949 | * @param string $date_to |
| 950 | */ |
| 951 | function _wc_save_product_price( $product_id, $regular_price, $sale_price = '', $date_from = '', $date_to = '' ) { |
| 952 | wc_doing_it_wrong( '_wc_save_product_price()', 'This function is not for developer use and is deprecated.', '3.0' ); |
| 953 | |
| 954 | $product_id = absint( $product_id ); |
| 955 | $regular_price = wc_format_decimal( $regular_price ); |
| 956 | $sale_price = '' === $sale_price ? '' : wc_format_decimal( $sale_price ); |
| 957 | $date_from = wc_clean( $date_from ); |
| 958 | $date_to = wc_clean( $date_to ); |
| 959 | |
| 960 | update_post_meta( $product_id, '_regular_price', $regular_price ); |
| 961 | update_post_meta( $product_id, '_sale_price', $sale_price ); |
| 962 | |
| 963 | // Save Dates |
| 964 | update_post_meta( $product_id, '_sale_price_dates_from', $date_from ? strtotime( $date_from ) : '' ); |
| 965 | update_post_meta( $product_id, '_sale_price_dates_to', $date_to ? strtotime( $date_to ) : '' ); |
| 966 | |
| 967 | if ( $date_to && ! $date_from ) { |
| 968 | $date_from = strtotime( 'NOW', current_time( 'timestamp' ) ); |
| 969 | update_post_meta( $product_id, '_sale_price_dates_from', $date_from ); |
| 970 | } |
| 971 | |
| 972 | // Update price if on sale |
| 973 | if ( '' !== $sale_price && '' === $date_to && '' === $date_from ) { |
| 974 | update_post_meta( $product_id, '_price', $sale_price ); |
| 975 | } else { |
| 976 | update_post_meta( $product_id, '_price', $regular_price ); |
| 977 | } |
| 978 | |
| 979 | if ( '' !== $sale_price && $date_from && strtotime( $date_from ) < strtotime( 'NOW', current_time( 'timestamp' ) ) ) { |
| 980 | update_post_meta( $product_id, '_price', $sale_price ); |
| 981 | } |
| 982 | |
| 983 | if ( $date_to && strtotime( $date_to ) < strtotime( 'NOW', current_time( 'timestamp' ) ) ) { |
| 984 | update_post_meta( $product_id, '_price', $regular_price ); |
| 985 | update_post_meta( $product_id, '_sale_price_dates_from', '' ); |
| 986 | update_post_meta( $product_id, '_sale_price_dates_to', '' ); |
| 987 | } |
| 988 | } |
| 989 | |
| 990 | /** |
| 991 | * Return customer avatar URL. |
| 992 | * |
| 993 | * @deprecated 3.1.0 |
| 994 | * @since 2.6.0 |
| 995 | * @param string $email the customer's email. |
| 996 | * @return string the URL to the customer's avatar. |
| 997 | */ |
| 998 | function wc_get_customer_avatar_url( $email ) { |
| 999 | // Deprecated in favor of WordPress get_avatar_url() function. |
| 1000 | wc_deprecated_function( 'wc_get_customer_avatar_url()', '3.1', 'get_avatar_url()' ); |
| 1001 | |
| 1002 | return get_avatar_url( $email ); |
| 1003 | } |
| 1004 | |
| 1005 | /** |
| 1006 | * WooCommerce Core Supported Themes. |
| 1007 | * |
| 1008 | * @deprecated 3.3.0 |
| 1009 | * @since 2.2 |
| 1010 | * @return string[] |
| 1011 | */ |
| 1012 | function wc_get_core_supported_themes() { |
| 1013 | wc_deprecated_function( 'wc_get_core_supported_themes()', '3.3' ); |
| 1014 | return array( 'twentyseventeen', 'twentysixteen', 'twentyfifteen', 'twentyfourteen', 'twentythirteen', 'twentyeleven', 'twentytwelve', 'twentyten' ); |
| 1015 | } |
| 1016 | |
| 1017 | /** |
| 1018 | * Get min/max price meta query args. |
| 1019 | * |
| 1020 | * @deprecated 3.6.0 |
| 1021 | * @since 3.0.0 |
| 1022 | * @param array $args Min price and max price arguments. |
| 1023 | * @return array |
| 1024 | */ |
| 1025 | function wc_get_min_max_price_meta_query( $args ) { |
| 1026 | wc_deprecated_function( 'wc_get_min_max_price_meta_query()', '3.6' ); |
| 1027 | |
| 1028 | $current_min_price = isset( $args['min_price'] ) ? floatval( $args['min_price'] ) : 0; |
| 1029 | $current_max_price = isset( $args['max_price'] ) ? floatval( $args['max_price'] ) : PHP_INT_MAX; |
| 1030 | |
| 1031 | return apply_filters( |
| 1032 | 'woocommerce_get_min_max_price_meta_query', |
| 1033 | array( |
| 1034 | 'key' => '_price', |
| 1035 | 'value' => array( $current_min_price, $current_max_price ), |
| 1036 | 'compare' => 'BETWEEN', |
| 1037 | 'type' => 'DECIMAL(10,' . wc_get_price_decimals() . ')', |
| 1038 | ), |
| 1039 | $args |
| 1040 | ); |
| 1041 | } |
| 1042 | |
| 1043 | /** |
| 1044 | * When a term is split, ensure meta data maintained. |
| 1045 | * |
| 1046 | * @deprecated 3.6.0 |
| 1047 | * @param int $old_term_id Old term ID. |
| 1048 | * @param int $new_term_id New term ID. |
| 1049 | * @param string $term_taxonomy_id Term taxonomy ID. |
| 1050 | * @param string $taxonomy Taxonomy. |
| 1051 | */ |
| 1052 | function wc_taxonomy_metadata_update_content_for_split_terms( $old_term_id, $new_term_id, $term_taxonomy_id, $taxonomy ) { |
| 1053 | wc_deprecated_function( 'wc_taxonomy_metadata_update_content_for_split_terms', '3.6' ); |
| 1054 | } |
| 1055 | |
| 1056 | /** |
| 1057 | * WooCommerce Term Meta API. |
| 1058 | * |
| 1059 | * WC tables for storing term meta are deprecated from WordPress 4.4 since 4.4 has its own table. |
| 1060 | * This function serves as a wrapper, using the new table if present, or falling back to the WC table. |
| 1061 | * |
| 1062 | * @deprecated 3.6.0 |
| 1063 | * @param int $term_id Term ID. |
| 1064 | * @param string $meta_key Meta key. |
| 1065 | * @param mixed $meta_value Meta value. |
| 1066 | * @param string $prev_value Previous value. (default: ''). |
| 1067 | * @return bool |
| 1068 | */ |
| 1069 | function update_woocommerce_term_meta( $term_id, $meta_key, $meta_value, $prev_value = '' ) { |
| 1070 | wc_deprecated_function( 'update_woocommerce_term_meta', '3.6', 'update_term_meta' ); |
| 1071 | return function_exists( 'update_term_meta' ) ? update_term_meta( $term_id, $meta_key, $meta_value, $prev_value ) : update_metadata( 'woocommerce_term', $term_id, $meta_key, $meta_value, $prev_value ); |
| 1072 | } |
| 1073 | |
| 1074 | /** |
| 1075 | * WooCommerce Term Meta API. |
| 1076 | * |
| 1077 | * WC tables for storing term meta are deprecated from WordPress 4.4 since 4.4 has its own table. |
| 1078 | * This function serves as a wrapper, using the new table if present, or falling back to the WC table. |
| 1079 | * |
| 1080 | * @deprecated 3.6.0 |
| 1081 | * @param int $term_id Term ID. |
| 1082 | * @param string $meta_key Meta key. |
| 1083 | * @param mixed $meta_value Meta value. |
| 1084 | * @param bool $unique Make meta key unique. (default: false). |
| 1085 | * @return bool |
| 1086 | */ |
| 1087 | function add_woocommerce_term_meta( $term_id, $meta_key, $meta_value, $unique = false ) { |
| 1088 | wc_deprecated_function( 'add_woocommerce_term_meta', '3.6', 'add_term_meta' ); |
| 1089 | return function_exists( 'add_term_meta' ) ? add_term_meta( $term_id, $meta_key, $meta_value, $unique ) : add_metadata( 'woocommerce_term', $term_id, $meta_key, $meta_value, $unique ); |
| 1090 | } |
| 1091 | |
| 1092 | /** |
| 1093 | * WooCommerce Term Meta API |
| 1094 | * |
| 1095 | * WC tables for storing term meta are deprecated from WordPress 4.4 since 4.4 has its own table. |
| 1096 | * This function serves as a wrapper, using the new table if present, or falling back to the WC table. |
| 1097 | * |
| 1098 | * @deprecated 3.6.0 |
| 1099 | * @param int $term_id Term ID. |
| 1100 | * @param string $meta_key Meta key. |
| 1101 | * @param string $meta_value Meta value (default: ''). |
| 1102 | * @param bool $deprecated Deprecated param (default: false). |
| 1103 | * @return bool |
| 1104 | */ |
| 1105 | function delete_woocommerce_term_meta( $term_id, $meta_key, $meta_value = '', $deprecated = false ) { |
| 1106 | wc_deprecated_function( 'delete_woocommerce_term_meta', '3.6', 'delete_term_meta' ); |
| 1107 | return function_exists( 'delete_term_meta' ) ? delete_term_meta( $term_id, $meta_key, $meta_value ) : delete_metadata( 'woocommerce_term', $term_id, $meta_key, $meta_value ); |
| 1108 | } |
| 1109 | |
| 1110 | /** |
| 1111 | * WooCommerce Term Meta API |
| 1112 | * |
| 1113 | * WC tables for storing term meta are deprecated from WordPress 4.4 since 4.4 has its own table. |
| 1114 | * This function serves as a wrapper, using the new table if present, or falling back to the WC table. |
| 1115 | * |
| 1116 | * @deprecated 3.6.0 |
| 1117 | * @param int $term_id Term ID. |
| 1118 | * @param string $key Meta key. |
| 1119 | * @param bool $single Whether to return a single value. (default: true). |
| 1120 | * @return mixed |
| 1121 | */ |
| 1122 | function get_woocommerce_term_meta( $term_id, $key, $single = true ) { |
| 1123 | wc_deprecated_function( 'get_woocommerce_term_meta', '3.6', 'get_term_meta' ); |
| 1124 | return function_exists( 'get_term_meta' ) ? get_term_meta( $term_id, $key, $single ) : get_metadata( 'woocommerce_term', $term_id, $key, $single ); |
| 1125 | } |
| 1126 |