WP-CLI plugin install causes PHP fatal error – Using $this when not in object context

Question

When running sudo wp install plugin pluginname –allowroot

It causes an error:

PHP Fatal error: Uncaught Error: Using $this when not in object context in /var/www/html/wp-content/plugins/pluginname/blocks.php:89

We have a custom plugin that has this line:

 class Block{ 
    public static function Run() {           
      add_action('enqueue_block_editor_assets',array($this,'RegisterBlock')); //complains on this line

When installing via WP admin – it works fine. But when using WP-CLI it fails.

Any help will be appreciated

0
Michael Soriano 3 months 0 Answers 10 views 0

Leave an answer