shortcode_atts()将用户输入的短代码的属性值和短代码默认属性值合并

目录

描述

 用户输入的短代码的属性值和短代码默认属性值合并,  将包含所有已知属性的每个 key,他们的值是合 之后的结果。

shortcode_atts() 描述

用法

<?php shortcode_atts$pairs $atts$shortcode ); ?>

shortcode_atts() 用法

参数

$pairs

(array) (必填) Entire list of supported attributes and their defaults

默认值: None

$atts

(array) (必填) User defined attributes in shortcode tag

默认值: None

$shortcode

(string) (可选) Shortcode name to be used by the shortcode_atts_{$shortcode} filter. If this is present, it makes a "shortcode_atts_$shortcode" filter available for other code to filter the attributes. It should always be included for maximum compatibility, however it is an optional variable.

默认值: None

shortcode_atts() 参数

返回值

(array

Combined and filtered attribute list.

shortcode_atts() 返回值

示例

[bartag foo="koala" bar="bears"] outputs the following:
bartag: koala bears

[bartag foo="koala"] outputs the following:
bartag: koala default bar

This creates a "[bartag]" shortcode that supports two attributes: [bartag foo="something" bar="something else"]. Both attributes are optional and will take on default options if they are not provided.

shortcode_atts() 示例

注意

The pairs should be considered to be all of the attributes which are supported by the caller and given as a list. The returned attributes will only contain the attributes in the $pairs list.

If the $atts list has unsupported attributes, then they will be ignored and removed from the final returned list.

shortcode_atts() 注意

历史

shortcode_atts() 历史

源文件

shortcode_atts() 函数的代码位于 wp-includes/shortcodes.php.

shortcode_atts() 源文件

相关