PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.3.23
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.3.23
1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 trunk All 48 releases
fluent-cart / app / Hooks / Handlers / AdminMenuBarHandler.php

AdminMenuBarHandler.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.3.23, at app/Hooks/Handlers/AdminMenuBarHandler.php

82 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentCart\App\Hooks\Handlers;
4
5 use FluentCart\App\Services\URL;
6 use FluentCart\App\Vite;
7 use FluentCart\Api\StoreSettings;
8 use FluentCart\App\Services\Permission\PermissionManager;
9
10 class AdminMenuBarHandler
11 {
12
13 public function register()
14 {
15 add_action('admin_bar_menu', [$this, 'init'], 100);
16 }
17
18 public function init($wp_admin_bar)
19 {
20 $isSuperAdmin = PermissionManager::userCan('is_super_admin');
21 if (!$isSuperAdmin) {
22 return;
23 }
24
25 $storeSettings = new StoreSettings();
26 $id = 'fluent_cart_live_mode';
27 $menuTitle = __('Live Mode', 'fluent-cart');
28 $color = 'color: #189877;';
29
30 if ($storeSettings->get('order_mode') === 'test') {
31 $id = 'fluent_cart_test_mode';
32 $menuTitle = __('Test Mode', 'fluent-cart');
33 $color = 'color: #F58E07;';
34 }
35
36
37 $logo = Vite::getAssetUrl('images/logo/logo-white.svg');
38 $title = '<div style="display: inline-flex;align-items: center;' . esc_attr($color) . '"><img src="' . esc_url($logo ?? '') . '" alt="Logo" style="width:20px; height:16px; vertical-align:middle; margin-right:6px;">' . $menuTitle . '</div>';
39
40
41 // Parent node (with class)
42
43
44 $wp_admin_bar->add_node([
45 'id' => $id,
46 'title' => $title,
47 'href' => false, // disables direct link to act as dropdown
48 'meta' => [
49 'class' => $id,
50 'title' => __('FluentCart', 'fluent-cart')
51 ]
52 ]);
53
54 // Child: Store Settings
55 $wp_admin_bar->add_node([
56 'id' => $id . '_orders',
57 'title' => __('View Orders', 'fluent-cart'),
58 'href' => URL::getDashboardUrl('orders'),
59 'parent' => $id
60 ]);
61
62 $wp_admin_bar->add_node([
63 'id' => $id . '_products',
64 'title' => __('View Products', 'fluent-cart'),
65 'href' => URL::getDashboardUrl('products'),
66 'parent' => $id
67 ]);
68
69 $wp_admin_bar->add_node([
70 'id' => $id . '_settings',
71 'title' => __('Store Settings', 'fluent-cart'),
72 'href' => URL::getDashboardUrl('settings/store-settings/'),
73 'parent' => $id
74 ]);
75
76 // Child: View Orders
77
78 }
79
80 }
81
82