[wp-trac] [WordPress Trac] #28207: $extra_fields of request_filesystem_credentials does not accept array's

WordPress Trac noreply at wordpress.org
Sun May 11 04:59:35 UTC 2014


#28207: $extra_fields of  request_filesystem_credentials does not accept array's
----------------------------+-----------------------------
 Reporter:  bassjobsen      |      Owner:
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Filesystem API  |    Version:  3.9.1
 Severity:  normal          |   Keywords:
  Focuses:                  |
----------------------------+-----------------------------
 If my form for instance contains:


 {{{
 <input type="text" name="test[]">
 <input type="text" name="test[]">
 }}}

 i can not add `test` to $extra_fields

 possible solution:


 {{{
 /*foreach ( (array) $extra_fields as $field ) {
         if ( isset( $_POST[ $field ] ) )
                 echo '<input type="hidden" name="' . esc_attr( $field ) .
 '" value="' . esc_attr( wp_unslash( $_POST[ $field ] ) ) . '" />';
 }*/
 foreach ( (array) $extra_fields as $field ) {
         if ( isset( $_POST[ $field ] ) )
         {

                 if(is_array($_POST[ $field ]))
                 {
                         foreach($_POST[ $field ] as $key=>$value)
                         {
                                 echo '<input type="hidden" name="' .
 esc_attr( $field ) . '[' .esc_attr( $key ). ']" value="' . esc_attr(
 wp_unslash(  $value ) ) . '" />';
                         }
                 }
                 else
                 {
                 echo '<input type="hidden" name="' . esc_attr( $field ) .
 '" value="' . esc_attr( wp_unslash( $_POST[ $field ] ) ) . '" />';
                 }
         }
 }
 }}}

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


More information about the wp-trac mailing list