Skip to content

Commit

Permalink
2.0.8
Browse files Browse the repository at this point in the history
* Fixed: PHP warning [reported
here](https://wordpress.org/support/topic/error-with-new-version-1)
* Fixed: Date wasn't respecting current timezone
* Added: Support for `[forecast]` and `[wunderground]` shortcodes in
Text widgets by adding a `do_shortcode` filter on widgets. This had
been enabled in Version 1.x.
* Added: `wp_wunderground_forecast` filter to be backward-compatible
with Version 1.x
  • Loading branch information
zackkatz committed Oct 7, 2014
1 parent e91b9b9 commit 152d9e3
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 9 deletions.
Binary file added assets/img/thumbnail/table-horizontal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion inc/class-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ function render( $template = NULL, $data = array() ) {
*/
$data = apply_filters( 'wunderground_template_data', apply_filters( 'wunderground_template_data_'.$template, $data ) );

echo $this->twig->render("{$template}.html", $data);
$output = $this->twig->render("{$template}.html", $data);

$output = apply_filters( 'wp_wunderground_forecast', $output, $template, $data );

echo $output;

}

Expand Down
4 changes: 2 additions & 2 deletions inc/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,10 @@ function wunderground_get_subdomain( $language_key = NULL ) {
// Convert "French Canadian" to "frenchcanadian" for subdomain
$languages = wunderground_get_languages();

if( isset( $languages[$language_key] ) ) {
if( isset( $languages[$language_key] ) && isset( $languages[$language_key]['value'] ) ) {

// Get the name of the language
$subdomain = $languages[$language_key];
$subdomain = $languages[$language_key]['value'];

// Replace "-" and " " with nothing
$subdomain = str_replace(array(' ', '-'), '', $subdomain);
Expand Down
17 changes: 17 additions & 0 deletions readme.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,21 @@ <h3>Shortcode Parameters</h3>
</ul>


<h2>Finding your location</h2>

<p>If you&rsquo;re using the shortcode, and your location can&rsquo;t be found:</p>

<ul>
<li>Go to Wunderground.com</li>
<li>In the &ldquo;Search Locations&rdquo; box, type in your location</li>
<li>Click on the location when it appears in the auto-complete box</li>
<li>When the page loads, copy the URL. It will likely look like this: <code>http://www.wunderground.com/q/zmw:00000.4.17340</code></li>
<li>Copy the part of the URL after the <code>/q/</code>. In this example, it would be <code>zmw:00000.4.17340</code></li>
<li>Use that as your location in the shortcode, like this: <code>[wunderground location="zmw:00000.4.17340" /]</code></li>
<li>That should work!</li>
</ul>


<h2>International</h2>

<h3>Language</h3>
Expand Down Expand Up @@ -118,6 +133,7 @@ <h3>Language &amp; Formatting Filters</h3>

<ul>
<li><code>wunderground_enable_forecast_shortcode</code> (boolean) Disable the old <code>[forecast]</code> shortcode and only use <code>[wunderground]</code>. Default: <code>true</code></li>
<li><code>wunderground_widget_text_do_shortcode</code> (boolean) Prevent the plugin from enabling <code>do_shortcode</code> filter on widget output. This is to provide backward compatibility for Version 1.x. Added in 2.0.8. Default: <code>true</code></li>
<li><code>wp_wunderground_forecast_icon</code> (string) URL path to icon. Passes two arguments: <code>$output</code> (default path), <code>$icon</code> Name of icon to be fetched</li>
<li><code>wunderground_autocomplete_country_code</code> (string) Set the locale of the Wunderground autocomplete results. If you only want US locations, for example, return <code>US</code>. Default: <code>NULL</code></li>
<li><code>wunderground_date_format</code> (string) Filter the date format sitewide. Return a PHP date format string. <a href="http://codex.wordpress.org/Formatting_Date_and_Time">Learn more about formatting dates</a>. Default: <code>m/d</code></li>
Expand All @@ -140,6 +156,7 @@ <h3>Template Filters</h3>
<li><code>wunderground_template_paths</code> (array) Paths to check for template files. Default: <code>/wunderground/</code> sub-directory of the current stylesheet directory</li>
<li><code>wunderground_twig_debug</code> (boolean) Enable Twig template debugging. Default: if user is logged in and <code>?debug</code> is set in the URL.</li>
<li><code>wunderground_template_data</code> (array) Data passed to the template, available in Twig template rendering engine</li>
<li><code>wp_wunderground_forecast</code> (string) Filter the output of the forecast HTML</li>
</ul>


Expand Down
14 changes: 14 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,18 @@ Will output the forecast using the `simple` template, show three days of forecas
- `alerts` - Weather alerts for the forecast area. This functionality is not yet available.
* `hidedata` - The items to hide in the forecast. Instead of setting what to show, use the defaults and set what to hide. Accepts the same parameters as `showdata`. Default: `(Empty)` Example: `hidedata="search"` will hide the search bar, but will show the rest of the default data.

## Finding your location

If you're using the shortcode, and your location can't be found:

* Go to Wunderground.com
* In the "Search Locations" box, type in your location
* Click on the location when it appears in the auto-complete box
* When the page loads, copy the URL. It will likely look like this: `http://www.wunderground.com/q/zmw:00000.4.17340`
* Copy the part of the URL after the `/q/`. In this example, it would be `zmw:00000.4.17340`
* Use that as your location in the shortcode, like this: `[wunderground location="zmw:00000.4.17340" /]`
* That should work!

## International

### Language
Expand Down Expand Up @@ -92,6 +104,7 @@ If you want to have the files located in another place, you can use the `wunderg
### Language & Formatting Filters

* `wunderground_enable_forecast_shortcode` (boolean) Disable the old `[forecast]` shortcode and only use `[wunderground]`. Default: `true`
* `wunderground_widget_text_do_shortcode` (boolean) Prevent the plugin from enabling `do_shortcode` filter on widget output. This is to provide backward compatibility for Version 1.x. Added in 2.0.8. Default: `true`
* `wp_wunderground_forecast_icon` (string) URL path to icon. Passes two arguments: `$output` (default path), `$icon` Name of icon to be fetched
* `wunderground_autocomplete_country_code` (string) Set the locale of the Wunderground autocomplete results. If you only want US locations, for example, return `US`. Default: `NULL`
* `wunderground_date_format` (string) Filter the date format sitewide. Return a PHP date format string. [Learn more about formatting dates](http://codex.wordpress.org/Formatting_Date_and_Time). Default: `m/d`
Expand All @@ -108,6 +121,7 @@ If you want to have the files located in another place, you can use the `wunderg
* `wunderground_template_paths` (array) Paths to check for template files. Default: `/wunderground/` sub-directory of the current stylesheet directory
* `wunderground_twig_debug` (boolean) Enable Twig template debugging. Default: if user is logged in and `?debug` is set in the URL.
* `wunderground_template_data` (array) Data passed to the template, available in Twig template rendering engine
* `wp_wunderground_forecast` (string) Filter the output of the forecast HTML.


### Screenshots
Expand Down
28 changes: 25 additions & 3 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,25 @@ Learn about setting up the plugin, how to configure the shortcode, template over

== Frequently Asked Questions ==

= Where is the settings page? =
= [Upgrading from 1.x] Where is the settings page? =

Version 2.0 got rid of the default settings page; now shortcodes and widgets are configured individually.

= My forecast looks different! =
= [Upgrading from 1.x] My forecast looks different =

Version 2.0 made lots of changes as to how the forecast is displayed. You can download the last update of the "1.x" version of the plugin here: **[Version 1.2.5.1](https://downloads.wordpress.org/plugin/wunderground.1.2.5.1.zip)**

= [Upgrading from 1.x] My location can no longer be found =
If your location isn't working any more, follow the steps below:

* Go to Wunderground.com
* In the "Search Locations" box, type in your location
* Click on the location when it appears in the auto-complete box
* When the page loads, copy the URL. It will likely look like this: `http://www.wunderground.com/q/zmw:00000.4.17340`
* Copy the part of the URL after the `/q/`. In this example, it would be `zmw:00000.4.17340`
* Use that as your location in the shortcode, like this: `[wunderground location="zmw:00000.4.17340" /]`
* That should work!

= How do I use my own icons? =

If you want to use your own icons, you would add a filter to the bottom of your theme's <code>functions.php</code> file. See a [list of icons you should have available](http://www.wunderground.com/weather/api/d/docs?d=resources/icon). Here's sample code:
Expand All @@ -74,14 +85,20 @@ Please see the "Using your own template" section on the [Plugin Github page](htt
This plugin is released under a GPL license. *Weather Underground is a registered trademark of The Weather Channel, LLC. both in the United States and internationally. The Weather Underground Logo is a trademark of Weather Underground, LLC.*

= Do I need a Wunderground account? =
Wunderground has been very gracious and has provided the plugin with free data - you don't need your own account. If you want to use Wunderground data in your own application, [register for a Wunderground API account](http://www.wunderground.com/?apiref=5f97d1e033236c26).
Weather Underground has been very gracious and has provided the plugin with free data - you don't need your own account. If you want to use Wunderground data in your own application, [register for a Weather Underground API account](http://www.wunderground.com/?apiref=5f97d1e033236c26).

== Changelog ==

= Version 2.0 is a major update! =

If you are upgrading the plugin, your forecast will look different. Version 2.x made lots of changes as to how the forecast is displayed. If you want to go back after upgrading, you can [download the previous version here](https://downloads.wordpress.org/plugin/wunderground.1.2.5.1.zip).

= 2.0.8 on October 7 =
* Fixed: PHP warning [reported here](https://wordpress.org/support/topic/error-with-new-version-1)
* Fixed: Date wasn't respecting current timezone
* Added: Support for `[forecast]` and `[wunderground]` shortcodes in Text widgets by adding a `do_shortcode` filter on widgets. This had been enabled in Version 1.x.
* Added: `wp_wunderground_forecast` filter to be backward-compatible with Version 1.x

= 2.0.7 on October 3 =
* Fixed: `hidedata` shortcode parameter wasn't working properly
* Modified: Removed support for `%%day%%` `%%month%%` and `%%year%%` placeholder tags
Expand Down Expand Up @@ -180,6 +197,11 @@ If you are upgrading the plugin, your forecast will look different. Version 2.x

== Upgrade Notice ==

= 2.0.8 on October 7 =
* Fixed: PHP warning [reported here](https://wordpress.org/support/topic/error-with-new-version-1)
* Fixed: Date wasn't respecting current timezone
* Added: Support for `[forecast]` and `[wunderground]` shortcodes in Text widgets by adding a `do_shortcode` filter on widgets. This had been enabled in Version 1.x.

= 2.0.7 on October 3 =
* Fixed: `hidedata` shortcode parameter wasn't working properly
* Modified: Removed support for `%%day%%` `%%month%%` and `%%year%%` placeholder tags
Expand Down
2 changes: 1 addition & 1 deletion templates/snippets/date.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% if showdata.date is not empty and day.summary.date.epoch is not empty %}
{# To modify the date format, check out the `strings` method in template.php #}
<{{tag}} class="wu-date">{{ day.summary.date.epoch|date(datelabel) }}</{{tag}}>
<{{tag}} class="wu-date">{{ day.summary.date.epoch|date(datelabel, day.summary.date.tz_long) }}</{{tag}}>
{% endif %}
13 changes: 11 additions & 2 deletions wunderground.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,21 @@ function init() {
// Add the shortcode
add_shortcode( 'wunderground', 'wunderground_shortcode' );

// You can disable the forecast shortcode if you want to. It's definitely
// not namespaced!
/**
* Enable or disable the forecast shortcode if you want to, since it's not namespaced
*/
if( apply_filters('wunderground_enable_forecast_shortcode', true ) ) {
add_shortcode( 'forecast', 'wunderground_shortcode' );
}

/**
* Process shortcodes in widgets previous shortcodes in widgets
* @since 2.0.8
*/
if( apply_filters('wunderground_widget_text_do_shortcode', true ) ) {
add_filter( 'widget_text', 'do_shortcode' );
}

}

function require_files() {
Expand Down

0 comments on commit 152d9e3

Please sign in to comment.