Yoast\WP\SEO\MyYoast_Client\User_Interface

Auth_Command::outputprivateYoast 1.0

Outputs data in the requested format.

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

Хуков нет.

Возвращает

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

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

// private - только в коде основоного (родительского) класса
$result = $this->output( $data, $format ): void;
$data(массив) (обязательный)
.
$format(строка) (обязательный)
The output format (table or json).

Код Auth_Command::output() Yoast 27.7

private function output( array $data, string $format ): void {
	if ( $format === 'json' ) {
		// phpcs:ignore Yoast.Yoast.JsonEncodeAlternative.FoundWithAdditionalParams -- CLI output, not user-facing HTML.
		$encoded = \wp_json_encode( $data, \JSON_PRETTY_PRINT );
		WP_CLI::log( ( $encoded !== false ) ? $encoded : '{}' );
		return;
	}

	$items = [];
	foreach ( $data as $key => $value ) {
		$items[] = [
			'field' => $key,
			'value' => (string) $value,
		];
	}

	WP_CLI\Utils\format_items( 'table', $items, [ 'field', 'value' ] );
}