Skip Navigation

This topic contains 0 replies, has 1 voice.

Last updated by justinK-16 5 months, 1 week ago.

Assisted by: Lauren.

Author Posts
July 5, 2024 at 5:05 pm #15899545

justinK-16

Background of the issue:
I recently had contact with Kor - one of your supporters. However, I have no email chain and all was online, first via chat. I also can not locate the support thread. I had a problem with an Unlimited Elements widget - Kor did some faultfinding and then sent the issue to second tier support and came back with some code to add to our functions.php folder. It works and now translates and appears in the secondary language instead of being overwritten on the next ATE save. This is the code supplied by Kor:

// WPML Workaround for compsupp-7445
add_filter( 'elementor/frontend/before_render', 'wpml_compsupp7445_filter_ucaddon_post_grid');

function wpml_compsupp7445_filter_ucaddon_post_grid($element) {
if ( 'ucaddon_post_grid' !== $element->get_name() ) {
return;
}

$settings = $element->get_settings();

if ( isset( $settings['post_list_manual_select_post_ids'] ) && is_array( $settings['post_list_manual_select_post_ids'] ) ) {
foreach ( $settings['post_list_manual_select_post_ids'] as $key => $id ) {

$post_type = get_post_type( $id );

if ( ! $post_type ) {
continue;
}

$id = apply_filters( 'wpml_object_id', $id, $post_type, true );

unset($settings['post_list_manual_select_post_ids'][$key]);
$settings['post_list_manual_select_post_ids'][] = $id;
}

$element->set_settings( 'post_list_manual_select_post_ids', $settings['post_list_manual_select_post_ids'] );
}

if (isset($settings['post_list_manual_post_ids_dynamic'])) {
// Check if the IDs are in a string and convert them to an array
if (is_string($settings['post_list_manual_post_ids_dynamic'])) {
$settings['post_list_manual_post_ids_dynamic'] = explode(',', $settings['post_list_manual_post_ids_dynamic']);
}

// Proceed only if it's an array
if (is_array($settings['post_list_manual_post_ids_dynamic'])) {
foreach ($settings['post_list_manual_post_ids_dynamic'] as $key => $id) {
$post_type = get_post_type($id);
if (!$post_type) {
continue;
}
$translated_id = apply_filters('wpml_object_id', $id, $post_type, true);
$settings['post_list_manual_post_ids_dynamic'][$key] = $translated_id;
}
$element->set_settings('post_list_manual_post_ids_dynamic', $settings['post_list_manual_post_ids_dynamic']);
}
}
}

Symptoms:
One part of the Unlimited Elements widget is not being translated - it appears in English (the primary language) for all translated languages.
In the Post Grid Widget, this part is called the 'Intro'.

Questions:
if the change/correction to the code could be made to also display this filed in the translated language then all will be working perfectly 🙂

If Kor is available, maybe it would be helpful as he is recently familiar with the issue.

The topic ‘[Closed] Unlimited Elements Widget not translating correctly’ is closed to new replies.