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.mdScaffolding with make.sh
make.shNote: The
_block-base/stub andmake.shscript 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 componentsThe script:
Copies
_block-base/stub intocomponents/testimonial.Replaces placeholders (
dummy-name,Dummy_Title, etc.).Creates the icon.svg from a template so your block has a unique glyph.
Life‑cycle
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