ACF\CLI
JsonCommand::display_dry_run
Displays a table of pending sync items for dry-run mode.
Method of the class: JsonCommand{}
No Hooks.
Returns
null. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->display_dry_run( $all_syncable );
- $all_syncable(array) (required)
- The syncable items.
Changelog
| Since 6.8 | Introduced. |
JsonCommand::display_dry_run() JsonCommand::display dry run code 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' ) );
}