WP Rig excels at providing pre-configured structures, but its true power lies in its modular extensibility. In this lesson, we will explore generating custom OOP PHP components and developing modern, zero-JS custom Gutenberg blocks.
1. Generating Custom PHP Components
Every core feature in WP Rig (Styles, Fonts, sidebars, Menus) is organized into a modular **Component** class under `inc/`.
To create a new custom PHP feature (for example, registering a custom post type or third-party API tracker), do not write procedural code in `functions.php`. Instead, generate a new component!
Generate via CLI
“`php namespace WP_RigWP_RigMy_Tracker;
use WP_RigWP_RigComponent_Interface;
class Component implements Component_Interface { public function get_slug(): string { return ‘my-tracker’; } public function initialize(): void { add_action( ‘init’, array( $this, ‘register_hooks’ ) ); } public function register_hooks(): void { // Your OOP Hook Logic Here } } “`
WP Rigβs core theme bootstrap automatically registers this class on boot, keeping your theme modular, organized, and trace-friendly!
2. Developing Custom Blocks
WP Rig includes a built-in block scaffolding engine that makes block development extremely simple.
Traditional React-based Block
WordPress 7.0 PHP-Only Block (Zero JS)
3. Server-Side Block Manifest Compilation
Registering blocks individually via filesystem directory scanning can degrade site speeds on every page hit. To optimize performance, WP Rig v3 uses a pre-compiled **Block Manifest** (`assets/blocks/blocks-manifest.php`).
When you compile your blocks: “`bash npm run build:blocks “` WP Rig scans all configurations and writes them into a unified, memory-cacheable PHP array, loading custom blocks near-instantaneously!
In our final lesson, we will master the layered configuration parameters and tokens to customize your theme designs!