WordPress Plugin: Simple Ajax Chat
Simple Ajax Chat displays a fully customizable Ajax-powered chat box anywhere on your site. SAC makes it easy for your visitors to chat with each other on your website. There already are a number of decent chat plugins, but I wanted one that is simple yet fully customizable with all the features AND outputs clean HTML markup for easy styling.
Simple Ajax Chat is based on Jalenack’s Wordspew (aka AJAX Shoutbox), which I’ve been using on my sites since the plugin was released back in 2005 (ish). Wordspew works great even today, but it hasn’t been updated in seven years, so I decided to adopt and improve the plugin with fresh code, clean markup, better control, and more features. Here’s a screenshot showing the plugin used for an imaginary, rather egocentric chat:
Screenshot of chat-box display (view more screenshots)
Features
Simple Ajax Chat uses Ajax to enable new chats to appear without refreshing the page. The form works great even without JavaScript, but the page is refreshed for each new message. Here is an overview of the plugin’s main features:
- Plug-n-play functionality, no configuration required
- Display on any post or page with the shortcode
- Display anywhere in your theme template with the template tag
- Includes default CSS styles and enables custom CSS from the settings
- JavaScript/Ajax goodness loads new chats without refreshing the page
- Also works when JavaScript is not available on the user’s browser
- Clean markup makes it easy to style the appearance as you please
- New chat messages fade-in with custom duration and color
- Includes manage-chats panel for editing and deleting chats
- Links included in chats include `_blank` target attributes
- Includes complete map of all available CSS hooks
- Includes built-in banned-phrases list
- Automatic smileys supported :)
- On-demand restoration of all default settings
- Super-slick toggling settings page
One of my favorite new features is the built-in chat blacklist, where you can add any phrase from the settings page and have it magically disappear from the username, chat input, or URL (if enabled). With the old plugin, I had to modify the source code to block stuff, but now it’s all handled from the comfort of the WP Admin.
Customize everything
The Wordspew plugin included a minimal set of options, which is one of the reasons I found it so useful. So I wanted to keep that simplicity while adding some much-needed features. It’s a balance that I think stays true to the original. Here’s a list of things you can customize with Simple Ajax Chat:
- Customize the update interval for the Ajax-requests
- Customize the fade-duration for new chat messages
- Customize the intro and outro colors for new chats
- Option to require login/registration to participate
- Option to enable/disable URL field for usernames
- Option to use textarea for larger input field
- Customize the default message and admin name
- Customize the appearance with your own CSS
- Option to enable/disable custom styles
- Option to load the JavaScript only when the chat box is displayed
- Add custom content to the chat box and chat form
- Built-in control panel to edit and delete chats
- Built-in blacklist to ban specific phrases from the chat
Installation & Usage
Activate the plugin and visit the SAC settings page to customize your options. Once everything is customized as you like it, display the form anywhere using the shortcode or template tag.
Shortcode & Template Tag
Use this shortcode to display the chat box on a post or page:
[sac_happens]
Use this template tag to display the chat box anywhere in your theme template:
<?php if (function_exists('simple_ajax_chat')) simple_ajax_chat(); ?>
Screenshots
Here are some screenshots of Simple Ajax Chat in action (using default settings):
- Chat box displayed on Twenty Eleven theme
- Settings page (panels toggled closed)
- Settings page (panels toggled open)
Demo
Download
Download Simple Ajax Chat via the WordPress.org Plugin Directory:
70 responses to “WordPress Plugin: Simple Ajax Chat”
Hi Jeff, my comment from yesterday has disappeared…
Anyway, I’ve been looking why when I press Enter, the message is not sent. I checked your code:
function pressedEnter(field,event){
var theCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
if (theCode == 13) {
sendComment();
return false;
}
else return true;
}
And the thread you refer to: http://www.codingforums.com/showthread.php?t=63818
Maybe it has something to do with that. The code is from 2005, maybe now it could need some change?
Since I don’t know how to code, I’m just suggesting, if it is of any help… Thanks! :)
Yes, sac.php is loaded!
‘Enter’ doesn’t work on FF nor on IE.
Hope that helps (see my previous comment, published after your reply).
Yes it does. I just checked the demo (linked in previous comment) in the following browsers:
PC / IE 8
PC / Firefox 3.6.25
Mac / Firefox 17.01
It sounds like something else is interfering with normal functionality, which you can easily verify on a new/default installation of WP. I’ve actually tested the plugin in many other browsers as well, and they all seem to work great.
I’m sure your plugin works fine on a new/default installation of WP (I asked a friend to check and it does), unfortunately, I’ve installed your plugin on a working WP site so I guess something is indeed interfering with normal functionality…
Don’t you have any idea what could cause the keycode not to work? Could it come from the CSS I modified? I’m stuck here, your plugin is so simple it’s great, if only the Enter key would work…
Thanks for your great work on this plugin and your help, much appreciated!
Sure, I have lots of ideas, but with a family of four, a mortgage, 80+ hour work week, and a life to live, my time for pro bono is limited.
Off the top of my head, I would try disabling all other plugins and seeing if that helps. Then I would do some tests to ensure that the JavaScript is working, and then after checking anything else that I could find, would set up a test install of WordPress and build things up until the point of failure is discovered.
Or I would just move on and find another plugin ;)
I have alot of spammers (posting random stuff) is there something i can do about that? or maybe add a rule that they must match a number>? 3 + 4 = ?
A good way of stopping spammers is to require login to chat. An alternate solution is to blacklist key terms via the plugin settings.
Hi Jeff, great thank you, i tried several chat plugins but this one worked in 2 seconds, big smile anne
Hi Jeff, when I send a message my browser refreshing the page , what can cause this bug ?
Never mind, just fixed it lol
Is there a way to make more than one chat room on a single website
Hi Cedricle, no SAC wasn’t designed for multiple chat forms.
is there a way to show who is online in the chat?
Not currently, but it’s a good idea that I’ll try to implement in the next version.
Please can we auto delete after some minutes all the chats?
Yes, please see this post: https://wp-mix.com/wordpress-cron-tips/
Another question ! It’s possible the persons don’t write anything or forgot to put the name , but the chat don’t show error?
Only by using the plugin settings, some aspects of this are possible, but you may also customize with code according to your specific needs.
first of all thanks for the answer, just another thing, what I have do change in the code you show to change from delete the chat in one hour to for example 3 minutes, or 180 seconds?