underpin / block-loader
Block Loader for Underpin
Installs: 119
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 3
pkg:composer/underpin/block-loader
Requires
- underpin/script-loader: ^1.1
- underpin/style-loader: ^1.0
- underpin/underpin: ^2.0
This package is auto-updated.
Last update: 2025-09-24 01:04:35 UTC
README
Loader That assists with adding blocks to a WordPress website.
Installation
Using Composer
composer require underpin/block-loader
Manually
This plugin uses a built-in autoloader, so as long as it is required before Underpin, it should work as-expected.
require_once(__DIR__ . '/underpin-blocks/blocks.php');
Setup
- Install Underpin. See Underpin Docs
- Register new blocks menus as-needed.
Example
A very basic example could look something like this. Note that your block will not display unless registered in Javascript as well.
// Register styles and scripts. underpin()->styles()->add( 'test-style', [/*...*/] ); underpin()->scripts()->add( 'test-script', [/*...*/] ); // Register block underpin()->blocks()->add( 'test', [ 'name' => 'Test Block', 'description' => 'Description for block.', 'type' => underpin()->dir() . 'block.json', // Can be the block ID or a link to a block.json file. See register_block_type 'args' => [], // Optional. See register_block_type ] );
Alternatively, you can extend Block
and reference the extended class directly, like so:
underpin()->blocks()->add('block-key','Namespace\To\Class');