From 56b0e3a2c7376c620eb6e1b7d66dbd82b7cb6dd1 Mon Sep 17 00:00:00 2001 From: Kader Ibrahim S Date: Fri, 6 Oct 2023 20:46:24 +0530 Subject: [PATCH 1/8] Moves autoload to main plugin class. --- class-wc-facebookcommerce.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/class-wc-facebookcommerce.php b/class-wc-facebookcommerce.php index dd22e2064..9a2737099 100644 --- a/class-wc-facebookcommerce.php +++ b/class-wc-facebookcommerce.php @@ -9,8 +9,7 @@ * @package FacebookCommerce */ -require_once __DIR__ . '/vendor/autoload.php'; -require_once __DIR__ . '/includes/fbutils.php'; + require_once __DIR__ . '/includes/fbutils.php'; use Automattic\WooCommerce\Admin\Features\Features as WooAdminFeatures; use Automattic\WooCommerce\Admin\Features\OnboardingTasks\TaskLists; From 55688c06ccfea10d98e8a4cf2637c840aa4afb30 Mon Sep 17 00:00:00 2001 From: Kader Ibrahim S Date: Fri, 6 Oct 2023 20:46:52 +0530 Subject: [PATCH 2/8] Adds Grow compat checker to composer. --- composer.json | 7 +++- composer.lock | 107 +++++++++++++++++++++++++++++++++----------------- 2 files changed, 77 insertions(+), 37 deletions(-) diff --git a/composer.json b/composer.json index 24caa03ee..6c341cc6c 100644 --- a/composer.json +++ b/composer.json @@ -7,12 +7,17 @@ { "type": "vcs", "url": "https://github.com/woocommerce/action-scheduler-job-framework" + }, + { + "type": "vcs", + "url": "https://github.com/woocommerce/grow" } ], "require": { "php": ">=7.4", "woocommerce/action-scheduler-job-framework": "2.0.0", - "composer/installers": "~1.0" + "composer/installers": "~1.0", + "woocommerce/grow": "dev-compat-checker" }, "require-dev": { "dealerdirect/phpcodesniffer-composer-installer": "^v0.7", diff --git a/composer.lock b/composer.lock index aec467fac..fe127fa5a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "08f484867e06d505d123ecb9dbe36f0b", + "content-hash": "457b046ddd23b25d32db4ac87378491c", "packages": [ { "name": "composer/installers", @@ -197,6 +197,39 @@ "issues": "https://github.com/woocommerce/action-scheduler-job-framework/issues" }, "time": "2021-05-20T02:32:48+00:00" + }, + { + "name": "woocommerce/grow", + "version": "dev-compat-checker", + "source": { + "type": "git", + "url": "https://github.com/woocommerce/grow.git", + "reference": "11cc586331ea0ddd327c1cb2541bc50fccfb77d5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/woocommerce/grow/zipball/11cc586331ea0ddd327c1cb2541bc50fccfb77d5", + "reference": "11cc586331ea0ddd327c1cb2541bc50fccfb77d5", + "shasum": "" + }, + "require-dev": { + "woocommerce/woocommerce-sniffs": "^0.1.3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Automattic\\WooCommerce\\Grow\\Tools\\CompatChecker\\v0_0_1\\": "src/" + } + }, + "license": [ + "GPL-3.0" + ], + "description": "Compatibility checker for Woo Grow extensions", + "support": { + "source": "https://github.com/woocommerce/grow/tree/compat-checker", + "issues": "https://github.com/woocommerce/grow/issues" + }, + "time": "2023-10-03T06:29:21+00:00" } ], "packages-dev": [ @@ -1059,16 +1092,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "9.2.27", + "version": "9.2.29", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "b0a88255cb70d52653d80c890bd7f38740ea50d1" + "reference": "6a3a87ac2bbe33b25042753df8195ba4aa534c76" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/b0a88255cb70d52653d80c890bd7f38740ea50d1", - "reference": "b0a88255cb70d52653d80c890bd7f38740ea50d1", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/6a3a87ac2bbe33b25042753df8195ba4aa534c76", + "reference": "6a3a87ac2bbe33b25042753df8195ba4aa534c76", "shasum": "" }, "require": { @@ -1125,7 +1158,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.27" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.29" }, "funding": [ { @@ -1133,7 +1166,7 @@ "type": "github" } ], - "time": "2023-07-26T13:44:30+00:00" + "time": "2023-09-19T04:57:46+00:00" }, { "name": "phpunit/php-file-iterator", @@ -1378,16 +1411,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.6.11", + "version": "9.6.13", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "810500e92855eba8a7a5319ae913be2da6f957b0" + "reference": "f3d767f7f9e191eab4189abe41ab37797e30b1be" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/810500e92855eba8a7a5319ae913be2da6f957b0", - "reference": "810500e92855eba8a7a5319ae913be2da6f957b0", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/f3d767f7f9e191eab4189abe41ab37797e30b1be", + "reference": "f3d767f7f9e191eab4189abe41ab37797e30b1be", "shasum": "" }, "require": { @@ -1402,7 +1435,7 @@ "phar-io/manifest": "^2.0.3", "phar-io/version": "^3.0.2", "php": ">=7.3", - "phpunit/php-code-coverage": "^9.2.13", + "phpunit/php-code-coverage": "^9.2.28", "phpunit/php-file-iterator": "^3.0.5", "phpunit/php-invoker": "^3.1.1", "phpunit/php-text-template": "^2.0.3", @@ -1461,7 +1494,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.11" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.13" }, "funding": [ { @@ -1477,7 +1510,7 @@ "type": "tidelift" } ], - "time": "2023-08-19T07:10:56+00:00" + "time": "2023-09-19T05:39:22+00:00" }, { "name": "sebastian/cli-parser", @@ -2632,16 +2665,16 @@ }, { "name": "symfony/polyfill-php80", - "version": "v1.27.0", + "version": "v1.28.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936" + "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936", - "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/6caa57379c4aec19c0a12a38b59b26487dcfe4b5", + "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5", "shasum": "" }, "require": { @@ -2650,7 +2683,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.27-dev" + "dev-main": "1.28-dev" }, "thanks": { "name": "symfony/polyfill", @@ -2695,7 +2728,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.27.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.28.0" }, "funding": [ { @@ -2711,7 +2744,7 @@ "type": "tidelift" } ], - "time": "2022-11-03T14:55:06+00:00" + "time": "2023-01-26T09:26:14+00:00" }, { "name": "theseer/tokenizer", @@ -2809,16 +2842,16 @@ }, { "name": "wp-cli/i18n-command", - "version": "v2.4.3", + "version": "v2.4.4", "source": { "type": "git", "url": "https://github.com/wp-cli/i18n-command.git", - "reference": "203b020318fe2596a218bf52db25adc6b187f42d" + "reference": "7d82e675f271359b1af614e6325d8eeaeb7d7474" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/wp-cli/i18n-command/zipball/203b020318fe2596a218bf52db25adc6b187f42d", - "reference": "203b020318fe2596a218bf52db25adc6b187f42d", + "url": "https://api.github.com/repos/wp-cli/i18n-command/zipball/7d82e675f271359b1af614e6325d8eeaeb7d7474", + "reference": "7d82e675f271359b1af614e6325d8eeaeb7d7474", "shasum": "" }, "require": { @@ -2829,7 +2862,7 @@ }, "require-dev": { "wp-cli/scaffold-command": "^1.2 || ^2", - "wp-cli/wp-cli-tests": "^3.1" + "wp-cli/wp-cli-tests": "^4" }, "suggest": { "ext-json": "Used for reading and generating JSON translation files", @@ -2871,9 +2904,9 @@ "homepage": "https://github.com/wp-cli/i18n-command", "support": { "issues": "https://github.com/wp-cli/i18n-command/issues", - "source": "https://github.com/wp-cli/i18n-command/tree/v2.4.3" + "source": "https://github.com/wp-cli/i18n-command/tree/v2.4.4" }, - "time": "2023-03-24T18:15:59+00:00" + "time": "2023-08-30T18:00:10+00:00" }, { "name": "wp-cli/mustangostang-spyc", @@ -2928,16 +2961,16 @@ }, { "name": "wp-cli/php-cli-tools", - "version": "v0.11.19", + "version": "v0.11.21", "source": { "type": "git", "url": "https://github.com/wp-cli/php-cli-tools.git", - "reference": "2d27f0db5c36f5aa0064abecddd6d05f28c4d001" + "reference": "b3457a8d60cd0b1c48cab76ad95df136d266f0b6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/wp-cli/php-cli-tools/zipball/2d27f0db5c36f5aa0064abecddd6d05f28c4d001", - "reference": "2d27f0db5c36f5aa0064abecddd6d05f28c4d001", + "url": "https://api.github.com/repos/wp-cli/php-cli-tools/zipball/b3457a8d60cd0b1c48cab76ad95df136d266f0b6", + "reference": "b3457a8d60cd0b1c48cab76ad95df136d266f0b6", "shasum": "" }, "require": { @@ -2945,7 +2978,7 @@ }, "require-dev": { "roave/security-advisories": "dev-latest", - "wp-cli/wp-cli-tests": "^3.1.6" + "wp-cli/wp-cli-tests": "^4" }, "type": "library", "extra": { @@ -2985,9 +3018,9 @@ ], "support": { "issues": "https://github.com/wp-cli/php-cli-tools/issues", - "source": "https://github.com/wp-cli/php-cli-tools/tree/v0.11.19" + "source": "https://github.com/wp-cli/php-cli-tools/tree/v0.11.21" }, - "time": "2023-07-21T11:37:15+00:00" + "time": "2023-09-29T15:28:10+00:00" }, { "name": "wp-cli/wp-cli", @@ -3173,7 +3206,9 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "woocommerce/grow": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { From d64a0f435bc5cb205c054306eb767b87e2f4becb Mon Sep 17 00:00:00 2001 From: Kader Ibrahim S Date: Fri, 6 Oct 2023 20:47:39 +0530 Subject: [PATCH 3/8] Adds compat checker checks before plugin init. --- facebook-for-woocommerce.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/facebook-for-woocommerce.php b/facebook-for-woocommerce.php index 60da98993..7d5eaee5f 100644 --- a/facebook-for-woocommerce.php +++ b/facebook-for-woocommerce.php @@ -21,6 +21,9 @@ * @package FacebookCommerce */ +require_once __DIR__ . '/vendor/autoload.php'; + +use Automattic\WooCommerce\Grow\Tools\CompatChecker\v0_0_1\Checker; use Automattic\WooCommerce\Utilities\FeaturesUtil; defined( 'ABSPATH' ) || exit; @@ -88,7 +91,6 @@ protected function __construct() { add_action( 'admin_init', array( $this, 'check_environment' ) ); - add_action( 'admin_notices', array( $this, 'add_plugin_notices' ) ); // admin_init is too early for the get_current_screen() function. add_action( 'admin_notices', array( $this, 'admin_notices' ), 15 ); // If the environment check fails, initialize the plugin. @@ -127,7 +129,7 @@ public function __wakeup() { */ public function init_plugin() { - if ( ! $this->plugins_compatible() ) { + if ( ! Checker::instance()->is_compatible( __FILE__, self::PLUGIN_VERSION ) || ! $this->plugins_compatible() ) { return; } From 638f2134f4addcc209bfec2b204ddee5faf4c5f7 Mon Sep 17 00:00:00 2001 From: Kader Ibrahim S Date: Thu, 12 Oct 2023 11:37:47 +0530 Subject: [PATCH 4/8] Update class-wc-facebookcommerce.php Co-authored-by: Rodrigue --- class-wc-facebookcommerce.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/class-wc-facebookcommerce.php b/class-wc-facebookcommerce.php index 9a2737099..a6a53fb31 100644 --- a/class-wc-facebookcommerce.php +++ b/class-wc-facebookcommerce.php @@ -9,7 +9,7 @@ * @package FacebookCommerce */ - require_once __DIR__ . '/includes/fbutils.php'; +require_once __DIR__ . '/includes/fbutils.php'; use Automattic\WooCommerce\Admin\Features\Features as WooAdminFeatures; use Automattic\WooCommerce\Admin\Features\OnboardingTasks\TaskLists; From 8eefaf340d5c5f310805b7b0dc07f9c40e3e46fc Mon Sep 17 00:00:00 2001 From: Kader Ibrahim S Date: Thu, 12 Oct 2023 11:43:57 +0530 Subject: [PATCH 5/8] Removes additional `plugins_compatible` check. --- facebook-for-woocommerce.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/facebook-for-woocommerce.php b/facebook-for-woocommerce.php index 7d5eaee5f..803848979 100644 --- a/facebook-for-woocommerce.php +++ b/facebook-for-woocommerce.php @@ -129,7 +129,7 @@ public function __wakeup() { */ public function init_plugin() { - if ( ! Checker::instance()->is_compatible( __FILE__, self::PLUGIN_VERSION ) || ! $this->plugins_compatible() ) { + if ( ! Checker::instance()->is_compatible( __FILE__, self::PLUGIN_VERSION ) ) { return; } From 70b0dd6dbca98366d203acd8f2aac60aeb04202e Mon Sep 17 00:00:00 2001 From: Kader Ibrahim S Date: Thu, 9 May 2024 21:09:40 +0530 Subject: [PATCH 6/8] Removes WP compat check in core --- facebook-for-woocommerce.php | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/facebook-for-woocommerce.php b/facebook-for-woocommerce.php index 803848979..98474e846 100644 --- a/facebook-for-woocommerce.php +++ b/facebook-for-woocommerce.php @@ -214,23 +214,6 @@ public function check_environment() { */ public function add_plugin_notices() { - if ( ! $this->is_wp_compatible() ) { - if ( current_user_can( 'update_core' ) ) { - $this->add_admin_notice( - 'update_wordpress', - 'error', - sprintf( - /* translators: %1$s - plugin name, %2$s - minimum WordPress version required, %3$s - update WordPress link open, %4$s - update WordPress link close */ - esc_html__( '%1$s requires WordPress version %2$s or higher. Please %3$supdate WordPress »%4$s', 'facebook-for-woocommerce' ), - '' . self::PLUGIN_NAME . '', - self::MINIMUM_WP_VERSION, - '', - '' - ) - ); - } - } - // Notices to install and activate or update WooCommerce. $screen = get_current_screen(); if ( isset( $screen->parent_file ) && 'plugins.php' === $screen->parent_file && 'update' === $screen->id ) { From 1b72247f1faeb40a420dd0dd25c2abd1f92da646 Mon Sep 17 00:00:00 2001 From: Kader Ibrahim S Date: Thu, 9 May 2024 21:11:03 +0530 Subject: [PATCH 7/8] Removes plugin notices from main plugin file. --- facebook-for-woocommerce.php | 77 ------------------------------------ 1 file changed, 77 deletions(-) diff --git a/facebook-for-woocommerce.php b/facebook-for-woocommerce.php index 98474e846..9b32c3181 100644 --- a/facebook-for-woocommerce.php +++ b/facebook-for-woocommerce.php @@ -204,83 +204,6 @@ public function check_environment() { } } - - /** - * Adds notices for out-of-date WordPress and/or WooCommerce versions. - * - * @internal - * - * @since 1.10.0 - */ - public function add_plugin_notices() { - - // Notices to install and activate or update WooCommerce. - $screen = get_current_screen(); - if ( isset( $screen->parent_file ) && 'plugins.php' === $screen->parent_file && 'update' === $screen->id ) { - return; // Do not display the install/update/activate notice in the update plugin screen. - } - - $plugin = 'woocommerce/woocommerce.php'; - // Check if WooCommerce is activated. - if ( ! $this->is_wc_activated() ) { - - if ( $this->is_wc_installed() ) { - // WooCommerce is installed but not activated. Ask the user to activate WooCommerce. - if ( current_user_can( 'activate_plugins' ) ) { - $activation_url = wp_nonce_url( 'plugins.php?action=activate&plugin=' . $plugin . '&plugin_status=all&paged=1&s', 'activate-plugin_' . $plugin ); - $message = sprintf( - /* translators: %1$s - Plugin Name, %2$s - activate WooCommerce link open, %3$s - activate WooCommerce link close. */ - esc_html__( '%1$s requires WooCommerce to be activated. Please %2$sactivate WooCommerce%3$s.', 'facebook-for-woocommerce' ), - '' . self::PLUGIN_NAME . '', - '', - '' - ); - $this->add_admin_notice( - 'activate_woocommerce', - 'error', - $message - ); - } - } else { - // WooCommerce is not installed. Ask the user to install WooCommerce. - if ( current_user_can( 'install_plugins' ) ) { - $install_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=woocommerce' ), 'install-plugin_woocommerce' ); - $message = sprintf( - /* translators: %1$s - Plugin Name, %2$s - install WooCommerce link open, %3$s - install WooCommerce link close. */ - esc_html__( '%1$s requires WooCommerce to be installed and activated. Please %2$sinstall WooCommerce%3$s.', 'facebook-for-woocommerce' ), - '' . self::PLUGIN_NAME . '', - '', - '' - ); - $this->add_admin_notice( - 'install_woocommerce', - 'error', - $message - ); - } - } - } elseif ( ! $this->is_wc_compatible() ) { // If WooCommerce is activated, check for the version. - if ( current_user_can( 'update_plugins' ) ) { - $update_url = wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $plugin, 'upgrade-plugin_' . $plugin ); - $this->add_admin_notice( - 'update_woocommerce', - 'error', - sprintf( - /* translators: %1$s - Plugin Name, %2$s - minimum WooCommerce version, %3$s - update WooCommerce link open, %4$s - update WooCommerce link close, %5$s - download minimum WooCommerce link open, %6$s - download minimum WooCommerce link close. */ - esc_html__( '%1$s requires WooCommerce version %2$s or higher. Please %3$supdate WooCommerce%4$s to the latest version, or %5$sdownload the minimum required version »%6$s', 'facebook-for-woocommerce' ), - '' . self::PLUGIN_NAME . '', - self::MINIMUM_WC_VERSION, - '', - '', - '', - '' - ) - ); - } - } - } - - /** * Determines if the required plugins are compatible. * From 05235979ef3958099123afa2a4a354ebb1dad821 Mon Sep 17 00:00:00 2001 From: Kader Ibrahim S Date: Thu, 9 May 2024 21:13:22 +0530 Subject: [PATCH 8/8] Removes redundant core from main plugin file. --- facebook-for-woocommerce.php | 67 ------------------------------------ 1 file changed, 67 deletions(-) diff --git a/facebook-for-woocommerce.php b/facebook-for-woocommerce.php index 9b32c3181..ff21cbaec 100644 --- a/facebook-for-woocommerce.php +++ b/facebook-for-woocommerce.php @@ -204,73 +204,6 @@ public function check_environment() { } } - /** - * Determines if the required plugins are compatible. - * - * @since 1.10.0 - * - * @return bool - */ - private function plugins_compatible() { - return $this->is_wp_compatible() && $this->is_wc_compatible(); - } - - - /** - * Determines if the WordPress compatible. - * - * @since 1.10.0 - * - * @return bool - */ - private function is_wp_compatible() { - - if ( ! self::MINIMUM_WP_VERSION ) { - return true; - } - - return version_compare( get_bloginfo( 'version' ), self::MINIMUM_WP_VERSION, '>=' ); - } - - /** - * Query WooCommerce activation. - * - * @since 2.6.24 - * @return bool - */ - private function is_wc_activated() { - return class_exists( 'WooCommerce' ) ? true : false; - } - - /** - * Determins if WooCommerce is installed. - * - * @since 2.6.24 - * @return bool - */ - private function is_wc_installed() { - $plugin = 'woocommerce/woocommerce.php'; - $installed_plugins = get_plugins(); - - return isset( $installed_plugins[ $plugin ] ); - } - - /** - * Determines if the WooCommerce compatible. - * - * @since 1.10.0 - * - * @return bool - */ - private function is_wc_compatible() { - - if ( ! self::MINIMUM_WC_VERSION ) { - return true; - } - - return defined( 'WC_VERSION' ) && version_compare( WC_VERSION, self::MINIMUM_WC_VERSION, '>=' ); - } - /** * Deactivates the plugin.