Query Monitor - Version 3.3.5

Version Description

Download this release

Release Info

Developer johnbillion
Plugin Icon 128x128 Query Monitor
Version 3.3.5
Comparing to
See all releases

Code changes from version 3.3.4 to 3.3.5

classes/Plugin.php CHANGED
@@ -95,5 +95,25 @@ abstract class QM_Plugin {
95
  return $met;
96
  }
97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  }
99
  }
95
  return $met;
96
  }
97
 
98
+ public static function php_version_nope() {
99
+ printf(
100
+ '<div id="qm-php-nope" class="notice notice-error is-dismissible"><p>%s</p></div>',
101
+ wp_kses(
102
+ sprintf(
103
+ /* translators: 1: Required PHP version number, 2: Current PHP version number, 3: URL of PHP update help page */
104
+ __( 'The Query Monitor plugin requires PHP version %1$s or higher. This site is running PHP version %2$s. <a href="%3$s">Learn about updating PHP</a>.', 'query-monitor' ),
105
+ self::$minimum_php_version,
106
+ PHP_VERSION,
107
+ 'https://wordpress.org/support/update-php/'
108
+ ),
109
+ array(
110
+ 'a' => array(
111
+ 'href' => array(),
112
+ ),
113
+ )
114
+ )
115
+ );
116
+ }
117
+
118
  }
119
  }
