WCML_Editor_Save_Filters

The WooCommerce Multilingual WCML Editor Save Filters class.

Defined (1)

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

/inc/translation-editor/class-wcml-editor-save-filters.php  
  1. class WCML_Editor_Save_Filters { 
  2.  
  3. private $trid; 
  4. private $language; 
  5.  
  6. public function __construct( $trid, $language ) { 
  7. $this->trid = $trid; 
  8. $this->language = $language; 
  9.  
  10. add_filter( 'wpml_tm_save_post_trid_value', array( $this, 'wpml_tm_save_post_trid_value' ), 10, 2 ); 
  11. add_filter( 'wpml_tm_save_post_lang_value', array( $this, 'wpml_tm_save_post_lang_value' ), 10, 2 ); 
  12. add_filter( 'wpml_save_post_trid_value', array( $this, 'wpml_save_post_trid_value' ), 10, 3 ); 
  13. add_filter( 'wpml_save_post_lang', array( $this, 'wpml_save_post_lang_value' ), 10 ); 
  14.  
  15. public function __destruct() { 
  16. remove_filter( 'wpml_tm_save_post_trid_value', array( $this, 'wpml_tm_save_post_trid_value' ), 10, 2 ); 
  17. remove_filter( 'wpml_tm_save_post_lang_value', array( $this, 'wpml_tm_save_post_lang_value' ), 10, 2 ); 
  18. remove_filter( 'wpml_save_post_trid_value', array( $this, 'wpml_save_post_trid_value' ), 10, 3 ); 
  19. remove_filter( 'wpml_save_post_lang', array( $this, 'wpml_save_post_lang_value' ), 10 ); 
  20.  
  21. // translation-management $trid filter 
  22. function wpml_tm_save_post_trid_value( $trid, $post_id ) { 
  23. $trid = $this->trid ? $this->trid : $trid; 
  24. return $trid; 
  25.  
  26. // translation-management $lang filter 
  27. function wpml_tm_save_post_lang_value( $lang, $post_id ) { 
  28. if(isset($_POST['action']) && $_POST['action'] == 'wpml_translation_dialog_save_job') { 
  29. $lang = $this->language ? $this->language : $lang; 
  30. return $lang; 
  31.  
  32. // sitepress $trid filter 
  33. function wpml_save_post_trid_value( $trid, $post_status ) { 
  34. if( $post_status != 'auto-draft' ) { 
  35. $trid = $this->trid ? $this->trid : $trid; 
  36. return $trid; 
  37.  
  38. // sitepress $lang filter 
  39. function wpml_save_post_lang_value( $lang ) { 
  40. $lang = $this->language ? $this->language : $lang; 
  41. return $lang; 
  42.