钩子文档

pre_do_shortcode_tag

💡 云策文档标注

概述

pre_do_shortcode_tag 是一个 WordPress 过滤器,用于控制是否调用短代码回调函数。通过返回非 false 值,可以绕过短代码的正常处理流程,直接输出自定义内容。

关键要点

  • 过滤器名称:pre_do_shortcode_tag
  • 作用:过滤是否执行短代码回调,返回非 false 值可短路处理
  • 参数:$output(false 或替换值)、$tag(短代码名称)、$attr(属性数组)、$m(正则匹配数组)
  • 相关函数:do_shortcode_tag()
  • 版本变化:6.5.0 中 $attr 始终为数组,4.7.0 引入

📄 原文内容

Filters whether to call a shortcode callback.

Description

Returning a non-false value from filter will short-circuit the shortcode generation process, returning that value instead.

Parameters

$outputfalse|string
Short-circuit return value. Either false or the value to replace the shortcode with.
$tagstring
Shortcode name.
$attrarray
Shortcode attributes array, can be empty if the original arguments string cannot be parsed.
$marray
Regular expression match array.

Source

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

Changelog

Version Description
6.5.0 The $attr parameter is always an array.
4.7.0 Introduced.