diff --git a/wp-includes/class-wp-widget.php b/wp-includes/class-wp-widget.php index 114328d499..0681d3715c 100644 --- a/wp-includes/class-wp-widget.php +++ b/wp-includes/class-wp-widget.php @@ -177,11 +177,17 @@ class WP_Widget { * * This function should be used in form() methods to create name attributes for fields to be saved by update() * + * @since 4.4.0 Array format field names are now accepted. + * * @param string $field_name Field name * @return string Name attribute for $field_name */ public function get_field_name($field_name) { - return 'widget-' . $this->id_base . '[' . $this->number . '][' . $field_name . ']'; + if ( false === $pos = strpos( $field_name, '[' ) ) { + return 'widget-' . $this->id_base . '[' . $this->number . '][' . $field_name . ']'; + } else { + return 'widget-' . $this->id_base . '[' . $this->number . '][' . substr_replace( $field_name, '][', $pos, strlen( '[' ) ); + } } /** @@ -190,6 +196,8 @@ class WP_Widget { * This function should be used in form() methods to create id attributes * for fields to be saved by {@see WP_Widget::update()}. * + * @since 4.4.0 Array format field IDs are now accepted. + * * @since 2.8.0 * @access public * @@ -197,7 +205,7 @@ class WP_Widget { * @return string ID attribute for `$field_name`. */ public function get_field_id( $field_name ) { - return 'widget-' . $this->id_base . '-' . $this->number . '-' . $field_name; + return 'widget-' . $this->id_base . '-' . $this->number . '-' . trim( str_replace( array( '[]', '[', ']' ), array( '', '-', '' ), $field_name ), '-' ); } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index e4208aeaba..df49039b63 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-alpha-34779'; +$wp_version = '4.4-alpha-34780'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.