Debug Bar - Version 0.5

Version Description

New UI Backend rewritten with a class for each panel Many miscellaneous improvements

Download this release

Release Info

Developer koopersmith
Plugin Icon 128x128 Debug Bar
Version 0.5
Comparing to
See all releases

Code changes from version 0.4.1 to 0.5

css/debug-bar.css ADDED
@@ -0,0 +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.warning{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.warning:hover,#wpadminbar #wp-admin-bar-debug-bar.warning.active{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.warning a{color:#fff;text-shadow:0 -1px 0 #700;}#wpadminbar #wp-admin-bar-debug-bar.notice{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.notice:hover,#wpadminbar #wp-admin-bar-debug-bar.notice.active{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.notice a{color:#fff;text-shadow:0 -1px 0 #884000;}#querylist{font-family:Arial,Tahoma,sans-serif;display:none;position:fixed;height:250px;left:0;right:0;bottom:0;background:#fff;z-index:99999;color:#000;line-height:150%!important;text-align:left;}#debug-bar-handle{border-color:#c6c6c6;border-style:solid;border-width:1px 0;height:2px;background:#fff;cursor:n-resize;}#debug-bar-menu{background:#d9d9d9;background:-moz-linear-gradient(bottom,#d7d7d7,#e4e4e4);background:-webkit-gradient(linear,left bottom,left top,from(#d7d7d7),to(#e4e4e4));overflow:hidden;height:24px;text-shadow:0 1px 0 #f4f4f4;}#debug-status{float:right;text-align:right;padding-top:4px;padding-right:15px;color:#bbb;}#debug-status .debug-status-title{color:#999;}#debug-status .debug-status-data{color:#999;font-weight:bold;}#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{clear:left;padding:3px 15px 0;overflow:hidden;list-style:none;margin:0;}#debug-menu-links li{float:left;margin-right:10px;margin-bottom:0!important;}#debug-menu-links li a{outline:none;display:block;line-height:16px;padding:2px 9px 3px;margin-right:0;color:#777!important;text-decoration:none!important;font-weight:bold!important;font-size:12px;-webkit-border-top-right-radius:4px;-webkit-border-top-left-radius:4px;-moz-border-radius-topright:4px;-moz-border-radius-topleft:4px;}#debug-menu-links li a:hover{color:#555!important;background-color:#eee;background-image:-moz-linear-gradient(bottom,#ddd,#eee);background-image:-webkit-gradient(linear,left bottom,left top,from(#ddd),to(#eee));}#debug-menu-links li a.current{background:#fff;color:#222!important;}#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;}#debug-menu-targets{overflow:auto;position:absolute;top:28px;left:0;right:0;bottom:0;}#querylist .debug-menu-target{margin:10px;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 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.dev.css → css/debug-bar.dev.css RENAMED
@@ -1,52 +1,111 @@
1
  /**
2
- * Debug Bar styling
3
  */
4
 
5
- div#wpadminbar li.ab-debug-bar {
6
  float: right;
7
  }
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  #querylist {
10
  font-family: Arial, Tahoma, sans-serif;
11
  display: none;
12
- position: absolute;
13
- top: 50px;
14
- left: 50px;
15
- right: 50px;
 
16
  background: #fff;
17
- padding: 20px;
18
- -moz-box-shadow: 0 0 15px #888;
19
- -webkit-box-shadow: 0 0 15px #888;
20
- box-shadow: 0 0 15px #888;
21
  z-index: 99999;
22
- border: 10px solid #f0f0f0;
23
  color: #000;
24
  line-height: 150% !important;
 
25
  }
26
 
27
- #querylist pre {
28
- font-size: 12px;
29
- padding: 10px;
 
 
 
 
30
  }
31
 
32
- #querylist h1 {
33
- font-family: georgia, times, serif;
34
- text-align: center;
35
- font-size: 24px;
36
- padding: 20px 5px;
37
- background: #eee;
38
- color: #555;
39
- margin: 0;
40
  }
41
 
42
- #querylist div#debug-status {
43
- background: #ccc;
44
- color: #fff;
45
- overflow: hidden;
46
- height: 21px;
47
- font-size: 14px;
48
- font-family: georgia, times, serif;
49
- padding: 7px 15px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  }
51
 
52
  #querylist .left {
@@ -63,12 +122,10 @@ div#wpadminbar li.ab-debug-bar {
63
 
64
  #debug-menu-links {
65
  clear: left;
66
- background: #ccc;
67
- padding: 10px 15px 0;
68
  overflow: hidden;
69
  list-style: none;
70
  margin: 0;
71
- padding: 0 0 0 15px;
72
  }
73
 
74
  #debug-menu-links li {
@@ -80,23 +137,28 @@ div#wpadminbar li.ab-debug-bar {
80
  #debug-menu-links li a {
81
  outline: none;
82
  display: block;
83
- padding: 5px 9px;
 
84
  margin-right: 0;
85
- background: #bbb;
86
- color: #fff !important;
87
  text-decoration: none !important;
88
- font-weight: normal;
89
  font-size: 12px;
90
- color: #555;
91
  -webkit-border-top-right-radius: 4px;
92
  -webkit-border-top-left-radius: 4px;
93
  -moz-border-radius-topright: 4px;
94
  -moz-border-radius-topleft: 4px;
95
  }
96
 
97
- #debug-menu-links li.current a {
98
- background: #fff;
99
  color: #555 !important;
 
 
 
 
 
 
 
100
  }
101
 
102
  #querylist h2 {
@@ -105,7 +167,6 @@ div#wpadminbar li.ab-debug-bar {
105
  border: 1px solid #eee;
106
  padding: 5px 10px 15px;
107
  clear: none;
108
- important;
109
  text-align: center;
110
  font-family: georgia, times, serif;
111
  font-size: 28px;
@@ -171,7 +232,17 @@ div#wpadminbar li.ab-debug-bar {
171
  text-decoration: none !important;
172
  }
173
 
 
 
 
 
 
 
 
 
 
174
  #querylist .debug-menu-target {
 
175
  display: none;
176
  }
177
 
@@ -192,12 +263,14 @@ div#wpadminbar li.ab-debug-bar {
192
  margin: 0 0 10px 0;
193
  }
194
 
195
- #debug-bar-php ol.debug-bar-php-list li.debug-bar-php-warning {
196
- background: red;
 
197
  }
198
 
199
- #debug-bar-php ol.debug-bar-php-list li.debug-bar-php-notice {
200
- background: orange;
 
201
  }
202
 
203
  #debug-bar-deprecated ol.debug-bar-deprecated-list {
@@ -213,14 +286,6 @@ div#wpadminbar li.ab-debug-bar {
213
  background: #f0f0f0;
214
  }
215
 
216
- #wpadminbar li.ab-php-warning {
217
- background: #dd0000;
218
- }
219
-
220
- #wpadminbar li.ab-php-notice {
221
- background: #dd5500;
222
- }
223
-
224
  #debug-bar-wp-query ol.debug-bar-wp-query-list {
225
  padding: 0 !important;
226
  margin: 0 !important;
1
  /**
2
+ * Admin bar styling
3
  */
4
 
5
+ #wpadminbar #wp-admin-bar-debug-bar {
6
  float: right;
7
  }
8
 
9
+ #wpadminbar #wp-admin-bar-debug-bar.active {
10
+ background: #555;
11
+ background: -moz-linear-gradient(bottom, #555, #3e3e3e);
12
+ background: -webkit-gradient(linear, left bottom, left top, from(#555), to(#3e3e3e));
13
+ }
14
+
15
+ #wpadminbar #wp-admin-bar-debug-bar.warning {
16
+ background-color: #f44;
17
+ background-image: -moz-linear-gradient(bottom, #d00, #f44);
18
+ background-image: -webkit-gradient(linear, left bottom, left top, from(#d00), to(#f44));
19
+ }
20
+ #wpadminbar #wp-admin-bar-debug-bar.warning:hover,
21
+ #wpadminbar #wp-admin-bar-debug-bar.warning.active {
22
+ background-color: #d00;
23
+ background-image: -moz-linear-gradient(bottom, #f44, #d00 );
24
+ background-image: -webkit-gradient(linear, left bottom, left top, from(#f44), to(#d00));
25
+ }
26
+ #wpadminbar #wp-admin-bar-debug-bar.warning a {
27
+ color: #fff;
28
+ text-shadow: 0 -1px 0 #700;
29
+ }
30
+
31
+ #wpadminbar #wp-admin-bar-debug-bar.notice {
32
+ background-color: #ff8922;
33
+ background-image: -moz-linear-gradient(bottom, #ee6f00, #ff8922);
34
+ background-image: -webkit-gradient(linear, left bottom, left top, from(#ee6f00), to(#ff8922));
35
+ }
36
+ #wpadminbar #wp-admin-bar-debug-bar.notice:hover,
37
+ #wpadminbar #wp-admin-bar-debug-bar.notice.active {
38
+ background-color: #ee6f00;
39
+ background-image: -moz-linear-gradient(bottom, #ff8922, #ee6f00 );
40
+ background-image: -webkit-gradient(linear, left bottom, left top, from(#ff8922), to(#ee6f00));
41
+ }
42
+ #wpadminbar #wp-admin-bar-debug-bar.notice a {
43
+ color: #fff;
44
+ text-shadow: 0 -1px 0 #884000;
45
+ }
46
+
47
+ /**
48
+ * Debug bar styling
49
+ */
50
+
51
  #querylist {
52
  font-family: Arial, Tahoma, sans-serif;
53
  display: none;
54
+ position: fixed;
55
+ height: 250px;
56
+ left: 0;
57
+ right: 0;
58
+ bottom: 0;
59
  background: #fff;
 
 
 
 
60
  z-index: 99999;
 
61
  color: #000;
62
  line-height: 150% !important;
63
+ text-align: left;
64
  }
65
 
66
+ #debug-bar-handle {
67
+ border-color: #c6c6c6;
68
+ border-style: solid;
69
+ border-width: 1px 0;
70
+ height: 2px;
71
+ background: #fff;
72
+ cursor: n-resize;
73
  }
74
 
75
+ #debug-bar-menu {
76
+ background: #d9d9d9; /* fallback color */
77
+ background:-moz-linear-gradient(bottom, #d7d7d7, #e4e4e4);
78
+ background:-webkit-gradient(linear, left bottom, left top, from(#d7d7d7), to(#e4e4e4));
79
+ overflow: hidden;
80
+ height: 24px;
81
+ text-shadow: 0 1px 0 #f4f4f4;
 
82
  }
83
 
84
+ #debug-status {
85
+ float: right;
86
+ text-align: right;
87
+ padding-top: 4px;
88
+ padding-right: 15px;
89
+ color: #bbb;
90
+ }
91
+ #debug-status .debug-status-title {
92
+ color: #999;
93
+ }
94
+ #debug-status .debug-status-data {
95
+ color: #999;
96
+ font-weight: bold;
97
+ }
98
+ #debug-status #debug-status-warning {
99
+ font-weight: bold;
100
+ color: red;
101
+ }
102
+ #debug-status #debug-status-site {
103
+ font-weight: bold;
104
+ }
105
+
106
+ #querylist pre {
107
+ font-size: 12px;
108
+ padding: 10px;
109
  }
110
 
111
  #querylist .left {
122
 
123
  #debug-menu-links {
124
  clear: left;
125
+ padding: 3px 15px 0;
 
126
  overflow: hidden;
127
  list-style: none;
128
  margin: 0;
 
129
  }
130
 
131
  #debug-menu-links li {
137
  #debug-menu-links li a {
138
  outline: none;
139
  display: block;
140
+ line-height: 16px;
141
+ padding: 2px 9px 3px;
142
  margin-right: 0;
143
+ color: #777 !important;
 
144
  text-decoration: none !important;
145
+ font-weight: bold !important;
146
  font-size: 12px;
 
147
  -webkit-border-top-right-radius: 4px;
148
  -webkit-border-top-left-radius: 4px;
149
  -moz-border-radius-topright: 4px;
150
  -moz-border-radius-topleft: 4px;
151
  }
152
 
153
+ #debug-menu-links li a:hover {
 
154
  color: #555 !important;
155
+ background-color: #eee;
156
+ background-image: -moz-linear-gradient(bottom, #ddd, #eee);
157
+ background-image: -webkit-gradient(linear, left bottom, left top, from(#ddd), to(#eee));
158
+ }
159
+ #debug-menu-links li a.current {
160
+ background: #fff;
161
+ color: #222 !important;
162
  }
163
 
164
  #querylist h2 {
167
  border: 1px solid #eee;
168
  padding: 5px 10px 15px;
169
  clear: none;
 
170
  text-align: center;
171
  font-family: georgia, times, serif;
172
  font-size: 28px;
232
  text-decoration: none !important;
233
  }
234
 
235
+ #debug-menu-targets {
236
+ overflow: auto;
237
+ position: absolute;
238
+ top: 28px;
239
+ left: 0;
240
+ right: 0;
241
+ bottom: 0;
242
+ }
243
+
244
  #querylist .debug-menu-target {
245
+ margin: 10px;
246
  display: none;
247
  }
248
 
263
  margin: 0 0 10px 0;
264
  }
265
 
266
+ #debug-bar-php .debug-bar-php-warning {
267
+ background-color: #ffebe8;
268
+ border: 1px solid #c00;
269
  }
270
 
271
+ #debug-bar-php .debug-bar-php-notice {
272
+ background-color: #ffffe0;
273
+ border: 1px solid #e6db55;
274
  }
275
 
276
  #debug-bar-deprecated ol.debug-bar-deprecated-list {
286
  background: #f0f0f0;
287
  }
288
 
 
 
 
 
 
 
 
 
289
  #debug-bar-wp-query ol.debug-bar-wp-query-list {
290
  padding: 0 !important;
291
  margin: 0 !important;
debug-bar.css DELETED
@@ -1 +0,0 @@
1
- div#wpadminbar li.ab-debug-bar{float:right;}#querylist{font-family:Arial,Tahoma,sans-serif;display:none;position:absolute;top:50px;left:50px;right:50px;background:#fff;padding:20px;-moz-box-shadow:0 0 15px #888;-webkit-box-shadow:0 0 15px #888;box-shadow:0 0 15px #888;z-index:99999;border:10px solid #f0f0f0;color:#000;line-height:150%!important;}#querylist pre{font-size:12px;padding:10px;}#querylist h1{font-family:georgia,times,serif;text-align:center;font-size:24px;padding:20px 5px;background:#eee;color:#555;margin:0;}#querylist div#debug-status{background:#ccc;color:#fff;overflow:hidden;height:21px;font-size:14px;font-family:georgia,times,serif;padding:7px 15px;}#querylist .left{float:left;}#querylist .right{float:right;}#querylist h1,#querylist h2,#querylist h3{font-weight:normal;}#debug-menu-links{clear:left;background:#ccc;padding:10px 15px 0;overflow:hidden;list-style:none;margin:0;padding:0 0 0 15px;}#debug-menu-links li{float:left;margin-right:10px;margin-bottom:0!important;}#debug-menu-links li a{outline:none;display:block;padding:5px 9px;margin-right:0;background:#bbb;color:#fff!important;text-decoration:none!important;font-weight:normal;font-size:12px;color:#555;-webkit-border-top-right-radius:4px;-webkit-border-top-left-radius:4px;-moz-border-radius-topright:4px;-moz-border-radius-topleft:4px;}#debug-menu-links li.current a{background:#fff;color:#555!important;}#querylist h2{float:left;min-width:150px;border:1px solid #eee;padding:5px 10px 15px;clear:none;important;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{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 ol.debug-bar-php-list li.debug-bar-php-warning{background:red;}#debug-bar-php ol.debug-bar-php-list li.debug-bar-php-notice{background:orange;}#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;}#wpadminbar li.ab-php-warning{background:#d00;}#wpadminbar li.ab-php-notice{background:#d50;}#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 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.dev.js DELETED
@@ -1,66 +0,0 @@
1
- (function(){
2
-
3
- var addEvent, preventDefault, toggleQueryList, clickDebugLink;
4
-
5
- addEvent = function( obj, type, fn ) {
6
- if (obj.addEventListener)
7
- obj.addEventListener(type, fn, false);
8
- else if (obj.attachEvent)
9
- obj.attachEvent('on' + type, function() { return fn.call(obj, window.event);});
10
- };
11
-
12
- preventDefault = function( e ) {
13
- // IE doesn't support preventDefault, and does support returnValue
14
- if ( e.preventDefault )
15
- e.preventDefault();
16
- e.returnValue = false;
17
- }
18
-
19
- toggleQueryList = function( e ) {
20
- var querylist = document.getElementById( 'querylist' );
21
-
22
- if( querylist && querylist.style.display == 'block' ) {
23
- querylist.style.display='none';
24
- } else {
25
- querylist.style.display='block';
26
- }
27
-
28
- preventDefault( e );
29
- };
30
-
31
- clickDebugLink = function( e ) {
32
- var sectionDivs, i, j,
33
- obj = e.target || e.srcElement;
34
-
35
- if ( ! obj.className || -1 == obj.className.indexOf('debug-menu-link') )
36
- return;
37
-
38
- sectionDivs = document.getElementById( 'debug-menu-targets' ).childNodes;
39
-
40
- for ( i = 0; i < sectionDivs.length; i++ ) {
41
- if ( 1 != sectionDivs[i].nodeType ) {
42
- continue;
43
- }
44
- sectionDivs[i].style.display = 'none';
45
- }
46
- document.getElementById( obj.href.substr( obj.href.indexOf( '#' ) + 1 ) ).style.display = 'block';
47
-
48
- for ( j = 0; j < obj.parentNode.parentNode.childNodes.length; j++ ) {
49
- if ( 1 != obj.parentNode.parentNode.childNodes[j].nodeType ) {
50
- continue;
51
- }
52
- obj.parentNode.parentNode.childNodes[j].removeAttribute( 'class' );
53
- }
54
- obj.parentNode.setAttribute( 'class', 'current' );
55
-
56
- preventDefault( e );
57
- };
58
-
59
- addEvent(window, 'load', function() {
60
- var adminBarLink = document.getElementById('wp-admin-bar-queries'),
61
- adminBarTabs = document.getElementById('debug-menu-links');
62
- addEvent( adminBarLink, 'click', toggleQueryList );
63
- addEvent( adminBarTabs, 'click', clickDebugLink );
64
- });
65
-
66
- })();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
debug-bar.js DELETED
@@ -1 +0,0 @@
1
- (function(){var d,b,a,c;d=function(g,f,e){if(g.addEventListener){g.addEventListener(f,e,false)}else{if(g.attachEvent){g.attachEvent("on"+f,function(){return e.call(g,window.event)})}}};b=function(f){if(f.preventDefault){f.preventDefault()}f.returnValue=false};a=function(g){var f=document.getElementById("querylist");if(f&&f.style.display=="block"){f.style.display="none"}else{f.style.display="block"}b(g)};c=function(l){var h,g,f,k=l.target||l.srcElement;if(!k.className||-1==k.className.indexOf("debug-menu-link")){return}h=document.getElementById("debug-menu-targets").childNodes;for(g=0;g<h.length;g++){if(1!=h[g].nodeType){continue}h[g].style.display="none"}document.getElementById(k.href.substr(k.href.indexOf("#")+1)).style.display="block";for(f=0;f<k.parentNode.parentNode.childNodes.length;f++){if(1!=k.parentNode.parentNode.childNodes[f].nodeType){continue}k.parentNode.parentNode.childNodes[f].removeAttribute("class")}k.parentNode.setAttribute("class","current");b(l)};d(window,"load",function(){var e=document.getElementById("wp-admin-bar-queries"),f=document.getElementById("debug-menu-links");d(e,"click",a);d(f,"click",c)})})();
 
