WP_Interactivity_API::evaluate( string|true $directive_value, string $default_namespace, array|false $context = false ): mixed|null

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.

Evaluates the reference path passed to a directive based on the current store namespace, state and context.

Parameters

$directive_valuestring|truerequired
The directive attribute value string or true when it’s a boolean attribute.
$default_namespacestringrequired
The default namespace to use if none is explicitly defined in the directive value.
$contextarray|falseoptional
The current context for evaluating the directive or false if there is no context.

Default:false

Return

mixed|null The result of the evaluation. Null if the reference path doesn’t exist.

Source

	$this->context_stack   = null;

	return null === $result ? $html : $result;
}

/**
 * Processes the interactivity directives contained within the HTML content
 * and updates the markup accordingly.
 *
 * It uses the WP_Interactivity_API instance's context and namespace stacks,
 * which are shared between all calls.
 *
 * This method returns null if the HTML contains unbalanced tags.
 *
 * @since 6.6.0
 *
 * @param string $html The HTML content to process.
 * @return string|null The processed HTML content. It returns null when the HTML contains unbalanced tags.
 */
private function _process_directives( string $html ) {
	$p          = new WP_Interactivity_API_Directives_Processor( $html );
	$tag_stack  = array();
	$unbalanced = false;

	$directive_processor_prefixes          = array_keys( self::$directive_processors );
	$directive_processor_prefixes_reversed = array_reverse( $directive_processor_prefixes );

	/*
	 * Save the current size for each stack to restore them in case

Changelog

VersionDescription
6.5.0Introduced.

User Contributed Notes

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