Categories
Technology Twitter Wordpress

New twitter plugin – to show tweets in rotation

As tweeted yesterday, I’ve just completed a new WordPress plug-in to show rotating tweets.

It’s easy to add using a widget or a shortcode in a post or on a page such as:

[rotatingtweets screen_name="mpntod"]

and, as a result, you get:

At a briefing on the Hampshire Local Transport Plan - an area where we need major change with a much stronger ambitions for decarbonisation and sustainable active travel hants.gov.uk/transport/loca…

About 2 months ago from Martin Tod's Twitter via Twitter Web App

For a bit more fun, you can add some extra options such as:

[rotatingtweets screen_name="mpntod" rotation_type='toss']

Problem retrieving data from Twitter

And the latest version goes for the official look:

[rotatingtweets screen_name="mpntod" official_format='1']

Problem retrieving data from Twitter

[rotatingtweets screen_name="mpntod" official_format='2']

Problem retrieving data from Twitter

You can also search:

[rotatingtweets search='#secretcourts']

Problem retrieving data from Twitter

You can see the widget in action on the top-right of this page.

You can download the plug-in from here.

All this was only possible due to the good people of WordPress, the Twitter API, jQuery and jQuery Cycle – and Syd who showed me jQuery Cycle in the first place  – so a big thank you to them too! 🙂

Categories
Wordpress

WordPress broken your Google map? This is how to fix it

You might have noticed some problems with the Google Map on this site at some point in the past.

Information ‘balloons’ had jagged edges and looked like this:

Faulty information balloon on Google Map - showing jagged corners in top and bottom right hand corners

when they should have looked like:

Fixed info balloon on Google Map with nicely smooth rounded cornersThe problem turned out to be with WordPress – particularly the TwentyTen stylesheet used as a base for the Winchester Marmalade template for this site.

In essence, this section of the stylesheet that sets the width for images on the WordPress page makes the images used for the map too narrow:

#content img {
margin: 0;
max-width: 640px;
}

So the daughter stylesheet needs to include something that gets rid of the width limit in the map like:

#content .boundarymap img {
max-width: none;
}

Many thanks to security_man and p for posting solutions to the problem.

Categories
Wordpress

Updated WordTube code

Just discovered that updating a plug-in deletes any spare files in its directory.

As a result, my hack to the Wordtube plugin disappeared.

This messed up my solution to the Wordtube streaming playlist problem.

To avoid having to re-upload my re-edited version of the myextractXML.php file every time the plug-in is uploaded, here it is again:

<?php
/*
+----------------------------------------------------------------+
+   wordtube-XSPF XML output for playlist
+   by Alex Rabe reviewed by Alakhnor
+   required for wordTube
+----------------------------------------------------------------+
*/


// look up for the path
if ( !defined('ABSPATH') )
    require_once( dirname(__FILE__) . '/wordtube-config.php');

global $wpdb;

// get the path url from querystring
$playlist_id = $_GET['id'];

$title = 'WordTube Playlist';

$themediafiles = array();
$limit = '';

if (substr($playlist_id,0,4) == 'last') {
    $l= (int) substr($playlist_id,4);
    if ($l <= 0) $l = 10;
    $limit = ' LIMIT 0,'.$l;
    $playlist_id = '0';
}
// Otherwise gets most viewed
if ($playlist_id == 'most') {
    $themediafiles = $wpdb->get_results("SELECT * FROM $wpdb->wordtube WHERE counter >0 ORDER BY counter DESC LIMIT 10");
// Otherwise gets mp3
} elseif ($playlist_id == 'music') {
    $themediafiles = $wpdb->get_results("SELECT * FROM $wpdb->wordtube WHERE file LIKE '%.mp3%' ORDER BY vid DESC");
// Otherwise gets flv
} elseif ($playlist_id == 'video') {
    $themediafiles = $wpdb->get_results("SELECT * FROM $wpdb->wordtube WHERE file LIKE '%.flv%' ORDER BY vid DESC");
// Shows all files when 0
} elseif ($playlist_id == '0') {
    // Updated to work with version 3.6 of the database
    $themediafiles = $wpdb->get_results( "SELECT * FROM $wpdb->wordtube ORDER BY vid DESC ".$limit );
// Otherwise gets playlist
} else {
    // Remove all evil code
    $playlist_id = intval($_GET['id']);
    $playlist = $wpdb->get_row("SELECT * FROM $wpdb->wordtube_playlist WHERE pid = '$playlist_id'");
    if ($playlist) {
        $select  = " SELECT * FROM {$wpdb->wordtube} w";
        $select .= " INNER JOIN {$wpdb->wordtube_med2play} m";
    // Updated to work with version 3.6 of the database
        $select .= " WHERE (m.playlist_id = %d" ;
        $select .= " AND m.media_id = w.vid) GROUP BY w.vid ";
        $select .= " ORDER BY m.porder {$playlist->playlist_order} ,w.vid {$playlist->playlist_order}";
    // Updated to work with version 3.6 of the database
        $themediafiles = $wpdb->get_results( $wpdb->prepare( $select , $playlist_id ) );
    // End update
        $title = $playlist->playlist_name;
    }
}

