Still investigating whether the problem is with the filter added to rewrite_rules_array or how the regex is written in the plugin.
On a site where a region and language slug are appended to every url rewrite rules are added to the rewrite_rules_array to determine the region and language from the given url.
Filter function
static function _filter_rewrite_rules_array( $initial_rules ) {
$region_lang_pattern_prefix = sprintf( '%s/', self::_get_region_url_pattern() );
$new_rules[$region_lang_pattern_prefix . '?$'] = 'index.php?selected_region=$matches[1]&selected_language=$matches[2]';
foreach ( $initial_rules as $pattern => $query ) {
self::$match_count = 2;
// Find all occurrences of $matches[x] and increment x by 2 since we are pushing the 2 query_var match rules in front of all existing rules. Kind of hackish but it works.
$query = preg_replace_callback( '/\\d/ui', array( __CLASS__, 'increment_matches' ), $query );
$query = str_ireplace( 'index.php?', 'index.php?selected_region=$matches[1]&selected_language=$matches[2]&', $query );
$new_rules[$region_lang_pattern_prefix . $pattern] = $query;
}
return $new_rules;
}
static function increment_matches( $match ) {
return (int)$match + self::$match_count++;
}
This causes the rule entry for minify to be written as follows:
Still investigating whether the problem is with the filter added to rewrite_rules_array or how the regex is written in the plugin.
On a site where a region and language slug are appended to every url rewrite rules are added to the rewrite_rules_array to determine the region and language from the given url.
Filter function
This causes the rule entry for minify to be written as follows: