Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
<?php
function gg_asset_url( $path = '' ) {
return esc_url( get_template_directory_uri() . '/assets/' . $path );
}
function gg_asset_path( $path = '' ) {
return get_template_directory() . '/assets/' . $path;
}
function gg_assets() {
wp_enqueue_style(
'gg-style', // name
gg_asset_url( 'css/style.css' ), // file URL
array(), // dependencies
filemtime( gg_asset_path( 'css/style.css' ) ) // `ver` paramater value
);
wp_enqueue_script(
'gg-script', // name
gg_asset_url( 'js/script.js' ), // file URL
array( 'jquery' ), // dependencies
filemtime( gg_asset_path( 'js/script.js' ) ), // `ver` paramater value
);
}
add_action( 'wp_enqueue_scripts', 'gg_assets' );
<link rel="stylesheet" href="my/css/file.css?ver=<?php echo filemtime(__DIR__ . '/my/css/file.css'); ?>">
<script src="my/js/file.js?ver=<?php echo filemtime(__DIR__ . '/my/js/file.js'); ?>"></script>
<link rel="stylesheet" href="my/css/file.css?ver=<?php echo time(); ?>">
<script src="my/js/file.js?ver=<?php echo time(); ?>"></script>
<link rel="stylesheet" href="my/css/file.css?ver=1">
<script src="my/js/file.js?ver=1"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment