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.

This topic contains 17 replies, has 7 voices.

Last updated by mohammeda-24 4 years, 1 month ago.

Assisted by: Bruno Kos.

Author Posts
December 16, 2020 at 8:43 pm #7680917

François Duroy

I am trying to: migrate my local WP website to an online staging environment

Link to a page where the issue can be seen: hidden link

I expected to see: an horizontal language switcher with css applied to

    tag as we usually do it for menu

    Instead, I got: a vertical language switcher (dropdown mode) and no css applied.

    The project has no bug on the local env and the language switcher is horizontal with css applied.

    The database and WP files deployment went smoothly but when visiting the file we noted that bug in the header.

    After investigating, we noticed a wrong URL in that the wp-options table. That record is about the language switcher preferences and some css.

    In the wp-options table, search for the string ´wpml_language_switcher_template_objects´ and check the option_value column.

    Basically, the URL pointing to some settings done withing the "Languages section" of WPML admin panel is messed up. Instead of ".../wp-content/plugings/..." we have ".../ontent/plugings/...". This wrong URL is showing at several places in that column value.

    When we replace that URL, it gets overriden eventually as if the plugin wanted to keep the URL like this.

    And when I try to change the settings inside the WPML admin, like switching from horizontal to vertical, save and then back to kind of try to override that value I am actually stuck and cannot even apply those changes.

url-wrong-rewriting-in-db3.png
url-wrong-rewriting-in-db2.png
url-wrong-rewriting-in-db.png
December 17, 2020 at 8:53 am #7683629

François Duroy

I am waiting for an assistance on this issue, thanks a lot... (have to write this because of the robot notification announcing the ticket will be closed)

December 17, 2020 at 1:04 pm #7685473

George Botsev
Supporter

Languages: English (English )

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

Hello!
The issue that you describe looks to me, as if there were corrupted settings during a migration perhaps.
Perhaps you should go to the options table in WordPress and remove the key: "wpml_language_switcher_template_objects" as it might contain wrong path to the css assets that need to be loaded.

Please always remember to create at least a database backup before modifying the database, and in best scenario - a full website backup.

December 17, 2020 at 1:05 pm #7685479

George Botsev
Supporter

Languages: English (English )

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

You might have to re-save the language switcher first, in order to have everything working.

December 17, 2020 at 4:29 pm #7687563

François Duroy

Hi George,

I disagree with your opinion.

The migration I made worked locally.
One WP local project (n°1) was migrated to another WP local project (n°2): --> No problem.

Then the deploy on the online staging, done with project n°2, was successful ! Not one problem but that WPML record!

But, I may ask my colleague to delete that record if you think it can be done safely and apply those settings again manually with the WPML Admin dashboard to let's say create a brand new record and see how it goes...

Do you confirm it's safe doing it this way???

December 17, 2020 at 7:33 pm #7688713

François Duroy

Hello George,

I didn't wait for your confirmation for that DB record removal.

We need that staging ready as soon as possible and we got actually delayed a lot by using WPML plugin: 2 bugs with you guys !

It is taking time to report and slowing the dev down...

Here are the steps we did to try and solve that problem:

1) We deleted the record from the online database, it was recreated automatically..!
2) We deleted the language widget switcher from wp admin..The record that was (re)created automatically was still there ! So the deletion would not remove the record from the DB
3) We deleted that record from the online database.
4) We created a new language widget switcher from wp admin..
5) The same weird ULR was applied.. (so nothing to do with migration here !)
6) We deleted the language widget switcher again.
7) We decided to restart the GCP container with a DB dump from which we took care removing that record...The record was recreated anyway after restart

Please could you give us clear instructions because we really don't know what to do !

Thanks very much in advance for your help

December 20, 2020 at 6:26 am #7702677

Andreas W.
Supporter

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

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

Hello,

This is a really very odd issue.

The language switcher is applied into the Elementor Template "Uci Header 2" as Custom Language Switcher.

Now, it appears on the site, which makes me wonder, as the option for Custom Language Switcher is not even enabled in WPML -> LAnguages -> Custom Language Switcher.

Then I see you are calling the class .wpml-ls-legacy-list-horizontal in your child-theme CSS.

But in fact, the element has applied those classes, whihc might be related to the Elementor Language Switcher Widget itself:

<div class="wpml-ls-statics-shortcode_actions wpml-ls wpml-ls-legacy-list-vertical">
	<ul>

					<li class="wpml-ls-slot-shortcode_actions wpml-ls-item wpml-ls-item-pt-pt wpml-ls-current-language wpml-ls-first-item wpml-ls-item-legacy-list-vertical">
				<a href="#" class="wpml-ls-link"><span class="wpml-ls-native">PT</span></a>
			</li>
					<li class="wpml-ls-slot-shortcode_actions wpml-ls-item wpml-ls-item-fr wpml-ls-item-legacy-list-vertical">
				<a href="#" class="wpml-ls-link"><span class="wpml-ls-native" lang="fr">FR</span></a>
			</li>
					<li class="wpml-ls-slot-shortcode_actions wpml-ls-item wpml-ls-item-en wpml-ls-last-item wpml-ls-item-legacy-list-vertical">
				<a href="#" class="wpml-ls-link"><span class="wpml-ls-native" lang="en">EN</span></a>
			</li>
		
	</ul>
</div>

Now, what I could do as a quick fix, was adding some positioning and custom CSS inside the Elementor Template Editor. See screenshots. I do not see a problem here, only issue is that thos language switcher should not show up as long inside WPML the Custom Language Switcher is disabled.

