wp-cli icon indicating copy to clipboard operation
wp-cli copied to clipboard

wp --context=admin doesn't trigger admin_init action

Open d1sparity-plesk opened this issue 3 years ago • 2 comments

Bug Report

Describe the current, buggy behavior

WP-CLI has got a cool feature "execution context". I have found that "admin" context doesn't trigger admin_init action.

Describe how other contributors can replicate this bug

  • add hook for admin_init action with debug code
  • run any command with --context=admin

Describe what you expect as the correct outcome

admin_init action is triggered

Let us know what environment you are running this on

WP-CLI version: 2.6.0

Provide additional context/screenshots

do_action( 'admin_init' ); performs in the wp-admin/admin.php file.

Looks like admin context of wp-cli, requires this file inside admin_init action handler here

So, so there is no place to trigger this action.

From Slack conversation https://wordpress.slack.com/archives/C02RP4T41/p1658199286371689

d1sparity-plesk avatar Jul 20 '22 03:07 d1sparity-plesk

Thanks for the report, @d1sparity-plesk

  • add hook for admin_init action with debug code
  • run any command with --context=admin

Just to confirm, where is your hook registered? Can you provide a code sample that reproduces the issue?

danielbachhuber avatar Jul 20 '22 14:07 danielbachhuber

Just to confirm, where is your hook registered? Can you provide a code sample that reproduces the issue?

@d1sparity-plesk Nevermind, I understand what's going on now.

danielbachhuber avatar Jul 20 '22 14:07 danielbachhuber

Fixed via #5663

schlessera avatar Oct 27 '22 15:10 schlessera