WPML Core API
Table of Contents
IfOriginalPost
- Full name: \WPML\Element\API\IfOriginalPost
getTranslations
Gets the element details for the translations of the given post id.
IfOriginalPost::getTranslations( integer $id = null ): \WPML\Collect\Support\Collection|callable
Returns an empty array if the id is not an original post.
element details structure:
(object) [
'original' => false, // bool True if the element is the original, false if a translation
'element_id' => 123, // int The element id
'source_language_code' => 'en', // string The source language code
'language_code' => 'de', // string The language of the element
'trid' => 456, // int The translation id that links translations to source.
]
- This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$id |
integer | The post id. Optional. If missing then returns a callable waiting for the id. |
getTranslationIds
Get the element ids for the translations of the given post id.
IfOriginalPost::getTranslationIds( integer $id = null ): \WPML\Collect\Support\Collection|callable
Returns an empty array if the id is not an original post.
- This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$id |
integer | The post id. Optional. If missing then returns a callable waiting for the id. |
Languages
- Full name: \WPML\Element\API\Languages
getActive
Languages::getActive( ): array
It returns an array of the active languages.
The returned array is indexed by language code and every element has the following structure:
'fr' => [
'code' => 'fr',
'id' => 3,
'english_name' => 'French',
'native_name' => 'Français',
'major' => 1,
'default_locale' => 'fr_FR',
'encode_url' => 0,
'tag' => 'fr ,
'display_name' => 'French
]
- This method is static.
getFlagUrl
Languages::getFlagUrl( mixed $...$code ): callable|string
- Curried :: string → string
Gets the flag url for the given language code.
- This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$...$code |
mixed |
withFlags
Languages::withFlags( mixed $...$langs ): callable|array
- Curried :: [code => lang] → [code => lang]
Adds the language flag url to the array of languages.
- This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$...$langs |
mixed |
getAll
Languages::getAll( ): callable|array
void → [lang]
It returns an array of the all the languages.
The returned array is indexed by language code and every element has the following structure:
'fr' => [
'code' => 'fr',
'id' => 3,
'english_name' => 'French',
'native_name' => 'Français',
'major' => 1,
'default_locale' => 'fr_FR',
'encode_url' => 0,
'tag' => 'fr ,
'display_name' => 'French
]
- This method is static.
PostTranslations
Class PostTranslations
- Full name: \WPML\Element\API\PostTranslations
setAsSource
PostTranslations::setAsSource( mixed $...$el_id, mixed $...$language_code ): callable|integer
Curried :: int → string → void
This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$...$el_id |
mixed | |
$...$language_code |
mixed |
setAsTranslationOf
PostTranslations::setAsTranslationOf( mixed $...$el_id, mixed $...$translated_id, mixed $...$language_code ): callable|integer
- This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$...$el_id |
mixed | |
$...$translated_id |
mixed | |
$...$language_code |
mixed |
get
PostTranslations::get( mixed $...$el_id ): callable|array
Curried :: int → [object]
This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$...$el_id |
mixed |
getIfOriginal
PostTranslations::getIfOriginal( mixed $...$el_id ): callable|array
Curried :: int → [object]
This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$...$el_id |
mixed |
Translations
Class Translations
- Full name: \WPML\Element\API\Translations
setLanguage
Translations::setLanguage( mixed $...$el_id, mixed $...$el_type, mixed $...$trid, mixed $...$language_code, mixed $...$src_language_code, mixed $...$check_duplicates ): callable|integer
-
Curried :: int → string → int|null → string → string → string|null → bool → bool|int|null|string
Wrapper function for SitePress::set_element_language_details int $el_id the element's ID (for terms we use the
term_taxonomy_id)string $el_type
int $trid
string $language_code
null|string $src_language_code
bool $check_duplicates
returns bool|int|null|string
- This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$...$el_id |
mixed | |
$...$el_type |
mixed | |
$...$trid |
mixed | |
$...$language_code |
mixed | |
$...$src_language_code |
mixed | |
$...$check_duplicates |
mixed |
setAsSource
Translations::setAsSource( mixed $...$el_id, mixed $...$el_type, mixed $...$language_code ): callable|integer
- This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$...$el_id |
mixed | |
$...$el_type |
mixed | |
$...$language_code |
mixed |
setAsTranslationOf
Translations::setAsTranslationOf( mixed $...$el_id, mixed $...$el_type, mixed $...$translated_id, mixed $...$language_code ): callable|integer
- This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$...$el_id |
mixed | |
$...$el_type |
mixed | |
$...$translated_id |
mixed | |
$...$language_code |
mixed |
get
Translations::get( mixed $...$el_id, mixed $...$el_type ): callable|array
- This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$...$el_id |
mixed | |
$...$el_type |
mixed |
getIfOriginal
Translations::getIfOriginal( mixed $...$el_id, mixed $...$el_type ): callable|array
- This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$...$el_id |
mixed | |
$...$el_type |
mixed |
isOriginal
Translations::isOriginal( mixed $...$el_id, mixed $...$translations ): callable|boolean
- This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$...$el_id |
mixed | |
$...$translations |
mixed |
This document was automatically generated from source code comments on 2020-06-28 using phpDocumentor and cvuorinen/phpdoc-markdown-public