-
-
Save slimndap/918c1bb318737a437d6f to your computer and use it in GitHub Desktop.
Gets the HTML output for the {{timetable}} placeholder. The {{timetable}} placeholder can be used in productions lists to display the start time for each individual day that the event takes place.
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 | |
/** | |
* Gets the HTML output for the {{timetable}} placeholder. | |
* | |
* The {{timetable}} placeholder can be used in productions lists to | |
* display the start time for each individual day that the event | |
* takes place. | |
* | |
* You can use it in a shortcode like this: | |
* | |
* [wpt_productions start="now"] | |
* {{thumbnail|permalink}}{{title|permalink}}{{categories}}{{timetable}} | |
* [/wpt_productions] | |
* | |
* It uses the date and time format from the WordPress setting. | |
* | |
* @param string $value Current HTML output for the {{timetable}} | |
* placeholder. | |
* @param string $field Name of the field. | |
* @param WPT_Production $production Current production. | |
* @return string New HTML output for the {{timetable}} | |
* placeholder. | |
*/ | |
function wpt_get_production_timetable( $html, $field, $production) { | |
global $wp_theatre; | |
$html = ''; | |
$events_args = array( | |
'start' => 'now', | |
'production' => $production->ID, | |
); | |
$days = $wp_theatre->events->get_days($events_args); | |
if (!empty($days)) { | |
$html.= '<ul>'; | |
foreach ($days as $key => $value) { | |
$events_args['start'] = $key; | |
$events_args['end'] = $key.' + 1 day'; | |
$events = $wp_theatre->events->get($events_args); | |
$html.= '<li>'; | |
$html.= date_i18n( get_option( 'date_format' ), strtotime($key)); | |
$html.= ' - '; | |
foreach($events as $event) { | |
$html.= '<span>'.$event->starttime().'</span> '; | |
} | |
$html.= '</li>'; | |
} | |
$html.= '</ul>'; | |
} | |
return $html; | |
} | |
add_filter( 'wpt_production_timetable', 'wpt_get_production_timetable', 10, 3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment