[wp-trac] [WordPress Trac] #56389: Make wp_required_field_indicator and wp_required_field_message filterable

WordPress Trac noreply at wordpress.org
Tue Aug 16 17:18:36 UTC 2022


#56389: Make wp_required_field_indicator and wp_required_field_message filterable
-------------------------------------------------+-------------------------
 Reporter:  kebbet                               |       Owner:  audrasjb
     Type:  enhancement                          |      Status:  reviewing
 Priority:  normal                               |   Milestone:  6.1
Component:  General                              |     Version:  trunk
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch needs-dev-note needs-      |     Focuses:
  unit-tests                                     |
-------------------------------------------------+-------------------------

Comment (by sabernhardt):

 Sample functions to test these filters:

 1. Remove `aria-hidden` attribute, if it stays in Core (see #55717):

 {{{
 add_filter( 'wp_required_field_indicator',
 'wptrac_remove_aria_hidden_indicator', 10, 1 );
 function wptrac_remove_aria_hidden_indicator( $indicator ) {
         $indicator = str_replace( ' aria-hidden="true"', '', $indicator );
         return $indicator;
 }

 add_filter( 'wp_required_field_message',
 'wptrac_remove_aria_hidden_message', 10, 1 );
 function wptrac_remove_aria_hidden_message( $message ) {
         $message = str_replace( ' aria-hidden="true"', '', $message );
         return $message;
 }
 }}}

 2. Use a non-breaking space before the indicator in the message so it does
 not wrap to the next line on its own.

 {{{
 add_filter( 'wp_required_field_message',
 'wptrac_required_fields_use_nonbreaking_space', 10, 1 );
 function wptrac_required_fields_use_nonbreaking_space( $message ) {
         $message = str_replace( ' <span class="required"', ' <span
 class="required"', $message );
         return $message;
 }
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/56389#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list