-
Notifications
You must be signed in to change notification settings - Fork 9
NO-JIRA: Twitter feed fix #80
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
This is the Wordpress theme for inclusivedesign.ca, the website of the Inclusive Design Institute. | ||
|
||
## Requirements | ||
* [oAuth Twitter Feed for Developers](https://wordpress.org/plugins/oauth-twitter-feed-for-developers/) - used by Twitter feeds on the front page. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,32 +128,25 @@ function panel_login_fail( $username ) { | |
} | ||
} | ||
|
||
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-3gtwAKtHHrPjGwa1PmAqXD8FKKKQY2C1ORB8dpyE"; | ||
$accesstokensecret = "kWuqrTk8IOHVSQdEK9dFfy337VjQv9P44lYKVfq8Fv7Ln"; | ||
$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>'; | ||
function idi_display_twitter_feed($twitter_username) { | ||
|
||
/* Use the "oAuth Twitter for Developers" plugin to get the Twitter feed. | ||
https://en-ca.wordpress.org/plugins/oauth-twitter-feed-for-developers/ */ | ||
if (function_exists('getTweets')) { | ||
$tweet_count = 5; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This variable should be defined as a constant instead of hiding deep in the script. |
||
$tweets = getTweets($tweet_count, $twitter_username); | ||
$out = '<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/'; | ||
$out .= $twitter_username.'" title="Follow @'.$twitter_username.'">@'.$twitter_username.'</a><ul>'; | ||
if (!empty($tweets)) { | ||
foreach ($tweets as $tweet) { | ||
$out .= '<li class="tweet"><div class="tweet-date">'.substr($tweet[created_at], 0, 16).'</div>'.$tweet[text].'</li>'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing quotes at accessing array elements:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the twitter plugin is installed but the consumer key and secret is not provided, this error will appear a number of times on the front page:
|
||
} | ||
} else{ | ||
echo "<p>no tweets found</p>"; | ||
} else { | ||
$out .= '<p>no tweets found</p>'; | ||
} | ||
$out .= '</ul></div></div>'; | ||
echo $out; | ||
} | ||
echo '</ul> | ||
</div> | ||
</div>'; | ||
} | ||
|
||
?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be helpful to add a link that explains how to use a Wordpress theme.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another helpful note in the readme is, after "oAuth Twitter Feed for Developers plugin" is installed, follow its installation doc to provide the consumer key/secret etc in the admin settings page in order to get tweets displayed. This step is easy to be missed.