Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 8:00 – 13:00 9:00 – 13:00 9:00 – 13:00 8:00 – 12:00 8:00 – 12:00 -
- 14:00 – 17:00 14:00 – 18:00 14:00 – 18:00 13:00 – 17:00 13:00 – 17:00 -

Supporter timezone: Europe/Zagreb (GMT+02:00)

This topic contains 1 reply, has 2 voices.

Last updated by Bruno Kos 1 year, 1 month ago.

Assisted by: Bruno Kos.

Author Posts
March 13, 2024 at 12:00 pm #15403552

lindas-13

Hello,

We detected issue in our backend with some template regarding WPML.

Here is the error we are getting:
Got error 'PHP message: PHP Warning: Undefined array key "template_id" in /home/runcloud/webapps/JobSquad/wp-content/plugins/sitepress-multilingual-cms/addons/wpml-page-builders/classes/Integrations/Elementor/class-wpml-elementor-translate-ids.php on line 117PHP message: PHP Warning: Undefined array key "template_id" in /home/runcloud/webapps/JobSquad/wp-content/plugins/sitepress-multilingual-cms/addons/wpml-page-builders/classes/Integrations/Elementor/class-wpml-elementor-translate-ids.php on line 117'

March 13, 2024 at 3:54 pm #15405433

Bruno Kos
WPML Supporter since 12/2018

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+02:00)

Hi,

Thank you for contacting WPML support!

Can you please check if this issue appears when:

- only WPML plugins (along with Elementor as I suppose this is related to Elementor) are activated, as it will tell us if there is an interaction issue with other plugin
- theme is set to a WordPress default like Twenty Twenty as it will tell us if there is an interaction issue with your theme

Maybe your theme or some other plugin expects a translated template ID somewhere.

If it still appears, can you try this - in sitepress-multilingual-cms\addons\wpml-page-builders\classes\Integrations\Elementor\class-wpml-elementor-translate-ids.php, can you replace:

	public function translate_global_widget_ids( $data_array, $post_id ) {
		foreach ( $data_array as &$data ) {
			if ( isset( $data['elType'] ) && 'widget' === $data['elType'] ) {
				if ( 'global' === $data['widgetType'] ) {
					$data['templateID'] = $this->translate_id( $data['templateID'] );
				} elseif ( 'template' === $data['widgetType'] ) {
					$data['settings']['template_id'] = $this->translate_id( $data['settings']['template_id'] );
				}
			}
			$data['elements'] = $this->translate_global_widget_ids( $data['elements'], $post_id );
		}

		return $data_array;
	}

with:

public function translate_global_widget_ids( $data_array, $post_id ) {
    foreach ( $data_array as &$data ) {
        if ( isset( $data['elType'] ) && 'widget' === $data['elType'] ) {
            if ( 'global' === $data['widgetType'] ) {
                $data['templateID'] = $this->translate_id( $data['templateID'] );
            } elseif ( 'template' === $data['widgetType'] ) {
                if ( isset( $data['settings']['template_id'] ) ) {
                    $data['settings']['template_id'] = $this->translate_id( $data['settings']['template_id'] );
                } else {
                    // Log the missing ID along with other relevant information
                    error_log( 'Missing template_id for widget: ' . json_encode( $data ) );
                    // Optionally, you can set a default value
                    // $data['settings']['template_id'] = '';
                    
                    // If you want to log into WordPress system log, you can use the following instead
                    if ( defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) {
                        // Append the message to the WordPress debug log
                        error_log( 'Missing template_id for widget: ' . json_encode( $data ), 3, WP_CONTENT_DIR . 'https://cdn.wpml.org/debug.log' );
                    }
                }
            }
        }
        $data['elements'] = $this->translate_global_widget_ids( $data['elements'], $post_id );
    }

    return $data_array;
}

The error messages will be logged into the WordPress system log, which you can access via the debug.log file in the wp-content directory of your WordPress installation.

Regards,
Bruno Kos

The topic ‘[Closed] Warning in "template_id"’ is closed to new replies.