Tuxlog

Tuxlog, aus dem Alltag eines Linux-Fans

wp-forecast Reference v1.7 (english)

First of all, let me tell, you have found the english reference page of wp-forecast.
This translation was well done by Barbara at a really sunny day.

Barbara, thanks a lot for your work.The english reference is updated frequently. for the most recent information you can have a look at german reference page

This document will be completed step by step.

  1. Introduction
  2. Download
  3. Installation
    1. Requirements
    2. Installing wp-forecast
    3. Updating wp-forecast
    4. Adjusting wp-forecast.css
  4. Configuration
    1. Number of displayed locations and widgets
    2. General configurations (adjustable for each location/widget)
    3. Display configurations (adjustable for each location/widget)
    4. Configurations when using wp-forecast as widget
  5. Displaying the forecast
    1. Displaying by widget
    2. Displaying by inserting the code in sidebar.php
    3. Direct call via an URL
  6. Version History

1. Introduction

wp-forecast is a plugin for the popular blogging software WordPress. This plugin offers the possibility to display the current weather as well as a weather forecast for up to nine days and twenty locations. The plugin uses the weatherdata from accuweather.com. This way it is possible to display weather information for nearly all places on earth in your own WordPress blog. In addition to the functionality of choosing a location and making general configurations (for instance the interval for updating the weather data), wp-forecast gives you the possibility to display or hide every single weather information. A simple weather display looks like this:

wp-forecast simple widget

wp-forecast is published under the GNU General Public License. Additionally please note the terms of license of accuweather.com.

I am taking great efforts in testing the software that I develop and in trying not to produce any errors, but I still cannot exclude the incidence of a serious error. Therefore I do not take the responsability or warranty for the software that I am placing at disposal. The software can only be used on one’s own risk, I cannot be made responsible for any damages (for instance loss of data) caused by using my software.

2. Download
In this section you find a link to the current version of wp-forecast for download. Older versions can be found in the section “Version History”.

wp-forecast-2.1.zip Downloads: 4120 times

3. Installation

3.1 Requirements

wp-forecast requires PHP version 4.3 or higher and WordPress Version 2.2.x or higher. No more specific features are necessary. However some web hosts are blocking the PHP function ‘fsockopen’, which prevents wp-forecast from collecting the weather data. In this case you should ask your hoster to enable the function ‘fsockopen’ (and rather switch to another hoster if he doesn’t).

3.2 Installing wp-forecast

The installation of wp-forecast is like installing any other WordPress plugin. First unzip the archive to a local directory (using winzip, unzip or tar). Then upload the directory wp-forecast on your WordPress server into the directory wp-content/plugins.

Now log in to your WordPress account as administrator. Under ‘Plugins’ you can activate the plugin by clicking ‘activate’.

3.3 Updating wp-forecast

If you have already installed wp-forecast and now want to use a newer version, it is not necessary to deactivate the plugin. Just copy the new files into your wp-forecast directory. By deactivating the plugin all your settings will be deleted.

3.4 Adjusting wp-forecast.css

To accomodate the look of the wp-forecast widgets to your own liking, you can edit the file wp-forecast.css, which is a cascading stylesheet file. You find a good CSS reference here: http://www.w3schools.com/css/css_reference.asp.

A wp-forecast widget is displayed in this class hierarchy:

<div class=wp-forecast">
<div class="wp-forecast-curr">
<div class="wp-forecast-curr-details">
</div>
<div class="wp-forecast-copyright">
</div>
</div>
<div class="wp-forecast-fc">
<div class="wp-forecast-fc-details">
</div>
</div>
</div>

4. Configuration

The plugin’s settings, except for the widget options (see 5.1), can be done under Settings – wp-forecast.

4.1 Number of displayed locations and widgets, system parameter

Anzahl Widgets

In the upper part of the settings dialog the number of the used widgets is fixed and the settings of each widget can be selected.

wp-forecast supports up to twenty widgets, so it is possible to display the weather of up to twenty locations in your blog. Just select the number of widgets you would like to display from the dropdown list and click on “save”.

Each widget is assigned to a widget ID. This widget ID is a letter from A to T. By this letter each widget is identified definitely.

To configure a widget it can be selected by its widget ID from the second dropdown list. Clicking on “select widget” lets you see the appropriate adjustings underneath.

From version 1.6 you can set a time limit for the connection and the date transfer from accuweather. This parameter is very useful when you have a slow connection from your server to accuweather’s server and want to avoid long waiting periods when the page is loading. This setting is in seconds and is valid for all widgets.

4.2 General configurations (adjustable for each location/widget)

On the left side of the settings dialog you see the general options of each widget, which means that the options are displayed and saved for the widget that is just being displayed.

Settings dialog

Location: The location whose weather data should be displayed. As accuweather’s abbreviations for the locations and its partly misspelled names cannot always be handled easily you can also search the location in the field Searchterm at the bottom of the settings dialog. Enter a search phrase (for instance London), and click on “Search location”. The results of your search are displayed in a dropdown list. Select your location from that list and click on “Set location”. The selected location with the necessary accuweather code will be displayed in the field Location. Click on “Update options” to complete your settings. Notice: accuweather does not support umlauts like german ü or swedish ø, so you have to replace them by the corresponding vowal (ü by u or ø by o) in your searchterm.

Locationname: Here you can enter an alternative locationname. The names that come from accuweather are mostly in english and will be replaced by your alternative name. Entering &nbsp; in this field will display no locationname at all.

Refresh cache after … secs: In this field you can enter the time interval (in seconds) after which the weather data should be updated. When calling a page that contains a wp-forecast-widget whose weather data is older than the displayed time interval, the weather data will be updated by accuweather.

Use metric units: Activating this checkbox will display metric units for temperature (Degree Celsius (C)) and wind speed (meter per second) instead of the english units Fahrenheit and mph.

Use current time: Activating this checkbox will display the current time instead of the last time the weather data had been updated by accuweather.

Windspeed-Unit: Here you can set the windspeed-unit. Possible settings are meter per second (m/s), kilometer per hour (km/h), miles per hour (mph) and knots (kts).

Language: Here you can set the language for the selected widget. Currently english, german, french, dutch, portuguese, italian and swedish are supported.

Forecast: Here you can select which forecast data should be displayed beside the current weather data. A forecast up to 9 days is possible, seperated into day (Daytime) and night (Nighttime).

Save your selected settings by clicking on “Update options”.

4.3 Display configurations (adjustable for each location/widget)

On the right side of the settings dialog you see the display configuration for each weather data. A selected checkbox means the information will be displayed, a non-selected checkbox means it will not be displayed. “n/a” means ”not available”. The settings can be selected seperately for the current conditions, the daytime forecast and the nighttime forecast. Save your selected settings by clicking on “Update options”.

4.4 Configurations when using wp-forecast as widget

Content follows.

5. Displaying the forecast

Content follows.

5.1 Displaying by widget

Content follows.

5.2 Displaying by inserting the code in sidebar.php

wp-forecast offers you several functions when inserting the code directly into your sidebar.php.

function wp_forecast($wpfcid="A", $language_override=null)
function wp_forecast_range($from=0, $to=0, $numpercol=1, $language_override=null)
function wp_forecast_set($wset, $numpercol=1, $language_override=null)

The necessary parameter for the function wp_forecast is the ID of the widget to display. Optionally you can indicate the iso languagecode of the language the forecast should be displayed in.

Examples:

wp_forecast ( "A" ); // displays widget A in the language of your blog's settings
wp_forecast( "C", "de_DE" ); // displays widget C in german

As wp-forecast supports up to 20 widgets, you have to indicate which widget to use when you insert wp-forecast manually into your sidebar. To do so, use letters in alphabetical order.
For your first widget use wp_forecast(“A”), for the second one wp_forecast(“B”), and so on.
For downwards compatibility the first widget (”A”) will be selected automatically when the code is inserted without an ID (wp_forecast()).

Generally you should check the existance of a called function in your sidebar.php. You can do this by a simple if-query which can be used with the other functions as well:

if ( function_exists(wp_forecast) ) {
wp_forecast( &lt;widget_id&gt; );
}

The function wp_forecast_range displays several widgets in a table. The parameters are a from- and a to-value (both integer), the number of widgets per table row and the iso languagecode. All parameters are optional.
Without parameters the first widget is displayed in your standard language.

Examples:

wp_forecast_range(0,6,2); // displays the first 6 widgets in a table 3x2
wp_forecast_range(10,20,5) // displays widgets 10 to 20 in a 5x2 table

The function wp_forecast_set displays the number of widgets you would like to display. The parameters are an array with your selected number of widgets, the number of widgets per table row and the iso language code. The number of widgets is essential, the other two parameters are optional.

Examples:

wp_forecast_set( array("C","D","H","A"), 2 ); // displays widgets C, D, H, A in a 2x2 table
wp_forecast_set( array("A","B","C","K","L","M"), 3, "fr_FR"); // displays widgets A, B, C, K, L, M in a 3x2 table

5.3 Direct call via an URL

It is possible to call a widget directly via an URL. The URL has to be something like http://my.wordpress.domain/wp-content/plugins/wp-forecast/wp-forecast-show.php?wpfcid=A. “A” indicates your selected widget. As a second parameter you can use language_override to adjust the language of the widget.

6. Version History

  • pre 1.0b see older versions
  • 2007-07-17 v1.0b added support for up to 20 widgets with different, locations and settings, added portugese language support, weather data is now cached in the database, no cookies needed anymore, default value of missing translations is now english, removed configuration dialog from widgets page to avoid misunderstanding about setup, fixed some minor errors
  • 2007-07-25 v1.0b2 work around for bug 4275 in wordpress 2.2, removed widget id from output
  • 2007-08-04 v1.0b3 fixed output of before/after widget stuff for empty forecast, fixed different parameters for calling wp_forecast as widget and from sidebar.php, added swedish translation (thx to Håkan Carlström)
  • 2007-09-01 v1.0b4 fixed humidity / pressure checkbox, removed hard coded formatting, added css class, added support to show current time
  • 2007-09-09 v1.0 fixed accuweather call for us locations, now works with wordpress mu
  • 2007-10-01 v1.1 fixed: setting the current time could not be disabled, fixed: on some servers the current date was converted to 0, switched translations to gettext as recommended by wp codex
  • 2007-11-05 v1.2 extend error handling for serverloss, added iso8859-1 coded german translation, fixed bug with german winddirections, added a widget title, removed standard location label (this can be handled via alternate location
  • 2007-12-26 v1.3 added french translation, added german icon 11 (fog, 11_de.gif), extended css classes to support horizontal view via css, removed repeating section title
  • 2008-01-26 v1.4 fix loading the wright textdomain when called from outside wordpress, added a bit debug code, work around for a bug in k2rc3 theme, added italian translation, added english lanuage file, a bit of code cleanup, extend function wp-forecast to select language per widget, added functions to display a set and a range of widgets at once
  • 2008-05-12 v1.5 fixed two dutch phrases in dutch translation, added norwegian translation (thanks to Eilif)
  • 2008-07-11 v1.6 removed some hardcoded css, it is now possible to call the widget directly outside from wp, fixed a problem with wp >2.5 and the widget dialog, removed some redundant html, when showing no current weather information, placed forecast header into own table with own css class, added timeout parameter for the accuweather connections, rounded humidity to integer values, fixed some typos in swedish translation and added norwegian selection (thanks to RAM_OS)

Older versions to download:

Artikel, die auch interessant sein könnten:

Diesen Artikel mit anderen teilen: Diese Icons verlinken auf Bookmark Dienste bei denen Nutzer neue Inhalte finden und mit anderen teilen können.
  • Print
  • email
  • Technorati
  • del.icio.us
  • MisterWong
  • Linkarena
  • Alltagz
  • Blogosphere News
  • Google Bookmarks
  • YahooMyWeb
  • Y!GG
  • Bloglines
  • TwitThis
  • Webnews
  • Digg
  • Wikio DE
  • Oneview
  • Facebook
  • XING

22. Juli 2008 Geschrieben von | wordpress | 106 Kommentare | Trackback URI

106 Kommentare zu wp-forecast Reference v1.7 (english)

  1. 60

    Thank you, Took me a while to locate a weather script that would do what I wanted it to do. After having someone modify the output I finally have the look I wanted http://www.todaysredmond.com/ Can see it has been modified and styled to my header to display what I needed it to do.

    So thank you again for providing this plugin.


  2. 59

    Pingback: wp-popular.com » Blog Archive » WP-Forecast Reference

  3. 58

    Thank you Hans for your answer,

    I thought that thanks to “localization”, I could manage it manually (with the call load_my_plugin_domain, or maybe call for a translator domain). Actually, my entire project works, I can switch from french to english easily, except for wp-forecast in the sidebar. Too bad.

    I tried to managed my sidebar manually but unfortunately, but I did not succeed in. So I won’t use it.

    Anyway, again, thank you for your help !


  4. 57

    Hi Hans,

    Thanks for that plug-in !
    I am building a multilingual blog where you can switch from a language to another by clicking on a button.
    Unfortunately, I have not found yet how to proceed if I want the widget to switch between the two languages : it always stays in the language I chose previously in wp-Forecast settings.

    Any idea ?

    Thanks!


    • 57.1

      hello Namps,

      well, there is no automatic solution at the moment using widgets. but if you handle your sidebar.php manually it should be possible to change the language using a piece of php. you can give the language as the second parameter. the call is wp_forecast($wpfcid=”A”, $language_override=null) giving the the language code e.g. “de_DE” or “en_US” as the second parameter should do the trick.

      hope it helps

      hans

       

  5. 56

    Hans, I’d like to send you my wp-settings.php file but I did not find your email on the website (the little icon at the end of your post does not work for me, the address box is empty in the message thunderbird opens )! Can you write your address in aposte or send me an email?

    Thank you very much.

    Eric


  6. 55

    Hello Hans, thank you for your plugin!
    I have a problem with the widget : if I choose the “?” to have a dropdown menu with my two locations, I have an error message displayed above : (I can send you an image by email, it can be better…)

    “Deprecated: Assigning the return value of new by reference is deprecated in W:\wamp\www\pellegrin\wp-settings.php on line 646

    Deprecated: Assigning the return value of new by reference is deprecated in W:\wamp\www\pellegrin\wp-settings.php on line 661

    and so on before the widget is shown.

    Do you know what is the problem?

    Thank you


    • 55.1

      hello Eric,
      which version of wordpress do you use? did you make any changes to wp-settings.php? can you send me your wp-settings.php file please?

      regards, hans

       

  7. 54

    Hi Hans,

    Great plugin, works really well, thanks!

    I’ve got my plugin working at the moment in the bottom left of my website’s footer. What I want to do is change the format a little: remove the name of the city, and put the date, time and current weather on one line together, like this:

    February 4, 2010, 1:45 am, [ICON] 8°C wind speed: 7 mph S

    How can I do this? I’m happy to play with any PHP or Java, but which files and which part?

    Many thanks,

    Mark


    • 54.1

      hello Mark,
      I would reccomend using the data api of wp-forecast it is described in the german wp-forecast reference under section 5.4. just use

      $erg=wp_forecast_data("A","de_DE"); print_r($erg);

      replacing the widget id and the langugage code as needed.
      you can then select which data to display using normal php code. since you use it in the footer, you have to edit the footer.php og your theme.

      hope it helps, hans

      p.s. sorry, this part isnt translated to english yet

       

  8. 53

    Hi Hans,

    Been away for a couple of weeks so only just got another chance to look into this. From what I can see, my blog time is correct. When I go to the ‘General Settings’ page in the Admin area of WordPress it shows a ‘UTC’ time and a ‘local’ time. I’m assuming that the UTC time is the time of the UK web server where my site is hosted – the time is correct for the UK. I have teh timezone set to Calcutta (as I am in India) and the local time is shown correctly as +5.5 hours ahead of UK time. So this all seems correct, right?

    But on my actual blog, the time shown by your plugin for Hyderabad is always 1/2 hour slow. (The times shown for the other two locations in the UK are correct). I have the use current time checkbox selected. Any idea why this might be? See here http://www.jos.co.uk for yourself.

    Thanks, and keep up the good work :good: James


  9. 52

    Hi Hans,

    Thanks for working on the new version of your plug-in, the AccuWeather links are now working perfectly and open up in a new window which is much better!

    I’m a little confused by the “Use current time / Time Offset” feature though. It seems that these options are either one OR the other, i.e. you cannot use the current time with a time offset. Here in India, the time displayed is always 1/2 hour too slow and hence I want to add on 30 minutes. But I currently only seem to be able to do this when the “Use current time” checkbox is not ticked. It is therefore only possible to offset the time that the weather forecast was updated by AccuWeather, and not the current time. Hopefully this is a simple fix! Also, it would be worth stating whether the time offset needs to be entered in seconds, minutes or hours. I think it is minutes (right?) but this is a little confusing as it doesn’t say and the refresh cache period directly above is in seconds.

    Hope this feedback is useful! Regards, James :good:


    • 52.1

      hello James,
      it is designed as follows: if you check “use current time”, wp-forecast takes the blogtime, if you uncheck it wp-forecast calculates the time which comes from accuweaher (which is the time the weather data was stored at accuweather). the offset is entered in minutes and is meant as a possibility to correct the accuweather time, because there are some locations accuweather sends the wrong time.
      for your situation there are two scenarios which can be possible. you blogtime is wrong, which is a problem with wordpress and should be corrected because all your comments, posts, etc. get the wrong time or wp-forecast calculates the wrong blogtime for you blog, which has to be analyzed in wp-forecast.
      can you tell which case it is? I will add the unit of the offset in the next release.

      thank you very much for your feedback
      regards, hans

       

  10. 51

    My site is aubstorehouse DOT com. (Sorry I don’t want any incoming links to it :) … If you want to contact me by email, that’d be great too. The WordPress version I’m running is 2.7. My own location is in Utah, but you should be able to see that on the page in the sidebar with the plugin information too. If you need more info, let me know. Thanks so much for looking into this!!!


Hinterlasse eine Antwort

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *

*

Du kannst folgende HTML-Tags benutzen: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">

:bye: 
:good: 
:negative: 
:scratch: 
:wacko: 
:yahoo: 
B-) 
mehr...