HooksHooks thực thi query
Hooks thực thi query
Gato AI Translations for Polylang thực thi queries GraphQL để thực hiện toàn bộ logic của nó:
- Tạo các mục dịch còn thiếu (bài viết, danh mục, thẻ, v.v.)
- Đồng bộ hóa dữ liệu giữa các ngôn ngữ
- Dịch nội dung
Ứng dụng của bạn có thể phản ứng với việc thực thi queries thông qua các action hook sau:
gatompl:query_execution_startgatompl:query_execution_end
Các hook nhận các tham số sau:
| Tham số | Mô tả | Ví dụ |
|---|---|---|
$querySlug | Slug của query cần thực thi | translate-customposts |
$queryVariables | Các biến được truyền vào query | ['customPostIds' => [123, 456], ...] |
gatompl:query_execution_start
Được kích hoạt ngay trước khi query được thực thi.
add_action(
'gatompl:query_execution_start',
/**
* @param array<string, mixed> $queryVariables The variables passed to the query.
*/
function (
string $querySlug,
array $queryVariables
): void {
// Do something
},
10,
2
);gatompl:query_execution_end
Được kích hoạt ngay sau khi query được thực thi.
add_action(
'gatompl:query_execution_start',
/**
* @param array<string, mixed> $queryVariables The variables passed to the query.
*/
function (
string $querySlug,
array $queryVariables
): void {
// Do something
},
10,
2
);Slug của các queries
Các slug query được hỗ trợ là:
create-missing-translation-categoriescreate-missing-translation-custompostscreate-missing-translation-mediacreate-missing-translation-tagssync-category-meta-entry-deletionsync-custompost-categoriessync-custompost-featuredimagesync-custompost-meta-entry-deletionsync-custompost-tagssync-tag-meta-entry-deletiontranslate-categoriestranslate-custompoststranslate-mediatranslate-tags