do_shortcode JS and CSS files
-
Hi,
On mobile devices I would like to do an Ajax call to show a map. The map is showing, but it only shows ‘map is loading’ message. I use do_shortcode to show the map, but because do_shortcode is not in the template the JS and CSS files are not loaded. How can I load the appropiates JS and CSS files manually?
This code is not working:
add_action('wp_enqueue_scripts', 'my_scripts_method'); function my_scripts_method() { if((is_home()) || (is_page(array(16,19,21,23,25)))){ wp_deregister_script( 'ai1ec_requirejs' ); } if ('ai1ec_event' !== get_post_type() && is_single()) { global $wp_styles; $plugin_version = get_option('leafletmapsmarker_version'); wp_register_style('leafletmapsmarker', LEAFLET_PLUGIN_URL . 'leaflet-dist/leaflet.css', array(), $plugin_version); wp_enqueue_style('leafletmapsmarker'); wp_register_style('leafletmapsmarker-ie-only', LEAFLET_PLUGIN_URL . 'leaflet-dist/leaflet.ie.css', array(), $plugin_version); wp_enqueue_style('leafletmapsmarker-ie-only'); $wp_styles->add_data('leafletmapsmarker-ie-only', 'conditional', 'lt IE 9'); wp_register_script( 'leafletmapsmarker', LEAFLET_PLUGIN_URL . 'leaflet-dist/leaflet.js', array('leafletmapsmarker-googlemaps-loader', 'jquery' ), $plugin_version, true); wp_register_script( 'show_map', LEAFLET_PLUGIN_URL . 'inc/js/show_map.js', array('leafletmapsmarker' ), $plugin_version, true); wp_register_script( 'leafletmapsmarker-googlemaps-loader', 'https://www.google.com/jsapi?key='.$google_maps_api_key, array(), 3.7, true); } }Is there anything else I should do to make it work?
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
The topic ‘do_shortcode JS and CSS files’ is closed to new replies.