Skip to content

Instantly share code, notes, and snippets.

Created March 30, 2015 20:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/2fc4ea90505a9376612d to your computer and use it in GitHub Desktop.
Save anonymous/2fc4ea90505a9376612d to your computer and use it in GitHub Desktop.
add_filter( 'tribe_events_rewrite_rules', 'rename_event_view_slugs', 10, 2 );
function rename_event_view_slugs( $rules, $new_rules = null ) {
if ( null === $new_rules ) return $rules;
// Original event view slugs and what we want to change each to
$to_change = array(
'list' => 'all-events',
'month' => 'calendar'
);
// Scan for rules relating to the views in question and update accordingly
foreach ( $new_rules as $added_rule => $query_string ) {
foreach ( $to_change as $look_for => $change_to ) {
// Skip if we don't have a match
if ( false === strpos( $added_rule, "/$look_for" ) ) continue;
// Form the revised rule
$revised_rule = array(
str_replace( "/$look_for", "/$change_to", $added_rule ) => $query_string
);
// Remove the old rule and insert the new one
unset( $rules[$added_rule] );
$rules = $revised_rule + $rules;
}
}
return $rules;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment