Changeset 34780 for trunk/src/wp-includes/class-wp-widget.php
- Timestamp:
- 10/02/2015 08:23:54 PM (11 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/class-wp-widget.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-widget.php
r34560 r34780 178 178 * This function should be used in form() methods to create name attributes for fields to be saved by update() 179 179 * 180 * @since 4.4.0 Array format field names are now accepted. 181 * 180 182 * @param string $field_name Field name 181 183 * @return string Name attribute for $field_name 182 184 */ 183 185 public function get_field_name($field_name) { 184 return 'widget-' . $this->id_base . '[' . $this->number . '][' . $field_name . ']'; 186 if ( false === $pos = strpos( $field_name, '[' ) ) { 187 return 'widget-' . $this->id_base . '[' . $this->number . '][' . $field_name . ']'; 188 } else { 189 return 'widget-' . $this->id_base . '[' . $this->number . '][' . substr_replace( $field_name, '][', $pos, strlen( '[' ) ); 190 } 185 191 } 186 192 … … 191 197 * for fields to be saved by {@see WP_Widget::update()}. 192 198 * 199 * @since 4.4.0 Array format field IDs are now accepted. 200 * 193 201 * @since 2.8.0 194 202 * @access public … … 198 206 */ 199 207 public function get_field_id( $field_name ) { 200 return 'widget-' . $this->id_base . '-' . $this->number . '-' . $field_name;208 return 'widget-' . $this->id_base . '-' . $this->number . '-' . trim( str_replace( array( '[]', '[', ']' ), array( '', '-', '' ), $field_name ), '-' ); 201 209 } 202 210
Note: See TracChangeset
for help on using the changeset viewer.