Skip to content

Commit

Permalink
IDI-116: Refactor twitter feed code to a single function, re-usable f…
Browse files Browse the repository at this point in the history
…or all feeds
  • Loading branch information
acheetham committed Jul 16, 2013
1 parent d462490 commit 2797b3b
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 102 deletions.
7 changes: 4 additions & 3 deletions front-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@
<?php endwhile; ?>

<div class="fl-col">
<?php get_template_part('tweets', 'FluidProject') ?>
<?php get_template_part('tweets', 'SNOWocad') ?>

<?php idi_display_twitter_feed('aegisproj'); ?>
<?php idi_display_twitter_feed('SNOWocad'); ?>
</div>

<div class="fl-col">
<?php idi_display_twitter_feed('FluidProject'); ?>

<div class="idi-box">
<div class="idi-mailing-list">
<?php get_template_part("mailing-list-form"); ?>
Expand Down
28 changes: 28 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,32 @@ function remove_parent_contentID() {
echo '</script>' . "\n";
}

function idi_display_twitter_feed($twitter_un) {
require_once("wp-content/plugins/twitteroauth/twitteroauth/twitteroauth.php");
$num_tweets = 1;
$consumerkey = "luK78NyRjDEmMVhi6sgIw";
$consumersecret = "E6bY0ShFmtibIqWU0oHokCVZKYtPEvZcNyACBPzYqo";
$accesstoken = "123905660-DBVNC6meqlD4KgZrQcAuynwYaMxJsLqLiyrtkArR";
$accesstokensecret = "UhlTPgNowuNOsC0Oaw89PM29PcVRD4N14sAdkAUk";
$connection = new TwitterOAuth($consumerkey, $consumersecret, $accesstoken, $accesstokensecret);
$tweets = array_filter($connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=".$twitter_un."&count=".$num_tweets));

echo '<div class="idi-box idi-highlight-box twitter-feed-group">
<div class="idi-box-text">
<a class="twitter-follow-button" rel="external nofollow" href="http://twitter.com/'.$twitter_un.'" title="Follow @'.$twitter_un.'">@'.$twitter_un.'</a>
<ul>
';
if(!empty($tweets)){
foreach($tweets as $tweet) {
echo '<li class="tweet">'.$tweet->text.
'<div class="tweet-date">'.substr($tweet->created_at, 0, 16).'</div></li>';
}
} else{
echo "<p>no tweets found</p>";
}
echo '</ul>
</div>
</div>';
}

?>
52 changes: 0 additions & 52 deletions tweets-FluidProject.php

This file was deleted.

47 changes: 0 additions & 47 deletions tweets-SNOWocad.php

This file was deleted.

0 comments on commit 2797b3b

Please sign in to comment.