WooCommerce Code Reference

WC_Deprecated_Action_Hooks extends WC_Deprecated_Hooks
in package

Handles deprecation notices and triggering of legacy action hooks.

Table of Contents

$deprecated_hooks  : array<string|int, mixed>
Array of deprecated hooks we need to handle. Format of 'new' => 'old'.
$deprecated_version  : array<string|int, mixed>
Array of versions on each hook has been deprecated.
__construct()  : mixed
Constructor.
get_old_hooks()  : array<string|int, mixed>
Get old hooks to map to new hook.
handle_deprecated_hook()  : mixed
If the old hook is in-use, trigger it.
hook_in()  : mixed
Hook into the new hook so we can handle deprecated hooks once fired.
maybe_handle_deprecated_hook()  : mixed
If the hook is Deprecated, call the old hooks here.
display_notice()  : mixed
Display a deprecated notice for old hooks.
get_deprecated_version()  : string
Get deprecated version.
trigger_hook()  : mixed
Fire off a legacy hook with it's args.

Properties

$deprecated_hooks

Array of deprecated hooks we need to handle. Format of 'new' => 'old'.

protected array<string|int, mixed> $deprecated_hooks = array('woocommerce_new_order_item' => array('woocommerce_order_add_shipping', 'woocommerce_order_add_coupon', 'woocommerce_order_add_tax', 'woocommerce_order_add_fee', 'woocommerce_add_shipping_order_item', 'woocommerce_add_order_item_meta', 'woocommerce_add_order_fee_meta'), 'woocommerce_update_order_item' => array('woocommerce_order_edit_product', 'woocommerce_order_update_coupon', 'woocommerce_order_update_shipping', 'woocommerce_order_update_fee', 'woocommerce_order_update_tax'), 'woocommerce_new_payment_token' => 'woocommerce_payment_token_created', 'woocommerce_new_product_variation' => 'woocommerce_create_product_variation', 'woocommerce_order_details_after_order_table_items' => 'woocommerce_order_items_table', 'woocommerce_settings_advanced_page_options' => array('woocommerce_settings_checkout_page_options', 'woocommerce_settings_account_page_options'), 'woocommerce_settings_advanced_page_options_end' => array('woocommerce_settings_checkout_page_options_end', 'woocommerce_settings_account_page_options_end'), 'woocommerce_settings_advanced_page_options_after' => array('woocommerce_settings_checkout_page_options_after', 'woocommerce_settings_account_page_options_after'))

$deprecated_version

Array of versions on each hook has been deprecated.

protected array<string|int, mixed> $deprecated_version = array('woocommerce_order_add_shipping' => '3.0.0', 'woocommerce_order_add_coupon' => '3.0.0', 'woocommerce_order_add_tax' => '3.0.0', 'woocommerce_order_add_fee' => '3.0.0', 'woocommerce_add_shipping_order_item' => '3.0.0', 'woocommerce_add_order_item_meta' => '3.0.0', 'woocommerce_add_order_fee_meta' => '3.0.0', 'woocommerce_order_edit_product' => '3.0.0', 'woocommerce_order_update_coupon' => '3.0.0', 'woocommerce_order_update_shipping' => '3.0.0', 'woocommerce_order_update_fee' => '3.0.0', 'woocommerce_order_update_tax' => '3.0.0', 'woocommerce_payment_token_created' => '3.0.0', 'woocommerce_create_product_variation' => '3.0.0', 'woocommerce_order_items_table' => '3.0.0', 'woocommerce_settings_checkout_page_options' => '3.4.0', 'woocommerce_settings_account_page_options' => '3.4.0', 'woocommerce_settings_checkout_page_options_end' => '3.4.0', 'woocommerce_settings_account_page_options_end' => '3.4.0', 'woocommerce_settings_checkout_page_options_after' => '3.4.0', 'woocommerce_settings_account_page_options_after' => '3.4.0')

Methods

get_old_hooks()

Get old hooks to map to new hook.

public get_old_hooks(string $new_hook) : array<string|int, mixed>
Parameters
$new_hook : string

New hook name.

Return values
array<string|int, mixed>

handle_deprecated_hook()

If the old hook is in-use, trigger it.

public handle_deprecated_hook(string $new_hook, string $old_hook, array<string|int, mixed> $new_callback_args, mixed $return_value) : mixed
Parameters
$new_hook : string

New hook name.

$old_hook : string

Old hook name.

$new_callback_args : array<string|int, mixed>

New callback args.

$return_value : mixed

Returned value.

Return values
mixed

hook_in()

Hook into the new hook so we can handle deprecated hooks once fired.

public hook_in(string $hook_name) : mixed
Parameters
$hook_name : string

Hook name.

Return values
mixed

display_notice()

Display a deprecated notice for old hooks.

protected display_notice(string $old_hook, string $new_hook) : mixed
Parameters
$old_hook : string

Old hook.

$new_hook : string

New hook.

Return values
mixed

trigger_hook()

Fire off a legacy hook with it's args.

protected trigger_hook(string $old_hook, array<string|int, mixed> $new_callback_args) : mixed
Parameters
$old_hook : string

Old hook name.

$new_callback_args : array<string|int, mixed>

New callback args.

Return values
mixed