Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php /* Template Name: Schedule */ ?>
- <?php get_header(); ?>
- <div id="main-content">
- <?php $is_page_builder_used = et_pb_is_pagebuilder_used( get_the_ID() ); ?>
- <?php if ( ! $is_page_builder_used ) : ?>
- <div class="container">
- <div id="content-area" class="clearfix">
- <div id="left-area">
- <?php endif; ?>
- <?php
- // Start the loop.
- while ( have_posts() ) : the_post();
- // Include the page content template.
- //get_template_part( 'template-parts/content', 'page' ); ?>
- <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
- <?php if ( ! $is_page_builder_used ) : ?>
- <?php
- $thumb = '';
- $width = (int) apply_filters( 'et_pb_index_blog_image_width', 1080 );
- $height = (int) apply_filters( 'et_pb_index_blog_image_height', 675 );
- $classtext = 'et_featured_image';
- $titletext = get_the_title();
- $thumbnail = get_thumbnail( $width, $height, $classtext, $titletext, $titletext, false, 'Blogimage' );
- $thumb = $thumbnail["thumb"];
- if ( 'on' === et_get_option( 'divi_page_thumbnails', 'false' ) && '' !== $thumb )
- print_thumbnail( $thumb, $thumbnail["use_timthumb"], $titletext, $width, $height );
- ?>
- <?php endif; ?>
- <div class="entry-content">
- <?php
- the_content();
- if ( ! $is_page_builder_used )
- wp_link_pages( array( 'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'Divi' ), 'after' => '</div>' ) );
- ?>
- </div> <!-- .entry-content -->
- <?php
- if ( ! $is_page_builder_used && comments_open() && 'on' === et_get_option( 'divi_show_pagescomments', 'false' ) ) comments_template( '', true );
- ?>
- </article> <!-- .et_pb_post -->
- <?php $days_id = get_field_objects(164);
- $args = array(
- 'post_type' => 'scheduled_shows',
- 'post_status' => 'publish',
- 'posts_per_page' => -1,
- );
- $days = get_posts($args);
- error_reporting(E_ALL);
- ini_set('display_errors','On');
- // Sort shows into an array by day
- $days_shows = array();
- foreach ($days as $show) {
- $day = get_field('days', $show->ID);
- $repeat_day = get_field('repeat_days', $show->ID);
- // Add time information to the show object
- $show->times = array(
- 'start' => get_field('start_time', $show->ID),
- 'end' => get_field('end_time', $show->ID),
- );
- $repeat_show->times = array(
- 'start' => get_field('repeat_start_time', $show->ID),
- 'end' => get_field('repeat_end_time', $show->ID),
- );
- if (!empty($day)) {
- $days_shows[$day[0]][] = $show;
- } elseif (!empty($repeat_day)) {
- $days_shows[$repeat_day[0]][] = $repeat_show;
- }
- }
- // Sort the shows by start time
- foreach ($days_shows as $day => $shows) {
- usort($days_shows[$day], function($a, $b) {
- list($hour_a, $minute_a) =
- array_map('intval', explode(':', $a->times['start']));
- list($hour_b, $minute_b) =
- array_map('intval', explode(':', $b->times['start']));
- if ($hour_a === $hour_b) {
- return $minute_a < $minute_b ? -1 : 1;
- } else {
- return $hour_a < $hour_b ? -1 : 1;
- }
- });
- }
- foreach ($days_shows as $repeat_day => $repeat_shows) {
- usort($days_shows[$repeat_day], function($a, $b) {
- list($hour_a, $minute_a) =
- array_map('intval', explode(':', $a->times['start']));
- list($hour_b, $minute_b) =
- array_map('intval', explode(':', $b->times['start']));
- if ($hour_a === $hour_b) {
- return $minute_a < $minute_b ? -1 : 1;
- } else {
- return $hour_a < $hour_b ? -1 : 1;
- }
- });
- }
- // Create tabbed output shortcode
- ob_start();
- ?>
- [tabs slidertype="top tabs"]
- [tabcontainer]
- <?php // Add tabs for each day ?>
- <?php foreach ($days_id['days']['choices'] as $key => $value): ?>
- [tabtext]<?php print $value; ?>[/tabtext]
- <?php endforeach; ?>
- [/tabcontainer]
- [tabcontent]
- <?php // Add tab contents ?>
- <?php foreach ($days_id['days']['choices'] as $key => $value): ?>
- [tab]
- <?php if (!isset($days_shows[$key])): ?>
- <p class="no-shows"><?php _e('No shows scheduled for this day'); ?></p>
- <?php else: ?>
- <ul class="schedule-day">
- <?php foreach ($days_shows[$key] as $show) {
- $GLOBALS['post'] = $show;
- setup_postdata($GLOBALS['post']);
- print '<li class="schedule-show">';
- print get_template_part('schedule', $show->post_type);
- print '</li>';
- wp_reset_postdata();
- } ?>
- </ul>
- <?php endif; ?>
- [/tab]
- <?php endforeach; ?>
- <?php foreach ($days_id['repeat_days']['choices'] as $key => $value): ?>
- [tab]
- <?php if (!isset($days_shows[$key])): ?>
- <p class="no-shows"><?php _e('No shows scheduled for this day'); ?></p>
- <?php else: ?>
- <ul class="schedule-day">
- <?php foreach ($days_shows[$key] as $repeat_show) {
- $GLOBALS['post'] = $repeat_show;
- setup_postdata($GLOBALS['post']);
- print '<li class="schedule-show">';
- print get_template_part('schedule', $repeat_show->post_type);
- print '</li>';
- wp_reset_postdata();
- } ?>
- </ul>
- <?php endif; ?>
- [/tab]
- <?php endforeach; ?>
- [/tabcontent]
- [/tabs]
- <?php
- // Output the tabbed schedule
- print '<div class="schedule">' . do_shortcode(ob_get_clean()) . '</div>';
- // If comments are open or we have at least one comment, load up the comment template.
- if ( comments_open() || get_comments_number() ) {
- comments_template();
- }
- // End of the loop.
- endwhile;
- ?>
- <?php if ( ! $is_page_builder_used ) : ?>
- </div> <!-- #left-area -->
- <?php get_sidebar(); ?>
- </div> <!-- #content-area -->
- </div> <!-- .container -->
- <?php endif; ?>
- </div> <!-- #main-content -->
- <?php get_footer(); ?>
Add Comment
Please, Sign In to add comment