Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

ianhaycox on "wptexturize convert ampersands in SCRIPT tags"

$
0
0

According to the documentation

http://codex.wordpress.org/Function_Reference/wptexturize

wptexturize is meant to skip processing text within various tags like PRE, SCRIPT etc, however it always seems to convert ampersands to #038;

For example,

wptexturize('<XXXscript type="text/javascript"> var x = "Hello & goodbye"; </script>');

correctly returns:
NOTE - I've added spaces for display reasons.

<XXXscript type="text/javascript"> var x = & #8220;Hello & #038; goodbye& #8221;; </script>

With the SCRIPT tag,

wptexturize('<script type="text/javascript"> var x = "Hello & goodbye"; </script>');

<script type="text/javascript"> var x = "Hello & #038; goodbye"; </script>

it correctly ignores the quotes but still convert the ampersand.

This causes a real problem with AJAX requests as any GET parameters are not passed, e.g.

http://xx.com/wp-admin/admin-ajax.php?action=foo&bar=1&foobar=2

gets converted to,

http://xx.com/wp-admin/admin-ajax.php?action=foo&#38; #038;bar=1& #038;foobar=2

Is this expected behaviour ?

If it is then is there a workaround, bar removing the wptexturize filter ?

Thanks.


Viewing all articles
Browse latest Browse all 8245

Trending Articles