Descrição
PDS Weather shows current conditions in your area using the OpenWeatherMap API (free tier).
The plugin fetches and displays:
- Current weather description
- Current temperature (°C and/or °F)
- “Feels like” temperature
- Weather font icon (optional)
- City name display (optional)
- Air Quality Index (optional)
- UV Index (optional)
Data is cached for one hour to minimize API calls.
New in 4.5.0:
- Automatic Dark Mode — the widget adapts to the visitor’s browser colour-scheme preference (with an OS-preference fallback when JavaScript is disabled). No configuration required.
- Air Quality Index — optionally display the Air Quality Index from the OpenWeatherMap Air Pollution API (e.g. “Air Quality: 2 (Fair)”).
- UV Index — optionally display the UV Index value (e.g. “UV Index: 5.2”).
- Custom CSS editor — a new Appearance tab lets you add your own CSS to style the widget without editing plugin files.
Requirements:
- A free OpenWeatherMap API key — Get one here
Setup:
- Go to PDS Weather > Settings in your WordPress admin.
- Enter your OpenWeatherMap API key.
- Select your country and enter your city name.
- Choose display options (icon, degrees, feels like, weather label, city name).
- Save settings.
Display options:
- Use the PDS Weather Gutenberg block in the Block Editor.
- Use the PDS Weather classic widget (Appearance > Widgets).
- Use the
[pdsweather]shortcode in any post or page. - Or call
<?php echo pdsweather_display(); ?>in your theme template. - Legacy function
pdsWeather()is still supported for backward compatibility.
Blocos
Este plugin inclui 1 bloco.
- PDS Weather Displays current weather conditions for your configured city. Configure via PDS Weather → Settings.
Instalação
- Upload the
pdsweatherfolder to/wp-content/plugins/. - Activate the plugin through the ‘Plugins’ menu in WordPress.
- Go to PDS Weather > Settings and enter your OpenWeatherMap API key.
- Configure country, city, and display preferences.
- Add the widget or use
<?php echo pdsweather_display(); ?>in your templates.
Perguntas frequentes
-
Where do I get an API key?
-
Sign up for a free account at OpenWeatherMap and create an API key. The free tier allows up to 1,000 calls per day.
-
The old Weather Underground API key no longer works. What do I do?
-
Weather Underground shut down their free API in 2019. Version 4.0 of this plugin uses OpenWeatherMap instead. Simply enter your new OpenWeatherMap API key in the settings.
-
How often does the weather data refresh?
-
The plugin caches data for one hour to minimize API calls.
Avaliações
Contribuidores e programadores
“PDS Weather” é software de código aberto. As seguintes pessoas contribuíram para este plugin:
ContribuidoresTraduza o “PDS Weather” para o seu idioma.
Interessado no desenvolvimento?
Consulte o código, consulte o repositório SVN, ou subscreva o registo de alterações por RSS.
Registo de alterações
4.5.2
- Fixed: The settings-page preview showed the temperature in both °F and °C after saving, regardless of the selected unit. The preview now respects the saved Celsius/Fahrenheit setting on page load (and continues to update live as you change it).
- Fixed: The Air Quality Index now appears in the settings-page preview when enabled.
- Fixed: The UV Index is now fetched from the OpenWeatherMap One Call API (the standard current-weather endpoint does not return UV data). It also now appears in the settings-page preview. If your API key does not have One Call access, the UV Index is skipped gracefully.
- Changed: Minimum required WordPress version raised to 6.5 to align with modern standards.
4.5.1
- Fixed: Dark mode now correctly follows the browser colour-scheme preference instead of only the operating-system preference. A small front-end script (
js/pdsweather-theme.js) detects the browser preference and sets adata-themeattribute on the widget; the stylesheet themes the widget from that attribute. When JavaScript is disabled, the plugin falls back to theprefers-color-schememedia query (OS preference).
4.5.0
- Added automatic Dark Mode support via
prefers-color-scheme— the widget colors adapt to the visitor’s system theme. Implemented with CSS custom properties for easy theming. - Added optional Air Quality Index display using the OpenWeatherMap Air Pollution API. Data is cached together with the weather data (one hour). Enable it under PDS Weather > Settings.
- Added optional UV Index display. Enable it under PDS Weather > Settings.
- Added a new Appearance admin tab with a Custom CSS editor — add your own CSS (saved to the
pdsweather_custom_cssoption and loaded on the front end viawp_add_inline_style()). Includes nonce verification, capability check and sanitization. uninstall.phpnow removes the new options (pdsweather_show_aqi,pdsweather_show_uv,pdsweather_custom_css).- Note: the UV Index value is only displayed when the weather API response includes a
uvifield; otherwise it is silently skipped.
4.0.2
- Added Gutenberg block — insert weather directly from the Block Editor with live server-side preview.
- Added
[pdsweather]shortcode for easy embedding in posts and pages. - Added “Show city name” option in settings.
- Modernized front-end CSS: switched from floats to flexbox layout, added temperature separator.
- Added
.pdsweather-cityCSS class for city name styling.
4.0.1
- Fixed widget not appearing properly in Appearance > Widgets admin screen.
- Added configurable widget title field with proper sanitization.
- Widget now outputs title using before_title/after_title theme wrappers.
- Widget no longer outputs empty wrapper when no weather data is available.
- Added explicit ‘classname’ to widget constructor for proper CSS targeting.
- Added link to settings page inside widget form for easier configuration.
4.0.0
- BREAKING: Replaced defunct Weather Underground API with OpenWeatherMap API.
- Added nonce verification for all admin forms.
- Added capability checks (manage_options) on all admin pages.
- Added input sanitization (sanitize_text_field) for all user inputs.
- Added output escaping (esc_html, esc_attr, esc_url) for all outputs.
- Added option whitelist — only pdsweather_* options are accepted.
- Added ABSPATH checks to prevent direct file access.
- Moved inline JavaScript to separate enqueued file (js/pdsweather-admin.js).
- Replaced file_get_contents() with wp_remote_get().
- Added proper error handling for API calls.
- Updated plugin header (Tested up to: 6.7, Requires PHP: 7.4).
- Added Text Domain and load_plugin_textdomain() support.
- Renamed all functions/options with pdsweather_ prefix.
- Removed Weather Underground icon set options (no longer available).
- Improved uninstall.php with WP_UNINSTALL_PLUGIN check and legacy option cleanup.
- Added weather icon mapping for OpenWeatherMap condition codes.
- Legacy pdsWeather() function preserved as wrapper for backward compatibility.
3.3
- Bugfix when weather string is blank — set clear for weather.
3.2
- Solved bug for conditions after new year has started.
- Tested on 4.7.
3.1
- Removed print of the results after save.
- Tested on 4.5.
- Implement selective refresh for widget.
3.0
- Solved more bugs.
- Added input field for API key to the settings area.
- Made sure API key is required for widget to be shown.
- Added drag & drop widget in widgets section.
2.0
- Solved some bugs.
- Added input field for API key.
- Added uninstall functions.
1.1.1
- Another little bug solved.
1.1
- Solved bug with showing of the countries.
- Added F and °C for temperature strings.
1.0
- First version of the plugin.
- Weather conditions change once per hour.
- Shows conditions and feels like string.
- Uses WU icons and weather font.
