Reputation: 1293
Updated to WordPress 4.7, and am receiving this error when I have one of my custom-made plugins enabled:
( ! ) Warning: call_user_func_array() expects parameter 1 to be a valid callback, no array or string given in /home/vagrant/Sites/wordpress/wp includes/class-wp-hook.php on line 298
I also get this with my debugging enabled:
I am uncertain as to what the issue is, as the stack trace seems rather cryptic. Any advice on what may have broken the plugin, or how to diagnose the problem?
Upvotes: 3
Views: 5255
Reputation: 11378
As @Afzal mentioned this line is problematic:
add_action('plugins_loaded', $this->plugin_update());
We can replicate the error you got with this simple example:
class Test
{
public function init()
{
add_action( 'plugins_loaded', $this->plugin_update() );
}
public function plugin_update()
{
}
}
$obj = new Test;
$obj->init();
The usual way around this problem is to replace:
add_action( 'plugins_loaded', $this->plugin_update() );
with:
add_action( 'plugins_loaded', array( $this, 'plugin_update' ) );
Upvotes: 5