TL;DR: The WP Plugin Scaffold repository contains a a very basic set of files that are needed to spin up a Composer-based WordPress Plugin.
Over the years, I’ve written or contributed to a number of different projects that have been aimed at making WordPress plugin development easier. At this point, there are a variety of ways people are creating WordPress plugins such that there isn’t really a way to create a boilerplate to capture all of them.
So I’m not aiming to do that.
But over the last few months (or maybe a year?), I’ve been working with the same structure for creating plugins. It normally grows into something larger based on if I’m taking an object-oriented approach or a procedural approach. It also changes based on how large the plugin is, what its purpose is, who is going to use it, or how it’s going to be used.
To that end, I’ve ended up with a very basic set of files that every project incorporates regardless of the size.
As such, I thought I’d share it.
WP Plugin Scaffold
The WP Plugin Scaffold is not meant to be a foundation off of which plugins are built. It’s not meant to be highly opinionated or even a guide on how to build plugins.
Instead, its a set of files that serve as a starting point for WordPress Plugins that:
- are built using Composer,
- are designed to work with PHP 8 (but this can easily be changed as the README explains),
- use Ray for debugging,
- and are run in Visual Studio Code with support for Xdebug and PHP Code Sniffer.
If this works for you, maybe you’ll find some use for it.
The Purpose of Each File
Here’s what each directory or file does in this repository:
settings.jsonfile for the settings for the IDE that I always use and
launch.jsonfor the Xdebug configuration,
vendor/includes the autoloader as generated by Composer,
.gitignoreis a basic git-ignore file for making sure nothing but the files I’ve specified are committed to the repository,
CHANGELOG.mdis a changelog based on the format defined by the team at Keep a Changelog,
LICENSEis a copy of the GPLv3,
README.mdis a file used to explain the name of the plugin, what it does, and how to install it,
composer.lockinclude a list of dependencies used in both development environments and set for distribution (this includes defining PHP 8 and includes Ray for debugging),
plugin.phpis the bootstrap for the plugin
Obviously, you can remove what you don’t need but this isn’t really designed to serve as a broad way to build plugins. It’s how I get started and I simply keep it in a public repository.
If you want to use the WP Plugin Scaffold as a starting point for your projects, clone the repository and then make sure to look for any TODO strings throughout the project.
Further, look for my name, email address, and domain throughout the code and update it to reflect your information.
Finally, make sure that you rename WP Plugin Scaffold to reflect whatever it is you’re working and update the
namespace in the core plugin file so that its unique to your project.
This project is not a definitive way to create plugins nor is it meant to serve as a foundation off of which all different types of plugins can be written.
At the most, it’s a starter for a Composer-based WordPress plugin. It’s an open repository based on the way I’ve been structuring a lot of my work. If it helps those of you who are building plugins in a similar way, that’s great! If not, then it’s not the type of set of files specifically meant for your type of project. 🙂