WP_HTML_Tag_Processor::skip_rcdata( string $tag_name ): bool

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness. Use https://html.spec.whatwg.org/multipage/parsing.html#rcdata-state instead.

Skips contents of RCDATA elements, namely title and textarea tags.

Description

See also

Parameters

$tag_namestringrequired
The uppercase tag name which will close the RCDATA region.

Return

bool Whether an end to the RCDATA region was found before the end of the document.

Source

 *     while ( $p->next_tag( array( 'tag_closers' => $in_list ? 'visit' : 'skip' ) ) ) {
 *         if ( 'UL' === $p->get_tag() ) {
 *             if ( $p->is_tag_closer() ) {
 *                 $in_list = false;
 *                 $p->set_bookmark( 'resume' );
 *                 if ( $p->seek( 'last-li' ) ) {
 *                     $p->add_class( 'last-li' );
 *                 }
 *                 $p->seek( 'resume' );
 *                 $p->release_bookmark( 'last-li' );
 *                 $p->release_bookmark( 'resume' );
 *             } else {
 *                 $in_list = true;
 *             }
 *         }
 *
 *         if ( 'LI' === $p->get_tag() ) {
 *             $p->set_bookmark( 'last-li' );
 *         }
 *     }
 *
 * Bookmarks intentionally hide the internal string offsets
 * to which they refer. They are maintained internally as
 * updates are applied to the HTML document and therefore
 * retain their "position" - the location to which they
 * originally pointed. The inability to use bookmarks with
 * functions like `substr` is therefore intentional to guard
 * against accidentally breaking the HTML.
 *
 * Because bookmarks allocate memory and require processing
 * for every applied update, they are limited and require
 * a name. They should not be created with programmatically-made
 * names, such as "li_{$index}" with some loop. As a general
 * rule they should only be created with string-literal names
 * like "start-of-section" or "last-paragraph".
 *
 * Bookmarks are a powerful tool to enable complicated behavior.
 * Consider double-checking that you need this tool if you are
 * reaching for it, as inappropriate use could lead to broken
 * HTML structure or unwanted processing overhead.
 *
 * @since 6.2.0
 *
 * @param string $name Identifies this particular bookmark.
 * @return bool Whether the bookmark was successfully created.
 */
public function set_bookmark( $name ): bool {
	// It only makes sense to set a bookmark if the parser has paused on a concrete token.
	if (
		self::STATE_COMPLETE === $this->parser_state ||
		self::STATE_INCOMPLETE_INPUT === $this->parser_state
	) {
		return false;
	}

	if ( ! array_key_exists( $name, $this->bookmarks ) && count( $this->bookmarks ) >= static::MAX_BOOKMARKS ) {
		_doing_it_wrong(
			__METHOD__,
			__( 'Too many bookmarks: cannot create any more.' ),
			'6.2.0'
		);
		return false;
	}

	$this->bookmarks[ $name ] = new WP_HTML_Span( $this->token_starts_at, $this->token_length );

	return true;
}


/**
 * Removes a bookmark that is no longer needed.
 *
 * Releasing a bookmark frees up the small
 * performance overhead it requires.
 *
 * @param string $name Name of the bookmark to remove.
 * @return bool Whether the bookmark already existed before removal.
 */
public function release_bookmark( $name ): bool {

Changelog

VersionDescription
6.2.0Introduced.

User Contributed Notes

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