-
Notifications
You must be signed in to change notification settings - Fork 1
/
page-the-schedule.php
171 lines (138 loc) · 5.06 KB
/
page-the-schedule.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?php // phpcs:ignore
get_header();
$frontpage_id = get_option( 'page_on_front' );
?>
<div class="wrap">
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php while ( have_posts() ) : the_post(); // phpcs:ignore ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
<?php twentyseventeen_edit_link( get_the_ID() ); ?>
</header><!-- .entry-header -->
<div class="entry-content">
<?php the_content(); ?>
</div><!-- .entry-content -->
<div class="current-talk">
<hr class="tophr">
<h2>Currently Live</h2>
<div class="holder">
</div>
<hr class="hrdivider">
</div><!-- .current-talk -->
<h2 class="scheduletitle">The Full Schedule</h2>
<?php
$args = array(
'post_type' => array( 'wptd_talk' ),
'post_status' => array( 'publish' ),
'nopaging' => true,
'posts_per_page' => -1,
'orderby' => 'meta_value_num',
'meta_key' => 'utc_start_time',
'order' => 'ASC',
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) : //phpcs:ignore ?>
<div class="entry-content">
<?php
while ( $query->have_posts() ) :
$query->the_post();
$speakers = get_field( 'speaker' );
$speaker_names = array();
foreach ( $speakers as $speaker ) {
array_push( $speaker_names, get_the_title( $speaker ) );
}
?>
<div class="talk">
<div class="left">
<div class="time"
data-duration="<?php echo esc_attr( str_replace( ' minutes', '', get_field( 'duration' ) ) ); ?>"
data-when="now"
data-time="<?php echo esc_attr( get_field( 'event_date', $frontpage_id ) ) . ' ' . esc_attr( get_field( 'utc_start_time' ) ) . ':00'; ?>">
<?php echo esc_attr( get_field( 'utc_start_time' ) ); ?>
</div>
<div class="lctimeholder">IN YOUR LOCAL TIME</div>
<div class="local-time">
<?php echo esc_attr( get_field( 'utc_start_time' ) ); ?>
</div>
</div>
<div class="right">
<div class="title">
<?php echo '<a href="' . esc_url( site_url( '/the-speakers/', 'https' ) ) . '">' . esc_attr( implode( ', ', $speaker_names ) ) . '</a>'; ?> - <?php the_title(); ?>
</div>
<div class="holder">
<?php
if ( 1 === count( $speakers ) ) {
$image = wp_get_attachment_image( get_field( 'image', $speaker ), 'full' );
if ( $image ) {
echo wp_kses_post( $image );
} else {
echo get_avatar( get_field( 'e_mail', $speaker ), 150 );
}
} else {
?>
<img src="https://wptranslationday.org/wp-content/themes/wptd4/assets/images/panel.jpg" >
<?php
}
?>
<?php echo wp_kses_post( get_field( 'description' ) ); ?>
<?php echo esc_attr( get_field( 'live_or_prerecorded' ) ) . ' | ' . esc_attr( get_field( 'target_language' ) ) . ' | ' . esc_attr( get_field( 'target_audience' ) ); ?>
</div>
</div>
</div>
<?php endwhile; ?>
</div><!-- .entry-content -->
<?php endif; ?>
<?php wp_reset_postdata(); ?>
</article><!-- #post-## -->
<?php endwhile; // End of the loop. ?>
</main><!-- #main -->
</div><!-- #primary -->
</div><!-- .wrap -->
<script>
( function( $ ) {
function fixTalkList() {
$( '.time' ).each( function () {
var talkTimeUTC = $( this ).attr( 'data-time' ),
timeLocal = moment.utc( $( this ).attr( 'data-time' ) ).toDate(),
currTimeUTC = moment().utc().format( 'YYYY-MM-DD HH:mm:ss' ),
durTimeUTC = $( this ).attr( 'data-duration' ),
durTime = moment( talkTimeUTC ).add( durTimeUTC, 'm' ),
endTime = durTime.format( 'YYYY-MM-DD HH:mm:ss' );
$( '.current-talk .holder' ).html('');
if ( currTimeUTC > talkTimeUTC ) {
$( this ).attr( 'data-when', 'past' );
} else {
$( this ).attr( 'data-when', 'future' );
}
if ( currTimeUTC < endTime && currTimeUTC > talkTimeUTC ) {
$( this ).attr( 'data-when', 'now' );
}
timeLocal = moment( timeLocal ).format( 'HH:mm' );
$( this ).siblings( '.local-time' ).html( timeLocal );
} );
$( 'div[data-when="past"]' ).each( function () {
$( this ).parent().parent().css( 'opacity', '.4' );
} );
var currTalk = $( 'div[data-when="now"]' ).parent().parent().clone();
$( '.current-talk .holder' ).html( currTalk );
if ( ! $( '.current-talk .holder .talk' ).length ) {
$( '.current-talk' ).css( 'display', 'none' );
}
}
$( 'document' ).ready( function() {
var theLiveDay = '<?php echo esc_attr( get_field( 'event_date', $frontpage_id ) ); ?>',
currDay = moment().utc().format( 'YYYY-MM-DD' );
if ( theLiveDay != currDay ) {
$('.current-talk').css('display', 'none');
}
fixTalkList();
setInterval( function () {
fixTalkList();
}, 60000 );
})
})( jQuery );
</script>
<?php
get_footer();