Skip to content

Commit c5445c6

Browse files
author
Ivan Chaplygin
committed
Removal of external source
Adding comments Fixing script version check Fixing check for non-existent parameters
1 parent 76a4431 commit c5445c6

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

src/include/class-wc-retailcrm-base.php

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -958,9 +958,10 @@ public function retailcrm_coupon_info()
958958
}
959959

960960
$jsScriptPath = plugins_url() . self::ASSETS_DIR . '/js/retailcrm-loyalty-cart.js';
961+
$scriptPath = plugin_dir_path( __FILE__ ) . '../assets/js/retailcrm-loyalty-cart.js';
961962

962-
wp_register_script('retailcrm-loyalty-cart', $jsScriptPath, false, filemtime($jsScriptPath), true);
963-
wp_enqueue_script('retailcrm-loyalty-cart', $jsScriptPath, '', filemtime($jsScriptPath), true);
963+
wp_register_script('retailcrm-loyalty-cart', $jsScriptPath, false, filemtime($scriptPath), true);
964+
wp_enqueue_script('retailcrm-loyalty-cart', $jsScriptPath, '', filemtime($scriptPath), true);
964965
wp_localize_script('retailcrm-loyalty-cart', 'RetailcrmAdminCoupon', [
965966
'url' => get_admin_url(),
966967
'nonce' => wp_create_nonce('woo-retailcrm-coupon-info-nonce')
@@ -1071,12 +1072,14 @@ private function include_js_scripts_for_admin()
10711072
];
10721073

10731074
$jsScriptsPath = plugins_url() . self::ASSETS_DIR . '/js/';
1075+
$jsScriptsPathDir = plugin_dir_path( __FILE__ ) . '../assets/js/';
10741076

10751077
foreach ($jsScripts as $scriptName) {
10761078
$scriptDir = $jsScriptsPath . $scriptName . '.js';
1079+
$scriptPath = $jsScriptsPathDir . $scriptName . '.js';
10771080

1078-
wp_register_script($scriptName, $scriptDir, false, filemtime($scriptDir), true);
1079-
wp_enqueue_script($scriptName, $scriptDir, '', filemtime($scriptDir), true);
1081+
wp_register_script($scriptName, $scriptDir, false, filemtime($scriptPath), true);
1082+
wp_enqueue_script($scriptName, $scriptDir, '', filemtime($scriptPath), true);
10801083
}
10811084

10821085
// In this method transfer wp-admin url in JS scripts.
@@ -1092,9 +1095,10 @@ public function retailcrm_include_js_script_for_tracker()
10921095
{
10931096
$scriptName = 'retailcrm-tracker';
10941097
$jsScriptsPath = plugins_url() . self::ASSETS_DIR . '/js/' . $scriptName . '.js';
1098+
$scriptPath = plugin_dir_path( __FILE__ ) . '../assets/js/' . $scriptName . '.js';
10951099

1096-
wp_register_script($scriptName, $jsScriptsPath, false, filemtime($jsScriptsPath), true);
1097-
wp_enqueue_script($scriptName, $jsScriptsPath, '', filemtime($jsScriptsPath), true);
1100+
wp_register_script($scriptName, $jsScriptsPath, false, filemtime($scriptPath), true);
1101+
wp_enqueue_script($scriptName, $jsScriptsPath, '', filemtime($scriptPath), true);
10981102
wp_localize_script($scriptName, 'RetailcrmTracker', ['url' => get_admin_url()]);
10991103
}
11001104

@@ -1315,9 +1319,10 @@ public function retailcrm_show_loyalty()
13151319
$loyaltyPersonal = $this->settings['loyalty_personal'] ?? '';
13161320

13171321
$scriptDir = $jsScriptsPath . $jsScript . '.js';
1322+
$scriptPath = plugin_dir_path( __FILE__ ) . '../assets/js/' . $jsScript . '.js';
13181323

1319-
wp_register_script($jsScript, $scriptDir, false, filemtime($scriptDir), true);
1320-
wp_enqueue_script($jsScript, $scriptDir, '', filemtime($scriptDir), true);
1324+
wp_register_script($jsScript, $scriptDir, false, filemtime($scriptPath), true);
1325+
wp_enqueue_script($jsScript, $scriptDir, '', filemtime($scriptPath), true);
13211326
wp_localize_script($jsScript, 'retailcrmLoyaltyUrl', $loyaltyUrl);
13221327
wp_localize_script($jsScript, 'retailcrmCustomerId', $userId);
13231328
wp_localize_script($jsScript, 'retailcrmMessagePhone', $messagePhone);
@@ -1451,11 +1456,13 @@ private function activate_integration($settings)
14511456
$client_id = uniqid();
14521457
}
14531458

1459+
$enabledCorporate = isset($settings['corporate_enabled']) ? $settings['corporate_enabled'] : 'no';
1460+
14541461
if ($settings['api_url'] && $settings['api_key']) {
14551462
$api_client = new WC_Retailcrm_Proxy(
14561463
$settings['api_url'],
14571464
$settings['api_key'],
1458-
$settings['corporate_enabled'] === 'yes'
1465+
$enabledCorporate === 'yes'
14591466
);
14601467

14611468
$result = WC_Retailcrm_Plugin::integration_module($api_client, $client_id);

src/include/class-wc-retailcrm-plugin.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ class WC_Retailcrm_Plugin
1818
public static $history_run = false;
1919
private static $instance = null;
2020

21-
// странная ссылка на лого самого Woocommerce. Проверить где выводится и удалить её/заменить
22-
const MARKETPLACE_LOGO = 'https://s3.eu-central-1.amazonaws.com/retailcrm-billing/images/5b69ce4bda663-woocommercesvg2.svg';
21+
/* Note: This parameter is used solely for identifying the module’s connection to WordPress and WooCommerce
22+
(establishing the link between the plugin and the integration).
23+
*/
2324
const INTEGRATION_CODE = 'woocommerce';
2425

2526
public static function getInstance($file)
@@ -146,9 +147,11 @@ public static function integration_module($api_client, $client_id, $active = tru
146147
return false;
147148
}
148149

150+
/* Note: Parameter "name" is used solely for identifying the module’s connection to WordPress and WooCommerce
151+
(establishing the link between the plugin and the integration).
152+
*/
149153
$configuration = array(
150154
'name' => 'WooCommerce',
151-
'logo' => self::MARKETPLACE_LOGO,
152155
'code' => self::INTEGRATION_CODE . '-' . $client_id,
153156
'active' => $active,
154157
);

0 commit comments

Comments
 (0)