Created
March 13, 2020 02:55
-
-
Save ediamin/4dc17d3521d2f338da0da16e5756cecc to your computer and use it in GitHub Desktop.
Using time() function in WordPress asset versioning for cache busting
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
<?php | |
namespace Vendor\Plugin; | |
class Assets { | |
// ... | |
public function register_scripts() { | |
$version = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? time() : MY_PLUGIN_VERSION; | |
wp_register_script( 'my-handle', MY_PLUGIN_ASSETS . '/js/script.js', [ 'jquery' ], $version, true ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment