Created
March 30, 2015 20:53
-
-
Save anonymous/2fc4ea90505a9376612d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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