refactor(Core): optimize admin panel and refactor

This commit is contained in:
2026-05-07 00:15:32 +03:30
parent dec4e67b9e
commit 7cc14b7439
25 changed files with 1162 additions and 282 deletions

View File

@@ -5,6 +5,8 @@ if (!defined('ABSPATH')) {
}
$current_page = sanitize_text_field($_GET['page'] ?? 'sodino-add-banner');
$form_content_type = function_exists('sodino_old_input') ? sodino_old_input('content_type', $banner->content_type) : $banner->content_type;
$form_display_type = function_exists('sodino_old_input') ? sodino_old_input('display_type', $banner->display_type) : $banner->display_type;
?>
<div id="sodino-app" class="min-h-screen bg-gray-50" dir="rtl">
<div class="bg-white border-b border-gray-200 shadow-sm">
@@ -22,6 +24,7 @@ $current_page = sanitize_text_field($_GET['page'] ?? 'sodino-add-banner');
</div>
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<?php if (function_exists('sodino_render_admin_notice')) { sodino_render_admin_notice(); } ?>
<div class="grid gap-8 lg:grid-cols-[280px_1fr]">
<aside class="bg-white rounded-2xl border border-gray-200 p-6 shadow-sm">
<h2 class="text-lg font-semibold text-gray-900 mb-4"><?php _e('منوی سودینو', 'sodino'); ?></h2>
@@ -32,9 +35,24 @@ $current_page = sanitize_text_field($_GET['page'] ?? 'sodino-add-banner');
<a href="<?php echo admin_url('admin.php?page=sodino-rules'); ?>" class="block px-3 py-2 rounded-xl text-sm font-medium <?php echo $current_page === 'sodino-rules' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('قوانین', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-add-rule'); ?>" class="block px-3 py-2 rounded-xl text-sm font-medium <?php echo $current_page === 'sodino-add-rule' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('افزودن قانون', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-upsells'); ?>" class="block px-3 py-2 rounded-xl text-sm font-medium <?php echo $current_page === 'sodino-upsells' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('آپسل (پیشنهاد فروش)', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-add-upsell'); ?>" class="block px-3 py-2 rounded-xl text-sm font-medium <?php echo $current_page === 'sodino-add-upsell' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('افزودن آپسل', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-banners'); ?>" class="block px-3 py-2 rounded-xl text-sm font-medium <?php echo $current_page === 'sodino-banners' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('بنرهای هوشمند', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-add-banner'); ?>" class="block px-3 py-2 rounded-xl text-sm font-medium <?php echo $current_page === 'sodino-add-banner' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('افزودن بنر', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-competitor-price'); ?>" class="block px-3 py-2 rounded-xl text-sm font-medium <?php echo $current_page === 'sodino-competitor-price' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('قیمت رقبا (به‌زودی)', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-settings'); ?>" class="block px-3 py-2 rounded-xl text-sm font-medium <?php echo $current_page === 'sodino-settings' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('تنظیمات', 'sodino'); ?>
</a>
@@ -53,7 +71,7 @@ $current_page = sanitize_text_field($_GET['page'] ?? 'sodino-add-banner');
<div class="grid gap-6 lg:grid-cols-2">
<div>
<label class="block text-sm font-medium text-gray-700 mb-2" for="title"><?php _e('عنوان بنر', 'sodino'); ?></label>
<input type="text" name="title" id="title" value="<?php echo esc_attr($banner->title); ?>" class="w-full rounded-2xl border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:ring-2 focus:ring-blue-100" required>
<input type="text" name="title" id="title" value="<?php echo esc_attr(function_exists('sodino_old_input') ? sodino_old_input('title', $banner->title) : $banner->title); ?>" class="w-full rounded-2xl border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:ring-2 focus:ring-blue-100" required>
</div>
<div>
@@ -62,7 +80,7 @@ $current_page = sanitize_text_field($_GET['page'] ?? 'sodino-add-banner');
<?php $content_types = ['image' => __('تصویر', 'sodino'), 'html' => __('HTML', 'sodino'), 'shortcode' => __('شورت‌کد', 'sodino')]; ?>
<?php foreach ($content_types as $value => $label) : ?>
<label class="flex items-center gap-3 rounded-2xl border border-gray-300 bg-white px-4 py-3 cursor-pointer hover:border-blue-300">
<input type="radio" name="content_type" value="<?php echo esc_attr($value); ?>" <?php checked($banner->content_type, $value); ?> class="h-4 w-4 text-blue-600 sodino-banner-content-type">
<input type="radio" name="content_type" value="<?php echo esc_attr($value); ?>" <?php checked($form_content_type, $value); ?> class="h-4 w-4 text-blue-600 sodino-banner-content-type">
<span class="text-sm text-gray-700"><?php echo esc_html($label); ?></span>
</label>
<?php endforeach; ?>
@@ -74,25 +92,25 @@ $current_page = sanitize_text_field($_GET['page'] ?? 'sodino-add-banner');
<div class="sodino-banner-content-group" data-type="image">
<label class="block text-sm font-medium text-gray-700 mb-2" for="content_value_image"><?php _e('آدرس تصویر بنر', 'sodino'); ?></label>
<div class="flex gap-3">
<input type="text" name="content_value" id="content_value_image" value="<?php echo esc_attr($banner->content_type === 'image' ? $banner->content_value : ''); ?>" class="w-full rounded-2xl border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:ring-2 focus:ring-blue-100">
<input type="text" name="content_values[image]" id="content_value_image" value="<?php echo esc_attr(function_exists('sodino_old_input') ? sodino_old_input('content_values.image', $banner->content_type === 'image' ? $banner->content_value : '') : ($banner->content_type === 'image' ? $banner->content_value : '')); ?>" class="w-full rounded-2xl border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:ring-2 focus:ring-blue-100">
<button type="button" id="sodino-banner-image-upload" class="inline-flex items-center rounded-2xl border border-gray-300 bg-white px-4 py-3 text-sm font-medium text-gray-700 shadow-sm hover:bg-gray-50"><?php _e('انتخاب تصویر', 'sodino'); ?></button>
</div>
</div>
<div class="sodino-banner-content-group" data-type="html">
<label class="block text-sm font-medium text-gray-700 mb-2" for="content_value_html"><?php _e('محتوای HTML بنر', 'sodino'); ?></label>
<textarea name="content_value" id="content_value_html" rows="6" class="w-full rounded-2xl border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:ring-2 focus:ring-blue-100"><?php echo esc_textarea($banner->content_type === 'html' ? $banner->content_value : ''); ?></textarea>
<textarea name="content_values[html]" id="content_value_html" rows="6" class="w-full rounded-2xl border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:ring-2 focus:ring-blue-100"><?php echo esc_textarea(function_exists('sodino_old_input') ? sodino_old_input('content_values.html', $banner->content_type === 'html' ? $banner->content_value : '') : ($banner->content_type === 'html' ? $banner->content_value : '')); ?></textarea>
</div>
<div class="sodino-banner-content-group" data-type="shortcode">
<label class="block text-sm font-medium text-gray-700 mb-2" for="content_value_shortcode"><?php _e('شورت‌کد بنر', 'sodino'); ?></label>
<textarea name="content_value" id="content_value_shortcode" rows="4" class="w-full rounded-2xl border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:ring-2 focus:ring-blue-100"><?php echo esc_textarea($banner->content_type === 'shortcode' ? $banner->content_value : ''); ?></textarea>
<textarea name="content_values[shortcode]" id="content_value_shortcode" rows="4" class="w-full rounded-2xl border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:ring-2 focus:ring-blue-100"><?php echo esc_textarea(function_exists('sodino_old_input') ? sodino_old_input('content_values.shortcode', $banner->content_type === 'shortcode' ? $banner->content_value : '') : ($banner->content_type === 'shortcode' ? $banner->content_value : '')); ?></textarea>
</div>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2" for="link_url"><?php _e('لینک بنر (اختیاری)', 'sodino'); ?></label>
<input type="url" name="link_url" id="link_url" value="<?php echo esc_attr($banner->link_url); ?>" class="w-full rounded-2xl border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:ring-2 focus:ring-blue-100" placeholder="https://">
<input type="url" name="link_url" id="link_url" value="<?php echo esc_attr(function_exists('sodino_old_input') ? sodino_old_input('link_url', $banner->link_url) : $banner->link_url); ?>" class="w-full rounded-2xl border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:ring-2 focus:ring-blue-100" placeholder="https://">
</div>
</div>
@@ -106,11 +124,12 @@ $current_page = sanitize_text_field($_GET['page'] ?? 'sodino-add-banner');
<div>
<label class="block text-sm font-medium text-gray-700 mb-2" for="position"><?php _e('محل نمایش', 'sodino'); ?></label>
<select name="position" id="position" class="w-full rounded-2xl border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:ring-2 focus:ring-blue-100">
<option value="top" <?php selected($banner->position, 'top'); ?>><?php _e('بالای سایت', 'sodino'); ?></option>
<option value="middle" <?php selected($banner->position, 'middle'); ?>><?php _e('وسط محتوا', 'sodino'); ?></option>
<option value="bottom" <?php selected($banner->position, 'bottom'); ?>><?php _e('پایین', 'sodino'); ?></option>
<option value="product_page" <?php selected($banner->position, 'product_page'); ?>><?php _e('صفحه محصول', 'sodino'); ?></option>
<option value="cart" <?php selected($banner->position, 'cart'); ?>><?php _e('سبد خرید', 'sodino'); ?></option>
<?php $form_position = function_exists('sodino_old_input') ? sodino_old_input('position', $banner->position) : $banner->position; ?>
<option value="top" <?php selected($form_position, 'top'); ?>><?php _e('بالای سایت', 'sodino'); ?></option>
<option value="middle" <?php selected($form_position, 'middle'); ?>><?php _e('وسط محتوا', 'sodino'); ?></option>
<option value="bottom" <?php selected($form_position, 'bottom'); ?>><?php _e('پایین', 'sodino'); ?></option>
<option value="product_page" <?php selected($form_position, 'product_page'); ?>><?php _e('صفحه محصول', 'sodino'); ?></option>
<option value="cart" <?php selected($form_position, 'cart'); ?>><?php _e('سبد خرید', 'sodino'); ?></option>
</select>
</div>
<div>
@@ -119,7 +138,7 @@ $current_page = sanitize_text_field($_GET['page'] ?? 'sodino-add-banner');
<?php $display_types = ['inline' => __('داخل صفحه', 'sodino'), 'popup' => __('پاپ‌آپ', 'sodino'), 'floating_bar' => __('نوار شناور', 'sodino')]; ?>
<?php foreach ($display_types as $value => $label) : ?>
<label class="flex items-center gap-3 rounded-2xl border border-gray-300 bg-white px-4 py-3 cursor-pointer hover:border-blue-300">
<input type="radio" name="display_type" value="<?php echo esc_attr($value); ?>" <?php checked($banner->display_type, $value); ?> class="h-4 w-4 text-blue-600">
<input type="radio" name="display_type" value="<?php echo esc_attr($value); ?>" <?php checked($form_display_type, $value); ?> class="h-4 w-4 text-blue-600">
<span class="text-sm text-gray-700"><?php echo esc_html($label); ?></span>
</label>
<?php endforeach; ?>

