3

I'm trying to set shortcode attribute value to ' " (single and double quote) by using escaped values ' ".

Example: [shortcode attr="' ""]test[/shortcode]

As soon as I switch to visual editor, they get converted back to ' " and shortcode is now broken. How does one properly escape shortcode attributes so that they can work even after switching between visual and text editor?

  • FWIW, I wonder if you should take one step further back and try to find a way around requiring attributes of this type at all. – mrwweb Apr 5 '16 at 22:44
  • A client added double quote in my shortcode and everything broke because WordPress unescaped the entered attribute value. I'm not requiring anything, I just need a way to safely escape all values. – Igor Jerosimić Apr 7 '16 at 9:45
6

I suggest using keywords for them. so you would do something like [shortcode attr="single_quote double_quote"]test[/shortcode]. Then, while parsing the shortcode you can change them back.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.