Getting SH-Autolink to do what I want
I have always been torn about adding HTML to my blog posts. Clearly, there are times when you need it to point off to an image or to format text for emphasis. I know other markup exists, like Markdown, Textile or even Wikitext, but those carry the same undesirable characteristic – content ends up being marked up. It is probably not that big of a deal, it all stems from the question of if I will ever want to extract the content and place it in a context where <insert your favorite markup> is not interpreted. My goal is to automatically tag keywords with the right URLs, reducing the amount of HTML markup in my posts and better, more centralized, link management.
Being a WordPress and PHP newbie, I thought I might write a plug-in to help accomplish this goal. I went through the “How to write a simple WordPress plugin” tutorial and realized it would be pretty simple to use that approach the problem.
I had a feeling that I was not alone in wanting such a plug-in so after I did a little coding, I did a search and found SH-Autolink. I was both bummed and excited – I really wanted to use writing the plug-in to get more familiar with PHP and after reading some comments about the plug-in, I was not going to have to write it from scratch! Stevie’s plug-in had the same issue I first ran into, if the text of the post included the keyword as part of existing anchor tags, then the string replace would break the markup.
So, I merged my code with Stevie’s to get the best of both worlds – my better string replacement and his data management / administration interface. (As a side note, I do think it is curious that he decided to specify the protocol of a link, but maybe I am not thinking the whole problem through.)