wp_required_field_indicator example

/** * Creates a message to explain required form fields. * * @since 6.1.0 * * @return string Message text and glyph wrapped in a `span` tag. */
function wp_required_field_message() {
    $message = sprintf(
        '<span class="required-field-message">%s</span>',
        /* translators: %s: Asterisk symbol (*). */
        sprintf( __( 'Required fields are marked %s' )wp_required_field_indicator() )
    );

    /** * Filters the message to explain required form fields. * * @since 6.1.0 * * @param string $message Message text and glyph wrapped in a `span` tag. */
    return apply_filters( 'wp_required_field_message', $message );
}

<?php         foreach ( $add_user_errors->get_error_messages() as $error ) {
            echo "<p>$error</p>";
        }
        ?> </div> <?php } ?> <form action="<?php echo esc_url( network_admin_url( 'user-new.php?action=add-user' ) ); ?>" id="adduser" method="post" novalidate="novalidate"> <p><?php echo wp_required_field_message(); ?></p> <table class="form-table" role="presentation"> <tr class="form-field form-required"> <th scope="row"><label for="username"><?php _e( 'Username' ); ?> <?php echo wp_required_field_indicator(); ?></label></th> <td><input type="text" class="regular-text" name="user[username]" id="username" autocapitalize="none" autocorrect="off" maxlength="60" required="required" /></td> </tr> <tr class="form-field form-required"> <th scope="row"><label for="email"><?php _e( 'Email' ); ?> <?php echo wp_required_field_indicator(); ?></label></th> <td><input type="email" class="regular-text" name="user[email]" id="email" required="required" /></td> </tr> <tr class="form-field"> <td colspan="2" class="td-full"><?php _e( 'A password reset link will be sent to the user via email.' ); ?></td> </tr> </table> <?php
$args['format'] = current_theme_supports( 'html5', 'comment-form' ) ? 'html5' : 'xhtml';
    }

    $req   = get_option( 'require_name_email' );
    $html5 = 'html5' === $args['format'];

    // Define attributes in HTML5 or XHTML syntax.     $required_attribute = ( $html5 ? ' required' : ' required="required"' );
    $checked_attribute  = ( $html5 ? ' checked' : ' checked="checked"' );

    // Identify required fields visually and create a message about the indicator.     $required_indicator = ' ' . wp_required_field_indicator();
    $required_text      = ' ' . wp_required_field_message();

    $fields = array(
        'author' => sprintf(
            '<p class="comment-form-author">%s %s</p>',
            sprintf(
                '<label for="author">%s%s</label>',
                __( 'Name' ),
                ( $req ? $required_indicator : '' )
            ),
            sprintf(
                

?> <p><?php echo wp_required_field_message(); ?></p> <form method="post" action="<?php echo esc_url( network_admin_url( 'site-new.php?action=add-site' ) ); ?>" novalidate="novalidate"> <?php wp_nonce_field( 'add-blog', '_wpnonce_add-blog' ); ?> <table class="form-table" role="presentation"> <tr class="form-field form-required"> <th scope="row"> <label for="site-address"> <?php                     _e( 'Site Address (URL)' );
                    echo ' ' . wp_required_field_indicator();
                    ?> </label> </th> <td> <?php if ( is_subdomain_install() ) { ?> <input name="blog[domain]" type="text" class="regular-text ltr" id="site-address" aria-describedby="site-address-desc" autocapitalize="none" autocorrect="off" required /><span class="no-break">.<?php echo preg_replace( '|^www\.|', '', get_network()->domain ); ?></span> <?php             } else {
                echo get_network()->domain . get_network()->path
                ?> <input name="blog[domain]" type="text" class="regular-text ltr" id="site-address" aria-describedby="site-address-desc" autocapitalize="none" autocorrect="off" required />
continue;
        }

        $field = array_merge( $defaults$field );
        $name  = "attachments[$attachment_id][$id]";

        if ( 'hidden' === $field['input'] ) {
            $hidden_fields[ $name ] = $field['value'];
            continue;
        }

        $required      = $field['required'] ? ' ' . wp_required_field_indicator() : '';
        $required_attr = $field['required'] ? ' required' : '';
        $class         = $id;
        $class        .= $field['required'] ? ' form-required' : '';

        $item .= "\t\t<tr class='$class'>\n\t\t\t<th scope='row' class='label'><label for='$name'><span class='alignleft'>{$field['label']}{$required}</span><br class='clear' /></label></th>\n\t\t\t<td class='field'>";

        if ( ! empty( $field[ $field['input'] ] ) ) {
            $item .= $field[ $field['input'] ];
        } elseif ( 'textarea' === $field['input'] ) {
            if ( 'post_content' === $id && user_can_richedit() ) {
                // Sanitize_post() skips the post_content when user_can_richedit.
Home | Imprint | This part of the site doesn't use cookies.