Last active
March 3, 2017 21:08
-
-
Save halfempty/9ef132d689d0cc14d27d1bda7965cd44 to your computer and use it in GitHub Desktop.
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 | |
/** | |
* @package Cecil | |
*/ | |
namespace Carnegie_Museums\Warhol\Theme; | |
use Carnegie_Museums\Warhol\Theme\Helpers; | |
if ( is_page('calendar-2') ) : | |
$calendar = get_page_by_path('calendar'); | |
$url = get_permalink($calendar->ID); | |
wp_redirect(clean_url($url), 301); | |
exit; | |
endif; | |
get_header();?> | |
<div id="content"> | |
<div class="gridContainer clearfix"> | |
<?php if ( have_posts() ) : ?> | |
<?php while ( have_posts() ) : the_post(); ?> | |
<?php do_action( 'cecil_breadcrumbs' ); ?> | |
<h1 id="page-title"><?php the_title(); ?></h1> | |
<div id="content-box"> | |
<div id="leftnav"> | |
<?php do_action( 'warhol_desktop_sidebar' ); ?> | |
</div><!-- #leftnav --> | |
<div id="main"> | |
<div class="main-content" id="ctl00_ContentPlaceHolder1_uxMainContent"> | |
<div id="page-top"> | |
<div id="page-top-image"> | |
<?php Helpers\display_featured_image_with_credits(); ?> | |
</div> | |
</div> | |
<?php the_content(); ?> | |
</div><!-- #ctl00_ContentPlaceHolder1_uxMainContent --> | |
<?php do_action( 'warhol_after_content' ); ?> | |
<div id="mobile-sidebar"> | |
<?php do_action( 'warhol_mobile_sidebar' ); ?> | |
</div><!-- #mobile-sidebar --> | |
</div><!-- #main --> | |
</div><!-- #content-box --> | |
<?php endwhile; ?> | |
<?php endif; ?> | |
</div><!-- .gridContainer.clearfix --> | |
</div><!-- #content --> | |
<?php | |
get_footer(); |
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 | |
/** | |
* @package Cecil | |
*/ | |
namespace Carnegie_Museums\Warhol\Theme; | |
use Carnegie_Museums\Warhol\Theme\Helpers; | |
// Pull in post meta | |
$post_id = get_the_id(); | |
// Get Event data | |
global $wpdb; | |
// Find Events ending today or later | |
$all_in_one_table_data = $wpdb->get_results( $wpdb->prepare( | |
"SELECT cost, ticket_url | |
FROM wp_ai1ec_events | |
WHERE post_id='%s'", absint( $post_id ) | |
), ARRAY_A ); | |
if ( ! empty( $all_in_one_table_data ) && ! empty( $all_in_one_table_data[0] ) ) { | |
$cost_data = maybe_unserialize( $all_in_one_table_data[0]['cost'] ); | |
$ticket_url = $all_in_one_table_data[0]['ticket_url']; | |
if ( ! empty( $cost_data ) && isset( $cost_data['cost'] ) ) { | |
$cost = $cost_data['cost']; | |
} | |
if ( ! empty( $cost_data ) && isset( $cost_data['is_free'] ) ) { | |
$is_free = $cost_data['is_free']; | |
} | |
} | |
// Get the meta data | |
$formatted_title = get_post_meta( $post_id, 'formatted_title', true ); | |
$readable_date = get_post_meta( $post_id, 'readable_date', true ); | |
$footnote = get_post_meta( $post_id, 'footnote', true ); | |
$sold_out = (bool) get_post_meta( $post_id, 'sold_out', true ); | |
$ticket_button_label = get_post_meta( $post_id, 'ticket_button_label', true ); | |
$student_price = get_post_meta( $post_id, 'student_price', true ); | |
$cmp_member_price = get_post_meta( $post_id, 'cmp_member_price', true ); | |
$other_ticket_option = get_post_meta( $post_id, 'other_ticket_option', true ); | |
$other_ticket_price = get_post_meta( $post_id, 'other_ticket_price', true ); | |
$additional_info = get_post_meta( $post_id, 'additional_info', true ); | |
$related_links = get_post_meta( $post_id, 'related_links', true ); | |
$related_events = get_post_meta( $post_id, 'related_events', true ); | |
$lobby_image = get_post_meta( $post_id, 'lobby_image', true ); | |
// Sort through the Related Events, and re-order them to be in chronological order | |
if ( ! empty( $related_events ) ) { | |
$related_events = Helpers\sort_events_by_start_time( $related_events ); | |
} | |
// Sort through the structure of ACF repeater fields to get all the Additional Video and Audio items | |
$additional_video_count = absint( get_post_meta( get_the_ID(), 'additional_video', true ) ); | |
if ( ! empty( $additional_video_count ) ) { | |
$additional_video = array(); | |
for ( $i = 0; $i < $additional_video_count; $i++ ) { | |
$additional_video[ $i ] = array(); | |
$additional_video[ $i ]['embed'] = get_post_meta( get_the_ID(), 'additional_video_' . $i . '_embed', true ); | |
$additional_video[ $i ]['caption'] = get_post_meta( get_the_ID(), 'additional_video_' . $i . 'caption', true ); | |
} | |
} | |
// Get the taxonomies | |
$event_categories = get_the_terms( $post_id, 'events_categories' ); | |
$locations = get_the_terms( $post_id, 'locations' ); | |
// Pull in content this way to get around All-in-One's weird way of filtering the_content | |
$post_content = get_post_field( 'post_content', $post_id ); | |
get_header();?> | |
<div id="content"> | |
<div class="gridContainer clearfix"> | |
<?php if ( have_posts() ) : ?> | |
<?php while ( have_posts() ) : the_post(); ?> | |
<?php do_action( 'cecil_breadcrumbs' ); ?> | |
<h1 id="page-title"> | |
<?php if ( ! empty( $formatted_title ) ) : ?> | |
<?php echo wp_kses_post( $formatted_title ); ?> | |
<?php else : ?> | |
<?php the_title(); ?> | |
<?php endif; ?> | |
</h1> | |
<div id="content-box"> | |
<div id="event-column1"> | |
<div id="event-category"> | |
<?php if ( ! empty( $event_categories ) && ! is_wp_error( $event_categories ) ) : ?> | |
<?php foreach ( $event_categories as $category ) : ?> | |
<div class="event-type"> | |
<a | |
title="<?php echo esc_attr( sprintf( __( 'See all %s', 'warhol' ), $category->name ) ); ?>" | |
href="/calendar/?event_category=<?php echo $category->slug; ?>" | |
> | |
<?php echo esc_html( $category->name ); ?> | |
</a> | |
</div> | |
<?php endforeach; ?> | |
<?php endif; ?> | |
</div> | |
<div id="ctl00_ContentPlaceHolder1_uxLeftColumn"> | |
<div id="event-time"> | |
<div class="event-headline">when</div> | |
<div id="event-time-date"> | |
<?php echo esc_html( $readable_date ); ?> | |
</div> | |
<div class="ai1ec-subscribe-dropdown ai1ec-dropdown ai1ec-btn | |
ai1ec-btn-default ai1ec-btn-sm"> | |
<span role="button" class="ai1ec-dropdown-toggle ai1ec-subscribe" data-toggle="ai1ec-dropdown"> | |
<i class="ai1ec-fa ai1ec-icon-rss ai1ec-fa-lg ai1ec-fa-fw"></i> | |
<span class="ai1ec-hidden-xs"> | |
Add to Calendar | |
<span class="ai1ec-caret"></span> | |
</span> | |
</span> | |
<?php | |
$google_url = sprintf( 'http://www.google.com/calendar/render?cid=%s1&ai1ec_post_ids=%d2&no_html=true', AI1EC_EXPORT_URL, get_the_id() ); | |
$outlook_url = AI1EC_EXPORT_URL . '&ai1ec_post_ids=' . get_the_id() . '&no_html=true'; | |
$apple_url = AI1EC_EXPORT_URL . '&ai1ec_post_ids=' . get_the_id() . '&no_html=true'; | |
$other_url = AI1EC_EXPORT_URL . '&ai1ec_post_ids=' . get_the_id() . '&no_html=true'; | |
?> | |
<ul class="ai1ec-dropdown-menu ai1ec-pull-right" role="menu"> | |
<li> | |
<a | |
class="ai1ec-tooltip-trigger ai1ec-tooltip-auto" | |
target="_blank" | |
data-placement="left" | |
title="Subscribe to this calendar in your Google Calendar" | |
href="<?php echo esc_url( $google_url ); ?>" | |
> | |
<i class="ai1ec-fa ai1ec-icon-google ai1ec-fa-lg ai1ec-fa-fw"></i> | |
Add to Google | |
</a> | |
</li> | |
<li> | |
<a | |
class="ai1ec-tooltip-trigger ai1ec-tooltip-auto" | |
target="_blank" | |
data-placement="left" | |
title="Subscribe to this calendar in MS Outlook" | |
href="<?php echo esc_url( $outlook_url ); ?>" | |
> | |
<i class="ai1ec-fa ai1ec-icon-windows ai1ec-fa-lg ai1ec-fa-fw"></i> | |
Add to Outlook | |
</a> | |
</li> | |
<li> | |
<a | |
class="ai1ec-tooltip-trigger ai1ec-tooltip-auto" | |
target="_blank" | |
data-placement="left" | |
title="Subscribe to this calendar in Apple Calendar/iCal" | |
href="<?php echo esc_url( $apple_url ); ?>" | |
> | |
<i class="ai1ec-fa ai1ec-icon-apple ai1ec-fa-lg ai1ec-fa-fw"></i> | |
Add to Apple Calendar | |
</a> | |
</li> | |
<li> | |
<a | |
class="ai1ec-tooltip-trigger ai1ec-tooltip-auto" | |
data-placement="left" | |
title="Subscribe to this calendar in another plain-text calendar" | |
href="<?php echo esc_url( $other_url ); ?>" | |
> | |
<i class="ai1ec-fa ai1ec-icon-calendar ai1ec-fa-fw"></i> | |
Add to other calendar | |
</a> | |
</li> | |
</ul> | |
</div> | |
</div> | |
<?php if ( ! empty( $locations ) && ! is_wp_error( $locations ) ) : ?> | |
<div id="event-location"> | |
<div class="event-headline">where</div> | |
<p class="event-location-link"> | |
<?php echo esc_html( $locations[0]->name ); ?> | |
</p> | |
<?php | |
$map_data = get_term_meta( $locations[0]->term_id, 'map', true ); | |
?> | |
<?php if ( ! empty( $map_data ) && isset( $map_data['address'] ) && defined( 'GOOGLE_MAPS_API_KEY' ) ) : ?> | |
<?php | |
$embed_url = 'https://www.google.com/maps/embed/v1/place'; | |
$embed_url = add_query_arg( array( | |
'q' => $map_data['address'], | |
'zoom' => '13', | |
'key' => GOOGLE_MAPS_API_KEY, | |
), $embed_url ); | |
?> | |
<iframe | |
src="<?php echo esc_url( $embed_url ); ?>" | |
class="event-location-iframe" | |
></iframe> | |
<?php endif; ?> | |
<div class="clear"></div> | |
</div> | |
<?php endif; ?> | |
<div id="event-tickets"> | |
<div class="event-headline">tickets</div> | |
<?php if ( true === $sold_out ) : ?> | |
<span class="sold-out-text">Sold Out</span> | |
<?php else : ?> | |
<table> | |
<tbody> | |
<?php if ( ( empty( $cost ) && empty( $ticket_url ) ) || | |
( isset( $is_free ) && true === $is_free ) ) : ?> | |
<p>Free with museum admission</p> | |
<?php endif; ?> | |
<?php if ( ! empty( $cost ) ) : ?> | |
<tr> | |
<td>General</td> | |
<td><?php echo esc_html( $cost ); ?></td> | |
</tr> | |
<?php endif; ?> | |
<?php if ( ! empty( $student_price ) ) : ?> | |
<tr> | |
<td>Student</td> | |
<td><?php echo esc_html( $student_price ); ?></td> | |
</tr> | |
<?php endif; ?> | |
<?php if ( ! empty( $cmp_member_price ) ) : ?> | |
<tr> | |
<td> | |
<a href="<?php echo esc_url( site_url( '/support/membership/' ) ); ?>"> | |
Members | |
</a> | |
</td> | |
<td><?php echo esc_html( $cmp_member_price ); ?></td> | |
</tr> | |
<?php endif; ?> | |
<?php if ( ! empty( $other_ticket_option ) && | |
! empty( $other_ticket_price ) ) : ?> | |
<tr> | |
<td><?php echo esc_html( $other_ticket_option ); ?></td> | |
<td><?php echo esc_html( $other_ticket_price ); ?></td> | |
</tr> | |
<?php endif; ?> | |
<?php if ( ! empty( $ticket_url ) ) : ?> | |
<tr> | |
<td colspan="2"> | |
<a | |
href="<?php echo esc_url( $ticket_url ); ?>" | |
target="_blank" | |
id="ticketbuylink" | |
> | |
<?php if ( ! empty( $ticket_button_label ) ) : ?> | |
<?php echo esc_html( $ticket_button_label ); ?> | |
<?php else : ?> | |
Buy Tickets | |
<?php endif; ?> | |
</a> | |
</td> | |
</tr> | |
<?php endif; ?> | |
</tbody> | |
</table> | |
<?php endif; ?> | |
</div> | |
</div> | |
</div> | |
<div id="ctl00_ContentPlaceHolder1_uxMiddleColumn"> | |
<div id="event-column2"> | |
<div id="event-image"> | |
<?php if ( ! empty( $lobby_image ) ) : ?> | |
<?php Helpers\display_featured_image_with_credits( $lobby_image ) ?> | |
<?php else : ?> | |
<?php Helpers\display_featured_image_with_credits(); ?> | |
<?php endif; ?> | |
</div> | |
<div id="event-imagedescription"> | |
<?php | |
// See top of file, this is working around All-in-One's behavior | |
echo do_shortcode( wpautop( $post_content ) ); | |
?> | |
</div> | |
<?php if ( ! empty( $footnote ) ) : ?> | |
<div id="event-sponsor"> | |
<?php echo wp_kses_post( wpautop( $footnote ) ); ?> | |
</div> | |
<?php endif; ?> | |
<?php if ( ! empty( $additional_info ) ) : ?> | |
<div id="event-additional"> | |
<h2>Additional Information</h2> | |
<eventadditionalinfo> | |
<?php echo wp_kses_post( wpautop( $additional_info ) ); ?> | |
</eventadditionalinfo> | |
</div> | |
<?php endif; ?> | |
<?php if ( ! empty( $related_links ) ) : ?> | |
<div id="event-related-links"> | |
<h2>Related Links</h2> | |
<?php echo wp_kses_post( wpautop( $related_links ) ); ?> | |
</div> | |
<?php endif; ?> | |
<?php if ( ! empty( $additional_video_count ) ) : ?> | |
<div id="event-related-media"> | |
<h2>Related Media</h2> | |
<?php foreach ( $additional_video as $video ) : ?> | |
<div class="video-container"> | |
<?php | |
// @codingStandardsIgnoreStart | |
echo wp_specialchars_decode( $video['embed'] ); | |
// @codingStandardsIgnoreEnd | |
?> | |
</div> | |
<?php endforeach; ?> | |
</div> | |
<?php endif; ?> | |
</div> | |
</div> | |
<div id="event-column3"> | |
<?php if ( ! empty( $related_events ) && is_array( $related_events ) ) : ?> | |
<div id="event-related-events"> | |
<div class="event-headline">related events</div> | |
<?php | |
foreach ( $related_events as $related_event ) : | |
$related_event_title = get_the_title( $related_event ); | |
$related_readable_dates = get_post_meta( $related_event, 'readable_date', true ); | |
?> | |
<div class="event-related-item"> | |
<a | |
title="<?php echo esc_attr( $related_event_title ); ?>" | |
class="link" | |
href="<?php echo esc_url( get_permalink( $related_event ) ); ?>" | |
> | |
<?php echo esc_html( $related_event_title ); ?> | |
</a> | |
<div class="clear"></div> | |
<div class="event-related-events-date"> | |
<?php echo esc_html( $related_readable_dates ); ?> | |
</div> | |
</div> | |
<?php endforeach; ?> | |
</div> | |
<?php endif; ?> | |
<?php get_template_part( 'template-parts/events-search-categories' ); ?> | |
<?php get_template_part( 'template-parts/events-search-calendar' ); ?> | |
</div> | |
<?php endwhile; ?> | |
<?php endif; ?> | |
</div> | |
</div> | |
<?php | |
get_footer(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment