Skip to content

Commit ad74042

Browse files
author
Ivan Chaplygin
committed
Fixes for module issues (Plugin Check)
1 parent 39f4cf3 commit ad74042

16 files changed

+195
-136
lines changed

resources/pot/woo-retailcrm-es_ES.pot

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,3 +629,12 @@ msgstr "El token no es válido"
629629

630630
msgid "Access denied"
631631
msgstr "Acceso denegado"
632+
633+
msgid "%1$s bonuses will expire %2$s"
634+
msgstr "%1$s bonos expirarán %2$s"
635+
636+
msgid "%1$s bonuses will active %2$s"
637+
msgstr "%1$s bonos se activarán %2$s"
638+
639+
msgid "Error while processing validation: %1$s. userId: %2$s"
640+
msgstr "Error al procesar la validación: %1$s. userId: %2$s"

resources/pot/woo-retailcrm-ru_RU.pot

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,3 +638,12 @@ msgstr "Токен недействителен"
638638

639639
msgid "Access denied"
640640
msgstr "Доступ запрещен"
641+
642+
msgid "%1$s bonuses will expire %2$s"
643+
msgstr "%1$s бонусов сгорят %2$s"
644+
645+
msgid "%1$s bonuses will active %2$s"
646+
msgstr "%1$s бонусов ожидают активации %2$s"
647+
648+
msgid "Error while processing validation: %1$s. userId: %2$s"
649+
msgstr "Ошибка при валидации: %1$s. userId: %2$s"

