Search by

concept-image / wp-make-block

concept-image

Acorn commands that scaffold concept-image/wp-blocks ACF blocks (view component, field group, Blade view, block.json, script module) and publish ready-made advanced blocks.

Package info

gitlab.com/concept-image-public/wp-make

Issues

pkg:composer/concept-image/wp-make-block

Statistics

Installs: 268

Dependents: 1

Suggesters: 1

Stars: 0

3.4.2 2026-12-03 16:48 UTC

This package is auto-updated.

Last update: 2026-12-03 15:49:15 UTC


README

WP Make Block

Scaffold ACF blocks for Acorn WordPress themes

Acorn commands for concept-image/wp-blocks themes (Bedrock + Sage), part of the Concept Image stack:

  • make:block: one command generates a block's view component, ACF Composer field group, Tailwind Blade view, block.json and, optionally, a script module;
  • advanced-block: publishes ready-made blocks: an Embla Carousel slider and a team grid.

Requirements

  • PHP 8.3+
  • Roots Acorn 6.1+
  • ACF Pro 6.6+ (blocks use ACF Blocks V3: "acf": {"blockVersion": 3}), log1x/acf-composer 3.4+
  • concept-image/wp-blocks 3+ (generated blocks extend its AcfBlockComponent)
  • concept-image/php-file-editor 0.1 (installed with the package; edits config/blocks.php). Until it is on Packagist, composer.json loads it from a path repository (../php-file-editor): remove that repository once it is published.
  • The core components of concept-image/wp-core-ui (required by wp-starter-theme) published in the theme: the generated views use <x-core.section> and <x-core.heading> (wp acorn core-ui:install; run it again before make:block if core-ui:clean removed them)
  • The generated views use wp-core-ui's components (<x-core.image>, <x-core.wysiwyg>…) and wp-starter-theme's directives (@filled) and Tailwind theme.

Installation

In the theme, as a development dependency:

composer require --dev concept-image/wp-make-block

Creating a block

Run it in the theme, inside the project container:

wp acorn make:block FrontPage/FpHero
GeneratedPath
View component, extends ConceptImage\WpBlocks\View\AcfBlockComponentapp/View/Components/Blocks/FrontPage/FpHero.php
ACF Composer field groupapp/Fields/Blocks/FrontPage/FpHero.php
Blade viewresources/views/components/blocks/front-page/fp-hero.blade.php
block.jsonresources/blocks-json/front-page/fp-hero/block.json
Script module (--script)resources/scripts/src/modules/fp-hero.ts

Options:

  • --script: also creates the script module;
  • --no-register: doesn't touch config/blocks.php, prints the lines to add instead;
  • --force: overwrites existing files. Without it, the command stops when the component exists, and skips any other file that exists (it says which ones);
  • --fields=: ACF fields to add, as comma-separated snake_case slugs (see below). Without it, an interactive run asks for them one by one ("Champ ACF (vide pour terminer)", empty answer to finish); -n or an empty --fields= adds none.

make:block-acf FrontPage/FpHero creates the field group alone (with --force and --fields= too).

ACF fields from their slugs

wp acorn make:block FrontPage/FpHero --fields=title,subtitle,cover_image,is_featured,event_date,items,cta_link -n

