Changeset 1572919
- Timestamp:
- 01/11/2017 11:19:29 PM (9 years ago)
- Location:
- national-weather-service-alerts/trunk
- Files:
-
- 6 edited
-
classes/class-nws-alerts-admin.php (modified) (15 diffs)
-
classes/class-nws-alerts-client.php (modified) (1 diff)
-
nws-alerts-globals.php (modified) (1 diff)
-
nws-alerts.php (modified) (1 diff)
-
readme.txt (modified) (3 diffs)
-
templates/template-map.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
national-weather-service-alerts/trunk/classes/class-nws-alerts-admin.php
r1118148 r1572919 234 234 235 235 public static function add_settings_page() { 236 $controls = array(); 236 $alerts_bar_controls = array(); 237 $google_maps_controls = array(); 237 238 238 239 if (!empty($_POST)) { … … 242 243 $control = 'error'; 243 244 $key = $prefix . $control; 244 $ controls[$control] = false;245 $alerts_bar_controls[$control] = false; 245 246 246 247 $control = 'zip'; … … 248 249 if (isset($_POST[$key])) { 249 250 update_option($key, $_POST[$key]); 250 $ controls[$control] = $_POST[$key];251 $alerts_bar_controls[$control] = $_POST[$key]; 251 252 } 252 253 … … 255 256 if (isset($_POST[$key])) { 256 257 update_option($key, $_POST[$key]); 257 $ controls[$control] = $_POST[$key];258 $alerts_bar_controls[$control] = $_POST[$key]; 258 259 } 259 260 … … 262 263 if (isset($_POST[$key])) { 263 264 update_option($key, $_POST[$key]); 264 $ controls[$control] = $_POST[$key];265 $alerts_bar_controls[$control] = $_POST[$key]; 265 266 } 266 267 … … 269 270 if (isset($_POST[$key])) { 270 271 update_option($key, $_POST[$key]); 271 $ controls[$control] = $_POST[$key];272 $alerts_bar_controls[$control] = $_POST[$key]; 272 273 } 273 274 … … 276 277 if (isset($_POST[$key])) { 277 278 update_option($key, $_POST[$key]); 278 $ controls[$control] = $_POST[$key];279 $alerts_bar_controls[$control] = $_POST[$key]; 279 280 } 280 281 … … 283 284 if (isset($_POST[$key])) { 284 285 update_option($key, $_POST[$key]); 285 $ controls[$control] = $_POST[$key];286 $alerts_bar_controls[$control] = $_POST[$key]; 286 287 } 287 288 … … 290 291 if (isset($_POST[$key])) { 291 292 update_option($key, $_POST[$key]); 292 $ controls[$control] = $_POST[$key];293 $alerts_bar_controls[$control] = $_POST[$key]; 293 294 } 294 295 … … 297 298 if (isset($_POST[$key]) && $_POST[$key] == 'on') { 298 299 update_option($key, 1); 299 $ controls[$control] = true;300 $alerts_bar_controls[$control] = true; 300 301 } else { 301 302 update_option($key, 0); 302 $ controls[$control] = false;303 $alerts_bar_controls[$control] = false; 303 304 } 304 305 … … 307 308 $allow_enabled = false; 308 309 309 if (isset($ controls['zip']) && !empty($controls['zip'])) $allow_enabled = true;310 if (isset($ controls['city']) && !empty($controls['city']) && isset($controls['state']) && !empty($controls['state'])) $allow_enabled = true;311 if (isset($ controls['state']) && !empty($controls['state']) && isset($controls['county']) && !empty($controls['county'])) $allow_enabled = true;310 if (isset($alerts_bar_controls['zip']) && !empty($alerts_bar_controls['zip'])) $allow_enabled = true; 311 if (isset($alerts_bar_controls['city']) && !empty($alerts_bar_controls['city']) && isset($alerts_bar_controls['state']) && !empty($alerts_bar_controls['state'])) $allow_enabled = true; 312 if (isset($alerts_bar_controls['state']) && !empty($alerts_bar_controls['state']) && isset($alerts_bar_controls['county']) && !empty($alerts_bar_controls['county'])) $allow_enabled = true; 312 313 313 314 if ($allow_enabled && isset($_POST[$key]) && $_POST[$key] == 'on') { 314 315 update_option($key, 1); 315 $ controls[$control] = true;316 $alerts_bar_controls[$control] = true; 316 317 } else { 317 318 if (isset($_POST[$key]) && $_POST[$key] == 'on') { 318 $ controls['error'] = 'Not enough location information was provided to enable the Alerts Bar';319 $alerts_bar_controls['error'] = 'Not enough location information was provided to enable the Alerts Bar'; 319 320 } 320 321 321 322 update_option($key, 0); 322 $controls[$control] = false; 323 $alerts_bar_controls[$control] = false; 324 } 325 } 326 327 if (isset($_POST['nws_alerts_google_maps_action']) && $_POST['nws_alerts_google_maps_action'] === 'update' && check_admin_referer('update', 'nws_alerts_google_maps_nonce')) { 328 $prefix = 'nws_alerts_google_maps_'; 329 330 $control = 'api_key'; 331 $key = $prefix . $control; 332 if (isset($_POST[$key])) { 333 update_option($key, $_POST[$key]); 334 $google_maps_controls[$control] = $_POST[$key]; 323 335 } 324 336 } … … 329 341 echo '<h2>National Weather Service Alerts</h2>'; 330 342 331 echo self::get_module('build-tables', $controls); 332 echo self::get_module('alerts-bar', $controls); 343 echo self::get_module('build-tables', array()); 344 echo self::get_module('google-maps', $google_maps_controls); 345 echo self::get_module('alerts-bar', $alerts_bar_controls); 333 346 334 347 echo '</div>'; … … 519 532 } 520 533 521 $return_value .= '</tbody>'; 522 $return_value .= '</table>'; 534 $return_value .= '</tbody>'; 535 $return_value .= '</table>'; 523 536 524 537 $return_value .= '<input type="submit" value="Save Changes" class="button button-primary" id="' . $control_id_prefix . '-submit" name="' . str_replace('-', '_', $control_id_prefix) . '-submit">'; 525 538 526 $return_value .= '</form>'; 527 $return_value .= '</div>'; 528 $return_value .= '</div>'; 539 $return_value .= '</form>'; 540 $return_value .= '</div>'; 541 $return_value .= '</div>'; 529 542 } else if ($module === 'build-tables') { 530 543 $return_value = ''; … … 545 558 $return_value .= '<p class="description">The NWS Alerts plugin database tables are fully setup and the plugin is ready to be used.</p>'; 546 559 } 560 $return_value .= '</div>'; 561 $return_value .= '</div>'; 562 } else if ($module === 'google-maps') { 563 $defaults = array('api_key' => NWS_ALERTS_GOOGLE_MAPS_API_KEY); 564 $controls = wp_parse_args($controls, $defaults); 565 $return_value = ''; 566 $module_id_prefix = 'nws-alerts'; 567 $control_id_prefix = $module_id_prefix . '-' . $module; 568 569 $return_value .= '<div class="metabox-holder"><div class="meta-box-sortables ui-sortable"><div class="postbox"><h3 class="hndle"><span>Google Maps</span></h3>'; 570 $return_value .= '<div class="inside">'; 571 $return_value .= '<p class="description">The Google Maps JavaScript API now requires an API key in order to display maps on websites. Due to the map API quota limits this API key cannot be included with the plugin and a unique key must be obtained by you.</p>'; 572 $return_value .= '<p class="description">You can obtain a Google Maps JavaScript API key by visiting the <a href="https://developers.google.com/maps/documentation/javascript/get-api-key" target="_blank">Get a Key/Authentication</a> page and following the instructions. Once a project has been created and an associated key has been generated, simply copy it and paste it into the "Google Maps API Key" field below.</p>'; 573 $return_value .= '<form id="' . $control_id_prefix . '" method="post" action="">'; 574 575 $return_value .= self::get_control('action', $control_id_prefix); 576 $return_value .= self::get_control('nonce', $control_id_prefix); 577 578 $return_value .= '<table>'; 579 $return_value .= '<tbody>'; 580 581 foreach($controls as $control => $default) { 582 $return_value .= self::get_control($control, $control_id_prefix, $default); 583 } 584 585 $return_value .= '</tbody>'; 586 $return_value .= '</table>'; 587 588 $return_value .= '<input type="submit" value="Save Changes" class="button button-primary" id="' . $control_id_prefix . '-submit" name="' . str_replace('-', '_', $control_id_prefix) . '-submit">'; 589 590 $return_value .= '</form>'; 547 591 $return_value .= '</div>'; 548 592 $return_value .= '</div>'; … … 572 616 if ($default === false) { $default = 'update'; } 573 617 $return_value .= wp_nonce_field($default, str_replace('-', '_', $control_id_prefix . '_' . $control), true, false); 618 } else if ($control === 'api_key') { 619 if ($default) { $default = ' value="' . $default . '"'; } else { $default = ''; } 620 $return_value .= '<tr>'; 621 $return_value .= '<td><h4>Google Maps API Key</h4></td>'; 622 $return_value .= '<td>'; 623 $return_value .= '<div class="nws-alerts-control-text-container">'; 624 $return_value .= '<input data-control-parent="' . $control . '" data-control="' . $control . '" id="' . $control_id_prefix . '-' . $control . '" name="' . str_replace('-', '_', $control_id_prefix . '_' . $control) . '" type="text"' . $default . ' />'; 625 $return_value .= '</div>'; 626 $return_value .= '</td>'; 627 $return_value .= '</tr>'; 574 628 } else if ($control === 'error') { 575 629 if ($default === false) return; -
national-weather-service-alerts/trunk/classes/class-nws-alerts-client.php
r1118148 r1572919 76 76 /* JavaScript */ 77 77 wp_enqueue_script('nws-alerts-js', NWS_ALERTS_URL . 'js/nws-alerts.js', array('jquery'), null, true); 78 wp_enqueue_script('google-map-api', 'https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=weather&sensor=false', false, null, false); 78 79 if (!empty(NWS_ALERTS_GOOGLE_MAPS_API_KEY)) { 80 wp_enqueue_script('google-map-api', 'https://maps.googleapis.com/maps/api/js?key=' . NWS_ALERTS_GOOGLE_MAPS_API_KEY . '&v=3.exp&libraries=weather', false, null, false); 81 } 79 82 } 80 83 -
national-weather-service-alerts/trunk/nws-alerts-globals.php
r1451950 r1572919 20 20 define('NWS_ALERTS_ABSPATH', plugin_dir_path(__FILE__)); 21 21 define('NWS_ALERTS_URL', plugins_url('/', __FILE__)); 22 23 define('NWS_ALERTS_GOOGLE_MAPS_API_KEY', get_option('nws_alerts_google_maps_api_key')); 22 24 23 25 define('NWS_ALERTS_BAR_ENABLED', filter_var(get_option('nws_alerts_alerts_bar_enabled'), FILTER_VALIDATE_BOOLEAN)); -
national-weather-service-alerts/trunk/nws-alerts.php
r1451950 r1572919 4 4 * Plugin URI: https://github.com/laubsterboy/nws-alerts 5 5 * Description: Easily add official National Weather Service alerts to your website. 6 * Version: 1.3. 26 * Version: 1.3.3 7 7 * Author: John Russell 8 8 * Author URI: http://www.laubsterboy.com -
national-weather-service-alerts/trunk/readme.txt
r1451950 r1572919 4 4 Tags: National Weather Service, NWS, Storm Prediction Center, SPC, Alert, Weather, Storm, Severe, Tornado, Thunder, Flood 5 5 Requires at least: 3.1 6 Tested up to: 4. 57 Stable tag: 1.3. 26 Tested up to: 4.7 7 Stable tag: 1.3.3 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 108 108 == Changelog == 109 109 110 = 1.3.3 = 111 * Fixed: The alerts map now requires a Google Maps JavaScript API key, so a new setting was added to the NWS Alerts settings page. 112 110 113 = 1.3.2 = 111 114 * Improvement: The wp_remote_get function is now used to request National Weather Service CAP data. This will use WordPress core HTTP functions and classes and improves server compatibility. … … 155 158 == Upgrade Notice == 156 159 160 = 1.3.3 = 161 * Fixed: The maps are working again as long as a Google Maps JavaScript API key is provided. 162 157 163 = 1.3.2 = 158 164 * Standardized the method used to request National Weather Service alert data. -
national-weather-service-alerts/trunk/templates/template-map.php
r1118148 r1572919 11 11 */ 12 12 13 if (!empty(NWS_ALERTS_GOOGLE_MAPS_API_KEY)) { 13 14 $return_value = ' 14 15 <script type="text/javascript"> … … 32 33 </script> 33 34 <section id="nws-alerts-map-' . $this->zip . $this->scope . '" class="nws-alerts-map"></section>'; 35 } 34 36 35 37 ?>
Note: See TracChangeset
for help on using the changeset viewer.