debug-bar.php CHANGED
@@ -4,7 +4,7 @@
4
  Plugin URI: http://wordpress.org/extend/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.4.1
8
  Author URI: http://wordpress.org/
9
  */
10
 
@@ -17,415 +17,192 @@
17
  * They are not used when a regular user is logged in.
18
  */
19
 
20
- function debug_bar_menu() {
21
- global $wp_admin_bar, $wpdb;
22
 
23
- if ( ! is_super_admin() || ! is_admin_bar_showing() )
24
- return;
25
-
26
- $class = 'ab-debug-bar';
27
- if ( count( $GLOBALS['_debug_bar_warnings'] ) )
28
- $class .= ' ab-php-warning';
29
- elseif ( count( $GLOBALS['_debug_bar_notices'] ) )
30
- $class .= ' ab-php-notice';
31
-
32
- /* Add the main siteadmin menu item */
33
- $wp_admin_bar->add_menu( array( 'id' => 'queries', 'title' => __('Debug'), 'meta' => array( 'class' => $class ) ) );
34
- }
35
- add_action( 'admin_bar_menu', 'debug_bar_menu', 1000 );
36
-
37
- function debug_bar_menu_init() {
38
- if ( ! is_super_admin() || ! is_admin_bar_showing() )
39
- return;
40
-
41
- $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '.dev' : '';
42
- wp_enqueue_style( 'admin-bar-debug', plugins_url("debug-bar/debug-bar$suffix.css"), array(), '20110112' );
43
- wp_enqueue_script( 'admin-bar-debug', plugins_url("debug-bar/debug-bar$suffix.js"), array(), '20110112' );
44
-
45
- // Silence E_NOTICE for deprecated usage.
46
- foreach ( array( 'function', 'file', 'argument' ) as $item )
47
- add_filter( "deprecated_{$item}_trigger_error", '__return_false' );
48
-
49
- }
50
- add_action('admin_bar_init', 'debug_bar_menu_init');
51
-
52
- function debug_bar_list() {
53
- global $wpdb, $wp_object_cache;
54
-
55
- if ( ! is_super_admin() || ! is_admin_bar_showing() )
56
- return;
57
-
58
- $debugs = array();
59
-
60
- if ( defined('SAVEQUERIES') && SAVEQUERIES )
61
- $debugs['wpdb'] = array( __('Queries'), 'debug_bar_queries' );
62
-
63
- if ( is_object($wp_object_cache) && method_exists($wp_object_cache, 'stats') )
64
- $debugs['object-cache'] = array( __('Object Cache'), 'debug_bar_object_cache' );
65
-
66
- if ( WP_DEBUG ) {
67
- $debugs['php'] = array( __('Notices / Warnings'), 'debug_bar_php' );
68
  }
69
 
70
- $debugs['deprecated'] = array( __('Deprecated'), 'debug_bar_deprecated' );
71
- $debugs['wp_query'] = array( __( 'WP Query' ), 'debug_bar_wp_query' );
72
-
73
- if ( ! is_admin() )
74
- $debugs['request'] = array( __( 'Request' ), 'debug_bar_request' );
75
-
76
- $debugs = apply_filters( 'debug_bar_list', $debugs );
77
-
78
- if ( empty($debugs) )
79
- return;
80
-
81
- ?>
82
- <div align='left' id='querylist'>
83
-
84
- <h1><?php printf( __('Debugging blog #%d on %s'), $GLOBALS['blog_id'], php_uname( 'n' ) ); ?></h1>
85
- <div id="debug-status">
86
- <p class="left"></p>
87
- <p class="right"><?php printf( __('PHP Version: %1$s, DB Version: %2$s'), phpversion(), $wpdb->db_version() ); ?></p>
88
- </div>
89
- <ul id="debug-menu-links">
90
-
91
- <?php $current = ' class="current"'; foreach ( $debugs as $debug => $debug_output ) : ?>
92
-
93
- <li <?php echo $current; ?>><a
94
- id="debug-menu-link-<?php echo $debug; ?>"
95
- class="debug-menu-link"
96
- href="#debug-menu-target-<?php echo $debug; ?>">
97
- <?php echo $debug_output[0] ?></a></li>
98
-
99
- <?php $current = ''; endforeach; ?>
100
-
101
- </ul>
102
-
103
- <div id="debug-menu-targets"><?php $current = ' style="display: block"'; foreach ( $debugs as $debug => $debug_output ) : ?>
104
-
105
- <div id="debug-menu-target-<?php echo $debug; ?>"
106
- class="debug-menu-target" <?php echo $current; ?>><?php echo str_replace( '&nbsp;', '', call_user_func( $debug_output[1] ) ); ?>
107
- </div>
108
-
109
- <?php $current = ''; endforeach; ?></div>
110
-
111
- <?php do_action( 'debug_bar' ); ?></div>
112
-
113
- <?php
114
- }
115
- add_action( 'wp_after_admin_bar_render', 'debug_bar_list' );
116
-
117
- function debug_bar_queries() {
118
- global $wpdb;
119
-
120
- $queries = array();
121
- $out = '';
122
- $total_time = 0;
123
-
124
- if ( !empty($wpdb->queries) ) {
125
- $show_many = isset($_GET['debug_queries']);
126
-
127
- if ( $wpdb->num_queries > 500 && !$show_many )
128
- $out .= "<p>" . sprintf( __('There are too many queries to show easily! <a href="%s">Show them anyway</a>'), add_query_arg( 'debug_queries', 'true' ) ) . "</p>";
129
-
130
- $out .= '<ol id="wpd-queries">';
131
- $first_query = 0;
132
- $counter = 0;
133
-
134
- foreach ( $wpdb->queries as $q ) {
135
- list($query, $elapsed, $debug) = $q;
136
 
137
- $total_time += $elapsed;
 
 
138
 
139
- if ( !$show_many && ++$counter > 500 )
140
- continue;
141
-
142
- $query = nl2br(esc_html($query));
143
-
144
- $out .= "<li>$query<br/><div class='qdebug'>$debug <span>#{$counter} (" . number_format(sprintf('%0.1f', $elapsed * 1000), 1, '.', ',') . "ms)</span></div></li>\n";
145
- }
146
- $out .= '</ol>';
147
- } else {
148
- $out .= "<p><strong>" . __('There are no queries on this page.') . "</strong></p>";
149
  }
150
 
151
- $query_count = '<h2><span>Total Queries:</span>' . number_format( $wpdb->num_queries ) . "</h2>\n";
152
- $query_time = '<h2><span>Total query time:</span>' . number_format(sprintf('%0.1f', $total_time * 1000), 1) . "ms</h2>\n";
153
- $memory_usage = '<h2><span>Peak Memory Used:</span>' . number_format( memory_get_peak_usage( ) ) . " bytes</h2>\n";
154
-
155
- $out = $query_count . $query_time . $memory_usage . $out;
156
-
157
- return $out;
158
- }
159
-
160
- function debug_bar_object_cache() {
161
- global $wp_object_cache;
162
- ob_start();
163
- echo "<div id='object-cache-stats'>";
164
- $wp_object_cache->stats();
165
- echo "</div>";
166
- $out = ob_get_contents();
167
- ob_end_clean();
168
-
169
- return $out;
170
- }
171
-
172
 
