Version Description
- Introduce sortable columns for database query times and numbers
- Display the queried object in the Request panel
- Fix the admin menu behaviour when viewing QM output
- Fixes for output buffering and AJAX requests
- Several bits of code cleanup
Download this release
Release Info
Developer | johnbillion |
Plugin | Query Monitor |
Version | 2.6.4 |
Comparing to | |
See all releases |
Code changes from version 2.6.3 to 2.6.4
- Collector.php +1 -32
- assets/query-monitor.css +50 -10
- assets/query-monitor.js +162 -4
- collectors/db_queries.php +0 -3
- collectors/request.php +13 -8
- dispatchers/Headers.php +1 -1
- dispatchers/Html.php +10 -2
- output/Html.php +41 -0
- output/html/admin.php +2 -2
- output/html/db_callers.php +5 -7
- output/html/db_components.php +5 -7
- output/html/db_queries.php +14 -11
- output/html/http.php +1 -4
- output/html/overview.php +5 -23
- output/html/php_errors.php +1 -1
- output/html/request.php +18 -0
- query-monitor.php +2 -8
- readme.txt +9 -1
Collector.php
CHANGED
@@ -24,34 +24,7 @@ abstract class QM_Collector {
|
|
24 |
return "qm-{$this->id}";
|
25 |
}
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
return wp_parse_args( $args, array(
|
30 |
-
'id' => "query-monitor-{$this->id}",
|
31 |
-
'href' => '#' . $this->id()
|
32 |
-
) );
|
33 |
-
|
34 |
-
}
|
35 |
-
|
36 |
-
public function name() {
|
37 |
-
return null;
|
38 |
-
}
|
39 |
-
|
40 |
-
protected function build_filter( $name, array $values ) {
|
41 |
-
|
42 |
-
usort( $values, 'strcasecmp' );
|
43 |
-
|
44 |
-
$out = '<select id="qm-filter-' . esc_attr( $this->id . '-' . $name ) . '" class="qm-filter" data-filter="' . esc_attr( $this->id . '-' . $name ) . '">';
|
45 |
-
$out .= '<option value="">' . _x( 'All', '"All" option for filters', 'query-monitor' ) . '</option>';
|
46 |
-
|
47 |
-
foreach ( $values as $value )
|
48 |
-
$out .= '<option value="' . esc_attr( $value ) . '">' . esc_html( $value ) . '</option>';
|
49 |
-
|
50 |
-
$out .= '</select>';
|
51 |
-
|
52 |
-
return $out;
|
53 |
-
|
54 |
-
}
|
55 |
|
56 |
public static function timer_stop_float() {
|
57 |
global $timestart;
|
@@ -71,8 +44,4 @@ abstract class QM_Collector {
|
|
71 |
|
72 |
public function process() {}
|
73 |
|
74 |
-
public function output_html( array $args, array $data ) {}
|
75 |
-
|
76 |
-
public function output_headers( array $args, array $data ) {}
|
77 |
-
|
78 |
}
|
24 |
return "qm-{$this->id}";
|
25 |
}
|
26 |
|
27 |
+
abstract public function name();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
public static function timer_stop_float() {
|
30 |
global $timestart;
|
44 |
|
45 |
public function process() {}
|
46 |
|
|
|
|
|
|
|
|
|
47 |
}
|
assets/query-monitor.css
CHANGED
@@ -183,6 +183,12 @@ body:not(.iframe).sticky-menu #qm {
|
|
183 |
margin-left: 160px !important;
|
184 |
}
|
185 |
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
body:not(.iframe).sticky-menu.folded #qm {
|
187 |
margin-left: 36px !important;
|
188 |
}
|
@@ -192,6 +198,10 @@ body:not(.iframe).sticky-menu.folded #qm {
|
|
192 |
max-width: 100em;
|
193 |
}
|
194 |
|
|
|
|
|
|
|
|
|
195 |
#qm-wrapper > p {
|
196 |
color: #777 !important;
|
197 |
font: 13px/15px 'Open Sans', Arial !important;
|
@@ -256,18 +266,29 @@ body:not(.iframe).sticky-menu.folded #qm {
|
|
256 |
color: #444 !important;
|
257 |
}
|
258 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
259 |
.qm-inner {
|
260 |
border-collapse: collapse !important;
|
261 |
margin: 0 !important;
|
262 |
background: #fff !important;
|
263 |
color: #555 !important;
|
264 |
-
border:
|
|
|
265 |
}
|
266 |
|
267 |
-
.qm-inner
|
268 |
-
|
269 |
-
border: none !important;
|
270 |
-
padding: 1px 0 !important;
|
271 |
}
|
272 |
|
273 |
.qm ul {
|
@@ -371,11 +392,6 @@ body:not(.iframe).sticky-menu.folded #qm {
|
|
371 |
text-align: right !important;
|
372 |
}
|
373 |
|
374 |
-
.qm td.qm-var {
|
375 |
-
text-align: right !important;
|
376 |
-
padding: 1px 1em 1px 0 !important;
|
377 |
-
}
|
378 |
-
|
379 |
/* Filters */
|
380 |
|
381 |
select.qm-filter {
|
@@ -407,6 +423,30 @@ select.qm-filter {
|
|
407 |
display: none !important;
|
408 |
}
|
409 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
410 |
/* RTL */
|
411 |
|
412 |
html[dir="rtl"] .qm-ltr {
|
183 |
margin-left: 160px !important;
|
184 |
}
|
185 |
|
186 |
+
@media all and (max-width: 900px) {
|
187 |
+
body:not(.iframe).sticky-menu #qm {
|
188 |
+
margin-left: 36px !important;
|
189 |
+
}
|
190 |
+
}
|
191 |
+
|
192 |
body:not(.iframe).sticky-menu.folded #qm {
|
193 |
margin-left: 36px !important;
|
194 |
}
|
198 |
max-width: 100em;
|
199 |
}
|
200 |
|
201 |
+
body.js #qm-wrapper {
|
202 |
+
max-width: none;
|
203 |
+
}
|
204 |
+
|
205 |
#qm-wrapper > p {
|
206 |
color: #777 !important;
|
207 |
font: 13px/15px 'Open Sans', Arial !important;
|
266 |
color: #444 !important;
|
267 |
}
|
268 |
|
269 |
+
.qm th.qm-num {
|
270 |
+
width: 4em !important;
|
271 |
+
}
|
272 |
+
|
273 |
+
.qm .qm-inner-toggle {
|
274 |
+
padding: 5px 8px 4px !important;
|
275 |
+
}
|
276 |
+
|
277 |
+
.qm-has-inner .qm-toggled > table {
|
278 |
+
border-top: 1px solid #eee !important;
|
279 |
+
}
|
280 |
+
|
281 |
.qm-inner {
|
282 |
border-collapse: collapse !important;
|
283 |
margin: 0 !important;
|
284 |
background: #fff !important;
|
285 |
color: #555 !important;
|
286 |
+
border-style: hidden !important;
|
287 |
+
width: 100% !important;
|
288 |
}
|
289 |
|
290 |
+
.qm td.qm-has-inner {
|
291 |
+
padding: 0 !important;
|
|
|
|
|
292 |
}
|
293 |
|
294 |
.qm ul {
|
392 |
text-align: right !important;
|
393 |
}
|
394 |
|
|
|
|
|
|
|
|
|
|
|
395 |
/* Filters */
|
396 |
|
397 |
select.qm-filter {
|
423 |
display: none !important;
|
424 |
}
|
425 |
|
426 |
+
/* Sorters */
|
427 |
+
|
428 |
+
.qm .qm-sort-controls {
|
429 |
+
display: block !important;
|
430 |
+
margin-top: 4px !important;
|
431 |
+
text-align: center !important;
|
432 |
+
}
|
433 |
+
|
434 |
+
.qm .qm-sort {
|
435 |
+
color: #ddd !important;
|
436 |
+
display: block !important;
|
437 |
+
font-size: 11px !important;
|
438 |
+
line-height: 9px !important;
|
439 |
+
text-decoration: none !important;
|
440 |
+
}
|
441 |
+
|
442 |
+
.qm .qm-sort:hover,
|
443 |
+
.qm .qm-sort:focus,
|
444 |
+
.qm .qm-sorted-asc .qm-sort-asc,
|
445 |
+
.qm .qm-sorted-desc .qm-sort-desc {
|
446 |
+
color: #888 !important;
|
447 |
+
text-decoration: none !important;
|
448 |
+
}
|
449 |
+
|
450 |
/* RTL */
|
451 |
|
452 |
html[dir="rtl"] .qm-ltr {
|
assets/query-monitor.js
CHANGED
@@ -56,6 +56,8 @@ jQuery( function($) {
|
|
56 |
if ( !window.qm )
|
57 |
return;
|
58 |
|
|
|
|
|
59 |
if ( $('#wp-admin-bar-query-monitor').length ) {
|
60 |
|
61 |
var container = document.createDocumentFragment();
|
@@ -88,6 +90,9 @@ jQuery( function($) {
|
|
88 |
$('#wp-admin-bar-query-monitor ul').append(container);
|
89 |
|
90 |
$('#wp-admin-bar-query-monitor').find('a').on('click',function(e){
|
|
|
|
|
|
|
91 |
$('#qm').show();
|
92 |
});
|
93 |
|
@@ -126,11 +131,11 @@ jQuery( function($) {
|
|
126 |
|
127 |
$('#qm').find('.qm-toggle').on('click',function(e){
|
128 |
var el = $(this);
|
129 |
-
$(this).
|
130 |
-
if ( '
|
131 |
-
el.text('-');
|
132 |
else
|
133 |
-
el.text('
|
134 |
});
|
135 |
e.preventDefault();
|
136 |
});
|
@@ -170,4 +175,157 @@ jQuery( function($) {
|
|
170 |
|
171 |
} );
|
172 |
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
} );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
if ( !window.qm )
|
57 |
return;
|
58 |
|
59 |
+
var is_admin = $('body').hasClass('wp-admin');
|
60 |
+
|
61 |
if ( $('#wp-admin-bar-query-monitor').length ) {
|
62 |
|
63 |
var container = document.createDocumentFragment();
|
90 |
$('#wp-admin-bar-query-monitor ul').append(container);
|
91 |
|
92 |
$('#wp-admin-bar-query-monitor').find('a').on('click',function(e){
|
93 |
+
if ( is_admin ) {
|
94 |
+
$('#wpfooter').css('position','relative');
|
95 |
+
}
|
96 |
$('#qm').show();
|
97 |
});
|
98 |
|
131 |
|
132 |
$('#qm').find('.qm-toggle').on('click',function(e){
|
133 |
var el = $(this);
|
134 |
+
$(this).closest('td').find('.qm-toggled').toggle(0,function(){
|
135 |
+
if ( el.attr('data-off') == el.text() )
|
136 |
+
el.text(el.attr('data-on'));
|
137 |
else
|
138 |
+
el.text(el.attr('data-off'));
|
139 |
});
|
140 |
e.preventDefault();
|
141 |
});
|
175 |
|
176 |
} );
|
177 |
|
178 |
+
if ( is_admin ) {
|
179 |
+
$('#qm').detach().appendTo('#wpwrap');
|
180 |
+
}
|
181 |
+
|
182 |
+
$.qm.tableSort({target: $('.qm-sortable'), debug: false});
|
183 |
+
|
184 |
} );
|
185 |
+
|
186 |
+
/**
|
187 |
+
* This is a modified version of:
|
188 |
+
*
|
189 |
+
* jQuery table-sort v0.1.1
|
190 |
+
* https://github.com/gajus/table-sort
|
191 |
+
*
|
192 |
+
* Licensed under the BSD.
|
193 |
+
* https://github.com/gajus/table-sort/blob/master/LICENSE
|
194 |
+
*
|
195 |
+
* Author: Gajus Kuizinas <g.kuizinas@anuary.com>
|
196 |
+
*/
|
197 |
+
(function ($) {
|
198 |
+
$.qm = $.qm || {};
|
199 |
+
$.qm.tableSort = function (options) {
|
200 |
+
var settings = $.extend({
|
201 |
+
'debug': false
|
202 |
+
}, options);
|
203 |
+
|
204 |
+
// @param object columns NodeList table colums.
|
205 |
+
// @param integer row_width defines the number of columns per row.
|
206 |
+
var table_to_array = function (columns, row_width) {
|
207 |
+
if (settings.debug) {
|
208 |
+
console.time('table to array');
|
209 |
+
}
|
210 |
+
|
211 |
+
columns = Array.prototype.slice.call(columns, 0);
|
212 |
+
|
213 |
+
var rows = [];
|
214 |
+
var row_index = 0;
|
215 |
+
|
216 |
+
for (var i = 0, j = columns.length; i < j; i += row_width) {
|
217 |
+
var row = [];
|
218 |
+
|
219 |
+
for (var k = 0, l = row_width; k < l; k++) {
|
220 |
+
var e = columns[i+k];
|
221 |
+
|
222 |
+
var data = e.dataset.qmSortWeight;
|
223 |
+
|
224 |
+
if (data === undefined) {
|
225 |
+
data = e.textContent || e.innerText;
|
226 |
+
}
|
227 |
+
|
228 |
+
var number = parseFloat(data);
|
229 |
+
|
230 |
+
data = isNaN(number) ? data : number;
|
231 |
+
|
232 |
+
row.push(data);
|
233 |
+
}
|
234 |
+
|
235 |
+
rows.push({index: row_index++, data: row});
|
236 |
+
}
|
237 |
+
|
238 |
+
if (settings.debug) {
|
239 |
+
console.timeEnd('table to array');
|
240 |
+
}
|
241 |
+
|
242 |
+
return rows;
|
243 |
+
};
|
244 |
+
|
245 |
+
if (!settings.target || !settings.target instanceof $) {
|
246 |
+
throw 'Target is not defined or it is not instance of jQuery.';
|
247 |
+
}
|
248 |
+
|
249 |
+
settings.target.each(function () {
|
250 |
+
var table = $(this);
|
251 |
+
|
252 |
+
table.find('.qm-sort').on('click', function (e) {
|
253 |
+
var desc = $(this).hasClass('qm-sort-desc');
|
254 |
+
|
255 |
+
var index = $(this).closest('th').index();
|
256 |
+
|
257 |
+
table.find('th').removeClass('qm-sorted-asc qm-sorted-desc');
|
258 |
+
|
259 |
+
if ( desc )
|
260 |
+
$(this).closest('th').addClass('qm-sorted-desc');
|
261 |
+
else
|
262 |
+
$(this).closest('th').addClass('qm-sorted-asc');
|
263 |
+
|
264 |
+
table.find('tbody:not(.qm-sort-no)').each(function () {
|
265 |
+
var tbody = $(this);
|
266 |
+
|
267 |
+
var rows = this.rows;
|
268 |
+
|
269 |
+
var anomalies = $(rows).has('[colspan]').detach();
|
270 |
+
|
271 |
+
var columns = this.getElementsByTagName('td');
|
272 |
+
|
273 |
+
if (this.data_matrix === undefined) {
|
274 |
+
this.data_matrix = table_to_array(columns, $(rows[0]).find('td').length);
|
275 |
+
}
|
276 |
+
|
277 |
+
var data = this.data_matrix;
|
278 |
+
|
279 |
+
if (settings.debug) {
|
280 |
+
console.time('sort data');
|
281 |
+
}
|
282 |
+
|
283 |
+
data.sort(function (a, b) {
|
284 |
+
if (a.data[index] == b.data[index]) {
|
285 |
+
return 0;
|
286 |
+
}
|
287 |
+
|
288 |
+
return (desc ? a.data[index] > b.data[index] : a.data[index] < b.data[index]) ? -1 : 1;
|
289 |
+
});
|
290 |
+
|
291 |
+
if (settings.debug) {
|
292 |
+
console.timeEnd('sort data');
|
293 |
+
console.time('build table');
|
294 |
+
}
|
295 |
+
|
296 |
+
// Will use this to re-attach the tbody object.
|
297 |
+
var table = tbody.parent();
|
298 |
+
|
299 |
+
// Detach the tbody to prevent unnecassy overhead related
|
300 |
+
// to the browser environment.
|
301 |
+
tbody = tbody.detach();
|
302 |
+
|
303 |
+
// Convert NodeList into an array.
|
304 |
+
rows = Array.prototype.slice.call(rows, 0);
|
305 |
+
|
306 |
+
var last_row = rows[data[data.length-1].index];
|
307 |
+
|
308 |
+
for (var i = 0, j = data.length-1; i < j; i++) {
|
309 |
+
tbody[0].insertBefore(rows[data[i].index], last_row);
|
310 |
+
|
311 |
+
// Restore the index.
|
312 |
+
data[i].index = i;
|
313 |
+
}
|
314 |
+
|
315 |
+
// // Restore the index.
|
316 |
+
data[data.length-1].index = data.length-1;
|
317 |
+
|
318 |
+
tbody.prepend(anomalies);
|
319 |
+
|
320 |
+
table.append(tbody);
|
321 |
+
|
322 |
+
|
323 |
+
if (settings.debug) {
|
324 |
+
console.timeEnd('build table');
|
325 |
+
}
|
326 |
+
});
|
327 |
+
e.preventDefault();
|
328 |
+
});
|
329 |
+
});
|
330 |
+
};
|
331 |
+
})(jQuery);
|
collectors/db_queries.php
CHANGED
@@ -211,9 +211,6 @@ class QM_Collector_DB_Queries extends QM_Collector {
|
|
211 |
|
212 |
}
|
213 |
|
214 |
-
if ( isset( $_REQUEST['qm_sort'] ) and ( 'time' == $_REQUEST['qm_sort'] ) )
|
215 |
-
usort( $rows, 'QM_Util::sort' );
|
216 |
-
|
217 |
$total_qs = count( $rows );
|
218 |
|
219 |
$this->data['total_qs'] += $total_qs;
|
211 |
|
212 |
}
|
213 |
|
|
|
|
|
|
|
214 |
$total_qs = count( $rows );
|
215 |
|
216 |
$this->data['total_qs'] += $total_qs;
|
collectors/request.php
CHANGED
@@ -82,29 +82,34 @@ class QM_Collector_Request extends QM_Collector {
|
|
82 |
case is_a( $qo, 'WP_Post' ):
|
83 |
// Single post
|
84 |
$this->data['queried_object_type'] = 'post';
|
85 |
-
$this->data['
|
86 |
-
|
|
|
|
|
87 |
break;
|
88 |
|
89 |
case is_a( $qo, 'WP_User' ):
|
90 |
// Author archive
|
91 |
$this->data['queried_object_type'] = 'user';
|
92 |
-
$this->data['
|
93 |
-
|
|
|
94 |
break;
|
95 |
|
96 |
case property_exists( $qo, 'term_id' ):
|
97 |
// Term archive
|
98 |
$this->data['queried_object_type'] = 'term';
|
99 |
-
$this->data['
|
100 |
-
|
|
|
101 |
break;
|
102 |
|
103 |
case property_exists( $qo, 'has_archive' ):
|
104 |
// Post type archive
|
105 |
$this->data['queried_object_type'] = 'archive';
|
106 |
-
$this->data['
|
107 |
-
|
|
|
108 |
break;
|
109 |
|
110 |
}
|
82 |
case is_a( $qo, 'WP_Post' ):
|
83 |
// Single post
|
84 |
$this->data['queried_object_type'] = 'post';
|
85 |
+
$this->data['queried_object_title'] = sprintf( __( 'Single %s: #%d', 'query-monitor' ),
|
86 |
+
get_post_type_object( $qo->post_type )->labels->singular_name,
|
87 |
+
$qo->ID
|
88 |
+
);
|
89 |
break;
|
90 |
|
91 |
case is_a( $qo, 'WP_User' ):
|
92 |
// Author archive
|
93 |
$this->data['queried_object_type'] = 'user';
|
94 |
+
$this->data['queried_object_title'] = sprintf( __( 'Author archive: %s', 'query-monitor' ),
|
95 |
+
$qo->user_nicename
|
96 |
+
);
|
97 |
break;
|
98 |
|
99 |
case property_exists( $qo, 'term_id' ):
|
100 |
// Term archive
|
101 |
$this->data['queried_object_type'] = 'term';
|
102 |
+
$this->data['queried_object_title'] = sprintf( __( 'Term archive: %s', 'query-monitor' ),
|
103 |
+
$qo->slug
|
104 |
+
);
|
105 |
break;
|
106 |
|
107 |
case property_exists( $qo, 'has_archive' ):
|
108 |
// Post type archive
|
109 |
$this->data['queried_object_type'] = 'archive';
|
110 |
+
$this->data['queried_object_title'] = sprintf( __( 'Post type archive: %s', 'query-monitor' ),
|
111 |
+
$qo->name
|
112 |
+
);
|
113 |
break;
|
114 |
|
115 |
}
|
dispatchers/Headers.php
CHANGED
@@ -48,7 +48,7 @@ class QM_Dispatcher_Headers extends QM_Dispatcher {
|
|
48 |
public function after_output() {
|
49 |
|
50 |
# flush once, because we're nice
|
51 |
-
if ( ob_get_length() ) {
|
52 |
ob_flush();
|
53 |
}
|
54 |
|
48 |
public function after_output() {
|
49 |
|
50 |
# flush once, because we're nice
|
51 |
+
if ( QM_Util::is_ajax() and ob_get_length() ) {
|
52 |
ob_flush();
|
53 |
}
|
54 |
|
dispatchers/Html.php
CHANGED
@@ -56,8 +56,6 @@ class QM_Dispatcher_Html extends QM_Dispatcher {
|
|
56 |
|
57 |
public function init() {
|
58 |
|
59 |
-
global $wp_locale;
|
60 |
-
|
61 |
if ( ! $this->qm->user_can_view() ) {
|
62 |
return;
|
63 |
}
|
@@ -66,6 +64,16 @@ class QM_Dispatcher_Html extends QM_Dispatcher {
|
|
66 |
define( 'DONOTCACHEPAGE', 1 );
|
67 |
}
|
68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
wp_enqueue_style(
|
70 |
'query-monitor',
|
71 |
$this->qm->plugin_url( 'assets/query-monitor.css' ),
|
56 |
|
57 |
public function init() {
|
58 |
|
|
|
|
|
59 |
if ( ! $this->qm->user_can_view() ) {
|
60 |
return;
|
61 |
}
|
64 |
define( 'DONOTCACHEPAGE', 1 );
|
65 |
}
|
66 |
|
67 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_assets' ) );
|
68 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) );
|
69 |
+
add_action( 'login_enqueue_scripts', array( $this, 'enqueue_assets' ) );
|
70 |
+
|
71 |
+
}
|
72 |
+
|
73 |
+
public function enqueue_assets() {
|
74 |
+
|
75 |
+
global $wp_locale;
|
76 |
+
|
77 |
wp_enqueue_style(
|
78 |
'query-monitor',
|
79 |
$this->qm->plugin_url( 'assets/query-monitor.css' ),
|
output/Html.php
CHANGED
@@ -59,6 +59,39 @@ class QM_Output_Html implements QM_Output {
|
|
59 |
|
60 |
}
|
61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
protected function build_filter( $name, array $values ) {
|
63 |
|
64 |
usort( $values, 'strcasecmp' );
|
@@ -75,6 +108,14 @@ class QM_Output_Html implements QM_Output {
|
|
75 |
|
76 |
}
|
77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
protected function menu( array $args ) {
|
79 |
|
80 |
return array_merge( array(
|
59 |
|
60 |
}
|
61 |
|
62 |
+
public static function output_inner( $vars ) {
|
63 |
+
|
64 |
+
echo '<table cellspacing="0" class="qm-inner">';
|
65 |
+
|
66 |
+
foreach ( $vars as $key => $value ) {
|
67 |
+
echo '<tr>';
|
68 |
+
echo '<td valign="top">' . esc_html( $key ) . '</td>';
|
69 |
+
if ( is_array( $value ) ) {
|
70 |
+
echo '<td valign="top" class="qm-has-inner">';
|
71 |
+
self::output_inner( $value );
|
72 |
+
echo '</td>';
|
73 |
+
} else if ( is_object( $value ) ) {
|
74 |
+
echo '<td valign="top" class="qm-has-inner">';
|
75 |
+
self::output_inner( get_object_vars( $value ) );
|
76 |
+
echo '</td>';
|
77 |
+
} else if ( is_bool( $value ) ) {
|
78 |
+
if ( $value ) {
|
79 |
+
echo '<td valign="top" class="qm-true">true</td>';
|
80 |
+
} else {
|
81 |
+
echo '<td valign="top" class="qm-false">false</td>';
|
82 |
+
}
|
83 |
+
} else {
|
84 |
+
echo '<td valign="top">';
|
85 |
+
echo nl2br( esc_html( $value ) );
|
86 |
+
echo '</td>';
|
87 |
+
}
|
88 |
+
echo '</td>';
|
89 |
+
echo '</tr>';
|
90 |
+
}
|
91 |
+
echo '</table>';
|
92 |
+
|
93 |
+
}
|
94 |
+
|
95 |
protected function build_filter( $name, array $values ) {
|
96 |
|
97 |
usort( $values, 'strcasecmp' );
|
108 |
|
109 |
}
|
110 |
|
111 |
+
protected function build_sorter() {
|
112 |
+
$out = '<span class="qm-sort-controls">';
|
113 |
+
$out .= '<a href="#" class="qm-sort qm-sort-asc">▲</a>';
|
114 |
+
$out .= '<a href="#" class="qm-sort qm-sort-desc">▼</a>';
|
115 |
+
$out .= '</span>';
|
116 |
+
return $out;
|
117 |
+
}
|
118 |
+
|
119 |
protected function menu( array $args ) {
|
120 |
|
121 |
return array_merge( array(
|
output/html/admin.php
CHANGED
@@ -40,13 +40,13 @@ class QM_Output_Html_Admin extends QM_Output_Html {
|
|
40 |
|
41 |
echo '<tr>';
|
42 |
echo '<td class="qm-ltr">get_current_screen()</td>';
|
43 |
-
echo '<td>';
|
44 |
|
45 |
echo '<table class="qm-inner" cellspacing="0">';
|
46 |
echo '<tbody>';
|
47 |
foreach ( $data['current_screen'] as $key => $value ) {
|
48 |
echo '<tr>';
|
49 |
-
echo '<td
|
50 |
echo '<td>' . esc_html( $value ) . '</td>';
|
51 |
echo '</tr>';
|
52 |
}
|
40 |
|
41 |
echo '<tr>';
|
42 |
echo '<td class="qm-ltr">get_current_screen()</td>';
|
43 |
+
echo '<td class="qm-has-inner">';
|
44 |
|
45 |
echo '<table class="qm-inner" cellspacing="0">';
|
46 |
echo '<tbody>';
|
47 |
foreach ( $data['current_screen'] as $key => $value ) {
|
48 |
echo '<tr>';
|
49 |
+
echo '<td>' . esc_html( $key ) . '</td>';
|
50 |
echo '<td>' . esc_html( $value ) . '</td>';
|
51 |
echo '</tr>';
|
52 |
}
|
output/html/db_callers.php
CHANGED
@@ -33,7 +33,7 @@ class QM_Output_Html_DB_Callers extends QM_Output_Html {
|
|
33 |
$span = count( $data['types'] ) + 2;
|
34 |
|
35 |
echo '<div class="qm qm-half" id="' . $this->collector->id() . '">';
|
36 |
-
echo '<table cellspacing="0">';
|
37 |
echo '<thead>';
|
38 |
echo '<tr>';
|
39 |
echo '<th colspan="' . $span . '">' . $this->collector->name() . '</th>';
|
@@ -43,10 +43,10 @@ class QM_Output_Html_DB_Callers extends QM_Output_Html {
|
|
43 |
|
44 |
if ( !empty( $data['types'] ) ) {
|
45 |
foreach ( $data['types'] as $type_name => $type_count )
|
46 |
-
echo '<th>' . $type_name . '</th>';
|
47 |
}
|
48 |
|
49 |
-
echo '<th>' . __( 'Time', 'query-monitor' ) . '</th>';
|
50 |
echo '</tr>';
|
51 |
echo '</thead>';
|
52 |
|
@@ -59,7 +59,6 @@ class QM_Output_Html_DB_Callers extends QM_Output_Html {
|
|
59 |
foreach ( $data['times'] as $caller => $row ) {
|
60 |
$total_time += $row['ltime'];
|
61 |
$stime = number_format_i18n( $row['ltime'], 4 );
|
62 |
-
$ltime = number_format_i18n( $row['ltime'], 10 );
|
63 |
|
64 |
echo '<tr>';
|
65 |
echo "<td valign='top' class='qm-ltr'>{$row['caller']}</td>";
|
@@ -71,7 +70,7 @@ class QM_Output_Html_DB_Callers extends QM_Output_Html {
|
|
71 |
echo "<td valign='top'> </td>";
|
72 |
}
|
73 |
|
74 |
-
echo "<td valign='top'
|
75 |
echo '</tr>';
|
76 |
|
77 |
}
|
@@ -80,7 +79,6 @@ class QM_Output_Html_DB_Callers extends QM_Output_Html {
|
|
80 |
echo '<tfoot>';
|
81 |
|
82 |
$total_stime = number_format_i18n( $total_time, 4 );
|
83 |
-
$total_ltime = number_format_i18n( $total_time, 10 );
|
84 |
|
85 |
echo '<tr>';
|
86 |
echo '<td> </td>';
|
@@ -88,7 +86,7 @@ class QM_Output_Html_DB_Callers extends QM_Output_Html {
|
|
88 |
foreach ( $data['types'] as $type_name => $type_count )
|
89 |
echo '<td>' . number_format_i18n( $type_count ) . '</td>';
|
90 |
|
91 |
-
echo "<td
|
92 |
echo '</tr>';
|
93 |
|
94 |
echo '</tfoot>';
|
33 |
$span = count( $data['types'] ) + 2;
|
34 |
|
35 |
echo '<div class="qm qm-half" id="' . $this->collector->id() . '">';
|
36 |
+
echo '<table cellspacing="0" class="qm-sortable">';
|
37 |
echo '<thead>';
|
38 |
echo '<tr>';
|
39 |
echo '<th colspan="' . $span . '">' . $this->collector->name() . '</th>';
|
43 |
|
44 |
if ( !empty( $data['types'] ) ) {
|
45 |
foreach ( $data['types'] as $type_name => $type_count )
|
46 |
+
echo '<th class="qm-num">' . $type_name . $this->build_sorter() . '</th>';
|
47 |
}
|
48 |
|
49 |
+
echo '<th class="qm-num qm-sorted-desc">' . __( 'Time', 'query-monitor' ) . $this->build_sorter() . '</th>';
|
50 |
echo '</tr>';
|
51 |
echo '</thead>';
|
52 |
|
59 |
foreach ( $data['times'] as $caller => $row ) {
|
60 |
$total_time += $row['ltime'];
|
61 |
$stime = number_format_i18n( $row['ltime'], 4 );
|
|
|
62 |
|
63 |
echo '<tr>';
|
64 |
echo "<td valign='top' class='qm-ltr'>{$row['caller']}</td>";
|
70 |
echo "<td valign='top'> </td>";
|
71 |
}
|
72 |
|
73 |
+
echo "<td valign='top'>{$stime}</td>";
|
74 |
echo '</tr>';
|
75 |
|
76 |
}
|
79 |
echo '<tfoot>';
|
80 |
|
81 |
$total_stime = number_format_i18n( $total_time, 4 );
|
|
|
82 |
|
83 |
echo '<tr>';
|
84 |
echo '<td> </td>';
|
86 |
foreach ( $data['types'] as $type_name => $type_count )
|
87 |
echo '<td>' . number_format_i18n( $type_count ) . '</td>';
|
88 |
|
89 |
+
echo "<td>{$total_stime}</td>";
|
90 |
echo '</tr>';
|
91 |
|
92 |
echo '</tfoot>';
|
output/html/db_components.php
CHANGED
@@ -34,7 +34,7 @@ class QM_Output_Html_DB_Components extends QM_Output_Html {
|
|
34 |
$span = count( $data['types'] ) + 2;
|
35 |
|
36 |
echo '<div class="qm qm-half" id="' . $this->collector->id() . '">';
|
37 |
-
echo '<table cellspacing="0">';
|
38 |
echo '<thead>';
|
39 |
echo '<tr>';
|
40 |
echo '<th colspan="' . $span . '">' . $this->collector->name() . '</th>';
|
@@ -44,10 +44,10 @@ class QM_Output_Html_DB_Components extends QM_Output_Html {
|
|
44 |
|
45 |
if ( !empty( $data['types'] ) ) {
|
46 |
foreach ( $data['types'] as $type_name => $type_count )
|
47 |
-
echo '<th>' . $type_name . '</th>';
|
48 |
}
|
49 |
|
50 |
-
echo '<th>' . __( 'Time', 'query-monitor' ) . '</th>';
|
51 |
echo '</tr>';
|
52 |
echo '</thead>';
|
53 |
|
@@ -61,7 +61,6 @@ class QM_Output_Html_DB_Components extends QM_Output_Html {
|
|
61 |
$total_time += $row['ltime'];
|
62 |
$total_calls += $row['calls'];
|
63 |
$stime = number_format_i18n( $row['ltime'], 4 );
|
64 |
-
$ltime = number_format_i18n( $row['ltime'], 10 );
|
65 |
|
66 |
echo '<tr>';
|
67 |
echo "<td valign='top' class='qm-ltr'>{$row['component']}</td>";
|
@@ -73,7 +72,7 @@ class QM_Output_Html_DB_Components extends QM_Output_Html {
|
|
73 |
echo "<td valign='top'> </td>";
|
74 |
}
|
75 |
|
76 |
-
echo "<td valign='top'
|
77 |
echo '</tr>';
|
78 |
|
79 |
}
|
@@ -82,7 +81,6 @@ class QM_Output_Html_DB_Components extends QM_Output_Html {
|
|
82 |
echo '<tfoot>';
|
83 |
|
84 |
$total_stime = number_format_i18n( $total_time, 4 );
|
85 |
-
$total_ltime = number_format_i18n( $total_time, 10 );
|
86 |
|
87 |
echo '<tr>';
|
88 |
echo '<td> </td>';
|
@@ -90,7 +88,7 @@ class QM_Output_Html_DB_Components extends QM_Output_Html {
|
|
90 |
foreach ( $data['types'] as $type_name => $type_count )
|
91 |
echo '<td>' . number_format_i18n( $type_count ) . '</td>';
|
92 |
|
93 |
-
echo "<td
|
94 |
echo '</tr>';
|
95 |
echo '</tfoot>';
|
96 |
|
34 |
$span = count( $data['types'] ) + 2;
|
35 |
|
36 |
echo '<div class="qm qm-half" id="' . $this->collector->id() . '">';
|
37 |
+
echo '<table cellspacing="0" class="qm-sortable">';
|
38 |
echo '<thead>';
|
39 |
echo '<tr>';
|
40 |
echo '<th colspan="' . $span . '">' . $this->collector->name() . '</th>';
|
44 |
|
45 |
if ( !empty( $data['types'] ) ) {
|
46 |
foreach ( $data['types'] as $type_name => $type_count )
|
47 |
+
echo '<th class="qm-num">' . $type_name . $this->build_sorter() . '</th>';
|
48 |
}
|
49 |
|
50 |
+
echo '<th class="qm-num qm-sorted-desc">' . __( 'Time', 'query-monitor' ) . $this->build_sorter() . '</th>';
|
51 |
echo '</tr>';
|
52 |
echo '</thead>';
|
53 |
|
61 |
$total_time += $row['ltime'];
|
62 |
$total_calls += $row['calls'];
|
63 |
$stime = number_format_i18n( $row['ltime'], 4 );
|
|
|
64 |
|
65 |
echo '<tr>';
|
66 |
echo "<td valign='top' class='qm-ltr'>{$row['component']}</td>";
|
72 |
echo "<td valign='top'> </td>";
|
73 |
}
|
74 |
|
75 |
+
echo "<td valign='top'>{$stime}</td>";
|
76 |
echo '</tr>';
|
77 |
|
78 |
}
|
81 |
echo '<tfoot>';
|
82 |
|
83 |
$total_stime = number_format_i18n( $total_time, 4 );
|
|
|
84 |
|
85 |
echo '<tr>';
|
86 |
echo '<td> </td>';
|
88 |
foreach ( $data['types'] as $type_name => $type_count )
|
89 |
echo '<td>' . number_format_i18n( $type_count ) . '</td>';
|
90 |
|
91 |
+
echo "<td>{$total_stime}</td>";
|
92 |
echo '</tr>';
|
93 |
echo '</tfoot>';
|
94 |
|
output/html/db_queries.php
CHANGED
@@ -17,6 +17,8 @@ GNU General Public License for more details.
|
|
17 |
|
18 |
class QM_Output_Html_DB_Queries extends QM_Output_Html {
|
19 |
|
|
|
|
|
20 |
public function __construct( QM_Collector $collector ) {
|
21 |
parent::__construct( $collector );
|
22 |
add_filter( 'query_monitor_menus', array( $this, 'admin_menu' ), 20 );
|
@@ -114,7 +116,7 @@ class QM_Output_Html_DB_Queries extends QM_Output_Html {
|
|
114 |
if ( isset( $expensive[0]['result'] ) )
|
115 |
echo '<th scope="col">' . __( 'Affected Rows', 'query-monitor' ) . '</th>';
|
116 |
|
117 |
-
echo '<th>' . __( 'Time', 'query-monitor' ) . '</th>';
|
118 |
echo '</tr>';
|
119 |
echo '</thead>';
|
120 |
echo '<tbody>';
|
@@ -132,7 +134,7 @@ class QM_Output_Html_DB_Queries extends QM_Output_Html {
|
|
132 |
|
133 |
$max_exceeded = $db->total_qs > QM_DB_LIMIT;
|
134 |
|
135 |
-
$span =
|
136 |
|
137 |
if ( $db->has_results )
|
138 |
$span++;
|
@@ -140,7 +142,7 @@ class QM_Output_Html_DB_Queries extends QM_Output_Html {
|
|
140 |
$span++;
|
141 |
|
142 |
echo '<div class="qm qm-queries" id="' . $this->collector->id() . '-' . sanitize_title( $name ) . '">';
|
143 |
-
echo '<table cellspacing="0">';
|
144 |
echo '<thead>';
|
145 |
echo '<tr>';
|
146 |
echo '<th colspan="' . $span . '">' . sprintf( __( '%s Queries', 'query-monitor' ), $name ) . '</th>';
|
@@ -165,6 +167,7 @@ class QM_Output_Html_DB_Queries extends QM_Output_Html {
|
|
165 |
}
|
166 |
|
167 |
echo '<tr>';
|
|
|
168 |
echo '<th scope="col">' . __( 'Query', 'query-monitor' ) . $this->build_filter( 'type', array_keys( $db->types ) ) . '</th>';
|
169 |
echo '<th scope="col">' . __( 'Caller', 'query-monitor' ) . $this->build_filter( 'caller', array_keys( $data['times'] ) ) . '</th>';
|
170 |
|
@@ -172,9 +175,9 @@ class QM_Output_Html_DB_Queries extends QM_Output_Html {
|
|
172 |
echo '<th scope="col">' . __( 'Component', 'query-monitor' ) . $this->build_filter( 'component', array_keys( $data['component_times'] ) ) . '</th>';
|
173 |
|
174 |
if ( $db->has_results )
|
175 |
-
echo '<th scope="col">' . __( '
|
176 |
|
177 |
-
echo '<th scope="col">' . __( 'Time', 'query-monitor' ) . '</th>';
|
178 |
echo '</tr>';
|
179 |
echo '</thead>';
|
180 |
|
@@ -182,14 +185,13 @@ class QM_Output_Html_DB_Queries extends QM_Output_Html {
|
|
182 |
|
183 |
echo '<tbody>';
|
184 |
|
185 |
-
foreach ( $db->rows as $
|
186 |
$this->output_query_row( $row, array( 'sql', 'caller', 'component', 'result', 'time' ) );
|
187 |
|
188 |
echo '</tbody>';
|
189 |
echo '<tfoot>';
|
190 |
|
191 |
$total_stime = number_format_i18n( $db->total_time, 4 );
|
192 |
-
$total_ltime = number_format_i18n( $db->total_time, 10 );
|
193 |
|
194 |
echo '<tr class="qm-items-shown qm-hide">';
|
195 |
echo '<td valign="top" colspan="' . ( $span - 1 ) . '">' . sprintf( __( 'Queries in filter: %s', 'query-monitor' ), '<span class="qm-items-number">' . number_format_i18n( $db->total_qs ) . '</span>' ) . '</td>';
|
@@ -198,7 +200,7 @@ class QM_Output_Html_DB_Queries extends QM_Output_Html {
|
|
198 |
|
199 |
echo '<tr>';
|
200 |
echo '<td valign="top" colspan="' . ( $span - 1 ) . '">' . sprintf( __( 'Total Queries: %s', 'query-monitor' ), number_format_i18n( $db->total_qs ) ) . '</td>';
|
201 |
-
echo "<td valign='top'
|
202 |
echo '</tr>';
|
203 |
echo '</tfoot>';
|
204 |
|
@@ -230,7 +232,6 @@ class QM_Output_Html_DB_Queries extends QM_Output_Html {
|
|
230 |
|
231 |
$row_attr = array();
|
232 |
$stime = number_format_i18n( $row['ltime'], 4 );
|
233 |
-
$ltime = number_format_i18n( $row['ltime'], 10 );
|
234 |
$td = $this->collector->is_expensive( $row ) ? ' qm-expensive' : '';
|
235 |
|
236 |
$sql = self::format_sql( $row['sql'] );
|
@@ -264,6 +265,8 @@ class QM_Output_Html_DB_Queries extends QM_Output_Html {
|
|
264 |
|
265 |
echo "<tr{$attr}>";
|
266 |
|
|
|
|
|
267 |
if ( isset( $cols['sql'] ) )
|
268 |
echo "<td valign='top' class='qm-row-sql qm-ltr qm-sql'>{$sql}</td>";
|
269 |
|
@@ -287,7 +290,7 @@ class QM_Output_Html_DB_Queries extends QM_Output_Html {
|
|
287 |
$stack = implode( '<br>', $stack );
|
288 |
|
289 |
if ( !empty( $stack ) ) {
|
290 |
-
echo '<a href="#" class="qm-toggle">+</a>';
|
291 |
echo '<div class="qm-toggled">' . $stack . '</div>';
|
292 |
}
|
293 |
|
@@ -309,7 +312,7 @@ class QM_Output_Html_DB_Queries extends QM_Output_Html {
|
|
309 |
echo $result;
|
310 |
|
311 |
if ( isset( $cols['time'] ) )
|
312 |
-
echo "<td valign='top'
|
313 |
|
314 |
echo '</tr>';
|
315 |
|
17 |
|
18 |
class QM_Output_Html_DB_Queries extends QM_Output_Html {
|
19 |
|
20 |
+
public $query_row = 0;
|
21 |
+
|
22 |
public function __construct( QM_Collector $collector ) {
|
23 |
parent::__construct( $collector );
|
24 |
add_filter( 'query_monitor_menus', array( $this, 'admin_menu' ), 20 );
|
116 |
if ( isset( $expensive[0]['result'] ) )
|
117 |
echo '<th scope="col">' . __( 'Affected Rows', 'query-monitor' ) . '</th>';
|
118 |
|
119 |
+
echo '<th class="qm-num">' . __( 'Time', 'query-monitor' ) . '</th>';
|
120 |
echo '</tr>';
|
121 |
echo '</thead>';
|
122 |
echo '<tbody>';
|
134 |
|
135 |
$max_exceeded = $db->total_qs > QM_DB_LIMIT;
|
136 |
|
137 |
+
$span = 4;
|
138 |
|
139 |
if ( $db->has_results )
|
140 |
$span++;
|
142 |
$span++;
|
143 |
|
144 |
echo '<div class="qm qm-queries" id="' . $this->collector->id() . '-' . sanitize_title( $name ) . '">';
|
145 |
+
echo '<table cellspacing="0" class="qm-sortable">';
|
146 |
echo '<thead>';
|
147 |
echo '<tr>';
|
148 |
echo '<th colspan="' . $span . '">' . sprintf( __( '%s Queries', 'query-monitor' ), $name ) . '</th>';
|
167 |
}
|
168 |
|
169 |
echo '<tr>';
|
170 |
+
echo '<th scope="col" class="qm-sorted-asc"> ' . $this->build_sorter() . '</th>';
|
171 |
echo '<th scope="col">' . __( 'Query', 'query-monitor' ) . $this->build_filter( 'type', array_keys( $db->types ) ) . '</th>';
|
172 |
echo '<th scope="col">' . __( 'Caller', 'query-monitor' ) . $this->build_filter( 'caller', array_keys( $data['times'] ) ) . '</th>';
|
173 |
|
175 |
echo '<th scope="col">' . __( 'Component', 'query-monitor' ) . $this->build_filter( 'component', array_keys( $data['component_times'] ) ) . '</th>';
|
176 |
|
177 |
if ( $db->has_results )
|
178 |
+
echo '<th scope="col">' . __( 'Rows', 'query-monitor' ) . $this->build_sorter() . '</th>';
|
179 |
|
180 |
+
echo '<th scope="col" class="qm-num">' . __( 'Time', 'query-monitor' ) . $this->build_sorter() . '</th>';
|
181 |
echo '</tr>';
|
182 |
echo '</thead>';
|
183 |
|
185 |
|
186 |
echo '<tbody>';
|
187 |
|
188 |
+
foreach ( $db->rows as $row )
|
189 |
$this->output_query_row( $row, array( 'sql', 'caller', 'component', 'result', 'time' ) );
|
190 |
|
191 |
echo '</tbody>';
|
192 |
echo '<tfoot>';
|
193 |
|
194 |
$total_stime = number_format_i18n( $db->total_time, 4 );
|
|
|
195 |
|
196 |
echo '<tr class="qm-items-shown qm-hide">';
|
197 |
echo '<td valign="top" colspan="' . ( $span - 1 ) . '">' . sprintf( __( 'Queries in filter: %s', 'query-monitor' ), '<span class="qm-items-number">' . number_format_i18n( $db->total_qs ) . '</span>' ) . '</td>';
|
200 |
|
201 |
echo '<tr>';
|
202 |
echo '<td valign="top" colspan="' . ( $span - 1 ) . '">' . sprintf( __( 'Total Queries: %s', 'query-monitor' ), number_format_i18n( $db->total_qs ) ) . '</td>';
|
203 |
+
echo "<td valign='top'>{$total_stime}</td>";
|
204 |
echo '</tr>';
|
205 |
echo '</tfoot>';
|
206 |
|
232 |
|
233 |
$row_attr = array();
|
234 |
$stime = number_format_i18n( $row['ltime'], 4 );
|
|
|
235 |
$td = $this->collector->is_expensive( $row ) ? ' qm-expensive' : '';
|
236 |
|
237 |
$sql = self::format_sql( $row['sql'] );
|
265 |
|
266 |
echo "<tr{$attr}>";
|
267 |
|
268 |
+
echo "<td valign='top' class='qm-'>" . ++$this->query_row . "</td>";
|
269 |
+
|
270 |
if ( isset( $cols['sql'] ) )
|
271 |
echo "<td valign='top' class='qm-row-sql qm-ltr qm-sql'>{$sql}</td>";
|
272 |
|
290 |
$stack = implode( '<br>', $stack );
|
291 |
|
292 |
if ( !empty( $stack ) ) {
|
293 |
+
echo '<a href="#" class="qm-toggle" data-on="+" data-off="-">+</a>';
|
294 |
echo '<div class="qm-toggled">' . $stack . '</div>';
|
295 |
}
|
296 |
|
312 |
echo $result;
|
313 |
|
314 |
if ( isset( $cols['time'] ) )
|
315 |
+
echo "<td valign='top' class='qm-row-time{$td}'>{$stime}</td>\n";
|
316 |
|
317 |
echo '</tr>';
|
318 |
|
output/html/http.php
CHANGED
@@ -48,8 +48,6 @@ class QM_Output_Html_HTTP extends QM_Output_Html {
|
|
48 |
echo '<tbody>';
|
49 |
|
50 |
foreach ( $data['http'] as $key => $row ) {
|
51 |
-
$funcs = array();
|
52 |
-
|
53 |
$ltime = $row['ltime'];
|
54 |
$total_time += $ltime;
|
55 |
|
@@ -117,7 +115,6 @@ class QM_Output_Html_HTTP extends QM_Output_Html {
|
|
117 |
echo '<tfoot>';
|
118 |
|
119 |
$total_stime = number_format_i18n( $total_time, 4 );
|
120 |
-
$total_ltime = number_format_i18n( $total_time, 10 );
|
121 |
|
122 |
$vars = ' ';
|
123 |
|
@@ -131,7 +128,7 @@ class QM_Output_Html_HTTP extends QM_Output_Html {
|
|
131 |
|
132 |
echo '<tr>';
|
133 |
echo '<td colspan="6">' . $vars . '</td>';
|
134 |
-
echo "<td
|
135 |
echo '</tr>';
|
136 |
echo '</tfoot>';
|
137 |
|
48 |
echo '<tbody>';
|
49 |
|
50 |
foreach ( $data['http'] as $key => $row ) {
|
|
|
|
|
51 |
$ltime = $row['ltime'];
|
52 |
$total_time += $ltime;
|
53 |
|
115 |
echo '<tfoot>';
|
116 |
|
117 |
$total_stime = number_format_i18n( $total_time, 4 );
|
|
|
118 |
|
119 |
$vars = ' ';
|
120 |
|
128 |
|
129 |
echo '<tr>';
|
130 |
echo '<td colspan="6">' . $vars . '</td>';
|
131 |
+
echo "<td>{$total_stime}</td>";
|
132 |
echo '</tr>';
|
133 |
echo '</tfoot>';
|
134 |
|
output/html/overview.php
CHANGED
@@ -26,45 +26,27 @@ class QM_Output_Html_Overview extends QM_Output_Html {
|
|
26 |
|
27 |
$data = $this->collector->get_data();
|
28 |
|
29 |
-
$http_time = null;
|
30 |
$db_query_num = null;
|
31 |
$db_query_types = array();
|
32 |
# @TODO: make this less derpy:
|
33 |
-
$http = QueryMonitor::get_collector( 'http' );
|
34 |
$db_queries = QueryMonitor::get_collector( 'db_queries' );
|
35 |
-
$time_usage = '';
|
36 |
-
$memory_usage = '';
|
37 |
-
|
38 |
-
if ( $http ) {
|
39 |
-
$http_data = $http->get_data();
|
40 |
-
if ( isset( $http_data['http'] ) ) {
|
41 |
-
foreach ( $http_data['http'] as $row ) {
|
42 |
-
if ( isset( $row['response'] ) )
|
43 |
-
$http_time += ( $row['end'] - $row['start'] );
|
44 |
-
else
|
45 |
-
$http_time += $row['args']['timeout'];
|
46 |
-
}
|
47 |
-
}
|
48 |
-
}
|
49 |
|
50 |
if ( $db_queries ) {
|
51 |
$db_queries_data = $db_queries->get_data();
|
52 |
if ( isset( $db_queries_data['types'] ) ) {
|
53 |
$db_query_num = $db_queries_data['types'];
|
54 |
$db_stime = number_format_i18n( $db_queries_data['total_time'], 4 );
|
55 |
-
$db_ltime = number_format_i18n( $db_queries_data['total_time'], 10 );
|
56 |
}
|
57 |
}
|
58 |
|
59 |
$total_stime = number_format_i18n( $data['time'], 4 );
|
60 |
-
$total_ltime = number_format_i18n( $data['time'], 10 );
|
61 |
|
62 |
echo '<div class="qm" id="' . $this->collector->id() . '">';
|
63 |
echo '<table cellspacing="0">';
|
64 |
|
65 |
-
$memory_usage
|
66 |
|
67 |
-
$time_usage
|
68 |
|
69 |
echo '<thead>';
|
70 |
echo '<tr>';
|
@@ -79,10 +61,10 @@ class QM_Output_Html_Overview extends QM_Output_Html {
|
|
79 |
|
80 |
echo '<tbody>';
|
81 |
echo '<tr>';
|
82 |
-
echo "<td
|
83 |
-
echo '<td
|
84 |
if ( isset( $db_query_num ) ) {
|
85 |
-
echo "<td
|
86 |
echo '<td>';
|
87 |
|
88 |
foreach ( $db_query_num as $type_name => $type_count )
|
26 |
|
27 |
$data = $this->collector->get_data();
|
28 |
|
|
|
29 |
$db_query_num = null;
|
30 |
$db_query_types = array();
|
31 |
# @TODO: make this less derpy:
|
|
|
32 |
$db_queries = QueryMonitor::get_collector( 'db_queries' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
if ( $db_queries ) {
|
35 |
$db_queries_data = $db_queries->get_data();
|
36 |
if ( isset( $db_queries_data['types'] ) ) {
|
37 |
$db_query_num = $db_queries_data['types'];
|
38 |
$db_stime = number_format_i18n( $db_queries_data['total_time'], 4 );
|
|
|
39 |
}
|
40 |
}
|
41 |
|
42 |
$total_stime = number_format_i18n( $data['time'], 4 );
|
|
|
43 |
|
44 |
echo '<div class="qm" id="' . $this->collector->id() . '">';
|
45 |
echo '<table cellspacing="0">';
|
46 |
|
47 |
+
$memory_usage = '<br><span class="qm-info">' . sprintf( __( '%1$s%% of %2$s kB limit', 'query-monitor' ), number_format_i18n( $data['memory_usage'], 1 ), number_format_i18n( $data['memory_limit'] / 1024 ) ) . '</span>';
|
48 |
|
49 |
+
$time_usage = '<br><span class="qm-info">' . sprintf( __( '%1$s%% of %2$ss limit', 'query-monitor' ), number_format_i18n( $data['time_usage'], 1 ), number_format_i18n( $data['time_limit'] ) ) . '</span>';
|
50 |
|
51 |
echo '<thead>';
|
52 |
echo '<tr>';
|
61 |
|
62 |
echo '<tbody>';
|
63 |
echo '<tr>';
|
64 |
+
echo "<td>{$total_stime}{$time_usage}</td>";
|
65 |
+
echo '<td>' . sprintf( __( '%s kB', 'query-monitor' ), number_format_i18n( $data['memory'] / 1024 ) ) . $memory_usage . '</td>';
|
66 |
if ( isset( $db_query_num ) ) {
|
67 |
+
echo "<td>{$db_stime}</td>";
|
68 |
echo '<td>';
|
69 |
|
70 |
foreach ( $db_query_num as $type_name => $type_count )
|
output/html/php_errors.php
CHANGED
@@ -72,7 +72,7 @@ class QM_Output_Html_PHP_Errors extends QM_Output_Html {
|
|
72 |
|
73 |
echo '<td>' . $message . '</td>';
|
74 |
echo '<td>' . number_format_i18n( $error->calls ) . '</td>';
|
75 |
-
echo '<td
|
76 |
echo self::output_filename( $output, $error->file, $error->line );
|
77 |
echo '</td>';
|
78 |
echo '<td class="qm-ltr">' . $stack . '</td>';
|
72 |
|
73 |
echo '<td>' . $message . '</td>';
|
74 |
echo '<td>' . number_format_i18n( $error->calls ) . '</td>';
|
75 |
+
echo '<td>';
|
76 |
echo self::output_filename( $output, $error->file, $error->line );
|
77 |
echo '</td>';
|
78 |
echo '<td class="qm-ltr">' . $stack . '</td>';
|
output/html/request.php
CHANGED
@@ -102,6 +102,24 @@ class QM_Output_Html_Request extends QM_Output_Html {
|
|
102 |
echo '</tr>';
|
103 |
}
|
104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
echo '</tbody>';
|
106 |
echo '</table>';
|
107 |
echo '</div>';
|
102 |
echo '</tr>';
|
103 |
}
|
104 |
|
105 |
+
if ( !empty( $data['queried_object'] ) ) {
|
106 |
+
|
107 |
+
$vars = get_object_vars( $data['queried_object'] );
|
108 |
+
|
109 |
+
echo '<tr>';
|
110 |
+
echo '<td valign="top">' . __( 'Queried Object', 'query-monitor' ) . '</td>';
|
111 |
+
echo '<td valign="top" colspan="2" class="qm-has-inner">';
|
112 |
+
echo '<div class="qm-inner-toggle">' . $data['queried_object_title'] . ' (' . get_class( $data['queried_object'] ) . ' object) (<a href="#" class="qm-toggle" data-on="' . esc_attr__( 'Show', 'query-monitor' ) . '" data-off="' . esc_attr__( 'Hide', 'query-monitor' ) . '">' . __( 'Show', 'query-monitor' ) . '</a>)</div>';
|
113 |
+
|
114 |
+
echo '<div class="qm-toggled">';
|
115 |
+
self::output_inner( $vars );
|
116 |
+
echo '</div>';
|
117 |
+
|
118 |
+
echo '</td>';
|
119 |
+
echo '</tr>';
|
120 |
+
|
121 |
+
}
|
122 |
+
|
123 |
echo '</tbody>';
|
124 |
echo '</table>';
|
125 |
echo '</div>';
|
query-monitor.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/*
|
3 |
Plugin Name: Query Monitor
|
4 |
Description: Monitoring of database queries, hooks, conditionals and more.
|
5 |
-
Version: 2.6.
|
6 |
Plugin URI: https://github.com/johnbillion/query-monitor
|
7 |
Author: John Blackbourn
|
8 |
Author URI: https://johnblackbourn.com/
|
@@ -144,13 +144,7 @@ class QueryMonitor extends QM_Plugin {
|
|
144 |
|
145 |
# Don't process if the minimum required actions haven't fired:
|
146 |
|
147 |
-
if (
|
148 |
-
|
149 |
-
if ( ! did_action( 'init' ) ) {
|
150 |
-
return false;
|
151 |
-
}
|
152 |
-
|
153 |
-
} else if ( is_admin() ) {
|
154 |
|
155 |
if ( ! did_action( 'admin_init' ) ) {
|
156 |
return false;
|
2 |
/*
|
3 |
Plugin Name: Query Monitor
|
4 |
Description: Monitoring of database queries, hooks, conditionals and more.
|
5 |
+
Version: 2.6.4
|
6 |
Plugin URI: https://github.com/johnbillion/query-monitor
|
7 |
Author: John Blackbourn
|
8 |
Author URI: https://johnblackbourn.com/
|
144 |
|
145 |
# Don't process if the minimum required actions haven't fired:
|
146 |
|
147 |
+
if ( is_admin() ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
|
149 |
if ( ! did_action( 'admin_init' ) ) {
|
150 |
return false;
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: johnbillion
|
|
3 |
Tags: debug, debugging, development, developer, performance, profiler, profiling, queries
|
4 |
Requires at least: 3.5
|
5 |
Tested up to: 3.9
|
6 |
-
Stable tag: 2.6.
|
7 |
License: GPLv2 or later
|
8 |
|
9 |
View debugging and performance information on database queries, hooks, conditionals, HTTP requests, redirects and more.
|
@@ -50,6 +50,7 @@ Filtering queries by component or calling function makes it easy to see which pl
|
|
50 |
|
51 |
* Shows **matched rewrite rules** and associated query strings
|
52 |
* Shows **query vars** for the current request, and highlights **custom query vars**
|
|
|
53 |
|
54 |
= HTTP Requests =
|
55 |
|
@@ -142,6 +143,13 @@ No, I do not accept donations. If you like the plugin, I'd love for you to [leav
|
|
142 |
|
143 |
== Changelog ==
|
144 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
= 2.6.3 =
|
146 |
* Clickable stack traces and file names if you've configured Xdebug's `file_link_format` setting
|
147 |
* Show the number of times each PHP error has been triggered
|
3 |
Tags: debug, debugging, development, developer, performance, profiler, profiling, queries
|
4 |
Requires at least: 3.5
|
5 |
Tested up to: 3.9
|
6 |
+
Stable tag: 2.6.4
|
7 |
License: GPLv2 or later
|
8 |
|
9 |
View debugging and performance information on database queries, hooks, conditionals, HTTP requests, redirects and more.
|
50 |
|
51 |
* Shows **matched rewrite rules** and associated query strings
|
52 |
* Shows **query vars** for the current request, and highlights **custom query vars**
|
53 |
+
* Shows the **queried object** details (collapsed by default)
|
54 |
|
55 |
= HTTP Requests =
|
56 |
|
143 |
|
144 |
== Changelog ==
|
145 |
|
146 |
+
= 2.6.4 =
|
147 |
+
* Introduce sortable columns for database query times and numbers
|
148 |
+
* Display the queried object in the Request panel
|
149 |
+
* Fix the admin menu behaviour when viewing QM output
|
150 |
+
* Fixes for output buffering and AJAX requests
|
151 |
+
* Several bits of code cleanup
|
152 |
+
|
153 |
= 2.6.3 =
|
154 |
* Clickable stack traces and file names if you've configured Xdebug's `file_link_format` setting
|
155 |
* Show the number of times each PHP error has been triggered
|