What it does is similar to how the itemstats works.
you post an item with the item tag, [item]foo[/item]
The first thing it does is it looks up the name foo , in the database (the database stores the item name, the item quality and the item ID). It reads the item ID and quality and writes the URL.
If it cannot find the item name there, it checks wowhead to see if the site exists. The URL to a wowhead item is pretty simple,
http://www.wowhead.com/?item=[ItemName]&xml , for example
http://www.wowhead.com/?item=Nightseye&xml
I just read the item ID from the xml and write the URL to match whats required by the wowhead javascript
http://www.wowhead.com/?powered