So you’re developing with WordPress. Whether you’re working on your own plugins, themes or doing client work, you’ll eventually run into the need of debugging something. Most people will simply print the data they need to debug to the screen but I’m not a big fan of this. When working on WordPress, or any web application, I don’t want to search through the browser where the data/error is being printed. I want a separate screen where all my data is logged in a clear way.
Turn WP_DEBUG on
Let’s start with stating the obvious. Set
WP_DEBUG to true in your
wp-config.php. Your notices, warning and errors will be suppressed when you leave
WP_DEBUG set to false. If you’re developing anything in WordPress, you must work with WP_DEBUG set to true.
Enable Error logging
Instead of simply printing data to your screen, for example with
var_dump, I like to log my data to the error log. By default WordPress will log errors in
/wp-content/debug.log. Before WordPress will log errors, you must enable it. Below code snippet includes all the WP and PHP settings you need for WordPress to log and display errors.
Using the Error Log
Now that you’ve enabled error logging you can log any data you want to the
debug.log file by using the
error_log function. Below example with send a test string to the log file.
The first parameter of
error_log, the message, is a string. Want to log an object or array? No problem. Simply use
Note the second argument of
print_r. This makes sure the output of the function is returned instead of being printed. I advise you to use the following command in your terminal to keep a ‘live stream’ of your
tail -f debug.log. Note that this command has to be run from the directory where the debug file is. This command will work on Mac and Unix.
So how do you debug in your WordPress projects? Did you find this article helpful or did I miss something? Be sure to let me know by leaving a comment below.
I like to use Codelobster to debug WordPress code.
Nice website. look at mine Internet download manager’s life time solution
In your location, game events like encountering monsters and other players happen in real time.
Ravensword: Shadowlands: A beautiful RPG with a world to explore,
various monsters to fight, and plenty of medieval & magical equipment to fight them with.
You may need to press the numbered buttons on your
Wiimote and tap ‘Init and Connect’ a few times before it detects it correctly.
Here is my blog :: download game path of exile,ex path of exile,how to download path of exile,path of exile,path of exile bloodlines,path of exile bots,path of exile cheat,path of exile cheat engine,path of exile cheats,path of exile download client,path of exile download free,path of exile free,path of exile free download,path of exile full,path of exile game download,path of exile gold,path of exile guides,path of exile hack tool,path of exile hints,path of exile indir,path of exile info,path of exile maps guide,path of exile pc game,path of exile tips,path of exile walkthrough
I’ve just stated tinkering with WP code. Thanks for the time and tips, I’m sure I’ll find it useful in the near future.