I am loading some jquery on a specific Wordpress admin page, the jquery loads and works fine but I need have this jquery only trigger if a php variable exists.
In php I would just write a function and hook it into the admin page:
I am enqueuing the jquery file, i.e., foo.js that contains this following jquery:
jQuery(document).ready(function($){
$('#someID.some-class > a').append('<div class="caption"></div>');
$(".caption").text("Add this text");
});
So the file foo.js file loads whenever the themes.php file is loaded but I do not want the jquery to run unless a variable is set by the themes.php page.
I am confused as to where and how I do check the variable and trigger the jquery.
Do I just add the jquery by echoing out the the jquery from within a function?
Do I somehow add the php variable check into the foo.js file?