| @@ -14,9 +14,9 @@ | ||
| 14 | 14 | { |
| 15 | 15 | public static function getProductMenu($product, $echo = false, $activeMenu = '') |
| 16 | 16 | { |
| 17 | 17 | // Skip rendering menu when custom editor modal is open |
| 18 | - if (isset($_GET['custom-editor']) && $_GET['custom-editor'] == 'true') { | |
| 18 | + if (App::request()->get('custom-editor') === 'true') { | |
| 19 | 19 | return ''; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | if (!$product instanceof Product) { |
| @@ -39,16 +39,8 @@ | ||
| 39 | 39 | 'product_integrations' => [ |
| 40 | 40 | 'label' => __('Integrations', 'fluent-cart'), |
| 41 | 41 | 'link' => $baseUrl . 'products/' . $productId . '/integrations' |
| 42 | 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 | 43 | ], [ |
| 52 | 44 | 'product_id' => $productId, |
| 53 | 45 | 'base_url' => $baseUrl |
| 54 | 46 | ]); |
| @@ -53,9 +45,9 @@ | ||
| 53 | 45 | 'base_url' => $baseUrl |
| 54 | 46 | ]); |
| 55 | 47 | |
| 56 | 48 | $request = App::request()->all(); |
| 57 | - if (isset($request['action']) && $request['action'] == 'edit') { | |
| 49 | + if (isset($request['action']) && $request['action'] === 'edit') { | |
| 58 | 50 | $menuItems['product_details'] = [ |
| 59 | 51 | 'label' => __('Edit Pricing', 'fluent-cart'), |
| 60 | 52 | 'link' => admin_url('admin.php?page=fluent-cart#/products/' . $productId) |
| 61 | 53 | ]; |
| @@ -72,13 +64,13 @@ | ||
| 72 | 64 | 'status' => $product->post_status, |
| 73 | 65 | 'product_id' => $productId |
| 74 | 66 | ]; |
| 75 | 67 | |
| 76 | - if ($echo) { | |
| 77 | - App::make('view')->render('admin.admin_product_menu', $data); | |
| 78 | - } else { | |
| 68 | + if (!$echo) { | |
| 79 | 69 | return (string)App::make('view')->make('admin.admin_product_menu', $data); |
| 80 | 70 | } |
| 71 | + | |
| 72 | + App::make('view')->render('admin.admin_product_menu', $data); | |
| 81 | 73 | } |
| 82 | 74 | |
| 83 | 75 | private static function getProductsMenu($baseUrl) |
| 84 | 76 | { |
| @@ -87,24 +79,59 @@ | ||
| 87 | 79 | 'link' => $baseUrl . 'products', |
| 88 | 80 | 'permission' => ['products/view'] |
| 89 | 81 | ]; |
| 90 | 82 | |
| 83 | + $children = []; | |
| 84 | + | |
| 85 | + // The parent link is not reachable on touch (the tap opens the dropdown), | |
| 86 | + // and the off-canvas menu renders children only — so list it as a child too. | |
| 87 | + $children['all_products'] = [ | |
| 88 | + 'label' => __('All Products', 'fluent-cart'), | |
| 89 | + 'link' => $baseUrl . 'products', | |
| 90 | + 'permission' => ['products/view'] | |
| 91 | + ]; | |
| 92 | + | |
| 93 | + // Attributes power the advanced-variations feature. | |
| 94 | + $children['product_attributes'] = [ | |
| 95 | + 'label' => __('Attributes', 'fluent-cart'), | |
| 96 | + 'link' => $baseUrl . 'products/attributes', | |
| 97 | + 'permission' => ['products/view'] | |
| 98 | + ]; | |
| 99 | + | |
| 100 | + // Inventory only when the advanced-inventory toggle is on. | |
| 91 | 101 | if (ModuleSettings::isActive('stock_management') && |
| 92 | 102 | 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 | - ] | |
| 103 | + $children['product_inventory'] = [ | |
| 104 | + 'label' => __('Inventory', 'fluent-cart'), | |
| 105 | + 'link' => $baseUrl . 'products/inventory', | |
| 106 | + 'permission' => ['products/view'] | |
| 99 | 107 | ]; |
| 100 | 108 | } |
| 101 | 109 | |
| 110 | + $menu['children'] = $children; | |
| 111 | + | |
| 102 | 112 | return $menu; |
| 103 | 113 | } |
| 104 | 114 | |
| 105 | 115 | public static function getAdminMenu($echo = false, $activeNav = '') |
| 106 | 116 | { |
| 117 | + $menuItems = self::getMenuItems(); | |
| 118 | + | |
| 119 | + if (!$echo) { | |
| 120 | + return App::make('view')->make('admin.admin_menu', [ | |
| 121 | + 'menu_items' => $menuItems, | |
| 122 | + 'active' => $activeNav | |
| 123 | + ]); | |
| 124 | + } | |
| 125 | + | |
| 126 | + App::make('view')->render('admin.admin_menu', [ | |
| 127 | + 'menu_items' => $menuItems, | |
| 128 | + 'active' => $activeNav | |
| 129 | + ]); | |
| 130 | + } | |
| 131 | + | |
| 132 | + public static function getMenuItems($withSettings = false) | |
| 133 | + { | |
| 107 | 134 | $baseUrl = apply_filters('fluent_cart/admin_base_url', admin_url('admin.php?page=fluent-cart#/'), []); |
| 108 | 135 | $menuItems = apply_filters('fluent_cart/global_admin_menu_items', [ |
| 109 | 136 | 'dashboard' => [ |
| 110 | 137 | 'label' => __('Dashboard', 'fluent-cart'), |
| @@ -132,15 +159,8 @@ | ||
| 132 | 159 | 'permission' => ['reports/view'] |
| 133 | 160 | ], |
| 134 | 161 | ], ['base_url' => $baseUrl]); |
| 135 | 162 | |
| 136 | - $menuItems['more'] = [ | |
| 137 | - 'label' => __('More', 'fluent-cart'), | |
| 138 | - 'link' => '#', | |
| 139 | - 'children' => [] | |
| 140 | - ]; | |
| 141 | - | |
| 142 | - | |
| 143 | 163 | $moreItems = apply_filters('fluent_cart/global_admin_menu_more_items', array_filter([ |
| 144 | 164 | 'integrations' => [ |
| 145 | 165 | 'label' => __('Integrations', 'fluent-cart'), |
| 146 | 166 | 'link' => $baseUrl . 'integrations', |
| @@ -172,21 +192,25 @@ | ||
| 172 | 192 | 'link' => $baseUrl . 'logs', |
| 173 | 193 | ], |
| 174 | 194 | ]), ['base_url' => $baseUrl]); |
| 175 | 195 | |
| 176 | - $menuItems['more']['children'] = $moreItems; | |
| 196 | + if ($withSettings) { | |
| 197 | + $menuItems['settings'] = [ | |
| 198 | + 'label' => __('Settings', 'fluent-cart'), | |
| 199 | + 'link' => $baseUrl . 'settings/store-settings', | |
| 200 | + 'permission' => ['store/settings', 'store/sensitive'], | |
| 201 | + 'icon' => 'fluent-settings' | |
| 202 | + ]; | |
| 203 | + } | |
| 177 | 204 | |
| 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 | - } | |
| 205 | + $menuItems['more'] = [ | |
| 206 | + 'label' => __('More', 'fluent-cart'), | |
| 207 | + 'link' => '#', | |
| 208 | + 'children' => $moreItems, | |
| 209 | + ]; | |
| 210 | + | |
| 211 | + | |
| 212 | + return $menuItems; | |
| 189 | 213 | } |
| 190 | 214 | |
| 191 | 215 | public static function pushGlobalAdminAssets() |
| 192 | 216 | { |
| @@ -201,14 +225,6 @@ | ||
| 201 | 225 | [], |
| 202 | 226 | FLUENTCART_VERSION, |
| 203 | 227 | ); |
| 204 | 228 | } |
| 205 | - | |
| 206 | - | |
| 207 | 229 | } |
| 208 | - | |
| 209 | - | |
| 210 | - | |
| 211 | - | |
| 212 | - | |
| 213 | - | |
| 214 | 230 | |