Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

Commit 35d1ef3

Browse files
authored
Merge pull request #8 from creode/docs/update
Update migration documentation.
2 parents 18a05c7 + 09c0011 commit 35d1ef3

1 file changed

Lines changed: 47 additions & 35 deletions

File tree

docs/migrating-from-theme-core.md

Lines changed: 47 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Follow the [installation guide](/installation) to install the Creode WordPress T
2424
Using composer, remove the theme core from your project.
2525

2626
```bash
27-
composer remove creode/theme-core
27+
composer remove creode/wordpress-theme-core
2828
```
2929

3030
### 4: Remove the installer path for theme core
@@ -33,43 +33,55 @@ In your composer.json file remove the following line:
3333
```jsonc
3434
{
3535
// ... other composer.json code ...
36-
"extra": { // [!code --]
37-
"installer-paths": { // [!code --]
38-
"wp-content/themes/gibraltar-international-bank/core/": ["type:wordpress-themecore"] // [!code --]
39-
} // [!code --]
40-
} // [!code --]
36+
"extra": { // [!code --]
37+
"installer-paths": { // [!code --]
38+
"wp-content/themes/gibraltar-international-bank/core/": ["type:wordpress-themecore"] // [!code --]
39+
} // [!code --]
40+
} // [!code --]
4141
// ... other composer.json code ...
4242
}
4343
```
4444

45-
### 5: Remove the requirement of the theme-core boot file
45+
### 5: Add the new theme framework to your project
46+
Require the new theme framework into your project.
47+
48+
```bash
49+
composer require creode/wordpress-theme
50+
```
51+
52+
### 6: Add the new mu-plugin to your .gitignore file
53+
Add the following line to your .gitignore file:
54+
55+
`/wp-content/mu-plugins/wordpress-theme*`
56+
57+
### 7: Remove the requirement of the theme-core boot file
4658
Remove the following line from your `functions.php` file.
4759

4860
```php
4961
require_once get_template_directory() . '/core/boot.php'; // [!code --]
5062
```
5163

52-
### 6: Replace class of register_vite_script function
64+
### 8: Replace class of register_vite_script function
5365
The assets class from theme core has been removed and instead is now replaced with a function from the new theme framework.
5466

5567
You will need to replace all occurrences and function calls:
5668
```php
5769
use Creode_Theme\Asset_Enqueue; // [!code ++]
5870

5971
function [[THEME_NAME]]_enqueue_script() {
60-
Assets::register_vite_script( 'header', 'src/components/header.js', array( 'jquery' ), true ); // [!code --]
72+
Assets::register_vite_script( 'header', 'src/components/header.js', array( 'jquery' ), true ); // [!code --]
6173

62-
$asset_enqueue = Asset_Enqueue::get_instance(); // [!code ++]
63-
$asset_enqueue->register_vite_script( 'header', 'src/components/header.js', array( 'jquery' ), true ); // [!code ++]
64-
65-
// ... other required code ...
74+
$asset_enqueue = Asset_Enqueue::get_instance(); // [!code ++]
75+
$asset_enqueue->register_vite_script( 'header', 'src/components/header.js', array( 'jquery' ), true ); // [!code ++]
76+
77+
// ... other required code ...
6678
};
6779
add_action( 'wp_enqueue_scripts', '[[THEME_NAME]]_enqueue_script' );
6880
```
6981

7082
This will now ensure that all JS is loaded from Vite correctly.
7183

72-
### 7: Remove hot reloading from your vite config file.
84+
### 9: Remove hot reloading from your vite config file.
7385
Hot reloading was a feature that was a little buggy on the theme core. It is therefore no longer supported in the new theme framework. There may be plans in future to reintroduce this feature.
7486

7587
In order to remove hot reloading, you will need to remove the following line from your vite config file.
@@ -79,19 +91,19 @@ import { manageHotReloadFile } from './core/js/hot-reload.js'; // [!code --]
7991

