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

208 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 (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 public static function getAdminMenu($echo = false, $activeNav = '')
84 {
85 $baseUrl = apply_filters('fluent_cart/admin_base_url', admin_url('admin.php?page=fluent-cart#/'), []);
86 $menuItems = apply_filters('fluent_cart/global_admin_menu_items', [
87 'dashboard' => [
88 'label' => __('Dashboard', 'fluent-cart'),
89 'link' => $baseUrl
90 ],
91 'orders' => [
92 'label' => __('Orders', 'fluent-cart'),
93 'link' => $baseUrl . 'orders',
94 'permission' => ['orders/view']
95 ],
96 'customers' => [
97 'label' => __('Customers', 'fluent-cart'),
98 'link' => $baseUrl . 'customers',
99 'permission' => ['customers/view', 'customers/manage']
100 ],
101 'products' => [
102 'label' => __('Products', 'fluent-cart'),
103 'link' => $baseUrl . 'products',
104 'permission' => ['products/view'],
105 'children' => [
106 'all_products' => [
107 'label' => __('All Products', 'fluent-cart'),
108 'link' => $baseUrl . 'products'
109 ],
110 'product_inventory' => [
111 'label' => __('Inventory', 'fluent-cart'),
112 'link' => $baseUrl . 'products/inventory',
113 'permission' => ['products/view']
114 ]
115 ]
116 ],
117 'subscriptions' => [
118 'label' => __('Subscriptions', 'fluent-cart'),
119 'link' => $baseUrl . 'subscriptions',
120 'permission' => ['subscriptions/view']
121 ],
122 'reports' => [
123 'label' => __('Reports', 'fluent-cart'),
124 'link' => $baseUrl . 'reports/overview',
125 'permission' => ['reports/view']
126 ],
127 ], ['base_url' => $baseUrl]);
128
129 $menuItems['more'] = [
130 'label' => __('More', 'fluent-cart'),
131 'link' => '#',
132 'children' => []
133 ];
134
135
136 $moreItems = apply_filters('fluent_cart/global_admin_menu_more_items', array_filter([
137 'integrations' => [
138 'label' => __('Integrations', 'fluent-cart'),
139 'link' => $baseUrl . 'integrations',
140 'permission' => ['is_super_admin'],
141 ],
142 'order_bump' => App::isProActive() && ModuleSettings::isActive('order_bump') ? [
143 'label' => __('Order Bump', 'fluent-cart'),
144 'link' => $baseUrl . 'order_bump',
145 ] : false,
146 'coupons' => [
147 'label' => __('Coupons', 'fluent-cart'),
148 'link' => $baseUrl . 'coupons',
149 ],
150 'taxes' => TaxModule::isTaxEnabled() ? [
151 'label' => __('Taxes', 'fluent-cart'),
152 'link' => $baseUrl . 'taxes',
153 'permission' => ['store/settings', 'store/sensitive'],
154 ] : false,
155 'categories' => [
156 'label' => __('Categories', 'fluent-cart'),
157 'link' => admin_url('edit-tags.php?taxonomy=product-categories&post_type=fluent-products')
158 ],
159 'brands' => [
160 'label' => __('Brands', 'fluent-cart'),
161 'link' => admin_url('edit-tags.php?taxonomy=product-brands&post_type=fluent-products')
162 ],
163 'logs' => [
164 'label' => __('Logs', 'fluent-cart'),
165 'link' => $baseUrl . 'logs',
166 ],
167 ]), ['base_url' => $baseUrl]);
168
169 $menuItems['more']['children'] = $moreItems;
170
171 if ($echo) {
172 App::make('view')->render('admin.admin_menu', [
173 'menu_items' => $menuItems,
174 'active' => $activeNav
175 ]);
176 } else {
177 return App::make('view')->make('admin.admin_menu', [
178 'menu_items' => $menuItems,
179 'active' => $activeNav
180 ]);
181 }
182 }
183
184 public static function pushGlobalAdminAssets()
185 {
186 $app = App::getInstance();
187
188 $assets = $app['url.assets'];
189
190 $slug = $app->config->get('app.slug');
191
192 wp_enqueue_style(
193 $slug . '_global_admin_app', $assets . 'admin/global_admin.css',
194 [],
195 FLUENTCART_VERSION,
196 );
197 }
198
199
200 }
201
202
203
204
205
206
207
208