feat(upsell): apply real cart discounts and track performance
This commit is contained in:
@@ -184,11 +184,11 @@ add_action('admin_menu', function() use ($adminController) {
|
||||
|
||||
add_submenu_page(
|
||||
'sodino-dashboard',
|
||||
__('قیمت رقبا (بهزودی)', 'sodino'),
|
||||
__('قیمت رقبا (بهزودی)', 'sodino'),
|
||||
__('ابزارها و سلامت', 'sodino'),
|
||||
__('ابزارها و سلامت', 'sodino'),
|
||||
'manage_options',
|
||||
'sodino-competitor-price',
|
||||
[$adminController, 'competitorPricePage']
|
||||
'sodino-tools',
|
||||
[$adminController, 'toolsPage']
|
||||
);
|
||||
|
||||
add_submenu_page(
|
||||
@@ -255,6 +255,11 @@ add_action('admin_init', function() use ($ruleController, $settingsController, $
|
||||
$settingsController->clearCache();
|
||||
}
|
||||
|
||||
// Tools actions
|
||||
if ($page === 'sodino-tools') {
|
||||
$adminController->handleToolsActions();
|
||||
}
|
||||
|
||||
// Banner actions
|
||||
if (strpos($page, 'sodino') === 0 && in_array($action, ['delete_banner', 'toggle_banner_status'], true)) {
|
||||
$adminController->handleBannerActions();
|
||||
|
||||
@@ -28,6 +28,7 @@ class Sodino_Upsell_List_Table extends WP_List_Table {
|
||||
'trigger' => __('شرط فعالسازی', 'sodino'),
|
||||
'suggested_product'=> __('محصول پیشنهادی', 'sodino'),
|
||||
'discount' => __('تخفیف', 'sodino'),
|
||||
'performance' => __('عملکرد', 'sodino'),
|
||||
'status' => __('وضعیت', 'sodino'),
|
||||
'actions' => __('عملیات', 'sodino'),
|
||||
];
|
||||
@@ -86,6 +87,22 @@ class Sodino_Upsell_List_Table extends WP_List_Table {
|
||||
return __('بدون تخفیف', 'sodino');
|
||||
}
|
||||
|
||||
public function column_performance($item) {
|
||||
$impressions = max(0, (int) ($item->impressions ?? 0));
|
||||
$conversions = max(0, (int) ($item->conversions ?? 0));
|
||||
$rate = $impressions > 0 ? round(($conversions / $impressions) * 100, 2) : 0;
|
||||
|
||||
return sprintf(
|
||||
'%s: %s<br>%s: %s<br>%s: %s%%',
|
||||
esc_html__('نمایش', 'sodino'),
|
||||
esc_html(number_format_i18n($impressions)),
|
||||
esc_html__('افزودن', 'sodino'),
|
||||
esc_html(number_format_i18n($conversions)),
|
||||
esc_html__('نرخ', 'sodino'),
|
||||
esc_html(number_format_i18n($rate, 2))
|
||||
);
|
||||
}
|
||||
|
||||
public function column_status($item) {
|
||||
return $item->status ? __('فعال', 'sodino') : __('غیرفعال', 'sodino');
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ $menu_items = [
|
||||
'sodino-add-upsell' => __('افزودن آپسل', 'sodino'),
|
||||
'sodino-banners' => __('بنرهای هوشمند', 'sodino'),
|
||||
'sodino-add-banner' => __('افزودن بنر', 'sodino'),
|
||||
'sodino-competitor-price' => __('قیمت رقبا (بهزودی)', 'sodino'),
|
||||
'sodino-tools' => __('ابزارها و سلامت', 'sodino'),
|
||||
'sodino-settings' => __('تنظیمات', 'sodino'),
|
||||
];
|
||||
?>
|
||||
|
||||
@@ -50,8 +50,8 @@ $form_display_type = function_exists('sodino_old_input') ? sodino_old_input('dis
|
||||
<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 href="<?php echo admin_url('admin.php?page=sodino-tools'); ?>" class="block px-3 py-2 rounded-xl text-sm font-medium <?php echo $current_page === 'sodino-tools' ? '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'); ?>
|
||||
|
||||
@@ -48,8 +48,8 @@ $current_page = sanitize_text_field($_GET['page'] ?? 'sodino-banners');
|
||||
<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 href="<?php echo admin_url('admin.php?page=sodino-tools'); ?>" class="block px-3 py-2 rounded-xl text-sm font-medium <?php echo $current_page === 'sodino-tools' ? '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'); ?>
|
||||
|
||||
@@ -1,152 +0,0 @@
|
||||
<?php
|
||||
// Prevent direct access
|
||||
if (!defined('ABSPATH')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$current_page = sanitize_text_field($_GET['page'] ?? 'sodino-competitor-price');
|
||||
?>
|
||||
<div id="sodino-app" class="min-h-screen bg-gray-50" dir="rtl">
|
||||
<div class="bg-white border-b border-gray-200">
|
||||
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div class="py-6">
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<h1 class="text-3xl font-bold text-gray-900"><?php _e('سودینو', 'sodino'); ?></h1>
|
||||
<p class="mt-1 text-sm text-gray-500"><?php _e('بهینهسازی هوشمند فروش', 'sodino'); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</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">
|
||||
<h2 class="text-lg font-semibold text-gray-900 mb-4"><?php _e('منوی سودینو', 'sodino'); ?></h2>
|
||||
<nav class="space-y-2">
|
||||
<a href="<?php echo admin_url('admin.php?page=sodino-dashboard'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-dashboard' ? '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-rules'); ?>" class="block px-3 py-2 rounded-md 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-md 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-md 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-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('تنظیمات', 'sodino'); ?>
|
||||
</a>
|
||||
</nav>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<main class="flex-1 min-w-0">
|
||||
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6 mb-8">
|
||||
<div class="flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
|
||||
<div>
|
||||
<h2 class="text-2xl font-semibold text-gray-900"><?php _e('قیمت رقبا', 'sodino'); ?></h2>
|
||||
<p class="mt-2 text-gray-600"><?php _e('بهزودی بخش مانیتورینگ قیمت رقبا فعال خواهد شد.', 'sodino'); ?></p>
|
||||
</div>
|
||||
<span class="inline-flex items-center rounded-full bg-yellow-50 px-3 py-1 text-sm font-medium text-yellow-700"><?php _e('بهزودی', 'sodino'); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-6 lg:grid-cols-3">
|
||||
<div class="lg:col-span-2 bg-white rounded-2xl border border-gray-200 shadow-sm p-6">
|
||||
<h3 class="text-lg font-semibold text-gray-900 mb-4"><?php _e('مشخصات رقیب', 'sodino'); ?></h3>
|
||||
<p class="text-sm text-gray-500 mb-6"><?php _e('این قابلیت به شما امکان میدهد قیمت محصولات خود را با رقبا مقایسه کرده و بهینهسازی کنید. (در نسخههای آینده فعال خواهد شد)', 'sodino'); ?></p>
|
||||
|
||||
<div class="overflow-x-auto rounded-xl border border-gray-200">
|
||||
<table class="min-w-full divide-y divide-gray-200 text-right text-sm text-gray-700">
|
||||
<thead class="bg-gray-50 text-gray-500">
|
||||
<tr>
|
||||
<th class="px-4 py-3 font-medium"><?php _e('محصول', 'sodino'); ?></th>
|
||||
<th class="px-4 py-3 font-medium"><?php _e('قیمت شما', 'sodino'); ?></th>
|
||||
<th class="px-4 py-3 font-medium"><?php _e('قیمت رقبا', 'sodino'); ?></th>
|
||||
<th class="px-4 py-3 font-medium"><?php _e('اختلاف قیمت', 'sodino'); ?></th>
|
||||
<th class="px-4 py-3 font-medium"><?php _e('وضعیت', 'sodino'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-200 bg-white">
|
||||
<tr>
|
||||
<td class="px-4 py-3"><?php _e('کفش دویدن', 'sodino'); ?></td>
|
||||
<td class="px-4 py-3">23,500 تومان</td>
|
||||
<td class="px-4 py-3">24,900 تومان</td>
|
||||
<td class="px-4 py-3 text-green-600">1,400 تومان کمتر</td>
|
||||
<td class="px-4 py-3"><span class="rounded-full bg-green-50 px-3 py-1 text-xs font-semibold text-green-700"><?php _e('رقبتی', 'sodino'); ?></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="px-4 py-3"><?php _e('کرم محافظ پوست', 'sodino'); ?></td>
|
||||
<td class="px-4 py-3">78,000 تومان</td>
|
||||
<td class="px-4 py-3">82,000 تومان</td>
|
||||
<td class="px-4 py-3 text-green-600">4,000 تومان کمتر</td>
|
||||
<td class="px-4 py-3"><span class="rounded-full bg-green-50 px-3 py-1 text-xs font-semibold text-green-700"><?php _e('رقبتی', 'sodino'); ?></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="px-4 py-3"><?php _e('کیف دستی', 'sodino'); ?></td>
|
||||
<td class="px-4 py-3">155,000 تومان</td>
|
||||
<td class="px-4 py-3">161,000 تومان</td>
|
||||
<td class="px-4 py-3 text-red-600">6,000 تومان بیشتر</td>
|
||||
<td class="px-4 py-3"><span class="rounded-full bg-gray-50 px-3 py-1 text-xs font-semibold text-gray-700"><?php _e('هشدار', 'sodino'); ?></span></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-6">
|
||||
<div class="bg-white rounded-2xl border border-gray-200 shadow-sm p-6">
|
||||
<div class="flex items-center justify-between mb-4">
|
||||
<h3 class="text-lg font-semibold text-gray-900"><?php _e('افزودن رقیب', 'sodino'); ?></h3>
|
||||
<span class="rounded-full bg-blue-50 px-3 py-1 text-xs font-semibold text-blue-700"><?php _e('بهزودی', 'sodino'); ?></span>
|
||||
</div>
|
||||
<div class="space-y-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-2"><?php _e('URL سایت رقیب', 'sodino'); ?></label>
|
||||
<input type="url" disabled class="w-full rounded-lg border border-gray-200 bg-gray-100 px-4 py-3 text-gray-500 shadow-sm" placeholder="https://example.com">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-2"><?php _e('نام فروشگاه', 'sodino'); ?></label>
|
||||
<input type="text" disabled class="w-full rounded-lg border border-gray-200 bg-gray-100 px-4 py-3 text-gray-500 shadow-sm" placeholder="<?php _e('مثلاً اسم فروشگاه رقبا', 'sodino'); ?>">
|
||||
</div>
|
||||
<button disabled class="w-full rounded-full bg-gray-300 px-4 py-3 text-sm font-semibold text-gray-700"><?php _e('افزودن', 'sodino'); ?></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bg-white rounded-2xl border border-gray-200 shadow-sm p-6">
|
||||
<div class="flex items-center justify-between mb-4">
|
||||
<div>
|
||||
<h3 class="text-lg font-semibold text-gray-900"><?php _e('فعالسازی مانیتورینگ قیمت', 'sodino'); ?></h3>
|
||||
<p class="mt-1 text-sm text-gray-500"><?php _e('این ویژگی در نسخههای آینده فعال میشود.', 'sodino'); ?></p>
|
||||
</div>
|
||||
<div class="flex items-center gap-3">
|
||||
<span class="px-3 py-1 rounded-full bg-gray-100 text-xs font-semibold text-gray-600"><?php _e('غیرفعال', 'sodino'); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="rounded-2xl border border-gray-200 bg-gray-50 p-5 text-sm text-gray-500">
|
||||
<?php _e('در اینجا میتوانید فعالسازی خودکار تحلیل قیمت رقبا را مشاهده کنید؛ در حال حاضر این بخش در دست ساخت است.', 'sodino'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -55,8 +55,8 @@ $current_page = sanitize_text_field($_GET['page'] ?? 'sodino-dashboard');
|
||||
<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 href="<?php echo admin_url('admin.php?page=sodino-tools'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-tools' ? '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('تنظیمات', 'sodino'); ?>
|
||||
|
||||
@@ -52,8 +52,8 @@ $form_action_type = function_exists('sodino_old_input') ? sodino_old_input('acti
|
||||
<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 href="<?php echo admin_url('admin.php?page=sodino-tools'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-tools' ? '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('تنظیمات', 'sodino'); ?>
|
||||
|
||||
@@ -50,8 +50,8 @@ $current_page = sanitize_text_field($_GET['page'] ?? 'sodino-rules');
|
||||
<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 href="<?php echo admin_url('admin.php?page=sodino-tools'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-tools' ? '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('تنظیمات', 'sodino'); ?>
|
||||
|
||||
131
admin/views/tools.php
Normal file
131
admin/views/tools.php
Normal file
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
// Prevent direct access
|
||||
if (!defined('ABSPATH')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$current_page = sanitize_text_field($_GET['page'] ?? 'sodino-tools');
|
||||
$toolsData = $toolsData ?? [];
|
||||
$tables = $toolsData['tables'] ?? [];
|
||||
$actions = $toolsData['actions'] ?? [];
|
||||
$settings = $toolsData['settings'] ?? [];
|
||||
$db_version = $toolsData['db_version'] ?? '0';
|
||||
$expected_db_version = $toolsData['expected_db_version'] ?? SODINO_VERSION;
|
||||
$old_event_count = (int) ($toolsData['old_event_count'] ?? 0);
|
||||
$oldest_event = $toolsData['oldest_event'] ?? '';
|
||||
?>
|
||||
<div id="sodino-app" class="min-h-screen bg-gray-50" dir="rtl">
|
||||
<div class="bg-white border-b border-gray-200">
|
||||
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div class="py-6">
|
||||
<h1 class="text-3xl font-bold text-gray-900"><?php _e('سودینو', 'sodino'); ?></h1>
|
||||
<p class="mt-1 text-sm text-gray-500"><?php _e('ابزارهای نگهداری، سلامت و بهینهسازی افزونه', 'sodino'); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</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">
|
||||
<?php include SODINO_PLUGIN_DIR . 'admin/components/sidebar.php'; ?>
|
||||
|
||||
<main class="flex-1 min-w-0 space-y-6">
|
||||
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6">
|
||||
<div class="flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between">
|
||||
<div>
|
||||
<h2 class="text-2xl font-semibold text-gray-900"><?php _e('ابزارها و سلامت', 'sodino'); ?></h2>
|
||||
<p class="mt-2 text-gray-600"><?php _e('وضعیت دیتابیس، کش و دادههای تحلیلی سودینو را از اینجا مدیریت کنید.', 'sodino'); ?></p>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-3">
|
||||
<a href="<?php echo esc_url($actions['clear_cache'] ?? '#'); ?>" class="inline-flex items-center justify-center rounded-lg bg-blue-600 px-4 py-2 text-sm font-semibold text-white hover:bg-blue-700">
|
||||
<?php _e('پاکسازی کش', 'sodino'); ?>
|
||||
</a>
|
||||
<a href="<?php echo esc_url($actions['run_migrations'] ?? '#'); ?>" class="inline-flex items-center justify-center rounded-lg border border-gray-300 bg-white px-4 py-2 text-sm font-semibold text-gray-700 hover:bg-gray-50">
|
||||
<?php _e('بررسی دیتابیس', 'sodino'); ?>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-6 lg:grid-cols-3">
|
||||
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6">
|
||||
<p class="text-sm font-medium text-gray-500"><?php _e('نسخه دیتابیس', 'sodino'); ?></p>
|
||||
<div class="mt-3 flex items-center justify-between">
|
||||
<strong class="text-2xl text-gray-900"><?php echo esc_html($db_version); ?></strong>
|
||||
<?php if (version_compare($db_version, $expected_db_version, '>=')) : ?>
|
||||
<span class="rounded-full bg-green-50 px-3 py-1 text-xs font-semibold text-green-700"><?php _e('بهروز', 'sodino'); ?></span>
|
||||
<?php else : ?>
|
||||
<span class="rounded-full bg-yellow-50 px-3 py-1 text-xs font-semibold text-yellow-700"><?php _e('نیازمند بررسی', 'sodino'); ?></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6">
|
||||
<p class="text-sm font-medium text-gray-500"><?php _e('رویدادهای تحلیلی', 'sodino'); ?></p>
|
||||
<strong class="mt-3 block text-2xl text-gray-900"><?php echo esc_html(number_format_i18n($tables['events']['count'] ?? 0)); ?></strong>
|
||||
<p class="mt-2 text-sm text-gray-500">
|
||||
<?php echo $oldest_event ? esc_html(sprintf(__('قدیمیترین رویداد: %s', 'sodino'), mysql2date('Y/m/d H:i', $oldest_event))) : esc_html__('هنوز رویدادی ثبت نشده است.', 'sodino'); ?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6">
|
||||
<p class="text-sm font-medium text-gray-500"><?php _e('وضعیت قابلیتها', 'sodino'); ?></p>
|
||||
<div class="mt-3 flex flex-wrap gap-2">
|
||||
<span class="rounded-full px-3 py-1 text-xs font-semibold <?php echo !empty($settings['pricing_enabled']) ? 'bg-green-50 text-green-700' : 'bg-gray-100 text-gray-600'; ?>"><?php _e('قیمتگذاری', 'sodino'); ?></span>
|
||||
<span class="rounded-full px-3 py-1 text-xs font-semibold <?php echo !empty($settings['upsell_enabled']) ? 'bg-green-50 text-green-700' : 'bg-gray-100 text-gray-600'; ?>"><?php _e('آپسل', 'sodino'); ?></span>
|
||||
<span class="rounded-full px-3 py-1 text-xs font-semibold <?php echo !empty($settings['banner_enabled']) ? 'bg-green-50 text-green-700' : 'bg-gray-100 text-gray-600'; ?>"><?php _e('بنر', 'sodino'); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-lg shadow-sm border border-gray-200 overflow-hidden">
|
||||
<div class="px-6 py-5 border-b border-gray-200">
|
||||
<h3 class="text-lg font-semibold text-gray-900"><?php _e('جدولهای سودینو', 'sodino'); ?></h3>
|
||||
</div>
|
||||
<div class="overflow-x-auto">
|
||||
<table class="min-w-full divide-y divide-gray-200 text-right text-sm">
|
||||
<thead class="bg-gray-50 text-gray-500">
|
||||
<tr>
|
||||
<th class="px-6 py-3 font-medium"><?php _e('بخش', 'sodino'); ?></th>
|
||||
<th class="px-6 py-3 font-medium"><?php _e('جدول', 'sodino'); ?></th>
|
||||
<th class="px-6 py-3 font-medium"><?php _e('تعداد رکورد', 'sodino'); ?></th>
|
||||
<th class="px-6 py-3 font-medium"><?php _e('وضعیت', 'sodino'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-200 bg-white text-gray-700">
|
||||
<?php foreach ($tables as $table) : ?>
|
||||
<tr>
|
||||
<td class="px-6 py-4 font-medium text-gray-900"><?php echo esc_html($table['label']); ?></td>
|
||||
<td class="px-6 py-4"><code><?php echo esc_html($table['name']); ?></code></td>
|
||||
<td class="px-6 py-4"><?php echo esc_html(number_format_i18n($table['count'])); ?></td>
|
||||
<td class="px-6 py-4">
|
||||
<?php if (!empty($table['exists'])) : ?>
|
||||
<span class="rounded-full bg-green-50 px-3 py-1 text-xs font-semibold text-green-700"><?php _e('موجود', 'sodino'); ?></span>
|
||||
<?php else : ?>
|
||||
<span class="rounded-full bg-red-50 px-3 py-1 text-xs font-semibold text-red-700"><?php _e('نیازمند ساخت', 'sodino'); ?></span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6">
|
||||
<div class="flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between">
|
||||
<div>
|
||||
<h3 class="text-lg font-semibold text-gray-900"><?php _e('پاکسازی دادههای قدیمی', 'sodino'); ?></h3>
|
||||
<p class="mt-2 text-sm text-gray-500">
|
||||
<?php echo esc_html(sprintf(__('رویدادهای قدیمیتر از ۹۰ روز آماده حذف: %s', 'sodino'), number_format_i18n($old_event_count))); ?>
|
||||
</p>
|
||||
</div>
|
||||
<a href="<?php echo esc_url($actions['prune_events'] ?? '#'); ?>" onclick="return confirm('<?php echo esc_js(__('رویدادهای قدیمی حذف شوند؟ این عملیات قابل بازگشت نیست.', 'sodino')); ?>');" class="inline-flex items-center justify-center rounded-lg border border-red-200 bg-red-50 px-4 py-2 text-sm font-semibold text-red-700 hover:bg-red-100">
|
||||
<?php _e('حذف رویدادهای قدیمی', 'sodino'); ?>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -69,8 +69,8 @@ $product_categories = get_terms([
|
||||
<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 href="<?php echo admin_url('admin.php?page=sodino-tools'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-tools' ? '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('تنظیمات', 'sodino'); ?>
|
||||
|
||||
@@ -48,8 +48,8 @@ $current_page = sanitize_text_field($_GET['page'] ?? 'sodino-upsells');
|
||||
<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 href="<?php echo admin_url('admin.php?page=sodino-tools'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-tools' ? '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('تنظیمات', 'sodino'); ?>
|
||||
|
||||
Reference in New Issue
Block a user