When building WordPress plugins that go beyond a few lines of code, organization, reusability, and scalability become critical. This is where the WordPress Plugin Boilerplate comes into play. It offers a standardized, object-oriented foundation for building robust, maintainable plugins. Whether you’re a seasoned developer or just starting out, the boilerplate can save you time, enforce best practices, and streamline your plugin development process.
What is the WordPress Plugin Boilerplate?
The WordPress Plugin Boilerplate is a well-structured, object-oriented foundation for building WordPress plugins. It was originally created by Tom McFarlin and later extended by the open-source community.
It comes pre-loaded with organized folders, base classes, and WordPress best practices, including:
- Object-oriented programming (OOP)
- Proper hook registration
- Namespace separation
- Internationalization readiness
- Separation of admin vs. public functionality
Why Use a Boilerplate?
Using a plugin boilerplate helps you:
- Kickstart plugin projects with clean, consistent code
- Follow WordPress coding standards out of the box
- Save time setting up structure, files, and functions
- Avoid reinventing the wheel with every new plugin
- Separate concerns (admin, public, core logic)
- Improve readability and maintenance over time
File and Folder Structure
Hereโs a high-level look at what you get with the default WordPress Plugin Boilerplate:
my-plugin-name/
|-- .gitignore
|-- README.md
|-- uninstall.php
|-- my-plugin-name.php
|-- includes/
| |-- class-my-plugin-name.php
| |-- class-my-plugin-name-activator.php
| |-- class-my-plugin-name-deactivator.php
|-- admin/
| |-- css/
| |-- js/
| |-- partials/
| |-- class-my-plugin-name-admin.php
|-- public/
| |-- css/
| |-- js/
| |-- partials/
| |-- class-my-plugin-name-public.php
|-- languages/
Key Components Explained
1. Main Plugin File (my-plugin-name.php)
This file is the entry point. It initializes core classes and hooks into WordPress.
2. Includes Folder
Contains core loader class and classes for plugin activation and deactivation. These files manage setup logic and plugin registration.
3. Admin Folder
Houses all admin-related functionality like menus, settings pages, admin styles/scripts, etc.
4. Public Folder
Contains code that affects front-end users. Here, you register public hooks and enqueue styles/scripts for the front-end.
5. Languages Folder
Used for internationalization. Includes .pot, .po, and .mo files to support multiple languages.
How to Use the Boilerplate
- Download or Generate the Boilerplate
- GitHub: https://github.com/DevinVinson/WordPress-Plugin-Boilerplate
- Generator Tool: https://wppb.me/
- Set Your Plugin Details
- Rename files and classes to reflect your plugin name
- Use the generator or find/replace manually (wppb.me makes this easy)
- Begin Development
- Add logic to the
adminandpublicclasses - Register hooks in
includes/class-my-plugin-name.php - Customize the structure as needed for your features
- Add logic to the
- Activate and Test
- Install and activate your plugin in the WordPress admin
- Use
WP_DEBUGto catch any issues early on
Sample Hook Registration
Inside class-my-plugin-name.php:
private function define_admin_hooks() {
$plugin_admin = new My_Plugin_Name_Admin($this->get_plugin_name(), $this->get_version());
$this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles');
$this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts');
}
Benefits for Teams and Larger Projects
- Shared understanding of code structure across multiple developers
- Easier code reviews and onboarding
- Reusability of components across plugins
- Support for automated testing and CI/CD integration
When Not to Use the Boilerplate
The boilerplate is ideal for medium to large-scale plugins, but may be overkill for very small plugins or utilities. In those cases, a minimal custom structure may be quicker.
WordPress Plugin Boilerplate
The WordPress Plugin Boilerplate provides a professional starting point for building plugins using modern development techniques. Whether you’re working solo or as part of a team, this boilerplate enforces a structured approach that pays dividends in code quality, scalability, and maintainability.
Explore it. Fork it. Extend it. And build better WordPress plugins with confidence.
