WC_Webhook::is_valid_post_action
Validates post actions.
Метод класса: WC_Webhook{}
Хуков нет.
Возвращает
bool. True if validation passes.
Использование
// private - только в коде основоного (родительского) класса $result = $this->is_valid_post_action( $arg );
- $arg(разное) (обязательный)
- First hook argument.
Список изменений
| С версии 3.6.0 | Введена. |
Код WC_Webhook::is_valid_post_action() WC Webhook::is valid post action 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();
}