Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

NO-JIRA: Twitter feed fix #80

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README

This file was deleted.

4 changes: 4 additions & 0 deletions README.md
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.
Copy link
Contributor

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.

Copy link
Contributor

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.


## Requirements
* [oAuth Twitter Feed for Developers](https://wordpress.org/plugins/oauth-twitter-feed-for-developers/) - used by Twitter feeds on the front page.
118 changes: 59 additions & 59 deletions front-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,75 +7,75 @@
<?php get_header(); ?>

<div class="fl-centered fl-col-mixed fl-site-wrapper">
<nav role="navigation" class="idi-research-clusters fl-centered fl-clearfix">
<div class="idi-clusters-overlay"></div>
<nav role="navigation" class="idi-research-clusters fl-centered fl-clearfix">
<div class="idi-clusters-overlay"></div>

<a class="idi-design-cluster-circle idi-cluster-circle-link idi-design-link idi-no-tab-focus" href="research/design" title="Design & Development"></a>
<div class="idi-cluster-circle idi-design-cluster-circle idi-design-cluster-circle-colour"></div>
<div class="idi-cluster-arrow idi-design-cluster-arrow"> </div>
<a class="idi-cluster-name idi-design-cluster-name" href="research/design">Design & Development</a>
<a class="idi-design-cluster-circle idi-cluster-circle-link idi-design-link idi-no-tab-focus" href="research/design" title="Design & Development"></a>
<div class="idi-cluster-circle idi-design-cluster-circle idi-design-cluster-circle-colour"></div>
<div class="idi-cluster-arrow idi-design-cluster-arrow"> </div>
<a class="idi-cluster-name idi-design-cluster-name" href="research/design">Design & Development</a>

<a class="idi-implementation-cluster-circle idi-implementation-link idi-cluster-circle-link idi-no-tab-focus" href="research/implementation" title="Implementation & Information Practices"></a>
<div class="idi-cluster-circle idi-implementation-cluster-circle idi-implementation-cluster-circle-colour"></div>
<div class="idi-cluster-arrow idi-implementation-cluster-arrow"> </div>
<a class="idi-cluster-name idi-implementation-cluster-name" href="research/implementation">Implementation & Information Practices</a>
<a class="idi-implementation-cluster-circle idi-implementation-link idi-cluster-circle-link idi-no-tab-focus" href="research/implementation" title="Implementation & Information Practices"></a>
<div class="idi-cluster-circle idi-implementation-cluster-circle idi-implementation-cluster-circle-colour"></div>
<div class="idi-cluster-arrow idi-implementation-cluster-arrow"> </div>
<a class="idi-cluster-name idi-implementation-cluster-name" href="research/implementation">Implementation & Information Practices</a>

<a class="idi-policies-cluster-circle idi-policies-link idi-cluster-circle-link idi-no-tab-focus" href="research/policies" title="Business Case, Policies, Standards & Legislation"></a>
<div class="idi-cluster-circle idi-policies-cluster-circle idi-policies-cluster-circle-colour"></div>
<div class="idi-cluster-arrow idi-policies-cluster-arrow"> </div>
<a class="idi-cluster-name idi-policies-cluster-name" href="research/policies">Business Case, Policies, Standards & Legislation</a>
<a class="idi-policies-cluster-circle idi-policies-link idi-cluster-circle-link idi-no-tab-focus" href="research/policies" title="Business Case, Policies, Standards & Legislation"></a>
<div class="idi-cluster-circle idi-policies-cluster-circle idi-policies-cluster-circle-colour"></div>
<div class="idi-cluster-arrow idi-policies-cluster-arrow"> </div>
<a class="idi-cluster-name idi-policies-cluster-name" href="research/policies">Business Case, Policies, Standards & Legislation</a>

<a class="idi-mobile-cluster-circle idi-mobile-link idi-cluster-circle-link idi-no-tab-focus" href="research/mobile" title="Mobile & Pervasive Computing"></a>
<div class="idi-cluster-circle idi-mobile-cluster-circle idi-mobile-cluster-circle-colour"></div>
<div class="idi-cluster-arrow idi-mobile-cluster-arrow"> </div>
<a class="idi-cluster-name idi-mobile-cluster-name" href="research/mobile">Mobile & Pervasive Computing</a>
</nav>
<a class="idi-mobile-cluster-circle idi-mobile-link idi-cluster-circle-link idi-no-tab-focus" href="research/mobile" title="Mobile & Pervasive Computing"></a>
<div class="idi-cluster-circle idi-mobile-cluster-circle idi-mobile-cluster-circle-colour"></div>
<div class="idi-cluster-arrow idi-mobile-cluster-arrow"> </div>
<a class="idi-cluster-name idi-mobile-cluster-name" href="research/mobile">Mobile & Pervasive Computing</a>
</nav>

<div class="fl-col-flex4 front-cols">
<?php
$the_query = new WP_Query( array('posts_per_page'=>2) );
<div class="fl-col-flex4 front-cols">
<?php
$the_query = new WP_Query( array('posts_per_page'=>2) );

while ($the_query->have_posts()):
$the_query->the_post();
global $more;
$more = 0;
?>
<div class="fl-col">
<div class="idi-box idi-highlight-box post">
<?php if(has_post_thumbnail()) {
the_post_thumbnail();
} ?>
<div class="idi-box-text">
<h2><a class="idi-article-title" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<div class="idi-date"><?php the_time('F jS, Y') ?></div>
<div class="entry">
<?php the_excerpt(); ?>
</div>
</div>
</div>
</div>
<?php endwhile; ?>
while ($the_query->have_posts()):
$the_query->the_post();
global $more;
$more = 0;
?>
<div class="fl-col">
<div class="idi-box idi-highlight-box post">
<?php if(has_post_thumbnail()) {
the_post_thumbnail();
} ?>
<div class="idi-box-text">
<h2><a class="idi-article-title" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<div class="idi-date"><?php the_time('F jS, Y') ?></div>
<div class="entry">
<?php the_excerpt(); ?>
</div>
</div>
</div>
</div>
<?php endwhile; ?>

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

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

<div class="idi-box">
<div class="idi-mailing-list">
<?php get_template_part("mailing-list-form"); ?>
</div>
<div class="idi-box idi-box-text">
<?php get_template_part("institution-list"); ?>
<?php get_template_part("contact-info"); ?>
</div>
</div>
</div>
<div class="idi-box">
<div class="idi-mailing-list">
<?php get_template_part("mailing-list-form"); ?>
</div>
<div class="idi-box idi-box-text">
<?php get_template_part("institution-list"); ?>
<?php get_template_part("contact-info"); ?>
</div>
</div>
</div>

</div>
</div>
</div>

<?php get_footer(); ?>
41 changes: 17 additions & 24 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

The 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>';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing quotes at accessing array elements:

$tweet[created_at] -> $tweet['created_at']
$tweet[text] -> $tweet['text']

Copy link
Contributor

Choose a reason for hiding this comment

The 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:

Warning: Illegal string offset 'created_at' in /.../wp-content/themes/idi-theme/functions.php on line 142

}
} else{
echo "<p>no tweets found</p>";
} else {
$out .= '<p>no tweets found</p>';
}
$out .= '</ul></div></div>';
echo $out;
}
echo '</ul>
</div>
</div>';
}

?>
4 changes: 4 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,10 @@ h3,
}

/* Twitter widget */
.tweet {
margin-bottom: 1.5rem;
}

.twitter-feed-group .tweet-container {
padding: 1em;
}
Expand Down