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()
$field_namestringrequired
$field_name.public function get_field_name( $field_name ) {
$pos = strpos( $field_name, '[' );
if ( false !== $pos ) {
// Replace the first occurrence of '[' with ']['.
$field_name = '[' . substr_replace( $field_name, '][', $pos, strlen( '[' ) );
} else {
$field_name = '[' . $field_name . ']';
}
return 'widget-' . $this->id_base . '[' . $this->number . ']' . $field_name;
}
© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_widget/get_field_name