WordPress函数文档do_shortcode_tag()
执行一个短标签钩子 描述 Regular Expression callable for do_shortco…
执行一个短标签钩子
描述
Regular Expression callable for do_shortcode() for calling shortcode hook.
用法
<?php do_shortcode_tag( $m ) ?>
参数
$m
(array) (必填) Regular expression match array
默认值: None
返回值
(mixed)
False on failure.
注意
- This is a private function. It should not be called directly. It is listed in the Codex for completeness.
- See get_shortcode_regex for details of the match array contents.
- 使用到 global: (unknown type) $shortcode_tags
历史
添加于 版本: 2.5
源文件
do_shortcode_tag() 函数的代码位于 wp-includes/shortcodes.php
.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
/* ———————————-
* wordpress函数 kim收集
* ———————————- */
/**
* Regular Expression callable for do_shortcode() for calling shortcode hook.
* @see get_shortcode_regex for details of the match array contents.
*
* @since 2.5.0
* @access private
*
* @global array $shortcode_tags
*
* @param array $m Regular expression match array
* @return string|false False on failure.
*/
function do_shortcode_tag( $m ) {
global $shortcode_tags;
// allow [[foo]] syntax for escaping a tag
if ( $m[1] == ‘[‘ && $m[6] == ‘]’ ) {
return substr($m[0], 1, –1);
}
$tag = $m[2];
$attr = shortcode_parse_atts( $m[3] );
if ( ! is_callable( $shortcode_tags[ $tag ] ) ) {
$message = sprintf( __( ‘Attempting to parse a shortcode without a valid callback: %s’ ), $tag );
_doing_it_wrong( __FUNCTION__, $message, ‘4.3.0’ );
return $m[0];
}
if ( isset( $m[5] ) ) {
// enclosing tag – extra parameter
return $m[1] . call_user_func( $shortcode_tags[$tag], $attr, $m[5], $tag ) . $m[6];
} else {
// self-closing tag
return $m[1] . call_user_func( $shortcode_tags[$tag], $attr, null, $tag ) . $m[6];
}
}
|
- 原文:http://codex.wordpress.org/Function_Reference/do_shortcode_tag
类别:WordPress函数文档、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。
评论功能已经关闭!