...

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()

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

PHP
// 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
    Set true return developer email addresses. When false, user IDs are returned.

Example Usage

PHP
// 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. Set true to 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

PHP
// 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

PHP
// 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

PHP
// 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

PHP
// 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 dwl might be used by another plugin or theme, so a long version is available).

PARAMETERS:

  • $log (mixed – required)
    What you want to log to the debug log.
  • $prefix (string | bool)
    Default: true
    If true, adds “DDTT_LOG: ” to beginning of line. You can use your own String as a prefix or false to 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

PHP
// 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

PHP
// 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

PHP
// Send the contents of $_POST to your email ddtt_debug_form_post( '[email protected]' );  // Specify a test number to differentiate multiple test submissions ddtt_debug_form_post( '[email protected]', 2 );  // Customize the subject line of the debug email ddtt_debug_form_post( '[email protected]', 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 to true, the error will be suppressed regardless of the user’s role.

Example Usage

PHP
// 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 to null or 0 to 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 by ddtt_start_timer().
  • $timeout (bool)
    Default: true
    Whether to restore the original cURL timeout setting after the timer stops.
  • $milliseconds (bool)
    Default: false
    If true, returns the result in milliseconds instead of seconds.

Example Usage

PHP
// 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

PHP
// 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

PHP
// Hook into plugin activation to fetch plugin data add_action( 'activated_plugin', function( $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 ); } );

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
    Set true to redact only when the string begins with the server’s absolute path.

Example Usage

PHP
// 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

PHP
/**  * 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  */ add_filter( 'ddtt_wpconfig_snippets', function( $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; } );

ddtt_htaccess_snippets

TYPE ⇢ Filter

Add, remove or modify a snippet from the HTACCESS tab. Find more snippets here.

Example Usage

PHP
/**  * Add, remove or modify a snippet from the DDT HTACCESS tab.  *  * @param array $snippets  * @return array  */ add_filter( 'ddtt_htaccess_snippets', function( $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; } );

ddtt_highlight_debug_log

TYPE ⇢ Filter

Change highlight colors on the Debug Log tab.

Example Usage

PHP
/**  * 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.  */ add_filter( 'ddtt_highlight_debug_log', function( $args ) {     $args[ 'parse-error' ][ 'bg_color' ]   = '#FFA500';     $args[ 'parse-error' ][ 'font_color' ] = '#000000';     return $args; } );

ddtt_highlight_activity_log

TYPE ⇢ Filter

Change highlight colors on the Activity Log tab. Introduced in version 3.0.

Example Usage

PHP
/**  * Change the highlight colors for the Settings-related activity log.  *  * @param array $args Existing highlight args.  * @return array Modified highlight args.  */ add_filter( 'ddtt_highlight_activity_log', function( $args ) {     $args[ 'settings' ][ 'bg_color' ]   = '#FF00FF';     $args[ 'settings' ][ 'font_color' ] = '#FFFFFF';     return $args; } );

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

PHP
/**  * Add your own link to Resources.  *  * @param array $links  * @return array  */ add_filter( 'ddtt_resource_links', function( $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; } );

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

PHP
/**  * 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  */ add_filter( 'ddtt_recommended_plugins', function( $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; } );

TYPE ⇢ Filter

Change the Quick Debug Link icon when quick links are added to posts and users in admin lists. Default is ⚡.

Example Usage

PHP
/**  * 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

PHP
/**  * 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

PHP
/**  * Add or remove post types that include quick links when enabled  *  * @param array $post_types  * @return array  */ add_filter( 'ddtt_quick_link_post_types', function( $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; } );

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

PHP
/**  * Add or modify special admin menu URLs.  *  * @param array $special_urls Array of slug => URL mappings.  * @return array  */ add_filter( 'ddtt_admin_menu_special_urls', function( $special_urls ) {     $special_urls[ 'my-plugin' ] = 'edit.php?post_type=my-plugin-slug';     return $special_urls; } );

TYPE ⇢ Filter

Add a link to the admin bar site name dropdown on the front-end.

Example Usage

