You can achieve this using wp_footer
action. Add bellow code to functions.php
file. It will load the script at the footer of page.
add_action('wp_footer', 'load_count_down');
function load_count_down(){
if ($year = get_option('of_year') && $month = get_option('of_month') && $day = get_option('of_day') ) {
$date = $year."https://wordpress.stackexchange.com/".$month."https://wordpress.stackexchange.com/".$day;
$script = <<<EOF
<script type="text/javascript">
var siteCountDown = function() {
if ( $('#date-countdown').length > 0 ) {
$('#date-countdown').countdown('$date', function(event) {
var \$this = $(this).html(event.strftime(''
+ '<span class="countdown-block"><span class="label">%w</span> weeks </span>'
+ '<span class="countdown-block"><span class="label">%d</span> days </span>'
+ '<span class="countdown-block"><span class="label">%H</span> hr </span>'
+ '<span class="countdown-block"><span class="label">%M</span> min </span>'
+ '<span class="countdown-block"><span class="label">%S</span> sec</span>'));
});
}
};
siteCountDown();
</script>
EOF;
echo $script;
}
}