QR URL too long
The QR codes generate by wpmp_barcode.php are very long. This makes them harder and slower to scan.
For example, a typical URL on my blog is
http://shkspr.mobi/blog/index.php/2009/12/do-newspapers-get-the-mobile-web/?wpmp_switcher=true
Using the post's GUID, this could be rendered as the shorter URL
http://shkspr.mobi/blog/?p=1503&wpmp_switcher=true
Thus making the QR much easier to scan. If we know that the Switcher Mode is by browser detection - we could omit the wpmp_switcher=true, giving us
http://shkspr.mobi/blog/?p=1503
For example, a typical URL on my blog is
http://shkspr.mobi/blog/index.php/2009/12/do-newspapers-get-the-mobile-web/?wpmp_switcher=true
Using the post's GUID, this could be rendered as the shorter URL
http://shkspr.mobi/blog/?p=1503&wpmp_switcher=true
Thus making the QR much easier to scan. If we know that the Switcher Mode is by browser detection - we could omit the wpmp_switcher=true, giving us
http://shkspr.mobi/blog/?p=1503
Leave a comment
Ready to test in Rev 190542
function wpmp_barcode_widget($args) {
extract($args);
print $before_widget;
if (($title = get_option('wpmp_barcode_title'))=='') {
$title = __("Our mobile site", 'wpmp');
}
print $before_title . $title . $after_title;
$size = get_option('wpmp_barcode_size');
if(!is_numeric($size) && $size < 64) {
$size = 190;
} else {
$size = floor($size);
}
$link = get_option('wpmp_barcode_link');
//If the user hasn't specified a URL in the widget admin panel
if (trim($link)=='')
{
//Get the unique ID of this post http://codex.wordpress.org/Function_Reference/get_the_ID
//We can use this to craft a shorter URL, thus making the QR code smaller and easier to scan.
//http://example.com/?p=1234 rather than http://example.com/2010/01/05/some-title
//Using http://codex.wordpress.org/Function_Reference/get_page
$page_data = get_page( get_the_ID() );
$link = $page_data->guid; //[guid] => (http://mydomain/?page_id={[ID]})
//We need to add wpmp_switcher=true to force the mobile version if the switcher uses domain mapping.
if (get_option('wpmp_switcher_mode') != 'browser' )
{
$link .= "&wpmp_switcher=mobile";
}
}
$url = "http://chart.apis.google.com/chart?chs=" .
$size . "x" . $size .
"&cht=qr&choe=UTF-8&chl=" .
urlencode($link);