Developer Knowledge Level

This content is intended for WordPress developers, and it may require coding knowledge of WordPress, PHP, and JavaScript. Code examples provided here may contain errors or needs some additional coding. Make sure to test the code before using it on a live website!

Filter gdrts_render_single_thumbs_rating_args_vote_from_user is used to filter the parameters used for the rendering of user vote text in the single rating block for Thumbs Rating method templates. This filter has several arguments:

  • $atts: the array of parameters to filter
  • $render_object: the instance of the render object
  • $vote: vote object
  • $vote_value: only the numeric vote value
  • $logged: datetime of the vote
  • $_remaining: number of remaining attempts to change the vote or vote
  • $_vote_limit: this can be single, multi, revote

Variable $vote_value can be +1 or -1, and if you want to change it (for display purposes only), you can use this filter:

Array $atts contains following elements:

  • before: HTML to show before the rating text.
  • after: HTML to show after the rating text.
  • vote: the string showing the vote. The format depends on the $_vote_limit argument.
  • remaining: the string showing the number of remaining attempts. The format depends on the $_vote_limit argument, and it will be empty for ‘single’ vote limit or if there are no attempts remaining.

Example to change strings

add_filter('gdrts_render_single_thumbs_rating_args_vote_from_user', 'custom__gdrts_render_single_thumbs_rating_args_vote_from_user', 10, 7);
function custom__gdrts_render_single_thumbs_rating_args_vote_from_user($atts, $obj, $vote, $vote_value, $logged, $_remaining, $_vote_limit) {
  if ($_vote_limit == 'single' || $_vote_limit == 'revote') {
    $atts['vote'] = sprintf('You voted <strong>%s</strong>, %s ago.', $vote_value, human_time_diff(strtotime($logged));
  } else if ($_vote_limit == 'multi') {
    $atts['vote'] = sprintf('You previously voted <strong>%s</strong>, %s ago.', $vote_value, human_time_diff(strtotime($logged));

  if ($_remaining > 0 && $_vote_limit != 'single') {
    if ($_vote_limit == 'revote') {
      $atts['remaining'] = sprintf(_n("You can change vote %s more time.", "You can change vote %s more times.", $_remaining), $_remaining);
    } else if ($_vote_limit == 'multi') {
      $atts['remaining'] = sprintf(_n("You can vote %s more time.", "You can vote %s more times.", $_remaining), $_remaining);

  return $atts;
Rate this reference

You are not allowed to rate this post.

Leave a Comment