Created
September 15, 2021 21:21
-
-
Save lelandf/90b980d2d8ebb086a7cbd05cf91d114f to your computer and use it in GitHub Desktop.
Redirect to arbitrary URL after clicking Mini Calendar Widget
This file contains hidden or 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
<?php | |
// Use at your own risk! | |
// No warranty, no support provided | |
add_action( 'wp_footer', function() { ?> | |
<script> | |
(function () { | |
// Change your redirection URL here | |
const REDIRECTION_URL = 'https://www.example.com/events/'; | |
const miniCalendar = document.querySelector( '.tribe-events-calendar-month' ); | |
// If there's no mini calendar, or if we're already on the redirect-to page | |
if ( ! miniCalendar || window.location.href === REDIRECTION_URL ) { | |
return; | |
} | |
miniCalendar.addEventListener( 'click', () => { | |
window.location = REDIRECTION_URL; | |
}); | |
})(); | |
</script> | |
<?php }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment