function uls_init_plugin()
{
    //load translation
    $plugin_dir = dirname(plugin_basename(__FILE__)) . '/languages/';
    load_plugin_textdomain('user-language-switch', false, $plugin_dir);
    //init flag of permalink convertion to true. When this flag is false, then don't try to get translations when is generating permalinks
    global $uls_permalink_convertion;
    $uls_permalink_convertion = true;
    //init flat for uls link filter function. When this flag is true is because it is running a process to generate a link with translations, then it abort any try to get a translation over a translation, in this way it doesn't do an infinite loop.
    global $uls_link_filter_flag;
    $uls_link_filter_flag = true;
    //redirects the user based on the browser language. It detectes the browser language and redirect the user to the site in that language. It is done only the first time that the user visits the website in a PHP session and if the user is visiting the home page.
    uls_redirect_by_browser_language();
    //if the current page language is not the same of the user or site language, then add the language flag to the URL
    uls_redirect_by_page_language();
    //if the URL contains the language and it is the same of the site language or the user langauge saved, then remove the language from the URL.
    uls_redirect_by_languange_redundancy();
    //reset flags
    $uls_permalink_convertion = false;
    $uls_link_filter_flag = false;
    //init session to detect if you are in the home page by "first time"
    if (!session_id()) {
        session_start();
    }
}
Exemplo n.º 2
0
function uls_init_plugin()
{
    //load translation
    $plugin_dir = dirname(plugin_basename(__FILE__)) . '/languages/';
    load_plugin_textdomain('user-language-switch', false, $plugin_dir);
    //init flag of permalink convertion to true
    global $uls_permalink_convertion;
    $uls_permalink_convertion = true;
    //redirects the user based on the browser language
    uls_redirect_by_browser_language();
    //if the current page language is not the same of the user or site language, then redirect the user to the correct language
    uls_redirect_by_page_language();
    //if the URL contains the language and it is the same of the site language or the user langauge saved, then remove the language from the URL.
    uls_redirect_by_languange_redundancy();
    //init session to detect if you are in the home page by "first time"
    if (!session_id()) {
        session_start();
    }
}