get_id() : ( isset( $object->ID ) ? (int) $object->ID : 0 );
if ( ! $id ) {
return;
}
$history = JournalReader::history( $id, 10 );
if ( empty( $history ) ) {
echo '
' . esc_html__( 'Recast has not changed this subscription.', 'recast-subscriptions' ) . '
';
return;
}
echo '';
foreach ( $history as $entry ) {
$fields = array_map( array( Fields::class, 'label' ), $entry['changed_fields'] );
printf(
'- %s · %s
%s ',
esc_url( Menu::url( '#/runs/' . (int) $entry['run']['id'] ) ),
esc_html( self::operation_label( $entry['run']['operation'] ) ),
esc_html( Labels::item_status( $entry['status'] ) ),
esc_html( $entry['applied_at'] . ( $fields ? ' · ' . implode( ', ', array_unique( $fields ) ) : '' ) )
);
}
echo '
';
}
/**
* Label of a change, or a readable fallback when it is no longer registered.
*
* @param string $operation_id Operation id.
* @return string
*/
private static function operation_label( $operation_id ) {
try {
return Plugin::instance()->operations()->get( $operation_id )->describe()->label;
} catch ( \Exception $e ) {
return Labels::humanize( str_replace( '.', ' ', (string) $operation_id ) );
}
}
}