using gettext filter causes add-ons to dissappear when updating the product
Issue #888
new
Reported here by multiple users.
Using this code snippet, causes the product add-ons to be deleted/removed from the product when updating the product:
add_filter( 'gettext', 'change_woocommerce_return_to_shop_text', 20, 3 );
function change_woocommerce_return_to_shop_text( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Return to shop' :
$translated_text = __( 'Return to ABC Home Page', 'woocommerce' );
break;
}
return $translated_text;
}
But wrapping it like this, does not:
add_filter( 'gettext', 'change_woocommerce_return_to_shop_text', 20, 3 );
function change_woocommerce_return_to_shop_text( $translated_text, $text, $domain ) {
if ($domain == 'woocommerce') {
switch ( $translated_text ) {
case 'Return to shop' :
$translated_text = __( 'Return to ABC Home Page', 'woocommerce' );
break;
}
}
return $translated_text;
}
Any idea what is happening and how can it be prevented?