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

Commit 80821ef

Browse files
authored
Merge pull request #2 from creode/add_documentation
Add documentation
2 parents acb8a36 + c268158 commit 80821ef

9 files changed

Lines changed: 373 additions & 0 deletions

File tree

.github/workflows/deploy-docs.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Sample workflow for building and deploying a VitePress site to GitHub Pages
2+
#
3+
name: Deploy VitePress site to Pages
4+
5+
on:
6+
# Runs on pushes targeting the `main` branch. Change this to `master` if you're
7+
# using the `master` branch as the default branch.
8+
push:
9+
branches: [main]
10+
11+
# Allows you to run this workflow manually from the Actions tab
12+
workflow_dispatch:
13+
14+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
15+
permissions:
16+
contents: read
17+
pages: write
18+
id-token: write
19+
20+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
21+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
22+
concurrency:
23+
group: pages
24+
cancel-in-progress: false
25+
26+
jobs:
27+
# Build job
28+
build:
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v4
33+
with:
34+
fetch-depth: 0 # Not needed if lastUpdated is not enabled
35+
# - uses: pnpm/action-setup@v3 # Uncomment this block if you're using pnpm
36+
# with:
37+
# version: 9 # Not needed if you've set "packageManager" in package.json
38+
# - uses: oven-sh/setup-bun@v1 # Uncomment this if you're using Bun
39+
- name: Setup Node
40+
uses: actions/setup-node@v4
41+
with:
42+
node-version: 22
43+
cache: npm # or pnpm / yarn
44+
- name: Setup Pages
45+
uses: actions/configure-pages@v4
46+
- name: Install dependencies
47+
run: npm ci # or pnpm install / yarn install / bun install
48+
- name: Build with VitePress
49+
run: npm run docs:build # or pnpm docs:build / yarn docs:build / bun run docs:build
50+
- name: Upload artifact
51+
uses: actions/upload-pages-artifact@v3
52+
with:
53+
path: docs/.vitepress/dist
54+
55+
# Deployment job
56+
deploy:
57+
environment:
58+
name: github-pages
59+
url: ${{ steps.deployment.outputs.page_url }}
60+
needs: build
61+
runs-on: ubuntu-latest
62+
name: Deploy
63+
steps:
64+
- name: Deploy to GitHub Pages
65+
id: deployment
66+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1+
# Composer Dependencies
12
/vendor
23
/composer.lock
4+
5+
# Node Dependencies
6+
/package-lock.json
7+
node_modules

