humanmade / rehydrator
Pattern-based content transformation for WordPress block migrations
Package info
github.com/humanmade/rehydrator
Type:wordpress-plugin
pkg:composer/humanmade/rehydrator
v1.0.0
2026-03-18 20:55 UTC
Requires
- php: >=8.0
Requires (Dev)
- humanmade/coding-standards: v2.x-dev
- phpunit/phpunit: ^9.5
- yoast/phpunit-polyfills: ^2.0
README
Pattern-based content transformation for WordPress block migrations. Provides utilities for loading block patterns, resolving nested pattern references, and applying targeted transformations to populate templates with content.
Installation
Via Composer:
composer require humanmade/rehydrator
As a WordPress plugin: Clone or download this repository to wp-content/plugins/ and activate.
Requirements
- PHP 8.0+
- WordPress 6.0+
Quick Start
use HM\Rehydrator\Template; $transformer = new Template( 'theme/template-article' ); $content = $transformer ->replace_text( 'theme/hero', 'core/heading', occurrence: 0, text: $title ) ->replace_text( 'theme/hero', 'core/paragraph', occurrence: 0, text: $standfirst ) ->replace_attributes( 'theme/hero', 'core/image', occurrence: 0, attrs: [ 'id' => $image_id, 'url' => $image_url, ] ) ->replace_placeholder( 'content-placeholder', $body_blocks ) ->get_content(); wp_update_post( [ 'ID' => $post_id, 'post_content' => $content, ] );
For full API documentation including all transformation methods and helper namespaces, see the docs site.
Development
Running Tests
composer install
composer test
Code Style
composer lint
License
GPL-2.0-or-later