I can’t find that Adam states that the meta information will be visible anywhere, this plugins seem to just allow the saving and restoring of post meta along with the revision. So i would say it’s working correctly.
That being said i also would like to see the meta differences on the compare screen. Maybe this can be included in a future version?
You can always pull the github repo and try to work it out yourself 🙂
I managed to show the meta on the revision screen for posts with the following code, as you can see the meta_field that im using is called rev_meta, change that to your field
//State that wp-post-meta-revisions should save our field
function add_meta_keys_to_revision( $keys ) {
$keys[] = 'rev_meta';
return $keys;
}
add_filter( 'wp_post_revision_meta_keys', 'add_meta_keys_to_revision' );
//Define the field on the revisions screen
function extrev_custom_fields($fields)
{
$fields['rev_meta'] = 'Revision meta value';
return $fields;
}
add_filter('_wp_post_revision_fields','extrev_custom_fields');
//For some reason (havent looked into it) the value is in a array, just pick it out
function extrev_field( $value, $field ) {
$test = $value[0];
return $test;
}
add_filter( '_wp_post_revision_field_rev_meta', 'extrev_field', 10, 2 );
You can see the result here: http://imgur.com/8iR8q0O
Please tell me how goofy this is done and how it can be improved, only put 30 min into it.
Hey Umocrajen,
Thanks for working through that code. It would be nice to only have to create the array of meta_keys once, but this works for now.
In wp-post-meta-revisions.php there is this code block:
// Add the revisioned meta to get_post_metadata for preview meta data
public function _add_metadata_preview_filter() {
add_filter( 'get_post_metadata', array( $this, '_wp_preview_meta_filter'), 10, 4 );
}
And on the plugin’s description page there is this bullet point:
- Adds revisioned meta to the preview data via get_post_metadata
That code and that bullet point led me to think that the meta data would be displayed on the Compare Revisions screen. Perhaps I misunderstood?
Anyhow, thanks again for working on this!
John
John,
Thanks for the question.
Umocrajen is correct, the revisions UI screen is not yet supported. I am working on this in the github repository: https://github.com/adamsilverstein/wp-post-meta-revisions.
The code you mentioned is used to load the meta for the preview screen, if you use post meta as part of your post view, this allows you to preview those values without saving them to the live post, a related issue.