Tom McFarlin

Software Engineering in Web Development, Backend Services, and More

Page 141 of 429

Learn “WordPress JavaScript” (And What That Means)

Now and then, I’ll stumble across a blog post, question, or comment that talks about WordPress JavaScript as if it’s a different type of or variant of JavaScript that exists solely within the WordPress application.

For those who have been working in web development for a long time, this seems like a silly statement, but if you’re brand new to web development (regardless of your age), then this is something that might be a bit confusing.

After all, it’s not like the JavaScript standard is cut and dry right now, right? But I digress.

Furthermore, WordPress includes jQuery, jQuery UI, Backbone, and so on. So when someone wants to work with JavaScript within the context of WordPress, what are they actually talking about?

And the answer is, unfortunately, “it depends.” But it does: It depends on the type of work you’re doing and where you’re focusing your efforts.

But this brings us back to the original problem: How do you learn “WordPress JavaScript” if you’ve never even touched JavaScript?

Continue reading

Working with Associative Array Values in WordPress

Spend enough time working in WordPress, and you find that a lot of data is often held in arrays (and multidimensional arrays, at that). I’m not arguing whether or not this is a bad thing or a good thing; it’s more of an intermediary step between grabbing something from the database and then rendering it on the page.

As you venture into the world of WordPress development, though, and you aren’t necessarily sure how you want to manipulate some of that data before rendering it, saving it, or working with it, you may ask yourself the following question:

How do I read the associative array values in WordPress?

And if you have experience in PHP, this isn’t something that’s terribly difficult. But if you’re working with an existing structure or trying to extend or manipulate something that already exists,

Associative Array Values: Look at all the serialized options.

Look at all the serialized options.

But if you’re still learning the ropes and you start trekking down the PHP manual, you’re likely to find something like array_values or array_intersect_key or something like that only to find out that you’re more confused than when you’ve started.

So what are you to do?

Continue reading

Should We Use PSRs or WordPress Coding Standards?

It probably gets a bit tiresome to talk about coding standards, practices, and things like that when you’re trying to focus on simply getting things done.

And though I get it, I also think that having standards and practices – at least within the context of your team – can go a long way regarding being productive, writing maintainable code, and having things in place to help with maintenance over time.

PSRs or WordPress Coding Standards: The PSRs

All of that’s beside the point, though. In the last few years, I’ve found that WordPress – at least those who work on the server-side – usually come in two flavors:

  1. Those who follow the WordPress Coding Standards,
  2. Those who follow the PSRs.

I think there are good reasons for choosing either one. Naturally, I’d say that because I’ve almost always used the WordPress Coding Standards (I have very few exceptions), but I understand the choice to use the alternative as well.

PSRs or WordPress Coding Standards: The WordPress Coding Standards

And it’s something I’m beginning to consider doing, too. But I’m curious, for anyone who’s used both or who has an opinion (strong or otherwise) on which one and why to share.

Continue reading

Safely Perform a WordPress Admin Redirect

A few posts ago, I talked through the process of creating your custom WordPress admin page (and listed reasons as to why you may want to do this rather than using an existing API). One of the challenges of doing this, though, is knowing how to set up a WordPress admin redirect.

That is, let’s say that you specify some options – or perhaps you don’t – and you need to be able to display a custom message. Or maybe you want to do some processing on the backend and then show the results on the front-end.

Whatever the case, one of the challenges of not using one of the existing APIs is being able to correctly setup a WordPress admin redirect so that it takes the user back to the page they were on, but also does so with whatever messaging you want to display.

Continue reading

WordPress REST API Example (One of Many)

With the second-half of the REST API merge confirmation coming to WordPress 4.7, it’s safe to say that there are going to be there clearly be more than one WordPress REST API example made available in the next few months.

Then again, there are examples that already exist because it’s possible to include the REST API in your project as a plugin, but I digress.

One of the neater, smaller examples that I’ve recently come across is by Brian Krogsgard.

WordPress REST API Example: By Brian Krogsgard

Not only does it show a WordPress REST API example, it shows how to use it in the context of a Rect applications.

Continue reading

« Older posts Newer posts »

© 2026 Tom McFarlin

Theme by Anders NorenUp ↑