Make WordPress Core

Ticket #12133: 12133.2.diff

File 12133.2.diff, 1.1 KB (added by welcher, 8 years ago)
  • src/wp-includes/class-wp-widget.php

     
    181181         * @return string Name attribute for $field_name
    182182         */
    183183        public function get_field_name($field_name) {
    184                 return 'widget-' . $this->id_base . '[' . $this->number . '][' . $field_name . ']';
     184                if ( false === $pos = strpos( $field_name, '[' ) ) {
     185                        return 'widget-' . $this->id_base . '[' . $this->number . '][' . $field_name . ']';
     186                } else {
     187                        return 'widget-' . $this->id_base . '[' . $this->number . '][' . substr_replace( $field_name, '][', $pos, strlen( '[' ) );
     188                }
    185189        }
    186190
    187191        /**
     
    197201         * @return string ID attribute for `$field_name`.
    198202         */
    199203        public function get_field_id( $field_name ) {
    200                 return 'widget-' . $this->id_base . '-' . $this->number . '-' . $field_name;
     204                return 'widget-' . $this->id_base . '-' . $this->number . '-' . trim( str_replace( array( '[]', '[', ']' ), array( '', '-', '' ), $field_name ), '-' );
    201205        }
    202206
    203207        /**