Last active
August 23, 2018 05:14
-
-
Save cliffordp/60b5acf003fa68ad7803313d662c08e7 to your computer and use it in GitHub Desktop.
The Events Calendar: Turn the "All Events" link into a true "Back" button.
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
<?php | |
/** | |
* The Events Calendar: Turn the "All Events" link into a true "Back" button. | |
* | |
* Generally not advisable but provided at customer's request: | |
* https://theeventscalendar.com/support/forums/topic/upcoming-events-8/ | |
* | |
* @link https://gist.github.com/cliffordp/60b5acf003fa68ad7803313d662c08e7 | |
* @link https://css-tricks.com/snippets/javascript/go-back-button/ | |
* @link https://api.jquery.com/replacewith/ | |
*/ | |
add_action( 'wp_footer', 'cliff_all_events_link_replaced_with_back_button' ); | |
function cliff_all_events_link_replaced_with_back_button() { | |
wp_enqueue_script( 'jquery' ); | |
?> | |
<script type="text/javascript"> | |
jQuery( document ).ready( function () { | |
var all_events = jQuery( 'p.tribe-events-back a' ); | |
// The following line is commented out because an "All Events" link that goes back to say the Blog Posts page would confuse the user. | |
// var button_text = all_events.text().trim(); | |
var button_text = '« Go Back'; | |
var new_element = '<input type="button" value="'; | |
new_element += button_text; | |
new_element += '" onclick="history.back(-1)" />'; | |
all_events.replaceWith( new_element ); | |
} ); | |
</script> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment