Unexpected token illegal when using JS in hook


#1

Hello. I’m trying to add the code to rtp_hook_end_post_content:

  

And then I got an error Uncaught Syntax Error: Unexpected Token ILLEGAL. But when I put the function to Chrome Console it works correctly.
What should I do to fix this?


#2

Hello Irina,

I just checked your code on my localhost and its working fine on my end. Give this a try after deleting all the invisible characters (whitespace) around that it.

Thanks,


#3

Thank you! The problem was that the code worked as widget but didn't worked as a hook. So I had to change single quotation marks to doubles like here:

So now it works well.


#4

Glad to know its working fine.

Thanks for using rtPanel.


#5

dfgdfgdfgdfgdfgdfg


#6