PHP
/**  * Add a link to the admin bar site name dropdown on the front-end.  *  * @param array $links  * @return array  */ add_filter( 'ddtt_admin_bar_dropdown_links', function( $links ) {     // Add your own links     $links[] = [ 'Title', 'https://yourlink.com' ];      // Return the new links array     return $links; } );

ddtt_admin_bar_condensed_items

TYPE ⇢ Filter

Modify the admin bar icons that get condensed when the option is set.

Example Usage

PHP
/**  * Modify the admin bar icons that get condensed when the option is set.  *  * @param array $condensed_items The menu item id  * @return array  */ add_filter( 'ddtt_admin_bar_condensed_items', function( $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; } );

ddtt_admin_bar_condensed_ignore

TYPE ⇢ Filter

Exclude specific admin bar nodes from condensation. Introduced in version 3.0.

Example Usage

PHP
/**  * Exclude specific admin bar nodes from condensation.  *  * @param array $ignored_nodes Array of admin bar node IDs to ignore.  * @return array  */ add_filter( 'ddtt_admin_bar_condensed_ignore', function( $ignored_nodes ) {     $ignored_nodes[] = 'your-plugin-node';     return $ignored_nodes; } );

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

PHP
/**  * 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  */ add_filter( 'ddtt_admin_bar_condensed_only_remove_ab_labels', function( $label_only_nodes ) {     $label_only_nodes[] = 'your-plugin-node';     return $label_only_nodes; } );

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

PHP
/**  * 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  */ add_filter( 'ddtt_admin_bar_condensed_css_icon_nodes', function( $css_icon_nodes ) {     $css_icon_nodes[ 'woocommerce' ] = 'ab-icon dashicons-store';     return $css_icon_nodes; } );

ddtt_omit_shortcodes

TYPE ⇢ Filter

Omit shortcodes from the admin bar shortcode finder.

Example Usage

PHP
/**  * Omit shortcodes from the admin bar shortcode finder.  *  * @param array $omits  * @return array  */ add_filter( 'ddtt_omit_shortcodes', function( $omits ) {     // Omit shortcodes starting with these keywords:     // Ex: [shortcode_name param=""]     $omits[] = 'shortcode_name';      // Return the new omits array     return $omits; } );

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

PHP
/**  * 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.  */ add_filter( 'ddtt_shortcode_finder_exclude_post_types', function( $post_types ) {     $post_types[] = 'my_custom_post_type';     return $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

PHP
/**  * 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.  */ add_filter( 'ddtt_shortcode_finder_content', function( $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; } );

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

PHP
/**  * 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  */ add_action( 'ddtt_admin_list_update_each_user', function( $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' );     } } );

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

PHP
/**  * 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  */ add_action( 'ddtt_admin_list_update_each_post', function( $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' );     } } );

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

PHP
/**  * Add a bot crawler to activity log "Bots Crawling Posts and Pages"  *  * @param array $bots  * @return array  */ add_filter( 'ddtt_bots_to_log', function( $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; } );

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

PHP
/**  * Change the capability required to view online users.  *  * @param string $capability The original capability required.  * @return string The modified capability required.  */ add_filter( 'ddtt_online_users_capability', function( $capability ) {     return 'edit_pages'; } );

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

PHP
/**  * Filter the debug log help map.  *  * @param array $map Associative array of regex patterns to their descriptions and links.  * @return array Modified map.  */ add_filter( 'ddtt_help_map_debug_log', function( $map ) {     $map[ '/Custom error pattern/' ] = [         'desc' => 'Description of the custom error.',         'link' => 'https://example.com/docs/custom-error',     ];      return $map; } );

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

PHP
/**  * 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.  */ add_filter( 'ddtt_time_format_choices', function( $format_strings ) {     // Add European style: day/month/year with 24-hour time     $format_strings[] = 'd/m/Y H:i';     return $format_strings; } );

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

PHP
/**  * 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.  */ add_filter( 'ddtt_issues', function( $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; } );  /**  * 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_security_checks

TYPE ⇢ Filter

Add, modify or remove the checks in the Security Checks tool. Each check needs a label, category (exposure, configuration, access, software or code), severity (critical, high, medium, low or info) and callback, with optional risk and fix text shown in the check’s details. The callback returns an array with a status (pass, fail, warning, unknown or info), a message, and optionally items (a list of what was found) and severity (to override the check’s severity for that result). Your checks appear in the tool, the security score, scheduled runs and the Security Checks settings. Checks added after a category has been saved in the settings start turned off in that category. Introduced in version 3.0.6.

Example Usage

PHP
/**  * Add a custom check, change a built-in one, and remove another.  *  * @param array $checks  * @return array  */ add_filter( 'ddtt_security_checks', function( $checks ) {     // Add a new check     $checks[ 'my_staging_flag' ] = [         'label'    => 'Staging Flag Left On',         'category' => 'configuration',         'severity' => 'medium',         'risk'     => 'Staging-only features stay active on the live site.',         'fix'      => 'Remove MY_STAGING from wp-config.php on the live site.',         'callback' => 'ddtt_check_staging_flag',     ];      // Make a built-in check less severe     $checks[ 'xmlrpc' ][ 'severity' ] = 'low';      // Remove a built-in check     unset( $checks[ 'inactive_software' ] );      return $checks; } );  /**  * Check if the staging flag is on.  *  * @return array  */ function ddtt_check_staging_flag() {     if ( defined( 'MY_STAGING' ) && MY_STAGING ) {         return [             'status'  => 'fail',             'message' => 'MY_STAGING is on.',             'items'   => [ 'wp-config.php' ],         ];     }      return [         'status'  => 'pass',         'message' => 'MY_STAGING is off.',     ]; } // End ddtt_check_staging_flag()

ddtt_security_checks_paused

TYPE ⇢ Filter

Pause scheduled runs of the Security Checks tool, such as while another plugin has the site in maintenance mode. Return a reason to pause runs, or an empty string to let them run. The reason is shown in the Security Checks settings and the tool’s sidebar. Runs are already paused while Simple Maintenance Redirect has maintenance mode turned on. Manual runs are not affected. Introduced in version 3.0.6.

Example Usage

PHP
/**  * Pause scheduled security checks while another maintenance plugin is on.  *  * @param string $reason Empty when runs are not paused.  * @return string  */ add_filter( 'ddtt_security_checks_paused', function( $reason ) {     if ( get_option( 'my_maintenance_mode' ) ) {         return 'My Maintenance plugin has maintenance mode turned on.';     }      return $reason; } );

ddtt_security_public_rest_routes

TYPE ⇢ Filter

Skip REST routes that are public on purpose, such as a contact form endpoint, in the Public REST Routes That Accept Changes and Public REST Routes From Plugins and Themes checks. Routes must match exactly as the checks list them, without the method. Defaults to /batch/v1 and /llar/v1/mfa/send-code (Limit Login Attempts Reloaded’s two-factor code). Introduced in version 3.0.6.

Example Usage

PHP
/**  * Skip REST routes that are public on purpose.  *  * @param array $routes  * @return array  */ add_filter( 'ddtt_security_public_rest_routes', function( $routes ) {     $routes[] = '/my-plugin/v1/contact';     return $routes; } );

ddtt_security_admin_inactive_days

TYPE ⇢ Filter

Change how many days an administrator can go without activity before the Administrator Accounts security check flags them. Activity comes from the plugin’s last online tracking or the administrator’s latest login session. Defaults to 180. Return 0 to turn off the inactivity part of the check. Introduced in version 3.0.6.

Example Usage

PHP
/**  * Flag administrators who have not been active in 90 days.  *  * @param int $days  * @return int  */ add_filter( 'ddtt_security_admin_inactive_days', function( $days ) {     return 90; } );

ddtt_security_max_admins

TYPE ⇢ Filter

Change how many administrator accounts are allowed before the Powerful Capabilities Outside Administrators security check warns. Defaults to 5. Return 0 to turn off the warning. Introduced in version 3.0.6.

Example Usage

PHP
/**  * Allow up to 10 administrators before warning.  *  * @param int $max  * @return int  */ add_filter( 'ddtt_security_max_admins', function( $max ) {     return 10; } );

ddtt_security_dev_plugins

TYPE ⇢ Filter

Change the plugin folders treated as developer plugins by the Developer Plugins on Production security check. The check only runs when the environment type is production, and plugins whose folder starts with debug-bar- are always included. Defaults include Query Monitor, Debug Bar, WP Reset, FakerPress, several database and file manager plugins, Theme Check and Log Deprecated Notices. Introduced in version 3.0.6.

Example Usage

PHP
/**  * Add a developer plugin to the list and remove another.  *  * @param array $folders Plugin folder names.  * @return array  */ add_filter( 'ddtt_security_dev_plugins', function( $folders ) {     // Add a plugin folder     $folders[] = 'my-debug-helper';      // Allow Query Monitor on production     $folders = array_diff( $folders, [ 'query-monitor' ] );      return $folders; } );

ddtt_security_known_php_files

TYPE ⇢ Filter

Allow extra PHP files in the main WordPress folder (root) or at the top of wp-content (content) so the PHP Files in Unexpected Places security check does not flag them, such as a loader your host adds. The defaults are the WordPress core files, wp-config.php, wordfence-waf.php, wp-cache-config.php and the standard drop-ins. Introduced in version 3.0.6.

Example Usage

PHP
/**  * Allow PHP files that the host adds.  *  * @param array $files [ 'root' => file names, 'content' => file names ]  * @return array  */ add_filter( 'ddtt_security_known_php_files', function( $files ) {     $files[ 'root' ][] = 'host-loader.php';     $files[ 'content' ][] = 'host-cache-config.php';     return $files; } );

ddtt_security_php_eol

TYPE ⇢ Filter

Change the end-of-life dates used by the PHP Version Unsupported security check, as branch => Y-m-d. The defaults are the security support end dates from php.net. Use this to add a new PHP branch before the plugin is updated. Branches older than the oldest one listed always fail. Introduced in version 3.0.6.

Example Usage

PHP
/**  * Set the end-of-life date for a PHP branch.  *  * @param array $eol [ branch => Y-m-d ]  * @return array  */ add_filter( 'ddtt_security_php_eol', function( $eol ) {     // Security support end date from php.net     $eol[ '8.4' ] = '2028-12-31';     return $eol; } );

ddtt_security_mysql_eol

TYPE ⇢ Filter

Change the MySQL end-of-life dates used by the Database Version Unsupported security check, as branch => Y-m-d. The defaults come from endoflife.date. Introduced in version 3.0.6.

Example Usage

PHP
/**  * Set the end-of-life date for a MySQL branch.  *  * @param array $eol [ branch => Y-m-d ]  * @return array  */ add_filter( 'ddtt_security_mysql_eol', function( $eol ) {     $eol[ '8.4' ] = '2032-04-30';     return $eol; } );

ddtt_security_mariadb_eol

TYPE ⇢ Filter

Change the MariaDB end-of-life dates used by the Database Version Unsupported security check, as branch => Y-m-d. The defaults are the community support end dates from endoflife.date. Introduced in version 3.0.6.

Example Usage

PHP
/**  * Set the end-of-life date for a MariaDB branch.  *  * @param array $eol [ branch => Y-m-d ]  * @return array  */ add_filter( 'ddtt_security_mariadb_eol', function( $eol ) {     $eol[ '11.4' ] = '2029-05-29';     return $eol; } );

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

PHP
/**  * 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.  */ add_filter( 'ddtt_easy_log_parse_error', function( $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; }, 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

PHP
/**  * Add a custom search option for error messages.  *  * @param array $options The existing array of search options.  *  * @return array Modified array of search options.  */ add_filter( 'ddtt_error_help_search_options', function( $options ) {      $options[] = [         'label' => __( 'Search Stack Overflow', 'dev-debug-tools' ),         'url'   => 'https://stackoverflow.com/search?q={string}',     ];      return $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

PHP
/**  * 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.  */ add_filter( 'ddtt_metadata_ui_setting_keys', function( $keys ) {     $keys[] = 'my_custom_ui_setting_*';     return $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

PHP
/**  * 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.  */ add_filter( 'ddtt_protected_meta_keys', function( $keys ) {     $keys[] = '_my_custom_meta_key';     return $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

PHP
/**  * 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.  */ add_filter( 'ddtt_site_option_prefixes', function( $prefixes ) {     $prefixes[ 'my_plugin_options_prefix_' ] = 'Plugin: My Custom Plugin';     return $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

PHP
/**  * 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.  */ add_filter( 'ddtt_online_users_discord_message_args', function( $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; }, 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

PHP
/**  * 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.  */ add_filter( 'ddtt_fatal_discord_message_args', function( $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; }, 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

PHP
/**  * Add your own "page not found" messages.  *  * @param array $messages  * @return array  */ add_filter( 'ddtt_page_not_found_error_messages', function( $messages ) {     // Add a message     $messages[] = 'This page went out for coffee and never came back.';      // Or replace them all (always keep at least one message)     // $messages = [ 'Sorry, this page does not exist.' ];      return $messages; } );

ddtt_playground_author_plugins

TYPE ⇢ Filter

Modify the “Add All PluginRx Plugins” button on the WordPress Playground link generator (Testing tool sidebar). Change the label, target a different WordPress.org author, supply a manual list of slugs, or remove the button entirely.

Example Usage

PHP
/**  * Modify the "Add All PluginRx Plugins" button on the WordPress Playground link generator.  *  * @param array $config  * @return array  */ add_filter( 'ddtt_playground_author_plugins', function( $config ) {     // Change the label and target a different WordPress.org author     $config[ 'label' ]  = 'Add All Acme Plugins';     $config[ 'author' ] = 'acmecorp';      // Or bypass WordPress.org entirely with a manual slug list     // $config[ 'label' ]  = 'Add All Custom Plugins';     // $config[ 'slugs' ] = [ 'my-plugin-one', 'my-plugin-two' ];      // Or remove the button entirely     // $config[ 'enabled' ] = false;      // Always return the config array     return $config; } );

Sign In

Register

Reset Password

Please enter your username or email address, you will receive a link to create a new password via email.

Seraphinite AcceleratorOptimized by Seraphinite Accelerator
Turns on site high speed to be attractive for people and search engines.