Software Engineering in WordPress, PHP, and Backend Development

Category: Articles (Page 109 of 258)

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

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

Programmatically Set the WordPress User Role

When using WordPress, it’s one thing to set the WordPress user role using the provided interface. And this is what we do if we’re working as administrators of a particular site.

But say you’re working on a project, you need to import users and, as part of the process, set the WordPress user role in the context of the import process.

This could come as importing a new user, or it could come as updating an existing user. It doesn’t matter so much as there is a need to set a user role with working with a user.

The WordPress API makes this pretty easy, but there are two things to understand that, if missed, can result in basically overloading the user with multiple roles.

Here’s what I mean.

Continue reading

Product Demos via Screencasts (Go for Video!)

If you’re working remotely or as part of a distributed team that is building a project for clients (versus something internal), having a way to give product demos is something that can be incredibly helpful.

I know, I know: The term “product demos” sounds like something you give after a product is complete. But when you’re chatting with a client through whatever means you’ve chosen, and you’re unable to pinpoint a bug, I’ve found that it helps to create a product demo and send it over to them.

Naturally, it’s not a good idea just to send a video and be the stereotypical developer who says:

Hey, it works on my machine. Must be yours.

First, that’s a terrible and counterproductive attitude. Secondly, it’s disrespectful to the client because you’re in the business of solving their problems. Not creating them or complicating them.

So how can you make their lives easier (as well as your own)?

Continue reading

Project TODOs: Track, Share, and Build Better Software

One of the challenges of working on a time-sensitive project is balancing getting something working while also keeping track of the various document, tasks, issues, and general project TODOs.

I don’t know what this looks like for you. But for me. project TODOs usually fall into one of two groups:

  1. I need to go back and document a file, class, property (or properties), functions, or module.
  2. There are places that I know need to be refactored. Perhaps a function needs to be split into two methods. Perhaps I need to rework an algorithm. Whatever the case, there’s something that needs to be done before I’m happy with it being final.

And when that’s the case, it’s easy to forget to come back to these areas in the code and rework them as you see fit.

This is where the idea of project TODOs come in, but I even think we can take it a bit further.

Continue reading

IIFE For JavaScript in WordPress Development

IIFE, or an immediately-invoked function expression, is something that’s been a relatively common way of writing code in JavaScript.

It’s something that I think anyone doing any type of client-side development with WordPress should be using, but first I think it’s important to grasp the concept. Wikipedia provides a definition of IIFE:

An immediately-invoked function expression (or IIFE, pronounced “iffy) is a JavaScript programming language idiom which produces a lexical scope using JavaScript’s function scoping.

If you’re new to JavaScript, that just sounds kind of intense, right? So perhaps a better definition might be:

An “iffy” defines how variable names are related to the functions in which they are contained. Inner functions maintain the scope of their parent functions.

And finally, these functions are invoked anonymously because the function that fires literally has no name. It’s fired when the browser loads, parses, and runs the script.

So how does this all relate to WordPress?

Continue reading

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