function template_preprocess_twitter_feed_item in Twitter_Feed 8
Implements hook_preprocess_twitter_feed_item().
File
- ./
twitter_feed.module, line 139 - Twitter module hooks.
Code
function template_preprocess_twitter_feed_item(&$vars) {
$tweet = $vars['tweet'];
// Creates a fake input_format so we can use some internal Drupal filters.
$fake_filter = new stdClass();
$fake_filter->settings = [
'filter_url_length' => 72,
];
// Converts URLs to links and line-breaks to paragraphs.
// TODO hashtags and usernames.
$vars['text'] = [
'#markup' => _filter_autop(_filter_url($tweet->full_text, $fake_filter)),
];
// This is the datestamp that jQuery timeago expects.
$vars['date']['stamp'] = date('c', strtotime($tweet->created_at));
$vars['date']['clean'] = \Drupal::service('date.formatter')
->format(strtotime($tweet->created_at), 'short');
}