# Readable Variable Dump for Administrators

> Adds a wpide_dump() helper that shows any variable in a readable, collapsible box only to administrators, so debug output never reaches visitors even if you forget to remove it.

- Type: PHP
- Runs: Run everywhere
- Category: [Developer](https://wpide.com/library/category/developer/)
- Tags: debugging, helper, var-dump
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/debug-pretty-dump-helper/

## Code

```php
if ( ! function_exists( 'wpide_dump' ) ) {
    function wpide_dump( $value, $stop = false ) {
        if ( ! current_user_can( 'manage_options' ) ) {
            return;
        }

        $trace = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 1 );
        $where = isset( $trace[0]['file'] ) ? str_replace( ABSPATH, '', $trace[0]['file'] ) . ':' . $trace[0]['line'] : '';

        printf(
            '<details open style="margin:1rem 0;padding:.75rem 1rem;background:#1d2327;color:#f0f0f1;border-radius:4px;font:12px/1.5 monospace;text-align:left;position:relative;z-index:99999"><summary>%s</summary><pre style="white-space:pre-wrap;margin:.5rem 0 0;color:inherit;background:none">%s</pre></details>',
            esc_html( 'Dump ' . $where ),
            esc_html( print_r( $value, true ) )
        );

        if ( $stop ) {
            exit;
        }
    }
}
```

## Notes

Example wpide_dump( get_queried_object() ); pass true as the second argument to stop the page after the dump.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Readable Variable Dump for Administrators" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
