函数文档

wp_interactivity_process_directives()

💡 云策文档标注

概述

wp_interactivity_process_directives() 函数用于处理 HTML 内容中的交互性指令,并相应更新标记。它返回处理后的 HTML 内容,或在 HTML 包含不平衡标签时返回原始内容。

关键要点

  • 参数:$html(字符串,必需),要处理的 HTML 内容。
  • 返回值:字符串,处理后的 HTML 内容;如果 HTML 包含不平衡标签,则返回原始内容。
  • 函数定义:调用 wp_interactivity()->process_directives($html) 来实现功能。
  • 相关函数:wp_interactivity() 用于检索 WP_Interactivity_API 实例。
  • 使用场景:被 WP_Block::render() 用于生成块的渲染输出。
  • 版本历史:在 WordPress 6.5.0 中引入。

📄 原文内容

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

Parameters

$htmlstringrequired
The HTML content to process.

Return

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

Source

function wp_interactivity_process_directives( string $html ): string {
	return wp_interactivity()->process_directives( $html );
}

Changelog

Version Description
6.5.0 Introduced.