钩子文档

wp_video_shortcode_override

💡 云策文档标注

概述

wp_video_shortcode_override 是一个 WordPress 过滤器,用于覆盖默认的视频短码输出。如果过滤后的输出非空,将替代默认模板生成。

关键要点

  • 这是一个过滤器,允许开发者自定义视频短码的 HTML 输出。
  • 当过滤器返回非空字符串时,将跳过默认的 wp_video_shortcode() 处理。
  • 参数包括 $html(空字符串)、$attr(短码属性数组)、$content(短码内容)和 $instance(唯一实例 ID)。
  • 常用于高级主题或插件开发,以修改视频嵌入行为。

代码示例

$override = apply_filters( 'wp_video_shortcode_override', '', $attr, $content, $instance );

注意事项

  • 确保过滤器返回有效的 HTML 字符串,否则可能破坏视频显示。
  • 参考 wp_video_shortcode() 函数以了解默认行为和属性。
  • 此过滤器自 WordPress 3.6.0 版本引入。

📄 原文内容

Filters the default video shortcode output.

Description

If the filtered output isn’t empty, it will be used instead of generating the default video template.

See also

Parameters

$htmlstring
Empty variable to be replaced with shortcode markup.
$attrarray
Attributes of the shortcode. See wp_video_shortcode().
$contentstring
Video shortcode content.
$instanceint
Unique numeric ID of this video shortcode instance.

Source

$override = apply_filters( 'wp_video_shortcode_override', '', $attr, $content, $instance );

Changelog

Version Description
3.6.0 Introduced.