WP_Customize_Widgets::get_setting_id() WordPress Method

The WP_Customize_Widgets::get_setting_id() method is used to retrieve the setting ID for a given widget. This is useful for creating custom controls for a widget.

WP_Customize_Widgets::get_setting_id( string $widget_id ) #

Converts a widget_id into its corresponding Customizer setting ID (option name).


Parameters

$widget_id

(string)(Required)Widget ID.


Top ↑

Return

(string) Maybe-parsed widget ID.


Top ↑

Source

File: wp-includes/class-wp-customize-widgets.php

	public function get_setting_id( $widget_id ) {
		$parsed_widget_id = $this->parse_widget_id( $widget_id );
		$setting_id       = sprintf( 'widget_%s', $parsed_widget_id['id_base'] );

		if ( ! is_null( $parsed_widget_id['number'] ) ) {
			$setting_id .= sprintf( '[%d]', $parsed_widget_id['number'] );
		}
		return $setting_id;
	}


Top ↑

Changelog

Changelog
VersionDescription
3.9.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More