Consider me newbie to web development and wordpress.
I am developing a plugin that randomly changes text color of elements. It is working good but its pretty much static right now. Now i want add this function for other elements too like post title.
How can i control conditions in a javascript .js file from options in an admin menu form. Like say I want to add that feature for post titles too so user will have a form with 2 checkboxes, one for blog title and other post title.
I have form ready with checkboxes, script working for title, just have to pass these checkbox values to that js file.
Thanks in advance.
Javascript file codes :
jQuery(document).ready(function($){
var $ttl = '.site-title a';
var rainbow = function(){
var $rrr = Math.round(((Math.random()*200)));
var $ggg = Math.round(((Math.random()*200)));
var $bbb = Math.round(((Math.random()*200)));
var $r = "'rgb(" + $rrr + ", " + $ggg + ", " + $bbb + ")'";
$($ttl).animate({color: $r},"slow");
}
$($ttl).mouseenter(
function(){
rainbow()
}
);
});
My plugin php file :
if ( ! function_exists( 'rainbow_title_script' ) ) {
function rainbow_title_script() {
wp_enqueue_script(
'rainbow_title_script',
plugins_url( '/rainbow_title.js' , __FILE__ ),
array( 'jquery-ui-core', 'jquery-color' )
);
} // function ends
} // if condition ends
add_action('wp_enqueue_scripts','rainbow_title_script')