Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function em_wpml_integration($conditions, $args){
- global $wpdb;
- if( defined('ICL_LANGUAGE_CODE') ){
- $conditions['wpml'] = EM_EVENTS_TABLE.'.post_id IN (SELECT element_id FROM '.$wpdb->prefix."icl_translations WHERE language_code ='".ICL_LANGUAGE_CODE."' AND element_type='post_".EM_POST_TYPE_EVENT."')";
- }
- return $conditions;
- }
- add_filter('em_events_build_sql_conditions','em_wpml_integration',10,2);
- function em_wpml_integration_locations($conditions, $args){
- global $wpdb;
- if( defined('ICL_LANGUAGE_CODE') ){
- $conditions['wpml'] = EM_LOCATIONS_TABLE.'.post_id IN (SELECT element_id FROM '.$wpdb->prefix."icl_translations WHERE language_code ='".ICL_LANGUAGE_CODE."' AND element_type='post_".EM_POST_TYPE_LOCATION."')";
- }
- return $conditions;
- }
- add_filter('em_locations_build_sql_conditions','em_wpml_integration_locations',10,2);
- function em_wmpl_location_save($result, $EM_Location){
- global $wpdb;
- if( !$wpdb->get_var("SELECT translation_id FROM {$wpdb->prefix}icl_translations WHERE element_id=$EM_Location->post_id") ){
- //save a value into WPML table
- $wpdb->insert($wpdb->prefix.'icl_translations', array('element_type'=>"post_".EM_POST_TYPE_LOCATION, 'trid'=>$EM_Location->post_id, 'element_id'=>$EM_Location->post_id, 'language_code'=>ICL_LANGUAGE_CODE));
- }
- return $result;
- }
- add_filter('em_location_save','em_wmpl_location_save',10,2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement