[WordPress] 外掛分享: Dynamic Asset Versioning

前言介紹

  • 這款 WordPress 外掛「Dynamic Asset Versioning」是 2016-12-11 上架。
  • 目前有 40 個安裝啟用數。
  • 上一次更新是 2016-12-14,距離現在已有 3063 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
  • 外掛最低要求 WordPress 4.7 以上版本才可以安裝。
  • 有 1 人給過評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

growella | stevegrunwell |

外掛標籤

cache | assets | versioning |

內容簡介

WordPress 資源版本控制有時候會是一把雙刃劍:一方面它能夠極有效地進行緩存破解,確保你不會向瀏覽者分享過時的腳本或樣式。另一方面,手動增加版本號碼是很麻煩的事情(即使是使用常數,也是如此!),往往會導致版本控制記錄充滿“升級版本號碼”提交。

動態資源版本控制的目標就是簡化此流程:如果一個已經入列的資源沒有明確的版本號碼,此外掛會自動獲取文件上次修改的時間戳並使用它作為版本號碼。這很簡單:你觸摸了文件,版本號碼就會自動更新。

使用方式

一旦啟用了動態資源版本控制,它會基於文件修改時間自動獲取版本號碼,對任何已經入列使用wp_enqueue_style() 或 wp_enqueue_script()的[非核心]文件生效。

範例

wp_enqueue_style(
'my-theme-styles',
get_template_directory_uri() . '/assets/css/my-styles.css',
array( 'some-other-styles' ),
false, // 別擔心,動態資源版本控制會為你覆蓋!
'screen'
);

特別感謝

一個特別的感謝要送給10up,他們調劑了這個外掛的原始概念。

原文外掛簡介

WordPress asset versioning can be a double-edged sword: on one-hand, it’s extremely effective for cache-busting, ensuring you aren’t sharing stale scripts or styles to your visitors. On the other hand, having to manually increment a version number is a pain (even as a constant), often resulting in a version control history full of “bumping the version number” commits.
Dynamic Asset Versioning aims to simplify this process: if an enqueued asset doesn’t have an explicit version number, the plugin will get the timestamp of the last time the file was changed and use that as the version number. It’s easy: you touch the file, the version number is updated automatically.
Usage
Once Dynamic Asset Versioning is active, it will automatically determine version numbers based on file modification time for any [non-core] files that have been enqueued using wp_enqueue_style() or wp_enqueue_script().
Example
wp_enqueue_style(
'my-theme-styles',
get_template_directory_uri() . '/assets/css/my-styles.css',
array( 'some-other-styles' ),
false, // Don't worry about it, Dynamic Asset Versioning has you covered!
'screen'
);

Special thanks
A special thanks goes out to 10up, who helped inspire the original concept of this plugin.

各版本下載點

  • 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
  • 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Dynamic Asset Versioning」來進行安裝。

(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。


0.1.0 | 0.2.0 | trunk |

延伸相關外掛(你可能也想知道)

文章
Filter
Apply Filters
Mastodon