allow php tag,wordpress函数do_shortcode_tag()用法示例

Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness. Use get_shortcode_regex instead.

do_shortcode_tag( array $m )

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

描述

参数

$m

(array)

(Required)

Regular expression match array

返回值

(string|false) False on failure.

源代码

File: wp-includes/shortcodes.php

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 ] ) ) {

/* translators: %s: shortcode 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];

}

/**

* Filters whether to call a shortcode callback.

*

* Passing a truthy value to the filter will effectively short-circuit the

* shortcode generation process, returning that value instead.

*

* @since 4.7.0

*

* @param bool|string $return Short-circuit return value. Either false or the value to replace the shortcode with.

* @param string $tag Shortcode name.

* @param array|string $attr Shortcode attributes array or empty string.

* @param array $m Regular expression match array.

*/

$return = apply_filters( 'pre_do_shortcode_tag', false, $tag, $attr, $m );

if ( false !== $return ) {

return $return;

}

$content = isset( $m[5] ) ? $m[5] : null;

$output = $m[1] . call_user_func( $shortcode_tags[ $tag ], $attr, $content, $tag ) . $m[6];

/**

* Filters the output created by a shortcode callback.

*

* @since 4.7.0

*

* @param string $output Shortcode output.

* @param string $tag Shortcode name.

* @param array|string $attr Shortcode attributes array or empty string.

* @param array $m Regular expression match array.

*/

return apply_filters( 'do_shortcode_tag', $output, $tag, $attr, $m );

}

更新日志

Version

描述

2.5.0

Introduced.

相关函数

Uses

wp-includes/shortcodes.php:

pre_do_shortcode_tag

wp-includes/shortcodes.php:

do_shortcode_tag

wp-includes/l10n.php:

__()

wp-includes/functions.php:

_doing_it_wrong()

wp-includes/shortcodes.php:

shortcode_parse_atts()

wp-includes/plugin.php:

apply_filters()

Show 1 more use

Used By

wp-includes/media.php:

get_post_galleries()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值