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
10:00 – 14:00 10:00 – 14:00 10:00 – 14:00 10:00 – 14:00 10:00 – 14:00 - -
16:00 – 20:00 16:00 – 20:00 16:00 – 20:00 16:00 – 20:00 16:00 – 20:00 - -

Supporter timezone: Asia/Jerusalem (GMT+03:00)

Tagged: 

This topic contains 3 replies, has 1 voice.

Last updated by Itamar 1 day, 2 hours ago.

Assisted by: Itamar.

Author Posts
July 6, 2025 at 9:11 am #17204739

desireeM

Background of the issue:
Similar to what I reported (and was fixed) in https://wpml.org/forums/topic/icl_string_positions-position_in_page-should-be-relative/
You cannot store absolute paths, full URLs or paths/URLs that include WP_CONTENT_DIR, WP_PLUGIN_DIR, WP_PLUGIN_URL,... in an option.

icl_sitepress_settings option:
...s:22:"theme_language_folders";a:1:{s:6:"parent";s:74:"/redacted/path/to/wp-content/theme/content/framework/languages";}...
Additionally, by saving the wp-content/theme path, this will break when WP_CONTENT_DIR,... constants are changed in wp-config. You should only store the theme path and build it dynamically when using it.

Same issue for these 2 options:
wcml_currency_switcher_template_objects
wpml_disabled_switcher_template_objects
Here additionally, you also store full URLs, which means it will break when the domain is changed and also for the above WP_CONTENT_DIR case too, as well as obviously for when the absolute path/ABSPATH changes.

'wpml_disabled_switcher_template_objects','a:6:{s:20:"wpml-legacy-dropdown";a:12:{s:4:"path";a:2:{i:0;s:101:"/redacted/path/to/wp-content/plugins/sitepress-multilingual-cms/templates/language-switchers";i:1;s:117:"/redacted/path/to/wp-content/plugins/sitepress-multilingual-cms/templates/language-switchers/legacy-dropdown";}s:7:"version";s:1:"1";s:4:"name";s:8:"Dropdown";s:4:"slug";s:20:"wpml-legacy-dropdown";s:8:"base_uri";s:118:"hidden link";s:3:"css";a:2:{i:0;s:127:"hidden link";i:1;s:131:"hidden link";}s:2:"js";a:2:{i:0;s:127:"hidden link";i:1;s:131:"hidden link";}s:14:"flags_base_uri";N;s:14:"flag_extension";N;s:7:"is_core";b:1;s:3:"for";a:2:{i:0;s:8:"sidebars";i:1;s:17:"shortcode_actions";}s:14:"force_settings";a:1:{s:29:"display_link_for_current_lang";i:1;}}s:26:"wpml-legacy-dropdown-click";a:12:{s:4:"path";a:2:{i:0;s:101:"/redacted/path/to/wp-content/plugins/sitepress-multilingual-cms/templates/language-switchers";i:1;s:123:"/redacted/path/to/wp-content/plugins/sitepress-multilingual-cms/templates/language-switchers/legacy-dropdown-click";}s:7:"version";s:1:"1";s:4:"name";s:14:"Dropdown click";s:4:"slug";s:26:"wpml-legacy-dropdown-click";s:8:"base_uri";s:124:"hidden link";s:3:"css";a:2:{i:0;s:133:"hidden link";i:1;s:137:"hidden link";}s:2:"js";a:2:{i:0;s:133:"hidden link";i:1;s:137:"hidden link";}s:14:"flags_base_uri";N;s:14:"flag_extension";N;s:7:"is_core";b:1;s:3:"for";a:2:{i:0;s:8:"sidebars";i:1;s:17:"shortcode_actions";}s:14:"force_settings";a:1:{s:29:"display_link_for_current_lang";i:1;}}s:27:"wpml-legacy-horizontal-list";a:12:{s:4:"path";a:2:{i:0;s:101:"/redacted/path/to/wp-content/plugins/sitepress-multilingual-cms/templates/language-switchers";i:1;s:124:"/redacted/path/to/wp-content/plugins/sitepress-multilingual-cms/templates/language-switchers/legacy-list-horizontal";}s:7:"version";s:1:"1";s:4:"name";s:15:"Horizontal List";s:4:"slug";s:27:"wpml-legacy-horizontal-list";s:8:"base_uri";s:125:"hidden link";s:3:"css";a:2:{i:0;s:134:"hidden link";i:1;s:138:"hidden link";}s:2:"js";a:0:{}s:14:"flags_base_uri";N;s:14:"flag_extension";N;s:7:"is_core";b:1;s:3:"for";a:3:{i:0;s:8:"sidebars";i:1;s:6:"footer";i:2;s:17:"shortcode_actions";}s:14:"force_settings";a:0:{}}s:25:"wpml-legacy-vertical-list";a:12:{s:4:"path";a:2:{i:0;s:101:"/redacted/path/to/wp-content/plugins/sitepress-multilingual-cms/templates/language-switchers";i:1;s:122:"/redacted/path/to/wp-content/plugins/sitepress-multilingual-cms/templates/language-switchers/legacy-list-vertical";}s:7:"version";s:1:"1";s:4:"name";s:13:"Vertical List";s:4:"slug";s:25:"wpml-legacy-vertical-list";s:8:"base_uri";s:123:"hidden link";s:3:"css";a:2:{i:0;s:132:"hidden link";i:1;s:136:"hidden link";}s:2:"js";a:0:{}s:14:"flags_base_uri";N;s:14:"flag_extension";N;s:7:"is_core";b:1;s:3:"for";a:3:{i:0;s:8:"sidebars";i:1;s:6:"footer";i:2;s:17:"shortcode_actions";}s:14:"force_settings";a:0:{}}s:29:"wpml-legacy-post-translations";a:12:{s:4:"path";a:2:{i:0;s:101:"/redacted/path/to/wp-content/plugins/sitepress-multilingual-cms/templates/language-switchers";i:1;s:126:"/redacted/path/to/wp-content/plugins/sitepress-multilingual-cms/templates/language-switchers/legacy-post-translations";}s:7:"version";s:1:"1";s:4:"name";s:17:"Post translations";s:4:"slug";s:29:"wpml-legacy-post-translations";s:8:"base_uri";s:127:"hidden link";s:3:"css";a:2:{i:0;s:136:"hidden link";i:1;s:140:"hidden link";}s:2:"js";a:0:{}s:14:"flags_base_uri";N;s:14:"flag_extension";N;s:7:"is_core";b:1;s:3:"for";a:1:{i:0;s:17:"post_translations";}s:14:"force_settings";a:0:{}}s:14:"wpml-menu-item";a:12:{s:4:"path";a:2:{i:0;s:101:"/redacted/path/to/wp-content/plugins/sitepress-multilingual-cms/templates/language-switchers";i:1;s:111:"/redacted/path/to/wp-content/plugins/sitepress-multilingual-cms/templates/language-switchers/menu-item";}s:7:"version";s:1:"1";s:4:"name";s:9:"Menu Item";s:4:"slug";s:14:"wpml-menu-item";s:8:"base_uri";s:112:"hidden link";s:3:"css";a:2:{i:0;s:121:"hidden link";i:1;s:125:"hidden link";}s:2:"js";a:0:{}s:14:"flags_base_uri";N;s:14:"flag_extension";N;s:7:"is_core";b:1;s:3:"for";a:1:{i:0;s:5:"menus";}s:14:"force_settings";a:0:{}}}','auto');

