Skip to content

Instantly share code, notes, and snippets.

@jessehs
Last active August 29, 2015 14:03
Show Gist options
  • Save jessehs/922f4f06583dfac4fd04 to your computer and use it in GitHub Desktop.
Save jessehs/922f4f06583dfac4fd04 to your computer and use it in GitHub Desktop.
<!-- Twitter widget embedded in block. -->
<a class="twitter-timeline"data-dnt="true" data-tweet-limit="5" href="https://twitter.com/jessetweet" data-widget-id="479455834242445314">Tweets by @jessetweet</a>
<!--Twitter widget script is attached in the footer.-->
<?php
/**
* Override or insert javascript on the site.
*
* @param (array) $js
* An array of all JavaScript being presented on the page. I can't figure out why it won't show up if I attach it in the footer.
*/
function MYTHEMENAME_js_alter(&$js) {
// Process Twitter widgets.
drupal_add_js('!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?"http":"https";if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");', array('type' => 'inline', 'scope' => 'header'));
$path = drupal_get_path('theme', 'MYTHEMENAME');
// Customize the look of the Twitter widget. (See https://github.com/kevinburke/customize-twitter-1.1.)
drupal_add_js($path . '/js/customize-twitter-1.1.min.js');
drupal_add_js('var options = {"url": "/' . $path . '/css/twitter.css"};CustomizeTwitterWidget(options);', array('type' => 'inline', 'scope' => 'header'));
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment