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.
- [--yes]
- Skip confirmation prompt.
EXAMPLES
wp yoast auth revoke --user=admin wp yoast auth revoke --site wp yoast auth revoke --user=admin --site --yes
Метод класса: 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 27.7
public function revoke( $args = null, $assoc_args = null ): void {
$user_id = \get_current_user_id();
$has_site = isset( $assoc_args['site'] );
$has_user = ( $user_id > 0 );
if ( ! $has_site && ! $has_user ) {
WP_CLI::error( 'Specify --site and/or use the global --user flag.' );
}
WP_CLI::confirm( 'This will revoke the specified tokens. Proceed?', $assoc_args );
if ( $has_user ) {
$this->myyoast_client->revoke_user_token( $user_id );
WP_CLI::log( \sprintf( 'User %d tokens revoked.', $user_id ) );
}
if ( $has_site ) {
$this->myyoast_client->clear_site_token();
WP_CLI::log( 'Site token cleared.' );
}
WP_CLI::success( 'Done.' );
}