I want to write a simple plugin. For every time a page is viewed, it will write to the MySQL database. Then, if the current hour is odd, it will set a PHP variable of $is_odd to true;
<?php
require_once('library-of-functions-to-support-this-plugin.php');
function_to_write_to_mysql_db();
$is_odd = false;
if(current_hour_odd()) {
$is_odd=true;
}
$is_odd_json = json_encode($is_odd);
?>
Then, it should embed the following JavaScript (note: I've already modified the theme's templates to put an on each page):
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
var odd = <?php echo $is_odd_json; ?>;
if(odd) {
$("#OddElement").html('Odd!');
}
</script>
So basically, I have no idea where to put these code snippets. What filters do I want to apply? I know this plugin seems stupid, but it's laying the groundwork for something else I want to do.
Thanks so much!