None of those functions are JavaScript functions. They’re PHP functions. You need to run them outside the <script>
tag in the PHP:
add_action(
'wp_footer',
function () {
if ( is_archive() || is_category() || is_author() || is_date() ) {
?>
<script>
// etc.
</script>
<?php
}
}
);
You were also missing the ()
on is_archive
.