icl_object_id

The Polylang icl object id function.

Description

icl_object_id( $id, (string) $type = 'post', (constant) $return_original_if_missing = false, (bool) $lang = false ); 

Parameters (4)

0. $id
The id.
1. $type — Optional. (string) => 'post'
The type.
2. $return_original_if_missing — Optional. (constant) => false
The return original if missing.
3. $lang — Optional. (bool) => false
The lang.

Usage

  1. if ( !function_exists( 'icl_object_id' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'polylang/modules/wpml/wpml-legacy-api.php'; 
  3.  
  4. // The id. 
  5. $id = null; 
  6.  
  7. // The type. 
  8. $type = 'post'; 
  9.  
  10. // The return original if missing. 
  11. $return_original_if_missing = false; 
  12.  
  13. // The lang. 
  14. $lang = false; 
  15.  
  16. // NOTICE! Understand what this does before running. 
  17. $result = icl_object_id($id, $type, $return_original_if_missing, $lang); 
  18.  

Defined (1)

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

/modules/wpml/wpml-legacy-api.php  
  1. function icl_object_id( $id, $type = 'post', $return_original_if_missing = false, $lang = false ) { 
  2. $pll_type = ( 'post' === $type || pll_is_translated_post_type( $type ) ) ? 'post' : ( 'term' === $type || pll_is_translated_taxonomy( $type ) ? 'term' : false ); 
  3. return $pll_type && ( $lang = $lang ? $lang : pll_current_language() ) && ( $tr_id = PLL()->model->$pll_type->get_translation( $id, $lang ) ) ? $tr_id : 
  4. ( $return_original_if_missing ? $id : null );