Plugin Directory

Changeset 2268400


Ignore:
Timestamp:
03/26/2020 04:21:41 PM (6 years ago)
Author:
vohotv
Message:

Small bugfix to only display data if there is a valid API response.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • coronavirus/trunk/includes/shared-partials/coronavirus-info.php

    r2267984 r2268400  
    44  </p>
    55  <div>
    6   <?php foreach ($corona_data_options as $key => $option) : $string = preg_replace('/[A-Z]/', ' $0', $key); ?>
    7     <!-- Get substring of the key to see if the first word is today. If it is we switch the first and last second word so we can omit hard coding key : value pairs-->
    8     <!-- If country attribute is present -->     
    9     <?php if ($option === 'on' && !empty($country_data->country)) : ?>
    10         <?php if (substr($key, 0, 5) !== 'today') : ?>
    11             <label class="panel-block" style="border-color: <?php echo esc_attr(get_option('border_color')); ?>; color: <?php echo esc_attr(get_option('general_text_color')); ?>!important;"><?php echo ucfirst(strtolower($string)) . ": " . esc_html__($country_data->$key); ?></label>
    12           <?php elseif (substr($key, 0, 5) === 'today') : $pieces = preg_split('/(?=[A-Z])/',$key); ?>
    13             <label class="panel-block" style="border-color: <?php echo esc_attr(get_option('border_color')); ?>; color: <?php echo esc_attr(get_option('general_text_color')); ?>!important;"><?php echo ucfirst($pieces[1]) . ' ' . strtolower($pieces[0]) . ": " . $country_data->$key; ?></label>
    14         <?php endif ?>
    15     <!-- If the country attribute is omitted -->     
    16     <?php elseif (empty($country_data->country)) : ?>
    17         <?php foreach ($country_data as $key => $value) : ?>
    18             <?php if ($key !== 'updated') : ?>
    19               <label class="panel-block" style="border-color: <?php echo esc_attr(get_option('border_color')); ?>; color: <?php echo esc_attr(get_option('general_text_color')); ?>!important;"><?php echo ucfirst($key) . ": $value"; ?></label>
    20             <?php endif; ?>   
    21         <?php endforeach; ?>
    22         <?php break;?>
    23     <?php endif; ?>
    24   <?php endforeach; ?>
     6  <?php if (!empty($corona_data_options) && !empty($country_data)): ?>
     7    <?php foreach ($corona_data_options as $key => $option) : $string = preg_replace('/[A-Z]/', ' $0', $key); ?>
     8      <!-- Get substring of the key to see if the first word is today. If it is we switch the first and last second word so we can omit hard coding key : value pairs-->
     9      <!-- If country attribute is present -->     
     10      <?php if ($option === 'on' && !empty($country_data->country)) : ?>
     11          <?php if (substr($key, 0, 5) !== 'today') : ?>
     12              <label class="panel-block" style="border-color: <?php echo esc_attr(get_option('border_color')); ?>; color: <?php echo esc_attr(get_option('general_text_color')); ?>!important;"><?php echo ucfirst(strtolower($string)) . ": " . esc_html__($country_data->$key); ?></label>
     13            <?php elseif (substr($key, 0, 5) === 'today') : $pieces = preg_split('/(?=[A-Z])/',$key); ?>
     14              <label class="panel-block" style="border-color: <?php echo esc_attr(get_option('border_color')); ?>; color: <?php echo esc_attr(get_option('general_text_color')); ?>!important;"><?php echo ucfirst($pieces[1]) . ' ' . strtolower($pieces[0]) . ": " . $country_data->$key; ?></label>
     15          <?php endif ?>
     16      <!-- If the country attribute is omitted -->     
     17      <?php elseif (empty($country_data->country)) : ?>
     18          <?php foreach ($country_data as $key => $value) : ?>
     19              <?php if ($key !== 'updated') : ?>
     20                <label class="panel-block" style="border-color: <?php echo esc_attr(get_option('border_color')); ?>; color: <?php echo esc_attr(get_option('general_text_color')); ?>!important;"><?php echo ucfirst($key) . ": $value"; ?></label>
     21              <?php endif; ?>   
     22          <?php endforeach; ?>
     23          <?php break;?>
     24      <?php endif; ?>
     25    <?php endforeach; ?>
     26  <?php endif; ?>
    2527  </div>
    2628</article>
Note: See TracChangeset for help on using the changeset viewer.