HEWEB11 – Plug It In: Writing Better WordPress Plugins (TPR10)
Tuesday, October 25th, 2011
Plug It In: Writing Better WordPress Plugins (TPR10)
Hill Country A & B
Writing a WordPress plugin can be extremely simple, but in order to write a good WordPress plugin, it takes a little more work. I will walk you through five simple tips to help improve your WordPress development skills and techniques.Some of the…
Curtiss Grymala (University of Mary Washington)
New site 100% WP – multi network! Multi multi site.
Use PHP classes for everything – then it can be reused.
Few or no options.
Do not create new db tables. They have 4500 plugins in their checker.
Only use what you need, when you need it.
Study the masters.
Avoid using activation/deactivation hooks.
wpdb
Set_blog_id – for multisite. Let’s you grab table for another blog without dumping the entire cache. It returns the ID of the blog you switched from – lets you quickly switch back.
Avoid hard coding anything.
$wpdb->prepare
Protects against SQL injections. Does all the escaping for you.
$show_errors to help find query issues.
$queries – turn on in config file. You can then see all queries to debug/reuse.
Use $prefix or it will break on many installations.
On multi-network you need one additional table to store global information for all sites.