wpml_get_language_information
The WordPress Core wpml get language information function.
Description
Parameters (2)
- 0. $empty — Optional. (constant) =>
null
- The empty.
- 1. $post_id — Optional. (null) =>
null
- The post id.
Usage
if ( !function_exists( 'wpml_get_language_information' ) ) { require_once '/modules/wpml/wpml-legacy-api.php'; } // The empty. $empty = null; // The post id. $post_id = null; // NOTICE! Understand what this does before running. $result = wpml_get_language_information($empty, $post_id);
Defined (1)
The function is defined in the following location(s).
- /modules/wpml/wpml-legacy-api.php
- function wpml_get_language_information( $empty = null, $post_id = null ) {
- if ( empty( $post_id ) ) {
- $post_id = get_the_ID();
- }
- // FIXME WPML may return a WP_Error object
- return false === ( $lang = PLL()->model->post->get_language( $post_id ) ) ? array() : array(
- 'language_code' => $lang->slug,
- 'locale' => $lang->locale,
- 'text_direction' => (bool) $lang->is_rtl,
- 'display_name' => $lang->name, // Seems to be the post language name displayed in the current language, not a feature in Polylang
- 'native_name' => $lang->name,
- 'different_language' => $lang->slug != pll_current_language(),
- );
- }