WordPress Plugin Template

Josh's WordPress plugin starter

Documentation
Name
Getting Started
PHP
JavaScript
Local Development
CI/ CD

View the Project on GitHub Shelob9/wordpress-plugin

WordPress Plugin

This is my – Josh Pollock – opinionated boilerplate and template for WordPress plugin with PSR-4 autoloader, TypeScript, Docker, Github actions, and other fun stuff.

Creating A Plugin

This plugin is a template. You can create a new Github project from this repo using the “Use This Template” button, or by downloading the plugin from Github.

There is a CLI for renaming things, or you can rename things manually.

Notes:

Rename With ClI

You can create two different versions of the plugin, using the CLI

Everything

This option includes everything: local dev, Typescript, composer autoloader, PHP tests, JavaScript tests, etc.

Basic

This version has less things, it does not use Yarn workspace or Typescript or composer. It generates one PHP file that can load JS/CSS and a WordPress-friendly webpack that can have any number of entry points.

Manual Renaming

After making your own version, I recommend you follow these steps, before running composer install:

  1. Choose a slug, and root namespace for your plugin.
  2. Change main plugin file’s name from wordpress-plugin.php to match your plugin slug.
  3. Find and replace, with case sensitivity, “wordpress-plugin” with your plugin’s slug in all files.
    • Text domain
    • Plugin name in package.json and composer.json
    • tests/bootstrap.php includes main plugin file.
  4. In composer.json change Josh\\WordPressPlugin\\ in both autoloader to match your new root namespace.
  5. Find and replace WordPressPlugin in php files with your root namespace.
  6. Fine and replace shelob9.gihub.io with your Github pages site URL.
  7. Enable Github pages for your repo.
    • Now you have a documentation site!

Suggestions

  1. Customize wp-env configuration.

Plugin Quickstart

Requirements

Using The Plugin