Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnTzonis committed Oct 21, 2024
1 parent 5ad1986 commit 226f798
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions includes/lib/transifex-live-integration-picker.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,20 @@ 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
// Check if URL corresponds to an image. If so, leave it unmodified.
if ($this->is_image_url($url_path)) {
$source_url_path = $url_path;
if (strpos($url_path, $lang ) !== false && $url_path !== $lang && strpos($url_path, $lang .'/' ) === false) {
$source_url_path = '/' . ltrim( $url_path, '/' );
} else {
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;
}
$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 );

// Ensure image URLs are not modified by the language prefix
foreach ($url_map as $key => $url) {
if (strpos($url, '/wp-content/uploads/') !== false) {
continue;
}
$url_map[$key] = rtrim($url, '/') . '/';
}
$site_url_slash_maybe = (new Transifex_Live_Integration_WP_Services())->get_site_url($this->is_subdirectory_install);
$site_url = rtrim( $site_url_slash_maybe, '/' ) . '/';
$source_url_path = ltrim( $source_url_path, '/' );
Expand Down

0 comments on commit 226f798

Please sign in to comment.