DM Blog

Enchufe: A Modular WordPress Plugin


I’ve been using my own WordPress plugin and custom theme since around 2009 or so. During that time, I’ve blogged about WordPress and posted some example code now and then. I contemplated making my plugin available for public use but ultimately decided against it since I didn’t want to have to deal with support requests… Even still, I’ve learned a lot from reading other people’s code, so I always felt like I should open-source it so that other WordPress developers might be able to learn from it too.

You can now look at the code, download it or fork it on GitLab. This modular WordPress plugin and custom theme will mostly benefit developers looking for sample code. Everything is commented extensively.

Here’s a list of the modules that are included in the repository:

  • Archives — generate a JSON feed of archives
  • Cache — cache WordPress content and send cache headers
  • Comments — generate comments as standalone HTML, load them via Ajax
  • DM Blog — miscellaneous fixes and optimizations to WordPress
  • Feed — change the default RSS feed
  • GeoJSON — generate a GeoJSON feed of blog posts
  • Headlines — generate a JSON feed of the latest posts
  • Metabox — add a metadata box to the post edit screen
  • Minify — minify HTML to remove whitespace
  • Settings — add a settings/options page for the plugin to the WordPress admin
  • ShortCodes — easily add new shortcodes to WordPress using simple HTML+PHP templates
  • ShortLinks — handle shortlinks without the need of query strings
  • Sitemap — generate a simple sitemap.xml file whenever a post is modified
  • Subscriptions — allow people to subscribe to email updates

It’s no secret that having too many plugins can slow WordPress to a crawl, so by putting everything into a single modular plugin, it was not only much more efficient and quicker to load, it was also a lot easier to maintain. It’s like having many plugins in one but without having to repeat yourself with duplicate code, and adding more functionality is as easy as dropping a PHP class into the classes/modules folder and it’ll autoload as needed.

I hope this helps! I’m now in the process of creating my own server-less static generator on AWS so I likely won’t be blogging much about WordPress anymore…