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 geoffrey.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 { }  

/* A tweet (since 1.1.5) */
.juiz_last_tweet_item { }

/* Position of a tweet (since 1.2.2) */
.jltw_item_first { }
.jltw_item_last { }

/* if is alone */
.jltw_item_alone { }

/* if not first or last one */
.jltw_item_2 { }
.jltw_item_3 { }
etc…

/* The tweet content */  
.juiz_lt_content { } 

/* The part after the tweet content (since 1.1.5) */
juiz_last_tweet_footer_item { }
   
/* The links inside a tweet */  
.juiz_last_tweet_tweetos { }  
.juiz_last_tweet_hastag { }  
.juiz_last_tweet_url { }

/* The container of action links */
.juiz_action_links { }
/* The different action links */
.juiz_al_reply { }
.juiz_al_retweet { }
.juiz_al_fav { }
   
/* The tweet metadata */  
.juiz_last_tweet_metadata { }  
   
/* 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.
You can use the keyword tweets, also. (since 1.2.0)

[jltw]
or since 1.2.0
[tweets]

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="1" transition="1" delay="7" cache="3600" links="1"]

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. Action links (retweet, reply, favorite) are displayed below each tweet.

Note: if you used the previous version of this shortcode, the version 1.1.3 needs 0 and 1 instead of False and True values respectively. Thanks.

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.

Template functions since 1.1.4

Template functions allow you to display list of tweets inside any theme template you need.
There are two functions: jltw($args) and get_jltw($args)

Example of use:

<div class="my_tweets_block">
	<?php
		/* your parameters */
		$jltw_args = array(
			'username'	=> 'geoffreycrofte',
			'nb_tweets'	=> 1,
			'avatar'	=> false,
			'cache'		=> 120,
			'transition'	=> false,
			'delay'		=> 8,
			'links'		=> true
		);

		/* display widget */
		jltw($jltw_args);
	?>
</div>

jltw() makes an echo, if you need to save data in a variable, use get_jltw().

Example of use:

<?php
	/* your parameters */
	$jltw_args = array(
		'username'	=> 'creativejuiz',
		'nb_tweets'	=> 2,
		'avatar'	=> true,
		'cache'		=> 1600,
		'transition'	=> true,
		'delay'		=> 10,
		'links'		=> false
	);

	/* set variable */

	$list_of_tweets = get_jltw($jltw_args);

	/* more later */
	echo $list_of_tweets;
?>

Since 1.2.0 you can use the_tweets( $args ) and get_the_tweets( $args ) instead of jltw( $args ) and get_jltw( $args )

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');
?>

Hook : juiz_ltw_target_attr

Change the '_self' default target value for all the links (almost, see next hook) generated by the Juiz Last Tweet Widget plugin
Example:

<?php
if( !function_exists('change_ltw_target_attr')) {
	function change_ltw_target_attr($target) {
		return '_blank';
	}
}
add_filter('juiz_ltw_target_attr', 'change_ltw_target_attr');
?>

Change the '_self' default target value for the optional action links below each tweet
Example:

<?php
if( !function_exists('change_ltw_target_attr_for_action_links')) {
	function change_ltw_target_attr_for_action_links($target) {
		return '_blank';
	}
}
add_filter('juiz_ltw_target_action_links_attr', 'change_ltw_target_attr_for_action_links');
?>

Hook : juiz_ltw_twitter_feed_not_loadable (since 1.1.5)

Change the "The RSS feed for this twitter account is not loadable for the moment." error message
Example:

<?php
if( !function_exists('change_juiz_ltw_twitter_feed_not_loadable')) {
	function change_juiz_ltw_twitter_feed_not_loadable($target) {
		return 'Tweets coming soon…';
	}
}
add_filter('juiz_ltw_twitter_feed_not_loadable', 'change_juiz_ltw_twitter_feed_not_loadable');
?>

Hook : juiz_ltw_twitter_has_a_problem (since 1.1.5)

Change the "Twitter has a problem with your RSS feed…" error message
Example:

<?php
if( !function_exists('change_juiz_ltw_twitter_has_a_problem')) {
	function change_juiz_ltw_twitter_has_a_problem($target) {
		return ''; // to remove this sentence for example
	}
}
add_filter('juiz_ltw_twitter_has_a_problem', 'change_juiz_ltw_twitter_has_a_problem');
?>

Hook : jltw_remove_follow_us_line (since 1.3.0)

Remove the "follow us" part of code (bird and message)
Example:

<?php
if( !function_exists('jltw_remove_follow_us')) {
	function jltw_remove_follow_us() {
		return true; // true remove the element
	}
}
add_filter('jltw_remove_follow_us_line', 'jltw_remove_follow_us');
?>

Hook : jltw_remove_metadata (since 1.3.0)

Remove the "date an source" part of code
Example:

<?php
if( !function_exists('jltw_remove_meta')) {
	function jltw_remove_meta() {
		return true; // true remove the element
	}
}
add_filter('jltw_remove_metadata', 'jltw_remove_meta');
?>

FAQ

The Twitter Bird image doesn't appear! What's happened?
Sorry, I don't know. Try to uninstall/install the plugin or just pick up the image in the svn repository.
Why the widget show me an error of load for my tweets ? since 1.0.1
First: do you have the latest version of this plugin?
Second: did you find the settings page, create your Twitter plugin?
My tweets are not always updated since 1.1.3
Since the v1.1.3, the cache system prefers keep your old tweets instead of displaying a error message due to a lack of tweets inside the Twitter flow.
It's a kind of security: old tweets are better than error message :)
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…
When I use my own CSS, defaults CSS seems to disappear ? only version 1.1.4
Yeah, sorry, it's a bug. Please, update the plugin…