@@ -5,63 +5,63 @@ |
||
| 5 | 5 | |
| 6 | 6 | interface HasSchemaInterface |
| 7 | 7 | { |
| 8 | - /** |
|
| 9 | - * Returns whatever is set as the nicename for the object. |
|
| 10 | - * |
|
| 11 | - * @return string |
|
| 12 | - */ |
|
| 13 | - public function getSchemaDescription(); |
|
| 8 | + /** |
|
| 9 | + * Returns whatever is set as the nicename for the object. |
|
| 10 | + * |
|
| 11 | + * @return string |
|
| 12 | + */ |
|
| 13 | + public function getSchemaDescription(); |
|
| 14 | 14 | |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * Returns whatever is set as the $_schema_type property for the object. |
|
| 18 | - * Note: this will automatically add 'null' to the schema if the object is_nullable() |
|
| 19 | - * |
|
| 20 | - * @return string|array |
|
| 21 | - */ |
|
| 22 | - public function getSchemaType(); |
|
| 16 | + /** |
|
| 17 | + * Returns whatever is set as the $_schema_type property for the object. |
|
| 18 | + * Note: this will automatically add 'null' to the schema if the object is_nullable() |
|
| 19 | + * |
|
| 20 | + * @return string|array |
|
| 21 | + */ |
|
| 22 | + public function getSchemaType(); |
|
| 23 | 23 | |
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * This is usually present when the $_schema_type property is 'object'. Any child classes will need to override |
|
| 27 | - * this method and return the properties for the schema. |
|
| 28 | - * The reason this is not a property on the class is because there may be filters set on the values for the property |
|
| 29 | - * that won't be exposed on construct. For example enum type schemas may have the enum values filtered. |
|
| 30 | - * |
|
| 31 | - * @return array |
|
| 32 | - */ |
|
| 33 | - public function getSchemaProperties(); |
|
| 25 | + /** |
|
| 26 | + * This is usually present when the $_schema_type property is 'object'. Any child classes will need to override |
|
| 27 | + * this method and return the properties for the schema. |
|
| 28 | + * The reason this is not a property on the class is because there may be filters set on the values for the property |
|
| 29 | + * that won't be exposed on construct. For example enum type schemas may have the enum values filtered. |
|
| 30 | + * |
|
| 31 | + * @return array |
|
| 32 | + */ |
|
| 33 | + public function getSchemaProperties(); |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * If a child class has enum values, they should override this method and provide a simple array |
|
| 37 | - * of the enum values. |
|
| 38 | - * The reason this is not a property on the class is because there may be filterable enum values that |
|
| 39 | - * are set on the instantiated object that could be filtered after construct. |
|
| 40 | - * |
|
| 41 | - * @return array |
|
| 42 | - */ |
|
| 43 | - public function getSchemaEnum(); |
|
| 35 | + /** |
|
| 36 | + * If a child class has enum values, they should override this method and provide a simple array |
|
| 37 | + * of the enum values. |
|
| 38 | + * The reason this is not a property on the class is because there may be filterable enum values that |
|
| 39 | + * are set on the instantiated object that could be filtered after construct. |
|
| 40 | + * |
|
| 41 | + * @return array |
|
| 42 | + */ |
|
| 43 | + public function getSchemaEnum(); |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * This returns the value of the $_schema_format property on the object. |
|
| 47 | - * |
|
| 48 | - * @return string |
|
| 49 | - */ |
|
| 50 | - public function getSchemaFormat(); |
|
| 45 | + /** |
|
| 46 | + * This returns the value of the $_schema_format property on the object. |
|
| 47 | + * |
|
| 48 | + * @return string |
|
| 49 | + */ |
|
| 50 | + public function getSchemaFormat(); |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * This returns the value of the $_schema_readonly property on the object. |
|
| 54 | - * |
|
| 55 | - * @return bool |
|
| 56 | - */ |
|
| 57 | - public function getSchemaReadonly(); |
|
| 52 | + /** |
|
| 53 | + * This returns the value of the $_schema_readonly property on the object. |
|
| 54 | + * |
|
| 55 | + * @return bool |
|
| 56 | + */ |
|
| 57 | + public function getSchemaReadonly(); |
|
| 58 | 58 | |
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * This returns elements used to represent this field in the json schema. |
|
| 62 | - * |
|
| 63 | - * @link http://json-schema.org/ |
|
| 64 | - * @return array |
|
| 65 | - */ |
|
| 66 | - public function getSchema(); |
|
| 60 | + /** |
|
| 61 | + * This returns elements used to represent this field in the json schema. |
|
| 62 | + * |
|
| 63 | + * @link http://json-schema.org/ |
|
| 64 | + * @return array |
|
| 65 | + */ |
|
| 66 | + public function getSchema(); |
|
| 67 | 67 | } |
| 68 | 68 | \ No newline at end of file |
@@ -7,36 +7,36 @@ |
||
| 7 | 7 | abstract class EE_Text_Field_Base extends EE_Model_Field_Base |
| 8 | 8 | { |
| 9 | 9 | |
| 10 | - function prepare_for_get($value_of_field_on_model_object) |
|
| 11 | - { |
|
| 12 | - return is_string($value_of_field_on_model_object) ? stripslashes($value_of_field_on_model_object) : $value_of_field_on_model_object; |
|
| 13 | - } |
|
| 10 | + function prepare_for_get($value_of_field_on_model_object) |
|
| 11 | + { |
|
| 12 | + return is_string($value_of_field_on_model_object) ? stripslashes($value_of_field_on_model_object) : $value_of_field_on_model_object; |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Accepts schema of 'form_input' which formats the string for echoing in form input's value. |
|
| 17 | - * |
|
| 18 | - * @param string $value_on_field_to_be_outputted |
|
| 19 | - * @param string $schema |
|
| 20 | - * @return string |
|
| 21 | - */ |
|
| 22 | - function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
| 23 | - { |
|
| 24 | - if ($schema == 'form_input') { |
|
| 25 | - $value_on_field_to_be_outputted = htmlentities($value_on_field_to_be_outputted, ENT_QUOTES, 'UTF-8'); |
|
| 26 | - } |
|
| 27 | - return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema); |
|
| 28 | - } |
|
| 15 | + /** |
|
| 16 | + * Accepts schema of 'form_input' which formats the string for echoing in form input's value. |
|
| 17 | + * |
|
| 18 | + * @param string $value_on_field_to_be_outputted |
|
| 19 | + * @param string $schema |
|
| 20 | + * @return string |
|
| 21 | + */ |
|
| 22 | + function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
| 23 | + { |
|
| 24 | + if ($schema == 'form_input') { |
|
| 25 | + $value_on_field_to_be_outputted = htmlentities($value_on_field_to_be_outputted, ENT_QUOTES, 'UTF-8'); |
|
| 26 | + } |
|
| 27 | + return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema); |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * In form inputs, we should have called htmlentities and addslashes on form inputs, |
|
| 32 | - * so we need to undo that on setting of these fields |
|
| 33 | - * |
|
| 34 | - * @param string $value_inputted_for_field_on_model_object |
|
| 35 | - * @return string |
|
| 36 | - */ |
|
| 37 | - function prepare_for_set($value_inputted_for_field_on_model_object) |
|
| 38 | - { |
|
| 39 | - return stripslashes(html_entity_decode(parent::prepare_for_set($value_inputted_for_field_on_model_object), |
|
| 40 | - ENT_QUOTES, 'UTF-8')); |
|
| 41 | - } |
|
| 30 | + /** |
|
| 31 | + * In form inputs, we should have called htmlentities and addslashes on form inputs, |
|
| 32 | + * so we need to undo that on setting of these fields |
|
| 33 | + * |
|
| 34 | + * @param string $value_inputted_for_field_on_model_object |
|
| 35 | + * @return string |
|
| 36 | + */ |
|
| 37 | + function prepare_for_set($value_inputted_for_field_on_model_object) |
|
| 38 | + { |
|
| 39 | + return stripslashes(html_entity_decode(parent::prepare_for_set($value_inputted_for_field_on_model_object), |
|
| 40 | + ENT_QUOTES, 'UTF-8')); |
|
| 41 | + } |
|
| 42 | 42 | } |
| 43 | 43 | \ No newline at end of file |
@@ -4,22 +4,22 @@ |
||
| 4 | 4 | class EE_Primary_Key_String_Field extends EE_Primary_Key_Field_Base |
| 5 | 5 | { |
| 6 | 6 | |
| 7 | - public function __construct($table_column, $nicename) |
|
| 8 | - { |
|
| 9 | - parent::__construct($table_column, $nicename, null); |
|
| 10 | - } |
|
| 7 | + public function __construct($table_column, $nicename) |
|
| 8 | + { |
|
| 9 | + parent::__construct($table_column, $nicename, null); |
|
| 10 | + } |
|
| 11 | 11 | |
| 12 | - /** |
|
| 13 | - * removes all tags when setting |
|
| 14 | - * |
|
| 15 | - * @param string $value_inputted_for_field_on_model_object |
|
| 16 | - * @return string |
|
| 17 | - */ |
|
| 18 | - function prepare_for_set($value_inputted_for_field_on_model_object) |
|
| 19 | - { |
|
| 20 | - if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) { |
|
| 21 | - $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID(); |
|
| 22 | - } |
|
| 23 | - return wp_strip_all_tags($value_inputted_for_field_on_model_object); |
|
| 24 | - } |
|
| 12 | + /** |
|
| 13 | + * removes all tags when setting |
|
| 14 | + * |
|
| 15 | + * @param string $value_inputted_for_field_on_model_object |
|
| 16 | + * @return string |
|
| 17 | + */ |
|
| 18 | + function prepare_for_set($value_inputted_for_field_on_model_object) |
|
| 19 | + { |
|
| 20 | + if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) { |
|
| 21 | + $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID(); |
|
| 22 | + } |
|
| 23 | + return wp_strip_all_tags($value_inputted_for_field_on_model_object); |
|
| 24 | + } |
|
| 25 | 25 | } |
| 26 | 26 | \ No newline at end of file |
@@ -4,17 +4,17 @@ |
||
| 4 | 4 | class EE_Foreign_Key_String_Field extends EE_Foreign_Key_Field_Base |
| 5 | 5 | { |
| 6 | 6 | |
| 7 | - /** |
|
| 8 | - * removes all tags when setting |
|
| 9 | - * |
|
| 10 | - * @param string $value_inputted_for_field_on_model_object |
|
| 11 | - * @return string |
|
| 12 | - */ |
|
| 13 | - function prepare_for_set($value_inputted_for_field_on_model_object) |
|
| 14 | - { |
|
| 15 | - if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) { |
|
| 16 | - $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID(); |
|
| 17 | - } |
|
| 18 | - return strtoupper(wp_strip_all_tags($value_inputted_for_field_on_model_object)); |
|
| 19 | - } |
|
| 7 | + /** |
|
| 8 | + * removes all tags when setting |
|
| 9 | + * |
|
| 10 | + * @param string $value_inputted_for_field_on_model_object |
|
| 11 | + * @return string |
|
| 12 | + */ |
|
| 13 | + function prepare_for_set($value_inputted_for_field_on_model_object) |
|
| 14 | + { |
|
| 15 | + if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) { |
|
| 16 | + $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID(); |
|
| 17 | + } |
|
| 18 | + return strtoupper(wp_strip_all_tags($value_inputted_for_field_on_model_object)); |
|
| 19 | + } |
|
| 20 | 20 | } |
| 21 | 21 | \ No newline at end of file |
@@ -6,14 +6,14 @@ |
||
| 6 | 6 | */ |
| 7 | 7 | class EE_All_Caps_Text_Field extends EE_Text_Field_Base |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * makes it all upper case, and key-like |
|
| 11 | - * |
|
| 12 | - * @param string $value_inputted_for_field_on_model_object |
|
| 13 | - * @return string |
|
| 14 | - */ |
|
| 15 | - function prepare_for_set($value_inputted_for_field_on_model_object) |
|
| 16 | - { |
|
| 17 | - return strtoupper(sanitize_key($value_inputted_for_field_on_model_object)); |
|
| 18 | - } |
|
| 9 | + /** |
|
| 10 | + * makes it all upper case, and key-like |
|
| 11 | + * |
|
| 12 | + * @param string $value_inputted_for_field_on_model_object |
|
| 13 | + * @return string |
|
| 14 | + */ |
|
| 15 | + function prepare_for_set($value_inputted_for_field_on_model_object) |
|
| 16 | + { |
|
| 17 | + return strtoupper(sanitize_key($value_inputted_for_field_on_model_object)); |
|
| 18 | + } |
|
| 19 | 19 | } |
| 20 | 20 | \ No newline at end of file |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | use EventEspresso\core\exceptions\InvalidEntityException; |
| 3 | 3 | |
| 4 | 4 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
| 5 | - exit('No direct script access allowed'); |
|
| 5 | + exit('No direct script access allowed'); |
|
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | |
@@ -17,1709 +17,1709 @@ discard block |
||
| 17 | 17 | class EED_Single_Page_Checkout extends EED_Module |
| 18 | 18 | { |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * $_initialized - has the SPCO controller already been initialized ? |
|
| 22 | - * |
|
| 23 | - * @access private |
|
| 24 | - * @var bool $_initialized |
|
| 25 | - */ |
|
| 26 | - private static $_initialized = false; |
|
| 27 | - |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * $_checkout_verified - is the EE_Checkout verified as correct for this request ? |
|
| 31 | - * |
|
| 32 | - * @access private |
|
| 33 | - * @var bool $_valid_checkout |
|
| 34 | - */ |
|
| 35 | - private static $_checkout_verified = true; |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * $_reg_steps_array - holds initial array of reg steps |
|
| 39 | - * |
|
| 40 | - * @access private |
|
| 41 | - * @var array $_reg_steps_array |
|
| 42 | - */ |
|
| 43 | - private static $_reg_steps_array = array(); |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * $checkout - EE_Checkout object for handling the properties of the current checkout process |
|
| 47 | - * |
|
| 48 | - * @access public |
|
| 49 | - * @var EE_Checkout $checkout |
|
| 50 | - */ |
|
| 51 | - public $checkout; |
|
| 52 | - |
|
| 53 | - |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * @return EED_Single_Page_Checkout |
|
| 57 | - */ |
|
| 58 | - public static function instance() |
|
| 59 | - { |
|
| 60 | - add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true'); |
|
| 61 | - return parent::get_instance(__CLASS__); |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * @return EE_CART |
|
| 68 | - */ |
|
| 69 | - public function cart() |
|
| 70 | - { |
|
| 71 | - return $this->checkout->cart; |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * @return EE_Transaction |
|
| 78 | - */ |
|
| 79 | - public function transaction() |
|
| 80 | - { |
|
| 81 | - return $this->checkout->transaction; |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
| 88 | - * |
|
| 89 | - * @access public |
|
| 90 | - * @return void |
|
| 91 | - * @throws \EE_Error |
|
| 92 | - */ |
|
| 93 | - public static function set_hooks() |
|
| 94 | - { |
|
| 95 | - EED_Single_Page_Checkout::set_definitions(); |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - |
|
| 99 | - |
|
| 100 | - /** |
|
| 101 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
| 102 | - * |
|
| 103 | - * @access public |
|
| 104 | - * @return void |
|
| 105 | - * @throws \EE_Error |
|
| 106 | - */ |
|
| 107 | - public static function set_hooks_admin() |
|
| 108 | - { |
|
| 109 | - EED_Single_Page_Checkout::set_definitions(); |
|
| 110 | - if ( ! (defined('DOING_AJAX') && DOING_AJAX)) { |
|
| 111 | - // hook into the top of pre_get_posts to set the reg step routing, which gives other modules or plugins a chance to modify the reg steps, but just before the routes get called |
|
| 112 | - add_action('pre_get_posts', array('EED_Single_Page_Checkout', 'load_reg_steps'), 1); |
|
| 113 | - return; |
|
| 114 | - } |
|
| 115 | - // going to start an output buffer in case anything gets accidentally output that might disrupt our JSON response |
|
| 116 | - ob_start(); |
|
| 117 | - EED_Single_Page_Checkout::load_request_handler(); |
|
| 118 | - EED_Single_Page_Checkout::load_reg_steps(); |
|
| 119 | - // set ajax hooks |
|
| 120 | - add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
| 121 | - add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
| 122 | - add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
| 123 | - add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
| 124 | - add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
| 125 | - add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - |
|
| 129 | - |
|
| 130 | - /** |
|
| 131 | - * process ajax request |
|
| 132 | - * |
|
| 133 | - * @param string $ajax_action |
|
| 134 | - * @throws \EE_Error |
|
| 135 | - */ |
|
| 136 | - public static function process_ajax_request($ajax_action) |
|
| 137 | - { |
|
| 138 | - EE_Registry::instance()->REQ->set('action', $ajax_action); |
|
| 139 | - EED_Single_Page_Checkout::instance()->_initialize(); |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - |
|
| 143 | - |
|
| 144 | - /** |
|
| 145 | - * ajax display registration step |
|
| 146 | - * |
|
| 147 | - * @throws \EE_Error |
|
| 148 | - */ |
|
| 149 | - public static function display_reg_step() |
|
| 150 | - { |
|
| 151 | - EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step'); |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - |
|
| 155 | - |
|
| 156 | - /** |
|
| 157 | - * ajax process registration step |
|
| 158 | - * |
|
| 159 | - * @throws \EE_Error |
|
| 160 | - */ |
|
| 161 | - public static function process_reg_step() |
|
| 162 | - { |
|
| 163 | - EED_Single_Page_Checkout::process_ajax_request('process_reg_step'); |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - |
|
| 167 | - |
|
| 168 | - /** |
|
| 169 | - * ajax process registration step |
|
| 170 | - * |
|
| 171 | - * @throws \EE_Error |
|
| 172 | - */ |
|
| 173 | - public static function update_reg_step() |
|
| 174 | - { |
|
| 175 | - EED_Single_Page_Checkout::process_ajax_request('update_reg_step'); |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - |
|
| 179 | - |
|
| 180 | - /** |
|
| 181 | - * update_checkout |
|
| 182 | - * |
|
| 183 | - * @access public |
|
| 184 | - * @return void |
|
| 185 | - * @throws \EE_Error |
|
| 186 | - */ |
|
| 187 | - public static function update_checkout() |
|
| 188 | - { |
|
| 189 | - EED_Single_Page_Checkout::process_ajax_request('update_checkout'); |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - |
|
| 193 | - |
|
| 194 | - /** |
|
| 195 | - * load_request_handler |
|
| 196 | - * |
|
| 197 | - * @access public |
|
| 198 | - * @return void |
|
| 199 | - */ |
|
| 200 | - public static function load_request_handler() |
|
| 201 | - { |
|
| 202 | - // load core Request_Handler class |
|
| 203 | - if ( ! isset(EE_Registry::instance()->REQ)) { |
|
| 204 | - EE_Registry::instance()->load_core('Request_Handler'); |
|
| 205 | - } |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - |
|
| 209 | - |
|
| 210 | - /** |
|
| 211 | - * set_definitions |
|
| 212 | - * |
|
| 213 | - * @access public |
|
| 214 | - * @return void |
|
| 215 | - * @throws \EE_Error |
|
| 216 | - */ |
|
| 217 | - public static function set_definitions() |
|
| 218 | - { |
|
| 219 | - define('SPCO_BASE_PATH', rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS) . DS); |
|
| 220 | - define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css' . DS); |
|
| 221 | - define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img' . DS); |
|
| 222 | - define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js' . DS); |
|
| 223 | - define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS); |
|
| 224 | - define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS); |
|
| 225 | - define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS); |
|
| 226 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true); |
|
| 227 | - EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf( |
|
| 228 | - __('%1$sWe\'re sorry, but you\'re registration time has expired.%2$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s', |
|
| 229 | - 'event_espresso'), |
|
| 230 | - '<h4 class="important-notice">', |
|
| 231 | - '</h4>', |
|
| 232 | - '<br />', |
|
| 233 | - '<p>', |
|
| 234 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" title="', |
|
| 235 | - '">', |
|
| 236 | - '</a>', |
|
| 237 | - '</p>' |
|
| 238 | - ); |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - |
|
| 242 | - |
|
| 243 | - /** |
|
| 244 | - * load_reg_steps |
|
| 245 | - * loads and instantiates each reg step based on the EE_Registry::instance()->CFG->registration->reg_steps array |
|
| 246 | - * |
|
| 247 | - * @access private |
|
| 248 | - * @throws EE_Error |
|
| 249 | - * @return void |
|
| 250 | - */ |
|
| 251 | - public static function load_reg_steps() |
|
| 252 | - { |
|
| 253 | - static $reg_steps_loaded = false; |
|
| 254 | - if ($reg_steps_loaded) { |
|
| 255 | - return; |
|
| 256 | - } |
|
| 257 | - // filter list of reg_steps |
|
| 258 | - $reg_steps_to_load = (array)apply_filters( |
|
| 259 | - 'AHEE__SPCO__load_reg_steps__reg_steps_to_load', |
|
| 260 | - EED_Single_Page_Checkout::get_reg_steps() |
|
| 261 | - ); |
|
| 262 | - // sort by key (order) |
|
| 263 | - ksort($reg_steps_to_load); |
|
| 264 | - // loop through folders |
|
| 265 | - foreach ($reg_steps_to_load as $order => $reg_step) { |
|
| 266 | - // we need a |
|
| 267 | - if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
| 268 | - // copy over to the reg_steps_array |
|
| 269 | - EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step; |
|
| 270 | - // register custom key route for each reg step |
|
| 271 | - // ie: step=>"slug" - this is the entire reason we load the reg steps array now |
|
| 272 | - EE_Config::register_route($reg_step['slug'], 'EED_Single_Page_Checkout', 'run', 'step'); |
|
| 273 | - // add AJAX or other hooks |
|
| 274 | - if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) { |
|
| 275 | - // setup autoloaders if necessary |
|
| 276 | - if ( ! class_exists($reg_step['class_name'])) { |
|
| 277 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder($reg_step['file_path'], true); |
|
| 278 | - } |
|
| 279 | - if (is_callable($reg_step['class_name'], 'set_hooks')) { |
|
| 280 | - call_user_func(array($reg_step['class_name'], 'set_hooks')); |
|
| 281 | - } |
|
| 282 | - } |
|
| 283 | - } |
|
| 284 | - } |
|
| 285 | - $reg_steps_loaded = true; |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - |
|
| 289 | - |
|
| 290 | - /** |
|
| 291 | - * get_reg_steps |
|
| 292 | - * |
|
| 293 | - * @access public |
|
| 294 | - * @return array |
|
| 295 | - */ |
|
| 296 | - public static function get_reg_steps() |
|
| 297 | - { |
|
| 298 | - $reg_steps = EE_Registry::instance()->CFG->registration->reg_steps; |
|
| 299 | - if (empty($reg_steps)) { |
|
| 300 | - $reg_steps = array( |
|
| 301 | - 10 => array( |
|
| 302 | - 'file_path' => SPCO_REG_STEPS_PATH . 'attendee_information', |
|
| 303 | - 'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information', |
|
| 304 | - 'slug' => 'attendee_information', |
|
| 305 | - 'has_hooks' => false, |
|
| 306 | - ), |
|
| 307 | - 20 => array( |
|
| 308 | - 'file_path' => SPCO_REG_STEPS_PATH . 'registration_confirmation', |
|
| 309 | - 'class_name' => 'EE_SPCO_Reg_Step_Registration_Confirmation', |
|
| 310 | - 'slug' => 'registration_confirmation', |
|
| 311 | - 'has_hooks' => false, |
|
| 312 | - ), |
|
| 313 | - 30 => array( |
|
| 314 | - 'file_path' => SPCO_REG_STEPS_PATH . 'payment_options', |
|
| 315 | - 'class_name' => 'EE_SPCO_Reg_Step_Payment_Options', |
|
| 316 | - 'slug' => 'payment_options', |
|
| 317 | - 'has_hooks' => true, |
|
| 318 | - ), |
|
| 319 | - 999 => array( |
|
| 320 | - 'file_path' => SPCO_REG_STEPS_PATH . 'finalize_registration', |
|
| 321 | - 'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration', |
|
| 322 | - 'slug' => 'finalize_registration', |
|
| 323 | - 'has_hooks' => false, |
|
| 324 | - ), |
|
| 325 | - ); |
|
| 326 | - } |
|
| 327 | - return $reg_steps; |
|
| 328 | - } |
|
| 329 | - |
|
| 330 | - |
|
| 331 | - |
|
| 332 | - /** |
|
| 333 | - * registration_checkout_for_admin |
|
| 334 | - * |
|
| 335 | - * @access public |
|
| 336 | - * @return string |
|
| 337 | - * @throws \EE_Error |
|
| 338 | - */ |
|
| 339 | - public static function registration_checkout_for_admin() |
|
| 340 | - { |
|
| 341 | - EED_Single_Page_Checkout::load_reg_steps(); |
|
| 342 | - EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
| 343 | - EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step'); |
|
| 344 | - EE_Registry::instance()->REQ->set('process_form_submission', false); |
|
| 345 | - EED_Single_Page_Checkout::instance()->_initialize(); |
|
| 346 | - EED_Single_Page_Checkout::instance()->_display_spco_reg_form(); |
|
| 347 | - return EE_Registry::instance()->REQ->get_output(); |
|
| 348 | - } |
|
| 349 | - |
|
| 350 | - |
|
| 351 | - |
|
| 352 | - /** |
|
| 353 | - * process_registration_from_admin |
|
| 354 | - * |
|
| 355 | - * @access public |
|
| 356 | - * @return \EE_Transaction |
|
| 357 | - * @throws \EE_Error |
|
| 358 | - */ |
|
| 359 | - public static function process_registration_from_admin() |
|
| 360 | - { |
|
| 361 | - EED_Single_Page_Checkout::load_reg_steps(); |
|
| 362 | - EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
| 363 | - EE_Registry::instance()->REQ->set('action', 'process_reg_step'); |
|
| 364 | - EE_Registry::instance()->REQ->set('process_form_submission', true); |
|
| 365 | - EED_Single_Page_Checkout::instance()->_initialize(); |
|
| 366 | - if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) { |
|
| 367 | - $final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps); |
|
| 368 | - if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) { |
|
| 369 | - EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step); |
|
| 370 | - if ($final_reg_step->process_reg_step()) { |
|
| 371 | - $final_reg_step->set_completed(); |
|
| 372 | - EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array(); |
|
| 373 | - return EED_Single_Page_Checkout::instance()->checkout->transaction; |
|
| 374 | - } |
|
| 375 | - } |
|
| 376 | - } |
|
| 377 | - return null; |
|
| 378 | - } |
|
| 379 | - |
|
| 380 | - |
|
| 381 | - |
|
| 382 | - /** |
|
| 383 | - * run |
|
| 384 | - * |
|
| 385 | - * @access public |
|
| 386 | - * @param WP_Query $WP_Query |
|
| 387 | - * @return void |
|
| 388 | - * @throws \EE_Error |
|
| 389 | - */ |
|
| 390 | - public function run($WP_Query) |
|
| 391 | - { |
|
| 392 | - if ( |
|
| 393 | - $WP_Query instanceof WP_Query |
|
| 394 | - && $WP_Query->is_main_query() |
|
| 395 | - && apply_filters('FHEE__EED_Single_Page_Checkout__run', true) |
|
| 396 | - && $this->_is_reg_checkout() |
|
| 397 | - ) { |
|
| 398 | - $this->_initialize(); |
|
| 399 | - } |
|
| 400 | - } |
|
| 401 | - |
|
| 402 | - |
|
| 403 | - |
|
| 404 | - /** |
|
| 405 | - * determines whether current url matches reg page url |
|
| 406 | - * |
|
| 407 | - * @return bool |
|
| 408 | - */ |
|
| 409 | - protected function _is_reg_checkout() |
|
| 410 | - { |
|
| 411 | - // get current permalink for reg page without any extra query args |
|
| 412 | - $reg_page_url = \get_permalink(EE_Config::instance()->core->reg_page_id); |
|
| 413 | - // get request URI for current request, but without the scheme or host |
|
| 414 | - $current_request_uri = \EEH_URL::filter_input_server_url('REQUEST_URI'); |
|
| 415 | - $current_request_uri = html_entity_decode($current_request_uri); |
|
| 416 | - // get array of query args from the current request URI |
|
| 417 | - $query_args = \EEH_URL::get_query_string($current_request_uri); |
|
| 418 | - // grab page id if it is set |
|
| 419 | - $page_id = isset($query_args['page_id']) ? absint($query_args['page_id']) : 0; |
|
| 420 | - // and remove the page id from the query args (we will re-add it later) |
|
| 421 | - unset($query_args['page_id']); |
|
| 422 | - // now strip all query args from current request URI |
|
| 423 | - $current_request_uri = remove_query_arg(array_flip($query_args), $current_request_uri); |
|
| 424 | - // and re-add the page id if it was set |
|
| 425 | - if ($page_id) { |
|
| 426 | - $current_request_uri = add_query_arg('page_id', $page_id, $current_request_uri); |
|
| 427 | - } |
|
| 428 | - // remove slashes and ? |
|
| 429 | - $current_request_uri = trim($current_request_uri, '?/'); |
|
| 430 | - // is current request URI part of the known full reg page URL ? |
|
| 431 | - return ! empty($current_request_uri) && strpos($reg_page_url, $current_request_uri) !== false; |
|
| 432 | - } |
|
| 433 | - |
|
| 434 | - |
|
| 435 | - |
|
| 436 | - /** |
|
| 437 | - * run |
|
| 438 | - * |
|
| 439 | - * @access public |
|
| 440 | - * @param WP_Query $WP_Query |
|
| 441 | - * @return void |
|
| 442 | - * @throws \EE_Error |
|
| 443 | - */ |
|
| 444 | - public static function init($WP_Query) |
|
| 445 | - { |
|
| 446 | - EED_Single_Page_Checkout::instance()->run($WP_Query); |
|
| 447 | - } |
|
| 448 | - |
|
| 449 | - |
|
| 450 | - |
|
| 451 | - /** |
|
| 452 | - * _initialize - initial module setup |
|
| 453 | - * |
|
| 454 | - * @access private |
|
| 455 | - * @throws EE_Error |
|
| 456 | - * @return void |
|
| 457 | - */ |
|
| 458 | - private function _initialize() |
|
| 459 | - { |
|
| 460 | - // ensure SPCO doesn't run twice |
|
| 461 | - if (EED_Single_Page_Checkout::$_initialized) { |
|
| 462 | - return; |
|
| 463 | - } |
|
| 464 | - try { |
|
| 465 | - $this->_verify_session(); |
|
| 466 | - // setup the EE_Checkout object |
|
| 467 | - $this->checkout = $this->_initialize_checkout(); |
|
| 468 | - // filter checkout |
|
| 469 | - $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout); |
|
| 470 | - // get the $_GET |
|
| 471 | - $this->_get_request_vars(); |
|
| 472 | - if ($this->_block_bots()) { |
|
| 473 | - return; |
|
| 474 | - } |
|
| 475 | - // filter continue_reg |
|
| 476 | - $this->checkout->continue_reg = apply_filters('FHEE__EED_Single_Page_Checkout__init___continue_reg', true, $this->checkout); |
|
| 477 | - // load the reg steps array |
|
| 478 | - if ( ! $this->_load_and_instantiate_reg_steps()) { |
|
| 479 | - EED_Single_Page_Checkout::$_initialized = true; |
|
| 480 | - return; |
|
| 481 | - } |
|
| 482 | - // set the current step |
|
| 483 | - $this->checkout->set_current_step($this->checkout->step); |
|
| 484 | - // and the next step |
|
| 485 | - $this->checkout->set_next_step(); |
|
| 486 | - // verify that everything has been setup correctly |
|
| 487 | - if ( ! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) { |
|
| 488 | - EED_Single_Page_Checkout::$_initialized = true; |
|
| 489 | - return; |
|
| 490 | - } |
|
| 491 | - // lock the transaction |
|
| 492 | - $this->checkout->transaction->lock(); |
|
| 493 | - // make sure all of our cached objects are added to their respective model entity mappers |
|
| 494 | - $this->checkout->refresh_all_entities(); |
|
| 495 | - // set amount owing |
|
| 496 | - $this->checkout->amount_owing = $this->checkout->transaction->remaining(); |
|
| 497 | - // initialize each reg step, which gives them the chance to potentially alter the process |
|
| 498 | - $this->_initialize_reg_steps(); |
|
| 499 | - // DEBUG LOG |
|
| 500 | - //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
|
| 501 | - // get reg form |
|
| 502 | - if( ! $this->_check_form_submission()) { |
|
| 503 | - EED_Single_Page_Checkout::$_initialized = true; |
|
| 504 | - return; |
|
| 505 | - } |
|
| 506 | - // checkout the action!!! |
|
| 507 | - $this->_process_form_action(); |
|
| 508 | - // add some style and make it dance |
|
| 509 | - $this->add_styles_and_scripts(); |
|
| 510 | - // kk... SPCO has successfully run |
|
| 511 | - EED_Single_Page_Checkout::$_initialized = true; |
|
| 512 | - // set no cache headers and constants |
|
| 513 | - EE_System::do_not_cache(); |
|
| 514 | - // add anchor |
|
| 515 | - add_action('loop_start', array($this, 'set_checkout_anchor'), 1); |
|
| 516 | - // remove transaction lock |
|
| 517 | - add_action('shutdown', array($this, 'unlock_transaction'), 1); |
|
| 518 | - } catch (Exception $e) { |
|
| 519 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
| 520 | - } |
|
| 521 | - } |
|
| 522 | - |
|
| 523 | - |
|
| 524 | - |
|
| 525 | - /** |
|
| 526 | - * _verify_session |
|
| 527 | - * checks that the session is valid and not expired |
|
| 528 | - * |
|
| 529 | - * @access private |
|
| 530 | - * @throws EE_Error |
|
| 531 | - */ |
|
| 532 | - private function _verify_session() |
|
| 533 | - { |
|
| 534 | - if ( ! EE_Registry::instance()->SSN instanceof EE_Session) { |
|
| 535 | - throw new EE_Error(__('The EE_Session class could not be loaded.', 'event_espresso')); |
|
| 536 | - } |
|
| 537 | - // is session still valid ? |
|
| 538 | - if (EE_Registry::instance()->SSN->expired() && EE_Registry::instance()->REQ->get('e_reg_url_link', '') === '') { |
|
| 539 | - $this->checkout = new EE_Checkout(); |
|
| 540 | - EE_Registry::instance()->SSN->reset_cart(); |
|
| 541 | - EE_Registry::instance()->SSN->reset_checkout(); |
|
| 542 | - EE_Registry::instance()->SSN->reset_transaction(); |
|
| 543 | - EE_Error::add_attention(EE_Registry::$i18n_js_strings['registration_expiration_notice'], __FILE__, |
|
| 544 | - __FUNCTION__, __LINE__); |
|
| 545 | - EE_Registry::instance()->SSN->reset_expired(); |
|
| 546 | - } |
|
| 547 | - } |
|
| 548 | - |
|
| 549 | - |
|
| 550 | - |
|
| 551 | - /** |
|
| 552 | - * _initialize_checkout |
|
| 553 | - * loads and instantiates EE_Checkout |
|
| 554 | - * |
|
| 555 | - * @access private |
|
| 556 | - * @throws EE_Error |
|
| 557 | - * @return EE_Checkout |
|
| 558 | - */ |
|
| 559 | - private function _initialize_checkout() |
|
| 560 | - { |
|
| 561 | - // look in session for existing checkout |
|
| 562 | - /** @type EE_Checkout $checkout */ |
|
| 563 | - $checkout = EE_Registry::instance()->SSN->checkout(); |
|
| 564 | - // verify |
|
| 565 | - if ( ! $checkout instanceof EE_Checkout) { |
|
| 566 | - // instantiate EE_Checkout object for handling the properties of the current checkout process |
|
| 567 | - $checkout = EE_Registry::instance()->load_file(SPCO_INC_PATH, 'EE_Checkout', 'class', array(), false); |
|
| 568 | - } else { |
|
| 569 | - if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) { |
|
| 570 | - $this->unlock_transaction(); |
|
| 571 | - wp_safe_redirect($checkout->redirect_url); |
|
| 572 | - exit(); |
|
| 573 | - } |
|
| 574 | - } |
|
| 575 | - $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout); |
|
| 576 | - // verify again |
|
| 577 | - if ( ! $checkout instanceof EE_Checkout) { |
|
| 578 | - throw new EE_Error(__('The EE_Checkout class could not be loaded.', 'event_espresso')); |
|
| 579 | - } |
|
| 580 | - // reset anything that needs a clean slate for each request |
|
| 581 | - $checkout->reset_for_current_request(); |
|
| 582 | - return $checkout; |
|
| 583 | - } |
|
| 584 | - |
|
| 585 | - |
|
| 586 | - |
|
| 587 | - /** |
|
| 588 | - * _get_request_vars |
|
| 589 | - * |
|
| 590 | - * @access private |
|
| 591 | - * @return void |
|
| 592 | - * @throws \EE_Error |
|
| 593 | - */ |
|
| 594 | - private function _get_request_vars() |
|
| 595 | - { |
|
| 596 | - // load classes |
|
| 597 | - EED_Single_Page_Checkout::load_request_handler(); |
|
| 598 | - //make sure this request is marked as belonging to EE |
|
| 599 | - EE_Registry::instance()->REQ->set_espresso_page(true); |
|
| 600 | - // which step is being requested ? |
|
| 601 | - $this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step()); |
|
| 602 | - // which step is being edited ? |
|
| 603 | - $this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', ''); |
|
| 604 | - // and what we're doing on the current step |
|
| 605 | - $this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step'); |
|
| 606 | - // timestamp |
|
| 607 | - $this->checkout->uts = EE_Registry::instance()->REQ->get('uts', 0); |
|
| 608 | - // returning to edit ? |
|
| 609 | - $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', ''); |
|
| 610 | - // or some other kind of revisit ? |
|
| 611 | - $this->checkout->revisit = filter_var( |
|
| 612 | - EE_Registry::instance()->REQ->get('revisit', false), |
|
| 613 | - FILTER_VALIDATE_BOOLEAN |
|
| 614 | - ); |
|
| 615 | - // and whether or not to generate a reg form for this request |
|
| 616 | - $this->checkout->generate_reg_form = filter_var( |
|
| 617 | - EE_Registry::instance()->REQ->get('generate_reg_form', true), |
|
| 618 | - FILTER_VALIDATE_BOOLEAN |
|
| 619 | - ); |
|
| 620 | - // and whether or not to process a reg form submission for this request |
|
| 621 | - $this->checkout->process_form_submission = filter_var( |
|
| 622 | - EE_Registry::instance()->REQ->get( |
|
| 623 | - 'process_form_submission', |
|
| 624 | - $this->checkout->action === 'process_reg_step' |
|
| 625 | - ), |
|
| 626 | - FILTER_VALIDATE_BOOLEAN |
|
| 627 | - ); |
|
| 628 | - $this->checkout->process_form_submission = filter_var( |
|
| 629 | - $this->checkout->action !== 'display_spco_reg_step' |
|
| 630 | - ? $this->checkout->process_form_submission |
|
| 631 | - : false, |
|
| 632 | - FILTER_VALIDATE_BOOLEAN |
|
| 633 | - ); |
|
| 634 | - // $this->_display_request_vars(); |
|
| 635 | - } |
|
| 636 | - |
|
| 637 | - |
|
| 638 | - |
|
| 639 | - /** |
|
| 640 | - * _display_request_vars |
|
| 641 | - * |
|
| 642 | - * @access protected |
|
| 643 | - * @return void |
|
| 644 | - */ |
|
| 645 | - protected function _display_request_vars() |
|
| 646 | - { |
|
| 647 | - if ( ! WP_DEBUG) { |
|
| 648 | - return; |
|
| 649 | - } |
|
| 650 | - EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__); |
|
| 651 | - EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__); |
|
| 652 | - EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__); |
|
| 653 | - EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__); |
|
| 654 | - EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__); |
|
| 655 | - EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__); |
|
| 656 | - EEH_Debug_Tools::printr($this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__); |
|
| 657 | - EEH_Debug_Tools::printr($this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__); |
|
| 658 | - } |
|
| 659 | - |
|
| 660 | - |
|
| 661 | - |
|
| 662 | - /** |
|
| 663 | - * _block_bots |
|
| 664 | - * checks that the incoming request has either of the following set: |
|
| 665 | - * a uts (unix timestamp) which indicates that the request was redirected from the Ticket Selector |
|
| 666 | - * a REG URL Link, which indicates that the request is a return visit to SPCO for a valid TXN |
|
| 667 | - * so if you're not coming from the Ticket Selector nor returning for a valid IP... |
|
| 668 | - * then where you coming from man? |
|
| 669 | - * |
|
| 670 | - * @return boolean |
|
| 671 | - */ |
|
| 672 | - private function _block_bots() |
|
| 673 | - { |
|
| 674 | - $invalid_checkout_access = \EED_Invalid_Checkout_Access::getInvalidCheckoutAccess(); |
|
| 675 | - if ($invalid_checkout_access->checkoutAccessIsInvalid($this->checkout)) { |
|
| 676 | - return true; |
|
| 677 | - } |
|
| 678 | - return false; |
|
| 679 | - } |
|
| 680 | - |
|
| 681 | - |
|
| 682 | - |
|
| 683 | - /** |
|
| 684 | - * _get_first_step |
|
| 685 | - * gets slug for first step in $_reg_steps_array |
|
| 686 | - * |
|
| 687 | - * @access private |
|
| 688 | - * @throws EE_Error |
|
| 689 | - * @return string |
|
| 690 | - */ |
|
| 691 | - private function _get_first_step() |
|
| 692 | - { |
|
| 693 | - $first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array); |
|
| 694 | - return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information'; |
|
| 695 | - } |
|
| 696 | - |
|
| 697 | - |
|
| 698 | - |
|
| 699 | - /** |
|
| 700 | - * _load_and_instantiate_reg_steps |
|
| 701 | - * instantiates each reg step based on the loaded reg_steps array |
|
| 702 | - * |
|
| 703 | - * @access private |
|
| 704 | - * @throws EE_Error |
|
| 705 | - * @return bool |
|
| 706 | - */ |
|
| 707 | - private function _load_and_instantiate_reg_steps() |
|
| 708 | - { |
|
| 709 | - // have reg_steps already been instantiated ? |
|
| 710 | - if ( |
|
| 711 | - empty($this->checkout->reg_steps) |
|
| 712 | - || apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout) |
|
| 713 | - ) { |
|
| 714 | - // if not, then loop through raw reg steps array |
|
| 715 | - foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) { |
|
| 716 | - if ( ! $this->_load_and_instantiate_reg_step($reg_step, $order)) { |
|
| 717 | - return false; |
|
| 718 | - } |
|
| 719 | - } |
|
| 720 | - EE_Registry::instance()->CFG->registration->skip_reg_confirmation = true; |
|
| 721 | - EE_Registry::instance()->CFG->registration->reg_confirmation_last = true; |
|
| 722 | - // skip the registration_confirmation page ? |
|
| 723 | - if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) { |
|
| 724 | - // just remove it from the reg steps array |
|
| 725 | - $this->checkout->remove_reg_step('registration_confirmation', false); |
|
| 726 | - } else if ( |
|
| 727 | - isset($this->checkout->reg_steps['registration_confirmation']) |
|
| 728 | - && EE_Registry::instance()->CFG->registration->reg_confirmation_last |
|
| 729 | - ) { |
|
| 730 | - // set the order to something big like 100 |
|
| 731 | - $this->checkout->set_reg_step_order('registration_confirmation', 100); |
|
| 732 | - } |
|
| 733 | - // filter the array for good luck |
|
| 734 | - $this->checkout->reg_steps = apply_filters( |
|
| 735 | - 'FHEE__Single_Page_Checkout__load_reg_steps__reg_steps', |
|
| 736 | - $this->checkout->reg_steps |
|
| 737 | - ); |
|
| 738 | - // finally re-sort based on the reg step class order properties |
|
| 739 | - $this->checkout->sort_reg_steps(); |
|
| 740 | - } else { |
|
| 741 | - foreach ($this->checkout->reg_steps as $reg_step) { |
|
| 742 | - // set all current step stati to FALSE |
|
| 743 | - $reg_step->set_is_current_step(false); |
|
| 744 | - } |
|
| 745 | - } |
|
| 746 | - if (empty($this->checkout->reg_steps)) { |
|
| 747 | - EE_Error::add_error(__('No Reg Steps were loaded..', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 748 | - return false; |
|
| 749 | - } |
|
| 750 | - // make reg step details available to JS |
|
| 751 | - $this->checkout->set_reg_step_JSON_info(); |
|
| 752 | - return true; |
|
| 753 | - } |
|
| 754 | - |
|
| 755 | - |
|
| 756 | - |
|
| 757 | - /** |
|
| 758 | - * _load_and_instantiate_reg_step |
|
| 759 | - * |
|
| 760 | - * @access private |
|
| 761 | - * @param array $reg_step |
|
| 762 | - * @param int $order |
|
| 763 | - * @return bool |
|
| 764 | - */ |
|
| 765 | - private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0) |
|
| 766 | - { |
|
| 767 | - // we need a file_path, class_name, and slug to add a reg step |
|
| 768 | - if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
| 769 | - // if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step) |
|
| 770 | - if ( |
|
| 771 | - $this->checkout->reg_url_link |
|
| 772 | - && $this->checkout->step !== $reg_step['slug'] |
|
| 773 | - && $reg_step['slug'] !== 'finalize_registration' |
|
| 774 | - ) { |
|
| 775 | - return true; |
|
| 776 | - } |
|
| 777 | - // instantiate step class using file path and class name |
|
| 778 | - $reg_step_obj = EE_Registry::instance()->load_file( |
|
| 779 | - $reg_step['file_path'], |
|
| 780 | - $reg_step['class_name'], |
|
| 781 | - 'class', |
|
| 782 | - $this->checkout, |
|
| 783 | - false |
|
| 784 | - ); |
|
| 785 | - // did we gets the goods ? |
|
| 786 | - if ($reg_step_obj instanceof EE_SPCO_Reg_Step) { |
|
| 787 | - // set reg step order based on config |
|
| 788 | - $reg_step_obj->set_order($order); |
|
| 789 | - // add instantiated reg step object to the master reg steps array |
|
| 790 | - $this->checkout->add_reg_step($reg_step_obj); |
|
| 791 | - } else { |
|
| 792 | - EE_Error::add_error( |
|
| 793 | - __('The current step could not be set.', 'event_espresso'), |
|
| 794 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 795 | - ); |
|
| 796 | - return false; |
|
| 797 | - } |
|
| 798 | - } else { |
|
| 799 | - if (WP_DEBUG) { |
|
| 800 | - EE_Error::add_error( |
|
| 801 | - sprintf( |
|
| 802 | - __('A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', 'event_espresso'), |
|
| 803 | - isset($reg_step['file_path']) ? $reg_step['file_path'] : '', |
|
| 804 | - isset($reg_step['class_name']) ? $reg_step['class_name'] : '', |
|
| 805 | - isset($reg_step['slug']) ? $reg_step['slug'] : '', |
|
| 806 | - '<ul>', |
|
| 807 | - '<li>', |
|
| 808 | - '</li>', |
|
| 809 | - '</ul>' |
|
| 810 | - ), |
|
| 811 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 812 | - ); |
|
| 813 | - } |
|
| 814 | - return false; |
|
| 815 | - } |
|
| 816 | - return true; |
|
| 817 | - } |
|
| 818 | - |
|
| 819 | - |
|
| 820 | - |
|
| 821 | - /** |
|
| 822 | - * _verify_transaction_and_get_registrations |
|
| 823 | - * |
|
| 824 | - * @access private |
|
| 825 | - * @return bool |
|
| 826 | - */ |
|
| 827 | - private function _verify_transaction_and_get_registrations() |
|
| 828 | - { |
|
| 829 | - // was there already a valid transaction in the checkout from the session ? |
|
| 830 | - if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
| 831 | - // get transaction from db or session |
|
| 832 | - $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin() |
|
| 833 | - ? $this->_get_transaction_and_cart_for_previous_visit() |
|
| 834 | - : $this->_get_cart_for_current_session_and_setup_new_transaction(); |
|
| 835 | - if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
| 836 | - EE_Error::add_error( |
|
| 837 | - __('Your Registration and Transaction information could not be retrieved from the db.', |
|
| 838 | - 'event_espresso'), |
|
| 839 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 840 | - ); |
|
| 841 | - $this->checkout->transaction = EE_Transaction::new_instance(); |
|
| 842 | - // add some style and make it dance |
|
| 843 | - $this->add_styles_and_scripts(); |
|
| 844 | - EED_Single_Page_Checkout::$_initialized = true; |
|
| 845 | - return false; |
|
| 846 | - } |
|
| 847 | - // and the registrations for the transaction |
|
| 848 | - $this->_get_registrations($this->checkout->transaction); |
|
| 849 | - } |
|
| 850 | - return true; |
|
| 851 | - } |
|
| 852 | - |
|
| 853 | - |
|
| 854 | - |
|
| 855 | - /** |
|
| 856 | - * _get_transaction_and_cart_for_previous_visit |
|
| 857 | - * |
|
| 858 | - * @access private |
|
| 859 | - * @return mixed EE_Transaction|NULL |
|
| 860 | - */ |
|
| 861 | - private function _get_transaction_and_cart_for_previous_visit() |
|
| 862 | - { |
|
| 863 | - /** @var $TXN_model EEM_Transaction */ |
|
| 864 | - $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
|
| 865 | - // because the reg_url_link is present in the request, this is a return visit to SPCO, so we'll get the transaction data from the db |
|
| 866 | - $transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link); |
|
| 867 | - // verify transaction |
|
| 868 | - if ($transaction instanceof EE_Transaction) { |
|
| 869 | - // and get the cart that was used for that transaction |
|
| 870 | - $this->checkout->cart = $this->_get_cart_for_transaction($transaction); |
|
| 871 | - return $transaction; |
|
| 872 | - } else { |
|
| 873 | - EE_Error::add_error(__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 874 | - return null; |
|
| 875 | - } |
|
| 876 | - } |
|
| 877 | - |
|
| 878 | - |
|
| 879 | - |
|
| 880 | - /** |
|
| 881 | - * _get_cart_for_transaction |
|
| 882 | - * |
|
| 883 | - * @access private |
|
| 884 | - * @param EE_Transaction $transaction |
|
| 885 | - * @return EE_Cart |
|
| 886 | - */ |
|
| 887 | - private function _get_cart_for_transaction($transaction) |
|
| 888 | - { |
|
| 889 | - return $this->checkout->get_cart_for_transaction($transaction); |
|
| 890 | - } |
|
| 891 | - |
|
| 892 | - |
|
| 893 | - |
|
| 894 | - /** |
|
| 895 | - * get_cart_for_transaction |
|
| 896 | - * |
|
| 897 | - * @access public |
|
| 898 | - * @param EE_Transaction $transaction |
|
| 899 | - * @return EE_Cart |
|
| 900 | - */ |
|
| 901 | - public function get_cart_for_transaction(EE_Transaction $transaction) |
|
| 902 | - { |
|
| 903 | - return $this->checkout->get_cart_for_transaction($transaction); |
|
| 904 | - } |
|
| 905 | - |
|
| 906 | - |
|
| 907 | - |
|
| 908 | - /** |
|
| 909 | - * _get_transaction_and_cart_for_current_session |
|
| 910 | - * generates a new EE_Transaction object and adds it to the $_transaction property. |
|
| 911 | - * |
|
| 912 | - * @access private |
|
| 913 | - * @return EE_Transaction |
|
| 914 | - * @throws \EE_Error |
|
| 915 | - */ |
|
| 916 | - private function _get_cart_for_current_session_and_setup_new_transaction() |
|
| 917 | - { |
|
| 918 | - // if there's no transaction, then this is the FIRST visit to SPCO |
|
| 919 | - // so load up the cart ( passing nothing for the TXN because it doesn't exist yet ) |
|
| 920 | - $this->checkout->cart = $this->_get_cart_for_transaction(null); |
|
| 921 | - // and then create a new transaction |
|
| 922 | - $transaction = $this->_initialize_transaction(); |
|
| 923 | - // verify transaction |
|
| 924 | - if ($transaction instanceof EE_Transaction) { |
|
| 925 | - // save it so that we have an ID for other objects to use |
|
| 926 | - $transaction->save(); |
|
| 927 | - // and save TXN data to the cart |
|
| 928 | - $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID()); |
|
| 929 | - } else { |
|
| 930 | - EE_Error::add_error(__('A Valid Transaction could not be initialized.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 931 | - } |
|
| 932 | - return $transaction; |
|
| 933 | - } |
|
| 934 | - |
|
| 935 | - |
|
| 936 | - |
|
| 937 | - /** |
|
| 938 | - * generates a new EE_Transaction object and adds it to the $_transaction property. |
|
| 939 | - * |
|
| 940 | - * @access private |
|
| 941 | - * @return mixed EE_Transaction|NULL |
|
| 942 | - */ |
|
| 943 | - private function _initialize_transaction() |
|
| 944 | - { |
|
| 945 | - try { |
|
| 946 | - // ensure cart totals have been calculated |
|
| 947 | - $this->checkout->cart->get_grand_total()->recalculate_total_including_taxes(); |
|
| 948 | - // grab the cart grand total |
|
| 949 | - $cart_total = $this->checkout->cart->get_cart_grand_total(); |
|
| 950 | - // create new TXN |
|
| 951 | - $transaction = EE_Transaction::new_instance( |
|
| 952 | - array( |
|
| 953 | - 'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(), |
|
| 954 | - 'TXN_total' => $cart_total > 0 ? $cart_total : 0, |
|
| 955 | - 'TXN_paid' => 0, |
|
| 956 | - 'STS_ID' => EEM_Transaction::failed_status_code, |
|
| 957 | - ) |
|
| 958 | - ); |
|
| 959 | - // save it so that we have an ID for other objects to use |
|
| 960 | - $transaction->save(); |
|
| 961 | - // set cron job for following up on TXNs after their session has expired |
|
| 962 | - EE_Cron_Tasks::schedule_expired_transaction_check( |
|
| 963 | - EE_Registry::instance()->SSN->expiration() + 1, |
|
| 964 | - $transaction->ID() |
|
| 965 | - ); |
|
| 966 | - return $transaction; |
|
| 967 | - } catch (Exception $e) { |
|
| 968 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
| 969 | - } |
|
| 970 | - return null; |
|
| 971 | - } |
|
| 972 | - |
|
| 973 | - |
|
| 974 | - |
|
| 975 | - /** |
|
| 976 | - * _get_registrations |
|
| 977 | - * |
|
| 978 | - * @access private |
|
| 979 | - * @param EE_Transaction $transaction |
|
| 980 | - * @return void |
|
| 981 | - * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
| 982 | - * @throws \EE_Error |
|
| 983 | - */ |
|
| 984 | - private function _get_registrations(EE_Transaction $transaction) |
|
| 985 | - { |
|
| 986 | - // first step: grab the registrants { : o |
|
| 987 | - $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, true); |
|
| 988 | - // verify registrations have been set |
|
| 989 | - if (empty($registrations)) { |
|
| 990 | - // if no cached registrations, then check the db |
|
| 991 | - $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false); |
|
| 992 | - // still nothing ? well as long as this isn't a revisit |
|
| 993 | - if (empty($registrations) && ! $this->checkout->revisit) { |
|
| 994 | - // generate new registrations from scratch |
|
| 995 | - $registrations = $this->_initialize_registrations($transaction); |
|
| 996 | - } |
|
| 997 | - } |
|
| 998 | - // sort by their original registration order |
|
| 999 | - usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count')); |
|
| 1000 | - // then loop thru the array |
|
| 1001 | - foreach ($registrations as $registration) { |
|
| 1002 | - // verify each registration |
|
| 1003 | - if ($registration instanceof EE_Registration) { |
|
| 1004 | - // we display all attendee info for the primary registrant |
|
| 1005 | - if ($this->checkout->reg_url_link === $registration->reg_url_link() |
|
| 1006 | - && $registration->is_primary_registrant() |
|
| 1007 | - ) { |
|
| 1008 | - $this->checkout->primary_revisit = true; |
|
| 1009 | - break; |
|
| 1010 | - } else if ($this->checkout->revisit |
|
| 1011 | - && $this->checkout->reg_url_link !== $registration->reg_url_link() |
|
| 1012 | - ) { |
|
| 1013 | - // but hide info if it doesn't belong to you |
|
| 1014 | - $transaction->clear_cache('Registration', $registration->ID()); |
|
| 1015 | - } |
|
| 1016 | - $this->checkout->set_reg_status_updated($registration->ID(), false); |
|
| 1017 | - } |
|
| 1018 | - } |
|
| 1019 | - } |
|
| 1020 | - |
|
| 1021 | - |
|
| 1022 | - |
|
| 1023 | - /** |
|
| 1024 | - * adds related EE_Registration objects for each ticket in the cart to the current EE_Transaction object |
|
| 1025 | - * |
|
| 1026 | - * @access private |
|
| 1027 | - * @param EE_Transaction $transaction |
|
| 1028 | - * @return array |
|
| 1029 | - * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
| 1030 | - * @throws \EE_Error |
|
| 1031 | - */ |
|
| 1032 | - private function _initialize_registrations(EE_Transaction $transaction) |
|
| 1033 | - { |
|
| 1034 | - $att_nmbr = 0; |
|
| 1035 | - $registrations = array(); |
|
| 1036 | - if ($transaction instanceof EE_Transaction) { |
|
| 1037 | - /** @type EE_Registration_Processor $registration_processor */ |
|
| 1038 | - $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
| 1039 | - $this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count(); |
|
| 1040 | - // now let's add the cart items to the $transaction |
|
| 1041 | - foreach ($this->checkout->cart->get_tickets() as $line_item) { |
|
| 1042 | - //do the following for each ticket of this type they selected |
|
| 1043 | - for ($x = 1; $x <= $line_item->quantity(); $x++) { |
|
| 1044 | - $att_nmbr++; |
|
| 1045 | - /** @var EventEspresso\core\services\commands\registration\CreateRegistrationCommand $CreateRegistrationCommand */ |
|
| 1046 | - $CreateRegistrationCommand = EE_Registry::instance() |
|
| 1047 | - ->create( |
|
| 1048 | - 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
| 1049 | - array( |
|
| 1050 | - $transaction, |
|
| 1051 | - $line_item, |
|
| 1052 | - $att_nmbr, |
|
| 1053 | - $this->checkout->total_ticket_count, |
|
| 1054 | - ) |
|
| 1055 | - ); |
|
| 1056 | - // override capabilities for frontend registrations |
|
| 1057 | - if ( ! is_admin()) { |
|
| 1058 | - $CreateRegistrationCommand->setCapCheck( |
|
| 1059 | - new PublicCapabilities('', 'create_new_registration') |
|
| 1060 | - ); |
|
| 1061 | - } |
|
| 1062 | - $registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand); |
|
| 1063 | - if ( ! $registration instanceof EE_Registration) { |
|
| 1064 | - throw new InvalidEntityException($registration, 'EE_Registration'); |
|
| 1065 | - } |
|
| 1066 | - $registrations[ $registration->ID() ] = $registration; |
|
| 1067 | - } |
|
| 1068 | - } |
|
| 1069 | - $registration_processor->fix_reg_final_price_rounding_issue($transaction); |
|
| 1070 | - } |
|
| 1071 | - return $registrations; |
|
| 1072 | - } |
|
| 1073 | - |
|
| 1074 | - |
|
| 1075 | - |
|
| 1076 | - /** |
|
| 1077 | - * sorts registrations by REG_count |
|
| 1078 | - * |
|
| 1079 | - * @access public |
|
| 1080 | - * @param EE_Registration $reg_A |
|
| 1081 | - * @param EE_Registration $reg_B |
|
| 1082 | - * @return int |
|
| 1083 | - */ |
|
| 1084 | - public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B) |
|
| 1085 | - { |
|
| 1086 | - // this shouldn't ever happen within the same TXN, but oh well |
|
| 1087 | - if ($reg_A->count() === $reg_B->count()) { |
|
| 1088 | - return 0; |
|
| 1089 | - } |
|
| 1090 | - return ($reg_A->count() > $reg_B->count()) ? 1 : -1; |
|
| 1091 | - } |
|
| 1092 | - |
|
| 1093 | - |
|
| 1094 | - |
|
| 1095 | - /** |
|
| 1096 | - * _final_verifications |
|
| 1097 | - * just makes sure that everything is set up correctly before proceeding |
|
| 1098 | - * |
|
| 1099 | - * @access private |
|
| 1100 | - * @return bool |
|
| 1101 | - * @throws \EE_Error |
|
| 1102 | - */ |
|
| 1103 | - private function _final_verifications() |
|
| 1104 | - { |
|
| 1105 | - // filter checkout |
|
| 1106 | - $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___final_verifications__checkout', $this->checkout); |
|
| 1107 | - //verify that current step is still set correctly |
|
| 1108 | - if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) { |
|
| 1109 | - EE_Error::add_error( |
|
| 1110 | - __('We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', 'event_espresso'), |
|
| 1111 | - __FILE__, |
|
| 1112 | - __FUNCTION__, |
|
| 1113 | - __LINE__ |
|
| 1114 | - ); |
|
| 1115 | - return false; |
|
| 1116 | - } |
|
| 1117 | - // if returning to SPCO, then verify that primary registrant is set |
|
| 1118 | - if ( ! empty($this->checkout->reg_url_link)) { |
|
| 1119 | - $valid_registrant = $this->checkout->transaction->primary_registration(); |
|
| 1120 | - if ( ! $valid_registrant instanceof EE_Registration) { |
|
| 1121 | - EE_Error::add_error( |
|
| 1122 | - __('We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', 'event_espresso'), |
|
| 1123 | - __FILE__, |
|
| 1124 | - __FUNCTION__, |
|
| 1125 | - __LINE__ |
|
| 1126 | - ); |
|
| 1127 | - return false; |
|
| 1128 | - } |
|
| 1129 | - $valid_registrant = null; |
|
| 1130 | - foreach ($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration) { |
|
| 1131 | - if ( |
|
| 1132 | - $registration instanceof EE_Registration |
|
| 1133 | - && $registration->reg_url_link() === $this->checkout->reg_url_link |
|
| 1134 | - ) { |
|
| 1135 | - $valid_registrant = $registration; |
|
| 1136 | - } |
|
| 1137 | - } |
|
| 1138 | - if ( ! $valid_registrant instanceof EE_Registration) { |
|
| 1139 | - // hmmm... maybe we have the wrong session because the user is opening multiple tabs ? |
|
| 1140 | - if (EED_Single_Page_Checkout::$_checkout_verified) { |
|
| 1141 | - // clear the session, mark the checkout as unverified, and try again |
|
| 1142 | - EE_Registry::instance()->SSN->clear_session(); |
|
| 1143 | - EED_Single_Page_Checkout::$_initialized = false; |
|
| 1144 | - EED_Single_Page_Checkout::$_checkout_verified = false; |
|
| 1145 | - $this->_initialize(); |
|
| 1146 | - EE_Error::reset_notices(); |
|
| 1147 | - return false; |
|
| 1148 | - } |
|
| 1149 | - EE_Error::add_error( |
|
| 1150 | - __('We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.', 'event_espresso'), |
|
| 1151 | - __FILE__, |
|
| 1152 | - __FUNCTION__, |
|
| 1153 | - __LINE__ |
|
| 1154 | - ); |
|
| 1155 | - return false; |
|
| 1156 | - } |
|
| 1157 | - } |
|
| 1158 | - // now that things have been kinda sufficiently verified, |
|
| 1159 | - // let's add the checkout to the session so that's available other systems |
|
| 1160 | - EE_Registry::instance()->SSN->set_checkout($this->checkout); |
|
| 1161 | - return true; |
|
| 1162 | - } |
|
| 1163 | - |
|
| 1164 | - |
|
| 1165 | - |
|
| 1166 | - /** |
|
| 1167 | - * _initialize_reg_steps |
|
| 1168 | - * first makes sure that EE_Transaction_Processor::set_reg_step_initiated() is called as required |
|
| 1169 | - * then loops thru all of the active reg steps and calls the initialize_reg_step() method |
|
| 1170 | - * |
|
| 1171 | - * @access private |
|
| 1172 | - * @param bool $reinitializing |
|
| 1173 | - * @throws \EE_Error |
|
| 1174 | - */ |
|
| 1175 | - private function _initialize_reg_steps($reinitializing = false) |
|
| 1176 | - { |
|
| 1177 | - $this->checkout->set_reg_step_initiated($this->checkout->current_step); |
|
| 1178 | - // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS |
|
| 1179 | - foreach ($this->checkout->reg_steps as $reg_step) { |
|
| 1180 | - if ( ! $reg_step->initialize_reg_step()) { |
|
| 1181 | - // if not initialized then maybe this step is being removed... |
|
| 1182 | - if ( ! $reinitializing && $reg_step->is_current_step()) { |
|
| 1183 | - // if it was the current step, then we need to start over here |
|
| 1184 | - $this->_initialize_reg_steps(true); |
|
| 1185 | - return; |
|
| 1186 | - } |
|
| 1187 | - continue; |
|
| 1188 | - } |
|
| 1189 | - // add css and JS for current step |
|
| 1190 | - $reg_step->enqueue_styles_and_scripts(); |
|
| 1191 | - // i18n |
|
| 1192 | - $reg_step->translate_js_strings(); |
|
| 1193 | - if ($reg_step->is_current_step()) { |
|
| 1194 | - // the text that appears on the reg step form submit button |
|
| 1195 | - $reg_step->set_submit_button_text(); |
|
| 1196 | - } |
|
| 1197 | - } |
|
| 1198 | - // dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information |
|
| 1199 | - do_action("AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", $this->checkout->current_step); |
|
| 1200 | - } |
|
| 1201 | - |
|
| 1202 | - |
|
| 1203 | - |
|
| 1204 | - /** |
|
| 1205 | - * _check_form_submission |
|
| 1206 | - * |
|
| 1207 | - * @access private |
|
| 1208 | - * @return boolean |
|
| 1209 | - */ |
|
| 1210 | - private function _check_form_submission() |
|
| 1211 | - { |
|
| 1212 | - //does this request require the reg form to be generated ? |
|
| 1213 | - if ($this->checkout->generate_reg_form) { |
|
| 1214 | - // ever heard that song by Blue Rodeo ? |
|
| 1215 | - try { |
|
| 1216 | - $this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form(); |
|
| 1217 | - // if not displaying a form, then check for form submission |
|
| 1218 | - if ( |
|
| 1219 | - $this->checkout->process_form_submission |
|
| 1220 | - && $this->checkout->current_step->reg_form->was_submitted() |
|
| 1221 | - ) { |
|
| 1222 | - // clear out any old data in case this step is being run again |
|
| 1223 | - $this->checkout->current_step->set_valid_data(array()); |
|
| 1224 | - // capture submitted form data |
|
| 1225 | - $this->checkout->current_step->reg_form->receive_form_submission( |
|
| 1226 | - apply_filters('FHEE__Single_Page_Checkout___check_form_submission__request_params', EE_Registry::instance()->REQ->params(), $this->checkout) |
|
| 1227 | - ); |
|
| 1228 | - // validate submitted form data |
|
| 1229 | - if ( ! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) { |
|
| 1230 | - // thou shall not pass !!! |
|
| 1231 | - $this->checkout->continue_reg = false; |
|
| 1232 | - // any form validation errors? |
|
| 1233 | - if ($this->checkout->current_step->reg_form->submission_error_message() !== '') { |
|
| 1234 | - $submission_error_messages = array(); |
|
| 1235 | - // bad, bad, bad registrant |
|
| 1236 | - foreach ($this->checkout->current_step->reg_form->get_validation_errors_accumulated() as $validation_error) { |
|
| 1237 | - if ($validation_error instanceof EE_Validation_Error) { |
|
| 1238 | - $submission_error_messages[] = sprintf( |
|
| 1239 | - __('%s : %s', 'event_espresso'), |
|
| 1240 | - $validation_error->get_form_section()->html_label_text(), |
|
| 1241 | - $validation_error->getMessage() |
|
| 1242 | - ); |
|
| 1243 | - } |
|
| 1244 | - } |
|
| 1245 | - EE_Error::add_error(implode('<br />', $submission_error_messages), __FILE__, __FUNCTION__, __LINE__); |
|
| 1246 | - } |
|
| 1247 | - // well not really... what will happen is we'll just get redirected back to redo the current step |
|
| 1248 | - $this->go_to_next_step(); |
|
| 1249 | - return false; |
|
| 1250 | - } |
|
| 1251 | - } |
|
| 1252 | - } catch (EE_Error $e) { |
|
| 1253 | - $e->get_error(); |
|
| 1254 | - } |
|
| 1255 | - } |
|
| 1256 | - return true; |
|
| 1257 | - } |
|
| 1258 | - |
|
| 1259 | - |
|
| 1260 | - |
|
| 1261 | - /** |
|
| 1262 | - * _process_action |
|
| 1263 | - * |
|
| 1264 | - * @access private |
|
| 1265 | - * @return void |
|
| 1266 | - * @throws \EE_Error |
|
| 1267 | - */ |
|
| 1268 | - private function _process_form_action() |
|
| 1269 | - { |
|
| 1270 | - // what cha wanna do? |
|
| 1271 | - switch ($this->checkout->action) { |
|
| 1272 | - // AJAX next step reg form |
|
| 1273 | - case 'display_spco_reg_step' : |
|
| 1274 | - $this->checkout->redirect = false; |
|
| 1275 | - if (EE_Registry::instance()->REQ->ajax) { |
|
| 1276 | - $this->checkout->json_response->set_reg_step_html($this->checkout->current_step->display_reg_form()); |
|
| 1277 | - } |
|
| 1278 | - break; |
|
| 1279 | - default : |
|
| 1280 | - // meh... do one of those other steps first |
|
| 1281 | - if ( ! empty($this->checkout->action) && is_callable(array($this->checkout->current_step, $this->checkout->action))) { |
|
| 1282 | - // dynamically creates hook point like: AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step |
|
| 1283 | - do_action("AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step); |
|
| 1284 | - // call action on current step |
|
| 1285 | - if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) { |
|
| 1286 | - // good registrant, you get to proceed |
|
| 1287 | - if ( |
|
| 1288 | - $this->checkout->current_step->success_message() !== '' |
|
| 1289 | - && apply_filters( |
|
| 1290 | - 'FHEE__Single_Page_Checkout___process_form_action__display_success', |
|
| 1291 | - false |
|
| 1292 | - ) |
|
| 1293 | - ) { |
|
| 1294 | - EE_Error::add_success( |
|
| 1295 | - $this->checkout->current_step->success_message() |
|
| 1296 | - . '<br />' . $this->checkout->next_step->_instructions() |
|
| 1297 | - ); |
|
| 1298 | - } |
|
| 1299 | - // pack it up, pack it in... |
|
| 1300 | - $this->_setup_redirect(); |
|
| 1301 | - } |
|
| 1302 | - // dynamically creates hook point like: AHEE__Single_Page_Checkout__after_payment_options__process_reg_step |
|
| 1303 | - do_action("AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step); |
|
| 1304 | - } else { |
|
| 1305 | - EE_Error::add_error( |
|
| 1306 | - sprintf( |
|
| 1307 | - __('The requested form action "%s" does not exist for the current "%s" registration step.', 'event_espresso'), |
|
| 1308 | - $this->checkout->action, |
|
| 1309 | - $this->checkout->current_step->name() |
|
| 1310 | - ), |
|
| 1311 | - __FILE__, |
|
| 1312 | - __FUNCTION__, |
|
| 1313 | - __LINE__ |
|
| 1314 | - ); |
|
| 1315 | - } |
|
| 1316 | - // end default |
|
| 1317 | - } |
|
| 1318 | - // store our progress so far |
|
| 1319 | - $this->checkout->stash_transaction_and_checkout(); |
|
| 1320 | - // advance to the next step! If you pass GO, collect $200 |
|
| 1321 | - $this->go_to_next_step(); |
|
| 1322 | - } |
|
| 1323 | - |
|
| 1324 | - |
|
| 1325 | - |
|
| 1326 | - /** |
|
| 1327 | - * add_styles_and_scripts |
|
| 1328 | - * |
|
| 1329 | - * @access public |
|
| 1330 | - * @return void |
|
| 1331 | - */ |
|
| 1332 | - public function add_styles_and_scripts() |
|
| 1333 | - { |
|
| 1334 | - // i18n |
|
| 1335 | - $this->translate_js_strings(); |
|
| 1336 | - if ($this->checkout->admin_request) { |
|
| 1337 | - add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
| 1338 | - } else { |
|
| 1339 | - add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
| 1340 | - } |
|
| 1341 | - } |
|
| 1342 | - |
|
| 1343 | - |
|
| 1344 | - |
|
| 1345 | - /** |
|
| 1346 | - * translate_js_strings |
|
| 1347 | - * |
|
| 1348 | - * @access public |
|
| 1349 | - * @return void |
|
| 1350 | - */ |
|
| 1351 | - public function translate_js_strings() |
|
| 1352 | - { |
|
| 1353 | - EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit; |
|
| 1354 | - EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link; |
|
| 1355 | - EE_Registry::$i18n_js_strings['server_error'] = __('An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso'); |
|
| 1356 | - EE_Registry::$i18n_js_strings['invalid_json_response'] = __('An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso'); |
|
| 1357 | - EE_Registry::$i18n_js_strings['validation_error'] = __('There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', 'event_espresso'); |
|
| 1358 | - EE_Registry::$i18n_js_strings['invalid_payment_method'] = __('There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', 'event_espresso'); |
|
| 1359 | - EE_Registry::$i18n_js_strings['reg_step_error'] = __('This registration step could not be completed. Please refresh the page and try again.', 'event_espresso'); |
|
| 1360 | - EE_Registry::$i18n_js_strings['invalid_coupon'] = __('We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.', 'event_espresso'); |
|
| 1361 | - EE_Registry::$i18n_js_strings['process_registration'] = sprintf( |
|
| 1362 | - __('Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.', 'event_espresso'), |
|
| 1363 | - '<br/>', |
|
| 1364 | - '<br/>' |
|
| 1365 | - ); |
|
| 1366 | - EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language'); |
|
| 1367 | - EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id(); |
|
| 1368 | - EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency; |
|
| 1369 | - EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20'; |
|
| 1370 | - EE_Registry::$i18n_js_strings['timer_years'] = __('years', 'event_espresso'); |
|
| 1371 | - EE_Registry::$i18n_js_strings['timer_months'] = __('months', 'event_espresso'); |
|
| 1372 | - EE_Registry::$i18n_js_strings['timer_weeks'] = __('weeks', 'event_espresso'); |
|
| 1373 | - EE_Registry::$i18n_js_strings['timer_days'] = __('days', 'event_espresso'); |
|
| 1374 | - EE_Registry::$i18n_js_strings['timer_hours'] = __('hours', 'event_espresso'); |
|
| 1375 | - EE_Registry::$i18n_js_strings['timer_minutes'] = __('minutes', 'event_espresso'); |
|
| 1376 | - EE_Registry::$i18n_js_strings['timer_seconds'] = __('seconds', 'event_espresso'); |
|
| 1377 | - EE_Registry::$i18n_js_strings['timer_year'] = __('year', 'event_espresso'); |
|
| 1378 | - EE_Registry::$i18n_js_strings['timer_month'] = __('month', 'event_espresso'); |
|
| 1379 | - EE_Registry::$i18n_js_strings['timer_week'] = __('week', 'event_espresso'); |
|
| 1380 | - EE_Registry::$i18n_js_strings['timer_day'] = __('day', 'event_espresso'); |
|
| 1381 | - EE_Registry::$i18n_js_strings['timer_hour'] = __('hour', 'event_espresso'); |
|
| 1382 | - EE_Registry::$i18n_js_strings['timer_minute'] = __('minute', 'event_espresso'); |
|
| 1383 | - EE_Registry::$i18n_js_strings['timer_second'] = __('second', 'event_espresso'); |
|
| 1384 | - EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf( |
|
| 1385 | - __( |
|
| 1386 | - '%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s', |
|
| 1387 | - 'event_espresso' |
|
| 1388 | - ), |
|
| 1389 | - '<h4 class="important-notice">', |
|
| 1390 | - '</h4>', |
|
| 1391 | - '<br />', |
|
| 1392 | - '<p>', |
|
| 1393 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" title="', |
|
| 1394 | - '">', |
|
| 1395 | - '</a>', |
|
| 1396 | - '</p>' |
|
| 1397 | - ); |
|
| 1398 | - EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters('FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', true); |
|
| 1399 | - EE_Registry::$i18n_js_strings['session_extension'] = absint( |
|
| 1400 | - apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS) |
|
| 1401 | - ); |
|
| 1402 | - EE_Registry::$i18n_js_strings['session_expiration'] = gmdate( |
|
| 1403 | - 'M d, Y H:i:s', EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS) |
|
| 1404 | - ); |
|
| 1405 | - } |
|
| 1406 | - |
|
| 1407 | - |
|
| 1408 | - |
|
| 1409 | - /** |
|
| 1410 | - * enqueue_styles_and_scripts |
|
| 1411 | - * |
|
| 1412 | - * @access public |
|
| 1413 | - * @return void |
|
| 1414 | - * @throws \EE_Error |
|
| 1415 | - */ |
|
| 1416 | - public function enqueue_styles_and_scripts() |
|
| 1417 | - { |
|
| 1418 | - // load css |
|
| 1419 | - wp_register_style('single_page_checkout', SPCO_CSS_URL . 'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 1420 | - wp_enqueue_style('single_page_checkout'); |
|
| 1421 | - // load JS |
|
| 1422 | - wp_register_script('jquery_plugin', EE_THIRD_PARTY_URL . 'jquery .plugin.min.js', array('jquery'), '1.0.1', true); |
|
| 1423 | - wp_register_script('jquery_countdown', EE_THIRD_PARTY_URL . 'jquery .countdown.min.js', array('jquery_plugin'), '2.0.2', true); |
|
| 1424 | - wp_register_script('single_page_checkout', SPCO_JS_URL . 'single_page_checkout.js', array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'), EVENT_ESPRESSO_VERSION, true); |
|
| 1425 | - if ($this->checkout->registration_form instanceof EE_Form_Section_Proper) { |
|
| 1426 | - $this->checkout->registration_form->enqueue_js(); |
|
| 1427 | - } |
|
| 1428 | - if ($this->checkout->current_step->reg_form instanceof EE_Form_Section_Proper) { |
|
| 1429 | - $this->checkout->current_step->reg_form->enqueue_js(); |
|
| 1430 | - } |
|
| 1431 | - wp_enqueue_script('single_page_checkout'); |
|
| 1432 | - /** |
|
| 1433 | - * global action hook for enqueueing styles and scripts with |
|
| 1434 | - * spco calls. |
|
| 1435 | - */ |
|
| 1436 | - do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this); |
|
| 1437 | - /** |
|
| 1438 | - * dynamic action hook for enqueueing styles and scripts with spco calls. |
|
| 1439 | - * The hook will end up being something like AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information |
|
| 1440 | - */ |
|
| 1441 | - do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(), $this); |
|
| 1442 | - } |
|
| 1443 | - |
|
| 1444 | - |
|
| 1445 | - |
|
| 1446 | - /** |
|
| 1447 | - * display the Registration Single Page Checkout Form |
|
| 1448 | - * |
|
| 1449 | - * @access private |
|
| 1450 | - * @return void |
|
| 1451 | - * @throws \EE_Error |
|
| 1452 | - */ |
|
| 1453 | - private function _display_spco_reg_form() |
|
| 1454 | - { |
|
| 1455 | - // if registering via the admin, just display the reg form for the current step |
|
| 1456 | - if ($this->checkout->admin_request) { |
|
| 1457 | - EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form()); |
|
| 1458 | - } else { |
|
| 1459 | - // add powered by EE msg |
|
| 1460 | - add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer')); |
|
| 1461 | - $empty_cart = count($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params)) < 1 |
|
| 1462 | - ? true |
|
| 1463 | - : false; |
|
| 1464 | - EE_Registry::$i18n_js_strings['empty_cart'] = $empty_cart; |
|
| 1465 | - $cookies_not_set_msg = ''; |
|
| 1466 | - if ($empty_cart && ! isset($_COOKIE['ee_cookie_test'])) { |
|
| 1467 | - $cookies_not_set_msg = apply_filters( |
|
| 1468 | - 'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg', |
|
| 1469 | - sprintf( |
|
| 1470 | - __( |
|
| 1471 | - '%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s', |
|
| 1472 | - 'event_espresso' |
|
| 1473 | - ), |
|
| 1474 | - '<div class="ee-attention">', |
|
| 1475 | - '</div>', |
|
| 1476 | - '<h6 class="important-notice">', |
|
| 1477 | - '</h6>', |
|
| 1478 | - '<p>', |
|
| 1479 | - '</p>', |
|
| 1480 | - '<br />', |
|
| 1481 | - '<a href="http://www.whatarecookies.com/enable.asp" target="_blank">', |
|
| 1482 | - '</a>' |
|
| 1483 | - ) |
|
| 1484 | - ); |
|
| 1485 | - } |
|
| 1486 | - $this->checkout->registration_form = new EE_Form_Section_Proper( |
|
| 1487 | - array( |
|
| 1488 | - 'name' => 'single-page-checkout', |
|
| 1489 | - 'html_id' => 'ee-single-page-checkout-dv', |
|
| 1490 | - 'layout_strategy' => |
|
| 1491 | - new EE_Template_Layout( |
|
| 1492 | - array( |
|
| 1493 | - 'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php', |
|
| 1494 | - 'template_args' => array( |
|
| 1495 | - 'empty_cart' => $empty_cart, |
|
| 1496 | - 'revisit' => $this->checkout->revisit, |
|
| 1497 | - 'reg_steps' => $this->checkout->reg_steps, |
|
| 1498 | - 'next_step' => $this->checkout->next_step instanceof EE_SPCO_Reg_Step |
|
| 1499 | - ? $this->checkout->next_step->slug() |
|
| 1500 | - : '', |
|
| 1501 | - 'cancel_page_url' => $this->checkout->cancel_page_url, |
|
| 1502 | - 'empty_msg' => apply_filters( |
|
| 1503 | - 'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg', |
|
| 1504 | - sprintf( |
|
| 1505 | - __('You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', |
|
| 1506 | - 'event_espresso'), |
|
| 1507 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" title="', |
|
| 1508 | - '">', |
|
| 1509 | - '</a>' |
|
| 1510 | - ) |
|
| 1511 | - ), |
|
| 1512 | - 'cookies_not_set_msg' => $cookies_not_set_msg, |
|
| 1513 | - 'registration_time_limit' => $this->checkout->get_registration_time_limit(), |
|
| 1514 | - 'session_expiration' => |
|
| 1515 | - date('M d, Y H:i:s', EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS)), |
|
| 1516 | - ), |
|
| 1517 | - ) |
|
| 1518 | - ), |
|
| 1519 | - ) |
|
| 1520 | - ); |
|
| 1521 | - // load template and add to output sent that gets filtered into the_content() |
|
| 1522 | - EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html()); |
|
| 1523 | - } |
|
| 1524 | - } |
|
| 1525 | - |
|
| 1526 | - |
|
| 1527 | - |
|
| 1528 | - /** |
|
| 1529 | - * add_extra_finalize_registration_inputs |
|
| 1530 | - * |
|
| 1531 | - * @access public |
|
| 1532 | - * @param $next_step |
|
| 1533 | - * @internal param string $label |
|
| 1534 | - * @return void |
|
| 1535 | - */ |
|
| 1536 | - public function add_extra_finalize_registration_inputs($next_step) |
|
| 1537 | - { |
|
| 1538 | - if ($next_step === 'finalize_registration') { |
|
| 1539 | - echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>'; |
|
| 1540 | - } |
|
| 1541 | - } |
|
| 1542 | - |
|
| 1543 | - |
|
| 1544 | - |
|
| 1545 | - /** |
|
| 1546 | - * display_registration_footer |
|
| 1547 | - * |
|
| 1548 | - * @access public |
|
| 1549 | - * @return string |
|
| 1550 | - */ |
|
| 1551 | - public static function display_registration_footer() |
|
| 1552 | - { |
|
| 1553 | - if ( |
|
| 1554 | - apply_filters( |
|
| 1555 | - 'FHEE__EE_Front__Controller__show_reg_footer', |
|
| 1556 | - EE_Registry::instance()->CFG->admin->show_reg_footer |
|
| 1557 | - ) |
|
| 1558 | - ) { |
|
| 1559 | - add_filter( |
|
| 1560 | - 'FHEE__EEH_Template__powered_by_event_espresso__url', |
|
| 1561 | - function ($url) { |
|
| 1562 | - return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url); |
|
| 1563 | - } |
|
| 1564 | - ); |
|
| 1565 | - echo apply_filters( |
|
| 1566 | - 'FHEE__EE_Front_Controller__display_registration_footer', |
|
| 1567 | - \EEH_Template::powered_by_event_espresso( |
|
| 1568 | - '', |
|
| 1569 | - 'espresso-registration-footer-dv', |
|
| 1570 | - array('utm_content' => 'registration_checkout') |
|
| 1571 | - ) |
|
| 1572 | - ); |
|
| 1573 | - } |
|
| 1574 | - return ''; |
|
| 1575 | - } |
|
| 1576 | - |
|
| 1577 | - |
|
| 1578 | - |
|
| 1579 | - /** |
|
| 1580 | - * unlock_transaction |
|
| 1581 | - * |
|
| 1582 | - * @access public |
|
| 1583 | - * @return void |
|
| 1584 | - * @throws \EE_Error |
|
| 1585 | - */ |
|
| 1586 | - public function unlock_transaction() |
|
| 1587 | - { |
|
| 1588 | - if ($this->checkout->transaction instanceof EE_Transaction) { |
|
| 1589 | - $this->checkout->transaction->unlock(); |
|
| 1590 | - } |
|
| 1591 | - } |
|
| 1592 | - |
|
| 1593 | - |
|
| 1594 | - |
|
| 1595 | - /** |
|
| 1596 | - * _setup_redirect |
|
| 1597 | - * |
|
| 1598 | - * @access private |
|
| 1599 | - * @return void |
|
| 1600 | - */ |
|
| 1601 | - private function _setup_redirect() |
|
| 1602 | - { |
|
| 1603 | - if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
| 1604 | - $this->checkout->redirect = true; |
|
| 1605 | - if (empty($this->checkout->redirect_url)) { |
|
| 1606 | - $this->checkout->redirect_url = $this->checkout->next_step->reg_step_url(); |
|
| 1607 | - } |
|
| 1608 | - $this->checkout->redirect_url = apply_filters( |
|
| 1609 | - 'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', |
|
| 1610 | - $this->checkout->redirect_url, |
|
| 1611 | - $this->checkout |
|
| 1612 | - ); |
|
| 1613 | - } |
|
| 1614 | - } |
|
| 1615 | - |
|
| 1616 | - |
|
| 1617 | - |
|
| 1618 | - /** |
|
| 1619 | - * handle ajax message responses and redirects |
|
| 1620 | - * |
|
| 1621 | - * @access public |
|
| 1622 | - * @return void |
|
| 1623 | - * @throws \EE_Error |
|
| 1624 | - */ |
|
| 1625 | - public function go_to_next_step() |
|
| 1626 | - { |
|
| 1627 | - if (EE_Registry::instance()->REQ->ajax) { |
|
| 1628 | - // capture contents of output buffer we started earlier in the request, and insert into JSON response |
|
| 1629 | - $this->checkout->json_response->set_unexpected_errors(ob_get_clean()); |
|
| 1630 | - } |
|
| 1631 | - $this->unlock_transaction(); |
|
| 1632 | - // just return for these conditions |
|
| 1633 | - if ( |
|
| 1634 | - $this->checkout->admin_request |
|
| 1635 | - || $this->checkout->action === 'redirect_form' |
|
| 1636 | - || $this->checkout->action === 'update_checkout' |
|
| 1637 | - ) { |
|
| 1638 | - return; |
|
| 1639 | - } |
|
| 1640 | - // AJAX response |
|
| 1641 | - $this->_handle_json_response(); |
|
| 1642 | - // redirect to next step or the Thank You page |
|
| 1643 | - $this->_handle_html_redirects(); |
|
| 1644 | - // hmmm... must be something wrong, so let's just display the form again ! |
|
| 1645 | - $this->_display_spco_reg_form(); |
|
| 1646 | - } |
|
| 1647 | - |
|
| 1648 | - |
|
| 1649 | - |
|
| 1650 | - /** |
|
| 1651 | - * _handle_json_response |
|
| 1652 | - * |
|
| 1653 | - * @access protected |
|
| 1654 | - * @return void |
|
| 1655 | - */ |
|
| 1656 | - protected function _handle_json_response() |
|
| 1657 | - { |
|
| 1658 | - // if this is an ajax request |
|
| 1659 | - if (EE_Registry::instance()->REQ->ajax) { |
|
| 1660 | - // DEBUG LOG |
|
| 1661 | - //$this->checkout->log( |
|
| 1662 | - // __CLASS__, __FUNCTION__, __LINE__, |
|
| 1663 | - // array( |
|
| 1664 | - // 'json_response_redirect_url' => $this->checkout->json_response->redirect_url(), |
|
| 1665 | - // 'redirect' => $this->checkout->redirect, |
|
| 1666 | - // 'continue_reg' => $this->checkout->continue_reg, |
|
| 1667 | - // ) |
|
| 1668 | - //); |
|
| 1669 | - $this->checkout->json_response->set_registration_time_limit( |
|
| 1670 | - $this->checkout->get_registration_time_limit() |
|
| 1671 | - ); |
|
| 1672 | - $this->checkout->json_response->set_payment_amount($this->checkout->amount_owing); |
|
| 1673 | - // just send the ajax ( |
|
| 1674 | - $json_response = apply_filters( |
|
| 1675 | - 'FHEE__EE_Single_Page_Checkout__JSON_response', |
|
| 1676 | - $this->checkout->json_response |
|
| 1677 | - ); |
|
| 1678 | - echo $json_response; |
|
| 1679 | - exit(); |
|
| 1680 | - } |
|
| 1681 | - } |
|
| 1682 | - |
|
| 1683 | - |
|
| 1684 | - |
|
| 1685 | - /** |
|
| 1686 | - * _handle_redirects |
|
| 1687 | - * |
|
| 1688 | - * @access protected |
|
| 1689 | - * @return void |
|
| 1690 | - */ |
|
| 1691 | - protected function _handle_html_redirects() |
|
| 1692 | - { |
|
| 1693 | - // going somewhere ? |
|
| 1694 | - if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) { |
|
| 1695 | - // store notices in a transient |
|
| 1696 | - EE_Error::get_notices(false, true, true); |
|
| 1697 | - // DEBUG LOG |
|
| 1698 | - //$this->checkout->log( |
|
| 1699 | - // __CLASS__, __FUNCTION__, __LINE__, |
|
| 1700 | - // array( |
|
| 1701 | - // 'headers_sent' => headers_sent(), |
|
| 1702 | - // 'redirect_url' => $this->checkout->redirect_url, |
|
| 1703 | - // 'headers_list' => headers_list(), |
|
| 1704 | - // ) |
|
| 1705 | - //); |
|
| 1706 | - wp_safe_redirect($this->checkout->redirect_url); |
|
| 1707 | - exit(); |
|
| 1708 | - } |
|
| 1709 | - } |
|
| 1710 | - |
|
| 1711 | - |
|
| 1712 | - |
|
| 1713 | - /** |
|
| 1714 | - * set_checkout_anchor |
|
| 1715 | - * |
|
| 1716 | - * @access public |
|
| 1717 | - * @return void |
|
| 1718 | - */ |
|
| 1719 | - public function set_checkout_anchor() |
|
| 1720 | - { |
|
| 1721 | - echo '<a id="checkout" style="float: left; margin-left: -999em;"></a>'; |
|
| 1722 | - } |
|
| 20 | + /** |
|
| 21 | + * $_initialized - has the SPCO controller already been initialized ? |
|
| 22 | + * |
|
| 23 | + * @access private |
|
| 24 | + * @var bool $_initialized |
|
| 25 | + */ |
|
| 26 | + private static $_initialized = false; |
|
| 27 | + |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * $_checkout_verified - is the EE_Checkout verified as correct for this request ? |
|
| 31 | + * |
|
| 32 | + * @access private |
|
| 33 | + * @var bool $_valid_checkout |
|
| 34 | + */ |
|
| 35 | + private static $_checkout_verified = true; |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * $_reg_steps_array - holds initial array of reg steps |
|
| 39 | + * |
|
| 40 | + * @access private |
|
| 41 | + * @var array $_reg_steps_array |
|
| 42 | + */ |
|
| 43 | + private static $_reg_steps_array = array(); |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * $checkout - EE_Checkout object for handling the properties of the current checkout process |
|
| 47 | + * |
|
| 48 | + * @access public |
|
| 49 | + * @var EE_Checkout $checkout |
|
| 50 | + */ |
|
| 51 | + public $checkout; |
|
| 52 | + |
|
| 53 | + |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * @return EED_Single_Page_Checkout |
|
| 57 | + */ |
|
| 58 | + public static function instance() |
|
| 59 | + { |
|
| 60 | + add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true'); |
|
| 61 | + return parent::get_instance(__CLASS__); |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * @return EE_CART |
|
| 68 | + */ |
|
| 69 | + public function cart() |
|
| 70 | + { |
|
| 71 | + return $this->checkout->cart; |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * @return EE_Transaction |
|
| 78 | + */ |
|
| 79 | + public function transaction() |
|
| 80 | + { |
|
| 81 | + return $this->checkout->transaction; |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
| 88 | + * |
|
| 89 | + * @access public |
|
| 90 | + * @return void |
|
| 91 | + * @throws \EE_Error |
|
| 92 | + */ |
|
| 93 | + public static function set_hooks() |
|
| 94 | + { |
|
| 95 | + EED_Single_Page_Checkout::set_definitions(); |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + |
|
| 99 | + |
|
| 100 | + /** |
|
| 101 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
| 102 | + * |
|
| 103 | + * @access public |
|
| 104 | + * @return void |
|
| 105 | + * @throws \EE_Error |
|
| 106 | + */ |
|
| 107 | + public static function set_hooks_admin() |
|
| 108 | + { |
|
| 109 | + EED_Single_Page_Checkout::set_definitions(); |
|
| 110 | + if ( ! (defined('DOING_AJAX') && DOING_AJAX)) { |
|
| 111 | + // hook into the top of pre_get_posts to set the reg step routing, which gives other modules or plugins a chance to modify the reg steps, but just before the routes get called |
|
| 112 | + add_action('pre_get_posts', array('EED_Single_Page_Checkout', 'load_reg_steps'), 1); |
|
| 113 | + return; |
|
| 114 | + } |
|
| 115 | + // going to start an output buffer in case anything gets accidentally output that might disrupt our JSON response |
|
| 116 | + ob_start(); |
|
| 117 | + EED_Single_Page_Checkout::load_request_handler(); |
|
| 118 | + EED_Single_Page_Checkout::load_reg_steps(); |
|
| 119 | + // set ajax hooks |
|
| 120 | + add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
| 121 | + add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
| 122 | + add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
| 123 | + add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
| 124 | + add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
| 125 | + add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + |
|
| 129 | + |
|
| 130 | + /** |
|
| 131 | + * process ajax request |
|
| 132 | + * |
|
| 133 | + * @param string $ajax_action |
|
| 134 | + * @throws \EE_Error |
|
| 135 | + */ |
|
| 136 | + public static function process_ajax_request($ajax_action) |
|
| 137 | + { |
|
| 138 | + EE_Registry::instance()->REQ->set('action', $ajax_action); |
|
| 139 | + EED_Single_Page_Checkout::instance()->_initialize(); |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + |
|
| 143 | + |
|
| 144 | + /** |
|
| 145 | + * ajax display registration step |
|
| 146 | + * |
|
| 147 | + * @throws \EE_Error |
|
| 148 | + */ |
|
| 149 | + public static function display_reg_step() |
|
| 150 | + { |
|
| 151 | + EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step'); |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + |
|
| 155 | + |
|
| 156 | + /** |
|
| 157 | + * ajax process registration step |
|
| 158 | + * |
|
| 159 | + * @throws \EE_Error |
|
| 160 | + */ |
|
| 161 | + public static function process_reg_step() |
|
| 162 | + { |
|
| 163 | + EED_Single_Page_Checkout::process_ajax_request('process_reg_step'); |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + |
|
| 167 | + |
|
| 168 | + /** |
|
| 169 | + * ajax process registration step |
|
| 170 | + * |
|
| 171 | + * @throws \EE_Error |
|
| 172 | + */ |
|
| 173 | + public static function update_reg_step() |
|
| 174 | + { |
|
| 175 | + EED_Single_Page_Checkout::process_ajax_request('update_reg_step'); |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + |
|
| 179 | + |
|
| 180 | + /** |
|
| 181 | + * update_checkout |
|
| 182 | + * |
|
| 183 | + * @access public |
|
| 184 | + * @return void |
|
| 185 | + * @throws \EE_Error |
|
| 186 | + */ |
|
| 187 | + public static function update_checkout() |
|
| 188 | + { |
|
| 189 | + EED_Single_Page_Checkout::process_ajax_request('update_checkout'); |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + |
|
| 193 | + |
|
| 194 | + /** |
|
| 195 | + * load_request_handler |
|
| 196 | + * |
|
| 197 | + * @access public |
|
| 198 | + * @return void |
|
| 199 | + */ |
|
| 200 | + public static function load_request_handler() |
|
| 201 | + { |
|
| 202 | + // load core Request_Handler class |
|
| 203 | + if ( ! isset(EE_Registry::instance()->REQ)) { |
|
| 204 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
| 205 | + } |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + |
|
| 209 | + |
|
| 210 | + /** |
|
| 211 | + * set_definitions |
|
| 212 | + * |
|
| 213 | + * @access public |
|
| 214 | + * @return void |
|
| 215 | + * @throws \EE_Error |
|
| 216 | + */ |
|
| 217 | + public static function set_definitions() |
|
| 218 | + { |
|
| 219 | + define('SPCO_BASE_PATH', rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS) . DS); |
|
| 220 | + define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css' . DS); |
|
| 221 | + define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img' . DS); |
|
| 222 | + define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js' . DS); |
|
| 223 | + define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS); |
|
| 224 | + define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS); |
|
| 225 | + define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS); |
|
| 226 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true); |
|
| 227 | + EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf( |
|
| 228 | + __('%1$sWe\'re sorry, but you\'re registration time has expired.%2$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s', |
|
| 229 | + 'event_espresso'), |
|
| 230 | + '<h4 class="important-notice">', |
|
| 231 | + '</h4>', |
|
| 232 | + '<br />', |
|
| 233 | + '<p>', |
|
| 234 | + '<a href="' . get_post_type_archive_link('espresso_events') . '" title="', |
|
| 235 | + '">', |
|
| 236 | + '</a>', |
|
| 237 | + '</p>' |
|
| 238 | + ); |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + |
|
| 242 | + |
|
| 243 | + /** |
|
| 244 | + * load_reg_steps |
|
| 245 | + * loads and instantiates each reg step based on the EE_Registry::instance()->CFG->registration->reg_steps array |
|
| 246 | + * |
|
| 247 | + * @access private |
|
| 248 | + * @throws EE_Error |
|
| 249 | + * @return void |
|
| 250 | + */ |
|
| 251 | + public static function load_reg_steps() |
|
| 252 | + { |
|
| 253 | + static $reg_steps_loaded = false; |
|
| 254 | + if ($reg_steps_loaded) { |
|
| 255 | + return; |
|
| 256 | + } |
|
| 257 | + // filter list of reg_steps |
|
| 258 | + $reg_steps_to_load = (array)apply_filters( |
|
| 259 | + 'AHEE__SPCO__load_reg_steps__reg_steps_to_load', |
|
| 260 | + EED_Single_Page_Checkout::get_reg_steps() |
|
| 261 | + ); |
|
| 262 | + // sort by key (order) |
|
| 263 | + ksort($reg_steps_to_load); |
|
| 264 | + // loop through folders |
|
| 265 | + foreach ($reg_steps_to_load as $order => $reg_step) { |
|
| 266 | + // we need a |
|
| 267 | + if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
| 268 | + // copy over to the reg_steps_array |
|
| 269 | + EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step; |
|
| 270 | + // register custom key route for each reg step |
|
| 271 | + // ie: step=>"slug" - this is the entire reason we load the reg steps array now |
|
| 272 | + EE_Config::register_route($reg_step['slug'], 'EED_Single_Page_Checkout', 'run', 'step'); |
|
| 273 | + // add AJAX or other hooks |
|
| 274 | + if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) { |
|
| 275 | + // setup autoloaders if necessary |
|
| 276 | + if ( ! class_exists($reg_step['class_name'])) { |
|
| 277 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($reg_step['file_path'], true); |
|
| 278 | + } |
|
| 279 | + if (is_callable($reg_step['class_name'], 'set_hooks')) { |
|
| 280 | + call_user_func(array($reg_step['class_name'], 'set_hooks')); |
|
| 281 | + } |
|
| 282 | + } |
|
| 283 | + } |
|
| 284 | + } |
|
| 285 | + $reg_steps_loaded = true; |
|
| 286 | + } |
|
| 287 | + |
|
| 288 | + |
|
| 289 | + |
|
| 290 | + /** |
|
| 291 | + * get_reg_steps |
|
| 292 | + * |
|
| 293 | + * @access public |
|
| 294 | + * @return array |
|
| 295 | + */ |
|
| 296 | + public static function get_reg_steps() |
|
| 297 | + { |
|
| 298 | + $reg_steps = EE_Registry::instance()->CFG->registration->reg_steps; |
|
| 299 | + if (empty($reg_steps)) { |
|
| 300 | + $reg_steps = array( |
|
| 301 | + 10 => array( |
|
| 302 | + 'file_path' => SPCO_REG_STEPS_PATH . 'attendee_information', |
|
| 303 | + 'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information', |
|
| 304 | + 'slug' => 'attendee_information', |
|
| 305 | + 'has_hooks' => false, |
|
| 306 | + ), |
|
| 307 | + 20 => array( |
|
| 308 | + 'file_path' => SPCO_REG_STEPS_PATH . 'registration_confirmation', |
|
| 309 | + 'class_name' => 'EE_SPCO_Reg_Step_Registration_Confirmation', |
|
| 310 | + 'slug' => 'registration_confirmation', |
|
| 311 | + 'has_hooks' => false, |
|
| 312 | + ), |
|
| 313 | + 30 => array( |
|
| 314 | + 'file_path' => SPCO_REG_STEPS_PATH . 'payment_options', |
|
| 315 | + 'class_name' => 'EE_SPCO_Reg_Step_Payment_Options', |
|
| 316 | + 'slug' => 'payment_options', |
|
| 317 | + 'has_hooks' => true, |
|
| 318 | + ), |
|
| 319 | + 999 => array( |
|
| 320 | + 'file_path' => SPCO_REG_STEPS_PATH . 'finalize_registration', |
|
| 321 | + 'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration', |
|
| 322 | + 'slug' => 'finalize_registration', |
|
| 323 | + 'has_hooks' => false, |
|
| 324 | + ), |
|
| 325 | + ); |
|
| 326 | + } |
|
| 327 | + return $reg_steps; |
|
| 328 | + } |
|
| 329 | + |
|
| 330 | + |
|
| 331 | + |
|
| 332 | + /** |
|
| 333 | + * registration_checkout_for_admin |
|
| 334 | + * |
|
| 335 | + * @access public |
|
| 336 | + * @return string |
|
| 337 | + * @throws \EE_Error |
|
| 338 | + */ |
|
| 339 | + public static function registration_checkout_for_admin() |
|
| 340 | + { |
|
| 341 | + EED_Single_Page_Checkout::load_reg_steps(); |
|
| 342 | + EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
| 343 | + EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step'); |
|
| 344 | + EE_Registry::instance()->REQ->set('process_form_submission', false); |
|
| 345 | + EED_Single_Page_Checkout::instance()->_initialize(); |
|
| 346 | + EED_Single_Page_Checkout::instance()->_display_spco_reg_form(); |
|
| 347 | + return EE_Registry::instance()->REQ->get_output(); |
|
| 348 | + } |
|
| 349 | + |
|
| 350 | + |
|
| 351 | + |
|
| 352 | + /** |
|
| 353 | + * process_registration_from_admin |
|
| 354 | + * |
|
| 355 | + * @access public |
|
| 356 | + * @return \EE_Transaction |
|
| 357 | + * @throws \EE_Error |
|
| 358 | + */ |
|
| 359 | + public static function process_registration_from_admin() |
|
| 360 | + { |
|
| 361 | + EED_Single_Page_Checkout::load_reg_steps(); |
|
| 362 | + EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
| 363 | + EE_Registry::instance()->REQ->set('action', 'process_reg_step'); |
|
| 364 | + EE_Registry::instance()->REQ->set('process_form_submission', true); |
|
| 365 | + EED_Single_Page_Checkout::instance()->_initialize(); |
|
| 366 | + if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) { |
|
| 367 | + $final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps); |
|
| 368 | + if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) { |
|
| 369 | + EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step); |
|
| 370 | + if ($final_reg_step->process_reg_step()) { |
|
| 371 | + $final_reg_step->set_completed(); |
|
| 372 | + EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array(); |
|
| 373 | + return EED_Single_Page_Checkout::instance()->checkout->transaction; |
|
| 374 | + } |
|
| 375 | + } |
|
| 376 | + } |
|
| 377 | + return null; |
|
| 378 | + } |
|
| 379 | + |
|
| 380 | + |
|
| 381 | + |
|
| 382 | + /** |
|
| 383 | + * run |
|
| 384 | + * |
|
| 385 | + * @access public |
|
| 386 | + * @param WP_Query $WP_Query |
|
| 387 | + * @return void |
|
| 388 | + * @throws \EE_Error |
|
| 389 | + */ |
|
| 390 | + public function run($WP_Query) |
|
| 391 | + { |
|
| 392 | + if ( |
|
| 393 | + $WP_Query instanceof WP_Query |
|
| 394 | + && $WP_Query->is_main_query() |
|
| 395 | + && apply_filters('FHEE__EED_Single_Page_Checkout__run', true) |
|
| 396 | + && $this->_is_reg_checkout() |
|
| 397 | + ) { |
|
| 398 | + $this->_initialize(); |
|
| 399 | + } |
|
| 400 | + } |
|
| 401 | + |
|
| 402 | + |
|
| 403 | + |
|
| 404 | + /** |
|
| 405 | + * determines whether current url matches reg page url |
|
| 406 | + * |
|
| 407 | + * @return bool |
|
| 408 | + */ |
|
| 409 | + protected function _is_reg_checkout() |
|
| 410 | + { |
|
| 411 | + // get current permalink for reg page without any extra query args |
|
| 412 | + $reg_page_url = \get_permalink(EE_Config::instance()->core->reg_page_id); |
|
| 413 | + // get request URI for current request, but without the scheme or host |
|
| 414 | + $current_request_uri = \EEH_URL::filter_input_server_url('REQUEST_URI'); |
|
| 415 | + $current_request_uri = html_entity_decode($current_request_uri); |
|
| 416 | + // get array of query args from the current request URI |
|
| 417 | + $query_args = \EEH_URL::get_query_string($current_request_uri); |
|
| 418 | + // grab page id if it is set |
|
| 419 | + $page_id = isset($query_args['page_id']) ? absint($query_args['page_id']) : 0; |
|
| 420 | + // and remove the page id from the query args (we will re-add it later) |
|
| 421 | + unset($query_args['page_id']); |
|
| 422 | + // now strip all query args from current request URI |
|
| 423 | + $current_request_uri = remove_query_arg(array_flip($query_args), $current_request_uri); |
|
| 424 | + // and re-add the page id if it was set |
|
| 425 | + if ($page_id) { |
|
| 426 | + $current_request_uri = add_query_arg('page_id', $page_id, $current_request_uri); |
|
| 427 | + } |
|
| 428 | + // remove slashes and ? |
|
| 429 | + $current_request_uri = trim($current_request_uri, '?/'); |
|
| 430 | + // is current request URI part of the known full reg page URL ? |
|
| 431 | + return ! empty($current_request_uri) && strpos($reg_page_url, $current_request_uri) !== false; |
|
| 432 | + } |
|
| 433 | + |
|
| 434 | + |
|
| 435 | + |
|
| 436 | + /** |
|
| 437 | + * run |
|
| 438 | + * |
|
| 439 | + * @access public |
|
| 440 | + * @param WP_Query $WP_Query |
|
| 441 | + * @return void |
|
| 442 | + * @throws \EE_Error |
|
| 443 | + */ |
|
| 444 | + public static function init($WP_Query) |
|
| 445 | + { |
|
| 446 | + EED_Single_Page_Checkout::instance()->run($WP_Query); |
|
| 447 | + } |
|
| 448 | + |
|
| 449 | + |
|
| 450 | + |
|
| 451 | + /** |
|
| 452 | + * _initialize - initial module setup |
|
| 453 | + * |
|
| 454 | + * @access private |
|
| 455 | + * @throws EE_Error |
|
| 456 | + * @return void |
|
| 457 | + */ |
|
| 458 | + private function _initialize() |
|
| 459 | + { |
|
| 460 | + // ensure SPCO doesn't run twice |
|
| 461 | + if (EED_Single_Page_Checkout::$_initialized) { |
|
| 462 | + return; |
|
| 463 | + } |
|
| 464 | + try { |
|
| 465 | + $this->_verify_session(); |
|
| 466 | + // setup the EE_Checkout object |
|
| 467 | + $this->checkout = $this->_initialize_checkout(); |
|
| 468 | + // filter checkout |
|
| 469 | + $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout); |
|
| 470 | + // get the $_GET |
|
| 471 | + $this->_get_request_vars(); |
|
| 472 | + if ($this->_block_bots()) { |
|
| 473 | + return; |
|
| 474 | + } |
|
| 475 | + // filter continue_reg |
|
| 476 | + $this->checkout->continue_reg = apply_filters('FHEE__EED_Single_Page_Checkout__init___continue_reg', true, $this->checkout); |
|
| 477 | + // load the reg steps array |
|
| 478 | + if ( ! $this->_load_and_instantiate_reg_steps()) { |
|
| 479 | + EED_Single_Page_Checkout::$_initialized = true; |
|
| 480 | + return; |
|
| 481 | + } |
|
| 482 | + // set the current step |
|
| 483 | + $this->checkout->set_current_step($this->checkout->step); |
|
| 484 | + // and the next step |
|
| 485 | + $this->checkout->set_next_step(); |
|
| 486 | + // verify that everything has been setup correctly |
|
| 487 | + if ( ! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) { |
|
| 488 | + EED_Single_Page_Checkout::$_initialized = true; |
|
| 489 | + return; |
|
| 490 | + } |
|
| 491 | + // lock the transaction |
|
| 492 | + $this->checkout->transaction->lock(); |
|
| 493 | + // make sure all of our cached objects are added to their respective model entity mappers |
|
| 494 | + $this->checkout->refresh_all_entities(); |
|
| 495 | + // set amount owing |
|
| 496 | + $this->checkout->amount_owing = $this->checkout->transaction->remaining(); |
|
| 497 | + // initialize each reg step, which gives them the chance to potentially alter the process |
|
| 498 | + $this->_initialize_reg_steps(); |
|
| 499 | + // DEBUG LOG |
|
| 500 | + //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
|
| 501 | + // get reg form |
|
| 502 | + if( ! $this->_check_form_submission()) { |
|
| 503 | + EED_Single_Page_Checkout::$_initialized = true; |
|
| 504 | + return; |
|
| 505 | + } |
|
| 506 | + // checkout the action!!! |
|
| 507 | + $this->_process_form_action(); |
|
| 508 | + // add some style and make it dance |
|
| 509 | + $this->add_styles_and_scripts(); |
|
| 510 | + // kk... SPCO has successfully run |
|
| 511 | + EED_Single_Page_Checkout::$_initialized = true; |
|
| 512 | + // set no cache headers and constants |
|
| 513 | + EE_System::do_not_cache(); |
|
| 514 | + // add anchor |
|
| 515 | + add_action('loop_start', array($this, 'set_checkout_anchor'), 1); |
|
| 516 | + // remove transaction lock |
|
| 517 | + add_action('shutdown', array($this, 'unlock_transaction'), 1); |
|
| 518 | + } catch (Exception $e) { |
|
| 519 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
| 520 | + } |
|
| 521 | + } |
|
| 522 | + |
|
| 523 | + |
|
| 524 | + |
|
| 525 | + /** |
|
| 526 | + * _verify_session |
|
| 527 | + * checks that the session is valid and not expired |
|
| 528 | + * |
|
| 529 | + * @access private |
|
| 530 | + * @throws EE_Error |
|
| 531 | + */ |
|
| 532 | + private function _verify_session() |
|
| 533 | + { |
|
| 534 | + if ( ! EE_Registry::instance()->SSN instanceof EE_Session) { |
|
| 535 | + throw new EE_Error(__('The EE_Session class could not be loaded.', 'event_espresso')); |
|
| 536 | + } |
|
| 537 | + // is session still valid ? |
|
| 538 | + if (EE_Registry::instance()->SSN->expired() && EE_Registry::instance()->REQ->get('e_reg_url_link', '') === '') { |
|
| 539 | + $this->checkout = new EE_Checkout(); |
|
| 540 | + EE_Registry::instance()->SSN->reset_cart(); |
|
| 541 | + EE_Registry::instance()->SSN->reset_checkout(); |
|
| 542 | + EE_Registry::instance()->SSN->reset_transaction(); |
|
| 543 | + EE_Error::add_attention(EE_Registry::$i18n_js_strings['registration_expiration_notice'], __FILE__, |
|
| 544 | + __FUNCTION__, __LINE__); |
|
| 545 | + EE_Registry::instance()->SSN->reset_expired(); |
|
| 546 | + } |
|
| 547 | + } |
|
| 548 | + |
|
| 549 | + |
|
| 550 | + |
|
| 551 | + /** |
|
| 552 | + * _initialize_checkout |
|
| 553 | + * loads and instantiates EE_Checkout |
|
| 554 | + * |
|
| 555 | + * @access private |
|
| 556 | + * @throws EE_Error |
|
| 557 | + * @return EE_Checkout |
|
| 558 | + */ |
|
| 559 | + private function _initialize_checkout() |
|
| 560 | + { |
|
| 561 | + // look in session for existing checkout |
|
| 562 | + /** @type EE_Checkout $checkout */ |
|
| 563 | + $checkout = EE_Registry::instance()->SSN->checkout(); |
|
| 564 | + // verify |
|
| 565 | + if ( ! $checkout instanceof EE_Checkout) { |
|
| 566 | + // instantiate EE_Checkout object for handling the properties of the current checkout process |
|
| 567 | + $checkout = EE_Registry::instance()->load_file(SPCO_INC_PATH, 'EE_Checkout', 'class', array(), false); |
|
| 568 | + } else { |
|
| 569 | + if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) { |
|
| 570 | + $this->unlock_transaction(); |
|
| 571 | + wp_safe_redirect($checkout->redirect_url); |
|
| 572 | + exit(); |
|
| 573 | + } |
|
| 574 | + } |
|
| 575 | + $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout); |
|
| 576 | + // verify again |
|
| 577 | + if ( ! $checkout instanceof EE_Checkout) { |
|
| 578 | + throw new EE_Error(__('The EE_Checkout class could not be loaded.', 'event_espresso')); |
|
| 579 | + } |
|
| 580 | + // reset anything that needs a clean slate for each request |
|
| 581 | + $checkout->reset_for_current_request(); |
|
| 582 | + return $checkout; |
|
| 583 | + } |
|
| 584 | + |
|
| 585 | + |
|
| 586 | + |
|
| 587 | + /** |
|
| 588 | + * _get_request_vars |
|
| 589 | + * |
|
| 590 | + * @access private |
|
| 591 | + * @return void |
|
| 592 | + * @throws \EE_Error |
|
| 593 | + */ |
|
| 594 | + private function _get_request_vars() |
|
| 595 | + { |
|
| 596 | + // load classes |
|
| 597 | + EED_Single_Page_Checkout::load_request_handler(); |
|
| 598 | + //make sure this request is marked as belonging to EE |
|
| 599 | + EE_Registry::instance()->REQ->set_espresso_page(true); |
|
| 600 | + // which step is being requested ? |
|
| 601 | + $this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step()); |
|
| 602 | + // which step is being edited ? |
|
| 603 | + $this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', ''); |
|
| 604 | + // and what we're doing on the current step |
|
| 605 | + $this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step'); |
|
| 606 | + // timestamp |
|
| 607 | + $this->checkout->uts = EE_Registry::instance()->REQ->get('uts', 0); |
|
| 608 | + // returning to edit ? |
|
| 609 | + $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', ''); |
|
| 610 | + // or some other kind of revisit ? |
|
| 611 | + $this->checkout->revisit = filter_var( |
|
| 612 | + EE_Registry::instance()->REQ->get('revisit', false), |
|
| 613 | + FILTER_VALIDATE_BOOLEAN |
|
| 614 | + ); |
|
| 615 | + // and whether or not to generate a reg form for this request |
|
| 616 | + $this->checkout->generate_reg_form = filter_var( |
|
| 617 | + EE_Registry::instance()->REQ->get('generate_reg_form', true), |
|
| 618 | + FILTER_VALIDATE_BOOLEAN |
|
| 619 | + ); |
|
| 620 | + // and whether or not to process a reg form submission for this request |
|
| 621 | + $this->checkout->process_form_submission = filter_var( |
|
| 622 | + EE_Registry::instance()->REQ->get( |
|
| 623 | + 'process_form_submission', |
|
| 624 | + $this->checkout->action === 'process_reg_step' |
|
| 625 | + ), |
|
| 626 | + FILTER_VALIDATE_BOOLEAN |
|
| 627 | + ); |
|
| 628 | + $this->checkout->process_form_submission = filter_var( |
|
| 629 | + $this->checkout->action !== 'display_spco_reg_step' |
|
| 630 | + ? $this->checkout->process_form_submission |
|
| 631 | + : false, |
|
| 632 | + FILTER_VALIDATE_BOOLEAN |
|
| 633 | + ); |
|
| 634 | + // $this->_display_request_vars(); |
|
| 635 | + } |
|
| 636 | + |
|
| 637 | + |
|
| 638 | + |
|
| 639 | + /** |
|
| 640 | + * _display_request_vars |
|
| 641 | + * |
|
| 642 | + * @access protected |
|
| 643 | + * @return void |
|
| 644 | + */ |
|
| 645 | + protected function _display_request_vars() |
|
| 646 | + { |
|
| 647 | + if ( ! WP_DEBUG) { |
|
| 648 | + return; |
|
| 649 | + } |
|
| 650 | + EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__); |
|
| 651 | + EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__); |
|
| 652 | + EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__); |
|
| 653 | + EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__); |
|
| 654 | + EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__); |
|
| 655 | + EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__); |
|
| 656 | + EEH_Debug_Tools::printr($this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__); |
|
| 657 | + EEH_Debug_Tools::printr($this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__); |
|
| 658 | + } |
|
| 659 | + |
|
| 660 | + |
|
| 661 | + |
|
| 662 | + /** |
|
| 663 | + * _block_bots |
|
| 664 | + * checks that the incoming request has either of the following set: |
|
| 665 | + * a uts (unix timestamp) which indicates that the request was redirected from the Ticket Selector |
|
| 666 | + * a REG URL Link, which indicates that the request is a return visit to SPCO for a valid TXN |
|
| 667 | + * so if you're not coming from the Ticket Selector nor returning for a valid IP... |
|
| 668 | + * then where you coming from man? |
|
| 669 | + * |
|
| 670 | + * @return boolean |
|
| 671 | + */ |
|
| 672 | + private function _block_bots() |
|
| 673 | + { |
|
| 674 | + $invalid_checkout_access = \EED_Invalid_Checkout_Access::getInvalidCheckoutAccess(); |
|
| 675 | + if ($invalid_checkout_access->checkoutAccessIsInvalid($this->checkout)) { |
|
| 676 | + return true; |
|
| 677 | + } |
|
| 678 | + return false; |
|
| 679 | + } |
|
| 680 | + |
|
| 681 | + |
|
| 682 | + |
|
| 683 | + /** |
|
| 684 | + * _get_first_step |
|
| 685 | + * gets slug for first step in $_reg_steps_array |
|
| 686 | + * |
|
| 687 | + * @access private |
|
| 688 | + * @throws EE_Error |
|
| 689 | + * @return string |
|
| 690 | + */ |
|
| 691 | + private function _get_first_step() |
|
| 692 | + { |
|
| 693 | + $first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array); |
|
| 694 | + return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information'; |
|
| 695 | + } |
|
| 696 | + |
|
| 697 | + |
|
| 698 | + |
|
| 699 | + /** |
|
| 700 | + * _load_and_instantiate_reg_steps |
|
| 701 | + * instantiates each reg step based on the loaded reg_steps array |
|
| 702 | + * |
|
| 703 | + * @access private |
|
| 704 | + * @throws EE_Error |
|
| 705 | + * @return bool |
|
| 706 | + */ |
|
| 707 | + private function _load_and_instantiate_reg_steps() |
|
| 708 | + { |
|
| 709 | + // have reg_steps already been instantiated ? |
|
| 710 | + if ( |
|
| 711 | + empty($this->checkout->reg_steps) |
|
| 712 | + || apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout) |
|
| 713 | + ) { |
|
| 714 | + // if not, then loop through raw reg steps array |
|
| 715 | + foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) { |
|
| 716 | + if ( ! $this->_load_and_instantiate_reg_step($reg_step, $order)) { |
|
| 717 | + return false; |
|
| 718 | + } |
|
| 719 | + } |
|
| 720 | + EE_Registry::instance()->CFG->registration->skip_reg_confirmation = true; |
|
| 721 | + EE_Registry::instance()->CFG->registration->reg_confirmation_last = true; |
|
| 722 | + // skip the registration_confirmation page ? |
|
| 723 | + if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) { |
|
| 724 | + // just remove it from the reg steps array |
|
| 725 | + $this->checkout->remove_reg_step('registration_confirmation', false); |
|
| 726 | + } else if ( |
|
| 727 | + isset($this->checkout->reg_steps['registration_confirmation']) |
|
| 728 | + && EE_Registry::instance()->CFG->registration->reg_confirmation_last |
|
| 729 | + ) { |
|
| 730 | + // set the order to something big like 100 |
|
| 731 | + $this->checkout->set_reg_step_order('registration_confirmation', 100); |
|
| 732 | + } |
|
| 733 | + // filter the array for good luck |
|
| 734 | + $this->checkout->reg_steps = apply_filters( |
|
| 735 | + 'FHEE__Single_Page_Checkout__load_reg_steps__reg_steps', |
|
| 736 | + $this->checkout->reg_steps |
|
| 737 | + ); |
|
| 738 | + // finally re-sort based on the reg step class order properties |
|
| 739 | + $this->checkout->sort_reg_steps(); |
|
| 740 | + } else { |
|
| 741 | + foreach ($this->checkout->reg_steps as $reg_step) { |
|
| 742 | + // set all current step stati to FALSE |
|
| 743 | + $reg_step->set_is_current_step(false); |
|
| 744 | + } |
|
| 745 | + } |
|
| 746 | + if (empty($this->checkout->reg_steps)) { |
|
| 747 | + EE_Error::add_error(__('No Reg Steps were loaded..', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 748 | + return false; |
|
| 749 | + } |
|
| 750 | + // make reg step details available to JS |
|
| 751 | + $this->checkout->set_reg_step_JSON_info(); |
|
| 752 | + return true; |
|
| 753 | + } |
|
| 754 | + |
|
| 755 | + |
|
| 756 | + |
|
| 757 | + /** |
|
| 758 | + * _load_and_instantiate_reg_step |
|
| 759 | + * |
|
| 760 | + * @access private |
|
| 761 | + * @param array $reg_step |
|
| 762 | + * @param int $order |
|
| 763 | + * @return bool |
|
| 764 | + */ |
|
| 765 | + private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0) |
|
| 766 | + { |
|
| 767 | + // we need a file_path, class_name, and slug to add a reg step |
|
| 768 | + if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
| 769 | + // if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step) |
|
| 770 | + if ( |
|
| 771 | + $this->checkout->reg_url_link |
|
| 772 | + && $this->checkout->step !== $reg_step['slug'] |
|
| 773 | + && $reg_step['slug'] !== 'finalize_registration' |
|
| 774 | + ) { |
|
| 775 | + return true; |
|
| 776 | + } |
|
| 777 | + // instantiate step class using file path and class name |
|
| 778 | + $reg_step_obj = EE_Registry::instance()->load_file( |
|
| 779 | + $reg_step['file_path'], |
|
| 780 | + $reg_step['class_name'], |
|
| 781 | + 'class', |
|
| 782 | + $this->checkout, |
|
| 783 | + false |
|
| 784 | + ); |
|
| 785 | + // did we gets the goods ? |
|
| 786 | + if ($reg_step_obj instanceof EE_SPCO_Reg_Step) { |
|
| 787 | + // set reg step order based on config |
|
| 788 | + $reg_step_obj->set_order($order); |
|
| 789 | + // add instantiated reg step object to the master reg steps array |
|
| 790 | + $this->checkout->add_reg_step($reg_step_obj); |
|
| 791 | + } else { |
|
| 792 | + EE_Error::add_error( |
|
| 793 | + __('The current step could not be set.', 'event_espresso'), |
|
| 794 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 795 | + ); |
|
| 796 | + return false; |
|
| 797 | + } |
|
| 798 | + } else { |
|
| 799 | + if (WP_DEBUG) { |
|
| 800 | + EE_Error::add_error( |
|
| 801 | + sprintf( |
|
| 802 | + __('A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', 'event_espresso'), |
|
| 803 | + isset($reg_step['file_path']) ? $reg_step['file_path'] : '', |
|
| 804 | + isset($reg_step['class_name']) ? $reg_step['class_name'] : '', |
|
| 805 | + isset($reg_step['slug']) ? $reg_step['slug'] : '', |
|
| 806 | + '<ul>', |
|
| 807 | + '<li>', |
|
| 808 | + '</li>', |
|
| 809 | + '</ul>' |
|
| 810 | + ), |
|
| 811 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 812 | + ); |
|
| 813 | + } |
|
| 814 | + return false; |
|
| 815 | + } |
|
| 816 | + return true; |
|
| 817 | + } |
|
| 818 | + |
|
| 819 | + |
|
| 820 | + |
|
| 821 | + /** |
|
| 822 | + * _verify_transaction_and_get_registrations |
|
| 823 | + * |
|
| 824 | + * @access private |
|
| 825 | + * @return bool |
|
| 826 | + */ |
|
| 827 | + private function _verify_transaction_and_get_registrations() |
|
| 828 | + { |
|
| 829 | + // was there already a valid transaction in the checkout from the session ? |
|
| 830 | + if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
| 831 | + // get transaction from db or session |
|
| 832 | + $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin() |
|
| 833 | + ? $this->_get_transaction_and_cart_for_previous_visit() |
|
| 834 | + : $this->_get_cart_for_current_session_and_setup_new_transaction(); |
|
| 835 | + if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
| 836 | + EE_Error::add_error( |
|
| 837 | + __('Your Registration and Transaction information could not be retrieved from the db.', |
|
| 838 | + 'event_espresso'), |
|
| 839 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 840 | + ); |
|
| 841 | + $this->checkout->transaction = EE_Transaction::new_instance(); |
|
| 842 | + // add some style and make it dance |
|
| 843 | + $this->add_styles_and_scripts(); |
|
| 844 | + EED_Single_Page_Checkout::$_initialized = true; |
|
| 845 | + return false; |
|
| 846 | + } |
|
| 847 | + // and the registrations for the transaction |
|
| 848 | + $this->_get_registrations($this->checkout->transaction); |
|
| 849 | + } |
|
| 850 | + return true; |
|
| 851 | + } |
|
| 852 | + |
|
| 853 | + |
|
| 854 | + |
|
| 855 | + /** |
|
| 856 | + * _get_transaction_and_cart_for_previous_visit |
|
| 857 | + * |
|
| 858 | + * @access private |
|
| 859 | + * @return mixed EE_Transaction|NULL |
|
| 860 | + */ |
|
| 861 | + private function _get_transaction_and_cart_for_previous_visit() |
|
| 862 | + { |
|
| 863 | + /** @var $TXN_model EEM_Transaction */ |
|
| 864 | + $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
|
| 865 | + // because the reg_url_link is present in the request, this is a return visit to SPCO, so we'll get the transaction data from the db |
|
| 866 | + $transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link); |
|
| 867 | + // verify transaction |
|
| 868 | + if ($transaction instanceof EE_Transaction) { |
|
| 869 | + // and get the cart that was used for that transaction |
|
| 870 | + $this->checkout->cart = $this->_get_cart_for_transaction($transaction); |
|
| 871 | + return $transaction; |
|
| 872 | + } else { |
|
| 873 | + EE_Error::add_error(__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 874 | + return null; |
|
| 875 | + } |
|
| 876 | + } |
|
| 877 | + |
|
| 878 | + |
|
| 879 | + |
|
| 880 | + /** |
|
| 881 | + * _get_cart_for_transaction |
|
| 882 | + * |
|
| 883 | + * @access private |
|
| 884 | + * @param EE_Transaction $transaction |
|
| 885 | + * @return EE_Cart |
|
| 886 | + */ |
|
| 887 | + private function _get_cart_for_transaction($transaction) |
|
| 888 | + { |
|
| 889 | + return $this->checkout->get_cart_for_transaction($transaction); |
|
| 890 | + } |
|
| 891 | + |
|
| 892 | + |
|
| 893 | + |
|
| 894 | + /** |
|
| 895 | + * get_cart_for_transaction |
|
| 896 | + * |
|
| 897 | + * @access public |
|
| 898 | + * @param EE_Transaction $transaction |
|
| 899 | + * @return EE_Cart |
|
| 900 | + */ |
|
| 901 | + public function get_cart_for_transaction(EE_Transaction $transaction) |
|
| 902 | + { |
|
| 903 | + return $this->checkout->get_cart_for_transaction($transaction); |
|
| 904 | + } |
|
| 905 | + |
|
| 906 | + |
|
| 907 | + |
|
| 908 | + /** |
|
| 909 | + * _get_transaction_and_cart_for_current_session |
|
| 910 | + * generates a new EE_Transaction object and adds it to the $_transaction property. |
|
| 911 | + * |
|
| 912 | + * @access private |
|
| 913 | + * @return EE_Transaction |
|
| 914 | + * @throws \EE_Error |
|
| 915 | + */ |
|
| 916 | + private function _get_cart_for_current_session_and_setup_new_transaction() |
|
| 917 | + { |
|
| 918 | + // if there's no transaction, then this is the FIRST visit to SPCO |
|
| 919 | + // so load up the cart ( passing nothing for the TXN because it doesn't exist yet ) |
|
| 920 | + $this->checkout->cart = $this->_get_cart_for_transaction(null); |
|
| 921 | + // and then create a new transaction |
|
| 922 | + $transaction = $this->_initialize_transaction(); |
|
| 923 | + // verify transaction |
|
| 924 | + if ($transaction instanceof EE_Transaction) { |
|
| 925 | + // save it so that we have an ID for other objects to use |
|
| 926 | + $transaction->save(); |
|
| 927 | + // and save TXN data to the cart |
|
| 928 | + $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID()); |
|
| 929 | + } else { |
|
| 930 | + EE_Error::add_error(__('A Valid Transaction could not be initialized.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 931 | + } |
|
| 932 | + return $transaction; |
|
| 933 | + } |
|
| 934 | + |
|
| 935 | + |
|
| 936 | + |
|
| 937 | + /** |
|
| 938 | + * generates a new EE_Transaction object and adds it to the $_transaction property. |
|
| 939 | + * |
|
| 940 | + * @access private |
|
| 941 | + * @return mixed EE_Transaction|NULL |
|
| 942 | + */ |
|
| 943 | + private function _initialize_transaction() |
|
| 944 | + { |
|
| 945 | + try { |
|
| 946 | + // ensure cart totals have been calculated |
|
| 947 | + $this->checkout->cart->get_grand_total()->recalculate_total_including_taxes(); |
|
| 948 | + // grab the cart grand total |
|
| 949 | + $cart_total = $this->checkout->cart->get_cart_grand_total(); |
|
| 950 | + // create new TXN |
|
| 951 | + $transaction = EE_Transaction::new_instance( |
|
| 952 | + array( |
|
| 953 | + 'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(), |
|
| 954 | + 'TXN_total' => $cart_total > 0 ? $cart_total : 0, |
|
| 955 | + 'TXN_paid' => 0, |
|
| 956 | + 'STS_ID' => EEM_Transaction::failed_status_code, |
|
| 957 | + ) |
|
| 958 | + ); |
|
| 959 | + // save it so that we have an ID for other objects to use |
|
| 960 | + $transaction->save(); |
|
| 961 | + // set cron job for following up on TXNs after their session has expired |
|
| 962 | + EE_Cron_Tasks::schedule_expired_transaction_check( |
|
| 963 | + EE_Registry::instance()->SSN->expiration() + 1, |
|
| 964 | + $transaction->ID() |
|
| 965 | + ); |
|
| 966 | + return $transaction; |
|
| 967 | + } catch (Exception $e) { |
|
| 968 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
| 969 | + } |
|
| 970 | + return null; |
|
| 971 | + } |
|
| 972 | + |
|
| 973 | + |
|
| 974 | + |
|
| 975 | + /** |
|
| 976 | + * _get_registrations |
|
| 977 | + * |
|
| 978 | + * @access private |
|
| 979 | + * @param EE_Transaction $transaction |
|
| 980 | + * @return void |
|
| 981 | + * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
| 982 | + * @throws \EE_Error |
|
| 983 | + */ |
|
| 984 | + private function _get_registrations(EE_Transaction $transaction) |
|
| 985 | + { |
|
| 986 | + // first step: grab the registrants { : o |
|
| 987 | + $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, true); |
|
| 988 | + // verify registrations have been set |
|
| 989 | + if (empty($registrations)) { |
|
| 990 | + // if no cached registrations, then check the db |
|
| 991 | + $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false); |
|
| 992 | + // still nothing ? well as long as this isn't a revisit |
|
| 993 | + if (empty($registrations) && ! $this->checkout->revisit) { |
|
| 994 | + // generate new registrations from scratch |
|
| 995 | + $registrations = $this->_initialize_registrations($transaction); |
|
| 996 | + } |
|
| 997 | + } |
|
| 998 | + // sort by their original registration order |
|
| 999 | + usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count')); |
|
| 1000 | + // then loop thru the array |
|
| 1001 | + foreach ($registrations as $registration) { |
|
| 1002 | + // verify each registration |
|
| 1003 | + if ($registration instanceof EE_Registration) { |
|
| 1004 | + // we display all attendee info for the primary registrant |
|
| 1005 | + if ($this->checkout->reg_url_link === $registration->reg_url_link() |
|
| 1006 | + && $registration->is_primary_registrant() |
|
| 1007 | + ) { |
|
| 1008 | + $this->checkout->primary_revisit = true; |
|
| 1009 | + break; |
|
| 1010 | + } else if ($this->checkout->revisit |
|
| 1011 | + && $this->checkout->reg_url_link !== $registration->reg_url_link() |
|
| 1012 | + ) { |
|
| 1013 | + // but hide info if it doesn't belong to you |
|
| 1014 | + $transaction->clear_cache('Registration', $registration->ID()); |
|
| 1015 | + } |
|
| 1016 | + $this->checkout->set_reg_status_updated($registration->ID(), false); |
|
| 1017 | + } |
|
| 1018 | + } |
|
| 1019 | + } |
|
| 1020 | + |
|
| 1021 | + |
|
| 1022 | + |
|
| 1023 | + /** |
|
| 1024 | + * adds related EE_Registration objects for each ticket in the cart to the current EE_Transaction object |
|
| 1025 | + * |
|
| 1026 | + * @access private |
|
| 1027 | + * @param EE_Transaction $transaction |
|
| 1028 | + * @return array |
|
| 1029 | + * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
| 1030 | + * @throws \EE_Error |
|
| 1031 | + */ |
|
| 1032 | + private function _initialize_registrations(EE_Transaction $transaction) |
|
| 1033 | + { |
|
| 1034 | + $att_nmbr = 0; |
|
| 1035 | + $registrations = array(); |
|
| 1036 | + if ($transaction instanceof EE_Transaction) { |
|
| 1037 | + /** @type EE_Registration_Processor $registration_processor */ |
|
| 1038 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
| 1039 | + $this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count(); |
|
| 1040 | + // now let's add the cart items to the $transaction |
|
| 1041 | + foreach ($this->checkout->cart->get_tickets() as $line_item) { |
|
| 1042 | + //do the following for each ticket of this type they selected |
|
| 1043 | + for ($x = 1; $x <= $line_item->quantity(); $x++) { |
|
| 1044 | + $att_nmbr++; |
|
| 1045 | + /** @var EventEspresso\core\services\commands\registration\CreateRegistrationCommand $CreateRegistrationCommand */ |
|
| 1046 | + $CreateRegistrationCommand = EE_Registry::instance() |
|
| 1047 | + ->create( |
|
| 1048 | + 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
| 1049 | + array( |
|
| 1050 | + $transaction, |
|
| 1051 | + $line_item, |
|
| 1052 | + $att_nmbr, |
|
| 1053 | + $this->checkout->total_ticket_count, |
|
| 1054 | + ) |
|
| 1055 | + ); |
|
| 1056 | + // override capabilities for frontend registrations |
|
| 1057 | + if ( ! is_admin()) { |
|
| 1058 | + $CreateRegistrationCommand->setCapCheck( |
|
| 1059 | + new PublicCapabilities('', 'create_new_registration') |
|
| 1060 | + ); |
|
| 1061 | + } |
|
| 1062 | + $registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand); |
|
| 1063 | + if ( ! $registration instanceof EE_Registration) { |
|
| 1064 | + throw new InvalidEntityException($registration, 'EE_Registration'); |
|
| 1065 | + } |
|
| 1066 | + $registrations[ $registration->ID() ] = $registration; |
|
| 1067 | + } |
|
| 1068 | + } |
|
| 1069 | + $registration_processor->fix_reg_final_price_rounding_issue($transaction); |
|
| 1070 | + } |
|
| 1071 | + return $registrations; |
|
| 1072 | + } |
|
| 1073 | + |
|
| 1074 | + |
|
| 1075 | + |
|
| 1076 | + /** |
|
| 1077 | + * sorts registrations by REG_count |
|
| 1078 | + * |
|
| 1079 | + * @access public |
|
| 1080 | + * @param EE_Registration $reg_A |
|
| 1081 | + * @param EE_Registration $reg_B |
|
| 1082 | + * @return int |
|
| 1083 | + */ |
|
| 1084 | + public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B) |
|
| 1085 | + { |
|
| 1086 | + // this shouldn't ever happen within the same TXN, but oh well |
|
| 1087 | + if ($reg_A->count() === $reg_B->count()) { |
|
| 1088 | + return 0; |
|
| 1089 | + } |
|
| 1090 | + return ($reg_A->count() > $reg_B->count()) ? 1 : -1; |
|
| 1091 | + } |
|
| 1092 | + |
|
| 1093 | + |
|
| 1094 | + |
|
| 1095 | + /** |
|
| 1096 | + * _final_verifications |
|
| 1097 | + * just makes sure that everything is set up correctly before proceeding |
|
| 1098 | + * |
|
| 1099 | + * @access private |
|
| 1100 | + * @return bool |
|
| 1101 | + * @throws \EE_Error |
|
| 1102 | + */ |
|
| 1103 | + private function _final_verifications() |
|
| 1104 | + { |
|
| 1105 | + // filter checkout |
|
| 1106 | + $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___final_verifications__checkout', $this->checkout); |
|
| 1107 | + //verify that current step is still set correctly |
|
| 1108 | + if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) { |
|
| 1109 | + EE_Error::add_error( |
|
| 1110 | + __('We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', 'event_espresso'), |
|
| 1111 | + __FILE__, |
|
| 1112 | + __FUNCTION__, |
|
| 1113 | + __LINE__ |
|
| 1114 | + ); |
|
| 1115 | + return false; |
|
| 1116 | + } |
|
| 1117 | + // if returning to SPCO, then verify that primary registrant is set |
|
| 1118 | + if ( ! empty($this->checkout->reg_url_link)) { |
|
| 1119 | + $valid_registrant = $this->checkout->transaction->primary_registration(); |
|
| 1120 | + if ( ! $valid_registrant instanceof EE_Registration) { |
|
| 1121 | + EE_Error::add_error( |
|
| 1122 | + __('We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', 'event_espresso'), |
|
| 1123 | + __FILE__, |
|
| 1124 | + __FUNCTION__, |
|
| 1125 | + __LINE__ |
|
| 1126 | + ); |
|
| 1127 | + return false; |
|
| 1128 | + } |
|
| 1129 | + $valid_registrant = null; |
|
| 1130 | + foreach ($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration) { |
|
| 1131 | + if ( |
|
| 1132 | + $registration instanceof EE_Registration |
|
| 1133 | + && $registration->reg_url_link() === $this->checkout->reg_url_link |
|
| 1134 | + ) { |
|
| 1135 | + $valid_registrant = $registration; |
|
| 1136 | + } |
|
| 1137 | + } |
|
| 1138 | + if ( ! $valid_registrant instanceof EE_Registration) { |
|
| 1139 | + // hmmm... maybe we have the wrong session because the user is opening multiple tabs ? |
|
| 1140 | + if (EED_Single_Page_Checkout::$_checkout_verified) { |
|
| 1141 | + // clear the session, mark the checkout as unverified, and try again |
|
| 1142 | + EE_Registry::instance()->SSN->clear_session(); |
|
| 1143 | + EED_Single_Page_Checkout::$_initialized = false; |
|
| 1144 | + EED_Single_Page_Checkout::$_checkout_verified = false; |
|
| 1145 | + $this->_initialize(); |
|
| 1146 | + EE_Error::reset_notices(); |
|
| 1147 | + return false; |
|
| 1148 | + } |
|
| 1149 | + EE_Error::add_error( |
|
| 1150 | + __('We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.', 'event_espresso'), |
|
| 1151 | + __FILE__, |
|
| 1152 | + __FUNCTION__, |
|
| 1153 | + __LINE__ |
|
| 1154 | + ); |
|
| 1155 | + return false; |
|
| 1156 | + } |
|
| 1157 | + } |
|
| 1158 | + // now that things have been kinda sufficiently verified, |
|
| 1159 | + // let's add the checkout to the session so that's available other systems |
|
| 1160 | + EE_Registry::instance()->SSN->set_checkout($this->checkout); |
|
| 1161 | + return true; |
|
| 1162 | + } |
|
| 1163 | + |
|
| 1164 | + |
|
| 1165 | + |
|
| 1166 | + /** |
|
| 1167 | + * _initialize_reg_steps |
|
| 1168 | + * first makes sure that EE_Transaction_Processor::set_reg_step_initiated() is called as required |
|
| 1169 | + * then loops thru all of the active reg steps and calls the initialize_reg_step() method |
|
| 1170 | + * |
|
| 1171 | + * @access private |
|
| 1172 | + * @param bool $reinitializing |
|
| 1173 | + * @throws \EE_Error |
|
| 1174 | + */ |
|
| 1175 | + private function _initialize_reg_steps($reinitializing = false) |
|
| 1176 | + { |
|
| 1177 | + $this->checkout->set_reg_step_initiated($this->checkout->current_step); |
|
| 1178 | + // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS |
|
| 1179 | + foreach ($this->checkout->reg_steps as $reg_step) { |
|
| 1180 | + if ( ! $reg_step->initialize_reg_step()) { |
|
| 1181 | + // if not initialized then maybe this step is being removed... |
|
| 1182 | + if ( ! $reinitializing && $reg_step->is_current_step()) { |
|
| 1183 | + // if it was the current step, then we need to start over here |
|
| 1184 | + $this->_initialize_reg_steps(true); |
|
| 1185 | + return; |
|
| 1186 | + } |
|
| 1187 | + continue; |
|
| 1188 | + } |
|
| 1189 | + // add css and JS for current step |
|
| 1190 | + $reg_step->enqueue_styles_and_scripts(); |
|
| 1191 | + // i18n |
|
| 1192 | + $reg_step->translate_js_strings(); |
|
| 1193 | + if ($reg_step->is_current_step()) { |
|
| 1194 | + // the text that appears on the reg step form submit button |
|
| 1195 | + $reg_step->set_submit_button_text(); |
|
| 1196 | + } |
|
| 1197 | + } |
|
| 1198 | + // dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information |
|
| 1199 | + do_action("AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", $this->checkout->current_step); |
|
| 1200 | + } |
|
| 1201 | + |
|
| 1202 | + |
|
| 1203 | + |
|
| 1204 | + /** |
|
| 1205 | + * _check_form_submission |
|
| 1206 | + * |
|
| 1207 | + * @access private |
|
| 1208 | + * @return boolean |
|
| 1209 | + */ |
|
| 1210 | + private function _check_form_submission() |
|
| 1211 | + { |
|
| 1212 | + //does this request require the reg form to be generated ? |
|
| 1213 | + if ($this->checkout->generate_reg_form) { |
|
| 1214 | + // ever heard that song by Blue Rodeo ? |
|
| 1215 | + try { |
|
| 1216 | + $this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form(); |
|
| 1217 | + // if not displaying a form, then check for form submission |
|
| 1218 | + if ( |
|
| 1219 | + $this->checkout->process_form_submission |
|
| 1220 | + && $this->checkout->current_step->reg_form->was_submitted() |
|
| 1221 | + ) { |
|
| 1222 | + // clear out any old data in case this step is being run again |
|
| 1223 | + $this->checkout->current_step->set_valid_data(array()); |
|
| 1224 | + // capture submitted form data |
|
| 1225 | + $this->checkout->current_step->reg_form->receive_form_submission( |
|
| 1226 | + apply_filters('FHEE__Single_Page_Checkout___check_form_submission__request_params', EE_Registry::instance()->REQ->params(), $this->checkout) |
|
| 1227 | + ); |
|
| 1228 | + // validate submitted form data |
|
| 1229 | + if ( ! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) { |
|
| 1230 | + // thou shall not pass !!! |
|
| 1231 | + $this->checkout->continue_reg = false; |
|
| 1232 | + // any form validation errors? |
|
| 1233 | + if ($this->checkout->current_step->reg_form->submission_error_message() !== '') { |
|
| 1234 | + $submission_error_messages = array(); |
|
| 1235 | + // bad, bad, bad registrant |
|
| 1236 | + foreach ($this->checkout->current_step->reg_form->get_validation_errors_accumulated() as $validation_error) { |
|
| 1237 | + if ($validation_error instanceof EE_Validation_Error) { |
|
| 1238 | + $submission_error_messages[] = sprintf( |
|
| 1239 | + __('%s : %s', 'event_espresso'), |
|
| 1240 | + $validation_error->get_form_section()->html_label_text(), |
|
| 1241 | + $validation_error->getMessage() |
|
| 1242 | + ); |
|
| 1243 | + } |
|
| 1244 | + } |
|
| 1245 | + EE_Error::add_error(implode('<br />', $submission_error_messages), __FILE__, __FUNCTION__, __LINE__); |
|
| 1246 | + } |
|
| 1247 | + // well not really... what will happen is we'll just get redirected back to redo the current step |
|
| 1248 | + $this->go_to_next_step(); |
|
| 1249 | + return false; |
|
| 1250 | + } |
|
| 1251 | + } |
|
| 1252 | + } catch (EE_Error $e) { |
|
| 1253 | + $e->get_error(); |
|
| 1254 | + } |
|
| 1255 | + } |
|
| 1256 | + return true; |
|
| 1257 | + } |
|
| 1258 | + |
|
| 1259 | + |
|
| 1260 | + |
|
| 1261 | + /** |
|
| 1262 | + * _process_action |
|
| 1263 | + * |
|
| 1264 | + * @access private |
|
| 1265 | + * @return void |
|
| 1266 | + * @throws \EE_Error |
|
| 1267 | + */ |
|
| 1268 | + private function _process_form_action() |
|
| 1269 | + { |
|
| 1270 | + // what cha wanna do? |
|
| 1271 | + switch ($this->checkout->action) { |
|
| 1272 | + // AJAX next step reg form |
|
| 1273 | + case 'display_spco_reg_step' : |
|
| 1274 | + $this->checkout->redirect = false; |
|
| 1275 | + if (EE_Registry::instance()->REQ->ajax) { |
|
| 1276 | + $this->checkout->json_response->set_reg_step_html($this->checkout->current_step->display_reg_form()); |
|
| 1277 | + } |
|
| 1278 | + break; |
|
| 1279 | + default : |
|
| 1280 | + // meh... do one of those other steps first |
|
| 1281 | + if ( ! empty($this->checkout->action) && is_callable(array($this->checkout->current_step, $this->checkout->action))) { |
|
| 1282 | + // dynamically creates hook point like: AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step |
|
| 1283 | + do_action("AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step); |
|
| 1284 | + // call action on current step |
|
| 1285 | + if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) { |
|
| 1286 | + // good registrant, you get to proceed |
|
| 1287 | + if ( |
|
| 1288 | + $this->checkout->current_step->success_message() !== '' |
|
| 1289 | + && apply_filters( |
|
| 1290 | + 'FHEE__Single_Page_Checkout___process_form_action__display_success', |
|
| 1291 | + false |
|
| 1292 | + ) |
|
| 1293 | + ) { |
|
| 1294 | + EE_Error::add_success( |
|
| 1295 | + $this->checkout->current_step->success_message() |
|
| 1296 | + . '<br />' . $this->checkout->next_step->_instructions() |
|
| 1297 | + ); |
|
| 1298 | + } |
|
| 1299 | + // pack it up, pack it in... |
|
| 1300 | + $this->_setup_redirect(); |
|
| 1301 | + } |
|
| 1302 | + // dynamically creates hook point like: AHEE__Single_Page_Checkout__after_payment_options__process_reg_step |
|
| 1303 | + do_action("AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step); |
|
| 1304 | + } else { |
|
| 1305 | + EE_Error::add_error( |
|
| 1306 | + sprintf( |
|
| 1307 | + __('The requested form action "%s" does not exist for the current "%s" registration step.', 'event_espresso'), |
|
| 1308 | + $this->checkout->action, |
|
| 1309 | + $this->checkout->current_step->name() |
|
| 1310 | + ), |
|
| 1311 | + __FILE__, |
|
| 1312 | + __FUNCTION__, |
|
| 1313 | + __LINE__ |
|
| 1314 | + ); |
|
| 1315 | + } |
|
| 1316 | + // end default |
|
| 1317 | + } |
|
| 1318 | + // store our progress so far |
|
| 1319 | + $this->checkout->stash_transaction_and_checkout(); |
|
| 1320 | + // advance to the next step! If you pass GO, collect $200 |
|
| 1321 | + $this->go_to_next_step(); |
|
| 1322 | + } |
|
| 1323 | + |
|
| 1324 | + |
|
| 1325 | + |
|
| 1326 | + /** |
|
| 1327 | + * add_styles_and_scripts |
|
| 1328 | + * |
|
| 1329 | + * @access public |
|
| 1330 | + * @return void |
|
| 1331 | + */ |
|
| 1332 | + public function add_styles_and_scripts() |
|
| 1333 | + { |
|
| 1334 | + // i18n |
|
| 1335 | + $this->translate_js_strings(); |
|
| 1336 | + if ($this->checkout->admin_request) { |
|
| 1337 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
| 1338 | + } else { |
|
| 1339 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
| 1340 | + } |
|
| 1341 | + } |
|
| 1342 | + |
|
| 1343 | + |
|
| 1344 | + |
|
| 1345 | + /** |
|
| 1346 | + * translate_js_strings |
|
| 1347 | + * |
|
| 1348 | + * @access public |
|
| 1349 | + * @return void |
|
| 1350 | + */ |
|
| 1351 | + public function translate_js_strings() |
|
| 1352 | + { |
|
| 1353 | + EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit; |
|
| 1354 | + EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link; |
|
| 1355 | + EE_Registry::$i18n_js_strings['server_error'] = __('An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso'); |
|
| 1356 | + EE_Registry::$i18n_js_strings['invalid_json_response'] = __('An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso'); |
|
| 1357 | + EE_Registry::$i18n_js_strings['validation_error'] = __('There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', 'event_espresso'); |
|
| 1358 | + EE_Registry::$i18n_js_strings['invalid_payment_method'] = __('There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', 'event_espresso'); |
|
| 1359 | + EE_Registry::$i18n_js_strings['reg_step_error'] = __('This registration step could not be completed. Please refresh the page and try again.', 'event_espresso'); |
|
| 1360 | + EE_Registry::$i18n_js_strings['invalid_coupon'] = __('We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.', 'event_espresso'); |
|
| 1361 | + EE_Registry::$i18n_js_strings['process_registration'] = sprintf( |
|
| 1362 | + __('Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.', 'event_espresso'), |
|
| 1363 | + '<br/>', |
|
| 1364 | + '<br/>' |
|
| 1365 | + ); |
|
| 1366 | + EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language'); |
|
| 1367 | + EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id(); |
|
| 1368 | + EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency; |
|
| 1369 | + EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20'; |
|
| 1370 | + EE_Registry::$i18n_js_strings['timer_years'] = __('years', 'event_espresso'); |
|
| 1371 | + EE_Registry::$i18n_js_strings['timer_months'] = __('months', 'event_espresso'); |
|
| 1372 | + EE_Registry::$i18n_js_strings['timer_weeks'] = __('weeks', 'event_espresso'); |
|
| 1373 | + EE_Registry::$i18n_js_strings['timer_days'] = __('days', 'event_espresso'); |
|
| 1374 | + EE_Registry::$i18n_js_strings['timer_hours'] = __('hours', 'event_espresso'); |
|
| 1375 | + EE_Registry::$i18n_js_strings['timer_minutes'] = __('minutes', 'event_espresso'); |
|
| 1376 | + EE_Registry::$i18n_js_strings['timer_seconds'] = __('seconds', 'event_espresso'); |
|
| 1377 | + EE_Registry::$i18n_js_strings['timer_year'] = __('year', 'event_espresso'); |
|
| 1378 | + EE_Registry::$i18n_js_strings['timer_month'] = __('month', 'event_espresso'); |
|
| 1379 | + EE_Registry::$i18n_js_strings['timer_week'] = __('week', 'event_espresso'); |
|
| 1380 | + EE_Registry::$i18n_js_strings['timer_day'] = __('day', 'event_espresso'); |
|
| 1381 | + EE_Registry::$i18n_js_strings['timer_hour'] = __('hour', 'event_espresso'); |
|
| 1382 | + EE_Registry::$i18n_js_strings['timer_minute'] = __('minute', 'event_espresso'); |
|
| 1383 | + EE_Registry::$i18n_js_strings['timer_second'] = __('second', 'event_espresso'); |
|
| 1384 | + EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf( |
|
| 1385 | + __( |
|
| 1386 | + '%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s', |
|
| 1387 | + 'event_espresso' |
|
| 1388 | + ), |
|
| 1389 | + '<h4 class="important-notice">', |
|
| 1390 | + '</h4>', |
|
| 1391 | + '<br />', |
|
| 1392 | + '<p>', |
|
| 1393 | + '<a href="' . get_post_type_archive_link('espresso_events') . '" title="', |
|
| 1394 | + '">', |
|
| 1395 | + '</a>', |
|
| 1396 | + '</p>' |
|
| 1397 | + ); |
|
| 1398 | + EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters('FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', true); |
|
| 1399 | + EE_Registry::$i18n_js_strings['session_extension'] = absint( |
|
| 1400 | + apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS) |
|
| 1401 | + ); |
|
| 1402 | + EE_Registry::$i18n_js_strings['session_expiration'] = gmdate( |
|
| 1403 | + 'M d, Y H:i:s', EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS) |
|
| 1404 | + ); |
|
| 1405 | + } |
|
| 1406 | + |
|
| 1407 | + |
|
| 1408 | + |
|
| 1409 | + /** |
|
| 1410 | + * enqueue_styles_and_scripts |
|
| 1411 | + * |
|
| 1412 | + * @access public |
|
| 1413 | + * @return void |
|
| 1414 | + * @throws \EE_Error |
|
| 1415 | + */ |
|
| 1416 | + public function enqueue_styles_and_scripts() |
|
| 1417 | + { |
|
| 1418 | + // load css |
|
| 1419 | + wp_register_style('single_page_checkout', SPCO_CSS_URL . 'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 1420 | + wp_enqueue_style('single_page_checkout'); |
|
| 1421 | + // load JS |
|
| 1422 | + wp_register_script('jquery_plugin', EE_THIRD_PARTY_URL . 'jquery .plugin.min.js', array('jquery'), '1.0.1', true); |
|
| 1423 | + wp_register_script('jquery_countdown', EE_THIRD_PARTY_URL . 'jquery .countdown.min.js', array('jquery_plugin'), '2.0.2', true); |
|
| 1424 | + wp_register_script('single_page_checkout', SPCO_JS_URL . 'single_page_checkout.js', array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'), EVENT_ESPRESSO_VERSION, true); |
|
| 1425 | + if ($this->checkout->registration_form instanceof EE_Form_Section_Proper) { |
|
| 1426 | + $this->checkout->registration_form->enqueue_js(); |
|
| 1427 | + } |
|
| 1428 | + if ($this->checkout->current_step->reg_form instanceof EE_Form_Section_Proper) { |
|
| 1429 | + $this->checkout->current_step->reg_form->enqueue_js(); |
|
| 1430 | + } |
|
| 1431 | + wp_enqueue_script('single_page_checkout'); |
|
| 1432 | + /** |
|
| 1433 | + * global action hook for enqueueing styles and scripts with |
|
| 1434 | + * spco calls. |
|
| 1435 | + */ |
|
| 1436 | + do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this); |
|
| 1437 | + /** |
|
| 1438 | + * dynamic action hook for enqueueing styles and scripts with spco calls. |
|
| 1439 | + * The hook will end up being something like AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information |
|
| 1440 | + */ |
|
| 1441 | + do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(), $this); |
|
| 1442 | + } |
|
| 1443 | + |
|
| 1444 | + |
|
| 1445 | + |
|
| 1446 | + /** |
|
| 1447 | + * display the Registration Single Page Checkout Form |
|
| 1448 | + * |
|
| 1449 | + * @access private |
|
| 1450 | + * @return void |
|
| 1451 | + * @throws \EE_Error |
|
| 1452 | + */ |
|
| 1453 | + private function _display_spco_reg_form() |
|
| 1454 | + { |
|
| 1455 | + // if registering via the admin, just display the reg form for the current step |
|
| 1456 | + if ($this->checkout->admin_request) { |
|
| 1457 | + EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form()); |
|
| 1458 | + } else { |
|
| 1459 | + // add powered by EE msg |
|
| 1460 | + add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer')); |
|
| 1461 | + $empty_cart = count($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params)) < 1 |
|
| 1462 | + ? true |
|
| 1463 | + : false; |
|
| 1464 | + EE_Registry::$i18n_js_strings['empty_cart'] = $empty_cart; |
|
| 1465 | + $cookies_not_set_msg = ''; |
|
| 1466 | + if ($empty_cart && ! isset($_COOKIE['ee_cookie_test'])) { |
|
| 1467 | + $cookies_not_set_msg = apply_filters( |
|
| 1468 | + 'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg', |
|
| 1469 | + sprintf( |
|
| 1470 | + __( |
|
| 1471 | + '%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s', |
|
| 1472 | + 'event_espresso' |
|
| 1473 | + ), |
|
| 1474 | + '<div class="ee-attention">', |
|
| 1475 | + '</div>', |
|
| 1476 | + '<h6 class="important-notice">', |
|
| 1477 | + '</h6>', |
|
| 1478 | + '<p>', |
|
| 1479 | + '</p>', |
|
| 1480 | + '<br />', |
|
| 1481 | + '<a href="http://www.whatarecookies.com/enable.asp" target="_blank">', |
|
| 1482 | + '</a>' |
|
| 1483 | + ) |
|
| 1484 | + ); |
|
| 1485 | + } |
|
| 1486 | + $this->checkout->registration_form = new EE_Form_Section_Proper( |
|
| 1487 | + array( |
|
| 1488 | + 'name' => 'single-page-checkout', |
|
| 1489 | + 'html_id' => 'ee-single-page-checkout-dv', |
|
| 1490 | + 'layout_strategy' => |
|
| 1491 | + new EE_Template_Layout( |
|
| 1492 | + array( |
|
| 1493 | + 'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php', |
|
| 1494 | + 'template_args' => array( |
|
| 1495 | + 'empty_cart' => $empty_cart, |
|
| 1496 | + 'revisit' => $this->checkout->revisit, |
|
| 1497 | + 'reg_steps' => $this->checkout->reg_steps, |
|
| 1498 | + 'next_step' => $this->checkout->next_step instanceof EE_SPCO_Reg_Step |
|
| 1499 | + ? $this->checkout->next_step->slug() |
|
| 1500 | + : '', |
|
| 1501 | + 'cancel_page_url' => $this->checkout->cancel_page_url, |
|
| 1502 | + 'empty_msg' => apply_filters( |
|
| 1503 | + 'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg', |
|
| 1504 | + sprintf( |
|
| 1505 | + __('You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', |
|
| 1506 | + 'event_espresso'), |
|
| 1507 | + '<a href="' . get_post_type_archive_link('espresso_events') . '" title="', |
|
| 1508 | + '">', |
|
| 1509 | + '</a>' |
|
| 1510 | + ) |
|
| 1511 | + ), |
|
| 1512 | + 'cookies_not_set_msg' => $cookies_not_set_msg, |
|
| 1513 | + 'registration_time_limit' => $this->checkout->get_registration_time_limit(), |
|
| 1514 | + 'session_expiration' => |
|
| 1515 | + date('M d, Y H:i:s', EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS)), |
|
| 1516 | + ), |
|
| 1517 | + ) |
|
| 1518 | + ), |
|
| 1519 | + ) |
|
| 1520 | + ); |
|
| 1521 | + // load template and add to output sent that gets filtered into the_content() |
|
| 1522 | + EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html()); |
|
| 1523 | + } |
|
| 1524 | + } |
|
| 1525 | + |
|
| 1526 | + |
|
| 1527 | + |
|
| 1528 | + /** |
|
| 1529 | + * add_extra_finalize_registration_inputs |
|
| 1530 | + * |
|
| 1531 | + * @access public |
|
| 1532 | + * @param $next_step |
|
| 1533 | + * @internal param string $label |
|
| 1534 | + * @return void |
|
| 1535 | + */ |
|
| 1536 | + public function add_extra_finalize_registration_inputs($next_step) |
|
| 1537 | + { |
|
| 1538 | + if ($next_step === 'finalize_registration') { |
|
| 1539 | + echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>'; |
|
| 1540 | + } |
|
| 1541 | + } |
|
| 1542 | + |
|
| 1543 | + |
|
| 1544 | + |
|
| 1545 | + /** |
|
| 1546 | + * display_registration_footer |
|
| 1547 | + * |
|
| 1548 | + * @access public |
|
| 1549 | + * @return string |
|
| 1550 | + */ |
|
| 1551 | + public static function display_registration_footer() |
|
| 1552 | + { |
|
| 1553 | + if ( |
|
| 1554 | + apply_filters( |
|
| 1555 | + 'FHEE__EE_Front__Controller__show_reg_footer', |
|
| 1556 | + EE_Registry::instance()->CFG->admin->show_reg_footer |
|
| 1557 | + ) |
|
| 1558 | + ) { |
|
| 1559 | + add_filter( |
|
| 1560 | + 'FHEE__EEH_Template__powered_by_event_espresso__url', |
|
| 1561 | + function ($url) { |
|
| 1562 | + return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url); |
|
| 1563 | + } |
|
| 1564 | + ); |
|
| 1565 | + echo apply_filters( |
|
| 1566 | + 'FHEE__EE_Front_Controller__display_registration_footer', |
|
| 1567 | + \EEH_Template::powered_by_event_espresso( |
|
| 1568 | + '', |
|
| 1569 | + 'espresso-registration-footer-dv', |
|
| 1570 | + array('utm_content' => 'registration_checkout') |
|
| 1571 | + ) |
|
| 1572 | + ); |
|
| 1573 | + } |
|
| 1574 | + return ''; |
|
| 1575 | + } |
|
| 1576 | + |
|
| 1577 | + |
|
| 1578 | + |
|
| 1579 | + /** |
|
| 1580 | + * unlock_transaction |
|
| 1581 | + * |
|
| 1582 | + * @access public |
|
| 1583 | + * @return void |
|
| 1584 | + * @throws \EE_Error |
|
| 1585 | + */ |
|
| 1586 | + public function unlock_transaction() |
|
| 1587 | + { |
|
| 1588 | + if ($this->checkout->transaction instanceof EE_Transaction) { |
|
| 1589 | + $this->checkout->transaction->unlock(); |
|
| 1590 | + } |
|
| 1591 | + } |
|
| 1592 | + |
|
| 1593 | + |
|
| 1594 | + |
|
| 1595 | + /** |
|
| 1596 | + * _setup_redirect |
|
| 1597 | + * |
|
| 1598 | + * @access private |
|
| 1599 | + * @return void |
|
| 1600 | + */ |
|
| 1601 | + private function _setup_redirect() |
|
| 1602 | + { |
|
| 1603 | + if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
| 1604 | + $this->checkout->redirect = true; |
|
| 1605 | + if (empty($this->checkout->redirect_url)) { |
|
| 1606 | + $this->checkout->redirect_url = $this->checkout->next_step->reg_step_url(); |
|
| 1607 | + } |
|
| 1608 | + $this->checkout->redirect_url = apply_filters( |
|
| 1609 | + 'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', |
|
| 1610 | + $this->checkout->redirect_url, |
|
| 1611 | + $this->checkout |
|
| 1612 | + ); |
|
| 1613 | + } |
|
| 1614 | + } |
|
| 1615 | + |
|
| 1616 | + |
|
| 1617 | + |
|
| 1618 | + /** |
|
| 1619 | + * handle ajax message responses and redirects |
|
| 1620 | + * |
|
| 1621 | + * @access public |
|
| 1622 | + * @return void |
|
| 1623 | + * @throws \EE_Error |
|
| 1624 | + */ |
|
| 1625 | + public function go_to_next_step() |
|
| 1626 | + { |
|
| 1627 | + if (EE_Registry::instance()->REQ->ajax) { |
|
| 1628 | + // capture contents of output buffer we started earlier in the request, and insert into JSON response |
|
| 1629 | + $this->checkout->json_response->set_unexpected_errors(ob_get_clean()); |
|
| 1630 | + } |
|
| 1631 | + $this->unlock_transaction(); |
|
| 1632 | + // just return for these conditions |
|
| 1633 | + if ( |
|
| 1634 | + $this->checkout->admin_request |
|
| 1635 | + || $this->checkout->action === 'redirect_form' |
|
| 1636 | + || $this->checkout->action === 'update_checkout' |
|
| 1637 | + ) { |
|
| 1638 | + return; |
|
| 1639 | + } |
|
| 1640 | + // AJAX response |
|
| 1641 | + $this->_handle_json_response(); |
|
| 1642 | + // redirect to next step or the Thank You page |
|
| 1643 | + $this->_handle_html_redirects(); |
|
| 1644 | + // hmmm... must be something wrong, so let's just display the form again ! |
|
| 1645 | + $this->_display_spco_reg_form(); |
|
| 1646 | + } |
|
| 1647 | + |
|
| 1648 | + |
|
| 1649 | + |
|
| 1650 | + /** |
|
| 1651 | + * _handle_json_response |
|
| 1652 | + * |
|
| 1653 | + * @access protected |
|
| 1654 | + * @return void |
|
| 1655 | + */ |
|
| 1656 | + protected function _handle_json_response() |
|
| 1657 | + { |
|
| 1658 | + // if this is an ajax request |
|
| 1659 | + if (EE_Registry::instance()->REQ->ajax) { |
|
| 1660 | + // DEBUG LOG |
|
| 1661 | + //$this->checkout->log( |
|
| 1662 | + // __CLASS__, __FUNCTION__, __LINE__, |
|
| 1663 | + // array( |
|
| 1664 | + // 'json_response_redirect_url' => $this->checkout->json_response->redirect_url(), |
|
| 1665 | + // 'redirect' => $this->checkout->redirect, |
|
| 1666 | + // 'continue_reg' => $this->checkout->continue_reg, |
|
| 1667 | + // ) |
|
| 1668 | + //); |
|
| 1669 | + $this->checkout->json_response->set_registration_time_limit( |
|
| 1670 | + $this->checkout->get_registration_time_limit() |
|
| 1671 | + ); |
|
| 1672 | + $this->checkout->json_response->set_payment_amount($this->checkout->amount_owing); |
|
| 1673 | + // just send the ajax ( |
|
| 1674 | + $json_response = apply_filters( |
|
| 1675 | + 'FHEE__EE_Single_Page_Checkout__JSON_response', |
|
| 1676 | + $this->checkout->json_response |
|
| 1677 | + ); |
|
| 1678 | + echo $json_response; |
|
| 1679 | + exit(); |
|
| 1680 | + } |
|
| 1681 | + } |
|
| 1682 | + |
|
| 1683 | + |
|
| 1684 | + |
|
| 1685 | + /** |
|
| 1686 | + * _handle_redirects |
|
| 1687 | + * |
|
| 1688 | + * @access protected |
|
| 1689 | + * @return void |
|
| 1690 | + */ |
|
| 1691 | + protected function _handle_html_redirects() |
|
| 1692 | + { |
|
| 1693 | + // going somewhere ? |
|
| 1694 | + if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) { |
|
| 1695 | + // store notices in a transient |
|
| 1696 | + EE_Error::get_notices(false, true, true); |
|
| 1697 | + // DEBUG LOG |
|
| 1698 | + //$this->checkout->log( |
|
| 1699 | + // __CLASS__, __FUNCTION__, __LINE__, |
|
| 1700 | + // array( |
|
| 1701 | + // 'headers_sent' => headers_sent(), |
|
| 1702 | + // 'redirect_url' => $this->checkout->redirect_url, |
|
| 1703 | + // 'headers_list' => headers_list(), |
|
| 1704 | + // ) |
|
| 1705 | + //); |
|
| 1706 | + wp_safe_redirect($this->checkout->redirect_url); |
|
| 1707 | + exit(); |
|
| 1708 | + } |
|
| 1709 | + } |
|
| 1710 | + |
|
| 1711 | + |
|
| 1712 | + |
|
| 1713 | + /** |
|
| 1714 | + * set_checkout_anchor |
|
| 1715 | + * |
|
| 1716 | + * @access public |
|
| 1717 | + * @return void |
|
| 1718 | + */ |
|
| 1719 | + public function set_checkout_anchor() |
|
| 1720 | + { |
|
| 1721 | + echo '<a id="checkout" style="float: left; margin-left: -999em;"></a>'; |
|
| 1722 | + } |
|
| 1723 | 1723 | |
| 1724 | 1724 | |
| 1725 | 1725 | |
@@ -216,13 +216,13 @@ discard block |
||
| 216 | 216 | */ |
| 217 | 217 | public static function set_definitions() |
| 218 | 218 | { |
| 219 | - define('SPCO_BASE_PATH', rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS) . DS); |
|
| 220 | - define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css' . DS); |
|
| 221 | - define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img' . DS); |
|
| 222 | - define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js' . DS); |
|
| 223 | - define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS); |
|
| 224 | - define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS); |
|
| 225 | - define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS); |
|
| 219 | + define('SPCO_BASE_PATH', rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS).DS); |
|
| 220 | + define('SPCO_CSS_URL', plugin_dir_url(__FILE__).'css'.DS); |
|
| 221 | + define('SPCO_IMG_URL', plugin_dir_url(__FILE__).'img'.DS); |
|
| 222 | + define('SPCO_JS_URL', plugin_dir_url(__FILE__).'js'.DS); |
|
| 223 | + define('SPCO_INC_PATH', SPCO_BASE_PATH.'inc'.DS); |
|
| 224 | + define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH.'reg_steps'.DS); |
|
| 225 | + define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH.'templates'.DS); |
|
| 226 | 226 | EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true); |
| 227 | 227 | EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf( |
| 228 | 228 | __('%1$sWe\'re sorry, but you\'re registration time has expired.%2$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s', |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | '</h4>', |
| 232 | 232 | '<br />', |
| 233 | 233 | '<p>', |
| 234 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" title="', |
|
| 234 | + '<a href="'.get_post_type_archive_link('espresso_events').'" title="', |
|
| 235 | 235 | '">', |
| 236 | 236 | '</a>', |
| 237 | 237 | '</p>' |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | return; |
| 256 | 256 | } |
| 257 | 257 | // filter list of reg_steps |
| 258 | - $reg_steps_to_load = (array)apply_filters( |
|
| 258 | + $reg_steps_to_load = (array) apply_filters( |
|
| 259 | 259 | 'AHEE__SPCO__load_reg_steps__reg_steps_to_load', |
| 260 | 260 | EED_Single_Page_Checkout::get_reg_steps() |
| 261 | 261 | ); |
@@ -299,25 +299,25 @@ discard block |
||
| 299 | 299 | if (empty($reg_steps)) { |
| 300 | 300 | $reg_steps = array( |
| 301 | 301 | 10 => array( |
| 302 | - 'file_path' => SPCO_REG_STEPS_PATH . 'attendee_information', |
|
| 302 | + 'file_path' => SPCO_REG_STEPS_PATH.'attendee_information', |
|
| 303 | 303 | 'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information', |
| 304 | 304 | 'slug' => 'attendee_information', |
| 305 | 305 | 'has_hooks' => false, |
| 306 | 306 | ), |
| 307 | 307 | 20 => array( |
| 308 | - 'file_path' => SPCO_REG_STEPS_PATH . 'registration_confirmation', |
|
| 308 | + 'file_path' => SPCO_REG_STEPS_PATH.'registration_confirmation', |
|
| 309 | 309 | 'class_name' => 'EE_SPCO_Reg_Step_Registration_Confirmation', |
| 310 | 310 | 'slug' => 'registration_confirmation', |
| 311 | 311 | 'has_hooks' => false, |
| 312 | 312 | ), |
| 313 | 313 | 30 => array( |
| 314 | - 'file_path' => SPCO_REG_STEPS_PATH . 'payment_options', |
|
| 314 | + 'file_path' => SPCO_REG_STEPS_PATH.'payment_options', |
|
| 315 | 315 | 'class_name' => 'EE_SPCO_Reg_Step_Payment_Options', |
| 316 | 316 | 'slug' => 'payment_options', |
| 317 | 317 | 'has_hooks' => true, |
| 318 | 318 | ), |
| 319 | 319 | 999 => array( |
| 320 | - 'file_path' => SPCO_REG_STEPS_PATH . 'finalize_registration', |
|
| 320 | + 'file_path' => SPCO_REG_STEPS_PATH.'finalize_registration', |
|
| 321 | 321 | 'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration', |
| 322 | 322 | 'slug' => 'finalize_registration', |
| 323 | 323 | 'has_hooks' => false, |
@@ -499,7 +499,7 @@ discard block |
||
| 499 | 499 | // DEBUG LOG |
| 500 | 500 | //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
| 501 | 501 | // get reg form |
| 502 | - if( ! $this->_check_form_submission()) { |
|
| 502 | + if ( ! $this->_check_form_submission()) { |
|
| 503 | 503 | EED_Single_Page_Checkout::$_initialized = true; |
| 504 | 504 | return; |
| 505 | 505 | } |
@@ -1063,7 +1063,7 @@ discard block |
||
| 1063 | 1063 | if ( ! $registration instanceof EE_Registration) { |
| 1064 | 1064 | throw new InvalidEntityException($registration, 'EE_Registration'); |
| 1065 | 1065 | } |
| 1066 | - $registrations[ $registration->ID() ] = $registration; |
|
| 1066 | + $registrations[$registration->ID()] = $registration; |
|
| 1067 | 1067 | } |
| 1068 | 1068 | } |
| 1069 | 1069 | $registration_processor->fix_reg_final_price_rounding_issue($transaction); |
@@ -1293,7 +1293,7 @@ discard block |
||
| 1293 | 1293 | ) { |
| 1294 | 1294 | EE_Error::add_success( |
| 1295 | 1295 | $this->checkout->current_step->success_message() |
| 1296 | - . '<br />' . $this->checkout->next_step->_instructions() |
|
| 1296 | + . '<br />'.$this->checkout->next_step->_instructions() |
|
| 1297 | 1297 | ); |
| 1298 | 1298 | } |
| 1299 | 1299 | // pack it up, pack it in... |
@@ -1390,7 +1390,7 @@ discard block |
||
| 1390 | 1390 | '</h4>', |
| 1391 | 1391 | '<br />', |
| 1392 | 1392 | '<p>', |
| 1393 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" title="', |
|
| 1393 | + '<a href="'.get_post_type_archive_link('espresso_events').'" title="', |
|
| 1394 | 1394 | '">', |
| 1395 | 1395 | '</a>', |
| 1396 | 1396 | '</p>' |
@@ -1416,12 +1416,12 @@ discard block |
||
| 1416 | 1416 | public function enqueue_styles_and_scripts() |
| 1417 | 1417 | { |
| 1418 | 1418 | // load css |
| 1419 | - wp_register_style('single_page_checkout', SPCO_CSS_URL . 'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 1419 | + wp_register_style('single_page_checkout', SPCO_CSS_URL.'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 1420 | 1420 | wp_enqueue_style('single_page_checkout'); |
| 1421 | 1421 | // load JS |
| 1422 | - wp_register_script('jquery_plugin', EE_THIRD_PARTY_URL . 'jquery .plugin.min.js', array('jquery'), '1.0.1', true); |
|
| 1423 | - wp_register_script('jquery_countdown', EE_THIRD_PARTY_URL . 'jquery .countdown.min.js', array('jquery_plugin'), '2.0.2', true); |
|
| 1424 | - wp_register_script('single_page_checkout', SPCO_JS_URL . 'single_page_checkout.js', array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'), EVENT_ESPRESSO_VERSION, true); |
|
| 1422 | + wp_register_script('jquery_plugin', EE_THIRD_PARTY_URL.'jquery .plugin.min.js', array('jquery'), '1.0.1', true); |
|
| 1423 | + wp_register_script('jquery_countdown', EE_THIRD_PARTY_URL.'jquery .countdown.min.js', array('jquery_plugin'), '2.0.2', true); |
|
| 1424 | + wp_register_script('single_page_checkout', SPCO_JS_URL.'single_page_checkout.js', array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'), EVENT_ESPRESSO_VERSION, true); |
|
| 1425 | 1425 | if ($this->checkout->registration_form instanceof EE_Form_Section_Proper) { |
| 1426 | 1426 | $this->checkout->registration_form->enqueue_js(); |
| 1427 | 1427 | } |
@@ -1438,7 +1438,7 @@ discard block |
||
| 1438 | 1438 | * dynamic action hook for enqueueing styles and scripts with spco calls. |
| 1439 | 1439 | * The hook will end up being something like AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information |
| 1440 | 1440 | */ |
| 1441 | - do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(), $this); |
|
| 1441 | + do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__'.$this->checkout->current_step->slug(), $this); |
|
| 1442 | 1442 | } |
| 1443 | 1443 | |
| 1444 | 1444 | |
@@ -1490,7 +1490,7 @@ discard block |
||
| 1490 | 1490 | 'layout_strategy' => |
| 1491 | 1491 | new EE_Template_Layout( |
| 1492 | 1492 | array( |
| 1493 | - 'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php', |
|
| 1493 | + 'layout_template_file' => SPCO_TEMPLATES_PATH.'registration_page_wrapper.template.php', |
|
| 1494 | 1494 | 'template_args' => array( |
| 1495 | 1495 | 'empty_cart' => $empty_cart, |
| 1496 | 1496 | 'revisit' => $this->checkout->revisit, |
@@ -1504,7 +1504,7 @@ discard block |
||
| 1504 | 1504 | sprintf( |
| 1505 | 1505 | __('You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', |
| 1506 | 1506 | 'event_espresso'), |
| 1507 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" title="', |
|
| 1507 | + '<a href="'.get_post_type_archive_link('espresso_events').'" title="', |
|
| 1508 | 1508 | '">', |
| 1509 | 1509 | '</a>' |
| 1510 | 1510 | ) |
@@ -1558,7 +1558,7 @@ discard block |
||
| 1558 | 1558 | ) { |
| 1559 | 1559 | add_filter( |
| 1560 | 1560 | 'FHEE__EEH_Template__powered_by_event_espresso__url', |
| 1561 | - function ($url) { |
|
| 1561 | + function($url) { |
|
| 1562 | 1562 | return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url); |
| 1563 | 1563 | } |
| 1564 | 1564 | ); |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php if ( ! defined('ABSPATH')) { |
| 2 | - exit('No direct script access allowed'); |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | 3 | } |
| 4 | 4 | /* |
| 5 | 5 | Plugin Name: Event Espresso |
@@ -40,239 +40,239 @@ discard block |
||
| 40 | 40 | * @since 4.0 |
| 41 | 41 | */ |
| 42 | 42 | if (function_exists('espresso_version')) { |
| 43 | - /** |
|
| 44 | - * espresso_duplicate_plugin_error |
|
| 45 | - * displays if more than one version of EE is activated at the same time |
|
| 46 | - */ |
|
| 47 | - function espresso_duplicate_plugin_error() |
|
| 48 | - { |
|
| 49 | - ?> |
|
| 43 | + /** |
|
| 44 | + * espresso_duplicate_plugin_error |
|
| 45 | + * displays if more than one version of EE is activated at the same time |
|
| 46 | + */ |
|
| 47 | + function espresso_duplicate_plugin_error() |
|
| 48 | + { |
|
| 49 | + ?> |
|
| 50 | 50 | <div class="error"> |
| 51 | 51 | <p> |
| 52 | 52 | <?php echo esc_html__( |
| 53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
| 54 | - 'event_espresso' |
|
| 55 | - ); ?> |
|
| 53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
| 54 | + 'event_espresso' |
|
| 55 | + ); ?> |
|
| 56 | 56 | </p> |
| 57 | 57 | </div> |
| 58 | 58 | <?php |
| 59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 60 | - } |
|
| 59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
| 62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
| 63 | 63 | } else { |
| 64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
| 65 | - if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
| 66 | - /** |
|
| 67 | - * espresso_minimum_php_version_error |
|
| 68 | - * |
|
| 69 | - * @return void |
|
| 70 | - */ |
|
| 71 | - function espresso_minimum_php_version_error() |
|
| 72 | - { |
|
| 73 | - ?> |
|
| 64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
| 65 | + if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
| 66 | + /** |
|
| 67 | + * espresso_minimum_php_version_error |
|
| 68 | + * |
|
| 69 | + * @return void |
|
| 70 | + */ |
|
| 71 | + function espresso_minimum_php_version_error() |
|
| 72 | + { |
|
| 73 | + ?> |
|
| 74 | 74 | <div class="error"> |
| 75 | 75 | <p> |
| 76 | 76 | <?php |
| 77 | - printf( |
|
| 78 | - esc_html__( |
|
| 79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
| 80 | - 'event_espresso' |
|
| 81 | - ), |
|
| 82 | - EE_MIN_PHP_VER_REQUIRED, |
|
| 83 | - PHP_VERSION, |
|
| 84 | - '<br/>', |
|
| 85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
| 86 | - ); |
|
| 87 | - ?> |
|
| 77 | + printf( |
|
| 78 | + esc_html__( |
|
| 79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
| 80 | + 'event_espresso' |
|
| 81 | + ), |
|
| 82 | + EE_MIN_PHP_VER_REQUIRED, |
|
| 83 | + PHP_VERSION, |
|
| 84 | + '<br/>', |
|
| 85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
| 86 | + ); |
|
| 87 | + ?> |
|
| 88 | 88 | </p> |
| 89 | 89 | </div> |
| 90 | 90 | <?php |
| 91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 92 | - } |
|
| 91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
| 95 | - } else { |
|
| 96 | - /** |
|
| 97 | - * espresso_version |
|
| 98 | - * Returns the plugin version |
|
| 99 | - * |
|
| 100 | - * @return string |
|
| 101 | - */ |
|
| 102 | - function espresso_version() |
|
| 103 | - { |
|
| 104 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.26.rc.002'); |
|
| 105 | - } |
|
| 94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
| 95 | + } else { |
|
| 96 | + /** |
|
| 97 | + * espresso_version |
|
| 98 | + * Returns the plugin version |
|
| 99 | + * |
|
| 100 | + * @return string |
|
| 101 | + */ |
|
| 102 | + function espresso_version() |
|
| 103 | + { |
|
| 104 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.26.rc.002'); |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - // define versions |
|
| 108 | - define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
| 109 | - define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
| 110 | - define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
| 111 | - define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
| 112 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
| 113 | - //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
|
| 114 | - if ( ! defined('DS')) { |
|
| 115 | - define('DS', '/'); |
|
| 116 | - } |
|
| 117 | - if ( ! defined('PS')) { |
|
| 118 | - define('PS', PATH_SEPARATOR); |
|
| 119 | - } |
|
| 120 | - if ( ! defined('SP')) { |
|
| 121 | - define('SP', ' '); |
|
| 122 | - } |
|
| 123 | - if ( ! defined('EENL')) { |
|
| 124 | - define('EENL', "\n"); |
|
| 125 | - } |
|
| 126 | - define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
| 127 | - // define the plugin directory and URL |
|
| 128 | - define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 129 | - define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 130 | - define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 131 | - // main root folder paths |
|
| 132 | - define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
| 133 | - define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
| 134 | - define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
| 135 | - define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
| 136 | - define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
| 137 | - define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
| 138 | - define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
| 139 | - define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
| 140 | - // core system paths |
|
| 141 | - define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
| 142 | - define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
| 143 | - define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
| 144 | - define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
| 145 | - define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
| 146 | - define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
| 147 | - define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
| 148 | - define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
| 149 | - define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
| 150 | - define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
| 151 | - define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
| 152 | - define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
| 153 | - // gateways |
|
| 154 | - define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
| 155 | - define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
| 156 | - // asset URL paths |
|
| 157 | - define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
| 158 | - define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
| 159 | - define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
| 160 | - define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
| 161 | - define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
| 162 | - define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
| 163 | - // define upload paths |
|
| 164 | - $uploads = wp_upload_dir(); |
|
| 165 | - // define the uploads directory and URL |
|
| 166 | - define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
| 167 | - define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
| 168 | - // define the templates directory and URL |
|
| 169 | - define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
| 170 | - define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
| 171 | - // define the gateway directory and URL |
|
| 172 | - define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
| 173 | - define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
| 174 | - // languages folder/path |
|
| 175 | - define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
| 176 | - define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
| 177 | - //check for dompdf fonts in uploads |
|
| 178 | - if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
| 179 | - define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
| 180 | - } |
|
| 181 | - //ajax constants |
|
| 182 | - define( |
|
| 183 | - 'EE_FRONT_AJAX', |
|
| 184 | - isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
| 185 | - ); |
|
| 186 | - define( |
|
| 187 | - 'EE_ADMIN_AJAX', |
|
| 188 | - isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
| 189 | - ); |
|
| 190 | - //just a handy constant occasionally needed for finding values representing infinity in the DB |
|
| 191 | - //you're better to use this than its straight value (currently -1) in case you ever |
|
| 192 | - //want to change its default value! or find when -1 means infinity |
|
| 193 | - define('EE_INF_IN_DB', -1); |
|
| 194 | - define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
| 195 | - define('EE_DEBUG', false); |
|
| 196 | - /** |
|
| 197 | - * espresso_plugin_activation |
|
| 198 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
| 199 | - */ |
|
| 200 | - function espresso_plugin_activation() |
|
| 201 | - { |
|
| 202 | - update_option('ee_espresso_activation', true); |
|
| 203 | - } |
|
| 107 | + // define versions |
|
| 108 | + define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
| 109 | + define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
| 110 | + define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
| 111 | + define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
| 112 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
| 113 | + //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
|
| 114 | + if ( ! defined('DS')) { |
|
| 115 | + define('DS', '/'); |
|
| 116 | + } |
|
| 117 | + if ( ! defined('PS')) { |
|
| 118 | + define('PS', PATH_SEPARATOR); |
|
| 119 | + } |
|
| 120 | + if ( ! defined('SP')) { |
|
| 121 | + define('SP', ' '); |
|
| 122 | + } |
|
| 123 | + if ( ! defined('EENL')) { |
|
| 124 | + define('EENL', "\n"); |
|
| 125 | + } |
|
| 126 | + define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
| 127 | + // define the plugin directory and URL |
|
| 128 | + define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 129 | + define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 130 | + define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 131 | + // main root folder paths |
|
| 132 | + define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
| 133 | + define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
| 134 | + define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
| 135 | + define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
| 136 | + define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
| 137 | + define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
| 138 | + define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
| 139 | + define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
| 140 | + // core system paths |
|
| 141 | + define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
| 142 | + define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
| 143 | + define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
| 144 | + define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
| 145 | + define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
| 146 | + define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
| 147 | + define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
| 148 | + define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
| 149 | + define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
| 150 | + define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
| 151 | + define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
| 152 | + define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
| 153 | + // gateways |
|
| 154 | + define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
| 155 | + define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
| 156 | + // asset URL paths |
|
| 157 | + define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
| 158 | + define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
| 159 | + define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
| 160 | + define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
| 161 | + define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
| 162 | + define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
| 163 | + // define upload paths |
|
| 164 | + $uploads = wp_upload_dir(); |
|
| 165 | + // define the uploads directory and URL |
|
| 166 | + define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
| 167 | + define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
| 168 | + // define the templates directory and URL |
|
| 169 | + define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
| 170 | + define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
| 171 | + // define the gateway directory and URL |
|
| 172 | + define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
| 173 | + define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
| 174 | + // languages folder/path |
|
| 175 | + define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
| 176 | + define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
| 177 | + //check for dompdf fonts in uploads |
|
| 178 | + if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
| 179 | + define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
| 180 | + } |
|
| 181 | + //ajax constants |
|
| 182 | + define( |
|
| 183 | + 'EE_FRONT_AJAX', |
|
| 184 | + isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
| 185 | + ); |
|
| 186 | + define( |
|
| 187 | + 'EE_ADMIN_AJAX', |
|
| 188 | + isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
| 189 | + ); |
|
| 190 | + //just a handy constant occasionally needed for finding values representing infinity in the DB |
|
| 191 | + //you're better to use this than its straight value (currently -1) in case you ever |
|
| 192 | + //want to change its default value! or find when -1 means infinity |
|
| 193 | + define('EE_INF_IN_DB', -1); |
|
| 194 | + define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
| 195 | + define('EE_DEBUG', false); |
|
| 196 | + /** |
|
| 197 | + * espresso_plugin_activation |
|
| 198 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
| 199 | + */ |
|
| 200 | + function espresso_plugin_activation() |
|
| 201 | + { |
|
| 202 | + update_option('ee_espresso_activation', true); |
|
| 203 | + } |
|
| 204 | 204 | |
| 205 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
| 206 | - /** |
|
| 207 | - * espresso_load_error_handling |
|
| 208 | - * this function loads EE's class for handling exceptions and errors |
|
| 209 | - */ |
|
| 210 | - function espresso_load_error_handling() |
|
| 211 | - { |
|
| 212 | - // load debugging tools |
|
| 213 | - if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
| 214 | - require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
| 215 | - EEH_Debug_Tools::instance(); |
|
| 216 | - } |
|
| 217 | - // load error handling |
|
| 218 | - if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
| 219 | - require_once(EE_CORE . 'EE_Error.core.php'); |
|
| 220 | - } else { |
|
| 221 | - wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
| 222 | - } |
|
| 223 | - } |
|
| 205 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
| 206 | + /** |
|
| 207 | + * espresso_load_error_handling |
|
| 208 | + * this function loads EE's class for handling exceptions and errors |
|
| 209 | + */ |
|
| 210 | + function espresso_load_error_handling() |
|
| 211 | + { |
|
| 212 | + // load debugging tools |
|
| 213 | + if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
| 214 | + require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
| 215 | + EEH_Debug_Tools::instance(); |
|
| 216 | + } |
|
| 217 | + // load error handling |
|
| 218 | + if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
| 219 | + require_once(EE_CORE . 'EE_Error.core.php'); |
|
| 220 | + } else { |
|
| 221 | + wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
| 222 | + } |
|
| 223 | + } |
|
| 224 | 224 | |
| 225 | - /** |
|
| 226 | - * espresso_load_required |
|
| 227 | - * given a class name and path, this function will load that file or throw an exception |
|
| 228 | - * |
|
| 229 | - * @param string $classname |
|
| 230 | - * @param string $full_path_to_file |
|
| 231 | - * @throws EE_Error |
|
| 232 | - */ |
|
| 233 | - function espresso_load_required($classname, $full_path_to_file) |
|
| 234 | - { |
|
| 235 | - static $error_handling_loaded = false; |
|
| 236 | - if ( ! $error_handling_loaded) { |
|
| 237 | - espresso_load_error_handling(); |
|
| 238 | - $error_handling_loaded = true; |
|
| 239 | - } |
|
| 240 | - if (is_readable($full_path_to_file)) { |
|
| 241 | - require_once($full_path_to_file); |
|
| 242 | - } else { |
|
| 243 | - throw new EE_Error ( |
|
| 244 | - sprintf( |
|
| 245 | - esc_html__( |
|
| 246 | - 'The %s class file could not be located or is not readable due to file permissions.', |
|
| 247 | - 'event_espresso' |
|
| 248 | - ), |
|
| 249 | - $classname |
|
| 250 | - ) |
|
| 251 | - ); |
|
| 252 | - } |
|
| 253 | - } |
|
| 225 | + /** |
|
| 226 | + * espresso_load_required |
|
| 227 | + * given a class name and path, this function will load that file or throw an exception |
|
| 228 | + * |
|
| 229 | + * @param string $classname |
|
| 230 | + * @param string $full_path_to_file |
|
| 231 | + * @throws EE_Error |
|
| 232 | + */ |
|
| 233 | + function espresso_load_required($classname, $full_path_to_file) |
|
| 234 | + { |
|
| 235 | + static $error_handling_loaded = false; |
|
| 236 | + if ( ! $error_handling_loaded) { |
|
| 237 | + espresso_load_error_handling(); |
|
| 238 | + $error_handling_loaded = true; |
|
| 239 | + } |
|
| 240 | + if (is_readable($full_path_to_file)) { |
|
| 241 | + require_once($full_path_to_file); |
|
| 242 | + } else { |
|
| 243 | + throw new EE_Error ( |
|
| 244 | + sprintf( |
|
| 245 | + esc_html__( |
|
| 246 | + 'The %s class file could not be located or is not readable due to file permissions.', |
|
| 247 | + 'event_espresso' |
|
| 248 | + ), |
|
| 249 | + $classname |
|
| 250 | + ) |
|
| 251 | + ); |
|
| 252 | + } |
|
| 253 | + } |
|
| 254 | 254 | |
| 255 | - espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
| 256 | - espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
| 257 | - espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
| 258 | - new EE_Bootstrap(); |
|
| 259 | - } |
|
| 255 | + espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
| 256 | + espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
| 257 | + espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
| 258 | + new EE_Bootstrap(); |
|
| 259 | + } |
|
| 260 | 260 | } |
| 261 | 261 | if ( ! function_exists('espresso_deactivate_plugin')) { |
| 262 | - /** |
|
| 263 | - * deactivate_plugin |
|
| 264 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
| 265 | - * |
|
| 266 | - * @access public |
|
| 267 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
| 268 | - * @return void |
|
| 269 | - */ |
|
| 270 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
| 271 | - { |
|
| 272 | - if ( ! function_exists('deactivate_plugins')) { |
|
| 273 | - require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
| 274 | - } |
|
| 275 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
| 276 | - deactivate_plugins($plugin_basename); |
|
| 277 | - } |
|
| 262 | + /** |
|
| 263 | + * deactivate_plugin |
|
| 264 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
| 265 | + * |
|
| 266 | + * @access public |
|
| 267 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
| 268 | + * @return void |
|
| 269 | + */ |
|
| 270 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
| 271 | + { |
|
| 272 | + if ( ! function_exists('deactivate_plugins')) { |
|
| 273 | + require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
| 274 | + } |
|
| 275 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
| 276 | + deactivate_plugins($plugin_basename); |
|
| 277 | + } |
|
| 278 | 278 | } |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | * @param string $table_column |
| 16 | 16 | * @param string $nicename |
| 17 | 17 | * @param bool $nullable |
| 18 | - * @param null $default_value |
|
| 18 | + * @param string|null $default_value |
|
| 19 | 19 | */ |
| 20 | 20 | public function __construct($table_column, $nicename, $nullable, $default_value = null) |
| 21 | 21 | { |
@@ -11,28 +11,28 @@ |
||
| 11 | 11 | abstract class EE_DB_Only_Field_Base extends EE_Model_Field_Base |
| 12 | 12 | { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * @param string $table_column |
|
| 16 | - * @param string $nicename |
|
| 17 | - * @param bool $nullable |
|
| 18 | - * @param null $default_value |
|
| 19 | - */ |
|
| 20 | - public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
| 21 | - { |
|
| 22 | - parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
| 23 | - $this->setSchemaReadOnly(true); |
|
| 24 | - } |
|
| 14 | + /** |
|
| 15 | + * @param string $table_column |
|
| 16 | + * @param string $nicename |
|
| 17 | + * @param bool $nullable |
|
| 18 | + * @param null $default_value |
|
| 19 | + */ |
|
| 20 | + public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
| 21 | + { |
|
| 22 | + parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
| 23 | + $this->setSchemaReadOnly(true); |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * All these children classes are for the db-only (meaning, we should select them |
|
| 29 | - * on get_all queries, update, delete, and will still want to set their default value |
|
| 30 | - * on inserts, but the model object won't have reference to these fields) |
|
| 31 | - * |
|
| 32 | - * @return boolean |
|
| 33 | - */ |
|
| 34 | - function is_db_only_field() |
|
| 35 | - { |
|
| 36 | - return true; |
|
| 37 | - } |
|
| 27 | + /** |
|
| 28 | + * All these children classes are for the db-only (meaning, we should select them |
|
| 29 | + * on get_all queries, update, delete, and will still want to set their default value |
|
| 30 | + * on inserts, but the model object won't have reference to these fields) |
|
| 31 | + * |
|
| 32 | + * @return boolean |
|
| 33 | + */ |
|
| 34 | + function is_db_only_field() |
|
| 35 | + { |
|
| 36 | + return true; |
|
| 37 | + } |
|
| 38 | 38 | } |
| 39 | 39 | \ No newline at end of file |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | * @param string $table_column |
| 13 | 13 | * @param string $nicename |
| 14 | 14 | * @param bool $nullable |
| 15 | - * @param null $default_value |
|
| 15 | + * @param integer|null $default_value |
|
| 16 | 16 | */ |
| 17 | 17 | public function __construct($table_column, $nicename, $nullable, $default_value = null) |
| 18 | 18 | { |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | * So if you want to pass in a string that NEEDS to interpret periods as decimal marks, call floatval() on it first. |
| 28 | 28 | * Returns a float |
| 29 | 29 | * |
| 30 | - * @param type $value_inputted_for_field_on_model_object |
|
| 30 | + * @param string $value_inputted_for_field_on_model_object |
|
| 31 | 31 | * @return float |
| 32 | 32 | */ |
| 33 | 33 | function prepare_for_set($value_inputted_for_field_on_model_object) |
@@ -8,64 +8,64 @@ |
||
| 8 | 8 | class EE_Float_Field extends EE_Model_Field_Base |
| 9 | 9 | { |
| 10 | 10 | |
| 11 | - /** |
|
| 12 | - * @param string $table_column |
|
| 13 | - * @param string $nicename |
|
| 14 | - * @param bool $nullable |
|
| 15 | - * @param null $default_value |
|
| 16 | - */ |
|
| 17 | - public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
| 18 | - { |
|
| 19 | - parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
| 20 | - $this->setSchemaType('number'); |
|
| 21 | - } |
|
| 11 | + /** |
|
| 12 | + * @param string $table_column |
|
| 13 | + * @param string $nicename |
|
| 14 | + * @param bool $nullable |
|
| 15 | + * @param null $default_value |
|
| 16 | + */ |
|
| 17 | + public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
| 18 | + { |
|
| 19 | + parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
| 20 | + $this->setSchemaType('number'); |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * If provided a string, strips out number-related formatting, like commas, periods, spaces, other junk, etc. |
|
| 26 | - * However, treats commas and periods as thousand-separators ro decimal marks, as indicate by the config's currency. |
|
| 27 | - * So if you want to pass in a string that NEEDS to interpret periods as decimal marks, call floatval() on it first. |
|
| 28 | - * Returns a float |
|
| 29 | - * |
|
| 30 | - * @param type $value_inputted_for_field_on_model_object |
|
| 31 | - * @return float |
|
| 32 | - */ |
|
| 33 | - function prepare_for_set($value_inputted_for_field_on_model_object) |
|
| 34 | - { |
|
| 24 | + /** |
|
| 25 | + * If provided a string, strips out number-related formatting, like commas, periods, spaces, other junk, etc. |
|
| 26 | + * However, treats commas and periods as thousand-separators ro decimal marks, as indicate by the config's currency. |
|
| 27 | + * So if you want to pass in a string that NEEDS to interpret periods as decimal marks, call floatval() on it first. |
|
| 28 | + * Returns a float |
|
| 29 | + * |
|
| 30 | + * @param type $value_inputted_for_field_on_model_object |
|
| 31 | + * @return float |
|
| 32 | + */ |
|
| 33 | + function prepare_for_set($value_inputted_for_field_on_model_object) |
|
| 34 | + { |
|
| 35 | 35 | // echo __LINE__."$value_inputted_for_field_on_model_object<br>"; |
| 36 | - //remove whitespaces and thousands separators |
|
| 37 | - if (is_string($value_inputted_for_field_on_model_object)) { |
|
| 38 | - $value_inputted_for_field_on_model_object = str_replace(array(" ", EE_Config::instance()->currency->thsnds), |
|
| 39 | - "", $value_inputted_for_field_on_model_object); |
|
| 36 | + //remove whitespaces and thousands separators |
|
| 37 | + if (is_string($value_inputted_for_field_on_model_object)) { |
|
| 38 | + $value_inputted_for_field_on_model_object = str_replace(array(" ", EE_Config::instance()->currency->thsnds), |
|
| 39 | + "", $value_inputted_for_field_on_model_object); |
|
| 40 | 40 | //echo __LINE__."$value_inputted_for_field_on_model_object<br>"; |
| 41 | 41 | //normalize it so periods are decimal marks (we don't care where you're from: we're talking PHP now) |
| 42 | - $value_inputted_for_field_on_model_object = str_replace(EE_Config::instance()->currency->dec_mrk, ".", |
|
| 43 | - $value_inputted_for_field_on_model_object); |
|
| 42 | + $value_inputted_for_field_on_model_object = str_replace(EE_Config::instance()->currency->dec_mrk, ".", |
|
| 43 | + $value_inputted_for_field_on_model_object); |
|
| 44 | 44 | //echo __LINE__."$value_inputted_for_field_on_model_object<br>"; |
| 45 | 45 | //double-check there's absolutely nothing left on this string besides numbers |
| 46 | - $value_inputted_for_field_on_model_object = preg_replace("/[^0-9,.]/", "", |
|
| 47 | - $value_inputted_for_field_on_model_object); |
|
| 48 | - } |
|
| 46 | + $value_inputted_for_field_on_model_object = preg_replace("/[^0-9,.]/", "", |
|
| 47 | + $value_inputted_for_field_on_model_object); |
|
| 48 | + } |
|
| 49 | 49 | // echo __LINE__."$value_inputted_for_field_on_model_object<br>"; |
| 50 | - return floatval($value_inputted_for_field_on_model_object); |
|
| 51 | - } |
|
| 50 | + return floatval($value_inputted_for_field_on_model_object); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Returns the number formatted according to local custom (set by the country of the blog). |
|
| 55 | - * |
|
| 56 | - * @param float $value_on_field_to_be_outputted |
|
| 57 | - * @return string |
|
| 58 | - */ |
|
| 59 | - function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
| 60 | - { |
|
| 61 | - $EE = EE_Registry::instance(); |
|
| 62 | - return number_format($value_on_field_to_be_outputted, $EE->CFG->currency->dec_plc, $EE->CFG->currency->dec_mrk, |
|
| 63 | - $EE->CFG->currency->thsnds); |
|
| 64 | - } |
|
| 53 | + /** |
|
| 54 | + * Returns the number formatted according to local custom (set by the country of the blog). |
|
| 55 | + * |
|
| 56 | + * @param float $value_on_field_to_be_outputted |
|
| 57 | + * @return string |
|
| 58 | + */ |
|
| 59 | + function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
| 60 | + { |
|
| 61 | + $EE = EE_Registry::instance(); |
|
| 62 | + return number_format($value_on_field_to_be_outputted, $EE->CFG->currency->dec_plc, $EE->CFG->currency->dec_mrk, |
|
| 63 | + $EE->CFG->currency->thsnds); |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
| 67 | - { |
|
| 66 | + function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
| 67 | + { |
|
| 68 | 68 | // echo "prepare for set from db of ";d($value_found_in_db_for_model_object); |
| 69 | - return floatval($value_found_in_db_for_model_object); |
|
| 70 | - } |
|
| 69 | + return floatval($value_found_in_db_for_model_object); |
|
| 70 | + } |
|
| 71 | 71 | } |
| 72 | 72 | \ No newline at end of file |