PHP Compatibility Checker - Version 1.0.2

Version Description

  • Added additional role protections
  • Changed the UI colors to better understand output at a glance
  • Exclude checking node_modules and tmp directories
  • Added support for child theme's parent theme
Download this release

Release Info

Developer wpengine
Plugin Icon 128x128 PHP Compatibility Checker
Version 1.0.2
Comparing to
See all releases

Code changes from version 1.0.1 to 1.0.2

Files changed (4) hide show
  1. readme.txt +32 -13
  2. src/css/style.css +1 -1
  3. src/wpephpcompat.php +11 -2
  4. wpengine-phpcompat.php +43 -40
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: wpengine, octalmage, stevenkword, taylor4484
3
  Tags: php 7, php 5.5, php, version, compatibility, checker, wp engine, wpe, wpengine
4
  Requires at least: 3.0.1
5
  Tested up to: 4.5
6
- Stable tag: 1.0.1
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -13,15 +13,17 @@ Make sure your plugins and themes are compatible with newer PHP versions.
13
 
14
  The WP Engine PHP Compatibility Checker can be used by any WordPress website on any web host to check PHP version compatibility.
15
 
16
- This plugin will lint theme and plugin code inside your WordPress file system and give you back a report of compatibility issues for you to fix. Compatibility issues are categorized into errors and warnings and will list the file and line number of the offending code, as well as the info about why that line of code is incompatible with the chosen version of PHP. The plugin will also suggest updates to themes and plugins, as a new version may offer compatible code.
17
 
18
  **This plugin does not execute your theme and plugin code, as such this plugin cannot detect runtime compatibility issues.**
19
 
 
 
20
  = Update to PHP 7 =
21
  * Use this plugin to check your site for compatibility for PHP 7!
22
- * As of June 2016, 60.2% of WordPress websites run a PHP version less PHP 5.5.
23
  * These versions of PHP have been deprecated and unsupported for over 9 months.
24
- * Only 1.7% of WordPress websites run PHP 7, the current main version of PHP.
25
 
26
 
27
  = Disclaimer =
@@ -29,14 +31,19 @@ This plugin will lint theme and plugin code inside your WordPress file system an
29
 
30
  The plugin was created by WP Engine to help the WordPress community increase adoption of modern PHP versions. We [welcome contributors](https://github.com/wpengine/phpcompat) to this plugin, and are excited to see how developers and other WordPress hosts use this plugin.
31
 
 
 
32
  == Installation ==
33
 
34
- *Note: If you have WordPress 2.7 or above you can simply go to 'Plugins' > 'Add New' in the WordPress admin and search for "Indeed Apply Shortcode" and install it from there.*
35
 
 
36
  1. Upload `phpcompat` to the `/wpengine-wp-content/plugins/` directory
37
  2. Activate the plugin through the 'Plugins' menu in WordPress
38
 
39
- You will find the plugin options in the WP Admin Tools => PHP Compatibility menu. Once you click run it will take a few minutes to conduct the test. While the test is running, you cannot navigate away from the page.
 
 
40
 
41
  == Other Notes ==
42
 
@@ -60,24 +67,28 @@ Example: `wp phpcompat 5.5 --scan=active`
60
 
61
  == Frequently Asked Questions ==
62
 
63
- 1) Will this work outside of the WP Engine hosting account?
64
 
65
  Yes, this plugin can be used any ANY WordPress website on ANY host.
66
 
 
 
67
 
68
- 2) Can I use this to test non-WordPress PHP Projects?
69
 
70
  Yes! While you cannot use this WordPress plugin to test your non-WordPress projects, you can use the [Open Source PHPCompatibility Library](https://github.com/wimg/PHPCompatibility) that this plugin is built on.
71
 
72
- 3) Why was my plugin/theme skipped?
73
  Some servers have timeouts to prevent long running queries, this is commonly 60 seconds. This can prevent the checker from being able to process large themes or plugins. You should check with your host to see if this timeout can be temporarily removed. The best way around this timeout issues is to run this plugin on a [local copy](https://make.wordpress.org/core/handbook/tutorials/installing-a-local-server/) of your site.
74
 
75
- 4) I found a bug, or have a suggestion, can I contribute back?
76
 
