WordPress Plugin: Hot’n'Cold
Hot’n'Cold è un plugin per WordPress che mostra targhette colorate diverse a seconda della popolarità dei post, basandosi sulle statistiche di Jetpack.

Se per caso vi siete mai chiesti come fare a visualizzare la lista dei vostri ultimi checkin su Foursquare, con tanto di mappetta di Google, senza stare a installare plugin (se per caso usate un CMS, come WordPress), ecco il codice che fa per voi.
Questo snippet può essere usato in qualsiasi sito, non solo quelli made in WordPress, basterà modificare a dovere i punti segnalati.
|
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 |
// Visualizzare lista degli ultimi checkin di Foursquare - Shambix function fsq_shambix() { $foursq_feed_URL ='VE5OO4HCULPTZQGYC45DLMMV4CSHHFJS'; //questo è il "codice utente" dal quale verrà presa la lista, per sapere il vostro basta andare su http://foursquare.com/feeds $foursq_counts = 9; //quanti checkin volete visualizzare in tutto $foursq_final_feed_URL = 'http://feeds.foursquare.com/history/'.$foursq_feed_URL.'.rss'; $foursq_object = simplexml_load_file($foursq_final_feed_URL . '?count=' . $foursq_counts); $items = $foursq_object->channel; $foursq_checkin = $items->item; $small_image_width = '85'; //larghezza della mappa $small_image_height = '85'; //altezza della mappa //$icon = '|icon:http://foursquare.com/img/categories/shops/default.png'; //se volete usare un marker personalizzato, cambiate l'url dell'immagine come vi pare, scommentate questa riga e commentate la prossima $icon = ''; //se non volete usare un marker personalizzato, lasciate il codice così com'è, altrimenti seguite la riga sopra e commentate questa // NON modificare niente qui sotto $count = 0; foreach ($foursq_checkin as $item) { $geopoint = $item->children('georss', true)->point; $descritpion = $item->description; $title = $item->title; $img_src = "http://maps.google.com/maps/api/staticmap?sensor=false&size={$small_image_width}x{$small_image_height}&zoom=15&markers=size:small$icon|$geopoint"; $img = "<img src='$img_src' alt='$title' title='$title' width='$small_image_width' height='$small_image_height' >"; if ($item->link != '') { echo "<li class='fsq_checkin'><div class='fsq_map'><a href='http://maps.google.com/maps?q=$geopoint' rel='nofollow' target='_blank'>$img</a></div></li>"; $count++; if ($count == $foursq_counts) {break;} } } } |
Per “attivare” la funzione, adesso non dovete far altro che inserire il successivo codice nel punto dove volete visualizzare i checkin.
|
1 2 3 4 |
<div class="fsq"> <h4>My Foursquare</h4> <ul><?php fsq_shambix(); ?></ul> </div> |
Adesso non vi rimane che creare lo stile che volete nel vostro .css!
If you var_dump($foursq_checkin) you should get an Array of possible data to extract. So you are free to extend the code with more data, and echo it where you like!
After some digging I solved the problem. I really am a Newbie regarding php but now I figured out how to implement the code on my site! Works very nice! I have an additional question: Is it also possible to list the location name as text (for Example “Rome, Italy”) and have that that text as a link to Google Maps?
I have roughly edited your snippet here:
http://www.distant-horizons.de/index2.php
Ciao from Austria
Edgar
Thank you very much for this snippet! I stumbled upon it through Google Search. I do not know PHP at all (well I know the very very basics…) and I want to implement this on my index.php
I know what to do with the second part of the snippet but how do I deal with the first part? Do I have to save it to a file called fsq_shambix.php and place it in the root directory or do I have to copy the lines into the header section of my php file? Both ways seem not to work… I am aware of the fact that this is a very dumb / newbie question…….
my site where I want to implement this is http://www.distant-horizons.de
Thank you very much in advance and best wishes from Austria!
Edgar