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)) {
        return $rules;
    }
    // The way Polylang built its regex.
    $imploded_langs = '(' . implode('|', $languages) . ')/';
    $poly_slug = $wp_rewrite->root . ($polylang->options['rewrite'] ? '' : 'language/') . $imploded_langs;
    // Post types slugs
    $slugs = sfput_get_option('post_types.archive');
    $slugs = array_filter($slugs);
    if (empty($slugs)) {
        return $rules;
    }
    $post_types = array_keys($slugs);
    $post_types = array_combine($post_types, $post_types);
    $old_slugs = array_map('sfput_get_post_type_archive_slug', $post_types);
    $post_types = implode('|', $post_types);
    $new_rules = array();
    foreach ($rules as $regex => $rule) {
        // Not a Polylang rule
        if (strpos($regex, $poly_slug) !== 0) {
            $new_rules[$regex] = $rule;
        } elseif (preg_match('@[?|&]post_type=(' . $post_types . ')(?:&.*)?$@', $rule, $matches)) {
            $post_type = $matches[1];
            foreach ($languages as $language) {
                $new_regex = str_replace_once($imploded_langs, '(' . $language . ')/', $regex);
                $new_regex = str_replace_once('/' . $old_slugs[$post_type] . '/', '/' . $slugs[$post_type][$language] . '/', '/' . $new_regex);
                $new_regex = ltrim($new_regex, '/');
                $new_rules[$new_regex] = $rule;
            }
        } else {
            $new_rules[$regex] = $rule;
        }
    }
    return $new_rules;
}
function sfput_get_taxonomies()
{
    static $taxonomies;
    global $polylang;
    if (!is_array($taxonomies) || apply_filters('sfput_options_clear_taxonomies_cache', false)) {
        $slugs = sfput_get_option('taxonomies');
        if (is_array($slugs) && !empty($slugs)) {
            $taxonomies = array_keys($slugs);
            $taxos_poly = $polylang->model->get_translated_taxonomies();
            if (!empty($taxos_poly)) {
                //$taxos_poly	= array_diff( $taxos_poly, array( 'post_format' ) );
                $taxos_poly = array_filter($taxos_poly, 'sfput_default_taxonomy_slug');
                // Remove the ones without rewrite slug.
                $taxonomies = array_intersect($taxonomies, $taxos_poly);
            }
            if (!empty($taxonomies)) {
                $taxonomies = array_combine($taxonomies, $taxonomies);
            }
        } else {
            $taxonomies = array();
        }
    }
    return $taxonomies;
}