Mycroft Search Plugin Generator

I was at work, and an idea hit me: Firefox search plugins are just text files. They also contain a lot of stuff that WordPress stores in it’s database. Why not make WordPress generate a search plugin for itself? Why not make a plugin that will work on any WordPress 1.5+ install? So I spent the rest of the day making the Mycroft Search Plugin Generator plugin

Current Version: 0.92

How it works:
When you change the settings, the plugin generates a .src file. This file is a Mycroft plugin file. the_mycroft_plugin() outputs some javascript and a link which trigger Firefox into installing the plugin.

Installation/Documentation:
Either:

Then:

  • Go to Options > Mycroft Search Plugin and change the options. At the very least, be sure to click “Update options »”, as this is the only event that the .src file will ever get created.

How to implement:
First, go to Options > Mycroft Search Plugin and configure the plugin

  • Use Custom Name for Plugin
    If you turn this option on, Custom Plugin Name will be used for the name of the plugin. Otherwise, your standard weblog title will be used.
  • Plugin File Name
    This will become the first part of the .src file. This should not contain any characters that standard file names cannot contain. If you enter any, it will be changed the same way that post and page slugs are generated. When you install, a recommended plugin file name will be generated from your weblog title.
  • Plugin Icon
    This is the icon that will appear next to your search plugin. This should be the full URL to a 16×16 GIF or PNG file.
    The image file name must be identical to the Plugin File Name, and end in either .gif or .png. For example: http://inner.geek.nz/innergeek.gif
  • Plugin Category
    To be honest, I don’t know how this is ever used in Firefox, but Firefox asks for it. Feel free to change it to a category of website that your weblog fits. Blogs is probably sufficient.
  • Plugin Description
    Same as above. Defaults to “Searches the blog posts on [weblog title]“
  • Include Javascript in <head> or when the_mycroft_plugin() is called
    If you’re using the_mycroft_plugin() in your header or footer template, you probably want this to be set to “in <head>“. This assumes you have < ?php wp_head(); ?> in your header.
    If it’s set to when the_mycroft_plugin() is called, the Javascript will be included inline just before the link is output.

Then Simply add this php code to any WordPress template:
<?php the_mycroft_plugin (); ?>
to get Add [weblog title] to your Firefox Search Box!, where
or customise the link text like this:
<?php the_mycroft_plugin ("Firefox Search Plugin"); ?>
to get Firefox Search Plugin.

Version History:
0.92: * Alert to non-firefox users telling them they need Firefox to use Mycroft plugins.
* Fixed problem with Use Custom name.
* Shortened menu item from “Mycroft Search Plugin” to “Mycroft”.
* Moved image preview to simulated menu preview with rollover effect.
* Linked to plugin page in plugin header.
* Increased the size of some text boxes.
* Fixed some wording issues.
0.91: Fixed issue with .src not getting created when it didn’t exist.
0.9: Initial Public Release.

Known Issues:

  • The plugin does not create the .src file until you press “Update options »”.
  • Image field is not checked to see if the image’s filename or dimensions are valid.
  • Doesn’t come with a default image set, but tries to guess what the image will be named.

Credit:

  • Brett Taylor (Me! aka Glutnix) for coming up with the idea and implementing it within a day.

Bugs and Suggestions
Any bugs or suggestions, please email me – email link in the sidebar.

RSSSubscribe to my feed now.

About Me

inner.geekAKA Glutnix. I'm a web-geek residing in Wellington, New Zealand. I'm passionate about Internet Culture, Copyright and the Creative Commons, Web Standards and Accessibility and Jesus Christ. Yeah so there.