@phcdevworks/spectre-shell-wordpress is a reusable template for building modern, high-performance WordPress themes. It acts as the "Organs" layer, providing the CMS-specific structure and integration logic for the Spectre ecosystem.
🤝 Contributing Guide | 📝 Changelog | 🏛️ Spectre Arsenal
This package is the CMS Integration Layer. It bridges modern frontend tooling (Vite, TS, Tailwind 4) with the WordPress theme hierarchy, ensuring Spectre standards are maintained in a CMS environment.
- 🐘 WordPress Native: Full support for standard PHP templates and functions.
- ⚡ Vite-Powered: Instant HMR and optimized production builds.
- 🌫️ Manifest-Based Assets: Reliable cache-busting and asset loading.
- 🎨 Tailwind 4 Ready: Pre-configured for the latest utility-first styling.
- ✅ Vite-powered development with instant HMR
- ✅ TypeScript for type-safe theme development
- ✅ Tailwind CSS 4 with modern
@importsyntax - ✅ Automatic dev/prod mode detection via
WP_ENV - ✅ Manifest-based asset loading with cache-busting
- ✅ WordPress-optimized build output to
spectre-theme/dist/
# Clone or use this template
git clone https://github.com/phcdevworks/spectre-shell-wordpress.git
cd spectre-shell-wordpress
# Install dependencies
npm installSet up your WordPress installation to work with the Vite dev server:
// wp-config.php
define('WP_ENV', 'development'); // Enable dev modeHow it works:
- Development mode: Assets load from Vite dev server (http://localhost:5173) with HMR
- Production mode: Assets load from
spectre-theme/dist/with manifest-based cache-busting
npm run devThis starts the Vite dev server on http://localhost:5173 with HMR enabled. Edit files in src/ and see changes instantly in your browser.
# Copy or symlink theme folder to WordPress
cp -r spectre-theme /path/to/wordpress/wp-content/themes/spectre-theme
# Or create a symlink for development
ln -s $(pwd)/spectre-theme /path/to/wordpress/wp-content/themes/spectre-themeThen activate the theme in WordPress admin.
npm run buildThis compiles TypeScript, processes CSS with Tailwind, and outputs optimized assets to spectre-theme/dist/ with a manifest for cache-busting.
Deploy: Upload the spectre-theme/ folder to your WordPress installation.
Edit spectre-theme/style.css with your theme details:
/*
Theme Name: Your Theme Name
Theme URI: https://yoursite.com
Author: Your Name
Description: Your amazing WordPress theme
Text Domain: your-theme-slug
*/Find and replace in spectre-theme/functions.php:
spectre_shell→your_theme_slug- Function names (e.g.,
spectre_shell_setup→yourtheme_setup)
Edit src/styles/main.css:
@import "tailwindcss";
/* Your custom styles */
:root {
--font-sans: system-ui, sans-serif;
}
body {
@apply antialiased;
}
/* WordPress alignment classes */
.alignleft {
@apply float-left mr-4;
}Edit src/js/main.ts:
import "../styles/main.css";
// Your TypeScript code
document.addEventListener("DOMContentLoaded", () => {
console.log("Theme loaded!");
});Customize tailwind.config.ts:
import type { Config } from "tailwindcss";
export default {
content: ["./spectre-theme/**/*.php", "./src/**/*.{js,ts,jsx,tsx}"],
theme: {
extend: {
colors: {
primary: "#your-color",
},
},
},
} satisfies Config;| Folder | Responsibility |
|---|---|
src/ |
TypeScript and CSS source files compiled by Vite |
src/js/ |
JavaScript/TypeScript entry points |
src/styles/ |
CSS files with Tailwind imports |
spectre-theme/ |
WordPress theme files (PHP templates, functions.php, style.css) |
spectre-theme/dist/ |
Generated build artifacts (CSS, JS, manifest) - auto-created by Vite |
Source files live in src/ and compile to spectre-theme/dist/. Only the spectre-theme/ folder gets deployed to WordPress.
When WP_ENV is set to development, spectre-theme/functions.php loads assets from the Vite dev server:
wp_enqueue_script(
'vite-client',
'http://localhost:5173/@vite/client',
array(),
null,
false
);Changes to source files trigger instant browser updates via HMR.
In production, assets load from the manifest file at spectre-theme/dist/.vite/manifest.json:
$manifest = json_decode(file_get_contents(get_template_directory() . '/dist/.vite/manifest.json'), true);
if (isset($manifest['src/styles/main.css'])) {
$css_file = $manifest['src/styles/main.css']['file'];
wp_enqueue_style('theme-style', get_template_directory_uri() . '/dist/' . $css_file);
}Hashed filenames ensure cache-busting on updates.
Add standard WordPress templates to the spectre-theme/ folder:
spectre-theme/
├── single.php # Single post template
├── page.php # Page template
├── archive.php # Archive template
├── 404.php # 404 error page
├── search.php # Search results
└── sidebar.php # Sidebar
All templates have access to enqueued Vite assets automatically.
npm run buildThe build process:
- TypeScript compilation - Compiles
src/js/to optimized JavaScript - CSS processing - Processes
src/styles/with Tailwind and PostCSS - Asset optimization - Minifies and generates hashed filenames
- Manifest generation - Creates
.vite/manifest.jsonfor asset lookup
Output goes to spectre-theme/dist/ and is ready for WordPress deployment.
For release history and version notes, see the Changelog.
This template follows a build tool first approach:
Purpose: Asset compilation pipeline for WordPress themes
Outputs: Compiled CSS and JavaScript to spectre-theme/dist/ with manifest
Rules:
- Vite handles all asset compilation and HMR
- Tailwind provides utility-first CSS framework
- All source files must go through Vite
Purpose: Development files for TypeScript and CSS
Contains:
main.ts- JavaScript entry pointmain.css- CSS entry with Tailwind imports- Optional component organization
Rules:
- Use TypeScript for type safety
- Import Tailwind via
@import 'tailwindcss' - Never ship raw source to production
Purpose: WordPress templates and functions that load Vite assets
Key mechanism:
functions.phpdetectsWP_ENVand switches between dev/prod- Dev mode loads from Vite server with HMR
- Prod mode loads from manifest
Rules:
- PHP never defines inline styles or scripts
- All assets load through Vite's build system
- Follow WordPress coding standards
Vite builds. WordPress loads. Source never ships.
WordPress themes ship only compiled assets from dist/, never raw source files.
- If it's a build config → belongs in
vite.config.tsortailwind.config.ts - If it's source code → belongs in
src/ - If it's WordPress PHP → belongs in
spectre-theme/
- Fast development - HMR and Vite dev server for instant feedback
- Type-safe - TypeScript catches errors before runtime
- Modern CSS - Tailwind CSS 4 with utility-first approach
- WordPress-native - Standard WordPress functions and hooks
- Production-ready - Optimized builds with cache-busting
Type definitions are included for Vite and WordPress globals:
// vite-env.d.ts
/// <reference types="vite/client" />
interface ImportMetaEnv {
readonly VITE_SOME_KEY: string;
}
interface ImportMeta {
readonly env: ImportMetaEnv;
}Spectre is built on a non-negotiable hierarchy to prevent style leakage and duplication:
- Layer 1: DNA (@phcdevworks/spectre-tokens) – Design values.
- Layer 2: Blueprint (@phcdevworks/spectre-ui) – Structure & Recipes.
- Layer 6: Organs (This Package) – CMS Integration & Themes.
The Golden Rule: Tokens define meaning. UI defines structure. Organs define delivery for specific engines like WordPress.
Issues and pull requests are welcome. For theme template improvements, test both dev and production modes.
For detailed contribution guidelines, see CONTRIBUTING.md.
MIT © PHCDevworks — See LICENSE for details.