The way I see, you could minimize code mixing storing the return value of get_theme_option("bg_slideshow")
into a JS variable, although it would not solve the problem as whole:
var themeOptBgSlideshow = <?php echo get_theme_option("bg_slideshow"); ?>;
if(themeOptBgSlideshow == 1){
/* Background Images */
var bg_slideshow = jQuery(".bg_slideshow").attr("data-active");
if(bg_slideshow == 1) {
jQuery.vegas('slideshow', {
delay: 8000,
backgrounds:[
<?php echo get_bg_images_url(); ?>
]
})('overlay');
}
}
But as said, that workoaround would only minimize code mixing. If you’re really into separating your code (which is always a good practice), I think the only option is to make an AJAX call. This way, your JS can request a PHP page/function that would only return the value of get_theme_option("bg_slideshow")
. Assign the returned value to any variable as proposed in the example above and you’re ready to go.
IMHO, I think an AJAX call for that is a bit of an extreme solution. But anyways, that’s up to you to decide which solution fits you best.