WC_Webhook::is_valid_post_action
Validates post actions.
Method of the class: WC_Webhook{}
No Hooks.
Returns
true|false. 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 10.6.2
private function is_valid_post_action( $arg ) {
// Only deliver deleted/restored event for coupons, orders, and products.
if ( isset( $GLOBALS['post_type'] ) && ! in_array( $GLOBALS['post_type'], array( 'shop_coupon', 'shop_order', 'product' ), true ) ) {
return false;
}
// Check if is delivering for the correct resource.
if ( isset( $GLOBALS['post_type'] ) && str_replace( 'shop_', '', $GLOBALS['post_type'] ) !== $this->get_resource() ) {
return false;
}
return true;
}