Software Engineering in WordPress, PHP, and Backend Development

Author: Tom (Page 99 of 427)

WordPress Debug Logs Are More Important Than You Think

When it comes to working with WordPress, the Codex does a good job of showing how to configure the application for debugging.

In short, you add the following to your wp-config.php:

// Enable WP_DEBUG mode
define( 'WP_DEBUG', true );

// Enable Debug logging to the /wp-content/debug.log file
define( 'WP_DEBUG_LOG', true );

// Disable display of errors and warnings
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );

There’s more you can add, but this is the general idea as to what I find useful.

But why bother covering this?

Continue reading

Updating Subsequent Events in Event Calendar Posts

This is a really nuanced case but I thought it might be worth trying to generalize for a post for anyone who may be working with future events with Modern Tribe’s Events Calendar.

Say you’re setting up some recurring event and within the body of the event (or, more appropriately, the post_content) you want to say something like:

It’s been N-years since [this event] occurred.

The thing is, each subsequent event will obviously be one year greater than the one before it. So you can’t necessarily hardcode the value into the events without it being placed into the post content of every event.

So what’s one way to tackle this?
Continue reading

Download User Email Addresses via JSON in WordPress, Part 2

In the previous post, I began sharing how to download user email addresses via JSON in WordPress (using Ajax). The first article covered:

  1. registering the JavaScript for doing so
  2. getting the users’ email addresses,
  3. and parsing out the results.

There’s more to do, though. Namely:

  1. converting the returned information into JSON,
  2. writing that file to disk,
  3. and how to tie the rest of it together using JavaScript.

And that’s what the remainder of this post is going to cover. So if you haven’t read the preceding article, I recommend it if for no other reason than to glance at the code to see it thus far.

Continue reading

Download User Email Addresses via JSON in WordPress, Part 1

Say you’re working on a project in which you want to provide the user the ability to download all of the email addresses from the users that exist in the WordPress installation. Granted, this has a few requirements:

  • You only want administrators to do it,
  • It needs to be secure via nonce values,
  • The responses should be in JSON,
  • And you want to use JavaScript to send the file when it’s ready to download.

Each of the above concepts has likely been covered here before, but what if you’re looking to tie them all together? That is, what if you want to make it easy to download user email addresses via JSON within WordPress from, say, an administration menu or a submenu?

Download User Email Addresses via JSON in WordPress

An obligatory shot of where I’m working while writing this post.

Here’s one way to tackle that problem. Note that it does assume you have some knowledge of the above, but I’ll do what I can to cover each of the above.

Continue reading

For Quality, It’s Understanding Before Coding

Whenever you aim to blog about a series of different things all seeking to help out people write quality code (or write anything, really) to help improve their workflow, you’re bound to get feedback, right?

Don’t get me wrong. I welcome it. I think it helps to make for better writing in the future (that is, I ask, what can I do better).

And at the risk of looking like I’m “calling someone out” (which I am not), I want to share an [unattributed] tweet that I received last week:

your title “high-quality code” got me pumped for some hardcore stuffs, but dude ~99% narrative vs ~1% code?? *drops dead on his keyboard*

And I get it. There’s very little code in a post that is aiming to talk about code. But there are reasons for this, and it comes from a few years of both reading articles, writing articles, reading code, and writing code.

So I thought for others who have the same thoughts, it might be worth explaining why I take the approach I do.

Continue reading

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