Merge pull request #32 from lukasjuhas/master
Use filetime() for asset revisions.
This commit is contained in:
commit
d98f41ad2c
|
@ -1,4 +1,7 @@
|
||||||
# barebones changelog
|
# barebones changelog
|
||||||
|
## 2.0.5
|
||||||
|
* Use filetime() for asset revisions as it's more compatible and easier to support.
|
||||||
|
|
||||||
## 2.0.4
|
## 2.0.4
|
||||||
* Better static asset revisioning using randomly generated hash when running gulp tasks.
|
* Better static asset revisioning using randomly generated hash when running gulp tasks.
|
||||||
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -72,7 +72,7 @@ function barebones_scripts()
|
||||||
wp_deregister_script('jquery');
|
wp_deregister_script('jquery');
|
||||||
wp_register_script('jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js', false, '1.11.3', true);
|
wp_register_script('jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js', false, '1.11.3', true);
|
||||||
wp_enqueue_script('jquery');
|
wp_enqueue_script('jquery');
|
||||||
wp_enqueue_script('script', get_stylesheet_directory_uri() . '/js/script.min.js?' . getPackageHash(), ['jquery'], null, true);
|
wp_enqueue_script('script', get_stylesheet_directory_uri() . '/js/script.min.js?' . filemtime(get_stylesheet_directory() . '/js/script.min.js'), ['jquery'], null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
add_action('wp_enqueue_scripts', 'barebones_scripts');
|
add_action('wp_enqueue_scripts', 'barebones_scripts');
|
||||||
|
@ -173,19 +173,6 @@ function barebones_tiny_mce_before_init($settings)
|
||||||
|
|
||||||
add_filter('tiny_mce_before_init', 'barebones_tiny_mce_before_init');
|
add_filter('tiny_mce_before_init', 'barebones_tiny_mce_before_init');
|
||||||
|
|
||||||
/**
|
|
||||||
* Get hash from package.json used for assets url hash
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function getPackageHash()
|
|
||||||
{
|
|
||||||
$package = file_get_contents(get_bloginfo( 'stylesheet_directory' ) . "/package.json");
|
|
||||||
$packageJson = json_decode($package, true);
|
|
||||||
|
|
||||||
// if there is problem, fallback to time.
|
|
||||||
return isset($packageJson['hash']) ? $packageJson['hash'] : time();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get post thumbnail url
|
* Get post thumbnail url
|
||||||
* @param string $size Size of the returned image
|
* @param string $size Size of the returned image
|
||||||
|
|
20
gulpfile.js
20
gulpfile.js
|
@ -21,27 +21,9 @@ elixir.extend('imagemin', function(src, dest) {
|
||||||
}).watch(elixir.config.assetsPath + src);
|
}).watch(elixir.config.assetsPath + src);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create a Hash in package.json
|
|
||||||
elixir.extend('hash', function() {
|
|
||||||
new Task('hash', function() {
|
|
||||||
var fs = require('fs');
|
|
||||||
var fileName = './package.json';
|
|
||||||
var file = require(fileName);
|
|
||||||
|
|
||||||
// generate a new hash
|
|
||||||
file.hash = ( 0 | Math.random() * 9e6 ).toString(36);
|
|
||||||
// save to package.json
|
|
||||||
fs.writeFile(fileName, JSON.stringify(file, null, 2), function (err) {
|
|
||||||
if (err) return console.log(err);
|
|
||||||
console.log('writing to ' + fileName);
|
|
||||||
});
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
// Run elixir tasks
|
// Run elixir tasks
|
||||||
elixir(function(mix) {
|
elixir(function(mix) {
|
||||||
mix.sass('barebones.scss', 'style.css')
|
mix.sass('barebones.scss', 'style.css')
|
||||||
.scripts(['script.js'], 'js/script.min.js')
|
.scripts(['script.js'], 'js/script.min.js')
|
||||||
.imagemin('/images/**/*', './img')
|
.imagemin('/images/**/*', './img');
|
||||||
.hash();
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0">
|
||||||
<link rel="dns-prefetch" href="//google-analytics.com">
|
<link rel="dns-prefetch" href="//google-analytics.com">
|
||||||
<link rel="stylesheet" href="<?php echo get_bloginfo('stylesheet_url') . '?' . getPackageHash(); ?>">
|
<link rel="stylesheet" href="<?php echo get_bloginfo( 'stylesheet_url' ) . '?' . filemtime(get_stylesheet_directory() . '/style.css'); ?>">
|
||||||
<?php wp_head(); ?>
|
<?php wp_head(); ?>
|
||||||
<!--[if lt IE 10]>
|
<!--[if lt IE 10]>
|
||||||
<script src="//cdnjs.cloudflare.com/ajax/libs/placeholders/3.0.2/placeholders.min.js"></script>
|
<script src="//cdnjs.cloudflare.com/ajax/libs/placeholders/3.0.2/placeholders.min.js"></script>
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "barebones",
|
"name": "barebones",
|
||||||
"version": "2.0.4",
|
"version": "2.0.5",
|
||||||
"hash": "brbns",
|
|
||||||
"author": "Benchmark Studios",
|
"author": "Benchmark Studios",
|
||||||
"description": "A lightweight and skeletal WordPress boilerplate theme for HTML5 and beyond",
|
"description": "A lightweight and skeletal WordPress boilerplate theme for HTML5 and beyond",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|
Loading…
Reference in New Issue