WP_CLI

Formatter::display_item()publicWP-CLI 1.0

Display a single item according to the output arguments.

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

Хуков нет.

Возвращает

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

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

$Formatter = new Formatter();
$Formatter->display_item( $item, $ascii_pre_colorized );
$item(разное) (обязательный)
-
$ascii_pre_colorized(true|false|массив)
A boolean or an array of booleans to pass to show_multiple_fields() if the item in the table is pre-colorized.
По умолчанию: false

Код Formatter::display_item() WP-CLI 2.8.0-alpha

public function display_item( $item, $ascii_pre_colorized = false ) {
	if ( isset( $this->args['field'] ) ) {
		$item  = (object) $item;
		$key   = $this->find_item_key( $item, $this->args['field'] );
		$value = $item->$key;
		if ( in_array( $this->args['format'], [ 'table', 'csv' ], true ) && ( is_object( $value ) || is_array( $value ) ) ) {
			$value = json_encode( $value );
		}
		WP_CLI::print_value(
			$value,
			[
				'format' => $this->args['format'],
			]
		);
	} else {
		$this->show_multiple_fields( $item, $this->args['format'], $ascii_pre_colorized );
	}
}