function test_register_mock_addon_success()
 {
     $this->_pretend_addon_hook_time();
     $this->assertArrayDoesNotContain('EEM_Mock', EE_Registry::instance()->non_abstract_db_models);
     $this->assertArrayDoesNotContain('EEM_Mock', EE_Registry::instance()->models);
     //register it for realz
     EE_Register_Model::register($this->_model_group, $this->_reg_args);
     EE_System::instance()->load_core_configuration();
     $this->assertArrayContains('EEM_Mock', EE_Registry::instance()->non_abstract_db_models);
     $this->assertArrayContains('EEM_Mock', EE_Registry::instance()->models);
     //now deregister it
     EE_Register_Model::deregister($this->_model_group);
     EE_System::instance()->load_core_configuration();
     $this->assertArrayDoesNotContain('EEM_Mock', EE_Registry::instance()->non_abstract_db_models);
     $this->assertArrayDoesNotContain('EEM_Mock', EE_Registry::instance()->models);
 }
 /**
  *    _initialize - initial module setup
  *
  * @access    private
  * @throws EE_Error
  * @return    void
  */
 private function _initialize()
 {
     // ensure SPCO doesn't run twice
     if (EED_Single_Page_Checkout::$_initialized) {
         return;
     }
     // setup the EE_Checkout object
     $this->checkout = $this->_initialize_checkout();
     // filter checkout
     $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout);
     // get the $_GET
     $this->_get_request_vars();
     // filter continue_reg
     $this->checkout->continue_reg = apply_filters('FHEE__EED_Single_Page_Checkout__init___continue_reg', TRUE, $this->checkout);
     // load the reg steps array
     if (!$this->_load_and_instantiate_reg_steps()) {
         EED_Single_Page_Checkout::$_initialized = true;
         return;
     }
     // set the current step
     $this->checkout->set_current_step($this->checkout->step);
     // and the next step
     $this->checkout->set_next_step();
     // was there already a valid transaction in the checkout from the session ?
     if (!$this->checkout->transaction instanceof EE_Transaction) {
         // get transaction from db or session
         $this->checkout->transaction = $this->checkout->reg_url_link && !is_admin() ? $this->_get_transaction_and_cart_for_previous_visit() : $this->_get_cart_for_current_session_and_setup_new_transaction();
         if (!$this->checkout->transaction instanceof EE_Transaction) {
             EE_Error::add_error(__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
             // add some style and make it dance
             $this->checkout->transaction = EE_Transaction::new_instance();
             $this->add_styles_and_scripts();
             EED_Single_Page_Checkout::$_initialized = true;
             return;
         }
         // and the registrations for the transaction
         $this->_get_registrations($this->checkout->transaction);
     }
     // verify that everything has been setup correctly
     if (!$this->_final_verifications()) {
         EED_Single_Page_Checkout::$_initialized = true;
         return;
     }
     // lock the transaction
     $this->checkout->transaction->lock();
     // make sure all of our cached objects are added to their respective model entity mappers
     $this->checkout->refresh_all_entities();
     // set amount owing
     $this->checkout->amount_owing = $this->checkout->transaction->remaining();
     // initialize each reg step, which gives them the chance to potentially alter the process
     $this->_initialize_reg_steps();
     // DEBUG LOG
     //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
     // get reg form
     $this->_check_form_submission();
     // checkout the action!!!
     $this->_process_form_action();
     // add some style and make it dance
     $this->add_styles_and_scripts();
     // kk... SPCO has successfully run
     EED_Single_Page_Checkout::$_initialized = TRUE;
     // set no cache headers and constants
     EE_System::do_not_cache();
     // add anchor
     add_action('loop_start', array($this, 'set_checkout_anchor'), 1);
     // remove transaction lock
     add_action('shutdown', array($this, 'unlock_transaction'), 1);
 }
 public function tearDown()
 {
     if (isset($this->_addon_name) && isset(EE_Registry::instance()->addons->EE_New_Addon)) {
         $main_file_path_before_deregistration = EE_Registry::instance()->addons->EE_New_Addon->get_main_plugin_file_basename();
         EE_Register_Addon::deregister($this->_addon_name);
         try {
             EE_Registry::instance()->addons->EE_New_Addon;
             $this->fail('EE_New_Addon is still registered. Deregister failed');
         } catch (PHPUnit_Framework_Error_Notice $e) {
             $this->assertEquals(EE_UnitTestCase::error_code_undefined_property, $e->getCode());
         }
         //verify the deactvation hook was removed
         $this->assertFalse(has_action('deactivate_' . $main_file_path_before_deregistration));
         //verify the models were deregistered
         EE_System::instance()->load_core_configuration();
         $this->assertArrayDoesNotContain('EEM_New_Addon_Thing', EE_Registry::instance()->non_abstract_db_models);
         $this->assertArrayDoesNotContain('EEM_New_Addon_Thing', EE_Registry::instance()->models);
         EE_Registry::instance()->reset_model('Attendee');
         //verify that the model and class extensions have been removed
         $this->assertFalse($this->_class_has_been_extended());
         $this->assertFalse($this->_model_has_been_extended());
     }
     //verify DMSs deregistered
     $DMSs_available = EE_Data_Migration_Manager::reset()->get_all_data_migration_scripts_available();
     $this->assertArrayNotHasKey('EE_DMS_New_Addon_1_0_0', $DMSs_available);
     $this->_stop_pretending_addon_hook_time();
     $this->_stop_pretending_after_plugin_activation();
     remove_all_filters('AHEE__EE_System__load_espresso_addons');
     parent::tearDown();
 }
 /**
  * Resets the entire EE4 database.
  * Currently basically only sets up ee4 database for a fresh install- doesn't
  * actually clean out the old wp options, or cpts (although does erase old ee table data)
  * @param boolean $nuke_old_ee4_data controls whether or not we
  * destroy the old ee4 data, or just try initializing ee4 default data
  */
 public function _reset_db($nuke_old_ee4_data = TRUE)
 {
     EE_Registry::instance()->load_helper('Activation');
     EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance);
     if ($nuke_old_ee4_data) {
         EEH_Activation::delete_all_espresso_cpt_data();
         EEH_Activation::delete_all_espresso_tables_and_data(FALSE);
         EEH_Activation::remove_cron_tasks();
     }
     //make sure when we reset the registry's config that it
     //switches to using the new singleton
     EE_Registry::instance()->CFG = EE_Registry::instance()->CFG->reset(TRUE);
     EE_System::instance()->initialize_db_if_no_migrations_required(TRUE);
     EE_System::instance()->redirect_to_about_ee();
 }
 /**
  * 	init
  *
  *  @access 	public
  *  @return 	void
  */
 public function init()
 {
     $this->_get_reg_url_link();
     if (!$this->get_txn()) {
         EE_Registry::instance()->load_helper('HTML');
         echo EEH_HTML::div(EEH_HTML::h4(__('We\'re sorry...', 'event_espresso'), '', '') . sprintf(__('This is a system page for displaying transaction information after a purchase.%1$sYou are most likely seeing this notice because you have navigated to this page%1$sthrough some means other than completing a transaction.%1$sSorry for the disappointment, but you will most likely find nothing of interest here.%1$s%1$s', 'event_espresso'), '<br/>'), '', 'ee-attention');
         return NULL;
     }
     // if we've made it to the Thank You page, then let's toggle any "Failed" transactions to "Incomplete"
     if ($this->_current_txn->status_ID() == EEM_Transaction::failed_status_code) {
         $this->_current_txn->set_status(EEM_Transaction::incomplete_status_code);
         $this->_current_txn->save();
     }
     $this->_primary_registrant = $this->_current_txn->primary_registration() instanceof EE_Registration ? $this->_current_txn->primary_registration() : NULL;
     $this->_is_primary = $this->_primary_registrant->reg_url_link() == $this->_reg_url_link ? TRUE : FALSE;
     $show_try_pay_again_link_default = apply_filters('AFEE__EES_Espresso_Thank_You__init__show_try_pay_again_link_default', TRUE);
     // txn status ?
     if ($this->_current_txn->is_completed()) {
         $this->_show_try_pay_again_link = $show_try_pay_again_link_default;
     } else {
         if ($this->_current_txn->is_incomplete() && ($this->_primary_registrant->is_approved() || $this->_primary_registrant->is_pending_payment())) {
             $this->_show_try_pay_again_link = TRUE;
         } else {
             if ($this->_primary_registrant->is_approved() || $this->_primary_registrant->is_pending_payment()) {
                 // its pending
                 $this->_show_try_pay_again_link = isset(EE_Registry::instance()->CFG->registration->show_pending_payment_options) && EE_Registry::instance()->CFG->registration->show_pending_payment_options ? TRUE : $show_try_pay_again_link_default;
             } else {
                 $this->_show_try_pay_again_link = $show_try_pay_again_link_default;
             }
         }
     }
     $this->_payments_closed = !$this->_current_txn->payment_method() instanceof EE_Payment_Method ? TRUE : FALSE;
     if (!$this->_current_txn->payment_method() instanceof EE_Payment_Method || $this->_current_txn->payment_method() instanceof EE_Payment_Method && $this->_current_txn->payment_method()->is_off_line()) {
         $this->_is_offline_payment_method = true;
     } else {
         $this->_is_offline_payment_method = false;
     }
     // link to SPCO
     $revisit_spco_url = add_query_arg(array('ee' => '_register', 'revisit' => TRUE, 'e_reg_url_link' => $this->_reg_url_link), EE_Registry::instance()->CFG->core->reg_page_url());
     // link to SPCO payment_options
     $this->_SPCO_payment_options_url = $this->_primary_registrant instanceof EE_Registration ? $this->_primary_registrant->payment_overview_url() : add_query_arg(array('step' => 'payment_options'), $revisit_spco_url);
     // link to SPCO attendee_information
     $this->_SPCO_attendee_information_url = $this->_primary_registrant instanceof EE_Registration ? $this->_primary_registrant->edit_attendee_information_url() : FALSE;
     EE_Registry::instance()->load_helper('Template');
     EE_Registry::instance()->load_helper('Template_Validator');
     do_action('AHEE__EES_Espresso_Thank_You__init_end', $this->_current_txn);
     // set no cache headers and constants
     EE_System::do_not_cache();
 }
 /**
  * Checks if there was a version change or something that merits invalidating the cached
  * route data. If so, invalidates the cached route data so that it gets refreshed
  * next time the WP API is used
  */
 public static function invalidate_cached_route_data_on_version_change()
 {
     if (EE_System::instance()->detect_req_type() != EE_System::req_type_normal) {
         EED_Core_Rest_Api::invalidate_cached_route_data();
     }
     foreach (EE_Registry::instance()->addons as $addon) {
         if ($addon instanceof EE_Addon && $addon->detect_req_type() != EE_System::req_type_normal) {
             EED_Core_Rest_Api::invalidate_cached_route_data();
         }
     }
 }
