Changeset 3431056
- Timestamp:
- 01/02/2026 01:27:39 PM (7 weeks ago)
- Location:
- spelhubben-weather
- Files:
-
- 2 added
- 6 deleted
- 4 edited
- 1 copied
-
tags/1.8.5 (copied) (copied from spelhubben-weather/trunk)
-
tags/1.8.5/.distignore (modified) (1 diff)
-
tags/1.8.5/assets/.htaccess (added)
-
tags/1.8.5/assets/icons/spelhubben-weather_banner.jpg (deleted)
-
tags/1.8.5/assets/icons/spelhubben-weather_banner2.jpg (deleted)
-
tags/1.8.5/assets/icons/spelhubben-weather_icon.png (deleted)
-
tags/1.8.5/includes/class-assets.php (modified) (2 diffs)
-
trunk/.distignore (modified) (1 diff)
-
trunk/assets/.htaccess (added)
-
trunk/assets/icons/spelhubben-weather_banner.jpg (deleted)
-
trunk/assets/icons/spelhubben-weather_banner2.jpg (deleted)
-
trunk/assets/icons/spelhubben-weather_icon.png (deleted)
-
trunk/includes/class-assets.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
spelhubben-weather/tags/1.8.5/.distignore
r3425273 r3431056 7 7 .editorconfig 8 8 .vs/ 9 Patch & Fix/ 9 PatchFix/ 10 .wordpress-org/ 10 11 11 12 # ---- Node/Composer ---- -
spelhubben-weather/tags/1.8.5/includes/class-assets.php
r3425273 r3431056 7 7 /** 8 8 * Enqueue public-facing assets (CSS/JS) for the frontend. 9 * Only loads core stylesheet; Leaflet/map assets are loaded conditionally via filters. 9 10 */ 10 11 public function enqueue_public_assets() { 11 // Core plugin stylesheet 12 // Core plugin stylesheet - always load 12 13 wp_enqueue_style('sv-vader-style', SV_VADER_URL . 'assets/style.css', [], SV_VADER_VER); 13 14 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 15 17 wp_register_style('leaflet-css', SV_VADER_URL . 'assets/vendor/leaflet/leaflet.css', [], '1.9.4'); 16 wp_enqueue_style('leaflet-css');17 18 18 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)22 19 wp_register_script('sv-vader-map', SV_VADER_URL . 'assets/map.js', ['leaflet-js'], SV_VADER_VER, true); 23 20 … … 27 24 ]); 28 25 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; 30 55 } 31 56 } -
spelhubben-weather/trunk/.distignore
r3425273 r3431056 7 7 .editorconfig 8 8 .vs/ 9 Patch & Fix/ 9 PatchFix/ 10 .wordpress-org/ 10 11 11 12 # ---- Node/Composer ---- -
spelhubben-weather/trunk/includes/class-assets.php
r3425273 r3431056 7 7 /** 8 8 * Enqueue public-facing assets (CSS/JS) for the frontend. 9 * Only loads core stylesheet; Leaflet/map assets are loaded conditionally via filters. 9 10 */ 10 11 public function enqueue_public_assets() { 11 // Core plugin stylesheet 12 // Core plugin stylesheet - always load 12 13 wp_enqueue_style('sv-vader-style', SV_VADER_URL . 'assets/style.css', [], SV_VADER_VER); 13 14 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 15 17 wp_register_style('leaflet-css', SV_VADER_URL . 'assets/vendor/leaflet/leaflet.css', [], '1.9.4'); 16 wp_enqueue_style('leaflet-css');17 18 18 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)22 19 wp_register_script('sv-vader-map', SV_VADER_URL . 'assets/map.js', ['leaflet-js'], SV_VADER_VER, true); 23 20 … … 27 24 ]); 28 25 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; 30 55 } 31 56 }
Note: See TracChangeset
for help on using the changeset viewer.