-
Notifications
You must be signed in to change notification settings - Fork 0
/
display.php
54 lines (45 loc) · 2.51 KB
/
display.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
<?php
class FAV_Event_Display{
public $event_post_type = 'rns_event';
function __construct(){
add_action('template_redirect', array($this, 'add_filters'));
}
function add_filters(){
global $post;
if(get_post_type() == $this->event_post_type){
//now do the magic sauce
add_filter('the_content', array($this, 'output_meta_display'));
add_filter('rns_event_before_content', array($this, 'before_content_event_data'));
add_filter('rns_event_after_content', array($this, 'after_content_event_data') );
}
}
function output_meta_display($content){
$content = apply_filters('rns_event_before_content', '') . $content . apply_filters('rns_event_after_content', '');
return $content;
}
function before_content_event_data($incoming){
$meta = get_post_custom(get_the_id());
//FORMAT -- Event Date: 1:30 pm May 28, 2014
$stuff = (isset($meta['_rns_event_starts'])) ? sprintf('<h3 class="event-date">%s: %s %s</h3>', __('Event Date', 'rns_events'),date('g:i a', $meta['_rns_event_starts'][0]), date('F j, Y', $meta['_rns_event_starts'][0])) : '<!-- no date given -->';
return $stuff.$incoming;
}
function after_content_event_data($incoming){
//FORMAT:
// Location
// The Giving Store at Glenwood Lutheran Church
// 2545 Monroe St.
// Toledo, OH 43620
// US';=
$meta = get_post_custom(get_the_id());
$stuff = (isset($meta['_rns_event_contact_url'])) ? sprintf('<a href="%s" class="event-link" title="%s">%s</a>', esc_url($meta['_rns_event_contact_url'][0]), __('Visit Event Website', 'rns_events'), __('Visit Event Website', 'rns_events')) : '';
$stuff .= sprintf('<h5>%s</h5>', __('Location', 'rns_event'));
$stuff .= (isset($meta['_rns_event_location'])) ? sprintf('%s<br />', $meta['_rns_event_location'][0]) : '';
$stuff .= (isset($meta['_rns_event_address'])) ? sprintf('%s<br />', $meta['_rns_event_address'][0]) : '';
$stuff .= (isset($meta['_rns_event_city'])) ? sprintf('%s ', $meta['_rns_event_city'][0]) : '';
$stuff .= (isset($meta['_rns_event_state'])) ? sprintf('%s ', $meta['_rns_event_state'][0]) : '';
$stuff .= (isset($meta['_rns_event_zip'])) ? sprintf('%s ', $meta['_rns_event_zip'][0]) : '';
$stuff .= (isset($meta['_rns_event_country'])) ? sprintf('<br />%s ', $meta['_rns_event_country'][0]) : '';
return $incoming.$stuff;
}
}
new FAV_Event_Display;