Last active
August 29, 2015 14:18
-
-
Save tojibon/3856a904e0b5df27328f to your computer and use it in GitHub Desktop.
WordPress JS enqueue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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