Inpsyde\MultilingualPress\API\WPDBLanguages::get_language_by_http_code PHP Method

get_language_by_http_code() public method

Returns the desired field value of the language with the given HTTP code.
Since: 3.0.0
public get_language_by_http_code ( string $http_code, string $field = 'native_name', string | string[] $fallbacks = ['native_name', 'english_name'] ) : string | string[]
$http_code string Language HTTP code.
$field string Optional. The field which should be queried. Defaults to 'native_name'.
$fallbacks string | string[] Optional. Falback language fields. Defaults to native and English name.
return string | string[] The desired field value, an empty string on failure, or an array for field 'all'.
    public function get_language_by_http_code($http_code, $field = 'native_name', $fallbacks = ['native_name', 'english_name'])
    {
        $query = $this->db->prepare("SELECT * FROM {$this->table} WHERE http_name = %s LIMIT 1", $http_code);
        $results = $this->db->get_row($query, ARRAY_A);
        if ('all' === $field) {
            return is_array($results) ? $results : [];
        }
        foreach (array_unique(array_merge((array) $field, (array) $fallbacks)) as $key) {
            if (!empty($results[$key])) {
                return (string) $results[$key];
            }
        }
        return '';
    }