8092
export default defineConfig(
8193
(command) => {
82-
manageHotReloadFile(command.mode, DDEV_HOSTNAME, HOT_RELOAD_PORT); // [!code --]
94+
manageHotReloadFile(command.mode, DDEV_HOSTNAME, HOT_RELOAD_PORT); // [!code --]
8395

84-
// ... other vite config code ...
96+
// ... other vite config code ...
8597
}
8698
);
8799
```
88100

89-
### 8: Move your SCSS folder up a level
101+
### 10: Move your SCSS folder up a level
90102
In the previous version of the theme core framework, the SCSS folder was located within the `src` folder. As part of this migration, you will need to move the SCSS folder up a level to the root of the project. The `SCSS` folder should now be located in the root of the theme.
91103

92104
For example if you had a `src/scss` folder in the theme, it should now be moved to the root of the theme to `scss/`.
93105

94-
### 9: Migrate the component specific CSS files up to the component directory
106+
### 11: Migrate the component specific CSS files up to the component directory
95107
As part of the changes to how blocks are handled, the SCSS files for each block should now be moved to their relevant block folder.
96108

97109
For example a header.scss component file will now be located in the following folder based on the theme root: `/blocks/header-block/assets/header.scss`.
@@ -100,17 +112,12 @@ Each of these components should be moved to their relevant block folder.
100112

101113
This is a change that will need to be done manually and can be quite tedious however it will ensure that all themes and blocks are kept consistent in the future.
102114

103-
### 10: Remove individual components imports from the `admin.scss` and `main.scss` files
115+
### 12: Remove individual components imports from the `admin.scss` and `main.scss` files
104116
As part of the changes to how blocks are handled, the individual components `@use` and `@include` from the `admin.scss` and `main.scss` files are no longer required. These are now handled by the theme framework and will be automatically added to the theme in a new `blocks/_all.scss` file.
105117

106118
This is a change that will need to be done manually and can be quite tedious however it will ensure that all themes and blocks are kept consistent in the future.
107119

108-
You can recompile the assets to check over your changes periodically during this process by running the following WP CLI command:
109-
```bash
110-
wp creode-theme:build
111-
```
112-
113-
### 11: Clean up scss import paths
120+
### 13: Clean up scss import paths
114121
After moving the SCSS files to their relevant block folder, you will need to clean up the `@use` paths for each of the SCSS files. Paths to scss files in vite can be absolute based on where the `vite.config.js` file is located. In this case it will be in the theme.
115122

116123
An example of this is demonstrated below with pulling the global file into the `header.scss` file:
@@ -122,29 +129,34 @@ An example of this is demonstrated below with pulling the global file into the `
122129

123130
This change can be quite tedious to do manually however we want to ensure that all themes keep the same structure and paths so a change like this will help our projects stay consistent in the future.
124131

125-
### 12: Run the script to install any framework files and compile assets
132+
### 14: Run the script to install any framework files and compile assets
126133
As part of the theme framework, there is a WordPress CLI command that will install any missing files and compile the assets. This ensures that the structure of the theme is kept consistent and that new files as part of the boilerplate can be added automatically to themes without having to keep track of them manually.
127134

128-
### 13: Remove the admin and main js files from src
129-
As part of the framework, the main.js and admin.js within the `src` folder are no longer required. These are now handled by the theme framework and will be automatically added to the theme in a new `vite-entry-points` folder. These files are no longer required and can be removed from the `src` folder, if there is more content to them, ensure this is now merged with the newly created equivalent files in the `vite-entry-points` folder.
135+
```bash
136+
wp creode-theme:install
137+
```
138+
139+
You should now be able to see some new files in your theme alongside a new `vite-entry-points` folder with the new admin.js and main.js files. You should copy the contents of the `src/main.js` and `src/admin.js` files into the corresponding new `vite-entry-points` folder, apart from the import lines for scss as these should be updated to the new new `/scss/` folder.
140+
141+
Once this has been done, you can remove the old `src/main.js` and `src/admin.js` files from your theme.
130142

131-
### 14: Update the vite config file to switch these entrypoints over
143+
### 15: Update the vite config file to switch these entrypoints over
132144
The `vite.config.js` file will need to be updated to switch these entrypoints over to the new `vite-entry-points` folder.
133145

134146
```js
135147
export default defineConfig(
136148
(command) => {
137149
return {
138-
// ... other vite config code ...
150+
// ... other vite config code ...
139151
build: {
140152
rollupOptions: {
141153
// overwrite default .html entry
142154
input: {
143-
main: resolve(__dirname, 'src/main.js'), // [!code --]
155+
main: resolve(__dirname, 'src/main.js'), // [!code --]
144156
admin: resolve(__dirname, 'src/admin.js'), // [!code --]
145-
main: resolve(__dirname, 'vite-entry-points/main.js'), // [!code ++]
157+
main: resolve(__dirname, 'vite-entry-points/main.js'), // [!code ++]
146158
admin: resolve(__dirname, 'vite-entry-points/admin.js'), // [!code ++]
147-
// ... other vite config code ...
159+
// ... other vite config code ...
148160
}
149161
}
150162
}
@@ -175,7 +187,7 @@ Add the following to the top of the `main.scss` file:
175187

176188
This will ensure that all blocks are loaded into the theme.
177189

178-
### 16: Import the new `blocks/_all.scss` file into the admin.scss file
190+
### 17: Import the new `blocks/_all.scss` file into the admin.scss file
179191
This process is very similar to the `main.scss` file however you will need to ensure that any admin specific mixins are handled manually using the new folder location. The new blocks all file only handle the render mixin and admin ones will need to be handled manually. See the below example for how this has changed:
180192

181193
```scss
@@ -206,7 +218,7 @@ Add the following to the `admin.scss` file:
206218
@include blocks.render; // [!code ++]
207219
```
208220

209-
### 17: Recompile the assets
221+
### 18: Recompile the assets
210222
Once these steps have been completed, you will need to recompile the assets. This can be done by running the following WP CLI command:
211223

212224
```bash

0 commit comments

Comments
 (0)