Make WordPress Core


Ignore:
Timestamp:
09/28/2025 10:36:30 PM (2 months 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-general.php

    r60645 r60805  
    290290</tr>
    291291
    292 <?php if ( ! is_multisite() ) { ?>
    293 
    294 <tr>
    295 <th scope="row"><?php _e( 'Membership' ); ?></th>
    296 <td> <fieldset><legend class="screen-reader-text"><span>
    297     <?php
    298     /* translators: Hidden accessibility text. */
    299     _e( 'Membership' );
    300     ?>
    301 </span></legend><label for="users_can_register">
     292<?php
     293if ( ! is_multisite() ) {
     294    $membership_title = __( 'Membership' );
     295    ?>
     296<tr>
     297<th scope="row"><?php echo $membership_title; ?></th>
     298<td><fieldset><legend class="screen-reader-text"><span><?php echo $membership_title; ?></span></legend><label for="users_can_register">
    302299<input name="users_can_register" type="checkbox" id="users_can_register" value="1" <?php checked( '1', get_option( 'users_can_register' ) ); ?> />
    303300    <?php _e( 'Anyone can register' ); ?></label>
     
    460457<?php endif; ?>
    461458</td>
    462 
    463 </tr>
    464 <tr>
    465 <th scope="row"><?php _e( 'Date Format' ); ?></th>
     459</tr>
     460
     461<?php $date_format_title = __( 'Date Format' ); ?>
     462<tr>
     463<th scope="row"><?php echo $date_format_title; ?></th>
    466464<td>
    467     <fieldset><legend class="screen-reader-text"><span>
    468         <?php
    469         /* translators: Hidden accessibility text. */
    470         _e( 'Date Format' );
    471         ?>
    472     </span></legend>
     465    <fieldset><legend class="screen-reader-text"><span><?php echo $date_format_title; ?></span></legend>
    473466<?php
    474467    /**
     
    512505</td>
    513506</tr>
    514 <tr>
    515 <th scope="row"><?php _e( 'Time Format' ); ?></th>
     507
     508<?php $time_format_title = __( 'Time Format' ); ?>
     509<tr>
     510<th scope="row"><?php echo $time_format_title; ?></th>
    516511<td>
    517     <fieldset><legend class="screen-reader-text"><span>
    518         <?php
    519         /* translators: Hidden accessibility text. */
    520         _e( 'Time Format' );
    521         ?>
    522     </span></legend>
     512    <fieldset><legend class="screen-reader-text"><span><?php echo $time_format_title; ?></span></legend>
    523513<?php
    524514    /**
Note: See TracChangeset for help on using the changeset viewer.