PluginProbe
wp-forecast / 2.9
wp-forecast v2.9
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
wp-forecast / setup.php

setup.php in wp-forecast 2.9, at setup.php

168 lines 5.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /* This file is part of the wp-forecast plugin for wordpress */
3
4 /* Copyright 2006-2009 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
21 //
22 // setting up the default options in table wp-options during
23 // plugin activation from the plugins page
24 //
25 function wp_forecast_activate()
26 {
27 pdebug(1,"Start of wp_forecast_activate ()");
28
29 // add number of widgets, default: 1
30 $count=get_option("wp-forecast-count");
31
32 if ($count == "") {
33 $count="1";
34 add_option("wp-forecast-count",$count);
35 };
36
37 // add timeout for accuweather connections, default: 30
38 $timeout=get_option("wp-forecast-timeout");
39
40 if ($timeout == "") {
41 $timeout="10";
42 add_option("wp-forecast-timeout",$timeout);
43 };
44
45 // add switch to control option deletion during plugin deactivation
46 $delopt=get_option("wp-forecast-delopt");
47
48 if ($delopt == "") {
49 $delopt="0";
50 add_option("wp-forecast-delopt",$delopt);
51 };
52
53 // add preselected transport method for wp-forecast
54 $pre_trans=get_option("wp-forecast-pre-transport");
55
56 if ($pre_trans == "") {
57 $pre_trans="default";
58 add_option("wp-forecast-pre-transport",$pre_tans);
59 };
60
61 // add transport to use by wordpress only for wp-forecast
62 $wp_trans=get_option("wp-forecast-wp-transport");
63
64 if ($wp_trans == "") {
65 $wp_trans="default";
66 add_option("wp-forecast-wp-transport",$wp_trans);
67 };
68
69 for ($i=0;$i<$count;$i++) {
70 $wpfcid = get_widget_id( $i );
71
72 // get all widget options
73 $av=get_wpf_opts($wpfcid);
74 $weather = get_option("wp-forecast-cache".$wpfcid);
75 $expire = get_option("wp-forecast-expire".$wpfcid);
76
77 // if the options dont exists, add the defaults
78 if ( empty($av['service']) or $av['service']=="" ) {
79 $av=array();
80
81 $av['service']="accu"; // specify the weatherservice to use
82 $av['apikey1']=""; // Partner ID or API Code for weatherbug or weather.com
83 $av['apikey2']=""; // License Key for weather.com
84 $av['location']="EUR|DE|GM007|FRANKFURT AM MAIN"; // location code
85 $av['locname']="Frankfurt am Main"; // user defined location name
86 $av['refresh']="1800"; // the intervall the local weather data is renewed
87 $av['metric']="1"; // 1 if you want to use metric scheme, else 0
88 $av['wpf_language']="en_US"; // language code for this widget
89 $av['daytime']="000000000"; // Switches for Daytime forecast
90 $av['nighttime']="000000000"; // Switches for Nighttime forecast
91 $av['currtime']="1"; // 1 if you want to use current time, else 0
92 $av['timeoffset']="0"; // offset to correct wrong accuweather time
93 $av['title']=__("The Weather","wp-forecast_".$av['wpf_language']); // the widget title
94 // Displayconfigurationmatrix
95 // CC FC Day FC Night
96 // Icon 0 10 14
97 // Datum 18 - -
98 // Zeit 1 - -
99 // Shorttext 2 11 15
100 // Temperatur 3 12 16
101 // gef. Temp 4 - -
102 // Luftdruck 5 - -
103 // Luftfeuchte 6 - -
104 // Wind 7 13 17
105 // Windboen 22 23 24
106 // Sonnenaufgang 8 - -
107 // Sonnenuntergang 9 - -
108 // Copyright 21 - -
109 // accuweather link 25 - -
110 // open in new window 26 - -
111 //
112 $av['dispconfig']="111111111111111111111111111";
113 $av['windunit']="ms"; // Choose between ms, kmh, mph or kts
114 $av['pdforecast']="0"; // pulldown forecast 0=No, 1=Yes
115 $av['pdfirstday']="0"; // day to start pulldown with
116
117 add_option( "wp-forecast-opts".$wpfcid, serialize($av) );
118 }
119
120 if ($weather == "") {
121 $weather="";
122 add_option("wp-forecast-cache".$wpfcid,$weather);
123 };
124
125 if ($expire == "") {
126 $expire="0";
127 add_option("wp-forecast-expire".$wpfcid, $expire );
128 };
129 } // end of for
130
131 pdebug(1,"End of wp_forecast_activate ()");
132 }
133
134 //
135 // is called when plugin is deactivated and removes all
136 // the wp-forecast options from the database
137 //
138 function wp_forecast_deactivate($wpfcid)
139 {
140 pdebug(1,"Start of wp_forecast_deactivate ()");
141
142 global $wpf_maxwidgets;
143
144 $delopt=get_option('wp-forecast-delopt');
145
146 // only delete options when switch is set
147 if ($delopt == 1)
148 {
149 $count = $wpf_maxwidgets; //get_option('wp-forecast-count');
150
151 for ($i=0;$i<$count;$i++)
152 {
153 $wpfcid = get_widget_id( $i );
154
155 delete_option("wp-forecast-opts".$wpfcid);
156 delete_option("wp-forecast-cache".$wpfcid);
157 delete_option("wp-forecast-expire".$wpfcid);
158 }
159 delete_option('wp-forecast-timeout');
160 delete_option('wp-forecast-count');
161 delete_option('wp-forecast-delopt');
162 delete_option("wp-forecast-pre-transport");
163 delete_option("wp-forecast-wp-transport");
164 }
165
166 pdebug(1,"End of wp_forecast_deactivate ()");
167 }
168 ?>