Ok, found it. These are the changes:
In events-manager.php, replace the 2 function definitions found below:
// Adding a new rule
function eme_insertMyRewriteRules($rules) {
// using pagename as param to index.php causes rewrite troubles if the page is a subpage of another
// luckily for us we have the page id, and this works ok
$page_id=get_option ( 'eme_events_page' );
$events_prefix=eme_permalink_convert(get_option ( 'eme_permalink_events_prefix'));
$locations_prefix=eme_permalink_convert(get_option ( 'eme_permalink_locations_prefix'));
$newrules = array();
$newrules[$events_prefix.'(\d{4})-(\d{2})-(\d{2})'] = 'index.php?page_id='.$page_id.'&calendar_day=$matches[1]-$matches[2]-$matches[3]';
$newrules[$events_prefix.'(\d*)/'] = 'index.php?page_id='.$page_id.'&event_id=$matches[1]';
$newrules[$events_prefix.'p(\d*)'] = 'index.php?page_id='.$page_id.'&eme_pmt_id=$matches[1]';
$newrules[$events_prefix.'town/(.*)'] = 'index.php?page_id='.$page_id.'&eme_town=$matches[1]';
$newrules[$locations_prefix.'(\d*)/'] = 'index.php?page_id='.$page_id.'&location_id=$matches[1]';
return $newrules + $rules;
}
add_filter('rewrite_rules_array','eme_insertMyRewriteRules');
// Adding the id var so that WP recognizes it
function eme_insertMyRewriteQueryVars($vars) {
array_push($vars, 'event_id');
array_push($vars, 'location_id');
array_push($vars, 'calendar_day');
// a bit cryptic for the booking id
array_push($vars, 'eme_pmt_id');
array_push($vars, 'eme_town');
return $vars;
}
And in eme_events.php, at the top of function eme_events_page_content:
if (isset ( $wp_query->query_vars['eme_town'] ) && $wp_query->query_vars['eme_town'] != '') {
$eme_town=eme_sanitize_request($wp_query->query_vars['eme_town']);
$location_ids = join(',',eme_get_town_location_ids($eme_town));
$stored_format = get_option('eme_event_list_item_format');
$event_list_format_header = get_option('eme_event_list_item_format_header' );
$event_list_format_header = ( $event_list_format_header != '' ) ? $event_list_format_header : "<ul class='eme_events_list'>";
$event_list_format_footer = get_option('eme_event_list_item_format_footer' );
$event_list_format_footer = ( $event_list_format_footer != '' ) ? $event_list_format_footer : "</ul>";
$page_body = $event_list_format_header . eme_get_events_list ( get_option('eme_event_list_number_items' ), $scope, "ASC", $stored_format, 0, '','',0,'','',0,$location_ids) . $event_list_format_footer;
return $page_body;
}
Then just deactivate/reactivate and you can then do things like:
http://localhost/wordpress/events/town/Galway
The thing is: the rewrite rule I added
$newrules[$events_prefix.'town/(.*)'] = 'index.php?page_id='.$page_id.'&eme_town=$matches[1]';
takes everything after "town/", since the regex ".*" is greedy. I tried to make it non-greedy, but still no luck there.