PluginProbe
wp-forecast / 2.4
wp-forecast v2.4
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.4, at setup.php

164 lines 5.4 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['title']=__("The Weather","wp-forecast_".$av['wpf_language']); // the widget title
93 // Displayconfigurationmatrix
94 // CC FC Day FC Night
95 // Icon 0 10 14
96 // Datum 18 - -
97 // Zeit 1 - -
98 // Shorttext 2 11 15
99 // Temperatur 3 12 16
100 // gef. Temp 4 - -
101 // Luftdruck 5 - -
102 // Luftfeuchte 6 - -
103 // Wind 7 13 17
104 // Windboen 22 23 24
105 // Sonnenaufgang 8 - -
106 // Sonnenuntergang 9 - -
107 // Copyright 21 - -
108 // accuweather link 25 - -
109 //
110 $av['dispconfig']="11111111111111111111111111";
111 $av['windunit']="ms"; // Choose between ms, kmh, mph or kts
112
113 add_option( "wp-forecast-opts".$wpfcid, serialize($av) );
114 }
115
116 if ($weather == "") {
117 $weather="";
118 add_option("wp-forecast-cache".$wpfcid,$weather);
119 };
120
121 if ($expire == "") {
122 $expire="0";
123 add_option("wp-forecast-expire".$wpfcid, $expire );
124 };
125 } // end of for
126
127 pdebug(1,"End of wp_forecast_activate ()");
128 }
129
130 //
131 // is called when plugin is deactivated and removes all
132 // the wp-forecast options from the database
133 //
134 function wp_forecast_deactivate($wpfcid)
135 {
136 pdebug(1,"Start of wp_forecast_deactivate ()");
137
138 global $wpf_maxwidgets;
139
140 $delopt=get_option('wp-forecast-delopt');
141
142 // only delete options when switch is set
143 if ($delopt == 1)
144 {
145 $count = $wpf_maxwidgets; //get_option('wp-forecast-count');
146
147 for ($i=0;$i<$count;$i++)
148 {
149 $wpfcid = get_widget_id( $i );
150
151 delete_option("wp-forecast-opts".$wpfcid);
152 delete_option("wp-forecast-cache".$wpfcid);
153 delete_option("wp-forecast-expire".$wpfcid);
154 }
155 delete_option('wp-forecast-timeout');
156 delete_option('wp-forecast-count');
157 delete_option('wp-forecast-delopt');
158 delete_option("wp-forecast-pre-transport");
159 delete_option("wp-forecast-wp-transport");
160 }
161
162 pdebug(1,"End of wp_forecast_deactivate ()");
163 }
164 ?>