Blog

Update Twitter API – Feast WordPress Theme

We all know that Twitter recently updated their API from version 1 to version 1.1. You can find more information here in the developers section of Twitter. For those who are using the Feast Theme from cro.ma, which can be found here, a simple solution without re-installing the whole theme and loosing all the tweaks previously made. We can be lazy sometimes and ignore we have to create a child-theme to avoid this kind of issues.

Step 1

Follow the instructions given by the amazing team of cro.ma. Here is the link. the reason is because you will need that in order to fix the issue.

Step 2

Make sure you save the following to any text pad available:
- consumer_key
- consumer_secret
- access_token
- access_token_secret

Step 3

Go to your /wp-content/themes/feast/includes and create a folder and name it 'twitterlib' . Now you can download codebird.php provided in the most recent package of feast. If you can't find it simply send me a request and I will give you a link to get that from that git.hub. It seems like the guys from cro.ma made some changes to the original.

Step 4

Now you should be able to open the custom_functions file and get ready to edit this file. Around line 346 look for the $action_identifier variable. We are going to change the if statement there with the recent updates. So copy and paste this code below: if($action_identifier == 'tweets'){ //***PASTE CODE BELOW IN HERE **** }
if (!class_exists('Codebird')) {
require ('twitterlib/codebird.php');
}
$username = get_option('nets_twitname');
//$consumer_key = get_option('nets_conskey');
//$consumer_secret = get_option('nets_consecret');
//$access_token = get_option('nets_acctoken');
//$access_token_secret = get_option('nets_accsecret');
$consumer_key = 'your consumer_key here';
$consumer_secret = 'you consumer_secret here';
$access_token = 'your access_token here';
$access_token_secret = 'your access_token_secret here';
$username = trim( urlencode( $username ) );
$params = array(
'screen_name' => $username,
'trim_user' => true,
'count' => 10,
'consumer_key' => $consumer_key ,
'consumer_secret' => $consumer_secret,
'access_token' => $access_token,
'access_token_secret' => $access_token_secret
);
Codebird::setConsumerKey($params['consumer_key'], $params['consumer_secret']);
$cb = Codebird::getInstance();
$cb->setToken($params['access_token'], $params['access_token_secret']);
$cb->setReturnFormat(CODEBIRD_RETURNFORMAT_ARRAY);
try {
$twitter_data = $cb->statuses_userTimeline(array(
'screen_name'=>$params['screen_name'],
'count'=>10
));
} catch (Exception $e) { return __('Error retrieving tweets','localize'); }
if (isset($twitter_data['errors'])) {
$cb->debug($options, __('Twitter data error:','localize').' '.$twitter_data['errors'][0]['message'].'
');
}
if (!isset($twitter_data['errors'])) {
update_option( 'nets_tweetsave', $twitter_data );
}

Step 4

Now we will make some more changes to the widgets.php for variable $tweets and $acountname inside class singletweet_widgets. Some around line 635 and 636 they should read like this: $tweets = get_option('nets_tweetsave'); $accountname = get_option('nets_twitname');

That should do it!. Hopefully this helps someone looking for a quick solution without having to update their current feast theme. I really appreciate they guys from cro.ma are always up to date and that helps a lot.

Posted in: Blog

Leave a Comment (0) ↓

Leave a Comment

To use reCAPTCHA you must get an API key from https://www.google.com/recaptcha/admin/create