Version Description
Added PHP Notice / Warning tracking Added deprecated function usage tracking
Download this release
Release Info
Developer | westi |
Plugin | Debug Bar |
Version | 0.2 |
Comparing to | |
See all releases |
Code changes from version 0.1 to 0.2
- debug-bar.css +1 -1
- debug-bar.dev.css +41 -0
- debug-bar.dev.js +31 -0
- debug-bar.js +1 -0
- debug-bar.php +184 -77
- readme.txt +10 -2
debug-bar.css
CHANGED
@@ -1 +1 @@
|
|
1 |
-
#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;}#querylist ul.debug-menu-links{clear:left;background:#ccc;padding:10px 15px 0;overflow:hidden;list-style:none;margin:0;padding:0 0 0 15px;}#querylist ul.debug-menu-links li{float:left;margin-right:10px;margin-bottom:0!important;}#querylist ul.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;}#querylist ul.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;}#object-cache-stats ul.debug-menu-links{padding:0;margin:0;background:none;}#object-cache-stats ul.debug-menu-links li{float:left;margin-bottom:10px!important;background:none!important;border:1px solid #eee!important;color:#555!important;}#object-cache-stats ul.debug-menu-links li.current a{background:#ccc!important;color:#fff!important;-webkit-border-top-right-radius:0;-webkit-border-top-left-radius:0;-moz-border-radius-topright:0;-moz-border-radius-topleft:0;}#object-cache-stats ul.debug-menu-links li a{background:none;color:#555!important;overflow:hidden;}#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;}#wpadminbar #admin-bar-micro ul li{list-style-type:none;position:relative;margin:0;padding:0;}#wpadminbar #admin-bar-micro ul ul,#wpadminbar #admin-bar-micro #awaiting-mod,#wpadminbar .ab-sadmin .count-0{display:none!important;}#wpadminbar #admin-bar-micro ul li:hover>ul{display:block;position:absolute;top:-1px;left:100%;}#wpadminbar #admin-bar-micro li a{display:block;text-decoration:none;}#wpadminbar #admin-bar-micro li li a{background:#ddd;}#wpadminbar #admin-bar-micro li li li a{background:#fff;}
|
1 |
+
#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;}#querylist ul.debug-menu-links{clear:left;background:#ccc;padding:10px 15px 0;overflow:hidden;list-style:none;margin:0;padding:0 0 0 15px;}#querylist ul.debug-menu-links li{float:left;margin-right:10px;margin-bottom:0!important;}#querylist ul.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;}#querylist ul.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;}#object-cache-stats ul.debug-menu-links{padding:0;margin:0;background:none;}#object-cache-stats ul.debug-menu-links li{float:left;margin-bottom:10px!important;background:none!important;border:1px solid #eee!important;color:#555!important;}#object-cache-stats ul.debug-menu-links li.current a{background:#ccc!important;color:#fff!important;-webkit-border-top-right-radius:0;-webkit-border-top-left-radius:0;-moz-border-radius-topright:0;-moz-border-radius-topleft:0;}#object-cache-stats ul.debug-menu-links li a{background:none;color:#555!important;overflow:hidden;}#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;}#wpadminbar #admin-bar-micro ul li{list-style-type:none;position:relative;margin:0;padding:0;}#wpadminbar #admin-bar-micro ul ul,#wpadminbar #admin-bar-micro #awaiting-mod,#wpadminbar .ab-sadmin .count-0{display:none!important;}#wpadminbar #admin-bar-micro ul li:hover>ul{display:block;position:absolute;top:-1px;left:100%;}#wpadminbar #admin-bar-micro li a{display:block;text-decoration:none;}#wpadminbar #admin-bar-micro li li a{background:#ddd;}#wpadminbar #admin-bar-micro li li li a{background:#fff;}#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.dev.css
CHANGED
@@ -217,6 +217,47 @@
|
|
217 |
background: #fff;
|
218 |
}
|
219 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
220 |
/**
|
221 |
* End super admin styling
|
222 |
*/
|
217 |
background: #fff;
|
218 |
}
|
219 |
|
220 |
+
#debug-bar-php ol.debug-bar-php-list {
|
221 |
+
padding: 0 !important;
|
222 |
+
margin: 0 !important;
|
223 |
+
list-style: none;
|
224 |
+
clear: left;
|
225 |
+
}
|
226 |
+
|
227 |
+
#debug-bar-php ol.debug-bar-php-list li {
|
228 |
+
padding: 10px;
|
229 |
+
margin: 0 0 10px 0;
|
230 |
+
}
|
231 |
+
|
232 |
+
#debug-bar-php ol.debug-bar-php-list li.debug-bar-php-warning {
|
233 |
+
background: red;
|
234 |
+
}
|
235 |
+
#debug-bar-php ol.debug-bar-php-list li.debug-bar-php-notice {
|
236 |
+
background: orange;
|
237 |
+
}
|
238 |
+
|
239 |
+
#debug-bar-deprecated ol.debug-bar-deprecated-list {
|
240 |
+
padding: 0 !important;
|
241 |
+
margin: 0 !important;
|
242 |
+
list-style: none;
|
243 |
+
clear: left;
|
244 |
+
}
|
245 |
+
|
246 |
+
#debug-bar-deprecated ol.debug-bar-deprecated-list li {
|
247 |
+
padding: 10px;
|
248 |
+
margin: 0 0 10px 0;
|
249 |
+
background: #f0f0f0;
|
250 |
+
}
|
251 |
+
|
252 |
+
#wpadminbar li.ab-php-warning {
|
253 |
+
background: #dd0000;
|
254 |
+
}
|
255 |
+
|
256 |
+
#wpadminbar li.ab-php-notice {
|
257 |
+
background: #dd5500;
|
258 |
+
}
|
259 |
+
|
260 |
+
|
261 |
/**
|
262 |
* End super admin styling
|
263 |
*/
|
debug-bar.dev.js
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var toggle_query_list, clickDebugLink;
|
2 |
+
|
3 |
+
toggle_query_list = function() {
|
4 |
+
var querylist = document.getElementById( 'querylist' );
|
5 |
+
if( querylist && querylist.style.display == 'block' ) {
|
6 |
+
querylist.style.display='none';
|
7 |
+
} else {
|
8 |
+
querylist.style.display='block';
|
9 |
+
}
|
10 |
+
}
|
11 |
+
|
12 |
+
clickDebugLink = function( targetsGroupId, obj) {
|
13 |
+
var sectionDivs, i, j;
|
14 |
+
sectionDivs = document.getElementById( targetsGroupId ).childNodes;
|
15 |
+
for ( i = 0; i < sectionDivs.length; i++ ) {
|
16 |
+
if ( 1 != sectionDivs[i].nodeType ) {
|
17 |
+
continue;
|
18 |
+
}
|
19 |
+
sectionDivs[i].style.display = 'none';
|
20 |
+
}
|
21 |
+
document.getElementById( obj.href.substr( obj.href.indexOf( '#' ) + 1 ) ).style.display = 'block';
|
22 |
+
|
23 |
+
for ( j = 0; j < obj.parentNode.parentNode.childNodes.length; j++ ) {
|
24 |
+
if ( 1 != obj.parentNode.parentNode.childNodes[j].nodeType ) {
|
25 |
+
continue;
|
26 |
+
}
|
27 |
+
obj.parentNode.parentNode.childNodes[j].removeAttribute( 'class' );
|
28 |
+
}
|
29 |
+
obj.parentNode.setAttribute( 'class', 'current' );
|
30 |
+
return false;
|
31 |
+
};
|
debug-bar.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
var toggle_query_list,clickDebugLink;toggle_query_list=function(){var a=document.getElementById("querylist");if(a&&a.style.display=="block"){a.style.display="none"}else{a.style.display="block"}};clickDebugLink=function(d,e){var c,b,a;c=document.getElementById(d).childNodes;for(b=0;b<c.length;b++){if(1!=c[b].nodeType){continue}c[b].style.display="none"}document.getElementById(e.href.substr(e.href.indexOf("#")+1)).style.display="block";for(a=0;a<e.parentNode.parentNode.childNodes.length;a++){if(1!=e.parentNode.parentNode.childNodes[a].nodeType){continue}e.parentNode.parentNode.childNodes[a].removeAttribute("class")}e.parentNode.setAttribute("class","current");return false};
|
debug-bar.php
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
-
Plugin Name: Debug Bar
|
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.
|
8 |
-
Author URI: http://wordpress.org/
|
9 |
-
*/
|
10 |
|
11 |
/***
|
12 |
* Debug Functions
|
@@ -21,16 +21,31 @@ function debug_bar_menu() {
|
|
21 |
global $wp_admin_bar, $wpdb;
|
22 |
|
23 |
if ( ! is_super_admin() || ! is_admin_bar_showing() )
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
-
|
|
|
27 |
}
|
28 |
-
add_action( '
|
29 |
|
30 |
function debug_bar_menu_init() {
|
31 |
if ( ! is_super_admin() || ! is_admin_bar_showing() )
|
32 |
-
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
}
|
35 |
add_action('admin_bar_init', 'debug_bar_menu_init');
|
36 |
|
@@ -38,86 +53,57 @@ function debug_bar_list() {
|
|
38 |
global $wpdb, $wp_object_cache;
|
39 |
|
40 |
if ( ! is_super_admin() || ! is_admin_bar_showing() )
|
41 |
-
|
42 |
|
43 |
$debugs = array();
|
44 |
|
45 |
if ( defined('SAVEQUERIES') && SAVEQUERIES )
|
46 |
-
|
47 |
|
48 |
if ( is_object($wp_object_cache) && method_exists($wp_object_cache, 'stats') )
|
49 |
-
|
50 |
|
51 |
-
|
52 |
-
|
53 |
-
if ( empty($debugs) )
|
54 |
-
return;
|
55 |
-
|
56 |
-
?>
|
57 |
-
<script type="text/javascript">
|
58 |
-
/* <![CDATA[ */
|
59 |
-
var toggle_query_list = function() {
|
60 |
-
var querylist = document.getElementById( 'querylist' );
|
61 |
-
if( querylist && querylist.style.display == 'block' ) {
|
62 |
-
querylist.style.display='none';
|
63 |
-
} else {
|
64 |
-
querylist.style.display='block';
|
65 |
-
}
|
66 |
}
|
|
|
|
|
67 |
|
68 |
-
|
69 |
-
var sectionDivs = document.getElementById( targetsGroupId ).childNodes;
|
70 |
-
for ( var i = 0; i < sectionDivs.length; i++ ) {
|
71 |
-
if ( 1 != sectionDivs[i].nodeType ) {
|
72 |
-
continue;
|
73 |
-
}
|
74 |
-
sectionDivs[i].style.display = 'none';
|
75 |
-
}
|
76 |
-
document.getElementById( obj.href.substr( obj.href.indexOf( '#' ) + 1 ) ).style.display = 'block';
|
77 |
-
|
78 |
-
for ( var i = 0; i < obj.parentNode.parentNode.childNodes.length; i++ ) {
|
79 |
-
if ( 1 != obj.parentNode.parentNode.childNodes[i].nodeType ) {
|
80 |
-
continue;
|
81 |
-
}
|
82 |
-
obj.parentNode.parentNode.childNodes[i].removeAttribute( 'class' );
|
83 |
-
}
|
84 |
-
obj.parentNode.setAttribute( 'class', 'current' );
|
85 |
-
return false;
|
86 |
-
};
|
87 |
-
/* ]]> */
|
88 |
-
</script>
|
89 |
-
<div align='left' id='querylist'>
|
90 |
-
|
91 |
-
<h1>Debugging blog #<?php echo $GLOBALS['blog_id']; ?> on <?php echo php_uname( 'n' ); ?></h1>
|
92 |
-
<div id="debug-status">
|
93 |
-
<p class="left"></p>
|
94 |
-
<p class="right">PHP Version: <?php echo phpversion(); ?></p>
|
95 |
-
</div>
|
96 |
-
<ul class="debug-menu-links">
|
97 |
|
98 |
-
|
|
|
99 |
|
100 |
-
|
|
|
101 |
|
102 |
-
|
|
|
|
|
|
|
|
|
|
|
103 |
|
104 |
-
|
105 |
|
106 |
-
<
|
|
|
|
|
|
|
107 |
|
108 |
-
<?php $current = '
|
109 |
|
110 |
-
|
111 |
-
<?php echo str_replace( ' ', '', call_user_func( $debug_output[1] ) ); ?>
|
112 |
-
</div>
|
113 |
|
114 |
-
|
115 |
|
116 |
-
|
|
|
|
|
117 |
|
118 |
-
<?php
|
119 |
|
120 |
-
|
121 |
|
122 |
<?php
|
123 |
}
|
@@ -134,7 +120,7 @@ function debug_bar_queries() {
|
|
134 |
$show_many = isset($_GET['debug_queries']);
|
135 |
|
136 |
if ( $wpdb->num_queries > 500 && !$show_many )
|
137 |
-
|
138 |
|
139 |
$out .= '<ol id="wpd-queries">';
|
140 |
$first_query = 0;
|
@@ -146,16 +132,15 @@ function debug_bar_queries() {
|
|
146 |
$total_time += $elapsed;
|
147 |
|
148 |
if ( !$show_many && ++$counter > 500 )
|
149 |
-
|
150 |
|
151 |
$query = nl2br(esc_html($query));
|
152 |
|
153 |
-
// $dbhname, $host, $port, $name, $tcp, $elapsed
|
154 |
$out .= "<li>$query<br/><div class='qdebug'>$debug <span>#{$counter} (" . number_format(sprintf('%0.1f', $elapsed * 1000), 1, '.', ',') . "ms)</span></div></li>\n";
|
155 |
}
|
156 |
$out .= '</ol>';
|
157 |
} else {
|
158 |
-
$out .= "<p><strong>There are no queries on this page
|
159 |
}
|
160 |
|
161 |
$query_count = '<h2><span>Total Queries:</span>' . number_format( $wpdb->num_queries ) . "</h2>\n";
|
@@ -171,7 +156,7 @@ function debug_bar_object_cache() {
|
|
171 |
global $wp_object_cache;
|
172 |
ob_start();
|
173 |
echo "<div id='object-cache-stats'>";
|
174 |
-
|
175 |
echo "</div>";
|
176 |
$out = ob_get_contents();
|
177 |
ob_end_clean();
|
@@ -179,4 +164,126 @@ function debug_bar_object_cache() {
|
|
179 |
return $out;
|
180 |
}
|
181 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
182 |
?>
|
1 |
<?php
|
2 |
/*
|
3 |
+
Plugin Name: Debug Bar
|
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.2
|
8 |
+
Author URI: http://wordpress.org/
|
9 |
+
*/
|
10 |
|
11 |
/***
|
12 |
* Debug Functions
|
21 |
global $wp_admin_bar, $wpdb;
|
22 |
|
23 |
if ( ! is_super_admin() || ! is_admin_bar_showing() )
|
24 |
+
return;
|
25 |
+
|
26 |
+
$class = 'ab-sadmin';
|
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'), 'href' => 'javascript:toggle_query_list()', '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', WP_PLUGIN_URL . "/debug-bar/debug-bar$suffix.css", array(), '20101112' );
|
43 |
+
wp_enqueue_script( 'admin-bar-debug', WP_PLUGIN_URL . "/debug-bar/debug-bar$suffix.js", array(), '20101109' );
|
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 |
|
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 |
|
72 |
+
$debugs = apply_filters( 'debug_bar_list', $debugs );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
+
if ( empty($debugs) )
|
75 |
+
return;
|
76 |
|
77 |
+
?>
|
78 |
+
<div align='left' id='querylist'>
|
79 |
|
80 |
+
<h1><?php printf( __('Debugging blog #%d on %s'), $GLOBALS['blog_id'], php_uname( 'n' ) ); ?></h1>
|
81 |
+
<div id="debug-status">
|
82 |
+
<p class="left"></p>
|
83 |
+
<p class="right"><?php printf( __('PHP Version: %s'), phpversion() ); ?></p>
|
84 |
+
</div>
|
85 |
+
<ul class="debug-menu-links">
|
86 |
|
87 |
+
<?php $current = ' class="current"'; foreach ( $debugs as $debug => $debug_output ) : ?>
|
88 |
|
89 |
+
<li <?php echo $current; ?>><a
|
90 |
+
id="debug-menu-link-<?php echo $debug; ?>"
|
91 |
+
href="#debug-menu-target-<?php echo $debug; ?>"
|
92 |
+
onclick="try { return clickDebugLink( 'debug-menu-targets', this ); } catch (e) { return true; }"><?php echo $debug_output[0] ?></a></li>
|
93 |
|
94 |
+
<?php $current = ''; endforeach; ?>
|
95 |
|
96 |
+
</ul>
|
|
|
|
|
97 |
|
98 |
+
<div id="debug-menu-targets"><?php $current = ' style="display: block"'; foreach ( $debugs as $debug => $debug_output ) : ?>
|
99 |
|
100 |
+
<div id="debug-menu-target-<?php echo $debug; ?>"
|
101 |
+
class="debug-menu-target" <?php echo $current; ?>><?php echo str_replace( ' ', '', call_user_func( $debug_output[1] ) ); ?>
|
102 |
+
</div>
|
103 |
|
104 |
+
<?php $current = ''; endforeach; ?></div>
|
105 |
|
106 |
+
<?php do_action( 'debug_bar' ); ?></div>
|
107 |
|
108 |
<?php
|
109 |
}
|
120 |
$show_many = isset($_GET['debug_queries']);
|
121 |
|
122 |
if ( $wpdb->num_queries > 500 && !$show_many )
|
123 |
+
$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>";
|
124 |
|
125 |
$out .= '<ol id="wpd-queries">';
|
126 |
$first_query = 0;
|
132 |
$total_time += $elapsed;
|
133 |
|
134 |
if ( !$show_many && ++$counter > 500 )
|
135 |
+
continue;
|
136 |
|
137 |
$query = nl2br(esc_html($query));
|
138 |
|
|
|
139 |
$out .= "<li>$query<br/><div class='qdebug'>$debug <span>#{$counter} (" . number_format(sprintf('%0.1f', $elapsed * 1000), 1, '.', ',') . "ms)</span></div></li>\n";
|
140 |
}
|
141 |
$out .= '</ol>';
|
142 |
} else {
|
143 |
+
$out .= "<p><strong>" . __('There are no queries on this page.') . "</strong></p>";
|
144 |
}
|
145 |
|
146 |
$query_count = '<h2><span>Total Queries:</span>' . number_format( $wpdb->num_queries ) . "</h2>\n";
|
156 |
global $wp_object_cache;
|
157 |
ob_start();
|
158 |
echo "<div id='object-cache-stats'>";
|
159 |
+
$wp_object_cache->stats();
|
160 |
echo "</div>";
|
161 |
$out = ob_get_contents();
|
162 |
ob_end_clean();
|
164 |
return $out;
|
165 |
}
|
166 |
|
167 |
+
|
168 |
+
function debug_bar_php() {
|
169 |
+
global $_debug_bar_notices, $_debug_bar_warnings;
|
170 |
+
echo "<div id='debug-bar-php'>";
|
171 |
+
echo '<h2><span>Total Warnings:</span>' . number_format( count( $_debug_bar_warnings ) ) . "</h2>\n";
|
172 |
+
echo '<h2><span>Total Notices:</span>' . number_format( count( $_debug_bar_notices ) ) . "</h2>\n";
|
173 |
+
echo '<ol class="debug-bar-php-list">';
|
174 |
+
foreach ( $_debug_bar_warnings as $location => $message)
|
175 |
+
echo "<li class='debug-bar-php-warning'>WARNING: ".str_replace(ABSPATH, '', $location) . ' - ' . strip_tags($message). "</li>";
|
176 |
+
echo '</ol>';
|
177 |
+
echo '<ol class="debug-bar-php-list">';
|
178 |
+
foreach ( $_debug_bar_notices as $location => $message)
|
179 |
+
echo "<li class='debug-bar-php-notice'>NOTICE: ".str_replace(ABSPATH, '', $location) . ' - ' . strip_tags($message). "</li>";
|
180 |
+
echo '</ol>';
|
181 |
+
echo "</div>";
|
182 |
+
}
|
183 |
+
|
184 |
+
function debug_bar_deprecated() {
|
185 |
+
global $_debug_bar_deprecated_functions, $_debug_bar_deprecated_files, $_debug_bar_deprecated_arguments;
|
186 |
+
echo "<div id='debug-bar-deprecated'>";
|
187 |
+
echo '<h2><span>Total Functions:</span>' . number_format( count( $_debug_bar_deprecated_functions ) ) . "</h2>\n";
|
188 |
+
echo '<h2><span>Total Arguments:</span>' . number_format( count( $_debug_bar_deprecated_arguments ) ) . "</h2>\n";
|
189 |
+
echo '<h2><span>Total Files:</span>' . number_format( count( $_debug_bar_deprecated_files ) ) . "</h2>\n";
|
190 |
+
echo '<ol class="debug-bar-deprecated-list">';
|
191 |
+
foreach ( $_debug_bar_deprecated_functions as $location => $message)
|
192 |
+
echo "<li class='debug-bar-deprecated-function'>".str_replace(ABSPATH, '', $location) . ' - ' . strip_tags($message). "</li>";
|
193 |
+
echo '</ol>';
|
194 |
+
echo '<ol class="debug-bar-deprecated-list">';
|
195 |
+
foreach ( $_debug_bar_deprecated_files as $location => $message)
|
196 |
+
echo "<li class='debug-bar-deprecated-function'>".str_replace(ABSPATH, '', $location) . ' - ' . strip_tags($message). "</li>";
|
197 |
+
echo '</ol>';
|
198 |
+
echo '<ol class="debug-bar-deprecated-list">';
|
199 |
+
foreach ( $_debug_bar_deprecated_arguments as $location => $message)
|
200 |
+
echo "<li class='debug-bar-deprecated-function'>".str_replace(ABSPATH, '', $location) . ' - ' . strip_tags($message). "</li>";
|
201 |
+
echo '</ol>';
|
202 |
+
echo "</div>";
|
203 |
+
}
|
204 |
+
|
205 |
+
function debug_bar_error_handler( $type, $message, $file, $line ) {
|
206 |
+
global $_debug_bar_real_error_handler, $_debug_bar_notices, $_debug_bar_warnings;
|
207 |
+
|
208 |
+
switch ( $type ) {
|
209 |
+
case E_WARNING :
|
210 |
+
case E_USER_WARNING :
|
211 |
+
$_debug_bar_warnings[$file.':'.$line] = $message;
|
212 |
+
break;
|
213 |
+
case E_NOTICE :
|
214 |
+
case E_USER_NOTICE :
|
215 |
+
$_debug_bar_notices[$file.':'.$line] = $message;
|
216 |
+
break;
|
217 |
+
case E_STRICT :
|
218 |
+
// TODO
|
219 |
+
break;
|
220 |
+
case E_DEPRECATED :
|
221 |
+
case E_USER_DEPRECATED :
|
222 |
+
// TODO
|
223 |
+
break;
|
224 |
+
case 0 :
|
225 |
+
// TODO
|
226 |
+
break;
|
227 |
+
}
|
228 |
+
|
229 |
+
if ( null != $_debug_bar_real_error_handler )
|
230 |
+
return call_user_func( $_debug_bar_real_error_handler, $type, $message, $file, $line );
|
231 |
+
else
|
232 |
+
return false;
|
233 |
+
}
|
234 |
+
if ( WP_DEBUG ) {
|
235 |
+
$GLOBALS['_debug_bar_real_error_handler'] = set_error_handler('debug_bar_error_handler');
|
236 |
+
$GLOBALS['_debug_bar_warnings'] = $GLOBALS['_debug_bar_notices'] = array();
|
237 |
+
}
|
238 |
+
|
239 |
+
// Alot of this code is massaged from nacin's log-deprecated-notices plugin
|
240 |
+
$_debug_bar_deprecated_functions = $_debug_bar_deprecated_files = $_debug_bar_deprecated_arguments = array();
|
241 |
+
function debug_bar_deprecated_function_run($function, $replacement, $version) {
|
242 |
+
global $_debug_bar_deprecated_functions;
|
243 |
+
$backtrace = debug_backtrace();
|
244 |
+
$bt = 4;
|
245 |
+
// Check if we're a hook callback.
|
246 |
+
if ( ! isset( $backtrace[4]['file'] ) && 'call_user_func_array' == $backtrace[5]['function'] ) {
|
247 |
+
$bt = 6;
|
248 |
+
}
|
249 |
+
$file = $backtrace[ $bt ]['file'];
|
250 |
+
$line = $backtrace[ $bt ]['line'];
|
251 |
+
if ( ! is_null($replacement) )
|
252 |
+
$message = sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $function, $version, $replacement );
|
253 |
+
else
|
254 |
+
$message = sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $function, $version );
|
255 |
+
|
256 |
+
$_debug_bar_deprecated_functions[$file.':'.$line] = $message;
|
257 |
+
}
|
258 |
+
add_action( 'deprecated_function_run', 'debug_bar_deprecated_function_run', 10, 3 );
|
259 |
+
|
260 |
+
function debug_bar_deprecated_file_included( $old_file, $replacement, $version, $message ) {
|
261 |
+
global $_debug_bar_deprecated_files;
|
262 |
+
$backtrace = debug_backtrace();
|
263 |
+
$file = $backtrace[4]['file'];
|
264 |
+
$file_abs = str_replace(ABSPATH, '', $file);
|
265 |
+
$line = $backtrace[4]['line'];
|
266 |
+
$message = empty( $message ) ? '' : ' ' . $message;
|
267 |
+
if ( ! is_null( $replacement ) )
|
268 |
+
$message = sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $file_abs, $version, $replacement ) . $message;
|
269 |
+
else
|
270 |
+
$message = sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $file_abs, $version ) . $message;
|
271 |
+
|
272 |
+
$_debug_bar_deprecated_files[$file.':'.$line] = $message;
|
273 |
+
}
|
274 |
+
add_action( 'deprecated_file_included', 'debug_bar_deprecated_file_included', 10, 4 );
|
275 |
+
|
276 |
+
function debug_bar_deprecated_argument_run( $function, $message, $version) {
|
277 |
+
global $_debug_bar_deprecated_arguments;
|
278 |
+
$backtrace = debug_backtrace();
|
279 |
+
$bt = 4;
|
280 |
+
if ( ! isset( $backtrace[4]['file'] ) && 'call_user_func_array' == $backtrace[5]['function'] ) {
|
281 |
+
$bt = 6;
|
282 |
+
}
|
283 |
+
$file = $backtrace[ $bt ]['file'];
|
284 |
+
$line = $backtrace[ $bt ]['line'];
|
285 |
+
|
286 |
+
$_debug_bar_deprecated_arguments[$file.':'.$line] = $message;
|
287 |
+
}
|
288 |
+
add_action( 'deprecated_argument_run', 'debug_bar_deprecated_argument_run', 10, 3 );
|
289 |
?>
|
readme.txt
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
=== Debug Bar ===
|
2 |
-
Contributors: wordpressdotorg, ryan
|
3 |
Tags: debug
|
4 |
Tested up to: 3.1
|
5 |
-
Stable tag: 0.
|
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.
|
@@ -13,11 +13,19 @@ Adds a debug menu to the admin bar that shows query, cache, and other helpful de
|
|
13 |
|
14 |
== Upgrade Notice ==
|
15 |
|
|
|
|
|
|
|
|
|
16 |
= 0.1 =
|
17 |
Initial Release
|
18 |
|
19 |
== Changelog ==
|
20 |
|
|
|
|
|
|
|
|
|
21 |
= 0.1 =
|
22 |
Initial Release
|
23 |
|
1 |
=== Debug Bar ===
|
2 |
+
Contributors: wordpressdotorg, ryan, westi
|
3 |
Tags: debug
|
4 |
Tested up to: 3.1
|
5 |
+
Stable tag: 0.2
|
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.
|
13 |
|
14 |
== Upgrade Notice ==
|
15 |
|
16 |
+
= 0.2 =
|
17 |
+
Added PHP Notice / Warning tracking
|
18 |
+
Added deprecated function usage tracking
|
19 |
+
|
20 |
= 0.1 =
|
21 |
Initial Release
|
22 |
|
23 |
== Changelog ==
|
24 |
|
25 |
+
= 0.2 =
|
26 |
+
Added PHP Notice / Warning tracking
|
27 |
+
Added deprecated function usage tracking
|
28 |
+
|
29 |
= 0.1 =
|
30 |
Initial Release
|
31 |
|