173
- function debug_bar_php() {
174
- global $_debug_bar_notices, $_debug_bar_warnings;
175
- echo "<div id='debug-bar-php'>";
176
- echo '<h2><span>Total Warnings:</span>' . number_format( count( $_debug_bar_warnings ) ) . "</h2>\n";
177
- echo '<h2><span>Total Notices:</span>' . number_format( count( $_debug_bar_notices ) ) . "</h2>\n";
178
- if ( count( $_debug_bar_warnings ) ) {
179
- echo '<ol class="debug-bar-php-list">';
180
- foreach ( $_debug_bar_warnings as $location_message) {
181
- list( $location, $message) = $location_message;
182
- echo "<li class='debug-bar-php-warning'>WARNING: ".str_replace(ABSPATH, '', $location) . ' - ' . strip_tags($message). "</li>";
183
- }
184
- echo '</ol>';
185
- }
186
- if ( count( $_debug_bar_notices ) ) {
187
- echo '<ol class="debug-bar-php-list">';
188
- foreach ( $_debug_bar_notices as $location_message) {
189
- list( $location, $message) = $location_message;
190
- echo "<li class='debug-bar-php-notice'>NOTICE: ".str_replace(ABSPATH, '', $location) . ' - ' . strip_tags($message). "</li>";
191
- }
192
- echo '</ol>';
193
  }
194
- echo "</div>";
195
- }
196
-
197
- function debug_bar_deprecated() {
198
- global $_debug_bar_deprecated_functions, $_debug_bar_deprecated_files, $_debug_bar_deprecated_arguments;
199
- echo "<div id='debug-bar-deprecated'>";
200
- echo '<h2><span>Total Functions:</span>' . number_format( count( $_debug_bar_deprecated_functions ) ) . "</h2>\n";
201
- echo '<h2><span>Total Arguments:</span>' . number_format( count( $_debug_bar_deprecated_arguments ) ) . "</h2>\n";
202
- echo '<h2><span>Total Files:</span>' . number_format( count( $_debug_bar_deprecated_files ) ) . "</h2>\n";
203
- if ( count( $_debug_bar_deprecated_functions ) ) {
204
- echo '<ol class="debug-bar-deprecated-list">';
205
- foreach ( $_debug_bar_deprecated_functions as $location => $message)
206
- echo "<li class='debug-bar-deprecated-function'>".str_replace(ABSPATH, '', $location) . ' - ' . strip_tags($message). "</li>";
207
- echo '</ol>';
208
- }
209
- if ( count( $_debug_bar_deprecated_files ) ) {
210
- echo '<ol class="debug-bar-deprecated-list">';
211
- foreach ( $_debug_bar_deprecated_files as $location => $message)
212
- echo "<li class='debug-bar-deprecated-function'>".str_replace(ABSPATH, '', $location) . ' - ' . strip_tags($message). "</li>";
213
- echo '</ol>';
214
- }
215
- if ( count( $_debug_bar_deprecated_arguments ) ) {
216
- echo '<ol class="debug-bar-deprecated-list">';
217
- foreach ( $_debug_bar_deprecated_arguments as $location => $message)
218
- echo "<li class='debug-bar-deprecated-function'>".str_replace(ABSPATH, '', $location) . ' - ' . strip_tags($message). "</li>";
219
- echo '</ol>';
220
- }
221
- echo "</div>";
222
- }
223
 
224
- function debug_bar_wp_query() {
225
- global $template, $wp_query;
226
-
227
- echo "<div id='debug-bar-wp-query'>";
228
- echo '<h2><span>Queried Object ID:</span>' . get_queried_object_id() . "</h2>\n";
229
-
230
- // Determine the query type. Follows the template loader order.
231
- $type = '';
232
- if ( is_404() )
233
- $type = '404';
234
- elseif ( is_search() )
235
- $type = 'Search';
236
- elseif ( is_tax() )
237
- $type = 'Taxonomy';
238
- elseif ( is_front_page() )
239
- $type = 'Front Page';
240
- elseif ( is_home() )
241
- $type = 'Home';
242
- elseif ( is_attachment() )
243
- $type = 'Attachment';
244
- elseif ( is_single() )
245
- $type = 'Single';
246
- elseif ( is_page() )
247
- $type = 'Page';
248
- elseif ( is_category() )
249
- $type = 'Category';
250
- elseif ( is_tag() )
251
- $type = 'Tag';
252
- elseif ( is_author() )
253
- $type = 'Author';
254
- elseif ( is_date() )
255
- $type = 'Date';
256
- elseif ( is_archive() )
257
- $type = 'Archive';
258
- elseif ( is_paged() )
259
- $type = 'Paged';
260
-
261
- if ( !empty($type) )
262
- echo '<h2><span>Query Type:</span>' . $type . "</h2>\n";
263
-
264
- if ( !empty($template) )
265
- echo '<h2><span>Query Template:</span>' . basename($template) . "</h2>\n";
266
-
267
- $show_on_front = get_option( 'show_on_front' );
268
- $page_on_front = get_option( 'page_on_front' );
269
- $page_for_posts = get_option( 'page_for_posts' );
270
-
271
- echo '<h2><span>Show on Front:</span>' . $show_on_front . "</h2>\n";
272
- if ( 'page' == $show_on_front ) {
273
- echo '<h2><span>Page for Posts:</span>' . $page_for_posts . "</h2>\n";
274
- echo '<h2><span>Page on Front:</span>' . $page_on_front . "</h2>\n";
275
  }
276
 
277
- echo '<div class="clear"></div>';
 
278
 
279
- if ( empty($wp_query->query) )
280
- $query = 'None';
281
- else
282
- $query = http_build_query( $wp_query->query );
283
 
284
- echo '<h3>Query Arguments:</h3>';
285
- echo '<p>' . esc_html( $query ) . '</p>';
 
286
 
287
- if ( ! empty($wp_query->request) ) {
288
- echo '<h3>Query SQL:</h3>';
289
- echo '<p>' . esc_html( $wp_query->request ) . '</p>';
290
  }
291
 
292
- $object = get_queried_object();
293
- if ( ! is_null( $object ) ) {
294
- echo '<h3>Queried Object:</h3>';
295
- echo '<ol class="debug-bar-wp-query-list">';
296
- foreach ($object as $key => $value) {
297
- echo '<li>' . $key . ' => ' . $value . '</li>';
 
 
 
 
 
 
298
  }
299
- echo '</ol>';
300
- }
301
- echo '</div>';
302
- }
303
-
304
- function debug_bar_request() {
305
- global $wp;
306
-
307
- echo "<div id='debug-bar-request'>";
308
-
309
- if ( empty($wp->request) )
310
- $request = 'None';
311
- else
312
- $request = $wp->request;
313
 
314
- echo '<h3>Request:</h3>';
315
- echo '<p>' . esc_html( $request ) . '</p>';
316
 
317
- if ( empty($wp->query_string) )
318
- $query_string = 'None';
319
- else
320
- $query_string = $wp->query_string;
 
321
 
322
- echo '<h3>Query String:</h3>';
323
- echo '<p>' . esc_html( $query_string ) . '</p>';
 
 
 
 
 
 
 
 
 
324
 
325
- if ( empty($wp->matched_rule) )
326
- $matched_rule = 'None';
327
- else
328
- $matched_rule = $wp->matched_rule;
329
 
330
- echo '<h3>Matched Rewrite Rule:</h3>';
331
- echo '<p>' . esc_html( $matched_rule ) . '</p>';
332
 
333
- if ( empty($wp->matched_query) )
334
- $matched_query = 'None';
335
- else
336
- $matched_query = $wp->matched_query;
 
 
 
337
 
338
- echo '<h3>Matched Rewrite Query:</h3>';
339
- echo '<p>' . esc_html( $matched_query ) . '</p>';
340
 
341
- echo '</div>';
342
- }
343
 
