diff --git a/src/js/run.js b/src/js/run.js old mode 100755 new mode 100644 index 3f51735..66624d5 --- a/src/js/run.js +++ b/src/js/run.js @@ -1,5 +1,5 @@ // Global variables. -var test_version, only_active, timer; +var test_version, only_active, skip_list, timer; jQuery( document ).ready(function($) { @@ -35,10 +35,12 @@ jQuery( document ).ready(function($) { resetDisplay(); test_version = $( 'input[name=phptest_version]:checked' ).val(); only_active = $( 'input[name=active_plugins]:checked' ).val(); + skip_list = $( 'textarea[name=skip_list]' ).val(); var data = { 'action': 'wpephpcompat_start_test', 'test_version': test_version, 'only_active': only_active, + 'skip_list': skip_list, 'startScan': 1 }; $( '.wpe-pcc-test-version' ).text(test_version); diff --git a/src/wpephpcompat.php b/src/wpephpcompat.php index 2f01622..79320a5 100644 --- a/src/wpephpcompat.php +++ b/src/wpephpcompat.php @@ -53,6 +53,15 @@ class WPEPHPCompat { */ public $only_active = null; + /** + * Skip some plugins by name, separated by `;` + * + * @since 1.5.0 + * @var string + */ + public $skip_list = null; + + /** * The base directory for the plugin. * @@ -69,31 +78,31 @@ class WPEPHPCompat { * @var array */ public $whitelist = array( - '*/jetpack/*' => '7.0', // https://github.com/wpengine/phpcompat/wiki/Results#jetpack - '*/wordfence/*' => '7.0', // https://github.com/wpengine/phpcompat/wiki/Results#wordfence-security - '*/woocommerce/*' => '7.0', // https://github.com/wpengine/phpcompat/wiki/Results#woocommerce - '*/wp-migrate-db/*' => '7.0', // https://github.com/wpengine/phpcompat/wiki/Results#wp-migrate-db - '*/easy-digital-downloads/*' => '7.0', // https://github.com/wpengine/phpcompat/wiki/Results#easy-digital-downloads - '*/updraftplus/*' => '7.0', - '*/megamenu/*' => '7.0', - '*/tablepress/*' => '7.0', - '*/myMail/*' => '7.0', - '*/wp-spamshield/*' => '7.0', + '*/jetpack/*' => '7.0', // https://github.com/wpengine/phpcompat/wiki/Results#jetpack + '*/wordfence/*' => '7.0', // https://github.com/wpengine/phpcompat/wiki/Results#wordfence-security + '*/woocommerce/*' => '7.0', // https://github.com/wpengine/phpcompat/wiki/Results#woocommerce + '*/wp-migrate-db/*' => '7.0', // https://github.com/wpengine/phpcompat/wiki/Results#wp-migrate-db + '*/easy-digital-downloads/*' => '7.0', // https://github.com/wpengine/phpcompat/wiki/Results#easy-digital-downloads + '*/updraftplus/*' => '7.0', + '*/megamenu/*' => '7.0', + '*/tablepress/*' => '7.0', + '*/myMail/*' => '7.0', + '*/wp-spamshield/*' => '7.0', '*/vendor/stripe/stripe-php/lib/StripeObject.php' => '7.0', // https://github.com/wpengine/phpcompat/issues/89 - '*/gravityforms/*' => '7.0', // https://github.com/wpengine/phpcompat/issues/85 - '*/download-monitor/*' => '7.0', // https://github.com/wpengine/phpcompat/issues/84 - '*/query-monitor/*' => '7.0', // https://wordpress.org/support/topic/false-positive-showing-query-monitor-as-not-php-7-compatible/ - '*/bbpress/*' => '7.0', // https://wordpress.org/support/topic/false-positive-showing-bbpress-as-not-php-7-compatible/ - '*/comet-cache/*' => '7.0', // https://wordpress.org/support/topic/false-positive-comet-cache/ - '*/comment-mail/*' => '7.0', // https://wordpress.org/support/topic/false-positive-comment-mail/ + '*/gravityforms/*' => '7.0', // https://github.com/wpengine/phpcompat/issues/85 + '*/download-monitor/*' => '7.0', // https://github.com/wpengine/phpcompat/issues/84 + '*/query-monitor/*' => '7.0', // https://wordpress.org/support/topic/false-positive-showing-query-monitor-as-not-php-7-compatible/ + '*/bbpress/*' => '7.0', // https://wordpress.org/support/topic/false-positive-showing-bbpress-as-not-php-7-compatible/ + '*/comet-cache/*' => '7.0', // https://wordpress.org/support/topic/false-positive-comet-cache/ + '*/comment-mail/*' => '7.0', // https://wordpress.org/support/topic/false-positive-comment-mail/ '*/social-networks-auto-poster-facebook-twitter-g/*' => '7.0', // https://wordpress.org/plugins/social-networks-auto-poster-facebook-twitter-g/ - '*/mailpoet/*' => '7.0', // https://wordpress.org/support/topic/false-positive-mailpoet-3-not-compatible-with-php7/ - '*/give/*' => '7.0', // https://github.com/wpengine/phpcompat/issues/148 - '*/woocommerce-pdf-invoices-packing-slips/*' => '7.0', // https://github.com/wpengine/phpcompat/issues/160 - '*/iwp-client/*' => '7.0', // https://wordpress.org/support/topic/iwp-client-and-php-7-compatibility/ - '*/health-check/*' => '7.2', // https://github.com/wpengine/phpcompat/issues/179 - '*/genesis/*' => '7.2', // https://github.com/wpengine/phpcompat/issues/127 - '*/wpmudev-updates/*' => '7.3', // https://github.com/wpengine/phpcompat/issues/178 + '*/mailpoet/*' => '7.0', // https://wordpress.org/support/topic/false-positive-mailpoet-3-not-compatible-with-php7/ + '*/give/*' => '7.0', // https://github.com/wpengine/phpcompat/issues/148 + '*/woocommerce-pdf-invoices-packing-slips/*' => '7.0', // https://github.com/wpengine/phpcompat/issues/160 + '*/iwp-client/*' => '7.0', // https://wordpress.org/support/topic/iwp-client-and-php-7-compatibility/ + '*/health-check/*' => '7.2', // https://github.com/wpengine/phpcompat/issues/179 + '*/genesis/*' => '7.2', // https://github.com/wpengine/phpcompat/issues/127 + '*/wpmudev-updates/*' => '7.3', // https://github.com/wpengine/phpcompat/issues/178 ); /** @@ -166,6 +175,7 @@ public function start_test() { update_option( 'wpephpcompat.status', '1', false ); update_option( 'wpephpcompat.test_version', $this->test_version, false ); update_option( 'wpephpcompat.only_active', $this->only_active, false ); + update_option( 'wpephpcompat.skip_list', $this->skip_list, false ); $this->debug_log( 'Generating directory list.' ); @@ -182,9 +192,9 @@ public function start_test() { $args = array( 'posts_per_page' => -1, - 'post_type' => 'wpephpcompat_jobs', - 'orderby' => 'title', - 'order' => 'ASC', + 'post_type' => 'wpephpcompat_jobs', + 'orderby' => 'title', + 'order' => 'ASC', ); $directories = get_posts( $args ); @@ -278,9 +288,9 @@ public function start_test() { * @return string Scan results. */ public function process_file( $dir ) { - $this->values['files'] = $dir; + $this->values['files'] = $dir; $this->values['testVersion'] = $this->test_version; - $this->values['standard'] = 'PHPCompatibility'; + $this->values['standard'] = 'PHPCompatibility'; $this->values['reportWidth'] = '9999'; $this->values['extensions'] = array( 'php' ); @@ -345,7 +355,13 @@ public function generate_directory_list() { $update_plugins = get_site_transient( 'update_plugins' ); + // strip newline for one line string + $this->skip_list = $this->skip_list ? str_replace(array("\r", "\n"), '', $this->skip_list) : ''; + // split on ; to array, strip leading and trailing whitespace + $ignored_plugins = $this->skip_list ? array_map('trim', explode(';', $this->skip_list) ) : []; + foreach ( $all_plugins as $k => $v ) { + // Exclude our plugin. if ( 'PHP Compatibility Checker' === $v['Name'] ) { continue; @@ -360,6 +376,9 @@ public function generate_directory_list() { continue; } } + if (in_array( $v['Name'], $ignored_plugins, true ) ) { + continue; + } $plugin_file = plugin_dir_path( $k ); @@ -391,6 +410,7 @@ public function generate_directory_list() { $all_themes = wp_get_themes(); foreach ( $all_themes as $k => $v ) { + continue; // TODO: remove this - it's only for skipping all themes since ours already passed if ( 'yes' === $this->only_active ) { $current_theme = wp_get_theme(); if ( $all_themes[ $k ]->Name !== $current_theme->Name ) { @@ -406,7 +426,7 @@ public function generate_directory_list() { // Add parent theme if the current theme is a child theme. if ( 'yes' === $this->only_active && is_child_theme() ) { $parent_theme_path = get_template_directory(); - $theme_data = wp_get_theme(); + $theme_data = wp_get_theme(); $parent_theme_name = $theme_data->parent()->Name; $this->add_directory( $parent_theme_name, $parent_theme_path ); @@ -417,7 +437,7 @@ public function generate_directory_list() { * Cleans and formats the final report. * * @param string $report The full report. - * @return string The cleaned report. + * @return string The cleaned report. */ public function clean_report( $report ) { // Remove unnecessary overview. @@ -446,7 +466,7 @@ public function clean_after_scan() { // Make sure all directories are removed from the queue. $args = array( 'posts_per_page' => -1, - 'post_type' => 'wpephpcompat_jobs', + 'post_type' => 'wpephpcompat_jobs', ); $directories = get_posts( $args ); @@ -469,7 +489,7 @@ private function add_directory( $name, $path ) { 'post_content' => $path, 'post_status' => 'publish', 'post_author' => 1, - 'post_type' => 'wpephpcompat_jobs', + 'post_type' => 'wpephpcompat_jobs', ); return wp_insert_post( $dir ); diff --git a/wpengine-phpcompat.php b/wpengine-phpcompat.php old mode 100755 new mode 100644 index 8f52611..33dc26e --- a/wpengine-phpcompat.php +++ b/wpengine-phpcompat.php @@ -9,8 +9,8 @@ * Plugin Name: PHP Compatibility Checker * Plugin URI: https://wpengine.com * Description: Make sure your plugins and themes are compatible with newer PHP versions. - * Author: WP Engine - * Version: 1.5.0 + * Author: WP Engine + * Version: 1.5.0 * Author URI: https://wpengine.com * Text Domain: php-compatibility-checker */ @@ -155,7 +155,7 @@ public function start_test() { $wpephpc = new WPEPHPCompat( dirname( __FILE__ ) ); $test_data = array(); - foreach ( array( 'test_version', 'only_active' ) as $key ) { + foreach ( array( 'test_version', 'only_active', 'skip_list' ) as $key ) { if ( isset( $_POST[ $key ] ) ) { $test_data[ $key ] = sanitize_text_field( $_POST[ $key ] ); } @@ -167,7 +167,7 @@ public function start_test() { $wpephpc->clean_after_scan(); // Fork so we can close the connection. - $this->fork_scan( $test_data['test_version'], $test_data['only_active'] ); + $this->fork_scan( $test_data['test_version'], $test_data['only_active'], $test_data['skip_list'] ); } else { if ( isset( $test_data['test_version'] ) ) { $wpephpc->test_version = $test_data['test_version']; @@ -177,6 +177,10 @@ public function start_test() { $wpephpc->only_active = $test_data['only_active']; } + if ( isset( $test_data['skip_list'] ) ) { + $wpephpc->skip_list = $test_data['skip_list']; + } + $wpephpc->start_test(); } @@ -199,15 +203,16 @@ public function check_status() { $total_jobs = get_option( 'wpephpcompat.numdirs' ); $test_version = get_option( 'wpephpcompat.test_version' ); $only_active = get_option( 'wpephpcompat.only_active' ); + $skip_list = get_option( 'wpephpcompat.skip_list' ); $active_job = false; $jobs = get_posts( array( 'posts_per_page' => -1, - 'post_type' => 'wpephpcompat_jobs', - 'orderby' => 'title', - 'order' => 'ASC', + 'post_type' => 'wpephpcompat_jobs', + 'orderby' => 'title', + 'order' => 'ASC', ) ); @@ -216,11 +221,11 @@ public function check_status() { } $to_encode = array( - 'status' => $scan_status, - 'count' => $count_jobs->publish, - 'total' => $total_jobs, + 'status' => $scan_status, + 'count' => $count_jobs->publish, + 'total' => $total_jobs, 'activeJob' => $active_job, - 'version' => $test_version, + 'version' => $test_version, 'onlyActive' => $only_active, ); @@ -249,7 +254,7 @@ public function check_status() { * @param string $test_version Version of PHP to test. * @param string $only_active Whether to scan only active plugins or all. */ - public function fork_scan( $test_version, $only_active ) { + public function fork_scan( $test_version, $only_active, $skip_list ) { $query = array( 'action' => 'wpephpcompat_start_test', ); @@ -258,13 +263,14 @@ public function fork_scan( $test_version, $only_active ) { $body = array( 'test_version' => $test_version, 'only_active' => $only_active, + 'skip_list' => $skip_list ); // Instantly return! $args = array( 'timeout' => 0.01, 'blocking' => false, - 'body' => $body, + 'body' => $body, 'cookies' => $_COOKIE, 'sslverify' => apply_filters( 'https_local_ssl_verify', false ), ); @@ -313,11 +319,11 @@ public function create_job_queue() { register_post_type( 'wpephpcompat_jobs', array( - 'labels' => array( - 'name' => __( 'Jobs', 'php-compatibility-checker' ), + 'labels' => array( + 'name' => __( 'Jobs', 'php-compatibility-checker' ), 'singular_name' => __( 'Job', 'php-compatibility-checker' ), ), - 'public' => false, + 'public' => false, 'has_archive' => false, ) ); @@ -370,14 +376,14 @@ public function admin_enqueue( $hook ) { * These translated strings can be access in jquery with window.wpephpcompat object. */ $strings = array( - 'name' => __( 'Name', 'php-compatibility-checker' ), + 'name' => __( 'Name', 'php-compatibility-checker' ), 'compatible' => __( 'compatible', 'php-compatibility-checker' ), - 'are_not' => __( 'plugins/themes may not be compatible', 'php-compatibility-checker' ), - 'is_not' => __( 'Your WordPress site is possibly not PHP', 'php-compatibility-checker' ), - 'out_of' => __( 'out of', 'php-compatibility-checker' ), - 'run' => __( 'Scan site', 'php-compatibility-checker' ), - 'rerun' => __( 'Scan site again', 'php-compatibility-checker' ), - 'your_wp' => __( 'Your WordPress site is', 'php-compatibility-checker' ), + 'are_not' => __( 'plugins/themes may not be compatible', 'php-compatibility-checker' ), + 'is_not' => __( 'Your WordPress site is possibly not PHP', 'php-compatibility-checker' ), + 'out_of' => __( 'out of', 'php-compatibility-checker' ), + 'run' => __( 'Scan site', 'php-compatibility-checker' ), + 'rerun' => __( 'Scan site again', 'php-compatibility-checker' ), + 'your_wp' => __( 'Your WordPress site is', 'php-compatibility-checker' ), ); wp_localize_script( 'wpephpcompat', 'wpephpcompat', $strings ); @@ -404,6 +410,7 @@ public function settings_page() { // Discover last options used. $test_version = get_option( 'wpephpcompat.test_version' ); $only_active = get_option( 'wpephpcompat.only_active' ); + $skip_list = get_option( 'wpephpcompat.skip_list' ); // Determine if current site is a WP Engine customer. $is_wpe_customer = ! empty( $_SERVER['IS_WPE'] ) && $_SERVER['IS_WPE']; @@ -413,13 +420,14 @@ public function settings_page() { // Assigns defaults for the scan if none are found in the database. $test_version = ( ! empty( $test_version ) ) ? $test_version : '7.0'; $only_active = ( ! empty( $only_active ) ) ? $only_active : 'yes'; + $skip_list = ( ! empty( $skip_list ) ) ? $skip_list : 'FFATG Cookie Notice'; // Content variables. - $url_get_hosting = esc_url( 'https://wpeng.in/5a0336/' ); + $url_get_hosting = esc_url( 'https://wpeng.in/5a0336/' ); $url_wpe_agency_partners = esc_url( 'https://wpeng.in/fa14e4/' ); $url_wpe_customer_upgrade = esc_url( 'https://wpeng.in/407b79/' ); - $url_wpe_logo = esc_url( 'https://wpeng.in/22f22b/' ); - $url_codeable_submit = esc_url( 'https://codeable.io/wp-admin/admin-ajax.php?action=wp_engine_phpcompat' ); + $url_wpe_logo = esc_url( 'https://wpeng.in/22f22b/' ); + $url_codeable_submit = esc_url( 'https://codeable.io/wp-admin/admin-ajax.php?action=wp_engine_phpcompat' ); $update_url = site_url( 'wp-admin/update-core.php', 'admin' ); @@ -455,6 +463,23 @@ public function settings_page() { + + + +
+ + + +
+ +