Support » Fixing WordPress » [How to] wp_grins in 2.1

  • The old instructions won’t work for 2.1, as a number of changes have been made.

    To get your clickable smilies into the edit page, you now need to edit wp-includes\general-template.php. As of the latest RC code, look around line 825 for:

    <script type="text/javascript">edToolbar()</script>

    On a new line below this, add:

    <?php if (function_exists('wp_grins')) wp_grins(); ?>

    Save and upload the file, making sure you kept a copy of the unedited version.

    The next change is because of the way smilies are being translated. Amongst other things, if your codes are not surrounded by spaces, they may not become smilies in your posts. To fix this, you need to edit wp-grins.php, so that it pads the smiley codes with spaces. Find line 34 and change it to this:

    $grins .= '<img src="'.get_settings('siteurl').'/wp-includes/images/smilies/'.$grin.'" alt="'.$tag.'" onclick="grin(' '.$tag.' ');"/> ';

    The only change (other than the same change of path needed for WP 2.0) is that this will insert spaces before and after the value of $tag.

    This won’t help with old posts and comments – their smilies may or may not appear, depending on spacing, and other factors.

Viewing 10 replies - 1 through 10 (of 10 total)
  • If you do find old posts’ smilies are appearing as “:)” or “:(” instead of your nice emoticons, first make sure that they’re in the right place:


    If they are, then you’ll have to edit the posts to make them appear. If you have :) defined as a smile, it may not appear. To make sure it does appear, it needs to have spaces around it. So you’d have to change every instance of :) with [space]:)[space]. (Actual spaces, not the word space, of course!) Doing that by hand could take ages.

    However, if you are careful and you have at least one backup of your database, you can use the Search and replace plugin to edit all your posts and comments in one go. It worked on my test site.

    If you do want to try this, make sure you have a backup of your database first. It should be perfectly safe, but odd things can happen…

    Alex has now updated WP-Grins so that it not only works with WP 2.0.x and WP 2.1, but it is no longer necessary to edit any core files.

    Woo hoo!

    Unlike the old this new version does not appear to allow you to add clickable smilies for commenters at your site. How can you make the WP-Grins work for commenters now?

    Even though I have the latest version of this plug-in, some of my smilies are still not showing up when they used to before the upgrade to 2.1

    Hey, I’m having the problem with needing the space before the smilies in the wp-grins. I copied and pasted the code given in the first post here, but I got T_CONSTANT_ENCAPSED_STRING error from it. I’m not too familiar with PHP, so I’m not exactly sure what’s wrong. If someone could please correct the code or tell me another way to have the space inserted, please tell! Thanks. =)

    Looks like the forum mangled the code a bit. Let’s try again:

    $grins .= '<img src="'.get_settings('siteurl').'/wp-includes/images/smilies/'.$grin.'" alt="'.$tag.'" onclick="grin(\' '.$tag.' \');"/> ';

    That did it – the first version lost the \ characters.

    Perfect! Thank you! =)

    It works with comments, BUT when i post an article and use wp-grins, I click on one smiley and press the publish button, but all i see is:
    :rockon: :saddam: 🙁
    The problem seems to be solved when hit the backspace and type the first “:”, as if I’m really “typing” the string. Looks like wordpress doesn’t parse the grins as smilies 🙁

    (This is not 2.1 material since there still are problems)

    I cant even get mine to work, can someone tell me how, I followed the instructins the best I could and after that I noone was able to add comments to the site so I took out wp_head from comments.php and changed id = “comment” back to id = “comments” and now people can add comments again. The instructions are not in depth enough for people to use it.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘[How to] wp_grins in 2.1’ is closed to new replies.