\DevOwl\MultilingualAbstractSyncPlugin

There are plugins like WPML or PolyLang which allows you to create a multilingual WordPress installation. devowl.io plugins needs to be compatible with those plugins so this abstract implementation handles actions like get original ID and get default language.

Summary

Methods
Properties
Constants
getSkipHTMLForTag()
maybePersistTranslation()
isCurrentlyInEditorPreview()
translateStrings()
termCopiedToAllOtherLanguages()
postCopiedToAllOtherLanguages()
setTermLanguage()
setPostLanguage()
copyTermToOtherLanguage()
copyPostToOtherLanguage()
duplicatePostMeta()
copyPostTaxonomies()
filterMetaValue()
No public properties found
No constants found
duplicateTerm()
duplicatePost()
duplicateTermMeta()
duplicateMeta()
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

getSkipHTMLForTag()

getSkipHTMLForTag(  $force = false)

Parameters

$force

maybePersistTranslation()

maybePersistTranslation(  $sourceContent,  $content,  $sourceLocale,  $targetLocale)

Parameters

$sourceContent
$content
$sourceLocale
$targetLocale

isCurrentlyInEditorPreview()

isCurrentlyInEditorPreview()

translateStrings()

translateStrings(  $content,  $locale,  $context = null)

Parameters

$content
$locale
$context

termCopiedToAllOtherLanguages()

termCopiedToAllOtherLanguages(array<mixed,integer>  $translations)

This method is called due to `Sync::created_term`. It allows you to get a list of all translations of a term in an associate array.

Parameters

array<mixed,integer> $translations

postCopiedToAllOtherLanguages()

postCopiedToAllOtherLanguages(array<mixed,integer>  $translations)

This method is called due to `Sync::save_post`. It allows you to get a list of all translations of a post in an associate array.

Parameters

array<mixed,integer> $translations

setTermLanguage()

setTermLanguage(integer  $termId,string  $locale)

This method is called due to `Sync::created_term`. It allows you to assign a term to a given language.

Parameters

integer $termId
string $locale

setPostLanguage()

setPostLanguage(integer  $postId,string  $locale)

This method is called due to `Sync::save_post`. It allows you to assign a post to a given language.

Parameters

integer $postId
string $locale

copyTermToOtherLanguage()

copyTermToOtherLanguage(string  $locale,string  $currentLanguage,integer  $term_id,string  $taxonomy,array<mixed,string>  $meta): integer|boolean

Translate given term to other language.

Parameters

string $locale
string $currentLanguage
integer $term_id
string $taxonomy
array<mixed,string> $meta

The meta keys to copy

Returns

integer|boolean —

The new created term id

copyPostToOtherLanguage()

copyPostToOtherLanguage(string  $locale,string  $currentLanguage,string  $post_id,array<mixed,string>  $meta,array<mixed,string>  $taxonomies): integer|boolean

Translate given post to other language.

Parameters

string $locale
string $currentLanguage
string $post_id
array<mixed,string> $meta

The meta keys to copy

array<mixed,string> $taxonomies

The taxonomies to copy

Returns

integer|boolean —

The new created post id

duplicatePostMeta()

duplicatePostMeta(integer  $from,integer  $to,array<mixed,string>  $meta)

Copy already existing meta as it can be inserted with `meta_input` directly.

Additionally listen to term meta addition and copy.

Parameters

integer $from
integer $to
array<mixed,string> $meta

Meta keys to copy

copyPostTaxonomies()

copyPostTaxonomies(integer  $from,integer  $to,array<mixed,string>  $taxonomies,string  $locale)

Copy already existing taxonomies as it can be inserted with `tax_input` directly.

Additionally listen to term additions and copy.

Parameters

integer $from
integer $to
array<mixed,string> $taxonomies

Taxonomy keys to copy

string $locale

The destination locale

filterMetaValue()

filterMetaValue(string  $type,integer  $from,integer  $to,string  $meta_key,mixed  $meta_value,string  $locale)

Apply a WordPress filter so a meta value can be modified for copy process to other languages.

Parameters

string $type

E. g. 'post'

integer $from

Object id of source language item

integer $to

Object id of destination language item

string $meta_key
mixed $meta_value
string $locale

Destination locale

duplicateTerm()

duplicateTerm(\WP_Term  $term,string  $taxonomy)

A simple `get_term` => `wp_insert_term` wrapper.

Parameters

\WP_Term $term
string $taxonomy

duplicatePost()

duplicatePost(\WP_Post  $post)

A simple `get_post` => `wp_insert_post` wrapper.

Parameters

\WP_Post $post

duplicateTermMeta()

duplicateTermMeta(integer  $from,integer  $to,array<mixed,string>  $meta)

Listen to term meta addition and copy.

Parameters

integer $from
integer $to
array<mixed,string> $meta

Meta keys to copy

duplicateMeta()

duplicateMeta(string  $type,integer  $from,integer  $to,array<mixed,string>  $meta)

Listen to meta (term, post, .

..) addition and copy.

Parameters

string $type

E. g. 'post'

integer $from
integer $to
array<mixed,string> $meta

Meta keys to copy