Quantcast
Channel: Topic Tag: xml | WordPress.org
Viewing all articles
Browse latest Browse all 3214

awelzel on "Stop converting `]]>`s to `]]& gt;`s"

$
0
0

The problem is - even the generated code of shortcodes gets manipulated this way!

Example:

I use the "insert php" plugin to embed a PHP script which generates a chart using RGraph which is a JavaScript library (see http://arnowelzel.de/wp/en/tools/statistics/).

I also extended the "insert php" plugin to output "raw" html without wp_texturize() etc. so the output of the embedded PHP script will be used WITHOUT any modification - since I KNOW how to generate valid HTML and JavaScript:

This chart shows the number of visits of the webserver. The data points show the exact value as tooltip when you touch them using the mouse.

[raw][insert_php]
include('my-script.php');
[/insert_php][/raw]

The chart was created using <a href="http://www.rgraph.net">RGraph</a>. The data will be updated daily, based on the reports of <a href="http://www.awstats.org">AWStats</a> on this server.

Everything seemed to be fine - until I realized, that the_content() still replaces "]]>" with "]]" followed by an "amp"-entity which makes the CDATA block invalid - even though I removed ANY filter for the output ("& gt;" is of course without the space in the code - but that's the only way to cite the code here without getting the entity being replaced by ">" in this post):

function the_content( $more_link_text = null, $strip_teaser = false) {
	$content = get_the_content( $more_link_text, $strip_teaser );
	$content = apply_filters( 'the_content', $content );
	$content = str_replace( ']]>', ']]& gt;', $content );
	echo $content;
}

That's the point - and not just adding CDATA blocks manually in posts or pages.


Viewing all articles
Browse latest Browse all 3214

Trending Articles