-
Notifications
You must be signed in to change notification settings - Fork 108
Improve i18n, a11y, and security #233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2859599
1f35d34
3929319
425c692
8aa1e81
ae26a67
c1e40ea
1df2832
8217760
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,15 +137,22 @@ protected function print_messages() { | |
esc_html_e( 'No snippets were imported.', 'code-snippets' ); | ||
|
||
} else { | ||
/* translators: 1: amount of snippets imported, 2: link to Snippets menu */ | ||
$text = _n( | ||
'Successfully imported <strong>%1$d</strong> snippet. <a href="%2$s">Have fun!</a>', | ||
'Successfully imported <strong>%1$d</strong> snippets. <a href="%2$s">Have fun!</a>', | ||
$imported, | ||
'code-snippets' | ||
/* translators: %d: amount of snippets imported */ | ||
printf( | ||
_n( | ||
'Successfully imported %d snippet.', | ||
'Successfully imported %d snippets.', | ||
$imported, | ||
'code-snippets' | ||
), | ||
'<strong>' . number_format_i18n(( $imported ) . '</strong>', | ||
); | ||
|
||
printf( wp_kses_post( $text ), esc_html( $imported ), esc_url( code_snippets()->get_menu_url( 'manage' ) ) ); | ||
printf( | ||
' <a href="%s">%s</a>', | ||
esc_url( code_snippets()->get_menu_url( 'manage' ) ) | ||
esc_html__( 'Have fun!', 'code-snippets' ); | ||
); | ||
Comment on lines
+140
to
+155
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Before:
After:
Short and easier to translate strings, without HTML tags. |
||
} | ||
|
||
echo '</p></div>'; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,7 +117,7 @@ public function display_rows() { | |
*/ | ||
foreach ( $this->items as $item ) { | ||
?> | ||
<div class="plugin-card cloud-search-card plugin-card-<?php echo sanitize_html_class( $item->id ); ?>"> | ||
<div class="plugin-card cloud-search-card plugin-card-<?php echo esc_attr( $item->id ); ?>"> | ||
<?php | ||
cloud_lts_display_column_hidden_input( 'code', $item ); | ||
cloud_lts_display_column_hidden_input( 'name', $item ); | ||
|
@@ -163,14 +163,12 @@ public function display_rows() { | |
<p class="authors"> | ||
<cite> | ||
<?php | ||
esc_html_e( 'Codevault: ', 'code-snippets' ); | ||
|
||
printf( | ||
'<a target="_blank" href="%s">%s</a>', | ||
'%s <a target="_blank" href="%s">%s</a>', | ||
esc_html__( 'Codevault:', 'code-snippets' ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
esc_url( sprintf( 'https://codesnippets.cloud/codevault/%s', $item->codevault ) ), | ||
esc_html( $item->codevault ) | ||
); | ||
|
||
?> | ||
</cite> | ||
</p> | ||
|
@@ -250,14 +248,22 @@ public function display_rows() { | |
</div> | ||
</div> | ||
<div class="column-compatibility"> | ||
<strong><?php esc_html_e( 'WP Compatability:', 'code-snippets' ); ?></strong> | ||
<strong><?php esc_html_e( 'WP Compatibility:', 'code-snippets' ); ?></strong> | ||
<?php | ||
if ( empty( $wp_tested ) ) { | ||
echo '<span class="compatibility-untested">', esc_html__( 'Not indicated by author', 'code-snippets' ), '</span>'; | ||
printf( | ||
'<span class="compatibility-untested">%s</span>', | ||
esc_html__( 'Not indicated by author', 'code-snippets' ) | ||
); | ||
} else { | ||
// translators: tested status. | ||
$text = sprintf( __( 'Author states %s', 'code-snippets' ), $wp_tested ); | ||
echo '<span class="compatibility-compatible">', esc_html( $text ), '</span>'; | ||
printf( | ||
'<span class="compatibility-compatible">%s</span>', | ||
sprintf( | ||
// translators: %s: tested status. | ||
__( 'Author states %s', 'code-snippets' ), | ||
$wp_tested | ||
) | ||
); | ||
} | ||
?> | ||
</div> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -303,11 +303,12 @@ public function render_content_shortcode( array $atts ): string { | |
} | ||
|
||
/* translators: 1: snippet name, 2: snippet edit link */ | ||
$text = __( '<strong>%1$s</strong> is currently inactive. You can <a href="%2$s">edit this snippet</a> to activate it and make it visible. This message will not appear in the published post.', 'code-snippets' ); | ||
|
||
$text = __( '%1$s is currently inactive. You can <a href="%2$s">edit this snippet</a> to activate it and make it visible. This message will not appear in the published post.', 'code-snippets' ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Before:
After:
|
||
$snippet_name = '<strong>' . $snippet->name . '</strong>'; | ||
$edit_url = add_query_arg( 'id', $snippet->id, code_snippets()->get_menu_url( 'edit' ) ); | ||
|
||
return wp_kses( | ||
sprintf( $text, $snippet->name, $edit_url ), | ||
sprintf( $text, $snippet_name, $edit_url ), | ||
[ | ||
'strong' => [], | ||
'a' => [ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will merge similar translation strings, and reduce the total strings by 2: