shortcode_parse_atts
函数
shortcode_parse_atts ( $text )
- 参数
-
-
(string)
$text- Required: 是
-
(string)
- 返回值
-
- (array|string) List of attribute values. Returns empty array if ‘””‘ === trim( $text ). Returns empty string if ” === trim( $text ). All other matches are checked for not empty().
- 定义位置
-
-
wp-includes/shortcodes.php
, line 530
-
wp-includes/shortcodes.php
- 引入
- 2.5.0
- 弃用
- –
Retrieves all attributes from the shortcodes tag.
The attributes list has the attribute name as the key and the value of the
attribute as the value in the key/value pair. This allows for easier
retrieval of the attributes, since all attributes have to be known.
function shortcode_parse_atts( $text ) { $atts = array(); $pattern = get_shortcode_atts_regex(); $text = preg_replace( "/[x{00a0}x{200b}]+/u", ' ', $text ); if ( preg_match_all( $pattern, $text, $match, PREG_SET_ORDER ) ) { foreach ( $match as $m ) { if ( ! empty( $m[1] ) ) { $atts[ strtolower( $m[1] ) ] = stripcslashes( $m[2] ); } elseif ( ! empty( $m[3] ) ) { $atts[ strtolower( $m[3] ) ] = stripcslashes( $m[4] ); } elseif ( ! empty( $m[5] ) ) { $atts[ strtolower( $m[5] ) ] = stripcslashes( $m[6] ); } elseif ( isset( $m[7] ) && strlen( $m[7] ) ) { $atts[] = stripcslashes( $m[7] ); } elseif ( isset( $m[8] ) && strlen( $m[8] ) ) { $atts[] = stripcslashes( $m[8] ); } elseif ( isset( $m[9] ) ) { $atts[] = stripcslashes( $m[9] ); } } // Reject any unclosed HTML elements. foreach ( $atts as &$value ) { if ( false !== strpos( $value, ']*+>[^
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。