PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.3.28
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.3.28
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.3.28, at app/Helpers/AdminHelper.php

229 lines 7.9 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 (isset($_GET['custom-editor']) && $_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 // 'product_pricing' => [
44 // 'label' => __('Pricing', 'fluent-cart'),
45 // 'link' => $baseUrl . 'products/' . $productId . '/pricing'
46 // ],
47 // 'product_integrations' => [
48 // 'label' => __('Integrations', 'fluent-cart'),
49 // 'link' => $baseUrl . 'products/' . $productId . '/integrations'
50 // ]
51 ], [
52 'product_id' => $productId,
53 'base_url' => $baseUrl
54 ]);
55
56 $request = App::request()->all();
57 if (isset($request['action']) && $request['action'] == 'edit') {
58 $menuItems['product_details'] = [
59 'label' => __('Edit Pricing', 'fluent-cart'),
60 'link' => admin_url('admin.php?page=fluent-cart#/products/' . $productId)
61 ];
62 }
63
64
65 $productName = $product->post_title;
66
67 $data = [
68 'menu_items' => $menuItems,
69 'active' => $activeMenu,
70 'products_url' => $baseUrl . 'products',
71 'product_name' => $productName,
72 'status' => $product->post_status,
73 'product_id' => $productId
74 ];
75
76 if ($echo) {
77 App::make('view')->render('admin.admin_product_menu', $data);
78 } else {
79 return (string)App::make('view')->make('admin.admin_product_menu', $data);
80 }
81 }
82
83 private static function getProductsMenu($baseUrl)
84 {
85 $menu = [
86 'label' => __('Products', 'fluent-cart'),
87 'link' => $baseUrl . 'products',
88 'permission' => ['products/view']
89 ];
90
91 if (ModuleSettings::isActive('stock_management') &&
92 ModuleSettings::getSettings('stock_management.enable_advanced_inventory') === 'yes') {
93 $menu['children'] = [
94 'product_inventory' => [
95 'label' => __('Inventory', 'fluent-cart'),
96 'link' => $baseUrl . 'products/inventory',
97 'permission' => ['products/view']
98 ]
99 ];
100 }
101
102 return $menu;
103 }
104
105 public static function getAdminMenu($echo = false, $activeNav = '')
106 {
107 $menuItems = self::getMenuItems();
108
109 if ($echo) {
110 App::make('view')->render('admin.admin_menu', [
111 'menu_items' => $menuItems,
112 'active' => $activeNav
113 ]);
114 } else {
115 return App::make('view')->make('admin.admin_menu', [
116 'menu_items' => $menuItems,
117 'active' => $activeNav
118 ]);
119 }
120 }
121
122 public static function getMenuItems($withSettings = false)
123 {
124 $baseUrl = apply_filters('fluent_cart/admin_base_url', admin_url('admin.php?page=fluent-cart#/'), []);
125 $menuItems = apply_filters('fluent_cart/global_admin_menu_items', [
126 'dashboard' => [
127 'label' => __('Dashboard', 'fluent-cart'),
128 'link' => $baseUrl
129 ],
130 'orders' => [
131 'label' => __('Orders', 'fluent-cart'),
132 'link' => $baseUrl . 'orders',
133 'permission' => ['orders/view']
134 ],
135 'customers' => [
136 'label' => __('Customers', 'fluent-cart'),
137 'link' => $baseUrl . 'customers',
138 'permission' => ['customers/view', 'customers/manage']
139 ],
140 'products' => self::getProductsMenu($baseUrl),
141 'subscriptions' => [
142 'label' => __('Subscriptions', 'fluent-cart'),
143 'link' => $baseUrl . 'subscriptions',
144 'permission' => ['subscriptions/view']
145 ],
146 'reports' => [
147 'label' => __('Reports', 'fluent-cart'),
148 'link' => $baseUrl . 'reports/overview',
149 'permission' => ['reports/view']
150 ],
151 ], ['base_url' => $baseUrl]);
152
153 $moreItems = apply_filters('fluent_cart/global_admin_menu_more_items', array_filter([
154 'integrations' => [
155 'label' => __('Integrations', 'fluent-cart'),
156 'link' => $baseUrl . 'integrations',
157 'permission' => ['is_super_admin'],
158 ],
159 'order_bump' => App::isProActive() && ModuleSettings::isActive('order_bump') ? [
160 'label' => __('Order Bump', 'fluent-cart'),
161 'link' => $baseUrl . 'order_bump',
162 ] : false,
163 'coupons' => [
164 'label' => __('Coupons', 'fluent-cart'),
165 'link' => $baseUrl . 'coupons',
166 ],
167 'taxes' => TaxModule::isTaxEnabled() ? [
168 'label' => __('Taxes', 'fluent-cart'),
169 'link' => $baseUrl . 'taxes',
170 'permission' => ['store/settings', 'store/sensitive'],
171 ] : false,
172 'categories' => [
173 'label' => __('Categories', 'fluent-cart'),
174 'link' => admin_url('edit-tags.php?taxonomy=product-categories&post_type=fluent-products')
175 ],
176 'brands' => [
177 'label' => __('Brands', 'fluent-cart'),
178 'link' => admin_url('edit-tags.php?taxonomy=product-brands&post_type=fluent-products')
179 ],
180 'logs' => [
181 'label' => __('Logs', 'fluent-cart'),
182 'link' => $baseUrl . 'logs',
183 ],
184 ]), ['base_url' => $baseUrl]);
185
186 if ($withSettings) {
187 $menuItems['settings'] = [
188 'label' => __('Settings', 'fluent-cart'),
189 'link' => $baseUrl . 'settings/store-settings',
190 'permission' => ['store/settings', 'store/sensitive'],
191 'icon' => 'fluent-settings'
192 ];
193 }
194
195 $menuItems['more'] = [
196 'label' => __('More', 'fluent-cart'),
197 'link' => '#',
198 'children' => $moreItems,
199 ];
200
201
202 return $menuItems;
203 }
204
205 public static function pushGlobalAdminAssets()
206 {
207 $app = App::getInstance();
208
209 $assets = $app['url.assets'];
210
211 $slug = $app->config->get('app.slug');
212
213 wp_enqueue_style(
214 $slug . '_global_admin_app', $assets . 'admin/global_admin.css',
215 [],
216 FLUENTCART_VERSION,
217 );
218 }
219
220
221 }
222
223
224
225
226
227
228
229