[wp-trac] [WordPress Trac] #3670: Removing CDATA close tag ( ]]> ) unbalances the CDATA block

WordPress Trac noreply at wordpress.org
Fri Dec 12 18:18:51 UTC 2014


#3670: Removing CDATA close tag ( ]]> ) unbalances the CDATA block
-------------------------------------------------+-------------------------
 Reporter:  scenic                               |       Owner:  andy
     Type:  defect (bug)                         |      Status:  new
 Priority:  normal                               |   Milestone:  Future
Component:  Posts, Post Types                    |  Release
 Severity:  minor                                |     Version:  2.1
 Keywords:  has-patch needs-refresh needs-unit-  |  Resolution:
  tests                                          |     Focuses:  template
-------------------------------------------------+-------------------------

Comment (by truebird):

 @awelzel

 If this would work it would be awesome. Thanks so much for posting it.
 Mine is slightly different:
 $content = str_replace( ']]>', ']]>', $content );

 Would I just have to change that line in your code to make it work (or
 anything else as well)? Also, I am on a multisite if that makes a
 different (and the site in question is a multisite).

 :)



 Replying to [comment:72 awelzel]:
 > I have to admit that I didn't have time to get into WordPress core
 coding yet - too many other projects - sorry.
 >
 > But anyway - until there is a solution - for those who don't want to
 fiddle around with the core code with every update: You can use the
 following workaround in the templates functions.php or a plugin.
 >
 > If there is an intentional "]]>" somewhere in a post this ''may''
 lead to invalid HTML in rare cases - although a "]]>" on its own as part
 of a page or post is not invalid.
 >
 > {{{
 > function cdata_markupfix($content) {
 >     $content = str_replace("]]>", "]]>", $content);
 >
 >     return $content;
 > }
 >
 > function cdata_template_redirect( $content ) {
 >       ob_start('cdata_markupfix');
 > }
 >
 > add_action('template_redirect','cdata_template_redirect',-1);
 > }}}
 >
 > You can see this live on one of my pages where I embed external scripts
 (using my own plugin) to generate JavaScript stuff and which validates
 fine: http://arnowelzel.de/wp/en/tools/statistics

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


More information about the wp-trac mailing list