WordPress

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

Updating a WordPress Post in the Save Post Action

For those who have worked with WordPress long enough, you’re likely familiar and comfortable with how hooks works – that is, you’re familiar and comfortable with the event-driven design pattern.

Sure, it’s a bit different than many other frameworks and foundations that use MVC, MVVM, and some other remix of the model-view paradigm, but I don’t think that’s really here nor there in terms of which is better. This is what WordPress uses and it’s easy enough – and powerful enough – to work with once you’ve got it.

But that’s not to say it’s not without it’s nuances.

For example, one of the challenges of working with event-driven design is understanding how hooks work throughout the page lifecycle, how it’s possible to actually get stuck in an infinite loop if you’re not careful, and how to work with the various hooks to prevent this from happening.

Thoughts on WordPress Developers, Communities, and Products

For those of you who are involved in working with building things for WordPress- specifically, premium plugins and themes – then you’re likely plugged closely into what many refer to as “the WordPress community.”

Granted, I’m not saying it’s not a community – it is – but it’s just part of the community, right? I mean, the word encompasses people who use WordPress to blog, people who are fans of the software, those who have contributed to it, those who build things with it, and so on.

All that to say, the community has a variety of facets.

And the challenge to this is that when we spend so much time with our subset of the community, it’s easy to accidentally develop a degree of tunnel vision such that we become at least partially focused on writing things, designing things, or buildings things with our part of the community in mind rather than our customers.

A Dilemma: Hiding Elements with The WordPress Theme Customizer

When it comes to working with the WordPress Theme Customizer, one of the options that you’re likely to see in other themes (or that you’re likely to introduce in your own themes) is an option that is responsible for toggling the visibility of an element.

For example, if a text box is empty, you may want to hide an element. Or, more simply, perhaps a user will need to click on an checkbox to toggle whether or not to display an element.

But this presents a dilemma: Either we can send all of the information to the browser and control its visibility using a class name, or we can send less code to the browser but lose a smooth user experience when using the Theme Customizer.

Steps To Writing Clean WordPress Code

I’d like to think that one of the things that most good developers continually strive for is writing the cleanest, most maintainable code possible.

Personally, I don’t know if there is an actual point at which you reach it – it’s the whole journey-not-a-destination thing – but that doesn’t mean that we shouldn’t continually aim to get better at what we do. In our case, that’s writing clean WordPress code.

The thing is, there’s only so far you can get on your own. You can read a number of books, follow the advice of some high profile programmers, and read as much of the “academic” material that you can get your hands on – and I think all of the above is great – but, at the same time, it only goes so far.

To that end, I think it’s worth seeking out other people in your same field to help provide some level of mentorship on how it relates to writing clean code because here’s the thing:

As much material as we can read written by other people, nothing beats interacting with those who are writing code in the same language(s) for the same APIs under the same coding standards and who are farther along than you in experience.

How To Define a New WordPress Cron Schedule

Last year, I shared how to properly setup a WordPress cron job in which I walked through the process of defining a cron job in the operating system so that a job fires as a true scheduled task (rather than the faux tasks that WordPress provides).

This isn’t to say that the native WordPress scheduled tasks are bad – they just may not work as expected for those who are used to native cron jobs.

Another limitation of the the WordPress scheduling system is that it defines only a handful of intervals in which your tasks may run. These include:

  • hourly
  • daily
  • twicedaily

And these are fine for a lot of tasks, but if you’re looking to define a new WordPress cron schedule, you’ll need to define a custom filter.

The Importance of Using Domain Language in WordPress

In building software – especially at the enterprise level – one phrase that’s used to describe the work that goes into understanding what all needs to make up an application is that of the “problem space” or the “problem domain.”

This is important because part of the process of understanding the problem domain is learning the language, the terminology, and the concepts that go into building an application.

For example, say you’re building a job board. You’re likely to have something like:

  • Job Posts
  • Resumes
  • Recruiters
  • Employers
  • Employees
  • Candidates
  • …and so on

These ideas are then taken and ultimately converted into code.

Sometimes, developers will use the terminology associated with the problem domain (and this is part of domain-driven design) in their code; other times, the problem may get solved but the code may not completely reflect the problem space at the code level.

At any rate, one of the things that I see – as designers and/or developers – doing is using terminology that is more frequently associated with how we view WordPress than how users do.

Kaizen and WordPress

According to Wikipedia, kaizen is defined like so:

Japanese for “improvement” or “change for the best”, refers to philosophy or practices that focus upon continuous improvement of processes in manufacturing, engineering, business management or any process.

Generally speaking, this is used to talk about the continuous improvement of a product. It’s also a core idea of lean manufacturing that has also been adapted into lean software development.

Anyway, the idea isn’t anything new and I honestly think now, more than ever, more people are familiar with the idea (even if it isn’t practiced) than ever before especially because some applications use the word in the release notes for their application.

Kaizen in Paper By FiftyThree

Paper By FiftyThree mentions it with nearly every release.

As far as building products is concerned, this is something that I think many designers and developers want to do (if they aren’t already doing it, of course), but it are sometimes hindered by the nature of their environment.

By that, I mean that can we do continuous improvement – that is, can we practice kaizen – on projects that aren’t deployed on any type of particular schedule?

Using LighthouseApp For WordPress Issues

One of the things that I love about GitHub is how they’ve done a great job integrating source code, milestones, tickets, pull requests, and so on.

But if you’re working with WordPress, not all projects all on which you work will use GitHub.

Case in point: If you’re selling a theme on WordPress.com or if you’re working on a plugin that is hosted in the WordPress Plugin Repository, then you’re going to be using Subversion as your source control system. But this doesn’t mean that you have to sacrifice the work flow of milestones, tickets, and so on.

It just requires that you use a third-party solution. For example, for the past couple of months, I’ve been using LighthouseApp as my issue tracker of choice for Mayer.

Two Versions of WordPress Themes (“Is It Worth It?”)

When it comes to selling a theme for both WordPress.com and for self-hosted installations, one of the questions that I find myself asking is:

“Is it worth maintaining two repositories for the same theme?”

And I wonder this because when it comes to maintaining a codebase of a theme on WordPress.com and a version for the self-hosted version of WordPress, you can make the case that there’s no need to have a difference in the version of the themes.

But for anyone who has worked in both variants of WordPress, then you know there’s actually little bit in variation.

The Third Version of Live Theme For WordPress

Comments are closed on this post. Please leave comments on the original blog post.

About four years ago, I had the pleasure of working with a team to help deliver the first iteration of Live Theme for WordPress; however, as the team leaned out, changed directions, and paired down our product focus, we sold the product to someone else for continued development and maintenance.

To make a somewhat long (perhaps even boring) story short, I’m currently working on the third version of Live Theme for WordPress.