This repository has been archived by the owner on Nov 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharchive-yumc_events.php
150 lines (136 loc) · 4.17 KB
/
archive-yumc_events.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
<?php
/*
* archive-yumc_events.php
* -----------------------
* PHP: Template for displaying all events
*/
get_header();
$fb_events = yumc_get_facebook_events(30);
$google_events = yumc_get_google_events(30);
$events_array = array();
foreach($google_events as $event) {
$events_array[] = array(
'id' => 'google-' . $event["id"],
'timestamp' => yumc_parse_google_timestamp($event["start"]["dateTime"]),
'title' => $event["summary"],
'content' => nl2br( $event["description"] ),
'location' => $event["location"],
'url' => rtrim( get_post_type_archive_link( 'yumc_events' ), '/' ) . '#event-google-' . $event["id"],
'origin' => "google",
'image' => "",
);
}
foreach($fb_events as $event) {
$exists = false;
foreach( $events_array as $existing_event ) {
if( $existing_event["title"] == $event["name"] ) {
$exists = true;
break;
}
}
if(!$exists) {
$events_array[] = array(
'id' => 'fb-' . $event["id"],
'timestamp' => yumc_parse_fb_timestamp($event["start_time"]),
'title' => $event["name"],
'content' => nl2br($event["description"]),
'location' => $event["place"]["name"],
'url' => rtrim(get_post_type_archive_link('yumc_events'), '/') . '#event-fb-' . $event["id"],
'origin' => "fb",
'image' => $event["cover"]["source"],
);
}
}
$args = array(
'post_status' => 'publish',
'post_type' => 'yumc_events',
'meta_key' => 'yumc_event_unix_timestamp',
'orderby' => 'meta_value_num',
'order' => 'DESC',
);
$site_events = get_posts( $args );
foreach($site_events as $site_event)
{
if( yumc_parse_event_timestamp( get_post_meta( $site_event->ID, 'yumc_event_unix_timestamp', true ) ) > new DateTime("14-07-2014") ) {
$events_array[] = array(
'id' => $site_event->ID,
'timestamp' => yumc_parse_event_timestamp(get_post_meta($site_event->ID, 'yumc_event_unix_timestamp', true)),
'title' => $site_event->post_title,
'content' => $site_event->post_content,
'location' => "temp",
'url' => rtrim( get_post_type_archive_link( 'yumc_events' ), '/' ) . '#event-' . $site_event->ID,
'origin' => "wp",
);
}
}
if( $events_array ) {
usort($events_array,
function ($a, $b) {
$ad = $a['timestamp'];
$bd = $b['timestamp'];
if ($ad == $bd) {
return 0;
}
return $ad < $bd ? -1 : 1;
}
);
}
?>
<main id="main" class="site-main grid_16 prefix_2 suffix_2" role="main">
<article id="events-page" class="event_listing">
<header class="entry-header grid_11 prefix_1 suffix_1">
<h1 class="entry-title">Upcoming Events<span class="page-title-underline"></span></h1>
</header><!-- .entry-header -->
<div class="clear"></div>
<?php
foreach($events_array as $event) {
?>
<div>
<a href="<?php echo $event["url"] ?>" id="event-<?php echo $event["id"]; ?>" class="event_entry calendar_entry">
<div class="date_stamp">
<span class="day"><?php echo $event["timestamp"]->format('d'); ?></span>
<span class="month"><?php echo $event["timestamp"]->format('M'); ?></span>
</div>
<div class="content">
<h2><?php echo $event["title"]; ?></h2>
<p>
<?php
echo $event["timestamp"]->format('g');
if ($event["timestamp"]->format('i') != "00")
echo ':' . $event["timestamp"]->format('i');
echo $event["timestamp"]->format('a') . '.';
?>
Click to show more info.
</p>
<div class="event_drop_down_icon">+</div>
</div>
</a>
<div class="event_content event_dropdown">
<?php
if ($event["origin"] == "fb")
{
if($event["image"])
{
?>
<div class="event_image" style="width: 842px; height: 421px; overflow: hidden;">
<img src="<?php echo $event["image"]; ?>" style="width: 100%;" />
</div>
<?php
}
}
else if ( has_post_thumbnail( $event["id"] ) ) {
echo get_the_post_thumbnail( $event["id"], '842-421-thumb', array( 'class' => 'event_image' ));
}
?>
<?php echo $event["content"] ?>
<div class="clear"></div>
</div>
<div class="clear"></div>
</div>
<?php
}
?>
</article>
</main><!-- #main -->
<?php
get_footer();