344
- function debug_bar_error_handler( $type, $message, $file, $line ) {
345
- global $_debug_bar_real_error_handler, $_debug_bar_notices, $_debug_bar_warnings;
346
-
347
- $_key = md5( $file . ':' . $line . ':' . $message );
348
-
349
- switch ( $type ) {
350
- case E_WARNING :
351
- case E_USER_WARNING :
352
- $_debug_bar_warnings[$_key] = array( $file.':'.$line, $message );
353
- break;
354
- case E_NOTICE :
355
- case E_USER_NOTICE :
356
- $_debug_bar_notices[$_key] = array( $file.':'.$line, $message );
357
- break;
358
- case E_STRICT :
359
- // TODO
360
- break;
361
- case E_DEPRECATED :
362
- case E_USER_DEPRECATED :
363
- // TODO
364
- break;
365
- case 0 :
366
- // TODO
367
- break;
368
- }
369
 
370
- if ( null != $_debug_bar_real_error_handler )
371
- return call_user_func( $_debug_bar_real_error_handler, $type, $message, $file, $line );
372
- else
373
- return false;
374
- }
375
- if ( WP_DEBUG ) {
376
- $GLOBALS['_debug_bar_real_error_handler'] = set_error_handler('debug_bar_error_handler');
377
- $GLOBALS['_debug_bar_warnings'] = $GLOBALS['_debug_bar_notices'] = array();
378
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
379
 
380
- // Alot of this code is massaged from nacin's log-deprecated-notices plugin
381
- $_debug_bar_deprecated_functions = $_debug_bar_deprecated_files = $_debug_bar_deprecated_arguments = array();
382
- function debug_bar_deprecated_function_run($function, $replacement, $version) {
383
- global $_debug_bar_deprecated_functions;
384
- $backtrace = debug_backtrace();
385
- $bt = 4;
386
- // Check if we're a hook callback.
387
- if ( ! isset( $backtrace[4]['file'] ) && 'call_user_func_array' == $backtrace[5]['function'] ) {
388
- $bt = 6;
389
  }
390
- $file = $backtrace[ $bt ]['file'];
391
- $line = $backtrace[ $bt ]['line'];
392
- if ( ! is_null($replacement) )
393
- $message = sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $function, $version, $replacement );
394
- else
395
- $message = sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $function, $version );
396
-
397
- $_debug_bar_deprecated_functions[$file.':'.$line] = $message;
398
- }
399
- add_action( 'deprecated_function_run', 'debug_bar_deprecated_function_run', 10, 3 );
400
-
401
- function debug_bar_deprecated_file_included( $old_file, $replacement, $version, $message ) {
402
- global $_debug_bar_deprecated_files;
403
- $backtrace = debug_backtrace();
404
- $file = $backtrace[4]['file'];
405
- $file_abs = str_replace(ABSPATH, '', $file);
406
- $line = $backtrace[4]['line'];
407
- $message = empty( $message ) ? '' : ' ' . $message;
408
- if ( ! is_null( $replacement ) )
409
- $message = sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $file_abs, $version, $replacement ) . $message;
410
- else
411
- $message = sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $file_abs, $version ) . $message;
412
-
413
- $_debug_bar_deprecated_files[$file.':'.$line] = $message;
414
  }
415
- add_action( 'deprecated_file_included', 'debug_bar_deprecated_file_included', 10, 4 );
416
-
417
- function debug_bar_deprecated_argument_run( $function, $message, $version) {
418
- global $_debug_bar_deprecated_arguments;
419
- $backtrace = debug_backtrace();
420
- $bt = 4;
421
- if ( ! isset( $backtrace[4]['file'] ) && 'call_user_func_array' == $backtrace[5]['function'] ) {
422
- $bt = 6;
423
- }
424
- $file = $backtrace[ $bt ]['file'];
425
- $line = $backtrace[ $bt ]['line'];
426
 
427
- $_debug_bar_deprecated_arguments[$file.':'.$line] = $message;
428
- }
429
- add_action( 'deprecated_argument_run', 'debug_bar_deprecated_argument_run', 10, 3 );
430
 
431
- ?>
4
  Plugin URI: http://wordpress.org/extend/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.5
8
  Author URI: http://wordpress.org/
9
  */
