The Return of the Shrinking Smilies

Readers with long memories might recall me muttering about having to fix a little problem with my smilies shrinking a while ago. Readers with memories like mine can click that link to read all about it.

Well, it seems one of the recent WordPress updates must have broken my fix, mutter. I noticed this when I inserted a  :tigger: into my Saal Digital review at the weekend. Instead of bouncing properly, Tigger was squashed into a tiny one-character space, which just isn’t right.

So, last night I reminded myself what I’d done. The key bit of code was this:

add_action( 'init', 'smilies_size_fix_init', 1 );

function smilies_size_fix_init() {

add_filter( 'the_content', 'smilies_size_fix', 11 );
add_filter( 'the_excerpt', 'smilies_size_fix', 11 );
add_filter( 'comment_text', 'smilies_size_fix', 21 );
}

function smilies_size_fix( $content ) {
return str_replace( 'class="wp-smiley" style="height: 1em; max-height: 1em;"', 'class="lcb-wp-smiley"', $content );
}

And after some head-scratching (heedless of the risk of splinters), and a bit of reading, I developed a theory. The last parameter on each add_filter() call is a kind of priority thingy[1]. The lower the number, the earlier the function will be called in the process of generating a page[2].

My theory was that some code changes or other were making my function run before the bit of code that inserts the smilies, so that my clever substitution wasn’t happening any more. SO, I thought, let’s try making it run later and see what happens.

So, I changed the priorities from 11 and 21 (numbers pretty much chosen at random at the time) to 50, saved the plugin, and….

Well, let’s just say  :tigger:

As always, I’m posting this so I know where to look next time something breaks this…

[1] I have mentioned that I’m not a coder, right?
[2] WordPress does Complicated Things to make all that happen…

Leave a Reply

Your email address will not be published. Required fields are marked *