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.

This topic contains 9 replies, has 2 voices.

Last updated by Andreas W. 5 months, 2 weeks ago.

Assigned support staff: Andreas W..

Author Posts
April 22, 2019 at 11:16 am #3655325

Puntorosso

Hi,
I would appreciate an advice for this scenario.

I use different JS scripts in a multilingual site (Analytics, GDPR, ....), and there's not a simple way to assign a different code/language, except a tedious and long "if .. then" in functions.php.

I thought I could use a plugin to insert the codes and use WPML to translate them, so that every language would have a different code inserted.

Does that makes sense?

I have checked some Header/Footer injector plugins, and they works fine, but all of them are not translatable.

Do you have a plugin or code suggestion?

Thanks

Best

April 22, 2019 at 3:43 pm #3656851

Puntorosso

I have tried this plugin, which works quiet well.
https://wordpress.org/plugins/insert-php/

The problem is that I cannot find a way to translate the snippet field of the plugin.

Any help is really appreciated.

Thanks

Best

April 22, 2019 at 5:48 pm #3657567

Andreas W.
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

Thank you for contacting WPML Support.

Please go to WPML -> String Translation and scroll to the bottom of the page. Now click the option "translate texts in admin screens".

Search for the domain of the plugin Insert PHP.

You should be able to find the string here and mark the checkbox. Then scroll to the bottom of the page to apply your changes.

The string should now be available on String Translation.

Let me know if you need any assistance with this task. In case, I enabled your next message to be private in order to provide access to your site.

Kind regards
Andreas

April 22, 2019 at 9:51 pm #3658445

Andreas W.
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

Additional to my last message I would like to request temporary access (wp-admin and FTP) to your site to take a better look at the issue. It would be better to a testing site where the issue is replicated.

You will find the needed fields for this below the comment area when you log in to leave your next reply. The information you will enter is private which means only you and I can see and have access to it.

Maybe I'll need to replicate your site locally. For this, I’ll need to temporarily install a plugin called “Duplicator” on your site. This will allow me to create a copy of your site and your content. Once the problem is resolved I will delete the local site. Let me know if this is ok with you.

IMPORTANT

Please make a backup of site files and database before providing us access.
If you do not see the wp-admin/FTP fields this means your post & website login details will be made PUBLIC. DO NOT post your website details unless you see the required wp-admin/FTP fields. If you do not, please ask me to enable the private box. The private box looks like this:
hidden link

Kind regards
Andreas

April 29, 2019 at 2:23 pm #3704333

Andreas W.
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

Thank you for your message.

Sadly, the wp-admin for your site ends in an 404 error. Could you please leave me short notification once the site is available again.

In the meantime could you please install a copy of the mentioned Snippets Plugin on the following test site in order for me to test it for compastibitlity with WPML?

One Click Login:hidden link

Please notify me once the sites are ready for testing.

Kind regards
Andreas

May 1, 2019 at 12:30 am #3715325

Puntorosso

Hi,

sorry for the typo.
Wordpress access is ......../test/wp-admin

Meanwhile I have installed the Woody plugin and an alternative one in your test site.

hidden link

Thanks

May 2, 2019 at 3:00 pm #3725809

Andreas W.
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

Thank you for your patience.

I have tested Woody Snippets on the test site. Please go to your snippets and change the admin language inisde of the top bar. Your should now be able to create snippets for ther selected language and obtain a shortcode for the page integration.

See screenshot for more details.

Let me know if this worked out.

Kind regards
Andreas

May 3, 2019 at 8:45 am #3732319

Puntorosso

Hi, I get your point, but this is only helpful if you use the shortcodes to insert the snippets in specifics pages.
Anyway you won't need to switch language for this, you can simply add new snippets in english and copy the relative shortcode where needed.

The problem is that you cannot add a snippet to be triggered in every page, but only when the user is in the "english" site and another one when is looking at the "german" version.

hidden link

For this you really need to "translate" the snippet.

Thanks

Best

May 3, 2019 at 2:38 pm #3735541

Andreas W.
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

Thank you for the clarification.

I am sorry for the misunderstanding, as I was not familiar with this plugin. I can see that the translation will not work if you use the automatic insertion feature.

I have escalated the issue to our compatibility team who will work on a solution as soon as possible and reach out to the plugin authors in order to implement the changes into their plugin.

I will be in contact with you as soon I receive feedback.

Kind regards
Andreas

May 9, 2019 at 3:20 pm #3777665

Andreas W.
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

We do have a fix for the issue with the Woody Snippets Plugin. Sadly the ULR for your test is unavailable at the moment.

Log into your server and include the following code in wp-content/plugins/insert-php/includes/class.execute.snippet.php line 287

replace the same part with this instead:

$join = '';
$where = '';
if ( apply_filters( 'wpml_setting', false, 'setup_complete' ) ) {
	$type = 'post_' . WINP_SNIPPETS_POST_TYPE;
	$join = " LEFT JOIN {$wpdb->prefix}icl_translations ON element_id = ID AND element_type = '$type'";

	$language = apply_filters( 'wpml_current_language', false );
	$where = " language_code = '$language' AND ";
}

$snippets = $wpdb->get_results( "SELECT {$wpdb->posts}.ID, {$wpdb->posts}.post_content
 					FROM {$wpdb->posts} $join
 					INNER JOIN {$wpdb->postmeta} ON ( {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id )
 					WHERE  $where  ( ( {$wpdb->postmeta}.meta_key = '" . WINP_Plugin::app()->getPrefix() . "snippet_scope' AND {$wpdb->postmeta}.meta_value = '{$scope}' )	) AND {$wpdb->posts}.post_type = '" . WINP_SNIPPETS_POST_TYPE . "' AND ( ({$wpdb->posts}.post_status = 'publish') )" );

Let me know if you need any further assistance.

Kind regards
Andreas