WP_Widget::get_field_id

Advertisement

Summery Summery

Constructs id attributes for use in WP_Widget::form() fields.

Syntax Syntax

WP_Widget::get_field_id( string $field_name )

Description Description

This function should be used in form() methods to create id attributes for fields to be saved by WP_Widget::update().

Parameters Parameters

$field_name

(Required) Field name.

Return Return

(string) ID attribute for $field_name.

Source Source

File: wp-includes/class-wp-widget.php

	public function get_field_id( $field_name ) {
		return 'widget-' . $this->id_base . '-' . $this->number . '-' . trim( str_replace( array( '[]', '[', ']' ), array( '', '-', '' ), $field_name ), '-' );
	}

Advertisement

Changelog Changelog

Changelog
Version Description
4.4.0 Array format field IDs are now accepted.
2.8.0 Introduced.

Advertisement

Leave a Reply