WP_Block_Processor::is_non_whitespace_htmlpublicWP 6.9.0

Indicates if the matched delimiter is an HTML span and comprises more than whitespace characters, i.e. contains real content.

Many block serializers introduce newlines between block delimiters, so the presence of top-level non-block content does not imply that there are “real” freeform HTML blocks. Checking if there is content beyond whitespace is a more certain check, such as for determining whether to load CSS for the freeform or fallback block type.

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

Хуков нет.

Возвращает

true|false. Whether the currently-matched delimiter is an HTML span containing non-whitespace text.

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

$WP_Block_Processor = new WP_Block_Processor();
$WP_Block_Processor->is_non_whitespace_html(): bool;

Заметки

  • Смотрите: self::is_html()

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

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

Код WP_Block_Processor::is_non_whitespace_html() WP 6.9.1

public function is_non_whitespace_html(): bool {
	if ( ! $this->is_html() ) {
		return false;
	}

	$length = $this->matched_delimiter_at - $this->after_previous_delimiter;

	$whitespace_length = strspn(
		$this->source_text,
		" \t\f\r\n",
		$this->after_previous_delimiter,
		$length
	);

	return $whitespace_length !== $length;
}