Trying to echo html on javascript condition in a php function. But i don't know if it's possible to echo out everything like this:
if(!is_user_logged_in()) {
function add_preloader(){
echo "<script>
if (readCookie('referrer') == null) {
<section class='loading-overlay'>
<div class='loader-inner ball-grid-pulse'>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
</section>}
</script>" ;
}
I'm trying to show a preloader only one time using cookie in a wordpress function
<script>is used for javascript functions , if you want to echo html inside it , you have to wrap html inside "" or ' ' (qoutes). But i can see also you are reading a cookie , you don't need javascript to read a cookie you can also read the cookie by using php$_COOKIE['referrer']