钩子文档

load_script_textdomain_relative_path

💡 云策文档标注

概述

本文档介绍了 WordPress 中的 load_script_textdomain_relative_path 过滤器,用于过滤脚本的相对路径以定位翻译文件。开发者可以通过此 Hook 自定义脚本的路径解析。

关键要点

  • load_script_textdomain_relative_path 是一个过滤器,用于修改脚本的相对路径,以便正确加载翻译文件。
  • 该过滤器接受两个参数:$relative(脚本的相对路径,可能为 false)和 $src(脚本的完整源 URL)。
  • 在 WordPress 5.0.2 版本中引入,主要用于 load_script_textdomain() 函数中。

代码示例

$relative = apply_filters( 'load_script_textdomain_relative_path', $relative, $src );

📄 原文内容

Filters the relative path of scripts used for finding translation files.

Parameters

$relativestring|false
The relative path of the script. False if it could not be determined.
$srcstring
The full source URL of the script.

Source

$relative = apply_filters( 'load_script_textdomain_relative_path', $relative, $src );

Changelog

Version Description
5.0.2 Introduced.