Created
October 4, 2018 22:28
-
-
Save nydame/3628c971857027121930dbf6eb4dcb94 to your computer and use it in GitHub Desktop.
Conditional cache-busting for WordPress stylesheets
This file contains 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
// Tired of making changes to your WordPress site's stylesheet, only to have the client tell you "It looks the same to me!"? | |
// Force WordPress to send a fresh copy to logged-in users with this simple code snippet. | |
// (In practice, put this code in your WordPress theme (e.g., in functions.php) or in a custom plugin.) | |
$now = new DateTime(); | |
$now_version = $now->format('YmdHis'); | |
if (is_user_logged_in()) { | |
wp_enqueue_style( 'pacificbiosciences-style', get_stylesheet_uri(), array(), $now_version ); | |
} else { | |
wp_enqueue_style( 'pacificbiosciences-style', get_stylesheet_uri() ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment