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 );