Blocks

PorterWP registers ACF blocks defined under porter/blocks/*/ and glues them into the editor via the blocks.json config.

blocks
└── components
    └── testimonial
        ├── acf-json/           # Field group exported by ACF Sync
        ├── block.json          # WP core block metadata
        ├── init.php            # Optional render_callback
        ├── template.php        # Twig‑like partial used by render callback
        ├── icon.svg            # Editor icon (created by make.sh)
        ├── scss/style.scss     # Block SCSS (compiled → css/style.css)
        └── readme.md

Scaffolding with make.sh

Note: The _block-base/ stub and make.sh script live in the public PorterWP scaffold repository, not inside the premium plugin ZIP. Clone the repo when you need to scaffold a new block.

Run from porter/blocks/:

sh make.sh testimonial components

The script:

  1. Copies _block-base/ stub into components/testimonial.

  2. Replaces placeholders (dummy-name, Dummy_Title, etc.).

  3. Creates the icon.svg from a template so your block has a unique glyph.

Life‑cycle

Phase
Hook

init

Porter_Blocks::register_blocks() registers every folder.

enqueue_block_editor_assets

Injects block‐specific JS/CSS if present.

render_callback

Calls template.php and passes $block + ACF data.


Dynamic Blocks

Add a block name to the dynamic_blocks array in Porter_Config_Block_Styles (defaults to core/query) if its style.css should be rendered server‑side.

Last updated