Could you please add Elementor PRO and the Astra Theme in their latest versions to this sandbox, as we should try to recreate this issue:

One-Click-Login:
hidden link

IMPORTANT: Leave us a short notification once the componenets are installed.

Best regards
Andreas

template language switcher positioning.png
CSS.png
December 20, 2020 at 4:37 pm #7704313

Bruno Kos
Supporter

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

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

Hi,

It seems like that this bug has been reported before:
https://wpml.org/forums/topic/wplml-style-sheet-is-getting-truncated-into-ontent/#post-6086511
https://wpml.org/fr/forums/topic/url-tronquee-language-switchers-legacy-list-horizontal/#post-4721645 (see this URL for that client setup, they are using special Docker environment under Bitnami.)

If possible, I suggest you go over that second thread and translate from French in case you don't speak the language.

Looks like a quite specific and difficult issue without solution in sight, even though it has been escalated to developers some time ago. It is possibly not even solvable now based on how we compare the length of one path to the length of the resultant path.

According to development ticket, it happens if something like this is used:

define('WP_PLUGIN_DIR', 'E:\laragon\www\wp-content\plugins');

It does not match the base path because of:

$relative_path = substr( $path, strlen( $base['path'] ) );

So it trims the url. It might also happen if the hosting service is hardcoding ABSPATH to implement their WordPress hosting service.

The only workaround that was suggested there was to copy the template file (so /sitepress-multilingual-cms/templates/language-switchers/legacy-list-vertical/style.css?ver=1) into your theme and load it from there.

All this being said, this issue has been escalated to WPML developers already and I will keep this thread updated as soon as I get any new information from them! However since there have been no movement there for a while, I suggest you try implementing this CSS through theme or any other means (so like https://developer.wordpress.org/themes/basics/including-css-javascript/#stylesheets).

Regards,
Bruno Kos

December 22, 2020 at 2:41 pm #7717505

François Duroy

Hello again Andreas,

Thanks for your assistance.

Please excuse me if I say stupid things but my experience with the plugin is really short.

I was actually not working with Custom Language Switcher but with Widget Language Switcher.

When trying to debug that DB problem with my colleague, we deleted it (the widget) and re-created it to see if it had any impact on the database. See the steps described above within my message to George.

So I must have ended up without any widget language switcher when I left it for you to take it over. This is why there is nothing today but there was before.. See the printscreen below.

I see now the website is different from your printscreen..The logo is missing. I personaly did not touch anything in order not to add another layer of mess.

Regarding this sandbox, it's the first time I am working with this.. just to make sure, you only want me to download and activate Astra and add Elementor Pro and activate it there, that's all?

Thanks for your assistance

url-wrong-rewriting-in-db3.png
logo_gone.png
December 22, 2020 at 2:44 pm #7717631

Bruno Kos
Supporter

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

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

Hi,

I took over this ticket and analyse it - have you seen this reply of mine?
https://wpml.org/forums/topic/language-switcher-settings-url-values-in-wp-options-table-with-messed-up-path/#post-7704313

Regards,
Bruno Kos

December 22, 2020 at 2:49 pm #7717651

François Duroy

Hi Bruno, I was first answering Andreas's message before answering yours..
I am going to read your links now..
I will let you know..
THanks

December 22, 2020 at 3:18 pm #7717881

François Duroy

Hello again Bruno,

Ok, so the workaround is to copy that css file into my child theme, right?

I get it.. but what do you mean by "Load it from there"?

I suppose the css file is set up with values coming from me making choices in the WPML Language section when editing the widget switcher..

How am I suppose to indicate the plugin that the css file is somewhere else than the default location?

December 22, 2020 at 3:31 pm #7717953

François Duroy

Oh sorry I missed that link in the other post..

All right so just adding the css rules somewhere else and not style anything in the WPML widget switcher admin panel I guess??

At the moment, the database is acting weird with that record, and therefore the widget switcher is not functioning anymore.

So what shall I do?
Should I first work locally, make sure the widget is deleted in the admin, delete that record in DB, then add the css rules in my child theme and try to push everything again in prod?

December 22, 2020 at 3:53 pm #7718161

Bruno Kos
Supporter

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

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

Hi,

Ok, here is the deal - if you open this url and check the chrome console, you will find many 404 files - hidden link

These are 404 because of wrong url, so like:
hidden link

etc.

But should be:
hidden link

on which if you replace "wp-content" with "ontent", you get these files.

So If got our 2nd tier right (they didn't have many ideas either), you should:
- set your language switcher templates
- get all these CSS files from the above urls, so from /wp-content/plugins/sitepress-multilingual-cms/templates/language-switchers/legacy-dropdown/
- add them into your theme files and enqueue using https://developer.wordpress.org/themes/basics/including-css-javascript/#stylesheets

Or you can also see this:
https://wpml.org/documentation/getting-started-guide/language-setup/designing-custom-language-switchers-using-template-files/#adding-a-language-switcher-template-to-your-theme

Regards,
Bruno Kos

404s.jpg
December 22, 2020 at 7:19 pm #7719469

François Duroy

Thanks Bruno,
The workaround is working as a charm.
I ended up forgetting about the widget and created a custom switcher then dropped those files in my child theme as you advised me.
The thing now is to get rid of that record in the database..
But it's another story..
Let me know if a better solution comes up !
Thanks again
Best regards, merry xmas and happy new year

20201222_workaround.png