Nav apraksta

wc-deprecated-functions.php 33KB

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