Improve callback verification while executing hooks
|Reported by:||ericlewis||Owned by:|
When executing hooks, we currently have a simple callback verification:
if ( !is_null($the_['function']) ) call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
This works in most cases, if everything is coded properly in the theme / plugins. However, there are cases when a bad callback makes it through this validation, such as dropping this in a theme or plugin:
add_action('init', array( NULL, 'method') );
Will cause an error you may be familiar with:
Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'Array' was given in /path/to/wp/wp-includes/plugin.php on line 405.
Which can be a tricky issue to debug.
I suggest using the is_callable() php function for verification instead, which should remove this warning from ever showing up.