blockstudio

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Blockstudio

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
    +
    index.php
    / Twig / Blade)
  • Defining block fields/attributes via the
    blockstudio
    key in
    block.json
  • Setting up global or per-block asset files (
    global-*.css
    ,
    style.css
    ,
    script.js
    )
  • Configuring
    blockstudio.json
    theme settings
  • 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
    +
    index.php
    / Twig / Blade)
  • 通过
    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 (
/blockstudio-llm.txt
) split into documentation and JSON schemas. The references below mirror that split:
TopicReferenceLoad When
Framework documentation
references/documentation.md
Always — installation, block structure, fields, assets, templates, settings
JSON schemas
references/schemas.md
When writing or validating
block.json
,
blockstudio.json
,
page.json
Blockstudio 附带官方AI上下文文件(
/blockstudio-llm.txt
),分为文档和JSON架构两部分。以下参考资料与此划分一致:
主题参考资料加载场景
框架文档
references/documentation.md
始终加载 — 安装、区块结构、字段、资源、模板、设置
JSON架构
references/schemas.md
编写或验证
block.json
blockstudio.json
page.json
时加载

Core Concepts

核心概念

  • Block directory: a folder inside
    blockstudio/
    containing
    block.json
    (with
    "blockstudio"
    key) and a render template (
    index.php
    ,
    index.twig
    , or
    index.blade.php
    )
  • Code-snippet directory: a folder without
    block.json
    ; used for global assets and
    init.php
    snippets
  • Asset convention:
    style.css
    → scoped to block;
    global-*.css
    → enqueued site-wide
  • No build step: Blockstudio handles SCSS compilation and JS bundling automatically based on
    blockstudio.json
    settings
  • $a
    variable
    : shorthand for block attributes available inside PHP templates
  • 区块目录:位于
    blockstudio/
    内的文件夹,包含
    block.json
    (带有
    "blockstudio"
    键)和渲染模板(
    index.php
    index.twig
    index.blade.php
  • 代码片段目录:不含
    block.json
    的文件夹;用于存放全局资源和
    init.php
    代码片段
  • 资源约定
    style.css
    → 作用域限定为单个区块;
    global-*.css
    → 全站范围入队
  • 无需构建步骤:Blockstudio会根据
    blockstudio.json
    设置自动处理SCSS编译和JS打包
  • $a
    变量
    :PHP模板中可用的区块属性的简写形式

Constraints

约束规则

MUST DO

必须遵守

  • Always include
    "blockstudio": {}
    key in
    block.json
    to opt into Blockstudio discovery
  • Use
    get_block_wrapper_attributes()
    in PHP templates for proper block support attributes
  • Escape output — use
    esc_html()
    ,
    esc_attr()
    ,
    wp_kses_post()
    as appropriate
  • 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
    parts/
    subdirectories (WordPress FSE limitation)
  • 禁止将模板片段嵌套在
    parts/
    子目录中(WordPress FSE限制)