shortcode_atts_{$shortcode}
云策文档标注
概述
shortcode_atts_{$shortcode} 是一个 WordPress 过滤器,用于修改短码属性。它仅在 shortcode_atts() 函数的第三个参数存在时可用,允许开发者基于短码名称自定义属性处理。
关键要点
- 过滤器名称:shortcode_atts_{$shortcode},其中 $shortcode 是短码名称。
- 触发条件:当 shortcode_atts() 函数提供第三个参数 $shortcode 时可用。
- 参数:$out(输出数组)、$pairs(支持的属性及默认值)、$atts(用户定义的属性)、$shortcode(短码名称)。
- 用途:结合用户属性与已知属性,并在需要时填充默认值。
- 版本历史:从 WordPress 3.6.0 引入,4.4.0 版本添加了 $shortcode 参数。
代码示例
$out = apply_filters( "shortcode_atts_{$shortcode}", $out, $pairs, $atts, $shortcode );
原文内容
Filters shortcode attributes.
Description
If the third parameter of the shortcode_atts() function is present then this filter is available.
The third parameter, $shortcode, is the name of the shortcode.
Parameters
$outarray-
The output array of shortcode attributes.
$pairsarray-
The supported attributes and their defaults.
$attsarray-
The user defined shortcode attributes.
$shortcodestring-
The shortcode name.
Source
$out = apply_filters( "shortcode_atts_{$shortcode}", $out, $pairs, $atts, $shortcode );