WP_HTML_Tag_Processor::get_updated_html()publicWP 6.2.0

Returns the string representation of the HTML Tag Processor.

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

Хуков нет.

Возвращает

Строку. The processed HTML.

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

$WP_HTML_Tag_Processor = new WP_HTML_Tag_Processor();
$WP_HTML_Tag_Processor->get_updated_html();

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

С версии 6.2.0 Введена.
С версии 6.2.1 Shifts the internal cursor corresponding to the applied updates.

Код WP_HTML_Tag_Processor::get_updated_html() WP 6.3.1

public function get_updated_html() {
	$requires_no_updating = 0 === count( $this->classname_updates ) && 0 === count( $this->lexical_updates );

	/*
	 * When there is nothing more to update and nothing has already been
	 * updated, return the original document and avoid a string copy.
	 */
	if ( $requires_no_updating ) {
		return $this->html;
	}

	/*
	 * Keep track of the position right before the current tag. This will
	 * be necessary for reparsing the current tag after updating the HTML.
	 */
	$before_current_tag = $this->tag_name_starts_at - 1;

	/*
	 * 1. Apply the enqueued edits and update all the pointers to reflect those changes.
	 */
	$this->class_name_updates_to_attributes_updates();
	$before_current_tag += $this->apply_attributes_updates( $before_current_tag );

	/*
	 * 2. Rewind to before the current tag and reparse to get updated attributes.
	 *
	 * At this point the internal cursor points to the end of the tag name.
	 * Rewind before the tag name starts so that it's as if the cursor didn't
	 * move; a call to `next_tag()` will reparse the recently-updated attributes
	 * and additional calls to modify the attributes will apply at this same
	 * location.
	 *
	 * <p>Previous HTML<em>More HTML</em></p>
	 *                 ^  | back up by the length of the tag name plus the opening <
	 *                 \<-/ back up by strlen("em") + 1 ==> 3
	 */

	// Store existing state so it can be restored after reparsing.
	$previous_parsed_byte_count = $this->bytes_already_parsed;
	$previous_query             = $this->last_query;

	// Reparse attributes.
	$this->bytes_already_parsed = $before_current_tag;
	$this->next_tag();

	// Restore previous state.
	$this->bytes_already_parsed = $previous_parsed_byte_count;
	$this->parse_query( $previous_query );

	return $this->html;
}