kokiddp/carbon-fields-innerblocks 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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 InnerBlocks integration
  • 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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0
  • 更新时间: 2025-07-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固