Plugin Directory

Changeset 3431056


Ignore:
Timestamp:
01/02/2026 01:27:39 PM (7 weeks ago)
Author:
spelhubben
Message:

Update to version 1.8.5 from GitHub

Location:
spelhubben-weather
Files:
2 added
6 deleted
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • spelhubben-weather/tags/1.8.5/.distignore

    r3425273 r3431056  
    77.editorconfig
    88.vs/
    9 Patch & Fix/
     9PatchFix/
     10.wordpress-org/
    1011
    1112# ---- Node/Composer ----
  • spelhubben-weather/tags/1.8.5/includes/class-assets.php

    r3425273 r3431056  
    77    /**
    88     * Enqueue public-facing assets (CSS/JS) for the frontend.
     9     * Only loads core stylesheet; Leaflet/map assets are loaded conditionally via filters.
    910     */
    1011    public function enqueue_public_assets() {
    11         // Core plugin stylesheet
     12        // Core plugin stylesheet - always load
    1213        wp_enqueue_style('sv-vader-style', SV_VADER_URL . 'assets/style.css', [], SV_VADER_VER);
    1314
    14         // Leaflet (bundled locally)
     15        // Register Leaflet and map assets but don't auto-enqueue
     16        // They will be enqueued conditionally via has_shortcode() or block detection
    1517        wp_register_style('leaflet-css', SV_VADER_URL . 'assets/vendor/leaflet/leaflet.css', [], '1.9.4');
    16         wp_enqueue_style('leaflet-css');
    17 
    1818        wp_register_script('leaflet-js', SV_VADER_URL . 'assets/vendor/leaflet/leaflet.js', [], '1.9.4', true);
    19         wp_enqueue_script('leaflet-js');
    20 
    21         // Map logic (depends on Leaflet)
    2219        wp_register_script('sv-vader-map', SV_VADER_URL . 'assets/map.js', ['leaflet-js'], SV_VADER_VER, true);
    2320
     
    2724        ]);
    2825
    29         wp_enqueue_script('sv-vader-map');
     26        // Load Leaflet assets only if shortcode is present or Gutenberg block is used
     27        if ( $this->should_load_leaflet() ) {
     28            wp_enqueue_style('leaflet-css');
     29            wp_enqueue_script('leaflet-js');
     30            wp_enqueue_script('sv-vader-map');
     31        }
     32    }
     33
     34    /**
     35     * Check if Leaflet assets should be loaded on this page.
     36     */
     37    private function should_load_leaflet() {
     38        global $post;
     39
     40        if ( ! isset( $post->post_content ) ) {
     41            return false;
     42        }
     43
     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;
     52        }
     53
     54        return false;
    3055    }
    3156}
  • spelhubben-weather/trunk/.distignore

    r3425273 r3431056  
    77.editorconfig
    88.vs/
    9 Patch & Fix/
     9PatchFix/
     10.wordpress-org/
    1011
    1112# ---- Node/Composer ----
  • spelhubben-weather/trunk/includes/class-assets.php

    r3425273 r3431056  
    77    /**
    88     * Enqueue public-facing assets (CSS/JS) for the frontend.
     9     * Only loads core stylesheet; Leaflet/map assets are loaded conditionally via filters.
    910     */
    1011    public function enqueue_public_assets() {
    11         // Core plugin stylesheet
     12        // Core plugin stylesheet - always load
    1213        wp_enqueue_style('sv-vader-style', SV_VADER_URL . 'assets/style.css', [], SV_VADER_VER);
    1314
    14         // Leaflet (bundled locally)
     15        // Register Leaflet and map assets but don't auto-enqueue
     16        // They will be enqueued conditionally via has_shortcode() or block detection
    1517        wp_register_style('leaflet-css', SV_VADER_URL . 'assets/vendor/leaflet/leaflet.css', [], '1.9.4');
    16         wp_enqueue_style('leaflet-css');
    17 
    1818        wp_register_script('leaflet-js', SV_VADER_URL . 'assets/vendor/leaflet/leaflet.js', [], '1.9.4', true);
    19         wp_enqueue_script('leaflet-js');
    20 
    21         // Map logic (depends on Leaflet)
    2219        wp_register_script('sv-vader-map', SV_VADER_URL . 'assets/map.js', ['leaflet-js'], SV_VADER_VER, true);
    2320
     
    2724        ]);
    2825
    29         wp_enqueue_script('sv-vader-map');
     26        // Load Leaflet assets only if shortcode is present or Gutenberg block is used
     27        if ( $this->should_load_leaflet() ) {
     28            wp_enqueue_style('leaflet-css');
     29            wp_enqueue_script('leaflet-js');
     30            wp_enqueue_script('sv-vader-map');
     31        }
     32    }
     33
     34    /**
     35     * Check if Leaflet assets should be loaded on this page.
     36     */
     37    private function should_load_leaflet() {
     38        global $post;
     39
     40        if ( ! isset( $post->post_content ) ) {
     41            return false;
     42        }
     43
     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;
     52        }
     53
     54        return false;
    3055    }
    3156}
Note: See TracChangeset for help on using the changeset viewer.