blob: a6780f6560ea264a9f2b78b0061bcd0301293a38 (
plain)
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
|
<?php
/* DISPLAY - front page widget
*
*/
function communievents_event_list($attr) {
global $wpdb;
global $wp_locale;
$out = '';
$table_name = $wpdb->prefix . 'communievents_events';
$limit = 10;
$tz = new DateTimeZone(CommuniApi::TIMEZONE);
$now_dt = new DateTime('now', $tz);
$list = $wpdb->get_results($wpdb->prepare("SELECT * FROM $table_name WHERE %s < end AND official=1 ORDER BY start LIMIT %d",
$now_dt->format('Y-m-d H:i:s'), $limit));
if ($list) {
$out .= '<table class="communievents-event-list">';
foreach ($list as $event) {
$start_dt = new DateTime($event->start, $tz);
$out .= '<tr class="communievents-event-future">';
$out .= '<td class="communievents-weekday">' . $wp_locale->get_weekday_abbrev($wp_locale->get_weekday($start_dt->format('w'))) . ', ';
$out .= '<td class="communievents-date">' . $start_dt->format('j.') . $wp_locale->get_month_abbrev($wp_locale->get_month($start_dt->format('m')));
$out .= '<td class="communievents-time">' . ($event->allday ? '' : $start_dt->format( 'G:i' ));
$out .= '<td class="communievents-link">';
$out .= '<a href="' . esc_url($event->url) . '">';
$out .= $event->title;
$out .= '</a>';
}
$out .= '</table>';
}
return $out;
}
function communievents_setup_event_list() {
add_shortcode('communievents-event-list', 'communievents_event_list');
}
|