You are here

twitter_timeline.module in Twitter Timeline 7

Twitter Timeline module.

File

twitter_timeline.module
View source
<?php

/**
 * @file
 * Twitter Timeline module.
 */

/**
 * Implements hook_bean_types_api_info().
 */
function twitter_timeline_bean_types_api_info() {
  return array(
    'api' => 4,
  );
}

/**
 * Implements hook_bean_types().
 */
function twitter_timeline_bean_types() {
  $plugins = array();
  $plugin_path = drupal_get_path('module', 'twitter_timeline') . '/plugins/bean';
  $plugins['twitter_timeline'] = array(
    'label' => t('Twitter Timeline'),
    'description' => t('Shows an embedded twitter timeline widget.'),
    'handler' => array(
      'class' => 'TwitterTimelineBean',
      'parent' => 'bean',
      'path' => $plugin_path,
      'file' => 'twitter_timeline.inc',
    ),
  );
  return $plugins;
}

/**
 * Render a twitter timeline widget.
 */
function twitter_timeline_render($widget_id, $placeholder_text, $placeholder_url) {
  $output = '<a class="twitter-timeline" href="' . check_plain($placeholder_url) . '" data-widget-id="' . check_plain($widget_id) . '">' . check_plain($placeholder_text) . '</a>';
  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="https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");', 'inline');
  return $output;
}

Functions