function tweetbutton_get_attributes in Tweet Button 7
Same name and namespace in other branches
- 6 tweetbutton.module \tweetbutton_get_attributes()
Helper function to build the required tweet attributes
Parameters
$object: Entity object can either be (node, user, taxonomy)
$options: Context specific options
Return value
List of attributes to be rendered for twitter tweetbutton
1 call to tweetbutton_get_attributes()
File
- ./
tweetbutton.module, line 179
Code
function tweetbutton_get_attributes($object = NULL, $options = array()) {
global $language;
$entity_type = empty($options['entity_type']) ? 'node' : $options['entity_type'];
$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'),
);
if (empty($options['url'])) {
if (empty($object)) {
$options['url'] = url($_GET['q'], array(
'absolute' => TRUE,
));
}
else {
$uri = entity_uri($entity_type, $object);
$options['url'] = url($uri['path'], array(
'absolute' => TRUE,
));
}
}
$options += $default_option;
if ($entity_type == 'taxonomy_term') {
$token_type = 'term';
}
else {
$token_type = $entity_type;
}
$attributes = array(
'data-count' => $options['type'],
'data-via' => $options['account'],
'data-related' => $options['rel_account'] . ':' . $options['rel_desc'],
'data-text' => !empty($options['text']) ? token_replace($options['text'], array(
$token_type => $object,
)) : '',
'data-counturl' => $options['url'],
'data-url' => $options['url'],
'data-lang' => $options['language'] == 'auto' ? $language->language : $options['language'],
'class' => 'twitter-share-button',
);
return $attributes;
}