Changeset 3764005 for langforge/trunk/langforge.php
- Timestamp:
- 10/25/2026 06:29:16 AM (27 hours ago)
- File:
-
- 1 edited
-
langforge/trunk/langforge.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
langforge/trunk/langforge.php
r3752345 r3764005 4 4 * Plugin URI: https://langforgewp.com 5 5 * Description: Multilingual plugin for WordPress — language routing (4 URL formats), manual translation, language switcher, string translation, hreflang SEO, Glossary, WooCommerce, unlimited languages, REST/WP-CLI, WPML compatibility, and one-click migration. AI translation available via the Lang Forge Pro add-on. 6 * Version: 1. 2.126 * Version: 1.3.0 7 7 * Author: Avakode 8 8 * Author URI: https://avakode.com … … 19 19 } 20 20 21 define('LANGFORGE_VERSION', '1. 2.12');21 define('LANGFORGE_VERSION', '1.3.0'); 22 22 // Schema version is independent from plugin version. Bump only when one of 23 23 // the langforge_* tables changes shape; LANGFORGE_Schema::maybe_upgrade compares … … 391 391 392 392 // - Taxonomy terms (`category`, `post_tag`, `tax_*`, any registered taxonomy): 393 // prefer the legacy WPML table `wp_icl_translations`. LangForge's own 394 // `get_translation_id` doesn't filter by element_type, so a stray row 395 // with the same element_id under a different element_type (e.g. an 396 // acf-field-group row carrying a numeric ID that happens to match a 397 // term_id) returns the wrong translation. Filtering by element_type 398 // via wp_icl_translations gives a clean lookup that matches WPML's 399 // behavior even on partly-migrated sites. 393 // LangForge's own term pairs first (LANGFORGE_Taxonomy_Translation, 394 // element_type `tax_<taxonomy>`: the lookup is strictly by taxonomy), then 395 // the legacy WPML table `wp_icl_translations`. The post lookup of 396 // `get_translations` is never asked for a term: it doesn't filter by 397 // element_type, so a stray row with the same element_id under a different 398 // element_type (e.g. an acf-field-group row carrying a numeric ID that 399 // happens to match a term_id) returns the wrong translation. The legacy 400 // table is filtered by element_type too, which matches WPML's behavior 401 // even on partly-migrated sites. 400 402 401 403 // - Posts / pages / custom post types: consult LangForge's native table … … 426 428 427 429 if ($is_term_type) { 430 // Lang's own pairs of terms first (strictly by taxonomy), the legacy table only as the fallback. 431 $own = LANGFORGE_Post_Translation::instance()->get_term_translation_id($element_id, $element_type, $language_code); 432 if ($own !== null) return $own; 428 433 $wpml_type = (strpos($element_type, 'tax_') === 0) ? $element_type : 'tax_' . $element_type; 429 434 $found = $wpml_lookup($element_id, $wpml_type); … … 475 480 476 481 /** 482 * WPML's language constants (BUG-LANG-INTEG-01). WPML defines ICL_LANGUAGE_CODE, ICL_LANGUAGE_NAME and 483 * ICL_LANGUAGE_NAME_EN together with the filters above, and a neighbour that sees the filters reads the 484 * constants next: WP Recipe Maker stops every post.php with "Undefined constant ICL_LANGUAGE_CODE" without 485 * them. Polylang's WPML layer defines the same three, so neighbours already live with them and no SitePress. 486 * 487 * Defined on init 2, after detect_language on init 1 has settled the language of the request. Never when 488 * the real WPML is in play (it defines them itself) nor when another plugin got there first. 489 */ 490 function langforge_wpml_language_constants() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- intentional ACF/WPML/core compatibility 491 if (langforge_wpml_real_plugin_in_play() || defined('ICL_LANGUAGE_CODE')) { 492 return; 493 } 494 $core = LANGFORGE_Core::instance(); 495 $code = $core->get_current_language(); 496 $info = $core->get_language_info($code) ?: []; 497 define('ICL_LANGUAGE_CODE', $code); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- WPML's own constant, read by neighbours 498 if (!defined('ICL_LANGUAGE_NAME')) { 499 define('ICL_LANGUAGE_NAME', $info['native_name'] ?? $code); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- WPML's own constant, read by neighbours 500 } 501 if (!defined('ICL_LANGUAGE_NAME_EN')) { 502 define('ICL_LANGUAGE_NAME_EN', $info['name'] ?? $code); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- WPML's own constant, read by neighbours 503 } 504 } 505 add_action('init', 'langforge_wpml_language_constants', 2); 506 507 /** 477 508 * Detect whether the real WPML (sitepress-multilingual-cms) is or is 478 509 * about to be active in the current request. Used by the WPML
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)