[wp-trac] [WordPress Trac] #33106: Removal of newlines in CDATA breaks inline scripts
WordPress Trac
noreply at wordpress.org
Tue Jul 28 22:16:25 UTC 2015
#33106: Removal of newlines in CDATA breaks inline scripts
-----------------------------+--------------------------
Reporter: jeremyfelt | Owner: miqrogroove
Type: defect (bug) | Status: assigned
Priority: highest omg bbq | Milestone: 4.2.4
Component: Formatting | Version: 4.2.3
Severity: major | Resolution:
Keywords: has-patch | Focuses:
-----------------------------+--------------------------
Comment (by azaozz):
@millertimesites try adding this to a plugin:
{{{
add_filter( 'the_content', '_my_fix_cdata', 20 );
function _my_fix_cdata( $content ) {
if ( strpos( $content, '// <![CDATA[' ) !== false ) {
$content = preg_replace( '%(<script[^>]*>)//
<!\[CDATA\[(?![\r\n])%', '$1/* <![CDATA[ */', $content );
}
return $content;
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/33106#comment:39>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list