theme_block_pattern_files
云策文档标注
概述
本文档介绍 WordPress 中的 theme_block_pattern_files 过滤器,用于过滤主题的区块模式文件列表。开发者可以通过此 Hook 修改或扩展主题在 patterns 目录中扫描到的文件数组。
关键要点
- theme_block_pattern_files 是一个过滤器,允许开发者修改主题的区块模式文件列表。
- 过滤器接收两个参数:$files(文件数组)和 $dirpath(目录路径)。
- 此过滤器在 WP_Theme::get_block_patterns() 方法中被调用,用于获取主题的区块模式数据。
- 该过滤器从 WordPress 6.8.0 版本开始引入。
原文内容
Filters list of block pattern files for a theme.
Parameters
$filesarray-
Array of theme files found within
patternsdirectory. $dirpathstring-
Path of theme
patternsdirectory being scanned.
Source
$files = apply_filters( 'theme_block_pattern_files', $files, $dirpath );
Changelog
| Version | Description |
|---|---|
| 6.8.0 | Introduced. |