When using wp_add_inline_script
, a CDATA section is required if you need your document to parse as XML (e.g. when an XHTML page is interpreted as XML) and you want to write literal i<10
and a && b
instead of i<10
and a && b
.
This is not an issue with scripts that are stored in external source files, but for any inline JavaScript in XHTML you will probably want to use a CDATA section. Note that many XHTML pages were never intended to be parsed as XML in which case this will not be an issue.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
wp_add_inline_script( | |
'handle', | |
'// <![CDATA[ | |
// Custom JS here. | |
// ]]>' | |
); |
Leave a Reply