Skip to content

Commit 1bcaf84

Browse files
authored
Ensuring compliance with technical requirements (#383)
1 parent 3812f9c commit 1bcaf84

File tree

56 files changed

+1703
-1131
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1703
-1131
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2025-09-01 5.0.0
2+
* Plugin update for WordPress compliance
3+
* Starting with this version, changes have been made to the customization mechanism and core functions that are not compatible with earlier versions. Before updating, review the module structure and function names to make the necessary adjustments to custom files.
4+
15
## 2025-08-05 4.8.35
26
* Module name change
37

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ remove_dir:
2424
rm -rf /tmp/svn_plugin_dir
2525

2626
compile_pot:
27-
msgfmt resources/pot/retailcrm-ru_RU.pot -o src/languages/retailcrm-ru_RU.mo
28-
msgfmt resources/pot/retailcrm-es_ES.pot -o src/languages/retailcrm-es_ES.mo
27+
msgfmt resources/pot/woo-retailcrm-ru_RU.pot -o src/languages/woo-retailcrm-ru_RU.mo
28+
msgfmt resources/pot/woo-retailcrm-es_ES.pot -o src/languages/woo-retailcrm-es_ES.mo
2929

3030
install:
3131
sudo apt install subversion

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.8.35
1+
5.0.0

doc/README.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,84 @@
11
# Developers documentation
2+
3+
4+
## 1 Правила разработки
5+
При доработке модуля необходимо придерживаться следующих правил:
6+
7+
### 1.1. Хуки и фильтры
8+
- При создании **новых хуков, фильтров, AJAX-хуков** добавляйте префикс, который идентифицирует принадлежность к плагину.
9+
- Используемый префикс: `retailcrm_`
10+
- **Пример правильного формата**:
11+
```php
12+
wp_ajax_retailcrm_do_upload
13+
```
14+
15+
### 1.2 Внешние источники
16+
Запрещается получать файлы (JSON, изображения и т.п.) из удалённых источников.
17+
Вместо этого — добавлять их в сам плагин.
18+
19+
### 1.3 Переводы
20+
- Всегда используйте идентичный идентификатор перевода `woo-retailcrm`:
21+
```php
22+
__('I agree to receive promotional newsletters', 'woo-retailcrm')
23+
```
24+
- Не подставлять переменные напрямую в перевод а использовать `sprintf()` или `printf()`:
25+
```php
26+
__($test, 'woo-retailcrm') // запрещено
27+
28+
printf( // Разрешено
29+
/* translators: %s: First name of the user */
30+
esc_html__( 'Hello %s, how are you?', 'woo-retailcrm' ),
31+
esc_html( $user_firstname )
32+
);
33+
34+
sprintf( // если параметров больше одного, используйте нумерацию
35+
'Fill order data: WC_Customer ID: %1$s email: %2$s WC_Order ID: %3$s',
36+
$wcCustomerId,
37+
$wcCustomerEmail,
38+
$wcOrder->get_id()
39+
)
40+
```
41+
42+
### 1.4 Экранирование переводов
43+
Не использовать стандартную функцию `__` без экранирования. Вместо этого:
44+
```php
45+
esc_html__() // Экранирование html тегов
46+
esc_attr__() // Экранирование аттрибутов html элементов
47+
```
48+
49+
### 1.5 Экранирование вывода данных
50+
При выводе данных (например, с помощью `echo`) необходимо выполнять экранирование с помощью методов:
51+
```php
52+
esc_html() // Экранирование html тегов
53+
esc_attr() // Экранирование аттрибутов html элементов
54+
esc_js() // Экранирование js
55+
```
56+
### 1.6. Очистка входящих данных
57+
- При использовании `filter_input()` обязательно указывать третий параметр — предполагаемый тип значения:
58+
```php
59+
filter_input(INPUT_POST, 'Step', FILTER_SANITIZE_NUMBER_INT);
60+
```
61+
- При получении параметров через `$_GET`, `$_POST`, `$_REQUEST`:
62+
```php
63+
$test = wp_unslash($_GET['value']); // Удаление слешей
64+
sanitize_text_field($_GET['value']); // удаление параметра
65+
```
66+
### 1.7 AJAX-запросы
67+
- Обязательно генерировать `nonce-токены`:
68+
```php
69+
$token = wp_create_nonce('woo-retailcrm-admin-nonce'); // пример названия для токена. Должен быть уникальным для каждой логической цепочки.
70+
```
71+
- Проверять `nonce-токен` при получении запроса:
72+
```php
73+
heck_ajax_referer('woo-retailcrm-admin-nonce', '_ajax_nonce', false); // _ajax_nonce - базовый ключ параметра WordPress, в котором хранится nonce-токен
74+
```
75+
- Если запрос требует прав `администратора/менеджера` для выполнения действий, производить проверку:
76+
```php
77+
current_user_can('manage_woocommerce');
78+
current_user_can('manage_options');
79+
```
80+
81+
## 2 Проверка плагина после доработки
82+
Для проверки используйте плагин: [WordPress Plugin Check](https://wordpress.org/plugins/plugin-check/) (Устанавливается как плагин в WordPress)
83+
- Исправьте все несоответствия с тегом `ERROR`
84+
- Сообщения с тегом `WARNING` — исправлять по возможности
Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ msgstr "Complemento de integración Simla.com"
2727
msgid "https://wordpress.org/plugins/woo-retailcrm/"
2828
msgstr "https://wordpress.org/plugins/woo-retailcrm/"
2929

30-
#. Plugin Name of the plugin/theme
31-
msgid "Simla.com"
32-
msgstr "Simla.com"
33-
3430
msgid "Orders"
3531
msgstr "Pedidos"
3632

@@ -460,8 +456,11 @@ msgstr "Condiciones de procesamiento de datos personales"
460456
msgid "Insert the terms and conditions for processing personal data"
461457
msgstr "Introduce las condiciones para el procesamiento de datos personales"
462458

463-
msgid "To activate the loyalty program it is necessary to activate the <a href='?page=wc-settings'>'enable use of coupons option'</a>"
464-
msgstr "Para activar el programa de fidelización es necesario activar la opción <a href='?page=wc-settings'>'habilitar el uso de cupones'</a>"
459+
msgid "To activate the loyalty program it is necessary to activate the %s"
460+
msgstr "Para activar el programa de fidelización es necesario activar la opción %s"
461+
462+
msgid "Enable use of coupons option"
463+
msgstr "'habilitar el uso de cupones'"
465464

466465
msgid "Bonus account"
467466
msgstr "Cuenta de bonos"
@@ -526,11 +525,11 @@ msgstr "Introduce el número de teléfono correcto"
526525
msgid "Close"
527526
msgstr "Cerrar"
528527

529-
msgid "Ordinary products: accrual of 1 bonus for each %s %s"
530-
msgstr "Productos ordinarios: acumulación de 1 bono por cada %s %s"
528+
msgid "Ordinary products: accrual of 1 bonus for each %1$s %2$s"
529+
msgstr "Productos ordinarios: acumulación de 1 bono por cada %1$s %2$s"
531530

532-
msgid "Promotional products: accrual of 1 bonus for each %s %s"
533-
msgstr "Productos promocionales: acumulación de 1 bono por cada %s %s"
531+
msgid "Promotional products: accrual of 1 bonus for each %1$s %2$s"
532+
msgstr "Productos promocionales: acumulación de 1 bono por cada %1$s %2$s"
534533

535534
msgid "Ordinary products: bonus accrual in the amount of %s%% of the purchase amount"
536535
msgstr "Productos ordinarios: acumulación de bonos en la cantidad de %s%% de la suma de la compra"
@@ -609,3 +608,33 @@ msgstr "Precio promocional Woocommerce"
609608

610609
msgid "Promotional price type for Woocommerce store, generated automatically. Necessary for correct synchronization work when loyalty program is enabled (Do not delete. Do not deactivate)"
611610
msgstr "Tipo de precio promocional para la tienda Woocommerce, generado automáticamente. Necesario para el correcto funcionamiento de la sincronización cuando el programa de fidelización está habilitado (No eliminar. No desactivar)"
611+
612+
msgid "Activate WooCommerce in order to enable Simla integration!"
613+
msgstr "¡Activa WooCommerce para habilitar la integración con Simla!"
614+
615+
msgid "Activate WooCommerce"
616+
msgstr "¡Activa WooCommerce!"
617+
618+
msgid "Click here to open plugins manager"
619+
msgstr "Haz clic aquí para abrir el administrador de complementos"
620+
621+
msgid "Install WooCommerce"
622+
msgstr "Instalar WooCommerce"
623+
624+
msgid "in order to enable RetailCRM integration!"
625+
msgstr "¡para habilitar la integración con Simla!"
626+
627+
msgid "Token is not valid"
628+
msgstr "El token no es válido"
629+
630+
msgid "Access denied"
631+
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"
Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ msgstr "Интеграционный плагин Simla.com"
2727
msgid "https://wordpress.org/plugins/woo-retailcrm/"
2828
msgstr "https://wordpress.org/plugins/woo-retailcrm/"
2929

30-
#. Plugin Name of the plugin/theme
31-
msgid "Simla.com"
32-
msgstr "Simla.com"
33-
3430
msgid "Orders"
3531
msgstr "Заказы"
3632

@@ -469,8 +465,11 @@ msgstr "Условия обработки персональных данных"
469465
msgid "Insert the terms and conditions for processing personal data"
470466
msgstr "Вставьте условия обработки персональных данных"
471467

472-
msgid "To activate the loyalty program it is necessary to activate the <a href='?page=wc-settings'>'enable use of coupons option'</a>"
473-
msgstr "Для активации программы лояльности необходимо активировать опцию <a href='?page=wc-settings'>'включить использование купонов'</a>"
468+
msgid "To activate the loyalty program it is necessary to activate the %s"
469+
msgstr "Для активации программы лояльности необходимо активировать опцию %s"
470+
471+
msgid "Enable use of coupons option"
472+
msgstr "включить использование купонов"
474473

475474
msgid "Bonus account"
476475
msgstr "Бонусный счёт"
@@ -535,11 +534,11 @@ msgstr "Введите корректный номер телефона"
535534
msgid "Close"
536535
msgstr "Закрыть"
537536

538-
msgid "Ordinary products: accrual of 1 bonus for each %s %s"
539-
msgstr "Обычные товары: начисление 1 бонуса за каждые %s %s"
537+
msgid "Ordinary products: accrual of 1 bonus for each %1$s %2$s"
538+
msgstr "Обычные товары: начисление 1 бонуса за каждые %1$s %2$s"
540539

541-
msgid "Promotional products: accrual of 1 bonus for each %s %s"
542-
msgstr "Акционные товары: начисление 1 бонуса за каждые %s %s"
540+
msgid "Promotional products: accrual of 1 bonus for each %1$s %2$s"
541+
msgstr "Акционные товары: начисление 1 бонуса за каждые %1$s %2$s"
543542

544543
msgid "Ordinary products: bonus accrual in the amount of %s%% of the purchase amount"
545544
msgstr "Обычные товары: начисление бонусов в размере %s%% от суммы покупки"
@@ -618,3 +617,33 @@ msgstr "Акционная цена Woocommerce"
618617

619618
msgid "Promotional price type for Woocommerce store, generated automatically. Necessary for correct synchronization work when loyalty program is enabled (Do not delete. Do not deactivate)"
620619
msgstr "Акционный тип цены для магазина Woocommerce, сгенерированный автоматически. Необходим для корректной работы синхронизации при включенной программы лояльности (Не удалять. Не деактивировать)"
620+
621+
msgid "Activate WooCommerce in order to enable RetailCRM integration!"
622+
msgstr "Активируйте WooCommerce, чтобы включить интеграцию с RetailCRM!"
623+
624+
msgid "Activate WooCommerce"
625+
msgstr "Активировать WooCommerce"
626+
627+
msgid "Click here to open plugins manager"
628+
msgstr "Нажмите здесь, чтобы открыть менеджер плагинов"
629+
630+
msgid "Install WooCommerce"
631+
msgstr "Установить WooCommerce"
632+
633+
msgid "in order to enable RetailCRM integration!"
634+
msgstr "чтобы включить интеграцию с RetailCRM!"
635+
636+
msgid "Token is not valid"
637+
msgstr "Токен недействителен"
638+
639+
msgid "Access denied"
640+
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/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 RetailDriver LLC
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

src/assets/js/retailcrm-cron-info.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,24 @@ jQuery(function () {
1818
this.messageSuccessful = '';
1919
this.loyaltyUploadPrice = 0;
2020

21-
this.adminUrl = AdminUrl.url;
21+
this.adminUrl = RetailcrmAdmin.url;
2222

2323
let _this = this;
2424

2525
jQuery.ajax({
26-
url: this.adminUrl + '/admin-ajax.php?action=cron_info',
26+
url: this.adminUrl + '/admin-ajax.php?action=retailcrm_cron_info',
2727
method: "POST",
2828
timeout: 0,
29-
data: {ajax: 1},
29+
data: {ajax: 1, _ajax_nonce: RetailcrmAdmin.nonce},
3030
dataType: "json"
3131
})
3232
.done(function (response) {
33+
if (response.error) {
34+
alert(response.error);
35+
36+
return false;
37+
}
38+
3339
_this.history = response.history;
3440
_this.icml = response.icml;
3541
_this.inventories = response.inventories;
@@ -67,8 +73,15 @@ jQuery(function () {
6773

6874
jQuery.ajax({
6975
type: "POST",
70-
url: this.adminUrl + '/admin-ajax.php?action=clear_cron_tasks',
76+
url: this.adminUrl + '/admin-ajax.php?action=retailcrm_clear_cron_tasks',
77+
data: {_ajax_nonce: RetailcrmAdmin.nonce},
7178
success: function (response) {
79+
if (response.error) {
80+
alert(response.error);
81+
82+
return false;
83+
}
84+
7285
alert(_this.messageSuccessful);
7386
}
7487
});

src/assets/js/retailcrm-export.js

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,24 @@ jQuery(function () {
2626
this.ordersCount = 0;
2727
this.customersCount = 0;
2828

29-
this.adminUrl = AdminUrl.url;
29+
this.adminUrl = RetailcrmAdmin.url;
3030

3131
let _this = this;
3232

3333
jQuery.ajax({
34-
url: this.adminUrl + '/admin-ajax.php?action=content_upload',
34+
url: this.adminUrl + '/admin-ajax.php?action=retailcrm_content_upload',
3535
method: "POST",
3636
timeout: 0,
37-
data: {ajax: 1},
37+
data: {ajax: 1, _ajax_nonce: RetailcrmAdmin.nonce},
3838
dataType: "json"
3939
})
4040
.done(function (response) {
41+
if (response.error) {
42+
alert(response.error);
43+
44+
return false;
45+
}
46+
4147
_this.ordersCount = Number(response.count_orders);
4248
_this.customersCount = Number(response.count_users);
4349
jQuery(_this.submitButton).removeClass('retailcrm-hidden');
@@ -101,15 +107,23 @@ jQuery(function () {
101107
}
102108
}
103109

110+
data._ajax_nonce = RetailcrmAdmin.nonce;
111+
104112
let _this = this;
105113

106114
jQuery.ajax({
107-
url: this.adminUrl + '/admin-ajax.php?action=do_upload',
115+
url: this.adminUrl + '/admin-ajax.php?action=retailcrm_do_upload',
108116
method: "POST",
109117
timeout: 0,
110118
data: data
111119
})
112120
.done(function (response) {
121+
if (response.error) {
122+
alert(response.error);
123+
124+
return false;
125+
}
126+
113127
if (_this.isDone) {
114128
return _this.exportDone();
115129
}
@@ -170,8 +184,15 @@ jQuery(function () {
170184

171185
jQuery.ajax({
172186
type: "POST",
173-
url: this.adminUrl + '/admin-ajax.php?action=upload_selected_orders&order_ids_retailcrm=' + ids,
187+
url: this.adminUrl + '/admin-ajax.php?action=retailcrm_upload_selected_orders&order_ids_retailcrm=' + ids,
188+
data: {_ajax_nonce: RetailcrmAdmin.nonce},
174189
success: function (response) {
190+
if (response.error) {
191+
alert(response.error);
192+
193+
return false;
194+
}
195+
175196
alert(_this.messageSuccessful);
176197
}
177198
});

0 commit comments

Comments
 (0)