The deprecated_argument_trigger_error WordPress PHP filter controls whether to trigger an error for deprecated arguments.
Usage
add_filter('deprecated_argument_trigger_error', 'your_custom_function'); function your_custom_function($trigger) { // your custom code here return $trigger; }
Parameters
$trigger
(bool): Whether to trigger the error for deprecated arguments. Default is true.
More information
See WordPress Developer Resources: deprecated_argument_trigger_error
Examples
Disable Deprecated Argument Errors
Disable error messages for deprecated arguments:
add_filter('deprecated_argument_trigger_error', '__return_false');
Log Deprecated Argument Errors
Log deprecated argument errors instead of displaying them:
add_filter('deprecated_argument_trigger_error', 'log_deprecated_argument_errors'); function log_deprecated_argument_errors($trigger) { // Change this to false to stop triggering errors $trigger = false; // Log the deprecated argument error message error_log('A deprecated argument was used.'); return $trigger; }
Display Custom Deprecated Argument Error Message
Display a custom error message for deprecated arguments:
add_filter('deprecated_argument_trigger_error', 'custom_deprecated_argument_error_message'); function custom_deprecated_argument_error_message($trigger) { if ($trigger) { trigger_error('A deprecated argument was used. Please update your code.', E_USER_NOTICE); } return $trigger; }
Disable Deprecated Argument Errors for Specific Functions
Disable error messages for deprecated arguments in specific functions only:
add_filter('deprecated_argument_trigger_error', 'disable_deprecated_argument_errors_for_specific_function', 10, 3); function disable_deprecated_argument_errors_for_specific_function($trigger, $function, $message) { if ('specific_function_name' === $function) { return false; } return $trigger; }
Show Deprecated Argument Errors Only for Administrators
Display deprecated argument errors only for administrators:
add_filter('deprecated_argument_trigger_error', 'show_deprecated_argument_errors_for_admins'); function show_deprecated_argument_errors_for_admins($trigger) { if (current_user_can('manage_options')) { return true; } return false; }