Skip to content

Commit 74018db

Browse files
committed
Merge branch 'TMS-1093' into stage
2 parents ad8b466 + 798e0d5 commit 74018db

File tree

6 files changed

+89
-2
lines changed

6 files changed

+89
-2
lines changed

CHANGELOG.MD

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77

88
## [Unreleased]
99

10+
- TMS-1093: Add graphics for dynamic event main images
11+
12+
## [1.59.4] - 2024-12-09
13+
1014
- TMS-1089: Fix event fetching for events-component
1115

1216
## [1.59.3] - 2024-11-25

lib/Eventz.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ public static function normalize_event( $event ) : array {
174174
'image' => $image ?? null,
175175
'url' => static::get_event_url( $event->_id ),
176176
'is_dynamic' => static::get_dynamic_event( $event->_id ),
177+
'graphic_field' => static::get_dynamic_event_fields( $event->_id ),
177178
];
178179
}
179180

@@ -594,6 +595,23 @@ public static function get_event_url( string $event_id ) : string {
594595
return '#';
595596
}
596597

598+
/**
599+
* Get dynamic events custom fields
600+
*
601+
* @param string $event_id Event's API ID.
602+
*
603+
* @return array
604+
*/
605+
public static function get_dynamic_event_fields( string $event_id ) : array {
606+
$dynamic_events = DynamicEvent::get_event_graphic_field();
607+
608+
if ( isset( $dynamic_events[ $event_id . '_graphic' ] ) ) {
609+
return $dynamic_events[ $event_id . '_graphic' ];
610+
}
611+
612+
return [];
613+
}
614+
597615
/**
598616
* Get dynamic events
599617
*

lib/PostType/DynamicEvent.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,4 +216,42 @@ public static function get_link_list() : array {
216216

217217
return $dynamic_events;
218218
}
219+
220+
/**
221+
* Get custom fields
222+
*
223+
* @return array
224+
*/
225+
public static function get_event_graphic_field() : array {
226+
$dynamic_events = [];
227+
228+
if ( ! empty( $dynamic_events ) ) {
229+
return $dynamic_events;
230+
}
231+
232+
$the_query = new \WP_Query( [
233+
'post_type' => self::SLUG,
234+
'posts_per_page' => - 1,
235+
'fields' => 'ids',
236+
'no_found_rows' => true,
237+
'post_status' => 'publish',
238+
] );
239+
240+
if ( ! $the_query->have_posts() ) {
241+
return $dynamic_events;
242+
}
243+
244+
foreach ( $the_query->posts as $dynamic_event_id ) {
245+
$api_id = \get_field( 'event', $dynamic_event_id );
246+
$graphic_field = \get_field( 'graphic', $dynamic_event_id );
247+
248+
if ( $api_id ) {
249+
if ( $graphic_field && $graphic_field !== 'none' ) {
250+
$dynamic_events[ $api_id . '_graphic' ][] = \get_stylesheet_directory_uri() . '/assets/images/' . $graphic_field . '.svg';
251+
}
252+
}
253+
}
254+
255+
return $dynamic_events;
256+
}
219257
}

models/single-dynamic-event-cpt.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,33 @@ public function hero_image() {
3939
: false;
4040
}
4141

42+
/**
43+
* Hero image URL
44+
*
45+
* @return false|string
46+
*/
47+
public function hero_image_url() {
48+
return has_post_thumbnail()
49+
? get_the_post_thumbnail_url()
50+
: false;
51+
}
52+
53+
/**
54+
* Hero image graphic field
55+
*
56+
* @return false|string
57+
*/
58+
public function hero_image_graphic() {
59+
$graphic_field = \get_field( 'graphic' );
60+
$hero_graphic = false;
61+
62+
if ( $graphic_field && $graphic_field !== 'none' ) {
63+
$hero_graphic = get_stylesheet_directory_uri() . '/assets/images/' . $graphic_field . '.svg';
64+
}
65+
66+
return $hero_graphic;
67+
}
68+
4269
/**
4370
* Get event id
4471
*

partials/views/single-dynamic-event/single-dynamic-event-hero-meta.dust

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
{/event.normalized.location}
2828

2929
{?event.normalized.link_purchase_ticket}
30-
<div class="has-width-100 mt-3">
30+
<div class="has-width-100 has-text-left mt-3">
3131
<a href="{event.normalized.link_purchase_ticket.url|url}" target="_blank" class="is-inline-block button is-small is-primary">
3232
{event.normalized.link_purchase_ticket.name|html}
3333
</a>

style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Theme Name: TMS Theme Base
33
* Description: Tampere Multisite Base Theme
44
* Domain Path: /lang
5-
* Version: 1.59.3
5+
* Version: 1.59.4
66
* Author: Geniem
77
* Author URI: https://geniem.fi
88
* Text Domain: tms-theme-base

0 commit comments

Comments
 (0)