Created
November 11, 2016 16:36
-
-
Save joshfeck/7543350476b18b2b4a5f98f8202b89a3 to your computer and use it in GitHub Desktop.
Wrap contents of the Event Espresso Thank You page with a div, and include a category class name if there's a category set on the event.
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 | |
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file | |
add_action( 'AHEE__thank_you_page_overview_template__top', 'my_custom_div_class_thank_you_page' ); | |
function my_custom_div_class_thank_you_page( $transaction ) { | |
if ( $transaction instanceof EE_Transaction ) { | |
foreach ( $transaction->registrations() as $registration ) { | |
if ( $registration instanceof EE_Registration ) { | |
$event = $registration->event(); | |
if ( $event instanceof EE_Event ) { | |
$events[ $event->ID() ] = $event; | |
$category = $event->first_event_category(); | |
if ( $category instanceof EE_Term ) { | |
$category_slug = $category->slug(); | |
echo '<div class="' . $category_slug . '">'; | |
} else { | |
echo '<div class="no-category">'; | |
} | |
} | |
} | |
} | |
} | |
} | |
add_action( 'AHEE__thank_you_page_overview_template__bottom', 'my_closing_div_thank_you_content' ); | |
function my_closing_div_thank_you_content( $transaction ) { | |
if ( $transaction instanceof EE_Transaction ) { | |
foreach ( $transaction->registrations() as $registration ) { | |
if ( $registration instanceof EE_Registration ) { | |
$event = $registration->event(); | |
if ( $event instanceof EE_Event ) { | |
echo '</div><!-- end category -->'; | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment