WC_Webhook
        
        extends WC_Legacy_Webhook
    
    
            
            in package
            
        
    
    
    
        
            Webhook class.
Table of Contents
- $cache_group : string
 - Stores meta in cache for future reads.
 - $changes : array<string|int, mixed>
 - Core data changes for this object.
 - $data : array<string|int, mixed>
 - Stores webhook data.
 - $data_store : object
 - Contains a reference to the data store for this class.
 - $default_data : array<string|int, mixed>
 - Set to _data on construct so we can track and reset data if needed.
 - $extra_data : array<string|int, mixed>
 - Extra data for this object. Name value pairs (name + default value).
 - $id : int
 - ID for this object.
 - $legacy_datastore_props : array<string|int, mixed>
 - List of properties that were earlier managed by data store. However, since DataStore is a not a stored entity in itself, they used to store data in metadata of the data object.
 - $meta_data : array<string|int, mixed>
 - Stores additional meta data.
 - $object_read : bool
 - This is false until the object is read from the DB.
 - $object_type : string
 - This is the name of this object type.
 - $processed : array<string|int, mixed>
 - Store which object IDs this webhook has processed (ie scheduled to be delivered) within the current page request.
 - __clone() : mixed
 - When the object is cloned, make sure meta is duplicated correctly.
 - __construct() : mixed
 - Load webhook data based on how WC_Webhook is called.
 - __get() : mixed
 - Magic __get method for backwards compatibility. Maps legacy vars to new getters.
 - __isset() : bool
 - Magic __isset method for backwards compatibility. Legacy properties which could be accessed directly in the past.
 - __sleep() : array<string|int, mixed>
 - Only store the object ID to avoid serializing the data object instance.
 - __toString() : string
 - Change data to JSON format.
 - __wakeup() : mixed
 - Re-run the constructor with the object ID.
 - add_meta_data() : mixed
 - Add meta data.
 - apply_changes() : mixed
 - Merge changes with data and clear.
 - build_payload() : mixed
 - Build the payload data for the webhook.
 - delete() : bool
 - Delete an object, set the ID to 0, and return result.
 - delete_meta_data() : mixed
 - Delete meta data.
 - delete_meta_data_by_mid() : mixed
 - Delete meta data.
 - delete_meta_data_value() : mixed
 - Delete meta data with a matching value.
 - deliver() : mixed
 - Deliver the webhook payload using wp_safe_remote_request().
 - deliver_ping() : bool|WP_Error
 - Send a test ping to the delivery URL, sent when the webhook is first created.
 - enqueue() : mixed
 - Enqueue the hooks associated with the webhook.
 - generate_meta_cache_key() : string
 - Generate cache key from id and group.
 - generate_signature() : string
 - Generate a base64-encoded HMAC-SHA256 signature of the payload body so the recipient can verify the authenticity of the webhook. Note that the signature is calculated after the body has already been encoded (JSON by default).
 - get_api_version() : string
 - API version.
 - get_changes() : array<string|int, mixed>
 - Return data changes only.
 - get_data() : array<string|int, mixed>
 - Returns all data for this object.
 - get_data_keys() : array<string|int, mixed>
 - Returns array of expected data keys for this object.
 - get_data_store() : object
 - Get the data store.
 - get_date_created() : WC_DateTime|null
 - Get webhook created date.
 - get_date_modified() : WC_DateTime|null
 - Get webhook modified date.
 - get_delivery_log() : void
 - Get the delivery log specified by the ID. The delivery log includes:
 - get_delivery_logs() : string
 - Get the delivery logs for this webhook.
 - get_delivery_url() : string
 - Get the delivery URL.
 - get_event() : string
 - Get the event for the webhook, e.g. `created`.
 - get_extra_data_keys() : array<string|int, mixed>
 - Returns all "extra" data keys for an object (for sub objects like product types).
 - get_failure_count() : int
 - Get the failure count.
 - get_hooks() : array<string|int, mixed>
 - Get the hook names for the webhook.
 - get_i18n_status() : string
 - Get the webhook i18n status.
 - get_id() : int
 - Returns the unique ID for this object.
 - get_meta() : mixed
 - Get Meta Data by Key.
 - get_meta_cache_key() : string
 - Helper method to compute meta cache key. Different from WP Meta cache key in that meta data cached using this key also contains meta_id column.
 - get_meta_data() : array<string|int, mixed>
 - Get All Meta Data.
 - get_name() : string
 - Get the friendly name for the webhook.
 - get_new_delivery_id() : string
 - Generate a new unique hash as a delivery id based on current time and wehbook id.
 - get_object_read() : bool
 - Get object read property.
 - get_pending_delivery() : bool
 - Get pending delivery.
 - get_post_data() : null|WP_Post
 - Get the post data for the webhook.
 - get_resource() : string
 - Get the resource for the webhook, e.g. `order`.
 - get_secret() : string
 - Get the secret used for generating the HMAC-SHA256 signature.
 - get_status() : string
 - Get the webhook status.
 - get_topic() : string
 - Get the webhook topic, e.g. `order.created`.
 - get_user_id() : int
 - Get the user ID for this webhook.
 - init_meta_data() : mixed
 - Helper function to initialize metadata entries from filtered raw meta data.
 - log_delivery() : mixed
 - Log the delivery request/response.
 - meta_exists() : bool
 - See if meta data exists, since get_meta always returns a '' or array().
 - prime_raw_meta_data_cache() : mixed
 - Prime caches for raw meta data. This includes meta_id column as well, which is not included by default in WP meta data.
 - process() : mixed
 - Process the webhook for delivery by verifying that it should be delivered.
 - read_meta_data() : mixed
 - Read Meta Data from the database. Ignore any internal properties.
 - save() : int
 - Save should create or update based on object existence.
 - save_meta_data() : mixed
 - Update Meta Data in the database.
 - set_api_version() : mixed
 - Set API version.
 - set_date_created() : mixed
 - Set webhook created date.
 - set_date_modified() : mixed
 - Set webhook modified date.
 - set_defaults() : mixed
 - Set all props to default values.
 - set_delivery_url() : mixed
 - Set the delivery URL.
 - set_failure_count() : mixed
 - Set failure count.
 - set_id() : mixed
 - Set ID.
 - set_meta_data() : mixed
 - Set all meta data from array.
 - set_name() : mixed
 - Set webhook name.
 - set_object_read() : mixed
 - Set object read property.
 - set_pending_delivery() : mixed
 - Set pending delivery.
 - set_props() : bool|WP_Error
 - Set a collection of props in one go, collect any errors, and return the result.
 - set_secret() : mixed
 - Set the secret used for generating the HMAC-SHA256 signature.
 - set_status() : mixed
 - Set status.
 - set_topic() : mixed
 - Set the webhook topic and associated hooks.
 - set_user_id() : mixed
 - Set user ID.
 - update_meta_data() : mixed
 - Update meta data by key or ID, if provided.
 - update_status() : mixed
 - Update the webhook status.
 - error() : mixed
 - When invalid data is found, throw an exception unless reading from the DB.
 - filter_null_meta() : bool
 - Filter null meta values from array.
 - get_hook_prefix() : string
 - Prefix for action and filter hooks on data.
 - get_prop() : mixed
 - Gets a prop for a getter method.
 - is_already_processed() : bool
 - Checks if the specified resource has already been queued for delivery within the current request.
 - is_internal_meta_key() : bool
 - Check if the key is an internal one.
 - maybe_read_meta_data() : mixed
 - Read meta data if null.
 - set_date_prop() : mixed
 - Sets a date prop whilst handling formatting and datetime objects.
 - set_prop() : mixed
 - Sets a prop for a setter method.
 - failed_delivery() : mixed
 - Track consecutive delivery failures and automatically disable the webhook.
 - get_topic_hooks() : array<string|int, mixed>
 - Get the associated hook names for a topic.
 - get_wp_api_payload() : array<string|int, mixed>
 - Get WP API integration payload.
 - is_active() : bool
 - Returns if webhook is active.
 - is_valid_action() : bool
 - Validates the criteria for certain actions.
 - is_valid_post_action() : bool
 - Validates post actions.
 - is_valid_processing_action() : bool
 - Validates WC processing actions.
 - is_valid_resource() : bool
 - Checks the resource for this webhook is valid e.g. valid post status.
 - is_valid_topic() : bool
 - Returns if topic is valid.
 - is_valid_user_action() : bool
 - Validates user actions.
 - should_deliver() : bool
 - Helper to check if the webhook should be delivered, as some hooks.
 
Properties
$cache_group
Stores meta in cache for future reads.
    protected
        string
    $cache_group
     = ''
        A group must be set to to enable caching.
Tags
$changes
Core data changes for this object.
    protected
        array<string|int, mixed>
    $changes
     = array()
        
    
    Tags
$data
Stores webhook data.
    protected
        array<string|int, mixed>
    $data
     = array('date_created' => 
ull, 'date_modified' => 
ull, 'status' => 'disabled', 'delivery_url' => '', 'secret' => '', 'name' => '', 'topic' => '', 'hooks' => '', 'resource' => '', 'event' => '', 'failure_count' => 0, 'user_id' => 0, 'api_version' => 3, 'pending_delivery' => alse)
        
    
$data_store
Contains a reference to the data store for this class.
    protected
        object
    $data_store
    
        
    
    Tags
$default_data
Set to _data on construct so we can track and reset data if needed.
    protected
        array<string|int, mixed>
    $default_data
     = array()
        
    
    Tags
$extra_data
Extra data for this object. Name value pairs (name + default value).
    protected
        array<string|int, mixed>
    $extra_data
     = array()
        Used as a standard way for sub classes (like product types) to add additional information to an inherited class.
Tags
$id
ID for this object.
    protected
        int
    $id
     = 0
        
    
    Tags
