Changeset 2281640
- Timestamp:
- 04/11/2020 07:26:24 PM (6 years ago)
- Location:
- coronavirus/trunk
- Files:
-
- 7 edited
-
README.txt (modified) (1 diff)
-
admin/class-coronavirus-admin.php (modified) (3 diffs)
-
admin/partials/coronavirus-settings.php (modified) (2 diffs)
-
coronavirus.php (modified) (2 diffs)
-
includes/class-coronavirus-activator.php (modified) (1 diff)
-
includes/class-coronavirus-shared-functionality.php (modified) (1 diff)
-
includes/shared-partials/coronavirus-info.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
coronavirus/trunk/README.txt
r2269081 r2281640 52 52 Yes, 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"]. 53 53 Look 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 126 126 * If user can manage_options/is admin and matches the forms nonce, save the settings. 127 127 */ 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')) { 129 129 if (isset($_POST['save-settings']) ) { 130 130 … … 139 139 $corona_data_options = []; 140 140 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'; 142 142 } 143 143 144 144 // 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'); 146 146 147 147 // Save data options and its chosen value. … … 157 157 delete_option('border_color'); 158 158 159 delete_option('corona_data_options'); 160 161 delete_option('display_flag'); 159 162 } 160 163 } -
coronavirus/trunk/admin/partials/coronavirus-settings.php
r2269081 r2281640 25 25 'critical' => __('Critical', 'coronavirus'), 26 26 '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') 28 30 ]; 29 31 30 32 $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'); 32 34 $corona_data_options = get_option('corona_data_options'); 33 35 ?> … … 118 120 <tr> 119 121 <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> 121 123 </tr> 122 124 </tbody> -
coronavirus/trunk/coronavirus.php
r2269081 r2281640 17 17 * Plugin URI: https://github.com/VoHoTv/coronavirus 18 18 * Description: Display data about the coronavirus. 19 * Version: 1. 2.019 * Version: 1.3.0 20 20 * Author: Mike Zuidhoek 21 21 * Author URI: https://mikezuidhoek.com/ … … 36 36 * Rename this for your plugin and update it as you release new versions. 37 37 */ 38 define( 'CORONAVIRUS_VERSION', '1. 2.0' );38 define( 'CORONAVIRUS_VERSION', '1.3.0' ); 39 39 40 40 /** -
coronavirus/trunk/includes/class-coronavirus-activator.php
r2269081 r2281640 31 31 */ 32 32 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'); 34 40 } 35 41 -
coronavirus/trunk/includes/class-coronavirus-shared-functionality.php
r2269081 r2281640 36 36 37 37 // // 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"; 39 39 40 40 $response = wp_remote_get( $url ); -
coronavirus/trunk/includes/shared-partials/coronavirus-info.php
r2269081 r2281640 9 9 <?php foreach ($corona_data_options as $key => $option) : $string = preg_replace('/[A-Z]/', ' $0', $key); ?> 10 10 <!-- 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') : ?> 13 12 <?php if (substr($key, 0, 5) !== 'today') : ?> 14 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(strtolower($string)) . ": " . esc_html__($country_data->$key); ?></label> … … 16 15 <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> 17 16 <?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;?>26 17 <?php endif; ?> 27 18 <?php endforeach; ?>
Note: See TracChangeset
for help on using the changeset viewer.