WordPress Plugin Library Saves You a Tone of Time

I’m sure you know that excitement when you start a new project. In this case, the project would be a new WordPress plugin that you are going to develop. And as with every new plugin for WordPress, you have to add the header comment and the new class, constructor, helper functions, etc.

Well, that’s pretty frustrating because you have to re-do the same thing every time like a robot. With that in mind, I thought I’ll just create a ‘boilerplate’ plugin that I’m going to use from now on for all my new plugins.

And that’s what I did but in time when I was creating more and more plugins for my own ideas or for the customers at MemberFix, I noticed that I had to constantly write the same helper functions and methods for some parts of the plugins and you know, that’s also repetitive work that I had to do over and over again.

So I got some of those repetitive tasks and added all of them to a small library that also serves as a boilerplate plugin that I’m using now for most of the new plugins that I’m developing.

I got to say that it made my life so much easier!

Let’s get through it a little bit, perhaps it can make your life easier too ๐Ÿ˜€


You have a couple of options to download it. I’ll list them below.


To install WordPress Plugin Library with git you just need to have git installed and to open a terminal window (or Windows Terminal if you are on Windows).

Navigate to the folder where you have the WordPress instance to the plugins folder. The path would look something like this:


And when you are in the plugins folder you have to enter the following snippet in your terminal:

git clone https://github.com/sorinmarta/wp-plugin-library

You are done! Now you should have a new folder that’s called ‘wp-plugin-library’ that contains the files of the library.


My less favorite option is also very simple to use. You just have to check my GitHub repo with the WordPress Plugin Library.

And while you are on that page you have to click on “Code” and “Download as ZIP”. You can follow this GIF if you need a visual example:


After downloading the library files you should have the following file structure:

 - controllers
  - index.php

 - helpers
  - index.php
  - wppl-helper.php
 - lib
  - index.php
  - wppl-form.php
  - wppl-loader.php
  - wppl-view.php

 - models
  - index.php

 - views
  - index.php

Most of the file names talk for themselves so I think you already have an idea of what they are doing. But let’s take the functions one by one and see what they are doing.

Also as you can probably see from the naming convention all the library files and classes have the ‘WPPL’ prefix so that it avoids naming conflicts and also respects the WordPress coding standards.


The WPPL_Loader class is simply a place where you can require all your files using the structure that is in place.


The WPPL_Helper class is a helper class that’s going to have helper static methods for various usages.


The ‘dd ‘ name stands for ‘die and dump’ which basically means that it will dump the parameter that it is given using the ‘var_dump’ native function of PHP and then it will end the process so that nothing that comes after it will run.

$value = 'Man, I really need to find out what I am';

string(40) "Man, I really need to find out what I am"


The ‘redirect ‘ method is helping with redirects of any kind. It can pass over messages and it is integrated with the WPPL_View class to also display the notices as either errors, success messages, or even regular notices.

Required Parameters
  • URL (required) – The location where the user should be redirected to
  • Type – The type of the message. Can be ‘error’, ‘success’ or ‘alert’
  • Message – The string it should display as the message
WPPL_Helper::redirect('https://huskystudios.digital', 'success', 'Sending some love ๐Ÿ’›');
The user will get redirected and they will see a green notice with the message value ๐Ÿ™‚


The WPPL_View class is a class inspired by Laravel’s ‘view’ function that helps you retrieve a view anywhere in the application.

The class constructor demands the name of the view file name when you are trying to create a new instance. The file name can also be a path if you have views in separate folders.

Important: The class is going to be looking for file names and paths that are inside the app/views folder of the plugin and it already has the ‘.php’ suffix so you don’t need to include it.

// The view file - app/views/settings.php

<h1>My awesome plugin is here!</h1>
<p>This is where I'm going to add my badass plugin's settings</p>
new WPPL_View('settings');

My awesome plugin is here!

This is where I’m going to add my badass plugin’s settings!


The WPPL_Form class is a bit more complicated than the other basic classes. It creates forms that can be directly processed using WordPress hooks for admin_post.

To create a new form you need to create a new instance of the class and pass a few values to the constructor. You can see more details below.


Required Parameters
  • Action – The name of the action suffix that will be expected in WordPress
  • Nonce – The value of the nonce that is going to be used for the security verification
  • Inputs – An array of arrays that will configure the form elements

The input has a few argument values that can be passed to the class.

  • Element (required) – The attribute is the attribute that sets the type of HTML node needs to be created. Which can be an input element or a select element
  • Type (required) – The type of the input (or select, or dropdown)
  • Name (required) – The name attribute of the HTML element
  • ID (required) – The id of the HTML element
  • Placeholder – The placeholder attribute of the HTML element
  • Value – The value attribute of the HTML element
  • Class – The class attribute of the HTML element

The select also has an argument that is required and a few optional arguments

  • Options (required) – An array of option elements (they are described below)
  • Name (required) – The name attribute of the HTML element
  • ID (required) – The id of the HTML element
  • Class – The class attribute of the HTML element
  • Name (required) – The name attribute of the HTML element
  • ID (required) – The id of the HTML element
  • Value – The value attribute of the HTML element
  • Class – The class attribute of the HTML element
  • ID (required) – The id of the HTML element
  • For (required) – The id of the parent html element
  • Label (required) – The text value that will be added to the HTML element
  • Class – The class attribute of the HTML element
new WPPL_Form('wppl-test-form', wp_create_nonce('wppl-test-form'), array(
        'element' => 'input',
        'type' => 'text',
        'name' => 'wppl-text-input',
        'id' => 'wppl-text-input'
        'element' => 'select',
        'options' => array(
                'name' => 'wppl-option-one',
                'id' => 'wppl-option-one',
                'value' => 'the first option'
                'name' => 'wppl-option-two',
                'id' => 'wppl-option-two',
                'value' => 'the second option'
        'name' => 'wppl-select-input',
        'id' => 'wppl-select-input'
        'element' => 'label',
        'id' => 'wppl-label',
        'class' => 'wppl-label',
        'for' => 'wppl-checkbox-input',
        'label' => 'Tick this if you are awesome'
        'element' => 'input',
        'type' => 'checkbox',
        'name' => 'wppl-checkbox-input',
        'id' => 'wppl-checkbox-input'
        'element' => 'input',
        'type' => 'submit',
        'name' => 'wppl-submit',
        'id' => 'wppl-submit'

A static function that will save up a bit of your time when you want to process the form information in the backend. You won’t have to check if the nonce exists and then validate its content. You can simply use this static method and it will do both of those.

$tag = "huksystudios-is-awesome";

$nonce = wp_create_nonce($tag);

WPPL_Form::check_nonce($nonce, $tag);
(bool) True


That’s pretty much it for the little library I’ve created. It is a work in progress and I’ll be working on new features in time.

But I’m also open to suggestions, so please let me know in the comments if you have any suggestions!

All done! ๐Ÿ˜‰

5 1 vote
Article Rating
Notify of
Inline Feedbacks
View all comments