Browse Source

fix: restore asset cache-busting (was stripping all ?ver)

dw_remove_wp_ver_css_js stripped every ?ver query arg, so browsers cached
CSS/JS indefinitely and never picked up a rebuild. Scope it to the WP core
version only, and add a filemtime() cache-buster to the v4-style.min.css
enqueue so stylesheet rebuilds invalidate on reload.
windhamdavid 1 week ago
parent
commit
4882373b10
2 changed files with 5 additions and 2 deletions
  1. 1 1
      functions.php
  2. 4 1
      inc/tweaks.php

+ 1 - 1
functions.php

@@ -59,7 +59,7 @@ function dw_remove_block_library_css(){
 add_action( 'wp_enqueue_scripts', 'dw_scripts' );
 function dw_scripts() {
 	global $post;
-	wp_enqueue_style( 'style-min', get_template_directory_uri() . '/v4-style.min.css');
+	wp_enqueue_style( 'style-min', get_template_directory_uri() . '/v4-style.min.css', array(), filemtime( get_template_directory() . '/v4-style.min.css' ) );
 	wp_deregister_script('jquery');
 
 	if ( is_page('studio') ) {

+ 4 - 1
inc/tweaks.php

@@ -46,8 +46,11 @@ remove_action('wp_head', 'feed_links', 2 );
 remove_action('wp_head', 'wp_oembed_add_discovery_links', 10);
 remove_action('wp_head', 'wp_oembed_add_host_js', 10);
 
+// Strip only the WordPress *core* version from asset URLs (mild version hiding).
+// Leave other ?ver values intact so filemtime cache-busters keep working —
+// otherwise browsers cache CSS/JS forever and never see a rebuild.
 function dw_remove_wp_ver_css_js( $src ) {
-    if ( strpos( $src, 'ver=' ) )
+    if ( strpos( $src, 'ver=' . $GLOBALS['wp_version'] ) !== false )
         $src = remove_query_arg( 'ver', $src );
     return $src;
 }