Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
gulp-wp-cache-bust
Advanced tools
Revisioning worpdress theme files by appending a hash to your assets path.
Wordpress cache busting plugin for gulp
There are many ways to embed files in Wordpress. You can manually link to a file, or use the wp_enqueue_script
/wp_enqueue_style
and wp_register_script
/wp_register_style
methods. Often there could be a need to mix and match both methods within the same theme. To cachebust your files, create a php file within your theme and define the files as constants:
<?php
define('RESET_CSS', get_template_directory_uri() . '/css/reset.css');
define('ABSOLUTE_PATH_TO_FILE', '/css/reset.css');
define('THIRD_PARTY', 'https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js');
This plugin will read this file and modify it to this:
<?php
define('RESET_CSS', get_template_directory_uri() . '/css/reset.css?v=84507b8f4af3062c3888dbd83bde27ea');
define('ABSOLUTE_PATH_TO_FILE', '/css/reset.css?v=84507b8f4af3062c3888dbd83bde27ea');
define('THIRD_PARTY', 'https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js');
You can then use these constants in functions.php (or wherever you want).
An example functions.php file:
<?php
include 'scripts.php';
wp_enqueue_style('reset_css', RESET_CSS);
wp_enqueue_script('site_vendor_js', VENDOR_JS, null, false, true);
$ npm install --save-dev gulp-wp-cache-bust
const gulp = require("gulp");
const wpcachebust = require("gulp-wp-cache-bust");
gulp.task("default", () =>
gulp
.src("./dev/wp-content/themes/themeName/scripts.php", { base: "./" })
.pipe(
wpcachebust({
themeFolder: "./dev/wp-content/themes/themeName",
rootPath: "./",
})
)
.pipe(gulp.dest("./"))
);
Type: Object
Type: string
Default: ``
Root path of dev folder. Used if path to file is absolute (/css/main.css/
).
Type: string
Default: null
Path to Wordpress theme folder. Used to find file when path to includes get_template_directory_uri()
or get_stylesheet_directory_uri()
.
MIT © Tyler Craft
FAQs
Revisioning worpdress theme files by appending a hash to your assets path.
We found that gulp-wp-cache-bust demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.