[wp-trac] [WordPress Trac] #54438: "Required fields are marked" shows up without required fields being present

WordPress Trac noreply at wordpress.org
Sat Nov 13 16:33:06 UTC 2021


#54438: "Required fields are marked" shows up without required fields being present
-------------------------+-----------------------------
 Reporter:  webzunft     |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  General      |    Version:  5.8.2
 Severity:  minor        |   Keywords:
  Focuses:  ui           |
-------------------------+-----------------------------
 A support ticket for my Image Source Control (ISC) plugin made me
 investigate this.

 https://wordpress.org/support/topic/erforderliche-felder-sind-mit-
 markiert/

 Whenever a custom field is added to the attachment edit page, the notice
 "Required fields are marked" is displayed by WordPress core.

 ISC uses the `attachment_fields_to_edit` filter for that.

 I looked into `wp-admin/includes/media.php`. The code responsible for
 showing the message is


 {{{
 if ( $item ) {
                 $item = '<p class="media-types media-types-required-
 info">' .
                         /* translators: %s: Asterisk symbol (*). */
                         sprintf( __( 'Required fields are marked %s' ),
 '<span class="required">*</span>' ) .
                         '</p>' .
                         '<table class="compat-attachment-fields">' . $item
 . '</table>';
         }
 }}}

 The foreach loop that goes through all fields could easily check if any
 field has the "required" attribute and rather use that as a condition to
 show the message instead of `$item`.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/54438>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list