WC_Webhook_Data_Store::get_webhook_count()protectedWC 3.6.0

Count webhooks.

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

Хуков нет.

Возвращает

int.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_webhook_count( $status );
$status(строка)
Status to count.
По умолчанию: 'active'

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

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

Код WC_Webhook_Data_Store::get_webhook_count() WC 8.7.0

protected function get_webhook_count( $status = 'active' ) {
	global $wpdb;
	$cache_key = WC_Cache_Helper::get_cache_prefix( 'webhooks' ) . $status . '_count';
	$count     = wp_cache_get( $cache_key, 'webhooks' );

	if ( false === $count ) {
		$count = absint( $wpdb->get_var( $wpdb->prepare( "SELECT count( webhook_id ) FROM {$wpdb->prefix}wc_webhooks WHERE `status` = %s;", $status ) ) );

		wp_cache_add( $cache_key, $count, 'webhooks' );
	}

	return $count;
}