Created
February 18, 2016 00:18
-
-
Save joshfeck/ba5d11cb8489667ce209 to your computer and use it in GitHub Desktop.
Prints a message regarding the duration of the event. For Event Espresso 4
This file contains hidden or 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__ticket_selector_chart__template__before_ticket_selector', 'ee_print_event_duration', 10 ); | |
function ee_print_event_duration( $event ) { | |
$datetimes = $event->datetimes(); | |
foreach($datetimes as $datetime){ | |
if ( $datetime instanceof EE_Datetime ) { | |
$start = $datetime->get_raw('DTT_EVT_start'); | |
$end = $datetime->get_raw('DTT_EVT_end'); | |
$diff = $end - $start; | |
$hours = $diff / 3600; | |
echo '<div><strong>This is ' . $hours . ' hours in duration</strong></div>'; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment