Support » Plugin: PHP Code Widget » Can't call site title that includes ampersand

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Samuel Wood (Otto)

    (@otto42)

    Presumably you’re using that in some kind of javascript code or something along those lines?

    HTML is not allowed to contain bare ampersands. They need to be changed to & amp; to be interpreted properly. Basically, run it through htmlspecialchars() before outputting it.

    <?php echo htmlspecialchars(get_bloginfo('name')); ?>

    Thanks for the reply.

    Oh yes. Sorry. That is what I’m doing. php within the javascript within the php widget. I’m using EasyBib’s widget… http://www.easybib.com/developer/easybib-cite-widget

    I had to change it a bit to get it to grab the info right from WordPress. It all worked great together until I added the ampersand to the site title.

    I tried your suggestion & changed the line to
    "site":"<?php echo htmlspecialchars(get_bloginfo('name')); ?>",
    but it still doesn’t work.

    Then…
    "site":"<?php htmlspecialchars(bloginfo('name')); ?>",

    Then I just took the simplest route…
    "site":"Out of the Family Tree & into the Fry-ing Pan",

    Nothing.

    As soon as I remove the & from the line, it works great.

    OK… got a reply from EasyBib.

    This worked:
    "site":escape("<?php bloginfo('name'); ?>"),

    Thanks!!!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Can't call site title that includes ampersand’ is closed to new replies.