/**
  * like test_REG_final_price_matches_total_of_filtering_line_item_tree,
  * but makes sure the tickets have sub-prices, because that has shown to have some
  * bugs with calculations so far
  */
 function test_REG_final_price_matches_total_of_filtering_line_item_tree__with_sub_line_items()
 {
     $transaction = $this->new_typical_transaction(array('ticket_types' => 2, 'fixed_ticket_price_modifiers' => 2));
     //add another ticket purchase for one of the same events
     $event1 = EEM_Event::instance()->get_one(array(array('Registration.TXN_ID' => $transaction->ID())));
     $event_line_item = EEM_Line_Item::instance()->get_one(array(array('TXN_ID' => $transaction->ID(), 'OBJ_type' => 'Event', 'OBJ_ID' => $event1->ID())));
     $discount = $this->new_model_obj_with_dependencies('Line_Item', array('LIN_type' => EEM_Line_Item::type_line_item, 'LIN_name' => 'event discount', 'LIN_total' => -8, 'LIN_unit_price' => -8, 'LIN_percent' => 0, 'LIN_quantity' => 1, 'LIN_parent' => $event_line_item->ID(), 'LIN_percent' => null, 'LIN_order' => count($event_line_item->children())));
     $transaction->total_line_item()->recalculate_pre_tax_total();
     //and add an unrelated purchase
     EEH_Line_Item::add_unrelated_item($transaction->total_line_item(), 'Transaction-Wide Discount', -5);
     $totals = EEH_Line_Item::calculate_reg_final_prices_per_line_item($transaction->total_line_item());
     //		honestly the easiest way to confirm the total was right is to visualize the tree
     //		var_dump( $totals );
     //		EEH_Line_Item::visualize( $transaction->total_line_item() );
     //for each registration on the tranasction, verify the REG_final_price
     //indicated by EEH_Line_Item::calculate_reg_final_prices_per_line_item matches
     //what the line item filters would have returned
     EEH_Autoloader::register_line_item_filter_autoloaders();
     foreach ($transaction->registrations() as $registration) {
         $ticket_line_item = EEM_Line_Item::instance()->get_line_item_for_registration($registration);
         $reg_final_price_from_line_item_helper = $totals[$ticket_line_item->ID()];
         //now get the line item filter's final price
         $filters = new EE_Line_Item_Filter_Collection();
         $filters->add(new EE_Single_Registration_Line_Item_Filter($registration));
         $line_item_filter_processor = new EE_Line_Item_Filter_Processor($filters, $transaction->total_line_item());
         $filtered_line_item_tree = $line_item_filter_processor->process();
         $reg_final_price_from_line_item_filter = $filtered_line_item_tree->total();
         $this->assertLessThan(0.2, abs($reg_final_price_from_line_item_filter - $reg_final_price_from_line_item_helper));
     }
 }
 public function setUp()
 {
     //save the hooks state before WP_UnitTestCase actually gets its hands on it...
     //as it immediately adds a few hooks we might not want to backup
     global $auto_made_thing_seed, $wp_filter, $wp_actions, $merged_filters, $wp_current_filter, $wpdb, $current_user;
     $this->wp_filters_saved = array('wp_filter' => $wp_filter, 'wp_actions' => $wp_actions, 'merged_filters' => $merged_filters, 'wp_current_filter' => $wp_current_filter);
     $this->_orig_current_user = clone $current_user;
     parent::setUp();
     EE_Registry::reset(TRUE);
     $auto_made_thing_seed = 1;
     //reset wpdb's list of queries executed so it only stores those from the current test
     $wpdb->queries = array();
     //the accidental txn commit indicator option shouldn't be set from the previous test
     update_option('accidental_txn_commit_indicator', TRUE);
     //		$this->wp_actions_saved = $wp_actions;
     // Fake WP mail globals, to avoid errors
     add_filter('wp_mail', array($this, 'setUp_wp_mail'));
     add_filter('wp_mail_from', array($this, 'tearDown_wp_mail'));
     add_filter('FHEE__EEH_Activation__create_table__short_circuit', '__return_true');
     add_filter('FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', '__return_true');
     add_filter('FHEE__EEH_Activation__drop_index__short_circuit', '__return_true');
     // load factories
     EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_TESTS_DIR . 'includes' . DS . 'factories');
     $this->factory = new EE_UnitTest_Factory();
     // load scenarios
     require_once EE_TESTS_DIR . 'includes/scenarios/EE_Test_Scenario_Classes.php';
     $this->scenarios = new EE_Test_Scenario_Factory($this);
     EE_Registry::reset();
 }
 /**
  * register method for setting up model extensions
  *
  * @param string $model_id unique id for the extensions being setup
  * @param array   $config   {
  *               @throws EE_Error
  *               @type  array $ model_extension_paths array of folders containing DB model extensions, where each file follows the models naming convention, which is: EEME_{your_plugin_slug}_model_name_extended}.model_ext.php. Where your_plugin_slug} is really anything you want (but something having to do with your addon, like 'Calendar' or '3D_View') and model_name_extended} is the model extended. The class contained in teh file should extend EEME_Base_{model_name_extended}.model_ext.php. Where {your_plugin_slug} is really anything you want (but something having to do with your addon, like 'Calendar' or '3D_View') and {model_name_extended} is the model extended. The class contained in teh file should extend EEME_Base
  *               @type array $ class_extension_paths array of folders containing DB class extensions, where each file follows the model class extension naming convention, which is: EEE_{your_plugin_slug}_model_name_extended}.class_ext.php. Where your_plugin_slug} is something like 'Calendar','MailChimp',etc, and model_name_extended} is the name of the model extended, eg 'Attendee','Event',etc. The class contained in the file should extend EEE_Base_Class._{model_name_extended}.class_ext.php. Where {your_plugin_slug} is something like 'Calendar','MailChimp',etc, and {model_name_extended} is the name of the model extended, eg 'Attendee','Event',etc. The class contained in the file should extend EEE_Base_Class.
  * }
  *
  * @return void
  */
 public static function register($model_id = NULL, $config = array())
 {
     //required fields MUST be present, so let's make sure they are.
     if (empty($model_id) || !is_array($config) || empty($config['model_extension_paths']) && empty($config['class_extension_paths'])) {
         throw new EE_Error(__('In order to register Model extensions with EE_Register_Model_Extensions::register(), you must include a "model_id" (a unique identifier for this set of models), and an array containing the following keys: "model_extension_paths" (an array of full server paths to folders that contain model extensions), and "class_extension_paths" (an array of full server paths to folders that contain class extensions)', 'event_espresso'));
     }
     //check correct loading
     if (!did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_Admin__loaded')) {
         EE_Error::doing_it_wrong(__METHOD__, sprintf(__('An attempt was made to register "%s" as a group models has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__load_espresso_addons" hook to register models.', 'event_espresso'), $model_id), '4.3');
     }
     self::$_registry[$model_id] = $config;
     EE_Registry::instance()->load_helper('File');
     if (isset($config['model_extension_paths'])) {
         require_once EE_LIBRARIES . 'plugin_api/db/EEME_Base.lib.php';
         $class_to_filepath_map = EEH_File::get_contents_of_folders($config['model_extension_paths']);
         EEH_Autoloader::register_autoloader($class_to_filepath_map);
         foreach (array_keys($class_to_filepath_map) as $classname) {
             new $classname();
         }
         unset($config['model_extension_paths']);
     }
     if (isset($config['class_extension_paths'])) {
         require_once EE_LIBRARIES . 'plugin_api/db/EEE_Base_Class.lib.php';
         $class_to_filepath_map = EEH_File::get_contents_of_folders($config['class_extension_paths']);
         EEH_Autoloader::register_autoloader($class_to_filepath_map);
         foreach (array_keys($class_to_filepath_map) as $classname) {
             new $classname();
         }
         unset($config['class_extension_paths']);
     }
     foreach ($config as $unknown_key => $unknown_config) {
         throw new EE_Error(sprintf(__("The key '%s' is not a known key for registering a model", "event_espresso"), $unknown_key));
     }
 }
 /**
  * class constructor
  *
  * @throws \EE_Error
  */
 protected function __construct()
 {
     // define global EE_Admin constants
     $this->_define_all_constants();
     // set autoloaders for our admin page classes based on included path information
     EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN);
     // admin hooks
     add_filter('plugin_action_links', array($this, 'filter_plugin_actions'), 10, 2);
     // load EE_Request_Handler early
     add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'get_request'));
     add_action('AHEE__EE_System__initialize_last', array($this, 'init'));
     // post shortcode tracking
     add_action('AHEE__EE_System__initialize_last', array('EventEspresso\\core\\admin\\PostShortcodeTracking', 'set_hooks_admin'));
     add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'route_admin_request'), 100, 2);
     add_action('wp_loaded', array($this, 'wp_loaded'), 100);
     add_action('admin_init', array($this, 'admin_init'), 100);
     add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'), 20);
     add_action('admin_notices', array($this, 'display_admin_notices'), 10);
     add_action('network_admin_notices', array($this, 'display_admin_notices'), 10);
     add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2);
     add_filter('admin_footer_text', array($this, 'espresso_admin_footer'));
     //reset Environment config (we only do this on admin page loads);
     EE_Registry::instance()->CFG->environment->recheck_values();
     do_action('AHEE__EE_Admin__loaded');
 }
 /**
  * @param string $model_id unique id for it
  * @param array  $config   {
  *		@type array $model_paths array of folders containing DB models, where each file follows the models naming convention,
  *                         which is: EEM_{model_name}.model.php which contains a single class called EEM_{model_name}. Eg. you could pass
  *                         "public_html/wp-content/plugins/my_addon/db_models" (with or without trailing slash) and in that folder put
  *                         each of your model files, like "EEM_Food.model.php" which contains the class "EEM_Food" and
  *                         "EEM_Monkey.model.php" which contains the class "EEM_Monkey". These will be autoloaded and added to
  *                         the EE registry so they can be used like ordinary models. The class contained in each file should extend EEM_Base.
  *		@type array $class_paths array of folders containing DB classes, where each file follows the model class naming convention,
  *                         which is EE_{model_name}.class.php. The class contained in each file should extend EE_Base_Class
  *
  * }
  * @throws EE_Error
  */
 public static function register($model_id = NULL, $config = array())
 {
     //required fields MUST be present, so let's make sure they are.
     if (empty($model_id) || !is_array($config) || empty($config['model_paths'])) {
         throw new EE_Error(__('In order to register Models with EE_Register_Model::register(), you must include a "model_id" (a unique identifier for this set of models), and an array containing the following keys: "model_paths" (an array of full server paths to folders that contain models)', 'event_espresso'));
     }
     //make sure we don't register twice
     if (isset(self::$_model_registry[$model_id])) {
         return;
     }
     if (!did_action('AHEE__EE_System__load_espresso_addons') || did_action('FHEE__EE_System__parse_model_names') || did_action('FHEE__EE_System__parse_implemented_model_names')) {
         EE_Error::doing_it_wrong(__METHOD__, sprintf(__('An attempt was made to register "%s" as a group models has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__load_espresso_addons" hook to register models.', 'event_espresso'), $model_id), '4.5');
     }
     self::$_model_registry[$model_id] = $config;
     EE_Registry::instance()->load_helper('File');
     if (isset($config['model_paths']) && !isset($config['class_paths']) || !isset($config['model_paths']) && isset($config['class_paths'])) {
         throw new EE_Error(sprintf(__('You must register both "model_paths" AND "class_paths", not just one or the other You provided %s', 'event_espresso'), implode(", ", array_keys($config))));
     }
     if (isset($config['model_paths'])) {
         //make sure they passed in an array
         if (!is_array($config['model_paths'])) {
             $config['model_paths'] = array($config['model_paths']);
         }
         //we want to add this as a model folder
         //and autoload them all
         $class_to_filepath_map = EEH_File::get_contents_of_folders($config['model_paths']);
         EEH_Autoloader::register_autoloader($class_to_filepath_map);
         $model_name_to_classname_map = array();
         foreach (array_keys($class_to_filepath_map) as $classname) {
             $model_name_to_classname_map[str_replace("EEM_", "", $classname)] = $classname;
         }
         self::$_model_name_to_classname_map[$model_id] = $model_name_to_classname_map;
         add_filter('FHEE__EE_System__parse_model_names', array('EE_Register_Model', 'add_addon_models'));
         add_filter('FHEE__EE_System__parse_implemented_model_names', array('EE_Register_Model', 'add_addon_models'));
         add_filter('FHEE__EE_Registry__load_model__paths', array('EE_Register_Model', 'add_model_folders'));
         unset($config['model_paths']);
     }
     if (isset($config['class_paths'])) {
         //make sure they passed in an array
         if (!is_array($config['class_paths'])) {
             $config['class_paths'] = array($config['class_paths']);
         }
         $class_to_filepath_map = EEH_File::get_contents_of_folders($config['class_paths']);
         EEH_Autoloader::register_autoloader($class_to_filepath_map);
         add_filter('FHEE__EE_Registry__load_class__paths', array('EE_Register_Model', 'add_class_folders'));
         unset($config['class_paths']);
     }
     foreach ($config as $unknown_key => $unknown_config) {
         self::deregister($model_id);
         throw new EE_Error(sprintf(__("The key '%s' is not a known key for registering a model", "event_espresso"), $unknown_key));
     }
 }
 /**
  * @return EE_Form_Section_Proper
  */
 public function generate_reg_form()
 {
     $this->_print_copy_info = FALSE;
     $primary_registrant = NULL;
     // autoload Line_Item_Display classes
     EEH_Autoloader::register_line_item_display_autoloaders();
     $Line_Item_Display = new EE_Line_Item_Display();
     // calculate taxes
     $Line_Item_Display->display_line_item($this->checkout->cart->get_grand_total(), array('set_tax_rate' => true));
     EE_Registry::instance()->load_helper('Line_Item');
     /** @var $subsections EE_Form_Section_Proper[] */
     $subsections = array('default_hidden_inputs' => $this->reg_step_hidden_inputs());
     $template_args = array('revisit' => $this->checkout->revisit, 'registrations' => array(), 'ticket_count' => array());
     // grab the saved registrations from the transaction
     $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
     if ($registrations) {
         foreach ($registrations as $registration) {
             if ($registration instanceof EE_Registration) {
                 // can this registration be processed during this visit ?
                 if ($this->checkout->visit_allows_processing_of_this_registration($registration)) {
                     $subsections[$registration->reg_url_link()] = $this->_registrations_reg_form($registration);
                     if (!$this->checkout->admin_request) {
                         $template_args['registrations'][$registration->reg_url_link()] = $registration;
                         $template_args['ticket_count'][$registration->ticket()->ID()] = isset($template_args['ticket_count'][$registration->ticket()->ID()]) ? $template_args['ticket_count'][$registration->ticket()->ID()] + 1 : 1;
                         $ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs($this->checkout->cart->get_grand_total(), 'Ticket', array($registration->ticket()->ID()));
                         $ticket_line_item = is_array($ticket_line_item) ? reset($ticket_line_item) : $ticket_line_item;
                         $template_args['ticket_line_item'][$registration->ticket()->ID()] = $Line_Item_Display->display_line_item($ticket_line_item);
                     }
                     if ($registration->is_primary_registrant()) {
                         $primary_registrant = $registration->reg_url_link();
                     }
                 }
             }
         }
         // print_copy_info ?
         if ($primary_registrant && count($registrations) > 1 && !$this->checkout->admin_request) {
             // TODO: add admin option for toggling copy attendee info, then use that value to change $this->_print_copy_info
             $copy_options['spco_copy_attendee_chk'] = $this->_print_copy_info ? $this->_copy_attendee_info_form() : $this->_auto_copy_attendee_info();
             // generate hidden input
             if (isset($subsections[$primary_registrant]) && $subsections[$primary_registrant] instanceof EE_Form_Section_Proper) {
                 $subsections[$primary_registrant]->add_subsections($copy_options, 'primary_registrant', false);
             }
         }
     }
     return new EE_Form_Section_Proper(array('name' => $this->reg_form_name(), 'html_id' => $this->reg_form_name(), 'subsections' => $subsections, 'layout_strategy' => $this->checkout->admin_request ? new EE_Div_Per_Section_Layout() : new EE_Template_Layout(array('layout_template_file' => $this->_template, 'template_args' => $template_args))));
 }
 /**
  * @return bool
  */
 public function generate_reg_form()
 {
     EE_Registry::instance()->load_helper('HTML');
     // reset in case someone changes their mind
     $this->_reset_selected_method_of_payment();
     // set some defaults
     $this->checkout->selected_method_of_payment = 'payments_closed';
     $registrations_requiring_payment = array();
     $registrations_for_free_events = array();
     $registrations_requiring_pre_approval = array();
     $sold_out_events = array();
     $reg_count = 0;
     // loop thru registrations to gather info
     $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
     foreach ($registrations as $registration) {
         /** @var $registration EE_Registration */
         $reg_count++;
         // if returning registrant is Approved then do NOT do this
         if (!($this->checkout->revisit && $registration->status_ID() == EEM_Registration::status_id_approved)) {
             if ($registration->event()->is_sold_out() || $registration->event()->is_sold_out(true)) {
                 // add event to list of events that are sold out
                 $sold_out_events[$registration->event()->ID()] = $registration->event();
                 do_action('AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event', $registration->event(), $this);
             }
             // event requires admin approval
             if ($registration->status_ID() == EEM_Registration::status_id_not_approved) {
                 // add event to list of events with pre-approval reg status
                 $registrations_requiring_pre_approval[$registration->ID()] = $registration;
                 do_action('AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_pre_approval', $registration->event(), $this);
             }
         }
         // are they allowed to pay now and is there monies owing?
         if ($registration->owes_monies_and_can_pay()) {
             $registrations_requiring_payment[$registration->ID()] = $registration;
             do_action('AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_payment', $registration->event(), $this);
         } else {
             if (!$this->checkout->revisit && $registration->status_ID() != EEM_Registration::status_id_not_approved && $registration->ticket()->is_free()) {
                 $registrations_for_free_events[$registration->event()->ID()] = $registration;
             }
         }
     }
     $subsections = array();
     // now decide which template to load
     if (!empty($sold_out_events)) {
         $subsections['sold_out_events'] = $this->_sold_out_events($sold_out_events);
     }
     if (!empty($registrations_requiring_pre_approval)) {
         $subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval($registrations_requiring_pre_approval);
     }
     if (!empty($registrations_for_free_events)) {
         $subsections['no_payment_required'] = $this->_no_payment_required($registrations_for_free_events);
     }
     if (!empty($registrations_requiring_payment)) {
         // autoload Line_Item_Display classes
         EEH_Autoloader::register_line_item_filter_autoloaders();
         $line_item_filter_processor = new EE_Line_Item_Filter_Processor(apply_filters('FHEE__SPCO__EE_Line_Item_Filter_Collection', new EE_Line_Item_Filter_Collection()), $this->checkout->cart->get_grand_total());
         $filtered_line_item_tree = $line_item_filter_processor->process();
         if ($this->checkout->amount_owing > 0) {
             EEH_Autoloader::register_line_item_display_autoloaders();
             $this->set_line_item_display(new EE_Line_Item_Display('spco'));
             $subsections['payment_options'] = $this->_display_payment_options($this->line_item_display->display_line_item($filtered_line_item_tree, array('registrations' => $registrations)));
             $this->checkout->amount_owing = $filtered_line_item_tree->total();
             $this->_apply_registration_payments_to_amount_owing($registrations);
         }
     } else {
         $this->_hide_reg_step_submit_button_if_revisit();
     }
     $this->_save_selected_method_of_payment();
     return new EE_Form_Section_Proper(array('name' => $this->reg_form_name(), 'html_id' => $this->reg_form_name(), 'subsections' => $subsections, 'layout_strategy' => new EE_No_Layout()));
 }
 /**
  *    Method for registering new EE_Addons.
  * Should be called AFTER AHEE__EE_System__load_espresso_addons but BEFORE AHEE__EE_System___detect_if_activation_or_upgrade__begin in order to register all its components.
  * However, it may also be called after the 'activate_plugin' action (when an addon is activated),
  * because an activating addon won't be loaded by WP until after AHEE__EE_System__load_espresso_addons has fired.
  * If its called after 'activate_plugin', it registers the addon still, but its components are not registered
  * (they shouldn't be needed anyways, because it's just an activation request and they won't have a chance to do anything anyways). Instead, it just sets the newly-activated addon's activation indicator wp option and returns
  * (so that we can detect that the addon has activated on the subsequent request)
  *
  * @since    4.3.0
  * @param string $addon_name 		the EE_Addon's name. Required.
  * @param  array $setup_args { 			An array of arguments provided for registering the message type.
  * @type  string $class_name the addon's main file name. If left blank, generated from the addon name, changes something like "calendar" to "EE_Calendar"
  *			@type string $min_core_version  the minimum version of EE Core that the addon will work with. eg "4.8.1.rc.084"
  *			@type string $version the "software" version for the addon. eg "1.0.0.p" for a first stable release, or "1.0.0.rc.043" for a version in progress
  *			@type string $main_file_path the full server path to the main file loaded directly by WP
  *          @type string $admin_path 	full server path to the folder where the addon\'s admin files reside
  *			@type string $admin_callback a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page
  *			@type string $config_section the section name for this addon's configuration settings section (defaults to "addons")
  *			@type string $config_class the class name for this addon's configuration settings object
  *			@type string $config_name the class name for this addon's configuration settings object
  * 			@type string $autoloader_paths an array of class names and the full server paths to those files. Required.
  *			@type string $autoloader_folders  an array of  "full server paths" for any folders containing classes that might be invoked by the addon
  * 			@type string $dms_paths 				an array of full server paths to folders that contain data migration scripts. Required.
  * 			@type string $module_paths 	an array of full server paths to any EED_Modules used by the addon
  * 			@type string $shortcode_paths 	an array of full server paths to folders that contain EES_Shortcodes
  * 			@type string $widget_paths 					an array of full server paths to folders that contain WP_Widgets
  *			@type string $pue_options
  * 			@type array $capabilities  {
  * 			      	an array indexed by role name (i.e. administrator,author ) and the values are an array of caps to add to the role.
  * 			      	'administrator' => array('read_addon', 'edit_addon' etc.).
  * 	         		}
  * 	        @type EE_Meta_Capability_Map[] $capability_maps an array of EE_Meta_Capability_Map object for any addons that need to register any special meta mapped capabilities.  Should be indexed where the key is the EE_Meta_Capability_Map class name and the values are the arguments sent to the class.
  *			@type array $model_paths array of folders containing DB models @see EE_Register_Model
  *			@type array $class_paths array of folders containing DB classes @see EE_Register_Model
  *			@type array $model_extension_paths array of folders containing DB model extensions @see EE_Register_Model_Extension
  *			@type array $class_extension_paths array of folders containing DB class extensions @see EE_Register_Model_Extension
  * 			@type array message_types {
  *       		 An array of message types with the key as the message type name and the values as below:
  *        		@type string $mtfilename The filename of the message type being registered.  This will be the main
  *                                       EE_{Messagetype_Name}_message_type class. (eg. EE_Declined_Registration_message_type.class.php). Required.
  *               @type array $autoloadpaths An array of paths to add to the messages autoloader for the new message type. Required.
  *               @type array $messengers_to_activate_with An array of messengers that this message
  *                           type should activate with. Each value in the array should match the name property of a EE_messenger. Optional.
  *               @type array $messengers_to_validate_with An array of messengers that this message
  *                          type should validate with. Each value in the array should match the name property of an EE_messenger. Optional.
  *       	}
  *			@type array $custom_post_types
  *			@type array $custom_taxonomies
  *			@type array $payment_method_paths each element is the folder containing the EE_PMT_Base child class
  *				(eg, 'public_html/wp-content/plugins/my_plugin/Payomatic/' which contains the files
  *				EE_PMT_Payomatic.pm.php)
  *			@type array $default_terms
  * 	}
  *
  * @throws EE_Error
  * @return void
  */
 public static function register($addon_name = '', $setup_args = array())
 {
     // required fields MUST be present, so let's make sure they are.
     if (empty($addon_name) || !is_array($setup_args)) {
         throw new EE_Error(__('In order to register an EE_Addon with EE_Register_Addon::register(), you must include the "addon_name" (the name of the addon), and an array of arguments.', 'event_espresso'));
     }
     if (!isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) {
         throw new EE_Error(sprintf(__('When registering an addon, you didn\'t provide the "main_file_path", which is the full path to the main file loaded directly by Wordpress. You only provided %s', 'event_espresso'), implode(",", array_keys($setup_args))));
     }
     // check that addon has not already been registered with that name
     if (isset(self::$_settings[$addon_name]) && !did_action('activate_plugin')) {
         throw new EE_Error(sprintf(__('An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.', 'event_espresso'), $addon_name));
     }
     // no class name for addon?
     if (empty($setup_args['class_name'])) {
         // generate one by first separating name with spaces
         $class_name = str_replace(array('-', '_'), ' ', trim($addon_name));
         //capitalize, then replace spaces with underscores
         $class_name = str_replace(' ', '_', ucwords($class_name));
     } else {
         $class_name = $setup_args['class_name'];
     }
     $class_name = strpos($class_name, 'EE_') === 0 ? $class_name : 'EE_' . $class_name;
     //setup $_settings array from incoming values.
     $addon_settings = array('class_name' => $class_name, 'plugin_slug' => isset($setup_args['plugin_slug']) ? (string) $setup_args['plugin_slug'] : '', 'plugin_action_slug' => isset($setup_args['plugin_action_slug']) ? (string) $setup_args['plugin_action_slug'] : '', 'version' => isset($setup_args['version']) ? (string) $setup_args['version'] : '', 'min_core_version' => isset($setup_args['min_core_version']) ? (string) $setup_args['min_core_version'] : '', 'main_file_path' => isset($setup_args['main_file_path']) ? (string) $setup_args['main_file_path'] : '', 'admin_path' => isset($setup_args['admin_path']) ? (string) $setup_args['admin_path'] : '', 'admin_callback' => isset($setup_args['admin_callback']) ? (string) $setup_args['admin_callback'] : '', 'config_section' => isset($setup_args['config_section']) ? (string) $setup_args['config_section'] : 'addons', 'config_class' => isset($setup_args['config_class']) ? (string) $setup_args['config_class'] : '', 'config_name' => isset($setup_args['config_name']) ? (string) $setup_args['config_name'] : '', 'autoloader_paths' => isset($setup_args['autoloader_paths']) ? (array) $setup_args['autoloader_paths'] : array(), 'autoloader_folders' => isset($setup_args['autoloader_folders']) ? (array) $setup_args['autoloader_folders'] : array(), 'dms_paths' => isset($setup_args['dms_paths']) ? (array) $setup_args['dms_paths'] : array(), 'module_paths' => isset($setup_args['module_paths']) ? (array) $setup_args['module_paths'] : array(), 'shortcode_paths' => isset($setup_args['shortcode_paths']) ? (array) $setup_args['shortcode_paths'] : array(), 'widget_paths' => isset($setup_args['widget_paths']) ? (array) $setup_args['widget_paths'] : array(), 'pue_options' => isset($setup_args['pue_options']) ? (array) $setup_args['pue_options'] : array(), 'message_types' => isset($setup_args['message_types']) ? (array) $setup_args['message_types'] : array(), 'capabilities' => isset($setup_args['capabilities']) ? (array) $setup_args['capabilities'] : array(), 'capability_maps' => isset($setup_args['capability_maps']) ? (array) $setup_args['capability_maps'] : array(), 'model_paths' => isset($setup_args['model_paths']) ? (array) $setup_args['model_paths'] : array(), 'class_paths' => isset($setup_args['class_paths']) ? (array) $setup_args['class_paths'] : array(), 'model_extension_paths' => isset($setup_args['model_extension_paths']) ? (array) $setup_args['model_extension_paths'] : array(), 'class_extension_paths' => isset($setup_args['class_extension_paths']) ? (array) $setup_args['class_extension_paths'] : array(), 'custom_post_types' => isset($setup_args['custom_post_types']) ? (array) $setup_args['custom_post_types'] : array(), 'custom_taxonomies' => isset($setup_args['custom_taxonomies']) ? (array) $setup_args['custom_taxonomies'] : array(), 'payment_method_paths' => isset($setup_args['payment_method_paths']) ? (array) $setup_args['payment_method_paths'] : array(), 'default_terms' => isset($setup_args['default_terms']) ? (array) $setup_args['default_terms'] : array(), 'plugins_page_row' => isset($setup_args['plugins_page_row']) ? $setup_args['plugins_page_row'] : '');
     // if plugin_action_slug is NOT set, but an admin page path IS set, then let's just use the plugin_slug since that will be used for linking to the admin page
     $addon_settings['plugin_action_slug'] = empty($addon_settings['plugin_action_slug']) && !empty($addon_settings['admin_path']) ? $addon_settings['plugin_slug'] : $addon_settings['plugin_action_slug'];
     // full server path to main file (file loaded directly by WP)
     $addon_settings['plugin_basename'] = plugin_basename($addon_settings['main_file_path']);
     //check whether this addon version is compatible with EE core
     if (isset(EE_Register_Addon::$_incompatible_addons[$addon_name]) && !self::_meets_min_core_version_requirement(EE_Register_Addon::$_incompatible_addons[$addon_name], $addon_settings['version'])) {
         $incompatibility_message = sprintf(__('The Event Espresso "%1$s" addon was deactivated because it is incompatible with this version of core.%2$s Only version %3$s or higher of "%1$s" can run with this version of core. This can happen when attempting to run beta versions or release candidates with older versions of core, or running old versions of addons with a newer version of core.%2$sPlease upgrade Event Espresso Core and the "%1$s" addon, then re-attempt activating it.', 'event_espresso'), $addon_name, '<br />', EE_Register_Addon::$_incompatible_addons[$addon_name]);
     } else {
         if (!self::_meets_min_core_version_requirement($setup_args['min_core_version'], espresso_version())) {
             $incompatibility_message = sprintf(__('The Event Espresso "%1$s" addon could not be activated because it requires Event Espresso Core version "%2$s" or higher in order to run.%4$sYour version of Event Espresso Core is currently at "%3$s". Please upgrade Event Espresso Core first and then re-attempt activating "%1$s".', 'event_espresso'), $addon_name, self::_effective_version($setup_args['min_core_version']), self::_effective_version(espresso_version()), '<br />');
         } else {
             $incompatibility_message = '';
         }
     }
     if (!empty($incompatibility_message)) {
         //remove 'activate' from the REQUEST so WP doesn't erroneously tell the user the
         //plugin activated fine when it didn't
         if (isset($_GET['activate'])) {
             unset($_GET['activate']);
         }
         if (isset($_REQUEST['activate'])) {
             unset($_REQUEST['activate']);
         }
         //and show an error message indicating the plugin didn't activate properly
         EE_Error::add_error($incompatibility_message, __FILE__, __FUNCTION__, __LINE__);
         if (current_user_can('activate_plugins')) {
             require_once ABSPATH . 'wp-admin/includes/plugin.php';
             deactivate_plugins(plugin_basename($addon_settings['main_file_path']), TRUE);
         }
         return;
     }
     //this is an activation request
     if (did_action('activate_plugin')) {
         //to find if THIS is the addon that was activated,
         //just check if we have already registered it or not
         //(as the newly-activated addon wasn't around the first time addons were registered)
         if (!isset(self::$_settings[$addon_name])) {
             self::$_settings[$addon_name] = $addon_settings;
             $addon = self::_load_and_init_addon_class($addon_name);
             $addon->set_activation_indicator_option();
             //dont bother setting up the rest of the addon.
             //we know it was just activated and the request will end soon
         }
         return;
     } else {
         // make sure this was called in the right place!
         if (!did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')) {
             EE_Error::doing_it_wrong(__METHOD__, sprintf(__('An attempt to register an EE_Addon named "%s" has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__load_espresso_addons" hook to register addons.', 'event_espresso'), $addon_name), '4.3.0');
         }
         self::$_settings[$addon_name] = $addon_settings;
     }
     // we need cars
     if (!empty(self::$_settings[$addon_name]['autoloader_paths'])) {
         // setup autoloader for single file
         EEH_Autoloader::instance()->register_autoloader(self::$_settings[$addon_name]['autoloader_paths']);
     }
     // setup autoloaders for folders
     if (!empty(self::$_settings[$addon_name]['autoloader_folders'])) {
         foreach (self::$_settings[$addon_name]['autoloader_folders'] as $autoloader_folder) {
             EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder);
         }
     }
     // register new models
     if (!empty(self::$_settings[$addon_name]['model_paths']) || !empty(self::$_settings[$addon_name]['class_paths'])) {
         EE_Register_Model::register($addon_name, array('model_paths' => self::$_settings[$addon_name]['model_paths'], 'class_paths' => self::$_settings[$addon_name]['class_paths']));
     }
     // register model extensions
     if (!empty(self::$_settings[$addon_name]['model_extension_paths']) || !empty(self::$_settings[$addon_name]['class_extension_paths'])) {
         EE_Register_Model_Extensions::register($addon_name, array('model_extension_paths' => self::$_settings[$addon_name]['model_extension_paths'], 'class_extension_paths' => self::$_settings[$addon_name]['class_extension_paths']));
     }
     // setup DMS
     if (!empty(self::$_settings[$addon_name]['dms_paths'])) {
         EE_Register_Data_Migration_Scripts::register($addon_name, array('dms_paths' => self::$_settings[$addon_name]['dms_paths']));
     }
     // if config_class is present let's register config.
     if (!empty(self::$_settings[$addon_name]['config_class'])) {
         EE_Register_Config::register(self::$_settings[$addon_name]['config_class'], array('config_section' => self::$_settings[$addon_name]['config_section'], 'config_name' => self::$_settings[$addon_name]['config_name']));
     }
     // register admin page
     if (!empty(self::$_settings[$addon_name]['admin_path'])) {
         EE_Register_Admin_Page::register($addon_name, array('page_path' => self::$_settings[$addon_name]['admin_path']));
     }
     // add to list of modules to be registered
     if (!empty(self::$_settings[$addon_name]['module_paths'])) {
         EE_Register_Module::register($addon_name, array('module_paths' => self::$_settings[$addon_name]['module_paths']));
     }
     // add to list of shortcodes to be registered
     if (!empty(self::$_settings[$addon_name]['shortcode_paths'])) {
         EE_Register_Shortcode::register($addon_name, array('shortcode_paths' => self::$_settings[$addon_name]['shortcode_paths']));
     }
     // add to list of widgets to be registered
     if (!empty(self::$_settings[$addon_name]['widget_paths'])) {
         EE_Register_Widget::register($addon_name, array('widget_paths' => self::$_settings[$addon_name]['widget_paths']));
     }
     //register capability related stuff.
     if (!empty(self::$_settings[$addon_name]['capabilities'])) {
         EE_Register_Capabilities::register($addon_name, array('capabilities' => self::$_settings[$addon_name]['capabilities'], 'capability_maps' => self::$_settings[$addon_name]['capability_maps']));
     }
     //any message type to register?
     if (!empty(self::$_settings[$addon_name]['message_types'])) {
         add_action('EE_Brewing_Regular___messages_caf', array('EE_Register_Addon', 'register_message_types'));
     }
     // if plugin update engine is being used for auto-updates (not needed if PUE is not being used)
     if (!empty($setup_args['pue_options'])) {
         self::$_settings[$addon_name]['pue_options'] = array('pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug']) ? (string) $setup_args['pue_options']['pue_plugin_slug'] : 'espresso_' . strtolower($class_name), 'plugin_basename' => isset($setup_args['pue_options']['plugin_basename']) ? (string) $setup_args['pue_options']['plugin_basename'] : plugin_basename(self::$_settings[$addon_name]['main_file_path']), 'checkPeriod' => isset($setup_args['pue_options']['checkPeriod']) ? (string) $setup_args['pue_options']['checkPeriod'] : '24', 'use_wp_update' => isset($setup_args['pue_options']['use_wp_update']) ? (string) $setup_args['pue_options']['use_wp_update'] : FALSE);
         add_action('AHEE__EE_System__brew_espresso__after_pue_init', array('EE_Register_Addon', 'load_pue_update'));
     }
     //any custom post type/ custom capabilities or default terms to register
     if (!empty(self::$_settings[$addon_name]['custom_post_types']) || !empty(self::$_settings[$addon_name]['custom_taxonomies'])) {
         EE_Register_CPT::register($addon_name, array('cpts' => self::$_settings[$addon_name]['custom_post_types'], 'cts' => self::$_settings[$addon_name]['custom_taxonomies'], 'default_terms' => self::$_settings[$addon_name]['default_terms']));
     }
     if (!empty(self::$_settings[$addon_name]['payment_method_paths'])) {
         EE_Register_Payment_Method::register($addon_name, array('payment_method_paths' => self::$_settings[$addon_name]['payment_method_paths']));
     }
     // load and instantiate main addon class
     $addon = self::_load_and_init_addon_class($addon_name);
     // call any additional admin_callback functions during load_admin_controller hook
     if (!empty(self::$_settings[$addon_name]['admin_callback'])) {
         add_action('AHEE__EE_System__load_controllers__load_admin_controllers', array($addon, self::$_settings[$addon_name]['admin_callback']));
     }
 }
 /**
  *    _get_payment_info
  *
  * @access    public
  * @param EE_Cart $cart
  * @return    array
  */
 public function _get_payment_info(EE_Cart $cart)
 {
     EEH_Autoloader::register_line_item_filter_autoloaders();
     $line_item_filter_processor = new EE_Line_Item_Filter_Processor(apply_filters('FHEE__SPCO__EE_Line_Item_Filter_Collection', new EE_Line_Item_Filter_Collection()), $cart->get_grand_total());
     $filtered_line_item_tree = $line_item_filter_processor->process();
     // autoload Line_Item_Display classes
     EEH_Autoloader::register_line_item_display_autoloaders();
     //$this->checkout->line_item_filters();
     $Line_Item_Display = new EE_Line_Item_Display('spco');
     return array('payment_info' => $Line_Item_Display->display_line_item($filtered_line_item_tree), 'cart_total' => $filtered_line_item_tree->total());
 }
 /**
  *    initialize_template_parts
  *
  * @access    public
  * @param \EE_Events_Archive_Config $config
  * @return \EE_Template_Part_Manager
  */
 public function initialize_template_parts(EE_Events_Archive_Config $config = null)
 {
     $config = $config instanceof EE_Events_Archive_Config ? $config : $this->config();
     EEH_Autoloader::instance()->register_template_part_autoloaders();
     $template_parts = new EE_Template_Part_Manager();
     $template_parts->add_template_part('tickets', __('Ticket Selector', 'event_espresso'), 'content-espresso_events-tickets.php', $config->display_order_tickets);
     $template_parts->add_template_part('datetimes', __('Dates and Times', 'event_espresso'), 'content-espresso_events-datetimes.php', $config->display_order_datetimes);
     $template_parts->add_template_part('event', __('Event Description', 'event_espresso'), 'content-espresso_events-details.php', $config->display_order_event);
     $template_parts->add_template_part('venue', __('Venue Information', 'event_espresso'), 'content-espresso_events-venues.php', $config->display_order_venue);
     do_action('AHEE__EED_Event_Archive__initialize_template_parts', $template_parts);
     return $template_parts;
 }
 /**
  * This simply makes sure the autoloaders are registered for the EE_messages system.
  *
  * @since 4.5.0
  *
  * @return void
  */
 public static function set_autoloaders()
 {
     if (empty(self::$_MSG_PATHS)) {
         self::_set_messages_paths();
         foreach (self::$_MSG_PATHS as $path) {
             EEH_Autoloader::register_autoloaders_for_each_file_in_folder($path);
         }
         // add aliases
         EEH_Autoloader::add_alias('EE_messages', 'EE_messages');
         EEH_Autoloader::add_alias('EE_messenger', 'EE_messenger');
     }
 }
 /**
  * This simply makes sure the autoloaders are registered for the EE_Messages system.
  *
  * @since 4.5.0
  *
  * @return void
  */
 public static function set_autoloaders()
 {
     if (empty(self::$_MSG_PATHS)) {
         self::_set_messages_paths();
         EE_Registry::instance()->load_helper('Autoloader');
         foreach (self::$_MSG_PATHS as $path) {
             EEH_Autoloader::register_autoloaders_for_each_file_in_folder($path);
         }
     }
 }
 /**
  * load_required_files
  */
 protected function set_autoloaders_for_required_files()
 {
     // load interfaces
     espresso_load_required('EEI_Interfaces', EE_CORE . 'interfaces' . DS . 'EEI_Interfaces.php');
     // load helpers
     EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS);
     // load request stack
     EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'request_stack' . DS);
     // load middleware
     EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'middleware' . DS);
 }
 /**
  * Assumes all the files in this folder have the normal naming scheme (namely that their classname
  * is the file's name, plus ".whatever.php".) and adds each of them to the autoloader list.
  * If that's not the case, you'll need to improve this function or just use EEH_File::get_classname_from_filepath_with_standard_filename() directly.
  * Yes this has to scan the directory for files, but it only does it once -- not on EACH
  * time the autoloader is used
  *
  * @param string $folder name, with or without trailing /, doesn't matter
  * @param bool   $recursive
  * @param bool   $debug - set to true to display autoloader class => path mappings
  * @return void
  * @throws \EE_Error
  */
 public static function register_autoloaders_for_each_file_in_folder($folder, $recursive = false, $debug = false)
 {
     // make sure last char is a /
     $folder .= $folder[strlen($folder) - 1] != DS ? DS : '';
     $class_to_filepath_map = array();
     $exclude = array('index');
     //get all the files in that folder that end in php
     $filepaths = glob($folder . '*');
     if (empty($filepaths)) {
         return;
     }
     foreach ($filepaths as $filepath) {
         if (substr($filepath, -4, 4) == '.php') {
             $class_name = EEH_File::get_classname_from_filepath_with_standard_filename($filepath);
             if (!in_array($class_name, $exclude)) {
                 $class_to_filepath_map[$class_name] = $filepath;
             }
         } else {
             if ($recursive) {
                 EEH_Autoloader::register_autoloaders_for_each_file_in_folder($filepath, $recursive);
             }
         }
     }
     // we remove the necessity to do a is_readable() check via the $read_check flag because glob by nature will not return non_readable files/directories.
     self::register_autoloader($class_to_filepath_map, false, $debug);
 }
 /**
  * txn_details_meta_box
  * generates HTML for the Transaction main meta box
  *
  * @access public
  *	@return void
  */
 public function txn_details_meta_box()
 {
     $this->_set_transaction_object();
     $this->_template_args['TXN_ID'] = $this->_transaction->ID();
     $this->_template_args['attendee'] = $this->_transaction->primary_registration() instanceof EE_Registration ? $this->_transaction->primary_registration()->attendee() : null;
     //get line table
     EEH_Autoloader::register_line_item_display_autoloaders();
     $Line_Item_Display = new EE_Line_Item_Display('admin_table', 'EE_Admin_Table_Line_Item_Display_Strategy');
     $this->_template_args['line_item_table'] = $Line_Item_Display->display_line_item($this->_transaction->total_line_item());
     $this->_template_args['REG_code'] = $this->_transaction->get_first_related('Registration')->get('REG_code');
     // process taxes
     $taxes = $this->_transaction->get_many_related('Line_Item', array(array('LIN_type' => EEM_Line_Item::type_tax)));
     $this->_template_args['taxes'] = !empty($taxes) ? $taxes : FALSE;
     $this->_template_args['grand_total'] = EEH_Template::format_currency($this->_transaction->get('TXN_total'), FALSE, FALSE);
     $this->_template_args['grand_raw_total'] = $this->_transaction->get('TXN_total');
     $this->_template_args['TXN_status'] = $this->_transaction->get('STS_ID');
     //		$txn_status_class = 'status-' . $this->_transaction->get('STS_ID');
     // process payment details
     $payments = $this->_transaction->get_many_related('Payment');
     if (!empty($payments)) {
         $this->_template_args['payments'] = $payments;
         $this->_template_args['existing_reg_payments'] = $this->_get_registration_payment_IDs($payments);
     } else {
         $this->_template_args['payments'] = false;
         $this->_template_args['existing_reg_payments'] = array();
     }
     $this->_template_args['edit_payment_url'] = add_query_arg(array('action' => 'edit_payment'), TXN_ADMIN_URL);
     $this->_template_args['delete_payment_url'] = add_query_arg(array('action' => 'espresso_delete_payment'), TXN_ADMIN_URL);
     if (isset($txn_details['invoice_number'])) {
         $this->_template_args['txn_details']['invoice_number']['value'] = $this->_template_args['REG_code'];
         $this->_template_args['txn_details']['invoice_number']['label'] = __('Invoice Number', 'event_espresso');
     }
     $this->_template_args['txn_details']['registration_session']['value'] = $this->_transaction->get_first_related('Registration')->get('REG_session');
     $this->_template_args['txn_details']['registration_session']['label'] = __('Registration Session', 'event_espresso');
     $this->_template_args['txn_details']['ip_address']['value'] = isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '';
     $this->_template_args['txn_details']['ip_address']['label'] = __('Transaction placed from IP', 'event_espresso');
     $this->_template_args['txn_details']['user_agent']['value'] = isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '';
     $this->_template_args['txn_details']['user_agent']['label'] = __('Registrant User Agent', 'event_espresso');
     $reg_steps = '<ul>';
     foreach ($this->_transaction->reg_steps() as $reg_step => $reg_step_status) {
         if ($reg_step_status === true) {
             $reg_steps .= '<li style="color:#70cc50">' . sprintf(__('%1$s : Completed', 'event_espresso'), ucwords(str_replace('_', ' ', $reg_step))) . '</li>';
         } else {
             if (is_numeric($reg_step_status) && $reg_step_status !== false) {
                 $reg_steps .= '<li style="color:#2EA2CC">' . sprintf(__('%1$s : Initiated %2$s', 'event_espresso'), ucwords(str_replace('_', ' ', $reg_step)), gmdate(get_option('date_format') . ' ' . get_option('time_format'), $reg_step_status + get_option('gmt_offset') * HOUR_IN_SECONDS)) . '</li>';
             } else {
                 $reg_steps .= '<li style="color:#E76700">' . sprintf(__('%1$s : Never Initiated', 'event_espresso'), ucwords(str_replace('_', ' ', $reg_step))) . '</li>';
             }
         }
     }
     $reg_steps .= '</ul>';
     $this->_template_args['txn_details']['reg_steps']['value'] = $reg_steps;
     $this->_template_args['txn_details']['reg_steps']['label'] = __('Registration Step Progress', 'event_espresso');
     $this->_get_registrations_to_apply_payment_to();
     $this->_get_payment_methods($payments);
     $this->_get_payment_status_array();
     $this->_get_reg_status_selection();
     //sets up the template args for the reg status array for the transaction.
     $this->_template_args['transaction_form_url'] = add_query_arg(array('action' => 'edit_transaction', 'process' => 'transaction'), TXN_ADMIN_URL);
     $this->_template_args['apply_payment_form_url'] = add_query_arg(array('page' => 'espresso_transactions', 'action' => 'espresso_apply_payment'), WP_AJAX_URL);
     $this->_template_args['delete_payment_form_url'] = add_query_arg(array('page' => 'espresso_transactions', 'action' => 'espresso_delete_payment'), WP_AJAX_URL);
     // 'espresso_delete_payment_nonce'
     $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_txn_details.template.php';
     echo EEH_Template::display_template($template_path, $this->_template_args, TRUE);
 }
 /**
  * @return bool
  */
 public function generate_reg_form()
 {
     EE_Registry::instance()->load_helper('HTML');
     // set some defaults
     $this->checkout->selected_method_of_payment = 'payments_closed';
     $registrations_requiring_payment = array();
     $registrations_for_free_events = array();
     $registrations_requiring_pre_approval = array();
     $sold_out_events = array();
     $reg_count = 0;
     // loop thru registrations to gather info
     $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
     foreach ($registrations as $registration) {
         //echo '<h3 style="color:#E76700;line-height:1em;">' . $registration->ID() . '<br/><span style="font-size:9px;font-weight:normal;color:#666">' . __FILE__ . '</span>    <b style="font-size:10px;color:#333">  ' . __LINE__ . ' </b></h3>';
         /** @var $registration EE_Registration */
         $reg_count++;
         // if returning registrant is Approved then do NOT do this
         if (!($this->checkout->revisit && $registration->status_ID() == EEM_Registration::status_id_approved)) {
             if ($registration->event()->is_sold_out() || $registration->event()->is_sold_out(true)) {
                 // add event to list of events that are sold out
                 $sold_out_events[$registration->event()->ID()] = $registration->event();
                 do_action('AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event', $registration->event(), $this);
             }
             // event requires admin approval
             if ($registration->status_ID() == EEM_Registration::status_id_not_approved) {
                 // add event to list of events with pre-approval reg status
                 $registrations_requiring_pre_approval[$registration->ID()] = $registration;
                 do_action('AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_pre_approval', $registration->event(), $this);
             }
         }
         // are they allowed to pay now and is there monies owing?
         if ($registration->owes_monies_and_can_pay()) {
             $registrations_requiring_payment[$registration->ID()] = $registration;
             do_action('AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_payment', $registration->event(), $this);
         } else {
             if (!$this->checkout->revisit && $registration->status_ID() != EEM_Registration::status_id_not_approved && $registration->ticket()->is_free()) {
                 $registrations_for_free_events[$registration->event()->ID()] = $registration;
             }
         }
     }
     $subsections = array();
     // now decide which template to load
     if (!empty($sold_out_events)) {
         $subsections['sold_out_events'] = $this->_sold_out_events($sold_out_events);
     }
     if (!empty($registrations_requiring_pre_approval)) {
         $subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval($registrations_requiring_pre_approval);
     }
     if (!empty($registrations_for_free_events)) {
         $subsections['no_payment_required'] = $this->_no_payment_required($registrations_for_free_events);
     }
     if (!empty($registrations_requiring_payment)) {
         //EEH_Debug_Tools::printr( $registrations_requiring_payment, '$registrations_requiring_payment', __FILE__, __LINE__ );
         // autoload Line_Item_Display classes
         EEH_Autoloader::register_line_item_display_autoloaders();
         $this->set_Line_Item_Display(new EE_Line_Item_Display('spco'));
         $transaction_details = $this->Line_Item_Display->display_line_item($this->checkout->cart->get_grand_total(), array('registrations' => $registrations));
         $this->checkout->amount_owing = $this->Line_Item_Display->grand_total();
         if ($this->checkout->amount_owing > 0) {
             $subsections['payment_options'] = $this->_display_payment_options($transaction_details);
         }
     }
     return new EE_Form_Section_Proper(array('name' => $this->reg_form_name(), 'html_id' => $this->reg_form_name(), 'subsections' => $subsections, 'layout_strategy' => new EE_No_Layout()));
 }
 /**
  *    get_event_cart
  *
  * @access public
  * @param string $template
  * @return string
  * @throws \EE_Error
  */
 public function get_mini_cart($template = '')
 {
     switch ($template) {
         case EE_MER_PATH . 'templates' . DS . 'widget_minicart_list.template.php':
             $minicart_line_item_display_strategy = 'EE_Mini_Cart_List_Line_Item_Display_Strategy';
             break;
         case EE_MER_PATH . 'templates' . DS . 'widget_minicart_table.template.php':
         default:
             $minicart_line_item_display_strategy = 'EE_Mini_Cart_Table_Line_Item_Display_Strategy';
             break;
     }
     EEH_Autoloader::register_autoloader(array($minicart_line_item_display_strategy => EE_MER_PATH . $minicart_line_item_display_strategy . '.php'));
     // autoload Line_Item_Display classes
     EEH_Autoloader::register_line_item_display_autoloaders();
     $Line_Item_Display = new EE_Line_Item_Display('event_cart', apply_filters('FHEE__EEW_Mini_Cart__widget__minicart_line_item_display_strategy', $minicart_line_item_display_strategy));
     if (!$Line_Item_Display instanceof EE_Line_Item_Display && WP_DEBUG) {
         throw new EE_Error(__('A valid instance of EE_Event_Cart_Line_Item_Display_Strategy could not be obtained.', 'event_espresso'));
     }
     return $Line_Item_Display->display_line_item(EE_Registry::instance()->CART->get_grand_total());
 }
 /**
  * load_reg_steps
  * loads and instantiates each reg step based on the EE_Registry::instance()->CFG->registration->reg_steps array
  *
  * @access    private
  * @throws EE_Error
  * @return    array
  */
 public static function load_reg_steps()
 {
     static $reg_steps_loaded = FALSE;
     if ($reg_steps_loaded) {
         return;
     }
     // load EE_SPCO_Reg_Step base class
     //		EE_Registry::instance()->load_file( SPCO_INC_PATH, 'EE_SPCO_Reg_Step', 'class'  );
     // filter list of reg_steps
     $reg_steps_to_load = apply_filters('AHEE__SPCO__load_reg_steps__reg_steps_to_load', EED_Single_Page_Checkout::get_reg_steps());
     // sort by key (order)
     ksort($reg_steps_to_load);
     // loop through folders
     foreach ($reg_steps_to_load as $order => $reg_step) {
         // we need a
         if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
             // copy over to the reg_steps_array
             EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step;
             // register custom key route for each reg step ( ie: step=>"slug" - this is the entire reason we load the reg steps array now )
             EE_Config::register_route($reg_step['slug'], 'EED_Single_Page_Checkout', 'run', 'step');
             // add AJAX or other hooks
             if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) {
                 // setup autoloaders if necessary
                 if (!class_exists($reg_step['class_name'])) {
                     EEH_Autoloader::register_autoloaders_for_each_file_in_folder($reg_step['file_path'], TRUE);
                 }
                 if (is_callable($reg_step['class_name'], 'set_hooks')) {
                     call_user_func(array($reg_step['class_name'], 'set_hooks'));
                 }
             }
         }
     }
     $reg_steps_loaded = TRUE;
 }
 * Meant to add the new ee_message table to the database.
 */
