Migrate pre Gutenberg contents to Gutenberg blocks.
- Extendable for different migration sources and destinations
- Restore from backups
- cli integration
- Migration analysis: Which contents will be affected and why
The first and until now only migration path is ShortcodesMigration
. You can migrate any shortcode to some other content structure like a gutenberg block.
This migration path can be used for:
- WPBakery Page Builder
The transformation of a shortcode to something different is handle by classes that implement the ShortcodeTransformation
interface. Abstract class AbsShortcodeTransformation
or AbsBlockXTransformation
can be extended.
vc_column_text
will be transformed to gutenberg paragraph block.
vc_column
, vc_column_inner
, vc_row_inner
, vc_row
will be transformed to gutenberg groups. (
vc_single_image
will be transformed to gutenberg image block.
For any shortcode transformation to whatever.
class MyTransformation implements \Palasthotel\WordPress\MigrateToGutenberg\Interfaces\ShortcodeTransformation {
function tag() : string{
return "my-shortcode";
}
function transform($attrs,string $content) : string{
return "<!-- wp:my/shortcode /-->";
}
}
For shortcodes that should stay shortcodes with the shortcode gutenberg block.
class MyShortcodeTransformation extends \Palasthotel\WordPress\MigrateToGutenberg\Transformations\AbsShortcodeTransformation {
function tag() : string{
return "my-block-shortcode";
}
}
This will append all shortcode attributes to BlockX content attributes and create a block with the give blockId.
class MyBlockXTransformation extends \Palasthotel\WordPress\MigrateToGutenberg\Transformations\AbsBlockXTransformation {
function tag() : string{
return "my-simple-shortcode";
}
function blockId() : \Palasthotel\WordPress\BlockX\Model\BlockId{
return \Palasthotel\WordPress\BlockX\Model\BlockId::build("my", "simple-block");
}
}
Add a new transformation to shortcode migration by using the filter in 'plugins_loaded' action.
add_filter(\Palasthotel\WordPress\MigrateToGutenberg\Plugin::FILTER_SHORTCODE_TRANSFORMATIONS, function($transformations){
return array_merge(
$transformations,
[
new MyTransformation(),
new MyShortcodeTransformation(),
new MyBlockXTransformation(),
]
);
});