This software is provided "as is" without any warranties, express or implied. The project is currently in active development and may contain bugs or incomplete features. Part of readme is generated by AI and because of frequent updates might not be up to date.
Designed around component-based architecture and DRY principles for better code organization and reusability. Note that this approach may not follow traditional WordPress theme patterns. It's a collection of best practices for streamlined theme development and long term maintenance that has proved to work for me in every environment during 15 years of developing bespoke WordPress themes.
Feedback welcome, contributions are not accepted at this stage. More examples on how to use this boilerplate will be provided soon.
Component-based page building using ACF flexible fields. Everything is built around one ACF Flexible Field called "Sections".
Quick Overview:
- Central hub: One ACF Flexible Field containing all section layouts
- Each section = self-contained component with PHP, SCSS, JS, and assets
- Auto-loading: Section CSS/JS loads only when used
- Reusable across any page/post type
Folder-based template system with automatic discovery and hierarchical fallbacks.
Quick Overview:
- Create a folder β template appears in WordPress admin
- Template hierarchy: Template-specific β Post-type β Shared
- Template parts support: Override header, footer, sidebar per template
Auto-discovery and bundling of template and section assets.
Quick Overview:
- Per-template bundles: Each template gets its own CSS/JS
- Per-section bundles: Each section gets its own CSS/JS
- Async loading support for deferred assets
- Hot Module Replacement for development
Composer package for managing WordPress options pages using ACF and custom post type. Data is stored and retrieved from post_content field and does not use the wp_options table. Supports multiple instances and capability-based access control.
Hardcoded configuration for settings that don't need WordPress admin editing.
Quick Overview:
- Version-controlled settings
- Template hierarchy for overrides
- Feature flags, API keys, defaults
- Environment-specific configuration
Code-based UI components with custom PHP class architecture.
Quick Overview:
- Self-contained component folders
- Class-based rendering
- Multiple template variations
- Perfect for logos, breadcrumbs, social icons
- PHP 8.2+, WordPress 6.x
- Node.js >= 22, npm
- ACF Pro
-
Clone the Repository:
git clone https://github.com/code-soup/pumpking.git my-awesome-theme cd my-awesome-theme -
Configure ACF Pro License: Create an
auth.jsonfile in the theme root with your ACF Pro license credentials:{ "http-basic": { "connect.advancedcustomfields.com": { "username": "YOUR_ACF_LICENSE_KEY", "password": "YOUR_ACF_LICENSE_URL" } } }Note: Get your license credentials from your ACF Pro account page.
-
Environment Configuration (Optional): Create a
.envfile for environment-specific settings:# Development settings WP_DEV_URL=http://localhost # Where your WordPress theme is installed WP_CONTENT_PATH=/wp-content/themes # Sepcify custom themes folder if different from default
-
Run the Setup Script: This script will ask for your theme's details and configure the boilerplate files for you.
npm run setup
-
Install Dependencies: Once the setup is complete, install the necessary PHP and Node.js dependencies.
# Install PHP dependencies (includes ACF Pro) composer install # Install Node.js dependencies npm install
-
Run the Development Server: For live-reloading and automatic recompilation of assets during development.
npm run dev
This boilerplate comes with a set of pre-configured scripts for development tasks.
composer lint: Lints all PHP files for syntax errors.composer wpcs: Checks PHP files against the WordPress Coding Standards.composer cbf: Automatically fixes manyphpcserrors.
npm run setup: Initial plugin setupnpm run dev: Starts the webpack dev server with Hot Module Replacement.npm run build: Compiles and optimizes all assets for a production environment.npm run build:dev: Compiles assets for development without optimization.npm run lint: Runs both the script and style linters.npm run lint:scripts: Lints JavaScript files with ESLint.npm run lint:styles: Lints SCSS files with Stylelint.
npm run clean: Deletes thedistfolder and the webpack cache.
pumpkin/
βββ π dist/ # Compiled assets (auto-generated)
β βββ manifest.json # Webpack asset manifest
β βββ scripts/ # Compiled JavaScript bundles
β βββ styles/ # Compiled CSS bundles
β
βββ π includes/ # Core PHP functionality
β βββ π acf/ # ACF integration classes
β β βββ class-sections.php # Flexible content sections
β β βββ class-setup.php # ACF configuration
β β βββ json/ # ACF field group exports
β βββ π core/ # Core theme classes
β β βββ class-bootstrap.php # Theme initialization
β β βββ class-component.php # Component base class
β β βββ class-hooker.php # WordPress hooks manager
β β βββ class-page-config.php # Page configuration handler
β βββ π plugin-mods/ # Third-party plugin modifications
β βββ π utils/ # Utility classes and traits
β β βββ html-helpers.php # HTML generation helpers
β β βββ trait-asset-loader.php # Asset loading functionality
β β βββ trait-script-loader.php # Script loading utilities
β β βββ trait-template-utilities.php # Template helper functions
β βββ π wp-mods/ # WordPress core modifications
β βββ class-script-loader.php # Custom script loading system
β βββ class-template-admin.php # Template admin interface
β βββ class-template-loader.php # Custom template loading system
β βββ class-theme-setup.php # WordPress theme setup
β
βββ π lang/ # Translation files
β βββ pumpkin.pot # Translation template
β
βββ π src/ # Source assets (pre-compilation)
β βββ π config/ # Build configuration
β β βββ config.user.js # User-specific webpack config
β β βββ config.webpack.js # Main webpack configuration
β β βββ π webpack/ # Webpack module configurations
β β βββ config.module.js # Module rules
β β βββ config.optimization.js # Optimization settings
β β βββ config.plugins.js # Webpack plugins
β β βββ π loaders/ # Asset loaders
β βββ π fonts/ # Font files
β βββ π icons/ # Icon assets
β βββ π images/ # Global images
β βββ π scripts/ # Global JavaScript
β β βββ admin.js # WordPress admin scripts
β β βββ main.js # Main frontend script
β β βββ π util/ # JavaScript utilities
β βββ π styles/ # Global SCSS
β βββ main.scss # Main stylesheet entry
β βββ admin.scss # Admin stylesheet
β βββ π abstracts/ # SCSS variables, mixins, functions
β βββ π components/ # Global component styles
β βββ π core/ # Base/reset styles
β βββ π layouts/ # Layout-specific styles
β βββ π sections/ # Section-specific styles
β
βββ π templates/ # Template system
β βββ π post-type/ # Post type specific templates
β β βββ π page/ # Page templates
β β β βββ index.php # Default page template
β β β βββ π 404/ # 404 page template
β β β βββ index.php # 404 template file
β β βββ π post/ # Post templates
β βββ π shared/ # Shared template components
β β βββ π components/ # Reusable static components
β β β βββ π website-logo/ # Example component
β β β βββ Component.php # Component class
β β β βββ π assets/ # Component-specific assets
β β β βββ π templates/ # Component templates
β β βββ π parts/ # Template parts (header, footer, etc.)
β β βββ π sections/ # ACF flexible content sections
β βββ π taxonomy/ # Taxonomy templates
β βββ index.php # Default taxonomy template
β
βββ π vendor/ # Composer dependencies
β βββ π codesoup/
β β βββ acf-admin-categories/ # ACF admin organization
β β βββ acf-options/ # ACF options manager
β βββ π wpengine/
β β βββ advanced-custom-fields-pro/ # ACF Pro plugin
β βββ autoload.php # Composer autoloader
β
βββ π base.php # Theme base template
βββ π functions.php # WordPress functions file
βββ π index.php # WordPress index template
βββ π page-config.php # Global page configuration
βββ π style.css # WordPress theme header
βββ π composer.json # PHP dependencies
βββ π package.json # Node.js dependencies
βββ π README.md # This file
The heart of Pumpkin's component-based architecture:
post-type/{post-type}/{template-name}/- Each template gets its own folder containing all related files (PHP, SCSS, JS, images)shared/components/- Reusable static components with their own PHP classesshared/parts/- Traditional WordPress template parts (header, footer, sidebar)shared/sections/- ACF Flexible Content sections for page building
PHP classes that power the theme's features:
core/- Essential theme classes (Bootstrap, Component base, Page config)acf/- ACF integration for flexible content sectionswp-mods/- WordPress core modifications (custom template loader, script loader)utils/- Helper functions and traits for common tasks
Pre-compiled assets and build configuration:
config/- Webpack configuration split into logical modulesstyles/- Global SCSS following ITCSS methodologyscripts/- Global JavaScript and utilities
Auto-generated by Webpack containing optimized, production-ready assets. Each page template gets its own bundle based on its index.js/scss files.
Templates follow this loading order for maximum flexibility:
- Page-specific:
/templates/post-type/{post-type}/{template-name}/index.php - Post-type default:
/templates/post-type/{post-type}/index.php - Shared fallback:
/templates/shared/index.php
The same hierarchy applies to template parts (header.php, footer.php, etc.), allowing granular customization per template while maintaining DRY principles.
For detailed information on each feature, see the documentation files in the /docs folder:
- ACF Flexible Field Sections - Component-based page building system
- Custom Template Loader - Folder-based template discovery and hierarchy
- Webpack Build System - Asset bundling and optimization
- ACF Options Manager - Theme options package
- Global PHP Config - Hardcoded configuration system
- Static Components - Reusable UI components
The Hooker class is a centralized service for adding WordPress actions and filters. It is registered in the Dependency Injection container and can be accessed from any class that has access to the container, such as a service provider or a class instantiated by one.
The primary benefit of using this service is to have a consistent, injectable way to manage WordPress hooks, which is useful for organization and testing.
// From Bootstrap
$hooker = \CodeSoup\Pumpkin\Core\Bootstrap::get_instance()->get_hooker();// Add a single action
$hooker->add_action( 'wp_footer', $this, 'render_footer' );
// Add a single filter
$hooker->add_filter( 'the_title', $this, 'modify_title', 10, 2 );
// Add multiple actions at once
$hooker->add_actions( [
[ 'wp_enqueue_scripts', $this, 'enqueue_scripts' ],
[ 'wp_footer', $this, 'render_footer', 20 ],
] );
// Add multiple filters at once
$hooker->add_filters( [
[ 'the_content', $this, 'filter_content' ],
[ 'the_title', $this ], // Method name matches hook name, can be omitted
[ 'quick_edit_enabled_for_post_type', '__return_false' ], // Use WordPress built in global function
] );