WP_HTML_Tag_Processor::seek()publicWP 6.2.0

Move the internal cursor in the Tag Processor to a given bookmark's location.

In order to prevent accidental infinite loops, there's a maximum limit on the number of times seek() can be called.

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

Хуков нет.

Возвращает

true|false. Whether the internal cursor was successfully moved to the bookmark's location.

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

$WP_HTML_Tag_Processor = new WP_HTML_Tag_Processor();
$WP_HTML_Tag_Processor->seek( $bookmark_name );
$bookmark_name(строка) (обязательный)
Jump to the place in the document identified by this bookmark name.

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

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

Код WP_HTML_Tag_Processor::seek() WP 6.3.1

public function seek( $bookmark_name ) {
	if ( ! array_key_exists( $bookmark_name, $this->bookmarks ) ) {
		_doing_it_wrong(
			__METHOD__,
			__( 'Unknown bookmark name.' ),
			'6.2.0'
		);
		return false;
	}

	if ( ++$this->seek_count > self::MAX_SEEK_OPS ) {
		_doing_it_wrong(
			__METHOD__,
			__( 'Too many calls to seek() - this can lead to performance issues.' ),
			'6.2.0'
		);
		return false;
	}

	// Flush out any pending updates to the document.
	$this->get_updated_html();

	// Point this tag processor before the sought tag opener and consume it.
	$this->bytes_already_parsed = $this->bookmarks[ $bookmark_name ]->start;
	return $this->next_tag( array( 'tag_closers' => 'visit' ) );
}