do_shortcode_tag()

执行一个短标签钩子

描述

正则表达式可调用 do_shortcode() 用于调用短代码钩子。

用法

<?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.

/**
* 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];

}

}
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索