77
  Yes! WP Engine has a public GitHub repo where you can contribute back to this plugin. Please open an issue on the [Plugin GitHub](https://github.com/wpengine/phpcompat). We actively develop this plugin, and are always happy to receive pull requests.
78
 
79
  The plugin was created by WP Engine to help the WordPress community increase adoption of modern PHP versions. We welcome contributors to this plugin, and are excited to see how developers and other WordPress hosts use this plugin.
80
 
 
 
81
  == Screenshots ==
82
 
83
  1. Main screen: compatibility checker options
@@ -85,6 +96,12 @@ The plugin was created by WP Engine to help the WordPress community increase ado
85
 
86
  == Changelog ==
87
 
 
 
 
 
 
 
88
  = 1.0.1 =
89
  - Updated compatibility library with a few bugfixes
90
  - Added skip logic to prevent checker from hanging
@@ -101,6 +118,8 @@ The plugin was created by WP Engine to help the WordPress community increase ado
101
 
102
  == Upgrade Notice ==
103
 
104
- = 1.0.1 =
105
- - Updated compatibility library with a few bugfixes
106
- - Added skip logic to prevent checker from hanging
 
 
3
  Tags: php 7, php 5.5, php, version, compatibility, checker, wp engine, wpe, wpengine
4
  Requires at least: 3.0.1
5
  Tested up to: 4.5
6
+ Stable tag: 1.0.2
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
13
 
14
  The WP Engine PHP Compatibility Checker can be used by any WordPress website on any web host to check PHP version compatibility.
15
 
16
+ This plugin will lint theme and plugin code inside your WordPress file system and give you back a report of compatibility issues for you to fix. Compatibility issues are categorized into errors and warnings and will list the file and line number of the offending code, as well as the info about why that line of code is incompatible with the chosen version of PHP. The plugin will also suggest updates to themes and plugins, as a new version may offer compatible code.
17
 
18
  **This plugin does not execute your theme and plugin code, as such this plugin cannot detect runtime compatibility issues.**
19
 
20
+ **Please note that linting code is not perfect. We are aware of a few infrequent false positives, we are continuously working to ensure the checker provides the most accurate results possible.**
21
+
22
  = Update to PHP 7 =
23
  * Use this plugin to check your site for compatibility for PHP 7!
24
+ * As of July 2016, 59.3% of WordPress websites run a PHP version less PHP 5.5.
25
  * These versions of PHP have been deprecated and unsupported for over 9 months.
26
+ * Only 1.8% of WordPress websites run PHP 7, the current main version of PHP.
27
 
28
 
29
  = Disclaimer =
31
 
32
  The plugin was created by WP Engine to help the WordPress community increase adoption of modern PHP versions. We [welcome contributors](https://github.com/wpengine/phpcompat) to this plugin, and are excited to see how developers and other WordPress hosts use this plugin.
33
 
34
+ To disclose security issues for this plugin please email WordPress@wpengine.com
35
+
36
  == Installation ==
37
 
38
+ *Note: If you have WordPress 2.7 or above you can simply go to 'Plugins' > 'Add New' in the WordPress admin and search for "PHP Compatibility Checker" and install it from there.*
39
 
40
+ To manually install:
41
  1. Upload `phpcompat` to the `/wpengine-wp-content/plugins/` directory
42
  2. Activate the plugin through the 'Plugins' menu in WordPress
43
 
44
+ You will find the plugin options in the WP Admin `Tools => PHP Compatibility` menu. Once you click `run` it will take a few minutes to conduct the test. While the test is running, you cannot navigate away from the page.
45
+
46
+ There are WP-CLI commands available see the [Other Notes](https://wordpress.org/plugins/php-compatibility-checker/other_notes/) tab for details.
47
 
48
  == Other Notes ==
49
 
67
 
68
  == Frequently Asked Questions ==
69
 
70
+ 1. Will this work outside of the WP Engine hosting account?
71
 
72
  Yes, this plugin can be used any ANY WordPress website on ANY host.
73
 
74
+ 2. Are there WP-CLI commands available?
75
+ Yes, this plugin does extend WP-CLI and provide commands. See the [Other Notes](https://wordpress.org/plugins/php-compatibility-checker/other_notes/) tab for details.
76
 
77
+ 3. Can I use this to test non-WordPress PHP Projects?
78
 
79
  Yes! While you cannot use this WordPress plugin to test your non-WordPress projects, you can use the [Open Source PHPCompatibility Library](https://github.com/wimg/PHPCompatibility) that this plugin is built on.
80
 
81
+ 4. Why was my plugin/theme skipped?
82
  Some servers have timeouts to prevent long running queries, this is commonly 60 seconds. This can prevent the checker from being able to process large themes or plugins. You should check with your host to see if this timeout can be temporarily removed. The best way around this timeout issues is to run this plugin on a [local copy](https://make.wordpress.org/core/handbook/tutorials/installing-a-local-server/) of your site.
83
 
84
+ 5. I found a bug, or have a suggestion, can I contribute back?
85
 
86
  Yes! WP Engine has a public GitHub repo where you can contribute back to this plugin. Please open an issue on the [Plugin GitHub](https://github.com/wpengine/phpcompat). We actively develop this plugin, and are always happy to receive pull requests.
87
 
88
  The plugin was created by WP Engine to help the WordPress community increase adoption of modern PHP versions. We welcome contributors to this plugin, and are excited to see how developers and other WordPress hosts use this plugin.
89
 
90
+ To disclose security issues for this plugin please email WordPress@wpengine.com
91
+
92
  == Screenshots ==
93
 
94
  1. Main screen: compatibility checker options
96
 
97
  == Changelog ==
98
 
99
+ = 1.0.2 =
100
+ - Added additional role protections
101
+ - Changed the UI colors to better understand output at a glance
102
+ - Exclude checking node_modules and tmp directories
103
+ - Added support for child theme's parent theme
104
+
105
  = 1.0.1 =
106
  - Updated compatibility library with a few bugfixes
107
  - Added skip logic to prevent checker from hanging
118
 
119
  == Upgrade Notice ==
120
 
121
+ = 1.0.2 =
122
+ - Added additional role protections
123
+ - Changed the UI colors to better understand output at a glance
124
+ - Exclude checking node_modules and tmp directories
125
+ - Added support for child theme's parent theme
src/css/style.css CHANGED
@@ -68,7 +68,7 @@
68
 
69
  .wpe-results-card .wpe-update
70
  {
71
- background-color: #60bb8f;
72
  }
73
 
74
  .wpe-results-card .warnings
68
 
69
  .wpe-results-card .wpe-update
70
  {
71
+ background-color: #0085ba;
72
  }
73
 
74
  .wpe-results-card .warnings
src/wpephpcompat.php CHANGED
@@ -209,7 +209,7 @@ class WPEPHPCompat {
209
  $this->values['standard'] = 'PHPCompatibility';
210
  $this->values['reportWidth'] = '9999';
211
  $this->values['extensions'] = array( 'php' );
212
- $this->values['ignored'] = array( '*/tests/*', '*/jetpack/modules/*' );
213
 
214
  PHP_CodeSniffer::setConfigData( 'testVersion', $this->test_version, true );
215
 
@@ -297,6 +297,15 @@ class WPEPHPCompat {
297
 
298
  $this->add_directory( $all_themes[$k]->Name, $theme_path );
299
  }
 
 
 
 
 
 
 
 
 
300
  }
301
 
302
  /**
@@ -401,7 +410,7 @@ class WPEPHPCompat {
401
  */
402
  private function close_connection( $body ) {
403
  ignore_user_abort( true );
404
- ob_end_clean();
405
  // Start buffering.
406
  ob_start();
407
  // Echo our response.
209
  $this->values['standard'] = 'PHPCompatibility';
210
  $this->values['reportWidth'] = '9999';
211
  $this->values['extensions'] = array( 'php' );
212
+ $this->values['ignored'] = array( '*/tests/*', '*/jetpack/modules/*', '*/node_modules/*', '*/tmp/*' );
213
 
214
  PHP_CodeSniffer::setConfigData( 'testVersion', $this->test_version, true );
215
 
297
 
298
  $this->add_directory( $all_themes[$k]->Name, $theme_path );
299
  }
300
+
301
+ // Add parent theme if the current theme is a child theme.
302
+ if ( 'yes' === $this->only_active && is_child_theme() ) {
303
+ $parent_theme_path = get_template_directory();
304
+ $theme_data = wp_get_theme();
305
+ $parent_theme_name = $theme_data->parent()->Name;
306
+
307
+ $this->add_directory( $parent_theme_name, $parent_theme_path );
308
+ }
309
  }
310
 
311
  /**
410
  */
411
  private function close_connection( $body ) {
412
  ignore_user_abort( true );
413
+ if (ob_get_length()) ob_end_clean();
414
  // Start buffering.
415
  ob_start();
416
  // Echo our response.
wpengine-phpcompat.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: PHP Compatibility Checker
4
  Plugin URI: https://wpengine.com
5
  Description: Make sure your plugins and themes are compatible with newer PHP versions.
6
  Author: WP Engine
7
- Version: 1.0.1
8
  Author URI: https://wpengine.com
9
  */
10
 
@@ -73,21 +73,23 @@ class WPEngine_PHPCompat {
73
  * @return null
74
  */
75
  function start_test() {
76
- global $wpdb;
 
77
 
78
- $wpephpc = new \WPEPHPCompat( __DIR__ );
79
 
80
- if ( isset( $_POST['startScan'] ) ) {
81
- $test_version = sanitize_text_field( $_POST['test_version'] );
82
- $only_active = sanitize_text_field( $_POST['only_active'] );
83
 
84
- $wpephpc->test_version = $test_version;
85
- $wpephpc->only_active = $only_active;
86
- $wpephpc->clean_after_scan();
87
- }
88
 
89
- $wpephpc->start_test();
90
- wp_die();
 
91
  }
92
 
93
  /**
@@ -99,33 +101,34 @@ class WPEngine_PHPCompat {
99
  * @return null
100
  */
101
  function check_status() {
102
- $scan_status = get_option( 'wpephpcompat.status' );
103
- $count_jobs = wp_count_posts( 'wpephpcompat_jobs' );
104
- $total_jobs = get_option( 'wpephpcompat.numdirs' );
105
-
106
- $to_encode = array(
107
- 'status' => $scan_status,
108
- 'count' => $count_jobs->publish,
109
- 'total' => $total_jobs,
110
- 'progress' => 100 - ( ( $count_jobs->publish / $total_jobs ) * 100 )
111
- );
112
-
113
- // If the scan is still running.
114
- if ( $scan_status ) {
115
- $to_encode['results'] = '0';
116
- } else {
117
- // Else return the results and clean up!
118
- $scan_results = get_option( 'wpephpcompat.scan_results' );
119
- // Not using esc_html since the results are shown in a textarea.
120
- $to_encode['results'] = $scan_results;
121
-
122
- $wpephpc = new \WPEPHPCompat( __DIR__ );
123
- $wpephpc->clean_after_scan();
 
 
 
 
 
124
  }
125
-
126
- echo json_encode( $to_encode );
127
- wp_die();
128
-
129
  }
130
 
131
  /**
@@ -184,7 +187,7 @@ class WPEngine_PHPCompat {
184
  */
185
  function create_menu() {
186
  // Create Tools sub-menu.
187
- $this->page = add_submenu_page( 'tools.php', 'PHP Compatibility', 'PHP Compatibility', 'administrator', __FILE__, array( self::instance(), 'settings_page' ) );
188
  }
189
 
190
  /**
@@ -264,7 +267,7 @@ class WPEngine_PHPCompat {
264
  <textarea style="display: none; white-space: pre;">{{logs}}</textarea><a class="view-details">view details</a>
265
  </div>
266
  <?php $update_url = site_url( 'wp-admin/update-core.php' , 'admin' ); ?>
267
- <div style="float:right;">{{#if updateAvailable}}<div class="badge wpe-update"><a href="<?php echo esc_url( $update_url ); ?>">Update Available</a></div>{{/if}}<div class="badge warnings">{{warnings}} Warnings</div><div class="badge errors">{{errors}} Errors</div></div>
268
  </div>
269
  </script>
270
  <?php
4
  Plugin URI: https://wpengine.com
5
  Description: Make sure your plugins and themes are compatible with newer PHP versions.
6
  Author: WP Engine
7
+ Version: 1.0.2
8
  Author URI: https://wpengine.com
9
  */
10
 
73
  * @return null
74
  */
75
  function start_test() {
76
+ if ( current_user_can( 'manage_options' ) || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
77
+ global $wpdb;
78
 
79
+ $wpephpc = new \WPEPHPCompat( __DIR__ );
80
 
81
+ if ( isset( $_POST['startScan'] ) ) {
82
+ $test_version = sanitize_text_field( $_POST['test_version'] );
83
+ $only_active = sanitize_text_field( $_POST['only_active'] );
84
 
85
+ $wpephpc->test_version = $test_version;
86
+ $wpephpc->only_active = $only_active;
87
+ $wpephpc->clean_after_scan();
88
+ }
89
 
90
+ $wpephpc->start_test();
91
+ wp_die();
92
+ }
93
  }
94
 
95
  /**
101
  * @return null
102
  */
103
  function check_status() {
104
+ if ( current_user_can( 'manage_options' ) || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
105
+ $scan_status = get_option( 'wpephpcompat.status' );
106
+ $count_jobs = wp_count_posts( 'wpephpcompat_jobs' );
107
+ $total_jobs = get_option( 'wpephpcompat.numdirs' );
108
+
109
+ $to_encode = array(
110
+ 'status' => $scan_status,
111
+ 'count' => $count_jobs->publish,
112
+ 'total' => $total_jobs,
113
+ 'progress' => 100 - ( ( $count_jobs->publish / $total_jobs ) * 100 )
114
+ );
115
+
116
+ // If the scan is still running.
117
+ if ( $scan_status ) {
118
+ $to_encode['results'] = '0';
119
+ } else {
120
+ // Else return the results and clean up!
121
+ $scan_results = get_option( 'wpephpcompat.scan_results' );
122
+ // Not using esc_html since the results are shown in a textarea.
123
+ $to_encode['results'] = $scan_results;
124
+
125
+ $wpephpc = new \WPEPHPCompat( __DIR__ );
126
+ $wpephpc->clean_after_scan();
127
+ }
128
+
129
+ echo json_encode( $to_encode );
130
+ wp_die();
131
  }
 
 
 
 
132
  }
133
 
134
  /**
187
  */
188
  function create_menu() {
189
  // Create Tools sub-menu.
190
+ $this->page = add_submenu_page( 'tools.php', 'PHP Compatibility', 'PHP Compatibility', 'manage_options', __FILE__, array( self::instance(), 'settings_page' ) );
191
  }
192
 
193
  /**
267
  <textarea style="display: none; white-space: pre;">{{logs}}</textarea><a class="view-details">view details</a>
268
  </div>
269
  <?php $update_url = site_url( 'wp-admin/update-core.php' , 'admin' ); ?>
270
+ <div style="float:right;">{{#if updateAvailable}}<div class="badge wpe-update"><a href="<?php echo esc_url( $update_url ); ?>">Update Available</a></div>{{/if}}{{#if warnings}}<div class="badge warnings">{{warnings}} Warnings</div>{{/if}}{{#if errors}}<div class="badge errors">{{errors}} Errors</div>{{/if}}</div>
271
  </div>
272
  </script>
273
  <?php