refactor(Core): optimize admin panel and refactor
This commit is contained in:
@@ -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; ?>
|
||||
|
||||
Reference in New Issue
Block a user