[$this, 'render'] ] ); } public function render(array $attributes, string $content, WP_Block $block):string { if (!is_singular(BASE.'event')) { return ''; } $meta = Meta::forPost(get_the_ID()); $values = $meta->getAll(); $out = '
'; $out .= Events::tags($values); if (!empty($values['post_thumbnail'])) { $out .= jvbFormatImage($values['post_thumbnail']); } $out .= '
'; if (!empty($values['post_title'])) { $out .= sprintf( '

%s

', sanitize_title($values['post_title']), $values['post_title'] ); } $out .= Events::calendarDay($values['date_start']??''); $out .= '
'; $out .= '
'; $out .= sprintf( ''; $out .= Events::location($values); $out .= $this->price($values['cost']??'', $values['ticket_url']??''); $out .= $this->participants($values['max_participants']??''); $out .= Events::terms($values); $out .= $this->rsvp($values['rsvp_required']??'', $values['rsvp_limit']??'', $values['rsvp_deadline']); $out .= '
'; $out .= $this->gallery($values['gallery']??''); $out .= $this->moreInfo($values['external_url']??''); $out .= '
'; return $out; } public function renderGallery():void { jvbRenderGallery(); } protected function price(string $price, string $url):string { $out = ''; if (!empty($price) || $price !== '0') { $out = jvbCurrency($price); } if (!empty($url)) { $out .= sprintf( '
%sPurchase Tickets', esc_url($url), jvbIcon('ticket') ); } return empty($out) ? $out : '

'.$out.'

'; } protected function participants(string $num):string { $out = ''; if (!empty($num) || $num !== '0') { $out .= sprintf( '

Maximum %d participants

', $num ); } return $out; } protected function moreInfo(string $url):string { $out = ''; if (!empty($url)) { $out .= sprintf( '

%sLearn More

', jvbIcon('link'), esc_url($url) ); } return $out; } protected function rsvp(string $mustRSVP, string $limit, string $deadline):string { $out = ''; if (!empty($mustRSVP) && $mustRSVP === '1') { $out = '

RSVP Required'; if (!empty($limit) && $limit !== '0') { $out .= sprintf( '
Maximum %d Seats', $limit ); } if (!empty($deadline)) { $out .= sprintf( '
RSVP Deadline: ', date('c', $deadline), date('F j, Y', $deadline) ); } $out .= '

'; } return $out; } protected function gallery(string $gallery):string { $out = ''; if (!empty($gallery)) { add_action('wp_footer', [$this, 'renderGallery']); $out = ''; } return $out; } }