10
 
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 Debug_Bar() {
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 init() {
30
+ if ( ! is_super_admin() || ! is_admin_bar_showing() )
31
+ return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
+ add_action( 'admin_bar_menu', array( &$this, 'admin_bar_menu' ), 1000 );
34
+ add_action( 'wp_after_admin_bar_render', array( &$this, 'render' ) );
35
+ add_action( 'wp_head', array( &$this, 'ensure_ajaxurl' ), 1 );
36
 
37
+ $this->requirements();
38
+ $this->enqueue();
39
+ $this->init_panels();
 
 
 
 
 
 
 
40
  }
41
 
42
+ function init_ajax() {
43
+ if ( ! is_super_admin() )
44
+ return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
 
46
+ $this->requirements();
47
+ $this->init_panels();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
 
50
+ function requirements() {
51
+ $recs = array( 'panel', 'php', 'queries', 'request', 'wp-query', 'object-cache', 'deprecated' );
52
+ foreach ( $recs as $rec )
53
+ require_once "panels/class-debug-bar-$rec.php";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  }
55
 
56
+ function enqueue() {
57
+ $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '.dev' : '';
58
 
59
+ $url = plugin_dir_url( __FILE__ );
 
 
 
60
 
61
+ wp_enqueue_style( 'debug-bar', "{$url}css/debug-bar$suffix.css", array(), '20110114' );
62
+ wp_enqueue_script( 'debug-bar-ui-dockable', "{$url}js/ui-dockable$suffix.js", array('jquery-ui-mouse'), '20110113' );
63
+ wp_enqueue_script( 'debug-bar', "{$url}js/debug-bar$suffix.js", array('jquery', 'debug-bar-ui-dockable'), '20110114' );
64
 
65
+ do_action('debug_bar_enqueue_scripts');
 
 
66
  }
67
 
68
+ function init_panels() {
69
+ $classes = array(
70
+ 'Debug_Bar_PHP',
71
+ 'Debug_Bar_WP_Query',
72
+ 'Debug_Bar_Queries',
73
+ 'Debug_Bar_Deprecated',
74
+ 'Debug_Bar_Request',
75
+ 'Debug_Bar_Object_Cache',
76
+ );
77
+
78
+ foreach ( $classes as $class ) {
79
+ $this->panels[] = new $class;
80
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
 
82
+ $this->panels = apply_filters( 'debug_bar_panels', $this->panels );
 
83
 
84
+ foreach ( $this->panels as $panel_key => $panel ) {
85
+ if ( ! $panel->is_visible() )
86
+ unset( $this->panels[ $panel_key ] );
87
+ }
88
+ }
89
 
90
+ function ensure_ajaxurl() {
91
+ if ( is_admin() )
92
+ return;
93
+ ?>
94
+ <script type="text/javascript">
95
+ //<![CDATA[
96
+ var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>';
97
+ //]]>
98
+ </script>
99
+ <?php
100
+ }
101
 
102
+ function admin_bar_menu() {
103
+ global $wp_admin_bar;
 
 
104
 
105
+ $classes = apply_filters( 'debug_bar_classes', array() );
106
+ $classes = implode( " ", $classes );
107
 
108
+ /* Add the main siteadmin menu item */
109
+ $wp_admin_bar->add_menu( array(
110
+ 'id' => 'debug-bar',
111
+ 'title' => __('Debug'),
112
+ 'meta' => array( 'class' => $classes )
113
+ ) );
114
+ }
115
 
116
+ function render() {
117
+ global $wpdb;
118
 
119
+ if ( empty( $this->panels ) )
120
+ return;
121
 
122
+ foreach ( $this->panels as $panel_key => $panel ) {
123
+ $panel->prerender();
124
+ if ( ! $panel->is_visible() )
125
+ unset( $this->panels[ $panel_key ] );
126
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
 
128
+ ?>
129
+ <div id='querylist'>
130
+
131
+ <div id='debug-bar-handle'></div>
132
+ <div id='debug-bar-menu'>
133
+ <div id="debug-status">
134
+ <?php //@todo: Add a links to information about WP_DEBUG, PHP version, MySQL version, and Peak Memory.
135
+ $statuses = array();
136
+ if ( ! WP_DEBUG )
137
+ $statuses[] = array( 'warning', __('WP_DEBUG OFF'), '' );
138
+ $statuses[] = array( 'site', sprintf( __('Site #%d on %s'), $GLOBALS['blog_id'], php_uname( 'n' ) ), '' );
139
+ $statuses[] = array( 'php', __('PHP'), phpversion() );
140
+ $statuses[] = array( 'db', __('DB'), $wpdb->db_version() );
141
+ $statuses[] = array( 'memory', __('Mem.'), sprintf( __('%s bytes'), number_format( memory_get_peak_usage() ) ) );
142
+
143
+ $statuses = apply_filters( 'debug_bar_statuses', $statuses );
144
+
145
+ $status_html = array();
146
+ foreach ( $statuses as $status ) {
147
+ list( $slug, $title, $data ) = $status;
148
+
149
+ $html = "<span id='debug-status-$slug' class='debug-status'>";
150
+ $html .= "<span class='debug-status-title'>$title</span>";
151
+ if ( ! empty( $data ) )
152
+ $html .= " <span class='debug-status-data'>$data</span>";
153
+ $html .= '</span>';
154
+ $status_html[] = $html;
155
+ }
156
+
157
+ echo implode( ' | ', $status_html );
158
+
159
+ ?>
160
+ </div>
161
+ <ul id="debug-menu-links">
162
+
163
+ <?php
164
+ $current = ' current';
165
+ foreach ( $this->panels as $panel ) :
166
+ $class = get_class( $panel );
167
+ ?>
168
+ <li><a
169
+ id="debug-menu-link-<?php echo esc_attr( $class ); ?>"
170
+ class="debug-menu-link<?php echo $current; ?>"
171
+ href="#debug-menu-target-<?php echo esc_attr( $class ); ?>">
172
+ <?php
173
+ // Not escaping html here, so panels can use html in the title.
174
+ echo $panel->title();
175
+ ?>
176
+ </a></li>
177
+ <?php
178
+ $current = '';
179
+ endforeach; ?>
180
+
181
+ </ul>
182
+ </div>
183
+
184
+ <div id="debug-menu-targets"><?php
185
+ $current = ' style="display: block"';
186
+ foreach ( $this->panels as $panel ) :
187
+ $class = get_class( $panel ); ?>
188
+
189
+ <div id="debug-menu-target-<?php echo $class; ?>" class="debug-menu-target" <?php echo $current; ?>>
190
+ <?php $panel->render(); ?>
191
+ <?php // echo str_replace( '&nbsp;', '', $panel->run() ); ?>
192
+ </div>
193
+
194
+ <?php
195
+ $current = '';
196
+ endforeach;
197
+ ?>
198
+ </div>
199
 
200
+ <?php do_action( 'debug_bar' ); ?>
201
+ </div>
202
+ <?php
 
 
 
 
 
 
203
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
204
  }
 
 
 
 
 
 
 
 
 
 
 
205
 
206
+ $GLOBALS['debug_bar'] = new Debug_Bar();
 
 
207
 
208
+ ?>
js/debug-bar.dev.js ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function($) {
2
+
3
+ var debugBar, bounds, wpDebugBar, $win, $body;
4
+
5
+ bounds = {
6
+ adminBarHeight: 0,
7
+ minHeight: 0,
8
+ marginBottom: 0,
9
+
10
+ inUpper: function(){
11
+ return debugBar.offset().top - $win.scrollTop() >= bounds.adminBarHeight;
12
+ },
13
+ inLower: function(){
14
+ return debugBar.outerHeight() >= bounds.minHeight
15
+ && $win.height() >= bounds.minHeight;
16
+ },
17
+ fix: function(){
18
+ if ( ! bounds.inUpper() )
19
+ debugBar.height( $win.height() - bounds.adminBarHeight );
20
+ if ( ! bounds.inLower() )
21
+ debugBar.height( bounds.minHeight );
22
+ $body.css( 'margin-bottom', debugBar.height() + bounds.marginBottom );
23
+ },
24
+ restore: function(){
25
+ $body.css( 'margin-bottom', bounds.marginBottom );
26
+ }
27
+ };
28
+
29
+ wpDebugBar = {
30
+ init: function(){
31
+ // Initialize variables.
32
+ debugBar = $('#querylist');
33
+ $win = $(window);
34
+ $body = $(document.body);
35
+
36
+ bounds.minHeight = $('#debug-bar-handle').outerHeight() + $('#debug-bar-menu').outerHeight();
37
+ bounds.adminBarHeight = $('#wpadminbar').outerHeight();
38
+ bounds.marginBottom = parseInt( $body.css('margin-bottom'), 10 );
39
+
40
+ wpDebugBar.dock();
41
+ wpDebugBar.toggle();
42
+ wpDebugBar.tabs();
43
+ },
44
+
45
+ dock: function(){
46
+ debugBar.dockable({
47
+ handle: '#debug-bar-handle',
48
+ resize: function( e, ui ) {
49
+ return bounds.inUpper() && bounds.inLower();
50
+ },
51
+ resized: function( e, ui ) {
52
+ bounds.fix();
53
+ }
54
+ });
55
+
56
+ // If the window is resized, make sure the debug bar isn't too large.
57
+ $win.resize( function(){
58
+ if ( debugBar.is(':visible') )
59
+ bounds.fix();
60
+ });
61
+ },
62
+
63
+ toggle: function(){
64
+ $('#wp-admin-bar-debug-bar').click( function(e){
65
+ var show = debugBar.is(':hidden');
66
+ e.preventDefault();
67
+
68
+ debugBar.toggle( show );
69
+ $(this).toggleClass( 'active', show );
70
+
71
+ if ( show )
72
+ bounds.fix();
73
+ else
74
+ bounds.restore();
75
+ });
76
+ },
77
+
78
+ tabs: function(){
79
+ var debugMenuLinks = $('.debug-menu-link'),
80
+ debugMenuTargets = $('.debug-menu-target');
81
+
82
+ debugMenuLinks.click( function(e){
83
+ var t = $(this);
84
+
85
+ e.preventDefault();
86
+
87
+ if ( t.hasClass('current') )
88
+ return;
89
+
90
+ // Deselect other tabs and hide other panels.
91
+ debugMenuTargets.hide();
92
+ debugMenuLinks.removeClass('current');
93
+
94
+ // Select the current tab and show the current panel.
95
+ t.addClass('current');
96
+ // The hashed component of the href is the id that we want to display.
97
+ $('#' + this.href.substr( this.href.indexOf( '#' ) + 1 ) ).show();
98
+ });
99
+ }
100
+ };
101
+
102
+ $(document).ready( wpDebugBar.init );
103
+
104
+ })(jQuery);
js/debug-bar.js ADDED
@@ -0,0 +1 @@
 
1
+ (function(c){var e,a,d,f,b;a={adminBarHeight:0,minHeight:0,marginBottom:0,inUpper:function(){return e.offset().top-f.scrollTop()>=a.adminBarHeight},inLower:function(){return e.outerHeight()>=a.minHeight&&f.height()>=a.minHeight},fix:function(){if(!a.inUpper()){e.height(f.height()-a.adminBarHeight)}if(!a.inLower()){e.height(a.minHeight)}b.css("margin-bottom",e.height()+a.marginBottom)},restore:function(){b.css("margin-bottom",a.marginBottom)}};d={init:function(){e=c("#querylist");f=c(window);b=c(document.body);a.minHeight=c("#debug-bar-handle").outerHeight()+c("#debug-bar-menu").outerHeight();a.adminBarHeight=c("#wpadminbar").outerHeight();a.marginBottom=parseInt(b.css("margin-bottom"),10);d.dock();d.toggle();d.tabs()},dock:function(){e.dockable({handle:"#debug-bar-handle",resize:function(h,g){return a.inUpper()&&a.inLower()},resized:function(h,g){a.fix()}});f.resize(function(){if(e.is(":visible")){a.fix()}})},toggle:function(){c("#wp-admin-bar-debug-bar").click(function(h){var g=e.is(":hidden");h.preventDefault();e.toggle(g);c(this).toggleClass("active",g);if(g){a.fix()}else{a.restore()}})},tabs:function(){var h=c(".debug-menu-link"),g=c(".debug-menu-target");h.click(function(j){var i=c(this);j.preventDefault();if(i.hasClass("current")){return}g.hide();h.removeClass("current");i.addClass("current");c("#"+this.href.substr(this.href.indexOf("#")+1)).show()})}};c(document).ready(d.init)})(jQuery);
js/ui-dockable.dev.js ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Dockable.
3
+ **/
4
+ (function($){
5
+ $.widget("db.dockable", $.ui.mouse, {
6
+ options: {
7
+ handle: false,
8
+ axis: 'y',
9
+ resize: function() {},
10
+ resized: function() {}
11
+ },
12
+ _create: function() {
13
+ if ( this.options.axis == 'x' ) {
14
+ this.page = 'pageX';
15
+ this.dimension = 'width';
16
+ } else {
17
+ this.page = 'pageY';
18
+ this.dimension = 'height';
19
+ }
20
+
21
+ if ( ! this.options.handle )
22
+ return;
23
+
24
+ this.handle = $( this.options.handle );
25
+
26
+ this._mouseInit();
27
+ },
28
+ widget: function() {
29
+ return {
30
+ element: this.element,
31
+ handle: this.handle,
32
+ axis: this.options.axis
33
+ };
34
+ },
35
+ _mouseStart: function(event) {
36
+ this.d0 = this.element[this.dimension]() + event[this.page];
37
+ },
38
+ _mouseDrag: function(event) {
39
+ var resize = this._trigger( "resize", event, this.widget() );
40
+
41
+ // If the resize event returns false, we don't resize.
42
+ if ( resize === false )
43
+ return;
44
+
45
+ this.element[this.dimension]( this.d0 - event[this.page] );
46
+ this._trigger( "resized", event, this.widget() );
47
+ },
48
+ _mouseCapture: function(event) {
49
+ return !this.options.disabled && event.target == this.handle[0];
50
+ }
51
+ });
52
+ })(jQuery);
js/ui-dockable.js ADDED
@@ -0,0 +1 @@
 
1
+ (function(a){a.widget("db.dockable",a.ui.mouse,{options:{handle:false,axis:"y",resize:function(){},resized:function(){}},_create:function(){if(this.options.axis=="x"){this.page="pageX";this.dimension="width"}else{this.page="pageY";this.dimension="height"}if(!this.options.handle){return}this.handle=a(this.options.handle);this._mouseInit()},widget:function(){return{element:this.element,handle:this.handle,axis:this.options.axis}},_mouseStart:function(b){this.d0=this.element[this.dimension]()+b[this.page]},_mouseDrag:function(c){var b=this._trigger("resize",c,this.widget());if(b===false){return}this.element[this.dimension](this.d0-c[this.page]);this._trigger("resized",c,this.widget())},_mouseCapture:function(b){return !this.options.disabled&&b.target==this.handle[0]}})})(jQuery);
panels/class-debug-bar-deprecated.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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') );
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() {
22
+ $this->set_visible(
23
+ count( $this->deprecated_functions )
24
+ || count( $this->deprecated_files )
25
+ || count( $this->deprecated_arguments )
26
+ );
27
+ }
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)
37
+ echo "<li class='debug-bar-deprecated-function'>".str_replace(ABSPATH, '', $location) . ' - ' . strip_tags($message). "</li>";
38
+ echo '</ol>';
39
+ }
40
+ if ( count( $this->deprecated_files ) ) {
41
+ echo '<ol class="debug-bar-deprecated-list">';
42
+ foreach ( $this->deprecated_files as $location => $message)
43
+ echo "<li class='debug-bar-deprecated-function'>".str_replace(ABSPATH, '', $location) . ' - ' . strip_tags($message). "</li>";
44
+ echo '</ol>';
45
+ }
46
+ if ( count( $this->deprecated_arguments ) ) {
47
+ echo '<ol class="debug-bar-deprecated-list">';
48
+ foreach ( $this->deprecated_arguments as $location => $message)
49
+ echo "<li class='debug-bar-deprecated-function'>".str_replace(ABSPATH, '', $location) . ' - ' . strip_tags($message). "</li>";
50
+ echo '</ol>';
51
+ }
52
+ echo "</div>";
53
+ }
54
+
55
+ function deprecated_function_run($function, $replacement, $version) {
56
+ $backtrace = debug_backtrace();
57
+ $bt = 4;
58
+ // Check if we're a hook callback.
59
+ if ( ! isset( $backtrace[4]['file'] ) && 'call_user_func_array' == $backtrace[5]['function'] ) {
60
+ $bt = 6;
61
+ }
62
+ $file = $backtrace[ $bt ]['file'];
63
+ $line = $backtrace[ $bt ]['line'];
64
+ if ( ! is_null($replacement) )
65
+ $message = sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $function, $version, $replacement );
66
+ else
67
+ $message = sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $function, $version );
68
+
69
+ $this->deprecated_functions[$file.':'.$line] = $message;
70
+ }
71
+
72
+ function deprecated_file_included( $old_file, $replacement, $version, $message ) {
73
+ $backtrace = debug_backtrace();
74
+ $file = $backtrace[4]['file'];
75
+ $file_abs = str_replace(ABSPATH, '', $file);
76
+ $line = $backtrace[4]['line'];
77
+ $message = empty( $message ) ? '' : ' ' . $message;
78
+ if ( ! is_null( $replacement ) )
79
+ $message = sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $file_abs, $version, $replacement ) . $message;
80
+ else
81
+ $message = sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $file_abs, $version ) . $message;
82
+
83
+ $this->deprecated_files[$file.':'.$line] = $message;
84
+ }
85
+
86
+ function deprecated_argument_run( $function, $message, $version) {
87
+ $backtrace = debug_backtrace();
88
+ $bt = 4;
89
+ if ( ! isset( $backtrace[4]['file'] ) && 'call_user_func_array' == $backtrace[5]['function'] ) {
90
+ $bt = 6;
91
+ }
92
+ $file = $backtrace[ $bt ]['file'];
93
+ $line = $backtrace[ $bt ]['line'];
94
+
95
+ $this->deprecated_arguments[$file.':'.$line] = $message;
96
+ }
97
+ }
98
+
99
+
100
+ ?>
panels/class-debug-bar-object-cache.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Debug_Bar_Object_Cache extends Debug_Bar_Panel {
4
+ function init() {
5
+ $this->title( __('Object Cache') );
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();
18
+ echo "</div>";
19
+ $out = ob_get_contents();
20
+ ob_end_clean();
21
+
22
+ echo $out;
23
+ }
24
+ }
25
+
26
+ ?>
panels/class-debug-bar-panel.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Debug_Bar_Panel {
4
+ var $_title = '';
5
+ var $_visible = true;
6
+
7
+ function Debug_Bar_Panel( $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
+ /**
19
+ * Initializes the panel.
20
+ */
21
+ function init() {}
22
+
23
+ function prerender() {}
24
+
25
+ /**
26
+ * Renders the panel.
27
+ */
28
+ function render() {}
29
+
30
+ function is_visible() {
31
+ return $this->_visible;
32
+ }
33
+
34
+ function set_visible( $visible ) {
35
+ $this->_visible = $visible;
36
+ }
37
+
38
+ function title( $title=NULL ) {
39
+ if ( ! isset( $title ) )
40
+ return $this->_title;
41
+ $this->_title = $title;
42
+ }
43
+
44
+ function debug_bar_classes( $classes ) {
45
+ return $classes;
46
+ }
47
+ }
48
+
49
+ ?>
panels/class-debug-bar-php.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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') );
13
+
14
+ $this->real_error_handler = set_error_handler( array( &$this, 'error_handler' ) );
15
+ }
16
+
17
+ function prerender() {
18
+ $this->set_visible( count( $this->notices ) || count( $this->warnings ) );
19
+ }
20
+
21
+ function debug_bar_classes( $classes ) {
22
+ if ( count( $this->warnings ) )
23
+ $classes[] = 'warning';
24
+ elseif ( count( $this->notices ) )
25
+ $classes[] = 'notice';
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 );
36
+ break;
37
+ case E_NOTICE :
38
+ case E_USER_NOTICE :
39
+ $this->notices[$_key] = array( $file.':'.$line, $message );
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) {
66
+ list( $location, $message) = $location_message;
67
+ echo "<li class='debug-bar-php-warning'>WARNING: ".str_replace(ABSPATH, '', $location) . ' - ' . strip_tags($message). "</li>";
68
+ }
69
+ echo '</ol>';
70
+ }
71
+ if ( count( $this->notices ) ) {
72
+ echo '<ol class="debug-bar-php-list">';
73
+ foreach ( $this->notices as $location_message) {
74
+ list( $location, $message) = $location_message;
75
+ echo "<li class='debug-bar-php-notice'>NOTICE: ".str_replace(ABSPATH, '', $location) . ' - ' . strip_tags($message). "</li>";
76
+ }
77
+ echo '</ol>';
78
+ }
79
+ echo "</div>";
80
+
81
+ }
82
+ }
83
+
84
+ ?>
panels/class-debug-bar-queries.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Debug_Bar_Queries extends Debug_Bar_Panel {
4
+ function init() {
5
+ $this->title( __('Queries') );
6
+ }
7
+
8
+ function prerender() {
9
+ $this->set_visible( defined('SAVEQUERIES') && SAVEQUERIES );
10
+ }
11
+
12
+ function render() {
13
+ global $wpdb;
14
+
15
+ $queries = array();
16
+ $out = '';
17
+ $total_time = 0;
18
+
19
+ if ( !empty($wpdb->queries) ) {
20
+ $show_many = isset($_GET['debug_queries']);
21
+
22
+ if ( $wpdb->num_queries > 500 && !$show_many )
23
+ $out .= "<p>" . sprintf( __('There are too many queries to show easily! <a href="%s">Show them anyway</a>'), add_query_arg( 'debug_queries', 'true' ) ) . "</p>";
24
+
25
+ $out .= '<ol id="wpd-queries">';
26
+ $first_query = 0;
27
+ $counter = 0;
28
+
29
+ foreach ( $wpdb->queries as $q ) {
30
+ list($query, $elapsed, $debug) = $q;
31
+
32
+ $total_time += $elapsed;
33
+
34
+ if ( !$show_many && ++$counter > 500 )
35
+ continue;
36
+
37
+ $debug = explode( ', ', $debug );
38
+ $debug = array_diff( $debug, array( 'require_once', 'require', 'include_once', 'include' ) );
39
+ $debug = implode( ', ', $debug );
40
+ $debug = str_replace( array( 'do_action, call_user_func_array' ), array( 'do_action' ), $debug );
41
+ $query = nl2br(esc_html($query));
42
+
43
+ $out .= "<li>$query<br/><div class='qdebug'>$debug <span>#{$counter} (" . number_format(sprintf('%0.1f', $elapsed * 1000), 1, '.', ',') . "ms)</span></div></li>\n";
44
+ }
45
+ $out .= '</ol>';
46
+ } else {
47
+ $out .= "<p><strong>" . __('There are no queries on this page.') . "</strong></p>";
48
+ }
49
+
50
+ $query_count = '<h2><span>Total Queries:</span>' . number_format( $wpdb->num_queries ) . "</h2>\n";
51
+ $query_time = '<h2><span>Total query time:</span>' . number_format(sprintf('%0.1f', $total_time * 1000), 1) . " ms</h2>\n";
52
+
53
+ $out = $query_count . $query_time . $out;
54
+
55
+ echo $out;
56
+ }
57
+ }
58
+
59
+ ?>
panels/class-debug-bar-request.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Debug_Bar_Request extends Debug_Bar_Panel {
4
+ function init() {
5
+ $this->title( __('Request') );
6
+ }
7
+
8
+ function prerender() {
9
+ $this->set_visible( ! is_admin() );
10
+ }
11
+
12
+ function render() {
13
+ global $wp;
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>';
50
+ }
51
+ }
52
+
53
+ ?>
panels/class-debug-bar-wp-query.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Debug_Bar_WP_Query extends Debug_Bar_Panel {
4
+ function init() {
5
+ $this->title( __('WP Query') );
6
+ }
7
+
8
+ function prerender() {
9
+ $this->set_visible( defined('SAVEQUERIES') && SAVEQUERIES );
10
+ }
11
+
12
+ function render() {
13
+ global $template, $wp_query;
14
+
15
+ echo "<div id='debug-bar-wp-query'>";
16
+ echo '<h2><span>Queried Object ID:</span>' . get_queried_object_id() . "</h2>\n";
17
+
18
+ // Determine the query type. Follows the template loader order.
19
+ $type = '';
20
+ if ( is_404() )
21
+ $type = '404';
22
+ elseif ( is_search() )
23
+ $type = 'Search';
24
+ elseif ( is_tax() )
25
+ $type = 'Taxonomy';
26
+ elseif ( is_front_page() )
27
+ $type = 'Front Page';
28
+ elseif ( is_home() )
29
+ $type = 'Home';
30
+ elseif ( is_attachment() )
31
+ $type = 'Attachment';
32
+ elseif ( is_single() )
33
+ $type = 'Single';
34
+ elseif ( is_page() )
35
+ $type = 'Page';
36
+ elseif ( is_category() )
37
+ $type = 'Category';
38
+ elseif ( is_tag() )
39
+ $type = 'Tag';
40
+ elseif ( is_author() )
41
+ $type = 'Author';
42
+ elseif ( is_date() )
43
+ $type = 'Date';
44
+ elseif ( is_archive() )
45
+ $type = 'Archive';
46
+ elseif ( is_paged() )
47
+ $type = 'Paged';
48
+
49
+ if ( !empty($type) )
50
+ echo '<h2><span>Query Type:</span>' . $type . "</h2>\n";
51
+
52
+ if ( !empty($template) )
53
+ echo '<h2><span>Query Template:</span>' . basename($template) . "</h2>\n";
54
+
55
+ $show_on_front = get_option( 'show_on_front' );
56
+ $page_on_front = get_option( 'page_on_front' );
57
+ $page_for_posts = get_option( 'page_for_posts' );
58
+
59
+ echo '<h2><span>Show on Front:</span>' . $show_on_front . "</h2>\n";
60
+ if ( 'page' == $show_on_front ) {
61
+ echo '<h2><span>Page for Posts:</span>' . $page_for_posts . "</h2>\n";
62
+ echo '<h2><span>Page on Front:</span>' . $page_on_front . "</h2>\n";
63
+ }
64
+
65
+ echo '<div class="clear"></div>';
66
+
67
+ if ( empty($wp_query->query) )
68
+ $query = 'None';
69
+ else
70
+ $query = http_build_query( $wp_query->query );
71
+
72
+ echo '<h3>Query Arguments:</h3>';
73
+ echo '<p>' . esc_html( $query ) . '</p>';
74
+
75
+ if ( ! empty($wp_query->request) ) {
76
+ echo '<h3>Query SQL:</h3>';
77
+ echo '<p>' . esc_html( $wp_query->request ) . '</p>';
78
+ }
79
+
80
+ $object = get_queried_object();
81
+ if ( ! is_null( $object ) ) {
82
+ echo '<h3>Queried Object:</h3>';
83
+ echo '<ol class="debug-bar-wp-query-list">';
84
+ foreach ($object as $key => $value) {
85
+ echo '<li>' . $key . ' => ' . $value . '</li>';
86
+ }
87
+ echo '</ol>';
88
+ }
89
+ echo '</div>';
90
+ }
91
+ }
92
+
93
+ ?>
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  Contributors: wordpressdotorg, ryan, westi, koopersmith
3
  Tags: debug
