Created
January 31, 2017 10:51
-
-
Save andrasguseo/6cf7738e3e34348d7ca398fd7bcfb9eb to your computer and use it in GitHub Desktop.
Render EventBrite iFrame on event page when EventBrite event is set to private
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 | |
/* | |
* For The Events Calendar and The Events Calendar: EventBrite Tickets | |
* Renders the EventBrite iFrame on single event page when EventBrite event is set to private | |
* Author: Barry Hughes | |
*/ | |
function eb_iframe_show_even_if_private() { | |
$post_id = get_the_ID(); | |
$api = tribe( 'eventbrite.api' ); | |
$event = $api->get_event( $post_id ); | |
if ( ! $event ) { | |
return; | |
} | |
$event_id = $event->id; | |
$iframe_url = ( is_ssl() ? 'https://' : 'http://' ) . 'www.eventbrite.com/tickets-external?eid=%s&ref=etckt&v=2'; | |
$iframe_url = apply_filters( 'tribe_events_eb_iframe_url', sprintf( $iframe_url, $event_id ) ); | |
$html = ''; | |
if ( | |
! empty( $event_id ) && | |
$api->is_live( $post_id ) && | |
tribe_event_show_tickets( $post_id ) | |
) { | |
$html = sprintf( | |
'<div class="eventbrite-ticket-embed" style="width:100%%;text-align:left"> | |
<iframe id="eventbrite-tickets-%1$s" src="%2$s" style="height:200px;width:100%%;overflow:auto;"></iframe> | |
<div style="font-family:Helvetica, Arial;font-size:10px;padding:5px 0 5px;margin:2px;width:100%%;text-align:left"> | |
<a target="_blank" href="http://www.eventbrite.com/features?ref=etckt" style="color:#ddd;text-decoration:none">Event registration</a> | |
<span style="color:#ddd"> powered by </span> | |
<a target="_blank" href="http://www.eventbrite.com?ref=etckt" style="color:#ddd;text-decoration:none">Eventbrite</a> | |
</div> | |
</div>', $event_id, $iframe_url ); | |
} | |
$html = apply_filters( 'tribe_template_factory_debug', $html, 'Tribe__Events__Eventbrite__Template::the_tickets' ); | |
return apply_filters( 'tribe_events_eb_iframe_html', $html, $event_id, $post_id ); | |
} | |
add_filter( 'tribe_events_eventbrite_the_tickets', 'eb_iframe_show_even_if_private' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment