WP_CLI\Context
Auto::is_command_to_run_as_admin()
Check whether the current WP-CLI command is amongst those we want to run as admin.
Method of the class: Auto{}
No Hooks.
Return
true|false
. Whether the current command should be run as admin.
Usage
// private - for code of main (parent) class only $result = $this->is_command_to_run_as_admin();
Auto::is_command_to_run_as_admin() Auto::is command to run as admin code WP-CLI 2.8.0-alpha
private function is_command_to_run_as_admin() { $command = WP_CLI::get_runner()->arguments; foreach ( self::COMMANDS_TO_RUN_AS_ADMIN as $command_to_run_as_admin ) { if ( array_slice( $command, 0, count( $command_to_run_as_admin ) ) === $command_to_run_as_admin ) { WP_CLI::debug( 'Detected a command to be intercepted: ' . implode( ' ', $command ), Context::DEBUG_GROUP ); return true; } } return false; }