Software Engineering in WordPress, PHP, and Backend Development

Category: Notes (Page 33 of 49)

Notes on programming-related problems that I’ve encountered while working on various projects.

Resolving “Invalid Regular Expression Flag” in JavaScript

Thanks to modern browsers, writing cross-browser compatible JavaScript isn’t nearly as difficult as it was even just a few years ago; however, there are still times when you get cryptic error messages such as “invalid regular expression flag.”

Just as Jamie Zawinski said:

Some people, when confronted with a problem, think “I know, I’ll use regular expressions.” Now they have two problems.

It’s funny because it’s true, right? But we still have regular expressions, they’re still powerful, and we still use them.

Unfortunately, there are still times in which they can plague us when working with JavaScript, string replacement, and modern web browsers.

Continue reading

How To Have WordPress Check if a User Exists

When it comes to building web applications, I’m a fan of letting a user use their email as their primary login – in fact, I’d go as far as to say that I wish our email was our primary identity: They are unique, it’s a single thing to remember, and we all must have them in order to get online these days.

To that end, whenever I’m working on an application that requires a username and password, I always default to using the email address for the user’s identification. Everything else can be managed in a profile setting, right?

If you’re building an application in WordPress where you’re building custom registration mechanisms through your own views, validation, and so on, you may find yourself needing to check to see if a user already exists.

And if you – like me – often use email as the user name, there’s a really easy way to perform this check.

Continue reading

Programmatically Mark a Comment as Unapproved

In a recent project, I was working with someone who wanted to mark a comment as unapproved regardless of the value that was set in the WordPress settings.

Specifically, the person was using a plugin that allowed for certain attachments to the plugin. In order to make sure that the comment could be screened prior to allowing it to go public on the blog, they wanted to moderate it from the dashboard without needed to completely enable comment moderation across the board.

This is something that’s relatively easy to achieve programmatically.

Continue reading

More Development – Domain For Sale

TL;DR: I am looking to sell a previous domain: MoreDevelopment.com

When I first went self-employed, my goal was simple: to build sites and software for small businesses, teams, and individuals.

To that end, I ended up using a variety of different platforms, languages, and tools in order to best serve whatever the primary need was.

But over the past year or so, I’ve begun to heavily focus specifically on WordPress. So much so that I’m currently doing 100% of my contract work building applications on WordPress, creating custom plugins (both for fun and profit), speaking at events, guest blogging, building themes, and so on and I’m really enjoying it.

As such, I’ve made the decision to deliberately focus specifically on WordPress for the foreseeable future and, as such, am working on rebranding my company as well as all the peripheral stuff that comes with doing that.

Additionally, I need to sell of an old domain.

Continue reading

The WordPress Register Activation Hook

For those of you who have been following development of the WordPress Plugin Boilerplate, you’ll recall that I previously included the `register_activation_hook` and `register_deactivation_hook` calls within the the class itself.

In the latest version of the Boilerplate, they’ve been removed outside of the context of the class and into a separate file. Last week, I received a great comment asking why this decision was made:

I have this one question – why plugin activation/deactivation hooks are registered outside the constructor (as they were in v1.0) ?

I thought it would be better to discuss the decision in a blog post rather than in a lengthy comment.

Continue reading

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