Skip to content

Instantly share code, notes, and snippets.

@tojibon
Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tojibon/3856a904e0b5df27328f to your computer and use it in GitHub Desktop.
Save tojibon/3856a904e0b5df27328f to your computer and use it in GitHub Desktop.
WordPress JS enqueue
add_action( 'wp_enqueue_scripts', 'mondira_slider_options' );
function mondira_slider_options(){
wp_enqueue_script( 'theme-slider', get_template_directory_uri() . '/js/theme-slider.js', array( 'jquery' ) );
wp_enqueue_script( 'theme-slider-init', get_template_directory_uri() . '/js/init.js', array( 'jquery', 'theme-slider' ) );
// get user options
$options = array();
$options['autoplay'] = get_theme_mod( 'slider-autoplay', true );
$options['navigation_style'] = get_theme_mod( 'numbers', 'circles' );
wp_localize_script( 'theme-slide-init', 'themeSliderOptions', $options );
}
jQuery( document ).ready( function( $ ){
$( '.slider' ).fancySlider({
'autoplay': themeSliderOptions.autoplay,
'navStyle': themeSliderOptions.navigation_style,
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment