@@ -26,467 +26,467 @@ |
||
26 | 26 | final class EE_Front_Controller |
27 | 27 | { |
28 | 28 | |
29 | - /** |
|
30 | - * @var string $_template_path |
|
31 | - */ |
|
32 | - private $_template_path; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var string $_template |
|
36 | - */ |
|
37 | - private $_template; |
|
38 | - |
|
39 | - /** |
|
40 | - * @type EE_Registry $Registry |
|
41 | - */ |
|
42 | - protected $Registry; |
|
43 | - |
|
44 | - /** |
|
45 | - * @type EE_Request_Handler $Request_Handler |
|
46 | - */ |
|
47 | - protected $Request_Handler; |
|
48 | - |
|
49 | - /** |
|
50 | - * @type EE_Module_Request_Router $Module_Request_Router |
|
51 | - */ |
|
52 | - protected $Module_Request_Router; |
|
53 | - |
|
54 | - |
|
55 | - /** |
|
56 | - * class constructor |
|
57 | - * should fire after shortcode, module, addon, or other plugin's default priority init phases have run |
|
58 | - * |
|
59 | - * @access public |
|
60 | - * @param \EE_Registry $Registry |
|
61 | - * @param \EE_Request_Handler $Request_Handler |
|
62 | - * @param \EE_Module_Request_Router $Module_Request_Router |
|
63 | - */ |
|
64 | - public function __construct( |
|
65 | - EE_Registry $Registry, |
|
66 | - EE_Request_Handler $Request_Handler, |
|
67 | - EE_Module_Request_Router $Module_Request_Router |
|
68 | - ) { |
|
69 | - $this->Registry = $Registry; |
|
70 | - $this->Request_Handler = $Request_Handler; |
|
71 | - $this->Module_Request_Router = $Module_Request_Router; |
|
72 | - // load other resources and begin to actually run shortcodes and modules |
|
73 | - add_action('wp_loaded', array($this, 'wp_loaded'), 5); |
|
74 | - // analyse the incoming WP request |
|
75 | - add_action('parse_request', array($this, 'get_request'), 1, 1); |
|
76 | - // process request with module factory |
|
77 | - add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1); |
|
78 | - // before headers sent |
|
79 | - add_action('wp', array($this, 'wp'), 5); |
|
80 | - // primarily used to process any content shortcodes |
|
81 | - add_action('template_redirect', array($this, 'templateRedirect'), 999); |
|
82 | - // header |
|
83 | - add_action('wp_head', array($this, 'header_meta_tag'), 5); |
|
84 | - add_action('wp_print_scripts', array($this, 'wp_print_scripts'), 10); |
|
85 | - add_filter('template_include', array($this, 'template_include'), 1); |
|
86 | - // display errors |
|
87 | - add_action('loop_start', array($this, 'display_errors'), 2); |
|
88 | - // the content |
|
89 | - // add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 ); |
|
90 | - // exclude our private cpt comments |
|
91 | - add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1); |
|
92 | - // make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://) |
|
93 | - add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1); |
|
94 | - // action hook EE |
|
95 | - do_action('AHEE__EE_Front_Controller__construct__done', $this); |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * @return EE_Request_Handler |
|
101 | - */ |
|
102 | - public function Request_Handler() |
|
103 | - { |
|
104 | - return $this->Request_Handler; |
|
105 | - } |
|
106 | - |
|
107 | - |
|
108 | - /** |
|
109 | - * @return EE_Module_Request_Router |
|
110 | - */ |
|
111 | - public function Module_Request_Router() |
|
112 | - { |
|
113 | - return $this->Module_Request_Router; |
|
114 | - } |
|
115 | - |
|
116 | - |
|
117 | - /** |
|
118 | - * @return LegacyShortcodesManager |
|
119 | - */ |
|
120 | - public function getLegacyShortcodesManager() |
|
121 | - { |
|
122 | - return EE_Config::getLegacyShortcodesManager(); |
|
123 | - } |
|
124 | - |
|
125 | - |
|
126 | - |
|
127 | - |
|
128 | - |
|
129 | - /*********************************************** INIT ACTION HOOK ***********************************************/ |
|
130 | - /** |
|
131 | - * filter_wp_comments |
|
132 | - * This simply makes sure that any "private" EE CPTs do not have their comments show up in any wp comment |
|
133 | - * widgets/queries done on frontend |
|
134 | - * |
|
135 | - * @param array $clauses array of comment clauses setup by WP_Comment_Query |
|
136 | - * @return array array of comment clauses with modifications. |
|
137 | - * @throws InvalidArgumentException |
|
138 | - * @throws InvalidDataTypeException |
|
139 | - * @throws InvalidInterfaceException |
|
140 | - */ |
|
141 | - public function filter_wp_comments($clauses) |
|
142 | - { |
|
143 | - global $wpdb; |
|
144 | - if (strpos($clauses['join'], $wpdb->posts) !== false) { |
|
145 | - /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */ |
|
146 | - $custom_post_types = LoaderFactory::getLoader()->getShared( |
|
147 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
148 | - ); |
|
149 | - $cpts = $custom_post_types->getPrivateCustomPostTypes(); |
|
150 | - foreach ($cpts as $cpt => $details) { |
|
151 | - $clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt); |
|
152 | - } |
|
153 | - } |
|
154 | - return $clauses; |
|
155 | - } |
|
156 | - |
|
157 | - |
|
158 | - /** |
|
159 | - * this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend |
|
160 | - * |
|
161 | - * @param string $url incoming url |
|
162 | - * @return string final assembled url |
|
163 | - */ |
|
164 | - public function maybe_force_admin_ajax_ssl($url) |
|
165 | - { |
|
166 | - if (is_ssl() && preg_match('/admin-ajax.php/', $url)) { |
|
167 | - $url = str_replace('http://', 'https://', $url); |
|
168 | - } |
|
169 | - return $url; |
|
170 | - } |
|
171 | - |
|
172 | - |
|
173 | - |
|
174 | - |
|
175 | - |
|
176 | - |
|
177 | - /*********************************************** WP_LOADED ACTION HOOK ***********************************************/ |
|
178 | - |
|
179 | - |
|
180 | - /** |
|
181 | - * wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their |
|
182 | - * default priority init phases have run |
|
183 | - * |
|
184 | - * @access public |
|
185 | - * @return void |
|
186 | - */ |
|
187 | - public function wp_loaded() |
|
188 | - { |
|
189 | - } |
|
190 | - |
|
191 | - |
|
192 | - |
|
193 | - |
|
194 | - |
|
195 | - /*********************************************** PARSE_REQUEST HOOK ***********************************************/ |
|
196 | - /** |
|
197 | - * _get_request |
|
198 | - * |
|
199 | - * @access public |
|
200 | - * @param WP $WP |
|
201 | - * @return void |
|
202 | - */ |
|
203 | - public function get_request(WP $WP) |
|
204 | - { |
|
205 | - do_action('AHEE__EE_Front_Controller__get_request__start'); |
|
206 | - $this->Request_Handler->parse_request($WP); |
|
207 | - do_action('AHEE__EE_Front_Controller__get_request__complete'); |
|
208 | - } |
|
209 | - |
|
210 | - |
|
211 | - /** |
|
212 | - * pre_get_posts - basically a module factory for instantiating modules and selecting the final view template |
|
213 | - * |
|
214 | - * @access public |
|
215 | - * @param WP_Query $WP_Query |
|
216 | - * @return void |
|
217 | - */ |
|
218 | - public function pre_get_posts($WP_Query) |
|
219 | - { |
|
220 | - // only load Module_Request_Router if this is the main query |
|
221 | - if ($this->Module_Request_Router instanceof EE_Module_Request_Router |
|
222 | - && $WP_Query->is_main_query() |
|
223 | - ) { |
|
224 | - // cycle thru module routes |
|
225 | - while ($route = $this->Module_Request_Router->get_route($WP_Query)) { |
|
226 | - // determine module and method for route |
|
227 | - $module = $this->Module_Request_Router->resolve_route($route[0], $route[1]); |
|
228 | - if ($module instanceof EED_Module) { |
|
229 | - // get registered view for route |
|
230 | - $this->_template_path = $this->Module_Request_Router->get_view($route); |
|
231 | - // grab module name |
|
232 | - $module_name = $module->module_name(); |
|
233 | - // map the module to the module objects |
|
234 | - $this->Registry->modules->{$module_name} = $module; |
|
235 | - } |
|
236 | - } |
|
237 | - } |
|
238 | - } |
|
239 | - |
|
240 | - |
|
241 | - |
|
242 | - |
|
243 | - |
|
244 | - /*********************************************** WP HOOK ***********************************************/ |
|
245 | - |
|
246 | - |
|
247 | - /** |
|
248 | - * wp - basically last chance to do stuff before headers sent |
|
249 | - * |
|
250 | - * @access public |
|
251 | - * @return void |
|
252 | - */ |
|
253 | - public function wp() |
|
254 | - { |
|
255 | - } |
|
256 | - |
|
257 | - |
|
258 | - |
|
259 | - /*********************** GET_HEADER && WP_HEAD HOOK ***********************/ |
|
260 | - |
|
261 | - |
|
262 | - /** |
|
263 | - * callback for the "template_redirect" hook point |
|
264 | - * checks sidebars for EE widgets |
|
265 | - * loads resources and assets accordingly |
|
266 | - * |
|
267 | - * @return void |
|
268 | - */ |
|
269 | - public function templateRedirect() |
|
270 | - { |
|
271 | - global $wp_query; |
|
272 | - if (empty($wp_query->posts)) { |
|
273 | - return; |
|
274 | - } |
|
275 | - // if we already know this is an espresso page, then load assets |
|
276 | - $load_assets = $this->Request_Handler->is_espresso_page(); |
|
277 | - // if we are already loading assets then just move along, otherwise check for widgets |
|
278 | - $load_assets = $load_assets ? $load_assets : $this->espresso_widgets_in_active_sidebars(); |
|
279 | - if ($load_assets) { |
|
280 | - add_action('wp_enqueue_scripts', array($this, 'enqueueStyle'), 10); |
|
281 | - add_action('wp_print_footer_scripts', array($this, 'enqueueScripts'), 10); |
|
282 | - } |
|
283 | - } |
|
284 | - |
|
285 | - |
|
286 | - /** |
|
287 | - * builds list of active widgets then scans active sidebars looking for them |
|
288 | - * returns true is an EE widget is found in an active sidebar |
|
289 | - * Please Note: this does NOT mean that the sidebar or widget |
|
290 | - * is actually in use in a given template, as that is unfortunately not known |
|
291 | - * until a sidebar and it's widgets are actually loaded |
|
292 | - * |
|
293 | - * @return boolean |
|
294 | - */ |
|
295 | - private function espresso_widgets_in_active_sidebars() |
|
296 | - { |
|
297 | - $espresso_widgets = array(); |
|
298 | - foreach ($this->Registry->widgets as $widget_class => $widget) { |
|
299 | - $id_base = EspressoWidget::getIdBase($widget_class); |
|
300 | - if (is_active_widget(false, false, $id_base)) { |
|
301 | - $espresso_widgets[] = $id_base; |
|
302 | - } |
|
303 | - } |
|
304 | - $all_sidebar_widgets = wp_get_sidebars_widgets(); |
|
305 | - foreach ($all_sidebar_widgets as $sidebar_name => $sidebar_widgets) { |
|
306 | - if (is_array($sidebar_widgets) && ! empty($sidebar_widgets)) { |
|
307 | - foreach ($sidebar_widgets as $sidebar_widget) { |
|
308 | - foreach ($espresso_widgets as $espresso_widget) { |
|
309 | - if (strpos($sidebar_widget, $espresso_widget) !== false) { |
|
310 | - return true; |
|
311 | - } |
|
312 | - } |
|
313 | - } |
|
314 | - } |
|
315 | - } |
|
316 | - return false; |
|
317 | - } |
|
318 | - |
|
319 | - |
|
320 | - /** |
|
321 | - * header_meta_tag |
|
322 | - * |
|
323 | - * @access public |
|
324 | - * @return void |
|
325 | - */ |
|
326 | - public function header_meta_tag() |
|
327 | - { |
|
328 | - print( |
|
329 | - apply_filters( |
|
330 | - 'FHEE__EE_Front_Controller__header_meta_tag', |
|
331 | - '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n" |
|
332 | - ) |
|
333 | - ); |
|
334 | - |
|
335 | - // let's exclude all event type taxonomy term archive pages from search engine indexing |
|
336 | - // @see https://events.codebasehq.com/projects/event-espresso/tickets/10249 |
|
337 | - // also exclude all critical pages from indexing |
|
338 | - if (( |
|
339 | - is_tax('espresso_event_type') |
|
340 | - && get_option('blog_public') !== '0' |
|
341 | - ) |
|
342 | - || is_page(EE_Registry::instance()->CFG->core->get_critical_pages_array()) |
|
343 | - ) { |
|
344 | - print( |
|
345 | - apply_filters( |
|
346 | - 'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type', |
|
347 | - '<meta name="robots" content="noindex,follow" />' . "\n" |
|
348 | - ) |
|
349 | - ); |
|
350 | - } |
|
351 | - } |
|
352 | - |
|
353 | - |
|
354 | - /** |
|
355 | - * wp_print_scripts |
|
356 | - * |
|
357 | - * @return void |
|
358 | - */ |
|
359 | - public function wp_print_scripts() |
|
360 | - { |
|
361 | - global $post; |
|
362 | - if (isset($post->EE_Event) |
|
363 | - && $post->EE_Event instanceof EE_Event |
|
364 | - && get_post_type() === 'espresso_events' |
|
365 | - && is_singular() |
|
366 | - ) { |
|
367 | - \EEH_Schema::add_json_linked_data_for_event($post->EE_Event); |
|
368 | - } |
|
369 | - } |
|
370 | - |
|
371 | - |
|
372 | - public function enqueueStyle() |
|
373 | - { |
|
374 | - wp_enqueue_style('espresso_default'); |
|
375 | - wp_enqueue_style('espresso_custom_css'); |
|
376 | - } |
|
377 | - |
|
378 | - |
|
379 | - |
|
380 | - /*********************************************** WP_FOOTER ***********************************************/ |
|
381 | - |
|
382 | - |
|
383 | - public function enqueueScripts() |
|
384 | - { |
|
385 | - wp_enqueue_script('espresso_core'); |
|
386 | - } |
|
387 | - |
|
388 | - |
|
389 | - /** |
|
390 | - * display_errors |
|
391 | - * |
|
392 | - * @access public |
|
393 | - * @return void |
|
394 | - * @throws DomainException |
|
395 | - */ |
|
396 | - public function display_errors() |
|
397 | - { |
|
398 | - static $shown_already = false; |
|
399 | - do_action('AHEE__EE_Front_Controller__display_errors__begin'); |
|
400 | - if (! $shown_already |
|
401 | - && apply_filters('FHEE__EE_Front_Controller__display_errors', true) |
|
402 | - && is_main_query() |
|
403 | - && ! is_feed() |
|
404 | - && in_the_loop() |
|
405 | - && did_action('wp_head') |
|
406 | - && $this->Request_Handler->is_espresso_page() |
|
407 | - ) { |
|
408 | - echo EE_Error::get_notices(); |
|
409 | - $shown_already = true; |
|
410 | - EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php'); |
|
411 | - } |
|
412 | - do_action('AHEE__EE_Front_Controller__display_errors__end'); |
|
413 | - } |
|
414 | - |
|
415 | - |
|
416 | - |
|
417 | - |
|
418 | - |
|
419 | - /*********************************************** UTILITIES ***********************************************/ |
|
420 | - /** |
|
421 | - * template_include |
|
422 | - * |
|
423 | - * @access public |
|
424 | - * @param string $template_include_path |
|
425 | - * @return string |
|
426 | - */ |
|
427 | - public function template_include($template_include_path = null) |
|
428 | - { |
|
429 | - if ($this->Request_Handler->is_espresso_page()) { |
|
430 | - $this->_template_path = ! empty($this->_template_path) |
|
431 | - ? basename($this->_template_path) |
|
432 | - : basename( |
|
433 | - $template_include_path |
|
434 | - ); |
|
435 | - $template_path = EEH_Template::locate_template($this->_template_path, array(), false); |
|
436 | - $this->_template_path = ! empty($template_path) ? $template_path : $template_include_path; |
|
437 | - $this->_template = basename($this->_template_path); |
|
438 | - return $this->_template_path; |
|
439 | - } |
|
440 | - return $template_include_path; |
|
441 | - } |
|
442 | - |
|
443 | - |
|
444 | - /** |
|
445 | - * get_selected_template |
|
446 | - * |
|
447 | - * @access public |
|
448 | - * @param bool $with_path |
|
449 | - * @return string |
|
450 | - */ |
|
451 | - public function get_selected_template($with_path = false) |
|
452 | - { |
|
453 | - return $with_path ? $this->_template_path : $this->_template; |
|
454 | - } |
|
455 | - |
|
456 | - |
|
457 | - /** |
|
458 | - * @deprecated 4.9.26 |
|
459 | - * @param string $shortcode_class |
|
460 | - * @param \WP $wp |
|
461 | - */ |
|
462 | - public function initialize_shortcode($shortcode_class = '', WP $wp = null) |
|
463 | - { |
|
464 | - \EE_Error::doing_it_wrong( |
|
465 | - __METHOD__, |
|
466 | - __( |
|
467 | - 'Usage is deprecated. Please use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::initializeShortcode() instead.', |
|
468 | - 'event_espresso' |
|
469 | - ), |
|
470 | - '4.9.26' |
|
471 | - ); |
|
472 | - $this->getLegacyShortcodesManager()->initializeShortcode($shortcode_class, $wp); |
|
473 | - } |
|
474 | - |
|
475 | - |
|
476 | - /** |
|
477 | - * @return void |
|
478 | - * @deprecated 4.9.57.p |
|
479 | - */ |
|
480 | - public function loadPersistentAdminNoticeManager() |
|
481 | - { |
|
482 | - } |
|
483 | - |
|
484 | - |
|
485 | - /** |
|
486 | - * @return void |
|
487 | - * @deprecated 4.9.64.p |
|
488 | - */ |
|
489 | - public function employ_CPT_Strategy() |
|
490 | - { |
|
491 | - } |
|
29 | + /** |
|
30 | + * @var string $_template_path |
|
31 | + */ |
|
32 | + private $_template_path; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var string $_template |
|
36 | + */ |
|
37 | + private $_template; |
|
38 | + |
|
39 | + /** |
|
40 | + * @type EE_Registry $Registry |
|
41 | + */ |
|
42 | + protected $Registry; |
|
43 | + |
|
44 | + /** |
|
45 | + * @type EE_Request_Handler $Request_Handler |
|
46 | + */ |
|
47 | + protected $Request_Handler; |
|
48 | + |
|
49 | + /** |
|
50 | + * @type EE_Module_Request_Router $Module_Request_Router |
|
51 | + */ |
|
52 | + protected $Module_Request_Router; |
|
53 | + |
|
54 | + |
|
55 | + /** |
|
56 | + * class constructor |
|
57 | + * should fire after shortcode, module, addon, or other plugin's default priority init phases have run |
|
58 | + * |
|
59 | + * @access public |
|
60 | + * @param \EE_Registry $Registry |
|
61 | + * @param \EE_Request_Handler $Request_Handler |
|
62 | + * @param \EE_Module_Request_Router $Module_Request_Router |
|
63 | + */ |
|
64 | + public function __construct( |
|
65 | + EE_Registry $Registry, |
|
66 | + EE_Request_Handler $Request_Handler, |
|
67 | + EE_Module_Request_Router $Module_Request_Router |
|
68 | + ) { |
|
69 | + $this->Registry = $Registry; |
|
70 | + $this->Request_Handler = $Request_Handler; |
|
71 | + $this->Module_Request_Router = $Module_Request_Router; |
|
72 | + // load other resources and begin to actually run shortcodes and modules |
|
73 | + add_action('wp_loaded', array($this, 'wp_loaded'), 5); |
|
74 | + // analyse the incoming WP request |
|
75 | + add_action('parse_request', array($this, 'get_request'), 1, 1); |
|
76 | + // process request with module factory |
|
77 | + add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1); |
|
78 | + // before headers sent |
|
79 | + add_action('wp', array($this, 'wp'), 5); |
|
80 | + // primarily used to process any content shortcodes |
|
81 | + add_action('template_redirect', array($this, 'templateRedirect'), 999); |
|
82 | + // header |
|
83 | + add_action('wp_head', array($this, 'header_meta_tag'), 5); |
|
84 | + add_action('wp_print_scripts', array($this, 'wp_print_scripts'), 10); |
|
85 | + add_filter('template_include', array($this, 'template_include'), 1); |
|
86 | + // display errors |
|
87 | + add_action('loop_start', array($this, 'display_errors'), 2); |
|
88 | + // the content |
|
89 | + // add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 ); |
|
90 | + // exclude our private cpt comments |
|
91 | + add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1); |
|
92 | + // make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://) |
|
93 | + add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1); |
|
94 | + // action hook EE |
|
95 | + do_action('AHEE__EE_Front_Controller__construct__done', $this); |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * @return EE_Request_Handler |
|
101 | + */ |
|
102 | + public function Request_Handler() |
|
103 | + { |
|
104 | + return $this->Request_Handler; |
|
105 | + } |
|
106 | + |
|
107 | + |
|
108 | + /** |
|
109 | + * @return EE_Module_Request_Router |
|
110 | + */ |
|
111 | + public function Module_Request_Router() |
|
112 | + { |
|
113 | + return $this->Module_Request_Router; |
|
114 | + } |
|
115 | + |
|
116 | + |
|
117 | + /** |
|
118 | + * @return LegacyShortcodesManager |
|
119 | + */ |
|
120 | + public function getLegacyShortcodesManager() |
|
121 | + { |
|
122 | + return EE_Config::getLegacyShortcodesManager(); |
|
123 | + } |
|
124 | + |
|
125 | + |
|
126 | + |
|
127 | + |
|
128 | + |
|
129 | + /*********************************************** INIT ACTION HOOK ***********************************************/ |
|
130 | + /** |
|
131 | + * filter_wp_comments |
|
132 | + * This simply makes sure that any "private" EE CPTs do not have their comments show up in any wp comment |
|
133 | + * widgets/queries done on frontend |
|
134 | + * |
|
135 | + * @param array $clauses array of comment clauses setup by WP_Comment_Query |
|
136 | + * @return array array of comment clauses with modifications. |
|
137 | + * @throws InvalidArgumentException |
|
138 | + * @throws InvalidDataTypeException |
|
139 | + * @throws InvalidInterfaceException |
|
140 | + */ |
|
141 | + public function filter_wp_comments($clauses) |
|
142 | + { |
|
143 | + global $wpdb; |
|
144 | + if (strpos($clauses['join'], $wpdb->posts) !== false) { |
|
145 | + /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */ |
|
146 | + $custom_post_types = LoaderFactory::getLoader()->getShared( |
|
147 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
148 | + ); |
|
149 | + $cpts = $custom_post_types->getPrivateCustomPostTypes(); |
|
150 | + foreach ($cpts as $cpt => $details) { |
|
151 | + $clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt); |
|
152 | + } |
|
153 | + } |
|
154 | + return $clauses; |
|
155 | + } |
|
156 | + |
|
157 | + |
|
158 | + /** |
|
159 | + * this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend |
|
160 | + * |
|
161 | + * @param string $url incoming url |
|
162 | + * @return string final assembled url |
|
163 | + */ |
|
164 | + public function maybe_force_admin_ajax_ssl($url) |
|
165 | + { |
|
166 | + if (is_ssl() && preg_match('/admin-ajax.php/', $url)) { |
|
167 | + $url = str_replace('http://', 'https://', $url); |
|
168 | + } |
|
169 | + return $url; |
|
170 | + } |
|
171 | + |
|
172 | + |
|
173 | + |
|
174 | + |
|
175 | + |
|
176 | + |
|
177 | + /*********************************************** WP_LOADED ACTION HOOK ***********************************************/ |
|
178 | + |
|
179 | + |
|
180 | + /** |
|
181 | + * wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their |
|
182 | + * default priority init phases have run |
|
183 | + * |
|
184 | + * @access public |
|
185 | + * @return void |
|
186 | + */ |
|
187 | + public function wp_loaded() |
|
188 | + { |
|
189 | + } |
|
190 | + |
|
191 | + |
|
192 | + |
|
193 | + |
|
194 | + |
|
195 | + /*********************************************** PARSE_REQUEST HOOK ***********************************************/ |
|
196 | + /** |
|
197 | + * _get_request |
|
198 | + * |
|
199 | + * @access public |
|
200 | + * @param WP $WP |
|
201 | + * @return void |
|
202 | + */ |
|
203 | + public function get_request(WP $WP) |
|
204 | + { |
|
205 | + do_action('AHEE__EE_Front_Controller__get_request__start'); |
|
206 | + $this->Request_Handler->parse_request($WP); |
|
207 | + do_action('AHEE__EE_Front_Controller__get_request__complete'); |
|
208 | + } |
|
209 | + |
|
210 | + |
|
211 | + /** |
|
212 | + * pre_get_posts - basically a module factory for instantiating modules and selecting the final view template |
|
213 | + * |
|
214 | + * @access public |
|
215 | + * @param WP_Query $WP_Query |
|
216 | + * @return void |
|
217 | + */ |
|
218 | + public function pre_get_posts($WP_Query) |
|
219 | + { |
|
220 | + // only load Module_Request_Router if this is the main query |
|
221 | + if ($this->Module_Request_Router instanceof EE_Module_Request_Router |
|
222 | + && $WP_Query->is_main_query() |
|
223 | + ) { |
|
224 | + // cycle thru module routes |
|
225 | + while ($route = $this->Module_Request_Router->get_route($WP_Query)) { |
|
226 | + // determine module and method for route |
|
227 | + $module = $this->Module_Request_Router->resolve_route($route[0], $route[1]); |
|
228 | + if ($module instanceof EED_Module) { |
|
229 | + // get registered view for route |
|
230 | + $this->_template_path = $this->Module_Request_Router->get_view($route); |
|
231 | + // grab module name |
|
232 | + $module_name = $module->module_name(); |
|
233 | + // map the module to the module objects |
|
234 | + $this->Registry->modules->{$module_name} = $module; |
|
235 | + } |
|
236 | + } |
|
237 | + } |
|
238 | + } |
|
239 | + |
|
240 | + |
|
241 | + |
|
242 | + |
|
243 | + |
|
244 | + /*********************************************** WP HOOK ***********************************************/ |
|
245 | + |
|
246 | + |
|
247 | + /** |
|
248 | + * wp - basically last chance to do stuff before headers sent |
|
249 | + * |
|
250 | + * @access public |
|
251 | + * @return void |
|
252 | + */ |
|
253 | + public function wp() |
|
254 | + { |
|
255 | + } |
|
256 | + |
|
257 | + |
|
258 | + |
|
259 | + /*********************** GET_HEADER && WP_HEAD HOOK ***********************/ |
|
260 | + |
|
261 | + |
|
262 | + /** |
|
263 | + * callback for the "template_redirect" hook point |
|
264 | + * checks sidebars for EE widgets |
|
265 | + * loads resources and assets accordingly |
|
266 | + * |
|
267 | + * @return void |
|
268 | + */ |
|
269 | + public function templateRedirect() |
|
270 | + { |
|
271 | + global $wp_query; |
|
272 | + if (empty($wp_query->posts)) { |
|
273 | + return; |
|
274 | + } |
|
275 | + // if we already know this is an espresso page, then load assets |
|
276 | + $load_assets = $this->Request_Handler->is_espresso_page(); |
|
277 | + // if we are already loading assets then just move along, otherwise check for widgets |
|
278 | + $load_assets = $load_assets ? $load_assets : $this->espresso_widgets_in_active_sidebars(); |
|
279 | + if ($load_assets) { |
|
280 | + add_action('wp_enqueue_scripts', array($this, 'enqueueStyle'), 10); |
|
281 | + add_action('wp_print_footer_scripts', array($this, 'enqueueScripts'), 10); |
|
282 | + } |
|
283 | + } |
|
284 | + |
|
285 | + |
|
286 | + /** |
|
287 | + * builds list of active widgets then scans active sidebars looking for them |
|
288 | + * returns true is an EE widget is found in an active sidebar |
|
289 | + * Please Note: this does NOT mean that the sidebar or widget |
|
290 | + * is actually in use in a given template, as that is unfortunately not known |
|
291 | + * until a sidebar and it's widgets are actually loaded |
|
292 | + * |
|
293 | + * @return boolean |
|
294 | + */ |
|
295 | + private function espresso_widgets_in_active_sidebars() |
|
296 | + { |
|
297 | + $espresso_widgets = array(); |
|
298 | + foreach ($this->Registry->widgets as $widget_class => $widget) { |
|
299 | + $id_base = EspressoWidget::getIdBase($widget_class); |
|
300 | + if (is_active_widget(false, false, $id_base)) { |
|
301 | + $espresso_widgets[] = $id_base; |
|
302 | + } |
|
303 | + } |
|
304 | + $all_sidebar_widgets = wp_get_sidebars_widgets(); |
|
305 | + foreach ($all_sidebar_widgets as $sidebar_name => $sidebar_widgets) { |
|
306 | + if (is_array($sidebar_widgets) && ! empty($sidebar_widgets)) { |
|
307 | + foreach ($sidebar_widgets as $sidebar_widget) { |
|
308 | + foreach ($espresso_widgets as $espresso_widget) { |
|
309 | + if (strpos($sidebar_widget, $espresso_widget) !== false) { |
|
310 | + return true; |
|
311 | + } |
|
312 | + } |
|
313 | + } |
|
314 | + } |
|
315 | + } |
|
316 | + return false; |
|
317 | + } |
|
318 | + |
|
319 | + |
|
320 | + /** |
|
321 | + * header_meta_tag |
|
322 | + * |
|
323 | + * @access public |
|
324 | + * @return void |
|
325 | + */ |
|
326 | + public function header_meta_tag() |
|
327 | + { |
|
328 | + print( |
|
329 | + apply_filters( |
|
330 | + 'FHEE__EE_Front_Controller__header_meta_tag', |
|
331 | + '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n" |
|
332 | + ) |
|
333 | + ); |
|
334 | + |
|
335 | + // let's exclude all event type taxonomy term archive pages from search engine indexing |
|
336 | + // @see https://events.codebasehq.com/projects/event-espresso/tickets/10249 |
|
337 | + // also exclude all critical pages from indexing |
|
338 | + if (( |
|
339 | + is_tax('espresso_event_type') |
|
340 | + && get_option('blog_public') !== '0' |
|
341 | + ) |
|
342 | + || is_page(EE_Registry::instance()->CFG->core->get_critical_pages_array()) |
|
343 | + ) { |
|
344 | + print( |
|
345 | + apply_filters( |
|
346 | + 'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type', |
|
347 | + '<meta name="robots" content="noindex,follow" />' . "\n" |
|
348 | + ) |
|
349 | + ); |
|
350 | + } |
|
351 | + } |
|
352 | + |
|
353 | + |
|
354 | + /** |
|
355 | + * wp_print_scripts |
|
356 | + * |
|
357 | + * @return void |
|
358 | + */ |
|
359 | + public function wp_print_scripts() |
|
360 | + { |
|
361 | + global $post; |
|
362 | + if (isset($post->EE_Event) |
|
363 | + && $post->EE_Event instanceof EE_Event |
|
364 | + && get_post_type() === 'espresso_events' |
|
365 | + && is_singular() |
|
366 | + ) { |
|
367 | + \EEH_Schema::add_json_linked_data_for_event($post->EE_Event); |
|
368 | + } |
|
369 | + } |
|
370 | + |
|
371 | + |
|
372 | + public function enqueueStyle() |
|
373 | + { |
|
374 | + wp_enqueue_style('espresso_default'); |
|
375 | + wp_enqueue_style('espresso_custom_css'); |
|
376 | + } |
|
377 | + |
|
378 | + |
|
379 | + |
|
380 | + /*********************************************** WP_FOOTER ***********************************************/ |
|
381 | + |
|
382 | + |
|
383 | + public function enqueueScripts() |
|
384 | + { |
|
385 | + wp_enqueue_script('espresso_core'); |
|
386 | + } |
|
387 | + |
|
388 | + |
|
389 | + /** |
|
390 | + * display_errors |
|
391 | + * |
|
392 | + * @access public |
|
393 | + * @return void |
|
394 | + * @throws DomainException |
|
395 | + */ |
|
396 | + public function display_errors() |
|
397 | + { |
|
398 | + static $shown_already = false; |
|
399 | + do_action('AHEE__EE_Front_Controller__display_errors__begin'); |
|
400 | + if (! $shown_already |
|
401 | + && apply_filters('FHEE__EE_Front_Controller__display_errors', true) |
|
402 | + && is_main_query() |
|
403 | + && ! is_feed() |
|
404 | + && in_the_loop() |
|
405 | + && did_action('wp_head') |
|
406 | + && $this->Request_Handler->is_espresso_page() |
|
407 | + ) { |
|
408 | + echo EE_Error::get_notices(); |
|
409 | + $shown_already = true; |
|
410 | + EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php'); |
|
411 | + } |
|
412 | + do_action('AHEE__EE_Front_Controller__display_errors__end'); |
|
413 | + } |
|
414 | + |
|
415 | + |
|
416 | + |
|
417 | + |
|
418 | + |
|
419 | + /*********************************************** UTILITIES ***********************************************/ |
|
420 | + /** |
|
421 | + * template_include |
|
422 | + * |
|
423 | + * @access public |
|
424 | + * @param string $template_include_path |
|
425 | + * @return string |
|
426 | + */ |
|
427 | + public function template_include($template_include_path = null) |
|
428 | + { |
|
429 | + if ($this->Request_Handler->is_espresso_page()) { |
|
430 | + $this->_template_path = ! empty($this->_template_path) |
|
431 | + ? basename($this->_template_path) |
|
432 | + : basename( |
|
433 | + $template_include_path |
|
434 | + ); |
|
435 | + $template_path = EEH_Template::locate_template($this->_template_path, array(), false); |
|
436 | + $this->_template_path = ! empty($template_path) ? $template_path : $template_include_path; |
|
437 | + $this->_template = basename($this->_template_path); |
|
438 | + return $this->_template_path; |
|
439 | + } |
|
440 | + return $template_include_path; |
|
441 | + } |
|
442 | + |
|
443 | + |
|
444 | + /** |
|
445 | + * get_selected_template |
|
446 | + * |
|
447 | + * @access public |
|
448 | + * @param bool $with_path |
|
449 | + * @return string |
|
450 | + */ |
|
451 | + public function get_selected_template($with_path = false) |
|
452 | + { |
|
453 | + return $with_path ? $this->_template_path : $this->_template; |
|
454 | + } |
|
455 | + |
|
456 | + |
|
457 | + /** |
|
458 | + * @deprecated 4.9.26 |
|
459 | + * @param string $shortcode_class |
|
460 | + * @param \WP $wp |
|
461 | + */ |
|
462 | + public function initialize_shortcode($shortcode_class = '', WP $wp = null) |
|
463 | + { |
|
464 | + \EE_Error::doing_it_wrong( |
|
465 | + __METHOD__, |
|
466 | + __( |
|
467 | + 'Usage is deprecated. Please use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::initializeShortcode() instead.', |
|
468 | + 'event_espresso' |
|
469 | + ), |
|
470 | + '4.9.26' |
|
471 | + ); |
|
472 | + $this->getLegacyShortcodesManager()->initializeShortcode($shortcode_class, $wp); |
|
473 | + } |
|
474 | + |
|
475 | + |
|
476 | + /** |
|
477 | + * @return void |
|
478 | + * @deprecated 4.9.57.p |
|
479 | + */ |
|
480 | + public function loadPersistentAdminNoticeManager() |
|
481 | + { |
|
482 | + } |
|
483 | + |
|
484 | + |
|
485 | + /** |
|
486 | + * @return void |
|
487 | + * @deprecated 4.9.64.p |
|
488 | + */ |
|
489 | + public function employ_CPT_Strategy() |
|
490 | + { |
|
491 | + } |
|
492 | 492 | } |
@@ -38,103 +38,103 @@ |
||
38 | 38 | * @since 4.0 |
39 | 39 | */ |
40 | 40 | if (function_exists('espresso_version')) { |
41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | - /** |
|
43 | - * espresso_duplicate_plugin_error |
|
44 | - * displays if more than one version of EE is activated at the same time |
|
45 | - */ |
|
46 | - function espresso_duplicate_plugin_error() |
|
47 | - { |
|
48 | - ?> |
|
41 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | + /** |
|
43 | + * espresso_duplicate_plugin_error |
|
44 | + * displays if more than one version of EE is activated at the same time |
|
45 | + */ |
|
46 | + function espresso_duplicate_plugin_error() |
|
47 | + { |
|
48 | + ?> |
|
49 | 49 | <div class="error"> |
50 | 50 | <p> |
51 | 51 | <?php |
52 | - echo esc_html__( |
|
53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | - 'event_espresso' |
|
55 | - ); ?> |
|
52 | + echo esc_html__( |
|
53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | + 'event_espresso' |
|
55 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
61 | - } |
|
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | + } |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | } else { |
64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
65 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | - /** |
|
67 | - * espresso_minimum_php_version_error |
|
68 | - * |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
65 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | + /** |
|
67 | + * espresso_minimum_php_version_error |
|
68 | + * |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + function espresso_minimum_php_version_error() |
|
72 | + { |
|
73 | + ?> |
|
74 | 74 | <div class="error"> |
75 | 75 | <p> |
76 | 76 | <?php |
77 | - printf( |
|
78 | - esc_html__( |
|
79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | - 'event_espresso' |
|
81 | - ), |
|
82 | - EE_MIN_PHP_VER_REQUIRED, |
|
83 | - PHP_VERSION, |
|
84 | - '<br/>', |
|
85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | - ); |
|
87 | - ?> |
|
77 | + printf( |
|
78 | + esc_html__( |
|
79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | + 'event_espresso' |
|
81 | + ), |
|
82 | + EE_MIN_PHP_VER_REQUIRED, |
|
83 | + PHP_VERSION, |
|
84 | + '<br/>', |
|
85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | + ); |
|
87 | + ?> |
|
88 | 88 | </p> |
89 | 89 | </div> |
90 | 90 | <?php |
91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | - } |
|
91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | + } |
|
93 | 93 | |
94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | - } else { |
|
96 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | - /** |
|
98 | - * espresso_version |
|
99 | - * Returns the plugin version |
|
100 | - * |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - function espresso_version() |
|
104 | - { |
|
105 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.65.rc.002'); |
|
106 | - } |
|
94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | + } else { |
|
96 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | + /** |
|
98 | + * espresso_version |
|
99 | + * Returns the plugin version |
|
100 | + * |
|
101 | + * @return string |
|
102 | + */ |
|
103 | + function espresso_version() |
|
104 | + { |
|
105 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.65.rc.002'); |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * espresso_plugin_activation |
|
110 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | - */ |
|
112 | - function espresso_plugin_activation() |
|
113 | - { |
|
114 | - update_option('ee_espresso_activation', true); |
|
115 | - } |
|
108 | + /** |
|
109 | + * espresso_plugin_activation |
|
110 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | + */ |
|
112 | + function espresso_plugin_activation() |
|
113 | + { |
|
114 | + update_option('ee_espresso_activation', true); |
|
115 | + } |
|
116 | 116 | |
117 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
117 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
118 | 118 | |
119 | - require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | - bootstrap_espresso(); |
|
121 | - } |
|
119 | + require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | + bootstrap_espresso(); |
|
121 | + } |
|
122 | 122 | } |
123 | 123 | if (! function_exists('espresso_deactivate_plugin')) { |
124 | - /** |
|
125 | - * deactivate_plugin |
|
126 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | - * |
|
128 | - * @access public |
|
129 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | - * @return void |
|
131 | - */ |
|
132 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | - { |
|
134 | - if (! function_exists('deactivate_plugins')) { |
|
135 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | - } |
|
137 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | - deactivate_plugins($plugin_basename); |
|
139 | - } |
|
124 | + /** |
|
125 | + * deactivate_plugin |
|
126 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | + * |
|
128 | + * @access public |
|
129 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | + * @return void |
|
131 | + */ |
|
132 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | + { |
|
134 | + if (! function_exists('deactivate_plugins')) { |
|
135 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | + } |
|
137 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | + deactivate_plugins($plugin_basename); |
|
139 | + } |
|
140 | 140 | } |