WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Lets say I have a function set up like such:

add_action( 'init', 'jigoshop_add_to_cart_action' );

function jigoshop_add_to_cart_action($url = false){

To make it pluggable by others plugins, I just need to change this to

add_action( 'init', 'jigoshop_add_to_cart_action' );
if (!function_exists('jigoshop_add_to_cart_action')) { //ADD THIS
function jigoshop_add_to_cart_action($url = false){


share|improve this question
up vote 0 down vote accepted

No, because you're hooking it to an init action, then somebody can replace the function simply by unhooking it themselves. You don't really need to wrap it or make it pluggable.

share|improve this answer
otto, i don't follow why this isn't considered pluggable? is it considered pluggable only if it cannot be unhooked? – helgatheviking Aug 26 '12 at 0:24
It is pluggable, but it's unnecessarily so. In other words, there's no need to have this extra code at all, because if somebody wants to replace it, then all they really have to do is to unhook it and hook in their own function. Simpler, easier to manage. Pluggable functions are pretty bad mojo and should generally be avoided. – Otto Aug 26 '12 at 14:16
Ok, thanks. I agree mostly, but I think they're a nice feature for people who don't understand hooks and filters... excerpt they probably train people to think you can override ANY function, when you can't. queue WSOD. – helgatheviking Aug 26 '12 at 14:40
Actions and filters are easy to learn and better to use. I'd stick to them, and help improve the general programming skill level. :) – Otto Aug 26 '12 at 14:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.