Symptoms:
I expected to see relative paths, but instead, I got absolute paths stored in options, which can break when certain constants or domains change.

Questions:
Why are absolute paths being stored in options instead of relative paths?
How can I ensure that paths are stored correctly to avoid issues when constants or domains change?

July 8, 2025 at 2:47 pm #17214787

George Botsev
WPML Supporter since 02/2014

Languages: English (English )

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

Hello!
That option that you are mentioning is not intended to be kept forever and should be cleared and repopulated with the proper path by several actions including by plugin deactivation and reactivation or switching the current theme.
You can of course clear it manually and it will be rebuilt.
So you can think of this as a deep sleeping transient. Yes, it is not the best option, however, it surely is better than having it transiented and being refreshed periodically (not on a specific action)

The value is stored as an absolute path because WordPress functions mainly return the absolute path for some functions like get_uploads_path, get_template_directory & etc...

This is of course subject to change as we plan on deprecating the TWIG templates and the underlying functions may not need calls to such functions in the future and also the absolute paths.

July 8, 2025 at 10:22 pm #17216259

desireeM

The problem is that it's permanently rewritten. When we deploy a new website version, the base path (ABSPATH) changes, since it contains the current version number (e.g. /foo/20250907/)

Additionally, when using a multi-server set up, the ABSPATH might not be the same in all cases.

Even when you plan on deprecating it: storing relative paths in there and then using ABSPATH and WP_CONTENT_DIR is in no way harder than what you are currently doing.
Why do you think WP core is using ABSPATH, WPINC, WP_CONTENT_DIR,... everywhere instead of hardcoding them?

July 13, 2025 at 8:10 pm #17231396

Itamar
WPML Supporter since 02/2016

Languages: English (English )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi,

I'll continue to help you with this issue.

Thanks for the information you provided. I'm consulting our second-tier supporter about this case.

I appreciate your patience.
Itamar.