Skip to content

Instantly share code, notes, and snippets.

@jrobinsonc
Created March 27, 2018 13:49
Show Gist options
  • Select an option

  • Save jrobinsonc/a05c6cd0af84f192b78ca14015959314 to your computer and use it in GitHub Desktop.

Select an option

Save jrobinsonc/a05c6cd0af84f192b78ca14015959314 to your computer and use it in GitHub Desktop.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)-[0-9]+\.(js|css)$ $1.$2 [L]
<?php
// Site styles
$css_file = '/css/main';
$version = filemtime(get_template_directory() . "{$css_file}.css");
wp_enqueue_style('site-css', get_template_directory_uri() . "{$css_file}-{$version}.css", [], null);
// Site scripts
$js_file = '/js/main';
$version = filemtime(get_template_directory() . "{$js_file}.js");
wp_enqueue_script('site-js', get_template_directory_uri() . "{$js_file}-{$version}.js", [], null, true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment