As a PHP-Dev you hate and love it: Wordpress. While the core devs are trying to keep up with older PHP 4 installations you tend to say: drop it. But if you take it more pragmatically, you can drop PHP 4 support yourself and code PHP 5 only for your Themes and Extensions. Some more Tips to have your code more stable and mature which came to my mind this morning:
- Use Classes for Plugins, Actions and Callbacks. WP (PHP!) supports that, it’s done with an array instead of a string for php function callbacks.
- Widgitize your Plug. Wordpress has a nice Interface for widgets that will help theme authors to keep up with your certain plugin.
- Write Code that is easy to read. Comment it. Zend and Pear have some suggestions good to know about.
- Keep it small & simple. I’m pretty shure you have got a great Idea and your Plugin will evolve THATBIGBUDYBUDY. But until then: Release often. Find other Devs to improve your Plugin. Get a more broad install-base first, let’s say 10 Blogs. You can find other Devs in a PHP User Group near you or the Wordpress Testing Mailinglist.
- Do not re-invent the CSS-Wheel for your Plugin Admin interface. I’ve seen a lot of plugin-admin-pages that are putting additional CSS into the header etc. . This always creates problems and often you didn’t even needed to do so. Checkout basic admin pages with firebug and think about reusing that XHTML+CSS.
- Do not re-invent the CSS-Wheel for your Plugin Output. Just document what kind of CSS a User has to add to it’s Theme-CSS File and that’s it. If you’re really pro, document the XHTML structure with IDs and CLASSes as well. You save your Users Blog a callback and a lot of work. And you keep up with a maximum compability! At least your output should work without any CSS as well.
- Use Version Control. Join other Developers.
- Translate your Plugin. Or at least, tend to do so, you do not even need to translate it infact, this will do others for you over time. But you should enable your plugin to be translateable. The documentation on Codex is not the best one (additional Plugin Translation Info), but you can checkout already translated Plugins. This will help you making it more popular and getting more developers on it.
- Make it stable and secure. Even if you can argue that wordpress isn’t the most secure software on the planet, there is no need for you to even lower the bar. I’ve seen so many plugins that directly used $_POST values in the output, trusted values coming back from get_options() (Why should you trust that function?), Escaping something anywhere and not even knowing why and other very, very mysterious, esoteric and therefore dangerous code. Define and document which kind of data a function expects, tag raw and escaped data. Just keep in- and output stable and secure. Think about how to make it even more secure by first understanding what is technically happening. Many mistakes are made because people do not think first twice what to do. They tend to react on how “the stuff looks like” afterwards instead. If something unexpected happens, first understand why.
- Check against 2.5 Version. It will come. Checkout what might be ready for a change, especially the Backend.