Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
The Events Calendar: Change the Event Website plain text link to a button, including shortening the anchor text to avoid a really long button.
<?php
/**
* The Events Calendar: Change the Event Website plain text link to a button, including shortening the anchor text to
* avoid a really long button.
*
* @link https://gist.github.com/cliffordp/e19775ce3eb7a66fb72ba38a24959546 This snippet.
* @link https://theeventscalendar.com/knowledgebase/k/make-the-event-website-url-a-linked-word-or-button/ KB article with this and other snippets.
* Screenshots with Twenty Twenty theme:
* @link https://share.getcloudapp.com/X6uz7NNZ without this snippet (before).
* @link https://share.getcloudapp.com/geu2PzzE with this snippet (after).
*
* @param string $label
*
* @return string
*/
function cliff_change_event_website_link_to_button( $label ) {
$url = tribe_get_event_website_url();
if ( $label === $url ) {
$label = 'Visit Website &raquo;';
}
$class = "button tribe-events-button tribe-common-c-btn tribe-common-c-btn--small";
$label = sprintf(
'<a class="%s" href="%s">%s</a>',
$class,
esc_url( $url ),
$label
);
return $label;
}
add_filter( 'tribe_get_event_website_link_label', 'cliff_change_event_website_link_to_button' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.