Can someone please explain what the purpose of this code is:
$text = str_replace(']]>', ']]>', $text);
I’m referring to a line of code inside wp_trim_excerpt(), but I’ve seen something very similar in some other wp functions as well.
On the surface, I would say it’s not doing anything at all, but I have to give the wordpress developers more credit than that, so I’m sure there’s a reason for this. I’ve looked into the php manual for str_replace to see if there is some special return value but everything is as I would expect.
Is this some sort of ninja data validation technique?
The replacement string contains a HTML entity which when displayed on a browser, looks like the needle string. It’s converting > to a HTML entity.
Reference: http://core.trac.wordpress.org/browser/tags/3.4.1/wp-includes/formatting.php#L2119