WCHAU_WPML_Compatibility

The WooCommerce Hear About Us WCHAU WPML Compatibility class.

Defined (1)

The class is defined in the following location(s).

/includes/wchau-wpml-compatibility.php  
  1. class WCHAU_WPML_Compatibility { 
  2.  
  3. public function __construct() { 
  4. add_filter( 'wchau_settings_fields', array( $this, 'translate_settings' ) ); 
  5. add_filter( 'wchau_get_option', array($this, 'translate_option')); 
  6.  
  7. public function translate_settings( $setting_fields ) { 
  8.  
  9. $new_settings = array(); 
  10.  
  11. $languages = $this->wpml_get_languages(); 
  12. $default_language = $this->wpml_get_default_lang(); 
  13.  
  14. foreach ( $setting_fields as $setting_field ) { 
  15. $new_settings[] = $setting_field; 
  16.  
  17. foreach ( $languages as $language ) { 
  18. if ( $language['language_code'] == $default_language ) { 
  19. continue; 
  20.  
  21. $field = $setting_field; 
  22.  
  23. //$field['title'] = '<img src="' . $language['country_flag_url'] . '" alt="' . sanitize_title($language['translated_name']) . '"> ' . $field['title']; 
  24. $field['title'] .= ' (' . strtoupper( $language['language_code'] ) . ')'; 
  25. $field['id'] .= "_" . $language['language_code']; 
  26. $field['default'] = ''; 
  27.  
  28. $new_settings[] = $field; 
  29.  
  30.  
  31. return $new_settings; 
  32.  
  33.  
  34. public function translate_option($option) { 
  35. $current_lang = ICL_LANGUAGE_CODE; 
  36.  
  37. if($current_lang == $this->wpml_get_default_lang()) { 
  38. return $option; 
  39.  
  40. return $option . "_" . $current_lang; 
  41.  
  42. public static function wpml_enabled() { 
  43. global $sitepress; 
  44.  
  45. return ( isset( $sitepress ) ); 
  46.  
  47. private function wpml_get_default_lang() { 
  48. global $sitepress; 
  49.  
  50. return $sitepress->get_default_language(); 
  51.  
  52. private function wpml_get_languages() { 
  53. return icl_get_languages();