WC_API_Webhooks::get_webhooks_count()publicWC 2.2

Get the total number of webhooks

Метод класса: WC_API_Webhooks{}

Хуков нет.

Возвращает

Массив|WP_Error.

Использование

$WC_API_Webhooks = new WC_API_Webhooks();
$WC_API_Webhooks->get_webhooks_count( $status, $filter );
$status(строка)
-
По умолчанию: null
$filter(массив)
-
По умолчанию: array()

Список изменений

С версии 2.2 Введена.

Код WC_API_Webhooks::get_webhooks_count() WC 8.7.0

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() ) );
	}
}