WooCommerce Code Reference

WC_Deprecated_Hooks
in package

WC_Deprecated_Hooks class maps old actions and filters to new ones. This is the base class for handling those deprecated hooks.

Based on the WCS_Hook_Deprecator class by Prospress.

Table of Contents

$deprecated_hooks  : array<string|int, mixed>
Array of deprecated hooks we need to handle.
$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

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 abstract 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 abstract 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 abstract 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