Changeset 3444848
- Timestamp:
- 01/22/2026 12:54:53 PM (2 months ago)
- Location:
- staticdelivr/trunk
- Files:
-
- 2 edited
-
README.txt (modified) (4 diffs)
-
staticdelivr.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
staticdelivr/trunk/README.txt
r3434846 r3444848 6 6 Tested up to: 6.9 7 7 Requires PHP: 7.4 8 Stable tag: 1. 3.18 Stable tag: 1.4.0 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 58 58 - **Core Files**: 59 59 Original: \`https://example.com/wp-includes/js/jquery/jquery.min.js\` 60 CDN: \`https://cdn.staticdelivr.com/wp/core/t runk/wp-includes/js/jquery/jquery.min.js\`60 CDN: \`https://cdn.staticdelivr.com/wp/core/tags/6.9/wp-includes/js/jquery/jquery.min.js\` 61 61 62 62 #### Images … … 115 115 == Changelog == 116 116 117 = 1.4.0 = 118 * Fixed WordPress core files to use proper version instead of "trunk" 119 * Core files CDN URLs now include WordPress version (e.g., /wp/core/tags/6.9/ instead of /wp/core/trunk/) 120 * Added WordPress version detection with support for development/RC/beta versions 121 * Cached WordPress version to avoid repeated calls 122 * Updated settings page to display detected WordPress version 123 * Prevents cache mismatches when WordPress is updated 124 117 125 = 1.3.1 = 118 126 * Fixed plugin/theme version detection to ensure CDN rewriting works correctly for all plugins … … 159 167 == Upgrade Notice == 160 168 169 = 1.4.0 = 170 Important update! Core files now use versioned CDN URLs instead of "trunk" to prevent cache mismatches when WordPress is updated. 171 161 172 = 1.3.1 = 162 173 Fixes for version detection and CDN rewriting. Added security attributes to external links. -
staticdelivr/trunk/staticdelivr.php
r3434846 r3444848 3 3 * Plugin Name: StaticDelivr CDN 4 4 * Description: Speed up your WordPress site with free CDN delivery and automatic image optimization. Reduces load times and bandwidth costs. 5 * Version: 1. 3.15 * Version: 1.4.0 6 6 * Requires at least: 5.8 7 7 * Requires PHP: 7.4 … … 19 19 // Define plugin constants 20 20 if (!defined('STATICDELIVR_VERSION')) { 21 define('STATICDELIVR_VERSION', '1. 3.1');21 define('STATICDELIVR_VERSION', '1.4.0'); 22 22 } 23 23 if (!defined('STATICDELIVR_PLUGIN_FILE')) { … … 106 106 private $version_cache = []; 107 107 108 /** 109 * Cached WordPress version. 110 * 111 * @var string|null 112 */ 113 private $wp_version_cache = null; 114 108 115 public function __construct() { 109 116 // CSS/JS rewriting hooks … … 271 278 272 279 /** 280 * Get the current WordPress version (cached). 281 * Extracts clean version number from development/RC versions. 282 * 283 * @return string The WordPress version (e.g., "6.9" or "6.9.1") 284 */ 285 private function get_wp_version() { 286 if ($this->wp_version_cache !== null) { 287 return $this->wp_version_cache; 288 } 289 290 $raw_version = get_bloginfo('version'); 291 292 // Extract just the version number (e.g., "6.9.1" from "6.9.1-alpha-12345" or "6.9-RC1") 293 // This handles development versions, RCs, betas, etc. 294 if (preg_match('/^(\d+\.\d+(?:\.\d+)?)/', $raw_version, $matches)) { 295 $this->wp_version_cache = $matches[1]; 296 } else { 297 // Fallback to raw version if pattern doesn't match 298 $this->wp_version_cache = $raw_version; 299 } 300 301 return $this->wp_version_cache; 302 } 303 304 /** 273 305 * Build StaticDelivr image CDN URL. 274 306 * … … 608 640 // Rewrite WordPress core files 609 641 if (strpos($clean_path, 'wp-includes/') === 0) { 610 $rewritten = sprintf('https://cdn.staticdelivr.com/wp/core/trunk/%s', ltrim($clean_path, '/')); 642 $wp_version = $this->get_wp_version(); 643 $rewritten = sprintf('https://cdn.staticdelivr.com/wp/core/tags/%s/%s', $wp_version, ltrim($clean_path, '/')); 611 644 $this->remember_original_source($handle, $src); 612 645 return $rewritten; … … 939 972 $image_format = get_option(STATICDELIVR_PREFIX . 'image_format', 'webp'); 940 973 $site_url = home_url(); 974 $wp_version = $this->get_wp_version(); 941 975 ?> 942 976 <div class="wrap"> … … 946 980 <!-- Status Bar --> 947 981 <div class="staticdelivr-status-bar"> 982 <div class="staticdelivr-status-item"> 983 <span class="label">WordPress Version:</span> 984 <span class="value"><?php echo esc_html($wp_version); ?></span> 985 </div> 948 986 <div class="staticdelivr-status-item"> 949 987 <span class="label">Assets CDN:</span> … … 985 1023 <p class="description">Serves WordPress core, theme, and plugin assets from StaticDelivr CDN for faster loading.</p> 986 1024 <div class="staticdelivr-example"> 987 <code><?php echo esc_html($site_url); ?>/wp-includes/js/jquery .js</code>1025 <code><?php echo esc_html($site_url); ?>/wp-includes/js/jquery/jquery.min.js</code> 988 1026 <span class="becomes">→</span> 989 <code>https://cdn.staticdelivr.com/wp/core/t runk/wp-includes/js/jquery.js</code>1027 <code>https://cdn.staticdelivr.com/wp/core/tags/<?php echo esc_html($wp_version); ?>/wp-includes/js/jquery/jquery.min.js</code> 990 1028 </div> 991 1029 </td> … … 1040 1078 <div style="background: #f0f0f1; padding: 15px; border-radius: 5px; margin-bottom: 20px;"> 1041 1079 <h4 style="margin-top: 0;">Assets (CSS & JS)</h4> 1042 <p style="margin-bottom: 5px;"><code><?php echo esc_html($site_url); ?>/wp-includes/js/jquery .js</code></p>1043 <p style="margin-bottom: 15px;">→ <code>https://cdn.staticdelivr.com/wp/core/t runk/wp-includes/js/jquery.js</code></p>1080 <p style="margin-bottom: 5px;"><code><?php echo esc_html($site_url); ?>/wp-includes/js/jquery/jquery.min.js</code></p> 1081 <p style="margin-bottom: 15px;">→ <code>https://cdn.staticdelivr.com/wp/core/tags/<?php echo esc_html($wp_version); ?>/wp-includes/js/jquery/jquery.min.js</code></p> 1044 1082 1045 1083 <h4>Images</h4>
Note: See TracChangeset
for help on using the changeset viewer.