WC_Webhook::is_valid_post_action
Validates post actions.
Method of the class: WC_Webhook{}
No Hooks.
Returns
bool. True if validation passes.
Usage
// private - for code of main (parent) class only $result = $this->is_valid_post_action( $arg );
- $arg(mixed) (required)
- First hook argument.
Changelog
| Since 3.6.0 | Introduced. |
WC_Webhook::is_valid_post_action() WC Webhook::is valid post action code WC 11.3.0
private function is_valid_post_action( $arg ) {
if ( ( ! is_int( $arg ) && ! ( is_string( $arg ) && ctype_digit( $arg ) ) ) || 0 >= (int) $arg ) {
return false;
}
$post_id = absint( $arg );
$post_type_to_resource = array_merge(
array(
'product' => 'product',
'product_variation' => 'product',
'shop_coupon' => 'coupon',
),
array_fill_keys( wc_get_order_types( 'order-webhooks' ), 'order' )
);
$post_type = get_post_type( $post_id );
return isset( $post_type_to_resource[ $post_type ] ) && $post_type_to_resource[ $post_type ] === $this->get_resource();
}