# Show Outgoing HTTP Requests in the Admin Bar

> Counts the external HTTP requests WordPress, plugins and themes make while building a page, and lists each URL, status and time in an admin bar menu for administrators.

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

## Code

```php
$wpide_http_log = array();

add_filter( 'pre_http_request', function ( $pre, $args, $url ) {
    $GLOBALS['wpide_http_started'][ md5( $url ) ] = microtime( true );
    return $pre;
}, 1, 3 );

add_action( 'http_api_debug', function ( $response, $context, $class, $args, $url ) use ( &$wpide_http_log ) {
    $started          = $GLOBALS['wpide_http_started'][ md5( $url ) ] ?? microtime( true );
    $wpide_http_log[] = array(
        'url'    => $url,
        'method' => $args['method'] ?? 'GET',
        'status' => is_wp_error( $response ) ? $response->get_error_code() : wp_remote_retrieve_response_code( $response ),
        'time'   => round( ( microtime( true ) - $started ) * 1000 ),
    );
}, 10, 5 );

add_action( 'admin_bar_menu', function ( $admin_bar ) use ( &$wpide_http_log ) {
    if ( ! current_user_can( 'manage_options' ) ) {
        return;
    }

    $admin_bar->add_node( array(
        'id'    => 'wpide-http',
        'title' => 'HTTP: ' . count( $wpide_http_log ),
    ) );

    foreach ( $wpide_http_log as $i => $request ) {
        $admin_bar->add_node( array(
            'id'     => 'wpide-http-' . $i,
            'parent' => 'wpide-http',
            'title'  => esc_html( sprintf( '%s %s - %s (%d ms)', $request['method'], wp_parse_url( $request['url'], PHP_URL_HOST ) . wp_parse_url( $request['url'], PHP_URL_PATH ), $request['status'], $request['time'] ) ),
        ) );
    }
}, 999 );
```

## Notes

Slow pages often come from plugins calling remote APIs on every load; this shows them at a glance.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Show Outgoing HTTP Requests in the Admin Bar" 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/
