function nobase_rewrite_rules($rules) { $rules = array(); $tax_name = sustr::rtrim_str(current_filter(), '_rewrite_rules'); $tax_obj = get_taxonomy($tax_name); wp_cache_flush(); //Otherwise get_terms() won't include the term just added $terms = get_terms($tax_name); if ($terms && !is_wp_error($terms)) { foreach ($terms as $term_obj) { $term_slug = suwp::get_term_slug($term_obj); if ($tax_obj->query_var && is_string($tax_obj->query_var)) { $url_start = "index.php?{$tax_obj->query_var}="; } else { $url_start = "index.php?taxonomy={$tax_name}&term="; } if ($this->get_setting('add_rule_if_conflict', true) || get_page_by_path($term_slug) === null) { $rules['(' . $term_slug . ')/(?:feed/)?(feed|rdf|rss|rss2|atom)/?$'] = $url_start . '$matches[1]&feed=$matches[2]'; $rules['(' . $term_slug . ')/page/?([0-9]{1,})/?$'] = $url_start . '$matches[1]&paged=$matches[2]'; $rules['(' . $term_slug . ')/?$'] = $url_start . '$matches[1]'; } } } global $wp_rewrite; $old_base = $wp_rewrite->get_extra_permastruct($tax_name); $old_base = str_replace("%{$tax_name}%", '(.+)', $old_base); $old_base = trim($old_base, '/'); $rules[$old_base . '$'] = 'index.php?su_term_redirect=$matches[1]'; return $rules; }