@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | use EventEspresso\widgets\EspressoWidget; |
5 | 5 | |
6 | 6 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
7 | - exit('No direct script access allowed'); |
|
7 | + exit('No direct script access allowed'); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | /** |
@@ -27,380 +27,380 @@ discard block |
||
27 | 27 | final class EE_Front_Controller |
28 | 28 | { |
29 | 29 | |
30 | - /** |
|
31 | - * @var string $_template_path |
|
32 | - */ |
|
33 | - private $_template_path; |
|
34 | - |
|
35 | - /** |
|
36 | - * @var string $_template |
|
37 | - */ |
|
38 | - private $_template; |
|
39 | - |
|
40 | - /** |
|
41 | - * @type EE_Registry $Registry |
|
42 | - */ |
|
43 | - protected $Registry; |
|
44 | - |
|
45 | - /** |
|
46 | - * @type EE_Request_Handler $Request_Handler |
|
47 | - */ |
|
48 | - protected $Request_Handler; |
|
49 | - |
|
50 | - /** |
|
51 | - * @type EE_Module_Request_Router $Module_Request_Router |
|
52 | - */ |
|
53 | - protected $Module_Request_Router; |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * class constructor |
|
58 | - * should fire after shortcode, module, addon, or other plugin's default priority init phases have run |
|
59 | - * |
|
60 | - * @access public |
|
61 | - * @param \EE_Registry $Registry |
|
62 | - * @param \EE_Request_Handler $Request_Handler |
|
63 | - * @param \EE_Module_Request_Router $Module_Request_Router |
|
64 | - */ |
|
65 | - public function __construct( |
|
66 | - EE_Registry $Registry, |
|
67 | - EE_Request_Handler $Request_Handler, |
|
68 | - EE_Module_Request_Router $Module_Request_Router |
|
69 | - ) { |
|
70 | - $this->Registry = $Registry; |
|
71 | - $this->Request_Handler = $Request_Handler; |
|
72 | - $this->Module_Request_Router = $Module_Request_Router; |
|
73 | - // determine how to integrate WP_Query with the EE models |
|
74 | - add_action('AHEE__EE_System__initialize', array($this, 'employ_CPT_Strategy')); |
|
75 | - // load other resources and begin to actually run shortcodes and modules |
|
76 | - add_action('wp_loaded', array($this, 'wp_loaded'), 5); |
|
77 | - // analyse the incoming WP request |
|
78 | - add_action('parse_request', array($this, 'get_request'), 1, 1); |
|
79 | - // process request with module factory |
|
80 | - add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1); |
|
81 | - // before headers sent |
|
82 | - add_action('wp', array($this, 'wp'), 5); |
|
83 | - // primarily used to process any content shortcodes |
|
84 | - add_action('template_redirect', array($this, 'templateRedirect'), 999); |
|
85 | - // header |
|
86 | - add_action('wp_head', array($this, 'header_meta_tag'), 5); |
|
87 | - add_action('wp_print_scripts', array($this, 'wp_print_scripts'), 10); |
|
88 | - add_filter('template_include', array($this, 'template_include'), 1); |
|
89 | - // display errors |
|
90 | - add_action('loop_start', array($this, 'display_errors'), 2); |
|
91 | - // the content |
|
92 | - // add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 ); |
|
93 | - //exclude our private cpt comments |
|
94 | - add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1); |
|
95 | - //make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://) |
|
96 | - add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1); |
|
97 | - // action hook EE |
|
98 | - do_action('AHEE__EE_Front_Controller__construct__done', $this); |
|
99 | - } |
|
100 | - |
|
101 | - |
|
102 | - /** |
|
103 | - * @return EE_Request_Handler |
|
104 | - */ |
|
105 | - public function Request_Handler() |
|
106 | - { |
|
107 | - return $this->Request_Handler; |
|
108 | - } |
|
109 | - |
|
110 | - |
|
111 | - /** |
|
112 | - * @return EE_Module_Request_Router |
|
113 | - */ |
|
114 | - public function Module_Request_Router() |
|
115 | - { |
|
116 | - return $this->Module_Request_Router; |
|
117 | - } |
|
118 | - |
|
119 | - |
|
120 | - |
|
121 | - /** |
|
122 | - * @return LegacyShortcodesManager |
|
123 | - */ |
|
124 | - public function getLegacyShortcodesManager() |
|
125 | - { |
|
126 | - return EE_Config::getLegacyShortcodesManager(); |
|
127 | - } |
|
128 | - |
|
129 | - |
|
130 | - |
|
131 | - |
|
132 | - |
|
133 | - /*********************************************** INIT ACTION HOOK ***********************************************/ |
|
134 | - |
|
135 | - |
|
136 | - |
|
137 | - /** |
|
138 | - * filter_wp_comments |
|
139 | - * This simply makes sure that any "private" EE CPTs do not have their comments show up in any wp comment |
|
140 | - * widgets/queries done on frontend |
|
141 | - * |
|
142 | - * @param array $clauses array of comment clauses setup by WP_Comment_Query |
|
143 | - * @return array array of comment clauses with modifications. |
|
144 | - */ |
|
145 | - public function filter_wp_comments($clauses) |
|
146 | - { |
|
147 | - global $wpdb; |
|
148 | - if (strpos($clauses['join'], $wpdb->posts) !== false) { |
|
149 | - $cpts = EE_Register_CPTs::get_private_CPTs(); |
|
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 | - * @return void |
|
160 | - * @throws EE_Error |
|
161 | - * @throws ReflectionException |
|
162 | - */ |
|
163 | - public function employ_CPT_Strategy() |
|
164 | - { |
|
165 | - if (apply_filters('FHEE__EE_Front_Controller__employ_CPT_Strategy', true)) { |
|
166 | - $this->Registry->load_core('CPT_Strategy'); |
|
167 | - } |
|
168 | - } |
|
169 | - |
|
170 | - |
|
171 | - /** |
|
172 | - * this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend |
|
173 | - * |
|
174 | - * @param string $url incoming url |
|
175 | - * @return string final assembled url |
|
176 | - */ |
|
177 | - public function maybe_force_admin_ajax_ssl($url) |
|
178 | - { |
|
179 | - if (is_ssl() && preg_match('/admin-ajax.php/', $url)) { |
|
180 | - $url = str_replace('http://', 'https://', $url); |
|
181 | - } |
|
182 | - return $url; |
|
183 | - } |
|
184 | - |
|
185 | - |
|
186 | - |
|
187 | - |
|
188 | - |
|
189 | - |
|
190 | - /*********************************************** WP_LOADED ACTION HOOK ***********************************************/ |
|
191 | - |
|
192 | - |
|
193 | - /** |
|
194 | - * wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their |
|
195 | - * default priority init phases have run |
|
196 | - * |
|
197 | - * @access public |
|
198 | - * @return void |
|
199 | - */ |
|
200 | - public function wp_loaded() |
|
201 | - { |
|
202 | - } |
|
203 | - |
|
204 | - |
|
205 | - |
|
206 | - |
|
207 | - |
|
208 | - /*********************************************** PARSE_REQUEST HOOK ***********************************************/ |
|
209 | - /** |
|
210 | - * _get_request |
|
211 | - * |
|
212 | - * @access public |
|
213 | - * @param WP $WP |
|
214 | - * @return void |
|
215 | - */ |
|
216 | - public function get_request(WP $WP) |
|
217 | - { |
|
218 | - do_action('AHEE__EE_Front_Controller__get_request__start'); |
|
219 | - $this->Request_Handler->parse_request($WP); |
|
220 | - do_action('AHEE__EE_Front_Controller__get_request__complete'); |
|
221 | - } |
|
222 | - |
|
223 | - |
|
224 | - |
|
225 | - /** |
|
226 | - * pre_get_posts - basically a module factory for instantiating modules and selecting the final view template |
|
227 | - * |
|
228 | - * @access public |
|
229 | - * @param WP_Query $WP_Query |
|
230 | - * @return void |
|
231 | - */ |
|
232 | - public function pre_get_posts($WP_Query) |
|
233 | - { |
|
234 | - // only load Module_Request_Router if this is the main query |
|
235 | - if ( |
|
236 | - $this->Module_Request_Router instanceof EE_Module_Request_Router |
|
237 | - && $WP_Query->is_main_query() |
|
238 | - ) { |
|
239 | - // cycle thru module routes |
|
240 | - while ($route = $this->Module_Request_Router->get_route($WP_Query)) { |
|
241 | - // determine module and method for route |
|
242 | - $module = $this->Module_Request_Router->resolve_route($route[0], $route[1]); |
|
243 | - if ($module instanceof EED_Module) { |
|
244 | - // get registered view for route |
|
245 | - $this->_template_path = $this->Module_Request_Router->get_view($route); |
|
246 | - // grab module name |
|
247 | - $module_name = $module->module_name(); |
|
248 | - // map the module to the module objects |
|
249 | - $this->Registry->modules->{$module_name} = $module; |
|
250 | - } |
|
251 | - } |
|
252 | - } |
|
253 | - } |
|
254 | - |
|
255 | - |
|
256 | - |
|
257 | - |
|
258 | - |
|
259 | - /*********************************************** WP HOOK ***********************************************/ |
|
260 | - |
|
261 | - |
|
262 | - /** |
|
263 | - * wp - basically last chance to do stuff before headers sent |
|
264 | - * |
|
265 | - * @access public |
|
266 | - * @return void |
|
267 | - */ |
|
268 | - public function wp() |
|
269 | - { |
|
270 | - } |
|
271 | - |
|
272 | - |
|
273 | - |
|
274 | - /*********************** GET_HEADER && WP_HEAD HOOK ***********************/ |
|
275 | - |
|
276 | - |
|
277 | - |
|
278 | - /** |
|
279 | - * callback for the "template_redirect" hook point |
|
280 | - * checks sidebars for EE widgets |
|
281 | - * loads resources and assets accordingly |
|
282 | - * |
|
283 | - * @return void |
|
284 | - */ |
|
285 | - public function templateRedirect() |
|
286 | - { |
|
287 | - global $wp_query; |
|
288 | - if (empty($wp_query->posts)){ |
|
289 | - return; |
|
290 | - } |
|
291 | - // if we already know this is an espresso page, then load assets |
|
292 | - $load_assets = $this->Request_Handler->is_espresso_page(); |
|
293 | - // if we are already loading assets then just move along, otherwise check for widgets |
|
294 | - $load_assets = $load_assets ? $load_assets : $this->espresso_widgets_in_active_sidebars(); |
|
295 | - if ( $load_assets){ |
|
296 | - add_action('wp_enqueue_scripts', array($this, 'enqueueStyle'), 10); |
|
297 | - add_action('wp_print_footer_scripts', array($this, 'enqueueScripts'), 10); |
|
298 | - } |
|
299 | - } |
|
300 | - |
|
301 | - |
|
302 | - |
|
303 | - /** |
|
304 | - * builds list of active widgets then scans active sidebars looking for them |
|
305 | - * returns true is an EE widget is found in an active sidebar |
|
306 | - * Please Note: this does NOT mean that the sidebar or widget |
|
307 | - * is actually in use in a given template, as that is unfortunately not known |
|
308 | - * until a sidebar and it's widgets are actually loaded |
|
309 | - * |
|
310 | - * @return boolean |
|
311 | - */ |
|
312 | - private function espresso_widgets_in_active_sidebars() |
|
313 | - { |
|
314 | - $espresso_widgets = array(); |
|
315 | - foreach ($this->Registry->widgets as $widget_class => $widget) { |
|
316 | - $id_base = EspressoWidget::getIdBase($widget_class); |
|
317 | - if (is_active_widget(false, false, $id_base)) { |
|
318 | - $espresso_widgets[] = $id_base; |
|
319 | - } |
|
320 | - } |
|
321 | - $all_sidebar_widgets = wp_get_sidebars_widgets(); |
|
322 | - foreach ($all_sidebar_widgets as $sidebar_name => $sidebar_widgets) { |
|
323 | - if (is_array($sidebar_widgets) && ! empty($sidebar_widgets)) { |
|
324 | - foreach ($sidebar_widgets as $sidebar_widget) { |
|
325 | - foreach ($espresso_widgets as $espresso_widget) { |
|
326 | - if (strpos($sidebar_widget, $espresso_widget) !== false) { |
|
327 | - return true; |
|
328 | - } |
|
329 | - } |
|
330 | - } |
|
331 | - } |
|
332 | - } |
|
333 | - return false; |
|
334 | - } |
|
335 | - |
|
336 | - |
|
337 | - |
|
338 | - |
|
339 | - /** |
|
340 | - * header_meta_tag |
|
341 | - * |
|
342 | - * @access public |
|
343 | - * @return void |
|
344 | - */ |
|
345 | - public function header_meta_tag() |
|
346 | - { |
|
347 | - print( |
|
348 | - apply_filters( |
|
349 | - 'FHEE__EE_Front_Controller__header_meta_tag', |
|
350 | - '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n") |
|
351 | - ); |
|
352 | - |
|
353 | - //let's exclude all event type taxonomy term archive pages from search engine indexing |
|
354 | - //@see https://events.codebasehq.com/projects/event-espresso/tickets/10249 |
|
355 | - //also exclude all critical pages from indexing |
|
356 | - if ( |
|
357 | - ( |
|
358 | - is_tax('espresso_event_type') |
|
359 | - && get_option( 'blog_public' ) !== '0' |
|
360 | - ) |
|
361 | - || is_page(EE_Registry::instance()->CFG->core->get_critical_pages_array()) |
|
362 | - ) { |
|
363 | - print( |
|
364 | - apply_filters( |
|
365 | - 'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type', |
|
366 | - '<meta name="robots" content="noindex,follow" />' . "\n" |
|
367 | - ) |
|
368 | - ); |
|
369 | - } |
|
370 | - } |
|
371 | - |
|
372 | - |
|
373 | - |
|
374 | - /** |
|
375 | - * wp_print_scripts |
|
376 | - * |
|
377 | - * @return void |
|
378 | - */ |
|
379 | - public function wp_print_scripts() |
|
380 | - { |
|
381 | - global $post; |
|
382 | - if ( |
|
383 | - isset($post->EE_Event) |
|
384 | - && $post->EE_Event instanceof EE_Event |
|
385 | - && get_post_type() === 'espresso_events' |
|
386 | - && is_singular() |
|
387 | - ) { |
|
388 | - \EEH_Schema::add_json_linked_data_for_event($post->EE_Event); |
|
389 | - } |
|
390 | - } |
|
391 | - |
|
392 | - |
|
393 | - |
|
394 | - public function enqueueStyle() |
|
395 | - { |
|
396 | - wp_enqueue_style('espresso_default'); |
|
397 | - wp_enqueue_style('espresso_custom_css'); |
|
398 | - } |
|
399 | - |
|
400 | - |
|
401 | - |
|
402 | - |
|
403 | - /*********************************************** THE_CONTENT FILTER HOOK ********************************************** |
|
30 | + /** |
|
31 | + * @var string $_template_path |
|
32 | + */ |
|
33 | + private $_template_path; |
|
34 | + |
|
35 | + /** |
|
36 | + * @var string $_template |
|
37 | + */ |
|
38 | + private $_template; |
|
39 | + |
|
40 | + /** |
|
41 | + * @type EE_Registry $Registry |
|
42 | + */ |
|
43 | + protected $Registry; |
|
44 | + |
|
45 | + /** |
|
46 | + * @type EE_Request_Handler $Request_Handler |
|
47 | + */ |
|
48 | + protected $Request_Handler; |
|
49 | + |
|
50 | + /** |
|
51 | + * @type EE_Module_Request_Router $Module_Request_Router |
|
52 | + */ |
|
53 | + protected $Module_Request_Router; |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * class constructor |
|
58 | + * should fire after shortcode, module, addon, or other plugin's default priority init phases have run |
|
59 | + * |
|
60 | + * @access public |
|
61 | + * @param \EE_Registry $Registry |
|
62 | + * @param \EE_Request_Handler $Request_Handler |
|
63 | + * @param \EE_Module_Request_Router $Module_Request_Router |
|
64 | + */ |
|
65 | + public function __construct( |
|
66 | + EE_Registry $Registry, |
|
67 | + EE_Request_Handler $Request_Handler, |
|
68 | + EE_Module_Request_Router $Module_Request_Router |
|
69 | + ) { |
|
70 | + $this->Registry = $Registry; |
|
71 | + $this->Request_Handler = $Request_Handler; |
|
72 | + $this->Module_Request_Router = $Module_Request_Router; |
|
73 | + // determine how to integrate WP_Query with the EE models |
|
74 | + add_action('AHEE__EE_System__initialize', array($this, 'employ_CPT_Strategy')); |
|
75 | + // load other resources and begin to actually run shortcodes and modules |
|
76 | + add_action('wp_loaded', array($this, 'wp_loaded'), 5); |
|
77 | + // analyse the incoming WP request |
|
78 | + add_action('parse_request', array($this, 'get_request'), 1, 1); |
|
79 | + // process request with module factory |
|
80 | + add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1); |
|
81 | + // before headers sent |
|
82 | + add_action('wp', array($this, 'wp'), 5); |
|
83 | + // primarily used to process any content shortcodes |
|
84 | + add_action('template_redirect', array($this, 'templateRedirect'), 999); |
|
85 | + // header |
|
86 | + add_action('wp_head', array($this, 'header_meta_tag'), 5); |
|
87 | + add_action('wp_print_scripts', array($this, 'wp_print_scripts'), 10); |
|
88 | + add_filter('template_include', array($this, 'template_include'), 1); |
|
89 | + // display errors |
|
90 | + add_action('loop_start', array($this, 'display_errors'), 2); |
|
91 | + // the content |
|
92 | + // add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 ); |
|
93 | + //exclude our private cpt comments |
|
94 | + add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1); |
|
95 | + //make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://) |
|
96 | + add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1); |
|
97 | + // action hook EE |
|
98 | + do_action('AHEE__EE_Front_Controller__construct__done', $this); |
|
99 | + } |
|
100 | + |
|
101 | + |
|
102 | + /** |
|
103 | + * @return EE_Request_Handler |
|
104 | + */ |
|
105 | + public function Request_Handler() |
|
106 | + { |
|
107 | + return $this->Request_Handler; |
|
108 | + } |
|
109 | + |
|
110 | + |
|
111 | + /** |
|
112 | + * @return EE_Module_Request_Router |
|
113 | + */ |
|
114 | + public function Module_Request_Router() |
|
115 | + { |
|
116 | + return $this->Module_Request_Router; |
|
117 | + } |
|
118 | + |
|
119 | + |
|
120 | + |
|
121 | + /** |
|
122 | + * @return LegacyShortcodesManager |
|
123 | + */ |
|
124 | + public function getLegacyShortcodesManager() |
|
125 | + { |
|
126 | + return EE_Config::getLegacyShortcodesManager(); |
|
127 | + } |
|
128 | + |
|
129 | + |
|
130 | + |
|
131 | + |
|
132 | + |
|
133 | + /*********************************************** INIT ACTION HOOK ***********************************************/ |
|
134 | + |
|
135 | + |
|
136 | + |
|
137 | + /** |
|
138 | + * filter_wp_comments |
|
139 | + * This simply makes sure that any "private" EE CPTs do not have their comments show up in any wp comment |
|
140 | + * widgets/queries done on frontend |
|
141 | + * |
|
142 | + * @param array $clauses array of comment clauses setup by WP_Comment_Query |
|
143 | + * @return array array of comment clauses with modifications. |
|
144 | + */ |
|
145 | + public function filter_wp_comments($clauses) |
|
146 | + { |
|
147 | + global $wpdb; |
|
148 | + if (strpos($clauses['join'], $wpdb->posts) !== false) { |
|
149 | + $cpts = EE_Register_CPTs::get_private_CPTs(); |
|
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 | + * @return void |
|
160 | + * @throws EE_Error |
|
161 | + * @throws ReflectionException |
|
162 | + */ |
|
163 | + public function employ_CPT_Strategy() |
|
164 | + { |
|
165 | + if (apply_filters('FHEE__EE_Front_Controller__employ_CPT_Strategy', true)) { |
|
166 | + $this->Registry->load_core('CPT_Strategy'); |
|
167 | + } |
|
168 | + } |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend |
|
173 | + * |
|
174 | + * @param string $url incoming url |
|
175 | + * @return string final assembled url |
|
176 | + */ |
|
177 | + public function maybe_force_admin_ajax_ssl($url) |
|
178 | + { |
|
179 | + if (is_ssl() && preg_match('/admin-ajax.php/', $url)) { |
|
180 | + $url = str_replace('http://', 'https://', $url); |
|
181 | + } |
|
182 | + return $url; |
|
183 | + } |
|
184 | + |
|
185 | + |
|
186 | + |
|
187 | + |
|
188 | + |
|
189 | + |
|
190 | + /*********************************************** WP_LOADED ACTION HOOK ***********************************************/ |
|
191 | + |
|
192 | + |
|
193 | + /** |
|
194 | + * wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their |
|
195 | + * default priority init phases have run |
|
196 | + * |
|
197 | + * @access public |
|
198 | + * @return void |
|
199 | + */ |
|
200 | + public function wp_loaded() |
|
201 | + { |
|
202 | + } |
|
203 | + |
|
204 | + |
|
205 | + |
|
206 | + |
|
207 | + |
|
208 | + /*********************************************** PARSE_REQUEST HOOK ***********************************************/ |
|
209 | + /** |
|
210 | + * _get_request |
|
211 | + * |
|
212 | + * @access public |
|
213 | + * @param WP $WP |
|
214 | + * @return void |
|
215 | + */ |
|
216 | + public function get_request(WP $WP) |
|
217 | + { |
|
218 | + do_action('AHEE__EE_Front_Controller__get_request__start'); |
|
219 | + $this->Request_Handler->parse_request($WP); |
|
220 | + do_action('AHEE__EE_Front_Controller__get_request__complete'); |
|
221 | + } |
|
222 | + |
|
223 | + |
|
224 | + |
|
225 | + /** |
|
226 | + * pre_get_posts - basically a module factory for instantiating modules and selecting the final view template |
|
227 | + * |
|
228 | + * @access public |
|
229 | + * @param WP_Query $WP_Query |
|
230 | + * @return void |
|
231 | + */ |
|
232 | + public function pre_get_posts($WP_Query) |
|
233 | + { |
|
234 | + // only load Module_Request_Router if this is the main query |
|
235 | + if ( |
|
236 | + $this->Module_Request_Router instanceof EE_Module_Request_Router |
|
237 | + && $WP_Query->is_main_query() |
|
238 | + ) { |
|
239 | + // cycle thru module routes |
|
240 | + while ($route = $this->Module_Request_Router->get_route($WP_Query)) { |
|
241 | + // determine module and method for route |
|
242 | + $module = $this->Module_Request_Router->resolve_route($route[0], $route[1]); |
|
243 | + if ($module instanceof EED_Module) { |
|
244 | + // get registered view for route |
|
245 | + $this->_template_path = $this->Module_Request_Router->get_view($route); |
|
246 | + // grab module name |
|
247 | + $module_name = $module->module_name(); |
|
248 | + // map the module to the module objects |
|
249 | + $this->Registry->modules->{$module_name} = $module; |
|
250 | + } |
|
251 | + } |
|
252 | + } |
|
253 | + } |
|
254 | + |
|
255 | + |
|
256 | + |
|
257 | + |
|
258 | + |
|
259 | + /*********************************************** WP HOOK ***********************************************/ |
|
260 | + |
|
261 | + |
|
262 | + /** |
|
263 | + * wp - basically last chance to do stuff before headers sent |
|
264 | + * |
|
265 | + * @access public |
|
266 | + * @return void |
|
267 | + */ |
|
268 | + public function wp() |
|
269 | + { |
|
270 | + } |
|
271 | + |
|
272 | + |
|
273 | + |
|
274 | + /*********************** GET_HEADER && WP_HEAD HOOK ***********************/ |
|
275 | + |
|
276 | + |
|
277 | + |
|
278 | + /** |
|
279 | + * callback for the "template_redirect" hook point |
|
280 | + * checks sidebars for EE widgets |
|
281 | + * loads resources and assets accordingly |
|
282 | + * |
|
283 | + * @return void |
|
284 | + */ |
|
285 | + public function templateRedirect() |
|
286 | + { |
|
287 | + global $wp_query; |
|
288 | + if (empty($wp_query->posts)){ |
|
289 | + return; |
|
290 | + } |
|
291 | + // if we already know this is an espresso page, then load assets |
|
292 | + $load_assets = $this->Request_Handler->is_espresso_page(); |
|
293 | + // if we are already loading assets then just move along, otherwise check for widgets |
|
294 | + $load_assets = $load_assets ? $load_assets : $this->espresso_widgets_in_active_sidebars(); |
|
295 | + if ( $load_assets){ |
|
296 | + add_action('wp_enqueue_scripts', array($this, 'enqueueStyle'), 10); |
|
297 | + add_action('wp_print_footer_scripts', array($this, 'enqueueScripts'), 10); |
|
298 | + } |
|
299 | + } |
|
300 | + |
|
301 | + |
|
302 | + |
|
303 | + /** |
|
304 | + * builds list of active widgets then scans active sidebars looking for them |
|
305 | + * returns true is an EE widget is found in an active sidebar |
|
306 | + * Please Note: this does NOT mean that the sidebar or widget |
|
307 | + * is actually in use in a given template, as that is unfortunately not known |
|
308 | + * until a sidebar and it's widgets are actually loaded |
|
309 | + * |
|
310 | + * @return boolean |
|
311 | + */ |
|
312 | + private function espresso_widgets_in_active_sidebars() |
|
313 | + { |
|
314 | + $espresso_widgets = array(); |
|
315 | + foreach ($this->Registry->widgets as $widget_class => $widget) { |
|
316 | + $id_base = EspressoWidget::getIdBase($widget_class); |
|
317 | + if (is_active_widget(false, false, $id_base)) { |
|
318 | + $espresso_widgets[] = $id_base; |
|
319 | + } |
|
320 | + } |
|
321 | + $all_sidebar_widgets = wp_get_sidebars_widgets(); |
|
322 | + foreach ($all_sidebar_widgets as $sidebar_name => $sidebar_widgets) { |
|
323 | + if (is_array($sidebar_widgets) && ! empty($sidebar_widgets)) { |
|
324 | + foreach ($sidebar_widgets as $sidebar_widget) { |
|
325 | + foreach ($espresso_widgets as $espresso_widget) { |
|
326 | + if (strpos($sidebar_widget, $espresso_widget) !== false) { |
|
327 | + return true; |
|
328 | + } |
|
329 | + } |
|
330 | + } |
|
331 | + } |
|
332 | + } |
|
333 | + return false; |
|
334 | + } |
|
335 | + |
|
336 | + |
|
337 | + |
|
338 | + |
|
339 | + /** |
|
340 | + * header_meta_tag |
|
341 | + * |
|
342 | + * @access public |
|
343 | + * @return void |
|
344 | + */ |
|
345 | + public function header_meta_tag() |
|
346 | + { |
|
347 | + print( |
|
348 | + apply_filters( |
|
349 | + 'FHEE__EE_Front_Controller__header_meta_tag', |
|
350 | + '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n") |
|
351 | + ); |
|
352 | + |
|
353 | + //let's exclude all event type taxonomy term archive pages from search engine indexing |
|
354 | + //@see https://events.codebasehq.com/projects/event-espresso/tickets/10249 |
|
355 | + //also exclude all critical pages from indexing |
|
356 | + if ( |
|
357 | + ( |
|
358 | + is_tax('espresso_event_type') |
|
359 | + && get_option( 'blog_public' ) !== '0' |
|
360 | + ) |
|
361 | + || is_page(EE_Registry::instance()->CFG->core->get_critical_pages_array()) |
|
362 | + ) { |
|
363 | + print( |
|
364 | + apply_filters( |
|
365 | + 'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type', |
|
366 | + '<meta name="robots" content="noindex,follow" />' . "\n" |
|
367 | + ) |
|
368 | + ); |
|
369 | + } |
|
370 | + } |
|
371 | + |
|
372 | + |
|
373 | + |
|
374 | + /** |
|
375 | + * wp_print_scripts |
|
376 | + * |
|
377 | + * @return void |
|
378 | + */ |
|
379 | + public function wp_print_scripts() |
|
380 | + { |
|
381 | + global $post; |
|
382 | + if ( |
|
383 | + isset($post->EE_Event) |
|
384 | + && $post->EE_Event instanceof EE_Event |
|
385 | + && get_post_type() === 'espresso_events' |
|
386 | + && is_singular() |
|
387 | + ) { |
|
388 | + \EEH_Schema::add_json_linked_data_for_event($post->EE_Event); |
|
389 | + } |
|
390 | + } |
|
391 | + |
|
392 | + |
|
393 | + |
|
394 | + public function enqueueStyle() |
|
395 | + { |
|
396 | + wp_enqueue_style('espresso_default'); |
|
397 | + wp_enqueue_style('espresso_custom_css'); |
|
398 | + } |
|
399 | + |
|
400 | + |
|
401 | + |
|
402 | + |
|
403 | + /*********************************************** THE_CONTENT FILTER HOOK ********************************************** |
|
404 | 404 | |
405 | 405 | |
406 | 406 | |
@@ -411,117 +411,117 @@ discard block |
||
411 | 411 | // * @param $the_content |
412 | 412 | // * @return string |
413 | 413 | // */ |
414 | - // public function the_content( $the_content ) { |
|
415 | - // // nothing gets loaded at this point unless other systems turn this hookpoint on by using: add_filter( 'FHEE_run_EE_the_content', '__return_true' ); |
|
416 | - // if ( apply_filters( 'FHEE_run_EE_the_content', FALSE ) ) { |
|
417 | - // } |
|
418 | - // return $the_content; |
|
419 | - // } |
|
420 | - |
|
421 | - |
|
422 | - |
|
423 | - /*********************************************** WP_FOOTER ***********************************************/ |
|
424 | - |
|
425 | - |
|
426 | - |
|
427 | - public function enqueueScripts() |
|
428 | - { |
|
429 | - wp_enqueue_script('espresso_core'); |
|
430 | - } |
|
431 | - |
|
432 | - |
|
433 | - |
|
434 | - /** |
|
435 | - * display_errors |
|
436 | - * |
|
437 | - * @access public |
|
438 | - * @return void |
|
439 | - * @throws DomainException |
|
440 | - */ |
|
441 | - public function display_errors() |
|
442 | - { |
|
443 | - static $shown_already = false; |
|
444 | - do_action('AHEE__EE_Front_Controller__display_errors__begin'); |
|
445 | - if ( |
|
446 | - ! $shown_already |
|
447 | - && apply_filters('FHEE__EE_Front_Controller__display_errors', true) |
|
448 | - && is_main_query() |
|
449 | - && ! is_feed() |
|
450 | - && in_the_loop() |
|
451 | - && $this->Request_Handler->is_espresso_page() |
|
452 | - ) { |
|
453 | - echo EE_Error::get_notices(); |
|
454 | - $shown_already = true; |
|
455 | - EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php'); |
|
456 | - } |
|
457 | - do_action('AHEE__EE_Front_Controller__display_errors__end'); |
|
458 | - } |
|
459 | - |
|
460 | - |
|
461 | - |
|
462 | - |
|
463 | - |
|
464 | - /*********************************************** UTILITIES ***********************************************/ |
|
465 | - /** |
|
466 | - * template_include |
|
467 | - * |
|
468 | - * @access public |
|
469 | - * @param string $template_include_path |
|
470 | - * @return string |
|
471 | - */ |
|
472 | - public function template_include($template_include_path = null) |
|
473 | - { |
|
474 | - if ($this->Request_Handler->is_espresso_page()) { |
|
475 | - $this->_template_path = ! empty($this->_template_path) ? basename($this->_template_path) : basename($template_include_path); |
|
476 | - $template_path = EEH_Template::locate_template($this->_template_path, array(), false); |
|
477 | - $this->_template_path = ! empty($template_path) ? $template_path : $template_include_path; |
|
478 | - $this->_template = basename($this->_template_path); |
|
479 | - return $this->_template_path; |
|
480 | - } |
|
481 | - return $template_include_path; |
|
482 | - } |
|
483 | - |
|
484 | - |
|
485 | - /** |
|
486 | - * get_selected_template |
|
487 | - * |
|
488 | - * @access public |
|
489 | - * @param bool $with_path |
|
490 | - * @return string |
|
491 | - */ |
|
492 | - public function get_selected_template($with_path = false) |
|
493 | - { |
|
494 | - return $with_path ? $this->_template_path : $this->_template; |
|
495 | - } |
|
496 | - |
|
497 | - |
|
498 | - |
|
499 | - /** |
|
500 | - * @deprecated 4.9.26 |
|
501 | - * @param string $shortcode_class |
|
502 | - * @param \WP $wp |
|
503 | - */ |
|
504 | - public function initialize_shortcode($shortcode_class = '', WP $wp = null) |
|
505 | - { |
|
506 | - \EE_Error::doing_it_wrong( |
|
507 | - __METHOD__, |
|
508 | - __( |
|
509 | - 'Usage is deprecated. Please use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::initializeShortcode() instead.', |
|
510 | - 'event_espresso' |
|
511 | - ), |
|
512 | - '4.9.26' |
|
513 | - ); |
|
514 | - $this->getLegacyShortcodesManager()->initializeShortcode($shortcode_class, $wp); |
|
515 | - } |
|
516 | - |
|
517 | - |
|
518 | - /** |
|
519 | - * @return void |
|
520 | - * @deprecated 4.9.57.p |
|
521 | - */ |
|
522 | - public function loadPersistentAdminNoticeManager() |
|
523 | - { |
|
524 | - } |
|
414 | + // public function the_content( $the_content ) { |
|
415 | + // // nothing gets loaded at this point unless other systems turn this hookpoint on by using: add_filter( 'FHEE_run_EE_the_content', '__return_true' ); |
|
416 | + // if ( apply_filters( 'FHEE_run_EE_the_content', FALSE ) ) { |
|
417 | + // } |
|
418 | + // return $the_content; |
|
419 | + // } |
|
420 | + |
|
421 | + |
|
422 | + |
|
423 | + /*********************************************** WP_FOOTER ***********************************************/ |
|
424 | + |
|
425 | + |
|
426 | + |
|
427 | + public function enqueueScripts() |
|
428 | + { |
|
429 | + wp_enqueue_script('espresso_core'); |
|
430 | + } |
|
431 | + |
|
432 | + |
|
433 | + |
|
434 | + /** |
|
435 | + * display_errors |
|
436 | + * |
|
437 | + * @access public |
|
438 | + * @return void |
|
439 | + * @throws DomainException |
|
440 | + */ |
|
441 | + public function display_errors() |
|
442 | + { |
|
443 | + static $shown_already = false; |
|
444 | + do_action('AHEE__EE_Front_Controller__display_errors__begin'); |
|
445 | + if ( |
|
446 | + ! $shown_already |
|
447 | + && apply_filters('FHEE__EE_Front_Controller__display_errors', true) |
|
448 | + && is_main_query() |
|
449 | + && ! is_feed() |
|
450 | + && in_the_loop() |
|
451 | + && $this->Request_Handler->is_espresso_page() |
|
452 | + ) { |
|
453 | + echo EE_Error::get_notices(); |
|
454 | + $shown_already = true; |
|
455 | + EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php'); |
|
456 | + } |
|
457 | + do_action('AHEE__EE_Front_Controller__display_errors__end'); |
|
458 | + } |
|
459 | + |
|
460 | + |
|
461 | + |
|
462 | + |
|
463 | + |
|
464 | + /*********************************************** UTILITIES ***********************************************/ |
|
465 | + /** |
|
466 | + * template_include |
|
467 | + * |
|
468 | + * @access public |
|
469 | + * @param string $template_include_path |
|
470 | + * @return string |
|
471 | + */ |
|
472 | + public function template_include($template_include_path = null) |
|
473 | + { |
|
474 | + if ($this->Request_Handler->is_espresso_page()) { |
|
475 | + $this->_template_path = ! empty($this->_template_path) ? basename($this->_template_path) : basename($template_include_path); |
|
476 | + $template_path = EEH_Template::locate_template($this->_template_path, array(), false); |
|
477 | + $this->_template_path = ! empty($template_path) ? $template_path : $template_include_path; |
|
478 | + $this->_template = basename($this->_template_path); |
|
479 | + return $this->_template_path; |
|
480 | + } |
|
481 | + return $template_include_path; |
|
482 | + } |
|
483 | + |
|
484 | + |
|
485 | + /** |
|
486 | + * get_selected_template |
|
487 | + * |
|
488 | + * @access public |
|
489 | + * @param bool $with_path |
|
490 | + * @return string |
|
491 | + */ |
|
492 | + public function get_selected_template($with_path = false) |
|
493 | + { |
|
494 | + return $with_path ? $this->_template_path : $this->_template; |
|
495 | + } |
|
496 | + |
|
497 | + |
|
498 | + |
|
499 | + /** |
|
500 | + * @deprecated 4.9.26 |
|
501 | + * @param string $shortcode_class |
|
502 | + * @param \WP $wp |
|
503 | + */ |
|
504 | + public function initialize_shortcode($shortcode_class = '', WP $wp = null) |
|
505 | + { |
|
506 | + \EE_Error::doing_it_wrong( |
|
507 | + __METHOD__, |
|
508 | + __( |
|
509 | + 'Usage is deprecated. Please use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::initializeShortcode() instead.', |
|
510 | + 'event_espresso' |
|
511 | + ), |
|
512 | + '4.9.26' |
|
513 | + ); |
|
514 | + $this->getLegacyShortcodesManager()->initializeShortcode($shortcode_class, $wp); |
|
515 | + } |
|
516 | + |
|
517 | + |
|
518 | + /** |
|
519 | + * @return void |
|
520 | + * @deprecated 4.9.57.p |
|
521 | + */ |
|
522 | + public function loadPersistentAdminNoticeManager() |
|
523 | + { |
|
524 | + } |
|
525 | 525 | } |
526 | 526 | // End of file EE_Front_Controller.core.php |
527 | 527 | // Location: /core/EE_Front_Controller.core.php |
@@ -38,216 +38,216 @@ |
||
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 | |
64 | 64 | } else { |
65 | - define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
66 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
67 | - /** |
|
68 | - * espresso_minimum_php_version_error |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
65 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
66 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
67 | + /** |
|
68 | + * espresso_minimum_php_version_error |
|
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.58.rc.000'); |
|
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.58.rc.000'); |
|
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'); |
|
118 | - /** |
|
119 | - * espresso_load_error_handling |
|
120 | - * this function loads EE's class for handling exceptions and errors |
|
121 | - */ |
|
122 | - function espresso_load_error_handling() |
|
123 | - { |
|
124 | - static $error_handling_loaded = false; |
|
125 | - if ($error_handling_loaded) { |
|
126 | - return; |
|
127 | - } |
|
128 | - // load debugging tools |
|
129 | - if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
130 | - require_once EE_HELPERS . 'EEH_Debug_Tools.helper.php'; |
|
131 | - \EEH_Debug_Tools::instance(); |
|
132 | - } |
|
133 | - // load error handling |
|
134 | - if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
135 | - require_once EE_CORE . 'EE_Error.core.php'; |
|
136 | - } else { |
|
137 | - wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
138 | - } |
|
139 | - $error_handling_loaded = true; |
|
140 | - } |
|
117 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
118 | + /** |
|
119 | + * espresso_load_error_handling |
|
120 | + * this function loads EE's class for handling exceptions and errors |
|
121 | + */ |
|
122 | + function espresso_load_error_handling() |
|
123 | + { |
|
124 | + static $error_handling_loaded = false; |
|
125 | + if ($error_handling_loaded) { |
|
126 | + return; |
|
127 | + } |
|
128 | + // load debugging tools |
|
129 | + if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
130 | + require_once EE_HELPERS . 'EEH_Debug_Tools.helper.php'; |
|
131 | + \EEH_Debug_Tools::instance(); |
|
132 | + } |
|
133 | + // load error handling |
|
134 | + if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
135 | + require_once EE_CORE . 'EE_Error.core.php'; |
|
136 | + } else { |
|
137 | + wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
138 | + } |
|
139 | + $error_handling_loaded = true; |
|
140 | + } |
|
141 | 141 | |
142 | - /** |
|
143 | - * espresso_load_required |
|
144 | - * given a class name and path, this function will load that file or throw an exception |
|
145 | - * |
|
146 | - * @param string $classname |
|
147 | - * @param string $full_path_to_file |
|
148 | - * @throws EE_Error |
|
149 | - */ |
|
150 | - function espresso_load_required($classname, $full_path_to_file) |
|
151 | - { |
|
152 | - if (is_readable($full_path_to_file)) { |
|
153 | - require_once $full_path_to_file; |
|
154 | - } else { |
|
155 | - throw new \EE_Error ( |
|
156 | - sprintf( |
|
157 | - esc_html__( |
|
158 | - 'The %s class file could not be located or is not readable due to file permissions.', |
|
159 | - 'event_espresso' |
|
160 | - ), |
|
161 | - $classname |
|
162 | - ) |
|
163 | - ); |
|
164 | - } |
|
165 | - } |
|
142 | + /** |
|
143 | + * espresso_load_required |
|
144 | + * given a class name and path, this function will load that file or throw an exception |
|
145 | + * |
|
146 | + * @param string $classname |
|
147 | + * @param string $full_path_to_file |
|
148 | + * @throws EE_Error |
|
149 | + */ |
|
150 | + function espresso_load_required($classname, $full_path_to_file) |
|
151 | + { |
|
152 | + if (is_readable($full_path_to_file)) { |
|
153 | + require_once $full_path_to_file; |
|
154 | + } else { |
|
155 | + throw new \EE_Error ( |
|
156 | + sprintf( |
|
157 | + esc_html__( |
|
158 | + 'The %s class file could not be located or is not readable due to file permissions.', |
|
159 | + 'event_espresso' |
|
160 | + ), |
|
161 | + $classname |
|
162 | + ) |
|
163 | + ); |
|
164 | + } |
|
165 | + } |
|
166 | 166 | |
167 | - /** |
|
168 | - * @since 4.9.27 |
|
169 | - * @throws \EE_Error |
|
170 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
171 | - * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
172 | - * @throws \EventEspresso\core\exceptions\InvalidIdentifierException |
|
173 | - * @throws \EventEspresso\core\exceptions\InvalidClassException |
|
174 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
175 | - * @throws \EventEspresso\core\services\container\exceptions\ServiceExistsException |
|
176 | - * @throws \EventEspresso\core\services\container\exceptions\ServiceNotFoundException |
|
177 | - * @throws \OutOfBoundsException |
|
178 | - */ |
|
179 | - function bootstrap_espresso() |
|
180 | - { |
|
181 | - require_once __DIR__ . '/core/espresso_definitions.php'; |
|
182 | - try { |
|
183 | - espresso_load_error_handling(); |
|
184 | - espresso_load_required( |
|
185 | - 'EEH_Base', |
|
186 | - EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php' |
|
187 | - ); |
|
188 | - espresso_load_required( |
|
189 | - 'EEH_File', |
|
190 | - EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php' |
|
191 | - ); |
|
192 | - espresso_load_required( |
|
193 | - 'EEH_File', |
|
194 | - EE_CORE . 'helpers' . DS . 'EEH_File.helper.php' |
|
195 | - ); |
|
196 | - espresso_load_required( |
|
197 | - 'EEH_Array', |
|
198 | - EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php' |
|
199 | - ); |
|
200 | - // instantiate and configure PSR4 autoloader |
|
201 | - espresso_load_required( |
|
202 | - 'Psr4Autoloader', |
|
203 | - EE_CORE . 'Psr4Autoloader.php' |
|
204 | - ); |
|
205 | - espresso_load_required( |
|
206 | - 'EE_Psr4AutoloaderInit', |
|
207 | - EE_CORE . 'EE_Psr4AutoloaderInit.core.php' |
|
208 | - ); |
|
209 | - $AutoloaderInit = new EE_Psr4AutoloaderInit(); |
|
210 | - $AutoloaderInit->initializeAutoloader(); |
|
211 | - espresso_load_required( |
|
212 | - 'EE_Request', |
|
213 | - EE_CORE . 'request_stack' . DS . 'EE_Request.core.php' |
|
214 | - ); |
|
215 | - espresso_load_required( |
|
216 | - 'EE_Response', |
|
217 | - EE_CORE . 'request_stack' . DS . 'EE_Response.core.php' |
|
218 | - ); |
|
219 | - espresso_load_required( |
|
220 | - 'EE_Bootstrap', |
|
221 | - EE_CORE . 'EE_Bootstrap.core.php' |
|
222 | - ); |
|
223 | - // bootstrap EE and the request stack |
|
224 | - new EE_Bootstrap( |
|
225 | - new EE_Request($_GET, $_POST, $_COOKIE), |
|
226 | - new EE_Response() |
|
227 | - ); |
|
228 | - } catch (Exception $e) { |
|
229 | - require_once EE_CORE . 'exceptions' . DS . 'ExceptionStackTraceDisplay.php'; |
|
230 | - new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e); |
|
231 | - } |
|
232 | - } |
|
233 | - bootstrap_espresso(); |
|
234 | - } |
|
167 | + /** |
|
168 | + * @since 4.9.27 |
|
169 | + * @throws \EE_Error |
|
170 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
171 | + * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
172 | + * @throws \EventEspresso\core\exceptions\InvalidIdentifierException |
|
173 | + * @throws \EventEspresso\core\exceptions\InvalidClassException |
|
174 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
175 | + * @throws \EventEspresso\core\services\container\exceptions\ServiceExistsException |
|
176 | + * @throws \EventEspresso\core\services\container\exceptions\ServiceNotFoundException |
|
177 | + * @throws \OutOfBoundsException |
|
178 | + */ |
|
179 | + function bootstrap_espresso() |
|
180 | + { |
|
181 | + require_once __DIR__ . '/core/espresso_definitions.php'; |
|
182 | + try { |
|
183 | + espresso_load_error_handling(); |
|
184 | + espresso_load_required( |
|
185 | + 'EEH_Base', |
|
186 | + EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php' |
|
187 | + ); |
|
188 | + espresso_load_required( |
|
189 | + 'EEH_File', |
|
190 | + EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php' |
|
191 | + ); |
|
192 | + espresso_load_required( |
|
193 | + 'EEH_File', |
|
194 | + EE_CORE . 'helpers' . DS . 'EEH_File.helper.php' |
|
195 | + ); |
|
196 | + espresso_load_required( |
|
197 | + 'EEH_Array', |
|
198 | + EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php' |
|
199 | + ); |
|
200 | + // instantiate and configure PSR4 autoloader |
|
201 | + espresso_load_required( |
|
202 | + 'Psr4Autoloader', |
|
203 | + EE_CORE . 'Psr4Autoloader.php' |
|
204 | + ); |
|
205 | + espresso_load_required( |
|
206 | + 'EE_Psr4AutoloaderInit', |
|
207 | + EE_CORE . 'EE_Psr4AutoloaderInit.core.php' |
|
208 | + ); |
|
209 | + $AutoloaderInit = new EE_Psr4AutoloaderInit(); |
|
210 | + $AutoloaderInit->initializeAutoloader(); |
|
211 | + espresso_load_required( |
|
212 | + 'EE_Request', |
|
213 | + EE_CORE . 'request_stack' . DS . 'EE_Request.core.php' |
|
214 | + ); |
|
215 | + espresso_load_required( |
|
216 | + 'EE_Response', |
|
217 | + EE_CORE . 'request_stack' . DS . 'EE_Response.core.php' |
|
218 | + ); |
|
219 | + espresso_load_required( |
|
220 | + 'EE_Bootstrap', |
|
221 | + EE_CORE . 'EE_Bootstrap.core.php' |
|
222 | + ); |
|
223 | + // bootstrap EE and the request stack |
|
224 | + new EE_Bootstrap( |
|
225 | + new EE_Request($_GET, $_POST, $_COOKIE), |
|
226 | + new EE_Response() |
|
227 | + ); |
|
228 | + } catch (Exception $e) { |
|
229 | + require_once EE_CORE . 'exceptions' . DS . 'ExceptionStackTraceDisplay.php'; |
|
230 | + new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e); |
|
231 | + } |
|
232 | + } |
|
233 | + bootstrap_espresso(); |
|
234 | + } |
|
235 | 235 | } |
236 | 236 | if (! function_exists('espresso_deactivate_plugin')) { |
237 | - /** |
|
238 | - * deactivate_plugin |
|
239 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
240 | - * |
|
241 | - * @access public |
|
242 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
243 | - * @return void |
|
244 | - */ |
|
245 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
246 | - { |
|
247 | - if (! function_exists('deactivate_plugins')) { |
|
248 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
249 | - } |
|
250 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
251 | - deactivate_plugins($plugin_basename); |
|
252 | - } |
|
237 | + /** |
|
238 | + * deactivate_plugin |
|
239 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
240 | + * |
|
241 | + * @access public |
|
242 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
243 | + * @return void |
|
244 | + */ |
|
245 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
246 | + { |
|
247 | + if (! function_exists('deactivate_plugins')) { |
|
248 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
249 | + } |
|
250 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
251 | + deactivate_plugins($plugin_basename); |
|
252 | + } |
|
253 | 253 | } |