Support » Plugin: WP-Post-Meta-Revisions » Post meta revisions added to database but not showing in UI

  • WP Post Meta Revisions is installed, and I’ve added the filter for an array of meta_keys associated with a custom post type.

    I’ve modified that meta data several times for a particular post, but the changes are not showing in the “Compare Revisions” UI for that post.

    I checked the database and WP Post Meta Revisions is storing the revisions in the _postmeta table like it should, but for some reason the UI is not displaying the meta_value content differences for those revisions.

    I wish it did, as this plugin is a great idea, but for now in WordPress 4.4.2 it is not working correctly.

    After a quick look at /wp-admin/includes/revision.php, it almost seems like this plugin should be adding a filter for wp_get_revision_ui_diff, but I could easily be wrong about that.

    https://wordpress.org/plugins/wp-post-meta-revisions/

Viewing 4 replies - 1 through 4 (of 4 total)
  • 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

    Plugin Author Adam Silverstein

    (@adamsilverstein)

    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.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.