Software Engineering in WordPress, PHP, and Backend Development

Author: Tom (Page 137 of 428)

Programmatically Add a WooCommerce Variable Product

Adding a custom WooCommerce variable product isn’t something that’s terribly difficult given the hooks that WooCommerce provides, but there’s always a bit of context that helps when giving an example like this, right?

Last week, I shared a small bit of a code that shows how to add a custom input field to a WooCommerce product. And in that post, one of the things I shared what how I like how easy it is to create UI elements using server-side logic.

WooCommerce Variable Product: Creating the UI

And working with variable products is no different. It is, however, a matter of using a different hook.

Continue reading

Use and Abuse Singletons in WordPress

For those who make a living by creating custom solutions for others using WordPress, you likely have your approach to how you structure the foundation of your typical plugin. And I think that’s a Good Thing™.

If you’ve read any of my previous posts, you know that I generally prefer the object-oriented approach to building plugins so there are a number of patterns, common solutions, and architectural decisions that I try to employ from project-to-project.

I’m not dogmatic about it, though:

If something new comes along, I’m willing to give it a try. Similarly, if someone I’ve been using for a while is criticized, I’m willing to take a look but that doesn’t mean I’ll change it.

In short, I need a lot of information to sell my on why I should change something that works, that’s maintainable, and that reads well for other developers.

And one of the points of discussion that comes up periodically is the idea of using Singletons in WordPress development.

Continue reading

Design Patterns and WordPress (And Resources!)

For whatever reason, it doesn’t seem common that we talk much about design patterns and WordPress. And that’s odd to me.

Maybe I’m not talking to the right people, maybe I’ve got my head in the sand, maybe it’s just not something about which people share much information, or maybe people who work with WordPress don’t care that much about design patterns at all.

Design Patterns and WordPress

The architecture of WordPress is not the same as using design patterns iin WordPress.

But if you’re using WordPress and you’re building more than a theme or a simple plugin, the odds of you building something more advanced and not taking advantage of design patterns seems highly unlikely.

Whatever the case, if you’re someone who’s working on advanced solutions – perhaps web applications, perhaps having your components talk to third-party components, or whatever the case – then it wouldn’t hurt to have a reference of popular design patterns and antipatterns would it?

Continue reading

Creating Custom WooCommerce Input Field

I’ve been working on a project that introduces a few new options into a standard WooCommerce installation, and one of the features calls for adding a custom WooCommerce input field.

WooCommerce

In WordPress, creating settings pages has its process. That is, you create the necessary options group (if needed), settings fields, values, and so on. You introduce any markup that’s needed, validation, sanitization, and so on.

And all of that is needed when it comes to working with WooCommerce, but one of the things that I like is how the API for the plugin supports creating input fields with server-side logic.

Continue reading

Append WordPress Page Content From the Database

When we – or the people for whom we’re working – create WordPress page content, it’s usually through the editor or maybe through some other client front-end that we’ve created.

But what about the case where there’s something specified using a custom settings page that controls the content displayed on a specific page?

This is getting into custom implementation territory so let me try to give a bit more context to this whole situation.

Continue reading

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