From efd0654aa3e45c00b22e9d02e4b0cda4d55b6e9c Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Thu, 16 Nov 2023 10:04:26 -0600 Subject: [PATCH] Stats comparison needs to be against most recent stats, not original --- src/wp-accessibility-stats.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/wp-accessibility-stats.php b/src/wp-accessibility-stats.php index 6186286..a76660e 100644 --- a/src/wp-accessibility-stats.php +++ b/src/wp-accessibility-stats.php @@ -82,7 +82,13 @@ function wpa_add_stats( $stats, $title, $type = 'view', $post_ID = 0 ) { // Log all on/off states for toolbar. add_post_meta( $exists, '_wpa_event', $stats ); } else { - $old_stats = get_post( $exists )->post_content; + // Get most recent test results and compare to current. + $history = get_post_meta( $post_id, '_wpa_event' ); + if ( $history && is_array( $history ) ) { + $old_stats = end( $history ); + } else { + $old_stats = get_post( $post_id )->post_content; + } if ( $stats !== $old_stats ) { // stats have changed; record the change. add_post_meta( $exists, '_wpa_event', $stats );