1
|
|
|
<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
2
|
|
|
exit('No direct script access allowed'); |
3
|
|
|
} |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Event Espresso |
7
|
|
|
* Event Registration and Management Plugin for WordPress |
8
|
|
|
* @ package Event Espresso |
9
|
|
|
* @ author Seth Shoultes |
10
|
|
|
* @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
11
|
|
|
* @ license http://eventespresso.com/support/terms-conditions/ * see Plugin Licensing * |
12
|
|
|
* @ link http://www.eventespresso.com |
13
|
|
|
* @ version 4.0 |
14
|
|
|
* ------------------------------------------------------------------------ |
15
|
|
|
* EE_Front_Controller |
16
|
|
|
* |
17
|
|
|
* @package Event Espresso |
18
|
|
|
* @subpackage core/ |
19
|
|
|
* @author Brent Christensen |
20
|
|
|
* ------------------------------------------------------------------------ |
21
|
|
|
*/ |
22
|
|
|
final class EE_Front_Controller |
23
|
|
|
{ |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* $_template_path |
27
|
|
|
* @var string $_template_path |
28
|
|
|
* @access public |
29
|
|
|
*/ |
30
|
|
|
private $_template_path; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* $_template |
34
|
|
|
* @var string $_template |
35
|
|
|
* @access public |
36
|
|
|
*/ |
37
|
|
|
private $_template; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @type EE_Registry $Registry |
41
|
|
|
* @access protected |
42
|
|
|
*/ |
43
|
|
|
protected $Registry; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @type EE_Request_Handler $Request_Handler |
47
|
|
|
* @access protected |
48
|
|
|
*/ |
49
|
|
|
protected $Request_Handler; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @type EE_Module_Request_Router $Module_Request_Router |
53
|
|
|
* @access protected |
54
|
|
|
*/ |
55
|
|
|
protected $Module_Request_Router; |
56
|
|
|
|
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* class constructor |
60
|
|
|
* should fire after shortcode, module, addon, or other plugin's default priority init phases have run |
61
|
|
|
* |
62
|
|
|
* @access public |
63
|
|
|
* @param \EE_Registry $Registry |
64
|
|
|
* @param \EE_Request_Handler $Request_Handler |
65
|
|
|
* @param \EE_Module_Request_Router $Module_Request_Router |
66
|
|
|
*/ |
67
|
|
|
public function __construct( |
68
|
|
|
EE_Registry $Registry, |
69
|
|
|
EE_Request_Handler $Request_Handler, |
70
|
|
|
EE_Module_Request_Router $Module_Request_Router |
71
|
|
|
) { |
72
|
|
|
$this->Registry = $Registry; |
73
|
|
|
$this->Request_Handler = $Request_Handler; |
74
|
|
|
$this->Module_Request_Router = $Module_Request_Router; |
75
|
|
|
// make sure template tags are loaded immediately so that themes don't break |
76
|
|
|
add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'load_espresso_template_tags'), 10); |
77
|
|
|
// determine how to integrate WP_Query with the EE models |
78
|
|
|
add_action('AHEE__EE_System__initialize', array($this, 'employ_CPT_Strategy')); |
79
|
|
|
// load other resources and begin to actually run shortcodes and modules |
80
|
|
|
add_action('wp_loaded', array($this, 'wp_loaded'), 5); |
81
|
|
|
// analyse the incoming WP request |
82
|
|
|
add_action('parse_request', array($this, 'get_request'), 1, 1); |
83
|
|
|
// process any content shortcodes |
84
|
|
|
add_action('parse_request', array($this, '_initialize_shortcodes'), 5); |
85
|
|
|
// process request with module factory |
86
|
|
|
add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1); |
87
|
|
|
// before headers sent |
88
|
|
|
add_action('wp', array($this, 'wp'), 5); |
89
|
|
|
// load css and js |
90
|
|
|
add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 1); |
91
|
|
|
// header |
92
|
|
|
add_action('wp_head', array($this, 'header_meta_tag'), 5); |
93
|
|
|
add_filter('template_include', array($this, 'template_include'), 1); |
94
|
|
|
// display errors |
95
|
|
|
add_action('loop_start', array($this, 'display_errors'), 2); |
96
|
|
|
// the content |
97
|
|
|
// add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 ); |
98
|
|
|
//exclude our private cpt comments |
99
|
|
|
add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1); |
100
|
|
|
//make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://) |
101
|
|
|
add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1); |
102
|
|
|
// action hook EE |
103
|
|
|
do_action('AHEE__EE_Front_Controller__construct__done', $this); |
104
|
|
|
// for checking that browser cookies are enabled |
105
|
|
|
if (apply_filters('FHEE__EE_Front_Controller____construct__set_test_cookie', true)) { |
106
|
|
|
setcookie('ee_cookie_test', uniqid(), time() + 24 * HOUR_IN_SECONDS, '/'); |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @return EE_Request_Handler |
113
|
|
|
*/ |
114
|
|
|
public function Request_Handler() |
115
|
|
|
{ |
116
|
|
|
return $this->Request_Handler; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* @return EE_Module_Request_Router |
122
|
|
|
*/ |
123
|
|
|
public function Module_Request_Router() |
124
|
|
|
{ |
125
|
|
|
return $this->Module_Request_Router; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
|
129
|
|
|
|
130
|
|
|
|
131
|
|
|
|
132
|
|
|
/*********************************************** INIT ACTION HOOK ***********************************************/ |
133
|
|
|
|
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* load_espresso_template_tags - if current theme is an espresso theme, or uses ee theme template parts, then |
137
|
|
|
* load it's functions.php file ( if not already loaded ) |
138
|
|
|
* |
139
|
|
|
* @return void |
140
|
|
|
*/ |
141
|
|
|
public function load_espresso_template_tags() |
142
|
|
|
{ |
143
|
|
|
if (is_readable(EE_PUBLIC . 'template_tags.php')) { |
144
|
|
|
require_once(EE_PUBLIC . 'template_tags.php'); |
145
|
|
|
} |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* filter_wp_comments |
151
|
|
|
* This simply makes sure that any "private" EE CPTs do not have their comments show up in any wp comment |
152
|
|
|
* widgets/queries done on frontend |
153
|
|
|
* |
154
|
|
|
* @param array $clauses array of comment clauses setup by WP_Comment_Query |
155
|
|
|
* @return array array of comment clauses with modifications. |
156
|
|
|
*/ |
157
|
|
|
public function filter_wp_comments($clauses) |
158
|
|
|
{ |
159
|
|
|
global $wpdb; |
160
|
|
|
if (strpos($clauses['join'], $wpdb->posts) !== false) { |
161
|
|
|
$cpts = EE_Register_CPTs::get_private_CPTs(); |
162
|
|
|
foreach ($cpts as $cpt => $details) { |
163
|
|
|
$clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt); |
164
|
|
|
} |
165
|
|
|
} |
166
|
|
|
return $clauses; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* employ_CPT_Strategy |
172
|
|
|
* |
173
|
|
|
* @access public |
174
|
|
|
* @return void |
175
|
|
|
*/ |
176
|
|
|
public function employ_CPT_Strategy() |
177
|
|
|
{ |
178
|
|
|
if (apply_filters('FHEE__EE_Front_Controller__employ_CPT_Strategy', true)) { |
179
|
|
|
$this->Registry->load_core('CPT_Strategy'); |
180
|
|
|
} |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
|
184
|
|
|
/** |
185
|
|
|
* this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend |
186
|
|
|
* |
187
|
|
|
* @param string $url incoming url |
188
|
|
|
* @return string final assembled url |
189
|
|
|
*/ |
190
|
|
|
public function maybe_force_admin_ajax_ssl($url) |
191
|
|
|
{ |
192
|
|
|
if (is_ssl() && preg_match('/admin-ajax.php/', $url)) { |
193
|
|
|
$url = str_replace('http://', 'https://', $url); |
194
|
|
|
} |
195
|
|
|
return $url; |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
|
199
|
|
|
|
200
|
|
|
|
201
|
|
|
|
202
|
|
|
|
203
|
|
|
/*********************************************** WP_LOADED ACTION HOOK ***********************************************/ |
204
|
|
|
|
205
|
|
|
|
206
|
|
|
/** |
207
|
|
|
* wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their |
208
|
|
|
* default priority init phases have run |
209
|
|
|
* |
210
|
|
|
* @access public |
211
|
|
|
* @return void |
212
|
|
|
*/ |
213
|
|
|
public function wp_loaded() |
214
|
|
|
{ |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
|
218
|
|
|
|
219
|
|
|
|
220
|
|
|
|
221
|
|
|
/*********************************************** PARSE_REQUEST HOOK ***********************************************/ |
222
|
|
|
/** |
223
|
|
|
* _get_request |
224
|
|
|
* |
225
|
|
|
* @access public |
226
|
|
|
* @param WP $WP |
227
|
|
|
* @return void |
228
|
|
|
*/ |
229
|
|
|
public function get_request(WP $WP) |
230
|
|
|
{ |
231
|
|
|
do_action('AHEE__EE_Front_Controller__get_request__start'); |
232
|
|
|
$this->Request_Handler->parse_request($WP); |
233
|
|
|
do_action('AHEE__EE_Front_Controller__get_request__complete'); |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
|
237
|
|
|
/** |
238
|
|
|
* _initialize_shortcodes - calls init method on shortcodes that have been determined to be in the_content for |
239
|
|
|
* the currently requested page |
240
|
|
|
* |
241
|
|
|
* @access public |
242
|
|
|
* @param WP $WP |
243
|
|
|
* @return void |
244
|
|
|
*/ |
245
|
|
|
public function _initialize_shortcodes(WP $WP) |
246
|
|
|
{ |
247
|
|
|
do_action('AHEE__EE_Front_Controller__initialize_shortcodes__begin', $WP, $this); |
248
|
|
|
$this->Request_Handler->set_request_vars($WP); |
249
|
|
|
// grab post_name from request |
250
|
|
|
$current_post = apply_filters('FHEE__EE_Front_Controller__initialize_shortcodes__current_post_name', |
251
|
|
|
$this->Request_Handler->get('post_name')); |
252
|
|
|
$show_on_front = get_option('show_on_front'); |
253
|
|
|
// if it's not set, then check if frontpage is blog |
254
|
|
View Code Duplication |
if (empty($current_post)) { |
255
|
|
|
// yup.. this is the posts page, prepare to load all shortcode modules |
256
|
|
|
$current_post = 'posts'; |
257
|
|
|
// unless.. |
258
|
|
|
if ($show_on_front === 'page') { |
259
|
|
|
// some other page is set as the homepage |
260
|
|
|
$page_on_front = get_option('page_on_front'); |
261
|
|
|
if ($page_on_front) { |
262
|
|
|
// k now we need to find the post_name for this page |
263
|
|
|
global $wpdb; |
264
|
|
|
$page_on_front = $wpdb->get_var( |
265
|
|
|
$wpdb->prepare( |
266
|
|
|
"SELECT post_name from $wpdb->posts WHERE post_type='page' AND post_status='publish' AND ID=%d", |
267
|
|
|
$page_on_front |
268
|
|
|
) |
269
|
|
|
); |
270
|
|
|
// set the current post slug to what it actually is |
271
|
|
|
$current_post = $page_on_front ? $page_on_front : $current_post; |
272
|
|
|
} |
273
|
|
|
} |
274
|
|
|
} |
275
|
|
|
// where are posts being displayed ? |
276
|
|
|
$page_for_posts = EE_Config::get_page_for_posts(); |
277
|
|
|
// in case $current_post is hierarchical like: /parent-page/current-page |
278
|
|
|
$current_post = basename($current_post); |
279
|
|
|
// are we on a category page? |
280
|
|
|
$term_exists = is_array(term_exists($current_post, 'category')) || array_key_exists('category_name', |
281
|
|
|
$WP->query_vars); |
282
|
|
|
// make sure shortcodes are set |
283
|
|
|
if (isset($this->Registry->CFG->core->post_shortcodes)) { |
284
|
|
|
if ( ! isset($this->Registry->CFG->core->post_shortcodes[$page_for_posts])) { |
285
|
|
|
$this->Registry->CFG->core->post_shortcodes[$page_for_posts] = array(); |
286
|
|
|
} |
287
|
|
|
// cycle thru all posts with shortcodes set |
288
|
|
|
foreach ($this->Registry->CFG->core->post_shortcodes as $post_name => $post_shortcodes) { |
289
|
|
|
// filter shortcodes so |
290
|
|
|
$post_shortcodes = apply_filters('FHEE__Front_Controller__initialize_shortcodes__post_shortcodes', |
291
|
|
|
$post_shortcodes); |
292
|
|
|
// now cycle thru shortcodes |
293
|
|
|
foreach ($post_shortcodes as $shortcode_class => $post_id) { |
294
|
|
|
// are we on this page, or on the blog page, or an EE CPT category page ? |
295
|
|
|
if ($current_post === $post_name || $term_exists) { |
296
|
|
|
// maybe init the shortcode |
297
|
|
|
$this->initialize_shortcode_if_active_on_page( |
298
|
|
|
$shortcode_class, |
299
|
|
|
$current_post, |
300
|
|
|
$page_for_posts, |
301
|
|
|
$post_id, |
302
|
|
|
$term_exists, |
303
|
|
|
$WP |
304
|
|
|
); |
305
|
|
|
// if this is NOT the "Posts page" and we have a valid entry |
306
|
|
|
// for the "Posts page" in our tracked post_shortcodes array |
307
|
|
|
// but the shortcode is not being tracked for this page |
308
|
|
|
} else if ( |
309
|
|
|
$post_name !== $page_for_posts |
310
|
|
|
&& isset($this->Registry->CFG->core->post_shortcodes[$page_for_posts]) |
311
|
|
|
&& ! isset($this->Registry->CFG->core->post_shortcodes[$page_for_posts][$shortcode_class]) |
312
|
|
|
) { |
313
|
|
|
// then remove the "fallback" shortcode processor |
314
|
|
|
remove_shortcode($shortcode_class); |
315
|
|
|
} |
316
|
|
|
} |
317
|
|
|
} |
318
|
|
|
} |
319
|
|
|
do_action('AHEE__EE_Front_Controller__initialize_shortcodes__end', $this); |
320
|
|
|
} |
321
|
|
|
|
322
|
|
|
|
323
|
|
|
/** |
324
|
|
|
* @param string $shortcode_class |
325
|
|
|
* @param string $current_post |
326
|
|
|
* @param string $page_for_posts |
327
|
|
|
* @param int $post_id |
328
|
|
|
* @param bool $term_exists |
329
|
|
|
* @param WP $WP |
330
|
|
|
*/ |
331
|
|
|
protected function initialize_shortcode_if_active_on_page( |
332
|
|
|
$shortcode_class, |
333
|
|
|
$current_post, |
334
|
|
|
$page_for_posts, |
335
|
|
|
$post_id, |
336
|
|
|
$term_exists, |
337
|
|
|
$WP |
338
|
|
|
) { |
339
|
|
|
// verify shortcode is in list of registered shortcodes |
340
|
|
|
if ( ! isset($this->Registry->shortcodes->{$shortcode_class})) { |
341
|
|
|
if ($current_post !== $page_for_posts && current_user_can('edit_post', $post_id)) { |
342
|
|
|
EE_Error::add_error( |
343
|
|
|
sprintf( |
344
|
|
|
__( |
345
|
|
|
'The [%s] shortcode has not been properly registered or the corresponding addon/module is not active for some reason. Either fix/remove the shortcode from the post, or activate the addon/module the shortcode is associated with.', |
346
|
|
|
'event_espresso' |
347
|
|
|
), |
348
|
|
|
$shortcode_class |
349
|
|
|
), |
350
|
|
|
__FILE__, |
351
|
|
|
__FUNCTION__, |
352
|
|
|
__LINE__ |
353
|
|
|
); |
354
|
|
|
add_filter('FHEE_run_EE_the_content', '__return_true'); |
355
|
|
|
} |
356
|
|
|
add_shortcode($shortcode_class, array('EES_Shortcode', 'invalid_shortcode_processor')); |
357
|
|
|
return; |
358
|
|
|
} |
359
|
|
|
// is this : a shortcodes set exclusively for this post, or for the home page, or a category, or a taxonomy ? |
360
|
|
|
if ( |
361
|
|
|
$term_exists |
362
|
|
|
|| $current_post === $page_for_posts |
363
|
|
|
|| isset($this->Registry->CFG->core->post_shortcodes[$current_post]) |
364
|
|
|
) { |
365
|
|
|
// let's pause to reflect on this... |
366
|
|
|
$sc_reflector = new ReflectionClass('EES_' . $shortcode_class); |
367
|
|
|
// ensure that class is actually a shortcode |
368
|
|
|
if ( |
369
|
|
|
defined('WP_DEBUG') |
370
|
|
|
&& WP_DEBUG === true |
371
|
|
|
&& ! $sc_reflector->isSubclassOf('EES_Shortcode') |
372
|
|
|
) { |
373
|
|
|
EE_Error::add_error( |
374
|
|
|
sprintf( |
375
|
|
|
__( |
376
|
|
|
'The requested %s shortcode is not of the class "EES_Shortcode". Please check your files.', |
377
|
|
|
'event_espresso' |
378
|
|
|
), |
379
|
|
|
$shortcode_class |
380
|
|
|
), |
381
|
|
|
__FILE__, |
382
|
|
|
__FUNCTION__, |
383
|
|
|
__LINE__ |
384
|
|
|
); |
385
|
|
|
add_filter('FHEE_run_EE_the_content', '__return_true'); |
386
|
|
|
return; |
387
|
|
|
} |
388
|
|
|
// and pass the request object to the run method |
389
|
|
|
$this->Registry->shortcodes->{$shortcode_class} = $sc_reflector->newInstance(); |
390
|
|
|
// fire the shortcode class's run method, so that it can activate resources |
391
|
|
|
$this->Registry->shortcodes->{$shortcode_class}->run($WP); |
392
|
|
|
} |
393
|
|
|
} |
394
|
|
|
|
395
|
|
|
|
396
|
|
|
/** |
397
|
|
|
* pre_get_posts - basically a module factory for instantiating modules and selecting the final view template |
398
|
|
|
* |
399
|
|
|
* @access public |
400
|
|
|
* @param WP_Query $WP_Query |
401
|
|
|
* @return void |
402
|
|
|
*/ |
403
|
|
|
public function pre_get_posts($WP_Query) |
404
|
|
|
{ |
405
|
|
|
// only load Module_Request_Router if this is the main query |
406
|
|
|
if ( |
407
|
|
|
$this->Module_Request_Router instanceof EE_Module_Request_Router |
408
|
|
|
&& $WP_Query->is_main_query() |
409
|
|
|
) { |
410
|
|
|
// cycle thru module routes |
411
|
|
|
while ($route = $this->Module_Request_Router->get_route($WP_Query)) { |
412
|
|
|
// determine module and method for route |
413
|
|
|
$module = $this->Module_Request_Router->resolve_route($route[0], $route[1]); |
414
|
|
|
if ($module instanceof EED_Module) { |
415
|
|
|
// get registered view for route |
416
|
|
|
$this->_template_path = $this->Module_Request_Router->get_view($route); |
417
|
|
|
// grab module name |
418
|
|
|
$module_name = $module->module_name(); |
419
|
|
|
// map the module to the module objects |
420
|
|
|
$this->Registry->modules->{$module_name} = $module; |
421
|
|
|
} |
422
|
|
|
} |
423
|
|
|
} |
424
|
|
|
} |
425
|
|
|
|
426
|
|
|
|
427
|
|
|
|
428
|
|
|
|
429
|
|
|
|
430
|
|
|
/*********************************************** WP HOOK ***********************************************/ |
431
|
|
|
|
432
|
|
|
|
433
|
|
|
/** |
434
|
|
|
* wp - basically last chance to do stuff before headers sent |
435
|
|
|
* |
436
|
|
|
* @access public |
437
|
|
|
* @return void |
438
|
|
|
*/ |
439
|
|
|
public function wp() |
440
|
|
|
{ |
441
|
|
|
} |
442
|
|
|
|
443
|
|
|
|
444
|
|
|
|
445
|
|
|
/*********************************************** WP_ENQUEUE_SCRIPTS && WP_HEAD HOOK ***********************************************/ |
446
|
|
|
|
447
|
|
|
|
448
|
|
|
/** |
449
|
|
|
* wp_enqueue_scripts |
450
|
|
|
* |
451
|
|
|
* @access public |
452
|
|
|
* @return void |
453
|
|
|
*/ |
454
|
|
|
public function wp_enqueue_scripts() |
455
|
|
|
{ |
456
|
|
|
|
457
|
|
|
// css is turned ON by default, but prior to the wp_enqueue_scripts hook, can be turned OFF via: add_filter( 'FHEE_load_css', '__return_false' ); |
458
|
|
|
if (apply_filters('FHEE_load_css', true)) { |
459
|
|
|
|
460
|
|
|
$this->Registry->CFG->template_settings->enable_default_style = true; |
461
|
|
|
//Load the ThemeRoller styles if enabled |
462
|
|
|
if (isset($this->Registry->CFG->template_settings->enable_default_style) && $this->Registry->CFG->template_settings->enable_default_style) { |
463
|
|
|
|
464
|
|
|
//Load custom style sheet if available |
465
|
|
|
if (isset($this->Registry->CFG->template_settings->custom_style_sheet)) { |
466
|
|
|
wp_register_style('espresso_custom_css', |
467
|
|
|
EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->Registry->CFG->template_settings->custom_style_sheet, |
468
|
|
|
EVENT_ESPRESSO_VERSION); |
469
|
|
|
wp_enqueue_style('espresso_custom_css'); |
470
|
|
|
} |
471
|
|
|
|
472
|
|
|
if (is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')) { |
473
|
|
|
wp_register_style('espresso_default', EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css', |
474
|
|
|
array('dashicons'), EVENT_ESPRESSO_VERSION); |
475
|
|
|
} else { |
476
|
|
|
wp_register_style('espresso_default', EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
477
|
|
|
array('dashicons'), EVENT_ESPRESSO_VERSION); |
478
|
|
|
} |
479
|
|
|
wp_enqueue_style('espresso_default'); |
480
|
|
|
|
481
|
|
View Code Duplication |
if (is_readable(get_stylesheet_directory() . EE_Config::get_current_theme() . DS . 'style.css')) { |
482
|
|
|
wp_register_style('espresso_style', |
483
|
|
|
get_stylesheet_directory_uri() . EE_Config::get_current_theme() . DS . 'style.css', |
484
|
|
|
array('dashicons', 'espresso_default')); |
485
|
|
|
} else { |
486
|
|
|
wp_register_style('espresso_style', |
487
|
|
|
EE_TEMPLATES_URL . EE_Config::get_current_theme() . DS . 'style.css', |
488
|
|
|
array('dashicons', 'espresso_default')); |
489
|
|
|
} |
490
|
|
|
|
491
|
|
|
} |
492
|
|
|
|
493
|
|
|
} |
494
|
|
|
|
495
|
|
|
// js is turned ON by default, but prior to the wp_enqueue_scripts hook, can be turned OFF via: add_filter( 'FHEE_load_js', '__return_false' ); |
496
|
|
|
if (apply_filters('FHEE_load_js', true)) { |
497
|
|
|
|
498
|
|
|
wp_enqueue_script('jquery'); |
499
|
|
|
//let's make sure that all required scripts have been setup |
500
|
|
|
if (function_exists('wp_script_is') && ! wp_script_is('jquery')) { |
501
|
|
|
$msg = sprintf( |
502
|
|
|
__('%sJquery is not loaded!%sEvent Espresso is unable to load Jquery due to a conflict with your theme or another plugin.', |
503
|
|
|
'event_espresso'), |
504
|
|
|
'<em><br />', |
505
|
|
|
'</em>' |
506
|
|
|
); |
507
|
|
|
EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
508
|
|
|
} |
509
|
|
|
// load core js |
510
|
|
|
wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), |
511
|
|
|
EVENT_ESPRESSO_VERSION, true); |
512
|
|
|
wp_enqueue_script('espresso_core'); |
513
|
|
|
wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings); |
514
|
|
|
|
515
|
|
|
} |
516
|
|
|
|
517
|
|
|
//qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
518
|
|
|
if (apply_filters('FHEE_load_qtip', false)) { |
519
|
|
|
EEH_Qtip_Loader::instance()->register_and_enqueue(); |
520
|
|
|
} |
521
|
|
|
|
522
|
|
|
|
523
|
|
|
//accounting.js library |
524
|
|
|
// @link http://josscrowcroft.github.io/accounting.js/ |
525
|
|
|
if (apply_filters('FHEE_load_accounting_js', false)) { |
526
|
|
|
$acct_js = EE_THIRD_PARTY_URL . 'accounting/accounting.js'; |
527
|
|
|
wp_register_script('ee-accounting', EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
528
|
|
|
array('ee-accounting-core'), EVENT_ESPRESSO_VERSION, true); |
529
|
|
|
wp_register_script('ee-accounting-core', $acct_js, array('underscore'), '0.3.2', true); |
530
|
|
|
wp_enqueue_script('ee-accounting'); |
531
|
|
|
|
532
|
|
|
$currency_config = array( |
533
|
|
|
'currency' => array( |
534
|
|
|
'symbol' => $this->Registry->CFG->currency->sign, |
535
|
|
|
'format' => array( |
536
|
|
|
'pos' => $this->Registry->CFG->currency->sign_b4 ? '%s%v' : '%v%s', |
537
|
|
|
'neg' => $this->Registry->CFG->currency->sign_b4 ? '- %s%v' : '- %v%s', |
538
|
|
|
'zero' => $this->Registry->CFG->currency->sign_b4 ? '%s--' : '--%s', |
539
|
|
|
), |
540
|
|
|
'decimal' => $this->Registry->CFG->currency->dec_mrk, |
541
|
|
|
'thousand' => $this->Registry->CFG->currency->thsnds, |
542
|
|
|
'precision' => $this->Registry->CFG->currency->dec_plc, |
543
|
|
|
), |
544
|
|
|
'number' => array( |
545
|
|
|
'precision' => 0, |
546
|
|
|
'thousand' => $this->Registry->CFG->currency->thsnds, |
547
|
|
|
'decimal' => $this->Registry->CFG->currency->dec_mrk, |
548
|
|
|
), |
549
|
|
|
); |
550
|
|
|
wp_localize_script('ee-accounting', 'EE_ACCOUNTING_CFG', $currency_config); |
551
|
|
|
} |
552
|
|
|
|
553
|
|
|
if ( ! function_exists('wp_head')) { |
554
|
|
|
$msg = sprintf( |
555
|
|
|
__('%sMissing wp_head() function.%sThe WordPress function wp_head() seems to be missing in your theme. Please contact the theme developer to make sure this is fixed before using Event Espresso.', |
556
|
|
|
'event_espresso'), |
557
|
|
|
'<em><br />', |
558
|
|
|
'</em>' |
559
|
|
|
); |
560
|
|
|
EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
561
|
|
|
} |
562
|
|
|
if ( ! function_exists('wp_footer')) { |
563
|
|
|
$msg = sprintf( |
564
|
|
|
__('%sMissing wp_footer() function.%sThe WordPress function wp_footer() seems to be missing in your theme. Please contact the theme developer to make sure this is fixed before using Event Espresso.', |
565
|
|
|
'event_espresso'), |
566
|
|
|
'<em><br />', |
567
|
|
|
'</em>' |
568
|
|
|
); |
569
|
|
|
EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
570
|
|
|
} |
571
|
|
|
|
572
|
|
|
} |
573
|
|
|
|
574
|
|
|
|
575
|
|
|
/** |
576
|
|
|
* header_meta_tag |
577
|
|
|
* |
578
|
|
|
* @access public |
579
|
|
|
* @return void |
580
|
|
|
*/ |
581
|
|
|
public function header_meta_tag() |
582
|
|
|
{ |
583
|
|
|
print( |
584
|
|
|
apply_filters( |
585
|
|
|
'FHEE__EE_Front_Controller__header_meta_tag', |
586
|
|
|
'<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n") |
587
|
|
|
); |
588
|
|
|
|
589
|
|
|
//let's exclude all event type taxonomy term archive pages from search engine indexing |
590
|
|
|
//@see https://events.codebasehq.com/projects/event-espresso/tickets/10249 |
591
|
|
|
if ( |
592
|
|
|
is_tax('espresso_event_type') |
593
|
|
|
&& get_option( 'blog_public' ) !== '0' |
594
|
|
|
) { |
595
|
|
|
print( |
596
|
|
|
apply_filters( |
597
|
|
|
'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type', |
598
|
|
|
'<meta name="robots" content="noindex,follow" />' . "\n" |
599
|
|
|
) |
600
|
|
|
); |
601
|
|
|
} |
602
|
|
|
} |
603
|
|
|
|
604
|
|
|
|
605
|
|
|
|
606
|
|
|
|
607
|
|
|
/*********************************************** THE_CONTENT FILTER HOOK ***********************************************/ |
608
|
|
|
/** |
609
|
|
|
* the_content |
610
|
|
|
* |
611
|
|
|
* @access public |
612
|
|
|
* @param $the_content |
613
|
|
|
* @return string |
614
|
|
|
*/ |
615
|
|
|
// public function the_content( $the_content ) { |
616
|
|
|
// // nothing gets loaded at this point unless other systems turn this hookpoint on by using: add_filter( 'FHEE_run_EE_the_content', '__return_true' ); |
617
|
|
|
// if ( apply_filters( 'FHEE_run_EE_the_content', FALSE ) ) { |
618
|
|
|
// } |
619
|
|
|
// return $the_content; |
620
|
|
|
// } |
621
|
|
|
|
622
|
|
|
|
623
|
|
|
/*********************************************** WP_FOOTER ***********************************************/ |
624
|
|
|
|
625
|
|
|
|
626
|
|
|
/** |
627
|
|
|
* display_errors |
628
|
|
|
* |
629
|
|
|
* @access public |
630
|
|
|
* @return string |
631
|
|
|
*/ |
632
|
|
|
public function display_errors() |
633
|
|
|
{ |
634
|
|
|
static $shown_already = false; |
635
|
|
|
do_action('AHEE__EE_Front_Controller__display_errors__begin'); |
636
|
|
|
if ( |
637
|
|
|
! $shown_already |
638
|
|
|
&& apply_filters('FHEE__EE_Front_Controller__display_errors', true) |
639
|
|
|
&& is_main_query() |
640
|
|
|
&& ! is_feed() |
641
|
|
|
&& in_the_loop() |
642
|
|
|
&& $this->Request_Handler->is_espresso_page() |
643
|
|
|
) { |
644
|
|
|
echo EE_Error::get_notices(); |
645
|
|
|
$shown_already = true; |
646
|
|
|
EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php'); |
647
|
|
|
} |
648
|
|
|
do_action('AHEE__EE_Front_Controller__display_errors__end'); |
649
|
|
|
} |
650
|
|
|
|
651
|
|
|
|
652
|
|
|
|
653
|
|
|
|
654
|
|
|
|
655
|
|
|
/*********************************************** UTILITIES ***********************************************/ |
656
|
|
|
/** |
657
|
|
|
* template_include |
658
|
|
|
* |
659
|
|
|
* @access public |
660
|
|
|
* @param string $template_include_path |
661
|
|
|
* @return string |
662
|
|
|
*/ |
663
|
|
|
public function template_include($template_include_path = null) |
664
|
|
|
{ |
665
|
|
|
if ($this->Request_Handler->is_espresso_page()) { |
666
|
|
|
$this->_template_path = ! empty($this->_template_path) ? basename($this->_template_path) : basename($template_include_path); |
667
|
|
|
$template_path = EEH_Template::locate_template($this->_template_path, array(), false); |
668
|
|
|
$this->_template_path = ! empty($template_path) ? $template_path : $template_include_path; |
669
|
|
|
$this->_template = basename($this->_template_path); |
670
|
|
|
return $this->_template_path; |
671
|
|
|
} |
672
|
|
|
return $template_include_path; |
673
|
|
|
} |
674
|
|
|
|
675
|
|
|
|
676
|
|
|
/** |
677
|
|
|
* get_selected_template |
678
|
|
|
* |
679
|
|
|
* @access public |
680
|
|
|
* @param bool $with_path |
681
|
|
|
* @return string |
682
|
|
|
*/ |
683
|
|
|
public function get_selected_template($with_path = false) |
684
|
|
|
{ |
685
|
|
|
return $with_path ? $this->_template_path : $this->_template; |
686
|
|
|
} |
687
|
|
|
|
688
|
|
|
|
689
|
|
|
} |
690
|
|
|
// End of file EE_Front_Controller.core.php |
691
|
|
|
// Location: /core/EE_Front_Controller.core.php |
692
|
|
|
|