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-admin/network/site-new.php

    r52978 r53888  
    194194}
    195195?>
    196 <p>
    197 <?php
    198 printf(
    199     /* translators: %s: Asterisk symbol (*). */
    200     __( 'Required fields are marked %s' ),
    201     '<span class="required">*</span>'
    202 );
    203 ?>
    204 </p>
     196<p><?php echo wp_required_field_message(); ?></p>
    205197<form method="post" action="<?php echo esc_url( network_admin_url( 'site-new.php?action=add-site' ) ); ?>" novalidate="novalidate">
    206198<?php wp_nonce_field( 'add-blog', '_wpnonce_add-blog' ); ?>
    207199    <table class="form-table" role="presentation">
    208200        <tr class="form-field form-required">
    209             <th scope="row"><label for="site-address"><?php _e( 'Site Address (URL)' ); ?> <span class="required">*</span></label></th>
     201            <th scope="row">
     202                <label for="site-address">
     203                    <?php
     204                    _e( 'Site Address (URL)' );
     205                    echo ' ' . wp_required_field_indicator();
     206                    ?>
     207                </label>
     208            </th>
    210209            <td>
    211210            <?php if ( is_subdomain_install() ) { ?>
     
    223222        </tr>
    224223        <tr class="form-field form-required">
    225             <th scope="row"><label for="site-title"><?php _e( 'Site Title' ); ?> <span class="required">*</span></label></th>
     224            <th scope="row">
     225                <label for="site-title">
     226                    <?php
     227                    _e( 'Site Title' );
     228                    echo ' ' . wp_required_field_indicator();
     229                    ?>
     230                </label>
     231            </th>
    226232            <td><input name="blog[title]" type="text" class="regular-text" id="site-title" required /></td>
    227233        </tr>
     
    258264        <?php endif; // Languages. ?>
    259265        <tr class="form-field form-required">
    260             <th scope="row"><label for="admin-email"><?php _e( 'Admin Email' ); ?> <span class="required">*</span></label></th>
     266            <th scope="row">
     267                <label for="admin-email">
     268                    <?php
     269                    _e( 'Admin Email' );
     270                    echo ' ' . wp_required_field_indicator();
     271                    ?>
     272                </label>
     273            </th>
    261274            <td><input name="blog[email]" type="email" class="regular-text wp-suggest-user" id="admin-email" data-autocomplete-type="search" data-autocomplete-field="user_email" aria-describedby="site-admin-email" required /></td>
    262275        </tr>
Note: See TracChangeset for help on using the changeset viewer.