Juiz LTW - Documentation

Geoffrey Crofte Developed, designed and polished by Geoffrey Crofte.
French blogger for Creative Juiz blog and Alsacréations community, I'm a code and pixels lover ! Find me on : Twitter, TryToTry Laboratory or crofte.fr

This file is a documention for the plugin Juiz Last Tweet Widget.
It will be updated each time with the plugin features.

Please, note that this documentation concerne all versions of the plugin. Read the "since" mention on each feature.

You like this plugin and want support it ?
Donate Tweet it

See also

Table of content

CSS Classes

If you need to use custom styles for your embedded tweets :

/* The big container */  
.juiz_last_tweet_widget { }  
       
/* The list of tweets and "follow us" container */  
.juiz_last_tweet_inside { }  
       
/* The list of tweets */  
.juiz_last_tweet_tweetlist { }  
       
/* The user avatar */  
.juiz_last_tweet_widget .user_avatar { }  
       
/* The user avatar link */  
.juiz_last_tweet_widget .user_avatar a { }  
       
/* The user avatar image */  
.juiz_last_tweet_widget .user_avatar img { }  
     
/* The tweet content */  
.juiz_lt_content { }  
   
/* The links inside a tweet */  
.juiz_last_tweet_tweetos { }  
.juiz_last_tweet_hastag { }  
.juiz_last_tweet_url { }  
   
/* The tweet metadata */  
.juiz_last_tweet_inner { }  
   
/* The source */  
.juiz_ltw_source { }  
   
/* The baseline */  
.juiz_last_tweet_follow_us { }  
   
/* The "follow" word */  
.juiz_ltw_follow { }  
   
/* The username link */  
.juiz_ltw_username { }  
   
/* The "on Twitter" words */  
.juiz_ltw_ontwitter { }  

You can improve your CSS editions by using Firebug plugin.

ShortCode since 1.1.0

This plugin has a Shortcode, a kind of BBcode, that allows you to display this widget where you want.
This shortcode uses the keyword jltw (Juiz Last Tweet Widget), a particular word to oust any conflict with other plugins.

[jltw]

Used in a post, this shortcode display the widget.
Morever, options are available. The list of options is the following :

So, you need to change the username, at least ;)

Basic ShortCode

[jltw username="your-account" nb="3" avatar="true"]

This sample of code show the 3 last tweets of the Twitter account named "your-account". It display the Twitter avatar (note: you can write avatar="something", it works).

Advanced ShortCode

[jltw username="your-account" nb="3" avatar="true" transition="true" delay="7" cache="3600"]

This sample does the same as the previous sample, it adds a slideshow with a delay of 7 seconds to display the 3 tweets one by one. A cache of 3600 seconds (1 hour) is used to maintain the speed of the page.

You can't desactivate default CSS when the widget is displayed with a shortcode. You'll need to overwrite it by using your own CSS file.

Hooks since 1.1.0

This plugin allows you to change some parts of its structure without broke the core.
The following samples of code can be inserted in the functions.php file.

In general, be careful when using several occurrences of this widget. Hooks presented here will apply to all occurrences simultaneously!

Hook : juiz_ltw_list_container_tag

Change the tag of the list container (<ul>) by another, for example:

<?php
if( !function_exists('replacing_by_div')) {
	function replacing_by_div() {
		return 'div';
	}
}
add_filter('juiz_ltw_list_container_tag', 'replacing_by_div');
?>

Hook : juiz_ltw_each_item_tag

Change the tag of each item (tweet) (<li>) by another, for example:

<?php
if( !function_exists('replacing_by_div')) {
	function replacing_by_div() {
		return 'div';
	}
}
add_filter('juiz_ltw_each_item_tag', 'replacing_by_div');
?>

Hook : juiz_ltw_user_avatar

Add things around avatar, or other manipulations using this hook. Example:

