Ticket #54394: 53494.2.patch
| File 53494.2.patch, 4.3 KB (added by , 5 years ago) |
|---|
-
src/wp-includes/comment-template.php
2357 2357 $required_attribute = ( $html5 ? ' required' : ' required="required"' ); 2358 2358 $checked_attribute = ( $html5 ? ' checked' : ' checked="checked"' ); 2359 2359 2360 // Identify required fields visually.2361 $required_indicator = ' <span class="required" aria-hidden="true">*</span>';2362 2363 2360 $fields = array( 2364 2361 'author' => sprintf( 2365 2362 '<p class="comment-form-author">%s %s</p>', … … 2366 2363 sprintf( 2367 2364 '<label for="author">%s%s</label>', 2368 2365 __( 'Name' ), 2369 ( $req ? $required_indicator: '' )2366 ( $req ? wp_required_field_indicator() : '' ) 2370 2367 ), 2371 2368 sprintf( 2372 2369 '<input id="author" name="author" type="text" value="%s" size="30" maxlength="245"%s />', … … 2379 2376 sprintf( 2380 2377 '<label for="email">%s%s</label>', 2381 2378 __( 'Email' ), 2382 ( $req ? $required_indicator: '' )2379 ( $req ? wp_required_field_indicator() : '' ) 2383 2380 ), 2384 2381 sprintf( 2385 2382 '<input id="email" name="email" %s value="%s" size="30" maxlength="100" aria-describedby="email-notes"%s />', … … 2423 2420 } 2424 2421 } 2425 2422 2426 $required_text = sprintf(2427 /* translators: %s: Asterisk symbol (*). */2428 ' <span class="comment-required-message" aria-hidden="true">' . __( 'Required fields are marked %s' ) . '</span>',2429 trim( $required_indicator )2430 );2431 2432 2423 /** 2433 2424 * Filters the default comment form fields. 2434 2425 * … … 2445 2436 sprintf( 2446 2437 '<label for="comment">%s%s</label>', 2447 2438 _x( 'Comment', 'noun' ), 2448 $required_indicator2439 wp_required_field_indicator() 2449 2440 ), 2450 2441 '<textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525"' . $required_attribute . '></textarea>' 2451 2442 ), … … 2470 2461 /** This filter is documented in wp-includes/link-template.php */ 2471 2462 wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ), $post_id ) ) 2472 2463 ), 2473 $required_text2464 wp_required_field_message() 2474 2465 ), 2475 2466 'comment_notes_before' => sprintf( 2476 2467 '<p class="comment-notes">%s%s</p>', … … 2478 2469 '<span id="email-notes">%s</span>', 2479 2470 __( 'Your email address will not be published.' ) 2480 2471 ), 2481 $required_text2472 wp_required_field_message() 2482 2473 ), 2483 2474 'comment_notes_after' => '', 2484 2475 'action' => site_url( '/wp-comments-post.php' ), -
src/wp-includes/functions.php
8328 8328 function wp_fuzzy_number_match( $expected, $actual, $precision = 1 ) { 8329 8329 return abs( (float) $expected - (float) $actual ) <= $precision; 8330 8330 } 8331 8332 /** 8333 * Assign a visual indicator for required form fields. 8334 * 8335 * @since 6.0.0 8336 * 8337 * @param string $space_before Space character, entity or empty string to add before glyph. Default ' '. 8338 * @param bool $echo Whether to output the result or instead return it. Default false. 8339 * @return string Indicator glyph wrapped in a `span` tag. 8340 */ 8341 function wp_required_field_indicator( $space_before = ' ', $echo = false ) { 8342 /* translators: Character to identify required form fields. */ 8343 $glyph = __( '*' ); // Can be filtered, too (see #23870). 8344 $indicator = sprintf( 8345 '%1$s<span class="required" aria-hidden="true">%2$s</span>', 8346 esc_html( $space_before ), 8347 esc_html( $glyph ), 8348 ); 8349 8350 if ( ! $echo ) { 8351 return $indicator; 8352 } 8353 echo $indicator; 8354 } 8355 8356 /** 8357 * Create a message to explain required form fields. 8358 * 8359 * @since 6.0.0 8360 * 8361 * @param string $space_before Space character, entity or empty string to add before glyph. Default ' '. 8362 * @param bool $echo Whether to output the result or instead return it. Default false. 8363 * @return string Message text and glyph wrapped in a `span` tag. 8364 */ 8365 function wp_required_field_message( $space_before = ' ', $echo = false ) { 8366 $message = sprintf( 8367 '%1$s<span class="required-field-message" aria-hidden="true">%2$s</span>', 8368 esc_html( $space_before ), 8369 /* translators: %s: Asterisk symbol (*). */ 8370 sprintf( __( 'Required fields are marked %s' ), wp_required_field_indicator( '' ) ), 8371 ); 8372 8373 if ( ! $echo ) { 8374 return $message; 8375 } 8376 echo $message; 8377 }