WP_Interactivity_API::data_wp_interactive_processor( WP_Interactivity_API_Directives_Processor $p, string $mode, array $context_stack, array $namespace_stack )

In this article

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.

Processes the data-wp-interactive directive.

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

$pWP_Interactivity_API_Directives_Processorrequired
The directives processor instance.
$modestringrequired
Whether the processing is entering or exiting the tag.
$context_stackarrayrequired
The reference to the context stack.
$namespace_stackarrayrequired
The reference to the store namespace stack.

Source

$attr_names    = $p->get_attribute_names_with_prefix( '' ) ?? array();

foreach ( $attr_names as $name ) {
	$element_attrs[ $name ] = $p->get_attribute( $name );
}

// Assign the current element right before running its directive processors.
$this->current_element = array(
	'attributes' => $element_attrs,
);

foreach ( $modes as $mode => $should_run ) {
	if ( ! $should_run ) {
		continue;
	}

	/*
	 * Sorts the attributes by the order of the `directives_processor` array
	 * and checks what directives are present in this element.
	 */
	$existing_directives_prefixes = array_intersect(
		'enter' === $mode ? $directive_processor_prefixes : $directive_processor_prefixes_reversed,
		$directives_prefixes
	);
	foreach ( $existing_directives_prefixes as $directive_prefix ) {
		$func = is_array( self::$directive_processors[ $directive_prefix ] )
			? self::$directive_processors[ $directive_prefix ]
			: array( $this, self::$directive_processors[ $directive_prefix ] );

		call_user_func_array( $func, array( $p, $mode, &$tag_stack ) );
	}

Changelog

VersionDescription
6.5.0Introduced.

User Contributed Notes

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