-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9816c76
commit 171e2be
Showing
3 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
add_filter( 'qtranslate_language_detect_redirect', 'qtranxf_slugs_language_detect_redirect', 600, 3 ); | ||
|
||
/** | ||
* Allows url redirection due to language auto detection only if site url has been requested | ||
* | ||
* @see qtranxf_check_url_maybe_redirect | ||
* @param string $url_lang proposed target URL for the active language to redirect to. | ||
* @param string $url_orig original URL supplied to browser, which needs to be standardized. | ||
* @param array $url_info a hash of various information parsed from original URL, cookies and other site configuration. The key names should be self-explanatory. | ||
* | ||
* @return string resulting redirection url | ||
*/ | ||
function qtranxf_slugs_language_detect_redirect($url_lang, $url_orig, $url_info): string { | ||
global $q_config; | ||
if (site_url().'/' === $url_orig) | ||
return $url_lang; | ||
else { | ||
if ( empty( $url_info['lang_url'] ) ){ | ||
return qtranxf_convertURL( $url_orig, $q_config['default_language'],false,true ); | ||
} else { | ||
return $url_orig; | ||
} | ||
} | ||
} | ||
|