3

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: enter image description here

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?

andreas
  • 16,357
  • 12
  • 72
  • 76
boisterouslobster
  • 1,283
  • 3
  • 25
  • 54

1 Answers1

5

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' ) );
birgire
  • 11,258
  • 1
  • 31
  • 54