钩子文档

font_dir

💡 云策文档标注

概述

font_dir 过滤器用于修改字体上传目录的数据,允许开发者自定义字体文件的存储路径和URL。

关键要点

  • font_dir 过滤器允许开发者修改字体目录信息,包括路径、URL等。
  • 参数 $font_dir 是一个数组,包含 path、url、subdir、basedir、baseurl 和 error 等键。
  • 该过滤器在 WordPress 6.5.0 版本中引入,与 _wp_filter_font_directory() 函数相关。

代码示例

return apply_filters( 'font_dir', $font_dir );

注意事项

  • 使用此过滤器时,需确保返回的数组结构正确,以避免字体上传错误。
  • error 键可以设置为 false 或错误消息字符串,用于处理目录创建失败等情况。

📄 原文内容

Filters the fonts directory data.

Description

This filter allows developers to modify the fonts directory data.

Parameters

$font_dirarray
Array of information about the font upload directory.

  • path string
    Base directory and subdirectory or full path to the fonts upload directory.
  • url string
    Base URL and subdirectory or absolute URL to the fonts upload directory.
  • subdir string
    Subdirectory
  • basedir string
    Path without subdir.
  • baseurl string
    URL path without subdir.
  • error string|false
    False or error message.

Source

return apply_filters( 'font_dir', $font_dir );

Changelog

Version Description
6.5.0 Introduced.