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.


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



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


 * 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
	 * the processing finds unbalanced tags.
	$namespace_stack_size = count( $this->namespace_stack );
	$context_stack_size   = count( $this->context_stack );

	while ( $p->next_tag( array( 'tag_closers' => 'visit' ) ) ) {
		$tag_name = $p->get_tag();

		 * Directives inside SVG and MATH tags are not processed,
		 * as they are not compatible with the Tag Processor yet.
		 * We still process the rest of the HTML.



User Contributed Notes

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