using get_option to add a different js

I’m trying to us get_option in my plugin to choose to load 1 of 3 js files.

I started with this (and it works) …

add_action('wp_footer','isotope_vpl_set_style');

function isotope_vpl_set_style() {
        include("inc/myfile.js");
        }

then I changed it to …

add_action('wp_footer','isotope_vpl_set_style');  

function isotope_vpl_set_style() {   
$style = (get_option('damien_style');    
if  $style = ("isotope"){
        include("inc/myfile.js");
        }
}

And it’s not working … I checked the SQL table and the option name and value are set.

My PHP error log tells me I have an unexpected ; on this line $style = (get_option('damien_style');

Where have I gone wrong please 🙂

1 Answer
1

You had an extra ( before get_option and the if statement syntax was wrong. Here is the revised code:

add_action('wp_footer','isotope_vpl_set_style');  

function isotope_vpl_set_style() {   
    $style = get_option('damien_style');    
    if($style == "isotope") {
        include("inc/myfile.js");
    }
}

Leave a Comment