GC_Customize_Manager::post_value()
最后更新于:2021-11-27 01:07:04
GC_Customize_Manager::post_value( GC_Customize_Setting$setting, mixed$default=null)响应s the sanitized value for a given setting from the current customized state.
参数
- $setting
-
(GC_Customize_Setting) (Required) A GC_Customize_Setting derived object.
- $default
-
(mixed) (Optional) Value returned $setting has no post value (added in 4.2.0) or the post value is invalid (added in 4.6.0).
Default value: null
响应
(string|mixed) Sanitized value or the $default provided.
源文件
文件: gc-includes/class-gc-customize-manager.php
public function post_value( $setting, $default = null ) {
$post_values = $this->unsanitized_post_values();
if ( ! array_key_exists( $setting->id, $post_values ) ) {
return $default;
}
$value = $post_values[ $setting->id ];
$valid = $setting->validate( $value );
if ( is_gc_error( $valid ) ) {
return $default;
}
$value = $setting->sanitize( $value );
if ( is_null( $value ) || is_gc_error( $value ) ) {
return $default;
}
return $value;
}