📄 原始资料 | 展开查看原始 JSON(bricks-theme_style_name.json){ “name”: “bricks/theme_style_name”, “kind”: “filter”, “url”: “https://academy.bricksbuilder.io/developer/hooks/filters/bricks-theme_style_name/”, “scraped_at”: “2026-08-29”, “hook_name”: “bricks/theme_style_name”, “description”: { “en”: …
📄 原始资料 | 展开查看原始 JSON(bricks-theme_style_name.json)
{
"name": "bricks/theme_style_name",
"kind": "filter",
"url": "https://academy.bricksbuilder.io/developer/hooks/filters/bricks-theme_style_name/",
"scraped_at": "2026-08-29",
"hook_name": "bricks/theme_style_name",
"description": {
"en": "Filters the name of the Theme Style used when generating the CSS file name. This allows you to sanitize or modify the name before it is used in the file system.",
"zh": "筛选生成 CSS 文件名时使用的主题样式名称。允许你在文件名进入文件系统之前对其进行清理或修改。"
},
"parameters": [
{
"name": "name",
"type": "string",
"type_zh": null,
"description": {
"en": "The theme style name.",
"zh": "主题样式名称。"
}
},
{
"name": "theme_style",
"type": "array",
"type_zh": null,
"description": {
"en": "The theme style data array.",
"zh": "主题样式数据数组。"
}
}
],
"example_usage": "add_filter( 'bricks/theme_style_name', function( $name, $theme_style ) {\n // Example: Prefix theme style file names\n return 'custom-prefix-' . $name;\n}, 10, 2 );"
}
前言
筛选生成 CSS 文件名时使用的主题样式名称。允许你在文件名进入文件系统之前对其进行清理或修改。
用法
将代码加入子主题的 functions.php:
add_filter( 'bricks/theme_style_name', function( $name, $theme_style ) {
// Example: Prefix theme style file names
return 'custom-prefix-' . $name;
}, 10, 2 );
参数
$name (string):主题样式名称。
$theme_style (array):主题样式数据数组。
示例代码
筛选返回值
add_filter( 'bricks/theme_style_name', function( $name, $theme_style ) {
// Example: Prefix theme style file names
return 'custom-prefix-' . $name;
}, 10, 2 );
根据条件短路返回原值
根据条件跳过或修改返回值:
add_filter( 'bricks/theme_style_name', function( $value, $name ) {
if ( is_admin() ) { return $value; }
// TODO: custom logic here
return $value;
} );
补充说明
更多细节可参考 官方文档。