Merge pull request #19675 from woocommerce/fix/19605
Slash meta values before updating the DB in the data store
This commit is contained in:
commit
006bd017cd
|
@ -532,6 +532,7 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
|
||||||
|
|
||||||
foreach ( $props_to_update as $meta_key => $prop ) {
|
foreach ( $props_to_update as $meta_key => $prop ) {
|
||||||
$value = $product->{"get_$prop"}( 'edit' );
|
$value = $product->{"get_$prop"}( 'edit' );
|
||||||
|
$value = is_string( $value ) ? wp_slash( $value ) : $value;
|
||||||
switch ( $prop ) {
|
switch ( $prop ) {
|
||||||
case 'virtual':
|
case 'virtual':
|
||||||
case 'downloadable':
|
case 'downloadable':
|
||||||
|
@ -566,12 +567,15 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
|
||||||
// Update extra data associated with the product like button text or product URL for external products.
|
// Update extra data associated with the product like button text or product URL for external products.
|
||||||
if ( ! $this->extra_data_saved ) {
|
if ( ! $this->extra_data_saved ) {
|
||||||
foreach ( $extra_data_keys as $key ) {
|
foreach ( $extra_data_keys as $key ) {
|
||||||
if ( ! array_key_exists( $key, $props_to_update ) ) {
|
if ( ! array_key_exists( '_' . $key, $props_to_update ) ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$function = 'get_' . $key;
|
$function = 'get_' . $key;
|
||||||
if ( is_callable( array( $product, $function ) ) ) {
|
if ( is_callable( array( $product, $function ) ) ) {
|
||||||
if ( update_post_meta( $product->get_id(), '_' . $key, $product->{$function}( 'edit' ) ) ) {
|
$value = $product->{$function}( 'edit' );
|
||||||
|
$value = is_string( $value ) ? wp_slash( $value ) : $value;
|
||||||
|
|
||||||
|
if ( update_post_meta( $product->get_id(), '_' . $key, $value ) ) {
|
||||||
$this->updated_props[] = $key;
|
$this->updated_props[] = $key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue