Skip to content

Instantly share code, notes, and snippets.

@JiveDig
Last active August 29, 2015 14:25
Show Gist options
  • Save JiveDig/899b83ec34667c3f89c6 to your computer and use it in GitHub Desktop.
Save JiveDig/899b83ec34667c3f89c6 to your computer and use it in GitHub Desktop.
Sensible script enqueueing - http://mikejolley.com/2013/12/sensible-script-enqueuing-shortcodes/ - use wp_enqueue_script('script-name'); in your shortcode.
<?php // Put this code in functions.php or a custom plugin. Don't include opening php tag.
/**
* Register scripts to enqueue in our shortcode
* @author Mike Hemberger
* @link http://thestizmedia.com/shortcode-to-show-map-markers-of-child-pages-with-acf-pro/
*/
add_action('wp_enqueue_scripts', 'tsm_register_non_global_scripts');
function tsm_register_non_global_scripts() {
wp_register_script( 'google-map', 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false', array(), '3', true );
wp_register_script( 'amc-map', get_stylesheet_directory_uri() . '/assets/js/map.js', array('google-map'), CHILD_THEME_VERSION, true );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment