WP Manifestindependent plugin directory
manifest / editor / dtmg-weather-posts-block

DTMG Weather Posts Block

Custom WordPress Gutenberg block plugin displaying two selected posts and a cached OpenWeatherMap weather snippet.

by Oleh Pyrkha · github.com/olezik777/dtmg-weather-posts-block

0stars
0forks

Install

No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:

wp plugin install https://github.com/olezik777/dtmg-weather-posts-block/archive/refs/heads/main.zip

Custom WordPress plugin with one dynamic Gutenberg block. The block displays two selected WordPress posts and a cached OpenWeatherMap weather snippet.

Author: Oleh Pyrkha

Features

  • Dynamic Gutenberg block for Full Site Editing friendly usage.
  • Editor controls for selecting exactly two posts.
  • Editorial 3/4 + 1/4 frontend layout: featured post on the left, side post and weather snippet in the right rail.
  • Weather snippet replaces the third post card from the provided Figma composition.
  • Latitude and longitude controls.
  • Weather field visibility toggles.
  • Server-side OpenWeatherMap API integration.
  • AJAX endpoint for logged-in and logged-out users.
  • One-hour weather cache per coordinate pair.
  • Admin settings page for the API key.
  • WP-CLI command for clearing cached weather data.
  • PSR-4 style PHP architecture.
  • Archivo and Archivo Narrow loaded through Google Fonts.

Installation

  1. Upload the plugin folder to wp-content/plugins/dtmg-weather-posts-block.
  2. Activate DTMG Weather Posts Block in WordPress admin.
  3. Go to Settings → DTMG Weather Block and add the OpenWeatherMap API key.
  4. Add the Weather Posts block in the editor.

Development

Install PHP dependencies:

composer install

Install JS dependencies:

npm install

Build block assets:

npm run build

The repository already includes a prebuilt build/ folder so the plugin can run immediately after upload.

WP-CLI

Clear cached weather responses:

wp dtmg-weather clear-cache

The next frontend AJAX request will fetch fresh weather data from OpenWeatherMap.

Notes

  • The OpenWeatherMap API key is stored in WordPress options and is never printed into frontend JavaScript.
  • Weather data is requested through admin-ajax.php using the dtmg_get_weather action.
  • Coordinates are validated server-side.
  • Frontend markup is rendered with PHP for content freshness and safer output.

    dtmg-weather-posts-block