ACF\CLI

JsonCommand::display_detailed_statusprivateACF 6.8

Displays detailed status showing individual items that need syncing.

Method of the class: JsonCommand{}

No Hooks.

Returns

null. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->display_detailed_status( $post_types, $format );
$post_types(array) (required)
List of post types to check.
$format(string) (required)
Output format.

Changelog

Since 6.8 Introduced.

JsonCommand::display_detailed_status() code ACF 6.8.8

private function display_detailed_status( $post_types, $format ) {
	$rows          = array();
	$total_pending = 0;

	foreach ( $post_types as $post_type ) {
		$syncable = $this->get_syncable_items( $post_type );

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

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

	if ( empty( $rows ) ) {
		WP_CLI::success( self::MESSAGE_ALREADY_IN_SYNC );
		return;
	}

	format_items( $format, $rows, array( 'Key', 'Title', 'Type', 'Action' ) );

	if ( 'table' === $format ) {
		WP_CLI::log( sprintf( '%d item(s) pending sync. Run `wp acf json sync` to apply changes.', $total_pending ) );
	}
}