Repository navigation
fix(assets): never require a non-script asset, hash every non-enqueued file - #513
Merged
Merged
Conversation
…d file dependencies() swapped .js for .asset.php with a regex; for any other path the regex matched nothing and the asset itself was require'd, echoing a stylesheet into the response. Only scripts have a sibling .asset.php. uri() only appended ?v= under images/ and svgs/, so fonts, components and anything else the manifest hashes went out unbusted. Bust everything except scripts and stylesheets, which wp_enqueue_* versions with ?ver=. Both fixes already run on the wp-gds-theme sites. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes this the canonical
Assets.phpbefore copying it to the sites, whose copies have drifted into about ten versions. It keeps this copy's child-theme manifest support and takes the two real fixes that only some copies have.Changes
dependencies()on a non-script path. The.js→.asset.phpswap was a regex, so for a.css(or any other) path it matched nothing andrequired the asset itself, echoing it into the response. It now returns[]for anything that isn't.js.uri()cache-busting.?v=<hash>was appended only underimages/andsvgs/, so fonts, components and anything else the manifest hashes went out unbusted. It now busts every manifest entry except.jsand.css, whichwp_enqueue_*versions with?ver=(busting them here too would emit?v=…&ver=…).Left out on purpose
Several copies change
version()to returnfalseinstead of'', commented "WordPress treats an empty string as print no ?ver= at all". That's not what core does:WP_Scripts/WP_Stylestreat any empty non-null version (''orfalse) the same and fall back to the default version; onlynulldrops?ver=. So it's a no-op and stays as is.Review
dependencies()is only called on.jsentries, and the only non-scripturi()isimages/default-teaser.webp, which was already busted.php -land Pint pass. No unit tests coverAssets.🤖 Generated with Claude Code