$legacy_datastore_props
List of properties that were earlier managed by data store. However, since DataStore is a not a stored entity in itself, they used to store data in metadata of the data object.
    protected
        array<string|int, mixed>
    $legacy_datastore_props
     = array()
        With custom tables, some of these are moved from metadata to their own columns, but existing code will still try to add them to metadata. This array is used to keep track of such properties.
Only reason to add a property here is that you are moving properties from DataStore instance to data object. If you are adding a new property, consider adding it to to $data array instead.
$meta_data
Stores additional meta data.
    protected
        array<string|int, mixed>
    $meta_data
     = 
ull
        
    
    Tags
$object_read
This is false until the object is read from the DB.
    protected
        bool
    $object_read
     = alse
        
    
    Tags
$object_type
This is the name of this object type.
    protected
        string
    $object_type
     = 'data'
        
    
    Tags
$processed
Store which object IDs this webhook has processed (ie scheduled to be delivered) within the current page request.
    protected
        array<string|int, mixed>
    $processed
     = array()
        
    
Methods
__clone()
When the object is cloned, make sure meta is duplicated correctly.
    public
                __clone() : mixed
        
    
    
    Tags
Return values
mixed —__construct()
Load webhook data based on how WC_Webhook is called.
    public
                __construct(WC_Webhook|int $data) : mixed
        
        Parameters
- $data : WC_Webhook|int
 - 
                    
Webhook ID or data.
 
Tags
Return values
mixed —__get()
Magic __get method for backwards compatibility. Maps legacy vars to new getters.
    public
                __get(string $key) : mixed
        
        Parameters
- $key : string
 - 
                    
Item to get.
 
Return values
mixed —__isset()
Magic __isset method for backwards compatibility. Legacy properties which could be accessed directly in the past.
    public
                __isset(string $key) : bool
        
        Parameters
- $key : string
 - 
                    
Item to check.
 
Return values
bool —__sleep()
Only store the object ID to avoid serializing the data object instance.
    public
                __sleep() : array<string|int, mixed>
        
    
    
        Return values
array<string|int, mixed> —__toString()
Change data to JSON format.
    public
                __toString() : string
        
    
    
    Tags
Return values
string — Data in JSON format.__wakeup()
Re-run the constructor with the object ID.
    public
                __wakeup() : mixed
        If the object no longer exists, remove the ID.
Return values
mixed —add_meta_data()
Add meta data.
    public
                add_meta_data(string $key, string|array<string|int, mixed> $value[, bool $unique = false ]) : mixed
        
        Parameters
- $key : string
 - 
                    
Meta key.
 - $value : string|array<string|int, mixed>
 - 
                    
Meta value.
 - $unique : bool = false
 - 
                    
Should this be a unique key?.
 
Tags
Return values
mixed —apply_changes()
Merge changes with data and clear.
    public
                apply_changes() : mixed
        
    
    
    Tags
