innocode-digital/wp-assets-version
最新稳定版本:1.1.0
Composer 安装命令:
composer require innocode-digital/wp-assets-version
包简介
Helps with versioning of CSS and JS files.
README 文档
README
Description
Helps with versioning of CSS and JS files. Plugin adds flush buttons to admin area for version upgrading. Requires Flush Cache Buttons plugin.
Install
-
Preferable way is to use Composer:
composer require innocode-digital/wp-assets-versionBy default, it will be installed as Must Use Plugin. It's possible to control with
extra.installer-pathsincomposer.json. -
Alternate way is to clone this repo to
wp-content/mu-plugins/orwp-content/plugins/:cd wp-content/plugins/ git clone git@github.com:innocode-digital/wp-assets-version.git cd wp-assets-version/ composer install
If plugin was installed as regular plugin then activate Assets Version from Plugins page
or WP-CLI: wp plugin activate wp-assets-version.
Usage
There are known functions wp_enqueue_script and
wp_enqueue_style in WordPress core to register
and enqueue scripts and styles. In both of them 4th parameter
is for version number and in ideal case it should be version of build or theme or null with some version hash in filename ...
but sometimes it's hard to implement or there are could be particular issues in caching, and it's where this plugin becomes
as a good hotfix. There are few ways to add version with this plugin:
-
Retrieve version through function
innocode_assets_version()and set as 4th parameter in enqueue functions, e.g.:$ver = function_exists( 'innocode_assets_version' ) ? innocode_assets_version() : false; wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer ); -
Force using of version where
nullset as 4th parameter:add_filter( 'innocode_assets_version_allow_default', '__return_true' ); -
Force using of version but with own logic per dependency (requires previous hook to be set), e.g.:
/** * @param bool $allow * @param string $type - One of [ 'script', 'style' ]. * @param _WP_Dependency $dependency */ add_filter( 'innocode_assets_version_allow_dependency', function ( bool $allow, string $type, _WP_Dependency $dependency ) { // @TODO: implement logic return $allow; }, 20, 3 );
统计信息
- 总下载量: 6.86k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0
- 更新时间: 2021-08-12