Files
sodino/admin/views/settings.php

189 lines
9.9 KiB
PHP

<?php
// Prevent direct access
if (!defined('ABSPATH')) {
exit;
}
// Load components
require_once SODINO_PLUGIN_DIR . 'admin/components/layout.php';
sodino_admin_layout($current_page ?? 'sodino-settings', function() use ($settings) {
?>
<!-- Page Header -->
<?php sodino_card(
__('تنظیمات سودینو', 'sodino'),
__('تنظیمات عمومی پلاگین را مدیریت کنید.', 'sodino'),
null,
'mb-8'
); ?>
<!-- Settings Form -->
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6">
<form method="post" class="space-y-8">
<?php wp_nonce_field('sodino_save_settings', 'sodino_settings_nonce'); ?>
<!-- General Settings -->
<div class="border-b border-gray-200 pb-6">
<h3 class="text-lg font-semibold text-gray-900 mb-4"><?php _e('تنظیمات عمومی', 'sodino'); ?></h3>
<div class="space-y-4">
<?php sodino_form_field([
'type' => 'checkbox',
'name' => 'plugin_enabled',
'label' => __('فعال‌سازی پلاگین', 'sodino'),
'value' => $settings['plugin_enabled'] ?? 1,
'description' => __('پلاگین سودینو را فعال یا غیرفعال کنید.', 'sodino')
]); ?>
<?php sodino_form_field([
'type' => 'checkbox',
'name' => 'pricing_enabled',
'label' => __('فعال‌سازی قیمت‌گذاری پویا', 'sodino'),
'value' => $settings['pricing_enabled'] ?? 1,
'description' => __('قیمت‌گذاری پویا بر اساس قوانین تعریف‌شده.', 'sodino')
]); ?>
<?php sodino_form_field([
'type' => 'checkbox',
'name' => 'upsell_enabled',
'label' => __('فعال‌سازی آپسل', 'sodino'),
'value' => $settings['upsell_enabled'] ?? 1,
'description' => __('نمایش پیشنهادات فروش به مشتریان.', 'sodino')
]); ?>
<?php sodino_form_field([
'type' => 'checkbox',
'name' => 'banner_enabled',
'label' => __('فعال‌سازی بنرهای هوشمند', 'sodino'),
'value' => $settings['banner_enabled'] ?? 1,
'description' => __('نمایش بنرهای هدفمند به کاربران.', 'sodino')
]); ?>
</div>
</div>
<!-- Pricing Strategy -->
<div class="border-b border-gray-200 pb-6">
<h3 class="text-lg font-semibold text-gray-900 mb-4"><?php _e('استراتژی قیمت‌گذاری', 'sodino'); ?></h3>
<div class="space-y-4">
<?php sodino_form_field([
'type' => 'checkbox',
'name' => 'allow_multiple_rules',
'label' => __('اجازه اعمال چند قانون همزمان', 'sodino'),
'value' => $settings['allow_multiple_rules'] ?? 0,
'description' => __('اگر فعال باشد، چند قانون می‌تواند روی یک محصول اعمال شود.', 'sodino')
]); ?>
<?php sodino_form_field([
'type' => 'select',
'name' => 'strategy',
'label' => __('استراتژی انتخاب قانون', 'sodino'),
'value' => $settings['strategy'] ?? 'priority',
'options' => [
'priority' => __('بر اساس اولویت', 'sodino'),
'highest_discount' => __('بیشترین تخفیف', 'sodino'),
'first_valid' => __('اولین قانون معتبر', 'sodino')
],
'description' => __('نحوه انتخاب قانون زمانی که چند قانون معتبر وجود دارد.', 'sodino')
]); ?>
<?php sodino_form_field([
'type' => 'number',
'name' => 'max_discount_percent',
'label' => __('حداکثر درصد تخفیف', 'sodino'),
'value' => $settings['max_discount_percent'] ?? 100,
'placeholder' => '100',
'description' => __('حداکثر درصد تخفیفی که می‌تواند اعمال شود (0-100).', 'sodino')
]); ?>
<?php sodino_form_field([
'type' => 'number',
'name' => 'min_product_price',
'label' => __('حداقل قیمت محصول', 'sodino'),
'value' => $settings['min_product_price'] ?? 0,
'placeholder' => '0',
'description' => __('حداقل قیمتی که یک محصول می‌تواند داشته باشد.', 'sodino')
]); ?>
<?php sodino_form_field([
'type' => 'checkbox',
'name' => 'cart_pricing_enabled',
'label' => __('قیمت‌گذاری در سبد خرید', 'sodino'),
'value' => $settings['cart_pricing_enabled'] ?? 1,
'description' => __('اعمال قیمت‌گذاری پویا در صفحه سبد خرید.', 'sodino')
]); ?>
</div>
</div>
<!-- Performance Settings -->
<div class="border-b border-gray-200 pb-6">
<h3 class="text-lg font-semibold text-gray-900 mb-4"><?php _e('تنظیمات عملکرد', 'sodino'); ?></h3>
<div class="space-y-4">
<?php sodino_form_field([
'type' => 'checkbox',
'name' => 'cache_enabled',
'label' => __('فعال‌سازی کش', 'sodino'),
'value' => $settings['cache_enabled'] ?? 1,
'description' => __('استفاده از کش برای بهبود عملکرد.', 'sodino')
]); ?>
<?php sodino_form_field([
'type' => 'number',
'name' => 'cache_duration',
'label' => __('مدت زمان کش (ثانیه)', 'sodino'),
'value' => $settings['cache_duration'] ?? 3600,
'placeholder' => '3600',
'description' => __('مدت زمان نگهداری داده‌ها در کش (پیش‌فرض: 3600 ثانیه = 1 ساعت).', 'sodino')
]); ?>
<div class="flex items-center gap-4">
<?php sodino_button(
__('پاک کردن کش', 'sodino'),
wp_nonce_url(admin_url('admin.php?page=sodino-settings&action=clear_cache'), 'clear_cache'),
'secondary'
); ?>
<span class="text-sm text-gray-500"><?php _e('تمام کش‌های سودینو را پاک می‌کند.', 'sodino'); ?></span>
</div>
</div>
</div>
<!-- Advanced Settings -->
<div>
<h3 class="text-lg font-semibold text-gray-900 mb-4"><?php _e('تنظیمات پیشرفته', 'sodino'); ?></h3>
<div class="space-y-4">
<?php sodino_form_field([
'type' => 'checkbox',
'name' => 'ab_testing_enabled',
'label' => __('فعال‌سازی A/B Testing', 'sodino'),
'value' => $settings['ab_testing_enabled'] ?? 0,
'description' => __('تست A/B برای قوانین قیمت‌گذاری (قابلیت آزمایشی).', 'sodino')
]); ?>
<?php sodino_form_field([
'type' => 'checkbox',
'name' => 'scheduled_campaigns_enabled',
'label' => __('فعال‌سازی کمپین‌های زمان‌بندی شده', 'sodino'),
'value' => $settings['scheduled_campaigns_enabled'] ?? 1,
'description' => __('اجرای خودکار قوانین بر اساس تاریخ شروع و پایان.', 'sodino')
]); ?>
<?php sodino_form_field([
'type' => 'checkbox',
'name' => 'debug_mode',
'label' => __('حالت دیباگ', 'sodino'),
'value' => $settings['debug_mode'] ?? 0,
'description' => __('فعال‌سازی لاگ‌های دیباگ (فقط برای توسعه‌دهندگان).', 'sodino')
]); ?>
</div>
</div>
<!-- Submit Button -->
<div class="flex items-center justify-end gap-4 pt-6 border-t border-gray-200">
<button type="submit" class="inline-flex items-center px-6 py-3 bg-blue-600 text-white text-sm font-medium rounded-lg hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors duration-200">
<?php _e('ذخیره تنظیمات', 'sodino'); ?>
</button>
</div>
</form>
</div>
<?php
});
?>