Dark Sky in Weather Master

Posted on

A Brief Tutorial Outlining Installation Steps for the Weather Master WordPress Plugin

Weather Master is one of the easiest weather plugins to install and use.  It integrates well into most themes whose sidebar widget area is active. Once installed, the Weather Master widget will ask you within which location you would like it displayed.  Next, it will ask you a few well explained questions to define the data.  After saving the changes, the feed is live.  Outlined below are the steps used to define a Dark Sky weather feed.  The process is exactly the same for an Open Weather Map feed with the exception of the widget data definition process, which as stated previously, is very well documented.

  1. Use the WordPress Installer, Updater to grab Weather Master.  Alternatively, download and install manually from WordPress.org.
  2. Activate when prompted in the plugin info window, or from within the “Plugins” admin panel.
  3. Click the Weather Master widget you wish to use in the “Appearance | Widgets” panel and select the widget area to use. (Instructions follow as Setting Up Custom Widget Areas).
  4. Click “Active Weather Display” and enter a latitude and longitude at minimum in the options available.
  5. Save your preferences and enjoy your feed.

Read more Weather Master documentation at TechGasp or WordPress.org.

Setting Up Custom Widget Areas

To define our own widget areas or if the sidebar is disabled, we first have to define the widget area in functions.php:

 * Register widget area.
 * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
function custom_wp_widgets_init() {

  // Widget Area - Weather

  register_sidebar( array(
  'name' => esc_html__( 'Weather Feeds', 'bourbon-wp' ),
  'id' => 'widget-area-3',
  'description' => esc_html__( 'Add widgets here.', 'bourbon-wp' ),
  'before_widget' => '<section id="%1$s" class="widget weather-widget-area">',
  'after_widget' => '</section>',
  'before_title' => '<h2 class="widget-title">',
  'after_title' => '</h2>',

add_action( 'widgets_init', 'custom_wp_widgets_init' );

And now to have more control as to where Weather Master will diplay its widget, we can easily create a new widget area.  Simply place the following line of code where you wish a widget area to appear:

<?php if ( (!function_exists('dynamic_sidebar') || !dynamic_sidebar("Weather Feed")) ) : ?>
<?php endif;?>

You can even conditionally display it:

<?php if ( is_page( 'projects' ) && (!function_exists('dynamic_sidebar') || !dynamic_sidebar("Weather Feed")) ) : ?>
<?php endif;?>

It really is that easy. The only drawback is that since the display is contained within an iFrame, any refining of styles except the basic outer layout is not possible.

You can read more about “Widgetizing” at codex.wordpress.org/Widgetizing_Themes