Skip to content

Commit

Permalink
Replace the file_get_content method with wp_remote_get (#346)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellynoize authored Sep 26, 2024
1 parent 61fcad6 commit 9fa0421
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 2024-09-26 4.8.6
* Optimized url-validator

## 2024-09-20 4.8.5
* Project testing has been updated

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.8.5
4.8.6
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ class WC_Retailcrm_Url_Constraint
/**
* @var string
*/
public $getFileError = 'Unable to obtain reference values.';
public $getFileError = 'Bad Request, file not getted';
}
endif;
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class WC_Retailcrm_Url_Validator extends WC_Retailcrm_Url_Constraint
{
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
Expand Down Expand Up @@ -169,9 +170,15 @@ private function checkPath(array $crmUrl)
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);
}
Expand Down
5 changes: 4 additions & 1 deletion src/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/retailcrm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/uninstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
* @link https://wordpress.org/plugins/woo-retailcrm/
*
* @version 4.8.5
* @version 4.8.6
*
* @package RetailCRM
*/
Expand Down

0 comments on commit 9fa0421

Please sign in to comment.