WC_Webhook::is_valid_processing_action
Validates WC processing actions.
Метод класса: WC_Webhook{}
Хуков нет.
Возвращает
bool. True if validation passes.
Использование
// private - только в коде основоного (родительского) класса $result = $this->is_valid_processing_action( $arg );
- $arg(разное) (обязательный)
- First hook argument.
Список изменений
| С версии 3.6.0 | Введена. |
Код WC_Webhook::is_valid_processing_action() WC Webhook::is valid processing action WC 11.1.2
private function is_valid_processing_action( $arg ) {
// The `woocommerce_process_shop_*` and `woocommerce_process_product_*` hooks
// fire for create and update of products and orders, so check the post
// creation date to determine the actual event.
$resource = get_post( absint( $arg ) );
// Drafts don't have post_date_gmt so calculate it here.
$gmt_date = get_gmt_from_date( $resource->post_date );
// A resource is considered created when the hook is executed within 10 seconds of the post creation date.
$resource_created = ( ( time() - 10 ) <= strtotime( $gmt_date ) );
if ( 'created' === $this->get_event() && ! $resource_created ) {
return false;
} elseif ( 'updated' === $this->get_event() && $resource_created ) {
return false;
}
return true;
}