Software Engineering in WordPress, PHP, and Backend Development

Category: Articles (Page 114 of 258)

Personal opinions and how-to’s that I’ve written both here and as contributions to other blogs.

Read All Files of a Certain Type (Using PHP)

Let’s say you’re working on a WordPress file that has to import data from a very large file. To avoid PHP timeouts, it helps to separate the files and then import then in pieces (or in chunks, because that word is more fun :).

But to do that, it implies you’re capable of taking a file and splitting it into some smaller files.

When you do this, I assume that each smaller file will follow a particular naming convention (like file_0.txt, file_1.txt, and so on).

Read All Files of a Certain Type

So when it comes time to read each file, how do you do it?

Continue reading

HTML Data Attributes, JavaScript, and Databases

HTML data attributes are one of the neat features of HTML5 that give us a lot of flexibility.

HTML Data Attributes to save information to the database

We can use them for a variety of things (and abused for just as much), but the general idea behind the attribute, according to MDN, is this:

HTML5 is designed with extensibility in mind for data that should be associated with a particular element but need not have any defined meaning. data-* attributes allow us to store extra information on standard, semantic HTML elements without other hacks such as non-standard attributes, extra properties on DOM, or setUserData.

Yes, it reads a bit long. Consider it like this, though:

Data attributes provide a way to save extra information about an element in a semantic way without using conventional hacks (that so many of us are used to using).

Though there are a variety of ways in which this attribute can be used, I’ve found it to be useful when working with a front-end element that’s part of a dynamic set of larger elements.

Further, any one of these elements will be used via JavaScript to send data to the server via Ajax.

Here’s a simple example of how to use the HTML data attributes and Ajax.

Continue reading

WordPress Tools and Our Responsibility

Once you’ve worked in the WordPress economy long enough, you become familiar with the larger players, smaller players, and everyone in between. You also gain a level of awareness with the various things people use as their WordPress tools.

The thing about “tools” is that it’s such a generic term, it depends on what it is you do with WordPress that defines what your tools may be.

  • If you’re someone who creates sites for others through the use of off-the-shelf products like themes and plugins, then your tools may include a suite of various themes, plugins, and preferred hosts.
  • If you’re a developer, then you may have a preferred piece of software for your local development environment, version control, staging environments, preprocessors, and so on.
  • If you’re a designer, then you may have your sources of inspiration, your tools for editing photographs, designing collateral, and so on.

Regardless of what you do within the WordPress economy, it’s important to make sure that you know with whom you’re doing business.

And this sounds a bit like obvious advice, but hang with me for a few paragraphs.

Continue reading

WordPress Plugin Design: Namespaces and Autoloading

WordPress plugin design is not something that we often read about explicitly, is it? Instead, we often talk about functionality, performance, and things like that (not that they are unimportant, but they are just one part of the conversation).

When it comes to WordPress plugins, the functionality one offers may range from very small to incredibly large. And this is how it is with almost any type of product, isn’t it?

WordPress Plugin Design: WordPress Plugins

“Plugins extend and expand the functionality of WordPress. 46,537 plugins with 1,392,817,734 total downloads are at your fingertips.”

Sometimes, I think we have a tendency to want to say “focused, and lean” with smaller plugins as if a larger plugin can be described as such simply because of its nature.

But that’s not true.

There are very small, well-built plugins that offer one or two features. And there are large plugins that are also well-built that offer a plethora of features. On the flip side, either type may also be unfocused, cobbled together, and may be anything but what we’d like it to be.

When you look at the landscape of all that’s offered regarding WordPress plugins, it raises a few questions (at least from a developer’s perspective).

I’m going to cover them all in this post, too! Or not.

But seriously, one of the things I’ve been thinking about is this:

At what point do you begin organizing your code, so it includes namespaces, autoloading, dependency management, and other such features that take it beyond a collection of classes or functions?

This implies a lot about a given hosting environment and a developer’s level of familiarity with PHP and experience with other tools, but that’s secondary to the question (and I’ll cover all of that momentarily).

Continue reading

Custom WordPress Administration Pages

Creating custom WordPress administration pages isn’t always necessary if you’re going to use something like the Settings API. But if you’re working on a feature for a plugin or something that extends WordPress core in a way that requires more flexibility, it’s something that may be useful.

Custom WordPress Administration Pages

In some respects, it gives you more control, but you may also need to work on writing your system for displaying messages in the administration area, handling sanitization and validation, and so on.

It’s a lot to consider, and there’s a variety of use cases. In my latest series on Envato, I begin walking through some of the foundational requirements for working on custom WordPress administration pages.

Continue reading

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