Whatever WP function assembles the $att
array from the [myShortcode att1="..." att2="..." ...]
string uses the "
character to delimit the data. However, the “
and the ”
characters seem to be read as text, not delimeters; and their use in place of "
can lead to shortcode errors.
In theory, there shouldn't ever be a problem because “
and ”
are not characters on the qwerty keyboard, and so would not be encountered with manual entry. Yet, cutting and pasting from sources that use “
and ”
allow for their inclusion (and there should be error checking for that situation). For example, the page The Beginner’s Guide to Writing Your Own Custom Shortcode says that [helloworld name=”Bob”]
outputs Hello Bob!
, which is not the case because the webpage cutely styled "
into ”
. Cutting and pasting [helloworld name=”Bob”]
outputs Hello ”Bob”!
; and [helloworld name=”Bob Smith”]
outputs Hello ”Bob!
, since the space between Bob
and Smith
is read as a delimeter and the array says that [name] = "Bob
and that [0] = Smith
.
Doing a preg_replace
on the shortcode string before it is parsed into the $atts
array seems like the best way to prevent errors. The question is where to do that.