Software Engineering in WordPress, PHP, and Backend Development

Author: Tom (Page 271 of 428)

WordPress Meta Boxes: Separating the Logic

This is the second post in a series on how to achieve simplicity with WordPress meta boxes.

In the previous post, I talked a bit about how working with WordPress meta boxes can be a bit of a hassle especially if you’re used to doing so in such a way the keeps all of the logic contained within a single file and a handful functions.

For example, if you’re working on a theme, then it’s likely that you’ve got a set of functions declared either in your functions.php file or file referenced by said file that is responsible for making a call to add_meta_box and all of the necessary arguments for rendering the meta box.

If you’re working on a plugin, it’s likely that this isn’t all together different; however, you may be approaching this from an object-oriented perspective. If that’s the case, then you may have a similar setup as above which isn’t really that different except you’re using classes and functions.

Continue reading

WordPress Meta Boxes: Aiming for Simplicity

This is the first post in a series on how to achieve simplicity with WordPress meta boxes.

For anyone who has does any kind of work with WordPress meta boxes, you know that it generally consists of the following steps:

  1. Define the meta box
  2. Define the callback functions responsible for displaying the markup

Pretty simple, isn’t it?

Of course if you’re looking to introduce a more advanced functionality into your meta box then you’re likely going to want to introduce stylesheets, JavaScript dependencies, nonce values, and perhaps even tabs to logically separate the options.

Given the fact that I’ve recently looked at some of the various ways to save data in WordPress meta boxes, I thought it might be work sharing one way to help separate the business logic from the presentation logic as it relates to incorporating WordPress meta boxes either in themes or plugins.

Continue reading

The Art of Solving Problems in Your Sleep

I don’t consider myself a “creative” – I think that term is usually designated for designers, artists, and illustrators, and other types. Developers – although we create things – are creative in a different way.

It’s more about problem solving, I guess.

Anyway, one of the things that seems to be the most common among people of the similar trade is the challenge that comes with having to solve problems that we’re stuck on during the daily grind.

I can’t speak about designers (though I know this is something that affects those who I do know), but in terms of developers, I know that the problem works something like this:

At some point during a project, we get mired in a problem and we’re unable to solve it. The more we try to solve it, the more the frustrated we get. Ultimately, we step away from the computer, but what happens in a few hours?

We end up solving the problem while focused on something else.

It’s an interesting thing, and it’s something around which plenty of research is done (and, I’m sure even has a proper name for it), but the point of all of this has nothing to do with mentioning the fact that this exists.

It’s how we – as developers or even those creative types – can leverage it to our own success. Continue reading

Looking at the Next Version of Dev Practices

For a little over half a year now, I’ve been running (or simply managing, at times) a Tumblr blog called Dev Practices. The whole idea behind the blog is simply this:

A day in the life of a developer as illustrated by GIFs.

But I’ve been surprised. The site’s been a lot of fun to manage, people have been contributing to it, and there’s a backlog of at least a month’s worth of content.

So, like any developer at this point, I’ve started thinking about Dev Practices 2.0 (of course, I should probably come up with a better than than name, right?)

Continue reading

Two Ways to Save Meta Box Data in WordPress

Recently, I was having a conversation with a friend about some of the various ways to serialize the values that are present within a collection of meta boxes that are defined for any type of post – be it a post, page, or a custom post type – within WordPress.

For example, imagine that you have a custom post type that has, say, four different meta boxes that are available below the main content area.

These meta boxes can be laid out in one of two ways:

  • The meta boxes can be listed individually with each meta box having its own set of values. Think of WordPress’ Excerpt field, Discussion field, and and Sharing Field.
  • The meta boxes can all be contained within a single container accessible by individual tabs.

The question is does the way that the meta boxes are displayed influence how the values are serialized in the database?

Continue reading

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