WPML Translate term meta not synced

Question

If we have a term_meta named icon which gets an integer and is set to copy when you translate a term with this meta programmatically it won’t get copied to the translated term.

        $ok = wp_insert_term("s", "feature");
        update_term_meta($ok["term_id"], "icon", 54);
        $ok2 = wp_insert_term("س", "feature");
        $taxonomy = "feature";
        $wpml_element_type = apply_filters("wpml_element_type", "feature");
        $originalElementId = get_term($ok["term_id"])->term_taxonomy_id;

        global $sitepress;
        $trid = $sitepress->get_element_trid(
            $originalElementId,
            "tax_" . $taxonomy
        );
        $sitepress->set_element_language_details(
            get_term($ok2["term_id"])->term_taxonomy_id,
            "tax_" . $taxonomy,
            $trid,
            "fa",
            $sitepress->get_default_language()
        );

        $ttid = apply_filters(
            "wpml_get_element_translations_filter",
            "",
            $trid,
            $wpml_element_type
        )["fa"]->term_id;

//        wp_update_term($ok2["term_id"], $taxonomy, []);
        dd(
            get_term($ttid),
            get_term_meta($ttid),
            get_term_meta($ok["term_id"])
        );

the output is:

WP_Term]8;;file:///Volumes/HDD/Websites/central-graphql/wp-includes/class-wp-term.php#L18\^]8;;\ {#7032
  +term_id: 196
  +name: "س"
  +slug: "%d8%b3"
  +term_group: 0
  +term_taxonomy_id: 174
  +taxonomy: "feature"
  +description: ""
  +parent: 0
  +count: 0
  +filter: "raw"
}
[]
array:1 [
  "icon" => array:1 [
    0 => "54"
  ]
]

I used this in phpunit, it shows the term meta is not copied.

0
Steve Moretz 1 month 2022-12-21T10:06:47-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse