diff --git a/qtranslate_core.php b/qtranslate_core.php index 0100e114..5b5c38e8 100644 --- a/qtranslate_core.php +++ b/qtranslate_core.php @@ -87,8 +87,10 @@ function qtranxf_init_language() { * @return mixed A new URL to be redirected to instead of $url_lang or "false" to cancel redirection. */ $target = apply_filters( 'qtranslate_language_detect_redirect', $url_lang, $url_orig, $url_info ); + if ( $target !== false && $target != $url_orig ) { - wp_redirect( $target ); + // rickfix,, we want redirects to be "permanent" and not default 302 + wp_redirect( $target, 301 ); nocache_headers(); // prevent browser from caching redirection exit(); } else { @@ -221,7 +223,7 @@ function qtranxf_detect_language( &$url_info ) { $url_info['language'] = $lang; // REST calls should be deterministic (stateless), no special language detection e.g. based on cookie - $url_info['set_cookie'] = ! wp_doing_ajax() && ! qtranxf_is_rest_request_expected(); + $url_info['set_cookie'] = ! wp_doing_ajax() && ! wp_doing_cron() && ! qtranxf_is_rest_request_expected(); /** * Hook for possible other methods diff --git a/qtranslate_frontend.php b/qtranslate_frontend.php index 15a7a382..78a84ffb 100644 --- a/qtranslate_frontend.php +++ b/qtranslate_frontend.php @@ -54,6 +54,8 @@ function qtranxf_wp_head() { // Fallback for unmatched language (default hreflang for SEO) $hreflangs['x-default'] = qtranxf_convertURL( '', $q_config['default_language'] ); + $hreflangs = apply_filters( 'qtranslate_hreflangs', $hreflangs ); + foreach ( $hreflangs as $hreflang => $href ) { echo '' . PHP_EOL; }