Fixed the sanitization for text-based default attributes
This commit is contained in:
parent
aa263ddc1e
commit
948c5c9cfc
|
@ -1518,11 +1518,15 @@ class WC_API_Products extends WC_API_Resource {
|
|||
$_attribute = $attributes[ $taxonomy ];
|
||||
|
||||
if ( $_attribute['is_variation'] ) {
|
||||
// Don't use wc_clean as it destroys sanitized characters
|
||||
$value = '';
|
||||
|
||||
if ( isset( $default_attr['option'] ) ) {
|
||||
if ( $_attribute['is_taxonomy'] ) {
|
||||
// Don't use wc_clean as it destroys sanitized characters
|
||||
$value = sanitize_title( trim( stripslashes( $default_attr['option'] ) ) );
|
||||
} else {
|
||||
$value = '';
|
||||
$value = wc_clean( trim( stripslashes( $default_attr['option'] ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $value ) {
|
||||
|
|
|
@ -1518,11 +1518,15 @@ class WC_API_Products extends WC_API_Resource {
|
|||
$_attribute = $attributes[ $taxonomy ];
|
||||
|
||||
if ( $_attribute['is_variation'] ) {
|
||||
// Don't use wc_clean as it destroys sanitized characters
|
||||
$value = '';
|
||||
|
||||
if ( isset( $default_attr['option'] ) ) {
|
||||
if ( $_attribute['is_taxonomy'] ) {
|
||||
// Don't use wc_clean as it destroys sanitized characters
|
||||
$value = sanitize_title( trim( stripslashes( $default_attr['option'] ) ) );
|
||||
} else {
|
||||
$value = '';
|
||||
$value = wc_clean( trim( stripslashes( $default_attr['option'] ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $value ) {
|
||||
|
|
|
@ -2875,12 +2875,15 @@ class WC_AJAX {
|
|||
foreach ( $attributes as $attribute ) {
|
||||
|
||||
if ( $attribute['is_variation'] ) {
|
||||
$value = '';
|
||||
|
||||
// Don't use wc_clean as it destroys sanitized characters
|
||||
if ( isset( $_POST[ 'default_attribute_' . sanitize_title( $attribute['name'] ) ] ) ) {
|
||||
if ( $attribute['is_taxonomy'] ) {
|
||||
// Don't use wc_clean as it destroys sanitized characters
|
||||
$value = sanitize_title( trim( stripslashes( $_POST[ 'default_attribute_' . sanitize_title( $attribute['name'] ) ] ) ) );
|
||||
} else {
|
||||
$value = '';
|
||||
$value = wc_clean( trim( stripslashes( $_POST[ 'default_attribute_' . sanitize_title( $attribute['name'] ) ] ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $value ) {
|
||||
|
|
Loading…
Reference in New Issue