WC_Deprecated_Filter_Hooks

Handles deprecation notices and triggering of legacy filter hooks.

Defined (1)

The class is defined in the following location(s).

/includes/class-wc-deprecated-filter-hooks.php  
  1. class WC_Deprecated_Filter_Hooks extends WC_Deprecated_Hooks { 
  2.  
  3. /** 
  4. * Array of deprecated hooks we need to handle. 
  5. * Format of 'new' => 'old'. 
  6. * @var array 
  7. */ 
  8. protected $deprecated_hooks = array( 
  9. 'woocommerce_structured_data_order' => 'woocommerce_email_order_schema_markup',  
  10. 'woocommerce_add_to_cart_fragments' => 'add_to_cart_fragments',  
  11. 'woocommerce_add_to_cart_redirect' => 'add_to_cart_redirect',  
  12. 'woocommerce_product_get_width' => 'woocommerce_product_width',  
  13. 'woocommerce_product_get_height' => 'woocommerce_product_height',  
  14. 'woocommerce_product_get_length' => 'woocommerce_product_length',  
  15. 'woocommerce_product_get_weight' => 'woocommerce_product_weight',  
  16. 'woocommerce_product_get_sku' => 'woocommerce_get_sku',  
  17. 'woocommerce_product_get_price' => 'woocommerce_get_price',  
  18. 'woocommerce_product_get_regular_price' => 'woocommerce_get_regular_price',  
  19. 'woocommerce_product_get_sale_price' => 'woocommerce_get_sale_price',  
  20. 'woocommerce_product_get_tax_class' => 'woocommerce_product_tax_class',  
  21. 'woocommerce_product_get_stock_quantity' => 'woocommerce_get_stock_quantity',  
  22. 'woocommerce_product_get_attributes' => 'woocommerce_get_product_attributes',  
  23. 'woocommerce_product_get_gallery_image_ids' => 'woocommerce_product_gallery_attachment_ids',  
  24. 'woocommerce_product_get_review_count' => 'woocommerce_product_review_count',  
  25. 'woocommerce_product_get_downloads' => 'woocommerce_product_files',  
  26. 'woocommerce_order_get_currency' => 'woocommerce_get_currency',  
  27. 'woocommerce_order_get_discount_total' => 'woocommerce_order_amount_discount_total',  
  28. 'woocommerce_order_get_discount_tax' => 'woocommerce_order_amount_discount_tax',  
  29. 'woocommerce_order_get_shipping_total' => 'woocommerce_order_amount_shipping_total',  
  30. 'woocommerce_order_get_shipping_tax' => 'woocommerce_order_amount_shipping_tax',  
  31. 'woocommerce_order_get_cart_tax' => 'woocommerce_order_amount_cart_tax',  
  32. 'woocommerce_order_get_total' => 'woocommerce_order_amount_total',  
  33. 'woocommerce_order_get_total_tax' => 'woocommerce_order_amount_total_tax',  
  34. 'woocommerce_order_get_total_discount' => 'woocommerce_order_amount_total_discount',  
  35. 'woocommerce_order_get_subtotal' => 'woocommerce_order_amount_subtotal',  
  36. 'woocommerce_order_get_tax_totals' => 'woocommerce_order_tax_totals',  
  37. 'woocommerce_get_order_refund_get_amount' => 'woocommerce_refund_amount',  
  38. 'woocommerce_get_order_refund_get_reason' => 'woocommerce_refund_reason',  
  39. 'default_checkout_billing_country' => 'default_checkout_country',  
  40. 'default_checkout_billing_state' => 'default_checkout_state',  
  41. 'default_checkout_billing_postcode' => 'default_checkout_postcode',  
  42. 'woocommerce_system_status_environment_rows' => 'woocommerce_debug_posting',  
  43. ); 
  44.  
  45. /** 
  46. * Hook into the new hook so we can handle deprecated hooks once fired. 
  47. * @param string $hook_name 
  48. */ 
  49. public function hook_in( $hook_name ) { 
  50. add_filter( $hook_name, array( $this, 'maybe_handle_deprecated_hook' ), -1000, 8 ); 
  51.  
  52. /** 
  53. * If the old hook is in-use, trigger it. 
  54. * @param string $new_hook 
  55. * @param string $old_hook 
  56. * @param array $new_callback_args 
  57. * @param mixed $return_value 
  58. * @return mixed 
  59. */ 
  60. public function handle_deprecated_hook( $new_hook, $old_hook, $new_callback_args, $return_value ) { 
  61. if ( has_filter( $old_hook ) ) { 
  62. $this->display_notice( $old_hook, $new_hook ); 
  63. $return_value = $this->trigger_hook( $old_hook, $new_callback_args ); 
  64. return $return_value; 
  65.  
  66. /** 
  67. * Fire off a legacy hook with it's args. 
  68. * @param string $old_hook 
  69. * @param array $new_callback_args 
  70. * @return mixed 
  71. */ 
  72. protected function trigger_hook( $old_hook, $new_callback_args ) { 
  73. return apply_filters_ref_array( $old_hook, $new_callback_args );