Ticket #35023: get_field_name_3.patch
File get_field_name_3.patch, 1.4 KB (added by , 9 years ago) |
---|
-
src/wp-includes/class-wp-widget.php
183 183 * @param string $field_name Field name 184 184 * @return string Name attribute for $field_name 185 185 */ 186 public function get_field_name( $field_name) {187 if ( false === $pos = strpos( $field_name, '[') ) {186 public function get_field_name( $field_name ) { 187 if ( ! preg_match( '/]$/', $field_name ) ) { 188 188 return 'widget-' . $this->id_base . '[' . $this->number . '][' . $field_name . ']'; 189 189 } else { 190 if ( false === $pos = strpos( $field_name, '[' ) ) { 191 return 'widget-' . $this->id_base . '[' . $this->number . '][' . $field_name; 192 } 190 193 return 'widget-' . $this->id_base . '[' . $this->number . '][' . substr_replace( $field_name, '][', $pos, strlen( '[' ) ); 191 194 } 192 195 } -
tests/phpunit/tests/widgets.php
351 351 'widget-foo[2][posttypes][4][][6]', 352 352 'posttypes[4][][6]', 353 353 ), 354 array( 355 'widget-foo[2][posttypes][name]', 356 'posttypes][name', 357 ), 358 array( 359 'widget-foo[2][][title]', 360 '[title]', 361 ), 362 array( 363 'widget-foo[2][title]', 364 'title]', 365 ), 354 366 ); 355 367 } 356 368