WordPress Debugging: The Essential Guide

WordPress Debugging: The Essential Guide

Regardless of what level of WordPress developer you are, there is one problem you’ll constantly face: bugs. Even the most seasoned developers cannot consistently code in a manner that doesn’t produce bugs. As a matter of fact, debugging WordPress actually can help you learn even more about the platform!

If you have prior programming experience, chances are that you’ve had errors upon compilation or runtime. Unless you threw in the towel and tossed the project, chances are you spent some time running through the code and tracking the problem down. The dynamic with WordPress is the same.

Unlike when you program in a common programming language, WordPress errors are not simply printed out on the page. This is because debug logs often contain sensitive information, like the credentials to databases. WordPress instead will drop those logs into files on your server not accessible to the public.

Fortunately, unlike the computers that weighed thirty tons developed by the US Army, you won’t have to literally remove dead bugs from your machine to accomplish this! Now that we have some context, let’s take a more technical look at what goes into the WordPress debug process.

WordPress Debug Explained

As you likely know, WordPress is developed using PHP. That means that the official WordPress guide on debugging, as well as the official PHP debugging guide will be excellent resources to help you along the way.

In order to debug at all, WordPress requires you to have a global PHP variable defined. We’ll go over exactly how to do that in the next section.

It’s important to distinguish between how the PHP debugging process is different from the WordPress debug process. With vanilla PHP, only two types of errors are shown by default.One is a “fatal error”, meaning it’s so severe that the page cannot even load. The other is simply showing the user a blank page if there’s a “sensitive fatal error”. In other words, PHP knows that printing out the full error message could pose a security risk. These settings can easily be modified in PHP itself.

WordPress, on the other hand, is a bit wordier when it comes to debugging. If you simply enable WordPress debugging and do not customize it, every level of error, warning, and even informative items for developers will be displayed. That means everything from fatal errors to a technical message about how you should optimize a section of JavaScript will be shown. While this is extremely helpful for developers, it’s probably not the best content to show to users.

Another unique feature is that you’ll be notified about WordPress-specific PHP functions that have become deprecated. Functions that have become deprecated are ones that may still work now, but support will be dropped for them in the future. This also typically means that there’s a better, faster way of accomplishing the same process.

We know that you probably aren’t excited about debugging WordPress, but it’s

[…]

 



This article was written by AJ Morris and originally published on WordPress News and Updates from iThemes – iThemes.

Disclosure: Some of the links in this post are "affiliate links." This means if you click on the link and purchase the product, We may receive an affiliate commission.

Leave a Comment

You have to agree to the comment policy.

Scroll to Top