Debug Bar - Version 0.9

Version Description

Added panel navigation to toolbar. Improved localization support. Security fixes.

Download this release

Release Info

Developer obenland
Plugin Icon 128x128 Debug Bar
Version 0.9
Comparing to
See all releases

Code changes from version 0.8.4 to 0.9

compat.php DELETED
@@ -1,44 +0,0 @@
1
- <?php
2
- //Backcompat for pre this function making it into WordPress
3
- if ( ! function_exists( 'wp_debug_backtrace_summary' ) ) {
4
- /**
5
- * Return a comma separated string of functions that have been called to get to the current point in code.
6
- * @link http://core.trac.wordpress.org/ticket/19589
7
- * @since 3.4
8
- *
9
- * @param string $ignore_class A class to ignore all function calls within - useful when you want to just give info about the callee
10
- * @param string $skip_frames A number of stack frames to skip - useful for unwinding back to the source of the issue
11
- * @param bool $pretty Whether or not you want a comma separated string or raw array returned
12
- * @return string|array Either a string containing a reversed comma separated trace or an array of individual calls.
13
- */
14
- function wp_debug_backtrace_summary( $ignore_class = null, $skip_frames = 0, $pretty = true ) {
15
- $trace = debug_backtrace( false );
16
- $caller = array();
17
- $check_class = ! is_null( $ignore_class );
18
- $skip_frames++; // skip this function
19
-
20
- foreach ( $trace as $call ) {
21
- if ( $skip_frames > 0 ) {
22
- $skip_frames--;
23
- } elseif ( isset( $call['class'] ) ) {
24
- if ( $check_class && $ignore_class == $call['class'] )
25
- continue; // Filter out calls
26
-
27
- $caller[] = "{$call['class']}{$call['type']}{$call['function']}";
28
- } else {
29
- if ( in_array( $call['function'], array( 'do_action', 'apply_filters' ) ) ) {
30
- $caller[] = "{$call['function']}('{$call['args'][0]}')";
31
- } elseif ( in_array( $call['function'], array( 'include', 'include_once', 'require', 'require_once' ) ) ) {
32
- $caller[] = $call['function'] . "('" . str_replace( array( WP_CONTENT_DIR, ABSPATH ) , '', $call['args'][0] ) . "')";
33
- } else {
34
- $caller[] = $call['function'];
35
- }
36
- }
37
- }
38
- if ( $pretty )
39
- return join( ', ', array_reverse( $caller ) );
40
- else
41
- return $caller;
42
- }
43
- }
44
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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{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;text-align:left;font-size:12px;}#querylist a{border:0;}.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,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{position:absolute;top:61px;left:0;width:250px;bottom:0;z-index:100;overflow:hidden;text-shadow:0 1px 1px rgba(0,0,0,0.9);background:#333;-webkit-box-shadow:inset -3px 0 6px rgba(0,0,0,0.4);-moz-box-shadow:inset -3px 0 6px rgba(0,0,0,0.4);box-shadow:inset -3px 0 6px rgba(0,0,0,0.4);}#debug-menu-targets{overflow:auto;position:absolute;top:61px;left:250px;right:0;bottom: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:bold;color:red;}#debug-status #debug-status-site{font-weight:bold;}#querylist pre{font-size:12px;padding:10px;}#querylist .left{float:left;}#querylist .right{float:right;}#querylist h1,#querylist h2,#querylist h3{font-weight:normal;}#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{padding:0 20px;width:210px;line-height:40px;outline:none;display:block;margin:0;color:#fff!important;text-decoration:none!important;font-weight:500!important;font-size:14px;}#debug-menu-links li a.current{background:rgba(0,0,0,0.2);}#querylist h2{float:left;min-width:150px;border:1px solid #eee;padding:5px 10px 15px;clear:none;text-align:center;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;}#object-cache-stats h2{border:none;float:none;text-align:left;font-size:22px;margin-bottom:0;}#querylist h3{margin-bottom:15px;}#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 0;}#querylist ol.wpd-queries li div.qdebug{background:#e8e8e8;margin:10px -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;}#querylist a{text-decoration:underline!important;color:blue!important;}#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;}#debug-bar-php ol.debug-bar-php-list{padding:0!important;margin:0!important;list-style:none;clear:left;}#debug-bar-php ol.debug-bar-php-list li{padding:10px;margin:0 0 10px 0;}#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{padding:0!important;margin:0!important;list-style:none;clear:left;}#debug-bar-deprecated ol.debug-bar-deprecated-list li{padding:10px;margin:0 0 10px 0;background:#f0f0f0;}#debug-bar-wp-query ol.debug-bar-wp-query-list{padding:0!important;margin:0!important;list-style:none;clear:left;}#debug-bar-wp-query ol.debug-bar-wp-query-list li,#debug-bar-wp-query p,#debug-bar-request p{padding:10px;margin:0 0 10px 0;background:#f0f0f0;}#debug-bar-wp-query ol.debug-bar-wp-query-list li ol{padding:0!important;margin:0!important;list-style:none;clear:left;}#debug-bar-wp-query h3,#debug-bar-request 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:bold;color:#eee;background:#aaa;cursor:pointer;}#debug-bar-actions span:hover{background:#888;}#debug-bar-actions span.restore{line-height:15px;}.debug-bar-maximized #debug-bar-actions span.restore{display:block;}.debug-bar-maximized #debug-bar-actions span.maximize{display:none;}.debug-bar-partial #debug-bar-actions span.restore{display:none;}.debug-bar-partial #debug-bar-actions span.maximize{display:block;}#debug-menu-links li a#debug-menu-link-Debug_Bar_JS{display:none;}#debug-bar-js ol.debug-bar-js-list{padding:0!important;margin:0!important;list-style:none;clear:left;}#debug-bar-js ol.debug-bar-js-list li{padding:10px;margin:0 0 10px 0;}#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;}
1
+ #debug-menu-links li a,#querylist a:hover{text-decoration:none!important}#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;text-align:left;font-size:12px}.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-menu,#debug-menu-targets{overflow:auto;position:absolute;top:61px;bottom:0}#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-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{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{font-size:12px;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:none;float:none;text-align:left;font-size:22px;margin-bottom:0}#querylist h3{margin-bottom:15px}#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}#querylist a{border:0;text-decoration:underline!important;color:#00f!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{padding:0!important;margin:0!important;list-style:none;clear:left}#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{padding:0!important;margin:0!important;list-style:none;clear:left}#debug-bar-deprecated ol.debug-bar-deprecated-list li{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-request p{padding:10px;margin:0 0 10px;background:#f0f0f0}#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-bar-maximized #debug-bar-actions span.restore{display:block}.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-menu-links li a#debug-menu-link-Debug_Bar_JS,#wp-admin-bar-debug-bar-Debug_Bar_JS{display:none}#debug-bar-js ol.debug-bar-js-list{padding:0!important;margin:0!important;list-style:none;clear:left}#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
@@ -59,6 +59,7 @@
59
  */
60
 
61
  #querylist {
 
62
  display: none;
63
  position: fixed;
64
  height: 33%;
@@ -121,7 +122,7 @@ body.debug-bar-maximized.debug-bar-visible {
121
  bottom: 0;
122
  z-index: 100;
123
 
124
- overflow: hidden;
125
  text-shadow: 0 1px 1px rgba( 0, 0, 0, 0.9 );
126
  background: #333;
127
  -webkit-box-shadow: inset -3px 0 6px rgba( 0, 0, 0, 0.4 );
@@ -203,9 +204,10 @@ body.debug-bar-maximized.debug-bar-visible {
203
  }
204
 
205
  #debug-menu-links li a {
 
206
  padding: 0 20px;
207
  width: 210px;
208
- line-height: 40px;
209
  outline: none;
210
  display: block;
211
  margin: 0;
@@ -226,6 +228,7 @@ body.debug-bar-maximized.debug-bar-visible {
226
  padding: 5px 10px 15px;
227
  clear: none;
228
  text-align: center;
 
229
  font-family: georgia, times, serif;
230
  font-size: 28px;
231
  margin: 15px 10px 15px 0 !important;
@@ -240,6 +243,15 @@ body.debug-bar-maximized.debug-bar-visible {
240
  margin-bottom: 5px;
241
  }
242
 
 
 
 
 
 
 
 
 
 
243
  #object-cache-stats h2 {
244
  border: none;
245
  float: none;
@@ -300,6 +312,21 @@ body.debug-bar-maximized.debug-bar-visible {
300
  line-height: 180% !important;
301
  }
302
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
303
  #debug-bar-php ol.debug-bar-php-list {
304
  padding: 0 !important;
305
  margin: 0 !important;
@@ -335,24 +362,31 @@ body.debug-bar-maximized.debug-bar-visible {
335
  background: #f0f0f0;
336
  }
337
 
338
- #debug-bar-wp-query ol.debug-bar-wp-query-list {
339
- padding: 0 !important;
340
- margin: 0 !important;
341
- list-style: none;
342
- clear: left;
343
  }
344
 
345
- #debug-bar-wp-query ol.debug-bar-wp-query-list li, #debug-bar-wp-query p, #debug-bar-request p {
346
- padding: 10px;
347
- margin: 0 0 10px 0;
348
- background: #f0f0f0;
349
  }
350
 
351
- #debug-bar-wp-query ol.debug-bar-wp-query-list li ol {
352
- padding: 0 !important;
353
- margin: 0 !important;
354
- list-style: none;
355
- clear: left;
 
 
 
 
 
 
 
 
356
  }
357
 
358
  #debug-bar-wp-query h3, #debug-bar-request h3 {
@@ -363,6 +397,12 @@ body.debug-bar-maximized.debug-bar-visible {
363
  margin: 15px 10px 15px 0 !important;
364
  }
365
 
 
 
 
 
 
 
366
  /* =========================================================================
367
  * Actions: Maximize / restore
368
  * ========================================================================= */
@@ -419,7 +459,8 @@ body.debug-bar-maximized.debug-bar-visible {
419
  * JS Error item styling
420
  * ========================================================================= */
421
 
422
- #debug-menu-links li a#debug-menu-link-Debug_Bar_JS {
 
423
  display: none;
424
  }
425
 
59
  */
60
 
61
  #querylist {
62
+ direction: ltr;
63
  display: none;
64
  position: fixed;
65
  height: 33%;
122
  bottom: 0;
123
  z-index: 100;
124
 
125
+ overflow: auto;
126
  text-shadow: 0 1px 1px rgba( 0, 0, 0, 0.9 );
127
  background: #333;
128
  -webkit-box-shadow: inset -3px 0 6px rgba( 0, 0, 0, 0.4 );
204
  }
205
 
206
  #debug-menu-links li a {
207
+ box-sizing: content-box;
208
  padding: 0 20px;
209
  width: 210px;
210
+ line-height: 32px;
211
  outline: none;
212
  display: block;
213
  margin: 0;
228
  padding: 5px 10px 15px;
229
  clear: none;
230
  text-align: center;
231
+ color: #000;
232
  font-family: georgia, times, serif;
233
  font-size: 28px;
234
  margin: 15px 10px 15px 0 !important;
243
  margin-bottom: 5px;
244
  }
245
 
246
+ #querylist h2 span#debug-bar-js-error-count {
247
+ font-size: inherit;
248
+ color: inherit;
249
+ text-transform: inherit;
250
+ white-space: inherit;
251
+ display: inherit;
252
+ margin-bottom: inherit;
253
+ }
254
+
255
  #object-cache-stats h2 {
256
  border: none;
257
  float: none;
312
  line-height: 180% !important;
313
  }
314
 
315
+ #querylist table {
316
+ table-layout: auto;
317
+ }
318
+
319
+ #querylist td, #querylist th {
320
+ text-transform: none;
321
+ }
322
+
323
+ #querylist table,
324
+ #querylist table th,
325
+ #querylist table td {
326
+ border: 0px none;
327
+ vertical-align: top;
328
+ }
329
+
330
  #debug-bar-php ol.debug-bar-php-list {
331
  padding: 0 !important;
332
  margin: 0 !important;
362
  background: #f0f0f0;
363
  }
364
 
365
+ #debug-bar-wp-query table.debug-bar-wp-query-list {
366
+ width: 100%;
367
+ border-collapse: collapse;
368
+ cell-padding: 1em;
369
+ clear: both;
370
  }
371
 
372
+ #debug-bar-wp-query table.debug-bar-wp-query-list td {
373
+ padding: 0.5em 5px;
374
+ border-bottom: 1px solid #ccc;
 
375
  }
376
 
