|
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 Details |
|
17
|
|
|
* |
|
18
|
|
|
* @package Event Espresso |
|
19
|
|
|
* @subpackage /modules/event_details/ |
|
20
|
|
|
* @author Brent Christensen |
|
21
|
|
|
* |
|
22
|
|
|
* ------------------------------------------------------------------------ |
|
23
|
|
|
*/ |
|
24
|
|
|
class EED_Event_Single extends EED_Module { |
|
25
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @type EE_Template_Part_Manager $template_parts |
|
29
|
|
|
*/ |
|
30
|
|
|
protected $template_parts; |
|
31
|
|
|
|
|
32
|
|
|
|
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @return EED_Event_Single |
|
36
|
|
|
*/ |
|
37
|
|
|
public static function instance() { |
|
38
|
|
|
return parent::get_instance( __CLASS__ ); |
|
|
|
|
|
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
|
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* set_hooks - for hooking into EE Core, other modules, etc |
|
45
|
|
|
* |
|
46
|
|
|
* @access public |
|
47
|
|
|
* @return void |
|
48
|
|
|
*/ |
|
49
|
|
|
public static function set_hooks() { |
|
50
|
|
|
add_filter( 'FHEE_run_EE_wp', '__return_true' ); |
|
51
|
|
|
add_action( 'wp_loaded', array( 'EED_Event_Single', 'set_definitions' ), 2 ); |
|
52
|
|
|
EE_Config::register_route( __( 'event', 'event_espresso' ), 'Event_Single', 'run' ); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
57
|
|
|
* |
|
58
|
|
|
* @access public |
|
59
|
|
|
* @return void |
|
60
|
|
|
*/ |
|
61
|
|
|
public static function set_hooks_admin() { |
|
62
|
|
|
add_action( 'wp_loaded', array( 'EED_Event_Single', 'set_definitions' ), 2 ); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
|
|
66
|
|
|
|
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* set_definitions |
|
70
|
|
|
* |
|
71
|
|
|
* @access public |
|
72
|
|
|
* @static |
|
73
|
|
|
* @return void |
|
74
|
|
|
*/ |
|
75
|
|
|
public static function set_definitions() { |
|
76
|
|
|
define( 'EVENT_SINGLE_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS ); |
|
77
|
|
|
define( 'EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path( __FILE__ ) . 'templates' . DS ); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
|
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* set_config |
|
84
|
|
|
* |
|
85
|
|
|
* @void |
|
86
|
|
|
*/ |
|
87
|
|
|
protected function set_config(){ |
|
88
|
|
|
$this->set_config_section( 'template_settings' ); |
|
89
|
|
|
$this->set_config_class( 'EE_Event_Single_Config' ); |
|
90
|
|
|
$this->set_config_name( 'EED_Event_Single' ); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
|
|
94
|
|
|
|
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* initialize_template_parts |
|
98
|
|
|
* |
|
99
|
|
|
* @access public |
|
100
|
|
|
* @param \EE_Event_Single_Config $config |
|
101
|
|
|
* @return \EE_Template_Part_Manager |
|
102
|
|
|
*/ |
|
103
|
|
View Code Duplication |
public function initialize_template_parts( EE_Event_Single_Config $config = null ) { |
|
|
|
|
|
|
104
|
|
|
$config = $config instanceof EE_Event_Single_Config ? $config : $this->config(); |
|
105
|
|
|
EEH_Autoloader::instance()->register_template_part_autoloaders(); |
|
106
|
|
|
$template_parts = new EE_Template_Part_Manager(); |
|
107
|
|
|
$template_parts->add_template_part( |
|
108
|
|
|
'tickets', |
|
109
|
|
|
__( 'Ticket Selector', 'event_espresso' ), |
|
110
|
|
|
'content-espresso_events-tickets.php', |
|
111
|
|
|
$config->display_order_tickets |
|
|
|
|
|
|
112
|
|
|
); |
|
113
|
|
|
$template_parts->add_template_part( |
|
114
|
|
|
'datetimes', |
|
115
|
|
|
__( 'Dates and Times', 'event_espresso' ), |
|
116
|
|
|
'content-espresso_events-datetimes.php', |
|
117
|
|
|
$config->display_order_datetimes |
|
|
|
|
|
|
118
|
|
|
); |
|
119
|
|
|
$template_parts->add_template_part( |
|
120
|
|
|
'event', |
|
121
|
|
|
__( 'Event Description', 'event_espresso' ), |
|
122
|
|
|
'content-espresso_events-details.php', |
|
123
|
|
|
$config->display_order_event |
|
|
|
|
|
|
124
|
|
|
); |
|
125
|
|
|
$template_parts->add_template_part( |
|
126
|
|
|
'venue', |
|
127
|
|
|
__( 'Venue Information', 'event_espresso' ), |
|
128
|
|
|
'content-espresso_events-venues.php', |
|
129
|
|
|
$config->display_order_venue |
|
|
|
|
|
|
130
|
|
|
); |
|
131
|
|
|
do_action( 'AHEE__EED_Event_Single__initialize_template_parts', $template_parts ); |
|
132
|
|
|
return $template_parts; |
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
|
|
|
|
136
|
|
|
|
|
137
|
|
|
|
|
138
|
|
|
/** |
|
139
|
|
|
* run - initial module setup |
|
140
|
|
|
* |
|
141
|
|
|
* @access public |
|
142
|
|
|
* @param WP $WP |
|
143
|
|
|
* @return void |
|
144
|
|
|
*/ |
|
145
|
|
|
public function run( $WP ) { |
|
146
|
|
|
// ensure valid EE_Events_Single_Config() object exists |
|
147
|
|
|
$this->set_config(); |
|
148
|
|
|
// check what template is loaded |
|
149
|
|
|
add_filter( 'template_include', array( $this, 'template_include' ), 999, 1 ); |
|
150
|
|
|
add_filter( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true' ); |
|
151
|
|
|
// load css |
|
152
|
|
|
add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 10 ); |
|
153
|
|
|
EE_Registry::instance()->load_helper( 'Venue_View' ); |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
|
|
157
|
|
|
|
|
158
|
|
|
/** |
|
159
|
|
|
* template_include |
|
160
|
|
|
* |
|
161
|
|
|
* @access public |
|
162
|
|
|
* @param string $template |
|
163
|
|
|
* @return string |
|
164
|
|
|
*/ |
|
165
|
|
|
public function template_include( $template ) { |
|
166
|
|
|
global $post; |
|
167
|
|
|
/** @type EE_Event_Single_Config $config */ |
|
168
|
|
|
$config = $this->config(); |
|
169
|
|
|
if ( $config->display_status_banner_single ) { |
|
170
|
|
|
add_filter( 'the_title', array( 'EED_Event_Single', 'the_title' ), 100, 2 ); |
|
171
|
|
|
} |
|
172
|
|
|
// not a custom template? |
|
173
|
|
|
if ( |
|
174
|
|
|
EE_Front_Controller::instance()->get_selected_template() != 'single-espresso_events.php' |
|
175
|
|
|
&& ! post_password_required( $post ) |
|
176
|
|
|
) { |
|
177
|
|
|
EEH_Template::load_espresso_theme_functions(); |
|
178
|
|
|
// then add extra event data via hooks |
|
179
|
|
|
add_action( 'loop_start', array( 'EED_Event_Single', 'loop_start' )); |
|
180
|
|
|
add_filter( 'the_content', array( 'EED_Event_Single', 'event_details' ), 100 ); |
|
181
|
|
|
add_action( 'loop_end', array( 'EED_Event_Single', 'loop_end' )); |
|
182
|
|
|
// don't display entry meta because the existing theme will take car of that |
|
183
|
|
|
add_filter( 'FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false' ); |
|
184
|
|
|
} |
|
185
|
|
|
return $template; |
|
186
|
|
|
} |
|
187
|
|
|
|
|
188
|
|
|
|
|
189
|
|
|
|
|
190
|
|
|
/** |
|
191
|
|
|
* loop_start |
|
192
|
|
|
* |
|
193
|
|
|
* @access public |
|
194
|
|
|
* @param array $wp_query_array an array containing the WP_Query object |
|
195
|
|
|
* @return void |
|
196
|
|
|
*/ |
|
197
|
|
|
public static function loop_start( $wp_query_array ) { |
|
198
|
|
|
global $post; |
|
199
|
|
|
do_action( 'AHEE_event_details_before_post', $post, $wp_query_array ); |
|
200
|
|
|
} |
|
201
|
|
|
|
|
202
|
|
|
|
|
203
|
|
|
|
|
204
|
|
|
/** |
|
205
|
|
|
* the_title |
|
206
|
|
|
* |
|
207
|
|
|
* @access public |
|
208
|
|
|
* @param string $title |
|
209
|
|
|
* @param int $id |
|
210
|
|
|
* @return string |
|
211
|
|
|
*/ |
|
212
|
|
|
public static function the_title( $title = '', $id = 0 ) { |
|
213
|
|
|
global $post; |
|
214
|
|
|
return in_the_loop() && $post->ID == $id ? espresso_event_status_banner( $post->ID ) . $title : $title; |
|
215
|
|
|
} |
|
216
|
|
|
|
|
217
|
|
|
|
|
218
|
|
|
/** |
|
219
|
|
|
* event_details |
|
220
|
|
|
* |
|
221
|
|
|
* @access public |
|
222
|
|
|
* @param string $content |
|
223
|
|
|
* @return string |
|
224
|
|
|
*/ |
|
225
|
|
|
public static function event_details( $content ) { |
|
226
|
|
|
global $post; |
|
227
|
|
|
static $current_post_ID = 0; |
|
228
|
|
|
if ( |
|
229
|
|
|
$current_post_ID != $post->ID |
|
230
|
|
|
&& $post->post_type == 'espresso_events' |
|
231
|
|
|
&& ! post_password_required() |
|
232
|
|
|
) { |
|
233
|
|
|
// Set current post ID to prevent showing content twice, but only if headers have definitely been sent. |
|
234
|
|
|
// Reason being is that some plugins, like Yoast, need to run through a copy of the loop early |
|
235
|
|
|
// BEFORE headers are sent in order to examine the post content and generate content for the HTML header. |
|
236
|
|
|
// We want to allow those plugins to still do their thing and have access to our content, but depending on |
|
237
|
|
|
// how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice, |
|
238
|
|
|
// so the following allows this filter to be applied multiple times, but only once for real |
|
239
|
|
|
$current_post_ID = did_action( 'loop_start' ) ? $post->ID : 0; |
|
240
|
|
|
if ( EE_Registry::instance()->CFG->template_settings->EED_Event_Single->use_sortable_display_order ) { |
|
241
|
|
|
// we need to first remove this callback from being applied to the_content() |
|
242
|
|
|
// (otherwise it will recurse and blow up the interweb) |
|
243
|
|
|
remove_filter( 'the_content', array( 'EED_Event_Single', 'event_details' ), 100 ); |
|
244
|
|
|
EED_Event_Single::instance()->template_parts = EED_Event_Single::instance()->initialize_template_parts(); |
|
245
|
|
|
$content = EEH_Template::locate_template( 'content-espresso_events-details.php' ); |
|
246
|
|
|
$content = EED_Event_Single::instance()->template_parts->apply_template_part_filters( $content ); |
|
247
|
|
|
add_filter( 'the_content', array( 'EED_Event_Single', 'event_details' ), 100 ); |
|
248
|
|
|
} else { |
|
249
|
|
|
$content = EED_Event_Single::use_filterable_display_order(); |
|
250
|
|
|
} |
|
251
|
|
|
} |
|
252
|
|
|
return $content; |
|
253
|
|
|
} |
|
254
|
|
|
|
|
255
|
|
|
|
|
256
|
|
|
|
|
257
|
|
|
/** |
|
258
|
|
|
* use_filterable_display_order |
|
259
|
|
|
* |
|
260
|
|
|
* @access protected |
|
261
|
|
|
* @return string |
|
262
|
|
|
*/ |
|
263
|
|
|
protected static function use_filterable_display_order() { |
|
264
|
|
|
// since the 'content-espresso_events-details.php' template might be used directly from within a theme, |
|
265
|
|
|
// it uses the_content() for displaying the $post->post_content |
|
266
|
|
|
// so in order to load a template that uses the_content() from within a callback being used to filter the_content(), |
|
267
|
|
|
// we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb) |
|
268
|
|
|
remove_filter( 'the_content', array( 'EED_Event_Single', 'event_details' ), 100 ); |
|
269
|
|
|
//now add additional content |
|
270
|
|
|
add_filter( 'the_content', array( 'EED_Event_Single', 'event_datetimes' ), 110, 1 ); |
|
271
|
|
|
add_filter( 'the_content', array( 'EED_Event_Single', 'event_tickets' ), 120, 1 ); |
|
272
|
|
|
add_filter( 'the_content', array( 'EED_Event_Single', 'event_venues' ), 130, 1 ); |
|
273
|
|
|
do_action( 'AHEE__EED_Event_Single__use_filterable_display_order__after_add_filters' ); |
|
274
|
|
|
// now load our template |
|
275
|
|
|
$content = EEH_Template::locate_template( 'content-espresso_events-details.php' ); |
|
276
|
|
|
//now add our filter back in, plus some others |
|
277
|
|
|
add_filter( 'the_content', array( 'EED_Event_Single', 'event_details' ), 100 ); |
|
278
|
|
|
remove_filter( 'the_content', array( 'EED_Event_Single', 'event_datetimes' ), 110 ); |
|
279
|
|
|
remove_filter( 'the_content', array( 'EED_Event_Single', 'event_tickets' ), 120 ); |
|
280
|
|
|
remove_filter( 'the_content', array( 'EED_Event_Single', 'event_venues' ), 130 ); |
|
281
|
|
|
// we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
|
282
|
|
|
return $content; |
|
283
|
|
|
} |
|
284
|
|
|
|
|
285
|
|
|
|
|
286
|
|
|
|
|
287
|
|
|
/** |
|
288
|
|
|
* event_datetimes - adds datetimes ABOVE content |
|
289
|
|
|
* |
|
290
|
|
|
* @access public |
|
291
|
|
|
* @param string $content |
|
292
|
|
|
* @return string |
|
293
|
|
|
*/ |
|
294
|
|
|
public static function event_datetimes( $content ) { |
|
295
|
|
|
return EEH_Template::locate_template( 'content-espresso_events-datetimes.php' ) . $content; |
|
296
|
|
|
} |
|
297
|
|
|
|
|
298
|
|
|
|
|
299
|
|
|
|
|
300
|
|
|
/** |
|
301
|
|
|
* event_tickets - adds tickets ABOVE content (which includes datetimes) |
|
302
|
|
|
* |
|
303
|
|
|
* @access public |
|
304
|
|
|
* @param string $content |
|
305
|
|
|
* @return string |
|
306
|
|
|
*/ |
|
307
|
|
|
public static function event_tickets( $content ) { |
|
308
|
|
|
return EEH_Template::locate_template( 'content-espresso_events-tickets.php' ) . $content; |
|
309
|
|
|
} |
|
310
|
|
|
|
|
311
|
|
|
|
|
312
|
|
|
|
|
313
|
|
|
/** |
|
314
|
|
|
* event_venues |
|
315
|
|
|
* |
|
316
|
|
|
* @access public |
|
317
|
|
|
* @param string $content |
|
318
|
|
|
* @return string |
|
319
|
|
|
*/ |
|
320
|
|
|
public static function event_venue( $content ) { |
|
321
|
|
|
return EED_Event_Single::event_venues( $content ); |
|
322
|
|
|
} |
|
323
|
|
|
|
|
324
|
|
|
|
|
325
|
|
|
|
|
326
|
|
|
/** |
|
327
|
|
|
* event_venues - adds venues BELOW content |
|
328
|
|
|
* |
|
329
|
|
|
* @access public |
|
330
|
|
|
* @param string $content |
|
331
|
|
|
* @return string |
|
332
|
|
|
*/ |
|
333
|
|
|
public static function event_venues( $content ) { |
|
334
|
|
|
return $content . EEH_Template::locate_template( 'content-espresso_events-venues.php' ); |
|
335
|
|
|
} |
|
336
|
|
|
|
|
337
|
|
|
|
|
338
|
|
|
|
|
339
|
|
|
/** |
|
340
|
|
|
* loop_end |
|
341
|
|
|
* |
|
342
|
|
|
* @access public |
|
343
|
|
|
* @param array $wp_query_array an array containing the WP_Query object |
|
344
|
|
|
* @return void |
|
345
|
|
|
*/ |
|
346
|
|
|
public static function loop_end( $wp_query_array ) { |
|
347
|
|
|
global $post; |
|
348
|
|
|
do_action( 'AHEE_event_details_after_post', $post, $wp_query_array ); |
|
349
|
|
|
} |
|
350
|
|
|
|
|
351
|
|
|
|
|
352
|
|
|
|
|
353
|
|
|
/** |
|
354
|
|
|
* wp_enqueue_scripts |
|
355
|
|
|
* |
|
356
|
|
|
* @access public |
|
357
|
|
|
* @return void |
|
358
|
|
|
*/ |
|
359
|
|
|
public function wp_enqueue_scripts() { |
|
360
|
|
|
// get some style |
|
361
|
|
|
if ( apply_filters( 'FHEE_enable_default_espresso_css', TRUE ) && apply_filters( 'FHEE__EED_Event_Single__wp_enqueue_scripts__enable_css', TRUE )) { |
|
362
|
|
|
EE_Registry::instance()->load_helper( 'File' ); |
|
363
|
|
|
// first check uploads folder |
|
364
|
|
|
if ( is_readable( get_stylesheet_directory() . $this->theme . DS . 'style.css' )) { |
|
365
|
|
|
wp_register_style( $this->theme, get_stylesheet_directory_uri() . $this->theme . DS . 'style.css', array( 'dashicons', 'espresso_default' )); |
|
366
|
|
|
} else { |
|
367
|
|
|
wp_register_style( $this->theme, EE_TEMPLATES_URL . $this->theme . DS . 'style.css', array( 'dashicons', 'espresso_default' )); |
|
368
|
|
|
} |
|
369
|
|
|
wp_enqueue_script( $this->theme ); |
|
370
|
|
|
if ( EE_Registry::instance()->CFG->map_settings->use_google_maps ) { |
|
371
|
|
|
EE_Registry::instance()->load_helper( 'Maps' ); |
|
372
|
|
|
add_action('wp_enqueue_scripts', array( 'EEH_Maps', 'espresso_google_map_js' ), 11 ); |
|
373
|
|
|
} |
|
374
|
|
|
} |
|
375
|
|
|
} |
|
376
|
|
|
|
|
377
|
|
|
|
|
378
|
|
|
|
|
379
|
|
|
|
|
380
|
|
|
|
|
381
|
|
|
|
|
382
|
|
|
|
|
383
|
|
|
|
|
384
|
|
|
/** |
|
385
|
|
|
* display_venue |
|
386
|
|
|
* |
|
387
|
|
|
* @access public |
|
388
|
|
|
* @return bool |
|
389
|
|
|
*/ |
|
390
|
|
|
public static function display_venue() { |
|
391
|
|
|
EE_Registry::instance()->load_helper( 'Venue_View' ); |
|
392
|
|
|
/** @type EE_Event_Single_Config $config */ |
|
393
|
|
|
$config = EED_Event_Single::instance()->config(); |
|
394
|
|
|
$display_venue= isset( $config->display_venue ) ? $config->display_venue : TRUE; |
|
395
|
|
|
$venue_name = EEH_Venue_View::venue_name(); |
|
396
|
|
|
return $display_venue && ! empty( $venue_name ) ? TRUE : FALSE; |
|
397
|
|
|
} |
|
398
|
|
|
|
|
399
|
|
|
|
|
400
|
|
|
|
|
401
|
|
|
} |
|
402
|
|
|
|
|
403
|
|
|
|
|
404
|
|
|
|
|
405
|
|
|
|
|
406
|
|
|
|
|
407
|
|
|
/** |
|
408
|
|
|
* espresso_display_venue_in_event_details |
|
409
|
|
|
* |
|
410
|
|
|
* @see EED_Event_Single::display_venue() |
|
411
|
|
|
* @return bool |
|
412
|
|
|
*/ |
|
413
|
|
|
function espresso_display_venue_in_event_details() { |
|
414
|
|
|
return EED_Event_Single::display_venue(); |
|
415
|
|
|
} |
|
416
|
|
|
|
|
417
|
|
|
|
|
418
|
|
|
|
|
419
|
|
|
// End of file EED_Event_Single.module.php |
|
420
|
|
|
// Location: /modules/event_details/EED_Event_Single.module.php |
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 theSoncalls the wrong method in the parent class.