You are here

function tweetbutton_get_attributes in Tweet Button 6

Same name and namespace in other branches
  1. 7 tweetbutton.module \tweetbutton_get_attributes()
1 call to tweetbutton_get_attributes()
theme_tweetbutton_display in ./tweetbutton.module

File

./tweetbutton.module, line 152

Code

function tweetbutton_get_attributes($entity = NULL, $options = array()) {

  // If data-url is not set then use node url, in teaser mode we want to set this parameter
  // to fetch different counters for each node
  $default_option = array(
    'type' => variable_get('tweetbutton_button', 'vertical'),
    'text' => variable_get('tweetbutton_tweet_text', ''),
    'language' => variable_get('tweetbutton_language', ''),
    'account' => variable_get('tweetbutton_account', ''),
    'rel_account' => variable_get('tweetbutton_rel_account_name', ''),
    'rel_desc' => variable_get('tweetbutton_rel_account_description', ''),
    'entity_type' => 'node',
    'url' => url('node/' . $entity->nid, array(
      'absolute' => TRUE,
    )),
  );
  $options += $default_option;
  global $language;
  $attributes = array(
    'data-count' => $options['type'],
    'data-via' => $options['account'],
    'data-related' => $options['rel_account'] . ':' . $options['rel_desc'],
    'data-text' => $options['text'] ? token_replace($options['text'], $options['entity_type'], $entity) : '',
    'data-counturl' => $options['url'],
    'data-url' => $options['url'],
    'data-lang' => $options['language'] == 'auto' ? $language->language : $options['language'],
  );
  return $attributes;
}