You are here

function sharethis_link in ShareThis 6

Same name and namespace in other branches
  1. 5 sharethis.module \sharethis_link()

Implementation of hook_link().

File

./sharethis.module, line 73
Provides the ShareThis service.

Code

function sharethis_link($type, $node = NULL, $teaser = FALSE) {
  if ($type == 'node' && user_access('use share this')) {
    if (!$teaser || variable_get('sharethis_teaser', 1)) {
      if (variable_get('sharethis_sharethis_this_where', 'links') == 'links') {
        if (in_array($node->type, variable_get('sharethis_sharethis_this_node_types', array()), TRUE)) {

          // Make sure the ShareThis JavaScript is made available.
          sharethis_add_js();

          // Create the ShareThis element.
          $links['sharethis_link'] = array(
            'title' => t('ShareThis'),
            'href' => url('node/' . $node->nid, array(
              'absolute' => TRUE,
            )),
            'attributes' => array(
              'class' => 'sharethis-link',
              // This is the class that is processed.
              'title' => check_plain($node->title),
              'rel' => 'nofollow',
            ),
          );
          return $links;
        }
      }
    }
  }
}