wpml/core-api

用于与WPML核心功能交互的类和实用工具


README

目录

IfOriginalPost

  • 全名: \WPML\Element\API\IfOriginalPost

getTranslations

获取给定帖子ID的翻译元素详情。

IfOriginalPost::getTranslations( integer $id = null ): \WPML\Collect\Support\Collection|callable

如果ID不是原始帖子,则返回空数组。

元素详情结构

(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.
]
  • 此方法为静态参数:
参数类型描述
$id整数帖子ID。可选。如果缺失,则返回一个等待ID的可调用对象。

getTranslationIds

获取给定帖子ID的翻译元素ID。

IfOriginalPost::getTranslationIds( integer $id = null ): \WPML\Collect\Support\Collection|callable

如果ID不是原始帖子,则返回空数组。

  • 此方法为静态参数:
参数类型描述
$id整数帖子ID。可选。如果缺失,则返回一个等待ID的可调用对象。

Languages

  • 全名: \WPML\Element\API\Languages

getActive

Languages::getActive(  ): array

返回活动语言的数组。

返回的数组按语言代码索引,每个元素具有以下结构

 '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
 ]
  • 此方法为静态

getFlagUrl

Languages::getFlagUrl( mixed $...$code ): callable|string
  • Curried :: string → string

获取给定语言代码的标志URL。

  • 此方法为静态参数:
参数类型描述
$...$code混合型

withFlags

Languages::withFlags( mixed $...$langs ): callable|array
  • Curried :: [code => lang] → [code => lang]

将语言标志URL添加到语言数组中。

  • 此方法为静态参数:
参数类型描述
$...$langs混合型

getAll

Languages::getAll(  ): callable|array

void → [lang]

它返回所有语言的数组。

返回的数组按语言代码索引,每个元素具有以下结构

 '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
 ]
  • 此方法为静态

PostTranslations

类 PostTranslations

  • 全名: \WPML\Element\API\PostTranslations

setAsSource

PostTranslations::setAsSource( mixed $...$el_id, mixed $...$language_code ): callable|integer
  • Curried :: int → string → void
  • 此方法为静态参数:
参数类型描述
$...$el_id混合型
$...$language_code混合型

setAsTranslationOf

PostTranslations::setAsTranslationOf( mixed $...$el_id, mixed $...$translated_id, mixed $...$language_code ): callable|integer
  • 此方法为静态参数:
参数类型描述
$...$el_id混合型
$...$translated_id混合型
$...$language_code混合型

get

PostTranslations::get( mixed $...$el_id ): callable|array
  • Curried :: int → [object]
  • 此方法为静态参数:
参数类型描述
$...$el_id混合型

getIfOriginal

PostTranslations::getIfOriginal( mixed $...$el_id ): callable|array
  • Curried :: int → [object]
  • 此方法为静态参数:
参数类型描述
$...$el_id混合型

Translations

类 Translations

  • 全名: \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 元素的ID(对于术语,我们使用 term_taxonomy_id

  • string $el_type
  • int $trid
  • string $language_code
  • null|string $src_language_code
  • bool $check_duplicates

返回 bool|int|null|string

  • 此方法为静态参数:
参数类型描述
$...$el_id混合型
$...$el_type混合型
$...$trid混合型
$...$language_code混合型
$...$src_language_code混合型
$...$check_duplicates混合型

setAsSource

Translations::setAsSource( mixed $...$el_id, mixed $...$el_type, mixed $...$language_code ): callable|integer
  • 此方法为静态参数:
参数类型描述
$...$el_id混合型
$...$el_type混合型
$...$language_code混合型

setAsTranslationOf

Translations::setAsTranslationOf( mixed $...$el_id, mixed $...$el_type, mixed $...$translated_id, mixed $...$language_code ): callable|integer
  • 此方法为静态参数:
参数类型描述
$...$el_id混合型
$...$el_type混合型
$...$translated_id混合型
$...$language_code混合型

get

Translations::get( mixed $...$el_id, mixed $...$el_type ): callable|array
  • 此方法为静态参数:
参数类型描述
$...$el_id混合型
$...$el_type混合型

getIfOriginal

Translations::getIfOriginal( mixed $...$el_id, mixed $...$el_type ): callable|array
  • 此方法为静态参数:
参数类型描述
$...$el_id混合型
$...$el_type混合型

isOriginal

Translations::isOriginal( mixed $...$el_id, mixed $...$translations ): callable|boolean
  • 此方法为静态参数:
参数类型描述
$...$el_id混合型
$...$translations混合型

此文档于2020-06-28自动从源代码注释生成,使用phpDocumentorcvuorinen/phpdoc-markdown-public