add_action( 'wp_enqueue_scripts', 'action_function_name_7714', 99 ); function action_function_name_7714(){ wp_localize_script( 'jquery', 'themeoptions', array( 'sky_header_sticky' => get_theme_mod( 'sky_header_sticky' ), ) ); }
var inner = $( '#site-header' ); if (true == themeoptions.sky_header_sticky) { $(window).scroll(function () { if ($(this).scrollTop() > 200) { inner.addClass("fixed"); } else { inner.removeClass("fixed"); } }); }
function wpdocs_theme_name_scripts() { if( get_theme_mod( 'sky_header_sticky' ) ) { wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/example.js', array(), '1.0.0', true ); } } add_action( 'wp_enqueue_scripts', 'wpdocs_theme_name_scripts' );