Version Description
Download this release
Release Info
Developer | johnbillion |
Plugin | Query Monitor |
Version | 3.2.2 |
Comparing to | |
See all releases |
Code changes from version 3.2.1 to 3.2.2
- assets/query-monitor-dark.css +16 -1
- assets/query-monitor.css +19 -4
- classes/Activation.php +4 -2
- classes/Dispatcher.php +2 -1
- classes/Timer.php +2 -1
- classes/Util.php +4 -2
- collectors/assets.php +8 -4
- collectors/block_editor.php +35 -17
- collectors/conditionals.php +6 -3
- collectors/db_callers.php +2 -1
- collectors/db_components.php +2 -1
- collectors/db_dupes.php +2 -1
- collectors/environment.php +7 -1
- collectors/hooks.php +5 -2
- composer.json +4 -4
- output/Html.php +1 -1
- output/headers/overview.php +2 -1
- output/headers/php_errors.php +2 -1
- output/headers/redirects.php +2 -1
- output/html/admin.php +5 -1
- output/html/assets.php +12 -5
- output/html/block_editor.php +157 -98
- output/html/caps.php +2 -1
- output/html/conditionals.php +2 -1
- output/html/db_callers.php +4 -2
- output/html/db_components.php +5 -2
- output/html/db_dupes.php +4 -2
- output/html/db_queries.php +7 -4
- output/html/environment.php +2 -1
- output/html/hooks.php +6 -4
- output/html/http.php +2 -1
- output/html/languages.php +2 -1
- output/html/logger.php +2 -1
- output/html/overview.php +2 -1
- output/html/php_errors.php +2 -1
- output/html/request.php +2 -1
- output/html/theme.php +5 -1
- output/html/timing.php +2 -1
- output/html/transients.php +2 -1
- query-monitor.php +1 -1
- readme.txt +26 -82
- wp-content/db.php +2 -0
assets/query-monitor-dark.css
CHANGED
@@ -225,6 +225,14 @@ body.admin-color-light #wp-admin-bar-query-monitor:not(.qm-all-clear):not(:hover
|
|
225 |
background-color: #B9D6FB !important;
|
226 |
color: #bbc8d4 !important;
|
227 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
|
229 |
#query-monitor.qm-show,
|
230 |
#query-monitor.qm-peek {
|
@@ -469,7 +477,7 @@ body.admin-color-light #wp-admin-bar-query-monitor:not(.qm-all-clear):not(:hover
|
|
469 |
min-width: 25em !important;
|
470 |
}
|
471 |
#query-monitor .qm td.qm-row-block-html {
|
472 |
-
max-width:
|
473 |
}
|
474 |
#query-monitor .qm tr.qm-warn td.qm-col-status,
|
475 |
#query-monitor .qm td.qm-url,
|
@@ -586,6 +594,7 @@ body.admin-color-light #wp-admin-bar-query-monitor:not(.qm-all-clear):not(:hover
|
|
586 |
#query-monitor .qm td.qm-false {
|
587 |
color: #999 !important;
|
588 |
}
|
|
|
589 |
#query-monitor .qm code,
|
590 |
#query-monitor .qm .qm-nowrap {
|
591 |
white-space: nowrap !important;
|
@@ -596,6 +605,11 @@ body.admin-color-light #wp-admin-bar-query-monitor:not(.qm-all-clear):not(:hover
|
|
596 |
word-break: break-all !important;
|
597 |
white-space: normal !important;
|
598 |
}
|
|
|
|
|
|
|
|
|
|
|
599 |
#query-monitor .qm .qm-sticky {
|
600 |
position: sticky !important;
|
601 |
top: 36px !important;
|
@@ -613,6 +627,7 @@ body.admin-color-light #wp-admin-bar-query-monitor:not(.qm-all-clear):not(:hover
|
|
613 |
margin-right: 0.75em !important;
|
614 |
margin-left: 0.75em !important;
|
615 |
}
|
|
|
616 |
#query-monitor .qm td .qm-toggled {
|
617 |
display: none;
|
618 |
}
|
225 |
background-color: #B9D6FB !important;
|
226 |
color: #bbc8d4 !important;
|
227 |
}
|
228 |
+
#query-monitor strong,
|
229 |
+
#query-monitor b {
|
230 |
+
font-weight: bold !important;
|
231 |
+
}
|
232 |
+
#query-monitor em,
|
233 |
+
#query-monitor i {
|
234 |
+
font-style: italic !important;
|
235 |
+
}
|
236 |
|
237 |
#query-monitor.qm-show,
|
238 |
#query-monitor.qm-peek {
|
477 |
min-width: 25em !important;
|
478 |
}
|
479 |
#query-monitor .qm td.qm-row-block-html {
|
480 |
+
max-width: 40em !important;
|
481 |
}
|
482 |
#query-monitor .qm tr.qm-warn td.qm-col-status,
|
483 |
#query-monitor .qm td.qm-url,
|
594 |
#query-monitor .qm td.qm-false {
|
595 |
color: #999 !important;
|
596 |
}
|
597 |
+
#query-monitor .qm .qm-num,
|
598 |
#query-monitor .qm code,
|
599 |
#query-monitor .qm .qm-nowrap {
|
600 |
white-space: nowrap !important;
|
605 |
word-break: break-all !important;
|
606 |
white-space: normal !important;
|
607 |
}
|
608 |
+
#query-monitor .qm .qm-pre-wrap code {
|
609 |
+
word-wrap: break-word !important;
|
610 |
+
word-break: break-all !important;
|
611 |
+
white-space: pre-wrap !important;
|
612 |
+
}
|
613 |
#query-monitor .qm .qm-sticky {
|
614 |
position: sticky !important;
|
615 |
top: 36px !important;
|
627 |
margin-right: 0.75em !important;
|
628 |
margin-left: 0.75em !important;
|
629 |
}
|
630 |
+
#query-monitor .qm td.qm-toggled-on .qm-inverse-toggled,
|
631 |
#query-monitor .qm td .qm-toggled {
|
632 |
display: none;
|
633 |
}
|
assets/query-monitor.css
CHANGED
@@ -218,6 +218,14 @@ body.admin-color-light #wp-admin-bar-query-monitor:not(.qm-all-clear):not(:hover
|
|
218 |
background-color: #B9D6FB !important;
|
219 |
color: #222 !important;
|
220 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
221 |
|
222 |
#query-monitor.qm-show,
|
223 |
#query-monitor.qm-peek {
|
@@ -462,7 +470,7 @@ body.admin-color-light #wp-admin-bar-query-monitor:not(.qm-all-clear):not(:hover
|
|
462 |
min-width: 25em !important;
|
463 |
}
|
464 |
#query-monitor .qm td.qm-row-block-html {
|
465 |
-
max-width:
|
466 |
}
|
467 |
#query-monitor .qm tr.qm-warn td.qm-col-status,
|
468 |
#query-monitor .qm td.qm-url,
|
@@ -579,6 +587,7 @@ body.admin-color-light #wp-admin-bar-query-monitor:not(.qm-all-clear):not(:hover
|
|
579 |
#query-monitor .qm td.qm-false {
|
580 |
color: #999 !important;
|
581 |
}
|
|
|
582 |
#query-monitor .qm code,
|
583 |
#query-monitor .qm .qm-nowrap {
|
584 |
white-space: nowrap !important;
|
@@ -589,6 +598,11 @@ body.admin-color-light #wp-admin-bar-query-monitor:not(.qm-all-clear):not(:hover
|
|
589 |
word-break: break-all !important;
|
590 |
white-space: normal !important;
|
591 |
}
|
|
|
|
|
|
|
|
|
|
|
592 |
#query-monitor .qm .qm-sticky {
|
593 |
position: sticky !important;
|
594 |
top: 36px !important;
|
@@ -606,6 +620,7 @@ body.admin-color-light #wp-admin-bar-query-monitor:not(.qm-all-clear):not(:hover
|
|
606 |
margin-right: 0.75em !important;
|
607 |
margin-left: 0.75em !important;
|
608 |
}
|
|
|
609 |
#query-monitor .qm td .qm-toggled {
|
610 |
display: none;
|
611 |
}
|
@@ -665,7 +680,7 @@ body.admin-color-light #wp-admin-bar-query-monitor:not(.qm-all-clear):not(:hover
|
|
665 |
#query-monitor .qm thead tr .qm-warn,
|
666 |
#query-monitor .qm tbody tr .qm-warn {
|
667 |
background-color: #fff0f0 !important;
|
668 |
-
color: #
|
669 |
}
|
670 |
#query-monitor .qm tbody tr th.qm-warn,
|
671 |
#query-monitor .qm tbody tr td.qm-warn,
|
@@ -674,13 +689,13 @@ body.admin-color-light #wp-admin-bar-query-monitor:not(.qm-all-clear):not(:hover
|
|
674 |
background-color: #fff0f0 !important;
|
675 |
box-shadow: inset 0 -1px #ffd6d6 !important;
|
676 |
border-color: #ffd6d6 !important;
|
677 |
-
color: #
|
678 |
}
|
679 |
#query-monitor .qm-non-tabular .qm-warn code,
|
680 |
#query-monitor .qm tbody .qm-warn li,
|
681 |
#query-monitor .qm tbody .qm-warn .qm-info,
|
682 |
#query-monitor .qm tbody .qm-warn code {
|
683 |
-
color: #
|
684 |
background-color: transparent !important;
|
685 |
}
|
686 |
#query-monitor .qm .qm-notice {
|
218 |
background-color: #B9D6FB !important;
|
219 |
color: #222 !important;
|
220 |
}
|
221 |
+
#query-monitor strong,
|
222 |
+
#query-monitor b {
|
223 |
+
font-weight: bold !important;
|
224 |
+
}
|
225 |
+
#query-monitor em,
|
226 |
+
#query-monitor i {
|
227 |
+
font-style: italic !important;
|
228 |
+
}
|
229 |
|
230 |
#query-monitor.qm-show,
|
231 |
#query-monitor.qm-peek {
|
470 |
min-width: 25em !important;
|
471 |
}
|
472 |
#query-monitor .qm td.qm-row-block-html {
|
473 |
+
max-width: 40em !important;
|
474 |
}
|
475 |
#query-monitor .qm tr.qm-warn td.qm-col-status,
|
476 |
#query-monitor .qm td.qm-url,
|
587 |
#query-monitor .qm td.qm-false {
|
588 |
color: #999 !important;
|
589 |
}
|
590 |
+
#query-monitor .qm .qm-num,
|
591 |
#query-monitor .qm code,
|
592 |
#query-monitor .qm .qm-nowrap {
|
593 |
white-space: nowrap !important;
|
598 |
word-break: break-all !important;
|
599 |
white-space: normal !important;
|
600 |
}
|
601 |
+
#query-monitor .qm .qm-pre-wrap code {
|
602 |
+
word-wrap: break-word !important;
|
603 |
+
word-break: break-all !important;
|
604 |
+
white-space: pre-wrap !important;
|
605 |
+
}
|
606 |
#query-monitor .qm .qm-sticky {
|
607 |
position: sticky !important;
|
608 |
top: 36px !important;
|
620 |
margin-right: 0.75em !important;
|
621 |
margin-left: 0.75em !important;
|
622 |
}
|
623 |
+
#query-monitor .qm td.qm-toggled-on .qm-inverse-toggled,
|
624 |
#query-monitor .qm td .qm-toggled {
|
625 |
display: none;
|
626 |
}
|
680 |
#query-monitor .qm thead tr .qm-warn,
|
681 |
#query-monitor .qm tbody tr .qm-warn {
|
682 |
background-color: #fff0f0 !important;
|
683 |
+
color: #a00 !important;
|
684 |
}
|
685 |
#query-monitor .qm tbody tr th.qm-warn,
|
686 |
#query-monitor .qm tbody tr td.qm-warn,
|
689 |
background-color: #fff0f0 !important;
|
690 |
box-shadow: inset 0 -1px #ffd6d6 !important;
|
691 |
border-color: #ffd6d6 !important;
|
692 |
+
color: #a00 !important;
|
693 |
}
|
694 |
#query-monitor .qm-non-tabular .qm-warn code,
|
695 |
#query-monitor .qm tbody .qm-warn li,
|
696 |
#query-monitor .qm tbody .qm-warn .qm-info,
|
697 |
#query-monitor .qm tbody .qm-warn code {
|
698 |
+
color: #a00 !important;
|
699 |
background-color: transparent !important;
|
700 |
}
|
701 |
#query-monitor .qm .qm-notice {
|
classes/Activation.php
CHANGED
@@ -29,8 +29,9 @@ class QM_Activation extends QM_Plugin {
|
|
29 |
}
|
30 |
|
31 |
public function activate( $sitewide = false ) {
|
|
|
32 |
|
33 |
-
if ( ! file_exists( $db
|
34 |
@symlink( plugin_dir_path( $this->file ) . 'wp-content/db.php', $db ); // @codingStandardsIgnoreLine
|
35 |
}
|
36 |
|
@@ -43,9 +44,10 @@ class QM_Activation extends QM_Plugin {
|
|
43 |
}
|
44 |
|
45 |
public function deactivate() {
|
|
|
46 |
|
47 |
// Remove legacy capability handling:
|
48 |
-
if ( $admins
|
49 |
$admins->remove_cap( 'view_query_monitor' );
|
50 |
}
|
51 |
|
29 |
}
|
30 |
|
31 |
public function activate( $sitewide = false ) {
|
32 |
+
$db = WP_CONTENT_DIR . '/db.php';
|
33 |
|
34 |
+
if ( ! file_exists( $db ) && function_exists( 'symlink' ) ) {
|
35 |
@symlink( plugin_dir_path( $this->file ) . 'wp-content/db.php', $db ); // @codingStandardsIgnoreLine
|
36 |
}
|
37 |
|
44 |
}
|
45 |
|
46 |
public function deactivate() {
|
47 |
+
$admins = QM_Util::get_admins();
|
48 |
|
49 |
// Remove legacy capability handling:
|
50 |
+
if ( $admins ) {
|
51 |
$admins->remove_cap( 'view_query_monitor' );
|
52 |
}
|
53 |
|
classes/Dispatcher.php
CHANGED
@@ -108,7 +108,8 @@ abstract class QM_Dispatcher {
|
|
108 |
}
|
109 |
|
110 |
public static function verify_cookie( $value ) {
|
111 |
-
|
|
|
112 |
return user_can( $old_user_id, 'view_query_monitor' );
|
113 |
}
|
114 |
return false;
|
108 |
}
|
109 |
|
110 |
public static function verify_cookie( $value ) {
|
111 |
+
$old_user_id = wp_validate_auth_cookie( $value, 'logged_in' );
|
112 |
+
if ( $old_user_id ) {
|
113 |
return user_can( $old_user_id, 'view_query_monitor' );
|
114 |
}
|
115 |
return false;
|
classes/Timer.php
CHANGED
@@ -65,7 +65,8 @@ class QM_Timer {
|
|
65 |
$lap['time_used'] = $lap['time'] - $prev['time'];
|
66 |
$lap['memory_used'] = $lap['memory'] - $prev['memory'];
|
67 |
|
68 |
-
$laps[ $lap_id ] = $
|
|
|
69 |
|
70 |
}
|
71 |
|
65 |
$lap['time_used'] = $lap['time'] - $prev['time'];
|
66 |
$lap['memory_used'] = $lap['memory'] - $prev['memory'];
|
67 |
|
68 |
+
$laps[ $lap_id ] = $lap;
|
69 |
+
$prev = $lap;
|
70 |
|
71 |
}
|
72 |
|
classes/Util.php
CHANGED
@@ -179,8 +179,9 @@ class QM_Util {
|
|
179 |
break;
|
180 |
}
|
181 |
|
182 |
-
|
183 |
|
|
|
184 |
}
|
185 |
|
186 |
public static function populate_callback( array $callback ) {
|
@@ -323,7 +324,8 @@ class QM_Util {
|
|
323 |
}
|
324 |
|
325 |
public static function get_query_type( $sql ) {
|
326 |
-
$sql
|
|
|
327 |
|
328 |
if ( 0 === strpos( $sql, '/*' ) ) {
|
329 |
// Strip out leading comments such as `/*NO_SELECT_FOUND_ROWS*/` before calculating the query type
|
179 |
break;
|
180 |
}
|
181 |
|
182 |
+
self::$file_components[ $file ] = (object) compact( 'type', 'name', 'context' );
|
183 |
|
184 |
+
return self::$file_components[ $file ];
|
185 |
}
|
186 |
|
187 |
public static function populate_callback( array $callback ) {
|
324 |
}
|
325 |
|
326 |
public static function get_query_type( $sql ) {
|
327 |
+
$sql = trim( $sql );
|
328 |
+
$type = $sql;
|
329 |
|
330 |
if ( 0 === strpos( $sql, '/*' ) ) {
|
331 |
// Strip out leading comments such as `/*NO_SELECT_FOUND_ROWS*/` before calculating the query type
|
collectors/assets.php
CHANGED
@@ -62,7 +62,8 @@ class QM_Collector_Assets extends QM_Collector {
|
|
62 |
|
63 |
if ( ! empty( $broken ) ) {
|
64 |
foreach ( $broken as $key => $handle ) {
|
65 |
-
|
|
|
66 |
$broken = array_merge( $broken, self::get_broken_dependencies( $item, $raw ) );
|
67 |
} else {
|
68 |
unset( $broken[ $key ] );
|
@@ -79,7 +80,8 @@ class QM_Collector_Assets extends QM_Collector {
|
|
79 |
$this->data['missing'][ $type ] = array_unique( $missing );
|
80 |
foreach ( $this->data['missing'][ $type ] as $handle ) {
|
81 |
$raw->add( $handle, false );
|
82 |
-
|
|
|
83 |
unset( $raw->done[ $key ] );
|
84 |
}
|
85 |
}
|
@@ -91,7 +93,8 @@ class QM_Collector_Assets extends QM_Collector {
|
|
91 |
$broken = array();
|
92 |
|
93 |
foreach ( $item->deps as $handle ) {
|
94 |
-
|
|
|
95 |
$broken = array_merge( $broken, self::get_broken_dependencies( $dep, $dependencies ) );
|
96 |
} else {
|
97 |
$broken[] = $item->handle;
|
@@ -106,7 +109,8 @@ class QM_Collector_Assets extends QM_Collector {
|
|
106 |
$handles = array_unique( array_merge( $dependencies->queue, $dependencies->done ) );
|
107 |
|
108 |
foreach ( $handles as $handle ) {
|
109 |
-
|
|
|
110 |
if ( in_array( $dependency->handle, $item->deps, true ) ) {
|
111 |
$dependents[] = $handle;
|
112 |
}
|
62 |
|
63 |
if ( ! empty( $broken ) ) {
|
64 |
foreach ( $broken as $key => $handle ) {
|
65 |
+
$item = $raw->query( $handle );
|
66 |
+
if ( $item ) {
|
67 |
$broken = array_merge( $broken, self::get_broken_dependencies( $item, $raw ) );
|
68 |
} else {
|
69 |
unset( $broken[ $key ] );
|
80 |
$this->data['missing'][ $type ] = array_unique( $missing );
|
81 |
foreach ( $this->data['missing'][ $type ] as $handle ) {
|
82 |
$raw->add( $handle, false );
|
83 |
+
$key = array_search( $handle, $raw->done, true );
|
84 |
+
if ( false !== $key ) {
|
85 |
unset( $raw->done[ $key ] );
|
86 |
}
|
87 |
}
|
93 |
$broken = array();
|
94 |
|
95 |
foreach ( $item->deps as $handle ) {
|
96 |
+
$dep = $dependencies->query( $handle );
|
97 |
+
if ( $dep ) {
|
98 |
$broken = array_merge( $broken, self::get_broken_dependencies( $dep, $dependencies ) );
|
99 |
} else {
|
100 |
$broken[] = $item->handle;
|
109 |
$handles = array_unique( array_merge( $dependencies->queue, $dependencies->done ) );
|
110 |
|
111 |
foreach ( $handles as $handle ) {
|
112 |
+
$item = $dependencies->query( $handle );
|
113 |
+
if ( $item ) {
|
114 |
if ( in_array( $dependency->handle, $item->deps, true ) ) {
|
115 |
$dependents[] = $handle;
|
116 |
}
|
collectors/block_editor.php
CHANGED
@@ -8,6 +8,7 @@
|
|
8 |
class QM_Collector_Block_Editor extends QM_Collector {
|
9 |
|
10 |
public $id = 'block_editor';
|
|
|
11 |
|
12 |
public function name() {
|
13 |
return __( 'Blocks', 'query-monitor' );
|
@@ -23,26 +24,43 @@ class QM_Collector_Block_Editor extends QM_Collector {
|
|
23 |
$this->data['post_has_blocks'] = self::wp_has_blocks( get_post()->post_content );
|
24 |
$this->data['post_blocks'] = self::wp_parse_blocks( get_post()->post_content );
|
25 |
$this->data['all_dynamic_blocks'] = self::wp_get_dynamic_block_names();
|
|
|
26 |
|
27 |
if ( $this->data['post_has_blocks'] ) {
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
}
|
|
|
|
|
46 |
}
|
47 |
|
48 |
protected static function wp_block_editor_enabled() {
|
8 |
class QM_Collector_Block_Editor extends QM_Collector {
|
9 |
|
10 |
public $id = 'block_editor';
|
11 |
+
protected static $block_type_registry = null;
|
12 |
|
13 |
public function name() {
|
14 |
return __( 'Blocks', 'query-monitor' );
|
24 |
$this->data['post_has_blocks'] = self::wp_has_blocks( get_post()->post_content );
|
25 |
$this->data['post_blocks'] = self::wp_parse_blocks( get_post()->post_content );
|
26 |
$this->data['all_dynamic_blocks'] = self::wp_get_dynamic_block_names();
|
27 |
+
$this->data['total_blocks'] = 0;
|
28 |
|
29 |
if ( $this->data['post_has_blocks'] ) {
|
30 |
+
self::$block_type_registry = WP_Block_Type_Registry::get_instance();
|
31 |
+
|
32 |
+
$this->data['post_blocks'] = array_values( array_filter( array_map( array( $this, 'process_block' ), $this->data['post_blocks'] ) ) );
|
33 |
+
}
|
34 |
+
}
|
35 |
+
|
36 |
+
protected function process_block( array $block ) {
|
37 |
+
// Remove empty blocks caused by two consecutive line breaks in content
|
38 |
+
if ( ! $block['blockName'] && ! trim( $block['innerHTML'] ) ) {
|
39 |
+
return null;
|
40 |
+
}
|
41 |
+
|
42 |
+
$this->data['total_blocks']++;
|
43 |
+
|
44 |
+
$block_type = self::$block_type_registry->get_registered( $block['blockName'] );
|
45 |
+
$dynamic = false;
|
46 |
+
$callback = null;
|
47 |
+
|
48 |
+
if ( $block_type && $block_type->is_dynamic() ) {
|
49 |
+
$dynamic = true;
|
50 |
+
$callback = QM_Util::populate_callback( array(
|
51 |
+
'function' => $block_type->render_callback,
|
52 |
+
) );
|
53 |
+
}
|
54 |
+
|
55 |
+
$block['dynamic'] = $dynamic;
|
56 |
+
$block['callback'] = $callback;
|
57 |
+
$block['size'] = strlen( $block['innerHTML'] );
|
58 |
+
|
59 |
+
if ( ! empty( $block['innerBlocks'] ) ) {
|
60 |
+
$block['innerBlocks'] = array_values( array_filter( array_map( array( $this, 'process_block' ), $block['innerBlocks'] ) ) );
|
61 |
}
|
62 |
+
|
63 |
+
return $block;
|
64 |
}
|
65 |
|
66 |
protected static function wp_block_editor_enabled() {
|
collectors/conditionals.php
CHANGED
@@ -71,15 +71,18 @@ class QM_Collector_Conditionals extends QM_Collector {
|
|
71 |
*/
|
72 |
$conds = apply_filters( 'query_monitor_conditionals', $conds );
|
73 |
|
74 |
-
$true
|
|
|
|
|
75 |
|
76 |
foreach ( $conds as $cond ) {
|
77 |
if ( function_exists( $cond ) ) {
|
78 |
-
|
|
|
79 |
# Special case for is_sticky to prevent PHP notices
|
80 |
$false[] = $cond;
|
81 |
} elseif ( ! is_multisite() && in_array( $cond, array( 'is_main_network', 'is_main_site' ), true ) ) {
|
82 |
-
# Special case for multisite conditionals to prevent them from being annoying on single site
|
83 |
$na[] = $cond;
|
84 |
} else {
|
85 |
if ( call_user_func( $cond ) ) {
|
71 |
*/
|
72 |
$conds = apply_filters( 'query_monitor_conditionals', $conds );
|
73 |
|
74 |
+
$true = array();
|
75 |
+
$false = array();
|
76 |
+
$na = array();
|
77 |
|
78 |
foreach ( $conds as $cond ) {
|
79 |
if ( function_exists( $cond ) ) {
|
80 |
+
$id = null;
|
81 |
+
if ( ( 'is_sticky' === $cond ) && ! get_post( $id ) ) {
|
82 |
# Special case for is_sticky to prevent PHP notices
|
83 |
$false[] = $cond;
|
84 |
} elseif ( ! is_multisite() && in_array( $cond, array( 'is_main_network', 'is_main_site' ), true ) ) {
|
85 |
+
# Special case for multisite conditionals to prevent them from being annoying on single site installations
|
86 |
$na[] = $cond;
|
87 |
} else {
|
88 |
if ( call_user_func( $cond ) ) {
|
collectors/db_callers.php
CHANGED
@@ -14,8 +14,9 @@ class QM_Collector_DB_Callers extends QM_Collector {
|
|
14 |
}
|
15 |
|
16 |
public function process() {
|
|
|
17 |
|
18 |
-
if ( $dbq
|
19 |
if ( isset( $dbq->data['times'] ) ) {
|
20 |
$this->data['times'] = $dbq->data['times'];
|
21 |
QM_Util::rsort( $this->data['times'], 'ltime' );
|
14 |
}
|
15 |
|
16 |
public function process() {
|
17 |
+
$dbq = QM_Collectors::get( 'db_queries' );
|
18 |
|
19 |
+
if ( $dbq ) {
|
20 |
if ( isset( $dbq->data['times'] ) ) {
|
21 |
$this->data['times'] = $dbq->data['times'];
|
22 |
QM_Util::rsort( $this->data['times'], 'ltime' );
|
collectors/db_components.php
CHANGED
@@ -14,8 +14,9 @@ class QM_Collector_DB_Components extends QM_Collector {
|
|
14 |
}
|
15 |
|
16 |
public function process() {
|
|
|
17 |
|
18 |
-
if ( $dbq
|
19 |
if ( isset( $dbq->data['component_times'] ) ) {
|
20 |
$this->data['times'] = $dbq->data['component_times'];
|
21 |
QM_Util::rsort( $this->data['times'], 'ltime' );
|
14 |
}
|
15 |
|
16 |
public function process() {
|
17 |
+
$dbq = QM_Collectors::get( 'db_queries' );
|
18 |
|
19 |
+
if ( $dbq ) {
|
20 |
if ( isset( $dbq->data['component_times'] ) ) {
|
21 |
$this->data['times'] = $dbq->data['component_times'];
|
22 |
QM_Util::rsort( $this->data['times'], 'ltime' );
|
collectors/db_dupes.php
CHANGED
@@ -14,8 +14,9 @@ class QM_Collector_DB_Dupes extends QM_Collector {
|
|
14 |
}
|
15 |
|
16 |
public function process() {
|
|
|
17 |
|
18 |
-
if ( ! $dbq
|
19 |
return;
|
20 |
}
|
21 |
if ( ! isset( $dbq->data['dupes'] ) ) {
|
14 |
}
|
15 |
|
16 |
public function process() {
|
17 |
+
$dbq = QM_Collectors::get( 'db_queries' );
|
18 |
|
19 |
+
if ( ! $dbq ) {
|
20 |
return;
|
21 |
}
|
22 |
if ( ! isset( $dbq->data['dupes'] ) ) {
|
collectors/environment.php
CHANGED
@@ -86,7 +86,9 @@ class QM_Collector_Environment extends QM_Collector {
|
|
86 |
'query_cache_type' => 'ON', # Query cache on or off
|
87 |
);
|
88 |
|
89 |
-
|
|
|
|
|
90 |
|
91 |
foreach ( $dbq->db_objects as $id => $db ) {
|
92 |
|
@@ -120,11 +122,15 @@ class QM_Collector_Environment extends QM_Collector {
|
|
120 |
$client = mysqli_get_client_version();
|
121 |
$info = mysqli_get_server_info( $db->dbh );
|
122 |
} else {
|
|
|
|
|
123 |
if ( preg_match( '|[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}|', mysql_get_client_info(), $matches ) ) {
|
124 |
$client = $matches[0];
|
125 |
} else {
|
126 |
$client = null;
|
127 |
}
|
|
|
|
|
128 |
$info = mysql_get_server_info( $db->dbh );
|
129 |
}
|
130 |
|
86 |
'query_cache_type' => 'ON', # Query cache on or off
|
87 |
);
|
88 |
|
89 |
+
$dbq = QM_Collectors::get( 'db_queries' );
|
90 |
+
|
91 |
+
if ( $dbq ) {
|
92 |
|
93 |
foreach ( $dbq->db_objects as $id => $db ) {
|
94 |
|
122 |
$client = mysqli_get_client_version();
|
123 |
$info = mysqli_get_server_info( $db->dbh );
|
124 |
} else {
|
125 |
+
// Please do not report this code as a PHP 7 incompatibility. Observe the surrounding logic.
|
126 |
+
// @codingStandardsIgnoreLine
|
127 |
if ( preg_match( '|[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}|', mysql_get_client_info(), $matches ) ) {
|
128 |
$client = $matches[0];
|
129 |
} else {
|
130 |
$client = null;
|
131 |
}
|
132 |
+
// Please do not report this code as a PHP 7 incompatibility. Observe the surrounding logic.
|
133 |
+
// @codingStandardsIgnoreLine
|
134 |
$info = mysql_get_server_info( $db->dbh );
|
135 |
}
|
136 |
|
collectors/hooks.php
CHANGED
@@ -21,7 +21,9 @@ class QM_Collector_Hooks extends QM_Collector {
|
|
21 |
self::$hide_qm = self::hide_qm();
|
22 |
self::$hide_core = ( defined( 'QM_HIDE_CORE_ACTIONS' ) && QM_HIDE_CORE_ACTIONS );
|
23 |
|
24 |
-
$hooks
|
|
|
|
|
25 |
|
26 |
if ( has_filter( 'all' ) ) {
|
27 |
$hooks['all'] = self::process_action( 'all', $wp_filter, self::$hide_qm, self::$hide_core );
|
@@ -62,7 +64,8 @@ class QM_Collector_Hooks extends QM_Collector {
|
|
62 |
|
63 |
public static function process_action( $name, array $wp_filter, $hide_qm = false, $hide_core = false ) {
|
64 |
|
65 |
-
$actions
|
|
|
66 |
|
67 |
if ( isset( $wp_filter[ $name ] ) ) {
|
68 |
|
21 |
self::$hide_qm = self::hide_qm();
|
22 |
self::$hide_core = ( defined( 'QM_HIDE_CORE_ACTIONS' ) && QM_HIDE_CORE_ACTIONS );
|
23 |
|
24 |
+
$hooks = array();
|
25 |
+
$all_parts = array();
|
26 |
+
$components = array();
|
27 |
|
28 |
if ( has_filter( 'all' ) ) {
|
29 |
$hooks['all'] = self::process_action( 'all', $wp_filter, self::$hide_qm, self::$hide_core );
|
64 |
|
65 |
public static function process_action( $name, array $wp_filter, $hide_qm = false, $hide_core = false ) {
|
66 |
|
67 |
+
$actions = array();
|
68 |
+
$components = array();
|
69 |
|
70 |
if ( isset( $wp_filter[ $name ] ) ) {
|
71 |
|
composer.json
CHANGED
@@ -20,14 +20,14 @@
|
|
20 |
"type": "package",
|
21 |
"package": {
|
22 |
"name": "danieltj27/dark-mode",
|
23 |
-
"version": "3.
|
24 |
"source": {
|
25 |
"type" : "git",
|
26 |
"url" : "git://github.com/danieltj27/Dark-Mode.git",
|
27 |
-
"reference" : "3.
|
28 |
},
|
29 |
"dist": {
|
30 |
-
"url": "https://github.com/danieltj27/Dark-Mode/archive/
|
31 |
"type": "zip"
|
32 |
}
|
33 |
}
|
@@ -41,7 +41,7 @@
|
|
41 |
"dealerdirect/phpcodesniffer-composer-installer": "^0.5.0",
|
42 |
"squizlabs/php_codesniffer": "^3.2",
|
43 |
"phpcompatibility/phpcompatibility-wp": "^2.0",
|
44 |
-
"danieltj27/dark-mode": "3.
|
45 |
"wp-coding-standards/wpcs": "^1.2",
|
46 |
"phpunit/phpunit": "^5"
|
47 |
}
|
20 |
"type": "package",
|
21 |
"package": {
|
22 |
"name": "danieltj27/dark-mode",
|
23 |
+
"version": "3.2",
|
24 |
"source": {
|
25 |
"type" : "git",
|
26 |
"url" : "git://github.com/danieltj27/Dark-Mode.git",
|
27 |
+
"reference" : "3.2"
|
28 |
},
|
29 |
"dist": {
|
30 |
+
"url": "https://github.com/danieltj27/Dark-Mode/archive/31e1407ef72af69bcd5d94cc3c502163547d4898.zip",
|
31 |
"type": "zip"
|
32 |
}
|
33 |
}
|
41 |
"dealerdirect/phpcodesniffer-composer-installer": "^0.5.0",
|
42 |
"squizlabs/php_codesniffer": "^3.2",
|
43 |
"phpcompatibility/phpcompatibility-wp": "^2.0",
|
44 |
+
"danieltj27/dark-mode": "3.2",
|
45 |
"wp-coding-standards/wpcs": "^1.2",
|
46 |
"phpunit/phpunit": "^5"
|
47 |
}
|
output/Html.php
CHANGED
@@ -156,7 +156,7 @@ abstract class QM_Output_Html extends QM_Output {
|
|
156 |
* @param string[] $values Option values for this control.
|
157 |
* @param string $label Label text for the filter control.
|
158 |
* @param array $args {
|
159 |
-
* @type string $
|
160 |
* @type array $prepend Associative array of options to prepend to the list of values.
|
161 |
* }
|
162 |
* @return string Markup for the table filter controls.
|
156 |
* @param string[] $values Option values for this control.
|
157 |
* @param string $label Label text for the filter control.
|
158 |
* @param array $args {
|
159 |
+
* @type string $highlight The name for the `data-` attributes that get highlighted by this control.
|
160 |
* @type array $prepend Associative array of options to prepend to the list of values.
|
161 |
* }
|
162 |
* @return string Markup for the table filter controls.
|
output/headers/overview.php
CHANGED
@@ -41,7 +41,8 @@ class QM_Output_Headers_Overview extends QM_Output_Headers {
|
|
41 |
}
|
42 |
|
43 |
function register_qm_output_headers_overview( array $output, QM_Collectors $collectors ) {
|
44 |
-
|
|
|
45 |
$output['overview'] = new QM_Output_Headers_Overview( $collector );
|
46 |
}
|
47 |
return $output;
|
41 |
}
|
42 |
|
43 |
function register_qm_output_headers_overview( array $output, QM_Collectors $collectors ) {
|
44 |
+
$collector = $collectors::get( 'overview' );
|
45 |
+
if ( $collector ) {
|
46 |
$output['overview'] = new QM_Output_Headers_Overview( $collector );
|
47 |
}
|
48 |
return $output;
|
output/headers/php_errors.php
CHANGED
@@ -53,7 +53,8 @@ class QM_Output_Headers_PHP_Errors extends QM_Output_Headers {
|
|
53 |
}
|
54 |
|
55 |
function register_qm_output_headers_php_errors( array $output, QM_Collectors $collectors ) {
|
56 |
-
|
|
|
57 |
$output['php_errors'] = new QM_Output_Headers_PHP_Errors( $collector );
|
58 |
}
|
59 |
return $output;
|
53 |
}
|
54 |
|
55 |
function register_qm_output_headers_php_errors( array $output, QM_Collectors $collectors ) {
|
56 |
+
$collector = $collectors::get( 'php_errors' );
|
57 |
+
if ( $collector ) {
|
58 |
$output['php_errors'] = new QM_Output_Headers_PHP_Errors( $collector );
|
59 |
}
|
60 |
return $output;
|
output/headers/redirects.php
CHANGED
@@ -23,7 +23,8 @@ class QM_Output_Headers_Redirects extends QM_Output_Headers {
|
|
23 |
}
|
24 |
|
25 |
function register_qm_output_headers_redirects( array $output, QM_Collectors $collectors ) {
|
26 |
-
|
|
|
27 |
$output['redirects'] = new QM_Output_Headers_Redirects( $collector );
|
28 |
}
|
29 |
return $output;
|
23 |
}
|
24 |
|
25 |
function register_qm_output_headers_redirects( array $output, QM_Collectors $collectors ) {
|
26 |
+
$collector = $collectors::get( 'redirects' );
|
27 |
+
if ( $collector ) {
|
28 |
$output['redirects'] = new QM_Output_Headers_Redirects( $collector );
|
29 |
}
|
30 |
return $output;
|
output/html/admin.php
CHANGED
@@ -75,7 +75,11 @@ class QM_Output_Html_Admin extends QM_Output_Html {
|
|
75 |
}
|
76 |
|
77 |
function register_qm_output_html_admin( array $output, QM_Collectors $collectors ) {
|
78 |
-
if ( is_admin()
|
|
|
|
|
|
|
|
|
79 |
$output['response'] = new QM_Output_Html_Admin( $collector );
|
80 |
}
|
81 |
return $output;
|
75 |
}
|
76 |
|
77 |
function register_qm_output_html_admin( array $output, QM_Collectors $collectors ) {
|
78 |
+
if ( ! is_admin() ) {
|
79 |
+
return $output;
|
80 |
+
}
|
81 |
+
$collector = $collectors::get( 'response' );
|
82 |
+
if ( $collector ) {
|
83 |
$output['response'] = new QM_Output_Html_Admin( $collector );
|
84 |
}
|
85 |
return $output;
|
output/html/assets.php
CHANGED
@@ -176,6 +176,11 @@ class QM_Output_Html_Assets extends QM_Output_Html {
|
|
176 |
$data = $this->collector->get_data();
|
177 |
|
178 |
$loader = rtrim( $type, 's' );
|
|
|
|
|
|
|
|
|
|
|
179 |
|
180 |
/**
|
181 |
* Filter the asset loader source.
|
@@ -187,7 +192,7 @@ class QM_Output_Html_Assets extends QM_Output_Html {
|
|
187 |
* @param string $src Script or style loader source path.
|
188 |
* @param string $handle Script or style handle.
|
189 |
*/
|
190 |
-
$source = apply_filters( "{$loader}_loader_src", $
|
191 |
|
192 |
$host = (string) wp_parse_url( $source, PHP_URL_HOST );
|
193 |
$scheme = (string) wp_parse_url( $source, PHP_URL_SCHEME );
|
@@ -207,8 +212,9 @@ class QM_Output_Html_Assets extends QM_Output_Html {
|
|
207 |
}
|
208 |
|
209 |
if ( is_wp_error( $source ) ) {
|
210 |
-
$src
|
211 |
-
|
|
|
212 |
$src .= ' (' . $error_data['src'] . ')';
|
213 |
$host = (string) wp_parse_url( $error_data['src'], PHP_URL_HOST );
|
214 |
}
|
@@ -262,7 +268,7 @@ class QM_Output_Html_Assets extends QM_Output_Html {
|
|
262 |
printf(
|
263 |
'<a href="%s" class="qm-link">%s</a>',
|
264 |
esc_attr( $src ),
|
265 |
-
esc_html( ltrim( str_replace( home_url(), '', $src ), '/' ) )
|
266 |
);
|
267 |
}
|
268 |
echo '</td>';
|
@@ -317,7 +323,8 @@ class QM_Output_Html_Assets extends QM_Output_Html {
|
|
317 |
}
|
318 |
|
319 |
function register_qm_output_html_assets( array $output, QM_Collectors $collectors ) {
|
320 |
-
|
|
|
321 |
$output['assets'] = new QM_Output_Html_Assets( $collector );
|
322 |
}
|
323 |
return $output;
|
176 |
$data = $this->collector->get_data();
|
177 |
|
178 |
$loader = rtrim( $type, 's' );
|
179 |
+
$src = $dependency->src;
|
180 |
+
|
181 |
+
if ( ! empty( $src ) && ! empty( $dependency->ver ) ) {
|
182 |
+
$src = add_query_arg( 'ver', $dependency->ver, $src );
|
183 |
+
}
|
184 |
|
185 |
/**
|
186 |
* Filter the asset loader source.
|
192 |
* @param string $src Script or style loader source path.
|
193 |
* @param string $handle Script or style handle.
|
194 |
*/
|
195 |
+
$source = apply_filters( "{$loader}_loader_src", $src, $dependency->handle );
|
196 |
|
197 |
$host = (string) wp_parse_url( $source, PHP_URL_HOST );
|
198 |
$scheme = (string) wp_parse_url( $source, PHP_URL_SCHEME );
|
212 |
}
|
213 |
|
214 |
if ( is_wp_error( $source ) ) {
|
215 |
+
$src = $source->get_error_message();
|
216 |
+
$error_data = $source->get_error_data();
|
217 |
+
if ( $error_data && isset( $error_data['src'] ) ) {
|
218 |
$src .= ' (' . $error_data['src'] . ')';
|
219 |
$host = (string) wp_parse_url( $error_data['src'], PHP_URL_HOST );
|
220 |
}
|
268 |
printf(
|
269 |
'<a href="%s" class="qm-link">%s</a>',
|
270 |
esc_attr( $src ),
|
271 |
+
esc_html( ltrim( str_replace( home_url(), '', remove_query_arg( 'ver', $src ) ), '/' ) )
|
272 |
);
|
273 |
}
|
274 |
echo '</td>';
|
323 |
}
|
324 |
|
325 |
function register_qm_output_html_assets( array $output, QM_Collectors $collectors ) {
|
326 |
+
$collector = $collectors::get( 'assets' );
|
327 |
+
if ( $collector ) {
|
328 |
$output['assets'] = new QM_Output_Html_Assets( $collector );
|
329 |
}
|
330 |
return $output;
|
output/html/block_editor.php
CHANGED
@@ -14,7 +14,6 @@ class QM_Output_Html_Block_Editor extends QM_Output_Html {
|
|
14 |
|
15 |
public function output() {
|
16 |
$data = $this->collector->get_data();
|
17 |
-
$i = 0;
|
18 |
|
19 |
if ( empty( $data['block_editor_enabled'] ) || empty( $data['post_blocks'] ) ) {
|
20 |
return;
|
@@ -45,132 +44,191 @@ class QM_Output_Html_Block_Editor extends QM_Output_Html {
|
|
45 |
|
46 |
echo '<tbody>';
|
47 |
|
48 |
-
foreach ( $data['post_blocks'] as $block ) {
|
49 |
-
|
|
|
50 |
|
51 |
-
|
52 |
-
if ( ! $block['blockName'] && ! $inner_html ) {
|
53 |
-
continue;
|
54 |
-
}
|
55 |
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
$
|
60 |
-
|
61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
|
63 |
-
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
$block_error = true;
|
68 |
-
$error_message =
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
$error_message = sprintf(
|
75 |
-
/* translators: %1$s: Erroneous post type name, %2$s: WordPress block post type name */
|
76 |
-
esc_html__( 'Referenced post is of type %1$s instead of %2$s.', 'query-monitor' ),
|
77 |
-
'<code>' . esc_html( $reused_type ) . '</code>',
|
78 |
-
'<code>wp_block</code>'
|
79 |
-
);
|
80 |
-
}
|
81 |
}
|
82 |
}
|
|
|
83 |
|
84 |
-
|
85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
}
|
|
|
87 |
|
88 |
-
|
|
|
|
|
89 |
|
90 |
-
|
91 |
|
92 |
-
|
93 |
|
94 |
-
|
95 |
-
echo '<span class="dashicons dashicons-warning" aria-hidden="true"></span>';
|
96 |
-
}
|
97 |
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
echo '<em>' . esc_html__( 'None', 'query-monitor' ) . '</em>';
|
102 |
-
}
|
103 |
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
|
|
108 |
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
|
114 |
-
|
|
|
|
|
|
|
115 |
|
116 |
-
|
117 |
-
if ( $block['attrs'] ) {
|
118 |
-
$json = json_encode( $block['attrs'], JSON_PRETTY_PRINT );
|
119 |
-
echo '<pre>' . esc_html( $json ) . '</pre>';
|
120 |
-
}
|
121 |
-
echo '</td>';
|
122 |
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
|
|
128 |
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
echo '</td>';
|
135 |
-
} else {
|
136 |
-
echo '<td class="qm-nowrap qm-ltr qm-has-toggle' . esc_attr( $class ) . '"><ol class="qm-toggler">';
|
137 |
-
echo self::build_toggler(); // WPCS: XSS ok;
|
138 |
-
echo '<li>';
|
139 |
-
echo self::output_filename( $block['callback']['name'], $block['callback']['file'], $block['callback']['line'] ); // WPCS: XSS ok.
|
140 |
-
echo '</li>';
|
141 |
-
echo '</ol></td>';
|
142 |
-
}
|
143 |
-
} else {
|
144 |
-
echo '<td class="qm-ltr qm-nowrap' . esc_attr( $class ) . '">';
|
145 |
-
echo '<code>' . esc_html( $block['callback']['name'] ) . '</code>';
|
146 |
-
|
147 |
-
if ( isset( $block['callback']['error'] ) ) {
|
148 |
-
echo '<br>';
|
149 |
-
echo esc_html( sprintf(
|
150 |
-
/* translators: %s: Error message text */
|
151 |
-
__( 'Error: %s', 'query-monitor' ),
|
152 |
-
$block['callback']['error']->get_error_message()
|
153 |
-
) );
|
154 |
-
}
|
155 |
|
|
|
|
|
|
|
|
|
|
|
156 |
echo '</td>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
}
|
158 |
} else {
|
159 |
-
echo '<td
|
160 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
|
162 |
-
|
163 |
-
if ( $block['innerHTML'] ) {
|
164 |
-
echo esc_html( $block['innerHTML'] );
|
165 |
}
|
166 |
-
|
|
|
|
|
167 |
|
168 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
}
|
170 |
|
171 |
-
echo '</
|
172 |
|
173 |
-
$
|
|
|
|
|
|
|
|
|
|
|
174 |
}
|
175 |
|
176 |
public function admin_menu( array $menu ) {
|
@@ -190,7 +248,8 @@ class QM_Output_Html_Block_Editor extends QM_Output_Html {
|
|
190 |
}
|
191 |
|
192 |
function register_qm_output_html_block_editor( array $output, QM_Collectors $collectors ) {
|
193 |
-
|
|
|
194 |
$output['block_editor'] = new QM_Output_Html_Block_Editor( $collector );
|
195 |
}
|
196 |
return $output;
|
14 |
|
15 |
public function output() {
|
16 |
$data = $this->collector->get_data();
|
|
|
17 |
|
18 |
if ( empty( $data['block_editor_enabled'] ) || empty( $data['post_blocks'] ) ) {
|
19 |
return;
|
44 |
|
45 |
echo '<tbody>';
|
46 |
|
47 |
+
foreach ( $data['post_blocks'] as $i => $block ) {
|
48 |
+
self::render_block( ++$i, $block, $data );
|
49 |
+
}
|
50 |
|
51 |
+
echo '</tbody>';
|
|
|
|
|
|
|
52 |
|
53 |
+
echo '<tfoot>';
|
54 |
+
echo '<tr>';
|
55 |
+
printf(
|
56 |
+
'<td colspan="5">%1$s</td>',
|
57 |
+
sprintf(
|
58 |
+
/* translators: %s: Total number of content blocks used */
|
59 |
+
esc_html_x( 'Total: %s', 'Content blocks used', 'query-monitor' ),
|
60 |
+
'<span class="qm-items-number">' . esc_html( number_format_i18n( $data['total_blocks'] ) ) . '</span>'
|
61 |
+
)
|
62 |
+
);
|
63 |
+
echo '</tr>';
|
64 |
+
echo '</tfoot>';
|
65 |
|
66 |
+
$this->after_tabular_output();
|
67 |
+
}
|
68 |
+
|
69 |
+
protected static function render_block( $i, array $block, array $data ) {
|
70 |
+
$block_error = ( empty( $block['blockName'] ) && trim( $block['innerHTML'] ) );
|
71 |
+
$row_class = '';
|
72 |
+
$referenced_post = null;
|
73 |
+
$referenced_type = null;
|
74 |
+
$referenced_pto = null;
|
75 |
+
$error_message = null;
|
76 |
+
|
77 |
+
if ( 'core/block' === $block['blockName'] && ! empty( $block['attrs']['ref'] ) ) {
|
78 |
+
$referenced_post = get_post( $block['attrs']['ref'] );
|
79 |
|
80 |
+
if ( ! $referenced_post ) {
|
81 |
+
$block_error = true;
|
82 |
+
$error_message = esc_html__( 'Referenced block does not exist.', 'query-monitor' );
|
83 |
+
} else {
|
84 |
+
$referenced_type = $referenced_post->post_type;
|
85 |
+
$referenced_pto = get_post_type_object( $referenced_type );
|
86 |
+
if ( 'wp_block' !== $referenced_type ) {
|
87 |
$block_error = true;
|
88 |
+
$error_message = sprintf(
|
89 |
+
/* translators: %1$s: Erroneous post type name, %2$s: WordPress block post type name */
|
90 |
+
esc_html__( 'Referenced post is of type %1$s instead of %2$s.', 'query-monitor' ),
|
91 |
+
'<code>' . esc_html( $referenced_type ) . '</code>',
|
92 |
+
'<code>wp_block</code>'
|
93 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
}
|
95 |
}
|
96 |
+
}
|
97 |
|
98 |
+
$media_blocks = array(
|
99 |
+
'core/audio' => 'id',
|
100 |
+
'core/cover-image' => 'id',
|
101 |
+
'core/file' => 'id',
|
102 |
+
'core/image' => 'id',
|
103 |
+
'core/media-text' => 'mediaId', // (╯°□°)╯︵ ┻━┻
|
104 |
+
'core/video' => 'id',
|
105 |
+
);
|
106 |
+
|
107 |
+
if ( isset( $media_blocks[ $block['blockName'] ] ) && ! empty( $block['attrs'][ $media_blocks[ $block['blockName'] ] ] ) ) {
|
108 |
+
$referenced_post = get_post( $block['attrs'][ $media_blocks[ $block['blockName'] ] ] );
|
109 |
+
|
110 |
+
if ( ! $referenced_post ) {
|
111 |
+
$block_error = true;
|
112 |
+
$error_message = esc_html__( 'Referenced media does not exist.', 'query-monitor' );
|
113 |
+
} else {
|
114 |
+
$referenced_type = $referenced_post->post_type;
|
115 |
+
$referenced_pto = get_post_type_object( $referenced_type );
|
116 |
+
if ( 'attachment' !== $referenced_type ) {
|
117 |
+
$block_error = true;
|
118 |
+
$error_message = sprintf(
|
119 |
+
/* translators: %1$s: Erroneous post type name, %2$s: WordPress attachment post type name */
|
120 |
+
esc_html__( 'Referenced media is of type %1$s instead of %2$s.', 'query-monitor' ),
|
121 |
+
'<code>' . esc_html( $referenced_type ) . '</code>',
|
122 |
+
'<code>attachment</code>'
|
123 |
+
);
|
124 |
+
}
|
125 |
}
|
126 |
+
}
|
127 |
|
128 |
+
if ( $block_error ) {
|
129 |
+
$row_class = 'qm-warn';
|
130 |
+
}
|
131 |
|
132 |
+
echo '<tr class="' . esc_attr( $row_class ) . '">';
|
133 |
|
134 |
+
echo '<th scope="row" class="qm-row-num qm-num"><span class="qm-sticky">' . esc_html( $i ) . '</span></th>';
|
135 |
|
136 |
+
echo '<td class="qm-row-block-name"><span class="qm-sticky">';
|
|
|
|
|
137 |
|
138 |
+
if ( $block_error ) {
|
139 |
+
echo '<span class="dashicons dashicons-warning" aria-hidden="true"></span>';
|
140 |
+
}
|
|
|
|
|
141 |
|
142 |
+
if ( $block['blockName'] ) {
|
143 |
+
echo esc_html( $block['blockName'] );
|
144 |
+
} else {
|
145 |
+
echo '<em>' . esc_html__( 'None', 'query-monitor' ) . '</em>';
|
146 |
+
}
|
147 |
|
148 |
+
if ( $error_message ) {
|
149 |
+
echo '<br>';
|
150 |
+
echo $error_message; // WPCS: XSS ok;
|
151 |
+
}
|
152 |
|
153 |
+
if ( ! empty( $referenced_post ) && ! empty( $referenced_pto ) ) {
|
154 |
+
echo '<br>';
|
155 |
+
echo '<a href="' . esc_url( get_edit_post_link( $referenced_post ) ) . '" class="qm-link">' . esc_html( $referenced_pto->labels->edit_item ) . '</a>';
|
156 |
+
}
|
157 |
|
158 |
+
echo '</span></td>';
|
|
|
|
|
|
|
|
|
|
|
159 |
|
160 |
+
echo '<td class="qm-row-block-attrs">';
|
161 |
+
if ( $block['attrs'] ) {
|
162 |
+
$json = json_encode( $block['attrs'], JSON_PRETTY_PRINT );
|
163 |
+
echo '<pre class="qm-pre-wrap"><code>' . esc_html( $json ) . '</code></pre>';
|
164 |
+
}
|
165 |
+
echo '</td>';
|
166 |
|
167 |
+
if ( isset( $block['callback']['error'] ) ) {
|
168 |
+
$class = ' qm-warn';
|
169 |
+
} else {
|
170 |
+
$class = '';
|
171 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
|
173 |
+
if ( $block['dynamic'] ) {
|
174 |
+
if ( isset( $block['callback']['file'] ) ) {
|
175 |
+
if ( self::has_clickable_links() ) {
|
176 |
+
echo '<td class="qm-nowrap qm-ltr' . esc_attr( $class ) . '">';
|
177 |
+
echo self::output_filename( $block['callback']['name'], $block['callback']['file'], $block['callback']['line'] ); // WPCS: XSS ok.
|
178 |
echo '</td>';
|
179 |
+
} else {
|
180 |
+
echo '<td class="qm-nowrap qm-ltr qm-has-toggle' . esc_attr( $class ) . '"><ol class="qm-toggler">';
|
181 |
+
echo self::build_toggler(); // WPCS: XSS ok;
|
182 |
+
echo '<li>';
|
183 |
+
echo self::output_filename( $block['callback']['name'], $block['callback']['file'], $block['callback']['line'] ); // WPCS: XSS ok.
|
184 |
+
echo '</li>';
|
185 |
+
echo '</ol></td>';
|
186 |
}
|
187 |
} else {
|
188 |
+
echo '<td class="qm-ltr qm-nowrap' . esc_attr( $class ) . '">';
|
189 |
+
echo '<code>' . esc_html( $block['callback']['name'] ) . '</code>';
|
190 |
+
|
191 |
+
if ( isset( $block['callback']['error'] ) ) {
|
192 |
+
echo '<br>';
|
193 |
+
echo esc_html( sprintf(
|
194 |
+
/* translators: %s: Error message text */
|
195 |
+
__( 'Error: %s', 'query-monitor' ),
|
196 |
+
$block['callback']['error']->get_error_message()
|
197 |
+
) );
|
198 |
+
}
|
199 |
|
200 |
+
echo '</td>';
|
|
|
|
|
201 |
}
|
202 |
+
} else {
|
203 |
+
echo '<td></td>';
|
204 |
+
}
|
205 |
|
206 |
+
$inner_html = trim( $block['innerHTML'] );
|
207 |
+
|
208 |
+
if ( $block['size'] > 600 ) {
|
209 |
+
echo '<td class="qm-ltr qm-has-toggle qm-row-block-html"><div class="qm-toggler">';
|
210 |
+
echo self::build_toggler(); // WPCS: XSS ok;
|
211 |
+
echo '<div class="qm-inverse-toggled"><pre class="qm-pre-wrap"><code>';
|
212 |
+
echo esc_html( substr( $inner_html, 0, 500 ) ) . '<br><b>…</b>';
|
213 |
+
echo '</code></pre></div>';
|
214 |
+
echo '<div class="qm-toggled"><pre class="qm-pre-wrap"><code>';
|
215 |
+
echo esc_html( $inner_html );
|
216 |
+
echo '</code></pre></div>';
|
217 |
+
echo '</div></td>';
|
218 |
+
} else {
|
219 |
+
echo '<td class="qm-row-block-html"><pre class="qm-pre-wrap"><code>';
|
220 |
+
echo esc_html( $inner_html );
|
221 |
+
echo '</code></pre></td>';
|
222 |
}
|
223 |
|
224 |
+
echo '</tr>';
|
225 |
|
226 |
+
if ( ! empty( $block['innerBlocks'] ) ) {
|
227 |
+
foreach ( $block['innerBlocks'] as $j => $inner_block ) {
|
228 |
+
$x = ++$j;
|
229 |
+
self::render_block( "{$i}-{$x}", $inner_block, $data );
|
230 |
+
}
|
231 |
+
}
|
232 |
}
|
233 |
|
234 |
public function admin_menu( array $menu ) {
|
248 |
}
|
249 |
|
250 |
function register_qm_output_html_block_editor( array $output, QM_Collectors $collectors ) {
|
251 |
+
$collector = $collectors::get( 'block_editor' );
|
252 |
+
if ( $collector ) {
|
253 |
$output['block_editor'] = new QM_Output_Html_Block_Editor( $collector );
|
254 |
}
|
255 |
return $output;
|
output/html/caps.php
CHANGED
@@ -218,7 +218,8 @@ class QM_Output_Html_Caps extends QM_Output_Html {
|
|
218 |
}
|
219 |
|
220 |
function register_qm_output_html_caps( array $output, QM_Collectors $collectors ) {
|
221 |
-
|
|
|
222 |
$output['caps'] = new QM_Output_Html_Caps( $collector );
|
223 |
}
|
224 |
return $output;
|
218 |
}
|
219 |
|
220 |
function register_qm_output_html_caps( array $output, QM_Collectors $collectors ) {
|
221 |
+
$collector = $collectors::get( 'caps' );
|
222 |
+
if ( $collector ) {
|
223 |
$output['caps'] = new QM_Output_Html_Caps( $collector );
|
224 |
}
|
225 |
return $output;
|
output/html/conditionals.php
CHANGED
@@ -77,7 +77,8 @@ class QM_Output_Html_Conditionals extends QM_Output_Html {
|
|
77 |
}
|
78 |
|
79 |
function register_qm_output_html_conditionals( array $output, QM_Collectors $collectors ) {
|
80 |
-
|
|
|
81 |
$output['conditionals'] = new QM_Output_Html_Conditionals( $collector );
|
82 |
}
|
83 |
return $output;
|
77 |
}
|
78 |
|
79 |
function register_qm_output_html_conditionals( array $output, QM_Collectors $collectors ) {
|
80 |
+
$collector = $collectors::get( 'conditionals' );
|
81 |
+
if ( $collector ) {
|
82 |
$output['conditionals'] = new QM_Output_Html_Conditionals( $collector );
|
83 |
}
|
84 |
return $output;
|
output/html/db_callers.php
CHANGED
@@ -93,8 +93,9 @@ class QM_Output_Html_DB_Callers extends QM_Output_Html {
|
|
93 |
}
|
94 |
|
95 |
public function admin_menu( array $menu ) {
|
|
|
96 |
|
97 |
-
if ( $dbq
|
98 |
$dbq_data = $dbq->get_data();
|
99 |
if ( isset( $dbq_data['times'] ) ) {
|
100 |
$menu[] = $this->menu( array(
|
@@ -109,7 +110,8 @@ class QM_Output_Html_DB_Callers extends QM_Output_Html {
|
|
109 |
}
|
110 |
|
111 |
function register_qm_output_html_db_callers( array $output, QM_Collectors $collectors ) {
|
112 |
-
|
|
|
113 |
$output['db_callers'] = new QM_Output_Html_DB_Callers( $collector );
|
114 |
}
|
115 |
return $output;
|
93 |
}
|
94 |
|
95 |
public function admin_menu( array $menu ) {
|
96 |
+
$dbq = QM_Collectors::get( 'db_queries' );
|
97 |
|
98 |
+
if ( $dbq ) {
|
99 |
$dbq_data = $dbq->get_data();
|
100 |
if ( isset( $dbq_data['times'] ) ) {
|
101 |
$menu[] = $this->menu( array(
|
110 |
}
|
111 |
|
112 |
function register_qm_output_html_db_callers( array $output, QM_Collectors $collectors ) {
|
113 |
+
$collector = $collectors::get( 'db_callers' );
|
114 |
+
if ( $collector ) {
|
115 |
$output['db_callers'] = new QM_Output_Html_DB_Callers( $collector );
|
116 |
}
|
117 |
return $output;
|
output/html/db_components.php
CHANGED
@@ -90,7 +90,9 @@ class QM_Output_Html_DB_Components extends QM_Output_Html {
|
|
90 |
return $menu;
|
91 |
}
|
92 |
|
93 |
-
|
|
|
|
|
94 |
$dbq_data = $dbq->get_data();
|
95 |
if ( isset( $dbq_data['component_times'] ) ) {
|
96 |
$menu[] = $this->menu( array(
|
@@ -105,7 +107,8 @@ class QM_Output_Html_DB_Components extends QM_Output_Html {
|
|
105 |
}
|
106 |
|
107 |
function register_qm_output_html_db_components( array $output, QM_Collectors $collectors ) {
|
108 |
-
|
|
|
109 |
$output['db_components'] = new QM_Output_Html_DB_Components( $collector );
|
110 |
}
|
111 |
return $output;
|
90 |
return $menu;
|
91 |
}
|
92 |
|
93 |
+
$dbq = QM_Collectors::get( 'db_queries' );
|
94 |
+
|
95 |
+
if ( $dbq ) {
|
96 |
$dbq_data = $dbq->get_data();
|
97 |
if ( isset( $dbq_data['component_times'] ) ) {
|
98 |
$menu[] = $this->menu( array(
|
107 |
}
|
108 |
|
109 |
function register_qm_output_html_db_components( array $output, QM_Collectors $collectors ) {
|
110 |
+
$collector = $collectors::get( 'db_components' );
|
111 |
+
if ( $collector ) {
|
112 |
$output['db_components'] = new QM_Output_Html_DB_Components( $collector );
|
113 |
}
|
114 |
return $output;
|
output/html/db_dupes.php
CHANGED
@@ -105,8 +105,9 @@ class QM_Output_Html_DB_Dupes extends QM_Output_Html {
|
|
105 |
}
|
106 |
|
107 |
public function admin_menu( array $menu ) {
|
|
|
108 |
|
109 |
-
if ( $dbq
|
110 |
$dbq_data = $dbq->get_data();
|
111 |
if ( isset( $dbq_data['dupes'] ) && count( $dbq_data['dupes'] ) ) {
|
112 |
$menu[] = $this->menu( array(
|
@@ -125,7 +126,8 @@ class QM_Output_Html_DB_Dupes extends QM_Output_Html {
|
|
125 |
}
|
126 |
|
127 |
function register_qm_output_html_db_dupes( array $output, QM_Collectors $collectors ) {
|
128 |
-
|
|
|
129 |
$output['db_dupes'] = new QM_Output_Html_DB_Dupes( $collector );
|
130 |
}
|
131 |
return $output;
|
105 |
}
|
106 |
|
107 |
public function admin_menu( array $menu ) {
|
108 |
+
$dbq = QM_Collectors::get( 'db_dupes' );
|
109 |
|
110 |
+
if ( $dbq ) {
|
111 |
$dbq_data = $dbq->get_data();
|
112 |
if ( isset( $dbq_data['dupes'] ) && count( $dbq_data['dupes'] ) ) {
|
113 |
$menu[] = $this->menu( array(
|
126 |
}
|
127 |
|
128 |
function register_qm_output_html_db_dupes( array $output, QM_Collectors $collectors ) {
|
129 |
+
$collector = $collectors::get( 'db_dupes' );
|
130 |
+
if ( $collector ) {
|
131 |
$output['db_dupes'] = new QM_Output_Html_DB_Dupes( $collector );
|
132 |
}
|
133 |
return $output;
|
output/html/db_queries.php
CHANGED
@@ -469,9 +469,11 @@ class QM_Output_Html_DB_Queries extends QM_Output_Html {
|
|
469 |
|
470 |
public function admin_menu( array $menu ) {
|
471 |
|
472 |
-
$data
|
|
|
|
|
473 |
|
474 |
-
if ( $errors
|
475 |
$menu[] = $this->menu( array(
|
476 |
'id' => 'query-monitor-errors',
|
477 |
'href' => '#qm-query-errors',
|
@@ -482,7 +484,7 @@ class QM_Output_Html_DB_Queries extends QM_Output_Html {
|
|
482 |
) ),
|
483 |
) );
|
484 |
}
|
485 |
-
if ( $expensive
|
486 |
$menu[] = $this->menu( array(
|
487 |
'id' => 'query-monitor-expensive',
|
488 |
'href' => '#qm-query-expensive',
|
@@ -520,7 +522,8 @@ class QM_Output_Html_DB_Queries extends QM_Output_Html {
|
|
520 |
}
|
521 |
|
522 |
function register_qm_output_html_db_queries( array $output, QM_Collectors $collectors ) {
|
523 |
-
|
|
|
524 |
$output['db_queries'] = new QM_Output_Html_DB_Queries( $collector );
|
525 |
}
|
526 |
return $output;
|
469 |
|
470 |
public function admin_menu( array $menu ) {
|
471 |
|
472 |
+
$data = $this->collector->get_data();
|
473 |
+
$errors = $this->collector->get_errors();
|
474 |
+
$expensive = $this->collector->get_expensive();
|
475 |
|
476 |
+
if ( $errors ) {
|
477 |
$menu[] = $this->menu( array(
|
478 |
'id' => 'query-monitor-errors',
|
479 |
'href' => '#qm-query-errors',
|
484 |
) ),
|
485 |
) );
|
486 |
}
|
487 |
+
if ( $expensive ) {
|
488 |
$menu[] = $this->menu( array(
|
489 |
'id' => 'query-monitor-expensive',
|
490 |
'href' => '#qm-query-expensive',
|
522 |
}
|
523 |
|
524 |
function register_qm_output_html_db_queries( array $output, QM_Collectors $collectors ) {
|
525 |
+
$collector = $collectors::get( 'db_queries' );
|
526 |
+
if ( $collector ) {
|
527 |
$output['db_queries'] = new QM_Output_Html_DB_Queries( $collector );
|
528 |
}
|
529 |
return $output;
|
output/html/environment.php
CHANGED
@@ -314,7 +314,8 @@ class QM_Output_Html_Environment extends QM_Output_Html {
|
|
314 |
}
|
315 |
|
316 |
function register_qm_output_html_environment( array $output, QM_Collectors $collectors ) {
|
317 |
-
|
|
|
318 |
$output['environment'] = new QM_Output_Html_Environment( $collector );
|
319 |
}
|
320 |
return $output;
|
314 |
}
|
315 |
|
316 |
function register_qm_output_html_environment( array $output, QM_Collectors $collectors ) {
|
317 |
+
$collector = $collectors::get( 'environment' );
|
318 |
+
if ( $collector ) {
|
319 |
$output['environment'] = new QM_Output_Html_Environment( $collector );
|
320 |
}
|
321 |
return $output;
|
output/html/hooks.php
CHANGED
@@ -95,11 +95,12 @@ class QM_Output_Html_Hooks extends QM_Output_Html {
|
|
95 |
$first = true;
|
96 |
|
97 |
foreach ( $hook['actions'] as $action ) {
|
|
|
|
|
98 |
|
99 |
if ( isset( $action['callback']['component'] ) ) {
|
100 |
-
$component = $
|
101 |
-
|
102 |
-
$component = $subject = '';
|
103 |
}
|
104 |
|
105 |
if ( __( 'Core', 'query-monitor' ) !== $component ) {
|
@@ -189,7 +190,8 @@ class QM_Output_Html_Hooks extends QM_Output_Html {
|
|
189 |
}
|
190 |
|
191 |
function register_qm_output_html_hooks( array $output, QM_Collectors $collectors ) {
|
192 |
-
|
|
|
193 |
$output['hooks'] = new QM_Output_Html_Hooks( $collector );
|
194 |
}
|
195 |
return $output;
|
95 |
$first = true;
|
96 |
|
97 |
foreach ( $hook['actions'] as $action ) {
|
98 |
+
$component = '';
|
99 |
+
$subject = '';
|
100 |
|
101 |
if ( isset( $action['callback']['component'] ) ) {
|
102 |
+
$component = $action['callback']['component']->name;
|
103 |
+
$subject = $component;
|
|
|
104 |
}
|
105 |
|
106 |
if ( __( 'Core', 'query-monitor' ) !== $component ) {
|
190 |
}
|
191 |
|
192 |
function register_qm_output_html_hooks( array $output, QM_Collectors $collectors ) {
|
193 |
+
$collector = $collectors::get( 'hooks' );
|
194 |
+
if ( $collector ) {
|
195 |
$output['hooks'] = new QM_Output_Html_Hooks( $collector );
|
196 |
}
|
197 |
return $output;
|
output/html/http.php
CHANGED
@@ -368,7 +368,8 @@ class QM_Output_Html_HTTP extends QM_Output_Html {
|
|
368 |
}
|
369 |
|
370 |
function register_qm_output_html_http( array $output, QM_Collectors $collectors ) {
|
371 |
-
|
|
|
372 |
$output['http'] = new QM_Output_Html_HTTP( $collector );
|
373 |
}
|
374 |
return $output;
|
368 |
}
|
369 |
|
370 |
function register_qm_output_html_http( array $output, QM_Collectors $collectors ) {
|
371 |
+
$collector = $collectors::get( 'http' );
|
372 |
+
if ( $collector ) {
|
373 |
$output['http'] = new QM_Output_Html_HTTP( $collector );
|
374 |
}
|
375 |
return $output;
|
output/html/languages.php
CHANGED
@@ -96,7 +96,8 @@ class QM_Output_Html_Languages extends QM_Output_Html {
|
|
96 |
}
|
97 |
|
98 |
function register_qm_output_html_languages( array $output, QM_Collectors $collectors ) {
|
99 |
-
|
|
|
100 |
$output['languages'] = new QM_Output_Html_Languages( $collector );
|
101 |
}
|
102 |
return $output;
|
96 |
}
|
97 |
|
98 |
function register_qm_output_html_languages( array $output, QM_Collectors $collectors ) {
|
99 |
+
$collector = $collectors::get( 'languages' );
|
100 |
+
if ( $collector ) {
|
101 |
$output['languages'] = new QM_Output_Html_Languages( $collector );
|
102 |
}
|
103 |
return $output;
|
output/html/logger.php
CHANGED
@@ -156,7 +156,8 @@ class QM_Output_Html_Logger extends QM_Output_Html {
|
|
156 |
}
|
157 |
|
158 |
function register_qm_output_html_logger( array $output, QM_Collectors $collectors ) {
|
159 |
-
|
|
|
160 |
$output['logger'] = new QM_Output_Html_Logger( $collector );
|
161 |
}
|
162 |
return $output;
|
156 |
}
|
157 |
|
158 |
function register_qm_output_html_logger( array $output, QM_Collectors $collectors ) {
|
159 |
+
$collector = $collectors::get( 'logger' );
|
160 |
+
if ( $collector ) {
|
161 |
$output['logger'] = new QM_Output_Html_Logger( $collector );
|
162 |
}
|
163 |
return $output;
|
output/html/overview.php
CHANGED
@@ -244,7 +244,8 @@ class QM_Output_Html_Overview extends QM_Output_Html {
|
|
244 |
}
|
245 |
|
246 |
function register_qm_output_html_overview( array $output, QM_Collectors $collectors ) {
|
247 |
-
|
|
|
248 |
$output['overview'] = new QM_Output_Html_Overview( $collector );
|
249 |
}
|
250 |
return $output;
|
244 |
}
|
245 |
|
246 |
function register_qm_output_html_overview( array $output, QM_Collectors $collectors ) {
|
247 |
+
$collector = $collectors::get( 'overview' );
|
248 |
+
if ( $collector ) {
|
249 |
$output['overview'] = new QM_Output_Html_Overview( $collector );
|
250 |
}
|
251 |
return $output;
|
output/html/php_errors.php
CHANGED
@@ -250,7 +250,8 @@ class QM_Output_Html_PHP_Errors extends QM_Output_Html {
|
|
250 |
}
|
251 |
|
252 |
function register_qm_output_html_php_errors( array $output, QM_Collectors $collectors ) {
|
253 |
-
|
|
|
254 |
$output['php_errors'] = new QM_Output_Html_PHP_Errors( $collector );
|
255 |
}
|
256 |
return $output;
|
250 |
}
|
251 |
|
252 |
function register_qm_output_html_php_errors( array $output, QM_Collectors $collectors ) {
|
253 |
+
$collector = $collectors::get( 'php_errors' );
|
254 |
+
if ( $collector ) {
|
255 |
$output['php_errors'] = new QM_Output_Html_PHP_Errors( $collector );
|
256 |
}
|
257 |
return $output;
|
output/html/request.php
CHANGED
@@ -189,7 +189,8 @@ class QM_Output_Html_Request extends QM_Output_Html {
|
|
189 |
}
|
190 |
|
191 |
function register_qm_output_html_request( array $output, QM_Collectors $collectors ) {
|
192 |
-
|
|
|
193 |
$output['request'] = new QM_Output_Html_Request( $collector );
|
194 |
}
|
195 |
return $output;
|
189 |
}
|
190 |
|
191 |
function register_qm_output_html_request( array $output, QM_Collectors $collectors ) {
|
192 |
+
$collector = $collectors::get( 'request' );
|
193 |
+
if ( $collector ) {
|
194 |
$output['request'] = new QM_Output_Html_Request( $collector );
|
195 |
}
|
196 |
return $output;
|
output/html/theme.php
CHANGED
@@ -165,7 +165,11 @@ class QM_Output_Html_Theme extends QM_Output_Html {
|
|
165 |
}
|
166 |
|
167 |
function register_qm_output_html_theme( array $output, QM_Collectors $collectors ) {
|
168 |
-
if (
|
|
|
|
|
|
|
|
|
169 |
$output['response'] = new QM_Output_Html_Theme( $collector );
|
170 |
}
|
171 |
return $output;
|
165 |
}
|
166 |
|
167 |
function register_qm_output_html_theme( array $output, QM_Collectors $collectors ) {
|
168 |
+
if ( is_admin() ) {
|
169 |
+
return $output;
|
170 |
+
}
|
171 |
+
$collector = $collectors::get( 'response' );
|
172 |
+
if ( $collector ) {
|
173 |
$output['response'] = new QM_Output_Html_Theme( $collector );
|
174 |
}
|
175 |
return $output;
|
output/html/timing.php
CHANGED
@@ -168,7 +168,8 @@ class QM_Output_Html_Timing extends QM_Output_Html {
|
|
168 |
}
|
169 |
|
170 |
function register_qm_output_html_timing( array $output, QM_Collectors $collectors ) {
|
171 |
-
|
|
|
172 |
$output['timing'] = new QM_Output_Html_Timing( $collector );
|
173 |
}
|
174 |
return $output;
|
168 |
}
|
169 |
|
170 |
function register_qm_output_html_timing( array $output, QM_Collectors $collectors ) {
|
171 |
+
$collector = $collectors::get( 'timing' );
|
172 |
+
if ( $collector ) {
|
173 |
$output['timing'] = new QM_Output_Html_Timing( $collector );
|
174 |
}
|
175 |
return $output;
|
output/html/transients.php
CHANGED
@@ -137,7 +137,8 @@ class QM_Output_Html_Transients extends QM_Output_Html {
|
|
137 |
}
|
138 |
|
139 |
function register_qm_output_html_transients( array $output, QM_Collectors $collectors ) {
|
140 |
-
|
|
|
141 |
$output['transients'] = new QM_Output_Html_Transients( $collector );
|
142 |
}
|
143 |
return $output;
|
137 |
}
|
138 |
|
139 |
function register_qm_output_html_transients( array $output, QM_Collectors $collectors ) {
|
140 |
+
$collector = $collectors::get( 'transients' );
|
141 |
+
if ( $collector ) {
|
142 |
$output['transients'] = new QM_Output_Html_Transients( $collector );
|
143 |
}
|
144 |
return $output;
|
query-monitor.php
CHANGED
@@ -10,7 +10,7 @@
|
|
10 |
*
|
11 |
* Plugin Name: Query Monitor
|
12 |
* Description: The Developer Tools Panel for WordPress.
|
13 |
-
* Version: 3.2.
|
14 |
* Plugin URI: https://querymonitor.com/
|
15 |
* Author: John Blackbourn & contributors
|
16 |
* Author URI: https://querymonitor.com/
|
10 |
*
|
11 |
* Plugin Name: Query Monitor
|
12 |
* Description: The Developer Tools Panel for WordPress.
|
13 |
+
* Version: 3.2.2
|
14 |
* Plugin URI: https://querymonitor.com/
|
15 |
* Author: John Blackbourn & contributors
|
16 |
* Author URI: https://querymonitor.com/
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: johnbillion
|
|
3 |
Tags: debug, debug-bar, debugging, development, developer, performance, profiler, queries, query monitor, rest-api
|
4 |
Requires at least: 3.7
|
5 |
Tested up to: 5.0
|
6 |
-
Stable tag: 3.2.
|
7 |
License: GPLv2 or later
|
8 |
Requires PHP: 5.3
|
9 |
|
@@ -11,92 +11,38 @@ Query Monitor is the developer tools panel for WordPress.
|
|
11 |
|
12 |
== Description ==
|
13 |
|
14 |
-
Query Monitor is the developer tools panel for WordPress. It
|
15 |
|
16 |
-
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
Here's an overview of some of what's shown:
|
21 |
-
|
22 |
-
= Database Queries =
|
23 |
-
|
24 |
-
* Shows all database queries performed on the current request
|
25 |
-
* Shows notifications for slow queries, duplicate queries, and queries with errors
|
26 |
-
* Filter queries by query type (`SELECT`, `UPDATE`, `DELETE`, etc)
|
27 |
-
* Filter queries by component (WordPress core, Plugin X, Plugin Y, theme)
|
28 |
-
* Filter queries by calling function
|
29 |
-
* View aggregate query information grouped by component, calling function, and type
|
30 |
-
* Super advanced: Supports multiple instances of wpdb on one page (more info in the FAQ)
|
31 |
-
|
32 |
-
Filtering queries by component or calling function makes it easy to see which plugins, themes, or functions are making the most (or the slowest) database queries.
|
33 |
-
|
34 |
-
= Hooks =
|
35 |
-
|
36 |
-
* Shows all hooks fired on the current request, along with hooked actions, their priorities, and their components
|
37 |
-
* Filter actions by component (WordPress core, Plugin X, Plugin Y, theme)
|
38 |
-
|
39 |
-
= Theme =
|
40 |
-
|
41 |
-
* Shows the template filename for the current request
|
42 |
-
* Shows the complete template hierarchy for the current request (WordPress 4.7+)
|
43 |
-
* Shows all template parts used on the current request
|
44 |
-
|
45 |
-
= PHP Errors =
|
46 |
-
|
47 |
-
* PHP errors (warnings, notices, stricts, and deprecated) are presented nicely along with their component and call stack
|
48 |
-
* Shows an easily visible warning in the admin toolbar
|
49 |
-
|
50 |
-
= Block Content =
|
51 |
-
|
52 |
-
* Post content blocks and associated information (when using WordPress 5.0+ or the Gutenberg plugin)
|
53 |
-
|
54 |
-
= Request =
|
55 |
-
|
56 |
-
* Shows query vars for the current request, and highlights custom query vars
|
57 |
-
* Shows all matched rewrite rules and associated query strings
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
* Shows all enqueued scripts and styles on the current request, along with their URL and version
|
62 |
-
* Shows their dependencies and dependents, and displays an alert for any broken dependencies
|
63 |
-
|
64 |
-
= Languages =
|
65 |
-
|
66 |
-
* Shows language settings and text domains
|
67 |
-
* Shows the MO files for each text domain and which ones were loaded or not
|
68 |
-
|
69 |
-
= HTTP Requests =
|
70 |
-
|
71 |
-
* Shows all HTTP requests performed on the current request (as long as they use WordPress' HTTP API)
|
72 |
-
* Shows the response code, call stack, component, timeout, and time taken
|
73 |
-
* Highlights erroneous responses, such as failed requests and anything without a `200` response code
|
74 |
-
|
75 |
-
= User Capability Checks =
|
76 |
-
|
77 |
-
* Shows every user capability check that is performed on the page, along with the result and any parameters passed along with the capability check.
|
78 |
-
|
79 |
-
= Redirects =
|
80 |
-
|
81 |
-
* Whenever a redirect occurs, Query Monitor adds an `X-QM-Redirect` HTTP header containing the call stack, so you can use your favourite HTTP inspector or browser developer tools to easily trace where a redirect has come from
|
82 |
-
|
83 |
-
= Ajax =
|
84 |
-
|
85 |
-
The response from any jQuery Ajax request on the page will contain various debugging information in its headers. Any errors also get output to the developer console. No hooking required.
|
86 |
-
|
87 |
-
Currently this includes PHP errors and some overview information such as memory usage, but this will be built upon in future versions.
|
88 |
|
89 |
-
|
90 |
|
91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
|
93 |
-
|
94 |
|
95 |
-
|
|
|
|
|
96 |
|
97 |
-
By default, Query Monitor's output is only shown to Administrators on single-site
|
98 |
|
99 |
-
In addition to this, you can set an authentication cookie which allows you to view Query Monitor output when you're not logged in (or if you're logged in as a non-
|
100 |
|
101 |
= Privacy Statement =
|
102 |
|
@@ -118,9 +64,9 @@ Query Monitor does not persistently store any of the data that it collects. It d
|
|
118 |
|
119 |
= Who can see Query Monitor's output? =
|
120 |
|
121 |
-
By default, Query Monitor's output is only shown to Administrators on single-site
|
122 |
|
123 |
-
In addition to this, you can set an authentication cookie which allows you to view Query Monitor output when you're not logged in (or if you're logged in as a non-
|
124 |
|
125 |
= Does Query Monitor itself impact the page generation time or memory usage? =
|
126 |
|
@@ -144,8 +90,6 @@ Please use [the issue tracker on Query Monitor's GitHub repo](https://github.com
|
|
144 |
|
145 |
Yep! You just need to add `define( 'WPCOM_VIP_QM_ENABLE', true );` to your `vip-config/vip-config.php` file.
|
146 |
|
147 |
-
(It's not available on standard WordPress.com VIP though.)
|
148 |
-
|
149 |
= I'm using multiple instances of `wpdb`. How do I get my additional instances to show up in Query Monitor? =
|
150 |
|
151 |
You'll need to hook into the `qm/collect/db_objects` filter and add an item to the array with your connection name as the key and the `wpdb` instance as the value. Your `wpdb` instance will then show up as a separate panel, and the query time and query count will show up separately in the admin toolbar menu. Aggregate information (queries by caller and component) will not be separated.
|
3 |
Tags: debug, debug-bar, debugging, development, developer, performance, profiler, queries, query monitor, rest-api
|
4 |
Requires at least: 3.7
|
5 |
Tested up to: 5.0
|
6 |
+
Stable tag: 3.2.2
|
7 |
License: GPLv2 or later
|
8 |
Requires PHP: 5.3
|
9 |
|
11 |
|
12 |
== Description ==
|
13 |
|
14 |
+
Query Monitor is the developer tools panel for WordPress. It enables debugging of database queries, PHP errors, hooks and actions, block editor blocks, enqueued scripts and stylesheets, HTTP API calls, and more.
|
15 |
|
16 |
+
It includes some advanced features such as debugging of Ajax calls, REST API calls, and user capability checks. It includes the ability to narrow down much of its output by plugin or theme, allowing you to quickly determine poorly performing plugins, themes, or functions.
|
17 |
|
18 |
+
Query Monitor focuses heavily on presenting its information in a useful manner, for example by showing aggregate database queries grouped by the plugins, themes, or functions that are responsible for them. It adds an admin toolbar menu showing an overview of the current page, with complete debugging information shown in panels once you select a menu item.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
+
For complete information, please see [the Query Monitor website](https://querymonitor.com/).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
+
Here's an overview of what's shown for each page load:
|
23 |
|
24 |
+
* Database queries, including notifications for slow, duplicate, or erroneous queries. Allows filtering by query type (`SELECT`, `UPDATE`, `DELETE`, etc), responsible component (plugin, theme, WordPress core), and calling function, and provides separate aggregate views for each.
|
25 |
+
* The template filename, the complete template hierarchy, and names of all template parts used.
|
26 |
+
* PHP errors presented nicely along with their responsible component and call stack, and a visible warning in the admin toolbar.
|
27 |
+
* Blocks and associated properties in post content when using WordPress 5.0+ or the Gutenberg plugin.
|
28 |
+
* Matched rewrite rules, associated query strings, and query vars.
|
29 |
+
* Enqueued scripts and stylesheets, along with their dependencies, dependents, and alerts for broken dependencies.
|
30 |
+
* Language settings and loaded translation files (MO files) for each text domain.
|
31 |
+
* HTTP API requests, with response code, responsible component, and time taken, with alerts for failed or erroneous requests.
|
32 |
+
* User capability checks, along with the result and any parameters passed to the capability check.
|
33 |
+
* Environment information, including detailed information about PHP, the database, WordPress, and the web server.
|
34 |
+
* The values of all WordPress conditional functions such as `is_single()`, `is_home()`, etc.
|
35 |
+
* Transients that were updated.
|
36 |
|
37 |
+
In addition:
|
38 |
|
39 |
+
* Whenever a redirect occurs, Query Monitor adds an HTTP header containing the call stack, so you can use your favourite HTTP inspector or browser developer tools to trace what triggered the redirect.
|
40 |
+
* The response from any jQuery-initiated Ajax request on the page will contain various debugging information in its headers. PHP errors also get output to the browser's developer console.
|
41 |
+
* The response from an authenticated WordPress REST API request will contain various debugging information in its headers, as long as the authenticated user has permission to view Query Monitor's output.
|
42 |
|
43 |
+
By default, Query Monitor's output is only shown to Administrators on single-site installations, and Super Admins on Multisite installations.
|
44 |
|
45 |
+
In addition to this, you can set an authentication cookie which allows you to view Query Monitor output when you're not logged in (or if you're logged in as a non-Administrator). See the Settings panel for details.
|
46 |
|
47 |
= Privacy Statement =
|
48 |
|
64 |
|
65 |
= Who can see Query Monitor's output? =
|
66 |
|
67 |
+
By default, Query Monitor's output is only shown to Administrators on single-site installations, and Super Admins on Multisite installations.
|
68 |
|
69 |
+
In addition to this, you can set an authentication cookie which allows you to view Query Monitor output when you're not logged in (or if you're logged in as a non-Administrator). See the Settings panel for details.
|
70 |
|
71 |
= Does Query Monitor itself impact the page generation time or memory usage? =
|
72 |
|
90 |
|
91 |
Yep! You just need to add `define( 'WPCOM_VIP_QM_ENABLE', true );` to your `vip-config/vip-config.php` file.
|
92 |
|
|
|
|
|
93 |
= I'm using multiple instances of `wpdb`. How do I get my additional instances to show up in Query Monitor? =
|
94 |
|
95 |
You'll need to hook into the `qm/collect/db_objects` filter and add an item to the array with your connection name as the key and the `wpdb` instance as the value. Your `wpdb` instance will then show up as a separate panel, and the query time and query count will show up separately in the admin toolbar menu. Aggregate information (queries by caller and component) will not be separated.
|
wp-content/db.php
CHANGED
@@ -120,6 +120,8 @@ class QM_DB extends wpdb {
|
|
120 |
}
|
121 |
} else {
|
122 |
if ( is_resource( $this->dbh ) ) {
|
|
|
|
|
123 |
$code = mysql_errno( $this->dbh );
|
124 |
}
|
125 |
}
|
120 |
}
|
121 |
} else {
|
122 |
if ( is_resource( $this->dbh ) ) {
|
123 |
+
// Please do not report this code as a PHP 7 incompatibility. Observe the surrounding logic.
|
124 |
+
// @codingStandardsIgnoreLine
|
125 |
$code = mysql_errno( $this->dbh );
|
126 |
}
|
127 |
}
|