Plug It In: Writing Better WordPress Plugins #heweb11
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:
- Do not create new database tables.
- Avoid offering too many options.
- Use native WordPress functions.
- Use PHP classes for everything (go OOP).
- Only use what you need, when you need it.
- If your plugin needs it, include it.
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.
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.