Hello, actually I'm using a simple function that uses tinyurl.com API to make short urls, I've been using it for quite a while now and not only for osclass but on many of my websites that support sharing posts systems.
To implement it, just open your functions.php on your theme's main folder and paste the following code:
/*-----------------------------------------------------------------------------------*/
/* URL Shortener
/*-----------------------------------------------------------------------------------*/
function wnc_shorturl($url) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,'http://tinyurl.com/api-create.php?url='.$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
To use this function on an item just write the following to display the shortened url for it:
<?php echo wnc_shorturl(osc_item_url()); ?>
Aditionally you can display it into a disabled text field (just like YouTube) and make selectable using JavaScript if you want, here's the code:
<input id="txtfld" class="itemlinkspace" type="text" readonly="readonly" value="<?php echo wnc_shorturl(osc_item_url()); ?>" onClick="SelectAll('txtfld');" />
The JavaScript is as follows (paste it just after the code above):
<script type="text/javascript">
function SelectAll(txtfld)
{
document.getElementById(txtfld).focus();
document.getElementById(txtfld).select();
}
</script>
Hope that helps.