Deprecated: Function wp_sanitize_script_attributes is deprecated since version 7.0.0! Use wp_get_script_tag() or wp_get_inline_script_tag() instead. in /home/yaronewoni9762/web/hardier-petrel-4cfad5.cloud.newsplicity.com/public_html/wp-includes/functions.php on line 6170

Deprecated: Function wp_sanitize_script_attributes is deprecated since version 7.0.0! Use wp_get_script_tag() or wp_get_inline_script_tag() instead. in /home/yaronewoni9762/web/hardier-petrel-4cfad5.cloud.newsplicity.com/public_html/wp-includes/functions.php on line 6170

WP2 Parts

Overview


Warning: file_exists(): open_basedir restriction in effect. File(/srv/htdocs/wp-content/mu-plugins/wp2-parts/README.md) is not within the allowed path(s): (/mnt/plugin-dev:/home/yaronewoni9762/.composer:/home/yaronewoni9762/web/hardier-petrel-4cfad5.cloud.newsplicity.com/public_html:/home/yaronewoni9762/web/hardier-petrel-4cfad5.cloud.newsplicity.com/private:/home/yaronewoni9762/web/hardier-petrel-4cfad5.cloud.newsplicity.com/public_shtml:/home/yaronewoni9762/tmp:/tmp:/var/www/html:/bin:/usr/bin:/usr/local/bin:/usr/share:/opt) in /home/yaronewoni9762/web/hardier-petrel-4cfad5.cloud.newsplicity.com/public_html/wp-content/mu-plugins/wp2-wiki/src/blocks/readme/init-helpers.php on line 43

A must‑use plugin that turns complex block‑based layouts into maintain‑able, reusable “Parts” with first‑class Block Studio integration.


 Purpose

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.


 Key Features

  • Modular architecture – every block, pattern, or layout lives in its own file under src/.
  • Dynamic Templates – Parts (e.g. wp2-parts/main) register templates that editors pick from a WP2 Layout dropdown added via blockstudio/blocks/meta.
  • Comprehensive layout library – ships with standard WP templates (archive, single, front‑page) plus custom variations (two-columns, full-canvas).
  • Reusable Parts – common site areas (header, footer, main) each have their own controller and dynamic template set.
  • Debug Explorer – an admin panel that surfaces health checks, malformed DB options, and empty layouts.
  • Dev‑friendly – namespaced, ABSPATH‑guarded, snake_case methods, short array syntax, PSR‑12 formatting.

 Directory Map

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)

 How Dynamic Templates Work

  1. Define a Part Place a controller in src/part-<slug>.php that extends Part_Controller.

  2. Return template data Inside the controller, add get_<template_slug>_layout() methods that return an array with label, value, and innerBlocks (PHP tuple format).

  3. Register the provider Call

     Helpers_Controller::register_part_provider(
         Helpers_Controller::WP2_PARTS_MAIN_BLOCK_NAME,
         Main_Pattern_Provider::class
     );
    
  4. Orchestration HelpersController merges all pattern configs (including those added via the wp2_parts_patterns filter or the wp2_parts_dynamic_patterns_options option).

  5. Blockstudio injection On the blockstudio/blocks/meta filter the helper adds a WP2 Layout <select> populated with those templates.

  6. Editor experience Selecting a template inserts the defined innerBlocks instantly.


 Installation

  1. Copy wp2-parts into wp-content/mu-plugins/.
  2. No activation required—MU plugins load automatically.

 Developer Guide

  • New block tweaks – drop an init‑my‑block.php in the right src/blocks/ subfolder.
  • New layout – add an init.php under src/layouts/{template|custom}/my-layout/ that returns a layout array.
  • New Part – create src/parts/my-part/index.php, extend Part_Controller, implement your template methods, then register via register_part_provider().
  • Assets – enqueue from an init‑*.php file and store the files in src/assets/.

 Debug & Troubleshooting

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)

 Roadmap

  • Full i18n wrappers and POT generation
  • PHPUnit test suite

Modules

Plugins

Integrations

Libraries

Preserving and protecting the freedom to use, study, copy, modify, and distribute WordPress.