Return values
mixed —build_payload()
Build the payload data for the webhook.
    public
                build_payload(mixed $resource_id) : mixed
        
        Parameters
- $resource_id : mixed
 - 
                    
First hook argument, typically the resource ID.
 
Tags
Return values
mixed — Payload data.delete()
Delete an object, set the ID to 0, and return result.
    public
                delete([bool $force_delete = false ]) : bool
        
        Parameters
- $force_delete : bool = false
 - 
                    
Should the date be deleted permanently.
 
Tags
Return values
bool — resultdelete_meta_data()
Delete meta data.
    public
                delete_meta_data(string $key) : mixed
        
        Parameters
- $key : string
 - 
                    
Meta key.
 
Tags
Return values
mixed —delete_meta_data_by_mid()
Delete meta data.
    public
                delete_meta_data_by_mid(int $mid) : mixed
        
        Parameters
- $mid : int
 - 
                    
Meta ID.
 
Tags
Return values
mixed —delete_meta_data_value()
Delete meta data with a matching value.
    public
                delete_meta_data_value(string $key, mixed $value) : mixed
        
        Parameters
- $key : string
 - 
                    
Meta key.
 - $value : mixed
 - 
                    
Meta value. Entries will only be removed that match the value.
 
Tags
Return values
mixed —deliver()
Deliver the webhook payload using wp_safe_remote_request().
    public
                deliver(mixed $arg) : mixed
        
        Parameters
- $arg : mixed
 - 
                    
First hook argument.
 
Tags
Return values
mixed —deliver_ping()
Send a test ping to the delivery URL, sent when the webhook is first created.
    public
                deliver_ping() : bool|WP_Error
        
    
    
    Tags
Return values
bool|WP_Error —enqueue()
Enqueue the hooks associated with the webhook.
    public
                enqueue() : mixed
        
    
    
    Tags
Return values
mixed —generate_meta_cache_key()
Generate cache key from id and group.
    public
            static    generate_meta_cache_key(int|string $id, string $cache_group) : string
        
        Parameters
- $id : int|string
 - 
                    
Object ID.
 - $cache_group : string
 - 
                    
Group name use to store cache. Whole group cache can be invalidated in one go.
 
Tags
Return values
string — Meta cache key.generate_signature()
Generate a base64-encoded HMAC-SHA256 signature of the payload body so the recipient can verify the authenticity of the webhook. Note that the signature is calculated after the body has already been encoded (JSON by default).
    public
                generate_signature(string $payload) : string
        
        Parameters
- $payload : string
 - 
                    
Payload data to hash.
 
Tags
Return values
string —get_api_version()
API version.
    public
                get_api_version([string $context = 'view' ]) : string
        
        Parameters
- $context : string = 'view'
 - 
                    
What the value is for. Valid values are 'view' and 'edit'.
 
Tags
Return values
string —get_changes()
Return data changes only.
    public
                get_changes() : array<string|int, mixed>
        
    
    
    Tags
Return values
array<string|int, mixed> —get_data()
Returns all data for this object.
    public
                get_data() : array<string|int, mixed>
        
    
    
    Tags
Return values
array<string|int, mixed> —get_data_keys()
Returns array of expected data keys for this object.
    public
                get_data_keys() : array<string|int, mixed>
        
    
    
    Tags
Return values
array<string|int, mixed> —get_data_store()
Get the data store.
    public
                get_data_store() : object
        
    
    
    Tags
Return values
object —get_date_created()
Get webhook created date.
    public
                get_date_created([string $context = 'view' ]) : WC_DateTime|null
        
        Parameters
- $context : string = 'view'
 - 
                    
What the value is for. Valid values are 'view' and 'edit'.
 
Tags
Return values
WC_DateTime|null — Object if the date is set or null if there is no date.get_date_modified()
Get webhook modified date.
    public
                get_date_modified([string $context = 'view' ]) : WC_DateTime|null
        
        Parameters
- $context : string = 'view'
 - 
                    
What the value is for. Valid values are 'view' and 'edit'.
 
Tags
Return values
WC_DateTime|null — Object if the date is set or null if there is no date.get_delivery_log()
Get the delivery log specified by the ID. The delivery log includes:
    public
                get_delivery_log(int $delivery_id) : void
        - duration
 - summary
 - request method/url
 - request headers/body
 - response code/message/headers/body
 
