Version Description
- Fix some PHP 5.2 compatibility issues introduced in 2.6.9; More tweaks to the CSS so QM avoids being covered up by the admin menu.
=
Download this release
Release Info
Developer | johnbillion |
Plugin | Query Monitor |
Version | 2.6.10 |
Comparing to | |
See all releases |
Code changes from version 2.6.9 to 2.6.10
- Dispatcher.php +33 -0
- Util.php +22 -0
- assets/query-monitor.css +7 -13
- assets/query-monitor.js +16 -6
- collectors/assets.php +12 -11
- collectors/authentication.php +0 -104
- dispatchers/Headers.php +3 -9
- dispatchers/Html.php +84 -10
- output/html/assets.php +14 -1
- output/html/authentication.php +0 -62
- query-monitor.php +5 -33
- readme.txt +13 -4
Dispatcher.php
CHANGED
@@ -19,6 +19,11 @@ abstract class QM_Dispatcher {
|
|
19 |
|
20 |
public function __construct( QM_Plugin $qm ) {
|
21 |
$this->qm = $qm;
|
|
|
|
|
|
|
|
|
|
|
22 |
}
|
23 |
|
24 |
abstract public function is_active();
|
@@ -37,6 +42,34 @@ abstract class QM_Dispatcher {
|
|
37 |
|
38 |
abstract public function get_outputter( QM_Collector $collector );
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
public function output( QM_Collector $collector ) {
|
41 |
|
42 |
$filter = 'query_monitor_output_' . $this->id . '_' . $collector->id;
|
19 |
|
20 |
public function __construct( QM_Plugin $qm ) {
|
21 |
$this->qm = $qm;
|
22 |
+
|
23 |
+
if ( !defined( 'QM_COOKIE' ) ) {
|
24 |
+
define( 'QM_COOKIE', 'query_monitor_' . COOKIEHASH );
|
25 |
+
}
|
26 |
+
|
27 |
}
|
28 |
|
29 |
abstract public function is_active();
|
42 |
|
43 |
abstract public function get_outputter( QM_Collector $collector );
|
44 |
|
45 |
+
public function user_can_view() {
|
46 |
+
|
47 |
+
if ( !did_action( 'plugins_loaded' ) ) {
|
48 |
+
return false;
|
49 |
+
}
|
50 |
+
|
51 |
+
if ( current_user_can( 'view_query_monitor' ) ) {
|
52 |
+
return true;
|
53 |
+
}
|
54 |
+
|
55 |
+
return $this->user_verified();
|
56 |
+
|
57 |
+
}
|
58 |
+
|
59 |
+
public function user_verified() {
|
60 |
+
if ( isset( $_COOKIE[QM_COOKIE] ) ) {
|
61 |
+
return $this->verify_cookie( stripslashes( $_COOKIE[QM_COOKIE] ) );
|
62 |
+
}
|
63 |
+
return false;
|
64 |
+
}
|
65 |
+
|
66 |
+
public static function verify_cookie( $value ) {
|
67 |
+
if ( $old_user_id = wp_validate_auth_cookie( $value, 'logged_in' ) ) {
|
68 |
+
return user_can( $old_user_id, 'view_query_monitor' );
|
69 |
+
}
|
70 |
+
return false;
|
71 |
+
}
|
72 |
+
|
73 |
public function output( QM_Collector $collector ) {
|
74 |
|
75 |
$filter = 'query_monitor_output_' . $this->id . '_' . $collector->id;
|
Util.php
CHANGED
@@ -200,5 +200,27 @@ class QM_Util {
|
|
200 |
return ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
201 |
}
|
202 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
203 |
}
|
204 |
}
|
200 |
return ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
201 |
}
|
202 |
|
203 |
+
public static function include_files( $path ) {
|
204 |
+
|
205 |
+
if ( class_exists( 'DirectoryIterator' ) and method_exists( 'DirectoryIterator', 'getExtension' ) ) {
|
206 |
+
|
207 |
+
$output_iterator = new DirectoryIterator( $path );
|
208 |
+
|
209 |
+
foreach ( $output_iterator as $output ) {
|
210 |
+
if ( $output->getExtension() === 'php' ) {
|
211 |
+
include $output->getPathname();
|
212 |
+
}
|
213 |
+
}
|
214 |
+
|
215 |
+
} else {
|
216 |
+
|
217 |
+
foreach ( glob( sprintf( '%s/*.php', $path ) ) as $file ) {
|
218 |
+
include $file;
|
219 |
+
}
|
220 |
+
|
221 |
+
}
|
222 |
+
|
223 |
+
}
|
224 |
+
|
225 |
}
|
226 |
}
|
assets/query-monitor.css
CHANGED
@@ -142,28 +142,22 @@ GNU General Public License for more details.
|
|
142 |
height: 0 !important;
|
143 |
}
|
144 |
|
145 |
-
body
|
146 |
margin: 0 0 0 160px !important;
|
147 |
}
|
148 |
|
149 |
-
body
|
150 |
-
body:not(.iframe).wp-admin.folded #qm {
|
151 |
margin-left: 36px !important;
|
152 |
}
|
153 |
|
154 |
@media screen and (max-width: 782px) {
|
155 |
-
body
|
156 |
margin-left: 0 !important;
|
157 |
}
|
158 |
}
|
159 |
|
160 |
#qm-wrapper {
|
161 |
margin: 0 auto;
|
162 |
-
max-width: 100em;
|
163 |
-
}
|
164 |
-
|
165 |
-
body.js #qm-wrapper {
|
166 |
-
max-width: none;
|
167 |
}
|
168 |
|
169 |
#qm-wrapper > p {
|
@@ -423,19 +417,19 @@ html[dir="rtl"] .qm-ltr {
|
|
423 |
text-align: right !important;
|
424 |
}
|
425 |
|
426 |
-
html[dir="rtl"] body
|
427 |
margin-right: 160px !important;
|
428 |
margin-left: 0 !important;
|
429 |
}
|
430 |
|
431 |
-
@media all and (max-width:
|
432 |
-
html[dir="rtl"] body
|
433 |
margin-right: 36px !important;
|
434 |
margin-left: 0 !important;
|
435 |
}
|
436 |
}
|
437 |
|
438 |
-
html[dir="rtl"] body
|
439 |
margin-right: 36px !important;
|
440 |
margin-left: 0 !important;
|
441 |
}
|
142 |
height: 0 !important;
|
143 |
}
|
144 |
|
145 |
+
body.wp-admin #qm {
|
146 |
margin: 0 0 0 160px !important;
|
147 |
}
|
148 |
|
149 |
+
body.wp-admin.folded #qm {
|
|
|
150 |
margin-left: 36px !important;
|
151 |
}
|
152 |
|
153 |
@media screen and (max-width: 782px) {
|
154 |
+
body.wp-admin #qm {
|
155 |
margin-left: 0 !important;
|
156 |
}
|
157 |
}
|
158 |
|
159 |
#qm-wrapper {
|
160 |
margin: 0 auto;
|
|
|
|
|
|
|
|
|
|
|
161 |
}
|
162 |
|
163 |
#qm-wrapper > p {
|
417 |
text-align: right !important;
|
418 |
}
|
419 |
|
420 |
+
html[dir="rtl"] body.wp-admin #qm {
|
421 |
margin-right: 160px !important;
|
422 |
margin-left: 0 !important;
|
423 |
}
|
424 |
|
425 |
+
@media all and (max-width: 782px) {
|
426 |
+
html[dir="rtl"] body.wp-admin #qm {
|
427 |
margin-right: 36px !important;
|
428 |
margin-left: 0 !important;
|
429 |
}
|
430 |
}
|
431 |
|
432 |
+
html[dir="rtl"] body.wp-admin.folded #qm {
|
433 |
margin-right: 36px !important;
|
434 |
margin-left: 0 !important;
|
435 |
}
|
assets/query-monitor.js
CHANGED
@@ -189,14 +189,24 @@ jQuery( function($) {
|
|
189 |
|
190 |
$('.qm-auth').on('click',function(e){
|
191 |
var action = $(this).data('action');
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
197 |
});
|
|
|
198 |
e.preventDefault();
|
199 |
-
})
|
200 |
|
201 |
$.qm.tableSort({target: $('.qm-sortable'), debug: false});
|
202 |
|
189 |
|
190 |
$('.qm-auth').on('click',function(e){
|
191 |
var action = $(this).data('action');
|
192 |
+
|
193 |
+
$.ajax(qm_l10n.ajaxurl,{
|
194 |
+
type : 'POST',
|
195 |
+
data : {
|
196 |
+
action : 'qm_auth_' + action,
|
197 |
+
nonce : qm_l10n.auth_nonce[action]
|
198 |
+
},
|
199 |
+
success : function(response){
|
200 |
+
alert( response.data );
|
201 |
+
},
|
202 |
+
dataType : 'json',
|
203 |
+
xhrFields: {
|
204 |
+
withCredentials: true
|
205 |
+
}
|
206 |
});
|
207 |
+
|
208 |
e.preventDefault();
|
209 |
+
});
|
210 |
|
211 |
$.qm.tableSort({target: $('.qm-sortable'), debug: false});
|
212 |
|
collectors/assets.php
CHANGED
@@ -22,6 +22,16 @@ class QM_Collector_Assets extends QM_Collector {
|
|
22 |
parent::__construct();
|
23 |
add_action( 'admin_print_footer_scripts', array( $this, 'action_print_footer_scripts' ) );
|
24 |
add_action( 'wp_print_footer_scripts', array( $this, 'action_print_footer_scripts' ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
}
|
26 |
|
27 |
public function action_print_footer_scripts() {
|
@@ -30,9 +40,8 @@ class QM_Collector_Assets extends QM_Collector {
|
|
30 |
$this->data['raw_scripts'] = $wp_scripts;
|
31 |
$this->data['raw_styles'] = $wp_styles;
|
32 |
|
33 |
-
$this->data['
|
34 |
-
$this->data['
|
35 |
-
$this->data['header_styles'] = $wp_styles->done;
|
36 |
|
37 |
}
|
38 |
|
@@ -40,14 +49,6 @@ class QM_Collector_Assets extends QM_Collector {
|
|
40 |
return __( 'Scripts & Styles', 'query-monitor' );
|
41 |
}
|
42 |
|
43 |
-
public function process() {
|
44 |
-
|
45 |
-
global $wp_scripts, $wp_styles;
|
46 |
-
|
47 |
-
// @TODO remove
|
48 |
-
|
49 |
-
}
|
50 |
-
|
51 |
}
|
52 |
|
53 |
function register_qm_collector_assets( array $qm ) {
|
22 |
parent::__construct();
|
23 |
add_action( 'admin_print_footer_scripts', array( $this, 'action_print_footer_scripts' ) );
|
24 |
add_action( 'wp_print_footer_scripts', array( $this, 'action_print_footer_scripts' ) );
|
25 |
+
add_action( 'admin_head', array( $this, 'action_head' ), 999 );
|
26 |
+
add_action( 'wp_head', array( $this, 'action_head' ), 999 );
|
27 |
+
}
|
28 |
+
|
29 |
+
public function action_head() {
|
30 |
+
global $wp_scripts, $wp_styles;
|
31 |
+
|
32 |
+
$this->data['header_styles'] = $wp_styles->done;
|
33 |
+
$this->data['header_scripts'] = $wp_scripts->done;
|
34 |
+
|
35 |
}
|
36 |
|
37 |
public function action_print_footer_scripts() {
|
40 |
$this->data['raw_scripts'] = $wp_scripts;
|
41 |
$this->data['raw_styles'] = $wp_styles;
|
42 |
|
43 |
+
$this->data['footer_scripts'] = array_diff( $wp_scripts->done, $this->data['header_scripts'] );
|
44 |
+
$this->data['footer_styles'] = array_diff( $wp_styles->done, $this->data['header_styles'] );
|
|
|
45 |
|
46 |
}
|
47 |
|
49 |
return __( 'Scripts & Styles', 'query-monitor' );
|
50 |
}
|
51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
}
|
53 |
|
54 |
function register_qm_collector_assets( array $qm ) {
|
collectors/authentication.php
DELETED
@@ -1,104 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Copyright 2009-2015 John Blackbourn
|
4 |
-
|
5 |
-
This program is free software; you can redistribute it and/or modify
|
6 |
-
it under the terms of the GNU General Public License as published by
|
7 |
-
the Free Software Foundation; either version 2 of the License, or
|
8 |
-
(at your option) any later version.
|
9 |
-
|
10 |
-
This program is distributed in the hope that it will be useful,
|
11 |
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
-
GNU General Public License for more details.
|
14 |
-
|
15 |
-
*/
|
16 |
-
|
17 |
-
class QM_Collector_Authentication extends QM_Collector {
|
18 |
-
|
19 |
-
public $id = 'authentication';
|
20 |
-
|
21 |
-
public function name() {
|
22 |
-
return __( 'Authentication', 'query-monitor' );
|
23 |
-
}
|
24 |
-
|
25 |
-
public function __construct() {
|
26 |
-
parent::__construct();
|
27 |
-
add_action( 'plugins_loaded', array( $this, 'action_plugins_loaded' ) );
|
28 |
-
add_action( 'wp_ajax_qm_auth_on', array( $this, 'ajax_on' ) );
|
29 |
-
add_action( 'wp_ajax_qm_auth_off', array( $this, 'ajax_off' ) );
|
30 |
-
}
|
31 |
-
|
32 |
-
public function action_plugins_loaded() {
|
33 |
-
|
34 |
-
if ( !defined( 'QM_COOKIE' ) ) {
|
35 |
-
define( 'QM_COOKIE', 'query_monitor_' . COOKIEHASH );
|
36 |
-
}
|
37 |
-
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Helper function. Should the authentication cookie be secure?
|
42 |
-
*
|
43 |
-
* @return bool Should the authentication cookie be secure?
|
44 |
-
*/
|
45 |
-
public static function secure_cookie() {
|
46 |
-
return ( is_ssl() and ( 'https' === parse_url( home_url(), PHP_URL_SCHEME ) ) );
|
47 |
-
}
|
48 |
-
|
49 |
-
public function ajax_on() {
|
50 |
-
|
51 |
-
if ( ! current_user_can( 'view_query_monitor' ) or ! check_ajax_referer( 'qm-auth-on', 'nonce', false ) ) {
|
52 |
-
wp_send_json_error( __( 'Could not set authentication cookie.', 'query-monitor' ) );
|
53 |
-
}
|
54 |
-
|
55 |
-
$expiration = time() + 172800; # 48 hours
|
56 |
-
$secure = self::secure_cookie();
|
57 |
-
$cookie = wp_generate_auth_cookie( get_current_user_id(), $expiration, 'logged_in' );
|
58 |
-
|
59 |
-
setcookie( QM_COOKIE, $cookie, $expiration, COOKIEPATH, COOKIE_DOMAIN, $secure, false );
|
60 |
-
|
61 |
-
$text = __( 'Authentication cookie set. You can now view Query Monitor output while logged out or while logged in as a different user.', 'query-monitor' );
|
62 |
-
|
63 |
-
wp_send_json_success( $text );
|
64 |
-
|
65 |
-
}
|
66 |
-
|
67 |
-
public function ajax_off() {
|
68 |
-
|
69 |
-
if ( ! $this->user_verified() or ! check_ajax_referer( 'qm-auth-off', 'nonce', false ) ) {
|
70 |
-
wp_send_json_error( __( 'Could not clear authentication cookie.', 'query-monitor' ) );
|
71 |
-
}
|
72 |
-
|
73 |
-
$expiration = time() - 31536000;
|
74 |
-
|
75 |
-
setcookie( QM_COOKIE, ' ', $expiration, COOKIEPATH, COOKIE_DOMAIN );
|
76 |
-
|
77 |
-
$text = __( 'Authentication cookie cleared.', 'query-monitor' );
|
78 |
-
|
79 |
-
wp_send_json_success( $text );
|
80 |
-
|
81 |
-
}
|
82 |
-
|
83 |
-
public function user_verified() {
|
84 |
-
if ( isset( $_COOKIE[QM_COOKIE] ) ) {
|
85 |
-
return $this->verify_cookie( stripslashes( $_COOKIE[QM_COOKIE] ) );
|
86 |
-
}
|
87 |
-
return false;
|
88 |
-
}
|
89 |
-
|
90 |
-
public static function verify_cookie( $value ) {
|
91 |
-
if ( $old_user_id = wp_validate_auth_cookie( $value, 'logged_in' ) ) {
|
92 |
-
return user_can( $old_user_id, 'view_query_monitor' );
|
93 |
-
}
|
94 |
-
return false;
|
95 |
-
}
|
96 |
-
|
97 |
-
}
|
98 |
-
|
99 |
-
function register_qm_collector_authentication( array $qm ) {
|
100 |
-
$qm['authentication'] = new QM_Collector_Authentication;
|
101 |
-
return $qm;
|
102 |
-
}
|
103 |
-
|
104 |
-
add_filter( 'query_monitor_collectors', 'register_qm_collector_authentication', 130 );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dispatchers/Headers.php
CHANGED
@@ -24,7 +24,7 @@ class QM_Dispatcher_Headers extends QM_Dispatcher {
|
|
24 |
|
25 |
public function init() {
|
26 |
|
27 |
-
if ( ! $this->
|
28 |
return;
|
29 |
}
|
30 |
|
@@ -38,13 +38,7 @@ class QM_Dispatcher_Headers extends QM_Dispatcher {
|
|
38 |
|
39 |
require_once $this->qm->plugin_path( 'output/Headers.php' );
|
40 |
|
41 |
-
|
42 |
-
$output_iterator = new DirectoryIterator( $this->qm->plugin_path( 'output/headers' ) );
|
43 |
-
foreach ( $output_iterator as $output ) {
|
44 |
-
if ( $output->getExtension() === 'php' ) {
|
45 |
-
include $output->getPathname();
|
46 |
-
}
|
47 |
-
}
|
48 |
|
49 |
}
|
50 |
|
@@ -63,7 +57,7 @@ class QM_Dispatcher_Headers extends QM_Dispatcher {
|
|
63 |
|
64 |
public function is_active() {
|
65 |
|
66 |
-
if ( ! $this->
|
67 |
return false;
|
68 |
}
|
69 |
|
24 |
|
25 |
public function init() {
|
26 |
|
27 |
+
if ( ! $this->user_can_view() ) {
|
28 |
return;
|
29 |
}
|
30 |
|
38 |
|
39 |
require_once $this->qm->plugin_path( 'output/Headers.php' );
|
40 |
|
41 |
+
QM_Util::include_files( $this->qm->plugin_path( 'output/headers' ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
}
|
44 |
|
57 |
|
58 |
public function is_active() {
|
59 |
|
60 |
+
if ( ! $this->user_can_view() ) {
|
61 |
return false;
|
62 |
}
|
63 |
|
dispatchers/Html.php
CHANGED
@@ -20,15 +20,61 @@ class QM_Dispatcher_Html extends QM_Dispatcher {
|
|
20 |
|
21 |
public function __construct( QM_Plugin $qm ) {
|
22 |
|
23 |
-
add_action( 'admin_bar_menu',
|
|
|
|
|
|
|
24 |
|
25 |
parent::__construct( $qm );
|
26 |
|
27 |
}
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
public function action_admin_bar_menu( WP_Admin_Bar $wp_admin_bar ) {
|
30 |
|
31 |
-
if ( ! $this->
|
32 |
return;
|
33 |
}
|
34 |
|
@@ -55,7 +101,7 @@ class QM_Dispatcher_Html extends QM_Dispatcher {
|
|
55 |
|
56 |
public function init() {
|
57 |
|
58 |
-
if ( ! $this->
|
59 |
return;
|
60 |
}
|
61 |
|
@@ -120,12 +166,7 @@ class QM_Dispatcher_Html extends QM_Dispatcher {
|
|
120 |
|
121 |
require_once $this->qm->plugin_path( 'output/Html.php' );
|
122 |
|
123 |
-
|
124 |
-
foreach ( $output_iterator as $output ) {
|
125 |
-
if ( $output->getExtension() === 'php' ) {
|
126 |
-
include $output->getPathname();
|
127 |
-
}
|
128 |
-
}
|
129 |
|
130 |
$class = array();
|
131 |
|
@@ -148,6 +189,39 @@ class QM_Dispatcher_Html extends QM_Dispatcher {
|
|
148 |
|
149 |
public function after_output() {
|
150 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
echo '</div>';
|
152 |
echo '</div>';
|
153 |
|
@@ -193,7 +267,7 @@ class QM_Dispatcher_Html extends QM_Dispatcher {
|
|
193 |
|
194 |
public function is_active() {
|
195 |
|
196 |
-
if ( ! $this->
|
197 |
return false;
|
198 |
}
|
199 |
|
20 |
|
21 |
public function __construct( QM_Plugin $qm ) {
|
22 |
|
23 |
+
add_action( 'admin_bar_menu', array( $this, 'action_admin_bar_menu' ), 999 );
|
24 |
+
add_action( 'wp_ajax_qm_auth_on', array( $this, 'ajax_on' ) );
|
25 |
+
add_action( 'wp_ajax_qm_auth_off', array( $this, 'ajax_off' ) );
|
26 |
+
add_action( 'wp_ajax_nopriv_qm_auth_off', array( $this, 'ajax_off' ) );
|
27 |
|
28 |
parent::__construct( $qm );
|
29 |
|
30 |
}
|
31 |
|
32 |
+
/**
|
33 |
+
* Helper function. Should the authentication cookie be secure?
|
34 |
+
*
|
35 |
+
* @return bool Should the authentication cookie be secure?
|
36 |
+
*/
|
37 |
+
public static function secure_cookie() {
|
38 |
+
return ( is_ssl() and ( 'https' === parse_url( home_url(), PHP_URL_SCHEME ) ) );
|
39 |
+
}
|
40 |
+
|
41 |
+
public function ajax_on() {
|
42 |
+
|
43 |
+
if ( ! current_user_can( 'view_query_monitor' ) or ! check_ajax_referer( 'qm-auth-on', 'nonce', false ) ) {
|
44 |
+
wp_send_json_error( __( 'Could not set authentication cookie.', 'query-monitor' ) );
|
45 |
+
}
|
46 |
+
|
47 |
+
$expiration = time() + 172800; # 48 hours
|
48 |
+
$secure = self::secure_cookie();
|
49 |
+
$cookie = wp_generate_auth_cookie( get_current_user_id(), $expiration, 'logged_in' );
|
50 |
+
|
51 |
+
setcookie( QM_COOKIE, $cookie, $expiration, COOKIEPATH, COOKIE_DOMAIN, $secure, false );
|
52 |
+
|
53 |
+
$text = __( 'Authentication cookie set. You can now view Query Monitor output while logged out or while logged in as a different user.', 'query-monitor' );
|
54 |
+
|
55 |
+
wp_send_json_success( $text );
|
56 |
+
|
57 |
+
}
|
58 |
+
|
59 |
+
public function ajax_off() {
|
60 |
+
|
61 |
+
if ( ! $this->user_verified() or ! check_ajax_referer( 'qm-auth-off', 'nonce', false ) ) {
|
62 |
+
wp_send_json_error( __( 'Could not clear authentication cookie.', 'query-monitor' ) );
|
63 |
+
}
|
64 |
+
|
65 |
+
$expiration = time() - 31536000;
|
66 |
+
|
67 |
+
setcookie( QM_COOKIE, ' ', $expiration, COOKIEPATH, COOKIE_DOMAIN );
|
68 |
+
|
69 |
+
$text = __( 'Authentication cookie cleared.', 'query-monitor' );
|
70 |
+
|
71 |
+
wp_send_json_success( $text );
|
72 |
+
|
73 |
+
}
|
74 |
+
|
75 |
public function action_admin_bar_menu( WP_Admin_Bar $wp_admin_bar ) {
|
76 |
|
77 |
+
if ( ! $this->user_can_view() ) {
|
78 |
return;
|
79 |
}
|
80 |
|
101 |
|
102 |
public function init() {
|
103 |
|
104 |
+
if ( ! $this->user_can_view() ) {
|
105 |
return;
|
106 |
}
|
107 |
|
166 |
|
167 |
require_once $this->qm->plugin_path( 'output/Html.php' );
|
168 |
|
169 |
+
QM_Util::include_files( $this->qm->plugin_path( 'output/html' ) );
|
|
|
|
|
|
|
|
|
|
|
170 |
|
171 |
$class = array();
|
172 |
|
189 |
|
190 |
public function after_output() {
|
191 |
|
192 |
+
echo '<div class="qm qm-half" id="qm-authentication">';
|
193 |
+
echo '<table cellspacing="0">';
|
194 |
+
echo '<thead>';
|
195 |
+
echo '<tr>';
|
196 |
+
echo '<th>' . esc_html__( 'Authentication', 'query-monitor' ) . '</th>';
|
197 |
+
echo '</tr>';
|
198 |
+
echo '</thead>';
|
199 |
+
echo '<tbody>';
|
200 |
+
|
201 |
+
if ( !$this->user_verified() ) {
|
202 |
+
|
203 |
+
echo '<tr>';
|
204 |
+
echo '<td>' . __( 'You can set an authentication cookie which allows you to view Query Monitor output when you’re not logged in.', 'query-monitor' ) . '</td>';
|
205 |
+
echo '</tr>';
|
206 |
+
echo '<tr>';
|
207 |
+
echo '<td><a href="#" class="qm-auth" data-action="on">' . __( 'Set authentication cookie', 'query-monitor' ) . '</a></td>';
|
208 |
+
echo '</tr>';
|
209 |
+
|
210 |
+
} else {
|
211 |
+
|
212 |
+
echo '<tr>';
|
213 |
+
echo '<td>' . __( 'You currently have an authentication cookie which allows you to view Query Monitor output.', 'query-monitor' ) . '</td>';
|
214 |
+
echo '</tr>';
|
215 |
+
echo '<tr>';
|
216 |
+
echo '<td><a href="#" class="qm-auth" data-action="off">' . __( 'Clear authentication cookie', 'query-monitor' ) . '</a></td>';
|
217 |
+
echo '</tr>';
|
218 |
+
|
219 |
+
}
|
220 |
+
|
221 |
+
echo '</tbody>';
|
222 |
+
echo '</table>';
|
223 |
+
echo '</div>';
|
224 |
+
|
225 |
echo '</div>';
|
226 |
echo '</div>';
|
227 |
|
267 |
|
268 |
public function is_active() {
|
269 |
|
270 |
+
if ( ! $this->user_can_view() ) {
|
271 |
return false;
|
272 |
}
|
273 |
|
output/html/assets.php
CHANGED
@@ -62,10 +62,17 @@ class QM_Output_Html_Assets extends QM_Output_Html {
|
|
62 |
$rowspan = count( $data['header_styles'] );
|
63 |
|
64 |
echo '<tr>';
|
65 |
-
echo "<td valign='top' rowspan='{$rowspan}'>" . __( 'Styles', 'query-monitor' ) . "</td>";
|
66 |
|
67 |
$this->dependency_rows( $data['header_styles'], $data['raw_styles'] );
|
68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
echo '</tbody>';
|
70 |
echo '</table>';
|
71 |
echo '</div>';
|
@@ -76,6 +83,12 @@ class QM_Output_Html_Assets extends QM_Output_Html {
|
|
76 |
|
77 |
$first = true;
|
78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
foreach ( $handles as $handle ) {
|
80 |
if ( !$first ) {
|
81 |
echo '<tr>';
|
62 |
$rowspan = count( $data['header_styles'] );
|
63 |
|
64 |
echo '<tr>';
|
65 |
+
echo "<td valign='top' rowspan='{$rowspan}'>" . __( 'Header Styles', 'query-monitor' ) . "</td>";
|
66 |
|
67 |
$this->dependency_rows( $data['header_styles'], $data['raw_styles'] );
|
68 |
|
69 |
+
$rowspan = count( $data['footer_styles'] );
|
70 |
+
|
71 |
+
echo '<tr>';
|
72 |
+
echo "<td valign='top' rowspan='{$rowspan}'>" . __( 'Footer Styles', 'query-monitor' ) . "</td>";
|
73 |
+
|
74 |
+
$this->dependency_rows( $data['footer_styles'], $data['raw_styles'] );
|
75 |
+
|
76 |
echo '</tbody>';
|
77 |
echo '</table>';
|
78 |
echo '</div>';
|
83 |
|
84 |
$first = true;
|
85 |
|
86 |
+
if ( empty( $handles ) ) {
|
87 |
+
echo '<td valign="top" colspan="3"><em>' . __( 'none', 'query-monitor' ) . '</em></td>';
|
88 |
+
echo '</tr>';
|
89 |
+
return;
|
90 |
+
}
|
91 |
+
|
92 |
foreach ( $handles as $handle ) {
|
93 |
if ( !$first ) {
|
94 |
echo '<tr>';
|
output/html/authentication.php
DELETED
@@ -1,62 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Copyright 2009-2015 John Blackbourn
|
4 |
-
|
5 |
-
This program is free software; you can redistribute it and/or modify
|
6 |
-
it under the terms of the GNU General Public License as published by
|
7 |
-
the Free Software Foundation; either version 2 of the License, or
|
8 |
-
(at your option) any later version.
|
9 |
-
|
10 |
-
This program is distributed in the hope that it will be useful,
|
11 |
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
-
GNU General Public License for more details.
|
14 |
-
|
15 |
-
*/
|
16 |
-
|
17 |
-
class QM_Output_Html_Authentication extends QM_Output_Html {
|
18 |
-
|
19 |
-
public function output() {
|
20 |
-
|
21 |
-
echo '<div class="qm qm-half" id="' . esc_attr( $this->collector->id() ) . '">';
|
22 |
-
echo '<table cellspacing="0">';
|
23 |
-
echo '<thead>';
|
24 |
-
echo '<tr>';
|
25 |
-
echo '<th>' . esc_html( $this->collector->name() ) . '</th>';
|
26 |
-
echo '</tr>';
|
27 |
-
echo '</thead>';
|
28 |
-
echo '<tbody>';
|
29 |
-
|
30 |
-
if ( !$this->collector->user_verified() ) {
|
31 |
-
|
32 |
-
echo '<tr>';
|
33 |
-
echo '<td>' . __( 'You can set an authentication cookie which allows you to view Query Monitor output when you’re not logged in.', 'query-monitor' ) . '</td>';
|
34 |
-
echo '</tr>';
|
35 |
-
echo '<tr>';
|
36 |
-
echo '<td><a href="#" class="qm-auth" data-action="on">' . __( 'Set authentication cookie', 'query-monitor' ) . '</a></td>';
|
37 |
-
echo '</tr>';
|
38 |
-
|
39 |
-
} else {
|
40 |
-
|
41 |
-
echo '<tr>';
|
42 |
-
echo '<td>' . __( 'You currently have an authentication cookie which allows you to view Query Monitor output.', 'query-monitor' ) . '</td>';
|
43 |
-
echo '</tr>';
|
44 |
-
echo '<tr>';
|
45 |
-
echo '<td><a href="#" class="qm-auth" data-action="off">' . __( 'Clear authentication cookie', 'query-monitor' ) . '</a></td>';
|
46 |
-
echo '</tr>';
|
47 |
-
|
48 |
-
}
|
49 |
-
|
50 |
-
echo '</tbody>';
|
51 |
-
echo '</table>';
|
52 |
-
echo '</div>';
|
53 |
-
|
54 |
-
}
|
55 |
-
|
56 |
-
}
|
57 |
-
|
58 |
-
function register_qm_output_html_authentication( QM_Output $output = null, QM_Collector $collector ) {
|
59 |
-
return new QM_Output_Html_Authentication( $collector );
|
60 |
-
}
|
61 |
-
|
62 |
-
add_filter( 'query_monitor_output_html_authentication', 'register_qm_output_html_authentication', 10, 2 );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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://querymonitor.com/
|
7 |
Author: John Blackbourn
|
8 |
Author URI: https://johnblackbourn.com/
|
@@ -60,12 +60,7 @@ class QueryMonitor extends QM_Plugin {
|
|
60 |
parent::__construct( $file );
|
61 |
|
62 |
# Collectors:
|
63 |
-
|
64 |
-
foreach ( $collector_iterator as $collector ) {
|
65 |
-
if ( $collector->getExtension() === 'php' ) {
|
66 |
-
include $collector->getPathname();
|
67 |
-
}
|
68 |
-
}
|
69 |
|
70 |
foreach ( apply_filters( 'query_monitor_collectors', array() ) as $collector ) {
|
71 |
$this->add_collector( $collector );
|
@@ -76,12 +71,7 @@ class QueryMonitor extends QM_Plugin {
|
|
76 |
public function action_plugins_loaded() {
|
77 |
|
78 |
# Dispatchers:
|
79 |
-
|
80 |
-
foreach ( $dispatcher_iterator as $dispatcher ) {
|
81 |
-
if ( $dispatcher->getExtension() === 'php' ) {
|
82 |
-
include $dispatcher->getPathname();
|
83 |
-
}
|
84 |
-
}
|
85 |
|
86 |
foreach ( apply_filters( 'query_monitor_dispatchers', array(), $this ) as $dispatcher ) {
|
87 |
$this->add_dispatcher( $dispatcher );
|
@@ -144,24 +134,6 @@ class QueryMonitor extends QM_Plugin {
|
|
144 |
|
145 |
}
|
146 |
|
147 |
-
public function user_can_view() {
|
148 |
-
|
149 |
-
if ( !did_action( 'plugins_loaded' ) ) {
|
150 |
-
return false;
|
151 |
-
}
|
152 |
-
|
153 |
-
if ( current_user_can( 'view_query_monitor' ) ) {
|
154 |
-
return true;
|
155 |
-
}
|
156 |
-
|
157 |
-
if ( $auth = self::get_collector( 'authentication' ) ) {
|
158 |
-
return $auth->user_verified();
|
159 |
-
}
|
160 |
-
|
161 |
-
return false;
|
162 |
-
|
163 |
-
}
|
164 |
-
|
165 |
public function should_process() {
|
166 |
|
167 |
# Don't process if the minimum required actions haven't fired:
|
@@ -183,7 +155,7 @@ class QueryMonitor extends QM_Plugin {
|
|
183 |
$e = error_get_last();
|
184 |
|
185 |
# Don't process if a fatal has occurred:
|
186 |
-
if ( ! empty( $e ) and (
|
187 |
return false;
|
188 |
}
|
189 |
|
@@ -278,7 +250,7 @@ class QueryMonitor extends QM_Plugin {
|
|
278 |
|
279 |
public static function symlink_warning() {
|
280 |
$db = WP_CONTENT_DIR . '/db.php';
|
281 |
-
trigger_error( sprintf( __( 'The symlink at
|
282 |
}
|
283 |
|
284 |
public static function init( $file = null ) {
|
2 |
/*
|
3 |
Plugin Name: Query Monitor
|
4 |
Description: Monitoring of database queries, hooks, conditionals and more.
|
5 |
+
Version: 2.6.10
|
6 |
Plugin URI: https://querymonitor.com/
|
7 |
Author: John Blackbourn
|
8 |
Author URI: https://johnblackbourn.com/
|
60 |
parent::__construct( $file );
|
61 |
|
62 |
# Collectors:
|
63 |
+
QM_Util::include_files( $this->plugin_path( 'collectors' ) );
|
|
|
|
|
|
|
|
|
|
|
64 |
|
65 |
foreach ( apply_filters( 'query_monitor_collectors', array() ) as $collector ) {
|
66 |
$this->add_collector( $collector );
|
71 |
public function action_plugins_loaded() {
|
72 |
|
73 |
# Dispatchers:
|
74 |
+
QM_Util::include_files( $this->plugin_path( 'dispatchers' ) );
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
foreach ( apply_filters( 'query_monitor_dispatchers', array(), $this ) as $dispatcher ) {
|
77 |
$this->add_dispatcher( $dispatcher );
|
134 |
|
135 |
}
|
136 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
public function should_process() {
|
138 |
|
139 |
# Don't process if the minimum required actions haven't fired:
|
155 |
$e = error_get_last();
|
156 |
|
157 |
# Don't process if a fatal has occurred:
|
158 |
+
if ( ! empty( $e ) and ( $e['type'] & ( E_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR ) ) ) {
|
159 |
return false;
|
160 |
}
|
161 |
|
250 |
|
251 |
public static function symlink_warning() {
|
252 |
$db = WP_CONTENT_DIR . '/db.php';
|
253 |
+
trigger_error( sprintf( __( 'The symlink at %s is no longer pointing to the correct location. Please remove the symlink, then deactivate and reactivate Query Monitor.', 'query-monitor' ), "<code>{$db}</code>" ), E_USER_WARNING );
|
254 |
}
|
255 |
|
256 |
public static function init( $file = null ) {
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: johnbillion
|
|
3 |
Tags: debug, debugging, development, developer, performance, profiler, profiling, queries, query monitor
|
4 |
Requires at least: 3.5
|
5 |
Tested up to: 4.1
|
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.
|
@@ -89,6 +89,7 @@ Hands up who can remember the correct names for the filters and actions for cust
|
|
89 |
* Shows any **transients that were set**, along with their timeout, component, and call stack
|
90 |
* Shows all **WordPress conditionals** on the current page, highlighted nicely
|
91 |
* Shows an overview including page generation time and memory limit as absolute values and as % of their respective limits
|
|
|
92 |
|
93 |
= Authentication =
|
94 |
|
@@ -139,7 +140,7 @@ Yep, the first one was released recently: [Query Monitor bbPress & BuddyPress Co
|
|
139 |
|
140 |
= Where can I suggest a new feature or report a bug? =
|
141 |
|
142 |
-
Please use [the issue tracker on Query Monitor's GitHub repo](https://github.com/johnbillion/
|
143 |
|
144 |
= Do you accept donations? =
|
145 |
|
@@ -147,11 +148,19 @@ No, I do not accept donations. If you like the plugin, I'd love for you to [leav
|
|
147 |
|
148 |
== Upgrade Notice ==
|
149 |
|
150 |
-
= 2.6.
|
151 |
-
*
|
152 |
|
153 |
== Changelog ==
|
154 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
= 2.6.9 =
|
156 |
* New Scripts & Styles component
|
157 |
* Support for the new `is_customize_preview()` conditional
|
3 |
Tags: debug, debugging, development, developer, performance, profiler, profiling, queries, query monitor
|
4 |
Requires at least: 3.5
|
5 |
Tested up to: 4.1
|
6 |
+
Stable tag: 2.6.10
|
7 |
License: GPLv2 or later
|
8 |
|
9 |
View debugging and performance information on database queries, hooks, conditionals, HTTP requests, redirects and more.
|
89 |
* Shows any **transients that were set**, along with their timeout, component, and call stack
|
90 |
* Shows all **WordPress conditionals** on the current page, highlighted nicely
|
91 |
* Shows an overview including page generation time and memory limit as absolute values and as % of their respective limits
|
92 |
+
* Shows all *scripts and styles* which were enqueued on the current page, along with their path, dependencies, and version number
|
93 |
|
94 |
= Authentication =
|
95 |
|
140 |
|
141 |
= Where can I suggest a new feature or report a bug? =
|
142 |
|
143 |
+
Please use [the issue tracker on Query Monitor's GitHub repo](https://github.com/johnbillion/query-monitor/issues) as it's easier to keep track of issues there, rather than on the wordpress.org support forums.
|
144 |
|
145 |
= Do you accept donations? =
|
146 |
|
148 |
|
149 |
== Upgrade Notice ==
|
150 |
|
151 |
+
= 2.6.10 =
|
152 |
+
* Fix some PHP 5.2 compatibility issues introduced in 2.6.9; More tweaks to the CSS so QM avoids being covered up by the admin menu.
|
153 |
|
154 |
== Changelog ==
|
155 |
|
156 |
+
= 2.6.10 =
|
157 |
+
* Add compatibility with PHP <5.3.6. `DirectoryIterator::getExtension()` isn't available on this version (and also as it's part of SPL it can be disabled).
|
158 |
+
* Simplify the admin CSS to avoid QM's output being covered by the admin menu.
|
159 |
+
* Add support for footer styles in the scripts and styles component.
|
160 |
+
* Update the authentication JavaScript so it works cross-protocol.
|
161 |
+
* Add support for footer styles in the scripts and styles component.
|
162 |
+
* Update the authentication JavaScript so it works cross-protocol.
|
163 |
+
|
164 |
= 2.6.9 =
|
165 |
* New Scripts & Styles component
|
166 |
* Support for the new `is_customize_preview()` conditional
|