do_shortcode_tag()执行一个短标签钩子

目录

描述

Regular Expression callable for do_shortcode() for calling shortcode hook.

do_shortcode_tag() 描述

用法

<?php do_shortcode_tag$m ?>

do_shortcode_tag() 用法

参数

$m

(array) (必填) Regular expression match array

默认值: None

do_shortcode_tag() 参数

返回值

(mixed) 

False on failure.

do_shortcode_tag() 返回值

注意

  • 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

do_shortcode_tag() 注意

历史

添加于 版本: 2.5

do_shortcode_tag() 历史

源文件

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

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
/**
 * 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];
	}
}

do_shortcode_tag() 源文件