WP_Block_Processor::get_span(): WP_HTML_Span|null

In this article

Returns the span representing the currently-matched delimiter, if matched, otherwise null.

Description

Example:

$processor = new WP_Block_Processor( '<!-- wp:void /-->' );
null     === $processor->get_span();

$processor->next_delimiter();
WP_HTML_Span( 0, 17 ) === $processor->get_span();

Return

WP_HTML_Span|null Span of text in source text spanning matched delimiter.

Source

public function get_span(): ?WP_HTML_Span {
	switch ( $this->state ) {
		case self::HTML_SPAN:
			return new WP_HTML_Span( $this->after_previous_delimiter, $this->matched_delimiter_at - $this->after_previous_delimiter );

		case self::MATCHED:
			return new WP_HTML_Span( $this->matched_delimiter_at, $this->matched_delimiter_length );

		default:
			return null;
	}
}

Changelog

VersionDescription
6.9.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.