Wordpress Logo

WordPress plugin: Wikipedia extract tooltip

Posted by

I’ve never written a WordPress plugin before and was surprised how simple it was. I have knocked up a plugin based on Altreus’s Protip to allow an abstract from Wikipedia to be pulled into a WordPress post using a simple shortcode. Version 1.0 is pretty rough and ready and doesn’t support any amount of customization. Regardless, it seems to work on the basic test cases I threw at it and any bug fixes/examples of where it doesn’t work would be appreciated so I may tweak it.

It’s not overly reliable because it has to parse Wikipedia’s markup since the API is fairly useless but no doubt it’ll improve as non-working cases are found.

Examples below:

Pink FloydWikipedia: Pink Floyd were an English rock band formed in London in 1965. Gaining a following as a psychedelic pop group, they were distinguished for their extended compositions, sonic experimentation, philosoph... are known to have loved sausagesWikipedia: Sausages are a meat product usually made from ground meat, often pork, beef, or poultry, along with salt, spices and other flavourings. Other ingredients such as grains or breadcrumbs may be included ... – especially when they visited Disney WorldWikipedia: The Walt Disney World Resort, also called Walt Disney World and Disney World, is an entertainment complex in Bay Lake and Lake Buena Vista, Florida, in the United States, near the cities of Orlando an... in FloridaWikipedia: Florida (/ˈflɒrɪdə/ (listen),[14]Spanish pronunciation: [floˈɾiða]) is a state located in the southeastern region of the United States. With a population of over 21 million, Florida is the t.... Furthermore, the catWikipedia: The cat (Felis catus) is a domestic species of small carnivorous mammal.[1][2] It is the only domesticated species in the family Felidae and is often referred to as the domestic cat to distinguish it ... sat on the matWikipedia: A mat is a piece of fabric material that generally is placed on a floor or other flat surface. Mats serve a range of purposes including: .

Source code can be downloaded here. Just unzip the archive into your wp-content/plugins folder and activate in the plugin manager. Then use the [wiki] shortcode to get the tooltip – e.g. [wiki]Pink Floyd[/wiki].

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *