Make WordPress Core


Ignore:
Timestamp:
09/28/2025 10:36:30 PM (3 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/includes/class-custom-background.php

    r59813 r60805  
    378378
    379379            <?php
     380            $background_position_title = __( 'Image Position' );
     381
    380382            $background_position = sprintf(
    381383                '%s %s',
     
    430432            ?>
    431433<tr>
    432 <th scope="row"><?php _e( 'Image Position' ); ?></th>
    433 <td><fieldset><legend class="screen-reader-text"><span>
    434             <?php
    435             /* translators: Hidden accessibility text. */
    436             _e( 'Image Position' );
    437             ?>
    438 </span></legend>
     434<th scope="row"><?php echo $background_position_title; ?></th>
     435<td><fieldset><legend class="screen-reader-text"><span><?php echo $background_position_title; ?></span></legend>
    439436<div class="background-position-control">
    440437            <?php foreach ( $background_position_options as $group ) : ?>
     
    453450</tr>
    454451
    455 <tr>
    456 <th scope="row"><label for="background-size"><?php _e( 'Image Size' ); ?></label></th>
    457 <td><fieldset><legend class="screen-reader-text"><span>
    458             <?php
    459             /* translators: Hidden accessibility text. */
    460             _e( 'Image Size' );
    461             ?>
    462 </span></legend>
     452            <?php $image_size_title = __( 'Image Size' ); ?>
     453<tr>
     454<th scope="row"><label for="background-size"><?php echo $image_size_title; ?></label></th>
     455<td><fieldset><legend class="screen-reader-text"><span><?php echo $image_size_title; ?></span></legend>
    463456<select id="background-size" name="background-size">
    464457<option value="auto"<?php selected( 'auto', get_theme_mod( 'background_size', get_theme_support( 'custom-background', 'default-size' ) ) ); ?>><?php _ex( 'Original', 'Original Size' ); ?></option>
     
    469462</tr>
    470463
    471 <tr>
    472 <th scope="row"><?php _ex( 'Repeat', 'Background Repeat' ); ?></th>
    473 <td><fieldset><legend class="screen-reader-text"><span>
    474             <?php
    475             /* translators: Hidden accessibility text. */
    476             _ex( 'Repeat', 'Background Repeat' );
    477             ?>
    478 </span></legend>
     464            <?php $background_repeat_title = _x( 'Repeat', 'Background Repeat' ); ?>
     465<tr>
     466<th scope="row"><?php echo $background_repeat_title; ?></th>
     467<td><fieldset><legend class="screen-reader-text"><span><?php echo $background_repeat_title; ?></span></legend>
    479468<input name="background-repeat" type="hidden" value="no-repeat">
    480469<label><input type="checkbox" name="background-repeat" value="repeat"<?php checked( 'repeat', get_theme_mod( 'background_repeat', get_theme_support( 'custom-background', 'default-repeat' ) ) ); ?>> <?php _e( 'Repeat Background Image' ); ?></label>
     
    482471</tr>
    483472
    484 <tr>
    485 <th scope="row"><?php _ex( 'Scroll', 'Background Scroll' ); ?></th>
    486 <td><fieldset><legend class="screen-reader-text"><span>
    487             <?php
    488             /* translators: Hidden accessibility text. */
    489             _ex( 'Scroll', 'Background Scroll' );
    490             ?>
    491 </span></legend>
     473            <?php $background_scroll_title = _x( 'Scroll', 'Background Scroll' ); ?>
     474<tr>
     475<th scope="row"><?php echo $background_scroll_title; ?></th>
     476<td><fieldset><legend class="screen-reader-text"><span><?php echo $background_scroll_title; ?></span></legend>
    492477<input name="background-attachment" type="hidden" value="fixed">
    493478<label><input name="background-attachment" type="checkbox" value="scroll" <?php checked( 'scroll', get_theme_mod( 'background_attachment', get_theme_support( 'custom-background', 'default-attachment' ) ) ); ?>> <?php _e( 'Scroll with Page' ); ?></label>
     
    495480</tr>
    496481<?php endif; // get_background_image() ?>
    497 <tr>
    498 <th scope="row"><?php _e( 'Background Color' ); ?></th>
    499 <td><fieldset><legend class="screen-reader-text"><span>
    500         <?php
    501         /* translators: Hidden accessibility text. */
    502         _e( 'Background Color' );
    503         ?>
    504 </span></legend>
     482
     483        <?php $background_color_title = __( 'Background Color' ); ?>
     484<tr>
     485<th scope="row"><?php echo $background_color_title; ?></th>
     486<td><fieldset><legend class="screen-reader-text"><span><?php echo $background_color_title; ?></span></legend>
    505487        <?php
    506488        $default_color = '';
Note: See TracChangeset for help on using the changeset viewer.