WPPB: WordPress Plugin Boilerplate

The WordPress Plugin Boilerplate (WPPB) is a foundational framework that accelerates the plugin development process for WordPress coders globally. It obviates the need for developers to code from scratch by providing an out-of-the-box standardized structure with every plugin following a similar pattern. The plugin boilerplate alleviates the pain of the initial setup that devours time and instead helps them dive right into the main functionality of their plugins by taking care of minor details. In addition, it also results in a neat and consistent plugin, that adheres to WordPress coding standards.

WordPress plugin development comes with specific organizational standards, patterns that have to be implemented to make sure every plugin fits into the platform and stays true to its structure. The use of WPPB lets WordPress coders start their development journey without having to worry about such standards as the entire housekeeping of a WordPress plugin is done for you in a professional manner. One such WordPress standard is the segregation of admin-facing and public-facing functionalities of plugins that, when followed, allows for better organization, easy scalability and cross-project consistency. In larger plugin projects with more than one developer on board, such coding conventions help developers orient themselves quickly on a new codebase without having to refer to documents or wait for mentors to explain the structure.

In addition, WPPB is particularly useful because it promotes the following of best practices from the get-go. In particular, the separation of logic and assets in the plugin itself helps to make sure any WordPress plugin created using it adheres to some general security and performance guidelines set by the WordPress community. These include but are not limited to functions like escaping output or sanitizing user input as well as ensuring that any verification of nonces from forms, inputs, and other functionality has been correctly added to the code. For many developers, especially those just beginning to learn how to code WordPress plugins, the boilerplate can provide the peace of mind that comes from knowing that the base code won’t have easy-to-fix holes which could, if left unattended, compromise the site the plugin is added to.

WordPress Plugin Boilerplate’s design principles follow object-oriented design (OOD) patterns that group similar features together for easier understanding and expansion later down the line. The architecture is compartmentalized such that the core logic of a WordPress plugin can be extended or added to seamlessly without interfering with other plugin functionalities or changing any part of the core structure of the plugin boilerplate. All elements in a plugin following this design patterns such as the activation class, custom post types class, meta boxes class, form handling class and the loader class, have a single reason to exist. They are coherent and complete by themselves. This design of the boilerplate makes debugging and development of different functionalities of the same plugin faster.

Internationalization and localization are baked into WPPB right from the start, too. The boilerplate includes templates for language files, meaning plugin creators who want to make their plugin translatable will have a head start. Translation files are critical if the target market for the plugin will be non-English-speaking audiences, as this makes the plugin more user-friendly to a wider range of potential users. Internationalization and localization are easy to overlook when planning a plugin, and WPPB makes including this functionality from the start much less daunting.

Finally, and perhaps one of the most useful aspects of WPPB is the amount of documentation and inline comments throughout the source files. The boilerplate itself has WIKI documentation that provides an overview of the source files and the thought processes behind their creation and architecture. On a file-by-file basis, functions and classes are well commented in most cases, usually with PHPDoc standard style comments which give both a description of purpose for a class and instructions on how to use or override it. This can make it much simpler to jump into WPPB as a beginner, or to provide handover to other developers if a plugin has to be taken over by a different team or created as part of a freelance project.

WordPress coders who follow this boilerplate code can reach a global audience. Internationalization is an aspect that WPPB takes care of with inbuilt support to support translations of strings and other features in the WordPress plugin so that a global audience can use it. In the boilerplate’s spirit of building well-coded and documented plugins that are standardized, it also offers support to build well-structured, easy-to-understand plugins to WordPress developers.

The WPPB also has a side-effect of forcing a transition from procedural to object-oriented plugin design. This helps to both make the code more reusable and more easily testable, as each piece of a plugin is broken into separate classes which are then responsible for their own functionality. This refactoring of code to place more emphasis on classes and objects, rather than procedural code, is a big help to new developers who may not yet be used to writing object-oriented code in PHP but have the need to learn for professional plugin development.