'
. ''
. '' . esc_html__( 'Other dates', 'eventwright' ) . '
';
foreach ( array_slice( $rows, 0, 12 ) as $r ) {
$html .= '
' . esc_html( $venue['full_address'] ); $map = eventwright_venue_map_url( $venue ); if ( $map ) { $html .= ' ' . esc_html__( 'Map', 'eventwright' ) . ''; } $html .= '
'; } $html .= Maps::button( $venue ); $bits = array(); if ( $venue['phone'] ) { $bits[] = '' . esc_html( $venue['phone'] ) . ''; } if ( $venue['website'] ) { $bits[] = '' . esc_html__( 'Website', 'eventwright' ) . ''; } if ( $bits ) { $html .= '' . implode( ' ', $bits ) . '
'; } $html .= '' . implode( ' ', $bits ) . '
' : ''; return $html . $content . self::related_events( array( 'organizer' => $post->ID ) ); } /** * Upcoming events for a venue or organizer. * * @param array $filter Query filter. * @return string */ private static function related_events( array $filter ) { $rows = Occurrences::query( array_merge( $filter, array( 'upcoming' => true, 'limit' => 20, ) ) ); Views::prime( $rows ); $html = ''; return $html; } /** * Show the date in front of event excerpts in theme archives and search. * * @param string $excerpt Excerpt. * @param \WP_Post $post Post. * @return string */ public static function excerpt_prefix( $excerpt, $post = null ) { if ( is_admin() || ! $post || Post_Types::EVENT !== $post->post_type || is_singular() || ( defined( 'REST_REQUEST' ) && REST_REQUEST ) ) { return $excerpt; } $occ = Occurrences::pick( $post->ID ); if ( ! $occ ) { return $excerpt; } $when = eventwright_format_when( $occ['start_local'], $occ['end_local'], (bool) $occ['all_day'], eventwright_event_timezone( $post->ID ) ); return $when . ' — ' . $excerpt; } /** * Theme archives of event tags and searches: soonest events first is not possible with WP_Query alone, so order by start meta. * * @param \WP_Query $q Query. */ public static function order_event_archives( $q ) { if ( is_admin() || ! $q->is_main_query() ) { return; } if ( $q->is_tax( Post_Types::CATEGORY ) || ( $q->is_tag() && Post_Types::EVENT === $q->get( 'post_type' ) ) ) { $q->set( 'meta_key', '_evwr_start' ); $q->set( 'orderby', 'meta_value' ); $q->set( 'order', 'DESC' ); } } /** * Canonical URL of the events page when it shows one category. * * @param string $url URL. * @param \WP_Post $post Post. * @return string */ public static function canonical( $url, $post ) { $page_id = (int) Settings::get( 'events_page_id' ); if ( $page_id && (int) $post->ID === $page_id ) { $state = Views::request_state(); if ( $state['cat'] ) { $term = get_term_by( 'slug', $state['cat'], Post_Types::CATEGORY ); if ( $term ) { $link = get_term_link( $term ); return is_wp_error( $link ) ? $url : $link; } } } return $url; } /** * Page title "Music – Events" for category views of the events page. * * @param array $parts Title parts. * @return array */ public static function title_parts( $parts ) { $page_id = (int) Settings::get( 'events_page_id' ); if ( $page_id && is_page( $page_id ) ) { $state = Views::request_state(); if ( $state['cat'] ) { $term = get_term_by( 'slug', $state['cat'], Post_Types::CATEGORY ); if ( $term ) { $parts['title'] = $term->name . ' – ' . $parts['title']; } } } return $parts; } /** * Status classes on event posts. * * @param string[] $classes Classes. * @param string[] $extra Extra. * @param int $post_id Post. * @return string[] */ public static function post_class( $classes, $extra, $post_id ) { if ( get_post_type( $post_id ) === Post_Types::EVENT ) { $status = get_post_meta( $post_id, '_evwr_status', true ); if ( $status && 'scheduled' !== $status ) { $classes[] = 'evw-status-' . sanitize_html_class( $status ); } } return $classes; } /** * schema.org Event data on single event pages. */ public static function json_ld() { if ( ! is_singular( Post_Types::EVENT ) || post_password_required() ) { return; } $data = self::schema( get_queried_object_id(), self::requested_date() ); if ( ! $data ) { return; } echo '' . "\n"; } /** * Build schema.org Event data. * * @param int $event_id Event. * @param string $date Occurrence date. * @return array|null */ public static function schema( $event_id, $date = '' ) { $event = eventwright_get_event( $event_id ); $occ = $event ? Occurrences::pick( $event_id, $date ) : null; if ( ! $occ ) { return null; } $tz = $event['timezone']; $status_map = array( 'scheduled' => 'https://schema.org/EventScheduled', 'cancelled' => 'https://schema.org/EventCancelled', 'postponed' => 'https://schema.org/EventPostponed', 'moved_online' => 'https://schema.org/EventMovedOnline', ); $data = array( '@context' => 'https://schema.org', '@type' => 'Event', 'name' => html_entity_decode( get_the_title( $event_id ), ENT_QUOTES, 'UTF-8' ), 'url' => eventwright_occurrence_url( $event_id, $occ['start_local'] ), 'startDate' => eventwright_iso8601( $occ['start_local'], $tz, (bool) $occ['all_day'] ), 'endDate' => eventwright_iso8601( $occ['end_local'], $tz, (bool) $occ['all_day'] ), 'eventStatus' => isset( $status_map[ $event['status'] ] ) ? $status_map[ $event['status'] ] : $status_map['scheduled'], ); $desc = Views::excerpt( get_post( $event_id ), 60 ); if ( $desc ) { $data['description'] = $desc; } $img = get_the_post_thumbnail_url( $event_id, 'full' ); if ( $img ) { $data['image'] = array( $img ); } $venue = eventwright_get_venue( $event['venue_id'] ); $locations = array(); if ( $venue ) { $place = array( '@type' => 'Place', 'name' => $venue['name'], ); $address = array_filter( array( '@type' => 'PostalAddress', 'streetAddress' => $venue['address'], 'addressLocality' => $venue['city'], 'addressRegion' => $venue['state'], 'postalCode' => $venue['zip'], 'addressCountry' => $venue['country'], ) ); if ( count( $address ) > 1 ) { $place['address'] = $address; } if ( $venue['lat'] && $venue['lng'] ) { $place['geo'] = array( '@type' => 'GeoCoordinates', 'latitude' => (float) $venue['lat'], 'longitude' => (float) $venue['lng'], ); } $locations[] = $place; } if ( $event['online_url'] ) { $locations[] = array( '@type' => 'VirtualLocation', 'url' => $event['online_url'], ); } if ( $locations ) { $data['location'] = 1 === count( $locations ) ? $locations[0] : $locations; $data['eventAttendanceMode'] = $venue && $event['online_url'] ? 'https://schema.org/MixedEventAttendanceMode' : ( $venue ? 'https://schema.org/OfflineEventAttendanceMode' : 'https://schema.org/OnlineEventAttendanceMode' ); } $orgs = array(); foreach ( $event['organizer_ids'] as $oid ) { $o = eventwright_get_organizer( $oid ); if ( $o ) { $orgs[] = array_filter( array( '@type' => 'Organization', 'name' => $o['name'], 'url' => $o['website'] ? $o['website'] : $o['url'], ) ); } } if ( $orgs ) { $data['organizer'] = 1 === count( $orgs ) ? $orgs[0] : $orgs; } $price = eventwright_cost_number( $event['cost'] ); if ( null !== $price ) { $data['offers'] = array( '@type' => 'Offer', 'price' => $price, 'priceCurrency' => Settings::get( 'currency' ), 'url' => $event['website'] ? $event['website'] : $data['url'], 'availability' => RSVP::is_full( $event_id, $occ ) ? 'https://schema.org/SoldOut' : 'https://schema.org/InStock', ); } return apply_filters( 'eventwright_schema', $data, $event_id, $occ ); } }