@@ -210,14 +210,14 @@ discard block |
||
| 210 | 210 | <?php _e('Show on all Pages:', 'event_espresso'); ?> |
| 211 | 211 | </label> |
| 212 | 212 | <?php |
| 213 | - echo EEH_Form_Fields::select( |
|
| 214 | - __('Show on all Pages:', 'event_espresso'), |
|
| 215 | - $instance['show_everywhere'], |
|
| 216 | - $yes_no_values, |
|
| 217 | - $this->get_field_name('show_everywhere'), |
|
| 218 | - $this->get_field_id('show_everywhere') |
|
| 219 | - ); |
|
| 220 | - ?> |
|
| 213 | + echo EEH_Form_Fields::select( |
|
| 214 | + __('Show on all Pages:', 'event_espresso'), |
|
| 215 | + $instance['show_everywhere'], |
|
| 216 | + $yes_no_values, |
|
| 217 | + $this->get_field_name('show_everywhere'), |
|
| 218 | + $this->get_field_id('show_everywhere') |
|
| 219 | + ); |
|
| 220 | + ?> |
|
| 221 | 221 | </p> |
| 222 | 222 | <p> |
| 223 | 223 | <label for="<?php echo $this->get_field_id('date_limit'); ?>"> |
@@ -300,14 +300,14 @@ discard block |
||
| 300 | 300 | extract($args); |
| 301 | 301 | |
| 302 | 302 | // add function to make the title a link |
| 303 | - add_filter('widget_title', array($this, 'make_the_title_a_link'), 15); |
|
| 303 | + add_filter('widget_title', array($this, 'make_the_title_a_link'), 15); |
|
| 304 | 304 | |
| 305 | 305 | $title = isset( $instance['title'] ) && ! empty( $instance['title'] ) ? $instance['title'] : ''; |
| 306 | 306 | // filter the title |
| 307 | 307 | $title = apply_filters('widget_title', $title); |
| 308 | 308 | |
| 309 | 309 | // remove the function from the filter, so it does not affect other widgets |
| 310 | - remove_filter('widget_title', array($this, 'make_the_title_a_link'), 15); |
|
| 310 | + remove_filter('widget_title', array($this, 'make_the_title_a_link'), 15); |
|
| 311 | 311 | |
| 312 | 312 | // Before widget (defined by themes). |
| 313 | 313 | echo $before_widget; |
@@ -419,7 +419,7 @@ discard block |
||
| 419 | 419 | * @return string |
| 420 | 420 | */ |
| 421 | 421 | public function make_the_title_a_link($title) { |
| 422 | - return '<a href="' . EEH_Event_View::event_archive_url() . '">' . $title . '</a>'; |
|
| 422 | + return '<a href="' . EEH_Event_View::event_archive_url() . '">' . $title . '</a>'; |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | } |
@@ -31,8 +31,8 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | public function __construct() { |
| 33 | 33 | parent::__construct( |
| 34 | - __( 'Event Espresso Upcoming Events', 'event_espresso' ), |
|
| 35 | - array( 'description' => __( 'A widget to display your upcoming events.', 'event_espresso' )) |
|
| 34 | + __('Event Espresso Upcoming Events', 'event_espresso'), |
|
| 35 | + array('description' => __('A widget to display your upcoming events.', 'event_espresso')) |
|
| 36 | 36 | ); |
| 37 | 37 | } |
| 38 | 38 | |
@@ -45,9 +45,9 @@ discard block |
||
| 45 | 45 | * @param array $instance Previously saved values from database. |
| 46 | 46 | * @return string|void |
| 47 | 47 | */ |
| 48 | - public function form( $instance ) { |
|
| 48 | + public function form($instance) { |
|
| 49 | 49 | |
| 50 | - EE_Registry::instance()->load_class( 'Question_Option', array(), FALSE, FALSE, TRUE ); |
|
| 50 | + EE_Registry::instance()->load_class('Question_Option', array(), FALSE, FALSE, TRUE); |
|
| 51 | 51 | // Set up some default widget settings. |
| 52 | 52 | $defaults = array( |
| 53 | 53 | 'title' => __('Upcoming Events', 'event_espresso'), |
@@ -63,16 +63,16 @@ discard block |
||
| 63 | 63 | 'image_size' => 'medium' |
| 64 | 64 | ); |
| 65 | 65 | |
| 66 | - $instance = wp_parse_args( (array) $instance, $defaults ); |
|
| 66 | + $instance = wp_parse_args((array) $instance, $defaults); |
|
| 67 | 67 | // don't add HTML labels for EE_Form_Fields generated inputs |
| 68 | - add_filter( 'FHEE__EEH_Form_Fields__label_html', '__return_empty_string' ); |
|
| 68 | + add_filter('FHEE__EEH_Form_Fields__label_html', '__return_empty_string'); |
|
| 69 | 69 | $yes_no_values = array( |
| 70 | - EE_Question_Option::new_instance( array( 'QSO_value' => FALSE, 'QSO_desc' => __('No', 'event_espresso'))), |
|
| 71 | - EE_Question_Option::new_instance( array( 'QSO_value' => TRUE, 'QSO_desc' => __('Yes', 'event_espresso'))) |
|
| 70 | + EE_Question_Option::new_instance(array('QSO_value' => FALSE, 'QSO_desc' => __('No', 'event_espresso'))), |
|
| 71 | + EE_Question_Option::new_instance(array('QSO_value' => TRUE, 'QSO_desc' => __('Yes', 'event_espresso'))) |
|
| 72 | 72 | ); |
| 73 | 73 | $sort_values = array( |
| 74 | - EE_Question_Option::new_instance( array( 'QSO_value' => 'ASC', 'QSO_desc' => __('ASC', 'event_espresso'))), |
|
| 75 | - EE_Question_Option::new_instance( array( 'QSO_value' => 'DESC', 'QSO_desc' => __('DESC', 'event_espresso'))) |
|
| 74 | + EE_Question_Option::new_instance(array('QSO_value' => 'ASC', 'QSO_desc' => __('ASC', 'event_espresso'))), |
|
| 75 | + EE_Question_Option::new_instance(array('QSO_value' => 'DESC', 'QSO_desc' => __('DESC', 'event_espresso'))) |
|
| 76 | 76 | ); |
| 77 | 77 | |
| 78 | 78 | ?> |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | <label for="<?php echo $this->get_field_id('title'); ?>"> |
| 84 | 84 | <?php _e('Title:', 'event_espresso'); ?> |
| 85 | 85 | </label> |
| 86 | - <input id="<?php echo $this->get_field_id('title'); ?>" class="widefat" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>" type="text" /> |
|
| 86 | + <input id="<?php echo $this->get_field_id('title'); ?>" class="widefat" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo esc_attr($instance['title']); ?>" type="text" /> |
|
| 87 | 87 | </p> |
| 88 | 88 | <p> |
| 89 | 89 | <label for="<?php echo $this->get_field_id('category_name'); ?>"> |
@@ -92,16 +92,16 @@ discard block |
||
| 92 | 92 | <?php |
| 93 | 93 | $event_categories = array(); |
| 94 | 94 | /** @type EEM_Term $EEM_Term */ |
| 95 | - $EEM_Term = EE_Registry::instance()->load_model( 'Term' ); |
|
| 96 | - $categories = $EEM_Term->get_all_ee_categories( TRUE ); |
|
| 97 | - if ( $categories ) { |
|
| 98 | - foreach ( $categories as $category ) { |
|
| 99 | - if ( $category instanceof EE_Term ) { |
|
| 100 | - $event_categories[] = EE_Question_Option::new_instance( array( 'QSO_value' => $category->get( 'slug' ), 'QSO_desc' => $category->get( 'name' ))); |
|
| 95 | + $EEM_Term = EE_Registry::instance()->load_model('Term'); |
|
| 96 | + $categories = $EEM_Term->get_all_ee_categories(TRUE); |
|
| 97 | + if ($categories) { |
|
| 98 | + foreach ($categories as $category) { |
|
| 99 | + if ($category instanceof EE_Term) { |
|
| 100 | + $event_categories[] = EE_Question_Option::new_instance(array('QSO_value' => $category->get('slug'), 'QSO_desc' => $category->get('name'))); |
|
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | - array_unshift( $event_categories, EE_Question_Option::new_instance( array( 'QSO_value' => '', 'QSO_desc' => __(' - display all - ', 'event_espresso')))); |
|
| 104 | + array_unshift($event_categories, EE_Question_Option::new_instance(array('QSO_value' => '', 'QSO_desc' => __(' - display all - ', 'event_espresso')))); |
|
| 105 | 105 | echo EEH_Form_Fields::select( |
| 106 | 106 | __('Event Category:', 'event_espresso'), |
| 107 | 107 | $instance['category_name'], |
@@ -126,9 +126,9 @@ discard block |
||
| 126 | 126 | __('Show Expired Events:', 'event_espresso'), |
| 127 | 127 | $instance['show_expired'], |
| 128 | 128 | array( |
| 129 | - EE_Question_Option::new_instance( array( 'QSO_value' => 0, 'QSO_desc' => __('No', 'event_espresso'))), |
|
| 130 | - EE_Question_Option::new_instance( array( 'QSO_value' => 1, 'QSO_desc' => __('Yes', 'event_espresso'))), |
|
| 131 | - EE_Question_Option::new_instance( array( 'QSO_value' => 2, 'QSO_desc' => __('Show Only Expired', 'event_espresso'))), |
|
| 129 | + EE_Question_Option::new_instance(array('QSO_value' => 0, 'QSO_desc' => __('No', 'event_espresso'))), |
|
| 130 | + EE_Question_Option::new_instance(array('QSO_value' => 1, 'QSO_desc' => __('Yes', 'event_espresso'))), |
|
| 131 | + EE_Question_Option::new_instance(array('QSO_value' => 2, 'QSO_desc' => __('Show Only Expired', 'event_espresso'))), |
|
| 132 | 132 | ), |
| 133 | 133 | $this->get_field_name('show_expired'), |
| 134 | 134 | $this->get_field_id('show_expired') |
@@ -156,16 +156,16 @@ discard block |
||
| 156 | 156 | <?php |
| 157 | 157 | $image_sizes = array(); |
| 158 | 158 | $sizes = get_intermediate_image_sizes(); |
| 159 | - if ( $sizes ) { |
|
| 159 | + if ($sizes) { |
|
| 160 | 160 | // loop thru images and create option objects out of them |
| 161 | - foreach ( $sizes as $image_size ) { |
|
| 162 | - $image_size = trim( $image_size ); |
|
| 161 | + foreach ($sizes as $image_size) { |
|
| 162 | + $image_size = trim($image_size); |
|
| 163 | 163 | // no big images plz |
| 164 | - if ( ! in_array( $image_size, array( 'large', 'post-thumbnail' ))) { |
|
| 165 | - $image_sizes[] = EE_Question_Option::new_instance( array( 'QSO_value' => $image_size, 'QSO_desc' => $image_size )); |
|
| 164 | + if ( ! in_array($image_size, array('large', 'post-thumbnail'))) { |
|
| 165 | + $image_sizes[] = EE_Question_Option::new_instance(array('QSO_value' => $image_size, 'QSO_desc' => $image_size)); |
|
| 166 | 166 | } |
| 167 | 167 | } |
| 168 | - $image_sizes[] = EE_Question_Option::new_instance( array( 'QSO_value' => 'none', 'QSO_desc' => __('don\'t show images', 'event_espresso') )); |
|
| 168 | + $image_sizes[] = EE_Question_Option::new_instance(array('QSO_value' => 'none', 'QSO_desc' => __('don\'t show images', 'event_espresso'))); |
|
| 169 | 169 | } |
| 170 | 170 | echo EEH_Form_Fields::select( |
| 171 | 171 | __('Image Size:', 'event_espresso'), |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | <label for="<?php echo $this->get_field_id('date_limit'); ?>"> |
| 224 | 224 | <?php _e('Number of Dates to Display:', 'event_espresso'); ?> |
| 225 | 225 | </label> |
| 226 | - <input id="<?php echo $this->get_field_id('date_limit'); ?>" name="<?php echo $this->get_field_name('date_limit'); ?>" value="<?php echo esc_attr( $instance['date_limit'] ); ?>" size="3" type="text" /> |
|
| 226 | + <input id="<?php echo $this->get_field_id('date_limit'); ?>" name="<?php echo $this->get_field_name('date_limit'); ?>" value="<?php echo esc_attr($instance['date_limit']); ?>" size="3" type="text" /> |
|
| 227 | 227 | </p> |
| 228 | 228 | <p> |
| 229 | 229 | <label for="<?php echo $this->get_field_id('date_range'); ?>"> |
@@ -255,9 +255,9 @@ discard block |
||
| 255 | 255 | * |
| 256 | 256 | * @return array Updated safe values to be saved. |
| 257 | 257 | */ |
| 258 | - public function update( $new_instance, $old_instance ) { |
|
| 258 | + public function update($new_instance, $old_instance) { |
|
| 259 | 259 | $instance = $old_instance; |
| 260 | - $instance['title'] = ! empty( $new_instance['title'] ) ? strip_tags( $new_instance['title'] ) : ''; |
|
| 260 | + $instance['title'] = ! empty($new_instance['title']) ? strip_tags($new_instance['title']) : ''; |
|
| 261 | 261 | $instance['category_name'] = $new_instance['category_name']; |
| 262 | 262 | $instance['show_expired'] = $new_instance['show_expired']; |
| 263 | 263 | $instance['limit'] = $new_instance['limit']; |
@@ -281,18 +281,18 @@ discard block |
||
| 281 | 281 | * @param array $args Widget arguments. |
| 282 | 282 | * @param array $instance Saved values from database. |
| 283 | 283 | */ |
| 284 | - public function widget( $args, $instance ) { |
|
| 284 | + public function widget($args, $instance) { |
|
| 285 | 285 | |
| 286 | 286 | global $post; |
| 287 | 287 | // make sure there is some kinda post object |
| 288 | - if ( $post instanceof WP_Post ) { |
|
| 288 | + if ($post instanceof WP_Post) { |
|
| 289 | 289 | $before_widget = ''; |
| 290 | 290 | $before_title = ''; |
| 291 | 291 | $after_title = ''; |
| 292 | 292 | $after_widget = ''; |
| 293 | 293 | // but NOT an events archives page, cuz that would be like two event lists on the same page |
| 294 | - $show_everywhere = isset( $instance['show_everywhere'] ) ? (bool) absint( $instance['show_everywhere'] ) : TRUE; |
|
| 295 | - if ( $show_everywhere || ! ( $post->post_type == 'espresso_events' && is_archive() )) { |
|
| 294 | + $show_everywhere = isset($instance['show_everywhere']) ? (bool) absint($instance['show_everywhere']) : TRUE; |
|
| 295 | + if ($show_everywhere || ! ($post->post_type == 'espresso_events' && is_archive())) { |
|
| 296 | 296 | // let's use some of the event helper functions' |
| 297 | 297 | // make separate vars out of attributes |
| 298 | 298 | |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | // add function to make the title a link |
| 303 | 303 | add_filter('widget_title', array($this, 'make_the_title_a_link'), 15); |
| 304 | 304 | |
| 305 | - $title = isset( $instance['title'] ) && ! empty( $instance['title'] ) ? $instance['title'] : ''; |
|
| 305 | + $title = isset($instance['title']) && ! empty($instance['title']) ? $instance['title'] : ''; |
|
| 306 | 306 | // filter the title |
| 307 | 307 | $title = apply_filters('widget_title', $title); |
| 308 | 308 | |
@@ -312,90 +312,90 @@ discard block |
||
| 312 | 312 | // Before widget (defined by themes). |
| 313 | 313 | echo $before_widget; |
| 314 | 314 | // Display the widget title if one was input (before and after defined by themes). |
| 315 | - if ( ! empty( $title )) { |
|
| 316 | - echo $before_title . $title . $after_title; |
|
| 315 | + if ( ! empty($title)) { |
|
| 316 | + echo $before_title.$title.$after_title; |
|
| 317 | 317 | } |
| 318 | 318 | // grab widget settings |
| 319 | - $category = isset( $instance['category_name'] ) && ! empty( $instance['category_name'] ) ? $instance['category_name'] : FALSE; |
|
| 320 | - $show_expired = isset( $instance['show_expired'] ) ? absint( $instance['show_expired'] ) : 0; |
|
| 321 | - $image_size = isset( $instance['image_size'] ) && ! empty( $instance['image_size'] ) ? $instance['image_size'] : 'medium'; |
|
| 322 | - $show_desc = isset( $instance['show_desc'] ) ? (bool) absint( $instance['show_desc'] ) : TRUE; |
|
| 323 | - $show_dates = isset( $instance['show_dates'] ) ? (bool) absint( $instance['show_dates'] ) : TRUE; |
|
| 324 | - $date_limit = isset( $instance['date_limit'] ) && ! empty( $instance['date_limit'] ) ? $instance['date_limit'] : NULL; |
|
| 325 | - $date_range = isset( $instance['date_range'] ) && ! empty( $instance['date_range'] ) ? $instance['date_range'] : FALSE; |
|
| 319 | + $category = isset($instance['category_name']) && ! empty($instance['category_name']) ? $instance['category_name'] : FALSE; |
|
| 320 | + $show_expired = isset($instance['show_expired']) ? absint($instance['show_expired']) : 0; |
|
| 321 | + $image_size = isset($instance['image_size']) && ! empty($instance['image_size']) ? $instance['image_size'] : 'medium'; |
|
| 322 | + $show_desc = isset($instance['show_desc']) ? (bool) absint($instance['show_desc']) : TRUE; |
|
| 323 | + $show_dates = isset($instance['show_dates']) ? (bool) absint($instance['show_dates']) : TRUE; |
|
| 324 | + $date_limit = isset($instance['date_limit']) && ! empty($instance['date_limit']) ? $instance['date_limit'] : NULL; |
|
| 325 | + $date_range = isset($instance['date_range']) && ! empty($instance['date_range']) ? $instance['date_range'] : FALSE; |
|
| 326 | 326 | // start to build our where clause |
| 327 | 327 | $where = array( |
| 328 | 328 | // 'Datetime.DTT_is_primary' => 1, |
| 329 | - 'status' => array( 'IN', array( 'publish', 'sold_out' ) ) |
|
| 329 | + 'status' => array('IN', array('publish', 'sold_out')) |
|
| 330 | 330 | ); |
| 331 | 331 | // add category |
| 332 | - if ( $category ) { |
|
| 332 | + if ($category) { |
|
| 333 | 333 | $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
| 334 | 334 | $where['Term_Taxonomy.Term.slug'] = $category; |
| 335 | 335 | } |
| 336 | 336 | // if NOT expired then we want events that start today or in the future |
| 337 | 337 | // if NOT show expired then we want events that start today or in the future |
| 338 | - if ( $show_expired == 0 ) { |
|
| 339 | - $where['Datetime.DTT_EVT_end'] = array( '>=', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) ); |
|
| 338 | + if ($show_expired == 0) { |
|
| 339 | + $where['Datetime.DTT_EVT_end'] = array('>=', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end')); |
|
| 340 | 340 | } |
| 341 | 341 | // if show ONLY expired we want events that ended prior to today |
| 342 | - if ( $show_expired == 2 ) { |
|
| 343 | - $where['Datetime.DTT_EVT_end'] = array( '<=', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_start' ) ); |
|
| 342 | + if ($show_expired == 2) { |
|
| 343 | + $where['Datetime.DTT_EVT_end'] = array('<=', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start')); |
|
| 344 | 344 | } |
| 345 | 345 | // allow $where to be filtered |
| 346 | - $where = apply_filters( 'FHEE__EEW_Upcoming_Events__widget__where', $where, $category, $show_expired ); |
|
| 346 | + $where = apply_filters('FHEE__EEW_Upcoming_Events__widget__where', $where, $category, $show_expired); |
|
| 347 | 347 | // run the query |
| 348 | - $events = EE_Registry::instance()->load_model( 'Event' )->get_all( array( |
|
| 348 | + $events = EE_Registry::instance()->load_model('Event')->get_all(array( |
|
| 349 | 349 | $where, |
| 350 | 350 | 'limit' => isset($instance['limit']) && $instance['limit'] > 0 |
| 351 | - ? '0,' . $instance['limit'] |
|
| 351 | + ? '0,'.$instance['limit'] |
|
| 352 | 352 | : '0,10', |
| 353 | 353 | 'order_by' => 'Datetime.DTT_EVT_start', |
| 354 | 354 | 'order' => isset($instance['sort']) ? $instance['sort'] : 'ASC', |
| 355 | 355 | 'group_by' => 'EVT_ID' |
| 356 | 356 | )); |
| 357 | 357 | |
| 358 | - if ( ! empty( $events )) { |
|
| 358 | + if ( ! empty($events)) { |
|
| 359 | 359 | echo '<ul class="ee-upcoming-events-widget-ul">'; |
| 360 | - foreach ( $events as $event ) { |
|
| 361 | - if ( $event instanceof EE_Event && ( !is_single() || $post->ID != $event->ID() ) ) { |
|
| 360 | + foreach ($events as $event) { |
|
| 361 | + if ($event instanceof EE_Event && ( ! is_single() || $post->ID != $event->ID())) { |
|
| 362 | 362 | //printr( $event, '$event <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
| 363 | - echo '<li id="ee-upcoming-events-widget-li-' . $event->ID() . '" class="ee-upcoming-events-widget-li">'; |
|
| 363 | + echo '<li id="ee-upcoming-events-widget-li-'.$event->ID().'" class="ee-upcoming-events-widget-li">'; |
|
| 364 | 364 | // how big is the event name ? |
| 365 | - $name_length = strlen( $event->name() ); |
|
| 366 | - switch( $name_length ) { |
|
| 365 | + $name_length = strlen($event->name()); |
|
| 366 | + switch ($name_length) { |
|
| 367 | 367 | case $name_length > 70 : |
| 368 | - $len_class = ' three-line'; |
|
| 368 | + $len_class = ' three-line'; |
|
| 369 | 369 | break; |
| 370 | 370 | case $name_length > 35 : |
| 371 | - $len_class = ' two-line'; |
|
| 371 | + $len_class = ' two-line'; |
|
| 372 | 372 | break; |
| 373 | 373 | default : |
| 374 | - $len_class = ' one-line'; |
|
| 374 | + $len_class = ' one-line'; |
|
| 375 | 375 | } |
| 376 | - $event_url = apply_filters( 'FHEE_EEW_Upcoming_Events__widget__event_url', $event->get_permalink(), $event ); |
|
| 377 | - echo '<h5 class="ee-upcoming-events-widget-title-h5"><a class="ee-widget-event-name-a' . $len_class . '" href="' . $event_url . '">' . $event->name() . '</a></h5>'; |
|
| 378 | - if ( post_password_required( $event->ID() ) ) { |
|
| 379 | - $pswd_form = apply_filters( 'FHEE_EEW_Upcoming_Events__widget__password_form', get_the_password_form( $event->ID() ), $event ); |
|
| 376 | + $event_url = apply_filters('FHEE_EEW_Upcoming_Events__widget__event_url', $event->get_permalink(), $event); |
|
| 377 | + echo '<h5 class="ee-upcoming-events-widget-title-h5"><a class="ee-widget-event-name-a'.$len_class.'" href="'.$event_url.'">'.$event->name().'</a></h5>'; |
|
| 378 | + if (post_password_required($event->ID())) { |
|
| 379 | + $pswd_form = apply_filters('FHEE_EEW_Upcoming_Events__widget__password_form', get_the_password_form($event->ID()), $event); |
|
| 380 | 380 | echo $pswd_form; |
| 381 | 381 | } else { |
| 382 | - if ( has_post_thumbnail( $event->ID() ) && $image_size != 'none' ) { |
|
| 383 | - echo '<div class="ee-upcoming-events-widget-img-dv"><a class="ee-upcoming-events-widget-img" href="' . $event_url . '">' . get_the_post_thumbnail( $event->ID(), $image_size ) . '</a></div>'; |
|
| 382 | + if (has_post_thumbnail($event->ID()) && $image_size != 'none') { |
|
| 383 | + echo '<div class="ee-upcoming-events-widget-img-dv"><a class="ee-upcoming-events-widget-img" href="'.$event_url.'">'.get_the_post_thumbnail($event->ID(), $image_size).'</a></div>'; |
|
| 384 | 384 | } |
| 385 | - $desc = $event->short_description( 25 ); |
|
| 386 | - if ( $show_dates ) { |
|
| 387 | - $date_format = apply_filters( 'FHEE__espresso_event_date_range__date_format', get_option( 'date_format' )); |
|
| 388 | - $time_format = apply_filters( 'FHEE__espresso_event_date_range__time_format', get_option( 'time_format' )); |
|
| 389 | - $single_date_format = apply_filters( 'FHEE__espresso_event_date_range__single_date_format', get_option( 'date_format' )); |
|
| 390 | - $single_time_format = apply_filters( 'FHEE__espresso_event_date_range__single_time_format', get_option( 'time_format' )); |
|
| 391 | - if ( $date_range == TRUE ) { |
|
| 392 | - echo espresso_event_date_range( $date_format, $time_format, $single_date_format, $single_time_format, $event->ID() ); |
|
| 393 | - }else{ |
|
| 394 | - echo espresso_list_of_event_dates( $event->ID(), $date_format, $time_format, FALSE, NULL, TRUE, TRUE, $date_limit ); |
|
| 385 | + $desc = $event->short_description(25); |
|
| 386 | + if ($show_dates) { |
|
| 387 | + $date_format = apply_filters('FHEE__espresso_event_date_range__date_format', get_option('date_format')); |
|
| 388 | + $time_format = apply_filters('FHEE__espresso_event_date_range__time_format', get_option('time_format')); |
|
| 389 | + $single_date_format = apply_filters('FHEE__espresso_event_date_range__single_date_format', get_option('date_format')); |
|
| 390 | + $single_time_format = apply_filters('FHEE__espresso_event_date_range__single_time_format', get_option('time_format')); |
|
| 391 | + if ($date_range == TRUE) { |
|
| 392 | + echo espresso_event_date_range($date_format, $time_format, $single_date_format, $single_time_format, $event->ID()); |
|
| 393 | + } else { |
|
| 394 | + echo espresso_list_of_event_dates($event->ID(), $date_format, $time_format, FALSE, NULL, TRUE, TRUE, $date_limit); |
|
| 395 | 395 | } |
| 396 | 396 | } |
| 397 | - if ( $show_desc && $desc ) { |
|
| 398 | - echo '<p style="margin-top: .5em">' . $desc . '</p>'; |
|
| 397 | + if ($show_desc && $desc) { |
|
| 398 | + echo '<p style="margin-top: .5em">'.$desc.'</p>'; |
|
| 399 | 399 | } |
| 400 | 400 | } |
| 401 | 401 | echo '</li>'; |
@@ -419,7 +419,7 @@ discard block |
||
| 419 | 419 | * @return string |
| 420 | 420 | */ |
| 421 | 421 | public function make_the_title_a_link($title) { |
| 422 | - return '<a href="' . EEH_Event_View::event_archive_url() . '">' . $title . '</a>'; |
|
| 422 | + return '<a href="'.EEH_Event_View::event_archive_url().'">'.$title.'</a>'; |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | } |
@@ -17,2474 +17,2474 @@ discard block |
||
| 17 | 17 | final class EE_Config implements ResettableInterface |
| 18 | 18 | { |
| 19 | 19 | |
| 20 | - const OPTION_NAME = 'ee_config'; |
|
| 20 | + const OPTION_NAME = 'ee_config'; |
|
| 21 | + |
|
| 22 | + const LOG_NAME = 'ee_config_log'; |
|
| 23 | + |
|
| 24 | + const LOG_LENGTH = 100; |
|
| 25 | + |
|
| 26 | + const ADDON_OPTION_NAMES = 'ee_config_option_names'; |
|
| 27 | + |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * instance of the EE_Config object |
|
| 31 | + * |
|
| 32 | + * @var EE_Config $_instance |
|
| 33 | + * @access private |
|
| 34 | + */ |
|
| 35 | + private static $_instance; |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * @var boolean $_logging_enabled |
|
| 39 | + */ |
|
| 40 | + private static $_logging_enabled = false; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * @var LegacyShortcodesManager $legacy_shortcodes_manager |
|
| 44 | + */ |
|
| 45 | + private $legacy_shortcodes_manager; |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * An StdClass whose property names are addon slugs, |
|
| 49 | + * and values are their config classes |
|
| 50 | + * |
|
| 51 | + * @var StdClass |
|
| 52 | + */ |
|
| 53 | + public $addons; |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * @var EE_Admin_Config |
|
| 57 | + */ |
|
| 58 | + public $admin; |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * @var EE_Core_Config |
|
| 62 | + */ |
|
| 63 | + public $core; |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * @var EE_Currency_Config |
|
| 67 | + */ |
|
| 68 | + public $currency; |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * @var EE_Organization_Config |
|
| 72 | + */ |
|
| 73 | + public $organization; |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * @var EE_Registration_Config |
|
| 77 | + */ |
|
| 78 | + public $registration; |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * @var EE_Template_Config |
|
| 82 | + */ |
|
| 83 | + public $template_settings; |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * Holds EE environment values. |
|
| 87 | + * |
|
| 88 | + * @var EE_Environment_Config |
|
| 89 | + */ |
|
| 90 | + public $environment; |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * settings pertaining to Google maps |
|
| 94 | + * |
|
| 95 | + * @var EE_Map_Config |
|
| 96 | + */ |
|
| 97 | + public $map_settings; |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * settings pertaining to Taxes |
|
| 101 | + * |
|
| 102 | + * @var EE_Tax_Config |
|
| 103 | + */ |
|
| 104 | + public $tax_settings; |
|
| 105 | + |
|
| 106 | + |
|
| 107 | + /** |
|
| 108 | + * Settings pertaining to global messages settings. |
|
| 109 | + * |
|
| 110 | + * @var EE_Messages_Config |
|
| 111 | + */ |
|
| 112 | + public $messages; |
|
| 113 | + |
|
| 114 | + /** |
|
| 115 | + * @deprecated |
|
| 116 | + * @var EE_Gateway_Config |
|
| 117 | + */ |
|
| 118 | + public $gateway; |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * @var array $_addon_option_names |
|
| 122 | + * @access private |
|
| 123 | + */ |
|
| 124 | + private $_addon_option_names = array(); |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * @var array $_module_route_map |
|
| 128 | + * @access private |
|
| 129 | + */ |
|
| 130 | + private static $_module_route_map = array(); |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * @var array $_module_forward_map |
|
| 134 | + * @access private |
|
| 135 | + */ |
|
| 136 | + private static $_module_forward_map = array(); |
|
| 137 | + |
|
| 138 | + /** |
|
| 139 | + * @var array $_module_view_map |
|
| 140 | + * @access private |
|
| 141 | + */ |
|
| 142 | + private static $_module_view_map = array(); |
|
| 143 | + |
|
| 144 | + |
|
| 145 | + |
|
| 146 | + /** |
|
| 147 | + * @singleton method used to instantiate class object |
|
| 148 | + * @access public |
|
| 149 | + * @return EE_Config instance |
|
| 150 | + */ |
|
| 151 | + public static function instance() |
|
| 152 | + { |
|
| 153 | + // check if class object is instantiated, and instantiated properly |
|
| 154 | + if (! self::$_instance instanceof EE_Config) { |
|
| 155 | + self::$_instance = new self(); |
|
| 156 | + } |
|
| 157 | + return self::$_instance; |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + |
|
| 161 | + |
|
| 162 | + /** |
|
| 163 | + * Resets the config |
|
| 164 | + * |
|
| 165 | + * @param bool $hard_reset if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE |
|
| 166 | + * (default) leaves the database alone, and merely resets the EE_Config object to |
|
| 167 | + * reflect its state in the database |
|
| 168 | + * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave |
|
| 169 | + * $_instance as NULL. Useful in case you want to forget about the old instance on |
|
| 170 | + * EE_Config, but might not be ready to instantiate EE_Config currently (eg if the |
|
| 171 | + * site was put into maintenance mode) |
|
| 172 | + * @return EE_Config |
|
| 173 | + */ |
|
| 174 | + public static function reset($hard_reset = false, $reinstantiate = true) |
|
| 175 | + { |
|
| 176 | + if (self::$_instance instanceof EE_Config) { |
|
| 177 | + if ($hard_reset) { |
|
| 178 | + self::$_instance->legacy_shortcodes_manager = null; |
|
| 179 | + self::$_instance->_addon_option_names = array(); |
|
| 180 | + self::$_instance->_initialize_config(); |
|
| 181 | + self::$_instance->update_espresso_config(); |
|
| 182 | + } |
|
| 183 | + self::$_instance->update_addon_option_names(); |
|
| 184 | + } |
|
| 185 | + self::$_instance = null; |
|
| 186 | + //we don't need to reset the static properties imo because those should |
|
| 187 | + //only change when a module is added or removed. Currently we don't |
|
| 188 | + //support removing a module during a request when it previously existed |
|
| 189 | + if ($reinstantiate) { |
|
| 190 | + return self::instance(); |
|
| 191 | + } else { |
|
| 192 | + return null; |
|
| 193 | + } |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + |
|
| 197 | + |
|
| 198 | + /** |
|
| 199 | + * class constructor |
|
| 200 | + * |
|
| 201 | + * @access private |
|
| 202 | + */ |
|
| 203 | + private function __construct() |
|
| 204 | + { |
|
| 205 | + do_action('AHEE__EE_Config__construct__begin', $this); |
|
| 206 | + EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false); |
|
| 207 | + // setup empty config classes |
|
| 208 | + $this->_initialize_config(); |
|
| 209 | + // load existing EE site settings |
|
| 210 | + $this->_load_core_config(); |
|
| 211 | + // confirm everything loaded correctly and set filtered defaults if not |
|
| 212 | + $this->_verify_config(); |
|
| 213 | + // register shortcodes and modules |
|
| 214 | + add_action( |
|
| 215 | + 'AHEE__EE_System__register_shortcodes_modules_and_widgets', |
|
| 216 | + array($this, 'register_shortcodes_and_modules'), |
|
| 217 | + 999 |
|
| 218 | + ); |
|
| 219 | + // initialize shortcodes and modules |
|
| 220 | + add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules')); |
|
| 221 | + // register widgets |
|
| 222 | + add_action('widgets_init', array($this, 'widgets_init'), 10); |
|
| 223 | + // shutdown |
|
| 224 | + add_action('shutdown', array($this, 'shutdown'), 10); |
|
| 225 | + // construct__end hook |
|
| 226 | + do_action('AHEE__EE_Config__construct__end', $this); |
|
| 227 | + // hardcoded hack |
|
| 228 | + $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014'; |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + |
|
| 232 | + |
|
| 233 | + /** |
|
| 234 | + * @return boolean |
|
| 235 | + */ |
|
| 236 | + public static function logging_enabled() |
|
| 237 | + { |
|
| 238 | + return self::$_logging_enabled; |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + |
|
| 242 | + |
|
| 243 | + /** |
|
| 244 | + * use to get the current theme if needed from static context |
|
| 245 | + * |
|
| 246 | + * @return string current theme set. |
|
| 247 | + */ |
|
| 248 | + public static function get_current_theme() |
|
| 249 | + { |
|
| 250 | + return isset(self::$_instance->template_settings->current_espresso_theme) |
|
| 251 | + ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014'; |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + |
|
| 255 | + |
|
| 256 | + /** |
|
| 257 | + * _initialize_config |
|
| 258 | + * |
|
| 259 | + * @access private |
|
| 260 | + * @return void |
|
| 261 | + */ |
|
| 262 | + private function _initialize_config() |
|
| 263 | + { |
|
| 264 | + EE_Config::trim_log(); |
|
| 265 | + //set defaults |
|
| 266 | + $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array()); |
|
| 267 | + $this->addons = new stdClass(); |
|
| 268 | + // set _module_route_map |
|
| 269 | + EE_Config::$_module_route_map = array(); |
|
| 270 | + // set _module_forward_map |
|
| 271 | + EE_Config::$_module_forward_map = array(); |
|
| 272 | + // set _module_view_map |
|
| 273 | + EE_Config::$_module_view_map = array(); |
|
| 274 | + } |
|
| 275 | + |
|
| 276 | + |
|
| 277 | + |
|
| 278 | + /** |
|
| 279 | + * load core plugin configuration |
|
| 280 | + * |
|
| 281 | + * @access private |
|
| 282 | + * @return void |
|
| 283 | + */ |
|
| 284 | + private function _load_core_config() |
|
| 285 | + { |
|
| 286 | + // load_core_config__start hook |
|
| 287 | + do_action('AHEE__EE_Config___load_core_config__start', $this); |
|
| 288 | + $espresso_config = $this->get_espresso_config(); |
|
| 289 | + foreach ($espresso_config as $config => $settings) { |
|
| 290 | + // load_core_config__start hook |
|
| 291 | + $settings = apply_filters( |
|
| 292 | + 'FHEE__EE_Config___load_core_config__config_settings', |
|
| 293 | + $settings, |
|
| 294 | + $config, |
|
| 295 | + $this |
|
| 296 | + ); |
|
| 297 | + if (is_object($settings) && property_exists($this, $config)) { |
|
| 298 | + $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings); |
|
| 299 | + //call configs populate method to ensure any defaults are set for empty values. |
|
| 300 | + if (method_exists($settings, 'populate')) { |
|
| 301 | + $this->{$config}->populate(); |
|
| 302 | + } |
|
| 303 | + if (method_exists($settings, 'do_hooks')) { |
|
| 304 | + $this->{$config}->do_hooks(); |
|
| 305 | + } |
|
| 306 | + } |
|
| 307 | + } |
|
| 308 | + if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) { |
|
| 309 | + $this->update_espresso_config(); |
|
| 310 | + } |
|
| 311 | + // load_core_config__end hook |
|
| 312 | + do_action('AHEE__EE_Config___load_core_config__end', $this); |
|
| 313 | + } |
|
| 314 | + |
|
| 315 | + |
|
| 316 | + |
|
| 317 | + /** |
|
| 318 | + * _verify_config |
|
| 319 | + * |
|
| 320 | + * @access protected |
|
| 321 | + * @return void |
|
| 322 | + */ |
|
| 323 | + protected function _verify_config() |
|
| 324 | + { |
|
| 325 | + $this->core = $this->core instanceof EE_Core_Config |
|
| 326 | + ? $this->core |
|
| 327 | + : new EE_Core_Config(); |
|
| 328 | + $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core); |
|
| 329 | + $this->organization = $this->organization instanceof EE_Organization_Config |
|
| 330 | + ? $this->organization |
|
| 331 | + : new EE_Organization_Config(); |
|
| 332 | + $this->organization = apply_filters( |
|
| 333 | + 'FHEE__EE_Config___initialize_config__organization', |
|
| 334 | + $this->organization |
|
| 335 | + ); |
|
| 336 | + $this->currency = $this->currency instanceof EE_Currency_Config |
|
| 337 | + ? $this->currency |
|
| 338 | + : new EE_Currency_Config(); |
|
| 339 | + $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency); |
|
| 340 | + $this->registration = $this->registration instanceof EE_Registration_Config |
|
| 341 | + ? $this->registration |
|
| 342 | + : new EE_Registration_Config(); |
|
| 343 | + $this->registration = apply_filters( |
|
| 344 | + 'FHEE__EE_Config___initialize_config__registration', |
|
| 345 | + $this->registration |
|
| 346 | + ); |
|
| 347 | + $this->admin = $this->admin instanceof EE_Admin_Config |
|
| 348 | + ? $this->admin |
|
| 349 | + : new EE_Admin_Config(); |
|
| 350 | + $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin); |
|
| 351 | + $this->template_settings = $this->template_settings instanceof EE_Template_Config |
|
| 352 | + ? $this->template_settings |
|
| 353 | + : new EE_Template_Config(); |
|
| 354 | + $this->template_settings = apply_filters( |
|
| 355 | + 'FHEE__EE_Config___initialize_config__template_settings', |
|
| 356 | + $this->template_settings |
|
| 357 | + ); |
|
| 358 | + $this->map_settings = $this->map_settings instanceof EE_Map_Config |
|
| 359 | + ? $this->map_settings |
|
| 360 | + : new EE_Map_Config(); |
|
| 361 | + $this->map_settings = apply_filters('FHEE__EE_Config___initialize_config__map_settings', |
|
| 362 | + $this->map_settings); |
|
| 363 | + $this->environment = $this->environment instanceof EE_Environment_Config |
|
| 364 | + ? $this->environment |
|
| 365 | + : new EE_Environment_Config(); |
|
| 366 | + $this->environment = apply_filters('FHEE__EE_Config___initialize_config__environment', |
|
| 367 | + $this->environment); |
|
| 368 | + $this->tax_settings = $this->tax_settings instanceof EE_Tax_Config |
|
| 369 | + ? $this->tax_settings |
|
| 370 | + : new EE_Tax_Config(); |
|
| 371 | + $this->tax_settings = apply_filters('FHEE__EE_Config___initialize_config__tax_settings', |
|
| 372 | + $this->tax_settings); |
|
| 373 | + $this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages); |
|
| 374 | + $this->messages = $this->messages instanceof EE_Messages_Config |
|
| 375 | + ? $this->messages |
|
| 376 | + : new EE_Messages_Config(); |
|
| 377 | + $this->gateway = $this->gateway instanceof EE_Gateway_Config |
|
| 378 | + ? $this->gateway |
|
| 379 | + : new EE_Gateway_Config(); |
|
| 380 | + $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway); |
|
| 381 | + $this->legacy_shortcodes_manager = null; |
|
| 382 | + } |
|
| 383 | + |
|
| 384 | + |
|
| 385 | + /** |
|
| 386 | + * get_espresso_config |
|
| 387 | + * |
|
| 388 | + * @access public |
|
| 389 | + * @return array of espresso config stuff |
|
| 390 | + */ |
|
| 391 | + public function get_espresso_config() |
|
| 392 | + { |
|
| 393 | + // grab espresso configuration |
|
| 394 | + return apply_filters( |
|
| 395 | + 'FHEE__EE_Config__get_espresso_config__CFG', |
|
| 396 | + get_option(EE_Config::OPTION_NAME, array()) |
|
| 397 | + ); |
|
| 398 | + } |
|
| 399 | + |
|
| 400 | + |
|
| 401 | + |
|
| 402 | + /** |
|
| 403 | + * double_check_config_comparison |
|
| 404 | + * |
|
| 405 | + * @access public |
|
| 406 | + * @param string $option |
|
| 407 | + * @param $old_value |
|
| 408 | + * @param $value |
|
| 409 | + */ |
|
| 410 | + public function double_check_config_comparison($option = '', $old_value, $value) |
|
| 411 | + { |
|
| 412 | + // make sure we're checking the ee config |
|
| 413 | + if ($option === EE_Config::OPTION_NAME) { |
|
| 414 | + // run a loose comparison of the old value against the new value for type and properties, |
|
| 415 | + // but NOT exact instance like WP update_option does (ie: NOT type safe comparison) |
|
| 416 | + if ($value != $old_value) { |
|
| 417 | + // if they are NOT the same, then remove the hook, |
|
| 418 | + // which means the subsequent update results will be based solely on the update query results |
|
| 419 | + // the reason we do this is because, as stated above, |
|
| 420 | + // WP update_option performs an exact instance comparison (===) on any update values passed to it |
|
| 421 | + // this happens PRIOR to serialization and any subsequent update. |
|
| 422 | + // If values are found to match their previous old value, |
|
| 423 | + // then WP bails before performing any update. |
|
| 424 | + // Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version |
|
| 425 | + // it just pulled from the db, with the one being passed to it (which will not match). |
|
| 426 | + // HOWEVER, once the object is serialized and passed off to MySQL to update, |
|
| 427 | + // MySQL MAY ALSO NOT perform the update because |
|
| 428 | + // the string it sees in the db looks the same as the new one it has been passed!!! |
|
| 429 | + // This results in the query returning an "affected rows" value of ZERO, |
|
| 430 | + // which gets returned immediately by WP update_option and looks like an error. |
|
| 431 | + remove_action('update_option', array($this, 'check_config_updated')); |
|
| 432 | + } |
|
| 433 | + } |
|
| 434 | + } |
|
| 435 | + |
|
| 436 | + |
|
| 437 | + |
|
| 438 | + /** |
|
| 439 | + * update_espresso_config |
|
| 440 | + * |
|
| 441 | + * @access public |
|
| 442 | + */ |
|
| 443 | + protected function _reset_espresso_addon_config() |
|
| 444 | + { |
|
| 445 | + $this->_addon_option_names = array(); |
|
| 446 | + foreach ($this->addons as $addon_name => $addon_config_obj) { |
|
| 447 | + $addon_config_obj = maybe_unserialize($addon_config_obj); |
|
| 448 | + if ($addon_config_obj instanceof EE_Config_Base) { |
|
| 449 | + $this->update_config('addons', $addon_name, $addon_config_obj, false); |
|
| 450 | + } |
|
| 451 | + $this->addons->{$addon_name} = null; |
|
| 452 | + } |
|
| 453 | + } |
|
| 454 | + |
|
| 455 | + |
|
| 456 | + |
|
| 457 | + /** |
|
| 458 | + * update_espresso_config |
|
| 459 | + * |
|
| 460 | + * @access public |
|
| 461 | + * @param bool $add_success |
|
| 462 | + * @param bool $add_error |
|
| 463 | + * @return bool |
|
| 464 | + */ |
|
| 465 | + public function update_espresso_config($add_success = false, $add_error = true) |
|
| 466 | + { |
|
| 467 | + // don't allow config updates during WP heartbeats |
|
| 468 | + if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') { |
|
| 469 | + return false; |
|
| 470 | + } |
|
| 471 | + // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197 |
|
| 472 | + //$clone = clone( self::$_instance ); |
|
| 473 | + //self::$_instance = NULL; |
|
| 474 | + do_action('AHEE__EE_Config__update_espresso_config__begin', $this); |
|
| 475 | + $this->_reset_espresso_addon_config(); |
|
| 476 | + // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional |
|
| 477 | + // but BEFORE the actual update occurs |
|
| 478 | + add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3); |
|
| 479 | + // don't want to persist legacy_shortcodes_manager, but don't want to lose it either |
|
| 480 | + $legacy_shortcodes_manager = $this->legacy_shortcodes_manager; |
|
| 481 | + $this->legacy_shortcodes_manager = null; |
|
| 482 | + // now update "ee_config" |
|
| 483 | + $saved = update_option(EE_Config::OPTION_NAME, $this); |
|
| 484 | + $this->legacy_shortcodes_manager = $legacy_shortcodes_manager; |
|
| 485 | + EE_Config::log(EE_Config::OPTION_NAME); |
|
| 486 | + // if not saved... check if the hook we just added still exists; |
|
| 487 | + // if it does, it means one of two things: |
|
| 488 | + // that update_option bailed at the ( $value === $old_value ) conditional, |
|
| 489 | + // or... |
|
| 490 | + // the db update query returned 0 rows affected |
|
| 491 | + // (probably because the data value was the same from it's perspective) |
|
| 492 | + // so the existence of the hook means that a negative result from update_option is NOT an error, |
|
| 493 | + // but just means no update occurred, so don't display an error to the user. |
|
| 494 | + // BUT... if update_option returns FALSE, AND the hook is missing, |
|
| 495 | + // then it means that something truly went wrong |
|
| 496 | + $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved; |
|
| 497 | + // remove our action since we don't want it in the system anymore |
|
| 498 | + remove_action('update_option', array($this, 'double_check_config_comparison'), 1); |
|
| 499 | + do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved); |
|
| 500 | + //self::$_instance = $clone; |
|
| 501 | + //unset( $clone ); |
|
| 502 | + // if config remains the same or was updated successfully |
|
| 503 | + if ($saved) { |
|
| 504 | + if ($add_success) { |
|
| 505 | + EE_Error::add_success( |
|
| 506 | + __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'), |
|
| 507 | + __FILE__, |
|
| 508 | + __FUNCTION__, |
|
| 509 | + __LINE__ |
|
| 510 | + ); |
|
| 511 | + } |
|
| 512 | + return true; |
|
| 513 | + } else { |
|
| 514 | + if ($add_error) { |
|
| 515 | + EE_Error::add_error( |
|
| 516 | + __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'), |
|
| 517 | + __FILE__, |
|
| 518 | + __FUNCTION__, |
|
| 519 | + __LINE__ |
|
| 520 | + ); |
|
| 521 | + } |
|
| 522 | + return false; |
|
| 523 | + } |
|
| 524 | + } |
|
| 525 | + |
|
| 526 | + |
|
| 527 | + |
|
| 528 | + /** |
|
| 529 | + * _verify_config_params |
|
| 530 | + * |
|
| 531 | + * @access private |
|
| 532 | + * @param string $section |
|
| 533 | + * @param string $name |
|
| 534 | + * @param string $config_class |
|
| 535 | + * @param EE_Config_Base $config_obj |
|
| 536 | + * @param array $tests_to_run |
|
| 537 | + * @param bool $display_errors |
|
| 538 | + * @return bool TRUE on success, FALSE on fail |
|
| 539 | + */ |
|
| 540 | + private function _verify_config_params( |
|
| 541 | + $section = '', |
|
| 542 | + $name = '', |
|
| 543 | + $config_class = '', |
|
| 544 | + $config_obj = null, |
|
| 545 | + $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8), |
|
| 546 | + $display_errors = true |
|
| 547 | + ) { |
|
| 548 | + try { |
|
| 549 | + foreach ($tests_to_run as $test) { |
|
| 550 | + switch ($test) { |
|
| 551 | + // TEST #1 : check that section was set |
|
| 552 | + case 1 : |
|
| 553 | + if (empty($section)) { |
|
| 554 | + if ($display_errors) { |
|
| 555 | + throw new EE_Error( |
|
| 556 | + sprintf( |
|
| 557 | + __( |
|
| 558 | + 'No configuration section has been provided while attempting to save "%s".', |
|
| 559 | + 'event_espresso' |
|
| 560 | + ), |
|
| 561 | + $config_class |
|
| 562 | + ) |
|
| 563 | + ); |
|
| 564 | + } |
|
| 565 | + return false; |
|
| 566 | + } |
|
| 567 | + break; |
|
| 568 | + // TEST #2 : check that settings section exists |
|
| 569 | + case 2 : |
|
| 570 | + if (! isset($this->{$section})) { |
|
| 571 | + if ($display_errors) { |
|
| 572 | + throw new EE_Error( |
|
| 573 | + sprintf( |
|
| 574 | + __('The "%s" configuration section does not exist.', 'event_espresso'), |
|
| 575 | + $section |
|
| 576 | + ) |
|
| 577 | + ); |
|
| 578 | + } |
|
| 579 | + return false; |
|
| 580 | + } |
|
| 581 | + break; |
|
| 582 | + // TEST #3 : check that section is the proper format |
|
| 583 | + case 3 : |
|
| 584 | + if ( |
|
| 585 | + ! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass) |
|
| 586 | + ) { |
|
| 587 | + if ($display_errors) { |
|
| 588 | + throw new EE_Error( |
|
| 589 | + sprintf( |
|
| 590 | + __( |
|
| 591 | + 'The "%s" configuration settings have not been formatted correctly.', |
|
| 592 | + 'event_espresso' |
|
| 593 | + ), |
|
| 594 | + $section |
|
| 595 | + ) |
|
| 596 | + ); |
|
| 597 | + } |
|
| 598 | + return false; |
|
| 599 | + } |
|
| 600 | + break; |
|
| 601 | + // TEST #4 : check that config section name has been set |
|
| 602 | + case 4 : |
|
| 603 | + if (empty($name)) { |
|
| 604 | + if ($display_errors) { |
|
| 605 | + throw new EE_Error( |
|
| 606 | + __( |
|
| 607 | + 'No name has been provided for the specific configuration section.', |
|
| 608 | + 'event_espresso' |
|
| 609 | + ) |
|
| 610 | + ); |
|
| 611 | + } |
|
| 612 | + return false; |
|
| 613 | + } |
|
| 614 | + break; |
|
| 615 | + // TEST #5 : check that a config class name has been set |
|
| 616 | + case 5 : |
|
| 617 | + if (empty($config_class)) { |
|
| 618 | + if ($display_errors) { |
|
| 619 | + throw new EE_Error( |
|
| 620 | + __( |
|
| 621 | + 'No class name has been provided for the specific configuration section.', |
|
| 622 | + 'event_espresso' |
|
| 623 | + ) |
|
| 624 | + ); |
|
| 625 | + } |
|
| 626 | + return false; |
|
| 627 | + } |
|
| 628 | + break; |
|
| 629 | + // TEST #6 : verify config class is accessible |
|
| 630 | + case 6 : |
|
| 631 | + if (! class_exists($config_class)) { |
|
| 632 | + if ($display_errors) { |
|
| 633 | + throw new EE_Error( |
|
| 634 | + sprintf( |
|
| 635 | + __( |
|
| 636 | + 'The "%s" class does not exist. Please ensure that an autoloader has been set for it.', |
|
| 637 | + 'event_espresso' |
|
| 638 | + ), |
|
| 639 | + $config_class |
|
| 640 | + ) |
|
| 641 | + ); |
|
| 642 | + } |
|
| 643 | + return false; |
|
| 644 | + } |
|
| 645 | + break; |
|
| 646 | + // TEST #7 : check that config has even been set |
|
| 647 | + case 7 : |
|
| 648 | + if (! isset($this->{$section}->{$name})) { |
|
| 649 | + if ($display_errors) { |
|
| 650 | + throw new EE_Error( |
|
| 651 | + sprintf( |
|
| 652 | + __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'), |
|
| 653 | + $section, |
|
| 654 | + $name |
|
| 655 | + ) |
|
| 656 | + ); |
|
| 657 | + } |
|
| 658 | + return false; |
|
| 659 | + } else { |
|
| 660 | + // and make sure it's not serialized |
|
| 661 | + $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name}); |
|
| 662 | + } |
|
| 663 | + break; |
|
| 664 | + // TEST #8 : check that config is the requested type |
|
| 665 | + case 8 : |
|
| 666 | + if (! $this->{$section}->{$name} instanceof $config_class) { |
|
| 667 | + if ($display_errors) { |
|
| 668 | + throw new EE_Error( |
|
| 669 | + sprintf( |
|
| 670 | + __( |
|
| 671 | + 'The configuration for "%1$s->%2$s" is not of the "%3$s" class.', |
|
| 672 | + 'event_espresso' |
|
| 673 | + ), |
|
| 674 | + $section, |
|
| 675 | + $name, |
|
| 676 | + $config_class |
|
| 677 | + ) |
|
| 678 | + ); |
|
| 679 | + } |
|
| 680 | + return false; |
|
| 681 | + } |
|
| 682 | + break; |
|
| 683 | + // TEST #9 : verify config object |
|
| 684 | + case 9 : |
|
| 685 | + if (! $config_obj instanceof EE_Config_Base) { |
|
| 686 | + if ($display_errors) { |
|
| 687 | + throw new EE_Error( |
|
| 688 | + sprintf( |
|
| 689 | + __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'), |
|
| 690 | + print_r($config_obj, true) |
|
| 691 | + ) |
|
| 692 | + ); |
|
| 693 | + } |
|
| 694 | + return false; |
|
| 695 | + } |
|
| 696 | + break; |
|
| 697 | + } |
|
| 698 | + } |
|
| 699 | + } catch (EE_Error $e) { |
|
| 700 | + $e->get_error(); |
|
| 701 | + } |
|
| 702 | + // you have successfully run the gauntlet |
|
| 703 | + return true; |
|
| 704 | + } |
|
| 705 | + |
|
| 706 | + |
|
| 707 | + |
|
| 708 | + /** |
|
| 709 | + * _generate_config_option_name |
|
| 710 | + * |
|
| 711 | + * @access protected |
|
| 712 | + * @param string $section |
|
| 713 | + * @param string $name |
|
| 714 | + * @return string |
|
| 715 | + */ |
|
| 716 | + private function _generate_config_option_name($section = '', $name = '') |
|
| 717 | + { |
|
| 718 | + return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name)); |
|
| 719 | + } |
|
| 720 | + |
|
| 721 | + |
|
| 722 | + |
|
| 723 | + /** |
|
| 724 | + * _set_config_class |
|
| 725 | + * ensures that a config class is set, either from a passed config class or one generated from the config name |
|
| 726 | + * |
|
| 727 | + * @access private |
|
| 728 | + * @param string $config_class |
|
| 729 | + * @param string $name |
|
| 730 | + * @return string |
|
| 731 | + */ |
|
| 732 | + private function _set_config_class($config_class = '', $name = '') |
|
| 733 | + { |
|
| 734 | + return ! empty($config_class) |
|
| 735 | + ? $config_class |
|
| 736 | + : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config'; |
|
| 737 | + } |
|
| 738 | + |
|
| 739 | + |
|
| 740 | + |
|
| 741 | + /** |
|
| 742 | + * set_config |
|
| 743 | + * |
|
| 744 | + * @access protected |
|
| 745 | + * @param string $section |
|
| 746 | + * @param string $name |
|
| 747 | + * @param string $config_class |
|
| 748 | + * @param EE_Config_Base $config_obj |
|
| 749 | + * @return EE_Config_Base |
|
| 750 | + */ |
|
| 751 | + public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null) |
|
| 752 | + { |
|
| 753 | + // ensure config class is set to something |
|
| 754 | + $config_class = $this->_set_config_class($config_class, $name); |
|
| 755 | + // run tests 1-4, 6, and 7 to verify all config params are set and valid |
|
| 756 | + if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
| 757 | + return null; |
|
| 758 | + } |
|
| 759 | + $config_option_name = $this->_generate_config_option_name($section, $name); |
|
| 760 | + // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now |
|
| 761 | + if (! isset($this->_addon_option_names[$config_option_name])) { |
|
| 762 | + $this->_addon_option_names[$config_option_name] = $config_class; |
|
| 763 | + $this->update_addon_option_names(); |
|
| 764 | + } |
|
| 765 | + // verify the incoming config object but suppress errors |
|
| 766 | + if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
| 767 | + $config_obj = new $config_class(); |
|
| 768 | + } |
|
| 769 | + if (get_option($config_option_name)) { |
|
| 770 | + EE_Config::log($config_option_name); |
|
| 771 | + update_option($config_option_name, $config_obj); |
|
| 772 | + $this->{$section}->{$name} = $config_obj; |
|
| 773 | + return $this->{$section}->{$name}; |
|
| 774 | + } else { |
|
| 775 | + // create a wp-option for this config |
|
| 776 | + if (add_option($config_option_name, $config_obj, '', 'no')) { |
|
| 777 | + $this->{$section}->{$name} = maybe_unserialize($config_obj); |
|
| 778 | + return $this->{$section}->{$name}; |
|
| 779 | + } else { |
|
| 780 | + EE_Error::add_error( |
|
| 781 | + sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class), |
|
| 782 | + __FILE__, |
|
| 783 | + __FUNCTION__, |
|
| 784 | + __LINE__ |
|
| 785 | + ); |
|
| 786 | + return null; |
|
| 787 | + } |
|
| 788 | + } |
|
| 789 | + } |
|
| 790 | + |
|
| 791 | + |
|
| 792 | + |
|
| 793 | + /** |
|
| 794 | + * update_config |
|
| 795 | + * Important: the config object must ALREADY be set, otherwise this will produce an error. |
|
| 796 | + * |
|
| 797 | + * @access public |
|
| 798 | + * @param string $section |
|
| 799 | + * @param string $name |
|
| 800 | + * @param EE_Config_Base|string $config_obj |
|
| 801 | + * @param bool $throw_errors |
|
| 802 | + * @return bool |
|
| 803 | + */ |
|
| 804 | + public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true) |
|
| 805 | + { |
|
| 806 | + // don't allow config updates during WP heartbeats |
|
| 807 | + if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') { |
|
| 808 | + return false; |
|
| 809 | + } |
|
| 810 | + $config_obj = maybe_unserialize($config_obj); |
|
| 811 | + // get class name of the incoming object |
|
| 812 | + $config_class = get_class($config_obj); |
|
| 813 | + // run tests 1-5 and 9 to verify config |
|
| 814 | + if (! $this->_verify_config_params( |
|
| 815 | + $section, |
|
| 816 | + $name, |
|
| 817 | + $config_class, |
|
| 818 | + $config_obj, |
|
| 819 | + array(1, 2, 3, 4, 7, 9) |
|
| 820 | + ) |
|
| 821 | + ) { |
|
| 822 | + return false; |
|
| 823 | + } |
|
| 824 | + $config_option_name = $this->_generate_config_option_name($section, $name); |
|
| 825 | + // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array |
|
| 826 | + if (! isset($this->_addon_option_names[$config_option_name])) { |
|
| 827 | + // save new config to db |
|
| 828 | + if ($this->set_config($section, $name, $config_class, $config_obj)) { |
|
| 829 | + return true; |
|
| 830 | + } |
|
| 831 | + } else { |
|
| 832 | + // first check if the record already exists |
|
| 833 | + $existing_config = get_option($config_option_name); |
|
| 834 | + $config_obj = serialize($config_obj); |
|
| 835 | + // just return if db record is already up to date (NOT type safe comparison) |
|
| 836 | + if ($existing_config == $config_obj) { |
|
| 837 | + $this->{$section}->{$name} = $config_obj; |
|
| 838 | + return true; |
|
| 839 | + } else if (update_option($config_option_name, $config_obj)) { |
|
| 840 | + EE_Config::log($config_option_name); |
|
| 841 | + // update wp-option for this config class |
|
| 842 | + $this->{$section}->{$name} = $config_obj; |
|
| 843 | + return true; |
|
| 844 | + } elseif ($throw_errors) { |
|
| 845 | + EE_Error::add_error( |
|
| 846 | + sprintf( |
|
| 847 | + __( |
|
| 848 | + 'The "%1$s" object stored at"%2$s" was not successfully updated in the database.', |
|
| 849 | + 'event_espresso' |
|
| 850 | + ), |
|
| 851 | + $config_class, |
|
| 852 | + 'EE_Config->' . $section . '->' . $name |
|
| 853 | + ), |
|
| 854 | + __FILE__, |
|
| 855 | + __FUNCTION__, |
|
| 856 | + __LINE__ |
|
| 857 | + ); |
|
| 858 | + } |
|
| 859 | + } |
|
| 860 | + return false; |
|
| 861 | + } |
|
| 862 | + |
|
| 863 | + |
|
| 864 | + |
|
| 865 | + /** |
|
| 866 | + * get_config |
|
| 867 | + * |
|
| 868 | + * @access public |
|
| 869 | + * @param string $section |
|
| 870 | + * @param string $name |
|
| 871 | + * @param string $config_class |
|
| 872 | + * @return mixed EE_Config_Base | NULL |
|
| 873 | + */ |
|
| 874 | + public function get_config($section = '', $name = '', $config_class = '') |
|
| 875 | + { |
|
| 876 | + // ensure config class is set to something |
|
| 877 | + $config_class = $this->_set_config_class($config_class, $name); |
|
| 878 | + // run tests 1-4, 6 and 7 to verify that all params have been set |
|
| 879 | + if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
| 880 | + return null; |
|
| 881 | + } |
|
| 882 | + // now test if the requested config object exists, but suppress errors |
|
| 883 | + if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) { |
|
| 884 | + // config already exists, so pass it back |
|
| 885 | + return $this->{$section}->{$name}; |
|
| 886 | + } |
|
| 887 | + // load config option from db if it exists |
|
| 888 | + $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name)); |
|
| 889 | + // verify the newly retrieved config object, but suppress errors |
|
| 890 | + if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
| 891 | + // config is good, so set it and pass it back |
|
| 892 | + $this->{$section}->{$name} = $config_obj; |
|
| 893 | + return $this->{$section}->{$name}; |
|
| 894 | + } |
|
| 895 | + // oops! $config_obj is not already set and does not exist in the db, so create a new one |
|
| 896 | + $config_obj = $this->set_config($section, $name, $config_class); |
|
| 897 | + // verify the newly created config object |
|
| 898 | + if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) { |
|
| 899 | + return $this->{$section}->{$name}; |
|
| 900 | + } else { |
|
| 901 | + EE_Error::add_error( |
|
| 902 | + sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class), |
|
| 903 | + __FILE__, |
|
| 904 | + __FUNCTION__, |
|
| 905 | + __LINE__ |
|
| 906 | + ); |
|
| 907 | + } |
|
| 908 | + return null; |
|
| 909 | + } |
|
| 910 | + |
|
| 911 | + |
|
| 912 | + |
|
| 913 | + /** |
|
| 914 | + * get_config_option |
|
| 915 | + * |
|
| 916 | + * @access public |
|
| 917 | + * @param string $config_option_name |
|
| 918 | + * @return mixed EE_Config_Base | FALSE |
|
| 919 | + */ |
|
| 920 | + public function get_config_option($config_option_name = '') |
|
| 921 | + { |
|
| 922 | + // retrieve the wp-option for this config class. |
|
| 923 | + $config_option = maybe_unserialize(get_option($config_option_name, array())); |
|
| 924 | + if (empty($config_option)) { |
|
| 925 | + EE_Config::log($config_option_name . '-NOT-FOUND'); |
|
| 926 | + } |
|
| 927 | + return $config_option; |
|
| 928 | + } |
|
| 929 | + |
|
| 930 | + |
|
| 931 | + |
|
| 932 | + /** |
|
| 933 | + * log |
|
| 934 | + * |
|
| 935 | + * @param string $config_option_name |
|
| 936 | + */ |
|
| 937 | + public static function log($config_option_name = '') |
|
| 938 | + { |
|
| 939 | + if (EE_Config::logging_enabled() && ! empty($config_option_name)) { |
|
| 940 | + $config_log = get_option(EE_Config::LOG_NAME, array()); |
|
| 941 | + //copy incoming $_REQUEST and sanitize it so we can save it |
|
| 942 | + $_request = $_REQUEST; |
|
| 943 | + array_walk_recursive($_request, 'sanitize_text_field'); |
|
| 944 | + $config_log[(string)microtime(true)] = array( |
|
| 945 | + 'config_name' => $config_option_name, |
|
| 946 | + 'request' => $_request, |
|
| 947 | + ); |
|
| 948 | + update_option(EE_Config::LOG_NAME, $config_log); |
|
| 949 | + } |
|
| 950 | + } |
|
| 951 | + |
|
| 952 | + |
|
| 953 | + |
|
| 954 | + /** |
|
| 955 | + * trim_log |
|
| 956 | + * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH |
|
| 957 | + */ |
|
| 958 | + public static function trim_log() |
|
| 959 | + { |
|
| 960 | + if (! EE_Config::logging_enabled()) { |
|
| 961 | + return; |
|
| 962 | + } |
|
| 963 | + $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array())); |
|
| 964 | + $log_length = count($config_log); |
|
| 965 | + if ($log_length > EE_Config::LOG_LENGTH) { |
|
| 966 | + ksort($config_log); |
|
| 967 | + $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true); |
|
| 968 | + update_option(EE_Config::LOG_NAME, $config_log); |
|
| 969 | + } |
|
| 970 | + } |
|
| 971 | + |
|
| 972 | + |
|
| 973 | + |
|
| 974 | + /** |
|
| 975 | + * get_page_for_posts |
|
| 976 | + * if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the |
|
| 977 | + * wp-option "page_for_posts", or "posts" if no page is selected |
|
| 978 | + * |
|
| 979 | + * @access public |
|
| 980 | + * @return string |
|
| 981 | + */ |
|
| 982 | + public static function get_page_for_posts() |
|
| 983 | + { |
|
| 984 | + $page_for_posts = get_option('page_for_posts'); |
|
| 985 | + if (! $page_for_posts) { |
|
| 986 | + return 'posts'; |
|
| 987 | + } |
|
| 988 | + /** @type WPDB $wpdb */ |
|
| 989 | + global $wpdb; |
|
| 990 | + $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d"; |
|
| 991 | + return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts)); |
|
| 992 | + } |
|
| 993 | + |
|
| 994 | + |
|
| 995 | + |
|
| 996 | + /** |
|
| 997 | + * register_shortcodes_and_modules. |
|
| 998 | + * At this point, it's too early to tell if we're maintenance mode or not. |
|
| 999 | + * In fact, this is where we give modules a chance to let core know they exist |
|
| 1000 | + * so they can help trigger maintenance mode if it's needed |
|
| 1001 | + * |
|
| 1002 | + * @access public |
|
| 1003 | + * @return void |
|
| 1004 | + */ |
|
| 1005 | + public function register_shortcodes_and_modules() |
|
| 1006 | + { |
|
| 1007 | + // allow modules to set hooks for the rest of the system |
|
| 1008 | + EE_Registry::instance()->modules = $this->_register_modules(); |
|
| 1009 | + } |
|
| 1010 | + |
|
| 1011 | + |
|
| 1012 | + |
|
| 1013 | + /** |
|
| 1014 | + * initialize_shortcodes_and_modules |
|
| 1015 | + * meaning they can start adding their hooks to get stuff done |
|
| 1016 | + * |
|
| 1017 | + * @access public |
|
| 1018 | + * @return void |
|
| 1019 | + */ |
|
| 1020 | + public function initialize_shortcodes_and_modules() |
|
| 1021 | + { |
|
| 1022 | + // allow modules to set hooks for the rest of the system |
|
| 1023 | + $this->_initialize_modules(); |
|
| 1024 | + } |
|
| 1025 | + |
|
| 1026 | + |
|
| 1027 | + |
|
| 1028 | + /** |
|
| 1029 | + * widgets_init |
|
| 1030 | + * |
|
| 1031 | + * @access private |
|
| 1032 | + * @return void |
|
| 1033 | + */ |
|
| 1034 | + public function widgets_init() |
|
| 1035 | + { |
|
| 1036 | + //only init widgets on admin pages when not in complete maintenance, and |
|
| 1037 | + //on frontend when not in any maintenance mode |
|
| 1038 | + if ( |
|
| 1039 | + ! EE_Maintenance_Mode::instance()->level() |
|
| 1040 | + || ( |
|
| 1041 | + is_admin() |
|
| 1042 | + && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance |
|
| 1043 | + ) |
|
| 1044 | + ) { |
|
| 1045 | + // grab list of installed widgets |
|
| 1046 | + $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR); |
|
| 1047 | + // filter list of modules to register |
|
| 1048 | + $widgets_to_register = apply_filters( |
|
| 1049 | + 'FHEE__EE_Config__register_widgets__widgets_to_register', |
|
| 1050 | + $widgets_to_register |
|
| 1051 | + ); |
|
| 1052 | + if (! empty($widgets_to_register)) { |
|
| 1053 | + // cycle thru widget folders |
|
| 1054 | + foreach ($widgets_to_register as $widget_path) { |
|
| 1055 | + // add to list of installed widget modules |
|
| 1056 | + EE_Config::register_ee_widget($widget_path); |
|
| 1057 | + } |
|
| 1058 | + } |
|
| 1059 | + // filter list of installed modules |
|
| 1060 | + EE_Registry::instance()->widgets = apply_filters( |
|
| 1061 | + 'FHEE__EE_Config__register_widgets__installed_widgets', |
|
| 1062 | + EE_Registry::instance()->widgets |
|
| 1063 | + ); |
|
| 1064 | + } |
|
| 1065 | + } |
|
| 1066 | + |
|
| 1067 | + |
|
| 1068 | + |
|
| 1069 | + /** |
|
| 1070 | + * register_ee_widget - makes core aware of this widget |
|
| 1071 | + * |
|
| 1072 | + * @access public |
|
| 1073 | + * @param string $widget_path - full path up to and including widget folder |
|
| 1074 | + * @return void |
|
| 1075 | + */ |
|
| 1076 | + public static function register_ee_widget($widget_path = null) |
|
| 1077 | + { |
|
| 1078 | + do_action('AHEE__EE_Config__register_widget__begin', $widget_path); |
|
| 1079 | + $widget_ext = '.widget.php'; |
|
| 1080 | + // make all separators match |
|
| 1081 | + $widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS); |
|
| 1082 | + // does the file path INCLUDE the actual file name as part of the path ? |
|
| 1083 | + if (strpos($widget_path, $widget_ext) !== false) { |
|
| 1084 | + // grab and shortcode file name from directory name and break apart at dots |
|
| 1085 | + $file_name = explode('.', basename($widget_path)); |
|
| 1086 | + // take first segment from file name pieces and remove class prefix if it exists |
|
| 1087 | + $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0]; |
|
| 1088 | + // sanitize shortcode directory name |
|
| 1089 | + $widget = sanitize_key($widget); |
|
| 1090 | + // now we need to rebuild the shortcode path |
|
| 1091 | + $widget_path = explode(DS, $widget_path); |
|
| 1092 | + // remove last segment |
|
| 1093 | + array_pop($widget_path); |
|
| 1094 | + // glue it back together |
|
| 1095 | + $widget_path = implode(DS, $widget_path); |
|
| 1096 | + } else { |
|
| 1097 | + // grab and sanitize widget directory name |
|
| 1098 | + $widget = sanitize_key(basename($widget_path)); |
|
| 1099 | + } |
|
| 1100 | + // create classname from widget directory name |
|
| 1101 | + $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget))); |
|
| 1102 | + // add class prefix |
|
| 1103 | + $widget_class = 'EEW_' . $widget; |
|
| 1104 | + // does the widget exist ? |
|
| 1105 | + if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) { |
|
| 1106 | + $msg = sprintf( |
|
| 1107 | + __( |
|
| 1108 | + 'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', |
|
| 1109 | + 'event_espresso' |
|
| 1110 | + ), |
|
| 1111 | + $widget_class, |
|
| 1112 | + $widget_path . DS . $widget_class . $widget_ext |
|
| 1113 | + ); |
|
| 1114 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1115 | + return; |
|
| 1116 | + } |
|
| 1117 | + // load the widget class file |
|
| 1118 | + require_once($widget_path . DS . $widget_class . $widget_ext); |
|
| 1119 | + // verify that class exists |
|
| 1120 | + if (! class_exists($widget_class)) { |
|
| 1121 | + $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class); |
|
| 1122 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1123 | + return; |
|
| 1124 | + } |
|
| 1125 | + register_widget($widget_class); |
|
| 1126 | + // add to array of registered widgets |
|
| 1127 | + EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext; |
|
| 1128 | + } |
|
| 1129 | + |
|
| 1130 | + |
|
| 1131 | + |
|
| 1132 | + /** |
|
| 1133 | + * _register_modules |
|
| 1134 | + * |
|
| 1135 | + * @access private |
|
| 1136 | + * @return array |
|
| 1137 | + */ |
|
| 1138 | + private function _register_modules() |
|
| 1139 | + { |
|
| 1140 | + // grab list of installed modules |
|
| 1141 | + $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR); |
|
| 1142 | + // filter list of modules to register |
|
| 1143 | + $modules_to_register = apply_filters( |
|
| 1144 | + 'FHEE__EE_Config__register_modules__modules_to_register', |
|
| 1145 | + $modules_to_register |
|
| 1146 | + ); |
|
| 1147 | + if (! empty($modules_to_register)) { |
|
| 1148 | + // loop through folders |
|
| 1149 | + foreach ($modules_to_register as $module_path) { |
|
| 1150 | + /**TEMPORARILY EXCLUDE gateways from modules for time being**/ |
|
| 1151 | + if ( |
|
| 1152 | + $module_path !== EE_MODULES . 'zzz-copy-this-module-template' |
|
| 1153 | + && $module_path !== EE_MODULES . 'gateways' |
|
| 1154 | + ) { |
|
| 1155 | + // add to list of installed modules |
|
| 1156 | + EE_Config::register_module($module_path); |
|
| 1157 | + } |
|
| 1158 | + } |
|
| 1159 | + } |
|
| 1160 | + // filter list of installed modules |
|
| 1161 | + return apply_filters( |
|
| 1162 | + 'FHEE__EE_Config___register_modules__installed_modules', |
|
| 1163 | + EE_Registry::instance()->modules |
|
| 1164 | + ); |
|
| 1165 | + } |
|
| 1166 | + |
|
| 1167 | + |
|
| 1168 | + |
|
| 1169 | + /** |
|
| 1170 | + * register_module - makes core aware of this module |
|
| 1171 | + * |
|
| 1172 | + * @access public |
|
| 1173 | + * @param string $module_path - full path up to and including module folder |
|
| 1174 | + * @return bool |
|
| 1175 | + */ |
|
| 1176 | + public static function register_module($module_path = null) |
|
| 1177 | + { |
|
| 1178 | + do_action('AHEE__EE_Config__register_module__begin', $module_path); |
|
| 1179 | + $module_ext = '.module.php'; |
|
| 1180 | + // make all separators match |
|
| 1181 | + $module_path = str_replace(array('\\', '/'), DS, $module_path); |
|
| 1182 | + // does the file path INCLUDE the actual file name as part of the path ? |
|
| 1183 | + if (strpos($module_path, $module_ext) !== false) { |
|
| 1184 | + // grab and shortcode file name from directory name and break apart at dots |
|
| 1185 | + $module_file = explode('.', basename($module_path)); |
|
| 1186 | + // now we need to rebuild the shortcode path |
|
| 1187 | + $module_path = explode(DS, $module_path); |
|
| 1188 | + // remove last segment |
|
| 1189 | + array_pop($module_path); |
|
| 1190 | + // glue it back together |
|
| 1191 | + $module_path = implode(DS, $module_path) . DS; |
|
| 1192 | + // take first segment from file name pieces and sanitize it |
|
| 1193 | + $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]); |
|
| 1194 | + // ensure class prefix is added |
|
| 1195 | + $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module; |
|
| 1196 | + } else { |
|
| 1197 | + // we need to generate the filename based off of the folder name |
|
| 1198 | + // grab and sanitize module name |
|
| 1199 | + $module = strtolower(basename($module_path)); |
|
| 1200 | + $module = preg_replace('/[^a-z0-9_\-]/', '', $module); |
|
| 1201 | + // like trailingslashit() |
|
| 1202 | + $module_path = rtrim($module_path, DS) . DS; |
|
| 1203 | + // create classname from module directory name |
|
| 1204 | + $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module))); |
|
| 1205 | + // add class prefix |
|
| 1206 | + $module_class = 'EED_' . $module; |
|
| 1207 | + } |
|
| 1208 | + // does the module exist ? |
|
| 1209 | + if (! is_readable($module_path . DS . $module_class . $module_ext)) { |
|
| 1210 | + $msg = sprintf( |
|
| 1211 | + __( |
|
| 1212 | + 'The requested %s module file could not be found or is not readable due to file permissions.', |
|
| 1213 | + 'event_espresso' |
|
| 1214 | + ), |
|
| 1215 | + $module |
|
| 1216 | + ); |
|
| 1217 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1218 | + return false; |
|
| 1219 | + } |
|
| 1220 | + // load the module class file |
|
| 1221 | + require_once($module_path . $module_class . $module_ext); |
|
| 1222 | + // verify that class exists |
|
| 1223 | + if (! class_exists($module_class)) { |
|
| 1224 | + $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class); |
|
| 1225 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1226 | + return false; |
|
| 1227 | + } |
|
| 1228 | + // add to array of registered modules |
|
| 1229 | + EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext; |
|
| 1230 | + do_action( |
|
| 1231 | + 'AHEE__EE_Config__register_module__complete', |
|
| 1232 | + $module_class, |
|
| 1233 | + EE_Registry::instance()->modules->{$module_class} |
|
| 1234 | + ); |
|
| 1235 | + return true; |
|
| 1236 | + } |
|
| 1237 | + |
|
| 1238 | + |
|
| 1239 | + |
|
| 1240 | + /** |
|
| 1241 | + * _initialize_modules |
|
| 1242 | + * allow modules to set hooks for the rest of the system |
|
| 1243 | + * |
|
| 1244 | + * @access private |
|
| 1245 | + * @return void |
|
| 1246 | + */ |
|
| 1247 | + private function _initialize_modules() |
|
| 1248 | + { |
|
| 1249 | + // cycle thru shortcode folders |
|
| 1250 | + foreach (EE_Registry::instance()->modules as $module_class => $module_path) { |
|
| 1251 | + // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
|
| 1252 | + // which set hooks ? |
|
| 1253 | + if (is_admin()) { |
|
| 1254 | + // fire immediately |
|
| 1255 | + call_user_func(array($module_class, 'set_hooks_admin')); |
|
| 1256 | + } else { |
|
| 1257 | + // delay until other systems are online |
|
| 1258 | + add_action( |
|
| 1259 | + 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', |
|
| 1260 | + array($module_class, 'set_hooks') |
|
| 1261 | + ); |
|
| 1262 | + } |
|
| 1263 | + } |
|
| 1264 | + } |
|
| 1265 | + |
|
| 1266 | + |
|
| 1267 | + |
|
| 1268 | + /** |
|
| 1269 | + * register_route - adds module method routes to route_map |
|
| 1270 | + * |
|
| 1271 | + * @access public |
|
| 1272 | + * @param string $route - "pretty" public alias for module method |
|
| 1273 | + * @param string $module - module name (classname without EED_ prefix) |
|
| 1274 | + * @param string $method_name - the actual module method to be routed to |
|
| 1275 | + * @param string $key - url param key indicating a route is being called |
|
| 1276 | + * @return bool |
|
| 1277 | + */ |
|
| 1278 | + public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee') |
|
| 1279 | + { |
|
| 1280 | + do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name); |
|
| 1281 | + $module = str_replace('EED_', '', $module); |
|
| 1282 | + $module_class = 'EED_' . $module; |
|
| 1283 | + if (! isset(EE_Registry::instance()->modules->{$module_class})) { |
|
| 1284 | + $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module); |
|
| 1285 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1286 | + return false; |
|
| 1287 | + } |
|
| 1288 | + if (empty($route)) { |
|
| 1289 | + $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route); |
|
| 1290 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1291 | + return false; |
|
| 1292 | + } |
|
| 1293 | + if (! method_exists('EED_' . $module, $method_name)) { |
|
| 1294 | + $msg = sprintf( |
|
| 1295 | + __('A valid class method for the %s route has not been supplied.', 'event_espresso'), |
|
| 1296 | + $route |
|
| 1297 | + ); |
|
| 1298 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1299 | + return false; |
|
| 1300 | + } |
|
| 1301 | + EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name); |
|
| 1302 | + return true; |
|
| 1303 | + } |
|
| 1304 | + |
|
| 1305 | + |
|
| 1306 | + |
|
| 1307 | + /** |
|
| 1308 | + * get_route - get module method route |
|
| 1309 | + * |
|
| 1310 | + * @access public |
|
| 1311 | + * @param string $route - "pretty" public alias for module method |
|
| 1312 | + * @param string $key - url param key indicating a route is being called |
|
| 1313 | + * @return string |
|
| 1314 | + */ |
|
| 1315 | + public static function get_route($route = null, $key = 'ee') |
|
| 1316 | + { |
|
| 1317 | + do_action('AHEE__EE_Config__get_route__begin', $route); |
|
| 1318 | + $route = (string)apply_filters('FHEE__EE_Config__get_route', $route); |
|
| 1319 | + if (isset(EE_Config::$_module_route_map[$key][$route])) { |
|
| 1320 | + return EE_Config::$_module_route_map[$key][$route]; |
|
| 1321 | + } |
|
| 1322 | + return null; |
|
| 1323 | + } |
|
| 1324 | + |
|
| 1325 | + |
|
| 1326 | + |
|
| 1327 | + /** |
|
| 1328 | + * get_routes - get ALL module method routes |
|
| 1329 | + * |
|
| 1330 | + * @access public |
|
| 1331 | + * @return array |
|
| 1332 | + */ |
|
| 1333 | + public static function get_routes() |
|
| 1334 | + { |
|
| 1335 | + return EE_Config::$_module_route_map; |
|
| 1336 | + } |
|
| 1337 | + |
|
| 1338 | + |
|
| 1339 | + |
|
| 1340 | + /** |
|
| 1341 | + * register_forward - allows modules to forward request to another module for further processing |
|
| 1342 | + * |
|
| 1343 | + * @access public |
|
| 1344 | + * @param string $route - "pretty" public alias for module method |
|
| 1345 | + * @param integer $status - integer value corresponding to status constant strings set in module parent |
|
| 1346 | + * class, allows different forwards to be served based on status |
|
| 1347 | + * @param array|string $forward - function name or array( class, method ) |
|
| 1348 | + * @param string $key - url param key indicating a route is being called |
|
| 1349 | + * @return bool |
|
| 1350 | + */ |
|
| 1351 | + public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee') |
|
| 1352 | + { |
|
| 1353 | + do_action('AHEE__EE_Config__register_forward', $route, $status, $forward); |
|
| 1354 | + if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
| 1355 | + $msg = sprintf( |
|
| 1356 | + __('The module route %s for this forward has not been registered.', 'event_espresso'), |
|
| 1357 | + $route |
|
| 1358 | + ); |
|
| 1359 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1360 | + return false; |
|
| 1361 | + } |
|
| 1362 | + if (empty($forward)) { |
|
| 1363 | + $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route); |
|
| 1364 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1365 | + return false; |
|
| 1366 | + } |
|
| 1367 | + if (is_array($forward)) { |
|
| 1368 | + if (! isset($forward[1])) { |
|
| 1369 | + $msg = sprintf( |
|
| 1370 | + __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'), |
|
| 1371 | + $route |
|
| 1372 | + ); |
|
| 1373 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1374 | + return false; |
|
| 1375 | + } |
|
| 1376 | + if (! method_exists($forward[0], $forward[1])) { |
|
| 1377 | + $msg = sprintf( |
|
| 1378 | + __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'), |
|
| 1379 | + $forward[1], |
|
| 1380 | + $route |
|
| 1381 | + ); |
|
| 1382 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1383 | + return false; |
|
| 1384 | + } |
|
| 1385 | + } else if (! function_exists($forward)) { |
|
| 1386 | + $msg = sprintf( |
|
| 1387 | + __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'), |
|
| 1388 | + $forward, |
|
| 1389 | + $route |
|
| 1390 | + ); |
|
| 1391 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1392 | + return false; |
|
| 1393 | + } |
|
| 1394 | + EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward; |
|
| 1395 | + return true; |
|
| 1396 | + } |
|
| 1397 | + |
|
| 1398 | + |
|
| 1399 | + |
|
| 1400 | + /** |
|
| 1401 | + * get_forward - get forwarding route |
|
| 1402 | + * |
|
| 1403 | + * @access public |
|
| 1404 | + * @param string $route - "pretty" public alias for module method |
|
| 1405 | + * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
| 1406 | + * allows different forwards to be served based on status |
|
| 1407 | + * @param string $key - url param key indicating a route is being called |
|
| 1408 | + * @return string |
|
| 1409 | + */ |
|
| 1410 | + public static function get_forward($route = null, $status = 0, $key = 'ee') |
|
| 1411 | + { |
|
| 1412 | + do_action('AHEE__EE_Config__get_forward__begin', $route, $status); |
|
| 1413 | + if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) { |
|
| 1414 | + return apply_filters( |
|
| 1415 | + 'FHEE__EE_Config__get_forward', |
|
| 1416 | + EE_Config::$_module_forward_map[$key][$route][$status], |
|
| 1417 | + $route, |
|
| 1418 | + $status |
|
| 1419 | + ); |
|
| 1420 | + } |
|
| 1421 | + return null; |
|
| 1422 | + } |
|
| 1423 | + |
|
| 1424 | + |
|
| 1425 | + |
|
| 1426 | + /** |
|
| 1427 | + * register_forward - allows modules to specify different view templates for different method routes and status |
|
| 1428 | + * results |
|
| 1429 | + * |
|
| 1430 | + * @access public |
|
| 1431 | + * @param string $route - "pretty" public alias for module method |
|
| 1432 | + * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
| 1433 | + * allows different views to be served based on status |
|
| 1434 | + * @param string $view |
|
| 1435 | + * @param string $key - url param key indicating a route is being called |
|
| 1436 | + * @return bool |
|
| 1437 | + */ |
|
| 1438 | + public static function register_view($route = null, $status = 0, $view = null, $key = 'ee') |
|
| 1439 | + { |
|
| 1440 | + do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view); |
|
| 1441 | + if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
| 1442 | + $msg = sprintf( |
|
| 1443 | + __('The module route %s for this view has not been registered.', 'event_espresso'), |
|
| 1444 | + $route |
|
| 1445 | + ); |
|
| 1446 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1447 | + return false; |
|
| 1448 | + } |
|
| 1449 | + if (! is_readable($view)) { |
|
| 1450 | + $msg = sprintf( |
|
| 1451 | + __( |
|
| 1452 | + 'The %s view file could not be found or is not readable due to file permissions.', |
|
| 1453 | + 'event_espresso' |
|
| 1454 | + ), |
|
| 1455 | + $view |
|
| 1456 | + ); |
|
| 1457 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1458 | + return false; |
|
| 1459 | + } |
|
| 1460 | + EE_Config::$_module_view_map[$key][$route][absint($status)] = $view; |
|
| 1461 | + return true; |
|
| 1462 | + } |
|
| 1463 | + |
|
| 1464 | + |
|
| 1465 | + |
|
| 1466 | + /** |
|
| 1467 | + * get_view - get view for route and status |
|
| 1468 | + * |
|
| 1469 | + * @access public |
|
| 1470 | + * @param string $route - "pretty" public alias for module method |
|
| 1471 | + * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
| 1472 | + * allows different views to be served based on status |
|
| 1473 | + * @param string $key - url param key indicating a route is being called |
|
| 1474 | + * @return string |
|
| 1475 | + */ |
|
| 1476 | + public static function get_view($route = null, $status = 0, $key = 'ee') |
|
| 1477 | + { |
|
| 1478 | + do_action('AHEE__EE_Config__get_view__begin', $route, $status); |
|
| 1479 | + if (isset(EE_Config::$_module_view_map[$key][$route][$status])) { |
|
| 1480 | + return apply_filters( |
|
| 1481 | + 'FHEE__EE_Config__get_view', |
|
| 1482 | + EE_Config::$_module_view_map[$key][$route][$status], |
|
| 1483 | + $route, |
|
| 1484 | + $status |
|
| 1485 | + ); |
|
| 1486 | + } |
|
| 1487 | + return null; |
|
| 1488 | + } |
|
| 1489 | + |
|
| 1490 | + |
|
| 1491 | + |
|
| 1492 | + public function update_addon_option_names() |
|
| 1493 | + { |
|
| 1494 | + update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names); |
|
| 1495 | + } |
|
| 1496 | + |
|
| 1497 | + |
|
| 1498 | + |
|
| 1499 | + public function shutdown() |
|
| 1500 | + { |
|
| 1501 | + $this->update_addon_option_names(); |
|
| 1502 | + } |
|
| 1503 | + |
|
| 1504 | + |
|
| 1505 | + |
|
| 1506 | + /** |
|
| 1507 | + * @return LegacyShortcodesManager |
|
| 1508 | + */ |
|
| 1509 | + public static function getLegacyShortcodesManager() |
|
| 1510 | + { |
|
| 1511 | + |
|
| 1512 | + if ( ! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) { |
|
| 1513 | + EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager( |
|
| 1514 | + EE_Registry::instance() |
|
| 1515 | + ); |
|
| 1516 | + } |
|
| 1517 | + return EE_Config::instance()->legacy_shortcodes_manager; |
|
| 1518 | + } |
|
| 1519 | + |
|
| 1520 | + |
|
| 1521 | + |
|
| 1522 | + /** |
|
| 1523 | + * register_shortcode - makes core aware of this shortcode |
|
| 1524 | + * |
|
| 1525 | + * @deprecated 4.9.26 |
|
| 1526 | + * @param string $shortcode_path - full path up to and including shortcode folder |
|
| 1527 | + * @return bool |
|
| 1528 | + */ |
|
| 1529 | + public static function register_shortcode($shortcode_path = null) |
|
| 1530 | + { |
|
| 1531 | + EE_Error::doing_it_wrong( |
|
| 1532 | + __METHOD__, |
|
| 1533 | + __( |
|
| 1534 | + 'Usage is deprecated. Use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::registerShortcode() as direct replacement, or better yet, please see the new \EventEspresso\core\services\shortcodes\ShortcodesManager class.', |
|
| 1535 | + 'event_espresso' |
|
| 1536 | + ), |
|
| 1537 | + '4.9.26' |
|
| 1538 | + ); |
|
| 1539 | + return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path); |
|
| 1540 | + } |
|
| 21 | 1541 | |
| 22 | - const LOG_NAME = 'ee_config_log'; |
|
| 23 | 1542 | |
| 24 | - const LOG_LENGTH = 100; |
|
| 25 | 1543 | |
| 26 | - const ADDON_OPTION_NAMES = 'ee_config_option_names'; |
|
| 27 | - |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * instance of the EE_Config object |
|
| 31 | - * |
|
| 32 | - * @var EE_Config $_instance |
|
| 33 | - * @access private |
|
| 34 | - */ |
|
| 35 | - private static $_instance; |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * @var boolean $_logging_enabled |
|
| 39 | - */ |
|
| 40 | - private static $_logging_enabled = false; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * @var LegacyShortcodesManager $legacy_shortcodes_manager |
|
| 44 | - */ |
|
| 45 | - private $legacy_shortcodes_manager; |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * An StdClass whose property names are addon slugs, |
|
| 49 | - * and values are their config classes |
|
| 50 | - * |
|
| 51 | - * @var StdClass |
|
| 52 | - */ |
|
| 53 | - public $addons; |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * @var EE_Admin_Config |
|
| 57 | - */ |
|
| 58 | - public $admin; |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * @var EE_Core_Config |
|
| 62 | - */ |
|
| 63 | - public $core; |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * @var EE_Currency_Config |
|
| 67 | - */ |
|
| 68 | - public $currency; |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * @var EE_Organization_Config |
|
| 72 | - */ |
|
| 73 | - public $organization; |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * @var EE_Registration_Config |
|
| 77 | - */ |
|
| 78 | - public $registration; |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * @var EE_Template_Config |
|
| 82 | - */ |
|
| 83 | - public $template_settings; |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * Holds EE environment values. |
|
| 87 | - * |
|
| 88 | - * @var EE_Environment_Config |
|
| 89 | - */ |
|
| 90 | - public $environment; |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * settings pertaining to Google maps |
|
| 94 | - * |
|
| 95 | - * @var EE_Map_Config |
|
| 96 | - */ |
|
| 97 | - public $map_settings; |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * settings pertaining to Taxes |
|
| 101 | - * |
|
| 102 | - * @var EE_Tax_Config |
|
| 103 | - */ |
|
| 104 | - public $tax_settings; |
|
| 105 | - |
|
| 106 | - |
|
| 107 | - /** |
|
| 108 | - * Settings pertaining to global messages settings. |
|
| 109 | - * |
|
| 110 | - * @var EE_Messages_Config |
|
| 111 | - */ |
|
| 112 | - public $messages; |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * @deprecated |
|
| 116 | - * @var EE_Gateway_Config |
|
| 117 | - */ |
|
| 118 | - public $gateway; |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * @var array $_addon_option_names |
|
| 122 | - * @access private |
|
| 123 | - */ |
|
| 124 | - private $_addon_option_names = array(); |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * @var array $_module_route_map |
|
| 128 | - * @access private |
|
| 129 | - */ |
|
| 130 | - private static $_module_route_map = array(); |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * @var array $_module_forward_map |
|
| 134 | - * @access private |
|
| 135 | - */ |
|
| 136 | - private static $_module_forward_map = array(); |
|
| 137 | - |
|
| 138 | - /** |
|
| 139 | - * @var array $_module_view_map |
|
| 140 | - * @access private |
|
| 141 | - */ |
|
| 142 | - private static $_module_view_map = array(); |
|
| 143 | - |
|
| 144 | - |
|
| 145 | - |
|
| 146 | - /** |
|
| 147 | - * @singleton method used to instantiate class object |
|
| 148 | - * @access public |
|
| 149 | - * @return EE_Config instance |
|
| 150 | - */ |
|
| 151 | - public static function instance() |
|
| 152 | - { |
|
| 153 | - // check if class object is instantiated, and instantiated properly |
|
| 154 | - if (! self::$_instance instanceof EE_Config) { |
|
| 155 | - self::$_instance = new self(); |
|
| 156 | - } |
|
| 157 | - return self::$_instance; |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - |
|
| 161 | - |
|
| 162 | - /** |
|
| 163 | - * Resets the config |
|
| 164 | - * |
|
| 165 | - * @param bool $hard_reset if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE |
|
| 166 | - * (default) leaves the database alone, and merely resets the EE_Config object to |
|
| 167 | - * reflect its state in the database |
|
| 168 | - * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave |
|
| 169 | - * $_instance as NULL. Useful in case you want to forget about the old instance on |
|
| 170 | - * EE_Config, but might not be ready to instantiate EE_Config currently (eg if the |
|
| 171 | - * site was put into maintenance mode) |
|
| 172 | - * @return EE_Config |
|
| 173 | - */ |
|
| 174 | - public static function reset($hard_reset = false, $reinstantiate = true) |
|
| 175 | - { |
|
| 176 | - if (self::$_instance instanceof EE_Config) { |
|
| 177 | - if ($hard_reset) { |
|
| 178 | - self::$_instance->legacy_shortcodes_manager = null; |
|
| 179 | - self::$_instance->_addon_option_names = array(); |
|
| 180 | - self::$_instance->_initialize_config(); |
|
| 181 | - self::$_instance->update_espresso_config(); |
|
| 182 | - } |
|
| 183 | - self::$_instance->update_addon_option_names(); |
|
| 184 | - } |
|
| 185 | - self::$_instance = null; |
|
| 186 | - //we don't need to reset the static properties imo because those should |
|
| 187 | - //only change when a module is added or removed. Currently we don't |
|
| 188 | - //support removing a module during a request when it previously existed |
|
| 189 | - if ($reinstantiate) { |
|
| 190 | - return self::instance(); |
|
| 191 | - } else { |
|
| 192 | - return null; |
|
| 193 | - } |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - |
|
| 197 | - |
|
| 198 | - /** |
|
| 199 | - * class constructor |
|
| 200 | - * |
|
| 201 | - * @access private |
|
| 202 | - */ |
|
| 203 | - private function __construct() |
|
| 204 | - { |
|
| 205 | - do_action('AHEE__EE_Config__construct__begin', $this); |
|
| 206 | - EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false); |
|
| 207 | - // setup empty config classes |
|
| 208 | - $this->_initialize_config(); |
|
| 209 | - // load existing EE site settings |
|
| 210 | - $this->_load_core_config(); |
|
| 211 | - // confirm everything loaded correctly and set filtered defaults if not |
|
| 212 | - $this->_verify_config(); |
|
| 213 | - // register shortcodes and modules |
|
| 214 | - add_action( |
|
| 215 | - 'AHEE__EE_System__register_shortcodes_modules_and_widgets', |
|
| 216 | - array($this, 'register_shortcodes_and_modules'), |
|
| 217 | - 999 |
|
| 218 | - ); |
|
| 219 | - // initialize shortcodes and modules |
|
| 220 | - add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules')); |
|
| 221 | - // register widgets |
|
| 222 | - add_action('widgets_init', array($this, 'widgets_init'), 10); |
|
| 223 | - // shutdown |
|
| 224 | - add_action('shutdown', array($this, 'shutdown'), 10); |
|
| 225 | - // construct__end hook |
|
| 226 | - do_action('AHEE__EE_Config__construct__end', $this); |
|
| 227 | - // hardcoded hack |
|
| 228 | - $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014'; |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - |
|
| 232 | - |
|
| 233 | - /** |
|
| 234 | - * @return boolean |
|
| 235 | - */ |
|
| 236 | - public static function logging_enabled() |
|
| 237 | - { |
|
| 238 | - return self::$_logging_enabled; |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - |
|
| 242 | - |
|
| 243 | - /** |
|
| 244 | - * use to get the current theme if needed from static context |
|
| 245 | - * |
|
| 246 | - * @return string current theme set. |
|
| 247 | - */ |
|
| 248 | - public static function get_current_theme() |
|
| 249 | - { |
|
| 250 | - return isset(self::$_instance->template_settings->current_espresso_theme) |
|
| 251 | - ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014'; |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - |
|
| 255 | - |
|
| 256 | - /** |
|
| 257 | - * _initialize_config |
|
| 258 | - * |
|
| 259 | - * @access private |
|
| 260 | - * @return void |
|
| 261 | - */ |
|
| 262 | - private function _initialize_config() |
|
| 263 | - { |
|
| 264 | - EE_Config::trim_log(); |
|
| 265 | - //set defaults |
|
| 266 | - $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array()); |
|
| 267 | - $this->addons = new stdClass(); |
|
| 268 | - // set _module_route_map |
|
| 269 | - EE_Config::$_module_route_map = array(); |
|
| 270 | - // set _module_forward_map |
|
| 271 | - EE_Config::$_module_forward_map = array(); |
|
| 272 | - // set _module_view_map |
|
| 273 | - EE_Config::$_module_view_map = array(); |
|
| 274 | - } |
|
| 275 | - |
|
| 276 | - |
|
| 277 | - |
|
| 278 | - /** |
|
| 279 | - * load core plugin configuration |
|
| 280 | - * |
|
| 281 | - * @access private |
|
| 282 | - * @return void |
|
| 283 | - */ |
|
| 284 | - private function _load_core_config() |
|
| 285 | - { |
|
| 286 | - // load_core_config__start hook |
|
| 287 | - do_action('AHEE__EE_Config___load_core_config__start', $this); |
|
| 288 | - $espresso_config = $this->get_espresso_config(); |
|
| 289 | - foreach ($espresso_config as $config => $settings) { |
|
| 290 | - // load_core_config__start hook |
|
| 291 | - $settings = apply_filters( |
|
| 292 | - 'FHEE__EE_Config___load_core_config__config_settings', |
|
| 293 | - $settings, |
|
| 294 | - $config, |
|
| 295 | - $this |
|
| 296 | - ); |
|
| 297 | - if (is_object($settings) && property_exists($this, $config)) { |
|
| 298 | - $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings); |
|
| 299 | - //call configs populate method to ensure any defaults are set for empty values. |
|
| 300 | - if (method_exists($settings, 'populate')) { |
|
| 301 | - $this->{$config}->populate(); |
|
| 302 | - } |
|
| 303 | - if (method_exists($settings, 'do_hooks')) { |
|
| 304 | - $this->{$config}->do_hooks(); |
|
| 305 | - } |
|
| 306 | - } |
|
| 307 | - } |
|
| 308 | - if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) { |
|
| 309 | - $this->update_espresso_config(); |
|
| 310 | - } |
|
| 311 | - // load_core_config__end hook |
|
| 312 | - do_action('AHEE__EE_Config___load_core_config__end', $this); |
|
| 313 | - } |
|
| 314 | - |
|
| 315 | - |
|
| 316 | - |
|
| 317 | - /** |
|
| 318 | - * _verify_config |
|
| 319 | - * |
|
| 320 | - * @access protected |
|
| 321 | - * @return void |
|
| 322 | - */ |
|
| 323 | - protected function _verify_config() |
|
| 324 | - { |
|
| 325 | - $this->core = $this->core instanceof EE_Core_Config |
|
| 326 | - ? $this->core |
|
| 327 | - : new EE_Core_Config(); |
|
| 328 | - $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core); |
|
| 329 | - $this->organization = $this->organization instanceof EE_Organization_Config |
|
| 330 | - ? $this->organization |
|
| 331 | - : new EE_Organization_Config(); |
|
| 332 | - $this->organization = apply_filters( |
|
| 333 | - 'FHEE__EE_Config___initialize_config__organization', |
|
| 334 | - $this->organization |
|
| 335 | - ); |
|
| 336 | - $this->currency = $this->currency instanceof EE_Currency_Config |
|
| 337 | - ? $this->currency |
|
| 338 | - : new EE_Currency_Config(); |
|
| 339 | - $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency); |
|
| 340 | - $this->registration = $this->registration instanceof EE_Registration_Config |
|
| 341 | - ? $this->registration |
|
| 342 | - : new EE_Registration_Config(); |
|
| 343 | - $this->registration = apply_filters( |
|
| 344 | - 'FHEE__EE_Config___initialize_config__registration', |
|
| 345 | - $this->registration |
|
| 346 | - ); |
|
| 347 | - $this->admin = $this->admin instanceof EE_Admin_Config |
|
| 348 | - ? $this->admin |
|
| 349 | - : new EE_Admin_Config(); |
|
| 350 | - $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin); |
|
| 351 | - $this->template_settings = $this->template_settings instanceof EE_Template_Config |
|
| 352 | - ? $this->template_settings |
|
| 353 | - : new EE_Template_Config(); |
|
| 354 | - $this->template_settings = apply_filters( |
|
| 355 | - 'FHEE__EE_Config___initialize_config__template_settings', |
|
| 356 | - $this->template_settings |
|
| 357 | - ); |
|
| 358 | - $this->map_settings = $this->map_settings instanceof EE_Map_Config |
|
| 359 | - ? $this->map_settings |
|
| 360 | - : new EE_Map_Config(); |
|
| 361 | - $this->map_settings = apply_filters('FHEE__EE_Config___initialize_config__map_settings', |
|
| 362 | - $this->map_settings); |
|
| 363 | - $this->environment = $this->environment instanceof EE_Environment_Config |
|
| 364 | - ? $this->environment |
|
| 365 | - : new EE_Environment_Config(); |
|
| 366 | - $this->environment = apply_filters('FHEE__EE_Config___initialize_config__environment', |
|
| 367 | - $this->environment); |
|
| 368 | - $this->tax_settings = $this->tax_settings instanceof EE_Tax_Config |
|
| 369 | - ? $this->tax_settings |
|
| 370 | - : new EE_Tax_Config(); |
|
| 371 | - $this->tax_settings = apply_filters('FHEE__EE_Config___initialize_config__tax_settings', |
|
| 372 | - $this->tax_settings); |
|
| 373 | - $this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages); |
|
| 374 | - $this->messages = $this->messages instanceof EE_Messages_Config |
|
| 375 | - ? $this->messages |
|
| 376 | - : new EE_Messages_Config(); |
|
| 377 | - $this->gateway = $this->gateway instanceof EE_Gateway_Config |
|
| 378 | - ? $this->gateway |
|
| 379 | - : new EE_Gateway_Config(); |
|
| 380 | - $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway); |
|
| 381 | - $this->legacy_shortcodes_manager = null; |
|
| 382 | - } |
|
| 383 | - |
|
| 384 | - |
|
| 385 | - /** |
|
| 386 | - * get_espresso_config |
|
| 387 | - * |
|
| 388 | - * @access public |
|
| 389 | - * @return array of espresso config stuff |
|
| 390 | - */ |
|
| 391 | - public function get_espresso_config() |
|
| 392 | - { |
|
| 393 | - // grab espresso configuration |
|
| 394 | - return apply_filters( |
|
| 395 | - 'FHEE__EE_Config__get_espresso_config__CFG', |
|
| 396 | - get_option(EE_Config::OPTION_NAME, array()) |
|
| 397 | - ); |
|
| 398 | - } |
|
| 399 | - |
|
| 400 | - |
|
| 401 | - |
|
| 402 | - /** |
|
| 403 | - * double_check_config_comparison |
|
| 404 | - * |
|
| 405 | - * @access public |
|
| 406 | - * @param string $option |
|
| 407 | - * @param $old_value |
|
| 408 | - * @param $value |
|
| 409 | - */ |
|
| 410 | - public function double_check_config_comparison($option = '', $old_value, $value) |
|
| 411 | - { |
|
| 412 | - // make sure we're checking the ee config |
|
| 413 | - if ($option === EE_Config::OPTION_NAME) { |
|
| 414 | - // run a loose comparison of the old value against the new value for type and properties, |
|
| 415 | - // but NOT exact instance like WP update_option does (ie: NOT type safe comparison) |
|
| 416 | - if ($value != $old_value) { |
|
| 417 | - // if they are NOT the same, then remove the hook, |
|
| 418 | - // which means the subsequent update results will be based solely on the update query results |
|
| 419 | - // the reason we do this is because, as stated above, |
|
| 420 | - // WP update_option performs an exact instance comparison (===) on any update values passed to it |
|
| 421 | - // this happens PRIOR to serialization and any subsequent update. |
|
| 422 | - // If values are found to match their previous old value, |
|
| 423 | - // then WP bails before performing any update. |
|
| 424 | - // Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version |
|
| 425 | - // it just pulled from the db, with the one being passed to it (which will not match). |
|
| 426 | - // HOWEVER, once the object is serialized and passed off to MySQL to update, |
|
| 427 | - // MySQL MAY ALSO NOT perform the update because |
|
| 428 | - // the string it sees in the db looks the same as the new one it has been passed!!! |
|
| 429 | - // This results in the query returning an "affected rows" value of ZERO, |
|
| 430 | - // which gets returned immediately by WP update_option and looks like an error. |
|
| 431 | - remove_action('update_option', array($this, 'check_config_updated')); |
|
| 432 | - } |
|
| 433 | - } |
|
| 434 | - } |
|
| 435 | - |
|
| 436 | - |
|
| 437 | - |
|
| 438 | - /** |
|
| 439 | - * update_espresso_config |
|
| 440 | - * |
|
| 441 | - * @access public |
|
| 442 | - */ |
|
| 443 | - protected function _reset_espresso_addon_config() |
|
| 444 | - { |
|
| 445 | - $this->_addon_option_names = array(); |
|
| 446 | - foreach ($this->addons as $addon_name => $addon_config_obj) { |
|
| 447 | - $addon_config_obj = maybe_unserialize($addon_config_obj); |
|
| 448 | - if ($addon_config_obj instanceof EE_Config_Base) { |
|
| 449 | - $this->update_config('addons', $addon_name, $addon_config_obj, false); |
|
| 450 | - } |
|
| 451 | - $this->addons->{$addon_name} = null; |
|
| 452 | - } |
|
| 453 | - } |
|
| 454 | - |
|
| 455 | - |
|
| 456 | - |
|
| 457 | - /** |
|
| 458 | - * update_espresso_config |
|
| 459 | - * |
|
| 460 | - * @access public |
|
| 461 | - * @param bool $add_success |
|
| 462 | - * @param bool $add_error |
|
| 463 | - * @return bool |
|
| 464 | - */ |
|
| 465 | - public function update_espresso_config($add_success = false, $add_error = true) |
|
| 466 | - { |
|
| 467 | - // don't allow config updates during WP heartbeats |
|
| 468 | - if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') { |
|
| 469 | - return false; |
|
| 470 | - } |
|
| 471 | - // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197 |
|
| 472 | - //$clone = clone( self::$_instance ); |
|
| 473 | - //self::$_instance = NULL; |
|
| 474 | - do_action('AHEE__EE_Config__update_espresso_config__begin', $this); |
|
| 475 | - $this->_reset_espresso_addon_config(); |
|
| 476 | - // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional |
|
| 477 | - // but BEFORE the actual update occurs |
|
| 478 | - add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3); |
|
| 479 | - // don't want to persist legacy_shortcodes_manager, but don't want to lose it either |
|
| 480 | - $legacy_shortcodes_manager = $this->legacy_shortcodes_manager; |
|
| 481 | - $this->legacy_shortcodes_manager = null; |
|
| 482 | - // now update "ee_config" |
|
| 483 | - $saved = update_option(EE_Config::OPTION_NAME, $this); |
|
| 484 | - $this->legacy_shortcodes_manager = $legacy_shortcodes_manager; |
|
| 485 | - EE_Config::log(EE_Config::OPTION_NAME); |
|
| 486 | - // if not saved... check if the hook we just added still exists; |
|
| 487 | - // if it does, it means one of two things: |
|
| 488 | - // that update_option bailed at the ( $value === $old_value ) conditional, |
|
| 489 | - // or... |
|
| 490 | - // the db update query returned 0 rows affected |
|
| 491 | - // (probably because the data value was the same from it's perspective) |
|
| 492 | - // so the existence of the hook means that a negative result from update_option is NOT an error, |
|
| 493 | - // but just means no update occurred, so don't display an error to the user. |
|
| 494 | - // BUT... if update_option returns FALSE, AND the hook is missing, |
|
| 495 | - // then it means that something truly went wrong |
|
| 496 | - $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved; |
|
| 497 | - // remove our action since we don't want it in the system anymore |
|
| 498 | - remove_action('update_option', array($this, 'double_check_config_comparison'), 1); |
|
| 499 | - do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved); |
|
| 500 | - //self::$_instance = $clone; |
|
| 501 | - //unset( $clone ); |
|
| 502 | - // if config remains the same or was updated successfully |
|
| 503 | - if ($saved) { |
|
| 504 | - if ($add_success) { |
|
| 505 | - EE_Error::add_success( |
|
| 506 | - __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'), |
|
| 507 | - __FILE__, |
|
| 508 | - __FUNCTION__, |
|
| 509 | - __LINE__ |
|
| 510 | - ); |
|
| 511 | - } |
|
| 512 | - return true; |
|
| 513 | - } else { |
|
| 514 | - if ($add_error) { |
|
| 515 | - EE_Error::add_error( |
|
| 516 | - __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'), |
|
| 517 | - __FILE__, |
|
| 518 | - __FUNCTION__, |
|
| 519 | - __LINE__ |
|
| 520 | - ); |
|
| 521 | - } |
|
| 522 | - return false; |
|
| 523 | - } |
|
| 524 | - } |
|
| 525 | - |
|
| 526 | - |
|
| 527 | - |
|
| 528 | - /** |
|
| 529 | - * _verify_config_params |
|
| 530 | - * |
|
| 531 | - * @access private |
|
| 532 | - * @param string $section |
|
| 533 | - * @param string $name |
|
| 534 | - * @param string $config_class |
|
| 535 | - * @param EE_Config_Base $config_obj |
|
| 536 | - * @param array $tests_to_run |
|
| 537 | - * @param bool $display_errors |
|
| 538 | - * @return bool TRUE on success, FALSE on fail |
|
| 539 | - */ |
|
| 540 | - private function _verify_config_params( |
|
| 541 | - $section = '', |
|
| 542 | - $name = '', |
|
| 543 | - $config_class = '', |
|
| 544 | - $config_obj = null, |
|
| 545 | - $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8), |
|
| 546 | - $display_errors = true |
|
| 547 | - ) { |
|
| 548 | - try { |
|
| 549 | - foreach ($tests_to_run as $test) { |
|
| 550 | - switch ($test) { |
|
| 551 | - // TEST #1 : check that section was set |
|
| 552 | - case 1 : |
|
| 553 | - if (empty($section)) { |
|
| 554 | - if ($display_errors) { |
|
| 555 | - throw new EE_Error( |
|
| 556 | - sprintf( |
|
| 557 | - __( |
|
| 558 | - 'No configuration section has been provided while attempting to save "%s".', |
|
| 559 | - 'event_espresso' |
|
| 560 | - ), |
|
| 561 | - $config_class |
|
| 562 | - ) |
|
| 563 | - ); |
|
| 564 | - } |
|
| 565 | - return false; |
|
| 566 | - } |
|
| 567 | - break; |
|
| 568 | - // TEST #2 : check that settings section exists |
|
| 569 | - case 2 : |
|
| 570 | - if (! isset($this->{$section})) { |
|
| 571 | - if ($display_errors) { |
|
| 572 | - throw new EE_Error( |
|
| 573 | - sprintf( |
|
| 574 | - __('The "%s" configuration section does not exist.', 'event_espresso'), |
|
| 575 | - $section |
|
| 576 | - ) |
|
| 577 | - ); |
|
| 578 | - } |
|
| 579 | - return false; |
|
| 580 | - } |
|
| 581 | - break; |
|
| 582 | - // TEST #3 : check that section is the proper format |
|
| 583 | - case 3 : |
|
| 584 | - if ( |
|
| 585 | - ! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass) |
|
| 586 | - ) { |
|
| 587 | - if ($display_errors) { |
|
| 588 | - throw new EE_Error( |
|
| 589 | - sprintf( |
|
| 590 | - __( |
|
| 591 | - 'The "%s" configuration settings have not been formatted correctly.', |
|
| 592 | - 'event_espresso' |
|
| 593 | - ), |
|
| 594 | - $section |
|
| 595 | - ) |
|
| 596 | - ); |
|
| 597 | - } |
|
| 598 | - return false; |
|
| 599 | - } |
|
| 600 | - break; |
|
| 601 | - // TEST #4 : check that config section name has been set |
|
| 602 | - case 4 : |
|
| 603 | - if (empty($name)) { |
|
| 604 | - if ($display_errors) { |
|
| 605 | - throw new EE_Error( |
|
| 606 | - __( |
|
| 607 | - 'No name has been provided for the specific configuration section.', |
|
| 608 | - 'event_espresso' |
|
| 609 | - ) |
|
| 610 | - ); |
|
| 611 | - } |
|
| 612 | - return false; |
|
| 613 | - } |
|
| 614 | - break; |
|
| 615 | - // TEST #5 : check that a config class name has been set |
|
| 616 | - case 5 : |
|
| 617 | - if (empty($config_class)) { |
|
| 618 | - if ($display_errors) { |
|
| 619 | - throw new EE_Error( |
|
| 620 | - __( |
|
| 621 | - 'No class name has been provided for the specific configuration section.', |
|
| 622 | - 'event_espresso' |
|
| 623 | - ) |
|
| 624 | - ); |
|
| 625 | - } |
|
| 626 | - return false; |
|
| 627 | - } |
|
| 628 | - break; |
|
| 629 | - // TEST #6 : verify config class is accessible |
|
| 630 | - case 6 : |
|
| 631 | - if (! class_exists($config_class)) { |
|
| 632 | - if ($display_errors) { |
|
| 633 | - throw new EE_Error( |
|
| 634 | - sprintf( |
|
| 635 | - __( |
|
| 636 | - 'The "%s" class does not exist. Please ensure that an autoloader has been set for it.', |
|
| 637 | - 'event_espresso' |
|
| 638 | - ), |
|
| 639 | - $config_class |
|
| 640 | - ) |
|
| 641 | - ); |
|
| 642 | - } |
|
| 643 | - return false; |
|
| 644 | - } |
|
| 645 | - break; |
|
| 646 | - // TEST #7 : check that config has even been set |
|
| 647 | - case 7 : |
|
| 648 | - if (! isset($this->{$section}->{$name})) { |
|
| 649 | - if ($display_errors) { |
|
| 650 | - throw new EE_Error( |
|
| 651 | - sprintf( |
|
| 652 | - __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'), |
|
| 653 | - $section, |
|
| 654 | - $name |
|
| 655 | - ) |
|
| 656 | - ); |
|
| 657 | - } |
|
| 658 | - return false; |
|
| 659 | - } else { |
|
| 660 | - // and make sure it's not serialized |
|
| 661 | - $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name}); |
|
| 662 | - } |
|
| 663 | - break; |
|
| 664 | - // TEST #8 : check that config is the requested type |
|
| 665 | - case 8 : |
|
| 666 | - if (! $this->{$section}->{$name} instanceof $config_class) { |
|
| 667 | - if ($display_errors) { |
|
| 668 | - throw new EE_Error( |
|
| 669 | - sprintf( |
|
| 670 | - __( |
|
| 671 | - 'The configuration for "%1$s->%2$s" is not of the "%3$s" class.', |
|
| 672 | - 'event_espresso' |
|
| 673 | - ), |
|
| 674 | - $section, |
|
| 675 | - $name, |
|
| 676 | - $config_class |
|
| 677 | - ) |
|
| 678 | - ); |
|
| 679 | - } |
|
| 680 | - return false; |
|
| 681 | - } |
|
| 682 | - break; |
|
| 683 | - // TEST #9 : verify config object |
|
| 684 | - case 9 : |
|
| 685 | - if (! $config_obj instanceof EE_Config_Base) { |
|
| 686 | - if ($display_errors) { |
|
| 687 | - throw new EE_Error( |
|
| 688 | - sprintf( |
|
| 689 | - __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'), |
|
| 690 | - print_r($config_obj, true) |
|
| 691 | - ) |
|
| 692 | - ); |
|
| 693 | - } |
|
| 694 | - return false; |
|
| 695 | - } |
|
| 696 | - break; |
|
| 697 | - } |
|
| 698 | - } |
|
| 699 | - } catch (EE_Error $e) { |
|
| 700 | - $e->get_error(); |
|
| 701 | - } |
|
| 702 | - // you have successfully run the gauntlet |
|
| 703 | - return true; |
|
| 704 | - } |
|
| 705 | - |
|
| 706 | - |
|
| 707 | - |
|
| 708 | - /** |
|
| 709 | - * _generate_config_option_name |
|
| 710 | - * |
|
| 711 | - * @access protected |
|
| 712 | - * @param string $section |
|
| 713 | - * @param string $name |
|
| 714 | - * @return string |
|
| 715 | - */ |
|
| 716 | - private function _generate_config_option_name($section = '', $name = '') |
|
| 717 | - { |
|
| 718 | - return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name)); |
|
| 719 | - } |
|
| 720 | - |
|
| 721 | - |
|
| 722 | - |
|
| 723 | - /** |
|
| 724 | - * _set_config_class |
|
| 725 | - * ensures that a config class is set, either from a passed config class or one generated from the config name |
|
| 726 | - * |
|
| 727 | - * @access private |
|
| 728 | - * @param string $config_class |
|
| 729 | - * @param string $name |
|
| 730 | - * @return string |
|
| 731 | - */ |
|
| 732 | - private function _set_config_class($config_class = '', $name = '') |
|
| 733 | - { |
|
| 734 | - return ! empty($config_class) |
|
| 735 | - ? $config_class |
|
| 736 | - : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config'; |
|
| 737 | - } |
|
| 738 | - |
|
| 739 | - |
|
| 740 | - |
|
| 741 | - /** |
|
| 742 | - * set_config |
|
| 743 | - * |
|
| 744 | - * @access protected |
|
| 745 | - * @param string $section |
|
| 746 | - * @param string $name |
|
| 747 | - * @param string $config_class |
|
| 748 | - * @param EE_Config_Base $config_obj |
|
| 749 | - * @return EE_Config_Base |
|
| 750 | - */ |
|
| 751 | - public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null) |
|
| 752 | - { |
|
| 753 | - // ensure config class is set to something |
|
| 754 | - $config_class = $this->_set_config_class($config_class, $name); |
|
| 755 | - // run tests 1-4, 6, and 7 to verify all config params are set and valid |
|
| 756 | - if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
| 757 | - return null; |
|
| 758 | - } |
|
| 759 | - $config_option_name = $this->_generate_config_option_name($section, $name); |
|
| 760 | - // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now |
|
| 761 | - if (! isset($this->_addon_option_names[$config_option_name])) { |
|
| 762 | - $this->_addon_option_names[$config_option_name] = $config_class; |
|
| 763 | - $this->update_addon_option_names(); |
|
| 764 | - } |
|
| 765 | - // verify the incoming config object but suppress errors |
|
| 766 | - if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
| 767 | - $config_obj = new $config_class(); |
|
| 768 | - } |
|
| 769 | - if (get_option($config_option_name)) { |
|
| 770 | - EE_Config::log($config_option_name); |
|
| 771 | - update_option($config_option_name, $config_obj); |
|
| 772 | - $this->{$section}->{$name} = $config_obj; |
|
| 773 | - return $this->{$section}->{$name}; |
|
| 774 | - } else { |
|
| 775 | - // create a wp-option for this config |
|
| 776 | - if (add_option($config_option_name, $config_obj, '', 'no')) { |
|
| 777 | - $this->{$section}->{$name} = maybe_unserialize($config_obj); |
|
| 778 | - return $this->{$section}->{$name}; |
|
| 779 | - } else { |
|
| 780 | - EE_Error::add_error( |
|
| 781 | - sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class), |
|
| 782 | - __FILE__, |
|
| 783 | - __FUNCTION__, |
|
| 784 | - __LINE__ |
|
| 785 | - ); |
|
| 786 | - return null; |
|
| 787 | - } |
|
| 788 | - } |
|
| 789 | - } |
|
| 790 | - |
|
| 791 | - |
|
| 792 | - |
|
| 793 | - /** |
|
| 794 | - * update_config |
|
| 795 | - * Important: the config object must ALREADY be set, otherwise this will produce an error. |
|
| 796 | - * |
|
| 797 | - * @access public |
|
| 798 | - * @param string $section |
|
| 799 | - * @param string $name |
|
| 800 | - * @param EE_Config_Base|string $config_obj |
|
| 801 | - * @param bool $throw_errors |
|
| 802 | - * @return bool |
|
| 803 | - */ |
|
| 804 | - public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true) |
|
| 805 | - { |
|
| 806 | - // don't allow config updates during WP heartbeats |
|
| 807 | - if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') { |
|
| 808 | - return false; |
|
| 809 | - } |
|
| 810 | - $config_obj = maybe_unserialize($config_obj); |
|
| 811 | - // get class name of the incoming object |
|
| 812 | - $config_class = get_class($config_obj); |
|
| 813 | - // run tests 1-5 and 9 to verify config |
|
| 814 | - if (! $this->_verify_config_params( |
|
| 815 | - $section, |
|
| 816 | - $name, |
|
| 817 | - $config_class, |
|
| 818 | - $config_obj, |
|
| 819 | - array(1, 2, 3, 4, 7, 9) |
|
| 820 | - ) |
|
| 821 | - ) { |
|
| 822 | - return false; |
|
| 823 | - } |
|
| 824 | - $config_option_name = $this->_generate_config_option_name($section, $name); |
|
| 825 | - // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array |
|
| 826 | - if (! isset($this->_addon_option_names[$config_option_name])) { |
|
| 827 | - // save new config to db |
|
| 828 | - if ($this->set_config($section, $name, $config_class, $config_obj)) { |
|
| 829 | - return true; |
|
| 830 | - } |
|
| 831 | - } else { |
|
| 832 | - // first check if the record already exists |
|
| 833 | - $existing_config = get_option($config_option_name); |
|
| 834 | - $config_obj = serialize($config_obj); |
|
| 835 | - // just return if db record is already up to date (NOT type safe comparison) |
|
| 836 | - if ($existing_config == $config_obj) { |
|
| 837 | - $this->{$section}->{$name} = $config_obj; |
|
| 838 | - return true; |
|
| 839 | - } else if (update_option($config_option_name, $config_obj)) { |
|
| 840 | - EE_Config::log($config_option_name); |
|
| 841 | - // update wp-option for this config class |
|
| 842 | - $this->{$section}->{$name} = $config_obj; |
|
| 843 | - return true; |
|
| 844 | - } elseif ($throw_errors) { |
|
| 845 | - EE_Error::add_error( |
|
| 846 | - sprintf( |
|
| 847 | - __( |
|
| 848 | - 'The "%1$s" object stored at"%2$s" was not successfully updated in the database.', |
|
| 849 | - 'event_espresso' |
|
| 850 | - ), |
|
| 851 | - $config_class, |
|
| 852 | - 'EE_Config->' . $section . '->' . $name |
|
| 853 | - ), |
|
| 854 | - __FILE__, |
|
| 855 | - __FUNCTION__, |
|
| 856 | - __LINE__ |
|
| 857 | - ); |
|
| 858 | - } |
|
| 859 | - } |
|
| 860 | - return false; |
|
| 861 | - } |
|
| 862 | - |
|
| 863 | - |
|
| 864 | - |
|
| 865 | - /** |
|
| 866 | - * get_config |
|
| 867 | - * |
|
| 868 | - * @access public |
|
| 869 | - * @param string $section |
|
| 870 | - * @param string $name |
|
| 871 | - * @param string $config_class |
|
| 872 | - * @return mixed EE_Config_Base | NULL |
|
| 873 | - */ |
|
| 874 | - public function get_config($section = '', $name = '', $config_class = '') |
|
| 875 | - { |
|
| 876 | - // ensure config class is set to something |
|
| 877 | - $config_class = $this->_set_config_class($config_class, $name); |
|
| 878 | - // run tests 1-4, 6 and 7 to verify that all params have been set |
|
| 879 | - if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
| 880 | - return null; |
|
| 881 | - } |
|
| 882 | - // now test if the requested config object exists, but suppress errors |
|
| 883 | - if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) { |
|
| 884 | - // config already exists, so pass it back |
|
| 885 | - return $this->{$section}->{$name}; |
|
| 886 | - } |
|
| 887 | - // load config option from db if it exists |
|
| 888 | - $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name)); |
|
| 889 | - // verify the newly retrieved config object, but suppress errors |
|
| 890 | - if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
| 891 | - // config is good, so set it and pass it back |
|
| 892 | - $this->{$section}->{$name} = $config_obj; |
|
| 893 | - return $this->{$section}->{$name}; |
|
| 894 | - } |
|
| 895 | - // oops! $config_obj is not already set and does not exist in the db, so create a new one |
|
| 896 | - $config_obj = $this->set_config($section, $name, $config_class); |
|
| 897 | - // verify the newly created config object |
|
| 898 | - if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) { |
|
| 899 | - return $this->{$section}->{$name}; |
|
| 900 | - } else { |
|
| 901 | - EE_Error::add_error( |
|
| 902 | - sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class), |
|
| 903 | - __FILE__, |
|
| 904 | - __FUNCTION__, |
|
| 905 | - __LINE__ |
|
| 906 | - ); |
|
| 907 | - } |
|
| 908 | - return null; |
|
| 909 | - } |
|
| 910 | - |
|
| 911 | - |
|
| 912 | - |
|
| 913 | - /** |
|
| 914 | - * get_config_option |
|
| 915 | - * |
|
| 916 | - * @access public |
|
| 917 | - * @param string $config_option_name |
|
| 918 | - * @return mixed EE_Config_Base | FALSE |
|
| 919 | - */ |
|
| 920 | - public function get_config_option($config_option_name = '') |
|
| 921 | - { |
|
| 922 | - // retrieve the wp-option for this config class. |
|
| 923 | - $config_option = maybe_unserialize(get_option($config_option_name, array())); |
|
| 924 | - if (empty($config_option)) { |
|
| 925 | - EE_Config::log($config_option_name . '-NOT-FOUND'); |
|
| 926 | - } |
|
| 927 | - return $config_option; |
|
| 928 | - } |
|
| 929 | - |
|
| 930 | - |
|
| 931 | - |
|
| 932 | - /** |
|
| 933 | - * log |
|
| 934 | - * |
|
| 935 | - * @param string $config_option_name |
|
| 936 | - */ |
|
| 937 | - public static function log($config_option_name = '') |
|
| 938 | - { |
|
| 939 | - if (EE_Config::logging_enabled() && ! empty($config_option_name)) { |
|
| 940 | - $config_log = get_option(EE_Config::LOG_NAME, array()); |
|
| 941 | - //copy incoming $_REQUEST and sanitize it so we can save it |
|
| 942 | - $_request = $_REQUEST; |
|
| 943 | - array_walk_recursive($_request, 'sanitize_text_field'); |
|
| 944 | - $config_log[(string)microtime(true)] = array( |
|
| 945 | - 'config_name' => $config_option_name, |
|
| 946 | - 'request' => $_request, |
|
| 947 | - ); |
|
| 948 | - update_option(EE_Config::LOG_NAME, $config_log); |
|
| 949 | - } |
|
| 950 | - } |
|
| 951 | - |
|
| 952 | - |
|
| 953 | - |
|
| 954 | - /** |
|
| 955 | - * trim_log |
|
| 956 | - * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH |
|
| 957 | - */ |
|
| 958 | - public static function trim_log() |
|
| 959 | - { |
|
| 960 | - if (! EE_Config::logging_enabled()) { |
|
| 961 | - return; |
|
| 962 | - } |
|
| 963 | - $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array())); |
|
| 964 | - $log_length = count($config_log); |
|
| 965 | - if ($log_length > EE_Config::LOG_LENGTH) { |
|
| 966 | - ksort($config_log); |
|
| 967 | - $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true); |
|
| 968 | - update_option(EE_Config::LOG_NAME, $config_log); |
|
| 969 | - } |
|
| 970 | - } |
|
| 971 | - |
|
| 972 | - |
|
| 973 | - |
|
| 974 | - /** |
|
| 975 | - * get_page_for_posts |
|
| 976 | - * if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the |
|
| 977 | - * wp-option "page_for_posts", or "posts" if no page is selected |
|
| 978 | - * |
|
| 979 | - * @access public |
|
| 980 | - * @return string |
|
| 981 | - */ |
|
| 982 | - public static function get_page_for_posts() |
|
| 983 | - { |
|
| 984 | - $page_for_posts = get_option('page_for_posts'); |
|
| 985 | - if (! $page_for_posts) { |
|
| 986 | - return 'posts'; |
|
| 987 | - } |
|
| 988 | - /** @type WPDB $wpdb */ |
|
| 989 | - global $wpdb; |
|
| 990 | - $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d"; |
|
| 991 | - return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts)); |
|
| 992 | - } |
|
| 993 | - |
|
| 994 | - |
|
| 995 | - |
|
| 996 | - /** |
|
| 997 | - * register_shortcodes_and_modules. |
|
| 998 | - * At this point, it's too early to tell if we're maintenance mode or not. |
|
| 999 | - * In fact, this is where we give modules a chance to let core know they exist |
|
| 1000 | - * so they can help trigger maintenance mode if it's needed |
|
| 1001 | - * |
|
| 1002 | - * @access public |
|
| 1003 | - * @return void |
|
| 1004 | - */ |
|
| 1005 | - public function register_shortcodes_and_modules() |
|
| 1006 | - { |
|
| 1007 | - // allow modules to set hooks for the rest of the system |
|
| 1008 | - EE_Registry::instance()->modules = $this->_register_modules(); |
|
| 1009 | - } |
|
| 1010 | - |
|
| 1011 | - |
|
| 1012 | - |
|
| 1013 | - /** |
|
| 1014 | - * initialize_shortcodes_and_modules |
|
| 1015 | - * meaning they can start adding their hooks to get stuff done |
|
| 1016 | - * |
|
| 1017 | - * @access public |
|
| 1018 | - * @return void |
|
| 1019 | - */ |
|
| 1020 | - public function initialize_shortcodes_and_modules() |
|
| 1021 | - { |
|
| 1022 | - // allow modules to set hooks for the rest of the system |
|
| 1023 | - $this->_initialize_modules(); |
|
| 1024 | - } |
|
| 1025 | - |
|
| 1026 | - |
|
| 1027 | - |
|
| 1028 | - /** |
|
| 1029 | - * widgets_init |
|
| 1030 | - * |
|
| 1031 | - * @access private |
|
| 1032 | - * @return void |
|
| 1033 | - */ |
|
| 1034 | - public function widgets_init() |
|
| 1035 | - { |
|
| 1036 | - //only init widgets on admin pages when not in complete maintenance, and |
|
| 1037 | - //on frontend when not in any maintenance mode |
|
| 1038 | - if ( |
|
| 1039 | - ! EE_Maintenance_Mode::instance()->level() |
|
| 1040 | - || ( |
|
| 1041 | - is_admin() |
|
| 1042 | - && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance |
|
| 1043 | - ) |
|
| 1044 | - ) { |
|
| 1045 | - // grab list of installed widgets |
|
| 1046 | - $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR); |
|
| 1047 | - // filter list of modules to register |
|
| 1048 | - $widgets_to_register = apply_filters( |
|
| 1049 | - 'FHEE__EE_Config__register_widgets__widgets_to_register', |
|
| 1050 | - $widgets_to_register |
|
| 1051 | - ); |
|
| 1052 | - if (! empty($widgets_to_register)) { |
|
| 1053 | - // cycle thru widget folders |
|
| 1054 | - foreach ($widgets_to_register as $widget_path) { |
|
| 1055 | - // add to list of installed widget modules |
|
| 1056 | - EE_Config::register_ee_widget($widget_path); |
|
| 1057 | - } |
|
| 1058 | - } |
|
| 1059 | - // filter list of installed modules |
|
| 1060 | - EE_Registry::instance()->widgets = apply_filters( |
|
| 1061 | - 'FHEE__EE_Config__register_widgets__installed_widgets', |
|
| 1062 | - EE_Registry::instance()->widgets |
|
| 1063 | - ); |
|
| 1064 | - } |
|
| 1065 | - } |
|
| 1066 | - |
|
| 1067 | - |
|
| 1068 | - |
|
| 1069 | - /** |
|
| 1070 | - * register_ee_widget - makes core aware of this widget |
|
| 1071 | - * |
|
| 1072 | - * @access public |
|
| 1073 | - * @param string $widget_path - full path up to and including widget folder |
|
| 1074 | - * @return void |
|
| 1075 | - */ |
|
| 1076 | - public static function register_ee_widget($widget_path = null) |
|
| 1077 | - { |
|
| 1078 | - do_action('AHEE__EE_Config__register_widget__begin', $widget_path); |
|
| 1079 | - $widget_ext = '.widget.php'; |
|
| 1080 | - // make all separators match |
|
| 1081 | - $widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS); |
|
| 1082 | - // does the file path INCLUDE the actual file name as part of the path ? |
|
| 1083 | - if (strpos($widget_path, $widget_ext) !== false) { |
|
| 1084 | - // grab and shortcode file name from directory name and break apart at dots |
|
| 1085 | - $file_name = explode('.', basename($widget_path)); |
|
| 1086 | - // take first segment from file name pieces and remove class prefix if it exists |
|
| 1087 | - $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0]; |
|
| 1088 | - // sanitize shortcode directory name |
|
| 1089 | - $widget = sanitize_key($widget); |
|
| 1090 | - // now we need to rebuild the shortcode path |
|
| 1091 | - $widget_path = explode(DS, $widget_path); |
|
| 1092 | - // remove last segment |
|
| 1093 | - array_pop($widget_path); |
|
| 1094 | - // glue it back together |
|
| 1095 | - $widget_path = implode(DS, $widget_path); |
|
| 1096 | - } else { |
|
| 1097 | - // grab and sanitize widget directory name |
|
| 1098 | - $widget = sanitize_key(basename($widget_path)); |
|
| 1099 | - } |
|
| 1100 | - // create classname from widget directory name |
|
| 1101 | - $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget))); |
|
| 1102 | - // add class prefix |
|
| 1103 | - $widget_class = 'EEW_' . $widget; |
|
| 1104 | - // does the widget exist ? |
|
| 1105 | - if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) { |
|
| 1106 | - $msg = sprintf( |
|
| 1107 | - __( |
|
| 1108 | - 'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', |
|
| 1109 | - 'event_espresso' |
|
| 1110 | - ), |
|
| 1111 | - $widget_class, |
|
| 1112 | - $widget_path . DS . $widget_class . $widget_ext |
|
| 1113 | - ); |
|
| 1114 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1115 | - return; |
|
| 1116 | - } |
|
| 1117 | - // load the widget class file |
|
| 1118 | - require_once($widget_path . DS . $widget_class . $widget_ext); |
|
| 1119 | - // verify that class exists |
|
| 1120 | - if (! class_exists($widget_class)) { |
|
| 1121 | - $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class); |
|
| 1122 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1123 | - return; |
|
| 1124 | - } |
|
| 1125 | - register_widget($widget_class); |
|
| 1126 | - // add to array of registered widgets |
|
| 1127 | - EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext; |
|
| 1128 | - } |
|
| 1129 | - |
|
| 1130 | - |
|
| 1131 | - |
|
| 1132 | - /** |
|
| 1133 | - * _register_modules |
|
| 1134 | - * |
|
| 1135 | - * @access private |
|
| 1136 | - * @return array |
|
| 1137 | - */ |
|
| 1138 | - private function _register_modules() |
|
| 1139 | - { |
|
| 1140 | - // grab list of installed modules |
|
| 1141 | - $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR); |
|
| 1142 | - // filter list of modules to register |
|
| 1143 | - $modules_to_register = apply_filters( |
|
| 1144 | - 'FHEE__EE_Config__register_modules__modules_to_register', |
|
| 1145 | - $modules_to_register |
|
| 1146 | - ); |
|
| 1147 | - if (! empty($modules_to_register)) { |
|
| 1148 | - // loop through folders |
|
| 1149 | - foreach ($modules_to_register as $module_path) { |
|
| 1150 | - /**TEMPORARILY EXCLUDE gateways from modules for time being**/ |
|
| 1151 | - if ( |
|
| 1152 | - $module_path !== EE_MODULES . 'zzz-copy-this-module-template' |
|
| 1153 | - && $module_path !== EE_MODULES . 'gateways' |
|
| 1154 | - ) { |
|
| 1155 | - // add to list of installed modules |
|
| 1156 | - EE_Config::register_module($module_path); |
|
| 1157 | - } |
|
| 1158 | - } |
|
| 1159 | - } |
|
| 1160 | - // filter list of installed modules |
|
| 1161 | - return apply_filters( |
|
| 1162 | - 'FHEE__EE_Config___register_modules__installed_modules', |
|
| 1163 | - EE_Registry::instance()->modules |
|
| 1164 | - ); |
|
| 1165 | - } |
|
| 1166 | - |
|
| 1167 | - |
|
| 1168 | - |
|
| 1169 | - /** |
|
| 1170 | - * register_module - makes core aware of this module |
|
| 1171 | - * |
|
| 1172 | - * @access public |
|
| 1173 | - * @param string $module_path - full path up to and including module folder |
|
| 1174 | - * @return bool |
|
| 1175 | - */ |
|
| 1176 | - public static function register_module($module_path = null) |
|
| 1177 | - { |
|
| 1178 | - do_action('AHEE__EE_Config__register_module__begin', $module_path); |
|
| 1179 | - $module_ext = '.module.php'; |
|
| 1180 | - // make all separators match |
|
| 1181 | - $module_path = str_replace(array('\\', '/'), DS, $module_path); |
|
| 1182 | - // does the file path INCLUDE the actual file name as part of the path ? |
|
| 1183 | - if (strpos($module_path, $module_ext) !== false) { |
|
| 1184 | - // grab and shortcode file name from directory name and break apart at dots |
|
| 1185 | - $module_file = explode('.', basename($module_path)); |
|
| 1186 | - // now we need to rebuild the shortcode path |
|
| 1187 | - $module_path = explode(DS, $module_path); |
|
| 1188 | - // remove last segment |
|
| 1189 | - array_pop($module_path); |
|
| 1190 | - // glue it back together |
|
| 1191 | - $module_path = implode(DS, $module_path) . DS; |
|
| 1192 | - // take first segment from file name pieces and sanitize it |
|
| 1193 | - $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]); |
|
| 1194 | - // ensure class prefix is added |
|
| 1195 | - $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module; |
|
| 1196 | - } else { |
|
| 1197 | - // we need to generate the filename based off of the folder name |
|
| 1198 | - // grab and sanitize module name |
|
| 1199 | - $module = strtolower(basename($module_path)); |
|
| 1200 | - $module = preg_replace('/[^a-z0-9_\-]/', '', $module); |
|
| 1201 | - // like trailingslashit() |
|
| 1202 | - $module_path = rtrim($module_path, DS) . DS; |
|
| 1203 | - // create classname from module directory name |
|
| 1204 | - $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module))); |
|
| 1205 | - // add class prefix |
|
| 1206 | - $module_class = 'EED_' . $module; |
|
| 1207 | - } |
|
| 1208 | - // does the module exist ? |
|
| 1209 | - if (! is_readable($module_path . DS . $module_class . $module_ext)) { |
|
| 1210 | - $msg = sprintf( |
|
| 1211 | - __( |
|
| 1212 | - 'The requested %s module file could not be found or is not readable due to file permissions.', |
|
| 1213 | - 'event_espresso' |
|
| 1214 | - ), |
|
| 1215 | - $module |
|
| 1216 | - ); |
|
| 1217 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1218 | - return false; |
|
| 1219 | - } |
|
| 1220 | - // load the module class file |
|
| 1221 | - require_once($module_path . $module_class . $module_ext); |
|
| 1222 | - // verify that class exists |
|
| 1223 | - if (! class_exists($module_class)) { |
|
| 1224 | - $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class); |
|
| 1225 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1226 | - return false; |
|
| 1227 | - } |
|
| 1228 | - // add to array of registered modules |
|
| 1229 | - EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext; |
|
| 1230 | - do_action( |
|
| 1231 | - 'AHEE__EE_Config__register_module__complete', |
|
| 1232 | - $module_class, |
|
| 1233 | - EE_Registry::instance()->modules->{$module_class} |
|
| 1234 | - ); |
|
| 1235 | - return true; |
|
| 1236 | - } |
|
| 1237 | - |
|
| 1238 | - |
|
| 1239 | - |
|
| 1240 | - /** |
|
| 1241 | - * _initialize_modules |
|
| 1242 | - * allow modules to set hooks for the rest of the system |
|
| 1243 | - * |
|
| 1244 | - * @access private |
|
| 1245 | - * @return void |
|
| 1246 | - */ |
|
| 1247 | - private function _initialize_modules() |
|
| 1248 | - { |
|
| 1249 | - // cycle thru shortcode folders |
|
| 1250 | - foreach (EE_Registry::instance()->modules as $module_class => $module_path) { |
|
| 1251 | - // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
|
| 1252 | - // which set hooks ? |
|
| 1253 | - if (is_admin()) { |
|
| 1254 | - // fire immediately |
|
| 1255 | - call_user_func(array($module_class, 'set_hooks_admin')); |
|
| 1256 | - } else { |
|
| 1257 | - // delay until other systems are online |
|
| 1258 | - add_action( |
|
| 1259 | - 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', |
|
| 1260 | - array($module_class, 'set_hooks') |
|
| 1261 | - ); |
|
| 1262 | - } |
|
| 1263 | - } |
|
| 1264 | - } |
|
| 1265 | - |
|
| 1266 | - |
|
| 1267 | - |
|
| 1268 | - /** |
|
| 1269 | - * register_route - adds module method routes to route_map |
|
| 1270 | - * |
|
| 1271 | - * @access public |
|
| 1272 | - * @param string $route - "pretty" public alias for module method |
|
| 1273 | - * @param string $module - module name (classname without EED_ prefix) |
|
| 1274 | - * @param string $method_name - the actual module method to be routed to |
|
| 1275 | - * @param string $key - url param key indicating a route is being called |
|
| 1276 | - * @return bool |
|
| 1277 | - */ |
|
| 1278 | - public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee') |
|
| 1279 | - { |
|
| 1280 | - do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name); |
|
| 1281 | - $module = str_replace('EED_', '', $module); |
|
| 1282 | - $module_class = 'EED_' . $module; |
|
| 1283 | - if (! isset(EE_Registry::instance()->modules->{$module_class})) { |
|
| 1284 | - $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module); |
|
| 1285 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1286 | - return false; |
|
| 1287 | - } |
|
| 1288 | - if (empty($route)) { |
|
| 1289 | - $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route); |
|
| 1290 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1291 | - return false; |
|
| 1292 | - } |
|
| 1293 | - if (! method_exists('EED_' . $module, $method_name)) { |
|
| 1294 | - $msg = sprintf( |
|
| 1295 | - __('A valid class method for the %s route has not been supplied.', 'event_espresso'), |
|
| 1296 | - $route |
|
| 1297 | - ); |
|
| 1298 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1299 | - return false; |
|
| 1300 | - } |
|
| 1301 | - EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name); |
|
| 1302 | - return true; |
|
| 1303 | - } |
|
| 1304 | - |
|
| 1305 | - |
|
| 1306 | - |
|
| 1307 | - /** |
|
| 1308 | - * get_route - get module method route |
|
| 1309 | - * |
|
| 1310 | - * @access public |
|
| 1311 | - * @param string $route - "pretty" public alias for module method |
|
| 1312 | - * @param string $key - url param key indicating a route is being called |
|
| 1313 | - * @return string |
|
| 1314 | - */ |
|
| 1315 | - public static function get_route($route = null, $key = 'ee') |
|
| 1316 | - { |
|
| 1317 | - do_action('AHEE__EE_Config__get_route__begin', $route); |
|
| 1318 | - $route = (string)apply_filters('FHEE__EE_Config__get_route', $route); |
|
| 1319 | - if (isset(EE_Config::$_module_route_map[$key][$route])) { |
|
| 1320 | - return EE_Config::$_module_route_map[$key][$route]; |
|
| 1321 | - } |
|
| 1322 | - return null; |
|
| 1323 | - } |
|
| 1324 | - |
|
| 1325 | - |
|
| 1326 | - |
|
| 1327 | - /** |
|
| 1328 | - * get_routes - get ALL module method routes |
|
| 1329 | - * |
|
| 1330 | - * @access public |
|
| 1331 | - * @return array |
|
| 1332 | - */ |
|
| 1333 | - public static function get_routes() |
|
| 1334 | - { |
|
| 1335 | - return EE_Config::$_module_route_map; |
|
| 1336 | - } |
|
| 1337 | - |
|
| 1338 | - |
|
| 1339 | - |
|
| 1340 | - /** |
|
| 1341 | - * register_forward - allows modules to forward request to another module for further processing |
|
| 1342 | - * |
|
| 1343 | - * @access public |
|
| 1344 | - * @param string $route - "pretty" public alias for module method |
|
| 1345 | - * @param integer $status - integer value corresponding to status constant strings set in module parent |
|
| 1346 | - * class, allows different forwards to be served based on status |
|
| 1347 | - * @param array|string $forward - function name or array( class, method ) |
|
| 1348 | - * @param string $key - url param key indicating a route is being called |
|
| 1349 | - * @return bool |
|
| 1350 | - */ |
|
| 1351 | - public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee') |
|
| 1352 | - { |
|
| 1353 | - do_action('AHEE__EE_Config__register_forward', $route, $status, $forward); |
|
| 1354 | - if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
| 1355 | - $msg = sprintf( |
|
| 1356 | - __('The module route %s for this forward has not been registered.', 'event_espresso'), |
|
| 1357 | - $route |
|
| 1358 | - ); |
|
| 1359 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1360 | - return false; |
|
| 1361 | - } |
|
| 1362 | - if (empty($forward)) { |
|
| 1363 | - $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route); |
|
| 1364 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1365 | - return false; |
|
| 1366 | - } |
|
| 1367 | - if (is_array($forward)) { |
|
| 1368 | - if (! isset($forward[1])) { |
|
| 1369 | - $msg = sprintf( |
|
| 1370 | - __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'), |
|
| 1371 | - $route |
|
| 1372 | - ); |
|
| 1373 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1374 | - return false; |
|
| 1375 | - } |
|
| 1376 | - if (! method_exists($forward[0], $forward[1])) { |
|
| 1377 | - $msg = sprintf( |
|
| 1378 | - __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'), |
|
| 1379 | - $forward[1], |
|
| 1380 | - $route |
|
| 1381 | - ); |
|
| 1382 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1383 | - return false; |
|
| 1384 | - } |
|
| 1385 | - } else if (! function_exists($forward)) { |
|
| 1386 | - $msg = sprintf( |
|
| 1387 | - __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'), |
|
| 1388 | - $forward, |
|
| 1389 | - $route |
|
| 1390 | - ); |
|
| 1391 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1392 | - return false; |
|
| 1393 | - } |
|
| 1394 | - EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward; |
|
| 1395 | - return true; |
|
| 1396 | - } |
|
| 1397 | - |
|
| 1398 | - |
|
| 1399 | - |
|
| 1400 | - /** |
|
| 1401 | - * get_forward - get forwarding route |
|
| 1402 | - * |
|
| 1403 | - * @access public |
|
| 1404 | - * @param string $route - "pretty" public alias for module method |
|
| 1405 | - * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
| 1406 | - * allows different forwards to be served based on status |
|
| 1407 | - * @param string $key - url param key indicating a route is being called |
|
| 1408 | - * @return string |
|
| 1409 | - */ |
|
| 1410 | - public static function get_forward($route = null, $status = 0, $key = 'ee') |
|
| 1411 | - { |
|
| 1412 | - do_action('AHEE__EE_Config__get_forward__begin', $route, $status); |
|
| 1413 | - if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) { |
|
| 1414 | - return apply_filters( |
|
| 1415 | - 'FHEE__EE_Config__get_forward', |
|
| 1416 | - EE_Config::$_module_forward_map[$key][$route][$status], |
|
| 1417 | - $route, |
|
| 1418 | - $status |
|
| 1419 | - ); |
|
| 1420 | - } |
|
| 1421 | - return null; |
|
| 1422 | - } |
|
| 1423 | - |
|
| 1424 | - |
|
| 1425 | - |
|
| 1426 | - /** |
|
| 1427 | - * register_forward - allows modules to specify different view templates for different method routes and status |
|
| 1428 | - * results |
|
| 1429 | - * |
|
| 1430 | - * @access public |
|
| 1431 | - * @param string $route - "pretty" public alias for module method |
|
| 1432 | - * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
| 1433 | - * allows different views to be served based on status |
|
| 1434 | - * @param string $view |
|
| 1435 | - * @param string $key - url param key indicating a route is being called |
|
| 1436 | - * @return bool |
|
| 1437 | - */ |
|
| 1438 | - public static function register_view($route = null, $status = 0, $view = null, $key = 'ee') |
|
| 1439 | - { |
|
| 1440 | - do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view); |
|
| 1441 | - if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
| 1442 | - $msg = sprintf( |
|
| 1443 | - __('The module route %s for this view has not been registered.', 'event_espresso'), |
|
| 1444 | - $route |
|
| 1445 | - ); |
|
| 1446 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1447 | - return false; |
|
| 1448 | - } |
|
| 1449 | - if (! is_readable($view)) { |
|
| 1450 | - $msg = sprintf( |
|
| 1451 | - __( |
|
| 1452 | - 'The %s view file could not be found or is not readable due to file permissions.', |
|
| 1453 | - 'event_espresso' |
|
| 1454 | - ), |
|
| 1455 | - $view |
|
| 1456 | - ); |
|
| 1457 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1458 | - return false; |
|
| 1459 | - } |
|
| 1460 | - EE_Config::$_module_view_map[$key][$route][absint($status)] = $view; |
|
| 1461 | - return true; |
|
| 1462 | - } |
|
| 1463 | - |
|
| 1464 | - |
|
| 1465 | - |
|
| 1466 | - /** |
|
| 1467 | - * get_view - get view for route and status |
|
| 1468 | - * |
|
| 1469 | - * @access public |
|
| 1470 | - * @param string $route - "pretty" public alias for module method |
|
| 1471 | - * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
| 1472 | - * allows different views to be served based on status |
|
| 1473 | - * @param string $key - url param key indicating a route is being called |
|
| 1474 | - * @return string |
|
| 1475 | - */ |
|
| 1476 | - public static function get_view($route = null, $status = 0, $key = 'ee') |
|
| 1477 | - { |
|
| 1478 | - do_action('AHEE__EE_Config__get_view__begin', $route, $status); |
|
| 1479 | - if (isset(EE_Config::$_module_view_map[$key][$route][$status])) { |
|
| 1480 | - return apply_filters( |
|
| 1481 | - 'FHEE__EE_Config__get_view', |
|
| 1482 | - EE_Config::$_module_view_map[$key][$route][$status], |
|
| 1483 | - $route, |
|
| 1484 | - $status |
|
| 1485 | - ); |
|
| 1486 | - } |
|
| 1487 | - return null; |
|
| 1488 | - } |
|
| 1489 | - |
|
| 1490 | - |
|
| 1491 | - |
|
| 1492 | - public function update_addon_option_names() |
|
| 1493 | - { |
|
| 1494 | - update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names); |
|
| 1495 | - } |
|
| 1496 | - |
|
| 1497 | - |
|
| 1498 | - |
|
| 1499 | - public function shutdown() |
|
| 1500 | - { |
|
| 1501 | - $this->update_addon_option_names(); |
|
| 1502 | - } |
|
| 1503 | - |
|
| 1504 | - |
|
| 1505 | - |
|
| 1506 | - /** |
|
| 1507 | - * @return LegacyShortcodesManager |
|
| 1508 | - */ |
|
| 1509 | - public static function getLegacyShortcodesManager() |
|
| 1510 | - { |
|
| 1511 | - |
|
| 1512 | - if ( ! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) { |
|
| 1513 | - EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager( |
|
| 1514 | - EE_Registry::instance() |
|
| 1515 | - ); |
|
| 1516 | - } |
|
| 1517 | - return EE_Config::instance()->legacy_shortcodes_manager; |
|
| 1518 | - } |
|
| 1519 | - |
|
| 1520 | - |
|
| 1521 | - |
|
| 1522 | - /** |
|
| 1523 | - * register_shortcode - makes core aware of this shortcode |
|
| 1524 | - * |
|
| 1525 | - * @deprecated 4.9.26 |
|
| 1526 | - * @param string $shortcode_path - full path up to and including shortcode folder |
|
| 1527 | - * @return bool |
|
| 1528 | - */ |
|
| 1529 | - public static function register_shortcode($shortcode_path = null) |
|
| 1530 | - { |
|
| 1531 | - EE_Error::doing_it_wrong( |
|
| 1532 | - __METHOD__, |
|
| 1533 | - __( |
|
| 1534 | - 'Usage is deprecated. Use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::registerShortcode() as direct replacement, or better yet, please see the new \EventEspresso\core\services\shortcodes\ShortcodesManager class.', |
|
| 1535 | - 'event_espresso' |
|
| 1536 | - ), |
|
| 1537 | - '4.9.26' |
|
| 1538 | - ); |
|
| 1539 | - return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path); |
|
| 1540 | - } |
|
| 1541 | - |
|
| 1542 | - |
|
| 1543 | - |
|
| 1544 | -} |
|
| 1545 | - |
|
| 1546 | - |
|
| 1547 | - |
|
| 1548 | -/** |
|
| 1549 | - * Base class used for config classes. These classes should generally not have |
|
| 1550 | - * magic functions in use, except we'll allow them to magically set and get stuff... |
|
| 1551 | - * basically, they should just be well-defined stdClasses |
|
| 1552 | - */ |
|
| 1553 | -class EE_Config_Base |
|
| 1554 | -{ |
|
| 1555 | - |
|
| 1556 | - /** |
|
| 1557 | - * Utility function for escaping the value of a property and returning. |
|
| 1558 | - * |
|
| 1559 | - * @param string $property property name (checks to see if exists). |
|
| 1560 | - * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned. |
|
| 1561 | - * @throws \EE_Error |
|
| 1562 | - */ |
|
| 1563 | - public function get_pretty($property) |
|
| 1564 | - { |
|
| 1565 | - if (! property_exists($this, $property)) { |
|
| 1566 | - throw new EE_Error( |
|
| 1567 | - sprintf( |
|
| 1568 | - __( |
|
| 1569 | - '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.', |
|
| 1570 | - 'event_espresso' |
|
| 1571 | - ), |
|
| 1572 | - get_class($this), |
|
| 1573 | - $property |
|
| 1574 | - ) |
|
| 1575 | - ); |
|
| 1576 | - } |
|
| 1577 | - //just handling escaping of strings for now. |
|
| 1578 | - if (is_string($this->{$property})) { |
|
| 1579 | - return stripslashes($this->{$property}); |
|
| 1580 | - } |
|
| 1581 | - return $this->{$property}; |
|
| 1582 | - } |
|
| 1583 | - |
|
| 1584 | - |
|
| 1585 | - |
|
| 1586 | - public function populate() |
|
| 1587 | - { |
|
| 1588 | - //grab defaults via a new instance of this class. |
|
| 1589 | - $class_name = get_class($this); |
|
| 1590 | - $defaults = new $class_name; |
|
| 1591 | - //loop through the properties for this class and see if they are set. If they are NOT, then grab the |
|
| 1592 | - //default from our $defaults object. |
|
| 1593 | - foreach (get_object_vars($defaults) as $property => $value) { |
|
| 1594 | - if ($this->{$property} === null) { |
|
| 1595 | - $this->{$property} = $value; |
|
| 1596 | - } |
|
| 1597 | - } |
|
| 1598 | - //cleanup |
|
| 1599 | - unset($defaults); |
|
| 1600 | - } |
|
| 1601 | - |
|
| 1602 | - |
|
| 1603 | - |
|
| 1604 | - /** |
|
| 1605 | - * __isset |
|
| 1606 | - * |
|
| 1607 | - * @param $a |
|
| 1608 | - * @return bool |
|
| 1609 | - */ |
|
| 1610 | - public function __isset($a) |
|
| 1611 | - { |
|
| 1612 | - return false; |
|
| 1613 | - } |
|
| 1614 | - |
|
| 1615 | - |
|
| 1616 | - |
|
| 1617 | - /** |
|
| 1618 | - * __unset |
|
| 1619 | - * |
|
| 1620 | - * @param $a |
|
| 1621 | - * @return bool |
|
| 1622 | - */ |
|
| 1623 | - public function __unset($a) |
|
| 1624 | - { |
|
| 1625 | - return false; |
|
| 1626 | - } |
|
| 1627 | - |
|
| 1628 | - |
|
| 1629 | - |
|
| 1630 | - /** |
|
| 1631 | - * __clone |
|
| 1632 | - */ |
|
| 1633 | - public function __clone() |
|
| 1634 | - { |
|
| 1635 | - } |
|
| 1636 | - |
|
| 1637 | - |
|
| 1638 | - |
|
| 1639 | - /** |
|
| 1640 | - * __wakeup |
|
| 1641 | - */ |
|
| 1642 | - public function __wakeup() |
|
| 1643 | - { |
|
| 1644 | - } |
|
| 1645 | - |
|
| 1646 | - |
|
| 1647 | - |
|
| 1648 | - /** |
|
| 1649 | - * __destruct |
|
| 1650 | - */ |
|
| 1651 | - public function __destruct() |
|
| 1652 | - { |
|
| 1653 | - } |
|
| 1654 | -} |
|
| 1655 | - |
|
| 1656 | - |
|
| 1657 | - |
|
| 1658 | -/** |
|
| 1659 | - * Class for defining what's in the EE_Config relating to registration settings |
|
| 1660 | - */ |
|
| 1661 | -class EE_Core_Config extends EE_Config_Base |
|
| 1662 | -{ |
|
| 1663 | - |
|
| 1664 | - public $current_blog_id; |
|
| 1665 | - |
|
| 1666 | - public $ee_ueip_optin; |
|
| 1667 | - |
|
| 1668 | - public $ee_ueip_has_notified; |
|
| 1669 | - |
|
| 1670 | - /** |
|
| 1671 | - * Not to be confused with the 4 critical page variables (See |
|
| 1672 | - * get_critical_pages_array()), this is just an array of wp posts that have EE |
|
| 1673 | - * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode |
|
| 1674 | - * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array. |
|
| 1675 | - * |
|
| 1676 | - * @var array |
|
| 1677 | - */ |
|
| 1678 | - public $post_shortcodes; |
|
| 1679 | - |
|
| 1680 | - public $module_route_map; |
|
| 1681 | - |
|
| 1682 | - public $module_forward_map; |
|
| 1683 | - |
|
| 1684 | - public $module_view_map; |
|
| 1685 | - |
|
| 1686 | - /** |
|
| 1687 | - * The next 4 vars are the IDs of critical EE pages. |
|
| 1688 | - * |
|
| 1689 | - * @var int |
|
| 1690 | - */ |
|
| 1691 | - public $reg_page_id; |
|
| 1692 | - |
|
| 1693 | - public $txn_page_id; |
|
| 1694 | - |
|
| 1695 | - public $thank_you_page_id; |
|
| 1696 | - |
|
| 1697 | - public $cancel_page_id; |
|
| 1698 | - |
|
| 1699 | - /** |
|
| 1700 | - * The next 4 vars are the URLs of critical EE pages. |
|
| 1701 | - * |
|
| 1702 | - * @var int |
|
| 1703 | - */ |
|
| 1704 | - public $reg_page_url; |
|
| 1705 | - |
|
| 1706 | - public $txn_page_url; |
|
| 1707 | - |
|
| 1708 | - public $thank_you_page_url; |
|
| 1709 | - |
|
| 1710 | - public $cancel_page_url; |
|
| 1711 | - |
|
| 1712 | - /** |
|
| 1713 | - * The next vars relate to the custom slugs for EE CPT routes |
|
| 1714 | - */ |
|
| 1715 | - public $event_cpt_slug; |
|
| 1716 | - |
|
| 1717 | - |
|
| 1718 | - /** |
|
| 1719 | - * This caches the _ee_ueip_option in case this config is reset in the same |
|
| 1720 | - * request across blog switches in a multisite context. |
|
| 1721 | - * Avoids extra queries to the db for this option. |
|
| 1722 | - * |
|
| 1723 | - * @var bool |
|
| 1724 | - */ |
|
| 1725 | - public static $ee_ueip_option; |
|
| 1726 | - |
|
| 1727 | - |
|
| 1728 | - |
|
| 1729 | - /** |
|
| 1730 | - * class constructor |
|
| 1731 | - * |
|
| 1732 | - * @access public |
|
| 1733 | - */ |
|
| 1734 | - public function __construct() |
|
| 1735 | - { |
|
| 1736 | - // set default organization settings |
|
| 1737 | - $this->current_blog_id = get_current_blog_id(); |
|
| 1738 | - $this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id; |
|
| 1739 | - $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin(); |
|
| 1740 | - $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true; |
|
| 1741 | - $this->post_shortcodes = array(); |
|
| 1742 | - $this->module_route_map = array(); |
|
| 1743 | - $this->module_forward_map = array(); |
|
| 1744 | - $this->module_view_map = array(); |
|
| 1745 | - // critical EE page IDs |
|
| 1746 | - $this->reg_page_id = 0; |
|
| 1747 | - $this->txn_page_id = 0; |
|
| 1748 | - $this->thank_you_page_id = 0; |
|
| 1749 | - $this->cancel_page_id = 0; |
|
| 1750 | - // critical EE page URLs |
|
| 1751 | - $this->reg_page_url = ''; |
|
| 1752 | - $this->txn_page_url = ''; |
|
| 1753 | - $this->thank_you_page_url = ''; |
|
| 1754 | - $this->cancel_page_url = ''; |
|
| 1755 | - //cpt slugs |
|
| 1756 | - $this->event_cpt_slug = __('events', 'event_espresso'); |
|
| 1757 | - //ueip constant check |
|
| 1758 | - if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) { |
|
| 1759 | - $this->ee_ueip_optin = false; |
|
| 1760 | - $this->ee_ueip_has_notified = true; |
|
| 1761 | - } |
|
| 1762 | - } |
|
| 1763 | - |
|
| 1764 | - |
|
| 1765 | - |
|
| 1766 | - /** |
|
| 1767 | - * @return array |
|
| 1768 | - */ |
|
| 1769 | - public function get_critical_pages_array() |
|
| 1770 | - { |
|
| 1771 | - return array( |
|
| 1772 | - $this->reg_page_id, |
|
| 1773 | - $this->txn_page_id, |
|
| 1774 | - $this->thank_you_page_id, |
|
| 1775 | - $this->cancel_page_id, |
|
| 1776 | - ); |
|
| 1777 | - } |
|
| 1778 | - |
|
| 1779 | - |
|
| 1780 | - |
|
| 1781 | - /** |
|
| 1782 | - * @return array |
|
| 1783 | - */ |
|
| 1784 | - public function get_critical_pages_shortcodes_array() |
|
| 1785 | - { |
|
| 1786 | - return array( |
|
| 1787 | - $this->reg_page_id => 'ESPRESSO_CHECKOUT', |
|
| 1788 | - $this->txn_page_id => 'ESPRESSO_TXN_PAGE', |
|
| 1789 | - $this->thank_you_page_id => 'ESPRESSO_THANK_YOU', |
|
| 1790 | - $this->cancel_page_id => 'ESPRESSO_CANCELLED', |
|
| 1791 | - ); |
|
| 1792 | - } |
|
| 1793 | - |
|
| 1794 | - |
|
| 1795 | - |
|
| 1796 | - /** |
|
| 1797 | - * gets/returns URL for EE reg_page |
|
| 1798 | - * |
|
| 1799 | - * @access public |
|
| 1800 | - * @return string |
|
| 1801 | - */ |
|
| 1802 | - public function reg_page_url() |
|
| 1803 | - { |
|
| 1804 | - if (! $this->reg_page_url) { |
|
| 1805 | - $this->reg_page_url = add_query_arg( |
|
| 1806 | - array('uts' => time()), |
|
| 1807 | - get_permalink($this->reg_page_id) |
|
| 1808 | - ) . '#checkout'; |
|
| 1809 | - } |
|
| 1810 | - return $this->reg_page_url; |
|
| 1811 | - } |
|
| 1812 | - |
|
| 1813 | - |
|
| 1814 | - |
|
| 1815 | - /** |
|
| 1816 | - * gets/returns URL for EE txn_page |
|
| 1817 | - * |
|
| 1818 | - * @param array $query_args like what gets passed to |
|
| 1819 | - * add_query_arg() as the first argument |
|
| 1820 | - * @access public |
|
| 1821 | - * @return string |
|
| 1822 | - */ |
|
| 1823 | - public function txn_page_url($query_args = array()) |
|
| 1824 | - { |
|
| 1825 | - if (! $this->txn_page_url) { |
|
| 1826 | - $this->txn_page_url = get_permalink($this->txn_page_id); |
|
| 1827 | - } |
|
| 1828 | - if ($query_args) { |
|
| 1829 | - return add_query_arg($query_args, $this->txn_page_url); |
|
| 1830 | - } else { |
|
| 1831 | - return $this->txn_page_url; |
|
| 1832 | - } |
|
| 1833 | - } |
|
| 1834 | - |
|
| 1835 | - |
|
| 1836 | - |
|
| 1837 | - /** |
|
| 1838 | - * gets/returns URL for EE thank_you_page |
|
| 1839 | - * |
|
| 1840 | - * @param array $query_args like what gets passed to |
|
| 1841 | - * add_query_arg() as the first argument |
|
| 1842 | - * @access public |
|
| 1843 | - * @return string |
|
| 1844 | - */ |
|
| 1845 | - public function thank_you_page_url($query_args = array()) |
|
| 1846 | - { |
|
| 1847 | - if (! $this->thank_you_page_url) { |
|
| 1848 | - $this->thank_you_page_url = get_permalink($this->thank_you_page_id); |
|
| 1849 | - } |
|
| 1850 | - if ($query_args) { |
|
| 1851 | - return add_query_arg($query_args, $this->thank_you_page_url); |
|
| 1852 | - } else { |
|
| 1853 | - return $this->thank_you_page_url; |
|
| 1854 | - } |
|
| 1855 | - } |
|
| 1856 | - |
|
| 1857 | - |
|
| 1858 | - |
|
| 1859 | - /** |
|
| 1860 | - * gets/returns URL for EE cancel_page |
|
| 1861 | - * |
|
| 1862 | - * @access public |
|
| 1863 | - * @return string |
|
| 1864 | - */ |
|
| 1865 | - public function cancel_page_url() |
|
| 1866 | - { |
|
| 1867 | - if (! $this->cancel_page_url) { |
|
| 1868 | - $this->cancel_page_url = get_permalink($this->cancel_page_id); |
|
| 1869 | - } |
|
| 1870 | - return $this->cancel_page_url; |
|
| 1871 | - } |
|
| 1872 | - |
|
| 1873 | - |
|
| 1874 | - |
|
| 1875 | - /** |
|
| 1876 | - * Resets all critical page urls to their original state. Used primarily by the __sleep() magic method currently. |
|
| 1877 | - * |
|
| 1878 | - * @since 4.7.5 |
|
| 1879 | - */ |
|
| 1880 | - protected function _reset_urls() |
|
| 1881 | - { |
|
| 1882 | - $this->reg_page_url = ''; |
|
| 1883 | - $this->txn_page_url = ''; |
|
| 1884 | - $this->cancel_page_url = ''; |
|
| 1885 | - $this->thank_you_page_url = ''; |
|
| 1886 | - } |
|
| 1887 | - |
|
| 1888 | - |
|
| 1889 | - |
|
| 1890 | - /** |
|
| 1891 | - * Used to return what the optin value is set for the EE User Experience Program. |
|
| 1892 | - * This accounts for multisite and this value being requested for a subsite. In multisite, the value is set |
|
| 1893 | - * on the main site only. |
|
| 1894 | - * |
|
| 1895 | - * @return mixed|void |
|
| 1896 | - */ |
|
| 1897 | - protected function _get_main_ee_ueip_optin() |
|
| 1898 | - { |
|
| 1899 | - //if this is the main site then we can just bypass our direct query. |
|
| 1900 | - if (is_main_site()) { |
|
| 1901 | - return get_option('ee_ueip_optin', false); |
|
| 1902 | - } |
|
| 1903 | - //is this already cached for this request? If so use it. |
|
| 1904 | - if ( ! empty(EE_Core_Config::$ee_ueip_option)) { |
|
| 1905 | - return EE_Core_Config::$ee_ueip_option; |
|
| 1906 | - } |
|
| 1907 | - global $wpdb; |
|
| 1908 | - $current_network_main_site = is_multisite() ? get_current_site() : null; |
|
| 1909 | - $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1; |
|
| 1910 | - $option = 'ee_ueip_optin'; |
|
| 1911 | - //set correct table for query |
|
| 1912 | - $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options'; |
|
| 1913 | - //rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because |
|
| 1914 | - //get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be |
|
| 1915 | - //re-constructed on the blog switch. Note, we are still executing any core wp filters on this option retrieval. |
|
| 1916 | - //this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog |
|
| 1917 | - //for the purpose of caching. |
|
| 1918 | - $pre = apply_filters('pre_option_' . $option, false, $option); |
|
| 1919 | - if (false !== $pre) { |
|
| 1920 | - EE_Core_Config::$ee_ueip_option = $pre; |
|
| 1921 | - return EE_Core_Config::$ee_ueip_option; |
|
| 1922 | - } |
|
| 1923 | - $row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1", |
|
| 1924 | - $option)); |
|
| 1925 | - if (is_object($row)) { |
|
| 1926 | - $value = $row->option_value; |
|
| 1927 | - } else { //option does not exist so use default. |
|
| 1928 | - return apply_filters('default_option_' . $option, false, $option); |
|
| 1929 | - } |
|
| 1930 | - EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option); |
|
| 1931 | - return EE_Core_Config::$ee_ueip_option; |
|
| 1932 | - } |
|
| 1933 | - |
|
| 1934 | - /** |
|
| 1935 | - * Utility function for escaping the value of a property and returning. |
|
| 1936 | - * |
|
| 1937 | - * @param string $property property name (checks to see if exists). |
|
| 1938 | - * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned. |
|
| 1939 | - * @throws \EE_Error |
|
| 1940 | - */ |
|
| 1941 | - public function get_pretty($property) |
|
| 1942 | - { |
|
| 1943 | - if ($property === 'ee_ueip_optin') { |
|
| 1944 | - return $this->ee_ueip_optin ? 'yes' : 'no'; |
|
| 1945 | - } |
|
| 1946 | - return parent::get_pretty($property); |
|
| 1947 | - } |
|
| 1948 | - |
|
| 1949 | - |
|
| 1950 | - /** |
|
| 1951 | - * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values |
|
| 1952 | - * on the object. |
|
| 1953 | - * |
|
| 1954 | - * @return array |
|
| 1955 | - */ |
|
| 1956 | - public function __sleep() |
|
| 1957 | - { |
|
| 1958 | - //reset all url properties |
|
| 1959 | - $this->_reset_urls(); |
|
| 1960 | - //return what to save to db |
|
| 1961 | - return array_keys(get_object_vars($this)); |
|
| 1962 | - } |
|
| 1963 | - |
|
| 1964 | -} |
|
| 1965 | - |
|
| 1966 | - |
|
| 1967 | - |
|
| 1968 | -/** |
|
| 1969 | - * Config class for storing info on the Organization |
|
| 1970 | - */ |
|
| 1971 | -class EE_Organization_Config extends EE_Config_Base |
|
| 1972 | -{ |
|
| 1973 | - |
|
| 1974 | - /** |
|
| 1975 | - * @var string $name |
|
| 1976 | - * eg EE4.1 |
|
| 1977 | - */ |
|
| 1978 | - public $name; |
|
| 1979 | - |
|
| 1980 | - /** |
|
| 1981 | - * @var string $address_1 |
|
| 1982 | - * eg 123 Onna Road |
|
| 1983 | - */ |
|
| 1984 | - public $address_1; |
|
| 1985 | - |
|
| 1986 | - /** |
|
| 1987 | - * @var string $address_2 |
|
| 1988 | - * eg PO Box 123 |
|
| 1989 | - */ |
|
| 1990 | - public $address_2; |
|
| 1991 | - |
|
| 1992 | - /** |
|
| 1993 | - * @var string $city |
|
| 1994 | - * eg Inna City |
|
| 1995 | - */ |
|
| 1996 | - public $city; |
|
| 1997 | - |
|
| 1998 | - /** |
|
| 1999 | - * @var int $STA_ID |
|
| 2000 | - * eg 4 |
|
| 2001 | - */ |
|
| 2002 | - public $STA_ID; |
|
| 2003 | - |
|
| 2004 | - /** |
|
| 2005 | - * @var string $CNT_ISO |
|
| 2006 | - * eg US |
|
| 2007 | - */ |
|
| 2008 | - public $CNT_ISO; |
|
| 2009 | - |
|
| 2010 | - /** |
|
| 2011 | - * @var string $zip |
|
| 2012 | - * eg 12345 or V1A 2B3 |
|
| 2013 | - */ |
|
| 2014 | - public $zip; |
|
| 2015 | - |
|
| 2016 | - /** |
|
| 2017 | - * @var string $email |
|
| 2018 | - * eg [email protected] |
|
| 2019 | - */ |
|
| 2020 | - public $email; |
|
| 2021 | - |
|
| 2022 | - |
|
| 2023 | - /** |
|
| 2024 | - * @var string $phone |
|
| 2025 | - * eg. 111-111-1111 |
|
| 2026 | - */ |
|
| 2027 | - public $phone; |
|
| 2028 | - |
|
| 2029 | - |
|
| 2030 | - /** |
|
| 2031 | - * @var string $vat |
|
| 2032 | - * VAT/Tax Number |
|
| 2033 | - */ |
|
| 2034 | - public $vat; |
|
| 2035 | - |
|
| 2036 | - /** |
|
| 2037 | - * @var string $logo_url |
|
| 2038 | - * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg |
|
| 2039 | - */ |
|
| 2040 | - public $logo_url; |
|
| 2041 | - |
|
| 2042 | - |
|
| 2043 | - /** |
|
| 2044 | - * The below are all various properties for holding links to organization social network profiles |
|
| 2045 | - * |
|
| 2046 | - * @var string |
|
| 2047 | - */ |
|
| 2048 | - /** |
|
| 2049 | - * facebook (facebook.com/profile.name) |
|
| 2050 | - * |
|
| 2051 | - * @var string |
|
| 2052 | - */ |
|
| 2053 | - public $facebook; |
|
| 2054 | - |
|
| 2055 | - |
|
| 2056 | - /** |
|
| 2057 | - * twitter (twitter.com/twitter_handle) |
|
| 2058 | - * |
|
| 2059 | - * @var string |
|
| 2060 | - */ |
|
| 2061 | - public $twitter; |
|
| 2062 | - |
|
| 2063 | - |
|
| 2064 | - /** |
|
| 2065 | - * linkedin (linkedin.com/in/profile_name) |
|
| 2066 | - * |
|
| 2067 | - * @var string |
|
| 2068 | - */ |
|
| 2069 | - public $linkedin; |
|
| 2070 | - |
|
| 2071 | - |
|
| 2072 | - /** |
|
| 2073 | - * pinterest (www.pinterest.com/profile_name) |
|
| 2074 | - * |
|
| 2075 | - * @var string |
|
| 2076 | - */ |
|
| 2077 | - public $pinterest; |
|
| 2078 | - |
|
| 2079 | - |
|
| 2080 | - /** |
|
| 2081 | - * google+ (google.com/+profileName) |
|
| 2082 | - * |
|
| 2083 | - * @var string |
|
| 2084 | - */ |
|
| 2085 | - public $google; |
|
| 2086 | - |
|
| 2087 | - |
|
| 2088 | - /** |
|
| 2089 | - * instagram (instagram.com/handle) |
|
| 2090 | - * |
|
| 2091 | - * @var string |
|
| 2092 | - */ |
|
| 2093 | - public $instagram; |
|
| 2094 | - |
|
| 2095 | - |
|
| 2096 | - |
|
| 2097 | - /** |
|
| 2098 | - * class constructor |
|
| 2099 | - * |
|
| 2100 | - * @access public |
|
| 2101 | - */ |
|
| 2102 | - public function __construct() |
|
| 2103 | - { |
|
| 2104 | - // set default organization settings |
|
| 2105 | - //decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded |
|
| 2106 | - $this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES); |
|
| 2107 | - $this->address_1 = '123 Onna Road'; |
|
| 2108 | - $this->address_2 = 'PO Box 123'; |
|
| 2109 | - $this->city = 'Inna City'; |
|
| 2110 | - $this->STA_ID = 4; |
|
| 2111 | - $this->CNT_ISO = 'US'; |
|
| 2112 | - $this->zip = '12345'; |
|
| 2113 | - $this->email = get_bloginfo('admin_email'); |
|
| 2114 | - $this->phone = ''; |
|
| 2115 | - $this->vat = '123456789'; |
|
| 2116 | - $this->logo_url = ''; |
|
| 2117 | - $this->facebook = ''; |
|
| 2118 | - $this->twitter = ''; |
|
| 2119 | - $this->linkedin = ''; |
|
| 2120 | - $this->pinterest = ''; |
|
| 2121 | - $this->google = ''; |
|
| 2122 | - $this->instagram = ''; |
|
| 2123 | - } |
|
| 2124 | - |
|
| 2125 | -} |
|
| 2126 | - |
|
| 2127 | - |
|
| 2128 | - |
|
| 2129 | -/** |
|
| 2130 | - * Class for defining what's in the EE_Config relating to currency |
|
| 2131 | - */ |
|
| 2132 | -class EE_Currency_Config extends EE_Config_Base |
|
| 2133 | -{ |
|
| 2134 | - |
|
| 2135 | - /** |
|
| 2136 | - * @var string $code |
|
| 2137 | - * eg 'US' |
|
| 2138 | - */ |
|
| 2139 | - public $code; |
|
| 2140 | - |
|
| 2141 | - /** |
|
| 2142 | - * @var string $name |
|
| 2143 | - * eg 'Dollar' |
|
| 2144 | - */ |
|
| 2145 | - public $name; |
|
| 2146 | - |
|
| 2147 | - /** |
|
| 2148 | - * plural name |
|
| 2149 | - * |
|
| 2150 | - * @var string $plural |
|
| 2151 | - * eg 'Dollars' |
|
| 2152 | - */ |
|
| 2153 | - public $plural; |
|
| 2154 | - |
|
| 2155 | - /** |
|
| 2156 | - * currency sign |
|
| 2157 | - * |
|
| 2158 | - * @var string $sign |
|
| 2159 | - * eg '$' |
|
| 2160 | - */ |
|
| 2161 | - public $sign; |
|
| 2162 | - |
|
| 2163 | - /** |
|
| 2164 | - * Whether the currency sign should come before the number or not |
|
| 2165 | - * |
|
| 2166 | - * @var boolean $sign_b4 |
|
| 2167 | - */ |
|
| 2168 | - public $sign_b4; |
|
| 2169 | - |
|
| 2170 | - /** |
|
| 2171 | - * How many digits should come after the decimal place |
|
| 2172 | - * |
|
| 2173 | - * @var int $dec_plc |
|
| 2174 | - */ |
|
| 2175 | - public $dec_plc; |
|
| 2176 | - |
|
| 2177 | - /** |
|
| 2178 | - * Symbol to use for decimal mark |
|
| 2179 | - * |
|
| 2180 | - * @var string $dec_mrk |
|
| 2181 | - * eg '.' |
|
| 2182 | - */ |
|
| 2183 | - public $dec_mrk; |
|
| 2184 | - |
|
| 2185 | - /** |
|
| 2186 | - * Symbol to use for thousands |
|
| 2187 | - * |
|
| 2188 | - * @var string $thsnds |
|
| 2189 | - * eg ',' |
|
| 2190 | - */ |
|
| 2191 | - public $thsnds; |
|
| 2192 | - |
|
| 2193 | - |
|
| 2194 | - |
|
| 2195 | - /** |
|
| 2196 | - * class constructor |
|
| 2197 | - * |
|
| 2198 | - * @access public |
|
| 2199 | - * @param string $CNT_ISO |
|
| 2200 | - * @throws \EE_Error |
|
| 2201 | - */ |
|
| 2202 | - public function __construct($CNT_ISO = '') |
|
| 2203 | - { |
|
| 2204 | - /** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */ |
|
| 2205 | - $table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
| 2206 | - // get country code from organization settings or use default |
|
| 2207 | - $ORG_CNT = isset(EE_Registry::instance()->CFG->organization) |
|
| 2208 | - && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config |
|
| 2209 | - ? EE_Registry::instance()->CFG->organization->CNT_ISO |
|
| 2210 | - : ''; |
|
| 2211 | - // but override if requested |
|
| 2212 | - $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT; |
|
| 2213 | - // so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists |
|
| 2214 | - if ( |
|
| 2215 | - ! empty($CNT_ISO) |
|
| 2216 | - && EE_Maintenance_Mode::instance()->models_can_query() |
|
| 2217 | - && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table()) |
|
| 2218 | - ) { |
|
| 2219 | - // retrieve the country settings from the db, just in case they have been customized |
|
| 2220 | - $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO); |
|
| 2221 | - if ($country instanceof EE_Country) { |
|
| 2222 | - $this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
| 2223 | - $this->name = $country->currency_name_single(); // Dollar |
|
| 2224 | - $this->plural = $country->currency_name_plural(); // Dollars |
|
| 2225 | - $this->sign = $country->currency_sign(); // currency sign: $ |
|
| 2226 | - $this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE or FALSE$ |
|
| 2227 | - $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
| 2228 | - $this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
| 2229 | - $this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
| 2230 | - } |
|
| 2231 | - } |
|
| 2232 | - // fallback to hardcoded defaults, in case the above failed |
|
| 2233 | - if (empty($this->code)) { |
|
| 2234 | - // set default currency settings |
|
| 2235 | - $this->code = 'USD'; // currency code: USD, CAD, EUR |
|
| 2236 | - $this->name = __('Dollar', 'event_espresso'); // Dollar |
|
| 2237 | - $this->plural = __('Dollars', 'event_espresso'); // Dollars |
|
| 2238 | - $this->sign = '$'; // currency sign: $ |
|
| 2239 | - $this->sign_b4 = true; // currency sign before or after: $TRUE or FALSE$ |
|
| 2240 | - $this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
| 2241 | - $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
| 2242 | - $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
| 2243 | - } |
|
| 2244 | - } |
|
| 2245 | -} |
|
| 2246 | - |
|
| 2247 | - |
|
| 2248 | - |
|
| 2249 | -/** |
|
| 2250 | - * Class for defining what's in the EE_Config relating to registration settings |
|
| 2251 | - */ |
|
| 2252 | -class EE_Registration_Config extends EE_Config_Base |
|
| 2253 | -{ |
|
| 2254 | - |
|
| 2255 | - /** |
|
| 2256 | - * Default registration status |
|
| 2257 | - * |
|
| 2258 | - * @var string $default_STS_ID |
|
| 2259 | - * eg 'RPP' |
|
| 2260 | - */ |
|
| 2261 | - public $default_STS_ID; |
|
| 2262 | - |
|
| 2263 | - |
|
| 2264 | - /** |
|
| 2265 | - * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of |
|
| 2266 | - * registrations) |
|
| 2267 | - * @var int |
|
| 2268 | - */ |
|
| 2269 | - public $default_maximum_number_of_tickets; |
|
| 2270 | - |
|
| 2271 | - |
|
| 2272 | - /** |
|
| 2273 | - * level of validation to apply to email addresses |
|
| 2274 | - * |
|
| 2275 | - * @var string $email_validation_level |
|
| 2276 | - * options: 'basic', 'wp_default', 'i18n', 'i18n_dns' |
|
| 2277 | - */ |
|
| 2278 | - public $email_validation_level; |
|
| 2279 | - |
|
| 2280 | - /** |
|
| 2281 | - * whether or not to show alternate payment options during the reg process if payment status is pending |
|
| 2282 | - * |
|
| 2283 | - * @var boolean $show_pending_payment_options |
|
| 2284 | - */ |
|
| 2285 | - public $show_pending_payment_options; |
|
| 2286 | - |
|
| 2287 | - /** |
|
| 2288 | - * Whether to skip the registration confirmation page |
|
| 2289 | - * |
|
| 2290 | - * @var boolean $skip_reg_confirmation |
|
| 2291 | - */ |
|
| 2292 | - public $skip_reg_confirmation; |
|
| 2293 | - |
|
| 2294 | - /** |
|
| 2295 | - * an array of SPCO reg steps where: |
|
| 2296 | - * the keys denotes the reg step order |
|
| 2297 | - * each element consists of an array with the following elements: |
|
| 2298 | - * "file_path" => the file path to the EE_SPCO_Reg_Step class |
|
| 2299 | - * "class_name" => the specific EE_SPCO_Reg_Step child class name |
|
| 2300 | - * "slug" => the URL param used to trigger the reg step |
|
| 2301 | - * |
|
| 2302 | - * @var array $reg_steps |
|
| 2303 | - */ |
|
| 2304 | - public $reg_steps; |
|
| 2305 | - |
|
| 2306 | - /** |
|
| 2307 | - * Whether registration confirmation should be the last page of SPCO |
|
| 2308 | - * |
|
| 2309 | - * @var boolean $reg_confirmation_last |
|
| 2310 | - */ |
|
| 2311 | - public $reg_confirmation_last; |
|
| 2312 | - |
|
| 2313 | - /** |
|
| 2314 | - * Whether or not to enable the EE Bot Trap |
|
| 2315 | - * |
|
| 2316 | - * @var boolean $use_bot_trap |
|
| 2317 | - */ |
|
| 2318 | - public $use_bot_trap; |
|
| 2319 | - |
|
| 2320 | - /** |
|
| 2321 | - * Whether or not to encrypt some data sent by the EE Bot Trap |
|
| 2322 | - * |
|
| 2323 | - * @var boolean $use_encryption |
|
| 2324 | - */ |
|
| 2325 | - public $use_encryption; |
|
| 2326 | - |
|
| 2327 | - /** |
|
| 2328 | - * Whether or not to use ReCaptcha |
|
| 2329 | - * |
|
| 2330 | - * @var boolean $use_captcha |
|
| 2331 | - */ |
|
| 2332 | - public $use_captcha; |
|
| 2333 | - |
|
| 2334 | - /** |
|
| 2335 | - * ReCaptcha Theme |
|
| 2336 | - * |
|
| 2337 | - * @var string $recaptcha_theme |
|
| 2338 | - * options: 'dark', 'light', 'invisible' |
|
| 2339 | - */ |
|
| 2340 | - public $recaptcha_theme; |
|
| 1544 | +} |
|
| 2341 | 1545 | |
| 2342 | - /** |
|
| 2343 | - * ReCaptcha Badge - determines the position of the reCAPTCHA badge if using Invisible ReCaptcha. |
|
| 2344 | - * |
|
| 2345 | - * @var string $recaptcha_badge |
|
| 2346 | - * options: 'bottomright', 'bottomleft', 'inline' |
|
| 2347 | - */ |
|
| 2348 | - public $recaptcha_badge; |
|
| 2349 | 1546 | |
| 2350 | - /** |
|
| 2351 | - * ReCaptcha Type |
|
| 2352 | - * |
|
| 2353 | - * @var string $recaptcha_type |
|
| 2354 | - * options: 'audio', 'image' |
|
| 2355 | - */ |
|
| 2356 | - public $recaptcha_type; |
|
| 2357 | 1547 | |
| 2358 | - /** |
|
| 2359 | - * ReCaptcha language |
|
| 2360 | - * |
|
| 2361 | - * @var string $recaptcha_language |
|
| 2362 | - * eg 'en' |
|
| 2363 | - */ |
|
| 2364 | - public $recaptcha_language; |
|
| 1548 | +/** |
|
| 1549 | + * Base class used for config classes. These classes should generally not have |
|
| 1550 | + * magic functions in use, except we'll allow them to magically set and get stuff... |
|
| 1551 | + * basically, they should just be well-defined stdClasses |
|
| 1552 | + */ |
|
| 1553 | +class EE_Config_Base |
|
| 1554 | +{ |
|
| 2365 | 1555 | |
| 2366 | - /** |
|
| 2367 | - * ReCaptcha public key |
|
| 2368 | - * |
|
| 2369 | - * @var string $recaptcha_publickey |
|
| 2370 | - */ |
|
| 2371 | - public $recaptcha_publickey; |
|
| 1556 | + /** |
|
| 1557 | + * Utility function for escaping the value of a property and returning. |
|
| 1558 | + * |
|
| 1559 | + * @param string $property property name (checks to see if exists). |
|
| 1560 | + * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned. |
|
| 1561 | + * @throws \EE_Error |
|
| 1562 | + */ |
|
| 1563 | + public function get_pretty($property) |
|
| 1564 | + { |
|
| 1565 | + if (! property_exists($this, $property)) { |
|
| 1566 | + throw new EE_Error( |
|
| 1567 | + sprintf( |
|
| 1568 | + __( |
|
| 1569 | + '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.', |
|
| 1570 | + 'event_espresso' |
|
| 1571 | + ), |
|
| 1572 | + get_class($this), |
|
| 1573 | + $property |
|
| 1574 | + ) |
|
| 1575 | + ); |
|
| 1576 | + } |
|
| 1577 | + //just handling escaping of strings for now. |
|
| 1578 | + if (is_string($this->{$property})) { |
|
| 1579 | + return stripslashes($this->{$property}); |
|
| 1580 | + } |
|
| 1581 | + return $this->{$property}; |
|
| 1582 | + } |
|
| 1583 | + |
|
| 1584 | + |
|
| 1585 | + |
|
| 1586 | + public function populate() |
|
| 1587 | + { |
|
| 1588 | + //grab defaults via a new instance of this class. |
|
| 1589 | + $class_name = get_class($this); |
|
| 1590 | + $defaults = new $class_name; |
|
| 1591 | + //loop through the properties for this class and see if they are set. If they are NOT, then grab the |
|
| 1592 | + //default from our $defaults object. |
|
| 1593 | + foreach (get_object_vars($defaults) as $property => $value) { |
|
| 1594 | + if ($this->{$property} === null) { |
|
| 1595 | + $this->{$property} = $value; |
|
| 1596 | + } |
|
| 1597 | + } |
|
| 1598 | + //cleanup |
|
| 1599 | + unset($defaults); |
|
| 1600 | + } |
|
| 1601 | + |
|
| 1602 | + |
|
| 1603 | + |
|
| 1604 | + /** |
|
| 1605 | + * __isset |
|
| 1606 | + * |
|
| 1607 | + * @param $a |
|
| 1608 | + * @return bool |
|
| 1609 | + */ |
|
| 1610 | + public function __isset($a) |
|
| 1611 | + { |
|
| 1612 | + return false; |
|
| 1613 | + } |
|
| 1614 | + |
|
| 1615 | + |
|
| 1616 | + |
|
| 1617 | + /** |
|
| 1618 | + * __unset |
|
| 1619 | + * |
|
| 1620 | + * @param $a |
|
| 1621 | + * @return bool |
|
| 1622 | + */ |
|
| 1623 | + public function __unset($a) |
|
| 1624 | + { |
|
| 1625 | + return false; |
|
| 1626 | + } |
|
| 1627 | + |
|
| 1628 | + |
|
| 1629 | + |
|
| 1630 | + /** |
|
| 1631 | + * __clone |
|
| 1632 | + */ |
|
| 1633 | + public function __clone() |
|
| 1634 | + { |
|
| 1635 | + } |
|
| 1636 | + |
|
| 1637 | + |
|
| 1638 | + |
|
| 1639 | + /** |
|
| 1640 | + * __wakeup |
|
| 1641 | + */ |
|
| 1642 | + public function __wakeup() |
|
| 1643 | + { |
|
| 1644 | + } |
|
| 1645 | + |
|
| 1646 | + |
|
| 1647 | + |
|
| 1648 | + /** |
|
| 1649 | + * __destruct |
|
| 1650 | + */ |
|
| 1651 | + public function __destruct() |
|
| 1652 | + { |
|
| 1653 | + } |
|
| 1654 | +} |
|
| 2372 | 1655 | |
| 2373 | - /** |
|
| 2374 | - * ReCaptcha private key |
|
| 2375 | - * |
|
| 2376 | - * @var string $recaptcha_privatekey |
|
| 2377 | - */ |
|
| 2378 | - public $recaptcha_privatekey; |
|
| 2379 | 1656 | |
| 2380 | - /** |
|
| 2381 | - * array of form names protected by ReCaptcha |
|
| 2382 | - * |
|
| 2383 | - * @var array $recaptcha_protected_forms |
|
| 2384 | - */ |
|
| 2385 | - public $recaptcha_protected_forms; |
|
| 2386 | 1657 | |
| 2387 | - /** |
|
| 2388 | - * ReCaptcha width |
|
| 2389 | - * |
|
| 2390 | - * @var int $recaptcha_width |
|
| 2391 | - * @deprecated |
|
| 2392 | - */ |
|
| 2393 | - public $recaptcha_width; |
|
| 1658 | +/** |
|
| 1659 | + * Class for defining what's in the EE_Config relating to registration settings |
|
| 1660 | + */ |
|
| 1661 | +class EE_Core_Config extends EE_Config_Base |
|
| 1662 | +{ |
|
| 2394 | 1663 | |
| 2395 | - /** |
|
| 2396 | - * Whether or not invalid attempts to directly access the registration checkout page should be tracked. |
|
| 2397 | - * |
|
| 2398 | - * @var boolean $track_invalid_checkout_access |
|
| 2399 | - */ |
|
| 2400 | - protected $track_invalid_checkout_access = true; |
|
| 1664 | + public $current_blog_id; |
|
| 1665 | + |
|
| 1666 | + public $ee_ueip_optin; |
|
| 1667 | + |
|
| 1668 | + public $ee_ueip_has_notified; |
|
| 1669 | + |
|
| 1670 | + /** |
|
| 1671 | + * Not to be confused with the 4 critical page variables (See |
|
| 1672 | + * get_critical_pages_array()), this is just an array of wp posts that have EE |
|
| 1673 | + * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode |
|
| 1674 | + * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array. |
|
| 1675 | + * |
|
| 1676 | + * @var array |
|
| 1677 | + */ |
|
| 1678 | + public $post_shortcodes; |
|
| 1679 | + |
|
| 1680 | + public $module_route_map; |
|
| 1681 | + |
|
| 1682 | + public $module_forward_map; |
|
| 1683 | + |
|
| 1684 | + public $module_view_map; |
|
| 1685 | + |
|
| 1686 | + /** |
|
| 1687 | + * The next 4 vars are the IDs of critical EE pages. |
|
| 1688 | + * |
|
| 1689 | + * @var int |
|
| 1690 | + */ |
|
| 1691 | + public $reg_page_id; |
|
| 1692 | + |
|
| 1693 | + public $txn_page_id; |
|
| 1694 | + |
|
| 1695 | + public $thank_you_page_id; |
|
| 1696 | + |
|
| 1697 | + public $cancel_page_id; |
|
| 1698 | + |
|
| 1699 | + /** |
|
| 1700 | + * The next 4 vars are the URLs of critical EE pages. |
|
| 1701 | + * |
|
| 1702 | + * @var int |
|
| 1703 | + */ |
|
| 1704 | + public $reg_page_url; |
|
| 1705 | + |
|
| 1706 | + public $txn_page_url; |
|
| 1707 | + |
|
| 1708 | + public $thank_you_page_url; |
|
| 1709 | + |
|
| 1710 | + public $cancel_page_url; |
|
| 1711 | + |
|
| 1712 | + /** |
|
| 1713 | + * The next vars relate to the custom slugs for EE CPT routes |
|
| 1714 | + */ |
|
| 1715 | + public $event_cpt_slug; |
|
| 1716 | + |
|
| 1717 | + |
|
| 1718 | + /** |
|
| 1719 | + * This caches the _ee_ueip_option in case this config is reset in the same |
|
| 1720 | + * request across blog switches in a multisite context. |
|
| 1721 | + * Avoids extra queries to the db for this option. |
|
| 1722 | + * |
|
| 1723 | + * @var bool |
|
| 1724 | + */ |
|
| 1725 | + public static $ee_ueip_option; |
|
| 1726 | + |
|
| 1727 | + |
|
| 1728 | + |
|
| 1729 | + /** |
|
| 1730 | + * class constructor |
|
| 1731 | + * |
|
| 1732 | + * @access public |
|
| 1733 | + */ |
|
| 1734 | + public function __construct() |
|
| 1735 | + { |
|
| 1736 | + // set default organization settings |
|
| 1737 | + $this->current_blog_id = get_current_blog_id(); |
|
| 1738 | + $this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id; |
|
| 1739 | + $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin(); |
|
| 1740 | + $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true; |
|
| 1741 | + $this->post_shortcodes = array(); |
|
| 1742 | + $this->module_route_map = array(); |
|
| 1743 | + $this->module_forward_map = array(); |
|
| 1744 | + $this->module_view_map = array(); |
|
| 1745 | + // critical EE page IDs |
|
| 1746 | + $this->reg_page_id = 0; |
|
| 1747 | + $this->txn_page_id = 0; |
|
| 1748 | + $this->thank_you_page_id = 0; |
|
| 1749 | + $this->cancel_page_id = 0; |
|
| 1750 | + // critical EE page URLs |
|
| 1751 | + $this->reg_page_url = ''; |
|
| 1752 | + $this->txn_page_url = ''; |
|
| 1753 | + $this->thank_you_page_url = ''; |
|
| 1754 | + $this->cancel_page_url = ''; |
|
| 1755 | + //cpt slugs |
|
| 1756 | + $this->event_cpt_slug = __('events', 'event_espresso'); |
|
| 1757 | + //ueip constant check |
|
| 1758 | + if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) { |
|
| 1759 | + $this->ee_ueip_optin = false; |
|
| 1760 | + $this->ee_ueip_has_notified = true; |
|
| 1761 | + } |
|
| 1762 | + } |
|
| 1763 | + |
|
| 1764 | + |
|
| 1765 | + |
|
| 1766 | + /** |
|
| 1767 | + * @return array |
|
| 1768 | + */ |
|
| 1769 | + public function get_critical_pages_array() |
|
| 1770 | + { |
|
| 1771 | + return array( |
|
| 1772 | + $this->reg_page_id, |
|
| 1773 | + $this->txn_page_id, |
|
| 1774 | + $this->thank_you_page_id, |
|
| 1775 | + $this->cancel_page_id, |
|
| 1776 | + ); |
|
| 1777 | + } |
|
| 1778 | + |
|
| 1779 | + |
|
| 1780 | + |
|
| 1781 | + /** |
|
| 1782 | + * @return array |
|
| 1783 | + */ |
|
| 1784 | + public function get_critical_pages_shortcodes_array() |
|
| 1785 | + { |
|
| 1786 | + return array( |
|
| 1787 | + $this->reg_page_id => 'ESPRESSO_CHECKOUT', |
|
| 1788 | + $this->txn_page_id => 'ESPRESSO_TXN_PAGE', |
|
| 1789 | + $this->thank_you_page_id => 'ESPRESSO_THANK_YOU', |
|
| 1790 | + $this->cancel_page_id => 'ESPRESSO_CANCELLED', |
|
| 1791 | + ); |
|
| 1792 | + } |
|
| 1793 | + |
|
| 1794 | + |
|
| 1795 | + |
|
| 1796 | + /** |
|
| 1797 | + * gets/returns URL for EE reg_page |
|
| 1798 | + * |
|
| 1799 | + * @access public |
|
| 1800 | + * @return string |
|
| 1801 | + */ |
|
| 1802 | + public function reg_page_url() |
|
| 1803 | + { |
|
| 1804 | + if (! $this->reg_page_url) { |
|
| 1805 | + $this->reg_page_url = add_query_arg( |
|
| 1806 | + array('uts' => time()), |
|
| 1807 | + get_permalink($this->reg_page_id) |
|
| 1808 | + ) . '#checkout'; |
|
| 1809 | + } |
|
| 1810 | + return $this->reg_page_url; |
|
| 1811 | + } |
|
| 1812 | + |
|
| 1813 | + |
|
| 1814 | + |
|
| 1815 | + /** |
|
| 1816 | + * gets/returns URL for EE txn_page |
|
| 1817 | + * |
|
| 1818 | + * @param array $query_args like what gets passed to |
|
| 1819 | + * add_query_arg() as the first argument |
|
| 1820 | + * @access public |
|
| 1821 | + * @return string |
|
| 1822 | + */ |
|
| 1823 | + public function txn_page_url($query_args = array()) |
|
| 1824 | + { |
|
| 1825 | + if (! $this->txn_page_url) { |
|
| 1826 | + $this->txn_page_url = get_permalink($this->txn_page_id); |
|
| 1827 | + } |
|
| 1828 | + if ($query_args) { |
|
| 1829 | + return add_query_arg($query_args, $this->txn_page_url); |
|
| 1830 | + } else { |
|
| 1831 | + return $this->txn_page_url; |
|
| 1832 | + } |
|
| 1833 | + } |
|
| 1834 | + |
|
| 1835 | + |
|
| 1836 | + |
|
| 1837 | + /** |
|
| 1838 | + * gets/returns URL for EE thank_you_page |
|
| 1839 | + * |
|
| 1840 | + * @param array $query_args like what gets passed to |
|
| 1841 | + * add_query_arg() as the first argument |
|
| 1842 | + * @access public |
|
| 1843 | + * @return string |
|
| 1844 | + */ |
|
| 1845 | + public function thank_you_page_url($query_args = array()) |
|
| 1846 | + { |
|
| 1847 | + if (! $this->thank_you_page_url) { |
|
| 1848 | + $this->thank_you_page_url = get_permalink($this->thank_you_page_id); |
|
| 1849 | + } |
|
| 1850 | + if ($query_args) { |
|
| 1851 | + return add_query_arg($query_args, $this->thank_you_page_url); |
|
| 1852 | + } else { |
|
| 1853 | + return $this->thank_you_page_url; |
|
| 1854 | + } |
|
| 1855 | + } |
|
| 1856 | + |
|
| 1857 | + |
|
| 1858 | + |
|
| 1859 | + /** |
|
| 1860 | + * gets/returns URL for EE cancel_page |
|
| 1861 | + * |
|
| 1862 | + * @access public |
|
| 1863 | + * @return string |
|
| 1864 | + */ |
|
| 1865 | + public function cancel_page_url() |
|
| 1866 | + { |
|
| 1867 | + if (! $this->cancel_page_url) { |
|
| 1868 | + $this->cancel_page_url = get_permalink($this->cancel_page_id); |
|
| 1869 | + } |
|
| 1870 | + return $this->cancel_page_url; |
|
| 1871 | + } |
|
| 1872 | + |
|
| 1873 | + |
|
| 1874 | + |
|
| 1875 | + /** |
|
| 1876 | + * Resets all critical page urls to their original state. Used primarily by the __sleep() magic method currently. |
|
| 1877 | + * |
|
| 1878 | + * @since 4.7.5 |
|
| 1879 | + */ |
|
| 1880 | + protected function _reset_urls() |
|
| 1881 | + { |
|
| 1882 | + $this->reg_page_url = ''; |
|
| 1883 | + $this->txn_page_url = ''; |
|
| 1884 | + $this->cancel_page_url = ''; |
|
| 1885 | + $this->thank_you_page_url = ''; |
|
| 1886 | + } |
|
| 1887 | + |
|
| 1888 | + |
|
| 1889 | + |
|
| 1890 | + /** |
|
| 1891 | + * Used to return what the optin value is set for the EE User Experience Program. |
|
| 1892 | + * This accounts for multisite and this value being requested for a subsite. In multisite, the value is set |
|
| 1893 | + * on the main site only. |
|
| 1894 | + * |
|
| 1895 | + * @return mixed|void |
|
| 1896 | + */ |
|
| 1897 | + protected function _get_main_ee_ueip_optin() |
|
| 1898 | + { |
|
| 1899 | + //if this is the main site then we can just bypass our direct query. |
|
| 1900 | + if (is_main_site()) { |
|
| 1901 | + return get_option('ee_ueip_optin', false); |
|
| 1902 | + } |
|
| 1903 | + //is this already cached for this request? If so use it. |
|
| 1904 | + if ( ! empty(EE_Core_Config::$ee_ueip_option)) { |
|
| 1905 | + return EE_Core_Config::$ee_ueip_option; |
|
| 1906 | + } |
|
| 1907 | + global $wpdb; |
|
| 1908 | + $current_network_main_site = is_multisite() ? get_current_site() : null; |
|
| 1909 | + $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1; |
|
| 1910 | + $option = 'ee_ueip_optin'; |
|
| 1911 | + //set correct table for query |
|
| 1912 | + $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options'; |
|
| 1913 | + //rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because |
|
| 1914 | + //get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be |
|
| 1915 | + //re-constructed on the blog switch. Note, we are still executing any core wp filters on this option retrieval. |
|
| 1916 | + //this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog |
|
| 1917 | + //for the purpose of caching. |
|
| 1918 | + $pre = apply_filters('pre_option_' . $option, false, $option); |
|
| 1919 | + if (false !== $pre) { |
|
| 1920 | + EE_Core_Config::$ee_ueip_option = $pre; |
|
| 1921 | + return EE_Core_Config::$ee_ueip_option; |
|
| 1922 | + } |
|
| 1923 | + $row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1", |
|
| 1924 | + $option)); |
|
| 1925 | + if (is_object($row)) { |
|
| 1926 | + $value = $row->option_value; |
|
| 1927 | + } else { //option does not exist so use default. |
|
| 1928 | + return apply_filters('default_option_' . $option, false, $option); |
|
| 1929 | + } |
|
| 1930 | + EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option); |
|
| 1931 | + return EE_Core_Config::$ee_ueip_option; |
|
| 1932 | + } |
|
| 1933 | + |
|
| 1934 | + /** |
|
| 1935 | + * Utility function for escaping the value of a property and returning. |
|
| 1936 | + * |
|
| 1937 | + * @param string $property property name (checks to see if exists). |
|
| 1938 | + * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned. |
|
| 1939 | + * @throws \EE_Error |
|
| 1940 | + */ |
|
| 1941 | + public function get_pretty($property) |
|
| 1942 | + { |
|
| 1943 | + if ($property === 'ee_ueip_optin') { |
|
| 1944 | + return $this->ee_ueip_optin ? 'yes' : 'no'; |
|
| 1945 | + } |
|
| 1946 | + return parent::get_pretty($property); |
|
| 1947 | + } |
|
| 1948 | + |
|
| 1949 | + |
|
| 1950 | + /** |
|
| 1951 | + * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values |
|
| 1952 | + * on the object. |
|
| 1953 | + * |
|
| 1954 | + * @return array |
|
| 1955 | + */ |
|
| 1956 | + public function __sleep() |
|
| 1957 | + { |
|
| 1958 | + //reset all url properties |
|
| 1959 | + $this->_reset_urls(); |
|
| 1960 | + //return what to save to db |
|
| 1961 | + return array_keys(get_object_vars($this)); |
|
| 1962 | + } |
|
| 2401 | 1963 | |
| 1964 | +} |
|
| 2402 | 1965 | |
| 2403 | 1966 | |
| 2404 | - /** |
|
| 2405 | - * class constructor |
|
| 2406 | - * |
|
| 2407 | - * @access public |
|
| 2408 | - */ |
|
| 2409 | - public function __construct() |
|
| 2410 | - { |
|
| 2411 | - // set default registration settings |
|
| 2412 | - $this->default_STS_ID = EEM_Registration::status_id_pending_payment; |
|
| 2413 | - $this->email_validation_level = 'wp_default'; |
|
| 2414 | - $this->show_pending_payment_options = true; |
|
| 2415 | - $this->skip_reg_confirmation = false; |
|
| 2416 | - $this->reg_steps = array(); |
|
| 2417 | - $this->reg_confirmation_last = false; |
|
| 2418 | - $this->use_bot_trap = true; |
|
| 2419 | - $this->use_encryption = true; |
|
| 2420 | - $this->use_captcha = false; |
|
| 2421 | - $this->recaptcha_theme = 'light'; |
|
| 2422 | - $this->recaptcha_badge = 'bottomleft'; |
|
| 2423 | - $this->recaptcha_type = 'image'; |
|
| 2424 | - $this->recaptcha_language = 'en'; |
|
| 2425 | - $this->recaptcha_publickey = null; |
|
| 2426 | - $this->recaptcha_privatekey = null; |
|
| 2427 | - $this->recaptcha_protected_forms = array(); |
|
| 2428 | - $this->recaptcha_width = 500; |
|
| 2429 | - $this->default_maximum_number_of_tickets = 10; |
|
| 2430 | - } |
|
| 2431 | - |
|
| 2432 | - |
|
| 2433 | - |
|
| 2434 | - /** |
|
| 2435 | - * This is called by the config loader and hooks are initialized AFTER the config has been populated. |
|
| 2436 | - * |
|
| 2437 | - * @since 4.8.8.rc.019 |
|
| 2438 | - */ |
|
| 2439 | - public function do_hooks() |
|
| 2440 | - { |
|
| 2441 | - add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event')); |
|
| 2442 | - add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event')); |
|
| 2443 | - } |
|
| 2444 | 1967 | |
| 1968 | +/** |
|
| 1969 | + * Config class for storing info on the Organization |
|
| 1970 | + */ |
|
| 1971 | +class EE_Organization_Config extends EE_Config_Base |
|
| 1972 | +{ |
|
| 2445 | 1973 | |
| 1974 | + /** |
|
| 1975 | + * @var string $name |
|
| 1976 | + * eg EE4.1 |
|
| 1977 | + */ |
|
| 1978 | + public $name; |
|
| 1979 | + |
|
| 1980 | + /** |
|
| 1981 | + * @var string $address_1 |
|
| 1982 | + * eg 123 Onna Road |
|
| 1983 | + */ |
|
| 1984 | + public $address_1; |
|
| 1985 | + |
|
| 1986 | + /** |
|
| 1987 | + * @var string $address_2 |
|
| 1988 | + * eg PO Box 123 |
|
| 1989 | + */ |
|
| 1990 | + public $address_2; |
|
| 1991 | + |
|
| 1992 | + /** |
|
| 1993 | + * @var string $city |
|
| 1994 | + * eg Inna City |
|
| 1995 | + */ |
|
| 1996 | + public $city; |
|
| 1997 | + |
|
| 1998 | + /** |
|
| 1999 | + * @var int $STA_ID |
|
| 2000 | + * eg 4 |
|
| 2001 | + */ |
|
| 2002 | + public $STA_ID; |
|
| 2003 | + |
|
| 2004 | + /** |
|
| 2005 | + * @var string $CNT_ISO |
|
| 2006 | + * eg US |
|
| 2007 | + */ |
|
| 2008 | + public $CNT_ISO; |
|
| 2009 | + |
|
| 2010 | + /** |
|
| 2011 | + * @var string $zip |
|
| 2012 | + * eg 12345 or V1A 2B3 |
|
| 2013 | + */ |
|
| 2014 | + public $zip; |
|
| 2015 | + |
|
| 2016 | + /** |
|
| 2017 | + * @var string $email |
|
| 2018 | + * eg [email protected] |
|
| 2019 | + */ |
|
| 2020 | + public $email; |
|
| 2021 | + |
|
| 2022 | + |
|
| 2023 | + /** |
|
| 2024 | + * @var string $phone |
|
| 2025 | + * eg. 111-111-1111 |
|
| 2026 | + */ |
|
| 2027 | + public $phone; |
|
| 2028 | + |
|
| 2029 | + |
|
| 2030 | + /** |
|
| 2031 | + * @var string $vat |
|
| 2032 | + * VAT/Tax Number |
|
| 2033 | + */ |
|
| 2034 | + public $vat; |
|
| 2035 | + |
|
| 2036 | + /** |
|
| 2037 | + * @var string $logo_url |
|
| 2038 | + * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg |
|
| 2039 | + */ |
|
| 2040 | + public $logo_url; |
|
| 2041 | + |
|
| 2042 | + |
|
| 2043 | + /** |
|
| 2044 | + * The below are all various properties for holding links to organization social network profiles |
|
| 2045 | + * |
|
| 2046 | + * @var string |
|
| 2047 | + */ |
|
| 2048 | + /** |
|
| 2049 | + * facebook (facebook.com/profile.name) |
|
| 2050 | + * |
|
| 2051 | + * @var string |
|
| 2052 | + */ |
|
| 2053 | + public $facebook; |
|
| 2054 | + |
|
| 2055 | + |
|
| 2056 | + /** |
|
| 2057 | + * twitter (twitter.com/twitter_handle) |
|
| 2058 | + * |
|
| 2059 | + * @var string |
|
| 2060 | + */ |
|
| 2061 | + public $twitter; |
|
| 2062 | + |
|
| 2063 | + |
|
| 2064 | + /** |
|
| 2065 | + * linkedin (linkedin.com/in/profile_name) |
|
| 2066 | + * |
|
| 2067 | + * @var string |
|
| 2068 | + */ |
|
| 2069 | + public $linkedin; |
|
| 2070 | + |
|
| 2071 | + |
|
| 2072 | + /** |
|
| 2073 | + * pinterest (www.pinterest.com/profile_name) |
|
| 2074 | + * |
|
| 2075 | + * @var string |
|
| 2076 | + */ |
|
| 2077 | + public $pinterest; |
|
| 2078 | + |
|
| 2079 | + |
|
| 2080 | + /** |
|
| 2081 | + * google+ (google.com/+profileName) |
|
| 2082 | + * |
|
| 2083 | + * @var string |
|
| 2084 | + */ |
|
| 2085 | + public $google; |
|
| 2086 | + |
|
| 2087 | + |
|
| 2088 | + /** |
|
| 2089 | + * instagram (instagram.com/handle) |
|
| 2090 | + * |
|
| 2091 | + * @var string |
|
| 2092 | + */ |
|
| 2093 | + public $instagram; |
|
| 2094 | + |
|
| 2095 | + |
|
| 2096 | + |
|
| 2097 | + /** |
|
| 2098 | + * class constructor |
|
| 2099 | + * |
|
| 2100 | + * @access public |
|
| 2101 | + */ |
|
| 2102 | + public function __construct() |
|
| 2103 | + { |
|
| 2104 | + // set default organization settings |
|
| 2105 | + //decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded |
|
| 2106 | + $this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES); |
|
| 2107 | + $this->address_1 = '123 Onna Road'; |
|
| 2108 | + $this->address_2 = 'PO Box 123'; |
|
| 2109 | + $this->city = 'Inna City'; |
|
| 2110 | + $this->STA_ID = 4; |
|
| 2111 | + $this->CNT_ISO = 'US'; |
|
| 2112 | + $this->zip = '12345'; |
|
| 2113 | + $this->email = get_bloginfo('admin_email'); |
|
| 2114 | + $this->phone = ''; |
|
| 2115 | + $this->vat = '123456789'; |
|
| 2116 | + $this->logo_url = ''; |
|
| 2117 | + $this->facebook = ''; |
|
| 2118 | + $this->twitter = ''; |
|
| 2119 | + $this->linkedin = ''; |
|
| 2120 | + $this->pinterest = ''; |
|
| 2121 | + $this->google = ''; |
|
| 2122 | + $this->instagram = ''; |
|
| 2123 | + } |
|
| 2446 | 2124 | |
| 2447 | - /** |
|
| 2448 | - * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_default_registration_status |
|
| 2449 | - * field matches the config setting for default_STS_ID. |
|
| 2450 | - */ |
|
| 2451 | - public function set_default_reg_status_on_EEM_Event() |
|
| 2452 | - { |
|
| 2453 | - EEM_Event::set_default_reg_status($this->default_STS_ID); |
|
| 2454 | - } |
|
| 2125 | +} |
|
| 2455 | 2126 | |
| 2456 | 2127 | |
| 2457 | - /** |
|
| 2458 | - * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field |
|
| 2459 | - * for Events matches the config setting for default_maximum_number_of_tickets |
|
| 2460 | - */ |
|
| 2461 | - public function set_default_max_ticket_on_EEM_Event() |
|
| 2462 | - { |
|
| 2463 | - EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets); |
|
| 2464 | - } |
|
| 2465 | 2128 | |
| 2129 | +/** |
|
| 2130 | + * Class for defining what's in the EE_Config relating to currency |
|
| 2131 | + */ |
|
| 2132 | +class EE_Currency_Config extends EE_Config_Base |
|
| 2133 | +{ |
|
| 2466 | 2134 | |
| 2135 | + /** |
|
| 2136 | + * @var string $code |
|
| 2137 | + * eg 'US' |
|
| 2138 | + */ |
|
| 2139 | + public $code; |
|
| 2140 | + |
|
| 2141 | + /** |
|
| 2142 | + * @var string $name |
|
| 2143 | + * eg 'Dollar' |
|
| 2144 | + */ |
|
| 2145 | + public $name; |
|
| 2146 | + |
|
| 2147 | + /** |
|
| 2148 | + * plural name |
|
| 2149 | + * |
|
| 2150 | + * @var string $plural |
|
| 2151 | + * eg 'Dollars' |
|
| 2152 | + */ |
|
| 2153 | + public $plural; |
|
| 2154 | + |
|
| 2155 | + /** |
|
| 2156 | + * currency sign |
|
| 2157 | + * |
|
| 2158 | + * @var string $sign |
|
| 2159 | + * eg '$' |
|
| 2160 | + */ |
|
| 2161 | + public $sign; |
|
| 2162 | + |
|
| 2163 | + /** |
|
| 2164 | + * Whether the currency sign should come before the number or not |
|
| 2165 | + * |
|
| 2166 | + * @var boolean $sign_b4 |
|
| 2167 | + */ |
|
| 2168 | + public $sign_b4; |
|
| 2169 | + |
|
| 2170 | + /** |
|
| 2171 | + * How many digits should come after the decimal place |
|
| 2172 | + * |
|
| 2173 | + * @var int $dec_plc |
|
| 2174 | + */ |
|
| 2175 | + public $dec_plc; |
|
| 2176 | + |
|
| 2177 | + /** |
|
| 2178 | + * Symbol to use for decimal mark |
|
| 2179 | + * |
|
| 2180 | + * @var string $dec_mrk |
|
| 2181 | + * eg '.' |
|
| 2182 | + */ |
|
| 2183 | + public $dec_mrk; |
|
| 2184 | + |
|
| 2185 | + /** |
|
| 2186 | + * Symbol to use for thousands |
|
| 2187 | + * |
|
| 2188 | + * @var string $thsnds |
|
| 2189 | + * eg ',' |
|
| 2190 | + */ |
|
| 2191 | + public $thsnds; |
|
| 2192 | + |
|
| 2193 | + |
|
| 2194 | + |
|
| 2195 | + /** |
|
| 2196 | + * class constructor |
|
| 2197 | + * |
|
| 2198 | + * @access public |
|
| 2199 | + * @param string $CNT_ISO |
|
| 2200 | + * @throws \EE_Error |
|
| 2201 | + */ |
|
| 2202 | + public function __construct($CNT_ISO = '') |
|
| 2203 | + { |
|
| 2204 | + /** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */ |
|
| 2205 | + $table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
| 2206 | + // get country code from organization settings or use default |
|
| 2207 | + $ORG_CNT = isset(EE_Registry::instance()->CFG->organization) |
|
| 2208 | + && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config |
|
| 2209 | + ? EE_Registry::instance()->CFG->organization->CNT_ISO |
|
| 2210 | + : ''; |
|
| 2211 | + // but override if requested |
|
| 2212 | + $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT; |
|
| 2213 | + // so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists |
|
| 2214 | + if ( |
|
| 2215 | + ! empty($CNT_ISO) |
|
| 2216 | + && EE_Maintenance_Mode::instance()->models_can_query() |
|
| 2217 | + && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table()) |
|
| 2218 | + ) { |
|
| 2219 | + // retrieve the country settings from the db, just in case they have been customized |
|
| 2220 | + $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO); |
|
| 2221 | + if ($country instanceof EE_Country) { |
|
| 2222 | + $this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
| 2223 | + $this->name = $country->currency_name_single(); // Dollar |
|
| 2224 | + $this->plural = $country->currency_name_plural(); // Dollars |
|
| 2225 | + $this->sign = $country->currency_sign(); // currency sign: $ |
|
| 2226 | + $this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE or FALSE$ |
|
| 2227 | + $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
| 2228 | + $this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
| 2229 | + $this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
| 2230 | + } |
|
| 2231 | + } |
|
| 2232 | + // fallback to hardcoded defaults, in case the above failed |
|
| 2233 | + if (empty($this->code)) { |
|
| 2234 | + // set default currency settings |
|
| 2235 | + $this->code = 'USD'; // currency code: USD, CAD, EUR |
|
| 2236 | + $this->name = __('Dollar', 'event_espresso'); // Dollar |
|
| 2237 | + $this->plural = __('Dollars', 'event_espresso'); // Dollars |
|
| 2238 | + $this->sign = '$'; // currency sign: $ |
|
| 2239 | + $this->sign_b4 = true; // currency sign before or after: $TRUE or FALSE$ |
|
| 2240 | + $this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
| 2241 | + $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
| 2242 | + $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
| 2243 | + } |
|
| 2244 | + } |
|
| 2245 | +} |
|
| 2467 | 2246 | |
| 2468 | - /** |
|
| 2469 | - * @return boolean |
|
| 2470 | - */ |
|
| 2471 | - public function track_invalid_checkout_access() |
|
| 2472 | - { |
|
| 2473 | - return $this->track_invalid_checkout_access; |
|
| 2474 | - } |
|
| 2475 | 2247 | |
| 2476 | 2248 | |
| 2249 | +/** |
|
| 2250 | + * Class for defining what's in the EE_Config relating to registration settings |
|
| 2251 | + */ |
|
| 2252 | +class EE_Registration_Config extends EE_Config_Base |
|
| 2253 | +{ |
|
| 2477 | 2254 | |
| 2478 | - /** |
|
| 2479 | - * @param boolean $track_invalid_checkout_access |
|
| 2480 | - */ |
|
| 2481 | - public function set_track_invalid_checkout_access($track_invalid_checkout_access) |
|
| 2482 | - { |
|
| 2483 | - $this->track_invalid_checkout_access = filter_var( |
|
| 2484 | - $track_invalid_checkout_access, |
|
| 2485 | - FILTER_VALIDATE_BOOLEAN |
|
| 2486 | - ); |
|
| 2487 | - } |
|
| 2255 | + /** |
|
| 2256 | + * Default registration status |
|
| 2257 | + * |
|
| 2258 | + * @var string $default_STS_ID |
|
| 2259 | + * eg 'RPP' |
|
| 2260 | + */ |
|
| 2261 | + public $default_STS_ID; |
|
| 2262 | + |
|
| 2263 | + |
|
| 2264 | + /** |
|
| 2265 | + * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of |
|
| 2266 | + * registrations) |
|
| 2267 | + * @var int |
|
| 2268 | + */ |
|
| 2269 | + public $default_maximum_number_of_tickets; |
|
| 2270 | + |
|
| 2271 | + |
|
| 2272 | + /** |
|
| 2273 | + * level of validation to apply to email addresses |
|
| 2274 | + * |
|
| 2275 | + * @var string $email_validation_level |
|
| 2276 | + * options: 'basic', 'wp_default', 'i18n', 'i18n_dns' |
|
| 2277 | + */ |
|
| 2278 | + public $email_validation_level; |
|
| 2279 | + |
|
| 2280 | + /** |
|
| 2281 | + * whether or not to show alternate payment options during the reg process if payment status is pending |
|
| 2282 | + * |
|
| 2283 | + * @var boolean $show_pending_payment_options |
|
| 2284 | + */ |
|
| 2285 | + public $show_pending_payment_options; |
|
| 2286 | + |
|
| 2287 | + /** |
|
| 2288 | + * Whether to skip the registration confirmation page |
|
| 2289 | + * |
|
| 2290 | + * @var boolean $skip_reg_confirmation |
|
| 2291 | + */ |
|
| 2292 | + public $skip_reg_confirmation; |
|
| 2293 | + |
|
| 2294 | + /** |
|
| 2295 | + * an array of SPCO reg steps where: |
|
| 2296 | + * the keys denotes the reg step order |
|
| 2297 | + * each element consists of an array with the following elements: |
|
| 2298 | + * "file_path" => the file path to the EE_SPCO_Reg_Step class |
|
| 2299 | + * "class_name" => the specific EE_SPCO_Reg_Step child class name |
|
| 2300 | + * "slug" => the URL param used to trigger the reg step |
|
| 2301 | + * |
|
| 2302 | + * @var array $reg_steps |
|
| 2303 | + */ |
|
| 2304 | + public $reg_steps; |
|
| 2305 | + |
|
| 2306 | + /** |
|
| 2307 | + * Whether registration confirmation should be the last page of SPCO |
|
| 2308 | + * |
|
| 2309 | + * @var boolean $reg_confirmation_last |
|
| 2310 | + */ |
|
| 2311 | + public $reg_confirmation_last; |
|
| 2312 | + |
|
| 2313 | + /** |
|
| 2314 | + * Whether or not to enable the EE Bot Trap |
|
| 2315 | + * |
|
| 2316 | + * @var boolean $use_bot_trap |
|
| 2317 | + */ |
|
| 2318 | + public $use_bot_trap; |
|
| 2319 | + |
|
| 2320 | + /** |
|
| 2321 | + * Whether or not to encrypt some data sent by the EE Bot Trap |
|
| 2322 | + * |
|
| 2323 | + * @var boolean $use_encryption |
|
| 2324 | + */ |
|
| 2325 | + public $use_encryption; |
|
| 2326 | + |
|
| 2327 | + /** |
|
| 2328 | + * Whether or not to use ReCaptcha |
|
| 2329 | + * |
|
| 2330 | + * @var boolean $use_captcha |
|
| 2331 | + */ |
|
| 2332 | + public $use_captcha; |
|
| 2333 | + |
|
| 2334 | + /** |
|
| 2335 | + * ReCaptcha Theme |
|
| 2336 | + * |
|
| 2337 | + * @var string $recaptcha_theme |
|
| 2338 | + * options: 'dark', 'light', 'invisible' |
|
| 2339 | + */ |
|
| 2340 | + public $recaptcha_theme; |
|
| 2341 | + |
|
| 2342 | + /** |
|
| 2343 | + * ReCaptcha Badge - determines the position of the reCAPTCHA badge if using Invisible ReCaptcha. |
|
| 2344 | + * |
|
| 2345 | + * @var string $recaptcha_badge |
|
| 2346 | + * options: 'bottomright', 'bottomleft', 'inline' |
|
| 2347 | + */ |
|
| 2348 | + public $recaptcha_badge; |
|
| 2349 | + |
|
| 2350 | + /** |
|
| 2351 | + * ReCaptcha Type |
|
| 2352 | + * |
|
| 2353 | + * @var string $recaptcha_type |
|
| 2354 | + * options: 'audio', 'image' |
|
| 2355 | + */ |
|
| 2356 | + public $recaptcha_type; |
|
| 2357 | + |
|
| 2358 | + /** |
|
| 2359 | + * ReCaptcha language |
|
| 2360 | + * |
|
| 2361 | + * @var string $recaptcha_language |
|
| 2362 | + * eg 'en' |
|
| 2363 | + */ |
|
| 2364 | + public $recaptcha_language; |
|
| 2365 | + |
|
| 2366 | + /** |
|
| 2367 | + * ReCaptcha public key |
|
| 2368 | + * |
|
| 2369 | + * @var string $recaptcha_publickey |
|
| 2370 | + */ |
|
| 2371 | + public $recaptcha_publickey; |
|
| 2372 | + |
|
| 2373 | + /** |
|
| 2374 | + * ReCaptcha private key |
|
| 2375 | + * |
|
| 2376 | + * @var string $recaptcha_privatekey |
|
| 2377 | + */ |
|
| 2378 | + public $recaptcha_privatekey; |
|
| 2379 | + |
|
| 2380 | + /** |
|
| 2381 | + * array of form names protected by ReCaptcha |
|
| 2382 | + * |
|
| 2383 | + * @var array $recaptcha_protected_forms |
|
| 2384 | + */ |
|
| 2385 | + public $recaptcha_protected_forms; |
|
| 2386 | + |
|
| 2387 | + /** |
|
| 2388 | + * ReCaptcha width |
|
| 2389 | + * |
|
| 2390 | + * @var int $recaptcha_width |
|
| 2391 | + * @deprecated |
|
| 2392 | + */ |
|
| 2393 | + public $recaptcha_width; |
|
| 2394 | + |
|
| 2395 | + /** |
|
| 2396 | + * Whether or not invalid attempts to directly access the registration checkout page should be tracked. |
|
| 2397 | + * |
|
| 2398 | + * @var boolean $track_invalid_checkout_access |
|
| 2399 | + */ |
|
| 2400 | + protected $track_invalid_checkout_access = true; |
|
| 2401 | + |
|
| 2402 | + |
|
| 2403 | + |
|
| 2404 | + /** |
|
| 2405 | + * class constructor |
|
| 2406 | + * |
|
| 2407 | + * @access public |
|
| 2408 | + */ |
|
| 2409 | + public function __construct() |
|
| 2410 | + { |
|
| 2411 | + // set default registration settings |
|
| 2412 | + $this->default_STS_ID = EEM_Registration::status_id_pending_payment; |
|
| 2413 | + $this->email_validation_level = 'wp_default'; |
|
| 2414 | + $this->show_pending_payment_options = true; |
|
| 2415 | + $this->skip_reg_confirmation = false; |
|
| 2416 | + $this->reg_steps = array(); |
|
| 2417 | + $this->reg_confirmation_last = false; |
|
| 2418 | + $this->use_bot_trap = true; |
|
| 2419 | + $this->use_encryption = true; |
|
| 2420 | + $this->use_captcha = false; |
|
| 2421 | + $this->recaptcha_theme = 'light'; |
|
| 2422 | + $this->recaptcha_badge = 'bottomleft'; |
|
| 2423 | + $this->recaptcha_type = 'image'; |
|
| 2424 | + $this->recaptcha_language = 'en'; |
|
| 2425 | + $this->recaptcha_publickey = null; |
|
| 2426 | + $this->recaptcha_privatekey = null; |
|
| 2427 | + $this->recaptcha_protected_forms = array(); |
|
| 2428 | + $this->recaptcha_width = 500; |
|
| 2429 | + $this->default_maximum_number_of_tickets = 10; |
|
| 2430 | + } |
|
| 2431 | + |
|
| 2432 | + |
|
| 2433 | + |
|
| 2434 | + /** |
|
| 2435 | + * This is called by the config loader and hooks are initialized AFTER the config has been populated. |
|
| 2436 | + * |
|
| 2437 | + * @since 4.8.8.rc.019 |
|
| 2438 | + */ |
|
| 2439 | + public function do_hooks() |
|
| 2440 | + { |
|
| 2441 | + add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event')); |
|
| 2442 | + add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event')); |
|
| 2443 | + } |
|
| 2444 | + |
|
| 2445 | + |
|
| 2446 | + |
|
| 2447 | + /** |
|
| 2448 | + * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_default_registration_status |
|
| 2449 | + * field matches the config setting for default_STS_ID. |
|
| 2450 | + */ |
|
| 2451 | + public function set_default_reg_status_on_EEM_Event() |
|
| 2452 | + { |
|
| 2453 | + EEM_Event::set_default_reg_status($this->default_STS_ID); |
|
| 2454 | + } |
|
| 2455 | + |
|
| 2456 | + |
|
| 2457 | + /** |
|
| 2458 | + * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field |
|
| 2459 | + * for Events matches the config setting for default_maximum_number_of_tickets |
|
| 2460 | + */ |
|
| 2461 | + public function set_default_max_ticket_on_EEM_Event() |
|
| 2462 | + { |
|
| 2463 | + EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets); |
|
| 2464 | + } |
|
| 2465 | + |
|
| 2466 | + |
|
| 2467 | + |
|
| 2468 | + /** |
|
| 2469 | + * @return boolean |
|
| 2470 | + */ |
|
| 2471 | + public function track_invalid_checkout_access() |
|
| 2472 | + { |
|
| 2473 | + return $this->track_invalid_checkout_access; |
|
| 2474 | + } |
|
| 2475 | + |
|
| 2476 | + |
|
| 2477 | + |
|
| 2478 | + /** |
|
| 2479 | + * @param boolean $track_invalid_checkout_access |
|
| 2480 | + */ |
|
| 2481 | + public function set_track_invalid_checkout_access($track_invalid_checkout_access) |
|
| 2482 | + { |
|
| 2483 | + $this->track_invalid_checkout_access = filter_var( |
|
| 2484 | + $track_invalid_checkout_access, |
|
| 2485 | + FILTER_VALIDATE_BOOLEAN |
|
| 2486 | + ); |
|
| 2487 | + } |
|
| 2488 | 2488 | |
| 2489 | 2489 | |
| 2490 | 2490 | |
@@ -2498,160 +2498,160 @@ discard block |
||
| 2498 | 2498 | class EE_Admin_Config extends EE_Config_Base |
| 2499 | 2499 | { |
| 2500 | 2500 | |
| 2501 | - /** |
|
| 2502 | - * @var boolean $use_personnel_manager |
|
| 2503 | - */ |
|
| 2504 | - public $use_personnel_manager; |
|
| 2505 | - |
|
| 2506 | - /** |
|
| 2507 | - * @var boolean $use_dashboard_widget |
|
| 2508 | - */ |
|
| 2509 | - public $use_dashboard_widget; |
|
| 2510 | - |
|
| 2511 | - /** |
|
| 2512 | - * @var int $events_in_dashboard |
|
| 2513 | - */ |
|
| 2514 | - public $events_in_dashboard; |
|
| 2515 | - |
|
| 2516 | - /** |
|
| 2517 | - * @var boolean $use_event_timezones |
|
| 2518 | - */ |
|
| 2519 | - public $use_event_timezones; |
|
| 2520 | - |
|
| 2521 | - /** |
|
| 2522 | - * @var boolean $use_full_logging |
|
| 2523 | - */ |
|
| 2524 | - public $use_full_logging; |
|
| 2525 | - |
|
| 2526 | - /** |
|
| 2527 | - * @var string $log_file_name |
|
| 2528 | - */ |
|
| 2529 | - public $log_file_name; |
|
| 2530 | - |
|
| 2531 | - /** |
|
| 2532 | - * @var string $debug_file_name |
|
| 2533 | - */ |
|
| 2534 | - public $debug_file_name; |
|
| 2535 | - |
|
| 2536 | - /** |
|
| 2537 | - * @var boolean $use_remote_logging |
|
| 2538 | - */ |
|
| 2539 | - public $use_remote_logging; |
|
| 2540 | - |
|
| 2541 | - /** |
|
| 2542 | - * @var string $remote_logging_url |
|
| 2543 | - */ |
|
| 2544 | - public $remote_logging_url; |
|
| 2545 | - |
|
| 2546 | - /** |
|
| 2547 | - * @var boolean $show_reg_footer |
|
| 2548 | - */ |
|
| 2549 | - public $show_reg_footer; |
|
| 2550 | - |
|
| 2551 | - /** |
|
| 2552 | - * @var string $affiliate_id |
|
| 2553 | - */ |
|
| 2554 | - public $affiliate_id; |
|
| 2555 | - |
|
| 2556 | - /** |
|
| 2557 | - * help tours on or off (global setting) |
|
| 2558 | - * |
|
| 2559 | - * @var boolean |
|
| 2560 | - */ |
|
| 2561 | - public $help_tour_activation; |
|
| 2562 | - |
|
| 2563 | - /** |
|
| 2564 | - * adds extra layer of encoding to session data to prevent serialization errors |
|
| 2565 | - * but is incompatible with some server configuration errors |
|
| 2566 | - * if you get "500 internal server errors" during registration, try turning this on |
|
| 2567 | - * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off |
|
| 2568 | - * |
|
| 2569 | - * @var boolean $encode_session_data |
|
| 2570 | - */ |
|
| 2571 | - private $encode_session_data = false; |
|
| 2572 | - |
|
| 2573 | - |
|
| 2574 | - |
|
| 2575 | - /** |
|
| 2576 | - * class constructor |
|
| 2577 | - * |
|
| 2578 | - * @access public |
|
| 2579 | - */ |
|
| 2580 | - public function __construct() |
|
| 2581 | - { |
|
| 2582 | - // set default general admin settings |
|
| 2583 | - $this->use_personnel_manager = true; |
|
| 2584 | - $this->use_dashboard_widget = true; |
|
| 2585 | - $this->events_in_dashboard = 30; |
|
| 2586 | - $this->use_event_timezones = false; |
|
| 2587 | - $this->use_full_logging = false; |
|
| 2588 | - $this->use_remote_logging = false; |
|
| 2589 | - $this->remote_logging_url = null; |
|
| 2590 | - $this->show_reg_footer = true; |
|
| 2591 | - $this->affiliate_id = 'default'; |
|
| 2592 | - $this->help_tour_activation = true; |
|
| 2593 | - $this->encode_session_data = false; |
|
| 2594 | - } |
|
| 2595 | - |
|
| 2596 | - |
|
| 2597 | - |
|
| 2598 | - /** |
|
| 2599 | - * @param bool $reset |
|
| 2600 | - * @return string |
|
| 2601 | - */ |
|
| 2602 | - public function log_file_name($reset = false) |
|
| 2603 | - { |
|
| 2604 | - if (empty($this->log_file_name) || $reset) { |
|
| 2605 | - $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt'; |
|
| 2606 | - EE_Config::instance()->update_espresso_config(false, false); |
|
| 2607 | - } |
|
| 2608 | - return $this->log_file_name; |
|
| 2609 | - } |
|
| 2610 | - |
|
| 2611 | - |
|
| 2612 | - |
|
| 2613 | - /** |
|
| 2614 | - * @param bool $reset |
|
| 2615 | - * @return string |
|
| 2616 | - */ |
|
| 2617 | - public function debug_file_name($reset = false) |
|
| 2618 | - { |
|
| 2619 | - if (empty($this->debug_file_name) || $reset) { |
|
| 2620 | - $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt'; |
|
| 2621 | - EE_Config::instance()->update_espresso_config(false, false); |
|
| 2622 | - } |
|
| 2623 | - return $this->debug_file_name; |
|
| 2624 | - } |
|
| 2625 | - |
|
| 2626 | - |
|
| 2627 | - |
|
| 2628 | - /** |
|
| 2629 | - * @return string |
|
| 2630 | - */ |
|
| 2631 | - public function affiliate_id() |
|
| 2632 | - { |
|
| 2633 | - return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default'; |
|
| 2634 | - } |
|
| 2635 | - |
|
| 2636 | - |
|
| 2637 | - |
|
| 2638 | - /** |
|
| 2639 | - * @return boolean |
|
| 2640 | - */ |
|
| 2641 | - public function encode_session_data() |
|
| 2642 | - { |
|
| 2643 | - return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN); |
|
| 2644 | - } |
|
| 2645 | - |
|
| 2646 | - |
|
| 2647 | - |
|
| 2648 | - /** |
|
| 2649 | - * @param boolean $encode_session_data |
|
| 2650 | - */ |
|
| 2651 | - public function set_encode_session_data($encode_session_data) |
|
| 2652 | - { |
|
| 2653 | - $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN); |
|
| 2654 | - } |
|
| 2501 | + /** |
|
| 2502 | + * @var boolean $use_personnel_manager |
|
| 2503 | + */ |
|
| 2504 | + public $use_personnel_manager; |
|
| 2505 | + |
|
| 2506 | + /** |
|
| 2507 | + * @var boolean $use_dashboard_widget |
|
| 2508 | + */ |
|
| 2509 | + public $use_dashboard_widget; |
|
| 2510 | + |
|
| 2511 | + /** |
|
| 2512 | + * @var int $events_in_dashboard |
|
| 2513 | + */ |
|
| 2514 | + public $events_in_dashboard; |
|
| 2515 | + |
|
| 2516 | + /** |
|
| 2517 | + * @var boolean $use_event_timezones |
|
| 2518 | + */ |
|
| 2519 | + public $use_event_timezones; |
|
| 2520 | + |
|
| 2521 | + /** |
|
| 2522 | + * @var boolean $use_full_logging |
|
| 2523 | + */ |
|
| 2524 | + public $use_full_logging; |
|
| 2525 | + |
|
| 2526 | + /** |
|
| 2527 | + * @var string $log_file_name |
|
| 2528 | + */ |
|
| 2529 | + public $log_file_name; |
|
| 2530 | + |
|
| 2531 | + /** |
|
| 2532 | + * @var string $debug_file_name |
|
| 2533 | + */ |
|
| 2534 | + public $debug_file_name; |
|
| 2535 | + |
|
| 2536 | + /** |
|
| 2537 | + * @var boolean $use_remote_logging |
|
| 2538 | + */ |
|
| 2539 | + public $use_remote_logging; |
|
| 2540 | + |
|
| 2541 | + /** |
|
| 2542 | + * @var string $remote_logging_url |
|
| 2543 | + */ |
|
| 2544 | + public $remote_logging_url; |
|
| 2545 | + |
|
| 2546 | + /** |
|
| 2547 | + * @var boolean $show_reg_footer |
|
| 2548 | + */ |
|
| 2549 | + public $show_reg_footer; |
|
| 2550 | + |
|
| 2551 | + /** |
|
| 2552 | + * @var string $affiliate_id |
|
| 2553 | + */ |
|
| 2554 | + public $affiliate_id; |
|
| 2555 | + |
|
| 2556 | + /** |
|
| 2557 | + * help tours on or off (global setting) |
|
| 2558 | + * |
|
| 2559 | + * @var boolean |
|
| 2560 | + */ |
|
| 2561 | + public $help_tour_activation; |
|
| 2562 | + |
|
| 2563 | + /** |
|
| 2564 | + * adds extra layer of encoding to session data to prevent serialization errors |
|
| 2565 | + * but is incompatible with some server configuration errors |
|
| 2566 | + * if you get "500 internal server errors" during registration, try turning this on |
|
| 2567 | + * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off |
|
| 2568 | + * |
|
| 2569 | + * @var boolean $encode_session_data |
|
| 2570 | + */ |
|
| 2571 | + private $encode_session_data = false; |
|
| 2572 | + |
|
| 2573 | + |
|
| 2574 | + |
|
| 2575 | + /** |
|
| 2576 | + * class constructor |
|
| 2577 | + * |
|
| 2578 | + * @access public |
|
| 2579 | + */ |
|
| 2580 | + public function __construct() |
|
| 2581 | + { |
|
| 2582 | + // set default general admin settings |
|
| 2583 | + $this->use_personnel_manager = true; |
|
| 2584 | + $this->use_dashboard_widget = true; |
|
| 2585 | + $this->events_in_dashboard = 30; |
|
| 2586 | + $this->use_event_timezones = false; |
|
| 2587 | + $this->use_full_logging = false; |
|
| 2588 | + $this->use_remote_logging = false; |
|
| 2589 | + $this->remote_logging_url = null; |
|
| 2590 | + $this->show_reg_footer = true; |
|
| 2591 | + $this->affiliate_id = 'default'; |
|
| 2592 | + $this->help_tour_activation = true; |
|
| 2593 | + $this->encode_session_data = false; |
|
| 2594 | + } |
|
| 2595 | + |
|
| 2596 | + |
|
| 2597 | + |
|
| 2598 | + /** |
|
| 2599 | + * @param bool $reset |
|
| 2600 | + * @return string |
|
| 2601 | + */ |
|
| 2602 | + public function log_file_name($reset = false) |
|
| 2603 | + { |
|
| 2604 | + if (empty($this->log_file_name) || $reset) { |
|
| 2605 | + $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt'; |
|
| 2606 | + EE_Config::instance()->update_espresso_config(false, false); |
|
| 2607 | + } |
|
| 2608 | + return $this->log_file_name; |
|
| 2609 | + } |
|
| 2610 | + |
|
| 2611 | + |
|
| 2612 | + |
|
| 2613 | + /** |
|
| 2614 | + * @param bool $reset |
|
| 2615 | + * @return string |
|
| 2616 | + */ |
|
| 2617 | + public function debug_file_name($reset = false) |
|
| 2618 | + { |
|
| 2619 | + if (empty($this->debug_file_name) || $reset) { |
|
| 2620 | + $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt'; |
|
| 2621 | + EE_Config::instance()->update_espresso_config(false, false); |
|
| 2622 | + } |
|
| 2623 | + return $this->debug_file_name; |
|
| 2624 | + } |
|
| 2625 | + |
|
| 2626 | + |
|
| 2627 | + |
|
| 2628 | + /** |
|
| 2629 | + * @return string |
|
| 2630 | + */ |
|
| 2631 | + public function affiliate_id() |
|
| 2632 | + { |
|
| 2633 | + return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default'; |
|
| 2634 | + } |
|
| 2635 | + |
|
| 2636 | + |
|
| 2637 | + |
|
| 2638 | + /** |
|
| 2639 | + * @return boolean |
|
| 2640 | + */ |
|
| 2641 | + public function encode_session_data() |
|
| 2642 | + { |
|
| 2643 | + return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN); |
|
| 2644 | + } |
|
| 2645 | + |
|
| 2646 | + |
|
| 2647 | + |
|
| 2648 | + /** |
|
| 2649 | + * @param boolean $encode_session_data |
|
| 2650 | + */ |
|
| 2651 | + public function set_encode_session_data($encode_session_data) |
|
| 2652 | + { |
|
| 2653 | + $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN); |
|
| 2654 | + } |
|
| 2655 | 2655 | |
| 2656 | 2656 | |
| 2657 | 2657 | |
@@ -2665,71 +2665,71 @@ discard block |
||
| 2665 | 2665 | class EE_Template_Config extends EE_Config_Base |
| 2666 | 2666 | { |
| 2667 | 2667 | |
| 2668 | - /** |
|
| 2669 | - * @var boolean $enable_default_style |
|
| 2670 | - */ |
|
| 2671 | - public $enable_default_style; |
|
| 2672 | - |
|
| 2673 | - /** |
|
| 2674 | - * @var string $custom_style_sheet |
|
| 2675 | - */ |
|
| 2676 | - public $custom_style_sheet; |
|
| 2677 | - |
|
| 2678 | - /** |
|
| 2679 | - * @var boolean $display_address_in_regform |
|
| 2680 | - */ |
|
| 2681 | - public $display_address_in_regform; |
|
| 2682 | - |
|
| 2683 | - /** |
|
| 2684 | - * @var int $display_description_on_multi_reg_page |
|
| 2685 | - */ |
|
| 2686 | - public $display_description_on_multi_reg_page; |
|
| 2687 | - |
|
| 2688 | - /** |
|
| 2689 | - * @var boolean $use_custom_templates |
|
| 2690 | - */ |
|
| 2691 | - public $use_custom_templates; |
|
| 2692 | - |
|
| 2693 | - /** |
|
| 2694 | - * @var string $current_espresso_theme |
|
| 2695 | - */ |
|
| 2696 | - public $current_espresso_theme; |
|
| 2697 | - |
|
| 2698 | - /** |
|
| 2699 | - * @var EE_Ticket_Selector_Config $EED_Ticket_Selector |
|
| 2700 | - */ |
|
| 2701 | - public $EED_Ticket_Selector; |
|
| 2702 | - |
|
| 2703 | - /** |
|
| 2704 | - * @var EE_Event_Single_Config $EED_Event_Single |
|
| 2705 | - */ |
|
| 2706 | - public $EED_Event_Single; |
|
| 2707 | - |
|
| 2708 | - /** |
|
| 2709 | - * @var EE_Events_Archive_Config $EED_Events_Archive |
|
| 2710 | - */ |
|
| 2711 | - public $EED_Events_Archive; |
|
| 2712 | - |
|
| 2713 | - |
|
| 2714 | - |
|
| 2715 | - /** |
|
| 2716 | - * class constructor |
|
| 2717 | - * |
|
| 2718 | - * @access public |
|
| 2719 | - */ |
|
| 2720 | - public function __construct() |
|
| 2721 | - { |
|
| 2722 | - // set default template settings |
|
| 2723 | - $this->enable_default_style = true; |
|
| 2724 | - $this->custom_style_sheet = null; |
|
| 2725 | - $this->display_address_in_regform = true; |
|
| 2726 | - $this->display_description_on_multi_reg_page = false; |
|
| 2727 | - $this->use_custom_templates = false; |
|
| 2728 | - $this->current_espresso_theme = 'Espresso_Arabica_2014'; |
|
| 2729 | - $this->EED_Event_Single = null; |
|
| 2730 | - $this->EED_Events_Archive = null; |
|
| 2731 | - $this->EED_Ticket_Selector = null; |
|
| 2732 | - } |
|
| 2668 | + /** |
|
| 2669 | + * @var boolean $enable_default_style |
|
| 2670 | + */ |
|
| 2671 | + public $enable_default_style; |
|
| 2672 | + |
|
| 2673 | + /** |
|
| 2674 | + * @var string $custom_style_sheet |
|
| 2675 | + */ |
|
| 2676 | + public $custom_style_sheet; |
|
| 2677 | + |
|
| 2678 | + /** |
|
| 2679 | + * @var boolean $display_address_in_regform |
|
| 2680 | + */ |
|
| 2681 | + public $display_address_in_regform; |
|
| 2682 | + |
|
| 2683 | + /** |
|
| 2684 | + * @var int $display_description_on_multi_reg_page |
|
| 2685 | + */ |
|
| 2686 | + public $display_description_on_multi_reg_page; |
|
| 2687 | + |
|
| 2688 | + /** |
|
| 2689 | + * @var boolean $use_custom_templates |
|
| 2690 | + */ |
|
| 2691 | + public $use_custom_templates; |
|
| 2692 | + |
|
| 2693 | + /** |
|
| 2694 | + * @var string $current_espresso_theme |
|
| 2695 | + */ |
|
| 2696 | + public $current_espresso_theme; |
|
| 2697 | + |
|
| 2698 | + /** |
|
| 2699 | + * @var EE_Ticket_Selector_Config $EED_Ticket_Selector |
|
| 2700 | + */ |
|
| 2701 | + public $EED_Ticket_Selector; |
|
| 2702 | + |
|
| 2703 | + /** |
|
| 2704 | + * @var EE_Event_Single_Config $EED_Event_Single |
|
| 2705 | + */ |
|
| 2706 | + public $EED_Event_Single; |
|
| 2707 | + |
|
| 2708 | + /** |
|
| 2709 | + * @var EE_Events_Archive_Config $EED_Events_Archive |
|
| 2710 | + */ |
|
| 2711 | + public $EED_Events_Archive; |
|
| 2712 | + |
|
| 2713 | + |
|
| 2714 | + |
|
| 2715 | + /** |
|
| 2716 | + * class constructor |
|
| 2717 | + * |
|
| 2718 | + * @access public |
|
| 2719 | + */ |
|
| 2720 | + public function __construct() |
|
| 2721 | + { |
|
| 2722 | + // set default template settings |
|
| 2723 | + $this->enable_default_style = true; |
|
| 2724 | + $this->custom_style_sheet = null; |
|
| 2725 | + $this->display_address_in_regform = true; |
|
| 2726 | + $this->display_description_on_multi_reg_page = false; |
|
| 2727 | + $this->use_custom_templates = false; |
|
| 2728 | + $this->current_espresso_theme = 'Espresso_Arabica_2014'; |
|
| 2729 | + $this->EED_Event_Single = null; |
|
| 2730 | + $this->EED_Events_Archive = null; |
|
| 2731 | + $this->EED_Ticket_Selector = null; |
|
| 2732 | + } |
|
| 2733 | 2733 | |
| 2734 | 2734 | } |
| 2735 | 2735 | |
@@ -2741,115 +2741,115 @@ discard block |
||
| 2741 | 2741 | class EE_Map_Config extends EE_Config_Base |
| 2742 | 2742 | { |
| 2743 | 2743 | |
| 2744 | - /** |
|
| 2745 | - * @var boolean $use_google_maps |
|
| 2746 | - */ |
|
| 2747 | - public $use_google_maps; |
|
| 2748 | - |
|
| 2749 | - /** |
|
| 2750 | - * @var string $api_key |
|
| 2751 | - */ |
|
| 2752 | - public $google_map_api_key; |
|
| 2753 | - |
|
| 2754 | - /** |
|
| 2755 | - * @var int $event_details_map_width |
|
| 2756 | - */ |
|
| 2757 | - public $event_details_map_width; |
|
| 2758 | - |
|
| 2759 | - /** |
|
| 2760 | - * @var int $event_details_map_height |
|
| 2761 | - */ |
|
| 2762 | - public $event_details_map_height; |
|
| 2763 | - |
|
| 2764 | - /** |
|
| 2765 | - * @var int $event_details_map_zoom |
|
| 2766 | - */ |
|
| 2767 | - public $event_details_map_zoom; |
|
| 2768 | - |
|
| 2769 | - /** |
|
| 2770 | - * @var boolean $event_details_display_nav |
|
| 2771 | - */ |
|
| 2772 | - public $event_details_display_nav; |
|
| 2773 | - |
|
| 2774 | - /** |
|
| 2775 | - * @var boolean $event_details_nav_size |
|
| 2776 | - */ |
|
| 2777 | - public $event_details_nav_size; |
|
| 2778 | - |
|
| 2779 | - /** |
|
| 2780 | - * @var string $event_details_control_type |
|
| 2781 | - */ |
|
| 2782 | - public $event_details_control_type; |
|
| 2783 | - |
|
| 2784 | - /** |
|
| 2785 | - * @var string $event_details_map_align |
|
| 2786 | - */ |
|
| 2787 | - public $event_details_map_align; |
|
| 2788 | - |
|
| 2789 | - /** |
|
| 2790 | - * @var int $event_list_map_width |
|
| 2791 | - */ |
|
| 2792 | - public $event_list_map_width; |
|
| 2793 | - |
|
| 2794 | - /** |
|
| 2795 | - * @var int $event_list_map_height |
|
| 2796 | - */ |
|
| 2797 | - public $event_list_map_height; |
|
| 2798 | - |
|
| 2799 | - /** |
|
| 2800 | - * @var int $event_list_map_zoom |
|
| 2801 | - */ |
|
| 2802 | - public $event_list_map_zoom; |
|
| 2803 | - |
|
| 2804 | - /** |
|
| 2805 | - * @var boolean $event_list_display_nav |
|
| 2806 | - */ |
|
| 2807 | - public $event_list_display_nav; |
|
| 2808 | - |
|
| 2809 | - /** |
|
| 2810 | - * @var boolean $event_list_nav_size |
|
| 2811 | - */ |
|
| 2812 | - public $event_list_nav_size; |
|
| 2813 | - |
|
| 2814 | - /** |
|
| 2815 | - * @var string $event_list_control_type |
|
| 2816 | - */ |
|
| 2817 | - public $event_list_control_type; |
|
| 2818 | - |
|
| 2819 | - /** |
|
| 2820 | - * @var string $event_list_map_align |
|
| 2821 | - */ |
|
| 2822 | - public $event_list_map_align; |
|
| 2823 | - |
|
| 2824 | - |
|
| 2825 | - |
|
| 2826 | - /** |
|
| 2827 | - * class constructor |
|
| 2828 | - * |
|
| 2829 | - * @access public |
|
| 2830 | - */ |
|
| 2831 | - public function __construct() |
|
| 2832 | - { |
|
| 2833 | - // set default map settings |
|
| 2834 | - $this->use_google_maps = true; |
|
| 2835 | - $this->google_map_api_key = ''; |
|
| 2836 | - // for event details pages (reg page) |
|
| 2837 | - $this->event_details_map_width = 585; // ee_map_width_single |
|
| 2838 | - $this->event_details_map_height = 362; // ee_map_height_single |
|
| 2839 | - $this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
| 2840 | - $this->event_details_display_nav = true; // ee_map_nav_display_single |
|
| 2841 | - $this->event_details_nav_size = false; // ee_map_nav_size_single |
|
| 2842 | - $this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
| 2843 | - $this->event_details_map_align = 'center'; // ee_map_align_single |
|
| 2844 | - // for event list pages |
|
| 2845 | - $this->event_list_map_width = 300; // ee_map_width |
|
| 2846 | - $this->event_list_map_height = 185; // ee_map_height |
|
| 2847 | - $this->event_list_map_zoom = 12; // ee_map_zoom |
|
| 2848 | - $this->event_list_display_nav = false; // ee_map_nav_display |
|
| 2849 | - $this->event_list_nav_size = true; // ee_map_nav_size |
|
| 2850 | - $this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
| 2851 | - $this->event_list_map_align = 'center'; // ee_map_align |
|
| 2852 | - } |
|
| 2744 | + /** |
|
| 2745 | + * @var boolean $use_google_maps |
|
| 2746 | + */ |
|
| 2747 | + public $use_google_maps; |
|
| 2748 | + |
|
| 2749 | + /** |
|
| 2750 | + * @var string $api_key |
|
| 2751 | + */ |
|
| 2752 | + public $google_map_api_key; |
|
| 2753 | + |
|
| 2754 | + /** |
|
| 2755 | + * @var int $event_details_map_width |
|
| 2756 | + */ |
|
| 2757 | + public $event_details_map_width; |
|
| 2758 | + |
|
| 2759 | + /** |
|
| 2760 | + * @var int $event_details_map_height |
|
| 2761 | + */ |
|
| 2762 | + public $event_details_map_height; |
|
| 2763 | + |
|
| 2764 | + /** |
|
| 2765 | + * @var int $event_details_map_zoom |
|
| 2766 | + */ |
|
| 2767 | + public $event_details_map_zoom; |
|
| 2768 | + |
|
| 2769 | + /** |
|
| 2770 | + * @var boolean $event_details_display_nav |
|
| 2771 | + */ |
|
| 2772 | + public $event_details_display_nav; |
|
| 2773 | + |
|
| 2774 | + /** |
|
| 2775 | + * @var boolean $event_details_nav_size |
|
| 2776 | + */ |
|
| 2777 | + public $event_details_nav_size; |
|
| 2778 | + |
|
| 2779 | + /** |
|
| 2780 | + * @var string $event_details_control_type |
|
| 2781 | + */ |
|
| 2782 | + public $event_details_control_type; |
|
| 2783 | + |
|
| 2784 | + /** |
|
| 2785 | + * @var string $event_details_map_align |
|
| 2786 | + */ |
|
| 2787 | + public $event_details_map_align; |
|
| 2788 | + |
|
| 2789 | + /** |
|
| 2790 | + * @var int $event_list_map_width |
|
| 2791 | + */ |
|
| 2792 | + public $event_list_map_width; |
|
| 2793 | + |
|
| 2794 | + /** |
|
| 2795 | + * @var int $event_list_map_height |
|
| 2796 | + */ |
|
| 2797 | + public $event_list_map_height; |
|
| 2798 | + |
|
| 2799 | + /** |
|
| 2800 | + * @var int $event_list_map_zoom |
|
| 2801 | + */ |
|
| 2802 | + public $event_list_map_zoom; |
|
| 2803 | + |
|
| 2804 | + /** |
|
| 2805 | + * @var boolean $event_list_display_nav |
|
| 2806 | + */ |
|
| 2807 | + public $event_list_display_nav; |
|
| 2808 | + |
|
| 2809 | + /** |
|
| 2810 | + * @var boolean $event_list_nav_size |
|
| 2811 | + */ |
|
| 2812 | + public $event_list_nav_size; |
|
| 2813 | + |
|
| 2814 | + /** |
|
| 2815 | + * @var string $event_list_control_type |
|
| 2816 | + */ |
|
| 2817 | + public $event_list_control_type; |
|
| 2818 | + |
|
| 2819 | + /** |
|
| 2820 | + * @var string $event_list_map_align |
|
| 2821 | + */ |
|
| 2822 | + public $event_list_map_align; |
|
| 2823 | + |
|
| 2824 | + |
|
| 2825 | + |
|
| 2826 | + /** |
|
| 2827 | + * class constructor |
|
| 2828 | + * |
|
| 2829 | + * @access public |
|
| 2830 | + */ |
|
| 2831 | + public function __construct() |
|
| 2832 | + { |
|
| 2833 | + // set default map settings |
|
| 2834 | + $this->use_google_maps = true; |
|
| 2835 | + $this->google_map_api_key = ''; |
|
| 2836 | + // for event details pages (reg page) |
|
| 2837 | + $this->event_details_map_width = 585; // ee_map_width_single |
|
| 2838 | + $this->event_details_map_height = 362; // ee_map_height_single |
|
| 2839 | + $this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
| 2840 | + $this->event_details_display_nav = true; // ee_map_nav_display_single |
|
| 2841 | + $this->event_details_nav_size = false; // ee_map_nav_size_single |
|
| 2842 | + $this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
| 2843 | + $this->event_details_map_align = 'center'; // ee_map_align_single |
|
| 2844 | + // for event list pages |
|
| 2845 | + $this->event_list_map_width = 300; // ee_map_width |
|
| 2846 | + $this->event_list_map_height = 185; // ee_map_height |
|
| 2847 | + $this->event_list_map_zoom = 12; // ee_map_zoom |
|
| 2848 | + $this->event_list_display_nav = false; // ee_map_nav_display |
|
| 2849 | + $this->event_list_nav_size = true; // ee_map_nav_size |
|
| 2850 | + $this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
| 2851 | + $this->event_list_map_align = 'center'; // ee_map_align |
|
| 2852 | + } |
|
| 2853 | 2853 | |
| 2854 | 2854 | } |
| 2855 | 2855 | |
@@ -2861,47 +2861,47 @@ discard block |
||
| 2861 | 2861 | class EE_Events_Archive_Config extends EE_Config_Base |
| 2862 | 2862 | { |
| 2863 | 2863 | |
| 2864 | - public $display_status_banner; |
|
| 2864 | + public $display_status_banner; |
|
| 2865 | 2865 | |
| 2866 | - public $display_description; |
|
| 2866 | + public $display_description; |
|
| 2867 | 2867 | |
| 2868 | - public $display_ticket_selector; |
|
| 2868 | + public $display_ticket_selector; |
|
| 2869 | 2869 | |
| 2870 | - public $display_datetimes; |
|
| 2870 | + public $display_datetimes; |
|
| 2871 | 2871 | |
| 2872 | - public $display_venue; |
|
| 2872 | + public $display_venue; |
|
| 2873 | 2873 | |
| 2874 | - public $display_expired_events; |
|
| 2874 | + public $display_expired_events; |
|
| 2875 | 2875 | |
| 2876 | - public $use_sortable_display_order; |
|
| 2876 | + public $use_sortable_display_order; |
|
| 2877 | 2877 | |
| 2878 | - public $display_order_tickets; |
|
| 2878 | + public $display_order_tickets; |
|
| 2879 | 2879 | |
| 2880 | - public $display_order_datetimes; |
|
| 2880 | + public $display_order_datetimes; |
|
| 2881 | 2881 | |
| 2882 | - public $display_order_event; |
|
| 2882 | + public $display_order_event; |
|
| 2883 | 2883 | |
| 2884 | - public $display_order_venue; |
|
| 2884 | + public $display_order_venue; |
|
| 2885 | 2885 | |
| 2886 | 2886 | |
| 2887 | 2887 | |
| 2888 | - /** |
|
| 2889 | - * class constructor |
|
| 2890 | - */ |
|
| 2891 | - public function __construct() |
|
| 2892 | - { |
|
| 2893 | - $this->display_status_banner = 0; |
|
| 2894 | - $this->display_description = 1; |
|
| 2895 | - $this->display_ticket_selector = 0; |
|
| 2896 | - $this->display_datetimes = 1; |
|
| 2897 | - $this->display_venue = 0; |
|
| 2898 | - $this->display_expired_events = 0; |
|
| 2899 | - $this->use_sortable_display_order = false; |
|
| 2900 | - $this->display_order_tickets = 100; |
|
| 2901 | - $this->display_order_datetimes = 110; |
|
| 2902 | - $this->display_order_event = 120; |
|
| 2903 | - $this->display_order_venue = 130; |
|
| 2904 | - } |
|
| 2888 | + /** |
|
| 2889 | + * class constructor |
|
| 2890 | + */ |
|
| 2891 | + public function __construct() |
|
| 2892 | + { |
|
| 2893 | + $this->display_status_banner = 0; |
|
| 2894 | + $this->display_description = 1; |
|
| 2895 | + $this->display_ticket_selector = 0; |
|
| 2896 | + $this->display_datetimes = 1; |
|
| 2897 | + $this->display_venue = 0; |
|
| 2898 | + $this->display_expired_events = 0; |
|
| 2899 | + $this->use_sortable_display_order = false; |
|
| 2900 | + $this->display_order_tickets = 100; |
|
| 2901 | + $this->display_order_datetimes = 110; |
|
| 2902 | + $this->display_order_event = 120; |
|
| 2903 | + $this->display_order_venue = 130; |
|
| 2904 | + } |
|
| 2905 | 2905 | } |
| 2906 | 2906 | |
| 2907 | 2907 | |
@@ -2912,35 +2912,35 @@ discard block |
||
| 2912 | 2912 | class EE_Event_Single_Config extends EE_Config_Base |
| 2913 | 2913 | { |
| 2914 | 2914 | |
| 2915 | - public $display_status_banner_single; |
|
| 2915 | + public $display_status_banner_single; |
|
| 2916 | 2916 | |
| 2917 | - public $display_venue; |
|
| 2917 | + public $display_venue; |
|
| 2918 | 2918 | |
| 2919 | - public $use_sortable_display_order; |
|
| 2919 | + public $use_sortable_display_order; |
|
| 2920 | 2920 | |
| 2921 | - public $display_order_tickets; |
|
| 2921 | + public $display_order_tickets; |
|
| 2922 | 2922 | |
| 2923 | - public $display_order_datetimes; |
|
| 2923 | + public $display_order_datetimes; |
|
| 2924 | 2924 | |
| 2925 | - public $display_order_event; |
|
| 2925 | + public $display_order_event; |
|
| 2926 | 2926 | |
| 2927 | - public $display_order_venue; |
|
| 2927 | + public $display_order_venue; |
|
| 2928 | 2928 | |
| 2929 | 2929 | |
| 2930 | 2930 | |
| 2931 | - /** |
|
| 2932 | - * class constructor |
|
| 2933 | - */ |
|
| 2934 | - public function __construct() |
|
| 2935 | - { |
|
| 2936 | - $this->display_status_banner_single = 0; |
|
| 2937 | - $this->display_venue = 1; |
|
| 2938 | - $this->use_sortable_display_order = false; |
|
| 2939 | - $this->display_order_tickets = 100; |
|
| 2940 | - $this->display_order_datetimes = 110; |
|
| 2941 | - $this->display_order_event = 120; |
|
| 2942 | - $this->display_order_venue = 130; |
|
| 2943 | - } |
|
| 2931 | + /** |
|
| 2932 | + * class constructor |
|
| 2933 | + */ |
|
| 2934 | + public function __construct() |
|
| 2935 | + { |
|
| 2936 | + $this->display_status_banner_single = 0; |
|
| 2937 | + $this->display_venue = 1; |
|
| 2938 | + $this->use_sortable_display_order = false; |
|
| 2939 | + $this->display_order_tickets = 100; |
|
| 2940 | + $this->display_order_datetimes = 110; |
|
| 2941 | + $this->display_order_event = 120; |
|
| 2942 | + $this->display_order_venue = 130; |
|
| 2943 | + } |
|
| 2944 | 2944 | } |
| 2945 | 2945 | |
| 2946 | 2946 | |
@@ -2951,152 +2951,152 @@ discard block |
||
| 2951 | 2951 | class EE_Ticket_Selector_Config extends EE_Config_Base |
| 2952 | 2952 | { |
| 2953 | 2953 | |
| 2954 | - /** |
|
| 2955 | - * constant to indicate that a datetime selector should NEVER be shown for ticket selectors |
|
| 2956 | - */ |
|
| 2957 | - const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector'; |
|
| 2958 | - |
|
| 2959 | - /** |
|
| 2960 | - * constant to indicate that a datetime selector should only be shown for ticket selectors |
|
| 2961 | - * when the number of datetimes for the event matches the value set for $datetime_selector_threshold |
|
| 2962 | - */ |
|
| 2963 | - const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector'; |
|
| 2964 | - |
|
| 2965 | - /** |
|
| 2966 | - * @var boolean $show_ticket_sale_columns |
|
| 2967 | - */ |
|
| 2968 | - public $show_ticket_sale_columns; |
|
| 2969 | - |
|
| 2970 | - /** |
|
| 2971 | - * @var boolean $show_ticket_details |
|
| 2972 | - */ |
|
| 2973 | - public $show_ticket_details; |
|
| 2974 | - |
|
| 2975 | - /** |
|
| 2976 | - * @var boolean $show_expired_tickets |
|
| 2977 | - */ |
|
| 2978 | - public $show_expired_tickets; |
|
| 2979 | - |
|
| 2980 | - /** |
|
| 2981 | - * whether or not to display a dropdown box populated with event datetimes |
|
| 2982 | - * that toggles which tickets are displayed for a ticket selector. |
|
| 2983 | - * uses one of the *_DATETIME_SELECTOR constants defined above |
|
| 2984 | - * |
|
| 2985 | - * @var string $show_datetime_selector |
|
| 2986 | - */ |
|
| 2987 | - private $show_datetime_selector = 'no_datetime_selector'; |
|
| 2988 | - |
|
| 2989 | - /** |
|
| 2990 | - * the number of datetimes an event has to have before conditionally displaying a datetime selector |
|
| 2991 | - * |
|
| 2992 | - * @var int $datetime_selector_threshold |
|
| 2993 | - */ |
|
| 2994 | - private $datetime_selector_threshold = 3; |
|
| 2995 | - |
|
| 2996 | - |
|
| 2997 | - |
|
| 2998 | - /** |
|
| 2999 | - * class constructor |
|
| 3000 | - */ |
|
| 3001 | - public function __construct() |
|
| 3002 | - { |
|
| 3003 | - $this->show_ticket_sale_columns = true; |
|
| 3004 | - $this->show_ticket_details = true; |
|
| 3005 | - $this->show_expired_tickets = true; |
|
| 3006 | - $this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
|
| 3007 | - $this->datetime_selector_threshold = 3; |
|
| 3008 | - } |
|
| 3009 | - |
|
| 3010 | - |
|
| 3011 | - |
|
| 3012 | - /** |
|
| 3013 | - * returns true if a datetime selector should be displayed |
|
| 3014 | - * |
|
| 3015 | - * @param array $datetimes |
|
| 3016 | - * @return bool |
|
| 3017 | - */ |
|
| 3018 | - public function showDatetimeSelector(array $datetimes) |
|
| 3019 | - { |
|
| 3020 | - // if the settings are NOT: don't show OR below threshold, THEN active = true |
|
| 3021 | - return ! ( |
|
| 3022 | - $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR |
|
| 3023 | - || ( |
|
| 3024 | - $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR |
|
| 3025 | - && count($datetimes) < $this->getDatetimeSelectorThreshold() |
|
| 3026 | - ) |
|
| 3027 | - ); |
|
| 3028 | - } |
|
| 3029 | - |
|
| 3030 | - |
|
| 3031 | - |
|
| 3032 | - /** |
|
| 3033 | - * @return string |
|
| 3034 | - */ |
|
| 3035 | - public function getShowDatetimeSelector() |
|
| 3036 | - { |
|
| 3037 | - return $this->show_datetime_selector; |
|
| 3038 | - } |
|
| 3039 | - |
|
| 3040 | - |
|
| 3041 | - |
|
| 3042 | - /** |
|
| 3043 | - * @param bool $keys_only |
|
| 3044 | - * @return array |
|
| 3045 | - */ |
|
| 3046 | - public function getShowDatetimeSelectorOptions($keys_only = true) |
|
| 3047 | - { |
|
| 3048 | - return $keys_only |
|
| 3049 | - ? array( |
|
| 3050 | - \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR, |
|
| 3051 | - \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR, |
|
| 3052 | - ) |
|
| 3053 | - : array( |
|
| 3054 | - \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__( |
|
| 3055 | - 'Do not show date & time filter', 'event_espresso' |
|
| 3056 | - ), |
|
| 3057 | - \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR => esc_html__( |
|
| 3058 | - 'Maybe show date & time filter', 'event_espresso' |
|
| 3059 | - ), |
|
| 3060 | - ); |
|
| 3061 | - } |
|
| 3062 | - |
|
| 3063 | - |
|
| 3064 | - |
|
| 3065 | - /** |
|
| 3066 | - * @param string $show_datetime_selector |
|
| 3067 | - */ |
|
| 3068 | - public function setShowDatetimeSelector($show_datetime_selector) |
|
| 3069 | - { |
|
| 3070 | - $this->show_datetime_selector = in_array( |
|
| 3071 | - $show_datetime_selector, |
|
| 3072 | - $this->getShowDatetimeSelectorOptions(), |
|
| 3073 | - true |
|
| 3074 | - ) |
|
| 3075 | - ? $show_datetime_selector |
|
| 3076 | - : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
|
| 3077 | - } |
|
| 3078 | - |
|
| 3079 | - |
|
| 3080 | - |
|
| 3081 | - /** |
|
| 3082 | - * @return int |
|
| 3083 | - */ |
|
| 3084 | - public function getDatetimeSelectorThreshold() |
|
| 3085 | - { |
|
| 3086 | - return $this->datetime_selector_threshold; |
|
| 3087 | - } |
|
| 3088 | - |
|
| 3089 | - |
|
| 3090 | - |
|
| 3091 | - |
|
| 3092 | - /** |
|
| 3093 | - * @param int $datetime_selector_threshold |
|
| 3094 | - */ |
|
| 3095 | - public function setDatetimeSelectorThreshold($datetime_selector_threshold) |
|
| 3096 | - { |
|
| 3097 | - $datetime_selector_threshold = absint($datetime_selector_threshold); |
|
| 3098 | - $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3; |
|
| 3099 | - } |
|
| 2954 | + /** |
|
| 2955 | + * constant to indicate that a datetime selector should NEVER be shown for ticket selectors |
|
| 2956 | + */ |
|
| 2957 | + const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector'; |
|
| 2958 | + |
|
| 2959 | + /** |
|
| 2960 | + * constant to indicate that a datetime selector should only be shown for ticket selectors |
|
| 2961 | + * when the number of datetimes for the event matches the value set for $datetime_selector_threshold |
|
| 2962 | + */ |
|
| 2963 | + const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector'; |
|
| 2964 | + |
|
| 2965 | + /** |
|
| 2966 | + * @var boolean $show_ticket_sale_columns |
|
| 2967 | + */ |
|
| 2968 | + public $show_ticket_sale_columns; |
|
| 2969 | + |
|
| 2970 | + /** |
|
| 2971 | + * @var boolean $show_ticket_details |
|
| 2972 | + */ |
|
| 2973 | + public $show_ticket_details; |
|
| 2974 | + |
|
| 2975 | + /** |
|
| 2976 | + * @var boolean $show_expired_tickets |
|
| 2977 | + */ |
|
| 2978 | + public $show_expired_tickets; |
|
| 2979 | + |
|
| 2980 | + /** |
|
| 2981 | + * whether or not to display a dropdown box populated with event datetimes |
|
| 2982 | + * that toggles which tickets are displayed for a ticket selector. |
|
| 2983 | + * uses one of the *_DATETIME_SELECTOR constants defined above |
|
| 2984 | + * |
|
| 2985 | + * @var string $show_datetime_selector |
|
| 2986 | + */ |
|
| 2987 | + private $show_datetime_selector = 'no_datetime_selector'; |
|
| 2988 | + |
|
| 2989 | + /** |
|
| 2990 | + * the number of datetimes an event has to have before conditionally displaying a datetime selector |
|
| 2991 | + * |
|
| 2992 | + * @var int $datetime_selector_threshold |
|
| 2993 | + */ |
|
| 2994 | + private $datetime_selector_threshold = 3; |
|
| 2995 | + |
|
| 2996 | + |
|
| 2997 | + |
|
| 2998 | + /** |
|
| 2999 | + * class constructor |
|
| 3000 | + */ |
|
| 3001 | + public function __construct() |
|
| 3002 | + { |
|
| 3003 | + $this->show_ticket_sale_columns = true; |
|
| 3004 | + $this->show_ticket_details = true; |
|
| 3005 | + $this->show_expired_tickets = true; |
|
| 3006 | + $this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
|
| 3007 | + $this->datetime_selector_threshold = 3; |
|
| 3008 | + } |
|
| 3009 | + |
|
| 3010 | + |
|
| 3011 | + |
|
| 3012 | + /** |
|
| 3013 | + * returns true if a datetime selector should be displayed |
|
| 3014 | + * |
|
| 3015 | + * @param array $datetimes |
|
| 3016 | + * @return bool |
|
| 3017 | + */ |
|
| 3018 | + public function showDatetimeSelector(array $datetimes) |
|
| 3019 | + { |
|
| 3020 | + // if the settings are NOT: don't show OR below threshold, THEN active = true |
|
| 3021 | + return ! ( |
|
| 3022 | + $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR |
|
| 3023 | + || ( |
|
| 3024 | + $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR |
|
| 3025 | + && count($datetimes) < $this->getDatetimeSelectorThreshold() |
|
| 3026 | + ) |
|
| 3027 | + ); |
|
| 3028 | + } |
|
| 3029 | + |
|
| 3030 | + |
|
| 3031 | + |
|
| 3032 | + /** |
|
| 3033 | + * @return string |
|
| 3034 | + */ |
|
| 3035 | + public function getShowDatetimeSelector() |
|
| 3036 | + { |
|
| 3037 | + return $this->show_datetime_selector; |
|
| 3038 | + } |
|
| 3039 | + |
|
| 3040 | + |
|
| 3041 | + |
|
| 3042 | + /** |
|
| 3043 | + * @param bool $keys_only |
|
| 3044 | + * @return array |
|
| 3045 | + */ |
|
| 3046 | + public function getShowDatetimeSelectorOptions($keys_only = true) |
|
| 3047 | + { |
|
| 3048 | + return $keys_only |
|
| 3049 | + ? array( |
|
| 3050 | + \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR, |
|
| 3051 | + \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR, |
|
| 3052 | + ) |
|
| 3053 | + : array( |
|
| 3054 | + \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__( |
|
| 3055 | + 'Do not show date & time filter', 'event_espresso' |
|
| 3056 | + ), |
|
| 3057 | + \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR => esc_html__( |
|
| 3058 | + 'Maybe show date & time filter', 'event_espresso' |
|
| 3059 | + ), |
|
| 3060 | + ); |
|
| 3061 | + } |
|
| 3062 | + |
|
| 3063 | + |
|
| 3064 | + |
|
| 3065 | + /** |
|
| 3066 | + * @param string $show_datetime_selector |
|
| 3067 | + */ |
|
| 3068 | + public function setShowDatetimeSelector($show_datetime_selector) |
|
| 3069 | + { |
|
| 3070 | + $this->show_datetime_selector = in_array( |
|
| 3071 | + $show_datetime_selector, |
|
| 3072 | + $this->getShowDatetimeSelectorOptions(), |
|
| 3073 | + true |
|
| 3074 | + ) |
|
| 3075 | + ? $show_datetime_selector |
|
| 3076 | + : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
|
| 3077 | + } |
|
| 3078 | + |
|
| 3079 | + |
|
| 3080 | + |
|
| 3081 | + /** |
|
| 3082 | + * @return int |
|
| 3083 | + */ |
|
| 3084 | + public function getDatetimeSelectorThreshold() |
|
| 3085 | + { |
|
| 3086 | + return $this->datetime_selector_threshold; |
|
| 3087 | + } |
|
| 3088 | + |
|
| 3089 | + |
|
| 3090 | + |
|
| 3091 | + |
|
| 3092 | + /** |
|
| 3093 | + * @param int $datetime_selector_threshold |
|
| 3094 | + */ |
|
| 3095 | + public function setDatetimeSelectorThreshold($datetime_selector_threshold) |
|
| 3096 | + { |
|
| 3097 | + $datetime_selector_threshold = absint($datetime_selector_threshold); |
|
| 3098 | + $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3; |
|
| 3099 | + } |
|
| 3100 | 3100 | |
| 3101 | 3101 | |
| 3102 | 3102 | |
@@ -3114,85 +3114,85 @@ discard block |
||
| 3114 | 3114 | class EE_Environment_Config extends EE_Config_Base |
| 3115 | 3115 | { |
| 3116 | 3116 | |
| 3117 | - /** |
|
| 3118 | - * Hold any php environment variables that we want to track. |
|
| 3119 | - * |
|
| 3120 | - * @var stdClass; |
|
| 3121 | - */ |
|
| 3122 | - public $php; |
|
| 3123 | - |
|
| 3124 | - |
|
| 3125 | - |
|
| 3126 | - /** |
|
| 3127 | - * constructor |
|
| 3128 | - */ |
|
| 3129 | - public function __construct() |
|
| 3130 | - { |
|
| 3131 | - $this->php = new stdClass(); |
|
| 3132 | - $this->_set_php_values(); |
|
| 3133 | - } |
|
| 3134 | - |
|
| 3135 | - |
|
| 3136 | - |
|
| 3137 | - /** |
|
| 3138 | - * This sets the php environment variables. |
|
| 3139 | - * |
|
| 3140 | - * @since 4.4.0 |
|
| 3141 | - * @return void |
|
| 3142 | - */ |
|
| 3143 | - protected function _set_php_values() |
|
| 3144 | - { |
|
| 3145 | - $this->php->max_input_vars = ini_get('max_input_vars'); |
|
| 3146 | - $this->php->version = phpversion(); |
|
| 3147 | - } |
|
| 3148 | - |
|
| 3149 | - |
|
| 3150 | - |
|
| 3151 | - /** |
|
| 3152 | - * helper method for determining whether input_count is |
|
| 3153 | - * reaching the potential maximum the server can handle |
|
| 3154 | - * according to max_input_vars |
|
| 3155 | - * |
|
| 3156 | - * @param int $input_count the count of input vars. |
|
| 3157 | - * @return array { |
|
| 3158 | - * An array that represents whether available space and if no available space the error |
|
| 3159 | - * message. |
|
| 3160 | - * @type bool $has_space whether more inputs can be added. |
|
| 3161 | - * @type string $msg Any message to be displayed. |
|
| 3162 | - * } |
|
| 3163 | - */ |
|
| 3164 | - public function max_input_vars_limit_check($input_count = 0) |
|
| 3165 | - { |
|
| 3166 | - if (! empty($this->php->max_input_vars) |
|
| 3167 | - && ($input_count >= $this->php->max_input_vars) |
|
| 3168 | - && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9) |
|
| 3169 | - ) { |
|
| 3170 | - return sprintf( |
|
| 3171 | - __( |
|
| 3172 | - 'The maximum number of inputs on this page has been exceeded. You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.', |
|
| 3173 | - 'event_espresso' |
|
| 3174 | - ), |
|
| 3175 | - '<br>', |
|
| 3176 | - $input_count, |
|
| 3177 | - $this->php->max_input_vars |
|
| 3178 | - ); |
|
| 3179 | - } else { |
|
| 3180 | - return ''; |
|
| 3181 | - } |
|
| 3182 | - } |
|
| 3183 | - |
|
| 3184 | - |
|
| 3185 | - |
|
| 3186 | - /** |
|
| 3187 | - * The purpose of this method is just to force rechecking php values so if they've changed, they get updated. |
|
| 3188 | - * |
|
| 3189 | - * @since 4.4.1 |
|
| 3190 | - * @return void |
|
| 3191 | - */ |
|
| 3192 | - public function recheck_values() |
|
| 3193 | - { |
|
| 3194 | - $this->_set_php_values(); |
|
| 3195 | - } |
|
| 3117 | + /** |
|
| 3118 | + * Hold any php environment variables that we want to track. |
|
| 3119 | + * |
|
| 3120 | + * @var stdClass; |
|
| 3121 | + */ |
|
| 3122 | + public $php; |
|
| 3123 | + |
|
| 3124 | + |
|
| 3125 | + |
|
| 3126 | + /** |
|
| 3127 | + * constructor |
|
| 3128 | + */ |
|
| 3129 | + public function __construct() |
|
| 3130 | + { |
|
| 3131 | + $this->php = new stdClass(); |
|
| 3132 | + $this->_set_php_values(); |
|
| 3133 | + } |
|
| 3134 | + |
|
| 3135 | + |
|
| 3136 | + |
|
| 3137 | + /** |
|
| 3138 | + * This sets the php environment variables. |
|
| 3139 | + * |
|
| 3140 | + * @since 4.4.0 |
|
| 3141 | + * @return void |
|
| 3142 | + */ |
|
| 3143 | + protected function _set_php_values() |
|
| 3144 | + { |
|
| 3145 | + $this->php->max_input_vars = ini_get('max_input_vars'); |
|
| 3146 | + $this->php->version = phpversion(); |
|
| 3147 | + } |
|
| 3148 | + |
|
| 3149 | + |
|
| 3150 | + |
|
| 3151 | + /** |
|
| 3152 | + * helper method for determining whether input_count is |
|
| 3153 | + * reaching the potential maximum the server can handle |
|
| 3154 | + * according to max_input_vars |
|
| 3155 | + * |
|
| 3156 | + * @param int $input_count the count of input vars. |
|
| 3157 | + * @return array { |
|
| 3158 | + * An array that represents whether available space and if no available space the error |
|
| 3159 | + * message. |
|
| 3160 | + * @type bool $has_space whether more inputs can be added. |
|
| 3161 | + * @type string $msg Any message to be displayed. |
|
| 3162 | + * } |
|
| 3163 | + */ |
|
| 3164 | + public function max_input_vars_limit_check($input_count = 0) |
|
| 3165 | + { |
|
| 3166 | + if (! empty($this->php->max_input_vars) |
|
| 3167 | + && ($input_count >= $this->php->max_input_vars) |
|
| 3168 | + && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9) |
|
| 3169 | + ) { |
|
| 3170 | + return sprintf( |
|
| 3171 | + __( |
|
| 3172 | + 'The maximum number of inputs on this page has been exceeded. You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.', |
|
| 3173 | + 'event_espresso' |
|
| 3174 | + ), |
|
| 3175 | + '<br>', |
|
| 3176 | + $input_count, |
|
| 3177 | + $this->php->max_input_vars |
|
| 3178 | + ); |
|
| 3179 | + } else { |
|
| 3180 | + return ''; |
|
| 3181 | + } |
|
| 3182 | + } |
|
| 3183 | + |
|
| 3184 | + |
|
| 3185 | + |
|
| 3186 | + /** |
|
| 3187 | + * The purpose of this method is just to force rechecking php values so if they've changed, they get updated. |
|
| 3188 | + * |
|
| 3189 | + * @since 4.4.1 |
|
| 3190 | + * @return void |
|
| 3191 | + */ |
|
| 3192 | + public function recheck_values() |
|
| 3193 | + { |
|
| 3194 | + $this->_set_php_values(); |
|
| 3195 | + } |
|
| 3196 | 3196 | |
| 3197 | 3197 | |
| 3198 | 3198 | |
@@ -3210,22 +3210,22 @@ discard block |
||
| 3210 | 3210 | class EE_Tax_Config extends EE_Config_Base |
| 3211 | 3211 | { |
| 3212 | 3212 | |
| 3213 | - /* |
|
| 3213 | + /* |
|
| 3214 | 3214 | * flag to indicate whether or not to display ticket prices with the taxes included |
| 3215 | 3215 | * |
| 3216 | 3216 | * @var boolean $prices_displayed_including_taxes |
| 3217 | 3217 | */ |
| 3218 | - public $prices_displayed_including_taxes; |
|
| 3218 | + public $prices_displayed_including_taxes; |
|
| 3219 | 3219 | |
| 3220 | 3220 | |
| 3221 | 3221 | |
| 3222 | - /** |
|
| 3223 | - * class constructor |
|
| 3224 | - */ |
|
| 3225 | - public function __construct() |
|
| 3226 | - { |
|
| 3227 | - $this->prices_displayed_including_taxes = true; |
|
| 3228 | - } |
|
| 3222 | + /** |
|
| 3223 | + * class constructor |
|
| 3224 | + */ |
|
| 3225 | + public function __construct() |
|
| 3226 | + { |
|
| 3227 | + $this->prices_displayed_including_taxes = true; |
|
| 3228 | + } |
|
| 3229 | 3229 | } |
| 3230 | 3230 | |
| 3231 | 3231 | |
@@ -3240,17 +3240,17 @@ discard block |
||
| 3240 | 3240 | class EE_Messages_Config extends EE_Config_Base |
| 3241 | 3241 | { |
| 3242 | 3242 | |
| 3243 | - /** |
|
| 3244 | - * This is an integer representing the deletion threshold in months for when old messages will get deleted. |
|
| 3245 | - * A value of 0 represents never deleting. Default is 0. |
|
| 3246 | - * |
|
| 3247 | - * @var integer |
|
| 3248 | - */ |
|
| 3249 | - public $delete_threshold; |
|
| 3250 | - |
|
| 3251 | - public function __construct() { |
|
| 3252 | - $this->delete_threshold = 0; |
|
| 3253 | - } |
|
| 3243 | + /** |
|
| 3244 | + * This is an integer representing the deletion threshold in months for when old messages will get deleted. |
|
| 3245 | + * A value of 0 represents never deleting. Default is 0. |
|
| 3246 | + * |
|
| 3247 | + * @var integer |
|
| 3248 | + */ |
|
| 3249 | + public $delete_threshold; |
|
| 3250 | + |
|
| 3251 | + public function __construct() { |
|
| 3252 | + $this->delete_threshold = 0; |
|
| 3253 | + } |
|
| 3254 | 3254 | } |
| 3255 | 3255 | |
| 3256 | 3256 | |
@@ -3262,34 +3262,34 @@ discard block |
||
| 3262 | 3262 | class EE_Gateway_Config extends EE_Config_Base |
| 3263 | 3263 | { |
| 3264 | 3264 | |
| 3265 | - /** |
|
| 3266 | - * Array with keys that are payment gateways slugs, and values are arrays |
|
| 3267 | - * with any config info the gateway wants to store |
|
| 3268 | - * |
|
| 3269 | - * @var array |
|
| 3270 | - */ |
|
| 3271 | - public $payment_settings; |
|
| 3272 | - |
|
| 3273 | - /** |
|
| 3274 | - * Where keys are gateway slugs, and values are booleans indicating whether or not |
|
| 3275 | - * the gateway is stored in the uploads directory |
|
| 3276 | - * |
|
| 3277 | - * @var array |
|
| 3278 | - */ |
|
| 3279 | - public $active_gateways; |
|
| 3280 | - |
|
| 3281 | - |
|
| 3282 | - |
|
| 3283 | - /** |
|
| 3284 | - * class constructor |
|
| 3285 | - * |
|
| 3286 | - * @deprecated |
|
| 3287 | - */ |
|
| 3288 | - public function __construct() |
|
| 3289 | - { |
|
| 3290 | - $this->payment_settings = array(); |
|
| 3291 | - $this->active_gateways = array('Invoice' => false); |
|
| 3292 | - } |
|
| 3265 | + /** |
|
| 3266 | + * Array with keys that are payment gateways slugs, and values are arrays |
|
| 3267 | + * with any config info the gateway wants to store |
|
| 3268 | + * |
|
| 3269 | + * @var array |
|
| 3270 | + */ |
|
| 3271 | + public $payment_settings; |
|
| 3272 | + |
|
| 3273 | + /** |
|
| 3274 | + * Where keys are gateway slugs, and values are booleans indicating whether or not |
|
| 3275 | + * the gateway is stored in the uploads directory |
|
| 3276 | + * |
|
| 3277 | + * @var array |
|
| 3278 | + */ |
|
| 3279 | + public $active_gateways; |
|
| 3280 | + |
|
| 3281 | + |
|
| 3282 | + |
|
| 3283 | + /** |
|
| 3284 | + * class constructor |
|
| 3285 | + * |
|
| 3286 | + * @deprecated |
|
| 3287 | + */ |
|
| 3288 | + public function __construct() |
|
| 3289 | + { |
|
| 3290 | + $this->payment_settings = array(); |
|
| 3291 | + $this->active_gateways = array('Invoice' => false); |
|
| 3292 | + } |
|
| 3293 | 3293 | } |
| 3294 | 3294 | |
| 3295 | 3295 | // End of file EE_Config.core.php |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | use EventEspresso\core\services\request\ResponseInterface; |
| 9 | 9 | |
| 10 | 10 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
| 11 | - exit('No direct script access allowed'); |
|
| 11 | + exit('No direct script access allowed'); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | |
@@ -25,891 +25,891 @@ discard block |
||
| 25 | 25 | class EE_Dependency_Map |
| 26 | 26 | { |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * This means that the requested class dependency is not present in the dependency map |
|
| 30 | - */ |
|
| 31 | - const not_registered = 0; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class. |
|
| 35 | - */ |
|
| 36 | - const load_new_object = 1; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * This instructs class loaders to return a previously instantiated and cached object for the requested class. |
|
| 40 | - * IF a previously instantiated object does not exist, a new one will be created and added to the cache. |
|
| 41 | - */ |
|
| 42 | - const load_from_cache = 2; |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * When registering a dependency, |
|
| 46 | - * this indicates to keep any existing dependencies that already exist, |
|
| 47 | - * and simply discard any new dependencies declared in the incoming data |
|
| 48 | - */ |
|
| 49 | - const KEEP_EXISTING_DEPENDENCIES = 0; |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * When registering a dependency, |
|
| 53 | - * this indicates to overwrite any existing dependencies that already exist using the incoming data |
|
| 54 | - */ |
|
| 55 | - const OVERWRITE_DEPENDENCIES = 1; |
|
| 56 | - |
|
| 57 | - |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * @type EE_Dependency_Map $_instance |
|
| 61 | - */ |
|
| 62 | - protected static $_instance; |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * @type RequestInterface $request |
|
| 66 | - */ |
|
| 67 | - protected $request; |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * @type LegacyRequestInterface $legacy_request |
|
| 71 | - */ |
|
| 72 | - protected $legacy_request; |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * @type ResponseInterface $response |
|
| 76 | - */ |
|
| 77 | - protected $response; |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * @type LoaderInterface $loader |
|
| 81 | - */ |
|
| 82 | - protected $loader; |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * @type array $_dependency_map |
|
| 86 | - */ |
|
| 87 | - protected $_dependency_map = array(); |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * @type array $_class_loaders |
|
| 91 | - */ |
|
| 92 | - protected $_class_loaders = array(); |
|
| 93 | - |
|
| 94 | - /** |
|
| 95 | - * @type array $_aliases |
|
| 96 | - */ |
|
| 97 | - protected $_aliases = array(); |
|
| 98 | - |
|
| 99 | - |
|
| 100 | - |
|
| 101 | - /** |
|
| 102 | - * EE_Dependency_Map constructor. |
|
| 103 | - */ |
|
| 104 | - protected function __construct() |
|
| 105 | - { |
|
| 106 | - // add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize')); |
|
| 107 | - do_action('EE_Dependency_Map____construct'); |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * @throws InvalidDataTypeException |
|
| 114 | - * @throws InvalidInterfaceException |
|
| 115 | - * @throws InvalidArgumentException |
|
| 116 | - */ |
|
| 117 | - public function initialize() |
|
| 118 | - { |
|
| 119 | - $this->_register_core_dependencies(); |
|
| 120 | - $this->_register_core_class_loaders(); |
|
| 121 | - $this->_register_core_aliases(); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * @singleton method used to instantiate class object |
|
| 128 | - * @return EE_Dependency_Map |
|
| 129 | - */ |
|
| 130 | - public static function instance() { |
|
| 131 | - // check if class object is instantiated, and instantiated properly |
|
| 132 | - if (! self::$_instance instanceof EE_Dependency_Map) { |
|
| 133 | - self::$_instance = new EE_Dependency_Map(/*$request, $response, $legacy_request*/); |
|
| 134 | - } |
|
| 135 | - return self::$_instance; |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - |
|
| 139 | - /** |
|
| 140 | - * @param RequestInterface $request |
|
| 141 | - */ |
|
| 142 | - public function setRequest(RequestInterface $request) |
|
| 143 | - { |
|
| 144 | - $this->request = $request; |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - |
|
| 148 | - /** |
|
| 149 | - * @param LegacyRequestInterface $legacy_request |
|
| 150 | - */ |
|
| 151 | - public function setLegacyRequest(LegacyRequestInterface $legacy_request) |
|
| 152 | - { |
|
| 153 | - $this->legacy_request = $legacy_request; |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - |
|
| 157 | - /** |
|
| 158 | - * @param ResponseInterface $response |
|
| 159 | - */ |
|
| 160 | - public function setResponse(ResponseInterface $response) |
|
| 161 | - { |
|
| 162 | - $this->response = $response; |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - |
|
| 166 | - |
|
| 167 | - /** |
|
| 168 | - * @param LoaderInterface $loader |
|
| 169 | - */ |
|
| 170 | - public function setLoader(LoaderInterface $loader) |
|
| 171 | - { |
|
| 172 | - $this->loader = $loader; |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - |
|
| 176 | - |
|
| 177 | - /** |
|
| 178 | - * @param string $class |
|
| 179 | - * @param array $dependencies |
|
| 180 | - * @param int $overwrite |
|
| 181 | - * @return bool |
|
| 182 | - */ |
|
| 183 | - public static function register_dependencies( |
|
| 184 | - $class, |
|
| 185 | - array $dependencies, |
|
| 186 | - $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
| 187 | - ) { |
|
| 188 | - return self::$_instance->registerDependencies($class, $dependencies, $overwrite); |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - |
|
| 192 | - |
|
| 193 | - /** |
|
| 194 | - * Assigns an array of class names and corresponding load sources (new or cached) |
|
| 195 | - * to the class specified by the first parameter. |
|
| 196 | - * IMPORTANT !!! |
|
| 197 | - * The order of elements in the incoming $dependencies array MUST match |
|
| 198 | - * the order of the constructor parameters for the class in question. |
|
| 199 | - * This is especially important when overriding any existing dependencies that are registered. |
|
| 200 | - * the third parameter controls whether any duplicate dependencies are overwritten or not. |
|
| 201 | - * |
|
| 202 | - * @param string $class |
|
| 203 | - * @param array $dependencies |
|
| 204 | - * @param int $overwrite |
|
| 205 | - * @return bool |
|
| 206 | - */ |
|
| 207 | - public function registerDependencies( |
|
| 208 | - $class, |
|
| 209 | - array $dependencies, |
|
| 210 | - $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
| 211 | - ) { |
|
| 212 | - $class = trim($class, '\\'); |
|
| 213 | - $registered = false; |
|
| 214 | - if (empty(self::$_instance->_dependency_map[ $class ])) { |
|
| 215 | - self::$_instance->_dependency_map[ $class ] = array(); |
|
| 216 | - } |
|
| 217 | - // we need to make sure that any aliases used when registering a dependency |
|
| 218 | - // get resolved to the correct class name |
|
| 219 | - foreach ($dependencies as $dependency => $load_source) { |
|
| 220 | - $alias = self::$_instance->get_alias($dependency); |
|
| 221 | - if ( |
|
| 222 | - $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
| 223 | - || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ]) |
|
| 224 | - ) { |
|
| 225 | - unset($dependencies[$dependency]); |
|
| 226 | - $dependencies[$alias] = $load_source; |
|
| 227 | - $registered = true; |
|
| 228 | - } |
|
| 229 | - } |
|
| 230 | - // now add our two lists of dependencies together. |
|
| 231 | - // using Union (+=) favours the arrays in precedence from left to right, |
|
| 232 | - // so $dependencies is NOT overwritten because it is listed first |
|
| 233 | - // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
|
| 234 | - // Union is way faster than array_merge() but should be used with caution... |
|
| 235 | - // especially with numerically indexed arrays |
|
| 236 | - $dependencies += self::$_instance->_dependency_map[ $class ]; |
|
| 237 | - // now we need to ensure that the resulting dependencies |
|
| 238 | - // array only has the entries that are required for the class |
|
| 239 | - // so first count how many dependencies were originally registered for the class |
|
| 240 | - $dependency_count = count(self::$_instance->_dependency_map[ $class ]); |
|
| 241 | - // if that count is non-zero (meaning dependencies were already registered) |
|
| 242 | - self::$_instance->_dependency_map[ $class ] = $dependency_count |
|
| 243 | - // then truncate the final array to match that count |
|
| 244 | - ? array_slice($dependencies, 0, $dependency_count) |
|
| 245 | - // otherwise just take the incoming array because nothing previously existed |
|
| 246 | - : $dependencies; |
|
| 247 | - return $registered; |
|
| 248 | - } |
|
| 249 | - |
|
| 250 | - |
|
| 251 | - |
|
| 252 | - /** |
|
| 253 | - * @param string $class_name |
|
| 254 | - * @param string $loader |
|
| 255 | - * @return bool |
|
| 256 | - * @throws DomainException |
|
| 257 | - */ |
|
| 258 | - public static function register_class_loader($class_name, $loader = 'load_core') |
|
| 259 | - { |
|
| 260 | - if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
| 261 | - throw new DomainException( |
|
| 262 | - esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
|
| 263 | - ); |
|
| 264 | - } |
|
| 265 | - // check that loader is callable or method starts with "load_" and exists in EE_Registry |
|
| 266 | - if ( |
|
| 267 | - ! is_callable($loader) |
|
| 268 | - && ( |
|
| 269 | - strpos($loader, 'load_') !== 0 |
|
| 270 | - || ! method_exists('EE_Registry', $loader) |
|
| 271 | - ) |
|
| 272 | - ) { |
|
| 273 | - throw new DomainException( |
|
| 274 | - sprintf( |
|
| 275 | - esc_html__( |
|
| 276 | - '"%1$s" is not a valid loader method on EE_Registry.', |
|
| 277 | - 'event_espresso' |
|
| 278 | - ), |
|
| 279 | - $loader |
|
| 280 | - ) |
|
| 281 | - ); |
|
| 282 | - } |
|
| 283 | - $class_name = self::$_instance->get_alias($class_name); |
|
| 284 | - if (! isset(self::$_instance->_class_loaders[$class_name])) { |
|
| 285 | - self::$_instance->_class_loaders[$class_name] = $loader; |
|
| 286 | - return true; |
|
| 287 | - } |
|
| 288 | - return false; |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - |
|
| 292 | - |
|
| 293 | - /** |
|
| 294 | - * @return array |
|
| 295 | - */ |
|
| 296 | - public function dependency_map() |
|
| 297 | - { |
|
| 298 | - return $this->_dependency_map; |
|
| 299 | - } |
|
| 300 | - |
|
| 301 | - |
|
| 302 | - |
|
| 303 | - /** |
|
| 304 | - * returns TRUE if dependency map contains a listing for the provided class name |
|
| 305 | - * |
|
| 306 | - * @param string $class_name |
|
| 307 | - * @return boolean |
|
| 308 | - */ |
|
| 309 | - public function has($class_name = '') |
|
| 310 | - { |
|
| 311 | - // all legacy models have the same dependencies |
|
| 312 | - if (strpos($class_name, 'EEM_') === 0) { |
|
| 313 | - $class_name = 'LEGACY_MODELS'; |
|
| 314 | - } |
|
| 315 | - return isset($this->_dependency_map[$class_name]) ? true : false; |
|
| 316 | - } |
|
| 317 | - |
|
| 318 | - |
|
| 319 | - |
|
| 320 | - /** |
|
| 321 | - * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
|
| 322 | - * |
|
| 323 | - * @param string $class_name |
|
| 324 | - * @param string $dependency |
|
| 325 | - * @return bool |
|
| 326 | - */ |
|
| 327 | - public function has_dependency_for_class($class_name = '', $dependency = '') |
|
| 328 | - { |
|
| 329 | - // all legacy models have the same dependencies |
|
| 330 | - if (strpos($class_name, 'EEM_') === 0) { |
|
| 331 | - $class_name = 'LEGACY_MODELS'; |
|
| 332 | - } |
|
| 333 | - $dependency = $this->get_alias($dependency); |
|
| 334 | - return isset($this->_dependency_map[$class_name][$dependency]) |
|
| 335 | - ? true |
|
| 336 | - : false; |
|
| 337 | - } |
|
| 338 | - |
|
| 339 | - |
|
| 340 | - |
|
| 341 | - /** |
|
| 342 | - * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned |
|
| 343 | - * |
|
| 344 | - * @param string $class_name |
|
| 345 | - * @param string $dependency |
|
| 346 | - * @return int |
|
| 347 | - */ |
|
| 348 | - public function loading_strategy_for_class_dependency($class_name = '', $dependency = '') |
|
| 349 | - { |
|
| 350 | - // all legacy models have the same dependencies |
|
| 351 | - if (strpos($class_name, 'EEM_') === 0) { |
|
| 352 | - $class_name = 'LEGACY_MODELS'; |
|
| 353 | - } |
|
| 354 | - $dependency = $this->get_alias($dependency); |
|
| 355 | - return $this->has_dependency_for_class($class_name, $dependency) |
|
| 356 | - ? $this->_dependency_map[$class_name][$dependency] |
|
| 357 | - : EE_Dependency_Map::not_registered; |
|
| 358 | - } |
|
| 359 | - |
|
| 360 | - |
|
| 361 | - |
|
| 362 | - /** |
|
| 363 | - * @param string $class_name |
|
| 364 | - * @return string | Closure |
|
| 365 | - */ |
|
| 366 | - public function class_loader($class_name) |
|
| 367 | - { |
|
| 368 | - // all legacy models use load_model() |
|
| 369 | - if(strpos($class_name, 'EEM_') === 0){ |
|
| 370 | - return 'load_model'; |
|
| 371 | - } |
|
| 372 | - $class_name = $this->get_alias($class_name); |
|
| 373 | - return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : ''; |
|
| 374 | - } |
|
| 375 | - |
|
| 376 | - |
|
| 377 | - |
|
| 378 | - /** |
|
| 379 | - * @return array |
|
| 380 | - */ |
|
| 381 | - public function class_loaders() |
|
| 382 | - { |
|
| 383 | - return $this->_class_loaders; |
|
| 384 | - } |
|
| 385 | - |
|
| 386 | - |
|
| 387 | - |
|
| 388 | - /** |
|
| 389 | - * adds an alias for a classname |
|
| 390 | - * |
|
| 391 | - * @param string $class_name the class name that should be used (concrete class to replace interface) |
|
| 392 | - * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
| 393 | - * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
| 394 | - */ |
|
| 395 | - public function add_alias($class_name, $alias, $for_class = '') |
|
| 396 | - { |
|
| 397 | - if ($for_class !== '') { |
|
| 398 | - if (! isset($this->_aliases[$for_class])) { |
|
| 399 | - $this->_aliases[$for_class] = array(); |
|
| 400 | - } |
|
| 401 | - $this->_aliases[$for_class][$class_name] = $alias; |
|
| 402 | - } |
|
| 403 | - $this->_aliases[$class_name] = $alias; |
|
| 404 | - } |
|
| 405 | - |
|
| 406 | - |
|
| 407 | - |
|
| 408 | - /** |
|
| 409 | - * returns TRUE if the provided class name has an alias |
|
| 410 | - * |
|
| 411 | - * @param string $class_name |
|
| 412 | - * @param string $for_class |
|
| 413 | - * @return bool |
|
| 414 | - */ |
|
| 415 | - public function has_alias($class_name = '', $for_class = '') |
|
| 416 | - { |
|
| 417 | - return isset($this->_aliases[$for_class][$class_name]) |
|
| 418 | - || ( |
|
| 419 | - isset($this->_aliases[$class_name]) |
|
| 420 | - && ! is_array($this->_aliases[$class_name]) |
|
| 421 | - ); |
|
| 422 | - } |
|
| 423 | - |
|
| 424 | - |
|
| 425 | - |
|
| 426 | - /** |
|
| 427 | - * returns alias for class name if one exists, otherwise returns the original classname |
|
| 428 | - * functions recursively, so that multiple aliases can be used to drill down to a classname |
|
| 429 | - * for example: |
|
| 430 | - * if the following two entries were added to the _aliases array: |
|
| 431 | - * array( |
|
| 432 | - * 'interface_alias' => 'some\namespace\interface' |
|
| 433 | - * 'some\namespace\interface' => 'some\namespace\classname' |
|
| 434 | - * ) |
|
| 435 | - * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
| 436 | - * to load an instance of 'some\namespace\classname' |
|
| 437 | - * |
|
| 438 | - * @param string $class_name |
|
| 439 | - * @param string $for_class |
|
| 440 | - * @return string |
|
| 441 | - */ |
|
| 442 | - public function get_alias($class_name = '', $for_class = '') |
|
| 443 | - { |
|
| 444 | - if (! $this->has_alias($class_name, $for_class)) { |
|
| 445 | - return $class_name; |
|
| 446 | - } |
|
| 447 | - if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) { |
|
| 448 | - return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class); |
|
| 449 | - } |
|
| 450 | - return $this->get_alias($this->_aliases[$class_name]); |
|
| 451 | - } |
|
| 452 | - |
|
| 453 | - |
|
| 454 | - |
|
| 455 | - /** |
|
| 456 | - * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
|
| 457 | - * if one exists, or whether a new object should be generated every time the requested class is loaded. |
|
| 458 | - * This is done by using the following class constants: |
|
| 459 | - * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
|
| 460 | - * EE_Dependency_Map::load_new_object - generates a new object every time |
|
| 461 | - */ |
|
| 462 | - protected function _register_core_dependencies() |
|
| 463 | - { |
|
| 464 | - $this->_dependency_map = array( |
|
| 465 | - 'EE_Request_Handler' => array( |
|
| 466 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
| 467 | - ), |
|
| 468 | - 'EE_System' => array( |
|
| 469 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
| 470 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 471 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 472 | - 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
| 473 | - ), |
|
| 474 | - 'EE_Session' => array( |
|
| 475 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
| 476 | - 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache, |
|
| 477 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 478 | - 'EE_Encryption' => EE_Dependency_Map::load_from_cache, |
|
| 479 | - ), |
|
| 480 | - 'EE_Cart' => array( |
|
| 481 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
| 482 | - ), |
|
| 483 | - 'EE_Front_Controller' => array( |
|
| 484 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
| 485 | - 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
| 486 | - 'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache, |
|
| 487 | - ), |
|
| 488 | - 'EE_Messenger_Collection_Loader' => array( |
|
| 489 | - 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
|
| 490 | - ), |
|
| 491 | - 'EE_Message_Type_Collection_Loader' => array( |
|
| 492 | - 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
|
| 493 | - ), |
|
| 494 | - 'EE_Message_Resource_Manager' => array( |
|
| 495 | - 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
| 496 | - 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
| 497 | - 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
| 498 | - ), |
|
| 499 | - 'EE_Message_Factory' => array( |
|
| 500 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 501 | - ), |
|
| 502 | - 'EE_messages' => array( |
|
| 503 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 504 | - ), |
|
| 505 | - 'EE_Messages_Generator' => array( |
|
| 506 | - 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
|
| 507 | - 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
|
| 508 | - 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
|
| 509 | - 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
|
| 510 | - ), |
|
| 511 | - 'EE_Messages_Processor' => array( |
|
| 512 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 513 | - ), |
|
| 514 | - 'EE_Messages_Queue' => array( |
|
| 515 | - 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
|
| 516 | - ), |
|
| 517 | - 'EE_Messages_Template_Defaults' => array( |
|
| 518 | - 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
| 519 | - 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
|
| 520 | - ), |
|
| 521 | - 'EE_Message_To_Generate_From_Request' => array( |
|
| 522 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 523 | - 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
| 524 | - ), |
|
| 525 | - 'EventEspresso\core\services\commands\CommandBus' => array( |
|
| 526 | - 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
|
| 527 | - ), |
|
| 528 | - 'EventEspresso\services\commands\CommandHandler' => array( |
|
| 529 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
| 530 | - 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
|
| 531 | - ), |
|
| 532 | - 'EventEspresso\core\services\commands\CommandHandlerManager' => array( |
|
| 533 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 534 | - ), |
|
| 535 | - 'EventEspresso\core\services\commands\CompositeCommandHandler' => array( |
|
| 536 | - 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
|
| 537 | - 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
|
| 538 | - ), |
|
| 539 | - 'EventEspresso\core\services\commands\CommandFactory' => array( |
|
| 540 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 541 | - ), |
|
| 542 | - 'EventEspresso\core\services\commands\middleware\CapChecker' => array( |
|
| 543 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
| 544 | - ), |
|
| 545 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => array( |
|
| 546 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
| 547 | - ), |
|
| 548 | - 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => array( |
|
| 549 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
| 550 | - ), |
|
| 551 | - 'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler' => array( |
|
| 552 | - 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 553 | - ), |
|
| 554 | - 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler' => array( |
|
| 555 | - 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 556 | - ), |
|
| 557 | - 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => array( |
|
| 558 | - 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 559 | - ), |
|
| 560 | - 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => array( |
|
| 561 | - 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 562 | - ), |
|
| 563 | - 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array( |
|
| 564 | - 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 565 | - ), |
|
| 566 | - 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler' => array( |
|
| 567 | - 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 568 | - ), |
|
| 569 | - 'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler' => array( |
|
| 570 | - 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 571 | - ), |
|
| 572 | - 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => array( |
|
| 573 | - 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 574 | - ), |
|
| 575 | - 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler' => array( |
|
| 576 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
| 577 | - ), |
|
| 578 | - 'EventEspresso\core\services\database\TableManager' => array( |
|
| 579 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 580 | - ), |
|
| 581 | - 'EE_Data_Migration_Class_Base' => array( |
|
| 582 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 583 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 584 | - ), |
|
| 585 | - 'EE_DMS_Core_4_1_0' => array( |
|
| 586 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 587 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 588 | - ), |
|
| 589 | - 'EE_DMS_Core_4_2_0' => array( |
|
| 590 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 591 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 592 | - ), |
|
| 593 | - 'EE_DMS_Core_4_3_0' => array( |
|
| 594 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 595 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 596 | - ), |
|
| 597 | - 'EE_DMS_Core_4_4_0' => array( |
|
| 598 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 599 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 600 | - ), |
|
| 601 | - 'EE_DMS_Core_4_5_0' => array( |
|
| 602 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 603 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 604 | - ), |
|
| 605 | - 'EE_DMS_Core_4_6_0' => array( |
|
| 606 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 607 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 608 | - ), |
|
| 609 | - 'EE_DMS_Core_4_7_0' => array( |
|
| 610 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 611 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 612 | - ), |
|
| 613 | - 'EE_DMS_Core_4_8_0' => array( |
|
| 614 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 615 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 616 | - ), |
|
| 617 | - 'EE_DMS_Core_4_9_0' => array( |
|
| 618 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 619 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 620 | - ), |
|
| 621 | - 'EventEspresso\core\services\assets\Registry' => array( |
|
| 622 | - 'EE_Template_Config' => EE_Dependency_Map::load_from_cache, |
|
| 623 | - 'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
|
| 624 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache |
|
| 625 | - ), |
|
| 626 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled' => array( |
|
| 627 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 628 | - ), |
|
| 629 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout' => array( |
|
| 630 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 631 | - ), |
|
| 632 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees' => array( |
|
| 633 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 634 | - ), |
|
| 635 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoEvents' => array( |
|
| 636 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 637 | - ), |
|
| 638 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou' => array( |
|
| 639 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 640 | - ), |
|
| 641 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector' => array( |
|
| 642 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 643 | - ), |
|
| 644 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage' => array( |
|
| 645 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 646 | - ), |
|
| 647 | - 'EventEspresso\core\services\cache\BasicCacheManager' => array( |
|
| 648 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
| 649 | - ), |
|
| 650 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => array( |
|
| 651 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
| 652 | - ), |
|
| 653 | - 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => array( |
|
| 654 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
| 655 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 656 | - ), |
|
| 657 | - 'EventEspresso\core\domain\values\EmailAddress' => array( |
|
| 658 | - null, |
|
| 659 | - 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache, |
|
| 660 | - ), |
|
| 661 | - 'EventEspresso\core\services\orm\ModelFieldFactory' => array( |
|
| 662 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 663 | - ), |
|
| 664 | - 'LEGACY_MODELS' => array( |
|
| 665 | - null, |
|
| 666 | - 'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache, |
|
| 667 | - ), |
|
| 668 | - 'EE_Module_Request_Router' => array( |
|
| 669 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
| 670 | - ), |
|
| 671 | - 'EE_Registration_Processor' => array( |
|
| 672 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
| 673 | - ), |
|
| 674 | - 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => array( |
|
| 675 | - null, |
|
| 676 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
| 677 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
| 678 | - ), |
|
| 679 | - 'EventEspresso\core\services\licensing\LicenseService' => array( |
|
| 680 | - 'EventEspresso\core\domain\services\pue\Stats' => EE_Dependency_Map::load_from_cache, |
|
| 681 | - 'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache |
|
| 682 | - ), |
|
| 28 | + /** |
|
| 29 | + * This means that the requested class dependency is not present in the dependency map |
|
| 30 | + */ |
|
| 31 | + const not_registered = 0; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class. |
|
| 35 | + */ |
|
| 36 | + const load_new_object = 1; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * This instructs class loaders to return a previously instantiated and cached object for the requested class. |
|
| 40 | + * IF a previously instantiated object does not exist, a new one will be created and added to the cache. |
|
| 41 | + */ |
|
| 42 | + const load_from_cache = 2; |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * When registering a dependency, |
|
| 46 | + * this indicates to keep any existing dependencies that already exist, |
|
| 47 | + * and simply discard any new dependencies declared in the incoming data |
|
| 48 | + */ |
|
| 49 | + const KEEP_EXISTING_DEPENDENCIES = 0; |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * When registering a dependency, |
|
| 53 | + * this indicates to overwrite any existing dependencies that already exist using the incoming data |
|
| 54 | + */ |
|
| 55 | + const OVERWRITE_DEPENDENCIES = 1; |
|
| 56 | + |
|
| 57 | + |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * @type EE_Dependency_Map $_instance |
|
| 61 | + */ |
|
| 62 | + protected static $_instance; |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * @type RequestInterface $request |
|
| 66 | + */ |
|
| 67 | + protected $request; |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * @type LegacyRequestInterface $legacy_request |
|
| 71 | + */ |
|
| 72 | + protected $legacy_request; |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * @type ResponseInterface $response |
|
| 76 | + */ |
|
| 77 | + protected $response; |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * @type LoaderInterface $loader |
|
| 81 | + */ |
|
| 82 | + protected $loader; |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * @type array $_dependency_map |
|
| 86 | + */ |
|
| 87 | + protected $_dependency_map = array(); |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * @type array $_class_loaders |
|
| 91 | + */ |
|
| 92 | + protected $_class_loaders = array(); |
|
| 93 | + |
|
| 94 | + /** |
|
| 95 | + * @type array $_aliases |
|
| 96 | + */ |
|
| 97 | + protected $_aliases = array(); |
|
| 98 | + |
|
| 99 | + |
|
| 100 | + |
|
| 101 | + /** |
|
| 102 | + * EE_Dependency_Map constructor. |
|
| 103 | + */ |
|
| 104 | + protected function __construct() |
|
| 105 | + { |
|
| 106 | + // add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize')); |
|
| 107 | + do_action('EE_Dependency_Map____construct'); |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * @throws InvalidDataTypeException |
|
| 114 | + * @throws InvalidInterfaceException |
|
| 115 | + * @throws InvalidArgumentException |
|
| 116 | + */ |
|
| 117 | + public function initialize() |
|
| 118 | + { |
|
| 119 | + $this->_register_core_dependencies(); |
|
| 120 | + $this->_register_core_class_loaders(); |
|
| 121 | + $this->_register_core_aliases(); |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * @singleton method used to instantiate class object |
|
| 128 | + * @return EE_Dependency_Map |
|
| 129 | + */ |
|
| 130 | + public static function instance() { |
|
| 131 | + // check if class object is instantiated, and instantiated properly |
|
| 132 | + if (! self::$_instance instanceof EE_Dependency_Map) { |
|
| 133 | + self::$_instance = new EE_Dependency_Map(/*$request, $response, $legacy_request*/); |
|
| 134 | + } |
|
| 135 | + return self::$_instance; |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + |
|
| 139 | + /** |
|
| 140 | + * @param RequestInterface $request |
|
| 141 | + */ |
|
| 142 | + public function setRequest(RequestInterface $request) |
|
| 143 | + { |
|
| 144 | + $this->request = $request; |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + |
|
| 148 | + /** |
|
| 149 | + * @param LegacyRequestInterface $legacy_request |
|
| 150 | + */ |
|
| 151 | + public function setLegacyRequest(LegacyRequestInterface $legacy_request) |
|
| 152 | + { |
|
| 153 | + $this->legacy_request = $legacy_request; |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + |
|
| 157 | + /** |
|
| 158 | + * @param ResponseInterface $response |
|
| 159 | + */ |
|
| 160 | + public function setResponse(ResponseInterface $response) |
|
| 161 | + { |
|
| 162 | + $this->response = $response; |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + |
|
| 166 | + |
|
| 167 | + /** |
|
| 168 | + * @param LoaderInterface $loader |
|
| 169 | + */ |
|
| 170 | + public function setLoader(LoaderInterface $loader) |
|
| 171 | + { |
|
| 172 | + $this->loader = $loader; |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + |
|
| 176 | + |
|
| 177 | + /** |
|
| 178 | + * @param string $class |
|
| 179 | + * @param array $dependencies |
|
| 180 | + * @param int $overwrite |
|
| 181 | + * @return bool |
|
| 182 | + */ |
|
| 183 | + public static function register_dependencies( |
|
| 184 | + $class, |
|
| 185 | + array $dependencies, |
|
| 186 | + $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
| 187 | + ) { |
|
| 188 | + return self::$_instance->registerDependencies($class, $dependencies, $overwrite); |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + |
|
| 192 | + |
|
| 193 | + /** |
|
| 194 | + * Assigns an array of class names and corresponding load sources (new or cached) |
|
| 195 | + * to the class specified by the first parameter. |
|
| 196 | + * IMPORTANT !!! |
|
| 197 | + * The order of elements in the incoming $dependencies array MUST match |
|
| 198 | + * the order of the constructor parameters for the class in question. |
|
| 199 | + * This is especially important when overriding any existing dependencies that are registered. |
|
| 200 | + * the third parameter controls whether any duplicate dependencies are overwritten or not. |
|
| 201 | + * |
|
| 202 | + * @param string $class |
|
| 203 | + * @param array $dependencies |
|
| 204 | + * @param int $overwrite |
|
| 205 | + * @return bool |
|
| 206 | + */ |
|
| 207 | + public function registerDependencies( |
|
| 208 | + $class, |
|
| 209 | + array $dependencies, |
|
| 210 | + $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
| 211 | + ) { |
|
| 212 | + $class = trim($class, '\\'); |
|
| 213 | + $registered = false; |
|
| 214 | + if (empty(self::$_instance->_dependency_map[ $class ])) { |
|
| 215 | + self::$_instance->_dependency_map[ $class ] = array(); |
|
| 216 | + } |
|
| 217 | + // we need to make sure that any aliases used when registering a dependency |
|
| 218 | + // get resolved to the correct class name |
|
| 219 | + foreach ($dependencies as $dependency => $load_source) { |
|
| 220 | + $alias = self::$_instance->get_alias($dependency); |
|
| 221 | + if ( |
|
| 222 | + $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
| 223 | + || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ]) |
|
| 224 | + ) { |
|
| 225 | + unset($dependencies[$dependency]); |
|
| 226 | + $dependencies[$alias] = $load_source; |
|
| 227 | + $registered = true; |
|
| 228 | + } |
|
| 229 | + } |
|
| 230 | + // now add our two lists of dependencies together. |
|
| 231 | + // using Union (+=) favours the arrays in precedence from left to right, |
|
| 232 | + // so $dependencies is NOT overwritten because it is listed first |
|
| 233 | + // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
|
| 234 | + // Union is way faster than array_merge() but should be used with caution... |
|
| 235 | + // especially with numerically indexed arrays |
|
| 236 | + $dependencies += self::$_instance->_dependency_map[ $class ]; |
|
| 237 | + // now we need to ensure that the resulting dependencies |
|
| 238 | + // array only has the entries that are required for the class |
|
| 239 | + // so first count how many dependencies were originally registered for the class |
|
| 240 | + $dependency_count = count(self::$_instance->_dependency_map[ $class ]); |
|
| 241 | + // if that count is non-zero (meaning dependencies were already registered) |
|
| 242 | + self::$_instance->_dependency_map[ $class ] = $dependency_count |
|
| 243 | + // then truncate the final array to match that count |
|
| 244 | + ? array_slice($dependencies, 0, $dependency_count) |
|
| 245 | + // otherwise just take the incoming array because nothing previously existed |
|
| 246 | + : $dependencies; |
|
| 247 | + return $registered; |
|
| 248 | + } |
|
| 249 | + |
|
| 250 | + |
|
| 251 | + |
|
| 252 | + /** |
|
| 253 | + * @param string $class_name |
|
| 254 | + * @param string $loader |
|
| 255 | + * @return bool |
|
| 256 | + * @throws DomainException |
|
| 257 | + */ |
|
| 258 | + public static function register_class_loader($class_name, $loader = 'load_core') |
|
| 259 | + { |
|
| 260 | + if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
| 261 | + throw new DomainException( |
|
| 262 | + esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
|
| 263 | + ); |
|
| 264 | + } |
|
| 265 | + // check that loader is callable or method starts with "load_" and exists in EE_Registry |
|
| 266 | + if ( |
|
| 267 | + ! is_callable($loader) |
|
| 268 | + && ( |
|
| 269 | + strpos($loader, 'load_') !== 0 |
|
| 270 | + || ! method_exists('EE_Registry', $loader) |
|
| 271 | + ) |
|
| 272 | + ) { |
|
| 273 | + throw new DomainException( |
|
| 274 | + sprintf( |
|
| 275 | + esc_html__( |
|
| 276 | + '"%1$s" is not a valid loader method on EE_Registry.', |
|
| 277 | + 'event_espresso' |
|
| 278 | + ), |
|
| 279 | + $loader |
|
| 280 | + ) |
|
| 281 | + ); |
|
| 282 | + } |
|
| 283 | + $class_name = self::$_instance->get_alias($class_name); |
|
| 284 | + if (! isset(self::$_instance->_class_loaders[$class_name])) { |
|
| 285 | + self::$_instance->_class_loaders[$class_name] = $loader; |
|
| 286 | + return true; |
|
| 287 | + } |
|
| 288 | + return false; |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + |
|
| 292 | + |
|
| 293 | + /** |
|
| 294 | + * @return array |
|
| 295 | + */ |
|
| 296 | + public function dependency_map() |
|
| 297 | + { |
|
| 298 | + return $this->_dependency_map; |
|
| 299 | + } |
|
| 300 | + |
|
| 301 | + |
|
| 302 | + |
|
| 303 | + /** |
|
| 304 | + * returns TRUE if dependency map contains a listing for the provided class name |
|
| 305 | + * |
|
| 306 | + * @param string $class_name |
|
| 307 | + * @return boolean |
|
| 308 | + */ |
|
| 309 | + public function has($class_name = '') |
|
| 310 | + { |
|
| 311 | + // all legacy models have the same dependencies |
|
| 312 | + if (strpos($class_name, 'EEM_') === 0) { |
|
| 313 | + $class_name = 'LEGACY_MODELS'; |
|
| 314 | + } |
|
| 315 | + return isset($this->_dependency_map[$class_name]) ? true : false; |
|
| 316 | + } |
|
| 317 | + |
|
| 318 | + |
|
| 319 | + |
|
| 320 | + /** |
|
| 321 | + * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
|
| 322 | + * |
|
| 323 | + * @param string $class_name |
|
| 324 | + * @param string $dependency |
|
| 325 | + * @return bool |
|
| 326 | + */ |
|
| 327 | + public function has_dependency_for_class($class_name = '', $dependency = '') |
|
| 328 | + { |
|
| 329 | + // all legacy models have the same dependencies |
|
| 330 | + if (strpos($class_name, 'EEM_') === 0) { |
|
| 331 | + $class_name = 'LEGACY_MODELS'; |
|
| 332 | + } |
|
| 333 | + $dependency = $this->get_alias($dependency); |
|
| 334 | + return isset($this->_dependency_map[$class_name][$dependency]) |
|
| 335 | + ? true |
|
| 336 | + : false; |
|
| 337 | + } |
|
| 338 | + |
|
| 339 | + |
|
| 340 | + |
|
| 341 | + /** |
|
| 342 | + * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned |
|
| 343 | + * |
|
| 344 | + * @param string $class_name |
|
| 345 | + * @param string $dependency |
|
| 346 | + * @return int |
|
| 347 | + */ |
|
| 348 | + public function loading_strategy_for_class_dependency($class_name = '', $dependency = '') |
|
| 349 | + { |
|
| 350 | + // all legacy models have the same dependencies |
|
| 351 | + if (strpos($class_name, 'EEM_') === 0) { |
|
| 352 | + $class_name = 'LEGACY_MODELS'; |
|
| 353 | + } |
|
| 354 | + $dependency = $this->get_alias($dependency); |
|
| 355 | + return $this->has_dependency_for_class($class_name, $dependency) |
|
| 356 | + ? $this->_dependency_map[$class_name][$dependency] |
|
| 357 | + : EE_Dependency_Map::not_registered; |
|
| 358 | + } |
|
| 359 | + |
|
| 360 | + |
|
| 361 | + |
|
| 362 | + /** |
|
| 363 | + * @param string $class_name |
|
| 364 | + * @return string | Closure |
|
| 365 | + */ |
|
| 366 | + public function class_loader($class_name) |
|
| 367 | + { |
|
| 368 | + // all legacy models use load_model() |
|
| 369 | + if(strpos($class_name, 'EEM_') === 0){ |
|
| 370 | + return 'load_model'; |
|
| 371 | + } |
|
| 372 | + $class_name = $this->get_alias($class_name); |
|
| 373 | + return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : ''; |
|
| 374 | + } |
|
| 375 | + |
|
| 376 | + |
|
| 377 | + |
|
| 378 | + /** |
|
| 379 | + * @return array |
|
| 380 | + */ |
|
| 381 | + public function class_loaders() |
|
| 382 | + { |
|
| 383 | + return $this->_class_loaders; |
|
| 384 | + } |
|
| 385 | + |
|
| 386 | + |
|
| 387 | + |
|
| 388 | + /** |
|
| 389 | + * adds an alias for a classname |
|
| 390 | + * |
|
| 391 | + * @param string $class_name the class name that should be used (concrete class to replace interface) |
|
| 392 | + * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
| 393 | + * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
| 394 | + */ |
|
| 395 | + public function add_alias($class_name, $alias, $for_class = '') |
|
| 396 | + { |
|
| 397 | + if ($for_class !== '') { |
|
| 398 | + if (! isset($this->_aliases[$for_class])) { |
|
| 399 | + $this->_aliases[$for_class] = array(); |
|
| 400 | + } |
|
| 401 | + $this->_aliases[$for_class][$class_name] = $alias; |
|
| 402 | + } |
|
| 403 | + $this->_aliases[$class_name] = $alias; |
|
| 404 | + } |
|
| 405 | + |
|
| 406 | + |
|
| 407 | + |
|
| 408 | + /** |
|
| 409 | + * returns TRUE if the provided class name has an alias |
|
| 410 | + * |
|
| 411 | + * @param string $class_name |
|
| 412 | + * @param string $for_class |
|
| 413 | + * @return bool |
|
| 414 | + */ |
|
| 415 | + public function has_alias($class_name = '', $for_class = '') |
|
| 416 | + { |
|
| 417 | + return isset($this->_aliases[$for_class][$class_name]) |
|
| 418 | + || ( |
|
| 419 | + isset($this->_aliases[$class_name]) |
|
| 420 | + && ! is_array($this->_aliases[$class_name]) |
|
| 421 | + ); |
|
| 422 | + } |
|
| 423 | + |
|
| 424 | + |
|
| 425 | + |
|
| 426 | + /** |
|
| 427 | + * returns alias for class name if one exists, otherwise returns the original classname |
|
| 428 | + * functions recursively, so that multiple aliases can be used to drill down to a classname |
|
| 429 | + * for example: |
|
| 430 | + * if the following two entries were added to the _aliases array: |
|
| 431 | + * array( |
|
| 432 | + * 'interface_alias' => 'some\namespace\interface' |
|
| 433 | + * 'some\namespace\interface' => 'some\namespace\classname' |
|
| 434 | + * ) |
|
| 435 | + * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
| 436 | + * to load an instance of 'some\namespace\classname' |
|
| 437 | + * |
|
| 438 | + * @param string $class_name |
|
| 439 | + * @param string $for_class |
|
| 440 | + * @return string |
|
| 441 | + */ |
|
| 442 | + public function get_alias($class_name = '', $for_class = '') |
|
| 443 | + { |
|
| 444 | + if (! $this->has_alias($class_name, $for_class)) { |
|
| 445 | + return $class_name; |
|
| 446 | + } |
|
| 447 | + if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) { |
|
| 448 | + return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class); |
|
| 449 | + } |
|
| 450 | + return $this->get_alias($this->_aliases[$class_name]); |
|
| 451 | + } |
|
| 452 | + |
|
| 453 | + |
|
| 454 | + |
|
| 455 | + /** |
|
| 456 | + * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
|
| 457 | + * if one exists, or whether a new object should be generated every time the requested class is loaded. |
|
| 458 | + * This is done by using the following class constants: |
|
| 459 | + * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
|
| 460 | + * EE_Dependency_Map::load_new_object - generates a new object every time |
|
| 461 | + */ |
|
| 462 | + protected function _register_core_dependencies() |
|
| 463 | + { |
|
| 464 | + $this->_dependency_map = array( |
|
| 465 | + 'EE_Request_Handler' => array( |
|
| 466 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
| 467 | + ), |
|
| 468 | + 'EE_System' => array( |
|
| 469 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
| 470 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 471 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 472 | + 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
| 473 | + ), |
|
| 474 | + 'EE_Session' => array( |
|
| 475 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
| 476 | + 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache, |
|
| 477 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 478 | + 'EE_Encryption' => EE_Dependency_Map::load_from_cache, |
|
| 479 | + ), |
|
| 480 | + 'EE_Cart' => array( |
|
| 481 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
| 482 | + ), |
|
| 483 | + 'EE_Front_Controller' => array( |
|
| 484 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
| 485 | + 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
| 486 | + 'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache, |
|
| 487 | + ), |
|
| 488 | + 'EE_Messenger_Collection_Loader' => array( |
|
| 489 | + 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
|
| 490 | + ), |
|
| 491 | + 'EE_Message_Type_Collection_Loader' => array( |
|
| 492 | + 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
|
| 493 | + ), |
|
| 494 | + 'EE_Message_Resource_Manager' => array( |
|
| 495 | + 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
| 496 | + 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
| 497 | + 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
| 498 | + ), |
|
| 499 | + 'EE_Message_Factory' => array( |
|
| 500 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 501 | + ), |
|
| 502 | + 'EE_messages' => array( |
|
| 503 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 504 | + ), |
|
| 505 | + 'EE_Messages_Generator' => array( |
|
| 506 | + 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
|
| 507 | + 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
|
| 508 | + 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
|
| 509 | + 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
|
| 510 | + ), |
|
| 511 | + 'EE_Messages_Processor' => array( |
|
| 512 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 513 | + ), |
|
| 514 | + 'EE_Messages_Queue' => array( |
|
| 515 | + 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
|
| 516 | + ), |
|
| 517 | + 'EE_Messages_Template_Defaults' => array( |
|
| 518 | + 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
| 519 | + 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
|
| 520 | + ), |
|
| 521 | + 'EE_Message_To_Generate_From_Request' => array( |
|
| 522 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 523 | + 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
| 524 | + ), |
|
| 525 | + 'EventEspresso\core\services\commands\CommandBus' => array( |
|
| 526 | + 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
|
| 527 | + ), |
|
| 528 | + 'EventEspresso\services\commands\CommandHandler' => array( |
|
| 529 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
| 530 | + 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
|
| 531 | + ), |
|
| 532 | + 'EventEspresso\core\services\commands\CommandHandlerManager' => array( |
|
| 533 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 534 | + ), |
|
| 535 | + 'EventEspresso\core\services\commands\CompositeCommandHandler' => array( |
|
| 536 | + 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
|
| 537 | + 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
|
| 538 | + ), |
|
| 539 | + 'EventEspresso\core\services\commands\CommandFactory' => array( |
|
| 540 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 541 | + ), |
|
| 542 | + 'EventEspresso\core\services\commands\middleware\CapChecker' => array( |
|
| 543 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
| 544 | + ), |
|
| 545 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => array( |
|
| 546 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
| 547 | + ), |
|
| 548 | + 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => array( |
|
| 549 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
| 550 | + ), |
|
| 551 | + 'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler' => array( |
|
| 552 | + 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 553 | + ), |
|
| 554 | + 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler' => array( |
|
| 555 | + 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 556 | + ), |
|
| 557 | + 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => array( |
|
| 558 | + 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 559 | + ), |
|
| 560 | + 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => array( |
|
| 561 | + 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 562 | + ), |
|
| 563 | + 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array( |
|
| 564 | + 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 565 | + ), |
|
| 566 | + 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler' => array( |
|
| 567 | + 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 568 | + ), |
|
| 569 | + 'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler' => array( |
|
| 570 | + 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 571 | + ), |
|
| 572 | + 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => array( |
|
| 573 | + 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 574 | + ), |
|
| 575 | + 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler' => array( |
|
| 576 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
| 577 | + ), |
|
| 578 | + 'EventEspresso\core\services\database\TableManager' => array( |
|
| 579 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 580 | + ), |
|
| 581 | + 'EE_Data_Migration_Class_Base' => array( |
|
| 582 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 583 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 584 | + ), |
|
| 585 | + 'EE_DMS_Core_4_1_0' => array( |
|
| 586 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 587 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 588 | + ), |
|
| 589 | + 'EE_DMS_Core_4_2_0' => array( |
|
| 590 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 591 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 592 | + ), |
|
| 593 | + 'EE_DMS_Core_4_3_0' => array( |
|
| 594 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 595 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 596 | + ), |
|
| 597 | + 'EE_DMS_Core_4_4_0' => array( |
|
| 598 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 599 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 600 | + ), |
|
| 601 | + 'EE_DMS_Core_4_5_0' => array( |
|
| 602 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 603 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 604 | + ), |
|
| 605 | + 'EE_DMS_Core_4_6_0' => array( |
|
| 606 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 607 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 608 | + ), |
|
| 609 | + 'EE_DMS_Core_4_7_0' => array( |
|
| 610 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 611 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 612 | + ), |
|
| 613 | + 'EE_DMS_Core_4_8_0' => array( |
|
| 614 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 615 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 616 | + ), |
|
| 617 | + 'EE_DMS_Core_4_9_0' => array( |
|
| 618 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 619 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 620 | + ), |
|
| 621 | + 'EventEspresso\core\services\assets\Registry' => array( |
|
| 622 | + 'EE_Template_Config' => EE_Dependency_Map::load_from_cache, |
|
| 623 | + 'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
|
| 624 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache |
|
| 625 | + ), |
|
| 626 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled' => array( |
|
| 627 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 628 | + ), |
|
| 629 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout' => array( |
|
| 630 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 631 | + ), |
|
| 632 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees' => array( |
|
| 633 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 634 | + ), |
|
| 635 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoEvents' => array( |
|
| 636 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 637 | + ), |
|
| 638 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou' => array( |
|
| 639 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 640 | + ), |
|
| 641 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector' => array( |
|
| 642 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 643 | + ), |
|
| 644 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage' => array( |
|
| 645 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 646 | + ), |
|
| 647 | + 'EventEspresso\core\services\cache\BasicCacheManager' => array( |
|
| 648 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
| 649 | + ), |
|
| 650 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => array( |
|
| 651 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
| 652 | + ), |
|
| 653 | + 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => array( |
|
| 654 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
| 655 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 656 | + ), |
|
| 657 | + 'EventEspresso\core\domain\values\EmailAddress' => array( |
|
| 658 | + null, |
|
| 659 | + 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache, |
|
| 660 | + ), |
|
| 661 | + 'EventEspresso\core\services\orm\ModelFieldFactory' => array( |
|
| 662 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 663 | + ), |
|
| 664 | + 'LEGACY_MODELS' => array( |
|
| 665 | + null, |
|
| 666 | + 'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache, |
|
| 667 | + ), |
|
| 668 | + 'EE_Module_Request_Router' => array( |
|
| 669 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
| 670 | + ), |
|
| 671 | + 'EE_Registration_Processor' => array( |
|
| 672 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
| 673 | + ), |
|
| 674 | + 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => array( |
|
| 675 | + null, |
|
| 676 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
| 677 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
| 678 | + ), |
|
| 679 | + 'EventEspresso\core\services\licensing\LicenseService' => array( |
|
| 680 | + 'EventEspresso\core\domain\services\pue\Stats' => EE_Dependency_Map::load_from_cache, |
|
| 681 | + 'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache |
|
| 682 | + ), |
|
| 683 | 683 | 'EE_Admin_Transactions_List_Table' => array( |
| 684 | - null, |
|
| 685 | - 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache, |
|
| 686 | - ), |
|
| 687 | - 'EventEspresso\core\domain\services\pue\Stats' => array( |
|
| 688 | - 'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache, |
|
| 689 | - 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
| 690 | - 'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache |
|
| 691 | - ), |
|
| 692 | - 'EventEspresso\core\domain\services\pue\Config' => array( |
|
| 693 | - 'EE_Network_Config' => EE_Dependency_Map::load_from_cache, |
|
| 694 | - 'EE_Config' => EE_Dependency_Map::load_from_cache |
|
| 695 | - ), |
|
| 696 | - 'EventEspresso\core\domain\services\pue\StatsGatherer' => array( |
|
| 697 | - 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache, |
|
| 698 | - 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
| 699 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
| 700 | - 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
| 701 | - 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
| 702 | - 'EEM_Transaction' => EE_Dependency_Map::load_from_cache, |
|
| 703 | - 'EE_Config' => EE_Dependency_Map::load_from_cache |
|
| 704 | - ), |
|
| 705 | - 'EventEspresso\core\domain\services\admin\ExitModal' => array( |
|
| 706 | - 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache |
|
| 707 | - ), |
|
| 708 | - 'EventEspresso\core\domain\services\admin\PluginUpsells' => array( |
|
| 709 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache |
|
| 710 | - ), |
|
| 711 | - 'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha' => array( |
|
| 712 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
| 713 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
| 714 | - ), |
|
| 715 | - 'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings' => array( |
|
| 716 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
| 717 | - ), |
|
| 718 | - 'EventEspresso\modules\ticket_selector\ProcessTicketSelector' => array( |
|
| 719 | - 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
| 720 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 721 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
| 722 | - 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
| 723 | - 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache, |
|
| 724 | - ), |
|
| 725 | - 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => array( |
|
| 726 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
| 727 | - ), |
|
| 728 | - ); |
|
| 729 | - } |
|
| 730 | - |
|
| 731 | - |
|
| 732 | - |
|
| 733 | - /** |
|
| 734 | - * Registers how core classes are loaded. |
|
| 735 | - * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
|
| 736 | - * 'EE_Request_Handler' => 'load_core' |
|
| 737 | - * 'EE_Messages_Queue' => 'load_lib' |
|
| 738 | - * 'EEH_Debug_Tools' => 'load_helper' |
|
| 739 | - * or, if greater control is required, by providing a custom closure. For example: |
|
| 740 | - * 'Some_Class' => function () { |
|
| 741 | - * return new Some_Class(); |
|
| 742 | - * }, |
|
| 743 | - * This is required for instantiating dependencies |
|
| 744 | - * where an interface has been type hinted in a class constructor. For example: |
|
| 745 | - * 'Required_Interface' => function () { |
|
| 746 | - * return new A_Class_That_Implements_Required_Interface(); |
|
| 747 | - * }, |
|
| 748 | - * |
|
| 749 | - * @throws InvalidInterfaceException |
|
| 750 | - * @throws InvalidDataTypeException |
|
| 751 | - * @throws InvalidArgumentException |
|
| 752 | - */ |
|
| 753 | - protected function _register_core_class_loaders() |
|
| 754 | - { |
|
| 755 | - //for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot |
|
| 756 | - //be used in a closure. |
|
| 757 | - $request = &$this->request; |
|
| 758 | - $response = &$this->response; |
|
| 759 | - $legacy_request = &$this->legacy_request; |
|
| 760 | - // $loader = &$this->loader; |
|
| 761 | - $this->_class_loaders = array( |
|
| 762 | - //load_core |
|
| 763 | - 'EE_Capabilities' => 'load_core', |
|
| 764 | - 'EE_Encryption' => 'load_core', |
|
| 765 | - 'EE_Front_Controller' => 'load_core', |
|
| 766 | - 'EE_Module_Request_Router' => 'load_core', |
|
| 767 | - 'EE_Registry' => 'load_core', |
|
| 768 | - 'EE_Request' => function () use (&$legacy_request) { |
|
| 769 | - return $legacy_request; |
|
| 770 | - }, |
|
| 771 | - 'EventEspresso\core\services\request\Request' => function () use (&$request) { |
|
| 772 | - return $request; |
|
| 773 | - }, |
|
| 774 | - 'EventEspresso\core\services\request\Response' => function () use (&$response) { |
|
| 775 | - return $response; |
|
| 776 | - }, |
|
| 777 | - 'EE_Request_Handler' => 'load_core', |
|
| 778 | - 'EE_Session' => 'load_core', |
|
| 779 | - 'EE_Cron_Tasks' => 'load_core', |
|
| 780 | - 'EE_System' => 'load_core', |
|
| 781 | - 'EE_Maintenance_Mode' => 'load_core', |
|
| 782 | - 'EE_Register_CPTs' => 'load_core', |
|
| 783 | - 'EE_Admin' => 'load_core', |
|
| 784 | - //load_lib |
|
| 785 | - 'EE_Message_Resource_Manager' => 'load_lib', |
|
| 786 | - 'EE_Message_Type_Collection' => 'load_lib', |
|
| 787 | - 'EE_Message_Type_Collection_Loader' => 'load_lib', |
|
| 788 | - 'EE_Messenger_Collection' => 'load_lib', |
|
| 789 | - 'EE_Messenger_Collection_Loader' => 'load_lib', |
|
| 790 | - 'EE_Messages_Processor' => 'load_lib', |
|
| 791 | - 'EE_Message_Repository' => 'load_lib', |
|
| 792 | - 'EE_Messages_Queue' => 'load_lib', |
|
| 793 | - 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
|
| 794 | - 'EE_Message_Template_Group_Collection' => 'load_lib', |
|
| 795 | - 'EE_Payment_Method_Manager' => 'load_lib', |
|
| 796 | - 'EE_Messages_Generator' => function () { |
|
| 797 | - return EE_Registry::instance()->load_lib( |
|
| 798 | - 'Messages_Generator', |
|
| 799 | - array(), |
|
| 800 | - false, |
|
| 801 | - false |
|
| 802 | - ); |
|
| 803 | - }, |
|
| 804 | - 'EE_Messages_Template_Defaults' => function ($arguments = array()) { |
|
| 805 | - return EE_Registry::instance()->load_lib( |
|
| 806 | - 'Messages_Template_Defaults', |
|
| 807 | - $arguments, |
|
| 808 | - false, |
|
| 809 | - false |
|
| 810 | - ); |
|
| 811 | - }, |
|
| 812 | - //load_helper |
|
| 813 | - 'EEH_Parse_Shortcodes' => function () { |
|
| 814 | - if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
| 815 | - return new EEH_Parse_Shortcodes(); |
|
| 816 | - } |
|
| 817 | - return null; |
|
| 818 | - }, |
|
| 819 | - 'EE_Template_Config' => function () { |
|
| 820 | - return EE_Config::instance()->template_settings; |
|
| 821 | - }, |
|
| 822 | - 'EE_Currency_Config' => function () { |
|
| 823 | - return EE_Config::instance()->currency; |
|
| 824 | - }, |
|
| 825 | - 'EE_Registration_Config' => function () { |
|
| 826 | - return EE_Config::instance()->registration; |
|
| 827 | - }, |
|
| 828 | - 'EE_Core_Config' => function () { |
|
| 829 | - return EE_Config::instance()->core; |
|
| 830 | - }, |
|
| 831 | - 'EventEspresso\core\services\loaders\Loader' => function () { |
|
| 832 | - return LoaderFactory::getLoader(); |
|
| 833 | - }, |
|
| 834 | - 'EE_Network_Config' => function() { |
|
| 835 | - return EE_Network_Config::instance(); |
|
| 836 | - }, |
|
| 837 | - 'EE_Config' => function () { |
|
| 838 | - return EE_Config::instance(); |
|
| 839 | - } |
|
| 840 | - ); |
|
| 841 | - } |
|
| 842 | - |
|
| 843 | - |
|
| 844 | - |
|
| 845 | - /** |
|
| 846 | - * can be used for supplying alternate names for classes, |
|
| 847 | - * or for connecting interface names to instantiable classes |
|
| 848 | - */ |
|
| 849 | - protected function _register_core_aliases() |
|
| 850 | - { |
|
| 851 | - $this->_aliases = array( |
|
| 852 | - 'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
|
| 853 | - 'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
|
| 854 | - 'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
| 855 | - 'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
| 856 | - 'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
|
| 857 | - 'AddActionHook' => 'EventEspresso\core\services\commands\middleware\AddActionHook', |
|
| 858 | - 'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
| 859 | - 'CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface', |
|
| 860 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
| 861 | - 'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
|
| 862 | - 'CreateRegCodeCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegCodeCommand', |
|
| 863 | - 'CreateRegUrlLinkCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegUrlLinkCommand', |
|
| 864 | - 'CreateRegistrationCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
| 865 | - 'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand', |
|
| 866 | - 'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand', |
|
| 867 | - 'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
|
| 868 | - 'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
|
| 869 | - 'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand', |
|
| 870 | - 'CreateTransactionCommandHandler' => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler', |
|
| 871 | - 'CreateAttendeeCommandHandler' => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler', |
|
| 872 | - 'TableManager' => 'EventEspresso\core\services\database\TableManager', |
|
| 873 | - 'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
|
| 874 | - 'EspressoShortcode' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
| 875 | - 'ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
| 876 | - 'EventEspresso\core\services\shortcodes\ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
| 877 | - 'EventEspresso\core\services\cache\CacheStorageInterface' => 'EventEspresso\core\services\cache\TransientCacheStorage', |
|
| 878 | - 'LoaderInterface' => 'EventEspresso\core\services\loaders\LoaderInterface', |
|
| 879 | - 'EventEspresso\core\services\loaders\LoaderInterface' => 'EventEspresso\core\services\loaders\Loader', |
|
| 880 | - 'CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactoryInterface', |
|
| 881 | - 'EventEspresso\core\services\commands\CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactory', |
|
| 882 | - 'EventEspresso\core\domain\services\session\SessionIdentifierInterface' => 'EE_Session', |
|
| 883 | - 'EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface', |
|
| 884 | - 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService', |
|
| 885 | - 'NoticeConverterInterface' => 'EventEspresso\core\services\notices\NoticeConverterInterface', |
|
| 886 | - 'EventEspresso\core\services\notices\NoticeConverterInterface' => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors', |
|
| 887 | - 'NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainerInterface', |
|
| 888 | - 'EventEspresso\core\services\notices\NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainer', |
|
| 889 | - 'EventEspresso\core\services\request\RequestInterface' => 'EventEspresso\core\services\request\Request', |
|
| 890 | - 'EventEspresso\core\services\request\ResponseInterface' => 'EventEspresso\core\services\request\Response', |
|
| 891 | - 'EventEspresso\core\domain\DomainInterface' => 'EventEspresso\core\domain\Domain', |
|
| 892 | - ); |
|
| 893 | - if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
| 894 | - $this->_aliases['EventEspresso\core\services\notices\NoticeConverterInterface'] = 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices'; |
|
| 895 | - } |
|
| 896 | - } |
|
| 897 | - |
|
| 898 | - |
|
| 899 | - |
|
| 900 | - /** |
|
| 901 | - * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
|
| 902 | - * request Primarily used by unit tests. |
|
| 903 | - * |
|
| 904 | - * @throws InvalidDataTypeException |
|
| 905 | - * @throws InvalidInterfaceException |
|
| 906 | - * @throws InvalidArgumentException |
|
| 907 | - */ |
|
| 908 | - public function reset() |
|
| 909 | - { |
|
| 910 | - $this->_register_core_class_loaders(); |
|
| 911 | - $this->_register_core_dependencies(); |
|
| 912 | - } |
|
| 684 | + null, |
|
| 685 | + 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache, |
|
| 686 | + ), |
|
| 687 | + 'EventEspresso\core\domain\services\pue\Stats' => array( |
|
| 688 | + 'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache, |
|
| 689 | + 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
| 690 | + 'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache |
|
| 691 | + ), |
|
| 692 | + 'EventEspresso\core\domain\services\pue\Config' => array( |
|
| 693 | + 'EE_Network_Config' => EE_Dependency_Map::load_from_cache, |
|
| 694 | + 'EE_Config' => EE_Dependency_Map::load_from_cache |
|
| 695 | + ), |
|
| 696 | + 'EventEspresso\core\domain\services\pue\StatsGatherer' => array( |
|
| 697 | + 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache, |
|
| 698 | + 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
| 699 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
| 700 | + 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
| 701 | + 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
| 702 | + 'EEM_Transaction' => EE_Dependency_Map::load_from_cache, |
|
| 703 | + 'EE_Config' => EE_Dependency_Map::load_from_cache |
|
| 704 | + ), |
|
| 705 | + 'EventEspresso\core\domain\services\admin\ExitModal' => array( |
|
| 706 | + 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache |
|
| 707 | + ), |
|
| 708 | + 'EventEspresso\core\domain\services\admin\PluginUpsells' => array( |
|
| 709 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache |
|
| 710 | + ), |
|
| 711 | + 'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha' => array( |
|
| 712 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
| 713 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
| 714 | + ), |
|
| 715 | + 'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings' => array( |
|
| 716 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
| 717 | + ), |
|
| 718 | + 'EventEspresso\modules\ticket_selector\ProcessTicketSelector' => array( |
|
| 719 | + 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
| 720 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 721 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
| 722 | + 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
| 723 | + 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache, |
|
| 724 | + ), |
|
| 725 | + 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => array( |
|
| 726 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
| 727 | + ), |
|
| 728 | + ); |
|
| 729 | + } |
|
| 730 | + |
|
| 731 | + |
|
| 732 | + |
|
| 733 | + /** |
|
| 734 | + * Registers how core classes are loaded. |
|
| 735 | + * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
|
| 736 | + * 'EE_Request_Handler' => 'load_core' |
|
| 737 | + * 'EE_Messages_Queue' => 'load_lib' |
|
| 738 | + * 'EEH_Debug_Tools' => 'load_helper' |
|
| 739 | + * or, if greater control is required, by providing a custom closure. For example: |
|
| 740 | + * 'Some_Class' => function () { |
|
| 741 | + * return new Some_Class(); |
|
| 742 | + * }, |
|
| 743 | + * This is required for instantiating dependencies |
|
| 744 | + * where an interface has been type hinted in a class constructor. For example: |
|
| 745 | + * 'Required_Interface' => function () { |
|
| 746 | + * return new A_Class_That_Implements_Required_Interface(); |
|
| 747 | + * }, |
|
| 748 | + * |
|
| 749 | + * @throws InvalidInterfaceException |
|
| 750 | + * @throws InvalidDataTypeException |
|
| 751 | + * @throws InvalidArgumentException |
|
| 752 | + */ |
|
| 753 | + protected function _register_core_class_loaders() |
|
| 754 | + { |
|
| 755 | + //for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot |
|
| 756 | + //be used in a closure. |
|
| 757 | + $request = &$this->request; |
|
| 758 | + $response = &$this->response; |
|
| 759 | + $legacy_request = &$this->legacy_request; |
|
| 760 | + // $loader = &$this->loader; |
|
| 761 | + $this->_class_loaders = array( |
|
| 762 | + //load_core |
|
| 763 | + 'EE_Capabilities' => 'load_core', |
|
| 764 | + 'EE_Encryption' => 'load_core', |
|
| 765 | + 'EE_Front_Controller' => 'load_core', |
|
| 766 | + 'EE_Module_Request_Router' => 'load_core', |
|
| 767 | + 'EE_Registry' => 'load_core', |
|
| 768 | + 'EE_Request' => function () use (&$legacy_request) { |
|
| 769 | + return $legacy_request; |
|
| 770 | + }, |
|
| 771 | + 'EventEspresso\core\services\request\Request' => function () use (&$request) { |
|
| 772 | + return $request; |
|
| 773 | + }, |
|
| 774 | + 'EventEspresso\core\services\request\Response' => function () use (&$response) { |
|
| 775 | + return $response; |
|
| 776 | + }, |
|
| 777 | + 'EE_Request_Handler' => 'load_core', |
|
| 778 | + 'EE_Session' => 'load_core', |
|
| 779 | + 'EE_Cron_Tasks' => 'load_core', |
|
| 780 | + 'EE_System' => 'load_core', |
|
| 781 | + 'EE_Maintenance_Mode' => 'load_core', |
|
| 782 | + 'EE_Register_CPTs' => 'load_core', |
|
| 783 | + 'EE_Admin' => 'load_core', |
|
| 784 | + //load_lib |
|
| 785 | + 'EE_Message_Resource_Manager' => 'load_lib', |
|
| 786 | + 'EE_Message_Type_Collection' => 'load_lib', |
|
| 787 | + 'EE_Message_Type_Collection_Loader' => 'load_lib', |
|
| 788 | + 'EE_Messenger_Collection' => 'load_lib', |
|
| 789 | + 'EE_Messenger_Collection_Loader' => 'load_lib', |
|
| 790 | + 'EE_Messages_Processor' => 'load_lib', |
|
| 791 | + 'EE_Message_Repository' => 'load_lib', |
|
| 792 | + 'EE_Messages_Queue' => 'load_lib', |
|
| 793 | + 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
|
| 794 | + 'EE_Message_Template_Group_Collection' => 'load_lib', |
|
| 795 | + 'EE_Payment_Method_Manager' => 'load_lib', |
|
| 796 | + 'EE_Messages_Generator' => function () { |
|
| 797 | + return EE_Registry::instance()->load_lib( |
|
| 798 | + 'Messages_Generator', |
|
| 799 | + array(), |
|
| 800 | + false, |
|
| 801 | + false |
|
| 802 | + ); |
|
| 803 | + }, |
|
| 804 | + 'EE_Messages_Template_Defaults' => function ($arguments = array()) { |
|
| 805 | + return EE_Registry::instance()->load_lib( |
|
| 806 | + 'Messages_Template_Defaults', |
|
| 807 | + $arguments, |
|
| 808 | + false, |
|
| 809 | + false |
|
| 810 | + ); |
|
| 811 | + }, |
|
| 812 | + //load_helper |
|
| 813 | + 'EEH_Parse_Shortcodes' => function () { |
|
| 814 | + if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
| 815 | + return new EEH_Parse_Shortcodes(); |
|
| 816 | + } |
|
| 817 | + return null; |
|
| 818 | + }, |
|
| 819 | + 'EE_Template_Config' => function () { |
|
| 820 | + return EE_Config::instance()->template_settings; |
|
| 821 | + }, |
|
| 822 | + 'EE_Currency_Config' => function () { |
|
| 823 | + return EE_Config::instance()->currency; |
|
| 824 | + }, |
|
| 825 | + 'EE_Registration_Config' => function () { |
|
| 826 | + return EE_Config::instance()->registration; |
|
| 827 | + }, |
|
| 828 | + 'EE_Core_Config' => function () { |
|
| 829 | + return EE_Config::instance()->core; |
|
| 830 | + }, |
|
| 831 | + 'EventEspresso\core\services\loaders\Loader' => function () { |
|
| 832 | + return LoaderFactory::getLoader(); |
|
| 833 | + }, |
|
| 834 | + 'EE_Network_Config' => function() { |
|
| 835 | + return EE_Network_Config::instance(); |
|
| 836 | + }, |
|
| 837 | + 'EE_Config' => function () { |
|
| 838 | + return EE_Config::instance(); |
|
| 839 | + } |
|
| 840 | + ); |
|
| 841 | + } |
|
| 842 | + |
|
| 843 | + |
|
| 844 | + |
|
| 845 | + /** |
|
| 846 | + * can be used for supplying alternate names for classes, |
|
| 847 | + * or for connecting interface names to instantiable classes |
|
| 848 | + */ |
|
| 849 | + protected function _register_core_aliases() |
|
| 850 | + { |
|
| 851 | + $this->_aliases = array( |
|
| 852 | + 'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
|
| 853 | + 'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
|
| 854 | + 'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
| 855 | + 'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
| 856 | + 'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
|
| 857 | + 'AddActionHook' => 'EventEspresso\core\services\commands\middleware\AddActionHook', |
|
| 858 | + 'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
| 859 | + 'CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface', |
|
| 860 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
| 861 | + 'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
|
| 862 | + 'CreateRegCodeCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegCodeCommand', |
|
| 863 | + 'CreateRegUrlLinkCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegUrlLinkCommand', |
|
| 864 | + 'CreateRegistrationCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
| 865 | + 'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand', |
|
| 866 | + 'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand', |
|
| 867 | + 'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
|
| 868 | + 'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
|
| 869 | + 'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand', |
|
| 870 | + 'CreateTransactionCommandHandler' => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler', |
|
| 871 | + 'CreateAttendeeCommandHandler' => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler', |
|
| 872 | + 'TableManager' => 'EventEspresso\core\services\database\TableManager', |
|
| 873 | + 'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
|
| 874 | + 'EspressoShortcode' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
| 875 | + 'ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
| 876 | + 'EventEspresso\core\services\shortcodes\ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
| 877 | + 'EventEspresso\core\services\cache\CacheStorageInterface' => 'EventEspresso\core\services\cache\TransientCacheStorage', |
|
| 878 | + 'LoaderInterface' => 'EventEspresso\core\services\loaders\LoaderInterface', |
|
| 879 | + 'EventEspresso\core\services\loaders\LoaderInterface' => 'EventEspresso\core\services\loaders\Loader', |
|
| 880 | + 'CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactoryInterface', |
|
| 881 | + 'EventEspresso\core\services\commands\CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactory', |
|
| 882 | + 'EventEspresso\core\domain\services\session\SessionIdentifierInterface' => 'EE_Session', |
|
| 883 | + 'EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface', |
|
| 884 | + 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService', |
|
| 885 | + 'NoticeConverterInterface' => 'EventEspresso\core\services\notices\NoticeConverterInterface', |
|
| 886 | + 'EventEspresso\core\services\notices\NoticeConverterInterface' => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors', |
|
| 887 | + 'NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainerInterface', |
|
| 888 | + 'EventEspresso\core\services\notices\NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainer', |
|
| 889 | + 'EventEspresso\core\services\request\RequestInterface' => 'EventEspresso\core\services\request\Request', |
|
| 890 | + 'EventEspresso\core\services\request\ResponseInterface' => 'EventEspresso\core\services\request\Response', |
|
| 891 | + 'EventEspresso\core\domain\DomainInterface' => 'EventEspresso\core\domain\Domain', |
|
| 892 | + ); |
|
| 893 | + if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
| 894 | + $this->_aliases['EventEspresso\core\services\notices\NoticeConverterInterface'] = 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices'; |
|
| 895 | + } |
|
| 896 | + } |
|
| 897 | + |
|
| 898 | + |
|
| 899 | + |
|
| 900 | + /** |
|
| 901 | + * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
|
| 902 | + * request Primarily used by unit tests. |
|
| 903 | + * |
|
| 904 | + * @throws InvalidDataTypeException |
|
| 905 | + * @throws InvalidInterfaceException |
|
| 906 | + * @throws InvalidArgumentException |
|
| 907 | + */ |
|
| 908 | + public function reset() |
|
| 909 | + { |
|
| 910 | + $this->_register_core_class_loaders(); |
|
| 911 | + $this->_register_core_dependencies(); |
|
| 912 | + } |
|
| 913 | 913 | |
| 914 | 914 | |
| 915 | 915 | } |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | use EventEspresso\core\services\request\RequestInterface; |
| 8 | 8 | use EventEspresso\core\services\request\ResponseInterface; |
| 9 | 9 | |
| 10 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 10 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 11 | 11 | exit('No direct script access allowed'); |
| 12 | 12 | } |
| 13 | 13 | |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | */ |
| 130 | 130 | public static function instance() { |
| 131 | 131 | // check if class object is instantiated, and instantiated properly |
| 132 | - if (! self::$_instance instanceof EE_Dependency_Map) { |
|
| 132 | + if ( ! self::$_instance instanceof EE_Dependency_Map) { |
|
| 133 | 133 | self::$_instance = new EE_Dependency_Map(/*$request, $response, $legacy_request*/); |
| 134 | 134 | } |
| 135 | 135 | return self::$_instance; |
@@ -211,8 +211,8 @@ discard block |
||
| 211 | 211 | ) { |
| 212 | 212 | $class = trim($class, '\\'); |
| 213 | 213 | $registered = false; |
| 214 | - if (empty(self::$_instance->_dependency_map[ $class ])) { |
|
| 215 | - self::$_instance->_dependency_map[ $class ] = array(); |
|
| 214 | + if (empty(self::$_instance->_dependency_map[$class])) { |
|
| 215 | + self::$_instance->_dependency_map[$class] = array(); |
|
| 216 | 216 | } |
| 217 | 217 | // we need to make sure that any aliases used when registering a dependency |
| 218 | 218 | // get resolved to the correct class name |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | $alias = self::$_instance->get_alias($dependency); |
| 221 | 221 | if ( |
| 222 | 222 | $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
| 223 | - || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ]) |
|
| 223 | + || ! isset(self::$_instance->_dependency_map[$class][$alias]) |
|
| 224 | 224 | ) { |
| 225 | 225 | unset($dependencies[$dependency]); |
| 226 | 226 | $dependencies[$alias] = $load_source; |
@@ -233,13 +233,13 @@ discard block |
||
| 233 | 233 | // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
| 234 | 234 | // Union is way faster than array_merge() but should be used with caution... |
| 235 | 235 | // especially with numerically indexed arrays |
| 236 | - $dependencies += self::$_instance->_dependency_map[ $class ]; |
|
| 236 | + $dependencies += self::$_instance->_dependency_map[$class]; |
|
| 237 | 237 | // now we need to ensure that the resulting dependencies |
| 238 | 238 | // array only has the entries that are required for the class |
| 239 | 239 | // so first count how many dependencies were originally registered for the class |
| 240 | - $dependency_count = count(self::$_instance->_dependency_map[ $class ]); |
|
| 240 | + $dependency_count = count(self::$_instance->_dependency_map[$class]); |
|
| 241 | 241 | // if that count is non-zero (meaning dependencies were already registered) |
| 242 | - self::$_instance->_dependency_map[ $class ] = $dependency_count |
|
| 242 | + self::$_instance->_dependency_map[$class] = $dependency_count |
|
| 243 | 243 | // then truncate the final array to match that count |
| 244 | 244 | ? array_slice($dependencies, 0, $dependency_count) |
| 245 | 245 | // otherwise just take the incoming array because nothing previously existed |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | */ |
| 258 | 258 | public static function register_class_loader($class_name, $loader = 'load_core') |
| 259 | 259 | { |
| 260 | - if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
| 260 | + if ( ! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
| 261 | 261 | throw new DomainException( |
| 262 | 262 | esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
| 263 | 263 | ); |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | ); |
| 282 | 282 | } |
| 283 | 283 | $class_name = self::$_instance->get_alias($class_name); |
| 284 | - if (! isset(self::$_instance->_class_loaders[$class_name])) { |
|
| 284 | + if ( ! isset(self::$_instance->_class_loaders[$class_name])) { |
|
| 285 | 285 | self::$_instance->_class_loaders[$class_name] = $loader; |
| 286 | 286 | return true; |
| 287 | 287 | } |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | public function class_loader($class_name) |
| 367 | 367 | { |
| 368 | 368 | // all legacy models use load_model() |
| 369 | - if(strpos($class_name, 'EEM_') === 0){ |
|
| 369 | + if (strpos($class_name, 'EEM_') === 0) { |
|
| 370 | 370 | return 'load_model'; |
| 371 | 371 | } |
| 372 | 372 | $class_name = $this->get_alias($class_name); |
@@ -395,7 +395,7 @@ discard block |
||
| 395 | 395 | public function add_alias($class_name, $alias, $for_class = '') |
| 396 | 396 | { |
| 397 | 397 | if ($for_class !== '') { |
| 398 | - if (! isset($this->_aliases[$for_class])) { |
|
| 398 | + if ( ! isset($this->_aliases[$for_class])) { |
|
| 399 | 399 | $this->_aliases[$for_class] = array(); |
| 400 | 400 | } |
| 401 | 401 | $this->_aliases[$for_class][$class_name] = $alias; |
@@ -441,10 +441,10 @@ discard block |
||
| 441 | 441 | */ |
| 442 | 442 | public function get_alias($class_name = '', $for_class = '') |
| 443 | 443 | { |
| 444 | - if (! $this->has_alias($class_name, $for_class)) { |
|
| 444 | + if ( ! $this->has_alias($class_name, $for_class)) { |
|
| 445 | 445 | return $class_name; |
| 446 | 446 | } |
| 447 | - if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) { |
|
| 447 | + if ($for_class !== '' && isset($this->_aliases[$for_class][$class_name])) { |
|
| 448 | 448 | return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class); |
| 449 | 449 | } |
| 450 | 450 | return $this->get_alias($this->_aliases[$class_name]); |
@@ -765,13 +765,13 @@ discard block |
||
| 765 | 765 | 'EE_Front_Controller' => 'load_core', |
| 766 | 766 | 'EE_Module_Request_Router' => 'load_core', |
| 767 | 767 | 'EE_Registry' => 'load_core', |
| 768 | - 'EE_Request' => function () use (&$legacy_request) { |
|
| 768 | + 'EE_Request' => function() use (&$legacy_request) { |
|
| 769 | 769 | return $legacy_request; |
| 770 | 770 | }, |
| 771 | - 'EventEspresso\core\services\request\Request' => function () use (&$request) { |
|
| 771 | + 'EventEspresso\core\services\request\Request' => function() use (&$request) { |
|
| 772 | 772 | return $request; |
| 773 | 773 | }, |
| 774 | - 'EventEspresso\core\services\request\Response' => function () use (&$response) { |
|
| 774 | + 'EventEspresso\core\services\request\Response' => function() use (&$response) { |
|
| 775 | 775 | return $response; |
| 776 | 776 | }, |
| 777 | 777 | 'EE_Request_Handler' => 'load_core', |
@@ -793,7 +793,7 @@ discard block |
||
| 793 | 793 | 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
| 794 | 794 | 'EE_Message_Template_Group_Collection' => 'load_lib', |
| 795 | 795 | 'EE_Payment_Method_Manager' => 'load_lib', |
| 796 | - 'EE_Messages_Generator' => function () { |
|
| 796 | + 'EE_Messages_Generator' => function() { |
|
| 797 | 797 | return EE_Registry::instance()->load_lib( |
| 798 | 798 | 'Messages_Generator', |
| 799 | 799 | array(), |
@@ -801,7 +801,7 @@ discard block |
||
| 801 | 801 | false |
| 802 | 802 | ); |
| 803 | 803 | }, |
| 804 | - 'EE_Messages_Template_Defaults' => function ($arguments = array()) { |
|
| 804 | + 'EE_Messages_Template_Defaults' => function($arguments = array()) { |
|
| 805 | 805 | return EE_Registry::instance()->load_lib( |
| 806 | 806 | 'Messages_Template_Defaults', |
| 807 | 807 | $arguments, |
@@ -810,31 +810,31 @@ discard block |
||
| 810 | 810 | ); |
| 811 | 811 | }, |
| 812 | 812 | //load_helper |
| 813 | - 'EEH_Parse_Shortcodes' => function () { |
|
| 813 | + 'EEH_Parse_Shortcodes' => function() { |
|
| 814 | 814 | if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
| 815 | 815 | return new EEH_Parse_Shortcodes(); |
| 816 | 816 | } |
| 817 | 817 | return null; |
| 818 | 818 | }, |
| 819 | - 'EE_Template_Config' => function () { |
|
| 819 | + 'EE_Template_Config' => function() { |
|
| 820 | 820 | return EE_Config::instance()->template_settings; |
| 821 | 821 | }, |
| 822 | - 'EE_Currency_Config' => function () { |
|
| 822 | + 'EE_Currency_Config' => function() { |
|
| 823 | 823 | return EE_Config::instance()->currency; |
| 824 | 824 | }, |
| 825 | - 'EE_Registration_Config' => function () { |
|
| 825 | + 'EE_Registration_Config' => function() { |
|
| 826 | 826 | return EE_Config::instance()->registration; |
| 827 | 827 | }, |
| 828 | - 'EE_Core_Config' => function () { |
|
| 828 | + 'EE_Core_Config' => function() { |
|
| 829 | 829 | return EE_Config::instance()->core; |
| 830 | 830 | }, |
| 831 | - 'EventEspresso\core\services\loaders\Loader' => function () { |
|
| 831 | + 'EventEspresso\core\services\loaders\Loader' => function() { |
|
| 832 | 832 | return LoaderFactory::getLoader(); |
| 833 | 833 | }, |
| 834 | 834 | 'EE_Network_Config' => function() { |
| 835 | 835 | return EE_Network_Config::instance(); |
| 836 | 836 | }, |
| 837 | - 'EE_Config' => function () { |
|
| 837 | + 'EE_Config' => function() { |
|
| 838 | 838 | return EE_Config::instance(); |
| 839 | 839 | } |
| 840 | 840 | ); |
@@ -890,7 +890,7 @@ discard block |
||
| 890 | 890 | 'EventEspresso\core\services\request\ResponseInterface' => 'EventEspresso\core\services\request\Response', |
| 891 | 891 | 'EventEspresso\core\domain\DomainInterface' => 'EventEspresso\core\domain\Domain', |
| 892 | 892 | ); |
| 893 | - if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
| 893 | + if ( ! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
| 894 | 894 | $this->_aliases['EventEspresso\core\services\notices\NoticeConverterInterface'] = 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices'; |
| 895 | 895 | } |
| 896 | 896 | } |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | use EventEspresso\core\exceptions\InvalidEntityException; |
| 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 | |
@@ -20,1849 +20,1849 @@ discard block |
||
| 20 | 20 | class EED_Single_Page_Checkout extends EED_Module |
| 21 | 21 | { |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * $_initialized - has the SPCO controller already been initialized ? |
|
| 25 | - * |
|
| 26 | - * @access private |
|
| 27 | - * @var bool $_initialized |
|
| 28 | - */ |
|
| 29 | - private static $_initialized = false; |
|
| 30 | - |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * $_checkout_verified - is the EE_Checkout verified as correct for this request ? |
|
| 34 | - * |
|
| 35 | - * @access private |
|
| 36 | - * @var bool $_valid_checkout |
|
| 37 | - */ |
|
| 38 | - private static $_checkout_verified = true; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * $_reg_steps_array - holds initial array of reg steps |
|
| 42 | - * |
|
| 43 | - * @access private |
|
| 44 | - * @var array $_reg_steps_array |
|
| 45 | - */ |
|
| 46 | - private static $_reg_steps_array = array(); |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * $checkout - EE_Checkout object for handling the properties of the current checkout process |
|
| 50 | - * |
|
| 51 | - * @access public |
|
| 52 | - * @var EE_Checkout $checkout |
|
| 53 | - */ |
|
| 54 | - public $checkout; |
|
| 55 | - |
|
| 56 | - |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * @return EED_Module|EED_Single_Page_Checkout |
|
| 60 | - */ |
|
| 61 | - public static function instance() |
|
| 62 | - { |
|
| 63 | - add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true'); |
|
| 64 | - return parent::get_instance(__CLASS__); |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * @return EE_CART |
|
| 71 | - */ |
|
| 72 | - public function cart() |
|
| 73 | - { |
|
| 74 | - return $this->checkout->cart; |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * @return EE_Transaction |
|
| 81 | - */ |
|
| 82 | - public function transaction() |
|
| 83 | - { |
|
| 84 | - return $this->checkout->transaction; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
| 91 | - * |
|
| 92 | - * @access public |
|
| 93 | - * @return void |
|
| 94 | - * @throws EE_Error |
|
| 95 | - */ |
|
| 96 | - public static function set_hooks() |
|
| 97 | - { |
|
| 98 | - EED_Single_Page_Checkout::set_definitions(); |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
| 105 | - * |
|
| 106 | - * @access public |
|
| 107 | - * @return void |
|
| 108 | - * @throws EE_Error |
|
| 109 | - */ |
|
| 110 | - public static function set_hooks_admin() |
|
| 111 | - { |
|
| 112 | - EED_Single_Page_Checkout::set_definitions(); |
|
| 113 | - if ( ! (defined('DOING_AJAX') && DOING_AJAX)) { |
|
| 114 | - return; |
|
| 115 | - } |
|
| 116 | - // going to start an output buffer in case anything gets accidentally output |
|
| 117 | - // that might disrupt our JSON response |
|
| 118 | - ob_start(); |
|
| 119 | - EED_Single_Page_Checkout::load_request_handler(); |
|
| 120 | - EED_Single_Page_Checkout::load_reg_steps(); |
|
| 121 | - // set ajax hooks |
|
| 122 | - add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
| 123 | - add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
| 124 | - add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
| 125 | - add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
| 126 | - add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
| 127 | - add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * process ajax request |
|
| 134 | - * |
|
| 135 | - * @param string $ajax_action |
|
| 136 | - * @throws EE_Error |
|
| 137 | - */ |
|
| 138 | - public static function process_ajax_request($ajax_action) |
|
| 139 | - { |
|
| 140 | - EE_Registry::instance()->REQ->set('action', $ajax_action); |
|
| 141 | - EED_Single_Page_Checkout::instance()->_initialize(); |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - |
|
| 145 | - |
|
| 146 | - /** |
|
| 147 | - * ajax display registration step |
|
| 148 | - * |
|
| 149 | - * @throws EE_Error |
|
| 150 | - */ |
|
| 151 | - public static function display_reg_step() |
|
| 152 | - { |
|
| 153 | - EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step'); |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - |
|
| 157 | - |
|
| 158 | - /** |
|
| 159 | - * ajax process registration step |
|
| 160 | - * |
|
| 161 | - * @throws EE_Error |
|
| 162 | - */ |
|
| 163 | - public static function process_reg_step() |
|
| 164 | - { |
|
| 165 | - EED_Single_Page_Checkout::process_ajax_request('process_reg_step'); |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - |
|
| 169 | - |
|
| 170 | - /** |
|
| 171 | - * ajax process registration step |
|
| 172 | - * |
|
| 173 | - * @throws EE_Error |
|
| 174 | - */ |
|
| 175 | - public static function update_reg_step() |
|
| 176 | - { |
|
| 177 | - EED_Single_Page_Checkout::process_ajax_request('update_reg_step'); |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - |
|
| 181 | - |
|
| 182 | - /** |
|
| 183 | - * update_checkout |
|
| 184 | - * |
|
| 185 | - * @access public |
|
| 186 | - * @return void |
|
| 187 | - * @throws EE_Error |
|
| 188 | - */ |
|
| 189 | - public static function update_checkout() |
|
| 190 | - { |
|
| 191 | - EED_Single_Page_Checkout::process_ajax_request('update_checkout'); |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - |
|
| 195 | - |
|
| 196 | - /** |
|
| 197 | - * load_request_handler |
|
| 198 | - * |
|
| 199 | - * @access public |
|
| 200 | - * @return void |
|
| 201 | - */ |
|
| 202 | - public static function load_request_handler() |
|
| 203 | - { |
|
| 204 | - // load core Request_Handler class |
|
| 205 | - if (EE_Registry::instance()->REQ !== null) { |
|
| 206 | - EE_Registry::instance()->load_core('Request_Handler'); |
|
| 207 | - } |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - |
|
| 211 | - |
|
| 212 | - /** |
|
| 213 | - * set_definitions |
|
| 214 | - * |
|
| 215 | - * @access public |
|
| 216 | - * @return void |
|
| 217 | - * @throws EE_Error |
|
| 218 | - */ |
|
| 219 | - public static function set_definitions() |
|
| 220 | - { |
|
| 221 | - if(defined('SPCO_BASE_PATH')) { |
|
| 222 | - return; |
|
| 223 | - } |
|
| 224 | - define( |
|
| 225 | - 'SPCO_BASE_PATH', |
|
| 226 | - rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS) . DS |
|
| 227 | - ); |
|
| 228 | - define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css' . DS); |
|
| 229 | - define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img' . DS); |
|
| 230 | - define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js' . DS); |
|
| 231 | - define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS); |
|
| 232 | - define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS); |
|
| 233 | - define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS); |
|
| 234 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true); |
|
| 235 | - EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice(); |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - |
|
| 239 | - |
|
| 240 | - /** |
|
| 241 | - * load_reg_steps |
|
| 242 | - * loads and instantiates each reg step based on the EE_Registry::instance()->CFG->registration->reg_steps array |
|
| 243 | - * |
|
| 244 | - * @access private |
|
| 245 | - * @throws EE_Error |
|
| 246 | - */ |
|
| 247 | - public static function load_reg_steps() |
|
| 248 | - { |
|
| 249 | - static $reg_steps_loaded = false; |
|
| 250 | - if ($reg_steps_loaded) { |
|
| 251 | - return; |
|
| 252 | - } |
|
| 253 | - // filter list of reg_steps |
|
| 254 | - $reg_steps_to_load = (array)apply_filters( |
|
| 255 | - 'AHEE__SPCO__load_reg_steps__reg_steps_to_load', |
|
| 256 | - EED_Single_Page_Checkout::get_reg_steps() |
|
| 257 | - ); |
|
| 258 | - // sort by key (order) |
|
| 259 | - ksort($reg_steps_to_load); |
|
| 260 | - // loop through folders |
|
| 261 | - foreach ($reg_steps_to_load as $order => $reg_step) { |
|
| 262 | - // we need a |
|
| 263 | - if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
| 264 | - // copy over to the reg_steps_array |
|
| 265 | - EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step; |
|
| 266 | - // register custom key route for each reg step |
|
| 267 | - // ie: step=>"slug" - this is the entire reason we load the reg steps array now |
|
| 268 | - EE_Config::register_route( |
|
| 269 | - $reg_step['slug'], |
|
| 270 | - 'EED_Single_Page_Checkout', |
|
| 271 | - 'run', |
|
| 272 | - 'step' |
|
| 273 | - ); |
|
| 274 | - // add AJAX or other hooks |
|
| 275 | - if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) { |
|
| 276 | - // setup autoloaders if necessary |
|
| 277 | - if ( ! class_exists($reg_step['class_name'])) { |
|
| 278 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( |
|
| 279 | - $reg_step['file_path'], |
|
| 280 | - true |
|
| 281 | - ); |
|
| 282 | - } |
|
| 283 | - if (is_callable($reg_step['class_name'], 'set_hooks')) { |
|
| 284 | - call_user_func(array($reg_step['class_name'], 'set_hooks')); |
|
| 285 | - } |
|
| 286 | - } |
|
| 287 | - } |
|
| 288 | - } |
|
| 289 | - $reg_steps_loaded = true; |
|
| 290 | - } |
|
| 291 | - |
|
| 292 | - |
|
| 293 | - |
|
| 294 | - /** |
|
| 295 | - * get_reg_steps |
|
| 296 | - * |
|
| 297 | - * @access public |
|
| 298 | - * @return array |
|
| 299 | - */ |
|
| 300 | - public static function get_reg_steps() |
|
| 301 | - { |
|
| 302 | - $reg_steps = EE_Registry::instance()->CFG->registration->reg_steps; |
|
| 303 | - if (empty($reg_steps)) { |
|
| 304 | - $reg_steps = array( |
|
| 305 | - 10 => array( |
|
| 306 | - 'file_path' => SPCO_REG_STEPS_PATH . 'attendee_information', |
|
| 307 | - 'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information', |
|
| 308 | - 'slug' => 'attendee_information', |
|
| 309 | - 'has_hooks' => false, |
|
| 310 | - ), |
|
| 311 | - 20 => array( |
|
| 312 | - 'file_path' => SPCO_REG_STEPS_PATH . 'registration_confirmation', |
|
| 313 | - 'class_name' => 'EE_SPCO_Reg_Step_Registration_Confirmation', |
|
| 314 | - 'slug' => 'registration_confirmation', |
|
| 315 | - 'has_hooks' => false, |
|
| 316 | - ), |
|
| 317 | - 30 => array( |
|
| 318 | - 'file_path' => SPCO_REG_STEPS_PATH . 'payment_options', |
|
| 319 | - 'class_name' => 'EE_SPCO_Reg_Step_Payment_Options', |
|
| 320 | - 'slug' => 'payment_options', |
|
| 321 | - 'has_hooks' => true, |
|
| 322 | - ), |
|
| 323 | - 999 => array( |
|
| 324 | - 'file_path' => SPCO_REG_STEPS_PATH . 'finalize_registration', |
|
| 325 | - 'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration', |
|
| 326 | - 'slug' => 'finalize_registration', |
|
| 327 | - 'has_hooks' => false, |
|
| 328 | - ), |
|
| 329 | - ); |
|
| 330 | - } |
|
| 331 | - return $reg_steps; |
|
| 332 | - } |
|
| 333 | - |
|
| 334 | - |
|
| 335 | - |
|
| 336 | - /** |
|
| 337 | - * registration_checkout_for_admin |
|
| 338 | - * |
|
| 339 | - * @access public |
|
| 340 | - * @return string |
|
| 341 | - * @throws EE_Error |
|
| 342 | - */ |
|
| 343 | - public static function registration_checkout_for_admin() |
|
| 344 | - { |
|
| 345 | - EED_Single_Page_Checkout::load_request_handler(); |
|
| 346 | - EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
| 347 | - EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step'); |
|
| 348 | - EE_Registry::instance()->REQ->set('process_form_submission', false); |
|
| 349 | - EED_Single_Page_Checkout::instance()->_initialize(); |
|
| 350 | - EED_Single_Page_Checkout::instance()->_display_spco_reg_form(); |
|
| 351 | - return EE_Registry::instance()->REQ->get_output(); |
|
| 352 | - } |
|
| 353 | - |
|
| 354 | - |
|
| 355 | - |
|
| 356 | - /** |
|
| 357 | - * process_registration_from_admin |
|
| 358 | - * |
|
| 359 | - * @access public |
|
| 360 | - * @return \EE_Transaction |
|
| 361 | - * @throws EE_Error |
|
| 362 | - */ |
|
| 363 | - public static function process_registration_from_admin() |
|
| 364 | - { |
|
| 365 | - EED_Single_Page_Checkout::load_request_handler(); |
|
| 366 | - EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
| 367 | - EE_Registry::instance()->REQ->set('action', 'process_reg_step'); |
|
| 368 | - EE_Registry::instance()->REQ->set('process_form_submission', true); |
|
| 369 | - EED_Single_Page_Checkout::instance()->_initialize(); |
|
| 370 | - if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) { |
|
| 371 | - $final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps); |
|
| 372 | - if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) { |
|
| 373 | - EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step); |
|
| 374 | - if ($final_reg_step->process_reg_step()) { |
|
| 375 | - $final_reg_step->set_completed(); |
|
| 376 | - EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array(); |
|
| 377 | - return EED_Single_Page_Checkout::instance()->checkout->transaction; |
|
| 378 | - } |
|
| 379 | - } |
|
| 380 | - } |
|
| 381 | - return null; |
|
| 382 | - } |
|
| 383 | - |
|
| 384 | - |
|
| 385 | - |
|
| 386 | - /** |
|
| 387 | - * run |
|
| 388 | - * |
|
| 389 | - * @access public |
|
| 390 | - * @param WP_Query $WP_Query |
|
| 391 | - * @return void |
|
| 392 | - * @throws EE_Error |
|
| 393 | - */ |
|
| 394 | - public function run($WP_Query) |
|
| 395 | - { |
|
| 396 | - if ( |
|
| 397 | - $WP_Query instanceof WP_Query |
|
| 398 | - && $WP_Query->is_main_query() |
|
| 399 | - && apply_filters('FHEE__EED_Single_Page_Checkout__run', true) |
|
| 400 | - && $this->_is_reg_checkout() |
|
| 401 | - ) { |
|
| 402 | - $this->_initialize(); |
|
| 403 | - } |
|
| 404 | - } |
|
| 405 | - |
|
| 406 | - |
|
| 407 | - |
|
| 408 | - /** |
|
| 409 | - * determines whether current url matches reg page url |
|
| 410 | - * |
|
| 411 | - * @return bool |
|
| 412 | - */ |
|
| 413 | - protected function _is_reg_checkout() |
|
| 414 | - { |
|
| 415 | - // get current permalink for reg page without any extra query args |
|
| 416 | - $reg_page_url = \get_permalink(EE_Config::instance()->core->reg_page_id); |
|
| 417 | - // get request URI for current request, but without the scheme or host |
|
| 418 | - $current_request_uri = \EEH_URL::filter_input_server_url('REQUEST_URI'); |
|
| 419 | - $current_request_uri = html_entity_decode($current_request_uri); |
|
| 420 | - // get array of query args from the current request URI |
|
| 421 | - $query_args = \EEH_URL::get_query_string($current_request_uri); |
|
| 422 | - // grab page id if it is set |
|
| 423 | - $page_id = isset($query_args['page_id']) ? absint($query_args['page_id']) : 0; |
|
| 424 | - // and remove the page id from the query args (we will re-add it later) |
|
| 425 | - unset($query_args['page_id']); |
|
| 426 | - // now strip all query args from current request URI |
|
| 427 | - $current_request_uri = remove_query_arg(array_keys($query_args), $current_request_uri); |
|
| 428 | - // and re-add the page id if it was set |
|
| 429 | - if ($page_id) { |
|
| 430 | - $current_request_uri = add_query_arg('page_id', $page_id, $current_request_uri); |
|
| 431 | - } |
|
| 432 | - // remove slashes and ? |
|
| 433 | - $current_request_uri = trim($current_request_uri, '?/'); |
|
| 434 | - // is current request URI part of the known full reg page URL ? |
|
| 435 | - return ! empty($current_request_uri) && strpos($reg_page_url, $current_request_uri) !== false; |
|
| 436 | - } |
|
| 437 | - |
|
| 438 | - |
|
| 439 | - |
|
| 440 | - /** |
|
| 441 | - * @param WP_Query $wp_query |
|
| 442 | - * @return void |
|
| 443 | - * @throws EE_Error |
|
| 444 | - */ |
|
| 445 | - public static function init($wp_query) |
|
| 446 | - { |
|
| 447 | - EED_Single_Page_Checkout::instance()->run($wp_query); |
|
| 448 | - } |
|
| 449 | - |
|
| 450 | - |
|
| 451 | - |
|
| 452 | - /** |
|
| 453 | - * _initialize - initial module setup |
|
| 454 | - * |
|
| 455 | - * @access private |
|
| 456 | - * @throws EE_Error |
|
| 457 | - * @return void |
|
| 458 | - */ |
|
| 459 | - private function _initialize() |
|
| 460 | - { |
|
| 461 | - // ensure SPCO doesn't run twice |
|
| 462 | - if (EED_Single_Page_Checkout::$_initialized) { |
|
| 463 | - return; |
|
| 464 | - } |
|
| 465 | - try { |
|
| 466 | - EED_Single_Page_Checkout::load_reg_steps(); |
|
| 467 | - $this->_verify_session(); |
|
| 468 | - // setup the EE_Checkout object |
|
| 469 | - $this->checkout = $this->_initialize_checkout(); |
|
| 470 | - // filter checkout |
|
| 471 | - $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout); |
|
| 472 | - // get the $_GET |
|
| 473 | - $this->_get_request_vars(); |
|
| 474 | - if ($this->_block_bots()) { |
|
| 475 | - return; |
|
| 476 | - } |
|
| 477 | - // filter continue_reg |
|
| 478 | - $this->checkout->continue_reg = apply_filters( |
|
| 479 | - 'FHEE__EED_Single_Page_Checkout__init___continue_reg', |
|
| 480 | - true, |
|
| 481 | - $this->checkout |
|
| 482 | - ); |
|
| 483 | - // load the reg steps array |
|
| 484 | - if ( ! $this->_load_and_instantiate_reg_steps()) { |
|
| 485 | - EED_Single_Page_Checkout::$_initialized = true; |
|
| 486 | - return; |
|
| 487 | - } |
|
| 488 | - // set the current step |
|
| 489 | - $this->checkout->set_current_step($this->checkout->step); |
|
| 490 | - // and the next step |
|
| 491 | - $this->checkout->set_next_step(); |
|
| 492 | - // verify that everything has been setup correctly |
|
| 493 | - if ( ! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) { |
|
| 494 | - EED_Single_Page_Checkout::$_initialized = true; |
|
| 495 | - return; |
|
| 496 | - } |
|
| 497 | - // lock the transaction |
|
| 498 | - $this->checkout->transaction->lock(); |
|
| 499 | - // make sure all of our cached objects are added to their respective model entity mappers |
|
| 500 | - $this->checkout->refresh_all_entities(); |
|
| 501 | - // set amount owing |
|
| 502 | - $this->checkout->amount_owing = $this->checkout->transaction->remaining(); |
|
| 503 | - // initialize each reg step, which gives them the chance to potentially alter the process |
|
| 504 | - $this->_initialize_reg_steps(); |
|
| 505 | - // DEBUG LOG |
|
| 506 | - //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
|
| 507 | - // get reg form |
|
| 508 | - if( ! $this->_check_form_submission()) { |
|
| 509 | - EED_Single_Page_Checkout::$_initialized = true; |
|
| 510 | - return; |
|
| 511 | - } |
|
| 512 | - // checkout the action!!! |
|
| 513 | - $this->_process_form_action(); |
|
| 514 | - // add some style and make it dance |
|
| 515 | - $this->add_styles_and_scripts(); |
|
| 516 | - // kk... SPCO has successfully run |
|
| 517 | - EED_Single_Page_Checkout::$_initialized = true; |
|
| 518 | - // set no cache headers and constants |
|
| 519 | - EE_System::do_not_cache(); |
|
| 520 | - // add anchor |
|
| 521 | - add_action('loop_start', array($this, 'set_checkout_anchor'), 1); |
|
| 522 | - // remove transaction lock |
|
| 523 | - add_action('shutdown', array($this, 'unlock_transaction'), 1); |
|
| 524 | - } catch (Exception $e) { |
|
| 525 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
| 526 | - } |
|
| 527 | - } |
|
| 528 | - |
|
| 529 | - |
|
| 530 | - |
|
| 531 | - /** |
|
| 532 | - * _verify_session |
|
| 533 | - * checks that the session is valid and not expired |
|
| 534 | - * |
|
| 535 | - * @access private |
|
| 536 | - * @throws EE_Error |
|
| 537 | - */ |
|
| 538 | - private function _verify_session() |
|
| 539 | - { |
|
| 540 | - if ( ! EE_Registry::instance()->SSN instanceof EE_Session) { |
|
| 541 | - throw new EE_Error(__('The EE_Session class could not be loaded.', 'event_espresso')); |
|
| 542 | - } |
|
| 543 | - $clear_session_requested = filter_var( |
|
| 544 | - EE_Registry::instance()->REQ->get('clear_session', false), |
|
| 545 | - FILTER_VALIDATE_BOOLEAN |
|
| 546 | - ); |
|
| 547 | - // is session still valid ? |
|
| 548 | - if ($clear_session_requested |
|
| 549 | - || ( EE_Registry::instance()->SSN->expired() |
|
| 550 | - && EE_Registry::instance()->REQ->get('e_reg_url_link', '') === '' |
|
| 551 | - ) |
|
| 552 | - ) { |
|
| 553 | - $this->checkout = new EE_Checkout(); |
|
| 554 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 555 | - // EE_Registry::instance()->SSN->reset_cart(); |
|
| 556 | - // EE_Registry::instance()->SSN->reset_checkout(); |
|
| 557 | - // EE_Registry::instance()->SSN->reset_transaction(); |
|
| 558 | - if (! $clear_session_requested) { |
|
| 559 | - EE_Error::add_attention( |
|
| 560 | - EE_Registry::$i18n_js_strings['registration_expiration_notice'], |
|
| 561 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 562 | - ); |
|
| 563 | - } |
|
| 564 | - // EE_Registry::instance()->SSN->reset_expired(); |
|
| 565 | - } |
|
| 566 | - } |
|
| 567 | - |
|
| 568 | - |
|
| 569 | - |
|
| 570 | - /** |
|
| 571 | - * _initialize_checkout |
|
| 572 | - * loads and instantiates EE_Checkout |
|
| 573 | - * |
|
| 574 | - * @access private |
|
| 575 | - * @throws EE_Error |
|
| 576 | - * @return EE_Checkout |
|
| 577 | - */ |
|
| 578 | - private function _initialize_checkout() |
|
| 579 | - { |
|
| 580 | - // look in session for existing checkout |
|
| 581 | - /** @type EE_Checkout $checkout */ |
|
| 582 | - $checkout = EE_Registry::instance()->SSN->checkout(); |
|
| 583 | - // verify |
|
| 584 | - if ( ! $checkout instanceof EE_Checkout) { |
|
| 585 | - // instantiate EE_Checkout object for handling the properties of the current checkout process |
|
| 586 | - $checkout = EE_Registry::instance()->load_file( |
|
| 587 | - SPCO_INC_PATH, |
|
| 588 | - 'EE_Checkout', |
|
| 589 | - 'class', array(), |
|
| 590 | - false |
|
| 591 | - ); |
|
| 592 | - } else { |
|
| 593 | - if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) { |
|
| 594 | - $this->unlock_transaction(); |
|
| 595 | - wp_safe_redirect($checkout->redirect_url); |
|
| 596 | - exit(); |
|
| 597 | - } |
|
| 598 | - } |
|
| 599 | - $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout); |
|
| 600 | - // verify again |
|
| 601 | - if ( ! $checkout instanceof EE_Checkout) { |
|
| 602 | - throw new EE_Error(__('The EE_Checkout class could not be loaded.', 'event_espresso')); |
|
| 603 | - } |
|
| 604 | - // reset anything that needs a clean slate for each request |
|
| 605 | - $checkout->reset_for_current_request(); |
|
| 606 | - return $checkout; |
|
| 607 | - } |
|
| 608 | - |
|
| 609 | - |
|
| 610 | - |
|
| 611 | - /** |
|
| 612 | - * _get_request_vars |
|
| 613 | - * |
|
| 614 | - * @access private |
|
| 615 | - * @return void |
|
| 616 | - * @throws EE_Error |
|
| 617 | - */ |
|
| 618 | - private function _get_request_vars() |
|
| 619 | - { |
|
| 620 | - // load classes |
|
| 621 | - EED_Single_Page_Checkout::load_request_handler(); |
|
| 622 | - //make sure this request is marked as belonging to EE |
|
| 623 | - EE_Registry::instance()->REQ->set_espresso_page(true); |
|
| 624 | - // which step is being requested ? |
|
| 625 | - $this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step()); |
|
| 626 | - // which step is being edited ? |
|
| 627 | - $this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', ''); |
|
| 628 | - // and what we're doing on the current step |
|
| 629 | - $this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step'); |
|
| 630 | - // timestamp |
|
| 631 | - $this->checkout->uts = EE_Registry::instance()->REQ->get('uts', 0); |
|
| 632 | - // returning to edit ? |
|
| 633 | - $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', ''); |
|
| 634 | - // add reg url link to registration query params |
|
| 635 | - if ($this->checkout->reg_url_link && strpos($this->checkout->reg_url_link, '1-') !== 0) { |
|
| 636 | - $this->checkout->reg_cache_where_params[0]['REG_url_link'] = $this->checkout->reg_url_link; |
|
| 637 | - } |
|
| 638 | - // or some other kind of revisit ? |
|
| 639 | - $this->checkout->revisit = filter_var( |
|
| 640 | - EE_Registry::instance()->REQ->get('revisit', false), |
|
| 641 | - FILTER_VALIDATE_BOOLEAN |
|
| 642 | - ); |
|
| 643 | - // and whether or not to generate a reg form for this request |
|
| 644 | - $this->checkout->generate_reg_form = filter_var( |
|
| 645 | - EE_Registry::instance()->REQ->get('generate_reg_form', true), |
|
| 646 | - FILTER_VALIDATE_BOOLEAN |
|
| 647 | - ); |
|
| 648 | - // and whether or not to process a reg form submission for this request |
|
| 649 | - $this->checkout->process_form_submission = filter_var( |
|
| 650 | - EE_Registry::instance()->REQ->get( |
|
| 651 | - 'process_form_submission', |
|
| 652 | - $this->checkout->action === 'process_reg_step' |
|
| 653 | - ), |
|
| 654 | - FILTER_VALIDATE_BOOLEAN |
|
| 655 | - ); |
|
| 656 | - $this->checkout->process_form_submission = filter_var( |
|
| 657 | - $this->checkout->action !== 'display_spco_reg_step' |
|
| 658 | - ? $this->checkout->process_form_submission |
|
| 659 | - : false, |
|
| 660 | - FILTER_VALIDATE_BOOLEAN |
|
| 661 | - ); |
|
| 662 | - // $this->_display_request_vars(); |
|
| 663 | - } |
|
| 664 | - |
|
| 665 | - |
|
| 666 | - |
|
| 667 | - /** |
|
| 668 | - * _display_request_vars |
|
| 669 | - * |
|
| 670 | - * @access protected |
|
| 671 | - * @return void |
|
| 672 | - */ |
|
| 673 | - protected function _display_request_vars() |
|
| 674 | - { |
|
| 675 | - if ( ! WP_DEBUG) { |
|
| 676 | - return; |
|
| 677 | - } |
|
| 678 | - EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__); |
|
| 679 | - EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__); |
|
| 680 | - EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__); |
|
| 681 | - EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__); |
|
| 682 | - EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__); |
|
| 683 | - EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__); |
|
| 684 | - EEH_Debug_Tools::printr($this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__); |
|
| 685 | - EEH_Debug_Tools::printr($this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__); |
|
| 686 | - } |
|
| 687 | - |
|
| 688 | - |
|
| 689 | - |
|
| 690 | - /** |
|
| 691 | - * _block_bots |
|
| 692 | - * checks that the incoming request has either of the following set: |
|
| 693 | - * a uts (unix timestamp) which indicates that the request was redirected from the Ticket Selector |
|
| 694 | - * a REG URL Link, which indicates that the request is a return visit to SPCO for a valid TXN |
|
| 695 | - * so if you're not coming from the Ticket Selector nor returning for a valid IP... |
|
| 696 | - * then where you coming from man? |
|
| 697 | - * |
|
| 698 | - * @return boolean |
|
| 699 | - */ |
|
| 700 | - private function _block_bots() |
|
| 701 | - { |
|
| 702 | - $invalid_checkout_access = EED_Invalid_Checkout_Access::getInvalidCheckoutAccess(); |
|
| 703 | - if ($invalid_checkout_access->checkoutAccessIsInvalid($this->checkout)) { |
|
| 704 | - return true; |
|
| 705 | - } |
|
| 706 | - return false; |
|
| 707 | - } |
|
| 708 | - |
|
| 709 | - |
|
| 710 | - |
|
| 711 | - /** |
|
| 712 | - * _get_first_step |
|
| 713 | - * gets slug for first step in $_reg_steps_array |
|
| 714 | - * |
|
| 715 | - * @access private |
|
| 716 | - * @throws EE_Error |
|
| 717 | - * @return string |
|
| 718 | - */ |
|
| 719 | - private function _get_first_step() |
|
| 720 | - { |
|
| 721 | - $first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array); |
|
| 722 | - return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information'; |
|
| 723 | - } |
|
| 724 | - |
|
| 725 | - |
|
| 726 | - |
|
| 727 | - /** |
|
| 728 | - * _load_and_instantiate_reg_steps |
|
| 729 | - * instantiates each reg step based on the loaded reg_steps array |
|
| 730 | - * |
|
| 731 | - * @access private |
|
| 732 | - * @throws EE_Error |
|
| 733 | - * @return bool |
|
| 734 | - */ |
|
| 735 | - private function _load_and_instantiate_reg_steps() |
|
| 736 | - { |
|
| 737 | - do_action('AHEE__Single_Page_Checkout___load_and_instantiate_reg_steps__start', $this->checkout); |
|
| 738 | - // have reg_steps already been instantiated ? |
|
| 739 | - if ( |
|
| 740 | - empty($this->checkout->reg_steps) |
|
| 741 | - || apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout) |
|
| 742 | - ) { |
|
| 743 | - // if not, then loop through raw reg steps array |
|
| 744 | - foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) { |
|
| 745 | - if ( ! $this->_load_and_instantiate_reg_step($reg_step, $order)) { |
|
| 746 | - return false; |
|
| 747 | - } |
|
| 748 | - } |
|
| 749 | - EE_Registry::instance()->CFG->registration->skip_reg_confirmation = true; |
|
| 750 | - EE_Registry::instance()->CFG->registration->reg_confirmation_last = true; |
|
| 751 | - // skip the registration_confirmation page ? |
|
| 752 | - if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) { |
|
| 753 | - // just remove it from the reg steps array |
|
| 754 | - $this->checkout->remove_reg_step('registration_confirmation', false); |
|
| 755 | - } else if ( |
|
| 756 | - isset($this->checkout->reg_steps['registration_confirmation']) |
|
| 757 | - && EE_Registry::instance()->CFG->registration->reg_confirmation_last |
|
| 758 | - ) { |
|
| 759 | - // set the order to something big like 100 |
|
| 760 | - $this->checkout->set_reg_step_order('registration_confirmation', 100); |
|
| 761 | - } |
|
| 762 | - // filter the array for good luck |
|
| 763 | - $this->checkout->reg_steps = apply_filters( |
|
| 764 | - 'FHEE__Single_Page_Checkout__load_reg_steps__reg_steps', |
|
| 765 | - $this->checkout->reg_steps |
|
| 766 | - ); |
|
| 767 | - // finally re-sort based on the reg step class order properties |
|
| 768 | - $this->checkout->sort_reg_steps(); |
|
| 769 | - } else { |
|
| 770 | - foreach ($this->checkout->reg_steps as $reg_step) { |
|
| 771 | - // set all current step stati to FALSE |
|
| 772 | - $reg_step->set_is_current_step(false); |
|
| 773 | - } |
|
| 774 | - } |
|
| 775 | - if (empty($this->checkout->reg_steps)) { |
|
| 776 | - EE_Error::add_error( |
|
| 777 | - __('No Reg Steps were loaded..', 'event_espresso'), |
|
| 778 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 779 | - ); |
|
| 780 | - return false; |
|
| 781 | - } |
|
| 782 | - // make reg step details available to JS |
|
| 783 | - $this->checkout->set_reg_step_JSON_info(); |
|
| 784 | - return true; |
|
| 785 | - } |
|
| 786 | - |
|
| 787 | - |
|
| 788 | - |
|
| 789 | - /** |
|
| 790 | - * _load_and_instantiate_reg_step |
|
| 791 | - * |
|
| 792 | - * @access private |
|
| 793 | - * @param array $reg_step |
|
| 794 | - * @param int $order |
|
| 795 | - * @return bool |
|
| 796 | - */ |
|
| 797 | - private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0) |
|
| 798 | - { |
|
| 799 | - // we need a file_path, class_name, and slug to add a reg step |
|
| 800 | - if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
| 801 | - // if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step) |
|
| 802 | - if ( |
|
| 803 | - $this->checkout->reg_url_link |
|
| 804 | - && $this->checkout->step !== $reg_step['slug'] |
|
| 805 | - && $reg_step['slug'] !== 'finalize_registration' |
|
| 806 | - // normally at this point we would NOT load the reg step, but this filter can change that |
|
| 807 | - && apply_filters( |
|
| 808 | - 'FHEE__Single_Page_Checkout___load_and_instantiate_reg_step__bypass_reg_step', |
|
| 809 | - true, |
|
| 810 | - $reg_step, |
|
| 811 | - $this->checkout |
|
| 812 | - ) |
|
| 813 | - ) { |
|
| 814 | - return true; |
|
| 815 | - } |
|
| 816 | - // instantiate step class using file path and class name |
|
| 817 | - $reg_step_obj = EE_Registry::instance()->load_file( |
|
| 818 | - $reg_step['file_path'], |
|
| 819 | - $reg_step['class_name'], |
|
| 820 | - 'class', |
|
| 821 | - $this->checkout, |
|
| 822 | - false |
|
| 823 | - ); |
|
| 824 | - // did we gets the goods ? |
|
| 825 | - if ($reg_step_obj instanceof EE_SPCO_Reg_Step) { |
|
| 826 | - // set reg step order based on config |
|
| 827 | - $reg_step_obj->set_order($order); |
|
| 828 | - // add instantiated reg step object to the master reg steps array |
|
| 829 | - $this->checkout->add_reg_step($reg_step_obj); |
|
| 830 | - } else { |
|
| 831 | - EE_Error::add_error( |
|
| 832 | - __('The current step could not be set.', 'event_espresso'), |
|
| 833 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 834 | - ); |
|
| 835 | - return false; |
|
| 836 | - } |
|
| 837 | - } else { |
|
| 838 | - if (WP_DEBUG) { |
|
| 839 | - EE_Error::add_error( |
|
| 840 | - sprintf( |
|
| 841 | - __( |
|
| 842 | - 'A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', |
|
| 843 | - 'event_espresso' |
|
| 844 | - ), |
|
| 845 | - isset($reg_step['file_path']) ? $reg_step['file_path'] : '', |
|
| 846 | - isset($reg_step['class_name']) ? $reg_step['class_name'] : '', |
|
| 847 | - isset($reg_step['slug']) ? $reg_step['slug'] : '', |
|
| 848 | - '<ul>', |
|
| 849 | - '<li>', |
|
| 850 | - '</li>', |
|
| 851 | - '</ul>' |
|
| 852 | - ), |
|
| 853 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 854 | - ); |
|
| 855 | - } |
|
| 856 | - return false; |
|
| 857 | - } |
|
| 858 | - return true; |
|
| 859 | - } |
|
| 860 | - |
|
| 861 | - |
|
| 862 | - /** |
|
| 863 | - * _verify_transaction_and_get_registrations |
|
| 864 | - * |
|
| 865 | - * @access private |
|
| 866 | - * @return bool |
|
| 867 | - * @throws InvalidDataTypeException |
|
| 868 | - * @throws InvalidEntityException |
|
| 869 | - * @throws EE_Error |
|
| 870 | - */ |
|
| 871 | - private function _verify_transaction_and_get_registrations() |
|
| 872 | - { |
|
| 873 | - // was there already a valid transaction in the checkout from the session ? |
|
| 874 | - if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
| 875 | - // get transaction from db or session |
|
| 876 | - $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin() |
|
| 877 | - ? $this->_get_transaction_and_cart_for_previous_visit() |
|
| 878 | - : $this->_get_cart_for_current_session_and_setup_new_transaction(); |
|
| 879 | - if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
| 880 | - EE_Error::add_error( |
|
| 881 | - __('Your Registration and Transaction information could not be retrieved from the db.', |
|
| 882 | - 'event_espresso'), |
|
| 883 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 884 | - ); |
|
| 885 | - $this->checkout->transaction = EE_Transaction::new_instance(); |
|
| 886 | - // add some style and make it dance |
|
| 887 | - $this->add_styles_and_scripts(); |
|
| 888 | - EED_Single_Page_Checkout::$_initialized = true; |
|
| 889 | - return false; |
|
| 890 | - } |
|
| 891 | - // and the registrations for the transaction |
|
| 892 | - $this->_get_registrations($this->checkout->transaction); |
|
| 893 | - } |
|
| 894 | - return true; |
|
| 895 | - } |
|
| 896 | - |
|
| 897 | - |
|
| 898 | - |
|
| 899 | - /** |
|
| 900 | - * _get_transaction_and_cart_for_previous_visit |
|
| 901 | - * |
|
| 902 | - * @access private |
|
| 903 | - * @return mixed EE_Transaction|NULL |
|
| 904 | - */ |
|
| 905 | - private function _get_transaction_and_cart_for_previous_visit() |
|
| 906 | - { |
|
| 907 | - /** @var $TXN_model EEM_Transaction */ |
|
| 908 | - $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
|
| 909 | - // because the reg_url_link is present in the request, |
|
| 910 | - // this is a return visit to SPCO, so we'll get the transaction data from the db |
|
| 911 | - $transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link); |
|
| 912 | - // verify transaction |
|
| 913 | - if ($transaction instanceof EE_Transaction) { |
|
| 914 | - // and get the cart that was used for that transaction |
|
| 915 | - $this->checkout->cart = $this->_get_cart_for_transaction($transaction); |
|
| 916 | - return $transaction; |
|
| 917 | - } |
|
| 918 | - EE_Error::add_error( |
|
| 919 | - __('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), |
|
| 920 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 921 | - ); |
|
| 922 | - return null; |
|
| 923 | - |
|
| 924 | - } |
|
| 925 | - |
|
| 926 | - |
|
| 927 | - |
|
| 928 | - /** |
|
| 929 | - * _get_cart_for_transaction |
|
| 930 | - * |
|
| 931 | - * @access private |
|
| 932 | - * @param EE_Transaction $transaction |
|
| 933 | - * @return EE_Cart |
|
| 934 | - */ |
|
| 935 | - private function _get_cart_for_transaction($transaction) |
|
| 936 | - { |
|
| 937 | - return $this->checkout->get_cart_for_transaction($transaction); |
|
| 938 | - } |
|
| 939 | - |
|
| 940 | - |
|
| 941 | - |
|
| 942 | - /** |
|
| 943 | - * get_cart_for_transaction |
|
| 944 | - * |
|
| 945 | - * @access public |
|
| 946 | - * @param EE_Transaction $transaction |
|
| 947 | - * @return EE_Cart |
|
| 948 | - */ |
|
| 949 | - public function get_cart_for_transaction(EE_Transaction $transaction) |
|
| 950 | - { |
|
| 951 | - return $this->checkout->get_cart_for_transaction($transaction); |
|
| 952 | - } |
|
| 953 | - |
|
| 954 | - |
|
| 955 | - |
|
| 956 | - /** |
|
| 957 | - * _get_transaction_and_cart_for_current_session |
|
| 958 | - * generates a new EE_Transaction object and adds it to the $_transaction property. |
|
| 959 | - * |
|
| 960 | - * @access private |
|
| 961 | - * @return EE_Transaction |
|
| 962 | - * @throws EE_Error |
|
| 963 | - */ |
|
| 964 | - private function _get_cart_for_current_session_and_setup_new_transaction() |
|
| 965 | - { |
|
| 966 | - // if there's no transaction, then this is the FIRST visit to SPCO |
|
| 967 | - // so load up the cart ( passing nothing for the TXN because it doesn't exist yet ) |
|
| 968 | - $this->checkout->cart = $this->_get_cart_for_transaction(null); |
|
| 969 | - // and then create a new transaction |
|
| 970 | - $transaction = $this->_initialize_transaction(); |
|
| 971 | - // verify transaction |
|
| 972 | - if ($transaction instanceof EE_Transaction) { |
|
| 973 | - // save it so that we have an ID for other objects to use |
|
| 974 | - $transaction->save(); |
|
| 975 | - // and save TXN data to the cart |
|
| 976 | - $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID()); |
|
| 977 | - } else { |
|
| 978 | - EE_Error::add_error( |
|
| 979 | - __('A Valid Transaction could not be initialized.', 'event_espresso'), |
|
| 980 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 981 | - ); |
|
| 982 | - } |
|
| 983 | - return $transaction; |
|
| 984 | - } |
|
| 985 | - |
|
| 986 | - |
|
| 987 | - |
|
| 988 | - /** |
|
| 989 | - * generates a new EE_Transaction object and adds it to the $_transaction property. |
|
| 990 | - * |
|
| 991 | - * @access private |
|
| 992 | - * @return mixed EE_Transaction|NULL |
|
| 993 | - */ |
|
| 994 | - private function _initialize_transaction() |
|
| 995 | - { |
|
| 996 | - try { |
|
| 997 | - // ensure cart totals have been calculated |
|
| 998 | - $this->checkout->cart->get_grand_total()->recalculate_total_including_taxes(); |
|
| 999 | - // grab the cart grand total |
|
| 1000 | - $cart_total = $this->checkout->cart->get_cart_grand_total(); |
|
| 1001 | - // create new TXN |
|
| 1002 | - $transaction = EE_Transaction::new_instance( |
|
| 1003 | - array( |
|
| 1004 | - 'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(), |
|
| 1005 | - 'TXN_total' => $cart_total > 0 ? $cart_total : 0, |
|
| 1006 | - 'TXN_paid' => 0, |
|
| 1007 | - 'STS_ID' => EEM_Transaction::failed_status_code, |
|
| 1008 | - ) |
|
| 1009 | - ); |
|
| 1010 | - // save it so that we have an ID for other objects to use |
|
| 1011 | - $transaction->save(); |
|
| 1012 | - // set cron job for following up on TXNs after their session has expired |
|
| 1013 | - EE_Cron_Tasks::schedule_expired_transaction_check( |
|
| 1014 | - EE_Registry::instance()->SSN->expiration() + 1, |
|
| 1015 | - $transaction->ID() |
|
| 1016 | - ); |
|
| 1017 | - return $transaction; |
|
| 1018 | - } catch (Exception $e) { |
|
| 1019 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
| 1020 | - } |
|
| 1021 | - return null; |
|
| 1022 | - } |
|
| 1023 | - |
|
| 1024 | - |
|
| 1025 | - /** |
|
| 1026 | - * _get_registrations |
|
| 1027 | - * |
|
| 1028 | - * @access private |
|
| 1029 | - * @param EE_Transaction $transaction |
|
| 1030 | - * @return void |
|
| 1031 | - * @throws InvalidDataTypeException |
|
| 1032 | - * @throws InvalidEntityException |
|
| 1033 | - * @throws EE_Error |
|
| 1034 | - */ |
|
| 1035 | - private function _get_registrations(EE_Transaction $transaction) |
|
| 1036 | - { |
|
| 1037 | - // first step: grab the registrants { : o |
|
| 1038 | - $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false); |
|
| 1039 | - $this->checkout->total_ticket_count = count($registrations); |
|
| 1040 | - // verify registrations have been set |
|
| 1041 | - if (empty($registrations)) { |
|
| 1042 | - // if no cached registrations, then check the db |
|
| 1043 | - $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false); |
|
| 1044 | - // still nothing ? well as long as this isn't a revisit |
|
| 1045 | - if (empty($registrations) && ! $this->checkout->revisit) { |
|
| 1046 | - // generate new registrations from scratch |
|
| 1047 | - $registrations = $this->_initialize_registrations($transaction); |
|
| 1048 | - } |
|
| 1049 | - } |
|
| 1050 | - // sort by their original registration order |
|
| 1051 | - usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count')); |
|
| 1052 | - // then loop thru the array |
|
| 1053 | - foreach ($registrations as $registration) { |
|
| 1054 | - // verify each registration |
|
| 1055 | - if ($registration instanceof EE_Registration) { |
|
| 1056 | - // we display all attendee info for the primary registrant |
|
| 1057 | - if ($this->checkout->reg_url_link === $registration->reg_url_link() |
|
| 1058 | - && $registration->is_primary_registrant() |
|
| 1059 | - ) { |
|
| 1060 | - $this->checkout->primary_revisit = true; |
|
| 1061 | - break; |
|
| 1062 | - } |
|
| 1063 | - if ($this->checkout->revisit && $this->checkout->reg_url_link !== $registration->reg_url_link()) { |
|
| 1064 | - // but hide info if it doesn't belong to you |
|
| 1065 | - $transaction->clear_cache('Registration', $registration->ID()); |
|
| 1066 | - $this->checkout->total_ticket_count--; |
|
| 1067 | - } |
|
| 1068 | - $this->checkout->set_reg_status_updated($registration->ID(), false); |
|
| 1069 | - } |
|
| 1070 | - } |
|
| 1071 | - } |
|
| 1072 | - |
|
| 1073 | - |
|
| 1074 | - /** |
|
| 1075 | - * adds related EE_Registration objects for each ticket in the cart to the current EE_Transaction object |
|
| 1076 | - * |
|
| 1077 | - * @access private |
|
| 1078 | - * @param EE_Transaction $transaction |
|
| 1079 | - * @return array |
|
| 1080 | - * @throws InvalidDataTypeException |
|
| 1081 | - * @throws InvalidEntityException |
|
| 1082 | - * @throws EE_Error |
|
| 1083 | - */ |
|
| 1084 | - private function _initialize_registrations(EE_Transaction $transaction) |
|
| 1085 | - { |
|
| 1086 | - $att_nmbr = 0; |
|
| 1087 | - $registrations = array(); |
|
| 1088 | - if ($transaction instanceof EE_Transaction) { |
|
| 1089 | - /** @type EE_Registration_Processor $registration_processor */ |
|
| 1090 | - $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
| 1091 | - $this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count(); |
|
| 1092 | - // now let's add the cart items to the $transaction |
|
| 1093 | - foreach ($this->checkout->cart->get_tickets() as $line_item) { |
|
| 1094 | - //do the following for each ticket of this type they selected |
|
| 1095 | - for ($x = 1; $x <= $line_item->quantity(); $x++) { |
|
| 1096 | - $att_nmbr++; |
|
| 1097 | - /** @var EventEspresso\core\services\commands\registration\CreateRegistrationCommand $CreateRegistrationCommand */ |
|
| 1098 | - $CreateRegistrationCommand = EE_Registry::instance()->create( |
|
| 1099 | - 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
| 1100 | - array( |
|
| 1101 | - $transaction, |
|
| 1102 | - $line_item, |
|
| 1103 | - $att_nmbr, |
|
| 1104 | - $this->checkout->total_ticket_count, |
|
| 1105 | - ) |
|
| 1106 | - ); |
|
| 1107 | - // override capabilities for frontend registrations |
|
| 1108 | - if ( ! is_admin()) { |
|
| 1109 | - $CreateRegistrationCommand->setCapCheck( |
|
| 1110 | - new PublicCapabilities('', 'create_new_registration') |
|
| 1111 | - ); |
|
| 1112 | - } |
|
| 1113 | - $registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand); |
|
| 1114 | - if ( ! $registration instanceof EE_Registration) { |
|
| 1115 | - throw new InvalidEntityException($registration, 'EE_Registration'); |
|
| 1116 | - } |
|
| 1117 | - $registrations[ $registration->ID() ] = $registration; |
|
| 1118 | - } |
|
| 1119 | - } |
|
| 1120 | - $registration_processor->fix_reg_final_price_rounding_issue($transaction); |
|
| 1121 | - } |
|
| 1122 | - return $registrations; |
|
| 1123 | - } |
|
| 1124 | - |
|
| 1125 | - |
|
| 1126 | - |
|
| 1127 | - /** |
|
| 1128 | - * sorts registrations by REG_count |
|
| 1129 | - * |
|
| 1130 | - * @access public |
|
| 1131 | - * @param EE_Registration $reg_A |
|
| 1132 | - * @param EE_Registration $reg_B |
|
| 1133 | - * @return int |
|
| 1134 | - */ |
|
| 1135 | - public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B) |
|
| 1136 | - { |
|
| 1137 | - // this shouldn't ever happen within the same TXN, but oh well |
|
| 1138 | - if ($reg_A->count() === $reg_B->count()) { |
|
| 1139 | - return 0; |
|
| 1140 | - } |
|
| 1141 | - return ($reg_A->count() > $reg_B->count()) ? 1 : -1; |
|
| 1142 | - } |
|
| 1143 | - |
|
| 1144 | - |
|
| 1145 | - |
|
| 1146 | - /** |
|
| 1147 | - * _final_verifications |
|
| 1148 | - * just makes sure that everything is set up correctly before proceeding |
|
| 1149 | - * |
|
| 1150 | - * @access private |
|
| 1151 | - * @return bool |
|
| 1152 | - * @throws EE_Error |
|
| 1153 | - */ |
|
| 1154 | - private function _final_verifications() |
|
| 1155 | - { |
|
| 1156 | - // filter checkout |
|
| 1157 | - $this->checkout = apply_filters( |
|
| 1158 | - 'FHEE__EED_Single_Page_Checkout___final_verifications__checkout', |
|
| 1159 | - $this->checkout |
|
| 1160 | - ); |
|
| 1161 | - //verify that current step is still set correctly |
|
| 1162 | - if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) { |
|
| 1163 | - EE_Error::add_error( |
|
| 1164 | - __('We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', 'event_espresso'), |
|
| 1165 | - __FILE__, |
|
| 1166 | - __FUNCTION__, |
|
| 1167 | - __LINE__ |
|
| 1168 | - ); |
|
| 1169 | - return false; |
|
| 1170 | - } |
|
| 1171 | - // if returning to SPCO, then verify that primary registrant is set |
|
| 1172 | - if ( ! empty($this->checkout->reg_url_link)) { |
|
| 1173 | - $valid_registrant = $this->checkout->transaction->primary_registration(); |
|
| 1174 | - if ( ! $valid_registrant instanceof EE_Registration) { |
|
| 1175 | - EE_Error::add_error( |
|
| 1176 | - __('We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', 'event_espresso'), |
|
| 1177 | - __FILE__, |
|
| 1178 | - __FUNCTION__, |
|
| 1179 | - __LINE__ |
|
| 1180 | - ); |
|
| 1181 | - return false; |
|
| 1182 | - } |
|
| 1183 | - $valid_registrant = null; |
|
| 1184 | - foreach ( |
|
| 1185 | - $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration |
|
| 1186 | - ) { |
|
| 1187 | - if ( |
|
| 1188 | - $registration instanceof EE_Registration |
|
| 1189 | - && $registration->reg_url_link() === $this->checkout->reg_url_link |
|
| 1190 | - ) { |
|
| 1191 | - $valid_registrant = $registration; |
|
| 1192 | - } |
|
| 1193 | - } |
|
| 1194 | - if ( ! $valid_registrant instanceof EE_Registration) { |
|
| 1195 | - // hmmm... maybe we have the wrong session because the user is opening multiple tabs ? |
|
| 1196 | - if (EED_Single_Page_Checkout::$_checkout_verified) { |
|
| 1197 | - // clear the session, mark the checkout as unverified, and try again |
|
| 1198 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 1199 | - EED_Single_Page_Checkout::$_initialized = false; |
|
| 1200 | - EED_Single_Page_Checkout::$_checkout_verified = false; |
|
| 1201 | - $this->_initialize(); |
|
| 1202 | - EE_Error::reset_notices(); |
|
| 1203 | - return false; |
|
| 1204 | - } |
|
| 1205 | - EE_Error::add_error( |
|
| 1206 | - __( |
|
| 1207 | - 'We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.', |
|
| 1208 | - 'event_espresso' |
|
| 1209 | - ), |
|
| 1210 | - __FILE__, |
|
| 1211 | - __FUNCTION__, |
|
| 1212 | - __LINE__ |
|
| 1213 | - ); |
|
| 1214 | - return false; |
|
| 1215 | - } |
|
| 1216 | - } |
|
| 1217 | - // now that things have been kinda sufficiently verified, |
|
| 1218 | - // let's add the checkout to the session so that it's available to other systems |
|
| 1219 | - EE_Registry::instance()->SSN->set_checkout($this->checkout); |
|
| 1220 | - return true; |
|
| 1221 | - } |
|
| 1222 | - |
|
| 1223 | - |
|
| 1224 | - |
|
| 1225 | - /** |
|
| 1226 | - * _initialize_reg_steps |
|
| 1227 | - * first makes sure that EE_Transaction_Processor::set_reg_step_initiated() is called as required |
|
| 1228 | - * then loops thru all of the active reg steps and calls the initialize_reg_step() method |
|
| 1229 | - * |
|
| 1230 | - * @access private |
|
| 1231 | - * @param bool $reinitializing |
|
| 1232 | - * @throws EE_Error |
|
| 1233 | - */ |
|
| 1234 | - private function _initialize_reg_steps($reinitializing = false) |
|
| 1235 | - { |
|
| 1236 | - $this->checkout->set_reg_step_initiated($this->checkout->current_step); |
|
| 1237 | - // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS |
|
| 1238 | - foreach ($this->checkout->reg_steps as $reg_step) { |
|
| 1239 | - if ( ! $reg_step->initialize_reg_step()) { |
|
| 1240 | - // if not initialized then maybe this step is being removed... |
|
| 1241 | - if ( ! $reinitializing && $reg_step->is_current_step()) { |
|
| 1242 | - // if it was the current step, then we need to start over here |
|
| 1243 | - $this->_initialize_reg_steps(true); |
|
| 1244 | - return; |
|
| 1245 | - } |
|
| 1246 | - continue; |
|
| 1247 | - } |
|
| 1248 | - // add css and JS for current step |
|
| 1249 | - $reg_step->enqueue_styles_and_scripts(); |
|
| 1250 | - // i18n |
|
| 1251 | - $reg_step->translate_js_strings(); |
|
| 1252 | - if ($reg_step->is_current_step()) { |
|
| 1253 | - // the text that appears on the reg step form submit button |
|
| 1254 | - $reg_step->set_submit_button_text(); |
|
| 1255 | - } |
|
| 1256 | - } |
|
| 1257 | - // dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information |
|
| 1258 | - do_action( |
|
| 1259 | - "AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", |
|
| 1260 | - $this->checkout->current_step |
|
| 1261 | - ); |
|
| 1262 | - } |
|
| 1263 | - |
|
| 1264 | - |
|
| 1265 | - |
|
| 1266 | - /** |
|
| 1267 | - * _check_form_submission |
|
| 1268 | - * |
|
| 1269 | - * @access private |
|
| 1270 | - * @return boolean |
|
| 1271 | - */ |
|
| 1272 | - private function _check_form_submission() |
|
| 1273 | - { |
|
| 1274 | - //does this request require the reg form to be generated ? |
|
| 1275 | - if ($this->checkout->generate_reg_form) { |
|
| 1276 | - // ever heard that song by Blue Rodeo ? |
|
| 1277 | - try { |
|
| 1278 | - $this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form(); |
|
| 1279 | - // if not displaying a form, then check for form submission |
|
| 1280 | - if ( |
|
| 1281 | - $this->checkout->process_form_submission |
|
| 1282 | - && $this->checkout->current_step->reg_form->was_submitted() |
|
| 1283 | - ) { |
|
| 1284 | - // clear out any old data in case this step is being run again |
|
| 1285 | - $this->checkout->current_step->set_valid_data(array()); |
|
| 1286 | - // capture submitted form data |
|
| 1287 | - $this->checkout->current_step->reg_form->receive_form_submission( |
|
| 1288 | - apply_filters( |
|
| 1289 | - 'FHEE__Single_Page_Checkout___check_form_submission__request_params', |
|
| 1290 | - EE_Registry::instance()->REQ->params(), |
|
| 1291 | - $this->checkout |
|
| 1292 | - ) |
|
| 1293 | - ); |
|
| 1294 | - // validate submitted form data |
|
| 1295 | - if ( ! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) { |
|
| 1296 | - // thou shall not pass !!! |
|
| 1297 | - $this->checkout->continue_reg = false; |
|
| 1298 | - // any form validation errors? |
|
| 1299 | - if ($this->checkout->current_step->reg_form->submission_error_message() !== '') { |
|
| 1300 | - EE_Error::add_error( |
|
| 1301 | - $this->checkout->current_step->reg_form->submission_error_message(), |
|
| 1302 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 1303 | - ); |
|
| 1304 | - } |
|
| 1305 | - // well not really... what will happen is |
|
| 1306 | - // we'll just get redirected back to redo the current step |
|
| 1307 | - $this->go_to_next_step(); |
|
| 1308 | - return false; |
|
| 1309 | - } |
|
| 1310 | - } |
|
| 1311 | - } catch (EE_Error $e) { |
|
| 1312 | - $e->get_error(); |
|
| 1313 | - } |
|
| 1314 | - } |
|
| 1315 | - return true; |
|
| 1316 | - } |
|
| 1317 | - |
|
| 1318 | - |
|
| 1319 | - |
|
| 1320 | - /** |
|
| 1321 | - * _process_action |
|
| 1322 | - * |
|
| 1323 | - * @access private |
|
| 1324 | - * @return void |
|
| 1325 | - * @throws EE_Error |
|
| 1326 | - */ |
|
| 1327 | - private function _process_form_action() |
|
| 1328 | - { |
|
| 1329 | - // what cha wanna do? |
|
| 1330 | - switch ($this->checkout->action) { |
|
| 1331 | - // AJAX next step reg form |
|
| 1332 | - case 'display_spco_reg_step' : |
|
| 1333 | - $this->checkout->redirect = false; |
|
| 1334 | - if (EE_Registry::instance()->REQ->ajax) { |
|
| 1335 | - $this->checkout->json_response->set_reg_step_html( |
|
| 1336 | - $this->checkout->current_step->display_reg_form() |
|
| 1337 | - ); |
|
| 1338 | - } |
|
| 1339 | - break; |
|
| 1340 | - default : |
|
| 1341 | - // meh... do one of those other steps first |
|
| 1342 | - if ( |
|
| 1343 | - ! empty($this->checkout->action) |
|
| 1344 | - && is_callable(array($this->checkout->current_step, $this->checkout->action)) |
|
| 1345 | - ) { |
|
| 1346 | - // dynamically creates hook point like: |
|
| 1347 | - // AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step |
|
| 1348 | - do_action( |
|
| 1349 | - "AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", |
|
| 1350 | - $this->checkout->current_step |
|
| 1351 | - ); |
|
| 1352 | - // call action on current step |
|
| 1353 | - if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) { |
|
| 1354 | - // good registrant, you get to proceed |
|
| 1355 | - if ( |
|
| 1356 | - $this->checkout->current_step->success_message() !== '' |
|
| 1357 | - && apply_filters( |
|
| 1358 | - 'FHEE__Single_Page_Checkout___process_form_action__display_success', |
|
| 1359 | - false |
|
| 1360 | - ) |
|
| 1361 | - ) { |
|
| 1362 | - EE_Error::add_success( |
|
| 1363 | - $this->checkout->current_step->success_message() |
|
| 1364 | - . '<br />' . $this->checkout->next_step->_instructions() |
|
| 1365 | - ); |
|
| 1366 | - } |
|
| 1367 | - // pack it up, pack it in... |
|
| 1368 | - $this->_setup_redirect(); |
|
| 1369 | - } |
|
| 1370 | - // dynamically creates hook point like: |
|
| 1371 | - // AHEE__Single_Page_Checkout__after_payment_options__process_reg_step |
|
| 1372 | - do_action( |
|
| 1373 | - "AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", |
|
| 1374 | - $this->checkout->current_step |
|
| 1375 | - ); |
|
| 1376 | - } else { |
|
| 1377 | - EE_Error::add_error( |
|
| 1378 | - sprintf( |
|
| 1379 | - __( |
|
| 1380 | - 'The requested form action "%s" does not exist for the current "%s" registration step.', |
|
| 1381 | - 'event_espresso' |
|
| 1382 | - ), |
|
| 1383 | - $this->checkout->action, |
|
| 1384 | - $this->checkout->current_step->name() |
|
| 1385 | - ), |
|
| 1386 | - __FILE__, |
|
| 1387 | - __FUNCTION__, |
|
| 1388 | - __LINE__ |
|
| 1389 | - ); |
|
| 1390 | - } |
|
| 1391 | - // end default |
|
| 1392 | - } |
|
| 1393 | - // store our progress so far |
|
| 1394 | - $this->checkout->stash_transaction_and_checkout(); |
|
| 1395 | - // advance to the next step! If you pass GO, collect $200 |
|
| 1396 | - $this->go_to_next_step(); |
|
| 1397 | - } |
|
| 1398 | - |
|
| 1399 | - |
|
| 1400 | - |
|
| 1401 | - /** |
|
| 1402 | - * add_styles_and_scripts |
|
| 1403 | - * |
|
| 1404 | - * @access public |
|
| 1405 | - * @return void |
|
| 1406 | - */ |
|
| 1407 | - public function add_styles_and_scripts() |
|
| 1408 | - { |
|
| 1409 | - // i18n |
|
| 1410 | - $this->translate_js_strings(); |
|
| 1411 | - if ($this->checkout->admin_request) { |
|
| 1412 | - add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
| 1413 | - } else { |
|
| 1414 | - add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
| 1415 | - } |
|
| 1416 | - } |
|
| 1417 | - |
|
| 1418 | - |
|
| 1419 | - |
|
| 1420 | - /** |
|
| 1421 | - * translate_js_strings |
|
| 1422 | - * |
|
| 1423 | - * @access public |
|
| 1424 | - * @return void |
|
| 1425 | - */ |
|
| 1426 | - public function translate_js_strings() |
|
| 1427 | - { |
|
| 1428 | - EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit; |
|
| 1429 | - EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link; |
|
| 1430 | - EE_Registry::$i18n_js_strings['server_error'] = __( |
|
| 1431 | - 'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.', |
|
| 1432 | - 'event_espresso' |
|
| 1433 | - ); |
|
| 1434 | - EE_Registry::$i18n_js_strings['invalid_json_response'] = __( |
|
| 1435 | - 'An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', |
|
| 1436 | - 'event_espresso' |
|
| 1437 | - ); |
|
| 1438 | - EE_Registry::$i18n_js_strings['validation_error'] = __( |
|
| 1439 | - 'There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', |
|
| 1440 | - 'event_espresso' |
|
| 1441 | - ); |
|
| 1442 | - EE_Registry::$i18n_js_strings['invalid_payment_method'] = __( |
|
| 1443 | - 'There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', |
|
| 1444 | - 'event_espresso' |
|
| 1445 | - ); |
|
| 1446 | - EE_Registry::$i18n_js_strings['reg_step_error'] = __( |
|
| 1447 | - 'This registration step could not be completed. Please refresh the page and try again.', |
|
| 1448 | - 'event_espresso' |
|
| 1449 | - ); |
|
| 1450 | - EE_Registry::$i18n_js_strings['invalid_coupon'] = __( |
|
| 1451 | - 'We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.', |
|
| 1452 | - 'event_espresso' |
|
| 1453 | - ); |
|
| 1454 | - EE_Registry::$i18n_js_strings['process_registration'] = sprintf( |
|
| 1455 | - __( |
|
| 1456 | - 'Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.', |
|
| 1457 | - 'event_espresso' |
|
| 1458 | - ), |
|
| 1459 | - '<br/>', |
|
| 1460 | - '<br/>' |
|
| 1461 | - ); |
|
| 1462 | - EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language'); |
|
| 1463 | - EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id(); |
|
| 1464 | - EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency; |
|
| 1465 | - EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20'; |
|
| 1466 | - EE_Registry::$i18n_js_strings['timer_years'] = __('years', 'event_espresso'); |
|
| 1467 | - EE_Registry::$i18n_js_strings['timer_months'] = __('months', 'event_espresso'); |
|
| 1468 | - EE_Registry::$i18n_js_strings['timer_weeks'] = __('weeks', 'event_espresso'); |
|
| 1469 | - EE_Registry::$i18n_js_strings['timer_days'] = __('days', 'event_espresso'); |
|
| 1470 | - EE_Registry::$i18n_js_strings['timer_hours'] = __('hours', 'event_espresso'); |
|
| 1471 | - EE_Registry::$i18n_js_strings['timer_minutes'] = __('minutes', 'event_espresso'); |
|
| 1472 | - EE_Registry::$i18n_js_strings['timer_seconds'] = __('seconds', 'event_espresso'); |
|
| 1473 | - EE_Registry::$i18n_js_strings['timer_year'] = __('year', 'event_espresso'); |
|
| 1474 | - EE_Registry::$i18n_js_strings['timer_month'] = __('month', 'event_espresso'); |
|
| 1475 | - EE_Registry::$i18n_js_strings['timer_week'] = __('week', 'event_espresso'); |
|
| 1476 | - EE_Registry::$i18n_js_strings['timer_day'] = __('day', 'event_espresso'); |
|
| 1477 | - EE_Registry::$i18n_js_strings['timer_hour'] = __('hour', 'event_espresso'); |
|
| 1478 | - EE_Registry::$i18n_js_strings['timer_minute'] = __('minute', 'event_espresso'); |
|
| 1479 | - EE_Registry::$i18n_js_strings['timer_second'] = __('second', 'event_espresso'); |
|
| 1480 | - EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice(); |
|
| 1481 | - EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters( |
|
| 1482 | - 'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', |
|
| 1483 | - true |
|
| 1484 | - ); |
|
| 1485 | - EE_Registry::$i18n_js_strings['session_extension'] = absint( |
|
| 1486 | - apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS) |
|
| 1487 | - ); |
|
| 1488 | - EE_Registry::$i18n_js_strings['session_expiration'] = gmdate( |
|
| 1489 | - 'M d, Y H:i:s', |
|
| 1490 | - EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS) |
|
| 1491 | - ); |
|
| 1492 | - } |
|
| 1493 | - |
|
| 1494 | - |
|
| 1495 | - |
|
| 1496 | - /** |
|
| 1497 | - * enqueue_styles_and_scripts |
|
| 1498 | - * |
|
| 1499 | - * @access public |
|
| 1500 | - * @return void |
|
| 1501 | - * @throws EE_Error |
|
| 1502 | - */ |
|
| 1503 | - public function enqueue_styles_and_scripts() |
|
| 1504 | - { |
|
| 1505 | - // load css |
|
| 1506 | - wp_register_style( |
|
| 1507 | - 'single_page_checkout', |
|
| 1508 | - SPCO_CSS_URL . 'single_page_checkout.css', |
|
| 1509 | - array('espresso_default'), |
|
| 1510 | - EVENT_ESPRESSO_VERSION |
|
| 1511 | - ); |
|
| 1512 | - wp_enqueue_style('single_page_checkout'); |
|
| 1513 | - // load JS |
|
| 1514 | - wp_register_script( |
|
| 1515 | - 'jquery_plugin', |
|
| 1516 | - EE_THIRD_PARTY_URL . 'jquery .plugin.min.js', |
|
| 1517 | - array('jquery'), |
|
| 1518 | - '1.0.1', |
|
| 1519 | - true |
|
| 1520 | - ); |
|
| 1521 | - wp_register_script( |
|
| 1522 | - 'jquery_countdown', |
|
| 1523 | - EE_THIRD_PARTY_URL . 'jquery .countdown.min.js', |
|
| 1524 | - array('jquery_plugin'), |
|
| 1525 | - '2.0.2', |
|
| 1526 | - true |
|
| 1527 | - ); |
|
| 1528 | - wp_register_script( |
|
| 1529 | - 'single_page_checkout', |
|
| 1530 | - SPCO_JS_URL . 'single_page_checkout.js', |
|
| 1531 | - array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'), |
|
| 1532 | - EVENT_ESPRESSO_VERSION, |
|
| 1533 | - true |
|
| 1534 | - ); |
|
| 1535 | - if ($this->checkout->registration_form instanceof EE_Form_Section_Proper) { |
|
| 1536 | - $this->checkout->registration_form->enqueue_js(); |
|
| 1537 | - } |
|
| 1538 | - if ($this->checkout->current_step->reg_form instanceof EE_Form_Section_Proper) { |
|
| 1539 | - $this->checkout->current_step->reg_form->enqueue_js(); |
|
| 1540 | - } |
|
| 1541 | - wp_enqueue_script('single_page_checkout'); |
|
| 1542 | - /** |
|
| 1543 | - * global action hook for enqueueing styles and scripts with |
|
| 1544 | - * spco calls. |
|
| 1545 | - */ |
|
| 1546 | - do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this); |
|
| 1547 | - /** |
|
| 1548 | - * dynamic action hook for enqueueing styles and scripts with spco calls. |
|
| 1549 | - * The hook will end up being something like: |
|
| 1550 | - * AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information |
|
| 1551 | - */ |
|
| 1552 | - do_action( |
|
| 1553 | - 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(), |
|
| 1554 | - $this |
|
| 1555 | - ); |
|
| 1556 | - } |
|
| 1557 | - |
|
| 1558 | - |
|
| 1559 | - |
|
| 1560 | - /** |
|
| 1561 | - * display the Registration Single Page Checkout Form |
|
| 1562 | - * |
|
| 1563 | - * @access private |
|
| 1564 | - * @return void |
|
| 1565 | - * @throws EE_Error |
|
| 1566 | - */ |
|
| 1567 | - private function _display_spco_reg_form() |
|
| 1568 | - { |
|
| 1569 | - // if registering via the admin, just display the reg form for the current step |
|
| 1570 | - if ($this->checkout->admin_request) { |
|
| 1571 | - EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form()); |
|
| 1572 | - } else { |
|
| 1573 | - // add powered by EE msg |
|
| 1574 | - add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer')); |
|
| 1575 | - $empty_cart = count( |
|
| 1576 | - $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) |
|
| 1577 | - ) < 1; |
|
| 1578 | - EE_Registry::$i18n_js_strings['empty_cart'] = $empty_cart; |
|
| 1579 | - $cookies_not_set_msg = ''; |
|
| 1580 | - if ($empty_cart) { |
|
| 1581 | - $cookies_not_set_msg = apply_filters( |
|
| 1582 | - 'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg', |
|
| 1583 | - sprintf( |
|
| 1584 | - __( |
|
| 1585 | - '%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s', |
|
| 1586 | - 'event_espresso' |
|
| 1587 | - ), |
|
| 1588 | - '<div class="ee-attention hidden" id="ee-cookies-not-set-msg">', |
|
| 1589 | - '</div>', |
|
| 1590 | - '<h6 class="important-notice">', |
|
| 1591 | - '</h6>', |
|
| 1592 | - '<p>', |
|
| 1593 | - '</p>', |
|
| 1594 | - '<br />', |
|
| 1595 | - '<a href="http://www.whatarecookies.com/enable.asp" target="_blank">', |
|
| 1596 | - '</a>' |
|
| 1597 | - ) |
|
| 1598 | - ); |
|
| 1599 | - } |
|
| 1600 | - $this->checkout->registration_form = new EE_Form_Section_Proper( |
|
| 1601 | - array( |
|
| 1602 | - 'name' => 'single-page-checkout', |
|
| 1603 | - 'html_id' => 'ee-single-page-checkout-dv', |
|
| 1604 | - 'layout_strategy' => |
|
| 1605 | - new EE_Template_Layout( |
|
| 1606 | - array( |
|
| 1607 | - 'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php', |
|
| 1608 | - 'template_args' => array( |
|
| 1609 | - 'empty_cart' => $empty_cart, |
|
| 1610 | - 'revisit' => $this->checkout->revisit, |
|
| 1611 | - 'reg_steps' => $this->checkout->reg_steps, |
|
| 1612 | - 'next_step' => $this->checkout->next_step instanceof EE_SPCO_Reg_Step |
|
| 1613 | - ? $this->checkout->next_step->slug() |
|
| 1614 | - : '', |
|
| 1615 | - 'empty_msg' => apply_filters( |
|
| 1616 | - 'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg', |
|
| 1617 | - sprintf( |
|
| 1618 | - __( |
|
| 1619 | - 'You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', |
|
| 1620 | - 'event_espresso' |
|
| 1621 | - ), |
|
| 1622 | - '<a href="' |
|
| 1623 | - . get_post_type_archive_link('espresso_events') |
|
| 1624 | - . '" title="', |
|
| 1625 | - '">', |
|
| 1626 | - '</a>' |
|
| 1627 | - ) |
|
| 1628 | - ), |
|
| 1629 | - 'cookies_not_set_msg' => $cookies_not_set_msg, |
|
| 1630 | - 'registration_time_limit' => $this->checkout->get_registration_time_limit(), |
|
| 1631 | - 'session_expiration' => gmdate( |
|
| 1632 | - 'M d, Y H:i:s', |
|
| 1633 | - EE_Registry::instance()->SSN->expiration() |
|
| 1634 | - + (get_option('gmt_offset') * HOUR_IN_SECONDS) |
|
| 1635 | - ), |
|
| 1636 | - ), |
|
| 1637 | - ) |
|
| 1638 | - ), |
|
| 1639 | - ) |
|
| 1640 | - ); |
|
| 1641 | - // load template and add to output sent that gets filtered into the_content() |
|
| 1642 | - EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html()); |
|
| 1643 | - } |
|
| 1644 | - } |
|
| 1645 | - |
|
| 1646 | - |
|
| 1647 | - |
|
| 1648 | - /** |
|
| 1649 | - * add_extra_finalize_registration_inputs |
|
| 1650 | - * |
|
| 1651 | - * @access public |
|
| 1652 | - * @param $next_step |
|
| 1653 | - * @internal param string $label |
|
| 1654 | - * @return void |
|
| 1655 | - */ |
|
| 1656 | - public function add_extra_finalize_registration_inputs($next_step) |
|
| 1657 | - { |
|
| 1658 | - if ($next_step === 'finalize_registration') { |
|
| 1659 | - echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>'; |
|
| 1660 | - } |
|
| 1661 | - } |
|
| 1662 | - |
|
| 1663 | - |
|
| 1664 | - |
|
| 1665 | - /** |
|
| 1666 | - * display_registration_footer |
|
| 1667 | - * |
|
| 1668 | - * @access public |
|
| 1669 | - * @return string |
|
| 1670 | - */ |
|
| 1671 | - public static function display_registration_footer() |
|
| 1672 | - { |
|
| 1673 | - if ( |
|
| 1674 | - apply_filters( |
|
| 1675 | - 'FHEE__EE_Front__Controller__show_reg_footer', |
|
| 1676 | - EE_Registry::instance()->CFG->admin->show_reg_footer |
|
| 1677 | - ) |
|
| 1678 | - ) { |
|
| 1679 | - add_filter( |
|
| 1680 | - 'FHEE__EEH_Template__powered_by_event_espresso__url', |
|
| 1681 | - function ($url) { |
|
| 1682 | - return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url); |
|
| 1683 | - } |
|
| 1684 | - ); |
|
| 1685 | - echo apply_filters( |
|
| 1686 | - 'FHEE__EE_Front_Controller__display_registration_footer', |
|
| 1687 | - \EEH_Template::powered_by_event_espresso( |
|
| 1688 | - '', |
|
| 1689 | - 'espresso-registration-footer-dv', |
|
| 1690 | - array('utm_content' => 'registration_checkout') |
|
| 1691 | - ) |
|
| 1692 | - ); |
|
| 1693 | - } |
|
| 1694 | - return ''; |
|
| 1695 | - } |
|
| 1696 | - |
|
| 1697 | - |
|
| 1698 | - |
|
| 1699 | - /** |
|
| 1700 | - * unlock_transaction |
|
| 1701 | - * |
|
| 1702 | - * @access public |
|
| 1703 | - * @return void |
|
| 1704 | - * @throws EE_Error |
|
| 1705 | - */ |
|
| 1706 | - public function unlock_transaction() |
|
| 1707 | - { |
|
| 1708 | - if ($this->checkout->transaction instanceof EE_Transaction) { |
|
| 1709 | - $this->checkout->transaction->unlock(); |
|
| 1710 | - } |
|
| 1711 | - } |
|
| 1712 | - |
|
| 1713 | - |
|
| 1714 | - |
|
| 1715 | - /** |
|
| 1716 | - * _setup_redirect |
|
| 1717 | - * |
|
| 1718 | - * @access private |
|
| 1719 | - * @return void |
|
| 1720 | - */ |
|
| 1721 | - private function _setup_redirect() |
|
| 1722 | - { |
|
| 1723 | - if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
| 1724 | - $this->checkout->redirect = true; |
|
| 1725 | - if (empty($this->checkout->redirect_url)) { |
|
| 1726 | - $this->checkout->redirect_url = $this->checkout->next_step->reg_step_url(); |
|
| 1727 | - } |
|
| 1728 | - $this->checkout->redirect_url = apply_filters( |
|
| 1729 | - 'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', |
|
| 1730 | - $this->checkout->redirect_url, |
|
| 1731 | - $this->checkout |
|
| 1732 | - ); |
|
| 1733 | - } |
|
| 1734 | - } |
|
| 1735 | - |
|
| 1736 | - |
|
| 1737 | - |
|
| 1738 | - /** |
|
| 1739 | - * handle ajax message responses and redirects |
|
| 1740 | - * |
|
| 1741 | - * @access public |
|
| 1742 | - * @return void |
|
| 1743 | - * @throws EE_Error |
|
| 1744 | - */ |
|
| 1745 | - public function go_to_next_step() |
|
| 1746 | - { |
|
| 1747 | - if (EE_Registry::instance()->REQ->ajax) { |
|
| 1748 | - // capture contents of output buffer we started earlier in the request, and insert into JSON response |
|
| 1749 | - $this->checkout->json_response->set_unexpected_errors(ob_get_clean()); |
|
| 1750 | - } |
|
| 1751 | - $this->unlock_transaction(); |
|
| 1752 | - // just return for these conditions |
|
| 1753 | - if ( |
|
| 1754 | - $this->checkout->admin_request |
|
| 1755 | - || $this->checkout->action === 'redirect_form' |
|
| 1756 | - || $this->checkout->action === 'update_checkout' |
|
| 1757 | - ) { |
|
| 1758 | - return; |
|
| 1759 | - } |
|
| 1760 | - // AJAX response |
|
| 1761 | - $this->_handle_json_response(); |
|
| 1762 | - // redirect to next step or the Thank You page |
|
| 1763 | - $this->_handle_html_redirects(); |
|
| 1764 | - // hmmm... must be something wrong, so let's just display the form again ! |
|
| 1765 | - $this->_display_spco_reg_form(); |
|
| 1766 | - } |
|
| 1767 | - |
|
| 1768 | - |
|
| 1769 | - |
|
| 1770 | - /** |
|
| 1771 | - * _handle_json_response |
|
| 1772 | - * |
|
| 1773 | - * @access protected |
|
| 1774 | - * @return void |
|
| 1775 | - */ |
|
| 1776 | - protected function _handle_json_response() |
|
| 1777 | - { |
|
| 1778 | - // if this is an ajax request |
|
| 1779 | - if (EE_Registry::instance()->REQ->ajax) { |
|
| 1780 | - // DEBUG LOG |
|
| 1781 | - //$this->checkout->log( |
|
| 1782 | - // __CLASS__, __FUNCTION__, __LINE__, |
|
| 1783 | - // array( |
|
| 1784 | - // 'json_response_redirect_url' => $this->checkout->json_response->redirect_url(), |
|
| 1785 | - // 'redirect' => $this->checkout->redirect, |
|
| 1786 | - // 'continue_reg' => $this->checkout->continue_reg, |
|
| 1787 | - // ) |
|
| 1788 | - //); |
|
| 1789 | - $this->checkout->json_response->set_registration_time_limit( |
|
| 1790 | - $this->checkout->get_registration_time_limit() |
|
| 1791 | - ); |
|
| 1792 | - $this->checkout->json_response->set_payment_amount($this->checkout->amount_owing); |
|
| 1793 | - // just send the ajax ( |
|
| 1794 | - $json_response = apply_filters( |
|
| 1795 | - 'FHEE__EE_Single_Page_Checkout__JSON_response', |
|
| 1796 | - $this->checkout->json_response |
|
| 1797 | - ); |
|
| 1798 | - echo $json_response; |
|
| 1799 | - exit(); |
|
| 1800 | - } |
|
| 1801 | - } |
|
| 1802 | - |
|
| 1803 | - |
|
| 1804 | - |
|
| 1805 | - /** |
|
| 1806 | - * _handle_redirects |
|
| 1807 | - * |
|
| 1808 | - * @access protected |
|
| 1809 | - * @return void |
|
| 1810 | - */ |
|
| 1811 | - protected function _handle_html_redirects() |
|
| 1812 | - { |
|
| 1813 | - // going somewhere ? |
|
| 1814 | - if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) { |
|
| 1815 | - // store notices in a transient |
|
| 1816 | - EE_Error::get_notices(false, true, true); |
|
| 1817 | - // DEBUG LOG |
|
| 1818 | - //$this->checkout->log( |
|
| 1819 | - // __CLASS__, __FUNCTION__, __LINE__, |
|
| 1820 | - // array( |
|
| 1821 | - // 'headers_sent' => headers_sent(), |
|
| 1822 | - // 'redirect_url' => $this->checkout->redirect_url, |
|
| 1823 | - // 'headers_list' => headers_list(), |
|
| 1824 | - // ) |
|
| 1825 | - //); |
|
| 1826 | - wp_safe_redirect($this->checkout->redirect_url); |
|
| 1827 | - exit(); |
|
| 1828 | - } |
|
| 1829 | - } |
|
| 1830 | - |
|
| 1831 | - |
|
| 1832 | - |
|
| 1833 | - /** |
|
| 1834 | - * set_checkout_anchor |
|
| 1835 | - * |
|
| 1836 | - * @access public |
|
| 1837 | - * @return void |
|
| 1838 | - */ |
|
| 1839 | - public function set_checkout_anchor() |
|
| 1840 | - { |
|
| 1841 | - echo '<a id="checkout" style="float: left; margin-left: -999em;"></a>'; |
|
| 1842 | - } |
|
| 1843 | - |
|
| 1844 | - /** |
|
| 1845 | - * getRegistrationExpirationNotice |
|
| 1846 | - * |
|
| 1847 | - * @since 4.9.59.p |
|
| 1848 | - * @access public |
|
| 1849 | - * @return string |
|
| 1850 | - */ |
|
| 1851 | - public static function getRegistrationExpirationNotice() |
|
| 1852 | - { |
|
| 1853 | - return sprintf( |
|
| 1854 | - __('%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please accept our apologies for any inconvenience this may have caused.%8$s', |
|
| 1855 | - 'event_espresso'), |
|
| 1856 | - '<h4 class="important-notice">', |
|
| 1857 | - '</h4>', |
|
| 1858 | - '<br />', |
|
| 1859 | - '<p>', |
|
| 1860 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" title="', |
|
| 1861 | - '">', |
|
| 1862 | - '</a>', |
|
| 1863 | - '</p>' |
|
| 1864 | - ); |
|
| 1865 | - } |
|
| 23 | + /** |
|
| 24 | + * $_initialized - has the SPCO controller already been initialized ? |
|
| 25 | + * |
|
| 26 | + * @access private |
|
| 27 | + * @var bool $_initialized |
|
| 28 | + */ |
|
| 29 | + private static $_initialized = false; |
|
| 30 | + |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * $_checkout_verified - is the EE_Checkout verified as correct for this request ? |
|
| 34 | + * |
|
| 35 | + * @access private |
|
| 36 | + * @var bool $_valid_checkout |
|
| 37 | + */ |
|
| 38 | + private static $_checkout_verified = true; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * $_reg_steps_array - holds initial array of reg steps |
|
| 42 | + * |
|
| 43 | + * @access private |
|
| 44 | + * @var array $_reg_steps_array |
|
| 45 | + */ |
|
| 46 | + private static $_reg_steps_array = array(); |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * $checkout - EE_Checkout object for handling the properties of the current checkout process |
|
| 50 | + * |
|
| 51 | + * @access public |
|
| 52 | + * @var EE_Checkout $checkout |
|
| 53 | + */ |
|
| 54 | + public $checkout; |
|
| 55 | + |
|
| 56 | + |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * @return EED_Module|EED_Single_Page_Checkout |
|
| 60 | + */ |
|
| 61 | + public static function instance() |
|
| 62 | + { |
|
| 63 | + add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true'); |
|
| 64 | + return parent::get_instance(__CLASS__); |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * @return EE_CART |
|
| 71 | + */ |
|
| 72 | + public function cart() |
|
| 73 | + { |
|
| 74 | + return $this->checkout->cart; |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * @return EE_Transaction |
|
| 81 | + */ |
|
| 82 | + public function transaction() |
|
| 83 | + { |
|
| 84 | + return $this->checkout->transaction; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
| 91 | + * |
|
| 92 | + * @access public |
|
| 93 | + * @return void |
|
| 94 | + * @throws EE_Error |
|
| 95 | + */ |
|
| 96 | + public static function set_hooks() |
|
| 97 | + { |
|
| 98 | + EED_Single_Page_Checkout::set_definitions(); |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
| 105 | + * |
|
| 106 | + * @access public |
|
| 107 | + * @return void |
|
| 108 | + * @throws EE_Error |
|
| 109 | + */ |
|
| 110 | + public static function set_hooks_admin() |
|
| 111 | + { |
|
| 112 | + EED_Single_Page_Checkout::set_definitions(); |
|
| 113 | + if ( ! (defined('DOING_AJAX') && DOING_AJAX)) { |
|
| 114 | + return; |
|
| 115 | + } |
|
| 116 | + // going to start an output buffer in case anything gets accidentally output |
|
| 117 | + // that might disrupt our JSON response |
|
| 118 | + ob_start(); |
|
| 119 | + EED_Single_Page_Checkout::load_request_handler(); |
|
| 120 | + EED_Single_Page_Checkout::load_reg_steps(); |
|
| 121 | + // set ajax hooks |
|
| 122 | + add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
| 123 | + add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
| 124 | + add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
| 125 | + add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
| 126 | + add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
| 127 | + add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * process ajax request |
|
| 134 | + * |
|
| 135 | + * @param string $ajax_action |
|
| 136 | + * @throws EE_Error |
|
| 137 | + */ |
|
| 138 | + public static function process_ajax_request($ajax_action) |
|
| 139 | + { |
|
| 140 | + EE_Registry::instance()->REQ->set('action', $ajax_action); |
|
| 141 | + EED_Single_Page_Checkout::instance()->_initialize(); |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + |
|
| 145 | + |
|
| 146 | + /** |
|
| 147 | + * ajax display registration step |
|
| 148 | + * |
|
| 149 | + * @throws EE_Error |
|
| 150 | + */ |
|
| 151 | + public static function display_reg_step() |
|
| 152 | + { |
|
| 153 | + EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step'); |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + |
|
| 157 | + |
|
| 158 | + /** |
|
| 159 | + * ajax process registration step |
|
| 160 | + * |
|
| 161 | + * @throws EE_Error |
|
| 162 | + */ |
|
| 163 | + public static function process_reg_step() |
|
| 164 | + { |
|
| 165 | + EED_Single_Page_Checkout::process_ajax_request('process_reg_step'); |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + |
|
| 169 | + |
|
| 170 | + /** |
|
| 171 | + * ajax process registration step |
|
| 172 | + * |
|
| 173 | + * @throws EE_Error |
|
| 174 | + */ |
|
| 175 | + public static function update_reg_step() |
|
| 176 | + { |
|
| 177 | + EED_Single_Page_Checkout::process_ajax_request('update_reg_step'); |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + |
|
| 181 | + |
|
| 182 | + /** |
|
| 183 | + * update_checkout |
|
| 184 | + * |
|
| 185 | + * @access public |
|
| 186 | + * @return void |
|
| 187 | + * @throws EE_Error |
|
| 188 | + */ |
|
| 189 | + public static function update_checkout() |
|
| 190 | + { |
|
| 191 | + EED_Single_Page_Checkout::process_ajax_request('update_checkout'); |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + |
|
| 195 | + |
|
| 196 | + /** |
|
| 197 | + * load_request_handler |
|
| 198 | + * |
|
| 199 | + * @access public |
|
| 200 | + * @return void |
|
| 201 | + */ |
|
| 202 | + public static function load_request_handler() |
|
| 203 | + { |
|
| 204 | + // load core Request_Handler class |
|
| 205 | + if (EE_Registry::instance()->REQ !== null) { |
|
| 206 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
| 207 | + } |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + |
|
| 211 | + |
|
| 212 | + /** |
|
| 213 | + * set_definitions |
|
| 214 | + * |
|
| 215 | + * @access public |
|
| 216 | + * @return void |
|
| 217 | + * @throws EE_Error |
|
| 218 | + */ |
|
| 219 | + public static function set_definitions() |
|
| 220 | + { |
|
| 221 | + if(defined('SPCO_BASE_PATH')) { |
|
| 222 | + return; |
|
| 223 | + } |
|
| 224 | + define( |
|
| 225 | + 'SPCO_BASE_PATH', |
|
| 226 | + rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS) . DS |
|
| 227 | + ); |
|
| 228 | + define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css' . DS); |
|
| 229 | + define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img' . DS); |
|
| 230 | + define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js' . DS); |
|
| 231 | + define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS); |
|
| 232 | + define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS); |
|
| 233 | + define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS); |
|
| 234 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true); |
|
| 235 | + EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice(); |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + |
|
| 239 | + |
|
| 240 | + /** |
|
| 241 | + * load_reg_steps |
|
| 242 | + * loads and instantiates each reg step based on the EE_Registry::instance()->CFG->registration->reg_steps array |
|
| 243 | + * |
|
| 244 | + * @access private |
|
| 245 | + * @throws EE_Error |
|
| 246 | + */ |
|
| 247 | + public static function load_reg_steps() |
|
| 248 | + { |
|
| 249 | + static $reg_steps_loaded = false; |
|
| 250 | + if ($reg_steps_loaded) { |
|
| 251 | + return; |
|
| 252 | + } |
|
| 253 | + // filter list of reg_steps |
|
| 254 | + $reg_steps_to_load = (array)apply_filters( |
|
| 255 | + 'AHEE__SPCO__load_reg_steps__reg_steps_to_load', |
|
| 256 | + EED_Single_Page_Checkout::get_reg_steps() |
|
| 257 | + ); |
|
| 258 | + // sort by key (order) |
|
| 259 | + ksort($reg_steps_to_load); |
|
| 260 | + // loop through folders |
|
| 261 | + foreach ($reg_steps_to_load as $order => $reg_step) { |
|
| 262 | + // we need a |
|
| 263 | + if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
| 264 | + // copy over to the reg_steps_array |
|
| 265 | + EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step; |
|
| 266 | + // register custom key route for each reg step |
|
| 267 | + // ie: step=>"slug" - this is the entire reason we load the reg steps array now |
|
| 268 | + EE_Config::register_route( |
|
| 269 | + $reg_step['slug'], |
|
| 270 | + 'EED_Single_Page_Checkout', |
|
| 271 | + 'run', |
|
| 272 | + 'step' |
|
| 273 | + ); |
|
| 274 | + // add AJAX or other hooks |
|
| 275 | + if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) { |
|
| 276 | + // setup autoloaders if necessary |
|
| 277 | + if ( ! class_exists($reg_step['class_name'])) { |
|
| 278 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder( |
|
| 279 | + $reg_step['file_path'], |
|
| 280 | + true |
|
| 281 | + ); |
|
| 282 | + } |
|
| 283 | + if (is_callable($reg_step['class_name'], 'set_hooks')) { |
|
| 284 | + call_user_func(array($reg_step['class_name'], 'set_hooks')); |
|
| 285 | + } |
|
| 286 | + } |
|
| 287 | + } |
|
| 288 | + } |
|
| 289 | + $reg_steps_loaded = true; |
|
| 290 | + } |
|
| 291 | + |
|
| 292 | + |
|
| 293 | + |
|
| 294 | + /** |
|
| 295 | + * get_reg_steps |
|
| 296 | + * |
|
| 297 | + * @access public |
|
| 298 | + * @return array |
|
| 299 | + */ |
|
| 300 | + public static function get_reg_steps() |
|
| 301 | + { |
|
| 302 | + $reg_steps = EE_Registry::instance()->CFG->registration->reg_steps; |
|
| 303 | + if (empty($reg_steps)) { |
|
| 304 | + $reg_steps = array( |
|
| 305 | + 10 => array( |
|
| 306 | + 'file_path' => SPCO_REG_STEPS_PATH . 'attendee_information', |
|
| 307 | + 'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information', |
|
| 308 | + 'slug' => 'attendee_information', |
|
| 309 | + 'has_hooks' => false, |
|
| 310 | + ), |
|
| 311 | + 20 => array( |
|
| 312 | + 'file_path' => SPCO_REG_STEPS_PATH . 'registration_confirmation', |
|
| 313 | + 'class_name' => 'EE_SPCO_Reg_Step_Registration_Confirmation', |
|
| 314 | + 'slug' => 'registration_confirmation', |
|
| 315 | + 'has_hooks' => false, |
|
| 316 | + ), |
|
| 317 | + 30 => array( |
|
| 318 | + 'file_path' => SPCO_REG_STEPS_PATH . 'payment_options', |
|
| 319 | + 'class_name' => 'EE_SPCO_Reg_Step_Payment_Options', |
|
| 320 | + 'slug' => 'payment_options', |
|
| 321 | + 'has_hooks' => true, |
|
| 322 | + ), |
|
| 323 | + 999 => array( |
|
| 324 | + 'file_path' => SPCO_REG_STEPS_PATH . 'finalize_registration', |
|
| 325 | + 'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration', |
|
| 326 | + 'slug' => 'finalize_registration', |
|
| 327 | + 'has_hooks' => false, |
|
| 328 | + ), |
|
| 329 | + ); |
|
| 330 | + } |
|
| 331 | + return $reg_steps; |
|
| 332 | + } |
|
| 333 | + |
|
| 334 | + |
|
| 335 | + |
|
| 336 | + /** |
|
| 337 | + * registration_checkout_for_admin |
|
| 338 | + * |
|
| 339 | + * @access public |
|
| 340 | + * @return string |
|
| 341 | + * @throws EE_Error |
|
| 342 | + */ |
|
| 343 | + public static function registration_checkout_for_admin() |
|
| 344 | + { |
|
| 345 | + EED_Single_Page_Checkout::load_request_handler(); |
|
| 346 | + EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
| 347 | + EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step'); |
|
| 348 | + EE_Registry::instance()->REQ->set('process_form_submission', false); |
|
| 349 | + EED_Single_Page_Checkout::instance()->_initialize(); |
|
| 350 | + EED_Single_Page_Checkout::instance()->_display_spco_reg_form(); |
|
| 351 | + return EE_Registry::instance()->REQ->get_output(); |
|
| 352 | + } |
|
| 353 | + |
|
| 354 | + |
|
| 355 | + |
|
| 356 | + /** |
|
| 357 | + * process_registration_from_admin |
|
| 358 | + * |
|
| 359 | + * @access public |
|
| 360 | + * @return \EE_Transaction |
|
| 361 | + * @throws EE_Error |
|
| 362 | + */ |
|
| 363 | + public static function process_registration_from_admin() |
|
| 364 | + { |
|
| 365 | + EED_Single_Page_Checkout::load_request_handler(); |
|
| 366 | + EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
| 367 | + EE_Registry::instance()->REQ->set('action', 'process_reg_step'); |
|
| 368 | + EE_Registry::instance()->REQ->set('process_form_submission', true); |
|
| 369 | + EED_Single_Page_Checkout::instance()->_initialize(); |
|
| 370 | + if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) { |
|
| 371 | + $final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps); |
|
| 372 | + if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) { |
|
| 373 | + EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step); |
|
| 374 | + if ($final_reg_step->process_reg_step()) { |
|
| 375 | + $final_reg_step->set_completed(); |
|
| 376 | + EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array(); |
|
| 377 | + return EED_Single_Page_Checkout::instance()->checkout->transaction; |
|
| 378 | + } |
|
| 379 | + } |
|
| 380 | + } |
|
| 381 | + return null; |
|
| 382 | + } |
|
| 383 | + |
|
| 384 | + |
|
| 385 | + |
|
| 386 | + /** |
|
| 387 | + * run |
|
| 388 | + * |
|
| 389 | + * @access public |
|
| 390 | + * @param WP_Query $WP_Query |
|
| 391 | + * @return void |
|
| 392 | + * @throws EE_Error |
|
| 393 | + */ |
|
| 394 | + public function run($WP_Query) |
|
| 395 | + { |
|
| 396 | + if ( |
|
| 397 | + $WP_Query instanceof WP_Query |
|
| 398 | + && $WP_Query->is_main_query() |
|
| 399 | + && apply_filters('FHEE__EED_Single_Page_Checkout__run', true) |
|
| 400 | + && $this->_is_reg_checkout() |
|
| 401 | + ) { |
|
| 402 | + $this->_initialize(); |
|
| 403 | + } |
|
| 404 | + } |
|
| 405 | + |
|
| 406 | + |
|
| 407 | + |
|
| 408 | + /** |
|
| 409 | + * determines whether current url matches reg page url |
|
| 410 | + * |
|
| 411 | + * @return bool |
|
| 412 | + */ |
|
| 413 | + protected function _is_reg_checkout() |
|
| 414 | + { |
|
| 415 | + // get current permalink for reg page without any extra query args |
|
| 416 | + $reg_page_url = \get_permalink(EE_Config::instance()->core->reg_page_id); |
|
| 417 | + // get request URI for current request, but without the scheme or host |
|
| 418 | + $current_request_uri = \EEH_URL::filter_input_server_url('REQUEST_URI'); |
|
| 419 | + $current_request_uri = html_entity_decode($current_request_uri); |
|
| 420 | + // get array of query args from the current request URI |
|
| 421 | + $query_args = \EEH_URL::get_query_string($current_request_uri); |
|
| 422 | + // grab page id if it is set |
|
| 423 | + $page_id = isset($query_args['page_id']) ? absint($query_args['page_id']) : 0; |
|
| 424 | + // and remove the page id from the query args (we will re-add it later) |
|
| 425 | + unset($query_args['page_id']); |
|
| 426 | + // now strip all query args from current request URI |
|
| 427 | + $current_request_uri = remove_query_arg(array_keys($query_args), $current_request_uri); |
|
| 428 | + // and re-add the page id if it was set |
|
| 429 | + if ($page_id) { |
|
| 430 | + $current_request_uri = add_query_arg('page_id', $page_id, $current_request_uri); |
|
| 431 | + } |
|
| 432 | + // remove slashes and ? |
|
| 433 | + $current_request_uri = trim($current_request_uri, '?/'); |
|
| 434 | + // is current request URI part of the known full reg page URL ? |
|
| 435 | + return ! empty($current_request_uri) && strpos($reg_page_url, $current_request_uri) !== false; |
|
| 436 | + } |
|
| 437 | + |
|
| 438 | + |
|
| 439 | + |
|
| 440 | + /** |
|
| 441 | + * @param WP_Query $wp_query |
|
| 442 | + * @return void |
|
| 443 | + * @throws EE_Error |
|
| 444 | + */ |
|
| 445 | + public static function init($wp_query) |
|
| 446 | + { |
|
| 447 | + EED_Single_Page_Checkout::instance()->run($wp_query); |
|
| 448 | + } |
|
| 449 | + |
|
| 450 | + |
|
| 451 | + |
|
| 452 | + /** |
|
| 453 | + * _initialize - initial module setup |
|
| 454 | + * |
|
| 455 | + * @access private |
|
| 456 | + * @throws EE_Error |
|
| 457 | + * @return void |
|
| 458 | + */ |
|
| 459 | + private function _initialize() |
|
| 460 | + { |
|
| 461 | + // ensure SPCO doesn't run twice |
|
| 462 | + if (EED_Single_Page_Checkout::$_initialized) { |
|
| 463 | + return; |
|
| 464 | + } |
|
| 465 | + try { |
|
| 466 | + EED_Single_Page_Checkout::load_reg_steps(); |
|
| 467 | + $this->_verify_session(); |
|
| 468 | + // setup the EE_Checkout object |
|
| 469 | + $this->checkout = $this->_initialize_checkout(); |
|
| 470 | + // filter checkout |
|
| 471 | + $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout); |
|
| 472 | + // get the $_GET |
|
| 473 | + $this->_get_request_vars(); |
|
| 474 | + if ($this->_block_bots()) { |
|
| 475 | + return; |
|
| 476 | + } |
|
| 477 | + // filter continue_reg |
|
| 478 | + $this->checkout->continue_reg = apply_filters( |
|
| 479 | + 'FHEE__EED_Single_Page_Checkout__init___continue_reg', |
|
| 480 | + true, |
|
| 481 | + $this->checkout |
|
| 482 | + ); |
|
| 483 | + // load the reg steps array |
|
| 484 | + if ( ! $this->_load_and_instantiate_reg_steps()) { |
|
| 485 | + EED_Single_Page_Checkout::$_initialized = true; |
|
| 486 | + return; |
|
| 487 | + } |
|
| 488 | + // set the current step |
|
| 489 | + $this->checkout->set_current_step($this->checkout->step); |
|
| 490 | + // and the next step |
|
| 491 | + $this->checkout->set_next_step(); |
|
| 492 | + // verify that everything has been setup correctly |
|
| 493 | + if ( ! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) { |
|
| 494 | + EED_Single_Page_Checkout::$_initialized = true; |
|
| 495 | + return; |
|
| 496 | + } |
|
| 497 | + // lock the transaction |
|
| 498 | + $this->checkout->transaction->lock(); |
|
| 499 | + // make sure all of our cached objects are added to their respective model entity mappers |
|
| 500 | + $this->checkout->refresh_all_entities(); |
|
| 501 | + // set amount owing |
|
| 502 | + $this->checkout->amount_owing = $this->checkout->transaction->remaining(); |
|
| 503 | + // initialize each reg step, which gives them the chance to potentially alter the process |
|
| 504 | + $this->_initialize_reg_steps(); |
|
| 505 | + // DEBUG LOG |
|
| 506 | + //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
|
| 507 | + // get reg form |
|
| 508 | + if( ! $this->_check_form_submission()) { |
|
| 509 | + EED_Single_Page_Checkout::$_initialized = true; |
|
| 510 | + return; |
|
| 511 | + } |
|
| 512 | + // checkout the action!!! |
|
| 513 | + $this->_process_form_action(); |
|
| 514 | + // add some style and make it dance |
|
| 515 | + $this->add_styles_and_scripts(); |
|
| 516 | + // kk... SPCO has successfully run |
|
| 517 | + EED_Single_Page_Checkout::$_initialized = true; |
|
| 518 | + // set no cache headers and constants |
|
| 519 | + EE_System::do_not_cache(); |
|
| 520 | + // add anchor |
|
| 521 | + add_action('loop_start', array($this, 'set_checkout_anchor'), 1); |
|
| 522 | + // remove transaction lock |
|
| 523 | + add_action('shutdown', array($this, 'unlock_transaction'), 1); |
|
| 524 | + } catch (Exception $e) { |
|
| 525 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
| 526 | + } |
|
| 527 | + } |
|
| 528 | + |
|
| 529 | + |
|
| 530 | + |
|
| 531 | + /** |
|
| 532 | + * _verify_session |
|
| 533 | + * checks that the session is valid and not expired |
|
| 534 | + * |
|
| 535 | + * @access private |
|
| 536 | + * @throws EE_Error |
|
| 537 | + */ |
|
| 538 | + private function _verify_session() |
|
| 539 | + { |
|
| 540 | + if ( ! EE_Registry::instance()->SSN instanceof EE_Session) { |
|
| 541 | + throw new EE_Error(__('The EE_Session class could not be loaded.', 'event_espresso')); |
|
| 542 | + } |
|
| 543 | + $clear_session_requested = filter_var( |
|
| 544 | + EE_Registry::instance()->REQ->get('clear_session', false), |
|
| 545 | + FILTER_VALIDATE_BOOLEAN |
|
| 546 | + ); |
|
| 547 | + // is session still valid ? |
|
| 548 | + if ($clear_session_requested |
|
| 549 | + || ( EE_Registry::instance()->SSN->expired() |
|
| 550 | + && EE_Registry::instance()->REQ->get('e_reg_url_link', '') === '' |
|
| 551 | + ) |
|
| 552 | + ) { |
|
| 553 | + $this->checkout = new EE_Checkout(); |
|
| 554 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 555 | + // EE_Registry::instance()->SSN->reset_cart(); |
|
| 556 | + // EE_Registry::instance()->SSN->reset_checkout(); |
|
| 557 | + // EE_Registry::instance()->SSN->reset_transaction(); |
|
| 558 | + if (! $clear_session_requested) { |
|
| 559 | + EE_Error::add_attention( |
|
| 560 | + EE_Registry::$i18n_js_strings['registration_expiration_notice'], |
|
| 561 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 562 | + ); |
|
| 563 | + } |
|
| 564 | + // EE_Registry::instance()->SSN->reset_expired(); |
|
| 565 | + } |
|
| 566 | + } |
|
| 567 | + |
|
| 568 | + |
|
| 569 | + |
|
| 570 | + /** |
|
| 571 | + * _initialize_checkout |
|
| 572 | + * loads and instantiates EE_Checkout |
|
| 573 | + * |
|
| 574 | + * @access private |
|
| 575 | + * @throws EE_Error |
|
| 576 | + * @return EE_Checkout |
|
| 577 | + */ |
|
| 578 | + private function _initialize_checkout() |
|
| 579 | + { |
|
| 580 | + // look in session for existing checkout |
|
| 581 | + /** @type EE_Checkout $checkout */ |
|
| 582 | + $checkout = EE_Registry::instance()->SSN->checkout(); |
|
| 583 | + // verify |
|
| 584 | + if ( ! $checkout instanceof EE_Checkout) { |
|
| 585 | + // instantiate EE_Checkout object for handling the properties of the current checkout process |
|
| 586 | + $checkout = EE_Registry::instance()->load_file( |
|
| 587 | + SPCO_INC_PATH, |
|
| 588 | + 'EE_Checkout', |
|
| 589 | + 'class', array(), |
|
| 590 | + false |
|
| 591 | + ); |
|
| 592 | + } else { |
|
| 593 | + if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) { |
|
| 594 | + $this->unlock_transaction(); |
|
| 595 | + wp_safe_redirect($checkout->redirect_url); |
|
| 596 | + exit(); |
|
| 597 | + } |
|
| 598 | + } |
|
| 599 | + $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout); |
|
| 600 | + // verify again |
|
| 601 | + if ( ! $checkout instanceof EE_Checkout) { |
|
| 602 | + throw new EE_Error(__('The EE_Checkout class could not be loaded.', 'event_espresso')); |
|
| 603 | + } |
|
| 604 | + // reset anything that needs a clean slate for each request |
|
| 605 | + $checkout->reset_for_current_request(); |
|
| 606 | + return $checkout; |
|
| 607 | + } |
|
| 608 | + |
|
| 609 | + |
|
| 610 | + |
|
| 611 | + /** |
|
| 612 | + * _get_request_vars |
|
| 613 | + * |
|
| 614 | + * @access private |
|
| 615 | + * @return void |
|
| 616 | + * @throws EE_Error |
|
| 617 | + */ |
|
| 618 | + private function _get_request_vars() |
|
| 619 | + { |
|
| 620 | + // load classes |
|
| 621 | + EED_Single_Page_Checkout::load_request_handler(); |
|
| 622 | + //make sure this request is marked as belonging to EE |
|
| 623 | + EE_Registry::instance()->REQ->set_espresso_page(true); |
|
| 624 | + // which step is being requested ? |
|
| 625 | + $this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step()); |
|
| 626 | + // which step is being edited ? |
|
| 627 | + $this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', ''); |
|
| 628 | + // and what we're doing on the current step |
|
| 629 | + $this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step'); |
|
| 630 | + // timestamp |
|
| 631 | + $this->checkout->uts = EE_Registry::instance()->REQ->get('uts', 0); |
|
| 632 | + // returning to edit ? |
|
| 633 | + $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', ''); |
|
| 634 | + // add reg url link to registration query params |
|
| 635 | + if ($this->checkout->reg_url_link && strpos($this->checkout->reg_url_link, '1-') !== 0) { |
|
| 636 | + $this->checkout->reg_cache_where_params[0]['REG_url_link'] = $this->checkout->reg_url_link; |
|
| 637 | + } |
|
| 638 | + // or some other kind of revisit ? |
|
| 639 | + $this->checkout->revisit = filter_var( |
|
| 640 | + EE_Registry::instance()->REQ->get('revisit', false), |
|
| 641 | + FILTER_VALIDATE_BOOLEAN |
|
| 642 | + ); |
|
| 643 | + // and whether or not to generate a reg form for this request |
|
| 644 | + $this->checkout->generate_reg_form = filter_var( |
|
| 645 | + EE_Registry::instance()->REQ->get('generate_reg_form', true), |
|
| 646 | + FILTER_VALIDATE_BOOLEAN |
|
| 647 | + ); |
|
| 648 | + // and whether or not to process a reg form submission for this request |
|
| 649 | + $this->checkout->process_form_submission = filter_var( |
|
| 650 | + EE_Registry::instance()->REQ->get( |
|
| 651 | + 'process_form_submission', |
|
| 652 | + $this->checkout->action === 'process_reg_step' |
|
| 653 | + ), |
|
| 654 | + FILTER_VALIDATE_BOOLEAN |
|
| 655 | + ); |
|
| 656 | + $this->checkout->process_form_submission = filter_var( |
|
| 657 | + $this->checkout->action !== 'display_spco_reg_step' |
|
| 658 | + ? $this->checkout->process_form_submission |
|
| 659 | + : false, |
|
| 660 | + FILTER_VALIDATE_BOOLEAN |
|
| 661 | + ); |
|
| 662 | + // $this->_display_request_vars(); |
|
| 663 | + } |
|
| 664 | + |
|
| 665 | + |
|
| 666 | + |
|
| 667 | + /** |
|
| 668 | + * _display_request_vars |
|
| 669 | + * |
|
| 670 | + * @access protected |
|
| 671 | + * @return void |
|
| 672 | + */ |
|
| 673 | + protected function _display_request_vars() |
|
| 674 | + { |
|
| 675 | + if ( ! WP_DEBUG) { |
|
| 676 | + return; |
|
| 677 | + } |
|
| 678 | + EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__); |
|
| 679 | + EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__); |
|
| 680 | + EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__); |
|
| 681 | + EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__); |
|
| 682 | + EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__); |
|
| 683 | + EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__); |
|
| 684 | + EEH_Debug_Tools::printr($this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__); |
|
| 685 | + EEH_Debug_Tools::printr($this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__); |
|
| 686 | + } |
|
| 687 | + |
|
| 688 | + |
|
| 689 | + |
|
| 690 | + /** |
|
| 691 | + * _block_bots |
|
| 692 | + * checks that the incoming request has either of the following set: |
|
| 693 | + * a uts (unix timestamp) which indicates that the request was redirected from the Ticket Selector |
|
| 694 | + * a REG URL Link, which indicates that the request is a return visit to SPCO for a valid TXN |
|
| 695 | + * so if you're not coming from the Ticket Selector nor returning for a valid IP... |
|
| 696 | + * then where you coming from man? |
|
| 697 | + * |
|
| 698 | + * @return boolean |
|
| 699 | + */ |
|
| 700 | + private function _block_bots() |
|
| 701 | + { |
|
| 702 | + $invalid_checkout_access = EED_Invalid_Checkout_Access::getInvalidCheckoutAccess(); |
|
| 703 | + if ($invalid_checkout_access->checkoutAccessIsInvalid($this->checkout)) { |
|
| 704 | + return true; |
|
| 705 | + } |
|
| 706 | + return false; |
|
| 707 | + } |
|
| 708 | + |
|
| 709 | + |
|
| 710 | + |
|
| 711 | + /** |
|
| 712 | + * _get_first_step |
|
| 713 | + * gets slug for first step in $_reg_steps_array |
|
| 714 | + * |
|
| 715 | + * @access private |
|
| 716 | + * @throws EE_Error |
|
| 717 | + * @return string |
|
| 718 | + */ |
|
| 719 | + private function _get_first_step() |
|
| 720 | + { |
|
| 721 | + $first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array); |
|
| 722 | + return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information'; |
|
| 723 | + } |
|
| 724 | + |
|
| 725 | + |
|
| 726 | + |
|
| 727 | + /** |
|
| 728 | + * _load_and_instantiate_reg_steps |
|
| 729 | + * instantiates each reg step based on the loaded reg_steps array |
|
| 730 | + * |
|
| 731 | + * @access private |
|
| 732 | + * @throws EE_Error |
|
| 733 | + * @return bool |
|
| 734 | + */ |
|
| 735 | + private function _load_and_instantiate_reg_steps() |
|
| 736 | + { |
|
| 737 | + do_action('AHEE__Single_Page_Checkout___load_and_instantiate_reg_steps__start', $this->checkout); |
|
| 738 | + // have reg_steps already been instantiated ? |
|
| 739 | + if ( |
|
| 740 | + empty($this->checkout->reg_steps) |
|
| 741 | + || apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout) |
|
| 742 | + ) { |
|
| 743 | + // if not, then loop through raw reg steps array |
|
| 744 | + foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) { |
|
| 745 | + if ( ! $this->_load_and_instantiate_reg_step($reg_step, $order)) { |
|
| 746 | + return false; |
|
| 747 | + } |
|
| 748 | + } |
|
| 749 | + EE_Registry::instance()->CFG->registration->skip_reg_confirmation = true; |
|
| 750 | + EE_Registry::instance()->CFG->registration->reg_confirmation_last = true; |
|
| 751 | + // skip the registration_confirmation page ? |
|
| 752 | + if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) { |
|
| 753 | + // just remove it from the reg steps array |
|
| 754 | + $this->checkout->remove_reg_step('registration_confirmation', false); |
|
| 755 | + } else if ( |
|
| 756 | + isset($this->checkout->reg_steps['registration_confirmation']) |
|
| 757 | + && EE_Registry::instance()->CFG->registration->reg_confirmation_last |
|
| 758 | + ) { |
|
| 759 | + // set the order to something big like 100 |
|
| 760 | + $this->checkout->set_reg_step_order('registration_confirmation', 100); |
|
| 761 | + } |
|
| 762 | + // filter the array for good luck |
|
| 763 | + $this->checkout->reg_steps = apply_filters( |
|
| 764 | + 'FHEE__Single_Page_Checkout__load_reg_steps__reg_steps', |
|
| 765 | + $this->checkout->reg_steps |
|
| 766 | + ); |
|
| 767 | + // finally re-sort based on the reg step class order properties |
|
| 768 | + $this->checkout->sort_reg_steps(); |
|
| 769 | + } else { |
|
| 770 | + foreach ($this->checkout->reg_steps as $reg_step) { |
|
| 771 | + // set all current step stati to FALSE |
|
| 772 | + $reg_step->set_is_current_step(false); |
|
| 773 | + } |
|
| 774 | + } |
|
| 775 | + if (empty($this->checkout->reg_steps)) { |
|
| 776 | + EE_Error::add_error( |
|
| 777 | + __('No Reg Steps were loaded..', 'event_espresso'), |
|
| 778 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 779 | + ); |
|
| 780 | + return false; |
|
| 781 | + } |
|
| 782 | + // make reg step details available to JS |
|
| 783 | + $this->checkout->set_reg_step_JSON_info(); |
|
| 784 | + return true; |
|
| 785 | + } |
|
| 786 | + |
|
| 787 | + |
|
| 788 | + |
|
| 789 | + /** |
|
| 790 | + * _load_and_instantiate_reg_step |
|
| 791 | + * |
|
| 792 | + * @access private |
|
| 793 | + * @param array $reg_step |
|
| 794 | + * @param int $order |
|
| 795 | + * @return bool |
|
| 796 | + */ |
|
| 797 | + private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0) |
|
| 798 | + { |
|
| 799 | + // we need a file_path, class_name, and slug to add a reg step |
|
| 800 | + if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
| 801 | + // if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step) |
|
| 802 | + if ( |
|
| 803 | + $this->checkout->reg_url_link |
|
| 804 | + && $this->checkout->step !== $reg_step['slug'] |
|
| 805 | + && $reg_step['slug'] !== 'finalize_registration' |
|
| 806 | + // normally at this point we would NOT load the reg step, but this filter can change that |
|
| 807 | + && apply_filters( |
|
| 808 | + 'FHEE__Single_Page_Checkout___load_and_instantiate_reg_step__bypass_reg_step', |
|
| 809 | + true, |
|
| 810 | + $reg_step, |
|
| 811 | + $this->checkout |
|
| 812 | + ) |
|
| 813 | + ) { |
|
| 814 | + return true; |
|
| 815 | + } |
|
| 816 | + // instantiate step class using file path and class name |
|
| 817 | + $reg_step_obj = EE_Registry::instance()->load_file( |
|
| 818 | + $reg_step['file_path'], |
|
| 819 | + $reg_step['class_name'], |
|
| 820 | + 'class', |
|
| 821 | + $this->checkout, |
|
| 822 | + false |
|
| 823 | + ); |
|
| 824 | + // did we gets the goods ? |
|
| 825 | + if ($reg_step_obj instanceof EE_SPCO_Reg_Step) { |
|
| 826 | + // set reg step order based on config |
|
| 827 | + $reg_step_obj->set_order($order); |
|
| 828 | + // add instantiated reg step object to the master reg steps array |
|
| 829 | + $this->checkout->add_reg_step($reg_step_obj); |
|
| 830 | + } else { |
|
| 831 | + EE_Error::add_error( |
|
| 832 | + __('The current step could not be set.', 'event_espresso'), |
|
| 833 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 834 | + ); |
|
| 835 | + return false; |
|
| 836 | + } |
|
| 837 | + } else { |
|
| 838 | + if (WP_DEBUG) { |
|
| 839 | + EE_Error::add_error( |
|
| 840 | + sprintf( |
|
| 841 | + __( |
|
| 842 | + 'A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', |
|
| 843 | + 'event_espresso' |
|
| 844 | + ), |
|
| 845 | + isset($reg_step['file_path']) ? $reg_step['file_path'] : '', |
|
| 846 | + isset($reg_step['class_name']) ? $reg_step['class_name'] : '', |
|
| 847 | + isset($reg_step['slug']) ? $reg_step['slug'] : '', |
|
| 848 | + '<ul>', |
|
| 849 | + '<li>', |
|
| 850 | + '</li>', |
|
| 851 | + '</ul>' |
|
| 852 | + ), |
|
| 853 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 854 | + ); |
|
| 855 | + } |
|
| 856 | + return false; |
|
| 857 | + } |
|
| 858 | + return true; |
|
| 859 | + } |
|
| 860 | + |
|
| 861 | + |
|
| 862 | + /** |
|
| 863 | + * _verify_transaction_and_get_registrations |
|
| 864 | + * |
|
| 865 | + * @access private |
|
| 866 | + * @return bool |
|
| 867 | + * @throws InvalidDataTypeException |
|
| 868 | + * @throws InvalidEntityException |
|
| 869 | + * @throws EE_Error |
|
| 870 | + */ |
|
| 871 | + private function _verify_transaction_and_get_registrations() |
|
| 872 | + { |
|
| 873 | + // was there already a valid transaction in the checkout from the session ? |
|
| 874 | + if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
| 875 | + // get transaction from db or session |
|
| 876 | + $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin() |
|
| 877 | + ? $this->_get_transaction_and_cart_for_previous_visit() |
|
| 878 | + : $this->_get_cart_for_current_session_and_setup_new_transaction(); |
|
| 879 | + if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
| 880 | + EE_Error::add_error( |
|
| 881 | + __('Your Registration and Transaction information could not be retrieved from the db.', |
|
| 882 | + 'event_espresso'), |
|
| 883 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 884 | + ); |
|
| 885 | + $this->checkout->transaction = EE_Transaction::new_instance(); |
|
| 886 | + // add some style and make it dance |
|
| 887 | + $this->add_styles_and_scripts(); |
|
| 888 | + EED_Single_Page_Checkout::$_initialized = true; |
|
| 889 | + return false; |
|
| 890 | + } |
|
| 891 | + // and the registrations for the transaction |
|
| 892 | + $this->_get_registrations($this->checkout->transaction); |
|
| 893 | + } |
|
| 894 | + return true; |
|
| 895 | + } |
|
| 896 | + |
|
| 897 | + |
|
| 898 | + |
|
| 899 | + /** |
|
| 900 | + * _get_transaction_and_cart_for_previous_visit |
|
| 901 | + * |
|
| 902 | + * @access private |
|
| 903 | + * @return mixed EE_Transaction|NULL |
|
| 904 | + */ |
|
| 905 | + private function _get_transaction_and_cart_for_previous_visit() |
|
| 906 | + { |
|
| 907 | + /** @var $TXN_model EEM_Transaction */ |
|
| 908 | + $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
|
| 909 | + // because the reg_url_link is present in the request, |
|
| 910 | + // this is a return visit to SPCO, so we'll get the transaction data from the db |
|
| 911 | + $transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link); |
|
| 912 | + // verify transaction |
|
| 913 | + if ($transaction instanceof EE_Transaction) { |
|
| 914 | + // and get the cart that was used for that transaction |
|
| 915 | + $this->checkout->cart = $this->_get_cart_for_transaction($transaction); |
|
| 916 | + return $transaction; |
|
| 917 | + } |
|
| 918 | + EE_Error::add_error( |
|
| 919 | + __('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), |
|
| 920 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 921 | + ); |
|
| 922 | + return null; |
|
| 923 | + |
|
| 924 | + } |
|
| 925 | + |
|
| 926 | + |
|
| 927 | + |
|
| 928 | + /** |
|
| 929 | + * _get_cart_for_transaction |
|
| 930 | + * |
|
| 931 | + * @access private |
|
| 932 | + * @param EE_Transaction $transaction |
|
| 933 | + * @return EE_Cart |
|
| 934 | + */ |
|
| 935 | + private function _get_cart_for_transaction($transaction) |
|
| 936 | + { |
|
| 937 | + return $this->checkout->get_cart_for_transaction($transaction); |
|
| 938 | + } |
|
| 939 | + |
|
| 940 | + |
|
| 941 | + |
|
| 942 | + /** |
|
| 943 | + * get_cart_for_transaction |
|
| 944 | + * |
|
| 945 | + * @access public |
|
| 946 | + * @param EE_Transaction $transaction |
|
| 947 | + * @return EE_Cart |
|
| 948 | + */ |
|
| 949 | + public function get_cart_for_transaction(EE_Transaction $transaction) |
|
| 950 | + { |
|
| 951 | + return $this->checkout->get_cart_for_transaction($transaction); |
|
| 952 | + } |
|
| 953 | + |
|
| 954 | + |
|
| 955 | + |
|
| 956 | + /** |
|
| 957 | + * _get_transaction_and_cart_for_current_session |
|
| 958 | + * generates a new EE_Transaction object and adds it to the $_transaction property. |
|
| 959 | + * |
|
| 960 | + * @access private |
|
| 961 | + * @return EE_Transaction |
|
| 962 | + * @throws EE_Error |
|
| 963 | + */ |
|
| 964 | + private function _get_cart_for_current_session_and_setup_new_transaction() |
|
| 965 | + { |
|
| 966 | + // if there's no transaction, then this is the FIRST visit to SPCO |
|
| 967 | + // so load up the cart ( passing nothing for the TXN because it doesn't exist yet ) |
|
| 968 | + $this->checkout->cart = $this->_get_cart_for_transaction(null); |
|
| 969 | + // and then create a new transaction |
|
| 970 | + $transaction = $this->_initialize_transaction(); |
|
| 971 | + // verify transaction |
|
| 972 | + if ($transaction instanceof EE_Transaction) { |
|
| 973 | + // save it so that we have an ID for other objects to use |
|
| 974 | + $transaction->save(); |
|
| 975 | + // and save TXN data to the cart |
|
| 976 | + $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID()); |
|
| 977 | + } else { |
|
| 978 | + EE_Error::add_error( |
|
| 979 | + __('A Valid Transaction could not be initialized.', 'event_espresso'), |
|
| 980 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 981 | + ); |
|
| 982 | + } |
|
| 983 | + return $transaction; |
|
| 984 | + } |
|
| 985 | + |
|
| 986 | + |
|
| 987 | + |
|
| 988 | + /** |
|
| 989 | + * generates a new EE_Transaction object and adds it to the $_transaction property. |
|
| 990 | + * |
|
| 991 | + * @access private |
|
| 992 | + * @return mixed EE_Transaction|NULL |
|
| 993 | + */ |
|
| 994 | + private function _initialize_transaction() |
|
| 995 | + { |
|
| 996 | + try { |
|
| 997 | + // ensure cart totals have been calculated |
|
| 998 | + $this->checkout->cart->get_grand_total()->recalculate_total_including_taxes(); |
|
| 999 | + // grab the cart grand total |
|
| 1000 | + $cart_total = $this->checkout->cart->get_cart_grand_total(); |
|
| 1001 | + // create new TXN |
|
| 1002 | + $transaction = EE_Transaction::new_instance( |
|
| 1003 | + array( |
|
| 1004 | + 'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(), |
|
| 1005 | + 'TXN_total' => $cart_total > 0 ? $cart_total : 0, |
|
| 1006 | + 'TXN_paid' => 0, |
|
| 1007 | + 'STS_ID' => EEM_Transaction::failed_status_code, |
|
| 1008 | + ) |
|
| 1009 | + ); |
|
| 1010 | + // save it so that we have an ID for other objects to use |
|
| 1011 | + $transaction->save(); |
|
| 1012 | + // set cron job for following up on TXNs after their session has expired |
|
| 1013 | + EE_Cron_Tasks::schedule_expired_transaction_check( |
|
| 1014 | + EE_Registry::instance()->SSN->expiration() + 1, |
|
| 1015 | + $transaction->ID() |
|
| 1016 | + ); |
|
| 1017 | + return $transaction; |
|
| 1018 | + } catch (Exception $e) { |
|
| 1019 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
| 1020 | + } |
|
| 1021 | + return null; |
|
| 1022 | + } |
|
| 1023 | + |
|
| 1024 | + |
|
| 1025 | + /** |
|
| 1026 | + * _get_registrations |
|
| 1027 | + * |
|
| 1028 | + * @access private |
|
| 1029 | + * @param EE_Transaction $transaction |
|
| 1030 | + * @return void |
|
| 1031 | + * @throws InvalidDataTypeException |
|
| 1032 | + * @throws InvalidEntityException |
|
| 1033 | + * @throws EE_Error |
|
| 1034 | + */ |
|
| 1035 | + private function _get_registrations(EE_Transaction $transaction) |
|
| 1036 | + { |
|
| 1037 | + // first step: grab the registrants { : o |
|
| 1038 | + $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false); |
|
| 1039 | + $this->checkout->total_ticket_count = count($registrations); |
|
| 1040 | + // verify registrations have been set |
|
| 1041 | + if (empty($registrations)) { |
|
| 1042 | + // if no cached registrations, then check the db |
|
| 1043 | + $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false); |
|
| 1044 | + // still nothing ? well as long as this isn't a revisit |
|
| 1045 | + if (empty($registrations) && ! $this->checkout->revisit) { |
|
| 1046 | + // generate new registrations from scratch |
|
| 1047 | + $registrations = $this->_initialize_registrations($transaction); |
|
| 1048 | + } |
|
| 1049 | + } |
|
| 1050 | + // sort by their original registration order |
|
| 1051 | + usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count')); |
|
| 1052 | + // then loop thru the array |
|
| 1053 | + foreach ($registrations as $registration) { |
|
| 1054 | + // verify each registration |
|
| 1055 | + if ($registration instanceof EE_Registration) { |
|
| 1056 | + // we display all attendee info for the primary registrant |
|
| 1057 | + if ($this->checkout->reg_url_link === $registration->reg_url_link() |
|
| 1058 | + && $registration->is_primary_registrant() |
|
| 1059 | + ) { |
|
| 1060 | + $this->checkout->primary_revisit = true; |
|
| 1061 | + break; |
|
| 1062 | + } |
|
| 1063 | + if ($this->checkout->revisit && $this->checkout->reg_url_link !== $registration->reg_url_link()) { |
|
| 1064 | + // but hide info if it doesn't belong to you |
|
| 1065 | + $transaction->clear_cache('Registration', $registration->ID()); |
|
| 1066 | + $this->checkout->total_ticket_count--; |
|
| 1067 | + } |
|
| 1068 | + $this->checkout->set_reg_status_updated($registration->ID(), false); |
|
| 1069 | + } |
|
| 1070 | + } |
|
| 1071 | + } |
|
| 1072 | + |
|
| 1073 | + |
|
| 1074 | + /** |
|
| 1075 | + * adds related EE_Registration objects for each ticket in the cart to the current EE_Transaction object |
|
| 1076 | + * |
|
| 1077 | + * @access private |
|
| 1078 | + * @param EE_Transaction $transaction |
|
| 1079 | + * @return array |
|
| 1080 | + * @throws InvalidDataTypeException |
|
| 1081 | + * @throws InvalidEntityException |
|
| 1082 | + * @throws EE_Error |
|
| 1083 | + */ |
|
| 1084 | + private function _initialize_registrations(EE_Transaction $transaction) |
|
| 1085 | + { |
|
| 1086 | + $att_nmbr = 0; |
|
| 1087 | + $registrations = array(); |
|
| 1088 | + if ($transaction instanceof EE_Transaction) { |
|
| 1089 | + /** @type EE_Registration_Processor $registration_processor */ |
|
| 1090 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
| 1091 | + $this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count(); |
|
| 1092 | + // now let's add the cart items to the $transaction |
|
| 1093 | + foreach ($this->checkout->cart->get_tickets() as $line_item) { |
|
| 1094 | + //do the following for each ticket of this type they selected |
|
| 1095 | + for ($x = 1; $x <= $line_item->quantity(); $x++) { |
|
| 1096 | + $att_nmbr++; |
|
| 1097 | + /** @var EventEspresso\core\services\commands\registration\CreateRegistrationCommand $CreateRegistrationCommand */ |
|
| 1098 | + $CreateRegistrationCommand = EE_Registry::instance()->create( |
|
| 1099 | + 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
| 1100 | + array( |
|
| 1101 | + $transaction, |
|
| 1102 | + $line_item, |
|
| 1103 | + $att_nmbr, |
|
| 1104 | + $this->checkout->total_ticket_count, |
|
| 1105 | + ) |
|
| 1106 | + ); |
|
| 1107 | + // override capabilities for frontend registrations |
|
| 1108 | + if ( ! is_admin()) { |
|
| 1109 | + $CreateRegistrationCommand->setCapCheck( |
|
| 1110 | + new PublicCapabilities('', 'create_new_registration') |
|
| 1111 | + ); |
|
| 1112 | + } |
|
| 1113 | + $registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand); |
|
| 1114 | + if ( ! $registration instanceof EE_Registration) { |
|
| 1115 | + throw new InvalidEntityException($registration, 'EE_Registration'); |
|
| 1116 | + } |
|
| 1117 | + $registrations[ $registration->ID() ] = $registration; |
|
| 1118 | + } |
|
| 1119 | + } |
|
| 1120 | + $registration_processor->fix_reg_final_price_rounding_issue($transaction); |
|
| 1121 | + } |
|
| 1122 | + return $registrations; |
|
| 1123 | + } |
|
| 1124 | + |
|
| 1125 | + |
|
| 1126 | + |
|
| 1127 | + /** |
|
| 1128 | + * sorts registrations by REG_count |
|
| 1129 | + * |
|
| 1130 | + * @access public |
|
| 1131 | + * @param EE_Registration $reg_A |
|
| 1132 | + * @param EE_Registration $reg_B |
|
| 1133 | + * @return int |
|
| 1134 | + */ |
|
| 1135 | + public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B) |
|
| 1136 | + { |
|
| 1137 | + // this shouldn't ever happen within the same TXN, but oh well |
|
| 1138 | + if ($reg_A->count() === $reg_B->count()) { |
|
| 1139 | + return 0; |
|
| 1140 | + } |
|
| 1141 | + return ($reg_A->count() > $reg_B->count()) ? 1 : -1; |
|
| 1142 | + } |
|
| 1143 | + |
|
| 1144 | + |
|
| 1145 | + |
|
| 1146 | + /** |
|
| 1147 | + * _final_verifications |
|
| 1148 | + * just makes sure that everything is set up correctly before proceeding |
|
| 1149 | + * |
|
| 1150 | + * @access private |
|
| 1151 | + * @return bool |
|
| 1152 | + * @throws EE_Error |
|
| 1153 | + */ |
|
| 1154 | + private function _final_verifications() |
|
| 1155 | + { |
|
| 1156 | + // filter checkout |
|
| 1157 | + $this->checkout = apply_filters( |
|
| 1158 | + 'FHEE__EED_Single_Page_Checkout___final_verifications__checkout', |
|
| 1159 | + $this->checkout |
|
| 1160 | + ); |
|
| 1161 | + //verify that current step is still set correctly |
|
| 1162 | + if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) { |
|
| 1163 | + EE_Error::add_error( |
|
| 1164 | + __('We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', 'event_espresso'), |
|
| 1165 | + __FILE__, |
|
| 1166 | + __FUNCTION__, |
|
| 1167 | + __LINE__ |
|
| 1168 | + ); |
|
| 1169 | + return false; |
|
| 1170 | + } |
|
| 1171 | + // if returning to SPCO, then verify that primary registrant is set |
|
| 1172 | + if ( ! empty($this->checkout->reg_url_link)) { |
|
| 1173 | + $valid_registrant = $this->checkout->transaction->primary_registration(); |
|
| 1174 | + if ( ! $valid_registrant instanceof EE_Registration) { |
|
| 1175 | + EE_Error::add_error( |
|
| 1176 | + __('We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', 'event_espresso'), |
|
| 1177 | + __FILE__, |
|
| 1178 | + __FUNCTION__, |
|
| 1179 | + __LINE__ |
|
| 1180 | + ); |
|
| 1181 | + return false; |
|
| 1182 | + } |
|
| 1183 | + $valid_registrant = null; |
|
| 1184 | + foreach ( |
|
| 1185 | + $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration |
|
| 1186 | + ) { |
|
| 1187 | + if ( |
|
| 1188 | + $registration instanceof EE_Registration |
|
| 1189 | + && $registration->reg_url_link() === $this->checkout->reg_url_link |
|
| 1190 | + ) { |
|
| 1191 | + $valid_registrant = $registration; |
|
| 1192 | + } |
|
| 1193 | + } |
|
| 1194 | + if ( ! $valid_registrant instanceof EE_Registration) { |
|
| 1195 | + // hmmm... maybe we have the wrong session because the user is opening multiple tabs ? |
|
| 1196 | + if (EED_Single_Page_Checkout::$_checkout_verified) { |
|
| 1197 | + // clear the session, mark the checkout as unverified, and try again |
|
| 1198 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 1199 | + EED_Single_Page_Checkout::$_initialized = false; |
|
| 1200 | + EED_Single_Page_Checkout::$_checkout_verified = false; |
|
| 1201 | + $this->_initialize(); |
|
| 1202 | + EE_Error::reset_notices(); |
|
| 1203 | + return false; |
|
| 1204 | + } |
|
| 1205 | + EE_Error::add_error( |
|
| 1206 | + __( |
|
| 1207 | + 'We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.', |
|
| 1208 | + 'event_espresso' |
|
| 1209 | + ), |
|
| 1210 | + __FILE__, |
|
| 1211 | + __FUNCTION__, |
|
| 1212 | + __LINE__ |
|
| 1213 | + ); |
|
| 1214 | + return false; |
|
| 1215 | + } |
|
| 1216 | + } |
|
| 1217 | + // now that things have been kinda sufficiently verified, |
|
| 1218 | + // let's add the checkout to the session so that it's available to other systems |
|
| 1219 | + EE_Registry::instance()->SSN->set_checkout($this->checkout); |
|
| 1220 | + return true; |
|
| 1221 | + } |
|
| 1222 | + |
|
| 1223 | + |
|
| 1224 | + |
|
| 1225 | + /** |
|
| 1226 | + * _initialize_reg_steps |
|
| 1227 | + * first makes sure that EE_Transaction_Processor::set_reg_step_initiated() is called as required |
|
| 1228 | + * then loops thru all of the active reg steps and calls the initialize_reg_step() method |
|
| 1229 | + * |
|
| 1230 | + * @access private |
|
| 1231 | + * @param bool $reinitializing |
|
| 1232 | + * @throws EE_Error |
|
| 1233 | + */ |
|
| 1234 | + private function _initialize_reg_steps($reinitializing = false) |
|
| 1235 | + { |
|
| 1236 | + $this->checkout->set_reg_step_initiated($this->checkout->current_step); |
|
| 1237 | + // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS |
|
| 1238 | + foreach ($this->checkout->reg_steps as $reg_step) { |
|
| 1239 | + if ( ! $reg_step->initialize_reg_step()) { |
|
| 1240 | + // if not initialized then maybe this step is being removed... |
|
| 1241 | + if ( ! $reinitializing && $reg_step->is_current_step()) { |
|
| 1242 | + // if it was the current step, then we need to start over here |
|
| 1243 | + $this->_initialize_reg_steps(true); |
|
| 1244 | + return; |
|
| 1245 | + } |
|
| 1246 | + continue; |
|
| 1247 | + } |
|
| 1248 | + // add css and JS for current step |
|
| 1249 | + $reg_step->enqueue_styles_and_scripts(); |
|
| 1250 | + // i18n |
|
| 1251 | + $reg_step->translate_js_strings(); |
|
| 1252 | + if ($reg_step->is_current_step()) { |
|
| 1253 | + // the text that appears on the reg step form submit button |
|
| 1254 | + $reg_step->set_submit_button_text(); |
|
| 1255 | + } |
|
| 1256 | + } |
|
| 1257 | + // dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information |
|
| 1258 | + do_action( |
|
| 1259 | + "AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", |
|
| 1260 | + $this->checkout->current_step |
|
| 1261 | + ); |
|
| 1262 | + } |
|
| 1263 | + |
|
| 1264 | + |
|
| 1265 | + |
|
| 1266 | + /** |
|
| 1267 | + * _check_form_submission |
|
| 1268 | + * |
|
| 1269 | + * @access private |
|
| 1270 | + * @return boolean |
|
| 1271 | + */ |
|
| 1272 | + private function _check_form_submission() |
|
| 1273 | + { |
|
| 1274 | + //does this request require the reg form to be generated ? |
|
| 1275 | + if ($this->checkout->generate_reg_form) { |
|
| 1276 | + // ever heard that song by Blue Rodeo ? |
|
| 1277 | + try { |
|
| 1278 | + $this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form(); |
|
| 1279 | + // if not displaying a form, then check for form submission |
|
| 1280 | + if ( |
|
| 1281 | + $this->checkout->process_form_submission |
|
| 1282 | + && $this->checkout->current_step->reg_form->was_submitted() |
|
| 1283 | + ) { |
|
| 1284 | + // clear out any old data in case this step is being run again |
|
| 1285 | + $this->checkout->current_step->set_valid_data(array()); |
|
| 1286 | + // capture submitted form data |
|
| 1287 | + $this->checkout->current_step->reg_form->receive_form_submission( |
|
| 1288 | + apply_filters( |
|
| 1289 | + 'FHEE__Single_Page_Checkout___check_form_submission__request_params', |
|
| 1290 | + EE_Registry::instance()->REQ->params(), |
|
| 1291 | + $this->checkout |
|
| 1292 | + ) |
|
| 1293 | + ); |
|
| 1294 | + // validate submitted form data |
|
| 1295 | + if ( ! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) { |
|
| 1296 | + // thou shall not pass !!! |
|
| 1297 | + $this->checkout->continue_reg = false; |
|
| 1298 | + // any form validation errors? |
|
| 1299 | + if ($this->checkout->current_step->reg_form->submission_error_message() !== '') { |
|
| 1300 | + EE_Error::add_error( |
|
| 1301 | + $this->checkout->current_step->reg_form->submission_error_message(), |
|
| 1302 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 1303 | + ); |
|
| 1304 | + } |
|
| 1305 | + // well not really... what will happen is |
|
| 1306 | + // we'll just get redirected back to redo the current step |
|
| 1307 | + $this->go_to_next_step(); |
|
| 1308 | + return false; |
|
| 1309 | + } |
|
| 1310 | + } |
|
| 1311 | + } catch (EE_Error $e) { |
|
| 1312 | + $e->get_error(); |
|
| 1313 | + } |
|
| 1314 | + } |
|
| 1315 | + return true; |
|
| 1316 | + } |
|
| 1317 | + |
|
| 1318 | + |
|
| 1319 | + |
|
| 1320 | + /** |
|
| 1321 | + * _process_action |
|
| 1322 | + * |
|
| 1323 | + * @access private |
|
| 1324 | + * @return void |
|
| 1325 | + * @throws EE_Error |
|
| 1326 | + */ |
|
| 1327 | + private function _process_form_action() |
|
| 1328 | + { |
|
| 1329 | + // what cha wanna do? |
|
| 1330 | + switch ($this->checkout->action) { |
|
| 1331 | + // AJAX next step reg form |
|
| 1332 | + case 'display_spco_reg_step' : |
|
| 1333 | + $this->checkout->redirect = false; |
|
| 1334 | + if (EE_Registry::instance()->REQ->ajax) { |
|
| 1335 | + $this->checkout->json_response->set_reg_step_html( |
|
| 1336 | + $this->checkout->current_step->display_reg_form() |
|
| 1337 | + ); |
|
| 1338 | + } |
|
| 1339 | + break; |
|
| 1340 | + default : |
|
| 1341 | + // meh... do one of those other steps first |
|
| 1342 | + if ( |
|
| 1343 | + ! empty($this->checkout->action) |
|
| 1344 | + && is_callable(array($this->checkout->current_step, $this->checkout->action)) |
|
| 1345 | + ) { |
|
| 1346 | + // dynamically creates hook point like: |
|
| 1347 | + // AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step |
|
| 1348 | + do_action( |
|
| 1349 | + "AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", |
|
| 1350 | + $this->checkout->current_step |
|
| 1351 | + ); |
|
| 1352 | + // call action on current step |
|
| 1353 | + if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) { |
|
| 1354 | + // good registrant, you get to proceed |
|
| 1355 | + if ( |
|
| 1356 | + $this->checkout->current_step->success_message() !== '' |
|
| 1357 | + && apply_filters( |
|
| 1358 | + 'FHEE__Single_Page_Checkout___process_form_action__display_success', |
|
| 1359 | + false |
|
| 1360 | + ) |
|
| 1361 | + ) { |
|
| 1362 | + EE_Error::add_success( |
|
| 1363 | + $this->checkout->current_step->success_message() |
|
| 1364 | + . '<br />' . $this->checkout->next_step->_instructions() |
|
| 1365 | + ); |
|
| 1366 | + } |
|
| 1367 | + // pack it up, pack it in... |
|
| 1368 | + $this->_setup_redirect(); |
|
| 1369 | + } |
|
| 1370 | + // dynamically creates hook point like: |
|
| 1371 | + // AHEE__Single_Page_Checkout__after_payment_options__process_reg_step |
|
| 1372 | + do_action( |
|
| 1373 | + "AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", |
|
| 1374 | + $this->checkout->current_step |
|
| 1375 | + ); |
|
| 1376 | + } else { |
|
| 1377 | + EE_Error::add_error( |
|
| 1378 | + sprintf( |
|
| 1379 | + __( |
|
| 1380 | + 'The requested form action "%s" does not exist for the current "%s" registration step.', |
|
| 1381 | + 'event_espresso' |
|
| 1382 | + ), |
|
| 1383 | + $this->checkout->action, |
|
| 1384 | + $this->checkout->current_step->name() |
|
| 1385 | + ), |
|
| 1386 | + __FILE__, |
|
| 1387 | + __FUNCTION__, |
|
| 1388 | + __LINE__ |
|
| 1389 | + ); |
|
| 1390 | + } |
|
| 1391 | + // end default |
|
| 1392 | + } |
|
| 1393 | + // store our progress so far |
|
| 1394 | + $this->checkout->stash_transaction_and_checkout(); |
|
| 1395 | + // advance to the next step! If you pass GO, collect $200 |
|
| 1396 | + $this->go_to_next_step(); |
|
| 1397 | + } |
|
| 1398 | + |
|
| 1399 | + |
|
| 1400 | + |
|
| 1401 | + /** |
|
| 1402 | + * add_styles_and_scripts |
|
| 1403 | + * |
|
| 1404 | + * @access public |
|
| 1405 | + * @return void |
|
| 1406 | + */ |
|
| 1407 | + public function add_styles_and_scripts() |
|
| 1408 | + { |
|
| 1409 | + // i18n |
|
| 1410 | + $this->translate_js_strings(); |
|
| 1411 | + if ($this->checkout->admin_request) { |
|
| 1412 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
| 1413 | + } else { |
|
| 1414 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
| 1415 | + } |
|
| 1416 | + } |
|
| 1417 | + |
|
| 1418 | + |
|
| 1419 | + |
|
| 1420 | + /** |
|
| 1421 | + * translate_js_strings |
|
| 1422 | + * |
|
| 1423 | + * @access public |
|
| 1424 | + * @return void |
|
| 1425 | + */ |
|
| 1426 | + public function translate_js_strings() |
|
| 1427 | + { |
|
| 1428 | + EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit; |
|
| 1429 | + EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link; |
|
| 1430 | + EE_Registry::$i18n_js_strings['server_error'] = __( |
|
| 1431 | + 'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.', |
|
| 1432 | + 'event_espresso' |
|
| 1433 | + ); |
|
| 1434 | + EE_Registry::$i18n_js_strings['invalid_json_response'] = __( |
|
| 1435 | + 'An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', |
|
| 1436 | + 'event_espresso' |
|
| 1437 | + ); |
|
| 1438 | + EE_Registry::$i18n_js_strings['validation_error'] = __( |
|
| 1439 | + 'There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', |
|
| 1440 | + 'event_espresso' |
|
| 1441 | + ); |
|
| 1442 | + EE_Registry::$i18n_js_strings['invalid_payment_method'] = __( |
|
| 1443 | + 'There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', |
|
| 1444 | + 'event_espresso' |
|
| 1445 | + ); |
|
| 1446 | + EE_Registry::$i18n_js_strings['reg_step_error'] = __( |
|
| 1447 | + 'This registration step could not be completed. Please refresh the page and try again.', |
|
| 1448 | + 'event_espresso' |
|
| 1449 | + ); |
|
| 1450 | + EE_Registry::$i18n_js_strings['invalid_coupon'] = __( |
|
| 1451 | + 'We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.', |
|
| 1452 | + 'event_espresso' |
|
| 1453 | + ); |
|
| 1454 | + EE_Registry::$i18n_js_strings['process_registration'] = sprintf( |
|
| 1455 | + __( |
|
| 1456 | + 'Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.', |
|
| 1457 | + 'event_espresso' |
|
| 1458 | + ), |
|
| 1459 | + '<br/>', |
|
| 1460 | + '<br/>' |
|
| 1461 | + ); |
|
| 1462 | + EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language'); |
|
| 1463 | + EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id(); |
|
| 1464 | + EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency; |
|
| 1465 | + EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20'; |
|
| 1466 | + EE_Registry::$i18n_js_strings['timer_years'] = __('years', 'event_espresso'); |
|
| 1467 | + EE_Registry::$i18n_js_strings['timer_months'] = __('months', 'event_espresso'); |
|
| 1468 | + EE_Registry::$i18n_js_strings['timer_weeks'] = __('weeks', 'event_espresso'); |
|
| 1469 | + EE_Registry::$i18n_js_strings['timer_days'] = __('days', 'event_espresso'); |
|
| 1470 | + EE_Registry::$i18n_js_strings['timer_hours'] = __('hours', 'event_espresso'); |
|
| 1471 | + EE_Registry::$i18n_js_strings['timer_minutes'] = __('minutes', 'event_espresso'); |
|
| 1472 | + EE_Registry::$i18n_js_strings['timer_seconds'] = __('seconds', 'event_espresso'); |
|
| 1473 | + EE_Registry::$i18n_js_strings['timer_year'] = __('year', 'event_espresso'); |
|
| 1474 | + EE_Registry::$i18n_js_strings['timer_month'] = __('month', 'event_espresso'); |
|
| 1475 | + EE_Registry::$i18n_js_strings['timer_week'] = __('week', 'event_espresso'); |
|
| 1476 | + EE_Registry::$i18n_js_strings['timer_day'] = __('day', 'event_espresso'); |
|
| 1477 | + EE_Registry::$i18n_js_strings['timer_hour'] = __('hour', 'event_espresso'); |
|
| 1478 | + EE_Registry::$i18n_js_strings['timer_minute'] = __('minute', 'event_espresso'); |
|
| 1479 | + EE_Registry::$i18n_js_strings['timer_second'] = __('second', 'event_espresso'); |
|
| 1480 | + EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice(); |
|
| 1481 | + EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters( |
|
| 1482 | + 'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', |
|
| 1483 | + true |
|
| 1484 | + ); |
|
| 1485 | + EE_Registry::$i18n_js_strings['session_extension'] = absint( |
|
| 1486 | + apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS) |
|
| 1487 | + ); |
|
| 1488 | + EE_Registry::$i18n_js_strings['session_expiration'] = gmdate( |
|
| 1489 | + 'M d, Y H:i:s', |
|
| 1490 | + EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS) |
|
| 1491 | + ); |
|
| 1492 | + } |
|
| 1493 | + |
|
| 1494 | + |
|
| 1495 | + |
|
| 1496 | + /** |
|
| 1497 | + * enqueue_styles_and_scripts |
|
| 1498 | + * |
|
| 1499 | + * @access public |
|
| 1500 | + * @return void |
|
| 1501 | + * @throws EE_Error |
|
| 1502 | + */ |
|
| 1503 | + public function enqueue_styles_and_scripts() |
|
| 1504 | + { |
|
| 1505 | + // load css |
|
| 1506 | + wp_register_style( |
|
| 1507 | + 'single_page_checkout', |
|
| 1508 | + SPCO_CSS_URL . 'single_page_checkout.css', |
|
| 1509 | + array('espresso_default'), |
|
| 1510 | + EVENT_ESPRESSO_VERSION |
|
| 1511 | + ); |
|
| 1512 | + wp_enqueue_style('single_page_checkout'); |
|
| 1513 | + // load JS |
|
| 1514 | + wp_register_script( |
|
| 1515 | + 'jquery_plugin', |
|
| 1516 | + EE_THIRD_PARTY_URL . 'jquery .plugin.min.js', |
|
| 1517 | + array('jquery'), |
|
| 1518 | + '1.0.1', |
|
| 1519 | + true |
|
| 1520 | + ); |
|
| 1521 | + wp_register_script( |
|
| 1522 | + 'jquery_countdown', |
|
| 1523 | + EE_THIRD_PARTY_URL . 'jquery .countdown.min.js', |
|
| 1524 | + array('jquery_plugin'), |
|
| 1525 | + '2.0.2', |
|
| 1526 | + true |
|
| 1527 | + ); |
|
| 1528 | + wp_register_script( |
|
| 1529 | + 'single_page_checkout', |
|
| 1530 | + SPCO_JS_URL . 'single_page_checkout.js', |
|
| 1531 | + array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'), |
|
| 1532 | + EVENT_ESPRESSO_VERSION, |
|
| 1533 | + true |
|
| 1534 | + ); |
|
| 1535 | + if ($this->checkout->registration_form instanceof EE_Form_Section_Proper) { |
|
| 1536 | + $this->checkout->registration_form->enqueue_js(); |
|
| 1537 | + } |
|
| 1538 | + if ($this->checkout->current_step->reg_form instanceof EE_Form_Section_Proper) { |
|
| 1539 | + $this->checkout->current_step->reg_form->enqueue_js(); |
|
| 1540 | + } |
|
| 1541 | + wp_enqueue_script('single_page_checkout'); |
|
| 1542 | + /** |
|
| 1543 | + * global action hook for enqueueing styles and scripts with |
|
| 1544 | + * spco calls. |
|
| 1545 | + */ |
|
| 1546 | + do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this); |
|
| 1547 | + /** |
|
| 1548 | + * dynamic action hook for enqueueing styles and scripts with spco calls. |
|
| 1549 | + * The hook will end up being something like: |
|
| 1550 | + * AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information |
|
| 1551 | + */ |
|
| 1552 | + do_action( |
|
| 1553 | + 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(), |
|
| 1554 | + $this |
|
| 1555 | + ); |
|
| 1556 | + } |
|
| 1557 | + |
|
| 1558 | + |
|
| 1559 | + |
|
| 1560 | + /** |
|
| 1561 | + * display the Registration Single Page Checkout Form |
|
| 1562 | + * |
|
| 1563 | + * @access private |
|
| 1564 | + * @return void |
|
| 1565 | + * @throws EE_Error |
|
| 1566 | + */ |
|
| 1567 | + private function _display_spco_reg_form() |
|
| 1568 | + { |
|
| 1569 | + // if registering via the admin, just display the reg form for the current step |
|
| 1570 | + if ($this->checkout->admin_request) { |
|
| 1571 | + EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form()); |
|
| 1572 | + } else { |
|
| 1573 | + // add powered by EE msg |
|
| 1574 | + add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer')); |
|
| 1575 | + $empty_cart = count( |
|
| 1576 | + $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) |
|
| 1577 | + ) < 1; |
|
| 1578 | + EE_Registry::$i18n_js_strings['empty_cart'] = $empty_cart; |
|
| 1579 | + $cookies_not_set_msg = ''; |
|
| 1580 | + if ($empty_cart) { |
|
| 1581 | + $cookies_not_set_msg = apply_filters( |
|
| 1582 | + 'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg', |
|
| 1583 | + sprintf( |
|
| 1584 | + __( |
|
| 1585 | + '%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s', |
|
| 1586 | + 'event_espresso' |
|
| 1587 | + ), |
|
| 1588 | + '<div class="ee-attention hidden" id="ee-cookies-not-set-msg">', |
|
| 1589 | + '</div>', |
|
| 1590 | + '<h6 class="important-notice">', |
|
| 1591 | + '</h6>', |
|
| 1592 | + '<p>', |
|
| 1593 | + '</p>', |
|
| 1594 | + '<br />', |
|
| 1595 | + '<a href="http://www.whatarecookies.com/enable.asp" target="_blank">', |
|
| 1596 | + '</a>' |
|
| 1597 | + ) |
|
| 1598 | + ); |
|
| 1599 | + } |
|
| 1600 | + $this->checkout->registration_form = new EE_Form_Section_Proper( |
|
| 1601 | + array( |
|
| 1602 | + 'name' => 'single-page-checkout', |
|
| 1603 | + 'html_id' => 'ee-single-page-checkout-dv', |
|
| 1604 | + 'layout_strategy' => |
|
| 1605 | + new EE_Template_Layout( |
|
| 1606 | + array( |
|
| 1607 | + 'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php', |
|
| 1608 | + 'template_args' => array( |
|
| 1609 | + 'empty_cart' => $empty_cart, |
|
| 1610 | + 'revisit' => $this->checkout->revisit, |
|
| 1611 | + 'reg_steps' => $this->checkout->reg_steps, |
|
| 1612 | + 'next_step' => $this->checkout->next_step instanceof EE_SPCO_Reg_Step |
|
| 1613 | + ? $this->checkout->next_step->slug() |
|
| 1614 | + : '', |
|
| 1615 | + 'empty_msg' => apply_filters( |
|
| 1616 | + 'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg', |
|
| 1617 | + sprintf( |
|
| 1618 | + __( |
|
| 1619 | + 'You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', |
|
| 1620 | + 'event_espresso' |
|
| 1621 | + ), |
|
| 1622 | + '<a href="' |
|
| 1623 | + . get_post_type_archive_link('espresso_events') |
|
| 1624 | + . '" title="', |
|
| 1625 | + '">', |
|
| 1626 | + '</a>' |
|
| 1627 | + ) |
|
| 1628 | + ), |
|
| 1629 | + 'cookies_not_set_msg' => $cookies_not_set_msg, |
|
| 1630 | + 'registration_time_limit' => $this->checkout->get_registration_time_limit(), |
|
| 1631 | + 'session_expiration' => gmdate( |
|
| 1632 | + 'M d, Y H:i:s', |
|
| 1633 | + EE_Registry::instance()->SSN->expiration() |
|
| 1634 | + + (get_option('gmt_offset') * HOUR_IN_SECONDS) |
|
| 1635 | + ), |
|
| 1636 | + ), |
|
| 1637 | + ) |
|
| 1638 | + ), |
|
| 1639 | + ) |
|
| 1640 | + ); |
|
| 1641 | + // load template and add to output sent that gets filtered into the_content() |
|
| 1642 | + EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html()); |
|
| 1643 | + } |
|
| 1644 | + } |
|
| 1645 | + |
|
| 1646 | + |
|
| 1647 | + |
|
| 1648 | + /** |
|
| 1649 | + * add_extra_finalize_registration_inputs |
|
| 1650 | + * |
|
| 1651 | + * @access public |
|
| 1652 | + * @param $next_step |
|
| 1653 | + * @internal param string $label |
|
| 1654 | + * @return void |
|
| 1655 | + */ |
|
| 1656 | + public function add_extra_finalize_registration_inputs($next_step) |
|
| 1657 | + { |
|
| 1658 | + if ($next_step === 'finalize_registration') { |
|
| 1659 | + echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>'; |
|
| 1660 | + } |
|
| 1661 | + } |
|
| 1662 | + |
|
| 1663 | + |
|
| 1664 | + |
|
| 1665 | + /** |
|
| 1666 | + * display_registration_footer |
|
| 1667 | + * |
|
| 1668 | + * @access public |
|
| 1669 | + * @return string |
|
| 1670 | + */ |
|
| 1671 | + public static function display_registration_footer() |
|
| 1672 | + { |
|
| 1673 | + if ( |
|
| 1674 | + apply_filters( |
|
| 1675 | + 'FHEE__EE_Front__Controller__show_reg_footer', |
|
| 1676 | + EE_Registry::instance()->CFG->admin->show_reg_footer |
|
| 1677 | + ) |
|
| 1678 | + ) { |
|
| 1679 | + add_filter( |
|
| 1680 | + 'FHEE__EEH_Template__powered_by_event_espresso__url', |
|
| 1681 | + function ($url) { |
|
| 1682 | + return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url); |
|
| 1683 | + } |
|
| 1684 | + ); |
|
| 1685 | + echo apply_filters( |
|
| 1686 | + 'FHEE__EE_Front_Controller__display_registration_footer', |
|
| 1687 | + \EEH_Template::powered_by_event_espresso( |
|
| 1688 | + '', |
|
| 1689 | + 'espresso-registration-footer-dv', |
|
| 1690 | + array('utm_content' => 'registration_checkout') |
|
| 1691 | + ) |
|
| 1692 | + ); |
|
| 1693 | + } |
|
| 1694 | + return ''; |
|
| 1695 | + } |
|
| 1696 | + |
|
| 1697 | + |
|
| 1698 | + |
|
| 1699 | + /** |
|
| 1700 | + * unlock_transaction |
|
| 1701 | + * |
|
| 1702 | + * @access public |
|
| 1703 | + * @return void |
|
| 1704 | + * @throws EE_Error |
|
| 1705 | + */ |
|
| 1706 | + public function unlock_transaction() |
|
| 1707 | + { |
|
| 1708 | + if ($this->checkout->transaction instanceof EE_Transaction) { |
|
| 1709 | + $this->checkout->transaction->unlock(); |
|
| 1710 | + } |
|
| 1711 | + } |
|
| 1712 | + |
|
| 1713 | + |
|
| 1714 | + |
|
| 1715 | + /** |
|
| 1716 | + * _setup_redirect |
|
| 1717 | + * |
|
| 1718 | + * @access private |
|
| 1719 | + * @return void |
|
| 1720 | + */ |
|
| 1721 | + private function _setup_redirect() |
|
| 1722 | + { |
|
| 1723 | + if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
| 1724 | + $this->checkout->redirect = true; |
|
| 1725 | + if (empty($this->checkout->redirect_url)) { |
|
| 1726 | + $this->checkout->redirect_url = $this->checkout->next_step->reg_step_url(); |
|
| 1727 | + } |
|
| 1728 | + $this->checkout->redirect_url = apply_filters( |
|
| 1729 | + 'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', |
|
| 1730 | + $this->checkout->redirect_url, |
|
| 1731 | + $this->checkout |
|
| 1732 | + ); |
|
| 1733 | + } |
|
| 1734 | + } |
|
| 1735 | + |
|
| 1736 | + |
|
| 1737 | + |
|
| 1738 | + /** |
|
| 1739 | + * handle ajax message responses and redirects |
|
| 1740 | + * |
|
| 1741 | + * @access public |
|
| 1742 | + * @return void |
|
| 1743 | + * @throws EE_Error |
|
| 1744 | + */ |
|
| 1745 | + public function go_to_next_step() |
|
| 1746 | + { |
|
| 1747 | + if (EE_Registry::instance()->REQ->ajax) { |
|
| 1748 | + // capture contents of output buffer we started earlier in the request, and insert into JSON response |
|
| 1749 | + $this->checkout->json_response->set_unexpected_errors(ob_get_clean()); |
|
| 1750 | + } |
|
| 1751 | + $this->unlock_transaction(); |
|
| 1752 | + // just return for these conditions |
|
| 1753 | + if ( |
|
| 1754 | + $this->checkout->admin_request |
|
| 1755 | + || $this->checkout->action === 'redirect_form' |
|
| 1756 | + || $this->checkout->action === 'update_checkout' |
|
| 1757 | + ) { |
|
| 1758 | + return; |
|
| 1759 | + } |
|
| 1760 | + // AJAX response |
|
| 1761 | + $this->_handle_json_response(); |
|
| 1762 | + // redirect to next step or the Thank You page |
|
| 1763 | + $this->_handle_html_redirects(); |
|
| 1764 | + // hmmm... must be something wrong, so let's just display the form again ! |
|
| 1765 | + $this->_display_spco_reg_form(); |
|
| 1766 | + } |
|
| 1767 | + |
|
| 1768 | + |
|
| 1769 | + |
|
| 1770 | + /** |
|
| 1771 | + * _handle_json_response |
|
| 1772 | + * |
|
| 1773 | + * @access protected |
|
| 1774 | + * @return void |
|
| 1775 | + */ |
|
| 1776 | + protected function _handle_json_response() |
|
| 1777 | + { |
|
| 1778 | + // if this is an ajax request |
|
| 1779 | + if (EE_Registry::instance()->REQ->ajax) { |
|
| 1780 | + // DEBUG LOG |
|
| 1781 | + //$this->checkout->log( |
|
| 1782 | + // __CLASS__, __FUNCTION__, __LINE__, |
|
| 1783 | + // array( |
|
| 1784 | + // 'json_response_redirect_url' => $this->checkout->json_response->redirect_url(), |
|
| 1785 | + // 'redirect' => $this->checkout->redirect, |
|
| 1786 | + // 'continue_reg' => $this->checkout->continue_reg, |
|
| 1787 | + // ) |
|
| 1788 | + //); |
|
| 1789 | + $this->checkout->json_response->set_registration_time_limit( |
|
| 1790 | + $this->checkout->get_registration_time_limit() |
|
| 1791 | + ); |
|
| 1792 | + $this->checkout->json_response->set_payment_amount($this->checkout->amount_owing); |
|
| 1793 | + // just send the ajax ( |
|
| 1794 | + $json_response = apply_filters( |
|
| 1795 | + 'FHEE__EE_Single_Page_Checkout__JSON_response', |
|
| 1796 | + $this->checkout->json_response |
|
| 1797 | + ); |
|
| 1798 | + echo $json_response; |
|
| 1799 | + exit(); |
|
| 1800 | + } |
|
| 1801 | + } |
|
| 1802 | + |
|
| 1803 | + |
|
| 1804 | + |
|
| 1805 | + /** |
|
| 1806 | + * _handle_redirects |
|
| 1807 | + * |
|
| 1808 | + * @access protected |
|
| 1809 | + * @return void |
|
| 1810 | + */ |
|
| 1811 | + protected function _handle_html_redirects() |
|
| 1812 | + { |
|
| 1813 | + // going somewhere ? |
|
| 1814 | + if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) { |
|
| 1815 | + // store notices in a transient |
|
| 1816 | + EE_Error::get_notices(false, true, true); |
|
| 1817 | + // DEBUG LOG |
|
| 1818 | + //$this->checkout->log( |
|
| 1819 | + // __CLASS__, __FUNCTION__, __LINE__, |
|
| 1820 | + // array( |
|
| 1821 | + // 'headers_sent' => headers_sent(), |
|
| 1822 | + // 'redirect_url' => $this->checkout->redirect_url, |
|
| 1823 | + // 'headers_list' => headers_list(), |
|
| 1824 | + // ) |
|
| 1825 | + //); |
|
| 1826 | + wp_safe_redirect($this->checkout->redirect_url); |
|
| 1827 | + exit(); |
|
| 1828 | + } |
|
| 1829 | + } |
|
| 1830 | + |
|
| 1831 | + |
|
| 1832 | + |
|
| 1833 | + /** |
|
| 1834 | + * set_checkout_anchor |
|
| 1835 | + * |
|
| 1836 | + * @access public |
|
| 1837 | + * @return void |
|
| 1838 | + */ |
|
| 1839 | + public function set_checkout_anchor() |
|
| 1840 | + { |
|
| 1841 | + echo '<a id="checkout" style="float: left; margin-left: -999em;"></a>'; |
|
| 1842 | + } |
|
| 1843 | + |
|
| 1844 | + /** |
|
| 1845 | + * getRegistrationExpirationNotice |
|
| 1846 | + * |
|
| 1847 | + * @since 4.9.59.p |
|
| 1848 | + * @access public |
|
| 1849 | + * @return string |
|
| 1850 | + */ |
|
| 1851 | + public static function getRegistrationExpirationNotice() |
|
| 1852 | + { |
|
| 1853 | + return sprintf( |
|
| 1854 | + __('%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please accept our apologies for any inconvenience this may have caused.%8$s', |
|
| 1855 | + 'event_espresso'), |
|
| 1856 | + '<h4 class="important-notice">', |
|
| 1857 | + '</h4>', |
|
| 1858 | + '<br />', |
|
| 1859 | + '<p>', |
|
| 1860 | + '<a href="' . get_post_type_archive_link('espresso_events') . '" title="', |
|
| 1861 | + '">', |
|
| 1862 | + '</a>', |
|
| 1863 | + '</p>' |
|
| 1864 | + ); |
|
| 1865 | + } |
|
| 1866 | 1866 | |
| 1867 | 1867 | } |
| 1868 | 1868 | // End of file EED_Single_Page_Checkout.module.php |