Architecture β
How Styble Pro is put together: a dual JavaScript + PHP block system with auto-registration, dynamic rendering, and server-side CSS generation.
Styble Pro is a WordPress Gutenberg blocks plugin built on a hybrid architecture. Every block is defined twice β once in JavaScript (for the editor experience) and once in PHP (for registration and, when needed, server-side rendering). This page gives you the mental model and points you to the deeper developer guides.
Two sides of every block β
| Side | Lives in | Responsibility |
|---|---|---|
| JavaScript | src/blocks/<block-name>/ | Editor UI (edit.jsx), save markup (save.jsx), block registration (index.js), inspector controls, and dynamic editor CSS. |
| PHP | blocks/Types/<Block_Name>/ | Server-side registration, attribute definitions (attributes.php), and render_block() for dynamic blocks. |
Static blocks save their own markup in save.jsx and need no PHP rendering. Dynamic blocks return null from save.jsx and produce their HTML in PHP via render_block().
Directory map β
styble-pro/
βββ styble-pro.php # Main plugin file, defines constants, boots Block_Init
βββ composer.json # PSR-4 autoload: ShapedPlugin\StyblePro\ β blocks/
βββ webpack.config.js # Build config + JS path aliases
βββ gulpfile.js # Standalone SCSS compilation
β
βββ src/ # JavaScript source (built with @wordpress/scripts)
β βββ blocks/ # One folder per block (index.js, edit.jsx, save.jsx, β¦)
β β βββ index.js # Imports + registers every block for the editor
β βββ admin/ # React admin dashboard
β βββ components/ # Shared React components
β βββ controls/ # Inspector controls + constants
β βββ hooks/ # Reusable hooks (e.g. useApiData)
β βββ global-settings/ # Global settings store + sidebar
β βββ icons/ # Block + category icons
β
βββ blocks/ # PHP root β PSR-4 base (ShapedPlugin\StyblePro\)
βββ Block_Init.php # Core bootstrap class
βββ Types/ # One folder per PHP block (class + attributes.php)
βββ Includes/ # Core engine
β βββ AbstractBlock.php # Base class for every PHP block
β βββ Blocks_Register.php # Auto-registers blocks by scanning Types/
β βββ Blocks_Query.php # AJAX query endpoints
β βββ PostQueryHandler.php # WP_Query construction
β βββ AssetManager.php # Script/style registration & enqueueing
β βββ Styles/ # Per-block dynamic CSS classes
β βββ Utils/ # DynamicCssGenerator, Css_Helpers, Transient_Registryβ¦
βββ Attributes/
β βββ CommonAttributes.php # Attributes shared by all blocks
βββ assets/ # Compiled frontend JS/CSS for blocks
βββ languages/ # Translation files (.pot/.po/.mo)PSR-4 autoloading
The blocks/ directory is the root of the ShapedPlugin\StyblePro\ namespace (see composer.json). A class such as ShapedPlugin\StyblePro\Includes\AbstractBlock maps to blocks/Includes/AbstractBlock.php. The constant SP_STYBLE_PATH (defined in styble-pro.php) also points to blocks/.
Registration flow β
Everything starts in styble-pro.php, which defines plugin constants and instantiates Block_Init.
styble-pro.php
ββ Block_Init::instance() blocks/Block_Init.php
ββ init_styble_blocks()
ββ Blocks_Register::instance() blocks/Includes/Blocks_Register.php
β ββ scans blocks/Types/ β instantiates each block class
β ββ new <Block> extends AbstractBlock
β ββ set_block_properties() (block sets its slug etc.)
β ββ load_attributes() (merges Common + per-block)
β ββ register_block() β register_block_type()
ββ Blocks_Query::instance() (AJAX endpoints)
ββ Block_Dynamic_Style::instance()(dynamic CSS engine)
ββ AssetManager::instance() (editor/frontend/dashboard assets)The key moving parts:
Block_Init(blocks/Block_Init.php) wires up registration, queries, dynamic styles, assets, the text domain, and cache clearing onsave_post/deleted_post.Blocks_Register(blocks/Includes/Blocks_Register.php) scans theblocks/Types/directory, converts each folder name to StudlyCase, and instantiates the matching class\ShapedPlugin\StyblePro\Types\<Name>\<Name>.AbstractBlock(blocks/Includes/AbstractBlock.php) is the base class. Its constructor callsset_block_properties(),load_attributes(), andregister_block()in sequence, ending with a call to WordPress'register_block_type().
On the JavaScript side, src/blocks/index.js imports each block folder, which in turn calls a small wrapper (registerStybleBlock) around registerBlockType() to register the block in the editor.
Where to go next β
| Guide | What it covers |
|---|---|
| Creating a Custom Block | Building a block end to end β JS files and the PHP class. |
| Attributes System | CommonAttributes, per-block attributes.php, and the merge flow. |
| Dynamic CSS Generation | DynamicCssGenerator, Css_Helpers, per-block style classes, and caching. |
| Query & AJAX | Blocks_Query, PostQueryHandler, transient caching, and the useApiData hook. |
| Hooks & Internationalization | Filters, actions, and the styble-pro text domain. |
| Build & Assets | npm/gulp/webpack workflow and AssetManager. |
For the end-user perspective on individual blocks, see the User Docs.