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 are an English rock band formed in London in 1965. Gaining an early following as one of the first British psychedelic groups, they were distinguished by their extended compositions, sonic e... are known to have loved sausagesWikipedia: A sausage is a type of 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 ... – especially when they visited Disney WorldWikipedia: The Walt Disney World Resort (also known as Walt Disney World or Disney World) is an entertainment resort complex located about 20 miles (32 km) southwest of Orlando, Florida, United States. Opened o... in FloridaWikipedia: Florida (/ˈflɒrɪdə/ ⓘ, FLORR-ih-də; .mw-parser-output .IPA-label-small{font-size:85%}.mw-parser-output .references .IPA-label-small,.mw-parser-output .infobox .IPA-label-small,.mw-parser-output.... Furthermore, the catWikipedia: The cat (Felis catus), also referred to as the domestic cat or house cat, is a small domesticated carnivorous mammal. It is the only domesticated species of the family Felidae. Advances in archaeology... sat on the matWikipedia: A mat is a hard floor covering 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