-
Notifications
You must be signed in to change notification settings - Fork 0
/
tlpd-events.php
executable file
·220 lines (216 loc) · 8 KB
/
tlpd-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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
<?php
/**
* Overrides parent theme function `em_events.php` in order to re-arrange the display
* of event elements
*
* Modified from original events manager plugin version: 5.6.6.1
* @author Brad Payne
* @package tlpd
* @since 0.9
* @license https://www.gnu.org/licenses/gpl.html GPLv3 or later
*
* Original:
* @author Marcus Sykes
* @copyright Copyright Marcus Sykes
*/
/**
*
* @param $page_content
*
* @return mixed|void
*/
add_filter(
'the_content', function ( $page_content ) {
global $post, $wpdb, $wp_query, $EM_Event, $EM_Location, $EM_Category;
if ( empty( $post ) ) {
return $page_content;
} //fix for any other plugins calling the_content outside the loop
$events_page_id = get_option( 'dbem_events_page' );
$locations_page_id = get_option( 'dbem_locations_page' );
$categories_page_id = get_option( 'dbem_categories_page' );
$tags_page_id = get_option( 'dbem_tags_page' );
$edit_events_page_id = get_option( 'dbem_edit_events_page' );
$edit_locations_page_id = get_option( 'dbem_edit_locations_page' );
$edit_bookings_page_id = get_option( 'dbem_edit_bookings_page' );
$my_bookings_page_id = get_option( 'dbem_my_bookings_page' );
//general defaults
$args = [
'owner' => false,
'pagination' => 1,
];
$args['ajax'] = isset( $args['ajax'] ) ? $args['ajax'] : ( ! defined( 'EM_AJAX' ) || EM_AJAX );
if ( ! post_password_required() && in_array( //@codingStandardsIgnoreLine
$post->ID, [
$events_page_id,
$locations_page_id,
$categories_page_id,
$edit_bookings_page_id,
$edit_events_page_id,
$edit_locations_page_id,
$my_bookings_page_id,
$tags_page_id,
]
)
) {
$content = apply_filters( 'em_content_pre', '', $page_content );
if ( empty( $content ) ) {
ob_start();
if ( $post->ID == $events_page_id && $events_page_id != 0 ) {
if ( ! empty( $_REQUEST['calendar_day'] ) ) { //@codingStandardsIgnoreLine
//Events for a specific day
$args = EM_Events::get_post_search( array_merge( $args, $_REQUEST ) ); //@codingStandardsIgnoreLine
em_locate_template(
'templates/calendar-day.php', true, [
'args' => $args,
]
);
} elseif ( is_object( $EM_Event ) ) {
em_locate_template(
'templates/event-single.php', true, [
'args' => $args,
]
);
} else {
// Multiple events page
$args['orderby'] = get_option( 'dbem_events_default_orderby' );
$args['order'] = get_option( 'dbem_events_default_order' );
if ( get_option( 'dbem_display_calendar_in_events_page' ) ) {
$args['long_events'] = 1;
em_locate_template(
'templates/events-calendar.php', true, [
'args' => $args,
]
);
} else {
//Intercept search request, if defined
if ( ! empty( $_REQUEST['action'] ) && ( $_REQUEST['action'] == 'search_events' || $_REQUEST['action'] == 'search_events_grouped' ) ) { //@codingStandardsIgnoreLine
$args = EM_Events::get_post_search( array_merge( $args, $_REQUEST ) ); //@codingStandardsIgnoreLine
}
if ( empty( $args['scope'] ) ) {
$args['scope'] = get_option( 'dbem_events_page_scope' );
}
$args['limit'] = ! empty( $args['limit'] ) ? $args['limit'] : get_option( 'dbem_events_default_limit' );
if ( ! empty( $args['ajax'] ) ) {
echo '<div class="em-search-ajax">';
} //AJAX wrapper open
if ( get_option( 'dbem_event_list_groupby' ) ) {
em_locate_template(
'templates/events-list-grouped.php', true, [
'args' => $args,
]
);
} else {
em_locate_template(
'templates/events-list.php', true, [
'args' => $args,
]
);
}
if ( get_option( 'dbem_events_page_search_form' ) ) {
//load the search form and pass on custom arguments (from settings page)
$search_args = em_get_search_form_defaults();
echo "<div class='c-search'>";
em_locate_template(
'templates/events-search.php', true, [
'args' => $search_args,
]
);
echo '</div>';
}
if ( ! empty( $args['ajax'] ) ) {
echo '</div>';
} //AJAX wrapper close
}
}
} elseif ( $post->ID == $locations_page_id && $locations_page_id != 0 ) {
$args['orderby'] = get_option( 'dbem_locations_default_orderby' );
$args['order'] = get_option( 'dbem_locations_default_order' );
$args['limit'] = ! empty( $args['limit'] ) ? $args['limit'] : get_option( 'dbem_locations_default_limit' );
if ( EM_MS_GLOBAL && is_object( $EM_Location ) ) {
em_locate_template(
'templates/location-single.php', true, [
'args' => $args,
]
);
} else {
//Intercept search request, if defined
if ( ! empty( $_REQUEST['action'] ) && $_REQUEST['action'] == 'search_locations' ) { //@codingStandardsIgnoreLine
$args = EM_Locations::get_post_search( array_merge( $args, $_REQUEST ) ); //@codingStandardsIgnoreLine
}
if ( get_option( 'dbem_locations_page_search_form' ) ) {
//load the search form and pass on custom arguments (from settings page)
$search_args = em_get_search_form_defaults();
//remove date and category
$search_args['search_categories'] = false;
$search_args['search_scope'] = false;
em_locate_template(
'templates/locations-search.php', true, [
'args' => $search_args,
]
);
}
if ( ! empty( $args['ajax'] ) ) {
echo '<div class="em-search-ajax">';
} //AJAX wrapper open
em_locate_template(
'templates/locations-list.php', true, [
'args' => $args,
]
);
if ( ! empty( $args['ajax'] ) ) {
echo '</div>';
} //AJAX wrapper close
}
} elseif ( $post->ID == $categories_page_id && $categories_page_id != 0 ) {
$args['limit'] = ! empty( $args['limit'] ) ? $args['limit'] : get_option( 'dbem_categories_default_limit' );
if ( ! empty( $args['ajax'] ) ) {
echo '<div class="em-search-ajax">';
} //AJAX wrapper open
em_locate_template(
'templates/categories-list.php', true, [
'args' => $args,
]
);
if ( ! empty( $args['ajax'] ) ) {
echo '</div>';
} //AJAX wrapper close
} elseif ( $post->ID == $tags_page_id && $tags_page_id != 0 ) {
$args['limit'] = ! empty( $args['limit'] ) ? $args['limit'] : get_option( 'dbem_tags_default_limit' );
if ( ! empty( $args['ajax'] ) ) {
echo '<div class="em-search-ajax">';
} //AJAX wrapper open
em_locate_template(
'templates/tags-list.php', true, [
'args' => $args,
]
);
if ( ! empty( $args['ajax'] ) ) {
echo '</div>';
} //AJAX wrapper close
} elseif ( $post->ID == $edit_events_page_id && $edit_events_page_id != 0 ) {
em_events_admin();
} elseif ( $post->ID == $edit_locations_page_id && $edit_locations_page_id != 0 ) {
em_locations_admin();
} elseif ( $post->ID == $my_bookings_page_id && $my_bookings_page_id != 0 ) {
em_my_bookings();
} elseif ( $post->ID == $edit_bookings_page_id && $edit_bookings_page_id != 0 ) {
em_bookings_admin();
}
$content = ob_get_clean();
//If disable rewrite flag is on, then we need to add a placeholder here
if ( get_option( 'dbem_disable_title_rewrites' ) == 1 ) {
$content = str_replace( '#_PAGETITLE', em_content_page_title( '' ), get_option( 'dbem_title_html' ) ) . $content;
}
//Now, we either replace CONTENTS or just replace the whole page
if ( preg_match( '/CONTENTS/', $page_content ) ) {
$content = str_replace( 'CONTENTS', $content, $page_content );
}
if ( get_option( 'dbem_credits' ) ) {
$content .= '<p style="color:#999; font-size:11px;">Powered by <a href="http://wp-events-plugin.com" style="color:#999;" target="_blank">Events Manager</a></p>';
}
}
return apply_filters( 'em_content', '<div id="em-wrapper">' . $content . '</div>' );
}
return $page_content;
}
);