WP_HTML_Processor::bail()privateWP 6.7.0

Stops the parser and terminates its execution when encountering unsupported markup.

Method of the class: WP_HTML_Processor{}

No Hooks.

Return

null. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->bail( $message );
$message(string) (required)
Explains support is missing in order to parse the current node.

Changelog

Since 6.7.0 Introduced.

WP_HTML_Processor::bail() code WP 6.7.1

private function bail( string $message ) {
	$here  = $this->bookmarks[ $this->state->current_token->bookmark_name ];
	$token = substr( $this->html, $here->start, $here->length );

	$open_elements = array();
	foreach ( $this->state->stack_of_open_elements->stack as $item ) {
		$open_elements[] = $item->node_name;
	}

	$active_formats = array();
	foreach ( $this->state->active_formatting_elements->walk_down() as $item ) {
		$active_formats[] = $item->node_name;
	}

	$this->last_error = self::ERROR_UNSUPPORTED;

	$this->unsupported_exception = new WP_HTML_Unsupported_Exception(
		$message,
		$this->state->current_token->node_name,
		$here->start,
		$token,
		$open_elements,
		$active_formats
	);

	throw $this->unsupported_exception;
}