O'Reilly logo

WordPress 3 Plugin Development Essentials by Everett Griffiths, Brian Bondari

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Conflicting names

PHP as a language is particularly vulnerable to naming collisions, and this is especially prevalent in WordPress plugins where many authors are not particularly aware or sensitive about this problem. If your site is running a lot of plugins, you are increasing the odds that a naming conflict might occur. While debugging a plugin, one of the first things that you should do is disable all of your other plugins so you can isolate problems.

We have seen a lot of useless attempts to prevent naming collisions when plugin authors wrap their function definitions in a big if-block:

if ( !function_exists('myfunction') )
{
function myfunction()
{
// Do stuff
}
}

Do not think that your plugin is safe if you use if-blocks like this! This ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required