[resolved] Adding custom smileys (10 posts)

  1. rec19
    Posted 2 years ago #

    I've got some custom smilies I would like to upload.

    I saw a couple of articles how to do this by uploading the smiley gifs in wp-includes/images then adding the code in wp-includes/themefunctions.php under the:
    $wpsmiliestrans = array(
    by writing for example:
    ':exclamation-mark:' => 'exclamation-mark.gif',

    here is an article I read on it.

    Is it possible to do this sort of thing in wp-content/mu-plugins then upload my image in another directory? As I would prefer not to add anything in the wp-includes directory.

  2. http://halfelf.org/2013/ie-8-and-svg-smilies/

    Filters! Toss it in an mu-plugins file (which is exactly what I did) :)

  3. rec19
    Posted 2 years ago #

    Thanks, I'll give it a try

  4. rec19
    Posted 2 years ago #

    I saw that 'don't use multisite' video a few months ago when I was thinking about using wordpress mutisite. I didn't realize that was you, anyway thanks for reply, maybe I can hire you at some point to check my multisite code as I'm bound to do something against wordpress best practices.

    That was what I've been looking for, I can now replace all the wordpress smilies without going into includes folder, however is it possible to add even more smilies to add to the collection as I created some of my own using Gimp.

    I'm creating some of my own smilies such as 'tired.gif', 'dance.gif', 'ice-cream.gif' but I don't know how to add the code to make smilies appear when users type:

  5. I'm not for hire this year. (Yeah I know it's February.)

    I don't know how to add the code to make smilies appear when users type:

    You mean add new ones (the ones listed here - https://codex.wordpress.org/Using_Smilies - should work).

    https://wordpress.org/plugins/custom-smilies-se/ - but that would only be per-site. You'd have to fork it and put it in mu-plugins with the new entries hard coded in.

  6. rec19
    Posted 2 years ago #

    Yes I would need to have a plugin like that to work on all sites because I would like to upload my own smilies and random images as well.

    The code you gave me gives me the ability to replace the default wordpress smilies (and change format to png which I might actually decide to do because it comes out smoother). I would also like to add my own smiley text code that links to my own smiley image.

    I saw on a site one way you can upload your own custom smilies + smiley text code - so say for example I created my own smiley such as dance.png and I wanted users to type :dance: to bring up the smiley - the way to do it would be to go to:

    then where it says:
    $wpsmiliestrans = array(
    I can add my own smiley text codes and smiley image such as:
    ':dance:' => 'dance.png',
    ':tired:' => 'tired.gif',
    ':bullet-point:' => 'bullet-point.png',
    Then I would have to do add images to the wp-includes/images/smilies as well.

    I don't suppose you would know how to do this in a file in mu-plugins instead of wp-includes/functions.php?
    I'm not good enough with php to figure that one out.

  7. See the plugin I linked to? You'll have to reverse engineer that and fork it. Because I don't know how to do it off the top of my head.

  8. rec19
    Posted 2 years ago #

    Ok, i'll see if I can do it

  9. rec19
    Posted 2 years ago #

    Ok, I would like to mention I'm pretty useless with php, I get php code snippets from codex.wordpress and various sites.

    I was messing around with the code all day and I finally managed to get it to work, does it look ok to you?

    Iv'e got this at the top:

    add_filter('smilies_src','custom_smilies_src', 1, 10);
    function custom_smilies_src($img_src, $img, $siteurl){
    	return 'http://my-website/smilies/'.$img.$type.'';

    and I took a section of code from that plugin and put this just below it:

    global $wpsmiliestrans;
    $wpsmiliestrans = get_option('clcs_smilies');
    if ($wpsmiliestrans == false) {
    	$wpsmiliestrans = array(
    	':custom1:' => 'custom1.png',
    	':custom2' => 'custom2.png',
    	':test1:' => 'test1.gif',

    This allows me to add my own text codes + smilies and then upload my custom smilies to my own directory and it seems to work ok.

  10. The logic looks good :)

Topic Closed

This topic has been closed to new replies.

About this Topic