// Create XML / XSPF output
header("content-type:text/xml;charset=utf-8");
   
echo "\n"."<playlist version='1' xmlns='http://xspf.org/ns/0/'>";
echo "\n\t".'<title>' . esc_attr($title) . '</title>';
echo "\n\t".'<tracklist>';
   
if (is_array ($themediafiles)){

    foreach ($themediafiles as $media) {
       
                $creator = esc_attr(stripslashes($media->creator));
                if ($creator == '')
                    $creator = 'Unknown';
                if ($media->image == '')
                    $image = get_option('siteurl') . '/wp-content/plugins/' . dirname( plugin_basename(__FILE__) ) . '/images/wordtube.jpg';
                else
                    $image = $media->image;
                $file = pathinfo($media->file);
// Added by MT starts
                $mediafile = $media->file;
                if (substr($mediafile, 0, 4) == 'rtmp') {
                    preg_match('/^(.+)\?id=(.+)/', $mediafile, $match);
                    if (!empty ($match)) {     
                        $streamer = $match[1];
                        $mediafile = $match[2];
                    }
                }
// ends
        echo "\n\t\t".'<track>';
        echo "\n\t\t\t".'<title>' . esc_attr( stripslashes($media->name) ) . '</title>';
        echo "\n\t\t\t".'<creator>' . esc_attr($creator) . '</creator>';
        echo "\n\t\t\t".'<location>' . esc_attr($mediafile) . '</location>'; //modified by MT
// Added by MT
        if(!empty($streamer)):
            echo "\n\t\t\t".'<meta rel="streamer"/>' . esc_attr($streamer) . '';
        endif;
// ends
        echo "\n\t\t\t".'<image>' . esc_attr($image) . '</image>';
        echo "\n\t\t\t".'<annotation>' . esc_attr( stripslashes($media->description) ) .  '</annotation>';
        echo "\n\t\t\t".'<id>' . $media->vid . '</id>';
        echo "\n\t\t\t".'<counter>' . $media->counter . '</counter>';
        echo "\n\t\t\t".'<info>' . esc_attr($media->link) . '</info>';
        echo "\n\t\t".'</track>';
    }
} else {
    print_r($themediafiles);
}
     
echo "\n\t".'</tracklist>';
echo "\n"."</playlist>\n"; 

?>

Updated again!

This code was further updated on October 16, 2013 to reflect this change to the WordPress API.

Categories
Wordpress

Experimenting with Social Media Map Pins

Mildly astonished not to have found these somewhere already.  Here are some basic attempts at Twitter and Flickr social media map pins for Google Maps.

Flickr map pin Flickr map pin Flickr map pin Flickr map pin Twitter map pin Twitter map pin

And here are the political ones I did ages ago for Ming.

Google Maps marker for speeches made Google Maps marker for upcoming meetings Google Maps marker for MPs Google Maps marker for MEPs

Categories
Wordpress

Fixing the Wordtube video player to stream from playlists

Ever since moving my video to stream from Amazon, I’d been getting a rather annoying error on the otherwise excellent Wordtube plugin with playlists: in essence it refused to play any of the streamed videos on the playlist with the error message ‘playlist could not be loaded due to crossdomain policy restrictions’.

After much playing around, I finally found the likely cause of the problem via this guide to XML playlists on the JW Player website.

In essence, Wordtube was sending the format it uses to store the location for streamed video direct to the JW Player – instead of the format JW Player needed.

The playlist file was including this:

<location>rtmp://video.martintod.org.uk/cfx/st?id=video/LunchtimeObamaReportReloaded.flv</location>

when it needed to include this:

<location>video/LunchtimeObamaReportReloaded.flv</location>
<meta rel="streamer"/>rtmp://video.martintod.org.uk/cfx/st

Fortunately, this was a fairly quick fix. The code for the playlist is in the Wordtube directory at myextractXML.php and you can borrow most of the code to make the necessary change from wordTubeClass::ReturnLocation() in /lib/wordtube.class.php.

I attach a modified version of myextractXML.php here here and you can see the functioning video playlist here.