Software Engineering in WordPress, PHP, and Backend Development

Tag: WordPress (Page 155 of 219)

Articles, tips, and resources for WordPress-based development.

The Usability of WordPress Featured Images

Featured images (also referred to as “post thumbnails”) are nice features to include in WordPress themes, but there are times where I question their implementation.

I know, I know: talking about stuff like this can come off as frivolous, but I think that if you deeply care about what you’re working on, then evaluating the decisions – every one of them – that go into your product matters.

And since featured images are a decision that need to be made when working in theme development matter, then it’s worth evaluating their implementation.

Continue reading

Your Own Instance of the WordPress Media Uploader

One of the nicest features of WordPress 3.5 was the introduction of a refresh of the WordPress Media Uploader.

For developers who aren’t familiar with the change, the short of it is a new version of the media uploader was built using Backbone.js and Underscore.js both of which are newer JavaScript libraries that introduce a different type of structure to creating JavaScript-intense web applications.

Sometimes, one of the challenges that comes with working with any new feature is the lack of documentation around how to take advantage of it. When that happens, you’re more or less left to dig into the core source code and/or the documentation for each of the specific libraries to learn how to use them.

Continue reading

Educate Your Users in Open Source Software

One of the things that I’m working hard to have released by the end of the month is the latest version of the WordPress Plugin Boilerplate.

The latest version has been in development for quite a while now (a lot has happened offline so, you know, that’s how it goes).

The last time that I really spent any time talking about this project was in November 2013. A lot has changed since then. Initially, I was planning on a minor upgrade with some of the following features:

  • Releasing the version has part of the 2.x.x versioning
  • Including a class specifically for administrative functionality
  • Fixing issues with symbolic links and textdomains
  • Including more TODO’s for users to find what needs to be changed
  • …and so on.

But when I got started on the next version of the Boilerplate, a lot of things changed. The short of it is that it’s being completely re-written from the ground up and the code and documentation are being split into to separate things for the sake of user education.

I’ll spend more time talking about the Boilerplate in a future, but one of the things that I wanted to share that’s related to running a project like the Boilerplate has to do with open source, contributions, lack of a vision, and how this can negatively impact your project and your users.

Continue reading

Stop Including Custom CSS in WordPress

One of the things that I think many, many young (that is: inexperienced) theme developers do is ship a custom.css file in WordPress. Years ago, I made the mistake so I’m just as guilty as the next person.

Unfortunately, this is something that’s still happening today – we need to stop including custom CSS in WordPress and use the native facilities to take advantage of the same functionality we’re trying to achieve with this particular file.

Here’s the thing: Normally I wouldn’t bother talking about something like this because the Codex does such a good job of outlining the proper way to introduce customizations into themes, but I recently received a comment (that I’ll paraphrase) in which I was told that:

In the real world not everyone uses child themes.

Odds are, many of us have heard the old cliché that:

The difference between theory and practice is that in theory there is no difference.

And when you’re talking about something like a complex algorithm for traversing, say, the shortest path across a graph over a large network, or when we’re talking about something like properly handling memory in embedded systems, talking about theory and the real world makes sense.

That is, all of those cases are important and are worthy of optimization, but we’re talking about a single CSS file.

We’re not talking about a complex system.

And it concerns me that those who are contributing to the WordPress economy through products aren’t taking the built-in features of the application seriously. It’s seen as some bit of impracticality that they don’t want to pursue.

But this introduces it’s own set of challenges that negatively affect theme development from both a developer and a customer standpoint.

Continue reading

How to Check if a WordPress Posts Exists by Its ID

I was recently having a conversation with a friend and fellow WordPress developer about the best ways to go about checking if a post exists given nothing but an ID.

For those who are experienced with the WordPress API, there are a number of ways to go about doing this. Functions and classes that exists for things like this are:

  • `get_post`
  • `WP_Query`
  • Running a direct query with `$wpdb`
  • …and so on

Each of these has its advantages and disadvantages, but of everything listed above, there are always two things I try to make sure that I do when working with simple functions (like checking on the existence of a post).

I try to make sure the function:

  1. Is as lightweight as possible
  2. Is as easy as possible to read within the context of the existing code

After all, months from now, you never know if you’ll recall why you wrote code a certain way nor will your team or your peers necessarily know why the code you selected is set in a certain way.

Continue reading

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