Weather Underground - Version 1.2.5.1

Version Description

  • Quick fix for icon issues: the icon images were broken.
Download this release

Release Info

Developer katzwebdesign
Plugin Icon 128x128 Weather Underground
Version 1.2.5.1
Comparing to
See all releases

Code changes from version 1.2.5 to 1.2.5.1

Files changed (2) hide show
  1. readme.txt +9 -3
  2. wunderground.php +106 -106
readme.txt CHANGED
@@ -1,7 +1,7 @@
1
  === Weather Forecast - WP Wunderground ===
2
  Tags: weather, weather.com, wunderground, weatherbug, forecast, widget, shortcode, Yahoo weather, Yahoo! Weather, wp-weather, wp weather, local weather, weather man, weather widget, cool weather, accuweather, get weather, wordpress weather
3
  Requires at least: 2.8
4
- Tested up to: 3.3.1
5
  Stable tag: trunk
6
  Contributors: katzwebdesign
7
  Donate link:https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=zackkatz%40gmail%2ecom&item_name=WP%20Wunderground%20for%20WordPress&no_shipping=0&no_note=1&tax=0&currency_code=USD&lc=US&bn=PP%2dDonationsBF&charset=UTF%2d8
@@ -151,8 +151,11 @@ For previous versions, it is recommended to use a caching plugin (such as WP Sup
151
 
152
  == Changelog ==
153
 
 
 
 
154
  = 1.2.5 =
155
- * Fixed issue where checkbox state wasn't being reflected in settings.
156
 
157
  = 1.2.4 =
158
  * Removed error generation when XML file cannot be read (Error on line 427, <a href="http://wordpress.org/support/topic/506565" rel="nofollow">as reported</a>). Now, it just outputs an HTML comment error message.
@@ -191,8 +194,11 @@ For previous versions, it is recommended to use a caching plugin (such as WP Sup
191
 
192
  == Upgrade Notice ==
193
 
 
 
 
194
  = 1.2.5 =
195
- * Fixed issue where checkbox state wasn't being reflected in settings.
196
 
197
  = 1.2.4 =
198
  * Removed error generation when XML file cannot be read (Error on line 427, <a href="http://wordpress.org/support/topic/506565" rel="nofollow">as reported</a>). Now, it just outputs an HTML comment error message.
1
  === Weather Forecast - WP Wunderground ===
2
  Tags: weather, weather.com, wunderground, weatherbug, forecast, widget, shortcode, Yahoo weather, Yahoo! Weather, wp-weather, wp weather, local weather, weather man, weather widget, cool weather, accuweather, get weather, wordpress weather
3
  Requires at least: 2.8
4
+ Tested up to: 3.5.1
5
  Stable tag: trunk
6
  Contributors: katzwebdesign
7
  Donate link:https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=zackkatz%40gmail%2ecom&item_name=WP%20Wunderground%20for%20WordPress&no_shipping=0&no_note=1&tax=0&currency_code=USD&lc=US&bn=PP%2dDonationsBF&charset=UTF%2d8
151
 
152
  == Changelog ==
153
 
154
+ = 1.2.5.1 =
155
+ * Quick fix for icon issues: the icon images were broken.
156
+
157
  = 1.2.5 =
158
+ * Fixed issue where checkbox state wasn't being reflected in settings (as mentioned <a href="http://wordpress.org/support/topic/plugin-weather-forecast-wp-wunderground-not-saving-checkbox-settings" rel="nofollow">in this support thread</a>)
159
 
160
  = 1.2.4 =
161
  * Removed error generation when XML file cannot be read (Error on line 427, <a href="http://wordpress.org/support/topic/506565" rel="nofollow">as reported</a>). Now, it just outputs an HTML comment error message.
194
 
195
  == Upgrade Notice ==
196
 
197
+ = 1.2.5.1 =
198
+ * Quick fix for icon issues: the icon images were broken.
199
+
200
  = 1.2.5 =
201
+ * Fixed issue where checkbox state wasn't being reflected in settings (as mentioned <a href="http://wordpress.org/support/topic/plugin-weather-forecast-wp-wunderground-not-saving-checkbox-settings" rel="nofollow">in this support thread</a>)
202
 
203
  = 1.2.4 =
204
  * Removed error generation when XML file cannot be read (Error on line 427, <a href="http://wordpress.org/support/topic/506565" rel="nofollow">as reported</a>). Now, it just outputs an HTML comment error message.
wunderground.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP Wunderground
4
  Plugin URI: http://www.seodenver.com/wunderground/
5
  Description: Get accurate and beautiful weather forecasts powered by Wunderground.com for your content or your sidebar.
6
- Version: 1.2.5
7
  Author: Katz Web Services, Inc.
8
  Author URI: http://www.katzwebservices.com/
9
  */
@@ -23,9 +23,9 @@ class wp_wunderground {
23
  var $showlink = '';
24
  var $cache = true;
25
  var $width = '100%';
26
-
27
  function wp_wunderground() {
28
-
29
  // PHP5 only
30
  if(!version_compare(PHP_VERSION, '5.0.0', '>=')) {
31
  add_action('admin_notices', 'wpwundergroundphp5error');
@@ -37,7 +37,7 @@ class wp_wunderground {
37
  }
38
  return;
39
  }
40
-
41
  // Some hosts don't support it...
42
  if(!function_exists('simplexml_load_string')) {
43
  add_action('admin_notices', 'wpwundergroundsimplexmlerror');
@@ -49,32 +49,32 @@ class wp_wunderground {
49
  }
50
  return;
51
  }
52
-
53
-
54
  add_action('admin_menu', array(&$this, 'admin'));
55
  add_filter('plugin_action_links', array(&$this, 'settings_link'), 10, 2 );
56
  add_action('admin_init', array(&$this, 'settings_init') );
57
  $this->options = get_option('wp_wunderground', array());
58
  add_shortcode('forecast', array(&$this, 'build_forecast'));
59
-
60
  // Set each setting...
61
  foreach($this->options as $key=> $value) {
62
  $this->{$key} = $value;
63
  }
64
-
65
  if(!is_admin()) {
66
  add_action('wp_footer', array(&$this,'showlink'));
67
  }
68
  }
69
-
70
  function settings_init() {
71
  register_setting( 'wp_wunderground_options', 'wp_wunderground', array(&$this, 'sanitize_settings') );
72
  }
73
-
74
  function sanitize_settings($input) {
75
  return $input;
76
  }
77
-
78
  function settings_link( $links, $file ) {
79
  static $this_plugin;
80
  if( ! $this_plugin ) $this_plugin = plugin_basename(__FILE__);
@@ -84,24 +84,24 @@ class wp_wunderground {
84
  }
85
  return $links;
86
  }
87
-
88
  function admin() {
89
- add_options_page('WP Wunderground', 'WP Wunderground', 'administrator', 'wp_wunderground', array(&$this, 'admin_page'));
90
  }
91
-
92
  function admin_page() {
93
  ?>
94
  <div class="wrap">
95
  <h2>WP Wunderground: Weather Forecasts for WordPress</h2>
96
  <div class="postbox-container" style="width:65%;">
97
- <div class="metabox-holder">
98
  <div class="meta-box-sortables">
99
  <form action="options.php" method="post">
100
- <?php
101
- wp_nonce_field('update-options');
102
  settings_fields('wp_wunderground_options');
103
-
104
-
105
  $rows[] = array(
106
  'id' => 'wp_wunderground_location',
107
  'label' => __('Location', 'wp_wunderground'),
@@ -114,50 +114,50 @@ class wp_wunderground {
114
  'desc' => 'How many days would you like to display in the forecast? Supports up to 6.',
115
  'content' => $this->buildDays()
116
  );
117
-
118
  $rows[] = array(
119
  'id' => 'wp_wunderground_measurement',
120
  'label' => __('Degree (&deg;) Measurement', 'wp_wunderground'),
121
  'desc' => 'Are you metric or U.S., baby?',
122
  'content' => $this->buildMeasurement()
123
  );
124
-
125
  $rows[] = array(
126
  'id' => 'wp_wunderground_caption',
127
  'label' => __('Forecast Caption', 'wp_wunderground'),
128
  'content' => "<input type='text' name='wp_wunderground[caption]' id='wp_wunderground_caption' value='".esc_attr__($this->caption)."' size='40' style='width:95%!important;' />",
129
  'desc' => 'This will display above the forecast. Think of it like a forecast title.'
130
  );
131
-
132
  $rows[] = array(
133
  'id' => 'wp_wunderground_datelabel',
134
  'label' => __('"All Dates" Label', 'wp_wunderground'),
135
  'content' => "<input type='text' name='wp_wunderground[datelabel]' id='wp_wunderground_datelabel' value='".esc_attr__($this->datelabel)."' size='40' style='width:95%!important;' />",
136
  'desc' => 'How all dates appear by default. See instructions in the "Date Formatting" section of the box on the right &rarr;'
137
  );
138
-
139
  $rows[] = array(
140
  'id' => 'wp_wunderground_todaylabel',
141
  'label' => __('"Today\'s Date" Label', 'wp_wunderground'),
142
  'content' => "<input type='text' name='wp_wunderground[todaylabel]' id='wp_wunderground_todaylabel' value='".esc_attr__($this->todaylabel)."' size='40' style='width:95%!important;' />",
143
  'desc' => 'How today\'s date appears (overrides All Dates format). See instructions in the "Date Formatting" section of the box on the right &rarr;'
144
  );
145
-
146
  $rows[] = array(
147
  'id' => 'wp_wunderground_highlow',
148
  'label' => __('"High/Low" Formatting', 'wp_wunderground'),
149
  'desc' => 'See instructions in the "Highs &amp; Lows Formatting" section of the box on the right &rarr;',
150
  'content' => "<input type='text' name='wp_wunderground[highlow]' id='wp_wunderground_highlow' value='".htmlspecialchars($this->highlow)."' size='40' style='width:95%!important;' />"
151
  );
152
-
153
-
154
  $rows[] = array(
155
  'id' => 'wp_wunderground_icon_set',
156
  'label' => __('Icon Set', 'wp_wunderground'),
157
  'desc' => 'How do you want your weather icons to look?',
158
  'content' => $this->buildIconSet()
159
  );
160
-
161
  $checked = (empty($this->cache) || $this->cache == 'yes') ? ' checked="checked"' : '';
162
  $rows[] = array(
163
  'id' => 'wp_wunderground_cache',
@@ -165,20 +165,20 @@ class wp_wunderground {
165
  'desc' => 'Cache the results to prevent fetching the forecast on each page load. <strong>Highly encouraged.</strong>',
166
  'content' => "<p><label for='wp_wunderground_cache'><input type='hidden' name='wp_wunderground[cache]' value='no' /><input type='checkbox' name='wp_wunderground[cache]' value='yes' id='wp_wunderground_cache' $checked /> Cache forecast results</label></p>"
167
  );
168
-
169
  $checked = (empty($this->showlink) || $this->showlink == 'yes') ? ' checked="checked"' : '';
170
-
171
  $rows[] = array(
172
  'id' => 'wp_wunderground_showlink',
173
  'label' => __('Give Thanks', 'wp_wunderground'),
174
  'desc' => 'Checking the box tells the world you use this free plugin by adding a link to your footer. If you don\'t like it, you can turn it off, so please enable.',
175
  'content' => "<p><label for='wp_wunderground_showlink'><input type='hidden' name='wp_wunderground[showlink]' value='no' /><input type='checkbox' name='wp_wunderground[showlink]' value='yes' id='wp_wunderground_showlink' $checked /> Help show the love.</label></p>"
176
  );
177
-
178
  $this->postbox('wp_wundergroundsettings',__('Store Settings', 'wp_wunderground'), $this->form_table($rows), false);
179
-
180
  ?>
181
-
182
 
183
  <input type="hidden" name="page_options" value="<?php foreach($rows as $row) { $output .= $row['id'].','; } echo substr($output, 0, -1);?>" />
184
  <input type="hidden" name="action" value="update" />
@@ -190,22 +190,22 @@ class wp_wunderground {
190
  </div>
191
  </div>
192
  <div class="postbox-container" style="width:34%;">
193
- <div class="metabox-holder">
194
  <div class="meta-box-sortables">
195
  <?php $this->postbox('wp_wundergroundhelp',__('Configuring This Plugin', 'wp_wunderground'), $this->configuration(), true); ?>
196
  </div>
197
  </div>
198
  </div>
199
-
200
  </div>
201
- <?php
202
  }
203
-
204
  function showLink() {
205
  if($this->showlink == 'yes') {
206
  mt_srand(crc32($_SERVER['REQUEST_URI'])); // Keep links the same on the same page
207
-
208
- $urls = array('http://seodenver.com/wunderground/?ref=foot', 'http://wordpress.org/extend/plugins/wunderground/', 'http://www.denversnowremovalservice.com');
209
  $url = $urls[mt_rand(0, count($urls)-1)];
210
  $names = array('WP Wunderground', 'Wordpress Weather', 'Wunderground for WordPress');
211
  $name = $names[mt_rand(0, count($names)-1)];
@@ -217,13 +217,13 @@ class wp_wunderground {
217
  'Our weather forecast is from <a href="'.$url.'">'.$name.'</a>'
218
  );
219
  $link = '<p class="wp_wunderground" style="text-align:center;">'.trim($links[mt_rand(0, count($links)-1)]).'</p>';
220
-
221
  echo apply_filters('wp_wunderground_showlink', $link);
222
-
223
  mt_srand(); // Make it random again.
224
  }
225
  }
226
-
227
  function buildDays() {
228
  $c = ' selected="selected"';
229
  $output = '<select id="wp_wunderground_numdays" name="wp_wunderground[numdays]">';
@@ -237,7 +237,7 @@ class wp_wunderground {
237
  $output .= '<label for="wp_wunderground_numdays" style="padding-left:10px;"># of Days in Forecast:</label>';
238
  return $output;
239
  }
240
-
241
  function buildMeasurement() {
242
  $c = ' selected="selected"';
243
  $output = '<select id="wp_wunderground_measurement" name="wp_wunderground[measurement]">';
@@ -247,7 +247,7 @@ class wp_wunderground {
247
  $output .= '<label for="wp_wunderground_measurement" style="padding-left:10px;">Fahrenheit or Celsius:</label>';
248
  return $output;
249
  }
250
-
251
  function buildIconSet() {
252
  $c = ' selected="selected"';
253
  $output = '<label for="wp_wunderground_icon_set" style="padding-right:10px;">Icon Set:</label>';
@@ -263,31 +263,31 @@ class wp_wunderground {
263
  $output .= ' <option value="Helen"'; if($this->icon_set == 'Helen') { $output .= $c; } $output .= '>Helen</option>';
264
  $output .= ' <option value="Incredible"'; if($this->icon_set == 'Incredible') { $output .= $c; } $output .= '>Incredible</option>';
265
  $output .= '</select>';
266
-
267
  $output .= '
268
  <div style="margin-top:1em; text-align:center;">
269
- <div style="padding-right:10px; width:100px; height:75px; float:left;"><img src="http://icons-ecast.wxug.com/i/c/a/clear.gif" width="50" height="50" /><img src="http://icons-ecast.wxug.com/i/c/a/rain.gif" width="50" height="50" /><br />Default</div>
270
- <div style="padding-right:10px; width:100px; height:67px; float:left; padding-top:8px;"><img src="http://icons-ecast.wxug.com/i/c/b/clear.gif" width="42" height="42" /><img src="http://icons-ecast.wxug.com/i/c/b/rain.gif" width="42" height="42" /><br />Smiley</div>
271
- <div style="padding-right:10px; width:100px; height:75px; float:left;"><img src="http://icons-ecast.wxug.com/i/c/c/clear.gif" width="50" height="50" /><img src="http://icons-ecast.wxug.com/i/c/c/rain.gif" width="50" height="50" /><br />Generic</div>
272
- <div style="padding-right:10px; width:100px; height:67px; float:left; padding-top:8px;"><img src="http://icons-ecast.wxug.com/i/c/d/clear.gif" width="42" height="42" /><img src="http://icons-ecast.wxug.com/i/c/d/rain.gif" width="42" height="42" /><br />Old School</div>
273
- <div style="padding-right:10px; width:100px; height:67px; float:left; padding-top:8px;"><img src="http://icons-ecast.wxug.com/i/c/e/clear.gif" width="42" height="42" /><img src="http://icons-ecast.wxug.com/i/c/e/rain.gif" width="42" height="42" /><br />Cartoon</div>
274
- <div style="padding-right:10px; width:100px; height:67px; float:left; padding-top:8px;"><img src="http://icons-ecast.wxug.com/i/c/f/clear.gif" width="42" height="42" /><img src="http://icons-ecast.wxug.com/i/c/f/rain.gif" width="42" height="42" /><br />Mobile</div>
275
- <div style="padding-right:10px; width:100px; height:75px; float:left;"><img src="http://icons-ecast.wxug.com/i/c/g/clear.gif" width="50" height="50" /><img src="http://icons-ecast.wxug.com/i/c/g/rain.gif" width="50" height="50" /><br />Simple</div>
276
- <div style="padding-right:10px; width:100px; height:75px; float:left;"><img src="http://icons-ecast.wxug.com/i/c/h/clear.gif" width="50" height="50" /><img src="http://icons-ecast.wxug.com/i/c/h/rain.gif" width="50" height="50" /><br />Contemporary</div>
277
- <div style="padding-right:10px; width:100px; height:75px; float:left;"><img src="http://icons-ecast.wxug.com/i/c/i/clear.gif" width="50" height="50" /><img src="http://icons-ecast.wxug.com/i/c/i/rain.gif" width="50" height="50" /><br />Helen</div>
278
- <div style="padding-right:10px; width:100px; height:75px; float:left;"><img src="http://icons-ecast.wxug.com/i/c/k/clear.gif" width="50" height="50" /><img src="http://icons-ecast.wxug.com/i/c/k/rain.gif" width="50" height="50" /><br />Incredible</div>
279
  </div>
280
  ';
281
 
282
  return $output;
283
  }
284
-
285
- function configuration() {
286
  $date2 = date('m-d-y');
287
  $date = date('m/d/Y');
288
  $weekday = date('l');
289
  $html = <<<EOD
290
- <h4>Adding the Forecast to your Content</h4>
291
  <p class="howto updated" style="padding:1em;">If you configure the settings to the left, all you will need to do is add <code>[forecast]</code> to your post or page content or text widget to add the forecast table.</p>
292
  <h4>Date Formatting</h4>
293
  <p>You can use the following tags: <code>%%weekday%%</code>, <code>%%day%%</code>, <code>%%month%%</code>, <code>%%year%%</code>, as well as using <a href="http://www.php.net/manual/en/function.date.php" target="_blank">PHP date formatting</a>.</p>
@@ -307,17 +307,17 @@ class wp_wunderground {
307
  <li><strong>Use CSS classes too:</strong><br /><code>&lt;div class=&quot;temp&quot;&gt;High of &lt;span class=&quot;temphigh&quot;&gt;%%high%%&lt;/span&gt;&lt;br /&gt;Low of &lt;span class=&quot;templow&quot;&gt;%%low%%&lt;/span&gt;&lt;/div&gt;</code> <em>outputs as:&nbsp;</em> <div class="temp">High of <span class="temphigh">85</span><br />Low of <span class="templow">55</span></div></li>
308
  </ul>
309
  <hr style="padding-top:1em; outline:none; border:none; border-bottom:1px solid #ccc;"/>
310
-
311
  <h4>Using the <code>[forecast]</code> Shortcode</h4>
312
-
313
  <p>If you're a maniac for shortcodes, and you want all control all the time, this is a good way to use it.</p>
314
-
315
  <p><code>[forecast location="Tokyo, Japan" caption="Weather for Tokyo" measurement='F' todaylabel="Today" datelabel="date('m/d/Y')" highlow='%%high%%&deg;/%%low%%&deg;' numdays="3" iconset="Cartoon" class="css_table_class" cache="true" width="100%"]</code></p>
316
-
317
  <p><strong>The shortcode supports the following settings:</strong></p>
318
  <ul>
319
  <li><code>location="Tokyo, Japan"</code> - Use any city/state combo or US/Canada ZIP code
320
- </li><li><code>caption="Weather for Tokyo"</code> - Add a caption to your table (it's like a title)
321
  </li><li><code>measurement='F'</code> - Choose Fahrenheit or Celsius by using "F" or "C"
322
  </li><li><code>datelabel="date('m/d/Y')"</code> - Format the way the days display ("9/30/2012" in this example)
323
  </li><li><code>todaylabel="Today"</code> - Format how today's date appears ("Today" in this example)
@@ -327,11 +327,11 @@ class wp_wunderground {
327
  </li><li><code>cache="true"</code> - Whether to cache forecast results. Use <code>0</code> to disable (not recommended).
328
  </li><li><code>width="100%"</code> - Change the width of the forecast table
329
  </ul>
330
-
331
  EOD;
332
  return $html;
333
  }
334
-
335
  // THANKS JOOST!
336
  function form_table($rows) {
337
  $content = '<table class="form-table" width="100%">';
@@ -345,7 +345,7 @@ EOD;
345
  $content .= '<br/><small>'.$row['desc'].'</small>';
346
  $content .= '</th><td valign="top">';
347
  $content .= $row['content'];
348
- $content .= '</td></tr>';
349
  }
350
  $content .= '</table>';
351
  return $content;
@@ -362,12 +362,12 @@ EOD;
362
  </div>
363
  <?php
364
  }
365
-
366
  function r($content, $kill = false) {
367
  echo '<pre>'.print_r($content,true).'</pre>';
368
  if($kill) { die(); }
369
  }
370
-
371
  function true_false($value) {
372
  $value = trim($value);
373
  if(
@@ -379,7 +379,7 @@ EOD;
379
  ) { return false; }
380
  return true;
381
  }
382
-
383
  function build_forecast($atts, $content=null) {
384
  $settings = shortcode_atts( array(
385
  'location' => $this->location,
@@ -398,29 +398,29 @@ EOD;
398
  'type' => 'table'
399
  ), $atts );
400
  extract( $settings );
401
-
402
  // Set custom hard-coded width. Added in 1.2
403
  if($this->true_false($width)) { $width = ' width="'.$width.'"';}
404
-
405
  // Added in 1.2
406
  $cache = $this->true_false($cache);
407
-
408
  // They're hard to spell and long, man!
409
  $measurement = strtolower($measurement);
410
  if($measurement == 'c') { $measurement = 'celsius'; }
411
  if($measurement == 'f') { $measurement = 'fahrenheit'; }
412
-
413
  if($cache) {
414
  // Shorten the settings into an encrypted 40-byte string so that
415
  // it's never longer than the 64-byte database column
416
  foreach($settings as $k => $v) { $settings[$k] = esc_attr__($v); }
417
  $transient_title = implode('_', $settings);
418
  $transient_title = 'wund_'.sha1($transient_title);
419
-
420
  // See if it exists already.
421
  $table = get_transient($transient_title);
422
  }
423
-
424
  if(!$table || !$cache || isset($_REQUEST['cache'])) {
425
  $xmlStr = @wp_remote_fopen(trim($this->url.urlencode($location)));
426
  if(is_wp_error($xmlStr) || !$xml=simplexml_load_string($xmlStr)){
@@ -429,7 +429,7 @@ EOD;
429
  } elseif(empty($xml->simpleforecast->forecastday)) {
430
  return '<!-- WP Wunderground Error : Weather feed was empty from '.$this->url.$this->location.' -->'.$content;
431
  }
432
-
433
  $tablehead = $tablebody = ''; $i = 0;
434
  foreach($xml->simpleforecast->forecastday as $day) {
435
  #$this->r($day); // For debug...
@@ -443,15 +443,15 @@ EOD;
443
  $low = $low[$measurement];
444
  $icon = '<img src="'.$icon_url.'"'.$icon_size.' alt="It is forcast to be '.$conditions.' at '.$date['pretty'].'" style="display:block;" />';
445
  $colwidth = round(100/$numdays, 2);
446
-
447
  $temp = str_replace('%%high%%', $high, $highlow);
448
- $temp = str_replace('%%low%%', $low, $temp);
449
  $temp = htmlspecialchars_decode($temp);
450
-
451
  $label = $this->format_date($date, $todaylabel, $datelabel);
452
-
453
  $tablehead .= "\n\t\t\t\t\t\t\t".'<th scope="col" width="'.$colwidth.'%" align="'.$align.'">'.$label.'</th>';
454
-
455
  $tablebody .=
456
  "\n\t\t\t\t\t\t\t".'<td align="'.$align.'" class="'.esc_attr__($class).'_'.sanitize_title($conditions).'">'.apply_filters('wp_wunderground_forecast_icon',$icon).'<div class="wp_wund_conditions">'.apply_filters('wp_wunderground_forecast_conditions',$conditions).'</div>'.apply_filters('wp_wunderground_forecast_temp',$temp).'</td>';
457
  }
@@ -474,24 +474,24 @@ EOD;
474
  $table = preg_replace('/\s+/ism', ' ', $table);
475
  set_transient($transient_title, $table, apply_filters('wp_wunderground_forecast_cache', 60*60*6));
476
  }
477
-
478
  return apply_filters('wp_wunderground_forecast', $table);
479
  }
480
-
481
  function format_date($date, $todaylabel = false, $datelabel = false) {
482
  if(!$todaylabel) { $todaylabel = $this->todaylabel; }
483
  if(!$datelabel) { $datelabel = $this->datelabel; }
484
  extract($date);
485
-
486
  try {
487
  $dt = new DateTime("$year-$month-$day", new DateTimeZone($tz_long));
488
  $dt->setTime($hour,$min,$sec);
489
  $tt = new DateTime('', new DateTimeZone($tz_long));
490
  if($tt->format('Y-m-d') == $dt->format('Y-m-d')) { $label = $todaylabel; } else { $label = $datelabel; }
491
- } catch(Exception $e) {
492
 
493
  }
494
-
495
  // First we do these easy date replacements
496
  $label = str_replace('%%weekday%%', $weekday, $label);
497
  $label = str_replace('%%day%%', $day, $label);
@@ -502,41 +502,41 @@ EOD;
502
  preg_match('/(.*?)date\([\'"]{0,1}(.*?)[\'"]{0,1}\)(.*?)/xism', $label, $matches);
503
  if(!empty($matches)) {
504
  try {
505
- // If we find date(), we format the date
506
  // and add the before text and after text back in
507
  $label = $matches[1].$dt->format($matches[2]).$matches[3];
508
  } catch(Exception $e) {
509
-
510
  }
511
  }
512
  return $label;
513
  }
514
-
515
  function get_icon_path($icons, $icon_set = false) {
516
  if(!$icon_set) { $icon_set = $this->icon_set; }
517
  // This may be slightly faster; let's try this first.
518
  switch($icon_set) {
519
- case 'Default': return 'http://icons-ecast.wxug.com/i/c/a/'; break;
520
- case 'Smiley': return 'http://icons-ecast.wxug.com/i/c/b/'; break;
521
- case 'Generic': return 'http://icons-ecast.wxug.com/i/c/c/'; break;
522
- case 'Old School': return 'http://icons-ecast.wxug.com/i/c/d/'; break;
523
- case 'Cartoon': return 'http://icons-ecast.wxug.com/i/c/e/'; break;
524
- case 'Mobile': return 'http://icons-ecast.wxug.com/i/c/f/'; break;
525
- case 'Simple': return 'http://icons-ecast.wxug.com/i/c/g/'; break;
526
- case 'Contemporary': return 'http://icons-ecast.wxug.com/i/c/h/'; break;
527
- case 'Helen': return 'http://icons-ecast.wxug.com/i/c/i/'; break;
528
- case 'Incredible': return 'http://icons-ecast.wxug.com/i/c/k/'; break;
529
  }
530
  // If this doesn't work, use the other method
531
  $this->get_icon_url($icons, $icon_set);
532
  }
533
-
534
  function get_icon_size($icon_set = false) {
535
  if(!$icon_set) { $icon_set = $this->icon_set; }
536
  switch($this->icon_set) {
537
-
538
  case 'Default':
539
- case 'Helen':
540
  case 'Generic':
541
  case 'Simple':
542
  case 'Contemporary':
@@ -550,10 +550,10 @@ EOD;
550
  default:
551
  return 42;
552
  break;
553
-
554
  }
555
  }
556
-
557
  function get_icon_url($icons) {
558
  foreach($icons['icon_set'] as $icon) {
559
  if(strtolower(trim($icon['name'])) == strtolower(trim($this->icon_set))) {
@@ -562,11 +562,11 @@ EOD;
562
  }
563
  return false;
564
  }
565
-
566
  }
567
 
568
 
569
- function simpleXMLToArray($xml,
570
  $flattenValues=true,
571
  $flattenAttributes = true,
572
  $flattenChildren=true,
@@ -615,7 +615,7 @@ function simpleXMLToArray($xml,
615
  if(!$flattenAttributes){$return[$attributesKey] = $attributes;}
616
  else{$return = array_merge($return, $attributes);}
617
  }
618
-
619
  return $return;
620
  }
621
 
3
  Plugin Name: WP Wunderground
4
  Plugin URI: http://www.seodenver.com/wunderground/
5
  Description: Get accurate and beautiful weather forecasts powered by Wunderground.com for your content or your sidebar.
6
+ Version: 1.2.5.1
7
  Author: Katz Web Services, Inc.
8
  Author URI: http://www.katzwebservices.com/
9
  */
23
  var $showlink = '';
24
  var $cache = true;
25
  var $width = '100%';
26
+
27
  function wp_wunderground() {
28
+
29
  // PHP5 only
30
  if(!version_compare(PHP_VERSION, '5.0.0', '>=')) {
31
  add_action('admin_notices', 'wpwundergroundphp5error');
37
  }
38
  return;
39
  }
40
+
41
  // Some hosts don't support it...
42
  if(!function_exists('simplexml_load_string')) {
43
  add_action('admin_notices', 'wpwundergroundsimplexmlerror');
49
  }
50
  return;
51
  }
52
+
53
+
54
  add_action('admin_menu', array(&$this, 'admin'));
55
  add_filter('plugin_action_links', array(&$this, 'settings_link'), 10, 2 );
56
  add_action('admin_init', array(&$this, 'settings_init') );
57
  $this->options = get_option('wp_wunderground', array());
58
  add_shortcode('forecast', array(&$this, 'build_forecast'));
59
+
60
  // Set each setting...
61
  foreach($this->options as $key=> $value) {
62
  $this->{$key} = $value;
63
  }
64
+
65
  if(!is_admin()) {
66
  add_action('wp_footer', array(&$this,'showlink'));
67
  }
68
  }
69
+
70
  function settings_init() {
71
  register_setting( 'wp_wunderground_options', 'wp_wunderground', array(&$this, 'sanitize_settings') );
72
  }
73
+
74
  function sanitize_settings($input) {
75
  return $input;
76
  }
77
+
78
  function settings_link( $links, $file ) {
79
  static $this_plugin;
80
  if( ! $this_plugin ) $this_plugin = plugin_basename(__FILE__);
84
  }
85
  return $links;
86
  }
87
+
88
  function admin() {
89
+ add_options_page('WP Wunderground', 'WP Wunderground', 'administrator', 'wp_wunderground', array(&$this, 'admin_page'));
90
  }
91
+
92
  function admin_page() {
93
  ?>
94
  <div class="wrap">
95
  <h2>WP Wunderground: Weather Forecasts for WordPress</h2>
96
  <div class="postbox-container" style="width:65%;">
97
+ <div class="metabox-holder">
98
  <div class="meta-box-sortables">
99
  <form action="options.php" method="post">
100
+ <?php
101
+ wp_nonce_field('update-options');
102
  settings_fields('wp_wunderground_options');
103
+
104
+
105
  $rows[] = array(
106
  'id' => 'wp_wunderground_location',
107
  'label' => __('Location', 'wp_wunderground'),
114
  'desc' => 'How many days would you like to display in the forecast? Supports up to 6.',
115
  'content' => $this->buildDays()
116
  );
117
+
118
  $rows[] = array(
119
  'id' => 'wp_wunderground_measurement',
120
  'label' => __('Degree (&deg;) Measurement', 'wp_wunderground'),
121
  'desc' => 'Are you metric or U.S., baby?',
122
  'content' => $this->buildMeasurement()
123
  );
124
+
125
  $rows[] = array(
126
  'id' => 'wp_wunderground_caption',
127
  'label' => __('Forecast Caption', 'wp_wunderground'),
128
  'content' => "<input type='text' name='wp_wunderground[caption]' id='wp_wunderground_caption' value='".esc_attr__($this->caption)."' size='40' style='width:95%!important;' />",
129
  'desc' => 'This will display above the forecast. Think of it like a forecast title.'
130
  );
131
+
132
  $rows[] = array(
133
  'id' => 'wp_wunderground_datelabel',
134
  'label' => __('"All Dates" Label', 'wp_wunderground'),
135
  'content' => "<input type='text' name='wp_wunderground[datelabel]' id='wp_wunderground_datelabel' value='".esc_attr__($this->datelabel)."' size='40' style='width:95%!important;' />",
136
  'desc' => 'How all dates appear by default. See instructions in the "Date Formatting" section of the box on the right &rarr;'
137
  );
138
+
139
  $rows[] = array(
140
  'id' => 'wp_wunderground_todaylabel',
141
  'label' => __('"Today\'s Date" Label', 'wp_wunderground'),
142
  'content' => "<input type='text' name='wp_wunderground[todaylabel]' id='wp_wunderground_todaylabel' value='".esc_attr__($this->todaylabel)."' size='40' style='width:95%!important;' />",
143
  'desc' => 'How today\'s date appears (overrides All Dates format). See instructions in the "Date Formatting" section of the box on the right &rarr;'
144
  );
145
+
146
  $rows[] = array(
147
  'id' => 'wp_wunderground_highlow',
148
  'label' => __('"High/Low" Formatting', 'wp_wunderground'),
149
  'desc' => 'See instructions in the "Highs &amp; Lows Formatting" section of the box on the right &rarr;',
150
  'content' => "<input type='text' name='wp_wunderground[highlow]' id='wp_wunderground_highlow' value='".htmlspecialchars($this->highlow)."' size='40' style='width:95%!important;' />"
151
  );
152
+
153
+
154
  $rows[] = array(
155
  'id' => 'wp_wunderground_icon_set',
156
  'label' => __('Icon Set', 'wp_wunderground'),
157
  'desc' => 'How do you want your weather icons to look?',
158
  'content' => $this->buildIconSet()
159
  );
160
+
161
  $checked = (empty($this->cache) || $this->cache == 'yes') ? ' checked="checked"' : '';
162
  $rows[] = array(
163
  'id' => 'wp_wunderground_cache',
165
  'desc' => 'Cache the results to prevent fetching the forecast on each page load. <strong>Highly encouraged.</strong>',
166
  'content' => "<p><label for='wp_wunderground_cache'><input type='hidden' name='wp_wunderground[cache]' value='no' /><input type='checkbox' name='wp_wunderground[cache]' value='yes' id='wp_wunderground_cache' $checked /> Cache forecast results</label></p>"
167
  );
168
+
169
  $checked = (empty($this->showlink) || $this->showlink == 'yes') ? ' checked="checked"' : '';
170
+
171
  $rows[] = array(
172
  'id' => 'wp_wunderground_showlink',
173
  'label' => __('Give Thanks', 'wp_wunderground'),
174
  'desc' => 'Checking the box tells the world you use this free plugin by adding a link to your footer. If you don\'t like it, you can turn it off, so please enable.',
175
  'content' => "<p><label for='wp_wunderground_showlink'><input type='hidden' name='wp_wunderground[showlink]' value='no' /><input type='checkbox' name='wp_wunderground[showlink]' value='yes' id='wp_wunderground_showlink' $checked /> Help show the love.</label></p>"
176
  );
177
+
178
  $this->postbox('wp_wundergroundsettings',__('Store Settings', 'wp_wunderground'), $this->form_table($rows), false);
179
+
180
  ?>
181
+
182
 
183
  <input type="hidden" name="page_options" value="<?php foreach($rows as $row) { $output .= $row['id'].','; } echo substr($output, 0, -1);?>" />
184
  <input type="hidden" name="action" value="update" />
190
  </div>
191
  </div>
192
  <div class="postbox-container" style="width:34%;">
193
+ <div class="metabox-holder">
194
  <div class="meta-box-sortables">
195
  <?php $this->postbox('wp_wundergroundhelp',__('Configuring This Plugin', 'wp_wunderground'), $this->configuration(), true); ?>
196
  </div>
197
  </div>
198
  </div>
199
+
200
  </div>
201
+ <?php
202
  }
203
+
204
  function showLink() {
205
  if($this->showlink == 'yes') {
206
  mt_srand(crc32($_SERVER['REQUEST_URI'])); // Keep links the same on the same page
207
+
208
+ $urls = array('http://seodenver.com/wunderground/?ref=foot', 'http://wordpress.org/extend/plugins/wunderground/', 'http://www.denversnow.co');
209
  $url = $urls[mt_rand(0, count($urls)-1)];
210
  $names = array('WP Wunderground', 'Wordpress Weather', 'Wunderground for WordPress');
211
  $name = $names[mt_rand(0, count($names)-1)];
217
  'Our weather forecast is from <a href="'.$url.'">'.$name.'</a>'
218
  );
219
  $link = '<p class="wp_wunderground" style="text-align:center;">'.trim($links[mt_rand(0, count($links)-1)]).'</p>';
220
+
221
  echo apply_filters('wp_wunderground_showlink', $link);
222
+
223
  mt_srand(); // Make it random again.
224
  }
225
  }
226
+
227
  function buildDays() {
228
  $c = ' selected="selected"';
229
  $output = '<select id="wp_wunderground_numdays" name="wp_wunderground[numdays]">';
237
  $output .= '<label for="wp_wunderground_numdays" style="padding-left:10px;"># of Days in Forecast:</label>';
238
  return $output;
239
  }
240
+
241
  function buildMeasurement() {
242
  $c = ' selected="selected"';
243
  $output = '<select id="wp_wunderground_measurement" name="wp_wunderground[measurement]">';
247
  $output .= '<label for="wp_wunderground_measurement" style="padding-left:10px;">Fahrenheit or Celsius:</label>';
248
  return $output;
249
  }
250
+
251
  function buildIconSet() {
252
  $c = ' selected="selected"';
253
  $output = '<label for="wp_wunderground_icon_set" style="padding-right:10px;">Icon Set:</label>';
263
  $output .= ' <option value="Helen"'; if($this->icon_set == 'Helen') { $output .= $c; } $output .= '>Helen</option>';
264
  $output .= ' <option value="Incredible"'; if($this->icon_set == 'Incredible') { $output .= $c; } $output .= '>Incredible</option>';
265
  $output .= '</select>';
266
+
267
  $output .= '
268
  <div style="margin-top:1em; text-align:center;">
269
+ <div style="padding-right:10px; width:100px; height:75px; float:left;"><img src="http://icons-ak.wxug.com/i/c/a/clear.gif" width="50" height="50" /><img src="http://icons-ak.wxug.com/i/c/a/rain.gif" width="50" height="50" /><br />Default</div>
270
+ <div style="padding-right:10px; width:100px; height:67px; float:left; padding-top:8px;"><img src="http://icons-ak.wxug.com/i/c/b/clear.gif" width="42" height="42" /><img src="http://icons-ak.wxug.com/i/c/b/rain.gif" width="42" height="42" /><br />Smiley</div>
271
+ <div style="padding-right:10px; width:100px; height:75px; float:left;"><img src="http://icons-ak.wxug.com/i/c/c/clear.gif" width="50" height="50" /><img src="http://icons-ak.wxug.com/i/c/c/rain.gif" width="50" height="50" /><br />Generic</div>
272
+ <div style="padding-right:10px; width:100px; height:67px; float:left; padding-top:8px;"><img src="http://icons-ak.wxug.com/i/c/d/clear.gif" width="42" height="42" /><img src="http://icons-ak.wxug.com/i/c/d/rain.gif" width="42" height="42" /><br />Old School</div>
273
+ <div style="padding-right:10px; width:100px; height:67px; float:left; padding-top:8px;"><img src="http://icons-ak.wxug.com/i/c/e/clear.gif" width="42" height="42" /><img src="http://icons-ak.wxug.com/i/c/e/rain.gif" width="42" height="42" /><br />Cartoon</div>
274
+ <div style="padding-right:10px; width:100px; height:67px; float:left; padding-top:8px;"><img src="http://icons-ak.wxug.com/i/c/f/clear.gif" width="42" height="42" /><img src="http://icons-ak.wxug.com/i/c/f/rain.gif" width="42" height="42" /><br />Mobile</div>
275
+ <div style="padding-right:10px; width:100px; height:75px; float:left;"><img src="http://icons-ak.wxug.com/i/c/g/clear.gif" width="50" height="50" /><img src="http://icons-ak.wxug.com/i/c/g/rain.gif" width="50" height="50" /><br />Simple</div>
276
+ <div style="padding-right:10px; width:100px; height:75px; float:left;"><img src="http://icons-ak.wxug.com/i/c/h/clear.gif" width="50" height="50" /><img src="http://icons-ak.wxug.com/i/c/h/rain.gif" width="50" height="50" /><br />Contemporary</div>
277
+ <div style="padding-right:10px; width:100px; height:75px; float:left;"><img src="http://icons-ak.wxug.com/i/c/i/clear.gif" width="50" height="50" /><img src="http://icons-ak.wxug.com/i/c/i/rain.gif" width="50" height="50" /><br />Helen</div>
278
+ <div style="padding-right:10px; width:100px; height:75px; float:left;"><img src="http://icons-ak.wxug.com/i/c/k/clear.gif" width="50" height="50" /><img src="http://icons-ak.wxug.com/i/c/k/rain.gif" width="50" height="50" /><br />Incredible</div>
279
  </div>
280
  ';
281
 
282
  return $output;
283
  }
284
+
285
+ function configuration() {
286
  $date2 = date('m-d-y');
287
  $date = date('m/d/Y');
288
  $weekday = date('l');
289
  $html = <<<EOD
290
+ <h4>Adding the Forecast to your Content</h4>
291
  <p class="howto updated" style="padding:1em;">If you configure the settings to the left, all you will need to do is add <code>[forecast]</code> to your post or page content or text widget to add the forecast table.</p>
292
  <h4>Date Formatting</h4>
293
  <p>You can use the following tags: <code>%%weekday%%</code>, <code>%%day%%</code>, <code>%%month%%</code>, <code>%%year%%</code>, as well as using <a href="http://www.php.net/manual/en/function.date.php" target="_blank">PHP date formatting</a>.</p>
307
  <li><strong>Use CSS classes too:</strong><br /><code>&lt;div class=&quot;temp&quot;&gt;High of &lt;span class=&quot;temphigh&quot;&gt;%%high%%&lt;/span&gt;&lt;br /&gt;Low of &lt;span class=&quot;templow&quot;&gt;%%low%%&lt;/span&gt;&lt;/div&gt;</code> <em>outputs as:&nbsp;</em> <div class="temp">High of <span class="temphigh">85</span><br />Low of <span class="templow">55</span></div></li>
308
  </ul>
309
  <hr style="padding-top:1em; outline:none; border:none; border-bottom:1px solid #ccc;"/>
310
+
311
  <h4>Using the <code>[forecast]</code> Shortcode</h4>
312
+
313
  <p>If you're a maniac for shortcodes, and you want all control all the time, this is a good way to use it.</p>
314
+
315
  <p><code>[forecast location="Tokyo, Japan" caption="Weather for Tokyo" measurement='F' todaylabel="Today" datelabel="date('m/d/Y')" highlow='%%high%%&deg;/%%low%%&deg;' numdays="3" iconset="Cartoon" class="css_table_class" cache="true" width="100%"]</code></p>
316
+
317
  <p><strong>The shortcode supports the following settings:</strong></p>
318
  <ul>
319
  <li><code>location="Tokyo, Japan"</code> - Use any city/state combo or US/Canada ZIP code
320
+ </li><li><code>caption="Weather for Tokyo"</code> - Add a caption to your table (it's like a title)
321
  </li><li><code>measurement='F'</code> - Choose Fahrenheit or Celsius by using "F" or "C"
322
  </li><li><code>datelabel="date('m/d/Y')"</code> - Format the way the days display ("9/30/2012" in this example)
323
  </li><li><code>todaylabel="Today"</code> - Format how today's date appears ("Today" in this example)
327
  </li><li><code>cache="true"</code> - Whether to cache forecast results. Use <code>0</code> to disable (not recommended).
328
  </li><li><code>width="100%"</code> - Change the width of the forecast table
329
  </ul>
330
+
331
  EOD;
332
  return $html;
333
  }
334
+
335
  // THANKS JOOST!
336
  function form_table($rows) {
337
  $content = '<table class="form-table" width="100%">';
345
  $content .= '<br/><small>'.$row['desc'].'</small>';
346
  $content .= '</th><td valign="top">';
347
  $content .= $row['content'];
348
+ $content .= '</td></tr>';
349
  }
350
  $content .= '</table>';
351
  return $content;
362
  </div>
363
  <?php
364
  }
365
+
366
  function r($content, $kill = false) {
367
  echo '<pre>'.print_r($content,true).'</pre>';
368
  if($kill) { die(); }
369
  }
370
+
371
  function true_false($value) {
372
  $value = trim($value);
373
  if(
379
  ) { return false; }
380
  return true;
381
  }
382
+
383
  function build_forecast($atts, $content=null) {
384
  $settings = shortcode_atts( array(
385
  'location' => $this->location,
398
  'type' => 'table'
399
  ), $atts );
400
  extract( $settings );
401
+
402
  // Set custom hard-coded width. Added in 1.2
403
  if($this->true_false($width)) { $width = ' width="'.$width.'"';}
404
+
405
  // Added in 1.2
406
  $cache = $this->true_false($cache);
407
+
408
  // They're hard to spell and long, man!
409
  $measurement = strtolower($measurement);
410
  if($measurement == 'c') { $measurement = 'celsius'; }
411
  if($measurement == 'f') { $measurement = 'fahrenheit'; }
412
+
413
  if($cache) {
414
  // Shorten the settings into an encrypted 40-byte string so that
415
  // it's never longer than the 64-byte database column
416
  foreach($settings as $k => $v) { $settings[$k] = esc_attr__($v); }
417
  $transient_title = implode('_', $settings);
418
  $transient_title = 'wund_'.sha1($transient_title);
419
+
420
  // See if it exists already.
421
  $table = get_transient($transient_title);
422
  }
423
+
424
  if(!$table || !$cache || isset($_REQUEST['cache'])) {
425
  $xmlStr = @wp_remote_fopen(trim($this->url.urlencode($location)));
426
  if(is_wp_error($xmlStr) || !$xml=simplexml_load_string($xmlStr)){
429
  } elseif(empty($xml->simpleforecast->forecastday)) {
430
  return '<!-- WP Wunderground Error : Weather feed was empty from '.$this->url.$this->location.' -->'.$content;
431
  }
432
+
433
  $tablehead = $tablebody = ''; $i = 0;
434
  foreach($xml->simpleforecast->forecastday as $day) {
435
  #$this->r($day); // For debug...
443
  $low = $low[$measurement];
444
  $icon = '<img src="'.$icon_url.'"'.$icon_size.' alt="It is forcast to be '.$conditions.' at '.$date['pretty'].'" style="display:block;" />';
445
  $colwidth = round(100/$numdays, 2);
446
+
447
  $temp = str_replace('%%high%%', $high, $highlow);
448
+ $temp = str_replace('%%low%%', $low, $temp);
449
  $temp = htmlspecialchars_decode($temp);
450
+
451
  $label = $this->format_date($date, $todaylabel, $datelabel);
452
+
453
  $tablehead .= "\n\t\t\t\t\t\t\t".'<th scope="col" width="'.$colwidth.'%" align="'.$align.'">'.$label.'</th>';
454
+
455
  $tablebody .=
456
  "\n\t\t\t\t\t\t\t".'<td align="'.$align.'" class="'.esc_attr__($class).'_'.sanitize_title($conditions).'">'.apply_filters('wp_wunderground_forecast_icon',$icon).'<div class="wp_wund_conditions">'.apply_filters('wp_wunderground_forecast_conditions',$conditions).'</div>'.apply_filters('wp_wunderground_forecast_temp',$temp).'</td>';
457
  }
474
  $table = preg_replace('/\s+/ism', ' ', $table);
475
  set_transient($transient_title, $table, apply_filters('wp_wunderground_forecast_cache', 60*60*6));
476
  }
477
+
478
  return apply_filters('wp_wunderground_forecast', $table);
479
  }
480
+
481
  function format_date($date, $todaylabel = false, $datelabel = false) {
482
  if(!$todaylabel) { $todaylabel = $this->todaylabel; }
483
  if(!$datelabel) { $datelabel = $this->datelabel; }
484
  extract($date);
485
+
486
  try {
487
  $dt = new DateTime("$year-$month-$day", new DateTimeZone($tz_long));
488
  $dt->setTime($hour,$min,$sec);
489
  $tt = new DateTime('', new DateTimeZone($tz_long));
490
  if($tt->format('Y-m-d') == $dt->format('Y-m-d')) { $label = $todaylabel; } else { $label = $datelabel; }
491
+ } catch(Exception $e) {
492
 
493
  }
494
+
495
  // First we do these easy date replacements
496
  $label = str_replace('%%weekday%%', $weekday, $label);
497
  $label = str_replace('%%day%%', $day, $label);
502
  preg_match('/(.*?)date\([\'"]{0,1}(.*?)[\'"]{0,1}\)(.*?)/xism', $label, $matches);
503
  if(!empty($matches)) {
504
  try {
505
+ // If we find date(), we format the date
506
  // and add the before text and after text back in
507
  $label = $matches[1].$dt->format($matches[2]).$matches[3];
508
  } catch(Exception $e) {
509
+
510
  }
511
  }
512
  return $label;
513
  }
514
+
515
  function get_icon_path($icons, $icon_set = false) {
516
  if(!$icon_set) { $icon_set = $this->icon_set; }
517
  // This may be slightly faster; let's try this first.
518
  switch($icon_set) {
519
+ case 'Default': return 'http://icons-ak.wxug.com/i/c/a/'; break;
520
+ case 'Smiley': return 'http://icons-ak.wxug.com/i/c/b/'; break;
521
+ case 'Generic': return 'http://icons-ak.wxug.com/i/c/c/'; break;
522
+ case 'Old School': return 'http://icons-ak.wxug.com/i/c/d/'; break;
523
+ case 'Cartoon': return 'http://icons-ak.wxug.com/i/c/e/'; break;
524
+ case 'Mobile': return 'http://icons-ak.wxug.com/i/c/f/'; break;
525
+ case 'Simple': return 'http://icons-ak.wxug.com/i/c/g/'; break;
526
+ case 'Contemporary': return 'http://icons-ak.wxug.com/i/c/h/'; break;
527
+ case 'Helen': return 'http://icons-ak.wxug.com/i/c/i/'; break;
528
+ case 'Incredible': return 'http://icons-ak.wxug.com/i/c/k/'; break;
529
  }
530
  // If this doesn't work, use the other method
531
  $this->get_icon_url($icons, $icon_set);
532
  }
533
+
534
  function get_icon_size($icon_set = false) {
535
  if(!$icon_set) { $icon_set = $this->icon_set; }
536
  switch($this->icon_set) {
537
+
538
  case 'Default':
539
+ case 'Helen':
540
  case 'Generic':
541
  case 'Simple':
542
  case 'Contemporary':
550
  default:
551
  return 42;
552
  break;
553
+
554
  }
555
  }
556
+
557
  function get_icon_url($icons) {
558
  foreach($icons['icon_set'] as $icon) {
559
  if(strtolower(trim($icon['name'])) == strtolower(trim($this->icon_set))) {
562
  }
563
  return false;
564
  }
565
+
566
  }
567
 
568
 
569
+ function simpleXMLToArray($xml,
570
  $flattenValues=true,
571
  $flattenAttributes = true,
572
  $flattenChildren=true,
615
  if(!$flattenAttributes){$return[$attributesKey] = $attributes;}
616
  else{$return = array_merge($return, $attributes);}
617
  }
618
+
619
  return $return;
620
  }
621