-
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
base: core
Are you sure you want to change the base?
Conversation
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 comment
The reason will be displayed to describe this comment to others. Learn more.
onClick={event => { | ||
event.preventDefault() | ||
openUpgradeDialog() | ||
}} | ||
> | ||
{_x('Upgrade to ', 'Upgrade to Pro', 'code-snippets')} | ||
<span className="badge">{_x('Pro', 'Upgrade to Pro', 'code-snippets')}</span> | ||
{__('Upgrade to <span class="badge">Pro</span>', 'code-snippets')} |
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.
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.
Great job finding these adjustments and misapplied translation functions. I'm curious about the change from title
to aria-label
– do non-screen reader browsers display this attribute in some way like titles are on hover? Is its use generally always preferred over title
attributes?
@sheabunge Read this, you will find several references to https://make.wordpress.org/core/2025/03/25/accessibility-improvements-in-wordpress-6-8/ To answer your question, when hovering links, non-screen reader browsers will not display |
Currently, the titles add important context to screen users, and I worry that by replacing them with |
/* 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' ); | ||
); |
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.
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.
Before:
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>
After:
Successfully imported %d snippet.
Successfully imported %d snippets.
Have fun!
Short and easier to translate strings, without HTML tags.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Before:
<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.
After:
%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.
This PR fixes the following:
esc_html_e
andesc_attr_e
).title
attributes, replacing them witharia-label
.