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 – 17:00 10:00 – 17:00 10:00 – 17:00 10:00 – 17:00 10:00 – 17:00 -
- 18:00 – 19:00 18:00 – 19:00 18:00 – 19:00 18:00 – 19:00 18:00 – 19:00 -

Supporter timezone: Asia/Kathmandu (GMT+05:45)

This topic contains 5 replies, has 0 voices.

Last updated by Shekhar Bhandari 6 days, 5 hours ago.

Assisted by: Shekhar Bhandari.

Author Posts
February 25, 2025 at 4:26 pm #16747041

desireeM

Background of the issue:
I am trying to convert URLs using the WPML plugin, specifically in the file sitepress-multilingual-cmsclassesurl-handlingconverterstrategyclass-wpml-url-converter-domain-strategy.php. The code snippet involved is:

<code>
public function convert_url_string( $source_url, $lang ) {
$original_source_url = untrailingslashit( $source_url );
if ( is_admin() && $this->get_url_helper()->is_url_admin( $original_source_url ) ) {
return $original_source_url;
}

return $this->convert_url( $source_url, $lang );
}
</code>

Symptoms:
The untrailingslashit function causes URL conversion of URLs without a trailing slash to include a trailing slash when converted, which is incorrect. I expected no trailing slash when the source URL does not contain one, but instead, I got a trailing slash.

Questions:
Why does the URL conversion add a trailing slash when it shouldn't?
How can I prevent the trailing slash from being added during URL conversion?

February 28, 2025 at 5:28 am #16758786

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hi there,

Thank you for reaching out to WPML support. I'd be happy to assist you with this issue.

To address your questions accurately, I’ll need to escalate this to our 2nd-tier team. However, before doing so, could you provide a few examples of pages where you're encountering this issue or any steps to reproduce the error. This will help us better understand the behavior and proceed accordingly.

Looking forward to your response.

Best regards

March 4, 2025 at 7:37 pm #16775753

desireeM

e.g.

var_dump( apply_filters( 'wpml_permalink', '<em><u>hidden link</u></em>', 'de' ) );
March 5, 2025 at 9:35 am #16777526

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

I asked our 2nd tiers about the issue and they mentioned the following:
[php]
Permalinks returned are based on the permalink settings - if the value is /%postname%/ then you will got a trailing slash. if this is without trailing slash, you will receive it without the slash.

Let me know if this helps.

Thanks

March 5, 2025 at 2:11 pm #16779368

desireeM

Why do you think did I specify the request URI in the example as "/some-invalid-url" ?

March 6, 2025 at 9:42 am #16782171

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello,

I believe you specified the request URI as /some-invalid-url to demonstrate how the system handles invalid or unexpected requests.

If you’re looking to retrieve results regardless of the permalink settings, please let me know. I can escalate your request to our second-tier team for further assistance.

Looking forward to your response.

Best regards