Title: WP_Customize_Manager::unsanitized_post_values
Published: April 23, 2015
Last modified: February 24, 2026

---

# WP_Customize_Manager::unsanitized_post_values( array $args = array() ): array

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_customize_manager/unsanitized_post_values/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/classes/wp_customize_manager/unsanitized_post_values/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_customize_manager/unsanitized_post_values/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_customize_manager/unsanitized_post_values/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_customize_manager/unsanitized_post_values/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_customize_manager/unsanitized_post_values/?output_format=md#changelog)

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

Gets dirty pre-sanitized setting values in the current customized state.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wp_customize_manager/unsanitized_post_values/?output_format=md#description)󠁿

The returned array consists of a merge of three sources:

 1. If the theme is not currently active, then the base array is any stashed theme 
    mods that were modified previously but never published.
 2. The values from the current changeset, if it exists.
 3. If the user can customize, the values parsed from the incoming `$_POST['customized']`
    JSON data.
 4. Any programmatically-set post values via `WP_Customize_Manager::set_post_value()`.

The name “unsanitized_post_values” is a carry-over from when the customized state
was exclusively sourced from `$_POST['customized']`. Nevertheless, the value returned
will come from the current changeset post and from the incoming post data.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_customize_manager/unsanitized_post_values/?output_format=md#parameters)󠁿

 `$args`arrayoptional

Args.

 * `exclude_changeset` bool
 * Whether the changeset values should also be excluded. Defaults to false.
 * `exclude_post_data` bool
 * Whether the post input values should also be excluded. Defaults to false when
   lacking the customize capability.

Default:`array()`

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_customize_manager/unsanitized_post_values/?output_format=md#return)󠁿

 array

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

    ```php
    public function unsanitized_post_values( $args = array() ) {
    	$args = array_merge(
    		array(
    			'exclude_changeset' => false,
    			'exclude_post_data' => ! current_user_can( 'customize' ),
    		),
    		$args
    	);

    	$values = array();

    	// Let default values be from the stashed theme mods if doing a theme switch and if no changeset is present.
    	if ( ! $this->is_theme_active() ) {
    		$stashed_theme_mods = get_option( 'customize_stashed_theme_mods' );
    		$stylesheet         = $this->get_stylesheet();
    		if ( isset( $stashed_theme_mods[ $stylesheet ] ) ) {
    			$values = array_merge( $values, wp_list_pluck( $stashed_theme_mods[ $stylesheet ], 'value' ) );
    		}
    	}

    	if ( ! $args['exclude_changeset'] ) {
    		foreach ( $this->changeset_data() as $setting_id => $setting_params ) {
    			if ( ! array_key_exists( 'value', $setting_params ) ) {
    				continue;
    			}
    			if ( isset( $setting_params['type'] ) && 'theme_mod' === $setting_params['type'] ) {

    				// Ensure that theme mods values are only used if they were saved under the active theme.
    				$namespace_pattern = '/^(?P<stylesheet>.+?)::(?P<setting_id>.+)$/';
    				if ( preg_match( $namespace_pattern, $setting_id, $matches ) && $this->get_stylesheet() === $matches['stylesheet'] ) {
    					$values[ $matches['setting_id'] ] = $setting_params['value'];
    				}
    			} else {
    				$values[ $setting_id ] = $setting_params['value'];
    			}
    		}
    	}

    	if ( ! $args['exclude_post_data'] ) {
    		if ( ! isset( $this->_post_values ) ) {
    			if ( isset( $_POST['customized'] ) ) {
    				$post_values = json_decode( wp_unslash( $_POST['customized'] ), true );
    			} else {
    				$post_values = array();
    			}
    			if ( is_array( $post_values ) ) {
    				$this->_post_values = $post_values;
    			} else {
    				$this->_post_values = array();
    			}
    		}
    		$values = array_merge( $values, $this->_post_values );
    	}
    	return $values;
    }
    ```

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

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

| Uses | Description | 
| [WP_Customize_Manager::changeset_data()](https://developer.wordpress.org/reference/classes/wp_customize_manager/changeset_data/)`wp-includes/class-wp-customize-manager.php` |

Gets changeset data.

  | 
| [WP_Customize_Manager::get_stylesheet()](https://developer.wordpress.org/reference/classes/wp_customize_manager/get_stylesheet/)`wp-includes/class-wp-customize-manager.php` |

Retrieves the stylesheet name of the previewed theme.

  | 
| [WP_Customize_Manager::is_theme_active()](https://developer.wordpress.org/reference/classes/wp_customize_manager/is_theme_active/)`wp-includes/class-wp-customize-manager.php` |

Checks if the current theme is active.

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

Plucks a certain field out of each object or array in an array.

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

Returns whether the current user has the specified capability.

  | 
| [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.

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

Retrieves an option value based on an option name.

  |

[Show 3 more](https://developer.wordpress.org/reference/classes/wp_customize_manager/unsanitized_post_values/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_customize_manager/unsanitized_post_values/?output_format=md#)

| Used by | Description | 
| [WP_Customize_Manager::_publish_changeset_values()](https://developer.wordpress.org/reference/classes/wp_customize_manager/_publish_changeset_values/)`wp-includes/class-wp-customize-manager.php` |

Publishes the values of a changeset.

  | 
| [WP_Customize_Manager::save_changeset_post()](https://developer.wordpress.org/reference/classes/wp_customize_manager/save_changeset_post/)`wp-includes/class-wp-customize-manager.php` |

Saves the post for the loaded changeset.

  | 
| [WP_Customize_Manager::customize_pane_settings()](https://developer.wordpress.org/reference/classes/wp_customize_manager/customize_pane_settings/)`wp-includes/class-wp-customize-manager.php` |

Prints JavaScript settings for parent window.

  | 
| [WP_Customize_Manager::register_dynamic_settings()](https://developer.wordpress.org/reference/classes/wp_customize_manager/register_dynamic_settings/)`wp-includes/class-wp-customize-manager.php` |

Adds settings from the POST data that were not added with code, e.g. dynamically-created settings for Widgets

  | 
| [WP_Customize_Manager::set_post_value()](https://developer.wordpress.org/reference/classes/wp_customize_manager/set_post_value/)`wp-includes/class-wp-customize-manager.php` |

Overrides a setting’s value in the current customized state.

  | 
| [WP_Customize_Manager::customize_preview_settings()](https://developer.wordpress.org/reference/classes/wp_customize_manager/customize_preview_settings/)`wp-includes/class-wp-customize-manager.php` |

Prints JavaScript settings for preview frame.

  | 
| [WP_Customize_Manager::post_value()](https://developer.wordpress.org/reference/classes/wp_customize_manager/post_value/)`wp-includes/class-wp-customize-manager.php` |

Returns the sanitized value for a given setting from the current customized state.

  |

[Show 2 more](https://developer.wordpress.org/reference/classes/wp_customize_manager/unsanitized_post_values/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_customize_manager/unsanitized_post_values/?output_format=md#)

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

| Version | Description | 
| [4.7.0](https://developer.wordpress.org/reference/since/4.7.0/) | Added `$args` parameter and merging with changeset values and stashed theme mods. | 
| [4.1.1](https://developer.wordpress.org/reference/since/4.1.1/) | Introduced. |

## User Contributed Notes

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