Skip to content

Commit

Permalink
Stats comparison needs to be against most recent stats, not original
Browse files Browse the repository at this point in the history
  • Loading branch information
joedolson committed Nov 16, 2023
1 parent 12c2a56 commit efd0654
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/wp-accessibility-stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down

0 comments on commit efd0654

Please sign in to comment.