Developer Debug Tools
The Developer Debug Tools plugin has some useful functions and hooks for developers to use to further enhance its functionality.
- ddtt_is_dev()
- ddtt_get_devs()
- ddtt_print_r() / dpr()
- ddtt_var_dump_to_string();
- ddtt_alert()
- ddtt_console_log() / ddtt_console()
- ddtt_write_log() / dwl()
- ddtt_backtrace()
- ddtt_debug_form_post()
- ddtt_admin_error()
- ddtt_start_timer()
- ddtt_stop_timer()
- ddtt_is_site()
- ddtt_get_plugins_data()
- ddtt_maybe_redact()
- ddtt_wpconfig_snippets
- ddtt_htaccess_snippets
- ddtt_highlight_debug_log
- ddtt_highlight_activity_log
- ddtt_resource_links
- ddtt_recommended_plugins
- ddtt_quick_link_icon
- ddtt_resources_icon
- ddtt_quick_link_post_types
- ddtt_admin_menu_special_urls
- ddtt_admin_bar_dropdown_links
- ddtt_admin_bar_condensed_items
- ddtt_admin_bar_condensed_ignore
- ddtt_admin_bar_condensed_only_remove_ab_labels
- ddtt_admin_bar_condensed_css_icon_nodes
- ddtt_omit_shortcodes
- ddtt_shortcode_finder_exclude_post_types
- ddtt_shortcode_finder_content
- ddtt_admin_list_update_each_user
- ddtt_admin_list_update_each_post
- ddtt_bots_to_log
- ddtt_online_users_capability
- ddtt_help_map_debug_log
- ddtt_time_format_choices
- ddtt_issues
- ddtt_easy_log_parse_error
- ddtt_error_help_search_options
- ddtt_metadata_ui_setting_keys
- ddtt_protected_meta_keys
- ddtt_site_option_prefixes
- ddtt_online_users_discord_message_args
- ddtt_fatal_discord_message_args
- ddtt_page_not_found_error_messages
ddtt_is_dev()
TYPE ⇢ Function
Checks if the current user is a developer. Returns a boolean only. As of version 3.0, this function no longer accepts parameters to return a list of developers; please use ddtt_get_devs() instead (see below).
Example Usage
// Only do something if the current user is a developer
if ( ddtt_is_dev() ) { ... }ddtt_get_devs( $return_emails = false )
TYPE ⇢ Function
Returns an array of developer user IDs or developer email addresses based on the plugin settings. If no developers are configured, administrators are used as the fallback group. Introduced in version 3.0.
PARAMETERS:
$return_emails(bool)
Default:false
Settruereturn developer email addresses. When false, user IDs are returned.
Example Usage
// Retrieve developer user IDs
$dev_ids = ddtt_get_devs();
// Retrieve developer email addresses
$dev_emails = ddtt_get_devs( true );ddtt_print_r( $var, $left_margin = null, $user_id = null, $write_bool = true ) / dpr()
TYPE ⇢ Function
ALTERNATIVE SHORT FUNCTION: dpr() => ddtt_print_r()
An extended version of print_r(). Wraps it in <pre> tags </pre> automatically. You can use the short dpr() or long ddtt_print_r() version of the function (in some cases dpr might be used by another plugin or theme, so a long version is available).
PARAMETERS:
$var(mixed - required)
What you want to print$left_margin(int | string | true | null)
Default:null
Add space to the left margin of what you are printing in case it becomes hidden behind the admin menu or other elements. Settrueto add 180px, which is the width of the admin menu sidebar plus some padding.$user_id(int | array | null)
Default:null
Display only to the specified user(s). Default is all developers.$write_bool(bool)
Default:true
Displays "TRUE" and "FALSE" instead of 1 and nothing.
Example Usage
// Print a variable that only developers can see
dpr( $var ); /* or */ ddtt_print_r( $var );
// Display an array in pretty print
dpr( $array );
// Add left margin to move the printed information out from behind the admin menu sidebar
global $menu;
dpr( $menu, true ); /* or */ dpr( $menu, '250px' );
// Make it visible to other users (for instance if you switch to another user to test an issue they are having)
// Whereas 3 and 7 are user ids
dpr( $var, null, 3 ); /* or */ dpr( $var, null, [ 3, 7 ] );ddtt_var_dump_to_string( $var );
TYPE ⇢ Function
Convert var_dump() to a string. Useful when logging it to the error log.
PARAMETERS:
$var(mixed - required)
What you want to dump.
Example Usage
// Log the var_dump() to the error log
error_log( ddtt_var_dump_to_string( $var ) );ddtt_alert( $msg, $user_id = null )
TYPE ⇢ Function
Add JavaScript alert in PHP.
PARAMETERS:
$msg(string - required)
The message that you want to display in an alert.$user_id(int | null)
Default:null
Display only to the specified user. Default is all developers.
Example Usage
// Display a javascript alert with PHP
ddtt_alert( $var );
// Make it visible to other users (for instance if you switch to another user to test an issue they are having)
// Whereas 3 is the user id
ddtt_alert( $var, 3 );ddtt_console_log( $msg ) / ddtt_console()
TYPE ⇢ Function
Add JavaScript console.log in PHP. This will be visible to everyone that opens their dev console, so it really should just be used for temporary testing. As of version 3.0, you can use the short ddtt_console() or long ddtt_console_log() version of the function.
PARAMETERS:
$msg(string - required)
The message that you want to display in the console.
Example Usage
// Display something in the developer console
ddtt_console_log( $var ); /* or */ ddtt_console( $var );ddtt_write_log( $log, $prefix = true, $backtrace = false, $full_stacktrace = false ) / dwl()
TYPE ⇢ Function
An extended version of error_log() that writes to the debug log. Automatically wraps arrays and objects in print_r() to be logged. Will only log if WP_DEBUG is set to true. As of version 3.0, you can use the short dwl() or long ddtt_write_log() version of the function (in some cases might be used by another plugin or theme, so a long version is available).dwl
PARAMETERS:
$log(mixed - required)
What you want to log to the debug log.$prefix(string | bool)
Default:true
Iftrue, adds "DDTT_LOG: " to beginning of line. You can use your ownStringas a prefix orfalseto remove.$backtrace(bool)
Include file and line number the function is called on.$full_stacktrace(bool)
Include the full stack trace of where the function is called.
Example Usage
// Testing which condition is running
dwl( 'Test Before' ); /* or */ ddtt_write_log( 'Test Before' ); /* Prints: DDTT_LOG: Test Before */
if ( $item == 'example 1' ) {
// Do something
dwl( 'Passed condition 1' ); /* Prints: DDTT_LOG: Passed condition 1 */
} elseif ( $item == 'example 2' ) {
// Do something
dwl( 'Passed condition 2' ); /* Prints: DDTT_LOG: Passed condition 2 */
} else {
// Do something
dwl( 'Else condition' ); /* Prints: DDTT_LOG: Else condition */
}
// Logging an array or object
dwl( $array );
// Remove or change the prefix
dwl( $array, false ); /* or */ dwl( $array, 'ME: ' );ddtt_backtrace( $ignore_class = null, $skip_frames = 0, $pretty = true )
TYPE ⇢ Function
Log a comma-separated string or array of functions that have been called to get to the current point in code. Basically logs wp_debug_backtrace_summary()to debug.log using ddtt_write_log().
PARAMETERS:
$ignore_class(string)
Default:null
A class to ignore all function calls within – useful when you want to just give info about the callee.$skip_frames(int)
Default:0
A number of stack frames to skip – useful for unwinding back to the source of the issue.$pretty(bool)
Default:true
Whether you want a comma separated string instead of the raw array returned.
Example Usage
// Log a simple backtrace for debugging
ddtt_backtrace();
// Skip the first 2 stack frames in the trace
ddtt_backtrace( null, 2 );
// Ignore a specific class in the backtrace summary
ddtt_backtrace( 'My_Plugin_Class' );
// Return the backtrace in raw format instead of a pretty string
ddtt_backtrace( null, 0, false );
// Combine options: ignore a class, skip 1 frame, and get raw output
ddtt_backtrace( 'WP_Hook', 1, false );ddtt_debug_form_post( $email, $test_number = 1, $subject = "Test Form $_POST " )
TYPE ⇢ Function
Send a sanitized summary of all $_POST data to a specified email address for debugging purposes. Useful for inspecting form submissions during development or troubleshooting without exposing data on-screen.
PARAMETERS:
$email(string - required)
The email you want to send debug email to.$test_number(int)
Default:1
Adds a test number to the subject so you know which test you are attempting.$subject(string)
Default:"Test Form $_POST"
Change the subject.
Example Usage
// Send the contents of $_POST to your email
ddtt_debug_form_post( 'dev@example.com' );
// Specify a test number to differentiate multiple test submissions
ddtt_debug_form_post( 'dev@example.com', 2 );
// Customize the subject line of the debug email
ddtt_debug_form_post( 'dev@example.com', 1, 'Debugging Contact Form Submission #' );ddtt_admin_error( $msg, $include_pre = true, $br = true, $hide_error = false )
TYPE ⇢ Function
Display an admin-only error message on the front or back end, intended for development and debugging. Only users with the Administrator role will see the message, and you can optionally suppress it or customize its formatting.
PARAMETERS:
$msg(string - required)
The message you want to display as the admin error.$include_pre(bool)
Default:true
Whether to prepend"ADMIN ERROR: "to the message.$br(bool)
Default:true
Whether to add a<br>before the error message to create spacing.$hide_error(bool)
Default:false
If set totrue, the error will be suppressed regardless of the user’s role.
Example Usage
// Show a simple admin-only error
echo ddtt_admin_error( 'Something went wrong.' );
// Suppress the "ADMIN ERROR: " prefix
echo ddtt_admin_error( 'Missing form field.', false );
// Remove line break spacing above the error
echo ddtt_admin_error( 'Post ID not found.', true, false );
// Hide the error completely (can be toggled via flag)
$testing = false;
echo ddtt_admin_error( 'This should not appear.', true, true, $testing );ddtt_start_timer( $timeout_seconds = 300 )
TYPE ⇢ Function
Starts a processing timer using microseconds and (optionally) increases the cURL timeout limit. Used with ddtt_stop_timer() (see next function below) to measure how long a process takes to run.
PARAMETERS:
$timeout_seconds(int)
Default:300
The number of seconds to temporarily extend the cURL timeout while timing. Set tonullor0to skip timeout changes.
ddtt_stop_timer( $start, $timeout = true, $milliseconds = false )
TYPE ⇢ Function
Stops a previously started timer (from ddtt_start_timer() above), calculates the total elapsed time, optionally restores the cURL timeout setting, and returns the result in seconds or milliseconds.
PARAMETERS:
$start(float - required)
The start time returned byddtt_start_timer().$timeout(bool)
Default:true
Whether to restore the original cURL timeout setting after the timer stops.$milliseconds(bool)
Default:false
Iftrue, returns the result in milliseconds instead of seconds.
Example Usage
// Start the timer
$start = ddtt_start_timer();
// Run some code you want to measure
do_some_custom_processing();
// Stop the timer and get elapsed time in seconds
$total_time = ddtt_stop_timer( $start );
// Display result
echo 'This process took '.$total_time.' seconds.';
/* or */
// Start the timer
$start = ddtt_start_timer();
// Process several items
$number_of_items = 0;
foreach ( $some_array as $item ) {
run_something_heavy();
$number_of_items++;
}
// Stop the timer and get elapsed time in seconds
$total_time = ddtt_stop_timer( $start );
// Get the length of time it took per item
$sec_per_item = round( ( $total_time / $number_of_items ), 2 );
// Display result
echo 'This process took a total of ' . $total_time . ' seconds; ' . $sec_per_item . ' per item.';ddtt_is_site( $site_to_check )
TYPE ⇢ Function
Check if the current site matches (or partially matches) a given domain string. Useful for targeting site-specific logic in multisite setups or shared codebases. Accepts partial matches (e.g. "example" matches example.com).
PARAMETERS:
$site_to_check(string - required)
The string to compare against the current site’s domain. Partial matches are allowed.
Example Usage
// Run specific logic only on example.com
if ( ddtt_is_site( 'example.com' ) ) {
// Do something only for example.com
}
// Use with negation to exclude logic on a specific site (devsite.com or thedevsite.org, etc)
if ( !ddtt_is_site( 'devsite' ) ) {
// Skip something on the dev site
}ddtt_get_plugins_data()
TYPE ⇢ Function
Fetches data for all of your plugins and caches them to a transient named ddtt_plugins_data for 1 day. You can schedule this to run at night using WP Crontrol.
Example Usage
// Hook into plugin activation to fetch plugin data
function ddtt_on_plugin_activated( $plugin ) {
// Fetch and cache the plugin data when a plugin is activated
$plugins_data = ddtt_get_plugins_data();
// You can also log or send notifications based on the data, if needed
error_log( 'Plugins data fetched after activation of: ' . $plugin );
}
add_action( 'activated_plugin', 'ddtt_on_plugin_activated' );ddtt_maybe_redact( $string, $abspath = false )
TYPE ⇢ Function
Redacts sensitive information when the “View Sensitive Information” security setting is disabled. Supports full-string redaction or conditional redaction of absolute paths. Introduced in version 3.0.
PARAMETERS:
$string(string - required)
String to potentially redact.$abspath(bool)
Default: false
Settrueto redact only when the string begins with the server’s absolute path.
Example Usage
// Fully redact a string if sensitive info is disabled
$redacted = ddtt_maybe_redact( $debug_output );
// Redact only the absolute path portion
$path_redacted = ddtt_maybe_redact( $file_path, true );ddtt_wpconfig_snippets
TYPE ⇢ Filter
Add, remove or modify a snippet from the WP-CONFIG tab. Find more snippets here.
Example Usage
/**
* Add, remove or modify a snippet from the DDT WP-CONFIG tab.
* Find more snippets here: https://developer.wordpress.org/apis/wp-config-php/
*
* @param array $snippets
* @return array
*/
function ddtt_wpconfig_snippets_filter( $snippets ) {
// Add a new snippet
$snippets[ 'post_revisions' ] = [
'label' => 'Change Number of Post Revisions',
'lines' => [
[
'prefix' => 'define',
'variable' => 'WP_POST_REVISIONS',
'value' => 3
]
],
'desc' => 'Changes the number of post revisions to 3.'
];
// Remove a snippet
unset( $snippets[ 'fs_method' ] );
// Change memory limit snippet to 512M
$snippets[ 'upload_size' ][ 'lines' ] = [
[
'prefix' => '@ini_set',
'variable' => 'upload_max_size',
'value' => '512M'
],
[
'prefix' => '@ini_set',
'variable' => 'post_max_size',
'value' => '512M'
]
];
// Return the new snippet array
return $snippets;
} // End ddtt_wpconfig_snippets_filter()
add_filter( 'ddtt_wpconfig_snippets', 'ddtt_wpconfig_snippets_filter' );ddtt_htaccess_snippets
TYPE ⇢ Filter
Add, remove or modify a snippet from the HTACCESS tab. Find more snippets here.
Example Usage
/**
* Add, remove or modify a snippet from the DDT HTACCESS tab.
*
* @param array $snippets
* @return array
*/
function ddtt_htaccess_snippets_filter( $snippets ) {
// Add a new snippet
$snippets[ 'force_trailing_slash' ] = [
'label' => 'Force Trailing Slash',
'lines' => [
'RewriteCond %{REQUEST_URI} /+[^\.]+$',
'RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]',
],
'desc' => 'Forces a trailing slash at the end of the domain.'
];
// Remove a snippet
unset( $snippets[ 'allow_backups' ] );
// Return the new snippet array
return $snippets;
} // End ddtt_htaccess_snippets_filter()
add_filter( 'ddtt_htaccess_snippets', 'ddtt_htaccess_snippets_filter' );ddtt_highlight_debug_log
TYPE ⇢ Filter
Change highlight colors on the Debug Log tab.
Example Usage
/**
* Change the highlight colors for Parse Errors in the debug log.
*
* @param array $args Existing debug log highlight args.
* @return array Modified debug log highlight args.
*/
function ddtt_custom_parse_error_highlight( $args ) {
$args[ 'parse-error' ][ 'bg_color' ] = '#FFA500';
$args[ 'parse-error' ][ 'font_color' ] = '#000000';
return $args;
}
add_filter( 'ddtt_highlight_debug_log', 'ddtt_custom_parse_error_highlight' );ddtt_highlight_activity_log
TYPE ⇢ Filter
Change highlight colors on the Activity Log tab. Introduced in version 3.0.
Example Usage
/**
* Change the highlight colors for the Settings-related activity log.
*
* @param array $args Existing highlight args.
* @return array Modified highlight args.
*/
function ddtt_custom_settings_highlight( $args ) {
$args[ 'settings' ][ 'bg_color' ] = '#FF00FF';
$args[ 'settings' ][ 'font_color' ] = '#FFFFFF';
return $args;
}
add_filter( 'ddtt_highlight_activity_log', 'ddtt_custom_settings_highlight' );ddtt_resource_links
TYPE ⇢ Filter
Add your own link to the Resources tab and the Resources admin bar dropdown. As of version 3.0, you can now add resources directly from the page. This hook will remain available so that you can add conditions to them.
Example Usage
/**
* Add your own link to Resources.
*
* @param array $links
* @return array
*/
function ddtt_resource_link_filter( $links ) {
// Add a new resource
$links[] = [
'title' => 'Google',
'url' => 'https://www.google.com',
'desc' => 'This is an example description.'
];
// Return the new links array
return $links;
} // End ddtt_resource_link_filter()
add_filter( 'ddtt_resource_links', 'ddtt_resource_link_filter' );ddtt_recommended_plugins
TYPE ⇢ Filter
Add or remove a recommended plugin on the Add Plugins > Dev Debug Tools tab. Note that you can only add plugins that are in the WordPress.org repository.
Example Usage
/**
* Add or remove a recommended plugin from the plugins page.
* Note that you can only add plugins that are in the WordPress.org repository.
*
* @param array $plugin_slugs
* @return array
*/
function ddtt_recommended_plugins_filter( $plugin_slugs ) {
// Add your own recommended plugin
// Find the slug in the WP.org url (https://wordpress.org/plugins/{slug}/)
// For example: https://wordpress.org/plugins/user-switching/
$plugin_slugs[] = 'user-switching';
// Remove a recommended plugin
if ( ( $key = array_search( 'post-type-switcher', $plugin_slugs ) ) !== false ) {
unset( $plugin_slugs[ $key ] );
}
// Return the new links array
return $plugin_slugs;
} // End ddtt_recommended_plugins_filter()
add_filter( 'ddtt_recommended_plugins', 'ddtt_recommended_plugins_filter' );ddtt_quick_link_icon
TYPE ⇢ Filter
Change the Quick Debug Link icon when quick links are added to posts and users in admin lists. Default is ⚡.
Example Usage
/**
* Change the Quick Debug Link icon when quick links are added to posts and users in admin lists.
*/
add_filter( 'ddtt_quick_link_icon', function() {
return '👍';
} );ddtt_resources_icon
TYPE ⇢ Filter
Modify the HTML used for the Resources icon in the admin bar. Default is . Introduced in version 3.0.
Example Usage
/**
* Change the Resources admin bar icon.
*/
add_filter( 'ddtt_resources_icon', function() {
return '<span class="ab-icon dashicons dashicons-media-text"></span>';
} );ddtt_quick_link_post_types
TYPE ⇢ Filter
Add or remove post types that include quick links when enabled. Default is post and page.
Example Usage
/**
* Add or remove post types that include quick links when enabled
*
* @param array $post_types
* @return array
*/
function ddtt_quick_link_post_types_filter( $post_types ) {
// Add a single post type
$post_types[ 'listing' ] = 'listing';
// Add multiple post types
// Example adding Events Calendar plugin post types
$post_types = array_merge( $post_types, [
'tribe_events' => 'tribe_events',
'tribe_venue' => 'tribe_venue',
'tribe_organizer' => 'tribe_organizer',
] );
// Remove a post type
unset( $post_types[ 'post' ] );
// Return the post types array
return $post_types;
} // End ddtt_quick_link_post_types_filter()
add_filter( 'ddtt_quick_link_post_types', 'ddtt_quick_link_post_types_filter' );ddtt_admin_menu_special_urls
TYPE ⇢ Filter
Modify “special” admin menu URLs used in the admin bar dropdown links if some links are broken. Introduced in version 3.0.
Example Usage
/**
* Add or modify special admin menu URLs.
*
* @param array $special_urls Array of slug => URL mappings.
* @return array
*/
function ddtt_admin_menu_special_urls_filter( $special_urls ) {
$special_urls[ 'my-plugin' ] = 'edit.php?post_type=my-plugin-slug',
return $special_urls;
}
add_filter( 'ddtt_admin_menu_special_urls', 'ddtt_admin_menu_special_urls_filter' );ddtt_admin_bar_dropdown_links
TYPE ⇢ Filter
Add a link to the admin bar site name dropdown on the front-end.
Example Usage
/**
* Add a link to the admin bar site name dropdown on the front-end.
*
* @param array $links
* @return array
*/
function ddtt_admin_bar_dropdown_links_filter( $links ) {
// Add your own links
$links[] = [ 'Title', 'https://yourlink.com' ];
// Return the new links array
return $links;
} // End ddtt_admin_bar_dropdown_links_filter()
add_filter( 'ddtt_admin_bar_dropdown_links', 'ddtt_admin_bar_dropdown_links_filter' );ddtt_admin_bar_condensed_items
TYPE ⇢ Filter
Modify the admin bar icons that get condensed when the option is set.
Example Usage
/**
* Modify the admin bar icons that get condensed when the option is set.
*
* @param array $condensed_items The menu item id
* @return array
*/
function ddtt_admin_bar_condensed_items_filter( $condensed_items ) {
// Lookup menu item ids with global $wp_admin_bar; or with console log <li id="wp-admin-bar-{id}">
// Stop condensing the site name
unset( $condensed_items[ 'site-name' ] );
// Condense a menu item that has an icon by simply removing the name
$condensed_items[ 'customize' ] = '';
// Condense a menu item that doesn't have an icon by replacing it with a shorter title
$condensed_items[ 'menu-item1-id' ] = 'WP';
// Condense a menu item that has an icon by giving it a shorter title (add left margin for space between icon and text)
$condensed_items[ 'edit' ] = '<span style="margin-left: 6px;">Edit</span>';
// Or change the title to a dashicon when there is no icon
// Lookup dashicons here: https://developer.wordpress.org/resource/dashicons/
$condensed_items[ 'menu-item2-id' ] = '<span class="ab-icon dashicons dashicons-carrot" style="margin-top: 2px;"></span>';
// Always return the condensed items array
return $condensed_items;
} // End ddtt_admin_bar_condensed_items_filter()
add_filter( 'ddtt_admin_bar_condensed_items', 'ddtt_admin_bar_condensed_items_filter' );ddtt_admin_bar_condensed_ignore
TYPE ⇢ Filter
Exclude specific admin bar nodes from condensation. Introduced in version 3.0.
Example Usage
/**
* Exclude specific admin bar nodes from condensation.
*
* @param array $ignored_nodes Array of admin bar node IDs to ignore.
* @return array
*/
function ddtt_admin_bar_condensed_ignore_filter( $ignored_nodes ) {
$ignored_nodes[] = 'your-plugin-node';
return $ignored_nodes;
}
add_filter( 'ddtt_admin_bar_condensed_ignore', 'ddtt_admin_bar_condensed_ignore_filter' );ddtt_admin_bar_condensed_only_remove_ab_labels
TYPE ⇢ Filter
Specify admin bar nodes that should remove labels but keep icons, without full condensation. Introduced in version 3.0.
Example Usage
/**
* Specify admin bar nodes that should remove labels but keep icons.
*
* @param array $label_only_nodes Array of node IDs that should display icons only.
* @return array
*/
function ddtt_admin_bar_condensed_only_remove_ab_labels_filter( $label_only_nodes ) {
$label_only_nodes[] = 'your-plugin-node';
return $label_only_nodes;
}
add_filter( 'ddtt_admin_bar_condensed_only_remove_ab_labels', 'ddtt_admin_bar_condensed_only_remove_ab_labels_filter' );ddtt_admin_bar_condensed_css_icon_nodes
TYPE ⇢ Filter
Define admin bar nodes that should use CSS-generated icons when condensed. Introduced in version 3.0.
Example Usage
/**
* Define admin bar nodes that should use CSS-generated icons when condensed.
*
* @param array $css_icon_nodes Array of node IDs that should receive CSS icon classes.
* @return array
*/
function ddtt_admin_bar_condensed_css_icon_nodes_filter( $css_icon_nodes ) {
$css_icon_nodes[ 'woocommerce' ] = 'ab-icon dashicons-store';
return $css_icon_nodes;
}
add_filter( 'ddtt_admin_bar_condensed_css_icon_nodes', 'ddtt_admin_bar_condensed_css_icon_nodes_filter' );ddtt_omit_shortcodes
TYPE ⇢ Filter
Omit shortcodes from the admin bar shortcode finder.
Example Usage
/**
* Omit shortcodes from the admin bar shortcode finder.
*
* @param array $omits
* @return array
*/
function ddtt_omit_shortcodes_filter( $omits ) {
// Omit shortcodes starting with these keywords:
// Ex: [shortcode_name param=""]
$omits[] = 'shortcode_name';
// Return the new omits array
return $omits;
} // End ddtt_omit_shortcodes_filter()
add_filter( 'ddtt_omit_shortcodes', 'ddtt_omit_shortcodes_filter' );ddtt_shortcode_finder_exclude_post_types
TYPE ⇢ Filter
Filters the list of post types to exclude from the shortcode search. Default excluded post types include: attachment, revision, nav_menu_item, custom_css, customize_changeset, oembed_cache, user_request, wp_block, wp_template, wp_template_part, wp_global_styles, wp_navigation, cs_template, cs_user_templates, um_form, um_directory, cs_global_block, x-portfolio. Introduced in version 3.0.
Example Usage
/**
* Exclude an additional custom post type from shortcode search.
*
* @param array $post_types The array of post types currently excluded.
* @return array Modified array of post types to exclude.
*/
function ddtt_excluded_post_types( $post_types ) {
$post_types[] = 'my_custom_post_type';
return $post_types;
}
add_filter( 'ddtt_shortcode_finder_exclude_post_types', 'ddtt_excluded_post_types' );ddtt_shortcode_finder_content
TYPE ⇢ Filter
Modify or provide the post content used by the Shortcode Finder admin bar display, allowing an alternative source if $post->post_content is empty. Introduced in version 3.0.
Example Usage
/**
* Provide content for the Shortcode Finder if $post->post_content is empty.
*
* @param string $content The original post content.
* @return string The modified or alternative post content.
*/
function ddtt_shortcode_finder_content_filter( $content ) {
if ( empty( $content ) ) {
// Fallback: get content from a custom field
$post_id = get_the_ID();
if ( $post_id ) {
$alt_content = get_post_meta( $post_id, '_custom_content', true );
if ( ! empty( $alt_content ) ) {
$content = $alt_content;
}
}
}
return $content;
}
add_filter( 'ddtt_shortcode_finder_content', 'ddtt_shortcode_finder_content_filter' );ddtt_admin_list_update_each_user
TYPE ⇢ Action
Do something for each user when you load the user admin list. Must have Quick Debug Links enabled in Settings.
Why? Because sometimes we have to update meta keys for all users (sometimes in the thousands), and running a function using pagination on a smaller amount of users at a time is better for testing, processing, preventing time-outs, etc. It's also easier to do this than to code a pagination script that you're only going to use once.
Example Usage
/**
* Do something for each user when you load the user admin list.
* Must have Quick Debug Links enabled in Settings.
*
* @param int $user_id
* @return void
*/
function ddtt_update_each_user( $user_id ) {
// Only update users with subscriber role
if ( ddtt_has_role( 'subscriber', $user_id ) ) {
// Console log what I'm doing to each user
$user = get_userdata( $user_id );
ddtt_console_log( $user->display_name.' is a subscriber.' );
// Add/update meta key/value
update_user_meta( $user_id, 'example_meta_key', 'This is just an example' );
}
} // End ddtt_update_each_user()
add_action( 'ddtt_admin_list_update_each_user', 'ddtt_update_each_user' );ddtt_admin_list_update_each_post
TYPE ⇢ Action
Do something for each post or page when you load the post or page admin lists. Must have Quick Debug Links enabled in Settings.
Why? Because sometimes we have to update meta keys for all posts (sometimes in the thousands), and running a function using pagination on a smaller amount of posts at a time is better for testing, processing, preventing time-outs, etc. It's also easier to do this than to code a pagination script that you're only going to use once.
Example Usage
/**
* Do something for each post or page when you load the post or page admin lists.
* Must have Quick Debug Links enabled in Settings.
*
* @param int $post_id
* @return void
*/
function ddtt_update_each_post( $post_id ) {
// Only update posts
if ( get_post_status( $post_id ) == 'publish' ) {
// Console log what I'm doing to each post
$title = get_the_title( $post_id );
ddtt_console_log( $title.' is published.' );
// Add/update meta key/value
update_post_meta( $post_id, 'example_meta_key', 'This is just an example' );
}
} // End ddtt_update_each_post()
add_action( 'ddtt_admin_list_update_each_post', 'ddtt_update_each_post' );ddtt_bots_to_log
TYPE ⇢ Filter
Add, remove or modify user agents that are flagged as bots to be included in the Bots Crawling Posts and Pages option of the Activity Log tab.
Current bots: AIOHTTP, Apache HTTP Client, Apache Nutch, Audisto Crawler, AwarioSmartBot, Axios, Baidu Spider, Bing Bot, BrightEdge Crawler, BuiltWith, Buzz Stream, Bytespider (ByteDance), CCBot (Common Crawl), Chrome Lighthouse, Cortex Xpanse Bot (Palo Alto Networks), Criteo Crawler, Curl, DataForSeoBot, DuckDuckBot, Dynatrace, FAST Enterprise Crawler, FAST-WebCrawler, Facebook External Hit, Feedbin, Feedly, GPTBot (ChatGPT), GeedoBot, Go HTTP client, Google APIs, Google Ads Bot Mobile", Google Ads Bot, Google Bot, Google Feedfetcher, Google Image Bot, Google Inspection Tool, Google Media Partners, Google Mobile Bot, Google News Bot, Google Other, Google Read Aloud, Google Safety, Google Site Verifier, Google Store Bot, Google Video Bot, HTTrack Website Copier, Headless Chrome, HttpUnit, HubSpot, Iframely, Internet Archive, Linespider, Linguee Bot, LinkedIn Bot, MSN Bot, Majestic (MJ12Bot), MetaInspector, Node Fetch, PHPCrawl, Page2RSS, Perplexity AI, PetalBot, Proximic, Python HTTPX, Python OpenGraph, Python Requests, Python Urllib, Turnitin, Uptimebot, Virustotal, WebPageTest, Wget, YaCy, Yahoo! Slurp, Yandex, ZGrab, libwww-perl
Example Usage
/**
* Add a bot crawler to activity log "Bots Crawling Posts and Pages"
*
* @param array $bots
* @return array
*/
function ddtt_bots_to_log_filter( $bots ) {
// Key is the keyword to search for in the user agent. For example, if the user agent is
// Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; custombot/2.0; +http://www.example.com/custombot.htm) Chrome/xxx.xx.xxx.xxx Safari/537.36
// Then the key would be "custombot"
$bots[ 'custombot' ] = [
'name' => 'Custom Bot',
'url' => 'http://www.example.com/custombot.htm'
];
return $bots;
} // End ddtt_bots_to_log_filter()
add_filter( 'ddtt_bots_to_log', 'ddtt_bots_to_log_filter' );ddtt_online_users_capability
TYPE ⇢ Filter
Modify the capability required for a user to view the online users admin functionality. By default, the capability is administrator. Use this filter to change it to any valid WordPress capability string. Introduced in version 3.0.
Example Usage
/**
* Change the capability required to view online users.
*
* @param string $capability The original capability required.
* @return string The modified capability required.
*/
function ddtt_online_users_capability_filter( $capability ) {
return 'edit_pages';
}
add_filter( 'ddtt_online_users_capability', 'ddtt_online_users_capability_filter' );ddtt_help_map_debug_log
TYPE ⇢ Filter
Modify or extend the map of debug log help references. Each entry maps a regular expression pattern matching a log message to an array containing a 'desc' (description) and 'link' (reference URL). Introduced in version 3.0.
Example Usage
/**
* Filter the debug log help map.
*
* @param array $map Associative array of regex patterns to their descriptions and links.
* @return array Modified map.
*/
function ddtt_debug_log_map_filter( $map ) {
$map[ '/Custom error pattern/' ] = [
'desc' => 'Description of the custom error.',
'link' => 'https://example.com/docs/custom-error',
];
return $map;
}
add_filter( 'ddtt_help_map_debug_log', 'ddtt_debug_log_map_filter' );ddtt_time_format_choices
TYPE ⇢ Filter
Allows modification of the array of time format strings used in Dev Debug Tools. Each string will be converted to an example using the current timestamp and developer timezone and will be added to the choices of formats in the plugin's general settings. Introduced in version 3.0.
Example Usage
/**
* Add ISO 8601 format to Dev Debug Tools time choices.
*
* @param array $format_strings Array of date/time format strings.
* @return array Modified array of format strings.
*/
function ddtt_add_iso_time_format( $format_strings ) {
// Add European style: day/month/year with 24-hour time
$format_strings[] = 'd/m/Y H:i';
return $format_strings;
}
add_filter( 'ddtt_time_format_choices', 'ddtt_add_iso_time_format' );ddtt_issues
TYPE ⇢ Filter
Allows modification, addition, or removal of issues that Dev Debug Tools checks on the dashboard. Introduced in version 3.0.
Example Usage
/**
* Add a custom issue to detect if a site does not have a privacy policy page set.
*
* @param array $issues Existing issues.
* @return array Modified issues.
*/
function ddtt_add_privacy_policy_issue( $issues ) {
$issues['missing_privacy_policy'] = [
'label' => __( 'Missing Privacy Policy Page', 'dev-debug-tools' ),
'details' => __( 'Every WordPress site should have a privacy policy page configured to comply with privacy regulations.', 'dev-debug-tools' ),
'severity' => 'warning',
'actions' => [
[
'label' => __( 'Set Privacy Policy Page', 'dev-debug-tools' ),
'url' => admin_url( 'options-privacy.php' ),
],
],
'callback' => 'ddtt_missing_privacy_policy_check',
];
return $issues;
}
add_filter( 'ddtt_issues', 'ddtt_add_privacy_policy_issue' );
/**
* Check if a privacy policy page is set.
*
* @return bool True if no privacy policy page exists, false otherwise.
*/
function ddtt_missing_privacy_policy_check() {
return ( ! get_option( 'wp_page_for_privacy_policy' ) );
}ddtt_easy_log_parse_error
TYPE ⇢ Filter
Allows customization or replacement of parsed error data when rendering the Easy Reader error log. Introduced in version 3.0.
Example Usage
/**
* Custom parsing for certain debug log errors.
*
* @param array|null $parsed_error The current parsed error array, or null if not yet parsed.
* @param string $error_line The first line of the raw error.
* @param string $subsection The log subsection (e.g., 'debug', 'error').
*
* @return array|null Modified parsed error array or null to fall back to default parsing.
*/
function ddtt_easy_log_error( $parsed_error, $error_line, $subsection ) {
if ( strpos( $error_line, 'MyPluginNotice' ) !== false ) {
$parsed_error = [
'datetime' => date_i18n( 'Y-m-d H:i:s' ),
'type' => __( 'My Plugin Notice', 'dev-debug-tools' ),
'message' => $error_line,
'file' => '',
'line' => '',
'source' => __( 'Plugin: MyPlugin', 'dev-debug-tools' ),
'help' => [
'desc' => __( 'This error comes from MyPlugin. Check your plugin settings.', 'dev-debug-tools' ),
'link' => 'https://example.com/docs/myplugin-errors',
],
'stack' => '',
];
}
return $parsed_error;
}
add_filter( 'ddtt_easy_log_parse_error', 'ddtt_easy_log_error', 10, 3 );ddtt_error_help_search_options
TYPE ⇢ Filter
Allows modification or addition of search options for error log messages in the Easy Reader error log. Each option should include a label and a URL with {string} as a placeholder for the error message. Introduced in version 3.0.
Example Usage
/**
* Add a custom search option for error messages.
*
* @param array $options The existing array of search options.
*
* @return array Modified array of search options.
*/
function ddtt_error_search_options( $options ) {
$options[] = [
'label' => __( 'Search Stack Overflow', 'dev-debug-tools' ),
'url' => 'https://stackoverflow.com/search?q={string}',
];
return $options;
}
add_filter( 'ddtt_error_help_search_options', 'ddtt_error_search_options' );ddtt_metadata_ui_setting_keys
TYPE ⇢ Filter
Allows modification of the list of UI-related setting keys that are hidden in the metadata viewer when "Hide UI Settings" is enabled in the Custom Meta section. This can include postbox states, column visibility, and screen layout preferences. Default keys include: closedpostboxes_*, meta-box-order_*, *columnshidden, metaboxhidden_*, screen_layout_*. Introduced in version 3.0.
Example Usage
/**
* Add a custom UI setting key to hide in the metadata viewer.
*
* @param array $keys The existing array of UI setting keys.
* @return array Modified array of UI setting keys.
*/
function ddtt_metadata_ui_keys( $keys ) {
$keys[] = 'my_custom_ui_setting_*';
return $keys;
}
add_filter( 'ddtt_metadata_ui_setting_keys', 'ddtt_metadata_ui_keys' );ddtt_protected_meta_keys
TYPE ⇢ Filter
Allows modification of the list of protected meta keys that cannot be edited or deleted. Disables the "Edit" button and removes the "Delete" button if in custom meta. Default keys include: ID, user_registered, user_activation_key, _edit_last, _edit_lock, _wp_attached_file, _wp_attachment_metadata. Introduced in version 3.0.
Example Usage
/**
* Add a custom protected meta key that cannot be deleted.
*
* @param array $keys The existing array of protected meta keys.
* @return array Modified array of protected meta keys.
*/
function ddtt_protected_meta_keys( $keys ) {
$keys[] = '_my_custom_meta_key';
return $keys;
}
add_filter( 'ddtt_protected_meta_keys', 'ddtt_protected_meta_keys' );ddtt_site_option_prefixes
TYPE ⇢ Filter
Filters the list of known site option prefixes mapped to their plugin or source labels. Used on the Site Options tool to define the source of the option under the Option Details column. Introduced in version 3.0.
Example Usage
/**
* Add a custom plugin prefix to the site option prefixes.
*
* @param array $prefixes Array of current option prefixes and labels.
* @return array Modified array including a custom plugin prefix.
*/
function ddtt_site_option_prefixes( $prefixes ) {
$prefixes[ 'my_plugin_options_prefix_' ] = 'Plugin: My Custom Plugin';
return $prefixes;
}
add_filter( 'ddtt_site_option_prefixes', 'ddtt_site_option_prefixes' );ddtt_online_users_discord_message_args
TYPE ⇢ Filter
Filters the Discord webhook message arguments before sending a user login notification. Introduced in version 3.0.
Example Usage
/**
* Customize the Discord login message for online users.
*
* @param array $args The default Discord webhook message arguments.
* @param string $user_login The user login name.
* @param WP_User $user The WP_User object of the logged-in user.
*
* @return array Modified Discord webhook message arguments.
*/
function ddtt_discord_login_message( $args, $user_login, $user ) {
// Change the title
$args[ 'title' ] = __( 'New Login Detected on', 'dev-debug-tools' ) . ' ' . get_bloginfo( 'name' );
// Change embed color
$args[ 'color' ] = 'FF5733';
// Add another field
$args[ 'fields' ][] = [
'name' => __( 'User Role', 'dev-debug-tools' ),
'value' => implode( ', ', $user->roles ),
'inline' => false,
];
return $args;
}
add_filter( 'ddtt_online_users_discord_message_args', 'ddtt_discord_login_message', 10, 3 );ddtt_fatal_discord_message_args
TYPE ⇢ Filter
Filters the Discord webhook message arguments before sending a fatal error or parse error notification. Introduced in version 3.0.
Example Usage
/**
* Customize the Discord fatal error message.
*
* @param array $args The default Discord webhook message arguments.
* @param array $error The PHP error array from error_get_last().
* @return array Modified Discord webhook message arguments.
*/
function ddtt_customize_fatal_discord_message( $args, $error ) {
// Change the title
$args[ 'title' ] = __( 'Critical Error Detected on', 'dev-debug-tools' ) . ' ' . get_bloginfo( 'name' );
// Change embed color
$args[ 'color' ] = '990000';
// Add a custom field with the error type in more detail
$args[ 'fields' ][] = [
'name' => __( 'Error Severity', 'dev-debug-tools' ),
'value' => isset( $error[ 'type' ] ) && absint( $error[ 'type' ] ) === E_PARSE ? 'Parse Error' : 'Fatal Error',
'inline' => false,
];
return $args;
}
add_filter( 'ddtt_fatal_discord_message_args', 'ddtt_customize_fatal_discord_message', 10, 2 );ddtt_page_not_found_error_messages
TYPE ⇢ Filter
Modify or extend the array of whimsical “page not found” messages used on the plugin 404 pages. By default, the messages use cartoon character-style humor to indicate the requested page does not exist. This filter allows you to add, remove, or replace messages. Introduced in version 3.0.
Example Usage
/**
* Change the capability required to view online users.
*
* @param string $capability The original capability required.
* @return string The modified capability required.
*/
function ddtt_online_users_capability_filter( $capability ) {
return 'edit_pages';
}
add_filter( 'ddtt_online_users_capability', 'ddtt_online_users_capability_filter' );