Constructs id attributes for use in WP_Widget::form() fields.
This function should be used in form() methods to create id attributes for fields to be saved by WP_Widget::update().
$field_namestringrequired
$field_name.public function get_field_id( $field_name ) {
$field_name = str_replace( array( '[]', '[', ']' ), array( '', '-', '' ), $field_name );
$field_name = trim( $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_id