[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 12:09:12 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          |  Resolution:
 Keywords:                  |     Focuses:
----------------------------+------------------------------

Comment (by bassjobsen):

 For multidimensional arrays some recursion will be needed too:


 {{{
  function with_recursion($value,$string)
 {
         foreach($value as $key=>$value) {
                                 if(is_array($value))
 {with_recursion($value, $string . '[' . $key . ']');}
                                 else
                                 {
                                 echo $string.'[' . $key . ']" value="' .
 $value  . '" />';
                             }
     }
 }
 foreach ( (array) $extra_fields as $field ) {
         if ( isset( $_POST[ $field ] ) )
         {

                 if(is_array($_POST[ $field ]))
                 {
                         foreach($_POST[ $field ] as $key=>$value)
                         {

                                 if(is_array($value))
 {with_recursion($value, '<input type="text" name="' . esc_attr($field).
 '[' . esc_attr($key). ']');}
                                 else
                                 {
                                 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#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list