PluginProbe
wp-forecast / 9.6
wp-forecast v9.6
10.0 trunk 1.4 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3..5 3..8 3.0 3.1 3.2 3.3 3.4 3.6 All 86 releases
← All changes | wp-forecast-admin.php +1449 -655 2.0 → 9.6 View file →
@@ -1,731 +1,1525 @@
1 1 <?php
2 -/* This file is part of the wp-forecast plugin for wordpress */
2 +/** This file is part of the wp-forecast plugin for WordPress
3 + *
4 + * Copyright 2006-2024 Hans Matzen (email : webmaster at tuxlog dot de)
5 + *
6 + * This program is free software; you can redistribute it and/or modify
7 + * it under the terms of the GNU General Public License as published by
8 + * the Free Software Foundation; either version 2 of the License, or
9 + * (at your option) any later version.
10 + *
11 + * This program is distributed in the hope that it will be useful,
12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 + * GNU General Public License for more details.
15 + *
16 + * You should have received a copy of the GNU General Public License
17 + * along with this program; if not, write to the Free Software
18 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 + *
20 + * @package wp-forecast
21 + */
3 22
4 -/* Copyright 2006,2007 Hans Matzen (email : webmaster at tuxlog.de)
23 +/** Location array and counter init. */
24 +$loc = array();
25 +$i = 0;
5 26
6 - This program is free software; you can redistribute it and/or modify
7 - it under the terms of the GNU General Public License as published by
8 - the Free Software Foundation; either version 2 of the License, or
9 - (at your option) any later version.
27 +// generic functions.
28 +require_once 'funclib.php';
29 +require_once 'func-openweathermap.php';
30 +require_once 'func-openweathermap-v2.php';
31 +require_once 'func-openmeteo.php';
32 +require_once 'supp/supp.php';
10 33
11 - This program is distributed in the hope that it will be useful,
12 - but WITHOUT ANY WARRANTY; without even the implied warranty of
13 - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 - GNU General Public License for more details.
34 +/**
35 + * Delete cache if parameters are changed, to make sure
36 + * current data will be available with next call.
37 + */
38 +function wp_forecast_admin_init() {
39 + $count = wpf_get_option( 'wp-forecast-count' );
15 40
16 - You should have received a copy of the GNU General Public License
17 - along with this program; if not, write to the Free Software
18 - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 -*/
41 + // Query arguments.
42 + $wpfqs = '';
43 + if ( isset( $_SERVER['QUERY_STRING'] ) ) {
44 + $wpfqs = sanitize_text_field( wp_unslash( $_SERVER['QUERY_STRING'] ) );
45 + }
20 46
47 + if ( ( 'page=wp-forecast-admin.php' == $wpfqs ) && ( isset( $_SERVER['REQUEST_METHOD'] ) && 'POST' === $_SERVER['REQUEST_METHOD'] ) ) {
48 + for ( $i = 0;$i < $count;$i++ ) {
49 + $wpfcid = get_widget_id( $i );
21 50
22 -// location array and counter init
23 -$loc=array();
24 -$i=0;
51 + // delete cache for old location.
52 + wpf_update_option( 'wp-forecast-expire' . $wpfcid, '0' );
53 + wpf_update_option( 'wp-forecast-cache' . $wpfcid, '' );
54 + }
55 + }
25 56
26 -// generic functions
27 -require_once("funclib.php");
57 + // add thickbox and jquery for checklist.
58 + wp_enqueue_script( 'thickbox' );
59 + wp_enqueue_style( 'thickbox' );
28 60
29 -//
30 -// delete cache if parameters are changed, to make sure
31 -// current data will be available with next call
32 -//
33 -function wp_forecast_admin_init()
34 -{
35 - global $wpf_debug;
61 + wp_localize_script( 'wpf_search', 'wpf_search', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
62 + add_action( 'wp_ajax_nopriv_wpf_search_ajax', 'wpf_search_ajax' );
63 + add_action( 'wp_ajax_wpf_search_ajax', 'wpf_search_ajax' );
64 + add_action( 'wp_ajax_nopriv_wpf_check_ajax', 'wpf_check_ajax' );
65 + add_action( 'wp_ajax_wpf_check_ajax', 'wpf_check_ajax' );
36 66
37 - if ($wpf_debug > 0)
38 - pdebug("Start of wp_forecast_admin_init ()");
39 -
40 - $count = get_option('wp-forecast-count');
67 + // add admin notice concerning the problems with accuweather.
68 + add_action( 'admin_notices', 'wpf_accuweather_problem_notice' );
69 +}
41 70
42 - if ( ($_SERVER['QUERY_STRING']=="page=wp-forecast-admin.php") &&
43 - (isset($_POST['info_update']) ))
44 - {
45 - for ($i=0;$i<$count;$i++) {
46 - $wpfcid = get_widget_id( $i );
47 -
48 - // delete cache for old location
49 - update_option("wp-forecast-expire".$wpfcid,"0");
50 - }
51 - }
71 +/**
72 + * Ajax funktion fuer die suche im admin dialog.
73 + */
74 +function wpf_search_ajax() {
75 + // check nonce3.
76 + if ( ! isset( $_POST['wpf_nonce_3'] ) ) {
77 + die( "<br><br>Looks like you didn't send any credentials. Please reload the page. " );
78 + }
79 + if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['wpf_nonce_3'] ) ), 'wpf_nonce_3' ) ) {
80 + die( "<br><br>Looks like you didn't send any credentials. Please reload the page. " );
81 + }
52 82
53 - if ($wpf_debug > 0)
54 - pdebug("End of wp_forecast_admin_init ()");
83 + $wpf_vars = get_wpf_opts( ( isset( $_POST['wpfcid'] ) ? sanitize_text_field( wp_unslash( $_POST['wpfcid'] ) ) : 'A' ) );
84 + $av = $wpf_vars;
85 + $locale = $wpf_vars['wpf_language'];
86 +
87 + // get translations.
88 + if ( function_exists( 'load_plugin_textdomain' ) ) {
89 + add_filter( 'plugin_locale', 'wpf_lplug', 10, 2 );
90 + load_plugin_textdomain( 'wp-forecast', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
91 + remove_filter( 'plugin_locale', 'wpf_lplug', 10, 2 );
92 + }
93 +
94 + $res = '';
95 + $res .= '<h2>' . esc_attr__( 'Searchresults', 'wp-forecast' ) . ':</h2>';
96 +
97 + if ( trim( ( isset( $_POST['searchterm'] ) ? sanitize_text_field( wp_unslash( $_POST['searchterm'] ) ) : '' ) ) == '' ) {
98 + $res .= '<p>' . esc_attr__( 'Please enter a non empty searchstring', 'wp-forecast' ) . '</p>';
99 + } else {
100 + $res .= '<p>' . esc_attr__( 'Please select a location', 'wp-forecast' ) . ':</p>';
101 +
102 + // search locations for openmeteo.
103 + $openmeteo_loc = get_loclist( $av['OPENMETEO_LOC_URI'], ( isset( $_POST['searchterm'] ) ? sanitize_text_field( wp_unslash( $_POST['searchterm'] ) ) : '' ) );
104 +
105 + $i = 0;
106 + // output searchresults.
107 + $res .= '<table border="1" ><thead><tr><th>';
108 + $res .= esc_attr__( 'Open-Meteo Hits', 'wp-forecast' );
109 + $res .= '</th></tr></thead><tbody>';
110 +
111 + $k = count( $openmeteo_loc );
112 + $i = 0;
113 +
114 + while ( $i < $k ) {
115 + $res .= '<tr>';
116 +
117 + $res .= '<td><a href="#" onclick="wpf_set_loc(\'' . addslashes( $openmeteo_loc[ $i ]['name'] ) . '\',' . $openmeteo_loc[ $i ]['latitude'] . ',' . $openmeteo_loc[ $i ]['longitude'] . ');" >';
118 + $res .= $openmeteo_loc[ $i ]['name'] . ', ' . ( isset( $openmeteo_loc[ $i ]['admin1'] ) ? $openmeteo_loc[ $i ]['admin1'] : '' ) . ' </a></td>';
119 + $res .= '</tr>';
120 + $i++;
121 + }
122 + $res .= '</tbody></table>';
123 + }
124 +
125 + echo wp_kses( $res, wpf_allowed_tags() );
126 + wp_die();
55 127 }
56 128
57 -//
58 -// add menuitem for options menu
59 -//
60 -function wp_forecast_admin()
61 -{
62 - global $wpf_debug;
129 +/**
130 + * Ajax funktion fuer den Verbindungstest im admin dialog.
131 + */
132 +function wpf_check_ajax() {
133 + $res = '';
63 134
64 - if ($wpf_debug > 0)
65 - pdebug("Start of wp_forecast_admin ()");
66 -
135 + // check nonce3.
136 + if ( ! isset( $_POST['wpf_nonce_3'] ) ) {
137 + die( "<br><br>Looks like you didn't send any credentials. Please reload the page. " );
138 + }
139 + if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['wpf_nonce_3'] ) ), 'wpf_nonce_3' ) ) {
140 + die( "<br><br>Looks like you didn't send any credentials. Please reload the page. " );
141 + }
67 142
68 - if (function_exists('add_options_page')) {
69 - add_options_page('WP-Forecast', 'WP-Forecast', 6,
70 - basename(__FILE__), 'wpf_admin_form');
71 - }
143 + /**
144 + * Check the URL $url.
145 + *
146 + * @param string $url The URL to check.
147 + */
148 + function check_url( $url ) {
149 + $erg = array();
72 150
73 - if ($wpf_debug > 0)
74 - pdebug("End of wp_forecast_admin ()");
75 -}
151 + $wprr_args = array(
152 + 'timeout' => 30,
153 + 'headers' => array(
154 + 'Connection' => 'Close',
155 + 'Accept' => '*/*',
156 + ),
157 + );
76 158
77 -//
78 -// print out hint for the widget control
79 -//
80 -function wpf_admin_hint($args = null)
81 -{
82 - global $wpf_debug;
83 -
84 - if ($wpf_debug > 0)
85 - pdebug("Start of wp_admin_hint ()");
159 + // use generic WordPress function to retrieve data.
160 + $s = time();
161 + $resp = wp_remote_request( $url, $wprr_args );
162 + $e = time();
86 163
87 - $wpfcid = $args;
164 + $erg['duration'] = (int) ( $e - $s );
88 165
89 - // get translation
90 - $locale = get_locale();
91 - if ( empty($locale) )
92 - $locale = 'en_US';
93 - if(function_exists('load_textdomain'))
94 - load_textdomain("wp-forecast_".$locale,ABSPATH . "wp-content/plugins/wp-forecast/lang/".$locale.".mo");
95 -
96 - // code for widget title form
97 - $title = $newtitle = get_option("wp-forecast-title".$wpfcid);
98 -
99 - if ( $_POST["wpf-submit-title".$wpfcid] )
100 - $newtitle = strip_tags(stripslashes($_POST["wpf-title-".$wpfcid]));
166 + if ( is_wp_error( $resp ) ) {
167 + $errcode = $resp->get_error_code();
168 + $errmesg = $resp->get_error_message( $errcode );
101 169
102 - if ( $title != $newtitle ) {
103 - $title = $newtitle;
104 - update_option('wp-forecast-title'.$wpfcid, $title);
105 - }
170 + $erg['error'] = $errcode . ' ' . $errmesg;
171 + $erg['body'] = '';
172 + $erg['len'] = '-1';
173 + } else {
174 + $erg['error'] = '';
175 + $erg['body'] = $resp['body'];
176 + $erg['len'] = strlen( $resp['body'] );
177 + }
178 + return $erg;
179 + }
106 180
107 - echo __("Title:","wp-forecast_".$locale);
108 - echo " <input style='width: 250px;' id='wpf-title-". $wpfcid ."' name='wpf-title-" . $wpfcid . "' type='text' value='". $title . "' />";
109 - echo "<input type='hidden' id='wpf-submit-title" . $wpfcid . "' name='wpf-submit-title".$wpfcid."' value='1' />";
110 - echo "<p>".__('widget_hint',"wp-forecast_".$locale)."</p>";
181 + /**
182 + * Show the result of the check.
183 + *
184 + * @param string $erg Contains the result string.
185 + */
186 + function show_check_result( $erg ) {
187 + $out = '';
188 + $space = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
189 + if ( '' == $erg['error'] ) {
190 + $out .= $space . 'Test was successfull.<br/>';
191 + $out .= $space . 'Fetched ' . $erg['len'] . ' Bytes in ';
192 + $out .= $erg['duration'] . ' seconds.<br/>';
193 + $out .= 'Content was: ' . $erg['body'] . '<br/>';
194 + } else {
195 + $out .= $space . 'Test ends in error.<br/>';
196 + $out .= $space . 'Error-Message was ' . $erg['error'] . '<br/>';
197 + }
198 + return $out;
199 + }
111 200
112 - if ($wpf_debug > 0)
113 - pdebug("End of wp_admin_hint ()");
201 + $wpf_vars = get_wpf_opts( 'A' );
202 +
203 + if ( ! empty( $_POST['provider'] ) ) {
204 + $provider = sanitize_text_field( wp_unslash( $_POST['provider'] ) );
205 + $res .= 'Checking for Weatherprovider ' . esc_attr( $provider ) . '<br />';
206 +
207 + if ( 'OpenWeatherMapV3' == $provider ) {
208 + if ( ! isset( $wpf_vars['apikey1'] ) ) {
209 + $out .= __( 'You have to set the API-Key to test OpenWeatherMap.', 'wp-forecast' );
210 + echo wp_kses( $out, wpf_allowed_tags() );
211 + die();
212 + }
213 + $url = 'https://api.openweathermap.org/data/3.0/onecall?lat=50.11&lon=8.68&appid=' . $wpf_vars['apikey1'] . '&exclude=minutely,hourly&units=1&lang=en';
214 + }
215 +
216 + if ( 'OpenWeatherMap' == $provider ) {
217 + if ( ! isset( $wpf_vars['apikey1'] ) ) {
218 + $out .= __( 'You have to set the API-Key to test OpenWeatherMap.', 'wp-forecast' );
219 + echo wp_kses( $out, wpf_allowed_tags() );
220 + die();
221 + }
222 + $url = 'https://api.openweathermap.org/data/2.5/weather?lat=50.11&lon=8.68&appid=' . $wpf_vars['apikey1'] . '&exclude=minutely,hourly&units=1&lang=en';
223 + }
224 +
225 + if ( 'Open-Meteo' == $provider ) {
226 + $url = 'https://api.open-meteo.com/v1/forecast?latitude=50.77664&longitude=6.08342&current_weather=true&timeformat=unixtime&timezone=GMT';
227 + }
228 +
229 + // checking for standard connection method.
230 + $res .= 'Checking using WordPress wp_remote_get<br />';
231 + $erg = check_url( $url );
232 + $res .= show_check_result( $erg );
233 + }
234 +
235 + echo wp_kses( $res, wpf_allowed_tags() );
236 + wp_die();
114 237 }
115 238
116 -//
117 -// get the locationlist and return it in one long string
118 -//
119 -function get_loclist($uri,$loc)
120 -{
121 - global $wpf_debug;
239 +/**
240 + * Add menuitem for options menu.
241 + */
242 +function wp_forecast_admin() {
243 + $ap = add_menu_page( 'wp-Forecast', 'wp-Forecast', 'manage_options', basename( __FILE__ ), 'wpf_admin_form', plugins_url( '/wpf.png', __FILE__ ) );
244 + add_action( 'load-' . $ap, 'wp_forecast_contextual_help' );
245 +}
122 246
123 - if ($wpf_debug > 0)
124 - pdebug("Start of get_loclist ()");
247 +/**
248 + * Print out hint for the widget control.
249 + *
250 + * @param array $args Parameters for amdin hint.
251 + */
252 +function wpf_admin_hint( $args = null ) {
253 + $wpfcid = $args;
125 254
126 - $url=$uri . urlencode($loc);
127 - $xml = fetchURL($url);
255 + // check nonce.
256 + if ( ! isset( $_POST['wpf_nonce_4'] ) ) {
257 + die( "<br><br>Looks like you didn't send any credentials. Please reload the page. " );
258 + }
259 + if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['wpf_nonce_4'] ) ), 'wpf_nonce_4' ) ) {
260 + die( "<br><br>Looks like you didn't send any credentials. Please reload the page. " );
261 + }
128 262
129 - if ($wpf_debug > 0)
130 - pdebug("End of get_loclist ()");
131 -
132 - return $xml;
263 + load_plugin_textdomain( 'wp-forecast', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
264 +
265 + // code for widget title form.
266 + $av = get_wpf_opts( $wpfcid );
267 + $av['title'] = $newtitle;
268 +
269 + if ( isset( $_POST[ 'wpf-submit-title' . $wpfcid ] ) ) {
270 + $newtitle = ( isset( $_POST[ 'wpf-title-' . $wpfcid ] ) ? sanitize_text_field( wp_unslash( $_POST[ 'wpf-title-' . $wpfcid ] ) ) : '' );
271 + }
272 +
273 + if ( $av['title'] != $newtitle ) {
274 + $av['title'] = $newtitle;
275 + wpf_update_option( 'wp-forecast-opts' . $wpfcid, serialize( $av ) );
276 + }
277 +
278 + echo esc_attr__( 'Title:', 'wp-forecast' );
279 + echo " <input style='width: 250px;' id='wpf-title-" . esc_attr( $wpfcid ) . "' name='wpf-title-" . esc_attr( $wpfcid ) . "' type='text' value='" . esc_attr( $av['title'] ) . "' />";
280 + echo "<input type='hidden' id='wpf-submit-title" . esc_attr( $wpfcid ) . "' name='wpf-submit-title" . esc_attr( $wpfcid ) . "' value='1' />";
281 + echo "<input name='wpf_nonce_4' type='hidden' value='<?php echo esc_attr( wp_create_nonce( 'wpf_nonce_4' ) ); ?>' />";
282 + echo '<p>' . esc_attr__( 'widget_hint', 'wp-forecast' ) . '</p>';
133 283 }
134 284
285 +/**
286 + * Get the locationlist and return it in one long string.
287 + *
288 + * @param string $uri This contains the uri to fetch the list from.
289 + * @param string $loc This contains the location identifier.
290 + */
291 +function get_loclist( $uri, $loc ) {
292 + $data = array();
135 293
136 -//
137 -// parse xml and extract locations as an array
138 -// for later us in the admin form
139 -//
140 -function get_locations($xml)
141 -{
142 - global $wpf_debug;
294 + $url = $uri . 'name=' . urlencode( $loc ) . '&count=100&language=en&format=json';
143 295
144 - if ($wpf_debug > 0)
145 - pdebug("Start of get_locations ()");
296 + // fetch the URL and decode it.
297 + $json = wp_remote_get( $url );
298 + if ( ! is_wp_error( $json ) ) {
299 + $data = json_decode( $json['body'], true );
300 + }
146 301
147 - // start_element() - wird vom XML-Parser bei öffnenden Tags aufgerufen
148 - function s_element( $parser, $name, $attribute )
149 - {
150 - global $loc,$i;
151 - if ($name == "LOCATION") {
152 - $loc[$i]=array();
153 - $loc[$i]['city'] = $attribute['CITY'];
154 - $loc[$i]['state'] = $attribute['STATE'];
155 - $loc[$i]['location'] = $attribute['LOCATION'];
156 - $i++;
157 - }
158 - }
159 -
160 - // end_element() - dummy function
161 - function e_element( $parser, $name ){}
162 -
163 - // Instanz des XML-Parsers erzeugen
164 - $parser = xml_parser_create();
165 -
166 - // Parameter des XML-Parsers setzen
167 - xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, true );
168 -
169 - // Handler für Elemente ( öffnende / schließende Tags ) setzen
170 - xml_set_element_handler( $parser, "s_element", "e_element" );
171 -
172 - // try to parse the xml
173 - if( !xml_parse( $parser, $xml,true ) )
174 - {
175 - // Fehler -> Ausführung abbrechen
176 - die( "XML Fehler: " .
177 - xml_error_string( xml_get_error_code( $parser ) ) .
178 - " in Zeile " .
179 - xml_get_current_line_number( $parser )
180 - );
181 - }
182 -
183 - // Vom XML-Parser belegten Speicher freigeben
184 - xml_parser_free( $parser );
302 + return $data['results'];
303 +}
185 304
186 - if ($wpf_debug > 0)
187 - pdebug("End of get_locations ()");
188 -
189 - // return locations
190 - return $loc;
305 +
306 +/**
307 + * Form handler for the widgets.
308 + *
309 + * @param string $wpfcid Widget-ID.
310 + * @param bool $widgetcall Is it a widget call.
311 + */
312 +function wpf_admin_form( $wpfcid = 'A', $widgetcall = 0 ) {
313 + global $wpf_maxwidgets, $blog_id;
314 +
315 + if ( function_exists( 'is_multisite' ) && is_multisite() && 1 != $blog_id && ! wpf_get_option( 'wpf_sa_allowed' ) ) {
316 + wp_forecast_activate();
317 + }
318 +
319 + $count = wpf_get_option( 'wp-forecast-count' );
320 + $wpf_delopt = wpf_get_option( 'wp-forecast-delopt' );
321 + $wpf_ipstack = wpf_get_option( 'wp-forecast-ipstackapikey' );
322 + $wpf_loadcss = wpf_get_option( 'wp-forecast-loadcss' );
323 +
324 + // called via the options menu not from widgets.
325 + if ( 0 == $widgetcall ) {
326 + // load translation.
327 + load_plugin_textdomain( 'wp-forecast', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
328 +
329 + // if this is a post call to update global settings.
330 + if ( isset( $_POST['wpf_global_settings_update'] ) ) {
331 + // check nonce.
332 + if ( ! isset( $_POST['wpf_nonce_1'] ) ) {
333 + die( "<br><br>Looks like you didn't send any credentials. Please reload the page. " );
334 + }
335 + if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['wpf_nonce_1'] ) ), 'wpf_nonce_1' ) ) {
336 + die( "<br><br>Looks like you didn't send any credentials. Please reload the page. " );
337 + }
338 +
339 + // update max widgets.
340 + $number = ( isset( $_POST['wp-forecast-count'] ) ? (int) $_POST['wp-forecast-count'] : 1 );
341 + if ( $number > $wpf_maxwidgets ) {
342 + $number = $wpf_maxwidgets;
343 + }
344 + if ( $number < 1 ) {
345 + $number = 1;
346 + }
347 + $newcount = $number;
348 +
349 + if ( $count != $newcount ) {
350 + $count = $newcount;
351 + wpf_update_option( 'wp-forecast-count', $count );
352 + // add missing option to database.
353 + wp_forecast_activate();
354 + // init the new number of widgets.
355 + widget_wp_forecast_init( $count );
356 + }
357 +
358 + // update delopt.
359 + $wpf_delopt = ( array_key_exists( 'wp-forecast-delopt', $_POST ) ? (int) ( 'on' == $_POST['wp-forecast-delopt'] ) : false );
360 + wpf_update_option( 'wp-forecast-delopt', $wpf_delopt );
361 +
362 + // update ipstack apikey.
363 + wpf_update_option( 'wp-forecast-ipstackapikey', ( isset( $_POST['wp-forecast-ipstackapikey'] ) ? sanitize_text_field( wp_unslash( $_POST['wp-forecast-ipstackapikey'] ) ) : '' ) );
364 +
365 + // update loadcss.
366 + $wpf_loadcss = ( array_key_exists( 'wp-forecast-loadcss', $_POST ) ? (int) ( 'on' == $_POST['wp-forecast-loadcss'] ) : false );
367 + wpf_update_option( 'wp-forecast-loadcss', $wpf_loadcss );
368 +
369 + $count = wpf_get_option( 'wp-forecast-count' );
370 + $wpf_delopt = wpf_get_option( 'wp-forecast-delopt' );
371 + $wpf_ipstack = wpf_get_option( 'wp-forecast-ipstackapikey' );
372 + $wpf_loadcss = wpf_get_option( 'wp-forecast-loadcss' );
373 +
374 + } // end of update global settings.
375 +
376 + // start of form ---------------------------------------------------------------------------
377 + //
378 + // print out number of widgets selection.
379 + $out = "<div class='wrap'>";
380 + $out .= '<h2>WP-Forecast Widgets</h2>';
381 + $out .= tl_add_supp();
382 +
383 + // begin of global settings.
384 + $out .= '<h2>' . esc_attr__( 'Global Settings', 'wp-forecast' ) . '</h2>';
385 + $out .= "<form name='options' id='options' method='post' action='#'>";
386 + $out .= '<input name="wpf_nonce_1" type="hidden" value="' . wp_create_nonce( 'wpf_nonce_1' ) . '" />';
387 + $out .= '<table style="width:80%;"><tr><td>' . esc_attr__( 'How many wp-forecast widgets would you like?', 'wp-forecast' ) . '</td>';
388 + $out .= '<td><select id="wp-forecast-count" name="wp-forecast-count">';
389 +
390 + for ( $i = 1; $i <= $wpf_maxwidgets; ++$i ) {
391 + $out .= "<option value='$i' ";
392 + if ( $count == $i ) {
393 + $out .= "selected='selected' ";
394 + }
395 + $out .= ">$i</option>";
396 + }
397 + $out .= '</select></td>';
398 +
399 + // print out option deletion switch.
400 + $out .= '<td>' . esc_attr__( 'Delete options during plugin deactivation?', 'wp-forecast' ) . '</td>';
401 + $out .= "<td><input id='wp-forecast-delopt' name='wp-forecast-delopt' type='checkbox' ";
402 + if ( $wpf_delopt ) {
403 + $out .= 'checked="checked"';
404 + }
405 + $out .= ' />';
406 + $out .= "</td></tr>\n";
407 +
408 + // print out input field for ipstack api key.
409 + $out .= "<tr><td><a href='http://www.ipstack.com' target='_blank'>" . esc_attr__( 'API key to use location from ipstack.com ', 'wp-forecast' ) . ':</a></td>';
410 + $out .= "<td><input id='wp-forecast-ipstackapikey' name='wp-forecast-ipstackapikey' type='text' size='40' width='32' value='$wpf_ipstack' />";
411 + $out .= "</td>\n";
412 +
413 + // print out option loadcss.
414 + $out .= '<td>' . esc_attr__( 'Do not load default CSS', 'wp-forecast' ) . '</td>';
415 + $out .= "<td><input id='wp-forecast-loadcss' name='wp-forecast-loadcss' type='checkbox' ";
416 + if ( $wpf_loadcss ) {
417 + $out .= 'checked="checked"';
418 + }
419 + $out .= ' />';
420 + $out .= "</td></tr>\n";
421 +
422 + $out .= "</table>\n";
423 +
424 + $out .= "<div class='submit'><input class='button-primary' type='submit' name='wpf_global_settings_update' value='" . esc_attr__( 'Update global options', 'wp-forecast' ) . " »' /></div>";
425 + $out .= "</form></div>\n";
426 + // end of global options.
427 +
428 + $out .= '<div style="text-align:right;padding-right:20px;">';
429 + $out .= '<a href="#TB_inline?height=1000&width=600&inlineId=wpf_check__&wpfcid=A" class="thickbox">';
430 + $out .= esc_attr__( 'Check connection to Weatherprovider', 'wp-forecast' ) . '</a></div>' . "\n";
431 +
432 + // print out widget selection form.
433 + if ( $count > 1 ) {
434 + $out .= "<form name='selwidget' id='selwidget' method='post' action='#'>";
435 + $out .= '<input name="wpf_nonce_2" type="hidden" value="' . wp_create_nonce( 'wpf_nonce_2' ) . '" />';
436 + $out .= '<div>' . esc_attr__( 'Available widgets', 'wp-forecast' ) . ': ';
437 +
438 + $out .= "<select name='widgetid' size='1' >";
439 + for ( $i = 0;$i < $count;$i++ ) {
440 + $id = get_widget_id( $i );
441 + $out .= "<option value='" . $id . "' ";
442 +
443 + if (
444 + (
445 + array_key_exists( 'widgetid', $_POST ) &&
446 + sanitize_text_field( wp_unslash( $_POST['widgetid'] ) ) == $id &&
447 + isset( $_POST['set_widget'] )
448 + ) || (
449 + array_key_exists( 'wid', $_POST ) && isset( $_POST['info_update'] ) && sanitize_text_field( $_POST['wid'] == $id )
450 + ) || (
451 + array_key_exists( 'wid', $_POST ) && isset( $_POST['search_loc'] ) && sanitize_text_field( $_POST['wid'] == $id )
452 + ) ) {
453 + $out .= "selected='selected'";
454 + }
455 + $out .= '>' . $id . '</option>';
456 + }
457 + $out .= '</select>';
458 +
459 + $out .= '<span class="submit"><input class="button" type="submit" name="set_widget" value="';
460 + $out .= esc_attr__( 'Select widget', 'wp-forecast' ) . " »\" /></span></div></form>\n";
461 + }
462 +
463 + echo wp_kses( $out, wpf_allowed_tags() );
464 + }
465 +
466 + // if this is a post call, select widget.
467 + if ( isset( $_POST['set_widget'] ) && 0 == $widgetcall ) {
468 + // check nonce.
469 + if ( ! isset( $_POST['wpf_nonce_2'] ) ) {
470 + die( "<br><br>Looks like you didn't send any credentials. Please reload the page. " );
471 + }
472 + if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['wpf_nonce_2'] ) ), 'wpf_nonce_2' ) ) {
473 + die( "<br><br>Looks like you didn't send any credentials. Please reload the page. " );
474 + }
475 +
476 + $wpfcid = sanitize_text_field( wp_unslash( $_POST['widgetid'] ) );
477 + }
478 +
479 + // if this is any other post call.
480 + if ( ( isset( $_POST['info_update'] ) && 0 == $widgetcall ) ||
481 + ( isset( $_POST['set_loc'] ) && 0 == $widgetcall ) ||
482 + ( isset( $_POST['search_loc'] ) && 0 == $widgetcall ) ) {
483 +
484 + // check nonce.
485 + if ( ! isset( $_POST['wpf_nonce_3'] ) ) {
486 + die( "<br><br>Looks like you didn't send any credentials. Please reload the page. " );
487 + }
488 + if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['wpf_nonce_3'] ) ), 'wpf_nonce_3' ) ) {
489 + die( "<br><br>Looks like you didn't send any credentials. Please reload the page. " );
490 + }
491 +
492 + $wpfcid = ( isset( $_POST['wid'] ) ? sanitize_text_field( wp_unslash( $_POST['wid'] ) ) : 'A' );
493 + }
494 +
495 + // default is the first widget.
496 + if ( '' == $wpfcid ) {
497 + $wpfcid = 'A';
498 + }
499 +
500 + // call sub form.
501 + wpf_sub_admin_form( $wpfcid, $widgetcall );
191 502 }
192 503
193 504
194 -//
195 -// form handler for the widgets
196 -//
197 -function wpf_admin_form($wpfcid='A',$widgetcall=0)
198 -{
199 - global $wpf_debug,$wpf_maxwidgets;
505 +/**
506 + * Form to modify wp-forecast setup
507 + * the form also has a search function to search the wright location.
508 + *
509 + * @param string $wpfcid Widget ID.
510 + * @param bool $widgetcall Is it a widgetcall.
511 + */
512 +function wpf_sub_admin_form( $wpfcid, $widgetcall ) {
513 + global $blog_id;
200 514
201 - if ($wpf_debug > 0)
202 - pdebug("Start of wpf_admin_form ()");
515 + // check nonce3.
516 + if ( isset( $_SERVER['REQUEST_METHOD'] ) && 'POST' === $_SERVER['REQUEST_METHOD'] && isset( $_POST['info_update'] ) ) {
517 + if ( ! isset( $_POST['wpf_nonce_3'] ) ) {
518 + die( "<br><br>Looks like you didn't send any credentials. Please reload the page. " );
519 + }
520 + if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['wpf_nonce_3'] ) ), 'wpf_nonce_3' ) ) {
521 + die( "<br><br>Looks like you didn't send any credentials. Please reload the page. " );
522 + }
523 + }
203 524
204 - $count = get_option('wp-forecast-count');
205 - $wpf_timeout = get_option("wp-forecast-timeout");
525 + // get parameters.
526 + $av = get_wpf_opts( $wpfcid );
527 + $allowed = maybe_unserialize( wpf_get_option( 'wpf_sa_allowed' ) );
206 528
207 - // get locale
208 - $locale = get_locale();
209 - if ( empty($locale) )
210 - $locale = 'en_US';
529 + $ismulti = false;
530 + if ( function_exists( 'is_multisite' ) && is_multisite() && get_current_blog_id() != 1 ) {
531 + $ismulti = true;
532 + }
211 533
212 - // called via the options menu not from widgets
213 - if ($widgetcall==0) {
214 - // load translation
215 - if(function_exists('load_textdomain')) {
216 - load_textdomain("wp-forecast_".$locale,ABSPATH . "wp-content/plugins/wp-forecast/lang/".$locale.".mo");
217 - }
534 + if ( function_exists( 'load_plugin_textdomain' ) ) {
535 + load_plugin_textdomain( 'wp-forecast', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
536 + }
218 537
219 - // if this is a post call, number of widgets
220 - if ( isset($_POST['wpf-count-submit']) ) {
221 - $number = (int) $_POST['wpf-number'];
222 - if ( $number > $wpf_maxwidgets ) $number = $wpf_maxwidgets;
223 - if ( $number < 1 ) $number = 1;
224 - $newcount = $number;
538 + // if this is a POST call, save new values.
539 + if ( isset( $_POST['info_update'] ) ) {
540 + $upflag = false;
225 541
226 - if ( $count != $newcount ) {
227 - $count = $newcount;
228 - update_option('wp-forecast-count', $count);
229 - // add missing option to database
230 - wp_forecast_activate();
231 - // init the new number of widgets
232 - widget_wp_forecast_init($count);
233 - }
234 - }
542 + $wpf_admin_fields = array(
543 + 'service',
544 + 'apikey1',
545 + 'location',
546 + 'loclongitude',
547 + 'loclatitude',
548 + 'visitorlocation',
549 + 'locname',
550 + 'location',
551 + 'refresh',
552 + 'provider',
553 + 'csssprites',
554 + 'windicon',
555 + 'fonticon',
556 + 'fonticon_color',
557 + 'pdforecast',
558 + 'pdfirstday',
559 + 'timeoffset',
560 + 'currtime',
561 + 'wpf_language',
562 + 'windunit',
563 + 'metric',
564 + 'ouv_safetime',
565 + 'ouv_ozone',
566 + 'ouv_uvmax',
567 + 'ouv_uv',
568 + 'ouv_apikey',
569 + 'ouv_alticons',
570 + );
235 571
236 - // if this is a post call, timeout
237 - if ( isset($_POST['wpf-timeout-submit']) ) {
238 - $timeout = (int) $_POST['wpf-timeout'];
239 - if ( $timeout < 0 ) $timeout = 1;
240 -
241 - if ( $wpf_timeout != $timeout ) {
242 - $wpf_timeout = $timeout;
243 - update_option('wp-forecast-timeout', $wpf_timeout);
244 - }
245 - }
572 + // fill up POST array with NULL vallues for unset keys.
573 + foreach ( $wpf_admin_fields as $k ) {
574 + if ( ! isset( $_POST[ $k ] ) ) {
575 + $_POST[ $k ] = null;
576 + }
577 + }
246 578
247 - // print out number of widgets selection
248 - $out = "<div class='wrap'>";
249 - $out .= "<h2>WP-Forecast Widgets</h2>";
250 - $out .= "<form name='options' id='options' method='post' action=''>";
251 - $out .= "<table class='form-table'><tr><td>".__('How many wp-forecast widgets would you like?',"wp-forecast_".$locale)."</td>";
252 - $out .= "<td><select id='wpf-number' name='wpf-number'>";
253 -
254 - for ( $i = 1; $i <= $wpf_maxwidgets; ++$i ) {
255 - $out .= "<option value='$i' ";
256 - if ($count==$i)
257 - $out .= "selected='selected' ";
258 - $out .= ">$i</option>";
259 - }
260 - $out .= "</select></td><td><span class='submit'><input type='submit' name='wpf-count-submit' id='wpf-count-submit' value='".attribute_escape(__('Save'),"wp-forecast_".$locale)."' /></span></td></tr>";
579 + // update fields if applicable.
580 + foreach ( $wpf_admin_fields as $k ) {
581 + $av[ $k ] = sanitize_text_field( wp_unslash( $_POST[ $k ] ) );
582 + $upflag = true;
583 + }
584 + if ( '' == $av['metric'] ) {
585 + $av['metric'] = '0';
586 + }
587 + if ( '' == $av['currtime'] ) {
588 + $av['currtime'] = '0';
589 + }
590 + if ( '' == $av['windicon'] ) {
591 + $av['windicon'] = '0';
592 + }
593 + if ( '' == $av['fonticon'] ) {
594 + $av['fonticon'] = '0';
595 + }
596 + if ( '' == $av['fonticon_color'] ) {
597 + $av['fonticon_color'] = '#924da3';
598 + }
599 + if ( '' == $av['ouv_uv'] ) {
600 + $av['ouv_uv'] = '0';
601 + }
602 + if ( '' == $av['ouv_uvmax'] ) {
603 + $av['ouv_uvmax'] = '0';
604 + }
605 + if ( '' == $av['ouv_ozone'] ) {
606 + $av['ouv_ozone'] = '0';
607 + }
608 + if ( '' == $av['ouv_safetime'] ) {
609 + $av['ouv_safetime'] = '0';
610 + }
611 + if ( '' == $av['ouv_alticons'] ) {
612 + $av['ouv_alticons'] = '0';
613 + }
261 614
262 - // print out widget selection form
263 - $out .="<tr><td>".__('Available widgets',"wp-forecast_".$locale).": </td>";
264 - $out .="<td><select name='widgetid' size='1' >";
265 - for ($i=0;$i<$count;$i++) {
266 - $id = get_widget_id( $i );
267 - $out .="<option value='".$id."' ";
268 - if ( ($id==$_POST['widgetid'] and isset($_POST['set_widget'])) or
269 - (isset($_POST['info_update']) and $id==$_POST['wid']) or
270 - (isset($_POST['search_loc']) and $id==$_POST['wid']) or
271 - (isset($_POST['set_loc']) and $id==$_POST['wid']))
272 - $out .="selected";
273 - $out .=">".$id."</option>";
274 - }
275 - $out .= "</select></td>";
276 -
277 - $out .="<td><span class=\"submit\"><input type=\"submit\" name=\"set_widget\" value=\"" ;
278 - $out .=__('Select widget',"wp-forecast_".$locale)." »\" /></span></td></tr>\n";
279 -
615 + if ( '' == $av['visitorlocation'] ) {
616 + $av['visitorlocation'] = '0';
617 + }
280 618
281 - // print out timeout input field for fsockopen
282 - // (timeout for accuweather connection)
283 - $out .= "<tr><td>".__('Timeout for accuweather connections (secs.)?',"wp-forecast_".$locale)."</td>";
284 - $out .= "<td><input id='wpf-timeout' name='wpf-timeout' type='text' size='3' maxlength='3' value='".$wpf_timeout. "' />";
285 - $out .= "</td><td><span class='submit'><input type='submit' name='wpf-timeout-submit' id='wpf-timeout-submit' value='".attribute_escape(__('Save'),"wp-forecast_".$locale)."' /></span></td></tr></table></form></div>\n";
619 + // set checkbox value to zero if not set.
620 + // for forecast options.
621 + $nd = array( 'day1', 'day2', 'day3', 'day4', 'day5', 'day6', 'day7', 'day8', 'day9', 'night1', 'night2', 'night3', 'night4', 'night5', 'night6', 'night7', 'night8', 'night9' );
622 + foreach ( $nd as $i ) {
623 + if ( ! isset( $_POST[ $i ] ) || '' == $_POST[ $i ] ) {
624 + $_POST[ "$i" ] = '0';
625 + }
626 + }
286 627
287 - echo $out;
288 - }
628 + // set empty checkboxes to 0.
629 + $do = array(
630 + 'd_c_icon',
631 + 'd_c_time',
632 + 'd_c_short',
633 + 'd_c_temp',
634 + 'd_c_real',
635 + 'd_c_press',
636 + 'd_c_humid',
637 + 'd_c_wind',
638 + 'd_c_sunrise',
639 + 'd_c_sunset',
640 + 'd_d_icon',
641 + 'd_d_short',
642 + 'd_d_temp',
643 + 'd_d_wind',
644 + 'd_n_icon',
645 + 'd_n_short',
646 + 'd_n_temp',
647 + 'd_n_wind',
648 + 'd_c_date',
649 + 'd_d_date',
650 + 'd_n_date',
651 + 'd_c_copyright',
652 + 'd_c_wgusts',
653 + 'd_d_wgusts',
654 + 'd_n_wgusts',
655 + 'd_c_accuweather',
656 + 'd_c_aw_newwindow',
657 + 'd_c_uvindex',
658 + 'd_d_maxuv',
659 + 'd_n_maxuv',
660 + 'd_c_precipe',
661 + 'd_d_precipe',
662 + 'd_n_precipe',
663 + );
664 + foreach ( $do as $i ) {
665 + if ( ! isset( $_POST[ $i ] ) || '' == $_POST[ $i ] ) {
666 + $_POST[ "$i" ] = '0';
667 + }
668 + }
289 669
290 -
291 - // if this is a post call, select widget
292 - if (isset($_POST['set_widget']) and $widgetcall==0)
293 - $wpfcid = $_POST['widgetid'];
670 + // build config string for dispconfig and update if necessary.
671 + $newdispconfig = '';
672 + foreach ( $do as $i ) {
673 + $newdispconfig .= (int) $_POST[ $i ];
674 + }
294 675
295 - // if this is any other post call
296 - if ( (isset($_POST['info_update']) and $widgetcall==0) or
297 - (isset($_POST['set_loc']) and $widgetcall==0) or
298 - (isset($_POST['search_loc']) and $widgetcall==0) )
299 - $wpfcid = $_POST['wid'];
676 + if ( ( ! $ismulti || isset( $allowed['ue_dispconfig'] ) ) && strcmp( $av['dispconfig'], $newdispconfig ) != 0 ) {
677 + $av['dispconfig'] = $newdispconfig;
678 + $upflag = true;
679 + }
300 680
301 - // default is the first widget
302 - if ($wpfcid=="")
303 - $wpfcid="A";
681 + // build config string for forecast and update if necessary.
682 + $newdaytime = ( isset( $_POST['day1'] ) ? (int) $_POST['day1'] : 0 )
683 + . ( isset( $_POST['day2'] ) ? (int) $_POST['day2'] : 0 )
684 + . ( isset( $_POST['day3'] ) ? (int) $_POST['day3'] : 0 )
685 + . ( isset( $_POST['day4'] ) ? (int) $_POST['day4'] : 0 )
686 + . ( isset( $_POST['day5'] ) ? (int) $_POST['day5'] : 0 )
687 + . ( isset( $_POST['day6'] ) ? (int) $_POST['day6'] : 0 )
688 + . ( isset( $_POST['day7'] ) ? (int) $_POST['day7'] : 0 )
689 + . ( isset( $_POST['day8'] ) ? (int) $_POST['day8'] : 0 )
690 + . ( isset( $_POST['day9'] ) ? (int) $_POST['day9'] : 0 );
304 691
305 - // call sub form
306 - wpf_sub_admin_form($wpfcid,$widgetcall);
307 -
308 - if ($wpf_debug > 0)
309 - pdebug("End of wpf_admin_form ()");
310 -}
311 -
312 -//
313 -// form to modify wp-forecast setup
314 -// options in wp_option: wp-forecast-location, wp-forecast-refresh
315 -// wp-forecast-metric, wp-forecast-language
316 -// wp-forecast-daytime wp-forecast-nighttime
317 -// wp-forecast-dispconfig wp-forecast-locname
318 -//
319 -// the form also has a search function to search the wright location
320 -//
321 -function wpf_sub_admin_form($wpfcid,$widgetcall) {
322 - global $loc,$wpf_debug;
692 + if ( ( ! $ismulti || isset( $allowed['ue_forecast'] ) ) && $av['daytime'] != $newdaytime ) {
693 + $av['daytime'] = $newdaytime;
694 + $upflag = true;
695 + }
323 696
324 - if ($wpf_debug > 0)
325 - pdebug("Start of wpf_sub_admin_form ()");
697 + $newnighttime = ( isset( $_POST['night1'] ) ? (int) $_POST['night1'] : 0 )
698 + . ( isset( $_POST['night2'] ) ? (int) $_POST['night2'] : 0 )
699 + . ( isset( $_POST['night3'] ) ? (int) $_POST['night3'] : 0 )
700 + . ( isset( $_POST['night4'] ) ? (int) $_POST['night4'] : 0 )
701 + . ( isset( $_POST['night5'] ) ? (int) $_POST['night5'] : 0 )
702 + . ( isset( $_POST['night6'] ) ? (int) $_POST['night6'] : 0 )
703 + . ( isset( $_POST['night7'] ) ? (int) $_POST['night7'] : 0 )
704 + . ( isset( $_POST['night8'] ) ? (int) $_POST['night8'] : 0 )
705 + . ( isset( $_POST['night9'] ) ? (int) $_POST['night9'] : 0 );
326 706
327 - // uri for location search
328 - $LOC_URI="http://forecastfox.accuweather.com/adcbin/forecastfox/locate_city.asp?location=";
707 + if ( ( ! $ismulti || isset( $allowed['ue_forecast'] ) ) && $av['nighttime'] != $newnighttime ) {
708 + $av['nighttime'] = $newnighttime;
709 + $upflag = true;
710 + }
329 711
330 - // wp-forecast optionen aus datenbank lesen
331 - $location=get_option("wp-forecast-location".$wpfcid);
332 - $locname=get_option("wp-forecast-locname".$wpfcid);
333 - $refresh=get_option("wp-forecast-refresh".$wpfcid);
334 - $metric=get_option("wp-forecast-metric".$wpfcid);
335 - $wpf_language=get_option("wp-forecast-language".$wpfcid);
336 - $daytime=get_option("wp-forecast-daytime".$wpfcid);
337 - $nighttime=get_option("wp-forecast-nighttime".$wpfcid);
338 - $dispconfig=get_option("wp-forecast-dispconfig".$wpfcid);
339 - $windunit = get_option("wp-forecast-windunit".$wpfcid);
340 - $currtime = get_option("wp-forecast-currtime".$wpfcid);
341 -
342 - // get translation
343 - $locale = get_locale();
344 - if ( empty($locale) )
345 - $locale = 'en_US';
346 - if(function_exists('load_textdomain'))
347 - load_textdomain("wp-forecast_".$locale,ABSPATH . "wp-content/plugins/wp-forecast/lang/".$locale.".mo");
348 -
349 -
350 - // if this is a POST call, save new values
351 - if (isset($_POST['info_update'])) {
352 - $upflag=false;
353 -
354 - if ($location != $_POST["location"]) {
355 - $location = $_POST["location"];
356 - update_option("wp-forecast-location".$wpfcid, $location);
357 - $upflag=true;
358 - }
359 -
360 - if ($locname != $_POST["locname"]) {
361 - $locname = $_POST["locname"];
362 - update_option("wp-forecast-locname".$wpfcid, $locname);
363 - $upflag=true;
364 - }
365 -
366 - if ($refresh != $_POST["refresh"]) {
367 - $refresh = $_POST["refresh"];
368 - update_option("wp-forecast-refresh".$wpfcid, $refresh);
369 - $upflag=true;
370 - }
371 -
372 - if ($metric != $_POST["metric"]) {
373 - $metric = $_POST["metric"];
374 - if ($metric=="") $metric="0";
375 - update_option("wp-forecast-metric".$wpfcid, $metric);
376 - $upflag=true;
377 - }
378 -
379 - if ($windunit != $_POST["windunit"]) {
380 - $windunit = $_POST["windunit"];
381 - update_option("wp-forecast-windunit".$wpfcid, $windunit);
382 - $upflag=true;
383 - }
384 -
385 - if ($wpf_language != $_POST["language"]) {
386 - $wpf_language = $_POST["language"];
387 - update_option("wp-forecast-language".$wpfcid, $wpf_language);
388 - $upflag=true;
389 - }
390 -
391 - if ($currtime != $_POST["currtime"]) {
392 - $currtime = $_POST["currtime"];
393 - if ($currtime=="") $currtime="0";
394 - update_option("wp-forecast-currtime".$wpfcid, $currtime);
395 - $upflag=true;
396 - }
712 + // put message after update.
713 + echo "<div class='updated'><p><strong>";
714 + if ( $upflag ) {
715 + wpf_update_option( 'wp-forecast-opts' . $wpfcid, serialize( $av ) );
716 + wpf_update_option( 'wp-forecast-expire' . $wpfcid, '0' );
717 + echo esc_attr__( 'Settings successfully updated', 'wp-forecast' );
718 + } else {
719 + echo esc_attr__( 'You have to change a field to update settings.', 'wp-forecast' );
720 + }
721 + echo '</strong></p></div>';
722 + }
397 723
398 - // set checkbox value to zero if not set
399 - // for forecast options
400 - $nd = array('day1','day2','day3','day4','day5','day6','day7','day8','day9','night1','night2','night3','night4','night5','night6','night7','night8','night9');
401 - foreach ($nd as $i) {
402 - if ($_POST[$i]=="")
403 - $_POST["$i"]="0";
404 - }
405 -
406 - // set empty checkboxes to 0
407 - $do = array('d_c_icon','d_c_time','d_c_short','d_c_temp','d_c_real','d_c_press','d_c_humid','d_c_wind','d_c_sunrise','d_c_sunset','d_d_icon','d_d_short','d_d_temp','d_d_wind','d_n_icon','d_n_short','d_n_temp','d_n_wind','d_c_date','d_d_date','d_n_date','d_c_copyright','d_c_wgusts','d_d_wgusts','d_n_wgusts','d_c_accuweather');
408 - foreach ($do as $i) {
409 - if ($_POST[$i]=="")
410 - $_POST["$i"]="0";
411 - }
412 -
413 - // build config string for dispconfig and update if necessary
414 - $newdispconfig="";
415 - foreach ($do as $i)
416 - $newdispconfig.=$_POST[$i];
417 -
418 - if (strcmp($dispconfig,$newdispconfig) != 0) {
419 - $dispconfig = $newdispconfig;
420 - update_option("wp-forecast-dispconfig".$wpfcid, $newdispconfig);
421 - $upflag=true;
422 - }
423 -
424 -
425 - // build config string for forecast and update if necessary
426 - $newdaytime=$_POST["day1"].$_POST["day2"].$_POST["day3"].$_POST["day4"].$_POST["day5"].$_POST["day6"].$_POST["day7"].$_POST["day8"].$_POST["day9"];
427 -
428 - if ($daytime != $newdaytime) {
429 - $daytime = $newdaytime;
430 - update_option("wp-forecast-daytime".$wpfcid, $newdaytime);
431 - $upflag=true;
432 - }
433 - // build config string for forecast and update if necessary
434 - $newnighttime=$_POST["night1"].$_POST["night2"].$_POST["night3"].$_POST["night4"].$_POST["night5"].$_POST["night6"].$_POST["night7"].$_POST["night8"].$_POST["night9"];
435 -
436 - if ($nighttime != $newnighttime) {
437 - $nighttime = $newnighttime;
438 - update_option("wp-forecast-nighttime".$wpfcid, $newnighttime);
439 - $upflag=true;
440 - }
441 - // put message after update
442 - echo"<div class='updated'><p><strong>";
443 - if ($upflag)
444 - echo __('Settings successfully updated',"wp-forecast_".$locale);
445 - else
446 - echo __('You have to change a field to update settings.',"wp-forecast_".$locale);
447 -
448 - echo "</strong></p></div>";
449 - }
450 -
451 - // if this is a POST call, search locations
452 - if (isset($_POST['search_loc'])) {
453 - $xml=get_loclist($LOC_URI,$_POST["searchloc"]);
454 - $xml=utf8_encode($xml);
455 - get_locations($xml);
456 - }
457 -
458 - // if this is a POST call, set location
459 - if (isset($_POST['set_loc'])) {
460 - $location=$_POST["newloc"];
461 - }
462 -?>
724 + // if this is a POST call, set location.
725 + if ( isset( $_POST['set_loc'] ) ) {
726 + if ( isset( $_POST['new_loc'] ) ) {
727 + $av['location'] = sanitize_text_field( wp_unslash( $_POST['new_loc'] ) );
728 + }
729 + if ( isset( $_POST['provider'] ) ) {
730 + $av['service'] = sanitize_text_field( wp_unslash( $_POST['provider'] ) );
731 + }
732 + }
733 + ?>
463 734
464 - <?php if ($widgetcall == 0): ?><div class="wrap">
465 - <form method="post" action=''><?php endif; ?>
466 - <input name='wid' type='hidden' value='<?php echo $wpfcid; ?>'/>
467 - <h2><?php echo __('WP-Forecast Setup',"wp-forecast_".$locale)." (Widget ".$wpfcid.") ";?></h2>
468 - <?php if ($widgetcall == 0): ?><fieldset id="set1"><?php endif; ?>
735 + <?php
736 + if ( 0 == $widgetcall ) :
737 + ?>
738 + <div class="wrap">
739 + <!-- add javascript for field control -->
740 + <?php
741 + include 'wp-forecast-js.php';
742 + ?>
743 + <form method="post" name='woptions' action='#'>
744 + <input name="wpf_nonce_3" type="hidden" value="<?php echo esc_attr( wp_create_nonce( 'wpf_nonce_3' ) ); ?>" />
745 + <?php endif; ?>
746 + <input name='wid' type='hidden' value='<?php echo esc_attr( $wpfcid ); ?>'/>
747 + <h2><?php echo esc_attr__( 'WP-Forecast Setup', 'wp-forecast' ) . ' (Widget ' . esc_attr( $wpfcid ) . ') '; ?></h2>
748 + <?php
749 + if ( 0 == $widgetcall ) :
750 + ?>
751 + <fieldset id="set1"><?php endif; ?>
752 +
753 +
469 754 <div style="float: left; width: 49%">
470 - <b><?php echo __('Location',"wp-forecast_".$locale)?>:</b>
471 - <input name="location" type="text" size="30" maxlength="80" value="<?php echo $location ?>"<?php if ($widgetcall==1) echo "readonly" ?> />
472 - <?php if (isset($_POST['set_loc'])) { ?>
473 - <p><b><?php echo __('Press Update options to save new location.',"wp-forecast_".$locale)?></b></p>
474 - <?php } ?>
475 -
476 - <p><b><?php echo __('Locationname',"wp-forecast_".$locale)?>:</b>
477 - <input name="locname" type="text" size="30" maxlength="80" value="<?php echo $locname ?>" /></p>
478 - <p><b><?php echo __('Refresh cache after',"wp-forecast_".$locale)?></b>
479 - <input name="refresh" type="text" size="10" maxlength="6" value="<?php echo $refresh ?>"/>
480 - <b><?php echo __('secs.',"wp-forecast_".$locale)?></b><br /></p>
481 - <p><input type="checkbox" name="metric" value="1" <?php if ($metric=="1") echo "checked=\"checked\""?> /> <b><?php echo __('Use metric units',"wp-forecast_".$locale)?></b>
755 + <p><b><?php echo esc_attr__( 'wp-forecast supports the free API from OpenMeteo, the OpenWeatherMap v2.5 FreeAPI or OneCall API v3. If you use OpenWeatherMap v3 please check if your plan includes the OneCall API.', 'wp-forecast' ); ?></b></p>
756 + <p><b><?php echo esc_attr__( 'Weatherservice', 'wp-forecast' ); ?>:</b>
757 + <select name="service" id="service" size="1" onchange="apifields(document.woptions.service.value);">
758 + <option value="openweathermap"
759 + <?php
760 + if ( 'openweathermap' === $av['service'] ) {
761 + echo 'selected="selected"';}
762 + ?>
763 + ><?php echo esc_attr__( 'OpenWeathermap', 'wp-forecast' ); ?></option>
764 + <option value="openweathermap3"
765 + <?php
766 + if ( 'openweathermap3' === $av['service'] ) {
767 + echo 'selected="selected"';}
768 + ?>
769 + ><?php echo esc_attr__( 'OpenWeatherMap v3', 'wp-forecast' ); ?></option>
770 +
771 + <option value="openmeteo"
772 + <?php
773 + if ( 'openmeteo' === $av['service'] ) {
774 + echo 'selected="selected"';}
775 + ?>
776 + ><?php echo esc_attr__( 'Open-Meteo', 'wp-forecast' ); ?></option>
777 + </select>&nbsp;
778 +
779 + <?php echo esc_attr__( 'API-Key', 'wp-forecast' ); ?>:
780 + <input name="apikey1" id="apikey1" type="text" size="20" maxlength="80" value="<?php echo esc_attr( $av['apikey1'] ); ?>" /></p>
781 + <script type="text/javascript">apifields(document.woptions.service.value);</script>
782 +
783 + <p><b><?php echo esc_attr__( 'Location', 'wp-forecast' ); ?>:</b>
784 + <input name="location" id="location" type="text" size="30" maxlength="80" value="<?php echo esc_attr( $av['location'] ); ?>"
785 + <?php
786 + if ( 1 === $widgetcall ) {
787 + echo 'readonly';}
788 + ?>
789 + />
790 +
791 + <a href="#TB_inline?height=1000&width=600&inlineId=wpf_search__&wpfcid=<?php echo esc_attr( $wpfcid ); ?>" class="thickbox">
792 + <img alt="Search Icon" src="<?php echo esc_attr( plugin_dir_url( __FILE__ ) ); ?>/Searchicon16x16.png" /></a>
793 + &nbsp;&nbsp;&nbsp;<input type="checkbox" name="visitorlocation" id="visitorlocation" value="1"
794 + <?php
795 + if ( isset( $av['visitorlocation'] ) && '1' === $av['visitorlocation'] ) {
796 + echo 'checked="checked"';}
797 + ?>
798 + onchange="vlocfields_update();" /><b><?php echo esc_attr__( 'Use visitors location', 'wp-forecast' ); ?></b>
482 799 </p>
483 800
484 - <p><input type="checkbox" name="currtime" value="1" <?php if ($currtime=="1") echo "checked=\"checked\""?> /> <b><?php echo __('Use current time',"wp-forecast_".$locale)?></b>
485 - </p>
801 + <p><b><?php echo esc_attr__( 'Latitude', 'wp-forecast' ); ?>:</b>
802 + <input name="loclatitude" id="loclatitude" type="text" size="15" maxlength="10"
803 + value="<?php echo ( isset( $av['loclatitude'] ) ? esc_attr( $av['loclatitude'] ) : '' ); ?>" />
804 +
805 + <b><?php echo esc_attr__( 'Longitude', 'wp-forecast' ); ?>:</b>
806 + <input name="loclongitude" id="loclongitude" type="text" size="15" maxlength="10"
807 + value="<?php echo ( isset( $av['loclongitude'] ) ? esc_attr( $av['loclongitude'] ) : '' ); ?>" /></p>
808 +
809 + <p><b><?php echo esc_attr__( 'Locationname', 'wp-forecast' ); ?>:</b>
810 + <input name="locname" id="locname" type="text" size="30" maxlength="80" value="<?php echo esc_attr( $av['locname'] ); ?>" /></p>
811 + <p><b><?php echo esc_attr__( 'Refresh cache after', 'wp-forecast' ); ?></b>
812 + <input name="refresh" id="refresh" type="text" size="10" maxlength="6" value="<?php echo esc_attr( $av['refresh'] ); ?>"/>
813 + <b><?php echo esc_attr__( 'secs.', 'wp-forecast' ); ?></b><br /></p>
814 + <p><input type="checkbox" name="metric" id="metric" value="1"
815 + <?php
816 + if ( '1' === $av['metric'] ) {
817 + echo 'checked="checked"';}
818 + ?>
819 + /> <b><?php echo esc_attr__( 'Use metric units', 'wp-forecast' ); ?></b>
820 + </p>
486 821
487 - <p><b><?php echo __('Windspeed-Unit',"wp-forecast_".$locale)?>: </b><select name="windunit" size="1">
488 - <option value="ms" <?php if ($windunit=="ms") echo "selected=\"selected\""?>><?php echo __('Meter/Second (m/s)',"wp-forecast_".$locale)?></option>
489 - <option value="kmh" <?php if ($windunit=="kmh") echo "selected=\"selected\""?>><?php echo __('Kilometer/Hour (km/h)',"wp-forecast_".$locale)?></option>
490 - <option value="mph" <?php if ($windunit=="mph") echo "selected=\"selected\""?>><?php echo __('Miles/Hour (mph)',"wp-forecast_".$locale)?></option>
491 - <option value="kts" <?php if ($windunit=="kts") echo "selected=\"selected\""?>><?php echo __('Knots (kts)',"wp-forecast_".$locale)?></option>
822 + <p><input type="checkbox" name="currtime" id="currtime" value="1"
823 + <?php
824 + if ( '1' === $av['currtime'] ) {
825 + echo 'checked="checked"';
826 + }
827 + ?>
828 + /> <b><?php echo esc_attr__( 'Use current time', 'wp-forecast' ); ?></b> / <b>
829 + <?php echo esc_attr__( 'Time-Offset', 'wp-forecast' ); ?> :</b>
830 + <input type="text" name="timeoffset" id="timeoffset" size="5" maxlength="5" value="<?php echo esc_attr( isset( $av['timeoffset'] ) ? $av['timeoffset'] : '' ); ?>" /> <b><?php echo esc_attr__( 'minutes', 'wp-forecast' ); ?></b>
831 + </p>
832 +
833 + <p><b><?php echo esc_attr__( 'Windspeed-Unit', 'wp-forecast' ); ?>: </b><select name="windunit" id="windunit" size="1">
834 + <option value="ms"
835 + <?php
836 + if ( 'ms' === $av['windunit'] ) {
837 + echo 'selected="selected"';}
838 + ?>
839 + ><?php echo esc_attr__( 'Meter/Second (m/s)', 'wp-forecast' ); ?></option>
840 + <option value="kmh"
841 + <?php
842 + if ( 'kmh' === $av['windunit'] ) {
843 + echo 'selected="selected"';}
844 + ?>
845 + ><?php echo esc_attr__( 'Kilometer/Hour (km/h)', 'wp-forecast' ); ?></option>
846 + <option value="mph"
847 + <?php
848 + if ( 'mph' === $av['windunit'] ) {
849 + echo 'selected="selected"';}
850 + ?>
851 + ><?php echo esc_attr__( 'Miles/Hour (mph)', 'wp-forecast' ); ?></option>
852 + <option value="kts"
853 + <?php
854 + if ( 'kts' === $av['windunit'] ) {
855 + echo 'selected="selected"';}
856 + ?>
857 + ><?php echo esc_attr__( 'Knots (kts)', 'wp-forecast' ); ?></option>
858 + <option value="bft"
859 + <?php
860 + if ( 'bft' === $av['windunit'] ) {
861 + echo 'selected="selected"';}
862 + ?>
863 + ><?php echo esc_attr__( 'Beaufort (bft)', 'wp-forecast' ); ?></option>
492 864 </select></p>
493 865
494 866
867 +
868 +
495 869 <p>
496 - <b><?php echo __('Language',"wp-forecast_".$locale)?>: </b><select name="language" size="1">
497 - <option value="en_US" <?php if ($wpf_language=="en_US") echo "selected=\"selected\""?>>english</option>
498 - <option value="de_DE" <?php if ($wpf_language=="de_DE") echo "selected=\"selected\""?>>deutsch</option>
499 - <option value="da_DK" <?php if ($wpf_language=="da_DK") echo "selected=\"selected\""?>>dansk</option>
500 - <option value="nl_NL" <?php if ($wpf_language=="nl_NL") echo "selected=\"selected\""?>>dutch</option>
501 - <option value="fr_FR" <?php if ($wpf_language=="fr_FR") echo "selected=\"selected\""?>>french</option>
502 - <option value="it_IT" <?php if ($wpf_language=="it_IT") echo "selected=\"selected\""?>>italian</option>
503 - <option value="pt_PT" <?php if ($wpf_language=="pt_PT") echo "selected=\"selected\""?>>portugu&#234;s</option>
504 - <option value="nb_NO" <?php if ($wpf_language=="nb_NO") echo "selected=\"selected\""?>>norwegian</option>
505 - <option value="sv_SE" <?php if ($wpf_language=="sv_SE") echo "selected=\"selected\""?>>swedish</option>
506 -
507 - </select></p>
508 -
509 - <b><?php echo __('Forecast',"wp-forecast_".$locale)?></b>
510 - <table border="1">
511 - <tr>
512 - <td>&nbsp;</td>
513 - <td><?php echo __('Day',"wp-forecast_".$locale)?> 1</td>
514 - <td><?php echo __('Day',"wp-forecast_".$locale)?> 2</td>
515 - <td><?php echo __('Day',"wp-forecast_".$locale)?> 3</td>
516 - <td><?php echo __('Day',"wp-forecast_".$locale)?> 4</td>
517 - <td><?php echo __('Day',"wp-forecast_".$locale)?> 5</td>
518 - <td><?php echo __('Day',"wp-forecast_".$locale)?> 6</td>
519 - <td><?php echo __('Day',"wp-forecast_".$locale)?> 7</td>
520 - <td><?php echo __('Day',"wp-forecast_".$locale)?> 8</td>
521 - <td><?php echo __('Day',"wp-forecast_".$locale)?> 9</td>
522 - </tr>
523 - <tr><td><?php echo __('Daytime',"wp-forecast_".$locale)?></td>
524 - <td><input type="checkbox" name="day1" value="1"
525 - <?php if (substr($daytime,0,1)=="1") echo "checked=\"checked\""?> /></td>
526 - <td><input type="checkbox" name="day2" value="1"
527 - <?php if (substr($daytime,1,1)=="1") echo "checked=\"checked\""?> /></td>
528 - <td><input type="checkbox" name="day3" value="1"
529 - <?php if (substr($daytime,2,1)=="1") echo "checked=\"checked\""?> /></td>
530 - <td><input type="checkbox" name="day4" value="1"
531 - <?php if (substr($daytime,3,1)=="1") echo "checked=\"checked\""?> /></td>
532 - <td><input type="checkbox" name="day5" value="1"
533 - <?php if (substr($daytime,4,1)=="1") echo "checked=\"checked\""?> /></td>
534 - <td><input type="checkbox" name="day6" value="1"
535 - <?php if (substr($daytime,5,1)=="1") echo "checked=\"checked\""?> /></td>
536 - <td><input type="checkbox" name="day7" value="1"
537 - <?php if (substr($daytime,6,1)=="1") echo "checked=\"checked\""?> /></td>
538 - <td><input type="checkbox" name="day8" value="1"
539 - <?php if (substr($daytime,7,1)=="1") echo "checked=\"checked\""?> /></td>
540 - <td><input type="checkbox" name="day9" value="1"
541 - <?php if (substr($daytime,8,1)=="1") echo "checked=\"checked\""?> /></td>
542 - </tr>
543 - <tr><td><?php echo __('Nighttime',"wp-forecast_".$locale)?></td>
544 - <td><input type="checkbox" name="night1" value="1"
545 - <?php if (substr($nighttime,0,1)=="1") echo "checked=\"checked\""?> /></td>
546 - <td><input type="checkbox" name="night2" value="1"
547 - <?php if (substr($nighttime,1,1)=="1") echo "checked=\"checked\""?> /></td>
548 - <td><input type="checkbox" name="night3" value="1"
549 - <?php if (substr($nighttime,2,1)=="1") echo "checked=\"checked\""?> /></td>
550 - <td><input type="checkbox" name="night4" value="1"
551 - <?php if (substr($nighttime,3,1)=="1") echo "checked=\"checked\""?> /></td>
552 - <td><input type="checkbox" name="night5" value="1"
553 - <?php if (substr($nighttime,4,1)=="1") echo "checked=\"checked\""?> /></td>
554 - <td><input type="checkbox" name="night6" value="1"
555 - <?php if (substr($nighttime,5,1)=="1") echo "checked=\"checked\""?> /></td>
556 - <td><input type="checkbox" name="night7" value="1"
557 - <?php if (substr($nighttime,6,1)=="1") echo "checked=\"checked\""?> /></td>
558 - <td><input type="checkbox" name="night8" value="1"
559 - <?php if (substr($nighttime,7,1)=="1") echo "checked=\"checked\""?> /></td>
560 - <td><input type="checkbox" name="night9" value="1"
561 - <?php if (substr($nighttime,8,1)=="1") echo "checked=\"checked\""?> /></td>
562 - </tr>
563 - </table>
564 - <br />
565 - </div>
566 - <div style="padding-left: 2%; float: left; width: 49%;">
567 - <b><?php echo __('Display Configuration',"wp-forecast_".$locale)?></b>
568 - <table border="1">
870 + <b><?php echo esc_attr__( 'Language', 'wp-forecast' ); ?>: </b><select name="wpf_language" id="wpf_language" size="1">
871 + <?php
872 + $iso_arr = array( 'en_US', 'de_DE', 'bg_BG', 'bs_BA', 'hr_HR', 'cs_CZ', 'da_DK', 'nl_NL', 'fi_FI', 'fr_FR', 'el_EL', 'he_IL', 'hu_HU', 'id_ID', 'it_IT', 'nb_NO', 'fa_IR', 'pl_PL', 'pt_PT', 'ro_RO', 'ru_RU', 'sr_SR', 'sk_SK', 'es_ES', 'sv_SE', 'uk_UA' );
873 + $lang_arr = array( 'english', 'deutsch', 'bulgarian', 'bosnian', 'croatian', 'czech', 'dansk', 'dutch', 'finnish', 'french', 'greek', 'hebrew', 'hungarian', 'indonesian', 'italian', 'norwegian', 'persian', 'polish', 'portugu&#234;s', 'romanian', 'russian', 'serbian', 'slovak', 'spanish', 'swedish', 'ukranian' );
874 + $lopt = '';
875 + $num = count( $iso_arr );
876 + for ( $i = 0; $i < $num; $i++ ) {
877 + $lopt .= '<option value="' . $iso_arr[ $i ] . '"';
878 + if ( $av['wpf_language'] == $iso_arr[ $i ] ) {
879 + // space as first characteer is important.
880 + $lopt .= ' selected="selected"';
881 + }
882 + $lopt .= '>' . $lang_arr[ $i ];
883 + $lopt .= '</option>';
884 + }
885 + echo wp_kses( $lopt, wpf_allowed_tags() );
886 + ?>
887 + </select></p>
888 +
889 + <p><input type="checkbox" name="pdforecast" id="pdforecast" value="1"
890 + <?php
891 + if ( '1' === $av['pdforecast'] ) {
892 + echo 'checked="checked"';}
893 + ?>
894 + onchange="pdfields_update();" /> <b><?php echo esc_attr__( 'Show forecast as ajax pull-down', 'wp-forecast' ); ?></b>
895 + </p>
896 +
897 + <p>
898 + <b><?php echo esc_attr__( 'First day in pull-down', 'wp-forecast' ); ?>: </b><select name="pdfirstday" id="pdfirstday" size="1">
899 + <?php
900 + for ( $i = 0; $i < 10; $i++ ) {
901 + echo "<option value='" . esc_attr( $i ) . "'";
902 + if ( $i == $av['pdfirstday'] ) {
903 + echo 'selected="selected"';
904 + }
905 + echo '>' . esc_attr( $i ) . '</option>';
906 + }
907 + ?>
908 + </select></p>
909 + <script type="text/javascript">pdfields_update();</script>
910 +
911 + <p><input type="checkbox" name="fonticon" id="fonticon" value="1" onclick="fonticon_update();"
912 + <?php
913 + if ( '1' === $av['fonticon'] ) {
914 + echo 'checked="checked"';
915 + }
916 + ?>
917 + /> <b><?php echo esc_attr__( 'Use weatherfont for icons', 'wp-forecast' ); ?></b>
918 + <input class="fonticon_color" name="fonticon_color" id="fonticon_color" type="text" value="<?php echo esc_attr( $av['fonticon_color'] ); ?>" />
919 + <b><?php echo esc_attr__( 'Choose color for weatherfont icons', 'wp-forecast' ); ?></b>
920 + </p>
921 +
922 +
923 + <p><input type="checkbox" name="windicon" id="windicon" value="1"
924 + <?php
925 + if ( '1' === $av['windicon'] ) {
926 + echo 'checked="checked"';}
927 + ?>
928 + /> <b><?php echo esc_attr__( 'Show wind condition as icon', 'wp-forecast' ); ?></b>
929 + </p>
930 + <p><input type="checkbox" name="csssprites" id="csssprites" value="1"
931 + <?php
932 + if ( '1' === $av['csssprites'] ) {
933 + echo 'checked="checked"';}
934 + ?>
935 + /> <b><?php echo esc_attr__( 'Use CSS-Sprites for showing icons', 'wp-forecast' ); ?></b>
936 + </p>
937 + </div>
938 + <script type="text/javascript">fonticon_update();</script>
939 + <!-- start of right column -->
940 + <div style="padding-left: 2%; float: left; width: 49%;">
941 + <b><?php echo esc_attr__( 'Display Configuration', 'wp-forecast' ); ?></b>
942 + <table>
569 943 <tr>
570 - <td>&nbsp;</td>
571 - <td><?php echo __('Current Conditions',"wp-forecast_".$locale)?></td>
572 - <td><?php echo __('Forecast Day',"wp-forecast_".$locale)?></td>
573 - <td><?php echo __('Forecast Night',"wp-forecast_".$locale)?></td>
574 - </tr>
575 - <tr>
576 - <td><?php echo __('Icon',"wp-forecast_".$locale)?></td>
577 - <td align='center'><input type="checkbox" name="d_c_icon" value="1"
578 - <?php if (substr($dispconfig,0,1)=="1") echo "checked=\"checked\""?> /></td>
579 - <td align='center'><input type="checkbox" name="d_d_icon" value="1"
580 - <?php if (substr($dispconfig,10,1)=="1") echo "checked=\"checked\""?> /></td>
581 - <td align='center'><input type="checkbox" name="d_n_icon" value="1"
582 - <?php if (substr($dispconfig,14,1)=="1") echo "checked=\"checked\""?> /></td>
583 - </tr>
584 - <tr>
585 - <td><?php echo __('Date',"wp-forecast_".$locale)?></td>
586 - <td align='center'><input type="checkbox" name="d_c_date" value="1"
587 - <?php if (substr($dispconfig,18,1)=="1") echo "checked=\"checked\""?> /></td>
588 - <td align='center'>n/a</td>
589 - <td align='center'>n/a</td>
590 - </tr>
944 + <td>&nbsp;</td>
945 + <td><?php echo esc_attr__( 'Current Conditions', 'wp-forecast' ); ?></td>
946 + <td><?php echo esc_attr__( 'Forecast Day', 'wp-forecast' ); ?></td>
947 + <td><?php echo esc_attr__( 'Forecast Night', 'wp-forecast' ); ?></td>
948 + </tr>
949 + <tr>
950 + <td><?php echo esc_attr__( 'Icon', 'wp-forecast' ); ?></td>
951 + <td class='td-center'><input type="checkbox" name="d_c_icon" id="d_c_icon" value="1"
952 + <?php
953 + if ( substr( $av['dispconfig'], 0, 1 ) == '1' ) {
954 + echo 'checked="checked"';}
955 + ?>
956 + /></td>
957 + <td class='td-center'><input type="checkbox" name="d_d_icon" id="d_d_icon" value="1"
958 + <?php
959 + if ( substr( $av['dispconfig'], 10, 1 ) == '1' ) {
960 + echo 'checked="checked"';}
961 + ?>
962 + /></td>
963 + <td class='td-center'><input type="checkbox" name="d_n_icon" id="d_n_icon" value="1"
964 + <?php
965 + if ( substr( $av['dispconfig'], 14, 1 ) == '1' ) {
966 + echo 'checked="checked"';}
967 + ?>
968 + /></td>
969 + </tr>
970 + <tr>
971 + <td><?php echo esc_attr__( 'Date', 'wp-forecast' ); ?></td>
972 + <td class='td-center'><input type="checkbox" name="d_c_date" id="d_c_date" value="1"
973 + <?php
974 + if ( substr( $av['dispconfig'], 18, 1 ) == '1' ) {
975 + echo 'checked="checked"';}
976 + ?>
977 + /></td>
978 + <td class='td-center'>&nbsp;</td>
979 + <td class='td-center'>&nbsp;</td>
980 + </tr>
591 981 <tr>
592 - <td><?php echo __('Time',"wp-forecast_".$locale)?></td>
593 - <td align='center'><input type="checkbox" name="d_c_time" value="1"
594 - <?php if (substr($dispconfig,1,1)=="1") echo "checked=\"checked\""?> /></td>
595 - <td align='center'>n/a</td>
596 - <td align='center'>n/a</td>
597 - </tr>
598 - <tr>
599 - <td><?php echo __('Short Description',"wp-forecast_".$locale)?></td>
600 - <td align='center'><input type="checkbox" name="d_c_short" value="1"
601 - <?php if (substr($dispconfig,2,1)=="1") echo "checked=\"checked\""?> /></td>
602 - <td align='center'><input type="checkbox" name="d_d_short" value="1"
603 - <?php if (substr($dispconfig,11,1)=="1") echo "checked=\"checked\""?> /></td>
604 - <td align='center'><input type="checkbox" name="d_n_short" value="1"
605 - <?php if (substr($dispconfig,15,1)=="1") echo "checked=\"checked\""?> /></td>
606 - </tr>
607 - <tr>
608 - <td><?php echo __('Temperature',"wp-forecast_".$locale)?></td>
609 - <td align='center'><input type="checkbox" name="d_c_temp" value="1"
610 - <?php if (substr($dispconfig,3,1)=="1") echo "checked=\"checked\""?> /></td>
611 - <td align='center'><input type="checkbox" name="d_d_temp" value="1"
612 - <?php if (substr($dispconfig,12,1)=="1") echo "checked=\"checked\""?> /></td>
613 - <td align='center'><input type="checkbox" name="d_n_temp" value="1"
614 - <?php if (substr($dispconfig,16,1)=="1") echo "checked=\"checked\""?> /></td>
615 - </tr>
616 - <tr>
617 - <td><?php echo __('Realfeel',"wp-forecast_".$locale)?></td>
618 - <td align='center'><input type="checkbox" name="d_c_real" value="1"
619 - <?php if (substr($dispconfig,4,1)=="1") echo "checked=\"checked\""?> /></td>
620 - <td align='center'>n/a</td>
621 - <td align='center'>n/a</td>
622 - </tr>
623 - <tr>
624 - <td><?php echo __('Pressure',"wp-forecast_".$locale)?></td>
625 - <td align='center'><input type="checkbox" name="d_c_press" value="1"
626 - <?php if (substr($dispconfig,5,1)=="1") echo "checked=\"checked\""?> /></td>
627 - <td align='center'>n/a</td>
628 - <td align='center'>n/a</td>
629 - </tr>
630 - <tr>
631 - <td><?php echo __('Humidity',"wp-forecast_".$locale)?></td>
632 - <td align='center'><input type="checkbox" name="d_c_humid" value="1"
633 - <?php if (substr($dispconfig,6,1)=="1") echo "checked=\"checked\""?> /></td>
634 - <td align='center'>n/a</td>
635 - <td align='center'>n/a</td>
636 - </tr>
637 - <tr>
638 - <td><?php echo __('Wind',"wp-forecast_".$locale)?></td>
639 - <td align='center'><input type="checkbox" name="d_c_wind" value="1"
640 - <?php if (substr($dispconfig,7,1)=="1") echo "checked=\"checked\""?> /></td>
641 - <td align='center'><input type="checkbox" name="d_d_wind" value="1"
642 - <?php if (substr($dispconfig,13,1)=="1") echo "checked=\"checked\""?> /></td>
643 - <td align='center'><input type="checkbox" name="d_n_wind" value="1"
644 - <?php if (substr($dispconfig,17,1)=="1") echo "checked=\"checked\""?> /></td>
645 - </tr>
982 + <td><?php echo esc_attr__( 'Time', 'wp-forecast' ); ?></td>
983 + <td class='td-center'><input type="checkbox" name="d_c_time" id="d_c_time" value="1"
984 + <?php
985 + if ( substr( $av['dispconfig'], 1, 1 ) == '1' ) {
986 + echo 'checked="checked"';}
987 + ?>
988 + /></td>
989 + <td class='td-center'>&nbsp;</td>
990 + <td class='td-center'>&nbsp;</td>
991 + </tr>
992 + <tr>
993 + <td><?php echo esc_attr__( 'Short Description', 'wp-forecast' ); ?></td>
994 + <td class='td-center'><input type="checkbox" name="d_c_short" id="d_c_short" value="1"
995 + <?php
996 + if ( substr( $av['dispconfig'], 2, 1 ) == '1' ) {
997 + echo 'checked="checked"';}
998 + ?>
999 + /></td>
1000 + <td class='td-center'><input type="checkbox" name="d_d_short" id="d_d_short" value="1"
1001 + <?php
1002 + if ( substr( $av['dispconfig'], 11, 1 ) == '1' ) {
1003 + echo 'checked="checked"';}
1004 + ?>
1005 + /></td>
1006 + <td class='td-center'><input type="checkbox" name="d_n_short" id="d_n_short" value="1"
1007 + <?php
1008 + if ( substr( $av['dispconfig'], 15, 1 ) == '1' ) {
1009 + echo 'checked="checked"';}
1010 + ?>
1011 + /></td>
1012 + </tr>
1013 + <tr>
1014 + <td><?php echo esc_attr__( 'Temperature', 'wp-forecast' ); ?></td>
1015 + <td class='td-center'><input type="checkbox" name="d_c_temp" id="d_c_temp" value="1"
1016 + <?php
1017 + if ( substr( $av['dispconfig'], 3, 1 ) == '1' ) {
1018 + echo 'checked="checked"';}
1019 + ?>
1020 + /></td>
1021 + <td class='td-center'><input type="checkbox" name="d_d_temp" id="d_d_temp" value="1"
1022 + <?php
1023 + if ( substr( $av['dispconfig'], 12, 1 ) == '1' ) {
1024 + echo 'checked="checked"';}
1025 + ?>
1026 + /></td>
1027 + <td class='td-center'><input type="checkbox" name="d_n_temp" id="d_n_temp" value="1"
1028 + <?php
1029 + if ( substr( $av['dispconfig'], 16, 1 ) == '1' ) {
1030 + echo 'checked="checked"';}
1031 + ?>
1032 + /></td>
1033 + </tr>
1034 + <tr>
1035 + <td><?php echo esc_attr__( 'Realfeel', 'wp-forecast' ); ?></td>
1036 + <td class='td-center'><input type="checkbox" name="d_c_real" id="d_c_real" value="1"
1037 + <?php
1038 + if ( substr( $av['dispconfig'], 4, 1 ) == '1' ) {
1039 + echo 'checked="checked"';}
1040 + ?>
1041 + /></td>
1042 + <td class='td-center'>&nbsp;</td>
1043 + <td class='td-center'>&nbsp;</td>
1044 + </tr>
1045 + <tr>
1046 + <td><?php echo esc_attr__( 'Pressure', 'wp-forecast' ); ?></td>
1047 + <td class='td-center'><input type="checkbox" name="d_c_press" id="d_c_press" value="1"
1048 + <?php
1049 + if ( substr( $av['dispconfig'], 5, 1 ) == '1' ) {
1050 + echo 'checked="checked"';}
1051 + ?>
1052 + /></td>
1053 + <td class='td-center'>&nbsp;</td>
1054 + <td class='td-center'>&nbsp;</td>
1055 + </tr>
1056 + <tr>
1057 + <td><?php echo esc_attr__( 'Humidity', 'wp-forecast' ); ?></td>
1058 + <td class='td-center'><input type="checkbox" name="d_c_humid" id="d_c_humid" value="1"
1059 + <?php
1060 + if ( substr( $av['dispconfig'], 6, 1 ) == '1' ) {
1061 + echo 'checked="checked"';}
1062 + ?>
1063 + /></td>
1064 + <td class='td-center'>&nbsp;</td>
1065 + <td class='td-center'>&nbsp;</td>
1066 + </tr>
1067 + <tr>
1068 + <td><?php echo esc_attr__( 'Wind', 'wp-forecast' ); ?></td>
1069 + <td class='td-center'><input type="checkbox" name="d_c_wind" id="d_c_wind" value="1"
1070 + <?php
1071 + if ( substr( $av['dispconfig'], 7, 1 ) == '1' ) {
1072 + echo 'checked="checked"';}
1073 + ?>
1074 + /></td>
1075 + <td class='td-center'><input type="checkbox" name="d_d_wind" id="d_d_wind" value="1"
1076 + <?php
1077 + if ( substr( $av['dispconfig'], 13, 1 ) == '1' ) {
1078 + echo 'checked="checked"';}
1079 + ?>
1080 + /></td>
1081 + <td class='td-center'><input type="checkbox" name="d_n_wind" id="d_n_wind" value="1"
1082 + <?php
1083 + if ( substr( $av['dispconfig'], 17, 1 ) == '1' ) {
1084 + echo 'checked="checked"';}
1085 + ?>
1086 + /></td>
1087 + </tr>
646 1088 <tr>
647 - <td><?php echo __('Windgusts',"wp-forecast_".$locale)?></td>
648 - <td align='center'><input type="checkbox" name="d_c_wgusts" value="1"
649 - <?php if (substr($dispconfig,22,1)=="1") echo "checked=\"checked\""?> /></td>
650 - <td align='center'><input type="checkbox" name="d_d_wgusts" value="1"
651 - <?php if (substr($dispconfig,23,1)=="1") echo "checked=\"checked\""?> /></td>
652 - <td align='center'><input type="checkbox" name="d_n_wgusts" value="1"
653 - <?php if (substr($dispconfig,24,1)=="1") echo "checked=\"checked\""?> /></td>
654 - </tr>
1089 + <td><?php echo esc_attr__( 'Windgusts', 'wp-forecast' ); ?></td>
1090 + <td class='td-center'><input type="checkbox" name="d_c_wgusts" id="d_c_wgusts" value="1"
1091 + <?php
1092 + if ( substr( $av['dispconfig'], 22, 1 ) == '1' ) {
1093 + echo 'checked="checked"';}
1094 + ?>
1095 + /></td>
1096 + <td class='td-center'><input type="checkbox" name="d_d_wgusts" id="d_d_wgusts" value="1"
1097 + <?php
1098 + if ( substr( $av['dispconfig'], 23, 1 ) == '1' ) {
1099 + echo 'checked="checked"';}
1100 + ?>
1101 + /></td>
1102 + <td class='td-center'><input type="checkbox" name="d_n_wgusts" id="d_n_wgusts" value="1"
1103 + <?php
1104 + if ( substr( $av['dispconfig'], 24, 1 ) == '1' ) {
1105 + echo 'checked="checked"';}
1106 + ?>
1107 + /></td>
1108 + </tr>
1109 +
1110 + <tr>
1111 + <td><?php echo esc_attr__( 'Precipitation', 'wp-forecast' ); ?></td>
1112 + <td class='td-center'><input type="checkbox" name="d_c_precipe" id="d_c_precipe" value="1"
1113 + <?php
1114 + if ( substr( $av['dispconfig'], 30, 1 ) == '1' ) {
1115 + echo 'checked="checked"';}
1116 + ?>
1117 + /></td>
1118 + <td class='td-center'><input type="checkbox" name="d_d_precipe" id="d_d_precipe" value="1"
1119 + <?php
1120 + if ( substr( $av['dispconfig'], 31, 1 ) == '1' ) {
1121 + echo 'checked="checked"';}
1122 + ?>
1123 + /></td>
1124 + <td class='td-center'><input type="checkbox" name="d_n_precipe" id="d_n_precipe" value="1"
1125 + <?php
1126 + if ( substr( $av['dispconfig'], 32, 1 ) == '1' ) {
1127 + echo 'checked="checked"';}
1128 + ?>
1129 + /></td>
1130 + </tr>
1131 +
1132 + <tr>
1133 + <td><?php echo esc_attr__( 'UV-Index', 'wp-forecast' ); ?></td>
1134 + <td class='td-center'><input type="checkbox" name="d_c_uvindex" id="d_c_uvindex" value="1"
1135 + <?php
1136 + if ( substr( $av['dispconfig'], 27, 1 ) == '1' ) {
1137 + echo 'checked="checked"';}
1138 + ?>
1139 + /></td>
1140 + <td class='td-center'><input type="checkbox" name="d_d_maxuv" id="d_d_maxuv" value="1"
1141 + <?php
1142 + if ( substr( $av['dispconfig'], 28, 1 ) == '1' ) {
1143 + echo 'checked="checked"';}
1144 + ?>
1145 + /></td>
1146 + <td class='td-center'><input type="checkbox" name="d_n_maxuv" id="d_n_maxuv" value="1"
1147 + <?php
1148 + if ( substr( $av['dispconfig'], 29, 1 ) == '1' ) {
1149 + echo 'checked="checked"';}
1150 + ?>
1151 + /></td>
1152 + </tr>
1153 +
655 1154 <tr>
656 - <td><?php echo __('Sunrise',"wp-forecast_".$locale)?></td>
657 - <td align='center'><input type="checkbox" name="d_c_sunrise" value="1"
658 - <?php if (substr($dispconfig,8,1)=="1") echo "checked=\"checked\""?> /></td>
659 - <td align='center'>n/a</td>
660 - <td align='center'>n/a</td>
661 - </tr>
662 - <tr>
663 - <td><?php echo __('Sunset',"wp-forecast_".$locale)?></td>
664 - <td align='center'><input type="checkbox" name="d_c_sunset" value="1"
665 - <?php if (substr($dispconfig,9,1)=="1") echo "checked=\"checked\""?> /></td>
666 - <td align='center'>n/a</td>
667 - <td align='center'>n/a</td>
668 - </tr>
669 - <tr>
670 - <td><?php echo __('Copyright',"wp-forecast_".$locale)?></td>
671 - <td align='center'><input type="checkbox" name="d_c_copyright" value="1"
672 - <?php if (substr($dispconfig,21,1)=="1") echo "checked=\"checked\""?> /></td>
673 - <td align='center'>n/a</td>
674 - <td align='center'>n/a</td>
675 - </tr>
1155 + <td><?php echo esc_attr__( 'Sunrise', 'wp-forecast' ); ?></td>
1156 + <td class='td-center'><input type="checkbox" name="d_c_sunrise" id="d_c_sunrise" value="1"
1157 + <?php
1158 + if ( substr( $av['dispconfig'], 8, 1 ) == '1' ) {
1159 + echo 'checked="checked"';}
1160 + ?>
1161 + /></td>
1162 + <td class='td-center'>&nbsp;</td>
1163 + <td class='td-center'>&nbsp;</td>
1164 + </tr>
1165 + <tr>
1166 + <td><?php echo esc_attr__( 'Sunset', 'wp-forecast' ); ?></td>
1167 + <td class='td-center'><input type="checkbox" name="d_c_sunset" id="d_c_sunset" value="1"
1168 + <?php
1169 + if ( substr( $av['dispconfig'], 9, 1 ) == '1' ) {
1170 + echo 'checked="checked"';}
1171 + ?>
1172 + /></td>
1173 + <td class='td-center'>&nbsp;</td>
1174 + <td class='td-center'>&nbsp;</td>
1175 + </tr>
1176 + <tr>
1177 + <td><?php echo esc_attr__( 'Copyright', 'wp-forecast' ); ?></td>
1178 + <td class='td-center'><input type="checkbox" name="d_c_copyright" id="d_c_copyright" value="1"
1179 + <?php
1180 + if ( substr( $av['dispconfig'], 21, 1 ) == '1' ) {
1181 + echo 'checked="checked"';}
1182 + ?>
1183 + /></td>
1184 + <td class='td-center'>&nbsp;</td>
1185 + <td class='td-center'>&nbsp;</td>
1186 + </tr>
676 1187 <tr>
677 - <td><?php echo __('Link to Accuweather',"wp-forecast_".$locale)?></td>
678 - <td align='center'><input type="checkbox" name="d_c_accuweather" value="1"
679 - <?php if (substr($dispconfig,25,1)=="1") echo "checked=\"checked\""?> /></td>
680 - <td align='center'>n/a</td>
681 - <td align='center'>n/a</td>
682 - </tr>
683 - </table>
1188 + <td><?php echo esc_attr__( 'Link to Weatherprovider', 'wp-forecast' ); ?></td>
1189 + <td class='td-center'><input type="checkbox" name="d_c_accuweather" id="d_c_accuweather" value="1"
1190 + <?php
1191 + if ( substr( $av['dispconfig'], 25, 1 ) == '1' ) {
1192 + echo 'checked="checked"';}
1193 + ?>
1194 + onchange="nwfields_update();" /></td>
1195 + <td colspan="2" >(<?php echo esc_attr__( 'Open in new Window', 'wp-forecast' ); ?>:
1196 + <input type="checkbox" name="d_c_aw_newwindow" id="d_c_aw_newwindow" value="1"
1197 + <?php
1198 + if ( substr( $av['dispconfig'], 26, 1 ) == '1' ) {
1199 + echo 'checked="checked"';}
1200 + ?>
1201 + />)</td>
1202 + </tr>
1203 + </table>
684 1204 <br />
685 - </div>
686 - <?php if ($widgetcall==0): ?></fieldset><?php endif; ?>
687 -<?php
688 - if ($widgetcall ==0)
689 - echo "<div class='submit'><input type='submit' name='info_update' value='".__('Update options',"wp-forecast_".$locale)." »' /></div>";
690 - else
691 - echo "<input type='hidden' name='info_update' value='1' />";
1205 + <script type="text/javascript">nwfields_update();</script>
692 1206
1207 +<b><?php echo esc_attr__( 'Forecast', 'wp-forecast' ); ?></b>
1208 +
1209 + <table>
1210 + <tr>
1211 + <td>&nbsp;</td>
1212 + <td><?php echo esc_attr__( 'All', 'wp-forecast' ); ?></td>
1213 + <td><?php echo esc_attr__( 'Day', 'wp-forecast' ); ?> 1</td>
1214 + <td><?php echo esc_attr__( 'Day', 'wp-forecast' ); ?> 2</td>
1215 + <td><?php echo esc_attr__( 'Day', 'wp-forecast' ); ?> 3</td>
1216 + <td><?php echo esc_attr__( 'Day', 'wp-forecast' ); ?> 4</td>
1217 + <td><?php echo esc_attr__( 'Day', 'wp-forecast' ); ?> 5</td>
1218 + <td><?php echo esc_attr__( 'Day', 'wp-forecast' ); ?> 6</td>
1219 + <td><?php echo esc_attr__( 'Day', 'wp-forecast' ); ?> 7</td>
1220 + <td><?php echo esc_attr__( 'Day', 'wp-forecast' ); ?> 8</td>
1221 + <td><?php echo esc_attr__( 'Day', 'wp-forecast' ); ?> 9</td>
1222 + </tr>
1223 + <tr><td><?php echo esc_attr__( 'Daytime', 'wp-forecast' ); ?></td>
1224 + <td><input type="checkbox" name="alldays" onclick="this.value=check('day')" /></td>
1225 + <td><input type="checkbox" name="day1" id="day1" value="1"
1226 + <?php
1227 + if ( substr( $av['daytime'], 0, 1 ) == '1' ) {
1228 + echo 'checked="checked"';}
1229 + ?>
1230 + /></td>
1231 + <td><input type="checkbox" name="day2" id="day2" value="1"
1232 + <?php
1233 + if ( substr( $av['daytime'], 1, 1 ) == '1' ) {
1234 + echo 'checked="checked"';}
1235 + ?>
1236 + /></td>
1237 + <td><input type="checkbox" name="day3" id="day3" value="1"
1238 + <?php
1239 + if ( substr( $av['daytime'], 2, 1 ) == '1' ) {
1240 + echo 'checked="checked"';}
1241 + ?>
1242 + /></td>
1243 + <td><input type="checkbox" name="day4" id="day4" value="1"
1244 + <?php
1245 + if ( substr( $av['daytime'], 3, 1 ) == '1' ) {
1246 + echo 'checked="checked"';}
1247 + ?>
1248 + /></td>
1249 + <td><input type="checkbox" name="day5" id="day5" value="1"
1250 + <?php
1251 + if ( substr( $av['daytime'], 4, 1 ) == '1' ) {
1252 + echo 'checked="checked"';}
1253 + ?>
1254 + /></td>
1255 + <td><input type="checkbox" name="day6" id="day6" value="1"
1256 + <?php
1257 + if ( substr( $av['daytime'], 5, 1 ) == '1' ) {
1258 + echo 'checked="checked"';}
1259 + ?>
1260 + /></td>
1261 + <td><input type="checkbox" name="day7" id="day7" value="1"
1262 + <?php
1263 + if ( substr( $av['daytime'], 6, 1 ) == '1' ) {
1264 + echo 'checked="checked"';}
1265 + ?>
1266 + /></td>
1267 + <td><input type="checkbox" name="day8" id="day8" value="1"
1268 + <?php
1269 + if ( substr( $av['daytime'], 7, 1 ) == '1' ) {
1270 + echo 'checked="checked"';}
1271 + ?>
1272 + /></td>
1273 + <td><input type="checkbox" name="day9" id="day9" value="1"
1274 + <?php
1275 + if ( substr( $av['daytime'], 8, 1 ) == '1' ) {
1276 + echo 'checked="checked"';}
1277 + ?>
1278 + /></td>
1279 + </tr>
1280 + <tr><td><?php echo esc_attr__( 'Nighttime', 'wp-forecast' ); ?></td>
1281 + <td><input type="checkbox" name="allnight" onclick="this.value=check('night')" /></td>
1282 + <td><input type="checkbox" name="night1" id="night1" value="1"
1283 + <?php
1284 + if ( substr( $av['nighttime'], 0, 1 ) == '1' ) {
1285 + echo 'checked="checked"';}
1286 + ?>
1287 + /></td>
1288 + <td><input type="checkbox" name="night2" id="night2" value="1"
1289 + <?php
1290 + if ( substr( $av['nighttime'], 1, 1 ) == '1' ) {
1291 + echo 'checked="checked"';}
1292 + ?>
1293 + /></td>
1294 + <td><input type="checkbox" name="night3" id="night3" value="1"
1295 + <?php
1296 + if ( substr( $av['nighttime'], 2, 1 ) == '1' ) {
1297 + echo 'checked="checked"';}
1298 + ?>
1299 + /></td>
1300 + <td><input type="checkbox" name="night4" id="night4" value="1"
1301 + <?php
1302 + if ( substr( $av['nighttime'], 3, 1 ) == '1' ) {
1303 + echo 'checked="checked"';}
1304 + ?>
1305 + /></td>
1306 + <td><input type="checkbox" name="night5" id="night5" value="1"
1307 + <?php
1308 + if ( substr( $av['nighttime'], 4, 1 ) == '1' ) {
1309 + echo 'checked="checked"';}
1310 + ?>
1311 + /></td>
1312 + <td><input type="checkbox" name="night6" id="night6" value="1"
1313 + <?php
1314 + if ( substr( $av['nighttime'], 5, 1 ) == '1' ) {
1315 + echo 'checked="checked"';}
1316 + ?>
1317 + /></td>
1318 + <td><input type="checkbox" name="night7" id="night7" value="1"
1319 + <?php
1320 + if ( substr( $av['nighttime'], 6, 1 ) == '1' ) {
1321 + echo 'checked="checked"';}
1322 + ?>
1323 + /></td>
1324 + <td><input type="checkbox" name="night8" id="night8" value="1"
1325 + <?php
1326 + if ( substr( $av['nighttime'], 7, 1 ) == '1' ) {
1327 + echo 'checked="checked"';}
1328 + ?>
1329 + /></td>
1330 + <td><input type="checkbox" name="night9" id="night9" value="1"
1331 + <?php
1332 + if ( substr( $av['nighttime'], 8, 1 ) == '1' ) {
1333 + echo 'checked="checked"';}
1334 + ?>
1335 + /></td>
1336 + </tr>
1337 + </table>
1338 + </div>
1339 +
1340 + <?php
1341 + if ( 0 === $widgetcall ) :
1342 + ?>
1343 + </fieldset><?php endif; ?>
1344 +
1345 + <?php
1346 + // OpenUV parameters.
1347 + echo '<div>';
1348 + echo "<b><a href='http://www.openuv.io' target='_blank'>" . esc_attr__( 'Use UV-Data from openuv.io', 'wp-forecast' ) . ':</a></b>&nbsp;&nbsp;&nbsp;';
693 1349
694 - if ($widgetcall==0) {
695 - echo "<hr /><fieldset id=\"set2\"><legend>".__('Search location',"wp-forecast_".$locale)."</legend><br />";
1350 + echo esc_attr__( 'OpenUV - API-Key', 'wp-forecast' );
1351 + echo ':<input name="ouv_apikey" id="ouv_apikey" type="text" size="40" maxlength="80" value="' . ( isset( $av['ouv_apikey'] ) ? esc_attr( $av['ouv_apikey'] ) : '' ) . '" />&nbsp;&nbsp;&nbsp;';
696 1352
697 - if (count($loc)<=0) {
698 - echo "<p><b>".__('Searchterm',"wp-forecast_".$locale).":</b>\n";
699 - echo "<input name=\"searchloc\" type=\"text\" size=\"30\" maxlength=\"30\" /><br /></p>\n";
700 - if (isset($_POST['search_loc'])) {
701 - echo "<p>".__('No locations found.',"wp-forecast_".$locale)."</p>";
702 - } else {
703 - echo "<p>".__('Please replace german Umlaute ä,ö,ü with a, o, u in your searchterm.',"wp-forecast_".$locale)."</p>";
704 - }
705 -
706 - echo "</fieldset>\n";
707 - echo "<div class=\"submit\">\n";
708 - echo "<input type=\"submit\" name=\"search_loc\" value=\"" ;
709 - echo __('Search location',"wp-forecast_".$locale);
710 - echo " »\" />\n";
711 - } else {
712 - echo "<b>".__('Search result',"wp-forecast_".$locale).": </b><select name=\"newloc\" size=\"1\">\n";
713 - foreach ($loc as $l) {
714 - echo "<option value=\"".$l['location']."\">";
715 - echo $l['city']."/".$l['state'];
716 - echo "</option>\n";
717 - }
718 - echo "</select><br /><p>".__('Please select your city and press set location.',"wp-forecast_".$locale)."</p>\n";
719 - echo "</fieldset>\n";
720 - echo "<div class=\"submit\">\n";
721 - echo "<input type=\"submit\" name=\"set_loc\" value=\"" ;
722 - echo __('Set location',"wp-forecast_".$locale);
723 - echo " »\" />\n";
724 - }
725 - echo "</div></form></div>";
726 - }
1353 + echo '<input type="checkbox" name="ouv_uv" id="oav_uv" value="1"';
1354 + if ( isset( $av['ouv_uv'] ) && '1' === $av['ouv_uv'] ) {
1355 + echo 'checked="checked"';
1356 + }
1357 + echo '/>';
1358 + echo '<label for="oav_uv">' . esc_attr__( 'Show UV-Index', 'wp-forecast' ) . '&nbsp;&nbsp;&nbsp;</label>';
727 1359
728 - if ($wpf_debug > 0)
729 - pdebug("End of wpf_sub_admin_form ()");
1360 + echo '<input type="checkbox" name="ouv_uvmax" id="oav_uvmax" value="1"';
1361 + if ( isset( $av['ouv_uvmax'] ) && '1' === $av['ouv_uvmax'] ) {
1362 + echo 'checked="checked"';
1363 + }
1364 + echo '/>';
1365 + echo '<label for="oav_uvmax">' . esc_attr__( 'Show max. UV-Index', 'wp-forecast' ) . '&nbsp;&nbsp;&nbsp;</label>';
1366 +
1367 + echo '<input type="checkbox" name="ouv_ozone" id="oav_ozone" value="1"';
1368 + if ( isset( $av['ouv_ozone'] ) && '1' === $av['ouv_ozone'] ) {
1369 + echo 'checked="checked"';
1370 + }
1371 + echo '/>';
1372 + echo '<label for="oav_ozone">' . esc_attr__( 'Show Ozone', 'wp-forecast' ) . '&nbsp;&nbsp;&nbsp;</label>';
1373 +
1374 + echo '<input type="checkbox" name="ouv_alticons" id="oav_alticons" value="1"';
1375 + if ( isset( $av['ouv_alticons'] ) && '1' === $av['ouv_alticons'] ) {
1376 + echo 'checked="checked"';
1377 + }
1378 + echo '/>';
1379 + echo '<label for="oav_alticons">' . esc_attr__( 'Show alternative UV-icons', 'wp-forecast' ) . '&nbsp;&nbsp;&nbsp;</label>';
1380 +
1381 + echo '</div>';
1382 + ?>
1383 +
1384 + <?php
1385 + // submit button.
1386 + if ( 0 === $widgetcall ) {
1387 + echo "<div class='submit'><input class='button-primary' type='submit' name='info_update' value='" . esc_attr__( 'Update options', 'wp-forecast' ) . " »' /></div>";
1388 + } else {
1389 + echo "<input type='hidden' name='info_update' value='1' />";
1390 + }
1391 + ?>
1392 +
1393 + </form>
1394 +
1395 + <!-- -- ANFANG Suchdialog -->
1396 + <div id="wpf_search__" style="display:none">
1397 + <div class='wpf-search'>
1398 + <form action='#' onsubmit="wpf_search(); return false;">
1399 + <input name="wpf_nonce_3" id="wpf_nonce_3" type="hidden" value="<?php echo esc_attr( wp_create_nonce( 'wpf_nonce_3' ) ); ?>" />
1400 + <?php
1401 + // get locale.
1402 + $locale = get_locale();
1403 + if ( empty( $locale ) ) {
1404 + $locale = 'en_US';
1405 + }
1406 + ?>
1407 + <input id='wpf_search_language' type='hidden' value='<?php echo esc_attr( $locale ); ?>' />
1408 + <input id='wpfcid' type='hidden' value='<?php echo esc_attr( $wpfcid ); ?>' />
1409 +
1410 + <h3><?php esc_attr_e( 'Search location', 'wp-forecast' ); ?></h3>
1411 + <p><b><?php esc_attr_e( 'Searchterm', 'wp-forecast' ); ?>:</b>
1412 + <input id="searchloc" type="text" size="30" maxlength="30" />
1413 + <a href="#" class='button-primary' style="color:#ffffff;" onclick='javascript:wpf_search();' id='search_loc'><?php esc_attr_e( 'Search location', 'wp-forecast' ); ?> »</a>
1414 + <br /></p>
1415 + <p><?php esc_attr_e( 'The search will be performed using OpenMeteo location database.', 'wp-forecast' ); ?></p>
1416 + </form>
1417 + </div>
1418 + <hr />
1419 + <div id="search_results"></div>
1420 + </div>
1421 + <!-- -- ENDE Suchdialog-->
1422 +
1423 + <!-- -- ANFANG Check Dialog -->
1424 + <div id="wpf_check__" style="display:none">
1425 + <style>#message {margin:20px; padding:20px; background:#cccccc; color:#cc0000;}</style>
1426 +
1427 + <div id="checkform" class="wrap" >
1428 + <h2>
1429 + <?php
1430 + echo 'wp-forecast ';
1431 + esc_attr_e( 'Connection-check', 'wp-forecast' );
1432 + ?>
1433 + </h2>
1434 + <p><?php esc_attr_e( 'For OpenWeatherMap please enter your API-Key for Widget A before starting the connection test.', 'wp-forecast' ); ?></p>
1435 + <form action='#' onsubmit="wpf_check(); return false;">
1436 + <input name="wpf_nonce_3" type="hidden" value="<?php echo esc_attr( wp_create_nonce( 'wpf_nonce_3' ) ); ?>" />
1437 + <table class="editform" cellspacing="5" cellpadding="5">
1438 + <tr>
1439 + <th scope="row"><label for="wprovider"><?php esc_attr_e( 'Select weatherprovider', 'wp-forecast' ); ?>:</label></th>
1440 + <td><select name="wprovider" id="wprovider">
1441 + <option value='Open-Meteo'>Open-Meteo</option>
1442 + <option value='OpenWeatherMap'>OpenWeatherMap</option>
1443 + <option value='OpenWeatherMapV3'>OpenWeatherMapV3</option>
1444 + </select></td>
1445 +
1446 + <tr><td><p class="submit">
1447 + <input type="submit" name="startcheck" id="startcheck" value="<?php echo esc_attr_e( 'Start check', 'wp-forecast' ); ?> &raquo;" />
1448 + <td><p class="submit">
1449 + <input type="submit" name="cancel" id="cancel" value="<?php esc_attr_e( 'Close', 'wp-forecast' ); ?>" onclick="jQuery('div#check_log').html('');tb_remove();" /></p></td>
1450 + </p></td></tr>
1451 + </form></table>
1452 + <hr />
1453 +
1454 + <div id="check_log">Check log</div></div>
1455 + </div>
1456 + <!-- -- ENDE Check Dialog -->
1457 +
1458 +
1459 +
1460 + </div>
1461 + <?php
1462 + echo '<script type="text/javascript">jQuery( document ).ready( function() { apifields(document.woptions.service.value); vlocfields_update();});';
1463 + echo '</script>';
730 1464 }
731 -?>
1465 +
1466 +/**
1467 + * Add contextual help to WordPress admin Help menu.
1468 + */
1469 +function wp_forecast_contextual_help() {
1470 +
1471 + $locale = get_locale();
1472 + if ( empty( $locale ) ) {
1473 + $locale = 'en_US';
1474 + }
1475 +
1476 + if ( function_exists( 'load_plugin_textdomain' ) ) {
1477 + load_plugin_textdomain( 'wp-forecast', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
1478 + }
1479 +
1480 + $contextual_help = '<p>';
1481 + $contextual_help .= esc_attr__(
1482 + 'If you are looking for instructions or help on wp-forecast,
1483 + please use the following ressources. If you are stuck you can
1484 + always write an email to',
1485 + 'wp-forecast'
1486 + );
1487 + $contextual_help .= ' <a href="mailto:[email protected]">[email protected]</a>.';
1488 + $contextual_help .= '</p>';
1489 + $contextual_help .= '<ul>';
1490 + $contextual_help .= '<li><a href="http://www.tuxlog.de/wordpress/2008/wp-forecast-reference-v17-english/" target="_blank">';
1491 + $contextual_help .= esc_attr__( 'English Manual', 'wp-forecast' );
1492 + $contextual_help .= '</a></li>';
1493 + $contextual_help .= '<li><a href=" http://www.tuxlog.de/wp-forecast-handbuch/" target="_blank">';
1494 + $contextual_help .= esc_attr__( 'German Manual', 'wp-forecast' );
1495 + $contextual_help .= '</a></li>';
1496 + $contextual_help .= '<li><a href="http://www.tuxlog.de/wordpress/2009/checkliste-fur-wp-forecast-checklist-for-wp-worecast" target="_blank">';
1497 + $contextual_help .= esc_attr__( 'Checklist for connection test', 'wp-forecast' );
1498 + $contextual_help .= '</a></li>';
1499 + $contextual_help .= '<li><a href="http://www.wordpress.org/extend/plugins/wp-forecast" target="_blank">';
1500 + $contextual_help .= esc_attr__( 'wp-forecast on WordPress.org', 'wp-forecast' );
1501 + $contextual_help .= '</a></li>';
1502 + $contextual_help .= '<li><a href="http://www.tuxlog.de/wp-forecast/" target="_blank">';
1503 + $contextual_help .= esc_attr__( 'German wp-forecast Site', 'wp-forecast' );
1504 + $contextual_help .= '</a></li>';
1505 + $contextual_help .= '<li><a href="http://www.tuxlog.de/wordpress/2012/wp-forecast-mit-wpml-nutzen" target="_blank">';
1506 + $contextual_help .= esc_attr__( 'Using wp-forecast with WPML (german)', 'wp-forecast' );
1507 + $contextual_help .= '</a></li>';
1508 + $contextual_help .= '<li><a href="http://wordpress.org/plugins/wp-forecast/changelog/" target="_blank">';
1509 + $contextual_help .= esc_attr__( 'Changelog', 'wp-forecast' );
1510 + $contextual_help .= '</a></li></ul>';
1511 + $contextual_help .= '<p>';
1512 + $contextual_help .= esc_attr__( 'Links will open in new Window/Tab.', 'wp-forecast' );
1513 + $contextual_help .= '</p>';
1514 +
1515 + $screen = get_current_screen();
1516 +
1517 + // Add my_help_tab if current screen is My Admin Page.
1518 + $screen->add_help_tab(
1519 + array(
1520 + 'id' => 'wpf_help_tab',
1521 + 'title' => esc_attr__( 'wp-forecast Help' ),
1522 + 'content' => $contextual_help,
1523 + )
1524 + );
1525 +}