You are here

function plus1_link in Plus 1 6.2

Implementation of hook_link().

File

./plus1.module, line 474
A simple +1 voting widget module.

Code

function plus1_link($type, $object, $teaser = FALSE) {
  $links = array();
  if ($type == 'node') {

    // Has the summary link been enabled?
    // And skip if voting is disabled.
    if (variable_get('plus1_show_link', 0) && !$object->plus1_disable_vote) {
      $score = plus1_get_score($object->nid);
      $score_class = variable_get('plus1_link_count', 'plus1-link-count');
      $score_text = "<span class=\"{$score_class}\">{$score}</span>";
      $singular = t(variable_get('plus1_link_singular', t('Vote')));
      $plural = t(variable_get('plus1_link_plural', t('Votes')));
      $title = format_plural($score, $singular, $plural, array(
        '!score' => $score,
      ));
      $links['plus1'] = array(
        'title' => $title,
        'html' => TRUE,
        'attributes' => array(
          'title' => $score ? $title : t('Be the first to @vote', array(
            '@vote' => variable_get('plus1_vote', 'Vote'),
          )),
        ),
      );
    }
  }
  return $links;
}