Hikari Enhanced Comments
Hikari Enhanced Comments enhances comments with features that make comments more visible and and becoming more exciting in website structure.
Things that you've been wanted to do, now can be done much easier.
- Introduction
- Features
- ScreenShots
- Download
- Donate
- Installation
- Installing and configuring ip2nation
- Adding flags to your theme
- Upgrading
- Uninstalling
- Support & Requests
- Frequently Asked Questions
- Versions
- To-do stuff
- Thanks
- Related Posts
- Comments (17)
Features
- An Enhanced Recent Comments widget, based on Wordpress core widget, but redesigned to make it possible to show at least 60 last comments.
- Widget also allows to exclude users from having their comments shown, perfect for website owners and authors that really participate on their site's comment debates
- If you also have Hikari Titled Comments plugin installed, comments with titles have their titles listed
- Comments authors have their gravatar shown in the widget
- For pingbacks, their gravatar is replaced by a "P" icon
- A Most Commented Posts widget, that lists your posts with higher number of comments
- If you have ip2nation installed (see installation instructions), comment authors are also shown with a flag of their country, in Recent Comments widget and in comments area
- Country flags can be added anywhere in your site, you just need to tweak your theme and use your imagination
ScreenShots
- Wordpress core, default Recent Comments widget
- Hikari Enhanced Recent Comments widget, showing all comments
- Hikari Enhanced Recent Comments widget, excluding my comments!
- When Hikari Titled Comments plugin is used, comments' titles are shown!
- Hikari Enhanced Recent Comments widget config interface
- A comment author
- A comment author with his country flag
- Here's ip2nation Diagnose when everything's working
- Hikari Most Commented Posts widget
License
© Copyright Hikari (http://wordpress.Hikari.ws), 2010
If you want to redistribute this software, please leave a link to this post together with it and mention me as its author
Parts of this code are provided or based on ideas and/or code written by others
If you want to extend the plugin features, please contact me so I can add your work to my official release.
Download
You can follow Hikari Enhanced Comments updates and older versions at Wordpress.org Plugin Directory (http://wordpress NULL.org/extend/plugins/hikari-enhanced-comments/), or you can get the last version from the direct link hikari-enhanced-comments.zip (http://downloads NULL.wordpress NULL.org/plugin/hikari-enhanced-comments NULL.zip).
Donate
There are also several ways you can show your appreciation:
- blogging about it
- linking it from your site (without using rel=nofollow)
- browsing the site sidebars
- suggesting it to your friends
- visiting other posts thru the site and adding valuable comments
- saying thanks on comments
- offering codes that add new features
- etc, use your imagination
Installation
Hikari Enhanced Comments requires at least Wordpress 2.8 and PHP5 to work.
You can use the built in installer and upgrader, or you can install the plugin manually.
- Download the zip file, upload it to your server and extract all its content to your
/wp-content/plugins
folder. Make sure the plugin has its own folder (for exemple/wp-content/plugins/hikari-enhanced-comments/
). - Activate the plugin through the 'Plugins' menu in WordPress admin page.
- Now you can go to widgets admin page and you'll find 2 new widgets available: "Hikari Enhanced Recent Comments" and "Hikari Most Commented Posts"
Installing and configuring ip2nation
ip2nation (http://ip2nation NULL.com/) is a website that provides a MySQL database table, listing all world's IPs and relating them to their respective country, together with each country name and code.
This table is provided in a downloadable .sql file. I don't add this table together with the plugin because it's updated from time to time, so it's better to just get it from the source and install it.
You are not required to have ip2nation installed to use Hikari Enhanced Comments. The plugin uses it just to get country flags. If ip2nation is not available, or if you are not able to install it, all other features from the plugin will still work, only flags won't be shown (the place where they'd go will be blank, don't worry with broken code .
ip2nation download
First of course you must download the file. You can go to their home page (http://ip2nation NULL.com/) and follow the 'Download' menu, or just download it directly: http://ip2nation.com/ip2nation.zip (http://ip2nation NULL.com/ip2nation NULL.zip).
Once you have the file, you must upload it to your database. But here's a cool feature: since its tables are so big (somewhat 3MB the uncompressed .sql file, and 1MB after importing to MySQL) and rarely updated, I provided a way to add it to a different database, separated from your Wordpress one. Doing so, you're not forced to back it up together with your website content (after all, it's not a relevant data worthy backing up, if you lose it you can just download it back from their site), and also if you have multiple sites you can have it stored only once.
If you wanna have ip2nation in the same database as your Wordpress install, just use it to import the .sql file. If you wanna use a different database, I suggest creating a new one only for it. The trick is to assign over this new database, full access from your Wordpress database's user (you can find its name in Wordpress config.php
. If the same user can access more than 1 database, it's easy for MySQL to provide simultaneous access to all of them. And if your Wordpress database user only has access to these 2 databases, and ip2nation table only has this data, you shouldn't have security issues. To know how to assing user permissions to databases, please call your webhost provider. Don't install each table in separated database, ip2nation tables can be separated from Wordpress but both tables must be in the same database!
As I've said, ip2nation database is big, I had trouble uploading it with phpMyAdmin. I just split the file in 3 and imported them separately, it's just 2 CREATE TABLE in the begining and then a bunch of endless INSERT INTO. If you have timeout trouble, try splitting it in more files, or again request your webhost assistance.
phpMyAdmin after importing ip2nation tables
Once you have your ip2nation database created, configured and populated with its data, and database user has privilege to it, go take a look if data was imported correctly. It creates 2 tables, ip2nation with more than 40.000 records, and ip2nationcountries with somewhat 250 records.
ip2nation Database option with its database name, I was only able to define part of its name
Now, to finish ip2nation installation, you must go to Hikari Enhanced Comments admin page, and under 'ip2nation Database' option, set ip2nation database name. If you just installed it in Wordpress database, leave this option blank. If it has its own database, the full database name must be added here. Pay attention because many shared hostings only let you define part of databases names and hide the part you can't change, make sure you're using the full name here.
To help you diagnose ip2nation and see if flags and countries are working, in this same page there is a section just below options where you can see it working. This section uses a testing IP from Brasil to query ip2nation tables, and if it was configured correctly you'll see its country code as 'br' and country name as 'Brazil', and just below you'll see Brasil's flag.
If you see all these info, you are good to go, gratz! If you see Brasil name and code but doesn't see its flag, assure you have properly extracted the plugin. If it was installed in /wp-content/plugins/hikari-enhanced-comments/
, you should have a folder /wp-content/plugins/hikari-enhanced-comments/flags/
and inside it a bunch of files with those flags.
And if you don't even see Brasil's name and code in diagnose, then ip2nation is not properly configured. Verify its database again, and then assure Wordpress database user can access it. If you have any trouble setting up your tables, or flags are in their place but are not accessible, please again go to your hosting provider ask for assistance.
Adding flags to your theme
You don't need to tweak your theme to have flags shown in it, Hikari Enhanced Comments adds them automatically to your comments authors. In the plugin admin page you can choose if flag should be added before or after author's name, where it better fits your theme layout.
But you can also add it manually, if you want a more customized layout. For that, just use the function HkEC_flag($ip)
, where $ip
is the IP whose flag you want. Flag image will be echoed automatically.
If that IP is from a comment author, you just use kEC_flag($comment->comment_author_IP)
and you are done.
Upgrading
If you have to upgrade manually, simply delete hikari-enhanced-comments
folder and follow installation steps again.
You don't need to touch ip2nation tables once they are installed, but since they are updated from time to time, you may want to update them to have info about all IPs. In this case, just import the lastest .sql file to your database.
Uninstalling
I've made an article just to explain in full details which options we have to upgrade and uninstall our plugins and what happens with each option, and how it works with my plugins: Uninstalling my plugins.
Plugin uninstall feature doesn't delete ip2nation tables, regarding if they are in same database as Wordpress or in a separated one. If they are not used anymore, currently you must delete them manually if you don't need them anymore.
Also, make sure to delete plugin's widgets before uninstalling the plugin. ATM it's not deleted upon uninstalling, I'll fix it in a future version
Support & Requests
If you want to request any new feature, leave a comment on this post explaining it with as many details as possible. I can't assure it will be added, but if it is viable, I like it AND have the time, I'll do my best.
If something seems to not be working and you need help, first read the FAQ and then leave a comment explaining what's happening. If you need to post a picture, please link it instead of using an img tag.
FAQ
-
Is "Hikari Enhanced Recent Comments" widget related to Wordpress core "Recent Comments"?
Well, in parts. PHP code is totally independant, but based on it. But it uses compatible CSS classes, so it shoud fit to theme layouts.
-
Can I use both core "Recent Comments" and "Hikari Enhanced Recent Comments" widgets together?
Sure! You can use them together and as many times as you want!
-
Is your titled comments plugin required to use the widget?
No, my idea isn't to force somebody to use them together.
Indeed, Hikari Enhanced Comments was first idealized to be part of Hikari Titled Comments, being implemented on a future version. But when I started coding it, I saw that core "Recent Comments" couldn't be simply extended (I did that ), and using filter wasn't enough for me. Code was becoming too big and getting out of "titled comments" scope, and also there was ip2nation to be installed separated, so I decided to port these features to a separated plugin and make both compatible.
If both are available they work together, but they work alone pretty fine too.
-
Your titled comments plugin requires WP 2.9, and this enhanced comments requires 2.8, strange!
All my plugins require PHP5 because I use OOP, and WP 2.8 because I use
settings_fields()
.Hikari Titled Comments requires WP 2.9 only because it uses comments metadata. Even though Hikari Enhanced Comments supports Hikari Titled Comments, it only uses its functions, it doesn't go over comments metadata directly, and since Hikari Enhanced Comments doesn't use metadata code, it works with WP 2.8. Remember these plugins work together but they don't require each other to do their own job .
-
I've looked on HTML code your widgets generate, and noted they use ordered lists, but ERC shows no list marking and MCP shows a disc mark instead of number marks. Why did you do that?
I like to use correct semantic markup and nice styles on the same time. Both widgets list some content sorted by date or amount, so they are ordered lists, and not unordered. But, Recent comments, even more when titled comments are present, don't fit well with list marks, while Most Commented Posts wouldn't be nice being listed with numbers. Well at least in my theme.
These styles are added directly to the HTML document, in 'wp_head' action, that's the same behavior of Wordpress Core's Recent Comments widget. If you wanna change it, just add your own style in your theme's style.css and override them. :)
-
You your ERC widget allows to exclude users from being listed, but MCP doesn't?
It's all database related. For Recent Comments, it's just a matter of defining comment's autor to be excluded, and MySQL does the trick easily because each comment has its author name on it.
For Commented Posts, on the other hand, each post has a field informing how many comments it has, and this field is easy to use. If I'd make specific commenters be excluded, I'd have to ignore this field, make a join between wp_posts and wp_comments based on post ID, and then exclude each comment whose author name matches those defined to not be counted. This SQL query would be much heavier and I believe it's not worthy. We could use cache to store the query and avoid it being done on every page load, but that would require another plugin to handle cache persistence. Explaining all this (or even worse, explain somebody why his site's page load became a bit slower upon using the widget) wouldn't be nice. Maybe someday I implement the feature, or if somebody asks me for it.
-
What happens if I don't have ip2nation tables installed and working?
What the plugin does with that is query it for a country related to a IP. If tables are not accessible for any reason, the query will return with error and it'll be ignored.
Without the country code, the flag URL can't be created, generating an error. And even if the code is found, if for some reason the flag can't be accesses, same error will happen.
This error is verified, and if flag is available, its code is generated and provided. But if flag is unavailable, it will just return a harmless blank string. In HTML document there will be no track of it, and user will just see nothing where the flag would be placed.
Of course, if you are adding the flag or relying on country code or name in your theme, you must be prepared for not receiving them, due to some error or simply the plugin not being active.
Cangelog
- 0.03 - 08/06/2010
- New widget: Most Commented Posts
- Added country name to flags title attribute (popup)
- Recent Comments widget: fixed minor widget saving code
- Small code cleanups
- 0.02 - 30/01/2010
- First public release.
Known bugs
- none ATM
To-do stuff
Here are my ideas that I wish to implement in the future.
- Move Recent Comments code to its own static method, so that it can be called anywhere, regardless if it's a widget or not.
- Add option to not include pingbacks in Recent Comments.
- Add option to include a small excerpt of comment in Recent Comments.
- Create new function to easily gather other country data, that's provided by ip2nation.
Thanks
First of all, thanks to people that created and maintain ip2nation, I can imagine how hard it is to keep IP table and countries data, and assure their accuracy!
Thanks again for Wordpress developers, that make an engine so easy to develop over. Having widgets abstracted as classes make it much easier to develop, and also sidebars are great to provide blocks of contents (the widgets) everywhere in the site!
And of course, thanks to everybody that add comments to my site!
Popularity: 100%
It has accumulated a total of 155,593 views. You can follow any comments to this article through the Comments RSS 2.0 Feed. You can leave a comment, or trackback from your own site.
Plugin
I downloaded your plugin but for some reason…it’s not working.
I downloaded the sql file…only appears 1….ip2nation..where do i dave it? An any particular folder? Just in the public_html??
Pleas if you can help me…thanks!!feedback
ip2nation
marketing
Are you having trouble installing ip2nation? Did you try the tutorial I provided, "Installing and configuring ip2nation"?
It’s 1 sql file, yes. You don’t store it with your site files, you import it into the database. How to import it depends of the software you use to access the database, phpMyAdmin has an "import" option in top menu. The easiest solution if you aren’t able to import the sql file is to open a ticket on your webhost provider (http://my NULL.hawkhost NULL.com/aff NULL.php?aff=558) and ask for help, they’ll do it for you or teach you how to use the software they provide.
If they say that you can’t directly access your database… then move to another host :P
Once you have ip2nation imported, you go to plugin admin page
/wp-admin/options-general.php?page=hkEC
and add the database name in the first option, ip2nation Database.Try contacting your host and ask them to import ip2nation for you, then come back and tell me how it worked out ^^
participate
Re: ip2nation
I tried to upload the file through phpMyadmin into my cPanel (importing it)…didn’t work, an error message shows up…
After reading your reply I opened a support ticket, asking them if the can do it…
Once they upload it….do I have to write the database name or leaving it blank…?
Thanks for your reply..research
database name config
informationIf it’s the same database where WordPress is installed, leave it blank. If it’s another database you must add database name there.
Having it in a different database helps to backup, since ip2nation data doesn’t need to be backuped, and also if you have many sites you can have it on a unique place and all sites access it. Remember that WordPress database user must have access to that database too.information
ip2nation
Hi,
I uploaded the file successfully….(through a video tutorial)….but for some reason, flag didn’t show up…
I even added the database name in the blank field…and didn’t worked….am I missing something?
My blog is new and only has 1 comment..maybe I should wait for more comments and see what happens…right?marketing
Diagnose
In plugin admin page you have a diagnose area, where you can see if it’s working without database part.
If you are using the same database where WordPress is installed, the field must be blank. Only in case it’s a different database that you must use its full name there, and both databases must have the same database user.
WordPress’ original comment doesn’t have IP, therefore no flag is used. Internal IPs like 192.168.0.5 also don’t have flag. You must add a comment using a valid Internet IP or edit database adding one. If your IP doesn’t work, edit database comment_author_IP field with 201.9.158.252, it’s the IP used on admin page diagnose.
information
ok…the field is now blank…didn't work…………..I quit…I'm not a programmer and I don't know how to edit
"database comment_author_IP field"…..maybe your plugin needs some fixing…
And the comment is from one friend..not the WP comment….
Regards,
Diagnose
feedback
Well if it needs to be fixed, I must know what to fix, because it’s working for me and it’s the plugin I’ve been spending most time developing and enhancing recently;)
Country codes are provided by ip2nation based on IP, your IP for exemple is related to Peru. If country code is found, then flag image file URL and path are built. If flag files are in their place, their existance check succeeds and img HTML code is created and returned. If any of these steps fail, image isn’t found and it returns empty, so that no error or invalid markup is generated.
You said
, so I understood it wasw WordPress’ exemple. You must see if that IP is recognized by ip2nation, if you provide it to me I can test it. Or you can change it to a IP we know that works.comment_author_IP
is a field in tablewp_comments
in WordPress database.So, there are tests you can do to find out what’s wrong:
All these are stuff Hikari Enhance Comments just provides or explains how to get, its code just use these resources. In plugin admin page you have a whole diagnose panel to see if each step is working. If I find a bug in code I can fix, but I must know the bug, and ATM everything is working, as you can see in comments and widgets.
research
homepage
Hi,
ok… this is what I exactly did….
At this part…your plugin should work automatically…the test doesn't show the flag of Brazil..
What else can we do? Thanks
participate
Separated database
homepage
Much better :) , now I’m able to have idea of what happens on your site.
If you created a new database of ip2nation, your WordPress user database must be granted access to that new database, so that WordPress can access it and query IPs info. If needed, ask your host help to assure both tables are accessed by WordPress. In diagnose panel you can test it seeing if br code and Brasil name is presented.
And also, if you use a different database for ip2nation, ip2nation Database option must be set with that database’s name, so that SQL query knows which database to access. Pay attention that most hosts use a prefix for database names and don’t use exactally the name you provided, you must use the whole database name.
Try these 2 and see if it works :)
homepage
ip2nation
The database I created was "flags"…..so with the prefix is something like….. skdjdjd_flags
I do not have to write this on the field? do I?
I sent a message to hosting support…asking if they can verify the WP access to my database..
In cPanel, by default, each database has its own user. So, just creating a new database it won’t be accessible by WordPress. WordPress database user (set in wp-config.php as DB_USER) must have access granted to your ip2nation database. Your host can help you in that.
And plugin option must be set with this database name, yes :)
Additional Feature Inquiry
Hello Hikari,
I'm curious about the possibility of using commenter's country flags as avatars (instead of gravatar, etc) using ip detection. I don't know if you are available for freelance projects, but in case you are, you can contact at the email address submitted.
Regadrs,
Alex
research
Hello. Using the flag as avatar is easy to implement and doesn’t require theme support, I believe :)
I’ve mailed you. If you wanna hire me I can develop your request in a few hours, otherwise I’ll implement it in next plugin update.participate
test flag.
this is just a test. to see if my flag appears.
gravatar size
can i change the size of the gravatar?
how?
feedback
Take the exemple of my gravatar URL:
http://www.gravatar.com/avatar/eb64d01778e8c506c5be5254beb50ed3?s=50 (http://www NULL.gravatar NULL.com/avatar/eb64d01778e8c506c5be5254beb50ed3?s=50)
Note the parameter ‘s’, that has a value of ’50’. That’s the gravatar size. Just change it to whatever you want and the image file will have that size:
http://www.gravatar.com/avatar/eb64d01778e8c506c5be5254beb50ed3?s=128 (http://www NULL.gravatar NULL.com/avatar/eb64d01778e8c506c5be5254beb50ed3?s=128)
marketing