This week I decided to start writing my first WordPress plugin. It’s a pretty simple functionality, but it’s been a lot of fun so far.
When a reader of your site highlights text on an article, a small tooltip pops up asking if they want to post to Twitter. If the reader clicks it, a Twitter tweet intent window pops open pre-populated with the highlighted text in quotes, link to the article, and your username. Here’s a demo of how it works.
The plugin configuration includes the Twitter username you want added to the tweet , any default hashtags to add, and bit.ly integration for shortening the permalink. Next I’m going to look into using the wp.me short link if Jetpack is installed and active on the site.
There’s a few small bugs to work out but it’s coming together nicely. Stay tuned for a release notice. If you want to help test it out, let me know. I might also want a more experienced developer to take a look at the code to make sure it all looks good.
Edit: I put it up on Github if anyone wants to take it for a spin before releasing it (and let me know if you find any bugs).
5 thoughts on “Writing a plugin”
Jetpack hooks into the wp_get_shortlink() function – you just need to call that, and you’ll get the wp.me shortlink (if Jetpack is installed), or the “?p=1234” style shortlink if it isn’t.
Awesome, that makes it easy. Thanks for the tip. You saved me from some googling 🙂