https://github.com/landjonathan/wp-theme-semver-bump
A small utility that bumps WordPress theme versions using semantic versioning. Useful for cache-busting production sites.
https://github.com/landjonathan/wp-theme-semver-bump
semantic-versioning semver theme-development wordpress wordpress-development wordpress-theme
Last synced: 2 months ago
JSON representation
A small utility that bumps WordPress theme versions using semantic versioning. Useful for cache-busting production sites.
- Host: GitHub
- URL: https://github.com/landjonathan/wp-theme-semver-bump
- Owner: landjonathan
- License: mit
- Created: 2021-06-02T16:20:36.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2022-11-14T08:13:48.000Z (over 3 years ago)
- Last Synced: 2026-01-19T16:34:08.515Z (5 months ago)
- Topics: semantic-versioning, semver, theme-development, wordpress, wordpress-development, wordpress-theme
- Language: JavaScript
- Homepage:
- Size: 25.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# WP theme semantic versioning
A small utility that bumps WordPress theme versions using [semantic versioning](https://semver.org/).
Useful for cache-busting production sites.
## Usage
### Terminal
In the theme's folder, run
```bash
npx wp-theme-semver-bump
```
### In a script (e.g. gulp)
```js
const bump = require('wp-theme-semver-bump')
// ...
bump()
```
## Arguments
### Release type
```bash
npx wp-theme-semver-bump minor
```
or
```js
bump('minor')
```
## Custom file location
```bash
npx wp-theme-semver-bump patch relative/path/to/style.css
```
or
```js
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:
```php
// 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);
```