Avoiding WordPress Plugin Conflicts

It has been an enjoyable experience delving into the inner workings of WordPress of late. And it has been during the development of one of our recent projects, the ‘WP Content Filter’, our first WordPress Plugin by the way :) , that we have come across some unanticipated subtleties.

For instance, any WordPress Plugin is free to access hooks that are exposed by the core WordPress code. Well, this is the whole point isn’t it? To be able to customise the functionality of your blog site over the default WordPress installation.

However, what happens when two Plugins access the same filter hook to, say, do some custom formatting of post comments. If there is an overlap in two (or more) Plugins functionality then it is likely they will all want to access a common WordPress Plugin hook. In this case which one is run first? Is there anyway to force you Plugins code to run before (or after) any others? Would that even be ethical. Or, is it completely ambiguous and decided by the Plugin attributes (such as the order that Plugins were installed on your WordPress blog).

As far as I am aware there are no hooks exposed by WordPress to control this. Perhaps more unpredictable is the behaviour resulting from action Plugin hooks. Plugin code running on a WordPress ‘event’ for more than one Plugin could have very strange results, and the likely culprit for conflicts between Plugins.

Perhaps in the future of WordPress there could be some way to allow the user of Plugins (i.e. site administrators) to be able to set which Plugins have priority over other Plugins. This could be handled in two ways:

  • At at a more basic level, simply specifying which Plugins had precedence (assuming Plugins access common hooks) over other.
  • Or, at a more advanced level, allowing the administrator to control precedence on a hook by hook basis – specifying which Plugins accessing these hooks have priority.

This would give administrators more flexibility by giving them an option to change Plugin execution order, rather than just having one course of action – namely, to uninstall one or more Plugins to prevent conflicts occuring.

I stated above that this would have to be controlled by the site administrator and not the Plugin developer, as every developer would want to add their Plugin to be of highest priority! Wouldn’t they? Such functionality would probably have to be added to the WordPress core as it may not be a good idea (for the above reasons) to expose Plugin execution priority as a new hook.

Anyway, enough rambling. Any thoughts…?

This entry was posted in WordPress Plugins and tagged , , , , , , , , , . Bookmark the permalink.

4 Responses to Avoiding WordPress Plugin Conflicts

  1. Pingback: Avoiding WordPress Plugin Conflicts | gwycon.com

  2. Pingback: Avoiding WordPress Plugin Conflicts | gwycon.com | thepluginsecrets

  3. Grae Cullen says:

    I think I having a problem like what you describe. Two plugs apply_filters to ‘the_content’. Sadly, data the one plugin gets source html from the other plug in, and inserts it in the code. Is this cause by what you are describing.


  4. Jussi says:

    Plugins do have an order. They each assign themselves an integer that is used to order actions. E.g. plugin calls a function
    (or something to that extent) at the end of the plugin code.

    Sadly the integer is often hard-coded but you can always ask the plugin dev to make a change.

Leave a Reply

Your email address will not be published.