Thank you for feed-back.
I just added a filter (‘sublanguage_redirect_uncanonical_url’) for filtering the redirect url, so now you can put your code outside of the plugin files and update the next plugin version without worrying.
public function redirect_uncanonical() {
// [...]
$url = apply_filters('sublanguage_redirect_uncanonical_url', $url, $this);
wp_redirect($url);
// [...]
}
So now just wrap your code in a filter declaration and move it in functions.php (or wherever)
add_filter('sublanguage_redirect_uncanonical_url', function($url) {
$query_string = parse_url($_SERVER['REQUEST_URI'], PHP_URL_QUERY);
if (!empty($query_string))
$url .= '?' . $query_string;
return $url;
});
And upgrade the plugin to developing version (v2.12):
https://downloads.wordpress.org/plugin/sublanguage.zip
Thread Starter
herzla
(@herzla)
thanks a lot, this is how I solved it for me, while I still wonder what is against forwarding all information in default:
add_filter(‘sublanguage_redirect_uncanonical_url’, function ($url) {
$requestUri = $_SERVER[‘REQUEST_URI’];
$parsedUrl = parse_url($url, PHP_URL_PATH);
$firstPath = ‘/’ . explode(‘/’, trim($parsedUrl, ‘/’))[0];
$baseUrl = parse_url($url, PHP_URL_SCHEME) . ‘://’ . parse_url($url, PHP_URL_HOST) . $firstPath;
$url = $baseUrl . $requestUri;
return $url;
});
when I enable error output in php an WP I see this messages:
Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /wp-includes/functions.php on line 7329
Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /wp-includes/functions.php on line 2189
for me this plugin is perferct, just this bug is a little bad: in page editor the save-button is jumping down when I enable sublanguage (with all other plugins disabled) and crashes the sidebar and top messages also a little