Plugin Directory

Changeset 2281640


Ignore:
Timestamp:
04/11/2020 07:26:24 PM (6 years ago)
Author:
vohotv
Message:

Version 1.3.0 which consists mostly of bug fixes.

Location:
coronavirus/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • coronavirus/trunk/README.txt

    r2269081 r2281640  
    5252Yes, you can display the data of a specific country by adding the country attribute to the shortcode like this [coronavirus country="name_of_the_country"].
    5353Look at the description for more information.
     54
     55== Changelog ==
     56
     57= 1.3.0 =
     58* Errors when saving options has been fixed.
     59* Selected options now get deleted from the database when the plugin is deactivated.
     60* Added option to display total tests and tests per one million.
     61* Fixed bug which could lead to the wrong country data being displayed.
  • coronavirus/trunk/admin/class-coronavirus-admin.php

    r2269081 r2281640  
    126126         * If user can manage_options/is admin and matches the forms nonce, save the settings.
    127127         */
    128         if (current_user_can('manage_options') && wp_verify_nonce($_POST['_wpnonce'], 'submit-settings')) {
     128        if (current_user_can('manage_options') && isset($_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'submit-settings')) {
    129129            if (isset($_POST['save-settings']) ) {
    130130               
     
    139139                $corona_data_options = [];
    140140                foreach ($checkbox_ids as $id => $display_value) {
    141                     $corona_data_options[$id] = sanitize_key($_POST[$id]);
     141                    isset($_POST[$id]) ? $corona_data_options[$id] = sanitize_key($_POST[$id]) : $corona_data_options[$id] = 'off';
    142142                }
    143143
    144144                // Update whether to display flag or not
    145                 update_option('display_flag', sanitize_key($_POST['display-flag']));
     145                isset($_POST['display-flag']) ? update_option('display_flag', sanitize_key($_POST['display-flag'])) : update_option('display_flag', 'off');
    146146               
    147147                // Save data options and its chosen value.
     
    157157                delete_option('border_color');
    158158               
     159                delete_option('corona_data_options');
     160
     161                delete_option('display_flag');
    159162            }
    160163        }
  • coronavirus/trunk/admin/partials/coronavirus-settings.php

    r2269081 r2281640  
    2525    'critical' => __('Critical', 'coronavirus'),
    2626    'casesPerOneMillion' => __('Cases per one million', 'coronavirus'),
    27     'deathsPerOneMillion' => __('Deaths per one million', 'coronavirus')
     27    'deathsPerOneMillion' => __('Deaths per one million', 'coronavirus'),
     28    'tests' => __('Tests', 'coronavirus'),
     29    'testsPerOneMillion' => __('Tests per one million', 'coronavirus')
    2830];
    2931
    3032$this->save_settings($checkbox_ids);
    31 $country_data = $this->shared_functionality->get_corona_data('China');
     33$country_data = $this->shared_functionality->get_corona_data('usa');
    3234$corona_data_options = get_option('corona_data_options');
    3335?>
     
    118120                    <tr>
    119121                    <th scope="row">Display data by country <small class="text-muted">quotation marks are mandatory, country name is not case sensitive</small></th>
    120                     <td>[coronavirus country="china"]</td>
     122                    <td>[coronavirus country="usa"]</td>
    121123                    </tr>
    122124                </tbody>
  • coronavirus/trunk/coronavirus.php

    r2269081 r2281640  
    1717 * Plugin URI:        https://github.com/VoHoTv/coronavirus
    1818 * Description:       Display data about the coronavirus.
    19  * Version:           1.2.0
     19 * Version:           1.3.0
    2020 * Author:            Mike Zuidhoek
    2121 * Author URI:        https://mikezuidhoek.com/
     
    3636 * Rename this for your plugin and update it as you release new versions.
    3737 */
    38 define( 'CORONAVIRUS_VERSION', '1.2.0' );
     38define( 'CORONAVIRUS_VERSION', '1.3.0' );
    3939
    4040/**
  • coronavirus/trunk/includes/class-coronavirus-activator.php

    r2269081 r2281640  
    3131     */
    3232    public static function activate() {
    33 
     33        delete_option('display_flag');
     34        delete_option('corona_data_options');
     35        delete_option('header_background_color');
     36        delete_option('header_text_color');
     37        delete_option('general_background_color');
     38        delete_option('general_text_color');
     39        delete_option('border_color');
    3440    }
    3541
  • coronavirus/trunk/includes/class-coronavirus-shared-functionality.php

    r2269081 r2281640  
    3636       
    3737        // // If country attribute is omitted display global data.
    38         $url = empty($country) ? "https://corona.lmao.ninja/all" : "https://corona.lmao.ninja/countries/$country_slug";
     38        $url = empty($country) ? "https://corona.lmao.ninja/all" : "https://corona.lmao.ninja/countries/$country_slug?strict=true";
    3939
    4040        $response = wp_remote_get( $url );
  • coronavirus/trunk/includes/shared-partials/coronavirus-info.php

    r2269081 r2281640  
    99    <?php foreach ($corona_data_options as $key => $option) : $string = preg_replace('/[A-Z]/', ' $0', $key); ?>
    1010      <!-- 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-->
    11       <!-- If country attribute is present -->     
    12       <?php if ($option === 'on' && !empty($country_data->country)) : ?>
     11      <?php if ($option === 'on') : ?>
    1312          <?php if (substr($key, 0, 5) !== 'today') : ?>
    1413              <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>
     
    1615              <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>
    1716          <?php endif ?>
    18       <!-- If the country attribute is omitted -->     
    19       <?php elseif (empty($country_data->country)) : ?>
    20           <?php foreach ($country_data as $key => $value) : ?>
    21               <?php if ($key !== 'updated') : ?>
    22                 <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>
    23               <?php endif; ?>   
    24           <?php endforeach; ?>
    25           <?php break;?>
    2617      <?php endif; ?>
    2718    <?php endforeach; ?>
Note: See TracChangeset for help on using the changeset viewer.