WordPress Plugin Boilerplate

A foundation for building high quality WordPress plugins with a modern development workflow and solid structure. An Object Oriented plugin template, integrated with Composer for PSR-4 autoloading and Gulp for automating your development tasks.

Composer and PSR-4

Composer is a dependency manager for PHP. It allows you to manage your libraries, classes, and functions throughout your applications and its rules makes all PHP project have the same structure and same code style. By implementing PSR-4 autoloading you automatically load classes that have not yet been instantiated, including the files that contain them.

Gulp.js

Gulp is a cross-platform, streaming task runner that lets developers automate many development tasks. At a high level, gulp reads files as streams and pipes the streams to different tasks.

These tasks are code-based and use plugins. The tasks modify the files, building source files into production files.

OOP

Object Oriented Programming is ideal for producing modular applications: Classes allow the creation of components, each of which can implement a specific functionality and interact with other components. It can provide customization through its encapsulated properties and inheritance, enabling a high degree of code reusability and easier maitainance of your plugins.

Install Plugin

Update Composer

Update the composer in order to refresh the autoloader. You can optionally add any project dependency or external library to your composer.json file before running the command. The file is under your root folder of the plugin boilerplate.

If you don't have composer installed at your local pc you can get it here.

Open your plugin in terminal and run:

/your-site/wp-content/plugins/your-plugin> composer update

Install Gulp

All the dependencies that will be installed with gulp are ready and defined on the package.json file which is under your plugin's root directory. You can optionally add any dependencies you require for your project before installing Gulp.

Gulp requires to have node installed to your pc. If you don't have Node.js installed you can download it here.

Open your plugin in terminal and run:

/your-site/wp-content/plugins/your-plugin> npm install -–save-dev

Scroll