377
+ #debug-bar-wp-query table.debug-bar-wp-query-list th {
378
+ padding: 0.5em 5px;
379
+ font-weight: bold;
380
+ border-bottom: 1px solid #ccc;
381
+ }
382
+
383
+ #debug-bar-wp-query table.debug-bar-wp-query-list tr:nth-child(2n+1) {
384
+ background-color: #E8E8E8;
385
+ }
386
+
387
+ #debug-bar-wp-query table.debug-bar-wp-query-list tr td:first-of-type {
388
+ font-size: 140%;
389
+ padding: 0.3em 0.5em;
390
  }
391
 
392
  #debug-bar-wp-query h3, #debug-bar-request h3 {
397
  margin: 15px 10px 15px 0 !important;
398
  }
399
 
400
+ #debug-bar-request p {
401
+ padding: 10px;
402
+ margin: 0 0 10px 0;
403
+ background: #f0f0f0;
404
+ }
405
+
406
  /* =========================================================================
407
  * Actions: Maximize / restore
408
  * ========================================================================= */
459
  * JS Error item styling
460
  * ========================================================================= */
461
 
462
+ #debug-menu-links li a#debug-menu-link-Debug_Bar_JS,
463
+ #wp-admin-bar-debug-bar-Debug_Bar_JS {
464
  display: none;
465
  }
466
 
debug-bar.php CHANGED
@@ -4,8 +4,9 @@
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: 0.8.4
8
  Author URI: https://wordpress.org/
 
9
  */
10
 
11
  /***
@@ -16,46 +17,83 @@
16
  *
17
  * They are not used when a regular user is logged in.
18
  */
