README.md
480 lines
| 1 | # WPML Core API |
| 2 | |
| 3 | ## Table of Contents |
| 4 | |
| 5 | * [IfOriginalPost](#iforiginalpost) |
| 6 | * [getTranslations](#gettranslations) |
| 7 | * [getTranslationIds](#gettranslationids) |
| 8 | * [Languages](#languages) |
| 9 | * [getActive](#getactive) |
| 10 | * [getFlagUrl](#getflagurl) |
| 11 | * [withFlags](#withflags) |
| 12 | * [getAll](#getall) |
| 13 | * [PostTranslations](#posttranslations) |
| 14 | * [setAsSource](#setassource) |
| 15 | * [setAsTranslationOf](#setastranslationof) |
| 16 | * [get](#get) |
| 17 | * [getIfOriginal](#getiforiginal) |
| 18 | * [Translations](#translations) |
| 19 | * [setLanguage](#setlanguage) |
| 20 | * [setAsSource](#setassource-1) |
| 21 | * [setAsTranslationOf](#setastranslationof-1) |
| 22 | * [get](#get-1) |
| 23 | * [getIfOriginal](#getiforiginal-1) |
| 24 | * [isOriginal](#isoriginal) |
| 25 | |
| 26 | ## IfOriginalPost |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | * Full name: \WPML\Element\API\IfOriginalPost |
| 33 | |
| 34 | |
| 35 | ### getTranslations |
| 36 | |
| 37 | Gets the element details for the translations of the given post id. |
| 38 | |
| 39 | ```php |
| 40 | IfOriginalPost::getTranslations( integer $id = null ): \WPML\Collect\Support\Collection|callable |
| 41 | ``` |
| 42 | |
| 43 | Returns an empty array if the id is not an original post. |
| 44 | |
| 45 | element details structure: |
| 46 | ```php |
| 47 | (object) [ |
| 48 | 'original' => false, // bool True if the element is the original, false if a translation |
| 49 | 'element_id' => 123, // int The element id |
| 50 | 'source_language_code' => 'en', // string The source language code |
| 51 | 'language_code' => 'de', // string The language of the element |
| 52 | 'trid' => 456, // int The translation id that links translations to source. |
| 53 | ] |
| 54 | ``` |
| 55 | |
| 56 | * This method is **static**. |
| 57 | **Parameters:** |
| 58 | |
| 59 | | Parameter | Type | Description | |
| 60 | |-----------|------|-------------| |
| 61 | | `$id` | **integer** | The post id. Optional. If missing then returns a callable waiting for the id. | |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | --- |
| 67 | |
| 68 | ### getTranslationIds |
| 69 | |
| 70 | Get the element ids for the translations of the given post id. |
| 71 | |
| 72 | ```php |
| 73 | IfOriginalPost::getTranslationIds( integer $id = null ): \WPML\Collect\Support\Collection|callable |
| 74 | ``` |
| 75 | |
| 76 | Returns an empty array if the id is not an original post. |
| 77 | |
| 78 | * This method is **static**. |
| 79 | **Parameters:** |
| 80 | |
| 81 | | Parameter | Type | Description | |
| 82 | |-----------|------|-------------| |
| 83 | | `$id` | **integer** | The post id. Optional. If missing then returns a callable waiting for the id. | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | --- |
| 89 | |
| 90 | ## Languages |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | * Full name: \WPML\Element\API\Languages |
| 97 | |
| 98 | |
| 99 | ### getActive |
| 100 | |
| 101 | |
| 102 | |
| 103 | ```php |
| 104 | Languages::getActive( ): array |
| 105 | ``` |
| 106 | |
| 107 | It returns an array of the active languages. |
| 108 | |
| 109 | The returned array is indexed by language code and every element has the following structure: |
| 110 | ``` |
| 111 | 'fr' => [ |
| 112 | 'code' => 'fr', |
| 113 | 'id' => 3, |
| 114 | 'english_name' => 'French', |
| 115 | 'native_name' => 'Français', |
| 116 | 'major' => 1, |
| 117 | 'default_locale' => 'fr_FR', |
| 118 | 'encode_url' => 0, |
| 119 | 'tag' => 'fr , |
| 120 | 'display_name' => 'French |
| 121 | ] |
| 122 | ``` |
| 123 | |
| 124 | * This method is **static**. |
| 125 | |
| 126 | |
| 127 | |
| 128 | --- |
| 129 | |
| 130 | ### getFlagUrl |
| 131 | |
| 132 | |
| 133 | |
| 134 | ```php |
| 135 | Languages::getFlagUrl( mixed $...$code ): callable|string |
| 136 | ``` |
| 137 | |
| 138 | - Curried :: string → string |
| 139 | |
| 140 | Gets the flag url for the given language code. |
| 141 | |
| 142 | * This method is **static**. |
| 143 | **Parameters:** |
| 144 | |
| 145 | | Parameter | Type | Description | |
| 146 | |-----------|------|-------------| |
| 147 | | `$...$code` | **mixed** | | |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | --- |
| 153 | |
| 154 | ### withFlags |
| 155 | |
| 156 | |
| 157 | |
| 158 | ```php |
| 159 | Languages::withFlags( mixed $...$langs ): callable|array |
| 160 | ``` |
| 161 | |
| 162 | - Curried :: [code => lang] → [code => lang] |
| 163 | |
| 164 | Adds the language flag url to the array of languages. |
| 165 | |
| 166 | * This method is **static**. |
| 167 | **Parameters:** |
| 168 | |
| 169 | | Parameter | Type | Description | |
| 170 | |-----------|------|-------------| |
| 171 | | `$...$langs` | **mixed** | | |
| 172 | |
| 173 | |
| 174 | |
| 175 | |
| 176 | --- |
| 177 | |
| 178 | ### getAll |
| 179 | |
| 180 | |
| 181 | |
| 182 | ```php |
| 183 | Languages::getAll( ): callable|array |
| 184 | ``` |
| 185 | |
| 186 | void → [lang] |
| 187 | |
| 188 | It returns an array of the all the languages. |
| 189 | |
| 190 | The returned array is indexed by language code and every element has the following structure: |
| 191 | ``` |
| 192 | 'fr' => [ |
| 193 | 'code' => 'fr', |
| 194 | 'id' => 3, |
| 195 | 'english_name' => 'French', |
| 196 | 'native_name' => 'Français', |
| 197 | 'major' => 1, |
| 198 | 'default_locale' => 'fr_FR', |
| 199 | 'encode_url' => 0, |
| 200 | 'tag' => 'fr , |
| 201 | 'display_name' => 'French |
| 202 | ] |
| 203 | ``` |
| 204 | |
| 205 | * This method is **static**. |
| 206 | |
| 207 | |
| 208 | |
| 209 | --- |
| 210 | |
| 211 | ## PostTranslations |
| 212 | |
| 213 | Class PostTranslations |
| 214 | |
| 215 | |
| 216 | |
| 217 | * Full name: \WPML\Element\API\PostTranslations |
| 218 | |
| 219 | |
| 220 | ### setAsSource |
| 221 | |
| 222 | |
| 223 | |
| 224 | ```php |
| 225 | PostTranslations::setAsSource( mixed $...$el_id, mixed $...$language_code ): callable|integer |
| 226 | ``` |
| 227 | |
| 228 | - Curried :: int → string → void |
| 229 | |
| 230 | * This method is **static**. |
| 231 | **Parameters:** |
| 232 | |
| 233 | | Parameter | Type | Description | |
| 234 | |-----------|------|-------------| |
| 235 | | `$...$el_id` | **mixed** | | |
| 236 | | `$...$language_code` | **mixed** | | |
| 237 | |
| 238 | |
| 239 | |
| 240 | |
| 241 | --- |
| 242 | |
| 243 | ### setAsTranslationOf |
| 244 | |
| 245 | |
| 246 | |
| 247 | ```php |
| 248 | PostTranslations::setAsTranslationOf( mixed $...$el_id, mixed $...$translated_id, mixed $...$language_code ): callable|integer |
| 249 | ``` |
| 250 | |
| 251 | |
| 252 | |
| 253 | * This method is **static**. |
| 254 | **Parameters:** |
| 255 | |
| 256 | | Parameter | Type | Description | |
| 257 | |-----------|------|-------------| |
| 258 | | `$...$el_id` | **mixed** | | |
| 259 | | `$...$translated_id` | **mixed** | | |
| 260 | | `$...$language_code` | **mixed** | | |
| 261 | |
| 262 | |
| 263 | |
| 264 | |
| 265 | --- |
| 266 | |
| 267 | ### get |
| 268 | |
| 269 | |
| 270 | |
| 271 | ```php |
| 272 | PostTranslations::get( mixed $...$el_id ): callable|array |
| 273 | ``` |
| 274 | |
| 275 | - Curried :: int → [object] |
| 276 | |
| 277 | * This method is **static**. |
| 278 | **Parameters:** |
| 279 | |
| 280 | | Parameter | Type | Description | |
| 281 | |-----------|------|-------------| |
| 282 | | `$...$el_id` | **mixed** | | |
| 283 | |
| 284 | |
| 285 | |
| 286 | |
| 287 | --- |
| 288 | |
| 289 | ### getIfOriginal |
| 290 | |
| 291 | |
| 292 | |
| 293 | ```php |
| 294 | PostTranslations::getIfOriginal( mixed $...$el_id ): callable|array |
| 295 | ``` |
| 296 | |
| 297 | - Curried :: int → [object] |
| 298 | |
| 299 | * This method is **static**. |
| 300 | **Parameters:** |
| 301 | |
| 302 | | Parameter | Type | Description | |
| 303 | |-----------|------|-------------| |
| 304 | | `$...$el_id` | **mixed** | | |
| 305 | |
| 306 | |
| 307 | |
| 308 | |
| 309 | --- |
| 310 | |
| 311 | ## Translations |
| 312 | |
| 313 | Class Translations |
| 314 | |
| 315 | |
| 316 | |
| 317 | * Full name: \WPML\Element\API\Translations |
| 318 | |
| 319 | |
| 320 | ### setLanguage |
| 321 | |
| 322 | |
| 323 | |
| 324 | ```php |
| 325 | Translations::setLanguage( mixed $...$el_id, mixed $...$el_type, mixed $...$trid, mixed $...$language_code, mixed $...$src_language_code, mixed $...$check_duplicates ): callable|integer |
| 326 | ``` |
| 327 | |
| 328 | - Curried :: int → string → int|null → string → string → string|null → bool → bool|int|null|string |
| 329 | |
| 330 | Wrapper function for SitePress::set_element_language_details |
| 331 | |
| 332 | - int $el_id the element's ID (for terms we use the `term_taxonomy_id`) |
| 333 | - string $el_type |
| 334 | - int $trid |
| 335 | - string $language_code |
| 336 | - null|string $src_language_code |
| 337 | - bool $check_duplicates |
| 338 | |
| 339 | returns bool|int|null|string |
| 340 | |
| 341 | * This method is **static**. |
| 342 | **Parameters:** |
| 343 | |
| 344 | | Parameter | Type | Description | |
| 345 | |-----------|------|-------------| |
| 346 | | `$...$el_id` | **mixed** | | |
| 347 | | `$...$el_type` | **mixed** | | |
| 348 | | `$...$trid` | **mixed** | | |
| 349 | | `$...$language_code` | **mixed** | | |
| 350 | | `$...$src_language_code` | **mixed** | | |
| 351 | | `$...$check_duplicates` | **mixed** | | |
| 352 | |
| 353 | |
| 354 | |
| 355 | |
| 356 | --- |
| 357 | |
| 358 | ### setAsSource |
| 359 | |
| 360 | |
| 361 | |
| 362 | ```php |
| 363 | Translations::setAsSource( mixed $...$el_id, mixed $...$el_type, mixed $...$language_code ): callable|integer |
| 364 | ``` |
| 365 | |
| 366 | |
| 367 | |
| 368 | * This method is **static**. |
| 369 | **Parameters:** |
| 370 | |
| 371 | | Parameter | Type | Description | |
| 372 | |-----------|------|-------------| |
| 373 | | `$...$el_id` | **mixed** | | |
| 374 | | `$...$el_type` | **mixed** | | |
| 375 | | `$...$language_code` | **mixed** | | |
| 376 | |
| 377 | |
| 378 | |
| 379 | |
| 380 | --- |
| 381 | |
| 382 | ### setAsTranslationOf |
| 383 | |
| 384 | |
| 385 | |
| 386 | ```php |
| 387 | Translations::setAsTranslationOf( mixed $...$el_id, mixed $...$el_type, mixed $...$translated_id, mixed $...$language_code ): callable|integer |
| 388 | ``` |
| 389 | |
| 390 | |
| 391 | |
| 392 | * This method is **static**. |
| 393 | **Parameters:** |
| 394 | |
| 395 | | Parameter | Type | Description | |
| 396 | |-----------|------|-------------| |
| 397 | | `$...$el_id` | **mixed** | | |
| 398 | | `$...$el_type` | **mixed** | | |
| 399 | | `$...$translated_id` | **mixed** | | |
| 400 | | `$...$language_code` | **mixed** | | |
| 401 | |
| 402 | |
| 403 | |
| 404 | |
| 405 | --- |
| 406 | |
| 407 | ### get |
| 408 | |
| 409 | |
| 410 | |
| 411 | ```php |
| 412 | Translations::get( mixed $...$el_id, mixed $...$el_type ): callable|array |
| 413 | ``` |
| 414 | |
| 415 | |
| 416 | |
| 417 | * This method is **static**. |
| 418 | **Parameters:** |
| 419 | |
| 420 | | Parameter | Type | Description | |
| 421 | |-----------|------|-------------| |
| 422 | | `$...$el_id` | **mixed** | | |
| 423 | | `$...$el_type` | **mixed** | | |
| 424 | |
| 425 | |
| 426 | |
| 427 | |
| 428 | --- |
| 429 | |
| 430 | ### getIfOriginal |
| 431 | |
| 432 | |
| 433 | |
| 434 | ```php |
| 435 | Translations::getIfOriginal( mixed $...$el_id, mixed $...$el_type ): callable|array |
| 436 | ``` |
| 437 | |
| 438 | |
| 439 | |
| 440 | * This method is **static**. |
| 441 | **Parameters:** |
| 442 | |
| 443 | | Parameter | Type | Description | |
| 444 | |-----------|------|-------------| |
| 445 | | `$...$el_id` | **mixed** | | |
| 446 | | `$...$el_type` | **mixed** | | |
| 447 | |
| 448 | |
| 449 | |
| 450 | |
| 451 | --- |
| 452 | |
| 453 | ### isOriginal |
| 454 | |
| 455 | |
| 456 | |
| 457 | ```php |
| 458 | Translations::isOriginal( mixed $...$el_id, mixed $...$translations ): callable|boolean |
| 459 | ``` |
| 460 | |
| 461 | |
| 462 | |
| 463 | * This method is **static**. |
| 464 | **Parameters:** |
| 465 | |
| 466 | | Parameter | Type | Description | |
| 467 | |-----------|------|-------------| |
| 468 | | `$...$el_id` | **mixed** | | |
| 469 | | `$...$translations` | **mixed** | | |
| 470 | |
| 471 | |
| 472 | |
| 473 | |
| 474 | --- |
| 475 | |
| 476 | |
| 477 | |
| 478 | -------- |
| 479 | > This document was automatically generated from source code comments on 2020-06-28 using [phpDocumentor](http://www.phpdoc.org/) and [cvuorinen/phpdoc-markdown-public](https://github.com/cvuorinen/phpdoc-markdown-public) |
| 480 |