src/include/abstracts/class-wc-retailcrm-abstracts-settings.php

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ abstract class WC_Retailcrm_Abstracts_Settings extends WC_Integration
3434
public function __construct()
3535
{
3636
$this->id = 'integration-retailcrm';
37-
$this->method_title = esc_html__('Simla.com', 'woo_retailcrm');
37+
$this->method_title = esc_html__('Simla.com', 'woo-retailcrm');
3838
$this->method_description = esc_html__('Integration with Simla.com management system', 'woo-retailcrm');
3939

4040
static::$option_key = $this->get_option_key();
@@ -55,14 +55,14 @@ public function __construct()
5555
*/
5656
public function ajax_retailcrm_generate_icml()
5757
{
58-
$ajax_url = esc_url(admin_url('admin-ajax.php'));
58+
$ajax_url = admin_url('admin-ajax.php');
5959
?>
6060
<script type="text/javascript">
6161
jQuery('#icml-retailcrm, #wp-admin-bar-retailcrm_ajax_generate_icml').bind('click', function() {
6262
jQuery.ajax({
6363
type: "POST",
64-
url: '<?php echo $ajax_url; ?>?action=retailcrm_generate_icml',
65-
data: { _ajax_nonce: '<?php echo wp_create_nonce('woo-retailcrm-admin-nonce'); ?>'},
64+
url: '<?php echo esc_js($ajax_url . '?action=retailcrm_generate_icml'); ?>',
65+
data: { _ajax_nonce: '<?php echo esc_js(wp_create_nonce('woo-retailcrm-admin-nonce')); ?>' },
6666
success: function (response) {
6767
alert('<?php echo esc_html__('Catalog was generated', 'woo-retailcrm'); ?>');
6868
console.log('AJAX response : ', response);
@@ -75,14 +75,14 @@ public function ajax_retailcrm_generate_icml()
7575

7676
public function ajax_retailcrm_upload_loyalty_price()
7777
{
78-
$ajax_url = esc_url(admin_url('admin-ajax.php'));
78+
$ajax_url = admin_url('admin-ajax.php');
7979
?>
8080
<script type="text/javascript">
8181
jQuery('#upload-loyalty-price-retailcrm').bind('click', function () {
8282
jQuery.ajax({
8383
type: "POST",
84-
url: '<?php echo $ajax_url; ?>?action=retailcrm_upload_loyalty_price',
85-
data: { _ajax_nonce: '<?php echo wp_create_nonce('woo-retailcrm-admin-nonce'); ?>'},
84+
url: '<?php echo esc_js($ajax_url . '?action=retailcrm_upload_loyalty_price'); ?>',
85+
data: { _ajax_nonce: '<?php echo esc_js(wp_create_nonce('woo-retailcrm-admin-nonce')); ?>'},
8686
success: function (response) {
8787
alert('<?php echo esc_html__('Promotional prices unloaded', 'woo-retailcrm');?>');
8888
console.log('AJAX response : ', response);
@@ -263,13 +263,9 @@ public function init_form_fields()
263263

264264
foreach ($wc_shipping_list as $shipping_code => $shipping) {
265265
if (isset($shipping['enabled']) && $shipping['enabled'] == static::YES) {
266-
$title = $shipping['title'] ? esc_html($shipping['title']): '';
267-
$description = $shipping['description'] ? esc_html($shipping['description']) : '';
268-
269-
270266
$this->form_fields[$shipping_code] = [
271-
'title' => esc_html__($title, 'woo-retailcrm'),
272-
'description' => esc_html__($description, 'woo-retailcrm'),
267+
'title' => $shipping['title'],
268+
'description' => $shipping['description'],
273269
'css' => 'min-width:350px;',
274270
'class' => 'select',
275271
'type' => 'select',
@@ -718,7 +714,7 @@ public function init_form_fields()
718714

719715
$this->form_fields['corporate_enabled'] = [
720716
'title' => esc_html__('Corporate customers support', 'woo-retailcrm'),
721-
'label' => esc_html__('Enabled'),
717+
'label' => esc_html__('Enabled', 'woo-retailcrm'),
722718
'description' => '',
723719
'class' => 'checkbox',
724720
'type' => 'checkbox',
@@ -813,13 +809,13 @@ public function generate_button_html($key, $data)
813809
<tr valign="top">
814810
<th scope="row" class="titledesc">
815811
<label for="<?php echo esc_attr($field); ?>"><?php echo wp_kses_post($data['title']); ?></label>
816-
<?php echo $this->get_tooltip_html($data); ?>
812+
<?php echo esc_attr($this->get_tooltip_html($data)); ?>
817813
</th>
818814
<td class="forminp">
819815
<fieldset>
820816
<legend class="screen-reader-text"><span><?php echo wp_kses_post($data['label']); ?></span></legend>
821-
<button id="<?php echo $data['id']; ?>" class="<?php echo esc_attr($data['class']); ?>" type="button" name="<?php echo esc_attr($field); ?>" id="<?php echo esc_attr($field); ?>" style="<?php echo esc_attr($data['css']); ?>" <?php echo $this->get_custom_attribute_html($data); ?>><?php echo wp_kses_post($data['label']); ?></button>
822-
<?php echo $this->get_description_html($data); ?>
817+
<button id="<?php echo esc_attr($data['id']); ?>" class="<?php echo esc_attr($data['class']); ?>" type="button" name="<?php echo esc_attr($field); ?>" id="<?php echo esc_attr($field); ?>" style="<?php echo esc_attr($data['css']); ?>" <?php echo esc_attr($this->get_custom_attribute_html($data)); ?>><?php echo wp_kses_post($data['label']); ?></button>
818+
<?php echo esc_attr($this->get_description_html($data)); ?>
823819
</fieldset>
824820
</td>
825821
</tr>

src/include/api/class-wc-retailcrm-client-v5.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ public function customersCorporateEdit(array $customerCorporate, $by = 'external
693693
$this->checkIdParameter($by);
694694
if (!array_key_exists($by, $customerCorporate)) {
695695
throw new InvalidArgumentException(
696-
sprintf('Corporate customer array must contain the "%s" parameter.', $by)
696+
sprintf('Corporate customer array must contain the "%s" parameter.', esc_attr($by))
697697
);
698698
}
699699

@@ -1184,7 +1184,7 @@ public function ordersEdit(array $order, $by = 'externalId', $site = null)
11841184

11851185
if (!array_key_exists($by, $order)) {
11861186
throw new InvalidArgumentException(
1187-
sprintf('Order array must contain the "%s" parameter.', $by)
1187+
sprintf('Order array must contain the "%s" parameter.', esc_attr($by))
11881188
);
11891189
}
11901190

@@ -1298,7 +1298,7 @@ public function ordersPaymentEdit(array $payment, $by = 'externalId', $site = nu
12981298

12991299
if (!array_key_exists($by, $payment)) {
13001300
throw new InvalidArgumentException(
1301-
sprintf('Order array must contain the "%s" parameter.', $by)
1301+
sprintf('Order array must contain the "%s" parameter.', esc_attr($by))
13021302
);
13031303
}
13041304

@@ -1486,7 +1486,7 @@ public function customersEdit(array $customer, $by = 'externalId', $site = null)
14861486

14871487
if (!array_key_exists($by, $customer)) {
14881488
throw new InvalidArgumentException(
1489-
sprintf('Customer array must contain the "%s" parameter.', $by)
1489+
sprintf('Customer array must contain the "%s" parameter.', esc_attr($by))
14901490
);
14911491
}
14921492

@@ -3123,8 +3123,8 @@ protected function checkIdParameter($by)
31233123
throw new InvalidArgumentException(
31243124
sprintf(
31253125
'Value "%s" for "by" param is not valid. Allowed values are %s.',
3126-
$by,
3127-
implode(', ', $allowedForBy)
3126+
esc_attr($by),
3127+
esc_attr(implode(', ', $allowedForBy))
31283128
)
31293129
);
31303130
}

src/include/api/class-wc-retailcrm-request.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ public function makeRequest(
6565
throw new \InvalidArgumentException(
6666
sprintf(
6767
'Method "%1$s" is not valid. Allowed methods are %2$s',
68-
$method,
69-
implode(', ', $allowedMethods)
68+
esc_attr($method),
69+
esc_attr(implode(', ', $allowedMethods))
7070
)
7171
);
7272
}
@@ -110,7 +110,7 @@ public function makeRequest(
110110
curl_close($curlHandler);
111111

112112
if ($errno) {
113-
throw new WC_Retailcrm_Exception_Curl($error, $errno);
113+
throw new WC_Retailcrm_Exception_Curl(esc_html($error), esc_html($errno));
114114
}
115115

116116
return new WC_Retailcrm_Response($statusCode, $responseBody);

src/include/api/class-wc-retailcrm-response.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ public function __construct($statusCode, $responseBody = null)
4343
$response = json_decode($responseBody, true);
4444

4545
if (!$response && JSON_ERROR_NONE !== ($error = json_last_error())) {
46-
throw new WC_Retailcrm_Exception_Json(
47-
"Invalid JSON in the API response body. Error code #$error",
48-
$error
46+
throw new WC_Retailcrm_Exception_Json(sprintf(
47+
"Invalid JSON in the API response body. Error code #%s", esc_attr($error)),
48+
esc_attr($error)
4949
);
5050
}
5151

@@ -89,7 +89,7 @@ public function __call($name, $arguments)
8989
$propertyName = strtolower(substr($name, 3, 1)) . substr($name, 4);
9090

9191
if (!isset($this->response[$propertyName])) {
92-
throw new \InvalidArgumentException("Method \"$name\" not found");
92+
throw new \InvalidArgumentException(sprintf("Method '%s' not found", esc_attr($name)));
9393
}
9494

9595
return $this->response[$propertyName];
@@ -107,7 +107,7 @@ public function __call($name, $arguments)
107107
public function __get($name)
108108
{
109109
if (!isset($this->response[$name])) {
110-
throw new \InvalidArgumentException("Property \"$name\" not found");
110+
throw new \InvalidArgumentException(sprintf("Property '%s' not found", esc_attr($name)));
111111
}
112112

113113
return $this->response[$name];
@@ -161,7 +161,7 @@ public function offsetExists($offset): bool
161161
public function offsetGet($offset)
162162
{
163163
if (!isset($this->response[$offset])) {
164-
throw new \InvalidArgumentException("Property \"$offset\" not found");
164+
throw new \InvalidArgumentException(sprintf("Property '%s' not found", esc_attr($offset)));
165165
}
166166

167167
return $this->response[$offset];

0 commit comments

Comments
 (0)