Shortcode in submenu
-
Hi,
I am developing a wordpress plugin for the first time and actually a first time wordpress user as well. This plugin is meant to be used by a friend of mine so we have a lot of discussing here and there. He had this idea to use a Max Mega Menu submenu to hold 2 shortcodes we had thought of. Now the shortcodes loaded in to the submenu, all fine until I tried loading the JS and CSS complementary to the shortcode. I have been trying to figure out how to do this for the past few hours. The shortcodes work fine on a page, but just not in the submenu, i can see that the JS and CSS are not loaded with the shortcode in the Network tab. I tried enqueueing via menu items:function eta_enqueue_menu_assets() {
$styles_dir = plugin_dir_url(__FILE__) . '../assets/css/';
$scripts_dir = plugin_dir_url(__FILE__) . '../assets/js/';
$menu_locations = get_nav_menu_locations();
if (!empty($menu_locations)) {
foreach ($menu_locations as $menu_id) {
$menu_items = wp_get_nav_menu_items($menu_id);
if ($menu_items) {
foreach ($menu_items as $menu_item) {
if (has_shortcode($menu_item->post_content, 'eta_chatbot')) {
eta_enqueue_dynamic_css('chatbot_css', $styles_dir . 'chatbot.css');
wp_enqueue_script('chatbot_js', $scripts_dir . 'chatbot.js', array('jquery'), null, true);
}
if (has_shortcode($menu_item->post_content, 'eta_dropdown')) {
wp_enqueue_style('dropdown_css', $styles_dir . 'dropdown.css');
wp_enqueue_script('dropdown_js', $scripts_dir . 'dropdown.js', array('jquery'), null, true);
}
if (has_shortcode($menu_item->post_content, 'eta_license_plate_checker')) {
wp_enqueue_style('license_plate_css', $styles_dir . 'license-plate.css');
wp_enqueue_script('license_plate_js', $scripts_dir . 'license-plate.js', array('jquery'), null, true);
}
}
}
}
}
}This did not do the trick, and now I am stuck on this problem. Is this even possible with MMM. Any help and/or tips are greatly appreciated, thank you in advance.
- You must be logged in to reply to this topic.