Download the PHP package ralfhortt/wp-block without Composer
On this page you can find all versions of the php package ralfhortt/wp-block. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ralfhortt/wp-block
More information about ralfhortt/wp-block
Files in ralfhortt/wp-block
Package wp-block
Short Description A composer wrapper for registering WordPress blocks.
License GPL-2.0-or-later
Informations about the package wp-block
WP Block
A modern, fluent PHP wrapper for WordPress block development.
Installation
Features
- 🚀 BlockManifest - Register multiple blocks from manifest files
- 🎨 BlockVariations - Create variations of existing blocks
- 🎭 BlockStyles - Manage block styles
- ⚙️ BlockDefaults - Override block attribute defaults with callback support
- 🛠️ BlockSupports - Configure block supports (enable/disable features)
- 📦 BlockManager - Unified management of supports, styles, and variations per block
- 🧩 Block - Custom PHP-rendered blocks
Quick Start
BlockManifest
Register blocks from a manifest file (recommended for modern block development):
BlockDefaults
Override default attribute values with support for dynamic callbacks:
BlockVariations
Create variations of existing blocks:
BlockStyles
Remove unwanted block styles:
Note: For adding styles, use
theme.jsonorblock.jsoninstead.
BlockSupports
Configure block supports (enable/disable block features):
Note: When both adding and removing the same support, removals take precedence.
BlockManager
Manage supports, styles, and variations for a specific block in one place:
Or use fluent chaining for a more compact syntax:
The BlockManager provides direct access to all methods from BlockSupports, BlockStyles, and BlockVariations with a unified fluent interface. Style and variation methods automatically use the managed block name, eliminating redundancy.
Custom Block Class
Create custom PHP-rendered blocks:
API Reference
Block Variation Properties
Each variation supports these properties:
name(required) - Unique identifiertitle- Display name in block inserterdescription- Description textattributes- Default attribute valuesinnerBlocks- Default inner blocks for containersscope- Where variation appears:['inserter'],['block'], or bothisDefault- Set as default variation
See WordPress Block Variations documentation for more details.
Available Hooks
Block Class:
{$blockName}/before- Action before block output{$blockName}/after- Action after block output{$blockName}/render- Filter render callback
WordPress Filters (used internally):
block_type_metadata- Used by BlockDefaults and BlockManifestblock_type_metadata_settings- Used by BlockVariations and BlockStylesget_block_type_variations- Used by BlockVariationsregister_block_type_args- Used by BlockSupports
Development
Requirements
- PHP 8.3 or higher
- Composer
Testing
Code Quality
- PestPHP for testing
- PHPStan (level 8) for static analysis
- GitHub Actions for CI/CD
- Brain\Monkey for WordPress mocking
Changelog
See CHANGELOG.md for version history and migration guides.
License
MIT License - see LICENSE file for details.
Credits
Developed and maintained by Ralf Hortt.