wp_interactivity_config()
云策文档标注
概述
wp_interactivity_config() 函数用于获取或设置 Interactivity API 中指定存储命名空间的配置。当提供配置参数时,它会将新配置与现有配置合并。
关键要点
- 函数功能:获取或设置 Interactivity API 的配置,针对特定 store namespace。
- 参数说明:$store_namespace 为必需的字符串参数,标识存储命名空间;$config 为可选数组参数,用于合并配置,默认值为空数组。
- 返回值:返回指定存储命名空间的配置数组,如果提供了 $config 参数,则返回更新后的配置。
- 内部实现:调用 wp_interactivity()->config() 方法处理配置操作。
- 版本历史:自 WordPress 6.5.0 版本引入。
代码示例
function wp_interactivity_config( string $store_namespace, array $config = array() ): array {
return wp_interactivity()->config( $store_namespace, $config );
}
原文内容
Gets and/or sets the configuration of the Interactivity API for a given store namespace.
Description
If configuration for that store namespace exists, it merges the new provided configuration with the existing one.
Parameters
$store_namespacestringrequired-
The unique store namespace identifier.
$configarrayoptional-
The array that will be merged with the existing configuration for the specified store namespace.
Default:
array()
Source
function wp_interactivity_config( string $store_namespace, array $config = array() ): array {
return wp_interactivity()->config( $store_namespace, $config );
}
Changelog
| Version | Description |
|---|---|
| 6.5.0 | Introduced. |