---
title: PHP Functions
description: From includes/api.php and includes/functions.php.
url: "https://shapetranslate.com/docs/dev-functions/"
updated: "2026-11-16"
category: Developer Guide
---

# PHP Functions

From `includes/api.php` and `includes/functions.php`.

## Languages

| Function | Returns | What it does |
| --- | --- | --- |
| `shapetranslate_is_active()` | bool | ShapeTranslate is booted and has at least one language. |
| `shapetranslate_current_language( $field = 'slug' )` | mixed | Language of the current request. |
| `shapetranslate_default_language( $field = 'slug' )` | mixed | The default language. |
| `shapetranslate_languages_list( $args = array() )` | array | Languages in order. Args: `fields` (`slug` or `all`), `hide_disabled` (true). |
| `shapetranslate_get_language( $language = '' )` | array|null | The full record for any language reference. |
| `shapetranslate_get_language_field( $language, $field = 'slug' )` | mixed | One field of a language. |
| `shapetranslate_is_rtl( $language = '' )` | bool | Whether a language is right-to-left. |
| `shapetranslate_home_url( $language = '' )` | string | Home URL in a language. |

## Posts and terms

| Function | Returns | What it does |
| --- | --- | --- |
| `shapetranslate_get_post( $post_id, $language = '' )` | int | ID of the translation, 0 when none. |
| `shapetranslate_get_post_language( $post_id, $field = 'slug' )` | mixed | Language of a post. |
| `shapetranslate_get_post_translations( $post_id )` | array | The whole group, e.g. `['en'=>12,'bn'=>34]`. |
| `shapetranslate_set_post_language( $post_id, $language )` | array|WP_Error | Assign a language to a post. |
| `shapetranslate_save_post_translations( $translations, $source_post_id = 0 )` | array|WP_Error | Link existing posts as translations. |
| `shapetranslate_get_term( $term_id, $language = '', $taxonomy = '' )` | int | ID of the translated term. |
| `shapetranslate_get_term_language( $term_id, $field = 'slug', $taxonomy = '' )` | mixed | Language of a term. |
| `shapetranslate_get_term_translations( $term_id, $taxonomy = '' )` | array | The term's group. |
| `shapetranslate_set_term_language( $term_id, $language, $taxonomy = '' )` | array|WP_Error | Assign a language to a term. |
| `shapetranslate_save_term_translations( $translations, $taxonomy = '', $source_term_id = 0 )` | array|WP_Error | Link existing terms. |
| `shapetranslate_is_translated_post_type( $post_type )` | bool | The post type is translatable. |
| `shapetranslate_is_translated_taxonomy( $taxonomy )` | bool | The taxonomy is translatable. |
| `shapetranslate_object_id( $id, $type = 'post', $return_original_if_missing = true, $language = '' )` | int|null | Same idea as WPML's `icl_object_id()`. |

## Strings and switcher

| Function | Returns | What it does |
| --- | --- | --- |
| `shapetranslate_register_string( $group, $key, $original )` | string|WP_Error | Register a string. Call on `init` or later. |
| `shapetranslate_translate_string( $group, $key, $fallback = '', $language_id = '' )` | string | Translated string, unescaped. |
| `shapetranslate__( $group, $key, $fallback = '', $language = '' )` | string | Same, by any language reference. |
| `shapetranslate_e()`, `shapetranslate_esc_html__()`, `shapetranslate_esc_html_e()`, `shapetranslate_esc_attr__()`, `shapetranslate_esc_attr_e()` | string|void | Escaped and echo variants, same arguments. |
| `shapetranslate_get_language_switcher( $args = array() )` | string | Switcher HTML. |
| `shapetranslate_language_switcher( $args = array() )` | void | Echoes the switcher. |
| `shapetranslate_the_languages( $args = array() )` | string | Echoes the switcher; pass `'echo' => false` to return it. |
