| @@ -1,11 +1,6 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -// no direct access allowed | |
| 4 | -if (!defined('ABSPATH')) { | |
| 5 | - exit; | |
| 6 | -} | |
| 7 | - | |
| 8 | 3 | /** |
| 9 | 4 | * Check given value empty or not |
| 10 | 5 | * |
| 11 | 6 | * @param [type] $value |
| @@ -130,10 +125,8 @@ | ||
| 130 | 125 | |
| 131 | 126 | $menu_slug = $item[2]; |
| 132 | 127 | $menu_title = $item[0]; |
| 133 | 128 | $menu_name = isset($item[5]) ? $item[5] : ''; |
| 134 | - // Use unique key for custom menu items instead of link URL | |
| 135 | - $menu_key_id = (!empty($menu_name) && strpos($menu_name, 'adminify-custom-menu-') !== false) ? $menu_name : $menu_slug; | |
| 136 | 129 | $menu_icon = isset($item[6]) ? $item[6] : ''; |
| 137 | 130 | $external_link = (isset($item['external_link']) && $item['external_link'] == 1 ) ? true: false; |
| 138 | 131 | |
| 139 | 132 | $menu_hook = get_plugin_page_hook($menu_slug, 'admin.php'); |
| @@ -145,9 +138,9 @@ | ||
| 145 | 138 | } |
| 146 | 139 | |
| 147 | 140 | $url = ''; |
| 148 | 141 | |
| 149 | - $arrParsedUrl = wp_parse_url($menu_slug); | |
| 142 | + $arrParsedUrl = parse_url($menu_slug); | |
| 150 | 143 | if (!empty($arrParsedUrl['scheme'])) { |
| 151 | 144 | if ($arrParsedUrl['scheme'] === "http" || $arrParsedUrl['scheme'] === "https") { |
| 152 | 145 | $url = $menu_slug; |
| 153 | 146 | } |
| @@ -156,10 +149,10 @@ | ||
| 156 | 149 | ? maybe_network_admin_url('admin.php?page=' . $menu_slug) |
| 157 | 150 | : maybe_network_admin_url($menu_slug); |
| 158 | 151 | } |
| 159 | 152 | |
| 160 | - $admin_menu[$menu_key_id] = [ | |
| 161 | - 'key' => $menu_key_id, | |
| 153 | + $admin_menu[$menu_slug] = [ | |
| 154 | + 'key' => $menu_slug, | |
| 162 | 155 | 'title' => $menu_title, |
| 163 | 156 | 'url' => $url, |
| 164 | 157 | 'name' => $menu_name, |
| 165 | 158 | 'icon' => $menu_icon, |
| @@ -169,18 +162,13 @@ | ||
| 169 | 162 | ]; |
| 170 | 163 | |
| 171 | 164 | if (!empty($submenu[$menu_slug])) { |
| 172 | 165 | foreach ($submenu[$menu_slug] as $sub_key => $sub_item) { |
| 173 | - $sub_slug = $sub_item[2]; | |
| 174 | - // Use unique key for custom submenu items instead of link URL | |
| 175 | - $sub_key_id = isset($sub_item['key']) ? $sub_item['key'] : $sub_slug; | |
| 176 | 166 | $external_link = false; |
| 177 | - // Look up external_link setting using unique key first, then fall back to slug | |
| 178 | - if( isset($optiongroup['submenu'][$sub_key_id])){ | |
| 179 | - $external_link = ($optiongroup['submenu'][$sub_key_id]['external_link'] == 1) ? true : false; | |
| 180 | - } elseif( isset($optiongroup['submenu'][$sub_slug])){ | |
| 181 | - $external_link = ($optiongroup['submenu'][$sub_slug]['external_link'] == 1) ? true : false; | |
| 167 | + if( isset($optiongroup['submenu'][$sub_item[2]])){ | |
| 168 | + $external_link = ($optiongroup['submenu'][$sub_item[2]]['external_link'] == 1)? true : false ; | |
| 182 | 169 | } |
| 170 | + $sub_slug = $sub_item[2]; | |
| 183 | 171 | $sub_title = $sub_item[0]; |
| 184 | 172 | $sub_name = isset($sub_item[5]) ? $sub_item[5] : ''; |
| 185 | 173 | $sub_icon = isset($sub_item[6]) ? $sub_item[6] : ''; |
| 186 | 174 | |
| @@ -194,9 +182,9 @@ | ||
| 194 | 182 | |
| 195 | 183 | |
| 196 | 184 | $sub_url = ''; |
| 197 | 185 | |
| 198 | - $arrParsedUrl = wp_parse_url($sub_slug); | |
| 186 | + $arrParsedUrl = parse_url($sub_slug); | |
| 199 | 187 | if (!empty($arrParsedUrl['scheme'])) { |
| 200 | 188 | if ($arrParsedUrl['scheme'] === "http" || $arrParsedUrl['scheme'] === "https") { |
| 201 | 189 | $sub_url = $sub_slug; |
| 202 | 190 | } |
| @@ -220,22 +208,11 @@ | ||
| 220 | 208 | if ('jfb-addons' === $sub_slug) { $sub_url = admin_url('edit.php?post_type=jet-form-builder&page=jfb-addons'); } |
| 221 | 209 | if ('jfb-payments' === $sub_slug) { $sub_url = admin_url('edit.php?post_type=jet-form-builder&page=jfb-payments'); } |
| 222 | 210 | if ('jfb-records' === $sub_slug) { $sub_url = admin_url('edit.php?post_type=jet-form-builder&page=jfb-records'); } |
| 223 | 211 | |
| 224 | - // WP Adminify Support - open in new tab | |
| 225 | - if ('adminify-support' === $sub_slug) { | |
| 226 | - $sub_url = \WPAdminify\Inc\Admin\AdminSettings::support_url(); | |
| 227 | - $external_link = true; | |
| 228 | - } | |
| 229 | 212 | |
| 230 | - // WP Adminify Pricing/Upgrade - open in new tab | |
| 231 | - if ('wp-adminify-settings-pricing' === $sub_slug) { | |
| 232 | - $sub_url = 'https://wpadminify.com/pricing'; | |
| 233 | - $external_link = true; | |
| 234 | - } | |
| 235 | - | |
| 236 | - $admin_menu[$menu_key_id]['children'][$sub_key_id] = [ | |
| 237 | - 'key' => $sub_key_id, | |
| 213 | + $admin_menu[$menu_slug]['children'][$sub_slug] = [ | |
| 214 | + 'key' => $sub_slug, | |
| 238 | 215 | 'title' => $sub_title, |
| 239 | 216 | 'url' => $sub_url, |
| 240 | 217 | 'name' => $sub_name, |
| 241 | 218 | 'icon' => $sub_icon, |
| @@ -243,87 +220,8 @@ | ||
| 243 | 220 | ]; |
| 244 | 221 | } |
| 245 | 222 | } |
| 246 | 223 | } |
| 247 | - | |
| 248 | - // Elementor 3rd-level flyout menu integration | |
| 249 | - // Grabs Quick Start, Settings, Tools, Role Manager, etc. from Elementor's sidebar navigation | |
| 250 | - // Wrapped in Throwable catch so any Elementor API change degrades gracefully | |
| 251 | - try { | |
| 252 | - $elementor_flyout_class = '\Elementor\Modules\EditorOne\Classes\Menu_Data_Provider'; | |
| 253 | - | |
| 254 | - if (class_exists($elementor_flyout_class)) { | |
| 255 | - $elementor_menu_key = isset($admin_menu['elementor-home']) ? 'elementor-home' : | |
| 256 | - (isset($admin_menu['elementor']) ? 'elementor' : null); | |
| 257 | - | |
| 258 | - if ($elementor_menu_key && isset($admin_menu[$elementor_menu_key]['children']['elementor']) | |
| 259 | - && method_exists($elementor_flyout_class, 'instance') | |
| 260 | - ) { | |
| 261 | - $menu_data_provider = $elementor_flyout_class::instance(); | |
| 262 | - | |
| 263 | - // Try known method names in order: current API → known alternates | |
| 264 | - $flyout_items = []; | |
| 265 | - $method_candidates = [ | |
| 266 | - 'get_third_level_data' => ['editor_flyout'], // Current Elementor API | |
| 267 | - 'get_editor_flyout_data' => [], // Legacy / alternate | |
| 268 | - 'get_level3_items' => [], // Fallback | |
| 269 | - ]; | |
| 270 | - | |
| 271 | - foreach ($method_candidates as $method => $args) { | |
| 272 | - if (!method_exists($menu_data_provider, $method)) { | |
| 273 | - continue; | |
| 274 | - } | |
| 275 | - | |
| 276 | - $result = call_user_func_array([$menu_data_provider, $method], $args); | |
| 277 | - | |
| 278 | - if (is_array($result)) { | |
| 279 | - // Normalize: result might wrap items under an 'items' key or be the array itself | |
| 280 | - $flyout_items = isset($result['items']) && is_array($result['items']) | |
| 281 | - ? $result['items'] | |
| 282 | - : $result; | |
| 283 | - } | |
| 284 | - break; | |
| 285 | - } | |
| 286 | - | |
| 287 | - if (!empty($flyout_items)) { | |
| 288 | - $flyout_children = []; | |
| 289 | - | |
| 290 | - foreach ($flyout_items as $item) { | |
| 291 | - if (!is_array($item)) { | |
| 292 | - continue; | |
| 293 | - } | |
| 294 | - | |
| 295 | - // Flexible key mapping — tolerate renamed fields | |
| 296 | - $slug = $item['slug'] ?? ($item['id'] ?? ''); | |
| 297 | - $label = $item['label'] ?? ($item['title'] ?? ''); | |
| 298 | - $url = $item['url'] ?? ($item['link'] ?? ''); | |
| 299 | - | |
| 300 | - if (empty($slug) || empty($label)) { | |
| 301 | - continue; | |
| 302 | - } | |
| 303 | - | |
| 304 | - $flyout_children[$slug] = [ | |
| 305 | - 'key' => $slug, | |
| 306 | - 'title' => $label, | |
| 307 | - 'url' => $url, | |
| 308 | - 'icon' => $item['icon'] ?? '', | |
| 309 | - 'name' => '', | |
| 310 | - 'is_flyout_child' => true, | |
| 311 | - 'external_link' => false, | |
| 312 | - ]; | |
| 313 | - } | |
| 314 | - | |
| 315 | - if (!empty($flyout_children)) { | |
| 316 | - $admin_menu[$elementor_menu_key]['children']['elementor']['children'] = $flyout_children; | |
| 317 | - $admin_menu[$elementor_menu_key]['children']['elementor']['has_flyout_children'] = true; | |
| 318 | - } | |
| 319 | - } | |
| 320 | - } | |
| 321 | - } | |
| 322 | - } catch (\Throwable $e) { | |
| 323 | - // Silently degrade — menu renders without flyout items | |
| 324 | - } | |
| 325 | - | |
| 326 | 224 | $admin_menu = jlt_adminify_replaceAmpersandInHref($admin_menu, 'url'); |
| 327 | 225 | return $admin_menu; |
| 328 | 226 | } |
| 329 | 227 | |