ppom_wpml_translate breaks ability to save default settings in WooCommerce
-
Ran into an issue with the ppom_wpml_translate function in functions.php line 110. When loading the WooCommerce settings page and trying to save changes to it there are two PHP warnings that interfere with the ability to save any changes.
Using the Query Monitor plugin I was able to trace it to your plugin causing a save failure in WooCommerce settings.
Warning stripslashes() expects parameter 1 to be string, array given
Count = 10
wp-content/plugins/woocommerce-product-addon/inc/functions.php:119
Plugin: woocommerce-product-addonWarning strtolower() expects parameter 1 to be string, array given
Count = 10
wp-includes/formatting.php:2126
Plugin: woocommerce-product-addonIt looks as though an array is being passed to the function as a field value. Not even sure why PPOM is loading on the default WooCommerce settings page. It should only be loaded for its particular settings tab.
Quick fix I implemented:
function ppom_wpml_translate($field_value, $domain) { if (!is_array($field_value)) { $field_name = $domain . ' - ' . sanitize_key($field_value); //WMPL /** * register strings for translation * source: https://wpml.org/wpml-hook/wpml_translate_single_string/ */ $field_value = stripslashes($field_value); } else { // Do something with the array here?? } if( has_filter('wpml_translate_single_string') ) { $field_value = apply_filters('wpml_translate_single_string', $field_value, $domain, $field_name ); } // Polylang if( function_exists('pll__') ) { $field_value = pll__($field_value); } return $field_value; }
- The topic ‘ppom_wpml_translate breaks ability to save default settings in WooCommerce’ is closed to new replies.