'',
'month' => '',
'week' => '',
'day' => '',
'cat' => '',
'page' => 1,
);
$view = isset( $state['evwr_view'] ) ? sanitize_key( $state['evwr_view'] ) : '';
if ( $view ) {
if ( isset( Compat_TEC::VIEWS[ $view ] ) ) {
$view = Compat_TEC::VIEWS[ $view ];
}
$out['view'] = in_array( $view, array( 'month', 'week', 'list', 'past' ), true ) ? $view : '';
}
if ( ! empty( $state['evwr_month'] ) && preg_match( '/^(\d{4})-(\d{2})$/', $state['evwr_month'], $m ) && (int) $m[2] >= 1 && (int) $m[2] <= 12 && (int) $m[1] > 1900 && (int) $m[1] < 2200 ) {
$out['month'] = $state['evwr_month'];
}
if ( ! empty( $state['evwr_day'] ) ) {
$d = eventwright_sanitize_local_datetime( $state['evwr_day'] );
$out['day'] = $d ? substr( $d, 0, 10 ) : '';
}
if ( ! empty( $state['evwr_week'] ) ) {
$d = eventwright_sanitize_local_datetime( $state['evwr_week'] );
$out['week'] = $d ? substr( $d, 0, 10 ) : '';
}
if ( ! empty( $state['evwr_cat'] ) ) {
$parts = explode( '/', trim( (string) $state['evwr_cat'], '/' ) );
$out['cat'] = sanitize_title( end( $parts ) );
}
if ( ! empty( $state['evwr_page'] ) ) {
$out['page'] = max( 1, min( 1000, absint( $state['evwr_page'] ) ) );
}
return $out;
}
/**
* Normalise calendar attributes from blocks and shortcodes.
*
* @param array $atts Raw.
* @return array
*/
public static function calendar_atts( $atts ) {
$atts = wp_parse_args(
is_array( $atts ) ? $atts : array(),
array(
'view' => Settings::get( 'default_view' ),
'categories' => array(),
'show_filters' => true,
'show_subscribe' => true,
'per_page' => Settings::get( 'list_per_page' ),
'show_images' => true,
'base_url' => '',
)
);
return array(
'view' => in_array( $atts['view'], array( 'month', 'week', 'list' ), true ) ? $atts['view'] : 'month',
'categories' => self::term_ids( $atts['categories'] ),
'show_filters' => self::to_bool( $atts['show_filters'] ),
'show_subscribe' => self::to_bool( $atts['show_subscribe'] ),
'per_page' => max( 1, min( 100, absint( $atts['per_page'] ) ) ),
'show_images' => self::to_bool( $atts['show_images'] ),
'base_url' => $atts['base_url'] ? esc_url_raw( $atts['base_url'] ) : '',
);
}
/**
* Truthy check for shortcode values like "yes", "false", "0".
*
* @param mixed $v Value.
* @return bool
*/
public static function to_bool( $v ) {
if ( is_string( $v ) ) {
return ! in_array( strtolower( $v ), array( '', '0', 'false', 'no', 'off' ), true );
}
return (bool) $v;
}
/**
* Category ids from ids, slugs, comma lists or arrays.
*
* @param mixed $cats Input.
* @return int[]
*/
public static function term_ids( $cats ) {
if ( is_string( $cats ) ) {
$cats = '' === trim( $cats ) ? array() : explode( ',', $cats );
}
$ids = array();
foreach ( (array) $cats as $c ) {
$c = trim( (string) $c );
if ( '' === $c ) {
continue;
}
if ( ctype_digit( $c ) ) {
$ids[] = (int) $c;
continue;
}
$term = get_term_by( 'slug', sanitize_title( $c ), Post_Types::CATEGORY );
if ( $term ) {
$ids[] = (int) $term->term_id;
}
}
return array_values( array_unique( $ids ) );
}
/**
* Base URL for view links (current page without our state args).
*
* @param array $atts Attributes.
* @return string
*/
public static function base_url( array $atts ) {
if ( ! empty( $atts['base_url'] ) ) {
$url = wp_validate_redirect( $atts['base_url'], home_url( '/' ) );
} else {
global $wp;
$path = isset( $wp->request ) ? $wp->request : '';
$url = home_url( $path ? user_trailingslashit( $path ) : '/' );
// Keep foreign query args (for example ?page_id= on sites without pretty links).
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only.
foreach ( $_GET as $k => $v ) {
$k = sanitize_key( $k );
if ( ! in_array( $k, self::STATE_KEYS, true ) && is_scalar( $v ) && in_array( $k, array( 'page_id', 'p', 'post_type', 'lang' ), true ) ) {
$url = add_query_arg( $k, rawurlencode( sanitize_text_field( wp_unslash( $v ) ) ), $url );
}
}
}
return remove_query_arg( self::STATE_KEYS, $url );
}
/**
* Full calendar (month or list) with toolbar.
*
* @param array $atts Attributes.
* @param array|null $state View state (null = read from the request).
* @return string
*/
public static function calendar( $atts = array(), $state = null ) {
$atts = self::calendar_atts( $atts );
$state = null === $state ? self::request_state() : self::clean_state( $state );
Frontend::enqueue_assets();
$view = $state['view'] ? $state['view'] : $atts['view'];
if ( $state['day'] && ! $state['view'] ) {
$view = 'list';
}
$cats = $atts['categories'];
$cat_term = null;
if ( $state['cat'] ) {
$cat_term = get_term_by( 'slug', $state['cat'], Post_Types::CATEGORY );
if ( $cat_term ) {
$cats = array( (int) $cat_term->term_id );
}
}
$base = self::base_url( $atts );
if ( $state['cat'] && $cat_term ) {
$base = add_query_arg( 'evwr_cat', $cat_term->slug, $base );
}
$month = $state['month'] ? $state['month'] : ( $state['day'] ? substr( $state['day'], 0, 7 ) : substr( eventwright_today_local(), 0, 7 ) );
$data = array(
'categories' => $atts['categories'],
'show_filters' => $atts['show_filters'],
'show_subscribe' => $atts['show_subscribe'],
'per_page' => $atts['per_page'],
'show_images' => $atts['show_images'],
'view' => $atts['view'],
);
$html = '
';
$html .= self::toolbar( $view, $month, $base, $atts, $state, $cat_term );
if ( $cat_term ) {
$html .= '
' . sprintf(
/* translators: %s: category name */
esc_html__( 'Showing: %s', 'eventwright' ),
'' . esc_html( $cat_term->name ) . ''
) . ' ' . esc_html__( 'Show all events', 'eventwright' ) . '
';
}
if ( 'month' === $view ) {
$html .= self::month_grid( $month, $cats, $base );
} elseif ( 'week' === $view ) {
$html .= self::week_grid( self::week_start( $state ), $cats, $base );
} else {
$html .= self::list_view( 'past' === $view, $state['day'], $state['page'], $cats, $atts, $base );
}
if ( $atts['show_subscribe'] ) {
$html .= self::subscribe_links( $cats );
}
$html .= '
';
return apply_filters( 'eventwright_calendar_html', $html, $atts, $state );
}
/**
* Toolbar with navigation, view switch and filter.
*
* @param string $view View.
* @param string $month Y-m.
* @param string $base Base URL.
* @param array $atts Attributes.
* @param array $state State.
* @param \WP_Term|null $cat_term Category filter.
* @return string
*/
private static function toolbar( $view, $month, $base, $atts, $state, $cat_term ) {
$html = '';
return $html;
}
/**
* Add days to a Y-m-d date.
*
* @param string $date Date.
* @param int $days Days (may be negative).
* @return string
*/
private static function add_days( $date, $days ) {
return gmdate( 'Y-m-d', strtotime( $date . ' 00:00:00 UTC' ) + $days * DAY_IN_SECONDS );
}
/**
* First day (Y-m-d) of the week shown, honouring the site's "week starts on" setting.
*
* @param array $state View state (uses week, day or month; empty = this week).
* @return string
*/
public static function week_start( array $state ) {
if ( ! empty( $state['week'] ) ) {
$anchor = $state['week'];
} elseif ( ! empty( $state['day'] ) ) {
$anchor = $state['day'];
} elseif ( ! empty( $state['month'] ) && substr( eventwright_today_local(), 0, 7 ) !== $state['month'] ) {
$anchor = $state['month'] . '-01';
} else {
$anchor = substr( eventwright_today_local(), 0, 10 );
}
$week_start = (int) get_option( 'start_of_week', 1 );
$dow = (int) gmdate( 'w', strtotime( $anchor . ' 00:00:00 UTC' ) );
return self::add_days( $anchor, -( ( $dow - $week_start + 7 ) % 7 ) );
}
/**
* Title of a week, like "Nov 22 - 28, 2026".
*
* @param string $start First day.
* @return string
*/
private static function week_title( $start ) {
$end = self::add_days( $start, 6 );
$a = $start . ' 00:00:00';
$b = $end . ' 00:00:00';
if ( substr( $start, 0, 4 ) !== substr( $end, 0, 4 ) ) {
return eventwright_format_local( 'M j, Y', $a ) . ' – ' . eventwright_format_local( 'M j, Y', $b );
}
if ( substr( $start, 0, 7 ) !== substr( $end, 0, 7 ) ) {
return eventwright_format_local( 'M j', $a ) . ' – ' . eventwright_format_local( 'M j, Y', $b );
}
return eventwright_format_local( 'M j', $a ) . ' – ' . eventwright_format_local( 'j, Y', $b );
}
/**
* Week view: seven day columns on wide screens, a plain day-by-day list on phones.
*
* @param string $start First day of the week (Y-m-d).
* @param int[] $cats Category ids.
* @param string $base Base URL.
* @return string
*/
public static function week_grid( $start, array $cats, $base ) {
$end = self::add_days( $start, 6 );
$today = eventwright_today_local();
$rows = Occurrences::query(
array(
'from' => $start . ' 00:00:00',
'to' => $end . ' 23:59:59',
'categories' => $cats,
'hide_hidden' => true,
)
);
self::prime( $rows );
$by_day = array();
foreach ( $rows as $row ) {
$d = max( substr( $row['start_local'], 0, 10 ), $start );
$last = min( self::effective_end_date( $row ), $end );
$n = 0;
while ( $d <= $last && $n++ < 8 ) {
$by_day[ $d ][] = $row;
$d = self::add_days( $d, 1 );
}
}
$html = '';
for ( $i = 0; $i < 7; $i++ ) {
$date = self::add_days( $start, $i );
$classes = array( 'evw-week-day' );
if ( $date === $today ) {
$classes[] = 'evw-is-today';
}
if ( $date < $today ) {
$classes[] = 'evw-is-past';
}
$classes[] = empty( $by_day[ $date ] ) ? 'evw-week-empty' : 'evw-has-events';
$html .= '
';
$html .= '';
if ( ! empty( $by_day[ $date ] ) ) {
$html .= '';
foreach ( $by_day[ $date ] as $row ) {
$html .= self::agenda_item( $row );
}
$html .= '
';
}
$html .= '';
}
$html .= '
';
if ( ! $by_day ) {
$html .= '' . esc_html__( 'No events this week.', 'eventwright' ) . '
';
}
return $html;
}
/**
* Month grid plus a phone-friendly agenda of the same month.
*
* @param string $month Y-m.
* @param int[] $cats Category ids.
* @param string $base Base URL.
* @return string
*/
public static function month_grid( $month, array $cats, $base ) {
$first = $month . '-01';
$first_ts = strtotime( $first . ' 00:00:00 UTC' );
$days_in = (int) gmdate( 't', $first_ts );
$week_start = (int) get_option( 'start_of_week', 1 );
$first_dow = (int) gmdate( 'w', $first_ts );
$lead = ( $first_dow - $week_start + 7 ) % 7;
$grid_start = gmdate( 'Y-m-d', $first_ts - $lead * DAY_IN_SECONDS );
$cells = (int) ( ceil( ( $lead + $days_in ) / 7 ) * 7 );
$grid_end = gmdate( 'Y-m-d', strtotime( $grid_start . ' 00:00:00 UTC' ) + ( $cells - 1 ) * DAY_IN_SECONDS );
$today = eventwright_today_local();
$rows = Occurrences::query(
array(
'from' => $grid_start . ' 00:00:00',
'to' => $grid_end . ' 23:59:59',
'categories' => $cats,
'hide_hidden' => true,
)
);
self::prime( $rows );
$by_day = array();
foreach ( $rows as $row ) {
$s_date = substr( $row['start_local'], 0, 10 );
$e_date = self::effective_end_date( $row );
$d = max( $s_date, $grid_start );
$last = min( $e_date, $grid_end );
$guard = 0;
while ( $d <= $last && $guard++ < 62 ) {
$by_day[ $d ][] = $row;
$d = gmdate( 'Y-m-d', strtotime( $d . ' 00:00:00 UTC' ) + DAY_IN_SECONDS );
}
}
global $wp_locale;
$html = '';
$html .= '' . esc_html( eventwright_format_local( 'F Y', $first . ' 00:00:00' ) ) . '';
$html .= '';
for ( $i = 0; $i < 7; $i++ ) {
$dow = ( $week_start + $i ) % 7;
$name = $wp_locale->get_weekday( $dow );
$html .= '| ' . esc_html( $wp_locale->get_weekday_abbrev( $name ) ) . ' | ';
}
$html .= '
';
$per_cell = (int) apply_filters( 'eventwright_month_events_per_day', 3 );
for ( $i = 0; $i < $cells; $i++ ) {
$date = gmdate( 'Y-m-d', strtotime( $grid_start . ' 00:00:00 UTC' ) + $i * DAY_IN_SECONDS );
if ( 0 === $i % 7 ) {
$html .= '';
}
$classes = array( 'evw-day' );
if ( substr( $date, 0, 7 ) !== $month ) {
$classes[] = 'evw-other-month';
}
if ( $date === $today ) {
$classes[] = 'evw-is-today';
}
if ( $date < $today ) {
$classes[] = 'evw-is-past';
}
$events = isset( $by_day[ $date ] ) ? $by_day[ $date ] : array();
if ( $events ) {
$classes[] = 'evw-has-events';
}
$html .= '';
$html .= '';
if ( $events ) {
$html .= '';
foreach ( array_slice( $events, 0, $per_cell ) as $row ) {
$html .= self::month_event_item( $row, $date );
}
$html .= ' ';
$more = count( $events ) - $per_cell;
if ( $more > 0 ) {
$html .= '' . esc_html(
/* translators: %d: number of more events */
sprintf( _n( '+%d more', '+%d more', $more, 'eventwright' ), $more )
) . '';
}
}
$html .= ' | ';
if ( 6 === $i % 7 ) {
$html .= '
';
}
}
$html .= '
';
// Agenda for small screens (and screen readers that prefer lists).
$html .= '';
$any = false;
for ( $d = 1; $d <= $days_in; $d++ ) {
$date = sprintf( '%s-%02d', $month, $d );
if ( empty( $by_day[ $date ] ) ) {
continue;
}
$any = true;
$html .= '
' . esc_html( eventwright_format_local( 'l, ' . self::short_date_format(), $date . ' 00:00:00' ) ) . '
';
foreach ( $by_day[ $date ] as $row ) {
$html .= self::agenda_item( $row );
}
$html .= '
';
}
$html .= '
';
if ( ! $any ) {
$html .= self::empty_month_note( $month, $cats, $base );
}
return $html;
}
/**
* End date for placing an occurrence on the grid (an event ending at midnight does not spill into the next day).
*
* @param array $row Occurrence row.
* @return string Y-m-d
*/
private static function effective_end_date( $row ) {
$e_date = substr( $row['end_local'], 0, 10 );
if ( '00:00:00' === substr( $row['end_local'], 11 ) && $row['end_local'] > $row['start_local'] ) {
$e_date = gmdate( 'Y-m-d', strtotime( $e_date . ' 00:00:00 UTC' ) - DAY_IN_SECONDS );
}
return max( $e_date, substr( $row['start_local'], 0, 10 ) );
}
/**
* Short date format without year.
*
* @return string
*/
private static function short_date_format() {
return apply_filters( 'eventwright_short_date_format', 'F j' );
}
/**
* One event inside a month cell.
*
* @param array $row Occurrence.
* @param string $date Cell date.
* @return string
*/
private static function month_event_item( $row, $date ) {
$id = (int) $row['event_id'];
$status = get_post_meta( $id, '_evwr_status', true );
$classes = array( 'evw-ev' );
$time = '';
if ( $row['all_day'] ) {
$classes[] = 'evw-all-day';
} elseif ( substr( $row['start_local'], 0, 10 ) === $date ) {
$time = eventwright_format_local( eventwright_time_format(), $row['start_local'] );
} else {
$classes[] = 'evw-continues';
}
if ( $status && 'scheduled' !== $status ) {
$classes[] = 'evw-status-' . $status;
}
$label = get_the_title( $id );
$html = '';
if ( $time ) {
$html .= '' . esc_html( $time ) . ' ';
}
$html .= '' . esc_html( $label ) . '';
if ( $status && 'scheduled' !== $status ) {
$html .= ' ' . esc_html( eventwright_status_label( $status ) ) . '';
}
$html .= '';
return $html;
}
/**
* One row of the small-screen agenda.
*
* @param array $row Occurrence.
* @return string
*/
private static function agenda_item( $row ) {
$id = (int) $row['event_id'];
$status = get_post_meta( $id, '_evwr_status', true );
$venue = eventwright_get_venue( (int) get_post_meta( $id, '_evwr_venue_id', true ) );
$when = $row['all_day'] ? __( 'All day', 'eventwright' ) : eventwright_format_local( eventwright_time_format(), $row['start_local'] );
$html = '' . esc_html( $when ) . ' ';
$html .= '' . esc_html( get_the_title( $id ) ) . '';
if ( $status && 'scheduled' !== $status ) {
$html .= ' ' . esc_html( eventwright_status_label( $status ) ) . '';
}
if ( $venue ) {
$html .= '' . esc_html( $venue['name'] ) . '';
}
$html .= '';
return $html;
}
/**
* "No events this month" with a link to the next month that has events.
*
* @param string $month Y-m.
* @param int[] $cats Categories.
* @param string $base Base URL.
* @return string
*/
private static function empty_month_note( $month, $cats, $base ) {
$month_end = gmdate( 'Y-m-t', strtotime( $month . '-01 00:00:00 UTC' ) ) . ' 23:59:59';
$next = Occurrences::query(
array(
'from' => $month_end,
'categories' => $cats,
'hide_hidden' => true,
'limit' => 1,
)
);
$html = '' . esc_html(
/* translators: %s: month and year */
sprintf( __( 'No events in %s.', 'eventwright' ), eventwright_format_local( 'F Y', $month . '-01 00:00:00' ) )
);
if ( $next ) {
$next_month = substr( $next[0]['start_local'], 0, 7 );
$html .= ' ' . esc_html(
/* translators: %s: month and year */
sprintf( __( 'Next events: %s', 'eventwright' ), eventwright_format_local( 'F Y', $next_month . '-01 00:00:00' ) )
) . ' →';
}
$html .= '
';
return $html;
}
/**
* List view (upcoming or past) with paging.
*
* @param bool $past Past events.
* @param string $day Start day for upcoming ('' = now).
* @param int $page Page.
* @param int[] $cats Categories.
* @param array $atts Attributes.
* @param string $base Base URL.
* @return string
*/
public static function list_view( $past, $day, $page, array $cats, array $atts, $base ) {
$per = $atts['per_page'];
$args = array(
'categories' => $cats,
'hide_hidden' => true,
'limit' => $per,
'offset' => ( $page - 1 ) * $per,
);
if ( $past ) {
$args['past'] = true;
$args['order'] = 'DESC';
} elseif ( $day ) {
$args['from'] = $day . ' 00:00:00';
} else {
$args['upcoming'] = true;
}
$rows = Occurrences::query( $args );
$total = Occurrences::query( array_merge( $args, array( 'count' => true, 'limit' => 0, 'offset' => 0 ) ) );
self::prime( $rows );
$html = '';
if ( ! $rows ) {
$html .= '
' . esc_html( $past ? __( 'No past events.', 'eventwright' ) : __( 'No upcoming events.', 'eventwright' ) ) . '
';
}
$current_month = '';
foreach ( $rows as $row ) {
$m = substr( $row['start_local'], 0, 7 );
if ( $m !== $current_month ) {
$current_month = $m;
$html .= '
' . esc_html( eventwright_format_local( 'F Y', $m . '-01 00:00:00' ) ) . '
';
}
$html .= self::list_item( $row, $atts['show_images'] );
}
$html .= '
';
$pages = (int) ceil( $total / $per );
if ( $pages > 1 || ! $past ) {
$html .= '';
}
return $html;
}
/**
* One list item.
*
* @param array $row Occurrence.
* @param bool $show_images Show the featured image.
* @return string
*/
public static function list_item( $row, $show_images = true ) {
$id = (int) $row['event_id'];
$post = get_post( $id );
$url = eventwright_occurrence_url( $id, $row['start_local'] );
$status = get_post_meta( $id, '_evwr_status', true );
$venue = eventwright_get_venue( (int) get_post_meta( $id, '_evwr_venue_id', true ) );
$cost = eventwright_format_cost( get_post_meta( $id, '_evwr_cost', true ) );
$when = eventwright_format_when( $row['start_local'], $row['end_local'], (bool) $row['all_day'], eventwright_event_timezone( $id ) );
$html = '';
$html .= '' . esc_html( eventwright_format_local( 'M', $row['start_local'] ) ) . '' . esc_html( eventwright_format_local( 'j', $row['start_local'] ) ) . '
';
$html .= '';
$html .= '
' . esc_html( get_the_title( $id ) ) . '';
if ( $status && 'scheduled' !== $status ) {
$html .= ' ' . esc_html( eventwright_status_label( $status ) ) . '';
}
$html .= '
';
$meta = array( '
' );
if ( $venue ) {
$meta[] = '
' . esc_html( $venue['name'] ) . '';
}
if ( $cost ) {
$meta[] = '
' . esc_html( $cost ) . '';
}
$html .= '
' . implode( ' · ', $meta ) . '
';
$excerpt = self::excerpt( $post );
if ( $excerpt ) {
$html .= '
' . esc_html( $excerpt ) . '
';
}
$html .= '
';
if ( $show_images && has_post_thumbnail( $id ) ) {
$html .= '' . get_the_post_thumbnail(
$id,
'medium',
array(
'loading' => 'lazy',
'alt' => '',
)
) . '';
}
$html .= '';
return $html;
}
/**
* Short plain-text excerpt without running the_content filters.
*
* @param \WP_Post|null $post Post.
* @param int $words Words.
* @return string
*/
public static function excerpt( $post, $words = 28 ) {
if ( ! $post ) {
return '';
}
if ( post_password_required( $post ) ) {
return '';
}
$text = $post->post_excerpt ? $post->post_excerpt : $post->post_content;
$text = excerpt_remove_blocks( $text );
$text = strip_shortcodes( $text );
$text = preg_replace( '#<(/p|/div|/h[1-6]|/li|br\s*/?)>#i', '$0 ', $text );
$text = trim( preg_replace( '/\s+/', ' ', wp_strip_all_tags( $text ) ) );
if ( '' === $text ) {
return '';
}
return html_entity_decode( wp_trim_words( $text, $words, '…' ), ENT_QUOTES, 'UTF-8' );
}
/**
* Compact list of upcoming events (for sidebars, home pages).
*
* @param array $atts {limit, categories, show_images, show_venue, show_all_link}.
* @return string
*/
public static function upcoming_list( $atts = array() ) {
Frontend::enqueue_assets();
$atts = wp_parse_args(
is_array( $atts ) ? $atts : array(),
array(
'limit' => 5,
'categories' => array(),
'show_images' => false,
'show_venue' => true,
'show_all_link' => true,
'layout' => 'list',
)
);
$rows = Occurrences::query(
array(
'upcoming' => true,
'categories' => self::term_ids( $atts['categories'] ),
'hide_hidden' => true,
'limit' => max( 1, min( 50, absint( $atts['limit'] ) ) ),
)
);
self::prime( $rows );
$layout = 'grid' === $atts['layout'] ? 'grid' : 'list';
$html = '';
if ( ! $rows ) {
$html .= '
' . esc_html__( 'No upcoming events.', 'eventwright' ) . '
';
} else {
$html .= '
';
}
if ( self::to_bool( $atts['show_all_link'] ) && (int) Settings::get( 'events_page_id' ) ) {
$html .= '
' . esc_html__( 'View all events', 'eventwright' ) . ' →
';
}
$html .= '
';
return $html;
}
/**
* Subscribe / export links under the calendar.
*
* @param int[] $cats Categories.
* @return string
*/
private static function subscribe_links( array $cats ) {
$feed = ICal::feed_url( $cats );
$html = '';
return $html;
}
/**
* Load posts and meta in bulk.
*
* @param array $rows Occurrence rows.
*/
public static function prime( array $rows ) {
$ids = array_values( array_unique( array_map( 'intval', wp_list_pluck( $rows, 'event_id' ) ) ) );
if ( ! $ids ) {
return;
}
_prime_post_caches( $ids, false, true );
$venues = array();
foreach ( $ids as $id ) {
$v = (int) get_post_meta( $id, '_evwr_venue_id', true );
if ( $v ) {
$venues[] = $v;
}
}
if ( $venues ) {
_prime_post_caches( array_unique( $venues ), false, true );
}
}
}