Skip to content

Upgrading from 0.x to 1.x

Changes

Changes to the block class

As part of the upgrade to 1.x of the block plugin, the base block class now includes the Trait_Has_Modifier_Classes trait. This trait is used to add modifier classes to the block.

This change breaks existing blocks due to the requirement of a new default-wrapper.php template for blocks. In order to upgrade, you will need to add the following function declaration to any existing block classes created prior to 1.x:

php
/**
 * {@inheritdoc}
 */
protected function use_default_wrapper_template(): bool {
    return false;
}

This ensures that the block will not use the default wrapper template.

Rector ruleset

You can find the Rector setup instructions for this plugin here.

For version 1.x of the block plugin, you can use the following command to upgrade your blocks, take specific note of the {theme-name} placeholder which should be replaced with the name of your WordPress theme:

bash
vendor/bin/rector process wp-content/themes/{theme-name} --config=vendor/creode/wordpress-blocks-rector/config/blocks-1-0-0.php