wc-deprecated-functions.php 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014
  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. if ( ! defined( 'ABSPATH' ) ) {
  13. exit;
  14. }
  15. /**
  16. * Runs a deprecated action with notice only if used.
  17. *
  18. * @since 3.0.0
  19. * @param string $tag The name of the action hook.
  20. * @param array $args Array of additional function arguments to be passed to do_action().
  21. * @param string $version The version of WooCommerce that deprecated the hook.
  22. * @param string $replacement The hook that should have been used.
  23. * @param string $message A message regarding the change.
  24. */
  25. function wc_do_deprecated_action( $tag, $args, $version, $replacement = null, $message = null ) {
  26. if ( ! has_action( $tag ) ) {
  27. return;
  28. }
  29. wc_deprecated_hook( $tag, $version, $replacement, $message );
  30. do_action_ref_array( $tag, $args );
  31. }
  32. /**
  33. * Wrapper for deprecated functions so we can apply some extra logic.
  34. *
  35. * @since 3.0.0
  36. * @param string $function Function used.
  37. * @param string $version Version the message was added in.
  38. * @param string $replacement Replacement for the called function.
  39. */
  40. function wc_deprecated_function( $function, $version, $replacement = null ) {
  41. // @codingStandardsIgnoreStart
  42. if ( is_ajax() ) {
  43. do_action( 'deprecated_function_run', $function, $replacement, $version );
  44. $log_string = "The {$function} function is deprecated since version {$version}.";
  45. $log_string .= $replacement ? " Replace with {$replacement}." : '';
  46. error_log( $log_string );
  47. } else {
  48. _deprecated_function( $function, $version, $replacement );
  49. }
  50. // @codingStandardsIgnoreEnd
  51. }
  52. /**
  53. * Wrapper for deprecated hook so we can apply some extra logic.
  54. *
  55. * @since 3.3.0
  56. * @param string $hook The hook that was used.
  57. * @param string $version The version of WordPress that deprecated the hook.
  58. * @param string $replacement The hook that should have been used.
  59. * @param string $message A message regarding the change.
  60. */
  61. function wc_deprecated_hook( $hook, $version, $replacement = null, $message = null ) {
  62. // @codingStandardsIgnoreStart
  63. if ( is_ajax() ) {
  64. do_action( 'deprecated_hook_run', $hook, $replacement, $version, $message );
  65. $message = empty( $message ) ? '' : ' ' . $message;
  66. $log_string = "{$hook} is deprecated since version {$version}";
  67. $log_string .= $replacement ? "! Use {$replacement} instead." : ' with no alternative available.';
  68. error_log( $log_string . $message );
  69. } else {
  70. _deprecated_hook( $hook, $version, $replacement, $message );
  71. }
  72. // @codingStandardsIgnoreEnd
  73. }
  74. /**
  75. * When catching an exception, this allows us to log it if unexpected.
  76. *
  77. * @since 3.3.0
  78. * @param Exception $exception_object The exception object.
  79. * @param string $function The function which threw exception.
  80. * @param array $args The args passed to the function.
  81. */
  82. function wc_caught_exception( $exception_object, $function = '', $args = array() ) {
  83. // @codingStandardsIgnoreStart
  84. $message = $exception_object->getMessage();
  85. $message .= '. Args: ' . print_r( $args, true ) . '.';
  86. do_action( 'woocommerce_caught_exception', $exception_object, $function, $args );
  87. error_log( "Exception caught in {$function}. {$message}." );
  88. // @codingStandardsIgnoreEnd
  89. }
  90. /**
  91. * Wrapper for wc_doing_it_wrong.
  92. *
  93. * @since 3.0.0
  94. * @param string $function Function used.
  95. * @param string $message Message to log.
  96. * @param string $version Version the message was added in.
  97. */
  98. function wc_doing_it_wrong( $function, $message, $version ) {
  99. // @codingStandardsIgnoreStart
  100. $message .= ' Backtrace: ' . wp_debug_backtrace_summary();
  101. if ( is_ajax() ) {
  102. do_action( 'doing_it_wrong_run', $function, $message, $version );
  103. error_log( "{$function} was called incorrectly. {$message}. This message was added in version {$version}." );
  104. } else {
  105. _doing_it_wrong( $function, $message, $version );
  106. }
  107. // @codingStandardsIgnoreEnd
  108. }
  109. /**
  110. * Wrapper for deprecated arguments so we can apply some extra logic.
  111. *
  112. * @since 3.0.0
  113. * @param string $argument
  114. * @param string $version
  115. * @param string $replacement
  116. */
  117. function wc_deprecated_argument( $argument, $version, $message = null ) {
  118. if ( is_ajax() ) {
  119. do_action( 'deprecated_argument_run', $argument, $message, $version );
  120. error_log( "The {$argument} argument is deprecated since version {$version}. {$message}" );
  121. } else {
  122. _deprecated_argument( $argument, $version, $message );
  123. }
  124. }
  125. /**
  126. * @deprecated 2.1
  127. */
  128. function woocommerce_show_messages() {
  129. wc_deprecated_function( 'woocommerce_show_messages', '2.1', 'wc_print_notices' );
  130. wc_print_notices();
  131. }
  132. /**
  133. * @deprecated 2.1
  134. */
  135. function woocommerce_weekend_area_js() {
  136. wc_deprecated_function( 'woocommerce_weekend_area_js', '2.1' );
  137. }
  138. /**
  139. * @deprecated 2.1
  140. */
  141. function woocommerce_tooltip_js() {
  142. wc_deprecated_function( 'woocommerce_tooltip_js', '2.1' );
  143. }
  144. /**
  145. * @deprecated 2.1
  146. */
  147. function woocommerce_datepicker_js() {
  148. wc_deprecated_function( 'woocommerce_datepicker_js', '2.1' );
  149. }
  150. /**
  151. * @deprecated 2.1
  152. */
  153. function woocommerce_admin_scripts() {
  154. wc_deprecated_function( 'woocommerce_admin_scripts', '2.1' );
  155. }
  156. /**
  157. * @deprecated 2.1
  158. */
  159. function woocommerce_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) {
  160. wc_deprecated_function( 'woocommerce_create_page', '2.1', 'wc_create_page' );
  161. return wc_create_page( $slug, $option, $page_title, $page_content, $post_parent );
  162. }
  163. /**
  164. * @deprecated 2.1
  165. */
  166. function woocommerce_readfile_chunked( $file, $retbytes = true ) {
  167. wc_deprecated_function( 'woocommerce_readfile_chunked', '2.1', 'WC_Download_Handler::readfile_chunked()' );
  168. return WC_Download_Handler::readfile_chunked( $file );
  169. }
  170. /**
  171. * Formal total costs - format to the number of decimal places for the base currency.
  172. *
  173. * @access public
  174. * @param mixed $number
  175. * @deprecated 2.1
  176. * @return string
  177. */
  178. function woocommerce_format_total( $number ) {
  179. wc_deprecated_function( __FUNCTION__, '2.1', 'wc_format_decimal()' );
  180. return wc_format_decimal( $number, wc_get_price_decimals(), false );
  181. }
  182. /**
  183. * Get product name with extra details such as SKU price and attributes. Used within admin.
  184. *
  185. * @access public
  186. * @param WC_Product $product
  187. * @deprecated 2.1
  188. * @return string
  189. */
  190. function woocommerce_get_formatted_product_name( $product ) {
  191. wc_deprecated_function( __FUNCTION__, '2.1', 'WC_Product::get_formatted_name()' );
  192. return $product->get_formatted_name();
  193. }
  194. /**
  195. * Handle IPN requests for the legacy paypal gateway by calling gateways manually if needed.
  196. *
  197. * @access public
  198. */
  199. function woocommerce_legacy_paypal_ipn() {
  200. if ( ! empty( $_GET['paypalListener'] ) && 'paypal_standard_IPN' === $_GET['paypalListener'] ) {
  201. WC()->payment_gateways();
  202. do_action( 'woocommerce_api_wc_gateway_paypal' );
  203. }
  204. }
  205. add_action( 'init', 'woocommerce_legacy_paypal_ipn' );
  206. /**
  207. * @deprecated 3.0
  208. */
  209. function get_product( $the_product = false, $args = array() ) {
  210. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_product' );
  211. return wc_get_product( $the_product, $args );
  212. }
  213. /**
  214. * @deprecated 3.0
  215. */
  216. function woocommerce_protected_product_add_to_cart( $passed, $product_id ) {
  217. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_protected_product_add_to_cart' );
  218. return wc_protected_product_add_to_cart( $passed, $product_id );
  219. }
  220. /**
  221. * @deprecated 3.0
  222. */
  223. function woocommerce_empty_cart() {
  224. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_empty_cart' );
  225. wc_empty_cart();
  226. }
  227. /**
  228. * @deprecated 3.0
  229. */
  230. function woocommerce_load_persistent_cart( $user_login, $user = 0 ) {
  231. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_load_persistent_cart' );
  232. return wc_load_persistent_cart( $user_login, $user );
  233. }
  234. /**
  235. * @deprecated 3.0
  236. */
  237. function woocommerce_add_to_cart_message( $product_id ) {
  238. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_add_to_cart_message' );
  239. wc_add_to_cart_message( $product_id );
  240. }
  241. /**
  242. * @deprecated 3.0
  243. */
  244. function woocommerce_clear_cart_after_payment() {
  245. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_clear_cart_after_payment' );
  246. wc_clear_cart_after_payment();
  247. }
  248. /**
  249. * @deprecated 3.0
  250. */
  251. function woocommerce_cart_totals_subtotal_html() {
  252. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_cart_totals_subtotal_html' );
  253. wc_cart_totals_subtotal_html();
  254. }
  255. /**
  256. * @deprecated 3.0
  257. */
  258. function woocommerce_cart_totals_shipping_html() {
  259. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_cart_totals_shipping_html' );
  260. wc_cart_totals_shipping_html();
  261. }
  262. /**
  263. * @deprecated 3.0
  264. */
  265. function woocommerce_cart_totals_coupon_html( $coupon ) {
  266. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_cart_totals_coupon_html' );
  267. wc_cart_totals_coupon_html( $coupon );
  268. }
  269. /**
  270. * @deprecated 3.0
  271. */
  272. function woocommerce_cart_totals_order_total_html() {
  273. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_cart_totals_order_total_html' );
  274. wc_cart_totals_order_total_html();
  275. }
  276. /**
  277. * @deprecated 3.0
  278. */
  279. function woocommerce_cart_totals_fee_html( $fee ) {
  280. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_cart_totals_fee_html' );
  281. wc_cart_totals_fee_html( $fee );
  282. }
  283. /**
  284. * @deprecated 3.0
  285. */
  286. function woocommerce_cart_totals_shipping_method_label( $method ) {
  287. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_cart_totals_shipping_method_label' );
  288. return wc_cart_totals_shipping_method_label( $method );
  289. }
  290. /**
  291. * @deprecated 3.0
  292. */
  293. function woocommerce_get_template_part( $slug, $name = '' ) {
  294. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_template_part' );
  295. wc_get_template_part( $slug, $name );
  296. }
  297. /**
  298. * @deprecated 3.0
  299. */
  300. function woocommerce_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
  301. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_template' );
  302. wc_get_template( $template_name, $args, $template_path, $default_path );
  303. }
  304. /**
  305. * @deprecated 3.0
  306. */
  307. function woocommerce_locate_template( $template_name, $template_path = '', $default_path = '' ) {
  308. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_locate_template' );
  309. return wc_locate_template( $template_name, $template_path, $default_path );
  310. }
  311. /**
  312. * @deprecated 3.0
  313. */
  314. function woocommerce_mail( $to, $subject, $message, $headers = "Content-Type: text/html\r\n", $attachments = "" ) {
  315. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_mail' );
  316. wc_mail( $to, $subject, $message, $headers, $attachments );
  317. }
  318. /**
  319. * @deprecated 3.0
  320. */
  321. function woocommerce_disable_admin_bar( $show_admin_bar ) {
  322. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_disable_admin_bar' );
  323. return wc_disable_admin_bar( $show_admin_bar );
  324. }
  325. /**
  326. * @deprecated 3.0
  327. */
  328. function woocommerce_create_new_customer( $email, $username = '', $password = '' ) {
  329. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_create_new_customer' );
  330. return wc_create_new_customer( $email, $username, $password );
  331. }
  332. /**
  333. * @deprecated 3.0
  334. */
  335. function woocommerce_set_customer_auth_cookie( $customer_id ) {
  336. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_set_customer_auth_cookie' );
  337. wc_set_customer_auth_cookie( $customer_id );
  338. }
  339. /**
  340. * @deprecated 3.0
  341. */
  342. function woocommerce_update_new_customer_past_orders( $customer_id ) {
  343. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_update_new_customer_past_orders' );
  344. return wc_update_new_customer_past_orders( $customer_id );
  345. }
  346. /**
  347. * @deprecated 3.0
  348. */
  349. function woocommerce_paying_customer( $order_id ) {
  350. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_paying_customer' );
  351. wc_paying_customer( $order_id );
  352. }
  353. /**
  354. * @deprecated 3.0
  355. */
  356. function woocommerce_customer_bought_product( $customer_email, $user_id, $product_id ) {
  357. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_customer_bought_product' );
  358. return wc_customer_bought_product( $customer_email, $user_id, $product_id );
  359. }
  360. /**
  361. * @deprecated 3.0
  362. */
  363. function woocommerce_customer_has_capability( $allcaps, $caps, $args ) {
  364. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_customer_has_capability' );
  365. return wc_customer_has_capability( $allcaps, $caps, $args );
  366. }
  367. /**
  368. * @deprecated 3.0
  369. */
  370. function woocommerce_sanitize_taxonomy_name( $taxonomy ) {
  371. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_sanitize_taxonomy_name' );
  372. return wc_sanitize_taxonomy_name( $taxonomy );
  373. }
  374. /**
  375. * @deprecated 3.0
  376. */
  377. function woocommerce_get_filename_from_url( $file_url ) {
  378. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_filename_from_url' );
  379. return wc_get_filename_from_url( $file_url );
  380. }
  381. /**
  382. * @deprecated 3.0
  383. */
  384. function woocommerce_get_dimension( $dim, $to_unit ) {
  385. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_dimension' );
  386. return wc_get_dimension( $dim, $to_unit );
  387. }
  388. /**
  389. * @deprecated 3.0
  390. */
  391. function woocommerce_get_weight( $weight, $to_unit ) {
  392. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_weight' );
  393. return wc_get_weight( $weight, $to_unit );
  394. }
  395. /**
  396. * @deprecated 3.0
  397. */
  398. function woocommerce_trim_zeros( $price ) {
  399. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_trim_zeros' );
  400. return wc_trim_zeros( $price );
  401. }
  402. /**
  403. * @deprecated 3.0
  404. */
  405. function woocommerce_round_tax_total( $tax ) {
  406. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_round_tax_total' );
  407. return wc_round_tax_total( $tax );
  408. }
  409. /**
  410. * @deprecated 3.0
  411. */
  412. function woocommerce_format_decimal( $number, $dp = false, $trim_zeros = false ) {
  413. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_format_decimal' );
  414. return wc_format_decimal( $number, $dp, $trim_zeros );
  415. }
  416. /**
  417. * @deprecated 3.0
  418. */
  419. function woocommerce_clean( $var ) {
  420. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_clean' );
  421. return wc_clean( $var );
  422. }
  423. /**
  424. * @deprecated 3.0
  425. */
  426. function woocommerce_array_overlay( $a1, $a2 ) {
  427. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_array_overlay' );
  428. return wc_array_overlay( $a1, $a2 );
  429. }
  430. /**
  431. * @deprecated 3.0
  432. */
  433. function woocommerce_price( $price, $args = array() ) {
  434. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_price' );
  435. return wc_price( $price, $args );
  436. }
  437. /**
  438. * @deprecated 3.0
  439. */
  440. function woocommerce_let_to_num( $size ) {
  441. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_let_to_num' );
  442. return wc_let_to_num( $size );
  443. }
  444. /**
  445. * @deprecated 3.0
  446. */
  447. function woocommerce_date_format() {
  448. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_date_format' );
  449. return wc_date_format();
  450. }
  451. /**
  452. * @deprecated 3.0
  453. */
  454. function woocommerce_time_format() {
  455. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_time_format' );
  456. return wc_time_format();
  457. }
  458. /**
  459. * @deprecated 3.0
  460. */
  461. function woocommerce_timezone_string() {
  462. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_timezone_string' );
  463. return wc_timezone_string();
  464. }
  465. if ( ! function_exists( 'woocommerce_rgb_from_hex' ) ) {
  466. /**
  467. * @deprecated 3.0
  468. */
  469. function woocommerce_rgb_from_hex( $color ) {
  470. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_rgb_from_hex' );
  471. return wc_rgb_from_hex( $color );
  472. }
  473. }
  474. if ( ! function_exists( 'woocommerce_hex_darker' ) ) {
  475. /**
  476. * @deprecated 3.0
  477. */
  478. function woocommerce_hex_darker( $color, $factor = 30 ) {
  479. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_hex_darker' );
  480. return wc_hex_darker( $color, $factor );
  481. }
  482. }
  483. if ( ! function_exists( 'woocommerce_hex_lighter' ) ) {
  484. /**
  485. * @deprecated 3.0
  486. */
  487. function woocommerce_hex_lighter( $color, $factor = 30 ) {
  488. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_hex_lighter' );
  489. return wc_hex_lighter( $color, $factor );
  490. }
  491. }
  492. if ( ! function_exists( 'woocommerce_light_or_dark' ) ) {
  493. /**
  494. * @deprecated 3.0
  495. */
  496. function woocommerce_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) {
  497. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_light_or_dark' );
  498. return wc_light_or_dark( $color, $dark, $light );
  499. }
  500. }
  501. if ( ! function_exists( 'woocommerce_format_hex' ) ) {
  502. /**
  503. * @deprecated 3.0
  504. */
  505. function woocommerce_format_hex( $hex ) {
  506. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_format_hex' );
  507. return wc_format_hex( $hex );
  508. }
  509. }
  510. /**
  511. * @deprecated 3.0
  512. */
  513. function woocommerce_get_order_id_by_order_key( $order_key ) {
  514. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_order_id_by_order_key' );
  515. return wc_get_order_id_by_order_key( $order_key );
  516. }
  517. /**
  518. * @deprecated 3.0
  519. */
  520. function woocommerce_downloadable_file_permission( $download_id, $product_id, $order ) {
  521. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_downloadable_file_permission' );
  522. return wc_downloadable_file_permission( $download_id, $product_id, $order );
  523. }
  524. /**
  525. * @deprecated 3.0
  526. */
  527. function woocommerce_downloadable_product_permissions( $order_id ) {
  528. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_downloadable_product_permissions' );
  529. wc_downloadable_product_permissions( $order_id );
  530. }
  531. /**
  532. * @deprecated 3.0
  533. */
  534. function woocommerce_add_order_item( $order_id, $item ) {
  535. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_add_order_item' );
  536. return wc_add_order_item( $order_id, $item );
  537. }
  538. /**
  539. * @deprecated 3.0
  540. */
  541. function woocommerce_delete_order_item( $item_id ) {
  542. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_delete_order_item' );
  543. return wc_delete_order_item( $item_id );
  544. }
  545. /**
  546. * @deprecated 3.0
  547. */
  548. function woocommerce_update_order_item_meta( $item_id, $meta_key, $meta_value, $prev_value = '' ) {
  549. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_update_order_item_meta' );
  550. return wc_update_order_item_meta( $item_id, $meta_key, $meta_value, $prev_value );
  551. }
  552. /**
  553. * @deprecated 3.0
  554. */
  555. function woocommerce_add_order_item_meta( $item_id, $meta_key, $meta_value, $unique = false ) {
  556. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_add_order_item_meta' );
  557. return wc_add_order_item_meta( $item_id, $meta_key, $meta_value, $unique );
  558. }
  559. /**
  560. * @deprecated 3.0
  561. */
  562. function woocommerce_delete_order_item_meta( $item_id, $meta_key, $meta_value = '', $delete_all = false ) {
  563. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_delete_order_item_meta' );
  564. return wc_delete_order_item_meta( $item_id, $meta_key, $meta_value, $delete_all );
  565. }
  566. /**
  567. * @deprecated 3.0
  568. */
  569. function woocommerce_get_order_item_meta( $item_id, $key, $single = true ) {
  570. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_order_item_meta' );
  571. return wc_get_order_item_meta( $item_id, $key, $single );
  572. }
  573. /**
  574. * @deprecated 3.0
  575. */
  576. function woocommerce_cancel_unpaid_orders() {
  577. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_cancel_unpaid_orders' );
  578. wc_cancel_unpaid_orders();
  579. }
  580. /**
  581. * @deprecated 3.0
  582. */
  583. function woocommerce_processing_order_count() {
  584. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_processing_order_count' );
  585. return wc_processing_order_count();
  586. }
  587. /**
  588. * @deprecated 3.0
  589. */
  590. function woocommerce_get_page_id( $page ) {
  591. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_page_id' );
  592. return wc_get_page_id( $page );
  593. }
  594. /**
  595. * @deprecated 3.0
  596. */
  597. function woocommerce_get_endpoint_url( $endpoint, $value = '', $permalink = '' ) {
  598. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_endpoint_url' );
  599. return wc_get_endpoint_url( $endpoint, $value, $permalink );
  600. }
  601. /**
  602. * @deprecated 3.0
  603. */
  604. function woocommerce_lostpassword_url( $url ) {
  605. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_lostpassword_url' );
  606. return wc_lostpassword_url( $url );
  607. }
  608. /**
  609. * @deprecated 3.0
  610. */
  611. function woocommerce_customer_edit_account_url() {
  612. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_customer_edit_account_url' );
  613. return wc_customer_edit_account_url();
  614. }
  615. /**
  616. * @deprecated 3.0
  617. */
  618. function woocommerce_nav_menu_items( $items, $args ) {
  619. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_nav_menu_items' );
  620. return wc_nav_menu_items( $items );
  621. }
  622. /**
  623. * @deprecated 3.0
  624. */
  625. function woocommerce_nav_menu_item_classes( $menu_items, $args ) {
  626. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_nav_menu_item_classes' );
  627. return wc_nav_menu_item_classes( $menu_items );
  628. }
  629. /**
  630. * @deprecated 3.0
  631. */
  632. function woocommerce_list_pages( $pages ) {
  633. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_list_pages' );
  634. return wc_list_pages( $pages );
  635. }
  636. /**
  637. * @deprecated 3.0
  638. */
  639. function woocommerce_product_dropdown_categories( $args = array(), $deprecated_hierarchical = 1, $deprecated_show_uncategorized = 1, $deprecated_orderby = '' ) {
  640. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_product_dropdown_categories' );
  641. return wc_product_dropdown_categories( $args, $deprecated_hierarchical, $deprecated_show_uncategorized, $deprecated_orderby );
  642. }
  643. /**
  644. * @deprecated 3.0
  645. */
  646. function woocommerce_walk_category_dropdown_tree( $a1 = '', $a2 = '', $a3 = '' ) {
  647. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_walk_category_dropdown_tree' );
  648. return wc_walk_category_dropdown_tree( $a1, $a2, $a3 );
  649. }
  650. /**
  651. * @deprecated 3.0
  652. */
  653. function woocommerce_taxonomy_metadata_wpdbfix() {
  654. wc_deprecated_function( __FUNCTION__, '3.0' );
  655. }
  656. /**
  657. * @deprecated 3.0
  658. */
  659. function wc_taxonomy_metadata_wpdbfix() {
  660. wc_deprecated_function( __FUNCTION__, '3.0' );
  661. }
  662. /**
  663. * @deprecated 3.0
  664. */
  665. function woocommerce_order_terms( $the_term, $next_id, $taxonomy, $index = 0, $terms = null ) {
  666. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_reorder_terms' );
  667. return wc_reorder_terms( $the_term, $next_id, $taxonomy, $index, $terms );
  668. }
  669. /**
  670. * @deprecated 3.0
  671. */
  672. function woocommerce_set_term_order( $term_id, $index, $taxonomy, $recursive = false ) {
  673. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_set_term_order' );
  674. return wc_set_term_order( $term_id, $index, $taxonomy, $recursive );
  675. }
  676. /**
  677. * @deprecated 3.0
  678. */
  679. function woocommerce_terms_clauses( $clauses, $taxonomies, $args ) {
  680. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_terms_clauses' );
  681. return wc_terms_clauses( $clauses, $taxonomies, $args );
  682. }
  683. /**
  684. * @deprecated 3.0
  685. */
  686. function _woocommerce_term_recount( $terms, $taxonomy, $callback, $terms_are_term_taxonomy_ids ) {
  687. wc_deprecated_function( __FUNCTION__, '3.0', '_wc_term_recount' );
  688. return _wc_term_recount( $terms, $taxonomy, $callback, $terms_are_term_taxonomy_ids );
  689. }
  690. /**
  691. * @deprecated 3.0
  692. */
  693. function woocommerce_recount_after_stock_change( $product_id ) {
  694. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_recount_after_stock_change' );
  695. return wc_recount_after_stock_change( $product_id );
  696. }
  697. /**
  698. * @deprecated 3.0
  699. */
  700. function woocommerce_change_term_counts( $terms, $taxonomies, $args ) {
  701. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_change_term_counts' );
  702. return wc_change_term_counts( $terms, $taxonomies );
  703. }
  704. /**
  705. * @deprecated 3.0
  706. */
  707. function woocommerce_get_product_ids_on_sale() {
  708. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_product_ids_on_sale' );
  709. return wc_get_product_ids_on_sale();
  710. }
  711. /**
  712. * @deprecated 3.0
  713. */
  714. function woocommerce_get_featured_product_ids() {
  715. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_featured_product_ids' );
  716. return wc_get_featured_product_ids();
  717. }
  718. /**
  719. * @deprecated 3.0
  720. */
  721. function woocommerce_get_product_terms( $object_id, $taxonomy, $fields = 'all' ) {
  722. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_product_terms' );
  723. return wc_get_product_terms( $object_id, $taxonomy, array( 'fields' => $fields ) );
  724. }
  725. /**
  726. * @deprecated 3.0
  727. */
  728. function woocommerce_product_post_type_link( $permalink, $post ) {
  729. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_product_post_type_link' );
  730. return wc_product_post_type_link( $permalink, $post );
  731. }
  732. /**
  733. * @deprecated 3.0
  734. */
  735. function woocommerce_placeholder_img_src() {
  736. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_placeholder_img_src' );
  737. return wc_placeholder_img_src();
  738. }
  739. /**
  740. * @deprecated 3.0
  741. */
  742. function woocommerce_placeholder_img( $size = 'woocommerce_thumbnail' ) {
  743. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_placeholder_img' );
  744. return wc_placeholder_img( $size );
  745. }
  746. /**
  747. * @deprecated 3.0
  748. */
  749. function woocommerce_get_formatted_variation( $variation = '', $flat = false ) {
  750. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_formatted_variation' );
  751. return wc_get_formatted_variation( $variation, $flat );
  752. }
  753. /**
  754. * @deprecated 3.0
  755. */
  756. function woocommerce_scheduled_sales() {
  757. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_scheduled_sales' );
  758. return wc_scheduled_sales();
  759. }
  760. /**
  761. * @deprecated 3.0
  762. */
  763. function woocommerce_get_attachment_image_attributes( $attr ) {
  764. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_attachment_image_attributes' );
  765. return wc_get_attachment_image_attributes( $attr );
  766. }
  767. /**
  768. * @deprecated 3.0
  769. */
  770. function woocommerce_prepare_attachment_for_js( $response ) {
  771. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_prepare_attachment_for_js' );
  772. return wc_prepare_attachment_for_js( $response );
  773. }
  774. /**
  775. * @deprecated 3.0
  776. */
  777. function woocommerce_track_product_view() {
  778. wc_deprecated_function( __FUNCTION__, '3.0', 'wc_track_product_view' );
  779. return wc_track_product_view();
  780. }
  781. /**
  782. * @since 2.3
  783. * @deprecated 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. * @since 2.6.0
  792. * @return string
  793. */
  794. function woocommerce_calc_shipping_backwards_compatibility( $value ) {
  795. if ( 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. }