HELP wordpress,make dash in the middle of the hotlink...

Status
Not open for further replies.

jozawa

Member
6
2010
0
0
Hey WJ,
wan to ask,what wp plugin must be use to make hotlink shorter by inserting dash in the middle of the hotlink.
before:
Code:
http://www.wupload.com/file/86559491/moviez.part3.rar
after:
Code:
[URL]http://www.wupload.com....9491/moviez.part3.rar[/URL]
and when click into the link, it will redirect first into ad, then go to the original site
Any help or hints are much appreciated.
Thanks!
 
2 comments
It could probably be achieved with some simple html / css coding.
I dont have time to look into it properly right now though.

In the meantime, try searching for plugins with this keyword - "Truncate"

---- edit ----

Ok, I had a spare second to take a look for you.
It seems like it's a PHP function that will sort this out for you.

What your trying to do it "truncate" so, I done a search for "truncate links"... and came up with these results.

Code:
http://www.google.co.uk/search?q=truncate+links&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a
The top link gives you more or less what you want - "I think". I'm not a PHP expert, but it looks like it will do the trick.

Code:
http://psoug.org/snippet/Truncate-Links-Over-X-Chars-long_230.htm
Code:
<?PHP
 
FUNCTION handle_url_tag($url, $link = ''){
     GLOBAL $FORUM_user;
 
     // maximum link length
     $MAXLEN = 50;
 
     // if too long, clip it to how many chars?
     $CLIPTO = 45;
 
     $full_url = STR_REPLACE(ARRAY(' ', '\'', '`', '"'), array('%20', '', '', ''), $url);
     if (strpos($url, 'www.') === 0)               // If it starts with www, we add http://
          $full_url = 'http://'.$full_url;
     else if (strpos($url, 'ftp.') === 0)     // Else if it starts with ftp, we add ftp://
          $full_url = 'ftp://'.$full_url;
     else if (!preg_match('#^([a-z0-9]{3,6})://#', $url, $bah))      // Else if it doesn't start with abcdef://, we add http://
          $full_url = 'http://'.$full_url;
 
     // Ok, not very pretty :-)
     $link = ($link == '' || $link == $url) ? ((strlen($url) > $MAXLEN) ? substr($url, 0 , $CLIPTO).' … '.substr($url, -10) : $url) : stripslashes($link);
 
     return '<a href="'.$full_url.'">'.$link.'</a>';
}
 
?>
But how to implement this, I don't exactly know. Hopefully others will drop by and help you out.
Anyway, I hope this helps you out at some degree :-)
 
Last edited:
It could probably be achieved with some simple html / css coding.
I dont have time to look into it properly right now though.

In the meantime, try searching for plugins with this keyword - "Truncate"

---- edit ----

Ok, I had a spare second to take a look for you.
It seems like it's a PHP function that will sort this out for you.

What your trying to do it "truncate" so, I done a search for "truncate links"... and came up with these results.

Code:
http://www.google.co.uk/search?q=truncate+links&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a
The top link gives you more or less what you want - "I think". I'm not a PHP expert, but it looks like it will do the trick.

Code:
http://psoug.org/snippet/Truncate-Links-Over-X-Chars-long_230.htm
Code:
<?PHP
 
FUNCTION handle_url_tag($url, $link = ''){
     GLOBAL $FORUM_user;
 
     // maximum link length
     $MAXLEN = 50;
 
     // if too long, clip it to how many chars?
     $CLIPTO = 45;
 
     $full_url = STR_REPLACE(ARRAY(' ', '\'', '`', '"'), array('%20', '', '', ''), $url);
     if (strpos($url, 'www.') === 0)               // If it starts with www, we add http://
          $full_url = 'http://'.$full_url;
     else if (strpos($url, 'ftp.') === 0)     // Else if it starts with ftp, we add ftp://
          $full_url = 'ftp://'.$full_url;
     else if (!preg_match('#^([a-z0-9]{3,6})://#', $url, $bah))      // Else if it doesn't start with abcdef://, we add http://
          $full_url = 'http://'.$full_url;
 
     // Ok, not very pretty :-)
     $link = ($link == '' || $link == $url) ? ((strlen($url) > $MAXLEN) ? substr($url, 0 , $CLIPTO).' … '.substr($url, -10) : $url) : stripslashes($link);
 
     return '<a href="'.$full_url.'">'.$link.'</a>';
}
 
?>
But how to implement this, I don't exactly know. Hopefully others will drop by and help you out.
Anyway, I hope this helps you out at some degree :-)

thanks Ashleyuk1984 , i will try that one
 
Status
Not open for further replies.
Back
Top