WordPress Plugin Development Tips

The DandyID Services Plugin displays the social identity favicons of the blog author — from the DandyID service — and displays them in the blog sidebar. They can be displayed as favicons only or as a favicons list. The plugin calls a REST interface that is exposed by the DandyID return_services() API which returns the data as XML. The DandyID web API is listed on Programmable Web, a useful web API directory.

The plugin, written in PHP, has several well-documented examples of helpful WordPress plugin features.

See how the readme.txt maps to the hosted plugin pages and the 5 hosted screenshots.

The main code module dandyid-services.php has examples of:

  • Creating a sidebar widget.
  • Processing returned XML that is PHP4 and PHP5 compatible.
  • Storing and retrieving wp-database options in an array.
  • Embedding the plugin name and version-number into a <div> tag that appears on all blog pages that render the plugin. (useful for debugging — many versions of the plugin can be out there in the wild)
  • Localization for international language support.
  • Creating an options page for admin plugin configuration, including HTML that renders radio buttons and checkboxes.
  • Caching the DandyID API results — on a busy blog, the plugin only calls the DandyID API once every 2 hours.
  • A plugin activation hook that creates initialized, defaulted wp-database options.
  • A plugin deactivation hook that cleanly removes the plugin wp-database options.

The WordPress maintained repository contains all of the DandyID Services Plugin files for the current release. WordPress automatically packages the plugin files as a zipfile for downloading.

One Comment

Leave a Reply