Last Twitter statuses: Pon tus últimas actualizaciones de Twitter en tu Wordpress (plugin de WP)

March 15th, 2009 | albertofortes |

Otro plugin tonto para Wordpress.
Está en versión beta, pero por ahora te permite elegir el usuario de twitter (lo lógico es que sea el tuyo), cuántas actualizaciones quieres, por defecto 5, el color de las filas, el tamaño de tu avatar, el mensaje del heading etc.
Ten en cuenta que cuando te lo instales, debes poner tu nombre de usuario, y tus últimas actualizaciones de estatus aparecerán en el sidebar de tu Wordpress. [Nota tu sidebar debe llamarse #sidebar, pero si no es así puedes cambiarlo también desde las variabels de configuración, incluso ponerlo en el footer, header, etc]
El código:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
/*
Plugin Name: Last Twitter Statuses
Plugin URI: http://www.albertofortes.com/blog/?p=673
Description: inserta tus últimos estatus de Twitter en tu blog
Author: Alberto Fortes
Version: beta
Author URI: http://www.albertofortes.com
*/
 
function writeTwitter()
{		
	//Configure the plugin:
	$Your_Twitter_Username = 'albertofs';
 
	$Where = '#footer'; // Where put the plugins, by defaul in #sidebar
	$plugin_size = ''; //void to get the size of his parent
	$Howmany_status_display = 5;
	$Size_of_avatar_in_pixels = 23;
	$Heading_n = 'h3'; //h3, h4, h5 or h6 in depends of your code.
	$Heading_Text = 'Últimos Twitters:';
	$zebra_odd_color = '#f0f0f0'; //please, hex with # before or void to none
	$zebra_even_color = '#fff'; //please, hex with # before or void to none
 
 
	$script =	"<script type=\"text/javascript\">\n" .	
				"var MiUrl = '".$Your_Twitter_Username."';\n" .
				"$(document).ready(function(){\n" .
					"$('".$Where."').append('<".$Heading_n.">".$Heading_Text."</".$Heading_n."><div id=\"tweeterWrap\"><ul></ul></div>');\n" .
					"var url = 'http://search.twitter.com/search.json?q=from%3A'+ MiUrl +'&rpp=".$Howmany_status_display."&callback=?';\n" .
					"$.getJSON(url,  function(data){\n" .
						"$.each(data.results, function(i,item){\n" .
							"$('#tweeterWrap ul').append('<li class=\'clearfix\'><img src=\"' + item.profile_image_url +'\" alt=\"' + item.from_user + '\" /><p>'+item.text.replace(/(\w+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+)/gi, '<a href=\"$1\">$1</a>').replace(/[\@]+([A-Za-z0-9-_]+)/gi, '<a href=\"http://twitter.com/$1\">@$1</a>')+' <a class=\'small\' href=\'http://www.twitter.com/'+item.from_user+'/statuses/'+item.id+'\'>'+item.created_at+'</a></p></li>');\n" .
							"$('#tweeterWrap ul li:even').addClass('impar');\n" .
							"$('#tweeterWrap ul li:odd').addClass('par');\n" .
						"});\n" .
						"$('#tweeterWrap ul').after('<p class=\'t-r\'><a href=\"http://twitter.com/' + MiUrl + '\">Visitar mi Twitter &raquo;</a></p>');\n" .
					"});\n" .
				"});\n" .
				"</script>\n";
 
	$style = 	"<style type='text/css' media='screen'>\n" .
				"/*	Plugin para Wordpress para ver tus últimos estatus en el sidebar\n" .
				"	Author: Alberto Fortes\n" .
				"	Author Uri: http://www.albertofortes.com\n" .
				"	Plugin Uri: http//www.albertofortes/blog/\n" .
				"	Version: beta\n" .
				"	Date: 15, march 2009\n" .
				"*/\n" .
				"#tweeterWrap {margin:10px 0; width:".$plugin_size."}\n" .
				"#tweeterWrap ul {margin:0 0 5px 0; padding:5px; border:1px solid #d3d3d3;background: #fff; border-radius:0 5px 5px;-moz-border-radius:0 5px 5px;-ms-border-radius:0 5px 5px;-webkit-border-radius:0 5px 5px;}\n" .
				"#tweeterWrap li {padding: 5px; background: ".$zebra_odd_color.";clear:left;}\n" .
				"#tweeterWrap li a.small {fon-family: verdana; font-size:8px;}\n" .
				"#tweeterWrap li.impar {background: ".$zebra_even_color.";}\n" .
				"#tweeterWrap li.par {background: ".$zebra_odd_color.";border:1px solid #d3d3d3;border-width: 1px 0;}\n" .
				"#tweeterWrap li img {float:left;width:".$Size_of_avatar_in_pixels."px;height:".$Size_of_avatar_in_pixels."px;border:1px solid #ccc; margin: 0 5px 0 0;}\n" .
				"#tweeterWrap li p {line-height:1.2em;font-size: 11px;color:#666;margin:0;}\n" .
				"#tweeterWrap  p.t-r {text-align:right;}\n" .
				"</style>\n";
 
	echo $script . $style;
}
 
add_action('wp_head','writeTwitter');
 
?>

Para configurarlo fácilmente puedes cambiar las variables:

 
function writeTwitter()
{		
	//Configure the plugin:
	$Your_Twitter_Username = 'albertofs';
 
	$Where = '#footer'; // Where put the plugins, by defaul in #sidebar
	$plugin_size = ''; //void to get the size of his parent
	$Howmany_status_display = 5;
	$Size_of_avatar_in_pixels = 23;
	$Heading_n = 'h3'; //h3, h4, h5 or h6 in depends of your code.
	$Heading_Text = 'Últimos Twitters:';
	$zebra_odd_color = '#f0f0f0'; //please, hex with # before or void to none
	$zebra_even_color = '#fff'; //please, hex with # before or void to none

Puedes verlo funcionando en este blog en el sidebar, descargarlo desde aquí, y para instalarlo guardarlo en tu carpeta wp-content/plugins

Requerimientos:
- JQuery, si no lo tienes instalado, puedes bajártelo desde http://jquery.com/

Deja tu comentario