How to Disable WordPress Deprecated Warnings

  • Update On June 4th, 2021
  • in WordPress
How to Disable WordPress Deprecated Warnings - How to Disable WordPress Deprecated Warnings

This post was last updated on June 4th, 2021 at 12:49 pm

define('WP_DEBUG', true); a WordPress configuration setting. With this setting enabled, WordPress displays all PHP errors, notices, warnings, and also enables WordPress’s deprecated messages. While these messages are an important way to tell developers that certain functions, arguments, or files have been deprecated and that their use is discouraged.

Unfortunately, when a piece of code is marked as deprecated, the offending code or scripts will be raising deprecated messages on the pages. So until we fix the codes we may need to disable these deprecated warning messages. Fortunately, WordPress has some filter hooks that can be used in this scenario. With these hooks, we can alternate the default behavior and how it handles deprecated function messages. Place the following code in you function.php

//How to Disable WordPress Deprecated Warnings
add_filter('deprecated_function_trigger_error', 'disable_all_deprecated_warnings');
add_filter('deprecated_argument_trigger_error', 'disable_all_deprecated_warnings');
add_filter('deprecated_file_trigger_error',     'disable_all_deprecated_warnings');

//Not to trigger any errors when a deprecated function or method is called.
add_filter( 'deprecated_hook_trigger_error',    'disable_all_deprecated_warnings');

function disable_all_deprecated_warnings($bolean) {
    return false;
}
Note: Normally debugging is used for development purposes only. So make sure to disable it again after you are done troubleshooting.
About This Author

My name is Parameshwar Roy (P. Roy), and I am a web developer. This is my personal blog to record my own thoughts. Though I am not a natural writer, I love to share my experiences. Hope my experiences will be useful to you...read more about me

Leave A Reply