@@ -240,12 +240,12 @@ discard block |
||
240 | 240 | } |
241 | 241 | |
242 | 242 | |
243 | - /** |
|
244 | - * @return void |
|
245 | - * @throws InvalidDataTypeException |
|
246 | - * @throws InvalidInterfaceException |
|
247 | - * @throws InvalidArgumentException |
|
248 | - */ |
|
243 | + /** |
|
244 | + * @return void |
|
245 | + * @throws InvalidDataTypeException |
|
246 | + * @throws InvalidInterfaceException |
|
247 | + * @throws InvalidArgumentException |
|
248 | + */ |
|
249 | 249 | protected function initializeTaxonomies() { |
250 | 250 | // check if taxonomies have already been set and that this CPT has taxonomies registered for it |
251 | 251 | if ( |
@@ -255,12 +255,12 @@ discard block |
||
255 | 255 | // if so then grab them, but we want the taxonomy name as the key |
256 | 256 | $taxonomies = array_flip( $this->cpt_details['args']['taxonomies'] ); |
257 | 257 | // then grab the list of ALL taxonomies |
258 | - /** @var \EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions |
|
259 | - * $taxonomy_definitions |
|
260 | - */ |
|
261 | - $taxonomy_definitions = LoaderFactory::getLoader()->getShared( |
|
262 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' |
|
263 | - ); |
|
258 | + /** @var \EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions |
|
259 | + * $taxonomy_definitions |
|
260 | + */ |
|
261 | + $taxonomy_definitions = LoaderFactory::getLoader()->getShared( |
|
262 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' |
|
263 | + ); |
|
264 | 264 | $all_taxonomies = $taxonomy_definitions->getCustomTaxonomyDefinitions(); |
265 | 265 | foreach ( $taxonomies as $taxonomy => &$details ) { |
266 | 266 | // add details to our taxonomies if they exist |
@@ -457,14 +457,14 @@ discard block |
||
457 | 457 | global $wpdb; |
458 | 458 | // adds something like " LEFT JOIN wp_esp_event_meta ON ( wp_esp_event_meta.EVT_ID = wp_posts.ID ) " to WP Query JOIN statement |
459 | 459 | $SQL .= ' LEFT JOIN ' |
460 | - . $this->meta_table->get_table_name() |
|
461 | - . ' ON ( ' |
|
462 | - . $this->meta_table->get_table_name() |
|
463 | - . '.' |
|
464 | - . $this->meta_table->get_fk_on_table() |
|
465 | - . ' = ' |
|
466 | - . $wpdb->posts |
|
467 | - . '.ID ) '; |
|
460 | + . $this->meta_table->get_table_name() |
|
461 | + . ' ON ( ' |
|
462 | + . $this->meta_table->get_table_name() |
|
463 | + . '.' |
|
464 | + . $this->meta_table->get_fk_on_table() |
|
465 | + . ' = ' |
|
466 | + . $wpdb->posts |
|
467 | + . '.ID ) '; |
|
468 | 468 | } |
469 | 469 | remove_filter( 'posts_join', array( $this, 'postsJoin' ) ); |
470 | 470 | return $SQL; |
@@ -6,8 +6,8 @@ discard block |
||
6 | 6 | use EventEspresso\core\services\loaders\LoaderFactory; |
7 | 7 | use InvalidArgumentException; |
8 | 8 | |
9 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
10 | - exit( 'No direct script access allowed' ); |
|
9 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
10 | + exit('No direct script access allowed'); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | |
@@ -85,10 +85,10 @@ discard block |
||
85 | 85 | \WP_Query $WP_Query, |
86 | 86 | \EE_Request_Handler $request |
87 | 87 | ) { |
88 | - $this->setRequest( $request ); |
|
89 | - $this->setWpQuery( $WP_Query ); |
|
90 | - $this->setPostType( $post_type ); |
|
91 | - $this->setCptDetails( $cpt_details ); |
|
88 | + $this->setRequest($request); |
|
89 | + $this->setWpQuery($WP_Query); |
|
90 | + $this->setPostType($post_type); |
|
91 | + $this->setCptDetails($cpt_details); |
|
92 | 92 | $this->init(); |
93 | 93 | } |
94 | 94 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | /** |
107 | 107 | * @param string $post_type |
108 | 108 | */ |
109 | - protected function setPostType( $post_type ) { |
|
109 | + protected function setPostType($post_type) { |
|
110 | 110 | $this->post_type = $post_type; |
111 | 111 | } |
112 | 112 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | /** |
125 | 125 | * @param array $cpt_details |
126 | 126 | */ |
127 | - protected function setCptDetails( $cpt_details ) { |
|
127 | + protected function setCptDetails($cpt_details) { |
|
128 | 128 | $this->cpt_details = $cpt_details; |
129 | 129 | } |
130 | 130 | |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | /** |
143 | 143 | * @param \EE_Table_Base[] $model_tables |
144 | 144 | */ |
145 | - protected function setModelTables( $model_tables ) { |
|
145 | + protected function setModelTables($model_tables) { |
|
146 | 146 | $this->model_tables = $model_tables; |
147 | 147 | } |
148 | 148 | |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * @return array |
153 | 153 | */ |
154 | 154 | public function taxonomies() { |
155 | - if ( empty( $this->taxonomies ) ) { |
|
155 | + if (empty($this->taxonomies)) { |
|
156 | 156 | $this->initializeTaxonomies(); |
157 | 157 | } |
158 | 158 | return $this->taxonomies; |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | /** |
164 | 164 | * @param array $taxonomies |
165 | 165 | */ |
166 | - protected function setTaxonomies( array $taxonomies ) { |
|
166 | + protected function setTaxonomies(array $taxonomies) { |
|
167 | 167 | $this->taxonomies = $taxonomies; |
168 | 168 | } |
169 | 169 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | /** |
182 | 182 | * @param \EE_Secondary_Table $meta_table |
183 | 183 | */ |
184 | - public function setMetaTable( \EE_Secondary_Table $meta_table ) { |
|
184 | + public function setMetaTable(\EE_Secondary_Table $meta_table) { |
|
185 | 185 | $this->meta_table = $meta_table; |
186 | 186 | } |
187 | 187 | |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | /** |
200 | 200 | * @param \EEM_Base $CPT_model |
201 | 201 | */ |
202 | - protected function setModel( \EEM_Base $CPT_model ) { |
|
202 | + protected function setModel(\EEM_Base $CPT_model) { |
|
203 | 203 | $this->model = $CPT_model; |
204 | 204 | } |
205 | 205 | |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | /** |
218 | 218 | * @param \EE_Request_Handler $request |
219 | 219 | */ |
220 | - protected function setRequest( \EE_Request_Handler $request ) { |
|
220 | + protected function setRequest(\EE_Request_Handler $request) { |
|
221 | 221 | $this->request = $request; |
222 | 222 | } |
223 | 223 | |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | /** |
236 | 236 | * @param \WP_Query $wp_query |
237 | 237 | */ |
238 | - public function setWpQuery( \WP_Query $wp_query ) { |
|
238 | + public function setWpQuery(\WP_Query $wp_query) { |
|
239 | 239 | $this->wp_query = $wp_query; |
240 | 240 | } |
241 | 241 | |
@@ -249,11 +249,11 @@ discard block |
||
249 | 249 | protected function initializeTaxonomies() { |
250 | 250 | // check if taxonomies have already been set and that this CPT has taxonomies registered for it |
251 | 251 | if ( |
252 | - empty( $this->taxonomies ) |
|
252 | + empty($this->taxonomies) |
|
253 | 253 | && isset($this->cpt_details['args']['taxonomies']) |
254 | 254 | ) { |
255 | 255 | // if so then grab them, but we want the taxonomy name as the key |
256 | - $taxonomies = array_flip( $this->cpt_details['args']['taxonomies'] ); |
|
256 | + $taxonomies = array_flip($this->cpt_details['args']['taxonomies']); |
|
257 | 257 | // then grab the list of ALL taxonomies |
258 | 258 | /** @var \EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions |
259 | 259 | * $taxonomy_definitions |
@@ -262,15 +262,15 @@ discard block |
||
262 | 262 | 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' |
263 | 263 | ); |
264 | 264 | $all_taxonomies = $taxonomy_definitions->getCustomTaxonomyDefinitions(); |
265 | - foreach ( $taxonomies as $taxonomy => &$details ) { |
|
265 | + foreach ($taxonomies as $taxonomy => &$details) { |
|
266 | 266 | // add details to our taxonomies if they exist |
267 | - $details = isset( $all_taxonomies[ $taxonomy ] ) |
|
268 | - ? $all_taxonomies[ $taxonomy ] |
|
267 | + $details = isset($all_taxonomies[$taxonomy]) |
|
268 | + ? $all_taxonomies[$taxonomy] |
|
269 | 269 | : array(); |
270 | 270 | } |
271 | 271 | // ALWAYS unset() variables that were passed by reference |
272 | - unset( $details ); |
|
273 | - $this->setTaxonomies( $taxonomies ); |
|
272 | + unset($details); |
|
273 | + $this->setTaxonomies($taxonomies); |
|
274 | 274 | } |
275 | 275 | } |
276 | 276 | |
@@ -280,11 +280,11 @@ discard block |
||
280 | 280 | $this->setAdditionalCptDetails(); |
281 | 281 | $this->setRequestVarsIfCpt(); |
282 | 282 | // convert post_type to model name |
283 | - $model_name = str_replace( 'EE_', '', $this->cpt_details['class_name'] ); |
|
283 | + $model_name = str_replace('EE_', '', $this->cpt_details['class_name']); |
|
284 | 284 | // load all tables related to CPT |
285 | - $this->setupModelsAndTables( $model_name ); |
|
285 | + $this->setupModelsAndTables($model_name); |
|
286 | 286 | // load and instantiate CPT_*_Strategy |
287 | - $CPT_Strategy = $this->cptStrategyClass( $model_name ); |
|
287 | + $CPT_Strategy = $this->cptStrategyClass($model_name); |
|
288 | 288 | // !!!!!!!!!! IMPORTANT !!!!!!!!!!!! |
289 | 289 | // here's the list of available filters in the WP_Query object |
290 | 290 | // 'posts_where_paged' |
@@ -295,17 +295,17 @@ discard block |
||
295 | 295 | // 'post_limits' |
296 | 296 | // 'posts_fields' |
297 | 297 | // 'posts_join' |
298 | - add_filter( 'posts_fields', array( $this, 'postsFields' ) ); |
|
299 | - add_filter( 'posts_join', array( $this, 'postsJoin' ) ); |
|
298 | + add_filter('posts_fields', array($this, 'postsFields')); |
|
299 | + add_filter('posts_join', array($this, 'postsJoin')); |
|
300 | 300 | add_filter( |
301 | - 'get_' . $this->post_type . '_metadata', |
|
302 | - array( $CPT_Strategy, 'get_EE_post_type_metadata' ), |
|
301 | + 'get_'.$this->post_type.'_metadata', |
|
302 | + array($CPT_Strategy, 'get_EE_post_type_metadata'), |
|
303 | 303 | 1, |
304 | 304 | 4 |
305 | 305 | ); |
306 | - add_filter( 'the_posts', array( $this, 'thePosts' ), 1, 1 ); |
|
307 | - if ( $this->wp_query->is_main_query() ) { |
|
308 | - add_filter( 'get_edit_post_link', array( $this, 'getEditPostLink' ), 10, 2 ); |
|
306 | + add_filter('the_posts', array($this, 'thePosts'), 1, 1); |
|
307 | + if ($this->wp_query->is_main_query()) { |
|
308 | + add_filter('get_edit_post_link', array($this, 'getEditPostLink'), 10, 2); |
|
309 | 309 | $this->addTemplateFilters(); |
310 | 310 | } |
311 | 311 | } |
@@ -322,18 +322,18 @@ discard block |
||
322 | 322 | // the post or category or term that is triggering EE |
323 | 323 | $this->cpt_details['espresso_page'] = $this->request->is_espresso_page(); |
324 | 324 | // requested post name |
325 | - $this->cpt_details['post_name'] = $this->request->get( 'post_name' ); |
|
325 | + $this->cpt_details['post_name'] = $this->request->get('post_name'); |
|
326 | 326 | // add support for viewing 'private', 'draft', or 'pending' posts |
327 | 327 | if ( |
328 | - isset( $this->wp_query->query_vars['p'] ) |
|
328 | + isset($this->wp_query->query_vars['p']) |
|
329 | 329 | && $this->wp_query->query_vars['p'] !== 0 |
330 | 330 | && is_user_logged_in() |
331 | - && current_user_can( 'edit_post', $this->wp_query->query_vars['p'] ) |
|
331 | + && current_user_can('edit_post', $this->wp_query->query_vars['p']) |
|
332 | 332 | ) { |
333 | 333 | // we can just inject directly into the WP_Query object |
334 | - $this->wp_query->query['post_status'] = array( 'publish', 'private', 'draft', 'pending' ); |
|
334 | + $this->wp_query->query['post_status'] = array('publish', 'private', 'draft', 'pending'); |
|
335 | 335 | // now set the main 'ee' request var so that the appropriate module can load the appropriate template(s) |
336 | - $this->request->set( 'ee', $this->cpt_details['singular_slug'] ); |
|
336 | + $this->request->set('ee', $this->cpt_details['singular_slug']); |
|
337 | 337 | } |
338 | 338 | } |
339 | 339 | |
@@ -350,15 +350,15 @@ discard block |
||
350 | 350 | */ |
351 | 351 | public function setRequestVarsIfCpt() { |
352 | 352 | // check if ee action var has been set |
353 | - if ( ! $this->request->is_set( 'ee' ) ) { |
|
353 | + if ( ! $this->request->is_set('ee')) { |
|
354 | 354 | // check that route exists for CPT archive slug |
355 | - if ( is_archive() && \EE_Config::get_route( $this->cpt_details['plural_slug'] ) ) { |
|
355 | + if (is_archive() && \EE_Config::get_route($this->cpt_details['plural_slug'])) { |
|
356 | 356 | // ie: set "ee" to "events" |
357 | - $this->request->set( 'ee', $this->cpt_details['plural_slug'] ); |
|
357 | + $this->request->set('ee', $this->cpt_details['plural_slug']); |
|
358 | 358 | // or does it match a single page CPT like /event/ |
359 | - } else if ( is_single() && \EE_Config::get_route( $this->cpt_details['singular_slug'] ) ) { |
|
359 | + } else if (is_single() && \EE_Config::get_route($this->cpt_details['singular_slug'])) { |
|
360 | 360 | // ie: set "ee" to "event" |
361 | - $this->request->set( 'ee', $this->cpt_details['singular_slug'] ); |
|
361 | + $this->request->set('ee', $this->cpt_details['singular_slug']); |
|
362 | 362 | } |
363 | 363 | } |
364 | 364 | } |
@@ -372,11 +372,11 @@ discard block |
||
372 | 372 | * @param string $model_name |
373 | 373 | * @throws \EE_Error |
374 | 374 | */ |
375 | - protected function setupModelsAndTables( $model_name ) { |
|
375 | + protected function setupModelsAndTables($model_name) { |
|
376 | 376 | // get CPT table data via CPT Model |
377 | - $model = \EE_Registry::instance()->load_model( $model_name ); |
|
378 | - if ( ! $model instanceof \EEM_Base ) { |
|
379 | - throw new \EE_Error ( |
|
377 | + $model = \EE_Registry::instance()->load_model($model_name); |
|
378 | + if ( ! $model instanceof \EEM_Base) { |
|
379 | + throw new \EE_Error( |
|
380 | 380 | sprintf( |
381 | 381 | __( |
382 | 382 | 'The "%1$s" model could not be loaded.', |
@@ -386,14 +386,14 @@ discard block |
||
386 | 386 | ) |
387 | 387 | ); |
388 | 388 | } |
389 | - $this->setModel( $model ); |
|
390 | - $this->setModelTables( $this->model->get_tables() ); |
|
389 | + $this->setModel($model); |
|
390 | + $this->setModelTables($this->model->get_tables()); |
|
391 | 391 | // is there a Meta Table for this CPT? |
392 | 392 | if ( |
393 | - isset( $this->cpt_details['tables'][ $model_name . '_Meta' ] ) |
|
394 | - && $this->cpt_details['tables'][ $model_name . '_Meta' ] instanceof \EE_Secondary_Table |
|
393 | + isset($this->cpt_details['tables'][$model_name.'_Meta']) |
|
394 | + && $this->cpt_details['tables'][$model_name.'_Meta'] instanceof \EE_Secondary_Table |
|
395 | 395 | ) { |
396 | - $this->setMetaTable( $this->cpt_details['tables'][ $model_name . '_Meta' ] ); |
|
396 | + $this->setMetaTable($this->cpt_details['tables'][$model_name.'_Meta']); |
|
397 | 397 | } |
398 | 398 | } |
399 | 399 | |
@@ -406,18 +406,18 @@ discard block |
||
406 | 406 | * @param string $model_name |
407 | 407 | * @return string |
408 | 408 | */ |
409 | - protected function cptStrategyClass( $model_name ) { |
|
409 | + protected function cptStrategyClass($model_name) { |
|
410 | 410 | // creates classname like: CPT_Event_Strategy |
411 | - $CPT_Strategy_class_name = 'CPT_' . $model_name . '_Strategy'; |
|
411 | + $CPT_Strategy_class_name = 'CPT_'.$model_name.'_Strategy'; |
|
412 | 412 | // load and instantiate |
413 | 413 | $CPT_Strategy = \EE_Registry::instance()->load_core( |
414 | 414 | $CPT_Strategy_class_name, |
415 | - array( 'WP_Query' => $this->wp_query, 'CPT' => $this->cpt_details ) |
|
415 | + array('WP_Query' => $this->wp_query, 'CPT' => $this->cpt_details) |
|
416 | 416 | ); |
417 | - if ( $CPT_Strategy === null ) { |
|
417 | + if ($CPT_Strategy === null) { |
|
418 | 418 | $CPT_Strategy = \EE_Registry::instance()->load_core( |
419 | 419 | 'CPT_Default_Strategy', |
420 | - array( 'WP_Query' => $this->wp_query, 'CPT' => $this->cpt_details ) |
|
420 | + array('WP_Query' => $this->wp_query, 'CPT' => $this->cpt_details) |
|
421 | 421 | ); |
422 | 422 | } |
423 | 423 | return $CPT_Strategy; |
@@ -432,13 +432,13 @@ discard block |
||
432 | 432 | * @param $SQL |
433 | 433 | * @return string |
434 | 434 | */ |
435 | - public function postsFields( $SQL ) { |
|
435 | + public function postsFields($SQL) { |
|
436 | 436 | // does this CPT have a meta table ? |
437 | - if ( $this->meta_table instanceof \EE_Secondary_Table ) { |
|
437 | + if ($this->meta_table instanceof \EE_Secondary_Table) { |
|
438 | 438 | // adds something like ", wp_esp_event_meta.* " to WP Query SELECT statement |
439 | - $SQL .= ', ' . $this->meta_table->get_table_name() . '.* '; |
|
439 | + $SQL .= ', '.$this->meta_table->get_table_name().'.* '; |
|
440 | 440 | } |
441 | - remove_filter( 'posts_fields', array( $this, 'postsFields' ) ); |
|
441 | + remove_filter('posts_fields', array($this, 'postsFields')); |
|
442 | 442 | return $SQL; |
443 | 443 | } |
444 | 444 | |
@@ -451,9 +451,9 @@ discard block |
||
451 | 451 | * @param $SQL |
452 | 452 | * @return string |
453 | 453 | */ |
454 | - public function postsJoin( $SQL ) { |
|
454 | + public function postsJoin($SQL) { |
|
455 | 455 | // does this CPT have a meta table ? |
456 | - if ( $this->meta_table instanceof \EE_Secondary_Table ) { |
|
456 | + if ($this->meta_table instanceof \EE_Secondary_Table) { |
|
457 | 457 | global $wpdb; |
458 | 458 | // adds something like " LEFT JOIN wp_esp_event_meta ON ( wp_esp_event_meta.EVT_ID = wp_posts.ID ) " to WP Query JOIN statement |
459 | 459 | $SQL .= ' LEFT JOIN ' |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | . $wpdb->posts |
467 | 467 | . '.ID ) '; |
468 | 468 | } |
469 | - remove_filter( 'posts_join', array( $this, 'postsJoin' ) ); |
|
469 | + remove_filter('posts_join', array($this, 'postsJoin')); |
|
470 | 470 | return $SQL; |
471 | 471 | } |
472 | 472 | |
@@ -479,17 +479,17 @@ discard block |
||
479 | 479 | * @param \WP_Post[] $posts |
480 | 480 | * @return \WP_Post[] |
481 | 481 | */ |
482 | - public function thePosts( $posts ) { |
|
482 | + public function thePosts($posts) { |
|
483 | 483 | $CPT_class = $this->cpt_details['class_name']; |
484 | 484 | // loop thru posts |
485 | - if ( is_array( $posts ) && $this->model instanceof \EEM_CPT_Base ) { |
|
486 | - foreach ( $posts as $key => $post ) { |
|
487 | - if ( $post->post_type === $this->post_type ) { |
|
488 | - $post->{$CPT_class} = $this->model->instantiate_class_from_post_object( $post ); |
|
485 | + if (is_array($posts) && $this->model instanceof \EEM_CPT_Base) { |
|
486 | + foreach ($posts as $key => $post) { |
|
487 | + if ($post->post_type === $this->post_type) { |
|
488 | + $post->{$CPT_class} = $this->model->instantiate_class_from_post_object($post); |
|
489 | 489 | } |
490 | 490 | } |
491 | 491 | } |
492 | - remove_filter( 'the_posts', array( $this, 'thePosts' ), 1 ); |
|
492 | + remove_filter('the_posts', array($this, 'thePosts'), 1); |
|
493 | 493 | return $posts; |
494 | 494 | } |
495 | 495 | |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | * @param $ID |
501 | 501 | * @return string |
502 | 502 | */ |
503 | - public function getEditPostLink( $url, $ID ) { |
|
503 | + public function getEditPostLink($url, $ID) { |
|
504 | 504 | // need to make sure we only edit links if our cpt |
505 | 505 | global $post; |
506 | 506 | //notice if the cpt is registered with `show_ee_ui` set to false, we take that to mean that the WordPress core ui |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | ! $post instanceof \WP_Post |
510 | 510 | || $post->post_type !== $this->post_type |
511 | 511 | || ( |
512 | - isset( $this->cpt_details['args']['show_ee_ui'] ) |
|
512 | + isset($this->cpt_details['args']['show_ee_ui']) |
|
513 | 513 | && ! $this->cpt_details['args']['show_ee_ui'] |
514 | 514 | ) |
515 | 515 | ) { |
@@ -518,8 +518,8 @@ discard block |
||
518 | 518 | //k made it here so all is good. |
519 | 519 | return wp_nonce_url( |
520 | 520 | add_query_arg( |
521 | - array( 'page' => $this->post_type, 'post' => $ID, 'action' => 'edit' ), |
|
522 | - admin_url( 'admin.php' ) |
|
521 | + array('page' => $this->post_type, 'post' => $ID, 'action' => 'edit'), |
|
522 | + admin_url('admin.php') |
|
523 | 523 | ), |
524 | 524 | 'edit', |
525 | 525 | 'edit_nonce' |
@@ -536,9 +536,9 @@ discard block |
||
536 | 536 | */ |
537 | 537 | public function addTemplateFilters() { |
538 | 538 | // if requested cpt supports page_templates and it's the main query |
539 | - if ( ! empty( $this->cpt_details['args']['page_templates'] ) && $this->wp_query->is_main_query() ) { |
|
539 | + if ( ! empty($this->cpt_details['args']['page_templates']) && $this->wp_query->is_main_query()) { |
|
540 | 540 | // then let's hook into the appropriate query_template hook |
541 | - add_filter( 'single_template', array( $this, 'singleCptTemplate' ) ); |
|
541 | + add_filter('single_template', array($this, 'singleCptTemplate')); |
|
542 | 542 | } |
543 | 543 | } |
544 | 544 | |
@@ -552,20 +552,20 @@ discard block |
||
552 | 552 | * @param string $current_template Existing default template path derived for this page call. |
553 | 553 | * @return string the path to the full template file. |
554 | 554 | */ |
555 | - public function singleCptTemplate( $current_template ) { |
|
555 | + public function singleCptTemplate($current_template) { |
|
556 | 556 | $object = get_queried_object(); |
557 | 557 | //does this called object HAVE a page template set that is something other than the default. |
558 | - $template = get_post_meta( $object->ID, '_wp_page_template', true ); |
|
558 | + $template = get_post_meta($object->ID, '_wp_page_template', true); |
|
559 | 559 | //exit early if default or not set or invalid path (accounts for theme changes) |
560 | 560 | if ( |
561 | 561 | $template === 'default' |
562 | - || empty( $template ) |
|
563 | - || ! is_readable( get_stylesheet_directory() . '/' . $template ) |
|
562 | + || empty($template) |
|
563 | + || ! is_readable(get_stylesheet_directory().'/'.$template) |
|
564 | 564 | ) { |
565 | 565 | return $current_template; |
566 | 566 | } |
567 | 567 | //made it here so we SHOULD be able to just locate the template and then return it. |
568 | - return locate_template( array( $template ) ); |
|
568 | + return locate_template(array($template)); |
|
569 | 569 | } |
570 | 570 | |
571 | 571 |
@@ -23,458 +23,458 @@ discard block |
||
23 | 23 | final class EE_Admin implements InterminableInterface |
24 | 24 | { |
25 | 25 | |
26 | - /** |
|
27 | - * @var EE_Admin $_instance |
|
28 | - */ |
|
29 | - private static $_instance; |
|
30 | - |
|
31 | - /** |
|
32 | - * @var PersistentAdminNoticeManager $persistent_admin_notice_manager |
|
33 | - */ |
|
34 | - private $persistent_admin_notice_manager; |
|
35 | - |
|
36 | - /** |
|
37 | - * @singleton method used to instantiate class object |
|
38 | - * @return EE_Admin |
|
39 | - * @throws EE_Error |
|
40 | - */ |
|
41 | - public static function instance() |
|
42 | - { |
|
43 | - // check if class object is instantiated |
|
44 | - if (! self::$_instance instanceof EE_Admin) { |
|
45 | - self::$_instance = new self(); |
|
46 | - } |
|
47 | - return self::$_instance; |
|
48 | - } |
|
49 | - |
|
50 | - |
|
51 | - /** |
|
52 | - * @return EE_Admin |
|
53 | - * @throws EE_Error |
|
54 | - */ |
|
55 | - public static function reset() |
|
56 | - { |
|
57 | - self::$_instance = null; |
|
58 | - return self::instance(); |
|
59 | - } |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * class constructor |
|
64 | - * |
|
65 | - * @throws EE_Error |
|
66 | - * @throws InvalidDataTypeException |
|
67 | - * @throws InvalidInterfaceException |
|
68 | - * @throws InvalidArgumentException |
|
69 | - */ |
|
70 | - protected function __construct() |
|
71 | - { |
|
72 | - // define global EE_Admin constants |
|
73 | - $this->_define_all_constants(); |
|
74 | - // set autoloaders for our admin page classes based on included path information |
|
75 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN); |
|
76 | - // admin hooks |
|
77 | - add_filter('plugin_action_links', array($this, 'filter_plugin_actions'), 10, 2); |
|
78 | - // load EE_Request_Handler early |
|
79 | - add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'get_request')); |
|
80 | - add_action('AHEE__EE_System__initialize_last', array($this, 'init')); |
|
81 | - add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'route_admin_request'), 100, 2); |
|
82 | - add_action('wp_loaded', array($this, 'wp_loaded'), 100); |
|
83 | - add_action('admin_init', array($this, 'admin_init'), 100); |
|
84 | - add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'), 20); |
|
85 | - add_action('admin_notices', array($this, 'display_admin_notices'), 10); |
|
86 | - add_action('network_admin_notices', array($this, 'display_admin_notices'), 10); |
|
87 | - add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2); |
|
88 | - add_filter('admin_footer_text', array($this, 'espresso_admin_footer')); |
|
89 | - add_action('load-plugins.php', array($this, 'hookIntoWpPluginsPage')); |
|
90 | - //reset Environment config (we only do this on admin page loads); |
|
91 | - EE_Registry::instance()->CFG->environment->recheck_values(); |
|
92 | - do_action('AHEE__EE_Admin__loaded'); |
|
93 | - } |
|
94 | - |
|
95 | - |
|
96 | - |
|
97 | - /** |
|
98 | - * _define_all_constants |
|
99 | - * define constants that are set globally for all admin pages |
|
100 | - * |
|
101 | - * @return void |
|
102 | - */ |
|
103 | - private function _define_all_constants() |
|
104 | - { |
|
105 | - if (! defined('EE_ADMIN_URL')) { |
|
106 | - define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/'); |
|
107 | - define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/'); |
|
108 | - define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates' . DS); |
|
109 | - define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/'); |
|
110 | - define('WP_AJAX_URL', admin_url('admin-ajax.php')); |
|
111 | - } |
|
112 | - } |
|
113 | - |
|
114 | - |
|
115 | - /** |
|
116 | - * filter_plugin_actions - adds links to the Plugins page listing |
|
117 | - * |
|
118 | - * @param array $links |
|
119 | - * @param string $plugin |
|
120 | - * @return array |
|
121 | - */ |
|
122 | - public function filter_plugin_actions($links, $plugin) |
|
123 | - { |
|
124 | - // set $main_file in stone |
|
125 | - static $main_file; |
|
126 | - // if $main_file is not set yet |
|
127 | - if (! $main_file) { |
|
128 | - $main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE); |
|
129 | - } |
|
130 | - if ($plugin === $main_file) { |
|
131 | - // compare current plugin to this one |
|
132 | - if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
133 | - $maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings"' |
|
134 | - . ' title="Event Espresso is in maintenance mode. Click this link to learn why.">' |
|
135 | - . esc_html__('Maintenance Mode Active', 'event_espresso') |
|
136 | - . '</a>'; |
|
137 | - array_unshift($links, $maintenance_link); |
|
138 | - } else { |
|
139 | - $org_settings_link = '<a href="admin.php?page=espresso_general_settings">' |
|
140 | - . esc_html__('Settings', 'event_espresso') |
|
141 | - . '</a>'; |
|
142 | - $events_link = '<a href="admin.php?page=espresso_events">' |
|
143 | - . esc_html__('Events', 'event_espresso') |
|
144 | - . '</a>'; |
|
145 | - // add before other links |
|
146 | - array_unshift($links, $org_settings_link, $events_link); |
|
147 | - } |
|
148 | - } |
|
149 | - return $links; |
|
150 | - } |
|
151 | - |
|
152 | - |
|
153 | - /** |
|
154 | - * _get_request |
|
155 | - * |
|
156 | - * @return void |
|
157 | - * @throws EE_Error |
|
158 | - * @throws InvalidArgumentException |
|
159 | - * @throws InvalidDataTypeException |
|
160 | - * @throws InvalidInterfaceException |
|
161 | - * @throws ReflectionException |
|
162 | - */ |
|
163 | - public function get_request() |
|
164 | - { |
|
165 | - EE_Registry::instance()->load_core('Request_Handler'); |
|
166 | - EE_Registry::instance()->load_core('CPT_Strategy'); |
|
167 | - } |
|
168 | - |
|
169 | - |
|
170 | - |
|
171 | - /** |
|
172 | - * hide_admin_pages_except_maintenance_mode |
|
173 | - * |
|
174 | - * @param array $admin_page_folder_names |
|
175 | - * @return array |
|
176 | - */ |
|
177 | - public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array()) |
|
178 | - { |
|
179 | - return array( |
|
180 | - 'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS, |
|
181 | - 'about' => EE_ADMIN_PAGES . 'about' . DS, |
|
182 | - 'support' => EE_ADMIN_PAGES . 'support' . DS, |
|
183 | - ); |
|
184 | - } |
|
185 | - |
|
186 | - |
|
187 | - |
|
188 | - /** |
|
189 | - * init- should fire after shortcode, module, addon, other plugin (default priority), and even |
|
190 | - * EE_Front_Controller's init phases have run |
|
191 | - * |
|
192 | - * @return void |
|
193 | - * @throws EE_Error |
|
194 | - * @throws InvalidArgumentException |
|
195 | - * @throws InvalidDataTypeException |
|
196 | - * @throws InvalidInterfaceException |
|
197 | - * @throws ReflectionException |
|
198 | - * @throws ServiceNotFoundException |
|
199 | - */ |
|
200 | - public function init() |
|
201 | - { |
|
202 | - //only enable most of the EE_Admin IF we're not in full maintenance mode |
|
203 | - if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
204 | - //ok so we want to enable the entire admin |
|
205 | - $this->persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared( |
|
206 | - 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
207 | - ); |
|
208 | - $this->persistent_admin_notice_manager->setReturnUrl( |
|
209 | - EE_Admin_Page::add_query_args_and_nonce( |
|
210 | - array( |
|
211 | - 'page' => EE_Registry::instance()->REQ->get('page', ''), |
|
212 | - 'action' => EE_Registry::instance()->REQ->get('action', ''), |
|
213 | - ), |
|
214 | - EE_ADMIN_URL |
|
215 | - ) |
|
216 | - ); |
|
217 | - $this->maybeSetDatetimeWarningNotice(); |
|
218 | - //at a glance dashboard widget |
|
219 | - add_filter('dashboard_glance_items', array($this, 'dashboard_glance_items'), 10); |
|
220 | - //filter for get_edit_post_link used on comments for custom post types |
|
221 | - add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 2); |
|
222 | - } |
|
223 | - // run the admin page factory but ONLY if we are doing an ee admin ajax request |
|
224 | - if (! defined('DOING_AJAX') || EE_ADMIN_AJAX) { |
|
225 | - try { |
|
226 | - //this loads the controller for the admin pages which will setup routing etc |
|
227 | - EE_Registry::instance()->load_core('Admin_Page_Loader'); |
|
228 | - } catch (EE_Error $e) { |
|
229 | - $e->get_error(); |
|
230 | - } |
|
231 | - } |
|
232 | - add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1); |
|
233 | - //make sure our CPTs and custom taxonomy metaboxes get shown for first time users |
|
234 | - add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes'), 10); |
|
235 | - add_action('admin_head', array($this, 'register_custom_nav_menu_boxes'), 10); |
|
236 | - //exclude EE critical pages from all nav menus and wp_list_pages |
|
237 | - add_filter('nav_menu_meta_box_object', array($this, 'remove_pages_from_nav_menu'), 10); |
|
238 | - } |
|
239 | - |
|
240 | - |
|
241 | - /** |
|
242 | - * get_persistent_admin_notices |
|
243 | - * |
|
244 | - * @access public |
|
245 | - * @return void |
|
246 | - * @throws EE_Error |
|
247 | - * @throws InvalidArgumentException |
|
248 | - * @throws InvalidDataTypeException |
|
249 | - * @throws InvalidInterfaceException |
|
250 | - */ |
|
251 | - public function maybeSetDatetimeWarningNotice() |
|
252 | - { |
|
253 | - //add dismissable notice for datetime changes. Only valid if site does not have a timezone_string set. |
|
254 | - //@todo This needs to stay in core for a bit to catch anyone upgrading from a version without this to a version |
|
255 | - //with this. But after enough time (indeterminate at this point) we can just remove this notice. |
|
256 | - //this was added with https://events.codebasehq.com/projects/event-espresso/tickets/10626 |
|
257 | - if (apply_filters('FHEE__EE_Admin__maybeSetDatetimeWarningNotice', true) |
|
258 | - && ! get_option('timezone_string') |
|
259 | - && EEM_Event::instance()->count() > 0 |
|
260 | - ) { |
|
261 | - new PersistentAdminNotice( |
|
262 | - 'datetime_fix_notice', |
|
263 | - sprintf( |
|
264 | - esc_html__( |
|
265 | - '%1$sImportant announcement related to your install of Event Espresso%2$s: There are some changes made to your site that could affect how dates display for your events and other related items with dates and times. Read more about it %3$shere%4$s. If your dates and times are displaying incorrectly (incorrect offset), you can fix it using the tool on %5$sthis page%4$s.', |
|
266 | - 'event_espresso' |
|
267 | - ), |
|
268 | - '<strong>', |
|
269 | - '</strong>', |
|
270 | - '<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">', |
|
271 | - '</a>', |
|
272 | - '<a href="' . EE_Admin_Page::add_query_args_and_nonce( |
|
273 | - array( |
|
274 | - 'page' => 'espresso_maintenance_settings', |
|
275 | - 'action' => 'datetime_tools' |
|
276 | - ), |
|
277 | - admin_url('admin.php') |
|
278 | - ) . '">' |
|
279 | - ), |
|
280 | - false, |
|
281 | - 'manage_options', |
|
282 | - 'datetime_fix_persistent_notice' |
|
283 | - ); |
|
284 | - } |
|
285 | - } |
|
286 | - |
|
287 | - |
|
288 | - |
|
289 | - /** |
|
290 | - * this simply hooks into the nav menu setup of pages metabox and makes sure that we remove EE critical pages from |
|
291 | - * the list of options. the wp function "wp_nav_menu_item_post_type_meta_box" found in |
|
292 | - * wp-admin/includes/nav-menu.php looks for the "_default_query" property on the post_type object and it uses that |
|
293 | - * to override any queries found in the existing query for the given post type. Note that _default_query is not a |
|
294 | - * normal property on the post_type object. It's found ONLY in this particular context. |
|
295 | - * |
|
296 | - * @param WP_Post $post_type WP post type object |
|
297 | - * @return WP_Post |
|
298 | - * @throws InvalidArgumentException |
|
299 | - * @throws InvalidDataTypeException |
|
300 | - * @throws InvalidInterfaceException |
|
301 | - */ |
|
302 | - public function remove_pages_from_nav_menu($post_type) |
|
303 | - { |
|
304 | - //if this isn't the "pages" post type let's get out |
|
305 | - if ($post_type->name !== 'page') { |
|
306 | - return $post_type; |
|
307 | - } |
|
308 | - $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
|
309 | - $post_type->_default_query = array( |
|
310 | - 'post__not_in' => $critical_pages, |
|
311 | - ); |
|
312 | - return $post_type; |
|
313 | - } |
|
314 | - |
|
315 | - |
|
316 | - |
|
317 | - /** |
|
318 | - * WP by default only shows three metaboxes in "nav-menus.php" for first times users. We want to make sure our |
|
319 | - * metaboxes get shown as well |
|
320 | - * |
|
321 | - * @return void |
|
322 | - */ |
|
323 | - public function enable_hidden_ee_nav_menu_metaboxes() |
|
324 | - { |
|
325 | - global $wp_meta_boxes, $pagenow; |
|
326 | - if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') { |
|
327 | - return; |
|
328 | - } |
|
329 | - $user = wp_get_current_user(); |
|
330 | - //has this been done yet? |
|
331 | - if (get_user_option('ee_nav_menu_initialized', $user->ID)) { |
|
332 | - return; |
|
333 | - } |
|
334 | - |
|
335 | - $hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus', $user->ID); |
|
336 | - $initial_meta_boxes = apply_filters( |
|
337 | - 'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes', |
|
338 | - array( |
|
339 | - 'nav-menu-theme-locations', |
|
340 | - 'add-page', |
|
341 | - 'add-custom-links', |
|
342 | - 'add-category', |
|
343 | - 'add-espresso_events', |
|
344 | - 'add-espresso_venues', |
|
345 | - 'add-espresso_event_categories', |
|
346 | - 'add-espresso_venue_categories', |
|
347 | - 'add-post-type-post', |
|
348 | - 'add-post-type-page', |
|
349 | - ) |
|
350 | - ); |
|
351 | - |
|
352 | - if (is_array($hidden_meta_boxes)) { |
|
353 | - foreach ($hidden_meta_boxes as $key => $meta_box_id) { |
|
354 | - if (in_array($meta_box_id, $initial_meta_boxes, true)) { |
|
355 | - unset($hidden_meta_boxes[$key]); |
|
356 | - } |
|
357 | - } |
|
358 | - } |
|
359 | - update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true); |
|
360 | - update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true); |
|
361 | - } |
|
362 | - |
|
363 | - |
|
364 | - |
|
365 | - /** |
|
366 | - * This method simply registers custom nav menu boxes for "nav_menus.php route" |
|
367 | - * Currently EE is using this to make sure there are menu options for our CPT archive page routes. |
|
368 | - * |
|
369 | - * @todo modify this so its more dynamic and automatic for all ee CPTs and setups and can also be hooked into by |
|
370 | - * addons etc. |
|
371 | - * @return void |
|
372 | - */ |
|
373 | - public function register_custom_nav_menu_boxes() |
|
374 | - { |
|
375 | - add_meta_box( |
|
376 | - 'add-extra-nav-menu-pages', |
|
377 | - esc_html__('Event Espresso Pages', 'event_espresso'), |
|
378 | - array($this, 'ee_cpt_archive_pages'), |
|
379 | - 'nav-menus', |
|
380 | - 'side', |
|
381 | - 'core' |
|
382 | - ); |
|
383 | - } |
|
384 | - |
|
385 | - |
|
386 | - |
|
387 | - /** |
|
388 | - * Use this to edit the post link for our cpts so that the edit link points to the correct page. |
|
389 | - * |
|
390 | - * @since 4.3.0 |
|
391 | - * @param string $link the original link generated by wp |
|
392 | - * @param int $id post id |
|
393 | - * @return string the (maybe) modified link |
|
394 | - */ |
|
395 | - public function modify_edit_post_link($link, $id) |
|
396 | - { |
|
397 | - if (! $post = get_post($id)) { |
|
398 | - return $link; |
|
399 | - } |
|
400 | - if ($post->post_type === 'espresso_attendees') { |
|
401 | - $query_args = array( |
|
402 | - 'action' => 'edit_attendee', |
|
403 | - 'post' => $id, |
|
404 | - ); |
|
405 | - return EEH_URL::add_query_args_and_nonce( |
|
406 | - $query_args, |
|
407 | - admin_url('admin.php?page=espresso_registrations') |
|
408 | - ); |
|
409 | - } |
|
410 | - return $link; |
|
411 | - } |
|
412 | - |
|
413 | - |
|
414 | - |
|
415 | - public function ee_cpt_archive_pages() |
|
416 | - { |
|
417 | - global $nav_menu_selected_id; |
|
418 | - $db_fields = false; |
|
419 | - $walker = new Walker_Nav_Menu_Checklist($db_fields); |
|
420 | - $current_tab = 'event-archives'; |
|
421 | - $removed_args = array( |
|
422 | - 'action', |
|
423 | - 'customlink-tab', |
|
424 | - 'edit-menu-item', |
|
425 | - 'menu-item', |
|
426 | - 'page-tab', |
|
427 | - '_wpnonce', |
|
428 | - ); |
|
429 | - ?> |
|
26 | + /** |
|
27 | + * @var EE_Admin $_instance |
|
28 | + */ |
|
29 | + private static $_instance; |
|
30 | + |
|
31 | + /** |
|
32 | + * @var PersistentAdminNoticeManager $persistent_admin_notice_manager |
|
33 | + */ |
|
34 | + private $persistent_admin_notice_manager; |
|
35 | + |
|
36 | + /** |
|
37 | + * @singleton method used to instantiate class object |
|
38 | + * @return EE_Admin |
|
39 | + * @throws EE_Error |
|
40 | + */ |
|
41 | + public static function instance() |
|
42 | + { |
|
43 | + // check if class object is instantiated |
|
44 | + if (! self::$_instance instanceof EE_Admin) { |
|
45 | + self::$_instance = new self(); |
|
46 | + } |
|
47 | + return self::$_instance; |
|
48 | + } |
|
49 | + |
|
50 | + |
|
51 | + /** |
|
52 | + * @return EE_Admin |
|
53 | + * @throws EE_Error |
|
54 | + */ |
|
55 | + public static function reset() |
|
56 | + { |
|
57 | + self::$_instance = null; |
|
58 | + return self::instance(); |
|
59 | + } |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * class constructor |
|
64 | + * |
|
65 | + * @throws EE_Error |
|
66 | + * @throws InvalidDataTypeException |
|
67 | + * @throws InvalidInterfaceException |
|
68 | + * @throws InvalidArgumentException |
|
69 | + */ |
|
70 | + protected function __construct() |
|
71 | + { |
|
72 | + // define global EE_Admin constants |
|
73 | + $this->_define_all_constants(); |
|
74 | + // set autoloaders for our admin page classes based on included path information |
|
75 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN); |
|
76 | + // admin hooks |
|
77 | + add_filter('plugin_action_links', array($this, 'filter_plugin_actions'), 10, 2); |
|
78 | + // load EE_Request_Handler early |
|
79 | + add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'get_request')); |
|
80 | + add_action('AHEE__EE_System__initialize_last', array($this, 'init')); |
|
81 | + add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'route_admin_request'), 100, 2); |
|
82 | + add_action('wp_loaded', array($this, 'wp_loaded'), 100); |
|
83 | + add_action('admin_init', array($this, 'admin_init'), 100); |
|
84 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'), 20); |
|
85 | + add_action('admin_notices', array($this, 'display_admin_notices'), 10); |
|
86 | + add_action('network_admin_notices', array($this, 'display_admin_notices'), 10); |
|
87 | + add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2); |
|
88 | + add_filter('admin_footer_text', array($this, 'espresso_admin_footer')); |
|
89 | + add_action('load-plugins.php', array($this, 'hookIntoWpPluginsPage')); |
|
90 | + //reset Environment config (we only do this on admin page loads); |
|
91 | + EE_Registry::instance()->CFG->environment->recheck_values(); |
|
92 | + do_action('AHEE__EE_Admin__loaded'); |
|
93 | + } |
|
94 | + |
|
95 | + |
|
96 | + |
|
97 | + /** |
|
98 | + * _define_all_constants |
|
99 | + * define constants that are set globally for all admin pages |
|
100 | + * |
|
101 | + * @return void |
|
102 | + */ |
|
103 | + private function _define_all_constants() |
|
104 | + { |
|
105 | + if (! defined('EE_ADMIN_URL')) { |
|
106 | + define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/'); |
|
107 | + define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/'); |
|
108 | + define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates' . DS); |
|
109 | + define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/'); |
|
110 | + define('WP_AJAX_URL', admin_url('admin-ajax.php')); |
|
111 | + } |
|
112 | + } |
|
113 | + |
|
114 | + |
|
115 | + /** |
|
116 | + * filter_plugin_actions - adds links to the Plugins page listing |
|
117 | + * |
|
118 | + * @param array $links |
|
119 | + * @param string $plugin |
|
120 | + * @return array |
|
121 | + */ |
|
122 | + public function filter_plugin_actions($links, $plugin) |
|
123 | + { |
|
124 | + // set $main_file in stone |
|
125 | + static $main_file; |
|
126 | + // if $main_file is not set yet |
|
127 | + if (! $main_file) { |
|
128 | + $main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE); |
|
129 | + } |
|
130 | + if ($plugin === $main_file) { |
|
131 | + // compare current plugin to this one |
|
132 | + if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
133 | + $maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings"' |
|
134 | + . ' title="Event Espresso is in maintenance mode. Click this link to learn why.">' |
|
135 | + . esc_html__('Maintenance Mode Active', 'event_espresso') |
|
136 | + . '</a>'; |
|
137 | + array_unshift($links, $maintenance_link); |
|
138 | + } else { |
|
139 | + $org_settings_link = '<a href="admin.php?page=espresso_general_settings">' |
|
140 | + . esc_html__('Settings', 'event_espresso') |
|
141 | + . '</a>'; |
|
142 | + $events_link = '<a href="admin.php?page=espresso_events">' |
|
143 | + . esc_html__('Events', 'event_espresso') |
|
144 | + . '</a>'; |
|
145 | + // add before other links |
|
146 | + array_unshift($links, $org_settings_link, $events_link); |
|
147 | + } |
|
148 | + } |
|
149 | + return $links; |
|
150 | + } |
|
151 | + |
|
152 | + |
|
153 | + /** |
|
154 | + * _get_request |
|
155 | + * |
|
156 | + * @return void |
|
157 | + * @throws EE_Error |
|
158 | + * @throws InvalidArgumentException |
|
159 | + * @throws InvalidDataTypeException |
|
160 | + * @throws InvalidInterfaceException |
|
161 | + * @throws ReflectionException |
|
162 | + */ |
|
163 | + public function get_request() |
|
164 | + { |
|
165 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
166 | + EE_Registry::instance()->load_core('CPT_Strategy'); |
|
167 | + } |
|
168 | + |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * hide_admin_pages_except_maintenance_mode |
|
173 | + * |
|
174 | + * @param array $admin_page_folder_names |
|
175 | + * @return array |
|
176 | + */ |
|
177 | + public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array()) |
|
178 | + { |
|
179 | + return array( |
|
180 | + 'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS, |
|
181 | + 'about' => EE_ADMIN_PAGES . 'about' . DS, |
|
182 | + 'support' => EE_ADMIN_PAGES . 'support' . DS, |
|
183 | + ); |
|
184 | + } |
|
185 | + |
|
186 | + |
|
187 | + |
|
188 | + /** |
|
189 | + * init- should fire after shortcode, module, addon, other plugin (default priority), and even |
|
190 | + * EE_Front_Controller's init phases have run |
|
191 | + * |
|
192 | + * @return void |
|
193 | + * @throws EE_Error |
|
194 | + * @throws InvalidArgumentException |
|
195 | + * @throws InvalidDataTypeException |
|
196 | + * @throws InvalidInterfaceException |
|
197 | + * @throws ReflectionException |
|
198 | + * @throws ServiceNotFoundException |
|
199 | + */ |
|
200 | + public function init() |
|
201 | + { |
|
202 | + //only enable most of the EE_Admin IF we're not in full maintenance mode |
|
203 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
204 | + //ok so we want to enable the entire admin |
|
205 | + $this->persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared( |
|
206 | + 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
207 | + ); |
|
208 | + $this->persistent_admin_notice_manager->setReturnUrl( |
|
209 | + EE_Admin_Page::add_query_args_and_nonce( |
|
210 | + array( |
|
211 | + 'page' => EE_Registry::instance()->REQ->get('page', ''), |
|
212 | + 'action' => EE_Registry::instance()->REQ->get('action', ''), |
|
213 | + ), |
|
214 | + EE_ADMIN_URL |
|
215 | + ) |
|
216 | + ); |
|
217 | + $this->maybeSetDatetimeWarningNotice(); |
|
218 | + //at a glance dashboard widget |
|
219 | + add_filter('dashboard_glance_items', array($this, 'dashboard_glance_items'), 10); |
|
220 | + //filter for get_edit_post_link used on comments for custom post types |
|
221 | + add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 2); |
|
222 | + } |
|
223 | + // run the admin page factory but ONLY if we are doing an ee admin ajax request |
|
224 | + if (! defined('DOING_AJAX') || EE_ADMIN_AJAX) { |
|
225 | + try { |
|
226 | + //this loads the controller for the admin pages which will setup routing etc |
|
227 | + EE_Registry::instance()->load_core('Admin_Page_Loader'); |
|
228 | + } catch (EE_Error $e) { |
|
229 | + $e->get_error(); |
|
230 | + } |
|
231 | + } |
|
232 | + add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1); |
|
233 | + //make sure our CPTs and custom taxonomy metaboxes get shown for first time users |
|
234 | + add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes'), 10); |
|
235 | + add_action('admin_head', array($this, 'register_custom_nav_menu_boxes'), 10); |
|
236 | + //exclude EE critical pages from all nav menus and wp_list_pages |
|
237 | + add_filter('nav_menu_meta_box_object', array($this, 'remove_pages_from_nav_menu'), 10); |
|
238 | + } |
|
239 | + |
|
240 | + |
|
241 | + /** |
|
242 | + * get_persistent_admin_notices |
|
243 | + * |
|
244 | + * @access public |
|
245 | + * @return void |
|
246 | + * @throws EE_Error |
|
247 | + * @throws InvalidArgumentException |
|
248 | + * @throws InvalidDataTypeException |
|
249 | + * @throws InvalidInterfaceException |
|
250 | + */ |
|
251 | + public function maybeSetDatetimeWarningNotice() |
|
252 | + { |
|
253 | + //add dismissable notice for datetime changes. Only valid if site does not have a timezone_string set. |
|
254 | + //@todo This needs to stay in core for a bit to catch anyone upgrading from a version without this to a version |
|
255 | + //with this. But after enough time (indeterminate at this point) we can just remove this notice. |
|
256 | + //this was added with https://events.codebasehq.com/projects/event-espresso/tickets/10626 |
|
257 | + if (apply_filters('FHEE__EE_Admin__maybeSetDatetimeWarningNotice', true) |
|
258 | + && ! get_option('timezone_string') |
|
259 | + && EEM_Event::instance()->count() > 0 |
|
260 | + ) { |
|
261 | + new PersistentAdminNotice( |
|
262 | + 'datetime_fix_notice', |
|
263 | + sprintf( |
|
264 | + esc_html__( |
|
265 | + '%1$sImportant announcement related to your install of Event Espresso%2$s: There are some changes made to your site that could affect how dates display for your events and other related items with dates and times. Read more about it %3$shere%4$s. If your dates and times are displaying incorrectly (incorrect offset), you can fix it using the tool on %5$sthis page%4$s.', |
|
266 | + 'event_espresso' |
|
267 | + ), |
|
268 | + '<strong>', |
|
269 | + '</strong>', |
|
270 | + '<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">', |
|
271 | + '</a>', |
|
272 | + '<a href="' . EE_Admin_Page::add_query_args_and_nonce( |
|
273 | + array( |
|
274 | + 'page' => 'espresso_maintenance_settings', |
|
275 | + 'action' => 'datetime_tools' |
|
276 | + ), |
|
277 | + admin_url('admin.php') |
|
278 | + ) . '">' |
|
279 | + ), |
|
280 | + false, |
|
281 | + 'manage_options', |
|
282 | + 'datetime_fix_persistent_notice' |
|
283 | + ); |
|
284 | + } |
|
285 | + } |
|
286 | + |
|
287 | + |
|
288 | + |
|
289 | + /** |
|
290 | + * this simply hooks into the nav menu setup of pages metabox and makes sure that we remove EE critical pages from |
|
291 | + * the list of options. the wp function "wp_nav_menu_item_post_type_meta_box" found in |
|
292 | + * wp-admin/includes/nav-menu.php looks for the "_default_query" property on the post_type object and it uses that |
|
293 | + * to override any queries found in the existing query for the given post type. Note that _default_query is not a |
|
294 | + * normal property on the post_type object. It's found ONLY in this particular context. |
|
295 | + * |
|
296 | + * @param WP_Post $post_type WP post type object |
|
297 | + * @return WP_Post |
|
298 | + * @throws InvalidArgumentException |
|
299 | + * @throws InvalidDataTypeException |
|
300 | + * @throws InvalidInterfaceException |
|
301 | + */ |
|
302 | + public function remove_pages_from_nav_menu($post_type) |
|
303 | + { |
|
304 | + //if this isn't the "pages" post type let's get out |
|
305 | + if ($post_type->name !== 'page') { |
|
306 | + return $post_type; |
|
307 | + } |
|
308 | + $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
|
309 | + $post_type->_default_query = array( |
|
310 | + 'post__not_in' => $critical_pages, |
|
311 | + ); |
|
312 | + return $post_type; |
|
313 | + } |
|
314 | + |
|
315 | + |
|
316 | + |
|
317 | + /** |
|
318 | + * WP by default only shows three metaboxes in "nav-menus.php" for first times users. We want to make sure our |
|
319 | + * metaboxes get shown as well |
|
320 | + * |
|
321 | + * @return void |
|
322 | + */ |
|
323 | + public function enable_hidden_ee_nav_menu_metaboxes() |
|
324 | + { |
|
325 | + global $wp_meta_boxes, $pagenow; |
|
326 | + if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') { |
|
327 | + return; |
|
328 | + } |
|
329 | + $user = wp_get_current_user(); |
|
330 | + //has this been done yet? |
|
331 | + if (get_user_option('ee_nav_menu_initialized', $user->ID)) { |
|
332 | + return; |
|
333 | + } |
|
334 | + |
|
335 | + $hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus', $user->ID); |
|
336 | + $initial_meta_boxes = apply_filters( |
|
337 | + 'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes', |
|
338 | + array( |
|
339 | + 'nav-menu-theme-locations', |
|
340 | + 'add-page', |
|
341 | + 'add-custom-links', |
|
342 | + 'add-category', |
|
343 | + 'add-espresso_events', |
|
344 | + 'add-espresso_venues', |
|
345 | + 'add-espresso_event_categories', |
|
346 | + 'add-espresso_venue_categories', |
|
347 | + 'add-post-type-post', |
|
348 | + 'add-post-type-page', |
|
349 | + ) |
|
350 | + ); |
|
351 | + |
|
352 | + if (is_array($hidden_meta_boxes)) { |
|
353 | + foreach ($hidden_meta_boxes as $key => $meta_box_id) { |
|
354 | + if (in_array($meta_box_id, $initial_meta_boxes, true)) { |
|
355 | + unset($hidden_meta_boxes[$key]); |
|
356 | + } |
|
357 | + } |
|
358 | + } |
|
359 | + update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true); |
|
360 | + update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true); |
|
361 | + } |
|
362 | + |
|
363 | + |
|
364 | + |
|
365 | + /** |
|
366 | + * This method simply registers custom nav menu boxes for "nav_menus.php route" |
|
367 | + * Currently EE is using this to make sure there are menu options for our CPT archive page routes. |
|
368 | + * |
|
369 | + * @todo modify this so its more dynamic and automatic for all ee CPTs and setups and can also be hooked into by |
|
370 | + * addons etc. |
|
371 | + * @return void |
|
372 | + */ |
|
373 | + public function register_custom_nav_menu_boxes() |
|
374 | + { |
|
375 | + add_meta_box( |
|
376 | + 'add-extra-nav-menu-pages', |
|
377 | + esc_html__('Event Espresso Pages', 'event_espresso'), |
|
378 | + array($this, 'ee_cpt_archive_pages'), |
|
379 | + 'nav-menus', |
|
380 | + 'side', |
|
381 | + 'core' |
|
382 | + ); |
|
383 | + } |
|
384 | + |
|
385 | + |
|
386 | + |
|
387 | + /** |
|
388 | + * Use this to edit the post link for our cpts so that the edit link points to the correct page. |
|
389 | + * |
|
390 | + * @since 4.3.0 |
|
391 | + * @param string $link the original link generated by wp |
|
392 | + * @param int $id post id |
|
393 | + * @return string the (maybe) modified link |
|
394 | + */ |
|
395 | + public function modify_edit_post_link($link, $id) |
|
396 | + { |
|
397 | + if (! $post = get_post($id)) { |
|
398 | + return $link; |
|
399 | + } |
|
400 | + if ($post->post_type === 'espresso_attendees') { |
|
401 | + $query_args = array( |
|
402 | + 'action' => 'edit_attendee', |
|
403 | + 'post' => $id, |
|
404 | + ); |
|
405 | + return EEH_URL::add_query_args_and_nonce( |
|
406 | + $query_args, |
|
407 | + admin_url('admin.php?page=espresso_registrations') |
|
408 | + ); |
|
409 | + } |
|
410 | + return $link; |
|
411 | + } |
|
412 | + |
|
413 | + |
|
414 | + |
|
415 | + public function ee_cpt_archive_pages() |
|
416 | + { |
|
417 | + global $nav_menu_selected_id; |
|
418 | + $db_fields = false; |
|
419 | + $walker = new Walker_Nav_Menu_Checklist($db_fields); |
|
420 | + $current_tab = 'event-archives'; |
|
421 | + $removed_args = array( |
|
422 | + 'action', |
|
423 | + 'customlink-tab', |
|
424 | + 'edit-menu-item', |
|
425 | + 'menu-item', |
|
426 | + 'page-tab', |
|
427 | + '_wpnonce', |
|
428 | + ); |
|
429 | + ?> |
|
430 | 430 | <div id="posttype-extra-nav-menu-pages" class="posttypediv"> |
431 | 431 | <ul id="posttype-extra-nav-menu-pages-tabs" class="posttype-tabs add-menu-item-tabs"> |
432 | 432 | <li <?php echo('event-archives' === $current_tab ? ' class="tabs"' : ''); ?>> |
433 | 433 | <a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-event-archives" |
434 | 434 | href="<?php if ($nav_menu_selected_id) { |
435 | - echo esc_url( |
|
436 | - add_query_arg( |
|
437 | - 'extra-nav-menu-pages-tab', |
|
438 | - 'event-archives', |
|
439 | - remove_query_arg($removed_args) |
|
440 | - ) |
|
441 | - ); |
|
442 | - } ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives"> |
|
435 | + echo esc_url( |
|
436 | + add_query_arg( |
|
437 | + 'extra-nav-menu-pages-tab', |
|
438 | + 'event-archives', |
|
439 | + remove_query_arg($removed_args) |
|
440 | + ) |
|
441 | + ); |
|
442 | + } ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives"> |
|
443 | 443 | <?php _e('Event Archive Pages', 'event_espresso'); ?> |
444 | 444 | </a> |
445 | 445 | </li> |
446 | 446 | </ul><!-- .posttype-tabs --> |
447 | 447 | |
448 | 448 | <div id="tabs-panel-posttype-extra-nav-menu-pages-event-archives" class="tabs-panel <?php |
449 | - echo('event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive'); |
|
450 | - ?>"> |
|
449 | + echo('event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive'); |
|
450 | + ?>"> |
|
451 | 451 | <ul id="extra-nav-menu-pageschecklist-event-archives" class="categorychecklist form-no-clear"> |
452 | 452 | <?php |
453 | - $pages = $this->_get_extra_nav_menu_pages_items(); |
|
454 | - $args['walker'] = $walker; |
|
455 | - echo walk_nav_menu_tree( |
|
456 | - array_map( |
|
457 | - array($this, '_setup_extra_nav_menu_pages_items'), |
|
458 | - $pages |
|
459 | - ), |
|
460 | - 0, |
|
461 | - (object) $args |
|
462 | - ); |
|
463 | - ?> |
|
453 | + $pages = $this->_get_extra_nav_menu_pages_items(); |
|
454 | + $args['walker'] = $walker; |
|
455 | + echo walk_nav_menu_tree( |
|
456 | + array_map( |
|
457 | + array($this, '_setup_extra_nav_menu_pages_items'), |
|
458 | + $pages |
|
459 | + ), |
|
460 | + 0, |
|
461 | + (object) $args |
|
462 | + ); |
|
463 | + ?> |
|
464 | 464 | </ul> |
465 | 465 | </div><!-- /.tabs-panel --> |
466 | 466 | |
467 | 467 | <p class="button-controls"> |
468 | 468 | <span class="list-controls"> |
469 | 469 | <a href="<?php |
470 | - echo esc_url(add_query_arg( |
|
471 | - array( |
|
472 | - 'extra-nav-menu-pages-tab' => 'event-archives', |
|
473 | - 'selectall' => 1, |
|
474 | - ), |
|
475 | - remove_query_arg($removed_args) |
|
476 | - )); |
|
477 | - ?>#posttype-extra-nav-menu-pages>" class="select-all"><?php _e('Select All'); ?></a> |
|
470 | + echo esc_url(add_query_arg( |
|
471 | + array( |
|
472 | + 'extra-nav-menu-pages-tab' => 'event-archives', |
|
473 | + 'selectall' => 1, |
|
474 | + ), |
|
475 | + remove_query_arg($removed_args) |
|
476 | + )); |
|
477 | + ?>#posttype-extra-nav-menu-pages>" class="select-all"><?php _e('Select All'); ?></a> |
|
478 | 478 | </span> |
479 | 479 | <span class="add-to-menu"> |
480 | 480 | <input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> |
@@ -487,489 +487,489 @@ discard block |
||
487 | 487 | |
488 | 488 | </div><!-- /.posttypediv --> |
489 | 489 | <?php |
490 | - } |
|
491 | - |
|
492 | - |
|
493 | - /** |
|
494 | - * Returns an array of event archive nav items. |
|
495 | - * |
|
496 | - * @todo for now this method is just in place so when it gets abstracted further we can substitute in whatever |
|
497 | - * method we use for getting the extra nav menu items |
|
498 | - * @return array |
|
499 | - */ |
|
500 | - private function _get_extra_nav_menu_pages_items() |
|
501 | - { |
|
502 | - $menuitems[] = array( |
|
503 | - 'title' => esc_html__('Event List', 'event_espresso'), |
|
504 | - 'url' => get_post_type_archive_link('espresso_events'), |
|
505 | - 'description' => esc_html__('Archive page for all events.', 'event_espresso'), |
|
506 | - ); |
|
507 | - return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems); |
|
508 | - } |
|
509 | - |
|
510 | - |
|
511 | - /** |
|
512 | - * Setup nav menu walker item for usage in the event archive nav menu metabox. It receives a menu_item array with |
|
513 | - * the properties and converts it to the menu item object. |
|
514 | - * |
|
515 | - * @see wp_setup_nav_menu_item() in wp-includes/nav-menu.php |
|
516 | - * @param $menu_item_values |
|
517 | - * @return stdClass |
|
518 | - */ |
|
519 | - private function _setup_extra_nav_menu_pages_items($menu_item_values) |
|
520 | - { |
|
521 | - $menu_item = new stdClass(); |
|
522 | - $keys = array( |
|
523 | - 'ID' => 0, |
|
524 | - 'db_id' => 0, |
|
525 | - 'menu_item_parent' => 0, |
|
526 | - 'object_id' => -1, |
|
527 | - 'post_parent' => 0, |
|
528 | - 'type' => 'custom', |
|
529 | - 'object' => '', |
|
530 | - 'type_label' => esc_html__('Extra Nav Menu Item', 'event_espresso'), |
|
531 | - 'title' => '', |
|
532 | - 'url' => '', |
|
533 | - 'target' => '', |
|
534 | - 'attr_title' => '', |
|
535 | - 'description' => '', |
|
536 | - 'classes' => array(), |
|
537 | - 'xfn' => '', |
|
538 | - ); |
|
539 | - |
|
540 | - foreach ($keys as $key => $value) { |
|
541 | - $menu_item->{$key} = isset($menu_item_values[$key]) ? $menu_item_values[$key] : $value; |
|
542 | - } |
|
543 | - return $menu_item; |
|
544 | - } |
|
545 | - |
|
546 | - |
|
547 | - /** |
|
548 | - * This is the action hook for the AHEE__EE_Admin_Page__route_admin_request hook that fires off right before an |
|
549 | - * EE_Admin_Page route is called. |
|
550 | - * |
|
551 | - * @return void |
|
552 | - */ |
|
553 | - public function route_admin_request() |
|
554 | - { |
|
555 | - } |
|
556 | - |
|
557 | - |
|
558 | - /** |
|
559 | - * wp_loaded should fire on the WordPress wp_loaded hook. This fires on a VERY late priority. |
|
560 | - * |
|
561 | - * @return void |
|
562 | - */ |
|
563 | - public function wp_loaded() |
|
564 | - { |
|
565 | - } |
|
566 | - |
|
567 | - |
|
568 | - /** |
|
569 | - * admin_init |
|
570 | - * |
|
571 | - * @return void |
|
572 | - * @throws EE_Error |
|
573 | - * @throws InvalidArgumentException |
|
574 | - * @throws InvalidDataTypeException |
|
575 | - * @throws InvalidInterfaceException |
|
576 | - * @throws ReflectionException |
|
577 | - */ |
|
578 | - public function admin_init() |
|
579 | - { |
|
580 | - |
|
581 | - /** |
|
582 | - * our cpt models must be instantiated on WordPress post processing routes (wp-admin/post.php), |
|
583 | - * so any hooking into core WP routes is taken care of. So in this next few lines of code: |
|
584 | - * - check if doing post processing. |
|
585 | - * - check if doing post processing of one of EE CPTs |
|
586 | - * - instantiate the corresponding EE CPT model for the post_type being processed. |
|
587 | - */ |
|
588 | - if (isset($_POST['action'], $_POST['post_type']) && $_POST['action'] === 'editpost') { |
|
589 | - /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */ |
|
590 | - $custom_post_types = LoaderFactory::getLoader()->getShared( |
|
591 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
592 | - ); |
|
593 | - $custom_post_types->getCustomPostTypeModels($_POST['post_type']); |
|
594 | - } |
|
595 | - |
|
596 | - |
|
597 | - /** |
|
598 | - * This code excludes EE critical pages anywhere `wp_dropdown_pages` is used to create a dropdown for selecting |
|
599 | - * critical pages. The only place critical pages need included in a generated dropdown is on the "Critical |
|
600 | - * Pages" tab in the EE General Settings Admin page. |
|
601 | - * This is for user-proofing. |
|
602 | - */ |
|
603 | - add_filter('wp_dropdown_pages', array($this, 'modify_dropdown_pages')); |
|
604 | - } |
|
605 | - |
|
606 | - |
|
607 | - /** |
|
608 | - * Callback for wp_dropdown_pages hook to remove ee critical pages from the dropdown selection. |
|
609 | - * |
|
610 | - * @param string $output Current output. |
|
611 | - * @return string |
|
612 | - * @throws InvalidArgumentException |
|
613 | - * @throws InvalidDataTypeException |
|
614 | - * @throws InvalidInterfaceException |
|
615 | - */ |
|
616 | - public function modify_dropdown_pages($output) |
|
617 | - { |
|
618 | - //get critical pages |
|
619 | - $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
|
620 | - |
|
621 | - //split current output by line break for easier parsing. |
|
622 | - $split_output = explode("\n", $output); |
|
623 | - |
|
624 | - //loop through to remove any critical pages from the array. |
|
625 | - foreach ($critical_pages as $page_id) { |
|
626 | - $needle = 'value="' . $page_id . '"'; |
|
627 | - foreach ($split_output as $key => $haystack) { |
|
628 | - if (strpos($haystack, $needle) !== false) { |
|
629 | - unset($split_output[$key]); |
|
630 | - } |
|
631 | - } |
|
632 | - } |
|
633 | - //replace output with the new contents |
|
634 | - return implode("\n", $split_output); |
|
635 | - } |
|
636 | - |
|
637 | - |
|
638 | - /** |
|
639 | - * enqueue all admin scripts that need loaded for admin pages |
|
640 | - * |
|
641 | - * @return void |
|
642 | - */ |
|
643 | - public function enqueue_admin_scripts() |
|
644 | - { |
|
645 | - // this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js. |
|
646 | - // Note: the intention of this script is to only do TARGETED injections. I.E, only injecting on certain script |
|
647 | - // calls. |
|
648 | - wp_enqueue_script( |
|
649 | - 'ee-inject-wp', |
|
650 | - EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js', |
|
651 | - array('jquery'), |
|
652 | - EVENT_ESPRESSO_VERSION, |
|
653 | - true |
|
654 | - ); |
|
655 | - // register cookie script for future dependencies |
|
656 | - wp_register_script( |
|
657 | - 'jquery-cookie', |
|
658 | - EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js', |
|
659 | - array('jquery'), |
|
660 | - '2.1', |
|
661 | - true |
|
662 | - ); |
|
663 | - //joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again |
|
664 | - // via: add_filter('FHEE_load_joyride', '__return_true' ); |
|
665 | - if (apply_filters('FHEE_load_joyride', false)) { |
|
666 | - //joyride style |
|
667 | - wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1'); |
|
668 | - wp_register_style( |
|
669 | - 'ee-joyride-css', |
|
670 | - EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css', |
|
671 | - array('joyride-css'), |
|
672 | - EVENT_ESPRESSO_VERSION |
|
673 | - ); |
|
674 | - wp_register_script( |
|
675 | - 'joyride-modernizr', |
|
676 | - EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js', |
|
677 | - array(), |
|
678 | - '2.1', |
|
679 | - true |
|
680 | - ); |
|
681 | - //joyride JS |
|
682 | - wp_register_script( |
|
683 | - 'jquery-joyride', |
|
684 | - EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js', |
|
685 | - array('jquery-cookie', 'joyride-modernizr'), |
|
686 | - '2.1', |
|
687 | - true |
|
688 | - ); |
|
689 | - // wanna go for a joyride? |
|
690 | - wp_enqueue_style('ee-joyride-css'); |
|
691 | - wp_enqueue_script('jquery-joyride'); |
|
692 | - } |
|
693 | - } |
|
694 | - |
|
695 | - |
|
696 | - /** |
|
697 | - * display_admin_notices |
|
698 | - * |
|
699 | - * @return void |
|
700 | - */ |
|
701 | - public function display_admin_notices() |
|
702 | - { |
|
703 | - echo EE_Error::get_notices(); |
|
704 | - } |
|
705 | - |
|
706 | - |
|
707 | - |
|
708 | - /** |
|
709 | - * @param array $elements |
|
710 | - * @return array |
|
711 | - * @throws EE_Error |
|
712 | - * @throws InvalidArgumentException |
|
713 | - * @throws InvalidDataTypeException |
|
714 | - * @throws InvalidInterfaceException |
|
715 | - */ |
|
716 | - public function dashboard_glance_items($elements) |
|
717 | - { |
|
718 | - $elements = is_array($elements) ? $elements : array($elements); |
|
719 | - $events = EEM_Event::instance()->count(); |
|
720 | - $items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
721 | - array('page' => 'espresso_events'), |
|
722 | - admin_url('admin.php') |
|
723 | - ); |
|
724 | - $items['events']['text'] = sprintf(_n('%s Event', '%s Events', $events), number_format_i18n($events)); |
|
725 | - $items['events']['title'] = esc_html__('Click to view all Events', 'event_espresso'); |
|
726 | - $registrations = EEM_Registration::instance()->count( |
|
727 | - array( |
|
728 | - array( |
|
729 | - 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete), |
|
730 | - ), |
|
731 | - ) |
|
732 | - ); |
|
733 | - $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
734 | - array('page' => 'espresso_registrations'), |
|
735 | - admin_url('admin.php') |
|
736 | - ); |
|
737 | - $items['registrations']['text'] = sprintf( |
|
738 | - _n('%s Registration', '%s Registrations', $registrations), |
|
739 | - number_format_i18n($registrations) |
|
740 | - ); |
|
741 | - $items['registrations']['title'] = esc_html__('Click to view all registrations', 'event_espresso'); |
|
742 | - |
|
743 | - $items = (array)apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items); |
|
744 | - |
|
745 | - foreach ($items as $type => $item_properties) { |
|
746 | - $elements[] = sprintf( |
|
747 | - '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>', |
|
748 | - $item_properties['url'], |
|
749 | - $item_properties['title'], |
|
750 | - $item_properties['text'] |
|
751 | - ); |
|
752 | - } |
|
753 | - return $elements; |
|
754 | - } |
|
755 | - |
|
756 | - |
|
757 | - /** |
|
758 | - * check_for_invalid_datetime_formats |
|
759 | - * if an admin changes their date or time format settings on the WP General Settings admin page, verify that |
|
760 | - * their selected format can be parsed by PHP |
|
761 | - * |
|
762 | - * @param $value |
|
763 | - * @param $option |
|
764 | - * @throws EE_Error |
|
765 | - * @return string |
|
766 | - */ |
|
767 | - public function check_for_invalid_datetime_formats($value, $option) |
|
768 | - { |
|
769 | - // check for date_format or time_format |
|
770 | - switch ($option) { |
|
771 | - case 'date_format': |
|
772 | - $date_time_format = $value . ' ' . get_option('time_format'); |
|
773 | - break; |
|
774 | - case 'time_format': |
|
775 | - $date_time_format = get_option('date_format') . ' ' . $value; |
|
776 | - break; |
|
777 | - default: |
|
778 | - $date_time_format = false; |
|
779 | - } |
|
780 | - // do we have a date_time format to check ? |
|
781 | - if ($date_time_format) { |
|
782 | - $error_msg = EEH_DTT_Helper::validate_format_string($date_time_format); |
|
783 | - |
|
784 | - if (is_array($error_msg)) { |
|
785 | - $msg = '<p>' |
|
786 | - . sprintf( |
|
787 | - esc_html__( |
|
788 | - 'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:', |
|
789 | - 'event_espresso' |
|
790 | - ), |
|
791 | - date($date_time_format), |
|
792 | - $date_time_format |
|
793 | - ) |
|
794 | - . '</p><p><ul>'; |
|
795 | - |
|
796 | - |
|
797 | - foreach ($error_msg as $error) { |
|
798 | - $msg .= '<li>' . $error . '</li>'; |
|
799 | - } |
|
800 | - |
|
801 | - $msg .= '</ul></p><p>' |
|
802 | - . sprintf( |
|
803 | - esc_html__( |
|
804 | - '%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s', |
|
805 | - 'event_espresso' |
|
806 | - ), |
|
807 | - '<span style="color:#D54E21;">', |
|
808 | - '</span>' |
|
809 | - ) |
|
810 | - . '</p>'; |
|
811 | - |
|
812 | - // trigger WP settings error |
|
813 | - add_settings_error( |
|
814 | - 'date_format', |
|
815 | - 'date_format', |
|
816 | - $msg |
|
817 | - ); |
|
818 | - |
|
819 | - // set format to something valid |
|
820 | - switch ($option) { |
|
821 | - case 'date_format': |
|
822 | - $value = 'F j, Y'; |
|
823 | - break; |
|
824 | - case 'time_format': |
|
825 | - $value = 'g:i a'; |
|
826 | - break; |
|
827 | - } |
|
828 | - } |
|
829 | - } |
|
830 | - return $value; |
|
831 | - } |
|
832 | - |
|
833 | - |
|
834 | - /** |
|
835 | - * its_eSpresso - converts the less commonly used spelling of "Expresso" to "Espresso" |
|
836 | - * |
|
837 | - * @param $content |
|
838 | - * @return string |
|
839 | - */ |
|
840 | - public function its_eSpresso($content) |
|
841 | - { |
|
842 | - return str_replace('[EXPRESSO_', '[ESPRESSO_', $content); |
|
843 | - } |
|
844 | - |
|
845 | - |
|
846 | - /** |
|
847 | - * espresso_admin_footer |
|
848 | - * |
|
849 | - * @return string |
|
850 | - */ |
|
851 | - public function espresso_admin_footer() |
|
852 | - { |
|
853 | - return \EEH_Template::powered_by_event_espresso('aln-cntr', '', array('utm_content' => 'admin_footer')); |
|
854 | - } |
|
855 | - |
|
856 | - |
|
857 | - /** |
|
858 | - * static method for registering ee admin page. |
|
859 | - * This method is deprecated in favor of the new location in EE_Register_Admin_Page::register. |
|
860 | - * |
|
861 | - * @since 4.3.0 |
|
862 | - * @deprecated 4.3.0 Use EE_Register_Admin_Page::register() instead |
|
863 | - * @see EE_Register_Admin_Page::register() |
|
864 | - * @param $page_basename |
|
865 | - * @param $page_path |
|
866 | - * @param array $config |
|
867 | - * @return void |
|
868 | - * @throws EE_Error |
|
869 | - */ |
|
870 | - public static function register_ee_admin_page($page_basename, $page_path, $config = array()) |
|
871 | - { |
|
872 | - EE_Error::doing_it_wrong( |
|
873 | - __METHOD__, |
|
874 | - sprintf( |
|
875 | - esc_html__( |
|
876 | - 'Usage is deprecated. Use EE_Register_Admin_Page::register() for registering the %s admin page.', |
|
877 | - 'event_espresso' |
|
878 | - ), |
|
879 | - $page_basename |
|
880 | - ), |
|
881 | - '4.3' |
|
882 | - ); |
|
883 | - if (class_exists('EE_Register_Admin_Page')) { |
|
884 | - $config['page_path'] = $page_path; |
|
885 | - } |
|
886 | - EE_Register_Admin_Page::register($page_basename, $config); |
|
887 | - } |
|
888 | - |
|
889 | - |
|
890 | - /** |
|
891 | - * @deprecated 4.8.41 |
|
892 | - * @param int $post_ID |
|
893 | - * @param \WP_Post $post |
|
894 | - * @return void |
|
895 | - */ |
|
896 | - public static function parse_post_content_on_save($post_ID, $post) |
|
897 | - { |
|
898 | - EE_Error::doing_it_wrong( |
|
899 | - __METHOD__, |
|
900 | - esc_html__('Usage is deprecated', 'event_espresso'), |
|
901 | - '4.8.41' |
|
902 | - ); |
|
903 | - } |
|
904 | - |
|
905 | - |
|
906 | - /** |
|
907 | - * @deprecated 4.8.41 |
|
908 | - * @param $option |
|
909 | - * @param $old_value |
|
910 | - * @param $value |
|
911 | - * @return void |
|
912 | - */ |
|
913 | - public function reset_page_for_posts_on_change($option, $old_value, $value) |
|
914 | - { |
|
915 | - EE_Error::doing_it_wrong( |
|
916 | - __METHOD__, |
|
917 | - esc_html__('Usage is deprecated', 'event_espresso'), |
|
918 | - '4.8.41' |
|
919 | - ); |
|
920 | - } |
|
921 | - |
|
922 | - |
|
923 | - |
|
924 | - /** |
|
925 | - * @deprecated 4.9.27 |
|
926 | - * @return void |
|
927 | - */ |
|
928 | - public function get_persistent_admin_notices() |
|
929 | - { |
|
930 | - EE_Error::doing_it_wrong( |
|
931 | - __METHOD__, |
|
932 | - sprintf( |
|
933 | - __('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), |
|
934 | - '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
935 | - ), |
|
936 | - '4.9.27' |
|
937 | - ); |
|
938 | - } |
|
939 | - |
|
940 | - |
|
941 | - |
|
942 | - /** |
|
943 | - * @deprecated 4.9.27 |
|
944 | - * @throws InvalidInterfaceException |
|
945 | - * @throws InvalidDataTypeException |
|
946 | - * @throws DomainException |
|
947 | - */ |
|
948 | - public function dismiss_ee_nag_notice_callback() |
|
949 | - { |
|
950 | - EE_Error::doing_it_wrong( |
|
951 | - __METHOD__, |
|
952 | - sprintf( |
|
953 | - __('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), |
|
954 | - '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
955 | - ), |
|
956 | - '4.9.27' |
|
957 | - ); |
|
958 | - $this->persistent_admin_notice_manager->dismissNotice(); |
|
959 | - } |
|
960 | - |
|
961 | - |
|
962 | - /** |
|
963 | - * Callback on load-plugins.php hook for setting up anything hooking into the wp plugins page. |
|
964 | - * @throws InvalidArgumentException |
|
965 | - * @throws InvalidDataTypeException |
|
966 | - * @throws InvalidInterfaceException |
|
967 | - */ |
|
968 | - public function hookIntoWpPluginsPage() |
|
969 | - { |
|
970 | - LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\services\admin\ExitModal'); |
|
971 | - LoaderFactory::getLoader() |
|
972 | - ->getShared('EventEspresso\core\domain\services\admin\PluginUpsells') |
|
973 | - ->decafUpsells(); |
|
974 | - } |
|
490 | + } |
|
491 | + |
|
492 | + |
|
493 | + /** |
|
494 | + * Returns an array of event archive nav items. |
|
495 | + * |
|
496 | + * @todo for now this method is just in place so when it gets abstracted further we can substitute in whatever |
|
497 | + * method we use for getting the extra nav menu items |
|
498 | + * @return array |
|
499 | + */ |
|
500 | + private function _get_extra_nav_menu_pages_items() |
|
501 | + { |
|
502 | + $menuitems[] = array( |
|
503 | + 'title' => esc_html__('Event List', 'event_espresso'), |
|
504 | + 'url' => get_post_type_archive_link('espresso_events'), |
|
505 | + 'description' => esc_html__('Archive page for all events.', 'event_espresso'), |
|
506 | + ); |
|
507 | + return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems); |
|
508 | + } |
|
509 | + |
|
510 | + |
|
511 | + /** |
|
512 | + * Setup nav menu walker item for usage in the event archive nav menu metabox. It receives a menu_item array with |
|
513 | + * the properties and converts it to the menu item object. |
|
514 | + * |
|
515 | + * @see wp_setup_nav_menu_item() in wp-includes/nav-menu.php |
|
516 | + * @param $menu_item_values |
|
517 | + * @return stdClass |
|
518 | + */ |
|
519 | + private function _setup_extra_nav_menu_pages_items($menu_item_values) |
|
520 | + { |
|
521 | + $menu_item = new stdClass(); |
|
522 | + $keys = array( |
|
523 | + 'ID' => 0, |
|
524 | + 'db_id' => 0, |
|
525 | + 'menu_item_parent' => 0, |
|
526 | + 'object_id' => -1, |
|
527 | + 'post_parent' => 0, |
|
528 | + 'type' => 'custom', |
|
529 | + 'object' => '', |
|
530 | + 'type_label' => esc_html__('Extra Nav Menu Item', 'event_espresso'), |
|
531 | + 'title' => '', |
|
532 | + 'url' => '', |
|
533 | + 'target' => '', |
|
534 | + 'attr_title' => '', |
|
535 | + 'description' => '', |
|
536 | + 'classes' => array(), |
|
537 | + 'xfn' => '', |
|
538 | + ); |
|
539 | + |
|
540 | + foreach ($keys as $key => $value) { |
|
541 | + $menu_item->{$key} = isset($menu_item_values[$key]) ? $menu_item_values[$key] : $value; |
|
542 | + } |
|
543 | + return $menu_item; |
|
544 | + } |
|
545 | + |
|
546 | + |
|
547 | + /** |
|
548 | + * This is the action hook for the AHEE__EE_Admin_Page__route_admin_request hook that fires off right before an |
|
549 | + * EE_Admin_Page route is called. |
|
550 | + * |
|
551 | + * @return void |
|
552 | + */ |
|
553 | + public function route_admin_request() |
|
554 | + { |
|
555 | + } |
|
556 | + |
|
557 | + |
|
558 | + /** |
|
559 | + * wp_loaded should fire on the WordPress wp_loaded hook. This fires on a VERY late priority. |
|
560 | + * |
|
561 | + * @return void |
|
562 | + */ |
|
563 | + public function wp_loaded() |
|
564 | + { |
|
565 | + } |
|
566 | + |
|
567 | + |
|
568 | + /** |
|
569 | + * admin_init |
|
570 | + * |
|
571 | + * @return void |
|
572 | + * @throws EE_Error |
|
573 | + * @throws InvalidArgumentException |
|
574 | + * @throws InvalidDataTypeException |
|
575 | + * @throws InvalidInterfaceException |
|
576 | + * @throws ReflectionException |
|
577 | + */ |
|
578 | + public function admin_init() |
|
579 | + { |
|
580 | + |
|
581 | + /** |
|
582 | + * our cpt models must be instantiated on WordPress post processing routes (wp-admin/post.php), |
|
583 | + * so any hooking into core WP routes is taken care of. So in this next few lines of code: |
|
584 | + * - check if doing post processing. |
|
585 | + * - check if doing post processing of one of EE CPTs |
|
586 | + * - instantiate the corresponding EE CPT model for the post_type being processed. |
|
587 | + */ |
|
588 | + if (isset($_POST['action'], $_POST['post_type']) && $_POST['action'] === 'editpost') { |
|
589 | + /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */ |
|
590 | + $custom_post_types = LoaderFactory::getLoader()->getShared( |
|
591 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
592 | + ); |
|
593 | + $custom_post_types->getCustomPostTypeModels($_POST['post_type']); |
|
594 | + } |
|
595 | + |
|
596 | + |
|
597 | + /** |
|
598 | + * This code excludes EE critical pages anywhere `wp_dropdown_pages` is used to create a dropdown for selecting |
|
599 | + * critical pages. The only place critical pages need included in a generated dropdown is on the "Critical |
|
600 | + * Pages" tab in the EE General Settings Admin page. |
|
601 | + * This is for user-proofing. |
|
602 | + */ |
|
603 | + add_filter('wp_dropdown_pages', array($this, 'modify_dropdown_pages')); |
|
604 | + } |
|
605 | + |
|
606 | + |
|
607 | + /** |
|
608 | + * Callback for wp_dropdown_pages hook to remove ee critical pages from the dropdown selection. |
|
609 | + * |
|
610 | + * @param string $output Current output. |
|
611 | + * @return string |
|
612 | + * @throws InvalidArgumentException |
|
613 | + * @throws InvalidDataTypeException |
|
614 | + * @throws InvalidInterfaceException |
|
615 | + */ |
|
616 | + public function modify_dropdown_pages($output) |
|
617 | + { |
|
618 | + //get critical pages |
|
619 | + $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
|
620 | + |
|
621 | + //split current output by line break for easier parsing. |
|
622 | + $split_output = explode("\n", $output); |
|
623 | + |
|
624 | + //loop through to remove any critical pages from the array. |
|
625 | + foreach ($critical_pages as $page_id) { |
|
626 | + $needle = 'value="' . $page_id . '"'; |
|
627 | + foreach ($split_output as $key => $haystack) { |
|
628 | + if (strpos($haystack, $needle) !== false) { |
|
629 | + unset($split_output[$key]); |
|
630 | + } |
|
631 | + } |
|
632 | + } |
|
633 | + //replace output with the new contents |
|
634 | + return implode("\n", $split_output); |
|
635 | + } |
|
636 | + |
|
637 | + |
|
638 | + /** |
|
639 | + * enqueue all admin scripts that need loaded for admin pages |
|
640 | + * |
|
641 | + * @return void |
|
642 | + */ |
|
643 | + public function enqueue_admin_scripts() |
|
644 | + { |
|
645 | + // this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js. |
|
646 | + // Note: the intention of this script is to only do TARGETED injections. I.E, only injecting on certain script |
|
647 | + // calls. |
|
648 | + wp_enqueue_script( |
|
649 | + 'ee-inject-wp', |
|
650 | + EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js', |
|
651 | + array('jquery'), |
|
652 | + EVENT_ESPRESSO_VERSION, |
|
653 | + true |
|
654 | + ); |
|
655 | + // register cookie script for future dependencies |
|
656 | + wp_register_script( |
|
657 | + 'jquery-cookie', |
|
658 | + EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js', |
|
659 | + array('jquery'), |
|
660 | + '2.1', |
|
661 | + true |
|
662 | + ); |
|
663 | + //joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again |
|
664 | + // via: add_filter('FHEE_load_joyride', '__return_true' ); |
|
665 | + if (apply_filters('FHEE_load_joyride', false)) { |
|
666 | + //joyride style |
|
667 | + wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1'); |
|
668 | + wp_register_style( |
|
669 | + 'ee-joyride-css', |
|
670 | + EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css', |
|
671 | + array('joyride-css'), |
|
672 | + EVENT_ESPRESSO_VERSION |
|
673 | + ); |
|
674 | + wp_register_script( |
|
675 | + 'joyride-modernizr', |
|
676 | + EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js', |
|
677 | + array(), |
|
678 | + '2.1', |
|
679 | + true |
|
680 | + ); |
|
681 | + //joyride JS |
|
682 | + wp_register_script( |
|
683 | + 'jquery-joyride', |
|
684 | + EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js', |
|
685 | + array('jquery-cookie', 'joyride-modernizr'), |
|
686 | + '2.1', |
|
687 | + true |
|
688 | + ); |
|
689 | + // wanna go for a joyride? |
|
690 | + wp_enqueue_style('ee-joyride-css'); |
|
691 | + wp_enqueue_script('jquery-joyride'); |
|
692 | + } |
|
693 | + } |
|
694 | + |
|
695 | + |
|
696 | + /** |
|
697 | + * display_admin_notices |
|
698 | + * |
|
699 | + * @return void |
|
700 | + */ |
|
701 | + public function display_admin_notices() |
|
702 | + { |
|
703 | + echo EE_Error::get_notices(); |
|
704 | + } |
|
705 | + |
|
706 | + |
|
707 | + |
|
708 | + /** |
|
709 | + * @param array $elements |
|
710 | + * @return array |
|
711 | + * @throws EE_Error |
|
712 | + * @throws InvalidArgumentException |
|
713 | + * @throws InvalidDataTypeException |
|
714 | + * @throws InvalidInterfaceException |
|
715 | + */ |
|
716 | + public function dashboard_glance_items($elements) |
|
717 | + { |
|
718 | + $elements = is_array($elements) ? $elements : array($elements); |
|
719 | + $events = EEM_Event::instance()->count(); |
|
720 | + $items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
721 | + array('page' => 'espresso_events'), |
|
722 | + admin_url('admin.php') |
|
723 | + ); |
|
724 | + $items['events']['text'] = sprintf(_n('%s Event', '%s Events', $events), number_format_i18n($events)); |
|
725 | + $items['events']['title'] = esc_html__('Click to view all Events', 'event_espresso'); |
|
726 | + $registrations = EEM_Registration::instance()->count( |
|
727 | + array( |
|
728 | + array( |
|
729 | + 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete), |
|
730 | + ), |
|
731 | + ) |
|
732 | + ); |
|
733 | + $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
734 | + array('page' => 'espresso_registrations'), |
|
735 | + admin_url('admin.php') |
|
736 | + ); |
|
737 | + $items['registrations']['text'] = sprintf( |
|
738 | + _n('%s Registration', '%s Registrations', $registrations), |
|
739 | + number_format_i18n($registrations) |
|
740 | + ); |
|
741 | + $items['registrations']['title'] = esc_html__('Click to view all registrations', 'event_espresso'); |
|
742 | + |
|
743 | + $items = (array)apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items); |
|
744 | + |
|
745 | + foreach ($items as $type => $item_properties) { |
|
746 | + $elements[] = sprintf( |
|
747 | + '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>', |
|
748 | + $item_properties['url'], |
|
749 | + $item_properties['title'], |
|
750 | + $item_properties['text'] |
|
751 | + ); |
|
752 | + } |
|
753 | + return $elements; |
|
754 | + } |
|
755 | + |
|
756 | + |
|
757 | + /** |
|
758 | + * check_for_invalid_datetime_formats |
|
759 | + * if an admin changes their date or time format settings on the WP General Settings admin page, verify that |
|
760 | + * their selected format can be parsed by PHP |
|
761 | + * |
|
762 | + * @param $value |
|
763 | + * @param $option |
|
764 | + * @throws EE_Error |
|
765 | + * @return string |
|
766 | + */ |
|
767 | + public function check_for_invalid_datetime_formats($value, $option) |
|
768 | + { |
|
769 | + // check for date_format or time_format |
|
770 | + switch ($option) { |
|
771 | + case 'date_format': |
|
772 | + $date_time_format = $value . ' ' . get_option('time_format'); |
|
773 | + break; |
|
774 | + case 'time_format': |
|
775 | + $date_time_format = get_option('date_format') . ' ' . $value; |
|
776 | + break; |
|
777 | + default: |
|
778 | + $date_time_format = false; |
|
779 | + } |
|
780 | + // do we have a date_time format to check ? |
|
781 | + if ($date_time_format) { |
|
782 | + $error_msg = EEH_DTT_Helper::validate_format_string($date_time_format); |
|
783 | + |
|
784 | + if (is_array($error_msg)) { |
|
785 | + $msg = '<p>' |
|
786 | + . sprintf( |
|
787 | + esc_html__( |
|
788 | + 'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:', |
|
789 | + 'event_espresso' |
|
790 | + ), |
|
791 | + date($date_time_format), |
|
792 | + $date_time_format |
|
793 | + ) |
|
794 | + . '</p><p><ul>'; |
|
795 | + |
|
796 | + |
|
797 | + foreach ($error_msg as $error) { |
|
798 | + $msg .= '<li>' . $error . '</li>'; |
|
799 | + } |
|
800 | + |
|
801 | + $msg .= '</ul></p><p>' |
|
802 | + . sprintf( |
|
803 | + esc_html__( |
|
804 | + '%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s', |
|
805 | + 'event_espresso' |
|
806 | + ), |
|
807 | + '<span style="color:#D54E21;">', |
|
808 | + '</span>' |
|
809 | + ) |
|
810 | + . '</p>'; |
|
811 | + |
|
812 | + // trigger WP settings error |
|
813 | + add_settings_error( |
|
814 | + 'date_format', |
|
815 | + 'date_format', |
|
816 | + $msg |
|
817 | + ); |
|
818 | + |
|
819 | + // set format to something valid |
|
820 | + switch ($option) { |
|
821 | + case 'date_format': |
|
822 | + $value = 'F j, Y'; |
|
823 | + break; |
|
824 | + case 'time_format': |
|
825 | + $value = 'g:i a'; |
|
826 | + break; |
|
827 | + } |
|
828 | + } |
|
829 | + } |
|
830 | + return $value; |
|
831 | + } |
|
832 | + |
|
833 | + |
|
834 | + /** |
|
835 | + * its_eSpresso - converts the less commonly used spelling of "Expresso" to "Espresso" |
|
836 | + * |
|
837 | + * @param $content |
|
838 | + * @return string |
|
839 | + */ |
|
840 | + public function its_eSpresso($content) |
|
841 | + { |
|
842 | + return str_replace('[EXPRESSO_', '[ESPRESSO_', $content); |
|
843 | + } |
|
844 | + |
|
845 | + |
|
846 | + /** |
|
847 | + * espresso_admin_footer |
|
848 | + * |
|
849 | + * @return string |
|
850 | + */ |
|
851 | + public function espresso_admin_footer() |
|
852 | + { |
|
853 | + return \EEH_Template::powered_by_event_espresso('aln-cntr', '', array('utm_content' => 'admin_footer')); |
|
854 | + } |
|
855 | + |
|
856 | + |
|
857 | + /** |
|
858 | + * static method for registering ee admin page. |
|
859 | + * This method is deprecated in favor of the new location in EE_Register_Admin_Page::register. |
|
860 | + * |
|
861 | + * @since 4.3.0 |
|
862 | + * @deprecated 4.3.0 Use EE_Register_Admin_Page::register() instead |
|
863 | + * @see EE_Register_Admin_Page::register() |
|
864 | + * @param $page_basename |
|
865 | + * @param $page_path |
|
866 | + * @param array $config |
|
867 | + * @return void |
|
868 | + * @throws EE_Error |
|
869 | + */ |
|
870 | + public static function register_ee_admin_page($page_basename, $page_path, $config = array()) |
|
871 | + { |
|
872 | + EE_Error::doing_it_wrong( |
|
873 | + __METHOD__, |
|
874 | + sprintf( |
|
875 | + esc_html__( |
|
876 | + 'Usage is deprecated. Use EE_Register_Admin_Page::register() for registering the %s admin page.', |
|
877 | + 'event_espresso' |
|
878 | + ), |
|
879 | + $page_basename |
|
880 | + ), |
|
881 | + '4.3' |
|
882 | + ); |
|
883 | + if (class_exists('EE_Register_Admin_Page')) { |
|
884 | + $config['page_path'] = $page_path; |
|
885 | + } |
|
886 | + EE_Register_Admin_Page::register($page_basename, $config); |
|
887 | + } |
|
888 | + |
|
889 | + |
|
890 | + /** |
|
891 | + * @deprecated 4.8.41 |
|
892 | + * @param int $post_ID |
|
893 | + * @param \WP_Post $post |
|
894 | + * @return void |
|
895 | + */ |
|
896 | + public static function parse_post_content_on_save($post_ID, $post) |
|
897 | + { |
|
898 | + EE_Error::doing_it_wrong( |
|
899 | + __METHOD__, |
|
900 | + esc_html__('Usage is deprecated', 'event_espresso'), |
|
901 | + '4.8.41' |
|
902 | + ); |
|
903 | + } |
|
904 | + |
|
905 | + |
|
906 | + /** |
|
907 | + * @deprecated 4.8.41 |
|
908 | + * @param $option |
|
909 | + * @param $old_value |
|
910 | + * @param $value |
|
911 | + * @return void |
|
912 | + */ |
|
913 | + public function reset_page_for_posts_on_change($option, $old_value, $value) |
|
914 | + { |
|
915 | + EE_Error::doing_it_wrong( |
|
916 | + __METHOD__, |
|
917 | + esc_html__('Usage is deprecated', 'event_espresso'), |
|
918 | + '4.8.41' |
|
919 | + ); |
|
920 | + } |
|
921 | + |
|
922 | + |
|
923 | + |
|
924 | + /** |
|
925 | + * @deprecated 4.9.27 |
|
926 | + * @return void |
|
927 | + */ |
|
928 | + public function get_persistent_admin_notices() |
|
929 | + { |
|
930 | + EE_Error::doing_it_wrong( |
|
931 | + __METHOD__, |
|
932 | + sprintf( |
|
933 | + __('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), |
|
934 | + '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
935 | + ), |
|
936 | + '4.9.27' |
|
937 | + ); |
|
938 | + } |
|
939 | + |
|
940 | + |
|
941 | + |
|
942 | + /** |
|
943 | + * @deprecated 4.9.27 |
|
944 | + * @throws InvalidInterfaceException |
|
945 | + * @throws InvalidDataTypeException |
|
946 | + * @throws DomainException |
|
947 | + */ |
|
948 | + public function dismiss_ee_nag_notice_callback() |
|
949 | + { |
|
950 | + EE_Error::doing_it_wrong( |
|
951 | + __METHOD__, |
|
952 | + sprintf( |
|
953 | + __('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), |
|
954 | + '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
955 | + ), |
|
956 | + '4.9.27' |
|
957 | + ); |
|
958 | + $this->persistent_admin_notice_manager->dismissNotice(); |
|
959 | + } |
|
960 | + |
|
961 | + |
|
962 | + /** |
|
963 | + * Callback on load-plugins.php hook for setting up anything hooking into the wp plugins page. |
|
964 | + * @throws InvalidArgumentException |
|
965 | + * @throws InvalidDataTypeException |
|
966 | + * @throws InvalidInterfaceException |
|
967 | + */ |
|
968 | + public function hookIntoWpPluginsPage() |
|
969 | + { |
|
970 | + LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\services\admin\ExitModal'); |
|
971 | + LoaderFactory::getLoader() |
|
972 | + ->getShared('EventEspresso\core\domain\services\admin\PluginUpsells') |
|
973 | + ->decafUpsells(); |
|
974 | + } |
|
975 | 975 | } |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | use EventEspresso\core\services\loaders\LoaderFactory; |
6 | 6 | |
7 | 7 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
8 | - exit('NO direct script access allowed'); |
|
8 | + exit('NO direct script access allowed'); |
|
9 | 9 | } |
10 | 10 | /** |
11 | 11 | * Event Espresso |
@@ -21,35 +21,35 @@ discard block |
||
21 | 21 | |
22 | 22 | |
23 | 23 | if ( ! function_exists('espresso_get_template_part')) { |
24 | - /** |
|
25 | - * espresso_get_template_part |
|
26 | - * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files |
|
27 | - * so not a very useful function at all except that it adds familiarity PLUS filtering based off of the entire template part name |
|
28 | - * |
|
29 | - * @param string $slug The slug name for the generic template. |
|
30 | - * @param string $name The name of the specialised template. |
|
31 | - * @return string the html output for the formatted money value |
|
32 | - */ |
|
33 | - function espresso_get_template_part($slug = null, $name = null) |
|
34 | - { |
|
35 | - EEH_Template::get_template_part($slug, $name); |
|
36 | - } |
|
24 | + /** |
|
25 | + * espresso_get_template_part |
|
26 | + * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files |
|
27 | + * so not a very useful function at all except that it adds familiarity PLUS filtering based off of the entire template part name |
|
28 | + * |
|
29 | + * @param string $slug The slug name for the generic template. |
|
30 | + * @param string $name The name of the specialised template. |
|
31 | + * @return string the html output for the formatted money value |
|
32 | + */ |
|
33 | + function espresso_get_template_part($slug = null, $name = null) |
|
34 | + { |
|
35 | + EEH_Template::get_template_part($slug, $name); |
|
36 | + } |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | |
40 | 40 | if ( ! function_exists('espresso_get_object_css_class')) { |
41 | - /** |
|
42 | - * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed |
|
43 | - * |
|
44 | - * @param EE_Base_Class $object the EE object the css class is being generated for |
|
45 | - * @param string $prefix added to the beginning of the generated class |
|
46 | - * @param string $suffix added to the end of the generated class |
|
47 | - * @return string |
|
48 | - */ |
|
49 | - function espresso_get_object_css_class($object = null, $prefix = '', $suffix = '') |
|
50 | - { |
|
51 | - return EEH_Template::get_object_css_class($object, $prefix, $suffix); |
|
52 | - } |
|
41 | + /** |
|
42 | + * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed |
|
43 | + * |
|
44 | + * @param EE_Base_Class $object the EE object the css class is being generated for |
|
45 | + * @param string $prefix added to the beginning of the generated class |
|
46 | + * @param string $suffix added to the end of the generated class |
|
47 | + * @return string |
|
48 | + */ |
|
49 | + function espresso_get_object_css_class($object = null, $prefix = '', $suffix = '') |
|
50 | + { |
|
51 | + return EEH_Template::get_object_css_class($object, $prefix, $suffix); |
|
52 | + } |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | |
@@ -64,658 +64,658 @@ discard block |
||
64 | 64 | class EEH_Template |
65 | 65 | { |
66 | 66 | |
67 | - private static $_espresso_themes = array(); |
|
68 | - |
|
69 | - |
|
70 | - /** |
|
71 | - * is_espresso_theme - returns TRUE or FALSE on whether the currently active WP theme is an espresso theme |
|
72 | - * |
|
73 | - * @return boolean |
|
74 | - */ |
|
75 | - public static function is_espresso_theme() |
|
76 | - { |
|
77 | - return wp_get_theme()->get('TextDomain') == 'event_espresso' ? true : false; |
|
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * load_espresso_theme_functions - if current theme is an espresso theme, or uses ee theme template parts, then |
|
82 | - * load it's functions.php file ( if not already loaded ) |
|
83 | - * |
|
84 | - * @return void |
|
85 | - */ |
|
86 | - public static function load_espresso_theme_functions() |
|
87 | - { |
|
88 | - if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) { |
|
89 | - if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php')) { |
|
90 | - require_once(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php'); |
|
91 | - } |
|
92 | - } |
|
93 | - } |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * get_espresso_themes - returns an array of Espresso Child themes located in the /templates/ directory |
|
98 | - * |
|
99 | - * @return array |
|
100 | - */ |
|
101 | - public static function get_espresso_themes() |
|
102 | - { |
|
103 | - if (empty(EEH_Template::$_espresso_themes)) { |
|
104 | - $espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR); |
|
105 | - if (empty($espresso_themes)) { |
|
106 | - return array(); |
|
107 | - } |
|
108 | - if (($key = array_search('global_assets', $espresso_themes)) !== false) { |
|
109 | - unset($espresso_themes[$key]); |
|
110 | - } |
|
111 | - EEH_Template::$_espresso_themes = array(); |
|
112 | - foreach ($espresso_themes as $espresso_theme) { |
|
113 | - EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme; |
|
114 | - } |
|
115 | - } |
|
116 | - return EEH_Template::$_espresso_themes; |
|
117 | - } |
|
118 | - |
|
119 | - |
|
120 | - /** |
|
121 | - * EEH_Template::get_template_part |
|
122 | - * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, |
|
123 | - * and doesn't add base versions of files so not a very useful function at all except that it adds familiarity PLUS |
|
124 | - * filtering based off of the entire template part name |
|
125 | - * |
|
126 | - * @param string $slug The slug name for the generic template. |
|
127 | - * @param string $name The name of the specialised template. |
|
128 | - * @param array $template_args |
|
129 | - * @param bool $return_string |
|
130 | - * @return string the html output for the formatted money value |
|
131 | - */ |
|
132 | - public static function get_template_part( |
|
133 | - $slug = null, |
|
134 | - $name = null, |
|
135 | - $template_args = array(), |
|
136 | - $return_string = false |
|
137 | - ) { |
|
138 | - do_action("get_template_part_{$slug}-{$name}", $slug, $name); |
|
139 | - $templates = array(); |
|
140 | - $name = (string)$name; |
|
141 | - if ($name != '') { |
|
142 | - $templates[] = "{$slug}-{$name}.php"; |
|
143 | - } |
|
144 | - // allow template parts to be turned off via something like: add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' ); |
|
145 | - if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", true)) { |
|
146 | - EEH_Template::locate_template($templates, $template_args, true, $return_string); |
|
147 | - } |
|
148 | - } |
|
149 | - |
|
150 | - |
|
151 | - /** |
|
152 | - * locate_template |
|
153 | - * locate a template file by looking in the following places, in the following order: |
|
154 | - * <server path up to>/wp-content/themes/<current active WordPress theme>/ |
|
155 | - * <assumed full absolute server path> |
|
156 | - * <server path up to>/wp-content/uploads/espresso/templates/<current EE theme>/ |
|
157 | - * <server path up to>/wp-content/uploads/espresso/templates/ |
|
158 | - * <server path up to>/wp-content/plugins/<EE4 folder>/public/<current EE theme>/ |
|
159 | - * <server path up to>/wp-content/plugins/<EE4 folder>/core/templates/<current EE theme>/ |
|
160 | - * <server path up to>/wp-content/plugins/<EE4 folder>/ |
|
161 | - * as soon as the template is found in one of these locations, it will be returned or loaded |
|
162 | - * Example: |
|
163 | - * You are using the WordPress Twenty Sixteen theme, |
|
164 | - * and you want to customize the "some-event.template.php" template, |
|
165 | - * which is located in the "/relative/path/to/" folder relative to the main EE plugin folder. |
|
166 | - * Assuming WP is installed on your server in the "/home/public_html/" folder, |
|
167 | - * EEH_Template::locate_template() will look at the following paths in order until the template is found: |
|
168 | - * /home/public_html/wp-content/themes/twentysixteen/some-event.template.php |
|
169 | - * /relative/path/to/some-event.template.php |
|
170 | - * /home/public_html/wp-content/uploads/espresso/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php |
|
171 | - * /home/public_html/wp-content/uploads/espresso/templates/relative/path/to/some-event.template.php |
|
172 | - * /home/public_html/wp-content/plugins/event-espresso-core-reg/public/Espresso_Arabica_2014/relative/path/to/some-event.template.php |
|
173 | - * /home/public_html/wp-content/plugins/event-espresso-core-reg/core/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php |
|
174 | - * /home/public_html/wp-content/plugins/event-espresso-core-reg/relative/path/to/some-event.template.php |
|
175 | - * Had you passed an absolute path to your template that was in some other location, |
|
176 | - * ie: "/absolute/path/to/some-event.template.php" |
|
177 | - * then the search would have been : |
|
178 | - * /home/public_html/wp-content/themes/twentysixteen/some-event.template.php |
|
179 | - * /absolute/path/to/some-event.template.php |
|
180 | - * and stopped there upon finding it in the second location |
|
181 | - * |
|
182 | - * @param array|string $templates array of template file names including extension (or just a single string) |
|
183 | - * @param array $template_args an array of arguments to be extracted for use in the template |
|
184 | - * @param boolean $load whether to pass the located template path on to the |
|
185 | - * EEH_Template::display_template() method or simply return it |
|
186 | - * @param boolean $return_string whether to send output immediately to screen, or capture and return as a |
|
187 | - * string |
|
188 | - * @param boolean $check_if_custom If TRUE, this flags this method to return boolean for whether this will |
|
189 | - * generate a custom template or not. Used in places where you don't actually |
|
190 | - * load the template, you just want to know if there's a custom version of it. |
|
191 | - * @return mixed |
|
192 | - * @throws DomainException |
|
193 | - * @throws InvalidArgumentException |
|
194 | - * @throws InvalidDataTypeException |
|
195 | - * @throws InvalidInterfaceException |
|
196 | - */ |
|
197 | - public static function locate_template( |
|
198 | - $templates = array(), |
|
199 | - $template_args = array(), |
|
200 | - $load = true, |
|
201 | - $return_string = true, |
|
202 | - $check_if_custom = false |
|
203 | - ) { |
|
204 | - // first use WP locate_template to check for template in the current theme folder |
|
205 | - $template_path = locate_template($templates); |
|
206 | - |
|
207 | - if ($check_if_custom && ! empty($template_path)) { |
|
208 | - return true; |
|
209 | - } |
|
210 | - |
|
211 | - // not in the theme |
|
212 | - if (empty($template_path)) { |
|
213 | - // not even a template to look for ? |
|
214 | - if (empty($templates)) { |
|
215 | - // get post_type |
|
216 | - $post_type = EE_Registry::instance()->REQ->get('post_type'); |
|
217 | - /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */ |
|
218 | - $custom_post_types = LoaderFactory::getLoader()->getShared( |
|
219 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
220 | - ); |
|
221 | - // get array of EE Custom Post Types |
|
222 | - $EE_CPTs = $custom_post_types->getDefinitions(); |
|
223 | - // build template name based on request |
|
224 | - if (isset($EE_CPTs[$post_type])) { |
|
225 | - $archive_or_single = is_archive() ? 'archive' : ''; |
|
226 | - $archive_or_single = is_single() ? 'single' : $archive_or_single; |
|
227 | - $templates = $archive_or_single . '-' . $post_type . '.php'; |
|
228 | - } |
|
229 | - } |
|
230 | - // currently active EE template theme |
|
231 | - $current_theme = EE_Config::get_current_theme(); |
|
232 | - |
|
233 | - // array of paths to folders that may contain templates |
|
234 | - $template_folder_paths = array( |
|
235 | - // first check the /wp-content/uploads/espresso/templates/(current EE theme)/ folder for an EE theme template file |
|
236 | - EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme, |
|
237 | - // then in the root of the /wp-content/uploads/espresso/templates/ folder |
|
238 | - EVENT_ESPRESSO_TEMPLATE_DIR, |
|
239 | - ); |
|
240 | - |
|
241 | - //add core plugin folders for checking only if we're not $check_if_custom |
|
242 | - if ( ! $check_if_custom) { |
|
243 | - $core_paths = array( |
|
244 | - // in the /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin |
|
245 | - EE_PUBLIC . $current_theme, |
|
246 | - // in the /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin |
|
247 | - EE_TEMPLATES . $current_theme, |
|
248 | - // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/ |
|
249 | - EE_PLUGIN_DIR_PATH, |
|
250 | - ); |
|
251 | - $template_folder_paths = array_merge($template_folder_paths, $core_paths); |
|
252 | - } |
|
253 | - |
|
254 | - // now filter that array |
|
255 | - $template_folder_paths = apply_filters('FHEE__EEH_Template__locate_template__template_folder_paths', |
|
256 | - $template_folder_paths); |
|
257 | - $templates = is_array($templates) ? $templates : array($templates); |
|
258 | - $template_folder_paths = is_array($template_folder_paths) ? $template_folder_paths : array($template_folder_paths); |
|
259 | - // array to hold all possible template paths |
|
260 | - $full_template_paths = array(); |
|
261 | - |
|
262 | - // loop through $templates |
|
263 | - foreach ($templates as $template) { |
|
264 | - // normalize directory separators |
|
265 | - $template = EEH_File::standardise_directory_separators($template); |
|
266 | - $file_name = basename($template); |
|
267 | - $template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1)); |
|
268 | - // while looping through all template folder paths |
|
269 | - foreach ($template_folder_paths as $template_folder_path) { |
|
270 | - // normalize directory separators |
|
271 | - $template_folder_path = EEH_File::standardise_directory_separators($template_folder_path); |
|
272 | - // determine if any common base path exists between the two paths |
|
273 | - $common_base_path = EEH_Template::_find_common_base_path( |
|
274 | - array($template_folder_path, $template_path_minus_file_name) |
|
275 | - ); |
|
276 | - if ($common_base_path !== '') { |
|
277 | - // both paths have a common base, so just tack the filename onto our search path |
|
278 | - $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name; |
|
279 | - } else { |
|
280 | - // no common base path, so let's just concatenate |
|
281 | - $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template; |
|
282 | - } |
|
283 | - // build up our template locations array by adding our resolved paths |
|
284 | - $full_template_paths[] = $resolved_path; |
|
285 | - } |
|
286 | - // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first |
|
287 | - array_unshift($full_template_paths, $template); |
|
288 | - // path to the directory of the current theme: /wp-content/themes/(current WP theme)/ |
|
289 | - array_unshift($full_template_paths, get_stylesheet_directory() . DS . $file_name); |
|
290 | - } |
|
291 | - // filter final array of full template paths |
|
292 | - $full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths', |
|
293 | - $full_template_paths, $file_name); |
|
294 | - // now loop through our final array of template location paths and check each location |
|
295 | - foreach ((array)$full_template_paths as $full_template_path) { |
|
296 | - if (is_readable($full_template_path)) { |
|
297 | - $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path); |
|
298 | - break; |
|
299 | - } |
|
300 | - } |
|
301 | - } |
|
302 | - |
|
303 | - // hook that can be used to display the full template path that will be used |
|
304 | - do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path); |
|
305 | - |
|
306 | - // if we got it and you want to see it... |
|
307 | - if ($template_path && $load && ! $check_if_custom) { |
|
308 | - if ($return_string) { |
|
309 | - return EEH_Template::display_template($template_path, $template_args, true); |
|
310 | - } else { |
|
311 | - EEH_Template::display_template($template_path, $template_args, false); |
|
312 | - } |
|
313 | - } |
|
314 | - return $check_if_custom && ! empty($template_path) ? true : $template_path; |
|
315 | - } |
|
316 | - |
|
317 | - |
|
318 | - /** |
|
319 | - * _find_common_base_path |
|
320 | - * given two paths, this determines if there is a common base path between the two |
|
321 | - * |
|
322 | - * @param array $paths |
|
323 | - * @return string |
|
324 | - */ |
|
325 | - protected static function _find_common_base_path($paths) |
|
326 | - { |
|
327 | - $last_offset = 0; |
|
328 | - $common_base_path = ''; |
|
329 | - while (($index = strpos($paths[0], DS, $last_offset)) !== false) { |
|
330 | - $dir_length = $index - $last_offset + 1; |
|
331 | - $directory = substr($paths[0], $last_offset, $dir_length); |
|
332 | - foreach ($paths as $path) { |
|
333 | - if (substr($path, $last_offset, $dir_length) != $directory) { |
|
334 | - return $common_base_path; |
|
335 | - } |
|
336 | - } |
|
337 | - $common_base_path .= $directory; |
|
338 | - $last_offset = $index + 1; |
|
339 | - } |
|
340 | - return substr($common_base_path, 0, -1); |
|
341 | - } |
|
342 | - |
|
343 | - |
|
344 | - /** |
|
345 | - * load and display a template |
|
346 | - * |
|
347 | - * @param bool|string $template_path server path to the file to be loaded, including file name and extension |
|
348 | - * @param array $template_args an array of arguments to be extracted for use in the template |
|
349 | - * @param boolean $return_string whether to send output immediately to screen, or capture and return as a string |
|
350 | - * @param bool $throw_exceptions if set to true, will throw an exception if the template is either |
|
351 | - * not found or is not readable |
|
352 | - * @return mixed string |
|
353 | - * @throws \DomainException |
|
354 | - */ |
|
67 | + private static $_espresso_themes = array(); |
|
68 | + |
|
69 | + |
|
70 | + /** |
|
71 | + * is_espresso_theme - returns TRUE or FALSE on whether the currently active WP theme is an espresso theme |
|
72 | + * |
|
73 | + * @return boolean |
|
74 | + */ |
|
75 | + public static function is_espresso_theme() |
|
76 | + { |
|
77 | + return wp_get_theme()->get('TextDomain') == 'event_espresso' ? true : false; |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * load_espresso_theme_functions - if current theme is an espresso theme, or uses ee theme template parts, then |
|
82 | + * load it's functions.php file ( if not already loaded ) |
|
83 | + * |
|
84 | + * @return void |
|
85 | + */ |
|
86 | + public static function load_espresso_theme_functions() |
|
87 | + { |
|
88 | + if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) { |
|
89 | + if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php')) { |
|
90 | + require_once(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php'); |
|
91 | + } |
|
92 | + } |
|
93 | + } |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * get_espresso_themes - returns an array of Espresso Child themes located in the /templates/ directory |
|
98 | + * |
|
99 | + * @return array |
|
100 | + */ |
|
101 | + public static function get_espresso_themes() |
|
102 | + { |
|
103 | + if (empty(EEH_Template::$_espresso_themes)) { |
|
104 | + $espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR); |
|
105 | + if (empty($espresso_themes)) { |
|
106 | + return array(); |
|
107 | + } |
|
108 | + if (($key = array_search('global_assets', $espresso_themes)) !== false) { |
|
109 | + unset($espresso_themes[$key]); |
|
110 | + } |
|
111 | + EEH_Template::$_espresso_themes = array(); |
|
112 | + foreach ($espresso_themes as $espresso_theme) { |
|
113 | + EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme; |
|
114 | + } |
|
115 | + } |
|
116 | + return EEH_Template::$_espresso_themes; |
|
117 | + } |
|
118 | + |
|
119 | + |
|
120 | + /** |
|
121 | + * EEH_Template::get_template_part |
|
122 | + * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, |
|
123 | + * and doesn't add base versions of files so not a very useful function at all except that it adds familiarity PLUS |
|
124 | + * filtering based off of the entire template part name |
|
125 | + * |
|
126 | + * @param string $slug The slug name for the generic template. |
|
127 | + * @param string $name The name of the specialised template. |
|
128 | + * @param array $template_args |
|
129 | + * @param bool $return_string |
|
130 | + * @return string the html output for the formatted money value |
|
131 | + */ |
|
132 | + public static function get_template_part( |
|
133 | + $slug = null, |
|
134 | + $name = null, |
|
135 | + $template_args = array(), |
|
136 | + $return_string = false |
|
137 | + ) { |
|
138 | + do_action("get_template_part_{$slug}-{$name}", $slug, $name); |
|
139 | + $templates = array(); |
|
140 | + $name = (string)$name; |
|
141 | + if ($name != '') { |
|
142 | + $templates[] = "{$slug}-{$name}.php"; |
|
143 | + } |
|
144 | + // allow template parts to be turned off via something like: add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' ); |
|
145 | + if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", true)) { |
|
146 | + EEH_Template::locate_template($templates, $template_args, true, $return_string); |
|
147 | + } |
|
148 | + } |
|
149 | + |
|
150 | + |
|
151 | + /** |
|
152 | + * locate_template |
|
153 | + * locate a template file by looking in the following places, in the following order: |
|
154 | + * <server path up to>/wp-content/themes/<current active WordPress theme>/ |
|
155 | + * <assumed full absolute server path> |
|
156 | + * <server path up to>/wp-content/uploads/espresso/templates/<current EE theme>/ |
|
157 | + * <server path up to>/wp-content/uploads/espresso/templates/ |
|
158 | + * <server path up to>/wp-content/plugins/<EE4 folder>/public/<current EE theme>/ |
|
159 | + * <server path up to>/wp-content/plugins/<EE4 folder>/core/templates/<current EE theme>/ |
|
160 | + * <server path up to>/wp-content/plugins/<EE4 folder>/ |
|
161 | + * as soon as the template is found in one of these locations, it will be returned or loaded |
|
162 | + * Example: |
|
163 | + * You are using the WordPress Twenty Sixteen theme, |
|
164 | + * and you want to customize the "some-event.template.php" template, |
|
165 | + * which is located in the "/relative/path/to/" folder relative to the main EE plugin folder. |
|
166 | + * Assuming WP is installed on your server in the "/home/public_html/" folder, |
|
167 | + * EEH_Template::locate_template() will look at the following paths in order until the template is found: |
|
168 | + * /home/public_html/wp-content/themes/twentysixteen/some-event.template.php |
|
169 | + * /relative/path/to/some-event.template.php |
|
170 | + * /home/public_html/wp-content/uploads/espresso/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php |
|
171 | + * /home/public_html/wp-content/uploads/espresso/templates/relative/path/to/some-event.template.php |
|
172 | + * /home/public_html/wp-content/plugins/event-espresso-core-reg/public/Espresso_Arabica_2014/relative/path/to/some-event.template.php |
|
173 | + * /home/public_html/wp-content/plugins/event-espresso-core-reg/core/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php |
|
174 | + * /home/public_html/wp-content/plugins/event-espresso-core-reg/relative/path/to/some-event.template.php |
|
175 | + * Had you passed an absolute path to your template that was in some other location, |
|
176 | + * ie: "/absolute/path/to/some-event.template.php" |
|
177 | + * then the search would have been : |
|
178 | + * /home/public_html/wp-content/themes/twentysixteen/some-event.template.php |
|
179 | + * /absolute/path/to/some-event.template.php |
|
180 | + * and stopped there upon finding it in the second location |
|
181 | + * |
|
182 | + * @param array|string $templates array of template file names including extension (or just a single string) |
|
183 | + * @param array $template_args an array of arguments to be extracted for use in the template |
|
184 | + * @param boolean $load whether to pass the located template path on to the |
|
185 | + * EEH_Template::display_template() method or simply return it |
|
186 | + * @param boolean $return_string whether to send output immediately to screen, or capture and return as a |
|
187 | + * string |
|
188 | + * @param boolean $check_if_custom If TRUE, this flags this method to return boolean for whether this will |
|
189 | + * generate a custom template or not. Used in places where you don't actually |
|
190 | + * load the template, you just want to know if there's a custom version of it. |
|
191 | + * @return mixed |
|
192 | + * @throws DomainException |
|
193 | + * @throws InvalidArgumentException |
|
194 | + * @throws InvalidDataTypeException |
|
195 | + * @throws InvalidInterfaceException |
|
196 | + */ |
|
197 | + public static function locate_template( |
|
198 | + $templates = array(), |
|
199 | + $template_args = array(), |
|
200 | + $load = true, |
|
201 | + $return_string = true, |
|
202 | + $check_if_custom = false |
|
203 | + ) { |
|
204 | + // first use WP locate_template to check for template in the current theme folder |
|
205 | + $template_path = locate_template($templates); |
|
206 | + |
|
207 | + if ($check_if_custom && ! empty($template_path)) { |
|
208 | + return true; |
|
209 | + } |
|
210 | + |
|
211 | + // not in the theme |
|
212 | + if (empty($template_path)) { |
|
213 | + // not even a template to look for ? |
|
214 | + if (empty($templates)) { |
|
215 | + // get post_type |
|
216 | + $post_type = EE_Registry::instance()->REQ->get('post_type'); |
|
217 | + /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */ |
|
218 | + $custom_post_types = LoaderFactory::getLoader()->getShared( |
|
219 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
220 | + ); |
|
221 | + // get array of EE Custom Post Types |
|
222 | + $EE_CPTs = $custom_post_types->getDefinitions(); |
|
223 | + // build template name based on request |
|
224 | + if (isset($EE_CPTs[$post_type])) { |
|
225 | + $archive_or_single = is_archive() ? 'archive' : ''; |
|
226 | + $archive_or_single = is_single() ? 'single' : $archive_or_single; |
|
227 | + $templates = $archive_or_single . '-' . $post_type . '.php'; |
|
228 | + } |
|
229 | + } |
|
230 | + // currently active EE template theme |
|
231 | + $current_theme = EE_Config::get_current_theme(); |
|
232 | + |
|
233 | + // array of paths to folders that may contain templates |
|
234 | + $template_folder_paths = array( |
|
235 | + // first check the /wp-content/uploads/espresso/templates/(current EE theme)/ folder for an EE theme template file |
|
236 | + EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme, |
|
237 | + // then in the root of the /wp-content/uploads/espresso/templates/ folder |
|
238 | + EVENT_ESPRESSO_TEMPLATE_DIR, |
|
239 | + ); |
|
240 | + |
|
241 | + //add core plugin folders for checking only if we're not $check_if_custom |
|
242 | + if ( ! $check_if_custom) { |
|
243 | + $core_paths = array( |
|
244 | + // in the /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin |
|
245 | + EE_PUBLIC . $current_theme, |
|
246 | + // in the /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin |
|
247 | + EE_TEMPLATES . $current_theme, |
|
248 | + // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/ |
|
249 | + EE_PLUGIN_DIR_PATH, |
|
250 | + ); |
|
251 | + $template_folder_paths = array_merge($template_folder_paths, $core_paths); |
|
252 | + } |
|
253 | + |
|
254 | + // now filter that array |
|
255 | + $template_folder_paths = apply_filters('FHEE__EEH_Template__locate_template__template_folder_paths', |
|
256 | + $template_folder_paths); |
|
257 | + $templates = is_array($templates) ? $templates : array($templates); |
|
258 | + $template_folder_paths = is_array($template_folder_paths) ? $template_folder_paths : array($template_folder_paths); |
|
259 | + // array to hold all possible template paths |
|
260 | + $full_template_paths = array(); |
|
261 | + |
|
262 | + // loop through $templates |
|
263 | + foreach ($templates as $template) { |
|
264 | + // normalize directory separators |
|
265 | + $template = EEH_File::standardise_directory_separators($template); |
|
266 | + $file_name = basename($template); |
|
267 | + $template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1)); |
|
268 | + // while looping through all template folder paths |
|
269 | + foreach ($template_folder_paths as $template_folder_path) { |
|
270 | + // normalize directory separators |
|
271 | + $template_folder_path = EEH_File::standardise_directory_separators($template_folder_path); |
|
272 | + // determine if any common base path exists between the two paths |
|
273 | + $common_base_path = EEH_Template::_find_common_base_path( |
|
274 | + array($template_folder_path, $template_path_minus_file_name) |
|
275 | + ); |
|
276 | + if ($common_base_path !== '') { |
|
277 | + // both paths have a common base, so just tack the filename onto our search path |
|
278 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name; |
|
279 | + } else { |
|
280 | + // no common base path, so let's just concatenate |
|
281 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template; |
|
282 | + } |
|
283 | + // build up our template locations array by adding our resolved paths |
|
284 | + $full_template_paths[] = $resolved_path; |
|
285 | + } |
|
286 | + // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first |
|
287 | + array_unshift($full_template_paths, $template); |
|
288 | + // path to the directory of the current theme: /wp-content/themes/(current WP theme)/ |
|
289 | + array_unshift($full_template_paths, get_stylesheet_directory() . DS . $file_name); |
|
290 | + } |
|
291 | + // filter final array of full template paths |
|
292 | + $full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths', |
|
293 | + $full_template_paths, $file_name); |
|
294 | + // now loop through our final array of template location paths and check each location |
|
295 | + foreach ((array)$full_template_paths as $full_template_path) { |
|
296 | + if (is_readable($full_template_path)) { |
|
297 | + $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path); |
|
298 | + break; |
|
299 | + } |
|
300 | + } |
|
301 | + } |
|
302 | + |
|
303 | + // hook that can be used to display the full template path that will be used |
|
304 | + do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path); |
|
305 | + |
|
306 | + // if we got it and you want to see it... |
|
307 | + if ($template_path && $load && ! $check_if_custom) { |
|
308 | + if ($return_string) { |
|
309 | + return EEH_Template::display_template($template_path, $template_args, true); |
|
310 | + } else { |
|
311 | + EEH_Template::display_template($template_path, $template_args, false); |
|
312 | + } |
|
313 | + } |
|
314 | + return $check_if_custom && ! empty($template_path) ? true : $template_path; |
|
315 | + } |
|
316 | + |
|
317 | + |
|
318 | + /** |
|
319 | + * _find_common_base_path |
|
320 | + * given two paths, this determines if there is a common base path between the two |
|
321 | + * |
|
322 | + * @param array $paths |
|
323 | + * @return string |
|
324 | + */ |
|
325 | + protected static function _find_common_base_path($paths) |
|
326 | + { |
|
327 | + $last_offset = 0; |
|
328 | + $common_base_path = ''; |
|
329 | + while (($index = strpos($paths[0], DS, $last_offset)) !== false) { |
|
330 | + $dir_length = $index - $last_offset + 1; |
|
331 | + $directory = substr($paths[0], $last_offset, $dir_length); |
|
332 | + foreach ($paths as $path) { |
|
333 | + if (substr($path, $last_offset, $dir_length) != $directory) { |
|
334 | + return $common_base_path; |
|
335 | + } |
|
336 | + } |
|
337 | + $common_base_path .= $directory; |
|
338 | + $last_offset = $index + 1; |
|
339 | + } |
|
340 | + return substr($common_base_path, 0, -1); |
|
341 | + } |
|
342 | + |
|
343 | + |
|
344 | + /** |
|
345 | + * load and display a template |
|
346 | + * |
|
347 | + * @param bool|string $template_path server path to the file to be loaded, including file name and extension |
|
348 | + * @param array $template_args an array of arguments to be extracted for use in the template |
|
349 | + * @param boolean $return_string whether to send output immediately to screen, or capture and return as a string |
|
350 | + * @param bool $throw_exceptions if set to true, will throw an exception if the template is either |
|
351 | + * not found or is not readable |
|
352 | + * @return mixed string |
|
353 | + * @throws \DomainException |
|
354 | + */ |
|
355 | 355 | public static function display_template( |
356 | - $template_path = false, |
|
357 | - $template_args = array(), |
|
358 | - $return_string = false, |
|
359 | - $throw_exceptions = false |
|
360 | - ) { |
|
361 | - |
|
362 | - /** |
|
363 | - * These two filters are intended for last minute changes to templates being loaded and/or template arg |
|
364 | - * modifications. NOTE... modifying these things can cause breakage as most templates running through |
|
365 | - * the display_template method are templates we DON'T want modified (usually because of js |
|
366 | - * dependencies etc). So unless you know what you are doing, do NOT filter templates or template args |
|
367 | - * using this. |
|
368 | - * |
|
369 | - * @since 4.6.0 |
|
370 | - */ |
|
371 | - $template_path = (string) apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path); |
|
372 | - $template_args = (array) apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args); |
|
373 | - |
|
374 | - // you gimme nuttin - YOU GET NUTTIN !! |
|
375 | - if ( ! $template_path || ! is_readable($template_path)) { |
|
376 | - return ''; |
|
377 | - } |
|
378 | - // if $template_args are not in an array, then make it so |
|
379 | - if ( ! is_array($template_args) && ! is_object($template_args)) { |
|
380 | - $template_args = array($template_args); |
|
381 | - } |
|
382 | - extract( $template_args, EXTR_SKIP ); |
|
383 | - // ignore whether template is accessible ? |
|
384 | - if ( $throw_exceptions && ! is_readable( $template_path ) ) { |
|
385 | - throw new \DomainException( |
|
386 | - esc_html__( |
|
387 | - 'Invalid, unreadable, or missing file.', |
|
388 | - 'event_espresso' |
|
389 | - ) |
|
390 | - ); |
|
391 | - } |
|
392 | - |
|
393 | - |
|
394 | - if ($return_string) { |
|
395 | - // because we want to return a string, we are going to capture the output |
|
396 | - ob_start(); |
|
397 | - include($template_path); |
|
398 | - return ob_get_clean(); |
|
399 | - } else { |
|
400 | - include($template_path); |
|
401 | - } |
|
402 | - return ''; |
|
403 | - } |
|
404 | - |
|
405 | - |
|
406 | - /** |
|
407 | - * get_object_css_class - attempts to generate a css class based on the type of EE object passed |
|
408 | - * |
|
409 | - * @param EE_Base_Class $object the EE object the css class is being generated for |
|
410 | - * @param string $prefix added to the beginning of the generated class |
|
411 | - * @param string $suffix added to the end of the generated class |
|
412 | - * @return string |
|
413 | - */ |
|
414 | - public static function get_object_css_class($object = null, $prefix = '', $suffix = '') |
|
415 | - { |
|
416 | - // in the beginning... |
|
417 | - $prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : ''; |
|
418 | - // da muddle |
|
419 | - $class = ''; |
|
420 | - // the end |
|
421 | - $suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : ''; |
|
422 | - // is the passed object an EE object ? |
|
423 | - if ($object instanceof EE_Base_Class) { |
|
424 | - // grab the exact type of object |
|
425 | - $obj_class = get_class($object); |
|
426 | - // depending on the type of object... |
|
427 | - switch ($obj_class) { |
|
428 | - // no specifics just yet... |
|
429 | - default : |
|
430 | - $class = strtolower(str_replace('_', '-', $obj_class)); |
|
431 | - $class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : ''; |
|
432 | - |
|
433 | - } |
|
434 | - } |
|
435 | - return $prefix . $class . $suffix; |
|
436 | - } |
|
437 | - |
|
438 | - |
|
439 | - |
|
440 | - /** |
|
441 | - * EEH_Template::format_currency |
|
442 | - * This helper takes a raw float value and formats it according to the default config country currency settings, or |
|
443 | - * the country currency settings from the supplied country ISO code |
|
444 | - * |
|
445 | - * @param float $amount raw money value |
|
446 | - * @param boolean $return_raw whether to return the formatted float value only with no currency sign or code |
|
447 | - * @param boolean $display_code whether to display the country code (USD). Default = TRUE |
|
448 | - * @param string $CNT_ISO 2 letter ISO code for a country |
|
449 | - * @param string $cur_code_span_class |
|
450 | - * @return string the html output for the formatted money value |
|
451 | - * @throws \EE_Error |
|
452 | - */ |
|
453 | - public static function format_currency( |
|
454 | - $amount = null, |
|
455 | - $return_raw = false, |
|
456 | - $display_code = true, |
|
457 | - $CNT_ISO = '', |
|
458 | - $cur_code_span_class = 'currency-code' |
|
459 | - ) { |
|
460 | - // ensure amount was received |
|
461 | - if ($amount === null) { |
|
462 | - $msg = __('In order to format currency, an amount needs to be passed.', 'event_espresso'); |
|
463 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
464 | - return ''; |
|
465 | - } |
|
466 | - //ensure amount is float |
|
467 | - $amount = apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float)$amount); |
|
468 | - $CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount); |
|
469 | - // filter raw amount (allows 0.00 to be changed to "free" for example) |
|
470 | - $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw); |
|
471 | - // still a number or was amount converted to a string like "free" ? |
|
472 | - if (is_float($amount_formatted)) { |
|
473 | - // was a country ISO code passed ? if so generate currency config object for that country |
|
474 | - $mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null; |
|
475 | - // verify results |
|
476 | - if ( ! $mny instanceof EE_Currency_Config) { |
|
477 | - // set default config country currency settings |
|
478 | - $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config |
|
479 | - ? EE_Registry::instance()->CFG->currency |
|
480 | - : new EE_Currency_Config(); |
|
481 | - } |
|
482 | - // format float |
|
483 | - $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds); |
|
484 | - // add formatting ? |
|
485 | - if ( ! $return_raw) { |
|
486 | - // add currency sign |
|
487 | - if ($mny->sign_b4) { |
|
488 | - if ($amount >= 0) { |
|
489 | - $amount_formatted = $mny->sign . $amount_formatted; |
|
490 | - } else { |
|
491 | - $amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted); |
|
492 | - } |
|
493 | - |
|
494 | - } else { |
|
495 | - $amount_formatted = $amount_formatted . $mny->sign; |
|
496 | - } |
|
497 | - |
|
498 | - // filter to allow global setting of display_code |
|
499 | - $display_code = apply_filters('FHEE__EEH_Template__format_currency__display_code', $display_code); |
|
500 | - |
|
501 | - // add currency code ? |
|
502 | - $amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted; |
|
503 | - } |
|
504 | - // filter results |
|
505 | - $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted', |
|
506 | - $amount_formatted, $mny, $return_raw); |
|
507 | - } |
|
508 | - // clean up vars |
|
509 | - unset($mny); |
|
510 | - // return formatted currency amount |
|
511 | - return $amount_formatted; |
|
512 | - } |
|
513 | - |
|
514 | - |
|
515 | - /** |
|
516 | - * This function is used for outputting the localized label for a given status id in the schema requested (and |
|
517 | - * possibly plural). The intended use of this function is only for cases where wanting a label outside of a |
|
518 | - * related status model or model object (i.e. in documentation etc.) |
|
519 | - * |
|
520 | - * @param string $status_id Status ID matching a registered status in the esp_status table. If there is no |
|
521 | - * match, then 'Unknown' will be returned. |
|
522 | - * @param boolean $plural Whether to return plural or not |
|
523 | - * @param string $schema 'UPPER', 'lower', or 'Sentence' |
|
524 | - * @return string The localized label for the status id. |
|
525 | - */ |
|
526 | - public static function pretty_status($status_id, $plural = false, $schema = 'upper') |
|
527 | - { |
|
528 | - /** @type EEM_Status $EEM_Status */ |
|
529 | - $EEM_Status = EE_Registry::instance()->load_model('Status'); |
|
530 | - $status = $EEM_Status->localized_status(array($status_id => __('unknown', 'event_espresso')), $plural, |
|
531 | - $schema); |
|
532 | - return $status[$status_id]; |
|
533 | - } |
|
534 | - |
|
535 | - |
|
536 | - /** |
|
537 | - * This helper just returns a button or link for the given parameters |
|
538 | - * |
|
539 | - * @param string $url the url for the link, note that `esc_url` will be called on it |
|
540 | - * @param string $label What is the label you want displayed for the button |
|
541 | - * @param string $class what class is used for the button (defaults to 'button-primary') |
|
542 | - * @param string $icon |
|
543 | - * @param string $title |
|
544 | - * @return string the html output for the button |
|
545 | - */ |
|
546 | - public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '', $title = '') |
|
547 | - { |
|
548 | - $icon_html = ''; |
|
549 | - if ( ! empty($icon)) { |
|
550 | - $dashicons = preg_split("(ee-icon |dashicons )", $icon); |
|
551 | - $dashicons = array_filter($dashicons); |
|
552 | - $count = count($dashicons); |
|
553 | - $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : ''; |
|
554 | - foreach ($dashicons as $dashicon) { |
|
555 | - $type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons '; |
|
556 | - $icon_html .= '<span class="' . $type . $dashicon . '"></span>'; |
|
557 | - } |
|
558 | - $icon_html .= $count > 1 ? '</span>' : ''; |
|
559 | - } |
|
560 | - $label = ! empty($icon) ? $icon_html . $label : $label; |
|
561 | - $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . esc_url($url) . '" class="' . $class . '" title="' . $title . '">' . $label . '</a>'; |
|
562 | - return $button; |
|
563 | - } |
|
564 | - |
|
565 | - |
|
566 | - /** |
|
567 | - * This returns a generated link that will load the related help tab on admin pages. |
|
568 | - * |
|
569 | - * @param string $help_tab_id the id for the connected help tab |
|
570 | - * @param bool|string $page The page identifier for the page the help tab is on |
|
571 | - * @param bool|string $action The action (route) for the admin page the help tab is on. |
|
572 | - * @param bool|string $icon_style (optional) include css class for the style you want to use for the help icon. |
|
573 | - * @param bool|string $help_text (optional) send help text you want to use for the link if default not to be used |
|
574 | - * @return string generated link |
|
575 | - */ |
|
576 | - public static function get_help_tab_link( |
|
577 | - $help_tab_id, |
|
578 | - $page = false, |
|
579 | - $action = false, |
|
580 | - $icon_style = false, |
|
581 | - $help_text = false |
|
582 | - ) { |
|
583 | - |
|
584 | - if ( ! $page) { |
|
585 | - $page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page; |
|
586 | - } |
|
587 | - |
|
588 | - if ( ! $action) { |
|
589 | - $action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action; |
|
590 | - } |
|
591 | - |
|
592 | - $action = empty($action) ? 'default' : $action; |
|
593 | - |
|
594 | - |
|
595 | - $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id; |
|
596 | - $icon = ! $icon_style ? ' dashicons-editor-help' : $icon_style; |
|
597 | - $help_text = ! $help_text ? '' : $help_text; |
|
598 | - return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.', |
|
599 | - 'event_espresso') . '" > ' . $help_text . ' </a>'; |
|
600 | - } |
|
601 | - |
|
602 | - |
|
603 | - /** |
|
604 | - * This helper generates the html structure for the jquery joyride plugin with the given params. |
|
605 | - * |
|
606 | - * @link http://zurb.com/playground/jquery-joyride-feature-tour-plugin |
|
607 | - * @see EE_Admin_Page->_stop_callback() for the construct expected for the $stops param. |
|
608 | - * @param EE_Help_Tour |
|
609 | - * @return string html |
|
610 | - */ |
|
611 | - public static function help_tour_stops_generator(EE_Help_Tour $tour) |
|
612 | - { |
|
613 | - $id = $tour->get_slug(); |
|
614 | - $stops = $tour->get_stops(); |
|
615 | - |
|
616 | - $content = '<ol style="display:none" id="' . $id . '">'; |
|
617 | - |
|
618 | - foreach ($stops as $stop) { |
|
619 | - $data_id = ! empty($stop['id']) ? ' data-id="' . $stop['id'] . '"' : ''; |
|
620 | - $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="' . $stop['class'] . '"' : ''; |
|
621 | - |
|
622 | - //if container is set to modal then let's make sure we set the options accordingly |
|
623 | - if (empty($data_id) && empty($data_class)) { |
|
624 | - $stop['options']['modal'] = true; |
|
625 | - $stop['options']['expose'] = true; |
|
626 | - } |
|
627 | - |
|
628 | - $custom_class = ! empty($stop['custom_class']) ? ' class="' . $stop['custom_class'] . '"' : ''; |
|
629 | - $button_text = ! empty($stop['button_text']) ? ' data-button="' . $stop['button_text'] . '"' : ''; |
|
630 | - $inner_content = isset($stop['content']) ? $stop['content'] : ''; |
|
631 | - |
|
632 | - //options |
|
633 | - if (isset($stop['options']) && is_array($stop['options'])) { |
|
634 | - $options = ' data-options="'; |
|
635 | - foreach ($stop['options'] as $option => $value) { |
|
636 | - $options .= $option . ':' . $value . ';'; |
|
637 | - } |
|
638 | - $options .= '"'; |
|
639 | - } else { |
|
640 | - $options = ''; |
|
641 | - } |
|
642 | - |
|
643 | - //let's put all together |
|
644 | - $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>'; |
|
645 | - } |
|
646 | - |
|
647 | - $content .= '</ol>'; |
|
648 | - return $content; |
|
649 | - } |
|
650 | - |
|
651 | - |
|
652 | - /** |
|
653 | - * This is a helper method to generate a status legend for a given status array. |
|
654 | - * Note this will only work if the incoming statuses have a key in the EEM_Status->localized_status() methods |
|
655 | - * status_array. |
|
656 | - * |
|
657 | - * @param array $status_array array of statuses that will make up the legend. In format: |
|
658 | - * array( |
|
659 | - * 'status_item' => 'status_name' |
|
660 | - * ) |
|
661 | - * @param string $active_status This is used to indicate what the active status is IF that is to be highlighted in |
|
662 | - * the legend. |
|
663 | - * @throws EE_Error |
|
664 | - * @return string html structure for status. |
|
665 | - */ |
|
666 | - public static function status_legend($status_array, $active_status = '') |
|
667 | - { |
|
668 | - if ( ! is_array($status_array)) { |
|
669 | - throw new EE_Error(esc_html__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', |
|
670 | - 'event_espresso')); |
|
671 | - } |
|
672 | - |
|
673 | - $setup_array = array(); |
|
674 | - foreach ($status_array as $item => $status) { |
|
675 | - $setup_array[$item] = array( |
|
676 | - 'class' => 'ee-status-legend ee-status-legend-' . $status, |
|
677 | - 'desc' => EEH_Template::pretty_status($status, false, 'sentence'), |
|
678 | - 'status' => $status, |
|
679 | - ); |
|
680 | - } |
|
681 | - |
|
682 | - $content = '<div class="ee-list-table-legend-container">' . "\n"; |
|
683 | - $content .= '<h4 class="status-legend-title">' . esc_html__('Status Legend', 'event_espresso') . '</h4>' . "\n"; |
|
684 | - $content .= '<dl class="ee-list-table-legend">' . "\n\t"; |
|
685 | - foreach ($setup_array as $item => $details) { |
|
686 | - $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : ''; |
|
687 | - $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t"; |
|
688 | - $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t"; |
|
689 | - $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t"; |
|
690 | - $content .= '</dt>' . "\n"; |
|
691 | - } |
|
692 | - $content .= '</dl>' . "\n"; |
|
693 | - $content .= '</div>' . "\n"; |
|
694 | - return $content; |
|
695 | - } |
|
696 | - |
|
697 | - |
|
698 | - /** |
|
699 | - * Gets HTML for laying out a deeply-nested array (and objects) in a format |
|
700 | - * that's nice for presenting in the wp admin |
|
701 | - * |
|
702 | - * @param mixed $data |
|
703 | - * @return string |
|
704 | - */ |
|
705 | - public static function layout_array_as_table($data) |
|
706 | - { |
|
707 | - if (is_object($data) || $data instanceof __PHP_Incomplete_Class) { |
|
708 | - $data = (array)$data; |
|
709 | - } |
|
710 | - ob_start(); |
|
711 | - if (is_array($data)) { |
|
712 | - if (EEH_Array::is_associative_array($data)) { |
|
713 | - ?> |
|
356 | + $template_path = false, |
|
357 | + $template_args = array(), |
|
358 | + $return_string = false, |
|
359 | + $throw_exceptions = false |
|
360 | + ) { |
|
361 | + |
|
362 | + /** |
|
363 | + * These two filters are intended for last minute changes to templates being loaded and/or template arg |
|
364 | + * modifications. NOTE... modifying these things can cause breakage as most templates running through |
|
365 | + * the display_template method are templates we DON'T want modified (usually because of js |
|
366 | + * dependencies etc). So unless you know what you are doing, do NOT filter templates or template args |
|
367 | + * using this. |
|
368 | + * |
|
369 | + * @since 4.6.0 |
|
370 | + */ |
|
371 | + $template_path = (string) apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path); |
|
372 | + $template_args = (array) apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args); |
|
373 | + |
|
374 | + // you gimme nuttin - YOU GET NUTTIN !! |
|
375 | + if ( ! $template_path || ! is_readable($template_path)) { |
|
376 | + return ''; |
|
377 | + } |
|
378 | + // if $template_args are not in an array, then make it so |
|
379 | + if ( ! is_array($template_args) && ! is_object($template_args)) { |
|
380 | + $template_args = array($template_args); |
|
381 | + } |
|
382 | + extract( $template_args, EXTR_SKIP ); |
|
383 | + // ignore whether template is accessible ? |
|
384 | + if ( $throw_exceptions && ! is_readable( $template_path ) ) { |
|
385 | + throw new \DomainException( |
|
386 | + esc_html__( |
|
387 | + 'Invalid, unreadable, or missing file.', |
|
388 | + 'event_espresso' |
|
389 | + ) |
|
390 | + ); |
|
391 | + } |
|
392 | + |
|
393 | + |
|
394 | + if ($return_string) { |
|
395 | + // because we want to return a string, we are going to capture the output |
|
396 | + ob_start(); |
|
397 | + include($template_path); |
|
398 | + return ob_get_clean(); |
|
399 | + } else { |
|
400 | + include($template_path); |
|
401 | + } |
|
402 | + return ''; |
|
403 | + } |
|
404 | + |
|
405 | + |
|
406 | + /** |
|
407 | + * get_object_css_class - attempts to generate a css class based on the type of EE object passed |
|
408 | + * |
|
409 | + * @param EE_Base_Class $object the EE object the css class is being generated for |
|
410 | + * @param string $prefix added to the beginning of the generated class |
|
411 | + * @param string $suffix added to the end of the generated class |
|
412 | + * @return string |
|
413 | + */ |
|
414 | + public static function get_object_css_class($object = null, $prefix = '', $suffix = '') |
|
415 | + { |
|
416 | + // in the beginning... |
|
417 | + $prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : ''; |
|
418 | + // da muddle |
|
419 | + $class = ''; |
|
420 | + // the end |
|
421 | + $suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : ''; |
|
422 | + // is the passed object an EE object ? |
|
423 | + if ($object instanceof EE_Base_Class) { |
|
424 | + // grab the exact type of object |
|
425 | + $obj_class = get_class($object); |
|
426 | + // depending on the type of object... |
|
427 | + switch ($obj_class) { |
|
428 | + // no specifics just yet... |
|
429 | + default : |
|
430 | + $class = strtolower(str_replace('_', '-', $obj_class)); |
|
431 | + $class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : ''; |
|
432 | + |
|
433 | + } |
|
434 | + } |
|
435 | + return $prefix . $class . $suffix; |
|
436 | + } |
|
437 | + |
|
438 | + |
|
439 | + |
|
440 | + /** |
|
441 | + * EEH_Template::format_currency |
|
442 | + * This helper takes a raw float value and formats it according to the default config country currency settings, or |
|
443 | + * the country currency settings from the supplied country ISO code |
|
444 | + * |
|
445 | + * @param float $amount raw money value |
|
446 | + * @param boolean $return_raw whether to return the formatted float value only with no currency sign or code |
|
447 | + * @param boolean $display_code whether to display the country code (USD). Default = TRUE |
|
448 | + * @param string $CNT_ISO 2 letter ISO code for a country |
|
449 | + * @param string $cur_code_span_class |
|
450 | + * @return string the html output for the formatted money value |
|
451 | + * @throws \EE_Error |
|
452 | + */ |
|
453 | + public static function format_currency( |
|
454 | + $amount = null, |
|
455 | + $return_raw = false, |
|
456 | + $display_code = true, |
|
457 | + $CNT_ISO = '', |
|
458 | + $cur_code_span_class = 'currency-code' |
|
459 | + ) { |
|
460 | + // ensure amount was received |
|
461 | + if ($amount === null) { |
|
462 | + $msg = __('In order to format currency, an amount needs to be passed.', 'event_espresso'); |
|
463 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
464 | + return ''; |
|
465 | + } |
|
466 | + //ensure amount is float |
|
467 | + $amount = apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float)$amount); |
|
468 | + $CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount); |
|
469 | + // filter raw amount (allows 0.00 to be changed to "free" for example) |
|
470 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw); |
|
471 | + // still a number or was amount converted to a string like "free" ? |
|
472 | + if (is_float($amount_formatted)) { |
|
473 | + // was a country ISO code passed ? if so generate currency config object for that country |
|
474 | + $mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null; |
|
475 | + // verify results |
|
476 | + if ( ! $mny instanceof EE_Currency_Config) { |
|
477 | + // set default config country currency settings |
|
478 | + $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config |
|
479 | + ? EE_Registry::instance()->CFG->currency |
|
480 | + : new EE_Currency_Config(); |
|
481 | + } |
|
482 | + // format float |
|
483 | + $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds); |
|
484 | + // add formatting ? |
|
485 | + if ( ! $return_raw) { |
|
486 | + // add currency sign |
|
487 | + if ($mny->sign_b4) { |
|
488 | + if ($amount >= 0) { |
|
489 | + $amount_formatted = $mny->sign . $amount_formatted; |
|
490 | + } else { |
|
491 | + $amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted); |
|
492 | + } |
|
493 | + |
|
494 | + } else { |
|
495 | + $amount_formatted = $amount_formatted . $mny->sign; |
|
496 | + } |
|
497 | + |
|
498 | + // filter to allow global setting of display_code |
|
499 | + $display_code = apply_filters('FHEE__EEH_Template__format_currency__display_code', $display_code); |
|
500 | + |
|
501 | + // add currency code ? |
|
502 | + $amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted; |
|
503 | + } |
|
504 | + // filter results |
|
505 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted', |
|
506 | + $amount_formatted, $mny, $return_raw); |
|
507 | + } |
|
508 | + // clean up vars |
|
509 | + unset($mny); |
|
510 | + // return formatted currency amount |
|
511 | + return $amount_formatted; |
|
512 | + } |
|
513 | + |
|
514 | + |
|
515 | + /** |
|
516 | + * This function is used for outputting the localized label for a given status id in the schema requested (and |
|
517 | + * possibly plural). The intended use of this function is only for cases where wanting a label outside of a |
|
518 | + * related status model or model object (i.e. in documentation etc.) |
|
519 | + * |
|
520 | + * @param string $status_id Status ID matching a registered status in the esp_status table. If there is no |
|
521 | + * match, then 'Unknown' will be returned. |
|
522 | + * @param boolean $plural Whether to return plural or not |
|
523 | + * @param string $schema 'UPPER', 'lower', or 'Sentence' |
|
524 | + * @return string The localized label for the status id. |
|
525 | + */ |
|
526 | + public static function pretty_status($status_id, $plural = false, $schema = 'upper') |
|
527 | + { |
|
528 | + /** @type EEM_Status $EEM_Status */ |
|
529 | + $EEM_Status = EE_Registry::instance()->load_model('Status'); |
|
530 | + $status = $EEM_Status->localized_status(array($status_id => __('unknown', 'event_espresso')), $plural, |
|
531 | + $schema); |
|
532 | + return $status[$status_id]; |
|
533 | + } |
|
534 | + |
|
535 | + |
|
536 | + /** |
|
537 | + * This helper just returns a button or link for the given parameters |
|
538 | + * |
|
539 | + * @param string $url the url for the link, note that `esc_url` will be called on it |
|
540 | + * @param string $label What is the label you want displayed for the button |
|
541 | + * @param string $class what class is used for the button (defaults to 'button-primary') |
|
542 | + * @param string $icon |
|
543 | + * @param string $title |
|
544 | + * @return string the html output for the button |
|
545 | + */ |
|
546 | + public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '', $title = '') |
|
547 | + { |
|
548 | + $icon_html = ''; |
|
549 | + if ( ! empty($icon)) { |
|
550 | + $dashicons = preg_split("(ee-icon |dashicons )", $icon); |
|
551 | + $dashicons = array_filter($dashicons); |
|
552 | + $count = count($dashicons); |
|
553 | + $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : ''; |
|
554 | + foreach ($dashicons as $dashicon) { |
|
555 | + $type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons '; |
|
556 | + $icon_html .= '<span class="' . $type . $dashicon . '"></span>'; |
|
557 | + } |
|
558 | + $icon_html .= $count > 1 ? '</span>' : ''; |
|
559 | + } |
|
560 | + $label = ! empty($icon) ? $icon_html . $label : $label; |
|
561 | + $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . esc_url($url) . '" class="' . $class . '" title="' . $title . '">' . $label . '</a>'; |
|
562 | + return $button; |
|
563 | + } |
|
564 | + |
|
565 | + |
|
566 | + /** |
|
567 | + * This returns a generated link that will load the related help tab on admin pages. |
|
568 | + * |
|
569 | + * @param string $help_tab_id the id for the connected help tab |
|
570 | + * @param bool|string $page The page identifier for the page the help tab is on |
|
571 | + * @param bool|string $action The action (route) for the admin page the help tab is on. |
|
572 | + * @param bool|string $icon_style (optional) include css class for the style you want to use for the help icon. |
|
573 | + * @param bool|string $help_text (optional) send help text you want to use for the link if default not to be used |
|
574 | + * @return string generated link |
|
575 | + */ |
|
576 | + public static function get_help_tab_link( |
|
577 | + $help_tab_id, |
|
578 | + $page = false, |
|
579 | + $action = false, |
|
580 | + $icon_style = false, |
|
581 | + $help_text = false |
|
582 | + ) { |
|
583 | + |
|
584 | + if ( ! $page) { |
|
585 | + $page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page; |
|
586 | + } |
|
587 | + |
|
588 | + if ( ! $action) { |
|
589 | + $action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action; |
|
590 | + } |
|
591 | + |
|
592 | + $action = empty($action) ? 'default' : $action; |
|
593 | + |
|
594 | + |
|
595 | + $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id; |
|
596 | + $icon = ! $icon_style ? ' dashicons-editor-help' : $icon_style; |
|
597 | + $help_text = ! $help_text ? '' : $help_text; |
|
598 | + return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.', |
|
599 | + 'event_espresso') . '" > ' . $help_text . ' </a>'; |
|
600 | + } |
|
601 | + |
|
602 | + |
|
603 | + /** |
|
604 | + * This helper generates the html structure for the jquery joyride plugin with the given params. |
|
605 | + * |
|
606 | + * @link http://zurb.com/playground/jquery-joyride-feature-tour-plugin |
|
607 | + * @see EE_Admin_Page->_stop_callback() for the construct expected for the $stops param. |
|
608 | + * @param EE_Help_Tour |
|
609 | + * @return string html |
|
610 | + */ |
|
611 | + public static function help_tour_stops_generator(EE_Help_Tour $tour) |
|
612 | + { |
|
613 | + $id = $tour->get_slug(); |
|
614 | + $stops = $tour->get_stops(); |
|
615 | + |
|
616 | + $content = '<ol style="display:none" id="' . $id . '">'; |
|
617 | + |
|
618 | + foreach ($stops as $stop) { |
|
619 | + $data_id = ! empty($stop['id']) ? ' data-id="' . $stop['id'] . '"' : ''; |
|
620 | + $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="' . $stop['class'] . '"' : ''; |
|
621 | + |
|
622 | + //if container is set to modal then let's make sure we set the options accordingly |
|
623 | + if (empty($data_id) && empty($data_class)) { |
|
624 | + $stop['options']['modal'] = true; |
|
625 | + $stop['options']['expose'] = true; |
|
626 | + } |
|
627 | + |
|
628 | + $custom_class = ! empty($stop['custom_class']) ? ' class="' . $stop['custom_class'] . '"' : ''; |
|
629 | + $button_text = ! empty($stop['button_text']) ? ' data-button="' . $stop['button_text'] . '"' : ''; |
|
630 | + $inner_content = isset($stop['content']) ? $stop['content'] : ''; |
|
631 | + |
|
632 | + //options |
|
633 | + if (isset($stop['options']) && is_array($stop['options'])) { |
|
634 | + $options = ' data-options="'; |
|
635 | + foreach ($stop['options'] as $option => $value) { |
|
636 | + $options .= $option . ':' . $value . ';'; |
|
637 | + } |
|
638 | + $options .= '"'; |
|
639 | + } else { |
|
640 | + $options = ''; |
|
641 | + } |
|
642 | + |
|
643 | + //let's put all together |
|
644 | + $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>'; |
|
645 | + } |
|
646 | + |
|
647 | + $content .= '</ol>'; |
|
648 | + return $content; |
|
649 | + } |
|
650 | + |
|
651 | + |
|
652 | + /** |
|
653 | + * This is a helper method to generate a status legend for a given status array. |
|
654 | + * Note this will only work if the incoming statuses have a key in the EEM_Status->localized_status() methods |
|
655 | + * status_array. |
|
656 | + * |
|
657 | + * @param array $status_array array of statuses that will make up the legend. In format: |
|
658 | + * array( |
|
659 | + * 'status_item' => 'status_name' |
|
660 | + * ) |
|
661 | + * @param string $active_status This is used to indicate what the active status is IF that is to be highlighted in |
|
662 | + * the legend. |
|
663 | + * @throws EE_Error |
|
664 | + * @return string html structure for status. |
|
665 | + */ |
|
666 | + public static function status_legend($status_array, $active_status = '') |
|
667 | + { |
|
668 | + if ( ! is_array($status_array)) { |
|
669 | + throw new EE_Error(esc_html__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', |
|
670 | + 'event_espresso')); |
|
671 | + } |
|
672 | + |
|
673 | + $setup_array = array(); |
|
674 | + foreach ($status_array as $item => $status) { |
|
675 | + $setup_array[$item] = array( |
|
676 | + 'class' => 'ee-status-legend ee-status-legend-' . $status, |
|
677 | + 'desc' => EEH_Template::pretty_status($status, false, 'sentence'), |
|
678 | + 'status' => $status, |
|
679 | + ); |
|
680 | + } |
|
681 | + |
|
682 | + $content = '<div class="ee-list-table-legend-container">' . "\n"; |
|
683 | + $content .= '<h4 class="status-legend-title">' . esc_html__('Status Legend', 'event_espresso') . '</h4>' . "\n"; |
|
684 | + $content .= '<dl class="ee-list-table-legend">' . "\n\t"; |
|
685 | + foreach ($setup_array as $item => $details) { |
|
686 | + $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : ''; |
|
687 | + $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t"; |
|
688 | + $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t"; |
|
689 | + $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t"; |
|
690 | + $content .= '</dt>' . "\n"; |
|
691 | + } |
|
692 | + $content .= '</dl>' . "\n"; |
|
693 | + $content .= '</div>' . "\n"; |
|
694 | + return $content; |
|
695 | + } |
|
696 | + |
|
697 | + |
|
698 | + /** |
|
699 | + * Gets HTML for laying out a deeply-nested array (and objects) in a format |
|
700 | + * that's nice for presenting in the wp admin |
|
701 | + * |
|
702 | + * @param mixed $data |
|
703 | + * @return string |
|
704 | + */ |
|
705 | + public static function layout_array_as_table($data) |
|
706 | + { |
|
707 | + if (is_object($data) || $data instanceof __PHP_Incomplete_Class) { |
|
708 | + $data = (array)$data; |
|
709 | + } |
|
710 | + ob_start(); |
|
711 | + if (is_array($data)) { |
|
712 | + if (EEH_Array::is_associative_array($data)) { |
|
713 | + ?> |
|
714 | 714 | <table class="widefat"> |
715 | 715 | <tbody> |
716 | 716 | <?php |
717 | - foreach ($data as $data_key => $data_values) { |
|
718 | - ?> |
|
717 | + foreach ($data as $data_key => $data_values) { |
|
718 | + ?> |
|
719 | 719 | <tr> |
720 | 720 | <td> |
721 | 721 | <?php echo $data_key; ?> |
@@ -725,248 +725,248 @@ discard block |
||
725 | 725 | </td> |
726 | 726 | </tr> |
727 | 727 | <?php |
728 | - } ?> |
|
728 | + } ?> |
|
729 | 729 | </tbody> |
730 | 730 | </table> |
731 | 731 | <?php |
732 | - } else { |
|
733 | - ?> |
|
732 | + } else { |
|
733 | + ?> |
|
734 | 734 | <ul> |
735 | 735 | <?php |
736 | - foreach ($data as $datum) { |
|
737 | - echo "<li>"; |
|
738 | - echo self::layout_array_as_table($datum); |
|
739 | - echo "</li>"; |
|
740 | - } ?> |
|
736 | + foreach ($data as $datum) { |
|
737 | + echo "<li>"; |
|
738 | + echo self::layout_array_as_table($datum); |
|
739 | + echo "</li>"; |
|
740 | + } ?> |
|
741 | 741 | </ul> |
742 | 742 | <?php |
743 | - } |
|
744 | - } else { |
|
745 | - //simple value |
|
746 | - echo esc_html($data); |
|
747 | - } |
|
748 | - return ob_get_clean(); |
|
749 | - } |
|
750 | - |
|
751 | - |
|
752 | - /** |
|
753 | - * wrapper for self::get_paging_html() that simply echos the generated paging html |
|
754 | - * |
|
755 | - * @since 4.4.0 |
|
756 | - * @see self:get_paging_html() for argument docs. |
|
757 | - * @param $total_items |
|
758 | - * @param $current |
|
759 | - * @param $per_page |
|
760 | - * @param $url |
|
761 | - * @param bool $show_num_field |
|
762 | - * @param string $paged_arg_name |
|
763 | - * @param array $items_label |
|
764 | - * @return string |
|
765 | - */ |
|
766 | - public static function paging_html( |
|
767 | - $total_items, |
|
768 | - $current, |
|
769 | - $per_page, |
|
770 | - $url, |
|
771 | - $show_num_field = true, |
|
772 | - $paged_arg_name = 'paged', |
|
773 | - $items_label = array() |
|
774 | - ) { |
|
775 | - echo self::get_paging_html($total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, |
|
776 | - $items_label); |
|
777 | - } |
|
778 | - |
|
779 | - |
|
780 | - /** |
|
781 | - * A method for generating paging similar to WP_List_Table |
|
782 | - * |
|
783 | - * @since 4.4.0 |
|
784 | - * @see wp-admin/includes/class-wp-list-table.php WP_List_Table::pagination() |
|
785 | - * @param integer $total_items How many total items there are to page. |
|
786 | - * @param integer $current What the current page is. |
|
787 | - * @param integer $per_page How many items per page. |
|
788 | - * @param string $url What the base url for page links is. |
|
789 | - * @param boolean $show_num_field Whether to show the input for changing page number. |
|
790 | - * @param string $paged_arg_name The name of the key for the paged query argument. |
|
791 | - * @param array $items_label An array of singular/plural values for the items label: |
|
792 | - * array( |
|
793 | - * 'single' => 'item', |
|
794 | - * 'plural' => 'items' |
|
795 | - * ) |
|
796 | - * @return string |
|
797 | - */ |
|
798 | - public static function get_paging_html( |
|
799 | - $total_items, |
|
800 | - $current, |
|
801 | - $per_page, |
|
802 | - $url, |
|
803 | - $show_num_field = true, |
|
804 | - $paged_arg_name = 'paged', |
|
805 | - $items_label = array() |
|
806 | - ) { |
|
807 | - $page_links = array(); |
|
808 | - $disable_first = $disable_last = ''; |
|
809 | - $total_items = (int)$total_items; |
|
810 | - $per_page = (int)$per_page; |
|
811 | - $current = (int)$current; |
|
812 | - $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name); |
|
813 | - |
|
814 | - //filter items_label |
|
815 | - $items_label = apply_filters( |
|
816 | - 'FHEE__EEH_Template__get_paging_html__items_label', |
|
817 | - $items_label |
|
818 | - ); |
|
819 | - |
|
820 | - if (empty($items_label) |
|
821 | - || ! is_array($items_label) |
|
822 | - || ! isset($items_label['single']) |
|
823 | - || ! isset($items_label['plural']) |
|
824 | - ) { |
|
825 | - $items_label = array( |
|
826 | - 'single' => __('1 item', 'event_espresso'), |
|
827 | - 'plural' => __('%s items', 'event_espresso'), |
|
828 | - ); |
|
829 | - } else { |
|
830 | - $items_label = array( |
|
831 | - 'single' => '1 ' . esc_html($items_label['single']), |
|
832 | - 'plural' => '%s ' . esc_html($items_label['plural']), |
|
833 | - ); |
|
834 | - } |
|
835 | - |
|
836 | - $total_pages = ceil($total_items / $per_page); |
|
837 | - |
|
838 | - if ($total_pages <= 1) { |
|
839 | - return ''; |
|
840 | - } |
|
841 | - |
|
842 | - $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single']; |
|
843 | - |
|
844 | - $output = '<span class="displaying-num">' . $item_label . '</span>'; |
|
845 | - |
|
846 | - if ($current === 1) { |
|
847 | - $disable_first = ' disabled'; |
|
848 | - } |
|
849 | - if ($current == $total_pages) { |
|
850 | - $disable_last = ' disabled'; |
|
851 | - } |
|
852 | - |
|
853 | - $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>", |
|
854 | - 'first-page' . $disable_first, |
|
855 | - esc_attr__('Go to the first page'), |
|
856 | - esc_url(remove_query_arg($paged_arg_name, $url)), |
|
857 | - '«' |
|
858 | - ); |
|
859 | - |
|
860 | - $page_links[] = sprintf( |
|
861 | - '<a class="%s" title="%s" href="%s">%s</a>', |
|
862 | - 'prev-page' . $disable_first, |
|
863 | - esc_attr__('Go to the previous page'), |
|
864 | - esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)), |
|
865 | - '‹' |
|
866 | - ); |
|
867 | - |
|
868 | - if ( ! $show_num_field) { |
|
869 | - $html_current_page = $current; |
|
870 | - } else { |
|
871 | - $html_current_page = sprintf("<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
872 | - esc_attr__('Current page'), |
|
873 | - $current, |
|
874 | - strlen($total_pages) |
|
875 | - ); |
|
876 | - } |
|
877 | - |
|
878 | - $html_total_pages = sprintf( |
|
879 | - '<span class="total-pages">%s</span>', |
|
880 | - number_format_i18n($total_pages) |
|
881 | - ); |
|
882 | - $page_links[] = sprintf( |
|
883 | - _x('%3$s%1$s of %2$s%4$s', 'paging'), |
|
884 | - $html_current_page, |
|
885 | - $html_total_pages, |
|
886 | - '<span class="paging-input">', |
|
887 | - '</span>' |
|
888 | - ); |
|
889 | - |
|
890 | - $page_links[] = sprintf( |
|
891 | - '<a class="%s" title="%s" href="%s">%s</a>', |
|
892 | - 'next-page' . $disable_last, |
|
893 | - esc_attr__('Go to the next page'), |
|
894 | - esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)), |
|
895 | - '›' |
|
896 | - ); |
|
897 | - |
|
898 | - $page_links[] = sprintf( |
|
899 | - '<a class="%s" title="%s" href="%s">%s</a>', |
|
900 | - 'last-page' . $disable_last, |
|
901 | - esc_attr__('Go to the last page'), |
|
902 | - esc_url(add_query_arg($paged_arg_name, $total_pages, $url)), |
|
903 | - '»' |
|
904 | - ); |
|
905 | - |
|
906 | - $output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>'; |
|
907 | - // set page class |
|
908 | - if ($total_pages) { |
|
909 | - $page_class = $total_pages < 2 ? ' one-page' : ''; |
|
910 | - } else { |
|
911 | - $page_class = ' no-pages'; |
|
912 | - } |
|
913 | - |
|
914 | - return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>'; |
|
915 | - } |
|
916 | - |
|
917 | - |
|
918 | - /** |
|
919 | - * @param string $wrap_class |
|
920 | - * @param string $wrap_id |
|
921 | - * @return string |
|
922 | - */ |
|
923 | - public static function powered_by_event_espresso($wrap_class = '', $wrap_id = '', array $query_args = array()) |
|
924 | - { |
|
925 | - $admin = is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX); |
|
926 | - if ( |
|
927 | - ! $admin && |
|
928 | - ! apply_filters( |
|
929 | - 'FHEE__EEH_Template__powered_by_event_espresso__show_reg_footer', |
|
930 | - EE_Registry::instance()->CFG->admin->show_reg_footer |
|
931 | - ) |
|
932 | - ) { |
|
933 | - return ''; |
|
934 | - } |
|
935 | - $tag = $admin ? 'span' : 'div'; |
|
936 | - $attributes = ! empty($wrap_id) ? " id=\"{$wrap_id}\"" : ''; |
|
937 | - $wrap_class = $admin ? "{$wrap_class} float-left" : $wrap_class; |
|
938 | - $attributes .= ! empty($wrap_class) |
|
939 | - ? " class=\"{$wrap_class} powered-by-event-espresso-credit\"" |
|
940 | - : ' class="powered-by-event-espresso-credit"'; |
|
941 | - $query_args = array_merge( |
|
942 | - array( |
|
943 | - 'ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id(), |
|
944 | - 'utm_source' => 'powered_by_event_espresso', |
|
945 | - 'utm_medium' => 'link', |
|
946 | - 'utm_campaign' => 'powered_by', |
|
947 | - ), |
|
948 | - $query_args |
|
949 | - ); |
|
950 | - $powered_by = apply_filters('FHEE__EEH_Template__powered_by_event_espresso_text', |
|
951 | - $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso'); |
|
952 | - $url = add_query_arg($query_args, 'https://eventespresso.com/'); |
|
953 | - $url = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url); |
|
954 | - return (string)apply_filters( |
|
955 | - 'FHEE__EEH_Template__powered_by_event_espresso__html', |
|
956 | - sprintf( |
|
957 | - esc_html_x( |
|
958 | - '%3$s%1$sOnline event registration and ticketing powered by %2$s%3$s', |
|
959 | - 'Online event registration and ticketing powered by [link to eventespresso.com]', |
|
960 | - 'event_espresso' |
|
961 | - ), |
|
962 | - "<{$tag}{$attributes}>", |
|
963 | - "<a href=\"{$url}\" target=\"_blank\" rel=\"nofollow\">{$powered_by}</a></{$tag}>", |
|
964 | - $admin ? '' : '<br />' |
|
965 | - ), |
|
966 | - $wrap_class, |
|
967 | - $wrap_id |
|
968 | - ); |
|
969 | - } |
|
743 | + } |
|
744 | + } else { |
|
745 | + //simple value |
|
746 | + echo esc_html($data); |
|
747 | + } |
|
748 | + return ob_get_clean(); |
|
749 | + } |
|
750 | + |
|
751 | + |
|
752 | + /** |
|
753 | + * wrapper for self::get_paging_html() that simply echos the generated paging html |
|
754 | + * |
|
755 | + * @since 4.4.0 |
|
756 | + * @see self:get_paging_html() for argument docs. |
|
757 | + * @param $total_items |
|
758 | + * @param $current |
|
759 | + * @param $per_page |
|
760 | + * @param $url |
|
761 | + * @param bool $show_num_field |
|
762 | + * @param string $paged_arg_name |
|
763 | + * @param array $items_label |
|
764 | + * @return string |
|
765 | + */ |
|
766 | + public static function paging_html( |
|
767 | + $total_items, |
|
768 | + $current, |
|
769 | + $per_page, |
|
770 | + $url, |
|
771 | + $show_num_field = true, |
|
772 | + $paged_arg_name = 'paged', |
|
773 | + $items_label = array() |
|
774 | + ) { |
|
775 | + echo self::get_paging_html($total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, |
|
776 | + $items_label); |
|
777 | + } |
|
778 | + |
|
779 | + |
|
780 | + /** |
|
781 | + * A method for generating paging similar to WP_List_Table |
|
782 | + * |
|
783 | + * @since 4.4.0 |
|
784 | + * @see wp-admin/includes/class-wp-list-table.php WP_List_Table::pagination() |
|
785 | + * @param integer $total_items How many total items there are to page. |
|
786 | + * @param integer $current What the current page is. |
|
787 | + * @param integer $per_page How many items per page. |
|
788 | + * @param string $url What the base url for page links is. |
|
789 | + * @param boolean $show_num_field Whether to show the input for changing page number. |
|
790 | + * @param string $paged_arg_name The name of the key for the paged query argument. |
|
791 | + * @param array $items_label An array of singular/plural values for the items label: |
|
792 | + * array( |
|
793 | + * 'single' => 'item', |
|
794 | + * 'plural' => 'items' |
|
795 | + * ) |
|
796 | + * @return string |
|
797 | + */ |
|
798 | + public static function get_paging_html( |
|
799 | + $total_items, |
|
800 | + $current, |
|
801 | + $per_page, |
|
802 | + $url, |
|
803 | + $show_num_field = true, |
|
804 | + $paged_arg_name = 'paged', |
|
805 | + $items_label = array() |
|
806 | + ) { |
|
807 | + $page_links = array(); |
|
808 | + $disable_first = $disable_last = ''; |
|
809 | + $total_items = (int)$total_items; |
|
810 | + $per_page = (int)$per_page; |
|
811 | + $current = (int)$current; |
|
812 | + $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name); |
|
813 | + |
|
814 | + //filter items_label |
|
815 | + $items_label = apply_filters( |
|
816 | + 'FHEE__EEH_Template__get_paging_html__items_label', |
|
817 | + $items_label |
|
818 | + ); |
|
819 | + |
|
820 | + if (empty($items_label) |
|
821 | + || ! is_array($items_label) |
|
822 | + || ! isset($items_label['single']) |
|
823 | + || ! isset($items_label['plural']) |
|
824 | + ) { |
|
825 | + $items_label = array( |
|
826 | + 'single' => __('1 item', 'event_espresso'), |
|
827 | + 'plural' => __('%s items', 'event_espresso'), |
|
828 | + ); |
|
829 | + } else { |
|
830 | + $items_label = array( |
|
831 | + 'single' => '1 ' . esc_html($items_label['single']), |
|
832 | + 'plural' => '%s ' . esc_html($items_label['plural']), |
|
833 | + ); |
|
834 | + } |
|
835 | + |
|
836 | + $total_pages = ceil($total_items / $per_page); |
|
837 | + |
|
838 | + if ($total_pages <= 1) { |
|
839 | + return ''; |
|
840 | + } |
|
841 | + |
|
842 | + $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single']; |
|
843 | + |
|
844 | + $output = '<span class="displaying-num">' . $item_label . '</span>'; |
|
845 | + |
|
846 | + if ($current === 1) { |
|
847 | + $disable_first = ' disabled'; |
|
848 | + } |
|
849 | + if ($current == $total_pages) { |
|
850 | + $disable_last = ' disabled'; |
|
851 | + } |
|
852 | + |
|
853 | + $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>", |
|
854 | + 'first-page' . $disable_first, |
|
855 | + esc_attr__('Go to the first page'), |
|
856 | + esc_url(remove_query_arg($paged_arg_name, $url)), |
|
857 | + '«' |
|
858 | + ); |
|
859 | + |
|
860 | + $page_links[] = sprintf( |
|
861 | + '<a class="%s" title="%s" href="%s">%s</a>', |
|
862 | + 'prev-page' . $disable_first, |
|
863 | + esc_attr__('Go to the previous page'), |
|
864 | + esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)), |
|
865 | + '‹' |
|
866 | + ); |
|
867 | + |
|
868 | + if ( ! $show_num_field) { |
|
869 | + $html_current_page = $current; |
|
870 | + } else { |
|
871 | + $html_current_page = sprintf("<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
872 | + esc_attr__('Current page'), |
|
873 | + $current, |
|
874 | + strlen($total_pages) |
|
875 | + ); |
|
876 | + } |
|
877 | + |
|
878 | + $html_total_pages = sprintf( |
|
879 | + '<span class="total-pages">%s</span>', |
|
880 | + number_format_i18n($total_pages) |
|
881 | + ); |
|
882 | + $page_links[] = sprintf( |
|
883 | + _x('%3$s%1$s of %2$s%4$s', 'paging'), |
|
884 | + $html_current_page, |
|
885 | + $html_total_pages, |
|
886 | + '<span class="paging-input">', |
|
887 | + '</span>' |
|
888 | + ); |
|
889 | + |
|
890 | + $page_links[] = sprintf( |
|
891 | + '<a class="%s" title="%s" href="%s">%s</a>', |
|
892 | + 'next-page' . $disable_last, |
|
893 | + esc_attr__('Go to the next page'), |
|
894 | + esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)), |
|
895 | + '›' |
|
896 | + ); |
|
897 | + |
|
898 | + $page_links[] = sprintf( |
|
899 | + '<a class="%s" title="%s" href="%s">%s</a>', |
|
900 | + 'last-page' . $disable_last, |
|
901 | + esc_attr__('Go to the last page'), |
|
902 | + esc_url(add_query_arg($paged_arg_name, $total_pages, $url)), |
|
903 | + '»' |
|
904 | + ); |
|
905 | + |
|
906 | + $output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>'; |
|
907 | + // set page class |
|
908 | + if ($total_pages) { |
|
909 | + $page_class = $total_pages < 2 ? ' one-page' : ''; |
|
910 | + } else { |
|
911 | + $page_class = ' no-pages'; |
|
912 | + } |
|
913 | + |
|
914 | + return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>'; |
|
915 | + } |
|
916 | + |
|
917 | + |
|
918 | + /** |
|
919 | + * @param string $wrap_class |
|
920 | + * @param string $wrap_id |
|
921 | + * @return string |
|
922 | + */ |
|
923 | + public static function powered_by_event_espresso($wrap_class = '', $wrap_id = '', array $query_args = array()) |
|
924 | + { |
|
925 | + $admin = is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX); |
|
926 | + if ( |
|
927 | + ! $admin && |
|
928 | + ! apply_filters( |
|
929 | + 'FHEE__EEH_Template__powered_by_event_espresso__show_reg_footer', |
|
930 | + EE_Registry::instance()->CFG->admin->show_reg_footer |
|
931 | + ) |
|
932 | + ) { |
|
933 | + return ''; |
|
934 | + } |
|
935 | + $tag = $admin ? 'span' : 'div'; |
|
936 | + $attributes = ! empty($wrap_id) ? " id=\"{$wrap_id}\"" : ''; |
|
937 | + $wrap_class = $admin ? "{$wrap_class} float-left" : $wrap_class; |
|
938 | + $attributes .= ! empty($wrap_class) |
|
939 | + ? " class=\"{$wrap_class} powered-by-event-espresso-credit\"" |
|
940 | + : ' class="powered-by-event-espresso-credit"'; |
|
941 | + $query_args = array_merge( |
|
942 | + array( |
|
943 | + 'ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id(), |
|
944 | + 'utm_source' => 'powered_by_event_espresso', |
|
945 | + 'utm_medium' => 'link', |
|
946 | + 'utm_campaign' => 'powered_by', |
|
947 | + ), |
|
948 | + $query_args |
|
949 | + ); |
|
950 | + $powered_by = apply_filters('FHEE__EEH_Template__powered_by_event_espresso_text', |
|
951 | + $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso'); |
|
952 | + $url = add_query_arg($query_args, 'https://eventespresso.com/'); |
|
953 | + $url = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url); |
|
954 | + return (string)apply_filters( |
|
955 | + 'FHEE__EEH_Template__powered_by_event_espresso__html', |
|
956 | + sprintf( |
|
957 | + esc_html_x( |
|
958 | + '%3$s%1$sOnline event registration and ticketing powered by %2$s%3$s', |
|
959 | + 'Online event registration and ticketing powered by [link to eventespresso.com]', |
|
960 | + 'event_espresso' |
|
961 | + ), |
|
962 | + "<{$tag}{$attributes}>", |
|
963 | + "<a href=\"{$url}\" target=\"_blank\" rel=\"nofollow\">{$powered_by}</a></{$tag}>", |
|
964 | + $admin ? '' : '<br />' |
|
965 | + ), |
|
966 | + $wrap_class, |
|
967 | + $wrap_id |
|
968 | + ); |
|
969 | + } |
|
970 | 970 | |
971 | 971 | |
972 | 972 | } //end EEH_Template class |
@@ -975,33 +975,33 @@ discard block |
||
975 | 975 | |
976 | 976 | |
977 | 977 | if ( ! function_exists('espresso_pagination')) { |
978 | - /** |
|
979 | - * espresso_pagination |
|
980 | - * |
|
981 | - * @access public |
|
982 | - * @return void |
|
983 | - */ |
|
984 | - function espresso_pagination() |
|
985 | - { |
|
986 | - global $wp_query; |
|
987 | - $big = 999999999; // need an unlikely integer |
|
988 | - $pagination = paginate_links( |
|
989 | - array( |
|
990 | - 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
991 | - 'format' => '?paged=%#%', |
|
992 | - 'current' => max(1, get_query_var('paged')), |
|
993 | - 'total' => $wp_query->max_num_pages, |
|
994 | - 'show_all' => true, |
|
995 | - 'end_size' => 10, |
|
996 | - 'mid_size' => 6, |
|
997 | - 'prev_next' => true, |
|
998 | - 'prev_text' => __('‹ PREV', 'event_espresso'), |
|
999 | - 'next_text' => __('NEXT ›', 'event_espresso'), |
|
1000 | - 'type' => 'plain', |
|
1001 | - 'add_args' => false, |
|
1002 | - 'add_fragment' => '', |
|
1003 | - ) |
|
1004 | - ); |
|
1005 | - echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : ''; |
|
1006 | - } |
|
978 | + /** |
|
979 | + * espresso_pagination |
|
980 | + * |
|
981 | + * @access public |
|
982 | + * @return void |
|
983 | + */ |
|
984 | + function espresso_pagination() |
|
985 | + { |
|
986 | + global $wp_query; |
|
987 | + $big = 999999999; // need an unlikely integer |
|
988 | + $pagination = paginate_links( |
|
989 | + array( |
|
990 | + 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
991 | + 'format' => '?paged=%#%', |
|
992 | + 'current' => max(1, get_query_var('paged')), |
|
993 | + 'total' => $wp_query->max_num_pages, |
|
994 | + 'show_all' => true, |
|
995 | + 'end_size' => 10, |
|
996 | + 'mid_size' => 6, |
|
997 | + 'prev_next' => true, |
|
998 | + 'prev_text' => __('‹ PREV', 'event_espresso'), |
|
999 | + 'next_text' => __('NEXT ›', 'event_espresso'), |
|
1000 | + 'type' => 'plain', |
|
1001 | + 'add_args' => false, |
|
1002 | + 'add_fragment' => '', |
|
1003 | + ) |
|
1004 | + ); |
|
1005 | + echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : ''; |
|
1006 | + } |
|
1007 | 1007 | } |
1008 | 1008 | \ No newline at end of file |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | use EventEspresso\core\exceptions\InvalidInterfaceException; |
5 | 5 | use EventEspresso\core\services\loaders\LoaderFactory; |
6 | 6 | |
7 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
7 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
8 | 8 | exit('NO direct script access allowed'); |
9 | 9 | } |
10 | 10 | /** |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | public static function load_espresso_theme_functions() |
87 | 87 | { |
88 | 88 | if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) { |
89 | - if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php')) { |
|
90 | - require_once(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php'); |
|
89 | + if (is_readable(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php')) { |
|
90 | + require_once(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php'); |
|
91 | 91 | } |
92 | 92 | } |
93 | 93 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | public static function get_espresso_themes() |
102 | 102 | { |
103 | 103 | if (empty(EEH_Template::$_espresso_themes)) { |
104 | - $espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR); |
|
104 | + $espresso_themes = glob(EE_PUBLIC.'*', GLOB_ONLYDIR); |
|
105 | 105 | if (empty($espresso_themes)) { |
106 | 106 | return array(); |
107 | 107 | } |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | ) { |
138 | 138 | do_action("get_template_part_{$slug}-{$name}", $slug, $name); |
139 | 139 | $templates = array(); |
140 | - $name = (string)$name; |
|
140 | + $name = (string) $name; |
|
141 | 141 | if ($name != '') { |
142 | 142 | $templates[] = "{$slug}-{$name}.php"; |
143 | 143 | } |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | if (isset($EE_CPTs[$post_type])) { |
225 | 225 | $archive_or_single = is_archive() ? 'archive' : ''; |
226 | 226 | $archive_or_single = is_single() ? 'single' : $archive_or_single; |
227 | - $templates = $archive_or_single . '-' . $post_type . '.php'; |
|
227 | + $templates = $archive_or_single.'-'.$post_type.'.php'; |
|
228 | 228 | } |
229 | 229 | } |
230 | 230 | // currently active EE template theme |
@@ -233,18 +233,18 @@ discard block |
||
233 | 233 | // array of paths to folders that may contain templates |
234 | 234 | $template_folder_paths = array( |
235 | 235 | // first check the /wp-content/uploads/espresso/templates/(current EE theme)/ folder for an EE theme template file |
236 | - EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme, |
|
236 | + EVENT_ESPRESSO_TEMPLATE_DIR.$current_theme, |
|
237 | 237 | // then in the root of the /wp-content/uploads/espresso/templates/ folder |
238 | 238 | EVENT_ESPRESSO_TEMPLATE_DIR, |
239 | 239 | ); |
240 | 240 | |
241 | 241 | //add core plugin folders for checking only if we're not $check_if_custom |
242 | 242 | if ( ! $check_if_custom) { |
243 | - $core_paths = array( |
|
243 | + $core_paths = array( |
|
244 | 244 | // in the /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin |
245 | - EE_PUBLIC . $current_theme, |
|
245 | + EE_PUBLIC.$current_theme, |
|
246 | 246 | // in the /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin |
247 | - EE_TEMPLATES . $current_theme, |
|
247 | + EE_TEMPLATES.$current_theme, |
|
248 | 248 | // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/ |
249 | 249 | EE_PLUGIN_DIR_PATH, |
250 | 250 | ); |
@@ -275,10 +275,10 @@ discard block |
||
275 | 275 | ); |
276 | 276 | if ($common_base_path !== '') { |
277 | 277 | // both paths have a common base, so just tack the filename onto our search path |
278 | - $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name; |
|
278 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$file_name; |
|
279 | 279 | } else { |
280 | 280 | // no common base path, so let's just concatenate |
281 | - $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template; |
|
281 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$template; |
|
282 | 282 | } |
283 | 283 | // build up our template locations array by adding our resolved paths |
284 | 284 | $full_template_paths[] = $resolved_path; |
@@ -286,13 +286,13 @@ discard block |
||
286 | 286 | // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first |
287 | 287 | array_unshift($full_template_paths, $template); |
288 | 288 | // path to the directory of the current theme: /wp-content/themes/(current WP theme)/ |
289 | - array_unshift($full_template_paths, get_stylesheet_directory() . DS . $file_name); |
|
289 | + array_unshift($full_template_paths, get_stylesheet_directory().DS.$file_name); |
|
290 | 290 | } |
291 | 291 | // filter final array of full template paths |
292 | 292 | $full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths', |
293 | 293 | $full_template_paths, $file_name); |
294 | 294 | // now loop through our final array of template location paths and check each location |
295 | - foreach ((array)$full_template_paths as $full_template_path) { |
|
295 | + foreach ((array) $full_template_paths as $full_template_path) { |
|
296 | 296 | if (is_readable($full_template_path)) { |
297 | 297 | $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path); |
298 | 298 | break; |
@@ -379,9 +379,9 @@ discard block |
||
379 | 379 | if ( ! is_array($template_args) && ! is_object($template_args)) { |
380 | 380 | $template_args = array($template_args); |
381 | 381 | } |
382 | - extract( $template_args, EXTR_SKIP ); |
|
382 | + extract($template_args, EXTR_SKIP); |
|
383 | 383 | // ignore whether template is accessible ? |
384 | - if ( $throw_exceptions && ! is_readable( $template_path ) ) { |
|
384 | + if ($throw_exceptions && ! is_readable($template_path)) { |
|
385 | 385 | throw new \DomainException( |
386 | 386 | esc_html__( |
387 | 387 | 'Invalid, unreadable, or missing file.', |
@@ -414,11 +414,11 @@ discard block |
||
414 | 414 | public static function get_object_css_class($object = null, $prefix = '', $suffix = '') |
415 | 415 | { |
416 | 416 | // in the beginning... |
417 | - $prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : ''; |
|
417 | + $prefix = ! empty($prefix) ? rtrim($prefix, '-').'-' : ''; |
|
418 | 418 | // da muddle |
419 | 419 | $class = ''; |
420 | 420 | // the end |
421 | - $suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : ''; |
|
421 | + $suffix = ! empty($suffix) ? '-'.ltrim($suffix, '-') : ''; |
|
422 | 422 | // is the passed object an EE object ? |
423 | 423 | if ($object instanceof EE_Base_Class) { |
424 | 424 | // grab the exact type of object |
@@ -428,11 +428,11 @@ discard block |
||
428 | 428 | // no specifics just yet... |
429 | 429 | default : |
430 | 430 | $class = strtolower(str_replace('_', '-', $obj_class)); |
431 | - $class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : ''; |
|
431 | + $class .= method_exists($obj_class, 'name') ? '-'.sanitize_title($object->name()) : ''; |
|
432 | 432 | |
433 | 433 | } |
434 | 434 | } |
435 | - return $prefix . $class . $suffix; |
|
435 | + return $prefix.$class.$suffix; |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | return ''; |
465 | 465 | } |
466 | 466 | //ensure amount is float |
467 | - $amount = apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float)$amount); |
|
467 | + $amount = apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float) $amount); |
|
468 | 468 | $CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount); |
469 | 469 | // filter raw amount (allows 0.00 to be changed to "free" for example) |
470 | 470 | $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw); |
@@ -486,20 +486,20 @@ discard block |
||
486 | 486 | // add currency sign |
487 | 487 | if ($mny->sign_b4) { |
488 | 488 | if ($amount >= 0) { |
489 | - $amount_formatted = $mny->sign . $amount_formatted; |
|
489 | + $amount_formatted = $mny->sign.$amount_formatted; |
|
490 | 490 | } else { |
491 | - $amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted); |
|
491 | + $amount_formatted = '-'.$mny->sign.str_replace('-', '', $amount_formatted); |
|
492 | 492 | } |
493 | 493 | |
494 | 494 | } else { |
495 | - $amount_formatted = $amount_formatted . $mny->sign; |
|
495 | + $amount_formatted = $amount_formatted.$mny->sign; |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | // filter to allow global setting of display_code |
499 | 499 | $display_code = apply_filters('FHEE__EEH_Template__format_currency__display_code', $display_code); |
500 | 500 | |
501 | 501 | // add currency code ? |
502 | - $amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted; |
|
502 | + $amount_formatted = $display_code ? $amount_formatted.' <span class="'.$cur_code_span_class.'">('.$mny->code.')</span>' : $amount_formatted; |
|
503 | 503 | } |
504 | 504 | // filter results |
505 | 505 | $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted', |
@@ -553,12 +553,12 @@ discard block |
||
553 | 553 | $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : ''; |
554 | 554 | foreach ($dashicons as $dashicon) { |
555 | 555 | $type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons '; |
556 | - $icon_html .= '<span class="' . $type . $dashicon . '"></span>'; |
|
556 | + $icon_html .= '<span class="'.$type.$dashicon.'"></span>'; |
|
557 | 557 | } |
558 | 558 | $icon_html .= $count > 1 ? '</span>' : ''; |
559 | 559 | } |
560 | - $label = ! empty($icon) ? $icon_html . $label : $label; |
|
561 | - $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . esc_url($url) . '" class="' . $class . '" title="' . $title . '">' . $label . '</a>'; |
|
560 | + $label = ! empty($icon) ? $icon_html.$label : $label; |
|
561 | + $button = '<a id="'.sanitize_title_with_dashes($label).'" href="'.esc_url($url).'" class="'.$class.'" title="'.$title.'">'.$label.'</a>'; |
|
562 | 562 | return $button; |
563 | 563 | } |
564 | 564 | |
@@ -592,11 +592,11 @@ discard block |
||
592 | 592 | $action = empty($action) ? 'default' : $action; |
593 | 593 | |
594 | 594 | |
595 | - $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id; |
|
595 | + $help_tab_lnk = $page.'-'.$action.'-'.$help_tab_id; |
|
596 | 596 | $icon = ! $icon_style ? ' dashicons-editor-help' : $icon_style; |
597 | 597 | $help_text = ! $help_text ? '' : $help_text; |
598 | - return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.', |
|
599 | - 'event_espresso') . '" > ' . $help_text . ' </a>'; |
|
598 | + return '<a id="'.$help_tab_lnk.'" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22'.$icon.'" title="'.esc_attr__('Click to open the \'Help\' tab for more information about this feature.', |
|
599 | + 'event_espresso').'" > '.$help_text.' </a>'; |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | |
@@ -613,11 +613,11 @@ discard block |
||
613 | 613 | $id = $tour->get_slug(); |
614 | 614 | $stops = $tour->get_stops(); |
615 | 615 | |
616 | - $content = '<ol style="display:none" id="' . $id . '">'; |
|
616 | + $content = '<ol style="display:none" id="'.$id.'">'; |
|
617 | 617 | |
618 | 618 | foreach ($stops as $stop) { |
619 | - $data_id = ! empty($stop['id']) ? ' data-id="' . $stop['id'] . '"' : ''; |
|
620 | - $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="' . $stop['class'] . '"' : ''; |
|
619 | + $data_id = ! empty($stop['id']) ? ' data-id="'.$stop['id'].'"' : ''; |
|
620 | + $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="'.$stop['class'].'"' : ''; |
|
621 | 621 | |
622 | 622 | //if container is set to modal then let's make sure we set the options accordingly |
623 | 623 | if (empty($data_id) && empty($data_class)) { |
@@ -625,15 +625,15 @@ discard block |
||
625 | 625 | $stop['options']['expose'] = true; |
626 | 626 | } |
627 | 627 | |
628 | - $custom_class = ! empty($stop['custom_class']) ? ' class="' . $stop['custom_class'] . '"' : ''; |
|
629 | - $button_text = ! empty($stop['button_text']) ? ' data-button="' . $stop['button_text'] . '"' : ''; |
|
628 | + $custom_class = ! empty($stop['custom_class']) ? ' class="'.$stop['custom_class'].'"' : ''; |
|
629 | + $button_text = ! empty($stop['button_text']) ? ' data-button="'.$stop['button_text'].'"' : ''; |
|
630 | 630 | $inner_content = isset($stop['content']) ? $stop['content'] : ''; |
631 | 631 | |
632 | 632 | //options |
633 | 633 | if (isset($stop['options']) && is_array($stop['options'])) { |
634 | 634 | $options = ' data-options="'; |
635 | 635 | foreach ($stop['options'] as $option => $value) { |
636 | - $options .= $option . ':' . $value . ';'; |
|
636 | + $options .= $option.':'.$value.';'; |
|
637 | 637 | } |
638 | 638 | $options .= '"'; |
639 | 639 | } else { |
@@ -641,7 +641,7 @@ discard block |
||
641 | 641 | } |
642 | 642 | |
643 | 643 | //let's put all together |
644 | - $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>'; |
|
644 | + $content .= '<li'.$data_id.$data_class.$custom_class.$button_text.$options.'>'.$inner_content.'</li>'; |
|
645 | 645 | } |
646 | 646 | |
647 | 647 | $content .= '</ol>'; |
@@ -673,24 +673,24 @@ discard block |
||
673 | 673 | $setup_array = array(); |
674 | 674 | foreach ($status_array as $item => $status) { |
675 | 675 | $setup_array[$item] = array( |
676 | - 'class' => 'ee-status-legend ee-status-legend-' . $status, |
|
676 | + 'class' => 'ee-status-legend ee-status-legend-'.$status, |
|
677 | 677 | 'desc' => EEH_Template::pretty_status($status, false, 'sentence'), |
678 | 678 | 'status' => $status, |
679 | 679 | ); |
680 | 680 | } |
681 | 681 | |
682 | - $content = '<div class="ee-list-table-legend-container">' . "\n"; |
|
683 | - $content .= '<h4 class="status-legend-title">' . esc_html__('Status Legend', 'event_espresso') . '</h4>' . "\n"; |
|
684 | - $content .= '<dl class="ee-list-table-legend">' . "\n\t"; |
|
682 | + $content = '<div class="ee-list-table-legend-container">'."\n"; |
|
683 | + $content .= '<h4 class="status-legend-title">'.esc_html__('Status Legend', 'event_espresso').'</h4>'."\n"; |
|
684 | + $content .= '<dl class="ee-list-table-legend">'."\n\t"; |
|
685 | 685 | foreach ($setup_array as $item => $details) { |
686 | 686 | $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : ''; |
687 | - $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t"; |
|
688 | - $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t"; |
|
689 | - $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t"; |
|
690 | - $content .= '</dt>' . "\n"; |
|
687 | + $content .= '<dt id="ee-legend-item-tooltip-'.$item.'"'.$active_class.'>'."\n\t\t"; |
|
688 | + $content .= '<span class="'.$details['class'].'"></span>'."\n\t\t"; |
|
689 | + $content .= '<span class="ee-legend-description">'.$details['desc'].'</span>'."\n\t"; |
|
690 | + $content .= '</dt>'."\n"; |
|
691 | 691 | } |
692 | - $content .= '</dl>' . "\n"; |
|
693 | - $content .= '</div>' . "\n"; |
|
692 | + $content .= '</dl>'."\n"; |
|
693 | + $content .= '</div>'."\n"; |
|
694 | 694 | return $content; |
695 | 695 | } |
696 | 696 | |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | public static function layout_array_as_table($data) |
706 | 706 | { |
707 | 707 | if (is_object($data) || $data instanceof __PHP_Incomplete_Class) { |
708 | - $data = (array)$data; |
|
708 | + $data = (array) $data; |
|
709 | 709 | } |
710 | 710 | ob_start(); |
711 | 711 | if (is_array($data)) { |
@@ -806,9 +806,9 @@ discard block |
||
806 | 806 | ) { |
807 | 807 | $page_links = array(); |
808 | 808 | $disable_first = $disable_last = ''; |
809 | - $total_items = (int)$total_items; |
|
810 | - $per_page = (int)$per_page; |
|
811 | - $current = (int)$current; |
|
809 | + $total_items = (int) $total_items; |
|
810 | + $per_page = (int) $per_page; |
|
811 | + $current = (int) $current; |
|
812 | 812 | $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name); |
813 | 813 | |
814 | 814 | //filter items_label |
@@ -828,8 +828,8 @@ discard block |
||
828 | 828 | ); |
829 | 829 | } else { |
830 | 830 | $items_label = array( |
831 | - 'single' => '1 ' . esc_html($items_label['single']), |
|
832 | - 'plural' => '%s ' . esc_html($items_label['plural']), |
|
831 | + 'single' => '1 '.esc_html($items_label['single']), |
|
832 | + 'plural' => '%s '.esc_html($items_label['plural']), |
|
833 | 833 | ); |
834 | 834 | } |
835 | 835 | |
@@ -841,7 +841,7 @@ discard block |
||
841 | 841 | |
842 | 842 | $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single']; |
843 | 843 | |
844 | - $output = '<span class="displaying-num">' . $item_label . '</span>'; |
|
844 | + $output = '<span class="displaying-num">'.$item_label.'</span>'; |
|
845 | 845 | |
846 | 846 | if ($current === 1) { |
847 | 847 | $disable_first = ' disabled'; |
@@ -851,7 +851,7 @@ discard block |
||
851 | 851 | } |
852 | 852 | |
853 | 853 | $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>", |
854 | - 'first-page' . $disable_first, |
|
854 | + 'first-page'.$disable_first, |
|
855 | 855 | esc_attr__('Go to the first page'), |
856 | 856 | esc_url(remove_query_arg($paged_arg_name, $url)), |
857 | 857 | '«' |
@@ -859,7 +859,7 @@ discard block |
||
859 | 859 | |
860 | 860 | $page_links[] = sprintf( |
861 | 861 | '<a class="%s" title="%s" href="%s">%s</a>', |
862 | - 'prev-page' . $disable_first, |
|
862 | + 'prev-page'.$disable_first, |
|
863 | 863 | esc_attr__('Go to the previous page'), |
864 | 864 | esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)), |
865 | 865 | '‹' |
@@ -879,7 +879,7 @@ discard block |
||
879 | 879 | '<span class="total-pages">%s</span>', |
880 | 880 | number_format_i18n($total_pages) |
881 | 881 | ); |
882 | - $page_links[] = sprintf( |
|
882 | + $page_links[] = sprintf( |
|
883 | 883 | _x('%3$s%1$s of %2$s%4$s', 'paging'), |
884 | 884 | $html_current_page, |
885 | 885 | $html_total_pages, |
@@ -889,7 +889,7 @@ discard block |
||
889 | 889 | |
890 | 890 | $page_links[] = sprintf( |
891 | 891 | '<a class="%s" title="%s" href="%s">%s</a>', |
892 | - 'next-page' . $disable_last, |
|
892 | + 'next-page'.$disable_last, |
|
893 | 893 | esc_attr__('Go to the next page'), |
894 | 894 | esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)), |
895 | 895 | '›' |
@@ -897,13 +897,13 @@ discard block |
||
897 | 897 | |
898 | 898 | $page_links[] = sprintf( |
899 | 899 | '<a class="%s" title="%s" href="%s">%s</a>', |
900 | - 'last-page' . $disable_last, |
|
900 | + 'last-page'.$disable_last, |
|
901 | 901 | esc_attr__('Go to the last page'), |
902 | 902 | esc_url(add_query_arg($paged_arg_name, $total_pages, $url)), |
903 | 903 | '»' |
904 | 904 | ); |
905 | 905 | |
906 | - $output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>'; |
|
906 | + $output .= "\n".'<span class="pagination-links">'.join("\n", $page_links).'</span>'; |
|
907 | 907 | // set page class |
908 | 908 | if ($total_pages) { |
909 | 909 | $page_class = $total_pages < 2 ? ' one-page' : ''; |
@@ -911,7 +911,7 @@ discard block |
||
911 | 911 | $page_class = ' no-pages'; |
912 | 912 | } |
913 | 913 | |
914 | - return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>'; |
|
914 | + return '<div class="tablenav"><div class="tablenav-pages'.$page_class.'">'.$output.'</div></div>'; |
|
915 | 915 | } |
916 | 916 | |
917 | 917 | |
@@ -948,10 +948,10 @@ discard block |
||
948 | 948 | $query_args |
949 | 949 | ); |
950 | 950 | $powered_by = apply_filters('FHEE__EEH_Template__powered_by_event_espresso_text', |
951 | - $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso'); |
|
951 | + $admin ? 'Event Espresso - '.EVENT_ESPRESSO_VERSION : 'Event Espresso'); |
|
952 | 952 | $url = add_query_arg($query_args, 'https://eventespresso.com/'); |
953 | 953 | $url = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url); |
954 | - return (string)apply_filters( |
|
954 | + return (string) apply_filters( |
|
955 | 955 | 'FHEE__EEH_Template__powered_by_event_espresso__html', |
956 | 956 | sprintf( |
957 | 957 | esc_html_x( |
@@ -1002,6 +1002,6 @@ discard block |
||
1002 | 1002 | 'add_fragment' => '', |
1003 | 1003 | ) |
1004 | 1004 | ); |
1005 | - echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : ''; |
|
1005 | + echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">'.$pagination.'</div>' : ''; |
|
1006 | 1006 | } |
1007 | 1007 | } |
1008 | 1008 | \ No newline at end of file |
@@ -104,46 +104,46 @@ discard block |
||
104 | 104 | '4.5.0' |
105 | 105 | ); |
106 | 106 | } |
107 | - //validate incoming args |
|
108 | - $validated = array( |
|
109 | - 'cpts' => isset($setup_args['cpts']) |
|
110 | - ? (array) $setup_args['cpts'] |
|
111 | - : array(), |
|
112 | - 'cts' => isset($setup_args['cts']) |
|
113 | - ? (array) $setup_args['cts'] |
|
114 | - : array(), |
|
115 | - 'default_terms' => isset($setup_args['default_terms']) |
|
116 | - ? (array) $setup_args['default_terms'] |
|
117 | - : array(), |
|
118 | - ); |
|
107 | + //validate incoming args |
|
108 | + $validated = array( |
|
109 | + 'cpts' => isset($setup_args['cpts']) |
|
110 | + ? (array) $setup_args['cpts'] |
|
111 | + : array(), |
|
112 | + 'cts' => isset($setup_args['cts']) |
|
113 | + ? (array) $setup_args['cts'] |
|
114 | + : array(), |
|
115 | + 'default_terms' => isset($setup_args['default_terms']) |
|
116 | + ? (array) $setup_args['default_terms'] |
|
117 | + : array(), |
|
118 | + ); |
|
119 | 119 | |
120 | 120 | self::$_registry[$cpt_ref] = $validated; |
121 | 121 | |
122 | 122 | //hook into to cpt system |
123 | 123 | add_filter( |
124 | - 'FHEE__EventEspresso_core_domain_entities_custom_post_types_CustomPostTypeDefinitions__getCustomPostTypes', |
|
125 | - array( __CLASS__, 'filterCustomPostTypeDefinitions' ), |
|
126 | - 5 |
|
127 | - ); |
|
124 | + 'FHEE__EventEspresso_core_domain_entities_custom_post_types_CustomPostTypeDefinitions__getCustomPostTypes', |
|
125 | + array( __CLASS__, 'filterCustomPostTypeDefinitions' ), |
|
126 | + 5 |
|
127 | + ); |
|
128 | 128 | add_filter( |
129 | - 'FHEE__EventEspresso_core_domain_entities_custom_post_types_TaxonomyDefinitions__getTaxonomies', |
|
130 | - array( __CLASS__, 'filterCustomTaxonomyDefinitions' ), |
|
131 | - 5 |
|
132 | - ); |
|
129 | + 'FHEE__EventEspresso_core_domain_entities_custom_post_types_TaxonomyDefinitions__getTaxonomies', |
|
130 | + array( __CLASS__, 'filterCustomTaxonomyDefinitions' ), |
|
131 | + 5 |
|
132 | + ); |
|
133 | 133 | add_action( |
134 | - 'AHEE__EventEspresso_core_domain_services_custom_post_types_RegisterCustomTaxonomyTerms__construct_end', |
|
135 | - array( __CLASS__, 'registerCustomTaxonomyTerm'), |
|
136 | - 5 |
|
137 | - ); |
|
134 | + 'AHEE__EventEspresso_core_domain_services_custom_post_types_RegisterCustomTaxonomyTerms__construct_end', |
|
135 | + array( __CLASS__, 'registerCustomTaxonomyTerm'), |
|
136 | + 5 |
|
137 | + ); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | |
141 | 141 | |
142 | 142 | |
143 | 143 | /** |
144 | - * Callback for |
|
145 | - * FHEE__EventEspresso_core_domain_entities_custom_post_types_CustomPostTypeDefinitions__getCustomPostTypes |
|
146 | - * that adds additional custom post types to be registered. |
|
144 | + * Callback for |
|
145 | + * FHEE__EventEspresso_core_domain_entities_custom_post_types_CustomPostTypeDefinitions__getCustomPostTypes |
|
146 | + * that adds additional custom post types to be registered. |
|
147 | 147 | * |
148 | 148 | * @param array $custom_post_type_definitions array of cpts that are already set |
149 | 149 | * @return array new array of cpts and their registration information |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | public static function filterCustomPostTypeDefinitions( $custom_post_type_definitions ) { |
152 | 152 | foreach( self::$_registry as $registries ) { |
153 | 153 | foreach ( $registries['cpts'] as $cpt_name => $cpt_settings ) { |
154 | - $custom_post_type_definitions[$cpt_name] = $cpt_settings; |
|
154 | + $custom_post_type_definitions[$cpt_name] = $cpt_settings; |
|
155 | 155 | } |
156 | 156 | } |
157 | 157 | return $custom_post_type_definitions; |
@@ -160,9 +160,9 @@ discard block |
||
160 | 160 | |
161 | 161 | |
162 | 162 | /** |
163 | - * Callback for |
|
164 | - * FHEE__EventEspresso_core_domain_entities_custom_post_types_TaxonomyDefinitions__getTaxonomies |
|
165 | - * that adds additional custom taxonomies to be registered. |
|
163 | + * Callback for |
|
164 | + * FHEE__EventEspresso_core_domain_entities_custom_post_types_TaxonomyDefinitions__getTaxonomies |
|
165 | + * that adds additional custom taxonomies to be registered. |
|
166 | 166 | * |
167 | 167 | * @param array $custom_taxonomy_definitions array of cts that are already set. |
168 | 168 | * @return array new array of cts and their registration information. |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | public static function filterCustomTaxonomyDefinitions( $custom_taxonomy_definitions ) { |
171 | 171 | foreach( self::$_registry as $registries ) { |
172 | 172 | foreach( $registries['cts'] as $ct_name => $ct_settings ) { |
173 | - $custom_taxonomy_definitions[$ct_name] = $ct_settings; |
|
173 | + $custom_taxonomy_definitions[$ct_name] = $ct_settings; |
|
174 | 174 | } |
175 | 175 | } |
176 | 176 | return $custom_taxonomy_definitions; |
@@ -180,27 +180,27 @@ discard block |
||
180 | 180 | |
181 | 181 | |
182 | 182 | /** |
183 | - * Callback for |
|
184 | - * AHEE__EventEspresso_core_domain_services_custom_post_types_RegisterCustomTaxonomyTerms__construct_end |
|
185 | - * which is used to set the default terms |
|
183 | + * Callback for |
|
184 | + * AHEE__EventEspresso_core_domain_services_custom_post_types_RegisterCustomTaxonomyTerms__construct_end |
|
185 | + * which is used to set the default terms |
|
186 | 186 | * |
187 | 187 | * @param RegisterCustomTaxonomyTerms $register_custom_taxonomy_terms |
188 | 188 | * @return void |
189 | 189 | */ |
190 | - public static function registerCustomTaxonomyTerm(RegisterCustomTaxonomyTerms $register_custom_taxonomy_terms) |
|
191 | - { |
|
192 | - foreach (self::$_registry as $registries) { |
|
193 | - foreach ($registries['default_terms'] as $taxonomy => $terms) { |
|
194 | - foreach ($terms as $term => $cpts) { |
|
195 | - $register_custom_taxonomy_terms->registerCustomTaxonomyTerm( |
|
196 | - $taxonomy, |
|
197 | - $term, |
|
198 | - $cpts |
|
199 | - ); |
|
200 | - } |
|
201 | - } |
|
202 | - } |
|
203 | - } |
|
190 | + public static function registerCustomTaxonomyTerm(RegisterCustomTaxonomyTerms $register_custom_taxonomy_terms) |
|
191 | + { |
|
192 | + foreach (self::$_registry as $registries) { |
|
193 | + foreach ($registries['default_terms'] as $taxonomy => $terms) { |
|
194 | + foreach ($terms as $term => $cpts) { |
|
195 | + $register_custom_taxonomy_terms->registerCustomTaxonomyTerm( |
|
196 | + $taxonomy, |
|
197 | + $term, |
|
198 | + $cpts |
|
199 | + ); |
|
200 | + } |
|
201 | + } |
|
202 | + } |
|
203 | + } |
|
204 | 204 | |
205 | 205 | |
206 | 206 | |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | |
209 | 209 | |
210 | 210 | /** |
211 | - * @deprecated $VID:$ |
|
211 | + * @deprecated $VID:$ |
|
212 | 212 | * @param array $cpts array of cpts that are already set |
213 | 213 | * @return array new array of cpts and their registration information |
214 | 214 | */ |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | |
225 | 225 | |
226 | 226 | /** |
227 | - * @deprecated $VID:$ |
|
227 | + * @deprecated $VID:$ |
|
228 | 228 | * @param array $cts array of cts that are already set. |
229 | 229 | * @return array new array of cts and their registration information. |
230 | 230 | */ |
@@ -241,8 +241,8 @@ discard block |
||
241 | 241 | |
242 | 242 | |
243 | 243 | /** |
244 | - * @deprecated $VID:$ |
|
245 | - * @param EE_Register_CPTs $cpt_class |
|
244 | + * @deprecated $VID:$ |
|
245 | + * @param EE_Register_CPTs $cpt_class |
|
246 | 246 | * @return void |
247 | 247 | */ |
248 | 248 | public static function default_terms( EE_Register_CPTs $cpt_class ) { |
@@ -68,33 +68,33 @@ discard block |
||
68 | 68 | * @throws EE_Error |
69 | 69 | * @return void |
70 | 70 | */ |
71 | - public static function register( $cpt_ref = NULL, $setup_args = array() ) { |
|
71 | + public static function register($cpt_ref = NULL, $setup_args = array()) { |
|
72 | 72 | |
73 | 73 | //check for required params |
74 | - if ( empty( $cpt_ref ) ) { |
|
74 | + if (empty($cpt_ref)) { |
|
75 | 75 | throw new EE_Error( |
76 | - __('In order to register custom post types and custom taxonomies, you must include a value to reference what had been registered', 'event_espresso' ) |
|
76 | + __('In order to register custom post types and custom taxonomies, you must include a value to reference what had been registered', 'event_espresso') |
|
77 | 77 | ); |
78 | 78 | } |
79 | 79 | |
80 | - if ( ! is_array( $setup_args ) || ( empty( $setup_args['cpts'] ) && empty( $setup_args['cts'] ) ) ) { |
|
80 | + if ( ! is_array($setup_args) || (empty($setup_args['cpts']) && empty($setup_args['cts']))) { |
|
81 | 81 | throw new EE_Error( |
82 | - __( 'In order to register custom post types or custom taxonomies, you must include an array containing either an array of custom post types to register (key "cpts"), an array of custom taxonomies ("cts") or both.', 'event_espresso' ) |
|
82 | + __('In order to register custom post types or custom taxonomies, you must include an array containing either an array of custom post types to register (key "cpts"), an array of custom taxonomies ("cts") or both.', 'event_espresso') |
|
83 | 83 | ); |
84 | 84 | } |
85 | 85 | |
86 | 86 | //make sure we don't register twice |
87 | - if( isset( self::$_registry[ $cpt_ref ] ) ){ |
|
87 | + if (isset(self::$_registry[$cpt_ref])) { |
|
88 | 88 | return; |
89 | 89 | } |
90 | 90 | |
91 | 91 | //make sure cpt ref is unique. |
92 | - if ( isset( self::$_registry[$cpt_ref] ) ) { |
|
93 | - $cpt_ref = uniqid() . '_' . $cpt_ref; |
|
92 | + if (isset(self::$_registry[$cpt_ref])) { |
|
93 | + $cpt_ref = uniqid().'_'.$cpt_ref; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | //make sure this was called in the right place! |
97 | - if ( did_action( 'AHEE__EE_System__load_CPTs_and_session__complete' ) ) { |
|
97 | + if (did_action('AHEE__EE_System__load_CPTs_and_session__complete')) { |
|
98 | 98 | EE_Error::doing_it_wrong( |
99 | 99 | __METHOD__, |
100 | 100 | sprintf( |
@@ -122,17 +122,17 @@ discard block |
||
122 | 122 | //hook into to cpt system |
123 | 123 | add_filter( |
124 | 124 | 'FHEE__EventEspresso_core_domain_entities_custom_post_types_CustomPostTypeDefinitions__getCustomPostTypes', |
125 | - array( __CLASS__, 'filterCustomPostTypeDefinitions' ), |
|
125 | + array(__CLASS__, 'filterCustomPostTypeDefinitions'), |
|
126 | 126 | 5 |
127 | 127 | ); |
128 | 128 | add_filter( |
129 | 129 | 'FHEE__EventEspresso_core_domain_entities_custom_post_types_TaxonomyDefinitions__getTaxonomies', |
130 | - array( __CLASS__, 'filterCustomTaxonomyDefinitions' ), |
|
130 | + array(__CLASS__, 'filterCustomTaxonomyDefinitions'), |
|
131 | 131 | 5 |
132 | 132 | ); |
133 | 133 | add_action( |
134 | 134 | 'AHEE__EventEspresso_core_domain_services_custom_post_types_RegisterCustomTaxonomyTerms__construct_end', |
135 | - array( __CLASS__, 'registerCustomTaxonomyTerm'), |
|
135 | + array(__CLASS__, 'registerCustomTaxonomyTerm'), |
|
136 | 136 | 5 |
137 | 137 | ); |
138 | 138 | } |
@@ -148,9 +148,9 @@ discard block |
||
148 | 148 | * @param array $custom_post_type_definitions array of cpts that are already set |
149 | 149 | * @return array new array of cpts and their registration information |
150 | 150 | */ |
151 | - public static function filterCustomPostTypeDefinitions( $custom_post_type_definitions ) { |
|
152 | - foreach( self::$_registry as $registries ) { |
|
153 | - foreach ( $registries['cpts'] as $cpt_name => $cpt_settings ) { |
|
151 | + public static function filterCustomPostTypeDefinitions($custom_post_type_definitions) { |
|
152 | + foreach (self::$_registry as $registries) { |
|
153 | + foreach ($registries['cpts'] as $cpt_name => $cpt_settings) { |
|
154 | 154 | $custom_post_type_definitions[$cpt_name] = $cpt_settings; |
155 | 155 | } |
156 | 156 | } |
@@ -167,9 +167,9 @@ discard block |
||
167 | 167 | * @param array $custom_taxonomy_definitions array of cts that are already set. |
168 | 168 | * @return array new array of cts and their registration information. |
169 | 169 | */ |
170 | - public static function filterCustomTaxonomyDefinitions( $custom_taxonomy_definitions ) { |
|
171 | - foreach( self::$_registry as $registries ) { |
|
172 | - foreach( $registries['cts'] as $ct_name => $ct_settings ) { |
|
170 | + public static function filterCustomTaxonomyDefinitions($custom_taxonomy_definitions) { |
|
171 | + foreach (self::$_registry as $registries) { |
|
172 | + foreach ($registries['cts'] as $ct_name => $ct_settings) { |
|
173 | 173 | $custom_taxonomy_definitions[$ct_name] = $ct_settings; |
174 | 174 | } |
175 | 175 | } |
@@ -212,9 +212,9 @@ discard block |
||
212 | 212 | * @param array $cpts array of cpts that are already set |
213 | 213 | * @return array new array of cpts and their registration information |
214 | 214 | */ |
215 | - public static function filter_cpts( $cpts ) { |
|
216 | - foreach( self::$_registry as $registries ) { |
|
217 | - foreach ( $registries['cpts'] as $cpt_name => $cpt_settings ) { |
|
215 | + public static function filter_cpts($cpts) { |
|
216 | + foreach (self::$_registry as $registries) { |
|
217 | + foreach ($registries['cpts'] as $cpt_name => $cpt_settings) { |
|
218 | 218 | $cpts[$cpt_name] = $cpt_settings; |
219 | 219 | } |
220 | 220 | } |
@@ -228,9 +228,9 @@ discard block |
||
228 | 228 | * @param array $cts array of cts that are already set. |
229 | 229 | * @return array new array of cts and their registration information. |
230 | 230 | */ |
231 | - public static function filter_cts( $cts ) { |
|
232 | - foreach( self::$_registry as $registries ) { |
|
233 | - foreach( $registries['cts'] as $ct_name => $ct_settings ) { |
|
231 | + public static function filter_cts($cts) { |
|
232 | + foreach (self::$_registry as $registries) { |
|
233 | + foreach ($registries['cts'] as $ct_name => $ct_settings) { |
|
234 | 234 | $cts[$ct_name] = $ct_settings; |
235 | 235 | } |
236 | 236 | } |
@@ -245,11 +245,11 @@ discard block |
||
245 | 245 | * @param EE_Register_CPTs $cpt_class |
246 | 246 | * @return void |
247 | 247 | */ |
248 | - public static function default_terms( EE_Register_CPTs $cpt_class ) { |
|
249 | - foreach( self::$_registry as $registries ) { |
|
250 | - foreach( $registries['default_terms'] as $taxonomy => $terms ) { |
|
251 | - foreach ( $terms as $term => $cpts ) { |
|
252 | - $cpt_class->set_default_term( $taxonomy, $term, $cpts ); |
|
248 | + public static function default_terms(EE_Register_CPTs $cpt_class) { |
|
249 | + foreach (self::$_registry as $registries) { |
|
250 | + foreach ($registries['default_terms'] as $taxonomy => $terms) { |
|
251 | + foreach ($terms as $term => $cpts) { |
|
252 | + $cpt_class->set_default_term($taxonomy, $term, $cpts); |
|
253 | 253 | } |
254 | 254 | } |
255 | 255 | } |
@@ -266,9 +266,9 @@ discard block |
||
266 | 266 | * |
267 | 267 | * @return void |
268 | 268 | */ |
269 | - public static function deregister( $cpt_ref = null ) { |
|
270 | - if ( !empty( self::$_registry[$cpt_ref] ) ) { |
|
271 | - unset( self::$_registry[$cpt_ref] ); |
|
269 | + public static function deregister($cpt_ref = null) { |
|
270 | + if ( ! empty(self::$_registry[$cpt_ref])) { |
|
271 | + unset(self::$_registry[$cpt_ref]); |
|
272 | 272 | } |
273 | 273 | } |
274 | 274 | } //end class EE_Register_CPT |
@@ -8,7 +8,9 @@ |
||
8 | 8 | |
9 | 9 | use EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomyTerms; |
10 | 10 | |
11 | -if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
11 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
12 | + exit('No direct script access allowed'); |
|
13 | +} |
|
12 | 14 | |
13 | 15 | /** |
14 | 16 | * Use this to register or deregister a new custom post type or custom taxonomy for the EE CPT system. |
@@ -21,288 +21,288 @@ |
||
21 | 21 | class CustomPostTypeDefinitions |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * @var EE_Core_Config |
|
26 | - */ |
|
27 | - public $core_config; |
|
24 | + /** |
|
25 | + * @var EE_Core_Config |
|
26 | + */ |
|
27 | + public $core_config; |
|
28 | 28 | |
29 | - /** |
|
30 | - * @var array $custom_post_types |
|
31 | - */ |
|
32 | - private $custom_post_types; |
|
29 | + /** |
|
30 | + * @var array $custom_post_types |
|
31 | + */ |
|
32 | + private $custom_post_types; |
|
33 | 33 | |
34 | - /** |
|
35 | - * @var LoaderInterface $loader |
|
36 | - */ |
|
37 | - private $loader; |
|
34 | + /** |
|
35 | + * @var LoaderInterface $loader |
|
36 | + */ |
|
37 | + private $loader; |
|
38 | 38 | |
39 | 39 | |
40 | - /** |
|
41 | - * EspressoCustomPostTypeDefinitions constructor. |
|
42 | - * |
|
43 | - * @param EE_Core_Config $core_config |
|
44 | - * @param LoaderInterface $loader |
|
45 | - */ |
|
46 | - public function __construct(EE_Core_Config $core_config, LoaderInterface $loader) |
|
47 | - { |
|
48 | - $this->core_config = $core_config; |
|
49 | - $this->loader = $loader; |
|
50 | - $this->setDefinitions(); |
|
51 | - } |
|
40 | + /** |
|
41 | + * EspressoCustomPostTypeDefinitions constructor. |
|
42 | + * |
|
43 | + * @param EE_Core_Config $core_config |
|
44 | + * @param LoaderInterface $loader |
|
45 | + */ |
|
46 | + public function __construct(EE_Core_Config $core_config, LoaderInterface $loader) |
|
47 | + { |
|
48 | + $this->core_config = $core_config; |
|
49 | + $this->loader = $loader; |
|
50 | + $this->setDefinitions(); |
|
51 | + } |
|
52 | 52 | |
53 | 53 | |
54 | - /** |
|
55 | - * defines Espresso Custom Post Types |
|
56 | - * NOTE the ['args']['page_templates'] array index is something specific to our CPTs |
|
57 | - * and not part of the WP custom post type api. |
|
58 | - * |
|
59 | - * @return void |
|
60 | - */ |
|
61 | - private function setDefinitions() |
|
62 | - { |
|
63 | - $this->custom_post_types = array( |
|
64 | - 'espresso_events' => array( |
|
65 | - 'singular_name' => esc_html__('Event', 'event_espresso'), |
|
66 | - 'plural_name' => esc_html__('Events', 'event_espresso'), |
|
67 | - 'singular_slug' => esc_html__('event', 'event_espresso'), |
|
68 | - 'plural_slug' => $this->core_config->event_cpt_slug, |
|
69 | - 'class_name' => 'EE_Event', |
|
70 | - 'model_name' => 'EEM_Event', |
|
71 | - 'args' => array( |
|
72 | - 'public' => true, |
|
73 | - 'show_in_nav_menus' => true, |
|
74 | - 'capability_type' => 'event', |
|
75 | - 'capabilities' => array( |
|
76 | - 'edit_post' => 'ee_edit_event', |
|
77 | - 'read_post' => 'ee_read_event', |
|
78 | - 'delete_post' => 'ee_delete_event', |
|
79 | - 'edit_posts' => 'ee_edit_events', |
|
80 | - 'edit_others_posts' => 'ee_edit_others_events', |
|
81 | - 'publish_posts' => 'ee_publish_events', |
|
82 | - 'read_private_posts' => 'ee_read_private_events', |
|
83 | - 'delete_posts' => 'ee_delete_events', |
|
84 | - 'delete_private_posts' => 'ee_delete_private_events', |
|
85 | - 'delete_published_posts' => 'ee_delete_published_events', |
|
86 | - 'delete_others_posts' => 'ee_delete_others_events', |
|
87 | - 'edit_private_posts' => 'ee_edit_private_events', |
|
88 | - 'edit_published_posts' => 'ee_edit_published_events', |
|
89 | - ), |
|
90 | - 'taxonomies' => array( |
|
91 | - 'espresso_event_categories', |
|
92 | - 'espresso_event_type', |
|
93 | - 'post_tag', |
|
94 | - ), |
|
95 | - 'page_templates' => true, |
|
96 | - ), |
|
97 | - ), |
|
98 | - 'espresso_venues' => array( |
|
99 | - 'singular_name' => esc_html__('Venue', 'event_espresso'), |
|
100 | - 'plural_name' => esc_html__('Venues', 'event_espresso'), |
|
101 | - 'singular_slug' => esc_html__('venue', 'event_espresso'), |
|
102 | - 'plural_slug' => esc_html__('venues', 'event_espresso'), |
|
103 | - 'class_name' => 'EE_Venue', |
|
104 | - 'model_name' => 'EEM_Venue', |
|
105 | - 'args' => array( |
|
106 | - 'public' => true, |
|
107 | - 'show_in_nav_menus' => false, //by default this doesn't show for decaf, |
|
108 | - 'capability_type' => 'venue', |
|
109 | - 'capabilities' => array( |
|
110 | - 'edit_post' => 'ee_edit_venue', |
|
111 | - 'read_post' => 'ee_read_venue', |
|
112 | - 'delete_post' => 'ee_delete_venue', |
|
113 | - 'edit_posts' => 'ee_edit_venues', |
|
114 | - 'edit_others_posts' => 'ee_edit_others_venues', |
|
115 | - 'publish_posts' => 'ee_publish_venues', |
|
116 | - 'read_private_posts' => 'ee_read_private_venues', |
|
117 | - 'delete_posts' => 'ee_delete_venues', |
|
118 | - 'delete_private_posts' => 'ee_delete_private_venues', |
|
119 | - 'delete_published_posts' => 'ee_delete_published_venues', |
|
120 | - 'delete_others_posts' => 'ee_edit_others_venues', |
|
121 | - 'edit_private_posts' => 'ee_edit_private_venues', |
|
122 | - 'edit_published_posts' => 'ee_edit_published_venues', |
|
123 | - ), |
|
124 | - 'taxonomies' => array( |
|
125 | - 'espresso_venue_categories', |
|
126 | - 'post_tag', |
|
127 | - ), |
|
128 | - 'page_templates' => true, |
|
129 | - ), |
|
130 | - ), |
|
131 | - 'espresso_attendees' => array( |
|
132 | - 'singular_name' => esc_html__('Contact', 'event_espresso'), |
|
133 | - 'plural_name' => esc_html__('Contacts', 'event_espresso'), |
|
134 | - 'singular_slug' => esc_html__('contact', 'event_espresso'), |
|
135 | - 'plural_slug' => esc_html__('contacts', 'event_espresso'), |
|
136 | - 'class_name' => 'EE_Attendee', |
|
137 | - 'model_name' => 'EEM_Attendee', |
|
138 | - 'args' => array( |
|
139 | - 'public' => false, |
|
140 | - 'publicly_queryable' => false, |
|
141 | - 'hierarchical' => false, |
|
142 | - 'has_archive' => false, |
|
143 | - 'supports' => array( |
|
144 | - 'editor', |
|
145 | - 'thumbnail', |
|
146 | - 'excerpt', |
|
147 | - 'custom-fields', |
|
148 | - 'comments', |
|
149 | - ), |
|
150 | - 'taxonomies' => array('post_tag'), |
|
151 | - 'capability_type' => 'contact', |
|
152 | - 'capabilities' => array( |
|
153 | - 'edit_post' => 'ee_edit_contact', |
|
154 | - 'read_post' => 'ee_read_contact', |
|
155 | - 'delete_post' => 'ee_delete_contact', |
|
156 | - 'edit_posts' => 'ee_edit_contacts', |
|
157 | - 'edit_others_posts' => 'ee_edit_contacts', |
|
158 | - 'publish_posts' => 'ee_edit_contacts', |
|
159 | - 'read_private_posts' => 'ee_edit_contacts', |
|
160 | - 'delete_posts' => 'ee_delete_contacts', |
|
161 | - 'delete_private_posts' => 'ee_delete_contacts', |
|
162 | - 'delete_published_posts' => 'ee_delete_contacts', |
|
163 | - 'delete_others_posts' => 'ee_delete_contacts', |
|
164 | - 'edit_private_posts' => 'ee_edit_contacts', |
|
165 | - 'edit_published_posts' => 'ee_edit_contacts', |
|
166 | - ), |
|
167 | - ), |
|
168 | - ), |
|
169 | - ); |
|
170 | - } |
|
54 | + /** |
|
55 | + * defines Espresso Custom Post Types |
|
56 | + * NOTE the ['args']['page_templates'] array index is something specific to our CPTs |
|
57 | + * and not part of the WP custom post type api. |
|
58 | + * |
|
59 | + * @return void |
|
60 | + */ |
|
61 | + private function setDefinitions() |
|
62 | + { |
|
63 | + $this->custom_post_types = array( |
|
64 | + 'espresso_events' => array( |
|
65 | + 'singular_name' => esc_html__('Event', 'event_espresso'), |
|
66 | + 'plural_name' => esc_html__('Events', 'event_espresso'), |
|
67 | + 'singular_slug' => esc_html__('event', 'event_espresso'), |
|
68 | + 'plural_slug' => $this->core_config->event_cpt_slug, |
|
69 | + 'class_name' => 'EE_Event', |
|
70 | + 'model_name' => 'EEM_Event', |
|
71 | + 'args' => array( |
|
72 | + 'public' => true, |
|
73 | + 'show_in_nav_menus' => true, |
|
74 | + 'capability_type' => 'event', |
|
75 | + 'capabilities' => array( |
|
76 | + 'edit_post' => 'ee_edit_event', |
|
77 | + 'read_post' => 'ee_read_event', |
|
78 | + 'delete_post' => 'ee_delete_event', |
|
79 | + 'edit_posts' => 'ee_edit_events', |
|
80 | + 'edit_others_posts' => 'ee_edit_others_events', |
|
81 | + 'publish_posts' => 'ee_publish_events', |
|
82 | + 'read_private_posts' => 'ee_read_private_events', |
|
83 | + 'delete_posts' => 'ee_delete_events', |
|
84 | + 'delete_private_posts' => 'ee_delete_private_events', |
|
85 | + 'delete_published_posts' => 'ee_delete_published_events', |
|
86 | + 'delete_others_posts' => 'ee_delete_others_events', |
|
87 | + 'edit_private_posts' => 'ee_edit_private_events', |
|
88 | + 'edit_published_posts' => 'ee_edit_published_events', |
|
89 | + ), |
|
90 | + 'taxonomies' => array( |
|
91 | + 'espresso_event_categories', |
|
92 | + 'espresso_event_type', |
|
93 | + 'post_tag', |
|
94 | + ), |
|
95 | + 'page_templates' => true, |
|
96 | + ), |
|
97 | + ), |
|
98 | + 'espresso_venues' => array( |
|
99 | + 'singular_name' => esc_html__('Venue', 'event_espresso'), |
|
100 | + 'plural_name' => esc_html__('Venues', 'event_espresso'), |
|
101 | + 'singular_slug' => esc_html__('venue', 'event_espresso'), |
|
102 | + 'plural_slug' => esc_html__('venues', 'event_espresso'), |
|
103 | + 'class_name' => 'EE_Venue', |
|
104 | + 'model_name' => 'EEM_Venue', |
|
105 | + 'args' => array( |
|
106 | + 'public' => true, |
|
107 | + 'show_in_nav_menus' => false, //by default this doesn't show for decaf, |
|
108 | + 'capability_type' => 'venue', |
|
109 | + 'capabilities' => array( |
|
110 | + 'edit_post' => 'ee_edit_venue', |
|
111 | + 'read_post' => 'ee_read_venue', |
|
112 | + 'delete_post' => 'ee_delete_venue', |
|
113 | + 'edit_posts' => 'ee_edit_venues', |
|
114 | + 'edit_others_posts' => 'ee_edit_others_venues', |
|
115 | + 'publish_posts' => 'ee_publish_venues', |
|
116 | + 'read_private_posts' => 'ee_read_private_venues', |
|
117 | + 'delete_posts' => 'ee_delete_venues', |
|
118 | + 'delete_private_posts' => 'ee_delete_private_venues', |
|
119 | + 'delete_published_posts' => 'ee_delete_published_venues', |
|
120 | + 'delete_others_posts' => 'ee_edit_others_venues', |
|
121 | + 'edit_private_posts' => 'ee_edit_private_venues', |
|
122 | + 'edit_published_posts' => 'ee_edit_published_venues', |
|
123 | + ), |
|
124 | + 'taxonomies' => array( |
|
125 | + 'espresso_venue_categories', |
|
126 | + 'post_tag', |
|
127 | + ), |
|
128 | + 'page_templates' => true, |
|
129 | + ), |
|
130 | + ), |
|
131 | + 'espresso_attendees' => array( |
|
132 | + 'singular_name' => esc_html__('Contact', 'event_espresso'), |
|
133 | + 'plural_name' => esc_html__('Contacts', 'event_espresso'), |
|
134 | + 'singular_slug' => esc_html__('contact', 'event_espresso'), |
|
135 | + 'plural_slug' => esc_html__('contacts', 'event_espresso'), |
|
136 | + 'class_name' => 'EE_Attendee', |
|
137 | + 'model_name' => 'EEM_Attendee', |
|
138 | + 'args' => array( |
|
139 | + 'public' => false, |
|
140 | + 'publicly_queryable' => false, |
|
141 | + 'hierarchical' => false, |
|
142 | + 'has_archive' => false, |
|
143 | + 'supports' => array( |
|
144 | + 'editor', |
|
145 | + 'thumbnail', |
|
146 | + 'excerpt', |
|
147 | + 'custom-fields', |
|
148 | + 'comments', |
|
149 | + ), |
|
150 | + 'taxonomies' => array('post_tag'), |
|
151 | + 'capability_type' => 'contact', |
|
152 | + 'capabilities' => array( |
|
153 | + 'edit_post' => 'ee_edit_contact', |
|
154 | + 'read_post' => 'ee_read_contact', |
|
155 | + 'delete_post' => 'ee_delete_contact', |
|
156 | + 'edit_posts' => 'ee_edit_contacts', |
|
157 | + 'edit_others_posts' => 'ee_edit_contacts', |
|
158 | + 'publish_posts' => 'ee_edit_contacts', |
|
159 | + 'read_private_posts' => 'ee_edit_contacts', |
|
160 | + 'delete_posts' => 'ee_delete_contacts', |
|
161 | + 'delete_private_posts' => 'ee_delete_contacts', |
|
162 | + 'delete_published_posts' => 'ee_delete_contacts', |
|
163 | + 'delete_others_posts' => 'ee_delete_contacts', |
|
164 | + 'edit_private_posts' => 'ee_edit_contacts', |
|
165 | + 'edit_published_posts' => 'ee_edit_contacts', |
|
166 | + ), |
|
167 | + ), |
|
168 | + ), |
|
169 | + ); |
|
170 | + } |
|
171 | 171 | |
172 | 172 | |
173 | - /** |
|
174 | - * @return array |
|
175 | - */ |
|
176 | - public function getDefinitions() |
|
177 | - { |
|
178 | - return (array) apply_filters( |
|
179 | - 'FHEE__EventEspresso_core_domain_entities_custom_post_types_CustomPostTypeDefinitions__getCustomPostTypes', |
|
180 | - // legacy filter applied for now, |
|
181 | - // later on we'll run a has_filter($tag) check and throw a doing_it_wrong() notice |
|
182 | - apply_filters( |
|
183 | - 'FHEE__EE_Register_CPTs__get_CPTs__cpts', |
|
184 | - $this->custom_post_types |
|
185 | - ) |
|
186 | - ); |
|
187 | - } |
|
173 | + /** |
|
174 | + * @return array |
|
175 | + */ |
|
176 | + public function getDefinitions() |
|
177 | + { |
|
178 | + return (array) apply_filters( |
|
179 | + 'FHEE__EventEspresso_core_domain_entities_custom_post_types_CustomPostTypeDefinitions__getCustomPostTypes', |
|
180 | + // legacy filter applied for now, |
|
181 | + // later on we'll run a has_filter($tag) check and throw a doing_it_wrong() notice |
|
182 | + apply_filters( |
|
183 | + 'FHEE__EE_Register_CPTs__get_CPTs__cpts', |
|
184 | + $this->custom_post_types |
|
185 | + ) |
|
186 | + ); |
|
187 | + } |
|
188 | 188 | |
189 | 189 | |
190 | - /** |
|
191 | - * @return array |
|
192 | - */ |
|
193 | - public function getCustomPostTypeSlugs() |
|
194 | - { |
|
195 | - return array_keys($this->getDefinitions()); |
|
196 | - } |
|
190 | + /** |
|
191 | + * @return array |
|
192 | + */ |
|
193 | + public function getCustomPostTypeSlugs() |
|
194 | + { |
|
195 | + return array_keys($this->getDefinitions()); |
|
196 | + } |
|
197 | 197 | |
198 | 198 | |
199 | - /** |
|
200 | - * This basically goes through the CPT array and returns only CPT's |
|
201 | - * that have the ['args']['public'] option set as false |
|
202 | - * |
|
203 | - * @return array |
|
204 | - */ |
|
205 | - public function getPrivateCustomPostTypes() |
|
206 | - { |
|
207 | - $private_CPTs = array(); |
|
208 | - foreach ($this->getDefinitions() as $CPT => $details) { |
|
209 | - if (empty($details['args']['public'])) { |
|
210 | - $private_CPTs[ $CPT ] = $details; |
|
211 | - } |
|
212 | - } |
|
213 | - return $private_CPTs; |
|
214 | - } |
|
199 | + /** |
|
200 | + * This basically goes through the CPT array and returns only CPT's |
|
201 | + * that have the ['args']['public'] option set as false |
|
202 | + * |
|
203 | + * @return array |
|
204 | + */ |
|
205 | + public function getPrivateCustomPostTypes() |
|
206 | + { |
|
207 | + $private_CPTs = array(); |
|
208 | + foreach ($this->getDefinitions() as $CPT => $details) { |
|
209 | + if (empty($details['args']['public'])) { |
|
210 | + $private_CPTs[ $CPT ] = $details; |
|
211 | + } |
|
212 | + } |
|
213 | + return $private_CPTs; |
|
214 | + } |
|
215 | 215 | |
216 | 216 | |
217 | - /** |
|
218 | - * This returns the corresponding model name for cpts registered by EE. |
|
219 | - * |
|
220 | - * @param string $post_type_slug If a slug is included, then attempt to retrieve |
|
221 | - * the model name for the given cpt slug. |
|
222 | - * Otherwise if empty, then we'll return |
|
223 | - * all cpt model names for cpts registered in EE. |
|
224 | - * @return array Empty array if no matching model names for the given slug |
|
225 | - * or an array of model names indexed by post type slug. |
|
226 | - */ |
|
227 | - public function getCustomPostTypeModelNames($post_type_slug = '') |
|
228 | - { |
|
229 | - $cpts = $this->getDefinitions(); |
|
230 | - //first if slug passed in... |
|
231 | - if (! empty($post_type_slug)) { |
|
232 | - // check that slug and cpt match |
|
233 | - if (! isset($cpts[ $post_type_slug ])) { |
|
234 | - return array(); |
|
235 | - } |
|
236 | - if ( |
|
237 | - empty($cpts[ $post_type_slug ]['class_name']) |
|
238 | - && empty($cpts[ $post_type_slug ]['model_name']) |
|
239 | - ) { |
|
240 | - return array(); |
|
241 | - } |
|
242 | - // k let's get the model name for this cpt. |
|
243 | - return $this->getCustomPostTypeModelName($post_type_slug, $cpts[ $post_type_slug ]); |
|
244 | - } |
|
245 | - //if we made it here then we're returning an array of cpt model names indexed by post_type_slug. |
|
246 | - $cpt_models = array(); |
|
247 | - foreach ($cpts as $slug => $args) { |
|
248 | - $model = $this->getCustomPostTypeModelName($post_type_slug, $cpts[ $post_type_slug ]); |
|
249 | - if (! empty($model)) { |
|
250 | - $cpt_models[ $slug ] = $model; |
|
251 | - } |
|
252 | - } |
|
253 | - return $cpt_models; |
|
254 | - } |
|
217 | + /** |
|
218 | + * This returns the corresponding model name for cpts registered by EE. |
|
219 | + * |
|
220 | + * @param string $post_type_slug If a slug is included, then attempt to retrieve |
|
221 | + * the model name for the given cpt slug. |
|
222 | + * Otherwise if empty, then we'll return |
|
223 | + * all cpt model names for cpts registered in EE. |
|
224 | + * @return array Empty array if no matching model names for the given slug |
|
225 | + * or an array of model names indexed by post type slug. |
|
226 | + */ |
|
227 | + public function getCustomPostTypeModelNames($post_type_slug = '') |
|
228 | + { |
|
229 | + $cpts = $this->getDefinitions(); |
|
230 | + //first if slug passed in... |
|
231 | + if (! empty($post_type_slug)) { |
|
232 | + // check that slug and cpt match |
|
233 | + if (! isset($cpts[ $post_type_slug ])) { |
|
234 | + return array(); |
|
235 | + } |
|
236 | + if ( |
|
237 | + empty($cpts[ $post_type_slug ]['class_name']) |
|
238 | + && empty($cpts[ $post_type_slug ]['model_name']) |
|
239 | + ) { |
|
240 | + return array(); |
|
241 | + } |
|
242 | + // k let's get the model name for this cpt. |
|
243 | + return $this->getCustomPostTypeModelName($post_type_slug, $cpts[ $post_type_slug ]); |
|
244 | + } |
|
245 | + //if we made it here then we're returning an array of cpt model names indexed by post_type_slug. |
|
246 | + $cpt_models = array(); |
|
247 | + foreach ($cpts as $slug => $args) { |
|
248 | + $model = $this->getCustomPostTypeModelName($post_type_slug, $cpts[ $post_type_slug ]); |
|
249 | + if (! empty($model)) { |
|
250 | + $cpt_models[ $slug ] = $model; |
|
251 | + } |
|
252 | + } |
|
253 | + return $cpt_models; |
|
254 | + } |
|
255 | 255 | |
256 | 256 | |
257 | - /** |
|
258 | - * @param $post_type_slug |
|
259 | - * @param array $cpt |
|
260 | - * @return array |
|
261 | - */ |
|
262 | - private function getCustomPostTypeModelName($post_type_slug, array $cpt) |
|
263 | - { |
|
264 | - if(! empty($cpt['model_name'])) { |
|
265 | - return array($post_type_slug => $cpt['model_name']); |
|
266 | - } |
|
267 | - if (! empty($cpt['class_name'])) { |
|
268 | - return array( |
|
269 | - $post_type_slug => $this->deriveCptModelNameFromClassName($cpt['class_name']) |
|
270 | - ); |
|
271 | - } |
|
272 | - return array(); |
|
273 | - } |
|
257 | + /** |
|
258 | + * @param $post_type_slug |
|
259 | + * @param array $cpt |
|
260 | + * @return array |
|
261 | + */ |
|
262 | + private function getCustomPostTypeModelName($post_type_slug, array $cpt) |
|
263 | + { |
|
264 | + if(! empty($cpt['model_name'])) { |
|
265 | + return array($post_type_slug => $cpt['model_name']); |
|
266 | + } |
|
267 | + if (! empty($cpt['class_name'])) { |
|
268 | + return array( |
|
269 | + $post_type_slug => $this->deriveCptModelNameFromClassName($cpt['class_name']) |
|
270 | + ); |
|
271 | + } |
|
272 | + return array(); |
|
273 | + } |
|
274 | 274 | |
275 | 275 | |
276 | - /** |
|
277 | - * @param string $class_name |
|
278 | - * @return string |
|
279 | - */ |
|
280 | - private function deriveCptModelNameFromClassName($class_name) |
|
281 | - { |
|
282 | - return str_replace('EE', 'EEM', $class_name); |
|
283 | - } |
|
276 | + /** |
|
277 | + * @param string $class_name |
|
278 | + * @return string |
|
279 | + */ |
|
280 | + private function deriveCptModelNameFromClassName($class_name) |
|
281 | + { |
|
282 | + return str_replace('EE', 'EEM', $class_name); |
|
283 | + } |
|
284 | 284 | |
285 | 285 | |
286 | - /** |
|
287 | - * This instantiates cpt models related to the cpts registered via EE. |
|
288 | - * |
|
289 | - * @since 4.6.16.rc.000 |
|
290 | - * @param string $post_type_slug If valid slug is provided, then will instantiate the model only for |
|
291 | - * the cpt matching the given slug. Otherwise all cpt models will be |
|
292 | - * instantiated (if possible). |
|
293 | - * @return EEM_CPT_Base[] successful instantiation will return an array of successfully instantiated |
|
294 | - * EEM models indexed by post slug. |
|
295 | - */ |
|
296 | - public function getCustomPostTypeModels($post_type_slug = '') |
|
297 | - { |
|
298 | - $cpt_model_names = $this->getCustomPostTypeModelNames($post_type_slug); |
|
299 | - $instantiated = array(); |
|
300 | - foreach ($cpt_model_names as $slug => $model_name) { |
|
301 | - $model = $this->loader->getShared($model_name); |
|
302 | - if ($model instanceof EEM_CPT_Base) { |
|
303 | - $instantiated[ $slug ] = $model; |
|
304 | - } |
|
305 | - } |
|
306 | - return $instantiated; |
|
307 | - } |
|
286 | + /** |
|
287 | + * This instantiates cpt models related to the cpts registered via EE. |
|
288 | + * |
|
289 | + * @since 4.6.16.rc.000 |
|
290 | + * @param string $post_type_slug If valid slug is provided, then will instantiate the model only for |
|
291 | + * the cpt matching the given slug. Otherwise all cpt models will be |
|
292 | + * instantiated (if possible). |
|
293 | + * @return EEM_CPT_Base[] successful instantiation will return an array of successfully instantiated |
|
294 | + * EEM models indexed by post slug. |
|
295 | + */ |
|
296 | + public function getCustomPostTypeModels($post_type_slug = '') |
|
297 | + { |
|
298 | + $cpt_model_names = $this->getCustomPostTypeModelNames($post_type_slug); |
|
299 | + $instantiated = array(); |
|
300 | + foreach ($cpt_model_names as $slug => $model_name) { |
|
301 | + $model = $this->loader->getShared($model_name); |
|
302 | + if ($model instanceof EEM_CPT_Base) { |
|
303 | + $instantiated[ $slug ] = $model; |
|
304 | + } |
|
305 | + } |
|
306 | + return $instantiated; |
|
307 | + } |
|
308 | 308 | } |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | $private_CPTs = array(); |
208 | 208 | foreach ($this->getDefinitions() as $CPT => $details) { |
209 | 209 | if (empty($details['args']['public'])) { |
210 | - $private_CPTs[ $CPT ] = $details; |
|
210 | + $private_CPTs[$CPT] = $details; |
|
211 | 211 | } |
212 | 212 | } |
213 | 213 | return $private_CPTs; |
@@ -228,26 +228,26 @@ discard block |
||
228 | 228 | { |
229 | 229 | $cpts = $this->getDefinitions(); |
230 | 230 | //first if slug passed in... |
231 | - if (! empty($post_type_slug)) { |
|
231 | + if ( ! empty($post_type_slug)) { |
|
232 | 232 | // check that slug and cpt match |
233 | - if (! isset($cpts[ $post_type_slug ])) { |
|
233 | + if ( ! isset($cpts[$post_type_slug])) { |
|
234 | 234 | return array(); |
235 | 235 | } |
236 | 236 | if ( |
237 | - empty($cpts[ $post_type_slug ]['class_name']) |
|
238 | - && empty($cpts[ $post_type_slug ]['model_name']) |
|
237 | + empty($cpts[$post_type_slug]['class_name']) |
|
238 | + && empty($cpts[$post_type_slug]['model_name']) |
|
239 | 239 | ) { |
240 | 240 | return array(); |
241 | 241 | } |
242 | 242 | // k let's get the model name for this cpt. |
243 | - return $this->getCustomPostTypeModelName($post_type_slug, $cpts[ $post_type_slug ]); |
|
243 | + return $this->getCustomPostTypeModelName($post_type_slug, $cpts[$post_type_slug]); |
|
244 | 244 | } |
245 | 245 | //if we made it here then we're returning an array of cpt model names indexed by post_type_slug. |
246 | 246 | $cpt_models = array(); |
247 | 247 | foreach ($cpts as $slug => $args) { |
248 | - $model = $this->getCustomPostTypeModelName($post_type_slug, $cpts[ $post_type_slug ]); |
|
249 | - if (! empty($model)) { |
|
250 | - $cpt_models[ $slug ] = $model; |
|
248 | + $model = $this->getCustomPostTypeModelName($post_type_slug, $cpts[$post_type_slug]); |
|
249 | + if ( ! empty($model)) { |
|
250 | + $cpt_models[$slug] = $model; |
|
251 | 251 | } |
252 | 252 | } |
253 | 253 | return $cpt_models; |
@@ -261,10 +261,10 @@ discard block |
||
261 | 261 | */ |
262 | 262 | private function getCustomPostTypeModelName($post_type_slug, array $cpt) |
263 | 263 | { |
264 | - if(! empty($cpt['model_name'])) { |
|
264 | + if ( ! empty($cpt['model_name'])) { |
|
265 | 265 | return array($post_type_slug => $cpt['model_name']); |
266 | 266 | } |
267 | - if (! empty($cpt['class_name'])) { |
|
267 | + if ( ! empty($cpt['class_name'])) { |
|
268 | 268 | return array( |
269 | 269 | $post_type_slug => $this->deriveCptModelNameFromClassName($cpt['class_name']) |
270 | 270 | ); |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | foreach ($cpt_model_names as $slug => $model_name) { |
301 | 301 | $model = $this->loader->getShared($model_name); |
302 | 302 | if ($model instanceof EEM_CPT_Base) { |
303 | - $instantiated[ $slug ] = $model; |
|
303 | + $instantiated[$slug] = $model; |
|
304 | 304 | } |
305 | 305 | } |
306 | 306 | return $instantiated; |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | use EventEspresso\widgets\EspressoWidget; |
8 | 8 | |
9 | 9 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
10 | - exit('No direct script access allowed'); |
|
10 | + exit('No direct script access allowed'); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
@@ -30,385 +30,385 @@ discard block |
||
30 | 30 | final class EE_Front_Controller |
31 | 31 | { |
32 | 32 | |
33 | - /** |
|
34 | - * @var string $_template_path |
|
35 | - */ |
|
36 | - private $_template_path; |
|
37 | - |
|
38 | - /** |
|
39 | - * @var string $_template |
|
40 | - */ |
|
41 | - private $_template; |
|
42 | - |
|
43 | - /** |
|
44 | - * @type EE_Registry $Registry |
|
45 | - */ |
|
46 | - protected $Registry; |
|
47 | - |
|
48 | - /** |
|
49 | - * @type EE_Request_Handler $Request_Handler |
|
50 | - */ |
|
51 | - protected $Request_Handler; |
|
52 | - |
|
53 | - /** |
|
54 | - * @type EE_Module_Request_Router $Module_Request_Router |
|
55 | - */ |
|
56 | - protected $Module_Request_Router; |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * class constructor |
|
61 | - * should fire after shortcode, module, addon, or other plugin's default priority init phases have run |
|
62 | - * |
|
63 | - * @access public |
|
64 | - * @param \EE_Registry $Registry |
|
65 | - * @param \EE_Request_Handler $Request_Handler |
|
66 | - * @param \EE_Module_Request_Router $Module_Request_Router |
|
67 | - */ |
|
68 | - public function __construct( |
|
69 | - EE_Registry $Registry, |
|
70 | - EE_Request_Handler $Request_Handler, |
|
71 | - EE_Module_Request_Router $Module_Request_Router |
|
72 | - ) { |
|
73 | - $this->Registry = $Registry; |
|
74 | - $this->Request_Handler = $Request_Handler; |
|
75 | - $this->Module_Request_Router = $Module_Request_Router; |
|
76 | - // determine how to integrate WP_Query with the EE models |
|
77 | - add_action('AHEE__EE_System__initialize', array($this, 'employ_CPT_Strategy')); |
|
78 | - // load other resources and begin to actually run shortcodes and modules |
|
79 | - add_action('wp_loaded', array($this, 'wp_loaded'), 5); |
|
80 | - // analyse the incoming WP request |
|
81 | - add_action('parse_request', array($this, 'get_request'), 1, 1); |
|
82 | - // process request with module factory |
|
83 | - add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1); |
|
84 | - // before headers sent |
|
85 | - add_action('wp', array($this, 'wp'), 5); |
|
86 | - // primarily used to process any content shortcodes |
|
87 | - add_action('template_redirect', array($this, 'templateRedirect'), 999); |
|
88 | - // header |
|
89 | - add_action('wp_head', array($this, 'header_meta_tag'), 5); |
|
90 | - add_action('wp_print_scripts', array($this, 'wp_print_scripts'), 10); |
|
91 | - add_filter('template_include', array($this, 'template_include'), 1); |
|
92 | - // display errors |
|
93 | - add_action('loop_start', array($this, 'display_errors'), 2); |
|
94 | - // the content |
|
95 | - // add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 ); |
|
96 | - //exclude our private cpt comments |
|
97 | - add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1); |
|
98 | - //make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://) |
|
99 | - add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1); |
|
100 | - // action hook EE |
|
101 | - do_action('AHEE__EE_Front_Controller__construct__done', $this); |
|
102 | - } |
|
103 | - |
|
104 | - |
|
105 | - /** |
|
106 | - * @return EE_Request_Handler |
|
107 | - */ |
|
108 | - public function Request_Handler() |
|
109 | - { |
|
110 | - return $this->Request_Handler; |
|
111 | - } |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * @return EE_Module_Request_Router |
|
116 | - */ |
|
117 | - public function Module_Request_Router() |
|
118 | - { |
|
119 | - return $this->Module_Request_Router; |
|
120 | - } |
|
121 | - |
|
122 | - |
|
123 | - |
|
124 | - /** |
|
125 | - * @return LegacyShortcodesManager |
|
126 | - */ |
|
127 | - public function getLegacyShortcodesManager() |
|
128 | - { |
|
129 | - return EE_Config::getLegacyShortcodesManager(); |
|
130 | - } |
|
131 | - |
|
132 | - |
|
133 | - |
|
134 | - |
|
135 | - |
|
136 | - /*********************************************** INIT ACTION HOOK ***********************************************/ |
|
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 | - * @throws InvalidArgumentException |
|
145 | - * @throws InvalidDataTypeException |
|
146 | - * @throws InvalidInterfaceException |
|
147 | - */ |
|
148 | - public function filter_wp_comments($clauses) |
|
149 | - { |
|
150 | - global $wpdb; |
|
151 | - if (strpos($clauses['join'], $wpdb->posts) !== false) { |
|
152 | - /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */ |
|
153 | - $custom_post_types = LoaderFactory::getLoader()->getShared( |
|
154 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
155 | - ); |
|
156 | - $cpts = $custom_post_types->getPrivateCustomPostTypes(); |
|
157 | - foreach ($cpts as $cpt => $details) { |
|
158 | - $clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt); |
|
159 | - } |
|
160 | - } |
|
161 | - return $clauses; |
|
162 | - } |
|
163 | - |
|
164 | - |
|
165 | - /** |
|
166 | - * @return void |
|
167 | - * @throws InvalidArgumentException |
|
168 | - * @throws InvalidDataTypeException |
|
169 | - * @throws InvalidInterfaceException |
|
170 | - */ |
|
171 | - public function employ_CPT_Strategy() |
|
172 | - { |
|
173 | - if (apply_filters('FHEE__EE_Front_Controller__employ_CPT_Strategy', true)) { |
|
174 | - LoaderFactory::getLoader()->getShared('EE_CPT_Strategy'); |
|
175 | - } |
|
176 | - } |
|
177 | - |
|
178 | - |
|
179 | - /** |
|
180 | - * this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend |
|
181 | - * |
|
182 | - * @param string $url incoming url |
|
183 | - * @return string final assembled url |
|
184 | - */ |
|
185 | - public function maybe_force_admin_ajax_ssl($url) |
|
186 | - { |
|
187 | - if (is_ssl() && preg_match('/admin-ajax.php/', $url)) { |
|
188 | - $url = str_replace('http://', 'https://', $url); |
|
189 | - } |
|
190 | - return $url; |
|
191 | - } |
|
192 | - |
|
193 | - |
|
194 | - |
|
195 | - |
|
196 | - |
|
197 | - |
|
198 | - /*********************************************** WP_LOADED ACTION HOOK ***********************************************/ |
|
199 | - |
|
200 | - |
|
201 | - /** |
|
202 | - * wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their |
|
203 | - * default priority init phases have run |
|
204 | - * |
|
205 | - * @access public |
|
206 | - * @return void |
|
207 | - */ |
|
208 | - public function wp_loaded() |
|
209 | - { |
|
210 | - } |
|
211 | - |
|
212 | - |
|
213 | - |
|
214 | - |
|
215 | - |
|
216 | - /*********************************************** PARSE_REQUEST HOOK ***********************************************/ |
|
217 | - /** |
|
218 | - * _get_request |
|
219 | - * |
|
220 | - * @access public |
|
221 | - * @param WP $WP |
|
222 | - * @return void |
|
223 | - */ |
|
224 | - public function get_request(WP $WP) |
|
225 | - { |
|
226 | - do_action('AHEE__EE_Front_Controller__get_request__start'); |
|
227 | - $this->Request_Handler->parse_request($WP); |
|
228 | - do_action('AHEE__EE_Front_Controller__get_request__complete'); |
|
229 | - } |
|
230 | - |
|
231 | - |
|
232 | - |
|
233 | - /** |
|
234 | - * pre_get_posts - basically a module factory for instantiating modules and selecting the final view template |
|
235 | - * |
|
236 | - * @access public |
|
237 | - * @param WP_Query $WP_Query |
|
238 | - * @return void |
|
239 | - */ |
|
240 | - public function pre_get_posts($WP_Query) |
|
241 | - { |
|
242 | - // only load Module_Request_Router if this is the main query |
|
243 | - if ( |
|
244 | - $this->Module_Request_Router instanceof EE_Module_Request_Router |
|
245 | - && $WP_Query->is_main_query() |
|
246 | - ) { |
|
247 | - // cycle thru module routes |
|
248 | - while ($route = $this->Module_Request_Router->get_route($WP_Query)) { |
|
249 | - // determine module and method for route |
|
250 | - $module = $this->Module_Request_Router->resolve_route($route[0], $route[1]); |
|
251 | - if ($module instanceof EED_Module) { |
|
252 | - // get registered view for route |
|
253 | - $this->_template_path = $this->Module_Request_Router->get_view($route); |
|
254 | - // grab module name |
|
255 | - $module_name = $module->module_name(); |
|
256 | - // map the module to the module objects |
|
257 | - $this->Registry->modules->{$module_name} = $module; |
|
258 | - } |
|
259 | - } |
|
260 | - } |
|
261 | - } |
|
262 | - |
|
263 | - |
|
264 | - |
|
265 | - |
|
266 | - |
|
267 | - /*********************************************** WP HOOK ***********************************************/ |
|
268 | - |
|
269 | - |
|
270 | - /** |
|
271 | - * wp - basically last chance to do stuff before headers sent |
|
272 | - * |
|
273 | - * @access public |
|
274 | - * @return void |
|
275 | - */ |
|
276 | - public function wp() |
|
277 | - { |
|
278 | - } |
|
279 | - |
|
280 | - |
|
281 | - |
|
282 | - /*********************** GET_HEADER && WP_HEAD HOOK ***********************/ |
|
283 | - |
|
284 | - |
|
285 | - |
|
286 | - /** |
|
287 | - * callback for the "template_redirect" hook point |
|
288 | - * checks sidebars for EE widgets |
|
289 | - * loads resources and assets accordingly |
|
290 | - * |
|
291 | - * @return void |
|
292 | - */ |
|
293 | - public function templateRedirect() |
|
294 | - { |
|
295 | - global $wp_query; |
|
296 | - if (empty($wp_query->posts)){ |
|
297 | - return; |
|
298 | - } |
|
299 | - // if we already know this is an espresso page, then load assets |
|
300 | - $load_assets = $this->Request_Handler->is_espresso_page(); |
|
301 | - // if we are already loading assets then just move along, otherwise check for widgets |
|
302 | - $load_assets = $load_assets ? $load_assets : $this->espresso_widgets_in_active_sidebars(); |
|
303 | - if ( $load_assets){ |
|
304 | - add_action('wp_enqueue_scripts', array($this, 'enqueueStyle'), 10); |
|
305 | - add_action('wp_print_footer_scripts', array($this, 'enqueueScripts'), 10); |
|
306 | - } |
|
307 | - } |
|
308 | - |
|
309 | - |
|
310 | - |
|
311 | - /** |
|
312 | - * builds list of active widgets then scans active sidebars looking for them |
|
313 | - * returns true is an EE widget is found in an active sidebar |
|
314 | - * Please Note: this does NOT mean that the sidebar or widget |
|
315 | - * is actually in use in a given template, as that is unfortunately not known |
|
316 | - * until a sidebar and it's widgets are actually loaded |
|
317 | - * |
|
318 | - * @return boolean |
|
319 | - */ |
|
320 | - private function espresso_widgets_in_active_sidebars() |
|
321 | - { |
|
322 | - $espresso_widgets = array(); |
|
323 | - foreach ($this->Registry->widgets as $widget_class => $widget) { |
|
324 | - $id_base = EspressoWidget::getIdBase($widget_class); |
|
325 | - if (is_active_widget(false, false, $id_base)) { |
|
326 | - $espresso_widgets[] = $id_base; |
|
327 | - } |
|
328 | - } |
|
329 | - $all_sidebar_widgets = wp_get_sidebars_widgets(); |
|
330 | - foreach ($all_sidebar_widgets as $sidebar_name => $sidebar_widgets) { |
|
331 | - if (is_array($sidebar_widgets) && ! empty($sidebar_widgets)) { |
|
332 | - foreach ($sidebar_widgets as $sidebar_widget) { |
|
333 | - foreach ($espresso_widgets as $espresso_widget) { |
|
334 | - if (strpos($sidebar_widget, $espresso_widget) !== false) { |
|
335 | - return true; |
|
336 | - } |
|
337 | - } |
|
338 | - } |
|
339 | - } |
|
340 | - } |
|
341 | - return false; |
|
342 | - } |
|
343 | - |
|
344 | - |
|
345 | - |
|
346 | - |
|
347 | - /** |
|
348 | - * header_meta_tag |
|
349 | - * |
|
350 | - * @access public |
|
351 | - * @return void |
|
352 | - */ |
|
353 | - public function header_meta_tag() |
|
354 | - { |
|
355 | - print( |
|
356 | - apply_filters( |
|
357 | - 'FHEE__EE_Front_Controller__header_meta_tag', |
|
358 | - '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n") |
|
359 | - ); |
|
360 | - |
|
361 | - //let's exclude all event type taxonomy term archive pages from search engine indexing |
|
362 | - //@see https://events.codebasehq.com/projects/event-espresso/tickets/10249 |
|
363 | - //also exclude all critical pages from indexing |
|
364 | - if ( |
|
365 | - ( |
|
366 | - is_tax('espresso_event_type') |
|
367 | - && get_option( 'blog_public' ) !== '0' |
|
368 | - ) |
|
369 | - || is_page(EE_Registry::instance()->CFG->core->get_critical_pages_array()) |
|
370 | - ) { |
|
371 | - print( |
|
372 | - apply_filters( |
|
373 | - 'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type', |
|
374 | - '<meta name="robots" content="noindex,follow" />' . "\n" |
|
375 | - ) |
|
376 | - ); |
|
377 | - } |
|
378 | - } |
|
379 | - |
|
380 | - |
|
381 | - |
|
382 | - /** |
|
383 | - * wp_print_scripts |
|
384 | - * |
|
385 | - * @return void |
|
386 | - */ |
|
387 | - public function wp_print_scripts() |
|
388 | - { |
|
389 | - global $post; |
|
390 | - if ( |
|
391 | - isset($post->EE_Event) |
|
392 | - && $post->EE_Event instanceof EE_Event |
|
393 | - && get_post_type() === 'espresso_events' |
|
394 | - && is_singular() |
|
395 | - ) { |
|
396 | - \EEH_Schema::add_json_linked_data_for_event($post->EE_Event); |
|
397 | - } |
|
398 | - } |
|
399 | - |
|
400 | - |
|
401 | - |
|
402 | - public function enqueueStyle() |
|
403 | - { |
|
404 | - wp_enqueue_style('espresso_default'); |
|
405 | - wp_enqueue_style('espresso_custom_css'); |
|
406 | - } |
|
407 | - |
|
408 | - |
|
409 | - |
|
410 | - |
|
411 | - /*********************************************** THE_CONTENT FILTER HOOK ********************************************** |
|
33 | + /** |
|
34 | + * @var string $_template_path |
|
35 | + */ |
|
36 | + private $_template_path; |
|
37 | + |
|
38 | + /** |
|
39 | + * @var string $_template |
|
40 | + */ |
|
41 | + private $_template; |
|
42 | + |
|
43 | + /** |
|
44 | + * @type EE_Registry $Registry |
|
45 | + */ |
|
46 | + protected $Registry; |
|
47 | + |
|
48 | + /** |
|
49 | + * @type EE_Request_Handler $Request_Handler |
|
50 | + */ |
|
51 | + protected $Request_Handler; |
|
52 | + |
|
53 | + /** |
|
54 | + * @type EE_Module_Request_Router $Module_Request_Router |
|
55 | + */ |
|
56 | + protected $Module_Request_Router; |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * class constructor |
|
61 | + * should fire after shortcode, module, addon, or other plugin's default priority init phases have run |
|
62 | + * |
|
63 | + * @access public |
|
64 | + * @param \EE_Registry $Registry |
|
65 | + * @param \EE_Request_Handler $Request_Handler |
|
66 | + * @param \EE_Module_Request_Router $Module_Request_Router |
|
67 | + */ |
|
68 | + public function __construct( |
|
69 | + EE_Registry $Registry, |
|
70 | + EE_Request_Handler $Request_Handler, |
|
71 | + EE_Module_Request_Router $Module_Request_Router |
|
72 | + ) { |
|
73 | + $this->Registry = $Registry; |
|
74 | + $this->Request_Handler = $Request_Handler; |
|
75 | + $this->Module_Request_Router = $Module_Request_Router; |
|
76 | + // determine how to integrate WP_Query with the EE models |
|
77 | + add_action('AHEE__EE_System__initialize', array($this, 'employ_CPT_Strategy')); |
|
78 | + // load other resources and begin to actually run shortcodes and modules |
|
79 | + add_action('wp_loaded', array($this, 'wp_loaded'), 5); |
|
80 | + // analyse the incoming WP request |
|
81 | + add_action('parse_request', array($this, 'get_request'), 1, 1); |
|
82 | + // process request with module factory |
|
83 | + add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1); |
|
84 | + // before headers sent |
|
85 | + add_action('wp', array($this, 'wp'), 5); |
|
86 | + // primarily used to process any content shortcodes |
|
87 | + add_action('template_redirect', array($this, 'templateRedirect'), 999); |
|
88 | + // header |
|
89 | + add_action('wp_head', array($this, 'header_meta_tag'), 5); |
|
90 | + add_action('wp_print_scripts', array($this, 'wp_print_scripts'), 10); |
|
91 | + add_filter('template_include', array($this, 'template_include'), 1); |
|
92 | + // display errors |
|
93 | + add_action('loop_start', array($this, 'display_errors'), 2); |
|
94 | + // the content |
|
95 | + // add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 ); |
|
96 | + //exclude our private cpt comments |
|
97 | + add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1); |
|
98 | + //make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://) |
|
99 | + add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1); |
|
100 | + // action hook EE |
|
101 | + do_action('AHEE__EE_Front_Controller__construct__done', $this); |
|
102 | + } |
|
103 | + |
|
104 | + |
|
105 | + /** |
|
106 | + * @return EE_Request_Handler |
|
107 | + */ |
|
108 | + public function Request_Handler() |
|
109 | + { |
|
110 | + return $this->Request_Handler; |
|
111 | + } |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * @return EE_Module_Request_Router |
|
116 | + */ |
|
117 | + public function Module_Request_Router() |
|
118 | + { |
|
119 | + return $this->Module_Request_Router; |
|
120 | + } |
|
121 | + |
|
122 | + |
|
123 | + |
|
124 | + /** |
|
125 | + * @return LegacyShortcodesManager |
|
126 | + */ |
|
127 | + public function getLegacyShortcodesManager() |
|
128 | + { |
|
129 | + return EE_Config::getLegacyShortcodesManager(); |
|
130 | + } |
|
131 | + |
|
132 | + |
|
133 | + |
|
134 | + |
|
135 | + |
|
136 | + /*********************************************** INIT ACTION HOOK ***********************************************/ |
|
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 | + * @throws InvalidArgumentException |
|
145 | + * @throws InvalidDataTypeException |
|
146 | + * @throws InvalidInterfaceException |
|
147 | + */ |
|
148 | + public function filter_wp_comments($clauses) |
|
149 | + { |
|
150 | + global $wpdb; |
|
151 | + if (strpos($clauses['join'], $wpdb->posts) !== false) { |
|
152 | + /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */ |
|
153 | + $custom_post_types = LoaderFactory::getLoader()->getShared( |
|
154 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
155 | + ); |
|
156 | + $cpts = $custom_post_types->getPrivateCustomPostTypes(); |
|
157 | + foreach ($cpts as $cpt => $details) { |
|
158 | + $clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt); |
|
159 | + } |
|
160 | + } |
|
161 | + return $clauses; |
|
162 | + } |
|
163 | + |
|
164 | + |
|
165 | + /** |
|
166 | + * @return void |
|
167 | + * @throws InvalidArgumentException |
|
168 | + * @throws InvalidDataTypeException |
|
169 | + * @throws InvalidInterfaceException |
|
170 | + */ |
|
171 | + public function employ_CPT_Strategy() |
|
172 | + { |
|
173 | + if (apply_filters('FHEE__EE_Front_Controller__employ_CPT_Strategy', true)) { |
|
174 | + LoaderFactory::getLoader()->getShared('EE_CPT_Strategy'); |
|
175 | + } |
|
176 | + } |
|
177 | + |
|
178 | + |
|
179 | + /** |
|
180 | + * this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend |
|
181 | + * |
|
182 | + * @param string $url incoming url |
|
183 | + * @return string final assembled url |
|
184 | + */ |
|
185 | + public function maybe_force_admin_ajax_ssl($url) |
|
186 | + { |
|
187 | + if (is_ssl() && preg_match('/admin-ajax.php/', $url)) { |
|
188 | + $url = str_replace('http://', 'https://', $url); |
|
189 | + } |
|
190 | + return $url; |
|
191 | + } |
|
192 | + |
|
193 | + |
|
194 | + |
|
195 | + |
|
196 | + |
|
197 | + |
|
198 | + /*********************************************** WP_LOADED ACTION HOOK ***********************************************/ |
|
199 | + |
|
200 | + |
|
201 | + /** |
|
202 | + * wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their |
|
203 | + * default priority init phases have run |
|
204 | + * |
|
205 | + * @access public |
|
206 | + * @return void |
|
207 | + */ |
|
208 | + public function wp_loaded() |
|
209 | + { |
|
210 | + } |
|
211 | + |
|
212 | + |
|
213 | + |
|
214 | + |
|
215 | + |
|
216 | + /*********************************************** PARSE_REQUEST HOOK ***********************************************/ |
|
217 | + /** |
|
218 | + * _get_request |
|
219 | + * |
|
220 | + * @access public |
|
221 | + * @param WP $WP |
|
222 | + * @return void |
|
223 | + */ |
|
224 | + public function get_request(WP $WP) |
|
225 | + { |
|
226 | + do_action('AHEE__EE_Front_Controller__get_request__start'); |
|
227 | + $this->Request_Handler->parse_request($WP); |
|
228 | + do_action('AHEE__EE_Front_Controller__get_request__complete'); |
|
229 | + } |
|
230 | + |
|
231 | + |
|
232 | + |
|
233 | + /** |
|
234 | + * pre_get_posts - basically a module factory for instantiating modules and selecting the final view template |
|
235 | + * |
|
236 | + * @access public |
|
237 | + * @param WP_Query $WP_Query |
|
238 | + * @return void |
|
239 | + */ |
|
240 | + public function pre_get_posts($WP_Query) |
|
241 | + { |
|
242 | + // only load Module_Request_Router if this is the main query |
|
243 | + if ( |
|
244 | + $this->Module_Request_Router instanceof EE_Module_Request_Router |
|
245 | + && $WP_Query->is_main_query() |
|
246 | + ) { |
|
247 | + // cycle thru module routes |
|
248 | + while ($route = $this->Module_Request_Router->get_route($WP_Query)) { |
|
249 | + // determine module and method for route |
|
250 | + $module = $this->Module_Request_Router->resolve_route($route[0], $route[1]); |
|
251 | + if ($module instanceof EED_Module) { |
|
252 | + // get registered view for route |
|
253 | + $this->_template_path = $this->Module_Request_Router->get_view($route); |
|
254 | + // grab module name |
|
255 | + $module_name = $module->module_name(); |
|
256 | + // map the module to the module objects |
|
257 | + $this->Registry->modules->{$module_name} = $module; |
|
258 | + } |
|
259 | + } |
|
260 | + } |
|
261 | + } |
|
262 | + |
|
263 | + |
|
264 | + |
|
265 | + |
|
266 | + |
|
267 | + /*********************************************** WP HOOK ***********************************************/ |
|
268 | + |
|
269 | + |
|
270 | + /** |
|
271 | + * wp - basically last chance to do stuff before headers sent |
|
272 | + * |
|
273 | + * @access public |
|
274 | + * @return void |
|
275 | + */ |
|
276 | + public function wp() |
|
277 | + { |
|
278 | + } |
|
279 | + |
|
280 | + |
|
281 | + |
|
282 | + /*********************** GET_HEADER && WP_HEAD HOOK ***********************/ |
|
283 | + |
|
284 | + |
|
285 | + |
|
286 | + /** |
|
287 | + * callback for the "template_redirect" hook point |
|
288 | + * checks sidebars for EE widgets |
|
289 | + * loads resources and assets accordingly |
|
290 | + * |
|
291 | + * @return void |
|
292 | + */ |
|
293 | + public function templateRedirect() |
|
294 | + { |
|
295 | + global $wp_query; |
|
296 | + if (empty($wp_query->posts)){ |
|
297 | + return; |
|
298 | + } |
|
299 | + // if we already know this is an espresso page, then load assets |
|
300 | + $load_assets = $this->Request_Handler->is_espresso_page(); |
|
301 | + // if we are already loading assets then just move along, otherwise check for widgets |
|
302 | + $load_assets = $load_assets ? $load_assets : $this->espresso_widgets_in_active_sidebars(); |
|
303 | + if ( $load_assets){ |
|
304 | + add_action('wp_enqueue_scripts', array($this, 'enqueueStyle'), 10); |
|
305 | + add_action('wp_print_footer_scripts', array($this, 'enqueueScripts'), 10); |
|
306 | + } |
|
307 | + } |
|
308 | + |
|
309 | + |
|
310 | + |
|
311 | + /** |
|
312 | + * builds list of active widgets then scans active sidebars looking for them |
|
313 | + * returns true is an EE widget is found in an active sidebar |
|
314 | + * Please Note: this does NOT mean that the sidebar or widget |
|
315 | + * is actually in use in a given template, as that is unfortunately not known |
|
316 | + * until a sidebar and it's widgets are actually loaded |
|
317 | + * |
|
318 | + * @return boolean |
|
319 | + */ |
|
320 | + private function espresso_widgets_in_active_sidebars() |
|
321 | + { |
|
322 | + $espresso_widgets = array(); |
|
323 | + foreach ($this->Registry->widgets as $widget_class => $widget) { |
|
324 | + $id_base = EspressoWidget::getIdBase($widget_class); |
|
325 | + if (is_active_widget(false, false, $id_base)) { |
|
326 | + $espresso_widgets[] = $id_base; |
|
327 | + } |
|
328 | + } |
|
329 | + $all_sidebar_widgets = wp_get_sidebars_widgets(); |
|
330 | + foreach ($all_sidebar_widgets as $sidebar_name => $sidebar_widgets) { |
|
331 | + if (is_array($sidebar_widgets) && ! empty($sidebar_widgets)) { |
|
332 | + foreach ($sidebar_widgets as $sidebar_widget) { |
|
333 | + foreach ($espresso_widgets as $espresso_widget) { |
|
334 | + if (strpos($sidebar_widget, $espresso_widget) !== false) { |
|
335 | + return true; |
|
336 | + } |
|
337 | + } |
|
338 | + } |
|
339 | + } |
|
340 | + } |
|
341 | + return false; |
|
342 | + } |
|
343 | + |
|
344 | + |
|
345 | + |
|
346 | + |
|
347 | + /** |
|
348 | + * header_meta_tag |
|
349 | + * |
|
350 | + * @access public |
|
351 | + * @return void |
|
352 | + */ |
|
353 | + public function header_meta_tag() |
|
354 | + { |
|
355 | + print( |
|
356 | + apply_filters( |
|
357 | + 'FHEE__EE_Front_Controller__header_meta_tag', |
|
358 | + '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n") |
|
359 | + ); |
|
360 | + |
|
361 | + //let's exclude all event type taxonomy term archive pages from search engine indexing |
|
362 | + //@see https://events.codebasehq.com/projects/event-espresso/tickets/10249 |
|
363 | + //also exclude all critical pages from indexing |
|
364 | + if ( |
|
365 | + ( |
|
366 | + is_tax('espresso_event_type') |
|
367 | + && get_option( 'blog_public' ) !== '0' |
|
368 | + ) |
|
369 | + || is_page(EE_Registry::instance()->CFG->core->get_critical_pages_array()) |
|
370 | + ) { |
|
371 | + print( |
|
372 | + apply_filters( |
|
373 | + 'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type', |
|
374 | + '<meta name="robots" content="noindex,follow" />' . "\n" |
|
375 | + ) |
|
376 | + ); |
|
377 | + } |
|
378 | + } |
|
379 | + |
|
380 | + |
|
381 | + |
|
382 | + /** |
|
383 | + * wp_print_scripts |
|
384 | + * |
|
385 | + * @return void |
|
386 | + */ |
|
387 | + public function wp_print_scripts() |
|
388 | + { |
|
389 | + global $post; |
|
390 | + if ( |
|
391 | + isset($post->EE_Event) |
|
392 | + && $post->EE_Event instanceof EE_Event |
|
393 | + && get_post_type() === 'espresso_events' |
|
394 | + && is_singular() |
|
395 | + ) { |
|
396 | + \EEH_Schema::add_json_linked_data_for_event($post->EE_Event); |
|
397 | + } |
|
398 | + } |
|
399 | + |
|
400 | + |
|
401 | + |
|
402 | + public function enqueueStyle() |
|
403 | + { |
|
404 | + wp_enqueue_style('espresso_default'); |
|
405 | + wp_enqueue_style('espresso_custom_css'); |
|
406 | + } |
|
407 | + |
|
408 | + |
|
409 | + |
|
410 | + |
|
411 | + /*********************************************** THE_CONTENT FILTER HOOK ********************************************** |
|
412 | 412 | |
413 | 413 | |
414 | 414 | |
@@ -419,117 +419,117 @@ discard block |
||
419 | 419 | // * @param $the_content |
420 | 420 | // * @return string |
421 | 421 | // */ |
422 | - // public function the_content( $the_content ) { |
|
423 | - // // nothing gets loaded at this point unless other systems turn this hookpoint on by using: add_filter( 'FHEE_run_EE_the_content', '__return_true' ); |
|
424 | - // if ( apply_filters( 'FHEE_run_EE_the_content', FALSE ) ) { |
|
425 | - // } |
|
426 | - // return $the_content; |
|
427 | - // } |
|
428 | - |
|
429 | - |
|
430 | - |
|
431 | - /*********************************************** WP_FOOTER ***********************************************/ |
|
432 | - |
|
433 | - |
|
434 | - |
|
435 | - public function enqueueScripts() |
|
436 | - { |
|
437 | - wp_enqueue_script('espresso_core'); |
|
438 | - } |
|
439 | - |
|
440 | - |
|
441 | - |
|
442 | - /** |
|
443 | - * display_errors |
|
444 | - * |
|
445 | - * @access public |
|
446 | - * @return void |
|
447 | - * @throws DomainException |
|
448 | - */ |
|
449 | - public function display_errors() |
|
450 | - { |
|
451 | - static $shown_already = false; |
|
452 | - do_action('AHEE__EE_Front_Controller__display_errors__begin'); |
|
453 | - if ( |
|
454 | - ! $shown_already |
|
455 | - && apply_filters('FHEE__EE_Front_Controller__display_errors', true) |
|
456 | - && is_main_query() |
|
457 | - && ! is_feed() |
|
458 | - && in_the_loop() |
|
459 | - && $this->Request_Handler->is_espresso_page() |
|
460 | - ) { |
|
461 | - echo EE_Error::get_notices(); |
|
462 | - $shown_already = true; |
|
463 | - EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php'); |
|
464 | - } |
|
465 | - do_action('AHEE__EE_Front_Controller__display_errors__end'); |
|
466 | - } |
|
467 | - |
|
468 | - |
|
469 | - |
|
470 | - |
|
471 | - |
|
472 | - /*********************************************** UTILITIES ***********************************************/ |
|
473 | - /** |
|
474 | - * template_include |
|
475 | - * |
|
476 | - * @access public |
|
477 | - * @param string $template_include_path |
|
478 | - * @return string |
|
479 | - */ |
|
480 | - public function template_include($template_include_path = null) |
|
481 | - { |
|
482 | - if ($this->Request_Handler->is_espresso_page()) { |
|
483 | - $this->_template_path = ! empty($this->_template_path) ? basename($this->_template_path) : basename($template_include_path); |
|
484 | - $template_path = EEH_Template::locate_template($this->_template_path, array(), false); |
|
485 | - $this->_template_path = ! empty($template_path) ? $template_path : $template_include_path; |
|
486 | - $this->_template = basename($this->_template_path); |
|
487 | - return $this->_template_path; |
|
488 | - } |
|
489 | - return $template_include_path; |
|
490 | - } |
|
491 | - |
|
492 | - |
|
493 | - /** |
|
494 | - * get_selected_template |
|
495 | - * |
|
496 | - * @access public |
|
497 | - * @param bool $with_path |
|
498 | - * @return string |
|
499 | - */ |
|
500 | - public function get_selected_template($with_path = false) |
|
501 | - { |
|
502 | - return $with_path ? $this->_template_path : $this->_template; |
|
503 | - } |
|
504 | - |
|
505 | - |
|
506 | - |
|
507 | - /** |
|
508 | - * @deprecated 4.9.26 |
|
509 | - * @param string $shortcode_class |
|
510 | - * @param \WP $wp |
|
511 | - */ |
|
512 | - public function initialize_shortcode($shortcode_class = '', WP $wp = null) |
|
513 | - { |
|
514 | - \EE_Error::doing_it_wrong( |
|
515 | - __METHOD__, |
|
516 | - __( |
|
517 | - 'Usage is deprecated. Please use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::initializeShortcode() instead.', |
|
518 | - 'event_espresso' |
|
519 | - ), |
|
520 | - '4.9.26' |
|
521 | - ); |
|
522 | - $this->getLegacyShortcodesManager()->initializeShortcode($shortcode_class, $wp); |
|
523 | - } |
|
524 | - |
|
525 | - |
|
526 | - /** |
|
527 | - * @return void |
|
528 | - * @deprecated 4.9.57.p |
|
529 | - */ |
|
530 | - public function loadPersistentAdminNoticeManager() |
|
531 | - { |
|
532 | - } |
|
422 | + // public function the_content( $the_content ) { |
|
423 | + // // nothing gets loaded at this point unless other systems turn this hookpoint on by using: add_filter( 'FHEE_run_EE_the_content', '__return_true' ); |
|
424 | + // if ( apply_filters( 'FHEE_run_EE_the_content', FALSE ) ) { |
|
425 | + // } |
|
426 | + // return $the_content; |
|
427 | + // } |
|
428 | + |
|
429 | + |
|
430 | + |
|
431 | + /*********************************************** WP_FOOTER ***********************************************/ |
|
432 | + |
|
433 | + |
|
434 | + |
|
435 | + public function enqueueScripts() |
|
436 | + { |
|
437 | + wp_enqueue_script('espresso_core'); |
|
438 | + } |
|
439 | + |
|
440 | + |
|
441 | + |
|
442 | + /** |
|
443 | + * display_errors |
|
444 | + * |
|
445 | + * @access public |
|
446 | + * @return void |
|
447 | + * @throws DomainException |
|
448 | + */ |
|
449 | + public function display_errors() |
|
450 | + { |
|
451 | + static $shown_already = false; |
|
452 | + do_action('AHEE__EE_Front_Controller__display_errors__begin'); |
|
453 | + if ( |
|
454 | + ! $shown_already |
|
455 | + && apply_filters('FHEE__EE_Front_Controller__display_errors', true) |
|
456 | + && is_main_query() |
|
457 | + && ! is_feed() |
|
458 | + && in_the_loop() |
|
459 | + && $this->Request_Handler->is_espresso_page() |
|
460 | + ) { |
|
461 | + echo EE_Error::get_notices(); |
|
462 | + $shown_already = true; |
|
463 | + EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php'); |
|
464 | + } |
|
465 | + do_action('AHEE__EE_Front_Controller__display_errors__end'); |
|
466 | + } |
|
467 | + |
|
468 | + |
|
469 | + |
|
470 | + |
|
471 | + |
|
472 | + /*********************************************** UTILITIES ***********************************************/ |
|
473 | + /** |
|
474 | + * template_include |
|
475 | + * |
|
476 | + * @access public |
|
477 | + * @param string $template_include_path |
|
478 | + * @return string |
|
479 | + */ |
|
480 | + public function template_include($template_include_path = null) |
|
481 | + { |
|
482 | + if ($this->Request_Handler->is_espresso_page()) { |
|
483 | + $this->_template_path = ! empty($this->_template_path) ? basename($this->_template_path) : basename($template_include_path); |
|
484 | + $template_path = EEH_Template::locate_template($this->_template_path, array(), false); |
|
485 | + $this->_template_path = ! empty($template_path) ? $template_path : $template_include_path; |
|
486 | + $this->_template = basename($this->_template_path); |
|
487 | + return $this->_template_path; |
|
488 | + } |
|
489 | + return $template_include_path; |
|
490 | + } |
|
491 | + |
|
492 | + |
|
493 | + /** |
|
494 | + * get_selected_template |
|
495 | + * |
|
496 | + * @access public |
|
497 | + * @param bool $with_path |
|
498 | + * @return string |
|
499 | + */ |
|
500 | + public function get_selected_template($with_path = false) |
|
501 | + { |
|
502 | + return $with_path ? $this->_template_path : $this->_template; |
|
503 | + } |
|
504 | + |
|
505 | + |
|
506 | + |
|
507 | + /** |
|
508 | + * @deprecated 4.9.26 |
|
509 | + * @param string $shortcode_class |
|
510 | + * @param \WP $wp |
|
511 | + */ |
|
512 | + public function initialize_shortcode($shortcode_class = '', WP $wp = null) |
|
513 | + { |
|
514 | + \EE_Error::doing_it_wrong( |
|
515 | + __METHOD__, |
|
516 | + __( |
|
517 | + 'Usage is deprecated. Please use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::initializeShortcode() instead.', |
|
518 | + 'event_espresso' |
|
519 | + ), |
|
520 | + '4.9.26' |
|
521 | + ); |
|
522 | + $this->getLegacyShortcodesManager()->initializeShortcode($shortcode_class, $wp); |
|
523 | + } |
|
524 | + |
|
525 | + |
|
526 | + /** |
|
527 | + * @return void |
|
528 | + * @deprecated 4.9.57.p |
|
529 | + */ |
|
530 | + public function loadPersistentAdminNoticeManager() |
|
531 | + { |
|
532 | + } |
|
533 | 533 | } |
534 | 534 | // End of file EE_Front_Controller.core.php |
535 | 535 | // Location: /core/EE_Front_Controller.core.php |
@@ -20,1115 +20,1115 @@ discard block |
||
20 | 20 | class EED_Events_Archive extends EED_Module |
21 | 21 | { |
22 | 22 | |
23 | - const EVENT_DETAILS_PRIORITY = 100; |
|
24 | - |
|
25 | - const EVENT_DATETIMES_PRIORITY = 110; |
|
26 | - |
|
27 | - const EVENT_TICKETS_PRIORITY = 120; |
|
28 | - |
|
29 | - const EVENT_VENUES_PRIORITY = 130; |
|
30 | - |
|
31 | - |
|
32 | - public static $espresso_event_list_ID = 0; |
|
33 | - |
|
34 | - public static $espresso_grid_event_lists = array(); |
|
35 | - |
|
36 | - /** |
|
37 | - * @type bool $using_get_the_excerpt |
|
38 | - */ |
|
39 | - protected static $using_get_the_excerpt = false; |
|
40 | - |
|
41 | - /** |
|
42 | - * Used to flag when the event list is being called from an external iframe. |
|
43 | - * |
|
44 | - * @var bool $iframe |
|
45 | - */ |
|
46 | - protected static $iframe = false; |
|
47 | - |
|
48 | - /** |
|
49 | - * @var \EventEspresso\core\libraries\iframe_display\EventListIframeEmbedButton $_iframe_embed_button |
|
50 | - */ |
|
51 | - private static $_iframe_embed_button; |
|
52 | - |
|
53 | - /** |
|
54 | - * @type EE_Template_Part_Manager $template_parts |
|
55 | - */ |
|
56 | - protected $template_parts; |
|
57 | - |
|
58 | - |
|
59 | - |
|
60 | - /** |
|
61 | - * @return EED_Events_Archive |
|
62 | - */ |
|
63 | - public static function instance() |
|
64 | - { |
|
65 | - return parent::get_instance(__CLASS__); |
|
66 | - } |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
71 | - * |
|
72 | - * @return void |
|
73 | - * @throws InvalidArgumentException |
|
74 | - * @throws InvalidDataTypeException |
|
75 | - * @throws InvalidInterfaceException |
|
76 | - */ |
|
77 | - public static function set_hooks() |
|
78 | - { |
|
79 | - /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */ |
|
80 | - $custom_post_type_definitions = LoaderFactory::getLoader()->getShared( |
|
81 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
82 | - ); |
|
83 | - $custom_post_types = $custom_post_type_definitions->getDefinitions(); |
|
84 | - EE_Config::register_route( |
|
85 | - $custom_post_types['espresso_events']['plural_slug'], |
|
86 | - 'Events_Archive', |
|
87 | - 'run' |
|
88 | - ); |
|
89 | - EE_Config::register_route( |
|
90 | - 'event_list', |
|
91 | - 'Events_Archive', |
|
92 | - 'event_list' |
|
93 | - ); |
|
94 | - EE_Config::register_route( |
|
95 | - 'iframe', |
|
96 | - 'Events_Archive', |
|
97 | - 'event_list_iframe', |
|
98 | - 'event_list' |
|
99 | - ); |
|
100 | - add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2); |
|
101 | - } |
|
102 | - |
|
103 | - |
|
104 | - |
|
105 | - /** |
|
106 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
107 | - * |
|
108 | - * @access public |
|
109 | - * @return void |
|
110 | - */ |
|
111 | - public static function set_hooks_admin() |
|
112 | - { |
|
113 | - add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2); |
|
114 | - // hook into the end of the \EE_Admin_Page::_load_page_dependencies() |
|
115 | - // to load assets for "espresso_events" page on the "default" route (action) |
|
116 | - add_action( |
|
117 | - 'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__default', |
|
118 | - array('EED_Events_Archive', 'event_list_iframe_embed_button'), |
|
119 | - 10 |
|
120 | - ); |
|
121 | - } |
|
122 | - |
|
123 | - |
|
124 | - |
|
125 | - /** |
|
126 | - * set_definitions |
|
127 | - * |
|
128 | - * @access public |
|
129 | - * @return void |
|
130 | - */ |
|
131 | - public static function set_definitions() |
|
132 | - { |
|
133 | - define('EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS); |
|
134 | - define('EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)) . 'templates' . DS); |
|
135 | - } |
|
136 | - |
|
137 | - |
|
138 | - |
|
139 | - /** |
|
140 | - * set up EE_Events_Archive_Config |
|
141 | - */ |
|
142 | - protected function set_config() |
|
143 | - { |
|
144 | - $this->set_config_section('template_settings'); |
|
145 | - $this->set_config_class('EE_Events_Archive_Config'); |
|
146 | - $this->set_config_name('EED_Events_Archive'); |
|
147 | - } |
|
148 | - |
|
149 | - |
|
150 | - |
|
151 | - /** |
|
152 | - * @return EventListIframeEmbedButton |
|
153 | - */ |
|
154 | - public static function get_iframe_embed_button() |
|
155 | - { |
|
156 | - if (! self::$_iframe_embed_button instanceof EventListIframeEmbedButton) { |
|
157 | - self::$_iframe_embed_button = new EventListIframeEmbedButton(); |
|
158 | - } |
|
159 | - return self::$_iframe_embed_button; |
|
160 | - } |
|
161 | - |
|
162 | - |
|
163 | - |
|
164 | - /** |
|
165 | - * event_list_iframe_embed_button |
|
166 | - * |
|
167 | - * @return void |
|
168 | - * @throws \EE_Error |
|
169 | - */ |
|
170 | - public static function event_list_iframe_embed_button() |
|
171 | - { |
|
172 | - $iframe_embed_button = \EED_Events_Archive::get_iframe_embed_button(); |
|
173 | - $iframe_embed_button->addEmbedButton(); |
|
174 | - } |
|
175 | - |
|
176 | - |
|
177 | - |
|
178 | - /** |
|
179 | - * initialize_template_parts |
|
180 | - * |
|
181 | - * @access public |
|
182 | - * @param \EE_Events_Archive_Config $config |
|
183 | - * @return \EE_Template_Part_Manager |
|
184 | - */ |
|
185 | - public function initialize_template_parts(EE_Events_Archive_Config $config = null) |
|
186 | - { |
|
187 | - $config = $config instanceof EE_Events_Archive_Config ? $config : $this->config(); |
|
188 | - EEH_Autoloader::instance()->register_template_part_autoloaders(); |
|
189 | - $template_parts = new EE_Template_Part_Manager(); |
|
190 | - $template_parts->add_template_part( |
|
191 | - 'tickets', |
|
192 | - __('Ticket Selector', 'event_espresso'), |
|
193 | - 'content-espresso_events-tickets.php', |
|
194 | - $config->display_order_tickets |
|
195 | - ); |
|
196 | - $template_parts->add_template_part( |
|
197 | - 'datetimes', |
|
198 | - __('Dates and Times', 'event_espresso'), |
|
199 | - 'content-espresso_events-datetimes.php', |
|
200 | - $config->display_order_datetimes |
|
201 | - ); |
|
202 | - $template_parts->add_template_part( |
|
203 | - 'event', |
|
204 | - __('Event Description', 'event_espresso'), |
|
205 | - 'content-espresso_events-details.php', |
|
206 | - $config->display_order_event |
|
207 | - ); |
|
208 | - $template_parts->add_template_part( |
|
209 | - 'venue', |
|
210 | - __('Venue Information', 'event_espresso'), |
|
211 | - 'content-espresso_events-venues.php', |
|
212 | - $config->display_order_venue |
|
213 | - ); |
|
214 | - do_action('AHEE__EED_Event_Archive__initialize_template_parts', $template_parts); |
|
215 | - return $template_parts; |
|
216 | - } |
|
217 | - |
|
218 | - |
|
219 | - |
|
220 | - /** |
|
221 | - * run - initial module setup - this gets called by the EE_Front_Controller if the module route is found in the incoming request |
|
222 | - * |
|
223 | - * @access public |
|
224 | - * @param WP $WP |
|
225 | - * @return void |
|
226 | - */ |
|
227 | - public function run($WP) |
|
228 | - { |
|
229 | - do_action('AHEE__EED_Events_Archive__before_run'); |
|
230 | - // ensure valid EE_Events_Archive_Config() object exists |
|
231 | - $this->set_config(); |
|
232 | - /** @type EE_Events_Archive_Config $config */ |
|
233 | - $config = $this->config(); |
|
234 | - // load other required components |
|
235 | - $this->load_event_list_assets(); |
|
236 | - // filter the WP posts_join, posts_where, and posts_orderby SQL clauses |
|
237 | - //add query filters |
|
238 | - EEH_Event_Query::add_query_filters(); |
|
239 | - // set params that will get used by the filters |
|
240 | - EEH_Event_Query::set_query_params( |
|
241 | - '', // month |
|
242 | - '', // category |
|
243 | - $config->display_expired_events, // show_expired |
|
244 | - 'start_date', // orderby |
|
245 | - 'ASC' // sort |
|
246 | - ); |
|
247 | - // check what template is loaded |
|
248 | - add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
249 | - } |
|
250 | - |
|
251 | - |
|
252 | - |
|
253 | - /** |
|
254 | - * most likely called by the ESPRESSO_EVENTS shortcode which uses this module to do some of it's lifting |
|
255 | - * |
|
256 | - * @return void |
|
257 | - */ |
|
258 | - public function event_list() |
|
259 | - { |
|
260 | - // ensure valid EE_Events_Archive_Config() object exists |
|
261 | - $this->set_config(); |
|
262 | - // load other required components |
|
263 | - $this->load_event_list_assets(); |
|
264 | - } |
|
265 | - |
|
266 | - |
|
267 | - |
|
268 | - /** |
|
269 | - * @access public |
|
270 | - * @return void |
|
271 | - * @throws \EE_Error |
|
272 | - * @throws \DomainException |
|
273 | - */ |
|
274 | - public function event_list_iframe() |
|
275 | - { |
|
276 | - \EED_Events_Archive::$iframe = true; |
|
277 | - $event_list_iframe = new EventsArchiveIframe($this); |
|
278 | - $event_list_iframe->display(); |
|
279 | - } |
|
280 | - |
|
281 | - |
|
282 | - |
|
283 | - /** |
|
284 | - * @access public |
|
285 | - * @return string |
|
286 | - */ |
|
287 | - public static function is_iframe() |
|
288 | - { |
|
289 | - return \EED_Events_Archive::$iframe; |
|
290 | - } |
|
291 | - |
|
292 | - |
|
293 | - |
|
294 | - /** |
|
295 | - * @access public |
|
296 | - * @return string |
|
297 | - */ |
|
298 | - public static function link_target() |
|
299 | - { |
|
300 | - return \EED_Events_Archive::$iframe ? ' target="_blank"' : ''; |
|
301 | - } |
|
302 | - |
|
303 | - |
|
304 | - |
|
305 | - /** |
|
306 | - * template_include |
|
307 | - * |
|
308 | - * @access public |
|
309 | - * @param string $template |
|
310 | - * @return string |
|
311 | - */ |
|
312 | - public function template_include($template = '') |
|
313 | - { |
|
314 | - // don't add content filter for dedicated EE child themes or private posts |
|
315 | - if (! EEH_Template::is_espresso_theme()) { |
|
316 | - /** @type EE_Events_Archive_Config $config */ |
|
317 | - $config = $this->config(); |
|
318 | - // add status banner ? |
|
319 | - if ($config->display_status_banner) { |
|
320 | - add_filter('the_title', array('EED_Events_Archive', 'the_title'), 100, 2); |
|
321 | - } |
|
322 | - // if NOT a custom template |
|
323 | - if ( |
|
324 | - apply_filters('FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', false) |
|
325 | - || EE_Registry::instance() |
|
326 | - ->load_core('Front_Controller') |
|
327 | - ->get_selected_template() !== 'archive-espresso_events.php' |
|
328 | - ) { |
|
329 | - // don't display entry meta because the existing theme will take care of that |
|
330 | - add_filter('FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true'); |
|
331 | - // load functions.php file for the theme (loaded by WP if using child theme) |
|
332 | - EEH_Template::load_espresso_theme_functions(); |
|
333 | - // because we don't know if the theme is using the_excerpt() |
|
334 | - add_filter( |
|
335 | - 'the_excerpt', |
|
336 | - array('EED_Events_Archive', 'event_details'), |
|
337 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
338 | - ); |
|
339 | - // or the_content |
|
340 | - add_filter( |
|
341 | - 'the_content', |
|
342 | - array('EED_Events_Archive', 'event_details'), |
|
343 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
344 | - ); |
|
345 | - // and just in case they are running get_the_excerpt() which DESTROYS things |
|
346 | - add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1); |
|
347 | - // don't display entry meta because the existing theme will take care of that |
|
348 | - add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false'); |
|
349 | - } |
|
350 | - } |
|
351 | - return $template; |
|
352 | - } |
|
353 | - |
|
354 | - |
|
355 | - |
|
356 | - /** |
|
357 | - * get_the_excerpt - kinda hacky, but if a theme is using get_the_excerpt(), then we need to remove our filters on the_content() |
|
358 | - * |
|
359 | - * @access public |
|
360 | - * @param string $excerpt |
|
361 | - * @return string |
|
362 | - */ |
|
363 | - public static function get_the_excerpt($excerpt = '') |
|
364 | - { |
|
365 | - if (post_password_required()) { |
|
366 | - return $excerpt; |
|
367 | - } |
|
368 | - if (apply_filters('FHEE__EED_Events_Archive__get_the_excerpt__theme_uses_get_the_excerpt', false)) { |
|
369 | - remove_filter( |
|
370 | - 'the_excerpt', |
|
371 | - array('EED_Events_Archive', 'event_details'), |
|
372 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
373 | - ); |
|
374 | - remove_filter( |
|
375 | - 'the_content', |
|
376 | - array('EED_Events_Archive', 'event_details'), |
|
377 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
378 | - ); |
|
379 | - $excerpt = EED_Events_Archive::event_details($excerpt); |
|
380 | - } else { |
|
381 | - EED_Events_Archive::$using_get_the_excerpt = true; |
|
382 | - add_filter('wp_trim_excerpt', array('EED_Events_Archive', 'end_get_the_excerpt'), 999, 1); |
|
383 | - } |
|
384 | - return $excerpt; |
|
385 | - } |
|
386 | - |
|
387 | - |
|
388 | - |
|
389 | - /** |
|
390 | - * end_get_the_excerpt |
|
391 | - * |
|
392 | - * @access public |
|
393 | - * @param string $text |
|
394 | - * @return string |
|
395 | - */ |
|
396 | - public static function end_get_the_excerpt($text = '') |
|
397 | - { |
|
398 | - EED_Events_Archive::$using_get_the_excerpt = false; |
|
399 | - return $text; |
|
400 | - } |
|
401 | - |
|
402 | - |
|
403 | - |
|
404 | - /** |
|
405 | - * the_title |
|
406 | - * |
|
407 | - * @access public |
|
408 | - * @param string $title |
|
409 | - * @param string $id |
|
410 | - * @return string |
|
411 | - */ |
|
412 | - public static function the_title($title = '', $id = '') |
|
413 | - { |
|
414 | - global $post; |
|
415 | - if ($post instanceof WP_Post) { |
|
416 | - return in_the_loop() && $post->ID == $id ? espresso_event_status_banner($post->ID) . $title : $title; |
|
417 | - } |
|
418 | - return $title; |
|
419 | - } |
|
420 | - |
|
421 | - |
|
422 | - |
|
423 | - /** |
|
424 | - * event_details |
|
425 | - * |
|
426 | - * @access public |
|
427 | - * @param string $content |
|
428 | - * @return string |
|
429 | - */ |
|
430 | - public static function event_details($content) |
|
431 | - { |
|
432 | - global $post; |
|
433 | - static $current_post_ID = 0; |
|
434 | - if ( |
|
435 | - $current_post_ID !== $post->ID |
|
436 | - && $post->post_type === 'espresso_events' |
|
437 | - && ! EED_Events_Archive::$using_get_the_excerpt |
|
438 | - && ! post_password_required() |
|
439 | - && ( |
|
440 | - apply_filters('FHEE__EES_Espresso_Events__process_shortcode__true', false) |
|
441 | - || ! apply_filters('FHEE__content_espresso_events__template_loaded', false) |
|
442 | - ) |
|
443 | - ) { |
|
444 | - // Set current post ID to prevent showing content twice, but only if headers have definitely been sent. |
|
445 | - // Reason being is that some plugins, like Yoast, need to run through a copy of the loop early |
|
446 | - // BEFORE headers are sent in order to examine the post content and generate content for the HTML header. |
|
447 | - // We want to allow those plugins to still do their thing and have access to our content, but depending on |
|
448 | - // how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice, |
|
449 | - // so the following allows this filter to be applied multiple times, but only once for real |
|
450 | - $current_post_ID = did_action('loop_start') ? $post->ID : 0; |
|
451 | - if (EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->use_sortable_display_order) { |
|
452 | - $content = \EED_Events_Archive::use_sortable_display_order(); |
|
453 | - } else { |
|
454 | - $content = \EED_Events_Archive::use_filterable_display_order(); |
|
455 | - } |
|
456 | - } |
|
457 | - return $content; |
|
458 | - } |
|
459 | - |
|
460 | - |
|
461 | - |
|
462 | - /** |
|
463 | - * use_sortable_display_order |
|
464 | - * |
|
465 | - * @access protected |
|
466 | - * @return string |
|
467 | - */ |
|
468 | - protected static function use_sortable_display_order() |
|
469 | - { |
|
470 | - // no further password checks required atm |
|
471 | - add_filter('FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true'); |
|
472 | - // we need to first remove this callback from being applied to the_content() or the_excerpt() |
|
473 | - // (otherwise it will recurse and blow up the interweb) |
|
474 | - remove_filter( |
|
475 | - 'the_excerpt', |
|
476 | - array('EED_Events_Archive', 'event_details'), |
|
477 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
478 | - ); |
|
479 | - remove_filter( |
|
480 | - 'the_content', |
|
481 | - array('EED_Events_Archive', 'event_details'), |
|
482 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
483 | - ); |
|
484 | - remove_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1); |
|
485 | - // now add additional content depending on whether event is using the_excerpt() or the_content() |
|
486 | - EED_Events_Archive::instance()->template_parts = EED_Events_Archive::instance()->initialize_template_parts(); |
|
487 | - $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
488 | - $content = EED_Events_Archive::instance()->template_parts->apply_template_part_filters($content); |
|
489 | - // re-add our main filters (or else the next event won't have them) |
|
490 | - add_filter( |
|
491 | - 'the_excerpt', |
|
492 | - array('EED_Events_Archive', 'event_details'), |
|
493 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
494 | - ); |
|
495 | - add_filter( |
|
496 | - 'the_content', |
|
497 | - array('EED_Events_Archive', 'event_details'), |
|
498 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
499 | - ); |
|
500 | - add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1); |
|
501 | - remove_filter( |
|
502 | - 'FHEE__EED_Events_Archive__event_details__no_post_password_required', |
|
503 | - '__return_true' |
|
504 | - ); |
|
505 | - return $content; |
|
506 | - } |
|
507 | - |
|
508 | - |
|
509 | - |
|
510 | - /** |
|
511 | - * use_filterable_display_order |
|
512 | - * |
|
513 | - * @access protected |
|
514 | - * @return string |
|
515 | - */ |
|
516 | - protected static function use_filterable_display_order() |
|
517 | - { |
|
518 | - // we need to first remove this callback from being applied to the_content() |
|
519 | - // (otherwise it will recurse and blow up the interweb) |
|
520 | - remove_filter( |
|
521 | - 'the_excerpt', |
|
522 | - array('EED_Events_Archive', 'event_details'), |
|
523 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
524 | - ); |
|
525 | - remove_filter( |
|
526 | - 'the_content', |
|
527 | - array('EED_Events_Archive', 'event_details'), |
|
528 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
529 | - ); |
|
530 | - remove_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1); |
|
531 | - //now add additional content depending on whether event is using the_excerpt() or the_content() |
|
532 | - EED_Events_Archive::_add_additional_excerpt_filters(); |
|
533 | - EED_Events_Archive::_add_additional_content_filters(); |
|
534 | - do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_add_filters'); |
|
535 | - // now load our template |
|
536 | - $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
537 | - // re-add our main filters (or else the next event won't have them) |
|
538 | - add_filter( |
|
539 | - 'the_excerpt', |
|
540 | - array('EED_Events_Archive', 'event_details'), |
|
541 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
542 | - ); |
|
543 | - add_filter( |
|
544 | - 'the_content', |
|
545 | - array('EED_Events_Archive', 'event_details'), |
|
546 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
547 | - ); |
|
548 | - add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1); |
|
549 | - // but remove the other filters so that they don't get applied to the next post |
|
550 | - EED_Events_Archive::_remove_additional_events_archive_filters(); |
|
551 | - do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_remove_filters'); |
|
552 | - // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
|
553 | - //return ! empty( $template ) ? $template : $content; |
|
554 | - return $content; |
|
555 | - } |
|
556 | - |
|
557 | - |
|
558 | - |
|
559 | - /** |
|
560 | - * event_datetimes - adds datetimes ABOVE content |
|
561 | - * |
|
562 | - * @access public |
|
563 | - * @param string $content |
|
564 | - * @return string |
|
565 | - */ |
|
566 | - public static function event_datetimes($content) |
|
567 | - { |
|
568 | - if (post_password_required()) { |
|
569 | - return $content; |
|
570 | - } |
|
571 | - return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content; |
|
572 | - } |
|
573 | - |
|
574 | - |
|
575 | - |
|
576 | - /** |
|
577 | - * event_tickets - adds tickets ABOVE content (which includes datetimes) |
|
578 | - * |
|
579 | - * @access public |
|
580 | - * @param string $content |
|
581 | - * @return string |
|
582 | - */ |
|
583 | - public static function event_tickets($content) |
|
584 | - { |
|
585 | - if (post_password_required()) { |
|
586 | - return $content; |
|
587 | - } |
|
588 | - return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content; |
|
589 | - } |
|
590 | - |
|
591 | - |
|
592 | - |
|
593 | - /** |
|
594 | - * event_venues - adds venues BELOW content |
|
595 | - * |
|
596 | - * @access public |
|
597 | - * @param string $content |
|
598 | - * @return string |
|
599 | - */ |
|
600 | - public static function event_venue($content) |
|
601 | - { |
|
602 | - return EED_Events_Archive::event_venues($content); |
|
603 | - } |
|
604 | - |
|
605 | - |
|
606 | - |
|
607 | - /** |
|
608 | - * event_venues - adds venues BELOW content |
|
609 | - * |
|
610 | - * @access public |
|
611 | - * @param string $content |
|
612 | - * @return string |
|
613 | - */ |
|
614 | - public static function event_venues($content) |
|
615 | - { |
|
616 | - if (post_password_required()) { |
|
617 | - return $content; |
|
618 | - } |
|
619 | - return $content . EEH_Template::locate_template('content-espresso_events-venues.php'); |
|
620 | - } |
|
621 | - |
|
622 | - |
|
623 | - |
|
624 | - /** |
|
625 | - * _add_additional_content_filters |
|
626 | - * |
|
627 | - * @access private |
|
628 | - * @return void |
|
629 | - */ |
|
630 | - private static function _add_additional_excerpt_filters() |
|
631 | - { |
|
632 | - add_filter( |
|
633 | - 'the_excerpt', |
|
634 | - array('EED_Events_Archive', 'event_datetimes'), |
|
635 | - EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
636 | - ); |
|
637 | - add_filter( |
|
638 | - 'the_excerpt', |
|
639 | - array('EED_Events_Archive', 'event_tickets'), |
|
640 | - EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
641 | - ); |
|
642 | - add_filter( |
|
643 | - 'the_excerpt', |
|
644 | - array('EED_Events_Archive', 'event_venues'), |
|
645 | - EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
646 | - ); |
|
647 | - } |
|
648 | - |
|
649 | - |
|
650 | - |
|
651 | - /** |
|
652 | - * _add_additional_content_filters |
|
653 | - * |
|
654 | - * @access private |
|
655 | - * @return void |
|
656 | - */ |
|
657 | - private static function _add_additional_content_filters() |
|
658 | - { |
|
659 | - add_filter( |
|
660 | - 'the_content', |
|
661 | - array('EED_Events_Archive', 'event_datetimes'), |
|
662 | - EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
663 | - ); |
|
664 | - add_filter( |
|
665 | - 'the_content', |
|
666 | - array('EED_Events_Archive', 'event_tickets'), |
|
667 | - EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
668 | - ); |
|
669 | - add_filter( |
|
670 | - 'the_content', |
|
671 | - array('EED_Events_Archive', 'event_venues'), |
|
672 | - EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
673 | - ); |
|
674 | - } |
|
675 | - |
|
676 | - |
|
677 | - |
|
678 | - /** |
|
679 | - * _remove_additional_events_archive_filters |
|
680 | - * |
|
681 | - * @access private |
|
682 | - * @return void |
|
683 | - */ |
|
684 | - private static function _remove_additional_events_archive_filters() |
|
685 | - { |
|
686 | - remove_filter( |
|
687 | - 'the_excerpt', |
|
688 | - array('EED_Events_Archive', 'event_datetimes'), |
|
689 | - EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
690 | - ); |
|
691 | - remove_filter( |
|
692 | - 'the_excerpt', |
|
693 | - array('EED_Events_Archive', 'event_tickets'), |
|
694 | - EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
695 | - ); |
|
696 | - remove_filter( |
|
697 | - 'the_excerpt', |
|
698 | - array('EED_Events_Archive', 'event_venues'), |
|
699 | - EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
700 | - ); |
|
701 | - remove_filter( |
|
702 | - 'the_content', |
|
703 | - array('EED_Events_Archive', 'event_datetimes'), |
|
704 | - EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
705 | - ); |
|
706 | - remove_filter( |
|
707 | - 'the_content', |
|
708 | - array('EED_Events_Archive', 'event_tickets'), |
|
709 | - EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
710 | - ); |
|
711 | - remove_filter( |
|
712 | - 'the_content', |
|
713 | - array('EED_Events_Archive', 'event_venues'), |
|
714 | - EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
715 | - ); |
|
716 | - } |
|
717 | - |
|
718 | - |
|
719 | - |
|
720 | - /** |
|
721 | - * remove_all_events_archive_filters |
|
722 | - * |
|
723 | - * @access public |
|
724 | - * @return void |
|
725 | - */ |
|
726 | - public static function remove_all_events_archive_filters() |
|
727 | - { |
|
728 | - //remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 ); |
|
729 | - remove_filter('the_title', array('EED_Events_Archive', 'the_title'), 1); |
|
730 | - remove_filter( |
|
731 | - 'the_excerpt', |
|
732 | - array('EED_Events_Archive', 'event_details'), |
|
733 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
734 | - ); |
|
735 | - remove_filter( |
|
736 | - 'the_excerpt', |
|
737 | - array('EED_Events_Archive', 'event_datetimes'), |
|
738 | - EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
739 | - ); |
|
740 | - remove_filter( |
|
741 | - 'the_excerpt', |
|
742 | - array('EED_Events_Archive', 'event_tickets'), |
|
743 | - EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
744 | - ); |
|
745 | - remove_filter( |
|
746 | - 'the_excerpt', |
|
747 | - array('EED_Events_Archive', 'event_venues'), |
|
748 | - EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
749 | - ); |
|
750 | - remove_filter( |
|
751 | - 'the_content', |
|
752 | - array('EED_Events_Archive', 'event_details'), |
|
753 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
754 | - ); |
|
755 | - remove_filter( |
|
756 | - 'the_content', |
|
757 | - array('EED_Events_Archive', 'event_datetimes'), |
|
758 | - EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
759 | - ); |
|
760 | - remove_filter( |
|
761 | - 'the_content', |
|
762 | - array('EED_Events_Archive', 'event_tickets'), |
|
763 | - EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
764 | - ); |
|
765 | - remove_filter( |
|
766 | - 'the_content', |
|
767 | - array('EED_Events_Archive', 'event_venues'), |
|
768 | - EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
769 | - ); |
|
770 | - // don't display entry meta because the existing theme will take care of that |
|
771 | - remove_filter( |
|
772 | - 'FHEE__content_espresso_events_details_template__display_entry_meta', |
|
773 | - '__return_false' |
|
774 | - ); |
|
775 | - } |
|
776 | - |
|
777 | - |
|
778 | - |
|
779 | - /** |
|
780 | - * load_event_list_assets |
|
781 | - * |
|
782 | - * @access public |
|
783 | - * @return void |
|
784 | - */ |
|
785 | - public function load_event_list_assets() |
|
786 | - { |
|
787 | - do_action('AHEE__EED_Events_Archive__before_load_assets'); |
|
788 | - add_filter('FHEE_load_EE_Session', '__return_true'); |
|
789 | - add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
790 | - add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
791 | - if (EE_Registry::instance()->CFG->map_settings->use_google_maps) { |
|
792 | - add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11); |
|
793 | - } |
|
794 | - } |
|
795 | - |
|
796 | - |
|
797 | - |
|
798 | - /** |
|
799 | - * wp_enqueue_scripts |
|
800 | - * |
|
801 | - * @access public |
|
802 | - * @return void |
|
803 | - */ |
|
804 | - public function wp_enqueue_scripts() |
|
805 | - { |
|
806 | - // get some style |
|
807 | - if (apply_filters('FHEE_enable_default_espresso_css', false)) { |
|
808 | - // first check uploads folder |
|
809 | - if (EEH_File::is_readable(get_stylesheet_directory() . $this->theme . DS . 'style.css')) { |
|
810 | - wp_register_style($this->theme, get_stylesheet_directory_uri() . $this->theme . DS . 'style.css', array('dashicons', 'espresso_default')); |
|
811 | - } else { |
|
812 | - } |
|
813 | - wp_enqueue_style($this->theme); |
|
814 | - } |
|
815 | - } |
|
816 | - |
|
817 | - |
|
818 | - |
|
819 | - /** |
|
820 | - * template_settings_form |
|
821 | - * |
|
822 | - * @access public |
|
823 | - * @static |
|
824 | - * @return string |
|
825 | - */ |
|
826 | - public static function template_settings_form() |
|
827 | - { |
|
828 | - $template_settings = EE_Registry::instance()->CFG->template_settings; |
|
829 | - $template_settings->EED_Events_Archive = isset($template_settings->EED_Events_Archive) ? $template_settings->EED_Events_Archive : new EE_Events_Archive_Config(); |
|
830 | - $template_settings->EED_Events_Archive = apply_filters('FHEE__EED_Events_Archive__template_settings_form__event_list_config', $template_settings->EED_Events_Archive); |
|
831 | - $events_archive_settings = array( |
|
832 | - 'display_status_banner' => 0, |
|
833 | - 'display_description' => 1, |
|
834 | - 'display_ticket_selector' => 0, |
|
835 | - 'display_datetimes' => 1, |
|
836 | - 'display_venue' => 0, |
|
837 | - 'display_expired_events' => 0, |
|
838 | - ); |
|
839 | - $events_archive_settings = array_merge($events_archive_settings, (array)$template_settings->EED_Events_Archive); |
|
840 | - EEH_Template::display_template(EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php', $events_archive_settings); |
|
841 | - } |
|
842 | - |
|
843 | - |
|
844 | - |
|
845 | - /** |
|
846 | - * update_template_settings |
|
847 | - * |
|
848 | - * @access public |
|
849 | - * @param EE_Template_Config $CFG |
|
850 | - * @param EE_Request_Handler $REQ |
|
851 | - * @return EE_Template_Config |
|
852 | - */ |
|
853 | - public static function update_template_settings($CFG, $REQ) |
|
854 | - { |
|
855 | - $CFG->EED_Events_Archive = new EE_Events_Archive_Config(); |
|
856 | - // unless we are resetting the config... |
|
857 | - if (! isset($REQ['EED_Events_Archive_reset_event_list_settings']) || absint($REQ['EED_Events_Archive_reset_event_list_settings']) !== 1) { |
|
858 | - $CFG->EED_Events_Archive->display_status_banner = isset($REQ['EED_Events_Archive_display_status_banner']) ? absint($REQ['EED_Events_Archive_display_status_banner']) : 0; |
|
859 | - $CFG->EED_Events_Archive->display_description = isset($REQ['EED_Events_Archive_display_description']) ? absint($REQ['EED_Events_Archive_display_description']) : 1; |
|
860 | - $CFG->EED_Events_Archive->display_ticket_selector = isset($REQ['EED_Events_Archive_display_ticket_selector']) ? absint($REQ['EED_Events_Archive_display_ticket_selector']) : 0; |
|
861 | - $CFG->EED_Events_Archive->display_datetimes = isset($REQ['EED_Events_Archive_display_datetimes']) ? absint($REQ['EED_Events_Archive_display_datetimes']) : 1; |
|
862 | - $CFG->EED_Events_Archive->display_venue = isset($REQ['EED_Events_Archive_display_venue']) ? absint($REQ['EED_Events_Archive_display_venue']) : 0; |
|
863 | - $CFG->EED_Events_Archive->display_expired_events = isset($REQ['EED_Events_Archive_display_expired_events']) ? absint($REQ['EED_Events_Archive_display_expired_events']) : 0; |
|
864 | - } |
|
865 | - return $CFG; |
|
866 | - } |
|
867 | - |
|
868 | - |
|
869 | - |
|
870 | - /** |
|
871 | - * event_list_css |
|
872 | - * |
|
873 | - * @access public |
|
874 | - * @param string $extra_class |
|
875 | - * @return string |
|
876 | - */ |
|
877 | - public static function event_list_css($extra_class = '') |
|
878 | - { |
|
879 | - $event_list_css = ! empty($extra_class) ? array($extra_class) : array(); |
|
880 | - $event_list_css[] = 'espresso-event-list-event'; |
|
881 | - return implode(' ', $event_list_css); |
|
882 | - } |
|
883 | - |
|
884 | - |
|
885 | - |
|
886 | - /** |
|
887 | - * event_categories |
|
888 | - * |
|
889 | - * @access public |
|
890 | - * @return array |
|
891 | - */ |
|
892 | - public static function event_categories() |
|
893 | - { |
|
894 | - return EE_Registry::instance()->load_model('Term')->get_all_ee_categories(); |
|
895 | - } |
|
896 | - |
|
897 | - |
|
898 | - |
|
899 | - /** |
|
900 | - * display_description |
|
901 | - * |
|
902 | - * @access public |
|
903 | - * @param $value |
|
904 | - * @return bool |
|
905 | - */ |
|
906 | - public static function display_description($value) |
|
907 | - { |
|
908 | - $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
|
909 | - $display_description = isset($config->display_description) ? $config->display_description : 1; |
|
910 | - return $display_description === $value ? true : false; |
|
911 | - } |
|
912 | - |
|
913 | - |
|
914 | - |
|
915 | - /** |
|
916 | - * display_ticket_selector |
|
917 | - * |
|
918 | - * @access public |
|
919 | - * @return bool |
|
920 | - */ |
|
921 | - public static function display_ticket_selector() |
|
922 | - { |
|
923 | - $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
|
924 | - return isset($config->display_ticket_selector) && $config->display_ticket_selector ? true : false; |
|
925 | - } |
|
926 | - |
|
927 | - |
|
928 | - |
|
929 | - /** |
|
930 | - * display_venue |
|
931 | - * |
|
932 | - * @access public |
|
933 | - * @return bool |
|
934 | - */ |
|
935 | - public static function display_venue() |
|
936 | - { |
|
937 | - $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
|
938 | - return isset($config->display_venue) && $config->display_venue && EEH_Venue_View::venue_name() ? true : false; |
|
939 | - } |
|
940 | - |
|
941 | - |
|
942 | - |
|
943 | - /** |
|
944 | - * display_datetimes |
|
945 | - * |
|
946 | - * @access public |
|
947 | - * @return bool |
|
948 | - */ |
|
949 | - public static function display_datetimes() |
|
950 | - { |
|
951 | - $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
|
952 | - return isset($config->display_datetimes) && $config->display_datetimes ? true : false; |
|
953 | - } |
|
954 | - |
|
955 | - |
|
956 | - |
|
957 | - /** |
|
958 | - * event_list_title |
|
959 | - * |
|
960 | - * @access public |
|
961 | - * @return string |
|
962 | - */ |
|
963 | - public static function event_list_title() |
|
964 | - { |
|
965 | - return apply_filters('FHEE__archive_espresso_events_template__upcoming_events_h1', __('Upcoming Events', 'event_espresso')); |
|
966 | - } |
|
967 | - |
|
968 | - |
|
969 | - // GRAVEYARD |
|
970 | - |
|
971 | - |
|
972 | - |
|
973 | - /** |
|
974 | - * @since 4.4.0 |
|
975 | - */ |
|
976 | - public static function _doing_it_wrong_notice($function = '') |
|
977 | - { |
|
978 | - EE_Error::doing_it_wrong( |
|
979 | - __FUNCTION__, |
|
980 | - sprintf( |
|
981 | - __('EED_Events_Archive::%1$s was moved to EEH_Event_Query::%1$s:%2$sPlease update your existing code because the method it calls will be removed in version %3$s', 'event_espresso'), |
|
982 | - $function, |
|
983 | - '<br />', |
|
984 | - '4.6.0' |
|
985 | - ), |
|
986 | - '4.4.0' |
|
987 | - ); |
|
988 | - } |
|
989 | - |
|
990 | - |
|
991 | - |
|
992 | - /** |
|
993 | - * @deprecated |
|
994 | - * @since 4.4.0 |
|
995 | - */ |
|
996 | - public function get_post_data() |
|
997 | - { |
|
998 | - EEH_Event_Query::set_query_params(); |
|
999 | - } |
|
1000 | - |
|
1001 | - |
|
1002 | - |
|
1003 | - /** |
|
1004 | - * @deprecated |
|
1005 | - * @since 4.4.0 |
|
1006 | - */ |
|
1007 | - public function posts_fields($SQL, WP_Query $wp_query) |
|
1008 | - { |
|
1009 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1010 | - return EEH_Event_Query::posts_fields($SQL, $wp_query); |
|
1011 | - } |
|
23 | + const EVENT_DETAILS_PRIORITY = 100; |
|
24 | + |
|
25 | + const EVENT_DATETIMES_PRIORITY = 110; |
|
26 | + |
|
27 | + const EVENT_TICKETS_PRIORITY = 120; |
|
28 | + |
|
29 | + const EVENT_VENUES_PRIORITY = 130; |
|
30 | + |
|
31 | + |
|
32 | + public static $espresso_event_list_ID = 0; |
|
33 | + |
|
34 | + public static $espresso_grid_event_lists = array(); |
|
35 | + |
|
36 | + /** |
|
37 | + * @type bool $using_get_the_excerpt |
|
38 | + */ |
|
39 | + protected static $using_get_the_excerpt = false; |
|
40 | + |
|
41 | + /** |
|
42 | + * Used to flag when the event list is being called from an external iframe. |
|
43 | + * |
|
44 | + * @var bool $iframe |
|
45 | + */ |
|
46 | + protected static $iframe = false; |
|
47 | + |
|
48 | + /** |
|
49 | + * @var \EventEspresso\core\libraries\iframe_display\EventListIframeEmbedButton $_iframe_embed_button |
|
50 | + */ |
|
51 | + private static $_iframe_embed_button; |
|
52 | + |
|
53 | + /** |
|
54 | + * @type EE_Template_Part_Manager $template_parts |
|
55 | + */ |
|
56 | + protected $template_parts; |
|
57 | + |
|
58 | + |
|
59 | + |
|
60 | + /** |
|
61 | + * @return EED_Events_Archive |
|
62 | + */ |
|
63 | + public static function instance() |
|
64 | + { |
|
65 | + return parent::get_instance(__CLASS__); |
|
66 | + } |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
71 | + * |
|
72 | + * @return void |
|
73 | + * @throws InvalidArgumentException |
|
74 | + * @throws InvalidDataTypeException |
|
75 | + * @throws InvalidInterfaceException |
|
76 | + */ |
|
77 | + public static function set_hooks() |
|
78 | + { |
|
79 | + /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */ |
|
80 | + $custom_post_type_definitions = LoaderFactory::getLoader()->getShared( |
|
81 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
82 | + ); |
|
83 | + $custom_post_types = $custom_post_type_definitions->getDefinitions(); |
|
84 | + EE_Config::register_route( |
|
85 | + $custom_post_types['espresso_events']['plural_slug'], |
|
86 | + 'Events_Archive', |
|
87 | + 'run' |
|
88 | + ); |
|
89 | + EE_Config::register_route( |
|
90 | + 'event_list', |
|
91 | + 'Events_Archive', |
|
92 | + 'event_list' |
|
93 | + ); |
|
94 | + EE_Config::register_route( |
|
95 | + 'iframe', |
|
96 | + 'Events_Archive', |
|
97 | + 'event_list_iframe', |
|
98 | + 'event_list' |
|
99 | + ); |
|
100 | + add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2); |
|
101 | + } |
|
102 | + |
|
103 | + |
|
104 | + |
|
105 | + /** |
|
106 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
107 | + * |
|
108 | + * @access public |
|
109 | + * @return void |
|
110 | + */ |
|
111 | + public static function set_hooks_admin() |
|
112 | + { |
|
113 | + add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2); |
|
114 | + // hook into the end of the \EE_Admin_Page::_load_page_dependencies() |
|
115 | + // to load assets for "espresso_events" page on the "default" route (action) |
|
116 | + add_action( |
|
117 | + 'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__default', |
|
118 | + array('EED_Events_Archive', 'event_list_iframe_embed_button'), |
|
119 | + 10 |
|
120 | + ); |
|
121 | + } |
|
122 | + |
|
123 | + |
|
124 | + |
|
125 | + /** |
|
126 | + * set_definitions |
|
127 | + * |
|
128 | + * @access public |
|
129 | + * @return void |
|
130 | + */ |
|
131 | + public static function set_definitions() |
|
132 | + { |
|
133 | + define('EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS); |
|
134 | + define('EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)) . 'templates' . DS); |
|
135 | + } |
|
136 | + |
|
137 | + |
|
138 | + |
|
139 | + /** |
|
140 | + * set up EE_Events_Archive_Config |
|
141 | + */ |
|
142 | + protected function set_config() |
|
143 | + { |
|
144 | + $this->set_config_section('template_settings'); |
|
145 | + $this->set_config_class('EE_Events_Archive_Config'); |
|
146 | + $this->set_config_name('EED_Events_Archive'); |
|
147 | + } |
|
148 | + |
|
149 | + |
|
150 | + |
|
151 | + /** |
|
152 | + * @return EventListIframeEmbedButton |
|
153 | + */ |
|
154 | + public static function get_iframe_embed_button() |
|
155 | + { |
|
156 | + if (! self::$_iframe_embed_button instanceof EventListIframeEmbedButton) { |
|
157 | + self::$_iframe_embed_button = new EventListIframeEmbedButton(); |
|
158 | + } |
|
159 | + return self::$_iframe_embed_button; |
|
160 | + } |
|
161 | + |
|
162 | + |
|
163 | + |
|
164 | + /** |
|
165 | + * event_list_iframe_embed_button |
|
166 | + * |
|
167 | + * @return void |
|
168 | + * @throws \EE_Error |
|
169 | + */ |
|
170 | + public static function event_list_iframe_embed_button() |
|
171 | + { |
|
172 | + $iframe_embed_button = \EED_Events_Archive::get_iframe_embed_button(); |
|
173 | + $iframe_embed_button->addEmbedButton(); |
|
174 | + } |
|
175 | + |
|
176 | + |
|
177 | + |
|
178 | + /** |
|
179 | + * initialize_template_parts |
|
180 | + * |
|
181 | + * @access public |
|
182 | + * @param \EE_Events_Archive_Config $config |
|
183 | + * @return \EE_Template_Part_Manager |
|
184 | + */ |
|
185 | + public function initialize_template_parts(EE_Events_Archive_Config $config = null) |
|
186 | + { |
|
187 | + $config = $config instanceof EE_Events_Archive_Config ? $config : $this->config(); |
|
188 | + EEH_Autoloader::instance()->register_template_part_autoloaders(); |
|
189 | + $template_parts = new EE_Template_Part_Manager(); |
|
190 | + $template_parts->add_template_part( |
|
191 | + 'tickets', |
|
192 | + __('Ticket Selector', 'event_espresso'), |
|
193 | + 'content-espresso_events-tickets.php', |
|
194 | + $config->display_order_tickets |
|
195 | + ); |
|
196 | + $template_parts->add_template_part( |
|
197 | + 'datetimes', |
|
198 | + __('Dates and Times', 'event_espresso'), |
|
199 | + 'content-espresso_events-datetimes.php', |
|
200 | + $config->display_order_datetimes |
|
201 | + ); |
|
202 | + $template_parts->add_template_part( |
|
203 | + 'event', |
|
204 | + __('Event Description', 'event_espresso'), |
|
205 | + 'content-espresso_events-details.php', |
|
206 | + $config->display_order_event |
|
207 | + ); |
|
208 | + $template_parts->add_template_part( |
|
209 | + 'venue', |
|
210 | + __('Venue Information', 'event_espresso'), |
|
211 | + 'content-espresso_events-venues.php', |
|
212 | + $config->display_order_venue |
|
213 | + ); |
|
214 | + do_action('AHEE__EED_Event_Archive__initialize_template_parts', $template_parts); |
|
215 | + return $template_parts; |
|
216 | + } |
|
217 | + |
|
218 | + |
|
219 | + |
|
220 | + /** |
|
221 | + * run - initial module setup - this gets called by the EE_Front_Controller if the module route is found in the incoming request |
|
222 | + * |
|
223 | + * @access public |
|
224 | + * @param WP $WP |
|
225 | + * @return void |
|
226 | + */ |
|
227 | + public function run($WP) |
|
228 | + { |
|
229 | + do_action('AHEE__EED_Events_Archive__before_run'); |
|
230 | + // ensure valid EE_Events_Archive_Config() object exists |
|
231 | + $this->set_config(); |
|
232 | + /** @type EE_Events_Archive_Config $config */ |
|
233 | + $config = $this->config(); |
|
234 | + // load other required components |
|
235 | + $this->load_event_list_assets(); |
|
236 | + // filter the WP posts_join, posts_where, and posts_orderby SQL clauses |
|
237 | + //add query filters |
|
238 | + EEH_Event_Query::add_query_filters(); |
|
239 | + // set params that will get used by the filters |
|
240 | + EEH_Event_Query::set_query_params( |
|
241 | + '', // month |
|
242 | + '', // category |
|
243 | + $config->display_expired_events, // show_expired |
|
244 | + 'start_date', // orderby |
|
245 | + 'ASC' // sort |
|
246 | + ); |
|
247 | + // check what template is loaded |
|
248 | + add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
249 | + } |
|
250 | + |
|
251 | + |
|
252 | + |
|
253 | + /** |
|
254 | + * most likely called by the ESPRESSO_EVENTS shortcode which uses this module to do some of it's lifting |
|
255 | + * |
|
256 | + * @return void |
|
257 | + */ |
|
258 | + public function event_list() |
|
259 | + { |
|
260 | + // ensure valid EE_Events_Archive_Config() object exists |
|
261 | + $this->set_config(); |
|
262 | + // load other required components |
|
263 | + $this->load_event_list_assets(); |
|
264 | + } |
|
265 | + |
|
266 | + |
|
267 | + |
|
268 | + /** |
|
269 | + * @access public |
|
270 | + * @return void |
|
271 | + * @throws \EE_Error |
|
272 | + * @throws \DomainException |
|
273 | + */ |
|
274 | + public function event_list_iframe() |
|
275 | + { |
|
276 | + \EED_Events_Archive::$iframe = true; |
|
277 | + $event_list_iframe = new EventsArchiveIframe($this); |
|
278 | + $event_list_iframe->display(); |
|
279 | + } |
|
280 | + |
|
281 | + |
|
282 | + |
|
283 | + /** |
|
284 | + * @access public |
|
285 | + * @return string |
|
286 | + */ |
|
287 | + public static function is_iframe() |
|
288 | + { |
|
289 | + return \EED_Events_Archive::$iframe; |
|
290 | + } |
|
291 | + |
|
292 | + |
|
293 | + |
|
294 | + /** |
|
295 | + * @access public |
|
296 | + * @return string |
|
297 | + */ |
|
298 | + public static function link_target() |
|
299 | + { |
|
300 | + return \EED_Events_Archive::$iframe ? ' target="_blank"' : ''; |
|
301 | + } |
|
302 | + |
|
303 | + |
|
304 | + |
|
305 | + /** |
|
306 | + * template_include |
|
307 | + * |
|
308 | + * @access public |
|
309 | + * @param string $template |
|
310 | + * @return string |
|
311 | + */ |
|
312 | + public function template_include($template = '') |
|
313 | + { |
|
314 | + // don't add content filter for dedicated EE child themes or private posts |
|
315 | + if (! EEH_Template::is_espresso_theme()) { |
|
316 | + /** @type EE_Events_Archive_Config $config */ |
|
317 | + $config = $this->config(); |
|
318 | + // add status banner ? |
|
319 | + if ($config->display_status_banner) { |
|
320 | + add_filter('the_title', array('EED_Events_Archive', 'the_title'), 100, 2); |
|
321 | + } |
|
322 | + // if NOT a custom template |
|
323 | + if ( |
|
324 | + apply_filters('FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', false) |
|
325 | + || EE_Registry::instance() |
|
326 | + ->load_core('Front_Controller') |
|
327 | + ->get_selected_template() !== 'archive-espresso_events.php' |
|
328 | + ) { |
|
329 | + // don't display entry meta because the existing theme will take care of that |
|
330 | + add_filter('FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true'); |
|
331 | + // load functions.php file for the theme (loaded by WP if using child theme) |
|
332 | + EEH_Template::load_espresso_theme_functions(); |
|
333 | + // because we don't know if the theme is using the_excerpt() |
|
334 | + add_filter( |
|
335 | + 'the_excerpt', |
|
336 | + array('EED_Events_Archive', 'event_details'), |
|
337 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
338 | + ); |
|
339 | + // or the_content |
|
340 | + add_filter( |
|
341 | + 'the_content', |
|
342 | + array('EED_Events_Archive', 'event_details'), |
|
343 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
344 | + ); |
|
345 | + // and just in case they are running get_the_excerpt() which DESTROYS things |
|
346 | + add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1); |
|
347 | + // don't display entry meta because the existing theme will take care of that |
|
348 | + add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false'); |
|
349 | + } |
|
350 | + } |
|
351 | + return $template; |
|
352 | + } |
|
353 | + |
|
354 | + |
|
355 | + |
|
356 | + /** |
|
357 | + * get_the_excerpt - kinda hacky, but if a theme is using get_the_excerpt(), then we need to remove our filters on the_content() |
|
358 | + * |
|
359 | + * @access public |
|
360 | + * @param string $excerpt |
|
361 | + * @return string |
|
362 | + */ |
|
363 | + public static function get_the_excerpt($excerpt = '') |
|
364 | + { |
|
365 | + if (post_password_required()) { |
|
366 | + return $excerpt; |
|
367 | + } |
|
368 | + if (apply_filters('FHEE__EED_Events_Archive__get_the_excerpt__theme_uses_get_the_excerpt', false)) { |
|
369 | + remove_filter( |
|
370 | + 'the_excerpt', |
|
371 | + array('EED_Events_Archive', 'event_details'), |
|
372 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
373 | + ); |
|
374 | + remove_filter( |
|
375 | + 'the_content', |
|
376 | + array('EED_Events_Archive', 'event_details'), |
|
377 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
378 | + ); |
|
379 | + $excerpt = EED_Events_Archive::event_details($excerpt); |
|
380 | + } else { |
|
381 | + EED_Events_Archive::$using_get_the_excerpt = true; |
|
382 | + add_filter('wp_trim_excerpt', array('EED_Events_Archive', 'end_get_the_excerpt'), 999, 1); |
|
383 | + } |
|
384 | + return $excerpt; |
|
385 | + } |
|
386 | + |
|
387 | + |
|
388 | + |
|
389 | + /** |
|
390 | + * end_get_the_excerpt |
|
391 | + * |
|
392 | + * @access public |
|
393 | + * @param string $text |
|
394 | + * @return string |
|
395 | + */ |
|
396 | + public static function end_get_the_excerpt($text = '') |
|
397 | + { |
|
398 | + EED_Events_Archive::$using_get_the_excerpt = false; |
|
399 | + return $text; |
|
400 | + } |
|
401 | + |
|
402 | + |
|
403 | + |
|
404 | + /** |
|
405 | + * the_title |
|
406 | + * |
|
407 | + * @access public |
|
408 | + * @param string $title |
|
409 | + * @param string $id |
|
410 | + * @return string |
|
411 | + */ |
|
412 | + public static function the_title($title = '', $id = '') |
|
413 | + { |
|
414 | + global $post; |
|
415 | + if ($post instanceof WP_Post) { |
|
416 | + return in_the_loop() && $post->ID == $id ? espresso_event_status_banner($post->ID) . $title : $title; |
|
417 | + } |
|
418 | + return $title; |
|
419 | + } |
|
420 | + |
|
421 | + |
|
422 | + |
|
423 | + /** |
|
424 | + * event_details |
|
425 | + * |
|
426 | + * @access public |
|
427 | + * @param string $content |
|
428 | + * @return string |
|
429 | + */ |
|
430 | + public static function event_details($content) |
|
431 | + { |
|
432 | + global $post; |
|
433 | + static $current_post_ID = 0; |
|
434 | + if ( |
|
435 | + $current_post_ID !== $post->ID |
|
436 | + && $post->post_type === 'espresso_events' |
|
437 | + && ! EED_Events_Archive::$using_get_the_excerpt |
|
438 | + && ! post_password_required() |
|
439 | + && ( |
|
440 | + apply_filters('FHEE__EES_Espresso_Events__process_shortcode__true', false) |
|
441 | + || ! apply_filters('FHEE__content_espresso_events__template_loaded', false) |
|
442 | + ) |
|
443 | + ) { |
|
444 | + // Set current post ID to prevent showing content twice, but only if headers have definitely been sent. |
|
445 | + // Reason being is that some plugins, like Yoast, need to run through a copy of the loop early |
|
446 | + // BEFORE headers are sent in order to examine the post content and generate content for the HTML header. |
|
447 | + // We want to allow those plugins to still do their thing and have access to our content, but depending on |
|
448 | + // how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice, |
|
449 | + // so the following allows this filter to be applied multiple times, but only once for real |
|
450 | + $current_post_ID = did_action('loop_start') ? $post->ID : 0; |
|
451 | + if (EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->use_sortable_display_order) { |
|
452 | + $content = \EED_Events_Archive::use_sortable_display_order(); |
|
453 | + } else { |
|
454 | + $content = \EED_Events_Archive::use_filterable_display_order(); |
|
455 | + } |
|
456 | + } |
|
457 | + return $content; |
|
458 | + } |
|
459 | + |
|
460 | + |
|
461 | + |
|
462 | + /** |
|
463 | + * use_sortable_display_order |
|
464 | + * |
|
465 | + * @access protected |
|
466 | + * @return string |
|
467 | + */ |
|
468 | + protected static function use_sortable_display_order() |
|
469 | + { |
|
470 | + // no further password checks required atm |
|
471 | + add_filter('FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true'); |
|
472 | + // we need to first remove this callback from being applied to the_content() or the_excerpt() |
|
473 | + // (otherwise it will recurse and blow up the interweb) |
|
474 | + remove_filter( |
|
475 | + 'the_excerpt', |
|
476 | + array('EED_Events_Archive', 'event_details'), |
|
477 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
478 | + ); |
|
479 | + remove_filter( |
|
480 | + 'the_content', |
|
481 | + array('EED_Events_Archive', 'event_details'), |
|
482 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
483 | + ); |
|
484 | + remove_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1); |
|
485 | + // now add additional content depending on whether event is using the_excerpt() or the_content() |
|
486 | + EED_Events_Archive::instance()->template_parts = EED_Events_Archive::instance()->initialize_template_parts(); |
|
487 | + $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
488 | + $content = EED_Events_Archive::instance()->template_parts->apply_template_part_filters($content); |
|
489 | + // re-add our main filters (or else the next event won't have them) |
|
490 | + add_filter( |
|
491 | + 'the_excerpt', |
|
492 | + array('EED_Events_Archive', 'event_details'), |
|
493 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
494 | + ); |
|
495 | + add_filter( |
|
496 | + 'the_content', |
|
497 | + array('EED_Events_Archive', 'event_details'), |
|
498 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
499 | + ); |
|
500 | + add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1); |
|
501 | + remove_filter( |
|
502 | + 'FHEE__EED_Events_Archive__event_details__no_post_password_required', |
|
503 | + '__return_true' |
|
504 | + ); |
|
505 | + return $content; |
|
506 | + } |
|
507 | + |
|
508 | + |
|
509 | + |
|
510 | + /** |
|
511 | + * use_filterable_display_order |
|
512 | + * |
|
513 | + * @access protected |
|
514 | + * @return string |
|
515 | + */ |
|
516 | + protected static function use_filterable_display_order() |
|
517 | + { |
|
518 | + // we need to first remove this callback from being applied to the_content() |
|
519 | + // (otherwise it will recurse and blow up the interweb) |
|
520 | + remove_filter( |
|
521 | + 'the_excerpt', |
|
522 | + array('EED_Events_Archive', 'event_details'), |
|
523 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
524 | + ); |
|
525 | + remove_filter( |
|
526 | + 'the_content', |
|
527 | + array('EED_Events_Archive', 'event_details'), |
|
528 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
529 | + ); |
|
530 | + remove_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1); |
|
531 | + //now add additional content depending on whether event is using the_excerpt() or the_content() |
|
532 | + EED_Events_Archive::_add_additional_excerpt_filters(); |
|
533 | + EED_Events_Archive::_add_additional_content_filters(); |
|
534 | + do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_add_filters'); |
|
535 | + // now load our template |
|
536 | + $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
537 | + // re-add our main filters (or else the next event won't have them) |
|
538 | + add_filter( |
|
539 | + 'the_excerpt', |
|
540 | + array('EED_Events_Archive', 'event_details'), |
|
541 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
542 | + ); |
|
543 | + add_filter( |
|
544 | + 'the_content', |
|
545 | + array('EED_Events_Archive', 'event_details'), |
|
546 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
547 | + ); |
|
548 | + add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1); |
|
549 | + // but remove the other filters so that they don't get applied to the next post |
|
550 | + EED_Events_Archive::_remove_additional_events_archive_filters(); |
|
551 | + do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_remove_filters'); |
|
552 | + // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
|
553 | + //return ! empty( $template ) ? $template : $content; |
|
554 | + return $content; |
|
555 | + } |
|
556 | + |
|
557 | + |
|
558 | + |
|
559 | + /** |
|
560 | + * event_datetimes - adds datetimes ABOVE content |
|
561 | + * |
|
562 | + * @access public |
|
563 | + * @param string $content |
|
564 | + * @return string |
|
565 | + */ |
|
566 | + public static function event_datetimes($content) |
|
567 | + { |
|
568 | + if (post_password_required()) { |
|
569 | + return $content; |
|
570 | + } |
|
571 | + return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content; |
|
572 | + } |
|
573 | + |
|
574 | + |
|
575 | + |
|
576 | + /** |
|
577 | + * event_tickets - adds tickets ABOVE content (which includes datetimes) |
|
578 | + * |
|
579 | + * @access public |
|
580 | + * @param string $content |
|
581 | + * @return string |
|
582 | + */ |
|
583 | + public static function event_tickets($content) |
|
584 | + { |
|
585 | + if (post_password_required()) { |
|
586 | + return $content; |
|
587 | + } |
|
588 | + return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content; |
|
589 | + } |
|
590 | + |
|
591 | + |
|
592 | + |
|
593 | + /** |
|
594 | + * event_venues - adds venues BELOW content |
|
595 | + * |
|
596 | + * @access public |
|
597 | + * @param string $content |
|
598 | + * @return string |
|
599 | + */ |
|
600 | + public static function event_venue($content) |
|
601 | + { |
|
602 | + return EED_Events_Archive::event_venues($content); |
|
603 | + } |
|
604 | + |
|
605 | + |
|
606 | + |
|
607 | + /** |
|
608 | + * event_venues - adds venues BELOW content |
|
609 | + * |
|
610 | + * @access public |
|
611 | + * @param string $content |
|
612 | + * @return string |
|
613 | + */ |
|
614 | + public static function event_venues($content) |
|
615 | + { |
|
616 | + if (post_password_required()) { |
|
617 | + return $content; |
|
618 | + } |
|
619 | + return $content . EEH_Template::locate_template('content-espresso_events-venues.php'); |
|
620 | + } |
|
621 | + |
|
622 | + |
|
623 | + |
|
624 | + /** |
|
625 | + * _add_additional_content_filters |
|
626 | + * |
|
627 | + * @access private |
|
628 | + * @return void |
|
629 | + */ |
|
630 | + private static function _add_additional_excerpt_filters() |
|
631 | + { |
|
632 | + add_filter( |
|
633 | + 'the_excerpt', |
|
634 | + array('EED_Events_Archive', 'event_datetimes'), |
|
635 | + EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
636 | + ); |
|
637 | + add_filter( |
|
638 | + 'the_excerpt', |
|
639 | + array('EED_Events_Archive', 'event_tickets'), |
|
640 | + EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
641 | + ); |
|
642 | + add_filter( |
|
643 | + 'the_excerpt', |
|
644 | + array('EED_Events_Archive', 'event_venues'), |
|
645 | + EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
646 | + ); |
|
647 | + } |
|
648 | + |
|
649 | + |
|
650 | + |
|
651 | + /** |
|
652 | + * _add_additional_content_filters |
|
653 | + * |
|
654 | + * @access private |
|
655 | + * @return void |
|
656 | + */ |
|
657 | + private static function _add_additional_content_filters() |
|
658 | + { |
|
659 | + add_filter( |
|
660 | + 'the_content', |
|
661 | + array('EED_Events_Archive', 'event_datetimes'), |
|
662 | + EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
663 | + ); |
|
664 | + add_filter( |
|
665 | + 'the_content', |
|
666 | + array('EED_Events_Archive', 'event_tickets'), |
|
667 | + EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
668 | + ); |
|
669 | + add_filter( |
|
670 | + 'the_content', |
|
671 | + array('EED_Events_Archive', 'event_venues'), |
|
672 | + EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
673 | + ); |
|
674 | + } |
|
675 | + |
|
676 | + |
|
677 | + |
|
678 | + /** |
|
679 | + * _remove_additional_events_archive_filters |
|
680 | + * |
|
681 | + * @access private |
|
682 | + * @return void |
|
683 | + */ |
|
684 | + private static function _remove_additional_events_archive_filters() |
|
685 | + { |
|
686 | + remove_filter( |
|
687 | + 'the_excerpt', |
|
688 | + array('EED_Events_Archive', 'event_datetimes'), |
|
689 | + EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
690 | + ); |
|
691 | + remove_filter( |
|
692 | + 'the_excerpt', |
|
693 | + array('EED_Events_Archive', 'event_tickets'), |
|
694 | + EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
695 | + ); |
|
696 | + remove_filter( |
|
697 | + 'the_excerpt', |
|
698 | + array('EED_Events_Archive', 'event_venues'), |
|
699 | + EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
700 | + ); |
|
701 | + remove_filter( |
|
702 | + 'the_content', |
|
703 | + array('EED_Events_Archive', 'event_datetimes'), |
|
704 | + EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
705 | + ); |
|
706 | + remove_filter( |
|
707 | + 'the_content', |
|
708 | + array('EED_Events_Archive', 'event_tickets'), |
|
709 | + EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
710 | + ); |
|
711 | + remove_filter( |
|
712 | + 'the_content', |
|
713 | + array('EED_Events_Archive', 'event_venues'), |
|
714 | + EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
715 | + ); |
|
716 | + } |
|
717 | + |
|
718 | + |
|
719 | + |
|
720 | + /** |
|
721 | + * remove_all_events_archive_filters |
|
722 | + * |
|
723 | + * @access public |
|
724 | + * @return void |
|
725 | + */ |
|
726 | + public static function remove_all_events_archive_filters() |
|
727 | + { |
|
728 | + //remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 ); |
|
729 | + remove_filter('the_title', array('EED_Events_Archive', 'the_title'), 1); |
|
730 | + remove_filter( |
|
731 | + 'the_excerpt', |
|
732 | + array('EED_Events_Archive', 'event_details'), |
|
733 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
734 | + ); |
|
735 | + remove_filter( |
|
736 | + 'the_excerpt', |
|
737 | + array('EED_Events_Archive', 'event_datetimes'), |
|
738 | + EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
739 | + ); |
|
740 | + remove_filter( |
|
741 | + 'the_excerpt', |
|
742 | + array('EED_Events_Archive', 'event_tickets'), |
|
743 | + EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
744 | + ); |
|
745 | + remove_filter( |
|
746 | + 'the_excerpt', |
|
747 | + array('EED_Events_Archive', 'event_venues'), |
|
748 | + EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
749 | + ); |
|
750 | + remove_filter( |
|
751 | + 'the_content', |
|
752 | + array('EED_Events_Archive', 'event_details'), |
|
753 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
754 | + ); |
|
755 | + remove_filter( |
|
756 | + 'the_content', |
|
757 | + array('EED_Events_Archive', 'event_datetimes'), |
|
758 | + EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
759 | + ); |
|
760 | + remove_filter( |
|
761 | + 'the_content', |
|
762 | + array('EED_Events_Archive', 'event_tickets'), |
|
763 | + EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
764 | + ); |
|
765 | + remove_filter( |
|
766 | + 'the_content', |
|
767 | + array('EED_Events_Archive', 'event_venues'), |
|
768 | + EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
769 | + ); |
|
770 | + // don't display entry meta because the existing theme will take care of that |
|
771 | + remove_filter( |
|
772 | + 'FHEE__content_espresso_events_details_template__display_entry_meta', |
|
773 | + '__return_false' |
|
774 | + ); |
|
775 | + } |
|
776 | + |
|
777 | + |
|
778 | + |
|
779 | + /** |
|
780 | + * load_event_list_assets |
|
781 | + * |
|
782 | + * @access public |
|
783 | + * @return void |
|
784 | + */ |
|
785 | + public function load_event_list_assets() |
|
786 | + { |
|
787 | + do_action('AHEE__EED_Events_Archive__before_load_assets'); |
|
788 | + add_filter('FHEE_load_EE_Session', '__return_true'); |
|
789 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
790 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
791 | + if (EE_Registry::instance()->CFG->map_settings->use_google_maps) { |
|
792 | + add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11); |
|
793 | + } |
|
794 | + } |
|
795 | + |
|
796 | + |
|
797 | + |
|
798 | + /** |
|
799 | + * wp_enqueue_scripts |
|
800 | + * |
|
801 | + * @access public |
|
802 | + * @return void |
|
803 | + */ |
|
804 | + public function wp_enqueue_scripts() |
|
805 | + { |
|
806 | + // get some style |
|
807 | + if (apply_filters('FHEE_enable_default_espresso_css', false)) { |
|
808 | + // first check uploads folder |
|
809 | + if (EEH_File::is_readable(get_stylesheet_directory() . $this->theme . DS . 'style.css')) { |
|
810 | + wp_register_style($this->theme, get_stylesheet_directory_uri() . $this->theme . DS . 'style.css', array('dashicons', 'espresso_default')); |
|
811 | + } else { |
|
812 | + } |
|
813 | + wp_enqueue_style($this->theme); |
|
814 | + } |
|
815 | + } |
|
816 | + |
|
817 | + |
|
818 | + |
|
819 | + /** |
|
820 | + * template_settings_form |
|
821 | + * |
|
822 | + * @access public |
|
823 | + * @static |
|
824 | + * @return string |
|
825 | + */ |
|
826 | + public static function template_settings_form() |
|
827 | + { |
|
828 | + $template_settings = EE_Registry::instance()->CFG->template_settings; |
|
829 | + $template_settings->EED_Events_Archive = isset($template_settings->EED_Events_Archive) ? $template_settings->EED_Events_Archive : new EE_Events_Archive_Config(); |
|
830 | + $template_settings->EED_Events_Archive = apply_filters('FHEE__EED_Events_Archive__template_settings_form__event_list_config', $template_settings->EED_Events_Archive); |
|
831 | + $events_archive_settings = array( |
|
832 | + 'display_status_banner' => 0, |
|
833 | + 'display_description' => 1, |
|
834 | + 'display_ticket_selector' => 0, |
|
835 | + 'display_datetimes' => 1, |
|
836 | + 'display_venue' => 0, |
|
837 | + 'display_expired_events' => 0, |
|
838 | + ); |
|
839 | + $events_archive_settings = array_merge($events_archive_settings, (array)$template_settings->EED_Events_Archive); |
|
840 | + EEH_Template::display_template(EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php', $events_archive_settings); |
|
841 | + } |
|
842 | + |
|
843 | + |
|
844 | + |
|
845 | + /** |
|
846 | + * update_template_settings |
|
847 | + * |
|
848 | + * @access public |
|
849 | + * @param EE_Template_Config $CFG |
|
850 | + * @param EE_Request_Handler $REQ |
|
851 | + * @return EE_Template_Config |
|
852 | + */ |
|
853 | + public static function update_template_settings($CFG, $REQ) |
|
854 | + { |
|
855 | + $CFG->EED_Events_Archive = new EE_Events_Archive_Config(); |
|
856 | + // unless we are resetting the config... |
|
857 | + if (! isset($REQ['EED_Events_Archive_reset_event_list_settings']) || absint($REQ['EED_Events_Archive_reset_event_list_settings']) !== 1) { |
|
858 | + $CFG->EED_Events_Archive->display_status_banner = isset($REQ['EED_Events_Archive_display_status_banner']) ? absint($REQ['EED_Events_Archive_display_status_banner']) : 0; |
|
859 | + $CFG->EED_Events_Archive->display_description = isset($REQ['EED_Events_Archive_display_description']) ? absint($REQ['EED_Events_Archive_display_description']) : 1; |
|
860 | + $CFG->EED_Events_Archive->display_ticket_selector = isset($REQ['EED_Events_Archive_display_ticket_selector']) ? absint($REQ['EED_Events_Archive_display_ticket_selector']) : 0; |
|
861 | + $CFG->EED_Events_Archive->display_datetimes = isset($REQ['EED_Events_Archive_display_datetimes']) ? absint($REQ['EED_Events_Archive_display_datetimes']) : 1; |
|
862 | + $CFG->EED_Events_Archive->display_venue = isset($REQ['EED_Events_Archive_display_venue']) ? absint($REQ['EED_Events_Archive_display_venue']) : 0; |
|
863 | + $CFG->EED_Events_Archive->display_expired_events = isset($REQ['EED_Events_Archive_display_expired_events']) ? absint($REQ['EED_Events_Archive_display_expired_events']) : 0; |
|
864 | + } |
|
865 | + return $CFG; |
|
866 | + } |
|
867 | + |
|
868 | + |
|
869 | + |
|
870 | + /** |
|
871 | + * event_list_css |
|
872 | + * |
|
873 | + * @access public |
|
874 | + * @param string $extra_class |
|
875 | + * @return string |
|
876 | + */ |
|
877 | + public static function event_list_css($extra_class = '') |
|
878 | + { |
|
879 | + $event_list_css = ! empty($extra_class) ? array($extra_class) : array(); |
|
880 | + $event_list_css[] = 'espresso-event-list-event'; |
|
881 | + return implode(' ', $event_list_css); |
|
882 | + } |
|
883 | + |
|
884 | + |
|
885 | + |
|
886 | + /** |
|
887 | + * event_categories |
|
888 | + * |
|
889 | + * @access public |
|
890 | + * @return array |
|
891 | + */ |
|
892 | + public static function event_categories() |
|
893 | + { |
|
894 | + return EE_Registry::instance()->load_model('Term')->get_all_ee_categories(); |
|
895 | + } |
|
896 | + |
|
897 | + |
|
898 | + |
|
899 | + /** |
|
900 | + * display_description |
|
901 | + * |
|
902 | + * @access public |
|
903 | + * @param $value |
|
904 | + * @return bool |
|
905 | + */ |
|
906 | + public static function display_description($value) |
|
907 | + { |
|
908 | + $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
|
909 | + $display_description = isset($config->display_description) ? $config->display_description : 1; |
|
910 | + return $display_description === $value ? true : false; |
|
911 | + } |
|
912 | + |
|
913 | + |
|
914 | + |
|
915 | + /** |
|
916 | + * display_ticket_selector |
|
917 | + * |
|
918 | + * @access public |
|
919 | + * @return bool |
|
920 | + */ |
|
921 | + public static function display_ticket_selector() |
|
922 | + { |
|
923 | + $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
|
924 | + return isset($config->display_ticket_selector) && $config->display_ticket_selector ? true : false; |
|
925 | + } |
|
926 | + |
|
927 | + |
|
928 | + |
|
929 | + /** |
|
930 | + * display_venue |
|
931 | + * |
|
932 | + * @access public |
|
933 | + * @return bool |
|
934 | + */ |
|
935 | + public static function display_venue() |
|
936 | + { |
|
937 | + $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
|
938 | + return isset($config->display_venue) && $config->display_venue && EEH_Venue_View::venue_name() ? true : false; |
|
939 | + } |
|
940 | + |
|
941 | + |
|
942 | + |
|
943 | + /** |
|
944 | + * display_datetimes |
|
945 | + * |
|
946 | + * @access public |
|
947 | + * @return bool |
|
948 | + */ |
|
949 | + public static function display_datetimes() |
|
950 | + { |
|
951 | + $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
|
952 | + return isset($config->display_datetimes) && $config->display_datetimes ? true : false; |
|
953 | + } |
|
954 | + |
|
955 | + |
|
956 | + |
|
957 | + /** |
|
958 | + * event_list_title |
|
959 | + * |
|
960 | + * @access public |
|
961 | + * @return string |
|
962 | + */ |
|
963 | + public static function event_list_title() |
|
964 | + { |
|
965 | + return apply_filters('FHEE__archive_espresso_events_template__upcoming_events_h1', __('Upcoming Events', 'event_espresso')); |
|
966 | + } |
|
967 | + |
|
968 | + |
|
969 | + // GRAVEYARD |
|
970 | + |
|
971 | + |
|
972 | + |
|
973 | + /** |
|
974 | + * @since 4.4.0 |
|
975 | + */ |
|
976 | + public static function _doing_it_wrong_notice($function = '') |
|
977 | + { |
|
978 | + EE_Error::doing_it_wrong( |
|
979 | + __FUNCTION__, |
|
980 | + sprintf( |
|
981 | + __('EED_Events_Archive::%1$s was moved to EEH_Event_Query::%1$s:%2$sPlease update your existing code because the method it calls will be removed in version %3$s', 'event_espresso'), |
|
982 | + $function, |
|
983 | + '<br />', |
|
984 | + '4.6.0' |
|
985 | + ), |
|
986 | + '4.4.0' |
|
987 | + ); |
|
988 | + } |
|
989 | + |
|
990 | + |
|
991 | + |
|
992 | + /** |
|
993 | + * @deprecated |
|
994 | + * @since 4.4.0 |
|
995 | + */ |
|
996 | + public function get_post_data() |
|
997 | + { |
|
998 | + EEH_Event_Query::set_query_params(); |
|
999 | + } |
|
1000 | + |
|
1001 | + |
|
1002 | + |
|
1003 | + /** |
|
1004 | + * @deprecated |
|
1005 | + * @since 4.4.0 |
|
1006 | + */ |
|
1007 | + public function posts_fields($SQL, WP_Query $wp_query) |
|
1008 | + { |
|
1009 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1010 | + return EEH_Event_Query::posts_fields($SQL, $wp_query); |
|
1011 | + } |
|
1012 | 1012 | |
1013 | - |
|
1014 | - |
|
1015 | - /** |
|
1016 | - * @deprecated |
|
1017 | - * @since 4.4.0 |
|
1018 | - */ |
|
1019 | - public static function posts_fields_sql_for_orderby($orderby_params = array()) |
|
1020 | - { |
|
1021 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1022 | - return EEH_Event_Query::posts_fields_sql_for_orderby($orderby_params); |
|
1023 | - } |
|
1013 | + |
|
1014 | + |
|
1015 | + /** |
|
1016 | + * @deprecated |
|
1017 | + * @since 4.4.0 |
|
1018 | + */ |
|
1019 | + public static function posts_fields_sql_for_orderby($orderby_params = array()) |
|
1020 | + { |
|
1021 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1022 | + return EEH_Event_Query::posts_fields_sql_for_orderby($orderby_params); |
|
1023 | + } |
|
1024 | 1024 | |
1025 | 1025 | |
1026 | 1026 | |
1027 | - /** |
|
1028 | - * @deprecated |
|
1029 | - * @since 4.4.0 |
|
1030 | - */ |
|
1031 | - public function posts_join($SQL, WP_Query $wp_query) |
|
1032 | - { |
|
1033 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1034 | - return EEH_Event_Query::posts_join($SQL, $wp_query); |
|
1035 | - } |
|
1027 | + /** |
|
1028 | + * @deprecated |
|
1029 | + * @since 4.4.0 |
|
1030 | + */ |
|
1031 | + public function posts_join($SQL, WP_Query $wp_query) |
|
1032 | + { |
|
1033 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1034 | + return EEH_Event_Query::posts_join($SQL, $wp_query); |
|
1035 | + } |
|
1036 | 1036 | |
1037 | 1037 | |
1038 | 1038 | |
1039 | - /** |
|
1040 | - * @deprecated |
|
1041 | - * @since 4.4.0 |
|
1042 | - */ |
|
1043 | - public static function posts_join_sql_for_terms($join_terms = null) |
|
1044 | - { |
|
1045 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1046 | - return EEH_Event_Query::posts_join_sql_for_terms($join_terms); |
|
1047 | - } |
|
1039 | + /** |
|
1040 | + * @deprecated |
|
1041 | + * @since 4.4.0 |
|
1042 | + */ |
|
1043 | + public static function posts_join_sql_for_terms($join_terms = null) |
|
1044 | + { |
|
1045 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1046 | + return EEH_Event_Query::posts_join_sql_for_terms($join_terms); |
|
1047 | + } |
|
1048 | 1048 | |
1049 | 1049 | |
1050 | 1050 | |
1051 | - /** |
|
1052 | - * @deprecated |
|
1053 | - * @since 4.4.0 |
|
1054 | - */ |
|
1055 | - public static function posts_join_for_orderby($orderby_params = array()) |
|
1056 | - { |
|
1057 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1058 | - return EEH_Event_Query::posts_join_for_orderby($orderby_params); |
|
1059 | - } |
|
1051 | + /** |
|
1052 | + * @deprecated |
|
1053 | + * @since 4.4.0 |
|
1054 | + */ |
|
1055 | + public static function posts_join_for_orderby($orderby_params = array()) |
|
1056 | + { |
|
1057 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1058 | + return EEH_Event_Query::posts_join_for_orderby($orderby_params); |
|
1059 | + } |
|
1060 | 1060 | |
1061 | 1061 | |
1062 | 1062 | |
1063 | - /** |
|
1064 | - * @deprecated |
|
1065 | - * @since 4.4.0 |
|
1066 | - */ |
|
1067 | - public function posts_where($SQL, WP_Query $wp_query) |
|
1068 | - { |
|
1069 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1070 | - return EEH_Event_Query::posts_where($SQL, $wp_query); |
|
1071 | - } |
|
1063 | + /** |
|
1064 | + * @deprecated |
|
1065 | + * @since 4.4.0 |
|
1066 | + */ |
|
1067 | + public function posts_where($SQL, WP_Query $wp_query) |
|
1068 | + { |
|
1069 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1070 | + return EEH_Event_Query::posts_where($SQL, $wp_query); |
|
1071 | + } |
|
1072 | 1072 | |
1073 | - |
|
1074 | - |
|
1075 | - /** |
|
1076 | - * @deprecated |
|
1077 | - * @since 4.4.0 |
|
1078 | - */ |
|
1079 | - public static function posts_where_sql_for_show_expired($show_expired = false) |
|
1080 | - { |
|
1081 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1082 | - return EEH_Event_Query::posts_where_sql_for_show_expired($show_expired); |
|
1083 | - } |
|
1073 | + |
|
1074 | + |
|
1075 | + /** |
|
1076 | + * @deprecated |
|
1077 | + * @since 4.4.0 |
|
1078 | + */ |
|
1079 | + public static function posts_where_sql_for_show_expired($show_expired = false) |
|
1080 | + { |
|
1081 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1082 | + return EEH_Event_Query::posts_where_sql_for_show_expired($show_expired); |
|
1083 | + } |
|
1084 | 1084 | |
1085 | 1085 | |
1086 | 1086 | |
1087 | - /** |
|
1088 | - * @deprecated |
|
1089 | - * @since 4.4.0 |
|
1090 | - */ |
|
1091 | - public static function posts_where_sql_for_event_category_slug($event_category_slug = null) |
|
1092 | - { |
|
1093 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1094 | - return EEH_Event_Query::posts_where_sql_for_event_category_slug($event_category_slug); |
|
1095 | - } |
|
1087 | + /** |
|
1088 | + * @deprecated |
|
1089 | + * @since 4.4.0 |
|
1090 | + */ |
|
1091 | + public static function posts_where_sql_for_event_category_slug($event_category_slug = null) |
|
1092 | + { |
|
1093 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1094 | + return EEH_Event_Query::posts_where_sql_for_event_category_slug($event_category_slug); |
|
1095 | + } |
|
1096 | 1096 | |
1097 | 1097 | |
1098 | 1098 | |
1099 | - /** |
|
1100 | - * @deprecated |
|
1101 | - * @since 4.4.0 |
|
1102 | - */ |
|
1103 | - public static function posts_where_sql_for_event_list_month($month = null) |
|
1104 | - { |
|
1105 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1106 | - return EEH_Event_Query::posts_where_sql_for_event_list_month($month); |
|
1107 | - } |
|
1099 | + /** |
|
1100 | + * @deprecated |
|
1101 | + * @since 4.4.0 |
|
1102 | + */ |
|
1103 | + public static function posts_where_sql_for_event_list_month($month = null) |
|
1104 | + { |
|
1105 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1106 | + return EEH_Event_Query::posts_where_sql_for_event_list_month($month); |
|
1107 | + } |
|
1108 | 1108 | |
1109 | 1109 | |
1110 | 1110 | |
1111 | - /** |
|
1112 | - * @deprecated |
|
1113 | - * @since 4.4.0 |
|
1114 | - */ |
|
1115 | - public function posts_orderby($SQL, WP_Query $wp_query) |
|
1116 | - { |
|
1117 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1118 | - return EEH_Event_Query::posts_orderby($SQL, $wp_query); |
|
1119 | - } |
|
1111 | + /** |
|
1112 | + * @deprecated |
|
1113 | + * @since 4.4.0 |
|
1114 | + */ |
|
1115 | + public function posts_orderby($SQL, WP_Query $wp_query) |
|
1116 | + { |
|
1117 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1118 | + return EEH_Event_Query::posts_orderby($SQL, $wp_query); |
|
1119 | + } |
|
1120 | 1120 | |
1121 | 1121 | |
1122 | 1122 | |
1123 | - /** |
|
1124 | - * @deprecated |
|
1125 | - * @since 4.4.0 |
|
1126 | - */ |
|
1127 | - public static function posts_orderby_sql($orderby_params = array(), $sort = 'ASC') |
|
1128 | - { |
|
1129 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1130 | - return EEH_Event_Query::posts_orderby_sql($orderby_params, $sort); |
|
1131 | - } |
|
1123 | + /** |
|
1124 | + * @deprecated |
|
1125 | + * @since 4.4.0 |
|
1126 | + */ |
|
1127 | + public static function posts_orderby_sql($orderby_params = array(), $sort = 'ASC') |
|
1128 | + { |
|
1129 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1130 | + return EEH_Event_Query::posts_orderby_sql($orderby_params, $sort); |
|
1131 | + } |
|
1132 | 1132 | |
1133 | 1133 | |
1134 | 1134 | |
@@ -1141,9 +1141,9 @@ discard block |
||
1141 | 1141 | */ |
1142 | 1142 | function espresso_get_event_list_ID() |
1143 | 1143 | { |
1144 | - EED_Events_Archive::$espresso_event_list_ID++; |
|
1145 | - EED_Events_Archive::$espresso_grid_event_lists[] = EED_Events_Archive::$espresso_event_list_ID; |
|
1146 | - return EED_Events_Archive::$espresso_event_list_ID; |
|
1144 | + EED_Events_Archive::$espresso_event_list_ID++; |
|
1145 | + EED_Events_Archive::$espresso_grid_event_lists[] = EED_Events_Archive::$espresso_event_list_ID; |
|
1146 | + return EED_Events_Archive::$espresso_event_list_ID; |
|
1147 | 1147 | } |
1148 | 1148 | |
1149 | 1149 | /** |
@@ -1151,7 +1151,7 @@ discard block |
||
1151 | 1151 | */ |
1152 | 1152 | function espresso_event_list_title() |
1153 | 1153 | { |
1154 | - return EED_Events_Archive::event_list_title(); |
|
1154 | + return EED_Events_Archive::event_list_title(); |
|
1155 | 1155 | } |
1156 | 1156 | |
1157 | 1157 | /** |
@@ -1160,7 +1160,7 @@ discard block |
||
1160 | 1160 | */ |
1161 | 1161 | function espresso_event_list_css($extra_class = '') |
1162 | 1162 | { |
1163 | - return EED_Events_Archive::event_list_css($extra_class); |
|
1163 | + return EED_Events_Archive::event_list_css($extra_class); |
|
1164 | 1164 | } |
1165 | 1165 | |
1166 | 1166 | /** |
@@ -1168,7 +1168,7 @@ discard block |
||
1168 | 1168 | */ |
1169 | 1169 | function espresso_get_event_categories() |
1170 | 1170 | { |
1171 | - return EED_Events_Archive::event_categories(); |
|
1171 | + return EED_Events_Archive::event_categories(); |
|
1172 | 1172 | } |
1173 | 1173 | |
1174 | 1174 | /** |
@@ -1176,7 +1176,7 @@ discard block |
||
1176 | 1176 | */ |
1177 | 1177 | function espresso_display_full_description_in_event_list() |
1178 | 1178 | { |
1179 | - return EED_Events_Archive::display_description(2); |
|
1179 | + return EED_Events_Archive::display_description(2); |
|
1180 | 1180 | } |
1181 | 1181 | |
1182 | 1182 | /** |
@@ -1184,7 +1184,7 @@ discard block |
||
1184 | 1184 | */ |
1185 | 1185 | function espresso_display_excerpt_in_event_list() |
1186 | 1186 | { |
1187 | - return EED_Events_Archive::display_description(1); |
|
1187 | + return EED_Events_Archive::display_description(1); |
|
1188 | 1188 | } |
1189 | 1189 | |
1190 | 1190 | /** |
@@ -1192,7 +1192,7 @@ discard block |
||
1192 | 1192 | */ |
1193 | 1193 | function espresso_display_ticket_selector_in_event_list() |
1194 | 1194 | { |
1195 | - return EED_Events_Archive::display_ticket_selector(); |
|
1195 | + return EED_Events_Archive::display_ticket_selector(); |
|
1196 | 1196 | } |
1197 | 1197 | |
1198 | 1198 | /** |
@@ -1200,7 +1200,7 @@ discard block |
||
1200 | 1200 | */ |
1201 | 1201 | function espresso_display_venue_in_event_list() |
1202 | 1202 | { |
1203 | - return EED_Events_Archive::display_venue(); |
|
1203 | + return EED_Events_Archive::display_venue(); |
|
1204 | 1204 | } |
1205 | 1205 | |
1206 | 1206 | /** |
@@ -1208,7 +1208,7 @@ discard block |
||
1208 | 1208 | */ |
1209 | 1209 | function espresso_display_datetimes_in_event_list() |
1210 | 1210 | { |
1211 | - return EED_Events_Archive::display_datetimes(); |
|
1211 | + return EED_Events_Archive::display_datetimes(); |
|
1212 | 1212 | } |
1213 | 1213 | |
1214 | 1214 |
@@ -35,26 +35,26 @@ |
||
35 | 35 | } |
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
40 | - * |
|
41 | - * @return void |
|
42 | - * @throws InvalidArgumentException |
|
43 | - * @throws InvalidDataTypeException |
|
44 | - * @throws InvalidInterfaceException |
|
45 | - */ |
|
38 | + /** |
|
39 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
40 | + * |
|
41 | + * @return void |
|
42 | + * @throws InvalidArgumentException |
|
43 | + * @throws InvalidDataTypeException |
|
44 | + * @throws InvalidInterfaceException |
|
45 | + */ |
|
46 | 46 | public static function set_hooks() { |
47 | - /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */ |
|
48 | - $custom_post_type_definitions = LoaderFactory::getLoader()->getShared( |
|
49 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
50 | - ); |
|
51 | - $custom_post_types = $custom_post_type_definitions->getDefinitions(); |
|
52 | - EE_Config::register_route( |
|
53 | - $custom_post_types['espresso_venues']['plural_slug'], |
|
54 | - 'Venues_Archive', |
|
55 | - 'run' |
|
56 | - ); |
|
57 | - } |
|
47 | + /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */ |
|
48 | + $custom_post_type_definitions = LoaderFactory::getLoader()->getShared( |
|
49 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
50 | + ); |
|
51 | + $custom_post_types = $custom_post_type_definitions->getDefinitions(); |
|
52 | + EE_Config::register_route( |
|
53 | + $custom_post_types['espresso_venues']['plural_slug'], |
|
54 | + 'Venues_Archive', |
|
55 | + 'run' |
|
56 | + ); |
|
57 | + } |
|
58 | 58 | |
59 | 59 | /** |
60 | 60 | * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
@@ -2,7 +2,9 @@ |
||
2 | 2 | use EventEspresso\core\exceptions\InvalidInterfaceException; |
3 | 3 | use EventEspresso\core\services\loaders\LoaderFactory; |
4 | 4 | |
5 | -if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
5 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
6 | + exit('No direct script access allowed'); |
|
7 | +} |
|
6 | 8 | /** |
7 | 9 | * Event Espresso |
8 | 10 | * |
@@ -35,26 +35,26 @@ |
||
35 | 35 | } |
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
40 | - * |
|
41 | - * @return void |
|
42 | - * @throws InvalidArgumentException |
|
43 | - * @throws InvalidDataTypeException |
|
44 | - * @throws InvalidInterfaceException |
|
45 | - */ |
|
38 | + /** |
|
39 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
40 | + * |
|
41 | + * @return void |
|
42 | + * @throws InvalidArgumentException |
|
43 | + * @throws InvalidDataTypeException |
|
44 | + * @throws InvalidInterfaceException |
|
45 | + */ |
|
46 | 46 | public static function set_hooks() { |
47 | - /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */ |
|
48 | - $custom_post_type_definitions = LoaderFactory::getLoader()->getShared( |
|
49 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
50 | - ); |
|
51 | - $custom_post_types = $custom_post_type_definitions->getDefinitions(); |
|
52 | - EE_Config::register_route( |
|
53 | - $custom_post_types['espresso_venues']['singular_slug'], |
|
54 | - 'Venue_Single', |
|
55 | - 'run' |
|
56 | - ); |
|
57 | - } |
|
47 | + /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */ |
|
48 | + $custom_post_type_definitions = LoaderFactory::getLoader()->getShared( |
|
49 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
50 | + ); |
|
51 | + $custom_post_types = $custom_post_type_definitions->getDefinitions(); |
|
52 | + EE_Config::register_route( |
|
53 | + $custom_post_types['espresso_venues']['singular_slug'], |
|
54 | + 'Venue_Single', |
|
55 | + 'run' |
|
56 | + ); |
|
57 | + } |
|
58 | 58 | |
59 | 59 | /** |
60 | 60 | * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
@@ -2,7 +2,9 @@ |
||
2 | 2 | use EventEspresso\core\exceptions\InvalidInterfaceException; |
3 | 3 | use EventEspresso\core\services\loaders\LoaderFactory; |
4 | 4 | |
5 | -if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
5 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
6 | + exit('No direct script access allowed'); |
|
7 | +} |
|
6 | 8 | /** |
7 | 9 | * Event Espresso |
8 | 10 | * |