The other day I was reading the discussions taking place in the comments on a relatively interesting blog post. I didn’t want to subscribe to comments via email because I hate littering my inbox with that stuff, so every now and then I’d flip over to that tab in my browser, refresh the page, and read the new comments. This worked ok up to a couple dozen comments. I had to step away for a few hours, and when I came back there was three dozen or so new comments. I couldn’t tell what was new and what wasn’t. So I didn’t read any of them.
Then I realized something I’ve known for a long time and never really paid any attention. Discussion software sucks. There are lots of reasons, and people have tried addressing these problems in a number of ways. And while there are many different types of platforms for discussions – forums, blog comments, Facebook groups, etc. – each with its own set of problems, there’s one problem that’s almost universal: the inability to identify new comments since your last visit.
Naturally I wondered if anyone had created a WordPress plugin that highlights new comments, and a quick search turned up nothing. But I did find a blog post by Natko Hasic that laid out an interesting way to highlight new comments.
I decided to turn his solution in a plugin. Comments Since Last Visit is a simple WordPress plugin that highlights new comments made on posts since a person’s last visit.
Right now it’s very simple and has no options for controlling the color, spacing, or other CSS. It’s better suited for developers or tinkerers who’d want to modify it to their own liking. Check it out and let me know what you think. And if you know a better or more interesting way to do this, please share.
9 thoughts on “Identifying new comments since your last visit”
Have been working on some modifications, in response to some user feedback and to my own user experience with this and similar functions.
Using your code as the starting point, I’ve implemented a session marker – in the form of two addition cookies, one storing current session time, the other storing a “fallback” time that will used on the next visit to replace the last-session/visit after a return visit/next session. The objective was to make it possible for a user to return to the site/post see a bunch of new comments, and freely reply and browse around without losing the old “since last visit” markings until the end of the current session. The other main change was removing since-last-visit highlighting for first-ever-visits, which I always found a bit confusing and also design-negative in the past.
Also added a function and shortcode for displaying the last-visit time at the top of the comment thread.
After I’ve worked a few more things out, I’ll want to add some admin options and maybe a function for displaying new comments only, which users also seem to want.
Of course, many sites using one or another Ajaxified comments system have their own special new comments functions, but I don’t care for them much. If they make sense, they make sense for very busy sites whose comment sections are closer to chat rooms than to places where more serious and thoughtful discussion is meant to take place.
If you’re still working on this plug-in at all, there are a couple of questions I have regarding the approach you took. If not, thanks much for your work, and I’ll be sure to continue crediting you in future forks or “reloads.”
I’d love to see some of your enhancements. I have the plugin on Github if you’d like to open an issue and/or pull request. https://github.com/mindctrl/comments-since-last-visit
Ah! Good to see you’re still interested! I’ll clean up the code, test a few things, and finish a couple of additions (including the “show only” button mentioned above), and post it on Github next week. I’m aiming to put something together for the WP plug-in repository. In the meantime, you can see the current version in use at http://ordinary-gentlemen.com/ . I’m also using and discussing it at my development blog attached to that site: http://ordinary-gentlemen.com/developing/2015/08/new-new-since-last-visit-commenting/
Just an update, since I let my self-imposed deadline slip a bit.
I’ve been working out the “show only” and also “scroll through new” functions (in jQuery). Am also still gathering strength and handling side-problems before 1) tackling a last set of complicated less-than-perfects on the new session cookies and “what counts as last visit” logic, and 2) setting up an admin options page
I’d mentioned questions I had for you. For one thing, I’m wonder why you set 50 as the limit for cookie size: Is that based on particular information, or was it just a number out of the air? Since my version sets three cookies, of which two persist until a distant expiration, I wonder if this is something to keep in mind.
New version being tested here: ordinary-gentlemen.com/developing/2015/08/comments-since-last-visit-reloaded-reloaded-testing-post/
That number was chosen by Natko, but if I recall correctly it was to ensure the cookie size didn’t exceed 4k limit most browsers support/supported at the time. I haven’t looked into that in quite some time to see if it has changed since.
Thanks. I think the 50 limit is well beyond what most normal site users for the sites I’m current working on will hit anytime soon, and I THINK the code is straightforward on that, so am leaving it to last.
Decided after user feedback to add sorting and mark-all-old convenience features. As so often in this process, every time I think I have the cookie set/get/encode/decode issues mastered, I get a new set of unexpected results, but it’s educational at least!
Haven’t yet run across a model for your and Natko’s approach, much less for my own more complicated one, so there’s been a LOT of trial-and-error involved. I think that other developers may instead enable “normal” session cookies for WP, and wonder if I should have taken that approach.
If I can’t solve the current problem easily, I’ll go ahead and post the Git for the best stable version I have later today.
It seems like every time I work with cookies I run into some oddity. :) Look forward to seeing your enhancements.
I THINK I have it, EXCEPT…. (I hate doing the almost-ready-for-real-this-time thing, but I guess it goes with the territory…).
Before “presenting to the world,” there is one nagging issue – security/validation/sanitization – that I currently have a StackExchange question on: http://wordpress.stackexchange.com/questions/201776/do-we-need-to-validate-sanitize-or-filter-simple-numerical-superglobals-cooki?noredirect=1#comment293054_201776
Despite the reaction from StackExchangers – insisting that security must be an issue – I can’t see how, after reviewing the code – it really can be for this plug-in.
Anyway, here the Git for Version 1.0 of Comments New Since Last Visit, Reloaded: https://github.com/CKMacLeod/WP-Comments-Since-Last-Visit-Reloaded
It’s installed on-line now at http://ordinary-gentlemen.com/developing/2015/09/new-new-comments-new-since-last-visit-reloaded-reloaded-augmented. I’ve not yet started asking for feedback from site users on it, tho it’s possible one or two might wander by.