collectors/conditionals.php CHANGED
@@ -47,6 +47,7 @@ class QM_Collector_Conditionals extends QM_Collector {
47
  'is_paged',
48
  'is_post_type_archive',
49
  'is_preview',
 
50
  'is_robots',
51
  'is_rtl',
52
  'is_search',
47
  'is_paged',
48
  'is_post_type_archive',
49
  'is_preview',
50
+ 'is_privacy_policy',
51
  'is_robots',
52
  'is_rtl',
53
  'is_search',
collectors/theme.php CHANGED
@@ -19,6 +19,7 @@ class QM_Collector_Theme extends QM_Collector {
19
  add_filter( 'body_class', array( $this, 'filter_body_class' ), 9999 );
20
  add_filter( 'timber/output', array( $this, 'filter_timber_output' ), 9999, 3 );
21
  add_action( 'template_redirect', array( $this, 'action_template_redirect' ) );
 
22
  }
23
 
24
  public function get_concerned_actions() {
@@ -54,25 +55,32 @@ class QM_Collector_Theme extends QM_Collector {
54
  }
55
 
56
  public static function get_query_template_names() {
57
- return array(
58
- 'embed' => 'is_embed',
59
- '404' => 'is_404',
60
- 'search' => 'is_search',
61
- 'front_page' => 'is_front_page',
62
- 'home' => 'is_home',
63
- 'post_type_archive' => 'is_post_type_archive',
64
- 'taxonomy' => 'is_tax',
65
- 'attachment' => 'is_attachment',
66
- 'single' => 'is_single',
67
- 'page' => 'is_page',
68
- 'singular' => 'is_singular',
69
- 'category' => 'is_category',
70
- 'tag' => 'is_tag',
71
- 'author' => 'is_author',
72
- 'date' => 'is_date',
73
- 'archive' => 'is_archive',
74
- 'index' => '__return_true',
75
- );
 
 
 
 
 
 
 
76
  }
77
 
78
  // https://core.trac.wordpress.org/ticket/14310
@@ -98,6 +106,17 @@ class QM_Collector_Theme extends QM_Collector {
98
 
99
  }
100
 
 
 
 
 
 
 
 
 
 
 
 
101
  public function filter_template_hierarchy( array $templates ) {
102
  if ( ! isset( $this->data['template_hierarchy'] ) ) {
103
  $this->data['template_hierarchy'] = array();
@@ -143,28 +162,64 @@ class QM_Collector_Theme extends QM_Collector {
143
  $this->data['template_hierarchy'] = array_unique( $this->data['template_hierarchy'] );
144
  }
145
 
146
- foreach ( get_included_files() as $file ) {
147
- $file = QM_Util::standard_dir( $file );
148
- $filename = str_replace( array(
149
- $stylesheet_directory,
150
- $template_directory,
151
- ), '', $file );
152
- if ( $filename !== $file ) {
153
- $slug = trim( str_replace( '.php', '', $filename ), '/' );
154
- $display = trim( $filename, '/' );
155
- $theme_display = trim( str_replace( $theme_directory, '', $file ), '/' );
156
- $count = did_action( "get_template_part_{$slug}" );
157
- if ( $count ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
  $this->data['template_parts'][ $file ] = $display;
159
  $this->data['theme_template_parts'][ $file ] = $theme_display;
160
- $this->data['count_template_parts'][ $file ] = $count;
161
- } else {
162
- $slug = trim( preg_replace( '|\-[^\-]+$|', '', $slug ), '/' );
163
- $count = did_action( "get_template_part_{$slug}" );
 
 
 
 
 
 
 
 
 
 
164
  if ( $count ) {
165
  $this->data['template_parts'][ $file ] = $display;
166
  $this->data['theme_template_parts'][ $file ] = $theme_display;
167
  $this->data['count_template_parts'][ $file ] = $count;
 
 
 
 
 
 
 
 
168
  }
169
  }
170
  }
19
  add_filter( 'body_class', array( $this, 'filter_body_class' ), 9999 );
20
  add_filter( 'timber/output', array( $this, 'filter_timber_output' ), 9999, 3 );
21
  add_action( 'template_redirect', array( $this, 'action_template_redirect' ) );
22
+ add_action( 'get_template_part', array( $this, 'action_get_template_part' ), 10, 3 );
23
  }
24
 
25
  public function get_concerned_actions() {
55
  }
56
 
57
  public static function get_query_template_names() {
58
+ $names = array();
59
+
60
+ $names['embed'] = 'is_embed';
61
+ $names['404'] = 'is_404';
62
+ $names['search'] = 'is_search';
63
+ $names['front_page'] = 'is_front_page';
64
+ $names['home'] = 'is_home';
65
+
66
+ if ( function_exists( 'is_privacy_policy' ) ) {
67
+ $names['privacy_policy'] = 'is_privacy_policy';
68
+ }
69
+
70
+ $names['post_type_archive'] = 'is_post_type_archive';
71
+ $names['taxonomy'] = 'is_tax';
72
+ $names['attachment'] = 'is_attachment';
73
+ $names['single'] = 'is_single';
74
+ $names['page'] = 'is_page';
75
+ $names['singular'] = 'is_singular';
76
+ $names['category'] = 'is_category';
77
+ $names['tag'] = 'is_tag';
78
+ $names['author'] = 'is_author';
79
+ $names['date'] = 'is_date';
80
+ $names['archive'] = 'is_archive';
81
+ $names['index'] = '__return_true';
82
+
83
+ return $names;
84
  }
85
 
86
  // https://core.trac.wordpress.org/ticket/14310
106
 
107
  }
108
 
109
+ /**
110
+ * Fires before a template part is loaded.
111
+ *
112
+ * @param string $slug The slug name for the generic template.
113
+ * @param string $name The name of the specialized template.
114
+ * @param string[] $templates Array of template files to search for, in order.
115
+ */
116
+ public function action_get_template_part( $slug, $name, $templates ) {
117
+ $this->data['requested_template_parts'][] = func_get_args();
118
+ }
119
+
120
  public function filter_template_hierarchy( array $templates ) {
121
  if ( ! isset( $this->data['template_hierarchy'] ) ) {
122
  $this->data['template_hierarchy'] = array();
162
  $this->data['template_hierarchy'] = array_unique( $this->data['template_hierarchy'] );
163
  }
164
 
165
+ if ( function_exists( 'wp_body_open' ) ) {
166
+ if ( ! empty( $this->data['requested_template_parts'] ) ) {
167
+ $this->data['template_parts'] = array();
168
+ $this->data['theme_template_parts'] = array();
169
+ $this->data['count_template_parts'] = array();
170
+
171
+ foreach ( $this->data['requested_template_parts'] as $party ) {
172
+ $file = locate_template( $party[2] );
173
+ if ( ! $file ) {
174
+ continue;
175
+ }
176
+
177
+ $file = QM_Util::standard_dir( $file );
178
+
179
+ if ( isset( $this->data['count_template_parts'][ $file ] ) ) {
180
+ $this->data['count_template_parts'][ $file ]++;
181
+ continue;
182
+ }
183
+
184
+ $this->data['count_template_parts'][ $file ] = 1;
185
+
186
+ $filename = str_replace( array(
187
+ $stylesheet_directory,
188
+ $template_directory,
189
+ ), '', $file );
190
+
191
+ $slug = trim( str_replace( '.php', '', $filename ), '/' );
192
+ $display = trim( $filename, '/' );
193
+ $theme_display = trim( str_replace( $theme_directory, '', $file ), '/' );
194
+
195
  $this->data['template_parts'][ $file ] = $display;
196
  $this->data['theme_template_parts'][ $file ] = $theme_display;
197
+ }
198
+ }
199
+ } else {
200
+ foreach ( get_included_files() as $file ) {
201
+ $file = QM_Util::standard_dir( $file );
202
+ $filename = str_replace( array(
203
+ $stylesheet_directory,
204
+ $template_directory,
205
+ ), '', $file );
206
+ if ( $filename !== $file ) {
207
+ $slug = trim( str_replace( '.php', '', $filename ), '/' );
208
+ $display = trim( $filename, '/' );
209
+ $theme_display = trim( str_replace( $theme_directory, '', $file ), '/' );
210
+ $count = did_action( "get_template_part_{$slug}" );
211
  if ( $count ) {
212
  $this->data['template_parts'][ $file ] = $display;
213
  $this->data['theme_template_parts'][ $file ] = $theme_display;
214
  $this->data['count_template_parts'][ $file ] = $count;
215
+ } else {
216
+ $slug = trim( preg_replace( '|\-[^\-]+$|', '', $slug ), '/' );
217
+ $count = did_action( "get_template_part_{$slug}" );
218
+ if ( $count ) {
219
+ $this->data['template_parts'][ $file ] = $display;
220
+ $this->data['theme_template_parts'][ $file ] = $theme_display;
221
+ $this->data['count_template_parts'][ $file ] = $count;
222
+ }
223
  }
224
  }
225
  }
composer.json CHANGED
@@ -37,7 +37,7 @@
37
  "preferred-install": "dist"
38
  },
39
  "extra": {
40
- "wordpress-install-dir": "vendor/wordpress/wordpress"
41
  },
42
  "require": {
43
  "php": ">=5.3",
@@ -49,10 +49,11 @@
49
  "phpcompatibility/phpcompatibility-wp": "^2.0",
50
  "danieltj27/dark-mode": "3.2",
51
  "wp-coding-standards/wpcs": "^2",
52
- "wp-phpunit/wp-phpunit": "* || *",
53
- "roots/wordpress": "* || *",
54
  "vlucas/phpdotenv": "^3",
55
  "johnkary/phpunit-speedtrap": "^1.1",
 
56
  "phpunit/phpunit": "^5"
57
  },
58
  "scripts": {
@@ -60,6 +61,7 @@
60
  "vendor/bin/phpcs -nps --colors --report-code --report-summary --report-width=80 ."
61
  ],
62
  "test:ut": [
 
63
  "export WP_MULTISITE=0 && vendor/bin/phpunit --verbose --colors=always --exclude-group=ms-required",
64
  "export WP_MULTISITE=1 && vendor/bin/phpunit --verbose --colors=always --exclude-group=ms-excluded"
65
  ],
37
  "preferred-install": "dist"
38
  },
39
  "extra": {
40
+ "wordpress-install-dir": "tests/wordpress"
41
  },
42
  "require": {
43
  "php": ">=5.3",
49
  "phpcompatibility/phpcompatibility-wp": "^2.0",
50
  "danieltj27/dark-mode": "3.2",
51
  "wp-coding-standards/wpcs": "^2",
52
+ "wp-phpunit/wp-phpunit": "*",
53
+ "roots/wordpress": "*",
54
  "vlucas/phpdotenv": "^3",
55
  "johnkary/phpunit-speedtrap": "^1.1",
56
+ "wp-cli/wp-cli-bundle": "^2.1",
57
  "phpunit/phpunit": "^5"
58
  },
59
  "scripts": {
61
  "vendor/bin/phpcs -nps --colors --report-code --report-summary --report-width=80 ."
62
  ],
63
  "test:ut": [
64
+ "vendor/bin/wp db reset --yes --path=tests/wordpress",
65
  "export WP_MULTISITE=0 && vendor/bin/phpunit --verbose --colors=always --exclude-group=ms-required",
66
  "export WP_MULTISITE=1 && vendor/bin/phpunit --verbose --colors=always --exclude-group=ms-excluded"
67
  ],
output/html/environment.php CHANGED
@@ -31,7 +31,7 @@ class QM_Output_Html_Environment extends QM_Output_Html {
31
  if ( $php_warning ) {
32
  $append .= sprintf(
33
  '&nbsp;<span class="qm-info">(<a href="%s" target="_blank" class="qm-external-link">%s</a>)</span>',
34
- 'https://wordpress.org/support/upgrade-php/',
35
  esc_html__( 'Help', 'query-monitor' )
36
  );
37
  $class = 'qm-warn';
31
  if ( $php_warning ) {
32
  $append .= sprintf(
33
  '&nbsp;<span class="qm-info">(<a href="%s" target="_blank" class="qm-external-link">%s</a>)</span>',
34
+ 'https://wordpress.org/support/update-php/',
35
  esc_html__( 'Help', 'query-monitor' )
36
  );
37
  $class = 'qm-warn';
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.3.4
14
  * Plugin URI: https://querymonitor.com/
15
  * Author: John Blackbourn
16
  * Author URI: https://querymonitor.com/
@@ -36,6 +36,7 @@ $qm_dir = dirname( __FILE__ );
36
  require_once "{$qm_dir}/classes/Plugin.php";
37
 
38
  if ( ! QM_Plugin::php_version_met() ) {
 
39
  return;
40
  }
41
 
10
  *
11
  * Plugin Name: Query Monitor
12
  * Description: The Developer Tools Panel for WordPress.
13
+ * Version: 3.3.5
14
  * Plugin URI: https://querymonitor.com/
15
  * Author: John Blackbourn
16
  * Author URI: https://querymonitor.com/
36
  require_once "{$qm_dir}/classes/Plugin.php";
37
 
38
  if ( ! QM_Plugin::php_version_met() ) {
39
+ add_action( 'admin_notices', 'QM_Plugin::php_version_nope' );
40
  return;
41
  }
42
 
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  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.1
6
- Stable tag: 3.3.4
7
  License: GPLv2 or later
8
  Requires PHP: 5.3
9
 
2
  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.2
6
+ Stable tag: 3.3.5
7
  License: GPLv2 or later
8
  Requires PHP: 5.3
9