Skip to content

Version 13 to 14

This migration guide contains migration instructions for:

before

if (\class_exists(ManifestCache::class)) {
(new ManifestCache())->setAllCache();
}
if (\class_exists(Main::class)) {
(new Main($loader->getPrefixesPsr4(), __NAMESPACE__))->register();
}

after

if (\class_exists(Main::class) && \class_exists(ManifestCache::class)) {
(new ManifestCache())->setAllCache();
(new Main($loader->getPrefixesPsr4(), __NAMESPACE__))->register();
}

The getViewComponent no longer automatically uses render method, so if it is used in the project you need to render manually. Here are the changes you need to do:

before

protected function getViewComponent(): string
{
return 'admin-theme-options';
}

after

protected function getViewComponent(array $attributes): string
{
return Helpers::render('admin-theme-options', $attributes);
}

classnames helper method is deprecated and should be replaced with clsx, the syntax remains the same.

There are significant changes in the backend on how blocks are registered so you can remove some filters. Here are the changes you need to do:

remove

\add_action('init', [$this, 'getBlocksDataFullRaw'], 10);

You can remove some configuration keys if you are using @infinum/eightshift-frontend-libs package. Here are the changes you should do:

remove

"outputCssGlobally": true,
"outputCssOptimize": true,
"outputCssSelectorName": "esCssVariables",

Abstract functions from AbstractEnqueueAdmin have changed:

before

\add_action('login_enqueue_scripts', [$this, 'enqueueStyles']);
\add_action('admin_enqueue_scripts', [$this, 'enqueueStyles'], 50);
\add_action('admin_enqueue_scripts', [$this, 'enqueueScripts']);

after

\add_action('login_enqueue_scripts', [$this, 'enqueueAdminStyles']);
\add_action('admin_enqueue_scripts', [$this, 'enqueueAdminStyles'], 50);
\add_action('admin_enqueue_scripts', [$this, 'enqueueAdminScripts']);

removed functions:

isEnqueueStylesUsed
isEnqueueScriptsUsed

Abstract functions from AbstractEnqueueTheme have changed:

before

\add_action('wp_enqueue_scripts', [$this, 'enqueueStyles']);
\add_action('wp_enqueue_scripts', [$this, 'enqueueScripts']);

after

\add_action('wp_enqueue_scripts', [$this, 'enqueueThemeStyles']);
\add_action('wp_enqueue_scripts', [$this, 'enqueueThemeScripts']);

removed functions:

isEnqueueStylesUsed
isEnqueueScriptsUsed

Abstract functions from AbstractEnqueueBlocks have changed:

removed functions:

isEnqueueBlockEditorScriptUsed
isEnqueueBlockEditorStyleUsed
isEnqueueBlockStyleUsed
isEnqueueBlockFrontendScriptUsed
isEnqueueBlockFrontendStyleUsed

Every component and block now have $manifest variable available by default.

This means you can remove every instance of $manifest = Helpers::getManifestByDir(__DIR__);

If you have a partial or need to get a manifest above in project file-tree e.g. $manifest = Helpers::getManifestByDir(dirname(__DIR__, 1)); you can replace the method with $manifest = Helpers::getBlock('{block-name}'); for a block or $manifest = Helpers::getComponent('{component-name}'); for a component.

Also if you need global manifest it can be retrieved with getSettings method from Helpers class e.g. $globalManifest = Helpers::getSettings();

PHPStan linter will report errors for the undefined $manifest variable in all the modified files. This can be addressed by adding '#^Variable \$manifest might not be defined\.#' to ignoreErrors attribute of phpstan.neon.dist file.

If you had a Helpers::getProjectPaths('projectRoot') replace it with Helpers::getProjectPaths('root');

Eightshift Frontend Libs repo is now dependant on the @infinum/eightshift-ui-components: 3.0.0+ package. You don’t need to install it but if you are using any kind of Editor components from the @infinum/eightshift-frontend-libs package you need to install it.

All application files are now loaded from the src/Blocks>assets folder. And the assets folder is discontinued. You need to move all your files from the assets folder to the src/Blocks>assets folder or create a manual webpack.config.js configuration for application and applicationAdmin entry points. We strongly recommend using the src/Blocks>assets folder.

webpack.config.js should be renamed to webpack.config.mjs

before

const path = require('path');
module.exports = (env, argv) => {
const projectConfig = {
config: {
projectDir: __dirname, // Current project directory absolute path.
projectPath: 'wp-content/themes/redesign', // Project path relative to project root.
},
};
// Generate Webpack config for this project using options object.
const project = require('@eightshift/frontend-libs/webpack')(argv.mode, projectConfig);
return {
...project,
entry: {
...project.entry,
applicationNoScript: path.join(projectConfig.config.projectDir, '/src/Blocks/assets/application-no-script.js'),
},
};
};

after

import path from 'path';
import { fileURLToPath } from 'url';
import { eightshiftConfig } from '@eightshift/frontend-libs/webpack/index.mjs';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
export default (_, argv) => {
const projectConfig = {
config: {
projectDir: __dirname, // Current project directory absolute path.
projectPath: 'wp-content/themes/redesign', // Project path relative to project root.
},
};
// Generate Webpack config for this project using options object.
const config = eightshiftConfig(argv.mode, projectConfig);
return {
...config,
entry: {
...config.entry,
applicationNoScript: path.join(projectConfig.config.projectDir, '/src/Blocks/assets/application-no-script.js'),
},
};
};