You are here

function theme_tweetbutton_follow_display in Tweet Button 8

Same name and namespace in other branches
  1. 7.2 tweetbutton.module \theme_tweetbutton_follow_display()
  2. 7 tweetbutton.module \theme_tweetbutton_follow_display()

Returns HTML for a follow button.

Parameters

array $variables: An associative array with options of follow button.

1 theme call to theme_tweetbutton_follow_display()
TweetbuttonFollowBlock::build in lib/Drupal/tweetbutton/Plugin/Block/TweetbuttonFollowBlock.php
Implements \Drupal\block\BlockBase::blockBuild().

File

./tweetbutton.module, line 216
Adds block with tweet and follow buttons.

Code

function theme_tweetbutton_follow_display($variables) {
  $script_url = url('http://platform.twitter.com/widgets.js', array(
    'external' => TRUE,
    'https' => TRUE,
  ));
  $options = $variables['options'];
  $screen_name = !empty($options['screen_name']) ? $options['screen_name'] : \Drupal::config('tweetbutton.settings')
    ->get('tweetbutton_follow_screen_name');
  $follow_text = t('Follow !screen_name', array(
    '!screen_name' => $screen_name,
  ));
  $twitter_account_link = 'http://twitter.com/' . $screen_name;
  $attributes = tweetbutton_follow_get_attributes($options);
  $follow_link = l($follow_text, $twitter_account_link, array(
    'attributes' => $attributes,
    'external' => TRUE,
    'https' => TRUE,
  ));
  $link = array(
    '#markup' => $follow_link,
    '#prefix' => '<div class="tweetbutton-follow tweetbutton">',
    '#suffix' => '</div>',
    '#attached' => array(
      'js' => array(
        $script_url => array(
          'type' => 'external',
          'scope' => 'footer',
        ),
      ),
    ),
  );
  return drupal_render($link);
}