Plugin Directory

Changeset 3444848


Ignore:
Timestamp:
01/22/2026 12:54:53 PM (2 months ago)
Author:
coozywana
Message:

Release 1.4.0 - Important update! Core files now use versioned CDN URLs instead of "trunk" to prevent cache mismatches when WordPress is updated.

Location:
staticdelivr/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • staticdelivr/trunk/README.txt

    r3434846 r3444848  
    66Tested up to: 6.9
    77Requires PHP: 7.4
    8 Stable tag: 1.3.1
     8Stable tag: 1.4.0
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    5858- **Core Files**:
    5959  Original: \`https://example.com/wp-includes/js/jquery/jquery.min.js\`
    60   CDN: \`https://cdn.staticdelivr.com/wp/core/trunk/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\`
    6161
    6262#### Images
     
    115115== Changelog ==
    116116
     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
    117125= 1.3.1 =
    118126* Fixed plugin/theme version detection to ensure CDN rewriting works correctly for all plugins
     
    159167== Upgrade Notice ==
    160168
     169= 1.4.0 =
     170Important update! Core files now use versioned CDN URLs instead of "trunk" to prevent cache mismatches when WordPress is updated.
     171
    161172= 1.3.1 =
    162173Fixes for version detection and CDN rewriting. Added security attributes to external links.
  • staticdelivr/trunk/staticdelivr.php

    r3434846 r3444848  
    33 * Plugin Name: StaticDelivr CDN
    44 * Description: Speed up your WordPress site with free CDN delivery and automatic image optimization. Reduces load times and bandwidth costs.
    5  * Version: 1.3.1
     5 * Version: 1.4.0
    66 * Requires at least: 5.8
    77 * Requires PHP: 7.4
     
    1919// Define plugin constants
    2020if (!defined('STATICDELIVR_VERSION')) {
    21     define('STATICDELIVR_VERSION', '1.3.1');
     21    define('STATICDELIVR_VERSION', '1.4.0');
    2222}
    2323if (!defined('STATICDELIVR_PLUGIN_FILE')) {
     
    106106    private $version_cache = [];
    107107
     108    /**
     109     * Cached WordPress version.
     110     *
     111     * @var string|null
     112     */
     113    private $wp_version_cache = null;
     114
    108115    public function __construct() {
    109116        // CSS/JS rewriting hooks
     
    271278
    272279    /**
     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    /**
    273305     * Build StaticDelivr image CDN URL.
    274306     *
     
    608640        // Rewrite WordPress core files
    609641        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, '/'));
    611644            $this->remember_original_source($handle, $src);
    612645            return $rewritten;
     
    939972        $image_format = get_option(STATICDELIVR_PREFIX . 'image_format', 'webp');
    940973        $site_url = home_url();
     974        $wp_version = $this->get_wp_version();
    941975        ?>
    942976        <div class="wrap">
     
    946980            <!-- Status Bar -->
    947981            <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>
    948986                <div class="staticdelivr-status-item">
    949987                    <span class="label">Assets CDN:</span>
     
    9851023                            <p class="description">Serves WordPress core, theme, and plugin assets from StaticDelivr CDN for faster loading.</p>
    9861024                            <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>
    9881026                                <span class="becomes">→</span>
    989                                 <code>https://cdn.staticdelivr.com/wp/core/trunk/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>
    9901028                            </div>
    9911029                        </td>
     
    10401078                <div style="background: #f0f0f1; padding: 15px; border-radius: 5px; margin-bottom: 20px;">
    10411079                    <h4 style="margin-top: 0;">Assets (CSS &amp; 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/trunk/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>
    10441082
    10451083                    <h4>Images</h4>
Note: See TracChangeset for help on using the changeset viewer.