Including Custom Templates in Our WordPress Plugins There's a common set of steps we can use when including custom templates in our WordPress plugins.

I think that one of the more underrated aspects – or perhaps one of the rarely discussed aspects of custom plugin development – is the ability to include custom templates in our WordPress plugins.

And, to be honest, I get it: I’m one who is pretty staunch on what should a plugin and what should be a theme.

That is:

  • themes are for presentation,
  • plugins are functionality.

If I include templates in a plugin, am I not doing the same thing as when developers include functionality in their themes?

As with so many things in development, I think it depends. I mean, adding a lot of functionality that locks you into a theme is something of which I’m not a fan. Similarly, if you have a plugin that is meant to showcase data on the front-end and is theme agnostic, then it makes sense.

So you have to be judicious in your decisions.

Regardless, there’s a common set of steps we can use when including custom templates in our WordPress plugins.

And that’s what this post is going to show.

Continue readingIncluding Custom Templates in Our WordPress Plugins There’s a common set of steps we can use when including custom templates in our WordPress plugins.

Don’t Pollute the WordPress Options Table Don't just toss data into the options table because it doesn't fit anywhere else.

I’m a fan of short release cycles. Depending on the project, the length of the cycle will vary, but for many of the types of projects on which I work, I aim to have two-week release cycles.

Further, there are times in which I’m working on a project for someone where environmental variables are necessary so the code knows if it’s running in development, staging, or production.

And this can be achieved a different way depending on the needs of the project. Sometimes, a configuration file will work, sometimes query string variables can work, and other times I think it’s reasonable to store a setting in the database.

Don't Pollute the WordPress Options Table: The Options Table ERD

But, as far as WordPress is concerned, I think we shortcut better design decisions and throw information in the database, specifically the options table, when alternatives may be better suited.

Continue readingDon’t Pollute the WordPress Options Table Don’t just toss data into the options table because it doesn’t fit anywhere else.

WordPress Widgets: Refactoring, Part 13 Here, we finalize the updated version of the WordPress Widget Boilerplate.

We’re finally at the final post of the series on refactoring the WordPress Widget Boilerplate. By the end of this post, we’ll have the development branch of our code done, and we’ll be ready to merge everything into the master branch.

There is, however, still a bit of work to do. Namely:

The last thing we’re going to look at after this is tightening up some of the conditional logic along with a word about caching data (since we’re already doing a bit of that in earlier posts).

So those are the two things we’re going to be looking at in this post. Specifically, we’re going to look at handling conditional logic for the front-end and then how to implement basic caching.

Continue readingWordPress Widgets: Refactoring, Part 13 Here, we finalize the updated version of the WordPress Widget Boilerplate.

Suggestions for Organizing Procedural Code How I write WordPress plugins using procedural programming versus object-oriented programming and how I go about organizing procedural code.

For as much as I write about – and am a fan of – object-oriented programming, I don’t write much about the times in which I’m working with a procedural code base.

Procedural programming is a programming paradigm, derived from structured programming, based upon the concept of the procedure call. Procedures, also known as routines, subroutines, or functions, simply contain a series of computational steps to be carried out.

Sometimes, I come by this from the requirements of a project, sometimes it’s from a project that I’ve inherited, or sometimes because of something else.

I think it’s important that, as programmers, we don’t hold one paradigm so high that we shy away from working with other ways of writing code. After all, the act of writing code is, at its core, about solving a problem.

How the problem is solved may be considered secondary.

Regardless, whenever I’m working with a code base; however, it’s written, I still try to make sure it’s organized in a way that’s cohesive, as easy to follow as possible, and is able to be maintained over time.

Organizing Procedural Code

I thought I’d share how I approach writing WordPress plugins using procedural programming versus object-oriented programming and how I go about organizing procedural code.

If nothing else, perhaps this will give you some ideas for a current or future project.

Continue readingSuggestions for Organizing Procedural Code How I write WordPress plugins using procedural programming versus object-oriented programming and how I go about organizing procedural code.

WordPress Widgets: Refactoring, Part 12 We're going to working on the area of the code that renders information for the user on the public-facing area of the site.

As far as refactoring the WordPress Widget Boilerplate is concerned – especially given how far we’ve come since the project started eight years ago – we’ve done a lot of work.

We’ve brought it up to a far more modern standard and we’re making it far easier to work with it such that building future widgets should be easier. And this is not only from the standard of the boilerplate but from an object-oriented standard so that maintenance and code quality is higher.

In the last post, we wrapped up much of the work for the administration area and are ready to begin our work on code for the front-end.

We said:

Next, we’re going to look at rendering content on the front-end. We’re nearing the end, of the refactoring of the Boilerplate but there’s just a bit more to do before we’re ready to merge it into the master branch of the codebase.

So in this post, we’re going to pick up there. Now if you’ve been following along up to this point then you should have everything you need from the develop branch.

If not, be sure to pull it as that’s where we’re going to pick up in the remainder of the post.

Continue readingWordPress Widgets: Refactoring, Part 12 We’re going to working on the area of the code that renders information for the user on the public-facing area of the site.