Перевод страниц для многоязычного сайта на WordPress (Gutenberg)
Этот GraphQL-запрос помогает создать многоязычный сайт, где каждый подсайт является переводом на определённый язык. Контент основан на блочном редакторе WordPress и лучше всего подходит для сети WordPress Multisite.
Для выполнения этого запроса необходимо, чтобы на эндпоинте были включены Вложенные мутации.
Запрос должен выполняться на главном сайте (с исходным контентом), на котором должен быть установлен плагин-пакет «Power Extensions». На всех остальных сайтах сети может быть установлен бесплатный плагин Gato GraphQL.
Для подключения к сайтам сети используется пароль приложения (Application Password). Обязательно укажите переменные $username и $appPassword для пользователя с доступом ко всем сайтам.
Запрос получает язык главного сайта и внешнего сайта и сравнивает их:
- Если они совпадают — просто реплицирует все страницы
- Если они различаются — реплицирует все страницы с переведённым контентом
(Таким образом, если главный сайт имеет язык en и другой сайт в сети также имеет en, все страницы всё равно реплицируются.)
Затем запрос извлекает страницы с главного сайта и (при необходимости) переводит их все сразу на язык целевого сайта, выполнив единственный вызов API Google Translate.
Наконец, запрос создаёт все эти страницы на внешнем сайте.
########################################################################
#
# Variables:
# - $username: The username to log into the external site
# - $appPassword: The application password to log into the external site
# - $externalSiteURL: The URL of the external site, where all pages will be (translated and) created
# - (Optional) $pageIDs: Restrict translating/creating the pages with given IDs
# - (Optional) $pageStatus: Fetch pages with given status
# - (Optional) $externalSiteGraphQLEndpointPath: Path to the GraphQL endpoint on the external site
#
# *********************************************************************
#
# === Description ===
#
# This Persisted GraphQL query helps create a Multilingual site
# where every site is the translation for some language. The content
# is based on the Gutenberg editor, and it is most suitable with a
# WordPress multisite network.
#
# It must be executed on the master site, which must have the PRO plugin.
# All other sites in the network can have the free Gato GraphQL plugin.
#
# The query retrieves the language from the main site and from the external
# site, and compares them:
#
# - If they are the same, simply replicate all pages
# - If they are different, replicate all pages with translated content
#
# (This way, if the main site has "en" language, and another site in
# the network also has "en", all pages are still replicated.)
#
# Then it grabs all the pages from the master site, and (if required) it
# translates them all at once (in bulk) to the destination site's language,
# by executing a single call to the Google Translate API.
#
# Finally it creates all those pages in the external site.
#
########################################################################
query InitializeVariables
@configureWarningsOnExportingDuplicateVariable(enabled: false)
{
isGutenbergEditorEnabled
@export(as: "isGutenbergEditorEnabled")
emptyBool: _echo(value: false)
@export(as: "hasMasterPages")
@export(as: "executeTranslation")
@remove
}
query ExportData(
$username: String!
$appPassword: String!
$externalSiteURL: URL!
$externalSiteGraphQLEndpointPath: String! = "/graphql/internal/"
$pageIDs: [ID!]! = []
$pageStatus: [CustomPostStatusEnum!]! = [publish]
)
@depends(on: "InitializeVariables")
@include(if: $isGutenbergEditorEnabled)
{
# Retrieve the language of the content
siteLanguage
@export(as: "fromLanguage")
# Generate the authorization header to connect to the external site
loginCredentials: _sprintf(
string: "%s:%s",
values: [$username, $appPassword]
)
@remove
base64EncodedLoginCredentials: _strBase64Encode(
string: $__loginCredentials
)
@remove
authorizationHeaderValue: _sprintf(
string: "Basic %s",
values: [$__base64EncodedLoginCredentials]
)
@remove
@export(as: "authorizationHeaderValue")
# Generate the external site's GraphQL endpoint to connect to
endpoint: _sprintf(
string: "%s%s",
values: [
$externalSiteURL,
$externalSiteGraphQLEndpointPath
]
)
@export(as: "endpoint")
masterPages: pages(filter: { ids: $pageIDs, status: $pageStatus }) {
id
emptyArray: _echo(value: [])
@export(
as: "rawTitle"
type: DICTIONARY
)
@export(
as: "rawContent"
type: DICTIONARY
)
@export(
as: "rawExcerpt"
type: DICTIONARY
)
@remove
}
hasMasterPages: _notEmpty(value: $__masterPages)
@export(as: "hasMasterPages")
}
query RetrieveAndExportExternalSiteLanguage
@depends(on: "ExportData")
@include(if: $hasMasterPages)
{
# Retrieve the language of the external site
externalHTTPRequest: _sendGraphQLHTTPRequest(input:{
endpoint: $endpoint,
query: """
{
me {
name
}
siteLanguage
}
""",
options: {
headers: [
{
name: "Authorization",
value: $authorizationHeaderValue
}
]
}
})
externalSiteLanguage: _objectProperty(
object: $__externalHTTPRequest,
by: {
path: "data.siteLanguage"
}
)
@export(as: "toLanguage")
# Indicate if connecting to the external site was successful
hasRetrievedExternalSiteLanguage: _notEmpty(
value: $__externalSiteLanguage
)
# Only translate the content if the master/destination sites languages are different
areFromToLanguagesDifferent: _notEquals(
value1: $fromLanguage
value2: $__externalSiteLanguage
)
# Flag to indicate if to translate the content
executeTranslation: _and(
values: [
$__hasRetrievedExternalSiteLanguage,
$__areFromToLanguagesDifferent,
]
)
@export(as: "executeTranslation")
}
query InitializeBlockVariables(
$pageIDs: [ID!]! = []
$pageStatus: [CustomPostStatusEnum!]! = [publish]
)
@depends(on: "RetrieveAndExportExternalSiteLanguage")
@include(if: $hasMasterPages)
{
emptyTranslationPageVars: pages(filter: { ids: $pageIDs, status: $pageStatus }) {
id
emptyArray: _echo(value: [])
@export(
as: "coreHeadingContentItems"
type: DICTIONARY
)
@export(
as: "coreHeadingContentReplacementsFrom"
type: DICTIONARY
)
@export(
as: "coreHeadingContentReplacementsTo"
type: DICTIONARY
)
@export(
as: "coreParagraphContentItems"
type: DICTIONARY
)
@export(
as: "coreParagraphContentReplacementsFrom"
type: DICTIONARY
)
@export(
as: "coreParagraphContentReplacementsTo"
type: DICTIONARY
)
@export(
as: "coreImageAltItems"
type: DICTIONARY
)
@export(
as: "coreImageAltReplacementsFrom"
type: DICTIONARY
)
@export(
as: "coreImageAltReplacementsTo"
type: DICTIONARY
)
@export(
as: "coreImageCaptionItems"
type: DICTIONARY
)
@export(
as: "coreImageCaptionReplacementsFrom"
type: DICTIONARY
)
@export(
as: "coreImageCaptionReplacementsTo"
type: DICTIONARY
)
@export(
as: "coreButtonTextItems"
type: DICTIONARY
)
@export(
as: "coreButtonTextReplacementsFrom"
type: DICTIONARY
)
@export(
as: "coreButtonTextReplacementsTo"
type: DICTIONARY
)
@export(
as: "coreTableCaptionItems"
type: DICTIONARY
)
@export(
as: "coreTableCaptionReplacementsFrom"
type: DICTIONARY
)
@export(
as: "coreTableCaptionReplacementsTo"
type: DICTIONARY
)
@export(
as: "coreTableBodyCellsContentItems"
type: DICTIONARY
)
@export(
as: "coreTableBodyCellsContentReplacementsFrom"
type: DICTIONARY
)
@export(
as: "coreTableBodyCellsContentReplacementsTo"
type: DICTIONARY
)
@export(
as: "coreListItemContentItems"
type: DICTIONARY
)
@export(
as: "coreListItemContentReplacementsFrom"
type: DICTIONARY
)
@export(
as: "coreListItemContentReplacementsTo"
type: DICTIONARY
)
@export(
as: "coreCoverAltItems"
type: DICTIONARY
)
@export(
as: "coreCoverAltReplacementsFrom"
type: DICTIONARY
)
@export(
as: "coreCoverAltReplacementsTo"
type: DICTIONARY
)
@export(
as: "coreMediaTextAltItems"
type: DICTIONARY
)
@export(
as: "coreMediaTextAltReplacementsFrom"
type: DICTIONARY
)
@export(
as: "coreMediaTextAltReplacementsTo"
type: DICTIONARY
)
@export(
as: "coreVerseContentItems"
type: DICTIONARY
)
@export(
as: "coreVerseContentReplacementsFrom"
type: DICTIONARY
)
@export(
as: "coreVerseContentReplacementsTo"
type: DICTIONARY
)
@export(
as: "coreQuoteCitationItems"
type: DICTIONARY
)
@export(
as: "coreQuoteCitationReplacementsFrom"
type: DICTIONARY
)
@export(
as: "coreQuoteCitationReplacementsTo"
type: DICTIONARY
)
@export(
as: "corePullquoteCitationItems"
type: DICTIONARY
)
@export(
as: "corePullquoteCitationReplacementsFrom"
type: DICTIONARY
)
@export(
as: "corePullquoteCitationReplacementsTo"
type: DICTIONARY
)
@export(
as: "corePullquoteValueItems"
type: DICTIONARY
)
@export(
as: "corePullquoteValueReplacementsFrom"
type: DICTIONARY
)
@export(
as: "corePullquoteValueReplacementsTo"
type: DICTIONARY
)
@export(
as: "coreAudioCaptionItems"
type: DICTIONARY
)
@export(
as: "coreAudioCaptionReplacementsFrom"
type: DICTIONARY
)
@export(
as: "coreAudioCaptionReplacementsTo"
type: DICTIONARY
)
@export(
as: "coreVideoCaptionItems"
type: DICTIONARY
)
@export(
as: "coreVideoCaptionReplacementsFrom"
type: DICTIONARY
)
@export(
as: "coreVideoCaptionReplacementsTo"
type: DICTIONARY
)
@export(
as: "corePreformattedContentItems"
type: DICTIONARY
)
@export(
as: "corePreformattedContentReplacementsFrom"
type: DICTIONARY
)
@export(
as: "corePreformattedContentReplacementsTo"
type: DICTIONARY
)
@export(
as: "coreEmbedCaptionItems"
type: DICTIONARY
)
@export(
as: "coreEmbedCaptionReplacementsFrom"
type: DICTIONARY
)
@export(
as: "coreEmbedCaptionReplacementsTo"
type: DICTIONARY
)
@remove
}
}
query FetchData(
$pageIDs: [ID!]! = []
$pageStatus: [CustomPostStatusEnum!]! = [publish]
)
@depends(on: "InitializeBlockVariables")
@include(if: $hasMasterPages)
{
fetchDataPages: pages(filter: { ids: $pageIDs, status: $pageStatus }) {
id
rawTitle
@export(
as: "rawTitle"
type: DICTIONARY
)
rawContent
@export(
as: "rawContent"
type: DICTIONARY
)
# Also export it as "transformed" for if the from/to languages are the same (and no translation is done)
@export(
as: "transformedRawContent"
type: DICTIONARY
)
rawExcerpt
@export(
as: "rawExcerpt"
type: DICTIONARY
)
}
}
query FetchBlockData(
$pageIDs: [ID!]! = []
$pageStatus: [CustomPostStatusEnum!]! = [publish]
)
@depends(on: "FetchData")
@include(if: $executeTranslation)
{
fetchBlockDataPages: pages(filter: { ids: $pageIDs, status: $pageStatus }) {
id
coreHeading: blockFlattenedDataItems(
filterBy: { include: "core/heading" }
)
@underEachArrayItem
@underJSONObjectProperty(
by: { path: "attributes.content" }
failIfNonExistingKeyOrPath: false
)
@export(
as: "coreHeadingContentItems"
type: DICTIONARY
)
coreParagraph: blockFlattenedDataItems(
filterBy: { include: "core/paragraph" }
)
@underEachArrayItem
@underJSONObjectProperty(
by: { path: "attributes.content" }
failIfNonExistingKeyOrPath: false
)
@export(
as: "coreParagraphContentItems"
type: DICTIONARY
)
coreImage: blockFlattenedDataItems(
filterBy: { include: "core/image" }
)
@underEachArrayItem
@underJSONObjectProperty(
by: { key: "attributes" }
affectDirectivesUnderPos: [1, 3]
)
@underJSONObjectProperty(
by: { key: "alt" }
failIfNonExistingKeyOrPath: false
)
@export(
as: "coreImageAltItems"
type: DICTIONARY
)
@underJSONObjectProperty(
by: { key: "caption" }
failIfNonExistingKeyOrPath: false
)
@export(
as: "coreImageCaptionItems"
type: DICTIONARY
)
coreButton: blockFlattenedDataItems(
filterBy: { include: "core/button" }
)
@underEachArrayItem
@underJSONObjectProperty(
by: { path: "attributes.text" }
failIfNonExistingKeyOrPath: false
)
@export(
as: "coreButtonTextItems"
type: DICTIONARY
)
coreTable: blockFlattenedDataItems(
filterBy: { include: "core/table" }
)
@underEachArrayItem
@underJSONObjectProperty(
by: { key: "attributes" }
affectDirectivesUnderPos: [1, 3]
)
@underJSONObjectProperty(
by: { key: "caption" }
failIfNonExistingKeyOrPath: false
)
@export(
as: "coreTableCaptionItems"
type: DICTIONARY
)
@underJSONObjectProperty(
by: { key: "body" }
failIfNonExistingKeyOrPath: false
)
@underEachArrayItem
@underJSONObjectProperty(
by: { key: "cells" }
)
@underEachArrayItem
@underJSONObjectProperty(
by: { key: "content" }
)
@export(
as: "coreTableBodyCellsContentItems"
type: DICTIONARY
)
coreListItem: blockFlattenedDataItems(
filterBy: { include: "core/list-item" }
)
@underEachArrayItem
@underJSONObjectProperty(
by: { path: "attributes.content" }
failIfNonExistingKeyOrPath: false
)
@export(
as: "coreListItemContentItems"
type: DICTIONARY
)
coreCover: blockFlattenedDataItems(
filterBy: { include: "core/cover" }
)
@underEachArrayItem
@underJSONObjectProperty(
by: { path: "attributes.alt" }
failIfNonExistingKeyOrPath: false
)
@export(
as: "coreCoverAltItems"
type: DICTIONARY
)
coreMediaText: blockFlattenedDataItems(
filterBy: { include: "core/media-text" }
)
@underEachArrayItem
@underJSONObjectProperty(
by: { path: "attributes.mediaAlt" }
failIfNonExistingKeyOrPath: false
)
@export(
as: "coreMediaTextAltItems"
type: DICTIONARY
)
coreVerse: blockFlattenedDataItems(
filterBy: { include: "core/verse" }
)
@underEachArrayItem
@underJSONObjectProperty(
by: { path: "attributes.content" }
failIfNonExistingKeyOrPath: false
)
@export(
as: "coreVerseContentItems"
type: DICTIONARY
)
coreQuote: blockFlattenedDataItems(
filterBy: { include: "core/quote" }
)
@underEachArrayItem
@underJSONObjectProperty(
by: { path: "attributes.citation" }
failIfNonExistingKeyOrPath: false
)
@export(
as: "coreQuoteCitationItems"
type: DICTIONARY
)
corePullquote: blockFlattenedDataItems(
filterBy: { include: "core/pullquote" }
)
@underEachArrayItem
@underJSONObjectProperty(
by: { key: "attributes" }
affectDirectivesUnderPos: [1, 3]
)
@underJSONObjectProperty(
by: { key: "citation" }
failIfNonExistingKeyOrPath: false
)
@export(
as: "corePullquoteCitationItems"
type: DICTIONARY
)
@underJSONObjectProperty(
by: { key: "value" }
failIfNonExistingKeyOrPath: false
)
@export(
as: "corePullquoteValueItems"
type: DICTIONARY
)
coreAudio: blockFlattenedDataItems(
filterBy: { include: "core/audio" }
)
@underEachArrayItem
@underJSONObjectProperty(
by: { path: "attributes.caption" }
failIfNonExistingKeyOrPath: false
)
@export(
as: "coreAudioCaptionItems"
type: DICTIONARY
)
coreVideo: blockFlattenedDataItems(
filterBy: { include: "core/video" }
)
@underEachArrayItem
@underJSONObjectProperty(
by: { path: "attributes.caption" }
failIfNonExistingKeyOrPath: false
)
@export(
as: "coreVideoCaptionItems"
type: DICTIONARY
)
corePreformatted: blockFlattenedDataItems(
filterBy: { include: "core/preformatted" }
)
@underEachArrayItem
@underJSONObjectProperty(
by: { path: "attributes.content" }
failIfNonExistingKeyOrPath: false
)
@export(
as: "corePreformattedContentItems"
type: DICTIONARY
)
coreEmbed: blockFlattenedDataItems(
filterBy: { include: "core/embed" }
)
@underEachArrayItem
@underJSONObjectProperty(
by: { path: "attributes.caption" }
failIfNonExistingKeyOrPath: false
)
@export(
as: "coreEmbedCaptionItems"
type: DICTIONARY
)
}
}
query AdaptData
@depends(on: "FetchBlockData")
@include(if: $hasMasterPages)
{
adaptedToRawTitle: _echo(value: $rawTitle)
@underEachJSONObjectProperty(
passValueOnwardsAs: "value"
)
@applyField(
name: "_echo"
arguments: {
value: [$value]
}
setResultInResponse: true
)
@export(as: "adaptedToRawTitle")
adaptedFromTitle: _echo(value: $rawTitle)
@underEachJSONObjectProperty
@applyField(
name: "_echo"
arguments: {
value: [""]
}
setResultInResponse: true
)
@export(as: "adaptedFromTitle")
adaptedToRawExcerpt: _echo(value: $rawExcerpt)
@underEachJSONObjectProperty(
passValueOnwardsAs: "value"
)
@applyField(
name: "_echo"
arguments: {
value: [$value]
}
setResultInResponse: true
)
@export(as: "adaptedToRawExcerpt")
adaptedFromRawExcerpt: _echo(value: $rawExcerpt)
@underEachJSONObjectProperty
@applyField(
name: "_echo"
arguments: {
value: [""]
}
setResultInResponse: true
)
@export(as: "adaptedFromRawExcerpt")
}
query TransformData
@depends(on: "AdaptData")
@include(if: $hasMasterPages)
{
transformations: _echo(value: {
metaRawTitle: {
from: $adaptedFromTitle,
to: $adaptedToRawTitle,
},
metaRawExcerpt: {
from: $adaptedFromRawExcerpt,
to: $adaptedToRawExcerpt,
},
coreHeadingContent: {
from: $coreHeadingContentItems,
to: $coreHeadingContentItems,
},
coreParagraphContent: {
from: $coreParagraphContentItems,
to: $coreParagraphContentItems,
},
coreImageAlt: {
from: $coreImageAltItems,
to: $coreImageAltItems,
},
coreImageCaption: {
from: $coreImageCaptionItems,
to: $coreImageCaptionItems,
},
coreButtonText: {
from: $coreButtonTextItems
to: $coreButtonTextItems
},
coreTableCaption: {
from: $coreTableCaptionItems,
to: $coreTableCaptionItems,
},
coreTableBodyCellsContent: {
from: $coreTableBodyCellsContentItems,
to: $coreTableBodyCellsContentItems,
},
coreListItemContent: {
from: $coreListItemContentItems,
to: $coreListItemContentItems,
},
coreCoverAlt: {
from: $coreCoverAltItems,
to: $coreCoverAltItems,
},
coreMediaTextAlt: {
from: $coreMediaTextAltItems,
to: $coreMediaTextAltItems,
},
coreVerseContent: {
from: $coreVerseContentItems,
to: $coreVerseContentItems,
},
coreQuoteCitation: {
from: $coreQuoteCitationItems,
to: $coreQuoteCitationItems,
},
corePullquoteCitation: {
from: $corePullquoteCitationItems,
to: $corePullquoteCitationItems,
},
corePullquoteValue: {
from: $corePullquoteValueItems,
to: $corePullquoteValueItems,
},
coreAudioCaption: {
from: $coreAudioCaptionItems,
to: $coreAudioCaptionItems,
},
coreVideoCaption: {
from: $coreVideoCaptionItems,
to: $coreVideoCaptionItems,
},
corePreformattedContent: {
from: $corePreformattedContentItems,
to: $corePreformattedContentItems,
},
coreEmbedCaption: {
from: $coreEmbedCaptionItems,
to: $coreEmbedCaptionItems,
},
})
@if(condition: $executeTranslation)
@underEachJSONObjectProperty
@underJSONObjectProperty(by: { key: "to" })
@underEachJSONObjectProperty
@underEachArrayItem
@strTranslate(
from: $fromLanguage,
to: $toLanguage
)
@export(as: "transformations")
}
query EscapeRegexStrings
@depends(on: "TransformData")
@include(if: $executeTranslation)
{
escapedRegexStrings: _echo(value: $transformations)
@underEachJSONObjectProperty(
filter: {
by: {
excludeKeys: [
"metaRawTitle",
"metaRawExcerpt"
]
}
}
)
@underJSONObjectProperty(by: { key: "from" })
@underEachJSONObjectProperty
@underEachArrayItem
@strQuoteRegex
@underEachJSONObjectProperty(
filter: {
by: {
excludeKeys: [
"metaRawTitle",
"metaRawExcerpt"
]
}
}
)
@underJSONObjectProperty(
by: { key: "to" }
)
@underEachJSONObjectProperty(
affectDirectivesUnderPos: [1, 3]
)
@underEachArrayItem
@strRegexReplace(
searchRegex: "#\\$(\\d+)#",
replaceWith: "\\\\\\$1"
)
@underEachArrayItem(
passValueOnwardsAs: "value"
)
@applyField(
name: "_sprintf",
arguments: {
string: "${1}%s${2}",
values: [$value]
},
setResultInResponse: true
)
@export(as: "escapedRegexTransformations")
}
query CreateRegexReplacements
@depends(on: "EscapeRegexStrings")
@include(if: $executeTranslation)
{
regexReplacements: _echo(value: $escapedRegexTransformations)
@underJSONObjectProperty(
by: { key: "coreHeadingContent" }
affectDirectivesUnderPos: [1, 6]
)
@underJSONObjectProperty(
by: { key: "from" }
affectDirectivesUnderPos: [1, 4],
)
@underEachJSONObjectProperty
@underEachArrayItem(
passValueOnwardsAs: "value"
)
@applyField(
name: "_sprintf",
arguments: {
string: "#(<!-- wp:heading .*?-->\\n?<h[1-6] ?.*?>)%s(</h[1-6]>\\n?<!-- /wp:heading -->)#",
values: [$value]
},
setResultInResponse: true
)
@export(
as: "coreHeadingContentReplacementsFrom",
)
@underJSONObjectProperty(
by: { key: "to" }
)
@export(
as: "coreHeadingContentReplacementsTo",
)
@underJSONObjectProperty(
by: { key: "coreParagraphContent" }
affectDirectivesUnderPos: [1, 6]
)
@underJSONObjectProperty(
by: { key: "from" }
affectDirectivesUnderPos: [1, 4],
)
@underEachJSONObjectProperty
@underEachArrayItem(
passValueOnwardsAs: "value"
)
@applyField(
name: "_sprintf",
arguments: {
string: "#(<!-- wp:paragraph .*?-->\\n?<p ?.*?>)%s(</p>\\n?<!-- /wp:paragraph -->)#",
values: [$value]
},
setResultInResponse: true
)
@export(
as: "coreParagraphContentReplacementsFrom",
)
@underJSONObjectProperty(
by: { key: "to" }
)
@export(
as: "coreParagraphContentReplacementsTo",
)
@underJSONObjectProperty(
by: { key: "coreImageAlt" }
affectDirectivesUnderPos: [1, 6]
)
@underJSONObjectProperty(
by: { key: "from" }
affectDirectivesUnderPos: [1, 4],
)
@underEachJSONObjectProperty
@underEachArrayItem(
passValueOnwardsAs: "value"
)
@applyField(
name: "_sprintf",
arguments: {
string: "#(<!-- wp:image .*?-->\\n?.*<img .*?alt=\\\")%s(\\\".*>.*\\n?<!-- /wp:image -->)#",
values: [$value]
},
setResultInResponse: true
)
@export(
as: "coreImageAltReplacementsFrom",
)
@underJSONObjectProperty(
by: { key: "to" }
)
@export(
as: "coreImageAltReplacementsTo",
)
@underJSONObjectProperty(
by: { key: "coreImageCaption" }
affectDirectivesUnderPos: [1, 6]
)
@underJSONObjectProperty(
by: { key: "from" }
affectDirectivesUnderPos: [1, 4],
)
@underEachJSONObjectProperty
@underEachArrayItem(
passValueOnwardsAs: "value"
)
@applyField(
name: "_sprintf",
arguments: {
string: "#(<!-- wp:image .*?-->\\n?.*<figcaption ?.*?>)%s(</figcaption>.*\\n?<!-- /wp:image -->)#",
values: [$value]
},
setResultInResponse: true
)
@export(
as: "coreImageCaptionReplacementsFrom",
)
@underJSONObjectProperty(
by: { key: "to" }
)
@export(
as: "coreImageCaptionReplacementsTo",
)
@underJSONObjectProperty(
by: { key: "coreButtonText" }
affectDirectivesUnderPos: [1, 6]
)
@underJSONObjectProperty(
by: { key: "from" }
affectDirectivesUnderPos: [1, 4],
)
@underEachJSONObjectProperty
@underEachArrayItem(
passValueOnwardsAs: "value"
)
@applyField(
name: "_sprintf",
arguments: {
string: "#(<!-- wp:button .*?-->\\n?.*<a ?.*?>)%s(</a>.*\\n?<!-- /wp:button -->)#",
values: [$value]
},
setResultInResponse: true
)
@export(
as: "coreButtonTextReplacementsFrom",
)
@underJSONObjectProperty(
by: { key: "to" }
)
@export(
as: "coreButtonTextReplacementsTo",
)
@underJSONObjectProperty(
by: { key: "coreTableCaption" }
affectDirectivesUnderPos: [1, 6]
)
@underJSONObjectProperty(
by: { key: "from" }
affectDirectivesUnderPos: [1, 4],
)
@underEachJSONObjectProperty
@underEachArrayItem(
passValueOnwardsAs: "value"
)
@applyField(
name: "_sprintf",
arguments: {
string: "#(<!-- wp:table .*?-->\\n?.*<figcaption ?.*?>.*)%s(.*</figcaption>.*\\n?<!-- /wp:table -->)#",
values: [$value]
},
setResultInResponse: true
)
@export(
as: "coreTableCaptionReplacementsFrom",
)
@underJSONObjectProperty(
by: { key: "to" }
)
@export(
as: "coreTableCaptionReplacementsTo",
)
@underJSONObjectProperty(
by: { key: "coreTableBodyCellsContent" }
affectDirectivesUnderPos: [1, 6]
)
@underJSONObjectProperty(
by: { key: "from" }
affectDirectivesUnderPos: [1, 4],
)
@underEachJSONObjectProperty
@underEachArrayItem(
passValueOnwardsAs: "value"
)
@applyField(
name: "_sprintf",
arguments: {
string: "#(<!-- wp:table .*?-->\\n?.*<table ?.*?>.*)%s(.*</table>.*\\n?<!-- /wp:table -->)#",
values: [$value]
},
setResultInResponse: true
)
@export(
as: "coreTableBodyCellsContentReplacementsFrom",
)
@underJSONObjectProperty(
by: { key: "to" }
)
@export(
as: "coreTableBodyCellsContentReplacementsTo",
)
@underJSONObjectProperty(
by: { key: "coreListItemContent" }
affectDirectivesUnderPos: [1, 6]
)
@underJSONObjectProperty(
by: { key: "from" }
affectDirectivesUnderPos: [1, 4],
)
@underEachJSONObjectProperty
@underEachArrayItem(
passValueOnwardsAs: "value"
)
@applyField(
name: "_sprintf",
arguments: {
string: "#(<!-- wp:list-item .*?-->\\n?<li ?.*?>)%s(</li>\\n?<!-- /wp:list-item -->)#",
values: [$value]
},
setResultInResponse: true
)
@export(
as: "coreListItemContentReplacementsFrom",
)
@underJSONObjectProperty(
by: { key: "to" }
)
@export(
as: "coreListItemContentReplacementsTo",
)
@underJSONObjectProperty(
by: { key: "coreCoverAlt" }
affectDirectivesUnderPos: [1, 6]
)
@underJSONObjectProperty(
by: { key: "from" }
affectDirectivesUnderPos: [1, 4],
)
@underEachJSONObjectProperty
@underEachArrayItem(
passValueOnwardsAs: "value"
)
@applyField(
name: "_sprintf",
arguments: {
string: "#(<!-- wp:cover .*?-->\\n?.*<img .*?alt=\\\")%s(\\\".*>.*\\n?<!-- /wp:cover -->)#",
values: [$value]
},
setResultInResponse: true
)
@export(
as: "coreCoverAltReplacementsFrom",
)
@underJSONObjectProperty(
by: { key: "to" }
)
@export(
as: "coreCoverAltReplacementsTo",
)
@underJSONObjectProperty(
by: { key: "coreMediaTextAlt" }
affectDirectivesUnderPos: [1, 6]
)
@underJSONObjectProperty(
by: { key: "from" }
affectDirectivesUnderPos: [1, 4],
)
@underEachJSONObjectProperty
@underEachArrayItem(
passValueOnwardsAs: "value"
)
@applyField(
name: "_sprintf",
arguments: {
string: "#(<!-- wp:media-text .*?-->\\n?<div .*><figure .*><img .*?alt=\\\")%s(\\\")#",
values: [$value]
},
setResultInResponse: true
)
@export(
as: "coreMediaTextAltReplacementsFrom",
)
@underJSONObjectProperty(
by: { key: "to" }
)
@export(
as: "coreMediaTextAltReplacementsTo",
)
@underJSONObjectProperty(
by: { key: "coreVerseContent" }
affectDirectivesUnderPos: [1, 6]
)
@underJSONObjectProperty(
by: { key: "from" }
affectDirectivesUnderPos: [1, 4],
)
@underEachJSONObjectProperty
@underEachArrayItem(
passValueOnwardsAs: "value"
)
@applyField(
name: "_sprintf",
arguments: {
string: "#(<!-- wp:verse .*?-->\\n?<pre ?.*?>)%s(</pre>\\n?<!-- /wp:verse -->)#",
values: [$value]
},
setResultInResponse: true
)
@export(
as: "coreVerseContentReplacementsFrom",
)
@underJSONObjectProperty(
by: { key: "to" }
)
@export(
as: "coreVerseContentReplacementsTo",
)
@underJSONObjectProperty(
by: { key: "coreQuoteCitation" }
affectDirectivesUnderPos: [1, 6]
)
@underJSONObjectProperty(
by: { key: "from" }
affectDirectivesUnderPos: [1, 4],
)
@underEachJSONObjectProperty
@underEachArrayItem(
passValueOnwardsAs: "value"
)
@applyField(
name: "_sprintf",
arguments: {
string: "#(<!-- wp:quote .*?-->\\n?<blockquote ?.*?>.*<cite ?.*?>)%s(</cite></blockquote>\\n?<!-- /wp:quote -->)#s",
values: [$value]
},
setResultInResponse: true
)
@export(
as: "coreQuoteCitationReplacementsFrom",
)
@underJSONObjectProperty(
by: { key: "to" }
)
@export(
as: "coreQuoteCitationReplacementsTo",
)
@underJSONObjectProperty(
by: { key: "corePullquoteCitation" }
affectDirectivesUnderPos: [1, 6]
)
@underJSONObjectProperty(
by: { key: "from" }
affectDirectivesUnderPos: [1, 4],
)
@underEachJSONObjectProperty
@underEachArrayItem(
passValueOnwardsAs: "value"
)
@applyField(
name: "_sprintf",
arguments: {
string: "#(<!-- wp:pullquote .*?-->\\n?<figure ?.*?><blockquote ?.*?><p ?.*?>.*</p><cite ?.*?>)%s(</cite></blockquote></figure>\\n?<!-- /wp:pullquote -->)#",
values: [$value]
},
setResultInResponse: true
)
@export(
as: "corePullquoteCitationReplacementsFrom",
)
@underJSONObjectProperty(
by: { key: "to" }
)
@export(
as: "corePullquoteCitationReplacementsTo",
)
@underJSONObjectProperty(
by: { key: "corePullquoteValue" }
affectDirectivesUnderPos: [1, 6]
)
@underJSONObjectProperty(
by: { key: "from" }
affectDirectivesUnderPos: [1, 4],
)
@underEachJSONObjectProperty
@underEachArrayItem(
passValueOnwardsAs: "value"
)
@applyField(
name: "_sprintf",
arguments: {
string: "#(<!-- wp:pullquote .*?-->\\n?<figure ?.*?><blockquote ?.*?><p ?.*?>)%s(</p>(?:<cite ?.*?>.*</cite>)?</blockquote></figure>\\n?<!-- /wp:pullquote -->)#",
values: [$value]
},
setResultInResponse: true
)
@export(
as: "corePullquoteValueReplacementsFrom",
)
@underJSONObjectProperty(
by: { key: "to" }
)
@export(
as: "corePullquoteValueReplacementsTo",
)
@underJSONObjectProperty(
by: { key: "coreAudioCaption" }
affectDirectivesUnderPos: [1, 6]
)
@underJSONObjectProperty(
by: { key: "from" }
affectDirectivesUnderPos: [1, 4],
)
@underEachJSONObjectProperty
@underEachArrayItem(
passValueOnwardsAs: "value"
)
@applyField(
name: "_sprintf",
arguments: {
string: "#(<!-- wp:audio .*?-->\\n?<figure ?.*?><audio ?.*?>.*</audio><figcaption ?.*?>)%s(</figcaption></figure>\\n?<!-- /wp:audio -->)#",
values: [$value]
},
setResultInResponse: true
)
@export(
as: "coreAudioCaptionReplacementsFrom",
)
@underJSONObjectProperty(
by: { key: "to" }
)
@export(
as: "coreAudioCaptionReplacementsTo",
)
@underJSONObjectProperty(
by: { key: "coreVideoCaption" }
affectDirectivesUnderPos: [1, 6]
)
@underJSONObjectProperty(
by: { key: "from" }
affectDirectivesUnderPos: [1, 4],
)
@underEachJSONObjectProperty
@underEachArrayItem(
passValueOnwardsAs: "value"
)
@applyField(
name: "_sprintf",
arguments: {
string: "#(<!-- wp:video .*?-->\\n?<figure ?.*?><video ?.*?>.*</video><figcaption ?.*?>)%s(</figcaption></figure>\\n?<!-- /wp:video -->)#",
values: [$value]
},
setResultInResponse: true
)
@export(
as: "coreVideoCaptionReplacementsFrom",
)
@underJSONObjectProperty(
by: { key: "to" }
)
@export(
as: "coreVideoCaptionReplacementsTo",
)
@underJSONObjectProperty(
by: { key: "corePreformattedContent" }
affectDirectivesUnderPos: [1, 6]
)
@underJSONObjectProperty(
by: { key: "from" }
affectDirectivesUnderPos: [1, 4],
)
@underEachJSONObjectProperty
@underEachArrayItem(
passValueOnwardsAs: "value"
)
@applyField(
name: "_sprintf",
arguments: {
string: "#(<!-- wp:preformatted .*?-->\\n?<pre ?.*?>)%s(</pre>\\n?<!-- /wp:preformatted -->)#",
values: [$value]
},
setResultInResponse: true
)
@export(
as: "corePreformattedContentReplacementsFrom",
)
@underJSONObjectProperty(
by: { key: "to" }
)
@export(
as: "corePreformattedContentReplacementsTo",
)
@underJSONObjectProperty(
by: { key: "coreEmbedCaption" }
affectDirectivesUnderPos: [1, 6]
)
@underJSONObjectProperty(
by: { key: "from" }
affectDirectivesUnderPos: [1, 4],
)
@underEachJSONObjectProperty
@underEachArrayItem(
passValueOnwardsAs: "value"
)
@applyField(
name: "_sprintf",
arguments: {
string: "#(<!-- wp:embed .*?-->\\n?<figure ?.*?><div ?.*?>.*</div><figcaption ?.*?>)%s(</figcaption></figure>\\n?<!-- /wp:embed -->)#s",
values: [$value]
},
setResultInResponse: true
)
@export(
as: "coreEmbedCaptionReplacementsFrom",
)
@underJSONObjectProperty(
by: { key: "to" }
)
@export(
as: "coreEmbedCaptionReplacementsTo",
)
}
query ExecuteRegexReplacements
@depends(on: "CreateRegexReplacements")
@include(if: $executeTranslation)
{
transformedRawContent: _echo(value: $rawContent)
@underEachJSONObjectProperty(
passKeyOnwardsAs: "pageID"
affectDirectivesUnderPos: [
1, 2,
6, 7,
11, 12,
16, 17,
21, 22,
26, 27,
31, 32,
36, 37,
41, 42,
46, 47,
51, 52,
56, 57,
61, 62,
66, 67,
71, 72,
76, 77,
81, 82,
86, 87,
]
)
@applyField(
name: "_propertyExistsInJSONObject"
arguments: {
object: $coreHeadingContentReplacementsFrom
by: { key: $pageID }
}
passOnwardsAs: "hasPageID"
)
@if(
condition: $hasPageID
affectDirectivesUnderPos: [1, 2, 3]
)
@applyField(
name: "_objectProperty",
arguments: {
object: $coreHeadingContentReplacementsFrom,
by: {
key: $pageID
}
},
passOnwardsAs: "postCoreHeadingContentReplacementsFrom"
)
@applyField(
name: "_objectProperty",
arguments: {
object: $coreHeadingContentReplacementsTo,
by: {
key: $pageID
}
},
passOnwardsAs: "postCoreHeadingContentReplacementsTo"
)
@strRegexReplaceMultiple(
limit: 1,
searchRegex: $postCoreHeadingContentReplacementsFrom,
replaceWith: $postCoreHeadingContentReplacementsTo
)
@applyField(
name: "_propertyExistsInJSONObject"
arguments: {
object: $coreParagraphContentReplacementsFrom
by: { key: $pageID }
}
passOnwardsAs: "hasPageID"
)
@if(
condition: $hasPageID
affectDirectivesUnderPos: [1, 2, 3]
)
@applyField(
name: "_objectProperty",
arguments: {
object: $coreParagraphContentReplacementsFrom,
by: {
key: $pageID
}
},
passOnwardsAs: "postCoreParagraphContentReplacementsFrom"
)
@applyField(
name: "_objectProperty",
arguments: {
object: $coreParagraphContentReplacementsTo,
by: {
key: $pageID
}
},
passOnwardsAs: "postCoreParagraphContentReplacementsTo"
)
@strRegexReplaceMultiple(
limit: 1,
searchRegex: $postCoreParagraphContentReplacementsFrom,
replaceWith: $postCoreParagraphContentReplacementsTo
)
@applyField(
name: "_propertyExistsInJSONObject"
arguments: {
object: $coreImageAltReplacementsFrom
by: { key: $pageID }
}
passOnwardsAs: "hasPageID"
)
@if(
condition: $hasPageID
affectDirectivesUnderPos: [1, 2, 3]
)
@applyField(
name: "_objectProperty",
arguments: {
object: $coreImageAltReplacementsFrom,
by: {
key: $pageID
}
},
passOnwardsAs: "postCoreImageAltReplacementsFrom"
)
@applyField(
name: "_objectProperty",
arguments: {
object: $coreImageAltReplacementsTo,
by: {
key: $pageID
}
},
passOnwardsAs: "postCoreImageAltReplacementsTo"
)
@strRegexReplaceMultiple(
limit: 1,
searchRegex: $postCoreImageAltReplacementsFrom,
replaceWith: $postCoreImageAltReplacementsTo
)
@applyField(
name: "_propertyExistsInJSONObject"
arguments: {
object: $coreImageCaptionReplacementsFrom
by: { key: $pageID }
}
passOnwardsAs: "hasPageID"
)
@if(
condition: $hasPageID
affectDirectivesUnderPos: [1, 2, 3]
)
@applyField(
name: "_objectProperty",
arguments: {
object: $coreImageCaptionReplacementsFrom,
by: {
key: $pageID
}
},
passOnwardsAs: "postCoreImageCaptionReplacementsFrom"
)
@applyField(
name: "_objectProperty",
arguments: {
object: $coreImageCaptionReplacementsTo,
by: {
key: $pageID
}
},
passOnwardsAs: "postCoreImageCaptionReplacementsTo"
)
@strRegexReplaceMultiple(
limit: 1,
searchRegex: $postCoreImageCaptionReplacementsFrom,
replaceWith: $postCoreImageCaptionReplacementsTo
)
@applyField(
name: "_propertyExistsInJSONObject"
arguments: {
object: $coreButtonTextReplacementsFrom
by: { key: $pageID }
}
passOnwardsAs: "hasPageID"
)
@if(
condition: $hasPageID
affectDirectivesUnderPos: [1, 2, 3]
)
@applyField(
name: "_objectProperty",
arguments: {
object: $coreButtonTextReplacementsFrom,
by: {
key: $pageID
}
},
passOnwardsAs: "postCoreButtonTextReplacementsFrom"
)
@applyField(
name: "_objectProperty",
arguments: {
object: $coreButtonTextReplacementsTo,
by: {
key: $pageID
}
},
passOnwardsAs: "postCoreButtonTextReplacementsTo"
)
@strRegexReplaceMultiple(
limit: 1,
searchRegex: $postCoreButtonTextReplacementsFrom,
replaceWith: $postCoreButtonTextReplacementsTo
)
@applyField(
name: "_propertyExistsInJSONObject"
arguments: {
object: $coreTableCaptionReplacementsFrom
by: { key: $pageID }
}
passOnwardsAs: "hasPageID"
)
@if(
condition: $hasPageID
affectDirectivesUnderPos: [1, 2, 3]
)
@applyField(
name: "_objectProperty",
arguments: {
object: $coreTableCaptionReplacementsFrom,
by: {
key: $pageID
}
},
passOnwardsAs: "postCoreTableCaptionReplacementsFrom"
)
@applyField(
name: "_objectProperty",
arguments: {
object: $coreTableCaptionReplacementsTo,
by: {
key: $pageID
}
},
passOnwardsAs: "postCoreTableCaptionReplacementsTo"
)
@strRegexReplaceMultiple(
limit: 1,
searchRegex: $postCoreTableCaptionReplacementsFrom,
replaceWith: $postCoreTableCaptionReplacementsTo
)
@applyField(
name: "_propertyExistsInJSONObject"
arguments: {
object: $coreTableBodyCellsContentReplacementsFrom
by: { key: $pageID }
}
passOnwardsAs: "hasPageID"
)
@if(
condition: $hasPageID
affectDirectivesUnderPos: [1, 2, 3]
)
@applyField(
name: "_objectProperty",
arguments: {
object: $coreTableBodyCellsContentReplacementsFrom,
by: {
key: $pageID
}
},
passOnwardsAs: "postCoreTableBodyCellsContentReplacementsFrom"
)
@applyField(
name: "_objectProperty",
arguments: {
object: $coreTableBodyCellsContentReplacementsTo,
by: {
key: $pageID
}
},
passOnwardsAs: "postCoreTableBodyCellsContentReplacementsTo"
)
@strRegexReplaceMultiple(
limit: 1,
searchRegex: $postCoreTableBodyCellsContentReplacementsFrom,
replaceWith: $postCoreTableBodyCellsContentReplacementsTo
)
@applyField(
name: "_propertyExistsInJSONObject"
arguments: {
object: $coreListItemContentReplacementsFrom
by: { key: $pageID }
}
passOnwardsAs: "hasPageID"
)
@if(
condition: $hasPageID
affectDirectivesUnderPos: [1, 2, 3]
)
@applyField(
name: "_objectProperty",
arguments: {
object: $coreListItemContentReplacementsFrom,
by: {
key: $pageID
}
},
passOnwardsAs: "postCoreListItemContentReplacementsFrom"
)
@applyField(
name: "_objectProperty",
arguments: {
object: $coreListItemContentReplacementsTo,
by: {
key: $pageID
}
},
passOnwardsAs: "postCoreListItemContentReplacementsTo"
)
@strRegexReplaceMultiple(
limit: 1,
searchRegex: $postCoreListItemContentReplacementsFrom,
replaceWith: $postCoreListItemContentReplacementsTo
)
@applyField(
name: "_propertyExistsInJSONObject"
arguments: {
object: $coreCoverAltReplacementsFrom
by: { key: $pageID }
}
passOnwardsAs: "hasPageID"
)
@if(
condition: $hasPageID
affectDirectivesUnderPos: [1, 2, 3]
)
@applyField(
name: "_objectProperty",
arguments: {
object: $coreCoverAltReplacementsFrom,
by: {
key: $pageID
}
},
passOnwardsAs: "postCoreCoverAltReplacementsFrom"
)
@applyField(
name: "_objectProperty",
arguments: {
object: $coreCoverAltReplacementsTo,
by: {
key: $pageID
}
},
passOnwardsAs: "postCoreCoverAltReplacementsTo"
)
@strRegexReplaceMultiple(
limit: 1,
searchRegex: $postCoreCoverAltReplacementsFrom,
replaceWith: $postCoreCoverAltReplacementsTo
)
@applyField(
name: "_propertyExistsInJSONObject"
arguments: {
object: $coreMediaTextAltReplacementsFrom
by: { key: $pageID }
}
passOnwardsAs: "hasPageID"
)
@if(
condition: $hasPageID
affectDirectivesUnderPos: [1, 2, 3]
)
@applyField(
name: "_objectProperty",
arguments: {
object: $coreMediaTextAltReplacementsFrom,
by: {
key: $pageID
}
},
passOnwardsAs: "postCoreMediaTextAltReplacementsFrom"
)
@applyField(
name: "_objectProperty",
arguments: {
object: $coreMediaTextAltReplacementsTo,
by: {
key: $pageID
}
},
passOnwardsAs: "postCoreMediaTextAltReplacementsTo"
)
@strRegexReplaceMultiple(
limit: 1,
searchRegex: $postCoreMediaTextAltReplacementsFrom,
replaceWith: $postCoreMediaTextAltReplacementsTo
)
@applyField(
name: "_propertyExistsInJSONObject"
arguments: {
object: $coreVerseContentReplacementsFrom
by: { key: $pageID }
}
passOnwardsAs: "hasPageID"
)
@if(
condition: $hasPageID
affectDirectivesUnderPos: [1, 2, 3]
)
@applyField(
name: "_objectProperty",
arguments: {
object: $coreVerseContentReplacementsFrom,
by: {
key: $pageID
}
},
passOnwardsAs: "postCoreVerseContentReplacementsFrom"
)
@applyField(
name: "_objectProperty",
arguments: {
object: $coreVerseContentReplacementsTo,
by: {
key: $pageID
}
},
passOnwardsAs: "postCoreVerseContentReplacementsTo"
)
@strRegexReplaceMultiple(
limit: 1,
searchRegex: $postCoreVerseContentReplacementsFrom,
replaceWith: $postCoreVerseContentReplacementsTo
)
@applyField(
name: "_propertyExistsInJSONObject"
arguments: {
object: $coreQuoteCitationReplacementsFrom
by: { key: $pageID }
}
passOnwardsAs: "hasPageID"
)
@if(
condition: $hasPageID
affectDirectivesUnderPos: [1, 2, 3]
)
@applyField(
name: "_objectProperty",
arguments: {
object: $coreQuoteCitationReplacementsFrom,
by: {
key: $pageID
}
},
passOnwardsAs: "postCoreQuoteCitationReplacementsFrom"
)
@applyField(
name: "_objectProperty",
arguments: {
object: $coreQuoteCitationReplacementsTo,
by: {
key: $pageID
}
},
passOnwardsAs: "postCoreQuoteCitationReplacementsTo"
)
@strRegexReplaceMultiple(
limit: 1,
searchRegex: $postCoreQuoteCitationReplacementsFrom,
replaceWith: $postCoreQuoteCitationReplacementsTo
)
@applyField(
name: "_propertyExistsInJSONObject"
arguments: {
object: $corePullquoteCitationReplacementsFrom
by: { key: $pageID }
}
passOnwardsAs: "hasPageID"
)
@if(
condition: $hasPageID
affectDirectivesUnderPos: [1, 2, 3]
)
@applyField(
name: "_objectProperty",
arguments: {
object: $corePullquoteCitationReplacementsFrom,
by: {
key: $pageID
}
},
passOnwardsAs: "postCorePullquoteCitationReplacementsFrom"
)
@applyField(
name: "_objectProperty",
arguments: {
object: $corePullquoteCitationReplacementsTo,
by: {
key: $pageID
}
},
passOnwardsAs: "postCorePullquoteCitationReplacementsTo"
)
@strRegexReplaceMultiple(
limit: 1,
searchRegex: $postCorePullquoteCitationReplacementsFrom,
replaceWith: $postCorePullquoteCitationReplacementsTo
)
@applyField(
name: "_propertyExistsInJSONObject"
arguments: {
object: $corePullquoteValueReplacementsFrom
by: { key: $pageID }
}
passOnwardsAs: "hasPageID"
)
@if(
condition: $hasPageID
affectDirectivesUnderPos: [1, 2, 3]
)
@applyField(
name: "_objectProperty",
arguments: {
object: $corePullquoteValueReplacementsFrom,
by: {
key: $pageID
}
},
passOnwardsAs: "postCorePullquoteValueReplacementsFrom"
)
@applyField(
name: "_objectProperty",
arguments: {
object: $corePullquoteValueReplacementsTo,
by: {
key: $pageID
}
},
passOnwardsAs: "postCorePullquoteValueReplacementsTo"
)
@strRegexReplaceMultiple(
limit: 1,
searchRegex: $postCorePullquoteValueReplacementsFrom,
replaceWith: $postCorePullquoteValueReplacementsTo
)
@applyField(
name: "_propertyExistsInJSONObject"
arguments: {
object: $coreAudioCaptionReplacementsFrom
by: { key: $pageID }
}
passOnwardsAs: "hasPageID"
)
@if(
condition: $hasPageID
affectDirectivesUnderPos: [1, 2, 3]
)
@applyField(
name: "_objectProperty",
arguments: {
object: $coreAudioCaptionReplacementsFrom,
by: {
key: $pageID
}
},
passOnwardsAs: "postCoreAudioCaptionReplacementsFrom"
)
@applyField(
name: "_objectProperty",
arguments: {
object: $coreAudioCaptionReplacementsTo,
by: {
key: $pageID
}
},
passOnwardsAs: "postCoreAudioCaptionReplacementsTo"
)
@strRegexReplaceMultiple(
limit: 1,
searchRegex: $postCoreAudioCaptionReplacementsFrom,
replaceWith: $postCoreAudioCaptionReplacementsTo
)
@applyField(
name: "_propertyExistsInJSONObject"
arguments: {
object: $coreVideoCaptionReplacementsFrom
by: { key: $pageID }
}
passOnwardsAs: "hasPageID"
)
@if(
condition: $hasPageID
affectDirectivesUnderPos: [1, 2, 3]
)
@applyField(
name: "_objectProperty",
arguments: {
object: $coreVideoCaptionReplacementsFrom,
by: {
key: $pageID
}
},
passOnwardsAs: "postCoreVideoCaptionReplacementsFrom"
)
@applyField(
name: "_objectProperty",
arguments: {
object: $coreVideoCaptionReplacementsTo,
by: {
key: $pageID
}
},
passOnwardsAs: "postCoreVideoCaptionReplacementsTo"
)
@strRegexReplaceMultiple(
limit: 1,
searchRegex: $postCoreVideoCaptionReplacementsFrom,
replaceWith: $postCoreVideoCaptionReplacementsTo
)
@applyField(
name: "_propertyExistsInJSONObject"
arguments: {
object: $corePreformattedContentReplacementsFrom
by: { key: $pageID }
}
passOnwardsAs: "hasPageID"
)
@if(
condition: $hasPageID
affectDirectivesUnderPos: [1, 2, 3]
)
@applyField(
name: "_objectProperty",
arguments: {
object: $corePreformattedContentReplacementsFrom,
by: {
key: $pageID
}
},
passOnwardsAs: "postCorePreformattedContentReplacementsFrom"
)
@applyField(
name: "_objectProperty",
arguments: {
object: $corePreformattedContentReplacementsTo,
by: {
key: $pageID
}
},
passOnwardsAs: "postCorePreformattedContentReplacementsTo"
)
@strRegexReplaceMultiple(
limit: 1,
searchRegex: $postCorePreformattedContentReplacementsFrom,
replaceWith: $postCorePreformattedContentReplacementsTo
)
@applyField(
name: "_propertyExistsInJSONObject"
arguments: {
object: $coreEmbedCaptionReplacementsFrom
by: { key: $pageID }
}
passOnwardsAs: "hasPageID"
)
@if(
condition: $hasPageID
affectDirectivesUnderPos: [1, 2, 3]
)
@applyField(
name: "_objectProperty",
arguments: {
object: $coreEmbedCaptionReplacementsFrom,
by: {
key: $pageID
}
},
passOnwardsAs: "postCoreEmbedCaptionReplacementsFrom"
)
@applyField(
name: "_objectProperty",
arguments: {
object: $coreEmbedCaptionReplacementsTo,
by: {
key: $pageID
}
},
passOnwardsAs: "postCoreEmbedCaptionReplacementsTo"
)
@strRegexReplaceMultiple(
limit: 1,
searchRegex: $postCoreEmbedCaptionReplacementsFrom,
replaceWith: $postCoreEmbedCaptionReplacementsTo
)
@export(as: "transformedRawContent")
}
query PrepareMetaReplacements
@depends(on: "TransformData")
@include(if: $hasMasterPages)
{
transformedMetaTitle: _echo(value: $rawTitle)
@underEachJSONObjectProperty(
passKeyOnwardsAs: "pageID"
affectDirectivesUnderPos: [1, 2, 3]
)
@applyField(
name: "_sprintf",
arguments: {
string: "metaRawTitle.to.%s",
values: [$pageID]
}
passOnwardsAs: "titlePath"
)
@applyField(
name: "_objectProperty",
arguments: {
object: $transformations
by: { path: $titlePath }
}
passOnwardsAs: "transformedPostTitleAsArray"
)
@applyField(
name: "_arrayItem",
arguments: {
array: $transformedPostTitleAsArray
position: 0
}
setResultInResponse: true
)
@export(
as: "transformedRawTitle"
)
transformedMetaRawExcerpt: _echo(value: $rawExcerpt)
@underEachJSONObjectProperty(
passKeyOnwardsAs: "pageID"
affectDirectivesUnderPos: [1, 2, 3]
)
@applyField(
name: "_sprintf",
arguments: {
string: "metaRawExcerpt.to.%s",
values: [$pageID]
}
passOnwardsAs: "rawExcerptPath"
)
@applyField(
name: "_objectProperty",
arguments: {
object: $transformations
by: { path: $rawExcerptPath }
}
passOnwardsAs: "transformedPostRawExcerptAsArray"
)
@applyField(
name: "_arrayItem",
arguments: {
array: $transformedPostRawExcerptAsArray
position: 0
}
setResultInResponse: true
)
@export(
as: "transformedRawExcerpt"
)
}
query ExportMutationInputs(
$pageIDs: [ID!]! = []
$pageStatus: [CustomPostStatusEnum!]! = [publish]
)
@depends(on: [
"ExecuteRegexReplacements",
"PrepareMetaReplacements"
])
@include(if: $hasMasterPages)
{
exportPages: pages(filter: { ids: $pageIDs, status: $pageStatus }) {
id
transformedRawContent: _objectProperty(
object: $transformedRawContent,
by: {
key: $__id
}
)
transformedRawTitle: _objectProperty(
object: $transformedRawTitle,
by: {
key: $__id
}
)
transformedSlug: _echo(value: $__transformedRawTitle)
transformedRawExcerpt: _objectProperty(
object: $transformedRawExcerpt,
by: {
key: $__id
}
)
input: _echo(value: {
status: draft,
title: $__transformedRawTitle,
slug: $__transformedSlug,
excerpt: $__transformedRawExcerpt,
contentAs: {
html: $__transformedRawContent
}
})
@export(
as: "createPostMutationInputs"
type: LIST
)
}
}
mutation CreatePagesWithTranslationOnExternalSite
@depends(on: "ExportMutationInputs")
@include(if: $hasMasterPages)
{
createExternalSitePageHTTPRequests: _echo(value: $createPostMutationInputs)
@underEachArrayItem(
passValueOnwardsAs: "input"
)
@applyField(
name: "_sendGraphQLHTTPRequest"
arguments: {
input: {
endpoint: $endpoint,
query: """
mutation CreatePageFromMasterSite($input: JSONObject!) {
createPage(input: $input) {
status
errors {
__typename
...on ErrorPayload {
message
}
}
page {
id
slug
title
content
status
url
excerpt
}
}
}
""",
variables: [
{
name: "input",
value: $input
}
],
options: {
headers: [
{
name: "Authorization",
value: $authorizationHeaderValue
}
]
}
}
},
setResultInResponse: true
)
}