WC_API_Webhooks::get_webhooks_count( string $status = null, array $filter = array() )
Get the total number of webhooks
Description Description
Parameters Parameters
- $status
-
(Optional)
Default value: null
- $filter
-
(Optional)
Default value: array()
Return Return
(array|WP_Error)
Source Source
File: includes/legacy/api/v2/class-wc-api-webhooks.php
public function get_webhooks_count( $status = null, $filter = array() ) { try { if ( ! current_user_can( 'manage_woocommerce' ) ) { throw new WC_API_Exception( 'woocommerce_api_user_cannot_read_webhooks_count', __( 'You do not have permission to read the webhooks count', 'woocommerce' ), 401 ); } if ( ! empty( $status ) ) { $filter['status'] = $status; } $query = $this->query_webhooks( $filter ); return array( 'count' => $query['headers']->total ); } catch ( WC_API_Exception $e ) { return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); } }
Changelog Changelog
Version | Description |
---|---|
2.2 | Introduced. |