blockstudio
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseBlockstudio
Blockstudio
Expert in building WordPress custom blocks with the Blockstudio PHP-first framework.
精通使用以PHP优先的Blockstudio框架构建WordPress自定义区块。
When to Use
使用场景
- Creating or configuring Blockstudio blocks (+
block.json/ Twig / Blade)index.php - Defining block fields/attributes via the key in
blockstudioblock.json - Setting up global or per-block asset files (,
global-*.css,style.css)script.js - Configuring theme settings
blockstudio.json - Bootstrapping Blockstudio via Composer (,
Build::init())blockstudio() - Working with code-snippet directories (folders without )
block.json - Debugging asset enqueuing, SCSS compilation, or block registration issues
- 创建或配置Blockstudio区块(+
block.json/ Twig / Blade)index.php - 通过中的
block.json键定义区块字段/属性blockstudio - 设置全局或单区块资源文件(、
global-*.css、style.css)script.js - 配置主题设置
blockstudio.json - 通过Composer初始化Blockstudio(、
Build::init())blockstudio() - 处理代码片段目录(无的文件夹)
block.json - 调试资源入队、SCSS编译或区块注册问题
Reference
参考资料
Blockstudio ships an official AI context file () split into documentation and JSON schemas. The references below mirror that split:
/blockstudio-llm.txt| Topic | Reference | Load When |
|---|---|---|
| Framework documentation | | Always — installation, block structure, fields, assets, templates, settings |
| JSON schemas | | When writing or validating |
Blockstudio 附带官方AI上下文文件(),分为文档和JSON架构两部分。以下参考资料与此划分一致:
/blockstudio-llm.txt| 主题 | 参考资料 | 加载场景 |
|---|---|---|
| 框架文档 | | 始终加载 — 安装、区块结构、字段、资源、模板、设置 |
| JSON架构 | | 编写或验证 |
Core Concepts
核心概念
- Block directory: a folder inside containing
blockstudio/(withblock.jsonkey) and a render template ("blockstudio",index.php, orindex.twig)index.blade.php - Code-snippet directory: a folder without ; used for global assets and
block.jsonsnippetsinit.php - Asset convention: → scoped to block;
style.css→ enqueued site-wideglobal-*.css - No build step: Blockstudio handles SCSS compilation and JS bundling automatically based on settings
blockstudio.json - variable: shorthand for block attributes available inside PHP templates
$a
- 区块目录:位于内的文件夹,包含
blockstudio/(带有block.json键)和渲染模板("blockstudio"、index.php或index.twig)index.blade.php - 代码片段目录:不含的文件夹;用于存放全局资源和
block.json代码片段init.php - 资源约定:→ 作用域限定为单个区块;
style.css→ 全站范围入队global-*.css - 无需构建步骤:Blockstudio会根据设置自动处理SCSS编译和JS打包
blockstudio.json - 变量:PHP模板中可用的区块属性的简写形式
$a
Constraints
约束规则
MUST DO
必须遵守
- Always include key in
"blockstudio": {}to opt into Blockstudio discoveryblock.json - Use in PHP templates for proper block support attributes
get_block_wrapper_attributes() - Escape output — use ,
esc_html(),esc_attr()as appropriatewp_kses_post() - Place global assets only in one location to avoid duplicate enqueuing
- 必须在中包含
block.json键,以启用Blockstudio的区块发现功能"blockstudio": {} - 在PHP模板中使用以获取正确的区块支持属性
get_block_wrapper_attributes() - 转义输出 — 按需使用、
esc_html()、esc_attr()函数wp_kses_post() - 全局资源仅放置在一个位置,避免重复入队
MUST NOT DO
禁止操作
- Nest template parts inside subdirectories (WordPress FSE limitation)
parts/
- 禁止将模板片段嵌套在子目录中(WordPress FSE限制)
parts/