My first lesson in PHP/Wordpress plugin development

Recently I had released a WordPress plugin - Google Blog Search Preview. I had tested it over two webhosting providers and everything seemed perfect. But within a week of release, I was getting reports of this plugin failing on certain installations. Well, it turns out that I had coded my plugins in PHP5.

The error was,

Parse error: syntax error, unexpected T_STATIC, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or ‘}’ in /home/brodopr/public_html/brodo/wp-content/plugins/jj_gblogsearch.php on line 15

Unfortunately many sites still run WordPress on PHP4. The biggest problem is that object oriented features in PHP is very different between version 4 and 5. For example, the static keyword is not available in PHP 4 which I was using in my plugins!

So the first lesson in WordPress plugin development - Test your plugins in both PHP 4 and PHP 5 installations! WAMP server even has a plugin which allows you to switch between PHP4 and PHP5. So that was easy!

I have released version 1.1 of Google Blog Search Preview  which works on PHP4 and PHP5. You can download it here. Many thanks to Carlo and Len for reporting this problem.

Leave a Reply