Skip to content

Commit e4abee8

Browse files
committed
Merge branch 'feature/5209-clipboard-friendly-errors' of github.com:ampproject/amp-wp into feature/5209-clipboard-friendly-errors
* 'feature/5209-clipboard-friendly-errors' of github.com:ampproject/amp-wp: Remove unnecessary aria-label Parse and re-stringify JSON data to prettify No need to pretty-print error details on the backend
2 parents 82edbbd + 23fbfed commit e4abee8

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

assets/src/amp-validation/copy-to-clipboard-buttons.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export function handleCopyToClipboardButtons() {
4949
// eslint-disable-next-line no-new
5050
clipboards.push( new Clipboard( 'button.single-url-detail-copy', {
5151
text: ( btn ) => {
52-
return btn.getAttribute( 'data-error-json' );
52+
return JSON.stringify( JSON.parse( btn.getAttribute( 'data-error-json' ) ), null, '\t' );
5353
},
5454
} ) );
5555

includes/validation/class-amp-validation-error-taxonomy.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1613,7 +1613,7 @@ public static function get_error_details_json( $term ) {
16131613
$json['removed'] = (bool) ( (int) $term->term_group & self::ACCEPTED_VALIDATION_ERROR_BIT_MASK );
16141614
$json['reviewed'] = (bool) ( (int) $term->term_group & self::ACKNOWLEDGED_VALIDATION_ERROR_BIT_MASK );
16151615

1616-
return wp_json_encode( $json, JSON_PRETTY_PRINT );
1616+
return wp_json_encode( $json );
16171617
}
16181618

16191619
/**
@@ -1646,8 +1646,7 @@ public static function filter_tag_row_actions( $actions, WP_Term $tag ) {
16461646
);
16471647

16481648
$actions['copy'] = sprintf(
1649-
'<button type="button" aria-label="%s" class="single-url-detail-copy button-link" data-error-json="%s">%s</button>',
1650-
esc_attr__( 'Copy to clipboard', 'amp' ),
1649+
'<button type="button" class="single-url-detail-copy button-link" data-error-json="%s">%s</button>',
16511650
esc_attr( self::get_error_details_json( $term ) ),
16521651
esc_html__( 'Copy to clipboard', 'amp' )
16531652
);

0 commit comments

Comments
 (0)