Example #7
0
/**
 * 	espresso_duplicate_plugin_error
 * 	displays if more than one version of EE is activated at the same time
 */
function espresso_duplicate_plugin_error()
{
    ?>
	<div class="error">
	<p><?php 
    _e('Can not run multiple versions of Event Espresso! Please deactivate one of the versions.', 'event_espresso');
    ?>
</p>
	</div>
	<?php 
    EE_System::deactivate_plugin(EE_PLUGIN_BASENAME);
}
 /**
  * Using the information gathered in EE_System::_incompatible_addon_error,
  * deactivates any addons considered incompatible with the current version of EE
  */
 private function _deactivate_incompatible_addons()
 {
     $incompatible_addons = get_option('ee_incompatible_addons', array());
     if (!empty($incompatible_addons)) {
         $active_plugins = get_option('active_plugins', array());
         foreach ($active_plugins as $active_plugin) {
             foreach ($incompatible_addons as $incompatible_addon) {
                 if (strpos($active_plugin, $incompatible_addon) !== FALSE) {
                     unset($_GET['activate']);
                     EE_System::deactivate_plugin($active_plugin);
                 }
             }
         }
     }
 }
 /**
  * Calls EE_Addon::initialize_db_if_no_migrations_required() on each addon
  * specified in EE_Data_Migration_Manager::get_db_init_queue(), and if 'Core' is
  * in the queue, calls EE_System::initialize_db_if_no_migrations_required().
  */
 public function initialize_db_for_enqueued_ee_plugins()
 {
     //		EEH_Debug_Tools::instance()->start_timer( 'initialize_db_for_enqueued_ee_plugins' );
     $queue = $this->get_db_initialization_queue();
     foreach ($queue as $plugin_slug) {
         $most_up_to_date_dms = $this->get_most_up_to_date_dms($plugin_slug);
         if (!$most_up_to_date_dms) {
             //if there is NO DMS for this plugin, obviously there's no schema to verify anyways
             $verify_db = false;
         } else {
             $most_up_to_date_dms_migrates_to = $this->script_migrates_to_version($most_up_to_date_dms);
             $verify_db = $this->database_needs_updating_to($most_up_to_date_dms_migrates_to);
         }
         if ($plugin_slug == 'Core') {
             EE_System::instance()->initialize_db_if_no_migrations_required(false, $verify_db);
         } else {
             //just loop through the addons to make sure their database is setup
             foreach (EE_Registry::instance()->addons as $addon) {
                 if ($addon->name() == $plugin_slug) {
                     $addon->initialize_db_if_no_migrations_required($verify_db);
                     break;
                 }
             }
         }
     }
     //		EEH_Debug_Tools::instance()->stop_timer( 'initialize_db_for_enqueued_ee_plugins' );
     //		EEH_Debug_Tools::instance()->show_times();
     //because we just initialized the DBs for the enqueued ee plugins
     //we don't need to keep remembering which ones needed to be initialized
     delete_option(self::db_init_queue_option_name);
 }
 /**
  * Resets the entire EE4 database.
  * Currently basically only sets up ee4 database for a fresh install- doesn't
  * actually clean out the old wp options, or cpts (although does erase old ee table data)
  * @param boolean $nuke_old_ee4_data controls whether or not we
  * destroy the old ee4 data, or just try initializing ee4 default data
  */
 public function _reset_db($nuke_old_ee4_data = TRUE)
 {
     EE_Registry::instance()->load_helper('Activation');
     EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance);
     if ($nuke_old_ee4_data) {
         EEH_Activation::delete_all_espresso_cpt_data();
         EEH_Activation::delete_all_espresso_tables_and_data(FALSE);
     }
     EE_System::instance()->initialize_db_if_no_migrations_required();
     EE_System::instance()->redirect_to_about_ee();
 }
 /**
  * restore the epsresso_db_update option
  */
 function tearDown()
 {
     update_option('espresso_db_update', $this->_original_espresso_db_update);
     EE_System::reset()->detect_req_type();
     EE_Data_Migration_Manager::reset();
     update_option(EE_Data_Migration_Manager::current_database_state, $this->_original_db_state);
     parent::tearDown();
 }
 /**
  * redirect_to_txn
  *
  * @access public
  * @return void
  */
 public function redirect_to_txn()
 {
     EE_System::do_not_cache();
     EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
     $query_args = array('action' => 'view_transaction', 'TXN_ID' => isset($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : 0, 'page' => 'espresso_transactions');
     if (isset($this->_req_data['EVT_ID'], $this->_req_data['redirect_from'])) {
         $query_args['EVT_ID'] = $this->_req_data['EVT_ID'];
         $query_args['event_name'] = urlencode($this->_req_data['event_name']);
         $query_args['redirect_from'] = $this->_req_data['redirect_from'];
     }
     EE_Error::add_success(__('Registration Created.  Please review the transaction and add any payments as necessary', 'event_espresso'));
     $this->_redirect_after_action(false, '', '', $query_args, true);
 }
 /**
  * Checks that even though the addon was upgraded, because it happened during
  * maintenance mode, we couldn't do any of its setup logic. (SO it should be run
  * later, when the site is taken out of MM by the migration manager)
  * @group 6910
  */
 public function test_detect_actiavtions_or_upgrade__upgrade_during_maintenance_mode()
 {
     global $wp_actions;
     //pretend an older version of this addon was activated a while ago
     $addon_activation_history = array('0.9.0.dev.000' => array(date('Y-m-d H:i:s', current_time('timestamp') - DAY_IN_SECONDS * 10)));
     update_option($this->_addon->get_activation_history_option_name(), $addon_activation_history);
     //and it also shouldn't be in the current db state
     $current_db_state = get_option(EE_Data_Migration_Manager::current_database_state);
     //just for assurance, make sure New Addon is the only existing addon
     unset($current_db_state[$this->_addon_name]);
     update_option(EE_Data_Migration_Manager::current_database_state, $current_db_state);
     $times_reactivation_hook_fired_before = isset($wp_actions["AHEE__{$this->_addon_classname}__upgrade"]) ? $wp_actions["AHEE__{$this->_addon_classname}__upgrade"] : 0;
     //lastly, and imporatntly SET MAINTENANCE MODE LEVEL 2
     $this->_add_mock_dms();
     //now check for activations/upgrades in addons
     EE_System::reset();
     $this->assertEquals(EE_Maintenance_Mode::level_2_complete_maintenance, EE_Maintenance_Mode::instance()->level());
     $this->assertEquals(EE_System::req_type_upgrade, $this->_addon->detect_req_type());
     $this->assertEquals($times_reactivation_hook_fired_before + 1, isset($wp_actions["AHEE__{$this->_addon_classname}__upgrade"]) ? $wp_actions["AHEE__{$this->_addon_classname}__upgrade"] : 0);
     $this->assertArrayContains('New_Addon', EE_Data_Migration_Manager::instance()->get_db_initialization_queue());
     $addon_activation_history = $this->_addon->get_activation_history();
     $this->assertArrayHasKey('0.9.0.dev.000', $addon_activation_history);
     $this->assertArrayHasKey('1.0.0.dev.000', $addon_activation_history);
     $this->assertTableDoesNotExist('esp_new_addon_thing');
     //ok, now let's pretend the site was teaken out of MM because migrations were finished
     $this->_remove_mock_dms();
     EE_Maintenance_Mode::reset()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance);
     EE_Data_Migration_Manager::instance()->initialize_db_for_enqueued_ee_plugins();
     //now we also want to check that the addon will have created the necessary table
     //that it needed upon new activation
     $this->assertEquals(array(), EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts());
     $this->assertEquals(EE_Maintenance_Mode::level_0_not_in_maintenance, EE_Maintenance_Mode::instance()->real_level());
     $this->assertTableExists('esp_new_addon_thing');
     //check for activations/upgrades again. It should be a normal request
     EE_System::reset();
     $this->assertEquals(EE_System::req_type_normal, $this->_addon->detect_req_type());
     $this->assertEquals($times_reactivation_hook_fired_before + 1, $wp_actions["AHEE__{$this->_addon_classname}__upgrade"]);
     $this->assertWPOptionDoesNotExist($this->_addon->get_activation_indicator_option_name());
 }
 /**
  * note this should be moved to the system tests folder.
  */
 function test_system_initialization()
 {
     $EE_SYS = EE_System::instance();
     $this->assertTrue($EE_SYS instanceof EE_System);
 }
 /**
  *    creates buttons for selecting number of attendees for an event
  *
  * @access 	public
  * @param 	object $event
  * @param 	bool 	$view_details
  * @return 	string
  */
 public static function display_ticket_selector($event = NULL, $view_details = FALSE)
 {
     // reset filter for displaying submit button
     remove_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
     // poke and prod incoming event till it tells us what it is
     if (!EED_Ticket_Selector::set_event($event)) {
         return false;
     }
     $event_post = self::$_event instanceof EE_Event ? self::$_event->ID() : $event;
     // grab event status
     $_event_active_status = self::$_event->get_active_status();
     if (!is_admin() && (!self::$_event->display_ticket_selector() || $view_details || post_password_required($event_post) || $_event_active_status != EE_Datetime::active && $_event_active_status != EE_Datetime::upcoming && $_event_active_status != EE_Datetime::sold_out && !($_event_active_status == EE_Datetime::inactive && is_user_logged_in()))) {
         return !is_single() ? EED_Ticket_Selector::display_view_details_btn() : '';
     }
     $template_args = array();
     $template_args['event_status'] = $_event_active_status;
     $template_args['date_format'] = apply_filters('FHEE__EED_Ticket_Selector__display_ticket_selector__date_format', get_option('date_format'));
     $template_args['time_format'] = apply_filters('FHEE__EED_Ticket_Selector__display_ticket_selector__time_format', get_option('time_format'));
     $template_args['EVT_ID'] = self::$_event->ID();
     $template_args['event'] = self::$_event;
     // is the event expired ?
     $template_args['event_is_expired'] = self::$_event->is_expired();
     if ($template_args['event_is_expired']) {
         return '<div class="ee-event-expired-notice"><span class="important-notice">' . __('We\'re sorry, but all tickets sales have ended because the event is expired.', 'event_espresso') . '</span></div>';
     }
     $ticket_query_args = array(array('Datetime.EVT_ID' => self::$_event->ID()), 'order_by' => array('TKT_order' => 'ASC', 'TKT_required' => 'DESC', 'TKT_start_date' => 'ASC', 'TKT_end_date' => 'ASC', 'Datetime.DTT_EVT_start' => 'DESC'));
     if (!EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets) {
         //use the correct applicable time query depending on what version of core is being run.
         $current_time = method_exists('EEM_Datetime', 'current_time_for_query') ? time() : current_time('timestamp');
         $ticket_query_args[0]['TKT_end_date'] = array('>', $current_time);
     }
     // get all tickets for this event ordered by the datetime
     $template_args['tickets'] = EEM_Ticket::instance()->get_all($ticket_query_args);
     if (count($template_args['tickets']) < 1) {
         return '<div class="ee-event-expired-notice"><span class="important-notice">' . __('We\'re sorry, but all ticket sales have ended.', 'event_espresso') . '</span></div>';
     }
     // filter the maximum qty that can appear in the Ticket Selector qty dropdowns
     $template_args['max_atndz'] = apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets', self::$_event->additional_limit());
     if ($template_args['max_atndz'] < 1) {
         $sales_closed_msg = __('We\'re sorry, but ticket sales have been closed at this time. Please check back again later.', 'event_espresso');
         if (current_user_can('edit_post', self::$_event->ID())) {
             $sales_closed_msg .= sprintf(__('%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s', 'event_espresso'), '<div class="ee-attention" style="text-align: left;"><b>', '</b><br />', $link = '<span class="edit-link"><a class="post-edit-link" href="' . get_edit_post_link(self::$_event->ID()) . '">', '</a></span></div>');
         }
         return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>';
     }
     $templates['ticket_selector'] = TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_selector_chart.template.php';
     $templates['ticket_selector'] = apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector__template_path', $templates['ticket_selector'], self::$_event);
     // redirecting to another site for registration ??
     $external_url = self::$_event->external_url() !== NULL || self::$_event->external_url() !== '' ? self::$_event->external_url() : FALSE;
     // set up the form (but not for the admin)
     $ticket_selector = !is_admin() ? EED_Ticket_Selector::ticket_selector_form_open(self::$_event->ID(), $external_url) : '';
     // if not redirecting to another site for registration
     if (!$external_url) {
         // then display the ticket selector
         $ticket_selector .= EEH_Template::locate_template($templates['ticket_selector'], $template_args);
     } else {
         // if not we still need to trigger the display of the submit button
         add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
         //display notice to admin that registration is external
         $ticket_selector .= !is_admin() ? '' : __('Registration is at an external URL for this event.', 'event_espresso');
     }
     // submit button and form close tag
     $ticket_selector .= !is_admin() ? EED_Ticket_Selector::display_ticket_selector_submit() : '';
     // set no cache headers and constants
     EE_System::do_not_cache();
     return $ticket_selector;
 }
 /**
  * Verifies the EE addons' database is up-to-date and records that we've done it on
  * EEM_Base::$_db_verification_level
  * @param $wpdb_method
  * @param $arguments_to_provide
  * @return string
  */
 private function _verify_addons_db($wpdb_method, $arguments_to_provide)
 {
     /** @type WPDB $wpdb */
     global $wpdb;
     //ok remember that we've already attempted fixing the addons dbs, in case the problem persists
     EEM_Base::$_db_verification_level = EEM_Base::db_verified_addons;
     $error_message = sprintf(__('WPDB AGAIN: Error "%1$s" while running the same method and arguments as before. Automatically attempting to fix EE Addons DB', 'event_espresso'), $wpdb->last_error, $wpdb_method, json_encode($arguments_to_provide));
     EE_System::instance()->initialize_addons();
     return $error_message;
 }
 /**
  * Detects the request type for this addon (whether it was just activated, upgrades, a normal request, etc.)
  * Should only be called once per request
  * @return void
  */
 function detect_activation_or_upgrade()
 {
     $activation_history_for_addon = $this->get_activation_history();
     //		d($activation_history_for_addon);
     $request_type = EE_System::detect_req_type_given_activation_history($activation_history_for_addon, $this->get_activation_indicator_option_name(), $this->version());
     $this->set_req_type($request_type);
     $classname = get_class($this);
     switch ($request_type) {
         case EE_System::req_type_new_activation:
             do_action("AHEE__{$classname}__detect_activations_or_upgrades__new_activation");
             do_action("AHEE__EE_Addon__detect_activations_or_upgrades__new_activation", $this);
             $this->new_install();
             $this->update_list_of_installed_versions($activation_history_for_addon);
             break;
         case EE_System::req_type_reactivation:
             do_action("AHEE__{$classname}__detect_activations_or_upgrades__reactivation");
             do_action("AHEE__EE_Addon__detect_activations_or_upgrades__reactivation", $this);
             $this->reactivation();
             $this->update_list_of_installed_versions($activation_history_for_addon);
             break;
         case EE_System::req_type_upgrade:
             do_action("AHEE__{$classname}__detect_activations_or_upgrades__upgrade");
             do_action("AHEE__EE_Addon__detect_activations_or_upgrades__upgrade", $this);
             $this->upgrade();
             $this->update_list_of_installed_versions($activation_history_for_addon);
             break;
         case EE_System::req_type_downgrade:
             do_action("AHEE__{$classname}__detect_activations_or_upgrades__downgrade");
             do_action("AHEE__EE_Addon__detect_activations_or_upgrades__downgrade", $this);
             $this->downgrade();
             $this->update_list_of_installed_versions($activation_history_for_addon);
             break;
         case EE_System::req_type_normal:
         default:
             //				$this->_maybe_redirect_to_ee_about();
             break;
     }
     do_action("AHEE__{$classname}__detect_if_activation_or_upgrade__complete");
 }
 /**
  * 	init
  *
  *  @access 	public
  *  @return 	void
  */
 public function init()
 {
     $this->_get_reg_url_link();
     if (!$this->get_txn()) {
         return NULL;
     }
     // if we've made it to the Thank You page, then let's toggle any "Failed" transactions to "Incomplete"
     if ($this->_current_txn->status_ID() == EEM_Transaction::failed_status_code) {
         $this->_current_txn->set_status(EEM_Transaction::incomplete_status_code);
         $this->_current_txn->save();
     }
     $this->_primary_registrant = $this->_current_txn->primary_registration() instanceof EE_Registration ? $this->_current_txn->primary_registration() : NULL;
     $this->_is_primary = $this->_primary_registrant->reg_url_link() == $this->_reg_url_link ? TRUE : FALSE;
     $show_try_pay_again_link_default = apply_filters('AFEE__EES_Espresso_Thank_You__init__show_try_pay_again_link_default', TRUE);
     // txn status ?
     if ($this->_current_txn->is_completed()) {
         $this->_show_try_pay_again_link = $show_try_pay_again_link_default;
     } else {
         if ($this->_current_txn->is_incomplete() && ($this->_primary_registrant->is_approved() || $this->_primary_registrant->is_pending_payment())) {
             $this->_show_try_pay_again_link = TRUE;
         } else {
             if ($this->_primary_registrant->is_approved() || $this->_primary_registrant->is_pending_payment()) {
                 // its pending
                 $this->_show_try_pay_again_link = isset(EE_Registry::instance()->CFG->registration->show_pending_payment_options) && EE_Registry::instance()->CFG->registration->show_pending_payment_options ? TRUE : $show_try_pay_again_link_default;
             } else {
                 $this->_show_try_pay_again_link = $show_try_pay_again_link_default;
             }
         }
     }
     $this->_payments_closed = !$this->_current_txn->payment_method() instanceof EE_Payment_Method ? TRUE : FALSE;
     $this->_is_offline_payment_method = $this->_current_txn->payment_method() instanceof EE_Payment_Method && $this->_current_txn->payment_method()->is_off_line() ? TRUE : FALSE;
     // link to SPCO
     $revisit_spco_url = add_query_arg(array('ee' => '_register', 'revisit' => TRUE, 'e_reg_url_link' => $this->_reg_url_link), EE_Registry::instance()->CFG->core->reg_page_url());
     // link to SPCO payment_options
     $this->_SPCO_payment_options_url = $this->_primary_registrant instanceof EE_Registration ? $this->_primary_registrant->payment_overview_url() : add_query_arg(array('step' => 'payment_options'), $revisit_spco_url);
     // link to SPCO attendee_information
     $this->_SPCO_attendee_information_url = $this->_primary_registrant instanceof EE_Registration ? $this->_primary_registrant->edit_attendee_information_url() : FALSE;
     EE_Registry::instance()->load_helper('Template');
     EE_Registry::instance()->load_helper('Template_Validator');
     do_action('AHEE__EES_Espresso_Thank_You__init_end', $this->_current_txn);
     // set no cache headers and constants
     EE_System::do_not_cache();
 }
 /**
  * Gets the request type for the plugin (core or addon) that corresponds to this DMS
  * @return int one of EE_System::_req_type_* constants
  * @throws EE_Error
  */
 private function _get_req_type_for_plugin_corresponding_to_this_dms()
 {
     if ($this->slug() == 'Core') {
         return EE_System::instance()->detect_req_type();
     } else {
         //it must be for an addon
         $addon_name = $this->slug();
         if (EE_Registry::instance()->get_addon_by_name($addon_name)) {
             return EE_Registry::instance()->get_addon_by_name($addon_name)->detect_req_type();
         } else {
             throw new EE_Error(sprintf(__("The DMS slug '%s' should correspond to the addon's name, which should also be '%s', but no such addon was registered. These are the registered addons' names: %s", "event_espresso"), $this->slug(), $addon_name, implode(",", array_keys(EE_Registry::instance()->get_addons_by_name()))));
         }
     }
 }
 /**
  * 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;
     }
 }
/**
 * 	espresso_plugin_deactivation
 */
function espresso_plugin_deactivation()
{
    if (EE_System::instance()->minimum_php_version_required()) {
        espresso_load_required('EEH_Activation', EE_HELPERS . 'EEH_Activation.helper.php');
        EEH_Activation::plugin_deactivation();
    }
}