0.2.0 • Published 3 years ago

wp-theme-semver-bump v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

WP theme semantic versioning

A small utility that bumps WordPress theme versions using semantic versioning. Useful for cache-busting production sites.

Usage

Terminal

In the theme's folder, run

npx wp-theme-semver-bump

In a script (e.g. gulp)

const bump = require('wp-theme-semver-bump')
// ...
bump()

Arguments

Release type

npx wp-theme-semver-bump minor

or

bump('minor')

Custom file location

npx wp-theme-semver-bump patch relative/path/to/style.css

or

bump('patch', './relative/path/to/style.css')

Why?

The main use case is cache busting in production. No more "Try emptying the cache or opening in an incognito tab"!

The theme version can be appended to enqueued assets:

// functions.php or wherever you enqueue assets

// get the Version value from the theme's root style.css
$theme_version = wp_get_theme()->get('Version'); 

// append the version no. to the asset's src / href, e.g. 'theme/css/style.min.css?ver=0.1.0'
wp_enqueue_style('style', get_stylesheet_directory_uri() . '/css/style.min.css', [], $theme_version);