Parameters
- $delivery_id : int
 - 
                    
Delivery ID.
 
Tags
Return values
void —get_delivery_logs()
Get the delivery logs for this webhook.
    public
                get_delivery_logs() : string
        
    
    
    Tags
Return values
string —get_delivery_url()
Get the delivery URL.
    public
                get_delivery_url([string $context = 'view' ]) : string
        
        Parameters
- $context : string = 'view'
 - 
                    
What the value is for. Valid values are 'view' and 'edit'.
 
Tags
Return values
string —get_event()
Get the event for the webhook, e.g. `created`.
    public
                get_event() : string
        
    
    
    Tags
Return values
string —get_extra_data_keys()
Returns all "extra" data keys for an object (for sub objects like product types).
    public
                get_extra_data_keys() : array<string|int, mixed>
        
    
    
    Tags
Return values
array<string|int, mixed> —get_failure_count()
Get the failure count.
    public
                get_failure_count([string $context = 'view' ]) : int
        
        Parameters
- $context : string = 'view'
 - 
                    
What the value is for. Valid values are 'view' and 'edit'.
 
Tags
Return values
int —get_hooks()
Get the hook names for the webhook.
    public
                get_hooks() : array<string|int, mixed>
        
    
    
    Tags
Return values
array<string|int, mixed> —get_i18n_status()
Get the webhook i18n status.
    public
                get_i18n_status() : string
        
    
    
        Return values
string —get_id()
Returns the unique ID for this object.
    public
                get_id() : int
        
    
    
    Tags
Return values
int —get_meta()
Get Meta Data by Key.
    public
                get_meta([string $key = '' ][, bool $single = true ][, string $context = 'view' ]) : mixed
        
        Parameters
- $key : string = ''
 - 
                    
Meta Key.
 - $single : bool = true
 - 
                    
return first found meta with key, or all with $key.
 - $context : string = 'view'
 - 
                    
What the value is for. Valid values are view and edit.
 
Tags
Return values
mixed —get_meta_cache_key()
Helper method to compute meta cache key. Different from WP Meta cache key in that meta data cached using this key also contains meta_id column.
    public
                get_meta_cache_key() : string
        
    
    
    Tags
Return values
string —get_meta_data()
Get All Meta Data.
    public
                get_meta_data() : array<string|int, mixed>
        
    
    
    Tags
Return values
array<string|int, mixed> — of objects.get_name()
Get the friendly name for the webhook.
    public
                get_name([string $context = 'view' ]) : string
        
        Parameters
- $context : string = 'view'
 - 
                    
What the value is for. Valid values are 'view' and 'edit'.
 
Tags
Return values
string —get_new_delivery_id()
Generate a new unique hash as a delivery id based on current time and wehbook id.
    public
                get_new_delivery_id() : string
        Return the hash for inclusion in the webhook request.
Tags
Return values
string —get_object_read()
Get object read property.
    public
                get_object_read() : bool
        
    
    
    Tags
Return values
bool —get_pending_delivery()
Get pending delivery.
    public
                get_pending_delivery([string $context = 'view' ]) : bool
        
        Parameters
- $context : string = 'view'
 - 
                    
What the value is for. Valid values are 'view' and 'edit'.
 
Tags
Return values
bool —get_post_data()
Get the post data for the webhook.
    public
                get_post_data() : null|WP_Post
        
    
    
    Tags
Return values
null|WP_Post —get_resource()
Get the resource for the webhook, e.g. `order`.
    public
                get_resource() : string
        
    
    
    Tags
Return values
string —get_secret()
Get the secret used for generating the HMAC-SHA256 signature.
    public
                get_secret([string $context = 'view' ]) : string
        
        Parameters
- $context : string = 'view'
 - 
                    
What the value is for. Valid values are 'view' and 'edit'.
 
Tags
Return values
string —get_status()
Get the webhook status.
    public
                get_status([string $context = 'view' ]) : string
        - 'active' - delivers payload.
 - 'paused' - does not deliver payload, paused by admin.
 - 'disabled' - does not delivery payload, paused automatically due to consecutive failures.
 
Parameters
- $context : string = 'view'
 - 
                    
What the value is for. Valid values are 'view' and 'edit'.
 
Tags
Return values
string — statusget_topic()
Get the webhook topic, e.g. `order.created`.
    public
                get_topic([string $context = 'view' ]) : string
        
        Parameters
- $context : string = 'view'
 - 
                    
What the value is for. Valid values are 'view' and 'edit'.
 
Tags
Return values
string —get_user_id()
Get the user ID for this webhook.
    public
                get_user_id([string $context = 'view' ]) : int
        
        Parameters
- $context : string = 'view'
 - 
                    
What the value is for. Valid values are 'view' and 'edit'.
 
Tags
Return values
int —init_meta_data()
Helper function to initialize metadata entries from filtered raw meta data.
    public
                init_meta_data([array<string|int, mixed> $filtered_meta_data = array() ]) : mixed
        
        Parameters
- $filtered_meta_data : array<string|int, mixed> = array()
 - 
                    
Filtered metadata fetched from DB.
 
Return values
mixed —log_delivery()
Log the delivery request/response.
    public
                log_delivery(string $delivery_id, array<string|int, mixed> $request, array<string|int, mixed>|WP_Error $response, float $duration) : mixed
        
        Parameters
- $delivery_id : string
 - 
                    
Previously created hash.
 - $request : array<string|int, mixed>
 - 
                    
Request data.
 - $response : array<string|int, mixed>|WP_Error
 - 
                    
Response data.
 - $duration : float
 - 
                    
Request duration.
 
Tags
Return values
mixed —meta_exists()
See if meta data exists, since get_meta always returns a '' or array().
    public
                meta_exists([string $key = '' ]) : bool
        
        Parameters
- $key : string = ''
 - 
                    
Meta Key.
 
Tags
Return values
bool —prime_raw_meta_data_cache()
Prime caches for raw meta data. This includes meta_id column as well, which is not included by default in WP meta data.
    public
            static    prime_raw_meta_data_cache(array<string|int, mixed> $raw_meta_data_collection, string $cache_group) : mixed
        
        Parameters
- $raw_meta_data_collection : array<string|int, mixed>
 - 
                    
Array of objects of { object_id => array( meta_row_1, meta_row_2, ... }.
 - $cache_group : string
 - 
                    
Name of cache group.
 
Tags
Return values
mixed —process()
Process the webhook for delivery by verifying that it should be delivered.
    public
                process(mixed $arg) : mixed
        and scheduling the delivery (in the background by default, or immediately).
Parameters
- $arg : mixed
 - 
                    
The first argument provided from the associated hooks.
 
Tags
Return values
mixed — $arg Returns the argument in case the webhook was hooked into a filter.read_meta_data()
Read Meta Data from the database. Ignore any internal properties.
    public
                read_meta_data([bool $force_read = false ]) : mixed
        Uses it's own caches because get_metadata does not provide meta_ids.
Parameters
- $force_read : bool = false
 - 
                    
True to force a new DB read (and update cache).
 
Tags
Return values
mixed —save()
Save should create or update based on object existence.
    public
                save() : int
        
    
    
    Tags
Return values
int —save_meta_data()
Update Meta Data in the database.
    public
                save_meta_data() : mixed
        
    
    
    Tags
Return values
mixed —set_api_version()
Set API version.
    public
                set_api_version(int|string $version) : mixed
        
        Parameters
- $version : int|string
 - 
                    
REST API version.
 
Tags
Return values
mixed —set_date_created()
Set webhook created date.
    public
                set_date_created([string|int|null $date = null ]) : mixed
        
        Parameters
- $date : string|int|null = null
 - 
                    
UTC timestamp, or ISO 8601 DateTime. If the DateTime string has no timezone or offset, WordPress site timezone will be assumed. Null if their is no date.
 
Tags
Return values
mixed —set_date_modified()
Set webhook modified date.
    public
                set_date_modified([string|int|null $date = null ]) : mixed
        
        Parameters
- $date : string|int|null = null
 - 
                    
UTC timestamp, or ISO 8601 DateTime. If the DateTime string has no timezone or offset, WordPress site timezone will be assumed. Null if their is no date.
 
Tags
Return values
mixed —set_defaults()
Set all props to default values.
    public
                set_defaults() : mixed
        
    
    
    Tags
Return values
mixed —set_delivery_url()
Set the delivery URL.
    public
                set_delivery_url(string $url) : mixed
        
        Parameters
- $url : string
 - 
                    
Delivery URL.
 
Tags
Return values
mixed —set_failure_count()
Set failure count.
    public
                set_failure_count(bool $failure_count) : mixed
        
        Parameters
- $failure_count : bool
 - 
                    
Total of failures.
 
Tags
Return values
mixed —set_id()
Set ID.
    public
                set_id(int $id) : mixed
        
        Parameters
- $id : int
 - 
                    
ID.
 
Tags
Return values
mixed —set_meta_data()
Set all meta data from array.
    public
                set_meta_data(array<string|int, mixed> $data) : mixed
        
        Parameters
- $data : array<string|int, mixed>
 - 
                    
Key/Value pairs.
 
Tags
Return values
mixed —set_name()
Set webhook name.
    public
                set_name(string $name) : mixed
        
        Parameters
- $name : string
 - 
                    
Webhook name.
 
Tags
Return values
mixed —set_object_read()
Set object read property.
    public
                set_object_read([bool $read = true ]) : mixed
        
        Parameters
- $read : bool = true
 - 
                    
Should read?.
 
Tags
Return values
mixed —set_pending_delivery()
Set pending delivery.
    public
                set_pending_delivery(bool $pending_delivery) : mixed
        
        Parameters
- $pending_delivery : bool
 - 
                    
Set true if is pending for delivery.
 
Tags
Return values
mixed —set_props()
Set a collection of props in one go, collect any errors, and return the result.
    public
                set_props(array<string|int, mixed> $props[, string $context = 'set' ]) : bool|WP_Error
        Only sets using public methods.
Parameters
- $props : array<string|int, mixed>
 - 
                    
Key value pairs to set. Key is the prop and should map to a setter function name.
 - $context : string = 'set'
 - 
                    
In what context to run this.
 
Tags
Return values
bool|WP_Error —set_secret()
Set the secret used for generating the HMAC-SHA256 signature.
    public
                set_secret(string $secret) : mixed
        
        Parameters
- $secret : string
 - 
                    
Secret.
 
Tags
Return values
mixed —set_status()
Set status.
    public
                set_status(string $status) : mixed
        
        Parameters
- $status : string
 - 
                    
Status.
 
Tags
Return values
mixed —set_topic()
Set the webhook topic and associated hooks.
    public
                set_topic(string $topic) : mixed
        The topic resource & event are also saved separately.
Parameters
- $topic : string
 - 
                    
Webhook topic.
 
Tags
Return values
mixed —set_user_id()
Set user ID.
    public
                set_user_id(int $user_id) : mixed
        
        Parameters
- $user_id : int
 - 
                    
User ID.
 
Tags
Return values
mixed —update_meta_data()
Update meta data by key or ID, if provided.
    public
                update_meta_data(string $key, string|array<string|int, mixed> $value, int $meta_id) : mixed
        
        Parameters
- $key : string
 - 
                    
Meta key.
 - $value : string|array<string|int, mixed>
 - 
                    
Meta value.
 - $meta_id : int
 - 
                    
Meta ID.
 
Tags
Return values
mixed —update_status()
Update the webhook status.
    public
                update_status(string $status) : mixed
        
        Parameters
- $status : string
 - 
                    
Status to set.
 
Tags
Return values
mixed —error()
When invalid data is found, throw an exception unless reading from the DB.
    protected
                error(string $code, string $message[, int $http_status_code = 400 ][, array<string|int, mixed> $data = array() ]) : mixed
        
        Parameters
- $code : string
 - 
                    
Error code.
 - $message : string
 - 
                    
Error message.
 - $http_status_code : int = 400
 - 
                    
HTTP status code.
 - $data : array<string|int, mixed> = array()
 - 
                    
Extra error data.
 
Tags
Return values
mixed —filter_null_meta()
Filter null meta values from array.
    protected
                filter_null_meta(mixed $meta) : bool
        
        Parameters
- $meta : mixed
 - 
                    
Meta value to check.
 
Tags
Return values
bool —get_hook_prefix()
Prefix for action and filter hooks on data.
    protected
                get_hook_prefix() : string
        
    
    
    Tags
Return values
string —get_prop()
Gets a prop for a getter method.
    protected
                get_prop(string $prop[, string $context = 'view' ]) : mixed
        Gets the value from either current pending changes, or the data itself. Context controls what happens to the value before it's returned.
Parameters
- $prop : string
 - 
                    
Name of prop to get.
 - $context : string = 'view'
 - 
                    
What the value is for. Valid values are view and edit.
 
Tags
Return values
mixed —is_already_processed()
Checks if the specified resource has already been queued for delivery within the current request.
    protected
                is_already_processed(mixed $arg) : bool
        Helps avoid duplication of data being sent for topics that have more than one hook defined.
Parameters
- $arg : mixed
 - 
                    
First hook argument.
 
Return values
bool —is_internal_meta_key()
Check if the key is an internal one.
    protected
                is_internal_meta_key(string $key) : bool
        
        Parameters
- $key : string
 - 
                    
Key to check.
 
Tags
Return values
bool — true if it's an internal key, false otherwisemaybe_read_meta_data()
Read meta data if null.
    protected
                maybe_read_meta_data() : mixed
        
    
    
    Tags
Return values
mixed —set_date_prop()
Sets a date prop whilst handling formatting and datetime objects.
    protected
                set_date_prop(string $prop, string|int $value) : mixed
        
        Parameters
- $prop : string
 - 
                    
Name of prop to set.
 - $value : string|int
 - 
                    
Value of the prop.
 
Tags
Return values
mixed —set_prop()
Sets a prop for a setter method.
    protected
                set_prop(string $prop, mixed $value) : mixed
        This stores changes in a special array so we can track what needs saving the DB later.
Parameters
- $prop : string
 - 
                    
Name of prop to set.
 - $value : mixed
 - 
                    
Value of the prop.
 
Tags
Return values
mixed —failed_delivery()
Track consecutive delivery failures and automatically disable the webhook.
    private
                failed_delivery() : mixed
        if more than 5 consecutive failures occur. A failure is defined as a. non-2xx response.
Tags
Return values
mixed —get_topic_hooks()
Get the associated hook names for a topic.
    private
                get_topic_hooks(string $topic) : array<string|int, mixed>
        
        Parameters
- $topic : string
 - 
                    
Topic name.
 
Tags
Return values
array<string|int, mixed> —get_wp_api_payload()
Get WP API integration payload.
    private
                get_wp_api_payload(string $resource, int $resource_id, string $event) : array<string|int, mixed>
        
        Parameters
- $resource : string
 - 
                    
Resource type.
 - $resource_id : int
 - 
                    
Resource ID.
 - $event : string
 - 
                    
Event type.
 
Tags
Return values
array<string|int, mixed> —is_active()
Returns if webhook is active.
    private
                is_active() : bool
        
    
    
    Tags
Return values
bool — True if validation passes.is_valid_action()
Validates the criteria for certain actions.
    private
                is_valid_action(mixed $arg) : bool
        
        Parameters
- $arg : mixed
 - 
                    
First hook argument.
 
Tags
Return values
bool — True if validation passes.is_valid_post_action()
Validates post actions.
    private
                is_valid_post_action(mixed $arg) : bool
        
        Parameters
- $arg : mixed
 - 
                    
First hook argument.
 
Tags
Return values
bool — True if validation passes.is_valid_processing_action()
Validates WC processing actions.
    private
                is_valid_processing_action(mixed $arg) : bool
        
        Parameters
- $arg : mixed
 - 
                    
First hook argument.
 
Tags
Return values
bool — True if validation passes.is_valid_resource()
Checks the resource for this webhook is valid e.g. valid post status.
    private
                is_valid_resource(mixed $arg) : bool
        
        Parameters
- $arg : mixed
 - 
                    
First hook argument.
 
Tags
Return values
bool — True if validation passes.is_valid_topic()
Returns if topic is valid.
    private
                is_valid_topic() : bool
        
    
    
    Tags
Return values
bool — True if validation passes.is_valid_user_action()
Validates user actions.
    private
                is_valid_user_action(mixed $arg) : bool
        
        Parameters
- $arg : mixed
 - 
                    
First hook argument.
 
Tags
Return values
bool — True if validation passes.should_deliver()
Helper to check if the webhook should be delivered, as some hooks.
    private
                should_deliver(mixed $arg) : bool
        (like wp_trash_post) will fire for every post type, not just ours.
Parameters
- $arg : mixed
 - 
                    
First hook argument.
 
