Plugin Directory

Changeset 3431559


Ignore:
Timestamp:
01/03/2026 10:27:08 AM (7 weeks ago)
Author:
spelhubben
Message:

Update to version 1.8.6 from GitHub

Location:
spelhubben-weather
Files:
12 edited
1 copied

Legend:

Unmodified
Added
Removed
  • spelhubben-weather/tags/1.8.6/assets/map.js

    r3425273 r3431559  
    3434    el.dataset.inited = '1';
    3535
     36    // Check if Leaflet is loaded
     37    if (typeof L === 'undefined' || !L.map) {
     38      console.warn('Leaflet not loaded yet, retrying...', el);
     39      // Try again in a moment
     40      setTimeout(() => {
     41        delete el.dataset.inited;
     42        initMap(el);
     43      }, 500);
     44      return;
     45    }
     46
    3647    const lat  = parseFloat(el.getAttribute('data-lat'));
    3748    const lon  = parseFloat(el.getAttribute('data-lon'));
    38     if (isNaN(lat) || isNaN(lon)) return;
     49    if (isNaN(lat) || isNaN(lon)) {
     50      console.warn('Missing or invalid lat/lon for map', el);
     51      return;
     52    }
    3953
    40     const map = L.map(el, { scrollWheelZoom:false, attributionControl:false });
    41     el._svvMap = map;
     54    // Ensure element has a computed height before initializing
     55    const computedHeight = window.getComputedStyle(el).height;
     56    if (!computedHeight || computedHeight === '0px' || computedHeight === 'auto') {
     57      console.warn('Map element has no height, retrying...', el);
     58      setTimeout(() => {
     59        delete el.dataset.inited;
     60        initMap(el);
     61      }, 500);
     62      return;
     63    }
    4264
    43     map.setView([lat, lon], 12);
    44     L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { maxZoom:19 }).addTo(map);
     65    try {
     66      const map = L.map(el, { scrollWheelZoom:false, attributionControl:false });
     67      el._svvMap = map;
    4568
    46     // NOTE: No L.marker here — the pin is never placed.
    47     setTimeout(()=>map.invalidateSize(), 200);
     69      map.setView([lat, lon], 12);
     70      L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { maxZoom:19 }).addTo(map);
     71
     72      // NOTE: No L.marker here — the pin is never placed.
     73      setTimeout(()=>map.invalidateSize(), 200);
     74    } catch (e) {
     75      console.error('Error initializing map:', e);
     76      delete el.dataset.inited;
     77    }
    4878  }
    4979
    50   function scanMaps(){ document.querySelectorAll('.svv-map').forEach(initMap); }
     80  function scanMaps(){
     81    if (typeof L === 'undefined') {
     82      // Leaflet not ready, try again
     83      requestAnimationFrame(scanMaps);
     84      return;
     85    }
     86    document.querySelectorAll('.svv-map').forEach(initMap);
     87  }
    5188
    5289  if (document.readyState === 'loading') {
  • spelhubben-weather/tags/1.8.6/assets/style.css

    r3425273 r3431559  
    6060
    6161/* Karta */
    62 .svv-map{width:100%;border:1px solid #e6e6e6;border-radius:var(--svv-radius);overflow:hidden;margin-top:calc(10px * var(--svv-scale))}
     62.svv-map{width:100%;height:240px;border:1px solid #e6e6e6;border-radius:var(--svv-radius);overflow:hidden;margin-top:calc(10px * var(--svv-scale))}
    6363.svv-map-attrib{margin-top:calc(6px * var(--svv-scale));font-size:calc(12px * var(--svv-scale));opacity:.8}
    6464.svv-map-attrib a{text-decoration:none}
  • spelhubben-weather/tags/1.8.6/blocks/spelhubben-weather/block.json

    r3425273 r3431559  
    11{
    22  "apiVersion": 2,
    3   "name": "spelhubben/weather",
     3  "name": "spelhubben-weather/spelhubben-weather",
    44  "title": "Spelhubben Weather",
    55  "category": "widgets",
  • spelhubben-weather/tags/1.8.6/blocks/spelhubben-weather/index.js

    r3425273 r3431559  
    1919  ];
    2020
    21   registerBlockType('spelhubben/weather', {
     21  registerBlockType('spelhubben-weather/spelhubben-weather', {
    2222    edit: (props) => {
    2323      const { attributes, setAttributes } = props;
  • spelhubben-weather/tags/1.8.6/includes/class-assets.php

    r3431056 r3431559  
    3636     */
    3737    private function should_load_leaflet() {
    38         global $post;
     38        global $post, $wp_registered_sidebars;
    3939
    40         if ( ! isset( $post->post_content ) ) {
    41             return false;
     40        // Check for shortcodes in post content
     41        if ( isset( $post->post_content ) ) {
     42            // Check for old shortcode (legacy)
     43            if ( has_shortcode( $post->post_content, 'sv-vader' ) ) {
     44                return true;
     45            }
     46            // Check for new shortcode
     47            if ( has_shortcode( $post->post_content, 'spelhubben_weather' ) ) {
     48                return true;
     49            }
     50            // Check for Gutenberg blocks
     51            if ( has_block( 'spelhubben-weather/spelhubben-weather', $post ) ) {
     52                return true;
     53            }
     54            if ( has_block( 'sv/vader', $post ) ) {
     55                return true;
     56            }
    4257        }
    4358
    44         // Check for shortcode
    45         if ( has_shortcode( $post->post_content, 'sv-vader' ) ) {
    46             return true;
    47         }
    48 
    49         // Check for Gutenberg block
    50         if ( has_block( 'spelhubben-weather/spelhubben-weather', $post ) ) {
    51             return true;
     59        // Check if the sv_vader_widget is active in any sidebar
     60        if ( function_exists( 'is_active_widget' ) ) {
     61            if ( is_active_widget( false, false, 'sv_vader_widget' ) ) {
     62                return true;
     63            }
    5264        }
    5365
  • spelhubben-weather/tags/1.8.6/spelhubben-weather.php

    r3425273 r3431559  
    33 * Plugin Name: Spelhubben Weather
    44 * Description: Displays current weather and an optional forecast with a simple consensus across providers (Open-Meteo, SMHI, Yr/MET Norway). Supports shortcode + Gutenberg block + classic widget. Optional Leaflet map, subtle animations, daily forecast, and multiple layouts.
    5  * Version: 1.8.4
     5 * Version: 1.8.6
    66 * Author: Spelhubben
    77 * Text Domain: spelhubben-weather
     
    1919// ── Constants (kept for backward compatibility).
    2020if ( ! defined( 'SV_VADER_VER' ) ) {
    21     define( 'SV_VADER_VER', '1.8.4' );
     21    define( 'SV_VADER_VER', '1.8.6' );
    2222}
    2323if ( ! defined( 'SV_VADER_DIR' ) ) {
  • spelhubben-weather/trunk/assets/map.js

    r3425273 r3431559  
    3434    el.dataset.inited = '1';
    3535
     36    // Check if Leaflet is loaded
     37    if (typeof L === 'undefined' || !L.map) {
     38      console.warn('Leaflet not loaded yet, retrying...', el);
     39      // Try again in a moment
     40      setTimeout(() => {
     41        delete el.dataset.inited;
     42        initMap(el);
     43      }, 500);
     44      return;
     45    }
     46
    3647    const lat  = parseFloat(el.getAttribute('data-lat'));
    3748    const lon  = parseFloat(el.getAttribute('data-lon'));
    38     if (isNaN(lat) || isNaN(lon)) return;
     49    if (isNaN(lat) || isNaN(lon)) {
     50      console.warn('Missing or invalid lat/lon for map', el);
     51      return;
     52    }
    3953
    40     const map = L.map(el, { scrollWheelZoom:false, attributionControl:false });
    41     el._svvMap = map;
     54    // Ensure element has a computed height before initializing
     55    const computedHeight = window.getComputedStyle(el).height;
     56    if (!computedHeight || computedHeight === '0px' || computedHeight === 'auto') {
     57      console.warn('Map element has no height, retrying...', el);
     58      setTimeout(() => {
     59        delete el.dataset.inited;
     60        initMap(el);
     61      }, 500);
     62      return;
     63    }
    4264
    43     map.setView([lat, lon], 12);
    44     L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { maxZoom:19 }).addTo(map);
     65    try {
     66      const map = L.map(el, { scrollWheelZoom:false, attributionControl:false });
     67      el._svvMap = map;
    4568
    46     // NOTE: No L.marker here — the pin is never placed.
    47     setTimeout(()=>map.invalidateSize(), 200);
     69      map.setView([lat, lon], 12);
     70      L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { maxZoom:19 }).addTo(map);
     71
     72      // NOTE: No L.marker here — the pin is never placed.
     73      setTimeout(()=>map.invalidateSize(), 200);
     74    } catch (e) {
     75      console.error('Error initializing map:', e);
     76      delete el.dataset.inited;
     77    }
    4878  }
    4979
    50   function scanMaps(){ document.querySelectorAll('.svv-map').forEach(initMap); }
     80  function scanMaps(){
     81    if (typeof L === 'undefined') {
     82      // Leaflet not ready, try again
     83      requestAnimationFrame(scanMaps);
     84      return;
     85    }
     86    document.querySelectorAll('.svv-map').forEach(initMap);
     87  }
    5188
    5289  if (document.readyState === 'loading') {
  • spelhubben-weather/trunk/assets/style.css

    r3425273 r3431559  
    6060
    6161/* Karta */
    62 .svv-map{width:100%;border:1px solid #e6e6e6;border-radius:var(--svv-radius);overflow:hidden;margin-top:calc(10px * var(--svv-scale))}
     62.svv-map{width:100%;height:240px;border:1px solid #e6e6e6;border-radius:var(--svv-radius);overflow:hidden;margin-top:calc(10px * var(--svv-scale))}
    6363.svv-map-attrib{margin-top:calc(6px * var(--svv-scale));font-size:calc(12px * var(--svv-scale));opacity:.8}
    6464.svv-map-attrib a{text-decoration:none}
  • spelhubben-weather/trunk/blocks/spelhubben-weather/block.json

    r3425273 r3431559  
    11{
    22  "apiVersion": 2,
    3   "name": "spelhubben/weather",
     3  "name": "spelhubben-weather/spelhubben-weather",
    44  "title": "Spelhubben Weather",
    55  "category": "widgets",
  • spelhubben-weather/trunk/blocks/spelhubben-weather/index.js

    r3425273 r3431559  
    1919  ];
    2020
    21   registerBlockType('spelhubben/weather', {
     21  registerBlockType('spelhubben-weather/spelhubben-weather', {
    2222    edit: (props) => {
    2323      const { attributes, setAttributes } = props;
  • spelhubben-weather/trunk/includes/class-assets.php

    r3431056 r3431559  
    3636     */
    3737    private function should_load_leaflet() {
    38         global $post;
     38        global $post, $wp_registered_sidebars;
    3939
    40         if ( ! isset( $post->post_content ) ) {
    41             return false;
     40        // Check for shortcodes in post content
     41        if ( isset( $post->post_content ) ) {
     42            // Check for old shortcode (legacy)
     43            if ( has_shortcode( $post->post_content, 'sv-vader' ) ) {
     44                return true;
     45            }
     46            // Check for new shortcode
     47            if ( has_shortcode( $post->post_content, 'spelhubben_weather' ) ) {
     48                return true;
     49            }
     50            // Check for Gutenberg blocks
     51            if ( has_block( 'spelhubben-weather/spelhubben-weather', $post ) ) {
     52                return true;
     53            }
     54            if ( has_block( 'sv/vader', $post ) ) {
     55                return true;
     56            }
    4257        }
    4358
    44         // Check for shortcode
    45         if ( has_shortcode( $post->post_content, 'sv-vader' ) ) {
    46             return true;
    47         }
    48 
    49         // Check for Gutenberg block
    50         if ( has_block( 'spelhubben-weather/spelhubben-weather', $post ) ) {
    51             return true;
     59        // Check if the sv_vader_widget is active in any sidebar
     60        if ( function_exists( 'is_active_widget' ) ) {
     61            if ( is_active_widget( false, false, 'sv_vader_widget' ) ) {
     62                return true;
     63            }
    5264        }
    5365
  • spelhubben-weather/trunk/spelhubben-weather.php

    r3425273 r3431559  
    33 * Plugin Name: Spelhubben Weather
    44 * Description: Displays current weather and an optional forecast with a simple consensus across providers (Open-Meteo, SMHI, Yr/MET Norway). Supports shortcode + Gutenberg block + classic widget. Optional Leaflet map, subtle animations, daily forecast, and multiple layouts.
    5  * Version: 1.8.4
     5 * Version: 1.8.6
    66 * Author: Spelhubben
    77 * Text Domain: spelhubben-weather
     
    1919// ── Constants (kept for backward compatibility).
    2020if ( ! defined( 'SV_VADER_VER' ) ) {
    21     define( 'SV_VADER_VER', '1.8.4' );
     21    define( 'SV_VADER_VER', '1.8.6' );
    2222}
    2323if ( ! defined( 'SV_VADER_DIR' ) ) {
Note: See TracChangeset for help on using the changeset viewer.