=== Time and Weather ===
Contributors: doyjo
Donate link:
Tags: weather, time, forecast, local, timezone, weather.gov, NWS
Requires at least: 5.6
Tested up to: 6.9
Stable tag: 1.7.28
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Local time + weather forecast shortcodes powered by Weather.gov, with optional visitor location input, radar loop, and optional Meow AI Engine chatbot placeholders.

== Description ==
Time and Weather adds simple shortcodes (and Gutenberg blocks) to any WordPress site:

* [time] — a live timezone-aware local time string
* [weather] — current conditions + a 7-day/period forecast accordion with weather icons

New in 1.7.28: the main weather output is also available as modular components (shortcodes + blocks), so site owners can rearrange the page layout:

* [taw_location_changer]
* [taw_current_conditions]
* [taw_radar_loop]
* [taw_forecast_7day]

Optional extras:

* Radar loop above the forecast (auto-follows the currently selected location, or you can paste a fixed GIF URL)
* Visitor switchable radar views: Local, Regional, National
* Temperature units toggle (Fahrenheit or Celsius)
* Visitor location input (search by city/ZIP) stored only in that visitor’s cookies
* Meow AI Engine (MWAI) integration: replaces {DATE} and {WEATHER} inside mwai_ai_instructions so your chatbot can answer “Are they open right now?” style questions with time/weather context (per visitor)
* Widget visibility rules for sidebar cards (show/hide by post type, category, tag)
* Sidebar widgets (Appearance → Widgets):
  - Time & Weather: Summary Card
  - Time & Weather: Clock Card
  - Time & Weather: Compact Forecast Card
  - Time & Weather: Weather Alerts

Weather is provided by the National Weather Service via Weather.gov (no API key required).

== Installation ==
1. Upload the `time-and-weather` folder to the `/wp-content/plugins/` directory.
2. Activate the plugin through the Plugins screen in WordPress.
3. Go to **Settings → Time & Weather** and set:
   - Default Location Label
   - Latitude and Longitude
   - Time Zone
   - Temperature Units (F/C)
   - (Optional) Show Radar Loop (leave URL blank for auto-following radar; choose the default view; or paste a fixed radar GIF URL)
   - Referrer Domain and Email (Weather.gov requests a contactable User-Agent string for server-side requests)

== Usage ==
Add shortcodes anywhere:

* [time]
* [weather]

Component shortcodes (optional):

* [taw_location_changer]
* [taw_current_conditions]
* [taw_radar_loop]
* [taw_forecast_7day]

You can also add widgets in **Appearance → Widgets** (or the Site Editor widget areas) for sidebar cards.

Optional debug shortcodes:

* [taw_date]
* [taw_weather_text]

== AI Engine (MWAI) integration ==
If you use Meow AI Engine, add tokens to your chatbot instructions:

* {DATE}
* {WEATHER}

Enable/disable this replacement in **Settings → Time & Weather**.

== Frequently Asked Questions ==
= Does visitor location switching change my site settings? =
No. Visitor selections are stored only in that visitor’s browser cookies. Your default settings remain unchanged.

= What weather source does this use? =
The National Weather Service API via Weather.gov.

= Do I need an API key? =
No.

= Why are Referrer Domain and Email required? =
Weather.gov recommends that automated requests include a contactable User-Agent string.

= Will uploading this ZIP create a duplicate plugin? =
WordPress won’t normally install over an existing plugin folder from a ZIP upload in wp-admin. To upgrade, overwrite `wp-content/plugins/time-and-weather/` via SFTP/File Manager, or deactivate + delete the old plugin first and then upload the new ZIP. (Your settings are stored in the database and will remain.)

== Changelog ==
= 1.7.28 =
* Release polish: updated admin Quick Start + documentation to include new blocks and component shortcodes.
* Weather layout: split [weather] into modular components (location changer, current conditions, radar loop, 7-day forecast) with dedicated shortcodes and Gutenberg blocks.
* Weather UI: current conditions line now includes the resolved location label (e.g., "Chicago, IL:") with responsive typography and wrap rules.
* Mobile UX: improved responsive scaling so current temperature/conditions remain visually prominent.
* Forecast accordion: refreshed styling (shadow/hover) while keeping strong day/night contrast and readable typography.
* Fix: resolved encoding issues that could display garbled characters on some sites.

= 1.7.27 =
* UI fixes and styling updates for the weather page and forecast accordion.

