[wp-trac] [WordPress Trac] #33106: Removal of newlines in CDATA breaks inline scripts

WordPress Trac noreply at wordpress.org
Mon Jul 27 08:53:15 UTC 2015


#33106: Removal of newlines in CDATA breaks inline scripts
-----------------------------+--------------------
 Reporter:  jeremyfelt       |       Owner:
     Type:  defect (bug)     |      Status:  new
 Priority:  highest omg bbq  |   Milestone:  4.2.4
Component:  Formatting       |     Version:  4.2.3
 Severity:  major            |  Resolution:
 Keywords:  has-patch        |     Focuses:
-----------------------------+--------------------

Comment (by schtief):

 Hi Wordpress-Team,

 please just replace

 {{{// <![CDATA[}}}
 by
 {{{/* <![CDATA[ */}}}

 and

 {{{// ]]>}}}
 by
 {{{/* ]]> */}}}

 With this CDATA-definition also inline JS are supported:
 {{{ #!js
 /* <![CDATA[ */document.write('hello');/* ]]> */
 }}}

 As a work around you can also define a filter in the functions.php for
 this task, but it would be great if native WP would support "one-line"
 (minified) javascript:

 {{{ #!php
 <?php
 // somewhere in the functions.php
 function my_filter_cdata( $content ) {
   $content = str_replace( '// <![CDATA[', '/* <![CDATA[ */', $content );
   $content = str_replace( '// ]]>', '/* ]]> */', $content );
   return $content;
 }
 add_filter( 'content_save_pre', 'my_filter_cdata', 9, 1 );
 }}}

 Thank you

--
Ticket URL: <https://core.trac.wordpress.org/ticket/33106#comment:24>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list