19
-
20
  class Debug_Bar {
21
- var $panels = array();
22
 
23
  function __construct() {
24
- if ( defined('DOING_AJAX') && DOING_AJAX )
25
- add_action( 'admin_init', array( &$this, 'init_ajax' ) );
26
- add_action( 'admin_bar_init', array( &$this, 'init' ) );
 
27
  }
28
 
29
  function Debug_Bar() {
30
- Debug_Bar::__construct();
 
31
  }
32
 
33
  function init() {
34
- if ( ! is_super_admin() || ! is_admin_bar_showing() || $this->is_wp_login() )
35
  return;
 
 
 
36
 
37
- add_action( 'admin_bar_menu', array( &$this, 'admin_bar_menu' ), 1000 );
38
- add_action( 'admin_footer', array( &$this, 'render' ), 1000 );
39
- add_action( 'wp_footer', array( &$this, 'render' ), 1000 );
40
- add_action( 'wp_head', array( &$this, 'ensure_ajaxurl' ), 1 );
41
- add_filter( 'body_class', array( &$this, 'body_class' ) );
42
- add_filter( 'admin_body_class', array( &$this, 'body_class' ) );
43
 
44
  $this->requirements();
45
  $this->enqueue();
46
  $this->init_panels();
47
  }
48
 
49
- /* Are we on the wp-login.php page?
50
- * We can get here while logged in and break the page as the admin bar isn't shown and otherthings the js relies on aren't available.
 
 
 
 
 
51
  */
52
  function is_wp_login() {
53
  return 'wp-login.php' == basename( $_SERVER['SCRIPT_NAME'] );
54
  }
55
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  function init_ajax() {
57
- if ( ! is_super_admin() )
58
  return;
 
59
 
60
  $this->requirements();
61
  $this->init_panels();
@@ -63,20 +101,21 @@ class Debug_Bar {
63
 
64
  function requirements() {
65
  $path = plugin_dir_path( __FILE__ );
66
- require_once( $path . '/compat.php' );
67
  $recs = array( 'panel', 'php', 'queries', 'request', 'wp-query', 'object-cache', 'deprecated', 'js' );
68
- foreach ( $recs as $rec )
 
69
  require_once "$path/panels/class-debug-bar-$rec.php";
 
70
  }
71
 
72
  function enqueue() {
73
- $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '.dev' : '';
74
 
75
- wp_enqueue_style( 'debug-bar', plugins_url( "css/debug-bar$suffix.css", __FILE__ ), array(), '20120317' );
76
 
77
- wp_enqueue_script( 'debug-bar', plugins_url( "js/debug-bar$suffix.js", __FILE__ ), array( 'jquery' ), '20121228.2', true );
78
 
79
- do_action('debug_bar_enqueue_scripts');
80
  }
81
 
82
  function init_panels() {
@@ -99,21 +138,16 @@ class Debug_Bar {
99
 
100
  function ensure_ajaxurl() { ?>
101
  <script type="text/javascript">
102
- //<![CDATA[
103
- var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>';
104
- //]]>
105
  </script>
106
  <?php
107
  }
108
 
109
  // memory_get_peak_usage is PHP >= 5.2.0 only
110
  function safe_memory_get_peak_usage() {
111
- if ( function_exists( 'memory_get_peak_usage' ) ) {
112
- $usage = memory_get_peak_usage();
113
- } else {
114
- $usage = memory_get_usage();
115
- }
116
- return $usage;
117
  }
118
 
119
  function admin_bar_menu() {
@@ -126,36 +160,43 @@ class Debug_Bar {
126
  $wp_admin_bar->add_menu( array(
127
  'id' => 'debug-bar',
128
  'parent' => 'top-secondary',
129
- 'title' => apply_filters( 'debug_bar_title', __('Debug', 'debug-bar') ),
130
  'meta' => array( 'class' => $classes ),
131
  ) );
132
 
133
- // @todo: Uncomment and finish me!
134
- // foreach ( $this->panels as $panel_key => $panel ) {
135
- // if ( ! $panel->is_visible() )
136
- // continue;
137
- //
138
- // $panel_class = get_class( $panel );
139
- //
140
- // $wp_admin_bar->add_menu( array(
141
- // 'parent' => 'debug-bar',
142
- // 'id' => "debug-bar-$panel_class",
143
- // 'title' => $panel->title(),
144
- // ) );
145
- // }
 
 
 
 
 
146
  }
147
 
148
  function body_class( $classes ) {
149
- if ( is_array( $classes ) )
150
  $classes[] = 'debug-bar-maximized';
151
- else
152
  $classes .= ' debug-bar-maximized ';
 
153
 
154
  if ( isset( $_GET['debug-bar'] ) ) {
155
- if ( is_array( $classes ) )
156
  $classes[] = 'debug-bar-visible';
157
- else
158
  $classes .= ' debug-bar-visible ';
 
159
  }
160
 
161
  return $classes;
@@ -164,95 +205,121 @@ class Debug_Bar {
164
  function render() {
165
  global $wpdb;
166
 
167
- if ( empty( $this->panels ) )
168
  return;
 
169
 
170
  foreach ( $this->panels as $panel_key => $panel ) {
171
  $panel->prerender();
172
- if ( ! $panel->is_visible() )
173
  unset( $this->panels[ $panel_key ] );
 
174
  }
175
 
176
  ?>
177
- <div id='querylist'>
178
-
179
- <div id="debug-bar-actions">
180
- <span class="maximize">+</span>
181
- <span class="restore">&ndash;</span>
182
- <span class="close">&times;</span>
183
- </div>
184
-
185
- <div id='debug-bar-info'>
186
- <div id="debug-status">
187
- <?php //@todo: Add a links to information about WP_DEBUG, PHP version, MySQL version, and Peak Memory.
188
- $statuses = array();
189
- $statuses[] = array( 'site', php_uname( 'n' ), sprintf( __( '#%d', 'debug-bar' ), get_current_blog_id() ) );
190
- $statuses[] = array( 'php', __('PHP', 'debug-bar'), phpversion() );
191
- $db_title = empty( $wpdb->is_mysql ) ? __( 'DB', 'debug-bar' ) : 'MySQL';
192
- $statuses[] = array( 'db', $db_title, $wpdb->db_version() );
193
- $statuses[] = array( 'memory', __('Memory Usage', 'debug-bar'), sprintf( __('%s bytes', 'debug-bar'), number_format_i18n( $this->safe_memory_get_peak_usage() ) ) );
194
-
195
- if ( ! WP_DEBUG )
196
- $statuses[] = array( 'warning', __('Please Enable', 'debug-bar'), 'WP_DEBUG' );
197
-
198
- $statuses = apply_filters( 'debug_bar_statuses', $statuses );
199
-
200
- foreach ( $statuses as $status ):
201
- list( $slug, $title, $data ) = $status;
202
-
203
- ?><div id='debug-status-<?php echo esc_attr( $slug ); ?>' class='debug-status'>
204
- <div class='debug-status-title'><?php echo $title; ?></div>
205
- <?php if ( ! empty( $data ) ): ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
206
  <div class='debug-status-data'><?php echo $data; ?></div>
207
  <?php endif; ?>
208
- </div><?php
209
- endforeach;
210
- ?>
211
- </div>
212
- </div>
213
-
214
- <div id='debug-bar-menu'>
215
- <ul id="debug-menu-links">
216
-
217
- <?php
218
- $current = ' current';
219
- foreach ( $this->panels as $panel ) :
220
- $class = get_class( $panel );
221
- ?>
222
- <li><a
223
- id="debug-menu-link-<?php echo esc_attr( $class ); ?>"
224
- class="debug-menu-link<?php echo $current; ?>"
225
- href="#debug-menu-target-<?php echo esc_attr( $class ); ?>">
226
- <?php
227
- // Not escaping html here, so panels can use html in the title.
228
- echo $panel->title();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
229
  ?>
230
- </a></li>
231
- <?php
232
- $current = '';
233
- endforeach; ?>
234
 
235
- </ul>
236
- </div>
237
-
238
- <div id="debug-menu-targets"><?php
239
- $current = ' style="display: block"';
240
- foreach ( $this->panels as $panel ) :
241
- $class = get_class( $panel ); ?>
242
-
243
- <div id="debug-menu-target-<?php echo $class; ?>" class="debug-menu-target" <?php echo $current; ?>>
244
- <?php $panel->render(); ?>
245
  </div>
246
-
247
  <?php
248
- $current = '';
249
- endforeach;
250
- ?>
251
- </div>
252
-
253
- <?php do_action( 'debug_bar' ); ?>
254
- </div>
255
- <?php
256
  }
257
  }
258
 
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: 0.9
8
  Author URI: https://wordpress.org/
9
+ Text Domain: debug-bar
10
  */
11
 
12
  /***
17
  *
18
  * They are not used when a regular user is logged in.
19
  */
 
20
  class Debug_Bar {
21
+ public $panels = array();
22
 
23
  function __construct() {
24
+ if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
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() {
31
+ _deprecated_constructor( __METHOD__, '0.8.3', __CLASS__ );
32
+ self::__construct();
33
  }
34
 
35
  function init() {
36
+ if ( ! $this->enable_debug_bar() ) {
37
  return;
38
+ }
39
+
40
+ load_plugin_textdomain( 'debug-bar' );
41
 
42
+ add_action( 'admin_bar_menu', array( $this, 'admin_bar_menu' ), 1000 );
43
+ add_action( 'admin_footer', array( $this, 'render' ), 1000 );
44
+ add_action( 'wp_footer', array( $this, 'render' ), 1000 );
45
+ add_action( 'wp_head', array( $this, 'ensure_ajaxurl' ), 1 );
46
+ add_filter( 'body_class', array( $this, 'body_class' ) );
47
+ add_filter( 'admin_body_class', array( $this, 'body_class' ) );
48
 
49
  $this->requirements();
50
  $this->enqueue();
51
  $this->init_panels();
52
  }
53
 
54
+ /**
55
+ * Are we on the wp-login.php page?
56
+ *
57
+ * We can get here while logged in and break the page as the admin bar
58
+ * is not shown and other things the js relies on are not available.
59
+ *
60
+ * @return bool
61
  */
62
  function is_wp_login() {
63
  return 'wp-login.php' == basename( $_SERVER['SCRIPT_NAME'] );
64
  }
65
 
66
+ /**
67
+ * Should the debug bar functionality be enabled?
68
+ *
69
+ * @since 0.9
70
+ *
71
+ * @param bool $ajax Whether this is an ajax call or not. Defaults to false.
72
+ * @return bool
73
+ */
74
+ function enable_debug_bar( $ajax = false ) {
75
+ $enable = false;
76
+
77
+ if ( $ajax && is_super_admin() ) {
78
+ $enable = true;
79
+ } elseif ( ! $ajax && ( is_super_admin() && is_admin_bar_showing() && ! $this->is_wp_login() ) ) {
80
+ $enable = true;
81
+ }
82
+
83
+ /**
84
+ * Allows for overruling of whether the debug bar functionality will be enabled.
85
+ *
86
+ * @since 0.9
87
+ *
88
+ * @param bool $enable Whether the debug bar will be enabled or not.
89
+ */
90
+ return apply_filters( 'debug_bar_enable', $enable );
91
+ }
92
+
93
  function init_ajax() {
94
+ if ( ! $this->enable_debug_bar( true ) ) {
95
  return;
96
+ }
97
 
98
  $this->requirements();
99
  $this->init_panels();
101
 
102
  function requirements() {
103
  $path = plugin_dir_path( __FILE__ );
 
104
  $recs = array( 'panel', 'php', 'queries', 'request', 'wp-query', 'object-cache', 'deprecated', 'js' );
105
+
106
+ foreach ( $recs as $rec ) {
107
  require_once "$path/panels/class-debug-bar-$rec.php";
108
+ }
109
  }
110
 
111
  function enqueue() {
112
+ $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.dev' : '';
113
 
114
+ wp_enqueue_style( 'debug-bar', plugins_url( "css/debug-bar$suffix.css", __FILE__ ), array(), '20170515' );
115
 
116
+ wp_enqueue_script( 'debug-bar', plugins_url( "js/debug-bar$suffix.js", __FILE__ ), array( 'jquery' ), '20170515', true );
117
 
118
+ do_action( 'debug_bar_enqueue_scripts' );
119
  }
120
 
121
  function init_panels() {
138
 
139
  function ensure_ajaxurl() { ?>
140
  <script type="text/javascript">
141
+ //<![CDATA[
142
+ var ajaxurl = '<?php echo admin_url( 'admin-ajax.php' ); ?>';
143
+ //]]>
144
  </script>
145
  <?php
146
  }
147
 
148
  // memory_get_peak_usage is PHP >= 5.2.0 only
149
  function safe_memory_get_peak_usage() {
150
+ return function_exists( 'memory_get_peak_usage' ) ? memory_get_peak_usage() : memory_get_usage();
 
 
 
 
 
151
  }
152
 
153
  function admin_bar_menu() {
160
  $wp_admin_bar->add_menu( array(
161
  'id' => 'debug-bar',
162
  'parent' => 'top-secondary',
163
+ 'title' => apply_filters( 'debug_bar_title', __( 'Debug', 'debug-bar' ) ),
164
  'meta' => array( 'class' => $classes ),
165
  ) );
166
 
167
+ foreach ( $this->panels as $panel_key => $panel ) {
168
+ $panel->prerender();
169
+ if ( ! $panel->is_visible() ) {
170
+ continue;
171
+ }
172
+
173
+ $panel_class = get_class( $panel );
174
+
175
+ $wp_admin_bar->add_menu( array(
176
+ 'parent' => 'debug-bar',
177
+ 'id' => "debug-bar-$panel_class",
178
+ 'title' => $panel->title(),
179
+ 'href' => '#debug-menu-target-' . esc_attr( $panel_class ),
180
+ 'meta' => array(
181
+ 'rel' => '#debug-menu-link-' . esc_attr( $panel_class ),
182
+ ),
183
+ ) );
184
+ }
185
  }
186
 
187
  function body_class( $classes ) {
188
+ if ( is_array( $classes ) ) {
189
  $classes[] = 'debug-bar-maximized';
190
+ } else {
191
  $classes .= ' debug-bar-maximized ';
192
+ }
193
 
194
  if ( isset( $_GET['debug-bar'] ) ) {
195
+ if ( is_array( $classes ) ) {
196
  $classes[] = 'debug-bar-visible';
197
+ } else {
198
  $classes .= ' debug-bar-visible ';
199
+ }
200
  }
201
 
202
  return $classes;
205
  function render() {
206
  global $wpdb;
207
 
208
+ if ( empty( $this->panels ) ) {
209
  return;
210
+ }
211
 
212
  foreach ( $this->panels as $panel_key => $panel ) {
213
  $panel->prerender();
214
+ if ( ! $panel->is_visible() ) {
215
  unset( $this->panels[ $panel_key ] );
216
+ }
217
  }
218
 
219
  ?>
220
+ <div id='querylist'>
221
+
222
+ <div id="debug-bar-actions">
223
+ <span class="maximize">+</span>
224
+ <span class="restore">&ndash;</span>
225
+ <span class="close">&times;</span>
226
+ </div>
227
+
228
+ <div id='debug-bar-info'>
229
+ <div id="debug-status">
230
+ <?php //@todo: Add a links to information about WP_DEBUG, PHP version, MySQL version, and Peak Memory.
231
+ $statuses = array();
232
+ $statuses[] = array(
233
+ 'site',
234
+ php_uname( 'n' ),
235
+ /* translators: %d is the site id number in a multi-site setting. */
236
+ sprintf( __( '#%d', 'debug-bar' ), get_current_blog_id() ),
237
+ );
238
+ $statuses[] = array(
239
+ 'php',
240
+ __( 'PHP', 'debug-bar' ),
241
+ phpversion(),
242
+ );
243
+ $db_title = empty( $wpdb->is_mysql ) ? __( 'DB', 'debug-bar' ) : __( 'MySQL', 'debug-bar' );
244
+ $statuses[] = array(
245
+ 'db',
246
+ $db_title,
247
+ $wpdb->db_version(),
248
+ );
249
+ $statuses[] = array(
250
+ 'memory',
251
+ __( 'Memory Usage', 'debug-bar' ),
252
+ /* translators: %s is a formatted number representing the memory usage. */
253
+ sprintf( __( '%s bytes', 'debug-bar' ), number_format_i18n( $this->safe_memory_get_peak_usage() ) ),
254
+ );
255
+
256
+ if ( ! WP_DEBUG ) {
257
+ $statuses[] = array(
258
+ 'warning',
259
+ __( 'Please Enable', 'debug-bar' ),
260
+ 'WP_DEBUG',
261
+ );
262
+ }
263
+
264
+ $statuses = apply_filters( 'debug_bar_statuses', $statuses );
265
+
266
+ foreach ( $statuses as $status ):
267
+ list( $slug, $title, $data ) = $status;
268
+
269
+ ?>
270
+ <div id='debug-status-<?php echo esc_attr( $slug ); ?>' class='debug-status'>
271
+ <div class='debug-status-title'><?php echo $title; ?></div>
272
+ <?php if ( ! empty( $data ) ): ?>
273
  <div class='debug-status-data'><?php echo $data; ?></div>
274
  <?php endif; ?>
275
+ </div><?php
276
+ endforeach;
277
+ ?>
278
+ </div>
279
+ </div>
280
+
281
+ <div id='debug-bar-menu'>
282
+ <ul id="debug-menu-links">
283
+
284
+ <?php
285
+ $current = ' current';
286
+ foreach ( $this->panels as $panel ) :
287
+ $class = get_class( $panel );
288
+ ?>
289
+ <li><a
290
+ id="debug-menu-link-<?php echo esc_attr( $class ); ?>"
291
+ class="debug-menu-link<?php echo $current; ?>"
292
+ href="#debug-menu-target-<?php echo esc_attr( $class ); ?>">
293
+ <?php
294
+ // Not escaping html here, so panels can use html in the title.
295
+ echo $panel->title();
296
+ ?>
297
+ </a></li>
298
+ <?php
299
+ $current = '';
300
+ endforeach; ?>
301
+
302
+ </ul>
303
+ </div>
304
+
305
+ <div id="debug-menu-targets"><?php
306
+ $current = ' style="display: block"';
307
+ foreach ( $this->panels as $panel ) :
308
+ $class = get_class( $panel ); ?>
309
+
310
+ <div id="debug-menu-target-<?php echo $class; ?>" class="debug-menu-target" <?php echo $current; ?>>
311
+ <?php $panel->render(); ?>
312
+ </div>
313
+
314
+ <?php
315
+ $current = '';
316
+ endforeach;
317
  ?>
318
+ </div>
 
 
 
319
 
320
+ <?php do_action( 'debug_bar' ); ?>
 
 
 
 
 
 
 
 
 
321
  </div>
 
322
  <?php
 
 
 
 
 
 
 
 
323
  }
324
  }
325
 
js/debug-bar-js.dev.js CHANGED
@@ -1,56 +1,67 @@
1
- (function() {
2
  var count, list, dbjsError,
3
  rawCount = 0,
4
  errors = [];
5
 
6
- window.onerror = function( errorMsg, url, lineNumber ) {
7
- if ( ! document.getElementById( 'debug-bar-js-error-count' ) )
8
- errors[ errors.length ] = [errorMsg, url, lineNumber];
9
- else
10
- dbjsError(errorMsg, url, lineNumber);
11
- }
12
-
13
- jQuery(document).ready( function(){
14
- for ( err in errors )
15
- dbjsError( errors[err][0], errors[err][1], errors[err][2] );
16
-
17
- });
18
 
19
- dbjsError = function( errorMsg, url, lineNumber ) {
 
 
 
 
20
 
 
21
  var errorLine, place, button, tab;
22
 
23
  rawCount++;
24
 
25
- if ( !count )
26
  count = document.getElementById( 'debug-bar-js-error-count' );
27
- if ( !list )
 
28
  list = document.getElementById( 'debug-bar-js-errors' );
 
29
 
30
- if ( !count || !list )
31
  return; // threw way too early... @todo cache these?
 
32
 
33
  if ( 1 == rawCount ) {
34
  button = document.getElementById( 'wp-admin-bar-debug-bar' );
35
- if ( !button )
 
36
  return; // how did this happen?
37
- if ( button.className.indexOf( 'debug-bar-php-warning-summary' ) === -1 )
 
 
38
  button.className = button.className + ' debug-bar-php-warning-summary';
 
39
 
40
- tab = document.getElementById('debug-menu-link-Debug_Bar_JS');
41
- if ( tab )
42
- tab.style.display = 'block';
 
 
 
43
  }
44
 
45
  count.textContent = rawCount;
 
46
  errorLine = document.createElement( 'li' );
47
  errorLine.className = 'debug-bar-js-error';
48
  errorLine.textContent = errorMsg;
 
49
  place = document.createElement( 'span' );
50
  place.textContent = url + ' line ' + lineNumber;
 
51
  errorLine.appendChild( place );
52
  list.appendChild( errorLine );
53
-
54
  };
55
-
56
- })();
1
+ ( function() {
2
  var count, list, dbjsError,
3
  rawCount = 0,
4
  errors = [];
5
 
6
+ window.onerror = function ( errorMsg, url, lineNumber ) {
7
+ if ( ! document.getElementById( 'debug-bar-js-error-count' ) ) {
8
+ errors[ errors.length ] = [ errorMsg, url, lineNumber ];
9
+ } else {
10
+ dbjsError( errorMsg, url, lineNumber );
11
+ }
12
+ };
 
 
 
 
 
13
 
14
+ jQuery( function () {
15
+ for ( err in errors ) {
16
+ dbjsError( errors[ err ][0], errors[ err ][1], errors[ err ][2] );
17
+ }
18
+ } );
19
 
20
+ dbjsError = function dbjsError( errorMsg, url, lineNumber ) {
21
  var errorLine, place, button, tab;
22
 
23
  rawCount++;
24
 
25
+ if ( ! count ) {
26
  count = document.getElementById( 'debug-bar-js-error-count' );
27
+ }
28
+ if ( ! list ) {
29
  list = document.getElementById( 'debug-bar-js-errors' );
30
+ }
31
 
32
+ if ( ! count || ! list ) {
33
  return; // threw way too early... @todo cache these?
34
+ }
35
 
36
  if ( 1 == rawCount ) {
37
  button = document.getElementById( 'wp-admin-bar-debug-bar' );
38
+
39
+ if ( ! button ) {
40
  return; // how did this happen?
41
+ }
42
+
43
+ if ( -1 === button.className.indexOf( 'debug-bar-php-warning-summary' ) ) {
44
  button.className = button.className + ' debug-bar-php-warning-summary';
45
+ }
46
 
47
+ [ 'debug-menu-link-Debug_Bar_JS', 'wp-admin-bar-debug-bar-Debug_Bar_JS' ].map( function( id ) {
48
+ tab = document.getElementById( id );
49
+ if ( tab ) {
50
+ tab.style.display = 'block';
51
+ }
52
+ } );
53
  }
54
 
55
  count.textContent = rawCount;
56
+
57
  errorLine = document.createElement( 'li' );
58
  errorLine.className = 'debug-bar-js-error';
59
  errorLine.textContent = errorMsg;
60
+
61
  place = document.createElement( 'span' );
62
  place.textContent = url + ' line ' + lineNumber;
63
+
64
  errorLine.appendChild( place );
65
  list.appendChild( errorLine );
 
66
  };
67
+ } )();
 
js/debug-bar-js.js CHANGED
@@ -1 +1 @@
1
- (function(){var count,list,dbjsError,rawCount=0,errors=[];window.onerror=function(errorMsg,url,lineNumber){if(!document.getElementById("debug-bar-js-error-count")){errors[errors.length]=[errorMsg,url,lineNumber]}else{dbjsError(errorMsg,url,lineNumber)}};jQuery(document).ready(function(){for(err in errors){dbjsError(errors[err][0],errors[err][1],errors[err][2])}});dbjsError=function(errorMsg,url,lineNumber){var errorLine,place,button,tab;rawCount++;if(!count){count=document.getElementById("debug-bar-js-error-count")}if(!list){list=document.getElementById("debug-bar-js-errors")}if(!count||!list){return}if(1==rawCount){button=document.getElementById("wp-admin-bar-debug-bar");if(!button){return}if(button.className.indexOf("debug-bar-php-warning-summary")===-1){button.className=button.className+" debug-bar-php-warning-summary"}tab=document.getElementById("debug-menu-link-Debug_Bar_JS");if(tab){tab.style.display="block"}}count.textContent=rawCount;errorLine=document.createElement("li");errorLine.className="debug-bar-js-error";errorLine.textContent=errorMsg;place=document.createElement("span");place.textContent=url+" line "+lineNumber;errorLine.appendChild(place);list.appendChild(errorLine)}})();
1
+ !function(){var e,i,t,r=0,n=[];window.onerror=function(e,i,r){document.getElementById("debug-bar-js-error-count")?t(e,i,r):n[n.length]=[e,i,r]},jQuery(function(){for(err in n)t(n[err][0],n[err][1],n[err][2])}),t=function(t,n,a){var s,o,u,d;if(r++,e||(e=document.getElementById("debug-bar-js-error-count")),i||(i=document.getElementById("debug-bar-js-errors")),e&&i){if(1==r){if(u=document.getElementById("wp-admin-bar-debug-bar"),!u)return;-1===u.className.indexOf("debug-bar-php-warning-summary")&&(u.className=u.className+" debug-bar-php-warning-summary"),["debug-menu-link-Debug_Bar_JS","wp-admin-bar-debug-bar-Debug_Bar_JS"].map(function(e){d=document.getElementById(e),d&&(d.style.display="block")})}e.textContent=r,s=document.createElement("li"),s.className="debug-bar-js-error",s.textContent=t,o=document.createElement("span"),o.textContent=n+" line "+a,s.appendChild(o),i.appendChild(s)}}}();
js/debug-bar.dev.js CHANGED
@@ -1,106 +1,123 @@
1
  var wpDebugBar;
2
 
3
- (function($) {
4
-
5
- var api;
6
-
7
- wpDebugBar = api = {
8
- // The element that we will pad to prevent the debug bar
9
- // from overlapping the bottom of the page.
10
- body: undefined,
11
-
12
- init: function() {
13
- // If we're not in the admin, pad the body.
14
- api.body = $(document.body);
15
-
16
- api.toggle.init();
17
- api.tabs();
18
- api.actions.init();
19
- },
20
-
21
- isVisible: function() {
22
- return api.body.hasClass( 'debug-bar-visible' );
23
- },
24
-
25
- toggle: {
26
- init: function() {
27
- $('#wp-admin-bar-debug-bar').click( function(e) {
28
- e.preventDefault();
29
- api.toggle.visibility();
30
- });
31
- },
32
- visibility: function( show ) {
33
- show = typeof show == 'undefined' ? ! api.isVisible() : show;
34
-
35
- // Show/hide the debug bar.
36
- api.body.toggleClass( 'debug-bar-visible', show );
37
 
38
- // Press/unpress the button.
39
- $(this).toggleClass( 'active', show );
40
- }
41
- },
42
 
43
- tabs: function() {
44
- var debugMenuLinks = $('.debug-menu-link'),
45
- debugMenuTargets = $('.debug-menu-target');
46
 
47
- debugMenuLinks.click( function(e) {
48
- var t = $(this);
 
 
49
 
50
- e.preventDefault();
 
 
51
 
52
- if ( t.hasClass('current') )
53
- return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
 
55
- // Deselect other tabs and hide other panels.
56
- debugMenuTargets.hide().trigger('debug-bar-hide');
57
- debugMenuLinks.removeClass('current');
58
 
59
- // Select the current tab and show the current panel.
60
- t.addClass('current');
61
- // The hashed component of the href is the id that we want to display.
62
- $('#' + this.href.substr( this.href.indexOf( '#' ) + 1 ) ).show().trigger('debug-bar-show');
63
- });
64
- },
65
 
66
- actions: {
67
- init: function() {
68
- var actions = $('#debug-bar-actions');
69
 
70
- // Close the panel with the esc key if it's open
71
- // 27 = esc
72
- $(document).keydown( function( e ) {
73
- var key = e.key || e.which || e.keyCode;
74
- if ( 27 != key || ! api.isVisible() )
75
  return;
 
76
 
77
- e.preventDefault();
78
- return api.actions.close();
79
- });
80
 
81
- $('.maximize', actions).click( api.actions.maximize );
82
- $('.restore', actions).click( api.actions.restore );
83
- $('.close', actions).click( api.actions.close );
 
 
84
  },
85
- maximize: function() {
86
- api.body.removeClass('debug-bar-partial');
87
- api.body.addClass('debug-bar-maximized');
88
- },
89
- restore: function() {
90
- api.body.removeClass('debug-bar-maximized');
91
- api.body.addClass('debug-bar-partial');
92
- },
93
- close: function() {
94
- api.toggle.visibility( false );
95
- console.log( 'boo');
96
- }
97
- }
98
- };
99
 
100
- wpDebugBar.Panel = function() {
101
-
102
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
 
104
- $(document).ready( wpDebugBar.init );
105
 
106
- })(jQuery);
1
  var wpDebugBar;
2
 
3
+ ( function( $ ) {
4
+ var api;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
+ wpDebugBar = api = {
7
+ // The element that we will pad to prevent the debug bar
8
+ // from overlapping the bottom of the page.
9
+ body: undefined,
10
 
11
+ init: function init() {
12
+ // If we're not in the admin, pad the body.
13
+ api.body = $( document.body );
14
 
15
+ api.toggle.init();
16
+ api.tabs();
17
+ api.actions.init();
18
+ },
19
 
20
+ isVisible: function isVisible() {
21
+ return api.body.hasClass( 'debug-bar-visible' );
22
+ },
23
 
24
+ toggle: {
25
+ init: function init() {
26
+ $( '#wp-admin-bar-debug-bar' ).click( function onClickAdminBarMenu( event ) {
27
+ event.preventDefault();
28
+
29
+ // Click on submenu item.
30
+ if ( event.target.hash ) {
31
+ var $menuLink = $( event.target.rel );
32
+
33
+ // Open/close debug bar.
34
+ if ( ! api.isVisible() ) {
35
+ api.toggle.visibility();
36
+ } else if ( $menuLink.hasClass( 'current' ) ) {
37
+ $menuLink.removeClass( 'current' );
38
+ api.toggle.visibility();
39
+
40
+ return;
41
+ }
42
+
43
+ // Deselect other tabs and hide other panels.
44
+ $( '.debug-menu-target' ).hide().trigger( 'debug-bar-hide' );
45
+ $( '.debug-menu-link' ).removeClass( 'current' );
46
+
47
+ $menuLink.addClass( 'current' );
48
+ $( event.target.hash ).show().trigger( 'debug-bar-show' );
49
+ } else {
50
+ api.toggle.visibility();
51
+ }
52
+ } );
53
+ },
54
+ visibility: function visibility( show ) {
55
+ show = typeof show == 'undefined' ? ! api.isVisible() : show;
56
+
57
+ // Show/hide the debug bar.
58
+ api.body.toggleClass( 'debug-bar-visible', show );
59
+
60
+ // Press/unpress the button.
61
+ $( this ).toggleClass( 'active', show );
62
+ }
63
+ },
64
 
65
+ tabs: function tabs() {
66
+ var debugMenuLinks = $( '.debug-menu-link' ),
67
+ debugMenuTargets = $( '.debug-menu-target' );
68
 
69
+ debugMenuLinks.click( function onClickLink( event ) {
70
+ var $this = $( this );
 
 
 
 
71
 
72
+ event.preventDefault();
 
 
73
 
74
+ if ( $this.hasClass( 'current' ) ) {
 
 
 
 
75
  return;
76
+ }
77
 
78
+ // Deselect other tabs and hide other panels.
79
+ debugMenuTargets.hide().trigger( 'debug-bar-hide' );
80
+ debugMenuLinks.removeClass( 'current' );
81
 
82
+ // Select the current tab and show the current panel.
83
+ $this.addClass( 'current' );
84
+ // The hashed component of the href is the id that we want to display.
85
+ $( '#' + this.href.substr( this.href.indexOf( '#' ) + 1 ) ).show().trigger( 'debug-bar-show' );
86
+ } );
87
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
 
89
+ actions: {
90
+ init: function init() {
91
+ var actions = $( '#debug-bar-actions' );
92
+
93
+ // Close the panel with the esc key if it's open.
94
+ $( document ).keydown( function maybeClosePanel( event ) {
95
+ var key = event.key || event.which || event.keyCode;
96
+
97
+ if ( 27 /* esc */ === key && api.isVisible() ) {
98
+ event.preventDefault();
99
+ api.actions.close();
100
+ }
101
+ } );
102
+
103
+ $( '.maximize', actions ).click( api.actions.maximize );
104
+ $( '.restore', actions ).click( api.actions.restore );
105
+ $( '.close', actions ).click( api.actions.close );
106
+ },
107
+ maximize: function maximize() {
108
+ api.body.removeClass( 'debug-bar-partial' );
109
+ api.body.addClass( 'debug-bar-maximized' );
110
+ },
111
+ restore: function restore() {
112
+ api.body.removeClass( 'debug-bar-maximized' );
113
+ api.body.addClass( 'debug-bar-partial' );
114
+ },
115
+ close: function close() {
116
+ api.toggle.visibility( false );
117
+ }
118
+ }
119
+ };
120
 
121
+ $( wpDebugBar.init );
122
 
123
+ } )( jQuery );
js/debug-bar.js CHANGED
@@ -1 +1 @@
1
- var wpDebugBar;(function(i){var e;wpDebugBar=e={body:void 0,init:function(){e.body=i(document.body),e.toggle.init(),e.tabs(),e.actions.init()},isVisible:function(){return e.body.hasClass("debug-bar-visible")},toggle:{init:function(){i("#wp-admin-bar-debug-bar").click(function(i){i.preventDefault(),e.toggle.visibility()})},visibility:function(t){t=t===void 0?!e.isVisible():t,e.body.toggleClass("debug-bar-visible",t),i(this).toggleClass("active",t)}},tabs:function(){var e=i(".debug-menu-link"),t=i(".debug-menu-target");e.click(function(a){var n=i(this);a.preventDefault(),n.hasClass("current")||(t.hide().trigger("debug-bar-hide"),e.removeClass("current"),n.addClass("current"),i("#"+this.href.substr(this.href.indexOf("#")+1)).show().trigger("debug-bar-show"))})},actions:{init:function(){var t=i("#debug-bar-actions");i(document).keydown(function(i){var t=i.key||i.which||i.keyCode;if(27==t&&e.isVisible())return i.preventDefault(),e.actions.close()}),i(".maximize",t).click(e.actions.maximize),i(".restore",t).click(e.actions.restore),i(".close",t).click(e.actions.close)},maximize:function(){e.body.removeClass("debug-bar-partial"),e.body.addClass("debug-bar-maximized")},restore:function(){e.body.removeClass("debug-bar-maximized"),e.body.addClass("debug-bar-partial")},close:function(){e.toggle.visibility(!1),console.log("boo")}}},wpDebugBar.Panel=function(){},i(document).ready(wpDebugBar.init)})(jQuery);
1
+ var wpDebugBar;!function(e){var i;wpDebugBar=i={body:void 0,init:function(){i.body=e(document.body),i.toggle.init(),i.tabs(),i.actions.init()},isVisible:function(){return i.body.hasClass("debug-bar-visible")},toggle:{init:function(){e("#wp-admin-bar-debug-bar").click(function(t){if(t.preventDefault(),t.target.hash){var s=e(t.target.rel);if(i.isVisible()){if(s.hasClass("current"))return s.removeClass("current"),void i.toggle.visibility()}else i.toggle.visibility();e(".debug-menu-target").hide().trigger("debug-bar-hide"),e(".debug-menu-link").removeClass("current"),s.addClass("current"),e(t.target.hash).show().trigger("debug-bar-show")}else i.toggle.visibility()})},visibility:function(t){t=void 0===t?!i.isVisible():t,i.body.toggleClass("debug-bar-visible",t),e(this).toggleClass("active",t)}},tabs:function(){var i=e(".debug-menu-link"),t=e(".debug-menu-target");i.click(function(s){var r=e(this);s.preventDefault(),r.hasClass("current")||(t.hide().trigger("debug-bar-hide"),i.removeClass("current"),r.addClass("current"),e("#"+this.href.substr(this.href.indexOf("#")+1)).show().trigger("debug-bar-show"))})},actions:{init:function(){var t=e("#debug-bar-actions");e(document).keydown(function(e){var t=e.key||e.which||e.keyCode;27===t&&i.isVisible()&&(e.preventDefault(),i.actions.close())}),e(".maximize",t).click(i.actions.maximize),e(".restore",t).click(i.actions.restore),e(".close",t).click(i.actions.close)},maximize:function(){i.body.removeClass("debug-bar-partial"),i.body.addClass("debug-bar-maximized")},restore:function(){i.body.removeClass("debug-bar-maximized"),i.body.addClass("debug-bar-partial")},close:function(){i.toggle.visibility(!1)}}},e(wpDebugBar.init)}(jQuery);
panels/class-debug-bar-deprecated.php CHANGED
@@ -1,21 +1,23 @@
1
  <?php
 
2
  // Alot of this code is massaged from Andrew Nacin's log-deprecated-notices plugin
3
 
4
  class Debug_Bar_Deprecated extends Debug_Bar_Panel {
5
- var $deprecated_functions = array();
6
- var $deprecated_files = array();
7
- var $deprecated_arguments = array();
8
 
9
  function init() {
10
- $this->title( __('Deprecated', 'debug-bar') );
11
 
12
- add_action( 'deprecated_function_run', array( &$this, 'deprecated_function_run' ), 10, 3 );
13
- add_action( 'deprecated_file_included', array( &$this, 'deprecated_file_included' ), 10, 4 );
14
- add_action( 'deprecated_argument_run', array( &$this, 'deprecated_argument_run' ), 10, 3 );
15
 
16
  // Silence E_NOTICE for deprecated usage.
17
- foreach ( array( 'function', 'file', 'argument' ) as $item )
18
  add_filter( "deprecated_{$item}_trigger_error", '__return_false' );
 
19
  }
20
 
21
  function prerender() {
@@ -28,15 +30,15 @@ class Debug_Bar_Deprecated extends Debug_Bar_Panel {
28
 
29
  function render() {
30
  echo "<div id='debug-bar-deprecated'>";
31
- echo '<h2><span>Total Functions:</span>' . number_format( count( $this->deprecated_functions ) ) . "</h2>\n";
32
- echo '<h2><span>Total Arguments:</span>' . number_format( count( $this->deprecated_arguments ) ) . "</h2>\n";
33
- echo '<h2><span>Total Files:</span>' . number_format( count( $this->deprecated_files ) ) . "</h2>\n";
34
  if ( count( $this->deprecated_functions ) ) {
35
  echo '<ol class="debug-bar-deprecated-list">';
36
- foreach ( $this->deprecated_functions as $location => $message_stack) {
37
- list( $message, $stack) = $message_stack;
38
  echo "<li class='debug-bar-deprecated-function'>";
39
- echo str_replace(ABSPATH, '', $location) . ' - ' . strip_tags($message);
40
  echo "<br/>";
41
  echo $stack;
42
  echo "</li>";
@@ -45,10 +47,10 @@ class Debug_Bar_Deprecated extends Debug_Bar_Panel {
45
  }
46
  if ( count( $this->deprecated_files ) ) {
47
  echo '<ol class="debug-bar-deprecated-list">';
48
- foreach ( $this->deprecated_files as $location => $message_stack) {
49
- list( $message, $stack) = $message_stack;
50
  echo "<li class='debug-bar-deprecated-file'>";
51
- echo str_replace(ABSPATH, '', $location) . ' - ' . strip_tags($message);
52
  echo "<br/>";
53
  echo $stack;
54
  echo "</li>";
@@ -57,10 +59,10 @@ class Debug_Bar_Deprecated extends Debug_Bar_Panel {
57
  }
58
  if ( count( $this->deprecated_arguments ) ) {
59
  echo '<ol class="debug-bar-deprecated-list">';
60
- foreach ( $this->deprecated_arguments as $location => $message_stack) {
61
- list( $message, $stack) = $message_stack;
62
  echo "<li class='debug-bar-deprecated-argument'>";
63
- echo str_replace(ABSPATH, '', $location) . ' - ' . strip_tags($message);
64
  echo "<br/>";
65
  echo $stack;
66
  echo "</li>";
@@ -70,41 +72,52 @@ class Debug_Bar_Deprecated extends Debug_Bar_Panel {
70
  echo "</div>";
71
  }
72
 
73
- function deprecated_function_run($function, $replacement, $version) {
74
  $backtrace = debug_backtrace( false );
75
- $bt = 4;
 
76
  // Check if we're a hook callback.
77
  if ( ! isset( $backtrace[4]['file'] ) && 'call_user_func_array' == $backtrace[5]['function'] ) {
78
  $bt = 6;
79
  }
80
- $file = $backtrace[ $bt ]['file'];
81
- $line = $backtrace[ $bt ]['line'];
82
- if ( ! is_null($replacement) )
83
- $message = sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', 'debug-bar'), $function, $version, $replacement );
84
- else
85
- $message = sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', 'debug-bar'), $function, $version );
86
-
87
- $this->deprecated_functions[$file.':'.$line] = array( $message, wp_debug_backtrace_summary( null, $bt ) );
 
 
 
 
88
  }
89
 
90
  function deprecated_file_included( $old_file, $replacement, $version, $message ) {
91
  $backtrace = debug_backtrace( false );
92
- $file = $backtrace[4]['file'];
93
- $file_abs = str_replace(ABSPATH, '', $file);
94
- $line = $backtrace[4]['line'];
95
- $message = empty( $message ) ? '' : ' ' . $message;
96
- if ( ! is_null( $replacement ) )
97
- $message = sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', 'debug-bar'), $file_abs, $version, $replacement ) . $message;
98
- else
99
- $message = sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', 'debug-bar'), $file_abs, $version ) . $message;
100
-
101
- $this->deprecated_functions[$file.':'.$line] = array( $message, wp_debug_backtrace_summary( null, 4 ) );
 
 
 
 
102
  }
103
 
104
- function deprecated_argument_run( $function, $message, $version) {
105
  $backtrace = debug_backtrace( false );
106
- if ( $function === 'define()' ) {
107
- $this->deprecated_functions[] = array( $message, '' );
 
 
108
  return;
109
  }
110
 
@@ -112,9 +125,15 @@ class Debug_Bar_Deprecated extends Debug_Bar_Panel {
112
  if ( ! isset( $backtrace[4]['file'] ) && 'call_user_func_array' == $backtrace[5]['function'] ) {
113
  $bt = 6;
114
  }
115
- $file = $backtrace[ $bt ]['file'];
116
- $line = $backtrace[ $bt ]['line'];
117
 
118
- $this->deprecated_functions[$file.':'.$line] = array( $message, wp_debug_backtrace_summary( null, $bt ) );
 
 
 
 
 
 
 
 
119
  }
120
  }
1
  <?php
2
+
3
  // Alot of this code is massaged from Andrew Nacin's log-deprecated-notices plugin
4
 
5
  class Debug_Bar_Deprecated extends Debug_Bar_Panel {
6
+ private $deprecated_functions = array();
7
+ private $deprecated_files = array();
8
+ private $deprecated_arguments = array();
9
 
10
  function init() {
11
+ $this->title( __( 'Deprecated', 'debug-bar' ) );
12
 
13
+ add_action( 'deprecated_function_run', array( $this, 'deprecated_function_run' ), 10, 3 );
14
+ add_action( 'deprecated_file_included', array( $this, 'deprecated_file_included' ), 10, 4 );
15
+ add_action( 'deprecated_argument_run', array( $this, 'deprecated_argument_run' ), 10, 3 );
16
 
17
  // Silence E_NOTICE for deprecated usage.
18
+ foreach ( array( 'function', 'file', 'argument' ) as $item ) {
19
  add_filter( "deprecated_{$item}_trigger_error", '__return_false' );
20
+ }
21
  }
22
 
23
  function prerender() {
30
 
31
  function render() {
32
  echo "<div id='debug-bar-deprecated'>";
33
+ echo '<h2><span>', __( 'Total Functions:', 'debug-bar' ), '</span>', number_format_i18n( count( $this->deprecated_functions ) ), "</h2>\n";
34
+ echo '<h2><span>', __( 'Total Arguments:', 'debug-bar' ), '</span>', number_format_i18n( count( $this->deprecated_arguments ) ), "</h2>\n";
35
+ echo '<h2><span>', __( 'Total Files:', 'debug-bar' ), '</span>', number_format_i18n( count( $this->deprecated_files ) ), "</h2>\n";
36
  if ( count( $this->deprecated_functions ) ) {
37
  echo '<ol class="debug-bar-deprecated-list">';
38
+ foreach ( $this->deprecated_functions as $location => $message_stack ) {
39
+ list( $message, $stack ) = $message_stack;
40
  echo "<li class='debug-bar-deprecated-function'>";
41
+ echo str_replace( ABSPATH, '', $location ) . ' - ' . strip_tags( $message );
42
  echo "<br/>";
43
  echo $stack;
44
  echo "</li>";
47
  }
48
  if ( count( $this->deprecated_files ) ) {
49
  echo '<ol class="debug-bar-deprecated-list">';
50
+ foreach ( $this->deprecated_files as $location => $message_stack ) {
51
+ list( $message, $stack ) = $message_stack;
52
  echo "<li class='debug-bar-deprecated-file'>";
53
+ echo str_replace( ABSPATH, '', $location ) . ' - ' . strip_tags( $message );
54
  echo "<br/>";
55
  echo $stack;
56
  echo "</li>";
59
  }
60
  if ( count( $this->deprecated_arguments ) ) {
61
  echo '<ol class="debug-bar-deprecated-list">';
62
+ foreach ( $this->deprecated_arguments as $location => $message_stack ) {
63
+ list( $message, $stack ) = $message_stack;
64
  echo "<li class='debug-bar-deprecated-argument'>";
65
+ echo str_replace( ABSPATH, '', $location ) . ' - ' . strip_tags( $message );
66
  echo "<br/>";
67
  echo $stack;
68
  echo "</li>";
72
  echo "</div>";
73
  }
74
 
75
+ function deprecated_function_run( $function, $replacement, $version ) {
76
  $backtrace = debug_backtrace( false );
77
+ $bt = 4;
78
+
79
  // Check if we're a hook callback.
80
  if ( ! isset( $backtrace[4]['file'] ) && 'call_user_func_array' == $backtrace[5]['function'] ) {
81
  $bt = 6;
82
  }
83
+
84
+ $location = $backtrace[ $bt ]['file'] . ':' . $backtrace[ $bt ]['line'];
85
+
86
+ if ( ! is_null( $replacement ) ) {
87
+ /* translators: %1$s is a function or file name, %2$s a version number, %3$s an alternative function or file to use. */
88
+ $message = sprintf( __( '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', 'debug-bar' ), $function, $version, $replacement );
89
+ } else {
90
+ /* translators: %1$s is a function or file name, %2$s a version number. */
91
+ $message = sprintf( __( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', 'debug-bar' ), $function, $version );
92
+ }
93
+
94
+ $this->deprecated_functions[ $location ] = array( $message, wp_debug_backtrace_summary( null, $bt ) );
95
  }
96
 
97
  function deprecated_file_included( $old_file, $replacement, $version, $message ) {
98
  $backtrace = debug_backtrace( false );
99
+ $file = $backtrace[4]['file'];
100
+ $file_abs = str_replace( ABSPATH, '', $file );
101
+ $location = $file . ':' . $backtrace[4]['line'];
102
+ $message = empty( $message ) ? '' : ' ' . $message;
103
+
104
+ if ( ! is_null( $replacement ) ) {
105
+ /* translators: %1$s is a function or file name, %2$s a version number, %3$s an alternative function or file to use. */
106
+ $message = sprintf( __( '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', 'debug-bar' ), $file_abs, $version, $replacement ) . $message;
107
+ } else {
108
+ /* translators: %1$s is a function or file name, %2$s a version number. */
109
+ $message = sprintf( __( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', 'debug-bar' ), $file_abs, $version ) . $message;
110
+ }
111
+
112
+ $this->deprecated_files[ $location ] = array( $message, wp_debug_backtrace_summary( null, 4 ) );
113
  }
114
 
115
+ function deprecated_argument_run( $function, $message, $version ) {
116
  $backtrace = debug_backtrace( false );
117
+
118
+ if ( 'define()' === $function ) {
119
+ $this->deprecated_arguments[] = array( $message, '' );
120
+
121
  return;
122
  }
123
 
125
  if ( ! isset( $backtrace[4]['file'] ) && 'call_user_func_array' == $backtrace[5]['function'] ) {
126
  $bt = 6;
127
  }
 
 
128
 
129
+ $location = $backtrace[ $bt ]['file'] . ':' . $backtrace[ $bt ]['line'];
130
+
131
+ if ( ! is_null( $message ) ) {
132
+ $message = sprintf( __( '%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s! %3$s' ), $function, $version, $message );
133
+ } else {
134
+ $message = sprintf( __( '%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s with no alternative available.' ), $function, $version );
135
+ }
136
+
137
+ $this->deprecated_arguments[ $location ] = array( $message, wp_debug_backtrace_summary( null, $bt ) );
138
  }
139
  }
panels/class-debug-bar-js.php CHANGED
@@ -1,20 +1,22 @@
1
  <?php
2
 
3
  class Debug_Bar_JS extends Debug_Bar_Panel {
4
- var $real_error_handler = array();
5
 
6
  function init() {
7
- $this->title( __('JavaScript', 'debug-bar') );
8
 
9
- // attach here instead of debug_bar_enqueue_scripts
10
- // because we want to be as early as possible!
11
- $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '.dev' : '';
12
- wp_enqueue_script( 'debug-bar-js', plugins_url( "js/debug-bar-js$suffix.js", dirname(__FILE__) ), array(), '20111216' );
 
 
13
  }
14
 
15
  function render() {
16
  echo '<div id="debug-bar-js">';
17
- echo '<h2><span>' . __( 'Total Errors:', 'debug-bar' ) . "</span><div id='debug-bar-js-error-count'>0</div></h2>\n";
18
  echo '<ol class="debug-bar-js-list" id="debug-bar-js-errors"></ol>' . "\n";
19
  echo '</div>';
20
  }
1
  <?php
2
 
3
  class Debug_Bar_JS extends Debug_Bar_Panel {
4
+ public $real_error_handler = array();
5
 
6
  function init() {
7
+ $this->title( __( 'JavaScript', 'debug-bar' ) );
8
 
9
+ /*
10
+ * attach here instead of debug_bar_enqueue_scripts
11
+ * because we want to be as early as possible!
12
+ */
13
+ $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.dev' : '';
14
+ wp_enqueue_script( 'debug-bar-js', plugins_url( "js/debug-bar-js$suffix.js", dirname( __FILE__ ) ), array( 'jquery' ), '20111216' );
15
  }
16
 
17
  function render() {
18
  echo '<div id="debug-bar-js">';
19
+ echo '<h2><span>' . __( 'Total Errors:', 'debug-bar' ) . "</span><span id='debug-bar-js-error-count'>0</span></h2>\n";
20
  echo '<ol class="debug-bar-js-list" id="debug-bar-js-errors"></ol>' . "\n";
21
  echo '</div>';
22
  }
panels/class-debug-bar-object-cache.php CHANGED
@@ -2,16 +2,17 @@
2
 
3
  class Debug_Bar_Object_Cache extends Debug_Bar_Panel {
4
  function init() {
5
- $this->title( __('Object Cache', 'debug-bar') );
6
  }
7
 
8
  function prerender() {
9
  global $wp_object_cache;
10
- $this->set_visible( is_object($wp_object_cache) && method_exists($wp_object_cache, 'stats') );
11
  }
12
 
13
  function render() {
14
  global $wp_object_cache;
 
15
  ob_start();
16
  echo "<div id='object-cache-stats'>";
17
  $wp_object_cache->stats();
2
 
3
  class Debug_Bar_Object_Cache extends Debug_Bar_Panel {
4
  function init() {
5
+ $this->title( __( 'Object Cache', 'debug-bar' ) );
6
  }
7
 
8
  function prerender() {
9
  global $wp_object_cache;
10
+ $this->set_visible( is_object( $wp_object_cache ) && method_exists( $wp_object_cache, 'stats' ) );
11
  }
12
 
13
  function render() {
14
  global $wp_object_cache;
15
+
16
  ob_start();
17
  echo "<div id='object-cache-stats'>";
18
  $wp_object_cache->stats();
panels/class-debug-bar-panel.php CHANGED
@@ -1,22 +1,24 @@
1
  <?php
2
 
3
  class Debug_Bar_Panel {
4
- var $_title = '';
5
- var $_visible = true;
6
 
7
  function __construct( $title = '' ) {
8
  $this->title( $title );
9
 
10
  if ( $this->init() === false ) {
11
  $this->set_visible( false );
 
12
  return;
13
  }
14
 
15
- add_filter( 'debug_bar_classes', array( &$this, 'debug_bar_classes' ) );
16
  }
17
 
18
  function Debug_Bar_Panel( $title = '' ) {
19
- Debug_Bar_Panel::__construct( $title );
 
20
  }
21
 
22
  /**
@@ -39,9 +41,17 @@ class Debug_Bar_Panel {
39
  $this->_visible = $visible;
40
  }
41
 
42
- function title( $title=NULL ) {
43
- if ( ! isset( $title ) )
 
 
 
 
 
 
44
  return $this->_title;
 
 
45
  $this->_title = $title;
46
  }
47
 
1
  <?php
2
 
3
  class Debug_Bar_Panel {
4
+ public $_title = '';
5
+ public $_visible = true;
6
 
7
  function __construct( $title = '' ) {
8
  $this->title( $title );
9
 
10
  if ( $this->init() === false ) {
11
  $this->set_visible( false );
12
+
13
  return;
14
  }
15
 
16
+ add_filter( 'debug_bar_classes', array( $this, 'debug_bar_classes' ) );
17
  }
18
 
19
  function Debug_Bar_Panel( $title = '' ) {
20
+ _deprecated_constructor( __METHOD__, '0.8.3', __CLASS__ );
21
+ self::__construct( $title );
22
  }
23
 
24
  /**
41
  $this->_visible = $visible;
42
  }
43
 
44
+ /**
45
+ * Get/set title.
46
+ *
47
+ * @param null $title
48
+ * @return string|void
49
+ */
50
+ function title( $title = null ) {
51
+ if ( ! isset( $title ) ) {
52
  return $this->_title;
53
+ }
54
+
55
  $this->_title = $title;
56
  }
57
 
panels/class-debug-bar-php.php CHANGED
@@ -1,15 +1,16 @@
1
  <?php
2
 
3
  class Debug_Bar_PHP extends Debug_Bar_Panel {
4
- var $warnings = array();
5
- var $notices = array();
6
- var $real_error_handler = array();
7
 
8
  function init() {
9
- if ( ! WP_DEBUG )
10
  return false;
 
11
 
12
- $this->title( __('Notices / Warnings', 'debug-bar') );
13
 
14
  $this->real_error_handler = set_error_handler( array( &$this, 'error_handler' ) );
15
  }
@@ -19,73 +20,92 @@ class Debug_Bar_PHP extends Debug_Bar_Panel {
19
  }
20
 
21
  function debug_bar_classes( $classes ) {
22
- if ( count( $this->warnings ) )
23
  $classes[] = 'debug-bar-php-warning-summary';
24
- elseif ( count( $this->notices ) )
25
  $classes[] = 'debug-bar-php-notice-summary';
 
 
26
  return $classes;
27
  }
28
 
29
  function error_handler( $type, $message, $file, $line ) {
30
  $_key = md5( $file . ':' . $line . ':' . $message );
31
 
 
 
 
 
 
 
 
32
  switch ( $type ) {
33
- case E_WARNING :
34
- case E_USER_WARNING :
35
- $this->warnings[$_key] = array( $file.':'.$line, $message, wp_debug_backtrace_summary( __CLASS__ ) );
 
 
 
 
36
  break;
37
- case E_NOTICE :
38
- case E_USER_NOTICE :
39
- $this->notices[$_key] = array( $file.':'.$line, $message, wp_debug_backtrace_summary( __CLASS__ ) );
 
 
 
 
40
  break;
41
- case E_STRICT :
42
  // TODO
43
  break;
44
- case E_DEPRECATED :
45
- case E_USER_DEPRECATED :
46
  // TODO
47
  break;
48
- case 0 :
49
  // TODO
50
  break;
51
  }
52
 
53
- if ( null != $this->real_error_handler )
54
  return call_user_func( $this->real_error_handler, $type, $message, $file, $line );
55
- else
56
  return false;
 
57
  }
58
 
59
  function render() {
60
  echo "<div id='debug-bar-php'>";
61
- echo '<h2><span>Total Warnings:</span>' . number_format( count( $this->warnings ) ) . "</h2>\n";
62
- echo '<h2><span>Total Notices:</span>' . number_format( count( $this->notices ) ) . "</h2>\n";
 
63
  if ( count( $this->warnings ) ) {
64
  echo '<ol class="debug-bar-php-list">';
65
  foreach ( $this->warnings as $location_message_stack ) {
66
- list( $location, $message, $stack) = $location_message_stack;
67
- echo '<li class="debug-bar-php-warning">WARNING: ';
68
- echo str_replace(ABSPATH, '', $location) . ' - ' . strip_tags($message);
69
  echo '<br/>';
70
  echo $stack;
71
  echo '</li>';
72
  }
73
  echo '</ol>';
74
  }
 
75
  if ( count( $this->notices ) ) {
76
  echo '<ol class="debug-bar-php-list">';
77
- foreach ( $this->notices as $location_message_stack) {
78
- list( $location, $message, $stack) = $location_message_stack;
79
- echo '<li class="debug-bar-php-notice">NOTICE: ';
80
- echo str_replace(ABSPATH, '', $location) . ' - ' . strip_tags($message);
81
  echo '<br/>';
82
  echo $stack;
83
  echo '</li>';
84
  }
85
  echo '</ol>';
86
  }
87
- echo "</div>";
88
 
 
89
  }
90
  }
91
-
1
  <?php
2
 
3
  class Debug_Bar_PHP extends Debug_Bar_Panel {
4
+ public $warnings = array();
5
+ public $notices = array();
6
+ public $real_error_handler = array();
7
 
8
  function init() {
9
+ if ( ! WP_DEBUG ) {
10
  return false;
11
+ }
12
 
13
+ $this->title( __( 'Notices / Warnings', 'debug-bar' ) );
14
 
15
  $this->real_error_handler = set_error_handler( array( &$this, 'error_handler' ) );
16
  }
20
  }
21
 
22
  function debug_bar_classes( $classes ) {
23
+ if ( count( $this->warnings ) ) {
24
  $classes[] = 'debug-bar-php-warning-summary';
25
+ } elseif ( count( $this->notices ) ) {
26
  $classes[] = 'debug-bar-php-notice-summary';
27
+ }
28
+
29
  return $classes;
30
  }
31
 
32
  function error_handler( $type, $message, $file, $line ) {
33
  $_key = md5( $file . ':' . $line . ':' . $message );
34
 
35
+ if ( ! defined( 'E_DEPRECATED' ) ) {
36
+ define( 'E_DEPRECATED', 8192 );
37
+ }
38
+ if ( ! defined( 'E_USER_DEPRECATED' ) ) {
39
+ define( 'E_USER_DEPRECATED', 16384 );
40
+ }
41
+
42
  switch ( $type ) {
43
+ case E_WARNING:
44
+ case E_USER_WARNING:
45
+ $this->warnings[ $_key ] = array(
46
+ $file . ':' . $line,
47
+ $message,
48
+ wp_debug_backtrace_summary( __CLASS__ ),
49
+ );
50
  break;
51
+ case E_NOTICE:
52
+ case E_USER_NOTICE:
53
+ $this->notices[ $_key ] = array(
54
+ $file . ':' . $line,
55
+ $message,
56
+ wp_debug_backtrace_summary( __CLASS__ ),
57
+ );
58
  break;
59
+ case E_STRICT:
60
  // TODO
61
  break;
62
+ case E_DEPRECATED:
63
+ case E_USER_DEPRECATED:
64
  // TODO
65
  break;
66
+ case 0:
67
  // TODO
68
  break;
69
  }
70
 
71
+ if ( null != $this->real_error_handler ) {
72
  return call_user_func( $this->real_error_handler, $type, $message, $file, $line );
73
+ } else {
74
  return false;
75
+ }
76
  }
77
 
78
  function render() {
79
  echo "<div id='debug-bar-php'>";
80
+ echo '<h2><span>', __( 'Total Warnings:', 'debug-bar' ), '</span>', number_format_i18n( count( $this->warnings ) ), "</h2>\n";
81
+ echo '<h2><span>', __( 'Total Notices:', 'debug-bar' ), '</span>', number_format_i18n( count( $this->notices ) ), "</h2>\n";
82
+
83
  if ( count( $this->warnings ) ) {
84
  echo '<ol class="debug-bar-php-list">';
85
  foreach ( $this->warnings as $location_message_stack ) {
86
+ list( $location, $message, $stack ) = $location_message_stack;
87
+ echo '<li class="debug-bar-php-warning">', __( 'WARNING:', 'debug-bar' ), ' ';
88
+ echo str_replace( ABSPATH, '', $location ) . ' - ' . strip_tags( $message );
89
  echo '<br/>';
90
  echo $stack;
91
  echo '</li>';
92
  }
93
  echo '</ol>';
94
  }
95
+
96
  if ( count( $this->notices ) ) {
97
  echo '<ol class="debug-bar-php-list">';
98
+ foreach ( $this->notices as $location_message_stack ) {
99
+ list( $location, $message, $stack ) = $location_message_stack;
100
+ echo '<li class="debug-bar-php-notice">', __( 'NOTICE:', 'debug-bar' ), ' ';
101
+ echo str_replace( ABSPATH, '', $location ) . ' - ' . strip_tags( $message );
102
  echo '<br/>';
103
  echo $stack;
104
  echo '</li>';
105
  }
106
  echo '</ol>';
107
  }
 
108
 
109
+ echo "</div>";
110
  }
111
  }
 
panels/class-debug-bar-queries.php CHANGED
@@ -1,80 +1,93 @@
1
  <?php
2
 
3
  class Debug_Bar_Queries extends Debug_Bar_Panel {
 
4
  function init() {
5
- $this->title( __('Queries', 'debug-bar') );
6
  }
7
 
8
  function prerender() {
9
- $this->set_visible( defined('SAVEQUERIES') && SAVEQUERIES || ! empty($GLOBALS['EZSQL_ERROR']) );
10
  }
11
 
12
  function debug_bar_classes( $classes ) {
13
- if ( ! empty($GLOBALS['EZSQL_ERROR']) )
14
  $classes[] = 'debug-bar-php-warning-summary';
 
 
15
  return $classes;
16
  }
17
 
18
  function render() {
19
  global $wpdb, $EZSQL_ERROR;
20
 
21
- $out = '';
22
  $total_time = 0;
23
 
24
- if ( !empty($wpdb->queries) ) {
25
- $show_many = isset($_GET['debug_queries']);
26
 
27
- if ( $wpdb->num_queries > 500 && !$show_many )
28
- $out .= "<p>" . sprintf( __('There are too many queries to show easily! <a href="%s">Show them anyway</a>', 'debug-bar'), esc_url( add_query_arg( 'debug_queries', 'true' ) ) ) . "</p>";
 
 
29
 
30
  $out .= '<ol class="wpd-queries">';
31
  $counter = 0;
32
 
33
  foreach ( $wpdb->queries as $q ) {
34
- list($query, $elapsed, $debug) = $q;
35
 
36
  $total_time += $elapsed;
37
 
38
- if ( ++$counter > 500 && ! $show_many )
39
  continue;
 
40
 
41
  $debug = explode( ', ', $debug );
42
  $debug = array_diff( $debug, array( 'require_once', 'require', 'include_once', 'include' ) );
43
  $debug = implode( ', ', $debug );
44
  $debug = str_replace( array( 'do_action, call_user_func_array' ), array( 'do_action' ), $debug );
45
- $query = nl2br(esc_html($query));
 
 
 
46
 
47
- $out .= "<li>$query<br/><div class='qdebug'>$debug <span>#{$counter} (" . number_format(sprintf('%0.1f', $elapsed * 1000), 1, '.', ',') . "ms)</span></div></li>\n";
 
48
  }
49
  $out .= '</ol>';
 
 
50
  } else {
51
- if ( $wpdb->num_queries == 0 )
52
- $out .= "<p><strong>" . __('There are no queries on this page.', 'debug-bar') . "</strong></p>";
53
- else
54
- $out .= "<p><strong>" . __('SAVEQUERIES must be defined to show the query log.', 'debug-bar') . "</strong></p>";
55
  }
56
 
57
- if ( ! empty($EZSQL_ERROR) ) {
58
  $out .= '<h3>' . __( 'Database Errors', 'debug-bar' ) . '</h3>';
59
  $out .= '<ol class="wpd-queries">';
60
 
61
- foreach ( $EZSQL_ERROR as $e ) {
62
- $query = nl2br(esc_html($e['query']));
63
- $out .= "<li>$query<br/><div class='qdebug'>{$e['error_str']}</div></li>\n";
 
64
  }
65
  $out .= '</ol>';
66
  }
67
 
68
  $heading = '';
69
- if ( $wpdb->num_queries )
70
- $heading .= '<h2><span>Total Queries:</span>' . number_format( $wpdb->num_queries ) . "</h2>\n";
71
- if ( $total_time )
72
- $heading .= '<h2><span>Total query time:</span>' . number_format(sprintf('%0.1f', $total_time * 1000), 1) . " ms</h2>\n";
73
- if ( ! empty($EZSQL_ERROR) )
74
- $heading .= '<h2><span>Total DB Errors:</span>' . number_format( count($EZSQL_ERROR) ) . "</h2>\n";
75
-
76
- $out = $heading . $out;
 
 
 
77
 
78
- echo $out;
79
  }
80
  }
1
  <?php
2
 
3
  class Debug_Bar_Queries extends Debug_Bar_Panel {
4
+
5
  function init() {
6
+ $this->title( __( 'Queries', 'debug-bar' ) );
7
  }
8
 
9
  function prerender() {
10
+ $this->set_visible( defined( 'SAVEQUERIES' ) && SAVEQUERIES || ! empty( $GLOBALS['EZSQL_ERROR'] ) );
11
  }
12
 
13
  function debug_bar_classes( $classes ) {
14
+ if ( ! empty( $GLOBALS['EZSQL_ERROR'] ) ) {
15
  $classes[] = 'debug-bar-php-warning-summary';
16
+ }
17
+
18
  return $classes;
19
  }
20
 
21
  function render() {
22
  global $wpdb, $EZSQL_ERROR;
23
 
24
+ $out = '';
25
  $total_time = 0;
26
 
27
+ if ( ! empty( $wpdb->queries ) ) {
28
+ $show_many = isset( $_GET['debug_queries'] );
29
 
30
+ if ( $wpdb->num_queries > 500 && ! $show_many ) {
31
+ /* translators: %s = a url. */
32
+ $out .= "<p>" . sprintf( __( 'There are too many queries to show easily! <a href="%s">Show them anyway</a>', 'debug-bar' ), esc_url( add_query_arg( 'debug_queries', 'true' ) ) ) . "</p>";
33
+ }
34
 
35
  $out .= '<ol class="wpd-queries">';
36
  $counter = 0;
37
 
38
  foreach ( $wpdb->queries as $q ) {
39
+ list( $query, $elapsed, $debug ) = $q;
40
 
41
  $total_time += $elapsed;
42
 
43
+ if ( ++$counter > 500 && ! $show_many ) {
44
  continue;
45
+ }
46
 
47
  $debug = explode( ', ', $debug );
48
  $debug = array_diff( $debug, array( 'require_once', 'require', 'include_once', 'include' ) );
49
  $debug = implode( ', ', $debug );
50
  $debug = str_replace( array( 'do_action, call_user_func_array' ), array( 'do_action' ), $debug );
51
+ $debug = esc_html( $debug );
52
+ $query = nl2br( esc_html( $query ) );
53
+ /* translators: %0.1f = duration in microseconds. */
54
+ $time = esc_html( sprintf( __( '%0.1f ms', 'debug-bar' ), number_format_i18n( ( $elapsed * 1000 ), 1 ) ) );
55
 
56
+ /* translators: %d = duration time in microseconds. */
57
+ $out .= "<li>$query<br/><div class='qdebug'>$debug <span>#$counter ($time)</span></div></li>\n";
58
  }
59
  $out .= '</ol>';
60
+ } else if ( 0 === $wpdb->num_queries ) {
61
+ $out .= "<p><strong>" . __( 'There are no queries on this page.', 'debug-bar' ) . "</strong></p>";
62
  } else {
63
+ $out .= "<p><strong>" . __( 'SAVEQUERIES must be defined to show the query log.', 'debug-bar' ) . "</strong></p>";
 
 
 
64
  }
65
 
66
+ if ( ! empty( $EZSQL_ERROR ) ) {
67
  $out .= '<h3>' . __( 'Database Errors', 'debug-bar' ) . '</h3>';
68
  $out .= '<ol class="wpd-queries">';
69
 
70
+ foreach ( $EZSQL_ERROR as $error ) {
71
+ $query = nl2br( esc_html( $error['query'] ) );
72
+ $message = esc_html( $error['error_str'] );
73
+ $out .= "<li>$query<br/><div class='qdebug'>$message</div></li>\n";
74
  }
75
  $out .= '</ol>';
76
  }
77
 
78
  $heading = '';
79
+ if ( $wpdb->num_queries ) {
80
+ $heading .= '<h2><span>' . __( 'Total Queries:', 'debug-bar' ) . '</span>' . number_format_i18n( $wpdb->num_queries ) . "</h2>\n";
81
+ }
82
+ if ( $total_time ) {
83
+ $heading .= '<h2><span>' . __( 'Total query time:', 'debug-bar' ) . '</span>';
84
+ /* translators: %0.1f = duration in microseconds. */
85
+ $heading .= sprintf( __( '%0.1f ms', 'debug-bar' ), number_format_i18n( ( $total_time * 1000 ), 1 ) ) . "</h2>\n";
86
+ }
87
+ if ( ! empty( $EZSQL_ERROR ) ) {
88
+ $heading .= '<h2><span>' . __( 'Total DB Errors:', 'debug-bar' ) . '</span>' . number_format_i18n( count( $EZSQL_ERROR ) ) . "</h2>\n";
89
+ }
90
 
91
+ echo $heading . $out;
92
  }
93
  }
panels/class-debug-bar-request.php CHANGED
@@ -14,36 +14,40 @@ class Debug_Bar_Request extends Debug_Bar_Panel {
14
 
15
  echo "<div id='debug-bar-request'>";
16
 
17
- if ( empty($wp->request) )
18
- $request = 'None';
19
- else
20
  $request = $wp->request;
 
21
 
22
- echo '<h3>Request:</h3>';
23
  echo '<p>' . esc_html( $request ) . '</p>';
24
 
25
- if ( empty($wp->query_string) )
26
- $query_string = 'None';
27
- else
28
  $query_string = $wp->query_string;
 
29
 
30
- echo '<h3>Query String:</h3>';
31
  echo '<p>' . esc_html( $query_string ) . '</p>';
32
 
33
- if ( empty($wp->matched_rule) )
34
- $matched_rule = 'None';
35
- else
36
  $matched_rule = $wp->matched_rule;
 
37
 
38
- echo '<h3>Matched Rewrite Rule:</h3>';
39
  echo '<p>' . esc_html( $matched_rule ) . '</p>';
40
 
41
- if ( empty($wp->matched_query) )
42
- $matched_query = 'None';
43
- else
44
  $matched_query = $wp->matched_query;
 
45
 
46
- echo '<h3>Matched Rewrite Query:</h3>';
47
  echo '<p>' . esc_html( $matched_query ) . '</p>';
48
 
49
  echo '</div>';
14
 
15
  echo "<div id='debug-bar-request'>";
16
 
17
+ if ( empty( $wp->request ) ) {
18
+ $request = __( 'None', 'debug-bar' );
19
+ } else {
20
  $request = $wp->request;
21
+ }
22
 
23
+ echo '<h3>', __( 'Request:', 'debug-bar' ), '</h3>';
24
  echo '<p>' . esc_html( $request ) . '</p>';
25
 
26
+ if ( empty( $wp->query_string ) ) {
27
+ $query_string = __( 'None', 'debug-bar' );
28
+ } else {
29
  $query_string = $wp->query_string;
30
+ }
31
 
32
+ echo '<h3>', __( 'Query String:', 'debug-bar' ), '</h3>';
33
  echo '<p>' . esc_html( $query_string ) . '</p>';
34
 
35
+ if ( empty( $wp->matched_rule ) ) {
36
+ $matched_rule = __( 'None', 'debug-bar' );
37
+ } else {
38
  $matched_rule = $wp->matched_rule;
39
+ }
40
 
41
+ echo '<h3>', __( 'Matched Rewrite Rule:', 'debug-bar' ), '</h3>';
42
  echo '<p>' . esc_html( $matched_rule ) . '</p>';
43
 
44
+ if ( empty( $wp->matched_query ) ) {
45
+ $matched_query = __( 'None', 'debug-bar' );
46
+ } else {
47
  $matched_query = $wp->matched_query;
48
+ }
49
 
50
+ echo '<h3>', __( 'Matched Rewrite Query:', 'debug-bar' ), '</h3>';
51
  echo '<p>' . esc_html( $matched_query ) . '</p>';
52
 
53
  echo '</div>';
panels/class-debug-bar-wp-query.php CHANGED
@@ -2,105 +2,112 @@
2
 
3
  class Debug_Bar_WP_Query extends Debug_Bar_Panel {
4
  function init() {
5
- $this->title( __('WP Query', 'debug-bar') );
6
  }
7
 
8
  function prerender() {
9
- $this->set_visible( defined('SAVEQUERIES') && SAVEQUERIES );
10
  }
11
 
12
  function render() {
13
  global $template, $wp_query;
 
14
  $queried_object = get_queried_object();
15
- if ( $queried_object && isset( $queried_object->post_type ) )
16
  $post_type_object = get_post_type_object( $queried_object->post_type );
 
17
 
18
  echo "<div id='debug-bar-wp-query'>";
19
- echo '<h2><span>Queried Object ID:</span>' . get_queried_object_id() . "</h2>\n";
20
 
21
  // Determine the query type. Follows the template loader order.
22
  $type = '';
23
- if ( is_404() )
24
- $type = '404';
25
- elseif ( is_search() )
26
- $type = 'Search';
27
- elseif ( is_tax() )
28
- $type = 'Taxonomy';
29
- elseif ( is_front_page() )
30
- $type = 'Front Page';
31
- elseif ( is_home() )
32
- $type = 'Home';
33
- elseif ( is_attachment() )
34
- $type = 'Attachment';
35
- elseif ( is_single() )
36
- $type = 'Single';
37
- elseif ( is_page() )
38
- $type = 'Page';
39
- elseif ( is_category() )
40
- $type = 'Category';
41
- elseif ( is_tag() )
42
- $type = 'Tag';
43
- elseif ( is_author() )
44
- $type = 'Author';
45
- elseif ( is_date() )
46
- $type = 'Date';
47
- elseif ( is_archive() )
48
- $type = 'Archive';
49
- elseif ( is_paged() )
50
- $type = 'Paged';
51
-
52
- if ( !empty($type) )
53
- echo '<h2><span>Query Type:</span>' . $type . "</h2>\n";
54
-
55
- if ( !empty($template) )
56
- echo '<h2><span>Query Template:</span>' . basename($template) . "</h2>\n";
57
-
58
- $show_on_front = get_option( 'show_on_front' );
59
- $page_on_front = get_option( 'page_on_front' );
 
 
 
60
  $page_for_posts = get_option( 'page_for_posts' );
61
 
62
- echo '<h2><span>Show on Front:</span>' . $show_on_front . "</h2>\n";
63
  if ( 'page' == $show_on_front ) {
64
- echo '<h2><span>Page for Posts:</span>' . $page_for_posts . "</h2>\n";
65
- echo '<h2><span>Page on Front:</span>' . $page_on_front . "</h2>\n";
66
  }
67
 
68
- if ( isset( $post_type_object ) )
69
- echo '<h2><span>Post Type:</span>' . $post_type_object->labels->singular_name . "</h2>\n";
 
70
 
71
  echo '<div class="clear"></div>';
72
 
73
- if ( empty($wp_query->query) )
74
- $query = 'None';
75
- else
76
  $query = http_build_query( $wp_query->query );
 
77
 
78
- echo '<h3>Query Arguments:</h3>';
79
  echo '<p>' . esc_html( $query ) . '</p>';
80
 
81
- if ( ! empty($wp_query->request) ) {
82
- echo '<h3>Query SQL:</h3>';
83
  echo '<p>' . esc_html( $wp_query->request ) . '</p>';
84
  }
85
 
86
  if ( ! is_null( $queried_object ) ) {
87
- echo '<h3>Queried Object:</h3>';
88
- echo '<ol class="debug-bar-wp-query-list">';
89
- $this->_recursive_print_kv($queried_object);
90
- echo '</ol>';
91
  }
92
  echo '</div>';
93
  }
94
-
95
- protected function _recursive_print_kv( $kv_array ) {
96
- foreach ( $kv_array as $key => $value ) {
97
- if( is_object( $value ) || is_array( $value ) ) {
98
- printf( '<li>%s => <ol>', $key );
99
- $this->_recursive_print_kv( $value );
100
- echo '</ol></li>';
101
- } else {
102
- echo "<li>{$key} => {$value}</li>";
103
- }
104
- }
105
- }
106
  }
2
 
3
  class Debug_Bar_WP_Query extends Debug_Bar_Panel {
4
  function init() {
5
+ $this->title( __( 'WP Query', 'debug-bar' ) );
6
  }
7
 
8
  function prerender() {
9
+ $this->set_visible( defined( 'SAVEQUERIES' ) && SAVEQUERIES );
10
  }
11
 
12
  function render() {
13
  global $template, $wp_query;
14
+
15
  $queried_object = get_queried_object();
16
+ if ( $queried_object && isset( $queried_object->post_type ) ) {
17
  $post_type_object = get_post_type_object( $queried_object->post_type );
18
+ }
19
 
20
  echo "<div id='debug-bar-wp-query'>";
21
+ echo '<h2><span>', __( 'Queried Object ID:', 'debug-bar' ), '</span>', get_queried_object_id(), "</h2>\n";
22
 
23
  // Determine the query type. Follows the template loader order.
24
  $type = '';
25
+ if ( is_404() ) {
26
+ $type = __( '404', 'debug-bar' );
27
+ } elseif ( is_search() ) {
28
+ $type = __( 'Search', 'debug-bar' );
29
+ } elseif ( is_tax() ) {
30
+ $type = __( 'Taxonomy', 'debug-bar' );
31
+ } elseif ( is_front_page() ) {
32
+ $type = __( 'Front Page', 'debug-bar' );
33
+ } elseif ( is_home() ) {
34
+ $type = __( 'Home', 'debug-bar' );
35
+ } elseif ( is_attachment() ) {
36
+ $type = __( 'Attachment', 'debug-bar' );
37
+ } elseif ( is_single() ) {
38
+ $type = __( 'Single', 'debug-bar' );
39
+ } elseif ( is_page() ) {
40
+ $type = __( 'Page', 'debug-bar' );
41
+ } elseif ( is_category() ) {
42
+ $type = __( 'Category', 'debug-bar' );
43
+ } elseif ( is_tag() ) {
44
+ $type = __( 'Tag', 'debug-bar' );
45
+ } elseif ( is_author() ) {
46
+ $type = __( 'Author', 'debug-bar' );
47
+ } elseif ( is_date() ) {
48
+ $type = __( 'Date', 'debug-bar' );
49
+ } elseif ( is_archive() ) {
50
+ $type = __( 'Archive', 'debug-bar' );
51
+ } elseif ( is_paged() ) {
52
+ $type = __( 'Paged', 'debug-bar' );
53
+ }
54
+
55
+ if ( ! empty( $type ) ) {
56
+ echo '<h2><span>', __( 'Query Type:', 'debug-bar' ), '</span>', $type, "</h2>\n";
57
+ }
58
+
59
+ if ( ! empty( $template ) ) {
60
+ echo '<h2><span>', __( 'Query Template:', 'debug-bar' ), '</span>', basename( $template ), "</h2>\n";
61
+ }
62
+
63
+ $show_on_front = get_option( 'show_on_front' );
64
+ $page_on_front = get_option( 'page_on_front' );
65
  $page_for_posts = get_option( 'page_for_posts' );
66
 
67
+ echo '<h2><span>', __( 'Show on Front:', 'debug-bar' ), '</span>', $show_on_front, "</h2>\n";
68
  if ( 'page' == $show_on_front ) {
69
+ echo '<h2><span>', __( 'Page for Posts:', 'debug-bar' ), '</span>', $page_for_posts, "</h2>\n";
70
+ echo '<h2><span>', __( 'Page on Front:', 'debug-bar' ), '</span>', $page_on_front, "</h2>\n";
71
  }
72
 
73
+ if ( isset( $post_type_object ) ) {
74
+ echo '<h2><span>', __( 'Post Type:', 'debug-bar' ), '</span>', $post_type_object->labels->singular_name, "</h2>\n";
75
+ }
76
 
77
  echo '<div class="clear"></div>';
78
 
79
+ if ( empty( $wp_query->query ) ) {
80
+ $query = __( 'None', 'debug-bar' );
81
+ } else {
82
  $query = http_build_query( $wp_query->query );
83
+ }
84
 
85
+ echo '<h3>', __( 'Query Arguments:', 'debug-bar' ), '</h3>';
86
  echo '<p>' . esc_html( $query ) . '</p>';
87
 
88
+ if ( ! empty( $wp_query->request ) ) {
89
+ echo '<h3>', __( 'Query SQL:', 'debug-bar' ), '</h3>';
90
  echo '<p>' . esc_html( $wp_query->request ) . '</p>';
91
  }
92
 
93
  if ( ! is_null( $queried_object ) ) {
94
+ echo '<h3>', __( 'Queried Object:', 'debug-bar' ), '</h3>';
95
+ echo '<table class="debug-bar-wp-query-list"><tbody>';
96
+ $this->_recursive_print_kv( $queried_object );
97
+ echo '</tbody></table>';
98
  }
99
  echo '</div>';
100
  }
101
+
102
+ protected function _recursive_print_kv( $kv_array ) {
103
+ foreach ( $kv_array as $key => $value ) {
104
+ if ( is_object( $value ) || is_array( $value ) ) {
105
+ echo '<tr><th>', $key, '</th> <td>&rArr;</td> <td>';
106
+ $this->_recursive_print_kv( $value );
107
+ echo '</td></tr>';
108
+ } else {
109
+ echo '<tr><th>', $key, '</th> <td>&rArr;</td> <td>', $value, '</td></tr>';
110
+ }
111
+ }
112
+ }
113
  }
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
  === Debug Bar ===
2
- Contributors: wordpressdotorg, ryan, westi, koopersmith, duck_, mitchoyoshitaka, dd32
3
  Tags: debug
4
- Tested up to: 4.5
5
- Stable tag: 0.8.4
6
- Requires at least: 3.1
7
 
8
  Adds a debug menu to the admin bar that shows query, cache, and other helpful debugging information.
9
 
@@ -13,14 +13,27 @@ Adds a debug menu to the admin bar that shows query, cache, and other helpful de
13
 
14
  A must for developers!
15
 
16
- When WP_DEBUG is enabled it also tracks PHP Warnings and Notices to make them easier to find.
17
 
18
- When SAVEQUERIES is enabled the mysql queries are tracked and displayed.
 
 
 
 
 
 
19
 
20
  Add a PHP/MySQL console with the [Debug Bar Console plugin](https://wordpress.org/plugins/debug-bar-console/).
21
 
 
 
22
  == Upgrade Notice ==
23
 
 
 
 
 
 
24
  = 0.8.4 =
25
  Updated to avoid incompatibilities with some extensions.
26
 
@@ -81,6 +94,11 @@ Initial Release
81
 
82
  == Changelog ==
83
 
 
 
 
 
 
84
  = 0.8.4 =
85
  Updated to avoid incompatibilities with some extensions.
86
 
1
  === Debug Bar ===
2
+ Contributors: wordpressdotorg, ryan, westi, koopersmith, duck_, mitchoyoshitaka, dd32, jrf, obenland
3
  Tags: debug
4
+ Tested up to: 4.8
5
+ Stable tag: 0.9
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.
9
 
13
 
14
  A must for developers!
15
 
16
+ When `WP_DEBUG` is enabled it also tracks PHP Warnings and Notices to make them easier to find.
17
 
18
+ When `SAVEQUERIES` is enabled the mysql queries are tracked and displayed.
19
+
20
+ To enable these options, add the following code to your `wp-config.php` file:
21
+ `
22
+ define( 'WP_DEBUG', true );
23
+ define( 'SAVEQUERIES', true );
24
+ `
25
 
26
  Add a PHP/MySQL console with the [Debug Bar Console plugin](https://wordpress.org/plugins/debug-bar-console/).
27
 
28
+ There are numerous other add-ons available to get more insight into, for instance, the registered Post Types, Shortcodes, WP Cron, Language file loading, Actions and Filters and so on. Just [search the plugin directory for 'Debug Bar'](https://wordpress.org/plugins/search/debug+bar/).
29
+
30
  == Upgrade Notice ==
31
 
32
+ = 0.9 =
33
+ Added panel navigation to toolbar.
34
+ Improved localization support.
35
+ Security fixes.
36
+
37
  = 0.8.4 =
38
  Updated to avoid incompatibilities with some extensions.
39
 
94
 
95
  == Changelog ==
96
 
97
+ = 0.9 =
98
+ Added panel navigation to toolbar.
99
+ Improved localization support.
100
+ Security fixes.
101
+
102
  = 0.8.4 =
103
  Updated to avoid incompatibilities with some extensions.
104