4
  Tested up to: 3.1
5
- Stable tag: 0.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.
@@ -19,6 +19,11 @@ When SAVEQUERIES is enabled the mysql queries are tracked and displayed.
19
 
20
  == Upgrade Notice ==
21
 
 
 
 
 
 
22
  = 0.4.1 =
23
  Compatibility updates for trunk
24
 
@@ -40,6 +45,11 @@ Initial Release
40
 
41
  == Changelog ==
42
 
 
 
 
 
 
43
  = 0.4.1 =
44
  Compatibility updates for trunk
45
 
2
  Contributors: wordpressdotorg, ryan, westi, koopersmith
3
  Tags: debug
4
  Tested up to: 3.1
5
+ Stable tag: 0.4.1
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.
19
 
20
  == Upgrade Notice ==
21
 
22
+ = 0.5 =
23
+ New UI
24
+ Backend rewritten with a class for each panel
25
+ Many miscellaneous improvements
26
+
27
  = 0.4.1 =
28
  Compatibility updates for trunk
29
 
45
 
46
  == Changelog ==
47
 
48
+ = 0.5 =
49
+ New UI
50
+ Backend rewritten with a class for each panel
51
+ Many miscellaneous improvements
52
+
53
  = 0.4.1 =
54
  Compatibility updates for trunk
55