You’ve created a plugin that worked happily since version 2.5 of WordPress. Then came version 2.9 and the users of your plugin complain that the theme editor does not work anymore! What the theme editor? What have I to do with the theme editor?
That were my thoughts when I received bug reports for the pagebar plugin. I had absolutely no idea why and first checked the usual suspects; with no success. So I tried a different approach and disabled all initialisation code. The theme editor worked. I enabled the first disabled line and Eureka! The theme editor failed. This has to be the
$dir = trailingslashit(WP_CONTENT [...]
$dir variable is global and that seemed to be the problem. A short look at
theme-editor.php shows that’s there a global variable called
$dir. So I changed the variable name in my plugin to a more unique name and voilà, everything works as expected.
There are some lessons I learned from this incident:
- Use a unique name for your global variables.
- Better: Never use global variables at all.
- Even better: encapsulate everythin inside a class.
I hope his short story helped you to debug your plugin and leave some happy users behind.