Defining Debugging Constants

When developing a WordPress site, on your local or development environment, its imperative to have the debug log turned on, in order to catch any errors/warnings before shipping the code further. Its quite easy to do, by simply setting these constants in wp-config.php:

define( 'WP_DISABLE_FATAL_ERROR_HANDLER', true );   // WP 5.2 and later
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_DISPLAY', false );
define( 'WP_DEBUG_LOG', true );

The purpose of this is to

  1. Route the error logging information to wp-content/debug.log so that you can tail it locally and be aware of any error/warning that occurs when running the site.
  2. Enlist any/all deprecated functions/arguments being used whenever they are called, to ensure that your code will continue to work as intended in the long run.
  3. Disable sending of error log statements in the response, so that you can ensure that no Ajax functionality breaks because of such statements.

To learn more about these constants (and a few more) that we can define in wp-config.php please refer WordPress Codex page for debugging.