abstracts
3 years ago
admin
3 years ago
blocks
5 years ago
cli
3 years ago
customizer
3 years ago
data-stores
3 years ago
emails
3 years ago
export
3 years ago
gateways
3 years ago
import
4 years ago
integrations
4 years ago
interfaces
4 years ago
legacy
3 years ago
libraries
3 years ago
log-handlers
4 years ago
payment-tokens
5 years ago
queue
4 years ago
react-admin
3 years ago
rest-api
3 years ago
shipping
4 years ago
shortcodes
4 years ago
theme-support
3 years ago
tracks
3 years ago
traits
5 years ago
walkers
5 years ago
wccom-site
5 years ago
widgets
4 years ago
class-wc-ajax.php
3 years ago
class-wc-api.php
4 years ago
class-wc-auth.php
4 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
3 years ago
class-wc-cart-totals.php
4 years ago
class-wc-cart.php
4 years ago
class-wc-checkout.php
4 years ago
class-wc-cli.php
3 years ago
class-wc-comments.php
3 years ago
class-wc-countries.php
4 years ago
class-wc-coupon.php
4 years ago
class-wc-customer-download-log.php
5 years ago
class-wc-customer-download.php
4 years ago
class-wc-customer.php
4 years ago
class-wc-data-exception.php
8 years ago
class-wc-data-store.php
3 years ago
class-wc-datetime.php
4 years ago
class-wc-deprecated-action-hooks.php
8 years ago
class-wc-deprecated-filter-hooks.php
4 years ago
class-wc-discounts.php
3 years ago
class-wc-download-handler.php
4 years ago
class-wc-emails.php
3 years ago
class-wc-embed.php
5 years ago
class-wc-form-handler.php
4 years ago
class-wc-frontend-scripts.php
3 years ago
class-wc-geo-ip.php
4 years ago
class-wc-geolite-integration.php
6 years ago
class-wc-geolocation.php
3 years ago
class-wc-https.php
4 years ago
class-wc-install.php
3 years ago
class-wc-integrations.php
5 years ago
class-wc-log-levels.php
5 years ago
class-wc-logger.php
4 years ago
class-wc-meta-data.php
4 years ago
class-wc-order-factory.php
3 years ago
class-wc-order-item-coupon.php
4 years ago
class-wc-order-item-fee.php
4 years ago
class-wc-order-item-meta.php
4 years ago
class-wc-order-item-product.php
4 years ago
class-wc-order-item-shipping.php
4 years ago
class-wc-order-item-tax.php
4 years ago
class-wc-order-item.php
4 years ago
class-wc-order-query.php
4 years ago
class-wc-order-refund.php
3 years ago
class-wc-order.php
3 years ago
class-wc-payment-gateways.php
4 years ago
class-wc-payment-tokens.php
5 years ago
class-wc-post-data.php
3 years ago
class-wc-post-types.php
3 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
4 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
3 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
4 years ago
class-wc-regenerate-images-request.php
3 years ago
class-wc-regenerate-images.php
3 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
4 years ago
class-wc-shipping-rate.php
4 years ago
class-wc-shipping-zone.php
5 years ago
class-wc-shipping-zones.php
5 years ago
class-wc-shipping.php
4 years ago
class-wc-shortcodes.php
5 years ago
class-wc-structured-data.php
5 years ago
class-wc-tax.php
4 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
3 years ago
class-woocommerce.php
3 years ago
wc-account-functions.php
5 years ago
wc-attribute-functions.php
3 years ago
wc-cart-functions.php
4 years ago
wc-conditional-functions.php
4 years ago
wc-core-functions.php
3 years ago
wc-coupon-functions.php
5 years ago
wc-deprecated-functions.php
4 years ago
wc-formatting-functions.php
3 years ago
wc-notice-functions.php
5 years ago
wc-order-functions.php
3 years ago
wc-order-item-functions.php
5 years ago
wc-page-functions.php
5 years ago
wc-product-functions.php
3 years ago
wc-rest-functions.php
3 years ago
wc-stock-functions.php
4 years ago
wc-template-functions.php
3 years ago
wc-template-hooks.php
5 years ago
wc-term-functions.php
3 years ago
wc-update-functions.php
3 years ago
wc-user-functions.php
3 years ago
wc-webhook-functions.php
4 years ago
wc-widget-functions.php
5 years ago
class-wc-deprecated-action-hooks.php
192 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Deprecated action hooks |
| 4 | * |
| 5 | * @package WooCommerce\Abstracts |
| 6 | * @since 3.0.0 |
| 7 | * @version 3.3.0 |
| 8 | */ |
| 9 | |
| 10 | defined( 'ABSPATH' ) || exit; |
| 11 | |
| 12 | /** |
| 13 | * Handles deprecation notices and triggering of legacy action hooks. |
| 14 | */ |
| 15 | class WC_Deprecated_Action_Hooks extends WC_Deprecated_Hooks { |
| 16 | |
| 17 | /** |
| 18 | * Array of deprecated hooks we need to handle. Format of 'new' => 'old'. |
| 19 | * |
| 20 | * @var array |
| 21 | */ |
| 22 | protected $deprecated_hooks = array( |
| 23 | 'woocommerce_new_order_item' => array( |
| 24 | 'woocommerce_order_add_shipping', |
| 25 | 'woocommerce_order_add_coupon', |
| 26 | 'woocommerce_order_add_tax', |
| 27 | 'woocommerce_order_add_fee', |
| 28 | 'woocommerce_add_shipping_order_item', |
| 29 | 'woocommerce_add_order_item_meta', |
| 30 | 'woocommerce_add_order_fee_meta', |
| 31 | ), |
| 32 | 'woocommerce_update_order_item' => array( |
| 33 | 'woocommerce_order_edit_product', |
| 34 | 'woocommerce_order_update_coupon', |
| 35 | 'woocommerce_order_update_shipping', |
| 36 | 'woocommerce_order_update_fee', |
| 37 | 'woocommerce_order_update_tax', |
| 38 | ), |
| 39 | 'woocommerce_new_payment_token' => 'woocommerce_payment_token_created', |
| 40 | 'woocommerce_new_product_variation' => 'woocommerce_create_product_variation', |
| 41 | 'woocommerce_order_details_after_order_table_items' => 'woocommerce_order_items_table', |
| 42 | |
| 43 | 'woocommerce_settings_advanced_page_options' => array( |
| 44 | 'woocommerce_settings_checkout_page_options', |
| 45 | 'woocommerce_settings_account_page_options', |
| 46 | ), |
| 47 | 'woocommerce_settings_advanced_page_options_end' => array( |
| 48 | 'woocommerce_settings_checkout_page_options_end', |
| 49 | 'woocommerce_settings_account_page_options_end', |
| 50 | ), |
| 51 | 'woocommerce_settings_advanced_page_options_after' => array( |
| 52 | 'woocommerce_settings_checkout_page_options_after', |
| 53 | 'woocommerce_settings_account_page_options_after', |
| 54 | ), |
| 55 | ); |
| 56 | |
| 57 | /** |
| 58 | * Array of versions on each hook has been deprecated. |
| 59 | * |
| 60 | * @var array |
| 61 | */ |
| 62 | protected $deprecated_version = array( |
| 63 | 'woocommerce_order_add_shipping' => '3.0.0', |
| 64 | 'woocommerce_order_add_coupon' => '3.0.0', |
| 65 | 'woocommerce_order_add_tax' => '3.0.0', |
| 66 | 'woocommerce_order_add_fee' => '3.0.0', |
| 67 | 'woocommerce_add_shipping_order_item' => '3.0.0', |
| 68 | 'woocommerce_add_order_item_meta' => '3.0.0', |
| 69 | 'woocommerce_add_order_fee_meta' => '3.0.0', |
| 70 | 'woocommerce_order_edit_product' => '3.0.0', |
| 71 | 'woocommerce_order_update_coupon' => '3.0.0', |
| 72 | 'woocommerce_order_update_shipping' => '3.0.0', |
| 73 | 'woocommerce_order_update_fee' => '3.0.0', |
| 74 | 'woocommerce_order_update_tax' => '3.0.0', |
| 75 | 'woocommerce_payment_token_created' => '3.0.0', |
| 76 | 'woocommerce_create_product_variation' => '3.0.0', |
| 77 | 'woocommerce_order_items_table' => '3.0.0', |
| 78 | 'woocommerce_settings_checkout_page_options' => '3.4.0', |
| 79 | 'woocommerce_settings_account_page_options' => '3.4.0', |
| 80 | 'woocommerce_settings_checkout_page_options_end' => '3.4.0', |
| 81 | 'woocommerce_settings_account_page_options_end' => '3.4.0', |
| 82 | 'woocommerce_settings_checkout_page_options_after' => '3.4.0', |
| 83 | 'woocommerce_settings_account_page_options_after' => '3.4.0', |
| 84 | ); |
| 85 | |
| 86 | /** |
| 87 | * Hook into the new hook so we can handle deprecated hooks once fired. |
| 88 | * |
| 89 | * @param string $hook_name Hook name. |
| 90 | */ |
| 91 | public function hook_in( $hook_name ) { |
| 92 | add_action( $hook_name, array( $this, 'maybe_handle_deprecated_hook' ), -1000, 8 ); |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * If the old hook is in-use, trigger it. |
| 97 | * |
| 98 | * @param string $new_hook New hook name. |
| 99 | * @param string $old_hook Old hook name. |
| 100 | * @param array $new_callback_args New callback args. |
| 101 | * @param mixed $return_value Returned value. |
| 102 | * @return mixed |
| 103 | */ |
| 104 | public function handle_deprecated_hook( $new_hook, $old_hook, $new_callback_args, $return_value ) { |
| 105 | if ( has_action( $old_hook ) ) { |
| 106 | $this->display_notice( $old_hook, $new_hook ); |
| 107 | $return_value = $this->trigger_hook( $old_hook, $new_callback_args ); |
| 108 | } |
| 109 | return $return_value; |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * Fire off a legacy hook with it's args. |
| 114 | * |
| 115 | * @param string $old_hook Old hook name. |
| 116 | * @param array $new_callback_args New callback args. |
| 117 | * @return mixed |
| 118 | */ |
| 119 | protected function trigger_hook( $old_hook, $new_callback_args ) { |
| 120 | switch ( $old_hook ) { |
| 121 | case 'woocommerce_order_add_shipping': |
| 122 | case 'woocommerce_order_add_fee': |
| 123 | $item_id = $new_callback_args[0]; |
| 124 | $item = $new_callback_args[1]; |
| 125 | $order_id = $new_callback_args[2]; |
| 126 | if ( is_a( $item, 'WC_Order_Item_Shipping' ) || is_a( $item, 'WC_Order_Item_Fee' ) ) { |
| 127 | do_action( $old_hook, $order_id, $item_id, $item ); |
| 128 | } |
| 129 | break; |
| 130 | case 'woocommerce_order_add_coupon': |
| 131 | $item_id = $new_callback_args[0]; |
| 132 | $item = $new_callback_args[1]; |
| 133 | $order_id = $new_callback_args[2]; |
| 134 | if ( is_a( $item, 'WC_Order_Item_Coupon' ) ) { |
| 135 | do_action( $old_hook, $order_id, $item_id, $item->get_code(), $item->get_discount(), $item->get_discount_tax() ); |
| 136 | } |
| 137 | break; |
| 138 | case 'woocommerce_order_add_tax': |
| 139 | $item_id = $new_callback_args[0]; |
| 140 | $item = $new_callback_args[1]; |
| 141 | $order_id = $new_callback_args[2]; |
| 142 | if ( is_a( $item, 'WC_Order_Item_Tax' ) ) { |
| 143 | do_action( $old_hook, $order_id, $item_id, $item->get_rate_id(), $item->get_tax_total(), $item->get_shipping_tax_total() ); |
| 144 | } |
| 145 | break; |
| 146 | case 'woocommerce_add_shipping_order_item': |
| 147 | $item_id = $new_callback_args[0]; |
| 148 | $item = $new_callback_args[1]; |
| 149 | $order_id = $new_callback_args[2]; |
| 150 | if ( is_a( $item, 'WC_Order_Item_Shipping' ) ) { |
| 151 | do_action( $old_hook, $order_id, $item_id, $item->legacy_package_key ); |
| 152 | } |
| 153 | break; |
| 154 | case 'woocommerce_add_order_item_meta': |
| 155 | $item_id = $new_callback_args[0]; |
| 156 | $item = $new_callback_args[1]; |
| 157 | $order_id = $new_callback_args[2]; |
| 158 | if ( is_a( $item, 'WC_Order_Item_Product' ) ) { |
| 159 | do_action( $old_hook, $item_id, $item->legacy_values, $item->legacy_cart_item_key ); |
| 160 | } |
| 161 | break; |
| 162 | case 'woocommerce_add_order_fee_meta': |
| 163 | $item_id = $new_callback_args[0]; |
| 164 | $item = $new_callback_args[1]; |
| 165 | $order_id = $new_callback_args[2]; |
| 166 | if ( is_a( $item, 'WC_Order_Item_Fee' ) ) { |
| 167 | do_action( $old_hook, $order_id, $item_id, $item->legacy_fee, $item->legacy_fee_key ); |
| 168 | } |
| 169 | break; |
| 170 | case 'woocommerce_order_edit_product': |
| 171 | $item_id = $new_callback_args[0]; |
| 172 | $item = $new_callback_args[1]; |
| 173 | $order_id = $new_callback_args[2]; |
| 174 | if ( is_a( $item, 'WC_Order_Item_Product' ) ) { |
| 175 | do_action( $old_hook, $order_id, $item_id, $item, $item->get_product() ); |
| 176 | } |
| 177 | break; |
| 178 | case 'woocommerce_order_update_coupon': |
| 179 | case 'woocommerce_order_update_shipping': |
| 180 | case 'woocommerce_order_update_fee': |
| 181 | case 'woocommerce_order_update_tax': |
| 182 | if ( ! is_a( $item, 'WC_Order_Item_Product' ) ) { |
| 183 | do_action( $old_hook, $order_id, $item_id, $item ); |
| 184 | } |
| 185 | break; |
| 186 | default: |
| 187 | do_action_ref_array( $old_hook, $new_callback_args ); |
| 188 | break; |
| 189 | } |
| 190 | } |
| 191 | } |
| 192 |