I’ve recently released a new package for Rector that allows you to automatically refactor and upgrade your WordPress codebase to the specified version that you want. Currently, it supports up from version 0.71(!) all the way to the latest WordPress 6.4.

It is very easy to get started. If you already incorporate Rector into your workflow, you are already halfway there. If you don’t, then I suggest you to look at [the documentation] for instructions..

The package is available on Packagist, so all you need to do is to install it via Composer:

1
composer require fsylum/rector-wordpress --dev

In your Rector config file, import WordPressSetList for a specific set of WordPress version upgrade. You can also import WordPressLevelSetList to get all the rules cascading from the lowest version. For example using WordPressLevelSetList::UP_TO_WP_6_4 will load all the Rector rules to upgrade your codebase starting from version 0.71 to the latest.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
<?php

use Fsylum\RectorWordPress\Set\WordPressLevelSetList;
use Rector\Config\RectorConfig;

return static function (RectorConfig $rectorConfig): void {
    $rectorConfig->sets([
        WordPressLevelSetList::UP_TO_WP_6_4
    ]);
};

Check the other constants defined in the both WordPressSetList and WordPressLevelSetList for any other versions.

If you have any feedbacks or found any issues, feel free to report it on GitHub.