Yoast\WP\SEO\MyYoast_Client\User_Interface
Auth_Command::revoke
Revokes tokens for the current user and/or the site.
Without --site, revokes the current user's tokens (requires --user flag). With --site, clears the cached site-level token. Both can be combined.
OPTIONS
- [--site]
- Clear the cached site-level token.
- [--resource=<uri>]
- Limit revocation to a single RFC 8707 resource indicator. Omit to target the default resource.
- [--all-resources]
- Revoke every stored token across all resource indicators. Cannot be combined with --resource.
- [--yes]
- Skip confirmation prompt.
EXAMPLES
wp yoast auth revoke --user=admin wp yoast auth revoke --site wp yoast auth revoke --user=admin --site --yes wp yoast auth revoke --user=admin --resource=https://ai.yoa.st wp yoast auth revoke --user=admin --site --all-resources
Метод класса: Auth_Command{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$Auth_Command = new Auth_Command(); $Auth_Command->revoke( $args, $assoc_args ): void;
- $args
- .
По умолчанию:null - $assoc_args
- .
По умолчанию:null
Код Auth_Command::revoke() Auth Command::revoke Yoast 28.3
public function revoke( $args = null, $assoc_args = null ): void {
$user_id = \get_current_user_id();
$has_user = ( $user_id > 0 );
$has_site = (bool) Utils\get_flag_value( $assoc_args, 'site', false );
$has_all_resources = (bool) Utils\get_flag_value( $assoc_args, 'all-resources', false );
$resource = Utils\get_flag_value( $assoc_args, 'resource' );
if ( ! $has_site && ! $has_user ) {
WP_CLI::error( 'Specify --site and/or use the global --user flag.' );
}
if ( $has_all_resources && $resource !== null && $resource !== '' ) {
WP_CLI::error( '--all-resources and --resource cannot be combined.' );
}
$resource_indicator = null;
if ( $resource !== null && $resource !== '' ) {
$resource_indicator = (string) $resource;
try {
new Resource_Indicator( $resource_indicator );
}
catch ( Invalid_Resource_Exception $e ) {
WP_CLI::error( 'Invalid resource indicator: ' . $e->getMessage() );
return;
}
}
WP_CLI::confirm( 'This will revoke the specified tokens. Proceed?', $assoc_args );
try {
if ( $has_user ) {
if ( $has_all_resources ) {
$this->myyoast_client->revoke_all_user_tokens( $user_id );
WP_CLI::log( \sprintf( 'User %d tokens revoked across all resources.', $user_id ) );
}
else {
$this->myyoast_client->revoke_user_token( $user_id, $resource_indicator );
WP_CLI::log( \sprintf( 'User %d tokens revoked.', $user_id ) );
}
}
if ( $has_site ) {
if ( $has_all_resources ) {
$this->myyoast_client->clear_all_site_tokens();
WP_CLI::log( 'All site tokens cleared.' );
}
else {
$this->myyoast_client->clear_site_token( $resource_indicator );
WP_CLI::log( 'Site token cleared.' );
}
}
}
catch ( Exception $e ) {
WP_CLI::error( 'Revocation failed: ' . $e->getMessage() );
return;
}
WP_CLI::success( 'Done.' );
}