function sfput_include()
{
    global $pagenow;
    $is_admin = is_admin() && !(defined('DOING_AJAX') && DOING_AJAX);
    if (!($is_admin || '' != get_option('permalink_structure'))) {
        return;
    }
    // Pas de bras, pas de chocolat.
    if (!sf_can_use_polylang('1.5.0.8') || !sfput_get_polylang_mode() || is_plugin_deactivation(SFPUT_FILE)) {
        return;
    }
    include SFPUT_PLUGIN_DIR . 'inc/settings.php';
    include SFPUT_PLUGIN_DIR . 'inc/main.php';
    if ($is_admin) {
        include SFPUT_PLUGIN_DIR . 'inc/admin.php';
        // We're visiting the Polylang settings page.
        if ('options-general.php' === $pagenow && !empty($_GET['page']) && 'mlang' === $_GET['page']) {
            include SFPUT_PLUGIN_DIR . 'inc/settings-page.php';
        }
    }
}
function sfput_registered_taxonomy($taxonomy, $object_type, $args)
{
    global $wp_taxonomies, $wp_rewrite, $polylang;
    add_filter('sfput_options_clear_taxonomies_cache', '__return_true');
    $taxonomies = sfput_get_taxonomies();
    if (empty($taxonomies[$taxonomy])) {
        return;
    }
    $mode = sfput_get_polylang_mode();
    // Language
    if ($mode === 1) {
        $lang = $polylang->options['default_lang'];
    } else {
        $lang = pll_current_language();
    }
    // Save the original slug somewhere safe, it could be usefull later (like in the settings page).
    $original_slug = sfput_get_taxonomy_slug($taxonomy);
    if (!sf_cache_data('sfput_original_slugs-taxo-' . $taxonomy)) {
        sf_cache_data('sfput_original_slugs-taxo-' . $taxonomy, $original_slug);
    }
    // Settings
    $slugs = sfput_get_option('taxonomies');
    $slug = !empty($slugs[$taxonomy][$lang]) ? $slugs[$taxonomy][$lang] : $original_slug;
    if (!$slug) {
        return;
    }
    // Change the slug
    if ($original_slug && $original_slug !== $slug) {
        // This is me being paranoïd: I want to make sure to replace "/my-slug/", and not "FOOmy-slugBAR".
        $has_slash = strpos($wp_rewrite->extra_permastructs[$taxonomy]['struct'], '/') === 0;
        $wp_rewrite->extra_permastructs[$taxonomy]['struct'] = str_replace('/' . $original_slug . '/', '/' . $slug . '/', '/' . $wp_rewrite->extra_permastructs[$taxonomy]['struct']);
        $wp_rewrite->extra_permastructs[$taxonomy]['struct'] = ($has_slash ? '/' : '') . ltrim($wp_rewrite->extra_permastructs[$taxonomy]['struct'], '/');
        $wp_taxonomies[$taxonomy]->rewrite['slug'] = $slug;
    }
    if (is_admin() && !(defined('DOING_AJAX') && DOING_AJAX) && $mode === 1) {
        remove_filter($taxonomy . '_rewrite_rules', 'sfput_extra_permastructs', 1000);
        add_filter($taxonomy . '_rewrite_rules', 'sfput_extra_permastructs', 1000);
    }
}
    foreach ($rules as $regex => $rule) {
        if (strpos($regex, $poly_slug) !== 0) {
            $new_rules[$regex] = $rule;
            continue;
        }
        foreach ($languages as $language) {
            $new_regex = str_replace_once($imploded_langs, '(' . $language . ')/', $regex);
            $new_regex = str_replace_once('/' . $slug . '/', '/' . $slugs[$language] . '/', '/' . $new_regex);
            $new_regex = ltrim($new_regex, '/');
            $new_rules[$new_regex] = $rule;
        }
    }
    return $new_rules;
}
// Post types (archive)
if (sfput_get_polylang_mode() === 1) {
    add_filter('rewrite_rules_array', 'sfput_rewrite_rules', 1000);
}
function sfput_rewrite_rules($rules)
{
    global $wp_rewrite, $polylang;
    if (empty($rules)) {
        // Uh? oO
        return $rules;
    }
    $languages = $polylang->model->get_languages_list(array('fields' => 'slug'));
    // If Polylang doesn't add the /{default_lang}/ in the URL, no need to modify the rules for this lang, sfput_registered_post_type() took care of it earlier.
    if ($polylang->options['hide_default']) {
        $languages = array_diff($languages, array($polylang->options['default_lang']));
    }
    if (empty($languages)) {