- public function setup_widget_addition_previews() {
- $is_customize_preview = false;
-
- if ( ! empty( $this->manager ) && ! is_admin() && 'on' === $this->get_post_value( 'wp_customize' ) ) {
- $is_customize_preview = check_ajax_referer( 'preview-customize_' . $this->manager->get_stylesheet(), 'nonce', false );
- }
-
- $is_ajax_widget_update = false;
- if ( $this->manager->doing_ajax() && 'update-widget' === $this->get_post_value( 'action' ) ) {
- $is_ajax_widget_update = check_ajax_referer( 'update-widget', 'nonce', false );
- }
-
- $is_ajax_customize_save = false;
- if ( $this->manager->doing_ajax() && 'customize_save' === $this->get_post_value( 'action' ) ) {
- $is_ajax_customize_save = check_ajax_referer( 'save-customize_' . $this->manager->get_stylesheet(), 'nonce', false );
- }
-
- $is_valid_request = ( $is_ajax_widget_update || $is_customize_preview || $is_ajax_customize_save );
- if ( ! $is_valid_request ) {
- return;
- }
-
- // Input from customizer preview.
- if ( isset( $_POST['customized'] ) ) {
- $this->_customized = json_decode( $this->get_post_value( 'customized' ), true );
- } else { // Input from ajax widget update request.
- $this->_customized = array();
- $id_base = $this->get_post_value( 'id_base' );
- $widget_number = $this->get_post_value( 'widget_number', false );
- $option_name = 'widget_' . $id_base;
- $this->_customized[ $option_name ] = array();
- if ( preg_match( '/^[0-9]+$/', $widget_number ) ) {
- $option_name .= '[' . $widget_number . ']';
- $this->_customized[ $option_name ][ $widget_number ] = array();
+ 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;