Skip to content

Repository files navigation

Pumpkin [Big Alpha Release]

Next generation WordPress Theme boilerplate concept

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.

⚠️ Important: This theme requires ACF Pro (paid plugin). You must purchase your own ACF Pro license separately. This project is not affiliated with or endorsed by ACF in any way.

Feedback welcome, contributions are not accepted at this stage. More examples on how to use this boilerplate will be provided soon.

Key Concepts

1. ACF Flexible Field Sections System

Component-based page building using ACF flexible fields. Everything is built around one ACF Flexible Field called "Sections".

πŸ“– Read Full Documentation

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

2. Custom Template Loader

Folder-based template system with automatic discovery and hierarchical fallbacks.

πŸ“– Read Full Documentation

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

3. Webpack Build System

Auto-discovery and bundling of template and section assets.

πŸ“– Read Full Documentation

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

4. ACF Options Manager

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.

πŸ“– Read Documentation

πŸ“– Package Documentation


5. Global PHP Config

Hardcoded configuration for settings that don't need WordPress admin editing.

πŸ“– Read Full Documentation

Quick Overview:

  • Version-controlled settings
  • Template hierarchy for overrides
  • Feature flags, API keys, defaults
  • Environment-specific configuration

6. Reusable Static Components

Code-based UI components with custom PHP class architecture.

πŸ“– Read Full Documentation

Quick Overview:

  • Self-contained component folders
  • Class-based rendering
  • Multiple template variations
  • Perfect for logos, breadcrumbs, social icons

Requirements:

  • PHP 8.2+, WordPress 6.x
  • Node.js >= 22, npm
  • ACF Pro

Quick Start

  1. Clone the Repository:

    git clone https://github.com/code-soup/pumpking.git my-awesome-theme
    cd my-awesome-theme
  2. Configure ACF Pro License: Create an auth.json file 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.

  3. Environment Configuration (Optional): Create a .env file 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
  4. Run the Setup Script: This script will ask for your theme's details and configure the boilerplate files for you.

    npm run setup
  5. 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
  6. Run the Development Server: For live-reloading and automatic recompilation of assets during development.

    npm run dev

Available Scripts

This boilerplate comes with a set of pre-configured scripts for development tasks.

PHP Scripts (via Composer)

  • composer lint: Lints all PHP files for syntax errors.
  • composer wpcs: Checks PHP files against the WordPress Coding Standards.
  • composer cbf: Automatically fixes many phpcs errors.

JavaScript/Asset Scripts (via npm)

  • npm run setup: Initial plugin setup
  • npm 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 the dist folder and the webpack cache.

Folder Structure

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

Key Directory Explanations

/templates/ - Template System

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 classes
  • shared/parts/ - Traditional WordPress template parts (header, footer, sidebar)
  • shared/sections/ - ACF Flexible Content sections for page building

/includes/ - Core Functionality

PHP classes that power the theme's features:

  • core/ - Essential theme classes (Bootstrap, Component base, Page config)
  • acf/ - ACF integration for flexible content sections
  • wp-mods/ - WordPress core modifications (custom template loader, script loader)
  • utils/ - Helper functions and traits for common tasks

/src/ - Source Assets

Pre-compiled assets and build configuration:

  • config/ - Webpack configuration split into logical modules
  • styles/ - Global SCSS following ITCSS methodology
  • scripts/ - Global JavaScript and utilities

/dist/ - Compiled Assets

Auto-generated by Webpack containing optimized, production-ready assets. Each page template gets its own bundle based on its index.js/scss files.

Template Loading Hierarchy

Templates follow this loading order for maximum flexibility:

  1. Page-specific: /templates/post-type/{post-type}/{template-name}/index.php
  2. Post-type default: /templates/post-type/{post-type}/index.php
  3. 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.

Documentation

For detailed information on each feature, see the documentation files in the /docs folder:

Hooker

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.

Basic Usage

Getting the Hooker Instance

// From Bootstrap
$hooker = \CodeSoup\Pumpkin\Core\Bootstrap::get_instance()->get_hooker();

Adding Actions and Filters

// 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
] );

About

WordPress starter theme that combines ACF PRO integration with a specific workflow for modular, component-based theme development.

Resources

Stars

8 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages