Ticket #35023: get_field_name.patch
File get_field_name.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) {186 public function get_field_name( $field_name ) { 187 187 if ( false === $pos = strpos( $field_name, '[' ) ) { 188 188 return 'widget-' . $this->id_base . '[' . $this->number . '][' . $field_name . ']'; 189 189 } else { 190 return 'widget-' . $this->id_base . '[' . $this->number . '][' . substr_replace( $field_name, '][', $pos, strlen( '[' ) ); 190 191 $id = 'widget-' . $this->id_base . '[' . $this->number . '][' . substr_replace( $field_name, '][', $pos, strlen( '[' ) ); 192 193 if ( ( strlen( $id ) - 1 ) !== strrpos( $id, ']' ) ) { 194 $id = $id . ']'; 195 } 196 $id = str_replace( ']]', ']', $id ); 197 return $id; 191 198 } 192 199 } 193 200 -
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 ), 354 358 ); 355 359 } 356 360