Security
Headlines
HeadlinesLatestCVEs

Headline

CVE-2023-4944: awesome-weather.php in awesome-weather/tags/3.0.2 – WordPress Plugin Repository

The Awesome Weather Widget for WordPress plugin for WordPress is vulnerable to Stored Cross-Site Scripting via ‘awesome-weather’ shortcode in versions up to, and including, 3.0.2 due to insufficient input sanitization and output escaping on user supplied attributes. This makes it possible for authenticated attackers with contributor-level and above permissions to inject arbitrary web scripts in pages that will execute whenever a user accesses an injected page.

CVE
#xss#web#google#js#git#java#wordpress#php#auth#ssl

1<?php2/*3Plugin Name: Awesome Weather Widget4Plugin URI: https://halgatewood.com/awesome-weather5Description: A weather widget that actually looks cool6Author: Hal Gatewood7Author URI: https://www.halgatewood.com8Version: 3.0.29Text Domain: awesome-weather10Domain Path: /languages1112Hi DEVS!13FILTERS AVAILABLE:14https://halgatewood.com/docs/plugins/awesome-weather-widget/available-filters15*/161718define( 'AWESOME_WEATHER_LOOKUP_URL’, ‘https://ipinfo.io/[[IP]]/json’ );19define( 'AWESOME_WEATHER_OWM_API_URL’, ‘https://api.openweathermap.org/data/2.5/’ );20define( 'AWESOME_WEATHER_DARKSKY_API_URL’, ‘https://api.darksky.net/’ );21define( 'AWESOME_WEATHER_LOCATIONIQ_API_URL’, apply_filters('awesome_weather_locationiq_endpoint’, ‘https://us1.locationiq.com/v1/’) );22define( 'AWESOME_WEATHER_PLUGIN_BASE’, plugin_dir_url( __FILE__ ) );2324// GLOBAL SETTINGS25$awesome_weather_sizes = apply_filters( ‘awesome_weather_sizes’ , array( 26 ‘tall’ => __('Tall’, ‘awesome-weather’), 27 ‘wide’ => __('Wide’, ‘awesome-weather’), 28 ‘micro’ => __('Micro’, ‘awesome-weather’), 29 ‘showcase’ => __('Showcase’, ‘awesome-weather’), 30 ‘long’ => __('Long’, ‘awesome-weather’), 31 ‘boxed’ => __('Boxed’, ‘awesome-weather’), 32 ‘material’ => __('Material’, ‘awesome-weather’), 33 ‘basic’ => __('Basic’, ‘awesome-weather’), 34 ‘custom’ => __('Custom’, ‘awesome-weather’) ) );353637// INCLUDES38require_once( dirname(__FILE__) . ‘/providers/openweathermaps.php’ );39require_once( dirname(__FILE__) . ‘/providers/darksky.php’ );40include_once( dirname(__FILE__) . ‘/awesome-weather-codes.php’);41include_once( dirname(__FILE__) . ‘/awesome-weather-mediabox.php’);42434445// SETUP46function awesome_weather_setup()47{ 48 if( is_admin() ) add_action( 'admin_menu’, ‘awesome_weather_setting_page_menu’ );49}50add_action('plugins_loaded’, 'awesome_weather_setup’, 99999, 0);515253// LANGUAGES54function awesome_weather_setup_locale()55{56 $locale = apply_filters('plugin_locale’, get_locale(), ‘awesome-weather’); 57 $mofile = WP_LANG_DIR . '/awesome-weather/awesome-weather-' . $locale . '.mo’;5859 if( file_exists( $mofile ) )60 {61 load_textdomain( 'awesome-weather’, $mofile );62 }63 else64 {65 load_plugin_textdomain( 'awesome-weather’, false, dirname( plugin_basename( __FILE__ ) ) . ‘/languages/’ );66 }67}68add_action( 'init’, ‘awesome_weather_setup_locale’ );69707172// ENQUEUE CSS73function awesome_weather_wp_head() 74{75 wp_enqueue_script( 'awesome_weather’, plugin_dir_url( __FILE__ ) . 'js/awesome-weather-widget-frontend.js’, array(‘jquery’), '1.1’, add_filter('awesome_weather_js_in_footer’, false) );76 wp_enqueue_style( 'awesome-weather’, plugins_url( '/awesome-weather.css’, __FILE__ ) );77 78 $use_google_font = apply_filters('awesome_weather_use_google_font’, true);79 $google_font_queuename = apply_filters('awesome_weather_google_font_queue_name’, ‘opensans-googlefont’);80 81 if( $use_google_font )82 {83 wp_enqueue_style( $google_font_queuename, ‘//fonts.googleapis.com/css?family=Open+Sans:400’ );84 wp_add_inline_style( 'awesome-weather’, “.awesome-weather-wrap { font-family: 'Open Sans’, sans-serif; font-weight: 400; font-size: 14px; line-height: 14px; }” );85 }86}87add_action('wp_enqueue_scripts’, ‘awesome_weather_wp_head’);888990// THE SHORTCODE91add_shortcode( 'awesome-weather’, ‘awesome_weather_shortcode’ );92add_shortcode( 'awesome-weather-ajax’, ‘awesome_weather_ajax’ );93function awesome_weather_shortcode( $atts )94{95 $run_as_ajax = true;96 if( isset($atts[‘ajax’]) )97 {98 if( !$atts[‘ajax’] ) $run_as_ajax = false;99 else if( strtolower($atts[‘ajax’]) == ‘false’) $run_as_ajax = false;100 else if( $atts[‘ajax’] == “0”) $run_as_ajax = false;101 }102 103 if( $run_as_ajax )104 {105 return awesome_weather_ajax( $atts );106 }107 else108 {109 return awesome_weather_logic( $atts );110 } 111}112113function awesome_weather_ajax( $atts )114{115 $atts = (object) $atts;116 117 $inline_style = isset($atts->inline_style_wrap) ? $atts->inline_style_wrap : ‘’;118 119 // HIDE LOADER120 $show_loader = true;121 if( isset($atts->loader) AND (!$atts->loader OR $atts->loader == ‘false’) ) $show_loader = false;122 123 // GET AN ID, SO WE KNOW WHERE TO LOAD124 if( !isset($atts->id) OR !$atts->id ) $atts->id= awe_widget_id( $atts, true );125 126 // AJAX TO PING127 $atts->ajaxurl = admin_url(‘admin-ajax.php’);128 $atts->via_ajax = 1;129 130 // OUTPUT A WRAPPER131 ob_start();132 133 echo ‘<div id="awe-ajax-' . $atts->id .’" class="awe-ajax-' . $atts->id .’ awe-weather-ajax-wrap" style="’ . $inline_style .’">’;134 if( $show_loader ) echo '<div class="awe-loading"><i class="wi ' . apply_filters('awesome_weather_loader’, ‘wi-day-sunny’) . '"></i></div>’;135 echo '</div>’;136 echo '<script type="text/javascript"> jQuery(document).ready(function() { awe_ajax_load(' . json_encode($atts) . '); }); </script>’;137 138 $output = ob_get_contents();139 ob_end_clean();140 return $output;141}142143// RETURN WEATHER WIDGET, ACF STYLE144function get_awesome_weather_widget( $atts )145{146 if( is_string($atts) )147 {148 $local = $atts;149 $atts = array();150 $atts[‘location’] = $local;151 }152 else if ( is_object($atts) )153 {154 $atts = (array) $atts;155 }156 else157 {158 if( !is_array($atts)) $atts = (array) $atts;159 }160161 return awesome_weather_logic( $atts ); 162}163164165// DISPLAY WEATHER WIDGET, ACF STYLE166function the_awesome_weather_widget( $atts )167{168 if( is_string($atts) )169 {170 $local = $atts;171 $atts = array();172 $atts[‘location’] = $local;173 }174 else if ( is_object($atts) )175 {176 $atts = (array) $atts;177 }178 else179 {180 if( !is_array($atts)) $atts = (array) $atts;181 }182 183 echo awesome_weather_logic( $atts ); 184}185186187// THE LOGIC188function awesome_weather_logic( $atts )189{190 global $awesome_weather_sizes;191 192 if( is_object($atts) ) $atts = (array) $atts;193 194 195 $add_to_transient = '’;196 $weather = new stdclass;197 198 // DEFAULT SETTINGS199 $weather->id = isset($atts[‘id’]) ? $atts[‘id’] : awe_widget_id_new( $atts );200 $weather->error = false;201 $weather->location = isset($atts[‘location’]) ? awesome_weather_prep_location( $atts[‘location’] ) : '’;202 $weather->owm_city_id = isset($atts[‘owm_city_id’]) ? $atts[‘owm_city_id’] : 0;203 204 $weather->user_location = isset($atts[‘user_location’]) ? $atts[‘user_location’] : '’;205 $weather->latlng = isset($atts[‘latlng’]) ? $atts[‘latlng’] : '’;206207 $weather->template = isset($atts[‘size’]) ? $atts[‘size’] : 'wide’;208 $weather->template = isset($atts[‘template’]) ? $atts[‘template’] : $weather->template;209 $weather->custom_template_name = isset($atts[‘custom_template_name’]) ? $atts[‘custom_template_name’] : '’;210 $weather->inline_style = isset($atts[‘inline_style’]) ? $atts[‘inline_style’] : '’;211212 $weather->units = (isset($atts[‘units’]) AND $atts[‘units’] != ‘’) ? $atts[‘units’] : '’;213 $weather->override_title = isset($atts[‘override_title’]) ? $atts[‘override_title’] : '’;214 $weather->forecast_days = isset($atts[‘forecast_days’]) ? $atts[‘forecast_days’] : 5;215 216 $weather->show_stats = (isset($atts[‘hide_stats’]) AND $atts[‘hide_stats’] == 1) ? 0 : 1;217 $weather->hide_stats = (isset($atts[‘hide_stats’]) AND $atts[‘hide_stats’] == 1) ? 1 : 0;218 $weather->show_link = (isset($atts[‘show_link’]) AND $atts[‘show_link’] == 1) ? 1 : 0;219 $weather->show_icons = (isset($atts[‘show_icons’]) AND $atts[‘show_icons’] == 1) ? 1 : 0;220 $weather->use_user_location = (isset($atts[‘use_user_location’]) AND $atts[‘use_user_location’] == 1) ? 1 : 0;221 $weather->allow_user_to_change = (isset($atts[‘allow_user_to_change’]) AND $atts[‘allow_user_to_change’] == 1) ? 1 : 0;222 $weather->skip_geolocate = (isset($atts[‘skip_geolocate’]) AND $atts[‘skip_geolocate’] == 1) ? 1 : 0;223 224 $weather->extended_url = isset($atts[‘extended_url’]) ? $atts[‘extended_url’] : '’;225 $weather->extended_text = isset($atts[‘extended_text’]) ? $atts[‘extended_text’] : '’;226 $weather->show_attribution = (isset($atts[‘hide_attribution’]) AND $atts[‘hide_attribution’] == 1) ? 0 : 1;227 if(isset($atts[‘hide_attribution’]) AND $atts[‘hide_attribution’] ) $weather->hide_attribution = $atts[‘hide_attribution’];228229 $weather->background_classes = isset($atts[‘background_classes’]) ? $atts[‘background_classes’] : array();230 $weather->background_image = isset($atts[‘background’]) ? $atts[‘background’] : 0;231 $weather->background_image = isset($atts[‘background_image’]) ? $atts[‘background_image’] : $weather->background_image;232 $weather->background_color = isset($atts[‘custom_bg_color’]) ? $atts[‘custom_bg_color’] : 0;233 $weather->background_color = isset($atts[‘background_color’]) ? $atts[‘background_color’] : $weather->background_color;234 $weather->background_by_weather = (isset($atts[‘background_by_weather’]) AND $atts[‘background_by_weather’] == 1) ? 1 : 0;235 $weather->background_by_weather_ext = isset($atts[‘background_by_weather_ext’]) ? $atts[‘background_by_weather_ext’] : apply_filters('awesome_weather_bg_ext’, ‘jpg’ );236 $weather->text_color = isset($atts[‘text_color’]) ? $atts[‘text_color’] : '#ffffff’;237 $weather->skip_geolocate = isset($atts[‘skip_geolocate’]) ? $atts[‘skip_geolocate’] : apply_filters('awesome_weather_skip_geolocate’, 0 );238 239 240 // PROVIDERS241 $providers = array('openweathermaps’, ‘darksky’);242 $weather->provider = in_array( get_option( ‘awe-weather-provider’ ), $providers ) ? get_option( ‘awe-weather-provider’ ) : 'openweathermaps’;243 if( isset($atts[‘provider’]) AND in_array($atts[‘provider’], $providers) ) $weather->provider = $atts[‘provider’];244 245 $weather->data = array();246 $weather->locale = 'en’;247 $weather->use_custom_translation = apply_filters('awesome_weather_use_custom_translation’, 0 );248 249250 // LOCALE SETTINGS251 $sytem_locale = get_locale();252 $available_locales = awesome_weather_get_locales(); 253254 // CHECK FOR LOCALE255 if( in_array( $sytem_locale, $available_locales ) ) $weather->locale = $sytem_locale;256 257 258 // CHECK FOR LOCALE BY FIRST TWO DIGITS259 if( in_array(substr($sytem_locale, 0, 2), $available_locales ) ) $weather->locale = substr($sytem_locale, 0, 2);260261 262 // OVERRIDE LOCALE PARAMETER263 if( isset($atts[‘locale’]) ) $weather->locale = $atts[‘locale’];264 265 266 // A LAST CHANCE TO OVERRIDE THE LOCALE267 $weather->locale = apply_filters('awesome_weather_locale’, $weather->locale );268 269 270 // BASIC TEMPLATE TRANSLATIONS271 $weather->t = new stdclass;272 $weather->t->humidity = __('humidity’, ‘awesome-weather’);273 $weather->t->high = __('H’, ‘awesome-weather’);274 $weather->t->low = __('L’, ‘awesome-weather’);275 $weather->t->now = __('Now’, ‘awesome-weather’);276 $weather->t->wind = __('wind:’, ‘awesome-weather’);277 $weather->t->weather_from = __('Weather from’, ‘awesome-weather’);278 $weather->t->set_location = __('Set Your Location’, ‘awesome-weather’);279 $weather->t->search_placeholder = __('Search: City, State or Country’, ‘awesome-weather’);280 $weather->t->city_not_found = __('City not found, please try again.’, ‘awesome-weather’);281 $weather->t = apply_filters('awesome_weather_basic_translations’, $weather->t, $weather->id);282 283 284 // DEFAULTS WEATHER UNITS285 if( $weather->provider == ‘openweathermaps’ AND !$weather->units ) 286 {287 $weather->units = 'F’;288 }289 else if( $weather->provider == ‘darksky’ AND !$weather->units )290 {291 $weather->units = 'us’;292 }293 294 295 // USE CHANGE LOCATION CODE296 $weather->user_provided = false;297 $weather->show_bubble = true;298 299 if( $weather->allow_user_to_change )300 {301 // IF GEO TRIGGERED302 if( isset($atts[‘geotriggered’]) AND $weather->latlng )303 {304 setcookie('awe_latlng’, $weather->latlng, time() + apply_filters( 'awesome_weather_latlon_cache’, 31104000 ), '/’, $_SERVER[‘HTTP_HOST’], is_ssl() ? true: false );305 306 $weather->units = 'auto’;307 $weather->show_bubble = false;308 $weather->user_provided = true; 309 310 unset($atts[‘geotriggered’]);311 }312 else if( $weather->user_location )313 {314 // IF USER SUBMITTED315 316 $weather->location = $weather->user_location;317 $weather->latlng = awe_get_latlng( $weather->user_location );318319 if( $weather->latlng )320 {321 $weather->owm_city_id = 0;322 setcookie('awe_latlng’, $weather->latlng, time() + apply_filters( 'awesome_weather_latlon_cache’, 31104000 ), '/’, $_SERVER[‘HTTP_HOST’], is_ssl() ? true: false );323 324 $weather->units = 'auto’;325 $weather->show_bubble = false;326 $weather->user_provided = true; 327 }328 }329 else if( isset($_COOKIE[‘awe_latlng’]) AND $_COOKIE[‘awe_latlng’] )330 {331 $weather->units = 'auto’;332 $weather->owm_city_id = 0;333 $weather->latlng = $_COOKIE[‘awe_latlng’];334 $weather->show_bubble = false;335 $weather->user_provided = true;336 }337 }338 339 // IF NO WEATHER FROM USER, AND WITH CAN USE THE IP340 if( !$weather->user_provided AND $weather->use_user_location )341 {342 $ll_from_ip = awe_latlng_from_ip();343 344 if( $ll_from_ip )345 {346 $weather->units = 'auto’;347 $weather->owm_city_id = 0;348 $weather->latlng = $ll_from_ip; 349 $weather->location = false;350 $weather->user_provided = true;351 } 352 }353 354 355 // FILTER TO SHOW OR HIDE THE CHANGE YOUR WEATHER BUBBLE356 $weather->show_bubble = apply_filters('awesome_weather_show_bubble’, $weather->show_bubble, $weather );357 358 // DEFAULT SETTINGS359 if( !$weather->id ) awe_widget_id( $weather, true );360361 // WEATHER DATA362 $weather->data = apply_filters( 'awesome_weather_data’, $weather->data, $weather);363 if( !$weather->data )364 {365 // SET THE WEATHER DATA366 if( $weather->provider == ‘darksky’ )367 {368 $weather->data = awesome_weather_get_weather_data_darksky( $weather );369 }370 else371 {372 $weather->data = awesome_weather_get_weather_data_openweathermaps( $weather );373 }374375 // IF ERROR, DISPLAY376 if( isset($weather->data[‘error’]) AND $weather->data[‘error’] )377 {378 $weather->error = $weather->data[‘msg’];379 }380 }381 382 // IF USER INITIATED THE WEATHER, GET NEW OVERRIDE TITLE383 if( $weather->user_provided AND isset($weather->data[‘name’]) ) $weather->override_title = $weather->data[‘name’];384385386 // BACKGROUND COLORS387 if( $weather->background_color )388 {389 if( substr(trim($weather->background_color), 0, 1) != ‘#’ AND substr(trim(strtolower($weather->background_color)), 0, 3) != ‘rgb’ AND $weather->background_color != ‘transparent’ ) { $weather->background_color = ‘#’ . $weather->background_color; }390 $weather->inline_style .= " background-color: {$weather->background_color};";391 $weather->background_classes[] = 'custom-bg-color’;392 }393 else if( isset($weather->data[‘current’]) )394 {395 // COLOR OF WIDGET396 $today_temp = $weather->data[‘current’][‘temp’];397 if( strtolower($weather->units) == ‘f’ OR strtolower($weather->units) == ‘us’ )398 {399 if($today_temp < 31) $weather->background_classes[] = 'temp1’;400 if($today_temp > 31 AND $today_temp < 40) $weather->background_classes[] = 'temp2’;401 if($today_temp >= 40 AND $today_temp < 50) $weather->background_classes[] = 'temp3’;402 if($today_temp >= 50 AND $today_temp < 60) $weather->background_classes[] = 'temp4’;403 if($today_temp >= 60 AND $today_temp < 80) $weather->background_classes[] = 'temp5’;404 if($today_temp >= 80 AND $today_temp < 90) $weather->background_classes[] = 'temp6’;405 if($today_temp >= 90) $weather->background_classes[] = 'temp7’;406 }407 else408 {409 if($today_temp < 1) $weather->background_classes[] = 'temp1’;410 if($today_temp > 1 AND $today_temp < 4) $weather->background_classes[] = 'temp2’;411 if($today_temp >= 4 AND $today_temp < 10) $weather->background_classes[] = 'temp3’;412 if($today_temp >= 10 AND $today_temp < 15) $weather->background_classes[] = 'temp4’;413 if($today_temp >= 15 AND $today_temp < 26) $weather->background_classes[] = 'temp5’;414 if($today_temp >= 26 AND $today_temp < 32) $weather->background_classes[] = 'temp6’;415 if($today_temp >= 32) $weather->background_classes[] = 'temp7’;416 }417 }418419 // HEADER TITLE420 $header_title = $weather->location;421422 // IF NOT LOCATION, GET FROM WEATHER DATA423 if( !$weather->location AND isset($weather->data[‘name’]) ) $header_title = $weather->data[‘name’];424425 // OVERRIDE TITLE TAKES THE CAKE426 if( $weather->override_title ) $header_title = $weather->override_title;427428 // BACKGROUND CLASSES429 $weather->background_classes[] = 'awesome-weather-wrap’;430 $weather->background_classes[] = 'awecf’;431 $weather->background_classes[] = ($weather->show_stats) ? ‘awe_with_stats’ : 'awe_without_stats’;432 $weather->background_classes[] = ($weather->show_icons) ? ‘awe_with_icons’ : 'awe_without_icons’;433 $weather->background_classes[] = ($weather->forecast_days == ‘hide’) ? ‘awe_without_forecast’ : 'awe_with_forecast’;434 $weather->background_classes[] = ($weather->extended_url) ? ‘awe_extended’ : '’;435 $weather->background_classes[] = ‘awe_’ . $weather->template;436 if( $weather->owm_city_id ) $weather->background_classes[] = 'awe-cityid-' . $weather->owm_city_id;437 438 439 // BACKGROUND IMAGE, ADD DARKEN CLASS440 if( $weather->background_image ) $weather->background_classes[] = 'darken’;441 if( $weather->allow_user_to_change ) $weather->background_classes[] = 'awe_changeable’;442443 444 // WEATHER CONDITION CSS445 $weather_code = $weather_description_slug = '’; 446 if( isset($weather->data[‘current’]) )447 {448 $weather_code = $weather->data[‘current’][‘condition_code’];449 $weather_description_slug = sanitize_title( $weather->data[‘current’][‘description’] );450 451 $weather->background_classes[] = 'awe-code-' . $weather_code;452 $weather->background_classes[] = 'awe-desc-' . sanitize_title( $weather_description_slug );453 }454 455 456 // CHECK FOR BACKGROUND BY WEATHER457 if( $weather->background_by_weather AND ( $weather_code OR $weather_description_slug ) )458 {459 // DEFAULTS460 $bg_img_names = array();461 $bg_ext = $weather->background_by_weather_ext;462 $bg_img_location = new stdclass;463 $bg_img_location->dir = get_stylesheet_directory() . '/awe-backgrounds/’;464 $bg_img_location->uri = trailingslashit(get_stylesheet_directory_uri()) . 'awe-backgrounds/’;465 466 // NAMES TO CHECK FOR467 if( $weather_code ) $bg_img_names[] = $weather_code . ‘.’ . $bg_ext;468 if( $weather_description_slug ) $bg_img_names[] = $weather_description_slug . ‘.’ . $bg_ext;469 470 // CUSTOM LOCATION471 $custom_template_location = apply_filters('awesome_weather_background_images_location’, false ); 472 if( $custom_template_location ) $bg_img_location = $custom_template_location;473474475 // CHECK FOR awesome-weather-bgs476 if( file_exists( dirname(__FILE__) . ‘/…/awesome-weather-bgs/awe-backgrounds/’) )477 {478 foreach( $bg_img_names as $bg_img_name )479 {480 if( file_exists( dirname(__FILE__) . ‘/…/awesome-weather-bgs/awe-backgrounds/’ . $bg_img_name) )481 {482 $weather->background_image = trailingslashit(plugins_url()) . ‘awesome-weather-bgs/awe-backgrounds/’ . $bg_img_name;483 break;484 }485 }486 }487 else if( file_exists($bg_img_location->dir) )488 {489 foreach( $bg_img_names as $bg_img_name )490 {491 if( file_exists( $bg_img_location->dir . $bg_img_name) )492 {493 $weather->background_image = $bg_img_location->uri . $bg_img_name;494 break;495 }496 }497 }498499 // USE DEFAULT BACKGROUND IMAGES500 if( !$weather->background_image )501 {502 if( $weather->provider == ‘darksky’ )503 {504 $preset_background_img_name = awesome_weather_preset_condition_names_darksky($weather_code);505 }506 else507 {508 $preset_background_img_name = awesome_weather_preset_condition_names_openweathermaps($weather_code);509 }510 511 if( $preset_background_img_name )512 {513 $weather->background_classes[] = 'awe-preset-' . $preset_background_img_name;514 if( file_exists( trailingslashit(dirname(__FILE__)) . ‘img/awe-backgrounds/’ . $preset_background_img_name . ‘.’ . $bg_ext) ) $weather->background_image = trailingslashit(AWESOME_WEATHER_PLUGIN_BASE) . ‘img/awe-backgrounds/’ . $preset_background_img_name . ‘.’ . $bg_ext;515 }516 }517 }518 519 // TEXT COLOR520 if( substr(trim($weather->text_color), 0, 1) != ‘#’ ) $weather->text_color = ‘#’ . $weather->text_color;521 if( $weather->text_color ) $weather->inline_style .= " color: {$weather->text_color}; ";522 523 524 // PREP INLINE STYLE525 $inline_style = "";526 if($weather->inline_style != ‘’) { $inline_style = " style=\"{$weather->inline_style}\""; }527 528 529 // PREP BACKGROUND CLASSES530 $background_classes = @implode( ' ', apply_filters( 'awesome_weather_background_classes’, $weather->background_classes ));531 532 533 // CREATE SHORT VARIABLES TO WORK WITH IN TEMPLATES534 $weather_forecast = array();535 if( isset($weather->data[‘forecast’]) ) $weather_forecast = (array) $weather->data[‘forecast’];536 537 538 // GET TEMPLATE 539 ob_start();540 541 // IF WE HAVE AN ERROR542 if( $weather->error ) return awesome_weather_error($weather->error);543 544 545 // IF USER CAN CHANGE, SET JSON OBJECT OF WEATHER546 if( $weather->allow_user_to_change AND !isset($atts[‘via_ajax’]) )547 {548 $json = clone $weather;549 $json->action = 'awesome_weather_refresh’;550 $json->user_location = '0’;551 $json->via_ajax = '1’;552 $json->data = false; 553 $json->ajaxurl = admin_url(‘admin-ajax.php’);554 echo "<script type=\"text/javascript\">555 if( typeof awe == ‘undefined’) { var awe = []; }556 awe[‘awe_weather_widget_json_{$weather->id}’] = " . json_encode($json) . ";557 </script>";558 }559 560 // GET TEMPLATE561 if( $weather->template == ‘custom’ OR !isset($awesome_weather_sizes[$weather->template]))562 {563 // GET CUSTOM TEMPLATE564 $template = locate_template( array( 'awe-' . $weather->template . ‘.php’ ) );565 566 $user_defined_template_location = apply_filters('awesome_weather_custom_template_location’, false);567568 if( $user_defined_template_location )569 {570 include( trailingslashit($user_defined_template_location) . 'awe-' . $weather->template . ‘.php’ );571 }572 else if( $template )573 {574 include( $template );575 }576 else577 {578 echo awesome_weather_error( __('Custom template file not found. Please add a file to your theme folder with this name:’, ‘awesome-weather’ ) . ' <span style="text-transform: lowercase">awe-' . $weather->template . ‘.php</span>’ ); 579 }580 }581 else582 {583 $awe_weather_template = dirname(__FILE__) . ‘/templates/’ . $weather->template . '.php’;584 585 if( file_exists( $awe_weather_template ) )586 {587 include( $awe_weather_template );588 }589 else590 {591 echo awesome_weather_error( __('Weather template not found:’, ‘awesome-weather’) . ' ' . $weather->template );592 }593 }594 595 // END 596 $output = ob_get_contents();597 ob_end_clean();598 return $output;599}600601602// RETURN ERROR603function awesome_weather_error( $msg = false )604{605 $error_handling = get_option( ‘aw-error-handling’ );606 if(!$error_handling) $error_handling = 'source’;607 if(!$msg) $msg = __('No weather information available’, ‘awesome-weather’);608 609 if( $error_handling == ‘display-admin’)610 {611 // DISPLAY ADMIN612 if ( current_user_can( ‘manage_options’ ) ) 613 {614 return “<div class=’awesome-weather-error’>” . $msg . "</div>";615 }616 }617 else if( $error_handling == ‘display-all’)618 {619 // DISPLAY ALL620 return “<div class=’awesome-weather-error’>” . $msg . "</div>";621 }622 else623 {624 return apply_filters( 'awesome_weather_error’, “<!-- awesome-weather-error: " . $msg . " -->” );625 }626}627628629// ENQUEUE ADMIN SCRIPTS630function awesome_weather_admin_scripts( $hook )631{632 if( ‘widgets.php’ != $hook ) return;633 634 wp_enqueue_style(‘jquery’);635 wp_enqueue_style(‘underscore’);636 wp_enqueue_script('awesome_weather_admin_script’, plugin_dir_url( __FILE__ ) . '/js/awesome-weather-widget-admin.js’, array('jquery’, ‘underscore’) );637 wp_enqueue_style(‘wp-color-picker’);638 wp_enqueue_script(‘wp-color-picker’);639 640 wp_localize_script( 'awesome_weather_admin_script’, 'awe_script’, array(641 ‘no_owm_city’ => esc_attr(__('No city found in OpenWeatherMap.’, ‘awesome-weather’)),642 ‘one_city_found’ => esc_attr(__('Only one location found. The ID has been set automatically above.’, ‘awesome-weather’)),643 ‘confirm_city’ => esc_attr(__('Please confirm your city:’, ‘awesome-weather’))644 )645 );646}647add_action( 'admin_enqueue_scripts’, ‘awesome_weather_admin_scripts’ );648649650651// WIDGET CODE652require_once(dirname(__FILE__) . ‘/widget.php’);653654655656// CREATE WIDGET ID657function awe_widget_id_new( $atts )658{659 $w = $atts;660 return awe_widget_id( $w, true );661}662663664function awe_widget_id( &$weather, $rtn = false )665{666 // SANITIZE667 if( !is_object($weather) ) $weather = (object) $weather;668 if( !isset($weather->id) ) $weather->id = false;669 670 // IF WE HAVE A LATLNG, USE IT671 if( !$weather->id AND isset($weather->latlng) AND $weather->latlng != ‘’ ) $weather->id = 'awesome-weather-' . sanitize_title( $weather->latlng );672673674 // USE LOCATION675 if( !$weather->id AND isset($weather->location) AND $weather->location != ‘’ ) $weather->id = 'awesome-weather-' . sanitize_title( $weather->location );676677678 // USE owm_city_id679 if( !$weather->id AND isset($weather->owm_city_id) AND $weather->owm_city_id != ‘’ ) $weather->id = 'awesome-weather-' . $weather->owm_city_id;680681682 // CREATE RANDOM683 if( !$weather->id ) $weather->id = 'awesome-weather-' . uniqid();684 685686 // FILTER TO DO WHATEVER687 $weather->id = apply_filters('awesome_weather_widget_id’, $weather->id, $weather);688 689 690 // RETURN DATA OR ECHO691 if( $rtn ) return $weather->id;692 else echo $weather->id;693}694695696// GET APPID697function awe_get_appid()698{699 return trim(defined(‘AWESOME_WEATHER_APPID’) ? AWESOME_WEATHER_APPID : get_option( ‘open-weather-key’ ));700}701702// GET DARKSKY KEY703function awe_get_darksky_key()704{705 return trim(defined(‘AWESOME_WEATHER_DARKSKY_KEY’) ? AWESOME_WEATHER_DARKSKY_KEY : get_option( ‘darksky-secret-key’ ));706}707708// GET IPINFO TOKEN709function awe_get_ipinfo_token()710{711 return trim(defined(‘IPINFO_TOKEN’) ? IPINFO_TOKEN : get_option( ‘ipinfo-token’ ));712}713714// GET LOCATIONIQ TOKEN715function awe_get_locationiq_token()716{717 return trim(defined(‘AWESOME_WEATHER_LOCATIONIQ_TOKEN’) ? AWESOME_WEATHER_LOCATIONIQ_TOKEN : get_option( ‘location-iq-token’ ));718}719720721722// PING OPENWEATHER FOR OWMID723add_action( 'wp_ajax_awe_ping_owm_for_id’, ‘awe_ping_owm_for_id’);724add_action( 'wp_ajax_nopriv_awe_ping_owm_for_id’, ‘awe_ping_owm_for_id’);725function awe_ping_owm_for_id( )726{727 $appid_string = '’;728 $appid = awe_get_appid();729 if( $appid ) $appid_string = ‘&APPID=’ . $appid;730731 $location = urlencode($_GET[‘location’]);732 $units = strtoupper($_GET[‘location’]) == ‘C’ ? ‘metric’ : 'imperial’;733 $owm_ping = AWESOME_WEATHER_OWM_API_URL . ‘find?q=’ . $location . ‘&units=’ . $units . ‘&mode=json’ . $appid_string;734 $owm_ping_get = wp_remote_get( $owm_ping );735 echo $owm_ping_get[‘body’];736 die;737}738739function awe_ping_owm_first_results( $location, $units )740{741 $appid_string = '’;742 $appid = awe_get_appid();743 if( $appid ) $appid_string = ‘&APPID=’ . $appid; 744 745 $owm_ping = AWESOME_WEATHER_OWM_API_URL . ‘find?q=’ . urlencode($location) . ‘&units=’ . $units . ‘&mode=json’ . $appid_string;746 $owm_ping_get = wp_remote_get( $owm_ping );747 $body = json_decode($owm_ping_get[‘body’]);748749 if( isset($body->list) AND isset($body->list[0]) )750 {751 return $body->list[0];752 }753 754 return false;755}756757add_action( 'wp_ajax_awe_get_latlng_ajax’, ‘awe_get_latlng_ajax’);758add_action( 'wp_ajax_nopriv_awe_get_latlng_ajax’, ‘awe_get_latlng_ajax’ );759function awe_get_latlng_ajax()760{761 $location_iq_token = awe_get_locationiq_token();762 $owm_appid = awe_get_appid();763 764 header(“Content-Type: application/json”);765766 // NO METHOD OF LOOKUP767 if( !$location_iq_token AND !$owm_appid )768 {769 echo json_encode(array( ‘error’ => __('No method of lookup available. Please enter an OpenWeatherMap APPID or LocationIQ Token in the Settings.’, ‘awesome-weather’), ‘latlng’ => ‘’ ));770 die;771 }772 773 if( isset($_GET[‘location’]) )774 {775 $latlng = awe_get_latlng( $_GET[‘location’] );776 if( $latlng )777 {778 echo json_encode(array( ‘error’ => '’, ‘latlng’ => $latlng ));779 die;780 }781 else782 {783 echo json_encode(array( ‘error’ => __('Location could not be geocoded.’, ‘awesome-weather’), ‘latlng’ => ‘’ ));784 die;785 }786 }787 788 echo json_encode(array( ‘error’ => '’, ‘latlng’ => 0 ));789 die;790}791792793// GET LAT LONG FROM TEXT794function awe_get_latlng( $text )795{796 $location_iq_token = awe_get_locationiq_token();797 $owm_appid = awe_get_appid();798 $location_transient = ‘awe_location_’ . sanitize_title($text);799 800 // USER LOCATION IQ801 if( $location_iq_token ) 802 {803 // CHECK FOR CLEAR804 if( isset($_GET[‘clear_awesome_widget’]) ) delete_transient( $location_transient );805 806 // GET CACHED FIRST807 if( get_transient($location_transient) )808 {809 return get_transient($location_transient);810 }811 else812 {813 // PING FOR NEW814 $ping_url = AWESOME_WEATHER_LOCATIONIQ_API_URL . ‘search.php?key=’ . $location_iq_token . ‘&q=’ . urlencode($text) . '&format=json’;815 $lq_ping = wp_remote_get( $ping_url );816 817 if( is_wp_error( $lq_ping ) ) return false;818 $places = json_decode( $lq_ping[‘body’] );819 if( $places AND is_array($places) )820 {821 $l = reset($places);822 if( isset($l->lat) AND isset($l->lon) )823 {824 set_transient( $location_transient, $l->lat . ‘,’ . $l->lon, apply_filters( 'awesome_weather_latlon_cache’, 31104000 ) );825 return $l->lat . ‘,’ . $l->lon;826 }827 } 828 }829 }830 else if ( $owm_appid )831 {832 // CHECK FOR CLEAR833 if( isset($_GET[‘clear_awesome_widget’]) ) delete_transient( $location_transient );834 835 // GET CACHED FIRST836 if( get_transient($location_transient) )837 {838 return get_transient($location_transient);839 }840 else841 {842 // USE OPEN WEATHER MAP843 $first_city = awe_ping_owm_first_results( $text, $units );844 if( $first_city AND isset($first_city->coord) )845 {846 if( isset($first_city->coord->lat) AND isset($first_city->coord->lon) )847 {848 set_transient( $location_transient, $first_city->coord->lat . ‘,’ . $first_city->coord->lon, apply_filters( 'awesome_weather_latlon_cache’, 31104000 ) );849 return $first_city->coord->lat . ‘,’ . $first_city->coord->lon;850 }851 }852 }853 }854 855 return false;856}857858859860// GET CITY ID BY LOCATION861function awe_get_location_city_id( $weather, $return = ‘id’ )862{863 $local = awe_ping_owm_first_results( $weather->location, $weather->units );864 if( isset($local->id) ) return (int) $local->id;865 return false;866}867868869// GET CITY ID BY LONG LAT870function awe_get_long_lat_city_id( $weather, $what_to_get = ‘id’ )871{872 $transient_name = ‘awe_ll_owm’ . $what_to_get . str_replace('-', '’, sanitize_title( $weather->latlng ));873 874 // CLEAR IF URL875 if( isset($_GET[‘clear_awesome_widget’]) ) delete_transient( $transient_name );876 if( get_transient( $transient_name ) )877 {878 return get_transient( $transient_name );879 }880 881 $appid_string = '’;882 $appid = awe_get_appid();883 if($appid) $appid_string = ‘&APPID=’ . $appid; 884 885 $lat_lon = explode(',’, $weather->latlng);886 $api_query = ‘lat=’ . $lat_lon[0] . ‘&lon=’ . $lat_lon[1];887 $longlat_ping_url = AWESOME_WEATHER_OWM_API_URL . ‘weather?’ . $api_query . $appid_string;888 $longlat_ping_get = wp_remote_get( $longlat_ping_url );889 890 if( !is_wp_error( $longlat_ping_get ) AND isset($longlat_ping_get[‘body’]) AND $longlat_ping_get[‘body’] != ‘’ ) 891 {892 $ping_data = json_decode( $longlat_ping_get[‘body’] );893 if( $ping_data AND isset($ping_data->id) AND $ping_data->id )894 {895 if( $what_to_get == ‘id’ )896 {897 set_transient( $transient_name, $ping_data->id, apply_filters( 'awesome_weather_latlon_cache’, 31104000 ) );898 return $ping_data->id;899 }900 else901 {902 set_transient( $transient_name, $ping_data, apply_filters( ‘awesome_weather_latlon_cache’, 31104000 ) );903 return $ping_data;904 }905 }906 }907908 return false;909}910911function awe_ip_check() 912{913 // USE EXACTLY ONE914 if( isset($weather->use_real_ip) )915 {916 return $_SERVER[‘HTTP_X_REAL_IP’];917 }918 if( isset($weather->use_x_forwarded) )919 {920 return $_SERVER[‘HTTP_X_FORWARDED_FOR’];921 }922 923 // USE OTHER STUFF 924 if( getenv(‘HTTP_X_FORWARDED_FOR’) ) 925 {926 $ip = getenv(‘HTTP_X_FORWARDED_FOR’);927 }928 else if( getenv(‘HTTP_X_REAL_IP’) ) 929 {930 $ip = getenv(‘HTTP_X_REAL_IP’);931 }932 else 933 {934 $ip = $_SERVER[‘REMOTE_ADDR’];935 }936 937 // TESTING938 //$ip = "68.12.196.42"; // OKC939 //$ip = “185.18.188.0"; // NYC940 //$ip = “192.99.128.170"; // MTL941 942 return $ip;943}944945// GET CITY ID FROM IP946function awe_latlng_from_ip()947{948 $ip = awe_ip_check();949 $ip_hash = str_replace('.’, '’, $ip);950 $ip_transient_name = ‘awe_ip_ll’ . $ip_hash;951952 // CLEAR CACHE953 if( isset($_GET[‘clear_awesome_widget’]) ) delete_transient( $ip_transient_name );954 if( get_transient( $ip_transient_name ) )955 {956 return get_transient( $ip_transient_name );957 }958 959 $location_ping_url = str_replace('[[IP]]', $ip, apply_filters( 'awesome_weather_location_lookup_url’, AWESOME_WEATHER_LOOKUP_URL ) );960 961 // CHECK FOR IPINFO TOKEN962 $ipinfo_token = awe_get_ipinfo_token();963 if( $ipinfo_token ) $location_ping_url .= ‘/?token=’ . $ipinfo_token; 964 965 // GET LOCATION966 $location_ping_get = wp_remote_get( $location_ping_url );967 if( !is_wp_error( $location_ping_get ) AND isset($location_ping_get[‘body’]) AND $location_ping_get[‘body’] != ‘’ ) 968 { 969 $ping_data = json_decode( apply_filters('awesome_weather_ip_ping_data’, $location_ping_get[‘body’]) );970 971 if( isset($ping_data->loc) AND $ping_data->loc != ‘’ )972 {973 set_transient( $ip_transient_name, $ping_data->loc, apply_filters( 'awesome_weather_ip_cache’, 15552000 ) );974 return $ping_data->loc;975 }976 }977 978 return false;979}980981982// GET UNITS FROM CITY ID983function awe_get_units( &$weather )984{985 // COUNTRIES THAT DEFAULT TO fahrenheit986 $f_countries_abbr = apply_filters( 'awesome_weather_f_countries_abbr’, array(‘US’,’BZ’,’BS’,’CY’,’PR’,’GU’) );987 $f_countries_names = apply_filters( 'awesome_weather_f_countries_names’, array( 'United States’, 'Belize’, 'Bahamas’, 'Cayman Islands’, 'Puerto Rico’, ‘Guam’) );988 989 990 // TRANSIENT NAME991 if( isset($weather->owm_city_id) AND $weather->owm_city_id )992 {993 // CITY ID994 $transient_name = ‘awe_cu_’ . $weather->provider . ‘_’ . $weather->owm_city_id;995 $api_query = ‘id=’ . $weather->owm_city_id;996 }997 else if( isset($weather->latlng) )998 {999 // LATLONG1000 $latlng = awesome_weather_parse_lat_lon( $weather->latlng );1001 1002 $transient_name = ‘awe_cu_’ . $weather->provider . ‘_’ . sanitize_title($weather->latlng);1003 $api_query = ‘lat=’ . $latlng->lat . ‘&lon=’ . $latlng->lng;1004 }1005 else1006 {1007 return false;1008 }100910101011 // CLEAR CACHE1012 if( isset($_GET[‘clear_awesome_widget’]) ) delete_transient( $transient_name );101310141015 // CHECK TRANSIENT1016 if( get_transient( $transient_name ) ) 1017 {1018 $cached_units = get_transient( $transient_name );1019 $weather->units = $cached_units;1020 return $cached_units;1021 }1022 1023 // GET UNITS1024 $cached_obj = new stdclass;1025 $appid_string = '’;1026 $appid = awe_get_appid();1027 if($appid) $appid_string = ‘&APPID=’ . $appid; 1028 1029 $ping = AWESOME_WEATHER_OWM_API_URL . ‘weather?’ . $api_query . ‘&lang=en’ . $appid_string;1030 $ping_get = wp_remote_get( $ping );10311032 if( !is_wp_error( $ping_get ) AND isset($ping_get[‘body’]) AND $ping_get[‘body’] != ‘’ ) 1033 {1034 $ping_data = json_decode( $ping_get[‘body’] );1035 if( isset($ping_data->sys) AND isset($ping_data->sys->country) )1036 {1037 if( in_array( $ping_data->sys->country, $f_countries_abbr ) )1038 {1039 $weather->units = $cached_obj->units = 'F’;1040 }1041 else1042 {1043 $weather->units = $cached_obj->units = 'C’;1044 }1045 }1046 }1047 1048 if( isset($cached_obj->units) )1049 {1050 set_transient( $transient_name, $cached_obj->units, apply_filters( 'awesome_weather_result_auto_units_cache’, 31104000 ) );1051 return $cached_obj->units;1052 }10531054 return false;1055}1056105710581059// CONVERSIONS1060function awe_c_to_f( $c )1061{1062 return round( ( $c * 1.8 ) + 32);1063}10641065function awe_f_to_c( $f )1066{1067 return round(($f- 32) / 1.8);1068}106910701071// CHANGE WEATHER FORM1072function awe_change_weather_form( $weather )1073{1074 if( ! $weather->allow_user_to_change ) return '’;1075 1076 $template = locate_template( array( ‘awesome-weather-form.php’ ) );1077 if( $template )1078 {1079 include( $template );1080 }1081 else1082 {1083 include( dirname(__FILE__) . ‘/awesome-weather-form.php’ );1084 }1085}10861087function awe_change_weather_trigger( $weather )1088{1089 if( !$weather->allow_user_to_change ) return '’;1090 1091 $template = locate_template( array( ‘awesome-weather-trigger.php’ ) );1092 if($template)1093 {1094 include( $template );1095 }1096 else1097 {1098 include(dirname(__FILE__) . ‘/awesome-weather-trigger.php’ );1099 }1100}110111021103function awe_attribution( $weather )1104{1105 if( $weather->show_attribution === ‘false’ ) return '’;1106 else if( !$weather->show_attribution ) return '’;1107 1108 if( $weather->provider == ‘darksky’ )1109 {1110 $attr_text = '<a href="https://darksky.net/poweredby/” target="_blank">’;1111 $attr_text .= __('Powered by Dark Sky’, ‘awesome-weather’);1112 $attr_text .= '</a>’;1113 }1114 else1115 {1116 $attr_text = $weather->t->weather_from . ' OpenWeatherMap’;1117 }11181119 echo apply_filters( 'awesome_weather_attribution’, ‘<div class="awesome-weather-attribution">’ . $attr_text . ‘</div>’);1120}112111221123// EXTENDED LINK, CUSTOM TEMPLATE AVAILABLE1124function awe_extended_link( &$weather, $do_before = '’, $do_after = ‘’ )1125{1126 if( $weather->show_link AND !$weather->extended_url AND isset($weather->owm_city_id) AND $weather->owm_city_id != ‘’ )1127 {1128 $weather->extended_url = ‘https://openweathermap.org/city/’ . $weather->owm_city_id;1129 }11301131 if( !$weather->show_link ) return '’;1132 1133 // IF NOT EXTENDED FORECAST TEXT, SET DEFAULT1134 if( !$weather->extended_text ) $weather->extended_text = apply_filters(‘awesome_weather_extended_forecast_text’ , __('extended forecast’, ‘awesome-weather’));1135 1136 // ESCAPE THE WEATHER URL IF WE HAVE IT1137 if( $weather->extended_url ) $weather->extended_url = esc_url($weather->extended_url);1138 1139 1140 $template = locate_template( array( ‘awesome-weather-extended.php’ ) );1141 if( $template )1142 {1143 echo $do_before;1144 include( $template );1145 echo $do_after;1146 }1147 else if( $weather->extended_url OR $weather->extended_text ) 1148 { 1149 echo $do_before;1150 $extended_url_target = apply_filters('awesome_weather_extended_url_target’, ‘_blank’);1151 echo '<div class="awesome-weather-more-weather-link">’;1152 if( $weather->extended_url ) echo ‘<a href="’ . $weather->extended_url . '” target="’ . $extended_url_target . '">’;1153 echo $weather->extended_text;1154 if( $weather->extended_url ) echo '</a>’;1155 echo '</div>’;1156 echo $do_after;1157 }1158}11591160function awesome_weather_refresh()1161{1162 echo awesome_weather_logic( $_POST );1163 exit;1164}1165add_action( 'wp_ajax_awesome_weather_refresh’, ‘awesome_weather_refresh’ );1166add_action( 'wp_ajax_nopriv_awesome_weather_refresh’, ‘awesome_weather_refresh’ );1167116811691170// SETTINGS1171require_once(dirname(__FILE__) . ‘/awesome-weather-settings.php’);117211731174// GET CUSTOM WETHER TEMPLATES1175function awesome_weather_use_template( $template_name, $weather )1176{1177 // GET THE TEMPLATE1178 if( $weather->template != ‘custom’ )1179 {1180 $awe_weather_template = dirname(__FILE__) . ‘/templates/’ . $template_name . '.php’;1181 1182 if( file_exists( $awe_weather_template ) )1183 {1184 include( $awe_weather_template );1185 }1186 else1187 {1188 echo awesome_weather_error( __('Weather template not found:’, ‘awesome-weather’) . ' ' . $weather->template );1189 }1190 }1191 else1192 {1193 // GET CUSTOM TEMPLATE1194 $template = locate_template( array( “awe-{$template_name}.php” ) );1195 1196 $user_defined_template_location = apply_filters('awesome_weather_custom_template_location’, false);11971198 if( $user_defined_template_location )1199 {1200 include( trailingslashit($user_defined_template_location) . “awe-{$template_name}.php” );1201 }1202 else if( $template )1203 {1204 include( $template );1205 }1206 else1207 {1208 echo awesome_weather_error( __('Custom template file not found. Please add a file to your theme folder with this name:’, ‘awesome-weather’ ) . " awe-" . $template_name . “.php” ); 1209 }1210 }1211}12121213// LOCALES1214function awesome_weather_get_locales()1215{1216 return apply_filters('awesome_weather_available_locales’, array( 'en’, 'es’, 'sp’, 'fr’, 'it’, 'de’, 'pt’, 'ro’, 'pl’, 'ru’, 'uk’, 'ua’, 'fi’, 'nl’, 'bg’, 'sv’, 'se’, 'sk’, 'ca’, 'tr’, 'hr’, 'zh’, 'zh_tw’, 'zh_cn’, ‘hu’ ) ); 1217}121812191220function awesome_weather_prep_location( $text ) 1221{ 1222 $text = stripslashes( $text );1223 $text = str_replace( array("\xe2\x80\x98", "\xe2\x80\x99", "\xe2\x80\x9c", "\xe2\x80\x9d", "\xe2\x80\x93", "\xe2\x80\x94", “\xe2\x80\xa6”), array("’", "’", '’, '’, '-', '–’, ‘…’), $text);1224 $text = str_replace( array(chr(145), chr(146), chr(147), chr(148), chr(150), chr(151), chr(133)), array("’", "’", '’, '’, '-', '–’, ‘…’), $text);1225 return $text;1226} 12271228function awesome_weather_parse_lat_lon( $latlng )1229{1230 $p = explode(',’, $latlng);1231 $rtn = new stdclass;1232 $rtn->lat = isset($p[0]) ? $p[0] : false;1233 $rtn->lng = isset($p[1]) ? $p[1] : false;1234 $rtn->text = $latlng;1235 return $rtn;1236}123712381239function awesome_weather_get_default_provider()1240{1241 if( defined(‘AWESOME_WEATHER_PROVIDER’) )1242 {1243 return AWESOME_WEATHER_PROVIDER;1244 }1245 else if ( get_option( ‘awe-weather-provider’ ) )1246 {1247 return get_option( ‘awe-weather-provider’ );1248 }1249 else 1250 {1251 return 'openweathermaps’;1252 }1253}

CVE: Latest News

CVE-2023-50976: Transactions API Authorization by oleiman · Pull Request #14969 · redpanda-data/redpanda
CVE-2023-6905
CVE-2023-6903
CVE-2023-6904
CVE-2023-3907