Title: WP_Customize_Widgets::register_settings
Published: April 23, 2015
Last modified: April 28, 2025

---

# WP_Customize_Widgets::register_settings()

## In this article

 * [Source](https://developer.wordpress.org/reference/classes/wp_customize_widgets/register_settings/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_customize_widgets/register_settings/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_customize_widgets/register_settings/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_customize_widgets/register_settings/?output_format=md#wp--skip-link--target)

Inspects the incoming customized data for any widget settings, and dynamically adds
them up-front so widgets will be initialized properly.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_customize_widgets/register_settings/?output_format=md#source)󠁿

    ```php
    public function register_settings() {
    	$widget_setting_ids   = array();
    	$incoming_setting_ids = array_keys( $this->manager->unsanitized_post_values() );
    	foreach ( $incoming_setting_ids as $setting_id ) {
    		if ( ! is_null( $this->get_setting_type( $setting_id ) ) ) {
    			$widget_setting_ids[] = $setting_id;
    		}
    	}
    	if ( $this->manager->doing_ajax( 'update-widget' ) && isset( $_REQUEST['widget-id'] ) ) {
    		$widget_setting_ids[] = $this->get_setting_id( wp_unslash( $_REQUEST['widget-id'] ) );
    	}

    	$settings = $this->manager->add_dynamic_settings( array_unique( $widget_setting_ids ) );

    	if ( $this->manager->settings_previewed() ) {
    		foreach ( $settings as $setting ) {
    			$setting->preview();
    		}
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-customize-widgets.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/class-wp-customize-widgets.php#L200)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/class-wp-customize-widgets.php#L200-L219)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_customize_widgets/register_settings/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_Customize_Widgets::get_setting_type()](https://developer.wordpress.org/reference/classes/wp_customize_widgets/get_setting_type/)`wp-includes/class-wp-customize-widgets.php` |

Retrieves the widget setting type given a setting ID.

  | 
| [WP_Customize_Widgets::get_setting_id()](https://developer.wordpress.org/reference/classes/wp_customize_widgets/get_setting_id/)`wp-includes/class-wp-customize-widgets.php` |

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

  | 
| [wp_unslash()](https://developer.wordpress.org/reference/functions/wp_unslash/)`wp-includes/formatting.php` |

Removes slashes from a string or recursively removes slashes from strings within an array.

  |

[Show 1 more](https://developer.wordpress.org/reference/classes/wp_customize_widgets/register_settings/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_customize_widgets/register_settings/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_customize_widgets/register_settings/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.2.0](https://developer.wordpress.org/reference/since/4.2.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_customize_widgets%2Fregister_settings%2F)
before being able to contribute a note or feedback.