Skip to content

Repository files navigation

WordPress Plugin Template

Header

The absolute minimal WordPress plugin template. Just the essentials - activation, deactivation, and code quality tools.

Features

  • WordPress Coding Standards - WPCS with PHP_CodeSniffer for WordPress coding standards compliance
  • EditorConfig - Consistent editor settings across different IDEs
  • Minimal Structure - Just the bare essentials, no bloat
  • Plugin Hooks - Basic activation and deactivation hooks ready to use

Quick Start

1. Use This Template

Click "Use this template" on GitHub or clone this repository:

git clone https://github.com/liasoft/template-wp-plugin.git my-new-plugin
cd my-new-plugin
rm -rf .git && git init  # Start fresh git history

2. Customize Your Plugin (Automated)

The easiest way to customize this template is using the initialization script:

  1. Edit template.json with your plugin details:
{
  "plugin": {
    "name": "My Awesome Plugin",
    "slug": "my-awesome-plugin",
    "description": "Does awesome things for WordPress.",
    "version": "1.0.0",
    "uri": "https://github.com/yourname/my-awesome-plugin"
  },
  "author": {
    "name": "Your Name",
    "uri": "https://yourwebsite.com"
  },
  "php": {
    "namespace": "MyAwesomePlugin",
    "function_prefix": "my_awesome_plugin",
    "constant_prefix": "MY_AWESOME_PLUGIN"
  },
  "composer": {
    "name": "yourname/my-awesome-plugin"
  },
  "github": {
    "owner": "yourname",
    "repo": "my-awesome-plugin"
  }
}
  1. Run the initialization script:
# Preview changes (dry run)
python scripts/init-repo.py --dry-run

# Apply changes (resets changelog by default)
python scripts/init-repo.py

# Apply changes but keep existing changelog
python scripts/init-repo.py --keep-changelog

The script will:

  • Replace all template placeholders across all files
  • Rename template-wp-plugin.php to your-plugin-slug.php
  • Update version validation scripts
  • Reset the changelog for a fresh start (use --keep-changelog to preserve it)

2b. Customize Your Plugin (Manual)

Alternatively, you can manually customize:

  1. Rename the main plugin file: template-wp-plugin.php → your-plugin-name.php

  2. Update plugin headers in your renamed file:

    • Template WordPress Plugin → Your Plugin Name
    • A minimal boilerplate for WordPress plugins → Your plugin description
    • Liasoft GmbH → Your name
    • Update all URLs to your repository
  3. Update function names to match your plugin (replace template_wp_plugin prefix)

  4. Update these files: composer.json, README.md, CHANGELOG.md, phpcs.xml

3. Install Development Dependencies

composer install

4. Development Workflow

Code Quality

# Check code against WordPress Coding Standards
composer run lint

# Auto-fix coding standards violations where possible
composer run lint:fix

Testing Your Plugin

  1. Copy to WordPress plugins directory:

    cp -r . /path/to/wordpress/wp-content/plugins/your-plugin-name/
  2. Activate in WordPress admin dashboard

  3. Your plugin is now active (it doesn't do anything yet - that's the point!)

Project Structure

your-plugin-name/
├── .editorconfig         # Editor configuration
├── .github/              # GitHub configuration
│   ├── prompts/          # Copilot workspace prompt files
│   └── workflows/        # CI/CD workflows
├── .gitignore            # Git ignore rules
├── assets/               # Plugin assets (banner, icons)
├── scripts/              # Development scripts
│   ├── build-plugin.sh   # Build and package plugin
│   ├── init-repo.py      # Template initialization script
│   └── validate-versions.sh  # Version consistency checker
├── phpcs.xml             # WordPress Coding Standards config
├── composer.json         # PHP dependencies and scripts
├── composer.lock         # Dependency lock file
├── template.json         # Template configuration (edit this first!)
├── LICENSE               # GPL-3.0-or-later license
├── README.md             # This file
├── template-wp-plugin.php # Main plugin file (rename this)
└── vendor/               # Composer dependencies (after install)

What's Included

Main Plugin File

  • WordPress plugin header with all required metadata
  • Direct access prevention
  • Plugin activation hook (empty, ready for your code)
  • Plugin deactivation hook (empty, ready for your code)

Development Tools

  • WordPress Coding Standards: Ensures your code follows WordPress coding standards and best practices
  • PHP_CodeSniffer: Automated code standards checking and fixing
  • EditorConfig: Consistent code formatting across different editors and IDEs

GitHub Copilot Prompt Files

The template includes workspace-specific prompt files in .github/prompts/ that provide specialized development assistance:

  • ws-commit.prompt.md - Review and commit changes with proper conventional commit messages
  • ws-review.prompt.md - Code review without committing, focusing on WordPress standards
  • ws-release.prompt.md - Manage plugin versioning and create releases with git tags
  • ws-update.prompt.md - Update and manage Composer dependencies safely

These become available as slash commands in VS Code (e.g., /ws-commit, /ws-review) when using GitHub Copilot. They provide project-specific guidance and automate common WordPress plugin development tasks.

Learn more: How to extend GitHub Copilot with prompt files

Adding Your Features

The template provides activation and deactivation hooks where you can add your plugin logic:

function template_wp_plugin_activate() {
	// Activation logic here.
}
register_activation_hook( __FILE__, 'template_wp_plugin_activate' );

/**
 * Plugin deactivation hook.
 */
function template_wp_plugin_deactivate() {
	// Deactivation logic here.
}
register_deactivation_hook( __FILE__, 'template_wp_plugin_deactivate' );

Add your plugin's main functionality after the hooks:

// Add your plugin code here
// Example: Register shortcodes, add admin menus, enqueue scripts, etc.

Important: Remember to rename the functions with your own unique prefix to avoid conflicts with other plugins.

Why So Minimal?

This template follows the principle of absolute minimalism:

  • No unnecessary classes or complex architecture
  • No assets directory (add only if you need it)
  • No admin pages boilerplate (add only if you need it)
  • No translation files (add only if you need it)
  • No shortcodes or widgets (add only if you need it)

Start simple, add complexity only when needed.

License

This template is licensed under the GPL-3.0-or-later License.

Support

About

Minimal boilerplate for a WordPress Plugin

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages