You are here

function twitter_pull_preprocess in Twitter Pull 7.2

Same name and namespace in other branches
  1. 7 twitter_pull.module \twitter_pull_preprocess()

Processes variables twitter_pull templates.

File

./twitter_pull.module, line 65
Twitter Pull module.

Code

function twitter_pull_preprocess(&$variables, $hook) {
  switch ($hook) {
    case 'twitter_pull_listing':
      if (!empty($variables['tweets']) && is_array($variables['tweets'])) {
        foreach ($variables['tweets'] as $key => $tweet) {
          $tweet->time_ago = t('!time ago.', array(
            '!time' => format_interval(time() - $tweet->timestamp),
          ));
          $variables['tweets'][$key] = $tweet;
        }

        // Add Follow Button javascript.
        drupal_add_js('!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");', 'inline');

        // Web Intents javascript.
        drupal_add_js('//platform.twitter.com/widgets.js', 'external');
      }
      break;
  }
}