Categories
2011 Conference

Plug It In: Writing Better WordPress Plugins #heweb11

View Session Description and Presenter Bio

Photo by MetalRiot, Flickr.

Thought I can’t talk for everyone, many developers would agree that WordPress is for real. It flexes, scales, and, generally knocks the socks off other CMS or blogging systems. But there are times you need to extend WordPress with a plugin, and Curtiss Grymala, from the University of Mary Washington, knows the business of ramping up your WordPress plugin efforts.

Recently Curtiss launched a new site at his university on what’s called a multi-network installation of WordPress, which is a step up in scale from a multi-site installation. Because of this, plugins enabled across all sites and networks needed to run very efficiently to save resources.

When you first write a plugin, there are a number of things you can do to help the process:

  1. Do not create new database tables.
  2. Avoid offering too many options.
  3. Use native WordPress functions.
  4. Use PHP classes for everything (go OOP).
  5. Only use what you need, when you need it.
  6. If your plugin needs it, include it.
All these tips really point to one thing: If you are building a large system of sites on WordPress, it is important to make you plugins clean and efficient. You want to make sure your plugins aren’t resource hogs.

Now, I am not going talk about all the items in the list above, but they are all points you can take to heart when building a WordPress plugin. There is, however, one native WordPress functions Curtiss felt was worth noting.

wpdb

One of the most valuable functions available for WordPress developers is the wpdb class. This helps developers forego the sometimes laborious PHP methods on querying a database in lieu of a more friendly process for digging information out of your WordPress database tables. SQL security is also built in to this class (see $wpdb->prepare()), keeping you safe from SQL injection.

This class, especially when used for large site development, will be a keystone to helping you solve a number of problems in site creation. Learn more about WordPress’ wpdb class.

Share this: