Yoast\WP\SEO\MyYoast_Client\User_Interface

Auth_Command::registerpublicYoast 1.0

Registers the site as an OAuth client.

Performs Dynamic Client Registration (RFC 7591) if the site is not already registered. Use --force to deregister and re-register.

OPTIONS

[--force]
Deregister first, then re-register.
[--format=<format>]
Output format.
--- default: table options:
  • table
  • json

EXAMPLES

wp yoast auth register
wp yoast auth register --force

Метод класса: Auth_Command{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$Auth_Command = new Auth_Command();
$Auth_Command->register( $args, $assoc_args ): void;
$args
.
По умолчанию: null
$assoc_args
.
По умолчанию: null

Код Auth_Command::register() Yoast 28.3

public function register( $args = null, $assoc_args = null ): void {
	if ( Utils\get_flag_value( $assoc_args, 'force', false ) ) {
		$this->myyoast_client->deregister();
		WP_CLI::log( 'Deregistered existing client.' );
	}

	try {
		$client = $this->myyoast_client->ensure_registered();
	} catch ( Registration_Temporarily_Unavailable_Exception $e ) {
		$retry_after = $e->get_retry_after_seconds();
		$retry_hint  = ( $retry_after !== null ) ? \sprintf( ' Try again in %d seconds.', $retry_after ) : ' Try again later.';
		WP_CLI::error( 'Registration is temporarily unavailable.' . $retry_hint );
		return;
	} catch ( Exception $e ) {
		WP_CLI::error( 'Registration failed: ' . $e->getMessage() );
		return;
	}

	$this->output(
		[
			'client_id' => $client->get_client_id(),
			'status'    => 'registered',
		],
		Utils\get_flag_value( $assoc_args, 'format', 'table' ),
	);

	WP_CLI::success( 'Client registered: ' . $client->get_client_id() );
}