Classipress - Short URL
Hi, I have solved how to make short url link in your custom form.
Edit file appthemes-functions.php
1. Add this function into the file
//url shortener
function get_tiny_url($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;
}
2. change function appthemes_make_url_clickable($matches) to:
function appthemes_make_url_clickable($matches) {
$url = $matches[2];
$url = esc_url($url);
if (empty($url))
return $matches[0];
$new_url = get_tiny_url($url);
return $matches[1] . "<a target=\"_blank\" href=\"$new_url\" rel=\"nofollow\">$new_url</a>";
}
That's all