This was a little embarassing
NOTE: The space condition has been removed as part of the temporary fix for this problem - see below.
Yesterday I was doing some testing on my Wordpress installation. I have a problem (that others have as well) where when I post PHP code, even in the syntax highlighter, the opening PHP tag gets split between the less than symbol (<) and the question mark (?).
An example of this can be seen here:
// some PHP
?>
See the space? This only happens after the post is made. Here it is inside of code tags:
// some PHP inside code tags
?>
Even with the syntax highlighter, it still does it:
<?php // some PHP inside of wp-syntax ?>
So far it has been added to the Wordpress forums several times. My most recent post seems to have touched off a little bit of action. We'll see how that goes.
Anyway, I had to edit this because it was just a test page yesterday. Today, it is a fell fledged, broken PHP tag post.
I AM TESTING A CHANGE I MADE TO WP-INCLUDES/FORMATTING.PHP (balanceTags):
// test
?>
Ok, so here is the fix I implemented in my Wordpress code:
- Open wp-includes/formatting.php
- At or around line 448 (in the balanceTags function) locate regular expression number 1
- Change that regular expression the one in regular expression number 2
- Save formatting.php and upload it.
Change from this:
"/<(\/?\w*)\s*([^>]*)>/"Change to this
"/<(\/?[^?]\w*)\s*([^>]*)>/"Test the fix by trying to post:
<?php // I are likes fixin' stuff $myWordpress = str_replace('broken', 'fixed', $wordpress); ?>
// New test echo 'This is a test';