Simple Footnoter
Time for another quick-and-dirty WordPress plugin.
Since Emiry likes my footnotes, I wrote a plugin that makes making them a bit easier.
Basically, the idea is that you write [1] (where 1 can be any number), and this plugin will replace it with 1. Then, at the bottom of the post (typically, but not necessarily), you write [f1], and it will replace it with 1. If the latter is at the start of a paragraph, it will also make said paragraph of class “footnote”, which you can then define in your CSS file or what have you to have a different style, if you so desire.
You’ll note that the ID of the anchor tag starts with a random number. This is to prevent (or at least make very unlikely) collisions in IDs if more than one post is being displayed at a time, since that breaks things. Ideally, it would use the post slug for that, but if there’s a way to retrieve a post slug from within a filter, I couldn’t find it in the WordPress API in under two minutes.
It’s not awesomely efficient (it uses regular expressions), or awesomely awesome, but it works well enough.
The code is here; as always, save that as a .php file, upload to your plugins folder, and activate. If you have suggestions for improvement, let me know.
What this plugin does it take your post and, before it’s displayed, replaces [[foo]] and [[bar|baz]] with links to Wikipedia. In the first case,
I give you the Cthulheriser!