shortcode_parse_atts()
shortcode_parse_atts( string $text ) 从shortcodes标记检索所有属…
shortcode_parse_atts( string $text )
从shortcodes标记检索所有属性。
		Retrieve all attributes from the shortcodes tag.
	
从shortcodes标记检索所有属性。
		Retrieve all attributes from the shortcodes tag.
	
目录锚点:#说明#参数#源码#笔记
说明(Description)
属性列表将属性名称作为键,属性的值作为键/值对中的值。这样可以更容易地检索属性,因为所有属性都必须是已知的。
参数(Parameters)
| 参数 | 类型 | 说明 | 
|---|---|---|
| $text | (string) | 
源码(Source)
/**
 * Retrieve 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.
 *
 * @since 2.5.0
 *
 * @param string $text
 * @return array List of attributes and their value.
 */
function shortcode_parse_atts($text) {
	$atts = array();
	$pattern = '/([w-]+)s*=s*"([^"]*)"(?:s|$)|([w-]+)s*=s*'([^']*)'(?:s|$)|([w-]+)s*=s*([^s'"]+)(?:s|$)|"([^"]*)"(?:s|$)|(S+)(?:s|$)/';
	$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]))
				$atts[] = stripcslashes($m[8]);
		}
	} else {
		$atts = ltrim($text);
	}
	return $atts;
}| 更新版本 | 源码位置 | 使用 | 被使用 | 
|---|---|---|---|
| 2.5.0 | wp-includes/shortcodes.php | 9 | 10 | 
笔记(Notes)
要获取shortcode属性值:
类别:WordPress 函数手册、 
		本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。







还没有任何评论,赶紧来占个楼吧!