Somewhere along the way, it seems that WordPress started requiring a space or line break after a smiley key in order for the key to be properly replaced with the smiley image.
For example:
:lol: , said the hyena.
instead of:
:lol:, said the hyena.
The first has a space after the ": l o l :" key, where the second does not.
I probably could have dug through the WP code and found where to change this, but the new behavior doesn't really bother me and I only had a couple of places where I needed to fix this.
Here is sample SQL1 to see if you have places in your database that need fixing:
SELECT *
FROM wp_posts
WHERE post_content LIKE '%:,%'
SELECT *
FROM wp_posts
WHERE post_content LIKE '%:,%'
etc.
And here is the SQL to fix it:
UPDATE wp_posts
SET post_content =
REPLACE(post_content, ':,', ': ,');
UPDATE wp_posts
SET post_content =
REPLACE(post_content, ':.', ': .');
etc.
Of course, you want to make sure you back up your database first before making sweeping changes like this. I screwed up the syntax myself and had to restore my posts table from my nightly backup.
It happens. 🙂
- This all assumes the standard 'wp_' prefix for your database tables. [back]
Interesting, that does indeed explain a thing or two.
I had some fun with that while testing 2.1. I used the Search and replace plugin rather than working directly with MySQL. I also modified WP-Grins to make sure to pad spaces around new smilies – documented here.
To “fix” Smilies in WordPress 2.1 just line:
$wp_smiliessearch[] = '/(\s|^)'.preg_quote($smiley, '/').'(\s|$)/';
in /wp-includes/vars.php with
$wp_smiliessearch[] = '/(\s|^)'.preg_quote($smiley, '/').'/';
Regards Emu
Simple, yes – but when you end up with a dozen or so of those little tweaks to be done on each upgrade, it’s a hassle. Making my data comply with WordPress’ expectations is a better forward-looking solution.
You are right, Alex.
I know this disadvantage well but I post that solution for people that do not want to edit his post and database records.
I’ll try to write a plugin that make this changes on the fly, so if the WordPress developers do not change the regular expression in next versions, this “fix” to work. If I success with develop, I’ll post here again.
Regards Emu
P.S. Sorry for my not so good english.
Where the behavior is most annoying is in comments. Average folk are more likely to use colon-parenthesis symbols which WordPress won’t replace correctly “on the fly” unless someone happens to luck into the secret method. I don’t get so many smiley-laced comments that’s it’s actually a problem for me, but it did happen often enough to drive me to the codex and help forums to see if it was just me…
How I promise, I write here again ;).
I wrote a plugin that “fix” wordpress 2.1 smilies. If someone want it – Usmivki.
Regards Emu
But what about smilies that have not a space in front of them? They are still being parsed as text instead of smilies….
e.g. say that :cheese: is a smilie.
:cheese::cheese::cheese::cheese:
will only give
[smilie]:cheese::cheese::cheese:
[…] smiles Cleanup|alexking […]
[…] smiles Cleanup|alexking […]