View File

@@ -22,6 +22,7 @@ $current_page = sanitize_text_field($_GET['page'] ?? 'sodino-banners');
</div>
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<?php if (function_exists('sodino_render_admin_notice')) { sodino_render_admin_notice(); } ?>
<div class="grid gap-8 lg:grid-cols-[280px_1fr]">
<aside class="bg-white rounded-2xl border border-gray-200 p-6 shadow-sm">
<h2 class="text-lg font-semibold text-gray-900 mb-4"><?php _e('منوی سودینو', 'sodino'); ?></h2>
@@ -32,9 +33,24 @@ $current_page = sanitize_text_field($_GET['page'] ?? 'sodino-banners');
<a href="<?php echo admin_url('admin.php?page=sodino-rules'); ?>" class="block px-3 py-2 rounded-xl text-sm font-medium <?php echo $current_page === 'sodino-rules' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('قوانین', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-add-rule'); ?>" class="block px-3 py-2 rounded-xl text-sm font-medium <?php echo $current_page === 'sodino-add-rule' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('افزودن قانون', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-upsells'); ?>" class="block px-3 py-2 rounded-xl text-sm font-medium <?php echo $current_page === 'sodino-upsells' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('آپسل (پیشنهاد فروش)', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-add-upsell'); ?>" class="block px-3 py-2 rounded-xl text-sm font-medium <?php echo $current_page === 'sodino-add-upsell' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('افزودن آپسل', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-banners'); ?>" class="block px-3 py-2 rounded-xl text-sm font-medium <?php echo $current_page === 'sodino-banners' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('بنرهای هوشمند', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-add-banner'); ?>" class="block px-3 py-2 rounded-xl text-sm font-medium <?php echo $current_page === 'sodino-add-banner' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('افزودن بنر', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-competitor-price'); ?>" class="block px-3 py-2 rounded-xl text-sm font-medium <?php echo $current_page === 'sodino-competitor-price' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('قیمت رقبا (به‌زودی)', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-settings'); ?>" class="block px-3 py-2 rounded-xl text-sm font-medium <?php echo $current_page === 'sodino-settings' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('تنظیمات', 'sodino'); ?>
</a>

