• Hi all,

    I’m developing a plugin that will overwrite some of the pluggable functions (in particular, wp_validate_auth_cookie).

    I noticed that to enable the plugin, I had to wrap the function definition in a if ( !function_exists(‘wp_validate_auth_cookie’) ) block, otherwise I would get a fatal error caused by the plugin (trying to redefine the function).

    Firstly, this doesn’t make much sense, as the definition in pluggable is only used if a plugin hasn’t defined the function. How can, upon activation, the plugin complain about the function already being defined (presumably the pluggable version is being included first here), but if I put it the guard around my plugin function then activate my plugin, *my* version of the function is called (presumably because it is included first)?

    Secondly, what happens if more than one plugin tries to override the function? As the function definitions are in guarded blocks, you wouldn’t necessarily be told that there is a conflict between plugins.. you would only find this out when you start realising your plugin functions aren’t being called!

    Taras

  • The topic ‘overriding functtions’ is closed to new replies.