PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.4.1
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.4.1
1.6.6 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 All 49 releases
fluent-cart / app / Helpers / AdminHelper.php

AdminHelper.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.4.1, at app/Helpers/AdminHelper.php

213 lines 7.4 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\Helpers;
4
5 use FluentCart\Api\ModuleSettings;
6 use FluentCart\App\App;
7 use FluentCart\App\Http\Controllers\ProductController;
8 use FluentCart\App\Models\Product;
9 use FluentCart\App\Modules\Tax\TaxModule;
10 use FluentCart\App\Services\Filter\OrderFilter;
11 use FluentCart\App\Services\URL;
12
13 class AdminHelper
14 {
15 public static function getProductMenu($product, $echo = false, $activeMenu = '')
16 {
17 // Skip rendering menu when custom editor modal is open
18 if (App::request()->get('custom-editor') === 'true') {
19 return '';
20 }
21
22 if (!$product instanceof Product) {
23 $product = Product::query()->find($product);
24 }
25
26 $productId = $product->ID;
27
28 $baseUrl = apply_filters('fluent_cart/admin_base_url', admin_url('admin.php?page=fluent-cart#/'), []);
29
30 $menuItems = apply_filters('fluent_cart/product_admin_items', [
31 'product_edit' => [
32 'label' => __('Edit Product', 'fluent-cart'),
33 'link' => $baseUrl . 'products/' . $productId
34 ],
35 'product_upgrade_paths' => [
36 'label' => __('Upgrade Paths', 'fluent-cart'),
37 'link' => $baseUrl . 'products/' . $productId . '/upgrade-paths'
38 ],
39 'product_integrations' => [
40 'label' => __('Integrations', 'fluent-cart'),
41 'link' => $baseUrl . 'products/' . $productId . '/integrations'
42 ],
43 ], [
44 'product_id' => $productId,
45 'base_url' => $baseUrl
46 ]);
47
48 $request = App::request()->all();
49 if (isset($request['action']) && $request['action'] === 'edit') {
50 $menuItems['product_details'] = [
51 'label' => __('Edit Pricing', 'fluent-cart'),
52 'link' => admin_url('admin.php?page=fluent-cart#/products/' . $productId)
53 ];
54 }
55
56
57 $productName = $product->post_title;
58
59 $data = [
60 'menu_items' => $menuItems,
61 'active' => $activeMenu,
62 'products_url' => $baseUrl . 'products',
63 'product_name' => $productName,
64 'status' => $product->post_status,
65 'product_id' => $productId
66 ];
67
68 if (!$echo) {
69 return (string)App::make('view')->make('admin.admin_product_menu', $data);
70 }
71
72 App::make('view')->render('admin.admin_product_menu', $data);
73 }
74
75 private static function getProductsMenu($baseUrl)
76 {
77 $menu = [
78 'label' => __('Products', 'fluent-cart'),
79 'link' => $baseUrl . 'products',
80 'permission' => ['products/view']
81 ];
82
83 if (ModuleSettings::isActive('stock_management') &&
84 ModuleSettings::getSettings('stock_management.enable_advanced_inventory') === 'yes') {
85 $menu['children'] = [
86 'product_inventory' => [
87 'label' => __('Inventory', 'fluent-cart'),
88 'link' => $baseUrl . 'products/inventory',
89 'permission' => ['products/view']
90 ]
91 ];
92 }
93
94 return $menu;
95 }
96
97 public static function getAdminMenu($echo = false, $activeNav = '')
98 {
99 $menuItems = self::getMenuItems();
100
101 if (!$echo) {
102 return App::make('view')->make('admin.admin_menu', [
103 'menu_items' => $menuItems,
104 'active' => $activeNav
105 ]);
106 }
107
108 App::make('view')->render('admin.admin_menu', [
109 'menu_items' => $menuItems,
110 'active' => $activeNav
111 ]);
112 }
113
114 public static function getMenuItems($withSettings = false)
115 {
116 $baseUrl = apply_filters('fluent_cart/admin_base_url', admin_url('admin.php?page=fluent-cart#/'), []);
117 $menuItems = apply_filters('fluent_cart/global_admin_menu_items', [
118 'dashboard' => [
119 'label' => __('Dashboard', 'fluent-cart'),
120 'link' => $baseUrl
121 ],
122 'orders' => [
123 'label' => __('Orders', 'fluent-cart'),
124 'link' => $baseUrl . 'orders',
125 'permission' => ['orders/view']
126 ],
127 'customers' => [
128 'label' => __('Customers', 'fluent-cart'),
129 'link' => $baseUrl . 'customers',
130 'permission' => ['customers/view', 'customers/manage']
131 ],
132 'products' => self::getProductsMenu($baseUrl),
133 'subscriptions' => [
134 'label' => __('Subscriptions', 'fluent-cart'),
135 'link' => $baseUrl . 'subscriptions',
136 'permission' => ['subscriptions/view']
137 ],
138 'reports' => [
139 'label' => __('Reports', 'fluent-cart'),
140 'link' => $baseUrl . 'reports/overview',
141 'permission' => ['reports/view']
142 ],
143 ], ['base_url' => $baseUrl]);
144
145 $moreItems = apply_filters('fluent_cart/global_admin_menu_more_items', array_filter([
146 'integrations' => [
147 'label' => __('Integrations', 'fluent-cart'),
148 'link' => $baseUrl . 'integrations',
149 'permission' => ['is_super_admin'],
150 ],
151 'order_bump' => App::isProActive() && ModuleSettings::isActive('order_bump') ? [
152 'label' => __('Order Bump', 'fluent-cart'),
153 'link' => $baseUrl . 'order_bump',
154 ] : false,
155 'coupons' => [
156 'label' => __('Coupons', 'fluent-cart'),
157 'link' => $baseUrl . 'coupons',
158 ],
159 'taxes' => TaxModule::isTaxEnabled() ? [
160 'label' => __('Taxes', 'fluent-cart'),
161 'link' => $baseUrl . 'taxes',
162 'permission' => ['store/settings', 'store/sensitive'],
163 ] : false,
164 'categories' => [
165 'label' => __('Categories', 'fluent-cart'),
166 'link' => admin_url('edit-tags.php?taxonomy=product-categories&post_type=fluent-products')
167 ],
168 'brands' => [
169 'label' => __('Brands', 'fluent-cart'),
170 'link' => admin_url('edit-tags.php?taxonomy=product-brands&post_type=fluent-products')
171 ],
172 'logs' => [
173 'label' => __('Logs', 'fluent-cart'),
174 'link' => $baseUrl . 'logs',
175 ],
176 ]), ['base_url' => $baseUrl]);
177
178 if ($withSettings) {
179 $menuItems['settings'] = [
180 'label' => __('Settings', 'fluent-cart'),
181 'link' => $baseUrl . 'settings/store-settings',
182 'permission' => ['store/settings', 'store/sensitive'],
183 'icon' => 'fluent-settings'
184 ];
185 }
186
187 $menuItems['more'] = [
188 'label' => __('More', 'fluent-cart'),
189 'link' => '#',
190 'children' => $moreItems,
191 ];
192
193
194 return $menuItems;
195 }
196
197 public static function pushGlobalAdminAssets()
198 {
199 $app = App::getInstance();
200
201 $assets = $app['url.assets'];
202
203 $slug = $app->config->get('app.slug');
204
205 wp_enqueue_style(
206 $slug . '_global_admin_app', $assets . 'admin/global_admin.css',
207 [],
208 FLUENTCART_VERSION,
209 );
210 }
211 }
212
213