= 1.7.7 =
* Directory auto-detect: improved URL and taxonomy parsing so "city-stateName" slugs (e.g. sheboygan-wisconsin) are recognized reliably.
* Directory auto-detect: prefers URL/taxonomy context before scanning full post text, reducing false matches when articles mention nearby towns.

= 1.7.6 =
* Directory auto-detect: normalized builder-rendered text so concatenated lines like "AvenueSheboygan" are detected as "Avenue Sheboygan".

= 1.7.2 =
* Update: Removed inline weather alerts from the main [weather] shortcode output by default. Alerts are now intended to be displayed via the dedicated Alerts widget/block/shortcode and/or the optional sticky alert banner.

= 1.7.1 =
* Directory auto-detect: improved the page-text detector so it prefers the main post content container (and avoids unrelated locations from “Similar/Related” sections or sidebars).
* Directory auto-detect: improved taxonomy/body-class parsing so city-state(-zip) slugs (e.g. philadelphia-pa or philadelphia-pa-19103) are recognized more reliably.

= 1.7.0 =
* Added Gutenberg blocks for all built-in shortcodes (Time, Weather, Weather Alerts, Date Token, Weather Token) so you can insert them in the block editor without memorizing shortcode tags.
* Settings improvement: when you change the Default Location Label, the plugin will automatically look up and fill the matching latitude/longitude.
* Directory improvement: auto-detect now recognizes flexible "City ST" and "City, ST" patterns from page titles/headings/content, and slug prefixes like "city-st-...".

= 1.6.1 =
* Fixed forecast accordion not opening on some themes by namespacing accordion class names (taw-*) to avoid collisions with common theme/plugin accordion styles.
* Made forecast accordion ARIA ids unique per instance (prevents collisions when multiple weather shortcodes/widgets appear on the same page).

= 1.6.0 =
* Added widget visibility rules (show/hide by post type, category/tag, and tag/category archives) to all widget cards for better directory control.

= 1.4.1 =
* Added a Sidebar Widgets section to the admin settings page so site admins can discover and set up the new widget cards.

= 1.4.0 =
* Added 3 sidebar widgets (Summary Card, Clock Card, Compact Forecast Card).
* Added day/night backgrounds (automatic) and lightweight weather overlay layers (rain/snow/etc) for widget cards.
* Fixed auto-detect source flags not being read correctly in the front-end script.
* Improved location label handling: decodes HTML entities so "&#44;" shows as commas.

= 1.3.5 =
* Security hardening: rate-limits the public geocode proxy (cache hits do not count).
* Security hardening: geocode endpoint returns 403 if visitor search is disabled in settings.
* Security hardening: only allows https URLs for the optional radar GIF setting.
* Security hardening: validates the Weather.gov forecast URL before fetching server-side.
* Admin output: uses wp_json_encode for timezone data.

= 1.3.4 =
* Radar view selector labels simplified to: Local, Regional, National.
* Removed the extra high-res national option to keep the UI simple.
* If a legacy placeholder radar GIF was previously configured, it is now cleared without disabling radar.

= 1.3.2 =
* Radar loop can automatically follow the visitor-entered location (leave radar URL blank and enable “Show Radar Loop”).
* Improved radar settings guidance in the admin screen.

= 1.3.0 =
* Added Fahrenheit/Celsius switch
* Added optional radar loop
* Added optional visitor location switching (cookies)
* Improved time shortcode to update live in the selected timezone
* Added optional Meow AI Engine placeholders integration per visitor

== Upgrade Notice ==
= 1.7.28 =
Adds modular weather components (shortcodes + blocks) for flexible layouts, improves mobile responsiveness, refreshes the forecast accordion styling, and fixes encoding issues that could appear on some sites.

= 1.7.1 =
Improves directory auto-detect on pages that include multiple locations (for example, “Similar Services” sections), and improves city-state slug detection from tags/categories.

= 1.4.1 =
Adds widget setup instructions to the admin settings page.

= 1.4.0 =
Adds 3 sidebar widgets and improves directory-mode auto-location detection.

= 1.3.5 =
Security hardening for public geocode + remote fetches.

= 1.3.4 =
Radar view selector is now Local/Regional/National and legacy placeholder radar GIFs are cleared automatically.

= 1.3.2 =
Radar loop can auto-follow the currently selected location.

= 1.3.0 =
Adds unit toggle, visitor location switching, radar loop, and improved chatbot context injection.
