kokiddp/carbon-fields-innerblocks
最新稳定版本:v0.1
Composer 安装命令:
composer require kokiddp/carbon-fields-innerblocks
包简介
Adds InnerBlocks support to Carbon Fields blocks.
README 文档
README
This is a Composer package that extends Carbon Fields to support InnerBlocks inside Gutenberg blocks.
Features
- Gutenberg
InnerBlocksintegration - Support for multiple innerblock fields per block
- Unlimited nested innerblocks
- Configurable attributes:
allowed_blocks()template()template_lock()orientation()
- Prevents use outside Gutenberg (e.g. options pages)
Installation
composer require kokiddp/carbon-fields-innerblocks
The field will be automatically registered when the package is autoloaded by Composer.
Usage Example
use Carbon_Fields\Block; use Carbon_Fields\Field; Block::make('Content Block') ->add_fields([ Field::make('text', 'section_title', 'Section Title'), Field::make('innerblock', 'main_content', 'Main Content') ->set_allowed_blocks(['core/paragraph', 'core/image']) ->set_template([ ['core/paragraph', ['placeholder' => 'Start typing...']] ]) ->set_template_lock(false) ->set_orientation('vertical'), Field::make('innerblock', 'sidebar_content', 'Sidebar Content') ]) ->set_render_callback(function ($fields, $attributes, $inner_blocks) { echo '<div class="my-block">'; echo '<h2>' . esc_html($fields['section_title']) . '</h2>'; echo '<div class="main">' . $inner_blocks . '</div>'; echo '<div class="sidebar">' . $inner_blocks . '</div>'; echo '</div>'; });
Limitations
- This field only works inside Gutenberg block contexts
- It will log an error and render nothing if used in options, users, terms, etc.
License
MIT © Gabriele Coquillard
统计信息
- 总下载量: 14
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0
- 更新时间: 2025-07-16