Version Description
Add a new panel for HTTP requests using the native WP methods.
AMP dev mode compatibility.
Change cache busters to use filemtime
instead of hardcoded values.
Minor CSS updates, so themes don't override the pre
styles.
Download this release
Release Info
Developer | aidvu |
Plugin | Debug Bar |
Version | 1.1 |
Comparing to | |
See all releases |
Code changes from version 1.0.1 to 1.1
- css/debug-bar.css +1 -1
- css/debug-bar.dev.css +1 -0
- debug-bar.php +63 -3
- panels/class-debug-bar-wp-http.php +142 -0
- readme.txt +15 -3
css/debug-bar.css
CHANGED
@@ -1 +1 @@
|
|
1 |
-
#wpadminbar #wp-admin-bar-debug-bar{float:right}#wpadminbar #wp-admin-bar-debug-bar.active{background:#555;background:-moz-linear-gradient(bottom,#555,#3e3e3e);background:-webkit-gradient(linear,left bottom,left top,from(#555),to(#3e3e3e))}#wpadminbar #wp-admin-bar-debug-bar.debug-bar-php-notice-summary,#wpadminbar #wp-admin-bar-debug-bar.debug-bar-php-notice-summary .ab-item:focus{background-color:#ff8922;background-image:-moz-linear-gradient(bottom,#ee6f00,#ff8922);background-image:-webkit-gradient(linear,left bottom,left top,from(#ee6f00),to(#ff8922))}#wpadminbar #wp-admin-bar-debug-bar.debug-bar-php-notice-summary .ab-item:hover,.debug-bar-visible #wpadminbar #wp-admin-bar-debug-bar.debug-bar-php-notice-summary,.debug-bar-visible #wpadminbar #wp-admin-bar-debug-bar.debug-bar-php-notice-summary .ab-item:focus{background-color:#ee6f00;background-image:-moz-linear-gradient(bottom,#ff8922,#ee6f00);background-image:-webkit-gradient(linear,left bottom,left top,from(#ff8922),to(#ee6f00))}#wpadminbar #wp-admin-bar-debug-bar.debug-bar-php-notice-summary .ab-item{color:#fff;text-shadow:0 -1px 0 #884000}#wpadminbar #wp-admin-bar-debug-bar.debug-bar-php-warning-summary,#wpadminbar #wp-admin-bar-debug-bar.debug-bar-php-warning-summary .ab-item:focus{background-color:#f44;background-image:-moz-linear-gradient(bottom,#d00,#f44);background-image:-webkit-gradient(linear,left bottom,left top,from(#d00),to(#f44))}#wpadminbar #wp-admin-bar-debug-bar.debug-bar-php-warning-summary .ab-item:hover,.debug-bar-visible #wpadminbar #wp-admin-bar-debug-bar.debug-bar-php-warning-summary,.debug-bar-visible #wpadminbar #wp-admin-bar-debug-bar.debug-bar-php-warning-summary .ab-item:focus{background-color:#d00;background-image:-moz-linear-gradient(bottom,#f44,#d00);background-image:-webkit-gradient(linear,left bottom,left top,from(#f44),to(#d00))}#wpadminbar #wp-admin-bar-debug-bar.debug-bar-php-warning-summary .ab-item{color:#fff;text-shadow:0 -1px 0 #700}#wpadminbar #wp-admin-bar-debug-bar ul{right:0}#querylist{direction:ltr;display:none;position:fixed;height:33%;min-height:350px;font-family:"Helvetica Neue",sans-serif;left:0;right:0;bottom:0;background:#f1f1f1;z-index:99000;color:#000;line-height:150%!important
|
1 |
+
#wpadminbar #wp-admin-bar-debug-bar{float:right}#wpadminbar #wp-admin-bar-debug-bar.active{background:#555;background:-moz-linear-gradient(bottom,#555,#3e3e3e);background:-webkit-gradient(linear,left bottom,left top,from(#555),to(#3e3e3e))}#wpadminbar #wp-admin-bar-debug-bar.debug-bar-php-notice-summary,#wpadminbar #wp-admin-bar-debug-bar.debug-bar-php-notice-summary .ab-item:focus{background-color:#ff8922;background-image:-moz-linear-gradient(bottom,#ee6f00,#ff8922);background-image:-webkit-gradient(linear,left bottom,left top,from(#ee6f00),to(#ff8922))}#wpadminbar #wp-admin-bar-debug-bar.debug-bar-php-notice-summary .ab-item:hover,.debug-bar-visible #wpadminbar #wp-admin-bar-debug-bar.debug-bar-php-notice-summary,.debug-bar-visible #wpadminbar #wp-admin-bar-debug-bar.debug-bar-php-notice-summary .ab-item:focus{background-color:#ee6f00;background-image:-moz-linear-gradient(bottom,#ff8922,#ee6f00);background-image:-webkit-gradient(linear,left bottom,left top,from(#ff8922),to(#ee6f00))}#wpadminbar #wp-admin-bar-debug-bar.debug-bar-php-notice-summary .ab-item{color:#fff;text-shadow:0 -1px 0 #884000}#wpadminbar #wp-admin-bar-debug-bar.debug-bar-php-warning-summary,#wpadminbar #wp-admin-bar-debug-bar.debug-bar-php-warning-summary .ab-item:focus{background-color:#f44;background-image:-moz-linear-gradient(bottom,#d00,#f44);background-image:-webkit-gradient(linear,left bottom,left top,from(#d00),to(#f44))}#wpadminbar #wp-admin-bar-debug-bar.debug-bar-php-warning-summary .ab-item:hover,.debug-bar-visible #wpadminbar #wp-admin-bar-debug-bar.debug-bar-php-warning-summary,.debug-bar-visible #wpadminbar #wp-admin-bar-debug-bar.debug-bar-php-warning-summary .ab-item:focus{background-color:#d00;background-image:-moz-linear-gradient(bottom,#f44,#d00);background-image:-webkit-gradient(linear,left bottom,left top,from(#f44),to(#d00))}#wpadminbar #wp-admin-bar-debug-bar.debug-bar-php-warning-summary .ab-item{color:#fff;text-shadow:0 -1px 0 #700}#wpadminbar #wp-admin-bar-debug-bar ul{right:0}#querylist,#querylist pre{text-align:left;font-size:12px}#querylist{direction:ltr;display:none;position:fixed;height:33%;min-height:350px;font-family:"Helvetica Neue",sans-serif;left:0;right:0;bottom:0;background:#f1f1f1;z-index:99000;color:#000;line-height:150%!important}#querylist a{border:0;text-decoration:underline!important;color:#00f!important}.debug-bar-maximized #debug-bar-actions span.restore,.debug-bar-visible #querylist{display:block}.debug-bar-maximized #querylist{position:fixed;top:28px;height:auto}body.debug-bar-maximized.debug-bar-visible{overflow:hidden}#debug-bar-info{height:60px;width:100%;position:absolute;z-index:200;background:#f1f1f1;border-bottom:1px solid #fff;box-shadow:0 0 6px rgba(0,0,0,.4);background-color:#f1f1f1;background-image:-ms-linear-gradient(top,#f9f9f9,#dfdfdf);background-image:-moz-linear-gradient(top,#f9f9f9,#dfdfdf);background-image:-o-linear-gradient(top,#f9f9f9,#dfdfdf);background-image:-webkit-gradient(linear,left top,left bottom,from(#f9f9f9),to(#dfdfdf));background-image:-webkit-linear-gradient(top,#f9f9f9,#dfdfdf);background-image:linear-gradient(top,#f9f9f9,#dfdfdf)}#debug-bar-menu,#debug-menu-targets{overflow:auto;position:absolute;top:61px;bottom:0}#debug-bar-menu{left:0;width:250px;z-index:100;text-shadow:0 1px 1px rgba(0,0,0,.9);background:#333;-webkit-box-shadow:inset -3px 0 6px rgba(0,0,0,.4);-moz-box-shadow:inset -3px 0 6px rgba(0,0,0,.4);box-shadow:inset -3px 0 6px rgba(0,0,0,.4)}#debug-menu-targets{left:250px;right:0;z-index:150}#debug-status{float:left;padding-left:20px;color:#bbb;font-size:14px;line-height:60px}.debug-status{float:left;margin-right:40px}#debug-status .debug-status-title{color:#555;font-weight:500;line-height:18px;font-size:12px;margin-top:10px}#debug-status .debug-status-data{color:#999;font-weight:200;line-height:20px;font-size:18px}#debug-status #debug-status-warning{font-weight:700;color:red}#debug-status #debug-status-site{font-weight:700}#querylist pre{padding:10px}#querylist .left{float:left}#querylist .right{float:right}#querylist h1,#querylist h2,#querylist h3{font-weight:400}#debug-menu-links{overflow:hidden;list-style:none;margin:0;padding:0}#debug-menu-links li{float:left;margin-bottom:0!important}#debug-menu-links li a{box-sizing:content-box;padding:0 20px;width:210px;line-height:32px;outline:0;display:block;margin:0;color:#fff!important;font-weight:500!important;font-size:14px}#debug-menu-links li a.current{background:rgba(0,0,0,.2)}#querylist h2{float:left;min-width:150px;border:1px solid #eee;padding:5px 10px 15px;clear:none;text-align:center;color:#000;font-family:georgia,times,serif;font-size:28px;margin:15px 10px 15px 0!important}#querylist h2 span{font-size:12px;color:#888;text-transform:uppercase;white-space:nowrap;display:block;margin-bottom:5px}#querylist h2 span#debug-bar-js-error-count{font-size:inherit;color:inherit;text-transform:inherit;white-space:inherit;display:inherit;margin-bottom:inherit}#object-cache-stats h2{border:0;float:left;text-align:left;font-size:22px;margin-bottom:0}#object-cache-stats ul.debug-menu-links,#object-cache-stats-menu-targets{clear:both}.object-cache-stats-menu-target pre{white-space:pre-wrap;margin:1rem 0}#object-cache-stats ul.debug-menu-links li{float:left;margin:0 10px 10px 0;background:0 0;border:1px solid #eee;color:#4b5259;list-style:none}#object-cache-stats ul.debug-menu-links li:hover{border-color:#ddd}#object-cache-stats ul.debug-menu-links li a{background:0 0;color:#4b5259;overflow:hidden;display:block;padding:5px 9px;text-decoration:none}#querylist h3{margin-bottom:15px}#debug-bar-deprecated ol.debug-bar-deprecated-list,#debug-bar-js ol.debug-bar-js-list,#debug-bar-php ol.debug-bar-php-list,#querylist ol.wpd-queries{padding:0!important;margin:0!important;list-style:none;clear:left}#querylist ol.wpd-queries li{padding:10px;background:#f0f0f0;margin:0 0 10px}#querylist ol.wpd-queries li div.qdebug{background:#e8e8e8;margin:10px -10px -10px;padding:5px 150px 5px 5px;font-size:11px;position:relative;min-height:20px}#querylist ol.wpd-queries li div.qdebug span{position:absolute;right:10px;top:5px;white-space:nowrap}#debug-menu-links li a,#querylist a:hover{text-decoration:none!important}#querylist .debug-menu-target{margin:20px;display:none}#querylist ol{font:12px Monaco,"Courier New",Courier,Fixed!important;line-height:180%!important}#querylist table{table-layout:auto}#querylist td,#querylist th{text-transform:none}#querylist table,#querylist table td,#querylist table th{border:0;vertical-align:top}#debug-bar-php ol.debug-bar-php-list li{padding:10px;margin:0 0 10px}#debug-bar-php .debug-bar-php-warning{background-color:#ffebe8;border:1px solid #c00}#debug-bar-php .debug-bar-php-notice{background-color:#ffffe0;border:1px solid #e6db55}#debug-bar-deprecated ol.debug-bar-deprecated-list li,#debug-bar-request p{padding:10px;margin:0 0 10px;background:#f0f0f0}#debug-bar-wp-query table.debug-bar-wp-query-list{width:100%;border-collapse:collapse;cell-padding:1em;clear:both}#debug-bar-wp-query table.debug-bar-wp-query-list td{padding:.5em 5px;border-bottom:1px solid #ccc}#debug-bar-wp-query table.debug-bar-wp-query-list th{padding:.5em 5px;font-weight:700;border-bottom:1px solid #ccc}#debug-bar-wp-query table.debug-bar-wp-query-list tr:nth-child(2n+1){background-color:#e8e8e8}#debug-bar-wp-query table.debug-bar-wp-query-list tr td:first-of-type{font-size:140%;padding:.3em .5em}#debug-bar-request h3,#debug-bar-wp-query h3{float:none;clear:both;font-family:georgia,times,serif;font-size:22px;margin:15px 10px 15px 0!important}#debug-bar-actions{position:absolute;top:21px;right:20px;z-index:300}#debug-bar-actions span{-moz-border-radius:20px;-webkit-border-radius:20px;border-radius:20px;display:block;float:left;height:19px;width:19px;margin-left:5px;font-size:18px;line-height:14px;text-align:center;font-weight:700;color:#eee;background:#aaa;cursor:pointer}#debug-bar-actions span:hover{background:#888}#debug-bar-actions span.restore{line-height:15px}#debug-menu-links li a#debug-menu-link-Debug_Bar_JS,#wp-admin-bar-debug-bar-Debug_Bar_JS,.debug-bar-maximized #debug-bar-actions span.maximize,.debug-bar-partial #debug-bar-actions span.restore{display:none}.debug-bar-partial #debug-bar-actions span.maximize{display:block}#debug-bar-js ol.debug-bar-js-list li{padding:10px;margin:0 0 10px}#debug-bar-js .debug-bar-js-error{background-color:#ffebe8;border:1px solid #c00}#debug-bar-js .debug-bar-js-error span{color:#666;font-size:.8em;display:block}#debug-bar-js .debug-bar-js-error:hover span{color:#000}
|
css/debug-bar.dev.css
CHANGED
@@ -175,6 +175,7 @@ body.debug-bar-maximized.debug-bar-visible {
|
|
175 |
}
|
176 |
|
177 |
#querylist pre {
|
|
|
178 |
font-size: 12px;
|
179 |
padding: 10px;
|
180 |
}
|
175 |
}
|
176 |
|
177 |
#querylist pre {
|
178 |
+
text-align: left;
|
179 |
font-size: 12px;
|
180 |
padding: 10px;
|
181 |
}
|
debug-bar.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
Plugin URI: https://wordpress.org/plugins/debug-bar/
|
5 |
Description: Adds a debug menu to the admin bar that shows query, cache, and other helpful debugging information.
|
6 |
Author: wordpressdotorg
|
7 |
-
Version: 1.
|
8 |
Author URI: https://wordpress.org/
|
9 |
Text Domain: debug-bar
|
10 |
*/
|
@@ -25,6 +25,9 @@ class Debug_Bar {
|
|
25 |
add_action( 'admin_init', array( $this, 'init_ajax' ) );
|
26 |
}
|
27 |
add_action( 'admin_bar_init', array( $this, 'init' ) );
|
|
|
|
|
|
|
28 |
}
|
29 |
|
30 |
function Debug_Bar() {
|
@@ -32,6 +35,19 @@ class Debug_Bar {
|
|
32 |
self::__construct();
|
33 |
}
|
34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
function init() {
|
36 |
if ( ! $this->enable_debug_bar() ) {
|
37 |
return;
|
@@ -111,9 +127,31 @@ class Debug_Bar {
|
|
111 |
function enqueue() {
|
112 |
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.dev' : '';
|
113 |
|
114 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
|
116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
|
118 |
do_action( 'debug_bar_enqueue_scripts' );
|
119 |
}
|
@@ -202,6 +240,27 @@ class Debug_Bar {
|
|
202 |
return $classes;
|
203 |
}
|
204 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
function render() {
|
206 |
global $wpdb;
|
207 |
|
@@ -324,3 +383,4 @@ class Debug_Bar {
|
|
324 |
}
|
325 |
|
326 |
$GLOBALS['debug_bar'] = new Debug_Bar();
|
|
4 |
Plugin URI: https://wordpress.org/plugins/debug-bar/
|
5 |
Description: Adds a debug menu to the admin bar that shows query, cache, and other helpful debugging information.
|
6 |
Author: wordpressdotorg
|
7 |
+
Version: 1.1
|
8 |
Author URI: https://wordpress.org/
|
9 |
Text Domain: debug-bar
|
10 |
*/
|
25 |
add_action( 'admin_init', array( $this, 'init_ajax' ) );
|
26 |
}
|
27 |
add_action( 'admin_bar_init', array( $this, 'init' ) );
|
28 |
+
|
29 |
+
// Stop the removal of important assets in AMP dev mode
|
30 |
+
add_filter( 'amp_dev_mode_element_xpaths', array( $this, 'amp_dev_mode_element_xpaths' ) );
|
31 |
}
|
32 |
|
33 |
function Debug_Bar() {
|
35 |
self::__construct();
|
36 |
}
|
37 |
|
38 |
+
// Runs immediately after constructor
|
39 |
+
function early_init() {
|
40 |
+
$path = plugin_dir_path( __FILE__ );
|
41 |
+
$recs = array( 'panel', 'wp-http' );
|
42 |
+
foreach ( $recs as $rec ) {
|
43 |
+
require_once "$path/panels/class-debug-bar-$rec.php";
|
44 |
+
}
|
45 |
+
|
46 |
+
$panel = new Debug_Bar_WP_Http();
|
47 |
+
$this->panels[] = $panel;
|
48 |
+
$panel->early_init();
|
49 |
+
}
|
50 |
+
|
51 |
function init() {
|
52 |
if ( ! $this->enable_debug_bar() ) {
|
53 |
return;
|
127 |
function enqueue() {
|
128 |
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.dev' : '';
|
129 |
|
130 |
+
$style_dependencies = array();
|
131 |
+
$script_dependencies = array( 'jquery' );
|
132 |
+
if ( $this->is_amp() ) {
|
133 |
+
// Add admin-bar dependencies so AMP dev mode will stop removing debug-bar assets
|
134 |
+
// https://weston.ruter.net/2019/09/24/integrating-with-amp-dev-mode-in-wordpress/
|
135 |
+
$style_dependencies[] = 'admin-bar';
|
136 |
+
$script_dependencies[] = 'admin-bar';
|
137 |
+
}
|
138 |
+
|
139 |
+
$css_filename = "css/debug-bar$suffix.css";
|
140 |
+
wp_enqueue_style(
|
141 |
+
'debug-bar',
|
142 |
+
plugins_url( $css_filename, __FILE__ ),
|
143 |
+
$style_dependencies,
|
144 |
+
filemtime( __DIR__ . '/' . $css_filename )
|
145 |
+
);
|
146 |
|
147 |
+
$js_filename = "js/debug-bar$suffix.js";
|
148 |
+
wp_enqueue_script(
|
149 |
+
'debug-bar',
|
150 |
+
plugins_url( $js_filename, __FILE__ ),
|
151 |
+
$script_dependencies,
|
152 |
+
filemtime( __DIR__ . '/' . $js_filename ),
|
153 |
+
true
|
154 |
+
);
|
155 |
|
156 |
do_action( 'debug_bar_enqueue_scripts' );
|
157 |
}
|
240 |
return $classes;
|
241 |
}
|
242 |
|
243 |
+
/*
|
244 |
+
* AMP Compatibility
|
245 |
+
* Based primarily on approach described in https://weston.ruter.net/2019/09/24/integrating-with-amp-dev-mode-in-wordpress/
|
246 |
+
*/
|
247 |
+
function is_amp() {
|
248 |
+
return function_exists( 'is_amp_endpoint' ) && is_amp_endpoint();
|
249 |
+
}
|
250 |
+
|
251 |
+
function amp_dev_mode_element_xpaths( $xpaths ) {
|
252 |
+
// Add data-ampdevmode to jQuery script tag so it will be left intact
|
253 |
+
$xpaths[] = '//script[ contains( @src, "wp-includes/js/jquery/jquery.js" ) ]';
|
254 |
+
|
255 |
+
// Add data-ampdevmode to object cache scripts used by the debug bar
|
256 |
+
$xpaths[] = '//*[@id = "object-cache-stats"]//script';
|
257 |
+
|
258 |
+
// Add data-ampdevmode to debug-menu-links because AMP is removing inline onclick handlers
|
259 |
+
$xpaths[] = '//*[@class = "debug-menu-links"]//a';
|
260 |
+
|
261 |
+
return $xpaths;
|
262 |
+
}
|
263 |
+
|
264 |
function render() {
|
265 |
global $wpdb;
|
266 |
|
383 |
}
|
384 |
|
385 |
$GLOBALS['debug_bar'] = new Debug_Bar();
|
386 |
+
$GLOBALS['debug_bar']->early_init();
|
panels/class-debug-bar-wp-http.php
ADDED
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Debug_Bar_WP_Http_Request {
|
4 |
+
public $time_start;
|
5 |
+
public $time_end;
|
6 |
+
|
7 |
+
public $request;
|
8 |
+
public $result;
|
9 |
+
public $stack_trace;
|
10 |
+
|
11 |
+
function __construct( $request ) {
|
12 |
+
$this->time_start = microtime( true );
|
13 |
+
if ( ! isset( $_GET['fullbody'] ) ) {
|
14 |
+
$request['args']['body'] = '[omitted]';
|
15 |
+
}
|
16 |
+
$this->request = $request;
|
17 |
+
}
|
18 |
+
|
19 |
+
function end( $result ) {
|
20 |
+
$this->time_end = microtime( true );
|
21 |
+
if ( is_array( $result['r'] ) && ! isset( $_GET['fullbody'] ) ) {
|
22 |
+
$result['r']['body'] = '[omitted]';
|
23 |
+
$result['args']['body'] = '[omitted]';
|
24 |
+
}
|
25 |
+
$this->result = $result;
|
26 |
+
$this->stack_trace = wp_debug_backtrace_summary( null, 0, false );
|
27 |
+
}
|
28 |
+
}
|
29 |
+
|
30 |
+
class Debug_Bar_WP_Http extends Debug_Bar_Panel {
|
31 |
+
public $requests = array();
|
32 |
+
|
33 |
+
function early_init() {
|
34 |
+
add_filter( 'http_request_args', array( $this, 'before_http_request' ), 10, 3 );
|
35 |
+
add_action( 'http_api_debug', array( $this, 'after_http_request' ), 10, 5 );
|
36 |
+
}
|
37 |
+
|
38 |
+
function before_http_request( $args, $url ) {
|
39 |
+
$request = new Debug_Bar_WP_Http_Request( array(
|
40 |
+
'args' => $args,
|
41 |
+
'url' => $url,
|
42 |
+
) );
|
43 |
+
|
44 |
+
$this->requests["$request->time_start"] = $request;
|
45 |
+
$args['time_start'] = $request->time_start;
|
46 |
+
|
47 |
+
return $args;
|
48 |
+
}
|
49 |
+
|
50 |
+
function after_http_request( $response, $type, $class, $args, $url ) {
|
51 |
+
if ( $type !== 'response' ) {
|
52 |
+
return;
|
53 |
+
}
|
54 |
+
|
55 |
+
$request =& $this->requests["{$args['time_start']}"];
|
56 |
+
$request->end( array(
|
57 |
+
'r' => $response,
|
58 |
+
'class' => $class,
|
59 |
+
'args' => $args,
|
60 |
+
'url' => $url,
|
61 |
+
) );
|
62 |
+
}
|
63 |
+
|
64 |
+
function count_errors() {
|
65 |
+
return 0;
|
66 |
+
}
|
67 |
+
|
68 |
+
function init() {
|
69 |
+
$this->title( __( 'WP_Http', 'debug-bar' ) );
|
70 |
+
}
|
71 |
+
|
72 |
+
function prerender() {
|
73 |
+
$this->set_visible( ! empty( $this->requests ) );
|
74 |
+
}
|
75 |
+
|
76 |
+
function debug_bar_classes( $classes ) {
|
77 |
+
if ( $this->count_errors() ) {
|
78 |
+
$classes[] = 'debug-bar-php-warning-summary';
|
79 |
+
}
|
80 |
+
|
81 |
+
return $classes;
|
82 |
+
}
|
83 |
+
|
84 |
+
function render() {
|
85 |
+
$out = "
|
86 |
+
<style>
|
87 |
+
#pdbhttp { clear: left; }
|
88 |
+
#pdbhttp .err { background-color: #ffebe8; border: 1px solid #c00; }
|
89 |
+
#pdbhttp th, #pdbhttp td { padding: 8px; }
|
90 |
+
#pdbhttp pre { font-family: monospace; }
|
91 |
+
</style>\n";
|
92 |
+
$out .= "<script>function pdbhttp_toggle(e) {jQuery(e).toggle();}</script>";
|
93 |
+
$out .= "<table id='pdbhttp'>\n";
|
94 |
+
$out .= "<thead><tr><th>More</th><th>Start</th><th>Duration</th><th>Method</th><th>URL</th><th>Code</th></tr></thead>\n<tbody>\n";
|
95 |
+
|
96 |
+
$total_time = 0;
|
97 |
+
$total_errors = 0;
|
98 |
+
foreach ( array_values( $this->requests ) as $i => $r ) {
|
99 |
+
$start = $r->time_start - $_SERVER['REQUEST_TIME_FLOAT'];
|
100 |
+
$elapsed = $r->time_end - $r->time_start;
|
101 |
+
$total_time += $elapsed;
|
102 |
+
|
103 |
+
$class = '';
|
104 |
+
$code = '';
|
105 |
+
if ( is_wp_error( $r->result['r'] ) || $r->result['r']['response']['code'] >= 400 ) {
|
106 |
+
$class = 'err';
|
107 |
+
$total_errors++;
|
108 |
+
if ( is_wp_error( $r->result['r'] ) ) {
|
109 |
+
$code = $r->result['r']->get_error_code();
|
110 |
+
} else {
|
111 |
+
$code = $r->result['r']['response']['code'];
|
112 |
+
}
|
113 |
+
}
|
114 |
+
|
115 |
+
$out .= "<tr class='$class'>";
|
116 |
+
$out .= "<td><a onclick='pdbhttp_toggle(\"#pdbhttp_$i\")'>Toggle</a></td>";
|
117 |
+
$out .= "<td>" . number_format( sprintf( '%0.1f', $start * 1000 ), 1 ) . " ms</td>";
|
118 |
+
$out .= "<td>" . number_format( sprintf( '%0.1f', $elapsed * 1000 ), 1 ) . " ms</td>";
|
119 |
+
$out .= "<td>{$r->request['args']['method']}</td>";
|
120 |
+
$out .= "<td>{$r->request['url']}</td>";
|
121 |
+
$out .= "<td>{$code}</td>";
|
122 |
+
$out .= "</tr>\n";
|
123 |
+
$out .= "<tr id='pdbhttp_$i' style='display: none'><td colspan=5><pre>" . esc_html( print_r( $r, 1 ) ) . "</pre></td></tr>\n";
|
124 |
+
}
|
125 |
+
$out .= "</tbody>\n</table>\n";
|
126 |
+
|
127 |
+
$heading = '';
|
128 |
+
$heading .= '<h2><span>HTTP Requests:</span>' . number_format( count( $this->requests ) ) . "</h2>\n";
|
129 |
+
$heading .= '<h2><span>Total Elapsed:</span>' . number_format( sprintf( '%0.1f', $total_time * 1000 ), 1 ) . " ms</h2>\n";
|
130 |
+
$heading .= '<h2><span>Errors:</span>' . number_format( $total_errors ) . "</h2>\n";
|
131 |
+
|
132 |
+
if ( isset( $_GET['fullbody'] ) ) {
|
133 |
+
$heading .= '<p style="clear:left">Request and response bodies are included. <a href="' . esc_attr( remove_query_arg( 'fullbody' ) ) . '">Reload with those omitted.</a>';
|
134 |
+
} else {
|
135 |
+
$heading .= '<p style="clear:left">Request and response bodies are omitted. <a href="' . esc_attr( add_query_arg( 'fullbody', 'please' ) ) . '">Reload with those included.</a>';
|
136 |
+
}
|
137 |
+
|
138 |
+
$out = $heading . $out;
|
139 |
+
|
140 |
+
echo $out;
|
141 |
+
}
|
142 |
+
}
|
readme.txt
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
=== Debug Bar ===
|
2 |
-
Contributors: wordpressdotorg, ryan, westi, koopersmith, duck_, mitchoyoshitaka, dd32, jrf, obenland
|
3 |
Tags: debug
|
4 |
-
Tested up to: 5.
|
5 |
-
Stable tag: 1.
|
6 |
Requires at least: 3.4
|
7 |
|
8 |
Adds a debug menu to the admin bar that shows query, cache, and other helpful debugging information.
|
@@ -29,6 +29,12 @@ There are numerous other add-ons available to get more insight into, for instanc
|
|
29 |
|
30 |
== Upgrade Notice ==
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
= 1.0.1 =
|
33 |
Update object cache panel CSS to be ready for new object-cache.php release with better stats()
|
34 |
|
@@ -100,6 +106,12 @@ Initial Release
|
|
100 |
|
101 |
== Changelog ==
|
102 |
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
= 1.0.1 =
|
104 |
Update object cache panel CSS to be ready for new object-cache.php release with better stats()
|
105 |
|
1 |
=== Debug Bar ===
|
2 |
+
Contributors: wordpressdotorg, ryan, westi, koopersmith, duck_, mitchoyoshitaka, dd32, jrf, obenland, nacin, evansolomon, Otto42, aidvu
|
3 |
Tags: debug
|
4 |
+
Tested up to: 5.5.1
|
5 |
+
Stable tag: 1.1
|
6 |
Requires at least: 3.4
|
7 |
|
8 |
Adds a debug menu to the admin bar that shows query, cache, and other helpful debugging information.
|
29 |
|
30 |
== Upgrade Notice ==
|
31 |
|
32 |
+
= 1.1 =
|
33 |
+
Add a new panel for HTTP requests using the native WP methods.
|
34 |
+
AMP dev mode compatibility.
|
35 |
+
Change cache busters to use `filemtime` instead of hardcoded values.
|
36 |
+
Minor CSS updates, so themes don't override the `pre` styles.
|
37 |
+
|
38 |
= 1.0.1 =
|
39 |
Update object cache panel CSS to be ready for new object-cache.php release with better stats()
|
40 |
|
106 |
|
107 |
== Changelog ==
|
108 |
|
109 |
+
= 1.1 =
|
110 |
+
Add a new panel for HTTP requests using the native WP methods.
|
111 |
+
AMP dev mode compatibility.
|
112 |
+
Change cache busters to use `filemtime` instead of hardcoded values.
|
113 |
+
Minor CSS updates, so themes don't override the `pre` styles.
|
114 |
+
|
115 |
= 1.0.1 =
|
116 |
Update object cache panel CSS to be ready for new object-cache.php release with better stats()
|
117 |
|