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

4 Replies

  • 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.

  • 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.

  • 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.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.