From 6288447d4c91c9999924f6a3342600aca6abba22 Mon Sep 17 00:00:00 2001 From: rg755421 Date: Wed, 30 Sep 2026 08:57:39 +0545 Subject: [PATCH 1/2] Fix - Version the theme stylesheet and custom script with the theme version (themegrill/radiate-pro#33) Co-Authored-By: Claude Sonnet 5.5 --- functions.php | 4 +-- .../e2e/specs/homepage/asset-versions.spec.ts | 35 +++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 tests/e2e/specs/homepage/asset-versions.spec.ts diff --git a/functions.php b/functions.php index 1d8f4a8..6e0f1c3 100644 --- a/functions.php +++ b/functions.php @@ -146,7 +146,7 @@ function radiate_widgets_init() { */ function radiate_scripts() { // Load our main stylesheet. - wp_enqueue_style( 'radiate-style', get_stylesheet_uri() ); + wp_enqueue_style( 'radiate-style', get_stylesheet_uri(), array(), wp_get_theme()->get( 'Version' ) ); wp_enqueue_style( 'radiate-google-fonts', '//fonts.googleapis.com/css?family=Roboto|Merriweather:400,300&display=swap' ); @@ -157,7 +157,7 @@ function radiate_scripts() { wp_enqueue_script( 'radiate-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20130115', true ); - wp_enqueue_script( 'radiate-custom-js', get_template_directory_uri() . '/js/custom.js', array( 'jquery' ), false, true ); + wp_enqueue_script( 'radiate-custom-js', get_template_directory_uri() . '/js/custom.js', array( 'jquery' ), RADIATE_THEME_VERSION, true ); $radiate_header_image_link = get_header_image(); wp_localize_script( 'radiate-custom-js', 'radiateScriptParam', array( 'radiate_image_link' => $radiate_header_image_link ) ); diff --git a/tests/e2e/specs/homepage/asset-versions.spec.ts b/tests/e2e/specs/homepage/asset-versions.spec.ts new file mode 100644 index 0000000..5f1d228 --- /dev/null +++ b/tests/e2e/specs/homepage/asset-versions.spec.ts @@ -0,0 +1,35 @@ +import { test, expect } from "../../fixtures"; +/** + * @area homepage + * @tier fresh + * @guards radiate-pro#33 + * @source fix/33-asset-versions 2026-09-30; functions.php + * @why The main stylesheet and custom.js were enqueued without a version, so + * WordPress stamped them with the WP core version and a theme update + * shipping new CSS/JS kept the old ?ver= (browsers and CDNs served stale + * files). Guards that they carry the theme's own Version header. Reads the + * Version from the theme's style.css, so it does not go stale on a release. + */ +test("the theme's own stylesheet and script are versioned with the theme version @fresh @homepage", async ({ + page, + request, +}) => { + await page.goto("/"); + + const styleHref = await page + .locator("link#radiate-style-css") + .getAttribute("href"); + const scriptSrc = await page + .locator("script#radiate-custom-js-js") + .getAttribute("src"); + expect(styleHref, "radiate-style-css href").toBeTruthy(); + expect(scriptSrc, "radiate-custom-js src").toBeTruthy(); + + const css = await (await request.get(styleHref!.split("?")[0])).text(); + const themeVersion = css.match(/^\s*Version:\s*(\S+)/m)?.[1]; + expect(themeVersion, "Version header in style.css").toBeTruthy(); + + const ver = (url: string) => new URL(url, "http://x").searchParams.get("ver"); + expect(ver(styleHref!)).toBe(themeVersion); + expect(ver(scriptSrc!)).toBe(themeVersion); +}); From c380a60208da805e1d6f9f4daa2e6ce2aad483e4 Mon Sep 17 00:00:00 2001 From: rg755421 Date: Wed, 30 Sep 2026 14:44:52 +0545 Subject: [PATCH 2/2] Fix - Read the theme version from the active theme folder, not a hard-coded slug (themegrill/radiate-pro#33) Co-Authored-By: Claude Opus 5.5 --- functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions.php b/functions.php index 6e0f1c3..cc9e131 100644 --- a/functions.php +++ b/functions.php @@ -137,7 +137,7 @@ function radiate_widgets_init() { /** * Assign the Radiate version to a variable. */ -$radiate_theme = wp_get_theme( 'radiate' ); +$radiate_theme = wp_get_theme( get_template() ); define( 'RADIATE_THEME_VERSION', $radiate_theme->get( 'Version' ) );