- <?php foreach ($latest_data as $key => $value) {
- // we generate the fields first and then populate the output
- if ( 'data' === $key ) {
- $latest_date = date('d/m/Y', strtotime($value));
- $previous_date = date('d/m/Y', strtotime($yesterday_data[0][$key]));
- }
- // this check is redundant because $value is obtained straight from the json
- // but still, better check than being sorry
- if ( is_numeric($value) ) {
- $latest_content = number_format($value, 0, ',', '˙');
- $diff = $value - $yesterday_data[0][$key];
- $diff_plusminus = (is_numeric($diff) && round($diff) > 1) ? '<span class="wp-exclude-emoji dnxcovita_goingup">↗</span> +' : '<span class="wp-exclude-emoji dnxcovita_goingdown">↘</span> −';
- $diff_content = $diff_plusminus . number_format($diff, 0, ',', '˙');
- }
- // Now we have all the values formatted so we can output the definition list
- if ('data' !== $key) {
- echo '<dt>' . str_replace('_', ' ', $key) . '</dt>';
- echo '<dd><span class="dnxcovita_latest_data">' . $latest_content . '</span> <span class="dnxcovita_previous_data">' . $diff_content . '</span></dd>';
+ <?php
+ foreach ( $latest_data as $key => $value ) {
+ // we generate the fields first and then populate the output
+ if ( 'data' === $key ) {
+ $latest_date = date( 'd/m/Y', strtotime( $value ) );
+ $previous_date = date( 'd/m/Y', strtotime( $yesterday_data[0][ $key ] ) );
+ }
+ // this check is redundant because $value is obtained straight from the json
+ // but still, better check than being sorry
+ if ( is_numeric( $value ) ) {
+ $latest_content = number_format( $value, 0, ',', '˙' );
+ $diff = $value - $yesterday_data[0][ $key ];
+ $diff_plusminus = ( is_numeric( $diff ) && round( $diff ) > 1 ) ? '<span class="wp-exclude-emoji dnxcovita_goingup">↗</span> +' : '<span class="wp-exclude-emoji dnxcovita_goingdown">↘</span>';
+ $diff_content = $diff_plusminus . number_format( $diff, 0, ',', '˙' );
+ }
+ // Now we have all the values formatted so we can output the definition list
+ if ( 'data' !== $key ) {
+ echo '<dt>' . str_replace( '_', ' ', $key ) . '</dt>';
+ echo '<dd><span class="dnxcovita_latest_data">' . $latest_content . '</span> <span class="dnxcovita_previous_data">' . $diff_content . '</span></dd>';
+ }