ACF\CLI

JsonCommand::display_dry_runprivateACF 6.8

Displays a table of pending sync items for dry-run mode.

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

Хуков нет.

Возвращает

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

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

// private - только в коде основоного (родительского) класса
$result = $this->display_dry_run( $all_syncable );
$all_syncable(массив) (обязательный)
The syncable items.

Список изменений

С версии 6.8 Введена.

Код JsonCommand::display_dry_run() ACF 6.8.8

private function display_dry_run( $all_syncable ) {
	$rows = array();

	foreach ( $all_syncable as $key => $item ) {
		$post   = $item['post'];
		$action = $post['ID'] ? 'Update' : 'Create';

		$rows[] = array(
			'Key'    => $key,
			'Title'  => $post['title'],
			'Type'   => $this->get_type_label( $item['post_type'] ),
			'Action' => $action,
		);
	}

	WP_CLI::log( sprintf( '%d item(s) pending sync:', count( $rows ) ) );
	format_items( 'table', $rows, array( 'Key', 'Title', 'Type', 'Action' ) );
}