Hi.
i know other automatic creating links but i am searching another thing.
i want to make this :
when i write on my panel :
http://www.adomain.com/sdfsdjfjsdfjsdojfoisdjfodsfsdfsdf.html
it's changing like this :
http://www.adomain.com/sdf...df.html (but same url at top)
vbulletin and smf have this hack.
how can i make like this hack ?
i have a tall links :(
i hope, i can explain my problem.
thanks.
fitztrev
Member
Posted 1 month ago #
I released a plugin that does this: Comment Url Compacter
It does it for comments only, but add this line to it, and it will work the way you want, too:
add_filter('the_content', 'compact_comment_urls');
i added this line but it's not work on my content pages.
it's just working on comments yet.
any mistake ?
<?php
/*
Plugin Name: Comment URL Compacter
Plugin URI: #
Description: When long URLs are left in a comment, they can break a theme and be obnoxious. This plugin shortens them so they look much nicer.
Version: 0.1
Author: Trevor Fitzgerald
Author URI: http://www.trevorfitzgerald.com/
*/
function compact_urls($link) {
if ( strlen($link) > 50 ) {
$link = preg_replace('/(https*:\/\/)*(www.)*/', '', $link);
$link = substr($link, 0, 18) . '…' . substr($link, -20);
}
return $link;
}
function compact_comment_urls($comment) {
$pattern = '/<a(.*)>(.*)<\/a>/ei';
$replace = '"<a$1>" . compact_urls("$2") . "</a>"';
$comment = preg_replace($pattern, $replace, $comment);
return $comment;
}
add_filter('comment_text', 'compact_comment_urls');
add_filter('the_content', 'compact_comment_urls');
?>
is nobody help me :(
please brada..
it's very important.
fitztrev
Member
Posted 1 month ago #
I just tested exactly like you have pasted above and it worked perfectly.
i am using,
2.3.3. version ?
what about yours ?
it's not working brada.. :(
fitztrev
Member
Posted 1 month ago #
Is the URL that you are testing in your content indeed long enough? It has to be at least 50 characters.
You can change that on this line:
if ( strlen($link) > 50 ) {
yes i see that.
i am sure it's enough long.
i captured a screenshot for my problem.
please look :
http://img146.imageshack.us/img146/4656/18482182xb4.png
(at comment, everything OK, but at content it is not working.)
WP Version : 2.3.3.
The codes are the same of top what you say.
have you got any idea ?
:(
fitztrev
Member
Posted 1 month ago #
Are they both actually links? If you click them do they do anything? or are they just text?
The comment one is usually automatically turned into a link while the post one remains just text. That might be what the problem is.
Make it a link.
ow..
thanks a lot.
it's OK.
i forgot to link to url.
it's working fine.
thanks :)