WP Manifestindependent plugin directory
manifest / utilities / fair-weather

FairWeather

FairWeather is a lightweight WordPress plugin that displays the current weather in a simple two-line format using a shortcode.

★ 0stars

Install

Download source zip No release zip yet

This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/kemtopher/fair-weather/archive/refs/heads/main.zip
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

FairWeather is a lightweight WordPress plugin that displays the current weather in a simple two-line format using a shortcode.

  • Line 1: location (City, State, Country Code)
  • Line 2: weekday + date + current temperature (for example: Tues. 4 72°F)

It is designed for theme areas like headers, widgets, and Elementor containers where a compact weather block is needed.

Build Overview

This plugin is a classic PHP WordPress plugin with no build steps.

Core parts:

  • fair-weather.php: plugin bootstrap, constants, activation defaults, hooks
  • includes/class-settings.php: Settings API registration and admin menu page
  • admin/settings-page.php: settings page UI
  • includes/class-weather-client.php: location resolution + weather API calls + caching
  • includes/class-shortcode.php: shortcode rendering and scoped/global style injection
  • assets/frontend.css: default front-end styles

Dependencies

Runtime Requirements

  • WordPress 6.0+
  • PHP 7.4+

External APIs

  • OpenWeatherMap
    • Required for geocoding and current weather data
    • You must provide your own API key in plugin settings
  • ip-api.com
    • Used server-side for visitor IP geolocation when no shortcode location override is provided

Internal/Platform Dependencies

  • WordPress Settings API
  • WordPress Shortcode API
  • WordPress HTTP API (wp_remote_get)
  • WordPress Transients API (get_transient / set_transient)

Installation

  1. Place the plugin folder in wp-content/plugins/.
  2. Activate FairWeather in WordPress Admin.
  3. Go to Settings -> FairWeather.
  4. Add your OpenWeatherMap API key.
  5. Configure defaults (location, unit, optional global CSS).
  6. Insert shortcode [fairweather] where you want output.

Plugin Settings

Open: WordPress Admin -> Settings -> FairWeather

1) OpenWeatherMap API Key

2) Default Location

  • Field: Default location
  • Example: Atlanta, GA
  • Used as fallback when IP geolocation is unavailable or fails.

3) Default Temperature Unit

  • Field: Default temperature unit
  • Options:
    • Fahrenheit
    • Celsius

4) Global Custom CSS

  • Field: Global custom CSS
  • Optional CSS rules loaded on pages where the shortcode appears.
  • Useful selectors:
    • .fairweather
    • .fairweather__location
    • .fairweather__meta
    • .fairweather__temp
    • .fairweather__error

Shortcode Usage

Base shortcode:

[fairweather]

Shortcode Attributes

  • location (optional)
    • City/region string, or lat/lon format: "33.7490,-84.3880"
    • If omitted, plugin tries IP geolocation, then falls back to the default location setting.
  • unit (optional)
    • f or c
    • If omitted, uses the admin default unit
  • class (optional)
    • Additional CSS classes added to wrapper
  • css (optional)
    • Scoped declaration block applied to this shortcode instance

Examples:

[fairweather location="Atlanta, GA"]
[fairweather unit="c"]
[fairweather location="33.7490,-84.3880" class="header-weather"]
[fairweather css="font-size:14px;color:#fff;"]

How Location Is Resolved

Resolution order:

  1. Shortcode location attribute (if provided)
  2. Visitor IP geolocation
  3. Default location from plugin settings

When IP is private/local (common in local development), it skips IP geolocation and uses the default location.

Caching and Performance

  • Current weather values are cached via WordPress transients for 20 minutes.
  • Cache key includes rounded coordinates and units.

Notes

  • This plugin outputs weather server-side at render time.
  • If API key is missing or API calls fail, an error message is rendered in the shortcode output.