From 2445f7f6a574531b0c25980906a4044d819e7487 Mon Sep 17 00:00:00 2001 From: Mike Henderson <107649073+nc-mhenderson@users.noreply.github.com> Date: Tue, 4 Oct 2022 09:33:45 -0600 Subject: [PATCH] add file modified time to script enqueue --- class-local-scripts-shortcode.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/class-local-scripts-shortcode.php b/class-local-scripts-shortcode.php index edd9f7f..7176570 100644 --- a/class-local-scripts-shortcode.php +++ b/class-local-scripts-shortcode.php @@ -58,8 +58,10 @@ public static function local_script( $attr ) { $full_path = get_site_url( 1, '/wp-content/themes/' . basename( get_template_directory() ) ) . '/' . $path . '/' . $script; $full_path = esc_attr($full_path); } + + $version_path = get_theme_file_path( $path . '/' . $script . '.js' ); - wp_enqueue_script( str_replace('/', '_', $full_path ), esc_attr($full_path . '.js'), $attr['dependencies'], false, true ); + wp_enqueue_script( str_replace('/', '_', $full_path ), esc_attr($full_path . '.js'), $attr['dependencies'], filemtime($version_path), true ); return ''; }