Asfihani Dicatet Ben Ora Lali™ (literally mean: dicatat biar tidak lupa)

Link Summarizer Patch

I use Link Summarizer plugin for WordPress, and it work great. Until I found there is no text limitation for displayed URL. So I decide write a small modification to limit the output of displayed URL. This patch will limit displayed URL to 70 characters long (sorry, the magic number is hardcoded :-(). For example:

Before:
Screenshot-3.png

After applying patch:

Screenshot-4.png

How to apply the patch

You can apply the patch manually or if you have shell access you can do it better (see below). To apply this patch manually, open link-summarizer.php file with your favourite editor. Modify the line 228 (est.) in function link_summary :

$matches[2][$i]

with following code:

lnsum_limit_link_output($matches[2][$i])

Then insert the following function in the bottom file just before ?> mark:

function lnsum_limit_link_output($input) {
 	$link_url_junk = $input;
 	$lnsum_url_limit = 70;
 	$lnsum_url_range = $lnsum_url_limit / 2;
 	if (strlen($link_url_junk) >= $lnsum_url_limit) {
 	        $link_url_junk = substr($link_url_junk,0,$lnsum_url_range) ."...". substr($link_url_junk,-$lnsum_url_range,$lnsum_url_range);
 	}
 	return $link_url_junk;
 }

If you have direct access to your hosting (shell access), you can do it better. After uploading the patch in your wordpress directory (eg. wp-content/plugins/link-summarizer/), just invoke the following command:

patch < limit_url_output.patch

The patch is here: limit_url_output.patch

Update: Link Summarizer 1.5.5 has limit text support

Random Posts:




4 Comments

1

Posted by HowdyNo Gravatar on 6 January 2008 14:01:57 WIB
Using Internet Explorer Internet Explorer 6.0 on Windows Windows XP

Notice on site post site, you use social bookmarking with “Link Summary”. How do you get “obsocialbookmarker” to work with “Link Summary” to work such that it doesn’t list social bookmarking links added to each post. Can you please help and provide what RegEx syntax you entered correctly. I’ve been spending quite sometimes on this :( Thank you.


2

Posted by AsfihaniNo Gravatar on 7 January 2008 08:01:52 WIB
Using Mozilla Firefox Mozilla Firefox 2.0.0.11 on Ubuntu Linux Ubuntu Linux

Hello, actually the regex pattern already described clearly on obsocialbookmarker site. It is pretty simple, just escape special characters (known as metacharaters) with slash (\) in domain that you wouldn’t show.

Like del.icio.us become del\.icio\.us or google.com/bookmarks become google\.com\/bookmarks etcetera.

Below is my current regex, based on social site or other plugin that I have used.

del\.icio\.us
technorati\.com
digg\.com
www\.facebook\.com
www\.google\.com\/bookmarks
www\.stumbleupon\.com
favorites\.live\.com
www\.netscape\.com
myweb2\.search\.yahoo\.com\/myresults\/bookmarklet
www\.bloglines\.com
www\.newsvine\.com
alexking\.org\/projects\/wordpress\/popularity-contest
deliciousdays\.com
reddit\.com\/submit

Hope it help.


3

Posted by Christoph ErdleNo Gravatar on 3 October 2008 17:10:18 WIB
Using Safari Safari 525.20.1 on Mac OS X Mac OS X 10.5.5

Hi,

Link Summarizer 1.5.5 introduced the feature of truncating the link text to a value defined in the admin pages of the plugin. Further the provided patch can not be applied as there was a code rewrite.

Best regards.


4

Posted by AsfihaniNo Gravatar on 9 October 2008 14:10:10 WIB
Using Mozilla Firefox Mozilla Firefox 3.0.3 on Mac OS X Mac OS X 10

Thank you Chris. Article updated.


Leave a Comment