Title: class@anonymous::remove_token
Published: August 20, 2026

---

# class@anonymous::remove_token()

## In this article

 * [Source](https://developer.wordpress.org/reference/classes/classanonymous/remove_token/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/classanonymous/remove_token/?output_format=md#related)

[ Back to top](https://developer.wordpress.org/reference/classes/classanonymous/remove_token/?output_format=md#wp--skip-link--target)

Removes the current token, keeping any text it wraps.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/classanonymous/remove_token/?output_format=md#source)󠁿

    ```php
    public function remove_token(): void {
    	// Always called after next_tag() returned true, so the bookmark is set.
    	$this->set_bookmark( 'here' );
    	$span = $this->bookmarks['here'];

    	$this->lexical_updates[] = new WP_HTML_Text_Replacement( $span->start, $span->length, '' );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/comment.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/comment.php#L4590)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/comment.php#L4590-L4596)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/classanonymous/remove_token/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_HTML_Text_Replacement::__construct()](https://developer.wordpress.org/reference/classes/wp_html_text_replacement/__construct/)`wp-includes/html-api/class-wp-html-text-replacement.php` |

Constructor.

  |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fclassanonymous%2Fremove_token%2F)
before being able to contribute a note or feedback.