KB Plugins

The best Wordpress plugins are free

Print this post

KB Linker v1.03

Now with options to set the link target and fix some problems that arise on non-English blogs. Thanks to Thomas Ohms for contributions.

Download KB Linker .

21 comments »

1
Ruth writes
at 2:24 pm on September 9, 2007 #

I love this plugin, and have it installed on a number of sites that I manage. I’ve noticed a problem, however; KBLinker does not detect when a word occurs inside of an HTML link tag, which messes up links that happen to contain words in its list.

If you look on my post archives page (http://www.toastyfrog.net/sitemap/) you’ll see an example of what I mean. About halfway down the page, under the category “Eccentricities” one of the titles is messed up. This happens because “my family” is in my KBLinker list, and links to a photo of my family. But in this case, it appears in a link to a post whose title contains the term, and KBLinker tries to add another link within the link, which breaks the code.

The same thing happens if you link to a Flickr photo whose name contains a keyword, etc.

Other than this one little glitch, however, this is a really useful plugin!

2
Thus saith Adam
at 7:57 am on September 10, 2007 #

Ruth,

I had somebody else mention this to me earlier, which confused me, since I thought I had written it in a way that it shouldn’t do that. I think I found the bug, though; it has to do with different capitalization in the link tag than in the options page. Give v1.04 a try and let me know whether it fixes the problem.

3
at 2:55 pm on September 14, 2007 #

Hello Adam,

It’s me again. Downloaded the update, and that initial problem is gone.

However, only 1 instance of my chosen keyword is being linked.

For example:

Word->http://word.com/ _Blank

That works great, but only one instance of “Word” gets linked, while the other keywords “Word” do NOT get linked.

Any thoughts?

Martin

4
at 3:05 pm on September 14, 2007 #

K - sorry… I’ve just installed your plugin on more of my sites, and that initial error DOES show (using the latest ver) - until I “Update” the keyword field within the admin section.

And still just one keyword gets linked. I have to say, I like this plugin.

5
Thus saith Adam
at 8:51 am on September 16, 2007 #

Martin:

Looks like there were two places that could cause that error, and I fixed only one before. They’re both fixed now.

As for linking only one–that is intentional. It could get a big annoying to have the same word linked over and over within a post. However, you can change this easily. If you look at the code, you’ll find four times where the function preg_replace() gets called. Don’t change the first two. For the third and fourth ones, you’ll notice that they each look something like this:

$content = preg_replace( ... , ... , $content, 1);

It’s that 1 at the end that limits it to one link. Just delete it, so you have this:

$content = preg_replace( ... , ... , $content);

and you’ll be done.

6
at 9:42 pm on September 16, 2007 #

Thanks Adam!

I’ll do this! Is the download on this site the latest one with the fix?

God Bless,

Martin

7
Thus saith Adam
at 7:41 am on September 17, 2007 #

The download link above goes to wordpress.org, which always has the most recent version. I think it’s at v1.06 now.

8
Ruth opines
at 12:08 am on September 23, 2007 #

Hey Adam,

Sorry, I was slow in checking back. I got busy with school; I guess you know how that is. I just installed 1.06, and it’s not breaking links that contain keywords any more. Thanks!! KB Linker is my second favorite plugin. (KB Countdown is my favorite. This is my last term of nursing school and it’s helping to keep me sane by counting the days until graduation for me.)

9
Ruth opines
at 6:18 pm on September 23, 2007 #

Oh, Nooooo! Sorry Adam, I was too sleepy when I checked last night. There’s still something going on when keywords appear within links. The one I gave you as an example looked okay at first glance, but on closer inspection today I discovered it wasn’t.

The keyword is “my family,” which is set up in KB Linker to point to a photo of my family: my family->http://www.flickr.com/photos/ladylong/854796999/. The link it appears in is a post title, “Valuable Information for my Family and Friends.” It’s still turning “my family” into a link to the photo, and the link to the article is truncated at “Valuable Information for.” “And friends” doesn’t link to anything. :( I think what fooled me was that there were no angle brackets showing this time.

There’s also an example on my husband’s blog at [link], where I also have 1.06 installed. These look more like what was happening on mine before, with the angle brackets becoming visible — look under “Poetry” for poem titles containing “Rusty” or “Rustin” (my son). The KB Linker settings for his name are:
Rusty->http://www.iamsane.com/
Rustin->http://www.iamsane.com/

Sorry to get your hopes up — if you need any more info, email me and let me know!

10
Thus saith Adam
at 8:48 am on September 24, 2007 #

Hmm. Interesting that this seems confined to sitemap pages. I’ll take a look at the Dagon Designs sitemap generator and see if something in there is interacting with my code to cause this.

11
Thus saith Adam
at 9:14 am on September 24, 2007 #

Ruth,

I’ll admit I’m a little stumped. I’ve made one small change that might fix the problem, IF the problem really is caused by a conflict with the sitemap generator. I hate to use you as my guinea pig, but since I’m unable to replicate the problem on my own system…

See if v1.101 fixes it.

12
Milorad thinks
at 2:01 am on September 25, 2007 #

I can tell you that the problem isn’t confined to sitemap pages… see my comment on the latest version - kb linker is the only plugin I have activated at the moment apart from akismet.

13
Thus saith Adam
at 8:41 am on September 25, 2007 #

Indeed… Ruth, I’m completely stumped. I just created a post containing the exact link you’ve got (the “Valuable Information…” link), and then I added a “my family->flickr” link exactly like what you’ve probably got, and I could not replicate the problem. The plugin didn’t modify the link on my setup. I’m really stumped. I wonder if maybe you’re using an older version of PHP with a different implementation of regexes or something.

Do you happen to know what version of PHP you’ve got (either Ruth of Milorad)?

More to the point, do you know what version of the PCRE library your PHP setup is using? (If you’re not sure how to check this, put the following code into a file, view the file in your browser, look for “PCRE Library Version”, then DELETE the file (for security reasons):

<?php phpinfo(); ?>

14
Milorad exclaims
at 2:56 pm on September 25, 2007 #

Sure Adam, I’m using PHP Version 4.4.7 with PCRE Library 7.0 18-Dec-2006.

While its not PHP5… its the newest of the version 4 branch I believe. Unfortunately I can’t upgrade to php5 because a number of other PHP-based sites on the same server don’t support it.

Fingers crossed.

15
Ruth writes
at 5:27 pm on September 25, 2007 #

PHP Version 5.2.3, PCRE Library 7.0 18-Dec-2006

You know, you’re right, the links don’t seem to break except in the sitemap view ([link]). Too bad I don’t know more about PHP… maybe after nursing school. :)

Anyway, I’m off to install your newest version and see what happens. The essay I’m supposed to be writing can wait a few more minutes. I’ll be back!

16
Thus saith Adam
at 1:22 pm on September 26, 2007 #

You both have a recent PCRE libraries, and one of you is in PHP 5, so that’s not it. Ruth, I’m glad my little change fixed it, but since Milorad still had the problem there’s something else going on apparently…

Unfortunately, the university starts back up this week, so this will be moving to my back burner for a while.

17
Milorad exclaims
at 4:31 am on September 27, 2007 #

No worries Adam, its clearly not a common problem since your comments here aren’t exactly overwhelmed with complaints.

Good luck with uni.

18
Danny thinks
at 2:33 pm on November 7, 2007 #

Is there a way I can exclude certain URL’s from adding automatic links?
I can see that it excludes the current URL.

What code can I add to exclude all url’s that begin with [link]
Or, to only include url’s that start with ???????

19
Thus saith Adam
at 4:24 pm on November 7, 2007 #

Sure, you could code it to do that, but I don’t do customizations myself. Take a look at the mechanism it uses for not linking the current page and do something similar.

probably the easiest way is to create an array of URLs (or substrings) that you don’t want to have the links applied to. Then check whether the current URL is in that array. If so, continue the loop.

20
OpeRon® writes
at 8:20 am on November 12, 2007 #

Hello Adam,

I love the idea of your plugin, I just started to use it a couple of days ago .. however, I found out that I cannot add a specific title to every URL I set for a keyword .. which is I do not like much, cos sometimes I am referring to blogs and I would like the title that appears in the screentip to be “xxx’s blog” for instance

I successfully changed this line to:
// set the title attribute:
if (KBLINKER_USE_TITLES)
$title = ‘ title=”‘.$kblinker_title_text[’before’].$mytitle.$kblinker_title_text[’after’].’”‘;

but the problem is I cannot insert the $mytitle tag into the $pair so that I can customize that from the options page.

I am not that good with PHP after all ..
would appreciate your help

21
Thus saith Adam
at 8:20 pm on November 21, 2007 #

Sorry I missed this earlier, OpeRon.

Your coded didn’t paste clearly. Would you mind pasting it into a pastebin?

Leave a comment

Comment Guidelines
  • Yes, your comments will be visible to everybody. (Unless you use the private contact form.)
  • Allowed HTML: <a> <b> <blockquote> <cite> <code> <em> <i> <strong>
  • Code: Put code in `backticks` (above your "Tab" key) or it won't display well
  • Gravatars: To override the default image by your comment, use a gravatar
  • Links: If you include more than one link, your comment will go into the spam queue

Please read before commenting: Because my real job has me swamped at the moment, I am not supporting my plugins at this time. Sorry. This may last several weeks.

If you have a bug report, feature request, or other general feedback about a plugin, please leave a comment—but do not expect an immediate response. If you are requesting help, though, please check the plugin's documentation thoroughly rather than ask your question as a comment.

Thank you for your understanding.