WordPress.org

Make WordPress Core

Ticket #12133: patch.diff

File patch.diff, 1.1 KB (added by ch1902, 5 years ago)
  • wp-includes/widgets.php

     
    107107         * @return string Name attribute for $field_name
    108108         */
    109109        function get_field_name($field_name) {
    110                 return 'widget-' . $this->id_base . '[' . $this->number . '][' . $field_name . ']';
     110      if (strpos($field_name, '[') === false)
     111                   return 'widget-' . $this->id_base . '[' . $this->number . '][' . ($field_name) . ']';
     112      else
     113         return 'widget-' . $this->id_base . '[' . $this->number . '][' . substr($field_name, 0, strpos($field_name, '[')) . ']' . substr($field_name, strpos($field_name, '['));
    111114        }
    112115
    113116        /**
     
    119122         * @return string ID attribute for $field_name
    120123         */
    121124        function get_field_id($field_name) {
    122                 return 'widget-' . $this->id_base . '-' . $this->number . '-' . $field_name;
     125                return 'widget-' . $this->id_base . '-' . $this->number . '-' . str_replace(array('][', '[', ']', ' '), '-', trim($field_name, ' []'));
    123126        }
    124127
    125128        // Private Functions. Don't worry about these.