PluginProbe
ووسلام – همگام سازی ووکامرس و باسلام / 1.10.20
ووسلام – همگام سازی ووکامرس و باسلام v1.10.20
1.10.19 1.10.20 1.10.18 1.10.17 1.10.15 1.10.14 1.10.13 1.10.12 1.10.10 1.10.9 1.10.8 1.10.7 1.10.6 1.10.5 1.10.4 1.10.3 1.10.2 1.10.1 1.10.0 1.9.2 1.9.1 1.9.0 1.8.8 1.8.5 1.8.6 All 53 releases
← All changes | includes/Admin/Product/Operations/ConnectProduct.php +23 -8 1.9.21.10.20 View file →
@@ -1,4 +1,4 @@
1 1 <?php
2 2
3 3 namespace SyncBasalam\Admin\Product\Operations;
4 4
@@ -3,10 +3,11 @@
3 3 namespace SyncBasalam\Admin\Product\Operations;
4 4
5 5 use SyncBasalam\Services\Products\ConnectSingleProductService;
6 6 use SyncBasalam\Services\Products\AutoConnectProducts;
7 -use SyncBasalam\JobManager;
8 -use SyncBasalam\Admin\Components\SingleProductPageComponents;
7 +use SyncBasalam\JobManager;
8 +use SyncBasalam\Admin\Components\SingleProductPageComponents;
9 +use SyncBasalam\Admin\Settings\SettingsManager;
9 10
10 11 defined('ABSPATH') || exit;
11 12
12 13 class ConnectProduct
@@ -12,8 +13,18 @@
12 13 class ConnectProduct
13 14 {
14 15 public function handleConnectProduct(): array
15 16 {
17 + $nonce = isset($_POST['_wpnonce']) ? sanitize_text_field(wp_unslash($_POST['_wpnonce'])) : '';
18 +
19 + if (!wp_verify_nonce($nonce, 'basalam_connect_product_nonce')) {
20 + return [
21 + 'success' => false,
22 + 'message' => 'دسترسی غیرمجاز!',
23 + 'status_code' => 403,
24 + ];
25 + }
26 +
16 27 if (!current_user_can('manage_woocommerce')) {
17 28 return [
18 29 'success' => false,
19 30 'message' => 'تنها مدیر کل امکان تغییر وضعیت سفارش را دارد.',
@@ -33,14 +44,16 @@
33 44 }
34 45
35 46 $connect_status = ConnectSingleProductService::connectProductById($woo_product_id, $sync_basalam_product_id);
36 47
37 - $job_manager = syncBasalamContainer()->get(JobManager::class);
38 - $job_manager->createJob(
39 - 'sync_basalam_update_single_product',
40 - 'pending',
41 - $woo_product_id,
42 - );
48 + if (SettingsManager::isProductUpdateSelectionValid()) {
49 + $job_manager = syncBasalamContainer()->get(JobManager::class);
50 + $job_manager->createJob(
51 + 'sync_basalam_update_single_product',
52 + 'pending',
53 + $woo_product_id,
54 + );
55 + }
43 56
44 57 if ($connect_status) {
45 58 return [
46 59 'success' => true,
@@ -57,8 +70,10 @@
57 70 }
58 71
59 72 public function handleSearchProducts(): void
60 73 {
74 + check_ajax_referer('basalam_search_products_nonce', '_wpnonce');
75 +
61 76 if (!current_user_can('edit_posts')) {
62 77 wp_send_json_error("دسترسی غیرمجاز.");
63 78 }
64 79