Skip to content

Fix EA Post Grid | Polylang: translate saved templates & pin Post Grid query language#825

Open
ZebaAfiaShama wants to merge 1 commit into
WPDevelopers:dev-prfrom
ZebaAfiaShama:fix/polylang-saved-template-translation
Open

Fix EA Post Grid | Polylang: translate saved templates & pin Post Grid query language#825
ZebaAfiaShama wants to merge 1 commit into
WPDevelopers:dev-prfrom
ZebaAfiaShama:fix/polylang-saved-template-translation

Conversation

@ZebaAfiaShama

Copy link
Copy Markdown

Saved templates embedded in EA widgets (Advanced Tabs, Advanced Accordion, Info Box, Flip Box, CTA Box, Countdown, Data Table) always rendered the source-language template on Polylang sites, and Post Grids could show posts from the wrong language.

Root causes:

  • Template translation used post type 'wp_template'; EA saved templates are 'elementor_library', so the wpml_object_id lookup never matched and returned the original id unchanged.
  • Polylang ships no Elementor integration, so elementor_library is not a translatable post type and the central documents/get/post_id translation filter was disabled (gated to WPML only).
  • Post Grid query had no language pinning, so it followed the ambient (cookie / last-page-load) language instead of the page's own language.

Fixes:

  • Correct post type 'wp_template' -> 'elementor_library' in all saved-template wpml_object_id calls.
  • Make eael_wpml_template_translation() Polylang-native via pll_get_post(), and re-enable the elementor/documents/get/post_id filter for Polylang.
  • Register elementor_library as translatable via pll_get_post_types.
  • Pin the Post Grid query to the page/document language (new Helper::eael_get_current_language()), with an eael/post_grid/query_lang filter.
  • Add a language suffix to Post Grid transient cache keys to avoid collisions between translated pages that share a widget id.

Saved templates embedded in EA widgets (Advanced Tabs, Advanced Accordion,
Info Box, Flip Box, CTA Box, Countdown, Data Table) always rendered the
source-language template on Polylang sites, and Post Grids could show posts
from the wrong language.

Root causes:
- Template translation used post type 'wp_template'; EA saved templates are
  'elementor_library', so the wpml_object_id lookup never matched and returned
  the original id unchanged.
- Polylang ships no Elementor integration, so elementor_library is not a
  translatable post type and the central documents/get/post_id translation
  filter was disabled (gated to WPML only).
- Post Grid query had no language pinning, so it followed the ambient
  (cookie / last-page-load) language instead of the page's own language.

Fixes:
- Correct post type 'wp_template' -> 'elementor_library' in all saved-template
  wpml_object_id calls.
- Make eael_wpml_template_translation() Polylang-native via pll_get_post(), and
  re-enable the elementor/documents/get/post_id filter for Polylang.
- Register elementor_library as translatable via pll_get_post_types.
- Pin the Post Grid query to the page/document language (new
  Helper::eael_get_current_language()), with an eael/post_grid/query_lang filter.
- Add a language suffix to Post Grid transient cache keys to avoid collisions
  between translated pages that share a widget id.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant