A must‑use plugin that turns complex block‑based layouts into maintain‑able, reusable “Parts” with first‑class Block Studio integration.
wp2-parts breaks large page designs into single‑responsibility files (blocks, layouts, patterns, assets). Each Part can expose Dynamic Templates—ready‑made innerBlock structures selectable from the block inspector—so editors build pages faster and stay on brand.
src/.wp2-parts/main) register templates that editors pick from a WP2 Layout dropdown added via blockstudio/blocks/meta.two-columns, full-canvas).Four‑space indentation is used so GitHub renders paths as plain text.
wp2-parts/
README.md
src/
assets/
blocks/ # init‑*.php per namespace/block
layouts/
area/ # WP template part areas
header/
footer/
template/ # WP templates
custom/ # bespoke
parts/
main/
header/
footer/
patterns/ # reusable patterns
panels/debug/
part-helpers.php # HelpersController (orchestrator)
part.php # abstract Part_Controller
init.php # bootstrap (autoloads helpers → parts → layouts)
Define a Part
Place a controller in src/part-<slug>.php that extends Part_Controller.
Return template data
Inside the controller, add get_<template_slug>_layout() methods that return an array with label, value, and innerBlocks (PHP tuple format).
Register the provider Call
Helpers_Controller::register_part_provider(
Helpers_Controller::WP2_PARTS_MAIN_BLOCK_NAME,
Main_Pattern_Provider::class
);
Orchestration
HelpersController merges all pattern configs (including those added via the wp2_parts_patterns filter or the wp2_parts_dynamic_patterns_options option).
Blockstudio injection
On the blockstudio/blocks/meta filter the helper adds a WP2 Layout <select> populated with those templates.
Editor experience
Selecting a template inserts the defined innerBlocks instantly.
wp2-parts into wp-content/mu-plugins/.init‑my‑block.php in the right src/blocks/ subfolder.init.php under src/layouts/{template|custom}/my-layout/ that returns a layout array.src/parts/my-part/index.php, extend Part_Controller, implement your template methods, then register via register_part_provider().init‑*.php file and store the files in src/assets/.Open WP2 Parts → System Explorer (added by panels/debug/) to view:
| Check | What to look for |
|---|---|
| Malformed DB entry | Empty wp2_parts_dynamic_patterns_options['wp2-parts/main'] → delete/fix in DB |
| Empty layout | header-area shows no innerBlocks → update LayoutsAreaHeaderController::get_content() |
| Provider counts | Should list three instantiated providers (main, header, footer) |