Search by

ralfhortt / wordpress-theme-boilerplate

Ralf Hortt

A WordPress Boilerplate Theme by Ralf Hortt

Package info

github.com/Horttcore/WordPress-Theme-Boilerplate

Type:wordpress-theme

pkg:composer/ralfhortt/wordpress-theme-boilerplate

Statistics

Installs: 32

Dependents: 0

Suggesters: 0

Stars: 3

Open Issues: 7

dev-master 2026-11-15 19:03 UTC

This package is auto-updated.

Last update: 2026-11-15 19:03:41 UTC


README

Lint

Block theme from (Ralf Hortt). Design tokens live in src/tokens.json; theme.json and styles/*.json are generated from src/ (see Build pipeline). Editor JavaScript is compiled with @wordpress/scripts, SCSS with Sass + Lightning CSS.

Repository: github.com/Horttcore/WordPress-Theme-Boilerplate

Requirements

WordPress 7.1+ (tested up to 7.1)
PHP 8.4+
Node.js 26+ (see .nvmrc and package.json engines)

Quick start

  1. Install the theme under wp-content/themes/wordpress-theme-boilerplate — the folder name must match this slug — and activate WordPress Theme Boilerplate in the admin. Or use npm run env:setup with @wordpress/env: .wp-env.json maps the checkout to that path regardless of its folder name.
  2. Install dependencies and build assets:
npm install
npm run build
  1. For local development with watch mode:
npm run start

CSS is written to build/css/, editor JS to build/js/; both are enqueued from inc/assets.php. theme.json and styles/*.json are gitignored build output (WordPress reads them at runtime). Edit src/, then npm run build or npm run start. CI uploads them with the build/ artifact; the Docker image uses that artifact or runs the build itself.

Build pipeline

Source Output Loaded
src/tokens.json (custom) theme.json settings.custom —
src/theme.ts theme.json —
src/blocks/<ns>/<block>/<block>.ts theme.json settings/styles.blocks["<ns>/<block>"] —
src/blocks/<ns>/<block>/<block>.<variant>.ts styles/<block>.<variant>.json (block style, slug = variant) —
src/blocks/<ns>/<block>/styles.scss build/css/blocks/<ns>/<block>/styles.css Front end (only with the block) + editor
src/blocks/<ns>/<block>/editor.scss build/css/blocks/<ns>/<block>/editor.css Editor only (block editorStyle)
src/css/app.scss, src/css/editor-styles.scss build/css/*.css Front end + editor / editor only
src/js/editor.ts build/js/editor.js Block editor
  • Block folders (src/blocks/<namespace>/<block>/) keep everything for one block together. Allowed files: <block>.ts, <block>.<variant>.ts, styles.scss, editor.scss, helpers _*.ts / partials _*.scss. Anything else fails the build. Folders with a block.json are custom blocks; their CSS/JS is built by wp-scripts.
  • Types and autocomplete: defineTheme, defineBlock and defineBlockStyle (src/define.ts) are typed against the theme.json schema of the minimum WordPress version. Every string value suggests the theme's own tokens (var:custom|…, var:preset|…) but accepts any string. npm run build:theme rewrites both type files in build/types/ (gitignored): token-paths.ts from the tokens, theme-json.ts from the vendored schema src/theme.schema.json. npm run types:theme-json only refreshes that schema from schemas.wp.org when the minimum WordPress version changes.
  • SCSS: @use partials from src/css/ by name (load path). Output is prefixed/lowered for @wordpress/browserslist-config, minified in builds, unminified with source maps in watch mode.

npm scripts

Script Description
npm run start Watch theme.json sources, SCSS and editor JS in parallel
npm run build Build theme.json + styles/, CSS and editor JS
npm run build:theme Generate theme.json, styles/*.json and build/types/*.ts
npm run build:css Compile SCSS to build/css/
npm run check:theme Fail if on-disk theme.json / styles/*.json differ from a fresh build
npm run types:theme-json Re-download the pinned schema into src/theme.schema.json (minimum WP bump)
npm run lint build:theme, then ESLint, Stylelint and tsc
npm run audit npm audit gate (fails on critical only; run npm audit for the full report)
npm run format Prettier (JS/TS) and Stylelint --fix (CSS/SCSS)
npm run env:start Start local WordPress via @wordpress/env
npm run env:setup Start env and activate this theme
npm run env:stop / env:reset Stop or reset the local env

Linting, formatting, and Git hooks

  • ESLint / Prettier: WordPress defaults via @wordpress/scripts and @wordpress/prettier-config.
  • Stylelint: @wordpress/stylelint-config (SCSS) — config in .stylelintrc.
  • Husky + lint-staged: On git commit, staged *.{js,ts} and *.{css,scss} under the theme are formatted and linted. Hooks are installed when you run npm install (prepare → Husky).

Run checks manually before pushing:

npm run lint
npm run format
npm run audit

PHP static analysis and refactoring use Composer:

composer install
composer lint:php
composer refactor -- --dry-run

PHPStan uses WordPress stubs at level 5 and analyzes the theme's PHP entrypoint, inc/, and patterns/. Rector is scoped to the same PHP files; omit --dry-run when you intend to apply its suggestions.

Theme structure

wordpress-theme-boilerplate/
├── patterns/          # Block patterns (PHP); registered automatically
├── templates/         # Block templates (mostly wp:pattern references)
├── parts/             # Template parts
├── bin/               # Build scripts (build-theme.ts, build-css.ts, theme-json-types.ts)
├── src/
│   ├── tokens.json    # All design tokens (settings.custom)
│   ├── theme.ts       # Global settings and styles
│   ├── define.ts      # defineTheme / defineBlock / defineBlockStyle
│   ├── schema.ts      # Pinned theme.json schema URL
│   ├── theme.schema.json # Vendored schema body (types:theme-json)
│   ├── blocks/        # <namespace>/<block>/ — theme.json part, block styles, SCSS
│   ├── css/           # Global SCSS (app.scss, editor-styles.scss, partials)
│   └── js/editor.ts   # Block editor scripts (variations, filters, etc.)
├── build/             # CSS, JS, build/types (gitignored)
├── theme.json         # Generated, gitignored — WordPress reads it
├── styles/            # *.json generated and gitignored; README stays
├── inc/assets.php     # Asset hooks; loaded from functions.php
└── style.css          # Theme header only