Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) );

Expand All @@ -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' );

Expand All @@ -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 ) );
Expand Down
35 changes: 35 additions & 0 deletions tests/e2e/specs/homepage/asset-versions.spec.ts
Original file line number Diff line number Diff line change
@@ -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);
});
Loading