2 New WordPress Plugins – OOP Plugin Boilerplate and MU Utility Plugin

I’ve done a lot of WordPress plugin development lately and thought I’d share some of the great little tools that I’ve used during creation. To start giving back to the community, I’ve decided to make public my OOP WordPress plugin boilerplate and my Utility Functions MU plugin – both valuable tools that I use whenever I’m building a new masterpiece with WordPress.

WordPress Plugin Boilerplate

Since plugin creation is an often done thing of mine (I think I’ve written at least 20 or so for private projects, some plugins of which are actually in the WordPress.org repository), I’ve created a boilerplate to start from. This boilerplate plugin is a basic Object Oriented PHP base with a pre-built options page with form submission, a route handler (for custom submission, AJAX and page rendering), activation and deactivation actions, automatic admin panel JavaScript and CSS loading, string sanitization function and is localization ready.

Download WordPress Plugin Boilerplate
Requires: WordPress 3.0+, PHP 5+

MU Utility Plugin

There are often a few standard functions I like to have available to me when I’m building a WordPress site. This plugin can run as a regular plugin, but I recommend placing it in your mu-plugins folder to make sure that the functions are available to all your other plugins as well as your theme. This plugin is a combination work of myself and jamie3d. This plugin includes the following functions:

  • abbr_number() – Abbreviate a large number to a short string, e.g. 1,000,000 to 1M
  • sanitize_data() – Sanitizes data using wp_kses() methods. Can process multi-dimensional arrays of data.
  • strip_tags_truncate() – Strips tags and truncates text to a specified length
  • _d() – Simple debugging function. Pass it a value and it will print_r() to the page wrapped in a <pre> tag. Can also var_dump() for more verbose debugging.
  • slugify() – Creates a URL safe slug from any string
  • truncate_text() – Simple truncate text function with trailing suffix

Download MU Utility Plugin
Requires: WordPress 3.0+, PHP 5+ 

10 Replies to “2 New WordPress Plugins – OOP Plugin Boilerplate and MU Utility Plugin”

  1. Nice work on plugin boilerplate!

    I’m starting on wp plugin development, but the book I’m reading don’t talk about OOP. I will keep your boilerplate as a reference for next projects. Thank you!

    One question, where do I include lib/template-functions.php?

    1. Better late than never, dunno if you’re still interested in using this plugin or not, but to answer your question any .php file in the lib folder will automatically be loaded by this plugin. You can see the glob() loop in the main class’ __construct() method.

  2. Thanks for sharing OOP Plugin Boilerplate. can you provide the repository link please. so that I can able to track if there are any further updates to this code or any contributions which are under progress.

  3. Hmm, this looks really interesting, I haven’t looked at the code properly yet. I’ll have a browse when I’m not at work 😉 .. After skimming over it quickly, it looks like it could be just what I’m looking for.


  4. I ran your boilerplate plugin, looks great, but the scripts and styles aren’t enqueing…

    I just uploaded the boilerplate as a test, so nothing was changed…

    Any ideas? FYI, I am using version 3.3.1

    Thanks for the help,


    1. Hey Luke, sorry about that. I’ve updated the plugin to enqueue the admin scripts and styles properly. They were being registered too early in the old version.

Leave a Reply