Make WordPress Core

Ticket #12133: 12133.diff

File 12133.diff, 1.1 KB (added by welcher, 9 years ago)

Refreshing patch

  • 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 === strpos( $field_name, '[' ) ) {
     185                        return 'widget-' . $this->id_base . '[' . $this->number . '][' . ($field_name) . ']';
     186                } else {
     187                        return 'widget-' . $this->id_base . '[' . $this->number . '][' . substr( $field_name, 0, strpos( $field_name, '[' ) ) . ']';
     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 . '-' . str_replace( array( '][', '[', ']', ' ' ), '-', trim( $field_name, ' []' ) );
    201205        }
    202206
    203207        /**