Completed
Branch BUG-10246-use-wp-json-encode (aacd81)
by
unknown
23:44 queued 12:52
created
core/libraries/form_sections/base/EE_Model_Form_Section.form.php 1 patch
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  * @since                4.5.0
12 12
  *
13 13
  */
14
-class EE_Model_Form_Section extends EE_Form_Section_Proper{
14
+class EE_Model_Form_Section extends EE_Form_Section_Proper {
15 15
 
16 16
 	/**
17 17
 	 *
@@ -36,36 +36,36 @@  discard block
 block discarded – undo
36 36
 	 * }
37 37
 	 * @throws EE_Error
38 38
 	 */
39
-	public function __construct($options_array = array()){
40
-		if(isset($options_array['model']) && $options_array['model'] instanceof EEM_Base){
39
+	public function __construct($options_array = array()) {
40
+		if (isset($options_array['model']) && $options_array['model'] instanceof EEM_Base) {
41 41
 			$this->_model = $options_array['model'];
42 42
 		}
43
-		if( ! $this->_model || ! $this->_model instanceof EEM_Base ){
43
+		if ( ! $this->_model || ! $this->_model instanceof EEM_Base) {
44 44
 			throw new EE_Error(sprintf(__("Model Form Sections must first specify the _model property to be a subclass of EEM_Base", "event_espresso")));
45 45
 		}
46 46
 
47
-		if(isset($options_array['subsection_args'])){
47
+		if (isset($options_array['subsection_args'])) {
48 48
 			$subsection_args = $options_array['subsection_args'];
49
-		}else{
49
+		} else {
50 50
 			$subsection_args = array();
51 51
 		}
52 52
 
53 53
 		//gather fields and relations to convert to inputs
54 54
 		//but if they're just going to exclude a field anyways, don't bother converting it to an input
55 55
 		$exclude = $this->_subsections;
56
-		if(isset($options_array['exclude'])){
57
-			$exclude = array_merge($exclude,array_flip($options_array['exclude']));
56
+		if (isset($options_array['exclude'])) {
57
+			$exclude = array_merge($exclude, array_flip($options_array['exclude']));
58 58
 		}
59 59
 		$model_fields = array_diff_key($this->_model->field_settings(), $exclude);
60 60
 		$model_relations = array_diff_key($this->_model->relation_settings(), $exclude);
61 61
 		//convert fields and relations to inputs
62 62
 		$this->_subsections = array_merge(
63 63
 			$this->_convert_model_fields_to_inputs($model_fields),
64
-			$this->_convert_model_relations_to_inputs($model_relations,$subsection_args),
64
+			$this->_convert_model_relations_to_inputs($model_relations, $subsection_args),
65 65
 			$this->_subsections
66 66
 		);
67 67
 		parent::__construct($options_array);
68
-		if(isset($options_array['model_object']) && $options_array['model_object'] instanceof EE_Base_Class){
68
+		if (isset($options_array['model_object']) && $options_array['model_object'] instanceof EE_Base_Class) {
69 69
 			$this->populate_model_obj($options_array['model_object']);
70 70
 		}
71 71
 
@@ -83,9 +83,9 @@  discard block
 block discarded – undo
83 83
 	 * 	}
84 84
 	 * @return array
85 85
 	 */
86
-	protected function _convert_model_relations_to_inputs($relations,$subsection_args = array()){
86
+	protected function _convert_model_relations_to_inputs($relations, $subsection_args = array()) {
87 87
 		$inputs = array();
88
-		foreach( $relations as $relation_name => $relation_obj ) {
88
+		foreach ($relations as $relation_name => $relation_obj) {
89 89
 			$input_constructor_args = array(
90 90
 				array_merge(
91 91
 					array(
@@ -96,19 +96,19 @@  discard block
 block discarded – undo
96 96
 				)
97 97
 			);
98 98
 			$input = NULL;
99
-			switch(get_class($relation_obj)){
99
+			switch (get_class($relation_obj)) {
100 100
 				case 'EE_HABTM_Relation':
101
-					if(isset($subsection_args[$relation_name]) &&
102
-							isset($subsection_args[$relation_name]['model_objects'])){
101
+					if (isset($subsection_args[$relation_name]) &&
102
+							isset($subsection_args[$relation_name]['model_objects'])) {
103 103
 						$model_objects = $subsection_args[$relation_name]['model_objects'];
104
-					}else{
104
+					} else {
105 105
 						$model_objects = $relation_obj->get_other_model()->get_all();
106 106
 					}
107
-					$input = new EE_Select_Multi_Model_Input($model_objects,$input_constructor_args);
107
+					$input = new EE_Select_Multi_Model_Input($model_objects, $input_constructor_args);
108 108
 					break;
109 109
 				default:
110 110
 			}
111
-			if($input){
111
+			if ($input) {
112 112
 				$inputs[$relation_name] = $input;
113 113
 			}
114 114
 		}
@@ -123,10 +123,10 @@  discard block
 block discarded – undo
123 123
 	 * @throws EE_Error
124 124
 	 * @return EE_Form_Input_Base[]
125 125
 	 */
126
-	protected function _convert_model_fields_to_inputs( $model_fields = array() ){
126
+	protected function _convert_model_fields_to_inputs($model_fields = array()) {
127 127
 		$inputs = array();
128
-		foreach( $model_fields as $field_name=>$model_field ){
129
-			if ( $model_field instanceof EE_Model_Field_Base ) {
128
+		foreach ($model_fields as $field_name=>$model_field) {
129
+			if ($model_field instanceof EE_Model_Field_Base) {
130 130
 				$input_constructor_args = array(
131 131
 					array(
132 132
 						'required'=> ! $model_field->is_nullable() && $model_field->get_default_value() === NULL,
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 						'default'=>$model_field->get_default_value(),
135 135
 					)
136 136
 				);
137
-				switch(get_class($model_field)){
137
+				switch (get_class($model_field)) {
138 138
 					case 'EE_All_Caps_Text_Field':
139 139
 					case 'EE_Any_Foreign_Model_Name_Field':
140 140
 						$input_class = 'EE_Text_Input';
@@ -143,16 +143,16 @@  discard block
 block discarded – undo
143 143
 						$input_class = 'EE_Yes_No_Input';
144 144
 						break;
145 145
 					case 'EE_Datetime_Field':
146
-						throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field)));
146
+						throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field)));
147 147
 						break;
148 148
 					case 'EE_Email_Field':
149 149
 						$input_class = 'EE_Email_Input';
150 150
 						break;
151 151
 					case 'EE_Enum_Integer_Field':
152
-						throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field)));
152
+						throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field)));
153 153
 						break;
154 154
 					case 'EE_Enum_Text_Field':
155
-						throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field)));
155
+						throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field)));
156 156
 						break;
157 157
 					case 'EE_Float_Field':
158 158
 						$input_class = 'EE_Float_Input';
@@ -161,15 +161,15 @@  discard block
 block discarded – undo
161 161
 					case 'EE_Foreign_Key_String_Field':
162 162
 					case 'EE_WP_User_Field':
163 163
 						$models_pointed_to = $model_field instanceof EE_Field_With_Model_Name ? $model_field->get_model_class_names_pointed_to() : array();
164
-						if(true || is_array($models_pointed_to) && count($models_pointed_to) > 1){
164
+						if (true || is_array($models_pointed_to) && count($models_pointed_to) > 1) {
165 165
 							$input_class = 'EE_Text_Input';
166
-						}else{
166
+						} else {
167 167
 							//so its just one model
168 168
 							$model_name = is_array($models_pointed_to) ? reset($models_pointed_to) : $models_pointed_to;
169 169
 							$model = EE_Registry::instance()->load_model($model_name);
170 170
 							$model_names = $model->get_all_names(array('limit'=>10));
171
-							if($model_field->is_nullable()){
172
-								array_unshift( $model_names, __( "Please Select", 'event_espresso' ));
171
+							if ($model_field->is_nullable()) {
172
+								array_unshift($model_names, __("Please Select", 'event_espresso'));
173 173
 							}
174 174
 							$input_constructor_args[1] = $input_constructor_args[0];
175 175
 							$input_constructor_args[0] = $model_names;
@@ -178,10 +178,10 @@  discard block
 block discarded – undo
178 178
 						break;
179 179
 					case 'EE_Full_HTML_Field':
180 180
 						$input_class = 'EE_Text_Area_Input';
181
-						$input_constructor_args[ 0 ]['validation_strategies'] = array( new EE_Full_HTML_Validation_Strategy() );
181
+						$input_constructor_args[0]['validation_strategies'] = array(new EE_Full_HTML_Validation_Strategy());
182 182
 						break;
183 183
 					case 'EE_Infinite_Integer':
184
-						throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field)));
184
+						throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field)));
185 185
 						break;
186 186
 					case 'EE_Integer_Field':
187 187
 						$input_class = 'EE_Text_Input';
@@ -190,11 +190,11 @@  discard block
 block discarded – undo
190 190
 						$input_class = 'EE_Text_Area_Input';
191 191
 						break;
192 192
 					case 'EE_Money_Field':
193
-						throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field)));
193
+						throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field)));
194 194
 						break;
195 195
 					case 'EE_Post_Content_Field':
196 196
 						$input_class = 'EE_Text_Area_Input';
197
-						$input_constructor_args[ 0 ][ 'validation_strategies' ] = array( new EE_Full_HTML_Validation_Strategy() );
197
+						$input_constructor_args[0]['validation_strategies'] = array(new EE_Full_HTML_Validation_Strategy());
198 198
 						break;
199 199
 					case 'EE_Plain_Text_Field':
200 200
 						$input_class = 'EE_Text_Input';
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 						break;
212 212
 					case 'EE_Simple_HTML_Field':
213 213
 						$input_class = 'EE_Text_Area_Input';
214
-						$input_constructor_args[ 0 ][ 'validation_strategies' ] = array( new EE_Simple_HTML_Validation_Strategy() );
214
+						$input_constructor_args[0]['validation_strategies'] = array(new EE_Simple_HTML_Validation_Strategy());
215 215
 						break;
216 216
 					case 'EE_Slug_Field':
217 217
 						$input_class = 'EE_Text_Input';
@@ -220,13 +220,13 @@  discard block
 block discarded – undo
220 220
 						$input_class = 'EE_Yes_No_Input';
221 221
 						break;
222 222
 					case 'EE_WP_Post_Status_Field':
223
-						throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field)));
223
+						throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field)));
224 224
 						break;
225 225
 					case 'EE_WP_Post_Type_Field':
226
-						throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field)));
226
+						throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field)));
227 227
 						break;
228 228
 					default:
229
-						throw new EE_Error(sprintf(__("Model field of type '%s' does not convert to any known Form Input. Please add a case to EE_Model_Form_section's _convert_model_fields_to_inputs switch statement", "event_espresso"),get_class($model_field)));
229
+						throw new EE_Error(sprintf(__("Model field of type '%s' does not convert to any known Form Input. Please add a case to EE_Model_Form_section's _convert_model_fields_to_inputs switch statement", "event_espresso"), get_class($model_field)));
230 230
 				}
231 231
 				$reflection = new ReflectionClass($input_class);
232 232
 				$input = $reflection->newInstanceArgs($input_constructor_args);
@@ -245,21 +245,21 @@  discard block
 block discarded – undo
245 245
 	 * @param EE_Base_Class $model_obj
246 246
 	 * @return void
247 247
 	 */
