Viewing 1 replies (of 1 total)
  • Thread Starter @anansi.pro

    (@mahasvin)

    Solved that, not related to this plugin, it is WPML problem.
    You can either comment line 9 in inc/browser-redirection.php in WPML, or use a fix (credit to WPML support team):

    /*
     * WPML browser redirect fix.
     *
    */
    function wpml_browser_redirect_fix(){
            global $sitepress, $post;
    
            $browser_language_code = substr( $_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2 );
            $active_languages = $sitepress->get_active_languages();
    
            $reffered = @$_SERVER['HTTP_REFERER'];
    
            foreach( $active_languages as $language_code => $language ){
                    if( $browser_language_code == $language_code && !$reffered ){
                            if ( is_home() || is_front_page() ) {
                                    if( $sitepress->get_current_language() != $language_code ){
                                            wp_redirect( $sitepress->convert_url( site_url(), $browser_language_code ) );
                                    }
                            } else {
                                    if( $post->ID ){
                                            if( $sitepress->get_current_language() != $language_code ){
                                                    $post_type = get_post_type( $post->ID );
                                                    wp_redirect( get_permalink( icl_object_id( $post->ID, $post_type, true, $language_code ) ) );
                                            }
                                    }
                            }
                    }
            }
    }
    add_action( 'wp_head', 'wpml_browser_redirect_fix', 0 );
Viewing 1 replies (of 1 total)
  • The topic ‘WPML compatibility issue’ is closed to new replies.