Automattic\WooCommerce\Internal\PushNotifications\DataStores

PushTokensDataStore::has_tokens │ public │ WC 11.2.0

Determines whether any push token exists, ignoring roles and preferences so callers can bail out before the cost of get_tokens_for_roles().

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

Хуков нет.

Возвращает

bool. True if at least one push token exists.

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

$PushTokensDataStore = new PushTokensDataStore();
$PushTokensDataStore->has_tokens(): bool;

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

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

Код PushTokensDataStore::has_tokens() WC 11.2.2

public function has_tokens(): bool {
	if ( null !== $this->has_tokens ) {
		return $this->has_tokens;
	}

	global $wpdb;

	// Exactly this SQL to leverage the wp_posts type_status_author index.
	$this->has_tokens = (bool) $wpdb->get_var(
		$wpdb->prepare(
			"SELECT 1 FROM {$wpdb->posts} WHERE post_type = %s AND post_status = 'private' LIMIT 1",
			PushToken::POST_TYPE
		)
	);

	return $this->has_tokens;
}