Make WordPress Core

Ticket #54394: 54394.patch

File 54394.patch, 2.3 KB (added by sabernhardt, 5 years ago)

basic concept

  • src/wp-includes/functions.php

     
    83328332function wp_fuzzy_number_match( $expected, $actual, $precision = 1 ) {
    83338333        return abs( (float) $expected - (float) $actual ) <= $precision;
    83348334}
     8335
     8336/**
     8337 * Assign a visual indicator for required form fields.
     8338 *
     8339 * @since 6.0.0
     8340 *
     8341 * @param string $space_before Space character, entity or empty string to add before glyph. Default ' '.
     8342 * @return string Indicator glyph wrapped in a `span` tag.
     8343 */
     8344function get_required_field_indicator( $space_before = ' ' ) {
     8345        $required_glyph     = __( '*' ); // Can be filtered, too (#23870).
     8346        $required_indicator = sprintf(
     8347                '%1$s<span class="required" aria-hidden="true">%2$s</span>',
     8348                esc_html( $space_before ),
     8349                esc_html( $required_glyph ),
     8350        );
     8351
     8352        return $required_indicator;
     8353}
     8354
     8355/**
     8356 * Display the visual indicator for a required form field.
     8357 *
     8358 * @since 6.0.0
     8359 *
     8360 * @param string $space_before Space character, entity or empty string to add before glyph. Default ' '.
     8361 */
     8362function the_required_field_indicator( $space_before = ' ' ) {
     8363        echo get_required_field_indicator( $space_before );
     8364}
     8365
     8366/**
     8367 * Create a message to explain required form fields.
     8368 *
     8369 * @since 6.0.0
     8370 *
     8371 * @param string $space_before Space character, entity or empty string to add before glyph. Default ' '.
     8372 * @return string Message text and glyph wrapped in a `span` tag.
     8373 */
     8374function get_required_field_message( $space_before = ' ' ) {
     8375        $required_indicator     = get_required_field_indicator( '' );
     8376        $required_field_message = sprintf(
     8377                '%1$s<span class="required-field-message" aria-hidden="true">%2$s</span>',
     8378                esc_html( $space_before ),
     8379                /* translators: %s: Asterisk symbol (*). */
     8380                sprintf( __( 'Required fields are marked %s' ), $required_indicator ),
     8381        );
     8382
     8383        return $required_field_message;
     8384}
     8385
     8386/**
     8387 * Display the message that explains required form fields.
     8388 *
     8389 * @since 6.0.0
     8390 *
     8391 * @param string $space_before Space character, entity or empty string to add before glyph. Default ' '.
     8392 */
     8393function the_required_field_message( $space_before = ' ' ) {
     8394        echo get_required_field_message( $space_before );
     8395}