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

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

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