Fix: Ampersand changed to &amp on product attribute export #36520 (#36525)

This commit is contained in:
aniketpatel32 2023-02-16 13:45:03 +05:30 committed by GitHub
parent e05a191156
commit 0e7c13d883
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 5 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Fix Ampersand changed to &amp on product attribute export

View File

@ -467,7 +467,7 @@ abstract class WC_CSV_Exporter {
$values_to_implode = array();
foreach ( $values as $value ) {
$value = (string) is_scalar( $value ) ? $value : '';
$value = (string) is_scalar( $value ) ? html_entity_decode( $value, ENT_QUOTES ) : '';
$values_to_implode[] = str_replace( ',', '\\,', $value );
}

View File

@ -652,7 +652,7 @@ class WC_Product_CSV_Exporter extends WC_CSV_Batch_Exporter {
$this->column_names[ 'attributes:taxonomy' . $i ] = sprintf( __( 'Attribute %d global', 'woocommerce' ), $i );
if ( is_a( $attribute, 'WC_Product_Attribute' ) ) {
$row[ 'attributes:name' . $i ] = wc_attribute_label( $attribute->get_name(), $product );
$row[ 'attributes:name' . $i ] = html_entity_decode( wc_attribute_label( $attribute->get_name(), $product ), ENT_QUOTES );
if ( $attribute->is_taxonomy() ) {
$terms = $attribute->get_terms();
@ -671,14 +671,14 @@ class WC_Product_CSV_Exporter extends WC_CSV_Batch_Exporter {
$row[ 'attributes:visible' . $i ] = $attribute->get_visible();
} else {
$row[ 'attributes:name' . $i ] = wc_attribute_label( $attribute_name, $product );
$row[ 'attributes:name' . $i ] = html_entity_decode( wc_attribute_label( $attribute_name, $product ), ENT_QUOTES );
if ( 0 === strpos( $attribute_name, 'pa_' ) ) {
$option_term = get_term_by( 'slug', $attribute, $attribute_name ); // @codingStandardsIgnoreLine.
$row[ 'attributes:value' . $i ] = $option_term && ! is_wp_error( $option_term ) ? str_replace( ',', '\\,', $option_term->name ) : str_replace( ',', '\\,', $attribute );
$row[ 'attributes:value' . $i ] = $option_term && ! is_wp_error( $option_term ) ? html_entity_decode( str_replace( ',', '\\,', $option_term->name ), ENT_QUOTES ) : html_entity_decode( str_replace( ',', '\\,', $attribute ), ENT_QUOTES );
$row[ 'attributes:taxonomy' . $i ] = 1;
} else {
$row[ 'attributes:value' . $i ] = str_replace( ',', '\\,', $attribute );
$row[ 'attributes:value' . $i ] = html_entity_decode( str_replace( ',', '\\,', $attribute ), ENT_QUOTES );
$row[ 'attributes:taxonomy' . $i ] = 0;
}