Plugin Directory


Ignore:
Timestamp:
10/25/2026 06:29:16 AM (27 hours ago)
Author:
avakodeforge
Message:

Release 1.3.0 (trunk + tag; see readme changelog)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • langforge/trunk/langforge.php

    r3752345 r3764005  
    44 * Plugin URI: https://langforgewp.com
    55 * 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.12
     6 * Version: 1.3.0
    77 * Author: Avakode
    88 * Author URI: https://avakode.com
    … …  
    1919}
    2020
    21 define('LANGFORGE_VERSION', '1.2.12');
     21define('LANGFORGE_VERSION', '1.3.0');
    2222// Schema version is independent from plugin version. Bump only when one of
    2323// the langforge_* tables changes shape; LANGFORGE_Schema::maybe_upgrade compares
    … …  
    391391
    392392        // - 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.
    400402
    401403        // - Posts / pages / custom post types: consult LangForge's native table
    … …  
    426428
    427429        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;
    428433            $wpml_type = (strpos($element_type, 'tax_') === 0) ? $element_type : 'tax_' . $element_type;
    429434            $found = $wpml_lookup($element_id, $wpml_type);
    … …  
    475480
    476481/**
     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 */
     490function 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}
     505add_action('init', 'langforge_wpml_language_constants', 2);
     506
     507/**
    477508 * Detect whether the real WPML (sitepress-multilingual-cms) is or is
    478509 * about to be active in the current request. Used by the WPML
Note: See TracChangeset for help on using the changeset viewer.