Rate/VotingAPI - Add class to button if user has voted I want to add a class to a button after the user has voted to display another picture.

This was posted here as a solution for Drupal 6. 

&lt;?php
  // Print all rate buttons
  foreach ($links as $link) {
    if ($results['user_vote'] == $link['value']) {
      // user has voted
      $class = 'voted';
    }
    else {
      // user has not voted
      $class = 'not-voted';
    }
    print theme('rate_button', $link['text'], $link['href'], $class);
  }
?&gt;


I couldn't get it to work, so I assumed that I had to convert it to D7 first. However, I have no skills of converting code, so a little help would be nice.
This change will only work for "Thumbs up" widget. You can place this code in your template.php under your custom theme or in a custom module.

function MODULE_NAME_OR_TEMPLATE_NAME_process_rate_template_thumbs_up(&amp;$variables) {
  extract($variables);

  $classes = 'rate-thumbs-up-btn-up';

  if (isset($results['user_vote']) &amp;&amp; $results['user_vote'] == $links[0]['value']) {
    $classes .= ' user-voted';
  } else {
    $classes .= ' user-not-voted';
  }

  $variables['up_button'] = theme('rate_button', array('text' =&gt; $links[0]['text'], 'href' =&gt; $links[0]['href'], 'class' =&gt; $classes));
}


Make sure to replace MODULE_NAME_OR_TEMPLATE_NAME with an actual template name or module name.