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

WP-Post-Meta-Revisions

外掛說明

This plugin implements a post meta revisioning feature as arrived at in https://core.trac.wordpress.org/ticket/20564.

The goal of releasing this code as a plugin is to allow as many people as possible to easily test the post meta revisioning feature, and also hopefully move towards inclusion of the feature into core, following the Features as Plugins model.

Further development of the code for this plugin will continue on its GitHub repository. Pull requests welcome!

To use this plugin, you must be running WordPress 4.1 or newer, two hooks were added in 4.1 that are required for this implementation.

To revision a post meta, you add its key via a filter:

function add_meta_keys_to_revision( $keys ) {
    $keys[] = 'meta-key-to-revision';
    return $keys;
}
add_filter( 'wp_post_revision_meta_keys', 'add_meta_keys_to_revision' );

Features:

  • Allows for a whitelisted array of ‘revisioned’ meta keys (which can change at any time)
  • A revision for the meta is stored on save (if the meta value has changed)
  • A meta revision save (if changed) is also triggered during auto-saves
  • Restoring a revision restores the revisioned meta field’s values at that revision (including auto-saves)
  • Supports storing of multiple values for a single key (and restoring them)
  • Adds revisioned meta to the preview data via get_post_metadata
  • Includes unit tests demonstrating feature
  • Travis CI tests integrated with GitHub repository, props @mattheu

螢幕擷圖

使用者評論

2016 年 9 月 3 日
DUDE! Why did I never think of this before? This is an awesome idea! I haven’t even installed the plugin and you are getting five stars straight off the bat for solving a problem I didn’t even know I had. Thanks 🙂
閱讀全部 5 則使用者評論

參與者及開發者

以下人員參與了開源軟體〈WP-Post-Meta-Revisions〉的開發相關工作。

參與者

將〈WP-Post-Meta-Revisions〉外掛本地化為台灣繁體中文版

對開發相關資訊感興趣?

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

變更記錄

2.0.0

  • Post meta storage mechanism simplified to use copy approach. This change updates the way meta is stored on the revision to mirror the meta on the post it is created from. props @aaemnnosttv, see https://github.com/adamsilverstein/wp-post-meta-revisions/pull/56.
    NOTE: This is a breaking change – restoring revisions saved in the previous format may result in the array of values restored as a single value rather than adding a value for each item in the array. The storage of single meta values is unaffected.

1.0.0

Tagging release as 1.0.

1.0.0

  • Simplify by no longer storing whitelist per revision.

0.1.9

  • Initial release.