Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion autodescription.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: The SEO Framework
* Plugin URI: https://theseoframework.com/
* Description: An automated, advanced, accessible, unbranded and extremely fast SEO solution for your WordPress website.
* Version: 5.1.3-dev-6
* Version: 5.1.3-dev-7
* Author: Sybre Waaijer
* Author URI: https://theseoframework.com/
* License: GPLv3
Expand Down
29 changes: 28 additions & 1 deletion inc/compat/plugin-polylang.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,35 @@ function _polylang_register_sitemap_languages( $list ) {
)
as $language
) {
// Get the language-specific home URL to determine the correct sitemap path
$lang_home_url = \function_exists( 'pll_home_url' ) ? \pll_home_url( $language ) : '';

if ( $lang_home_url ) {
// Parse the language-specific home URL to get the path
$lang_parsed = parse_url( $lang_home_url );
$lang_path = $lang_parsed['path'] ?? '';

// Remove the site's base path to get the language-specific part
$site_parsed = parse_url( \home_url() );
$site_path = rtrim( $site_parsed['path'] ?? '', '/' );

// Get the relative path for this language
if ( $site_path && str_starts_with( $lang_path, $site_path ) ) {
$relative_path = substr( $lang_path, \strlen( $site_path ) );
} else {
$relative_path = $lang_path;
}
$relative_path = trim( $relative_path, '/' );

// Build the endpoint with the correct language path
$endpoint = $relative_path ? "$relative_path/{$list['base']['endpoint']}" : $list['base']['endpoint'];
} else {
// Fallback to the original method if pll_home_url is not available
$endpoint = "$language/{$list['base']['endpoint']}";
}

$list[ "_base_polylang_$language" ] = [
'endpoint' => "$language/{$list['base']['endpoint']}",
'endpoint' => $endpoint,
] + $list['base'];
}
}
Expand Down