<?php
if( !function_exists('add_username_under_avatar')) {
	function add_username_under_avatar($avatar) {
		$new_content = $avatar.'<span class="avatar_username">@my_username</span>';
		return $new_content;
	}
}
add_filter('juiz_ltw_user_avatar', 'add_username_under_avatar');
?>

Hook: juiz_ltw_user_avatar_attr

You can also manipulate all the avatar attributes by using this hook. Example:

<?php
if( !function_exists('change_some_avatar_attr')) {
	function change_some_avatar_attr($avatar_attr) {
		// existing attributes
		$avatar_attr['title']	= __('Web expert on Twitter');
		$avatar_attr['src']	= '/my-own-avatar.png';
		$avatar_attr['alt']	= 'John Smith';
		$avatar_attr['width']	= '30';
		$avatar_attr['height']	= '30';
		
		// adding attributes
		$avatar_attr['attrs'] 	= array(
			'id'		=> 'jltw_avatar',
			'data-custom'	=> 'my-data'
		);
		return $avatar_attr;
	}
}
add_filter('juiz_ltw_user_avatar_attr', 'change_some_avatar_attr');
?>

Hook : juiz_ltw_each_tweet

Add things around each tweet, or other manipulations using this hook. Example:

<?php
if( !function_exists('add_arrow_before_tweet')) {
	function add_arrow_before_tweet($a_tweet) {
		$new_content = preg_replace(
				  '#<span class="juiz_lt_content">#',
				  '<span class="juiz_lt_content">→',
				   $a_tweet);
		return $new_content;
	}
}
add_filter('juiz_ltw_each_tweet', 'add_arrow_before_tweet');
?>

Hook : juiz_ltw_content

Add things around the widget container. Example:

<?php
if( !function_exists('see_more_tweets_on')) {
	function see_more_tweets_on($tweets_block) {
		$new_content = '<a href="http://twitter.com/my_username">'.
		               __('See more tweets on Twitter').
			       '</a>'.$tweets_block;
		return $new_content;
	}
}
add_filter('juiz_ltw_content', 'see_more_tweets_on');
?>

Hook : juiz_ltw_time_ago

Change the content of the "time ago" part of code or, with the same idea, delete, replace, or add content before and after "time ago" content.
Example:

<?php
if( !function_exists('see_more_tweets_link')) {
	function see_more_tweets_link($time_ago) {
		$time_ago['before']  = '<span>';
		$time_ago['content'] = __('See the status', 'juiz_ltw');
		$time_ago['after']   = __('on Twitter', 'juiz_ltw') . '</span>';
		
		return $time_ago;
	}
}
add_filter('juiz_ltw_time_ago', 'see_more_tweets_link');
?>

FAQ

Why the widget show me an error of load for my tweets ? since 1.0.1
Try to visit the link : http://search.twitter.com/search.rss?q=from%3AUSERNAME&rpp=2 by replacing "USERNAME" with your own username.
If nothing happens, try with : http://api.twitter.com/1/statuses/user_timeline.rss?screen_name=USERNAME&count=2
If nothing happens, it's the fault of Twitter API limitation.
If this link shows your 2 last tweets, it's the fault of my script, so contact me.
Why the widget shows me less tweets than I ask it to show me ? since 1.1.0
Twitter do what it wants to do with its feeds of tweets. This plugin uses both of feeds and controls the two to know which is available. The first available is chosen. If the chosen feed don't have tweets enought (example: 2 tweets whereas you chose 4 tweets to display) the selected stream will not allow you to display all your tweets you want.

You can try to solve a part of the problem by switching two variables in my code (see `wp-content/plugins/juiz-last-tweet-widget/juiz-last-tweet.php`) on lines 346 and 347. You have $search_feed1 and $search_feed2.
Just change 1 by 2, and 2 by 1.

A future update will allow you to change the feed directly from widget interface.
Why the widget show me "See the status" instead of the time ago ? since 1.1.0
You certainly host your site in a PHP4 installation…