IMO,违约的唯一回扣Post Revisions 它还存储自动保存操作。但是,它确实有一个历史记录,记录了改变了什么,改变了谁,并且似乎满足了OP的要求。
如果需要对此默认元框应用某些更改,则应将其删除并recreated, 似乎没有可用的挂钩。也许一个简单的jQuery更容易删除Autosave
条目:
add_action( \'admin_head-post-new.php\', \'remove_autosave_revisions_wpse_75651\' );
add_action( \'admin_head-post.php\', \'remove_autosave_revisions_wpse_75651\' );
function remove_autosave_revisions_wpse_75651()
{
?>
<script language="javascript" type="text/javascript">
jQuery(document).ready(function($)
{
$("ul.post-revisions").find("li:contains(\'Autosave\')").remove();
});
</script>
<?php
}
如果要使用自定义元框,请检查以下示例:
add_action( \'add_meta_boxes\', \'add_custom_box_wpse_75651\' );
add_action( \'save_post\', \'save_postdata_wpse_75651\', 10, 2 );
function add_custom_box_wpse_75651()
{
add_meta_box(
\'sectionid_wpse_75651\',
__( \'Post History\' ),
\'inner_custom_box_wpse_75651\',
\'post\'
);
}
function inner_custom_box_wpse_75651( $post )
{
$history = get_post_meta( $post->ID, \'_history\', true );
if( $history )
{
$reverse_history = array_reverse( $history );
echo "
<table class=\'widefat\'>
<thead>
<tr>
<th style=\'width:20%\'>Modified by</th>
<th>Date</th>
</tr>
</thead>
<tfoot>
<tr>
<th style=\'width:20%\'>Modified by</th>
<th>Date</th>
</tr>
</tfoot>
<tbody>";
foreach( $reverse_history as $h )
{
echo "
<tr>
<td>
{$h[0]}
</td>
<td>
{$h[1]}
</td>
</tr>
";
}
echo "</tbody>
</table>
";
}
}
function save_postdata_wpse_75651( $post_id, $post_object )
{
// Block auto-save
if ( defined( \'DOING_AUTOSAVE\' ) && DOING_AUTOSAVE )
return;
// Block revisions
if ( \'revision\' == $post_object->post_type )
return;
// Check post type
if ( \'post\' == $post_object->post_type )
{
global $current_user;
$history = get_post_meta( $post_id, \'_history\', true );
$history[] = array( $current_user->user_login, current_time( \'mysql\' ) );
update_post_meta( $post_id, \'_history\', $history );
}
}
其结果是: