diff --git a/CHANGELOG.md b/CHANGELOG.md index 24d40d6..fe23a7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2024-09-26 4.8.6 +* Optimized url-validator + ## 2024-09-20 4.8.5 * Project testing has been updated diff --git a/VERSION b/VERSION index bb6ebd3..7ea5948 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.8.5 +4.8.6 diff --git a/src/include/validators/url-validator/class-wc-retailcrm-url-constraint.php b/src/include/validators/url-validator/class-wc-retailcrm-url-constraint.php index ef9adab..01fa705 100644 --- a/src/include/validators/url-validator/class-wc-retailcrm-url-constraint.php +++ b/src/include/validators/url-validator/class-wc-retailcrm-url-constraint.php @@ -62,6 +62,6 @@ if (!class_exists('WC_Retailcrm_Url_Constraint')) : /** * @var string */ - public $getFileError = 'Unable to obtain reference values.'; + public $getFileError = 'Bad Request, file not getted'; } endif; diff --git a/src/include/validators/url-validator/class-wc-retailcrm-url-validator.php b/src/include/validators/url-validator/class-wc-retailcrm-url-validator.php index 0f1b245..2e0d25c 100644 --- a/src/include/validators/url-validator/class-wc-retailcrm-url-validator.php +++ b/src/include/validators/url-validator/class-wc-retailcrm-url-validator.php @@ -16,6 +16,7 @@ if (!class_exists('WC_Retailcrm_Url_Validator')) : { const CRM_DOMAINS_URL = 'https://infra-data.retailcrm.tech/crm-domains.json'; const BOX_DOMAINS_URL = 'https://infra-data.retailcrm.tech/box-domains.json'; + const CRM_ALL_DOMAINS = ["ecomlogic.com", "retailcrm.ru", "retailcrm.pro", "retailcrm.es", "simla.com", "simla.io", "retailcrm.io"]; /** * @param string $crmUrl @@ -169,9 +170,15 @@ if (!class_exists('WC_Retailcrm_Url_Validator')) : private function getValidDomains(string $domainUrl): array { try { - $content = json_decode(file_get_contents($domainUrl), true); + $content = wp_remote_get($domainUrl); + + if (!$content instanceof WP_ERROR && $content['response']['code'] === 200) { + $domains = json_decode($content['body'], true); - return array_column($content['domains'], 'domain'); + return array_column($domains['domains'], 'domain'); + } + + return self::CRM_ALL_DOMAINS; } catch (Exception $exception) { throw new ValidatorException($this->getFileError); } diff --git a/src/readme.txt b/src/readme.txt index b604677..6db55e0 100644 --- a/src/readme.txt +++ b/src/readme.txt @@ -5,7 +5,7 @@ Tags: Интеграция, Simla.com, simla Requires PHP: 7.1 Requires at least: 5.3 Tested up to: 6.5 -Stable tag: 4.8.5 +Stable tag: 4.8.6 License: GPLv1 or later License URI: http://www.gnu.org/licenses/gpl-1.0.html @@ -82,6 +82,9 @@ Asegúrate de tener una clave API específica para cada tienda. Las siguientes i == Changelog == += 4.8.6 = +* Optimized url-validator + = 4.8.5 = * Project testing has been updated diff --git a/src/retailcrm.php b/src/retailcrm.php index f941f5f..24a7591 100644 --- a/src/retailcrm.php +++ b/src/retailcrm.php @@ -5,7 +5,7 @@ * Description: Integration plugin for WooCommerce & Simla.com * Author: RetailDriver LLC * Author URI: http://retailcrm.pro/ - * Version: 4.8.5 + * Version: 4.8.6 * Tested up to: 6.5 * Requires Plugins: woocommerce * WC requires at least: 5.4 diff --git a/src/uninstall.php b/src/uninstall.php index 56cfb4f..2db9e4a 100644 --- a/src/uninstall.php +++ b/src/uninstall.php @@ -16,7 +16,7 @@ * * @link https://wordpress.org/plugins/woo-retailcrm/ * - * @version 4.8.5 + * @version 4.8.6 * * @package RetailCRM */