Smart link plugin for WordPress, beta

In resources — The smart links plugin for WordPress lets you insert links in your posts using natural language rather than urls. The resulting increase in usability is positively spectacular. Such, in fact, that you might never want to insert an html anchor again.

This plugin is likely to addict all but the most nerdy software grunt.

Comments on Smart link plugin for WordPress, beta

  1. Lots of interesting plugins here! And I just got my site online, thinking that I had it all configured and ready for take-off. Very well, I guess I’m in for a new round of plugin-testing…

  2. hi, i was wondering is ther’s eny way of maiking links open in a new page when they are external…

    tnkz :)

  3. @task: Sorry, no way available. several reasons:

    1. It’s a usability mistake to make external link target links in a new window. users who want a new window will open one.

    2. IE7 will disable opening new windows entirely, meaning this won’t work for 90% of your users

    3. if your user has a tabbed browser, he’ll likely prefer to open a tab — and will hate you for multiplying windows on his screen

  4. I was looking for a simple solution to add links in my posts, your plugin fits in nicely to my needs. Awesome stuff.

    I noticed that some autolinks to the post slugs don’t appear when they are viewed from the index page. They do appear to work properly when that single post is viewed. I had one test post at my site which if you want I can publish again to demonstrate the problem.

    Sorry about my English, I’m not very good at it.

  5. The plugin is a cool idea! Some comments:

    * External links would be more useful if they retained the description as given when the link was added to the database.

    * The “search engine” isbn.nu could be added to the list — it’s nice for referencing books in a somewhat neutral way (that is, without sending everybody directly to Amazon).

  6. There’s some problem with links made in comments, please [see my post about it][1]. Could this have something to do with the use of `$wp_version != ‘1.5’` instead of something more robust like `version_compare($wp_version, ‘1.5’) == -1` — given that the meaning of that test is to find version such as 1.2. I’m running the latest SVN (version 1.5.1.1 at the moment).

    [1]: http://mgeisler.net/2005/05/21/now-using-smart-links/

  7. @Denis de Bernardy:

    tnkz for your reply..

    maybe an option, like add “->external” or “->ext”

    or at list be able of adding class=”external” or something so we can customize the output, to external links…

  8. the problem with trying to insert classes is that they cannot be inserted in Markdown. so i opted to leave it without classes. then again, if you really want a class on external links, i recall a plugin already exists to add them.

  9. @task: just change the filter priority:

    add_filter(‘the_content’, ‘wp_external_links’, 2);
    add_filter(‘the_excerpt’, ‘wp_external_links’, 2);

    To:

    add_filter(‘the_content’, ‘wp_external_links’, 1000);
    add_filter(‘the_excerpt’, ‘wp_external_links’, 1000);

  10. Maybe this is a silly question (I’m code illiterate, I’m afraid), but is there a way to add functionality to this to link to an amazon search?
    The reason I ask is, it would be nice to mention a book or movie, and link it as such `[The Great Gatsby->@amazon]`

    Is this something that can be added to future versions, or something I can adjust myself?
    Again, this plugin is simply the best I’ve come across, and it is changing the way I post.
    Thanks again!
    Monkeypup

  11. @monkeypup: Amazon is a bit more complex that the other search engines, so I left it out of the current version. This is mainly because:

    – You’d likely want to add your amazon affiliate ID in the link
    – The url structure is quite obfuscated and user specific (the link that I removed from your comment, for instance, did not work)

    Moreover, what you’ll really want to use is something like `[The Great Gatsby->@@amazon]`, which is the syntax I plan to use to automatically insert a link to the top result of the search query using search engine APIs, for an “I feel lucky” like feature.

  12. @Denis de Bernardy:

    cool, making that fix the problem…

    but when using `[etc->@]` (searching in the same blog) the plugin thinks is a external one… :(

  13. fascinating plugin. it sounded useful to start with, but as i read the documentation i became more and more impressed. i like that it simplifies adding search engine queries – and the “mutating links” thing is brilliant. it almost adds wiki-like functionality…

    bravo.

  14. There’s a minor upgrade to beta 4 for those of you who are interested. The plugin now shows the smart links in the admin preview panel. I also added the amazon shortcut to insert links. I’ll be upgrading the plugin to insert an affiliate ID as soon as I find out how to insert it.

    @Task: It should also correct the external link problem.

  15. I think I’ve found the real reason why I couldn’t get the smart links to work in [my comments][1]: they `$comments` variable isn’t defined as global by `comments.php`. The variable is a local variable in the `comments_template()` and when this function includes `comments.php` it is still just a local variable.

    So when your plugin does

    if ( !$comments_to_cache )
    {
    global $comments;
    $comments_to_cache = $comments;
    }

    then it doesn’t work.

    [1]: http://mgeisler.net/2005/05/21/now-using-smart-links/#comment-230

  16. @Denis: yes they use the `$comments` array, but this isn’t global, it’s a local variable in the function that includes the `comments.php`file. So there are no way for the `sem_smart_link_cache_comments()` function to access it.

  17. Oh, one other thing. If this doesn’t win the Wordpress Plugin competition (you have entered it, right?), something is wrong with the world.

  18. @Monkeypup: I’ve a login on the plugin blog, but I’ve yet to register as a competing plugin author. But I imagine I’ll give it a shot. :)

    @Martin: Could you check if declaring the following at the beginning of the comment loop solves the problem?

    global $comments;

  19. salut bernard,
    ne parlons pas du non d’hier. ici berlin, comme partout, les francais expatriés ont voté massivement oui…
    aurais-tu une doc en francais sur ce plugin, mon anglais laisse un peu désirer.
    a+
    philippe

  20. @Denis: Sorry about the wait — I’ve now tested your plugin with the standard Kubrick theme (without the nested-comments plugin) and your change isn’t quite enough to make it work.

    Instead one has to do

    $GLOBALS[‘comments’] = $comments;

    for there are actually no global `$comments` variable at all. The above creates it and gives it the right value. Maybe one should use `=&` instead, but I find that construct very annoying so I left it out.

  21. @Denis: Yes, well, it seems very open-ended: you just attach some code to a hook, and then do what you want. But at the same time it’s limited because you have to rely on the right things to be in score when your hook is executed. So without careful planning, you end up having a needed variable be inaccessible from a plugin.

  22. Denis-
    Hate to bother you, since you were nice enough to add an Amazon function to the plugin, but I noticed that the Amazon link takes you to a book search, rather than an overall Amazon search. Is it possible to change this? Just curious. I find I get more use out of this plugin everyday. Still the best plugin around.
    Thanks!
    MP