WooCommerce Code Reference

Search results

WC_Deprecated_Action_Hooks extends WC_Deprecated_Hooks

Handles deprecation notices and triggering of legacy action hooks.

Based on the WCS_Hook_Deprecator class by Prospress.

Table of Contents

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

Properties

$deprecated_hooks

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

protected array $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 $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

hook_in()

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

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

Hook name.

Return values
mixed

handle_deprecated_hook()

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

public handle_deprecated_hook( $new_hook : string , $old_hook : string , $new_callback_args : array , $return_value : mixed ) : mixed
Parameters
$new_hook : string

New hook name.

$old_hook : string

Old hook name.

$new_callback_args : array

New callback args.

$return_value : mixed

Returned value.

Return values
mixed

trigger_hook()

Fire off a legacy hook with it's args.

protected trigger_hook( $old_hook : string , $new_callback_args : array ) : mixed
Parameters
$old_hook : string

Old hook name.

$new_callback_args : array

New callback args.

Return values
mixed

hook_in()

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

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

Hook name.

Return values
mixed

get_old_hooks()

Get old hooks to map to new hook.

public get_old_hooks( $new_hook : string ) : array
Parameters
$new_hook : string

New hook name.

Return values
array

maybe_handle_deprecated_hook()

If the hook is Deprecated, call the old hooks here.

public maybe_handle_deprecated_hook( ) : mixed
Return values
mixed

handle_deprecated_hook()

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

public abstract handle_deprecated_hook( $new_hook : string , $old_hook : string , $new_callback_args : array , $return_value : mixed ) : mixed
Parameters
$new_hook : string

New hook name.

$old_hook : string

Old hook name.

$new_callback_args : array

New callback args.

$return_value : mixed

Returned value.

Return values
mixed

get_deprecated_version()

Get deprecated version.

protected get_deprecated_version( $old_hook : string ) : string
Parameters
$old_hook : string

Old hook name.

Return values
string

display_notice()

Display a deprecated notice for old hooks.

protected display_notice( $old_hook : string , $new_hook : string ) : 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 abstract trigger_hook( $old_hook : string , $new_callback_args : array ) : mixed
Parameters
$old_hook : string

Old hook name.

$new_callback_args : array

New callback args.

Return values
mixed
Back to the top