Created
December 26, 2018 18:42
-
-
Save joshfeck/8c32d87377525d2071db4712aa4b4e00 to your computer and use it in GitHub Desktop.
Add the event name as a CSS class to the body tag of the EE4 registration page. Useful for custom jQuery and/or CSS for specific events.
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_filter( 'body_class', 'jf_ee_return_event_name_on_spco' ); | |
function jf_ee_return_event_name_on_spco( $classes ){ | |
// change 'registration-checkout' to match your reg. page slug | |
if (! is_page( 'registration-checkout' ) ){ | |
return $classes; | |
} | |
$events = array(); | |
$checkout = EE_Registry::instance()->SSN->checkout(); | |
if ( $checkout instanceof EE_Checkout ) { | |
$transaction = $checkout->transaction; | |
if ( $transaction instanceof EE_Transaction ) { | |
foreach ( $transaction->registrations() as $registration ) { | |
if ( $registration instanceof EE_Registration ) { | |
$event = $registration->event(); | |
if ( $event instanceof EE_Event ) { | |
$classes[] = sanitize_title($event->name()); | |
} | |
} | |
} | |
} | |
} | |
return $classes; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment