You are here

function _prepare_share_link in Responsive Share Buttons 7

Prepare a sharing link.

Parameters

string $network: The name of the social network to use.

string $url: The URL to share.

string $title: The title to use.

Return value

string The link for sharing.

1 call to _prepare_share_link()
template_preprocess_responsive_share_buttons in ./responsive_share_buttons.module
Theme preprocess function for theme_responsive_share_buttons().

File

./responsive_share_buttons.module, line 193
Module to enable CSS responsive share buttons.

Code

function _prepare_share_link($network, $url, $title) {
  $link = '';
  $link_options = array(
    'attributes' => array(
      'class' => array(
        'button-wrap',
        $network,
      ),
    ),
  );
  switch ($network) {
    case 'delicious':
      $link_text = t('Delicious');
      $link_url = 'http://del.icio.us/post?url=' . $url . '&title=' . $title;
      break;
    case 'digg':
      $link_text = t('Digg it');
      $link_url = 'http://www.digg.com/submit?phase=2&url=' . $url . '&title=' . $title;
      break;
    case 'facebook':
      $link_text = t('Facebook');
      $link_url = 'https://www.facebook.com/sharer/sharer.php?u=' . $url . '&title=' . $title;
      break;
    case 'google':
      $link_text = t('Plus Share');
      $link_url = 'https://plus.google.com/share?url=' . $url . '&title=' . $title;
      break;
    case 'linkedin':
      $link_text = t('LinkedIn');
      $link_url = 'http://www.linkedin.com/shareArticle?mini=true&url=' . $url . '&title=' . $title;
      break;
    case 'pinterest':
      $link_text = t('Pinterest');
      $link_url = 'https://www.pinterest.com/pin/create/button/?url=' . $url . '&description=' . $title;
      break;
    case 'stumbleupon':
      $link_text = t('Stumbleupon');
      $link_url = 'http://www.stumbleupon.com/submit?url=' . $url . '&title=' . $title;
      break;
    case 'twitter':
      if ($twitter_name = variable_get('responsive_share_buttons_twitter_name', '')) {
        $title .= t(' via @@twitter_name', array(
          '@twitter_name' => $twitter_name,
        ));
      }
      $link_text = t('Tweet');
      $link_url = 'http://twitter.com/home?status=' . $title . ' ' . $url;
      break;
  }
  drupal_alter('responsive_share_buttons_share_link', $link_text, $link_url, $link_options, $network);
  if (!empty($link_text)) {
    $link = l($link_text, $link_url, $link_options, $network);
  }
  return $link;
}