[wp-hackers] Checking if hock exists

Rob powzor at gmail.com
Mon Jan 30 00:33:34 GMT 2006


CK wrote:
> Hi all,
>
> I was wondering if there is an easy way to check if an action exists 
> before calling it. I'll give an example because I am sure not many of 
> you have understand my query.
>
> Since wp2.0.1 we can use the add_action('dbx_post_advance', 
> 'my_function'); instead of add_action('edit_form_advance', 
> 'my_function'); What I wan't is to check if dbx_post_advance exists 
> before calling it or call edit_form_advance so my plugin will be 
> compatible with both wp2.0 and wp.2.0.1.
>
> Any Ideas, I've tried function_exists but it doesn't work since it's a 
> hock no a function.
>
> Constantinos
>
> -- 
> GPG: 0x2502604D
> http://kouloumbris.com
>
> "A bus station is where a bus stops. A train station is where a train 
> stops. On my desk, I have a workstation…go figure."
> ~ Steven Wright ~
>
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
Can't you just add your function to both hooks? If the hook doesn't 
exist then it'll be added, just never executed. The Wordpress core has 
no way of knowing every single hook in every single file, so it just 
adds them "blindly".

-- 
Rob Miller
http://robm.me.uk/ | http://kantian.co.uk/



More information about the wp-hackers mailing list