The Boring Backstory
On Tuesday, I read about Justin Blanton’s Slugger+ WordPress plugin, which allows you to set your post slug by entering your desired slug enclosed in
[slug] tags, e.g.
[slug]this-is-my-slug[/slug]. I wondered if I could adapt my Daring Fireball Linked List plugin to do the same, i.e. if someone entered,
[dfll]http://yjsoon.com[/dfll] somewhere in their post, the plugin could find the URL and set the custom field link to it.
So I tried implementing this, and I was stalled when I ran into a problem. Apart from posting it on the WP forums, I emailed Justin to see if he had any ideas. Coincidentally, he had been working on the same feature, and he’d also run into the same problem! I went off for work, and a few hours later, Justin emailed to say he’d solved the problem, and he released his CF Setter plugin the next day.
After CF Setter was released, I decided not to replicate its functionality in my plugin. (If you’d like to use that feature, go take a look — you just need some minor adjustments to get it to work with my plugin.) Instead, I thought I’d try and adapt Justin’s code to solve another problem: posting using WordPress’s built-in “Press This” bookmarklet. Shawn Blanc had put up a customised version of the bookmarklet’s code a while ago, but I was never comfortable with editing core files, what with automatic upgrades and all.
New Coolness: Link from Post Content
So, long story long, a few hours and a lot of painful regular expression writing later, the new DFLL plugin supports “Press This” by extracting the link from the first anchor tag in the post content.
Here’s how you use it: First, turn on the setting in the options page. Next, on any page you’d like to link to, just click the “Press This” bookmarklet, and the following will pop up:
Click on the end of the first line, press enter (be careful not to delete the period!), and type whatever comments you’d like. The plugin will automatically grab the URL in the first line, set it to the linked_list_url custom field, and delete the entire first line for you, preserving whatever you’ve entered into the rest of the post content. Ta-da! Linked list item!
If you’d like to use this with the MarsEdit bookmarklet, you can customise the Attribution preference as follows:
More details are on the DFLL plugin page, which I’ve linked to thrice already in this post. Many thanks to Justin Blanton for his plugins which both inspired and laid the foundations for this feature.