WordPress-Simple-History
WordPress-Simple-History copied to clipboard
Feature Request: Show Meta Data Diff
When changes are made to a post, a diff is shown for the standard fields, ie title, content, status, but it'd be great if it could log all meta data changes as well. The custom post types I work with are mostly meta data. Thanks!
I am also interested in this feature and have been working on it for a good part of my day. I can say that showing a diff is easy for WordPress custom fields but I am having trouble with ACF and Metabox custom fields. The old values are being retrieved but the new value are not. I think this is what you are after. I was able to accomplish this by installing the Classic Editor plugin then making two native custom fields.
@bonny Anything you can think of that would not allow for ACF or Metabox field values to be queried? I think it might have something to do with timing on this function.
https://github.com/bonny/WordPress-Simple-History/blob/66b8c7f94c8acae7a93d131e223561c29d247a37/loggers/SimplePostLogger.php#L103
Here is my code for displaying custom fields in a diff. Insert this on line 791
https://github.com/bonny/WordPress-Simple-History/blob/66b8c7f94c8acae7a93d131e223561c29d247a37/loggers/SimplePostLogger.php#L791
foreach ($old_meta as $diff_key => $old_diff_values) {
$context["post_prev_{$diff_key}"] = $old_meta[$diff_key][0];
}
foreach ($new_meta as $new_diff_key => $new_diff_values) {
$context["post_new_{$new_diff_key}"] = $new_diff_values[0];
}
This is also a requested feature in the support forums, for example: https://wordpress.org/support/topic/support-logging-changes-in-custom-fields/.