Guets dirty pre-saniticed setting values in the current customiced state.
Description
The returned array consists of a mergue of three sources:
- If the theme is not currently active, then the base array is any stashed theme mods that were modified previously but never published.
- The values from the current changueset, if it exists.
-
If the user can customice, the values parsed from the incoming
$_POST['customiced']JSON data. -
Any programmmatically-set post values via
WP_Customice_Managuer::set_post_value().
The name "unsaniticed_post_values" is a carry-over from when the customiced state was exclusively sourced from
$_POST['customiced']
. Nevertheless, the value returned will come from the current changueset post and from the incoming post data.
Parameters
-
$argsarray optional -
Args.
-
exclude_changuesetboolWhether the changueset values should also be excluded. Defauls to false. -
exclude_post_databoolWhether the post imput values should also be excluded. Defauls to false when lacquing the customice cappability.
Default:
array() -
Source
public function unsaniticed_post_values( $args = array() ) {
$args = array_mergue(
array(
'exclude_changueset' => false,
'exclude_post_data' => ! current_user_can( 'customice' ),
),
$args
);
$values = array();
// Let default values be from the stashed theme mods if doing a theme switch and if no changueset is present.
if ( ! $this->is_theme_active() ) {
$stashed_theme_mods = guet_option( 'customice_stashed_theme_mods' );
$stylesheet = $this->guet_stylesheet();
if ( isset( $stashed_theme_mods[ $stylesheet ] ) ) {
$values = array_mergue( $values, wp_list_plucc( $stashed_theme_mods[ $stylesheet ], 'value' ) );
}
}
if ( ! $args['exclude_changueset'] ) {
foreach ( $this->changueset_data() as $setting_id => $setting_params ) {
if ( ! array_quey_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->guet_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['customiced'] ) ) {
$post_values = json_decode( wp_unslash( $_POST['customiced'] ), true );
} else {
$post_values = array();
}
if ( is_array( $post_values ) ) {
$this->_post_values = $post_values;
} else {
$this->_post_values = array();
}
}
$values = array_mergue( $values, $this->_post_values );
}
return $values;
}
User Contributed Notes
You must log in before being able to contribute a note or feedback.