function _migration_step($num_items = 50)
 {
     //get teh calendar's config
     if (isset(EE_Config::instance()->addons->EE_Calendar) && EE_Config::instance()->addons->EE_Calendar instanceof EE_Calendar_Config) {
         $c = EE_Config::instance()->addons->EE_Calendar;
     } else {
         $c = new EE_Calendar_Config();
         EE_Config::instance()->addons->EE_Calendar = $c;
     }
     $items_actually_migrated = 0;
     $old_org_options = get_option('espresso_calendar_options');
     //the option's name differened depending on the version of the calendar
     if (!$old_org_options) {
         $old_org_options = get_option('espresso_calendar_settings');
     }
     foreach ($this->_org_options_we_know_how_to_migrate as $option_name) {
         //only bother migrating if there's a setting to migrate. Otherwise we'll just use the default
         if (isset($old_org_options[$option_name])) {
             $this->_handle_org_option($option_name, $old_org_options[$option_name], $c);
         }
         $items_actually_migrated++;
     }
     //		d($c);
     $success = EE_Config::instance()->update_config('addons', 'EE_Calendar', $c);
     if (!$success) {
         $this->add_error(EE_Error::get_notices());
     }
     //		d($success);
     //		d($c);
     //		die;
     if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
         $this->set_completed();
     }
     return $items_actually_migrated;
 }
 /**
  *	_migration_step
  *
  * @access protected
  * @param int $num_items
  * @throws EE_Error
  * @return int number of items ACTUALLY migrated
  */
 protected function _migration_step($num_items = 1)
 {
     // if this isn't set then something is really wrong
     if (!EE_Config::instance()->core instanceof EE_Core_Config) {
         throw new EE_Error(__('It appears the Event Espresso Core Configuration is not setup correctly.', 'event_espresso'));
     }
     // name of the WP Posts Page
     $posts_page = $this->_get_page_for_posts();
     // make sure critical pages get removed
     $this->_update_post_shortcodes($posts_page);
     // save updated config, but don't add errors
     if (!EE_Config::instance()->update_espresso_config(FALSE, FALSE)) {
         EE_Error::add_error(__('The Event Espresso Configuration Settings were not updated when attempting to save the "critical page post shortcodes".', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
     }
     // check for errors
     $notices = EE_Error::get_notices(FALSE);
     // any errors to report?
     if (isset($notices['errors'])) {
         foreach ($notices as $value) {
             $this->add_error($value);
         }
     }
     //regardless of whether it worked or not, we ought to continue the migration
     $this->set_completed();
     return 1;
 }
 /**
  * 	_load_registry
  *
  * 	@access private
  * 	@return void
  */
 private function _load_registry()
 {
     if (is_readable(EE_CORE . 'EE_Registry.core.php')) {
         require_once EE_CORE . 'EE_Registry.core.php';
     } else {
         $msg = __('The EE_Registry core class could not be loaded.', 'event_espresso');
         EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
         wp_die(EE_Error::get_notices());
     }
 }
 /**
  * update_debug_logging_options
  *
  * @param array $admin_options
  * @return array
  */
 public function update_debug_logging_options($admin_options = array())
 {
     $use_full_logging = isset($this->_req_data['use_full_logging']) ? (bool) absint($this->_req_data['use_full_logging']) : $admin_options->use_full_logging;
     $admin_options->use_full_logging = $use_full_logging;
     if ($use_full_logging === FALSE) {
         EE_Error::get_notices(FALSE);
         EE_Error::reset_notices();
     }
     $admin_options->use_remote_logging = isset($this->_req_data['use_remote_logging']) ? absint($this->_req_data['use_remote_logging']) : $admin_options->use_remote_logging;
     $admin_options->remote_logging_url = isset($this->_req_data['remote_logging_url']) ? esc_url_raw($this->_req_data['remote_logging_url']) : $admin_options->remote_logging_url;
     return $admin_options;
 }
 /**
  * update_event_single_order
  *
  * @access    public
  * @return    void
  */
 public static function update_event_single_order()
 {
     $config_saved = false;
     $template_parts = sanitize_text_field($_POST['elements']);
     if (!empty($template_parts)) {
         $template_parts = explode(',', trim($template_parts, ','));
         foreach ($template_parts as $key => $template_part) {
             $template_part = "display_order_{$template_part}";
             $priority = $key * 10 + 100;
             EE_Registry::instance()->CFG->template_settings->EED_Event_Single->{$template_part} = $priority;
             do_action("AHEE__EED_Event_Single__update_event_single_order__{$template_part}", $priority);
         }
         $config_saved = EE_Registry::instance()->CFG->update_espresso_config(false, false);
     }
     if ($config_saved) {
         EE_Error::add_success(__('Display Order has been successfully updated.', 'event_espresso'));
     } else {
         EE_Error::add_error(__('Display Order was not updated.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
     }
     echo wp_json_encode(EE_Error::get_notices(false));
     exit;
 }
 /**
  * delete_payment
  * 	delete a payment or refund made towards a transaction
  *
  * @access public
  *	@return void
  */
 public function delete_payment()
 {
     $json_response_data = array('return_data' => FALSE);
     $PAY_ID = isset($this->_req_data['delete_txn_admin_payment'], $this->_req_data['delete_txn_admin_payment']['PAY_ID']) ? absint($this->_req_data['delete_txn_admin_payment']['PAY_ID']) : 0;
     if ($PAY_ID) {
         $delete_txn_reg_status_change = isset($this->_req_data['delete_txn_reg_status_change']) ? $this->_req_data['delete_txn_reg_status_change'] : false;
         $payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID);
         if ($payment instanceof EE_Payment) {
             /** @type EE_Transaction_Payments $transaction_payments */
             $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
             if ($transaction_payments->delete_payment_and_update_transaction($payment)) {
                 EE_Error::add_success(__('The Payment was successfully deleted.', 'event_espresso'));
                 $json_response_data['return_data'] = array('PAY_ID' => $PAY_ID, 'amount' => $payment->amount(), 'total_paid' => $payment->transaction()->paid(), 'txn_status' => $payment->transaction()->status_ID(), 'pay_status' => $payment->STS_ID(), 'delete_txn_reg_status_change' => $delete_txn_reg_status_change);
                 if ($delete_txn_reg_status_change) {
                     $this->_req_data['txn_reg_status_change'] = $delete_txn_reg_status_change;
                     //MAKE sure we also add the delete_txn_req_status_change to the
                     //$_REQUEST global because that's how messages will be looking
                     //for it.
                     $_REQUEST['txn_reg_status_change'] = $delete_txn_reg_status_change;
                     $this->_process_registration_status_change($payment->transaction());
                 }
             }
         } else {
             EE_Error::add_error(__('Valid Payment data could not be retrieved from the database.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
         }
     } else {
         $msg = __('A valid Payment ID was not received, therefore payment form data could not be loaded.', 'event_espresso');
         EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
     }
     $notices = EE_Error::get_notices(FALSE, FALSE, FALSE);
     echo json_encode(array_merge($json_response_data, $notices));
     die;
 }
 function _migration_step($num_items = 50)
 {
     $items_actually_migrated = 0;
     $old_org_options = get_option('events_organization_settings');
     foreach ($this->_org_options_we_know_how_to_migrate as $option_name) {
         //only bother migrating if there's a setting to migrate. Otherwise we'll just use the default
         if (isset($old_org_options[$option_name])) {
             $this->_handle_org_option($option_name, $old_org_options[$option_name]);
         }
         if ($option_name == 'surcharge') {
             $this->_insert_new_global_surcharge_price($old_org_options);
         }
         $items_actually_migrated++;
     }
     $success = EE_Config::instance()->update_espresso_config(FALSE, TRUE);
     if (!$success) {
         $this->add_error(sprintf(__('Could not save EE Config during org options stage. Reason: %s', 'event_espresso'), EE_Error::get_notices(FALSE)));
         EE_Error::overwrite_errors();
     }
     EE_Network_Config::instance()->update_config(FALSE, FALSE);
     if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
         //we may have added new pages and this might be necessary
         flush_rewrite_rules();
         $this->set_completed();
     }
     return $items_actually_migrated;
 }
 /**
  *    __toString
  *
  * 		allows you to simply echo or print an EE_SPCO_JSON_Response object to produce a  JSON encoded string
  * 		ie: $json_response = new EE_SPCO_JSON_Response();
  * 		echo $json_response;
  *
  * @access    public
  * @return    string
  */
 public function __toString()
 {
     $JSON_response = array();
     // grab notices
     $notices = EE_Error::get_notices(FALSE);
     $this->set_attention(isset($notices['attention']) ? $notices['attention'] : '');
     $this->set_errors(isset($notices['errors']) ? $notices['errors'] : '');
     $this->set_success(isset($notices['success']) ? $notices['success'] : '');
     // add notices to JSON response, but only if they exist
     if ($this->attention()) {
         $JSON_response['attention'] = $this->attention();
     }
     if ($this->errors()) {
         $JSON_response['errors'] = $this->errors();
     }
     if ($this->unexpected_errors()) {
         $JSON_response['unexpected_errors'] = $this->unexpected_errors();
     }
     if ($this->success()) {
         $JSON_response['success'] = $this->success();
     }
     // but if NO notices are set... at least set the "success" as a key so that the JS knows everything worked
     if (!isset($JSON_response['attention']) && !isset($JSON_response['errors']) && !isset($JSON_response['success'])) {
         $JSON_response['success'] = null;
     }
     // set redirect_url, IF it exists
     if ($this->redirect_url()) {
         $JSON_response['redirect_url'] = $this->redirect_url();
     }
     // set registration_time_limit, IF it exists
     if ($this->registration_time_limit()) {
         $JSON_response['registration_time_limit'] = $this->registration_time_limit();
     }
     // set payment_amount, IF it exists
     if ($this->payment_amount() !== null) {
         $JSON_response['payment_amount'] = $this->payment_amount();
     }
     // grab generic return data
     $return_data = $this->return_data();
     // add billing form validation rules
     if ($this->validation_rules()) {
         $return_data['validation_rules'] = $this->validation_rules();
     }
     // set reg_step_html, IF it exists
     if ($this->reg_step_html()) {
         $return_data['reg_step_html'] = $this->reg_step_html();
     }
     // set method of payment, IF it exists
     if ($this->method_of_payment()) {
         $return_data['method_of_payment'] = $this->method_of_payment();
     }
     // set "plz_select_method_of_payment" message, IF it exists
     if ($this->plz_select_method_of_payment()) {
         $return_data['plz_select_method_of_payment'] = $this->plz_select_method_of_payment();
     }
     // set redirect_form, IF it exists
     if ($this->redirect_form()) {
         $return_data['redirect_form'] = $this->redirect_form();
     }
     // and finally, add return_data array to main JSON response array, IF it contains anything
     // why did we add some of the above properties to the return data array?
     // because it is easier and cleaner in the Javascript to deal with this way
     if (!empty($return_data)) {
         $JSON_response['return_data'] = $return_data;
     }
     // filter final array
     $JSON_response = apply_filters('FHEE__EE_SPCO_JSON_Response___toString__JSON_response', $JSON_response);
     // return encoded array
     return json_encode($JSON_response);
 }
 /**
  * 	resend_reg_confirmation_email
  */
 public static function resend_reg_confirmation_email()
 {
     EE_Registry::instance()->load_core('Request_Handler');
     $reg_url_link = EE_Registry::instance()->REQ->get('token');
     // was a REG_ID passed ?
     if ($reg_url_link) {
         $registration = EE_Registry::instance()->load_model('Registration')->get_one(array(array('REG_url_link' => $reg_url_link)));
         if ($registration instanceof EE_Registration) {
             // resend email
             EED_Messages::process_resend(array('_REG_ID' => $registration->ID()));
         } else {
             EE_Error::add_error(__('The Registration Confirmation email could not be sent because a valid Registration could not be retrieved from the database.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
         }
     } else {
         EE_Error::add_error(__('The Registration Confirmation email could not be sent because a registration token is missing or invalid.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
     }
     // request sent via AJAX ?
     if (EE_FRONT_AJAX) {
         echo json_encode(EE_Error::get_notices(FALSE));
         die;
         // or was JS disabled ?
     } else {
         // save errors so that they get picked up on the next request
         EE_Error::get_notices(TRUE, TRUE);
         wp_safe_redirect(add_query_arg(array('e_reg_url_link' => $reg_url_link), EE_Registry::instance()->CFG->core->thank_you_page_url()));
     }
 }
Ejemplo n.º 10
0
 /**
  * 	display_admin_notices
  *
  *  @access 	public
  *  @return 	string
  */
 public function display_admin_notices()
 {
     echo EE_Error::get_notices();
 }
 /**
  * 	process_ticket_selections
  *
  *	@access public
  * 	@access 		public
  * 	@return		array  or FALSE
  */
 public function process_ticket_selections()
 {
     do_action('EED_Ticket_Selector__process_ticket_selections__before');
     // check nonce
     if (!is_admin() && (!EE_Registry::instance()->REQ->is_set('process_ticket_selections_nonce') || !wp_verify_nonce(EE_Registry::instance()->REQ->get('process_ticket_selections_nonce'), 'process_ticket_selections'))) {
         EE_Error::add_error(sprintf(__('We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.', 'event_espresso'), '<br/>'), __FILE__, __FUNCTION__, __LINE__);
         return FALSE;
     }
     //		d( EE_Registry::instance()->REQ );
     self::$_available_spaces = array('tickets' => array(), 'datetimes' => array());
     //we should really only have 1 registration in the works now (ie, no MER) so clear any previous items in the cart.
     // When MER happens this will probably need to be tweaked, possibly wrapped in a conditional checking for some constant defined in MER etc.
     EE_Registry::instance()->load_core('Session');
     // unless otherwise requested, clear the session
     if (apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', TRUE)) {
         EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
     }
     //d( EE_Registry::instance()->SSN );
     do_action('AHEE_log', __FILE__, __FUNCTION__, '');
     // do we have an event id?
     if (EE_Registry::instance()->REQ->is_set('tkt-slctr-event-id')) {
         // validate/sanitize data
         $valid = self::_validate_post_data();
         //EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ );
         //EEH_Debug_Tools::printr( $valid, '$valid', __FILE__, __LINE__ );
         //EEH_Debug_Tools::printr( $valid[ 'total_tickets' ], 'total_tickets', __FILE__, __LINE__ );
         //EEH_Debug_Tools::printr( $valid[ 'max_atndz' ], 'max_atndz', __FILE__, __LINE__ );
         //check total tickets ordered vs max number of attendees that can register
         if ($valid['total_tickets'] > $valid['max_atndz']) {
             // ordering too many tickets !!!
             $total_tickets_string = _n('You have attempted to purchase %s ticket.', 'You have attempted to purchase %s tickets.', $valid['total_tickets'], 'event_espresso');
             $limit_error_1 = sprintf($total_tickets_string, $valid['total_tickets']);
             // dev only message
             $max_atndz_string = _n('The registration limit for this event is %s ticket per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.', 'The registration limit for this event is %s tickets per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.', $valid['max_atndz'], 'event_espresso');
             $limit_error_2 = sprintf($max_atndz_string, $valid['max_atndz'], $valid['max_atndz']);
             EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__);
         } else {
             // all data appears to be valid
             $tckts_slctd = FALSE;
             $success = TRUE;
             // load cart
             EE_Registry::instance()->load_core('Cart');
             // cycle thru the number of data rows sent from the event listing
             for ($x = 0; $x < $valid['rows']; $x++) {
                 // does this row actually contain a ticket quantity?
                 if (isset($valid['qty'][$x]) && $valid['qty'][$x] > 0) {
                     // YES we have a ticket quantity
                     $tckts_slctd = TRUE;
                     //						d( $valid['ticket_obj'][$x] );
                     if ($valid['ticket_obj'][$x] instanceof EE_Ticket) {
                         // then add ticket to cart
                         $ticket_added = self::_add_ticket_to_cart($valid['ticket_obj'][$x], $valid['qty'][$x]);
                         $success = !$ticket_added ? FALSE : $success;
                         if (EE_Error::has_error()) {
                             break;
                         }
                     } else {
                         // nothing added to cart retrieved
                         EE_Error::add_error(sprintf(__('A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.', 'event_espresso'), '<br/>'), __FILE__, __FUNCTION__, __LINE__);
                     }
                 }
             }
             //d( EE_Registry::instance()->CART );
             //die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE
             if ($tckts_slctd) {
                 if ($success) {
                     do_action('FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout', EE_Registry::instance()->CART, $this);
                     EE_Registry::instance()->CART->recalculate_all_cart_totals();
                     EE_Registry::instance()->CART->save_cart(FALSE);
                     EE_Registry::instance()->SSN->update();
                     //d( EE_Registry::instance()->CART );
                     //die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< OR HERE TO KILL REDIRECT AFTER CART UPDATE
                     // just return TRUE for registrations being made from admin
                     if (is_admin()) {
                         return TRUE;
                     }
                     wp_safe_redirect(apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url', EE_Registry::instance()->CFG->core->reg_page_url()));
                     exit;
                 } else {
                     if (!EE_Error::has_error()) {
                         // nothing added to cart
                         EE_Error::add_attention(__('No tickets were added for the event', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
                     }
                 }
             } else {
                 // no ticket quantities were selected
                 EE_Error::add_error(__('You need to select a ticket quantity before you can proceed.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
             }
         }
         //die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL BEFORE REDIRECT
         // at this point, just return if registration is being made from admin
         if (is_admin()) {
             return FALSE;
         }
         if ($valid['return_url']) {
             EE_Error::get_notices(FALSE, TRUE);
             wp_safe_redirect($valid['return_url']);
             exit;
         } elseif (isset($event_to_add['id'])) {
             EE_Error::get_notices(FALSE, TRUE);
             wp_safe_redirect(get_permalink($event_to_add['id']));
             exit;
         } else {
             echo EE_Error::get_notices();
         }
     } else {
         // $_POST['tkt-slctr-event-id'] was not set ?!?!?!?
         EE_Error::add_error(sprintf(__('An event id was not provided or was not received.%sPlease click the back button on your browser and try again.', 'event_espresso'), '<br/>'), __FILE__, __FUNCTION__, __LINE__);
     }
     return FALSE;
 }
 /**
  * 		delete a payment or refund made towards a transaction
  *		@access public
  *		@return void
  */
 public function delete_payment()
 {
     $return_data = array();
     if (isset($this->_req_data['delete_txn_admin_payment'])) {
         $pymt = $this->_req_data['delete_txn_admin_payment'];
         if ($payment = EEM_Payment::instance()->get_one_by_ID($pymt['PAY_ID'])) {
             if ($transaction = EEM_Payment::instance()->delete_by_ID($payment->ID())) {
                 $return_data = array('amount' => $payment->amount(), 'total_paid' => $transaction->paid(), 'txn_status' => $transaction->status_ID(), 'pay_status' => $payment->STS_ID(), 'PAY_ID' => $pymt['PAY_ID'], 'delete_txn_reg_status_change' => $this->_req_data['delete_txn_reg_status_change']);
             }
         }
         if (isset($this->_req_data['delete_txn_reg_status_change'])) {
             $this->_req_data['txn_reg_status_change'] = $this->_req_data['delete_txn_reg_status_change'];
             $_REQUEST['txn_reg_status_change'] = $this->_req_data['delete_txn_reg_status_change'];
             $this->_process_registration_status_change($transaction);
         }
     } else {
         $msg = __('An error occurred. The payment form data could not be loaded.', 'event_espresso');
         EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
         $return_data = FALSE;
     }
     $notices = EE_Error::get_notices(FALSE, FALSE, FALSE);
     echo json_encode(array('return_data' => $return_data, 'success' => $notices['success'], 'errors' => $notices['errors']));
     die;
 }
 /**
  * This basically mimics the WordPress _doing_it_wrong() function except adds our own messaging etc.  Very useful for providing helpful messages to developers when the method of doing something has been deprecated, or we want to make sure they use something the right way.
  *
  * @access public
  * @param  string $function The function that was called
  * @param  string $message A message explaining what has been done incorrectly
  * @param  string $version The version of Event Espresso where the error was added
  * @param int     $error_type
  * @uses trigger_error()
  */
 public function doing_it_wrong($function, $message, $version, $error_type = E_USER_NOTICE)
 {
     do_action('AHEE__EEH_Debug_Tools__doing_it_wrong_run', $function, $message, $version);
     $version = is_null($version) ? '' : sprintf(__('(This message was added in version %s of Event Espresso.', 'event_espresso'), $version);
     $error_message = sprintf(esc_html__('%1$s was called %2$sincorrectly%3$s. %4$s %5$s', 'event_espresso'), $function, '<strong>', '</strong>', $message, $version);
     //don't trigger error if doing ajax, instead we'll add a transient EE_Error notice that in theory should show on the next request.
     if (defined('DOING_AJAX') && DOING_AJAX) {
         $error_message .= esc_html__('This is a doing_it_wrong message that was triggered during an ajax request.  The request params on this request were: ', 'event_espresso');
         $error_message .= '<ul><li>';
         $error_message .= implode('</li><li>', EE_Registry::instance()->REQ->params());
         $error_message .= '</ul>';
         EE_Error::add_error($error_message, 'debug::doing_it_wrong', $function, '42');
         //now we set this on the transient so it shows up on the next request.
         EE_Error::get_notices(is_admin(), true);
     } else {
         trigger_error($error_message, $error_type);
     }
 }
 /**
  *   handle ajax message responses
  *
  * @access protected
  * @param bool $empty_cart
  * @param string  $redirect_url
  * @return void
  */
 protected function send_ajax_response($empty_cart = false, $redirect_url = '')
 {
     $grand_total = EE_Registry::instance()->CART->get_grand_total();
     $grand_total->recalculate_total_including_taxes();
     $empty_cart = $empty_cart || EE_Registry::instance()->CART->all_ticket_quantity_count() < 1 ? true : false;
     // if this is an ajax request AND a callback function exists
     if ($this->_ajax === true) {
         // grab updated html for the event cart
         $new_html = array('tbody' => '<tbody>' . $this->_get_event_cart() . '</tbody>');
         if ($empty_cart) {
             $new_html['.event-cart-grand-total'] = '';
             $new_html['.event-cart-register-button'] = '';
         }
         // just send the ajax
         echo json_encode(array_merge(EE_Error::get_notices(false), array('new_html' => $new_html, 'mini_cart' => EED_Multi_Event_Registration::get_mini_cart())));
         // to be... or...
         die;
     }
     EE_Error::get_notices(false, true);
     $redirect_url = !empty($redirect_url) ? $redirect_url : add_query_arg(array('event_cart' => 'view'), EE_EVENT_QUEUE_BASE_URL);
     wp_safe_redirect($redirect_url);
     exit;
 }
 /**
  * update_debug_logging_options
  *
  * @param array $admin_options
  * @return array
  */
 public function update_debug_logging_options($admin_options = array())
 {
     $use_full_logging = isset($this->_req_data['use_full_logging']) ? (bool) absint($this->_req_data['use_full_logging']) : $admin_options->use_full_logging;
     // trying to enable full logging for the first time?
     if ($use_full_logging && $use_full_logging !== $admin_options->use_full_logging) {
         $admin_options->use_full_logging = $this->_request_filesystem_credentials() ? TRUE : NULL;
         if ($admin_options->use_full_logging === NULL) {
             add_filter('FHEE__General_Settings_Admin_Page___update_admin_option_settings__success', '__return_false');
         }
     } else {
         $admin_options->use_full_logging = $use_full_logging;
     }
     if ($use_full_logging === FALSE) {
         EE_Error::get_notices(FALSE);
         EE_Error::reset_notices();
     }
     $admin_options->use_remote_logging = isset($this->_req_data['use_remote_logging']) ? absint($this->_req_data['use_remote_logging']) : $admin_options->use_remote_logging;
     $admin_options->remote_logging_url = isset($this->_req_data['remote_logging_url']) ? esc_url_raw($this->_req_data['remote_logging_url']) : $admin_options->remote_logging_url;
     return $admin_options;
 }
 /**
  * Returns a json response
  *
  * @param array $data The data we want to send echo via in the JSON response's "data" element
  *
  * The returned json object is created from an array in the following format:
  * array(
  * 	'notices' => '', // - contains any EE_Error formatted notices
  * 	'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js. We're also going to include the template args with every package (so js can pick out any specific template args that might be included in here)
  *	'isEEajax' => true,//indicates this is a response from EE
  * )
  */
 protected function _return_json($data)
 {
     $json = array('notices' => EE_Error::get_notices(), 'data' => $data, 'isEEajax' => TRUE);
     // make sure there are no php errors or headers_sent.  Then we can set correct json header.
     if (NULL === error_get_last() || !headers_sent()) {
         header('Content-Type: application/json; charset=UTF-8');
     }
     if (function_exists('wp_json_encode')) {
         echo wp_json_encode($json);
     } else {
         echo json_encode($json);
     }
     exit;
 }
 /**
  * This basically mimics the WordPress _doing_it_wrong() function except adds our own messaging etc.
  * Very useful for providing helpful messages to developers when the method of doing something has been deprecated,
  * or we want to make sure they use something the right way.
  *
  * @access public
  * @param string $function      The function that was called
  * @param string $message       A message explaining what has been done incorrectly
  * @param string $version       The version of Event Espresso where the error was added
  * @param string  $applies_when a version string for when you want the doing_it_wrong notice to begin appearing
  *                              for a deprecated function. This allows deprecation to occur during one version,
  *                              but not have any notices appear until a later version. This allows developers
  *                              extra time to update their code before notices appear.
  * @param int     $error_type
  * @uses   trigger_error()
  */
 public function doing_it_wrong($function, $message, $version, $applies_when = '', $error_type = null)
 {
     $applies_when = !empty($applies_when) ? $applies_when : espresso_version();
     $error_type = $error_type !== null ? $error_type : E_USER_NOTICE;
     // because we swapped the parameter order around for the last two params,
     // let's verify that some third party isn't still passing an error type value for the third param
     if (is_int($applies_when)) {
         $error_type = $applies_when;
         $applies_when = espresso_version();
     }
     // if not displaying notices yet, then just leave
     if (version_compare(espresso_version(), $applies_when, '<')) {
         return;
     }
     do_action('AHEE__EEH_Debug_Tools__doing_it_wrong_run', $function, $message, $version);
     $version = $version === null ? '' : sprintf(__('(This message was added in version %s of Event Espresso)', 'event_espresso'), $version);
     $error_message = sprintf(esc_html__('%1$s was called %2$sincorrectly%3$s. %4$s %5$s', 'event_espresso'), $function, '<strong>', '</strong>', $message, $version);
     //don't trigger error if doing ajax, instead we'll add a transient EE_Error notice that in theory should show on the next request.
     if (defined('DOING_AJAX') && DOING_AJAX) {
         $error_message .= ' ' . esc_html__('This is a doing_it_wrong message that was triggered during an ajax request.  The request params on this request were: ', 'event_espresso');
         $error_message .= '<ul><li>';
         $error_message .= implode('</li><li>', EE_Registry::instance()->REQ->params());
         $error_message .= '</ul>';
         EE_Error::add_error($error_message, 'debug::doing_it_wrong', $function, '42');
         //now we set this on the transient so it shows up on the next request.
         EE_Error::get_notices(false, true);
     } else {
         trigger_error($error_message, $error_type);
     }
 }
 protected function _assertNoImportErrors()
 {
     $notices = EE_Error::get_notices(false, false, true);
     $this->assertEmpty(EE_Import::instance()->get_total_update_errors(), isset($notices['errors']) ? $notices['errors'] : '');
     $this->assertEmpty(EE_Import::instance()->get_total_insert_errors(), isset($notices['errors']) ? $notices['errors'] : '');
 }
 /**
  *    dismiss_persistent_admin_notice
  *
  * @access    public
  * @param        string $pan_name the name, or key of the Persistent Admin Notice to be dismissed
  * @param bool          $purge
  * @param bool          $return_immediately
  * @return        void
  */
 public static function dismiss_persistent_admin_notice($pan_name = '', $purge = FALSE, $return_immediately = FALSE)
 {
     $pan_name = EE_Registry::instance()->REQ->is_set('ee_nag_notice') ? EE_Registry::instance()->REQ->get('ee_nag_notice') : $pan_name;
     if (!empty($pan_name)) {
         $persistent_admin_notices = get_option('ee_pers_admin_notices', array());
         // check if notice we wish to dismiss is actually in the $persistent_admin_notices array
         if (is_array($persistent_admin_notices) && isset($persistent_admin_notices[$pan_name])) {
             // completely delete nag notice, or just NULL message so that it can NOT be added again ?
             if ($purge) {
                 unset($persistent_admin_notices[$pan_name]);
             } else {
                 $persistent_admin_notices[$pan_name] = NULL;
             }
             if (update_option('ee_pers_admin_notices', $persistent_admin_notices) === FALSE) {
                 EE_Error::add_error(sprintf(__('The persistent admin notice for "%s" could not be deleted.', 'event_espresso'), $pan_name), __FILE__, __FUNCTION__, __LINE__);
             }
         }
     }
     if ($return_immediately) {
         return;
     } else {
         if (EE_Registry::instance()->REQ->ajax) {
             // grab any notices and concatenate into string
             echo json_encode(array('errors' => implode('<br />', EE_Error::get_notices(FALSE))));
             exit;
         } else {
             // save errors to a transient to be displayed on next request (after redirect)
             EE_Error::get_notices(FALSE, TRUE);
             $return_url = EE_Registry::instance()->REQ->is_set('return_url') ? EE_Registry::instance()->REQ->get('return_url') : '';
             wp_safe_redirect(urldecode($return_url));
         }
     }
 }
 public function tearDown()
 {
     parent::tearDown();
     global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter, $current_user;
     $wp_filter = $this->wp_filters_saved['wp_filter'];
     $wp_actions = $this->wp_filters_saved['wp_actions'];
     $merged_filters = $this->wp_filters_saved['merged_filters'];
     $wp_current_filter = $this->wp_filters_saved['wp_current_filter'];
     $current_user = $this->_orig_current_user;
     $this->_detect_accidental_txn_commit();
     $notices = EE_Error::get_notices(false, false, true);
     EE_Error::reset_notices();
     if (!empty($notices['errors'])) {
         $this->fail($notices['errors']);
     }
 }
 /**
  * delete_payment
  * 	delete a payment or refund made towards a transaction
  *
  * @access public
  *	@return void
  */
 public function delete_payment()
 {
     $json_response_data = array('return_data' => FALSE);
     $PAY_ID = isset($this->_req_data['delete_txn_admin_payment'], $this->_req_data['delete_txn_admin_payment']['PAY_ID']) ? absint($this->_req_data['delete_txn_admin_payment']['PAY_ID']) : 0;
     if ($PAY_ID) {
         $delete_txn_reg_status_change = isset($this->_req_data['delete_txn_reg_status_change']) ? $this->_req_data['delete_txn_reg_status_change'] : false;
         $payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID);
         if ($payment instanceof EE_Payment) {
             $REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment);
             /** @type EE_Transaction_Payments $transaction_payments */
             $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
             if ($transaction_payments->delete_payment_and_update_transaction($payment)) {
                 EE_Error::add_success(__('The Payment was successfully deleted.', 'event_espresso'));
                 $json_response_data['return_data'] = array('PAY_ID' => $PAY_ID, 'amount' => $payment->amount(), 'total_paid' => $payment->transaction()->paid(), 'txn_status' => $payment->transaction()->status_ID(), 'pay_status' => $payment->STS_ID(), 'delete_txn_reg_status_change' => $delete_txn_reg_status_change);
                 //if non empty reg_ids lets get an array of registrations and update the values for the apply_payment/refund rows.
                 if (!empty($REG_IDs)) {
                     EE_Registry::instance()->load_helper('Template');
                     $registrations = EEM_Registration::instance()->get_all(array(array('REG_ID' => array('IN', $REG_IDs))));
                     foreach ($registrations as $registration) {
                         $json_response_data['return_data']['registrations'][$registration->ID()] = array('owing' => EEH_Template::format_currency($registration->final_price() - $registration->paid()), 'paid' => $registration->pretty_paid());
                     }
                 }
                 if ($delete_txn_reg_status_change) {
                     $this->_req_data['txn_reg_status_change'] = $delete_txn_reg_status_change;
                     //MAKE sure we also add the delete_txn_req_status_change to the
                     //$_REQUEST global because that's how messages will be looking
                     //for it.
                     $_REQUEST['txn_reg_status_change'] = $delete_txn_reg_status_change;
                     $this->_process_registration_status_change($payment->transaction());
                 }
             }
         } else {
             EE_Error::add_error(__('Valid Payment data could not be retrieved from the database.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
         }
     } else {
         $msg = __('A valid Payment ID was not received, therefore payment form data could not be loaded.', 'event_espresso');
         EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
     }
     $notices = EE_Error::get_notices(FALSE, FALSE, FALSE);
     echo json_encode(array_merge($json_response_data, $notices));
     die;
 }
Ejemplo n.º 22
0
 /**
  * This redirects to the about EE page after activation
  * @return void
  */
 public function redirect_to_about_ee()
 {
     $notices = EE_Error::get_notices(FALSE);
     //if current user is an admin and it's not an ajax request
     if ($this->registry->CAP->current_user_can('manage_options', 'espresso_about_default') && !(defined('DOING_AJAX') && DOING_AJAX) && !isset($notices['errors'])) {
         $query_params = array('page' => 'espresso_about');
         if (EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation) {
             $query_params['new_activation'] = TRUE;
         }
         if (EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation) {
             $query_params['reactivation'] = TRUE;
         }
         $url = add_query_arg($query_params, admin_url('admin.php'));
         wp_safe_redirect($url);
         exit;
     }
 }
 /**
  *   _handle_redirects
  *
  * @access protected
  * @return void
  */
 protected function _handle_html_redirects()
 {
     // going somewhere ?
     if ($this->checkout->redirect && !empty($this->checkout->redirect_url)) {
         // store notices in a transient
         EE_Error::get_notices(false, true, true);
         $this->unlock_transaction();
         // DEBUG LOG
         //$this->checkout->log(
         //	__CLASS__, __FUNCTION__, __LINE__,
         //	array(
         //		'headers_sent' => headers_sent(),
         //		'redirect_url'     => $this->checkout->redirect_url,
         //		'headers_list'    => headers_list(),
         //	)
         //);
         wp_safe_redirect($this->checkout->redirect_url);
         exit;
     }
 }
 /**
  * process any notices before redirecting (or returning ajax request)
  * This method sets the $this->_template_args['notices'] attribute;
  *
  * @param  array  $query_args any query args that need to be used for notice transient ('action')
  * @param bool    $skip_route_verify This is typically used when we are processing notices REALLY early and page_routes haven't been defined yet.
  * @param bool    $sticky_notices      This is used to flag that regardless of whether this is doing_ajax or not, we still save a transient for the notice.
  * @return void
  */
 protected function _process_notices($query_args = array(), $skip_route_verify = FALSE, $sticky_notices = TRUE)
 {
     //first let's set individual error properties if doing_ajax and the properties aren't already set.
     if (defined('DOING_AJAX') && DOING_AJAX) {
         $notices = EE_Error::get_notices(false);
         if (empty($this->_template_args['success'])) {
             $this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
         }
         if (empty($this->_template_args['errors'])) {
             $this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
         }
         if (empty($this->_template_args['attention'])) {
             $this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
         }
     }
     $this->_template_args['notices'] = EE_Error::get_notices();
     //IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
     if (!defined('DOING_AJAX') || $sticky_notices) {
         $route = isset($query_args['action']) ? $query_args['action'] : 'default';
         $this->_add_transient($route, $this->_template_args['notices'], TRUE, $skip_route_verify);
     }
 }
 /**
  * 		generates HTML for the Registration main meta box
  *		@access public
  *		@return void
  */
 public function _reg_attendees_meta_box()
 {
     $REG = EEM_Registration::instance();
     //get all other registrations on this transaction, and cache
     //the attendees for them so we don't have to run another query using force_join
     $registrations = $REG->get_all(array(array('TXN_ID' => $this->_registration->transaction_ID(), 'REG_ID' => array('!=', $this->_registration->ID())), 'force_join' => array('Attendee')));
     $this->_template_args['attendees'] = array();
     $this->_template_args['attendee_notice'] = '';
     EE_Registry::instance()->load_helper('Array');
     if (empty($registrations) || is_array($registrations) && !EEH_Array::get_one_item_from_array($registrations)) {
         EE_Error::add_error(__('There are no records attached to this registration. Something may have gone wrong with the registration', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
         $this->_template_args['attendee_notice'] = EE_Error::get_notices();
     } else {
         $att_nmbr = 1;
         foreach ($registrations as $registration) {
             /* @var $registration EE_Registration */
             $attendee = $registration->attendee() ? $registration->attendee() : EEM_Attendee::instance()->create_default_object();
             $this->_template_args['attendees'][$att_nmbr]['fname'] = $attendee->fname();
             //( isset( $registration->ATT_fname ) & ! empty( $registration->ATT_fname ) ) ? $registration->ATT_fname : '';
             $this->_template_args['attendees'][$att_nmbr]['lname'] = $attendee->lname();
             //( isset( $registration->ATT_lname ) & ! empty( $registration->ATT_lname ) ) ? $registration->ATT_lname : '';
             $this->_template_args['attendees'][$att_nmbr]['email'] = $attendee->email();
             //( isset( $registration->ATT_email ) & ! empty( $registration->ATT_email ) ) ? $registration->ATT_email : '';
             $this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price();
             //( isset( $registration->REG_final_price ) & ! empty( $registration->REG_final_price ) ) ? $registration->REG_final_price : '';
             $this->_template_args['attendees'][$att_nmbr]['address'] = implode(', ', $attendee->full_address_as_array());
             $this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce(array('action' => 'edit_attendee', 'post' => $attendee->ID()), REG_ADMIN_URL);
             $att_nmbr++;
         }
         //EEH_Debug_Tools::printr( $attendees, '$attendees  <br /><span style="font-size:10px;font-weight:normal;">( file: '. __FILE__ . ' - line no: ' . __LINE__ . ' )</span>', 'auto' );
         $this->_template_args['event_name'] = $this->_registration->event_obj()->name();
         $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
         //			$this->_template_args['registration_form_url'] = add_query_arg( array( 'action' => 'edit_registration', 'process' => 'attendees'  ), REG_ADMIN_URL );
     }
     $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
     echo EEH_Template::display_template($template_path, $this->_template_args, TRUE);
 }
 /**
  * 	display_errors
  *
  *  @access 	public
  *  @return 	string
  */
 public function display_errors()
 {
     static $shown_already = FALSE;
     do_action('AHEE__EE_Front_Controller__display_errors__begin');
     if (!$shown_already && apply_filters('FHEE__EE_Front_Controller__display_errors', TRUE) && is_main_query() && !is_feed() && in_the_loop() && $this->Request_Handler->is_espresso_page()) {
         echo EE_Error::get_notices();
         $shown_already = TRUE;
         EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php');
     }
     do_action('AHEE__EE_Front_Controller__display_errors__end');
 }
 /**
  * verify_default_pages_exist
  *
  * 	@access public
  * 	@static
  * 	@return void
  */
 public static function verify_default_pages_exist()
 {
     $critical_page_problem = FALSE;
     $critical_pages = array(array('id' => 'reg_page_id', 'name' => __('Registration Checkout', 'event_espresso'), 'post' => NULL, 'code' => 'ESPRESSO_CHECKOUT'), array('id' => 'txn_page_id', 'name' => __('Transactions', 'event_espresso'), 'post' => NULL, 'code' => 'ESPRESSO_TXN_PAGE'), array('id' => 'thank_you_page_id', 'name' => __('Thank You', 'event_espresso'), 'post' => NULL, 'code' => 'ESPRESSO_THANK_YOU'), array('id' => 'cancel_page_id', 'name' => __('Registration Cancelled', 'event_espresso'), 'post' => NULL, 'code' => 'ESPRESSO_CANCELLED'));
     foreach ($critical_pages as $critical_page) {
         // is critical page ID set in config ?
         if (EE_Registry::instance()->CFG->core->{$critical_page}['id'] !== FALSE) {
             // attempt to find post by ID
             $critical_page['post'] = get_post(EE_Registry::instance()->CFG->core->{$critical_page}['id']);
         }
         // no dice?
         if ($critical_page['post'] == NULL) {
             // attempt to find post by title
             $critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']);
             // still nothing?
             if ($critical_page['post'] == NULL) {
                 $critical_page = EEH_Activation::create_critical_page($critical_page);
                 // REALLY? Still nothing ??!?!?
                 if ($critical_page['post'] == NULL) {
                     $msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso');
                     EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
                     break;
                 }
             }
         }
         // track post_shortcodes
         if ($critical_page['post']) {
             EEH_Activation::_track_critical_page_post_shortcodes($critical_page);
         }
         // check that Post ID matches critical page ID in config
         if (isset($critical_page['post']->ID) && $critical_page['post']->ID != EE_Registry::instance()->CFG->core->{$critical_page}['id']) {
             //update Config with post ID
             EE_Registry::instance()->CFG->core->{$critical_page}['id'] = $critical_page['post']->ID;
             if (!EE_Config::instance()->update_espresso_config(FALSE, FALSE)) {
                 $msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso');
                 EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
             }
         }
         $critical_page_problem = !isset($critical_page['post']->post_status) || $critical_page['post']->post_status != 'publish' || strpos($critical_page['post']->post_content, $critical_page['code']) === FALSE ? TRUE : $critical_page_problem;
     }
     if ($critical_page_problem) {
         $msg = sprintf(__('A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', 'event_espresso'), '<a href="' . admin_url('admin.php?page=espresso_general_settings&action=critical_pages') . '">' . __('Event Espresso Critical Pages Settings', 'event_espresso') . '</a>');
         EE_Error::add_persistent_admin_notice('critical_page_problem', $msg);
     }
     if (EE_Error::has_notices()) {
         EE_Error::get_notices(FALSE, TRUE, TRUE);
     }
 }
 /**
  * process any notices before redirecting (or returning ajax request)
  * This method sets the $this->_template_args['notices'] attribute;
  *
  * @param  array  $query_args any query args that need to be used for notice transient ('action')
  * @param bool    $skip_route_verify This is typically used when we are processing notices REALLY early and page_routes haven't been defined yet.
  * @param bool    $sticky_notices      This is used to flag that regardless of whether this is doing_ajax or not, we still save a transient for the notice.
  * @return void
  */
 protected function _process_notices($query_args = array(), $skip_route_verify = FALSE, $sticky_notices = TRUE)
 {
     $this->_template_args['notices'] = EE_Error::get_notices();
     //IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
     if (!defined('DOING_AJAX') || $sticky_notices) {
         $route = isset($query_args['action']) ? $query_args['action'] : 'default';
         $this->_add_transient($route, $this->_template_args['notices'], TRUE, $skip_route_verify);
     }
 }
 /**
  * 		delete_state
  *
  * 		@access 	public
  * 		@return 		boolean | void
  */
 public function delete_state()
 {
     $CNT_ISO = isset($this->_req_data['CNT_ISO']) ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) : FALSE;
     $STA_ID = isset($this->_req_data['STA_ID']) ? sanitize_text_field($this->_req_data['STA_ID']) : FALSE;
     $STA_abbrev = isset($this->_req_data['STA_abbrev']) ? sanitize_text_field($this->_req_data['STA_abbrev']) : FALSE;
     if (!$STA_ID) {
         EE_Error::add_error(__('No State ID or an invalid State ID was received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
         return FALSE;
     }
     $success = EEM_State::instance()->delete_by_ID($STA_ID);
     if ($success !== FALSE) {
         do_action('AHEE__General_Settings_Admin_Page__delete_state__state_deleted', $CNT_ISO, $STA_ID, array('STA_abbrev' => $STA_abbrev));
         EE_Error::add_success(__('The State was deleted successfully.', 'event_espresso'));
     }
     if (defined('DOING_AJAX')) {
         $notices = EE_Error::get_notices(FALSE, FALSE);
         $notices['return_data'] = TRUE;
         echo json_encode($notices);
         die;
     } else {
         $this->_redirect_after_action($success, 'State', 'deleted', array('action' => 'country_settings'));
     }
 }
 /**
  *   handle ajax message responses and redirects
  *
  * @access public
  * @param string $prev_step
  * @param bool   $callback
  * @param bool   $callback_param
  * @return void
  */
 public function go_to_next_step($prev_step = '', $callback = FALSE, $callback_param = FALSE)
 {
     $no_errors = TRUE;
     switch ($this->_next_step) {
         case 'registration_confirmation':
             $callback = '_go_to_registration_confirmation_ajax_response';
             break;
         case 'finalize_registration':
             $callback = $this->_revisit ? '_finalize_' . $this->_current_step : '_process_finalize_registration';
             break;
     }
     $notices = EE_Error::get_notices(FALSE);
     $success_msg = isset($notices['success']) ? $notices['success'] : FALSE;
     $error_msg = isset($notices['errors']) ? $notices['errors'] : FALSE;
     if ($prev_step == $callback && !$error_msg) {
         $error_msg = __('A recursive loop was detected and the registration process was halted.', 'event_espresso');
         EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
     }
     // check for valid callback function
     $valid_callback = $callback !== FALSE && $callback != '' && method_exists($this, $callback) ? TRUE : FALSE;
     if ($success_msg && !$error_msg) {
         // if this is an ajax request AND a callback function exists
         if (EE_Registry::instance()->REQ->ajax && $valid_callback) {
             // send data through to the callback function
             $this->{$callback}($callback_param, $success_msg);
         } elseif (EE_Registry::instance()->REQ->ajax) {
             // just send the ajax
             $json_response = apply_filters('FHEE__EE_Single_Page_Checkout__JSON_response', array('success' => $success_msg));
             echo json_encode($json_response);
             die;
         } else {
             // not ajax, so return TRUE to advance to next step
             $no_errors = TRUE;
         }
     } elseif ($error_msg) {
         if (EE_Registry::instance()->REQ->ajax) {
             $json_response = apply_filters('FHEE__EE_Single_Page_Checkout__JSON_response', array('error' => $error_msg));
             echo json_encode($json_response);
             die;
         } else {
             // not ajax, so return FALSE to repeat the current step while displaying the error notice
             $no_errors = FALSE;
         }
     }
     // store notices in a transient
     EE_Error::get_notices(FALSE, TRUE, TRUE);
     // no errors, means progress to next step, but if next step is empty, then redirect to thank you page. errors means return to page we came from
     $next_step = $no_errors ? $this->_next_step : str_replace('process_', '', $this->_current_step);
     if ($next_step) {
         $args = $this->_process_return_to_reg_step_query_args(array('ee' => '_register', 'step' => $next_step));
         $redirect = add_query_arg($args, $this->_reg_page_base_url);
     } else {
         $redirect = $this->_thank_you_page_url;
     }
     //		echo '<h4>$prev_step : ' . $prev_step . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
     //		echo '<h4>$this->_current_step : ' . $this->_current_step . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
     //		echo '<h4>$this->_next_step : ' . $this->_next_step . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
     //		echo '<h4>$valid_callback : ' . $valid_callback . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
     //		echo '<h4>$callback : ' . $callback . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
     //		echo '<h4>$success_msg : ' . $success_msg . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
     //		echo '<h4>$error_msg : ' . $error_msg . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
     //		echo '<h4>EE_Registry::instance()->REQ->ajax : ' . EE_Registry::instance()->REQ->ajax . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
     //		echo '<h4>$this->_revisit : ' . $this->_revisit . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
     //		echo '<h4>$no_errors : ' . $no_errors . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
     //		echo '<h4>$next_step : ' . $next_step . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
     //		echo '<h4>$redirect : ' . $redirect . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
     //		printr( EE_Registry::instance()->REQ, 'EE_Registry::instance()->REQ  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
     wp_safe_redirect($redirect);
     exit;
 }