wpml_get_language_information

The WordPress Core wpml get language information function.

Description

wpml_get_language_information( (constant) $empty = null, (null) $post_id = null ); 

Parameters (2)

0. $empty — Optional. (constant) => null
The empty.
1. $post_id — Optional. (null) => null
The post id.

Usage

  1. if ( !function_exists( 'wpml_get_language_information' ) ) { 
  2. require_once '/modules/wpml/wpml-legacy-api.php'; 
  3.  
  4. // The empty. 
  5. $empty = null; 
  6.  
  7. // The post id. 
  8. $post_id = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wpml_get_language_information($empty, $post_id); 
  12.  

Defined (1)

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

/modules/wpml/wpml-legacy-api.php  
  1. function wpml_get_language_information( $empty = null, $post_id = null ) { 
  2. if ( empty( $post_id ) ) { 
  3. $post_id = get_the_ID(); 
  4.  
  5. // FIXME WPML may return a WP_Error object 
  6. return false === ( $lang = PLL()->model->post->get_language( $post_id ) ) ? array() : array( 
  7. 'language_code' => $lang->slug,  
  8. 'locale' => $lang->locale,  
  9. 'text_direction' => (bool) $lang->is_rtl,  
  10. 'display_name' => $lang->name, // Seems to be the post language name displayed in the current language, not a feature in Polylang 
  11. 'native_name' => $lang->name,  
  12. 'different_language' => $lang->slug != pll_current_language(),  
  13. );