WP_Interactivity_API::process_directives()publicWP 6.5.0

Processes the interactivity directives contained within the HTML content and updates the markup accordingly.

Method of the class: WP_Interactivity_API{}

No Hooks.

Return

String. The processed HTML content. It returns the original content when the HTML contains unbalanced tags.

Usage

$WP_Interactivity_API = new WP_Interactivity_API();
$WP_Interactivity_API->process_directives( $html ): string;
$html(string) (required)
The HTML content to process.

Changelog

Since 6.5.0 Introduced.

WP_Interactivity_API::process_directives() code WP 6.6

public function process_directives( string $html ): string {
	if ( ! str_contains( $html, 'data-wp-' ) ) {
		return $html;
	}

	$this->namespace_stack = array();
	$this->context_stack   = array();

	$result = $this->_process_directives( $html );

	$this->namespace_stack = null;
	$this->context_stack   = null;

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