248
-	public function populate_model_obj($model_obj){
248
+	public function populate_model_obj($model_obj) {
249 249
 		$model_obj = $this->_model->ensure_is_obj($model_obj);
250 250
 		$this->_model_object = $model_obj;
251 251
 		$defaults = $model_obj->model_field_array();
252
-		foreach($this->_model->relation_settings() as $relation_name => $relation_obj){
252
+		foreach ($this->_model->relation_settings() as $relation_name => $relation_obj) {
253 253
 			$form_inputs = $this->inputs();
254
-			if(isset($form_inputs[$relation_name])){
255
-				if($relation_obj instanceof EE_Belongs_To_Relation){
254
+			if (isset($form_inputs[$relation_name])) {
255
+				if ($relation_obj instanceof EE_Belongs_To_Relation) {
256 256
 					//then we only expect there to be one
257 257
 					$related_item = $this->_model_object->get_first_related($relation_name);
258 258
 					$defaults[$relation_name] = $related_item->ID();
259
-				}else{
259
+				} else {
260 260
 					$related_items = $this->_model_object->get_many_related($relation_name);
261 261
 					$ids = array();
262
-					foreach($related_items as $related_item){
262
+					foreach ($related_items as $related_item) {
263 263
 						$ids[] = $related_item->ID();
264 264
 					}
265 265
 					$defaults[$relation_name] = $ids;
@@ -281,8 +281,8 @@  discard block
 block discarded – undo
281 281
 	 * values are their normalized values
282 282
 	 * @return array
283 283
 	 */
284
-	public function inputs_values_corresponding_to_model_fields(){
285
-		return array_intersect_key($this->input_values(),$this->_model->field_settings());
284
+	public function inputs_values_corresponding_to_model_fields() {
285
+		return array_intersect_key($this->input_values(), $this->_model->field_settings());
286 286
 	}
287 287
 
288 288
 
@@ -293,17 +293,17 @@  discard block
 block discarded – undo
293 293
 	 * @param array $req_data should usually be $_REQUEST (the default).
294 294
 	 * @return void
295 295
 	 */	
296
-	public function _normalize( $req_data ) {
297
-		parent::_normalize( $req_data );
296
+	public function _normalize($req_data) {
297
+		parent::_normalize($req_data);
298 298
 		//create or set the model object, if it isn't already
299
-		if( ! $this->_model_object ){
299
+		if ( ! $this->_model_object) {
300 300
 			//check to see if the form indicates a PK, in which case we want to only retrieve it and update it
301 301
 			$pk_name = $this->_model->primary_key_name();
302 302
 			$model_obj = $this->_model->get_one_by_ID($this->get_input_value($pk_name));
303
-			if($model_obj){
303
+			if ($model_obj) {
304 304
 				$this->_model_object = $model_obj;
305
-			}else{
306
-				$this->_model_object = EE_Registry::instance()->load_class($this->_model->get_this_model_name() );
305
+			} else {
306
+				$this->_model_object = EE_Registry::instance()->load_class($this->_model->get_this_model_name());
307 307
 			}
308 308
 		}
309 309
 	}
@@ -318,24 +318,24 @@  discard block
 block discarded – undo
318 318
 	 * @return int, 1 on a successful update, the ID of
319 319
 	 *                    the new entry on insert; 0 on failure
320 320
 	 */
321
-	public function save(){
322
-		if( ! $this->_model_object){
323
-			throw new EE_Error(sprintf(__("Cannot save the model form's model object (model is '%s') because there is no model object set. You must either set it, or call receive_form_submission where it is set automatically", "event_espresso"),get_class($this->_model)));
321
+	public function save() {
322
+		if ( ! $this->_model_object) {
323
+			throw new EE_Error(sprintf(__("Cannot save the model form's model object (model is '%s') because there is no model object set. You must either set it, or call receive_form_submission where it is set automatically", "event_espresso"), get_class($this->_model)));
324 324
 		}
325 325
 		//ok so the model object is set. Just set it with the submitted form data
326
-		foreach($this->inputs_values_corresponding_to_model_fields() as $field_name=>$field_value){
326
+		foreach ($this->inputs_values_corresponding_to_model_fields() as $field_name=>$field_value) {
327 327
 			//only set the non-primary key
328
-			if($field_name != $this->_model->primary_key_name()){
329
-				$this->_model_object->set($field_name,$field_value);
328
+			if ($field_name != $this->_model->primary_key_name()) {
329
+				$this->_model_object->set($field_name, $field_value);
330 330
 			}
331 331
 		}
332
-		$success =  $this->_model_object->save();
333
-		foreach($this->_model->relation_settings() as $relation_name => $relation_obj){
334
-			if(isset($this->_subsections[$relation_name])){
332
+		$success = $this->_model_object->save();
333
+		foreach ($this->_model->relation_settings() as $relation_name => $relation_obj) {
334
+			if (isset($this->_subsections[$relation_name])) {
335 335
 				$success = $this->_save_related_info($relation_name);
336 336
 			}
337 337
 		}
338
-		do_action( 'AHEE__EE_Model_Form_Section__save__done', $this, $success );
338
+		do_action('AHEE__EE_Model_Form_Section__save__done', $this, $success);
339 339
 		return $success;
340 340
 	}
341 341
 
@@ -348,29 +348,29 @@  discard block
 block discarded – undo
348 348
 	 * @return bool
349 349
 	 * @throws EE_Error
350 350
 	 */
351
-	protected function _save_related_info($relation_name){
351
+	protected function _save_related_info($relation_name) {
352 352
 		$relation_obj = $this->_model->related_settings_for($relation_name);
353
-		if($relation_obj instanceof EE_Belongs_To_Relation){
353
+		if ($relation_obj instanceof EE_Belongs_To_Relation) {
354 354
 			//there is just a foreign key on this model pointing to that one
355 355
 			$this->_model_object->_add_relation_to($this->get_input_value($relation_name), $relation_name);
356
-		}elseif($relation_obj instanceof EE_Has_Many_Relation){
356
+		}elseif ($relation_obj instanceof EE_Has_Many_Relation) {
357 357
 			//then we want to consider all of its currently-related things.
358 358
 			//if they're in this list, keep them
359 359
 			//if they're not in this list, remove them
360 360
 			//and lastly add all the new items
361 361
 			throw new EE_Error(sprintf(__('Automatic saving of related info across a "has many" relation is not yet supported', "event_espresso")));
362
-		}elseif($relation_obj instanceof EE_HABTM_Relation){
362
+		}elseif ($relation_obj instanceof EE_HABTM_Relation) {
363 363
 			//delete everything NOT in this list
364 364
 			$normalized_input_value = $this->get_input_value($relation_name);
365
-			if($normalized_input_value && is_array($normalized_input_value)){
365
+			if ($normalized_input_value && is_array($normalized_input_value)) {
366 366
 				$where_query_params = array(
367
-					$relation_obj->get_other_model()->primary_key_name() => array('NOT_IN',$normalized_input_value));
368
-			}else{
367
+					$relation_obj->get_other_model()->primary_key_name() => array('NOT_IN', $normalized_input_value));
368
+			} else {
369 369
 				$where_query_params = array();
370 370
 			}
371
-			$this->_model_object->_remove_relations( $relation_name, $where_query_params );
372
-			foreach($normalized_input_value as $id){
373
-				$this->_model_object->_add_relation_to( $id, $relation_name );
371
+			$this->_model_object->_remove_relations($relation_name, $where_query_params);
372
+			foreach ($normalized_input_value as $id) {
373
+				$this->_model_object->_add_relation_to($id, $relation_name);
374 374
 			}
375 375
 		}
376 376
 		return TRUE;
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 	 * Gets the model of this model form
383 383
 	 * @return EEM_Base
384 384
 	 */
385
-	public function get_model(){
385
+	public function get_model() {
386 386
 		return $this->_model;
387 387
 	}
388 388
 
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 	 * when receive_form_submission($req_data) was called.
396 396
 	 * @return EE_Base_Class
397 397
 	 */
398
-	public function get_model_object(){
398
+	public function get_model_object() {
399 399
 		return $this->_model_object;
400 400
 	}
401 401
 
@@ -405,10 +405,10 @@  discard block
 block discarded – undo
405 405
 	 * gets teh default name of this form section if none is specified
406 406
 	 * @return string
407 407
 	 */
408
-	protected function _set_default_name_if_empty(){
409
-		if( ! $this->_name ){
410
-			$default_name = str_replace("EEM_", "", get_class($this->_model)) . "_Model_Form";
411
-			$this->_name =  $default_name;
408
+	protected function _set_default_name_if_empty() {
409
+		if ( ! $this->_name) {
410
+			$default_name = str_replace("EEM_", "", get_class($this->_model))."_Model_Form";
411
+			$this->_name = $default_name;
412 412
 		}
413 413
 	}
414 414
 
Please login to merge, or discard this patch.
admin_pages/payments/Payments_Admin_Page.core.php 1 patch
Spacing   +173 added lines, -173 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
3 3
 	exit('NO direct script access allowed');
4 4
 
5 5
 /**
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
 	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
45 45
 	 * @return \Payments_Admin_Page
46 46
 	 */
47
-	public function __construct( $routing = TRUE ) {
48
-		parent::__construct( $routing );
47
+	public function __construct($routing = TRUE) {
48
+		parent::__construct($routing);
49 49
 	}
50 50
 
51 51
 
@@ -130,19 +130,19 @@  discard block
 block discarded – undo
130 130
 	protected function _set_page_config() {
131 131
 		$payment_method_list_config = array(
132 132
 			'nav'           => array(
133
-				'label' => __( 'Payment Methods', 'event_espresso' ),
133
+				'label' => __('Payment Methods', 'event_espresso'),
134 134
 				'order' => 10
135 135
 			),
136 136
 			'metaboxes'     => $this->_default_espresso_metaboxes,
137 137
 			'help_tabs'     => array_merge(
138 138
 				array(
139 139
 					'payment_methods_overview_help_tab' => array(
140
-						'title'    => __( 'Payment Methods Overview', 'event_espresso' ),
140
+						'title'    => __('Payment Methods Overview', 'event_espresso'),
141 141
 						'filename' => 'payment_methods_overview'
142 142
 					)
143 143
 				),
144 144
 				$this->_add_payment_method_help_tabs() ),
145
-			'help_tour'     => array( 'Payment_Methods_Selection_Help_Tour' ),
145
+			'help_tour'     => array('Payment_Methods_Selection_Help_Tour'),
146 146
 			'require_nonce' => false
147 147
 		);
148 148
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 					)
161 161
 				),
162 162
 				//'help_tour' => array( 'Payment_Methods_Settings_Help_Tour' ),
163
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ),
163
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
164 164
 				'require_nonce' => FALSE
165 165
 			),
166 166
 			'payment_log'=>array(
@@ -179,17 +179,17 @@  discard block
 block discarded – undo
179 179
 	/**
180 180
 	 * @return array
181 181
 	 */
182
-	protected function _add_payment_method_help_tabs(){
182
+	protected function _add_payment_method_help_tabs() {
183 183
 		EE_Registry::instance()->load_lib('Payment_Method_Manager');
184 184
 		$payment_method_types = EE_Payment_Method_Manager::instance()->payment_method_types();
185 185
 		$all_pmt_help_tabs_config = array();
186
-		foreach( $payment_method_types as $payment_method_type ){
187
-			if ( ! EE_Registry::instance()->CAP->current_user_can( $payment_method_type->cap_name(), 'specific_payment_method_type_access' ) ) {
186
+		foreach ($payment_method_types as $payment_method_type) {
187
+			if ( ! EE_Registry::instance()->CAP->current_user_can($payment_method_type->cap_name(), 'specific_payment_method_type_access')) {
188 188
 				continue;
189 189
 			}
190
-			foreach( $payment_method_type->help_tabs_config() as $help_tab_name => $config ){
191
-				$template_args = isset( $config[ 'template_args' ] ) ? $config[ 'template_args' ] : array();
192
-				$template_args[ 'admin_page_obj' ] = $this;
190
+			foreach ($payment_method_type->help_tabs_config() as $help_tab_name => $config) {
191
+				$template_args = isset($config['template_args']) ? $config['template_args'] : array();
192
+				$template_args['admin_page_obj'] = $this;
193 193
 				$all_pmt_help_tabs_config[$help_tab_name] = array(
194 194
 					'title'=>$config['title'],
195 195
 					'content'=>EEH_Template::display_template(
@@ -216,9 +216,9 @@  discard block
 block discarded – undo
216 216
 
217 217
 
218 218
 	public function load_scripts_styles() {
219
-		wp_enqueue_script( 'ee_admin_js' );
220
-		wp_enqueue_script( 'ee-text-links' );
221
-		wp_enqueue_script( 'espresso_payments', EE_PAYMENTS_ASSETS_URL . 'espresso_payments_admin.js', array( 'espresso-ui-theme', 'ee-datepicker' ), EVENT_ESPRESSO_VERSION, TRUE );
219
+		wp_enqueue_script('ee_admin_js');
220
+		wp_enqueue_script('ee-text-links');
221
+		wp_enqueue_script('espresso_payments', EE_PAYMENTS_ASSETS_URL.'espresso_payments_admin.js', array('espresso-ui-theme', 'ee-datepicker'), EVENT_ESPRESSO_VERSION, TRUE);
222 222
 	}
223 223
 
224 224
 
@@ -227,9 +227,9 @@  discard block
 block discarded – undo
227 227
 
228 228
 	public function load_scripts_styles_default() {
229 229
 		//styles
230
-		wp_register_style( 'espresso_payments', EE_PAYMENTS_ASSETS_URL . 'ee-payments.css', array(), EVENT_ESPRESSO_VERSION );
231
-		wp_enqueue_style( 'espresso_payments' );
232
-		wp_enqueue_style( 'ee-text-links' );
230
+		wp_register_style('espresso_payments', EE_PAYMENTS_ASSETS_URL.'ee-payments.css', array(), EVENT_ESPRESSO_VERSION);
231
+		wp_enqueue_style('espresso_payments');
232
+		wp_enqueue_style('ee-text-links');
233 233
 		//scripts
234 234
 	}
235 235
 
@@ -243,44 +243,44 @@  discard block
 block discarded – undo
243 243
 		 * to the loading process.  However, people MUST setup the details for the payment method so its safe to do a
244 244
 		 * recheck here.
245 245
 		 */
246
-		EE_Registry::instance()->load_lib( 'Payment_Method_Manager' );
246
+		EE_Registry::instance()->load_lib('Payment_Method_Manager');
247 247
 		EEM_Payment_Method::instance()->verify_button_urls();
248 248
 		//setup tabs, one for each payment method type
249 249
 		$tabs = array();
250 250
 		$payment_methods = array();
251
-		foreach( EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj ) {
251
+		foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) {
252 252
 			// we don't want to show admin-only PMTs for now
253
-			if ( $pmt_obj instanceof EE_PMT_Admin_Only ) {
253
+			if ($pmt_obj instanceof EE_PMT_Admin_Only) {
254 254
 				continue;
255 255
 			}
256 256
 			//check access
257
-			if ( ! EE_Registry::instance()->CAP->current_user_can( $pmt_obj->cap_name(), 'specific_payment_method_type_access' ) ) {
257
+			if ( ! EE_Registry::instance()->CAP->current_user_can($pmt_obj->cap_name(), 'specific_payment_method_type_access')) {
258 258
 				continue;
259 259
 			}
260 260
 			//check for any active pms of that type
261
-			$payment_method = EEM_Payment_Method::instance()->get_one_of_type( $pmt_obj->system_name() );
262
-			if ( ! $payment_method instanceof EE_Payment_Method ) {
261
+			$payment_method = EEM_Payment_Method::instance()->get_one_of_type($pmt_obj->system_name());
262
+			if ( ! $payment_method instanceof EE_Payment_Method) {
263 263
 				$payment_method = EE_Payment_Method::new_instance(
264 264
 					array(
265
-						'PMD_slug'					=>sanitize_key( $pmt_obj->system_name() ),
265
+						'PMD_slug'					=>sanitize_key($pmt_obj->system_name()),
266 266
 						'PMD_type'					=>$pmt_obj->system_name(),
267 267
 						'PMD_name'				=>$pmt_obj->pretty_name(),
268 268
 						'PMD_admin_name'	=>$pmt_obj->pretty_name()
269 269
 					)
270 270
 				);
271 271
 			}
272
-			$payment_methods[ $payment_method->slug() ] = $payment_method;
272
+			$payment_methods[$payment_method->slug()] = $payment_method;
273 273
 		}
274
-		$payment_methods = apply_filters( 'FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', $payment_methods );
275
-		foreach( $payment_methods as $payment_method ) {
276
-			if ( $payment_method instanceof EE_Payment_Method ) {
274
+		$payment_methods = apply_filters('FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', $payment_methods);
275
+		foreach ($payment_methods as $payment_method) {
276
+			if ($payment_method instanceof EE_Payment_Method) {
277 277
 				add_meta_box(
278 278
 					//html id
279
-					'espresso_' . $payment_method->slug() . '_payment_settings',
279
+					'espresso_'.$payment_method->slug().'_payment_settings',
280 280
 					//title
281
-					sprintf( __( '%s Settings', 'event_espresso' ), $payment_method->admin_name() ),
281
+					sprintf(__('%s Settings', 'event_espresso'), $payment_method->admin_name()),
282 282
 					//callback
283
-					array( $this, 'payment_method_settings_meta_box' ),
283
+					array($this, 'payment_method_settings_meta_box'),
284 284
 					//post type
285 285
 					null,
286 286
 					//context
@@ -288,19 +288,19 @@  discard block
 block discarded – undo
288 288
 					//priority
289 289
 					'default',
290 290
 					//callback args
291
-					array( 'payment_method' => $payment_method )
291
+					array('payment_method' => $payment_method)
292 292
 				);
293 293
 				//setup for tabbed content
294
-				$tabs[ $payment_method->slug() ] = array(
294
+				$tabs[$payment_method->slug()] = array(
295 295
 					'label' => $payment_method->admin_name(),
296 296
 					'class' => $payment_method->active() ? 'gateway-active' : '',
297
-					'href'  => 'espresso_' . $payment_method->slug() . '_payment_settings',
298
-					'title' => __( 'Modify this Payment Method', 'event_espresso' ),
297
+					'href'  => 'espresso_'.$payment_method->slug().'_payment_settings',
298
+					'title' => __('Modify this Payment Method', 'event_espresso'),
299 299
 					'slug'  => $payment_method->slug()
300 300
 				);
301 301
 			}
302 302
 		}
303
-		$this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links( $tabs, 'payment_method_links', '|', $this->_get_active_payment_method_slug() );
303
+		$this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links($tabs, 'payment_method_links', '|', $this->_get_active_payment_method_slug());
304 304
 		$this->display_admin_page_with_sidebar();
305 305
 
306 306
 	}
@@ -311,20 +311,20 @@  discard block
 block discarded – undo
311 311
 	 *   _get_active_payment_method_slug
312 312
 	 * 	@return string
313 313
 	 */
314
-	protected function _get_active_payment_method_slug(){
314
+	protected function _get_active_payment_method_slug() {
315 315
 		$payment_method_slug = FALSE;
316 316
 		//decide which payment method tab to open first, as dictated by the request's 'payment_method'
317
-		if ( isset( $this->_req_data['payment_method'] )) {
317
+		if (isset($this->_req_data['payment_method'])) {
318 318
 			// if they provided the current payment method, use it
319
-			$payment_method_slug = sanitize_key( $this->_req_data['payment_method'] );
319
+			$payment_method_slug = sanitize_key($this->_req_data['payment_method']);
320 320
 		}
321
-		$payment_method = EEM_Payment_Method::instance()->get_one( array( array( 'PMD_slug' => $payment_method_slug )));
321
+		$payment_method = EEM_Payment_Method::instance()->get_one(array(array('PMD_slug' => $payment_method_slug)));
322 322
 		// if that didn't work or wasn't provided, find another way to select the current pm
323
-		if ( ! $this->_verify_payment_method( $payment_method )) {
323
+		if ( ! $this->_verify_payment_method($payment_method)) {
324 324
 			// like, looking for an active one
325
-			$payment_method = EEM_Payment_Method::instance()->get_one_active( 'CART' );
325
+			$payment_method = EEM_Payment_Method::instance()->get_one_active('CART');
326 326
 			// test that one as well
327
-			if ( $this->_verify_payment_method( $payment_method )) {
327
+			if ($this->_verify_payment_method($payment_method)) {
328 328
 				$payment_method_slug = $payment_method->slug();
329 329
 			} else {
330 330
 				$payment_method_slug = 'paypal_standard';
@@ -342,11 +342,11 @@  discard block
 block discarded – undo
342 342
 	 * @param \EE_Payment_Method $payment_method
343 343
 	 * @return boolean
344 344
 	 */
345
-	protected function _verify_payment_method( $payment_method ){
345
+	protected function _verify_payment_method($payment_method) {
346 346
 		if (
347 347
 			$payment_method instanceof EE_Payment_Method &&
348 348
 			$payment_method->type_obj() instanceof EE_PMT_Base &&
349
-			EE_Registry::instance()->CAP->current_user_can( $payment_method->type_obj()->cap_name(), 'specific_payment_method_type_access' )
349
+			EE_Registry::instance()->CAP->current_user_can($payment_method->type_obj()->cap_name(), 'specific_payment_method_type_access')
350 350
 		) {
351 351
 			return TRUE;
352 352
 		}
@@ -363,21 +363,21 @@  discard block
 block discarded – undo
363 363
 	 * @return string
364 364
 	 * @throws EE_Error
365 365
 	 */
366
-	public function payment_method_settings_meta_box( $post_obj_which_is_null, $metabox ){
367
-		$payment_method = isset( $metabox['args'], $metabox['args']['payment_method'] ) ? $metabox['args']['payment_method'] : NULL;
368
-		if ( ! $payment_method instanceof EE_Payment_Method ){
369
-			throw new EE_Error( sprintf( __( 'Payment method metabox setup incorrectly. No Payment method object was supplied', 'event_espresso' )));
366
+	public function payment_method_settings_meta_box($post_obj_which_is_null, $metabox) {
367
+		$payment_method = isset($metabox['args'], $metabox['args']['payment_method']) ? $metabox['args']['payment_method'] : NULL;
368
+		if ( ! $payment_method instanceof EE_Payment_Method) {
369
+			throw new EE_Error(sprintf(__('Payment method metabox setup incorrectly. No Payment method object was supplied', 'event_espresso')));
370 370
 		}
371 371
 		$payment_method_scopes = $payment_method->active();
372 372
 		// if the payment method really exists show its form, otherwise the activation template
373
-		if ( $payment_method->ID() && ! empty( $payment_method_scopes )) {
374
-				$form = $this->_generate_payment_method_settings_form( $payment_method );
375
-				if ( $form->form_data_present_in( $this->_req_data )) {
376
-					$form->receive_form_submission( $this->_req_data );
373
+		if ($payment_method->ID() && ! empty($payment_method_scopes)) {
374
+				$form = $this->_generate_payment_method_settings_form($payment_method);
375
+				if ($form->form_data_present_in($this->_req_data)) {
376
+					$form->receive_form_submission($this->_req_data);
377 377
 				}
378
-				echo $form->form_open() . $form->get_html_and_js() . $form->form_close();
378
+				echo $form->form_open().$form->get_html_and_js().$form->form_close();
379 379
 		} else {
380
-			echo $this->_activate_payment_method_button( $payment_method )->get_html_and_js();
380
+			echo $this->_activate_payment_method_button($payment_method)->get_html_and_js();
381 381
 		}
382 382
 	}
383 383
 
@@ -390,14 +390,14 @@  discard block
 block discarded – undo
390 390
 	 * @param \EE_Payment_Method $payment_method
391 391
 	 * @return \EE_Form_Section_Proper
392 392
 	 */
393
-	protected function _generate_payment_method_settings_form( EE_Payment_Method $payment_method ) {
394
-		if ( ! $payment_method instanceof EE_Payment_Method ){
393
+	protected function _generate_payment_method_settings_form(EE_Payment_Method $payment_method) {
394
+		if ( ! $payment_method instanceof EE_Payment_Method) {
395 395
 			return new EE_Form_Section_Proper();
396 396
 		}
397 397
 		return new EE_Form_Section_Proper(
398 398
 			array(
399
-				'name' 	=> $payment_method->slug() . '_settings_form',
400
-				'html_id' 	=> $payment_method->slug() . '_settings_form',
399
+				'name' 	=> $payment_method->slug().'_settings_form',
400
+				'html_id' 	=> $payment_method->slug().'_settings_form',
401 401
 				'action' 	=> EE_Admin_Page::add_query_args_and_nonce(
402 402
 					array(
403 403
 						'action' 						=> 'update_payment_method',
@@ -409,12 +409,12 @@  discard block
 block discarded – undo
409 409
 				'subsections' 			=> apply_filters(
410 410
 					'FHEE__Payments_Admin_Page___generate_payment_method_settings_form__form_subsections',
411 411
 					array(
412
-						'pci_dss_compliance_' . $payment_method->slug() 				=> $this->_pci_dss_compliance( $payment_method ),
413
-						'currency_support_' . $payment_method->slug()					=> $this->_currency_support( $payment_method ),
414
-						'payment_method_settings_' . $payment_method->slug() 	=> $this->_payment_method_settings( $payment_method ),
415
-						'update_' . $payment_method->slug()										=> $this->_update_payment_method_button( $payment_method ),
416
-						'deactivate_' . $payment_method->slug()								=> $this->_deactivate_payment_method_button( $payment_method ),
417
-						'fine_print_' . $payment_method->slug()									=> $this->_fine_print()
412
+						'pci_dss_compliance_'.$payment_method->slug() 				=> $this->_pci_dss_compliance($payment_method),
413
+						'currency_support_'.$payment_method->slug()					=> $this->_currency_support($payment_method),
414
+						'payment_method_settings_'.$payment_method->slug() 	=> $this->_payment_method_settings($payment_method),
415
+						'update_'.$payment_method->slug()										=> $this->_update_payment_method_button($payment_method),
416
+						'deactivate_'.$payment_method->slug()								=> $this->_deactivate_payment_method_button($payment_method),
417
+						'fine_print_'.$payment_method->slug()									=> $this->_fine_print()
418 418
 					),
419 419
 					$payment_method
420 420
 				)
@@ -431,19 +431,19 @@  discard block
 block discarded – undo
431 431
 	 * @param \EE_Payment_Method $payment_method
432 432
 	 * @return \EE_Form_Section_Proper
433 433
 	 */
434
-	protected function _pci_dss_compliance( EE_Payment_Method $payment_method ) {
435
-		if ( $payment_method->type_obj()->requires_https() ) {
434
+	protected function _pci_dss_compliance(EE_Payment_Method $payment_method) {
435
+		if ($payment_method->type_obj()->requires_https()) {
436 436
 			return new EE_Form_Section_HTML(
437 437
 				EEH_HTML::tr(
438 438
 					EEH_HTML::th(
439 439
 						EEH_HTML::label(
440
-							EEH_HTML::strong( __( 'IMPORTANT', 'event_espresso' ), '', 'important-notice' )
440
+							EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice')
441 441
 						)
442
-					) .
442
+					).
443 443
 					EEH_HTML::td(
444
-						EEH_HTML::strong( __( 'You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.', 'event_espresso' )) .
445
-						EEH_HTML::br() .
446
-						__( 'Learn more about ', 'event_espresso' ) . EEH_HTML::link( 'https://www.pcisecuritystandards.org/merchants/index.php', __( 'PCI DSS compliance', 'event_espresso' ))
444
+						EEH_HTML::strong(__('You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.', 'event_espresso')).
445
+						EEH_HTML::br().
446
+						__('Learn more about ', 'event_espresso').EEH_HTML::link('https://www.pcisecuritystandards.org/merchants/index.php', __('PCI DSS compliance', 'event_espresso'))
447 447
 					)
448 448
 				)
449 449
 			);
@@ -461,19 +461,19 @@  discard block
 block discarded – undo
461 461
 	 * @param \EE_Payment_Method $payment_method
462 462
 	 * @return \EE_Form_Section_Proper
463 463
 	 */
464
-	protected function _currency_support( EE_Payment_Method $payment_method ) {
465
-		if ( ! $payment_method->usable_for_currency( EE_Config::instance()->currency->code )) {
464
+	protected function _currency_support(EE_Payment_Method $payment_method) {
465
+		if ( ! $payment_method->usable_for_currency(EE_Config::instance()->currency->code)) {
466 466
 			return new EE_Form_Section_HTML(
467 467
 				EEH_HTML::tr(
468 468
 					EEH_HTML::th(
469 469
 						EEH_HTML::label(
470
-							EEH_HTML::strong( __( 'IMPORTANT', 'event_espresso' ), '', 'important-notice' )
470
+							EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice')
471 471
 						)
472
-					) .
472
+					).
473 473
 					EEH_HTML::td(
474 474
 						EEH_HTML::strong(
475 475
 							sprintf(
476
-								__( 'This payment method does not support the currency set on your site (%1$s) and so will not appear as a payment option to registrants. Please activate a different payment method or change your site\'s country and associated currency.', 'event_espresso'),
476
+								__('This payment method does not support the currency set on your site (%1$s) and so will not appear as a payment option to registrants. Please activate a different payment method or change your site\'s country and associated currency.', 'event_espresso'),
477 477
 								EE_Config::instance()->currency->code
478 478
 							)
479 479
 						)
@@ -493,9 +493,9 @@  discard block
 block discarded – undo
493 493
 	 * @param \EE_Payment_Method $payment_method
494 494
 	 * @return \EE_Form_Section_HTML
495 495
 	 */
496
-	protected function _payment_method_settings( EE_Payment_Method $payment_method ) {
496
+	protected function _payment_method_settings(EE_Payment_Method $payment_method) {
497 497
 		//modify the form so we only have/show fields that will be implemented for this version
498
-		return $this->_simplify_form( $payment_method->type_obj()->settings_form(), $payment_method->name() );
498
+		return $this->_simplify_form($payment_method->type_obj()->settings_form(), $payment_method->name());
499 499
 	}
500 500
 
501 501
 
@@ -508,8 +508,8 @@  discard block
 block discarded – undo
508 508
 	 * @return \EE_Payment_Method_Form
509 509
 	 * @throws \EE_Error
510 510
 	 */
511
-	protected function _simplify_form( $form_section, $payment_method_name = '' ){
512
-		if ( $form_section instanceof EE_Payment_Method_Form ) {
511
+	protected function _simplify_form($form_section, $payment_method_name = '') {
512
+		if ($form_section instanceof EE_Payment_Method_Form) {
513 513
 			$form_section->exclude(
514 514
 				array(
515 515
 					'PMD_type', //dont want them changing the type
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
 			);
521 521
 			return $form_section;
522 522
 		} else {
523
-			throw new EE_Error( sprintf( __( 'The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.', 'event_espresso' ), $payment_method_name ));
523
+			throw new EE_Error(sprintf(__('The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.', 'event_espresso'), $payment_method_name));
524 524
 		}
525 525
 	}
526 526
 
@@ -533,19 +533,19 @@  discard block
 block discarded – undo
533 533
 	 * @param \EE_Payment_Method $payment_method
534 534
 	 * @return \EE_Form_Section_HTML
535 535
 	 */
536
-	protected function _update_payment_method_button( EE_Payment_Method $payment_method ) {
536
+	protected function _update_payment_method_button(EE_Payment_Method $payment_method) {
537 537
 		$update_button = new EE_Submit_Input(
538 538
 			array(
539 539
 				'name' => 'submit',
540
-				'html_id' 		=> 'save_' . $payment_method->slug() . '_settings',
541
-				'default' 		=> sprintf( __( 'Update %s Payment Settings', 'event_espresso' ), $payment_method->admin_name() ),
540
+				'html_id' 		=> 'save_'.$payment_method->slug().'_settings',
541
+				'default' 		=> sprintf(__('Update %s Payment Settings', 'event_espresso'), $payment_method->admin_name()),
542 542
 				'html_label' => EEH_HTML::nbsp()
543 543
 			)
544 544
 		);
545 545
 		return new EE_Form_Section_HTML(
546
-			EEH_HTML::no_row( EEH_HTML::br(2) ) .
546
+			EEH_HTML::no_row(EEH_HTML::br(2)).
547 547
 			EEH_HTML::tr(
548
-				EEH_HTML::th( __( 'Update Settings', 'event_espresso') ) .
548
+				EEH_HTML::th(__('Update Settings', 'event_espresso')).
549 549
 				EEH_HTML::td(
550 550
 					$update_button->get_html_for_input()
551 551
 				)
@@ -562,11 +562,11 @@  discard block
 block discarded – undo
562 562
 	 * @param \EE_Payment_Method $payment_method
563 563
 	 * @return \EE_Form_Section_Proper
564 564
 	 */
565
-	protected function _deactivate_payment_method_button( EE_Payment_Method $payment_method ) {
566
-		$link_text_and_title = sprintf( __( 'Deactivate %1$s Payments?', 'event_espresso'), $payment_method->admin_name() );
565
+	protected function _deactivate_payment_method_button(EE_Payment_Method $payment_method) {
566
+		$link_text_and_title = sprintf(__('Deactivate %1$s Payments?', 'event_espresso'), $payment_method->admin_name());
567 567
 		return new EE_Form_Section_HTML(
568 568
 			EEH_HTML::tr(
569
-				EEH_HTML::th( __( 'Deactivate Payment Method', 'event_espresso') ) .
569
+				EEH_HTML::th(__('Deactivate Payment Method', 'event_espresso')).
570 570
 				EEH_HTML::td(
571 571
 					EEH_HTML::link(
572 572
 						EE_Admin_Page::add_query_args_and_nonce(
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
 						),
579 579
 						$link_text_and_title,
580 580
 						$link_text_and_title,
581
-						'deactivate_' . $payment_method->slug(),
581
+						'deactivate_'.$payment_method->slug(),
582 582
 						'espresso-button button-secondary'
583 583
 					)
584 584
 				)
@@ -594,12 +594,12 @@  discard block
 block discarded – undo
594 594
 	 * @param \EE_Payment_Method $payment_method
595 595
 	 * @return \EE_Form_Section_Proper
596 596
 	 */
597
-	protected function _activate_payment_method_button( EE_Payment_Method $payment_method ) {
598
-		$link_text_and_title = sprintf( __( 'Activate %1$s Payment Method?', 'event_espresso'), $payment_method->admin_name() );
597
+	protected function _activate_payment_method_button(EE_Payment_Method $payment_method) {
598
+		$link_text_and_title = sprintf(__('Activate %1$s Payment Method?', 'event_espresso'), $payment_method->admin_name());
599 599
 		return new EE_Form_Section_Proper(
600 600
 			array(
601
-				'name' 	=> 'activate_' . $payment_method->slug() . '_settings_form',
602
-				'html_id' 	=> 'activate_' . $payment_method->slug() . '_settings_form',
601
+				'name' 	=> 'activate_'.$payment_method->slug().'_settings_form',
602
+				'html_id' 	=> 'activate_'.$payment_method->slug().'_settings_form',
603 603
 				'action' 	=> '#',
604 604
 				'layout_strategy'		=> new EE_Admin_Two_Column_Layout(),
605 605
 				'subsections' 			=> apply_filters(
@@ -607,17 +607,17 @@  discard block
 block discarded – undo
607 607
 					array(
608 608
 						new EE_Form_Section_HTML(
609 609
 							EEH_HTML::tr(
610
-								EEH_HTML::td( $payment_method->type_obj()->introductory_html(),
610
+								EEH_HTML::td($payment_method->type_obj()->introductory_html(),
611 611
 									'',
612 612
 									'',
613 613
 									'',
614 614
 									'colspan="2"' 
615 615
 								)
616
-							) . 
616
+							). 
617 617
 							EEH_HTML::tr(
618 618
 								EEH_HTML::th(
619
-									EEH_HTML::label( __( 'Click to Activate ', 'event_espresso' ))
620
-								) .
619
+									EEH_HTML::label(__('Click to Activate ', 'event_espresso'))
620
+								).
621 621
 								EEH_HTML::td(
622 622
 									EEH_HTML::link(
623 623
 										EE_Admin_Page::add_query_args_and_nonce(
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
 										),
630 630
 										$link_text_and_title,
631 631
 										$link_text_and_title,
632
-										'activate_' . $payment_method->slug(),
632
+										'activate_'.$payment_method->slug(),
633 633
 										'espresso-button-green button-primary'
634 634
 									)
635 635
 								)
@@ -651,9 +651,9 @@  discard block
 block discarded – undo
651 651
 	protected function _fine_print() {
652 652
 		return new EE_Form_Section_HTML(
653 653
 			EEH_HTML::tr(
654
-				EEH_HTML::th() .
654
+				EEH_HTML::th().
655 655
 				EEH_HTML::td(
656
-					EEH_HTML::p( __( 'All fields marked with a * are required fields', 'event_espresso' ), '', 'grey-text' )
656
+					EEH_HTML::p(__('All fields marked with a * are required fields', 'event_espresso'), '', 'grey-text')
657 657
 				)
658 658
 			)
659 659
 		);
@@ -665,15 +665,15 @@  discard block
 block discarded – undo
665 665
 	 * Activates a payment method of that type. Mostly assuming there is only 1 of that type (or none so far)
666 666
 	 * @global WP_User $current_user
667 667
 	 */
668
-	protected function _activate_payment_method(){
669
-		if(isset($this->_req_data['payment_method_type'])){
668
+	protected function _activate_payment_method() {
669
+		if (isset($this->_req_data['payment_method_type'])) {
670 670
 			$payment_method_type = sanitize_text_field($this->_req_data['payment_method_type']);
671 671
 			//see if one exists
672
-			EE_Registry::instance()->load_lib( 'Payment_Method_Manager' );
673
-			$payment_method = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( $payment_method_type );
672
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
673
+			$payment_method = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type($payment_method_type);
674 674
 
675
-			$this->_redirect_after_action(1, 'Payment Method', 'activated', array('action' => 'default','payment_method'=>$payment_method->slug()));
676
-		}else{
675
+			$this->_redirect_after_action(1, 'Payment Method', 'activated', array('action' => 'default', 'payment_method'=>$payment_method->slug()));
676
+		} else {
677 677
 			$this->_redirect_after_action(FALSE, 'Payment Method', 'activated', array('action' => 'default'));
678 678
 		}
679 679
 	}
@@ -681,14 +681,14 @@  discard block
 block discarded – undo
681 681
 	/**
682 682
 	 * Deactivates the payment method with the specified slug, and redirects.
683 683
 	 */
684
-	protected function _deactivate_payment_method(){
685
-		if(isset($this->_req_data['payment_method'])){
684
+	protected function _deactivate_payment_method() {
685
+		if (isset($this->_req_data['payment_method'])) {
686 686
 			$payment_method_slug = sanitize_key($this->_req_data['payment_method']);
687 687
 			//deactivate it
688 688
 			EE_Registry::instance()->load_lib('Payment_Method_Manager');
689
-			$count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method( $payment_method_slug );
690
-			$this->_redirect_after_action($count_updated, 'Payment Method', 'deactivated', array('action' => 'default','payment_method'=>$payment_method_slug));
691
-		}else{
689
+			$count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method($payment_method_slug);
690
+			$this->_redirect_after_action($count_updated, 'Payment Method', 'deactivated', array('action' => 'default', 'payment_method'=>$payment_method_slug));
691
+		} else {
692 692
 			$this->_redirect_after_action(FALSE, 'Payment Method', 'deactivated', array('action' => 'default'));
693 693
 		}
694 694
 	}
@@ -702,46 +702,46 @@  discard block
 block discarded – undo
702 702
 	 * subsequently called 'headers_sent_func' which is _payment_methods_list)
703 703
 	 * @return void
704 704
 	 */
705
-	protected function _update_payment_method(){
706
-		if( $_SERVER['REQUEST_METHOD'] == 'POST'){
705
+	protected function _update_payment_method() {
706
+		if ($_SERVER['REQUEST_METHOD'] == 'POST') {
707 707
 			//ok let's find which gateway form to use based on the form input
708 708
 			EE_Registry::instance()->load_lib('Payment_Method_Manager');
709 709
 			/** @var $correct_pmt_form_to_use EE_Payment_Method_Form */
710 710
 			$correct_pmt_form_to_use = NULL;
711 711
 			$payment_method = NULL;
712
-			foreach( EEM_Payment_Method::instance()->get_all() as $payment_method){
712
+			foreach (EEM_Payment_Method::instance()->get_all() as $payment_method) {
713 713
 				//get the form and simplify it, like what we do when we display it
714
-				$pmt_form = $this->_generate_payment_method_settings_form( $payment_method );
715
-				if($pmt_form->form_data_present_in($this->_req_data)){
714
+				$pmt_form = $this->_generate_payment_method_settings_form($payment_method);
715
+				if ($pmt_form->form_data_present_in($this->_req_data)) {
716 716
 					$correct_pmt_form_to_use = $pmt_form;
717 717
 					break;
718 718
 				}
719 719
 			}
720 720
 			//if we couldn't find the correct payment method type...
721
-			if( ! $correct_pmt_form_to_use ){
721
+			if ( ! $correct_pmt_form_to_use) {
722 722
 				EE_Error::add_error(__("We could not find which payment method type your form submission related to. Please contact support", 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
723 723
 				$this->_redirect_after_action(FALSE, 'Payment Method', 'activated', array('action' => 'default'));
724 724
 			}
725 725
 			$correct_pmt_form_to_use->receive_form_submission($this->_req_data);
726
-			if($correct_pmt_form_to_use->is_valid()){
727
-				$subsection_name = 'payment_method_settings_' . $payment_method->slug();
728
-				$payment_settings_subform = $correct_pmt_form_to_use->get_subsection( $subsection_name );
729
-				if( ! $payment_settings_subform instanceof EE_Payment_Method_Form ) {
726
+			if ($correct_pmt_form_to_use->is_valid()) {
727
+				$subsection_name = 'payment_method_settings_'.$payment_method->slug();
728
+				$payment_settings_subform = $correct_pmt_form_to_use->get_subsection($subsection_name);
729
+				if ( ! $payment_settings_subform instanceof EE_Payment_Method_Form) {
730 730
 					throw new EE_Error( 
731 731
 						sprintf(
732
-							__( 'The payment method could not be saved because the form sections were misnamed. We expected to find %1$s, but did not.','event_espresso' ),
732
+							__('The payment method could not be saved because the form sections were misnamed. We expected to find %1$s, but did not.', 'event_espresso'),
733 733
 							$subsection_name
734 734
 						)
735 735
 					);
736 736
 				}
737 737
 				$payment_settings_subform->save();
738 738
 				/** @var $pm EE_Payment_Method */
739
-				$this->_redirect_after_action(TRUE, 'Payment Method', 'updated', array('action' => 'default','payment_method'=>$payment_method->slug()));
740
-			}else{
739
+				$this->_redirect_after_action(TRUE, 'Payment Method', 'updated', array('action' => 'default', 'payment_method'=>$payment_method->slug()));
740
+			} else {
741 741
 				EE_Error::add_error(
742 742
 					sprintf(
743 743
 						__('Payment method of type %s was not saved because there were validation errors. They have been marked in the form', 'event_espresso'),
744
-						$payment_method instanceof EE_PMT_Base ? $payment_method->pretty_name() : __( '"(unknown)"', 'event_espresso' )
744
+						$payment_method instanceof EE_PMT_Base ? $payment_method->pretty_name() : __('"(unknown)"', 'event_espresso')
745 745
 					),
746 746
 					__FILE__,
747 747
 					__FUNCTION__,
@@ -758,11 +758,11 @@  discard block
 block discarded – undo
758 758
 	protected function _payment_settings() {
759 759
 
760 760
 		$this->_template_args['values'] = $this->_yes_no_values;
761
-		$this->_template_args['show_pending_payment_options'] = isset( EE_Registry::instance()->CFG->registration->show_pending_payment_options ) ? absint( EE_Registry::instance()->CFG->registration->show_pending_payment_options ) : FALSE;
761
+		$this->_template_args['show_pending_payment_options'] = isset(EE_Registry::instance()->CFG->registration->show_pending_payment_options) ? absint(EE_Registry::instance()->CFG->registration->show_pending_payment_options) : FALSE;
762 762
 
763
-		$this->_set_add_edit_form_tags( 'update_payment_settings' );
764
-		$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
765
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( EE_PAYMENTS_TEMPLATE_PATH . 'payment_settings.template.php', $this->_template_args, TRUE );
763
+		$this->_set_add_edit_form_tags('update_payment_settings');
764
+		$this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE);
765
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(EE_PAYMENTS_TEMPLATE_PATH.'payment_settings.template.php', $this->_template_args, TRUE);
766 766
 		$this->display_admin_page_with_sidebar();
767 767
 
768 768
 	}
@@ -776,8 +776,8 @@  discard block
 block discarded – undo
776 776
 	*		@return array
777 777
 	*/
778 778
 	protected function _update_payment_settings() {
779
-		EE_Registry::instance()->CFG->registration->show_pending_payment_options = isset( $this->_req_data['show_pending_payment_options'] ) ? $this->_req_data['show_pending_payment_options'] : FALSE;
780
-		EE_Registry::instance()->CFG = apply_filters( 'FHEE__Payments_Admin_Page___update_payment_settings__CFG', EE_Registry::instance()->CFG );
779
+		EE_Registry::instance()->CFG->registration->show_pending_payment_options = isset($this->_req_data['show_pending_payment_options']) ? $this->_req_data['show_pending_payment_options'] : FALSE;
780
+		EE_Registry::instance()->CFG = apply_filters('FHEE__Payments_Admin_Page___update_payment_settings__CFG', EE_Registry::instance()->CFG);
781 781
 
782 782
 //		 $superform = new EE_Form_Section_Proper(
783 783
 //		 	array(
@@ -797,9 +797,9 @@  discard block
 block discarded – undo
797 797
 //		 	$this->_redirect_after_action( 0, 'settings', 'updated', array( 'action' => 'payment_settings' ) );
798 798
 //		 }
799 799
 
800
-		$what = __('Payment Settings','event_espresso');
801
-		$success = $this->_update_espresso_configuration( $what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, __LINE__ );
802
-		$this->_redirect_after_action( $success, $what, __('updated','event_espresso'), array( 'action' => 'payment_settings' ) );
800
+		$what = __('Payment Settings', 'event_espresso');
801
+		$success = $this->_update_espresso_configuration($what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, __LINE__);
802
+		$this->_redirect_after_action($success, $what, __('updated', 'event_espresso'), array('action' => 'payment_settings'));
803 803
 
804 804
 	}
805 805
 	protected function _payment_log_overview_list_table() {
@@ -825,18 +825,18 @@  discard block
 block discarded – undo
825 825
 	 * @param bool $count
826 826
 	 * @return array
827 827
 	 */
828
-	public function get_payment_logs($per_page = 50, $current_page = 0, $count = false){
829
-		EE_Registry::instance()->load_model( 'Change_Log' );
828
+	public function get_payment_logs($per_page = 50, $current_page = 0, $count = false) {
829
+		EE_Registry::instance()->load_model('Change_Log');
830 830
 		//we may need to do multiple queries (joining differently), so we actually wan tan array of query params
831
-		$query_params =  array(array('LOG_type'=>  EEM_Change_Log::type_gateway));
831
+		$query_params = array(array('LOG_type'=>  EEM_Change_Log::type_gateway));
832 832
 		//check if they've selected a specific payment method
833
-		if( isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all'){
833
+		if (isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all') {
834 834
 			$query_params[0]['OR*pm_or_pay_pm'] = array('Payment.Payment_Method.PMD_ID'=>$this->_req_data['_payment_method'],
835 835
 				'Payment_Method.PMD_ID'=>$this->_req_data['_payment_method']);
836 836
 		}
837 837
 		//take into account search
838
-		if(isset($this->_req_data['s']) && $this->_req_data['s']){
839
-			$similarity_string = array('LIKE','%'.str_replace("","%",$this->_req_data['s']) .'%');
838
+		if (isset($this->_req_data['s']) && $this->_req_data['s']) {
839
+			$similarity_string = array('LIKE', '%'.str_replace("", "%", $this->_req_data['s']).'%');
840 840
 			$query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_fname'] = $similarity_string;
841 841
 			$query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_lname'] = $similarity_string;
842 842
 			$query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_email'] = $similarity_string;
@@ -851,48 +851,48 @@  discard block
 block discarded – undo
851 851
 			$query_params[0]['OR*s']['LOG_message'] = $similarity_string;
852 852
 
853 853
 		}
854
-		if(isset( $this->_req_data['payment-filter-start-date'] ) && isset( $this->_req_data['payment-filter-end-date'] )){
854
+		if (isset($this->_req_data['payment-filter-start-date']) && isset($this->_req_data['payment-filter-end-date'])) {
855 855
 			//add date
856
-			$start_date =wp_strip_all_tags( $this->_req_data['payment-filter-start-date'] );
857
-			$end_date = wp_strip_all_tags( $this->_req_data['payment-filter-end-date'] );
856
+			$start_date = wp_strip_all_tags($this->_req_data['payment-filter-start-date']);
857
+			$end_date = wp_strip_all_tags($this->_req_data['payment-filter-end-date']);
858 858
 			//make sure our timestamps start and end right at the boundaries for each day
859
-			$start_date = date( 'Y-m-d', strtotime( $start_date ) ) . ' 00:00:00';
860
-			$end_date = date( 'Y-m-d', strtotime( $end_date ) ) . ' 23:59:59';
859
+			$start_date = date('Y-m-d', strtotime($start_date)).' 00:00:00';
860
+			$end_date = date('Y-m-d', strtotime($end_date)).' 23:59:59';
861 861
 
862 862
 			//convert to timestamps
863
-			$start_date = strtotime( $start_date );
864
-			$end_date = strtotime( $end_date );
863
+			$start_date = strtotime($start_date);
864
+			$end_date = strtotime($end_date);
865 865
 
866 866
 			//makes sure start date is the lowest value and vice versa
867
-			$start_date = min( $start_date, $end_date );
868
-			$end_date = max( $start_date, $end_date );
867
+			$start_date = min($start_date, $end_date);
868
+			$end_date = max($start_date, $end_date);
869 869
 
870 870
 			//convert for query
871
-			$start_date = EEM_Change_Log::instance()->convert_datetime_for_query( 'LOG_time', date( 'Y-m-d H:i:s', $start_date ), 'Y-m-d H:i:s' );
872
-			$end_date = EEM_Change_Log::instance()->convert_datetime_for_query( 'LOG_time', date( 'Y-m-d H:i:s', $end_date ), 'Y-m-d H:i:s' );
871
+			$start_date = EEM_Change_Log::instance()->convert_datetime_for_query('LOG_time', date('Y-m-d H:i:s', $start_date), 'Y-m-d H:i:s');
872
+			$end_date = EEM_Change_Log::instance()->convert_datetime_for_query('LOG_time', date('Y-m-d H:i:s', $end_date), 'Y-m-d H:i:s');
873 873
 
874
-			$query_params[0]['LOG_time'] = array('BETWEEN',array($start_date,$end_date));
874
+			$query_params[0]['LOG_time'] = array('BETWEEN', array($start_date, $end_date));
875 875
 
876 876
 		}
877
-		if($count){
877
+		if ($count) {
878 878
 			return EEM_Change_Log::instance()->count($query_params);
879 879
 		}
880
-		if(isset($this->_req_data['order'])){
881
-			$sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'DESC';
880
+		if (isset($this->_req_data['order'])) {
881
+			$sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'DESC';
882 882
 			$query_params['order_by'] = array('LOG_time' => $sort);
883
-		}else{
883
+		} else {
884 884
 				$query_params['order_by'] = array('LOG_time' => 'DESC');
885 885
 		}
886
-		$offset = ($current_page-1)*$per_page;
886
+		$offset = ($current_page - 1) * $per_page;
887 887
 
888
-		if( ! isset($this->_req_data['download_results'])){
889
-			$query_params['limit'] = array( $offset, $per_page );
888
+		if ( ! isset($this->_req_data['download_results'])) {
889
+			$query_params['limit'] = array($offset, $per_page);
890 890
 		}
891 891
 
892 892
 
893 893
 
894 894
 		//now they've requested to instead just download the file instead of viewing it.
895
-		if(isset($this->_req_data['download_results'])){
895
+		if (isset($this->_req_data['download_results'])) {
896 896
 			$wpdb_results = EEM_Change_Log::instance()->get_all_efficiently($query_params);
897 897
 			header('Content-Disposition: attachment');
898 898
 			header("Content-Disposition: attachment; filename=ee_payment_logs_for_".sanitize_key(site_url()));
@@ -914,36 +914,36 @@  discard block
 block discarded – undo
914 914
 	 * @param EE_Change_Log $logB
915 915
 	 * @return int
916 916
 	 */
917
-	protected function _sort_logs_again($logA,$logB){
917
+	protected function _sort_logs_again($logA, $logB) {
918 918
 		$timeA = $logA->get_raw('LOG_time');
919 919
 		$timeB = $logB->get_raw('LOG_time');
920
-		if($timeA == $timeB){
920
+		if ($timeA == $timeB) {
921 921
 			return 0;
922 922
 		}
923 923
 		$comparison = $timeA < $timeB ? -1 : 1;
924
-		if(strtoupper($this->_sort_logs_again_direction) == 'DESC'){
924
+		if (strtoupper($this->_sort_logs_again_direction) == 'DESC') {
925 925
 			return $comparison * -1;
926
-		}else{
926
+		} else {
927 927
 			return $comparison;
928 928
 		}
929 929
 	}
930 930
 
931 931
 	protected function _payment_log_details() {
932
-		EE_Registry::instance()->load_model( 'Change_Log' );
932
+		EE_Registry::instance()->load_model('Change_Log');
933 933
 		/** @var $payment_log EE_Change_Log */
934 934
 		$payment_log = EEM_Change_Log::instance()->get_one_by_ID($this->_req_data['ID']);
935 935
 		$payment_method = NULL;
936 936
 		$transaction = NULL;
937
-		if( $payment_log instanceof EE_Change_Log ){
938
-			if( $payment_log->object() instanceof EE_Payment ){
937
+		if ($payment_log instanceof EE_Change_Log) {
938
+			if ($payment_log->object() instanceof EE_Payment) {
939 939
 				$payment_method = $payment_log->object()->payment_method();
940 940
 				$transaction = $payment_log->object()->transaction();
941
-			}elseif($payment_log->object() instanceof EE_Payment_Method){
941
+			}elseif ($payment_log->object() instanceof EE_Payment_Method) {
942 942
 				$payment_method = $payment_log->object();
943 943
 			}
944 944
 		}
945 945
 		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
946
-			EE_PAYMENTS_TEMPLATE_PATH . 'payment_log_details.template.php',
946
+			EE_PAYMENTS_TEMPLATE_PATH.'payment_log_details.template.php',
947 947
 			array(
948 948
 				'payment_log'=>$payment_log,
949 949
 				'payment_method'=>$payment_method,
Please login to merge, or discard this patch.
core/libraries/form_sections/base/EE_Form_Section_Base.form.php 1 patch
Spacing   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION')){
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3 3
 	exit('No direct script access allowed');
4 4
 }
5 5
 /**
@@ -79,12 +79,12 @@  discard block
 block discarded – undo
79 79
 	 *	@type $name string the name for this form section, if you want to explicitly define it
80 80
 	 * }
81 81
 	 */
82
-	public function __construct( $options_array = array() ) {
82
+	public function __construct($options_array = array()) {
83 83
 		// used by display strategies
84 84
 		// assign incoming values to properties
85
-		foreach( $options_array as $key => $value ) {
86
-			$key = '_' . $key;
87
-			if ( property_exists( $this, $key ) && empty( $this->{$key} )) {
85
+		foreach ($options_array as $key => $value) {
86
+			$key = '_'.$key;
87
+			if (property_exists($this, $key) && empty($this->{$key} )) {
88 88
 				$this->{$key} = $value;
89 89
 			}
90 90
 		}
@@ -97,10 +97,10 @@  discard block
 block discarded – undo
97 97
 	 * @param $name
98 98
 	 * @throws \EE_Error
99 99
 	 */
100
-	protected function _construct_finalize( $parent_form_section, $name ){
100
+	protected function _construct_finalize($parent_form_section, $name) {
101 101
 		$this->_construction_finalized = TRUE;
102 102
 		$this->_parent_section = $parent_form_section;
103
-		if( $name !== null ) {
103
+		if ($name !== null) {
104 104
 			$this->_name = $name;
105 105
 		}
106 106
 	}
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
111 111
 	 * @return void
112 112
 	 * @throws \EE_Error
113 113
 	 */
114
-	public function ensure_construct_finalized_called(){
115
-		if( ! $this->_construction_finalized ){
116
-			$this->_construct_finalize($this->_parent_section, $this->_name );
114
+	public function ensure_construct_finalized_called() {
115
+		if ( ! $this->_construction_finalized) {
116
+			$this->_construct_finalize($this->_parent_section, $this->_name);
117 117
 		}
118 118
 	}
119 119
 
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	/**
132 132
 	 * @param string $action
133 133
 	 */
134
-	public function set_action( $action ) {
134
+	public function set_action($action) {
135 135
 		$this->_action = $action;
136 136
 	}
137 137
 
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 * @return string
142 142
 	 */
143 143
 	public function method() {
144
-		return ! empty( $this->_method ) ? $this->_method : 'POST';
144
+		return ! empty($this->_method) ? $this->_method : 'POST';
145 145
 	}
146 146
 
147 147
 
@@ -149,8 +149,8 @@  discard block
 block discarded – undo
149 149
 	/**
150 150
 	 * @param string $method
151 151
 	 */
152
-	public function set_method( $method ) {
153
-		switch ( $method ) {
152
+	public function set_method($method) {
153
+		switch ($method) {
154 154
 			case 'get' :
155 155
 			case 'GET' :
156 156
 				$this->_method = 'GET';
@@ -169,12 +169,12 @@  discard block
 block discarded – undo
169 169
 	 *
170 170
 	 * @throws \EE_Error
171 171
 	 */
172
-	protected function _set_default_html_id_if_empty(){
173
-		if( ! $this->_html_id ){
174
-			if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper ){
175
-				$this->_html_id = $this->_parent_section->html_id() . '-' . $this->_prep_name_for_html_id( $this->name() );
176
-			}else{
177
-				$this->_html_id = $this->_prep_name_for_html_id( $this->name() );
172
+	protected function _set_default_html_id_if_empty() {
173
+		if ( ! $this->_html_id) {
174
+			if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) {
175
+				$this->_html_id = $this->_parent_section->html_id().'-'.$this->_prep_name_for_html_id($this->name());
176
+			} else {
177
+				$this->_html_id = $this->_prep_name_for_html_id($this->name());
178 178
 			}
179 179
 		}
180 180
 	}
@@ -186,8 +186,8 @@  discard block
 block discarded – undo
186 186
 	 * @param $name
187 187
 	 * @return string
188 188
 	 */
189
-	private function _prep_name_for_html_id( $name ) {
190
-		return sanitize_key( str_replace( array( '&nbsp;', ' ', '_' ), '-', $name ));
189
+	private function _prep_name_for_html_id($name) {
190
+		return sanitize_key(str_replace(array('&nbsp;', ' ', '_'), '-', $name));
191 191
 	}
192 192
 
193 193
 
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 	 * and so might stop working anytime.
202 202
 	 * @return string
203 203
 	 */
204
-	public function get_html_and_js(){
204
+	public function get_html_and_js() {
205 205
 		return $this->get_html();
206 206
 	}
207 207
 	
@@ -217,9 +217,9 @@  discard block
 block discarded – undo
217 217
 	 * @param bool $add_pound_sign
218 218
 	 * @return string
219 219
 	 */
220
-	public function html_id( $add_pound_sign = FALSE ){
220
+	public function html_id($add_pound_sign = FALSE) {
221 221
 		$this->_set_default_html_id_if_empty();
222
-		return $add_pound_sign ? '#' . $this->_html_id : $this->_html_id;
222
+		return $add_pound_sign ? '#'.$this->_html_id : $this->_html_id;
223 223
 	}
224 224
 
225 225
 
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 	/**
228 228
 	 * @return string
229 229
 	 */
230
-	public function html_class(){
230
+	public function html_class() {
231 231
 		return $this->_html_class;
232 232
 	}
233 233
 
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 	/**
237 237
 	 * @return string
238 238
 	 */
239
-	public function html_style(){
239
+	public function html_style() {
240 240
 		return $this->_html_style;
241 241
 	}
242 242
 
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 	/**
246 246
 	 * @param mixed $html_class
247 247
 	 */
248
-	public function set_html_class( $html_class ) {
248
+	public function set_html_class($html_class) {
249 249
 		$this->_html_class = $html_class;
250 250
 	}
251 251
 
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 	/**
255 255
 	 * @param mixed $html_id
256 256
 	 */
257
-	public function set_html_id( $html_id ) {
257
+	public function set_html_id($html_id) {
258 258
 		$this->_html_id = $html_id;
259 259
 	}
260 260
 
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 	/**
264 264
 	 * @param mixed $html_style
265 265
 	 */
266
-	public function set_html_style( $html_style ) {
266
+	public function set_html_style($html_style) {
267 267
 		$this->_html_style = $html_style;
268 268
 	}
269 269
 
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 	/**
273 273
 	 * @param string $other_html_attributes
274 274
 	 */
275
-	public function set_other_html_attributes( $other_html_attributes ) {
275
+	public function set_other_html_attributes($other_html_attributes) {
276 276
 		$this->_other_html_attributes = $other_html_attributes;
277 277
 	}
278 278
 
@@ -292,9 +292,9 @@  discard block
 block discarded – undo
292 292
 	 * @throws EE_Error
293 293
 	 * @return string
294 294
 	 */
295
-	public function name(){
296
-		if( ! $this->_construction_finalized ){
297
-			throw new EE_Error(sprintf( __( 'You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'', 'event_espresso' ), get_class($this) ) );
295
+	public function name() {
296
+		if ( ! $this->_construction_finalized) {
297
+			throw new EE_Error(sprintf(__('You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'', 'event_espresso'), get_class($this)));
298 298
 		}
299 299
 		return $this->_name;
300 300
 	}
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 	 * Gets the parent section
306 306
 	 * @return EE_Form_Section_Proper
307 307
 	 */
308
-	public function parent_section(){
308
+	public function parent_section() {
309 309
 		return $this->_parent_section;
310 310
 	}
311 311
 
@@ -318,18 +318,18 @@  discard block
 block discarded – undo
318 318
 	 * @param string $other_attributes anything else added to the form open tag, MUST BE VALID HTML
319 319
 	 * @return string
320 320
 	 */
321
-	public function form_open( $action = '', $method = '', $other_attributes = '' ) {
322
-		if ( ! empty( $action )) {
323
-			$this->set_action( $action );
321
+	public function form_open($action = '', $method = '', $other_attributes = '') {
322
+		if ( ! empty($action)) {
323
+			$this->set_action($action);
324 324
 		}
325
-		if ( ! empty( $method )) {
326
-			$this->set_method( $method );
325
+		if ( ! empty($method)) {
326
+			$this->set_method($method);
327 327
 		}
328
-		$html = EEH_HTML::nl( 1, 'form' ) . '<form';
329
-		$html .= $this->html_id() !== '' ? ' id="' . $this->html_id() . '"' : '';
330
-		$html .= ' action="' . $this->action() . '"';
331
-		$html .= ' method="' . $this->method() . '"';
332
-		$html .= $other_attributes . '>';
328
+		$html = EEH_HTML::nl(1, 'form').'<form';
329
+		$html .= $this->html_id() !== '' ? ' id="'.$this->html_id().'"' : '';
330
+		$html .= ' action="'.$this->action().'"';
331
+		$html .= ' method="'.$this->method().'"';
332
+		$html .= $other_attributes.'>';
333 333
 		return $html;
334 334
 	}
335 335
 
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 	 * @return string
341 341
 	 */
342 342
 	public function form_close() {
343
-		return EEH_HTML::nl( -1, 'form' ) . '</form>' . EEH_HTML::nl() . '<!-- end of ee-' . $this->html_id() . '-form -->' . EEH_HTML::nl();
343
+		return EEH_HTML::nl( -1, 'form' ).'</form>'.EEH_HTML::nl().'<!-- end of ee-'.$this->html_id().'-form -->'.EEH_HTML::nl();
344 344
 	}
345 345
 	
346 346
 	/**
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 	 * Default does nothing, but child classes can override
350 350
 	 * @return void
351 351
 	 */
352
-	public function enqueue_js(){
352
+	public function enqueue_js() {
353 353
 		//defaults to enqueue NO js or css
354 354
 	}
355 355
 
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 	 * @param array $form_other_js_data
366 366
 	 * @return array
367 367
 	 */
368
-	public function get_other_js_data( $form_other_js_data = array() ) {
368
+	public function get_other_js_data($form_other_js_data = array()) {
369 369
 		return $form_other_js_data;
370 370
 	}
371 371
 
@@ -383,20 +383,20 @@  discard block
 block discarded – undo
383 383
 	 * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false
384 384
 	 * @return EE_Form_Section_Base
385 385
 	 */
386
-	public function find_section_from_path( $form_section_path ) {		
387
-		if( strpos( $form_section_path, '/' ) === 0 ) {
388
-			$form_section_path = substr( $form_section_path, strlen( '/' ) );
386
+	public function find_section_from_path($form_section_path) {		
387
+		if (strpos($form_section_path, '/') === 0) {
388
+			$form_section_path = substr($form_section_path, strlen('/'));
389 389
 		}
390
-		if( empty( $form_section_path ) ) {
390
+		if (empty($form_section_path)) {
391 391
 			return $this;
392 392
 		}
393
-		if( strpos( $form_section_path, '../' ) === 0 ) {
393
+		if (strpos($form_section_path, '../') === 0) {
394 394
 			$parent = $this->parent_section();
395 395
 			
396
-			$form_section_path = substr( $form_section_path, strlen( '../' ) );
397
-			if( $parent instanceof EE_Form_Section_Base ) {
398
-				return $parent->find_section_from_path( $form_section_path );
399
-			} elseif( empty( $form_section_path ) ) {
396
+			$form_section_path = substr($form_section_path, strlen('../'));
397
+			if ($parent instanceof EE_Form_Section_Base) {
398
+				return $parent->find_section_from_path($form_section_path);
399
+			} elseif (empty($form_section_path)) {
400 400
 				return $this;
401 401
 			}
402 402
 		}
Please login to merge, or discard this patch.
payment_methods/Paypal_Standard/EE_Paypal_Standard_Form.form.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -57,11 +57,11 @@
 block discarded – undo
57 57
 
58 58
 
59 59
 
60
-    /**
61
-     * @param array $req_data
62
-     * @throws EE_Error
63
-     */
64
-    public function _normalize( $req_data ) {
60
+	/**
61
+	 * @param array $req_data
62
+	 * @throws EE_Error
63
+	 */
64
+	public function _normalize( $req_data ) {
65 65
 		parent::_normalize( $req_data );
66 66
 		$paypal_calculates_shipping = $this->get_input_value( 'paypal_shipping' );
67 67
 		$paypal_calculates_taxes = $this->get_input_value( 'paypal_taxes' );
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
-	exit( 'No direct script access allowed' );
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 
6 6
 /**
@@ -21,35 +21,35 @@  discard block
 block discarded – undo
21 21
 	/**
22 22
 	 * @param EE_PMT_Paypal_Standard $payment_method_type
23 23
 	 */
24
-	public function __construct( $payment_method_type ){
24
+	public function __construct($payment_method_type) {
25 25
 		parent::__construct(
26 26
 			array(
27 27
 				'payment_method_type'          => $payment_method_type,
28 28
 				'extra_meta_inputs'            => array(
29
-					'paypal_id'        => new EE_Text_Input( array(
30
-						'html_label_text' => sprintf( __( "Paypal Email %s", 'event_espresso' ), $payment_method_type->get_help_tab_link() ),
31
-						'html_help_text'  => __( "Typically [email protected]", 'event_espresso' ),
29
+					'paypal_id'        => new EE_Text_Input(array(
30
+						'html_label_text' => sprintf(__("Paypal Email %s", 'event_espresso'), $payment_method_type->get_help_tab_link()),
31
+						'html_help_text'  => __("Typically [email protected]", 'event_espresso'),
32 32
 						'required'        => true
33
-					) ),
34
-					'image_url'        => new EE_Admin_File_Uploader_Input( array(
35
-						'html_help_text'  => __( "Used for your business/personal logo on the PayPal page", 'event_espresso' ),
36
-						'html_label_text' => __( 'Image URL', 'event_espresso' )
37
-					) ),
38
-					'paypal_taxes'     => new EE_Yes_No_Input( array(
39
-						'html_label_text' => sprintf( __( 'Paypal Calculates Taxes %s', 'event_espresso' ), $payment_method_type->get_help_tab_link() ),
40
-						'html_help_text'  => __( 'Whether Paypal should add taxes to the order', 'event_espresso' ),
33
+					)),
34
+					'image_url'        => new EE_Admin_File_Uploader_Input(array(
35
+						'html_help_text'  => __("Used for your business/personal logo on the PayPal page", 'event_espresso'),
36
+						'html_label_text' => __('Image URL', 'event_espresso')
37
+					)),
38
+					'paypal_taxes'     => new EE_Yes_No_Input(array(
39
+						'html_label_text' => sprintf(__('Paypal Calculates Taxes %s', 'event_espresso'), $payment_method_type->get_help_tab_link()),
40
+						'html_help_text'  => __('Whether Paypal should add taxes to the order', 'event_espresso'),
41 41
 						'default'         => false
42
-					) ),
43
-					'paypal_shipping'  => new EE_Yes_No_Input( array(
44
-						'html_label_text' => sprintf( __( 'Paypal Calculates Shipping %s', 'event_espresso' ), $payment_method_type->get_help_tab_link() ),
45
-						'html_help_text'  => __( 'Whether Paypal should add shipping surcharges', 'event_espresso' ),
42
+					)),
43
+					'paypal_shipping'  => new EE_Yes_No_Input(array(
44
+						'html_label_text' => sprintf(__('Paypal Calculates Shipping %s', 'event_espresso'), $payment_method_type->get_help_tab_link()),
45
+						'html_help_text'  => __('Whether Paypal should add shipping surcharges', 'event_espresso'),
46 46
 						'default'         => false
47
-					) ),
48
-					'shipping_details' => new EE_Select_Input( array(
49
-						EE_PMT_Paypal_Standard::shipping_info_none     => __( "Do not prompt for an address", 'event_espresso' ),
50
-						EE_PMT_Paypal_Standard::shipping_info_optional => __( "Prompt for an address, but do not require it", 'event_espresso' ),
51
-						EE_PMT_Paypal_Standard::shipping_info_required => __( "Prompt for an address, and require it", 'event_espresso' )
52
-					) )
47
+					)),
48
+					'shipping_details' => new EE_Select_Input(array(
49
+						EE_PMT_Paypal_Standard::shipping_info_none     => __("Do not prompt for an address", 'event_espresso'),
50
+						EE_PMT_Paypal_Standard::shipping_info_optional => __("Prompt for an address, but do not require it", 'event_espresso'),
51
+						EE_PMT_Paypal_Standard::shipping_info_required => __("Prompt for an address, and require it", 'event_espresso')
52
+					))
53 53
 				)
54 54
 			)
55 55
 		);
@@ -61,28 +61,28 @@  discard block
 block discarded – undo
61 61
      * @param array $req_data
62 62
      * @throws EE_Error
63 63
      */
64
-    public function _normalize( $req_data ) {
65
-		parent::_normalize( $req_data );
66
-		$paypal_calculates_shipping = $this->get_input_value( 'paypal_shipping' );
67
-		$paypal_calculates_taxes = $this->get_input_value( 'paypal_taxes' );
68
-		$paypal_requests_address_info = $this->get_input_value( 'shipping_details' );
64
+    public function _normalize($req_data) {
65
+		parent::_normalize($req_data);
66
+		$paypal_calculates_shipping = $this->get_input_value('paypal_shipping');
67
+		$paypal_calculates_taxes = $this->get_input_value('paypal_taxes');
68
+		$paypal_requests_address_info = $this->get_input_value('shipping_details');
69 69
 		if (
70
-			( $paypal_calculates_shipping || $paypal_calculates_taxes ) &&
70
+			($paypal_calculates_shipping || $paypal_calculates_taxes) &&
71 71
 			$paypal_requests_address_info == EE_PMT_Paypal_Standard::shipping_info_none
72 72
 		) {
73 73
 			//they want paypal to calculate taxes or shipping. They need to ask for
74 74
 			//address info, otherwise paypal can't calculate taxes or shipping
75 75
 			/** @type EE_Select_Input $shipping_details_input */
76
-			$shipping_details_input = $this->get_input( 'shipping_details' );
77
-			$shipping_details_input->set_default( EE_PMT_Paypal_Standard::shipping_info_optional );
76
+			$shipping_details_input = $this->get_input('shipping_details');
77
+			$shipping_details_input->set_default(EE_PMT_Paypal_Standard::shipping_info_optional);
78 78
 			$shipping_details_input_options = $shipping_details_input->options();
79 79
 			EE_Error::add_attention(
80 80
 				sprintf(
81
-					__( 'Automatically set "%s" to "%s" because Paypal requires address info in order to calculate shipping or taxes.', 'event_espresso' ),
82
-					strip_tags( $shipping_details_input->html_label_text() ),
83
-					isset( $shipping_details_input_options[ EE_PMT_Paypal_Standard::shipping_info_optional ] )
84
-						? $shipping_details_input_options[ EE_PMT_Paypal_Standard::shipping_info_optional ]
85
-						: __( 'Unknown', 'event_espresso' )
81
+					__('Automatically set "%s" to "%s" because Paypal requires address info in order to calculate shipping or taxes.', 'event_espresso'),
82
+					strip_tags($shipping_details_input->html_label_text()),
83
+					isset($shipping_details_input_options[EE_PMT_Paypal_Standard::shipping_info_optional])
84
+						? $shipping_details_input_options[EE_PMT_Paypal_Standard::shipping_info_optional]
85
+						: __('Unknown', 'event_espresso')
86 86
 				),
87 87
 				__FILE__, __FUNCTION__, __LINE__
88 88
 			);
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Form_Input_Base.input.php 1 patch
Spacing   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @subpackage
9 9
  * @author				Mike Nelson
10 10
  */
11
-abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable{
11
+abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable {
12 12
 
13 13
 	/**
14 14
 	 * the input's name attribute
@@ -143,54 +143,54 @@  discard block
 block discarded – undo
143 143
 	 *  @type EE_Validation_Strategy_Base[]  $validation_strategies
144 144
 	 * }
145 145
 	 */
146
-	public function __construct( $input_args = array() ){
147
-		$input_args = (array) apply_filters( 'FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this );
146
+	public function __construct($input_args = array()) {
147
+		$input_args = (array) apply_filters('FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this);
148 148
 		// the following properties must be cast as arrays
149
-		if ( isset( $input_args['validation_strategies'] ) ) {
150
-			foreach ( (array) $input_args['validation_strategies'] as $validation_strategy ) {
151
-				if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) {
152
-					$this->_validation_strategies[ get_class( $validation_strategy ) ] = $validation_strategy;
149
+		if (isset($input_args['validation_strategies'])) {
150
+			foreach ((array) $input_args['validation_strategies'] as $validation_strategy) {
151
+				if ($validation_strategy instanceof EE_Validation_Strategy_Base) {
152
+					$this->_validation_strategies[get_class($validation_strategy)] = $validation_strategy;
153 153
 				}
154 154
 			}
155
-			unset( $input_args['validation_strategies'] );
155
+			unset($input_args['validation_strategies']);
156 156
 		}
157 157
 		// loop thru incoming options
158
-		foreach( $input_args as $key => $value ) {
158
+		foreach ($input_args as $key => $value) {
159 159
 			// add underscore to $key to match property names
160
-			$_key = '_' . $key;
161
-			if ( property_exists( $this, $_key )) {
160
+			$_key = '_'.$key;
161
+			if (property_exists($this, $_key)) {
162 162
 				$this->{$_key} = $value;
163 163
 			}
164 164
 		}
165 165
 		// ensure that "required" is set correctly
166 166
 		$this->set_required(
167
-			$this->_required, isset( $input_args[ 'required_validation_error_message' ] )
168
-				? $input_args[ 'required_validation_error_message' ]
167
+			$this->_required, isset($input_args['required_validation_error_message'])
168
+				? $input_args['required_validation_error_message']
169 169
 				: null
170 170
 		);
171 171
 
172 172
 		//$this->_html_name_specified = isset( $input_args['html_name'] ) ? TRUE : FALSE;
173 173
 
174 174
 		$this->_display_strategy->_construct_finalize($this);
175
-		foreach( $this->_validation_strategies as $validation_strategy ){
175
+		foreach ($this->_validation_strategies as $validation_strategy) {
176 176
 			$validation_strategy->_construct_finalize($this);
177 177
 		}
178 178
 
179
-		if( ! $this->_normalization_strategy){
179
+		if ( ! $this->_normalization_strategy) {
180 180
 			$this->_normalization_strategy = new EE_Text_Normalization();
181 181
 		}
182 182
 		$this->_normalization_strategy->_construct_finalize($this);
183 183
 
184 184
 		//at least we can use the normalization strategy to populate the default
185
-		if( isset( $input_args[ 'default' ] ) ) {
186
-			$this->set_default( $input_args[ 'default' ] );
185
+		if (isset($input_args['default'])) {
186
+			$this->set_default($input_args['default']);
187 187
 		}
188 188
 
189
-		if( ! $this->_sensitive_data_removal_strategy){
189
+		if ( ! $this->_sensitive_data_removal_strategy) {
190 190
 			$this->_sensitive_data_removal_strategy = new EE_No_Sensitive_Data_Removal();
191 191
 		}
192 192
 		$this->_sensitive_data_removal_strategy->_construct_finalize($this);
193
-		parent::__construct( $input_args );
193
+		parent::__construct($input_args);
194 194
 	}
195 195
 
196 196
 
@@ -201,11 +201,11 @@  discard block
 block discarded – undo
201 201
 	 *
202 202
 	 * @throws \EE_Error
203 203
 	 */
204
-	protected function _set_default_html_name_if_empty(){
205
-		if( ! $this->_html_name){
204
+	protected function _set_default_html_name_if_empty() {
205
+		if ( ! $this->_html_name) {
206 206
 			$this->_html_name = $this->name();
207
-			if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper){
208
-				$this->_html_name = $this->_parent_section->html_name_prefix() . "[{$this->name()}]";
207
+			if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) {
208
+				$this->_html_name = $this->_parent_section->html_name_prefix()."[{$this->name()}]";
209 209
 			}
210 210
 		}
211 211
 	}
@@ -219,10 +219,10 @@  discard block
 block discarded – undo
219 219
 	 */
220 220
 	public function _construct_finalize($parent_form_section, $name) {
221 221
 		parent::_construct_finalize($parent_form_section, $name);
222
-		if( $this->_html_label === null && $this->_html_label_text === null ){
223
-			$this->_html_label_text = ucwords( str_replace("_"," ",$name));
222
+		if ($this->_html_label === null && $this->_html_label_text === null) {
223
+			$this->_html_label_text = ucwords(str_replace("_", " ", $name));
224 224
 		}
225
-		do_action( 'AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name );
225
+		do_action('AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name);
226 226
 	}
227 227
 
228 228
 	 /**
@@ -230,9 +230,9 @@  discard block
 block discarded – undo
230 230
 	  * @return EE_Display_Strategy_Base
231 231
 	  * @throws EE_Error
232 232
 	  */
233
-	protected function _get_display_strategy(){
233
+	protected function _get_display_strategy() {
234 234
 		$this->ensure_construct_finalized_called();
235
-		if( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base){
235
+		if ( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base) {
236 236
 			throw new EE_Error(
237 237
 				sprintf(
238 238
 					__(
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 					$this->html_id()
244 244
 				)
245 245
 			);
246
-		}else{
246
+		} else {
247 247
 			return $this->_display_strategy;
248 248
 		}
249 249
 	}
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 	 * Sets the display strategy.
252 252
 	 * @param EE_Display_Strategy_Base $strategy
253 253
 	 */
254
-	protected function _set_display_strategy(EE_Display_Strategy_Base $strategy){
254
+	protected function _set_display_strategy(EE_Display_Strategy_Base $strategy) {
255 255
 		$this->_display_strategy = $strategy;
256 256
 	}
257 257
 
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 	 * Sets the sanitization strategy
260 260
 	 * @param EE_Normalization_Strategy_Base $strategy
261 261
 	 */
262
-	protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy){
262
+	protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy) {
263 263
 		$this->_normalization_strategy = $strategy;
264 264
 	}
265 265
 
@@ -285,14 +285,14 @@  discard block
 block discarded – undo
285 285
 	 * Gets the display strategy for this input
286 286
 	 * @return EE_Display_Strategy_Base
287 287
 	 */
288
-	public function get_display_strategy(){
288
+	public function get_display_strategy() {
289 289
 		return $this->_display_strategy;
290 290
 	}
291 291
 	/**
292 292
 	 * Overwrites the display strategy
293 293
 	 * @param EE_Display_Strategy_Base $display_strategy
294 294
 	 */
295
-	public function set_display_strategy($display_strategy){
295
+	public function set_display_strategy($display_strategy) {
296 296
 		$this->_display_strategy = $display_strategy;
297 297
 		$this->_display_strategy->_construct_finalize($this);
298 298
 	}
@@ -300,14 +300,14 @@  discard block
 block discarded – undo
300 300
 	 * Gets the normalization strategy set on this input
301 301
 	 * @return EE_Normalization_Strategy_Base
302 302
 	 */
303
-	public function get_normalization_strategy(){
303
+	public function get_normalization_strategy() {
304 304
 		return $this->_normalization_strategy;
305 305
 	}
306 306
 	/**
307 307
 	 * Overwrites the normalization strategy
308 308
 	 * @param EE_Normalization_Strategy_Base $normalization_strategy
309 309
 	 */
310
-	public function set_normalization_strategy($normalization_strategy){
310
+	public function set_normalization_strategy($normalization_strategy) {
311 311
 		$this->_normalization_strategy = $normalization_strategy;
312 312
 		$this->_normalization_strategy->_construct_finalize($this);
313 313
 	}
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 	 * Returns all teh validation strategies which apply to this field, numerically indexed
317 317
 	 * @return EE_Validation_Strategy_Base[]
318 318
 	 */
319
-	public function get_validation_strategies(){
319
+	public function get_validation_strategies() {
320 320
 		return $this->_validation_strategies;
321 321
 	}
322 322
 
@@ -327,8 +327,8 @@  discard block
 block discarded – undo
327 327
 	 * @param EE_Validation_Strategy_Base $validation_strategy
328 328
 	 * @return void
329 329
 	 */
330
-	protected function _add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ){
331
-		$validation_strategy->_construct_finalize( $this );
330
+	protected function _add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) {
331
+		$validation_strategy->_construct_finalize($this);
332 332
 		$this->_validation_strategies[] = $validation_strategy;
333 333
 	}
334 334
 
@@ -339,8 +339,8 @@  discard block
 block discarded – undo
339 339
 	 * @param EE_Validation_Strategy_Base $validation_strategy
340 340
 	 * @return void
341 341
 	 */
342
-	public function add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ) {
343
-		$this->_add_validation_strategy( $validation_strategy );
342
+	public function add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) {
343
+		$this->_add_validation_strategy($validation_strategy);
344 344
 	}
345 345
 
346 346
 
@@ -350,13 +350,13 @@  discard block
 block discarded – undo
350 350
 	 *
351 351
 	 * @param string $validation_strategy_classname
352 352
 	 */
353
-	public function remove_validation_strategy( $validation_strategy_classname ) {
354
-		foreach( $this->_validation_strategies as $key => $validation_strategy ){
355
-			if(
353
+	public function remove_validation_strategy($validation_strategy_classname) {
354
+		foreach ($this->_validation_strategies as $key => $validation_strategy) {
355
+			if (
356 356
 				$validation_strategy instanceof $validation_strategy_classname
357
-				|| is_subclass_of( $validation_strategy, $validation_strategy_classname )
357
+				|| is_subclass_of($validation_strategy, $validation_strategy_classname)
358 358
 			) {
359
-				unset( $this->_validation_strategies[ $key ] );
359
+				unset($this->_validation_strategies[$key]);
360 360
 			}
361 361
 		}
362 362
 	}
@@ -369,12 +369,12 @@  discard block
 block discarded – undo
369 369
 	 * @param array $validation_strategy_classnames
370 370
 	 * @return bool
371 371
 	 */
372
-	public function has_validation_strategy( $validation_strategy_classnames ) {
373
-		$validation_strategy_classnames = is_array( $validation_strategy_classnames )
372
+	public function has_validation_strategy($validation_strategy_classnames) {
373
+		$validation_strategy_classnames = is_array($validation_strategy_classnames)
374 374
 			? $validation_strategy_classnames
375
-			: array( $validation_strategy_classnames );
376
-		foreach( $this->_validation_strategies as $key => $validation_strategy ){
377
-			if( in_array( $key, $validation_strategy_classnames ) ) {
375
+			: array($validation_strategy_classnames);
376
+		foreach ($this->_validation_strategies as $key => $validation_strategy) {
377
+			if (in_array($key, $validation_strategy_classnames)) {
378 378
 				return true;
379 379
 			}
380 380
 		}
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 	 * Gets the HTML
388 388
 	 * @return string
389 389
 	 */
390
-	public function get_html(){
390
+	public function get_html() {
391 391
 		return $this->_parent_section->get_html_for_input($this);
392 392
 	}
393 393
 
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
 	 * @return string
402 402
 	 * @throws \EE_Error
403 403
 	 */
404
-	public function get_html_for_input(){
404
+	public function get_html_for_input() {
405 405
 		
406 406
 		return  $this->_get_display_strategy()->display();
407 407
 	}
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
 	 * @return string
413 413
 	 */
414 414
 	public function html_other_attributes() {
415
-		return ! empty( $this->_html_other_attributes ) ? ' ' . $this->_html_other_attributes : '';
415
+		return ! empty($this->_html_other_attributes) ? ' '.$this->_html_other_attributes : '';
416 416
 	}
417 417
 
418 418
 
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
 	/**
421 421
 	 * @param string $html_other_attributes
422 422
 	 */
423
-	public function set_html_other_attributes( $html_other_attributes ) {
423
+	public function set_html_other_attributes($html_other_attributes) {
424 424
 		$this->_html_other_attributes = $html_other_attributes;
425 425
 	}
426 426
 
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 	 * according to the form section's layout strategy
430 430
 	 * @return string
431 431
 	 */
432
-	public function get_html_for_label(){
432
+	public function get_html_for_label() {
433 433
 		return $this->_parent_section->get_layout_strategy()->display_label($this);
434 434
 	}
435 435
 	/**
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 	 * according to the form section's layout strategy
438 438
 	 * @return string
439 439
 	 */
440
-	public function get_html_for_errors(){
440
+	public function get_html_for_errors() {
441 441
 		return $this->_parent_section->get_layout_strategy()->display_errors($this);
442 442
 	}
443 443
 	/**
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 	 * according to the form section's layout strategy
446 446
 	 * @return string
447 447
 	 */
448
-	public function get_html_for_help(){
448
+	public function get_html_for_help() {
449 449
 		return $this->_parent_section->get_layout_strategy()->display_help_text($this);
450 450
 	}
451 451
 	/**
@@ -454,18 +454,18 @@  discard block
 block discarded – undo
454 454
 	 * @return boolean
455 455
 	 */
456 456
 	protected function _validate() {
457
-		foreach($this->_validation_strategies as $validation_strategy){
458
-			if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) {
459
-				try{
457
+		foreach ($this->_validation_strategies as $validation_strategy) {
458
+			if ($validation_strategy instanceof EE_Validation_Strategy_Base) {
459
+				try {
460 460
 					$validation_strategy->validate($this->normalized_value());
461
-				}catch(EE_Validation_Error $e){
461
+				} catch (EE_Validation_Error $e) {
462 462
 					$this->add_validation_error($e);
463 463
 				}
464 464
 			}
465 465
 		}
466
-		if( $this->get_validation_errors()){
466
+		if ($this->get_validation_errors()) {
467 467
 			return false;
468
-		}else{
468
+		} else {
469 469
 			return true;
470 470
 		}
471 471
 	}
@@ -479,8 +479,8 @@  discard block
 block discarded – undo
479 479
 	 * @param string $value
480 480
 	 * @return null|string
481 481
 	 */
482
-	private function _sanitize( $value ) {
483
-		return $value !== null ? stripslashes( html_entity_decode( trim( $value ) ) ) : null;
482
+	private function _sanitize($value) {
483
+		return $value !== null ? stripslashes(html_entity_decode(trim($value))) : null;
484 484
 	}
485 485
 
486 486
 
@@ -494,25 +494,25 @@  discard block
 block discarded – undo
494 494
 	 * @return boolean whether or not there was an error
495 495
 	 * @throws \EE_Error
496 496
 	 */
497
-	protected function _normalize( $req_data ) {
497
+	protected function _normalize($req_data) {
498 498
 		//any existing validation errors don't apply so clear them
499 499
 		$this->_validation_errors = array();
500 500
 		try {
501
-			$raw_input = $this->find_form_data_for_this_section( $req_data );
501
+			$raw_input = $this->find_form_data_for_this_section($req_data);
502 502
 			//super simple sanitization for now
503
-			if ( is_array( $raw_input )) {
503
+			if (is_array($raw_input)) {
504 504
 				$raw_value = array();
505
-				foreach( $raw_input as $key => $value ) {
506
-					$raw_value[ $key ] = $this->_sanitize( $value );
505
+				foreach ($raw_input as $key => $value) {
506
+					$raw_value[$key] = $this->_sanitize($value);
507 507
 				}
508
-				$this->_set_raw_value( $raw_value );
508
+				$this->_set_raw_value($raw_value);
509 509
 			} else {
510
-				$this->_set_raw_value( $this->_sanitize( $raw_input ) );
510
+				$this->_set_raw_value($this->_sanitize($raw_input));
511 511
 			}
512 512
 			//we want to mostly leave the input alone in case we need to re-display it to the user
513
-			$this->_set_normalized_value( $this->_normalization_strategy->normalize( $this->raw_value() ) );
514
-		} catch ( EE_Validation_Error $e ) {
515
-			$this->add_validation_error( $e );
513
+			$this->_set_normalized_value($this->_normalization_strategy->normalize($this->raw_value()));
514
+		} catch (EE_Validation_Error $e) {
515
+			$this->add_validation_error($e);
516 516
 		}
517 517
 	}
518 518
 
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
 	/**
522 522
 	 * @return string
523 523
 	 */
524
-	public function html_name(){
524
+	public function html_name() {
525 525
 		$this->_set_default_html_name_if_empty();
526 526
 		return $this->_html_name;
527 527
 	}
@@ -531,8 +531,8 @@  discard block
 block discarded – undo
531 531
 	/**
532 532
 	 * @return string
533 533
 	 */
534
-	public function html_label_id(){
535
-		return ! empty( $this->_html_label_id ) ? $this->_html_label_id : $this->_html_id . '-lbl';
534
+	public function html_label_id() {
535
+		return ! empty($this->_html_label_id) ? $this->_html_label_id : $this->_html_id.'-lbl';
536 536
 	}
537 537
 
538 538
 
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
 	/**
541 541
 	 * @return string
542 542
 	 */
543
-	public function html_label_class(){
543
+	public function html_label_class() {
544 544
 		return $this->_html_label_class;
545 545
 	}
546 546
 
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
 	/**
550 550
 	 * @return string
551 551
 	 */
552
-	public function html_label_style(){
552
+	public function html_label_style() {
553 553
 		return $this->_html_label_style;
554 554
 	}
555 555
 
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
 	/**
559 559
 	 * @return string
560 560
 	 */
561
-	public function html_label_text(){
561
+	public function html_label_text() {
562 562
 		return $this->_html_label_text;
563 563
 	}
564 564
 
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
 	/**
568 568
 	 * @return string
569 569
 	 */
570
-	public function html_help_text(){
570
+	public function html_help_text() {
571 571
 		return $this->_html_help_text;
572 572
 	}
573 573
 
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
 	/**
577 577
 	 * @return string
578 578
 	 */
579
-	public function html_help_class(){
579
+	public function html_help_class() {
580 580
 		return $this->_html_help_class;
581 581
 	}
582 582
 
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
 	/**
586 586
 	 * @return string
587 587
 	 */
588
-	public function html_help_style(){
588
+	public function html_help_style() {
589 589
 		return $this->_html_style;
590 590
 	}
591 591
 	/**
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
 	 * in which case, we would have stored the malicious content to our database.
599 599
 	 * @return string
600 600
 	 */
601
-	public function raw_value(){
601
+	public function raw_value() {
602 602
 		return $this->_raw_value;
603 603
 	}
604 604
 	/**
@@ -606,15 +606,15 @@  discard block
 block discarded – undo
606 606
 	 * it escapes all html entities
607 607
 	 * @return string
608 608
 	 */
609
-	public function raw_value_in_form(){
610
-		return htmlentities($this->raw_value(),ENT_QUOTES, 'UTF-8');
609
+	public function raw_value_in_form() {
610
+		return htmlentities($this->raw_value(), ENT_QUOTES, 'UTF-8');
611 611
 	}
612 612
 	/**
613 613
 	 * returns the value after it's been sanitized, and then converted into it's proper type
614 614
 	 * in PHP. Eg, a string, an int, an array,
615 615
 	 * @return mixed
616 616
 	 */
617
-	public function normalized_value(){
617
+	public function normalized_value() {
618 618
 		return $this->_normalized_value;
619 619
 	}
620 620
 
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
 	 * the best thing to display
625 625
 	 * @return string
626 626
 	 */
627
-	public function pretty_value(){
627
+	public function pretty_value() {
628 628
 		return $this->_normalized_value;
629 629
 	}
630 630
 	/**
@@ -643,19 +643,19 @@  discard block
 block discarded – undo
643 643
 		  }</code>
644 644
 	 * @return array
645 645
 	 */
646
-	public function get_jquery_validation_rules(){
646
+	public function get_jquery_validation_rules() {
647 647
 		$jquery_validation_js = array();
648 648
 		$jquery_validation_rules = array();
649
-		foreach($this->get_validation_strategies() as $validation_strategy){
649
+		foreach ($this->get_validation_strategies() as $validation_strategy) {
650 650
 			$jquery_validation_rules = array_replace_recursive(
651 651
 				$jquery_validation_rules,
652 652
 				$validation_strategy->get_jquery_validation_rule_array()
653 653
 			);
654 654
 		}
655 655
 
656
-		if(! empty($jquery_validation_rules)){
657
-			foreach( $this->get_display_strategy()->get_html_input_ids( true ) as $html_id_with_pound_sign ) {
658
-				$jquery_validation_js[ $html_id_with_pound_sign ] = $jquery_validation_rules;
656
+		if ( ! empty($jquery_validation_rules)) {
657
+			foreach ($this->get_display_strategy()->get_html_input_ids(true) as $html_id_with_pound_sign) {
658
+				$jquery_validation_js[$html_id_with_pound_sign] = $jquery_validation_rules;
659 659
 			}
660 660
 		}
661 661
 		return $jquery_validation_js;
@@ -667,16 +667,16 @@  discard block
 block discarded – undo
667 667
 	 * @param mixed $value
668 668
 	 * @return void
669 669
 	 */
670
-	public function set_default($value){
671
-		$this->_set_normalized_value( $value );
672
-		$this->_set_raw_value( $value );
670
+	public function set_default($value) {
671
+		$this->_set_normalized_value($value);
672
+		$this->_set_raw_value($value);
673 673
 	}
674 674
 	
675 675
 	/**
676 676
 	 * Sets the normalized value on this input
677 677
 	 * @param mixed $value
678 678
 	 */
679
-	protected function _set_normalized_value( $value ) {
679
+	protected function _set_normalized_value($value) {
680 680
 		$this->_normalized_value = $value;
681 681
 	}
682 682
 	
@@ -684,8 +684,8 @@  discard block
 block discarded – undo
684 684
 	 * Sets the raw value on this input (ie, exactly as the user submitted it)
685 685
 	 * @param mixed $value
686 686
 	 */
687
-	protected function _set_raw_value( $value ) {
688
-		$this->_raw_value = $this->_normalization_strategy->unnormalize( $value );
687
+	protected function _set_raw_value($value) {
688
+		$this->_raw_value = $this->_normalization_strategy->unnormalize($value);
689 689
 	}
690 690
 
691 691
 	/**
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
 	 * @param string $label
694 694
 	 * @return void
695 695
 	 */
696
-	public function set_html_label_text($label){
696
+	public function set_html_label_text($label) {
697 697
 		$this->_html_label_text = $label;
698 698
 	}
699 699
 
@@ -707,13 +707,13 @@  discard block
 block discarded – undo
707 707
 	 * @param boolean $required boolean
708 708
 	 * @param null    $required_text
709 709
 	 */
710
-	public function set_required($required = true, $required_text = NULL ){
711
-		$required = filter_var( $required, FILTER_VALIDATE_BOOLEAN  );
710
+	public function set_required($required = true, $required_text = NULL) {
711
+		$required = filter_var($required, FILTER_VALIDATE_BOOLEAN);
712 712
 		//whether $required is a string or a boolean, we want to add a required validation strategy
713
-		if ( $required ) {
714
-			$this->_add_validation_strategy( new EE_Required_Validation_Strategy( $required_text ) );
713
+		if ($required) {
714
+			$this->_add_validation_strategy(new EE_Required_Validation_Strategy($required_text));
715 715
 		} else {
716
-			$this->remove_validation_strategy( 'EE_Required_Validation_Strategy' );
716
+			$this->remove_validation_strategy('EE_Required_Validation_Strategy');
717 717
 		}
718 718
 		$this->_required = $required;
719 719
 	}
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
 	 * Returns whether or not this field is required
722 722
 	 * @return boolean
723 723
 	 */
724
-	public function required(){
724
+	public function required() {
725 725
 		return $this->_required;
726 726
 	}
727 727
 
@@ -730,7 +730,7 @@  discard block
 block discarded – undo
730 730
 	/**
731 731
 	 * @param string $required_css_class
732 732
 	 */
733
-	public function set_required_css_class( $required_css_class ) {
733
+	public function set_required_css_class($required_css_class) {
734 734
 		$this->_required_css_class = $required_css_class;
735 735
 	}
736 736
 
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
 	 * Sets the help text, in case
750 750
 	 * @param string $text
751 751
 	 */
752
-	public function set_html_help_text($text){
752
+	public function set_html_help_text($text) {
753 753
 		$this->_html_help_text = $text;
754 754
 	}
755 755
 	/**
@@ -761,9 +761,9 @@  discard block
 block discarded – undo
761 761
 	public function clean_sensitive_data() {
762 762
 		//if we do ANY kind of sensitive data removal on this, then just clear out the raw value
763 763
 		//if we need more logic than this we'll make a strategy for it
764
-		if( $this->_sensitive_data_removal_strategy &&
765
-				! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal ){
766
-			$this->_set_raw_value( null );
764
+		if ($this->_sensitive_data_removal_strategy &&
765
+				! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal) {
766
+			$this->_set_raw_value(null);
767 767
 		}
768 768
 		//and clean the normalized value according to the appropriate strategy
769 769
 		$this->_set_normalized_value(
@@ -780,10 +780,10 @@  discard block
 block discarded – undo
780 780
 	 * @param string $button_size
781 781
 	 * @param string $other_attributes
782 782
 	 */
783
-	public function set_button_css_attributes( $primary = TRUE, $button_size = '', $other_attributes = '' ) {
783
+	public function set_button_css_attributes($primary = TRUE, $button_size = '', $other_attributes = '') {
784 784
 		$button_css_attributes = 'button';
785 785
 		$button_css_attributes .= $primary === TRUE ? ' button-primary' : ' button-secondary';
786
-		switch ( $button_size ) {
786
+		switch ($button_size) {
787 787
 			case 'xs' :
788 788
 			case 'extra-small' :
789 789
 				$button_css_attributes .= ' button-xs';
@@ -804,8 +804,8 @@  discard block
 block discarded – undo
804 804
 			default :
805 805
 				$button_css_attributes .= '';
806 806
 		}
807
-		$this->_button_css_attributes .= ! empty( $other_attributes )
808
-			? $button_css_attributes . ' ' . $other_attributes
807
+		$this->_button_css_attributes .= ! empty($other_attributes)
808
+			? $button_css_attributes.' '.$other_attributes
809 809
 			: $button_css_attributes;
810 810
 	}
811 811
 
@@ -815,7 +815,7 @@  discard block
 block discarded – undo
815 815
 	 * @return string
816 816
 	 */
817 817
 	public function button_css_attributes() {
818
-		if ( empty( $this->_button_css_attributes )) {
818
+		if (empty($this->_button_css_attributes)) {
819 819
 			$this->set_button_css_attributes();
820 820
 		}
821 821
 		return $this->_button_css_attributes;
@@ -837,26 +837,26 @@  discard block
 block discarded – undo
837 837
 	 * @return mixed whatever the raw value of this form section is in the request data
838 838
 	 * @throws \EE_Error
839 839
 	 */
840
-	public function find_form_data_for_this_section( $req_data ){
840
+	public function find_form_data_for_this_section($req_data) {
841 841
 		// break up the html name by "[]"
842
-		if ( strpos( $this->html_name(), '[' ) !== FALSE ) {
843
-			$before_any_brackets = substr( $this->html_name(), 0, strpos($this->html_name(), '[') );
842
+		if (strpos($this->html_name(), '[') !== FALSE) {
843
+			$before_any_brackets = substr($this->html_name(), 0, strpos($this->html_name(), '['));
844 844
 		} else {
845 845
 			$before_any_brackets = $this->html_name();
846 846
 		}
847 847
 		// grab all of the segments
848
-		preg_match_all('~\[([^]]*)\]~',$this->html_name(), $matches);
849
-		if( isset( $matches[ 1 ] ) && is_array( $matches[ 1 ] ) ){
850
-			$name_parts = $matches[ 1 ];
848
+		preg_match_all('~\[([^]]*)\]~', $this->html_name(), $matches);
849
+		if (isset($matches[1]) && is_array($matches[1])) {
850
+			$name_parts = $matches[1];
851 851
 			array_unshift($name_parts, $before_any_brackets);
852
-		}else{
853
-			$name_parts = array( $before_any_brackets );
852
+		} else {
853
+			$name_parts = array($before_any_brackets);
854 854
 		}
855 855
 		// now get the value for the input
856 856
 		$value = $this->_find_form_data_for_this_section_using_name_parts($name_parts, $req_data);
857 857
 		// check if this thing's name is at the TOP level of the request data
858
-		if( $value === null && isset( $req_data[ $this->name() ] ) ){
859
-			$value = $req_data[ $this->name() ];
858
+		if ($value === null && isset($req_data[$this->name()])) {
859
+			$value = $req_data[$this->name()];
860 860
 		}
861 861
 		return $value;
862 862
 	}
@@ -869,18 +869,18 @@  discard block
 block discarded – undo
869 869
 	 * @param array $req_data
870 870
 	 * @return array | NULL
871 871
 	 */
872
-	public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data){
873
-		$first_part_to_consider = array_shift( $html_name_parts );
874
-		if( isset( $req_data[ $first_part_to_consider ] ) ){
875
-			if( empty($html_name_parts ) ){
876
-				return $req_data[ $first_part_to_consider ];
877
-			}else{
872
+	public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data) {
873
+		$first_part_to_consider = array_shift($html_name_parts);
874
+		if (isset($req_data[$first_part_to_consider])) {
875
+			if (empty($html_name_parts)) {
876
+				return $req_data[$first_part_to_consider];
877
+			} else {
878 878
 				return $this->_find_form_data_for_this_section_using_name_parts(
879 879
 					$html_name_parts,
880
-					$req_data[ $first_part_to_consider ]
880
+					$req_data[$first_part_to_consider]
881 881
 				);
882 882
 			}
883
-		}else{
883
+		} else {
884 884
 			return NULL;
885 885
 		}
886 886
 	}
@@ -894,14 +894,14 @@  discard block
 block discarded – undo
894 894
 	 * @return boolean
895 895
 	 * @throws \EE_Error
896 896
 	 */
897
-	public function form_data_present_in($req_data = NULL){
898
-		if( $req_data === NULL ){
897
+	public function form_data_present_in($req_data = NULL) {
898
+		if ($req_data === NULL) {
899 899
 			$req_data = $_POST;
900 900
 		}
901
-		$checked_value = $this->find_form_data_for_this_section( $req_data );
902
-		if( $checked_value !== null ){
901
+		$checked_value = $this->find_form_data_for_this_section($req_data);
902
+		if ($checked_value !== null) {
903 903
 			return TRUE;
904
-		}else{
904
+		} else {
905 905
 			return FALSE;
906 906
 		}
907 907
 	}
@@ -912,8 +912,8 @@  discard block
 block discarded – undo
912 912
 	 * @param array $form_other_js_data
913 913
 	 * @return array
914 914
 	 */
915
-	public function get_other_js_data( $form_other_js_data = array() ) {
916
-		$form_other_js_data = $this->get_other_js_data_from_strategies( $form_other_js_data );
915
+	public function get_other_js_data($form_other_js_data = array()) {
916
+		$form_other_js_data = $this->get_other_js_data_from_strategies($form_other_js_data);
917 917
 		return $form_other_js_data;
918 918
 	}
919 919
 
@@ -926,10 +926,10 @@  discard block
 block discarded – undo
926 926
 	 * @param array $form_other_js_data
927 927
 	 * @return array
928 928
 	 */
929
-	public function get_other_js_data_from_strategies( $form_other_js_data = array() ) {
930
-		$form_other_js_data = $this->get_display_strategy()->get_other_js_data( $form_other_js_data );
931
-		foreach( $this->get_validation_strategies() as $validation_strategy ) {
932
-			$form_other_js_data = $validation_strategy->get_other_js_data( $form_other_js_data );
929
+	public function get_other_js_data_from_strategies($form_other_js_data = array()) {
930
+		$form_other_js_data = $this->get_display_strategy()->get_other_js_data($form_other_js_data);
931
+		foreach ($this->get_validation_strategies() as $validation_strategy) {
932
+			$form_other_js_data = $validation_strategy->get_other_js_data($form_other_js_data);
933 933
 		}
934 934
 		return $form_other_js_data;
935 935
 	}
@@ -938,7 +938,7 @@  discard block
 block discarded – undo
938 938
 	 * Override parent because we want to give our strategies an opportunity to enqueue some js and css
939 939
 	 * @return void
940 940
 	 */
941
-	public function enqueue_js(){
941
+	public function enqueue_js() {
942 942
 		//ask our display strategy and validation strategies if they have js to enqueue
943 943
 		$this->enqueue_js_from_strategies();
944 944
 	}
@@ -949,7 +949,7 @@  discard block
 block discarded – undo
949 949
 	 */
950 950
 	public function enqueue_js_from_strategies() {
951 951
 		$this->get_display_strategy()->enqueue_js();
952
-		foreach( $this->get_validation_strategies() as $validation_strategy ) {
952
+		foreach ($this->get_validation_strategies() as $validation_strategy) {
953 953
 			$validation_strategy->enqueue_js();
954 954
 		}
955 955
 	}
Please login to merge, or discard this patch.
help_tours/Registration_Form_Question_Groups_Help_Tour.class.php 2 patches
Indentation   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('NO direct script access allowed');
3
+	exit('NO direct script access allowed');
4 4
 }
5 5
 
6 6
 /**
@@ -18,130 +18,130 @@  discard block
 block discarded – undo
18 18
 class Registration_Form_Question_Groups_Help_Tour extends EE_Help_Tour
19 19
 {
20 20
     
21
-    protected function _set_tour_properties()
22
-    {
23
-        $this->_label = __('Question Groups Tour', 'event_espresso');
24
-        $this->_slug  = $this->_is_caf ? 'question-groups-caf-overview-joyride' : 'question-groups-overview-joyride';
25
-    }
21
+	protected function _set_tour_properties()
22
+	{
23
+		$this->_label = __('Question Groups Tour', 'event_espresso');
24
+		$this->_slug  = $this->_is_caf ? 'question-groups-caf-overview-joyride' : 'question-groups-overview-joyride';
25
+	}
26 26
     
27 27
     
28
-    protected function _set_tour_stops()
29
-    {
30
-        $this->_stops = array(
31
-            10 => array(
32
-                'content' => $this->_start(),
33
-            )
34
-        );
28
+	protected function _set_tour_stops()
29
+	{
30
+		$this->_stops = array(
31
+			10 => array(
32
+				'content' => $this->_start(),
33
+			)
34
+		);
35 35
         
36
-        if ($this->_is_caf) {
37
-            $this->_stops[20] = array(
38
-                'id'      => 'name',
39
-                'content' => $this->_name_stop(),
40
-                'options' => array(
41
-                    'tipLocation'    => 'top',
42
-                    'tipAdjustmentY' => -30,
43
-                    'tipAdjustmentX' => 25
44
-                )
45
-            );
46
-            $this->_stops[30] = array(
47
-                'id'      => 'description',
48
-                'content' => $this->_description_stop(),
49
-                'options' => array(
50
-                    'tipLocation'    => 'top',
51
-                    'tipAdjustmentY' => -30,
52
-                    'tipAdjustmentX' => 20
53
-                )
54
-            );
55
-            $this->_stops[40] = array(
56
-                'id'      => 'show_group_name',
57
-                'content' => $this->_show_group_name_stop(),
58
-                'options' => array(
59
-                    'tipLocation'    => 'top',
60
-                    'tipAdjustmentY' => -30,
61
-                    'tipAdjustmentX' => 20
62
-                )
63
-            );
64
-            $this->_stops[50] = array(
65
-                'id'      => 'show_group_desc',
66
-                'content' => $this->_show_group_description_stop(),
67
-                'options' => array(
68
-                    'tipLocation'    => 'top',
69
-                    'tipAdjustmentY' => -30,
70
-                    'tipAdjustmentX' => 20
71
-                )
72
-            );
73
-            $this->_stops[60] = array(
74
-                'class'   => 'bulkactions',
75
-                'content' => $this->_bulk_actions_stop(),
76
-                'options' => array(
77
-                    'tipLocation'    => 'left',
78
-                    'tipAdjustmentY' => -50,
79
-                    'tipAdjustmentX' => -80
80
-                )
81
-            );
82
-            $this->_stops[70] = array(
83
-                'id'      => 'add-new-question-group',
84
-                'content' => $this->_add_new_question_group_stop(),
85
-                'options' => array(
86
-                    'tipLocation'    => 'right',
87
-                    'tipAdjustmentY' => -50,
88
-                    'tipAdjustmentX' => 15
89
-                )
90
-            );
91
-        }
92
-    }
36
+		if ($this->_is_caf) {
37
+			$this->_stops[20] = array(
38
+				'id'      => 'name',
39
+				'content' => $this->_name_stop(),
40
+				'options' => array(
41
+					'tipLocation'    => 'top',
42
+					'tipAdjustmentY' => -30,
43
+					'tipAdjustmentX' => 25
44
+				)
45
+			);
46
+			$this->_stops[30] = array(
47
+				'id'      => 'description',
48
+				'content' => $this->_description_stop(),
49
+				'options' => array(
50
+					'tipLocation'    => 'top',
51
+					'tipAdjustmentY' => -30,
52
+					'tipAdjustmentX' => 20
53
+				)
54
+			);
55
+			$this->_stops[40] = array(
56
+				'id'      => 'show_group_name',
57
+				'content' => $this->_show_group_name_stop(),
58
+				'options' => array(
59
+					'tipLocation'    => 'top',
60
+					'tipAdjustmentY' => -30,
61
+					'tipAdjustmentX' => 20
62
+				)
63
+			);
64
+			$this->_stops[50] = array(
65
+				'id'      => 'show_group_desc',
66
+				'content' => $this->_show_group_description_stop(),
67
+				'options' => array(
68
+					'tipLocation'    => 'top',
69
+					'tipAdjustmentY' => -30,
70
+					'tipAdjustmentX' => 20
71
+				)
72
+			);
73
+			$this->_stops[60] = array(
74
+				'class'   => 'bulkactions',
75
+				'content' => $this->_bulk_actions_stop(),
76
+				'options' => array(
77
+					'tipLocation'    => 'left',
78
+					'tipAdjustmentY' => -50,
79
+					'tipAdjustmentX' => -80
80
+				)
81
+			);
82
+			$this->_stops[70] = array(
83
+				'id'      => 'add-new-question-group',
84
+				'content' => $this->_add_new_question_group_stop(),
85
+				'options' => array(
86
+					'tipLocation'    => 'right',
87
+					'tipAdjustmentY' => -50,
88
+					'tipAdjustmentX' => 15
89
+				)
90
+			);
91
+		}
92
+	}
93 93
     
94 94
     
95
-    protected function _start()
96
-    {
97
-        $content = '<h3>' . __('Question Groups', 'event_espresso') . '</h3>';
98
-        if ($this->_is_caf) {
99
-            $content .= '<p>' . __('This tour of the Question Groups page will go over different areas of the screen to help you understand what they are used for.',
100
-                    'event_espresso') . '</p>';
101
-        } else {
102
-            $content .= '<p>' . __('Sorry, Event Espresso Decaf does not have this feature. Please purchase a support license to get access to this feature.',
103
-                    'event_espresso') . '</p>';
104
-        }
95
+	protected function _start()
96
+	{
97
+		$content = '<h3>' . __('Question Groups', 'event_espresso') . '</h3>';
98
+		if ($this->_is_caf) {
99
+			$content .= '<p>' . __('This tour of the Question Groups page will go over different areas of the screen to help you understand what they are used for.',
100
+					'event_espresso') . '</p>';
101
+		} else {
102
+			$content .= '<p>' . __('Sorry, Event Espresso Decaf does not have this feature. Please purchase a support license to get access to this feature.',
103
+					'event_espresso') . '</p>';
104
+		}
105 105
         
106
-        return $content;
107
-    }
106
+		return $content;
107
+	}
108 108
     
109
-    protected function _name_stop()
110
-    {
111
-        return '<p>' . __('View available questions groups. You can reorder your questions by dragging and dropping them.',
112
-            'event_espresso') . '</p>';
113
-    }
109
+	protected function _name_stop()
110
+	{
111
+		return '<p>' . __('View available questions groups. You can reorder your questions by dragging and dropping them.',
112
+			'event_espresso') . '</p>';
113
+	}
114 114
     
115
-    protected function _description_stop()
116
-    {
117
-        return '<p>' . __('View the question group description.', 'event_espresso') . '</p>';
118
-    }
115
+	protected function _description_stop()
116
+	{
117
+		return '<p>' . __('View the question group description.', 'event_espresso') . '</p>';
118
+	}
119 119
     
120
-    protected function _show_group_name_stop()
121
-    {
122
-        return '<p>' . __('View if the name of the question group should be shown to customers.',
123
-            'event_espresso') . '</p>';
124
-    }
120
+	protected function _show_group_name_stop()
121
+	{
122
+		return '<p>' . __('View if the name of the question group should be shown to customers.',
123
+			'event_espresso') . '</p>';
124
+	}
125 125
     
126
-    protected function _show_group_description_stop()
127
-    {
128
-        return '<p>' . __('View if the description of the question group should be shown to customers.',
129
-            'event_espresso') . '</p>';
130
-    }
126
+	protected function _show_group_description_stop()
127
+	{
128
+		return '<p>' . __('View if the description of the question group should be shown to customers.',
129
+			'event_espresso') . '</p>';
130
+	}
131 131
     
132
-    protected function _bulk_actions_stop()
133
-    {
134
-        return '<p>' . __('Perform bulk actions to multiple question groups.', 'event_espresso') . '</p>';
135
-    }
132
+	protected function _bulk_actions_stop()
133
+	{
134
+		return '<p>' . __('Perform bulk actions to multiple question groups.', 'event_espresso') . '</p>';
135
+	}
136 136
     
137
-    protected function _search_stop()
138
-    {
139
-        return '<p>' . __('Search through questions. The following sources will be searched: question group name and question group description.',
140
-            'event_espresso') . '</p>';
141
-    }
137
+	protected function _search_stop()
138
+	{
139
+		return '<p>' . __('Search through questions. The following sources will be searched: question group name and question group description.',
140
+			'event_espresso') . '</p>';
141
+	}
142 142
     
143
-    protected function _add_new_question_group_stop()
144
-    {
145
-        return '<p>' . __('Click here to create a new question group.', 'event_espresso') . '</p>';
146
-    }
143
+	protected function _add_new_question_group_stop()
144
+	{
145
+		return '<p>' . __('Click here to create a new question group.', 'event_espresso') . '</p>';
146
+	}
147 147
 }
148 148
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -94,13 +94,13 @@  discard block
 block discarded – undo
94 94
     
95 95
     protected function _start()
96 96
     {
97
-        $content = '<h3>' . __('Question Groups', 'event_espresso') . '</h3>';
97
+        $content = '<h3>'.__('Question Groups', 'event_espresso').'</h3>';
98 98
         if ($this->_is_caf) {
99
-            $content .= '<p>' . __('This tour of the Question Groups page will go over different areas of the screen to help you understand what they are used for.',
100
-                    'event_espresso') . '</p>';
99
+            $content .= '<p>'.__('This tour of the Question Groups page will go over different areas of the screen to help you understand what they are used for.',
100
+                    'event_espresso').'</p>';
101 101
         } else {
102
-            $content .= '<p>' . __('Sorry, Event Espresso Decaf does not have this feature. Please purchase a support license to get access to this feature.',
103
-                    'event_espresso') . '</p>';
102
+            $content .= '<p>'.__('Sorry, Event Espresso Decaf does not have this feature. Please purchase a support license to get access to this feature.',
103
+                    'event_espresso').'</p>';
104 104
         }
105 105
         
106 106
         return $content;
@@ -108,40 +108,40 @@  discard block
 block discarded – undo
108 108
     
109 109
     protected function _name_stop()
110 110
     {
111
-        return '<p>' . __('View available questions groups. You can reorder your questions by dragging and dropping them.',
112
-            'event_espresso') . '</p>';
111
+        return '<p>'.__('View available questions groups. You can reorder your questions by dragging and dropping them.',
112
+            'event_espresso').'</p>';
113 113
     }
114 114
     
115 115
     protected function _description_stop()
116 116
     {
117
-        return '<p>' . __('View the question group description.', 'event_espresso') . '</p>';
117
+        return '<p>'.__('View the question group description.', 'event_espresso').'</p>';
118 118
     }
119 119
     
120 120
     protected function _show_group_name_stop()
121 121
     {
122
-        return '<p>' . __('View if the name of the question group should be shown to customers.',
123
-            'event_espresso') . '</p>';
122
+        return '<p>'.__('View if the name of the question group should be shown to customers.',
123
+            'event_espresso').'</p>';
124 124
     }
125 125
     
126 126
     protected function _show_group_description_stop()
127 127
     {
128
-        return '<p>' . __('View if the description of the question group should be shown to customers.',
129
-            'event_espresso') . '</p>';
128
+        return '<p>'.__('View if the description of the question group should be shown to customers.',
129
+            'event_espresso').'</p>';
130 130
     }
131 131
     
132 132
     protected function _bulk_actions_stop()
133 133
     {
134
-        return '<p>' . __('Perform bulk actions to multiple question groups.', 'event_espresso') . '</p>';
134
+        return '<p>'.__('Perform bulk actions to multiple question groups.', 'event_espresso').'</p>';
135 135
     }
136 136
     
137 137
     protected function _search_stop()
138 138
     {
139
-        return '<p>' . __('Search through questions. The following sources will be searched: question group name and question group description.',
140
-            'event_espresso') . '</p>';
139
+        return '<p>'.__('Search through questions. The following sources will be searched: question group name and question group description.',
140
+            'event_espresso').'</p>';
141 141
     }
142 142
     
143 143
     protected function _add_new_question_group_stop()
144 144
     {
145
-        return '<p>' . __('Click here to create a new question group.', 'event_espresso') . '</p>';
145
+        return '<p>'.__('Click here to create a new question group.', 'event_espresso').'</p>';
146 146
     }
147 147
 }
148 148
\ No newline at end of file
Please login to merge, or discard this patch.
general_settings/help_tours/Your_Organization_Help_Tour.class.php 2 patches
Indentation   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('NO direct script access allowed');
3
+	exit('NO direct script access allowed');
4 4
 }
5 5
 
6 6
 /**
@@ -18,121 +18,121 @@  discard block
 block discarded – undo
18 18
 class Your_Organization_Help_Tour extends EE_Help_Tour
19 19
 {
20 20
     
21
-    protected function _set_tour_properties()
22
-    {
23
-        $this->_label = __('Your Organization Tour', 'event_espresso');
24
-        $this->_slug  = 'your-organization-joyride';
25
-    }
21
+	protected function _set_tour_properties()
22
+	{
23
+		$this->_label = __('Your Organization Tour', 'event_espresso');
24
+		$this->_slug  = 'your-organization-joyride';
25
+	}
26 26
     
27 27
     
28
-    protected function _set_tour_stops()
29
-    {
30
-        $this->_stops = array(
31
-            10 => array(
32
-                'content' => $this->_start(),
33
-            ),
34
-            30 => array(
35
-                'id'      => 'contact_info_h4',
36
-                'content' => $this->_contact_information_stop(),
37
-                'options' => array(
38
-                    'tipLocation'    => 'left',
39
-                    'tipAdjustmentY' => -50,
40
-                    'tipAdjustmentX' => 15
41
-                )
42
-            ),
43
-            40 => array(
44
-                'id'      => 'upload_image',
45
-                'content' => $this->_upload_image_stop(),
46
-                'options' => array(
47
-                    'tipLocation'    => 'right',
48
-                    'tipAdjustmentY' => -50,
49
-                    'tipAdjustmentX' => 15
50
-                )
51
-            ),
52
-            50 => array(
53
-                'id'      => 'organization_facebook',
54
-                'content' => $this->_organization_facebook_stop(),
55
-                'options' => array(
56
-                    'tipLocation'    => 'right',
57
-                    'tipAdjustmentY' => -50,
58
-                    'tipAdjustmentX' => 15
59
-                )
60
-            ),
61
-            60 => array(
62
-                'id'      => 'ueip_optin',
63
-                'content' => $this->_ueip_option_stop(),
64
-                'options' => array(
65
-                    'tipLocation'    => 'right',
66
-                    'tipAdjustmentY' => -50,
67
-                    'tipAdjustmentX' => 15
68
-                )
69
-            ),
70
-            70 => array(
71
-                'id'      => 'espresso_major_buttons_wrapper',
72
-                'content' => $this->_end_tour_stop(),
73
-                'options' => array(
74
-                    'tipLocation'    => 'right',
75
-                    'tipAdjustmentY' => -50,
76
-                    'tipAdjustmentX' => 185
77
-                )
78
-            )
79
-        );
28
+	protected function _set_tour_stops()
29
+	{
30
+		$this->_stops = array(
31
+			10 => array(
32
+				'content' => $this->_start(),
33
+			),
34
+			30 => array(
35
+				'id'      => 'contact_info_h4',
36
+				'content' => $this->_contact_information_stop(),
37
+				'options' => array(
38
+					'tipLocation'    => 'left',
39
+					'tipAdjustmentY' => -50,
40
+					'tipAdjustmentX' => 15
41
+				)
42
+			),
43
+			40 => array(
44
+				'id'      => 'upload_image',
45
+				'content' => $this->_upload_image_stop(),
46
+				'options' => array(
47
+					'tipLocation'    => 'right',
48
+					'tipAdjustmentY' => -50,
49
+					'tipAdjustmentX' => 15
50
+				)
51
+			),
52
+			50 => array(
53
+				'id'      => 'organization_facebook',
54
+				'content' => $this->_organization_facebook_stop(),
55
+				'options' => array(
56
+					'tipLocation'    => 'right',
57
+					'tipAdjustmentY' => -50,
58
+					'tipAdjustmentX' => 15
59
+				)
60
+			),
61
+			60 => array(
62
+				'id'      => 'ueip_optin',
63
+				'content' => $this->_ueip_option_stop(),
64
+				'options' => array(
65
+					'tipLocation'    => 'right',
66
+					'tipAdjustmentY' => -50,
67
+					'tipAdjustmentX' => 15
68
+				)
69
+			),
70
+			70 => array(
71
+				'id'      => 'espresso_major_buttons_wrapper',
72
+				'content' => $this->_end_tour_stop(),
73
+				'options' => array(
74
+					'tipLocation'    => 'right',
75
+					'tipAdjustmentY' => -50,
76
+					'tipAdjustmentX' => 185
77
+				)
78
+			)
79
+		);
80 80
         
81
-        if (is_main_site()) {
82
-            $this->_stops[20] = array(
83
-                'id' => 'site_license_key',
84
-                'content' => $this->_site_license_key_stop(),
85
-                'options' => array(
86
-                    'tipLocation' => 'right',
87
-                    'tipAdjustmentY' => -50,
88
-                    'tipAdjustmentX' => 15
89
-                )
90
-            );
91
-        }
92
-        ksort( $this->_stops );
93
-    }
81
+		if (is_main_site()) {
82
+			$this->_stops[20] = array(
83
+				'id' => 'site_license_key',
84
+				'content' => $this->_site_license_key_stop(),
85
+				'options' => array(
86
+					'tipLocation' => 'right',
87
+					'tipAdjustmentY' => -50,
88
+					'tipAdjustmentX' => 15
89
+				)
90
+			);
91
+		}
92
+		ksort( $this->_stops );
93
+	}
94 94
     
95 95
     
96
-    protected function _start()
97
-    {
98
-        $content = '<h3>' . __('Organization Settings', 'event_espresso') . '</h3>';
99
-        $content .= '<p>' . __('This tour of the Your Organization page will go over different areas of the screen to help you understand what they are used for.',
100
-                'event_espresso') . '</p>';
96
+	protected function _start()
97
+	{
98
+		$content = '<h3>' . __('Organization Settings', 'event_espresso') . '</h3>';
99
+		$content .= '<p>' . __('This tour of the Your Organization page will go over different areas of the screen to help you understand what they are used for.',
100
+				'event_espresso') . '</p>';
101 101
         
102
-        return $content;
103
-    }
102
+		return $content;
103
+	}
104 104
     
105
-    protected function _site_license_key_stop()
106
-    {
107
-        return '<p>' . __('Enter your support license key here to enable one-click updates.',
108
-            'event_espresso') . '</p>';
109
-    }
105
+	protected function _site_license_key_stop()
106
+	{
107
+		return '<p>' . __('Enter your support license key here to enable one-click updates.',
108
+			'event_espresso') . '</p>';
109
+	}
110 110
     
111
-    protected function _contact_information_stop()
112
-    {
113
-        return '<p>' . __('You can change your business / organization information below. Be sure to keep this information updated as it is used in other areas of the site. Adjusting the country option here will update your currency settings. More options are available in the Countries tab.',
114
-            'event_espresso') . '</p>';
115
-    }
111
+	protected function _contact_information_stop()
112
+	{
113
+		return '<p>' . __('You can change your business / organization information below. Be sure to keep this information updated as it is used in other areas of the site. Adjusting the country option here will update your currency settings. More options are available in the Countries tab.',
114
+			'event_espresso') . '</p>';
115
+	}
116 116
     
117
-    protected function _upload_image_stop()
118
-    {
119
-        return '<p>' . __('Add a logo. This can be used for invoices and tickets.', 'event_espresso') . '</p>';
120
-    }
117
+	protected function _upload_image_stop()
118
+	{
119
+		return '<p>' . __('Add a logo. This can be used for invoices and tickets.', 'event_espresso') . '</p>';
120
+	}
121 121
     
122
-    protected function _organization_facebook_stop()
123
-    {
124
-        return '<p>' . __('Add links to various social media networks.', 'event_espresso') . '</p>';
125
-    }
122
+	protected function _organization_facebook_stop()
123
+	{
124
+		return '<p>' . __('Add links to various social media networks.', 'event_espresso') . '</p>';
125
+	}
126 126
     
127
-    protected function _ueip_option_stop()
128
-    {
129
-        return '<p>' . __('Help us to help you! Sign up to the User eXperience Improvement Program and send us anonymous data that will help us improve Event Espresso.',
130
-            'event_espresso') . '</p>';
131
-    }
127
+	protected function _ueip_option_stop()
128
+	{
129
+		return '<p>' . __('Help us to help you! Sign up to the User eXperience Improvement Program and send us anonymous data that will help us improve Event Espresso.',
130
+			'event_espresso') . '</p>';
131
+	}
132 132
     
133
-    protected function _end_tour_stop()
134
-    {
135
-        return '<p>' . __('You are almost done updating Your Organization information. Click on the Save button to save changes and then go to the Payment Methods screen so you can setup a payment gateway.',
136
-            'event_espresso') . '</p>';
137
-    }
133
+	protected function _end_tour_stop()
134
+	{
135
+		return '<p>' . __('You are almost done updating Your Organization information. Click on the Save button to save changes and then go to the Payment Methods screen so you can setup a payment gateway.',
136
+			'event_espresso') . '</p>';
137
+	}
138 138
 }
139 139
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -89,50 +89,50 @@
 block discarded – undo
89 89
                 )
90 90
             );
91 91
         }
92
-        ksort( $this->_stops );
92
+        ksort($this->_stops);
93 93
     }
94 94
     
95 95
     
96 96
     protected function _start()
97 97
     {
98
-        $content = '<h3>' . __('Organization Settings', 'event_espresso') . '</h3>';
99
-        $content .= '<p>' . __('This tour of the Your Organization page will go over different areas of the screen to help you understand what they are used for.',
100
-                'event_espresso') . '</p>';
98
+        $content = '<h3>'.__('Organization Settings', 'event_espresso').'</h3>';
99
+        $content .= '<p>'.__('This tour of the Your Organization page will go over different areas of the screen to help you understand what they are used for.',
100
+                'event_espresso').'</p>';
101 101
         
102 102
         return $content;
103 103
     }
104 104
     
105 105
     protected function _site_license_key_stop()
106 106
     {
107
-        return '<p>' . __('Enter your support license key here to enable one-click updates.',
108
-            'event_espresso') . '</p>';
107
+        return '<p>'.__('Enter your support license key here to enable one-click updates.',
108
+            'event_espresso').'</p>';
109 109
     }
110 110
     
111 111
     protected function _contact_information_stop()
112 112
     {
113
-        return '<p>' . __('You can change your business / organization information below. Be sure to keep this information updated as it is used in other areas of the site. Adjusting the country option here will update your currency settings. More options are available in the Countries tab.',
114
-            'event_espresso') . '</p>';
113
+        return '<p>'.__('You can change your business / organization information below. Be sure to keep this information updated as it is used in other areas of the site. Adjusting the country option here will update your currency settings. More options are available in the Countries tab.',
114
+            'event_espresso').'</p>';
115 115
     }
116 116
     
117 117
     protected function _upload_image_stop()
118 118
     {
119
-        return '<p>' . __('Add a logo. This can be used for invoices and tickets.', 'event_espresso') . '</p>';
119
+        return '<p>'.__('Add a logo. This can be used for invoices and tickets.', 'event_espresso').'</p>';
120 120
     }
121 121
     
122 122
     protected function _organization_facebook_stop()
123 123
     {
124
-        return '<p>' . __('Add links to various social media networks.', 'event_espresso') . '</p>';
124
+        return '<p>'.__('Add links to various social media networks.', 'event_espresso').'</p>';
125 125
     }
126 126
     
127 127
     protected function _ueip_option_stop()
128 128
     {
129
-        return '<p>' . __('Help us to help you! Sign up to the User eXperience Improvement Program and send us anonymous data that will help us improve Event Espresso.',
130
-            'event_espresso') . '</p>';
129
+        return '<p>'.__('Help us to help you! Sign up to the User eXperience Improvement Program and send us anonymous data that will help us improve Event Espresso.',
130
+            'event_espresso').'</p>';
131 131
     }
132 132
     
133 133
     protected function _end_tour_stop()
134 134
     {
135
-        return '<p>' . __('You are almost done updating Your Organization information. Click on the Save button to save changes and then go to the Payment Methods screen so you can setup a payment gateway.',
136
-            'event_espresso') . '</p>';
135
+        return '<p>'.__('You are almost done updating Your Organization information. Click on the Save button to save changes and then go to the Payment Methods screen so you can setup a payment gateway.',
136
+            'event_espresso').'</p>';
137 137
     }
138 138
 }
139 139
\ No newline at end of file
Please login to merge, or discard this patch.
core/EE_Cron_Tasks.core.php 2 patches
Indentation   +358 added lines, -358 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 /**
@@ -12,363 +12,363 @@  discard block
 block discarded – undo
12 12
 class EE_Cron_Tasks extends EE_Base
13 13
 {
14 14
 
15
-    /**
16
-     * WordPress doesn't allow duplicate crons within 10 minutes of the original,
17
-     * so we'll set our retry time for just over 10 minutes to avoid that
18
-     */
19
-    const reschedule_timeout = 605;
20
-
21
-
22
-    /**
23
-     * @var EE_Cron_Tasks
24
-     */
25
-    private static $_instance;
26
-
27
-
28
-    /**
29
-     * @return EE_Cron_Tasks
30
-     */
31
-    public static function instance()
32
-    {
33
-        if ( ! self::$_instance instanceof EE_Cron_Tasks) {
34
-            self::$_instance = new self();
35
-        }
36
-        return self::$_instance;
37
-    }
38
-
39
-
40
-    /**
41
-     * @access private
42
-     * @return EE_Cron_Tasks
43
-     */
44
-    private function __construct()
45
-    {
46
-        do_action('AHEE_log', __CLASS__, __FUNCTION__);
47
-        // verify that WP Cron is enabled
48
-        if (
49
-            defined('DISABLE_WP_CRON')
50
-            && DISABLE_WP_CRON
51
-            && is_admin()
52
-            && ! get_option('ee_disabled_wp_cron_check')
53
-        ) {
54
-            /**
55
-             * This needs to be delayed until after the config is loaded because EE_Cron_Tasks is constructed before
56
-             * config is loaded.
57
-             * This is intentionally using a anonymous function so that its not easily de-registered.  Client code
58
-             * wanting to not have this functionality can just register its own action at a priority after this one to
59
-             * reverse any changes.
60
-             */
61
-            add_action('AHEE__EE_System__load_core_configuration__complete', function () {
62
-                EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request = true;
63
-                EE_Registry::instance()->NET_CFG->update_config(true, false);
64
-                add_option('ee_disabled_wp_cron_check', 1, '', false);
65
-            });
66
-        }
67
-        // UPDATE TRANSACTION WITH PAYMENT
68
-        add_action(
69
-            'AHEE__EE_Cron_Tasks__update_transaction_with_payment_2',
70
-            array('EE_Cron_Tasks', 'setup_update_for_transaction_with_payment'),
71
-            10, 2
72
-        );
73
-        // FINALIZE ABANDONED TRANSACTIONS
74
-        add_action(
75
-            'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions',
76
-            array('EE_Cron_Tasks', 'check_for_abandoned_transactions'),
77
-            10, 1
78
-        );
79
-        // CLEAN OUT JUNK TRANSACTIONS AND RELATED DATA
80
-        add_action(
81
-            'AHEE__EE_Cron_Tasks__clean_up_junk_transactions',
82
-            array('EE_Cron_Tasks', 'clean_out_junk_transactions')
83
-        );
84
-        // logging
85
-        add_action(
86
-            'AHEE__EE_System__load_core_configuration__complete',
87
-            array('EE_Cron_Tasks', 'log_scheduled_ee_crons')
88
-        );
89
-        EE_Registry::instance()->load_lib('Messages_Scheduler');
90
-    }
91
-
92
-
93
-    /**
94
-     * @access protected
95
-     * @return void
96
-     */
97
-    public static function log_scheduled_ee_crons()
98
-    {
99
-        $ee_crons = array(
100
-            'AHEE__EE_Cron_Tasks__update_transaction_with_payment',
101
-            'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions',
102
-            'AHEE__EE_Cron_Tasks__clean_up_junk_transactions',
103
-        );
104
-        $crons    = get_option('cron');
105
-        if ( ! is_array($crons)) {
106
-            return;
107
-        }
108
-        foreach ($crons as $timestamp => $cron) {
109
-            foreach ($ee_crons as $ee_cron) {
110
-                if (isset($cron[$ee_cron])) {
111
-                    do_action('AHEE_log', __CLASS__, __FUNCTION__, $ee_cron, 'scheduled EE cron');
112
-                    foreach ($cron[$ee_cron] as $ee_cron_details) {
113
-                        if ( ! empty($ee_cron_details['args'])) {
114
-                            do_action('AHEE_log', __CLASS__, __FUNCTION__, print_r($ee_cron_details['args'], true),
115
-                                "$ee_cron args");
116
-                        }
117
-                    }
118
-                }
119
-            }
120
-        }
121
-    }
122
-
123
-
124
-
125
-
126
-    /****************  UPDATE TRANSACTION WITH PAYMENT ****************/
127
-
128
-
129
-    /**
130
-     * array of TXN IDs and the payment
131
-     *
132
-     * @var array
133
-     */
134
-    protected static $_update_transactions_with_payment = array();
135
-
136
-
137
-    /**
138
-     * schedule_update_transaction_with_payment
139
-     * sets a wp_schedule_single_event() for updating any TXNs that may
140
-     * require updating due to recently received payments
141
-     *
142
-     * @param int $timestamp
143
-     * @param int $TXN_ID
144
-     * @param int $PAY_ID
145
-     */
146
-    public static function schedule_update_transaction_with_payment(
147
-        $timestamp,
148
-        $TXN_ID,
149
-        $PAY_ID
150
-    ) {
151
-        do_action('AHEE_log', __CLASS__, __FUNCTION__);
152
-        // validate $TXN_ID and $timestamp
153
-        $TXN_ID    = absint($TXN_ID);
154
-        $timestamp = absint($timestamp);
155
-        if ($TXN_ID && $timestamp) {
156
-            wp_schedule_single_event(
157
-                $timestamp,
158
-                'AHEE__EE_Cron_Tasks__update_transaction_with_payment_2',
159
-                array($TXN_ID, $PAY_ID)
160
-            );
161
-        }
162
-    }
163
-
164
-
165
-    /**
166
-     * setup_update_for_transaction_with_payment
167
-     * this is the callback for the action hook:
168
-     * 'AHEE__EE_Cron_Tasks__update_transaction_with_payment'
169
-     * which is setup by EE_Cron_Tasks::schedule_update_transaction_with_payment().
170
-     * The passed TXN_ID and associated payment gets added to an array, and then
171
-     * the EE_Cron_Tasks::update_transaction_with_payment() function is hooked into
172
-     * 'shutdown' which will actually handle the processing of any
173
-     * transactions requiring updating, because doing so now would be too early
174
-     * and the required resources may not be available
175
-     *
176
-     * @param int $TXN_ID
177
-     * @param int $PAY_ID
178
-     */
179
-    public static function setup_update_for_transaction_with_payment($TXN_ID = 0, $PAY_ID = 0)
180
-    {
181
-        do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID');
182
-        if (absint($TXN_ID)) {
183
-            self::$_update_transactions_with_payment[$TXN_ID] = $PAY_ID;
184
-            add_action(
185
-                'shutdown',
186
-                array('EE_Cron_Tasks', 'update_transaction_with_payment'),
187
-                5
188
-            );
189
-        }
190
-    }
191
-
192
-
193
-    /**
194
-     * update_transaction_with_payment
195
-     * loops through the self::$_abandoned_transactions array
196
-     * and attempts to finalize any TXNs that have not been completed
197
-     * but have had their sessions expired, most likely due to a user not
198
-     * returning from an off-site payment gateway
199
-     *
200
-     * @throws \EE_Error
201
-     */
202
-    public static function update_transaction_with_payment()
203
-    {
204
-        do_action('AHEE_log', __CLASS__, __FUNCTION__);
205
-        // are there any TXNs that need cleaning up ?
206
-        if ( ! empty(self::$_update_transactions_with_payment)) {
207
-            /** @type EE_Payment_Processor $payment_processor */
208
-            $payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
209
-            // set revisit flag for payment processor
210
-            $payment_processor->set_revisit(false);
211
-            // load EEM_Transaction
212
-            EE_Registry::instance()->load_model('Transaction');
213
-            foreach (self::$_update_transactions_with_payment as $TXN_ID => $PAY_ID) {
214
-                // reschedule the cron if we can't hit the db right now
215
-                if ( ! EE_Maintenance_Mode::instance()->models_can_query()) {
216
-                    // reset cron job for updating the TXN
217
-                    EE_Cron_Tasks::schedule_update_transaction_with_payment(
218
-                        time() + EE_Cron_Tasks::reschedule_timeout,
219
-                        $TXN_ID,
220
-                        $PAY_ID
221
-                    );
222
-                    continue;
223
-                }
224
-                $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
225
-                $payment     = EEM_Payment::instance()->get_one_by_ID($PAY_ID);
226
-                // verify transaction
227
-                if ($transaction instanceof EE_Transaction && $payment instanceof EE_Payment) {
228
-                    // now try to update the TXN with any payments
229
-                    $payment_processor->update_txn_based_on_payment($transaction, $payment, true, true);
230
-                }
231
-                unset(self::$_update_transactions_with_payment[$TXN_ID]);
232
-            }
233
-        }
234
-    }
235
-
236
-
237
-
238
-    /************  END OF UPDATE TRANSACTION WITH PAYMENT  ************/
239
-
240
-
241
-    /*****************  FINALIZE ABANDONED TRANSACTIONS *****************/
242
-
243
-
244
-    /**
245
-     * array of TXN IDs
246
-     *
247
-     * @var array
248
-     */
249
-    protected static $_abandoned_transactions = array();
250
-
251
-
252
-    /**
253
-     * schedule_finalize_abandoned_transactions_check
254
-     * sets a wp_schedule_single_event() for finalizing any TXNs that may
255
-     * have been abandoned during the registration process
256
-     *
257
-     * @param int $timestamp
258
-     * @param int $TXN_ID
259
-     */
260
-    public static function schedule_finalize_abandoned_transactions_check(
261
-        $timestamp,
262
-        $TXN_ID
263
-    ) {
264
-        // validate $TXN_ID and $timestamp
265
-        $TXN_ID    = absint($TXN_ID);
266
-        $timestamp = absint($timestamp);
267
-        do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID');
268
-        if ($TXN_ID && $timestamp) {
269
-            wp_schedule_single_event(
270
-                $timestamp,
271
-                'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions',
272
-                array($TXN_ID)
273
-            );
274
-        }
275
-    }
276
-
277
-
278
-    /**
279
-     * check_for_abandoned_transactions
280
-     * this is the callback for the action hook:
281
-     * 'AHEE__EE_Cron_Tasks__espresso_finalize_abandoned_transactions'
282
-     * which is utilized by wp_schedule_single_event()
283
-     * in EE_SPCO_Reg_Step_Payment_Options::_post_payment_processing().
284
-     * The passed TXN_ID gets added to an array, and then the
285
-     * espresso_finalize_abandoned_transactions() function is hooked into
286
-     * 'AHEE__EE_System__core_loaded_and_ready' which will actually handle the
287
-     * processing of any abandoned transactions, because doing so now would be
288
-     * too early and the required resources may not be available
289
-     *
290
-     * @param int $TXN_ID
291
-     */
292
-    public static function check_for_abandoned_transactions($TXN_ID = 0)
293
-    {
294
-        do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID');
295
-        if (absint($TXN_ID)) {
296
-            self::$_abandoned_transactions[] = $TXN_ID;
297
-            add_action(
298
-                'shutdown',
299
-                array('EE_Cron_Tasks', 'finalize_abandoned_transactions'),
300
-                5
301
-            );
302
-        }
303
-    }
304
-
305
-
306
-    /**
307
-     * finalize_abandoned_transactions
308
-     * loops through the self::$_abandoned_transactions array
309
-     * and attempts to finalize any TXNs that have not been completed
310
-     * but have had their sessions expired, most likely due to a user not
311
-     * returning from an off-site payment gateway
312
-     *
313
-     * @throws \EE_Error
314
-     */
315
-    public static function finalize_abandoned_transactions()
316
-    {
317
-        do_action('AHEE_log', __CLASS__, __FUNCTION__);
318
-        // are there any TXNs that need cleaning up ?
319
-        if ( ! empty(self::$_abandoned_transactions)) {
320
-            /** @type EE_Transaction_Processor $transaction_processor */
321
-            $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
322
-            // set revisit flag for txn processor
323
-            $transaction_processor->set_revisit(false);
324
-            /** @type EE_Payment_Processor $payment_processor */
325
-            $payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
326
-            // load EEM_Transaction
327
-            EE_Registry::instance()->load_model('Transaction');
328
-            foreach (self::$_abandoned_transactions as $TXN_ID) {
329
-                do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID');
330
-                // reschedule the cron if we can't hit the db right now
331
-                if ( ! EE_Maintenance_Mode::instance()->models_can_query()) {
332
-                    // reset cron job for finalizing the TXN
333
-                    EE_Cron_Tasks::schedule_finalize_abandoned_transactions_check(
334
-                        time() + EE_Cron_Tasks::reschedule_timeout,
335
-                        $TXN_ID
336
-                    );
337
-                    continue;
338
-                }
339
-                $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
340
-                // verify transaction
341
-                if ($transaction instanceof EE_Transaction) {
342
-                    // don't finalize the TXN if it has already been completed
343
-                    if ($transaction->all_reg_steps_completed() === true) {
344
-                        continue;
345
-                    }
346
-                    // let's simulate an IPN here which will trigger any notifications that need to go out
347
-                    $payment_processor->update_txn_based_on_payment($transaction, $transaction->last_payment(), true,
348
-                        true);
349
-                }
350
-                unset(self::$_abandoned_transactions[$TXN_ID]);
351
-            }
352
-        }
353
-    }
354
-
355
-
356
-
357
-    /*************  END OF FINALIZE ABANDONED TRANSACTIONS  *************/
358
-
359
-
360
-    /************* START CLEAN UP BOT TRANSACTIONS **********************/
361
-
362
-    //when a transaction is initially made, schedule this check.
363
-    //if it has NO REG data by the time it has expired, forget about it
364
-    public static function clean_out_junk_transactions()
365
-    {
366
-        if (EE_Maintenance_Mode::instance()->models_can_query()) {
367
-            EEM_Transaction::instance('')->delete_junk_transactions();
368
-            EEM_Registration::instance('')->delete_registrations_with_no_transaction();
369
-            EEM_Line_Item::instance('')->delete_line_items_with_no_transaction();
370
-        }
371
-    }
15
+	/**
16
+	 * WordPress doesn't allow duplicate crons within 10 minutes of the original,
17
+	 * so we'll set our retry time for just over 10 minutes to avoid that
18
+	 */
19
+	const reschedule_timeout = 605;
20
+
21
+
22
+	/**
23
+	 * @var EE_Cron_Tasks
24
+	 */
25
+	private static $_instance;
26
+
27
+
28
+	/**
29
+	 * @return EE_Cron_Tasks
30
+	 */
31
+	public static function instance()
32
+	{
33
+		if ( ! self::$_instance instanceof EE_Cron_Tasks) {
34
+			self::$_instance = new self();
35
+		}
36
+		return self::$_instance;
37
+	}
38
+
39
+
40
+	/**
41
+	 * @access private
42
+	 * @return EE_Cron_Tasks
43
+	 */
44
+	private function __construct()
45
+	{
46
+		do_action('AHEE_log', __CLASS__, __FUNCTION__);
47
+		// verify that WP Cron is enabled
48
+		if (
49
+			defined('DISABLE_WP_CRON')
50
+			&& DISABLE_WP_CRON
51
+			&& is_admin()
52
+			&& ! get_option('ee_disabled_wp_cron_check')
53
+		) {
54
+			/**
55
+			 * This needs to be delayed until after the config is loaded because EE_Cron_Tasks is constructed before
56
+			 * config is loaded.
57
+			 * This is intentionally using a anonymous function so that its not easily de-registered.  Client code
58
+			 * wanting to not have this functionality can just register its own action at a priority after this one to
59
+			 * reverse any changes.
60
+			 */
61
+			add_action('AHEE__EE_System__load_core_configuration__complete', function () {
62
+				EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request = true;
63
+				EE_Registry::instance()->NET_CFG->update_config(true, false);
64
+				add_option('ee_disabled_wp_cron_check', 1, '', false);
65
+			});
66
+		}
67
+		// UPDATE TRANSACTION WITH PAYMENT
68
+		add_action(
69
+			'AHEE__EE_Cron_Tasks__update_transaction_with_payment_2',
70
+			array('EE_Cron_Tasks', 'setup_update_for_transaction_with_payment'),
71
+			10, 2
72
+		);
73
+		// FINALIZE ABANDONED TRANSACTIONS
74
+		add_action(
75
+			'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions',
76
+			array('EE_Cron_Tasks', 'check_for_abandoned_transactions'),
77
+			10, 1
78
+		);
79
+		// CLEAN OUT JUNK TRANSACTIONS AND RELATED DATA
80
+		add_action(
81
+			'AHEE__EE_Cron_Tasks__clean_up_junk_transactions',
82
+			array('EE_Cron_Tasks', 'clean_out_junk_transactions')
83
+		);
84
+		// logging
85
+		add_action(
86
+			'AHEE__EE_System__load_core_configuration__complete',
87
+			array('EE_Cron_Tasks', 'log_scheduled_ee_crons')
88
+		);
89
+		EE_Registry::instance()->load_lib('Messages_Scheduler');
90
+	}
91
+
92
+
93
+	/**
94
+	 * @access protected
95
+	 * @return void
96
+	 */
97
+	public static function log_scheduled_ee_crons()
98
+	{
99
+		$ee_crons = array(
100
+			'AHEE__EE_Cron_Tasks__update_transaction_with_payment',
101
+			'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions',
102
+			'AHEE__EE_Cron_Tasks__clean_up_junk_transactions',
103
+		);
104
+		$crons    = get_option('cron');
105
+		if ( ! is_array($crons)) {
106
+			return;
107
+		}
108
+		foreach ($crons as $timestamp => $cron) {
109
+			foreach ($ee_crons as $ee_cron) {
110
+				if (isset($cron[$ee_cron])) {
111
+					do_action('AHEE_log', __CLASS__, __FUNCTION__, $ee_cron, 'scheduled EE cron');
112
+					foreach ($cron[$ee_cron] as $ee_cron_details) {
113
+						if ( ! empty($ee_cron_details['args'])) {
114
+							do_action('AHEE_log', __CLASS__, __FUNCTION__, print_r($ee_cron_details['args'], true),
115
+								"$ee_cron args");
116
+						}
117
+					}
118
+				}
119
+			}
120
+		}
121
+	}
122
+
123
+
124
+
125
+
126
+	/****************  UPDATE TRANSACTION WITH PAYMENT ****************/
127
+
128
+
129
+	/**
130
+	 * array of TXN IDs and the payment
131
+	 *
132
+	 * @var array
133
+	 */
134
+	protected static $_update_transactions_with_payment = array();
135
+
136
+
137
+	/**
138
+	 * schedule_update_transaction_with_payment
139
+	 * sets a wp_schedule_single_event() for updating any TXNs that may
140
+	 * require updating due to recently received payments
141
+	 *
142
+	 * @param int $timestamp
143
+	 * @param int $TXN_ID
144
+	 * @param int $PAY_ID
145
+	 */
146
+	public static function schedule_update_transaction_with_payment(
147
+		$timestamp,
148
+		$TXN_ID,
149
+		$PAY_ID
150
+	) {
151
+		do_action('AHEE_log', __CLASS__, __FUNCTION__);
152
+		// validate $TXN_ID and $timestamp
153
+		$TXN_ID    = absint($TXN_ID);
154
+		$timestamp = absint($timestamp);
155
+		if ($TXN_ID && $timestamp) {
156
+			wp_schedule_single_event(
157
+				$timestamp,
158
+				'AHEE__EE_Cron_Tasks__update_transaction_with_payment_2',
159
+				array($TXN_ID, $PAY_ID)
160
+			);
161
+		}
162
+	}
163
+
164
+
165
+	/**
166
+	 * setup_update_for_transaction_with_payment
167
+	 * this is the callback for the action hook:
168
+	 * 'AHEE__EE_Cron_Tasks__update_transaction_with_payment'
169
+	 * which is setup by EE_Cron_Tasks::schedule_update_transaction_with_payment().
170
+	 * The passed TXN_ID and associated payment gets added to an array, and then
171
+	 * the EE_Cron_Tasks::update_transaction_with_payment() function is hooked into
172
+	 * 'shutdown' which will actually handle the processing of any
173
+	 * transactions requiring updating, because doing so now would be too early
174
+	 * and the required resources may not be available
175
+	 *
176
+	 * @param int $TXN_ID
177
+	 * @param int $PAY_ID
178
+	 */
179
+	public static function setup_update_for_transaction_with_payment($TXN_ID = 0, $PAY_ID = 0)
180
+	{
181
+		do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID');
182
+		if (absint($TXN_ID)) {
183
+			self::$_update_transactions_with_payment[$TXN_ID] = $PAY_ID;
184
+			add_action(
185
+				'shutdown',
186
+				array('EE_Cron_Tasks', 'update_transaction_with_payment'),
187
+				5
188
+			);
189
+		}
190
+	}
191
+
192
+
193
+	/**
194
+	 * update_transaction_with_payment
195
+	 * loops through the self::$_abandoned_transactions array
196
+	 * and attempts to finalize any TXNs that have not been completed
197
+	 * but have had their sessions expired, most likely due to a user not
198
+	 * returning from an off-site payment gateway
199
+	 *
200
+	 * @throws \EE_Error
201
+	 */
202
+	public static function update_transaction_with_payment()
203
+	{
204
+		do_action('AHEE_log', __CLASS__, __FUNCTION__);
205
+		// are there any TXNs that need cleaning up ?
206
+		if ( ! empty(self::$_update_transactions_with_payment)) {
207
+			/** @type EE_Payment_Processor $payment_processor */
208
+			$payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
209
+			// set revisit flag for payment processor
210
+			$payment_processor->set_revisit(false);
211
+			// load EEM_Transaction
212
+			EE_Registry::instance()->load_model('Transaction');
213
+			foreach (self::$_update_transactions_with_payment as $TXN_ID => $PAY_ID) {
214
+				// reschedule the cron if we can't hit the db right now
215
+				if ( ! EE_Maintenance_Mode::instance()->models_can_query()) {
216
+					// reset cron job for updating the TXN
217
+					EE_Cron_Tasks::schedule_update_transaction_with_payment(
218
+						time() + EE_Cron_Tasks::reschedule_timeout,
219
+						$TXN_ID,
220
+						$PAY_ID
221
+					);
222
+					continue;
223
+				}
224
+				$transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
225
+				$payment     = EEM_Payment::instance()->get_one_by_ID($PAY_ID);
226
+				// verify transaction
227
+				if ($transaction instanceof EE_Transaction && $payment instanceof EE_Payment) {
228
+					// now try to update the TXN with any payments
229
+					$payment_processor->update_txn_based_on_payment($transaction, $payment, true, true);
230
+				}
231
+				unset(self::$_update_transactions_with_payment[$TXN_ID]);
232
+			}
233
+		}
234
+	}
235
+
236
+
237
+
238
+	/************  END OF UPDATE TRANSACTION WITH PAYMENT  ************/
239
+
240
+
241
+	/*****************  FINALIZE ABANDONED TRANSACTIONS *****************/
242
+
243
+
244
+	/**
245
+	 * array of TXN IDs
246
+	 *
247
+	 * @var array
248
+	 */
249
+	protected static $_abandoned_transactions = array();
250
+
251
+
252
+	/**
253
+	 * schedule_finalize_abandoned_transactions_check
254
+	 * sets a wp_schedule_single_event() for finalizing any TXNs that may
255
+	 * have been abandoned during the registration process
256
+	 *
257
+	 * @param int $timestamp
258
+	 * @param int $TXN_ID
259
+	 */
260
+	public static function schedule_finalize_abandoned_transactions_check(
261
+		$timestamp,
262
+		$TXN_ID
263
+	) {
264
+		// validate $TXN_ID and $timestamp
265
+		$TXN_ID    = absint($TXN_ID);
266
+		$timestamp = absint($timestamp);
267
+		do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID');
268
+		if ($TXN_ID && $timestamp) {
269
+			wp_schedule_single_event(
270
+				$timestamp,
271
+				'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions',
272
+				array($TXN_ID)
273
+			);
274
+		}
275
+	}
276
+
277
+
278
+	/**
279
+	 * check_for_abandoned_transactions
280
+	 * this is the callback for the action hook:
281
+	 * 'AHEE__EE_Cron_Tasks__espresso_finalize_abandoned_transactions'
282
+	 * which is utilized by wp_schedule_single_event()
283
+	 * in EE_SPCO_Reg_Step_Payment_Options::_post_payment_processing().
284
+	 * The passed TXN_ID gets added to an array, and then the
285
+	 * espresso_finalize_abandoned_transactions() function is hooked into
286
+	 * 'AHEE__EE_System__core_loaded_and_ready' which will actually handle the
287
+	 * processing of any abandoned transactions, because doing so now would be
288
+	 * too early and the required resources may not be available
289
+	 *
290
+	 * @param int $TXN_ID
291
+	 */
292
+	public static function check_for_abandoned_transactions($TXN_ID = 0)
293
+	{
294
+		do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID');
295
+		if (absint($TXN_ID)) {
296
+			self::$_abandoned_transactions[] = $TXN_ID;
297
+			add_action(
298
+				'shutdown',
299
+				array('EE_Cron_Tasks', 'finalize_abandoned_transactions'),
300
+				5
301
+			);
302
+		}
303
+	}
304
+
305
+
306
+	/**
307
+	 * finalize_abandoned_transactions
308
+	 * loops through the self::$_abandoned_transactions array
309
+	 * and attempts to finalize any TXNs that have not been completed
310
+	 * but have had their sessions expired, most likely due to a user not
311
+	 * returning from an off-site payment gateway
312
+	 *
313
+	 * @throws \EE_Error
314
+	 */
315
+	public static function finalize_abandoned_transactions()
316
+	{
317
+		do_action('AHEE_log', __CLASS__, __FUNCTION__);
318
+		// are there any TXNs that need cleaning up ?
319
+		if ( ! empty(self::$_abandoned_transactions)) {
320
+			/** @type EE_Transaction_Processor $transaction_processor */
321
+			$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
322
+			// set revisit flag for txn processor
323
+			$transaction_processor->set_revisit(false);
324
+			/** @type EE_Payment_Processor $payment_processor */
325
+			$payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
326
+			// load EEM_Transaction
327
+			EE_Registry::instance()->load_model('Transaction');
328
+			foreach (self::$_abandoned_transactions as $TXN_ID) {
329
+				do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID');
330
+				// reschedule the cron if we can't hit the db right now
331
+				if ( ! EE_Maintenance_Mode::instance()->models_can_query()) {
332
+					// reset cron job for finalizing the TXN
333
+					EE_Cron_Tasks::schedule_finalize_abandoned_transactions_check(
334
+						time() + EE_Cron_Tasks::reschedule_timeout,
335
+						$TXN_ID
336
+					);
337
+					continue;
338
+				}
339
+				$transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
340
+				// verify transaction
341
+				if ($transaction instanceof EE_Transaction) {
342
+					// don't finalize the TXN if it has already been completed
343
+					if ($transaction->all_reg_steps_completed() === true) {
344
+						continue;
345
+					}
346
+					// let's simulate an IPN here which will trigger any notifications that need to go out
347
+					$payment_processor->update_txn_based_on_payment($transaction, $transaction->last_payment(), true,
348
+						true);
349
+				}
350
+				unset(self::$_abandoned_transactions[$TXN_ID]);
351
+			}
352
+		}
353
+	}
354
+
355
+
356
+
357
+	/*************  END OF FINALIZE ABANDONED TRANSACTIONS  *************/
358
+
359
+
360
+	/************* START CLEAN UP BOT TRANSACTIONS **********************/
361
+
362
+	//when a transaction is initially made, schedule this check.
363
+	//if it has NO REG data by the time it has expired, forget about it
364
+	public static function clean_out_junk_transactions()
365
+	{
366
+		if (EE_Maintenance_Mode::instance()->models_can_query()) {
367
+			EEM_Transaction::instance('')->delete_junk_transactions();
368
+			EEM_Registration::instance('')->delete_registrations_with_no_transaction();
369
+			EEM_Line_Item::instance('')->delete_line_items_with_no_transaction();
370
+		}
371
+	}
372 372
 
373 373
 
374 374
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
              * wanting to not have this functionality can just register its own action at a priority after this one to
59 59
              * reverse any changes.
60 60
              */
61
-            add_action('AHEE__EE_System__load_core_configuration__complete', function () {
61
+            add_action('AHEE__EE_System__load_core_configuration__complete', function() {
62 62
                 EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request = true;
63 63
                 EE_Registry::instance()->NET_CFG->update_config(true, false);
64 64
                 add_option('ee_disabled_wp_cron_check', 1, '', false);
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
             'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions',
102 102
             'AHEE__EE_Cron_Tasks__clean_up_junk_transactions',
103 103
         );
104
-        $crons    = get_option('cron');
104
+        $crons = get_option('cron');
105 105
         if ( ! is_array($crons)) {
106 106
             return;
107 107
         }
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +215 added lines, -215 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
 block discarded – undo
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.0');
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.0');
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.22.rc.021');
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.22.rc.021');
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
 }
Please login to merge, or discard this patch.