Title: WP_Interactivity_API::data_wp_interactive_processor
Published: April 3, 2024
Last modified: May 20, 2026

---

# WP_Interactivity_API::data_wp_interactive_processor( WP_Interactivity_API_Directives_Processor $p, string $mode )

## In this article

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

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

This function’s access is marked private. This means it is not intended for use 
by plugin or theme developers, only by core. It is listed here for completeness.

Processes the `data-wp-interactive` directive.

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

It adds the default store namespace defined in the directive value to the stack 
so that it’s available for the nested interactivity elements.

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

 `$p`[WP_Interactivity_API_Directives_Processor](https://developer.wordpress.org/reference/classes/wp_interactivity_api_directives_processor/)
required

The directives processor instance.

`$mode`stringrequired

Whether the processing is entering or exiting the tag.

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

    ```php
    private function data_wp_interactive_processor( WP_Interactivity_API_Directives_Processor $p, string $mode ) {
    	// When exiting tags, it removes the last namespace from the stack.
    	if ( 'exit' === $mode ) {
    		array_pop( $this->namespace_stack );
    		return;
    	}

    	// Tries to decode the `data-wp-interactive` attribute value.
    	$attribute_value = $p->get_attribute( 'data-wp-interactive' );

    	/*
    	 * Pushes the newly defined namespace or the current one if the
    	 * `data-wp-interactive` definition was invalid or does not contain a
    	 * namespace. It does so because the function pops out the current namespace
    	 * from the stack whenever it finds a `data-wp-interactive`'s closing tag,
    	 * independently of whether the previous `data-wp-interactive` definition
    	 * contained a valid namespace.
    	 */
    	$new_namespace = null;
    	if ( is_string( $attribute_value ) && ! empty( $attribute_value ) ) {
    		$decoded_json = json_decode( $attribute_value, true );
    		if ( is_array( $decoded_json ) ) {
    			$new_namespace = $decoded_json['namespace'] ?? null;
    		} else {
    			$new_namespace = $attribute_value;
    		}
    	}
    	$this->namespace_stack[] = ( $new_namespace && 1 === preg_match( '/^([\w\-_\/]+)/', $new_namespace ) )
    		? $new_namespace
    		: end( $this->namespace_stack );
    }
    ```

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

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

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

## User Contributed Notes

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