Title: [Plugin: Better WordPress Recent Comments] Misc suggestions
Last modified: August 20, 2016

---

# [Plugin: Better WordPress Recent Comments] Misc suggestions

 *  [Zanes](https://wordpress.org/support/users/zanes/)
 * (@zanes)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/plugin-better-wordpress-recent-comments-misc-suggestions/)
 * Hi there.
 * First, let me say that your plugin is very nice and works like a charm !
 * I switched from my old “recent comments” to this one, but I tweaked your plugin
   a little bit to add some features I missed from my old plugin.
 * Suggestions :
    **1 –** Add a %time_ago% variable, to display the time elapsed
   between the current time at the time at which the post was posted.
 * Example :
    “Zanes commented on XXXXX (**15 seconds ago**)” “Anon commented on
   XXXXX (**18 minutes ago**)” “WP commented on XXXXX (**5 hours ago**)” “Anonymous
   commented on XXXX (**1 week ago**)” “Dude commented on XXXX (**2 weeks ago**)”
 * Notice that the plural is handled correctly (week/weeks).
 * I tweaked the code by inspiring myself from the “recent comments with gravatar”
   plugin.
 * 2 – Gravatar Hovercard support.
    I had hovercard support previously, but it partially
   work here. The “Jetpack plugin” from Automaticc implements hovercards, but they
   stop working as soon as you refresh the comment widget by using ajax pagination.
   A full support for hovercards would be great !
 * [http://wordpress.org/extend/plugins/bwp-recent-comments/](http://wordpress.org/extend/plugins/bwp-recent-comments/)

Viewing 9 replies - 1 through 9 (of 9 total)

 *  Plugin Author [Khang Minh](https://wordpress.org/support/users/oddoneout/)
 * (@oddoneout)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/plugin-better-wordpress-recent-comments-misc-suggestions/#post-2323731)
 * Hi Zanes, thanks for using BWP RC!
 * About your suggestions:
 * 1. That’s great! Are you a coder? Do you have an account on Github? If so you
   can create a pull request and add your codes. I will review them shortly and 
   merge them later.
 * 2. I believe that the new comments created by AJAX call are not processed by 
   Hovercard plugin because they are, obviously, added after Hovercard’s Javascript
   registers hover event. Anyway, I will take a look and see if there’s a work around.
 * Thanks :).
 *  Thread Starter [Zanes](https://wordpress.org/support/users/zanes/)
 * (@zanes)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/plugin-better-wordpress-recent-comments-misc-suggestions/#post-2323917)
 * Hello, sorry for the late reply.
    I don’t have an account on Github (got my own
   SVN), so i’ll paste what you need to get here. It’s quick and dirty, so it’ll
   probably need some optimization. Here’s the code (I believe you’ll know where
   this is located) :
 *     ```
       /**
       * Format comment contents
       */
       	function format_comment($commentdata)
       	{
       		$comment = array();
   
       		$comment['comment_number'] = isset($commentdata['comment_number']) ? $commentdata['comment_number'] : '';
       		$comment['pid'] = $commentdata['comment_post_ID'];
       		$comment['home'] = get_option('home');
       		$comment['user_id'] = $commentdata['user_id'];
       		$date_format = (!empty($this->options['input_date'])) ? $this->options['input_date'] : $this->options_default['input_date'];
       		//$comment['time'] = date_i18n($date_format, strtotime($commentdata['comment_date']));
   
       		  $difference = time() - strtotime(get_gmt_from_date($commentdata['comment_date']));
   
       		  $weeks = round($difference / 604800);
       		  $difference = $difference % 604800;
       		  $days = round($difference / 86400);
       		  $difference = $difference % 86400;
       		  $hours = round($difference / 3600);
       		  $difference = $difference % 3600;
       		  $minutes = round($difference / 60);
       		  $difference = $difference % 60;
       		  $seconds = $difference;
   
       		  if ($weeks > 0) {
       				if ($weeks == 1) {
       				$comment['time'] = $weeks . ' ' . __('week', $this->_folder); }
       				else { $comment['time'] = $weeks . ' ' . __('weeks', $this->_folder); }
       		  } else if ($days > 0) {
       				if ($days == 1) {
       				$comment['time'] = $days . ' ' . __('day', $this->_folder); }
       				else { $comment['time'] = $days . ' ' . __('days', $this->_folder); }
       		  } else if ($hours > 0) {
       				if ($hours == 1) {
       				$comment['time'] = $hours . ' ' . __('hour', $this->_folder); }
       				else { $comment['time'] = $hours . ' ' . __('hours', $this->_folder); }
       		  } else if ($minutes > 0) {
       				if ($minutes == 1) {
       				$comment['time'] = $minutes . ' ' . __('minute', $this->_folder); }
       				else { $comment['time'] = $minutes . ' ' . __('minutes', $this->_folder); }
       		  } else if ($seconds >= 0) {
       				if ($seconds <= 1) {
       				$comment['time'] = $seconds . ' ' . __('second', $this->_folder); }
       				else { $comment['time'] = $seconds . ' ' . __('seconds', $this->_folder); }
       		  }
   
       		//$comment['time'] = get_time_diff($commentdata['comment_date']);
       		//$comment['time'] = apply_filters('bwp_rc_date_format', $comment['time'], $commentdata['comment_date']);
       		// for dynamic comment_type loading
       		$comment['comment_type'] = $commentdata['comment_type'];
       		$comment['type']	= $commentdata['comment_type'];
       		// Format post_title, also trim it if necessary - @since 1.1.0
       ```
   
 * I’ve commented the parts in your code that aren’t used anymore.
 * For this to work neatly, the cache needs to be disabled. Adding an option to 
   turn off the cache would be nice (it’d need to be activated by default if this
   procedure is used though) 😉
    Do you have any way to quickly turn off the cache
   in your code? I’d love to do a quick fix in the code for my website.
 * Regards,
 * Zanes
 *  Plugin Author [Khang Minh](https://wordpress.org/support/users/oddoneout/)
 * (@oddoneout)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/plugin-better-wordpress-recent-comments-misc-suggestions/#post-2323925)
 * Hi Zanes, thanks for your reply!
 * Turning off the cache is highly NOT recommended, but for this kind of time format
   it is necessary. Are you using widget to show the comment list, or template function?
   At the very first codeblock in class-bwp-recent-comments.php you will be able
   to find what you’re looking for, i.e. disable cache :).
 * Hope that helps.
 *  Thread Starter [Zanes](https://wordpress.org/support/users/zanes/)
 * (@zanes)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/plugin-better-wordpress-recent-comments-misc-suggestions/#post-2323926)
 * Hi again,
 * Thanks for your reply.
    Tried turning on the need_refresh, but the problem is
   that it disables the ability to get “older comments” (ie : the pagination links
   do not show) in the widget (I use the widget). I’ve had this problem when I first
   tried to tweak the code some time ago, and I haven’t fixed it (yet 😉 ).
 * When you say “not” recommended, do you mean it’s because the server will have
   to make a request to the database each time somebody loads a page with the widget?
   I know this is kind of inevitable, but can’t help it :/
    Also, I believe you 
   only do a “get older comments” request when the pagination link is clicked, and
   not at the start, right? (not really sure about that one)
 * Regards,
 * Zanes
 *  Plugin Author [Khang Minh](https://wordpress.org/support/users/oddoneout/)
 * (@oddoneout)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/plugin-better-wordpress-recent-comments-misc-suggestions/#post-2323948)
 * Hi Zanes,
 * > Tried turning on the need_refresh, but the problem is that it disables the 
   > ability to get “older comments” (ie : the pagination links do not show) in 
   > the widget (I use the widget). I’ve had this problem when I first tried to 
   > tweak the code some time ago, and I haven’t fixed it (yet 😉 ).
 * I will take a look at that.
 * > When you say “not” recommended, do you mean it’s because the server will have
   > to make a request to the database each time somebody loads a page with the 
   > widget? I know this is kind of inevitable, but can’t help it :/
 * I think there’s a way to work around this, turning off the cache is something
   I really don’t want to do. Anyway, if you want to discuss possible solutions,
   please go here: [http://betterwp.net/community/forum/4/bwp-recent-comments/](http://betterwp.net/community/forum/4/bwp-recent-comments/).
 * > Also, I believe you only do a “get older comments” request when the pagination
   > link is clicked, and not at the start, right? (not really sure about that one)
 * Of course :).
 *  [zehrgut](https://wordpress.org/support/users/zehrgut/)
 * (@zehrgut)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/plugin-better-wordpress-recent-comments-misc-suggestions/#post-2324030)
 * > At the very first codeblock in class-bwp-recent-comments.php you will be able
   > to find what you’re looking for, i.e. disable cache 🙂
 * I’ve tried to change:
 *     ```
       function bwp_get_recent_comments($args = array(), $echo = true, $need_refresh = false)
       ```
   
 * to
 *     ```
       function bwp_get_recent_comments($args = array(), $echo = true, $need_refresh = true)
       ```
   
 * But nothing changed 🙁 New comments don’t appear.
 *  [zehrgut](https://wordpress.org/support/users/zehrgut/)
 * (@zehrgut)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/plugin-better-wordpress-recent-comments-misc-suggestions/#post-2324045)
 * Hello!
    about my previous posts. Please ignore it. It seems the problem is with
   SQL-sorting not cache.
 *  [ernest_d](https://wordpress.org/support/users/sfedona/)
 * (@sfedona)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/plugin-better-wordpress-recent-comments-misc-suggestions/#post-2324075)
 * On the author’s website i see:
 *  “Hook References”
 * bwp_rc_date_format – Used to apply advanced date formatting, such as x days ago,
   etc. (filter)
 * Is it possible actualy use it , and how ?
 *  Plugin Author [Khang Minh](https://wordpress.org/support/users/oddoneout/)
 * (@oddoneout)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/plugin-better-wordpress-recent-comments-misc-suggestions/#post-2324077)
 * bwp_rc_date_format is a hook that provides you with 2 variables: **comment_time**
   and **comment_date**.
 * Follow what is written here: [http://www.php.net/manual/en/function.time.php#108581](http://www.php.net/manual/en/function.time.php#108581)(
   along with using the variables the plugin provides) if you would like to achieve
   that advanced date time.

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘[Plugin: Better WordPress Recent Comments] Misc suggestions’ is closed
to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/bwp-recent-comments.svg)
 * [Better WordPress Recent Comments](https://wordpress.org/plugins/bwp-recent-comments/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/bwp-recent-comments/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/bwp-recent-comments/)
 * [Active Topics](https://wordpress.org/support/plugin/bwp-recent-comments/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/bwp-recent-comments/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/bwp-recent-comments/reviews/)

 * 9 replies
 * 4 participants
 * Last reply from: [Khang Minh](https://wordpress.org/support/users/oddoneout/)
 * Last activity: [13 years, 10 months ago](https://wordpress.org/support/topic/plugin-better-wordpress-recent-comments-misc-suggestions/#post-2324077)
 * Status: not resolved