Make WordPress Core


Ignore:
Timestamp:
08/12/2022 12:09:10 PM (21 months ago)
Author:
audrasjb
Message:

General: Add required fields helper functions for better reusability.

This changeset introduces new wp_required_field_indicator() and wp_required_field_message() helper functions to generate reusable and consistent required field indicator and message. It also implements these functions in various admin screens.

Props sabernhardt, ryokuhi, joedolson, audrasjb, SergeyBiryukov.
Fixes #54394.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/comment-template.php

    r53796 r53888  
    23552355    $checked_attribute  = ( $html5 ? ' checked' : ' checked="checked"' );
    23562356
    2357     // Identify required fields visually.
    2358     $required_indicator = ' <span class="required" aria-hidden="true">*</span>';
     2357    // Identify required fields visually and create a message about the indicator.
     2358    $required_indicator = ' ' . wp_required_field_indicator();
     2359    $required_text      = ' ' . wp_required_field_message();
    23592360
    23602361    $fields = array(
     
    24202421        }
    24212422    }
    2422 
    2423     $required_text = sprintf(
    2424         /* translators: %s: Asterisk symbol (*). */
    2425         ' <span class="required-field-message" aria-hidden="true">' . __( 'Required fields are marked %s' ) . '</span>',
    2426         trim( $required_indicator )
    2427     );
    24282423
    24292424    /**
Note: See TracChangeset for help on using the changeset viewer.