The debug_information WordPress PHP filter allows plugins or themes to add custom debug information to the Tools -> Site Health -> Info screen without creating additional admin pages.
Usage
add_filter( 'debug_information', 'my_custom_debug_info' ); function my_custom_debug_info( $debug_info ) { // your custom code here return $debug_info; }
Parameters
$debug_info
(array) – The debug information to be added to the core information page.
More information
See WordPress Developer Resources: debug_information
Examples
Add a custom section with basic information
Add a new custom section to Site Health with two fields showing information about the custom theme.
add_filter( 'debug_information', 'my_custom_theme_info' ); function my_custom_theme_info( $debug_info ) { $debug_info['my_custom_theme'] = array( 'label' => 'My Custom Theme', 'description' => 'This section shows information about My Custom Theme.', 'fields' => array( 'theme_version' => array( 'label' => 'Theme Version', 'value' => '1.0.0', ), 'author' => array( 'label' => 'Author', 'value' => 'John Doe', ), ), ); return $debug_info; }
Add field to an existing section
Add a new field to the existing WordPress Constants section to display the custom constant value.
add_filter( 'debug_information', 'add_custom_constant' ); function add_custom_constant( $debug_info ) { $debug_info['wp-constants']['fields']['my_custom_constant'] = array( 'label' => 'MY_CUSTOM_CONSTANT', 'value' => MY_CUSTOM_CONSTANT, ); return $debug_info; }
Add private information
Add a new custom section with an API key that should not be included in copied data.
add_filter( 'debug_information', 'add_private_api_key_info' ); function add_private_api_key_info( $debug_info ) { $debug_info['my_private_api_key'] = array( 'label' => 'My Private API Key', 'fields' => array( 'api_key' => array( 'label' => 'API Key', 'value' => '1234567890abcdef', 'private' => true, ), ), ); return $debug_info; }
Display an array of data
Add a new custom section with an array of data displayed as name/value pairs.
add_filter( 'debug_information', 'add_custom_array_data' ); function add_custom_array_data( $debug_info ) { $debug_info['my_custom_data'] = array( 'label' => 'My Custom Data', 'fields' => array( 'data_array' => array( 'label' => 'Data Array', 'value' => array( 'key1' => 'value1', 'key2' => 'value2', ), ), ), ); return $debug_info; }