myWeather widget

To create a quick and dirty widget from myWeather wordpress plugin just add the following to the end of myweather.php

 1 function widget_weather_init(){
 2   if ( !function_exists('register_sidebar_widget') )
 3     return;
 4   register_sidebar_widget(array('Weather', 'widgets'), 'widget_weather');
 5 }
 6 
 7 function widget_weather($args){
 8   extract($args);
 9   echo $before_widget . $before_title . $title . $after_title;
10   wp_myweather();
11   echo $after_widget;
12 }
13 
14 add_action('widgets_init', 'widget_weather_init');

Also the part where you search for the city could be added as a control for the widget but i didn't relay need it to be .

MyWeather plugin's homepage.

Update

If you have multiple users with different credentials on your blog and you are the only administrator you can restrict the access to myWeather plugin administration interface by changing the function myweathertoadmin() to look like this (use 10 instead of 1 for required level) :

1 function myweather_to_admin() {
2   if (function_exists('add_submenu_page')) {
3     add_submenu_page('options-general.php', 'myWeather',
4     'myWeather', 10, basename(__FILE__),'myweather_admin');
5   }
6 }

Comments