Droplet Wordpress Plugin Framework

Sat, 02/17/2018 - 15:50

For a time I was working on an MLS plugin for a real estate website company and I had previously began grouping functions I would use regularly and classes, etc...

I decided to build a framework add-on for Wordpress. The result was a plugin I called Droplet. ( I was completely unaware of Drop-ins at the time ).

I was also unaware of namespaces at the time and so to reduce load the program had a class that literally included sub classes as were required. It was sort of like a hook as it it had a main class that used a list of public static methods that wrapped require_once calls to a path that then allowed a list of parameters to instantiate the class.

It also contained a general method that allowed the user to call any sub-class located within a custom classes folder by using a standardized naming convention. 

The design allowed any new plugin that was droplet plugin could inherit from the framework. The folder convention of the new plugin required a convention as well so I wrote a command-line script to create a new empty plugin on the fly.

The folder convention had folders for configuration, classes, administrative post pages, running ajax functions, as well as css and javascript and finally because I don't like to rely on the Wordpress cron there was a folder for using the server cron.

The base plugin had an administrative interface allowing the admin to turn on and off debugging that appended to the footer of the site load times and other useful information.

The plugin created a row in the wp_options table as a namespace for the droplet and subsequent child plugins.

It works quite well and was easy to deploy.

 

 

Tags