View File

@@ -21,6 +21,7 @@ $current_page = sanitize_text_field($_GET['page'] ?? 'sodino-competitor-price');
</div>
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<?php if (function_exists('sodino_render_admin_notice')) { sodino_render_admin_notice(); } ?>
<div class="flex gap-8">
<aside class="w-64 flex-shrink-0">
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6">
@@ -41,6 +42,12 @@ $current_page = sanitize_text_field($_GET['page'] ?? 'sodino-competitor-price');
<a href="<?php echo admin_url('admin.php?page=sodino-add-upsell'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-add-upsell' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('افزودن آپسل', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-banners'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-banners' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('بنرهای هوشمند', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-add-banner'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-add-banner' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('افزودن بنر', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-competitor-price'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-competitor-price' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('قیمت رقبا (به‌زودی)', 'sodino'); ?>
</a>

View File

@@ -27,6 +27,7 @@ $current_page = sanitize_text_field($_GET['page'] ?? 'sodino-dashboard');
</div>
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<?php if (function_exists('sodino_render_admin_notice')) { sodino_render_admin_notice(); } ?>
<div class="flex gap-8">
<!-- Sidebar -->
<aside class="w-64 flex-shrink-0">
@@ -48,6 +49,12 @@ $current_page = sanitize_text_field($_GET['page'] ?? 'sodino-dashboard');
<a href="<?php echo admin_url('admin.php?page=sodino-add-upsell'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-add-upsell' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('افزودن آپسل', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-banners'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-banners' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('بنرهای هوشمند', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-add-banner'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-add-banner' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('افزودن بنر', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-competitor-price'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-competitor-price' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('قیمت رقبا (به‌زودی)', 'sodino'); ?>
</a>

View File

@@ -5,6 +5,8 @@ if (!defined('ABSPATH')) {
}
$current_page = sanitize_text_field($_GET['page'] ?? 'sodino-add-rule');
$form_condition_type = function_exists('sodino_old_input') ? sodino_old_input('condition_type', $rule->condition_type) : $rule->condition_type;
$form_action_type = function_exists('sodino_old_input') ? sodino_old_input('action_type', $rule->action_type) : $rule->action_type;
?>
<div id="sodino-app" class="min-h-screen bg-gray-50" dir="rtl">
<!-- Header -->
@@ -22,6 +24,7 @@ $current_page = sanitize_text_field($_GET['page'] ?? 'sodino-add-rule');
</div>
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<?php if (function_exists('sodino_render_admin_notice')) { sodino_render_admin_notice(); } ?>
<div class="flex gap-8">
<!-- Sidebar -->
<aside class="w-64 flex-shrink-0">
@@ -43,6 +46,12 @@ $current_page = sanitize_text_field($_GET['page'] ?? 'sodino-add-rule');
<a href="<?php echo admin_url('admin.php?page=sodino-add-upsell'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-add-upsell' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('افزودن آپسل', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-banners'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-banners' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('بنرهای هوشمند', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-add-banner'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-add-banner' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('افزودن بنر', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-competitor-price'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-competitor-price' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('قیمت رقبا (به‌زودی)', 'sodino'); ?>
</a>
@@ -74,27 +83,27 @@ $current_page = sanitize_text_field($_GET['page'] ?? 'sodino-add-rule');
<!-- Form -->
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6">
<form method="post">
<?php wp_nonce_field('gheymatyar_save_rule', 'gheymatyar_rule_nonce'); ?>
<?php wp_nonce_field('sodino_save_rule', 'sodino_rule_nonce'); ?>
<div class="grid gap-6 md:grid-cols-2">
<!-- Rule Name -->
<div class="md:col-span-2">
<label for="name" class="block text-sm font-medium text-gray-700 mb-2"><?php _e('عنوان قانون', 'sodino'); ?></label>
<input type="text" name="name" id="name" value="<?php echo esc_attr($rule->name); ?>" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100" required>
<input type="text" name="name" id="name" value="<?php echo esc_attr(function_exists('sodino_old_input') ? sodino_old_input('name', $rule->name) : $rule->name); ?>" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100" required>
<p class="mt-2 text-sm text-gray-500"><?php _e('نامی کوتاه و قابل فهم برای قانون انتخاب کنید.', 'sodino'); ?></p>
</div>
<!-- Priority -->
<div>
<label for="priority" class="block text-sm font-medium text-gray-700 mb-2"><?php _e('اولویت', 'sodino'); ?></label>
<input type="number" name="priority" id="priority" value="<?php echo esc_attr($rule->priority ?: 10); ?>" min="1" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100">
<input type="number" name="priority" id="priority" value="<?php echo esc_attr(function_exists('sodino_old_input') ? sodino_old_input('priority', $rule->priority ?: 10) : ($rule->priority ?: 10)); ?>" min="1" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100">
<p class="mt-2 text-sm text-gray-500"><?php _e('عدد بالاتر، اولویت بیشتری دارد.', 'sodino'); ?></p>
</div>
<!-- Usage Limit -->
<div>
<label for="usage_limit" class="block text-sm font-medium text-gray-700 mb-2"><?php _e('محدودیت تعداد استفاده', 'sodino'); ?></label>
<input type="number" name="usage_limit" id="usage_limit" value="<?php echo esc_attr($rule->usage_limit ?? 0); ?>" min="0" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100">
<input type="number" name="usage_limit" id="usage_limit" value="<?php echo esc_attr(function_exists('sodino_old_input') ? sodino_old_input('usage_limit', $rule->usage_limit ?? 0) : ($rule->usage_limit ?? 0)); ?>" min="0" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100">
<p class="mt-2 text-sm text-gray-500"><?php _e('0 به معنی بدون محدودیت است.', 'sodino'); ?></p>
</div>
@@ -113,9 +122,9 @@ $current_page = sanitize_text_field($_GET['page'] ?? 'sodino-add-rule');
<div>
<label for="condition_type" class="block text-sm font-medium text-gray-700 mb-2"><?php _e('نوع شرط', 'sodino'); ?></label>
<select name="condition_type" id="condition_type" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100" required>
<option value="user_type" <?php selected($rule->condition_type, 'user_type'); ?>><?php _e('نوع کاربر', 'sodino'); ?></option>
<option value="product_category" <?php selected($rule->condition_type, 'product_category'); ?>><?php _e('دسته‌بندی محصول', 'sodino'); ?></option>
<option value="product_ids" <?php selected($rule->condition_type, 'product_ids'); ?>><?php _e('محصولات خاص', 'sodino'); ?></option>
<option value="user_type" <?php selected($form_condition_type, 'user_type'); ?>><?php _e('نوع کاربر', 'sodino'); ?></option>
<option value="product_category" <?php selected($form_condition_type, 'product_category'); ?>><?php _e('دسته‌بندی محصول', 'sodino'); ?></option>
<option value="product_ids" <?php selected($form_condition_type, 'product_ids'); ?>><?php _e('محصولات خاص', 'sodino'); ?></option>
</select>
<p class="mt-2 text-sm text-gray-500"><?php _e('نوع شرطی که باید قبل از اعمال قانون بررسی شود.', 'sodino'); ?></p>
</div>
@@ -123,7 +132,7 @@ $current_page = sanitize_text_field($_GET['page'] ?? 'sodino-add-rule');
<!-- Condition Value -->
<div>
<label for="condition_value" class="block text-sm font-medium text-gray-700 mb-2"><?php _e('مقدار شرط', 'sodino'); ?></label>
<input type="text" name="condition_value" id="condition_value" value="<?php echo esc_attr($rule->condition_value); ?>" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100" required>
<input type="text" name="condition_value" id="condition_value" value="<?php echo esc_attr(function_exists('sodino_old_input') ? sodino_old_input('condition_value', $rule->condition_value) : $rule->condition_value); ?>" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100" required>
<p class="mt-2 text-sm text-gray-500"><?php _e('برای کاربر جدید/بازگشتی: new یا returning. برای دسته‌بندی: شناسه دسته‌بندی، برای محصولات: شناسه محصول.', 'sodino'); ?></p>
</div>
@@ -131,16 +140,16 @@ $current_page = sanitize_text_field($_GET['page'] ?? 'sodino-add-rule');
<div>
<label for="action_type" class="block text-sm font-medium text-gray-700 mb-2"><?php _e('نوع عملیات', 'sodino'); ?></label>
<select name="action_type" id="action_type" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100" required>
<option value="discount_percent" <?php selected($rule->action_type, 'discount_percent'); ?>><?php _e('درصد تخفیف', 'sodino'); ?></option>
<option value="discount_fixed" <?php selected($rule->action_type, 'discount_fixed'); ?>><?php _e('تخفیف ثابت', 'sodino'); ?></option>
<option value="free_shipping" <?php selected($rule->action_type, 'free_shipping'); ?>><?php _e('ارسال رایگان', 'sodino'); ?></option>
<option value="discount_percent" <?php selected($form_action_type, 'discount_percent'); ?>><?php _e('درصد تخفیف', 'sodino'); ?></option>
<option value="discount_fixed" <?php selected($form_action_type, 'discount_fixed'); ?>><?php _e('تخفیف ثابت', 'sodino'); ?></option>
<option value="free_shipping" <?php selected($form_action_type, 'free_shipping'); ?>><?php _e('ارسال رایگان', 'sodino'); ?></option>
</select>
</div>
<!-- Action Value -->
<div>
<label for="action_value" class="block text-sm font-medium text-gray-700 mb-2"><?php _e('مقدار عملیات', 'sodino'); ?></label>
<input type="number" name="action_value" id="action_value" value="<?php echo esc_attr($rule->action_value); ?>" min="0" step="0.01" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100">
<input type="number" name="action_value" id="action_value" value="<?php echo esc_attr(function_exists('sodino_old_input') ? sodino_old_input('action_value', $rule->action_value) : $rule->action_value); ?>" min="0" step="0.01" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100">
<p class="mt-2 text-sm text-gray-500"><?php _e('برای درصد یا مقدار ثابت وارد کنید.', 'sodino'); ?></p>
</div>
@@ -164,4 +173,4 @@ $current_page = sanitize_text_field($_GET['page'] ?? 'sodino-add-rule');
</main>
</div>
</div>
</div>
</div>

