1
|
|
|
<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2
|
|
|
/** |
3
|
|
|
* Event Espresso |
4
|
|
|
* |
5
|
|
|
* Event Registration and Management Plugin for WordPress |
6
|
|
|
* |
7
|
|
|
* @ package Event Espresso |
8
|
|
|
* @ author Seth Shoultes |
9
|
|
|
* @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
10
|
|
|
* @ license http://eventespresso.com/support/terms-conditions/ * see Plugin Licensing * |
11
|
|
|
* @ link http://www.eventespresso.com |
12
|
|
|
* @ version 4.0 |
13
|
|
|
* |
14
|
|
|
* ------------------------------------------------------------------------ |
15
|
|
|
* |
16
|
|
|
* Event List |
17
|
|
|
* |
18
|
|
|
* @package Event Espresso |
19
|
|
|
* @subpackage /modules/events_archive/ |
20
|
|
|
* @author Brent Christensen |
21
|
|
|
* |
22
|
|
|
* ------------------------------------------------------------------------ |
23
|
|
|
*/ |
24
|
|
|
class EED_Events_Archive extends EED_Module { |
25
|
|
|
|
26
|
|
|
|
27
|
|
|
public static $espresso_event_list_ID = 0; |
28
|
|
|
public static $espresso_grid_event_lists = array(); |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @type EE_Template_Part_Manager $template_parts |
32
|
|
|
*/ |
33
|
|
|
protected $template_parts; |
34
|
|
|
|
35
|
|
|
|
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @return EED_Events_Archive |
39
|
|
|
*/ |
40
|
|
|
public static function instance() { |
41
|
|
|
return parent::get_instance( __CLASS__ ); |
|
|
|
|
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
|
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* set_hooks - for hooking into EE Core, other modules, etc |
48
|
|
|
* |
49
|
|
|
* @access public |
50
|
|
|
* @return void |
51
|
|
|
*/ |
52
|
|
|
public static function set_hooks() { |
53
|
|
|
EE_Config::register_route( EE_Registry::instance()->CFG->core->event_cpt_slug, 'Events_Archive', 'run' ); |
54
|
|
|
EE_Config::register_route( 'event_list', 'Events_Archive', 'event_list' ); |
55
|
|
|
add_action( 'wp_loaded', array( 'EED_Events_Archive', 'set_definitions' ), 2 ); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
60
|
|
|
* |
61
|
|
|
* @access public |
62
|
|
|
* @return void |
63
|
|
|
*/ |
64
|
|
|
public static function set_hooks_admin() { |
65
|
|
|
add_action( 'wp_loaded', array( 'EED_Events_Archive', 'set_definitions' ), 2 ); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
|
69
|
|
|
|
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* set_definitions |
73
|
|
|
* |
74
|
|
|
* @access public |
75
|
|
|
* @return void |
76
|
|
|
*/ |
77
|
|
|
public static function set_definitions() { |
78
|
|
|
define( 'EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS ); |
79
|
|
|
define( 'EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS ); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
|
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* set_config |
86
|
|
|
* |
87
|
|
|
* @return \EE_Events_Archive_Config |
88
|
|
|
*/ |
89
|
|
|
protected function set_config(){ |
90
|
|
|
$this->set_config_section( 'template_settings' ); |
91
|
|
|
$this->set_config_class( 'EE_Events_Archive_Config' ); |
92
|
|
|
$this->set_config_name( 'EED_Events_Archive' ); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
|
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* initialize_template_parts |
99
|
|
|
* |
100
|
|
|
* @access public |
101
|
|
|
* @param \EE_Events_Archive_Config $config |
102
|
|
|
* @return \EE_Template_Part_Manager |
103
|
|
|
*/ |
104
|
|
View Code Duplication |
public function initialize_template_parts( EE_Events_Archive_Config $config = null ) { |
|
|
|
|
105
|
|
|
$config = $config instanceof EE_Events_Archive_Config ? $config : $this->config(); |
106
|
|
|
EEH_Autoloader::instance()->register_template_part_autoloaders(); |
107
|
|
|
$template_parts = new EE_Template_Part_Manager(); |
108
|
|
|
$template_parts->add_template_part( |
109
|
|
|
'tickets', |
110
|
|
|
__( 'Ticket Selector', 'event_espresso' ), |
111
|
|
|
'content-espresso_events-tickets.php', |
112
|
|
|
$config->display_order_tickets |
|
|
|
|
113
|
|
|
); |
114
|
|
|
$template_parts->add_template_part( |
115
|
|
|
'datetimes', |
116
|
|
|
__( 'Dates and Times', 'event_espresso' ), |
117
|
|
|
'content-espresso_events-datetimes.php', |
118
|
|
|
$config->display_order_datetimes |
|
|
|
|
119
|
|
|
); |
120
|
|
|
$template_parts->add_template_part( |
121
|
|
|
'event', |
122
|
|
|
__( 'Event Description', 'event_espresso' ), |
123
|
|
|
'content-espresso_events-details.php', |
124
|
|
|
$config->display_order_event |
|
|
|
|
125
|
|
|
); |
126
|
|
|
$template_parts->add_template_part( |
127
|
|
|
'venue', |
128
|
|
|
__( 'Venue Information', 'event_espresso' ), |
129
|
|
|
'content-espresso_events-venues.php', |
130
|
|
|
$config->display_order_venue |
|
|
|
|
131
|
|
|
); |
132
|
|
|
do_action( 'AHEE__EED_Event_Archive__initialize_template_parts', $template_parts ); |
133
|
|
|
return $template_parts; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
|
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* run - initial module setup - this gets called by the EE_Front_Controller if the module route is found in the incoming request |
140
|
|
|
* |
141
|
|
|
* @access public |
142
|
|
|
* @param WP $WP |
143
|
|
|
* @return void |
144
|
|
|
*/ |
145
|
|
|
public function run( $WP ) { |
146
|
|
|
do_action( 'AHEE__EED_Events_Archive__before_run' ); |
147
|
|
|
// ensure valid EE_Events_Archive_Config() object exists |
148
|
|
|
$this->set_config(); |
149
|
|
|
/** @type EE_Events_Archive_Config $config */ |
150
|
|
|
$config = $this->config(); |
151
|
|
|
// load other required components |
152
|
|
|
$this->load_event_list_assets(); |
153
|
|
|
// filter the WP posts_join, posts_where, and posts_orderby SQL clauses |
154
|
|
|
EE_Registry::instance()->load_helper( 'Event_Query' ); |
155
|
|
|
//add query filters |
156
|
|
|
EEH_Event_Query::add_query_filters(); |
157
|
|
|
// set params that will get used by the filters |
158
|
|
|
EEH_Event_Query::set_query_params( |
159
|
|
|
'', // month |
160
|
|
|
'', // category |
161
|
|
|
$config->display_expired_events, // show_expired |
|
|
|
|
162
|
|
|
'start_date', // orderby |
163
|
|
|
'ASC' // sort |
164
|
|
|
); |
165
|
|
|
// check what template is loaded |
166
|
|
|
add_filter( 'template_include', array( $this, 'template_include' ), 999, 1 ); |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
|
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* event_list - most likely called by the EES_Espresso_Events shortcode which uses this module to do some of it's lifting |
173
|
|
|
* |
174
|
|
|
* @access public |
175
|
|
|
* @return void |
176
|
|
|
*/ |
177
|
|
|
public function event_list() { |
178
|
|
|
// ensure valid EE_Events_Archive_Config() object exists |
179
|
|
|
$this->set_config(); |
180
|
|
|
// load other required components |
181
|
|
|
$this->load_event_list_assets(); |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
|
185
|
|
|
|
186
|
|
|
|
187
|
|
|
|
188
|
|
|
|
189
|
|
|
|
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* template_include |
193
|
|
|
* |
194
|
|
|
* @access public |
195
|
|
|
* @param string $template |
196
|
|
|
* @return string |
197
|
|
|
*/ |
198
|
|
|
public function template_include( $template = '' ) { |
199
|
|
|
// don't add content filter for dedicated EE child themes or private posts |
200
|
|
|
EE_Registry::instance()->load_helper( 'Template' ); |
201
|
|
|
if ( ! EEH_Template::is_espresso_theme() ) { |
202
|
|
|
/** @type EE_Events_Archive_Config $config */ |
203
|
|
|
$config = $this->config(); |
204
|
|
|
// add status banner ? |
205
|
|
|
if ( $config->display_status_banner ) { |
206
|
|
|
add_filter( 'the_title', array( 'EED_Events_Archive', 'the_title' ), 100, 2 ); |
207
|
|
|
} |
208
|
|
|
// if NOT a custom template |
209
|
|
|
if ( EE_Front_Controller::instance()->get_selected_template() != 'archive-espresso_events.php' ) { |
210
|
|
|
// don't display entry meta because the existing theme will take care of that |
211
|
|
|
add_filter( 'FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true' ); |
212
|
|
|
// load functions.php file for the theme (loaded by WP if using child theme) |
213
|
|
|
EEH_Template::load_espresso_theme_functions(); |
214
|
|
|
// because we don't know if the theme is using the_excerpt() |
215
|
|
|
add_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 100, 1 ); |
216
|
|
|
// or the_content |
217
|
|
|
add_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 100, 1 ); |
218
|
|
|
// and just in case they are running get_the_excerpt() which DESTROYS things |
219
|
|
|
add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 ); |
220
|
|
|
// don't display entry meta because the existing theme will take care of that |
221
|
|
|
add_filter( 'FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false' ); |
222
|
|
|
} |
223
|
|
|
} |
224
|
|
|
return $template; |
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
|
228
|
|
|
|
229
|
|
|
/** |
230
|
|
|
* get_the_excerpt - kinda hacky, but if a theme is using get_the_excerpt(), then we need to remove our filters on the_content() |
231
|
|
|
* |
232
|
|
|
* @access public |
233
|
|
|
* @param string $excerpt |
234
|
|
|
* @return string |
235
|
|
|
*/ |
236
|
|
|
public static function get_the_excerpt( $excerpt = '' ) { |
237
|
|
|
if ( post_password_required() ) { |
238
|
|
|
return $excerpt; |
239
|
|
|
} |
240
|
|
|
if ( apply_filters( 'FHEE__EED_Events_Archive__get_the_excerpt__theme_uses_get_the_excerpt', false ) ) { |
241
|
|
|
remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 100 ); |
242
|
|
|
remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 100 ); |
243
|
|
|
$excerpt = EED_Events_Archive::event_details( $excerpt ); |
244
|
|
|
} |
245
|
|
|
return $excerpt; |
246
|
|
|
} |
247
|
|
|
|
248
|
|
|
|
249
|
|
|
|
250
|
|
|
/** |
251
|
|
|
* the_title |
252
|
|
|
* |
253
|
|
|
* @access public |
254
|
|
|
* @param string $title |
255
|
|
|
* @param string $id |
256
|
|
|
* @return string |
257
|
|
|
*/ |
258
|
|
|
public static function the_title( $title = '', $id = '' ) { |
259
|
|
|
global $post; |
260
|
|
|
if ( $post instanceof WP_Post ) { |
|
|
|
|
261
|
|
|
return in_the_loop() && $post->ID == $id ? espresso_event_status_banner( $post->ID ) . $title : $title; |
262
|
|
|
} |
263
|
|
|
return $title; |
264
|
|
|
} |
265
|
|
|
|
266
|
|
|
|
267
|
|
|
|
268
|
|
|
/** |
269
|
|
|
* event_details |
270
|
|
|
* |
271
|
|
|
* @access public |
272
|
|
|
* @param string $content |
273
|
|
|
* @return string |
274
|
|
|
*/ |
275
|
|
|
public static function event_details( $content ) { |
276
|
|
|
global $post; |
277
|
|
|
static $current_post_ID = 0; |
278
|
|
|
if ( |
279
|
|
|
$current_post_ID != $post->ID && |
280
|
|
|
$post->post_type == 'espresso_events' && |
281
|
|
|
! post_password_required() && |
282
|
|
|
( |
283
|
|
|
apply_filters( 'FHEE__EES_Espresso_Events__process_shortcode__true', false ) |
284
|
|
|
|| ! apply_filters( 'FHEE__content_espresso_events__template_loaded', false ) |
285
|
|
|
) |
286
|
|
|
) { |
287
|
|
|
// Set current post ID to prevent showing content twice, but only if headers have definitely been sent. |
288
|
|
|
// Reason being is that some plugins, like Yoast, need to run through a copy of the loop early |
289
|
|
|
// BEFORE headers are sent in order to examine the post content and generate content for the HTML header. |
290
|
|
|
// We want to allow those plugins to still do their thing and have access to our content, but depending on |
291
|
|
|
// how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice, |
292
|
|
|
// so the following allows this filter to be applied multiple times, but only once for real |
293
|
|
|
$current_post_ID = did_action( 'loop_start' ) ? $post->ID : 0; |
294
|
|
|
if ( EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->use_sortable_display_order ) { |
295
|
|
|
$content = \EED_Events_Archive::use_sortable_display_order(); |
296
|
|
|
} else { |
297
|
|
|
$content = \EED_Events_Archive::use_filterable_display_order(); |
298
|
|
|
} |
299
|
|
|
} |
300
|
|
|
return $content; |
301
|
|
|
} |
302
|
|
|
|
303
|
|
|
|
304
|
|
|
|
305
|
|
|
/** |
306
|
|
|
* use_sortable_display_order |
307
|
|
|
* |
308
|
|
|
* @access protected |
309
|
|
|
* @return string |
310
|
|
|
*/ |
311
|
|
|
protected static function use_sortable_display_order() { |
312
|
|
|
// no further password checks required atm |
313
|
|
|
add_filter( 'FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true' ); |
314
|
|
|
// we need to first remove this callback from being applied to the_content() or the_excerpt() (otherwise it will recurse and blow up the interweb) |
315
|
|
|
remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 100 ); |
316
|
|
|
remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 100 ); |
317
|
|
|
remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 ); |
318
|
|
|
// now add additional content depending on whether event is using the_excerpt() or the_content() |
319
|
|
|
EED_Events_Archive::instance()->template_parts = EED_Events_Archive::instance()->initialize_template_parts(); |
320
|
|
|
$content = EEH_Template::locate_template( 'content-espresso_events-details.php' ); |
321
|
|
|
$content = EED_Events_Archive::instance()->template_parts->apply_template_part_filters( $content ); |
322
|
|
|
// re-add our main filters (or else the next event won't have them) |
323
|
|
|
add_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 100, 1 ); |
324
|
|
|
add_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 100, 1 ); |
325
|
|
|
add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 ); |
326
|
|
|
remove_filter( 'FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true' ); |
327
|
|
|
return $content; |
328
|
|
|
} |
329
|
|
|
|
330
|
|
|
|
331
|
|
|
|
332
|
|
|
/** |
333
|
|
|
* use_filterable_display_order |
334
|
|
|
* |
335
|
|
|
* @access protected |
336
|
|
|
* @return string |
337
|
|
|
*/ |
338
|
|
|
protected static function use_filterable_display_order() { |
339
|
|
|
// we need to first remove this callback from being applied to the_content() |
340
|
|
|
// (otherwise it will recurse and blow up the interweb) |
341
|
|
|
remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 100 ); |
342
|
|
|
remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 100 ); |
343
|
|
|
remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 ); |
344
|
|
|
//now add additional content depending on whether event is using the_excerpt() or the_content() |
345
|
|
|
EED_Events_Archive::_add_additional_excerpt_filters(); |
346
|
|
|
EED_Events_Archive::_add_additional_content_filters(); |
347
|
|
|
do_action( 'AHEE__EED_Events_Archive__use_filterable_display_order__after_add_filters' ); |
348
|
|
|
// now load our template |
349
|
|
|
$content = EEH_Template::locate_template( 'content-espresso_events-details.php' ); |
350
|
|
|
// re-add our main filters (or else the next event won't have them) |
351
|
|
|
add_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 100, 1 ); |
352
|
|
|
add_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 100, 1 ); |
353
|
|
|
add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 ); |
354
|
|
|
// but remove the other filters so that they don't get applied to the next post |
355
|
|
|
EED_Events_Archive::_remove_additional_events_archive_filters(); |
356
|
|
|
do_action( 'AHEE__EED_Events_Archive__use_filterable_display_order__after_remove_filters' ); |
357
|
|
|
// we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
358
|
|
|
//return ! empty( $template ) ? $template : $content; |
359
|
|
|
return $content; |
360
|
|
|
} |
361
|
|
|
|
362
|
|
|
|
363
|
|
|
|
364
|
|
|
/** |
365
|
|
|
* event_datetimes - adds datetimes ABOVE content |
366
|
|
|
* |
367
|
|
|
* @access public |
368
|
|
|
* @param string $content |
369
|
|
|
* @return string |
370
|
|
|
*/ |
371
|
|
|
public static function event_datetimes( $content ) { |
372
|
|
|
if ( post_password_required() ) { |
373
|
|
|
return $content; |
374
|
|
|
} |
375
|
|
|
return EEH_Template::locate_template( 'content-espresso_events-datetimes.php' ) . $content; |
376
|
|
|
} |
377
|
|
|
|
378
|
|
|
/** |
379
|
|
|
* event_tickets - adds tickets ABOVE content (which includes datetimes) |
380
|
|
|
* |
381
|
|
|
* @access public |
382
|
|
|
* @param string $content |
383
|
|
|
* @return string |
384
|
|
|
*/ |
385
|
|
|
public static function event_tickets( $content ) { |
386
|
|
|
if ( post_password_required() ) { |
387
|
|
|
return $content; |
388
|
|
|
} |
389
|
|
|
return EEH_Template::locate_template( 'content-espresso_events-tickets.php' ) . $content; |
390
|
|
|
} |
391
|
|
|
|
392
|
|
|
|
393
|
|
|
|
394
|
|
|
/** |
395
|
|
|
* event_venues - adds venues BELOW content |
396
|
|
|
* |
397
|
|
|
* @access public |
398
|
|
|
* @param string $content |
399
|
|
|
* @return string |
400
|
|
|
*/ |
401
|
|
|
public static function event_venue( $content ) { |
402
|
|
|
return EED_Events_Archive::event_venues( $content ); |
403
|
|
|
} |
404
|
|
|
|
405
|
|
|
/** |
406
|
|
|
* event_venues - adds venues BELOW content |
407
|
|
|
* |
408
|
|
|
* @access public |
409
|
|
|
* @param string $content |
410
|
|
|
* @return string |
411
|
|
|
*/ |
412
|
|
|
public static function event_venues( $content ) { |
413
|
|
|
if ( post_password_required() ) { |
414
|
|
|
return $content; |
415
|
|
|
} |
416
|
|
|
return $content . EEH_Template::locate_template( 'content-espresso_events-venues.php' ); |
417
|
|
|
} |
418
|
|
|
|
419
|
|
|
|
420
|
|
|
|
421
|
|
|
/** |
422
|
|
|
* _add_additional_content_filters |
423
|
|
|
* |
424
|
|
|
* @access private |
425
|
|
|
* @return void |
426
|
|
|
*/ |
427
|
|
|
private static function _add_additional_excerpt_filters() { |
428
|
|
|
add_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_datetimes' ), 110, 1 ); |
429
|
|
|
add_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_tickets' ), 120, 1 ); |
430
|
|
|
add_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_venues' ), 130, 1 ); |
431
|
|
|
} |
432
|
|
|
|
433
|
|
|
|
434
|
|
|
|
435
|
|
|
/** |
436
|
|
|
* _add_additional_content_filters |
437
|
|
|
* |
438
|
|
|
* @access private |
439
|
|
|
* @return void |
440
|
|
|
*/ |
441
|
|
|
private static function _add_additional_content_filters() { |
442
|
|
|
add_filter( 'the_content', array( 'EED_Events_Archive', 'event_datetimes' ), 110, 1 ); |
443
|
|
|
add_filter( 'the_content', array( 'EED_Events_Archive', 'event_tickets' ), 120, 1 ); |
444
|
|
|
add_filter( 'the_content', array( 'EED_Events_Archive', 'event_venues' ), 130, 1 ); |
445
|
|
|
} |
446
|
|
|
|
447
|
|
|
|
448
|
|
|
|
449
|
|
|
/** |
450
|
|
|
* _remove_additional_events_archive_filters |
451
|
|
|
* |
452
|
|
|
* @access private |
453
|
|
|
* @return void |
454
|
|
|
*/ |
455
|
|
|
private static function _remove_additional_events_archive_filters() { |
456
|
|
|
remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_datetimes' ), 110 ); |
457
|
|
|
remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_tickets' ), 120 ); |
458
|
|
|
remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_venues' ), 130 ); |
459
|
|
|
remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_datetimes' ), 110 ); |
460
|
|
|
remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_tickets' ), 120 ); |
461
|
|
|
remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_venues' ), 130 ); |
462
|
|
|
} |
463
|
|
|
|
464
|
|
|
|
465
|
|
|
|
466
|
|
|
/** |
467
|
|
|
* remove_all_events_archive_filters |
468
|
|
|
* |
469
|
|
|
* @access public |
470
|
|
|
* @return void |
471
|
|
|
*/ |
472
|
|
|
public static function remove_all_events_archive_filters() { |
473
|
|
|
//remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 ); |
474
|
|
|
remove_filter( 'the_title', array( 'EED_Events_Archive', 'the_title' ), 100 ); |
475
|
|
|
remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 100 ); |
476
|
|
|
remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_datetimes' ), 110 ); |
477
|
|
|
remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_tickets' ), 120 ); |
478
|
|
|
remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_venues' ), 130 ); |
479
|
|
|
remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 100 ); |
480
|
|
|
remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_datetimes' ), 110 ); |
481
|
|
|
remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_tickets' ), 120 ); |
482
|
|
|
remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_venues' ), 130 ); |
483
|
|
|
// don't display entry meta because the existing theme will take care of that |
484
|
|
|
remove_filter( 'FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false' ); |
485
|
|
|
} |
486
|
|
|
|
487
|
|
|
|
488
|
|
|
|
489
|
|
|
|
490
|
|
|
|
491
|
|
|
|
492
|
|
|
/** |
493
|
|
|
* load_event_list_assets |
494
|
|
|
* |
495
|
|
|
* @access public |
496
|
|
|
* @return void |
497
|
|
|
*/ |
498
|
|
View Code Duplication |
public function load_event_list_assets() { |
|
|
|
|
499
|
|
|
do_action( 'AHEE__EED_Events_Archive__before_load_assets' ); |
500
|
|
|
add_filter( 'FHEE_load_EE_Session', '__return_true' ); |
501
|
|
|
add_filter( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true' ); |
502
|
|
|
add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 10 ); |
503
|
|
|
if ( EE_Registry::instance()->CFG->map_settings->use_google_maps ) { |
504
|
|
|
EE_Registry::instance()->load_helper( 'Maps' ); |
505
|
|
|
add_action('wp_enqueue_scripts', array( 'EEH_Maps', 'espresso_google_map_js' ), 11 ); |
506
|
|
|
} |
507
|
|
|
EE_Registry::instance()->load_helper( 'Event_View' ); |
508
|
|
|
} |
509
|
|
|
|
510
|
|
|
|
511
|
|
|
|
512
|
|
|
|
513
|
|
|
|
514
|
|
|
|
515
|
|
|
/** |
516
|
|
|
* wp_enqueue_scripts |
517
|
|
|
* |
518
|
|
|
* @access public |
519
|
|
|
* @return void |
520
|
|
|
*/ |
521
|
|
|
public function wp_enqueue_scripts() { |
522
|
|
|
// get some style |
523
|
|
|
if ( apply_filters( 'FHEE_enable_default_espresso_css', FALSE ) ) { |
524
|
|
|
// first check uploads folder |
525
|
|
|
EE_Registry::instance()->load_helper( 'File' ); |
526
|
|
|
if ( EEH_File::is_readable( get_stylesheet_directory() . $this->theme . DS . 'style.css' )) { |
527
|
|
|
wp_register_style( $this->theme, get_stylesheet_directory_uri() . $this->theme . DS . 'style.css', array( 'dashicons', 'espresso_default' )); |
528
|
|
|
} else { |
|
|
|
|
529
|
|
|
} |
530
|
|
|
wp_enqueue_style( $this->theme ); |
531
|
|
|
|
532
|
|
|
} |
533
|
|
|
} |
534
|
|
|
|
535
|
|
|
|
536
|
|
|
|
537
|
|
|
|
538
|
|
|
|
539
|
|
|
/** |
540
|
|
|
* template_settings_form |
541
|
|
|
* |
542
|
|
|
* @access public |
543
|
|
|
* @static |
544
|
|
|
* @return string |
545
|
|
|
*/ |
546
|
|
|
public static function template_settings_form() { |
547
|
|
|
$template_settings = EE_Registry::instance()->CFG->template_settings; |
548
|
|
|
$template_settings->EED_Events_Archive = isset( $template_settings->EED_Events_Archive ) ? $template_settings->EED_Events_Archive : new EE_Events_Archive_Config(); |
549
|
|
|
$template_settings->EED_Events_Archive = apply_filters( 'FHEE__EED_Events_Archive__template_settings_form__event_list_config', $template_settings->EED_Events_Archive ); |
550
|
|
|
$events_archive_settings = array( |
551
|
|
|
'display_status_banner' => 0, |
552
|
|
|
'display_description' => 1, |
553
|
|
|
'display_ticket_selector' => 0, |
554
|
|
|
'display_datetimes' => 1, |
555
|
|
|
'display_venue' => 0, |
556
|
|
|
'display_expired_events' => 0 |
557
|
|
|
); |
558
|
|
|
$events_archive_settings = array_merge( $events_archive_settings, (array)$template_settings->EED_Events_Archive ); |
559
|
|
|
EEH_Template::display_template( EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php', $events_archive_settings ); |
560
|
|
|
} |
561
|
|
|
|
562
|
|
|
|
563
|
|
|
|
564
|
|
|
|
565
|
|
|
|
566
|
|
|
|
567
|
|
|
/** |
568
|
|
|
* update_template_settings |
569
|
|
|
* |
570
|
|
|
* @access public |
571
|
|
|
* @param EE_Template_Config $CFG |
572
|
|
|
* @param EE_Request_Handler $REQ |
573
|
|
|
* @return EE_Template_Config |
574
|
|
|
*/ |
575
|
|
|
public static function update_template_settings( $CFG, $REQ ) { |
576
|
|
|
$CFG->EED_Events_Archive = new EE_Events_Archive_Config(); |
577
|
|
|
// unless we are resetting the config... |
578
|
|
|
if ( ! isset( $REQ['EED_Events_Archive_reset_event_list_settings'] ) || absint( $REQ['EED_Events_Archive_reset_event_list_settings'] ) !== 1 ) { |
579
|
|
|
$CFG->EED_Events_Archive->display_status_banner = isset( $REQ['EED_Events_Archive_display_status_banner'] ) ? absint( $REQ['EED_Events_Archive_display_status_banner'] ) : 0; |
580
|
|
|
$CFG->EED_Events_Archive->display_description = isset( $REQ['EED_Events_Archive_display_description'] ) ? absint( $REQ['EED_Events_Archive_display_description'] ) : 1; |
581
|
|
|
$CFG->EED_Events_Archive->display_ticket_selector = isset( $REQ['EED_Events_Archive_display_ticket_selector'] ) ? absint( $REQ['EED_Events_Archive_display_ticket_selector'] ) : 0; |
582
|
|
|
$CFG->EED_Events_Archive->display_datetimes = isset( $REQ['EED_Events_Archive_display_datetimes'] ) ? absint( $REQ['EED_Events_Archive_display_datetimes'] ) : 1; |
583
|
|
|
$CFG->EED_Events_Archive->display_venue = isset( $REQ['EED_Events_Archive_display_venue'] ) ? absint( $REQ['EED_Events_Archive_display_venue'] ) : 0; |
584
|
|
|
$CFG->EED_Events_Archive->display_expired_events = isset( $REQ['EED_Events_Archive_display_expired_events'] ) ? absint( $REQ['EED_Events_Archive_display_expired_events'] ) : 0; } |
585
|
|
|
return $CFG; |
586
|
|
|
} |
587
|
|
|
|
588
|
|
|
|
589
|
|
|
|
590
|
|
|
/** |
591
|
|
|
* event_list_css |
592
|
|
|
* |
593
|
|
|
* @access public |
594
|
|
|
* @param string $extra_class |
595
|
|
|
* @return string |
596
|
|
|
*/ |
597
|
|
|
public static function event_list_css( $extra_class = '' ) { |
598
|
|
|
$event_list_css = ! empty( $extra_class ) ? array( $extra_class ) : array(); |
599
|
|
|
$event_list_css[] = 'espresso-event-list-event'; |
600
|
|
|
return implode( ' ', $event_list_css ); |
601
|
|
|
} |
602
|
|
|
|
603
|
|
|
|
604
|
|
|
|
605
|
|
|
|
606
|
|
|
|
607
|
|
|
|
608
|
|
|
/** |
609
|
|
|
* event_categories |
610
|
|
|
* |
611
|
|
|
* @access public |
612
|
|
|
* @return array |
613
|
|
|
*/ |
614
|
|
|
public static function event_categories() { |
615
|
|
|
return EE_Registry::instance()->load_model('Term')->get_all_ee_categories(); |
|
|
|
|
616
|
|
|
} |
617
|
|
|
|
618
|
|
|
|
619
|
|
|
|
620
|
|
|
/** |
621
|
|
|
* display_description |
622
|
|
|
* |
623
|
|
|
* @access public |
624
|
|
|
* @param $value |
625
|
|
|
* @return bool |
626
|
|
|
*/ |
627
|
|
|
public static function display_description( $value ) { |
628
|
|
|
$config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
629
|
|
|
$display_description= isset( $config->display_description ) ? $config->display_description : 1; |
630
|
|
|
return $display_description === $value ? TRUE : FALSE; |
631
|
|
|
} |
632
|
|
|
|
633
|
|
|
|
634
|
|
|
/** |
635
|
|
|
* display_ticket_selector |
636
|
|
|
* |
637
|
|
|
* @access public |
638
|
|
|
* @return bool |
639
|
|
|
*/ |
640
|
|
|
public static function display_ticket_selector() { |
641
|
|
|
$config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
642
|
|
|
return isset( $config->display_ticket_selector ) && $config->display_ticket_selector ? TRUE : FALSE; |
643
|
|
|
} |
644
|
|
|
|
645
|
|
|
|
646
|
|
|
|
647
|
|
|
/** |
648
|
|
|
* display_venue |
649
|
|
|
* |
650
|
|
|
* @access public |
651
|
|
|
* @return bool |
652
|
|
|
*/ |
653
|
|
|
public static function display_venue() { |
654
|
|
|
EE_Registry::instance()->load_helper( 'Venue_View' ); |
655
|
|
|
$config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
656
|
|
|
return isset( $config->display_venue ) && $config->display_venue && EEH_Venue_View::venue_name() ? TRUE : FALSE; |
657
|
|
|
} |
658
|
|
|
|
659
|
|
|
|
660
|
|
|
/** |
661
|
|
|
* display_datetimes |
662
|
|
|
* |
663
|
|
|
* @access public |
664
|
|
|
* @return bool |
665
|
|
|
*/ |
666
|
|
|
public static function display_datetimes() { |
667
|
|
|
$config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
668
|
|
|
return isset( $config->display_datetimes ) && $config->display_datetimes ? TRUE : FALSE; |
669
|
|
|
} |
670
|
|
|
|
671
|
|
|
|
672
|
|
|
|
673
|
|
|
|
674
|
|
|
|
675
|
|
|
|
676
|
|
|
/** |
677
|
|
|
* event_list_title |
678
|
|
|
* |
679
|
|
|
* @access public |
680
|
|
|
* @return string |
681
|
|
|
*/ |
682
|
|
|
public static function event_list_title() { |
683
|
|
|
return apply_filters( 'FHEE__archive_espresso_events_template__upcoming_events_h1', __( 'Upcoming Events', 'event_espresso' )); |
684
|
|
|
} |
685
|
|
|
|
686
|
|
|
|
687
|
|
|
// GRAVEYARD |
688
|
|
|
|
689
|
|
|
/** |
690
|
|
|
* @since 4.4.0 |
691
|
|
|
*/ |
692
|
|
|
public static function _doing_it_wrong_notice( $function = '' ) { |
693
|
|
|
EE_Error::doing_it_wrong( |
694
|
|
|
__FUNCTION__, |
695
|
|
|
sprintf( |
696
|
|
|
__( 'EED_Events_Archive::%1$s was moved to EEH_Event_Query::%1$s:%2$sPlease update your existing code because the method it calls will be removed in version %3$s', 'event_espresso' ), |
697
|
|
|
$function, |
698
|
|
|
'<br />', |
699
|
|
|
'4.6.0' |
700
|
|
|
), |
701
|
|
|
'4.4.0' |
702
|
|
|
); |
703
|
|
|
} |
704
|
|
|
|
705
|
|
|
|
706
|
|
|
|
707
|
|
|
/** |
708
|
|
|
* @deprecated |
709
|
|
|
* @since 4.4.0 |
710
|
|
|
*/ |
711
|
|
|
public function get_post_data() { |
712
|
|
|
EE_Registry::instance()->load_helper( 'Event_Query' ); |
713
|
|
|
EEH_Event_Query::set_query_params(); |
714
|
|
|
} |
715
|
|
|
/** |
716
|
|
|
* @deprecated |
717
|
|
|
* @since 4.4.0 |
718
|
|
|
*/ |
719
|
|
|
public function posts_fields( $SQL, WP_Query $wp_query ) { |
720
|
|
|
EE_Registry::instance()->load_helper( 'Event_Query' ); |
721
|
|
|
EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
722
|
|
|
return EEH_Event_Query::posts_fields( $SQL, $wp_query ); |
723
|
|
|
} |
724
|
|
|
/** |
725
|
|
|
* @deprecated |
726
|
|
|
* @since 4.4.0 |
727
|
|
|
*/ |
728
|
|
|
public static function posts_fields_sql_for_orderby( $orderby_params = array() ) { |
729
|
|
|
EE_Registry::instance()->load_helper( 'Event_Query' ); |
730
|
|
|
EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
731
|
|
|
return EEH_Event_Query::posts_fields_sql_for_orderby( $orderby_params ); |
732
|
|
|
} |
733
|
|
|
/** |
734
|
|
|
* @deprecated |
735
|
|
|
* @since 4.4.0 |
736
|
|
|
*/ |
737
|
|
|
public function posts_join( $SQL, WP_Query $wp_query ) { |
738
|
|
|
EE_Registry::instance()->load_helper( 'Event_Query' ); |
739
|
|
|
EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
740
|
|
|
return EEH_Event_Query::posts_join( $SQL, $wp_query ); |
741
|
|
|
} |
742
|
|
|
/** |
743
|
|
|
* @deprecated |
744
|
|
|
* @since 4.4.0 |
745
|
|
|
*/ |
746
|
|
|
public static function posts_join_sql_for_terms( $join_terms = NULL ) { |
747
|
|
|
EE_Registry::instance()->load_helper( 'Event_Query' ); |
748
|
|
|
EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
749
|
|
|
return EEH_Event_Query::posts_join_sql_for_terms( $join_terms ); |
750
|
|
|
} |
751
|
|
|
/** |
752
|
|
|
* @deprecated |
753
|
|
|
* @since 4.4.0 |
754
|
|
|
*/ |
755
|
|
|
public static function posts_join_for_orderby( $orderby_params = array() ) { |
756
|
|
|
EE_Registry::instance()->load_helper( 'Event_Query' ); |
757
|
|
|
EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
758
|
|
|
return EEH_Event_Query::posts_join_for_orderby( $orderby_params ); |
|
|
|
|
759
|
|
|
} |
760
|
|
|
/** |
761
|
|
|
* @deprecated |
762
|
|
|
* @since 4.4.0 |
763
|
|
|
*/ |
764
|
|
|
public function posts_where( $SQL, WP_Query $wp_query ) { |
765
|
|
|
EE_Registry::instance()->load_helper( 'Event_Query' ); |
766
|
|
|
EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
767
|
|
|
return EEH_Event_Query::posts_where( $SQL, $wp_query ); |
768
|
|
|
} |
769
|
|
|
/** |
770
|
|
|
* @deprecated |
771
|
|
|
* @since 4.4.0 |
772
|
|
|
*/ |
773
|
|
|
public static function posts_where_sql_for_show_expired( $show_expired = FALSE ) { |
774
|
|
|
EE_Registry::instance()->load_helper( 'Event_Query' ); |
775
|
|
|
EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
776
|
|
|
return EEH_Event_Query::posts_where_sql_for_show_expired( $show_expired ); |
777
|
|
|
} |
778
|
|
|
/** |
779
|
|
|
* @deprecated |
780
|
|
|
* @since 4.4.0 |
781
|
|
|
*/ |
782
|
|
|
public static function posts_where_sql_for_event_category_slug( $event_category_slug = NULL ) { |
783
|
|
|
EE_Registry::instance()->load_helper( 'Event_Query' ); |
784
|
|
|
EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
785
|
|
|
return EEH_Event_Query::posts_where_sql_for_event_category_slug( $event_category_slug ); |
786
|
|
|
} |
787
|
|
|
/** |
788
|
|
|
* @deprecated |
789
|
|
|
* @since 4.4.0 |
790
|
|
|
*/ |
791
|
|
|
public static function posts_where_sql_for_event_list_month( $month = NULL ) { |
792
|
|
|
EE_Registry::instance()->load_helper( 'Event_Query' ); |
793
|
|
|
EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
794
|
|
|
return EEH_Event_Query::posts_where_sql_for_event_list_month( $month ); |
795
|
|
|
} |
796
|
|
|
/** |
797
|
|
|
* @deprecated |
798
|
|
|
* @since 4.4.0 |
799
|
|
|
*/ |
800
|
|
|
public function posts_orderby( $SQL, WP_Query $wp_query ) { |
801
|
|
|
EE_Registry::instance()->load_helper( 'Event_Query' ); |
802
|
|
|
EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
803
|
|
|
return EEH_Event_Query::posts_orderby( $SQL, $wp_query ); |
804
|
|
|
} |
805
|
|
|
/** |
806
|
|
|
* @deprecated |
807
|
|
|
* @since 4.4.0 |
808
|
|
|
*/ |
809
|
|
|
public static function posts_orderby_sql( $orderby_params = array(), $sort = 'ASC' ) { |
810
|
|
|
EE_Registry::instance()->load_helper( 'Event_Query' ); |
811
|
|
|
EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
812
|
|
|
return EEH_Event_Query::posts_orderby_sql( $orderby_params, $sort ); |
813
|
|
|
} |
814
|
|
|
|
815
|
|
|
|
816
|
|
|
|
817
|
|
|
} |
818
|
|
|
|
819
|
|
|
|
820
|
|
|
|
821
|
|
|
|
822
|
|
|
|
823
|
|
|
/** |
824
|
|
|
* @return int |
825
|
|
|
*/ |
826
|
|
|
function espresso_get_event_list_ID() { |
827
|
|
|
EED_Events_Archive::$espresso_event_list_ID++; |
828
|
|
|
EED_Events_Archive::$espresso_grid_event_lists[] = EED_Events_Archive::$espresso_event_list_ID; |
829
|
|
|
return EED_Events_Archive::$espresso_event_list_ID; |
830
|
|
|
} |
831
|
|
|
|
832
|
|
|
/** |
833
|
|
|
* @return string |
834
|
|
|
*/ |
835
|
|
|
function espresso_event_list_title() { |
836
|
|
|
return EED_Events_Archive::event_list_title(); |
837
|
|
|
} |
838
|
|
|
|
839
|
|
|
/** |
840
|
|
|
* @param string $extra_class |
841
|
|
|
* @return string |
842
|
|
|
*/ |
843
|
|
|
function espresso_event_list_css( $extra_class = '' ) { |
844
|
|
|
return EED_Events_Archive::event_list_css( $extra_class ); |
845
|
|
|
} |
846
|
|
|
|
847
|
|
|
/** |
848
|
|
|
* @return array |
849
|
|
|
*/ |
850
|
|
|
function espresso_get_event_categories() { |
851
|
|
|
return EED_Events_Archive::event_categories(); |
852
|
|
|
} |
853
|
|
|
|
854
|
|
|
/** |
855
|
|
|
* @return bool |
856
|
|
|
*/ |
857
|
|
|
function espresso_display_full_description_in_event_list() { |
858
|
|
|
return EED_Events_Archive::display_description( 2 ); |
859
|
|
|
} |
860
|
|
|
|
861
|
|
|
/** |
862
|
|
|
* @return bool |
863
|
|
|
*/ |
864
|
|
|
function espresso_display_excerpt_in_event_list() { |
865
|
|
|
return EED_Events_Archive::display_description( 1 ); |
866
|
|
|
} |
867
|
|
|
|
868
|
|
|
/** |
869
|
|
|
* @return bool |
870
|
|
|
*/ |
871
|
|
|
function espresso_display_ticket_selector_in_event_list() { |
872
|
|
|
return EED_Events_Archive::display_ticket_selector(); |
873
|
|
|
} |
874
|
|
|
|
875
|
|
|
/** |
876
|
|
|
* @return bool |
877
|
|
|
*/ |
878
|
|
|
function espresso_display_venue_in_event_list() { |
879
|
|
|
return EED_Events_Archive::display_venue(); |
880
|
|
|
} |
881
|
|
|
|
882
|
|
|
/** |
883
|
|
|
* @return bool |
884
|
|
|
*/ |
885
|
|
|
function espresso_display_datetimes_in_event_list() { |
886
|
|
|
return EED_Events_Archive::display_datetimes(); |
887
|
|
|
} |
888
|
|
|
|
889
|
|
|
|
890
|
|
|
|
891
|
|
|
|
892
|
|
|
|
893
|
|
|
|
894
|
|
|
|
895
|
|
|
// End of file EED_Events_Archive.module.php |
896
|
|
|
// Location: /modules/events_archive/EED_Events_Archive.module.php |
897
|
|
|
|
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()
method in theSon
calls the wrong method in the parent class.