Make WordPress Core


Ignore:
Timestamp:
09/28/2025 10:36:30 PM (7 weeks ago)
Author:
joedolson
Message:

I18n: Combine duplicate text strings into variables.

In cases where a string is used both for a visible label and a screen reader text label, the screen reader text should never be different from the visible label. To help ensure this doesn't happen, use only a single string. The associated screen reader text comments are no longer required.

This is also true for a few cases where there are strings in contexts where variables can't be used. In these cases, the screen reader text comments are also removed.

Props sabernhardt, swissspidy, audrasjb, joedolson.
Fixes #63620.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/options-discussion.php

    r60269 r60805  
    4444
    4545<table class="form-table indent-children" role="presentation">
    46 <tr>
    47 <th scope="row"><?php _e( 'Default post settings' ); ?></th>
    48 <td><fieldset><legend class="screen-reader-text"><span>
    49     <?php
    50     /* translators: Hidden accessibility text. */
    51     _e( 'Default post settings' );
    52     ?>
    53 </span></legend>
     46<?php $default_post_settings_title = __( 'Default post settings' ); ?>
     47<tr>
     48<th scope="row"><?php echo $default_post_settings_title; ?></th>
     49<td><fieldset><legend class="screen-reader-text"><span><?php echo $default_post_settings_title; ?></span></legend>
    5450<label for="default_pingback_flag">
    5551<input name="default_pingback_flag" type="checkbox" id="default_pingback_flag" value="1" <?php checked( '1', get_option( 'default_pingback_flag' ) ); ?> />
     
    6763</fieldset></td>
    6864</tr>
    69 <tr>
    70 <th scope="row"><?php _e( 'Other comment settings' ); ?></th>
    71 <td><fieldset><legend class="screen-reader-text"><span>
    72     <?php
    73     /* translators: Hidden accessibility text. */
    74     _e( 'Other comment settings' );
    75     ?>
    76 </span></legend>
     65<?php $other_comment_settings_title = __( 'Other comment settings' ); ?>
     66<tr>
     67<th scope="row"><?php echo $other_comment_settings_title; ?></th>
     68<td><fieldset><legend class="screen-reader-text"><span><?php echo $other_comment_settings_title; ?></span></legend>
    7769<label for="require_name_email"><input type="checkbox" name="require_name_email" id="require_name_email" value="1" <?php checked( '1', get_option( 'require_name_email' ) ); ?> /> <?php _e( 'Comment author must fill out name and email' ); ?></label>
    7870<br />
     
    130122</tr>
    131123
    132 <tr>
    133 <th scope="row"><?php _e( 'Comment Pagination' ); ?></th>
    134 <td><fieldset><legend class="screen-reader-text"><span>
    135     <?php
    136     /* translators: Hidden accessibility text. */
    137     _e( 'Comment Pagination' );
    138     ?>
    139 </span></legend>
     124<?php $comment_pagination_title = __( 'Comment Pagination' ); ?>
     125<tr>
     126<th scope="row"><?php echo $comment_pagination_title; ?></th>
     127<td><fieldset><legend class="screen-reader-text"><span><?php echo $comment_pagination_title; ?></span></legend>
    140128<input name="page_comments" type="checkbox" id="page_comments" value="1" <?php checked( '1', get_option( 'page_comments' ) ); ?> />
    141129<label for="page_comments"><?php _e( 'Break comments into pages' ); ?></label>
     
    162150</fieldset></td>
    163151</tr>
    164 <tr>
    165 <th scope="row"><?php _e( 'Email me whenever' ); ?></th>
    166 <td><fieldset><legend class="screen-reader-text"><span>
    167     <?php
    168     /* translators: Hidden accessibility text. */
    169     _e( 'Email me whenever' );
    170     ?>
    171 </span></legend>
     152<?php $email_me_whenever_title = __( 'Email me whenever' ); ?>
     153<tr>
     154<th scope="row"><?php echo $email_me_whenever_title; ?></th>
     155<td><fieldset><legend class="screen-reader-text"><span><?php echo $email_me_whenever_title; ?></span></legend>
    172156<label for="comments_notify">
    173157<input name="comments_notify" type="checkbox" id="comments_notify" value="1" <?php checked( '1', get_option( 'comments_notify' ) ); ?> />
     
    179163</fieldset></td>
    180164</tr>
    181 <tr>
    182 <th scope="row"><?php _e( 'Before a comment appears' ); ?></th>
    183 <td><fieldset><legend class="screen-reader-text"><span>
    184     <?php
    185     /* translators: Hidden accessibility text. */
    186     _e( 'Before a comment appears' );
    187     ?>
    188 </span></legend>
     165<?php $before_comment_appears_title = __( 'Before a comment appears' ); ?>
     166<tr>
     167<th scope="row"><?php echo $before_comment_appears_title; ?></th>
     168<td><fieldset><legend class="screen-reader-text"><span><?php echo $before_comment_appears_title; ?></span></legend>
    189169<label for="comment_moderation">
    190170<input name="comment_moderation" type="checkbox" id="comment_moderation" value="1" <?php checked( '1', get_option( 'comment_moderation' ) ); ?> />
     
    194174</fieldset></td>
    195175</tr>
    196 <tr>
    197 <th scope="row"><?php _e( 'Comment Moderation' ); ?></th>
    198 <td><fieldset><legend class="screen-reader-text"><span>
    199     <?php
    200     /* translators: Hidden accessibility text. */
    201     _e( 'Comment Moderation' );
    202     ?>
    203 </span></legend>
     176<?php $comment_moderation_title = __( 'Comment Moderation' ); ?>
     177<tr>
     178<th scope="row"><?php echo $comment_moderation_title; ?></th>
     179<td><fieldset><legend class="screen-reader-text"><span><?php echo $comment_moderation_title; ?></span></legend>
    204180<p><label for="comment_max_links">
    205181<?php
     
    218194</fieldset></td>
    219195</tr>
    220 <tr>
    221 <th scope="row"><?php _e( 'Disallowed Comment Keys' ); ?></th>
    222 <td><fieldset><legend class="screen-reader-text"><span>
    223     <?php
    224     /* translators: Hidden accessibility text. */
    225     _e( 'Disallowed Comment Keys' );
    226     ?>
    227 </span></legend>
     196<?php $disallowed_comment_keys_title = __( 'Disallowed Comment Keys' ); ?>
     197<tr>
     198<th scope="row"><?php echo $disallowed_comment_keys_title; ?></th>
     199<td><fieldset><legend class="screen-reader-text"><span><?php echo $disallowed_comment_keys_title; ?></span></legend>
    228200<p><label for="disallowed_keys"><?php _e( 'When a comment contains any of these words in its content, author name, URL, email, IP address, or browser&#8217;s user agent string, it will be put in the Trash. One word or IP address per line. It will match inside words, so &#8220;press&#8221; will match &#8220;WordPress&#8221;.' ); ?></label></p>
    229201<p>
     
    259231</td>
    260232</tr>
     233<?php $maximum_rating_title = __( 'Maximum Rating' ); ?>
    261234<tr class="avatar-settings<?php echo $show_avatars_class; ?>">
    262 <th scope="row"><?php _e( 'Maximum Rating' ); ?></th>
    263 <td><fieldset><legend class="screen-reader-text"><span>
    264     <?php
    265     /* translators: Hidden accessibility text. */
    266     _e( 'Maximum Rating' );
    267     ?>
    268 </span></legend>
     235<th scope="row"><?php echo $maximum_rating_title; ?></th>
     236<td><fieldset><legend class="screen-reader-text"><span><?php echo $maximum_rating_title; ?></span></legend>
    269237
    270238<?php
     
    287255</fieldset></td>
    288256</tr>
     257<?php $default_avatar_title = __( 'Default Avatar' ); ?>
    289258<tr class="avatar-settings<?php echo $show_avatars_class; ?>">
    290 <th scope="row"><?php _e( 'Default Avatar' ); ?></th>
    291 <td class="defaultavatarpicker"><fieldset><legend class="screen-reader-text"><span>
    292     <?php
    293     /* translators: Hidden accessibility text. */
    294     _e( 'Default Avatar' );
    295     ?>
    296 </span></legend>
     259<th scope="row"><?php echo $default_avatar_title; ?></th>
     260<td class="defaultavatarpicker"><fieldset><legend class="screen-reader-text"><span><?php echo $default_avatar_title; ?></span></legend>
    297261
    298262<p>
Note: See TracChangeset for help on using the changeset viewer.