WC_API_Webhooks::get_webhook()
Get the webhook for the given ID
Метод класса: WC_API_Webhooks{}
Хуки из метода
Возвращает
Массив|WP_Error
.
Использование
$WC_API_Webhooks = new WC_API_Webhooks(); $WC_API_Webhooks->get_webhook( $id, $fields );
- $id(int) (обязательный)
- webhook ID
- $fields(массив)
- -
По умолчанию: null
Список изменений
С версии 2.2 | Введена. |
Код WC_API_Webhooks::get_webhook() WC API Webhooks::get webhook WC 7.7.2
public function get_webhook( $id, $fields = null ) { // ensure webhook ID is valid & user has permission to read $id = $this->validate_request( $id, 'shop_webhook', 'read' ); if ( is_wp_error( $id ) ) { return $id; } $webhook = wc_get_webhook( $id ); $webhook_data = array( 'id' => $webhook->get_id(), 'name' => $webhook->get_name(), 'status' => $webhook->get_status(), 'topic' => $webhook->get_topic(), 'resource' => $webhook->get_resource(), 'event' => $webhook->get_event(), 'hooks' => $webhook->get_hooks(), 'delivery_url' => $webhook->get_delivery_url(), 'created_at' => $this->server->format_datetime( $webhook->get_date_created() ? $webhook->get_date_created()->getTimestamp() : 0, false, false ), // API gives UTC times. 'updated_at' => $this->server->format_datetime( $webhook->get_date_modified() ? $webhook->get_date_modified()->getTimestamp() : 0, false, false ), // API gives UTC times. ); return array( 'webhook' => apply_filters( 'woocommerce_api_webhook_response', $webhook_data, $webhook, $fields, $this ) ); }