View File

@@ -22,6 +22,7 @@ $current_page = sanitize_text_field($_GET['page'] ?? 'sodino-rules');
</div>
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<?php if (function_exists('sodino_render_admin_notice')) { sodino_render_admin_notice(); } ?>
<div class="flex gap-8">
<!-- Sidebar -->
<aside class="w-64 flex-shrink-0">
@@ -43,11 +44,17 @@ $current_page = sanitize_text_field($_GET['page'] ?? 'sodino-rules');
<a href="<?php echo admin_url('admin.php?page=sodino-add-upsell'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-add-upsell' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('افزودن آپسل', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-banners'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-banners' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('بنرهای هوشمند', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-add-banner'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-add-banner' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('افزودن بنر', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-competitor-price'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-competitor-price' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('قیمت رقبا (به‌زودی)', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-settings'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-settings' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('تنظیمات', 'sودینو'); ?>
<?php _e('تنظیمات', 'sodino'); ?>
</a>
</nav>
</div>
@@ -80,4 +87,4 @@ $current_page = sanitize_text_field($_GET['page'] ?? 'sodino-rules');
</main>
</div>
</div>
</div>
</div>

View File

@@ -5,18 +5,20 @@ if (!defined('ABSPATH')) {
}
$current_page = sanitize_text_field($_GET['page'] ?? 'sodino-add-upsell');
$form_trigger_type = function_exists('sodino_old_input') ? sodino_old_input('trigger_type', $upsell->trigger_type) : $upsell->trigger_type;
$form_discount_type = function_exists('sodino_old_input') ? sodino_old_input('discount_type', $upsell->discount_type) : $upsell->discount_type;
$trigger_product = null;
$trigger_product_label = '';
$target_product = null;
$target_product_label = '';
if ($upsell->trigger_type === 'product' && $upsell->trigger_value) {
$trigger_product = wc_get_product(intval($upsell->trigger_value));
if ($form_trigger_type === 'product' && (function_exists('sodino_old_input') ? sodino_old_input('trigger_values.product', $upsell->trigger_value) : $upsell->trigger_value)) {
$trigger_product = wc_get_product(intval(function_exists('sodino_old_input') ? sodino_old_input('trigger_values.product', $upsell->trigger_value) : $upsell->trigger_value));
$trigger_product_label = $trigger_product ? $trigger_product->get_name() : '';
}
if ($upsell->target_product_id) {
$target_product = wc_get_product($upsell->target_product_id);
if (function_exists('sodino_old_input') ? sodino_old_input('target_product_id', $upsell->target_product_id) : $upsell->target_product_id) {
$target_product = wc_get_product(function_exists('sodino_old_input') ? sodino_old_input('target_product_id', $upsell->target_product_id) : $upsell->target_product_id);
$target_product_label = $target_product ? $target_product->get_name() : '';
}
@@ -40,6 +42,7 @@ $product_categories = get_terms([
</div>
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<?php if (function_exists('sodino_render_admin_notice')) { sodino_render_admin_notice(); } ?>
<div class="flex gap-8">
<aside class="w-64 flex-shrink-0">
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6">
@@ -60,6 +63,12 @@ $product_categories = get_terms([
<a href="<?php echo admin_url('admin.php?page=sodino-add-upsell'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-add-upsell' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('افزودن آپسل', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-banners'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-banners' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('بنرهای هوشمند', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-add-banner'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-add-banner' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('افزودن بنر', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-competitor-price'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-competitor-price' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('قیمت رقبا (به‌زودی)', 'sodino'); ?>
</a>
@@ -90,30 +99,30 @@ $product_categories = get_terms([
<div class="grid gap-6 md:grid-cols-2">
<div class="md:col-span-2">
<label for="title" class="block text-sm font-medium text-gray-700 mb-2"><?php _e('عنوان', 'sodino'); ?></label>
<input type="text" name="title" id="title" value="<?php echo esc_attr($upsell->title); ?>" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100" required>
<input type="text" name="title" id="title" value="<?php echo esc_attr(function_exists('sodino_old_input') ? sodino_old_input('title', $upsell->title) : $upsell->title); ?>" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100" required>
</div>
<div class="md:col-span-2">
<label class="block text-sm font-medium text-gray-700 mb-2"><?php _e('نوع شرط', 'sodino'); ?></label>
<div class="space-y-3">
<label class="flex items-center gap-3 rounded-lg border border-gray-200 bg-white px-4 py-3 cursor-pointer hover:border-blue-300">
<input type="radio" name="trigger_type" value="product" class="trigger-type" <?php checked($upsell->trigger_type, 'product'); ?>>
<input type="radio" name="trigger_type" value="product" class="trigger-type" <?php checked($form_trigger_type, 'product'); ?>>
<span><?php _e('محصول خاص', 'sodino'); ?></span>
</label>
<label class="flex items-center gap-3 rounded-lg border border-gray-200 bg-white px-4 py-3 cursor-pointer hover:border-blue-300">
<input type="radio" name="trigger_type" value="category" class="trigger-type" <?php checked($upsell->trigger_type, 'category'); ?>>
<input type="radio" name="trigger_type" value="category" class="trigger-type" <?php checked($form_trigger_type, 'category'); ?>>
<span><?php _e('دسته‌بندی', 'sodino'); ?></span>
</label>
<label class="flex items-center gap-3 rounded-lg border border-gray-200 bg-white px-4 py-3 cursor-pointer hover:border-blue-300">
<input type="radio" name="trigger_type" value="cart_total" class="trigger-type" <?php checked($upsell->trigger_type, 'cart_total'); ?>>
<input type="radio" name="trigger_type" value="cart_total" class="trigger-type" <?php checked($form_trigger_type, 'cart_total'); ?>>
<span><?php _e('مبلغ سبد خرید', 'sodino'); ?></span>
</label>
</div>
</div>
<input type="hidden" name="trigger_value" id="trigger_value" value="<?php echo esc_attr($upsell->trigger_value); ?>">
<input type="hidden" name="trigger_values[product]" id="trigger_value" value="<?php echo esc_attr(function_exists('sodino_old_input') ? sodino_old_input('trigger_values.product', $form_trigger_type === 'product' ? $upsell->trigger_value : '') : ($form_trigger_type === 'product' ? $upsell->trigger_value : '')); ?>">
<div id="trigger-product-wrapper" class="md:col-span-2 <?php echo $upsell->trigger_type === 'product' ? '' : 'hidden'; ?>">
<div id="trigger-product-wrapper" class="md:col-span-2 <?php echo $form_trigger_type === 'product' ? '' : 'hidden'; ?>">
<label for="trigger_product_search" class="block text-sm font-medium text-gray-700 mb-2"><?php _e('محصول فعال‌ساز', 'sodino'); ?></label>
<div class="relative">
<input type="text" id="trigger_product_search" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100" placeholder="<?php _e('جستجوی محصول...', 'sodino'); ?>" value="<?php echo esc_attr($trigger_product_label); ?>">
@@ -122,25 +131,25 @@ $product_categories = get_terms([
<p class="mt-2 text-sm text-gray-500"><?php _e('محصولی که باعث نمایش پیشنهاد آپسل می‌شود را انتخاب کنید.', 'sodino'); ?></p>
</div>
<div id="trigger-category-wrapper" class="md:col-span-2 <?php echo $upsell->trigger_type === 'category' ? '' : 'hidden'; ?>">
<div id="trigger-category-wrapper" class="md:col-span-2 <?php echo $form_trigger_type === 'category' ? '' : 'hidden'; ?>">
<label for="trigger_value_category" class="block text-sm font-medium text-gray-700 mb-2"><?php _e('دسته‌بندی', 'sodino'); ?></label>
<select name="trigger_value" id="trigger_value_category" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100">
<select name="trigger_values[category]" id="trigger_value_category" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100">
<option value=""><?php _e('دسته‌بندی را انتخاب کنید', 'sodino'); ?></option>
<?php foreach ($product_categories as $category) : ?>
<option value="<?php echo esc_attr($category->term_id); ?>" <?php selected($upsell->trigger_type, 'category'); selected($upsell->trigger_value, $category->term_id); ?>><?php echo esc_html($category->name); ?></option>
<option value="<?php echo esc_attr($category->term_id); ?>" <?php selected((string) (function_exists('sodino_old_input') ? sodino_old_input('trigger_values.category', $form_trigger_type === 'category' ? $upsell->trigger_value : '') : ($form_trigger_type === 'category' ? $upsell->trigger_value : '')), (string) $category->term_id); ?>><?php echo esc_html($category->name); ?></option>
<?php endforeach; ?>
</select>
</div>
<div id="trigger-amount-wrapper" class="md:col-span-2 <?php echo $upsell->trigger_type === 'cart_total' ? '' : 'hidden'; ?>">
<div id="trigger-amount-wrapper" class="md:col-span-2 <?php echo $form_trigger_type === 'cart_total' ? '' : 'hidden'; ?>">
<label for="trigger_value_amount" class="block text-sm font-medium text-gray-700 mb-2"><?php _e('مبلغ سبد خرید', 'sodino'); ?></label>
<input type="number" name="trigger_value" id="trigger_value_amount" value="<?php echo esc_attr($upsell->trigger_type === 'cart_total' ? $upsell->trigger_value : ''); ?>" min="0" step="0.01" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100">
<input type="number" name="trigger_values[cart_total]" id="trigger_value_amount" value="<?php echo esc_attr(function_exists('sodino_old_input') ? sodino_old_input('trigger_values.cart_total', $form_trigger_type === 'cart_total' ? $upsell->trigger_value : '') : ($form_trigger_type === 'cart_total' ? $upsell->trigger_value : '')); ?>" min="0" step="0.01" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100">
</div>
<div class="md:col-span-2">
<label for="target_product_search" class="block text-sm font-medium text-gray-700 mb-2"><?php _e('محصول پیشنهادی', 'sodino'); ?></label>
<div class="relative">
<input type="hidden" name="target_product_id" id="target_product_id" value="<?php echo esc_attr($upsell->target_product_id); ?>">
<input type="hidden" name="target_product_id" id="target_product_id" value="<?php echo esc_attr(function_exists('sodino_old_input') ? sodino_old_input('target_product_id', $upsell->target_product_id) : $upsell->target_product_id); ?>">
<input type="text" id="target_product_search" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100" placeholder="<?php _e('جستجوی محصول پیشنهادی...', 'sodino'); ?>" value="<?php echo esc_attr($target_product_label); ?>">
<div id="target_product_results" class="absolute z-10 mt-1 w-full rounded-xl border border-gray-200 bg-white shadow-lg hidden"></div>
</div>
@@ -150,20 +159,20 @@ $product_categories = get_terms([
<div>
<label for="discount_type" class="block text-sm font-medium text-gray-700 mb-2"><?php _e('نوع تخفیف', 'sodino'); ?></label>
<select name="discount_type" id="discount_type" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100">
<option value="percentage" <?php selected($upsell->discount_type, 'percentage'); ?>><?php _e('درصدی', 'sodino'); ?></option>
<option value="fixed" <?php selected($upsell->discount_type, 'fixed'); ?>><?php _e('مبلغ ثابت', 'sodino'); ?></option>
<option value="none" <?php selected($upsell->discount_type, 'none'); ?>><?php _e('بدون تخفیف', 'sodino'); ?></option>
<option value="percentage" <?php selected($form_discount_type, 'percentage'); ?>><?php _e('درصدی', 'sodino'); ?></option>
<option value="fixed" <?php selected($form_discount_type, 'fixed'); ?>><?php _e('مبلغ ثابت', 'sodino'); ?></option>
<option value="none" <?php selected($form_discount_type, 'none'); ?>><?php _e('بدون تخفیف', 'sodino'); ?></option>
</select>
</div>
<div>
<label for="discount_value" class="block text-sm font-medium text-gray-700 mb-2"><?php _e('مقدار تخفیف', 'sodino'); ?></label>
<input type="number" name="discount_value" id="discount_value" value="<?php echo esc_attr($upsell->discount_value); ?>" min="0" step="0.01" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100">
<input type="number" name="discount_value" id="discount_value" value="<?php echo esc_attr(function_exists('sodino_old_input') ? sodino_old_input('discount_value', $upsell->discount_value) : $upsell->discount_value); ?>" min="0" step="0.01" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100">
</div>
<div>
<label for="priority" class="block text-sm font-medium text-gray-700 mb-2"><?php _e('اولویت', 'sodino'); ?></label>
<input type="number" name="priority" id="priority" value="<?php echo esc_attr($upsell->priority); ?>" min="1" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100">
<input type="number" name="priority" id="priority" value="<?php echo esc_attr(function_exists('sodino_old_input') ? sodino_old_input('priority', $upsell->priority) : $upsell->priority); ?>" min="1" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100">
</div>
<div class="md:col-span-2">

View File

@@ -21,6 +21,7 @@ $current_page = sanitize_text_field($_GET['page'] ?? 'sodino-upsells');
</div>
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<?php if (function_exists('sodino_render_admin_notice')) { sodino_render_admin_notice(); } ?>
<div class="flex gap-8">
<aside class="w-64 flex-shrink-0">
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6">
@@ -41,6 +42,12 @@ $current_page = sanitize_text_field($_GET['page'] ?? 'sodino-upsells');
<a href="<?php echo admin_url('admin.php?page=sodino-add-upsell'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-add-upsell' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('افزودن آپسل', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-banners'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-banners' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('بنرهای هوشمند', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-add-banner'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-add-banner' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('افزودن بنر', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-competitor-price'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-competitor-price' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('قیمت رقبا (به‌زودی)', 'sodino'); ?>
</a>