函数文档

wp_interactivity_get_element()

💡 云策文档标注

概述

wp_interactivity_get_element() 函数用于在指令处理期间获取当前正在处理的元素的数组表示。它返回一个包含属性信息的数组或 null。

关键要点

  • 函数返回当前元素的数组表示,格式为 array{attributes: array}|null。
  • 仅应在指令处理过程中使用此函数。
  • 函数内部调用 wp_interactivity()->get_element() 来获取元素数据。
  • 首次引入于 WordPress 6.7.0 版本。

代码示例

function wp_interactivity_get_element(): ?array {
    return wp_interactivity()->get_element();
}

📄 原文内容

Returns an array representation of the current element being processed.

Description

The function should be used only during directive processing.

Return

array{attributes: array<string, string|bool>}|null Current element.

Source

function wp_interactivity_get_element(): ?array {
	return wp_interactivity()->get_element();
}

Changelog

Version Description
6.7.0 Introduced.