Each slug becomes an acf-builder call appended to the field group's add* chain (before its ;), and is added to the component's $fields (a repeater is listed, its sub-fields aren't):

$fpHero
    ->addText('title', [ /* the stub's field, kept */ ])
    ->addText('subtitle', [
        'label' => 'Subtitle',
        'required' => 0,
    ])
    ->addImage('cover_image', [
        'label' => 'Cover image',
        'required' => 0,
    ])
    ->addTrueFalse('is_featured', [ /* … */ ])
    ->addDatePicker('event_date', [ /* … */ ])
    ->addRepeater('items', [
        'label' => 'Éléments',
        'required' => 0,
    ])
    //
    ->endRepeater()
    ->addLink('cta_link', [ /* … */ ]);

The method comes from an is_ / has_ prefix (true/false), then from the exact slug or its suffix after the last _ (compound suffixes first: date_time, button_group, true_false, page_link); anything else is a text field. The label is fixed for an exact name (title → 'Titre'), else the humanized slug (hero_title → 'Hero title').

Names (exact or *_name)MethodFixed label
text / titleaddText'Texte' / 'Titre'
textareaaddTextarea'Texte long'
desc / contentaddWysiwyg'Description' / 'Contenu'
email, mailaddEmail'Email'
number, countaddNumber'Nombre'
image / icon / avatar / thumbnailaddImage'Image' / 'Icône' / 'Avatar' / 'Image mise en avant'
images, galleryaddGallery'Galerie d\'images'
fileaddFile'Fichier'
oembedaddOembed'oEmbed'
rangeaddRange'Range'
select, checkbox, radio, button_groupaddSelect, addCheckbox, addRadio, addButtonGroupcomputed
true_false, bool, boolean, is_*, has_*addTrueFalsecomputed
date_time, datetimeaddDateTimePicker'Date et heure'
date / timeaddDatePicker / addTimePicker'Date' / 'Heure'
page_linkaddPageLink'Lien vers la page'
link / urladdLink / addUrl'Lien' / 'URL'
items, repeateraddRepeater … ->endRepeater()'Éléments'

A slug the field group already uses (the stub's title, sub-fields included) is skipped with a notice. An invalid slug stops the command before anything is written. When a file can't be edited (an overridden stub without Builder::make() and a single return $group->build();, or without $fields = [...]), the code is printed to add by hand. The edits run after generation, so overridden stubs keep working.

The command registers the block in the theme's config/blocks.php. The section is the directory of the name (FrontPage/FpHero → front-page):

'blocks_to_register' => [
    'front-page' => ['fp-hero'],         // the group is created when missing
],
'allowed_block_types' => [
    'front-page' => [/* … */ 'acf/fp-hero'], // the context named after the section, else 'default'
],

Entries already there are left alone, and the comments and layout of the file are kept. When the config is cached (wp acorn config:cache), the cache is cleared. With --no-register, or when the file or one of these arrays is missing, the command prints the lines to add by hand instead.

With --script, load the module from resources/scripts/src/load-modules.ts:

if (document.querySelector('[data-fp-hero]')) {
    (await import('./modules/fp-hero.ts')).default();
}

Naming

The name must be Directory/Block: wp-blocks resolves blocks_to_register['front-page']['fp-hero'] to the class App\View\Components\Blocks\FrontPage\FpHero. Kebab-case (front-page/fp-hero) is accepted.

FrontPage/FpHero
Block typeacf/fp-hero
blocks_to_register keyfront-page
Component $viewNamefront-page.fp-hero
Field groupfp_hero
Component $prefixfp_hero_ (field keys field_fp_hero_{field})

The generated block

  • The component lists the view's fields in $fields (title to start with) and adds computed data in getCustomDatas().
  • The view is wrapped in <x-core.section :anchor="$anchor"> and prints its title with <x-core.heading>: the anchor is sanitized by wp-blocks and printed quoted, and spacing, container and title styles come from the core components (the theme's copies, published by wp-core-ui), so they are changed once for every block. Use <x-core.heading :level="3" size="lg"> rather than heading classes in the view.
  • When you add fields, keep the views safe:
    • WYSIWYG goes through <x-core.wysiwyg>;
    • links are printed with {{ sanitize_url($url) }}, which drops javascript: URLs, and skipped when it returns '';
    • target="_blank" gets rel="noopener".
  • block.json enables anchors and uses a valid dashicon. Change its title, icon and keywords.

Overriding the stubs

Copy a stub from vendor/concept-image/wp-make-block/src/Console/stubs to the theme's stubs/ folder and edit it: block-view-component.stub, block-acf.stub, block-view.stub, block-json.stub, block-script.stub. Keep the placeholders:

  • component: {{ namespace }}, {{ class }}, {{ view }}, {{ prefix }}
  • field group: {{ field }}, {{ builder }}, {{ block }}
  • view and script: {{ name }}, {{ slug }}
  • block.json: {{ name }}

To make every block extend a project class (wp-blocks' optional wp-blocks-component), override block-view-component.stub.

Advanced blocks

wp acorn advanced-block            # choose
wp acorn advanced-block slider
wp acorn advanced-block team

The command publishes the block's files into the theme's app/ and resources/. It keeps files that already exist unless you pass --force, and then registers the block in config/blocks.php like make:block (--no-register to print the lines instead).

BlockTypeContents
slideracf/base-sliderTitle and slides (image, title, optional link). Embla Carousel (loop, drag free) with prev/next buttons, hidden when every slide fits. Tailwind only, no CSS to import.
teamacf/base-teamTitle and members (image, name, job, LinkedIn link, e-mail obfuscated with antispambot()).

The slider needs embla-carousel. The command offers to run npm install embla-carousel in the theme. Use --no-install, or run it without interaction (-n), to skip that; it then prints the command to run. Then add to resources/scripts/src/load-modules.ts:

if (document.querySelector('[data-slider]')) {
    (await import('./modules/slider.ts')).default();
}

Published files belong to the project: package updates don't change them.

Claude Code

Bedrock projects have no Laravel Boost, so the package publishes its AI guidance straight into the Bedrock root, where Claude Code loads it on its own. An agent then creates blocks with make:block ("add a hero block to the front page") and knows the naming rules without reading the package:

  • .claude/skills/wp-make-block/: the wp-make-block skill (commands and options, generated files, registration, naming, stub overrides, advanced blocks, pitfalls);
  • .claude/rules/wp-make-block/: rules loaded by path (wp-make-block.md always; stubs.md for the theme's stubs/).

wp-starter-theme's wp acorn starter:ai publishes them with the other packages' guidance. On their own, or after a package update:

wp acorn vendor:publish --tag=wp-make-block-ai --force      # skill and rules
wp acorn vendor:publish --tag=wp-make-block-skill --force   # skill only (wp-make-block-rules: rules only)

Development

composer ci   # Pint, Larastan (max on src/, level 5 on advanced/), Pest

Without dom, xml and mbstring on the host: docker run --rm -u "$(id -u):$(id -g)" -v "$PWD/..":/work -w /work/wp-make composer:2 composer ci (the parent is mounted for the ../php-file-editor path repository).

Changelog

Please refer to CHANGELOG for more information, including the upgrade from 2.x.

Contributing

Please refer to CONTRIBUTING for more information.

License

Please refer to LICENSE for more information.

Credits