Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

wpml_functions.php

By: a guest on Feb 24th, 2014  |  syntax: None  |  size: 4.60 KB  |  views: 49  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. #-----------------------------------------
  3. #       RT-Theme wpml_functions.php
  4. #       version: 1.0
  5. #-----------------------------------------
  6.  
  7.  
  8.  
  9. #
  10. # WPML match page id
  11. #
  12. function wpml_page_id($id){      
  13.         if(function_exists('icl_object_id')) {
  14.                 global $sitepress;
  15.                 $get_default_language =  ICL_LANGUAGE_CODE;
  16.  
  17.                 return icl_object_id($id,'page',true,$get_default_language);
  18.         } else {
  19.                 return $id;
  20.         }
  21. }
  22.  
  23. #
  24. # WPML match post id
  25. #
  26. function wpml_post_id($id){
  27.         if(function_exists('icl_object_id')) {
  28.                 global $sitepress, $post;
  29.                 $get_default_language =  ICL_LANGUAGE_CODE;
  30.                 $post_type = isset( $post->post_type ) ? $post->post_type : "post" ;
  31.                 return icl_object_id($id,$post_type,true,$get_default_language);
  32.         } else {
  33.                 return $id;
  34.         }
  35. }
  36.  
  37. #
  38. # WPML match category id
  39. #
  40. function wpml_category_id($id){
  41.         if(function_exists('icl_object_id')) {
  42.                 global $sitepress;
  43.                 $get_default_language = ICL_LANGUAGE_CODE;
  44.  
  45.                 return icl_object_id($id,'category',true,$get_default_language);
  46.         } else {
  47.                 return $id;
  48.         }
  49. }
  50.  
  51.  
  52. #
  53. # WPML match product category id
  54. #
  55. function wpml_product_category_id($id){
  56.         if(function_exists('icl_object_id')) {
  57.                 global $sitepress;
  58.                 $get_default_language =  ICL_LANGUAGE_CODE;
  59.  
  60.                 return icl_object_id($id,'product_categories',true,$get_default_language);
  61.         } else {
  62.                 return $id;
  63.         }
  64. }
  65.  
  66. #
  67. # WPML match portfolio category id
  68. #
  69. function wpml_portfolio_category_id($id){
  70.         if(function_exists('icl_object_id')) {
  71.                 global $sitepress;
  72.                 $get_default_language =  ICL_LANGUAGE_CODE;
  73.  
  74.                 return icl_object_id($id,'portfolio_categories',true,$get_default_language);
  75.         } else {
  76.                 return $id;
  77.         }
  78. }
  79.  
  80.  
  81. #
  82. # WPML match categories
  83. #
  84. function wpml_lang_object_ids($ids_array, $type) {
  85.         if(function_exists('icl_object_id')) {
  86.                 global $sitepress;
  87.                 $get_default_language =  ICL_LANGUAGE_CODE;
  88.  
  89.                 $res = array();
  90.                 foreach ($ids_array as $id) {
  91.                         $xlat = icl_object_id($id,$type,false,$get_default_language);
  92.                         if(!is_null($xlat)) $res[] = $xlat;
  93.                 }
  94.                 return $res;
  95.         } else {
  96.                 return $ids_array;
  97.         }
  98. }
  99.  
  100. #
  101. # Get WPML Plugin Flags
  102. #
  103. function languages_list(){
  104.     $languages = icl_get_languages('skip_missing=0&orderby=code');
  105.         if(!empty($languages)){
  106.                 echo '<ul class="flags">';
  107.                 foreach($languages as $l){
  108.                         echo '<li>';
  109.                         if($l['country_flag_url']){
  110.                             echo '<a href="'.$l['url'].'" title="'.$l['native_name'].'" class="j_ttip"><img src="'.$l['country_flag_url'].'" height="12" alt="'.$l['language_code'].'" width="18" /></a>';
  111.                         }
  112.                         echo '</li>';
  113.                 }
  114.                 echo '</ul>';
  115.         }
  116. }
  117.  
  118.  
  119. #
  120. #       WPML Home URL
  121. #
  122. function wpml_get_home_url(){
  123.         if(function_exists('icl_get_home_url')){
  124.             return icl_get_home_url();
  125.         }else{
  126.             return rtrim(get_bloginfo('url') , '/') . '/';
  127.         }
  128. }
  129.  
  130. #
  131. #       WPML String Register
  132. #
  133. function wpml_register_string($context, $name, $value){
  134.         if(function_exists('icl_register_string') && trim($value)){
  135.                 icl_register_string($context, $name, $value);
  136.         }    
  137. }
  138.  
  139. #
  140. #       WPML Get Registered String
  141. #
  142. function wpml_t($context, $name, $original_value){
  143.     if(function_exists('icl_t')){
  144.         return icl_t($context, $name, $original_value);
  145.     }else{
  146.         return $original_value;
  147.     }
  148. }
  149.  
  150.  
  151. #
  152. #       String Registration
  153. #
  154. wpml_register_string( THEMESLUG , 'Footer Copyright Text', stripslashes(get_option(THEMESLUG.'_footer_copy')));
  155. wpml_register_string( THEMESLUG , 'Breadcrumb Menu Text',  get_option(THEMESLUG.'_breadcrumb_text'));
  156. wpml_register_string( THEMESLUG , 'Contact - Map Code', stripslashes(get_option(THEMESLUG.'_map_code')));
  157. wpml_register_string( THEMESLUG , 'Contact - Title', stripslashes(get_option(THEMESLUG.'_contact_title')));
  158. wpml_register_string( THEMESLUG , 'Contact - Text', stripslashes(get_option(THEMESLUG.'_contact_text')));
  159. wpml_register_string( THEMESLUG , 'Contact - Address', stripslashes(get_option(THEMESLUG.'_address')));
  160. wpml_register_string( THEMESLUG , 'Contact - Phone', stripslashes(get_option(THEMESLUG.'_phone')));
  161. wpml_register_string( THEMESLUG , 'Contact - Email', stripslashes(get_option(THEMESLUG.'_email_contact')));
  162. wpml_register_string( THEMESLUG , 'Contact - Support Email', stripslashes(get_option(THEMESLUG.'_support_email')));
  163. wpml_register_string( THEMESLUG , 'Contact - Fax', stripslashes(get_option(THEMESLUG.'_fax')));
  164. wpml_register_string( THEMESLUG , 'Contact - Link for Map', stripslashes(get_option(THEMESLUG.'_link_for_map')));
  165. wpml_register_string( THEMESLUG , 'Contact - Contact Form Title', stripslashes(get_option(THEMESLUG.'_contact_form_title')));
  166. wpml_register_string( THEMESLUG , 'Contact - Contact Form Email', stripslashes(get_option(THEMESLUG.'_contact_email')));
  167.  
  168.  
  169.  
  170.  
  171. ?>
clone this paste RAW Paste Data