Pull the add_action()
outside of the function, and put the conditional inside the callback. Also, if you’re printing a script directly, use wp_print_scripts
instead of wp_head
. You also have a syntax error.
function testingone(){
if( get_option( 'MyOptionName' ) ) {
?>
<script>var Script = GoesHere; </script>
<?php
}
}
add_action( 'wp_print_scripts','testingone' );