• Hi! When I use && in my JS code (in Custom HTML block), it produces error “Uncaught SyntaxError: Invalid or unexpected token (at (index):1577:1232)”. In console I see that, && was converted to “& # 038;& # 038;” and the error is pointing on it. How to disable this autoformatting? Please let me know, thanks!

    UPD: ( x<y && z>w) produces error, but (z>w && x<y) doesn’t.

    • This topic was modified 1 year, 11 months ago by nicewp123.
    • This topic was modified 1 year, 11 months ago by nicewp123.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    JS is executable (interpretable actually) code, it’s not HTML, even though it’s within a <script> block. All editor HTML is encoded with htmlspecialchars(), so you cannot reliably place JS in any editor block. In the right context it can work, but it’s not reliable. To reliably place JS on a page, it could be inserted by a custom shortcode or block that does not use htmlspecialchars(). Or you could use wp_add_inline_script() or use a plugin specifically meant for inserting JS onto pages.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    Also make sure you’re an admin or editor level user. Lesser user levels don’t have the privilege of posting unfiltered HTML.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘&& produces error’ is closed to new replies.