Hooks
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_start
  • gatompl:query_execution_end

Các hook nhận các tham số sau:

Tham sốMô tảVí dụ
$querySlugSlug của query cần thực thitranslate-customposts
$queryVariablesCá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-categories
  • create-missing-translation-customposts
  • create-missing-translation-media
  • create-missing-translation-tags
  • sync-category-meta-entry-deletion
  • sync-custompost-categories
  • sync-custompost-featuredimage
  • sync-custompost-meta-entry-deletion
  • sync-custompost-tags
  • sync-tag-meta-entry-deletion
  • translate-categories
  • translate-customposts
  • translate-media
  • translate-tags