diff --git a/assets/img/thumbnail/table-horizontal.png b/assets/img/thumbnail/table-horizontal.png new file mode 100644 index 0000000..5509dca Binary files /dev/null and b/assets/img/thumbnail/table-horizontal.png differ diff --git a/inc/class-template.php b/inc/class-template.php index 8b40db4..fdbf975 100644 --- a/inc/class-template.php +++ b/inc/class-template.php @@ -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; } diff --git a/inc/functions.php b/inc/functions.php index 44e59fc..aeae696 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -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); diff --git a/readme.html b/readme.html index 9f21348..709fee7 100644 --- a/readme.html +++ b/readme.html @@ -78,6 +78,21 @@

Shortcode Parameters

+

Finding your location

+ +

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

+ + + +

International

Language

@@ -118,6 +133,7 @@

Language & Formatting Filters

diff --git a/readme.md b/readme.md index 1143c21..892f0be 100644 --- a/readme.md +++ b/readme.md @@ -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 @@ -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` @@ -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 diff --git a/readme.txt b/readme.txt index f1ac1c4..248611f 100644 --- a/readme.txt +++ b/readme.txt @@ -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 functions.php 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: @@ -74,7 +85,7 @@ 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 == @@ -82,6 +93,12 @@ Wunderground has been very gracious and has provided the plugin with free data - 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 @@ -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 diff --git a/templates/snippets/date.html b/templates/snippets/date.html index 516569e..98bdeb8 100644 --- a/templates/snippets/date.html +++ b/templates/snippets/date.html @@ -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}} class="wu-date">{{ day.summary.date.epoch|date(datelabel, day.summary.date.tz_long) }} {% endif %} diff --git a/wunderground.php b/wunderground.php index 17b2aec..00e1739 100644 --- a/wunderground.php +++ b/wunderground.php @@ -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() {