Open Enchiridion opened 4 years ago
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.
Here is my code for displaying custom fields in a diff. Insert this on line 791
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/.
@bonny This would be great, even if initially limited to text fields to simplify the presentation of before-after diffs.
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!