This package contains a mirror of multiple versions of Gutenberg plugin, in different sub-folders. This allows to contemporarily deploy multiple versions of Gutenberg to WordPress, and let different themes (for example) require different versions.
The wp.org API is called regularly in a GitHub Action to find new Gutenberg versions.
If new versions are found, they are saved, each in a separate folder.
A utility class shipped with the package allows external code to require Gutenberg in the desired version.
- Require via Composer.
- Ensure Composer autoload is loaded.
- From a MU plugin require the version you need in one of the following ways
/** @var string|null $loadedVersion The exact version loaded or null on failure */
$loadedVersion = Inpsyde\GutenbergVersions\Loader::loadVersion('14.1.0');
/** @var string|null $loadedVersion The exact version loaded or null on failure */
$loadedVersion = Inpsyde\GutenbergVersions\Loader::loadVersion('14.1.0', '13.2.0');
/** @var string|null $loadedVersion The exact version loaded or null on failure */
$loadedVersion = Inpsyde\GutenbergVersions\Loader::loadMatching('^14');
$loadedVersion = Inpsyde\GutenbergVersions\Loader::loadMatching('>=14.2.0 || ~13.2');
Gutenberg internally calls plugins_url()
with the assumption it is installed under the plugins' folder.
However, when using this library, Gutenberg files are deeper in the plugin folder tree.
To fix broken URLs resulting from that, when loading a Gutenberg version, the package also filters
plugins_url()
.
The package ensures that any attempt of loading Gutenberg multiple times (same of different version) will fail.
This repository is a free software, and is released under the terms of the GNU General Public License version 2 or (at your option) any later version. See LICENSE for complete license.