//make sure we have all the stages loaded too
//unfortunately, this needs to be done upon INCLUSION of this file,
//instead of construction, because it only gets constructed on first page load
//(all other times it gets resurrected from a wordpress option)
$stages = glob(EE_CORE . 'data_migration_scripts/4_9_0_stages/*');
$class_to_filepath = array();
foreach ($stages as $filepath) {
    $matches = array();
    preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches);
    $class_to_filepath[$matches[1]] = $filepath;
}
//give addons a chance to autoload their stages too
$class_to_filepath = apply_filters('FHEE__EE_DMS_4_9_0__autoloaded_stages', $class_to_filepath);
EEH_Autoloader::register_autoloader($class_to_filepath);
/**
 * Class EE_DMS_Core_4_9_0
 *
 * @package            Event Espresso
 * @subpackage    core
 * @author                Mike Nelson
 * @since                4.6.0
 *
 */
class EE_DMS_Core_4_9_0 extends EE_Data_Migration_Script_Base
{
    /**
     * return EE_DMS_Core_4_9_0
     */
    public function __construct()
 /**
  * load_espresso_addons
  *
  * allow addons to load first so that they can set hooks for running DMS's, etc
  *
  * @access public
  * @return void
  */
 public function load_espresso_addons()
 {
     // set autoloaders for all of the classes implementing EEI_Plugin_API
     // which provide helpers for EE plugin authors to more easily register certain components with EE.
     EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api');
     //load and setup EE_Capabilities
     EE_Registry::instance()->load_core('Capabilities');
     do_action('AHEE__EE_System__load_espresso_addons');
 }
 /**
  * 		generates HTML for the Registration main meta box
  *		@access public
  *		@return void
  */
 public function _reg_details_meta_box()
 {
     EEH_Autoloader::register_line_item_display_autoloaders();
     EEH_Autoloader::register_line_item_filter_autoloaders();
     EE_Registry::instance()->load_Helper('Line_Item');
     $transaction = $this->_registration->transaction() ? $this->_registration->transaction() : EE_Transaction::new_instance();
     $this->_session = $transaction->session_data();
     $filters = new EE_Line_Item_Filter_Collection();
     $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
     $filters->add(new EE_Non_Zero_Line_Item_Filter());
     $line_item_filter_processor = new EE_Line_Item_Filter_Processor($filters, $transaction->total_line_item());
     $filtered_line_item_tree = $line_item_filter_processor->process();
     $this->_template_args['REG_ID'] = $this->_registration->ID();
     $line_item_display = new EE_Line_Item_Display('reg_admin_table', 'EE_Admin_Table_Registration_Line_Item_Display_Strategy');
     $this->_template_args['line_item_table'] = $line_item_display->display_line_item($filtered_line_item_tree, array('EE_Registration' => $this->_registration));
     $attendee = $this->_registration->attendee();
     $this->_template_args['view_transaction_button'] = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', 'espresso_transactions_view_transaction') ? EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array('action' => 'view_transaction', 'TXN_ID' => $transaction->ID()), TXN_ADMIN_URL), __(' View Transaction'), 'button secondary-button right', 'dashicons dashicons-cart') : '';
     $this->_template_args['resend_registration_button'] = $attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_registrations_resend_registration') ? EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array('action' => 'resend_registration', '_REG_ID' => $this->_registration->ID(), 'redirect_to' => 'view_registration'), REG_ADMIN_URL), __(' Resend Registration'), 'button secondary-button right', 'dashicons dashicons-email-alt') : '';
     $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
     $payment = $transaction->get_first_related('Payment');
     $payment = !$payment instanceof EE_Payment ? EE_Payment::new_instance() : $payment;
     $payment_method = $payment->get_first_related('Payment_Method');
     $payment_method = !$payment_method instanceof EE_Payment_Method ? EE_Payment_Method::new_instance() : $payment_method;
     $reg_status_class = 'status-' . $this->_registration->status_ID();
     $reg_details = array('payment_method' => $payment_method->name(), 'response_msg' => $payment->gateway_response(), 'registration_id' => $this->_registration->get('REG_code'), 'registration_session' => $this->_registration->session_ID(), 'ip_address' => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '', 'user_agent' => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '');
     if (isset($reg_details['registration_id'])) {
         $this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
         $this->_template_args['reg_details']['registration_id']['label'] = __('Registration ID', 'event_espresso');
         $this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
     }
     if (isset($reg_details['payment_method'])) {
         $this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
         $this->_template_args['reg_details']['payment_method']['label'] = __('Most Recent Payment Method', 'event_espresso');
         $this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
         $this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg'];
         $this->_template_args['reg_details']['response_msg']['label'] = __('Payment method response', 'event_espresso');
         $this->_template_args['reg_details']['response_msg']['class'] = 'regular-text';
     }
     $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
     $this->_template_args['reg_details']['registration_session']['label'] = __('Registration Session', 'event_espresso');
     $this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
     $this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address'];
     $this->_template_args['reg_details']['ip_address']['label'] = __('Registration placed from IP', 'event_espresso');
     $this->_template_args['reg_details']['ip_address']['class'] = 'regular-text';
     $this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent'];
     $this->_template_args['reg_details']['user_agent']['label'] = __('Registrant User Agent', 'event_espresso');
     $this->_template_args['reg_details']['user_agent']['class'] = 'large-text';
     $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'default', 'event_id' => $this->_registration->event_ID()), REG_ADMIN_URL);
     $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
     echo EEH_Template::display_template($template_path, $this->_template_args, TRUE);
 }
 /**
  * 	register core, model and class 'autoloaders'
  *
  * 	@access private
  * 	@return void
  */
 private function _register_custom_autoloaders()
 {
     EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE);
     EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_MODELS);
     EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_MODELS . DS . 'fields');
     EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_MODELS . DS . 'helpers');
     EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_MODELS . DS . 'relations');
     EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_MODELS . DS . 'strategies');
     EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CLASSES);
 }
 /**
  *    _get_event_cart
  *
  * @access        protected
  * @param \EE_Line_Item $line_item
  * @return string
  * @throws \EE_Error
  */
 protected function _get_event_cart($line_item = null)
 {
     $line_item = $line_item instanceof EE_Line_Item ? $line_item : EE_Registry::instance()->CART->get_grand_total();
     // autoload Line_Item_Display classes
     EEH_Autoloader::register_line_item_display_autoloaders();
     $Line_Item_Display = new EE_Line_Item_Display('event_cart', 'EE_Event_Cart_Line_Item_Display_Strategy');
     if (!$Line_Item_Display instanceof EE_Line_Item_Display && WP_DEBUG) {
         throw new EE_Error(__('A valid instance of EE_Event_Cart_Line_Item_Display_Strategy could not be obtained.', 'event_espresso'));
     }
     return $Line_Item_Display->display_line_item($line_item);
 }
 /**
  * Gets all the data migration scripts available in the core folder and folders
  * in addons. Has the side effect of adding them for autoloading
  * @return array keys are expected classnames, values are their filepaths
  */
 public function get_all_data_migration_scripts_available()
 {
     if (!$this->_data_migration_class_to_filepath_map) {
         $this->_data_migration_class_to_filepath_map = array();
         foreach ($this->get_data_migration_script_folders() as $folder_path) {
             if ($folder_path[count($folder_path - 1)] != DS) {
                 $folder_path .= DS;
             }
             $files = glob($folder_path . '*.dms.php');
             if (empty($files)) {
                 continue;
             }
             foreach ($files as $file) {
                 $pos_of_last_slash = strrpos($file, DS);
                 $classname = str_replace(".dms.php", "", substr($file, $pos_of_last_slash + 1));
                 $migrates_to = $this->script_migrates_to_version($classname);
                 $slug = $migrates_to['slug'];
                 //check that the slug as contained in the DMS is associated with
                 //the slug of an addon or core
                 if ($slug != 'Core') {
                     if (!EE_Registry::instance()->get_addon_by_name($slug)) {
                         EE_Error::doing_it_wrong(__FUNCTION__, sprintf(__('The data migration script "%s" migrates the "%s" data, but there is no EE addon with that name. There is only: %s. ', 'event_espresso'), $classname, $slug, implode(",", array_keys(EE_Registry::instance()->get_addons_by_name()))), '4.3.0.alpha.019');
                     }
                 }
                 $this->_data_migration_class_to_filepath_map[$classname] = $file;
             }
         }
         EEH_Autoloader::register_autoloader($this->_data_migration_class_to_filepath_map);
     }
     return $this->_data_migration_class_to_filepath_map;
 }
 /**
  * load_espresso_addons
  *
  * allow addons to load first so that they can set hooks for running DMS's, etc
  * this is hooked into both:
  * 	'AHEE__EE_Bootstrap__load_core_configuration'
  * 		which runs during the WP 'plugins_loaded' action at priority 5
  * 	and the WP 'activate_plugin' hookpoint
  *
  * @access public
  * @return void
  */
 public function load_espresso_addons()
 {
     // set autoloaders for all of the classes implementing EEI_Plugin_API
     // which provide helpers for EE plugin authors to more easily register certain components with EE.
     EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api');
     //load and setup EE_Capabilities
     $this->registry->load_core('Capabilities');
     //caps need to be initialized on every request so that capability maps are set.
     //@see https://events.codebasehq.com/projects/event-espresso/tickets/8674
     $this->registry->CAP->init_caps();
     do_action('AHEE__EE_System__load_espresso_addons');
     //if the WP API basic auth plugin isn't already loaded, load it now.
     //We want it for mobile apps. Just include the entire plugin
     //also, don't load the basic auth when a plugin is getting activated, because
     //it could be the basic auth plugin, and it doesn't check if its methods are already defined
     //and causes a fatal error
     if (!function_exists('json_basic_auth_handler') && !function_exists('json_basic_auth_error') && !(isset($_GET['action']) && in_array($_GET['action'], array('activate', 'activate-selected'))) && !(isset($_GET['activate']) && $_GET['activate'] === 'true')) {
         include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php';
     }
 }
 /**
  * This method is the "workhorse" for detecting and setting up caffeinated functionality.
  *
  * In this method there are three checks being done:
  * 1. Do we have any NEW admin page sets.  If we do, lets add them into the menu setup (via the $installed_refs array) etc.  (new page sets are found in caffeinated/new/{page})
  * 2. Do we have any EXTENDED page sets.  Basically an extended EE_Admin Page extends the core {child}_Admin_Page class.  eg. would be caffeinated/extend/events/Extend_Events_Admin_Page.core.php and in there would be a class: Extend_Events_Admin_Page extends Events_Admin_Page.
  * 3. Do we have any files just for setting up hooks into other core pages.  The files can be any name in "caffeinated/hooks" EXCEPT they need a ".class.php" extension and the file name must correspond with the classname inside.  These classes are instantiated really early so that any hooks in them are run before the corresponding apply_filters/do_actions that are found in any future loaded EE_Admin pages (INCLUDING caffeinated admin_pages)
  *
  *
  *
  * @param array $installed_refs the original installed_refs array that may contain our NEW EE_Admin_Pages to be loaded.
  * @return array
  */
 private function _set_caffeinated($installed_refs)
 {
     //first let's check if there IS a caffeinated folder. If there is not then lets get out.
     if (!is_dir(EE_PLUGIN_DIR_PATH . 'caffeinated' . DS . 'admin') || defined('EE_DECAF') && EE_DECAF) {
         return $installed_refs;
     }
     $this->_define_caffeinated_constants();
     $exclude = array('tickets');
     //okay let's setup an "New" pages first (we'll return installed refs later)
     $new_admin_screens = glob(EE_CORE_CAF_ADMIN . 'new/*', GLOB_ONLYDIR);
     if ($new_admin_screens) {
         foreach ($new_admin_screens as $admin_screen) {
             // files and anything in the exclude array need not apply
             if (is_dir($admin_screen) && !in_array(basename($admin_screen), $exclude)) {
                 // these folders represent the different NEW EE admin pages
                 $installed_refs[basename($admin_screen)] = $admin_screen;
                 // set autoloaders for our admin page classes based on included path information
                 EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder($admin_screen);
                 //					$this->_caf_autoloader[] = array(
                 //						'dir' => 'new',
                 //						'folder' => basename( $admin_screen )
                 //					);
             }
         }
     }
     //let's see if there are any EXTENDS to setup in the $_caffeinated_extends array (that will be used later for hooking into the _initialize_admin_age in the related core_init admin page)
     $extends = glob(EE_CORE_CAF_ADMIN . 'extend/*', GLOB_ONLYDIR);
     if ($extends) {
         foreach ($extends as $extend) {
             if (is_dir($extend)) {
                 $extend_ref = basename($extend);
                 //now let's make sure there is a file that matches the expected format
                 $filename = str_replace(' ', '_', ucwords(str_replace('_', ' ', $extend_ref)));
                 $filename = 'Extend_' . $filename . '_Admin_Page';
                 $this->_caffeinated_extends[$extend_ref]['path'] = str_replace(array('\\', '/'), DS, EE_CORE_CAF_ADMIN . 'extend' . DS . $extend_ref . DS . $filename . '.core.php');
                 $this->_caffeinated_extends[$extend_ref]['admin_page'] = $filename;
                 // set autoloaders for our admin page classes based on included path information
                 EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder($extend);
                 //					$this->_caf_autoloader[] = array(
                 //						'dir' => 'extend',
                 //						'folder' => $extend_ref
                 //					);
             }
         }
     }
     //let's see if there are any HOOK files and instantiate them if there are (so that hooks are loaded early!).
     $ee_admin_hooks = array();
     $hooks = glob(EE_CORE_CAF_ADMIN . 'hooks/*.class.php');
     if ($hooks) {
         foreach ($hooks as $hook) {
             if (is_readable($hook)) {
                 require_once $hook;
                 $classname = str_replace(EE_CORE_CAF_ADMIN . 'hooks/', '', $hook);
                 $classname = str_replace('.class.php', '', $classname);
                 if (class_exists($classname)) {
                     $a = new ReflectionClass($classname);
                     $ee_admin_hooks[] = $a->newInstance();
                 }
             }
         }
     }
     /**/
     $ee_admin_hooks = apply_filters('FHEE__EE_Admin_Page_Loader__set_caffeinated__ee_admin_hooks', $ee_admin_hooks);
     return $installed_refs;
 }
 function setUp()
 {
     parent::setUp();
     EEH_Autoloader::register_line_item_filter_autoloaders();
 }
 /**
  * load_espresso_addons
  *
  * allow addons to load first so that they can set hooks for running DMS's, etc
  * this is hooked into both:
  * 	'AHEE__EE_Bootstrap__load_core_configuration'
  * 		which runs during the WP 'plugins_loaded' action at priority 5
  * 	and the WP 'activate_plugin' hookpoint
  *
  * @access public
  * @return void
  */
 public function load_espresso_addons()
 {
     // set autoloaders for all of the classes implementing EEI_Plugin_API
     // which provide helpers for EE plugin authors to more easily register certain components with EE.
     EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api');
     //load and setup EE_Capabilities
     EE_Registry::instance()->load_core('Capabilities');
     //caps need to be initialized on every request so that capability maps are set.
     //@see https://events.codebasehq.com/projects/event-espresso/tickets/8674
     EE_Registry::instance()->CAP->init_caps();
     do_action('AHEE__EE_System__load_espresso_addons');
 }