這個外掛並未在最新的 3 個 WordPress 主要版本上進行測試。開發者可能不再對這個外掛進行維護或提供技術支援,並可能會與更新版本的 WordPress 產生使用上的相容性問題。

Dynamic Asset Versioning

外掛說明

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.

安裝方式

There are two ways to install Dynamic Asset Versioning in your WordPress site: as a must-use (MU) or a standard plugin.

As a must-use (MU) plugin (recommended)

  1. Download or clone the repository into wp-content/mu-plugins.
  2. As MU plugins cannot run in a sub-directory, move dynamic-asset-versioning.php directly into the wp-content/mu-plugins directory.

As a standard WordPress plugin

  1. Download or clone the repository into wp-content/plugins.
  2. Activate the plugin through the WordPress plugins screen.

使用者評論

閱讀全部 1 則使用者評論

參與者及開發者

以下人員參與了開源軟體〈Dynamic Asset Versioning〉的開發相關工作。

參與者

將〈Dynamic Asset Versioning〉外掛本地化為台灣繁體中文版

對開發相關資訊感興趣?

任何人均可瀏覽程式碼、查看 SVN 存放庫,或透過 RSS 訂閱開發記錄

變更記錄

0.1.0

Initial public release.