Constructs name attributes for use in form() fields
This function should be used in form() methods to create name attributes for fields to be saved by update()
(string) (Required) Field name
(string) Name attribute for $field_name
File: wp-includes/class-wp-widget.php
public function get_field_name( $field_name ) { $pos = strpos( $field_name, '[' ); if ( false === $pos ) { return 'widget-' . $this->id_base . '[' . $this->number . '][' . $field_name . ']'; } else { return 'widget-' . $this->id_base . '[' . $this->number . '][' . substr_replace( $field_name, '][', $pos, strlen( '[' ) ); } }
Version | Description |
---|---|
4.4.0 | Array format field names are now accepted. |
2.8.0 | Introduced. |
© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_widget/get_field_name