Highlight Author Comments
Purpose
Highlight Author Comments automatically displays comments made by a post’s author in a distinctive style with no need to edit your template files, etc. All you do is provide a snippet of CSS styling to be applied to author posts.
This is version 1.0.0
.
Installation Instructions
Highlight Author Comments is installed in 3 easy steps:
- Unzip the “Highlight Author Comments” archive and copy the folder to /wp-content/plugins/
- Activate the plugin
- Use the Options > Highlight Comment admin page to enter the CSS styling you want to apply to author comments.
Frequently Asked Questions
What Do I Enter in the Options Page?
The plugin Options page just has one text box where you put the bit of CSS you want to apply to highlighted comments. Don’t include { or }: just the CSS. For example, by default the plugin applies the CSS padding: 1em which ‘indents’ the comment a little all round. If you wanted to also make the text red, for example, you would use color: red; padding: 1em.
CSS Styling… What’s That?
Cascading Style Sheets (CSS) is too complex a subject to go into here. A good resource is provided by the Web Design Group.
How About Some Examples?
Here’s where some artistry would be a help! In lieu of skill here are some examples to play with:
- padding: 1em;
- padding-left: 20px;
- background-color: #FFFF95;
- border-left: 1em solid #DDD; padding: 1em;
- background: white url(http://www.yourblog.com/images/fluffy-clouds.gif)
- background-color: silver; margin-left: -2em; padding: 1em 1em 1em 2em;
- etc.
How Does It Know Which Comments to Highlight?
The plugin simply compares the email of the post author with the email of the commentor. This works fine as long as a post author is logged in when commenting. It will fail if the author is not logged in an uses a different email.
77 Comments Add your own
1. anton | October 21st, 2007 at 7:52 am
??????, ???????? ?????
2. Chuchu | October 25th, 2007 at 8:55 am
Because it’s hard to modify php files for em, I’ve wanted this.
I just applied this plugin to my blog(wp 2.2.1) and it worked fine. Thank you for the plugin.
3. dogorgod | October 25th, 2007 at 9:51 am
非常好用,谢谢~
4. jez | October 25th, 2007 at 12:26 pm
would like to use it, but the zip file is broken. tried downloading twice. thanks a lot for your work, great idea.
5. Rob | October 25th, 2007 at 12:41 pm
jez: It should be fine now… I was testing a new caching plugin and it was corrupting downloads. Thanks for the heads up.
6. David Lancelot Sjövall | October 25th, 2007 at 1:41 pm
Great and EASY plugin. I totaly love it!
7. jez | October 25th, 2007 at 1:59 pm
thanks, using and loving it on my page e.g. http://www.h4×3d.com/motorola-razr-v3i-software-usb-driver/
works like a charm!
8. John Kolbert | October 25th, 2007 at 2:32 pm
Hey, this looks like a nice plugin! I’m going to try it right now. Nice work!
9. Sergio | October 25th, 2007 at 3:23 pm
Thanks for the plugin man!!!
10. Rolando | October 25th, 2007 at 5:41 pm
Very cool, thanks!
11. Chuck | October 25th, 2007 at 9:31 pm
Very nice plugin - Installed and worked as advertised.
Thank you!
12. Oliver Chesler | October 27th, 2007 at 12:32 am
It’s working on our blog. Thanks.
http://www.wiretotheear.com/
13. David Potter | October 29th, 2007 at 5:14 am
Very nice plugin. I’ve been wanting this feature on all my blogs, none of whose themes currently implement the feature. Thanks for doing this.
One problem I ran into was that you are doing an exact comparison of the email address. This only works if the email address is exactly the same, down to using the same casing. I implemented a modification to call strtolower when dong the comparison. You can see details here:
http://dpotter.net/Technical/index.php/2007/10/28/highlight-author-comments-wordpress-plugin-review/
Thanks again.
David
14. Rob | October 29th, 2007 at 9:15 am
David Potter: Thank you for the favourable review.
15. couchmouse | November 6th, 2007 at 3:15 am
Thank you for this plugin. I am using it on my site. WP 2.3.1
16. Schmelding | December 1st, 2007 at 10:37 pm
I’m very thankful for this plugin. Past plugins that I’ve seen like this were very limited because only one author per plugin could be specified. How you’re doing is how it should be done.
I’m not a big fan of inline styling, and it isn’t a “web standards” best practice. One item, or “feature request”, would be to allow for class or id assignments instead inline styling.
Also, being able to add a tag to a WordPress template instead of simply modding the comment_text() template tag. For example, being able to bold or color the author’s name would be a big benefit.
That said, again I think this plugin is awesome. Good work and thanks!
17. chada | December 2nd, 2007 at 1:14 am
Thanks for your work!
18. Rob | December 2nd, 2007 at 9:12 am
Schmelding: Thank you for your comments. I agree with you that inline styling isn’t to be generally recommended but in the context of a specific plugin I don’t see the problem. I decided against achieving the desired effect by adding a class because of the extra editing needed — I wanted the solution to be very simple for the novice.
I like the idea of extending the plugin to be more flexible about what it can style. Can you explain your ‘tag’ idea a little more clearly for me?
19. Caesar | December 19th, 2007 at 1:15 pm
How about a threaded reply option, like Better Comment Manager? I love the functionality of Better Comment Manager, but I refuse to use it because it doesn’t integrate with the Manage Comments page…
20. Caesar | December 19th, 2007 at 1:16 pm
Sorry - the above comment was meant for another blog! :(
21. Caesar | December 19th, 2007 at 1:17 pm
Sorry, the above comment was meant for another blog… :(
22. John | February 1st, 2008 at 12:07 am
When I use your plugin, the author’s first line shows up in a bigger font and the background color, when used, does not fill in the last line of the post.
I don’t know enough about css to figure out how to fix this.
It works fine when I replace the comment.php file for use with brian’s threaded comments, probably because the brian plugin uses a replacement css. Unfortunately though I have been unable to work out the many complications of using that plugin with my theme.
Interestingly your plugin also changes the background of all the comments, not just the author’s, when viewing the comments using the ajaxified “fold down” on the site.
You have a great plugin and I’ll keep trying to get it to work properly.
23. Rob | February 1st, 2008 at 10:45 am
John: Can you tell me what theme you are using?
24. John | February 2nd, 2008 at 1:08 am
I’m using MyJournal Hypereal
http://themes.wordpress.net/columns/3-columns/4021/myjournal-hypereal/
the home page for the theme seems to be having host issues, it currently has a suspended page.
my blog is here: http://www.d4v.org
25. Rob | February 2nd, 2008 at 12:27 pm
John: I’ve just been looking at the theme and it seems already set up to highlight author comments — at least it applies a style ‘bypostauthor’ to the right comments. All you should need to do is edit your css to do the job you want.
My plugin tries to do the task for themes which don’t distinguish between comments. It wraps a styled div around the comment text. In the case of this theme the comments are already quite highly styled and it looks like the styles from the two sources are not interacting well. If you want to keep on with the plugin try using different styles till you find something that suits. I suspect the background is not going to work given the theme’s use of a background image (unless you invent an alternative one) — try just changing the colour of the text enough to stand out. Since the comment text looks slightly grey you could try ‘color: black’ for a start. Or you could pick up the blue colour you use for titles etc.
Good luck!
26. John | February 2nd, 2008 at 1:50 pm
Thanks very much for your comment and help, Rob. Formatting ‘bypostauthor’ accomplished the task and tool care of the issue.
27. get it from Boy! | February 3rd, 2008 at 2:28 am
what’s surprising is that i don’t see any comment highlight by the author of this blog in this comments section! isn’t it ironic…
28. Rob | February 3rd, 2008 at 9:44 am
get it: It’s probably a contrast problem in your browser.
29. Michael Aulia | February 8th, 2008 at 12:04 am
The simplest plugin to use!
If you can just use a multi-line text area for the CSS Styles for Author Comments field, it’ll be much easier to customize the CSS style :)
30. Rob | February 8th, 2008 at 10:14 am
Michael Aulia: Thank you. I agree with you — a textarea is probably better.
31. Shanx | February 8th, 2008 at 11:58 am
Quick question Rob. I think the way your code recognizes an “author” is based on the WP world, where the user’s email is registered. So this is the code you have:
if ($comment->comment_author_email !== get_the_author_email())But for those of us who are importing our blog content from Movable Type or EE or something, this may or may not always apply.
So I’m trying to modify the code you have in this simple but elegant plugin, as follows:
The idea being: try to recognize the user from whatever method we can. But this isn’t working. Any ideas or thoughts?
32. Rob | February 8th, 2008 at 3:40 pm
Shanx: I think your mods may work if you use strpos instead of stristr… check for strpos(…) !== false.
33. Shanx | February 8th, 2008 at 5:30 pm
Brilliant, it works! Thanks.
My only minor wishlist for this is that the DIV tag is wrapped around only the comment-text, not the whole comment with name, email, etc. I suppose that’s tought to do without too much hacking?
I’m happy as it is. Thanks!
34. Rob | February 8th, 2008 at 6:16 pm
Shanx: I agree with you but since I’m injecting the CSS via a WordPress hook I couldn’t find anything else suitable. If you have a brainwave let me know.
35. mus | February 12th, 2008 at 4:19 pm
I built the feature into this template I’m making. Will users have a problem if they have my template and your plug in?
36. Rob | February 13th, 2008 at 10:29 am
mus: It would be best if they deactivated the plugin but the worst effect should just be some unwanted styling. The default extra styling is just a little extra padding.
37. Jennifer | February 15th, 2008 at 6:39 am
I’ve tried nearly 5 different ways of doing this, yours was by far the best talked out version to get me through it all. Thank you for finally making me understand this!
38. Mona | February 15th, 2008 at 8:13 pm
Thanks for the very simple plugin !
39. onimaru | February 19th, 2008 at 12:33 pm
it’s really a good plug-in!
I have longed for it so long.
thanks.
40. OllieMag | March 16th, 2008 at 6:57 am
Using it on my site right now, http://www.olliemag.com
41. wildfire | March 25th, 2008 at 5:59 pm
Rob - I’m trying to do the same mod that Shanx mentioned above but it’s not working for my site. Can you repost what the PHP code will look like if you inserted Shanx’s strpos comments into the code section below? Thanks!
function hac_highlight_comment($content){
global $comment;
if ($comment->comment_author_email !== get_the_author_email())
return $content;
else {
$options = get_option(’hac_highlight_author_comments’);
return ”.$content.”;
}
}
42. Rob | March 25th, 2008 at 9:33 pm
wildfire: It is hard to do that kind of thing in general. Shanx wanted to hard-wire some tests for specific substrings that identified himself. Basically he replaces the line:
with
Does that make sense? You would probably want to force both sides of the comparison to lower case too.
43. wildfire | March 26th, 2008 at 12:20 am
Rob - thanks for that. Not sure what you mean by “force both sides of the comparison to lower case”, but this is exactly what I was trying to do with my code. Unfortunately it had the opposite effect - highlighting the comments that I didn’t make and leaving those that I did untouched. (obviously I changed the ’shanx’ to my full email address in the example you list above) I’m not very knowledgeable about PHP, but would love to get your thoughts on this if you have any - as I’m also moving my blog from TypePad to WordPress and want to make this really cool feature retroactive for all my old posts!
44. Rob | March 26th, 2008 at 7:36 am
wildfire: Sorry, replace the ‘!==’ in the comparison by ‘===’ and the right posts should be highlighted.
45. wildfire | March 27th, 2008 at 4:08 pm
Rob - this works, but not as I had hoped. I was under the impression that Shanx’s string above worked if ANY of the three STRPOS strings were true, but it only seems to work if ALL of the three strings are true. Any suggestions as to how I can make it work, say, if the name and URL match but not the email? (in TypePad, I never asked for emails, so this data wasn’t collected - but in WP now is - so I’d like this flexibility)
46. Rob | March 27th, 2008 at 9:35 pm
Maybe…
47. elf_fu | April 1st, 2008 at 2:20 pm
Thank you very much, not only for designing a plug-in that’s extremely easy to use, but one that is needed (as I see it.)
I’m using it now and happy too! :)
48. eric | April 5th, 2008 at 4:37 am
hi rob, thanks for the plugins. im using the recent comments / similar posts and this one… simplistic and excellant! :)
im not sure if you’ll be able to assist… though in regards to this plugin… is it possible to modify this script and add a “avatar image” as well?.
thanks again!
49. Rob | April 5th, 2008 at 3:29 pm
eric: At present all the plugin does is wrap the comment content in a styled DIV. It would be possible in a similar way to slip some code, like a gravatar call, before/after the content. Would that do what you would like?
50. eric | April 7th, 2008 at 8:04 am
g`day rob.
thanks for the reply.
i’ve figured out how to insert the gravatar “standard” into the comments section (mind you… it too damn easy XD
keep up the good work, will look forward for future updates on this and other plugs :)
51. space | April 23rd, 2008 at 7:24 pm
Can you tell me how to get to the options page you mention? I don’t see it anywhere.
52. Rob | April 24th, 2008 at 11:13 am
space: From the WordPress Dashboard you should see either a settings menu (in WP 2.5) or one called options (<2.5). Under that menu there should be an entry for ‘Highlight’ or ‘Highlight Comments’.
53. space | April 24th, 2008 at 1:31 pm
Good Lord, I felt like I looked all over the admin site. Thanks, Rob.
54. Daniel Cox | May 9th, 2008 at 10:25 pm
Woooohoooo!!!
After three days, countless clicks, and feeling a bit churlish about editing my templates, can I just say I love your plug in! thanks for a simple to use, great looking solution.
Kudos.
55. Rob | May 10th, 2008 at 10:53 am
Daniel: Thanks!
56. ari | May 14th, 2008 at 6:21 am
thanks for your creativity. I Luv it. I will use your plugin. Nice idea
57. adspedia.ro | June 3rd, 2008 at 10:45 am
Thank you. Great plugin.
Have 1 question: if I want the background box to have rounded corners (like google adsense) how do I insert that in the CSS code field?
Can u help me?
58. adspedia.ro | June 3rd, 2008 at 10:50 am
Also:if I have an external CSS stylesheet can I just insert somehow reference to it so the plugin applies that style to my author comment?
59. plandem | June 3rd, 2008 at 11:21 am
is it useless in WP2.5? Afaik author is colored by other color.
60. Rob | June 3rd, 2008 at 11:27 am
adspedia.ro: As it is the plugin only lets you insert css code directly which it them places in an inline style attribute. The plugin code is very simple so if you wanted to you could easily change it to instead insert a class attribute.
As for rounded corners … they are not straightforward but there are plenty of ways out there. Try googling for ‘css rounded corners’
61. Rob | June 3rd, 2008 at 11:38 am
plandem: It is working fine here on 2.5 and 2.5.1.
62. adspedia.ro | June 3rd, 2008 at 12:41 pm
Rob: I did find a .css file that is already doing that, the question is can you point me to the location in the plugin file where I should modify code to get the absolute path to the style .css document, for author comments, liked http://www.adspedia.ro/css/style_auth.css ?
Is this possible?
Thanks.
Val
63. Rob | June 3rd, 2008 at 2:28 pm
adspedia.ro: This is a crude hack but…
Find the line in the plugin that reads:
and change it into:
Then instead of entering css codes into the options screen enter the name of the class that you want applied to the div that wraps the comment.
I’m not sure if it will work … but it might.
64. David | June 12th, 2008 at 6:54 pm
Correcting a minor bug. The line
return '<div style="'.$options['highlight_style'].'">'.$content.'</div>';Should be
return '<div style="'.$options['highlight_style'].'"><p>'.$content.'</div>';Without the additional ” the author’s first and second paragraphs in his own comment are not properly separated.
65. David | June 12th, 2008 at 7:10 pm
Note, btw, that the symptom of the missing p is evident in your author comments — #18, 25, and 60– above on this very page.
66. Rob | June 12th, 2008 at 8:28 pm
David: Thanks–I’ll check it out.
67. John | June 12th, 2008 at 8:53 pm
David,
This plugin was breaking the css on the first paragraph of each comment in my theme.
The change in code in your comment #64 fixed the issue.
I don’t understand enough of this to know why. Thanks for the fix.
68. Amanda | June 27th, 2008 at 8:56 pm
Thank you so much! Works perfectly on 2.5.1 :)
69. Benoy | June 30th, 2008 at 1:48 am
This seams really nice. I will give it a try. thanks a lot!
70. ジェイソン (Jason) | June 30th, 2008 at 2:29 am
What a great plugin! I’ve been looking for something like this :)
Thanks!
71. BOLL | June 30th, 2008 at 10:39 am
Yay plugin! :D Many thanks Rob!! And David (#64) for fixing it so it works for me as well ;)
72. malapu | June 30th, 2008 at 6:24 pm
thanks for the plugin. very nice
73. Cole | July 7th, 2008 at 11:03 pm
Hmm. This is the third author highlight plugin that has done nothing for me. I am becoming suspicious.
Plugin is activated, CSS changed and nothing. I do see that my comments have “li author” so something is happening, right?
74. Rob | July 10th, 2008 at 10:32 am
Cole: Sounds strange! My plugin doesn’t out in the ‘author’ in the
<li>element — it’s probably from one of the other alternative plugins you’ve tried. Are any of them still installed?This plugin wraps the comment content in a div with a style attribute. It sounds like that isn’t getting added.
75. Rebecca | July 12th, 2008 at 9:13 am
Lovley plugin!
I have searched for a plugin like this for a long time. But now i found it. Yippie!!!
Great work!
76. France | July 22nd, 2008 at 8:52 pm
A simple thank you note for a simple and practical plugin.
77. katya | August 6th, 2008 at 8:34 am
Shall download and implement.
:)
Leave a Comment
Trackback this post | Subscribe to the comments via RSS Feed