Skip to content

Commit

Permalink
Fix errors in stats reporting; correct links to image resources
Browse files Browse the repository at this point in the history
  • Loading branch information
joedolson committed Jun 26, 2024
1 parent f4fa057 commit 2dd73e7
Showing 1 changed file with 36 additions and 25 deletions.
61 changes: 36 additions & 25 deletions src/wp-accessibility-stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,45 +334,56 @@ function wpa_stats_data_point( $post, $type, $limit = 5 ) {
$line = '';
$total = 0;
if ( 'event' === $type ) {
$date = gmdate( 'Y-m-d', $data->timestamp );
$time = gmdate( 'H:i', $data->timestamp );
// translators: date changed, time changed.
$hc_text_enabled = __( 'High contrast enabled on %1$s at %2$s', 'wp-accessibility' );
$hc_text_enabled = sprintf( __( 'High contrast enabled on %1$s at %2$s', 'wp-accessibility' ), $date, $time );
// translators: date changed, time changed.
$lf_text_enabled = __( 'Large font size enabled on %1$s at %2$s', 'wp-accessibility' );
$lf_text_enabled = sprintf( __( 'Large font size enabled on %1$s at %2$s', 'wp-accessibility' ), $date, $time );
// translators: date changed, time changed.
$hc_text_disabled = __( 'High contrast disabled on %1$s at %2$s', 'wp-accessibility' );
$hc_text_disabled = sprintf( __( 'High contrast disabled on %1$s at %2$s', 'wp-accessibility' ), $date, $time );
// translators: date changed, time changed.
$lf_text_disabled = __( 'Large font size disabled on %1$s at %2$s', 'wp-accessibility' );
$lf_text_disabled = sprintf( __( 'Large font size disabled on %1$s at %2$s', 'wp-accessibility' ), $date, $time );

$param = ( property_exists( $data, 'contrast' ) ) ? 'contrast' : 'fontsize';
if ( 'contrast' === $param ) {
switch ( $data->contrast ) {
case 'enabled':
$text = $hc_text_enabled;
break;
case 'disabled':
$text = $hc_text_disabled;
}
} else {
switch ( $data->fontsize ) {
case 'enabled':
$text = $lf_text_enabled;
break;
case 'disabled':
$text = $lf_text_disabled;
}
switch ( $param ) {
case 'contrast':
if ( property_exists( $data, 'contrast' ) ) {
switch ( $data->contrast ) {
case 'enabled':
$text = $hc_text_enabled;
break;
case 'disabled':
$text = $hc_text_disabled;
}
}
break;
case 'fontsize':
if ( property_exists( $data, 'fontsize' ) ) {
switch ( $data->fontsize ) {
case 'enabled':
$text = $lf_text_enabled;
break;
case 'disabled':
$text = $lf_text_disabled;
}
}
break;
}
$date = gmdate( 'Y-m-d', $data->timestamp );
$time = gmdate( 'H:i', $data->timestamp );

if ( property_exists( $data, 'alttext' ) ) {
$image_link = '<a href="' . esc_url( add_query_arg( 'item', $data->alttext, admin_url( 'upload.php' ) ) ) . '">' . esc_html( $data->alttext ) . '</a>';
$alt_img = preg_replace("/[^0-9]/", '', $data->alttext );
$image_link = '<a href="' . esc_url( get_edit_post_link( $alt_img ) ) . '">' . esc_html( $data->alttext ) . '</a>';
// translators: 1) image link. 2) date 3) time.
$text = sprintf( __( 'Alt text expanded on image %1$s on %2$s at %3$s', 'wp-accessibility' ), $image_link, $date, $time );
}
if ( property_exists( $data, 'longdesc' ) ) {
$image_link = '<a href="' . esc_url( add_query_arg( 'item', $data->longdesc, admin_url( 'upload.php' ) ) ) . '">' . esc_html( $data->longdesc ) . '</a>';
$ld_img = preg_replace("/[^0-9]/", '', $data->longdesc );
$image_link = '<a href="' . esc_url( get_edit_post_link( $ld_img ) ) . '">' . esc_html( $data->longdesc ) . '</a>';
// translators: 1) image link. 2) date 3) time.
$text = sprintf( __( 'Long description expanded on image %1$s on %2$s at %3$s', 'wp-accessibility' ), $image_link, $date, $time );
}
$line = '<li>' . sprintf( $text, $date, $time ) . '</li>';
$line = '<li>' . $text . '</li>';
if ( 'all' === $limit ) {
$limit = count( $history ) + 1;
}
Expand Down

0 comments on commit 2dd73e7

Please sign in to comment.