-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharchive-webinar.php
116 lines (97 loc) · 3.25 KB
/
archive-webinar.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
<?php
/**
* The template for displaying archive pages.
*
* Learn more: http://codex.wordpress.org/Template_Hierarchy
*
* @package BusinessPress
*/
get_header(); ?>
<section id="primary" class="content-area">
<main id="main" class="site-main">
<?php if ( have_posts() ) : ?>
<header class="page-header">
<h1 class="page-title-webinar">ウェビナー一覧</h1>
</header><!-- .page-header -->
<div class="loop-wrapper"><table>
<tr>
<th>📅 開催日時</th>
<th>📝 タイトル</th>
<th>🎟 募集人数</th>
</tr>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : ?>
<?php
the_post();
$fields = get_fields();
/* 空席チェック */
$tickets = get_tickets( get_the_ID() );
$ticket_num = count( $tickets );
$limit = $fields['limit'];
$vacant = $ticket_num < $limit;
/* 締め切りのための計算 */
$now_time = time();
$start_time = strtotime( $fields['time_start'] );
$end_time = strtotime( $fields['time_end'] );
list( $can_reserve, $close_time, $close_msg ) = can_reserve( $now_time, $fields['time_close'], $start_time, $end_time );
/* 募集されていて、開催期間中で、空席があって、予約可能 */
$open = $fields['open'];
$in_time = $now_time < $end_time;
$available = $open && $in_time && $vacant && $can_reserve;
if ( is_user_logged_in() ) {
$current_user_id = ( wp_get_current_user() )->ID;
list( $is_attendee, $ticket_id ) = has_ticket( $current_user_id, $tickets );
} else {
$is_attendee = false;
}
$ticket_status = '';
if ( $can_reserve ) {
if ( $open ) {
if ( $is_attendee ) {
$ticket_status = '✅ 申し込み済';
} else {
if ( $vacant ) {
$ticket_status = '募集中';
} else {
$ticket_status = '🈵 満席';
}
}
} else {
$ticket_status = '⛔️ 閉鎖中';
}
} else {
$ticket_status = '終了しました';
}
$available_class = $in_time ? '' : 'webinar-disable';
?>
<tr class="<?php echo esc_attr( $available_class ); ?>">
<td>
<?php echo esc_html( date_i18n( 'n月 d日(D)', $start_time ) ); ?><br>
<?php echo esc_html( gmdate( 'H:i', $start_time ) . ' - ' . gmdate( 'H:i', $end_time ) ); ?><br>
<small><?php echo esc_html( $close_msg ); ?></small></td>
<td><a href="<?php the_permalink(); ?>"><?php the_title( '<strong>', '</strong>' ); ?></a><br>
</td>
<td>
<?php echo esc_html( $ticket_num ); ?> / <?php echo esc_html( $limit ); ?>人<br>
<?php echo esc_html( $ticket_status ); ?>
</td>
</tr>
<?php endwhile; ?>
</table></div><!-- .loop-wrapper -->
<?php
the_posts_pagination(
array(
'prev_text' => esc_html__( '« Previous', 'businesspress' ),
'next_text' => esc_html__( 'Next »', 'businesspress' ),
)
);
?>
<?php else : ?>
<?php get_template_part( 'template-parts/content', 'none' ); ?>
<?php endif; ?>
</main><!-- #main -->
</section><!-- #primary -->
<?php if ( '3-column' !== get_theme_mod( 'businesspress_content_archive' ) ): ?>
<?php get_sidebar(); ?>
<?php endif; ?>
<?php get_footer(); ?>