ars aranea. the web, the way we make it. | |||
20 Taming WordPress smiliesPosted: Nov 26, 2005, under WordPress. Updated: Jul 19, 2007. Add a comment!The emoticons used by WordPress can be a rowdy bunch. Read this to learn how to replace them with your own smilies, and, most important, how to control the way they behave and look.
1. IntroductionSo, what’s the problem with smilies? First of all, you may not like how they look and/or what codes they respond to. Perhaps, like me, you’d like some emoticons that integrate better with the colors on your blog, or you’d like to be able to use Furthermore, if you’re using a plugin such as my Smiley JS Buttons 8), and if you have more than one code for the same smiley, it’s pretty hard to guess which one will actually be used when you click the smiley button. They seem to use a logic all of their own. 2. Explanations for expertsThis is a small run-through for the more advanced WP users. If you’re a PHP (and WP) veteran, the pointers below are all you need. If you’re an amateur, you’d better jump straight to the examples, below. 2.1. The WP source codeThe good news is that there’s only one file that needs to be modified, and that the modifications are rather simple. It’s Even better news: this file holds special blog configuration which doesn’t change when you upgrade WP, so it will never be overwritten when you upgrade WP. The correspondence between emoticon codes and actual smiley images is done with an array, There’s also a function, Although not widely known, WP versions 1.5.x and 2.x already expect and allow you to define both the function and the array in
2.2. The smiley imagesThe images are held under Unfortunately, this path cannot be easily changed, as it is used hardcoded in several places (not counting plugins). This means that if you want to change the default set you will have to rename or delete the directory and replace it with a new
3. Actual examples (for everybody)3.1. Just changing the default imagesYou don’t need to mess with Be careful what images you choose. If you use images that are too big, they will produce gaps between the lines of your text. If they are too small, people will have trouble understanding what they mean. Also try to pick some images that can be recognized easily. The default images may be a bit on the ugly side, but at least they are small and easily recognizable. 3.2. Changing both the images and the codesThis second example is a bit more complex, but it will let you do more things with the smilies. Suppose you’ve just downloaded a set of Becca’s smilies. Their names differ quite a bit from those in the default WP set. Plus, you want to assign them more sensible codes, but also keep some of the most widely used. Also, it wouldn’t hurt if you could control what codes are produced when you use my Smiley JS Buttons. You probably already know what to do with the images: backup the original Now, edit
You have to go between them and add something like this:
Some explanations are probably in order. :) There are two parts in the example above. First, we have a part which defines a function called The array is what you really care about. It contains pairs formed with emoticon codes and actual images. Basically, it says “if this code is found, replace with this image”. The images are taken from the well known directory, of course. As you can see, you can give the image files whatever names you want, as long as you tell WP what they are. Even better, you can define many different codes for the same image. So now you can get crazy, hack and slash the thing and put anything you want in there. 4. Some words of warning4.1. Choose your codes carefullyFirst, think carefully about what codes you choose. Those codes will be used both by you, in the posts, and by other people, in the comments. Once people use some codes, they are put in the body of either the posts or the comments and that’s it. If someone enters Secondly, you should also leave in some of the most common codes, those that people have come to expect, such as smile, sad, cool, grin, wink, blank, cry, tongue; you know them. Many people will use them by reflex, because that’s what they use all the time in email and chats. Thirdly, mind those extra spaces in front of the “classical” codes. You may notice that they have an extra space in my example. That’s a good idea, because it’s very easy to have, for instance, an 8 (eight) next to a round bracket “)” and make a “cool” face when you actually just wanted to put a number between brackets. 4.2. Using Smiley JS ButtonsIf you use this plugin, there’s an extra precaution you must take. The plugin can only use one of the codes, if there are more than one for the same image. It will always use the last one, as they appear in the array above. So take care to arrange them properly and to test what comes out when you click the smiley buttons. Note: the general order doesn’t matter. What matters is just the relative order of the codes that produce the same image. If you know PHP, the explanation is simple: the plugin uses 5. I’ve messed up! I want the default back!Oh, alright. Here’s what you have to do:
That’s it. Once you have the config file with the modifications undone and the original smilies back, WP will behave just like in the beginning. You can now start messing with it all over again! :) 6. Tips and tricks6.1. Vertical alignment for smiliesThis is actually useful for all small images that you have throughout the site, such as RSS icons, not just smilies. You may have noticed that sometimes they appear misaligned vertically, usually too high compared to the writing around them. The fix is a simple CSS statement, which should go into your
However, you may need to tweak it a bit. It may affect other images that you don’t want it to if you add the statement as is. Depending on the situation, you may wish to limit its scope to only certain zones on the page. One example would be just the sidebar, or just the content, or just the comments. How exactly to accomplish this depends on what identifiers those page parts are using. An example:
…which states that only images inside the You can also try adding
| Important
Categories
Authoring
(1)Books (2)Cross platforms (2)DHTML (12)Graphical design (3)IT today (12)Morals&Politics (10)ODP (1)Random stuff (3)Romania (16)Security (7)SEO (2)Software (9)SQL (1)Standards (7)Technology (4)WordPress (4)[În română] (5)[This website] (2)Time-jump Syndication Need hosting?I've been a happy user of LunarPages since 2005. |
||
Copyright ©2005–2010 Zuavra | |||