0

I'm developing a WordPress site, and want to include auto-versioning of the main stylesheet so users will always download the newest CSS file version whenever changes are made.

To do that, I'm using the method here (https://eric.blog/2014/05/12/auto-versioning-css-javascript-wordpress/) where you use filemtime to add the file's last-modified time to the end of the the filename as a version variable (e.g. mystylesheet.css?ver=12345). It seems to be working.

I know you can print out a list of all the enqueued styles and scripts using a method like this (Get the list of enqueued scripts in wordpress?), but it only gives you the handles, not the actual file path/name/version.

Enqueued styles & scripts do NOT show up in the Network tab, or in the source code. I really want to ensure that this is working as intended, and not just working because it's falling back to a WordPress default. Is there any way to see what FILE VERSIONS are being requested during the enqueue process?

supernaut
  • 311
  • 3
  • 11

1 Answers1

0
$themecsspath = get_stylesheet_directory() . '/css/styles.css';
wp_enqueue_style(
    'child-theme',
    get_stylesheet_directory_uri() . '/css/styles.css',
    array(),
    filemtime( $themecsspath )
);

filemtime($file) will give you the file modification time.

  • Yes, that's basically the method I'm using--but how can I verify that it's working? Is there a way to see the file & version that's being called by WordPress? The second link I posted shows a way to see the *handles* of the enqueued styles & scripts, but I'd like to see the *paths* including the appended version variables. – supernaut Jan 15 '19 at 13:55