Skip to content

Commit

Permalink
Prevent lang code to be included in URL for images
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnTzonis committed Oct 21, 2024
1 parent f28af30 commit 5ad1986
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions includes/lib/transifex-live-integration-picker.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,15 @@ function render() {
// in this case return the url_path with e.g engagement => /engagement
// Otherwise remove the part from url string until the language prefix
// e.g el/sample_page =>sample_page
if (strpos($url_path, $lang ) !== false && $url_path !== $lang && strpos($url_path, $lang .'/' ) === false) {
$source_url_path = '/' . ltrim( $url_path, '/' );
// Check if URL corresponds to an image. If so, leave it unmodified.
if ($this->is_image_url($url_path)) {
$source_url_path = $url_path;
} else {
$source_url_path = (substr($url_path, 0, strlen($lang)) === $lang) ? substr($url_path, strlen($lang)) : $url_path;
if (strpos($url_path, $lang ) !== false && $url_path !== $lang && strpos($url_path, $lang .'/' ) === false) {
$source_url_path = '/' . ltrim( $url_path, '/' );
} else {
$source_url_path = (substr($url_path, 0, strlen($lang)) === $lang) ? substr($url_path, strlen($lang)) : $url_path;
}
}
$url_map = Transifex_Live_Integration_Common::generate_language_url_map( $source_url_path, $this->tokenized_url, $this->language_map );
$site_url_slash_maybe = (new Transifex_Live_Integration_WP_Services())->get_site_url($this->is_subdirectory_install);
Expand Down

0 comments on commit 5ad1986

Please sign in to comment.