< Back

MVC Shortcode Boilerplate Plugin for WordPress

I have been struggling with building on top of WordPress (WP) for as long as I can remember. One of the biggest development problems is figuring out whether you should do things the WordPress way, or completely hijack the request pipeline and design your own custom solution.

Prior to really understanding WP, I was more inclined for the latter approach. I consistently crowded the web root with a myriad of randomly named folders and files never following a particular pattern. Obviously, this propagated an immense amount of technical debt. A new developer would have no chance of understanding what I did without many hours of code inspection and frustration. There has to be a better way.

One of the better options, in my opinion, is a marriage between the WordPress way and a commonly understood development framework like Model-View-Controller (MVC). By following WP coding practices, you get a clean and organized file structure, and you can leverage cool things like short codes, custom post types, custom taxonomies and filters. Bringing MVC into the mix then provides the developer with a clear and consistent programmatic framework to structure (and separate) views from business logic. A pattern will help prevent the countless spaghetti-coded plugins that currently litter the WordPress.com plugin directory.

The Plugin

There are some more full-fledged WP MVC plugin solutions available for download, but I wanted something simple and light that developers could start custom development projects from. This is a boilerplate and is only intended for programmers. Documentation is sparse, but hopefully a MVC-minded background will help. Download instructions are below:

Download

Download from YSL here.

Installation

  1. Unzip the “mvc-shortcode-boilerplate” archive and move folder into your WordPress instance under wp-content -> plugins.
  2. In the WordPress administration site, click on Plugins and activate the MVC Shortcode Boilerplate plugin.
  3. To see the newsletter demo, create a new page and add this shortcode, [mvc_shortcode_registration_form], to the body.
  4. You can also manage submitted registrations in the administration-side by clicking on “Registrations”.

Going Forward

If this boilerplate is worth pursuing, I would like to make it modular and integrate the following:

  • Active Record
  • Page template and widget support
  • AJAX routing
  • Data types for Models

Also, if any developers are interested in making this an open-source initiative, please email me.

Connect with us

Thank You!

We really appreciate your interest in what we do.

We'll get back to you as soon as we can.