Last active
June 28, 2024 21:31
-
-
Save andrasguseo/7b107a6da97c1a3ac9195c1aff99a71a to your computer and use it in GitHub Desktop.
TEC Eventbrite Tickets > Inject iFrame to content
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
<? | |
/** | |
* Description: Inject the Eventbrite Tickets iFrame into the post content. | |
* Workaround for Elementor Pro. | |
* Usage: Paste the below snippet into your active (child) theme's functions.php file | |
* or use a plugin like Code Snippets. | |
* | |
* Plugins: The Events Calendar, The Events Calendar: Eventbrite Tickets, Elementor, Elementor Pro | |
* Author: Andras Guseo | |
* Last updated: 2024-05-28 | |
* | |
* @param string $content The post content. | |
* | |
* @return string The post content with the Eventbrite iFrame. | |
*/ | |
/** | |
* Inject the Eventbrite Tickets iFrame into the post content | |
* Needs a template override for qr-image.php | |
* @return int[] | |
*/ | |
function tec_eventbrite_frame_inject( $content ) { | |
global $post; | |
// Bail if admin | |
if ( is_admin() ) { | |
return $content; | |
} | |
// Bail if not single | |
if ( ! is_single() ) { | |
return $content; | |
} | |
// Bail if not event | |
if ( get_post_type() !== 'tribe_events' ) { | |
return $content; | |
} | |
// Get post meta | |
$postmeta = get_post_meta( $post->ID ); | |
// Bail if not a live Eventbrite event. | |
if ( | |
! isset( $postmeta['_EventBriteId'] ) | |
|| ! isset( $postmeta['_EventBriteStatus'] ) | |
|| $postmeta['_EventBriteStatus'][0] !== 'live' | |
) { | |
return $content; | |
} | |
// Get the frame | |
$eventbrite_frame = Tribe__Events__Tickets__Eventbrite__Template::the_tickets(); | |
return $eventbrite_frame . $content; | |
} | |
add_filter( 'the_content', 'tec_eventbrite_frame_inject' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment