Weather and Time Plug-in

Posted: June 11, 2012 in My creations, Plug-ins, Wordpress
Tags: , , , , , , , ,

Features :-

1. You can display weather and time of multiple cities.

2. The front-end display is simple and flexible. So you can style the front-end easily based on your theme.

3. There are several options in plug-in admin. So you can easily manage the plug-in.

Download Plug-in

Installation and Usage :-

1. Download and install the plg-in
2. Use <?php weather_time(); ?> or <?php weather_time(array(‘city’ => ‘Your City’,’zone’ => ‘Your Time Zone’)); ?> .
3. You can use the shortcode [weather_time] or [weather_time city="Your City" zone="Your Time Zone"] .
4. You can also use the widget “Weather & Time” for widget area.

Screenshots :-

Comment here if you have any queries..

About these ads
Comments
  1. Elizabeth says:

    I have been trying to install the weather and time plugin on WP (version 3.4.1) and cannot seem to get it to display. I have tried putting both

    <?php weather_time(); ?>

    and

    <?php weather_time(array(‘city’ => ‘Toronto’,’America/New_York’ => ‘America/New_York’’)); ?>

    on the sidebar coding but nothing shows. What have I done incorrectly?

    • labeeb1604 says:

      For the sidebars… you can use widgets…u can see weather time widget in widgets section.

      Regarding :- weather_time()
      you have to configure the city and time zone in backed/admin section.

      And use

      weather_time(array(‘city’ =&gt ‘Toronto’,’zone’ =&gt ‘America/New_York’))

      instead of

      city=>‘Toronto’,’America/New_York’ => ‘America/New_York’’)); ?>

      You can use the shortcode [weather_time] or [weather_time city="Your City" zone="Your Time Zone"]

      • Elizabeth says:

        Thank you for your quick reply.

        I am not using widgets and would prefer to enter the coding directly onto the sidebar file. I have already configured the city and time zone in the admin area and put the following into the sidebar coding.

        <?php weather_time(array(‘city’ => ‘Toronto’,’zone’ => ‘America/New_York’)); ?>

        Nothing shows up.

        Please advise.

  2. labeeb1604 says:

    where you using this..

    if you are placing the code in admin panel please use the shortcode

    [weather_time city="Toronto" zone="America/New_York"] .

  3. Elizabeth says:

    I would like it to appear on the sidebar of my wordpress and have put the coding into my sidebar coding.

    If I am placing the code in the admin panel, exactly where in the admin panel is the short code to be placed?

  4. labeeb1604 says:

    if uhave dynamic sidebars..it wll better to use widget otherwise u have to place php code in ur sidebar.php of ur theme file

  5. Elizabeth says:

    Update! I’m please to report that I’ve now managed to get the plugin to work without using the widget. (Please note that the installation instructions at http://wordpress.org/extend/plugins/weather-and-time/installation/ are mangled.) I don’t know why it wasn’t working before. But I would like to change the styles. Is there an easy way to do that, or must I look in the source code and change my theme stylesheet?

    • labeeb1604 says:

      Nice to here this from u….

      each and every text has a css class,. u can see them by inpecting element from bowser, and u can style these classes in ur theme style sheeet…

  6. Elizabeth says:

    Okay, thank you.

  7. Elizabeth says:

    Hello again. Here I am back with yet another question. Is there a way to show the wind in kph rather than mph? I looked around in the various php files and the only thing I could find was the following:

    code:
    if(get_option($shortname.”_wind”)==”yes”)

    Any ideas?

  8. Labbeb says:

    no…ucant chane the unit…bcz the unit is came from the google service itself…u can covert using some custome php pregmatch codes…

    • Elizabeth says:

      I could do that if I knew how….

      What I’ve done in the meantime is to add “(multiply by 1.6 for kph)” to the ‘wind’ section in weather.php:

      ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

      <?php if(get_option($shortname.”_wind”)==”yes”) : ?>
      <span class=”wind”>
      <?php print “, “.$current[0]->wind_condition['data']; ?> (multiply by 1.6 for kph)
      </span>
      <?php endif; ?>

  9. Labbeb says:

    First you have to split unit and the numeric value from .$current[0]->wind_condition['data'] , using php pregmatch function, after that u have to multiply this with 1.6 and display the result and add the unit as kph…

  10. Elizabeth says:

    Yes, that works. Thanks for the hint about using pregmatch

  11. Elizabeth says:

    No, I’m not a developer. I like to fool around with the coding to customize it to my taste and just muddle my way through (I had to get help from a real programmer for this one though. I only know enough php to make cosmetic changes). I’m in Canada.

  12. Elizabeth says:

    Hello again; I would like to show forecasted temperature (in celcius) but when I choose “yes” for forecast, it only shows the icon and condition. For today in Toronto, it is “thunderstorm”.

    I tried selecting “show high and low temperature” but that CAN’T be right. For today in Toronto when it is already 22C and likely to go up to 30C, this is what appears:

    Low Temp : -4°C
    High Temp : 14°C

    This cannot be correct. For Toronto on 31July, the average high is 27C and average low is 15C. The record high for this day is 36C in 1975 and the record low is 7C in 1965.

    Please advise.

  13. Elizabeth says:

    Excuse me for replying to myself.

    I temporarily switched to showing both Celcius and Fahrenheit and saw that the forecasted F temp were correct. So I took a closer look at the coding to see the following for the forecasted high in Celcius:

    $val=intval($forecast_list[$i]->high['data']);
    echo $val-72;echo “°C     “;

    Subtracting 72 doesn’t work to convert from F to C. The standard formula is to subtract 32 and multiply by 5/9:

    round(($val – 32) * 0.55)

    So here is what I have now for the forecast Low:
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    <?php if((get_option($shortname.”_unit”)==”Degree Celsius”) || (get_option($shortname.”_unit”)==”Both”)) : ?>
    <?php $val=intval($forecast_list[$i]->low['data']);
    echo round(($val – 32) * 0.55).”°C “; ?>
    <?php endif; ?>
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

    and for the forecast high:

    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    <?php if((get_option($shortname.”_unit”)==”Degree Celsius”) || (get_option($shortname.”_unit”)==”Both”)) : ?>
    <?php $val=intval($forecast_list[$i]->high['data']);
    echo round(($val – 32) * 0.55) . “°C “; ?>
    <?php endif; ?>
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

    With this fix, it now works correctly.

  14. Elizabeth says:

    Oops, I forgot to encode the degree sign… Here is the coding again:

    For the Low:

    ::::::::::::::::::::::::::::::::::::::::::::::
    <?php if((get_option($shortname.”_unit”)==”Degree Celsius”) || (get_option($shortname.”_unit”)==”Both”)) : ?>
    <?php $val=intval($forecast_list[$i]->low['data']);
    echo round(($val – 32) * 0.55).”&deg;C     “; ?>
    <?php endif; ?>
    :::::::::::::::::::::::::::::::::::::::::::::;

    For the high:
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::
    <?php if((get_option($shortname.”_unit”)==”Degree Celsius”) || (get_option($shortname.”_unit”)==”Both”)) : ?>
    <?php $val=intval($forecast_list[$i]->high['data']);
    echo round(($val – 32) * 0.55) . “&deg;C     “; ?>
    <?php endif; ?>
    ::::::::::::::::::::::::::::::::::::::::::::::::::::

    • labeeb1604 says:

      Thank you so much…thank you for clarifying me.. i didn’t checked the conversion formula correctly.. Thank you so much for your reply.. And i will update the code in plug-in soon.

  15. Elizabeth says:

    You’re most welcome. And thank you again for the plugin.

  16. Rich says:

    Quick question. I am showing the time and weather for Los Angeles and Moscow. It is displaying as Los Angeles, CA and Moscow, Moscow. Is there a way to show Moscow, RU <- for Russia?

    I've had comments from people that Moscow, Moscow look like a mistake

    Thanks, great plugin btw. very easy and looks great.

    • labeeb1604 says:

      No, The short code of the city is generated from the google api. If there any short code in google it will appear there. if you want the same you can hard code it for moscow.

      Thank you

  17. Rich says:

    i am getting a error that says

    Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 2: parser error : AttValue: ” or ‘ expected in /wp-content/plugins/weather-and-time/weather.php on line 17

    How do i fix this?
    Thank you

  18. Rich says:

    Just saw this… at the end of the errors it says this

    Fatal error: Call to a member function xpath() on a non-object in /wp-content/plugins/weather-and-time/weather.php on line 18

  19. labeeb1604 says:

    hmm.. Just reload the page…some times it may becuase of bad network connection or the server will be in down condition.. Please let me know which city u have tried!!

  20. Rich says:

    Thanks for the quick reply,
    The cities are los angeles and moscow. after a couple of reloads everything works. if i do a few more reloads or page changes it breaks again.

    You say may be a bad connection or server down, are you referring to googles end?

    thanks

  21. labeeb1604 says:

    Yeh..The plug-in fetching data from google..

  22. Rich says:

    so its not something on our end and there is no fix other then a refresh of the page?

  23. labeeb1604 says:

    Yeh…i have noticed it.. I will check the solution.. i think i have to show an error message in this condition.. i will update it in new version..

  24. Rich says:

    Ok, Thank you

  25. Rich says:

    could a possible solution other then a error message be adding some sort of data storage, to keep the information safe for X seconds and reduce the requests to googles servers?

  26. Hi i have installed your plugin but i cant find anywhere the control panel of google

  27. Hi, How can i install the plug in please? i use MAC. the file is downloaded on my Mac but i do not know what to do next. looking forward your reply.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s