From c54530d8dab8088603cdced2e33dca305b5769ee Mon Sep 17 00:00:00 2001 From: Kazem Alghasi Date: Sat, 3 Oct 2026 07:01:54 +0330 Subject: [PATCH] refactor(admin): optimize dashboard layout and enhance sidebar UX Refactor the Filament admin dashboard by decoupling the recent shipments logic into a dedicated widget and improving the sidebar navigation experience. Additionally, implement several improvements to the WordPress theme for better client-side usability. Laravel/Filament: - Extract `RecentShipmentsWidget` from `DashboardInfoWidget` to improve modularization and dashboard performance. - Update widget sorting and layout to accommodate the new structure. - Inject custom CSS and Alpine.js logic into the admin head to provide sidebar group toggling and a "collapse all" utility. - Improve sidebar group label visibility and hover states. WordPress: - Implement `ifnex_login_url()` to support Polylang-aware, language-specific login pages. - Hide the WordPress admin bar for non-administrator users to provide a cleaner client interface. - Add conditional rendering for the registration link in the login template based on WordPress user registration settings. --- .../wp-content/themes/ifnex/functions.php | 25 ++++ .../wp-content/themes/ifnex/header.php | 2 +- .../themes/ifnex/template-login.php | 3 + .../Filament/Widgets/DashboardInfoWidget.php | 80 ++--------- .../Filament/Widgets/ExchangeRateWidget.php | 2 +- .../Widgets/RecentShipmentsWidget.php | 73 ++++++++++ .../app/Filament/Widgets/WalletStats.php | 2 +- .../Providers/Filament/AdminPanelProvider.php | 1 + .../views/filament/hooks/head.blade.php | 130 +++++++++++++++++- .../filament/widgets/dashboard-info.blade.php | 105 +++----------- .../widgets/recent-shipments.blade.php | 58 ++++++++ 11 files changed, 327 insertions(+), 154 deletions(-) create mode 100644 04_Laravel/app/Filament/Widgets/RecentShipmentsWidget.php create mode 100644 04_Laravel/resources/views/filament/widgets/recent-shipments.blade.php diff --git a/03_WordPress/wp-content/themes/ifnex/functions.php b/03_WordPress/wp-content/themes/ifnex/functions.php index bc6d5f9..74d6035 100644 --- a/03_WordPress/wp-content/themes/ifnex/functions.php +++ b/03_WordPress/wp-content/themes/ifnex/functions.php @@ -30,6 +30,15 @@ function ifnex_theme_setup() { } add_action('after_setup_theme', 'ifnex_theme_setup'); +// ─── مخفی‌کردن نوار مدیریت وردپرس برای غیرمدیرها ────── +// مشتریان نباید نوار پیش‌فرض ادمین را در پنل خود ببینند +add_filter('show_admin_bar', function ($show) { + if (current_user_can('administrator')) { + return $show; + } + return false; +}); + // ─── بارگذاری فایل‌های کمکی ────────────────────────── $ifnex_includes = ['/inc/customizer.php']; foreach ($ifnex_includes as $file) { @@ -68,6 +77,22 @@ function ifnex_text_direction() { return ifnex_is_english() ? 'ltr' : 'rtl'; } +// ─── آدرس صفحه لاگین سازگار با زبان جاری (Polylang) ─── +// صفحه EN با slug یگانه login-en ساخته شده تا با صفحه FA تداخل canonical رخ ندهد +function ifnex_login_url() { + $page = get_page_by_path('login'); + if (!$page) { + return home_url('/login/'); + } + if (function_exists('pll_get_post')) { + $translated = pll_get_post($page->ID, ifnex_get_current_lang()); + if ($translated) { + return get_permalink($translated); + } + } + return get_permalink($page->ID); +} + // ─── سوئیچر زبان (سازگار با Polylang) ─────────────── function ifnex_language_switcher() { if (function_exists('pll_the_languages')) { diff --git a/03_WordPress/wp-content/themes/ifnex/header.php b/03_WordPress/wp-content/themes/ifnex/header.php index 4d3fc6e..4aa235a 100644 --- a/03_WordPress/wp-content/themes/ifnex/header.php +++ b/03_WordPress/wp-content/themes/ifnex/header.php @@ -16,7 +16,7 @@ if (is_user_logged_in()) { $login_btn_text = ifnex_t('پنل کاربری', 'Dashboard'); $login_btn_class = 'btn btn-primary'; } else { - $login_btn_url = esc_url(home_url('/login/')); + $login_btn_url = esc_url(ifnex_login_url()); $login_btn_text = ifnex_t('ورود مشتریان', 'Client Login'); $login_btn_class = 'btn btn-secondary'; } diff --git a/03_WordPress/wp-content/themes/ifnex/template-login.php b/03_WordPress/wp-content/themes/ifnex/template-login.php index f103e99..861250e 100644 --- a/03_WordPress/wp-content/themes/ifnex/template-login.php +++ b/03_WordPress/wp-content/themes/ifnex/template-login.php @@ -142,10 +142,13 @@ get_header();