• hoomn

    (@hoomn)


    Hey,

    I want to create a simple custom smilies plugin. I can easily use the global $wpsmiliestrans; to change the smiley codes and image names, but I also want to change the smilies directory. How can I do that?

    Is the smilies directory only mentioned in the formatting.php? If yes, can I use a remove_action for translate_smiley function in that file, and then use an add_action and rewrite that function in my plugin? If yes, how should I use remove_action and add_action here?

    Your quick response would be highly appreciated!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    The smilies directory is constructed in the translate_smiley() function itself. There is no action to hook there, but there is a filter, ‘smilies_src’. No need to remove another prior filter, unless some other plugin hooked in. Your filter function is passed a few useful bits of information, just return the actual image path you wish to use.

    Thread Starter hoomn

    (@hoomn)

    Thank you very much for your response. (BTW, that filter is not located in default-filters.php, do you know where it is located?)

    I also want to do something more important in my plugin, i.e. I want to change the image alt for the smilies. (e.g. I want to have wink instead of ;-) as the image alt) Could you please tell me how it is possible to change translate_smiley‘s behavior for that?

    Moderator bcworkz

    (@bcworkz)

    The filter is initiated from wp-includes/formatting.php. You can get this kind of information from http://adambrown.info/p/wp_hooks .

    Changing the alt attribute is not so easy, it cannot be done at the translate_smiley() level. You may have to hook ‘the_content’ and search for img tags with class ‘wp-smiley’ , unless you can find where translate_smiley() is called and identify some way to filter the value there.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Custom Smilies’ is closed to new replies.