diff --git a/tweetbutton.module b/tweetbutton.module index 7ec1891..88b0dc8 100644 --- a/tweetbutton.module +++ b/tweetbutton.module @@ -474,3 +474,36 @@ function theme_tweetbutton_hashtag_display($variables) { return '
' . $hash_link . '
'; } +/** + * Implements hook_ds_fields_info(). + */ +function tweetbutton_ds_fields_info($entity_type) { + $fields = array(); + + if ($entity_type == 'node') { + $fields['node'] = array(); + $fields['node']['tweetbutton_ds_field'] = array( + 'title' => t('Tweet Button'), + 'field_type' => DS_FIELD_TYPE_FUNCTION, + 'function' => '_tweetbutton_ds_field', + ); + } + + return $fields; +} + +/** + * Callback for ds button. + */ +function _tweetbutton_ds_field($field) { + if (!user_access('use tweetbutton field')) { + return ''; + } + + $uri = entity_uri($field['entity_type'], $field['entity']); + $options = array( + 'url' => url($uri['path'], array('absolute' => TRUE)), + ); + + return theme('tweetbutton_tweet_display', array('options' => $options)); +}