Title: WP_HTML_Open_Elements::after_element_pop
Published: November 8, 2023
Last modified: February 24, 2026

---

# WP_HTML_Open_Elements::after_element_pop( WP_HTML_Token $item )

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_html_open_elements/after_element_pop/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/classes/wp_html_open_elements/after_element_pop/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/classes/wp_html_open_elements/after_element_pop/?output_format=md#source)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_html_open_elements/after_element_pop/?output_format=md#changelog)

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

Updates internal flags after removing an element.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wp_html_open_elements/after_element_pop/?output_format=md#description)󠁿

Certain conditions (such as “has_p_in_button_scope”) are maintained here as flags
that are only modified when adding and removing elements. This allows the HTML Processor
to quickly check for these conditions instead of iterating over the open stack elements
upon each new tag it encounters. These flags, however, need to be maintained as 
items are added and removed from the stack.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_html_open_elements/after_element_pop/?output_format=md#parameters)󠁿

 `$item`[WP_HTML_Token](https://developer.wordpress.org/reference/classes/wp_html_token/)
required

Element that was removed from the stack of open elements.

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

    ```php
     */
    public function after_element_pop( WP_HTML_Token $item ): void {
    	/*
    	 * When adding support for new elements, expand this switch to trap
    	 * cases where the precalculated value needs to change.
    	 */
    	switch ( $item->node_name ) {
    		case 'APPLET':
    		case 'BUTTON':
    		case 'CAPTION':
    		case 'HTML':
    		case 'P':
    		case 'TABLE':
    		case 'TD':
    		case 'TH':
    		case 'MARQUEE':
    		case 'OBJECT':
    		case 'TEMPLATE':
    		case 'math MI':
    		case 'math MO':
    		case 'math MN':
    		case 'math MS':
    		case 'math MTEXT':
    		case 'math ANNOTATION-XML':
    		case 'svg FOREIGNOBJECT':
    		case 'svg DESC':
    		case 'svg TITLE':
    			$this->has_p_in_button_scope = $this->has_element_in_button_scope( 'P' );
    			break;
    	}

    	if ( null !== $this->pop_handler ) {
    		call_user_func( $this->pop_handler, $item );
    	}
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/html-api/class-wp-html-open-elements.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/html-api/class-wp-html-open-elements.php#L735)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/html-api/class-wp-html-open-elements.php#L735-L768)

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_html_open_elements/after_element_pop/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.4.0](https://developer.wordpress.org/reference/since/6.4.0/) | Introduced. |

## User Contributed Notes

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