docs/.vitepress/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
cache/*
2+
dist/*

docs/.vitepress/config.mts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { defineConfig } from 'vitepress'
2+
3+
// https://vitepress.dev/reference/site-config
4+
export default defineConfig({
5+
title: "WordPress Theme Framework - Documentation",
6+
description: "Documentation for Creode's WordPress Theme Framework.",
7+
themeConfig: {
8+
// https://vitepress.dev/reference/default-theme-config
9+
nav: [
10+
{ text: 'Home', link: '/' },
11+
{ text: 'Installation', link: '/installation' },
12+
],
13+
14+
sidebar: [
15+
{
16+
text: 'Setup',
17+
items: [
18+
{ text: 'Introduction', link: '/' },
19+
{ text: 'Installation', link: '/installation' },
20+
{ text: 'Migrating from Theme Core', link: '/migrating-from-theme-core' }
21+
]
22+
},
23+
{
24+
text: 'Commands',
25+
items: [
26+
{ text: 'Commands', link: '/commands' }
27+
]
28+
}
29+
],
30+
31+
socialLinks: [
32+
{ icon: 'github', link: 'https://github.com/vuejs/vitepress' }
33+
]
34+
}
35+
})

docs/commands.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Commands
2+
This plugin comes with a number of commands to help you manage your theme.
3+
4+
## `wp creode-theme:install`
5+
Installs the Creode WordPress Framework files into your active theme (or a theme of your choice).
6+
7+
## `wp creode-theme:build`
8+
Builds the assets for all active themes (or a theme of your choice).

docs/index.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
outline: deep
3+
---
4+
5+
# Introduction
6+
This project is a simple WordPress plugin containing the Creode WordPress Theme Framework.
7+
8+
## Plugin Features
9+
This plugin provides a simple way to install the Creode WordPress Theme Framework. It contains functionality that will allow for the simple compilation and handling of assets. It can facilitate the following:
10+
11+
- Installation of the Creode WordPress Theme Framework
12+
- Compilation of assets
13+
- Providing a simple way to keep track of theme framework files and give a single location to manage SCSS and theme related files.
14+
- Allow the sharing of new theme files and systems across multiple themes.
15+
16+
## Commands
17+
This plugin provides a number of commands. These are associated with the syncronisation of theme framework files and the compilation of assets. You can find more details on these commands in the [commands](/commands) section.
18+
19+
## Upgrades from Theme Core
20+
The theme core was a small framework that initially handled the compilation of assets and the enqueueing of scripts and styles. It was a small framework that was not designed to be used as a base for themes. Details of this can be found in the [repository](https://github.com/creode/wordpress-theme-core).
21+
22+
This package is designed to replace the theme core and provide a more robust framework for themes.
23+
24+
A guide on upgrading your theme from the theme core to the new framework can be found in the [migrating from theme core](/migrating-from-theme-core) section.

docs/installation.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
outline: deep
3+
---
4+
5+
# Installation
6+
7+
## Composer (recommended)
8+
Installing the plugin via composer will automatically create the loader for you and add to the mu-plugins directory of your WordPress installation. Ensure your composer paths are set correctly for your WordPress installation.
9+
10+
```bash
11+
composer require creode/wordpress-theme
12+
```
13+
14+
## Manual
15+
16+
1. Download the plugin from the [Creode WordPress Theme Framework GitHub repository](https://github.com/creode/wordpress-theme).
17+
2. Upload the plugin to your WordPress mu-plugins directory.
18+
3. Create the loader (steps to follow #TODO).
19+
3. Activate the plugin.

docs/migrating-from-theme-core.md

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
---
2+
outline: deep
3+
---
4+
5+
# Migrating from Theme Core
6+
7+
## Introduction
8+
This guide will walk you through the process of migrating from the [theme core repository](https://github.com/creode/wordpress-theme-core) to the new framework.
9+
10+
## Upgrade Steps
11+
12+
### 1: Ensure you have all composer packages updated
13+
Run the following command to ensure you have all the latest packages installed.
14+
15+
```bash
16+
composer update
17+
```
18+
19+
### 2: Install the Creode WordPress Theme Framework
20+
21+
Follow the [installation guide](/installation) to install the Creode WordPress Theme Framework.
22+
23+
### 3: Remove the theme core from your project
24+
Using composer, remove the theme core from your project.
25+
26+
```bash
27+
composer remove creode/theme-core
28+
```
29+
30+
### 4: Remove the requirement of the theme-core boot file
31+
Remove the following line from your `functions.php` file.
32+
33+
```php
34+
require_once get_template_directory() . '/core/boot.php'; // [!code --]
35+
```
36+
37+
### 5: Replace class of register_vite_script function
38+
The assets class from theme core has been removed and instead is now replaced with a function from the new theme framework.
39+
40+
You will need to replace all occurrences and function calls:
41+
```php
42+
use Creode_Theme\Asset_Enqueue; // [!code ++]
43+
44+
function [[THEME_NAME]]_enqueue_script() {
45+
Assets::register_vite_script( 'header', 'src/components/header.js', array( 'jquery' ), true ); // [!code --]
46+
47+
$asset_enqueue = Asset_Enqueue::get_instance(); // [!code ++]
48+
$asset_enqueue->register_vite_script( 'header', 'src/components/header.js', array( 'jquery' ), true ); // [!code ++]
49+
50+
// ... other required code ...
51+
};
52+
add_action( 'wp_enqueue_scripts', '[[THEME_NAME]]_enqueue_script' );
53+
```
54+
55+
This will now ensure that all JS is loaded from Vite correctly.
56+
57+
### 6: Remove hot reloading from your vite config file.
58+
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.
59+
60+
In order to remove hot reloading, you will need to remove the following line from your vite config file.
61+
62+
```js
63+
import { manageHotReloadFile } from './core/js/hot-reload.js'; // [!code --]
64+
65+
export default defineConfig(
66+
(command) => {
67+
manageHotReloadFile(command.mode, DDEV_HOSTNAME, HOT_RELOAD_PORT); // [!code --]
68+
69+
// ... other vite config code ...
70+
}
71+
);
72+
```
73+
74+
### 7: Move your SCSS folder up a level
75+
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.
76+
77+
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/`.
78+
79+
### 8: Migrate the component specific CSS files up to the component directory
80+
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.
81+
82+
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`.
83+
84+
Each of these components should be moved to their relevant block folder.
85+
86+
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.
87+
88+
### 9: Remove individual components imports from the `admin.scss` and `main.scss` files
89+
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.
90+
91+
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.
92+
93+
You can recompile the assets to check over your changes periodically during this process by running the following WP CLI command:
94+
```bash
95+
wp creode-theme:build
96+
```
97+
98+
### 10: Clean up scss import paths
99+
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.
100+
101+
An example of this is demonstrated below with pulling the global file into the `header.scss` file:
102+
103+
```scss
104+
@use "../globals"; // [!code --]
105+
@use "/scss/globals"; // [!code ++]
106+
```
107+
108+
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.
109+
110+
### 11: Run the script to install any framework files and compile assets
111+
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.
112+
113+
### 12: Remove the admin and main js files from src
114+
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.
115+
116+
### 13: Update the vite config file to switch these entrypoints over
117+
The `vite.config.js` file will need to be updated to switch these entrypoints over to the new `vite-entry-points` folder.
118+
119+
```js
120+
export default defineConfig(
121+
(command) => {
122+
return {
123+
// ... other vite config code ...
124+
build: {
125+
rollupOptions: {
126+
// overwrite default .html entry
127+
input: {
128+
main: resolve(__dirname, 'src/main.js'), // [!code --]
129+
admin: resolve(__dirname, 'src/admin.js'), // [!code --]
130+
main: resolve(__dirname, 'vite-entry-points/main.js'), // [!code ++]
131+
admin: resolve(__dirname, 'vite-entry-points/admin.js'), // [!code ++]
132+
// ... other vite config code ...
133+
}
134+
}
135+
}
136+
}
137+
}
138+
);
139+
```
140+
141+
142+
### 14: Import the new `blocks/_all.scss` file into the main.scss file
143+
Add the following to the top of the `main.scss` file:
144+
145+
```scss
146+
// Use base elements
147+
@use 'base';
148+
149+
// Use blocks // [!code ++]
150+
@use '/blocks/all' as blocks; // [!code ++]
151+
152+
// ...other scss code...
153+
154+
// Render base elements
155+
@include base.render;
156+
157+
// Render blocks // [!code ++]
158+
@include blocks.render; // [!code ++]
159+
```
160+
161+
This will ensure that all blocks are loaded into the theme.
162+
163+
### 15: Import the new `blocks/_all.scss` file into the admin.scss file
164+
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:
165+
166+
```scss
167+
@use 'components/header'; // [!code --]
168+
@use '/blocks/header-block/assets/_header' as header; // [!code ++]
169+
170+
// ...other scss code...
171+
172+
@include header.render; // [!code --]
173+
@include header.admin; // [!code ++]
174+
```
175+
176+
Add the following to the `admin.scss` file:
177+
178+
```scss
179+
// Use base elements
180+
@use 'base';
181+
182+
// Use blocks
183+
@use '/blocks/all' as blocks; // [!code ++]
184+
185+
// ...other scss code...
186+
187+
// Render base elements
188+
@include base.render;
189+
190+
// Render blocks // [!code ++]
191+
@include blocks.render; // [!code ++]
192+
```
193+
194+
### 16: Recompile the assets
195+
Once these steps have been completed, you will need to recompile the assets. This can be done by running the following WP CLI command:
196+
197+
```bash
198+
wp creode-theme:build
199+
```

package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "creode-wordpress-theme-framework",
3+
"version": "1.0.0",
4+
"description": "Creode's WordPress Theme Framework",
5+
"author": "Creode",
6+
"license": "MIT",
7+
"devDependencies": {
8+
"vitepress": "^1.6.4"
9+
},
10+
"scripts": {
11+
"docs:dev": "vitepress dev docs",
12+
"docs:build": "vitepress build docs",
13+
"docs:preview": "vitepress preview docs"
14+
}
15+
}

0 commit comments

Comments
 (0)