[WordPress] 外掛分享: WP-Post-Meta-Revisions

首頁外掛目錄 › WP-Post-Meta-Revisions
WordPress 外掛 WP-Post-Meta-Revisions 的封面圖片
400+
安裝啟用
★★★★
4.2/5 分(5 則評價)
976 天前
最後更新
問題解決
WordPress 4.1+ v2.0.0 上架:2014-12-03

內容簡介

這個外掛程式實現了 "https://core.trac.wordpress.org/ticket/20564" 中提出的文章元數據修訂功能。

將此代碼作為外掛程式發布的目的是讓盡可能多的人輕鬆測試文章元數據修訂功能,並希望按照插件化功能的模式將此功能納入核心。

此外掛程式的進一步開發將繼續在其GitHub 存儲庫上進行。歡迎提交拉取請求!

為了使用這個外掛程式,您必須運行 WordPress 4.1 或更新版本,因為 4.1 中添加了兩個掛鉤,這些掛鉤對於此功能的實現是必需的。

要對文章元數據進行修訂,您可以通過一個過濾器添加其鍵:

function add_meta_keys_to_revision( $keys ) {
$keys[] = '要進行修訂的元數據鍵';
return $keys;
}
add_filter( 'wp_post_revision_meta_keys', 'add_meta_keys_to_revision' );

特點:

允許一個白名單陣列進行“修訂”的元數據鍵(可以隨時更改)
如果元數據的值已更改,將在保存時保存元數據的修訂
自動保存期間還會觸發元數據修訂的保存(如果已更改)
還原修訂會恢復該修訂中的修訂元字段值(包括自動保存)
支持為單個鍵存儲多個值(並恢復它們)
通過 get_post_metadata 添加修訂元數據到預覽數據中
包括演示功能的單元測試
集成了 Travis CI 和 GitHub 存儲庫的測試(感謝 @mattheu)

開發者團隊

⬇ 下載最新版 (v2.0.0) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「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

延伸相關外掛

文章
Filter
Mastodon