Completed
Branch BUG/11475/decode-site-title-fo... (bbd86e)
by
unknown
13:39 queued 25s
created
modules/single_page_checkout/inc/EE_SPCO_JSON_Response.php 2 patches
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
2 2
  /**
3
- *
4
- * Class EE_SPCO_JSON_Response
5
- *
6
- * Description
7
- *
8
- * @package         Event Espresso
9
- * @subpackage    core
10
- * @author				Brent Christensen
11
- *
12
- *
13
- */
3
+  *
4
+  * Class EE_SPCO_JSON_Response
5
+  *
6
+  * Description
7
+  *
8
+  * @package         Event Espresso
9
+  * @subpackage    core
10
+  * @author				Brent Christensen
11
+  *
12
+  *
13
+  */
14 14
 class EE_SPCO_JSON_Response {
15 15
 
16 16
 	/**
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 
85 85
 	/**
86 86
 	 *    class constructor
87
-   */
87
+	 */
88 88
 	public function __construct(  ) {
89 89
 	}
90 90
 
@@ -271,10 +271,10 @@  discard block
 block discarded – undo
271 271
 	}
272 272
 
273 273
 
274
-    /**
275
-     * @param float $payment_amount
276
-     * @throws EE_Error
277
-     */
274
+	/**
275
+	 * @param float $payment_amount
276
+	 * @throws EE_Error
277
+	 */
278 278
 	public function set_payment_amount( $payment_amount ) {
279 279
 		$this->_payment_amount = (float)$payment_amount;
280 280
 	}
@@ -408,11 +408,11 @@  discard block
 block discarded – undo
408 408
 	}
409 409
 
410 410
 
411
-    public function echoAndExit()
412
-    {
413
-        echo $this;
414
-        exit();
415
-    }
411
+	public function echoAndExit()
412
+	{
413
+		echo $this;
414
+		exit();
415
+	}
416 416
 
417 417
 }
418 418
 // End of file EE_SPCO_JSON_Response.php
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -104,71 +104,71 @@  discard block
 block discarded – undo
104 104
 	public function __toString() {
105 105
 		$JSON_response = array();
106 106
 		// grab notices
107
-		$notices = EE_Error::get_notices( FALSE );
108
-		$this->set_attention( isset( $notices['attention'] ) ? $notices['attention'] : '' );
109
-		$this->set_errors( isset( $notices['errors'] ) ? $notices['errors'] : '' );
110
-		$this->set_success( isset( $notices['success'] ) ? $notices['success'] : '' );
107
+		$notices = EE_Error::get_notices(FALSE);
108
+		$this->set_attention(isset($notices['attention']) ? $notices['attention'] : '');
109
+		$this->set_errors(isset($notices['errors']) ? $notices['errors'] : '');
110
+		$this->set_success(isset($notices['success']) ? $notices['success'] : '');
111 111
 		// add notices to JSON response, but only if they exist
112
-		if ( $this->attention() ) {
112
+		if ($this->attention()) {
113 113
 			$JSON_response['attention'] = $this->attention();
114 114
 		}
115
-		if ( $this->errors() ) {
115
+		if ($this->errors()) {
116 116
 			$JSON_response['errors'] = $this->errors();
117 117
 		}
118
-		if ( $this->unexpected_errors() ) {
118
+		if ($this->unexpected_errors()) {
119 119
 			$JSON_response['unexpected_errors'] = $this->unexpected_errors();
120 120
 		}
121
-		if ( $this->success() ) {
121
+		if ($this->success()) {
122 122
 			$JSON_response['success'] = $this->success();
123 123
 		}
124 124
 		// but if NO notices are set... at least set the "success" as a key so that the JS knows everything worked
125
-		if ( ! isset( $JSON_response[ 'attention' ] ) && ! isset( $JSON_response[ 'errors' ] ) && ! isset( $JSON_response[ 'success' ] ) ) {
125
+		if ( ! isset($JSON_response['attention']) && ! isset($JSON_response['errors']) && ! isset($JSON_response['success'])) {
126 126
 			$JSON_response['success'] = null;
127 127
 		}
128 128
 		// set redirect_url, IF it exists
129
-		if ( $this->redirect_url() ) {
129
+		if ($this->redirect_url()) {
130 130
 			$JSON_response['redirect_url'] = $this->redirect_url();
131 131
 		}
132 132
 		// set registration_time_limit, IF it exists
133
-		if ( $this->registration_time_limit() ) {
133
+		if ($this->registration_time_limit()) {
134 134
 			$JSON_response['registration_time_limit'] = $this->registration_time_limit();
135 135
 		}
136 136
 		// set payment_amount, IF it exists
137
-		if ( $this->payment_amount() !== null ) {
138
-			$JSON_response[ 'payment_amount' ] = $this->payment_amount();
137
+		if ($this->payment_amount() !== null) {
138
+			$JSON_response['payment_amount'] = $this->payment_amount();
139 139
 		}
140 140
 		// grab generic return data
141 141
 		$return_data = $this->return_data();
142 142
 		// add billing form validation rules
143
-		if ( $this->validation_rules() ) {
143
+		if ($this->validation_rules()) {
144 144
 			$return_data['validation_rules'] = $this->validation_rules();
145 145
 		}
146 146
 		// set reg_step_html, IF it exists
147
-		if ( $this->reg_step_html() ) {
147
+		if ($this->reg_step_html()) {
148 148
 			$return_data['reg_step_html'] = $this->reg_step_html();
149 149
 		}
150 150
 		// set method of payment, IF it exists
151
-		if ( $this->method_of_payment() ) {
151
+		if ($this->method_of_payment()) {
152 152
 			$return_data['method_of_payment'] = $this->method_of_payment();
153 153
 		}
154 154
 		// set "plz_select_method_of_payment" message, IF it exists
155
-		if ( $this->plz_select_method_of_payment() ) {
155
+		if ($this->plz_select_method_of_payment()) {
156 156
 			$return_data['plz_select_method_of_payment'] = $this->plz_select_method_of_payment();
157 157
 		}
158 158
 		// set redirect_form, IF it exists
159
-		if ( $this->redirect_form() ) {
159
+		if ($this->redirect_form()) {
160 160
 			$return_data['redirect_form'] = $this->redirect_form();
161 161
 		}
162 162
 		// and finally, add return_data array to main JSON response array, IF it contains anything
163 163
 		// why did we add some of the above properties to the return data array?
164 164
 		// because it is easier and cleaner in the Javascript to deal with this way
165
-		if ( ! empty( $return_data )) {
165
+		if ( ! empty($return_data)) {
166 166
 			$JSON_response['return_data'] = $return_data;
167 167
 		}
168 168
 		// filter final array
169
-		$JSON_response = apply_filters( 'FHEE__EE_SPCO_JSON_Response___toString__JSON_response', $JSON_response );
169
+		$JSON_response = apply_filters('FHEE__EE_SPCO_JSON_Response___toString__JSON_response', $JSON_response);
170 170
 		// return encoded array
171
-		return (string) wp_json_encode( $JSON_response );
171
+		return (string) wp_json_encode($JSON_response);
172 172
 	}
173 173
 
174 174
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 	/**
177 177
 	 * @param string $attention
178 178
 	 */
179
-	public function set_attention( $attention ) {
179
+	public function set_attention($attention) {
180 180
 		$this->_attention = $attention;
181 181
 	}
182 182
 
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 	/**
195 195
 	 * @param string $errors
196 196
 	 */
197
-	public function set_errors( $errors ) {
197
+	public function set_errors($errors) {
198 198
 		$this->_errors = $errors;
199 199
 	}
200 200
 
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 	/**
222 222
 	 * @param string $unexpected_errors
223 223
 	 */
224
-	public function set_unexpected_errors( $unexpected_errors ) {
224
+	public function set_unexpected_errors($unexpected_errors) {
225 225
 		$this->_unexpected_errors = $unexpected_errors;
226 226
 	}
227 227
 
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 	/**
231 231
 	 * @param string $success
232 232
 	 */
233
-	public function set_success( $success ) {
233
+	public function set_success($success) {
234 234
 		$this->_success = $success;
235 235
 	}
236 236
 
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 	/**
249 249
 	 * @param string $method_of_payment
250 250
 	 */
251
-	public function set_method_of_payment( $method_of_payment ) {
251
+	public function set_method_of_payment($method_of_payment) {
252 252
 		$this->_method_of_payment = $method_of_payment;
253 253
 	}
254 254
 
@@ -275,8 +275,8 @@  discard block
 block discarded – undo
275 275
      * @param float $payment_amount
276 276
      * @throws EE_Error
277 277
      */
278
-	public function set_payment_amount( $payment_amount ) {
279
-		$this->_payment_amount = (float)$payment_amount;
278
+	public function set_payment_amount($payment_amount) {
279
+		$this->_payment_amount = (float) $payment_amount;
280 280
 	}
281 281
 
282 282
 
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 	/**
285 285
 	 * @param string $next_step_html
286 286
 	 */
287
-	public function set_reg_step_html( $next_step_html ) {
287
+	public function set_reg_step_html($next_step_html) {
288 288
 		$this->_reg_step_html = $next_step_html;
289 289
 	}
290 290
 
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 	/**
303 303
 	 * @param string $redirect_form
304 304
 	 */
305
-	public function set_redirect_form( $redirect_form ) {
305
+	public function set_redirect_form($redirect_form) {
306 306
 		$this->_redirect_form = $redirect_form;
307 307
 	}
308 308
 
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 	 * @return string
313 313
 	 */
314 314
 	public function redirect_form() {
315
-		return ! empty( $this->_redirect_form ) ? $this->_redirect_form : FALSE;
315
+		return ! empty($this->_redirect_form) ? $this->_redirect_form : FALSE;
316 316
 	}
317 317
 
318 318
 
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 	/**
321 321
 	 * @param string $plz_select_method_of_payment
322 322
 	 */
323
-	public function set_plz_select_method_of_payment( $plz_select_method_of_payment ) {
323
+	public function set_plz_select_method_of_payment($plz_select_method_of_payment) {
324 324
 		$this->_plz_select_method_of_payment = $plz_select_method_of_payment;
325 325
 	}
326 326
 
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
 	/**
339 339
 	 * @param string $redirect_url
340 340
 	 */
341
-	public function set_redirect_url( $redirect_url ) {
341
+	public function set_redirect_url($redirect_url) {
342 342
 		$this->_redirect_url = $redirect_url;
343 343
 	}
344 344
 
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 	/**
366 366
 	 * @param string $registration_time_limit
367 367
 	 */
368
-	public function set_registration_time_limit( $registration_time_limit ) {
368
+	public function set_registration_time_limit($registration_time_limit) {
369 369
 		$this->_registration_time_limit = $registration_time_limit;
370 370
 	}
371 371
 
@@ -374,8 +374,8 @@  discard block
 block discarded – undo
374 374
 	/**
375 375
 	 * @param array $return_data
376 376
 	 */
377
-	public function set_return_data( $return_data ) {
378
-		$this->_return_data = array_merge( $this->_return_data, $return_data );
377
+	public function set_return_data($return_data) {
378
+		$this->_return_data = array_merge($this->_return_data, $return_data);
379 379
 	}
380 380
 
381 381
 
@@ -393,8 +393,8 @@  discard block
 block discarded – undo
393 393
 	 * @param array $validation_rules
394 394
 	 */
395 395
 	public function add_validation_rules(array $validation_rules = array()) {
396
-		if ( is_array( $validation_rules ) && ! empty( $validation_rules )) {
397
-			$this->_validation_rules = array_merge( $this->_validation_rules, $validation_rules );
396
+		if (is_array($validation_rules) && ! empty($validation_rules)) {
397
+			$this->_validation_rules = array_merge($this->_validation_rules, $validation_rules);
398 398
 		}
399 399
 	}
400 400
 
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 	 * @return array | bool
405 405
 	 */
406 406
 	public function validation_rules() {
407
-		return ! empty( $this->_validation_rules ) ? $this->_validation_rules : FALSE;
407
+		return ! empty($this->_validation_rules) ? $this->_validation_rules : FALSE;
408 408
 	}
409 409
 
410 410
 
Please login to merge, or discard this patch.
core/libraries/form_sections/base/EE_Form_Section_Proper.form.php 2 patches
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
             //AND we are going to make sure they're in that specified order
112 112
             $reordered_subsections = array();
113 113
             foreach ($options_array['include'] as $input_name) {
114
-                if (isset($this->_subsections[ $input_name ])) {
115
-                    $reordered_subsections[ $input_name ] = $this->_subsections[ $input_name ];
114
+                if (isset($this->_subsections[$input_name])) {
115
+                    $reordered_subsections[$input_name] = $this->_subsections[$input_name];
116 116
                 }
117 117
             }
118 118
             $this->_subsections = $reordered_subsections;
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
         if (isset($options_array['layout_strategy'])) {
125 125
             $this->_layout_strategy = $options_array['layout_strategy'];
126 126
         }
127
-        if (! $this->_layout_strategy) {
127
+        if ( ! $this->_layout_strategy) {
128 128
             $this->_layout_strategy = is_admin() ? new EE_Admin_Two_Column_Layout() : new EE_Two_Column_Layout();
129 129
         }
130 130
         $this->_layout_strategy->_construct_finalize($this);
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
                 $req_data,
278 278
                 $this
279 279
             );
280
-            $this->cached_request_data = (array)$req_data;
280
+            $this->cached_request_data = (array) $req_data;
281 281
         }
282 282
         return $this->cached_request_data;
283 283
     }
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
         if ($validate) {
314 314
             $this->_validate();
315 315
             //if it's invalid, we're going to want to re-display so remember what they submitted
316
-            if (! $this->is_valid()) {
316
+            if ( ! $this->is_valid()) {
317 317
                 $this->store_submitted_form_data_in_session();
318 318
             }
319 319
         }
@@ -426,11 +426,11 @@  discard block
 block discarded – undo
426 426
     public function populate_defaults($default_data)
427 427
     {
428 428
         foreach ($this->subsections(false) as $subsection_name => $subsection) {
429
-            if (isset($default_data[ $subsection_name ])) {
429
+            if (isset($default_data[$subsection_name])) {
430 430
                 if ($subsection instanceof EE_Form_Input_Base) {
431
-                    $subsection->set_default($default_data[ $subsection_name ]);
431
+                    $subsection->set_default($default_data[$subsection_name]);
432 432
                 } elseif ($subsection instanceof EE_Form_Section_Proper) {
433
-                    $subsection->populate_defaults($default_data[ $subsection_name ]);
433
+                    $subsection->populate_defaults($default_data[$subsection_name]);
434 434
                 }
435 435
             }
436 436
         }
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
      */
446 446
     public function subsection_exists($name)
447 447
     {
448
-        return isset($this->_subsections[ $name ]) ? true : false;
448
+        return isset($this->_subsections[$name]) ? true : false;
449 449
     }
450 450
 
451 451
 
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
         if ($require_construction_to_be_finalized) {
468 468
             $this->ensure_construct_finalized_called();
469 469
         }
470
-        return $this->subsection_exists($name) ? $this->_subsections[ $name ] : null;
470
+        return $this->subsection_exists($name) ? $this->_subsections[$name] : null;
471 471
     }
472 472
 
473 473
 
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
         $validatable_subsections = array();
483 483
         foreach ($this->subsections() as $name => $obj) {
484 484
             if ($obj instanceof EE_Form_Section_Validatable) {
485
-                $validatable_subsections[ $name ] = $obj;
485
+                $validatable_subsections[$name] = $obj;
486 486
             }
487 487
         }
488 488
         return $validatable_subsections;
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
             $name,
510 510
             $require_construction_to_be_finalized
511 511
         );
512
-        if (! $subsection instanceof EE_Form_Input_Base) {
512
+        if ( ! $subsection instanceof EE_Form_Input_Base) {
513 513
             throw new EE_Error(
514 514
                 sprintf(
515 515
                     esc_html__(
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
             $name,
547 547
             $require_construction_to_be_finalized
548 548
         );
549
-        if (! $subsection instanceof EE_Form_Section_Proper) {
549
+        if ( ! $subsection instanceof EE_Form_Section_Proper) {
550 550
             throw new EE_Error(
551 551
                 sprintf(
552 552
                     esc_html__(
@@ -585,8 +585,8 @@  discard block
 block discarded – undo
585 585
      */
586 586
     public function is_valid()
587 587
     {
588
-        if($this->is_valid === null) {
589
-            if (! $this->has_received_submission()) {
588
+        if ($this->is_valid === null) {
589
+            if ( ! $this->has_received_submission()) {
590 590
                 throw new EE_Error(
591 591
                     sprintf(
592 592
                         esc_html__(
@@ -596,14 +596,14 @@  discard block
 block discarded – undo
596 596
                     )
597 597
                 );
598 598
             }
599
-            if (! parent::is_valid()) {
599
+            if ( ! parent::is_valid()) {
600 600
                 $this->is_valid = false;
601 601
             } else {
602 602
                 // ok so no general errors to this entire form section.
603 603
                 // so let's check the subsections, but only set errors if that hasn't been done yet
604 604
                 $this->is_valid = true;
605 605
                 foreach ($this->get_validatable_subsections() as $subsection) {
606
-                    if (! $subsection->is_valid()) {
606
+                    if ( ! $subsection->is_valid()) {
607 607
                         $this->is_valid = false;
608 608
                     }
609 609
                 }
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
      */
621 621
     protected function _set_default_name_if_empty()
622 622
     {
623
-        if (! $this->_name) {
623
+        if ( ! $this->_name) {
624 624
             $classname    = get_class($this);
625 625
             $default_name = str_replace('EE_', '', $classname);
626 626
             $this->_name  = $default_name;
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
     {
711 711
         wp_register_script(
712 712
             'ee_form_section_validation',
713
-            EE_GLOBAL_ASSETS_URL . 'scripts' . DS . 'form_section_validation.js',
713
+            EE_GLOBAL_ASSETS_URL.'scripts'.DS.'form_section_validation.js',
714 714
             array('jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods'),
715 715
             EVENT_ESPRESSO_VERSION,
716 716
             true
@@ -754,13 +754,13 @@  discard block
 block discarded – undo
754 754
         // we only want to localize vars ONCE for the entire form,
755 755
         // so if the form section doesn't have a parent, then it must be the top dog
756 756
         if ($return_for_subsection || ! $this->parent_section()) {
757
-            EE_Form_Section_Proper::$_js_localization['form_data'][ $this->html_id() ] = array(
757
+            EE_Form_Section_Proper::$_js_localization['form_data'][$this->html_id()] = array(
758 758
                 'form_section_id'  => $this->html_id(true),
759 759
                 'validation_rules' => $this->get_jquery_validation_rules(),
760 760
                 'other_data'       => $this->get_other_js_data(),
761 761
                 'errors'           => $this->subsection_validation_errors_by_html_name(),
762 762
             );
763
-            EE_Form_Section_Proper::$_scripts_localized                                = true;
763
+            EE_Form_Section_Proper::$_scripts_localized = true;
764 764
         }
765 765
     }
766 766
 
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
         $inputs = array();
796 796
         foreach ($this->subsections() as $subsection) {
797 797
             if ($subsection instanceof EE_Form_Input_Base) {
798
-                $inputs[ $subsection->html_name() ] = $subsection;
798
+                $inputs[$subsection->html_name()] = $subsection;
799 799
             } elseif ($subsection instanceof EE_Form_Section_Proper) {
800 800
                 $inputs += $subsection->inputs_in_subsections();
801 801
             }
@@ -818,7 +818,7 @@  discard block
 block discarded – undo
818 818
         $errors = array();
819 819
         foreach ($inputs as $form_input) {
820 820
             if ($form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors()) {
821
-                $errors[ $form_input->html_name() ] = $form_input->get_validation_error_string();
821
+                $errors[$form_input->html_name()] = $form_input->get_validation_error_string();
822 822
             }
823 823
         }
824 824
         return $errors;
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
         $email_validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level)
842 842
             ? EE_Registry::instance()->CFG->registration->email_validation_level
843 843
             : 'wp_default';
844
-        EE_Form_Section_Proper::$_js_localization['email_validation_level']   = $email_validation_level;
844
+        EE_Form_Section_Proper::$_js_localization['email_validation_level'] = $email_validation_level;
845 845
         wp_enqueue_script('ee_form_section_validation');
846 846
         wp_localize_script(
847 847
             'ee_form_section_validation',
@@ -858,7 +858,7 @@  discard block
 block discarded – undo
858 858
      */
859 859
     public function ensure_scripts_localized()
860 860
     {
861
-        if (! EE_Form_Section_Proper::$_scripts_localized) {
861
+        if ( ! EE_Form_Section_Proper::$_scripts_localized) {
862 862
             $this->_enqueue_and_localize_form_js();
863 863
         }
864 864
     }
@@ -954,8 +954,8 @@  discard block
 block discarded – undo
954 954
         //reset the cache of whether this form is valid or not- we're re-validating it now
955 955
         $this->is_valid = null;
956 956
         foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) {
957
-            if (method_exists($this, '_validate_' . $subsection_name)) {
958
-                call_user_func_array(array($this, '_validate_' . $subsection_name), array($subsection));
957
+            if (method_exists($this, '_validate_'.$subsection_name)) {
958
+                call_user_func_array(array($this, '_validate_'.$subsection_name), array($subsection));
959 959
             }
960 960
             $subsection->_validate();
961 961
         }
@@ -973,9 +973,9 @@  discard block
 block discarded – undo
973 973
         $inputs = array();
974 974
         foreach ($this->subsections() as $subsection_name => $subsection) {
975 975
             if ($subsection instanceof EE_Form_Section_Proper) {
976
-                $inputs[ $subsection_name ] = $subsection->valid_data();
976
+                $inputs[$subsection_name] = $subsection->valid_data();
977 977
             } elseif ($subsection instanceof EE_Form_Input_Base) {
978
-                $inputs[ $subsection_name ] = $subsection->normalized_value();
978
+                $inputs[$subsection_name] = $subsection->normalized_value();
979 979
             }
980 980
         }
981 981
         return $inputs;
@@ -993,7 +993,7 @@  discard block
 block discarded – undo
993 993
         $inputs = array();
994 994
         foreach ($this->subsections() as $subsection_name => $subsection) {
995 995
             if ($subsection instanceof EE_Form_Input_Base) {
996
-                $inputs[ $subsection_name ] = $subsection;
996
+                $inputs[$subsection_name] = $subsection;
997 997
             }
998 998
         }
999 999
         return $inputs;
@@ -1011,7 +1011,7 @@  discard block
 block discarded – undo
1011 1011
         $form_sections = array();
1012 1012
         foreach ($this->subsections() as $name => $obj) {
1013 1013
             if ($obj instanceof EE_Form_Section_Proper) {
1014
-                $form_sections[ $name ] = $obj;
1014
+                $form_sections[$name] = $obj;
1015 1015
             }
1016 1016
         }
1017 1017
         return $form_sections;
@@ -1118,7 +1118,7 @@  discard block
 block discarded – undo
1118 1118
         $input_values = array();
1119 1119
         foreach ($this->subsections() as $subsection_name => $subsection) {
1120 1120
             if ($subsection instanceof EE_Form_Input_Base) {
1121
-                $input_values[ $subsection_name ] = $pretty
1121
+                $input_values[$subsection_name] = $pretty
1122 1122
                     ? $subsection->pretty_value()
1123 1123
                     : $subsection->normalized_value();
1124 1124
             } elseif ($subsection instanceof EE_Form_Section_Proper && $include_subform_inputs) {
@@ -1130,7 +1130,7 @@  discard block
 block discarded – undo
1130 1130
                 if ($flatten) {
1131 1131
                     $input_values = array_merge($input_values, $subform_input_values);
1132 1132
                 } else {
1133
-                    $input_values[ $subsection_name ] = $subform_input_values;
1133
+                    $input_values[$subsection_name] = $subform_input_values;
1134 1134
                 }
1135 1135
             }
1136 1136
         }
@@ -1158,7 +1158,7 @@  discard block
 block discarded – undo
1158 1158
             if ($subsection instanceof EE_Form_Input_Base) {
1159 1159
                 // is this input part of an array of inputs?
1160 1160
                 if (strpos($subsection->html_name(), '[') !== false) {
1161
-                    $full_input_name  = EEH_Array::convert_array_values_to_keys(
1161
+                    $full_input_name = EEH_Array::convert_array_values_to_keys(
1162 1162
                         explode(
1163 1163
                             '[',
1164 1164
                             str_replace(']', '', $subsection->html_name())
@@ -1167,7 +1167,7 @@  discard block
 block discarded – undo
1167 1167
                     );
1168 1168
                     $submitted_values = array_replace_recursive($submitted_values, $full_input_name);
1169 1169
                 } else {
1170
-                    $submitted_values[ $subsection->html_name() ] = $subsection->raw_value();
1170
+                    $submitted_values[$subsection->html_name()] = $subsection->raw_value();
1171 1171
                 }
1172 1172
             } elseif ($subsection instanceof EE_Form_Section_Proper && $include_subforms) {
1173 1173
                 $subform_input_values = $subsection->submitted_values($include_subforms);
@@ -1202,7 +1202,7 @@  discard block
 block discarded – undo
1202 1202
     public function exclude(array $inputs_to_exclude = array())
1203 1203
     {
1204 1204
         foreach ($inputs_to_exclude as $input_to_exclude_name) {
1205
-            unset($this->_subsections[ $input_to_exclude_name ]);
1205
+            unset($this->_subsections[$input_to_exclude_name]);
1206 1206
         }
1207 1207
     }
1208 1208
 
@@ -1244,7 +1244,7 @@  discard block
 block discarded – undo
1244 1244
     public function add_subsections($new_subsections, $subsection_name_to_target = null, $add_before = true)
1245 1245
     {
1246 1246
         foreach ($new_subsections as $subsection_name => $subsection) {
1247
-            if (! $subsection instanceof EE_Form_Section_Base) {
1247
+            if ( ! $subsection instanceof EE_Form_Section_Base) {
1248 1248
                 EE_Error::add_error(
1249 1249
                     sprintf(
1250 1250
                         esc_html__(
@@ -1256,7 +1256,7 @@  discard block
 block discarded – undo
1256 1256
                         $this->name()
1257 1257
                     )
1258 1258
                 );
1259
-                unset($new_subsections[ $subsection_name ]);
1259
+                unset($new_subsections[$subsection_name]);
1260 1260
             }
1261 1261
         }
1262 1262
         $this->_subsections = EEH_Array::insert_into_array(
@@ -1280,7 +1280,7 @@  discard block
 block discarded – undo
1280 1280
      */
1281 1281
     public function has_subsection($subsection_name, $recursive = false)
1282 1282
     {
1283
-        foreach ($this->_subsections as $name => $subsection) {if(
1283
+        foreach ($this->_subsections as $name => $subsection) {if (
1284 1284
                 $name === $subsection_name
1285 1285
                 || (
1286 1286
                     $recursive
@@ -1371,7 +1371,7 @@  discard block
 block discarded – undo
1371 1371
     public function html_name_prefix()
1372 1372
     {
1373 1373
         if ($this->parent_section() instanceof EE_Form_Section_Proper) {
1374
-            return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']';
1374
+            return $this->parent_section()->html_name_prefix().'['.$this->name().']';
1375 1375
         }
1376 1376
         return $this->name();
1377 1377
     }
@@ -1411,7 +1411,7 @@  discard block
 block discarded – undo
1411 1411
      */
1412 1412
     public function ensure_construct_finalized_called()
1413 1413
     {
1414
-        if (! $this->_construction_finalized) {
1414
+        if ( ! $this->_construction_finalized) {
1415 1415
             $this->_construct_finalize($this->_parent_section, $this->_name);
1416 1416
         }
1417 1417
     }
@@ -1484,7 +1484,7 @@  discard block
 block discarded – undo
1484 1484
                 $form_section = $validation_error->get_form_section();
1485 1485
                 if ($form_section instanceof EE_Form_Input_Base) {
1486 1486
                    $label = $validation_error->get_form_section()->html_label_text();
1487
-                } elseif($form_section instanceof EE_Form_Section_Validatable) {
1487
+                } elseif ($form_section instanceof EE_Form_Section_Validatable) {
1488 1488
                     $label = $validation_error->get_form_section()->name();
1489 1489
                 } else {
1490 1490
                     $label = esc_html__('Unknown', 'event_espresso');
Please login to merge, or discard this patch.
Indentation   +1524 added lines, -1524 removed lines patch added patch discarded remove patch
@@ -14,1529 +14,1529 @@
 block discarded – undo
14 14
 class EE_Form_Section_Proper extends EE_Form_Section_Validatable
15 15
 {
16 16
 
17
-    const SUBMITTED_FORM_DATA_SSN_KEY = 'submitted_form_data';
18
-
19
-    /**
20
-     * Subsections
21
-     *
22
-     * @var EE_Form_Section_Validatable[]
23
-     */
24
-    protected $_subsections = array();
25
-
26
-    /**
27
-     * Strategy for laying out the form
28
-     *
29
-     * @var EE_Form_Section_Layout_Base
30
-     */
31
-    protected $_layout_strategy;
32
-
33
-    /**
34
-     * Whether or not this form has received and validated a form submission yet
35
-     *
36
-     * @var boolean
37
-     */
38
-    protected $_received_submission = false;
39
-
40
-    /**
41
-     * message displayed to users upon successful form submission
42
-     *
43
-     * @var string
44
-     */
45
-    protected $_form_submission_success_message = '';
46
-
47
-    /**
48
-     * message displayed to users upon unsuccessful form submission
49
-     *
50
-     * @var string
51
-     */
52
-    protected $_form_submission_error_message = '';
53
-
54
-    /**
55
-     * @var array like $_REQUEST
56
-     */
57
-    protected $cached_request_data;
58
-
59
-    /**
60
-     * Stores whether this form (and its sub-sections) were found to be valid or not.
61
-     * Starts off as null, but once the form is validated, it set to either true or false
62
-     * @var boolean|null
63
-     */
64
-    protected $is_valid;
65
-
66
-    /**
67
-     * Stores all the data that will localized for form validation
68
-     *
69
-     * @var array
70
-     */
71
-    static protected $_js_localization = array();
72
-
73
-    /**
74
-     * whether or not the form's localized validation JS vars have been set
75
-     *
76
-     * @type boolean
77
-     */
78
-    static protected $_scripts_localized = false;
79
-
80
-
81
-    /**
82
-     * when constructing a proper form section, calls _construct_finalize on children
83
-     * so that they know who their parent is, and what name they've been given.
84
-     *
85
-     * @param array[] $options_array   {
86
-     * @type          $subsections     EE_Form_Section_Validatable[] where keys are the section's name
87
-     * @type          $include         string[] numerically-indexed where values are section names to be included,
88
-     *                                 and in that order. This is handy if you want
89
-     *                                 the subsections to be ordered differently than the default, and if you override
90
-     *                                 which fields are shown
91
-     * @type          $exclude         string[] values are subsections to be excluded. This is handy if you want
92
-     *                                 to remove certain default subsections (note: if you specify BOTH 'include' AND
93
-     *                                 'exclude', the inclusions will be applied first, and the exclusions will exclude
94
-     *                                 items from that list of inclusions)
95
-     * @type          $layout_strategy EE_Form_Section_Layout_Base strategy for laying out the form
96
-     *                                 } @see EE_Form_Section_Validatable::__construct()
97
-     * @throws EE_Error
98
-     */
99
-    public function __construct($options_array = array())
100
-    {
101
-        $options_array = (array) apply_filters(
102
-            'FHEE__EE_Form_Section_Proper___construct__options_array',
103
-            $options_array,
104
-            $this
105
-        );
106
-        //call parent first, as it may be setting the name
107
-        parent::__construct($options_array);
108
-        //if they've included subsections in the constructor, add them now
109
-        if (isset($options_array['include'])) {
110
-            //we are going to make sure we ONLY have those subsections to include
111
-            //AND we are going to make sure they're in that specified order
112
-            $reordered_subsections = array();
113
-            foreach ($options_array['include'] as $input_name) {
114
-                if (isset($this->_subsections[ $input_name ])) {
115
-                    $reordered_subsections[ $input_name ] = $this->_subsections[ $input_name ];
116
-                }
117
-            }
118
-            $this->_subsections = $reordered_subsections;
119
-        }
120
-        if (isset($options_array['exclude'])) {
121
-            $exclude            = $options_array['exclude'];
122
-            $this->_subsections = array_diff_key($this->_subsections, array_flip($exclude));
123
-        }
124
-        if (isset($options_array['layout_strategy'])) {
125
-            $this->_layout_strategy = $options_array['layout_strategy'];
126
-        }
127
-        if (! $this->_layout_strategy) {
128
-            $this->_layout_strategy = is_admin() ? new EE_Admin_Two_Column_Layout() : new EE_Two_Column_Layout();
129
-        }
130
-        $this->_layout_strategy->_construct_finalize($this);
131
-        //ok so we are definitely going to want the forms JS,
132
-        //so enqueue it or remember to enqueue it during wp_enqueue_scripts
133
-        if (did_action('wp_enqueue_scripts') || did_action('admin_enqueue_scripts')) {
134
-            //ok so they've constructed this object after when they should have.
135
-            //just enqueue the generic form scripts and initialize the form immediately in the JS
136
-            EE_Form_Section_Proper::wp_enqueue_scripts(true);
137
-        } else {
138
-            add_action('wp_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts'));
139
-            add_action('admin_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts'));
140
-        }
141
-        add_action('wp_footer', array($this, 'ensure_scripts_localized'), 1);
142
-        /**
143
-         * Gives other plugins a chance to hook in before construct finalize is called.
144
-         * The form probably doesn't yet have a parent form section.
145
-         * Since 4.9.32, when this action was introduced, this is the best place to add a subsection onto a form,
146
-         * assuming you don't care what the form section's name, HTML ID, or HTML name etc are.
147
-         * Also see AHEE__EE_Form_Section_Proper___construct_finalize__end
148
-         *
149
-         * @since 4.9.32
150
-         * @param EE_Form_Section_Proper $this          before __construct is done, but all of its logic,
151
-         *                                              except maybe calling _construct_finalize has been done
152
-         * @param array                  $options_array options passed into the constructor
153
-         */
154
-        do_action(
155
-            'AHEE__EE_Form_Input_Base___construct__before_construct_finalize_called',
156
-            $this,
157
-            $options_array
158
-        );
159
-        if (isset($options_array['name'])) {
160
-            $this->_construct_finalize(null, $options_array['name']);
161
-        }
162
-    }
163
-
164
-
165
-    /**
166
-     * Finishes construction given the parent form section and this form section's name
167
-     *
168
-     * @param EE_Form_Section_Proper $parent_form_section
169
-     * @param string                 $name
170
-     * @throws EE_Error
171
-     */
172
-    public function _construct_finalize($parent_form_section, $name)
173
-    {
174
-        parent::_construct_finalize($parent_form_section, $name);
175
-        $this->_set_default_name_if_empty();
176
-        $this->_set_default_html_id_if_empty();
177
-        foreach ($this->_subsections as $subsection_name => $subsection) {
178
-            if ($subsection instanceof EE_Form_Section_Base) {
179
-                $subsection->_construct_finalize($this, $subsection_name);
180
-            } else {
181
-                throw new EE_Error(
182
-                    sprintf(
183
-                        esc_html__(
184
-                            'Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"',
185
-                            'event_espresso'
186
-                        ),
187
-                        $subsection_name,
188
-                        get_class($this),
189
-                        $subsection ? get_class($subsection) : esc_html__('NULL', 'event_espresso')
190
-                    )
191
-                );
192
-            }
193
-        }
194
-        /**
195
-         * Action performed just after form has been given a name (and HTML ID etc) and is fully constructed.
196
-         * If you have code that should modify the form and needs it and its subsections to have a name, HTML ID
197
-         * (or other attributes derived from the name like the HTML label id, etc), this is where it should be done.
198
-         * This might only happen just before displaying the form, or just before it receives form submission data.
199
-         * If you need to modify the form or its subsections before _construct_finalize is called on it (and we've
200
-         * ensured it has a name, HTML IDs, etc
201
-         *
202
-         * @param EE_Form_Section_Proper      $this
203
-         * @param EE_Form_Section_Proper|null $parent_form_section
204
-         * @param string                      $name
205
-         */
206
-        do_action(
207
-            'AHEE__EE_Form_Section_Proper___construct_finalize__end',
208
-            $this,
209
-            $parent_form_section,
210
-            $name
211
-        );
212
-    }
213
-
214
-
215
-    /**
216
-     * Gets the layout strategy for this form section
217
-     *
218
-     * @return EE_Form_Section_Layout_Base
219
-     */
220
-    public function get_layout_strategy()
221
-    {
222
-        return $this->_layout_strategy;
223
-    }
224
-
225
-
226
-    /**
227
-     * Gets the HTML for a single input for this form section according
228
-     * to the layout strategy
229
-     *
230
-     * @param EE_Form_Input_Base $input
231
-     * @return string
232
-     */
233
-    public function get_html_for_input($input)
234
-    {
235
-        return $this->_layout_strategy->layout_input($input);
236
-    }
237
-
238
-
239
-    /**
240
-     * was_submitted - checks if form inputs are present in request data
241
-     * Basically an alias for form_data_present_in() (which is used by both
242
-     * proper form sections and form inputs)
243
-     *
244
-     * @param null $form_data
245
-     * @return boolean
246
-     * @throws EE_Error
247
-     */
248
-    public function was_submitted($form_data = null)
249
-    {
250
-        return $this->form_data_present_in($form_data);
251
-    }
252
-
253
-    /**
254
-     * Gets the cached request data; but if there is none, or $req_data was set with
255
-     * something different, refresh the cache, and then return it
256
-     * @param null $req_data
257
-     * @return array
258
-     */
259
-    protected function getCachedRequest($req_data = null)
260
-    {
261
-        if ($this->cached_request_data === null
262
-            || (
263
-                $req_data !== null &&
264
-                $req_data !== $this->cached_request_data
265
-            )
266
-        ) {
267
-            $req_data = apply_filters(
268
-                'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data',
269
-                $req_data,
270
-                $this
271
-            );
272
-            if ($req_data === null) {
273
-                $req_data = array_merge($_GET, $_POST);
274
-            }
275
-            $req_data = apply_filters(
276
-                'FHEE__EE_Form_Section_Proper__receive_form_submission__request_data',
277
-                $req_data,
278
-                $this
279
-            );
280
-            $this->cached_request_data = (array)$req_data;
281
-        }
282
-        return $this->cached_request_data;
283
-    }
284
-
285
-
286
-    /**
287
-     * After the form section is initially created, call this to sanitize the data in the submission
288
-     * which relates to this form section, validate it, and set it as properties on the form.
289
-     *
290
-     * @param array|null $req_data should usually be $_POST (the default).
291
-     *                             However, you CAN supply a different array.
292
-     *                             Consider using set_defaults() instead however.
293
-     *                             (If you rendered the form in the page using echo $form_x->get_html()
294
-     *                             the inputs will have the correct name in the request data for this function
295
-     *                             to find them and populate the form with them.
296
-     *                             If you have a flat form (with only input subsections),
297
-     *                             you can supply a flat array where keys
298
-     *                             are the form input names and values are their values)
299
-     * @param boolean    $validate whether or not to perform validation on this data. Default is,
300
-     *                             of course, to validate that data, and set errors on the invalid values.
301
-     *                             But if the data has already been validated
302
-     *                             (eg you validated the data then stored it in the DB)
303
-     *                             you may want to skip this step.
304
-     * @throws InvalidArgumentException
305
-     * @throws InvalidInterfaceException
306
-     * @throws InvalidDataTypeException
307
-     * @throws EE_Error
308
-     */
309
-    public function receive_form_submission($req_data = null, $validate = true)
310
-    {
311
-        $req_data = $this->getCachedRequest($req_data);
312
-        $this->_normalize($req_data);
313
-        if ($validate) {
314
-            $this->_validate();
315
-            //if it's invalid, we're going to want to re-display so remember what they submitted
316
-            if (! $this->is_valid()) {
317
-                $this->store_submitted_form_data_in_session();
318
-            }
319
-        }
320
-        if ($this->submission_error_message() === '' && ! $this->is_valid()) {
321
-            $this->set_submission_error_message();
322
-        }
323
-        do_action(
324
-            'AHEE__EE_Form_Section_Proper__receive_form_submission__end',
325
-            $req_data,
326
-            $this,
327
-            $validate
328
-        );
329
-    }
330
-
331
-
332
-    /**
333
-     * caches the originally submitted input values in the session
334
-     * so that they can be used to repopulate the form if it failed validation
335
-     *
336
-     * @return boolean whether or not the data was successfully stored in the session
337
-     * @throws InvalidArgumentException
338
-     * @throws InvalidInterfaceException
339
-     * @throws InvalidDataTypeException
340
-     * @throws EE_Error
341
-     */
342
-    protected function store_submitted_form_data_in_session()
343
-    {
344
-        return EE_Registry::instance()->SSN->set_session_data(
345
-            array(
346
-                EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY => $this->submitted_values(true),
347
-            )
348
-        );
349
-    }
350
-
351
-
352
-    /**
353
-     * retrieves the originally submitted input values in the session
354
-     * so that they can be used to repopulate the form if it failed validation
355
-     *
356
-     * @return array
357
-     * @throws InvalidArgumentException
358
-     * @throws InvalidInterfaceException
359
-     * @throws InvalidDataTypeException
360
-     */
361
-    protected function get_submitted_form_data_from_session()
362
-    {
363
-        $session = EE_Registry::instance()->SSN;
364
-        if ($session instanceof EE_Session) {
365
-            return $session->get_session_data(
366
-                EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY
367
-            );
368
-        }
369
-        return array();
370
-    }
371
-
372
-
373
-    /**
374
-     * flushed the originally submitted input values from the session
375
-     *
376
-     * @return boolean whether or not the data was successfully removed from the session
377
-     * @throws InvalidArgumentException
378
-     * @throws InvalidInterfaceException
379
-     * @throws InvalidDataTypeException
380
-     */
381
-    protected function flush_submitted_form_data_from_session()
382
-    {
383
-        return EE_Registry::instance()->SSN->reset_data(
384
-            array(EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY)
385
-        );
386
-    }
387
-
388
-
389
-    /**
390
-     * Populates this form and its subsections with data from the session.
391
-     * (Wrapper for EE_Form_Section_Proper::receive_form_submission, so it shows
392
-     * validation errors when displaying too)
393
-     * Returns true if the form was populated from the session, false otherwise
394
-     *
395
-     * @return boolean
396
-     * @throws InvalidArgumentException
397
-     * @throws InvalidInterfaceException
398
-     * @throws InvalidDataTypeException
399
-     * @throws EE_Error
400
-     */
401
-    public function populate_from_session()
402
-    {
403
-        $form_data_in_session = $this->get_submitted_form_data_from_session();
404
-        if (empty($form_data_in_session)) {
405
-            return false;
406
-        }
407
-        $this->receive_form_submission($form_data_in_session);
408
-        $this->flush_submitted_form_data_from_session();
409
-        if ($this->form_data_present_in($form_data_in_session)) {
410
-            return true;
411
-        }
412
-        return false;
413
-    }
414
-
415
-
416
-    /**
417
-     * Populates the default data for the form, given an array where keys are
418
-     * the input names, and values are their values (preferably normalized to be their
419
-     * proper PHP types, not all strings... although that should be ok too).
420
-     * Proper subsections are sub-arrays, the key being the subsection's name, and
421
-     * the value being an array formatted in teh same way
422
-     *
423
-     * @param array $default_data
424
-     * @throws EE_Error
425
-     */
426
-    public function populate_defaults($default_data)
427
-    {
428
-        foreach ($this->subsections(false) as $subsection_name => $subsection) {
429
-            if (isset($default_data[ $subsection_name ])) {
430
-                if ($subsection instanceof EE_Form_Input_Base) {
431
-                    $subsection->set_default($default_data[ $subsection_name ]);
432
-                } elseif ($subsection instanceof EE_Form_Section_Proper) {
433
-                    $subsection->populate_defaults($default_data[ $subsection_name ]);
434
-                }
435
-            }
436
-        }
437
-    }
438
-
439
-
440
-    /**
441
-     * returns true if subsection exists
442
-     *
443
-     * @param string $name
444
-     * @return boolean
445
-     */
446
-    public function subsection_exists($name)
447
-    {
448
-        return isset($this->_subsections[ $name ]) ? true : false;
449
-    }
450
-
451
-
452
-    /**
453
-     * Gets the subsection specified by its name
454
-     *
455
-     * @param string  $name
456
-     * @param boolean $require_construction_to_be_finalized most client code should leave this as TRUE
457
-     *                                                      so that the inputs will be properly configured.
458
-     *                                                      However, some client code may be ok
459
-     *                                                      with construction finalize being called later
460
-     *                                                      (realizing that the subsections' html names
461
-     *                                                      might not be set yet, etc.)
462
-     * @return EE_Form_Section_Base
463
-     * @throws EE_Error
464
-     */
465
-    public function get_subsection($name, $require_construction_to_be_finalized = true)
466
-    {
467
-        if ($require_construction_to_be_finalized) {
468
-            $this->ensure_construct_finalized_called();
469
-        }
470
-        return $this->subsection_exists($name) ? $this->_subsections[ $name ] : null;
471
-    }
472
-
473
-
474
-    /**
475
-     * Gets all the validatable subsections of this form section
476
-     *
477
-     * @return EE_Form_Section_Validatable[]
478
-     * @throws EE_Error
479
-     */
480
-    public function get_validatable_subsections()
481
-    {
482
-        $validatable_subsections = array();
483
-        foreach ($this->subsections() as $name => $obj) {
484
-            if ($obj instanceof EE_Form_Section_Validatable) {
485
-                $validatable_subsections[ $name ] = $obj;
486
-            }
487
-        }
488
-        return $validatable_subsections;
489
-    }
490
-
491
-
492
-    /**
493
-     * Gets an input by the given name. If not found, or if its not an EE_FOrm_Input_Base child,
494
-     * throw an EE_Error.
495
-     *
496
-     * @param string  $name
497
-     * @param boolean $require_construction_to_be_finalized most client code should
498
-     *                                                      leave this as TRUE so that the inputs will be properly
499
-     *                                                      configured. However, some client code may be ok with
500
-     *                                                      construction finalize being called later
501
-     *                                                      (realizing that the subsections' html names might not be
502
-     *                                                      set yet, etc.)
503
-     * @return EE_Form_Input_Base
504
-     * @throws EE_Error
505
-     */
506
-    public function get_input($name, $require_construction_to_be_finalized = true)
507
-    {
508
-        $subsection = $this->get_subsection(
509
-            $name,
510
-            $require_construction_to_be_finalized
511
-        );
512
-        if (! $subsection instanceof EE_Form_Input_Base) {
513
-            throw new EE_Error(
514
-                sprintf(
515
-                    esc_html__(
516
-                        "Subsection '%s' is not an instanceof EE_Form_Input_Base on form '%s'. It is a '%s'",
517
-                        'event_espresso'
518
-                    ),
519
-                    $name,
520
-                    get_class($this),
521
-                    $subsection ? get_class($subsection) : esc_html__('NULL', 'event_espresso')
522
-                )
523
-            );
524
-        }
525
-        return $subsection;
526
-    }
527
-
528
-
529
-    /**
530
-     * Like get_input(), gets the proper subsection of the form given the name,
531
-     * otherwise throws an EE_Error
532
-     *
533
-     * @param string  $name
534
-     * @param boolean $require_construction_to_be_finalized most client code should
535
-     *                                                      leave this as TRUE so that the inputs will be properly
536
-     *                                                      configured. However, some client code may be ok with
537
-     *                                                      construction finalize being called later
538
-     *                                                      (realizing that the subsections' html names might not be
539
-     *                                                      set yet, etc.)
540
-     * @return EE_Form_Section_Proper
541
-     * @throws EE_Error
542
-     */
543
-    public function get_proper_subsection($name, $require_construction_to_be_finalized = true)
544
-    {
545
-        $subsection = $this->get_subsection(
546
-            $name,
547
-            $require_construction_to_be_finalized
548
-        );
549
-        if (! $subsection instanceof EE_Form_Section_Proper) {
550
-            throw new EE_Error(
551
-                sprintf(
552
-                    esc_html__(
553
-                        "Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'",
554
-                        'event_espresso'
555
-                    ),
556
-                    $name,
557
-                    get_class($this)
558
-                )
559
-            );
560
-        }
561
-        return $subsection;
562
-    }
563
-
564
-
565
-    /**
566
-     * Gets the value of the specified input. Should be called after receive_form_submission()
567
-     * or populate_defaults() on the form, where the normalized value on the input is set.
568
-     *
569
-     * @param string $name
570
-     * @return mixed depending on the input's type and its normalization strategy
571
-     * @throws EE_Error
572
-     */
573
-    public function get_input_value($name)
574
-    {
575
-        $input = $this->get_input($name);
576
-        return $input->normalized_value();
577
-    }
578
-
579
-
580
-    /**
581
-     * Checks if this form section itself is valid, and then checks its subsections
582
-     *
583
-     * @throws EE_Error
584
-     * @return boolean
585
-     */
586
-    public function is_valid()
587
-    {
588
-        if($this->is_valid === null) {
589
-            if (! $this->has_received_submission()) {
590
-                throw new EE_Error(
591
-                    sprintf(
592
-                        esc_html__(
593
-                            'You cannot check if a form is valid before receiving the form submission using receive_form_submission',
594
-                            'event_espresso'
595
-                        )
596
-                    )
597
-                );
598
-            }
599
-            if (! parent::is_valid()) {
600
-                $this->is_valid = false;
601
-            } else {
602
-                // ok so no general errors to this entire form section.
603
-                // so let's check the subsections, but only set errors if that hasn't been done yet
604
-                $this->is_valid = true;
605
-                foreach ($this->get_validatable_subsections() as $subsection) {
606
-                    if (! $subsection->is_valid()) {
607
-                        $this->is_valid = false;
608
-                    }
609
-                }
610
-            }
611
-        }
612
-        return $this->is_valid;
613
-    }
614
-
615
-
616
-    /**
617
-     * gets the default name of this form section if none is specified
618
-     *
619
-     * @return void
620
-     */
621
-    protected function _set_default_name_if_empty()
622
-    {
623
-        if (! $this->_name) {
624
-            $classname    = get_class($this);
625
-            $default_name = str_replace('EE_', '', $classname);
626
-            $this->_name  = $default_name;
627
-        }
628
-    }
629
-
630
-
631
-    /**
632
-     * Returns the HTML for the form, except for the form opening and closing tags
633
-     * (as the form section doesn't know where you necessarily want to send the information to),
634
-     * and except for a submit button. Enqueues JS and CSS; if called early enough we will
635
-     * try to enqueue them in the header, otherwise they'll be enqueued in the footer.
636
-     * Not doing_it_wrong because theoretically this CAN be used properly,
637
-     * provided its used during "wp_enqueue_scripts", or it doesn't need to enqueue
638
-     * any CSS.
639
-     *
640
-     * @throws InvalidArgumentException
641
-     * @throws InvalidInterfaceException
642
-     * @throws InvalidDataTypeException
643
-     * @throws EE_Error
644
-     */
645
-    public function get_html_and_js()
646
-    {
647
-        $this->enqueue_js();
648
-        return $this->get_html();
649
-    }
650
-
651
-
652
-    /**
653
-     * returns HTML for displaying this form section. recursively calls display_section() on all subsections
654
-     *
655
-     * @param bool $display_previously_submitted_data
656
-     * @return string
657
-     * @throws InvalidArgumentException
658
-     * @throws InvalidInterfaceException
659
-     * @throws InvalidDataTypeException
660
-     * @throws EE_Error
661
-     * @throws EE_Error
662
-     * @throws EE_Error
663
-     */
664
-    public function get_html($display_previously_submitted_data = true)
665
-    {
666
-        $this->ensure_construct_finalized_called();
667
-        if ($display_previously_submitted_data) {
668
-            $this->populate_from_session();
669
-        }
670
-        return $this->_form_html_filter
671
-            ? $this->_form_html_filter->filterHtml($this->_layout_strategy->layout_form(), $this)
672
-            : $this->_layout_strategy->layout_form();
673
-    }
674
-
675
-
676
-    /**
677
-     * enqueues JS and CSS for the form.
678
-     * It is preferred to call this before wp_enqueue_scripts so the
679
-     * scripts and styles can be put in the header, but if called later
680
-     * they will be put in the footer (which is OK for JS, but in HTML4 CSS should
681
-     * only be in the header; but in HTML5 its ok in the body.
682
-     * See http://stackoverflow.com/questions/4957446/load-external-css-file-in-body-tag.
683
-     * So if your form enqueues CSS, it's preferred to call this before wp_enqueue_scripts.)
684
-     *
685
-     * @return void
686
-     * @throws EE_Error
687
-     */
688
-    public function enqueue_js()
689
-    {
690
-        $this->_enqueue_and_localize_form_js();
691
-        foreach ($this->subsections() as $subsection) {
692
-            $subsection->enqueue_js();
693
-        }
694
-    }
695
-
696
-
697
-    /**
698
-     * adds a filter so that jquery validate gets enqueued in EE_System::wp_enqueue_scripts().
699
-     * This must be done BEFORE wp_enqueue_scripts() gets called, which is on
700
-     * the wp_enqueue_scripts hook.
701
-     * However, registering the form js and localizing it can happen when we
702
-     * actually output the form (which is preferred, seeing how teh form's fields
703
-     * could change until it's actually outputted)
704
-     *
705
-     * @param boolean $init_form_validation_automatically whether or not we want the form validation
706
-     *                                                    to be triggered automatically or not
707
-     * @return void
708
-     */
709
-    public static function wp_enqueue_scripts($init_form_validation_automatically = true)
710
-    {
711
-        wp_register_script(
712
-            'ee_form_section_validation',
713
-            EE_GLOBAL_ASSETS_URL . 'scripts' . DS . 'form_section_validation.js',
714
-            array('jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods'),
715
-            EVENT_ESPRESSO_VERSION,
716
-            true
717
-        );
718
-        wp_localize_script(
719
-            'ee_form_section_validation',
720
-            'ee_form_section_validation_init',
721
-            array('init' => $init_form_validation_automatically ? '1' : '0')
722
-        );
723
-    }
724
-
725
-
726
-    /**
727
-     * gets the variables used by form_section_validation.js.
728
-     * This needs to be called AFTER we've called $this->_enqueue_jquery_validate_script,
729
-     * but before the wordpress hook wp_loaded
730
-     *
731
-     * @throws EE_Error
732
-     */
733
-    public function _enqueue_and_localize_form_js()
734
-    {
735
-        $this->ensure_construct_finalized_called();
736
-        //actually, we don't want to localize just yet. There may be other forms on the page.
737
-        //so we need to add our form section data to a static variable accessible by all form sections
738
-        //and localize it just before the footer
739
-        $this->localize_validation_rules();
740
-        add_action('wp_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'), 2);
741
-        add_action('admin_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'));
742
-    }
743
-
744
-
745
-    /**
746
-     * add our form section data to a static variable accessible by all form sections
747
-     *
748
-     * @param bool $return_for_subsection
749
-     * @return void
750
-     * @throws EE_Error
751
-     */
752
-    public function localize_validation_rules($return_for_subsection = false)
753
-    {
754
-        // we only want to localize vars ONCE for the entire form,
755
-        // so if the form section doesn't have a parent, then it must be the top dog
756
-        if ($return_for_subsection || ! $this->parent_section()) {
757
-            EE_Form_Section_Proper::$_js_localization['form_data'][ $this->html_id() ] = array(
758
-                'form_section_id'  => $this->html_id(true),
759
-                'validation_rules' => $this->get_jquery_validation_rules(),
760
-                'other_data'       => $this->get_other_js_data(),
761
-                'errors'           => $this->subsection_validation_errors_by_html_name(),
762
-            );
763
-            EE_Form_Section_Proper::$_scripts_localized                                = true;
764
-        }
765
-    }
766
-
767
-
768
-    /**
769
-     * Gets an array of extra data that will be useful for client-side javascript.
770
-     * This is primarily data added by inputs and forms in addition to any
771
-     * scripts they might enqueue
772
-     *
773
-     * @param array $form_other_js_data
774
-     * @return array
775
-     * @throws EE_Error
776
-     */
777
-    public function get_other_js_data($form_other_js_data = array())
778
-    {
779
-        foreach ($this->subsections() as $subsection) {
780
-            $form_other_js_data = $subsection->get_other_js_data($form_other_js_data);
781
-        }
782
-        return $form_other_js_data;
783
-    }
784
-
785
-
786
-    /**
787
-     * Gets a flat array of inputs for this form section and its subsections.
788
-     * Keys are their form names, and values are the inputs themselves
789
-     *
790
-     * @return EE_Form_Input_Base
791
-     * @throws EE_Error
792
-     */
793
-    public function inputs_in_subsections()
794
-    {
795
-        $inputs = array();
796
-        foreach ($this->subsections() as $subsection) {
797
-            if ($subsection instanceof EE_Form_Input_Base) {
798
-                $inputs[ $subsection->html_name() ] = $subsection;
799
-            } elseif ($subsection instanceof EE_Form_Section_Proper) {
800
-                $inputs += $subsection->inputs_in_subsections();
801
-            }
802
-        }
803
-        return $inputs;
804
-    }
805
-
806
-
807
-    /**
808
-     * Gets a flat array of all the validation errors.
809
-     * Keys are html names (because those should be unique)
810
-     * and values are a string of all their validation errors
811
-     *
812
-     * @return string[]
813
-     * @throws EE_Error
814
-     */
815
-    public function subsection_validation_errors_by_html_name()
816
-    {
817
-        $inputs = $this->inputs();
818
-        $errors = array();
819
-        foreach ($inputs as $form_input) {
820
-            if ($form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors()) {
821
-                $errors[ $form_input->html_name() ] = $form_input->get_validation_error_string();
822
-            }
823
-        }
824
-        return $errors;
825
-    }
826
-
827
-
828
-    /**
829
-     * passes all the form data required by the JS to the JS, and enqueues the few required JS files.
830
-     * Should be setup by each form during the _enqueues_and_localize_form_js
831
-     *
832
-     * @throws InvalidArgumentException
833
-     * @throws InvalidInterfaceException
834
-     * @throws InvalidDataTypeException
835
-     */
836
-    public static function localize_script_for_all_forms()
837
-    {
838
-        //allow inputs and stuff to hook in their JS and stuff here
839
-        do_action('AHEE__EE_Form_Section_Proper__localize_script_for_all_forms__begin');
840
-        EE_Form_Section_Proper::$_js_localization['localized_error_messages'] = EE_Form_Section_Proper::_get_localized_error_messages();
841
-        $email_validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level)
842
-            ? EE_Registry::instance()->CFG->registration->email_validation_level
843
-            : 'wp_default';
844
-        EE_Form_Section_Proper::$_js_localization['email_validation_level']   = $email_validation_level;
845
-        wp_enqueue_script('ee_form_section_validation');
846
-        wp_localize_script(
847
-            'ee_form_section_validation',
848
-            'ee_form_section_vars',
849
-            EE_Form_Section_Proper::$_js_localization
850
-        );
851
-    }
852
-
853
-
854
-    /**
855
-     * ensure_scripts_localized
856
-     *
857
-     * @throws EE_Error
858
-     */
859
-    public function ensure_scripts_localized()
860
-    {
861
-        if (! EE_Form_Section_Proper::$_scripts_localized) {
862
-            $this->_enqueue_and_localize_form_js();
863
-        }
864
-    }
865
-
866
-
867
-    /**
868
-     * Gets the hard-coded validation error messages to be used in the JS. The convention
869
-     * is that the key here should be the same as the custom validation rule put in the JS file
870
-     *
871
-     * @return array keys are custom validation rules, and values are internationalized strings
872
-     */
873
-    private static function _get_localized_error_messages()
874
-    {
875
-        return array(
876
-            'validUrl' => esc_html__('This is not a valid absolute URL. Eg, http://domain.com/monkey.jpg', 'event_espresso'),
877
-            'regex'    => esc_html__('Please check your input', 'event_espresso'),
878
-        );
879
-    }
880
-
881
-
882
-    /**
883
-     * @return array
884
-     */
885
-    public static function js_localization()
886
-    {
887
-        return self::$_js_localization;
888
-    }
889
-
890
-
891
-    /**
892
-     * @return void
893
-     */
894
-    public static function reset_js_localization()
895
-    {
896
-        self::$_js_localization = array();
897
-    }
898
-
899
-
900
-    /**
901
-     * Gets the JS to put inside the jquery validation rules for subsection of this form section.
902
-     * See parent function for more...
903
-     *
904
-     * @return array
905
-     * @throws EE_Error
906
-     */
907
-    public function get_jquery_validation_rules()
908
-    {
909
-        $jquery_validation_rules = array();
910
-        foreach ($this->get_validatable_subsections() as $subsection) {
911
-            $jquery_validation_rules = array_merge(
912
-                $jquery_validation_rules,
913
-                $subsection->get_jquery_validation_rules()
914
-            );
915
-        }
916
-        return $jquery_validation_rules;
917
-    }
918
-
919
-
920
-    /**
921
-     * Sanitizes all the data and sets the sanitized value of each field
922
-     *
923
-     * @param array $req_data like $_POST
924
-     * @return void
925
-     * @throws EE_Error
926
-     */
927
-    protected function _normalize($req_data)
928
-    {
929
-        $this->_received_submission = true;
930
-        $this->_validation_errors   = array();
931
-        foreach ($this->get_validatable_subsections() as $subsection) {
932
-            try {
933
-                $subsection->_normalize($req_data);
934
-            } catch (EE_Validation_Error $e) {
935
-                $subsection->add_validation_error($e);
936
-            }
937
-        }
938
-    }
939
-
940
-
941
-    /**
942
-     * Performs validation on this form section and its subsections.
943
-     * For each subsection,
944
-     * calls _validate_{subsection_name} on THIS form (if the function exists)
945
-     * and passes it the subsection, then calls _validate on that subsection.
946
-     * If you need to perform validation on the form as a whole (considering multiple)
947
-     * you would be best to override this _validate method,
948
-     * calling parent::_validate() first.
949
-     *
950
-     * @throws EE_Error
951
-     */
952
-    protected function _validate()
953
-    {
954
-        //reset the cache of whether this form is valid or not- we're re-validating it now
955
-        $this->is_valid = null;
956
-        foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) {
957
-            if (method_exists($this, '_validate_' . $subsection_name)) {
958
-                call_user_func_array(array($this, '_validate_' . $subsection_name), array($subsection));
959
-            }
960
-            $subsection->_validate();
961
-        }
962
-    }
963
-
964
-
965
-    /**
966
-     * Gets all the validated inputs for the form section
967
-     *
968
-     * @return array
969
-     * @throws EE_Error
970
-     */
971
-    public function valid_data()
972
-    {
973
-        $inputs = array();
974
-        foreach ($this->subsections() as $subsection_name => $subsection) {
975
-            if ($subsection instanceof EE_Form_Section_Proper) {
976
-                $inputs[ $subsection_name ] = $subsection->valid_data();
977
-            } elseif ($subsection instanceof EE_Form_Input_Base) {
978
-                $inputs[ $subsection_name ] = $subsection->normalized_value();
979
-            }
980
-        }
981
-        return $inputs;
982
-    }
983
-
984
-
985
-    /**
986
-     * Gets all the inputs on this form section
987
-     *
988
-     * @return EE_Form_Input_Base[]
989
-     * @throws EE_Error
990
-     */
991
-    public function inputs()
992
-    {
993
-        $inputs = array();
994
-        foreach ($this->subsections() as $subsection_name => $subsection) {
995
-            if ($subsection instanceof EE_Form_Input_Base) {
996
-                $inputs[ $subsection_name ] = $subsection;
997
-            }
998
-        }
999
-        return $inputs;
1000
-    }
1001
-
1002
-
1003
-    /**
1004
-     * Gets all the subsections which are a proper form
1005
-     *
1006
-     * @return EE_Form_Section_Proper[]
1007
-     * @throws EE_Error
1008
-     */
1009
-    public function subforms()
1010
-    {
1011
-        $form_sections = array();
1012
-        foreach ($this->subsections() as $name => $obj) {
1013
-            if ($obj instanceof EE_Form_Section_Proper) {
1014
-                $form_sections[ $name ] = $obj;
1015
-            }
1016
-        }
1017
-        return $form_sections;
1018
-    }
1019
-
1020
-
1021
-    /**
1022
-     * Gets all the subsections (inputs, proper subsections, or html-only sections).
1023
-     * Consider using inputs() or subforms()
1024
-     * if you only want form inputs or proper form sections.
1025
-     *
1026
-     * @param boolean $require_construction_to_be_finalized most client code should
1027
-     *                                                      leave this as TRUE so that the inputs will be properly
1028
-     *                                                      configured. However, some client code may be ok with
1029
-     *                                                      construction finalize being called later
1030
-     *                                                      (realizing that the subsections' html names might not be
1031
-     *                                                      set yet, etc.)
1032
-     * @return EE_Form_Section_Proper[]
1033
-     * @throws EE_Error
1034
-     */
1035
-    public function subsections($require_construction_to_be_finalized = true)
1036
-    {
1037
-        if ($require_construction_to_be_finalized) {
1038
-            $this->ensure_construct_finalized_called();
1039
-        }
1040
-        return $this->_subsections;
1041
-    }
1042
-
1043
-
1044
-    /**
1045
-     * Returns whether this form has any subforms or inputs
1046
-     * @return bool
1047
-     */
1048
-    public function hasSubsections()
1049
-    {
1050
-        return ! empty($this->_subsections);
1051
-    }
1052
-
1053
-
1054
-    /**
1055
-     * Returns a simple array where keys are input names, and values are their normalized
1056
-     * values. (Similar to calling get_input_value on inputs)
1057
-     *
1058
-     * @param boolean $include_subform_inputs Whether to include inputs from subforms,
1059
-     *                                        or just this forms' direct children inputs
1060
-     * @param boolean $flatten                Whether to force the results into 1-dimensional array,
1061
-     *                                        or allow multidimensional array
1062
-     * @return array if $flatten is TRUE it will always be a 1-dimensional array
1063
-     *                                        with array keys being input names
1064
-     *                                        (regardless of whether they are from a subsection or not),
1065
-     *                                        and if $flatten is FALSE it can be a multidimensional array
1066
-     *                                        where keys are always subsection names and values are either
1067
-     *                                        the input's normalized value, or an array like the top-level array
1068
-     * @throws EE_Error
1069
-     */
1070
-    public function input_values($include_subform_inputs = false, $flatten = false)
1071
-    {
1072
-        return $this->_input_values(false, $include_subform_inputs, $flatten);
1073
-    }
1074
-
1075
-
1076
-    /**
1077
-     * Similar to EE_Form_Section_Proper::input_values(), except this returns the 'display_value'
1078
-     * of each input. On some inputs (especially radio boxes or checkboxes), the value stored
1079
-     * is not necessarily the value we want to display to users. This creates an array
1080
-     * where keys are the input names, and values are their display values
1081
-     *
1082
-     * @param boolean $include_subform_inputs Whether to include inputs from subforms,
1083
-     *                                        or just this forms' direct children inputs
1084
-     * @param boolean $flatten                Whether to force the results into 1-dimensional array,
1085
-     *                                        or allow multidimensional array
1086
-     * @return array if $flatten is TRUE it will always be a 1-dimensional array
1087
-     *                                        with array keys being input names
1088
-     *                                        (regardless of whether they are from a subsection or not),
1089
-     *                                        and if $flatten is FALSE it can be a multidimensional array
1090
-     *                                        where keys are always subsection names and values are either
1091
-     *                                        the input's normalized value, or an array like the top-level array
1092
-     * @throws EE_Error
1093
-     */
1094
-    public function input_pretty_values($include_subform_inputs = false, $flatten = false)
1095
-    {
1096
-        return $this->_input_values(true, $include_subform_inputs, $flatten);
1097
-    }
1098
-
1099
-
1100
-    /**
1101
-     * Gets the input values from the form
1102
-     *
1103
-     * @param boolean $pretty                 Whether to retrieve the pretty value,
1104
-     *                                        or just the normalized value
1105
-     * @param boolean $include_subform_inputs Whether to include inputs from subforms,
1106
-     *                                        or just this forms' direct children inputs
1107
-     * @param boolean $flatten                Whether to force the results into 1-dimensional array,
1108
-     *                                        or allow multidimensional array
1109
-     * @return array if $flatten is TRUE it will always be a 1-dimensional array with array keys being
1110
-     *                                        input names (regardless of whether they are from a subsection or not),
1111
-     *                                        and if $flatten is FALSE it can be a multidimensional array
1112
-     *                                        where keys are always subsection names and values are either
1113
-     *                                        the input's normalized value, or an array like the top-level array
1114
-     * @throws EE_Error
1115
-     */
1116
-    public function _input_values($pretty = false, $include_subform_inputs = false, $flatten = false)
1117
-    {
1118
-        $input_values = array();
1119
-        foreach ($this->subsections() as $subsection_name => $subsection) {
1120
-            if ($subsection instanceof EE_Form_Input_Base) {
1121
-                $input_values[ $subsection_name ] = $pretty
1122
-                    ? $subsection->pretty_value()
1123
-                    : $subsection->normalized_value();
1124
-            } elseif ($subsection instanceof EE_Form_Section_Proper && $include_subform_inputs) {
1125
-                $subform_input_values = $subsection->_input_values(
1126
-                    $pretty,
1127
-                    $include_subform_inputs,
1128
-                    $flatten
1129
-                );
1130
-                if ($flatten) {
1131
-                    $input_values = array_merge($input_values, $subform_input_values);
1132
-                } else {
1133
-                    $input_values[ $subsection_name ] = $subform_input_values;
1134
-                }
1135
-            }
1136
-        }
1137
-        return $input_values;
1138
-    }
1139
-
1140
-
1141
-    /**
1142
-     * Gets the originally submitted input values from the form
1143
-     *
1144
-     * @param boolean $include_subforms  Whether to include inputs from subforms,
1145
-     *                                   or just this forms' direct children inputs
1146
-     * @return array                     if $flatten is TRUE it will always be a 1-dimensional array
1147
-     *                                   with array keys being input names
1148
-     *                                   (regardless of whether they are from a subsection or not),
1149
-     *                                   and if $flatten is FALSE it can be a multidimensional array
1150
-     *                                   where keys are always subsection names and values are either
1151
-     *                                   the input's normalized value, or an array like the top-level array
1152
-     * @throws EE_Error
1153
-     */
1154
-    public function submitted_values($include_subforms = false)
1155
-    {
1156
-        $submitted_values = array();
1157
-        foreach ($this->subsections() as $subsection) {
1158
-            if ($subsection instanceof EE_Form_Input_Base) {
1159
-                // is this input part of an array of inputs?
1160
-                if (strpos($subsection->html_name(), '[') !== false) {
1161
-                    $full_input_name  = EEH_Array::convert_array_values_to_keys(
1162
-                        explode(
1163
-                            '[',
1164
-                            str_replace(']', '', $subsection->html_name())
1165
-                        ),
1166
-                        $subsection->raw_value()
1167
-                    );
1168
-                    $submitted_values = array_replace_recursive($submitted_values, $full_input_name);
1169
-                } else {
1170
-                    $submitted_values[ $subsection->html_name() ] = $subsection->raw_value();
1171
-                }
1172
-            } elseif ($subsection instanceof EE_Form_Section_Proper && $include_subforms) {
1173
-                $subform_input_values = $subsection->submitted_values($include_subforms);
1174
-                $submitted_values     = array_replace_recursive($submitted_values, $subform_input_values);
1175
-            }
1176
-        }
1177
-        return $submitted_values;
1178
-    }
1179
-
1180
-
1181
-    /**
1182
-     * Indicates whether or not this form has received a submission yet
1183
-     * (ie, had receive_form_submission called on it yet)
1184
-     *
1185
-     * @return boolean
1186
-     * @throws EE_Error
1187
-     */
1188
-    public function has_received_submission()
1189
-    {
1190
-        $this->ensure_construct_finalized_called();
1191
-        return $this->_received_submission;
1192
-    }
1193
-
1194
-
1195
-    /**
1196
-     * Equivalent to passing 'exclude' in the constructor's options array.
1197
-     * Removes the listed inputs from the form
1198
-     *
1199
-     * @param array $inputs_to_exclude values are the input names
1200
-     * @return void
1201
-     */
1202
-    public function exclude(array $inputs_to_exclude = array())
1203
-    {
1204
-        foreach ($inputs_to_exclude as $input_to_exclude_name) {
1205
-            unset($this->_subsections[ $input_to_exclude_name ]);
1206
-        }
1207
-    }
1208
-
1209
-
1210
-    /**
1211
-     * Changes these inputs' display strategy to be EE_Hidden_Display_Strategy.
1212
-     * @param array $inputs_to_hide
1213
-     * @throws EE_Error
1214
-     */
1215
-    public function hide(array $inputs_to_hide = array())
1216
-    {
1217
-        foreach ($inputs_to_hide as $input_to_hide) {
1218
-            $input = $this->get_input($input_to_hide);
1219
-            $input->set_display_strategy(new EE_Hidden_Display_Strategy());
1220
-        }
1221
-    }
1222
-
1223
-
1224
-    /**
1225
-     * add_subsections
1226
-     * Adds the listed subsections to the form section.
1227
-     * If $subsection_name_to_target is provided,
1228
-     * then new subsections are added before or after that subsection,
1229
-     * otherwise to the start or end of the entire subsections array.
1230
-     *
1231
-     * @param EE_Form_Section_Base[] $new_subsections           array of new form subsections
1232
-     *                                                          where keys are their names
1233
-     * @param string                 $subsection_name_to_target an existing for section that $new_subsections
1234
-     *                                                          should be added before or after
1235
-     *                                                          IF $subsection_name_to_target is null,
1236
-     *                                                          then $new_subsections will be added to
1237
-     *                                                          the beginning or end of the entire subsections array
1238
-     * @param boolean                $add_before                whether to add $new_subsections, before or after
1239
-     *                                                          $subsection_name_to_target,
1240
-     *                                                          or if $subsection_name_to_target is null,
1241
-     *                                                          before or after entire subsections array
1242
-     * @return void
1243
-     * @throws EE_Error
1244
-     */
1245
-    public function add_subsections($new_subsections, $subsection_name_to_target = null, $add_before = true)
1246
-    {
1247
-        foreach ($new_subsections as $subsection_name => $subsection) {
1248
-            if (! $subsection instanceof EE_Form_Section_Base) {
1249
-                EE_Error::add_error(
1250
-                    sprintf(
1251
-                        esc_html__(
1252
-                            "Trying to add a %s as a subsection (it was named '%s') to the form section '%s'. It was removed.",
1253
-                            'event_espresso'
1254
-                        ),
1255
-                        get_class($subsection),
1256
-                        $subsection_name,
1257
-                        $this->name()
1258
-                    )
1259
-                );
1260
-                unset($new_subsections[ $subsection_name ]);
1261
-            }
1262
-        }
1263
-        $this->_subsections = EEH_Array::insert_into_array(
1264
-            $this->_subsections,
1265
-            $new_subsections,
1266
-            $subsection_name_to_target,
1267
-            $add_before
1268
-        );
1269
-        if ($this->_construction_finalized) {
1270
-            foreach ($this->_subsections as $name => $subsection) {
1271
-                $subsection->_construct_finalize($this, $name);
1272
-            }
1273
-        }
1274
-    }
1275
-
1276
-
1277
-    /**
1278
-     * @param string $subsection_name
1279
-     * @param bool   $recursive
1280
-     * @return bool
1281
-     */
1282
-    public function has_subsection($subsection_name, $recursive = false)
1283
-    {
1284
-        foreach ($this->_subsections as $name => $subsection) {if(
1285
-                $name === $subsection_name
1286
-                || (
1287
-                    $recursive
1288
-                    && $subsection instanceof EE_Form_Section_Proper
1289
-                    && $subsection->has_subsection($subsection_name, $recursive)
1290
-                )
1291
-            ) {
1292
-                return true;
1293
-            }
1294
-        }
1295
-        return false;
1296
-    }
1297
-
1298
-
1299
-
1300
-    /**
1301
-     * Just gets all validatable subsections to clean their sensitive data
1302
-     *
1303
-     * @throws EE_Error
1304
-     */
1305
-    public function clean_sensitive_data()
1306
-    {
1307
-        foreach ($this->get_validatable_subsections() as $subsection) {
1308
-            $subsection->clean_sensitive_data();
1309
-        }
1310
-    }
1311
-
1312
-
1313
-    /**
1314
-     * Sets the submission error message (aka validation error message for this form section and all sub-sections)
1315
-     * @param string                           $form_submission_error_message
1316
-     * @param EE_Form_Section_Validatable $form_section unused
1317
-     * @throws EE_Error
1318
-     */
1319
-    public function set_submission_error_message(
1320
-        $form_submission_error_message = ''
1321
-    ) {
1322
-        $this->_form_submission_error_message = ! empty($form_submission_error_message)
1323
-            ? $form_submission_error_message
1324
-            : $this->getAllValidationErrorsString();
1325
-    }
1326
-
1327
-
1328
-    /**
1329
-     * Returns the cached error message. A default value is set for this during _validate(),
1330
-     * (called during receive_form_submission) but it can be explicitly set using
1331
-     * set_submission_error_message
1332
-     *
1333
-     * @return string
1334
-     */
1335
-    public function submission_error_message()
1336
-    {
1337
-        return $this->_form_submission_error_message;
1338
-    }
1339
-
1340
-
1341
-    /**
1342
-     * Sets a message to display if the data submitted to the form was valid.
1343
-     * @param string $form_submission_success_message
1344
-     */
1345
-    public function set_submission_success_message($form_submission_success_message = '')
1346
-    {
1347
-        $this->_form_submission_success_message = ! empty($form_submission_success_message)
1348
-            ? $form_submission_success_message
1349
-            : esc_html__('Form submitted successfully', 'event_espresso');
1350
-    }
1351
-
1352
-
1353
-    /**
1354
-     * Gets a message appropriate for display when the form is correctly submitted
1355
-     * @return string
1356
-     */
1357
-    public function submission_success_message()
1358
-    {
1359
-        return $this->_form_submission_success_message;
1360
-    }
1361
-
1362
-
1363
-    /**
1364
-     * Returns the prefix that should be used on child of this form section for
1365
-     * their html names. If this form section itself has a parent, prepends ITS
1366
-     * prefix onto this form section's prefix. Used primarily by
1367
-     * EE_Form_Input_Base::_set_default_html_name_if_empty
1368
-     *
1369
-     * @return string
1370
-     * @throws EE_Error
1371
-     */
1372
-    public function html_name_prefix()
1373
-    {
1374
-        if ($this->parent_section() instanceof EE_Form_Section_Proper) {
1375
-            return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']';
1376
-        }
1377
-        return $this->name();
1378
-    }
1379
-
1380
-
1381
-    /**
1382
-     * Gets the name, but first checks _construct_finalize has been called. If not,
1383
-     * calls it (assumes there is no parent and that we want the name to be whatever
1384
-     * was set, which is probably nothing, or the classname)
1385
-     *
1386
-     * @return string
1387
-     * @throws EE_Error
1388
-     */
1389
-    public function name()
1390
-    {
1391
-        $this->ensure_construct_finalized_called();
1392
-        return parent::name();
1393
-    }
1394
-
1395
-
1396
-    /**
1397
-     * @return EE_Form_Section_Proper
1398
-     * @throws EE_Error
1399
-     */
1400
-    public function parent_section()
1401
-    {
1402
-        $this->ensure_construct_finalized_called();
1403
-        return parent::parent_section();
1404
-    }
1405
-
1406
-
1407
-    /**
1408
-     * make sure construction finalized was called, otherwise children might not be ready
1409
-     *
1410
-     * @return void
1411
-     * @throws EE_Error
1412
-     */
1413
-    public function ensure_construct_finalized_called()
1414
-    {
1415
-        if (! $this->_construction_finalized) {
1416
-            $this->_construct_finalize($this->_parent_section, $this->_name);
1417
-        }
1418
-    }
1419
-
1420
-
1421
-    /**
1422
-     * Checks if any of this form section's inputs, or any of its children's inputs,
1423
-     * are in teh form data. If any are found, returns true. Else false
1424
-     *
1425
-     * @param array $req_data
1426
-     * @return boolean
1427
-     * @throws EE_Error
1428
-     */
1429
-    public function form_data_present_in($req_data = null)
1430
-    {
1431
-        $req_data = $this->getCachedRequest($req_data);
1432
-        foreach ($this->subsections() as $subsection) {
1433
-            if ($subsection instanceof EE_Form_Input_Base) {
1434
-                if ($subsection->form_data_present_in($req_data)) {
1435
-                    return true;
1436
-                }
1437
-            } elseif ($subsection instanceof EE_Form_Section_Proper) {
1438
-                if ($subsection->form_data_present_in($req_data)) {
1439
-                    return true;
1440
-                }
1441
-            }
1442
-        }
1443
-        return false;
1444
-    }
1445
-
1446
-
1447
-    /**
1448
-     * Gets validation errors for this form section and subsections
1449
-     * Similar to EE_Form_Section_Validatable::get_validation_errors() except this
1450
-     * gets the validation errors for ALL subsection
1451
-     *
1452
-     * @return EE_Validation_Error[]
1453
-     * @throws EE_Error
1454
-     */
1455
-    public function get_validation_errors_accumulated()
1456
-    {
1457
-        $validation_errors = $this->get_validation_errors();
1458
-        foreach ($this->get_validatable_subsections() as $subsection) {
1459
-            if ($subsection instanceof EE_Form_Section_Proper) {
1460
-                $validation_errors_on_this_subsection = $subsection->get_validation_errors_accumulated();
1461
-            } else {
1462
-                $validation_errors_on_this_subsection = $subsection->get_validation_errors();
1463
-            }
1464
-            if ($validation_errors_on_this_subsection) {
1465
-                $validation_errors = array_merge($validation_errors, $validation_errors_on_this_subsection);
1466
-            }
1467
-        }
1468
-        return $validation_errors;
1469
-    }
1470
-
1471
-    /**
1472
-     * Fetch validation errors from children and grandchildren and puts them in a single string.
1473
-     * This traverses the form section tree to generate this, but you probably want to instead use
1474
-     * get_form_submission_error_message() which is usually this message cached (or a custom validation error message)
1475
-     *
1476
-     * @return string
1477
-     * @since $VID:$
1478
-     */
1479
-    protected function getAllValidationErrorsString()
1480
-    {
1481
-        $submission_error_messages = array();
1482
-        // bad, bad, bad registrant
1483
-        foreach ($this->get_validation_errors_accumulated() as $validation_error) {
1484
-            if ($validation_error instanceof EE_Validation_Error) {
1485
-                $form_section = $validation_error->get_form_section();
1486
-                if ($form_section instanceof EE_Form_Input_Base) {
1487
-                   $label = $validation_error->get_form_section()->html_label_text();
1488
-                } elseif($form_section instanceof EE_Form_Section_Validatable) {
1489
-                    $label = $validation_error->get_form_section()->name();
1490
-                } else {
1491
-                    $label = esc_html__('Unknown', 'event_espresso');
1492
-                }
1493
-                $submission_error_messages[] = sprintf(
1494
-                    __('%s : %s', 'event_espresso'),
1495
-                    $label,
1496
-                    $validation_error->getMessage()
1497
-                );
1498
-            }
1499
-        }
1500
-        return implode('<br', $submission_error_messages);
1501
-    }
1502
-
1503
-
1504
-    /**
1505
-     * This isn't just the name of an input, it's a path pointing to an input. The
1506
-     * path is similar to a folder path: slash (/) means to descend into a subsection,
1507
-     * dot-dot-slash (../) means to ascend into the parent section.
1508
-     * After a series of slashes and dot-dot-slashes, there should be the name of an input,
1509
-     * which will be returned.
1510
-     * Eg, if you want the related input to be conditional on a sibling input name 'foobar'
1511
-     * just use 'foobar'. If you want it to be conditional on an aunt/uncle input name
1512
-     * 'baz', use '../baz'. If you want it to be conditional on a cousin input,
1513
-     * the child of 'baz_section' named 'baz_child', use '../baz_section/baz_child'.
1514
-     * Etc
1515
-     *
1516
-     * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false
1517
-     * @return EE_Form_Section_Base
1518
-     * @throws EE_Error
1519
-     */
1520
-    public function find_section_from_path($form_section_path)
1521
-    {
1522
-        //check if we can find the input from purely going straight up the tree
1523
-        $input = parent::find_section_from_path($form_section_path);
1524
-        if ($input instanceof EE_Form_Section_Base) {
1525
-            return $input;
1526
-        }
1527
-        $next_slash_pos = strpos($form_section_path, '/');
1528
-        if ($next_slash_pos !== false) {
1529
-            $child_section_name = substr($form_section_path, 0, $next_slash_pos);
1530
-            $subpath            = substr($form_section_path, $next_slash_pos + 1);
1531
-        } else {
1532
-            $child_section_name = $form_section_path;
1533
-            $subpath            = '';
1534
-        }
1535
-        $child_section = $this->get_subsection($child_section_name);
1536
-        if ($child_section instanceof EE_Form_Section_Base) {
1537
-            return $child_section->find_section_from_path($subpath);
1538
-        }
1539
-        return null;
1540
-    }
17
+	const SUBMITTED_FORM_DATA_SSN_KEY = 'submitted_form_data';
18
+
19
+	/**
20
+	 * Subsections
21
+	 *
22
+	 * @var EE_Form_Section_Validatable[]
23
+	 */
24
+	protected $_subsections = array();
25
+
26
+	/**
27
+	 * Strategy for laying out the form
28
+	 *
29
+	 * @var EE_Form_Section_Layout_Base
30
+	 */
31
+	protected $_layout_strategy;
32
+
33
+	/**
34
+	 * Whether or not this form has received and validated a form submission yet
35
+	 *
36
+	 * @var boolean
37
+	 */
38
+	protected $_received_submission = false;
39
+
40
+	/**
41
+	 * message displayed to users upon successful form submission
42
+	 *
43
+	 * @var string
44
+	 */
45
+	protected $_form_submission_success_message = '';
46
+
47
+	/**
48
+	 * message displayed to users upon unsuccessful form submission
49
+	 *
50
+	 * @var string
51
+	 */
52
+	protected $_form_submission_error_message = '';
53
+
54
+	/**
55
+	 * @var array like $_REQUEST
56
+	 */
57
+	protected $cached_request_data;
58
+
59
+	/**
60
+	 * Stores whether this form (and its sub-sections) were found to be valid or not.
61
+	 * Starts off as null, but once the form is validated, it set to either true or false
62
+	 * @var boolean|null
63
+	 */
64
+	protected $is_valid;
65
+
66
+	/**
67
+	 * Stores all the data that will localized for form validation
68
+	 *
69
+	 * @var array
70
+	 */
71
+	static protected $_js_localization = array();
72
+
73
+	/**
74
+	 * whether or not the form's localized validation JS vars have been set
75
+	 *
76
+	 * @type boolean
77
+	 */
78
+	static protected $_scripts_localized = false;
79
+
80
+
81
+	/**
82
+	 * when constructing a proper form section, calls _construct_finalize on children
83
+	 * so that they know who their parent is, and what name they've been given.
84
+	 *
85
+	 * @param array[] $options_array   {
86
+	 * @type          $subsections     EE_Form_Section_Validatable[] where keys are the section's name
87
+	 * @type          $include         string[] numerically-indexed where values are section names to be included,
88
+	 *                                 and in that order. This is handy if you want
89
+	 *                                 the subsections to be ordered differently than the default, and if you override
90
+	 *                                 which fields are shown
91
+	 * @type          $exclude         string[] values are subsections to be excluded. This is handy if you want
92
+	 *                                 to remove certain default subsections (note: if you specify BOTH 'include' AND
93
+	 *                                 'exclude', the inclusions will be applied first, and the exclusions will exclude
94
+	 *                                 items from that list of inclusions)
95
+	 * @type          $layout_strategy EE_Form_Section_Layout_Base strategy for laying out the form
96
+	 *                                 } @see EE_Form_Section_Validatable::__construct()
97
+	 * @throws EE_Error
98
+	 */
99
+	public function __construct($options_array = array())
100
+	{
101
+		$options_array = (array) apply_filters(
102
+			'FHEE__EE_Form_Section_Proper___construct__options_array',
103
+			$options_array,
104
+			$this
105
+		);
106
+		//call parent first, as it may be setting the name
107
+		parent::__construct($options_array);
108
+		//if they've included subsections in the constructor, add them now
109
+		if (isset($options_array['include'])) {
110
+			//we are going to make sure we ONLY have those subsections to include
111
+			//AND we are going to make sure they're in that specified order
112
+			$reordered_subsections = array();
113
+			foreach ($options_array['include'] as $input_name) {
114
+				if (isset($this->_subsections[ $input_name ])) {
115
+					$reordered_subsections[ $input_name ] = $this->_subsections[ $input_name ];
116
+				}
117
+			}
118
+			$this->_subsections = $reordered_subsections;
119
+		}
120
+		if (isset($options_array['exclude'])) {
121
+			$exclude            = $options_array['exclude'];
122
+			$this->_subsections = array_diff_key($this->_subsections, array_flip($exclude));
123
+		}
124
+		if (isset($options_array['layout_strategy'])) {
125
+			$this->_layout_strategy = $options_array['layout_strategy'];
126
+		}
127
+		if (! $this->_layout_strategy) {
128
+			$this->_layout_strategy = is_admin() ? new EE_Admin_Two_Column_Layout() : new EE_Two_Column_Layout();
129
+		}
130
+		$this->_layout_strategy->_construct_finalize($this);
131
+		//ok so we are definitely going to want the forms JS,
132
+		//so enqueue it or remember to enqueue it during wp_enqueue_scripts
133
+		if (did_action('wp_enqueue_scripts') || did_action('admin_enqueue_scripts')) {
134
+			//ok so they've constructed this object after when they should have.
135
+			//just enqueue the generic form scripts and initialize the form immediately in the JS
136
+			EE_Form_Section_Proper::wp_enqueue_scripts(true);
137
+		} else {
138
+			add_action('wp_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts'));
139
+			add_action('admin_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts'));
140
+		}
141
+		add_action('wp_footer', array($this, 'ensure_scripts_localized'), 1);
142
+		/**
143
+		 * Gives other plugins a chance to hook in before construct finalize is called.
144
+		 * The form probably doesn't yet have a parent form section.
145
+		 * Since 4.9.32, when this action was introduced, this is the best place to add a subsection onto a form,
146
+		 * assuming you don't care what the form section's name, HTML ID, or HTML name etc are.
147
+		 * Also see AHEE__EE_Form_Section_Proper___construct_finalize__end
148
+		 *
149
+		 * @since 4.9.32
150
+		 * @param EE_Form_Section_Proper $this          before __construct is done, but all of its logic,
151
+		 *                                              except maybe calling _construct_finalize has been done
152
+		 * @param array                  $options_array options passed into the constructor
153
+		 */
154
+		do_action(
155
+			'AHEE__EE_Form_Input_Base___construct__before_construct_finalize_called',
156
+			$this,
157
+			$options_array
158
+		);
159
+		if (isset($options_array['name'])) {
160
+			$this->_construct_finalize(null, $options_array['name']);
161
+		}
162
+	}
163
+
164
+
165
+	/**
166
+	 * Finishes construction given the parent form section and this form section's name
167
+	 *
168
+	 * @param EE_Form_Section_Proper $parent_form_section
169
+	 * @param string                 $name
170
+	 * @throws EE_Error
171
+	 */
172
+	public function _construct_finalize($parent_form_section, $name)
173
+	{
174
+		parent::_construct_finalize($parent_form_section, $name);
175
+		$this->_set_default_name_if_empty();
176
+		$this->_set_default_html_id_if_empty();
177
+		foreach ($this->_subsections as $subsection_name => $subsection) {
178
+			if ($subsection instanceof EE_Form_Section_Base) {
179
+				$subsection->_construct_finalize($this, $subsection_name);
180
+			} else {
181
+				throw new EE_Error(
182
+					sprintf(
183
+						esc_html__(
184
+							'Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"',
185
+							'event_espresso'
186
+						),
187
+						$subsection_name,
188
+						get_class($this),
189
+						$subsection ? get_class($subsection) : esc_html__('NULL', 'event_espresso')
190
+					)
191
+				);
192
+			}
193
+		}
194
+		/**
195
+		 * Action performed just after form has been given a name (and HTML ID etc) and is fully constructed.
196
+		 * If you have code that should modify the form and needs it and its subsections to have a name, HTML ID
197
+		 * (or other attributes derived from the name like the HTML label id, etc), this is where it should be done.
198
+		 * This might only happen just before displaying the form, or just before it receives form submission data.
199
+		 * If you need to modify the form or its subsections before _construct_finalize is called on it (and we've
200
+		 * ensured it has a name, HTML IDs, etc
201
+		 *
202
+		 * @param EE_Form_Section_Proper      $this
203
+		 * @param EE_Form_Section_Proper|null $parent_form_section
204
+		 * @param string                      $name
205
+		 */
206
+		do_action(
207
+			'AHEE__EE_Form_Section_Proper___construct_finalize__end',
208
+			$this,
209
+			$parent_form_section,
210
+			$name
211
+		);
212
+	}
213
+
214
+
215
+	/**
216
+	 * Gets the layout strategy for this form section
217
+	 *
218
+	 * @return EE_Form_Section_Layout_Base
219
+	 */
220
+	public function get_layout_strategy()
221
+	{
222
+		return $this->_layout_strategy;
223
+	}
224
+
225
+
226
+	/**
227
+	 * Gets the HTML for a single input for this form section according
228
+	 * to the layout strategy
229
+	 *
230
+	 * @param EE_Form_Input_Base $input
231
+	 * @return string
232
+	 */
233
+	public function get_html_for_input($input)
234
+	{
235
+		return $this->_layout_strategy->layout_input($input);
236
+	}
237
+
238
+
239
+	/**
240
+	 * was_submitted - checks if form inputs are present in request data
241
+	 * Basically an alias for form_data_present_in() (which is used by both
242
+	 * proper form sections and form inputs)
243
+	 *
244
+	 * @param null $form_data
245
+	 * @return boolean
246
+	 * @throws EE_Error
247
+	 */
248
+	public function was_submitted($form_data = null)
249
+	{
250
+		return $this->form_data_present_in($form_data);
251
+	}
252
+
253
+	/**
254
+	 * Gets the cached request data; but if there is none, or $req_data was set with
255
+	 * something different, refresh the cache, and then return it
256
+	 * @param null $req_data
257
+	 * @return array
258
+	 */
259
+	protected function getCachedRequest($req_data = null)
260
+	{
261
+		if ($this->cached_request_data === null
262
+			|| (
263
+				$req_data !== null &&
264
+				$req_data !== $this->cached_request_data
265
+			)
266
+		) {
267
+			$req_data = apply_filters(
268
+				'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data',
269
+				$req_data,
270
+				$this
271
+			);
272
+			if ($req_data === null) {
273
+				$req_data = array_merge($_GET, $_POST);
274
+			}
275
+			$req_data = apply_filters(
276
+				'FHEE__EE_Form_Section_Proper__receive_form_submission__request_data',
277
+				$req_data,
278
+				$this
279
+			);
280
+			$this->cached_request_data = (array)$req_data;
281
+		}
282
+		return $this->cached_request_data;
283
+	}
284
+
285
+
286
+	/**
287
+	 * After the form section is initially created, call this to sanitize the data in the submission
288
+	 * which relates to this form section, validate it, and set it as properties on the form.
289
+	 *
290
+	 * @param array|null $req_data should usually be $_POST (the default).
291
+	 *                             However, you CAN supply a different array.
292
+	 *                             Consider using set_defaults() instead however.
293
+	 *                             (If you rendered the form in the page using echo $form_x->get_html()
294
+	 *                             the inputs will have the correct name in the request data for this function
295
+	 *                             to find them and populate the form with them.
296
+	 *                             If you have a flat form (with only input subsections),
297
+	 *                             you can supply a flat array where keys
298
+	 *                             are the form input names and values are their values)
299
+	 * @param boolean    $validate whether or not to perform validation on this data. Default is,
300
+	 *                             of course, to validate that data, and set errors on the invalid values.
301
+	 *                             But if the data has already been validated
302
+	 *                             (eg you validated the data then stored it in the DB)
303
+	 *                             you may want to skip this step.
304
+	 * @throws InvalidArgumentException
305
+	 * @throws InvalidInterfaceException
306
+	 * @throws InvalidDataTypeException
307
+	 * @throws EE_Error
308
+	 */
309
+	public function receive_form_submission($req_data = null, $validate = true)
310
+	{
311
+		$req_data = $this->getCachedRequest($req_data);
312
+		$this->_normalize($req_data);
313
+		if ($validate) {
314
+			$this->_validate();
315
+			//if it's invalid, we're going to want to re-display so remember what they submitted
316
+			if (! $this->is_valid()) {
317
+				$this->store_submitted_form_data_in_session();
318
+			}
319
+		}
320
+		if ($this->submission_error_message() === '' && ! $this->is_valid()) {
321
+			$this->set_submission_error_message();
322
+		}
323
+		do_action(
324
+			'AHEE__EE_Form_Section_Proper__receive_form_submission__end',
325
+			$req_data,
326
+			$this,
327
+			$validate
328
+		);
329
+	}
330
+
331
+
332
+	/**
333
+	 * caches the originally submitted input values in the session
334
+	 * so that they can be used to repopulate the form if it failed validation
335
+	 *
336
+	 * @return boolean whether or not the data was successfully stored in the session
337
+	 * @throws InvalidArgumentException
338
+	 * @throws InvalidInterfaceException
339
+	 * @throws InvalidDataTypeException
340
+	 * @throws EE_Error
341
+	 */
342
+	protected function store_submitted_form_data_in_session()
343
+	{
344
+		return EE_Registry::instance()->SSN->set_session_data(
345
+			array(
346
+				EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY => $this->submitted_values(true),
347
+			)
348
+		);
349
+	}
350
+
351
+
352
+	/**
353
+	 * retrieves the originally submitted input values in the session
354
+	 * so that they can be used to repopulate the form if it failed validation
355
+	 *
356
+	 * @return array
357
+	 * @throws InvalidArgumentException
358
+	 * @throws InvalidInterfaceException
359
+	 * @throws InvalidDataTypeException
360
+	 */
361
+	protected function get_submitted_form_data_from_session()
362
+	{
363
+		$session = EE_Registry::instance()->SSN;
364
+		if ($session instanceof EE_Session) {
365
+			return $session->get_session_data(
366
+				EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY
367
+			);
368
+		}
369
+		return array();
370
+	}
371
+
372
+
373
+	/**
374
+	 * flushed the originally submitted input values from the session
375
+	 *
376
+	 * @return boolean whether or not the data was successfully removed from the session
377
+	 * @throws InvalidArgumentException
378
+	 * @throws InvalidInterfaceException
379
+	 * @throws InvalidDataTypeException
380
+	 */
381
+	protected function flush_submitted_form_data_from_session()
382
+	{
383
+		return EE_Registry::instance()->SSN->reset_data(
384
+			array(EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY)
385
+		);
386
+	}
387
+
388
+
389
+	/**
390
+	 * Populates this form and its subsections with data from the session.
391
+	 * (Wrapper for EE_Form_Section_Proper::receive_form_submission, so it shows
392
+	 * validation errors when displaying too)
393
+	 * Returns true if the form was populated from the session, false otherwise
394
+	 *
395
+	 * @return boolean
396
+	 * @throws InvalidArgumentException
397
+	 * @throws InvalidInterfaceException
398
+	 * @throws InvalidDataTypeException
399
+	 * @throws EE_Error
400
+	 */
401
+	public function populate_from_session()
402
+	{
403
+		$form_data_in_session = $this->get_submitted_form_data_from_session();
404
+		if (empty($form_data_in_session)) {
405
+			return false;
406
+		}
407
+		$this->receive_form_submission($form_data_in_session);
408
+		$this->flush_submitted_form_data_from_session();
409
+		if ($this->form_data_present_in($form_data_in_session)) {
410
+			return true;
411
+		}
412
+		return false;
413
+	}
414
+
415
+
416
+	/**
417
+	 * Populates the default data for the form, given an array where keys are
418
+	 * the input names, and values are their values (preferably normalized to be their
419
+	 * proper PHP types, not all strings... although that should be ok too).
420
+	 * Proper subsections are sub-arrays, the key being the subsection's name, and
421
+	 * the value being an array formatted in teh same way
422
+	 *
423
+	 * @param array $default_data
424
+	 * @throws EE_Error
425
+	 */
426
+	public function populate_defaults($default_data)
427
+	{
428
+		foreach ($this->subsections(false) as $subsection_name => $subsection) {
429
+			if (isset($default_data[ $subsection_name ])) {
430
+				if ($subsection instanceof EE_Form_Input_Base) {
431
+					$subsection->set_default($default_data[ $subsection_name ]);
432
+				} elseif ($subsection instanceof EE_Form_Section_Proper) {
433
+					$subsection->populate_defaults($default_data[ $subsection_name ]);
434
+				}
435
+			}
436
+		}
437
+	}
438
+
439
+
440
+	/**
441
+	 * returns true if subsection exists
442
+	 *
443
+	 * @param string $name
444
+	 * @return boolean
445
+	 */
446
+	public function subsection_exists($name)
447
+	{
448
+		return isset($this->_subsections[ $name ]) ? true : false;
449
+	}
450
+
451
+
452
+	/**
453
+	 * Gets the subsection specified by its name
454
+	 *
455
+	 * @param string  $name
456
+	 * @param boolean $require_construction_to_be_finalized most client code should leave this as TRUE
457
+	 *                                                      so that the inputs will be properly configured.
458
+	 *                                                      However, some client code may be ok
459
+	 *                                                      with construction finalize being called later
460
+	 *                                                      (realizing that the subsections' html names
461
+	 *                                                      might not be set yet, etc.)
462
+	 * @return EE_Form_Section_Base
463
+	 * @throws EE_Error
464
+	 */
465
+	public function get_subsection($name, $require_construction_to_be_finalized = true)
466
+	{
467
+		if ($require_construction_to_be_finalized) {
468
+			$this->ensure_construct_finalized_called();
469
+		}
470
+		return $this->subsection_exists($name) ? $this->_subsections[ $name ] : null;
471
+	}
472
+
473
+
474
+	/**
475
+	 * Gets all the validatable subsections of this form section
476
+	 *
477
+	 * @return EE_Form_Section_Validatable[]
478
+	 * @throws EE_Error
479
+	 */
480
+	public function get_validatable_subsections()
481
+	{
482
+		$validatable_subsections = array();
483
+		foreach ($this->subsections() as $name => $obj) {
484
+			if ($obj instanceof EE_Form_Section_Validatable) {
485
+				$validatable_subsections[ $name ] = $obj;
486
+			}
487
+		}
488
+		return $validatable_subsections;
489
+	}
490
+
491
+
492
+	/**
493
+	 * Gets an input by the given name. If not found, or if its not an EE_FOrm_Input_Base child,
494
+	 * throw an EE_Error.
495
+	 *
496
+	 * @param string  $name
497
+	 * @param boolean $require_construction_to_be_finalized most client code should
498
+	 *                                                      leave this as TRUE so that the inputs will be properly
499
+	 *                                                      configured. However, some client code may be ok with
500
+	 *                                                      construction finalize being called later
501
+	 *                                                      (realizing that the subsections' html names might not be
502
+	 *                                                      set yet, etc.)
503
+	 * @return EE_Form_Input_Base
504
+	 * @throws EE_Error
505
+	 */
506
+	public function get_input($name, $require_construction_to_be_finalized = true)
507
+	{
508
+		$subsection = $this->get_subsection(
509
+			$name,
510
+			$require_construction_to_be_finalized
511
+		);
512
+		if (! $subsection instanceof EE_Form_Input_Base) {
513
+			throw new EE_Error(
514
+				sprintf(
515
+					esc_html__(
516
+						"Subsection '%s' is not an instanceof EE_Form_Input_Base on form '%s'. It is a '%s'",
517
+						'event_espresso'
518
+					),
519
+					$name,
520
+					get_class($this),
521
+					$subsection ? get_class($subsection) : esc_html__('NULL', 'event_espresso')
522
+				)
523
+			);
524
+		}
525
+		return $subsection;
526
+	}
527
+
528
+
529
+	/**
530
+	 * Like get_input(), gets the proper subsection of the form given the name,
531
+	 * otherwise throws an EE_Error
532
+	 *
533
+	 * @param string  $name
534
+	 * @param boolean $require_construction_to_be_finalized most client code should
535
+	 *                                                      leave this as TRUE so that the inputs will be properly
536
+	 *                                                      configured. However, some client code may be ok with
537
+	 *                                                      construction finalize being called later
538
+	 *                                                      (realizing that the subsections' html names might not be
539
+	 *                                                      set yet, etc.)
540
+	 * @return EE_Form_Section_Proper
541
+	 * @throws EE_Error
542
+	 */
543
+	public function get_proper_subsection($name, $require_construction_to_be_finalized = true)
544
+	{
545
+		$subsection = $this->get_subsection(
546
+			$name,
547
+			$require_construction_to_be_finalized
548
+		);
549
+		if (! $subsection instanceof EE_Form_Section_Proper) {
550
+			throw new EE_Error(
551
+				sprintf(
552
+					esc_html__(
553
+						"Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'",
554
+						'event_espresso'
555
+					),
556
+					$name,
557
+					get_class($this)
558
+				)
559
+			);
560
+		}
561
+		return $subsection;
562
+	}
563
+
564
+
565
+	/**
566
+	 * Gets the value of the specified input. Should be called after receive_form_submission()
567
+	 * or populate_defaults() on the form, where the normalized value on the input is set.
568
+	 *
569
+	 * @param string $name
570
+	 * @return mixed depending on the input's type and its normalization strategy
571
+	 * @throws EE_Error
572
+	 */
573
+	public function get_input_value($name)
574
+	{
575
+		$input = $this->get_input($name);
576
+		return $input->normalized_value();
577
+	}
578
+
579
+
580
+	/**
581
+	 * Checks if this form section itself is valid, and then checks its subsections
582
+	 *
583
+	 * @throws EE_Error
584
+	 * @return boolean
585
+	 */
586
+	public function is_valid()
587
+	{
588
+		if($this->is_valid === null) {
589
+			if (! $this->has_received_submission()) {
590
+				throw new EE_Error(
591
+					sprintf(
592
+						esc_html__(
593
+							'You cannot check if a form is valid before receiving the form submission using receive_form_submission',
594
+							'event_espresso'
595
+						)
596
+					)
597
+				);
598
+			}
599
+			if (! parent::is_valid()) {
600
+				$this->is_valid = false;
601
+			} else {
602
+				// ok so no general errors to this entire form section.
603
+				// so let's check the subsections, but only set errors if that hasn't been done yet
604
+				$this->is_valid = true;
605
+				foreach ($this->get_validatable_subsections() as $subsection) {
606
+					if (! $subsection->is_valid()) {
607
+						$this->is_valid = false;
608
+					}
609
+				}
610
+			}
611
+		}
612
+		return $this->is_valid;
613
+	}
614
+
615
+
616
+	/**
617
+	 * gets the default name of this form section if none is specified
618
+	 *
619
+	 * @return void
620
+	 */
621
+	protected function _set_default_name_if_empty()
622
+	{
623
+		if (! $this->_name) {
624
+			$classname    = get_class($this);
625
+			$default_name = str_replace('EE_', '', $classname);
626
+			$this->_name  = $default_name;
627
+		}
628
+	}
629
+
630
+
631
+	/**
632
+	 * Returns the HTML for the form, except for the form opening and closing tags
633
+	 * (as the form section doesn't know where you necessarily want to send the information to),
634
+	 * and except for a submit button. Enqueues JS and CSS; if called early enough we will
635
+	 * try to enqueue them in the header, otherwise they'll be enqueued in the footer.
636
+	 * Not doing_it_wrong because theoretically this CAN be used properly,
637
+	 * provided its used during "wp_enqueue_scripts", or it doesn't need to enqueue
638
+	 * any CSS.
639
+	 *
640
+	 * @throws InvalidArgumentException
641
+	 * @throws InvalidInterfaceException
642
+	 * @throws InvalidDataTypeException
643
+	 * @throws EE_Error
644
+	 */
645
+	public function get_html_and_js()
646
+	{
647
+		$this->enqueue_js();
648
+		return $this->get_html();
649
+	}
650
+
651
+
652
+	/**
653
+	 * returns HTML for displaying this form section. recursively calls display_section() on all subsections
654
+	 *
655
+	 * @param bool $display_previously_submitted_data
656
+	 * @return string
657
+	 * @throws InvalidArgumentException
658
+	 * @throws InvalidInterfaceException
659
+	 * @throws InvalidDataTypeException
660
+	 * @throws EE_Error
661
+	 * @throws EE_Error
662
+	 * @throws EE_Error
663
+	 */
664
+	public function get_html($display_previously_submitted_data = true)
665
+	{
666
+		$this->ensure_construct_finalized_called();
667
+		if ($display_previously_submitted_data) {
668
+			$this->populate_from_session();
669
+		}
670
+		return $this->_form_html_filter
671
+			? $this->_form_html_filter->filterHtml($this->_layout_strategy->layout_form(), $this)
672
+			: $this->_layout_strategy->layout_form();
673
+	}
674
+
675
+
676
+	/**
677
+	 * enqueues JS and CSS for the form.
678
+	 * It is preferred to call this before wp_enqueue_scripts so the
679
+	 * scripts and styles can be put in the header, but if called later
680
+	 * they will be put in the footer (which is OK for JS, but in HTML4 CSS should
681
+	 * only be in the header; but in HTML5 its ok in the body.
682
+	 * See http://stackoverflow.com/questions/4957446/load-external-css-file-in-body-tag.
683
+	 * So if your form enqueues CSS, it's preferred to call this before wp_enqueue_scripts.)
684
+	 *
685
+	 * @return void
686
+	 * @throws EE_Error
687
+	 */
688
+	public function enqueue_js()
689
+	{
690
+		$this->_enqueue_and_localize_form_js();
691
+		foreach ($this->subsections() as $subsection) {
692
+			$subsection->enqueue_js();
693
+		}
694
+	}
695
+
696
+
697
+	/**
698
+	 * adds a filter so that jquery validate gets enqueued in EE_System::wp_enqueue_scripts().
699
+	 * This must be done BEFORE wp_enqueue_scripts() gets called, which is on
700
+	 * the wp_enqueue_scripts hook.
701
+	 * However, registering the form js and localizing it can happen when we
702
+	 * actually output the form (which is preferred, seeing how teh form's fields
703
+	 * could change until it's actually outputted)
704
+	 *
705
+	 * @param boolean $init_form_validation_automatically whether or not we want the form validation
706
+	 *                                                    to be triggered automatically or not
707
+	 * @return void
708
+	 */
709
+	public static function wp_enqueue_scripts($init_form_validation_automatically = true)
710
+	{
711
+		wp_register_script(
712
+			'ee_form_section_validation',
713
+			EE_GLOBAL_ASSETS_URL . 'scripts' . DS . 'form_section_validation.js',
714
+			array('jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods'),
715
+			EVENT_ESPRESSO_VERSION,
716
+			true
717
+		);
718
+		wp_localize_script(
719
+			'ee_form_section_validation',
720
+			'ee_form_section_validation_init',
721
+			array('init' => $init_form_validation_automatically ? '1' : '0')
722
+		);
723
+	}
724
+
725
+
726
+	/**
727
+	 * gets the variables used by form_section_validation.js.
728
+	 * This needs to be called AFTER we've called $this->_enqueue_jquery_validate_script,
729
+	 * but before the wordpress hook wp_loaded
730
+	 *
731
+	 * @throws EE_Error
732
+	 */
733
+	public function _enqueue_and_localize_form_js()
734
+	{
735
+		$this->ensure_construct_finalized_called();
736
+		//actually, we don't want to localize just yet. There may be other forms on the page.
737
+		//so we need to add our form section data to a static variable accessible by all form sections
738
+		//and localize it just before the footer
739
+		$this->localize_validation_rules();
740
+		add_action('wp_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'), 2);
741
+		add_action('admin_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'));
742
+	}
743
+
744
+
745
+	/**
746
+	 * add our form section data to a static variable accessible by all form sections
747
+	 *
748
+	 * @param bool $return_for_subsection
749
+	 * @return void
750
+	 * @throws EE_Error
751
+	 */
752
+	public function localize_validation_rules($return_for_subsection = false)
753
+	{
754
+		// we only want to localize vars ONCE for the entire form,
755
+		// so if the form section doesn't have a parent, then it must be the top dog
756
+		if ($return_for_subsection || ! $this->parent_section()) {
757
+			EE_Form_Section_Proper::$_js_localization['form_data'][ $this->html_id() ] = array(
758
+				'form_section_id'  => $this->html_id(true),
759
+				'validation_rules' => $this->get_jquery_validation_rules(),
760
+				'other_data'       => $this->get_other_js_data(),
761
+				'errors'           => $this->subsection_validation_errors_by_html_name(),
762
+			);
763
+			EE_Form_Section_Proper::$_scripts_localized                                = true;
764
+		}
765
+	}
766
+
767
+
768
+	/**
769
+	 * Gets an array of extra data that will be useful for client-side javascript.
770
+	 * This is primarily data added by inputs and forms in addition to any
771
+	 * scripts they might enqueue
772
+	 *
773
+	 * @param array $form_other_js_data
774
+	 * @return array
775
+	 * @throws EE_Error
776
+	 */
777
+	public function get_other_js_data($form_other_js_data = array())
778
+	{
779
+		foreach ($this->subsections() as $subsection) {
780
+			$form_other_js_data = $subsection->get_other_js_data($form_other_js_data);
781
+		}
782
+		return $form_other_js_data;
783
+	}
784
+
785
+
786
+	/**
787
+	 * Gets a flat array of inputs for this form section and its subsections.
788
+	 * Keys are their form names, and values are the inputs themselves
789
+	 *
790
+	 * @return EE_Form_Input_Base
791
+	 * @throws EE_Error
792
+	 */
793
+	public function inputs_in_subsections()
794
+	{
795
+		$inputs = array();
796
+		foreach ($this->subsections() as $subsection) {
797
+			if ($subsection instanceof EE_Form_Input_Base) {
798
+				$inputs[ $subsection->html_name() ] = $subsection;
799
+			} elseif ($subsection instanceof EE_Form_Section_Proper) {
800
+				$inputs += $subsection->inputs_in_subsections();
801
+			}
802
+		}
803
+		return $inputs;
804
+	}
805
+
806
+
807
+	/**
808
+	 * Gets a flat array of all the validation errors.
809
+	 * Keys are html names (because those should be unique)
810
+	 * and values are a string of all their validation errors
811
+	 *
812
+	 * @return string[]
813
+	 * @throws EE_Error
814
+	 */
815
+	public function subsection_validation_errors_by_html_name()
816
+	{
817
+		$inputs = $this->inputs();
818
+		$errors = array();
819
+		foreach ($inputs as $form_input) {
820
+			if ($form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors()) {
821
+				$errors[ $form_input->html_name() ] = $form_input->get_validation_error_string();
822
+			}
823
+		}
824
+		return $errors;
825
+	}
826
+
827
+
828
+	/**
829
+	 * passes all the form data required by the JS to the JS, and enqueues the few required JS files.
830
+	 * Should be setup by each form during the _enqueues_and_localize_form_js
831
+	 *
832
+	 * @throws InvalidArgumentException
833
+	 * @throws InvalidInterfaceException
834
+	 * @throws InvalidDataTypeException
835
+	 */
836
+	public static function localize_script_for_all_forms()
837
+	{
838
+		//allow inputs and stuff to hook in their JS and stuff here
839
+		do_action('AHEE__EE_Form_Section_Proper__localize_script_for_all_forms__begin');
840
+		EE_Form_Section_Proper::$_js_localization['localized_error_messages'] = EE_Form_Section_Proper::_get_localized_error_messages();
841
+		$email_validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level)
842
+			? EE_Registry::instance()->CFG->registration->email_validation_level
843
+			: 'wp_default';
844
+		EE_Form_Section_Proper::$_js_localization['email_validation_level']   = $email_validation_level;
845
+		wp_enqueue_script('ee_form_section_validation');
846
+		wp_localize_script(
847
+			'ee_form_section_validation',
848
+			'ee_form_section_vars',
849
+			EE_Form_Section_Proper::$_js_localization
850
+		);
851
+	}
852
+
853
+
854
+	/**
855
+	 * ensure_scripts_localized
856
+	 *
857
+	 * @throws EE_Error
858
+	 */
859
+	public function ensure_scripts_localized()
860
+	{
861
+		if (! EE_Form_Section_Proper::$_scripts_localized) {
862
+			$this->_enqueue_and_localize_form_js();
863
+		}
864
+	}
865
+
866
+
867
+	/**
868
+	 * Gets the hard-coded validation error messages to be used in the JS. The convention
869
+	 * is that the key here should be the same as the custom validation rule put in the JS file
870
+	 *
871
+	 * @return array keys are custom validation rules, and values are internationalized strings
872
+	 */
873
+	private static function _get_localized_error_messages()
874
+	{
875
+		return array(
876
+			'validUrl' => esc_html__('This is not a valid absolute URL. Eg, http://domain.com/monkey.jpg', 'event_espresso'),
877
+			'regex'    => esc_html__('Please check your input', 'event_espresso'),
878
+		);
879
+	}
880
+
881
+
882
+	/**
883
+	 * @return array
884
+	 */
885
+	public static function js_localization()
886
+	{
887
+		return self::$_js_localization;
888
+	}
889
+
890
+
891
+	/**
892
+	 * @return void
893
+	 */
894
+	public static function reset_js_localization()
895
+	{
896
+		self::$_js_localization = array();
897
+	}
898
+
899
+
900
+	/**
901
+	 * Gets the JS to put inside the jquery validation rules for subsection of this form section.
902
+	 * See parent function for more...
903
+	 *
904
+	 * @return array
905
+	 * @throws EE_Error
906
+	 */
907
+	public function get_jquery_validation_rules()
908
+	{
909
+		$jquery_validation_rules = array();
910
+		foreach ($this->get_validatable_subsections() as $subsection) {
911
+			$jquery_validation_rules = array_merge(
912
+				$jquery_validation_rules,
913
+				$subsection->get_jquery_validation_rules()
914
+			);
915
+		}
916
+		return $jquery_validation_rules;
917
+	}
918
+
919
+
920
+	/**
921
+	 * Sanitizes all the data and sets the sanitized value of each field
922
+	 *
923
+	 * @param array $req_data like $_POST
924
+	 * @return void
925
+	 * @throws EE_Error
926
+	 */
927
+	protected function _normalize($req_data)
928
+	{
929
+		$this->_received_submission = true;
930
+		$this->_validation_errors   = array();
931
+		foreach ($this->get_validatable_subsections() as $subsection) {
932
+			try {
933
+				$subsection->_normalize($req_data);
934
+			} catch (EE_Validation_Error $e) {
935
+				$subsection->add_validation_error($e);
936
+			}
937
+		}
938
+	}
939
+
940
+
941
+	/**
942
+	 * Performs validation on this form section and its subsections.
943
+	 * For each subsection,
944
+	 * calls _validate_{subsection_name} on THIS form (if the function exists)
945
+	 * and passes it the subsection, then calls _validate on that subsection.
946
+	 * If you need to perform validation on the form as a whole (considering multiple)
947
+	 * you would be best to override this _validate method,
948
+	 * calling parent::_validate() first.
949
+	 *
950
+	 * @throws EE_Error
951
+	 */
952
+	protected function _validate()
953
+	{
954
+		//reset the cache of whether this form is valid or not- we're re-validating it now
955
+		$this->is_valid = null;
956
+		foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) {
957
+			if (method_exists($this, '_validate_' . $subsection_name)) {
958
+				call_user_func_array(array($this, '_validate_' . $subsection_name), array($subsection));
959
+			}
960
+			$subsection->_validate();
961
+		}
962
+	}
963
+
964
+
965
+	/**
966
+	 * Gets all the validated inputs for the form section
967
+	 *
968
+	 * @return array
969
+	 * @throws EE_Error
970
+	 */
971
+	public function valid_data()
972
+	{
973
+		$inputs = array();
974
+		foreach ($this->subsections() as $subsection_name => $subsection) {
975
+			if ($subsection instanceof EE_Form_Section_Proper) {
976
+				$inputs[ $subsection_name ] = $subsection->valid_data();
977
+			} elseif ($subsection instanceof EE_Form_Input_Base) {
978
+				$inputs[ $subsection_name ] = $subsection->normalized_value();
979
+			}
980
+		}
981
+		return $inputs;
982
+	}
983
+
984
+
985
+	/**
986
+	 * Gets all the inputs on this form section
987
+	 *
988
+	 * @return EE_Form_Input_Base[]
989
+	 * @throws EE_Error
990
+	 */
991
+	public function inputs()
992
+	{
993
+		$inputs = array();
994
+		foreach ($this->subsections() as $subsection_name => $subsection) {
995
+			if ($subsection instanceof EE_Form_Input_Base) {
996
+				$inputs[ $subsection_name ] = $subsection;
997
+			}
998
+		}
999
+		return $inputs;
1000
+	}
1001
+
1002
+
1003
+	/**
1004
+	 * Gets all the subsections which are a proper form
1005
+	 *
1006
+	 * @return EE_Form_Section_Proper[]
1007
+	 * @throws EE_Error
1008
+	 */
1009
+	public function subforms()
1010
+	{
1011
+		$form_sections = array();
1012
+		foreach ($this->subsections() as $name => $obj) {
1013
+			if ($obj instanceof EE_Form_Section_Proper) {
1014
+				$form_sections[ $name ] = $obj;
1015
+			}
1016
+		}
1017
+		return $form_sections;
1018
+	}
1019
+
1020
+
1021
+	/**
1022
+	 * Gets all the subsections (inputs, proper subsections, or html-only sections).
1023
+	 * Consider using inputs() or subforms()
1024
+	 * if you only want form inputs or proper form sections.
1025
+	 *
1026
+	 * @param boolean $require_construction_to_be_finalized most client code should
1027
+	 *                                                      leave this as TRUE so that the inputs will be properly
1028
+	 *                                                      configured. However, some client code may be ok with
1029
+	 *                                                      construction finalize being called later
1030
+	 *                                                      (realizing that the subsections' html names might not be
1031
+	 *                                                      set yet, etc.)
1032
+	 * @return EE_Form_Section_Proper[]
1033
+	 * @throws EE_Error
1034
+	 */
1035
+	public function subsections($require_construction_to_be_finalized = true)
1036
+	{
1037
+		if ($require_construction_to_be_finalized) {
1038
+			$this->ensure_construct_finalized_called();
1039
+		}
1040
+		return $this->_subsections;
1041
+	}
1042
+
1043
+
1044
+	/**
1045
+	 * Returns whether this form has any subforms or inputs
1046
+	 * @return bool
1047
+	 */
1048
+	public function hasSubsections()
1049
+	{
1050
+		return ! empty($this->_subsections);
1051
+	}
1052
+
1053
+
1054
+	/**
1055
+	 * Returns a simple array where keys are input names, and values are their normalized
1056
+	 * values. (Similar to calling get_input_value on inputs)
1057
+	 *
1058
+	 * @param boolean $include_subform_inputs Whether to include inputs from subforms,
1059
+	 *                                        or just this forms' direct children inputs
1060
+	 * @param boolean $flatten                Whether to force the results into 1-dimensional array,
1061
+	 *                                        or allow multidimensional array
1062
+	 * @return array if $flatten is TRUE it will always be a 1-dimensional array
1063
+	 *                                        with array keys being input names
1064
+	 *                                        (regardless of whether they are from a subsection or not),
1065
+	 *                                        and if $flatten is FALSE it can be a multidimensional array
1066
+	 *                                        where keys are always subsection names and values are either
1067
+	 *                                        the input's normalized value, or an array like the top-level array
1068
+	 * @throws EE_Error
1069
+	 */
1070
+	public function input_values($include_subform_inputs = false, $flatten = false)
1071
+	{
1072
+		return $this->_input_values(false, $include_subform_inputs, $flatten);
1073
+	}
1074
+
1075
+
1076
+	/**
1077
+	 * Similar to EE_Form_Section_Proper::input_values(), except this returns the 'display_value'
1078
+	 * of each input. On some inputs (especially radio boxes or checkboxes), the value stored
1079
+	 * is not necessarily the value we want to display to users. This creates an array
1080
+	 * where keys are the input names, and values are their display values
1081
+	 *
1082
+	 * @param boolean $include_subform_inputs Whether to include inputs from subforms,
1083
+	 *                                        or just this forms' direct children inputs
1084
+	 * @param boolean $flatten                Whether to force the results into 1-dimensional array,
1085
+	 *                                        or allow multidimensional array
1086
+	 * @return array if $flatten is TRUE it will always be a 1-dimensional array
1087
+	 *                                        with array keys being input names
1088
+	 *                                        (regardless of whether they are from a subsection or not),
1089
+	 *                                        and if $flatten is FALSE it can be a multidimensional array
1090
+	 *                                        where keys are always subsection names and values are either
1091
+	 *                                        the input's normalized value, or an array like the top-level array
1092
+	 * @throws EE_Error
1093
+	 */
1094
+	public function input_pretty_values($include_subform_inputs = false, $flatten = false)
1095
+	{
1096
+		return $this->_input_values(true, $include_subform_inputs, $flatten);
1097
+	}
1098
+
1099
+
1100
+	/**
1101
+	 * Gets the input values from the form
1102
+	 *
1103
+	 * @param boolean $pretty                 Whether to retrieve the pretty value,
1104
+	 *                                        or just the normalized value
1105
+	 * @param boolean $include_subform_inputs Whether to include inputs from subforms,
1106
+	 *                                        or just this forms' direct children inputs
1107
+	 * @param boolean $flatten                Whether to force the results into 1-dimensional array,
1108
+	 *                                        or allow multidimensional array
1109
+	 * @return array if $flatten is TRUE it will always be a 1-dimensional array with array keys being
1110
+	 *                                        input names (regardless of whether they are from a subsection or not),
1111
+	 *                                        and if $flatten is FALSE it can be a multidimensional array
1112
+	 *                                        where keys are always subsection names and values are either
1113
+	 *                                        the input's normalized value, or an array like the top-level array
1114
+	 * @throws EE_Error
1115
+	 */
1116
+	public function _input_values($pretty = false, $include_subform_inputs = false, $flatten = false)
1117
+	{
1118
+		$input_values = array();
1119
+		foreach ($this->subsections() as $subsection_name => $subsection) {
1120
+			if ($subsection instanceof EE_Form_Input_Base) {
1121
+				$input_values[ $subsection_name ] = $pretty
1122
+					? $subsection->pretty_value()
1123
+					: $subsection->normalized_value();
1124
+			} elseif ($subsection instanceof EE_Form_Section_Proper && $include_subform_inputs) {
1125
+				$subform_input_values = $subsection->_input_values(
1126
+					$pretty,
1127
+					$include_subform_inputs,
1128
+					$flatten
1129
+				);
1130
+				if ($flatten) {
1131
+					$input_values = array_merge($input_values, $subform_input_values);
1132
+				} else {
1133
+					$input_values[ $subsection_name ] = $subform_input_values;
1134
+				}
1135
+			}
1136
+		}
1137
+		return $input_values;
1138
+	}
1139
+
1140
+
1141
+	/**
1142
+	 * Gets the originally submitted input values from the form
1143
+	 *
1144
+	 * @param boolean $include_subforms  Whether to include inputs from subforms,
1145
+	 *                                   or just this forms' direct children inputs
1146
+	 * @return array                     if $flatten is TRUE it will always be a 1-dimensional array
1147
+	 *                                   with array keys being input names
1148
+	 *                                   (regardless of whether they are from a subsection or not),
1149
+	 *                                   and if $flatten is FALSE it can be a multidimensional array
1150
+	 *                                   where keys are always subsection names and values are either
1151
+	 *                                   the input's normalized value, or an array like the top-level array
1152
+	 * @throws EE_Error
1153
+	 */
1154
+	public function submitted_values($include_subforms = false)
1155
+	{
1156
+		$submitted_values = array();
1157
+		foreach ($this->subsections() as $subsection) {
1158
+			if ($subsection instanceof EE_Form_Input_Base) {
1159
+				// is this input part of an array of inputs?
1160
+				if (strpos($subsection->html_name(), '[') !== false) {
1161
+					$full_input_name  = EEH_Array::convert_array_values_to_keys(
1162
+						explode(
1163
+							'[',
1164
+							str_replace(']', '', $subsection->html_name())
1165
+						),
1166
+						$subsection->raw_value()
1167
+					);
1168
+					$submitted_values = array_replace_recursive($submitted_values, $full_input_name);
1169
+				} else {
1170
+					$submitted_values[ $subsection->html_name() ] = $subsection->raw_value();
1171
+				}
1172
+			} elseif ($subsection instanceof EE_Form_Section_Proper && $include_subforms) {
1173
+				$subform_input_values = $subsection->submitted_values($include_subforms);
1174
+				$submitted_values     = array_replace_recursive($submitted_values, $subform_input_values);
1175
+			}
1176
+		}
1177
+		return $submitted_values;
1178
+	}
1179
+
1180
+
1181
+	/**
1182
+	 * Indicates whether or not this form has received a submission yet
1183
+	 * (ie, had receive_form_submission called on it yet)
1184
+	 *
1185
+	 * @return boolean
1186
+	 * @throws EE_Error
1187
+	 */
1188
+	public function has_received_submission()
1189
+	{
1190
+		$this->ensure_construct_finalized_called();
1191
+		return $this->_received_submission;
1192
+	}
1193
+
1194
+
1195
+	/**
1196
+	 * Equivalent to passing 'exclude' in the constructor's options array.
1197
+	 * Removes the listed inputs from the form
1198
+	 *
1199
+	 * @param array $inputs_to_exclude values are the input names
1200
+	 * @return void
1201
+	 */
1202
+	public function exclude(array $inputs_to_exclude = array())
1203
+	{
1204
+		foreach ($inputs_to_exclude as $input_to_exclude_name) {
1205
+			unset($this->_subsections[ $input_to_exclude_name ]);
1206
+		}
1207
+	}
1208
+
1209
+
1210
+	/**
1211
+	 * Changes these inputs' display strategy to be EE_Hidden_Display_Strategy.
1212
+	 * @param array $inputs_to_hide
1213
+	 * @throws EE_Error
1214
+	 */
1215
+	public function hide(array $inputs_to_hide = array())
1216
+	{
1217
+		foreach ($inputs_to_hide as $input_to_hide) {
1218
+			$input = $this->get_input($input_to_hide);
1219
+			$input->set_display_strategy(new EE_Hidden_Display_Strategy());
1220
+		}
1221
+	}
1222
+
1223
+
1224
+	/**
1225
+	 * add_subsections
1226
+	 * Adds the listed subsections to the form section.
1227
+	 * If $subsection_name_to_target is provided,
1228
+	 * then new subsections are added before or after that subsection,
1229
+	 * otherwise to the start or end of the entire subsections array.
1230
+	 *
1231
+	 * @param EE_Form_Section_Base[] $new_subsections           array of new form subsections
1232
+	 *                                                          where keys are their names
1233
+	 * @param string                 $subsection_name_to_target an existing for section that $new_subsections
1234
+	 *                                                          should be added before or after
1235
+	 *                                                          IF $subsection_name_to_target is null,
1236
+	 *                                                          then $new_subsections will be added to
1237
+	 *                                                          the beginning or end of the entire subsections array
1238
+	 * @param boolean                $add_before                whether to add $new_subsections, before or after
1239
+	 *                                                          $subsection_name_to_target,
1240
+	 *                                                          or if $subsection_name_to_target is null,
1241
+	 *                                                          before or after entire subsections array
1242
+	 * @return void
1243
+	 * @throws EE_Error
1244
+	 */
1245
+	public function add_subsections($new_subsections, $subsection_name_to_target = null, $add_before = true)
1246
+	{
1247
+		foreach ($new_subsections as $subsection_name => $subsection) {
1248
+			if (! $subsection instanceof EE_Form_Section_Base) {
1249
+				EE_Error::add_error(
1250
+					sprintf(
1251
+						esc_html__(
1252
+							"Trying to add a %s as a subsection (it was named '%s') to the form section '%s'. It was removed.",
1253
+							'event_espresso'
1254
+						),
1255
+						get_class($subsection),
1256
+						$subsection_name,
1257
+						$this->name()
1258
+					)
1259
+				);
1260
+				unset($new_subsections[ $subsection_name ]);
1261
+			}
1262
+		}
1263
+		$this->_subsections = EEH_Array::insert_into_array(
1264
+			$this->_subsections,
1265
+			$new_subsections,
1266
+			$subsection_name_to_target,
1267
+			$add_before
1268
+		);
1269
+		if ($this->_construction_finalized) {
1270
+			foreach ($this->_subsections as $name => $subsection) {
1271
+				$subsection->_construct_finalize($this, $name);
1272
+			}
1273
+		}
1274
+	}
1275
+
1276
+
1277
+	/**
1278
+	 * @param string $subsection_name
1279
+	 * @param bool   $recursive
1280
+	 * @return bool
1281
+	 */
1282
+	public function has_subsection($subsection_name, $recursive = false)
1283
+	{
1284
+		foreach ($this->_subsections as $name => $subsection) {if(
1285
+				$name === $subsection_name
1286
+				|| (
1287
+					$recursive
1288
+					&& $subsection instanceof EE_Form_Section_Proper
1289
+					&& $subsection->has_subsection($subsection_name, $recursive)
1290
+				)
1291
+			) {
1292
+				return true;
1293
+			}
1294
+		}
1295
+		return false;
1296
+	}
1297
+
1298
+
1299
+
1300
+	/**
1301
+	 * Just gets all validatable subsections to clean their sensitive data
1302
+	 *
1303
+	 * @throws EE_Error
1304
+	 */
1305
+	public function clean_sensitive_data()
1306
+	{
1307
+		foreach ($this->get_validatable_subsections() as $subsection) {
1308
+			$subsection->clean_sensitive_data();
1309
+		}
1310
+	}
1311
+
1312
+
1313
+	/**
1314
+	 * Sets the submission error message (aka validation error message for this form section and all sub-sections)
1315
+	 * @param string                           $form_submission_error_message
1316
+	 * @param EE_Form_Section_Validatable $form_section unused
1317
+	 * @throws EE_Error
1318
+	 */
1319
+	public function set_submission_error_message(
1320
+		$form_submission_error_message = ''
1321
+	) {
1322
+		$this->_form_submission_error_message = ! empty($form_submission_error_message)
1323
+			? $form_submission_error_message
1324
+			: $this->getAllValidationErrorsString();
1325
+	}
1326
+
1327
+
1328
+	/**
1329
+	 * Returns the cached error message. A default value is set for this during _validate(),
1330
+	 * (called during receive_form_submission) but it can be explicitly set using
1331
+	 * set_submission_error_message
1332
+	 *
1333
+	 * @return string
1334
+	 */
1335
+	public function submission_error_message()
1336
+	{
1337
+		return $this->_form_submission_error_message;
1338
+	}
1339
+
1340
+
1341
+	/**
1342
+	 * Sets a message to display if the data submitted to the form was valid.
1343
+	 * @param string $form_submission_success_message
1344
+	 */
1345
+	public function set_submission_success_message($form_submission_success_message = '')
1346
+	{
1347
+		$this->_form_submission_success_message = ! empty($form_submission_success_message)
1348
+			? $form_submission_success_message
1349
+			: esc_html__('Form submitted successfully', 'event_espresso');
1350
+	}
1351
+
1352
+
1353
+	/**
1354
+	 * Gets a message appropriate for display when the form is correctly submitted
1355
+	 * @return string
1356
+	 */
1357
+	public function submission_success_message()
1358
+	{
1359
+		return $this->_form_submission_success_message;
1360
+	}
1361
+
1362
+
1363
+	/**
1364
+	 * Returns the prefix that should be used on child of this form section for
1365
+	 * their html names. If this form section itself has a parent, prepends ITS
1366
+	 * prefix onto this form section's prefix. Used primarily by
1367
+	 * EE_Form_Input_Base::_set_default_html_name_if_empty
1368
+	 *
1369
+	 * @return string
1370
+	 * @throws EE_Error
1371
+	 */
1372
+	public function html_name_prefix()
1373
+	{
1374
+		if ($this->parent_section() instanceof EE_Form_Section_Proper) {
1375
+			return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']';
1376
+		}
1377
+		return $this->name();
1378
+	}
1379
+
1380
+
1381
+	/**
1382
+	 * Gets the name, but first checks _construct_finalize has been called. If not,
1383
+	 * calls it (assumes there is no parent and that we want the name to be whatever
1384
+	 * was set, which is probably nothing, or the classname)
1385
+	 *
1386
+	 * @return string
1387
+	 * @throws EE_Error
1388
+	 */
1389
+	public function name()
1390
+	{
1391
+		$this->ensure_construct_finalized_called();
1392
+		return parent::name();
1393
+	}
1394
+
1395
+
1396
+	/**
1397
+	 * @return EE_Form_Section_Proper
1398
+	 * @throws EE_Error
1399
+	 */
1400
+	public function parent_section()
1401
+	{
1402
+		$this->ensure_construct_finalized_called();
1403
+		return parent::parent_section();
1404
+	}
1405
+
1406
+
1407
+	/**
1408
+	 * make sure construction finalized was called, otherwise children might not be ready
1409
+	 *
1410
+	 * @return void
1411
+	 * @throws EE_Error
1412
+	 */
1413
+	public function ensure_construct_finalized_called()
1414
+	{
1415
+		if (! $this->_construction_finalized) {
1416
+			$this->_construct_finalize($this->_parent_section, $this->_name);
1417
+		}
1418
+	}
1419
+
1420
+
1421
+	/**
1422
+	 * Checks if any of this form section's inputs, or any of its children's inputs,
1423
+	 * are in teh form data. If any are found, returns true. Else false
1424
+	 *
1425
+	 * @param array $req_data
1426
+	 * @return boolean
1427
+	 * @throws EE_Error
1428
+	 */
1429
+	public function form_data_present_in($req_data = null)
1430
+	{
1431
+		$req_data = $this->getCachedRequest($req_data);
1432
+		foreach ($this->subsections() as $subsection) {
1433
+			if ($subsection instanceof EE_Form_Input_Base) {
1434
+				if ($subsection->form_data_present_in($req_data)) {
1435
+					return true;
1436
+				}
1437
+			} elseif ($subsection instanceof EE_Form_Section_Proper) {
1438
+				if ($subsection->form_data_present_in($req_data)) {
1439
+					return true;
1440
+				}
1441
+			}
1442
+		}
1443
+		return false;
1444
+	}
1445
+
1446
+
1447
+	/**
1448
+	 * Gets validation errors for this form section and subsections
1449
+	 * Similar to EE_Form_Section_Validatable::get_validation_errors() except this
1450
+	 * gets the validation errors for ALL subsection
1451
+	 *
1452
+	 * @return EE_Validation_Error[]
1453
+	 * @throws EE_Error
1454
+	 */
1455
+	public function get_validation_errors_accumulated()
1456
+	{
1457
+		$validation_errors = $this->get_validation_errors();
1458
+		foreach ($this->get_validatable_subsections() as $subsection) {
1459
+			if ($subsection instanceof EE_Form_Section_Proper) {
1460
+				$validation_errors_on_this_subsection = $subsection->get_validation_errors_accumulated();
1461
+			} else {
1462
+				$validation_errors_on_this_subsection = $subsection->get_validation_errors();
1463
+			}
1464
+			if ($validation_errors_on_this_subsection) {
1465
+				$validation_errors = array_merge($validation_errors, $validation_errors_on_this_subsection);
1466
+			}
1467
+		}
1468
+		return $validation_errors;
1469
+	}
1470
+
1471
+	/**
1472
+	 * Fetch validation errors from children and grandchildren and puts them in a single string.
1473
+	 * This traverses the form section tree to generate this, but you probably want to instead use
1474
+	 * get_form_submission_error_message() which is usually this message cached (or a custom validation error message)
1475
+	 *
1476
+	 * @return string
1477
+	 * @since $VID:$
1478
+	 */
1479
+	protected function getAllValidationErrorsString()
1480
+	{
1481
+		$submission_error_messages = array();
1482
+		// bad, bad, bad registrant
1483
+		foreach ($this->get_validation_errors_accumulated() as $validation_error) {
1484
+			if ($validation_error instanceof EE_Validation_Error) {
1485
+				$form_section = $validation_error->get_form_section();
1486
+				if ($form_section instanceof EE_Form_Input_Base) {
1487
+				   $label = $validation_error->get_form_section()->html_label_text();
1488
+				} elseif($form_section instanceof EE_Form_Section_Validatable) {
1489
+					$label = $validation_error->get_form_section()->name();
1490
+				} else {
1491
+					$label = esc_html__('Unknown', 'event_espresso');
1492
+				}
1493
+				$submission_error_messages[] = sprintf(
1494
+					__('%s : %s', 'event_espresso'),
1495
+					$label,
1496
+					$validation_error->getMessage()
1497
+				);
1498
+			}
1499
+		}
1500
+		return implode('<br', $submission_error_messages);
1501
+	}
1502
+
1503
+
1504
+	/**
1505
+	 * This isn't just the name of an input, it's a path pointing to an input. The
1506
+	 * path is similar to a folder path: slash (/) means to descend into a subsection,
1507
+	 * dot-dot-slash (../) means to ascend into the parent section.
1508
+	 * After a series of slashes and dot-dot-slashes, there should be the name of an input,
1509
+	 * which will be returned.
1510
+	 * Eg, if you want the related input to be conditional on a sibling input name 'foobar'
1511
+	 * just use 'foobar'. If you want it to be conditional on an aunt/uncle input name
1512
+	 * 'baz', use '../baz'. If you want it to be conditional on a cousin input,
1513
+	 * the child of 'baz_section' named 'baz_child', use '../baz_section/baz_child'.
1514
+	 * Etc
1515
+	 *
1516
+	 * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false
1517
+	 * @return EE_Form_Section_Base
1518
+	 * @throws EE_Error
1519
+	 */
1520
+	public function find_section_from_path($form_section_path)
1521
+	{
1522
+		//check if we can find the input from purely going straight up the tree
1523
+		$input = parent::find_section_from_path($form_section_path);
1524
+		if ($input instanceof EE_Form_Section_Base) {
1525
+			return $input;
1526
+		}
1527
+		$next_slash_pos = strpos($form_section_path, '/');
1528
+		if ($next_slash_pos !== false) {
1529
+			$child_section_name = substr($form_section_path, 0, $next_slash_pos);
1530
+			$subpath            = substr($form_section_path, $next_slash_pos + 1);
1531
+		} else {
1532
+			$child_section_name = $form_section_path;
1533
+			$subpath            = '';
1534
+		}
1535
+		$child_section = $this->get_subsection($child_section_name);
1536
+		if ($child_section instanceof EE_Form_Section_Base) {
1537
+			return $child_section->find_section_from_path($subpath);
1538
+		}
1539
+		return null;
1540
+	}
1541 1541
 }
1542 1542
 
Please login to merge, or discard this patch.
core/services/request/Request.php 3 patches
Indentation   +584 added lines, -584 removed lines patch added patch discarded remove patch
@@ -20,590 +20,590 @@
 block discarded – undo
20 20
 class Request implements InterminableInterface, RequestInterface
21 21
 {
22 22
 
23
-    /**
24
-     * $_GET parameters
25
-     *
26
-     * @var array $get
27
-     */
28
-    private $get;
29
-
30
-    /**
31
-     * $_POST parameters
32
-     *
33
-     * @var array $post
34
-     */
35
-    private $post;
36
-
37
-    /**
38
-     * $_COOKIE parameters
39
-     *
40
-     * @var array $cookie
41
-     */
42
-    private $cookie;
43
-
44
-    /**
45
-     * $_SERVER parameters
46
-     *
47
-     * @var array $server
48
-     */
49
-    private $server;
50
-
51
-    /**
52
-     * $_REQUEST parameters
53
-     *
54
-     * @var array $request
55
-     */
56
-    private $request;
57
-
58
-    /**
59
-     * @var RequestTypeContextCheckerInterface
60
-     */
61
-    private $request_type;
62
-
63
-    /**
64
-     * IP address for request
65
-     *
66
-     * @var string $ip_address
67
-     */
68
-    private $ip_address;
69
-
70
-    /**
71
-     * @var string $user_agent
72
-     */
73
-    private $user_agent;
74
-
75
-    /**
76
-     * true if current user appears to be some kind of bot
77
-     *
78
-     * @var bool $is_bot
79
-     */
80
-    private $is_bot;
81
-
82
-
83
-
84
-    /**
85
-     * @param array                              $get
86
-     * @param array                              $post
87
-     * @param array                              $cookie
88
-     * @param array                              $server
89
-     */
90
-    public function __construct(array $get, array $post, array $cookie, array $server)
91
-    {
92
-        // grab request vars
93
-        $this->get        = $get;
94
-        $this->post       = $post;
95
-        $this->cookie     = $cookie;
96
-        $this->server     = $server;
97
-        $this->request    = array_merge($this->get, $this->post);
98
-        $this->ip_address = $this->visitorIp();
99
-    }
100
-
101
-
102
-    /**
103
-     * @param RequestTypeContextCheckerInterface $type
104
-     */
105
-    public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type)
106
-    {
107
-        $this->request_type = $type;
108
-    }
109
-
110
-
111
-
112
-    /**
113
-     * @return array
114
-     */
115
-    public function getParams()
116
-    {
117
-        return $this->get;
118
-    }
119
-
120
-
121
-
122
-    /**
123
-     * @return array
124
-     */
125
-    public function postParams()
126
-    {
127
-        return $this->post;
128
-    }
129
-
130
-
131
-
132
-    /**
133
-     * @return array
134
-     */
135
-    public function cookieParams()
136
-    {
137
-        return $this->cookie;
138
-    }
139
-
140
-
141
-    /**
142
-     * @return array
143
-     */
144
-    public function serverParams()
145
-    {
146
-        return $this->server;
147
-    }
148
-
149
-
150
-
151
-    /**
152
-     * returns contents of $_REQUEST
153
-     *
154
-     * @return array
155
-     */
156
-    public function requestParams()
157
-    {
158
-        return $this->request;
159
-    }
160
-
161
-
162
-
163
-    /**
164
-     * @param      $key
165
-     * @param      $value
166
-     * @param bool $override_ee
167
-     * @return    void
168
-     */
169
-    public function setRequestParam($key, $value, $override_ee = false)
170
-    {
171
-        // don't allow "ee" to be overwritten unless explicitly instructed to do so
172
-        if (
173
-            $key !== 'ee'
174
-            || ($key === 'ee' && empty($this->request['ee']))
175
-            || ($key === 'ee' && ! empty($this->request['ee']) && $override_ee)
176
-        ) {
177
-            $this->request[ $key ] = $value;
178
-        }
179
-    }
180
-
181
-
182
-
183
-    /**
184
-     * returns   the value for a request param if the given key exists
185
-     *
186
-     * @param       $key
187
-     * @param null  $default
188
-     * @return mixed
189
-     */
190
-    public function getRequestParam($key, $default = null)
191
-    {
192
-        return $this->requestParameterDrillDown($key, $default, 'get');
193
-    }
194
-
195
-
196
-
197
-    /**
198
-     * check if param exists
199
-     *
200
-     * @param       $key
201
-     * @return bool
202
-     */
203
-    public function requestParamIsSet($key)
204
-    {
205
-        return $this->requestParameterDrillDown($key);
206
-    }
207
-
208
-
209
-    /**
210
-     * check if a request parameter exists whose key that matches the supplied wildcard pattern
211
-     * and return the value for the first match found
212
-     * wildcards can be either of the following:
213
-     *      ? to represent a single character of any type
214
-     *      * to represent one or more characters of any type
215
-     *
216
-     * @param string     $pattern
217
-     * @param null|mixed $default
218
-     * @return false|int
219
-     */
220
-    public function getMatch($pattern, $default = null)
221
-    {
222
-        return $this->requestParameterDrillDown($pattern, $default, 'match');
223
-    }
224
-
225
-
226
-    /**
227
-     * check if a request parameter exists whose key matches the supplied wildcard pattern
228
-     * wildcards can be either of the following:
229
-     *      ? to represent a single character of any type
230
-     *      * to represent one or more characters of any type
231
-     * returns true if a match is found or false if not
232
-     *
233
-     * @param string $pattern
234
-     * @return false|int
235
-     */
236
-    public function matches($pattern)
237
-    {
238
-        return $this->requestParameterDrillDown($pattern, null, 'match') !== null;
239
-    }
240
-
241
-
242
-    /**
243
-     * @see https://stackoverflow.com/questions/6163055/php-string-matching-with-wildcard
244
-     * @param string $pattern               A string including wildcards to be converted to a regex pattern
245
-     *                                      and used to search through the current request's parameter keys
246
-     * @param array  $request_params        The array of request parameters to search through
247
-     * @param mixed  $default               [optional] The value to be returned if no match is found.
248
-     *                                      Default is null
249
-     * @param string $return                [optional] Controls what kind of value is returned.
250
-     *                                      Options are:
251
-     *                                      'bool' will return true or false if match is found or not
252
-     *                                      'key' will return the first key found that matches the supplied pattern
253
-     *                                      'value' will return the value for the first request parameter
254
-     *                                      whose key matches the supplied pattern
255
-     *                                      Default is 'value'
256
-     * @return boolean|string
257
-     */
258
-    private function match($pattern, array $request_params, $default = null, $return = 'value')
259
-    {
260
-        $return = in_array($return, array('bool', 'key', 'value'), true)
261
-            ? $return
262
-            : 'is_set';
263
-        // replace wildcard chars with regex chars
264
-        $pattern = str_replace(
265
-            array("\*", "\?"),
266
-            array('.*', '.'),
267
-            preg_quote($pattern, '/')
268
-        );
269
-        foreach ($request_params as $key => $request_param) {
270
-            if (preg_match('/^' . $pattern . '$/is', $key)) {
271
-                // return value for request param
272
-                if ($return === 'value') {
273
-                    return $request_params[ $key ];
274
-                }
275
-                // or actual key or true just to indicate it was found
276
-                return $return === 'key' ? $key : true;
277
-            }
278
-        }
279
-        // match not found so return default value or false
280
-        return $return === 'value' ? $default : false;
281
-    }
282
-
283
-
284
-    /**
285
-     * the supplied key can be a simple string to represent a "top-level" request parameter
286
-     * or represent a key for a request parameter that is nested deeper within the request parameter array,
287
-     * by using square brackets to surround keys for deeper array elements.
288
-     * For example :
289
-     * if the supplied $key was: "first[second][third]"
290
-     * then this will attempt to drill down into the request parameter array to find a value.
291
-     * Given the following request parameters:
292
-     *  array(
293
-     *      'first' => array(
294
-     *          'second' => array(
295
-     *              'third' => 'has a value'
296
-     *          )
297
-     *      )
298
-     *  )
299
-     * would return true if default parameters were set
300
-     *
301
-     * @param string $callback
302
-     * @param        $key
303
-     * @param null   $default
304
-     * @param array  $request_params
305
-     * @return bool|mixed|null
306
-     */
307
-    private function requestParameterDrillDown(
308
-        $key,
309
-        $default = null,
310
-        $callback = 'is_set',
311
-        array $request_params = array()
312
-    ) {
313
-        $callback       = in_array($callback, array('is_set', 'get', 'match'), true)
314
-            ? $callback
315
-            : 'is_set';
316
-        $request_params = ! empty($request_params)
317
-            ? $request_params
318
-            : $this->request;
319
-        // does incoming key represent an array like 'first[second][third]'  ?
320
-        if (strpos($key, '[') !== false) {
321
-            // turn it into an actual array
322
-            $key  = str_replace(']', '', $key);
323
-            $keys = explode('[', $key);
324
-            $key  = array_shift($keys);
325
-            if ($callback === 'match') {
326
-                $real_key = $this->match($key, $request_params, $default, 'key');
327
-                $key      = $real_key ? $real_key : $key;
328
-            }
329
-            // check if top level key exists
330
-            if (isset($request_params[ $key ])) {
331
-                // build a new key to pass along like: 'second[third]'
332
-                // or just 'second' depending on depth of keys
333
-                $key_string = array_shift($keys);
334
-                if (! empty($keys)) {
335
-                    $key_string .= '[' . implode('][', $keys) . ']';
336
-                }
337
-                return $this->requestParameterDrillDown(
338
-                    $key_string,
339
-                    $default,
340
-                    $callback,
341
-                    $request_params[ $key ]
342
-                );
343
-            }
344
-        }
345
-        if ($callback === 'is_set') {
346
-            return isset($request_params[ $key ]);
347
-        }
348
-        if ($callback === 'match') {
349
-            return $this->match($key, $request_params, $default);
350
-        }
351
-        return isset($request_params[ $key ])
352
-            ? $request_params[ $key ]
353
-            : $default;
354
-    }
355
-
356
-
357
-    /**
358
-     * remove param
359
-     *
360
-     * @param      $key
361
-     * @param bool $unset_from_global_too
362
-     */
363
-    public function unSetRequestParam($key, $unset_from_global_too = false)
364
-    {
365
-        unset($this->request[ $key ]);
366
-        if ($unset_from_global_too) {
367
-            unset($_REQUEST[ $key ]);
368
-        }
369
-    }
370
-
371
-
372
-
373
-    /**
374
-     * @return string
375
-     */
376
-    public function ipAddress()
377
-    {
378
-        return $this->ip_address;
379
-    }
380
-
381
-
382
-    /**
383
-     * attempt to get IP address of current visitor from server
384
-     * plz see: http://stackoverflow.com/a/2031935/1475279
385
-     *
386
-     * @access public
387
-     * @return string
388
-     */
389
-    private function visitorIp()
390
-    {
391
-        $visitor_ip  = '0.0.0.0';
392
-        $server_keys = array(
393
-            'HTTP_CLIENT_IP',
394
-            'HTTP_X_FORWARDED_FOR',
395
-            'HTTP_X_FORWARDED',
396
-            'HTTP_X_CLUSTER_CLIENT_IP',
397
-            'HTTP_FORWARDED_FOR',
398
-            'HTTP_FORWARDED',
399
-            'REMOTE_ADDR',
400
-        );
401
-        foreach ($server_keys as $key) {
402
-            if (isset($this->server[ $key ])) {
403
-                foreach (array_map('trim', explode(',', $this->server[ $key ])) as $ip) {
404
-                    if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) {
405
-                        $visitor_ip = $ip;
406
-                    }
407
-                }
408
-            }
409
-        }
410
-        return $visitor_ip;
411
-    }
412
-
413
-
414
-    /**
415
-     * @return string
416
-     */
417
-    public function requestUri()
418
-    {
419
-        $request_uri = filter_input(
420
-            INPUT_SERVER,
421
-            'REQUEST_URI',
422
-            FILTER_SANITIZE_URL,
423
-            FILTER_NULL_ON_FAILURE
424
-        );
425
-        if (empty($request_uri)) {
426
-            // fallback sanitization if the above fails
427
-            $request_uri = wp_sanitize_redirect($this->server['REQUEST_URI']);
428
-        }
429
-        return $request_uri;
430
-    }
431
-
432
-
433
-    /**
434
-     * @return string
435
-     */
436
-    public function userAgent()
437
-    {
438
-        return $this->user_agent;
439
-    }
440
-
441
-
442
-    /**
443
-     * @param string $user_agent
444
-     */
445
-    public function setUserAgent($user_agent = '')
446
-    {
447
-        if ($user_agent === '' || ! is_string($user_agent)) {
448
-            $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? (string) esc_attr($_SERVER['HTTP_USER_AGENT']) : '';
449
-        }
450
-        $this->user_agent = $user_agent;
451
-    }
452
-
453
-
454
-    /**
455
-     * @return bool
456
-     */
457
-    public function isBot()
458
-    {
459
-        return $this->is_bot;
460
-    }
461
-
462
-
463
-    /**
464
-     * @param bool $is_bot
465
-     */
466
-    public function setIsBot($is_bot)
467
-    {
468
-        $this->is_bot = filter_var($is_bot, FILTER_VALIDATE_BOOLEAN);
469
-    }
470
-
471
-
472
-    /**
473
-     * @return bool
474
-     */
475
-    public function isActivation()
476
-    {
477
-        return $this->request_type->isActivation();
478
-    }
479
-
480
-
481
-    /**
482
-     * @param $is_activation
483
-     * @return bool
484
-     */
485
-    public function setIsActivation($is_activation)
486
-    {
487
-        return $this->request_type->setIsActivation($is_activation);
488
-    }
489
-
490
-
491
-    /**
492
-     * @return bool
493
-     */
494
-    public function isAdmin()
495
-    {
496
-        return $this->request_type->isAdmin();
497
-    }
498
-
499
-
500
-    /**
501
-     * @return bool
502
-     */
503
-    public function isAdminAjax()
504
-    {
505
-        return $this->request_type->isAdminAjax();
506
-    }
507
-
508
-
509
-    /**
510
-     * @return bool
511
-     */
512
-    public function isAjax()
513
-    {
514
-        return $this->request_type->isAjax();
515
-    }
516
-
517
-
518
-    /**
519
-     * @return bool
520
-     */
521
-    public function isEeAjax()
522
-    {
523
-        return $this->request_type->isEeAjax();
524
-    }
525
-
526
-
527
-    /**
528
-     * @return bool
529
-     */
530
-    public function isOtherAjax()
531
-    {
532
-        return $this->request_type->isOtherAjax();
533
-    }
534
-
535
-
536
-    /**
537
-     * @return bool
538
-     */
539
-    public function isApi()
540
-    {
541
-        return $this->request_type->isApi();
542
-    }
543
-
544
-
545
-    /**
546
-     * @return bool
547
-     */
548
-    public function isCli()
549
-    {
550
-        return $this->request_type->isCli();
551
-    }
552
-
553
-
554
-    /**
555
-     * @return bool
556
-     */
557
-    public function isCron()
558
-    {
559
-        return $this->request_type->isCron();
560
-    }
561
-
562
-
563
-    /**
564
-     * @return bool
565
-     */
566
-    public function isFeed()
567
-    {
568
-        return $this->request_type->isFeed();
569
-    }
570
-
571
-
572
-    /**
573
-     * @return bool
574
-     */
575
-    public function isFrontend()
576
-    {
577
-        return $this->request_type->isFrontend();
578
-    }
579
-
580
-
581
-    /**
582
-     * @return bool
583
-     */
584
-    public function isFrontAjax()
585
-    {
586
-        return $this->request_type->isFrontAjax();
587
-    }
588
-
589
-
590
-
591
-    /**
592
-     * @return bool
593
-     */
594
-    public function isIframe()
595
-    {
596
-        return $this->request_type->isIframe();
597
-    }
598
-
599
-
600
-    /**
601
-     * @return string
602
-     */
603
-    public function slug()
604
-    {
605
-        return $this->request_type->slug();
606
-    }
23
+	/**
24
+	 * $_GET parameters
25
+	 *
26
+	 * @var array $get
27
+	 */
28
+	private $get;
29
+
30
+	/**
31
+	 * $_POST parameters
32
+	 *
33
+	 * @var array $post
34
+	 */
35
+	private $post;
36
+
37
+	/**
38
+	 * $_COOKIE parameters
39
+	 *
40
+	 * @var array $cookie
41
+	 */
42
+	private $cookie;
43
+
44
+	/**
45
+	 * $_SERVER parameters
46
+	 *
47
+	 * @var array $server
48
+	 */
49
+	private $server;
50
+
51
+	/**
52
+	 * $_REQUEST parameters
53
+	 *
54
+	 * @var array $request
55
+	 */
56
+	private $request;
57
+
58
+	/**
59
+	 * @var RequestTypeContextCheckerInterface
60
+	 */
61
+	private $request_type;
62
+
63
+	/**
64
+	 * IP address for request
65
+	 *
66
+	 * @var string $ip_address
67
+	 */
68
+	private $ip_address;
69
+
70
+	/**
71
+	 * @var string $user_agent
72
+	 */
73
+	private $user_agent;
74
+
75
+	/**
76
+	 * true if current user appears to be some kind of bot
77
+	 *
78
+	 * @var bool $is_bot
79
+	 */
80
+	private $is_bot;
81
+
82
+
83
+
84
+	/**
85
+	 * @param array                              $get
86
+	 * @param array                              $post
87
+	 * @param array                              $cookie
88
+	 * @param array                              $server
89
+	 */
90
+	public function __construct(array $get, array $post, array $cookie, array $server)
91
+	{
92
+		// grab request vars
93
+		$this->get        = $get;
94
+		$this->post       = $post;
95
+		$this->cookie     = $cookie;
96
+		$this->server     = $server;
97
+		$this->request    = array_merge($this->get, $this->post);
98
+		$this->ip_address = $this->visitorIp();
99
+	}
100
+
101
+
102
+	/**
103
+	 * @param RequestTypeContextCheckerInterface $type
104
+	 */
105
+	public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type)
106
+	{
107
+		$this->request_type = $type;
108
+	}
109
+
110
+
111
+
112
+	/**
113
+	 * @return array
114
+	 */
115
+	public function getParams()
116
+	{
117
+		return $this->get;
118
+	}
119
+
120
+
121
+
122
+	/**
123
+	 * @return array
124
+	 */
125
+	public function postParams()
126
+	{
127
+		return $this->post;
128
+	}
129
+
130
+
131
+
132
+	/**
133
+	 * @return array
134
+	 */
135
+	public function cookieParams()
136
+	{
137
+		return $this->cookie;
138
+	}
139
+
140
+
141
+	/**
142
+	 * @return array
143
+	 */
144
+	public function serverParams()
145
+	{
146
+		return $this->server;
147
+	}
148
+
149
+
150
+
151
+	/**
152
+	 * returns contents of $_REQUEST
153
+	 *
154
+	 * @return array
155
+	 */
156
+	public function requestParams()
157
+	{
158
+		return $this->request;
159
+	}
160
+
161
+
162
+
163
+	/**
164
+	 * @param      $key
165
+	 * @param      $value
166
+	 * @param bool $override_ee
167
+	 * @return    void
168
+	 */
169
+	public function setRequestParam($key, $value, $override_ee = false)
170
+	{
171
+		// don't allow "ee" to be overwritten unless explicitly instructed to do so
172
+		if (
173
+			$key !== 'ee'
174
+			|| ($key === 'ee' && empty($this->request['ee']))
175
+			|| ($key === 'ee' && ! empty($this->request['ee']) && $override_ee)
176
+		) {
177
+			$this->request[ $key ] = $value;
178
+		}
179
+	}
180
+
181
+
182
+
183
+	/**
184
+	 * returns   the value for a request param if the given key exists
185
+	 *
186
+	 * @param       $key
187
+	 * @param null  $default
188
+	 * @return mixed
189
+	 */
190
+	public function getRequestParam($key, $default = null)
191
+	{
192
+		return $this->requestParameterDrillDown($key, $default, 'get');
193
+	}
194
+
195
+
196
+
197
+	/**
198
+	 * check if param exists
199
+	 *
200
+	 * @param       $key
201
+	 * @return bool
202
+	 */
203
+	public function requestParamIsSet($key)
204
+	{
205
+		return $this->requestParameterDrillDown($key);
206
+	}
207
+
208
+
209
+	/**
210
+	 * check if a request parameter exists whose key that matches the supplied wildcard pattern
211
+	 * and return the value for the first match found
212
+	 * wildcards can be either of the following:
213
+	 *      ? to represent a single character of any type
214
+	 *      * to represent one or more characters of any type
215
+	 *
216
+	 * @param string     $pattern
217
+	 * @param null|mixed $default
218
+	 * @return false|int
219
+	 */
220
+	public function getMatch($pattern, $default = null)
221
+	{
222
+		return $this->requestParameterDrillDown($pattern, $default, 'match');
223
+	}
224
+
225
+
226
+	/**
227
+	 * check if a request parameter exists whose key matches the supplied wildcard pattern
228
+	 * wildcards can be either of the following:
229
+	 *      ? to represent a single character of any type
230
+	 *      * to represent one or more characters of any type
231
+	 * returns true if a match is found or false if not
232
+	 *
233
+	 * @param string $pattern
234
+	 * @return false|int
235
+	 */
236
+	public function matches($pattern)
237
+	{
238
+		return $this->requestParameterDrillDown($pattern, null, 'match') !== null;
239
+	}
240
+
241
+
242
+	/**
243
+	 * @see https://stackoverflow.com/questions/6163055/php-string-matching-with-wildcard
244
+	 * @param string $pattern               A string including wildcards to be converted to a regex pattern
245
+	 *                                      and used to search through the current request's parameter keys
246
+	 * @param array  $request_params        The array of request parameters to search through
247
+	 * @param mixed  $default               [optional] The value to be returned if no match is found.
248
+	 *                                      Default is null
249
+	 * @param string $return                [optional] Controls what kind of value is returned.
250
+	 *                                      Options are:
251
+	 *                                      'bool' will return true or false if match is found or not
252
+	 *                                      'key' will return the first key found that matches the supplied pattern
253
+	 *                                      'value' will return the value for the first request parameter
254
+	 *                                      whose key matches the supplied pattern
255
+	 *                                      Default is 'value'
256
+	 * @return boolean|string
257
+	 */
258
+	private function match($pattern, array $request_params, $default = null, $return = 'value')
259
+	{
260
+		$return = in_array($return, array('bool', 'key', 'value'), true)
261
+			? $return
262
+			: 'is_set';
263
+		// replace wildcard chars with regex chars
264
+		$pattern = str_replace(
265
+			array("\*", "\?"),
266
+			array('.*', '.'),
267
+			preg_quote($pattern, '/')
268
+		);
269
+		foreach ($request_params as $key => $request_param) {
270
+			if (preg_match('/^' . $pattern . '$/is', $key)) {
271
+				// return value for request param
272
+				if ($return === 'value') {
273
+					return $request_params[ $key ];
274
+				}
275
+				// or actual key or true just to indicate it was found
276
+				return $return === 'key' ? $key : true;
277
+			}
278
+		}
279
+		// match not found so return default value or false
280
+		return $return === 'value' ? $default : false;
281
+	}
282
+
283
+
284
+	/**
285
+	 * the supplied key can be a simple string to represent a "top-level" request parameter
286
+	 * or represent a key for a request parameter that is nested deeper within the request parameter array,
287
+	 * by using square brackets to surround keys for deeper array elements.
288
+	 * For example :
289
+	 * if the supplied $key was: "first[second][third]"
290
+	 * then this will attempt to drill down into the request parameter array to find a value.
291
+	 * Given the following request parameters:
292
+	 *  array(
293
+	 *      'first' => array(
294
+	 *          'second' => array(
295
+	 *              'third' => 'has a value'
296
+	 *          )
297
+	 *      )
298
+	 *  )
299
+	 * would return true if default parameters were set
300
+	 *
301
+	 * @param string $callback
302
+	 * @param        $key
303
+	 * @param null   $default
304
+	 * @param array  $request_params
305
+	 * @return bool|mixed|null
306
+	 */
307
+	private function requestParameterDrillDown(
308
+		$key,
309
+		$default = null,
310
+		$callback = 'is_set',
311
+		array $request_params = array()
312
+	) {
313
+		$callback       = in_array($callback, array('is_set', 'get', 'match'), true)
314
+			? $callback
315
+			: 'is_set';
316
+		$request_params = ! empty($request_params)
317
+			? $request_params
318
+			: $this->request;
319
+		// does incoming key represent an array like 'first[second][third]'  ?
320
+		if (strpos($key, '[') !== false) {
321
+			// turn it into an actual array
322
+			$key  = str_replace(']', '', $key);
323
+			$keys = explode('[', $key);
324
+			$key  = array_shift($keys);
325
+			if ($callback === 'match') {
326
+				$real_key = $this->match($key, $request_params, $default, 'key');
327
+				$key      = $real_key ? $real_key : $key;
328
+			}
329
+			// check if top level key exists
330
+			if (isset($request_params[ $key ])) {
331
+				// build a new key to pass along like: 'second[third]'
332
+				// or just 'second' depending on depth of keys
333
+				$key_string = array_shift($keys);
334
+				if (! empty($keys)) {
335
+					$key_string .= '[' . implode('][', $keys) . ']';
336
+				}
337
+				return $this->requestParameterDrillDown(
338
+					$key_string,
339
+					$default,
340
+					$callback,
341
+					$request_params[ $key ]
342
+				);
343
+			}
344
+		}
345
+		if ($callback === 'is_set') {
346
+			return isset($request_params[ $key ]);
347
+		}
348
+		if ($callback === 'match') {
349
+			return $this->match($key, $request_params, $default);
350
+		}
351
+		return isset($request_params[ $key ])
352
+			? $request_params[ $key ]
353
+			: $default;
354
+	}
355
+
356
+
357
+	/**
358
+	 * remove param
359
+	 *
360
+	 * @param      $key
361
+	 * @param bool $unset_from_global_too
362
+	 */
363
+	public function unSetRequestParam($key, $unset_from_global_too = false)
364
+	{
365
+		unset($this->request[ $key ]);
366
+		if ($unset_from_global_too) {
367
+			unset($_REQUEST[ $key ]);
368
+		}
369
+	}
370
+
371
+
372
+
373
+	/**
374
+	 * @return string
375
+	 */
376
+	public function ipAddress()
377
+	{
378
+		return $this->ip_address;
379
+	}
380
+
381
+
382
+	/**
383
+	 * attempt to get IP address of current visitor from server
384
+	 * plz see: http://stackoverflow.com/a/2031935/1475279
385
+	 *
386
+	 * @access public
387
+	 * @return string
388
+	 */
389
+	private function visitorIp()
390
+	{
391
+		$visitor_ip  = '0.0.0.0';
392
+		$server_keys = array(
393
+			'HTTP_CLIENT_IP',
394
+			'HTTP_X_FORWARDED_FOR',
395
+			'HTTP_X_FORWARDED',
396
+			'HTTP_X_CLUSTER_CLIENT_IP',
397
+			'HTTP_FORWARDED_FOR',
398
+			'HTTP_FORWARDED',
399
+			'REMOTE_ADDR',
400
+		);
401
+		foreach ($server_keys as $key) {
402
+			if (isset($this->server[ $key ])) {
403
+				foreach (array_map('trim', explode(',', $this->server[ $key ])) as $ip) {
404
+					if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) {
405
+						$visitor_ip = $ip;
406
+					}
407
+				}
408
+			}
409
+		}
410
+		return $visitor_ip;
411
+	}
412
+
413
+
414
+	/**
415
+	 * @return string
416
+	 */
417
+	public function requestUri()
418
+	{
419
+		$request_uri = filter_input(
420
+			INPUT_SERVER,
421
+			'REQUEST_URI',
422
+			FILTER_SANITIZE_URL,
423
+			FILTER_NULL_ON_FAILURE
424
+		);
425
+		if (empty($request_uri)) {
426
+			// fallback sanitization if the above fails
427
+			$request_uri = wp_sanitize_redirect($this->server['REQUEST_URI']);
428
+		}
429
+		return $request_uri;
430
+	}
431
+
432
+
433
+	/**
434
+	 * @return string
435
+	 */
436
+	public function userAgent()
437
+	{
438
+		return $this->user_agent;
439
+	}
440
+
441
+
442
+	/**
443
+	 * @param string $user_agent
444
+	 */
445
+	public function setUserAgent($user_agent = '')
446
+	{
447
+		if ($user_agent === '' || ! is_string($user_agent)) {
448
+			$user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? (string) esc_attr($_SERVER['HTTP_USER_AGENT']) : '';
449
+		}
450
+		$this->user_agent = $user_agent;
451
+	}
452
+
453
+
454
+	/**
455
+	 * @return bool
456
+	 */
457
+	public function isBot()
458
+	{
459
+		return $this->is_bot;
460
+	}
461
+
462
+
463
+	/**
464
+	 * @param bool $is_bot
465
+	 */
466
+	public function setIsBot($is_bot)
467
+	{
468
+		$this->is_bot = filter_var($is_bot, FILTER_VALIDATE_BOOLEAN);
469
+	}
470
+
471
+
472
+	/**
473
+	 * @return bool
474
+	 */
475
+	public function isActivation()
476
+	{
477
+		return $this->request_type->isActivation();
478
+	}
479
+
480
+
481
+	/**
482
+	 * @param $is_activation
483
+	 * @return bool
484
+	 */
485
+	public function setIsActivation($is_activation)
486
+	{
487
+		return $this->request_type->setIsActivation($is_activation);
488
+	}
489
+
490
+
491
+	/**
492
+	 * @return bool
493
+	 */
494
+	public function isAdmin()
495
+	{
496
+		return $this->request_type->isAdmin();
497
+	}
498
+
499
+
500
+	/**
501
+	 * @return bool
502
+	 */
503
+	public function isAdminAjax()
504
+	{
505
+		return $this->request_type->isAdminAjax();
506
+	}
507
+
508
+
509
+	/**
510
+	 * @return bool
511
+	 */
512
+	public function isAjax()
513
+	{
514
+		return $this->request_type->isAjax();
515
+	}
516
+
517
+
518
+	/**
519
+	 * @return bool
520
+	 */
521
+	public function isEeAjax()
522
+	{
523
+		return $this->request_type->isEeAjax();
524
+	}
525
+
526
+
527
+	/**
528
+	 * @return bool
529
+	 */
530
+	public function isOtherAjax()
531
+	{
532
+		return $this->request_type->isOtherAjax();
533
+	}
534
+
535
+
536
+	/**
537
+	 * @return bool
538
+	 */
539
+	public function isApi()
540
+	{
541
+		return $this->request_type->isApi();
542
+	}
543
+
544
+
545
+	/**
546
+	 * @return bool
547
+	 */
548
+	public function isCli()
549
+	{
550
+		return $this->request_type->isCli();
551
+	}
552
+
553
+
554
+	/**
555
+	 * @return bool
556
+	 */
557
+	public function isCron()
558
+	{
559
+		return $this->request_type->isCron();
560
+	}
561
+
562
+
563
+	/**
564
+	 * @return bool
565
+	 */
566
+	public function isFeed()
567
+	{
568
+		return $this->request_type->isFeed();
569
+	}
570
+
571
+
572
+	/**
573
+	 * @return bool
574
+	 */
575
+	public function isFrontend()
576
+	{
577
+		return $this->request_type->isFrontend();
578
+	}
579
+
580
+
581
+	/**
582
+	 * @return bool
583
+	 */
584
+	public function isFrontAjax()
585
+	{
586
+		return $this->request_type->isFrontAjax();
587
+	}
588
+
589
+
590
+
591
+	/**
592
+	 * @return bool
593
+	 */
594
+	public function isIframe()
595
+	{
596
+		return $this->request_type->isIframe();
597
+	}
598
+
599
+
600
+	/**
601
+	 * @return string
602
+	 */
603
+	public function slug()
604
+	{
605
+		return $this->request_type->slug();
606
+	}
607 607
 
608 608
 
609 609
 }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
             || ($key === 'ee' && empty($this->request['ee']))
175 175
             || ($key === 'ee' && ! empty($this->request['ee']) && $override_ee)
176 176
         ) {
177
-            $this->request[ $key ] = $value;
177
+            $this->request[$key] = $value;
178 178
         }
179 179
     }
180 180
 
@@ -267,10 +267,10 @@  discard block
 block discarded – undo
267 267
             preg_quote($pattern, '/')
268 268
         );
269 269
         foreach ($request_params as $key => $request_param) {
270
-            if (preg_match('/^' . $pattern . '$/is', $key)) {
270
+            if (preg_match('/^'.$pattern.'$/is', $key)) {
271 271
                 // return value for request param
272 272
                 if ($return === 'value') {
273
-                    return $request_params[ $key ];
273
+                    return $request_params[$key];
274 274
                 }
275 275
                 // or actual key or true just to indicate it was found
276 276
                 return $return === 'key' ? $key : true;
@@ -327,29 +327,29 @@  discard block
 block discarded – undo
327 327
                 $key      = $real_key ? $real_key : $key;
328 328
             }
329 329
             // check if top level key exists
330
-            if (isset($request_params[ $key ])) {
330
+            if (isset($request_params[$key])) {
331 331
                 // build a new key to pass along like: 'second[third]'
332 332
                 // or just 'second' depending on depth of keys
333 333
                 $key_string = array_shift($keys);
334
-                if (! empty($keys)) {
335
-                    $key_string .= '[' . implode('][', $keys) . ']';
334
+                if ( ! empty($keys)) {
335
+                    $key_string .= '['.implode('][', $keys).']';
336 336
                 }
337 337
                 return $this->requestParameterDrillDown(
338 338
                     $key_string,
339 339
                     $default,
340 340
                     $callback,
341
-                    $request_params[ $key ]
341
+                    $request_params[$key]
342 342
                 );
343 343
             }
344 344
         }
345 345
         if ($callback === 'is_set') {
346
-            return isset($request_params[ $key ]);
346
+            return isset($request_params[$key]);
347 347
         }
348 348
         if ($callback === 'match') {
349 349
             return $this->match($key, $request_params, $default);
350 350
         }
351
-        return isset($request_params[ $key ])
352
-            ? $request_params[ $key ]
351
+        return isset($request_params[$key])
352
+            ? $request_params[$key]
353 353
             : $default;
354 354
     }
355 355
 
@@ -362,9 +362,9 @@  discard block
 block discarded – undo
362 362
      */
363 363
     public function unSetRequestParam($key, $unset_from_global_too = false)
364 364
     {
365
-        unset($this->request[ $key ]);
365
+        unset($this->request[$key]);
366 366
         if ($unset_from_global_too) {
367
-            unset($_REQUEST[ $key ]);
367
+            unset($_REQUEST[$key]);
368 368
         }
369 369
     }
370 370
 
@@ -399,8 +399,8 @@  discard block
 block discarded – undo
399 399
             'REMOTE_ADDR',
400 400
         );
401 401
         foreach ($server_keys as $key) {
402
-            if (isset($this->server[ $key ])) {
403
-                foreach (array_map('trim', explode(',', $this->server[ $key ])) as $ip) {
402
+            if (isset($this->server[$key])) {
403
+                foreach (array_map('trim', explode(',', $this->server[$key])) as $ip) {
404 404
                     if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) {
405 405
                         $visitor_ip = $ip;
406 406
                     }
Please login to merge, or discard this patch.
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
      *
186 186
      * @param       $key
187 187
      * @param null  $default
188
-     * @return mixed
188
+     * @return integer
189 189
      */
190 190
     public function getRequestParam($key, $default = null)
191 191
     {
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
      * returns true if a match is found or false if not
232 232
      *
233 233
      * @param string $pattern
234
-     * @return false|int
234
+     * @return boolean
235 235
      */
236 236
     public function matches($pattern)
237 237
     {
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
      * would return true if default parameters were set
300 300
      *
301 301
      * @param string $callback
302
-     * @param        $key
302
+     * @param        string $key
303 303
      * @param null   $default
304 304
      * @param array  $request_params
305 305
      * @return bool|mixed|null
Please login to merge, or discard this patch.
core/services/request/RequestInterface.php 1 patch
Indentation   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -20,139 +20,139 @@
 block discarded – undo
20 20
 interface RequestInterface extends RequestTypeContextCheckerInterface
21 21
 {
22 22
 
23
-    /**
24
-     * @param RequestTypeContextCheckerInterface $type
25
-     */
26
-    public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type);
27
-
28
-    /**
29
-     * @return array
30
-     */
31
-    public function getParams();
32
-
33
-
34
-    /**
35
-     * @return array
36
-     */
37
-    public function postParams();
38
-
39
-
40
-    /**
41
-     * @return array
42
-     */
43
-    public function cookieParams();
44
-
45
-
46
-    /**
47
-     * @return array
48
-     */
49
-    public function serverParams();
50
-
51
-
52
-    /**
53
-     * returns contents of $_REQUEST
54
-     *
55
-     * @return array
56
-     */
57
-    public function requestParams();
23
+	/**
24
+	 * @param RequestTypeContextCheckerInterface $type
25
+	 */
26
+	public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type);
27
+
28
+	/**
29
+	 * @return array
30
+	 */
31
+	public function getParams();
32
+
33
+
34
+	/**
35
+	 * @return array
36
+	 */
37
+	public function postParams();
38
+
39
+
40
+	/**
41
+	 * @return array
42
+	 */
43
+	public function cookieParams();
44
+
45
+
46
+	/**
47
+	 * @return array
48
+	 */
49
+	public function serverParams();
50
+
51
+
52
+	/**
53
+	 * returns contents of $_REQUEST
54
+	 *
55
+	 * @return array
56
+	 */
57
+	public function requestParams();
58 58
 
59 59
 
60
-    /**
61
-     * @param string $key
62
-     * @param string $value
63
-     * @param bool   $override_ee
64
-     * @return    void
65
-     */
66
-    public function setRequestParam($key, $value, $override_ee = false);
60
+	/**
61
+	 * @param string $key
62
+	 * @param string $value
63
+	 * @param bool   $override_ee
64
+	 * @return    void
65
+	 */
66
+	public function setRequestParam($key, $value, $override_ee = false);
67 67
 
68 68
 
69
-    /**
70
-     * returns the value for a request param if the given key exists
71
-     *
72
-     * @param string $key
73
-     * @param null   $default
74
-     * @return mixed
75
-     */
76
-    public function getRequestParam($key, $default = null);
69
+	/**
70
+	 * returns the value for a request param if the given key exists
71
+	 *
72
+	 * @param string $key
73
+	 * @param null   $default
74
+	 * @return mixed
75
+	 */
76
+	public function getRequestParam($key, $default = null);
77 77
 
78 78
 
79
-    /**
80
-     * check if param exists
81
-     *
82
-     * @param string $key
83
-     * @return bool
84
-     */
85
-    public function requestParamIsSet($key);
79
+	/**
80
+	 * check if param exists
81
+	 *
82
+	 * @param string $key
83
+	 * @return bool
84
+	 */
85
+	public function requestParamIsSet($key);
86 86
 
87 87
 
88
-    /**
89
-     * check if a request parameter exists whose key that matches the supplied wildcard pattern
90
-     * and return the value for the first match found
91
-     * wildcards can be either of the following:
92
-     *      ? to represent a single character of any type
93
-     *      * to represent one or more characters of any type
94
-     *
95
-     * @param string     $pattern
96
-     * @param null|mixed $default
97
-     * @return false|int
98
-     */
99
-    public function getMatch($pattern, $default = null);
88
+	/**
89
+	 * check if a request parameter exists whose key that matches the supplied wildcard pattern
90
+	 * and return the value for the first match found
91
+	 * wildcards can be either of the following:
92
+	 *      ? to represent a single character of any type
93
+	 *      * to represent one or more characters of any type
94
+	 *
95
+	 * @param string     $pattern
96
+	 * @param null|mixed $default
97
+	 * @return false|int
98
+	 */
99
+	public function getMatch($pattern, $default = null);
100 100
 
101 101
 
102
-    /**
103
-     * check if a request parameter exists whose key matches the supplied wildcard pattern
104
-     * wildcards can be either of the following:
105
-     *      ? to represent a single character of any type
106
-     *      * to represent one or more characters of any type
107
-     * returns true if a match is found or false if not
108
-     *
109
-     * @param string $pattern
110
-     * @return false|int
111
-     */
112
-    public function matches($pattern);
102
+	/**
103
+	 * check if a request parameter exists whose key matches the supplied wildcard pattern
104
+	 * wildcards can be either of the following:
105
+	 *      ? to represent a single character of any type
106
+	 *      * to represent one or more characters of any type
107
+	 * returns true if a match is found or false if not
108
+	 *
109
+	 * @param string $pattern
110
+	 * @return false|int
111
+	 */
112
+	public function matches($pattern);
113 113
 
114 114
 
115
-    /**
116
-     * remove param
117
-     *
118
-     * @param string $key
119
-     * @param bool   $unset_from_global_too
120
-     */
121
-    public function unSetRequestParam($key, $unset_from_global_too = false);
115
+	/**
116
+	 * remove param
117
+	 *
118
+	 * @param string $key
119
+	 * @param bool   $unset_from_global_too
120
+	 */
121
+	public function unSetRequestParam($key, $unset_from_global_too = false);
122 122
 
123 123
 
124
-    /**
125
-     * @return string
126
-     */
127
-    public function ipAddress();
124
+	/**
125
+	 * @return string
126
+	 */
127
+	public function ipAddress();
128 128
 
129 129
 
130
-    /**
131
-     * @return string
132
-     */
133
-    public function requestUri();
134
-
130
+	/**
131
+	 * @return string
132
+	 */
133
+	public function requestUri();
134
+
135 135
 
136
-    /**
137
-     * @return string
138
-     */
139
-    public function userAgent();
140
-
141
-
142
-    /**
143
-     * @param string $user_agent
144
-     */
145
-    public function setUserAgent($user_agent = '');
146
-
147
-
148
-    /**
149
-     * @return bool
150
-     */
151
-    public function isBot();
152
-
153
-
154
-    /**
155
-     * @param bool $is_bot
156
-     */
157
-    public function setIsBot($is_bot);
136
+	/**
137
+	 * @return string
138
+	 */
139
+	public function userAgent();
140
+
141
+
142
+	/**
143
+	 * @param string $user_agent
144
+	 */
145
+	public function setUserAgent($user_agent = '');
146
+
147
+
148
+	/**
149
+	 * @return bool
150
+	 */
151
+	public function isBot();
152
+
153
+
154
+	/**
155
+	 * @param bool $is_bot
156
+	 */
157
+	public function setIsBot($is_bot);
158 158
 }
Please login to merge, or discard this patch.
core/domain/services/admin/PluginUpsells.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -83,12 +83,12 @@
 block discarded – undo
83 83
                     <div class="notice inline notice-alt">
84 84
                         <div class="ee-upsell-container">
85 85
                             <div class="ee-upsell-inner-container">
86
-                                <a href="' . $button_url . '">
87
-                                    ' . $button_text . '
86
+                                <a href="' . $button_url.'">
87
+                                    ' . $button_text.'
88 88
                                 </a>
89 89
                             </div>
90 90
                             <div class="ee-upsell-inner-container">
91
-                                <p>' . $upsell_text . '</p>
91
+                                <p>' . $upsell_text.'</p>
92 92
                             </div>
93 93
                             <div style="clear:both"></div>
94 94
                         </div>
Please login to merge, or discard this patch.
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -16,46 +16,46 @@  discard block
 block discarded – undo
16 16
 class PluginUpsells
17 17
 {
18 18
 
19
-    /**
20
-     * @var DomainInterface
21
-     */
22
-    private $domain;
19
+	/**
20
+	 * @var DomainInterface
21
+	 */
22
+	private $domain;
23 23
 
24 24
 
25
-    /**
26
-     * PluginUpsells constructor.
27
-     *
28
-     * @param DomainInterface $domain
29
-     */
30
-    public function __construct(DomainInterface $domain)
31
-    {
32
-        $this->domain = $domain;
33
-    }
25
+	/**
26
+	 * PluginUpsells constructor.
27
+	 *
28
+	 * @param DomainInterface $domain
29
+	 */
30
+	public function __construct(DomainInterface $domain)
31
+	{
32
+		$this->domain = $domain;
33
+	}
34 34
 
35 35
 
36
-    /**
37
-     * Hook in various upsells for the decaf version of EE.
38
-     */
39
-    public function decafUpsells()
40
-    {
41
-        if ($this->domain instanceof CaffeinatedInterface && ! $this->domain->isCaffeinated()) {
42
-            add_action('after_plugin_row', array($this, 'doPremiumUpsell'), 10, 3);
43
-        }
44
-    }
36
+	/**
37
+	 * Hook in various upsells for the decaf version of EE.
38
+	 */
39
+	public function decafUpsells()
40
+	{
41
+		if ($this->domain instanceof CaffeinatedInterface && ! $this->domain->isCaffeinated()) {
42
+			add_action('after_plugin_row', array($this, 'doPremiumUpsell'), 10, 3);
43
+		}
44
+	}
45 45
 
46 46
 
47
-    /**
48
-     * Callback for `after_plugin_row` to add upsell info
49
-     * @param string $plugin_file
50
-     * @param array $plugin_data
51
-     * @param string $status
52
-     * @throws DomainException
53
-     */
54
-    public function doPremiumUpsell($plugin_file, $plugin_data, $status)
55
-    {
56
-        if ($plugin_file === $this->domain->pluginBasename()) {
57
-            list($button_text, $button_url, $upsell_text) = $this->getAfterPluginRowDetails();
58
-            echo '<tr class="plugin-update-tr ee-upsell-plugin-list-table active">
47
+	/**
48
+	 * Callback for `after_plugin_row` to add upsell info
49
+	 * @param string $plugin_file
50
+	 * @param array $plugin_data
51
+	 * @param string $status
52
+	 * @throws DomainException
53
+	 */
54
+	public function doPremiumUpsell($plugin_file, $plugin_data, $status)
55
+	{
56
+		if ($plugin_file === $this->domain->pluginBasename()) {
57
+			list($button_text, $button_url, $upsell_text) = $this->getAfterPluginRowDetails();
58
+			echo '<tr class="plugin-update-tr ee-upsell-plugin-list-table active">
59 59
                 <td colspan="3" class="plugin-update colspanchange">
60 60
                     <div class="notice inline notice-alt">
61 61
                         <div class="ee-upsell-container">
@@ -72,26 +72,26 @@  discard block
 block discarded – undo
72 72
                     </div>
73 73
                 </td>
74 74
               </tr>';
75
-        }
76
-    }
75
+		}
76
+	}
77 77
 
78
-    /**
79
-     * Provide the details used for the upsell container.
80
-     * @return array
81
-     */
82
-    protected function getAfterPluginRowDetails()
83
-    {
84
-        return array(
85
-            esc_html__('Upgrade for Support', 'event_espresso'),
86
-            'https://eventespresso.com/purchase/?slug=ee4-license-personal&utm_source=wp_admin_plugins_screen&utm_medium=link&utm_campaign=plugins_screen_upgrade_link" class="button button-primary',
87
-            sprintf(
88
-                esc_html__(
89
-                    'You\'re missing out on %1$sexpert support%2$s and %1$sone-click updates%2$s! Don\'t have an Event Espresso support license key? Support the project and buy one today!',
90
-                    'event_espresso'
91
-                ),
92
-                '<strong>',
93
-                '</strong>'
94
-            )
95
-        );
96
-    }
78
+	/**
79
+	 * Provide the details used for the upsell container.
80
+	 * @return array
81
+	 */
82
+	protected function getAfterPluginRowDetails()
83
+	{
84
+		return array(
85
+			esc_html__('Upgrade for Support', 'event_espresso'),
86
+			'https://eventespresso.com/purchase/?slug=ee4-license-personal&utm_source=wp_admin_plugins_screen&utm_medium=link&utm_campaign=plugins_screen_upgrade_link" class="button button-primary',
87
+			sprintf(
88
+				esc_html__(
89
+					'You\'re missing out on %1$sexpert support%2$s and %1$sone-click updates%2$s! Don\'t have an Event Espresso support license key? Support the project and buy one today!',
90
+					'event_espresso'
91
+				),
92
+				'<strong>',
93
+				'</strong>'
94
+			)
95
+		);
96
+	}
97 97
 }
Please login to merge, or discard this patch.
core/EE_Dependency_Map.core.php 2 patches
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 use EventEspresso\core\services\request\RequestInterface;
8 8
 use EventEspresso\core\services\request\ResponseInterface;
9 9
 
10
-if (! defined('EVENT_ESPRESSO_VERSION')) {
10
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
11 11
     exit('No direct script access allowed');
12 12
 }
13 13
 
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
      */
130 130
     public static function instance() {
131 131
         // check if class object is instantiated, and instantiated properly
132
-        if (! self::$_instance instanceof EE_Dependency_Map) {
132
+        if ( ! self::$_instance instanceof EE_Dependency_Map) {
133 133
             self::$_instance = new EE_Dependency_Map(/*$request, $response, $legacy_request*/);
134 134
         }
135 135
         return self::$_instance;
@@ -211,8 +211,8 @@  discard block
 block discarded – undo
211 211
     ) {
212 212
         $class = trim($class, '\\');
213 213
         $registered = false;
214
-        if (empty(self::$_instance->_dependency_map[ $class ])) {
215
-            self::$_instance->_dependency_map[ $class ] = array();
214
+        if (empty(self::$_instance->_dependency_map[$class])) {
215
+            self::$_instance->_dependency_map[$class] = array();
216 216
         }
217 217
         // we need to make sure that any aliases used when registering a dependency
218 218
         // get resolved to the correct class name
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
             $alias = self::$_instance->get_alias($dependency);
221 221
             if (
222 222
                 $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
223
-                || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
223
+                || ! isset(self::$_instance->_dependency_map[$class][$alias])
224 224
             ) {
225 225
                 unset($dependencies[$dependency]);
226 226
                 $dependencies[$alias] = $load_source;
@@ -233,13 +233,13 @@  discard block
 block discarded – undo
233 233
         // ie: with A = B + C, entries in B take precedence over duplicate entries in C
234 234
         // Union is way faster than array_merge() but should be used with caution...
235 235
         // especially with numerically indexed arrays
236
-        $dependencies += self::$_instance->_dependency_map[ $class ];
236
+        $dependencies += self::$_instance->_dependency_map[$class];
237 237
         // now we need to ensure that the resulting dependencies
238 238
         // array only has the entries that are required for the class
239 239
         // so first count how many dependencies were originally registered for the class
240
-        $dependency_count = count(self::$_instance->_dependency_map[ $class ]);
240
+        $dependency_count = count(self::$_instance->_dependency_map[$class]);
241 241
         // if that count is non-zero (meaning dependencies were already registered)
242
-        self::$_instance->_dependency_map[ $class ] = $dependency_count
242
+        self::$_instance->_dependency_map[$class] = $dependency_count
243 243
             // then truncate the  final array to match that count
244 244
             ? array_slice($dependencies, 0, $dependency_count)
245 245
             // otherwise just take the incoming array because nothing previously existed
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
      */
258 258
     public static function register_class_loader($class_name, $loader = 'load_core')
259 259
     {
260
-        if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
260
+        if ( ! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
261 261
             throw new DomainException(
262 262
                 esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
263 263
             );
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
             );
282 282
         }
283 283
         $class_name = self::$_instance->get_alias($class_name);
284
-        if (! isset(self::$_instance->_class_loaders[$class_name])) {
284
+        if ( ! isset(self::$_instance->_class_loaders[$class_name])) {
285 285
             self::$_instance->_class_loaders[$class_name] = $loader;
286 286
             return true;
287 287
         }
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
     public function class_loader($class_name)
367 367
     {
368 368
         // all legacy models use load_model()
369
-        if(strpos($class_name, 'EEM_') === 0){
369
+        if (strpos($class_name, 'EEM_') === 0) {
370 370
             return 'load_model';
371 371
         }
372 372
         $class_name = $this->get_alias($class_name);
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
     public function add_alias($class_name, $alias, $for_class = '')
396 396
     {
397 397
         if ($for_class !== '') {
398
-            if (! isset($this->_aliases[$for_class])) {
398
+            if ( ! isset($this->_aliases[$for_class])) {
399 399
                 $this->_aliases[$for_class] = array();
400 400
             }
401 401
             $this->_aliases[$for_class][$class_name] = $alias;
@@ -441,10 +441,10 @@  discard block
 block discarded – undo
441 441
      */
442 442
     public function get_alias($class_name = '', $for_class = '')
443 443
     {
444
-        if (! $this->has_alias($class_name, $for_class)) {
444
+        if ( ! $this->has_alias($class_name, $for_class)) {
445 445
             return $class_name;
446 446
         }
447
-        if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) {
447
+        if ($for_class !== '' && isset($this->_aliases[$for_class][$class_name])) {
448 448
             return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class);
449 449
         }
450 450
         return $this->get_alias($this->_aliases[$class_name]);
@@ -725,13 +725,13 @@  discard block
 block discarded – undo
725 725
             'EE_Front_Controller'      => 'load_core',
726 726
             'EE_Module_Request_Router' => 'load_core',
727 727
             'EE_Registry'              => 'load_core',
728
-            'EE_Request'               => function () use (&$legacy_request) {
728
+            'EE_Request'               => function() use (&$legacy_request) {
729 729
                 return $legacy_request;
730 730
             },
731
-            'EventEspresso\core\services\request\Request' => function () use (&$request) {
731
+            'EventEspresso\core\services\request\Request' => function() use (&$request) {
732 732
                 return $request;
733 733
             },
734
-            'EventEspresso\core\services\request\Response' => function () use (&$response) {
734
+            'EventEspresso\core\services\request\Response' => function() use (&$response) {
735 735
                 return $response;
736 736
             },
737 737
             'EE_Request_Handler'       => 'load_core',
@@ -753,7 +753,7 @@  discard block
 block discarded – undo
753 753
             'EE_Messages_Data_Handler_Collection'  => 'load_lib',
754 754
             'EE_Message_Template_Group_Collection' => 'load_lib',
755 755
             'EE_Payment_Method_Manager'            => 'load_lib',
756
-            'EE_Messages_Generator'                => function () {
756
+            'EE_Messages_Generator'                => function() {
757 757
                 return EE_Registry::instance()->load_lib(
758 758
                     'Messages_Generator',
759 759
                     array(),
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
                     false
762 762
                 );
763 763
             },
764
-            'EE_Messages_Template_Defaults'        => function ($arguments = array()) {
764
+            'EE_Messages_Template_Defaults'        => function($arguments = array()) {
765 765
                 return EE_Registry::instance()->load_lib(
766 766
                     'Messages_Template_Defaults',
767 767
                     $arguments,
@@ -774,25 +774,25 @@  discard block
 block discarded – undo
774 774
             // 'EEM_Message_Template_Group'           => 'load_model',
775 775
             // 'EEM_Message_Template'                 => 'load_model',
776 776
             //load_helper
777
-            'EEH_Parse_Shortcodes'                 => function () {
777
+            'EEH_Parse_Shortcodes'                 => function() {
778 778
                 if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
779 779
                     return new EEH_Parse_Shortcodes();
780 780
                 }
781 781
                 return null;
782 782
             },
783
-            'EE_Template_Config'                   => function () {
783
+            'EE_Template_Config'                   => function() {
784 784
                 return EE_Config::instance()->template_settings;
785 785
             },
786
-            'EE_Currency_Config'                   => function () {
786
+            'EE_Currency_Config'                   => function() {
787 787
                 return EE_Config::instance()->currency;
788 788
             },
789
-            'EE_Registration_Config'                   => function () {
789
+            'EE_Registration_Config'                   => function() {
790 790
                 return EE_Config::instance()->registration;
791 791
             },
792
-            'EE_Core_Config'                   => function () {
792
+            'EE_Core_Config'                   => function() {
793 793
                 return EE_Config::instance()->core;
794 794
             },
795
-            'EventEspresso\core\services\loaders\Loader' => function () {
795
+            'EventEspresso\core\services\loaders\Loader' => function() {
796 796
                 return LoaderFactory::getLoader();
797 797
             },
798 798
         );
@@ -848,7 +848,7 @@  discard block
 block discarded – undo
848 848
             'EventEspresso\core\services\request\ResponseInterface'               => 'EventEspresso\core\services\request\Response',
849 849
             'EventEspresso\core\domain\DomainInterface'                           => 'EventEspresso\core\domain\Domain',
850 850
         );
851
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
851
+        if ( ! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
852 852
             $this->_aliases['EventEspresso\core\services\notices\NoticeConverterInterface'] = 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices';
853 853
         }
854 854
     }
Please login to merge, or discard this patch.
Indentation   +862 added lines, -862 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 use EventEspresso\core\services\request\ResponseInterface;
9 9
 
10 10
 if (! defined('EVENT_ESPRESSO_VERSION')) {
11
-    exit('No direct script access allowed');
11
+	exit('No direct script access allowed');
12 12
 }
13 13
 
14 14
 
@@ -25,867 +25,867 @@  discard block
 block discarded – undo
25 25
 class EE_Dependency_Map
26 26
 {
27 27
 
28
-    /**
29
-     * This means that the requested class dependency is not present in the dependency map
30
-     */
31
-    const not_registered = 0;
32
-
33
-    /**
34
-     * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
35
-     */
36
-    const load_new_object = 1;
37
-
38
-    /**
39
-     * This instructs class loaders to return a previously instantiated and cached object for the requested class.
40
-     * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
41
-     */
42
-    const load_from_cache = 2;
43
-
44
-    /**
45
-     * When registering a dependency,
46
-     * this indicates to keep any existing dependencies that already exist,
47
-     * and simply discard any new dependencies declared in the incoming data
48
-     */
49
-    const KEEP_EXISTING_DEPENDENCIES = 0;
50
-
51
-    /**
52
-     * When registering a dependency,
53
-     * this indicates to overwrite any existing dependencies that already exist using the incoming data
54
-     */
55
-    const OVERWRITE_DEPENDENCIES = 1;
56
-
57
-
58
-
59
-    /**
60
-     * @type EE_Dependency_Map $_instance
61
-     */
62
-    protected static $_instance;
63
-
64
-    /**
65
-     * @type RequestInterface $request
66
-     */
67
-    protected $request;
68
-
69
-    /**
70
-     * @type LegacyRequestInterface $legacy_request
71
-     */
72
-    protected $legacy_request;
73
-
74
-    /**
75
-     * @type ResponseInterface $response
76
-     */
77
-    protected $response;
78
-
79
-    /**
80
-     * @type LoaderInterface $loader
81
-     */
82
-    protected $loader;
83
-
84
-    /**
85
-     * @type array $_dependency_map
86
-     */
87
-    protected $_dependency_map = array();
88
-
89
-    /**
90
-     * @type array $_class_loaders
91
-     */
92
-    protected $_class_loaders = array();
93
-
94
-    /**
95
-     * @type array $_aliases
96
-     */
97
-    protected $_aliases = array();
98
-
99
-
100
-
101
-    /**
102
-     * EE_Dependency_Map constructor.
103
-     */
104
-    protected function __construct()
105
-    {
106
-        // add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
107
-        do_action('EE_Dependency_Map____construct');
108
-    }
109
-
110
-
111
-
112
-    /**
113
-     * @throws InvalidDataTypeException
114
-     * @throws InvalidInterfaceException
115
-     * @throws InvalidArgumentException
116
-     */
117
-    public function initialize()
118
-    {
119
-        $this->_register_core_dependencies();
120
-        $this->_register_core_class_loaders();
121
-        $this->_register_core_aliases();
122
-    }
123
-
124
-
125
-
126
-    /**
127
-     * @singleton method used to instantiate class object
128
-     * @return EE_Dependency_Map
129
-     */
130
-    public static function instance() {
131
-        // check if class object is instantiated, and instantiated properly
132
-        if (! self::$_instance instanceof EE_Dependency_Map) {
133
-            self::$_instance = new EE_Dependency_Map(/*$request, $response, $legacy_request*/);
134
-        }
135
-        return self::$_instance;
136
-    }
137
-
138
-
139
-    /**
140
-     * @param RequestInterface $request
141
-     */
142
-    public function setRequest(RequestInterface $request)
143
-    {
144
-        $this->request = $request;
145
-    }
146
-
147
-
148
-    /**
149
-     * @param LegacyRequestInterface $legacy_request
150
-     */
151
-    public function setLegacyRequest(LegacyRequestInterface $legacy_request)
152
-    {
153
-        $this->legacy_request = $legacy_request;
154
-    }
155
-
156
-
157
-    /**
158
-     * @param ResponseInterface $response
159
-     */
160
-    public function setResponse(ResponseInterface $response)
161
-    {
162
-        $this->response = $response;
163
-    }
164
-
165
-
166
-
167
-    /**
168
-     * @param LoaderInterface $loader
169
-     */
170
-    public function setLoader(LoaderInterface $loader)
171
-    {
172
-        $this->loader = $loader;
173
-    }
174
-
175
-
176
-
177
-    /**
178
-     * @param string $class
179
-     * @param array  $dependencies
180
-     * @param int    $overwrite
181
-     * @return bool
182
-     */
183
-    public static function register_dependencies(
184
-        $class,
185
-        array $dependencies,
186
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
187
-    ) {
188
-        return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
189
-    }
190
-
191
-
192
-
193
-    /**
194
-     * Assigns an array of class names and corresponding load sources (new or cached)
195
-     * to the class specified by the first parameter.
196
-     * IMPORTANT !!!
197
-     * The order of elements in the incoming $dependencies array MUST match
198
-     * the order of the constructor parameters for the class in question.
199
-     * This is especially important when overriding any existing dependencies that are registered.
200
-     * the third parameter controls whether any duplicate dependencies are overwritten or not.
201
-     *
202
-     * @param string $class
203
-     * @param array  $dependencies
204
-     * @param int    $overwrite
205
-     * @return bool
206
-     */
207
-    public function registerDependencies(
208
-        $class,
209
-        array $dependencies,
210
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
211
-    ) {
212
-        $class = trim($class, '\\');
213
-        $registered = false;
214
-        if (empty(self::$_instance->_dependency_map[ $class ])) {
215
-            self::$_instance->_dependency_map[ $class ] = array();
216
-        }
217
-        // we need to make sure that any aliases used when registering a dependency
218
-        // get resolved to the correct class name
219
-        foreach ($dependencies as $dependency => $load_source) {
220
-            $alias = self::$_instance->get_alias($dependency);
221
-            if (
222
-                $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
223
-                || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
224
-            ) {
225
-                unset($dependencies[$dependency]);
226
-                $dependencies[$alias] = $load_source;
227
-                $registered = true;
228
-            }
229
-        }
230
-        // now add our two lists of dependencies together.
231
-        // using Union (+=) favours the arrays in precedence from left to right,
232
-        // so $dependencies is NOT overwritten because it is listed first
233
-        // ie: with A = B + C, entries in B take precedence over duplicate entries in C
234
-        // Union is way faster than array_merge() but should be used with caution...
235
-        // especially with numerically indexed arrays
236
-        $dependencies += self::$_instance->_dependency_map[ $class ];
237
-        // now we need to ensure that the resulting dependencies
238
-        // array only has the entries that are required for the class
239
-        // so first count how many dependencies were originally registered for the class
240
-        $dependency_count = count(self::$_instance->_dependency_map[ $class ]);
241
-        // if that count is non-zero (meaning dependencies were already registered)
242
-        self::$_instance->_dependency_map[ $class ] = $dependency_count
243
-            // then truncate the  final array to match that count
244
-            ? array_slice($dependencies, 0, $dependency_count)
245
-            // otherwise just take the incoming array because nothing previously existed
246
-            : $dependencies;
247
-        return $registered;
248
-    }
249
-
250
-
251
-
252
-    /**
253
-     * @param string $class_name
254
-     * @param string $loader
255
-     * @return bool
256
-     * @throws DomainException
257
-     */
258
-    public static function register_class_loader($class_name, $loader = 'load_core')
259
-    {
260
-        if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
261
-            throw new DomainException(
262
-                esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
263
-            );
264
-        }
265
-        // check that loader is callable or method starts with "load_" and exists in EE_Registry
266
-        if (
267
-            ! is_callable($loader)
268
-            && (
269
-                strpos($loader, 'load_') !== 0
270
-                || ! method_exists('EE_Registry', $loader)
271
-            )
272
-        ) {
273
-            throw new DomainException(
274
-                sprintf(
275
-                    esc_html__(
276
-                        '"%1$s" is not a valid loader method on EE_Registry.',
277
-                        'event_espresso'
278
-                    ),
279
-                    $loader
280
-                )
281
-            );
282
-        }
283
-        $class_name = self::$_instance->get_alias($class_name);
284
-        if (! isset(self::$_instance->_class_loaders[$class_name])) {
285
-            self::$_instance->_class_loaders[$class_name] = $loader;
286
-            return true;
287
-        }
288
-        return false;
289
-    }
290
-
291
-
292
-
293
-    /**
294
-     * @return array
295
-     */
296
-    public function dependency_map()
297
-    {
298
-        return $this->_dependency_map;
299
-    }
300
-
301
-
302
-
303
-    /**
304
-     * returns TRUE if dependency map contains a listing for the provided class name
305
-     *
306
-     * @param string $class_name
307
-     * @return boolean
308
-     */
309
-    public function has($class_name = '')
310
-    {
311
-        // all legacy models have the same dependencies
312
-        if (strpos($class_name, 'EEM_') === 0) {
313
-            $class_name = 'LEGACY_MODELS';
314
-        }
315
-        return isset($this->_dependency_map[$class_name]) ? true : false;
316
-    }
317
-
318
-
319
-
320
-    /**
321
-     * returns TRUE if dependency map contains a listing for the provided class name AND dependency
322
-     *
323
-     * @param string $class_name
324
-     * @param string $dependency
325
-     * @return bool
326
-     */
327
-    public function has_dependency_for_class($class_name = '', $dependency = '')
328
-    {
329
-        // all legacy models have the same dependencies
330
-        if (strpos($class_name, 'EEM_') === 0) {
331
-            $class_name = 'LEGACY_MODELS';
332
-        }
333
-        $dependency = $this->get_alias($dependency);
334
-        return isset($this->_dependency_map[$class_name][$dependency])
335
-            ? true
336
-            : false;
337
-    }
338
-
339
-
340
-
341
-    /**
342
-     * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
343
-     *
344
-     * @param string $class_name
345
-     * @param string $dependency
346
-     * @return int
347
-     */
348
-    public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
349
-    {
350
-        // all legacy models have the same dependencies
351
-        if (strpos($class_name, 'EEM_') === 0) {
352
-            $class_name = 'LEGACY_MODELS';
353
-        }
354
-        $dependency = $this->get_alias($dependency);
355
-        return $this->has_dependency_for_class($class_name, $dependency)
356
-            ? $this->_dependency_map[$class_name][$dependency]
357
-            : EE_Dependency_Map::not_registered;
358
-    }
359
-
360
-
361
-
362
-    /**
363
-     * @param string $class_name
364
-     * @return string | Closure
365
-     */
366
-    public function class_loader($class_name)
367
-    {
368
-        // all legacy models use load_model()
369
-        if(strpos($class_name, 'EEM_') === 0){
370
-            return 'load_model';
371
-        }
372
-        $class_name = $this->get_alias($class_name);
373
-        return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : '';
374
-    }
375
-
376
-
377
-
378
-    /**
379
-     * @return array
380
-     */
381
-    public function class_loaders()
382
-    {
383
-        return $this->_class_loaders;
384
-    }
385
-
386
-
387
-
388
-    /**
389
-     * adds an alias for a classname
390
-     *
391
-     * @param string $class_name the class name that should be used (concrete class to replace interface)
392
-     * @param string $alias      the class name that would be type hinted for (abstract parent or interface)
393
-     * @param string $for_class  the class that has the dependency (is type hinting for the interface)
394
-     */
395
-    public function add_alias($class_name, $alias, $for_class = '')
396
-    {
397
-        if ($for_class !== '') {
398
-            if (! isset($this->_aliases[$for_class])) {
399
-                $this->_aliases[$for_class] = array();
400
-            }
401
-            $this->_aliases[$for_class][$class_name] = $alias;
402
-        }
403
-        $this->_aliases[$class_name] = $alias;
404
-    }
405
-
406
-
407
-
408
-    /**
409
-     * returns TRUE if the provided class name has an alias
410
-     *
411
-     * @param string $class_name
412
-     * @param string $for_class
413
-     * @return bool
414
-     */
415
-    public function has_alias($class_name = '', $for_class = '')
416
-    {
417
-        return isset($this->_aliases[$for_class][$class_name])
418
-               || (
419
-                   isset($this->_aliases[$class_name])
420
-                   && ! is_array($this->_aliases[$class_name])
421
-               );
422
-    }
423
-
424
-
425
-
426
-    /**
427
-     * returns alias for class name if one exists, otherwise returns the original classname
428
-     * functions recursively, so that multiple aliases can be used to drill down to a classname
429
-     *  for example:
430
-     *      if the following two entries were added to the _aliases array:
431
-     *          array(
432
-     *              'interface_alias'           => 'some\namespace\interface'
433
-     *              'some\namespace\interface'  => 'some\namespace\classname'
434
-     *          )
435
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
436
-     *      to load an instance of 'some\namespace\classname'
437
-     *
438
-     * @param string $class_name
439
-     * @param string $for_class
440
-     * @return string
441
-     */
442
-    public function get_alias($class_name = '', $for_class = '')
443
-    {
444
-        if (! $this->has_alias($class_name, $for_class)) {
445
-            return $class_name;
446
-        }
447
-        if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) {
448
-            return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class);
449
-        }
450
-        return $this->get_alias($this->_aliases[$class_name]);
451
-    }
452
-
453
-
454
-
455
-    /**
456
-     * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
457
-     * if one exists, or whether a new object should be generated every time the requested class is loaded.
458
-     * This is done by using the following class constants:
459
-     *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
460
-     *        EE_Dependency_Map::load_new_object - generates a new object every time
461
-     */
462
-    protected function _register_core_dependencies()
463
-    {
464
-        $this->_dependency_map = array(
465
-            'EE_Request_Handler'                                                                                          => array(
466
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
467
-            ),
468
-            'EE_System'                                                                                                   => array(
469
-                'EE_Registry'                                 => EE_Dependency_Map::load_from_cache,
470
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
471
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
472
-                'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
473
-            ),
474
-            'EE_Session'                                                                                                  => array(
475
-                'EventEspresso\core\services\cache\TransientCacheStorage'  => EE_Dependency_Map::load_from_cache,
476
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
477
-                'EventEspresso\core\services\request\Request'              => EE_Dependency_Map::load_from_cache,
478
-                'EE_Encryption'                                            => EE_Dependency_Map::load_from_cache,
479
-            ),
480
-            'EE_Cart'                                                                                                     => array(
481
-                'EE_Session' => EE_Dependency_Map::load_from_cache,
482
-            ),
483
-            'EE_Front_Controller'                                                                                         => array(
484
-                'EE_Registry'              => EE_Dependency_Map::load_from_cache,
485
-                'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
486
-                'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
487
-            ),
488
-            'EE_Messenger_Collection_Loader'                                                                              => array(
489
-                'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
490
-            ),
491
-            'EE_Message_Type_Collection_Loader'                                                                           => array(
492
-                'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
493
-            ),
494
-            'EE_Message_Resource_Manager'                                                                                 => array(
495
-                'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
496
-                'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
497
-                'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
498
-            ),
499
-            'EE_Message_Factory'                                                                                          => array(
500
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
501
-            ),
502
-            'EE_messages'                                                                                                 => array(
503
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
504
-            ),
505
-            'EE_Messages_Generator'                                                                                       => array(
506
-                'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
507
-                'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
508
-                'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
509
-                'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
510
-            ),
511
-            'EE_Messages_Processor'                                                                                       => array(
512
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
513
-            ),
514
-            'EE_Messages_Queue'                                                                                           => array(
515
-                'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
516
-            ),
517
-            'EE_Messages_Template_Defaults'                                                                               => array(
518
-                'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
519
-                'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
520
-            ),
521
-            'EE_Message_To_Generate_From_Request'                                                                         => array(
522
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
523
-                'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
524
-            ),
525
-            'EventEspresso\core\services\commands\CommandBus'                                                             => array(
526
-                'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
527
-            ),
528
-            'EventEspresso\services\commands\CommandHandler'                                                              => array(
529
-                'EE_Registry'         => EE_Dependency_Map::load_from_cache,
530
-                'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
531
-            ),
532
-            'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
533
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
534
-            ),
535
-            'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => array(
536
-                'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
537
-                'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
538
-            ),
539
-            'EventEspresso\core\services\commands\CommandFactory'                                                         => array(
540
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
541
-            ),
542
-            'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
543
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
544
-            ),
545
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
546
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
547
-            ),
548
-            'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
549
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
550
-            ),
551
-            'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
552
-                'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
553
-            ),
554
-            'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
555
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
556
-            ),
557
-            'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
558
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
559
-            ),
560
-            'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
561
-                'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
562
-            ),
563
-            'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
564
-                'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
565
-            ),
566
-            'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
567
-                'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
568
-            ),
569
-            'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
570
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
571
-            ),
572
-            'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
573
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
574
-            ),
575
-            'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => array(
576
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
577
-            ),
578
-            'EventEspresso\core\services\database\TableManager'                                                           => array(
579
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
580
-            ),
581
-            'EE_Data_Migration_Class_Base'                                                                                => array(
582
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
583
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
584
-            ),
585
-            'EE_DMS_Core_4_1_0'                                                                                           => array(
586
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
587
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
588
-            ),
589
-            'EE_DMS_Core_4_2_0'                                                                                           => array(
590
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
591
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
592
-            ),
593
-            'EE_DMS_Core_4_3_0'                                                                                           => array(
594
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
595
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
596
-            ),
597
-            'EE_DMS_Core_4_4_0'                                                                                           => array(
598
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
599
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
600
-            ),
601
-            'EE_DMS_Core_4_5_0'                                                                                           => array(
602
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
603
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
604
-            ),
605
-            'EE_DMS_Core_4_6_0'                                                                                           => array(
606
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
607
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
608
-            ),
609
-            'EE_DMS_Core_4_7_0'                                                                                           => array(
610
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
611
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
612
-            ),
613
-            'EE_DMS_Core_4_8_0'                                                                                           => array(
614
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
615
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
616
-            ),
617
-            'EE_DMS_Core_4_9_0'                                                                                           => array(
618
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
619
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
620
-            ),
621
-            'EventEspresso\core\services\assets\Registry'                                                                 => array(
622
-                'EE_Template_Config' => EE_Dependency_Map::load_from_cache,
623
-                'EE_Currency_Config' => EE_Dependency_Map::load_from_cache,
624
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache
625
-            ),
626
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
627
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
628
-            ),
629
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
630
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
631
-            ),
632
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
633
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
634
-            ),
635
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
636
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
637
-            ),
638
-            'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
639
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
640
-            ),
641
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
642
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
643
-            ),
644
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
645
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
646
-            ),
647
-            'EventEspresso\core\services\cache\BasicCacheManager'                        => array(
648
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
649
-            ),
650
-            'EventEspresso\core\services\cache\PostRelatedCacheManager'                  => array(
651
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
652
-            ),
653
-            'EventEspresso\core\domain\services\validation\email\EmailValidationService' => array(
654
-                'EE_Registration_Config'                                  => EE_Dependency_Map::load_from_cache,
655
-                'EventEspresso\core\services\loaders\Loader'              => EE_Dependency_Map::load_from_cache,
656
-            ),
657
-            'EventEspresso\core\domain\values\EmailAddress'                              => array(
658
-                null,
659
-                'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
660
-            ),
661
-            'EventEspresso\core\services\orm\ModelFieldFactory' => array(
662
-                'EventEspresso\core\services\loaders\Loader'              => EE_Dependency_Map::load_from_cache,
663
-            ),
664
-            'LEGACY_MODELS'                                                   => array(
665
-                null,
666
-                'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
667
-            ),
668
-            'EE_Module_Request_Router' => array(
669
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
670
-            ),
671
-            'EE_Registration_Processor' => array(
672
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
673
-            ),
674
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => array(
675
-                null,
676
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
677
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
678
-            ),
679
-            'EE_Admin_Transactions_List_Table' => array(
680
-                null,
681
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
682
-            ),
683
-            'EventEspresso\core\domain\services\admin\ExitModal' => array(
684
-                'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache
685
-            ),
686
-            'EventEspresso\core\domain\services\admin\PluginUpsells' => array(
687
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache
688
-            ),
689
-            'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha' => array(
690
-                'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
691
-                'EE_Session'             => EE_Dependency_Map::load_from_cache,
692
-            ),
693
-            'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings' => array(
694
-                'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
695
-            ),
696
-            'EventEspresso\modules\ticket_selector\ProcessTicketSelector' => array(
697
-                'EE_Core_Config' => EE_Dependency_Map::load_from_cache,
698
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
699
-                'EE_Session' => EE_Dependency_Map::load_from_cache,
700
-                'EEM_Ticket' => EE_Dependency_Map::load_from_cache,
701
-                'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache,
702
-            ),
703
-            'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => array(
704
-                'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
705
-            ),
706
-        );
707
-    }
708
-
709
-
710
-
711
-    /**
712
-     * Registers how core classes are loaded.
713
-     * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
714
-     *        'EE_Request_Handler' => 'load_core'
715
-     *        'EE_Messages_Queue'  => 'load_lib'
716
-     *        'EEH_Debug_Tools'    => 'load_helper'
717
-     * or, if greater control is required, by providing a custom closure. For example:
718
-     *        'Some_Class' => function () {
719
-     *            return new Some_Class();
720
-     *        },
721
-     * This is required for instantiating dependencies
722
-     * where an interface has been type hinted in a class constructor. For example:
723
-     *        'Required_Interface' => function () {
724
-     *            return new A_Class_That_Implements_Required_Interface();
725
-     *        },
726
-     *
727
-     * @throws InvalidInterfaceException
728
-     * @throws InvalidDataTypeException
729
-     * @throws InvalidArgumentException
730
-     */
731
-    protected function _register_core_class_loaders()
732
-    {
733
-        //for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot
734
-        //be used in a closure.
735
-        $request = &$this->request;
736
-        $response = &$this->response;
737
-        $legacy_request = &$this->legacy_request;
738
-        // $loader = &$this->loader;
739
-        $this->_class_loaders = array(
740
-            //load_core
741
-            'EE_Capabilities'          => 'load_core',
742
-            'EE_Encryption'            => 'load_core',
743
-            'EE_Front_Controller'      => 'load_core',
744
-            'EE_Module_Request_Router' => 'load_core',
745
-            'EE_Registry'              => 'load_core',
746
-            'EE_Request'               => function () use (&$legacy_request) {
747
-                return $legacy_request;
748
-            },
749
-            'EventEspresso\core\services\request\Request' => function () use (&$request) {
750
-                return $request;
751
-            },
752
-            'EventEspresso\core\services\request\Response' => function () use (&$response) {
753
-                return $response;
754
-            },
755
-            'EE_Request_Handler'       => 'load_core',
756
-            'EE_Session'               => 'load_core',
757
-            'EE_Cron_Tasks'            => 'load_core',
758
-            'EE_System'                => 'load_core',
759
-            'EE_Maintenance_Mode'      => 'load_core',
760
-            'EE_Register_CPTs'         => 'load_core',
761
-            'EE_Admin'                 => 'load_core',
762
-            //load_lib
763
-            'EE_Message_Resource_Manager'          => 'load_lib',
764
-            'EE_Message_Type_Collection'           => 'load_lib',
765
-            'EE_Message_Type_Collection_Loader'    => 'load_lib',
766
-            'EE_Messenger_Collection'              => 'load_lib',
767
-            'EE_Messenger_Collection_Loader'       => 'load_lib',
768
-            'EE_Messages_Processor'                => 'load_lib',
769
-            'EE_Message_Repository'                => 'load_lib',
770
-            'EE_Messages_Queue'                    => 'load_lib',
771
-            'EE_Messages_Data_Handler_Collection'  => 'load_lib',
772
-            'EE_Message_Template_Group_Collection' => 'load_lib',
773
-            'EE_Payment_Method_Manager'            => 'load_lib',
774
-            'EE_Messages_Generator'                => function () {
775
-                return EE_Registry::instance()->load_lib(
776
-                    'Messages_Generator',
777
-                    array(),
778
-                    false,
779
-                    false
780
-                );
781
-            },
782
-            'EE_Messages_Template_Defaults'        => function ($arguments = array()) {
783
-                return EE_Registry::instance()->load_lib(
784
-                    'Messages_Template_Defaults',
785
-                    $arguments,
786
-                    false,
787
-                    false
788
-                );
789
-            },
790
-            //load_model
791
-            // 'EEM_Attendee'                         => 'load_model',
792
-            // 'EEM_Message_Template_Group'           => 'load_model',
793
-            // 'EEM_Message_Template'                 => 'load_model',
794
-            //load_helper
795
-            'EEH_Parse_Shortcodes'                 => function () {
796
-                if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
797
-                    return new EEH_Parse_Shortcodes();
798
-                }
799
-                return null;
800
-            },
801
-            'EE_Template_Config'                   => function () {
802
-                return EE_Config::instance()->template_settings;
803
-            },
804
-            'EE_Currency_Config'                   => function () {
805
-                return EE_Config::instance()->currency;
806
-            },
807
-            'EE_Registration_Config'                   => function () {
808
-                return EE_Config::instance()->registration;
809
-            },
810
-            'EE_Core_Config'                   => function () {
811
-                return EE_Config::instance()->core;
812
-            },
813
-            'EventEspresso\core\services\loaders\Loader' => function () {
814
-                return LoaderFactory::getLoader();
815
-            },
816
-        );
817
-    }
818
-
819
-
820
-
821
-    /**
822
-     * can be used for supplying alternate names for classes,
823
-     * or for connecting interface names to instantiable classes
824
-     */
825
-    protected function _register_core_aliases()
826
-    {
827
-        $this->_aliases = array(
828
-            'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
829
-            'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
830
-            'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
831
-            'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
832
-            'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
833
-            'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
834
-            'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
835
-            'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
836
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
837
-            'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
838
-            'CreateRegCodeCommandHandler'                                                  => 'EventEspresso\core\services\commands\registration\CreateRegCodeCommand',
839
-            'CreateRegUrlLinkCommandHandler'                                               => 'EventEspresso\core\services\commands\registration\CreateRegUrlLinkCommand',
840
-            'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
841
-            'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
842
-            'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
843
-            'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
844
-            'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
845
-            'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
846
-            'CreateTransactionCommandHandler'                                     => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
847
-            'CreateAttendeeCommandHandler'                                        => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
848
-            'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
849
-            'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
850
-            'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
851
-            'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
852
-            'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
853
-            'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
854
-            'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
855
-            'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
856
-            'CommandFactoryInterface'                                                     => 'EventEspresso\core\services\commands\CommandFactoryInterface',
857
-            'EventEspresso\core\services\commands\CommandFactoryInterface'                => 'EventEspresso\core\services\commands\CommandFactory',
858
-            'EventEspresso\core\domain\services\session\SessionIdentifierInterface'       => 'EE_Session',
859
-            'EmailValidatorInterface'                                                     => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
860
-            'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
861
-            'NoticeConverterInterface'                                            => 'EventEspresso\core\services\notices\NoticeConverterInterface',
862
-            'EventEspresso\core\services\notices\NoticeConverterInterface'        => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
863
-            'NoticesContainerInterface'                                           => 'EventEspresso\core\services\notices\NoticesContainerInterface',
864
-            'EventEspresso\core\services\notices\NoticesContainerInterface'       => 'EventEspresso\core\services\notices\NoticesContainer',
865
-            'EventEspresso\core\services\request\RequestInterface'                => 'EventEspresso\core\services\request\Request',
866
-            'EventEspresso\core\services\request\ResponseInterface'               => 'EventEspresso\core\services\request\Response',
867
-            'EventEspresso\core\domain\DomainInterface'                           => 'EventEspresso\core\domain\Domain',
868
-        );
869
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
870
-            $this->_aliases['EventEspresso\core\services\notices\NoticeConverterInterface'] = 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices';
871
-        }
872
-    }
873
-
874
-
875
-
876
-    /**
877
-     * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
878
-     * request Primarily used by unit tests.
879
-     *
880
-     * @throws InvalidDataTypeException
881
-     * @throws InvalidInterfaceException
882
-     * @throws InvalidArgumentException
883
-     */
884
-    public function reset()
885
-    {
886
-        $this->_register_core_class_loaders();
887
-        $this->_register_core_dependencies();
888
-    }
28
+	/**
29
+	 * This means that the requested class dependency is not present in the dependency map
30
+	 */
31
+	const not_registered = 0;
32
+
33
+	/**
34
+	 * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
35
+	 */
36
+	const load_new_object = 1;
37
+
38
+	/**
39
+	 * This instructs class loaders to return a previously instantiated and cached object for the requested class.
40
+	 * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
41
+	 */
42
+	const load_from_cache = 2;
43
+
44
+	/**
45
+	 * When registering a dependency,
46
+	 * this indicates to keep any existing dependencies that already exist,
47
+	 * and simply discard any new dependencies declared in the incoming data
48
+	 */
49
+	const KEEP_EXISTING_DEPENDENCIES = 0;
50
+
51
+	/**
52
+	 * When registering a dependency,
53
+	 * this indicates to overwrite any existing dependencies that already exist using the incoming data
54
+	 */
55
+	const OVERWRITE_DEPENDENCIES = 1;
56
+
57
+
58
+
59
+	/**
60
+	 * @type EE_Dependency_Map $_instance
61
+	 */
62
+	protected static $_instance;
63
+
64
+	/**
65
+	 * @type RequestInterface $request
66
+	 */
67
+	protected $request;
68
+
69
+	/**
70
+	 * @type LegacyRequestInterface $legacy_request
71
+	 */
72
+	protected $legacy_request;
73
+
74
+	/**
75
+	 * @type ResponseInterface $response
76
+	 */
77
+	protected $response;
78
+
79
+	/**
80
+	 * @type LoaderInterface $loader
81
+	 */
82
+	protected $loader;
83
+
84
+	/**
85
+	 * @type array $_dependency_map
86
+	 */
87
+	protected $_dependency_map = array();
88
+
89
+	/**
90
+	 * @type array $_class_loaders
91
+	 */
92
+	protected $_class_loaders = array();
93
+
94
+	/**
95
+	 * @type array $_aliases
96
+	 */
97
+	protected $_aliases = array();
98
+
99
+
100
+
101
+	/**
102
+	 * EE_Dependency_Map constructor.
103
+	 */
104
+	protected function __construct()
105
+	{
106
+		// add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
107
+		do_action('EE_Dependency_Map____construct');
108
+	}
109
+
110
+
111
+
112
+	/**
113
+	 * @throws InvalidDataTypeException
114
+	 * @throws InvalidInterfaceException
115
+	 * @throws InvalidArgumentException
116
+	 */
117
+	public function initialize()
118
+	{
119
+		$this->_register_core_dependencies();
120
+		$this->_register_core_class_loaders();
121
+		$this->_register_core_aliases();
122
+	}
123
+
124
+
125
+
126
+	/**
127
+	 * @singleton method used to instantiate class object
128
+	 * @return EE_Dependency_Map
129
+	 */
130
+	public static function instance() {
131
+		// check if class object is instantiated, and instantiated properly
132
+		if (! self::$_instance instanceof EE_Dependency_Map) {
133
+			self::$_instance = new EE_Dependency_Map(/*$request, $response, $legacy_request*/);
134
+		}
135
+		return self::$_instance;
136
+	}
137
+
138
+
139
+	/**
140
+	 * @param RequestInterface $request
141
+	 */
142
+	public function setRequest(RequestInterface $request)
143
+	{
144
+		$this->request = $request;
145
+	}
146
+
147
+
148
+	/**
149
+	 * @param LegacyRequestInterface $legacy_request
150
+	 */
151
+	public function setLegacyRequest(LegacyRequestInterface $legacy_request)
152
+	{
153
+		$this->legacy_request = $legacy_request;
154
+	}
155
+
156
+
157
+	/**
158
+	 * @param ResponseInterface $response
159
+	 */
160
+	public function setResponse(ResponseInterface $response)
161
+	{
162
+		$this->response = $response;
163
+	}
164
+
165
+
166
+
167
+	/**
168
+	 * @param LoaderInterface $loader
169
+	 */
170
+	public function setLoader(LoaderInterface $loader)
171
+	{
172
+		$this->loader = $loader;
173
+	}
174
+
175
+
176
+
177
+	/**
178
+	 * @param string $class
179
+	 * @param array  $dependencies
180
+	 * @param int    $overwrite
181
+	 * @return bool
182
+	 */
183
+	public static function register_dependencies(
184
+		$class,
185
+		array $dependencies,
186
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
187
+	) {
188
+		return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
189
+	}
190
+
191
+
192
+
193
+	/**
194
+	 * Assigns an array of class names and corresponding load sources (new or cached)
195
+	 * to the class specified by the first parameter.
196
+	 * IMPORTANT !!!
197
+	 * The order of elements in the incoming $dependencies array MUST match
198
+	 * the order of the constructor parameters for the class in question.
199
+	 * This is especially important when overriding any existing dependencies that are registered.
200
+	 * the third parameter controls whether any duplicate dependencies are overwritten or not.
201
+	 *
202
+	 * @param string $class
203
+	 * @param array  $dependencies
204
+	 * @param int    $overwrite
205
+	 * @return bool
206
+	 */
207
+	public function registerDependencies(
208
+		$class,
209
+		array $dependencies,
210
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
211
+	) {
212
+		$class = trim($class, '\\');
213
+		$registered = false;
214
+		if (empty(self::$_instance->_dependency_map[ $class ])) {
215
+			self::$_instance->_dependency_map[ $class ] = array();
216
+		}
217
+		// we need to make sure that any aliases used when registering a dependency
218
+		// get resolved to the correct class name
219
+		foreach ($dependencies as $dependency => $load_source) {
220
+			$alias = self::$_instance->get_alias($dependency);
221
+			if (
222
+				$overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
223
+				|| ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
224
+			) {
225
+				unset($dependencies[$dependency]);
226
+				$dependencies[$alias] = $load_source;
227
+				$registered = true;
228
+			}
229
+		}
230
+		// now add our two lists of dependencies together.
231
+		// using Union (+=) favours the arrays in precedence from left to right,
232
+		// so $dependencies is NOT overwritten because it is listed first
233
+		// ie: with A = B + C, entries in B take precedence over duplicate entries in C
234
+		// Union is way faster than array_merge() but should be used with caution...
235
+		// especially with numerically indexed arrays
236
+		$dependencies += self::$_instance->_dependency_map[ $class ];
237
+		// now we need to ensure that the resulting dependencies
238
+		// array only has the entries that are required for the class
239
+		// so first count how many dependencies were originally registered for the class
240
+		$dependency_count = count(self::$_instance->_dependency_map[ $class ]);
241
+		// if that count is non-zero (meaning dependencies were already registered)
242
+		self::$_instance->_dependency_map[ $class ] = $dependency_count
243
+			// then truncate the  final array to match that count
244
+			? array_slice($dependencies, 0, $dependency_count)
245
+			// otherwise just take the incoming array because nothing previously existed
246
+			: $dependencies;
247
+		return $registered;
248
+	}
249
+
250
+
251
+
252
+	/**
253
+	 * @param string $class_name
254
+	 * @param string $loader
255
+	 * @return bool
256
+	 * @throws DomainException
257
+	 */
258
+	public static function register_class_loader($class_name, $loader = 'load_core')
259
+	{
260
+		if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
261
+			throw new DomainException(
262
+				esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
263
+			);
264
+		}
265
+		// check that loader is callable or method starts with "load_" and exists in EE_Registry
266
+		if (
267
+			! is_callable($loader)
268
+			&& (
269
+				strpos($loader, 'load_') !== 0
270
+				|| ! method_exists('EE_Registry', $loader)
271
+			)
272
+		) {
273
+			throw new DomainException(
274
+				sprintf(
275
+					esc_html__(
276
+						'"%1$s" is not a valid loader method on EE_Registry.',
277
+						'event_espresso'
278
+					),
279
+					$loader
280
+				)
281
+			);
282
+		}
283
+		$class_name = self::$_instance->get_alias($class_name);
284
+		if (! isset(self::$_instance->_class_loaders[$class_name])) {
285
+			self::$_instance->_class_loaders[$class_name] = $loader;
286
+			return true;
287
+		}
288
+		return false;
289
+	}
290
+
291
+
292
+
293
+	/**
294
+	 * @return array
295
+	 */
296
+	public function dependency_map()
297
+	{
298
+		return $this->_dependency_map;
299
+	}
300
+
301
+
302
+
303
+	/**
304
+	 * returns TRUE if dependency map contains a listing for the provided class name
305
+	 *
306
+	 * @param string $class_name
307
+	 * @return boolean
308
+	 */
309
+	public function has($class_name = '')
310
+	{
311
+		// all legacy models have the same dependencies
312
+		if (strpos($class_name, 'EEM_') === 0) {
313
+			$class_name = 'LEGACY_MODELS';
314
+		}
315
+		return isset($this->_dependency_map[$class_name]) ? true : false;
316
+	}
317
+
318
+
319
+
320
+	/**
321
+	 * returns TRUE if dependency map contains a listing for the provided class name AND dependency
322
+	 *
323
+	 * @param string $class_name
324
+	 * @param string $dependency
325
+	 * @return bool
326
+	 */
327
+	public function has_dependency_for_class($class_name = '', $dependency = '')
328
+	{
329
+		// all legacy models have the same dependencies
330
+		if (strpos($class_name, 'EEM_') === 0) {
331
+			$class_name = 'LEGACY_MODELS';
332
+		}
333
+		$dependency = $this->get_alias($dependency);
334
+		return isset($this->_dependency_map[$class_name][$dependency])
335
+			? true
336
+			: false;
337
+	}
338
+
339
+
340
+
341
+	/**
342
+	 * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
343
+	 *
344
+	 * @param string $class_name
345
+	 * @param string $dependency
346
+	 * @return int
347
+	 */
348
+	public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
349
+	{
350
+		// all legacy models have the same dependencies
351
+		if (strpos($class_name, 'EEM_') === 0) {
352
+			$class_name = 'LEGACY_MODELS';
353
+		}
354
+		$dependency = $this->get_alias($dependency);
355
+		return $this->has_dependency_for_class($class_name, $dependency)
356
+			? $this->_dependency_map[$class_name][$dependency]
357
+			: EE_Dependency_Map::not_registered;
358
+	}
359
+
360
+
361
+
362
+	/**
363
+	 * @param string $class_name
364
+	 * @return string | Closure
365
+	 */
366
+	public function class_loader($class_name)
367
+	{
368
+		// all legacy models use load_model()
369
+		if(strpos($class_name, 'EEM_') === 0){
370
+			return 'load_model';
371
+		}
372
+		$class_name = $this->get_alias($class_name);
373
+		return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : '';
374
+	}
375
+
376
+
377
+
378
+	/**
379
+	 * @return array
380
+	 */
381
+	public function class_loaders()
382
+	{
383
+		return $this->_class_loaders;
384
+	}
385
+
386
+
387
+
388
+	/**
389
+	 * adds an alias for a classname
390
+	 *
391
+	 * @param string $class_name the class name that should be used (concrete class to replace interface)
392
+	 * @param string $alias      the class name that would be type hinted for (abstract parent or interface)
393
+	 * @param string $for_class  the class that has the dependency (is type hinting for the interface)
394
+	 */
395
+	public function add_alias($class_name, $alias, $for_class = '')
396
+	{
397
+		if ($for_class !== '') {
398
+			if (! isset($this->_aliases[$for_class])) {
399
+				$this->_aliases[$for_class] = array();
400
+			}
401
+			$this->_aliases[$for_class][$class_name] = $alias;
402
+		}
403
+		$this->_aliases[$class_name] = $alias;
404
+	}
405
+
406
+
407
+
408
+	/**
409
+	 * returns TRUE if the provided class name has an alias
410
+	 *
411
+	 * @param string $class_name
412
+	 * @param string $for_class
413
+	 * @return bool
414
+	 */
415
+	public function has_alias($class_name = '', $for_class = '')
416
+	{
417
+		return isset($this->_aliases[$for_class][$class_name])
418
+			   || (
419
+				   isset($this->_aliases[$class_name])
420
+				   && ! is_array($this->_aliases[$class_name])
421
+			   );
422
+	}
423
+
424
+
425
+
426
+	/**
427
+	 * returns alias for class name if one exists, otherwise returns the original classname
428
+	 * functions recursively, so that multiple aliases can be used to drill down to a classname
429
+	 *  for example:
430
+	 *      if the following two entries were added to the _aliases array:
431
+	 *          array(
432
+	 *              'interface_alias'           => 'some\namespace\interface'
433
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
434
+	 *          )
435
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
436
+	 *      to load an instance of 'some\namespace\classname'
437
+	 *
438
+	 * @param string $class_name
439
+	 * @param string $for_class
440
+	 * @return string
441
+	 */
442
+	public function get_alias($class_name = '', $for_class = '')
443
+	{
444
+		if (! $this->has_alias($class_name, $for_class)) {
445
+			return $class_name;
446
+		}
447
+		if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) {
448
+			return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class);
449
+		}
450
+		return $this->get_alias($this->_aliases[$class_name]);
451
+	}
452
+
453
+
454
+
455
+	/**
456
+	 * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
457
+	 * if one exists, or whether a new object should be generated every time the requested class is loaded.
458
+	 * This is done by using the following class constants:
459
+	 *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
460
+	 *        EE_Dependency_Map::load_new_object - generates a new object every time
461
+	 */
462
+	protected function _register_core_dependencies()
463
+	{
464
+		$this->_dependency_map = array(
465
+			'EE_Request_Handler'                                                                                          => array(
466
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
467
+			),
468
+			'EE_System'                                                                                                   => array(
469
+				'EE_Registry'                                 => EE_Dependency_Map::load_from_cache,
470
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
471
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
472
+				'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
473
+			),
474
+			'EE_Session'                                                                                                  => array(
475
+				'EventEspresso\core\services\cache\TransientCacheStorage'  => EE_Dependency_Map::load_from_cache,
476
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
477
+				'EventEspresso\core\services\request\Request'              => EE_Dependency_Map::load_from_cache,
478
+				'EE_Encryption'                                            => EE_Dependency_Map::load_from_cache,
479
+			),
480
+			'EE_Cart'                                                                                                     => array(
481
+				'EE_Session' => EE_Dependency_Map::load_from_cache,
482
+			),
483
+			'EE_Front_Controller'                                                                                         => array(
484
+				'EE_Registry'              => EE_Dependency_Map::load_from_cache,
485
+				'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
486
+				'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
487
+			),
488
+			'EE_Messenger_Collection_Loader'                                                                              => array(
489
+				'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
490
+			),
491
+			'EE_Message_Type_Collection_Loader'                                                                           => array(
492
+				'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
493
+			),
494
+			'EE_Message_Resource_Manager'                                                                                 => array(
495
+				'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
496
+				'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
497
+				'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
498
+			),
499
+			'EE_Message_Factory'                                                                                          => array(
500
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
501
+			),
502
+			'EE_messages'                                                                                                 => array(
503
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
504
+			),
505
+			'EE_Messages_Generator'                                                                                       => array(
506
+				'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
507
+				'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
508
+				'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
509
+				'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
510
+			),
511
+			'EE_Messages_Processor'                                                                                       => array(
512
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
513
+			),
514
+			'EE_Messages_Queue'                                                                                           => array(
515
+				'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
516
+			),
517
+			'EE_Messages_Template_Defaults'                                                                               => array(
518
+				'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
519
+				'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
520
+			),
521
+			'EE_Message_To_Generate_From_Request'                                                                         => array(
522
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
523
+				'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
524
+			),
525
+			'EventEspresso\core\services\commands\CommandBus'                                                             => array(
526
+				'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
527
+			),
528
+			'EventEspresso\services\commands\CommandHandler'                                                              => array(
529
+				'EE_Registry'         => EE_Dependency_Map::load_from_cache,
530
+				'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
531
+			),
532
+			'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
533
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
534
+			),
535
+			'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => array(
536
+				'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
537
+				'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
538
+			),
539
+			'EventEspresso\core\services\commands\CommandFactory'                                                         => array(
540
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
541
+			),
542
+			'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
543
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
544
+			),
545
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
546
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
547
+			),
548
+			'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
549
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
550
+			),
551
+			'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
552
+				'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
553
+			),
554
+			'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
555
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
556
+			),
557
+			'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
558
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
559
+			),
560
+			'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
561
+				'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
562
+			),
563
+			'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
564
+				'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
565
+			),
566
+			'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
567
+				'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
568
+			),
569
+			'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
570
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
571
+			),
572
+			'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
573
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
574
+			),
575
+			'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => array(
576
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
577
+			),
578
+			'EventEspresso\core\services\database\TableManager'                                                           => array(
579
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
580
+			),
581
+			'EE_Data_Migration_Class_Base'                                                                                => array(
582
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
583
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
584
+			),
585
+			'EE_DMS_Core_4_1_0'                                                                                           => array(
586
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
587
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
588
+			),
589
+			'EE_DMS_Core_4_2_0'                                                                                           => array(
590
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
591
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
592
+			),
593
+			'EE_DMS_Core_4_3_0'                                                                                           => array(
594
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
595
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
596
+			),
597
+			'EE_DMS_Core_4_4_0'                                                                                           => array(
598
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
599
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
600
+			),
601
+			'EE_DMS_Core_4_5_0'                                                                                           => array(
602
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
603
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
604
+			),
605
+			'EE_DMS_Core_4_6_0'                                                                                           => array(
606
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
607
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
608
+			),
609
+			'EE_DMS_Core_4_7_0'                                                                                           => array(
610
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
611
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
612
+			),
613
+			'EE_DMS_Core_4_8_0'                                                                                           => array(
614
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
615
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
616
+			),
617
+			'EE_DMS_Core_4_9_0'                                                                                           => array(
618
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
619
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
620
+			),
621
+			'EventEspresso\core\services\assets\Registry'                                                                 => array(
622
+				'EE_Template_Config' => EE_Dependency_Map::load_from_cache,
623
+				'EE_Currency_Config' => EE_Dependency_Map::load_from_cache,
624
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache
625
+			),
626
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
627
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
628
+			),
629
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
630
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
631
+			),
632
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
633
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
634
+			),
635
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
636
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
637
+			),
638
+			'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
639
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
640
+			),
641
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
642
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
643
+			),
644
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
645
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
646
+			),
647
+			'EventEspresso\core\services\cache\BasicCacheManager'                        => array(
648
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
649
+			),
650
+			'EventEspresso\core\services\cache\PostRelatedCacheManager'                  => array(
651
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
652
+			),
653
+			'EventEspresso\core\domain\services\validation\email\EmailValidationService' => array(
654
+				'EE_Registration_Config'                                  => EE_Dependency_Map::load_from_cache,
655
+				'EventEspresso\core\services\loaders\Loader'              => EE_Dependency_Map::load_from_cache,
656
+			),
657
+			'EventEspresso\core\domain\values\EmailAddress'                              => array(
658
+				null,
659
+				'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
660
+			),
661
+			'EventEspresso\core\services\orm\ModelFieldFactory' => array(
662
+				'EventEspresso\core\services\loaders\Loader'              => EE_Dependency_Map::load_from_cache,
663
+			),
664
+			'LEGACY_MODELS'                                                   => array(
665
+				null,
666
+				'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
667
+			),
668
+			'EE_Module_Request_Router' => array(
669
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
670
+			),
671
+			'EE_Registration_Processor' => array(
672
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
673
+			),
674
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => array(
675
+				null,
676
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
677
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
678
+			),
679
+			'EE_Admin_Transactions_List_Table' => array(
680
+				null,
681
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
682
+			),
683
+			'EventEspresso\core\domain\services\admin\ExitModal' => array(
684
+				'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache
685
+			),
686
+			'EventEspresso\core\domain\services\admin\PluginUpsells' => array(
687
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache
688
+			),
689
+			'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha' => array(
690
+				'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
691
+				'EE_Session'             => EE_Dependency_Map::load_from_cache,
692
+			),
693
+			'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings' => array(
694
+				'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
695
+			),
696
+			'EventEspresso\modules\ticket_selector\ProcessTicketSelector' => array(
697
+				'EE_Core_Config' => EE_Dependency_Map::load_from_cache,
698
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
699
+				'EE_Session' => EE_Dependency_Map::load_from_cache,
700
+				'EEM_Ticket' => EE_Dependency_Map::load_from_cache,
701
+				'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache,
702
+			),
703
+			'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => array(
704
+				'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
705
+			),
706
+		);
707
+	}
708
+
709
+
710
+
711
+	/**
712
+	 * Registers how core classes are loaded.
713
+	 * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
714
+	 *        'EE_Request_Handler' => 'load_core'
715
+	 *        'EE_Messages_Queue'  => 'load_lib'
716
+	 *        'EEH_Debug_Tools'    => 'load_helper'
717
+	 * or, if greater control is required, by providing a custom closure. For example:
718
+	 *        'Some_Class' => function () {
719
+	 *            return new Some_Class();
720
+	 *        },
721
+	 * This is required for instantiating dependencies
722
+	 * where an interface has been type hinted in a class constructor. For example:
723
+	 *        'Required_Interface' => function () {
724
+	 *            return new A_Class_That_Implements_Required_Interface();
725
+	 *        },
726
+	 *
727
+	 * @throws InvalidInterfaceException
728
+	 * @throws InvalidDataTypeException
729
+	 * @throws InvalidArgumentException
730
+	 */
731
+	protected function _register_core_class_loaders()
732
+	{
733
+		//for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot
734
+		//be used in a closure.
735
+		$request = &$this->request;
736
+		$response = &$this->response;
737
+		$legacy_request = &$this->legacy_request;
738
+		// $loader = &$this->loader;
739
+		$this->_class_loaders = array(
740
+			//load_core
741
+			'EE_Capabilities'          => 'load_core',
742
+			'EE_Encryption'            => 'load_core',
743
+			'EE_Front_Controller'      => 'load_core',
744
+			'EE_Module_Request_Router' => 'load_core',
745
+			'EE_Registry'              => 'load_core',
746
+			'EE_Request'               => function () use (&$legacy_request) {
747
+				return $legacy_request;
748
+			},
749
+			'EventEspresso\core\services\request\Request' => function () use (&$request) {
750
+				return $request;
751
+			},
752
+			'EventEspresso\core\services\request\Response' => function () use (&$response) {
753
+				return $response;
754
+			},
755
+			'EE_Request_Handler'       => 'load_core',
756
+			'EE_Session'               => 'load_core',
757
+			'EE_Cron_Tasks'            => 'load_core',
758
+			'EE_System'                => 'load_core',
759
+			'EE_Maintenance_Mode'      => 'load_core',
760
+			'EE_Register_CPTs'         => 'load_core',
761
+			'EE_Admin'                 => 'load_core',
762
+			//load_lib
763
+			'EE_Message_Resource_Manager'          => 'load_lib',
764
+			'EE_Message_Type_Collection'           => 'load_lib',
765
+			'EE_Message_Type_Collection_Loader'    => 'load_lib',
766
+			'EE_Messenger_Collection'              => 'load_lib',
767
+			'EE_Messenger_Collection_Loader'       => 'load_lib',
768
+			'EE_Messages_Processor'                => 'load_lib',
769
+			'EE_Message_Repository'                => 'load_lib',
770
+			'EE_Messages_Queue'                    => 'load_lib',
771
+			'EE_Messages_Data_Handler_Collection'  => 'load_lib',
772
+			'EE_Message_Template_Group_Collection' => 'load_lib',
773
+			'EE_Payment_Method_Manager'            => 'load_lib',
774
+			'EE_Messages_Generator'                => function () {
775
+				return EE_Registry::instance()->load_lib(
776
+					'Messages_Generator',
777
+					array(),
778
+					false,
779
+					false
780
+				);
781
+			},
782
+			'EE_Messages_Template_Defaults'        => function ($arguments = array()) {
783
+				return EE_Registry::instance()->load_lib(
784
+					'Messages_Template_Defaults',
785
+					$arguments,
786
+					false,
787
+					false
788
+				);
789
+			},
790
+			//load_model
791
+			// 'EEM_Attendee'                         => 'load_model',
792
+			// 'EEM_Message_Template_Group'           => 'load_model',
793
+			// 'EEM_Message_Template'                 => 'load_model',
794
+			//load_helper
795
+			'EEH_Parse_Shortcodes'                 => function () {
796
+				if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
797
+					return new EEH_Parse_Shortcodes();
798
+				}
799
+				return null;
800
+			},
801
+			'EE_Template_Config'                   => function () {
802
+				return EE_Config::instance()->template_settings;
803
+			},
804
+			'EE_Currency_Config'                   => function () {
805
+				return EE_Config::instance()->currency;
806
+			},
807
+			'EE_Registration_Config'                   => function () {
808
+				return EE_Config::instance()->registration;
809
+			},
810
+			'EE_Core_Config'                   => function () {
811
+				return EE_Config::instance()->core;
812
+			},
813
+			'EventEspresso\core\services\loaders\Loader' => function () {
814
+				return LoaderFactory::getLoader();
815
+			},
816
+		);
817
+	}
818
+
819
+
820
+
821
+	/**
822
+	 * can be used for supplying alternate names for classes,
823
+	 * or for connecting interface names to instantiable classes
824
+	 */
825
+	protected function _register_core_aliases()
826
+	{
827
+		$this->_aliases = array(
828
+			'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
829
+			'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
830
+			'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
831
+			'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
832
+			'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
833
+			'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
834
+			'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
835
+			'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
836
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
837
+			'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
838
+			'CreateRegCodeCommandHandler'                                                  => 'EventEspresso\core\services\commands\registration\CreateRegCodeCommand',
839
+			'CreateRegUrlLinkCommandHandler'                                               => 'EventEspresso\core\services\commands\registration\CreateRegUrlLinkCommand',
840
+			'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
841
+			'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
842
+			'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
843
+			'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
844
+			'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
845
+			'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
846
+			'CreateTransactionCommandHandler'                                     => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
847
+			'CreateAttendeeCommandHandler'                                        => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
848
+			'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
849
+			'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
850
+			'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
851
+			'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
852
+			'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
853
+			'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
854
+			'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
855
+			'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
856
+			'CommandFactoryInterface'                                                     => 'EventEspresso\core\services\commands\CommandFactoryInterface',
857
+			'EventEspresso\core\services\commands\CommandFactoryInterface'                => 'EventEspresso\core\services\commands\CommandFactory',
858
+			'EventEspresso\core\domain\services\session\SessionIdentifierInterface'       => 'EE_Session',
859
+			'EmailValidatorInterface'                                                     => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
860
+			'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
861
+			'NoticeConverterInterface'                                            => 'EventEspresso\core\services\notices\NoticeConverterInterface',
862
+			'EventEspresso\core\services\notices\NoticeConverterInterface'        => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
863
+			'NoticesContainerInterface'                                           => 'EventEspresso\core\services\notices\NoticesContainerInterface',
864
+			'EventEspresso\core\services\notices\NoticesContainerInterface'       => 'EventEspresso\core\services\notices\NoticesContainer',
865
+			'EventEspresso\core\services\request\RequestInterface'                => 'EventEspresso\core\services\request\Request',
866
+			'EventEspresso\core\services\request\ResponseInterface'               => 'EventEspresso\core\services\request\Response',
867
+			'EventEspresso\core\domain\DomainInterface'                           => 'EventEspresso\core\domain\Domain',
868
+		);
869
+		if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
870
+			$this->_aliases['EventEspresso\core\services\notices\NoticeConverterInterface'] = 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices';
871
+		}
872
+	}
873
+
874
+
875
+
876
+	/**
877
+	 * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
878
+	 * request Primarily used by unit tests.
879
+	 *
880
+	 * @throws InvalidDataTypeException
881
+	 * @throws InvalidInterfaceException
882
+	 * @throws InvalidArgumentException
883
+	 */
884
+	public function reset()
885
+	{
886
+		$this->_register_core_class_loaders();
887
+		$this->_register_core_dependencies();
888
+	}
889 889
 
890 890
 
891 891
 }
Please login to merge, or discard this patch.
caffeinated/modules/recaptcha_invisible/EED_Recaptcha_Invisible.module.php 2 patches
Indentation   +322 added lines, -322 removed lines patch added patch discarded remove patch
@@ -21,326 +21,326 @@
 block discarded – undo
21 21
 class EED_Recaptcha_Invisible extends EED_Module
22 22
 {
23 23
 
24
-    /**
25
-     * @var EE_Registration_Config $config
26
-     */
27
-    private static $config;
28
-
29
-
30
-    /**
31
-     * @return EED_Module|EED_Recaptcha
32
-     */
33
-    public static function instance()
34
-    {
35
-        return parent::get_instance(__CLASS__);
36
-    }
37
-
38
-
39
-    /**
40
-     * @return void
41
-     * @throws InvalidInterfaceException
42
-     * @throws InvalidDataTypeException
43
-     * @throws InvalidArgumentException
44
-     */
45
-    public static function set_hooks()
46
-    {
47
-        EED_Recaptcha_Invisible::setProperties();
48
-        if (EED_Recaptcha_Invisible::useInvisibleRecaptcha()) {
49
-            if(EED_Recaptcha_Invisible::protectForm('ticket_selector')){
50
-                // ticket selection
51
-                add_filter(
52
-                    'FHEE__EE_Ticket_Selector__after_ticket_selector_submit',
53
-                    array('EED_Recaptcha_Invisible', 'ticketSelectorForm'),
54
-                    10, 3
55
-                );
56
-                add_action(
57
-                    'EED_Ticket_Selector__process_ticket_selections__before',
58
-                    array('EED_Recaptcha_Invisible', 'processTicketSelectorForm')
59
-                );
60
-            }
61
-            if (EED_Recaptcha_Invisible::protectForm('registration_form')) {
62
-                // checkout
63
-                add_action(
64
-                    'AHEE__EE_SPCO_Reg_Step__display_reg_form__reg_form',
65
-                    array('EED_Recaptcha_Invisible', 'spcoRegStepForm')
66
-                );
67
-                add_filter(
68
-                    'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data',
69
-                    array('EED_Recaptcha_Invisible', 'receiveSpcoRegStepForm'),
70
-                    10, 2
71
-                );
72
-            }
73
-            add_action('loop_end', array('EED_Recaptcha_Invisible', 'localizeScriptVars'));
74
-        }
75
-    }
76
-
77
-
78
-    /**
79
-     * @return void
80
-     * @throws InvalidInterfaceException
81
-     * @throws InvalidDataTypeException
82
-     * @throws InvalidArgumentException
83
-     */
84
-    public static function set_hooks_admin()
85
-    {
86
-        EED_Recaptcha_Invisible::setProperties();
87
-        if (EED_Recaptcha_Invisible::protectForm('ticket_selector')) {
88
-            add_action(
89
-                'EED_Ticket_Selector__process_ticket_selections__before',
90
-                array('EED_Recaptcha_Invisible', 'processTicketSelectorForm')
91
-            );
92
-        }
93
-        if (EED_Recaptcha_Invisible::protectForm('registration_form')) {
94
-            add_filter(
95
-                'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data',
96
-                array('EED_Recaptcha_Invisible', 'receiveSpcoRegStepForm'),
97
-                10, 2
98
-            );
99
-        }
100
-        // admin settings
101
-        add_action(
102
-            'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
103
-            array('EED_Recaptcha_Invisible', 'adminSettings')
104
-        );
105
-        add_filter(
106
-            'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration',
107
-            array('EED_Recaptcha_Invisible', 'updateAdminSettings')
108
-        );
109
-    }
110
-
111
-
112
-    /**
113
-     * @return void
114
-     * @throws InvalidInterfaceException
115
-     * @throws InvalidDataTypeException
116
-     * @throws InvalidArgumentException
117
-     */
118
-    public static function setProperties()
119
-    {
120
-
121
-        EED_Recaptcha_Invisible::$config = EE_Registry::instance()->CFG->registration;
122
-    }
123
-
124
-
125
-
126
-    /**
127
-     * @return boolean
128
-     */
129
-    public static function useInvisibleRecaptcha()
130
-    {
131
-        return EED_Recaptcha_Invisible::$config->use_captcha
132
-               && EED_Recaptcha_Invisible::$config->recaptcha_theme === 'invisible';
133
-    }
134
-
135
-
136
-    /**
137
-     * @param string $form
138
-     * @return boolean
139
-     */
140
-    public static function protectForm($form)
141
-    {
142
-        return is_array(EED_Recaptcha_Invisible::$config->recaptcha_protected_forms)
143
-            && in_array($form, EED_Recaptcha_Invisible::$config->recaptcha_protected_forms, true);
144
-    }
145
-
146
-
147
-
148
-
149
-    /**
150
-     * @return void
151
-     * @throws InvalidInterfaceException
152
-     * @throws InvalidDataTypeException
153
-     * @throws InvalidArgumentException
154
-     */
155
-    public static function localizeScriptVars()
156
-    {
157
-        wp_localize_script(
158
-            EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA,
159
-            'eeRecaptcha',
160
-            RecaptchaFactory::create()->getLocalizedVars()
161
-        );
162
-    }
163
-
164
-
165
-    /**
166
-     * @return string
167
-     */
168
-    public static function assetsUrl()
169
-    {
170
-        return plugin_dir_url(__FILE__) . 'assets' . DS;
171
-    }
172
-
173
-
174
-    /**
175
-     * @param \WP $WP
176
-     */
177
-    public function run($WP)
178
-    {
179
-    }
180
-
181
-
182
-
183
-    /**
184
-     * @param EE_Request $request
185
-     * @return bool
186
-     * @throws InvalidArgumentException
187
-     * @throws InvalidDataTypeException
188
-     * @throws InvalidInterfaceException
189
-     * @throws RuntimeException
190
-     */
191
-    public static function verifyToken(EE_Request $request)
192
-    {
193
-        return RecaptchaFactory::create()->verifyToken($request);
194
-    }
195
-
196
-
197
-    /**
198
-     * @param EE_Form_Section_Proper $reg_form
199
-     * @return void
200
-     * @throws EE_Error
201
-     * @throws InvalidArgumentException
202
-     * @throws InvalidDataTypeException
203
-     * @throws InvalidInterfaceException
204
-     * @throws DomainException
205
-     */
206
-    public static function spcoRegStepForm(EE_Form_Section_Proper $reg_form)
207
-    {
208
-        // do nothing if form isn't for a reg step or test has already been passed
209
-        if (! EED_Recaptcha_Invisible::processSpcoRegStepForm($reg_form)) {
210
-            return;
211
-        }
212
-        $default_hidden_inputs = $reg_form->get_subsection('default_hidden_inputs');
213
-        if ($default_hidden_inputs instanceof EE_Form_Section_Proper) {
214
-            $invisible_recaptcha = RecaptchaFactory::create();
215
-            $invisible_recaptcha->addToFormSection($default_hidden_inputs);
216
-        }
217
-    }
218
-
219
-
220
-    /**
221
-     * @param EE_Form_Section_Proper $reg_form
222
-     * @return bool
223
-     * @throws InvalidDataTypeException
224
-     * @throws InvalidInterfaceException
225
-     * @throws EE_Error
226
-     * @throws InvalidArgumentException
227
-     */
228
-    public static function processSpcoRegStepForm(EE_Form_Section_Proper $reg_form)
229
-    {
230
-        return strpos($reg_form->name(), 'reg-step-form') !== false
231
-               && ! RecaptchaFactory::create()->recaptchaPassed();
232
-    }
233
-
234
-
235
-    /**
236
-     * @param array|null             $req_data
237
-     * @param EE_Form_Section_Proper $reg_form
238
-     * @return array
239
-     * @throws EE_Error
240
-     * @throws InvalidArgumentException
241
-     * @throws InvalidDataTypeException
242
-     * @throws InvalidInterfaceException
243
-     * @throws RuntimeException
244
-     */
245
-    public static function receiveSpcoRegStepForm($req_data = array(), EE_Form_Section_Proper $reg_form)
246
-    {
247
-        // do nothing if form isn't for a reg step or test has already been passed
248
-        if (! EED_Recaptcha_Invisible::processSpcoRegStepForm($reg_form)) {
249
-            return $req_data;
250
-        }
251
-        /** @var EE_Request $request */
252
-        $request = LoaderFactory::getLoader()->getShared('EE_Request');
253
-        if (! EED_Recaptcha_Invisible::verifyToken($request)) {
254
-            if ($request->isAjax()) {
255
-                $json_response = new EE_SPCO_JSON_Response();
256
-                $json_response->echoAndExit();
257
-            }
258
-            EEH_URL::safeRedirectAndExit(
259
-                EE_Registry::instance()->CFG->core->reg_page_url()
260
-            );
261
-        }
262
-        return $req_data;
263
-    }
264
-
265
-
266
-    /**
267
-     * @param string   $html
268
-     * @param EE_Event $event
269
-     * @param bool     $iframe
270
-     * @return string
271
-     * @throws EE_Error
272
-     * @throws InvalidArgumentException
273
-     * @throws InvalidDataTypeException
274
-     * @throws InvalidInterfaceException
275
-     * @throws ReflectionException
276
-     * @throws DomainException
277
-     */
278
-    public static function ticketSelectorForm($html = '', EE_Event $event, $iframe = false)
279
-    {
280
-        $recaptcha = RecaptchaFactory::create();
281
-        // do nothing if test has  already  been passed
282
-        if ($recaptcha->recaptchaPassed()) {
283
-            return $html;
284
-        }
285
-        $html .= $recaptcha->getInputHtml(
286
-            array(
287
-                'recaptcha_id'   => $event->ID(),
288
-                'iframe'         => $iframe,
289
-                'localized_vars' => $recaptcha->getLocalizedVars(),
290
-            )
291
-        );
292
-        return $html;
293
-    }
294
-
295
-
296
-    /**
297
-     * @return void
298
-     * @throws InvalidArgumentException
299
-     * @throws InvalidInterfaceException
300
-     * @throws InvalidDataTypeException
301
-     * @throws RuntimeException
302
-     */
303
-    public static function processTicketSelectorForm()
304
-    {
305
-        // do nothing if test has  already  been passed
306
-        if (RecaptchaFactory::create()->recaptchaPassed()) {
307
-            return;
308
-        }
309
-        /** @var EE_Request $request */
310
-        $request = LoaderFactory::getLoader()->getShared('EE_Request');
311
-        if (! EED_Recaptcha_Invisible::verifyToken($request)) {
312
-            $event_id   = $request->get('tkt-slctr-event-id');
313
-            $return_url = $request->is_set("tkt-slctr-return-url-{$event_id}")
314
-                ? $request->get("tkt-slctr-return-url-{$event_id}")
315
-                : get_permalink($event_id);
316
-            EEH_URL::safeRedirectAndExit($return_url);
317
-        }
318
-    }
319
-
320
-
321
-    /**
322
-     * @throws EE_Error
323
-     * @throws InvalidArgumentException
324
-     * @throws InvalidDataTypeException
325
-     * @throws InvalidInterfaceException
326
-     */
327
-    public static function adminSettings()
328
-    {
329
-        RecaptchaFactory::getAdminModule()->adminSettings();
330
-    }
331
-
332
-
333
-    /**
334
-     * @param EE_Registration_Config $EE_Registration_Config
335
-     * @return EE_Registration_Config
336
-     * @throws EE_Error
337
-     * @throws InvalidArgumentException
338
-     * @throws InvalidDataTypeException
339
-     * @throws InvalidInterfaceException
340
-     * @throws ReflectionException
341
-     */
342
-    public static function updateAdminSettings(EE_Registration_Config $EE_Registration_Config)
343
-    {
344
-        return RecaptchaFactory::getAdminModule()->updateAdminSettings($EE_Registration_Config);
345
-    }
24
+	/**
25
+	 * @var EE_Registration_Config $config
26
+	 */
27
+	private static $config;
28
+
29
+
30
+	/**
31
+	 * @return EED_Module|EED_Recaptcha
32
+	 */
33
+	public static function instance()
34
+	{
35
+		return parent::get_instance(__CLASS__);
36
+	}
37
+
38
+
39
+	/**
40
+	 * @return void
41
+	 * @throws InvalidInterfaceException
42
+	 * @throws InvalidDataTypeException
43
+	 * @throws InvalidArgumentException
44
+	 */
45
+	public static function set_hooks()
46
+	{
47
+		EED_Recaptcha_Invisible::setProperties();
48
+		if (EED_Recaptcha_Invisible::useInvisibleRecaptcha()) {
49
+			if(EED_Recaptcha_Invisible::protectForm('ticket_selector')){
50
+				// ticket selection
51
+				add_filter(
52
+					'FHEE__EE_Ticket_Selector__after_ticket_selector_submit',
53
+					array('EED_Recaptcha_Invisible', 'ticketSelectorForm'),
54
+					10, 3
55
+				);
56
+				add_action(
57
+					'EED_Ticket_Selector__process_ticket_selections__before',
58
+					array('EED_Recaptcha_Invisible', 'processTicketSelectorForm')
59
+				);
60
+			}
61
+			if (EED_Recaptcha_Invisible::protectForm('registration_form')) {
62
+				// checkout
63
+				add_action(
64
+					'AHEE__EE_SPCO_Reg_Step__display_reg_form__reg_form',
65
+					array('EED_Recaptcha_Invisible', 'spcoRegStepForm')
66
+				);
67
+				add_filter(
68
+					'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data',
69
+					array('EED_Recaptcha_Invisible', 'receiveSpcoRegStepForm'),
70
+					10, 2
71
+				);
72
+			}
73
+			add_action('loop_end', array('EED_Recaptcha_Invisible', 'localizeScriptVars'));
74
+		}
75
+	}
76
+
77
+
78
+	/**
79
+	 * @return void
80
+	 * @throws InvalidInterfaceException
81
+	 * @throws InvalidDataTypeException
82
+	 * @throws InvalidArgumentException
83
+	 */
84
+	public static function set_hooks_admin()
85
+	{
86
+		EED_Recaptcha_Invisible::setProperties();
87
+		if (EED_Recaptcha_Invisible::protectForm('ticket_selector')) {
88
+			add_action(
89
+				'EED_Ticket_Selector__process_ticket_selections__before',
90
+				array('EED_Recaptcha_Invisible', 'processTicketSelectorForm')
91
+			);
92
+		}
93
+		if (EED_Recaptcha_Invisible::protectForm('registration_form')) {
94
+			add_filter(
95
+				'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data',
96
+				array('EED_Recaptcha_Invisible', 'receiveSpcoRegStepForm'),
97
+				10, 2
98
+			);
99
+		}
100
+		// admin settings
101
+		add_action(
102
+			'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
103
+			array('EED_Recaptcha_Invisible', 'adminSettings')
104
+		);
105
+		add_filter(
106
+			'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration',
107
+			array('EED_Recaptcha_Invisible', 'updateAdminSettings')
108
+		);
109
+	}
110
+
111
+
112
+	/**
113
+	 * @return void
114
+	 * @throws InvalidInterfaceException
115
+	 * @throws InvalidDataTypeException
116
+	 * @throws InvalidArgumentException
117
+	 */
118
+	public static function setProperties()
119
+	{
120
+
121
+		EED_Recaptcha_Invisible::$config = EE_Registry::instance()->CFG->registration;
122
+	}
123
+
124
+
125
+
126
+	/**
127
+	 * @return boolean
128
+	 */
129
+	public static function useInvisibleRecaptcha()
130
+	{
131
+		return EED_Recaptcha_Invisible::$config->use_captcha
132
+			   && EED_Recaptcha_Invisible::$config->recaptcha_theme === 'invisible';
133
+	}
134
+
135
+
136
+	/**
137
+	 * @param string $form
138
+	 * @return boolean
139
+	 */
140
+	public static function protectForm($form)
141
+	{
142
+		return is_array(EED_Recaptcha_Invisible::$config->recaptcha_protected_forms)
143
+			&& in_array($form, EED_Recaptcha_Invisible::$config->recaptcha_protected_forms, true);
144
+	}
145
+
146
+
147
+
148
+
149
+	/**
150
+	 * @return void
151
+	 * @throws InvalidInterfaceException
152
+	 * @throws InvalidDataTypeException
153
+	 * @throws InvalidArgumentException
154
+	 */
155
+	public static function localizeScriptVars()
156
+	{
157
+		wp_localize_script(
158
+			EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA,
159
+			'eeRecaptcha',
160
+			RecaptchaFactory::create()->getLocalizedVars()
161
+		);
162
+	}
163
+
164
+
165
+	/**
166
+	 * @return string
167
+	 */
168
+	public static function assetsUrl()
169
+	{
170
+		return plugin_dir_url(__FILE__) . 'assets' . DS;
171
+	}
172
+
173
+
174
+	/**
175
+	 * @param \WP $WP
176
+	 */
177
+	public function run($WP)
178
+	{
179
+	}
180
+
181
+
182
+
183
+	/**
184
+	 * @param EE_Request $request
185
+	 * @return bool
186
+	 * @throws InvalidArgumentException
187
+	 * @throws InvalidDataTypeException
188
+	 * @throws InvalidInterfaceException
189
+	 * @throws RuntimeException
190
+	 */
191
+	public static function verifyToken(EE_Request $request)
192
+	{
193
+		return RecaptchaFactory::create()->verifyToken($request);
194
+	}
195
+
196
+
197
+	/**
198
+	 * @param EE_Form_Section_Proper $reg_form
199
+	 * @return void
200
+	 * @throws EE_Error
201
+	 * @throws InvalidArgumentException
202
+	 * @throws InvalidDataTypeException
203
+	 * @throws InvalidInterfaceException
204
+	 * @throws DomainException
205
+	 */
206
+	public static function spcoRegStepForm(EE_Form_Section_Proper $reg_form)
207
+	{
208
+		// do nothing if form isn't for a reg step or test has already been passed
209
+		if (! EED_Recaptcha_Invisible::processSpcoRegStepForm($reg_form)) {
210
+			return;
211
+		}
212
+		$default_hidden_inputs = $reg_form->get_subsection('default_hidden_inputs');
213
+		if ($default_hidden_inputs instanceof EE_Form_Section_Proper) {
214
+			$invisible_recaptcha = RecaptchaFactory::create();
215
+			$invisible_recaptcha->addToFormSection($default_hidden_inputs);
216
+		}
217
+	}
218
+
219
+
220
+	/**
221
+	 * @param EE_Form_Section_Proper $reg_form
222
+	 * @return bool
223
+	 * @throws InvalidDataTypeException
224
+	 * @throws InvalidInterfaceException
225
+	 * @throws EE_Error
226
+	 * @throws InvalidArgumentException
227
+	 */
228
+	public static function processSpcoRegStepForm(EE_Form_Section_Proper $reg_form)
229
+	{
230
+		return strpos($reg_form->name(), 'reg-step-form') !== false
231
+			   && ! RecaptchaFactory::create()->recaptchaPassed();
232
+	}
233
+
234
+
235
+	/**
236
+	 * @param array|null             $req_data
237
+	 * @param EE_Form_Section_Proper $reg_form
238
+	 * @return array
239
+	 * @throws EE_Error
240
+	 * @throws InvalidArgumentException
241
+	 * @throws InvalidDataTypeException
242
+	 * @throws InvalidInterfaceException
243
+	 * @throws RuntimeException
244
+	 */
245
+	public static function receiveSpcoRegStepForm($req_data = array(), EE_Form_Section_Proper $reg_form)
246
+	{
247
+		// do nothing if form isn't for a reg step or test has already been passed
248
+		if (! EED_Recaptcha_Invisible::processSpcoRegStepForm($reg_form)) {
249
+			return $req_data;
250
+		}
251
+		/** @var EE_Request $request */
252
+		$request = LoaderFactory::getLoader()->getShared('EE_Request');
253
+		if (! EED_Recaptcha_Invisible::verifyToken($request)) {
254
+			if ($request->isAjax()) {
255
+				$json_response = new EE_SPCO_JSON_Response();
256
+				$json_response->echoAndExit();
257
+			}
258
+			EEH_URL::safeRedirectAndExit(
259
+				EE_Registry::instance()->CFG->core->reg_page_url()
260
+			);
261
+		}
262
+		return $req_data;
263
+	}
264
+
265
+
266
+	/**
267
+	 * @param string   $html
268
+	 * @param EE_Event $event
269
+	 * @param bool     $iframe
270
+	 * @return string
271
+	 * @throws EE_Error
272
+	 * @throws InvalidArgumentException
273
+	 * @throws InvalidDataTypeException
274
+	 * @throws InvalidInterfaceException
275
+	 * @throws ReflectionException
276
+	 * @throws DomainException
277
+	 */
278
+	public static function ticketSelectorForm($html = '', EE_Event $event, $iframe = false)
279
+	{
280
+		$recaptcha = RecaptchaFactory::create();
281
+		// do nothing if test has  already  been passed
282
+		if ($recaptcha->recaptchaPassed()) {
283
+			return $html;
284
+		}
285
+		$html .= $recaptcha->getInputHtml(
286
+			array(
287
+				'recaptcha_id'   => $event->ID(),
288
+				'iframe'         => $iframe,
289
+				'localized_vars' => $recaptcha->getLocalizedVars(),
290
+			)
291
+		);
292
+		return $html;
293
+	}
294
+
295
+
296
+	/**
297
+	 * @return void
298
+	 * @throws InvalidArgumentException
299
+	 * @throws InvalidInterfaceException
300
+	 * @throws InvalidDataTypeException
301
+	 * @throws RuntimeException
302
+	 */
303
+	public static function processTicketSelectorForm()
304
+	{
305
+		// do nothing if test has  already  been passed
306
+		if (RecaptchaFactory::create()->recaptchaPassed()) {
307
+			return;
308
+		}
309
+		/** @var EE_Request $request */
310
+		$request = LoaderFactory::getLoader()->getShared('EE_Request');
311
+		if (! EED_Recaptcha_Invisible::verifyToken($request)) {
312
+			$event_id   = $request->get('tkt-slctr-event-id');
313
+			$return_url = $request->is_set("tkt-slctr-return-url-{$event_id}")
314
+				? $request->get("tkt-slctr-return-url-{$event_id}")
315
+				: get_permalink($event_id);
316
+			EEH_URL::safeRedirectAndExit($return_url);
317
+		}
318
+	}
319
+
320
+
321
+	/**
322
+	 * @throws EE_Error
323
+	 * @throws InvalidArgumentException
324
+	 * @throws InvalidDataTypeException
325
+	 * @throws InvalidInterfaceException
326
+	 */
327
+	public static function adminSettings()
328
+	{
329
+		RecaptchaFactory::getAdminModule()->adminSettings();
330
+	}
331
+
332
+
333
+	/**
334
+	 * @param EE_Registration_Config $EE_Registration_Config
335
+	 * @return EE_Registration_Config
336
+	 * @throws EE_Error
337
+	 * @throws InvalidArgumentException
338
+	 * @throws InvalidDataTypeException
339
+	 * @throws InvalidInterfaceException
340
+	 * @throws ReflectionException
341
+	 */
342
+	public static function updateAdminSettings(EE_Registration_Config $EE_Registration_Config)
343
+	{
344
+		return RecaptchaFactory::getAdminModule()->updateAdminSettings($EE_Registration_Config);
345
+	}
346 346
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
     {
47 47
         EED_Recaptcha_Invisible::setProperties();
48 48
         if (EED_Recaptcha_Invisible::useInvisibleRecaptcha()) {
49
-            if(EED_Recaptcha_Invisible::protectForm('ticket_selector')){
49
+            if (EED_Recaptcha_Invisible::protectForm('ticket_selector')) {
50 50
                 // ticket selection
51 51
                 add_filter(
52 52
                     'FHEE__EE_Ticket_Selector__after_ticket_selector_submit',
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
      */
168 168
     public static function assetsUrl()
169 169
     {
170
-        return plugin_dir_url(__FILE__) . 'assets' . DS;
170
+        return plugin_dir_url(__FILE__).'assets'.DS;
171 171
     }
172 172
 
173 173
 
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
     public static function spcoRegStepForm(EE_Form_Section_Proper $reg_form)
207 207
     {
208 208
         // do nothing if form isn't for a reg step or test has already been passed
209
-        if (! EED_Recaptcha_Invisible::processSpcoRegStepForm($reg_form)) {
209
+        if ( ! EED_Recaptcha_Invisible::processSpcoRegStepForm($reg_form)) {
210 210
             return;
211 211
         }
212 212
         $default_hidden_inputs = $reg_form->get_subsection('default_hidden_inputs');
@@ -245,12 +245,12 @@  discard block
 block discarded – undo
245 245
     public static function receiveSpcoRegStepForm($req_data = array(), EE_Form_Section_Proper $reg_form)
246 246
     {
247 247
         // do nothing if form isn't for a reg step or test has already been passed
248
-        if (! EED_Recaptcha_Invisible::processSpcoRegStepForm($reg_form)) {
248
+        if ( ! EED_Recaptcha_Invisible::processSpcoRegStepForm($reg_form)) {
249 249
             return $req_data;
250 250
         }
251 251
         /** @var EE_Request $request */
252 252
         $request = LoaderFactory::getLoader()->getShared('EE_Request');
253
-        if (! EED_Recaptcha_Invisible::verifyToken($request)) {
253
+        if ( ! EED_Recaptcha_Invisible::verifyToken($request)) {
254 254
             if ($request->isAjax()) {
255 255
                 $json_response = new EE_SPCO_JSON_Response();
256 256
                 $json_response->echoAndExit();
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
         }
309 309
         /** @var EE_Request $request */
310 310
         $request = LoaderFactory::getLoader()->getShared('EE_Request');
311
-        if (! EED_Recaptcha_Invisible::verifyToken($request)) {
311
+        if ( ! EED_Recaptcha_Invisible::verifyToken($request)) {
312 312
             $event_id   = $request->get('tkt-slctr-event-id');
313 313
             $return_url = $request->is_set("tkt-slctr-return-url-{$event_id}")
314 314
                 ? $request->get("tkt-slctr-return-url-{$event_id}")
Please login to merge, or discard this patch.
caffeinated/modules/recaptcha_invisible/RecaptchaAdminSettings.php 1 patch
Indentation   +321 added lines, -321 removed lines patch added patch discarded remove patch
@@ -35,337 +35,337 @@
 block discarded – undo
35 35
 class RecaptchaAdminSettings
36 36
 {
37 37
 
38
-    /**
39
-     * @var EE_Registration_Config $config
40
-     */
41
-    private $config;
38
+	/**
39
+	 * @var EE_Registration_Config $config
40
+	 */
41
+	private $config;
42 42
 
43 43
 
44
-    /**
45
-     * RecaptchaAdminSettings constructor.
46
-     *
47
-     * @param EE_Registration_Config $registration_config
48
-     */
49
-    public function __construct(EE_Registration_Config $registration_config)
50
-    {
51
-        $this->config = $registration_config;
52
-    }
44
+	/**
45
+	 * RecaptchaAdminSettings constructor.
46
+	 *
47
+	 * @param EE_Registration_Config $registration_config
48
+	 */
49
+	public function __construct(EE_Registration_Config $registration_config)
50
+	{
51
+		$this->config = $registration_config;
52
+	}
53 53
 
54 54
 
55
-    /**
56
-     * @throws InvalidArgumentException
57
-     * @throws InvalidInterfaceException
58
-     * @throws InvalidDataTypeException
59
-     * @throws EE_Error
60
-     */
61
-    public function adminSettings()
62
-    {
63
-        echo $this->settingsForm()->get_html_and_js();
64
-    }
55
+	/**
56
+	 * @throws InvalidArgumentException
57
+	 * @throws InvalidInterfaceException
58
+	 * @throws InvalidDataTypeException
59
+	 * @throws EE_Error
60
+	 */
61
+	public function adminSettings()
62
+	{
63
+		echo $this->settingsForm()->get_html_and_js();
64
+	}
65 65
 
66 66
 
67
-    /**
68
-     * @return EE_Form_Section_Proper
69
-     * @throws EE_Error
70
-     */
71
-    protected function settingsForm()
72
-    {
73
-        return new EE_Form_Section_Proper(
74
-            array(
75
-                'name'            => 'recaptcha_settings_form',
76
-                'html_id'         => 'recaptcha_settings_form',
77
-                'layout_strategy' => new EE_Div_Per_Section_Layout(),
78
-                'subsections'     => apply_filters(
79
-                    'FHEE__EED_Recaptcha___recaptcha_settings_form__form_subsections',
80
-                    array(
81
-                        'main_settings_hdr'       => new EE_Form_Section_HTML(
82
-                            EEH_HTML::h2(
83
-                                esc_html__('reCAPTCHA Anti-spam Settings', 'event_espresso')
84
-                                . EEH_Template::get_help_tab_link('recaptcha_info')
85
-                            )
86
-                        ),
87
-                        'main_settings'           => $this->mainSettings(),
88
-                        'appearance_settings_hdr' => new EE_Form_Section_HTML(
89
-                            EEH_HTML::h2(esc_html__('reCAPTCHA Appearance', 'event_espresso'))
90
-                        ),
91
-                        'appearance_settings'     => $this->appearanceSettings(),
92
-                        'required_fields_note'    => new EE_Form_Section_HTML(
93
-                            EEH_HTML::p(
94
-                                esc_html__('All fields marked with a * are required fields', 'event_espresso'),
95
-                                '', 'grey-text'
96
-                            )
97
-                        ),
98
-                    )
99
-                ),
100
-            )
101
-        );
102
-    }
67
+	/**
68
+	 * @return EE_Form_Section_Proper
69
+	 * @throws EE_Error
70
+	 */
71
+	protected function settingsForm()
72
+	{
73
+		return new EE_Form_Section_Proper(
74
+			array(
75
+				'name'            => 'recaptcha_settings_form',
76
+				'html_id'         => 'recaptcha_settings_form',
77
+				'layout_strategy' => new EE_Div_Per_Section_Layout(),
78
+				'subsections'     => apply_filters(
79
+					'FHEE__EED_Recaptcha___recaptcha_settings_form__form_subsections',
80
+					array(
81
+						'main_settings_hdr'       => new EE_Form_Section_HTML(
82
+							EEH_HTML::h2(
83
+								esc_html__('reCAPTCHA Anti-spam Settings', 'event_espresso')
84
+								. EEH_Template::get_help_tab_link('recaptcha_info')
85
+							)
86
+						),
87
+						'main_settings'           => $this->mainSettings(),
88
+						'appearance_settings_hdr' => new EE_Form_Section_HTML(
89
+							EEH_HTML::h2(esc_html__('reCAPTCHA Appearance', 'event_espresso'))
90
+						),
91
+						'appearance_settings'     => $this->appearanceSettings(),
92
+						'required_fields_note'    => new EE_Form_Section_HTML(
93
+							EEH_HTML::p(
94
+								esc_html__('All fields marked with a * are required fields', 'event_espresso'),
95
+								'', 'grey-text'
96
+							)
97
+						),
98
+					)
99
+				),
100
+			)
101
+		);
102
+	}
103 103
 
104 104
 
105
-    /**
106
-     * @return EE_Form_Section_Proper
107
-     * @throws EE_Error
108
-     */
109
-    protected function mainSettings()
110
-    {
111
-        return new EE_Form_Section_Proper(
112
-            array(
113
-                'name'            => 'recaptcha_settings_tbl',
114
-                'html_id'         => 'recaptcha_settings_tbl',
115
-                'html_class'      => 'form-table',
116
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
117
-                'subsections'     => apply_filters(
118
-                    'FHEE__EED_Recaptcha___recaptcha_main_settings__form_subsections',
119
-                    array(
120
-                        'use_captcha'          => new EE_Yes_No_Input(
121
-                            array(
122
-                                'html_label_text'         => esc_html__('Use reCAPTCHA', 'event_espresso'),
123
-                                'html_help_text'          => sprintf(
124
-                                    esc_html__('reCAPTCHA is a free service that  protects your website from spam and abuse. It employs advanced risk analysis technology to separate humans from abusive actors. Sign up %1$shere%2$s to receive your Public and Private keys.',
125
-                                        'event_espresso'),
126
-                                    '<a href="https://www.google.com/recaptcha/intro/index.html">',
127
-                                    '</a>'
128
-                                ),
129
-                                'default'                 => $this->config->use_captcha !== null
130
-                                    ? $this->config->use_captcha : false,
131
-                                'display_html_label_text' => false,
132
-                            )
133
-                        ),
134
-                        'recaptcha_publickey'  => new EE_Text_Input(
135
-                            array(
136
-                                'html_label_text' => esc_html__('Site Key', 'event_espresso'),
137
-                                'html_help_text'  => esc_html__('The site key is used to display the widget on your site.',
138
-                                    'event_espresso'),
139
-                                'default'         => $this->config->recaptcha_publickey !== null
140
-                                    ? stripslashes($this->config->recaptcha_publickey) : '',
141
-                            )
142
-                        ),
143
-                        'recaptcha_privatekey' => new EE_Text_Input(
144
-                            array(
145
-                                'html_label_text' => esc_html__('Secret Key', 'event_espresso'),
146
-                                'html_help_text'  => esc_html__('The secret key authorizes communication between your application backend and the reCAPTCHA server to verify the user\'s response. The secret key needs to be kept safe for security purposes.',
147
-                                    'event_espresso'),
148
-                                'default'         => $this->config->recaptcha_privatekey !== null
149
-                                    ? stripslashes($this->config->recaptcha_privatekey)
150
-                                    : '',
151
-                            )
152
-                        ),
153
-                        'recaptcha_protected_forms' => new EE_Checkbox_Multi_Input(
154
-                            array(
155
-                                'ticket_selector'   => esc_html__('Ticket Selector', 'event_espresso'),
156
-                                'registration_form' => esc_html__('Registration Form', 'event_espresso'),
157
-                            ),
158
-                            array(
159
-                                'html_label_text'         => esc_html__('Invisible reCAPTCHA Protection', 'event_espresso'),
160
-                                'html_help_text'          => esc_html__('Select which Event Espresso forms you would like to enable Invisible reCAPTCHA on.',
161
-                                    'event_espresso'),
162
-                                'default'                 => is_array($this->config->recaptcha_protected_forms)
163
-                                    ? $this->config->recaptcha_protected_forms
164
-                                    : array(),
165
-                                'display_html_label_text' => false,
166
-                            )
167
-                        ),
168
-                    )
169
-                ),
170
-            )
171
-        );
172
-    }
105
+	/**
106
+	 * @return EE_Form_Section_Proper
107
+	 * @throws EE_Error
108
+	 */
109
+	protected function mainSettings()
110
+	{
111
+		return new EE_Form_Section_Proper(
112
+			array(
113
+				'name'            => 'recaptcha_settings_tbl',
114
+				'html_id'         => 'recaptcha_settings_tbl',
115
+				'html_class'      => 'form-table',
116
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
117
+				'subsections'     => apply_filters(
118
+					'FHEE__EED_Recaptcha___recaptcha_main_settings__form_subsections',
119
+					array(
120
+						'use_captcha'          => new EE_Yes_No_Input(
121
+							array(
122
+								'html_label_text'         => esc_html__('Use reCAPTCHA', 'event_espresso'),
123
+								'html_help_text'          => sprintf(
124
+									esc_html__('reCAPTCHA is a free service that  protects your website from spam and abuse. It employs advanced risk analysis technology to separate humans from abusive actors. Sign up %1$shere%2$s to receive your Public and Private keys.',
125
+										'event_espresso'),
126
+									'<a href="https://www.google.com/recaptcha/intro/index.html">',
127
+									'</a>'
128
+								),
129
+								'default'                 => $this->config->use_captcha !== null
130
+									? $this->config->use_captcha : false,
131
+								'display_html_label_text' => false,
132
+							)
133
+						),
134
+						'recaptcha_publickey'  => new EE_Text_Input(
135
+							array(
136
+								'html_label_text' => esc_html__('Site Key', 'event_espresso'),
137
+								'html_help_text'  => esc_html__('The site key is used to display the widget on your site.',
138
+									'event_espresso'),
139
+								'default'         => $this->config->recaptcha_publickey !== null
140
+									? stripslashes($this->config->recaptcha_publickey) : '',
141
+							)
142
+						),
143
+						'recaptcha_privatekey' => new EE_Text_Input(
144
+							array(
145
+								'html_label_text' => esc_html__('Secret Key', 'event_espresso'),
146
+								'html_help_text'  => esc_html__('The secret key authorizes communication between your application backend and the reCAPTCHA server to verify the user\'s response. The secret key needs to be kept safe for security purposes.',
147
+									'event_espresso'),
148
+								'default'         => $this->config->recaptcha_privatekey !== null
149
+									? stripslashes($this->config->recaptcha_privatekey)
150
+									: '',
151
+							)
152
+						),
153
+						'recaptcha_protected_forms' => new EE_Checkbox_Multi_Input(
154
+							array(
155
+								'ticket_selector'   => esc_html__('Ticket Selector', 'event_espresso'),
156
+								'registration_form' => esc_html__('Registration Form', 'event_espresso'),
157
+							),
158
+							array(
159
+								'html_label_text'         => esc_html__('Invisible reCAPTCHA Protection', 'event_espresso'),
160
+								'html_help_text'          => esc_html__('Select which Event Espresso forms you would like to enable Invisible reCAPTCHA on.',
161
+									'event_espresso'),
162
+								'default'                 => is_array($this->config->recaptcha_protected_forms)
163
+									? $this->config->recaptcha_protected_forms
164
+									: array(),
165
+								'display_html_label_text' => false,
166
+							)
167
+						),
168
+					)
169
+				),
170
+			)
171
+		);
172
+	}
173 173
 
174 174
 
175
-    /**
176
-     * @return EE_Form_Section_Proper
177
-     * @throws EE_Error
178
-     */
179
-    protected function appearanceSettings()
180
-    {
181
-        return new EE_Form_Section_Proper(
182
-            array(
183
-                'name'            => 'recaptcha_appearance_settings_tbl',
184
-                'html_id'         => 'recaptcha_appearance_settings_tbl',
185
-                'html_class'      => 'form-table',
186
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
187
-                'subsections'     => apply_filters(
188
-                    'FHEE__EED_Recaptcha___recaptcha_appearance_settings__form_subsections',
189
-                    array(
190
-                        'recaptcha_theme'    => new EE_Radio_Button_Input(
191
-                            array(
192
-                                'invisible' => esc_html__('Invisible', 'event_espresso'),
193
-                                'light'     => esc_html__('Light', 'event_espresso'),
194
-                                'dark'      => esc_html__('Dark', 'event_espresso'),
195
-                            ),
196
-                            array(
197
-                                'html_label_text'         => esc_html__('Theme', 'event_espresso'),
198
-                                'html_help_text'          => esc_html__('The color theme of the widget.',
199
-                                    'event_espresso'),
200
-                                'default'                 => $this->config->recaptcha_theme !== null
201
-                                    ? $this->config->recaptcha_theme
202
-                                    : 'invisible',
203
-                                'display_html_label_text' => false,
204
-                            )
205
-                        ),
206
-                        'recaptcha_badge'     => new EE_Radio_Button_Input(
207
-                            array(
208
-                                'bottomleft' => esc_html__('Bottom Left', 'event_espresso'),
209
-                                'bottomright' => esc_html__('Bottom Right', 'event_espresso'),
210
-                                'inline' => esc_html__('Inline', 'event_espresso'),
211
-                            ),
212
-                            array(
213
-                                'html_label_text'         => esc_html__('Invisible reCAPTCHA Badge Position', 'event_espresso'),
214
-                                'html_help_text'          => esc_html__(
215
-                                    'If using Invisible reCAPTCHA, then this determines the position of the reCAPTCHA badge. "Bottom Left" and "Bottom Right" both will float at the bottom of the screen. "Inline" appears beside the submit button but allows you to control the CSS.',
216
-                                    'event_espresso'
217
-                                ),
218
-                                'default'                 => $this->config->recaptcha_badge !== null
219
-                                    ? $this->config->recaptcha_badge
220
-                                    : 'bottomleft',
221
-                                'display_html_label_text' => false,
222
-                            )
223
-                        ),
224
-                        'recaptcha_type'     => new EE_Radio_Button_Input(
225
-                            array(
226
-                                'image' => esc_html__('Image', 'event_espresso'),
227
-                                'audio' => esc_html__('Audio', 'event_espresso'),
228
-                            ),
229
-                            array(
230
-                                'html_label_text'         => esc_html__('Type', 'event_espresso'),
231
-                                'html_help_text'          => esc_html__('The type of CAPTCHA to serve.',
232
-                                    'event_espresso'),
233
-                                'default'                 => $this->config->recaptcha_type !== null
234
-                                    ? $this->config->recaptcha_type
235
-                                    : 'image',
236
-                                'display_html_label_text' => false,
237
-                            )
238
-                        ),
239
-                        'recaptcha_language' => new EE_Select_Input(
240
-                            array(
241
-                                'ar'     => esc_html__('Arabic', 'event_espresso'),
242
-                                'bg'     => esc_html__('Bulgarian', 'event_espresso'),
243
-                                'ca'     => esc_html__('Catalan', 'event_espresso'),
244
-                                'zh-CN'  => esc_html__('Chinese (Simplified)', 'event_espresso'),
245
-                                'zh-TW'  => esc_html__('Chinese (Traditional)	', 'event_espresso'),
246
-                                'hr'     => esc_html__('Croatian', 'event_espresso'),
247
-                                'cs'     => esc_html__('Czech', 'event_espresso'),
248
-                                'da'     => esc_html__('Danish', 'event_espresso'),
249
-                                'nl'     => esc_html__('Dutch', 'event_espresso'),
250
-                                'en-GB'  => esc_html__('English (UK)', 'event_espresso'),
251
-                                'en'     => esc_html__('English (US)', 'event_espresso'),
252
-                                'fil'    => esc_html__('Filipino', 'event_espresso'),
253
-                                'fi'     => esc_html__('Finnish', 'event_espresso'),
254
-                                'fr'     => esc_html__('French', 'event_espresso'),
255
-                                'fr-CA'  => esc_html__('French (Canadian)', 'event_espresso'),
256
-                                'de'     => esc_html__('German', 'event_espresso'),
257
-                                'de-AT'  => esc_html__('German (Austria)', 'event_espresso'),
258
-                                'de-CH'  => esc_html__('German (Switzerland)', 'event_espresso'),
259
-                                'el'     => esc_html__('Greek', 'event_espresso'),
260
-                                'iw'     => esc_html__('Hebrew', 'event_espresso'),
261
-                                'hi'     => esc_html__('Hindi', 'event_espresso'),
262
-                                'hu'     => esc_html__('Hungarian', 'event_espresso'),
263
-                                'id'     => esc_html__('Indonesian', 'event_espresso'),
264
-                                'it'     => esc_html__('Italian', 'event_espresso'),
265
-                                'ja'     => esc_html__('Japanese', 'event_espresso'),
266
-                                'ko'     => esc_html__('Korean', 'event_espresso'),
267
-                                'lv'     => esc_html__('Latvian', 'event_espresso'),
268
-                                'lt'     => esc_html__('Lithuanian', 'event_espresso'),
269
-                                'no'     => esc_html__('Norwegian', 'event_espresso'),
270
-                                'fa'     => esc_html__('Persian', 'event_espresso'),
271
-                                'pl'     => esc_html__('Polish', 'event_espresso'),
272
-                                'pt'     => esc_html__('Portuguese', 'event_espresso'),
273
-                                'pt-BR'  => esc_html__('Portuguese (Brazil)', 'event_espresso'),
274
-                                'pt-PT'  => esc_html__('Portuguese (Portugal)', 'event_espresso'),
275
-                                'ro'     => esc_html__('Romanian', 'event_espresso'),
276
-                                'ru'     => esc_html__('Russian', 'event_espresso'),
277
-                                'sr'     => esc_html__('Serbian', 'event_espresso'),
278
-                                'sk'     => esc_html__('Slovak', 'event_espresso'),
279
-                                'sl'     => esc_html__('Slovenian', 'event_espresso'),
280
-                                'es'     => esc_html__('Spanish', 'event_espresso'),
281
-                                'es-419' => esc_html__('Spanish (Latin America)', 'event_espresso'),
282
-                                'sv'     => esc_html__('Swedish', 'event_espresso'),
283
-                                'th'     => esc_html__('Thai', 'event_espresso'),
284
-                                'tr'     => esc_html__('Turkish', 'event_espresso'),
285
-                                'uk'     => esc_html__('Ukrainian', 'event_espresso'),
286
-                                'vi'     => esc_html__('Vietnamese', 'event_espresso'),
287
-                            ),
288
-                            array(
289
-                                'html_label_text' => esc_html__('Language', 'event_espresso'),
290
-                                'html_help_text'  => esc_html__('Forces the widget to render in a specific language.',
291
-                                    'event_espresso'),
292
-                                'default'         => $this->config->recaptcha_language !== null
293
-                                    ? $this->config->recaptcha_language : 'en',
294
-                            )
295
-                        ),
296
-                    )
297
-                ),
298
-            )
299
-        );
300
-    }
175
+	/**
176
+	 * @return EE_Form_Section_Proper
177
+	 * @throws EE_Error
178
+	 */
179
+	protected function appearanceSettings()
180
+	{
181
+		return new EE_Form_Section_Proper(
182
+			array(
183
+				'name'            => 'recaptcha_appearance_settings_tbl',
184
+				'html_id'         => 'recaptcha_appearance_settings_tbl',
185
+				'html_class'      => 'form-table',
186
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
187
+				'subsections'     => apply_filters(
188
+					'FHEE__EED_Recaptcha___recaptcha_appearance_settings__form_subsections',
189
+					array(
190
+						'recaptcha_theme'    => new EE_Radio_Button_Input(
191
+							array(
192
+								'invisible' => esc_html__('Invisible', 'event_espresso'),
193
+								'light'     => esc_html__('Light', 'event_espresso'),
194
+								'dark'      => esc_html__('Dark', 'event_espresso'),
195
+							),
196
+							array(
197
+								'html_label_text'         => esc_html__('Theme', 'event_espresso'),
198
+								'html_help_text'          => esc_html__('The color theme of the widget.',
199
+									'event_espresso'),
200
+								'default'                 => $this->config->recaptcha_theme !== null
201
+									? $this->config->recaptcha_theme
202
+									: 'invisible',
203
+								'display_html_label_text' => false,
204
+							)
205
+						),
206
+						'recaptcha_badge'     => new EE_Radio_Button_Input(
207
+							array(
208
+								'bottomleft' => esc_html__('Bottom Left', 'event_espresso'),
209
+								'bottomright' => esc_html__('Bottom Right', 'event_espresso'),
210
+								'inline' => esc_html__('Inline', 'event_espresso'),
211
+							),
212
+							array(
213
+								'html_label_text'         => esc_html__('Invisible reCAPTCHA Badge Position', 'event_espresso'),
214
+								'html_help_text'          => esc_html__(
215
+									'If using Invisible reCAPTCHA, then this determines the position of the reCAPTCHA badge. "Bottom Left" and "Bottom Right" both will float at the bottom of the screen. "Inline" appears beside the submit button but allows you to control the CSS.',
216
+									'event_espresso'
217
+								),
218
+								'default'                 => $this->config->recaptcha_badge !== null
219
+									? $this->config->recaptcha_badge
220
+									: 'bottomleft',
221
+								'display_html_label_text' => false,
222
+							)
223
+						),
224
+						'recaptcha_type'     => new EE_Radio_Button_Input(
225
+							array(
226
+								'image' => esc_html__('Image', 'event_espresso'),
227
+								'audio' => esc_html__('Audio', 'event_espresso'),
228
+							),
229
+							array(
230
+								'html_label_text'         => esc_html__('Type', 'event_espresso'),
231
+								'html_help_text'          => esc_html__('The type of CAPTCHA to serve.',
232
+									'event_espresso'),
233
+								'default'                 => $this->config->recaptcha_type !== null
234
+									? $this->config->recaptcha_type
235
+									: 'image',
236
+								'display_html_label_text' => false,
237
+							)
238
+						),
239
+						'recaptcha_language' => new EE_Select_Input(
240
+							array(
241
+								'ar'     => esc_html__('Arabic', 'event_espresso'),
242
+								'bg'     => esc_html__('Bulgarian', 'event_espresso'),
243
+								'ca'     => esc_html__('Catalan', 'event_espresso'),
244
+								'zh-CN'  => esc_html__('Chinese (Simplified)', 'event_espresso'),
245
+								'zh-TW'  => esc_html__('Chinese (Traditional)	', 'event_espresso'),
246
+								'hr'     => esc_html__('Croatian', 'event_espresso'),
247
+								'cs'     => esc_html__('Czech', 'event_espresso'),
248
+								'da'     => esc_html__('Danish', 'event_espresso'),
249
+								'nl'     => esc_html__('Dutch', 'event_espresso'),
250
+								'en-GB'  => esc_html__('English (UK)', 'event_espresso'),
251
+								'en'     => esc_html__('English (US)', 'event_espresso'),
252
+								'fil'    => esc_html__('Filipino', 'event_espresso'),
253
+								'fi'     => esc_html__('Finnish', 'event_espresso'),
254
+								'fr'     => esc_html__('French', 'event_espresso'),
255
+								'fr-CA'  => esc_html__('French (Canadian)', 'event_espresso'),
256
+								'de'     => esc_html__('German', 'event_espresso'),
257
+								'de-AT'  => esc_html__('German (Austria)', 'event_espresso'),
258
+								'de-CH'  => esc_html__('German (Switzerland)', 'event_espresso'),
259
+								'el'     => esc_html__('Greek', 'event_espresso'),
260
+								'iw'     => esc_html__('Hebrew', 'event_espresso'),
261
+								'hi'     => esc_html__('Hindi', 'event_espresso'),
262
+								'hu'     => esc_html__('Hungarian', 'event_espresso'),
263
+								'id'     => esc_html__('Indonesian', 'event_espresso'),
264
+								'it'     => esc_html__('Italian', 'event_espresso'),
265
+								'ja'     => esc_html__('Japanese', 'event_espresso'),
266
+								'ko'     => esc_html__('Korean', 'event_espresso'),
267
+								'lv'     => esc_html__('Latvian', 'event_espresso'),
268
+								'lt'     => esc_html__('Lithuanian', 'event_espresso'),
269
+								'no'     => esc_html__('Norwegian', 'event_espresso'),
270
+								'fa'     => esc_html__('Persian', 'event_espresso'),
271
+								'pl'     => esc_html__('Polish', 'event_espresso'),
272
+								'pt'     => esc_html__('Portuguese', 'event_espresso'),
273
+								'pt-BR'  => esc_html__('Portuguese (Brazil)', 'event_espresso'),
274
+								'pt-PT'  => esc_html__('Portuguese (Portugal)', 'event_espresso'),
275
+								'ro'     => esc_html__('Romanian', 'event_espresso'),
276
+								'ru'     => esc_html__('Russian', 'event_espresso'),
277
+								'sr'     => esc_html__('Serbian', 'event_espresso'),
278
+								'sk'     => esc_html__('Slovak', 'event_espresso'),
279
+								'sl'     => esc_html__('Slovenian', 'event_espresso'),
280
+								'es'     => esc_html__('Spanish', 'event_espresso'),
281
+								'es-419' => esc_html__('Spanish (Latin America)', 'event_espresso'),
282
+								'sv'     => esc_html__('Swedish', 'event_espresso'),
283
+								'th'     => esc_html__('Thai', 'event_espresso'),
284
+								'tr'     => esc_html__('Turkish', 'event_espresso'),
285
+								'uk'     => esc_html__('Ukrainian', 'event_espresso'),
286
+								'vi'     => esc_html__('Vietnamese', 'event_espresso'),
287
+							),
288
+							array(
289
+								'html_label_text' => esc_html__('Language', 'event_espresso'),
290
+								'html_help_text'  => esc_html__('Forces the widget to render in a specific language.',
291
+									'event_espresso'),
292
+								'default'         => $this->config->recaptcha_language !== null
293
+									? $this->config->recaptcha_language : 'en',
294
+							)
295
+						),
296
+					)
297
+				),
298
+			)
299
+		);
300
+	}
301 301
 
302 302
 
303
-    /**
304
-     * @param EE_Registration_Config $EE_Registration_Config
305
-     * @return EE_Registration_Config
306
-     * @throws InvalidArgumentException
307
-     * @throws InvalidInterfaceException
308
-     * @throws InvalidDataTypeException
309
-     * @throws EE_Error
310
-     * @throws ReflectionException
311
-     */
312
-    public function updateAdminSettings(EE_Registration_Config $EE_Registration_Config)
313
-    {
314
-        try {
315
-            $recaptcha_settings_form = $this->settingsForm();
316
-            // if not displaying a form, then check for form submission
317
-            if ($recaptcha_settings_form->was_submitted()) {
318
-                // capture form data
319
-                $recaptcha_settings_form->receive_form_submission();
320
-                // validate form data
321
-                if ($recaptcha_settings_form->is_valid()) {
322
-                    // grab validated data from form
323
-                    $valid_data = $recaptcha_settings_form->valid_data();
324
-                    // user proofing recaptcha:  If Use reCAPTCHA is set to yes but we dont' have site or secret keys then set Use reCAPTCHA to FALSE and give error message.
325
-                    if (
326
-                        $valid_data['main_settings']['use_captcha']
327
-                        && (
328
-                            ! $EE_Registration_Config->use_captcha
329
-                            && (
330
-                                empty($valid_data['main_settings']['recaptcha_publickey'])
331
-                                || empty($valid_data['main_settings']['recaptcha_privatekey'])
332
-                            )
333
-                        )
334
-                        && apply_filters(
335
-                            'FHEE__Extend_Registration_Form_Admin_Page__check_for_recaptcha_keys',
336
-                            true,
337
-                            $EE_Registration_Config
338
-                        )
339
-                    ) {
340
-                        $valid_data['main_settings']['use_captcha'] = false;
341
-                        EE_Error::add_error(
342
-                            esc_html__(
343
-                                'The use reCAPTCHA setting has been reset to "no". In order to enable the reCAPTCHA service, you must enter a Site Key and Secret Key.',
344
-                                'event_espresso'
345
-                            ),
346
-                            __FILE__, __FUNCTION__, __LINE__
347
-                        );
348
-                    }
349
-                    $EE_Registration_Config->use_captcha          = $valid_data['main_settings']['use_captcha'];
350
-                    $EE_Registration_Config->recaptcha_publickey  = $valid_data['main_settings']['recaptcha_publickey'];
351
-                    $EE_Registration_Config->recaptcha_protected_forms = $valid_data['main_settings']['recaptcha_protected_forms'];
352
-                    $EE_Registration_Config->recaptcha_privatekey = $valid_data['main_settings']['recaptcha_privatekey'];
353
-                    $EE_Registration_Config->recaptcha_type       = $valid_data['appearance_settings']['recaptcha_type'];
354
-                    $EE_Registration_Config->recaptcha_theme      = $valid_data['appearance_settings']['recaptcha_theme'];
355
-                    $EE_Registration_Config->recaptcha_badge      = $valid_data['appearance_settings']['recaptcha_badge'];
356
-                    $EE_Registration_Config->recaptcha_language   = $valid_data['appearance_settings']['recaptcha_language'];
357
-                } else {
358
-                    if ($recaptcha_settings_form->submission_error_message() !== '') {
359
-                        EE_Error::add_error(
360
-                            $recaptcha_settings_form->submission_error_message(),
361
-                            __FILE__, __FUNCTION__, __LINE__
362
-                        );
363
-                    }
364
-                }
365
-            }
366
-        } catch (EE_Error $e) {
367
-            $e->get_error();
368
-        }
369
-        return $EE_Registration_Config;
370
-    }
303
+	/**
304
+	 * @param EE_Registration_Config $EE_Registration_Config
305
+	 * @return EE_Registration_Config
306
+	 * @throws InvalidArgumentException
307
+	 * @throws InvalidInterfaceException
308
+	 * @throws InvalidDataTypeException
309
+	 * @throws EE_Error
310
+	 * @throws ReflectionException
311
+	 */
312
+	public function updateAdminSettings(EE_Registration_Config $EE_Registration_Config)
313
+	{
314
+		try {
315
+			$recaptcha_settings_form = $this->settingsForm();
316
+			// if not displaying a form, then check for form submission
317
+			if ($recaptcha_settings_form->was_submitted()) {
318
+				// capture form data
319
+				$recaptcha_settings_form->receive_form_submission();
320
+				// validate form data
321
+				if ($recaptcha_settings_form->is_valid()) {
322
+					// grab validated data from form
323
+					$valid_data = $recaptcha_settings_form->valid_data();
324
+					// user proofing recaptcha:  If Use reCAPTCHA is set to yes but we dont' have site or secret keys then set Use reCAPTCHA to FALSE and give error message.
325
+					if (
326
+						$valid_data['main_settings']['use_captcha']
327
+						&& (
328
+							! $EE_Registration_Config->use_captcha
329
+							&& (
330
+								empty($valid_data['main_settings']['recaptcha_publickey'])
331
+								|| empty($valid_data['main_settings']['recaptcha_privatekey'])
332
+							)
333
+						)
334
+						&& apply_filters(
335
+							'FHEE__Extend_Registration_Form_Admin_Page__check_for_recaptcha_keys',
336
+							true,
337
+							$EE_Registration_Config
338
+						)
339
+					) {
340
+						$valid_data['main_settings']['use_captcha'] = false;
341
+						EE_Error::add_error(
342
+							esc_html__(
343
+								'The use reCAPTCHA setting has been reset to "no". In order to enable the reCAPTCHA service, you must enter a Site Key and Secret Key.',
344
+								'event_espresso'
345
+							),
346
+							__FILE__, __FUNCTION__, __LINE__
347
+						);
348
+					}
349
+					$EE_Registration_Config->use_captcha          = $valid_data['main_settings']['use_captcha'];
350
+					$EE_Registration_Config->recaptcha_publickey  = $valid_data['main_settings']['recaptcha_publickey'];
351
+					$EE_Registration_Config->recaptcha_protected_forms = $valid_data['main_settings']['recaptcha_protected_forms'];
352
+					$EE_Registration_Config->recaptcha_privatekey = $valid_data['main_settings']['recaptcha_privatekey'];
353
+					$EE_Registration_Config->recaptcha_type       = $valid_data['appearance_settings']['recaptcha_type'];
354
+					$EE_Registration_Config->recaptcha_theme      = $valid_data['appearance_settings']['recaptcha_theme'];
355
+					$EE_Registration_Config->recaptcha_badge      = $valid_data['appearance_settings']['recaptcha_badge'];
356
+					$EE_Registration_Config->recaptcha_language   = $valid_data['appearance_settings']['recaptcha_language'];
357
+				} else {
358
+					if ($recaptcha_settings_form->submission_error_message() !== '') {
359
+						EE_Error::add_error(
360
+							$recaptcha_settings_form->submission_error_message(),
361
+							__FILE__, __FUNCTION__, __LINE__
362
+						);
363
+					}
364
+				}
365
+			}
366
+		} catch (EE_Error $e) {
367
+			$e->get_error();
368
+		}
369
+		return $EE_Registration_Config;
370
+	}
371 371
 }
Please login to merge, or discard this patch.
core/EE_Config.core.php 1 patch
Indentation   +3078 added lines, -3078 removed lines patch added patch discarded remove patch
@@ -17,2460 +17,2460 @@  discard block
 block discarded – undo
17 17
 final class EE_Config implements ResettableInterface
18 18
 {
19 19
 
20
-    const OPTION_NAME        = 'ee_config';
20
+	const OPTION_NAME        = 'ee_config';
21
+
22
+	const LOG_NAME           = 'ee_config_log';
23
+
24
+	const LOG_LENGTH         = 100;
25
+
26
+	const ADDON_OPTION_NAMES = 'ee_config_option_names';
27
+
28
+
29
+	/**
30
+	 *    instance of the EE_Config object
31
+	 *
32
+	 * @var    EE_Config $_instance
33
+	 * @access    private
34
+	 */
35
+	private static $_instance;
36
+
37
+	/**
38
+	 * @var boolean $_logging_enabled
39
+	 */
40
+	private static $_logging_enabled = false;
41
+
42
+	/**
43
+	 * @var LegacyShortcodesManager $legacy_shortcodes_manager
44
+	 */
45
+	private $legacy_shortcodes_manager;
46
+
47
+	/**
48
+	 * An StdClass whose property names are addon slugs,
49
+	 * and values are their config classes
50
+	 *
51
+	 * @var StdClass
52
+	 */
53
+	public $addons;
54
+
55
+	/**
56
+	 * @var EE_Admin_Config
57
+	 */
58
+	public $admin;
59
+
60
+	/**
61
+	 * @var EE_Core_Config
62
+	 */
63
+	public $core;
64
+
65
+	/**
66
+	 * @var EE_Currency_Config
67
+	 */
68
+	public $currency;
69
+
70
+	/**
71
+	 * @var EE_Organization_Config
72
+	 */
73
+	public $organization;
74
+
75
+	/**
76
+	 * @var EE_Registration_Config
77
+	 */
78
+	public $registration;
79
+
80
+	/**
81
+	 * @var EE_Template_Config
82
+	 */
83
+	public $template_settings;
84
+
85
+	/**
86
+	 * Holds EE environment values.
87
+	 *
88
+	 * @var EE_Environment_Config
89
+	 */
90
+	public $environment;
91
+
92
+	/**
93
+	 * settings pertaining to Google maps
94
+	 *
95
+	 * @var EE_Map_Config
96
+	 */
97
+	public $map_settings;
98
+
99
+	/**
100
+	 * settings pertaining to Taxes
101
+	 *
102
+	 * @var EE_Tax_Config
103
+	 */
104
+	public $tax_settings;
105
+
106
+
107
+	/**
108
+	 * Settings pertaining to global messages settings.
109
+	 *
110
+	 * @var EE_Messages_Config
111
+	 */
112
+	public $messages;
113
+
114
+	/**
115
+	 * @deprecated
116
+	 * @var EE_Gateway_Config
117
+	 */
118
+	public $gateway;
119
+
120
+	/**
121
+	 * @var    array $_addon_option_names
122
+	 * @access    private
123
+	 */
124
+	private $_addon_option_names = array();
125
+
126
+	/**
127
+	 * @var    array $_module_route_map
128
+	 * @access    private
129
+	 */
130
+	private static $_module_route_map = array();
131
+
132
+	/**
133
+	 * @var    array $_module_forward_map
134
+	 * @access    private
135
+	 */
136
+	private static $_module_forward_map = array();
137
+
138
+	/**
139
+	 * @var    array $_module_view_map
140
+	 * @access    private
141
+	 */
142
+	private static $_module_view_map = array();
143
+
144
+
145
+
146
+	/**
147
+	 * @singleton method used to instantiate class object
148
+	 * @access    public
149
+	 * @return EE_Config instance
150
+	 */
151
+	public static function instance()
152
+	{
153
+		// check if class object is instantiated, and instantiated properly
154
+		if (! self::$_instance instanceof EE_Config) {
155
+			self::$_instance = new self();
156
+		}
157
+		return self::$_instance;
158
+	}
159
+
160
+
161
+
162
+	/**
163
+	 * Resets the config
164
+	 *
165
+	 * @param bool    $hard_reset    if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE
166
+	 *                               (default) leaves the database alone, and merely resets the EE_Config object to
167
+	 *                               reflect its state in the database
168
+	 * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave
169
+	 *                               $_instance as NULL. Useful in case you want to forget about the old instance on
170
+	 *                               EE_Config, but might not be ready to instantiate EE_Config currently (eg if the
171
+	 *                               site was put into maintenance mode)
172
+	 * @return EE_Config
173
+	 */
174
+	public static function reset($hard_reset = false, $reinstantiate = true)
175
+	{
176
+		if (self::$_instance instanceof EE_Config) {
177
+			if ($hard_reset) {
178
+				self::$_instance->legacy_shortcodes_manager = null;
179
+				self::$_instance->_addon_option_names = array();
180
+				self::$_instance->_initialize_config();
181
+				self::$_instance->update_espresso_config();
182
+			}
183
+			self::$_instance->update_addon_option_names();
184
+		}
185
+		self::$_instance = null;
186
+		//we don't need to reset the static properties imo because those should
187
+		//only change when a module is added or removed. Currently we don't
188
+		//support removing a module during a request when it previously existed
189
+		if ($reinstantiate) {
190
+			return self::instance();
191
+		} else {
192
+			return null;
193
+		}
194
+	}
195
+
196
+
197
+
198
+	/**
199
+	 *    class constructor
200
+	 *
201
+	 * @access    private
202
+	 */
203
+	private function __construct()
204
+	{
205
+		do_action('AHEE__EE_Config__construct__begin', $this);
206
+		EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
207
+		// setup empty config classes
208
+		$this->_initialize_config();
209
+		// load existing EE site settings
210
+		$this->_load_core_config();
211
+		// confirm everything loaded correctly and set filtered defaults if not
212
+		$this->_verify_config();
213
+		//  register shortcodes and modules
214
+		add_action(
215
+			'AHEE__EE_System__register_shortcodes_modules_and_widgets',
216
+			array($this, 'register_shortcodes_and_modules'),
217
+			999
218
+		);
219
+		//  initialize shortcodes and modules
220
+		add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules'));
221
+		// register widgets
222
+		add_action('widgets_init', array($this, 'widgets_init'), 10);
223
+		// shutdown
224
+		add_action('shutdown', array($this, 'shutdown'), 10);
225
+		// construct__end hook
226
+		do_action('AHEE__EE_Config__construct__end', $this);
227
+		// hardcoded hack
228
+		$this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
229
+	}
230
+
231
+
232
+
233
+	/**
234
+	 * @return boolean
235
+	 */
236
+	public static function logging_enabled()
237
+	{
238
+		return self::$_logging_enabled;
239
+	}
240
+
241
+
242
+
243
+	/**
244
+	 * use to get the current theme if needed from static context
245
+	 *
246
+	 * @return string current theme set.
247
+	 */
248
+	public static function get_current_theme()
249
+	{
250
+		return isset(self::$_instance->template_settings->current_espresso_theme)
251
+			? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
252
+	}
253
+
254
+
255
+
256
+	/**
257
+	 *        _initialize_config
258
+	 *
259
+	 * @access private
260
+	 * @return void
261
+	 */
262
+	private function _initialize_config()
263
+	{
264
+		EE_Config::trim_log();
265
+		//set defaults
266
+		$this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
267
+		$this->addons = new stdClass();
268
+		// set _module_route_map
269
+		EE_Config::$_module_route_map = array();
270
+		// set _module_forward_map
271
+		EE_Config::$_module_forward_map = array();
272
+		// set _module_view_map
273
+		EE_Config::$_module_view_map = array();
274
+	}
275
+
276
+
277
+
278
+	/**
279
+	 *        load core plugin configuration
280
+	 *
281
+	 * @access private
282
+	 * @return void
283
+	 */
284
+	private function _load_core_config()
285
+	{
286
+		// load_core_config__start hook
287
+		do_action('AHEE__EE_Config___load_core_config__start', $this);
288
+		$espresso_config = $this->get_espresso_config();
289
+		foreach ($espresso_config as $config => $settings) {
290
+			// load_core_config__start hook
291
+			$settings = apply_filters(
292
+				'FHEE__EE_Config___load_core_config__config_settings',
293
+				$settings,
294
+				$config,
295
+				$this
296
+			);
297
+			if (is_object($settings) && property_exists($this, $config)) {
298
+				$this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
299
+				//call configs populate method to ensure any defaults are set for empty values.
300
+				if (method_exists($settings, 'populate')) {
301
+					$this->{$config}->populate();
302
+				}
303
+				if (method_exists($settings, 'do_hooks')) {
304
+					$this->{$config}->do_hooks();
305
+				}
306
+			}
307
+		}
308
+		if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
309
+			$this->update_espresso_config();
310
+		}
311
+		// load_core_config__end hook
312
+		do_action('AHEE__EE_Config___load_core_config__end', $this);
313
+	}
314
+
315
+
316
+
317
+	/**
318
+	 *    _verify_config
319
+	 *
320
+	 * @access    protected
321
+	 * @return    void
322
+	 */
323
+	protected function _verify_config()
324
+	{
325
+		$this->core = $this->core instanceof EE_Core_Config
326
+			? $this->core
327
+			: new EE_Core_Config();
328
+		$this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
329
+		$this->organization = $this->organization instanceof EE_Organization_Config
330
+			? $this->organization
331
+			: new EE_Organization_Config();
332
+		$this->organization = apply_filters(
333
+			'FHEE__EE_Config___initialize_config__organization',
334
+			$this->organization
335
+		);
336
+		$this->currency = $this->currency instanceof EE_Currency_Config
337
+			? $this->currency
338
+			: new EE_Currency_Config();
339
+		$this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
340
+		$this->registration = $this->registration instanceof EE_Registration_Config
341
+			? $this->registration
342
+			: new EE_Registration_Config();
343
+		$this->registration = apply_filters(
344
+			'FHEE__EE_Config___initialize_config__registration',
345
+			$this->registration
346
+		);
347
+		$this->admin = $this->admin instanceof EE_Admin_Config
348
+			? $this->admin
349
+			: new EE_Admin_Config();
350
+		$this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
351
+		$this->template_settings = $this->template_settings instanceof EE_Template_Config
352
+			? $this->template_settings
353
+			: new EE_Template_Config();
354
+		$this->template_settings = apply_filters(
355
+			'FHEE__EE_Config___initialize_config__template_settings',
356
+			$this->template_settings
357
+		);
358
+		$this->map_settings = $this->map_settings instanceof EE_Map_Config
359
+			? $this->map_settings
360
+			: new EE_Map_Config();
361
+		$this->map_settings = apply_filters('FHEE__EE_Config___initialize_config__map_settings',
362
+			$this->map_settings);
363
+		$this->environment = $this->environment instanceof EE_Environment_Config
364
+			? $this->environment
365
+			: new EE_Environment_Config();
366
+		$this->environment = apply_filters('FHEE__EE_Config___initialize_config__environment',
367
+			$this->environment);
368
+		$this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
369
+			? $this->tax_settings
370
+			: new EE_Tax_Config();
371
+		$this->tax_settings = apply_filters('FHEE__EE_Config___initialize_config__tax_settings',
372
+			$this->tax_settings);
373
+		$this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages);
374
+		$this->messages = $this->messages instanceof EE_Messages_Config
375
+			? $this->messages
376
+			: new EE_Messages_Config();
377
+		$this->gateway = $this->gateway instanceof EE_Gateway_Config
378
+			? $this->gateway
379
+			: new EE_Gateway_Config();
380
+		$this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
381
+		$this->legacy_shortcodes_manager = null;
382
+	}
383
+
384
+
385
+	/**
386
+	 *    get_espresso_config
387
+	 *
388
+	 * @access    public
389
+	 * @return    array of espresso config stuff
390
+	 */
391
+	public function get_espresso_config()
392
+	{
393
+		// grab espresso configuration
394
+		return apply_filters(
395
+			'FHEE__EE_Config__get_espresso_config__CFG',
396
+			get_option(EE_Config::OPTION_NAME, array())
397
+		);
398
+	}
399
+
400
+
401
+
402
+	/**
403
+	 *    double_check_config_comparison
404
+	 *
405
+	 * @access    public
406
+	 * @param string $option
407
+	 * @param        $old_value
408
+	 * @param        $value
409
+	 */
410
+	public function double_check_config_comparison($option = '', $old_value, $value)
411
+	{
412
+		// make sure we're checking the ee config
413
+		if ($option === EE_Config::OPTION_NAME) {
414
+			// run a loose comparison of the old value against the new value for type and properties,
415
+			// but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
416
+			if ($value != $old_value) {
417
+				// if they are NOT the same, then remove the hook,
418
+				// which means the subsequent update results will be based solely on the update query results
419
+				// the reason we do this is because, as stated above,
420
+				// WP update_option performs an exact instance comparison (===) on any update values passed to it
421
+				// this happens PRIOR to serialization and any subsequent update.
422
+				// If values are found to match their previous old value,
423
+				// then WP bails before performing any update.
424
+				// Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
425
+				// it just pulled from the db, with the one being passed to it (which will not match).
426
+				// HOWEVER, once the object is serialized and passed off to MySQL to update,
427
+				// MySQL MAY ALSO NOT perform the update because
428
+				// the string it sees in the db looks the same as the new one it has been passed!!!
429
+				// This results in the query returning an "affected rows" value of ZERO,
430
+				// which gets returned immediately by WP update_option and looks like an error.
431
+				remove_action('update_option', array($this, 'check_config_updated'));
432
+			}
433
+		}
434
+	}
435
+
436
+
437
+
438
+	/**
439
+	 *    update_espresso_config
440
+	 *
441
+	 * @access   public
442
+	 */
443
+	protected function _reset_espresso_addon_config()
444
+	{
445
+		$this->_addon_option_names = array();
446
+		foreach ($this->addons as $addon_name => $addon_config_obj) {
447
+			$addon_config_obj = maybe_unserialize($addon_config_obj);
448
+			if ($addon_config_obj instanceof EE_Config_Base) {
449
+				$this->update_config('addons', $addon_name, $addon_config_obj, false);
450
+			}
451
+			$this->addons->{$addon_name} = null;
452
+		}
453
+	}
454
+
455
+
456
+
457
+	/**
458
+	 *    update_espresso_config
459
+	 *
460
+	 * @access   public
461
+	 * @param   bool $add_success
462
+	 * @param   bool $add_error
463
+	 * @return   bool
464
+	 */
465
+	public function update_espresso_config($add_success = false, $add_error = true)
466
+	{
467
+		// don't allow config updates during WP heartbeats
468
+		if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
469
+			return false;
470
+		}
471
+		// commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
472
+		//$clone = clone( self::$_instance );
473
+		//self::$_instance = NULL;
474
+		do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
475
+		$this->_reset_espresso_addon_config();
476
+		// hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
477
+		// but BEFORE the actual update occurs
478
+		add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
479
+		// don't want to persist legacy_shortcodes_manager, but don't want to lose it either
480
+		$legacy_shortcodes_manager = $this->legacy_shortcodes_manager;
481
+		$this->legacy_shortcodes_manager = null;
482
+		// now update "ee_config"
483
+		$saved = update_option(EE_Config::OPTION_NAME, $this);
484
+		$this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
485
+		EE_Config::log(EE_Config::OPTION_NAME);
486
+		// if not saved... check if the hook we just added still exists;
487
+		// if it does, it means one of two things:
488
+		// 		that update_option bailed at the ( $value === $old_value ) conditional,
489
+		//		 or...
490
+		// 		the db update query returned 0 rows affected
491
+		// 		(probably because the data  value was the same from it's perspective)
492
+		// so the existence of the hook means that a negative result from update_option is NOT an error,
493
+		// but just means no update occurred, so don't display an error to the user.
494
+		// BUT... if update_option returns FALSE, AND the hook is missing,
495
+		// then it means that something truly went wrong
496
+		$saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
497
+		// remove our action since we don't want it in the system anymore
498
+		remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
499
+		do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
500
+		//self::$_instance = $clone;
501
+		//unset( $clone );
502
+		// if config remains the same or was updated successfully
503
+		if ($saved) {
504
+			if ($add_success) {
505
+				EE_Error::add_success(
506
+					__('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
507
+					__FILE__,
508
+					__FUNCTION__,
509
+					__LINE__
510
+				);
511
+			}
512
+			return true;
513
+		} else {
514
+			if ($add_error) {
515
+				EE_Error::add_error(
516
+					__('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
517
+					__FILE__,
518
+					__FUNCTION__,
519
+					__LINE__
520
+				);
521
+			}
522
+			return false;
523
+		}
524
+	}
525
+
526
+
527
+
528
+	/**
529
+	 *    _verify_config_params
530
+	 *
531
+	 * @access    private
532
+	 * @param    string         $section
533
+	 * @param    string         $name
534
+	 * @param    string         $config_class
535
+	 * @param    EE_Config_Base $config_obj
536
+	 * @param    array          $tests_to_run
537
+	 * @param    bool           $display_errors
538
+	 * @return    bool    TRUE on success, FALSE on fail
539
+	 */
540
+	private function _verify_config_params(
541
+		$section = '',
542
+		$name = '',
543
+		$config_class = '',
544
+		$config_obj = null,
545
+		$tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
546
+		$display_errors = true
547
+	) {
548
+		try {
549
+			foreach ($tests_to_run as $test) {
550
+				switch ($test) {
551
+					// TEST #1 : check that section was set
552
+					case 1 :
553
+						if (empty($section)) {
554
+							if ($display_errors) {
555
+								throw new EE_Error(
556
+									sprintf(
557
+										__(
558
+											'No configuration section has been provided while attempting to save "%s".',
559
+											'event_espresso'
560
+										),
561
+										$config_class
562
+									)
563
+								);
564
+							}
565
+							return false;
566
+						}
567
+						break;
568
+					// TEST #2 : check that settings section exists
569
+					case 2 :
570
+						if (! isset($this->{$section})) {
571
+							if ($display_errors) {
572
+								throw new EE_Error(
573
+									sprintf(
574
+										__('The "%s" configuration section does not exist.', 'event_espresso'),
575
+										$section
576
+									)
577
+								);
578
+							}
579
+							return false;
580
+						}
581
+						break;
582
+					// TEST #3 : check that section is the proper format
583
+					case 3 :
584
+						if (
585
+						! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
586
+						) {
587
+							if ($display_errors) {
588
+								throw new EE_Error(
589
+									sprintf(
590
+										__(
591
+											'The "%s" configuration settings have not been formatted correctly.',
592
+											'event_espresso'
593
+										),
594
+										$section
595
+									)
596
+								);
597
+							}
598
+							return false;
599
+						}
600
+						break;
601
+					// TEST #4 : check that config section name has been set
602
+					case 4 :
603
+						if (empty($name)) {
604
+							if ($display_errors) {
605
+								throw new EE_Error(
606
+									__(
607
+										'No name has been provided for the specific configuration section.',
608
+										'event_espresso'
609
+									)
610
+								);
611
+							}
612
+							return false;
613
+						}
614
+						break;
615
+					// TEST #5 : check that a config class name has been set
616
+					case 5 :
617
+						if (empty($config_class)) {
618
+							if ($display_errors) {
619
+								throw new EE_Error(
620
+									__(
621
+										'No class name has been provided for the specific configuration section.',
622
+										'event_espresso'
623
+									)
624
+								);
625
+							}
626
+							return false;
627
+						}
628
+						break;
629
+					// TEST #6 : verify config class is accessible
630
+					case 6 :
631
+						if (! class_exists($config_class)) {
632
+							if ($display_errors) {
633
+								throw new EE_Error(
634
+									sprintf(
635
+										__(
636
+											'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
637
+											'event_espresso'
638
+										),
639
+										$config_class
640
+									)
641
+								);
642
+							}
643
+							return false;
644
+						}
645
+						break;
646
+					// TEST #7 : check that config has even been set
647
+					case 7 :
648
+						if (! isset($this->{$section}->{$name})) {
649
+							if ($display_errors) {
650
+								throw new EE_Error(
651
+									sprintf(
652
+										__('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
653
+										$section,
654
+										$name
655
+									)
656
+								);
657
+							}
658
+							return false;
659
+						} else {
660
+							// and make sure it's not serialized
661
+							$this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
662
+						}
663
+						break;
664
+					// TEST #8 : check that config is the requested type
665
+					case 8 :
666
+						if (! $this->{$section}->{$name} instanceof $config_class) {
667
+							if ($display_errors) {
668
+								throw new EE_Error(
669
+									sprintf(
670
+										__(
671
+											'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
672
+											'event_espresso'
673
+										),
674
+										$section,
675
+										$name,
676
+										$config_class
677
+									)
678
+								);
679
+							}
680
+							return false;
681
+						}
682
+						break;
683
+					// TEST #9 : verify config object
684
+					case 9 :
685
+						if (! $config_obj instanceof EE_Config_Base) {
686
+							if ($display_errors) {
687
+								throw new EE_Error(
688
+									sprintf(
689
+										__('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
690
+										print_r($config_obj, true)
691
+									)
692
+								);
693
+							}
694
+							return false;
695
+						}
696
+						break;
697
+				}
698
+			}
699
+		} catch (EE_Error $e) {
700
+			$e->get_error();
701
+		}
702
+		// you have successfully run the gauntlet
703
+		return true;
704
+	}
705
+
706
+
707
+
708
+	/**
709
+	 *    _generate_config_option_name
710
+	 *
711
+	 * @access        protected
712
+	 * @param        string $section
713
+	 * @param        string $name
714
+	 * @return        string
715
+	 */
716
+	private function _generate_config_option_name($section = '', $name = '')
717
+	{
718
+		return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
719
+	}
720
+
721
+
722
+
723
+	/**
724
+	 *    _set_config_class
725
+	 * ensures that a config class is set, either from a passed config class or one generated from the config name
726
+	 *
727
+	 * @access    private
728
+	 * @param    string $config_class
729
+	 * @param    string $name
730
+	 * @return    string
731
+	 */
732
+	private function _set_config_class($config_class = '', $name = '')
733
+	{
734
+		return ! empty($config_class)
735
+			? $config_class
736
+			: str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
737
+	}
738
+
739
+
740
+
741
+	/**
742
+	 *    set_config
743
+	 *
744
+	 * @access    protected
745
+	 * @param    string         $section
746
+	 * @param    string         $name
747
+	 * @param    string         $config_class
748
+	 * @param    EE_Config_Base $config_obj
749
+	 * @return    EE_Config_Base
750
+	 */
751
+	public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null)
752
+	{
753
+		// ensure config class is set to something
754
+		$config_class = $this->_set_config_class($config_class, $name);
755
+		// run tests 1-4, 6, and 7 to verify all config params are set and valid
756
+		if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
757
+			return null;
758
+		}
759
+		$config_option_name = $this->_generate_config_option_name($section, $name);
760
+		// if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
761
+		if (! isset($this->_addon_option_names[$config_option_name])) {
762
+			$this->_addon_option_names[$config_option_name] = $config_class;
763
+			$this->update_addon_option_names();
764
+		}
765
+		// verify the incoming config object but suppress errors
766
+		if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
767
+			$config_obj = new $config_class();
768
+		}
769
+		if (get_option($config_option_name)) {
770
+			EE_Config::log($config_option_name);
771
+			update_option($config_option_name, $config_obj);
772
+			$this->{$section}->{$name} = $config_obj;
773
+			return $this->{$section}->{$name};
774
+		} else {
775
+			// create a wp-option for this config
776
+			if (add_option($config_option_name, $config_obj, '', 'no')) {
777
+				$this->{$section}->{$name} = maybe_unserialize($config_obj);
778
+				return $this->{$section}->{$name};
779
+			} else {
780
+				EE_Error::add_error(
781
+					sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
782
+					__FILE__,
783
+					__FUNCTION__,
784
+					__LINE__
785
+				);
786
+				return null;
787
+			}
788
+		}
789
+	}
790
+
791
+
792
+
793
+	/**
794
+	 *    update_config
795
+	 * Important: the config object must ALREADY be set, otherwise this will produce an error.
796
+	 *
797
+	 * @access    public
798
+	 * @param    string                $section
799
+	 * @param    string                $name
800
+	 * @param    EE_Config_Base|string $config_obj
801
+	 * @param    bool                  $throw_errors
802
+	 * @return    bool
803
+	 */
804
+	public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
805
+	{
806
+		// don't allow config updates during WP heartbeats
807
+		if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
808
+			return false;
809
+		}
810
+		$config_obj = maybe_unserialize($config_obj);
811
+		// get class name of the incoming object
812
+		$config_class = get_class($config_obj);
813
+		// run tests 1-5 and 9 to verify config
814
+		if (! $this->_verify_config_params(
815
+			$section,
816
+			$name,
817
+			$config_class,
818
+			$config_obj,
819
+			array(1, 2, 3, 4, 7, 9)
820
+		)
821
+		) {
822
+			return false;
823
+		}
824
+		$config_option_name = $this->_generate_config_option_name($section, $name);
825
+		// check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
826
+		if (! isset($this->_addon_option_names[$config_option_name])) {
827
+			// save new config to db
828
+			if ($this->set_config($section, $name, $config_class, $config_obj)) {
829
+				return true;
830
+			}
831
+		} else {
832
+			// first check if the record already exists
833
+			$existing_config = get_option($config_option_name);
834
+			$config_obj = serialize($config_obj);
835
+			// just return if db record is already up to date (NOT type safe comparison)
836
+			if ($existing_config == $config_obj) {
837
+				$this->{$section}->{$name} = $config_obj;
838
+				return true;
839
+			} else if (update_option($config_option_name, $config_obj)) {
840
+				EE_Config::log($config_option_name);
841
+				// update wp-option for this config class
842
+				$this->{$section}->{$name} = $config_obj;
843
+				return true;
844
+			} elseif ($throw_errors) {
845
+				EE_Error::add_error(
846
+					sprintf(
847
+						__(
848
+							'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
849
+							'event_espresso'
850
+						),
851
+						$config_class,
852
+						'EE_Config->' . $section . '->' . $name
853
+					),
854
+					__FILE__,
855
+					__FUNCTION__,
856
+					__LINE__
857
+				);
858
+			}
859
+		}
860
+		return false;
861
+	}
862
+
863
+
864
+
865
+	/**
866
+	 *    get_config
867
+	 *
868
+	 * @access    public
869
+	 * @param    string $section
870
+	 * @param    string $name
871
+	 * @param    string $config_class
872
+	 * @return    mixed EE_Config_Base | NULL
873
+	 */
874
+	public function get_config($section = '', $name = '', $config_class = '')
875
+	{
876
+		// ensure config class is set to something
877
+		$config_class = $this->_set_config_class($config_class, $name);
878
+		// run tests 1-4, 6 and 7 to verify that all params have been set
879
+		if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
880
+			return null;
881
+		}
882
+		// now test if the requested config object exists, but suppress errors
883
+		if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
884
+			// config already exists, so pass it back
885
+			return $this->{$section}->{$name};
886
+		}
887
+		// load config option from db if it exists
888
+		$config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
889
+		// verify the newly retrieved config object, but suppress errors
890
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
891
+			// config is good, so set it and pass it back
892
+			$this->{$section}->{$name} = $config_obj;
893
+			return $this->{$section}->{$name};
894
+		}
895
+		// oops! $config_obj is not already set and does not exist in the db, so create a new one
896
+		$config_obj = $this->set_config($section, $name, $config_class);
897
+		// verify the newly created config object
898
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
899
+			return $this->{$section}->{$name};
900
+		} else {
901
+			EE_Error::add_error(
902
+				sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
903
+				__FILE__,
904
+				__FUNCTION__,
905
+				__LINE__
906
+			);
907
+		}
908
+		return null;
909
+	}
910
+
911
+
912
+
913
+	/**
914
+	 *    get_config_option
915
+	 *
916
+	 * @access    public
917
+	 * @param    string $config_option_name
918
+	 * @return    mixed EE_Config_Base | FALSE
919
+	 */
920
+	public function get_config_option($config_option_name = '')
921
+	{
922
+		// retrieve the wp-option for this config class.
923
+		$config_option = maybe_unserialize(get_option($config_option_name, array()));
924
+		if (empty($config_option)) {
925
+			EE_Config::log($config_option_name . '-NOT-FOUND');
926
+		}
927
+		return $config_option;
928
+	}
929
+
930
+
931
+
932
+	/**
933
+	 * log
934
+	 *
935
+	 * @param string $config_option_name
936
+	 */
937
+	public static function log($config_option_name = '')
938
+	{
939
+		if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
940
+			$config_log = get_option(EE_Config::LOG_NAME, array());
941
+			//copy incoming $_REQUEST and sanitize it so we can save it
942
+			$_request = $_REQUEST;
943
+			array_walk_recursive($_request, 'sanitize_text_field');
944
+			$config_log[(string)microtime(true)] = array(
945
+				'config_name' => $config_option_name,
946
+				'request'     => $_request,
947
+			);
948
+			update_option(EE_Config::LOG_NAME, $config_log);
949
+		}
950
+	}
951
+
952
+
953
+
954
+	/**
955
+	 * trim_log
956
+	 * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
957
+	 */
958
+	public static function trim_log()
959
+	{
960
+		if (! EE_Config::logging_enabled()) {
961
+			return;
962
+		}
963
+		$config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
964
+		$log_length = count($config_log);
965
+		if ($log_length > EE_Config::LOG_LENGTH) {
966
+			ksort($config_log);
967
+			$config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
968
+			update_option(EE_Config::LOG_NAME, $config_log);
969
+		}
970
+	}
971
+
972
+
973
+
974
+	/**
975
+	 *    get_page_for_posts
976
+	 *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
977
+	 *    wp-option "page_for_posts", or "posts" if no page is selected
978
+	 *
979
+	 * @access    public
980
+	 * @return    string
981
+	 */
982
+	public static function get_page_for_posts()
983
+	{
984
+		$page_for_posts = get_option('page_for_posts');
985
+		if (! $page_for_posts) {
986
+			return 'posts';
987
+		}
988
+		/** @type WPDB $wpdb */
989
+		global $wpdb;
990
+		$SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
991
+		return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
992
+	}
993
+
994
+
995
+
996
+	/**
997
+	 *    register_shortcodes_and_modules.
998
+	 *    At this point, it's too early to tell if we're maintenance mode or not.
999
+	 *    In fact, this is where we give modules a chance to let core know they exist
1000
+	 *    so they can help trigger maintenance mode if it's needed
1001
+	 *
1002
+	 * @access    public
1003
+	 * @return    void
1004
+	 */
1005
+	public function register_shortcodes_and_modules()
1006
+	{
1007
+		// allow modules to set hooks for the rest of the system
1008
+		EE_Registry::instance()->modules = $this->_register_modules();
1009
+	}
1010
+
1011
+
1012
+
1013
+	/**
1014
+	 *    initialize_shortcodes_and_modules
1015
+	 *    meaning they can start adding their hooks to get stuff done
1016
+	 *
1017
+	 * @access    public
1018
+	 * @return    void
1019
+	 */
1020
+	public function initialize_shortcodes_and_modules()
1021
+	{
1022
+		// allow modules to set hooks for the rest of the system
1023
+		$this->_initialize_modules();
1024
+	}
1025
+
1026
+
1027
+
1028
+	/**
1029
+	 *    widgets_init
1030
+	 *
1031
+	 * @access private
1032
+	 * @return void
1033
+	 */
1034
+	public function widgets_init()
1035
+	{
1036
+		//only init widgets on admin pages when not in complete maintenance, and
1037
+		//on frontend when not in any maintenance mode
1038
+		if (
1039
+			! EE_Maintenance_Mode::instance()->level()
1040
+			|| (
1041
+				is_admin()
1042
+				&& EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1043
+			)
1044
+		) {
1045
+			// grab list of installed widgets
1046
+			$widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1047
+			// filter list of modules to register
1048
+			$widgets_to_register = apply_filters(
1049
+				'FHEE__EE_Config__register_widgets__widgets_to_register',
1050
+				$widgets_to_register
1051
+			);
1052
+			if (! empty($widgets_to_register)) {
1053
+				// cycle thru widget folders
1054
+				foreach ($widgets_to_register as $widget_path) {
1055
+					// add to list of installed widget modules
1056
+					EE_Config::register_ee_widget($widget_path);
1057
+				}
1058
+			}
1059
+			// filter list of installed modules
1060
+			EE_Registry::instance()->widgets = apply_filters(
1061
+				'FHEE__EE_Config__register_widgets__installed_widgets',
1062
+				EE_Registry::instance()->widgets
1063
+			);
1064
+		}
1065
+	}
1066
+
1067
+
1068
+
1069
+	/**
1070
+	 *    register_ee_widget - makes core aware of this widget
1071
+	 *
1072
+	 * @access    public
1073
+	 * @param    string $widget_path - full path up to and including widget folder
1074
+	 * @return    void
1075
+	 */
1076
+	public static function register_ee_widget($widget_path = null)
1077
+	{
1078
+		do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1079
+		$widget_ext = '.widget.php';
1080
+		// make all separators match
1081
+		$widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS);
1082
+		// does the file path INCLUDE the actual file name as part of the path ?
1083
+		if (strpos($widget_path, $widget_ext) !== false) {
1084
+			// grab and shortcode file name from directory name and break apart at dots
1085
+			$file_name = explode('.', basename($widget_path));
1086
+			// take first segment from file name pieces and remove class prefix if it exists
1087
+			$widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1088
+			// sanitize shortcode directory name
1089
+			$widget = sanitize_key($widget);
1090
+			// now we need to rebuild the shortcode path
1091
+			$widget_path = explode(DS, $widget_path);
1092
+			// remove last segment
1093
+			array_pop($widget_path);
1094
+			// glue it back together
1095
+			$widget_path = implode(DS, $widget_path);
1096
+		} else {
1097
+			// grab and sanitize widget directory name
1098
+			$widget = sanitize_key(basename($widget_path));
1099
+		}
1100
+		// create classname from widget directory name
1101
+		$widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1102
+		// add class prefix
1103
+		$widget_class = 'EEW_' . $widget;
1104
+		// does the widget exist ?
1105
+		if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) {
1106
+			$msg = sprintf(
1107
+				__(
1108
+					'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s',
1109
+					'event_espresso'
1110
+				),
1111
+				$widget_class,
1112
+				$widget_path . DS . $widget_class . $widget_ext
1113
+			);
1114
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1115
+			return;
1116
+		}
1117
+		// load the widget class file
1118
+		require_once($widget_path . DS . $widget_class . $widget_ext);
1119
+		// verify that class exists
1120
+		if (! class_exists($widget_class)) {
1121
+			$msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1122
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1123
+			return;
1124
+		}
1125
+		register_widget($widget_class);
1126
+		// add to array of registered widgets
1127
+		EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext;
1128
+	}
1129
+
1130
+
1131
+
1132
+	/**
1133
+	 *        _register_modules
1134
+	 *
1135
+	 * @access private
1136
+	 * @return array
1137
+	 */
1138
+	private function _register_modules()
1139
+	{
1140
+		// grab list of installed modules
1141
+		$modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1142
+		// filter list of modules to register
1143
+		$modules_to_register = apply_filters(
1144
+			'FHEE__EE_Config__register_modules__modules_to_register',
1145
+			$modules_to_register
1146
+		);
1147
+		if (! empty($modules_to_register)) {
1148
+			// loop through folders
1149
+			foreach ($modules_to_register as $module_path) {
1150
+				/**TEMPORARILY EXCLUDE gateways from modules for time being**/
1151
+				if (
1152
+					$module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1153
+					&& $module_path !== EE_MODULES . 'gateways'
1154
+				) {
1155
+					// add to list of installed modules
1156
+					EE_Config::register_module($module_path);
1157
+				}
1158
+			}
1159
+		}
1160
+		// filter list of installed modules
1161
+		return apply_filters(
1162
+			'FHEE__EE_Config___register_modules__installed_modules',
1163
+			EE_Registry::instance()->modules
1164
+		);
1165
+	}
1166
+
1167
+
1168
+
1169
+	/**
1170
+	 *    register_module - makes core aware of this module
1171
+	 *
1172
+	 * @access    public
1173
+	 * @param    string $module_path - full path up to and including module folder
1174
+	 * @return    bool
1175
+	 */
1176
+	public static function register_module($module_path = null)
1177
+	{
1178
+		do_action('AHEE__EE_Config__register_module__begin', $module_path);
1179
+		$module_ext = '.module.php';
1180
+		// make all separators match
1181
+		$module_path = str_replace(array('\\', '/'), DS, $module_path);
1182
+		// does the file path INCLUDE the actual file name as part of the path ?
1183
+		if (strpos($module_path, $module_ext) !== false) {
1184
+			// grab and shortcode file name from directory name and break apart at dots
1185
+			$module_file = explode('.', basename($module_path));
1186
+			// now we need to rebuild the shortcode path
1187
+			$module_path = explode(DS, $module_path);
1188
+			// remove last segment
1189
+			array_pop($module_path);
1190
+			// glue it back together
1191
+			$module_path = implode(DS, $module_path) . DS;
1192
+			// take first segment from file name pieces and sanitize it
1193
+			$module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1194
+			// ensure class prefix is added
1195
+			$module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1196
+		} else {
1197
+			// we need to generate the filename based off of the folder name
1198
+			// grab and sanitize module name
1199
+			$module = strtolower(basename($module_path));
1200
+			$module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1201
+			// like trailingslashit()
1202
+			$module_path = rtrim($module_path, DS) . DS;
1203
+			// create classname from module directory name
1204
+			$module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1205
+			// add class prefix
1206
+			$module_class = 'EED_' . $module;
1207
+		}
1208
+		// does the module exist ?
1209
+		if (! is_readable($module_path . DS . $module_class . $module_ext)) {
1210
+			$msg = sprintf(
1211
+				__(
1212
+					'The requested %s module file could not be found or is not readable due to file permissions.',
1213
+					'event_espresso'
1214
+				),
1215
+				$module
1216
+			);
1217
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1218
+			return false;
1219
+		}
1220
+		// load the module class file
1221
+		require_once($module_path . $module_class . $module_ext);
1222
+		// verify that class exists
1223
+		if (! class_exists($module_class)) {
1224
+			$msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1225
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1226
+			return false;
1227
+		}
1228
+		// add to array of registered modules
1229
+		EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1230
+		do_action(
1231
+			'AHEE__EE_Config__register_module__complete',
1232
+			$module_class,
1233
+			EE_Registry::instance()->modules->{$module_class}
1234
+		);
1235
+		return true;
1236
+	}
1237
+
1238
+
1239
+
1240
+	/**
1241
+	 *    _initialize_modules
1242
+	 *    allow modules to set hooks for the rest of the system
1243
+	 *
1244
+	 * @access private
1245
+	 * @return void
1246
+	 */
1247
+	private function _initialize_modules()
1248
+	{
1249
+		// cycle thru shortcode folders
1250
+		foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1251
+			// fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1252
+			// which set hooks ?
1253
+			if (is_admin()) {
1254
+				// fire immediately
1255
+				call_user_func(array($module_class, 'set_hooks_admin'));
1256
+			} else {
1257
+				// delay until other systems are online
1258
+				add_action(
1259
+					'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1260
+					array($module_class, 'set_hooks')
1261
+				);
1262
+			}
1263
+		}
1264
+	}
1265
+
1266
+
1267
+
1268
+	/**
1269
+	 *    register_route - adds module method routes to route_map
1270
+	 *
1271
+	 * @access    public
1272
+	 * @param    string $route       - "pretty" public alias for module method
1273
+	 * @param    string $module      - module name (classname without EED_ prefix)
1274
+	 * @param    string $method_name - the actual module method to be routed to
1275
+	 * @param    string $key         - url param key indicating a route is being called
1276
+	 * @return    bool
1277
+	 */
1278
+	public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1279
+	{
1280
+		do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1281
+		$module = str_replace('EED_', '', $module);
1282
+		$module_class = 'EED_' . $module;
1283
+		if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1284
+			$msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1285
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1286
+			return false;
1287
+		}
1288
+		if (empty($route)) {
1289
+			$msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1290
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1291
+			return false;
1292
+		}
1293
+		if (! method_exists('EED_' . $module, $method_name)) {
1294
+			$msg = sprintf(
1295
+				__('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1296
+				$route
1297
+			);
1298
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1299
+			return false;
1300
+		}
1301
+		EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name);
1302
+		return true;
1303
+	}
1304
+
1305
+
1306
+
1307
+	/**
1308
+	 *    get_route - get module method route
1309
+	 *
1310
+	 * @access    public
1311
+	 * @param    string $route - "pretty" public alias for module method
1312
+	 * @param    string $key   - url param key indicating a route is being called
1313
+	 * @return    string
1314
+	 */
1315
+	public static function get_route($route = null, $key = 'ee')
1316
+	{
1317
+		do_action('AHEE__EE_Config__get_route__begin', $route);
1318
+		$route = (string)apply_filters('FHEE__EE_Config__get_route', $route);
1319
+		if (isset(EE_Config::$_module_route_map[$key][$route])) {
1320
+			return EE_Config::$_module_route_map[$key][$route];
1321
+		}
1322
+		return null;
1323
+	}
1324
+
1325
+
1326
+
1327
+	/**
1328
+	 *    get_routes - get ALL module method routes
1329
+	 *
1330
+	 * @access    public
1331
+	 * @return    array
1332
+	 */
1333
+	public static function get_routes()
1334
+	{
1335
+		return EE_Config::$_module_route_map;
1336
+	}
1337
+
1338
+
1339
+
1340
+	/**
1341
+	 *    register_forward - allows modules to forward request to another module for further processing
1342
+	 *
1343
+	 * @access    public
1344
+	 * @param    string       $route   - "pretty" public alias for module method
1345
+	 * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1346
+	 *                                 class, allows different forwards to be served based on status
1347
+	 * @param    array|string $forward - function name or array( class, method )
1348
+	 * @param    string       $key     - url param key indicating a route is being called
1349
+	 * @return    bool
1350
+	 */
1351
+	public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1352
+	{
1353
+		do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1354
+		if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1355
+			$msg = sprintf(
1356
+				__('The module route %s for this forward has not been registered.', 'event_espresso'),
1357
+				$route
1358
+			);
1359
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1360
+			return false;
1361
+		}
1362
+		if (empty($forward)) {
1363
+			$msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1364
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1365
+			return false;
1366
+		}
1367
+		if (is_array($forward)) {
1368
+			if (! isset($forward[1])) {
1369
+				$msg = sprintf(
1370
+					__('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1371
+					$route
1372
+				);
1373
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1374
+				return false;
1375
+			}
1376
+			if (! method_exists($forward[0], $forward[1])) {
1377
+				$msg = sprintf(
1378
+					__('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1379
+					$forward[1],
1380
+					$route
1381
+				);
1382
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1383
+				return false;
1384
+			}
1385
+		} else if (! function_exists($forward)) {
1386
+			$msg = sprintf(
1387
+				__('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1388
+				$forward,
1389
+				$route
1390
+			);
1391
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1392
+			return false;
1393
+		}
1394
+		EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward;
1395
+		return true;
1396
+	}
1397
+
1398
+
1399
+
1400
+	/**
1401
+	 *    get_forward - get forwarding route
1402
+	 *
1403
+	 * @access    public
1404
+	 * @param    string  $route  - "pretty" public alias for module method
1405
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1406
+	 *                           allows different forwards to be served based on status
1407
+	 * @param    string  $key    - url param key indicating a route is being called
1408
+	 * @return    string
1409
+	 */
1410
+	public static function get_forward($route = null, $status = 0, $key = 'ee')
1411
+	{
1412
+		do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1413
+		if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) {
1414
+			return apply_filters(
1415
+				'FHEE__EE_Config__get_forward',
1416
+				EE_Config::$_module_forward_map[$key][$route][$status],
1417
+				$route,
1418
+				$status
1419
+			);
1420
+		}
1421
+		return null;
1422
+	}
1423
+
1424
+
1425
+
1426
+	/**
1427
+	 *    register_forward - allows modules to specify different view templates for different method routes and status
1428
+	 *    results
1429
+	 *
1430
+	 * @access    public
1431
+	 * @param    string  $route  - "pretty" public alias for module method
1432
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1433
+	 *                           allows different views to be served based on status
1434
+	 * @param    string  $view
1435
+	 * @param    string  $key    - url param key indicating a route is being called
1436
+	 * @return    bool
1437
+	 */
1438
+	public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1439
+	{
1440
+		do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1441
+		if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1442
+			$msg = sprintf(
1443
+				__('The module route %s for this view has not been registered.', 'event_espresso'),
1444
+				$route
1445
+			);
1446
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1447
+			return false;
1448
+		}
1449
+		if (! is_readable($view)) {
1450
+			$msg = sprintf(
1451
+				__(
1452
+					'The %s view file could not be found or is not readable due to file permissions.',
1453
+					'event_espresso'
1454
+				),
1455
+				$view
1456
+			);
1457
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1458
+			return false;
1459
+		}
1460
+		EE_Config::$_module_view_map[$key][$route][absint($status)] = $view;
1461
+		return true;
1462
+	}
1463
+
1464
+
1465
+
1466
+	/**
1467
+	 *    get_view - get view for route and status
1468
+	 *
1469
+	 * @access    public
1470
+	 * @param    string  $route  - "pretty" public alias for module method
1471
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1472
+	 *                           allows different views to be served based on status
1473
+	 * @param    string  $key    - url param key indicating a route is being called
1474
+	 * @return    string
1475
+	 */
1476
+	public static function get_view($route = null, $status = 0, $key = 'ee')
1477
+	{
1478
+		do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1479
+		if (isset(EE_Config::$_module_view_map[$key][$route][$status])) {
1480
+			return apply_filters(
1481
+				'FHEE__EE_Config__get_view',
1482
+				EE_Config::$_module_view_map[$key][$route][$status],
1483
+				$route,
1484
+				$status
1485
+			);
1486
+		}
1487
+		return null;
1488
+	}
1489
+
1490
+
1491
+
1492
+	public function update_addon_option_names()
1493
+	{
1494
+		update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1495
+	}
1496
+
1497
+
1498
+
1499
+	public function shutdown()
1500
+	{
1501
+		$this->update_addon_option_names();
1502
+	}
1503
+
1504
+
1505
+
1506
+	/**
1507
+	 * @return LegacyShortcodesManager
1508
+	 */
1509
+	public static function getLegacyShortcodesManager()
1510
+	{
1511
+
1512
+		if ( ! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1513
+			EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager(
1514
+				EE_Registry::instance()
1515
+			);
1516
+		}
1517
+		return EE_Config::instance()->legacy_shortcodes_manager;
1518
+	}
1519
+
1520
+
1521
+
1522
+	/**
1523
+	 * register_shortcode - makes core aware of this shortcode
1524
+	 *
1525
+	 * @deprecated 4.9.26
1526
+	 * @param    string $shortcode_path - full path up to and including shortcode folder
1527
+	 * @return    bool
1528
+	 */
1529
+	public static function register_shortcode($shortcode_path = null)
1530
+	{
1531
+		EE_Error::doing_it_wrong(
1532
+			__METHOD__,
1533
+			__(
1534
+				'Usage is deprecated. Use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::registerShortcode() as direct replacement, or better yet, please see the new \EventEspresso\core\services\shortcodes\ShortcodesManager class.',
1535
+				'event_espresso'
1536
+			),
1537
+			'4.9.26'
1538
+		);
1539
+		return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path);
1540
+	}
21 1541
 
22
-    const LOG_NAME           = 'ee_config_log';
23 1542
 
24
-    const LOG_LENGTH         = 100;
25 1543
 
26
-    const ADDON_OPTION_NAMES = 'ee_config_option_names';
27
-
28
-
29
-    /**
30
-     *    instance of the EE_Config object
31
-     *
32
-     * @var    EE_Config $_instance
33
-     * @access    private
34
-     */
35
-    private static $_instance;
36
-
37
-    /**
38
-     * @var boolean $_logging_enabled
39
-     */
40
-    private static $_logging_enabled = false;
41
-
42
-    /**
43
-     * @var LegacyShortcodesManager $legacy_shortcodes_manager
44
-     */
45
-    private $legacy_shortcodes_manager;
46
-
47
-    /**
48
-     * An StdClass whose property names are addon slugs,
49
-     * and values are their config classes
50
-     *
51
-     * @var StdClass
52
-     */
53
-    public $addons;
54
-
55
-    /**
56
-     * @var EE_Admin_Config
57
-     */
58
-    public $admin;
59
-
60
-    /**
61
-     * @var EE_Core_Config
62
-     */
63
-    public $core;
64
-
65
-    /**
66
-     * @var EE_Currency_Config
67
-     */
68
-    public $currency;
69
-
70
-    /**
71
-     * @var EE_Organization_Config
72
-     */
73
-    public $organization;
74
-
75
-    /**
76
-     * @var EE_Registration_Config
77
-     */
78
-    public $registration;
79
-
80
-    /**
81
-     * @var EE_Template_Config
82
-     */
83
-    public $template_settings;
84
-
85
-    /**
86
-     * Holds EE environment values.
87
-     *
88
-     * @var EE_Environment_Config
89
-     */
90
-    public $environment;
91
-
92
-    /**
93
-     * settings pertaining to Google maps
94
-     *
95
-     * @var EE_Map_Config
96
-     */
97
-    public $map_settings;
98
-
99
-    /**
100
-     * settings pertaining to Taxes
101
-     *
102
-     * @var EE_Tax_Config
103
-     */
104
-    public $tax_settings;
105
-
106
-
107
-    /**
108
-     * Settings pertaining to global messages settings.
109
-     *
110
-     * @var EE_Messages_Config
111
-     */
112
-    public $messages;
113
-
114
-    /**
115
-     * @deprecated
116
-     * @var EE_Gateway_Config
117
-     */
118
-    public $gateway;
119
-
120
-    /**
121
-     * @var    array $_addon_option_names
122
-     * @access    private
123
-     */
124
-    private $_addon_option_names = array();
125
-
126
-    /**
127
-     * @var    array $_module_route_map
128
-     * @access    private
129
-     */
130
-    private static $_module_route_map = array();
131
-
132
-    /**
133
-     * @var    array $_module_forward_map
134
-     * @access    private
135
-     */
136
-    private static $_module_forward_map = array();
137
-
138
-    /**
139
-     * @var    array $_module_view_map
140
-     * @access    private
141
-     */
142
-    private static $_module_view_map = array();
143
-
144
-
145
-
146
-    /**
147
-     * @singleton method used to instantiate class object
148
-     * @access    public
149
-     * @return EE_Config instance
150
-     */
151
-    public static function instance()
152
-    {
153
-        // check if class object is instantiated, and instantiated properly
154
-        if (! self::$_instance instanceof EE_Config) {
155
-            self::$_instance = new self();
156
-        }
157
-        return self::$_instance;
158
-    }
159
-
160
-
161
-
162
-    /**
163
-     * Resets the config
164
-     *
165
-     * @param bool    $hard_reset    if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE
166
-     *                               (default) leaves the database alone, and merely resets the EE_Config object to
167
-     *                               reflect its state in the database
168
-     * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave
169
-     *                               $_instance as NULL. Useful in case you want to forget about the old instance on
170
-     *                               EE_Config, but might not be ready to instantiate EE_Config currently (eg if the
171
-     *                               site was put into maintenance mode)
172
-     * @return EE_Config
173
-     */
174
-    public static function reset($hard_reset = false, $reinstantiate = true)
175
-    {
176
-        if (self::$_instance instanceof EE_Config) {
177
-            if ($hard_reset) {
178
-                self::$_instance->legacy_shortcodes_manager = null;
179
-                self::$_instance->_addon_option_names = array();
180
-                self::$_instance->_initialize_config();
181
-                self::$_instance->update_espresso_config();
182
-            }
183
-            self::$_instance->update_addon_option_names();
184
-        }
185
-        self::$_instance = null;
186
-        //we don't need to reset the static properties imo because those should
187
-        //only change when a module is added or removed. Currently we don't
188
-        //support removing a module during a request when it previously existed
189
-        if ($reinstantiate) {
190
-            return self::instance();
191
-        } else {
192
-            return null;
193
-        }
194
-    }
195
-
196
-
197
-
198
-    /**
199
-     *    class constructor
200
-     *
201
-     * @access    private
202
-     */
203
-    private function __construct()
204
-    {
205
-        do_action('AHEE__EE_Config__construct__begin', $this);
206
-        EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
207
-        // setup empty config classes
208
-        $this->_initialize_config();
209
-        // load existing EE site settings
210
-        $this->_load_core_config();
211
-        // confirm everything loaded correctly and set filtered defaults if not
212
-        $this->_verify_config();
213
-        //  register shortcodes and modules
214
-        add_action(
215
-            'AHEE__EE_System__register_shortcodes_modules_and_widgets',
216
-            array($this, 'register_shortcodes_and_modules'),
217
-            999
218
-        );
219
-        //  initialize shortcodes and modules
220
-        add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules'));
221
-        // register widgets
222
-        add_action('widgets_init', array($this, 'widgets_init'), 10);
223
-        // shutdown
224
-        add_action('shutdown', array($this, 'shutdown'), 10);
225
-        // construct__end hook
226
-        do_action('AHEE__EE_Config__construct__end', $this);
227
-        // hardcoded hack
228
-        $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
229
-    }
230
-
231
-
232
-
233
-    /**
234
-     * @return boolean
235
-     */
236
-    public static function logging_enabled()
237
-    {
238
-        return self::$_logging_enabled;
239
-    }
240
-
241
-
242
-
243
-    /**
244
-     * use to get the current theme if needed from static context
245
-     *
246
-     * @return string current theme set.
247
-     */
248
-    public static function get_current_theme()
249
-    {
250
-        return isset(self::$_instance->template_settings->current_espresso_theme)
251
-            ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
252
-    }
253
-
254
-
255
-
256
-    /**
257
-     *        _initialize_config
258
-     *
259
-     * @access private
260
-     * @return void
261
-     */
262
-    private function _initialize_config()
263
-    {
264
-        EE_Config::trim_log();
265
-        //set defaults
266
-        $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
267
-        $this->addons = new stdClass();
268
-        // set _module_route_map
269
-        EE_Config::$_module_route_map = array();
270
-        // set _module_forward_map
271
-        EE_Config::$_module_forward_map = array();
272
-        // set _module_view_map
273
-        EE_Config::$_module_view_map = array();
274
-    }
275
-
276
-
277
-
278
-    /**
279
-     *        load core plugin configuration
280
-     *
281
-     * @access private
282
-     * @return void
283
-     */
284
-    private function _load_core_config()
285
-    {
286
-        // load_core_config__start hook
287
-        do_action('AHEE__EE_Config___load_core_config__start', $this);
288
-        $espresso_config = $this->get_espresso_config();
289
-        foreach ($espresso_config as $config => $settings) {
290
-            // load_core_config__start hook
291
-            $settings = apply_filters(
292
-                'FHEE__EE_Config___load_core_config__config_settings',
293
-                $settings,
294
-                $config,
295
-                $this
296
-            );
297
-            if (is_object($settings) && property_exists($this, $config)) {
298
-                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
299
-                //call configs populate method to ensure any defaults are set for empty values.
300
-                if (method_exists($settings, 'populate')) {
301
-                    $this->{$config}->populate();
302
-                }
303
-                if (method_exists($settings, 'do_hooks')) {
304
-                    $this->{$config}->do_hooks();
305
-                }
306
-            }
307
-        }
308
-        if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
309
-            $this->update_espresso_config();
310
-        }
311
-        // load_core_config__end hook
312
-        do_action('AHEE__EE_Config___load_core_config__end', $this);
313
-    }
314
-
315
-
316
-
317
-    /**
318
-     *    _verify_config
319
-     *
320
-     * @access    protected
321
-     * @return    void
322
-     */
323
-    protected function _verify_config()
324
-    {
325
-        $this->core = $this->core instanceof EE_Core_Config
326
-            ? $this->core
327
-            : new EE_Core_Config();
328
-        $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
329
-        $this->organization = $this->organization instanceof EE_Organization_Config
330
-            ? $this->organization
331
-            : new EE_Organization_Config();
332
-        $this->organization = apply_filters(
333
-            'FHEE__EE_Config___initialize_config__organization',
334
-            $this->organization
335
-        );
336
-        $this->currency = $this->currency instanceof EE_Currency_Config
337
-            ? $this->currency
338
-            : new EE_Currency_Config();
339
-        $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
340
-        $this->registration = $this->registration instanceof EE_Registration_Config
341
-            ? $this->registration
342
-            : new EE_Registration_Config();
343
-        $this->registration = apply_filters(
344
-            'FHEE__EE_Config___initialize_config__registration',
345
-            $this->registration
346
-        );
347
-        $this->admin = $this->admin instanceof EE_Admin_Config
348
-            ? $this->admin
349
-            : new EE_Admin_Config();
350
-        $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
351
-        $this->template_settings = $this->template_settings instanceof EE_Template_Config
352
-            ? $this->template_settings
353
-            : new EE_Template_Config();
354
-        $this->template_settings = apply_filters(
355
-            'FHEE__EE_Config___initialize_config__template_settings',
356
-            $this->template_settings
357
-        );
358
-        $this->map_settings = $this->map_settings instanceof EE_Map_Config
359
-            ? $this->map_settings
360
-            : new EE_Map_Config();
361
-        $this->map_settings = apply_filters('FHEE__EE_Config___initialize_config__map_settings',
362
-            $this->map_settings);
363
-        $this->environment = $this->environment instanceof EE_Environment_Config
364
-            ? $this->environment
365
-            : new EE_Environment_Config();
366
-        $this->environment = apply_filters('FHEE__EE_Config___initialize_config__environment',
367
-            $this->environment);
368
-        $this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
369
-            ? $this->tax_settings
370
-            : new EE_Tax_Config();
371
-        $this->tax_settings = apply_filters('FHEE__EE_Config___initialize_config__tax_settings',
372
-            $this->tax_settings);
373
-        $this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages);
374
-        $this->messages = $this->messages instanceof EE_Messages_Config
375
-            ? $this->messages
376
-            : new EE_Messages_Config();
377
-        $this->gateway = $this->gateway instanceof EE_Gateway_Config
378
-            ? $this->gateway
379
-            : new EE_Gateway_Config();
380
-        $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
381
-        $this->legacy_shortcodes_manager = null;
382
-    }
383
-
384
-
385
-    /**
386
-     *    get_espresso_config
387
-     *
388
-     * @access    public
389
-     * @return    array of espresso config stuff
390
-     */
391
-    public function get_espresso_config()
392
-    {
393
-        // grab espresso configuration
394
-        return apply_filters(
395
-            'FHEE__EE_Config__get_espresso_config__CFG',
396
-            get_option(EE_Config::OPTION_NAME, array())
397
-        );
398
-    }
399
-
400
-
401
-
402
-    /**
403
-     *    double_check_config_comparison
404
-     *
405
-     * @access    public
406
-     * @param string $option
407
-     * @param        $old_value
408
-     * @param        $value
409
-     */
410
-    public function double_check_config_comparison($option = '', $old_value, $value)
411
-    {
412
-        // make sure we're checking the ee config
413
-        if ($option === EE_Config::OPTION_NAME) {
414
-            // run a loose comparison of the old value against the new value for type and properties,
415
-            // but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
416
-            if ($value != $old_value) {
417
-                // if they are NOT the same, then remove the hook,
418
-                // which means the subsequent update results will be based solely on the update query results
419
-                // the reason we do this is because, as stated above,
420
-                // WP update_option performs an exact instance comparison (===) on any update values passed to it
421
-                // this happens PRIOR to serialization and any subsequent update.
422
-                // If values are found to match their previous old value,
423
-                // then WP bails before performing any update.
424
-                // Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
425
-                // it just pulled from the db, with the one being passed to it (which will not match).
426
-                // HOWEVER, once the object is serialized and passed off to MySQL to update,
427
-                // MySQL MAY ALSO NOT perform the update because
428
-                // the string it sees in the db looks the same as the new one it has been passed!!!
429
-                // This results in the query returning an "affected rows" value of ZERO,
430
-                // which gets returned immediately by WP update_option and looks like an error.
431
-                remove_action('update_option', array($this, 'check_config_updated'));
432
-            }
433
-        }
434
-    }
435
-
436
-
437
-
438
-    /**
439
-     *    update_espresso_config
440
-     *
441
-     * @access   public
442
-     */
443
-    protected function _reset_espresso_addon_config()
444
-    {
445
-        $this->_addon_option_names = array();
446
-        foreach ($this->addons as $addon_name => $addon_config_obj) {
447
-            $addon_config_obj = maybe_unserialize($addon_config_obj);
448
-            if ($addon_config_obj instanceof EE_Config_Base) {
449
-                $this->update_config('addons', $addon_name, $addon_config_obj, false);
450
-            }
451
-            $this->addons->{$addon_name} = null;
452
-        }
453
-    }
454
-
455
-
456
-
457
-    /**
458
-     *    update_espresso_config
459
-     *
460
-     * @access   public
461
-     * @param   bool $add_success
462
-     * @param   bool $add_error
463
-     * @return   bool
464
-     */
465
-    public function update_espresso_config($add_success = false, $add_error = true)
466
-    {
467
-        // don't allow config updates during WP heartbeats
468
-        if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
469
-            return false;
470
-        }
471
-        // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
472
-        //$clone = clone( self::$_instance );
473
-        //self::$_instance = NULL;
474
-        do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
475
-        $this->_reset_espresso_addon_config();
476
-        // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
477
-        // but BEFORE the actual update occurs
478
-        add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
479
-        // don't want to persist legacy_shortcodes_manager, but don't want to lose it either
480
-        $legacy_shortcodes_manager = $this->legacy_shortcodes_manager;
481
-        $this->legacy_shortcodes_manager = null;
482
-        // now update "ee_config"
483
-        $saved = update_option(EE_Config::OPTION_NAME, $this);
484
-        $this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
485
-        EE_Config::log(EE_Config::OPTION_NAME);
486
-        // if not saved... check if the hook we just added still exists;
487
-        // if it does, it means one of two things:
488
-        // 		that update_option bailed at the ( $value === $old_value ) conditional,
489
-        //		 or...
490
-        // 		the db update query returned 0 rows affected
491
-        // 		(probably because the data  value was the same from it's perspective)
492
-        // so the existence of the hook means that a negative result from update_option is NOT an error,
493
-        // but just means no update occurred, so don't display an error to the user.
494
-        // BUT... if update_option returns FALSE, AND the hook is missing,
495
-        // then it means that something truly went wrong
496
-        $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
497
-        // remove our action since we don't want it in the system anymore
498
-        remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
499
-        do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
500
-        //self::$_instance = $clone;
501
-        //unset( $clone );
502
-        // if config remains the same or was updated successfully
503
-        if ($saved) {
504
-            if ($add_success) {
505
-                EE_Error::add_success(
506
-                    __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
507
-                    __FILE__,
508
-                    __FUNCTION__,
509
-                    __LINE__
510
-                );
511
-            }
512
-            return true;
513
-        } else {
514
-            if ($add_error) {
515
-                EE_Error::add_error(
516
-                    __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
517
-                    __FILE__,
518
-                    __FUNCTION__,
519
-                    __LINE__
520
-                );
521
-            }
522
-            return false;
523
-        }
524
-    }
525
-
526
-
527
-
528
-    /**
529
-     *    _verify_config_params
530
-     *
531
-     * @access    private
532
-     * @param    string         $section
533
-     * @param    string         $name
534
-     * @param    string         $config_class
535
-     * @param    EE_Config_Base $config_obj
536
-     * @param    array          $tests_to_run
537
-     * @param    bool           $display_errors
538
-     * @return    bool    TRUE on success, FALSE on fail
539
-     */
540
-    private function _verify_config_params(
541
-        $section = '',
542
-        $name = '',
543
-        $config_class = '',
544
-        $config_obj = null,
545
-        $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
546
-        $display_errors = true
547
-    ) {
548
-        try {
549
-            foreach ($tests_to_run as $test) {
550
-                switch ($test) {
551
-                    // TEST #1 : check that section was set
552
-                    case 1 :
553
-                        if (empty($section)) {
554
-                            if ($display_errors) {
555
-                                throw new EE_Error(
556
-                                    sprintf(
557
-                                        __(
558
-                                            'No configuration section has been provided while attempting to save "%s".',
559
-                                            'event_espresso'
560
-                                        ),
561
-                                        $config_class
562
-                                    )
563
-                                );
564
-                            }
565
-                            return false;
566
-                        }
567
-                        break;
568
-                    // TEST #2 : check that settings section exists
569
-                    case 2 :
570
-                        if (! isset($this->{$section})) {
571
-                            if ($display_errors) {
572
-                                throw new EE_Error(
573
-                                    sprintf(
574
-                                        __('The "%s" configuration section does not exist.', 'event_espresso'),
575
-                                        $section
576
-                                    )
577
-                                );
578
-                            }
579
-                            return false;
580
-                        }
581
-                        break;
582
-                    // TEST #3 : check that section is the proper format
583
-                    case 3 :
584
-                        if (
585
-                        ! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
586
-                        ) {
587
-                            if ($display_errors) {
588
-                                throw new EE_Error(
589
-                                    sprintf(
590
-                                        __(
591
-                                            'The "%s" configuration settings have not been formatted correctly.',
592
-                                            'event_espresso'
593
-                                        ),
594
-                                        $section
595
-                                    )
596
-                                );
597
-                            }
598
-                            return false;
599
-                        }
600
-                        break;
601
-                    // TEST #4 : check that config section name has been set
602
-                    case 4 :
603
-                        if (empty($name)) {
604
-                            if ($display_errors) {
605
-                                throw new EE_Error(
606
-                                    __(
607
-                                        'No name has been provided for the specific configuration section.',
608
-                                        'event_espresso'
609
-                                    )
610
-                                );
611
-                            }
612
-                            return false;
613
-                        }
614
-                        break;
615
-                    // TEST #5 : check that a config class name has been set
616
-                    case 5 :
617
-                        if (empty($config_class)) {
618
-                            if ($display_errors) {
619
-                                throw new EE_Error(
620
-                                    __(
621
-                                        'No class name has been provided for the specific configuration section.',
622
-                                        'event_espresso'
623
-                                    )
624
-                                );
625
-                            }
626
-                            return false;
627
-                        }
628
-                        break;
629
-                    // TEST #6 : verify config class is accessible
630
-                    case 6 :
631
-                        if (! class_exists($config_class)) {
632
-                            if ($display_errors) {
633
-                                throw new EE_Error(
634
-                                    sprintf(
635
-                                        __(
636
-                                            'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
637
-                                            'event_espresso'
638
-                                        ),
639
-                                        $config_class
640
-                                    )
641
-                                );
642
-                            }
643
-                            return false;
644
-                        }
645
-                        break;
646
-                    // TEST #7 : check that config has even been set
647
-                    case 7 :
648
-                        if (! isset($this->{$section}->{$name})) {
649
-                            if ($display_errors) {
650
-                                throw new EE_Error(
651
-                                    sprintf(
652
-                                        __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
653
-                                        $section,
654
-                                        $name
655
-                                    )
656
-                                );
657
-                            }
658
-                            return false;
659
-                        } else {
660
-                            // and make sure it's not serialized
661
-                            $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
662
-                        }
663
-                        break;
664
-                    // TEST #8 : check that config is the requested type
665
-                    case 8 :
666
-                        if (! $this->{$section}->{$name} instanceof $config_class) {
667
-                            if ($display_errors) {
668
-                                throw new EE_Error(
669
-                                    sprintf(
670
-                                        __(
671
-                                            'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
672
-                                            'event_espresso'
673
-                                        ),
674
-                                        $section,
675
-                                        $name,
676
-                                        $config_class
677
-                                    )
678
-                                );
679
-                            }
680
-                            return false;
681
-                        }
682
-                        break;
683
-                    // TEST #9 : verify config object
684
-                    case 9 :
685
-                        if (! $config_obj instanceof EE_Config_Base) {
686
-                            if ($display_errors) {
687
-                                throw new EE_Error(
688
-                                    sprintf(
689
-                                        __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
690
-                                        print_r($config_obj, true)
691
-                                    )
692
-                                );
693
-                            }
694
-                            return false;
695
-                        }
696
-                        break;
697
-                }
698
-            }
699
-        } catch (EE_Error $e) {
700
-            $e->get_error();
701
-        }
702
-        // you have successfully run the gauntlet
703
-        return true;
704
-    }
705
-
706
-
707
-
708
-    /**
709
-     *    _generate_config_option_name
710
-     *
711
-     * @access        protected
712
-     * @param        string $section
713
-     * @param        string $name
714
-     * @return        string
715
-     */
716
-    private function _generate_config_option_name($section = '', $name = '')
717
-    {
718
-        return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
719
-    }
720
-
721
-
722
-
723
-    /**
724
-     *    _set_config_class
725
-     * ensures that a config class is set, either from a passed config class or one generated from the config name
726
-     *
727
-     * @access    private
728
-     * @param    string $config_class
729
-     * @param    string $name
730
-     * @return    string
731
-     */
732
-    private function _set_config_class($config_class = '', $name = '')
733
-    {
734
-        return ! empty($config_class)
735
-            ? $config_class
736
-            : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
737
-    }
738
-
739
-
740
-
741
-    /**
742
-     *    set_config
743
-     *
744
-     * @access    protected
745
-     * @param    string         $section
746
-     * @param    string         $name
747
-     * @param    string         $config_class
748
-     * @param    EE_Config_Base $config_obj
749
-     * @return    EE_Config_Base
750
-     */
751
-    public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null)
752
-    {
753
-        // ensure config class is set to something
754
-        $config_class = $this->_set_config_class($config_class, $name);
755
-        // run tests 1-4, 6, and 7 to verify all config params are set and valid
756
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
757
-            return null;
758
-        }
759
-        $config_option_name = $this->_generate_config_option_name($section, $name);
760
-        // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
761
-        if (! isset($this->_addon_option_names[$config_option_name])) {
762
-            $this->_addon_option_names[$config_option_name] = $config_class;
763
-            $this->update_addon_option_names();
764
-        }
765
-        // verify the incoming config object but suppress errors
766
-        if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
767
-            $config_obj = new $config_class();
768
-        }
769
-        if (get_option($config_option_name)) {
770
-            EE_Config::log($config_option_name);
771
-            update_option($config_option_name, $config_obj);
772
-            $this->{$section}->{$name} = $config_obj;
773
-            return $this->{$section}->{$name};
774
-        } else {
775
-            // create a wp-option for this config
776
-            if (add_option($config_option_name, $config_obj, '', 'no')) {
777
-                $this->{$section}->{$name} = maybe_unserialize($config_obj);
778
-                return $this->{$section}->{$name};
779
-            } else {
780
-                EE_Error::add_error(
781
-                    sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
782
-                    __FILE__,
783
-                    __FUNCTION__,
784
-                    __LINE__
785
-                );
786
-                return null;
787
-            }
788
-        }
789
-    }
790
-
791
-
792
-
793
-    /**
794
-     *    update_config
795
-     * Important: the config object must ALREADY be set, otherwise this will produce an error.
796
-     *
797
-     * @access    public
798
-     * @param    string                $section
799
-     * @param    string                $name
800
-     * @param    EE_Config_Base|string $config_obj
801
-     * @param    bool                  $throw_errors
802
-     * @return    bool
803
-     */
804
-    public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
805
-    {
806
-        // don't allow config updates during WP heartbeats
807
-        if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
808
-            return false;
809
-        }
810
-        $config_obj = maybe_unserialize($config_obj);
811
-        // get class name of the incoming object
812
-        $config_class = get_class($config_obj);
813
-        // run tests 1-5 and 9 to verify config
814
-        if (! $this->_verify_config_params(
815
-            $section,
816
-            $name,
817
-            $config_class,
818
-            $config_obj,
819
-            array(1, 2, 3, 4, 7, 9)
820
-        )
821
-        ) {
822
-            return false;
823
-        }
824
-        $config_option_name = $this->_generate_config_option_name($section, $name);
825
-        // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
826
-        if (! isset($this->_addon_option_names[$config_option_name])) {
827
-            // save new config to db
828
-            if ($this->set_config($section, $name, $config_class, $config_obj)) {
829
-                return true;
830
-            }
831
-        } else {
832
-            // first check if the record already exists
833
-            $existing_config = get_option($config_option_name);
834
-            $config_obj = serialize($config_obj);
835
-            // just return if db record is already up to date (NOT type safe comparison)
836
-            if ($existing_config == $config_obj) {
837
-                $this->{$section}->{$name} = $config_obj;
838
-                return true;
839
-            } else if (update_option($config_option_name, $config_obj)) {
840
-                EE_Config::log($config_option_name);
841
-                // update wp-option for this config class
842
-                $this->{$section}->{$name} = $config_obj;
843
-                return true;
844
-            } elseif ($throw_errors) {
845
-                EE_Error::add_error(
846
-                    sprintf(
847
-                        __(
848
-                            'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
849
-                            'event_espresso'
850
-                        ),
851
-                        $config_class,
852
-                        'EE_Config->' . $section . '->' . $name
853
-                    ),
854
-                    __FILE__,
855
-                    __FUNCTION__,
856
-                    __LINE__
857
-                );
858
-            }
859
-        }
860
-        return false;
861
-    }
862
-
863
-
864
-
865
-    /**
866
-     *    get_config
867
-     *
868
-     * @access    public
869
-     * @param    string $section
870
-     * @param    string $name
871
-     * @param    string $config_class
872
-     * @return    mixed EE_Config_Base | NULL
873
-     */
874
-    public function get_config($section = '', $name = '', $config_class = '')
875
-    {
876
-        // ensure config class is set to something
877
-        $config_class = $this->_set_config_class($config_class, $name);
878
-        // run tests 1-4, 6 and 7 to verify that all params have been set
879
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
880
-            return null;
881
-        }
882
-        // now test if the requested config object exists, but suppress errors
883
-        if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
884
-            // config already exists, so pass it back
885
-            return $this->{$section}->{$name};
886
-        }
887
-        // load config option from db if it exists
888
-        $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
889
-        // verify the newly retrieved config object, but suppress errors
890
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
891
-            // config is good, so set it and pass it back
892
-            $this->{$section}->{$name} = $config_obj;
893
-            return $this->{$section}->{$name};
894
-        }
895
-        // oops! $config_obj is not already set and does not exist in the db, so create a new one
896
-        $config_obj = $this->set_config($section, $name, $config_class);
897
-        // verify the newly created config object
898
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
899
-            return $this->{$section}->{$name};
900
-        } else {
901
-            EE_Error::add_error(
902
-                sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
903
-                __FILE__,
904
-                __FUNCTION__,
905
-                __LINE__
906
-            );
907
-        }
908
-        return null;
909
-    }
910
-
911
-
912
-
913
-    /**
914
-     *    get_config_option
915
-     *
916
-     * @access    public
917
-     * @param    string $config_option_name
918
-     * @return    mixed EE_Config_Base | FALSE
919
-     */
920
-    public function get_config_option($config_option_name = '')
921
-    {
922
-        // retrieve the wp-option for this config class.
923
-        $config_option = maybe_unserialize(get_option($config_option_name, array()));
924
-        if (empty($config_option)) {
925
-            EE_Config::log($config_option_name . '-NOT-FOUND');
926
-        }
927
-        return $config_option;
928
-    }
929
-
930
-
931
-
932
-    /**
933
-     * log
934
-     *
935
-     * @param string $config_option_name
936
-     */
937
-    public static function log($config_option_name = '')
938
-    {
939
-        if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
940
-            $config_log = get_option(EE_Config::LOG_NAME, array());
941
-            //copy incoming $_REQUEST and sanitize it so we can save it
942
-            $_request = $_REQUEST;
943
-            array_walk_recursive($_request, 'sanitize_text_field');
944
-            $config_log[(string)microtime(true)] = array(
945
-                'config_name' => $config_option_name,
946
-                'request'     => $_request,
947
-            );
948
-            update_option(EE_Config::LOG_NAME, $config_log);
949
-        }
950
-    }
951
-
952
-
953
-
954
-    /**
955
-     * trim_log
956
-     * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
957
-     */
958
-    public static function trim_log()
959
-    {
960
-        if (! EE_Config::logging_enabled()) {
961
-            return;
962
-        }
963
-        $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
964
-        $log_length = count($config_log);
965
-        if ($log_length > EE_Config::LOG_LENGTH) {
966
-            ksort($config_log);
967
-            $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
968
-            update_option(EE_Config::LOG_NAME, $config_log);
969
-        }
970
-    }
971
-
972
-
973
-
974
-    /**
975
-     *    get_page_for_posts
976
-     *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
977
-     *    wp-option "page_for_posts", or "posts" if no page is selected
978
-     *
979
-     * @access    public
980
-     * @return    string
981
-     */
982
-    public static function get_page_for_posts()
983
-    {
984
-        $page_for_posts = get_option('page_for_posts');
985
-        if (! $page_for_posts) {
986
-            return 'posts';
987
-        }
988
-        /** @type WPDB $wpdb */
989
-        global $wpdb;
990
-        $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
991
-        return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
992
-    }
993
-
994
-
995
-
996
-    /**
997
-     *    register_shortcodes_and_modules.
998
-     *    At this point, it's too early to tell if we're maintenance mode or not.
999
-     *    In fact, this is where we give modules a chance to let core know they exist
1000
-     *    so they can help trigger maintenance mode if it's needed
1001
-     *
1002
-     * @access    public
1003
-     * @return    void
1004
-     */
1005
-    public function register_shortcodes_and_modules()
1006
-    {
1007
-        // allow modules to set hooks for the rest of the system
1008
-        EE_Registry::instance()->modules = $this->_register_modules();
1009
-    }
1010
-
1011
-
1012
-
1013
-    /**
1014
-     *    initialize_shortcodes_and_modules
1015
-     *    meaning they can start adding their hooks to get stuff done
1016
-     *
1017
-     * @access    public
1018
-     * @return    void
1019
-     */
1020
-    public function initialize_shortcodes_and_modules()
1021
-    {
1022
-        // allow modules to set hooks for the rest of the system
1023
-        $this->_initialize_modules();
1024
-    }
1025
-
1026
-
1027
-
1028
-    /**
1029
-     *    widgets_init
1030
-     *
1031
-     * @access private
1032
-     * @return void
1033
-     */
1034
-    public function widgets_init()
1035
-    {
1036
-        //only init widgets on admin pages when not in complete maintenance, and
1037
-        //on frontend when not in any maintenance mode
1038
-        if (
1039
-            ! EE_Maintenance_Mode::instance()->level()
1040
-            || (
1041
-                is_admin()
1042
-                && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1043
-            )
1044
-        ) {
1045
-            // grab list of installed widgets
1046
-            $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1047
-            // filter list of modules to register
1048
-            $widgets_to_register = apply_filters(
1049
-                'FHEE__EE_Config__register_widgets__widgets_to_register',
1050
-                $widgets_to_register
1051
-            );
1052
-            if (! empty($widgets_to_register)) {
1053
-                // cycle thru widget folders
1054
-                foreach ($widgets_to_register as $widget_path) {
1055
-                    // add to list of installed widget modules
1056
-                    EE_Config::register_ee_widget($widget_path);
1057
-                }
1058
-            }
1059
-            // filter list of installed modules
1060
-            EE_Registry::instance()->widgets = apply_filters(
1061
-                'FHEE__EE_Config__register_widgets__installed_widgets',
1062
-                EE_Registry::instance()->widgets
1063
-            );
1064
-        }
1065
-    }
1066
-
1067
-
1068
-
1069
-    /**
1070
-     *    register_ee_widget - makes core aware of this widget
1071
-     *
1072
-     * @access    public
1073
-     * @param    string $widget_path - full path up to and including widget folder
1074
-     * @return    void
1075
-     */
1076
-    public static function register_ee_widget($widget_path = null)
1077
-    {
1078
-        do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1079
-        $widget_ext = '.widget.php';
1080
-        // make all separators match
1081
-        $widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS);
1082
-        // does the file path INCLUDE the actual file name as part of the path ?
1083
-        if (strpos($widget_path, $widget_ext) !== false) {
1084
-            // grab and shortcode file name from directory name and break apart at dots
1085
-            $file_name = explode('.', basename($widget_path));
1086
-            // take first segment from file name pieces and remove class prefix if it exists
1087
-            $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1088
-            // sanitize shortcode directory name
1089
-            $widget = sanitize_key($widget);
1090
-            // now we need to rebuild the shortcode path
1091
-            $widget_path = explode(DS, $widget_path);
1092
-            // remove last segment
1093
-            array_pop($widget_path);
1094
-            // glue it back together
1095
-            $widget_path = implode(DS, $widget_path);
1096
-        } else {
1097
-            // grab and sanitize widget directory name
1098
-            $widget = sanitize_key(basename($widget_path));
1099
-        }
1100
-        // create classname from widget directory name
1101
-        $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1102
-        // add class prefix
1103
-        $widget_class = 'EEW_' . $widget;
1104
-        // does the widget exist ?
1105
-        if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) {
1106
-            $msg = sprintf(
1107
-                __(
1108
-                    'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s',
1109
-                    'event_espresso'
1110
-                ),
1111
-                $widget_class,
1112
-                $widget_path . DS . $widget_class . $widget_ext
1113
-            );
1114
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1115
-            return;
1116
-        }
1117
-        // load the widget class file
1118
-        require_once($widget_path . DS . $widget_class . $widget_ext);
1119
-        // verify that class exists
1120
-        if (! class_exists($widget_class)) {
1121
-            $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1122
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1123
-            return;
1124
-        }
1125
-        register_widget($widget_class);
1126
-        // add to array of registered widgets
1127
-        EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext;
1128
-    }
1129
-
1130
-
1131
-
1132
-    /**
1133
-     *        _register_modules
1134
-     *
1135
-     * @access private
1136
-     * @return array
1137
-     */
1138
-    private function _register_modules()
1139
-    {
1140
-        // grab list of installed modules
1141
-        $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1142
-        // filter list of modules to register
1143
-        $modules_to_register = apply_filters(
1144
-            'FHEE__EE_Config__register_modules__modules_to_register',
1145
-            $modules_to_register
1146
-        );
1147
-        if (! empty($modules_to_register)) {
1148
-            // loop through folders
1149
-            foreach ($modules_to_register as $module_path) {
1150
-                /**TEMPORARILY EXCLUDE gateways from modules for time being**/
1151
-                if (
1152
-                    $module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1153
-                    && $module_path !== EE_MODULES . 'gateways'
1154
-                ) {
1155
-                    // add to list of installed modules
1156
-                    EE_Config::register_module($module_path);
1157
-                }
1158
-            }
1159
-        }
1160
-        // filter list of installed modules
1161
-        return apply_filters(
1162
-            'FHEE__EE_Config___register_modules__installed_modules',
1163
-            EE_Registry::instance()->modules
1164
-        );
1165
-    }
1166
-
1167
-
1168
-
1169
-    /**
1170
-     *    register_module - makes core aware of this module
1171
-     *
1172
-     * @access    public
1173
-     * @param    string $module_path - full path up to and including module folder
1174
-     * @return    bool
1175
-     */
1176
-    public static function register_module($module_path = null)
1177
-    {
1178
-        do_action('AHEE__EE_Config__register_module__begin', $module_path);
1179
-        $module_ext = '.module.php';
1180
-        // make all separators match
1181
-        $module_path = str_replace(array('\\', '/'), DS, $module_path);
1182
-        // does the file path INCLUDE the actual file name as part of the path ?
1183
-        if (strpos($module_path, $module_ext) !== false) {
1184
-            // grab and shortcode file name from directory name and break apart at dots
1185
-            $module_file = explode('.', basename($module_path));
1186
-            // now we need to rebuild the shortcode path
1187
-            $module_path = explode(DS, $module_path);
1188
-            // remove last segment
1189
-            array_pop($module_path);
1190
-            // glue it back together
1191
-            $module_path = implode(DS, $module_path) . DS;
1192
-            // take first segment from file name pieces and sanitize it
1193
-            $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1194
-            // ensure class prefix is added
1195
-            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1196
-        } else {
1197
-            // we need to generate the filename based off of the folder name
1198
-            // grab and sanitize module name
1199
-            $module = strtolower(basename($module_path));
1200
-            $module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1201
-            // like trailingslashit()
1202
-            $module_path = rtrim($module_path, DS) . DS;
1203
-            // create classname from module directory name
1204
-            $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1205
-            // add class prefix
1206
-            $module_class = 'EED_' . $module;
1207
-        }
1208
-        // does the module exist ?
1209
-        if (! is_readable($module_path . DS . $module_class . $module_ext)) {
1210
-            $msg = sprintf(
1211
-                __(
1212
-                    'The requested %s module file could not be found or is not readable due to file permissions.',
1213
-                    'event_espresso'
1214
-                ),
1215
-                $module
1216
-            );
1217
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1218
-            return false;
1219
-        }
1220
-        // load the module class file
1221
-        require_once($module_path . $module_class . $module_ext);
1222
-        // verify that class exists
1223
-        if (! class_exists($module_class)) {
1224
-            $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1225
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1226
-            return false;
1227
-        }
1228
-        // add to array of registered modules
1229
-        EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1230
-        do_action(
1231
-            'AHEE__EE_Config__register_module__complete',
1232
-            $module_class,
1233
-            EE_Registry::instance()->modules->{$module_class}
1234
-        );
1235
-        return true;
1236
-    }
1237
-
1238
-
1239
-
1240
-    /**
1241
-     *    _initialize_modules
1242
-     *    allow modules to set hooks for the rest of the system
1243
-     *
1244
-     * @access private
1245
-     * @return void
1246
-     */
1247
-    private function _initialize_modules()
1248
-    {
1249
-        // cycle thru shortcode folders
1250
-        foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1251
-            // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1252
-            // which set hooks ?
1253
-            if (is_admin()) {
1254
-                // fire immediately
1255
-                call_user_func(array($module_class, 'set_hooks_admin'));
1256
-            } else {
1257
-                // delay until other systems are online
1258
-                add_action(
1259
-                    'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1260
-                    array($module_class, 'set_hooks')
1261
-                );
1262
-            }
1263
-        }
1264
-    }
1265
-
1266
-
1267
-
1268
-    /**
1269
-     *    register_route - adds module method routes to route_map
1270
-     *
1271
-     * @access    public
1272
-     * @param    string $route       - "pretty" public alias for module method
1273
-     * @param    string $module      - module name (classname without EED_ prefix)
1274
-     * @param    string $method_name - the actual module method to be routed to
1275
-     * @param    string $key         - url param key indicating a route is being called
1276
-     * @return    bool
1277
-     */
1278
-    public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1279
-    {
1280
-        do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1281
-        $module = str_replace('EED_', '', $module);
1282
-        $module_class = 'EED_' . $module;
1283
-        if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1284
-            $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1285
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1286
-            return false;
1287
-        }
1288
-        if (empty($route)) {
1289
-            $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1290
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1291
-            return false;
1292
-        }
1293
-        if (! method_exists('EED_' . $module, $method_name)) {
1294
-            $msg = sprintf(
1295
-                __('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1296
-                $route
1297
-            );
1298
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1299
-            return false;
1300
-        }
1301
-        EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name);
1302
-        return true;
1303
-    }
1304
-
1305
-
1306
-
1307
-    /**
1308
-     *    get_route - get module method route
1309
-     *
1310
-     * @access    public
1311
-     * @param    string $route - "pretty" public alias for module method
1312
-     * @param    string $key   - url param key indicating a route is being called
1313
-     * @return    string
1314
-     */
1315
-    public static function get_route($route = null, $key = 'ee')
1316
-    {
1317
-        do_action('AHEE__EE_Config__get_route__begin', $route);
1318
-        $route = (string)apply_filters('FHEE__EE_Config__get_route', $route);
1319
-        if (isset(EE_Config::$_module_route_map[$key][$route])) {
1320
-            return EE_Config::$_module_route_map[$key][$route];
1321
-        }
1322
-        return null;
1323
-    }
1324
-
1325
-
1326
-
1327
-    /**
1328
-     *    get_routes - get ALL module method routes
1329
-     *
1330
-     * @access    public
1331
-     * @return    array
1332
-     */
1333
-    public static function get_routes()
1334
-    {
1335
-        return EE_Config::$_module_route_map;
1336
-    }
1337
-
1338
-
1339
-
1340
-    /**
1341
-     *    register_forward - allows modules to forward request to another module for further processing
1342
-     *
1343
-     * @access    public
1344
-     * @param    string       $route   - "pretty" public alias for module method
1345
-     * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1346
-     *                                 class, allows different forwards to be served based on status
1347
-     * @param    array|string $forward - function name or array( class, method )
1348
-     * @param    string       $key     - url param key indicating a route is being called
1349
-     * @return    bool
1350
-     */
1351
-    public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1352
-    {
1353
-        do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1354
-        if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1355
-            $msg = sprintf(
1356
-                __('The module route %s for this forward has not been registered.', 'event_espresso'),
1357
-                $route
1358
-            );
1359
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1360
-            return false;
1361
-        }
1362
-        if (empty($forward)) {
1363
-            $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1364
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1365
-            return false;
1366
-        }
1367
-        if (is_array($forward)) {
1368
-            if (! isset($forward[1])) {
1369
-                $msg = sprintf(
1370
-                    __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1371
-                    $route
1372
-                );
1373
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1374
-                return false;
1375
-            }
1376
-            if (! method_exists($forward[0], $forward[1])) {
1377
-                $msg = sprintf(
1378
-                    __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1379
-                    $forward[1],
1380
-                    $route
1381
-                );
1382
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1383
-                return false;
1384
-            }
1385
-        } else if (! function_exists($forward)) {
1386
-            $msg = sprintf(
1387
-                __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1388
-                $forward,
1389
-                $route
1390
-            );
1391
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1392
-            return false;
1393
-        }
1394
-        EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward;
1395
-        return true;
1396
-    }
1397
-
1398
-
1399
-
1400
-    /**
1401
-     *    get_forward - get forwarding route
1402
-     *
1403
-     * @access    public
1404
-     * @param    string  $route  - "pretty" public alias for module method
1405
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1406
-     *                           allows different forwards to be served based on status
1407
-     * @param    string  $key    - url param key indicating a route is being called
1408
-     * @return    string
1409
-     */
1410
-    public static function get_forward($route = null, $status = 0, $key = 'ee')
1411
-    {
1412
-        do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1413
-        if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) {
1414
-            return apply_filters(
1415
-                'FHEE__EE_Config__get_forward',
1416
-                EE_Config::$_module_forward_map[$key][$route][$status],
1417
-                $route,
1418
-                $status
1419
-            );
1420
-        }
1421
-        return null;
1422
-    }
1423
-
1424
-
1425
-
1426
-    /**
1427
-     *    register_forward - allows modules to specify different view templates for different method routes and status
1428
-     *    results
1429
-     *
1430
-     * @access    public
1431
-     * @param    string  $route  - "pretty" public alias for module method
1432
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1433
-     *                           allows different views to be served based on status
1434
-     * @param    string  $view
1435
-     * @param    string  $key    - url param key indicating a route is being called
1436
-     * @return    bool
1437
-     */
1438
-    public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1439
-    {
1440
-        do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1441
-        if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1442
-            $msg = sprintf(
1443
-                __('The module route %s for this view has not been registered.', 'event_espresso'),
1444
-                $route
1445
-            );
1446
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1447
-            return false;
1448
-        }
1449
-        if (! is_readable($view)) {
1450
-            $msg = sprintf(
1451
-                __(
1452
-                    'The %s view file could not be found or is not readable due to file permissions.',
1453
-                    'event_espresso'
1454
-                ),
1455
-                $view
1456
-            );
1457
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1458
-            return false;
1459
-        }
1460
-        EE_Config::$_module_view_map[$key][$route][absint($status)] = $view;
1461
-        return true;
1462
-    }
1463
-
1464
-
1465
-
1466
-    /**
1467
-     *    get_view - get view for route and status
1468
-     *
1469
-     * @access    public
1470
-     * @param    string  $route  - "pretty" public alias for module method
1471
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1472
-     *                           allows different views to be served based on status
1473
-     * @param    string  $key    - url param key indicating a route is being called
1474
-     * @return    string
1475
-     */
1476
-    public static function get_view($route = null, $status = 0, $key = 'ee')
1477
-    {
1478
-        do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1479
-        if (isset(EE_Config::$_module_view_map[$key][$route][$status])) {
1480
-            return apply_filters(
1481
-                'FHEE__EE_Config__get_view',
1482
-                EE_Config::$_module_view_map[$key][$route][$status],
1483
-                $route,
1484
-                $status
1485
-            );
1486
-        }
1487
-        return null;
1488
-    }
1489
-
1490
-
1491
-
1492
-    public function update_addon_option_names()
1493
-    {
1494
-        update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1495
-    }
1496
-
1497
-
1498
-
1499
-    public function shutdown()
1500
-    {
1501
-        $this->update_addon_option_names();
1502
-    }
1503
-
1504
-
1505
-
1506
-    /**
1507
-     * @return LegacyShortcodesManager
1508
-     */
1509
-    public static function getLegacyShortcodesManager()
1510
-    {
1511
-
1512
-        if ( ! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1513
-            EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager(
1514
-                EE_Registry::instance()
1515
-            );
1516
-        }
1517
-        return EE_Config::instance()->legacy_shortcodes_manager;
1518
-    }
1519
-
1520
-
1521
-
1522
-    /**
1523
-     * register_shortcode - makes core aware of this shortcode
1524
-     *
1525
-     * @deprecated 4.9.26
1526
-     * @param    string $shortcode_path - full path up to and including shortcode folder
1527
-     * @return    bool
1528
-     */
1529
-    public static function register_shortcode($shortcode_path = null)
1530
-    {
1531
-        EE_Error::doing_it_wrong(
1532
-            __METHOD__,
1533
-            __(
1534
-                'Usage is deprecated. Use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::registerShortcode() as direct replacement, or better yet, please see the new \EventEspresso\core\services\shortcodes\ShortcodesManager class.',
1535
-                'event_espresso'
1536
-            ),
1537
-            '4.9.26'
1538
-        );
1539
-        return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path);
1540
-    }
1541
-
1542
-
1543
-
1544
-}
1545
-
1546
-
1547
-
1548
-/**
1549
- * Base class used for config classes. These classes should generally not have
1550
- * magic functions in use, except we'll allow them to magically set and get stuff...
1551
- * basically, they should just be well-defined stdClasses
1552
- */
1553
-class EE_Config_Base
1554
-{
1555
-
1556
-    /**
1557
-     * Utility function for escaping the value of a property and returning.
1558
-     *
1559
-     * @param string $property property name (checks to see if exists).
1560
-     * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1561
-     * @throws \EE_Error
1562
-     */
1563
-    public function get_pretty($property)
1564
-    {
1565
-        if (! property_exists($this, $property)) {
1566
-            throw new EE_Error(
1567
-                sprintf(
1568
-                    __(
1569
-                        '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1570
-                        'event_espresso'
1571
-                    ),
1572
-                    get_class($this),
1573
-                    $property
1574
-                )
1575
-            );
1576
-        }
1577
-        //just handling escaping of strings for now.
1578
-        if (is_string($this->{$property})) {
1579
-            return stripslashes($this->{$property});
1580
-        }
1581
-        return $this->{$property};
1582
-    }
1583
-
1584
-
1585
-
1586
-    public function populate()
1587
-    {
1588
-        //grab defaults via a new instance of this class.
1589
-        $class_name = get_class($this);
1590
-        $defaults = new $class_name;
1591
-        //loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1592
-        //default from our $defaults object.
1593
-        foreach (get_object_vars($defaults) as $property => $value) {
1594
-            if ($this->{$property} === null) {
1595
-                $this->{$property} = $value;
1596
-            }
1597
-        }
1598
-        //cleanup
1599
-        unset($defaults);
1600
-    }
1601
-
1602
-
1603
-
1604
-    /**
1605
-     *        __isset
1606
-     *
1607
-     * @param $a
1608
-     * @return bool
1609
-     */
1610
-    public function __isset($a)
1611
-    {
1612
-        return false;
1613
-    }
1614
-
1615
-
1616
-
1617
-    /**
1618
-     *        __unset
1619
-     *
1620
-     * @param $a
1621
-     * @return bool
1622
-     */
1623
-    public function __unset($a)
1624
-    {
1625
-        return false;
1626
-    }
1627
-
1628
-
1629
-
1630
-    /**
1631
-     *        __clone
1632
-     */
1633
-    public function __clone()
1634
-    {
1635
-    }
1636
-
1637
-
1638
-
1639
-    /**
1640
-     *        __wakeup
1641
-     */
1642
-    public function __wakeup()
1643
-    {
1644
-    }
1645
-
1646
-
1647
-
1648
-    /**
1649
-     *        __destruct
1650
-     */
1651
-    public function __destruct()
1652
-    {
1653
-    }
1654
-}
1655
-
1656
-
1657
-
1658
-/**
1659
- * Class for defining what's in the EE_Config relating to registration settings
1660
- */
1661
-class EE_Core_Config extends EE_Config_Base
1662
-{
1663
-
1664
-    public $current_blog_id;
1665
-
1666
-    public $ee_ueip_optin;
1667
-
1668
-    public $ee_ueip_has_notified;
1669
-
1670
-    /**
1671
-     * Not to be confused with the 4 critical page variables (See
1672
-     * get_critical_pages_array()), this is just an array of wp posts that have EE
1673
-     * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1674
-     * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1675
-     *
1676
-     * @var array
1677
-     */
1678
-    public $post_shortcodes;
1679
-
1680
-    public $module_route_map;
1681
-
1682
-    public $module_forward_map;
1683
-
1684
-    public $module_view_map;
1685
-
1686
-    /**
1687
-     * The next 4 vars are the IDs of critical EE pages.
1688
-     *
1689
-     * @var int
1690
-     */
1691
-    public $reg_page_id;
1692
-
1693
-    public $txn_page_id;
1694
-
1695
-    public $thank_you_page_id;
1696
-
1697
-    public $cancel_page_id;
1698
-
1699
-    /**
1700
-     * The next 4 vars are the URLs of critical EE pages.
1701
-     *
1702
-     * @var int
1703
-     */
1704
-    public $reg_page_url;
1705
-
1706
-    public $txn_page_url;
1707
-
1708
-    public $thank_you_page_url;
1709
-
1710
-    public $cancel_page_url;
1711
-
1712
-    /**
1713
-     * The next vars relate to the custom slugs for EE CPT routes
1714
-     */
1715
-    public $event_cpt_slug;
1716
-
1717
-
1718
-    /**
1719
-     * This caches the _ee_ueip_option in case this config is reset in the same
1720
-     * request across blog switches in a multisite context.
1721
-     * Avoids extra queries to the db for this option.
1722
-     *
1723
-     * @var bool
1724
-     */
1725
-    public static $ee_ueip_option;
1726
-
1727
-
1728
-
1729
-    /**
1730
-     *    class constructor
1731
-     *
1732
-     * @access    public
1733
-     */
1734
-    public function __construct()
1735
-    {
1736
-        // set default organization settings
1737
-        $this->current_blog_id = get_current_blog_id();
1738
-        $this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1739
-        $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1740
-        $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1741
-        $this->post_shortcodes = array();
1742
-        $this->module_route_map = array();
1743
-        $this->module_forward_map = array();
1744
-        $this->module_view_map = array();
1745
-        // critical EE page IDs
1746
-        $this->reg_page_id = 0;
1747
-        $this->txn_page_id = 0;
1748
-        $this->thank_you_page_id = 0;
1749
-        $this->cancel_page_id = 0;
1750
-        // critical EE page URLs
1751
-        $this->reg_page_url = '';
1752
-        $this->txn_page_url = '';
1753
-        $this->thank_you_page_url = '';
1754
-        $this->cancel_page_url = '';
1755
-        //cpt slugs
1756
-        $this->event_cpt_slug = __('events', 'event_espresso');
1757
-        //ueip constant check
1758
-        if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1759
-            $this->ee_ueip_optin = false;
1760
-            $this->ee_ueip_has_notified = true;
1761
-        }
1762
-    }
1763
-
1764
-
1765
-
1766
-    /**
1767
-     * @return array
1768
-     */
1769
-    public function get_critical_pages_array()
1770
-    {
1771
-        return array(
1772
-            $this->reg_page_id,
1773
-            $this->txn_page_id,
1774
-            $this->thank_you_page_id,
1775
-            $this->cancel_page_id,
1776
-        );
1777
-    }
1778
-
1779
-
1780
-
1781
-    /**
1782
-     * @return array
1783
-     */
1784
-    public function get_critical_pages_shortcodes_array()
1785
-    {
1786
-        return array(
1787
-            $this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1788
-            $this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1789
-            $this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1790
-            $this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1791
-        );
1792
-    }
1793
-
1794
-
1795
-
1796
-    /**
1797
-     *  gets/returns URL for EE reg_page
1798
-     *
1799
-     * @access    public
1800
-     * @return    string
1801
-     */
1802
-    public function reg_page_url()
1803
-    {
1804
-        if (! $this->reg_page_url) {
1805
-            $this->reg_page_url = add_query_arg(
1806
-                                      array('uts' => time()),
1807
-                                      get_permalink($this->reg_page_id)
1808
-                                  ) . '#checkout';
1809
-        }
1810
-        return $this->reg_page_url;
1811
-    }
1812
-
1813
-
1814
-
1815
-    /**
1816
-     *  gets/returns URL for EE txn_page
1817
-     *
1818
-     * @param array $query_args like what gets passed to
1819
-     *                          add_query_arg() as the first argument
1820
-     * @access    public
1821
-     * @return    string
1822
-     */
1823
-    public function txn_page_url($query_args = array())
1824
-    {
1825
-        if (! $this->txn_page_url) {
1826
-            $this->txn_page_url = get_permalink($this->txn_page_id);
1827
-        }
1828
-        if ($query_args) {
1829
-            return add_query_arg($query_args, $this->txn_page_url);
1830
-        } else {
1831
-            return $this->txn_page_url;
1832
-        }
1833
-    }
1834
-
1835
-
1836
-
1837
-    /**
1838
-     *  gets/returns URL for EE thank_you_page
1839
-     *
1840
-     * @param array $query_args like what gets passed to
1841
-     *                          add_query_arg() as the first argument
1842
-     * @access    public
1843
-     * @return    string
1844
-     */
1845
-    public function thank_you_page_url($query_args = array())
1846
-    {
1847
-        if (! $this->thank_you_page_url) {
1848
-            $this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1849
-        }
1850
-        if ($query_args) {
1851
-            return add_query_arg($query_args, $this->thank_you_page_url);
1852
-        } else {
1853
-            return $this->thank_you_page_url;
1854
-        }
1855
-    }
1856
-
1857
-
1858
-
1859
-    /**
1860
-     *  gets/returns URL for EE cancel_page
1861
-     *
1862
-     * @access    public
1863
-     * @return    string
1864
-     */
1865
-    public function cancel_page_url()
1866
-    {
1867
-        if (! $this->cancel_page_url) {
1868
-            $this->cancel_page_url = get_permalink($this->cancel_page_id);
1869
-        }
1870
-        return $this->cancel_page_url;
1871
-    }
1872
-
1873
-
1874
-
1875
-    /**
1876
-     * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1877
-     *
1878
-     * @since 4.7.5
1879
-     */
1880
-    protected function _reset_urls()
1881
-    {
1882
-        $this->reg_page_url = '';
1883
-        $this->txn_page_url = '';
1884
-        $this->cancel_page_url = '';
1885
-        $this->thank_you_page_url = '';
1886
-    }
1887
-
1888
-
1889
-
1890
-    /**
1891
-     * Used to return what the optin value is set for the EE User Experience Program.
1892
-     * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1893
-     * on the main site only.
1894
-     *
1895
-     * @return mixed|void
1896
-     */
1897
-    protected function _get_main_ee_ueip_optin()
1898
-    {
1899
-        //if this is the main site then we can just bypass our direct query.
1900
-        if (is_main_site()) {
1901
-            return get_option('ee_ueip_optin', false);
1902
-        }
1903
-        //is this already cached for this request?  If so use it.
1904
-        if ( ! empty(EE_Core_Config::$ee_ueip_option)) {
1905
-            return EE_Core_Config::$ee_ueip_option;
1906
-        }
1907
-        global $wpdb;
1908
-        $current_network_main_site = is_multisite() ? get_current_site() : null;
1909
-        $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1910
-        $option = 'ee_ueip_optin';
1911
-        //set correct table for query
1912
-        $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1913
-        //rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1914
-        //get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1915
-        //re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1916
-        //this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1917
-        //for the purpose of caching.
1918
-        $pre = apply_filters('pre_option_' . $option, false, $option);
1919
-        if (false !== $pre) {
1920
-            EE_Core_Config::$ee_ueip_option = $pre;
1921
-            return EE_Core_Config::$ee_ueip_option;
1922
-        }
1923
-        $row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1924
-            $option));
1925
-        if (is_object($row)) {
1926
-            $value = $row->option_value;
1927
-        } else { //option does not exist so use default.
1928
-            return apply_filters('default_option_' . $option, false, $option);
1929
-        }
1930
-        EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1931
-        return EE_Core_Config::$ee_ueip_option;
1932
-    }
1933
-
1934
-
1935
-
1936
-    /**
1937
-     * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1938
-     * on the object.
1939
-     *
1940
-     * @return array
1941
-     */
1942
-    public function __sleep()
1943
-    {
1944
-        //reset all url properties
1945
-        $this->_reset_urls();
1946
-        //return what to save to db
1947
-        return array_keys(get_object_vars($this));
1948
-    }
1949
-
1950
-}
1951
-
1952
-
1953
-
1954
-/**
1955
- * Config class for storing info on the Organization
1956
- */
1957
-class EE_Organization_Config extends EE_Config_Base
1958
-{
1959
-
1960
-    /**
1961
-     * @var string $name
1962
-     * eg EE4.1
1963
-     */
1964
-    public $name;
1965
-
1966
-    /**
1967
-     * @var string $address_1
1968
-     * eg 123 Onna Road
1969
-     */
1970
-    public $address_1;
1971
-
1972
-    /**
1973
-     * @var string $address_2
1974
-     * eg PO Box 123
1975
-     */
1976
-    public $address_2;
1977
-
1978
-    /**
1979
-     * @var string $city
1980
-     * eg Inna City
1981
-     */
1982
-    public $city;
1983
-
1984
-    /**
1985
-     * @var int $STA_ID
1986
-     * eg 4
1987
-     */
1988
-    public $STA_ID;
1989
-
1990
-    /**
1991
-     * @var string $CNT_ISO
1992
-     * eg US
1993
-     */
1994
-    public $CNT_ISO;
1995
-
1996
-    /**
1997
-     * @var string $zip
1998
-     * eg 12345  or V1A 2B3
1999
-     */
2000
-    public $zip;
2001
-
2002
-    /**
2003
-     * @var string $email
2004
-     * eg [email protected]
2005
-     */
2006
-    public $email;
2007
-
2008
-
2009
-    /**
2010
-     * @var string $phone
2011
-     * eg. 111-111-1111
2012
-     */
2013
-    public $phone;
2014
-
2015
-
2016
-    /**
2017
-     * @var string $vat
2018
-     * VAT/Tax Number
2019
-     */
2020
-    public $vat;
2021
-
2022
-    /**
2023
-     * @var string $logo_url
2024
-     * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
2025
-     */
2026
-    public $logo_url;
2027
-
2028
-
2029
-    /**
2030
-     * The below are all various properties for holding links to organization social network profiles
2031
-     *
2032
-     * @var string
2033
-     */
2034
-    /**
2035
-     * facebook (facebook.com/profile.name)
2036
-     *
2037
-     * @var string
2038
-     */
2039
-    public $facebook;
2040
-
2041
-
2042
-    /**
2043
-     * twitter (twitter.com/twitter_handle)
2044
-     *
2045
-     * @var string
2046
-     */
2047
-    public $twitter;
2048
-
2049
-
2050
-    /**
2051
-     * linkedin (linkedin.com/in/profile_name)
2052
-     *
2053
-     * @var string
2054
-     */
2055
-    public $linkedin;
2056
-
2057
-
2058
-    /**
2059
-     * pinterest (www.pinterest.com/profile_name)
2060
-     *
2061
-     * @var string
2062
-     */
2063
-    public $pinterest;
2064
-
2065
-
2066
-    /**
2067
-     * google+ (google.com/+profileName)
2068
-     *
2069
-     * @var string
2070
-     */
2071
-    public $google;
2072
-
2073
-
2074
-    /**
2075
-     * instagram (instagram.com/handle)
2076
-     *
2077
-     * @var string
2078
-     */
2079
-    public $instagram;
2080
-
2081
-
2082
-
2083
-    /**
2084
-     *    class constructor
2085
-     *
2086
-     * @access    public
2087
-     */
2088
-    public function __construct()
2089
-    {
2090
-        // set default organization settings
2091
-        //decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded
2092
-        $this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
2093
-        $this->address_1 = '123 Onna Road';
2094
-        $this->address_2 = 'PO Box 123';
2095
-        $this->city = 'Inna City';
2096
-        $this->STA_ID = 4;
2097
-        $this->CNT_ISO = 'US';
2098
-        $this->zip = '12345';
2099
-        $this->email = get_bloginfo('admin_email');
2100
-        $this->phone = '';
2101
-        $this->vat = '123456789';
2102
-        $this->logo_url = '';
2103
-        $this->facebook = '';
2104
-        $this->twitter = '';
2105
-        $this->linkedin = '';
2106
-        $this->pinterest = '';
2107
-        $this->google = '';
2108
-        $this->instagram = '';
2109
-    }
2110
-
2111
-}
2112
-
2113
-
2114
-
2115
-/**
2116
- * Class for defining what's in the EE_Config relating to currency
2117
- */
2118
-class EE_Currency_Config extends EE_Config_Base
2119
-{
2120
-
2121
-    /**
2122
-     * @var string $code
2123
-     * eg 'US'
2124
-     */
2125
-    public $code;
2126
-
2127
-    /**
2128
-     * @var string $name
2129
-     * eg 'Dollar'
2130
-     */
2131
-    public $name;
2132
-
2133
-    /**
2134
-     * plural name
2135
-     *
2136
-     * @var string $plural
2137
-     * eg 'Dollars'
2138
-     */
2139
-    public $plural;
2140
-
2141
-    /**
2142
-     * currency sign
2143
-     *
2144
-     * @var string $sign
2145
-     * eg '$'
2146
-     */
2147
-    public $sign;
2148
-
2149
-    /**
2150
-     * Whether the currency sign should come before the number or not
2151
-     *
2152
-     * @var boolean $sign_b4
2153
-     */
2154
-    public $sign_b4;
2155
-
2156
-    /**
2157
-     * How many digits should come after the decimal place
2158
-     *
2159
-     * @var int $dec_plc
2160
-     */
2161
-    public $dec_plc;
2162
-
2163
-    /**
2164
-     * Symbol to use for decimal mark
2165
-     *
2166
-     * @var string $dec_mrk
2167
-     * eg '.'
2168
-     */
2169
-    public $dec_mrk;
2170
-
2171
-    /**
2172
-     * Symbol to use for thousands
2173
-     *
2174
-     * @var string $thsnds
2175
-     * eg ','
2176
-     */
2177
-    public $thsnds;
2178
-
2179
-
2180
-
2181
-    /**
2182
-     *    class constructor
2183
-     *
2184
-     * @access    public
2185
-     * @param string $CNT_ISO
2186
-     * @throws \EE_Error
2187
-     */
2188
-    public function __construct($CNT_ISO = '')
2189
-    {
2190
-        /** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */
2191
-        $table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
2192
-        // get country code from organization settings or use default
2193
-        $ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2194
-                   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2195
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
2196
-            : '';
2197
-        // but override if requested
2198
-        $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2199
-        // so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists
2200
-        if (
2201
-            ! empty($CNT_ISO)
2202
-            && EE_Maintenance_Mode::instance()->models_can_query()
2203
-            && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2204
-        ) {
2205
-            // retrieve the country settings from the db, just in case they have been customized
2206
-            $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2207
-            if ($country instanceof EE_Country) {
2208
-                $this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2209
-                $this->name = $country->currency_name_single();    // Dollar
2210
-                $this->plural = $country->currency_name_plural();    // Dollars
2211
-                $this->sign = $country->currency_sign();            // currency sign: $
2212
-                $this->sign_b4 = $country->currency_sign_before();        // currency sign before or after: $TRUE  or  FALSE$
2213
-                $this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2214
-                $this->dec_mrk = $country->currency_decimal_mark();    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2215
-                $this->thsnds = $country->currency_thousands_separator();    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2216
-            }
2217
-        }
2218
-        // fallback to hardcoded defaults, in case the above failed
2219
-        if (empty($this->code)) {
2220
-            // set default currency settings
2221
-            $this->code = 'USD';    // currency code: USD, CAD, EUR
2222
-            $this->name = __('Dollar', 'event_espresso');    // Dollar
2223
-            $this->plural = __('Dollars', 'event_espresso');    // Dollars
2224
-            $this->sign = '$';    // currency sign: $
2225
-            $this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2226
-            $this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2227
-            $this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2228
-            $this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2229
-        }
2230
-    }
2231
-}
2232
-
2233
-
2234
-
2235
-/**
2236
- * Class for defining what's in the EE_Config relating to registration settings
2237
- */
2238
-class EE_Registration_Config extends EE_Config_Base
2239
-{
2240
-
2241
-    /**
2242
-     * Default registration status
2243
-     *
2244
-     * @var string $default_STS_ID
2245
-     * eg 'RPP'
2246
-     */
2247
-    public $default_STS_ID;
2248
-
2249
-
2250
-    /**
2251
-     * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of
2252
-     * registrations)
2253
-     * @var int
2254
-     */
2255
-    public $default_maximum_number_of_tickets;
2256
-
2257
-
2258
-    /**
2259
-     * level of validation to apply to email addresses
2260
-     *
2261
-     * @var string $email_validation_level
2262
-     * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2263
-     */
2264
-    public $email_validation_level;
2265
-
2266
-    /**
2267
-     *    whether or not to show alternate payment options during the reg process if payment status is pending
2268
-     *
2269
-     * @var boolean $show_pending_payment_options
2270
-     */
2271
-    public $show_pending_payment_options;
2272
-
2273
-    /**
2274
-     * Whether to skip the registration confirmation page
2275
-     *
2276
-     * @var boolean $skip_reg_confirmation
2277
-     */
2278
-    public $skip_reg_confirmation;
2279
-
2280
-    /**
2281
-     * an array of SPCO reg steps where:
2282
-     *        the keys denotes the reg step order
2283
-     *        each element consists of an array with the following elements:
2284
-     *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2285
-     *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2286
-     *            "slug" => the URL param used to trigger the reg step
2287
-     *
2288
-     * @var array $reg_steps
2289
-     */
2290
-    public $reg_steps;
2291
-
2292
-    /**
2293
-     * Whether registration confirmation should be the last page of SPCO
2294
-     *
2295
-     * @var boolean $reg_confirmation_last
2296
-     */
2297
-    public $reg_confirmation_last;
2298
-
2299
-    /**
2300
-     * Whether or not to enable the EE Bot Trap
2301
-     *
2302
-     * @var boolean $use_bot_trap
2303
-     */
2304
-    public $use_bot_trap;
2305
-
2306
-    /**
2307
-     * Whether or not to encrypt some data sent by the EE Bot Trap
2308
-     *
2309
-     * @var boolean $use_encryption
2310
-     */
2311
-    public $use_encryption;
2312
-
2313
-    /**
2314
-     * Whether or not to use ReCaptcha
2315
-     *
2316
-     * @var boolean $use_captcha
2317
-     */
2318
-    public $use_captcha;
2319
-
2320
-    /**
2321
-     * ReCaptcha Theme
2322
-     *
2323
-     * @var string $recaptcha_theme
2324
-     *    options: 'dark', 'light', 'invisible'
2325
-     */
2326
-    public $recaptcha_theme;
1544
+}
2327 1545
 
2328
-    /**
2329
-     * ReCaptcha Badge - determines the position of the reCAPTCHA badge if using Invisible ReCaptcha.
2330
-     *
2331
-     * @var string $recaptcha_badge
2332
-     *    options: 'bottomright', 'bottomleft', 'inline'
2333
-     */
2334
-    public $recaptcha_badge;
2335 1546
 
2336
-    /**
2337
-     * ReCaptcha Type
2338
-     *
2339
-     * @var string $recaptcha_type
2340
-     *    options: 'audio', 'image'
2341
-     */
2342
-    public $recaptcha_type;
2343 1547
 
2344
-    /**
2345
-     * ReCaptcha language
2346
-     *
2347
-     * @var string $recaptcha_language
2348
-     * eg 'en'
2349
-     */
2350
-    public $recaptcha_language;
1548
+/**
1549
+ * Base class used for config classes. These classes should generally not have
1550
+ * magic functions in use, except we'll allow them to magically set and get stuff...
1551
+ * basically, they should just be well-defined stdClasses
1552
+ */
1553
+class EE_Config_Base
1554
+{
2351 1555
 
2352
-    /**
2353
-     * ReCaptcha public key
2354
-     *
2355
-     * @var string $recaptcha_publickey
2356
-     */
2357
-    public $recaptcha_publickey;
1556
+	/**
1557
+	 * Utility function for escaping the value of a property and returning.
1558
+	 *
1559
+	 * @param string $property property name (checks to see if exists).
1560
+	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1561
+	 * @throws \EE_Error
1562
+	 */
1563
+	public function get_pretty($property)
1564
+	{
1565
+		if (! property_exists($this, $property)) {
1566
+			throw new EE_Error(
1567
+				sprintf(
1568
+					__(
1569
+						'%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1570
+						'event_espresso'
1571
+					),
1572
+					get_class($this),
1573
+					$property
1574
+				)
1575
+			);
1576
+		}
1577
+		//just handling escaping of strings for now.
1578
+		if (is_string($this->{$property})) {
1579
+			return stripslashes($this->{$property});
1580
+		}
1581
+		return $this->{$property};
1582
+	}
1583
+
1584
+
1585
+
1586
+	public function populate()
1587
+	{
1588
+		//grab defaults via a new instance of this class.
1589
+		$class_name = get_class($this);
1590
+		$defaults = new $class_name;
1591
+		//loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1592
+		//default from our $defaults object.
1593
+		foreach (get_object_vars($defaults) as $property => $value) {
1594
+			if ($this->{$property} === null) {
1595
+				$this->{$property} = $value;
1596
+			}
1597
+		}
1598
+		//cleanup
1599
+		unset($defaults);
1600
+	}
1601
+
1602
+
1603
+
1604
+	/**
1605
+	 *        __isset
1606
+	 *
1607
+	 * @param $a
1608
+	 * @return bool
1609
+	 */
1610
+	public function __isset($a)
1611
+	{
1612
+		return false;
1613
+	}
1614
+
1615
+
1616
+
1617
+	/**
1618
+	 *        __unset
1619
+	 *
1620
+	 * @param $a
1621
+	 * @return bool
1622
+	 */
1623
+	public function __unset($a)
1624
+	{
1625
+		return false;
1626
+	}
1627
+
1628
+
1629
+
1630
+	/**
1631
+	 *        __clone
1632
+	 */
1633
+	public function __clone()
1634
+	{
1635
+	}
1636
+
1637
+
1638
+
1639
+	/**
1640
+	 *        __wakeup
1641
+	 */
1642
+	public function __wakeup()
1643
+	{
1644
+	}
1645
+
1646
+
1647
+
1648
+	/**
1649
+	 *        __destruct
1650
+	 */
1651
+	public function __destruct()
1652
+	{
1653
+	}
1654
+}
2358 1655
 
2359
-    /**
2360
-     * ReCaptcha private key
2361
-     *
2362
-     * @var string $recaptcha_privatekey
2363
-     */
2364
-    public $recaptcha_privatekey;
2365 1656
 
2366
-    /**
2367
-     * array of form names protected by ReCaptcha
2368
-     *
2369
-     * @var array $recaptcha_protected_forms
2370
-     */
2371
-    public $recaptcha_protected_forms;
2372 1657
 
2373
-    /**
2374
-     * ReCaptcha width
2375
-     *
2376
-     * @var int $recaptcha_width
2377
-     * @deprecated
2378
-     */
2379
-    public $recaptcha_width;
1658
+/**
1659
+ * Class for defining what's in the EE_Config relating to registration settings
1660
+ */
1661
+class EE_Core_Config extends EE_Config_Base
1662
+{
2380 1663
 
2381
-    /**
2382
-     * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2383
-     *
2384
-     * @var boolean $track_invalid_checkout_access
2385
-     */
2386
-    protected $track_invalid_checkout_access = true;
1664
+	public $current_blog_id;
1665
+
1666
+	public $ee_ueip_optin;
1667
+
1668
+	public $ee_ueip_has_notified;
1669
+
1670
+	/**
1671
+	 * Not to be confused with the 4 critical page variables (See
1672
+	 * get_critical_pages_array()), this is just an array of wp posts that have EE
1673
+	 * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1674
+	 * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1675
+	 *
1676
+	 * @var array
1677
+	 */
1678
+	public $post_shortcodes;
1679
+
1680
+	public $module_route_map;
1681
+
1682
+	public $module_forward_map;
1683
+
1684
+	public $module_view_map;
1685
+
1686
+	/**
1687
+	 * The next 4 vars are the IDs of critical EE pages.
1688
+	 *
1689
+	 * @var int
1690
+	 */
1691
+	public $reg_page_id;
1692
+
1693
+	public $txn_page_id;
1694
+
1695
+	public $thank_you_page_id;
1696
+
1697
+	public $cancel_page_id;
1698
+
1699
+	/**
1700
+	 * The next 4 vars are the URLs of critical EE pages.
1701
+	 *
1702
+	 * @var int
1703
+	 */
1704
+	public $reg_page_url;
1705
+
1706
+	public $txn_page_url;
1707
+
1708
+	public $thank_you_page_url;
1709
+
1710
+	public $cancel_page_url;
1711
+
1712
+	/**
1713
+	 * The next vars relate to the custom slugs for EE CPT routes
1714
+	 */
1715
+	public $event_cpt_slug;
1716
+
1717
+
1718
+	/**
1719
+	 * This caches the _ee_ueip_option in case this config is reset in the same
1720
+	 * request across blog switches in a multisite context.
1721
+	 * Avoids extra queries to the db for this option.
1722
+	 *
1723
+	 * @var bool
1724
+	 */
1725
+	public static $ee_ueip_option;
1726
+
1727
+
1728
+
1729
+	/**
1730
+	 *    class constructor
1731
+	 *
1732
+	 * @access    public
1733
+	 */
1734
+	public function __construct()
1735
+	{
1736
+		// set default organization settings
1737
+		$this->current_blog_id = get_current_blog_id();
1738
+		$this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1739
+		$this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1740
+		$this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1741
+		$this->post_shortcodes = array();
1742
+		$this->module_route_map = array();
1743
+		$this->module_forward_map = array();
1744
+		$this->module_view_map = array();
1745
+		// critical EE page IDs
1746
+		$this->reg_page_id = 0;
1747
+		$this->txn_page_id = 0;
1748
+		$this->thank_you_page_id = 0;
1749
+		$this->cancel_page_id = 0;
1750
+		// critical EE page URLs
1751
+		$this->reg_page_url = '';
1752
+		$this->txn_page_url = '';
1753
+		$this->thank_you_page_url = '';
1754
+		$this->cancel_page_url = '';
1755
+		//cpt slugs
1756
+		$this->event_cpt_slug = __('events', 'event_espresso');
1757
+		//ueip constant check
1758
+		if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1759
+			$this->ee_ueip_optin = false;
1760
+			$this->ee_ueip_has_notified = true;
1761
+		}
1762
+	}
1763
+
1764
+
1765
+
1766
+	/**
1767
+	 * @return array
1768
+	 */
1769
+	public function get_critical_pages_array()
1770
+	{
1771
+		return array(
1772
+			$this->reg_page_id,
1773
+			$this->txn_page_id,
1774
+			$this->thank_you_page_id,
1775
+			$this->cancel_page_id,
1776
+		);
1777
+	}
1778
+
1779
+
1780
+
1781
+	/**
1782
+	 * @return array
1783
+	 */
1784
+	public function get_critical_pages_shortcodes_array()
1785
+	{
1786
+		return array(
1787
+			$this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1788
+			$this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1789
+			$this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1790
+			$this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1791
+		);
1792
+	}
1793
+
1794
+
1795
+
1796
+	/**
1797
+	 *  gets/returns URL for EE reg_page
1798
+	 *
1799
+	 * @access    public
1800
+	 * @return    string
1801
+	 */
1802
+	public function reg_page_url()
1803
+	{
1804
+		if (! $this->reg_page_url) {
1805
+			$this->reg_page_url = add_query_arg(
1806
+									  array('uts' => time()),
1807
+									  get_permalink($this->reg_page_id)
1808
+								  ) . '#checkout';
1809
+		}
1810
+		return $this->reg_page_url;
1811
+	}
1812
+
1813
+
1814
+
1815
+	/**
1816
+	 *  gets/returns URL for EE txn_page
1817
+	 *
1818
+	 * @param array $query_args like what gets passed to
1819
+	 *                          add_query_arg() as the first argument
1820
+	 * @access    public
1821
+	 * @return    string
1822
+	 */
1823
+	public function txn_page_url($query_args = array())
1824
+	{
1825
+		if (! $this->txn_page_url) {
1826
+			$this->txn_page_url = get_permalink($this->txn_page_id);
1827
+		}
1828
+		if ($query_args) {
1829
+			return add_query_arg($query_args, $this->txn_page_url);
1830
+		} else {
1831
+			return $this->txn_page_url;
1832
+		}
1833
+	}
1834
+
1835
+
1836
+
1837
+	/**
1838
+	 *  gets/returns URL for EE thank_you_page
1839
+	 *
1840
+	 * @param array $query_args like what gets passed to
1841
+	 *                          add_query_arg() as the first argument
1842
+	 * @access    public
1843
+	 * @return    string
1844
+	 */
1845
+	public function thank_you_page_url($query_args = array())
1846
+	{
1847
+		if (! $this->thank_you_page_url) {
1848
+			$this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1849
+		}
1850
+		if ($query_args) {
1851
+			return add_query_arg($query_args, $this->thank_you_page_url);
1852
+		} else {
1853
+			return $this->thank_you_page_url;
1854
+		}
1855
+	}
1856
+
1857
+
1858
+
1859
+	/**
1860
+	 *  gets/returns URL for EE cancel_page
1861
+	 *
1862
+	 * @access    public
1863
+	 * @return    string
1864
+	 */
1865
+	public function cancel_page_url()
1866
+	{
1867
+		if (! $this->cancel_page_url) {
1868
+			$this->cancel_page_url = get_permalink($this->cancel_page_id);
1869
+		}
1870
+		return $this->cancel_page_url;
1871
+	}
1872
+
1873
+
1874
+
1875
+	/**
1876
+	 * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1877
+	 *
1878
+	 * @since 4.7.5
1879
+	 */
1880
+	protected function _reset_urls()
1881
+	{
1882
+		$this->reg_page_url = '';
1883
+		$this->txn_page_url = '';
1884
+		$this->cancel_page_url = '';
1885
+		$this->thank_you_page_url = '';
1886
+	}
1887
+
1888
+
1889
+
1890
+	/**
1891
+	 * Used to return what the optin value is set for the EE User Experience Program.
1892
+	 * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1893
+	 * on the main site only.
1894
+	 *
1895
+	 * @return mixed|void
1896
+	 */
1897
+	protected function _get_main_ee_ueip_optin()
1898
+	{
1899
+		//if this is the main site then we can just bypass our direct query.
1900
+		if (is_main_site()) {
1901
+			return get_option('ee_ueip_optin', false);
1902
+		}
1903
+		//is this already cached for this request?  If so use it.
1904
+		if ( ! empty(EE_Core_Config::$ee_ueip_option)) {
1905
+			return EE_Core_Config::$ee_ueip_option;
1906
+		}
1907
+		global $wpdb;
1908
+		$current_network_main_site = is_multisite() ? get_current_site() : null;
1909
+		$current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1910
+		$option = 'ee_ueip_optin';
1911
+		//set correct table for query
1912
+		$table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1913
+		//rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1914
+		//get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1915
+		//re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1916
+		//this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1917
+		//for the purpose of caching.
1918
+		$pre = apply_filters('pre_option_' . $option, false, $option);
1919
+		if (false !== $pre) {
1920
+			EE_Core_Config::$ee_ueip_option = $pre;
1921
+			return EE_Core_Config::$ee_ueip_option;
1922
+		}
1923
+		$row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1924
+			$option));
1925
+		if (is_object($row)) {
1926
+			$value = $row->option_value;
1927
+		} else { //option does not exist so use default.
1928
+			return apply_filters('default_option_' . $option, false, $option);
1929
+		}
1930
+		EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1931
+		return EE_Core_Config::$ee_ueip_option;
1932
+	}
1933
+
1934
+
1935
+
1936
+	/**
1937
+	 * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1938
+	 * on the object.
1939
+	 *
1940
+	 * @return array
1941
+	 */
1942
+	public function __sleep()
1943
+	{
1944
+		//reset all url properties
1945
+		$this->_reset_urls();
1946
+		//return what to save to db
1947
+		return array_keys(get_object_vars($this));
1948
+	}
2387 1949
 
1950
+}
2388 1951
 
2389 1952
 
2390
-    /**
2391
-     *    class constructor
2392
-     *
2393
-     * @access    public
2394
-     */
2395
-    public function __construct()
2396
-    {
2397
-        // set default registration settings
2398
-        $this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2399
-        $this->email_validation_level = 'wp_default';
2400
-        $this->show_pending_payment_options = true;
2401
-        $this->skip_reg_confirmation = false;
2402
-        $this->reg_steps = array();
2403
-        $this->reg_confirmation_last = false;
2404
-        $this->use_bot_trap = true;
2405
-        $this->use_encryption = true;
2406
-        $this->use_captcha = false;
2407
-        $this->recaptcha_theme = 'light';
2408
-        $this->recaptcha_badge = 'bottomleft';
2409
-        $this->recaptcha_type = 'image';
2410
-        $this->recaptcha_language = 'en';
2411
-        $this->recaptcha_publickey = null;
2412
-        $this->recaptcha_privatekey = null;
2413
-        $this->recaptcha_protected_forms = array();
2414
-        $this->recaptcha_width = 500;
2415
-        $this->default_maximum_number_of_tickets = 10;
2416
-    }
2417
-
2418
-
2419
-
2420
-    /**
2421
-     * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2422
-     *
2423
-     * @since 4.8.8.rc.019
2424
-     */
2425
-    public function do_hooks()
2426
-    {
2427
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2428
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event'));
2429
-    }
2430 1953
 
1954
+/**
1955
+ * Config class for storing info on the Organization
1956
+ */
1957
+class EE_Organization_Config extends EE_Config_Base
1958
+{
2431 1959
 
1960
+	/**
1961
+	 * @var string $name
1962
+	 * eg EE4.1
1963
+	 */
1964
+	public $name;
1965
+
1966
+	/**
1967
+	 * @var string $address_1
1968
+	 * eg 123 Onna Road
1969
+	 */
1970
+	public $address_1;
1971
+
1972
+	/**
1973
+	 * @var string $address_2
1974
+	 * eg PO Box 123
1975
+	 */
1976
+	public $address_2;
1977
+
1978
+	/**
1979
+	 * @var string $city
1980
+	 * eg Inna City
1981
+	 */
1982
+	public $city;
1983
+
1984
+	/**
1985
+	 * @var int $STA_ID
1986
+	 * eg 4
1987
+	 */
1988
+	public $STA_ID;
1989
+
1990
+	/**
1991
+	 * @var string $CNT_ISO
1992
+	 * eg US
1993
+	 */
1994
+	public $CNT_ISO;
1995
+
1996
+	/**
1997
+	 * @var string $zip
1998
+	 * eg 12345  or V1A 2B3
1999
+	 */
2000
+	public $zip;
2001
+
2002
+	/**
2003
+	 * @var string $email
2004
+	 * eg [email protected]
2005
+	 */
2006
+	public $email;
2007
+
2008
+
2009
+	/**
2010
+	 * @var string $phone
2011
+	 * eg. 111-111-1111
2012
+	 */
2013
+	public $phone;
2014
+
2015
+
2016
+	/**
2017
+	 * @var string $vat
2018
+	 * VAT/Tax Number
2019
+	 */
2020
+	public $vat;
2021
+
2022
+	/**
2023
+	 * @var string $logo_url
2024
+	 * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
2025
+	 */
2026
+	public $logo_url;
2027
+
2028
+
2029
+	/**
2030
+	 * The below are all various properties for holding links to organization social network profiles
2031
+	 *
2032
+	 * @var string
2033
+	 */
2034
+	/**
2035
+	 * facebook (facebook.com/profile.name)
2036
+	 *
2037
+	 * @var string
2038
+	 */
2039
+	public $facebook;
2040
+
2041
+
2042
+	/**
2043
+	 * twitter (twitter.com/twitter_handle)
2044
+	 *
2045
+	 * @var string
2046
+	 */
2047
+	public $twitter;
2048
+
2049
+
2050
+	/**
2051
+	 * linkedin (linkedin.com/in/profile_name)
2052
+	 *
2053
+	 * @var string
2054
+	 */
2055
+	public $linkedin;
2056
+
2057
+
2058
+	/**
2059
+	 * pinterest (www.pinterest.com/profile_name)
2060
+	 *
2061
+	 * @var string
2062
+	 */
2063
+	public $pinterest;
2064
+
2065
+
2066
+	/**
2067
+	 * google+ (google.com/+profileName)
2068
+	 *
2069
+	 * @var string
2070
+	 */
2071
+	public $google;
2072
+
2073
+
2074
+	/**
2075
+	 * instagram (instagram.com/handle)
2076
+	 *
2077
+	 * @var string
2078
+	 */
2079
+	public $instagram;
2080
+
2081
+
2082
+
2083
+	/**
2084
+	 *    class constructor
2085
+	 *
2086
+	 * @access    public
2087
+	 */
2088
+	public function __construct()
2089
+	{
2090
+		// set default organization settings
2091
+		//decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded
2092
+		$this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
2093
+		$this->address_1 = '123 Onna Road';
2094
+		$this->address_2 = 'PO Box 123';
2095
+		$this->city = 'Inna City';
2096
+		$this->STA_ID = 4;
2097
+		$this->CNT_ISO = 'US';
2098
+		$this->zip = '12345';
2099
+		$this->email = get_bloginfo('admin_email');
2100
+		$this->phone = '';
2101
+		$this->vat = '123456789';
2102
+		$this->logo_url = '';
2103
+		$this->facebook = '';
2104
+		$this->twitter = '';
2105
+		$this->linkedin = '';
2106
+		$this->pinterest = '';
2107
+		$this->google = '';
2108
+		$this->instagram = '';
2109
+	}
2432 2110
 
2433
-    /**
2434
-     * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_default_registration_status
2435
-     * field matches the config setting for default_STS_ID.
2436
-     */
2437
-    public function set_default_reg_status_on_EEM_Event()
2438
-    {
2439
-        EEM_Event::set_default_reg_status($this->default_STS_ID);
2440
-    }
2111
+}
2441 2112
 
2442 2113
 
2443
-    /**
2444
-     * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field
2445
-     * for Events matches the config setting for default_maximum_number_of_tickets
2446
-     */
2447
-    public function set_default_max_ticket_on_EEM_Event()
2448
-    {
2449
-        EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets);
2450
-    }
2451 2114
 
2115
+/**
2116
+ * Class for defining what's in the EE_Config relating to currency
2117
+ */
2118
+class EE_Currency_Config extends EE_Config_Base
2119
+{
2452 2120
 
2121
+	/**
2122
+	 * @var string $code
2123
+	 * eg 'US'
2124
+	 */
2125
+	public $code;
2126
+
2127
+	/**
2128
+	 * @var string $name
2129
+	 * eg 'Dollar'
2130
+	 */
2131
+	public $name;
2132
+
2133
+	/**
2134
+	 * plural name
2135
+	 *
2136
+	 * @var string $plural
2137
+	 * eg 'Dollars'
2138
+	 */
2139
+	public $plural;
2140
+
2141
+	/**
2142
+	 * currency sign
2143
+	 *
2144
+	 * @var string $sign
2145
+	 * eg '$'
2146
+	 */
2147
+	public $sign;
2148
+
2149
+	/**
2150
+	 * Whether the currency sign should come before the number or not
2151
+	 *
2152
+	 * @var boolean $sign_b4
2153
+	 */
2154
+	public $sign_b4;
2155
+
2156
+	/**
2157
+	 * How many digits should come after the decimal place
2158
+	 *
2159
+	 * @var int $dec_plc
2160
+	 */
2161
+	public $dec_plc;
2162
+
2163
+	/**
2164
+	 * Symbol to use for decimal mark
2165
+	 *
2166
+	 * @var string $dec_mrk
2167
+	 * eg '.'
2168
+	 */
2169
+	public $dec_mrk;
2170
+
2171
+	/**
2172
+	 * Symbol to use for thousands
2173
+	 *
2174
+	 * @var string $thsnds
2175
+	 * eg ','
2176
+	 */
2177
+	public $thsnds;
2178
+
2179
+
2180
+
2181
+	/**
2182
+	 *    class constructor
2183
+	 *
2184
+	 * @access    public
2185
+	 * @param string $CNT_ISO
2186
+	 * @throws \EE_Error
2187
+	 */
2188
+	public function __construct($CNT_ISO = '')
2189
+	{
2190
+		/** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */
2191
+		$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
2192
+		// get country code from organization settings or use default
2193
+		$ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2194
+				   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2195
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
2196
+			: '';
2197
+		// but override if requested
2198
+		$CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2199
+		// so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists
2200
+		if (
2201
+			! empty($CNT_ISO)
2202
+			&& EE_Maintenance_Mode::instance()->models_can_query()
2203
+			&& $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2204
+		) {
2205
+			// retrieve the country settings from the db, just in case they have been customized
2206
+			$country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2207
+			if ($country instanceof EE_Country) {
2208
+				$this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2209
+				$this->name = $country->currency_name_single();    // Dollar
2210
+				$this->plural = $country->currency_name_plural();    // Dollars
2211
+				$this->sign = $country->currency_sign();            // currency sign: $
2212
+				$this->sign_b4 = $country->currency_sign_before();        // currency sign before or after: $TRUE  or  FALSE$
2213
+				$this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2214
+				$this->dec_mrk = $country->currency_decimal_mark();    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2215
+				$this->thsnds = $country->currency_thousands_separator();    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2216
+			}
2217
+		}
2218
+		// fallback to hardcoded defaults, in case the above failed
2219
+		if (empty($this->code)) {
2220
+			// set default currency settings
2221
+			$this->code = 'USD';    // currency code: USD, CAD, EUR
2222
+			$this->name = __('Dollar', 'event_espresso');    // Dollar
2223
+			$this->plural = __('Dollars', 'event_espresso');    // Dollars
2224
+			$this->sign = '$';    // currency sign: $
2225
+			$this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2226
+			$this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2227
+			$this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2228
+			$this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2229
+		}
2230
+	}
2231
+}
2453 2232
 
2454
-    /**
2455
-     * @return boolean
2456
-     */
2457
-    public function track_invalid_checkout_access()
2458
-    {
2459
-        return $this->track_invalid_checkout_access;
2460
-    }
2461 2233
 
2462 2234
 
2235
+/**
2236
+ * Class for defining what's in the EE_Config relating to registration settings
2237
+ */
2238
+class EE_Registration_Config extends EE_Config_Base
2239
+{
2463 2240
 
2464
-    /**
2465
-     * @param boolean $track_invalid_checkout_access
2466
-     */
2467
-    public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2468
-    {
2469
-        $this->track_invalid_checkout_access = filter_var(
2470
-            $track_invalid_checkout_access,
2471
-            FILTER_VALIDATE_BOOLEAN
2472
-        );
2473
-    }
2241
+	/**
2242
+	 * Default registration status
2243
+	 *
2244
+	 * @var string $default_STS_ID
2245
+	 * eg 'RPP'
2246
+	 */
2247
+	public $default_STS_ID;
2248
+
2249
+
2250
+	/**
2251
+	 * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of
2252
+	 * registrations)
2253
+	 * @var int
2254
+	 */
2255
+	public $default_maximum_number_of_tickets;
2256
+
2257
+
2258
+	/**
2259
+	 * level of validation to apply to email addresses
2260
+	 *
2261
+	 * @var string $email_validation_level
2262
+	 * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2263
+	 */
2264
+	public $email_validation_level;
2265
+
2266
+	/**
2267
+	 *    whether or not to show alternate payment options during the reg process if payment status is pending
2268
+	 *
2269
+	 * @var boolean $show_pending_payment_options
2270
+	 */
2271
+	public $show_pending_payment_options;
2272
+
2273
+	/**
2274
+	 * Whether to skip the registration confirmation page
2275
+	 *
2276
+	 * @var boolean $skip_reg_confirmation
2277
+	 */
2278
+	public $skip_reg_confirmation;
2279
+
2280
+	/**
2281
+	 * an array of SPCO reg steps where:
2282
+	 *        the keys denotes the reg step order
2283
+	 *        each element consists of an array with the following elements:
2284
+	 *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2285
+	 *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2286
+	 *            "slug" => the URL param used to trigger the reg step
2287
+	 *
2288
+	 * @var array $reg_steps
2289
+	 */
2290
+	public $reg_steps;
2291
+
2292
+	/**
2293
+	 * Whether registration confirmation should be the last page of SPCO
2294
+	 *
2295
+	 * @var boolean $reg_confirmation_last
2296
+	 */
2297
+	public $reg_confirmation_last;
2298
+
2299
+	/**
2300
+	 * Whether or not to enable the EE Bot Trap
2301
+	 *
2302
+	 * @var boolean $use_bot_trap
2303
+	 */
2304
+	public $use_bot_trap;
2305
+
2306
+	/**
2307
+	 * Whether or not to encrypt some data sent by the EE Bot Trap
2308
+	 *
2309
+	 * @var boolean $use_encryption
2310
+	 */
2311
+	public $use_encryption;
2312
+
2313
+	/**
2314
+	 * Whether or not to use ReCaptcha
2315
+	 *
2316
+	 * @var boolean $use_captcha
2317
+	 */
2318
+	public $use_captcha;
2319
+
2320
+	/**
2321
+	 * ReCaptcha Theme
2322
+	 *
2323
+	 * @var string $recaptcha_theme
2324
+	 *    options: 'dark', 'light', 'invisible'
2325
+	 */
2326
+	public $recaptcha_theme;
2327
+
2328
+	/**
2329
+	 * ReCaptcha Badge - determines the position of the reCAPTCHA badge if using Invisible ReCaptcha.
2330
+	 *
2331
+	 * @var string $recaptcha_badge
2332
+	 *    options: 'bottomright', 'bottomleft', 'inline'
2333
+	 */
2334
+	public $recaptcha_badge;
2335
+
2336
+	/**
2337
+	 * ReCaptcha Type
2338
+	 *
2339
+	 * @var string $recaptcha_type
2340
+	 *    options: 'audio', 'image'
2341
+	 */
2342
+	public $recaptcha_type;
2343
+
2344
+	/**
2345
+	 * ReCaptcha language
2346
+	 *
2347
+	 * @var string $recaptcha_language
2348
+	 * eg 'en'
2349
+	 */
2350
+	public $recaptcha_language;
2351
+
2352
+	/**
2353
+	 * ReCaptcha public key
2354
+	 *
2355
+	 * @var string $recaptcha_publickey
2356
+	 */
2357
+	public $recaptcha_publickey;
2358
+
2359
+	/**
2360
+	 * ReCaptcha private key
2361
+	 *
2362
+	 * @var string $recaptcha_privatekey
2363
+	 */
2364
+	public $recaptcha_privatekey;
2365
+
2366
+	/**
2367
+	 * array of form names protected by ReCaptcha
2368
+	 *
2369
+	 * @var array $recaptcha_protected_forms
2370
+	 */
2371
+	public $recaptcha_protected_forms;
2372
+
2373
+	/**
2374
+	 * ReCaptcha width
2375
+	 *
2376
+	 * @var int $recaptcha_width
2377
+	 * @deprecated
2378
+	 */
2379
+	public $recaptcha_width;
2380
+
2381
+	/**
2382
+	 * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2383
+	 *
2384
+	 * @var boolean $track_invalid_checkout_access
2385
+	 */
2386
+	protected $track_invalid_checkout_access = true;
2387
+
2388
+
2389
+
2390
+	/**
2391
+	 *    class constructor
2392
+	 *
2393
+	 * @access    public
2394
+	 */
2395
+	public function __construct()
2396
+	{
2397
+		// set default registration settings
2398
+		$this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2399
+		$this->email_validation_level = 'wp_default';
2400
+		$this->show_pending_payment_options = true;
2401
+		$this->skip_reg_confirmation = false;
2402
+		$this->reg_steps = array();
2403
+		$this->reg_confirmation_last = false;
2404
+		$this->use_bot_trap = true;
2405
+		$this->use_encryption = true;
2406
+		$this->use_captcha = false;
2407
+		$this->recaptcha_theme = 'light';
2408
+		$this->recaptcha_badge = 'bottomleft';
2409
+		$this->recaptcha_type = 'image';
2410
+		$this->recaptcha_language = 'en';
2411
+		$this->recaptcha_publickey = null;
2412
+		$this->recaptcha_privatekey = null;
2413
+		$this->recaptcha_protected_forms = array();
2414
+		$this->recaptcha_width = 500;
2415
+		$this->default_maximum_number_of_tickets = 10;
2416
+	}
2417
+
2418
+
2419
+
2420
+	/**
2421
+	 * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2422
+	 *
2423
+	 * @since 4.8.8.rc.019
2424
+	 */
2425
+	public function do_hooks()
2426
+	{
2427
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2428
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event'));
2429
+	}
2430
+
2431
+
2432
+
2433
+	/**
2434
+	 * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_default_registration_status
2435
+	 * field matches the config setting for default_STS_ID.
2436
+	 */
2437
+	public function set_default_reg_status_on_EEM_Event()
2438
+	{
2439
+		EEM_Event::set_default_reg_status($this->default_STS_ID);
2440
+	}
2441
+
2442
+
2443
+	/**
2444
+	 * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field
2445
+	 * for Events matches the config setting for default_maximum_number_of_tickets
2446
+	 */
2447
+	public function set_default_max_ticket_on_EEM_Event()
2448
+	{
2449
+		EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets);
2450
+	}
2451
+
2452
+
2453
+
2454
+	/**
2455
+	 * @return boolean
2456
+	 */
2457
+	public function track_invalid_checkout_access()
2458
+	{
2459
+		return $this->track_invalid_checkout_access;
2460
+	}
2461
+
2462
+
2463
+
2464
+	/**
2465
+	 * @param boolean $track_invalid_checkout_access
2466
+	 */
2467
+	public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2468
+	{
2469
+		$this->track_invalid_checkout_access = filter_var(
2470
+			$track_invalid_checkout_access,
2471
+			FILTER_VALIDATE_BOOLEAN
2472
+		);
2473
+	}
2474 2474
 
2475 2475
 
2476 2476
 
@@ -2484,160 +2484,160 @@  discard block
 block discarded – undo
2484 2484
 class EE_Admin_Config extends EE_Config_Base
2485 2485
 {
2486 2486
 
2487
-    /**
2488
-     * @var boolean $use_personnel_manager
2489
-     */
2490
-    public $use_personnel_manager;
2491
-
2492
-    /**
2493
-     * @var boolean $use_dashboard_widget
2494
-     */
2495
-    public $use_dashboard_widget;
2496
-
2497
-    /**
2498
-     * @var int $events_in_dashboard
2499
-     */
2500
-    public $events_in_dashboard;
2501
-
2502
-    /**
2503
-     * @var boolean $use_event_timezones
2504
-     */
2505
-    public $use_event_timezones;
2506
-
2507
-    /**
2508
-     * @var boolean $use_full_logging
2509
-     */
2510
-    public $use_full_logging;
2511
-
2512
-    /**
2513
-     * @var string $log_file_name
2514
-     */
2515
-    public $log_file_name;
2516
-
2517
-    /**
2518
-     * @var string $debug_file_name
2519
-     */
2520
-    public $debug_file_name;
2521
-
2522
-    /**
2523
-     * @var boolean $use_remote_logging
2524
-     */
2525
-    public $use_remote_logging;
2526
-
2527
-    /**
2528
-     * @var string $remote_logging_url
2529
-     */
2530
-    public $remote_logging_url;
2531
-
2532
-    /**
2533
-     * @var boolean $show_reg_footer
2534
-     */
2535
-    public $show_reg_footer;
2536
-
2537
-    /**
2538
-     * @var string $affiliate_id
2539
-     */
2540
-    public $affiliate_id;
2541
-
2542
-    /**
2543
-     * help tours on or off (global setting)
2544
-     *
2545
-     * @var boolean
2546
-     */
2547
-    public $help_tour_activation;
2548
-
2549
-    /**
2550
-     * adds extra layer of encoding to session data to prevent serialization errors
2551
-     * but is incompatible with some server configuration errors
2552
-     * if you get "500 internal server errors" during registration, try turning this on
2553
-     * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2554
-     *
2555
-     * @var boolean $encode_session_data
2556
-     */
2557
-    private $encode_session_data = false;
2558
-
2559
-
2560
-
2561
-    /**
2562
-     *    class constructor
2563
-     *
2564
-     * @access    public
2565
-     */
2566
-    public function __construct()
2567
-    {
2568
-        // set default general admin settings
2569
-        $this->use_personnel_manager = true;
2570
-        $this->use_dashboard_widget = true;
2571
-        $this->events_in_dashboard = 30;
2572
-        $this->use_event_timezones = false;
2573
-        $this->use_full_logging = false;
2574
-        $this->use_remote_logging = false;
2575
-        $this->remote_logging_url = null;
2576
-        $this->show_reg_footer = true;
2577
-        $this->affiliate_id = 'default';
2578
-        $this->help_tour_activation = true;
2579
-        $this->encode_session_data = false;
2580
-    }
2581
-
2582
-
2583
-
2584
-    /**
2585
-     * @param bool $reset
2586
-     * @return string
2587
-     */
2588
-    public function log_file_name($reset = false)
2589
-    {
2590
-        if (empty($this->log_file_name) || $reset) {
2591
-            $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2592
-            EE_Config::instance()->update_espresso_config(false, false);
2593
-        }
2594
-        return $this->log_file_name;
2595
-    }
2596
-
2597
-
2598
-
2599
-    /**
2600
-     * @param bool $reset
2601
-     * @return string
2602
-     */
2603
-    public function debug_file_name($reset = false)
2604
-    {
2605
-        if (empty($this->debug_file_name) || $reset) {
2606
-            $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2607
-            EE_Config::instance()->update_espresso_config(false, false);
2608
-        }
2609
-        return $this->debug_file_name;
2610
-    }
2611
-
2612
-
2613
-
2614
-    /**
2615
-     * @return string
2616
-     */
2617
-    public function affiliate_id()
2618
-    {
2619
-        return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2620
-    }
2621
-
2622
-
2623
-
2624
-    /**
2625
-     * @return boolean
2626
-     */
2627
-    public function encode_session_data()
2628
-    {
2629
-        return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2630
-    }
2631
-
2632
-
2633
-
2634
-    /**
2635
-     * @param boolean $encode_session_data
2636
-     */
2637
-    public function set_encode_session_data($encode_session_data)
2638
-    {
2639
-        $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2640
-    }
2487
+	/**
2488
+	 * @var boolean $use_personnel_manager
2489
+	 */
2490
+	public $use_personnel_manager;
2491
+
2492
+	/**
2493
+	 * @var boolean $use_dashboard_widget
2494
+	 */
2495
+	public $use_dashboard_widget;
2496
+
2497
+	/**
2498
+	 * @var int $events_in_dashboard
2499
+	 */
2500
+	public $events_in_dashboard;
2501
+
2502
+	/**
2503
+	 * @var boolean $use_event_timezones
2504
+	 */
2505
+	public $use_event_timezones;
2506
+
2507
+	/**
2508
+	 * @var boolean $use_full_logging
2509
+	 */
2510
+	public $use_full_logging;
2511
+
2512
+	/**
2513
+	 * @var string $log_file_name
2514
+	 */
2515
+	public $log_file_name;
2516
+
2517
+	/**
2518
+	 * @var string $debug_file_name
2519
+	 */
2520
+	public $debug_file_name;
2521
+
2522
+	/**
2523
+	 * @var boolean $use_remote_logging
2524
+	 */
2525
+	public $use_remote_logging;
2526
+
2527
+	/**
2528
+	 * @var string $remote_logging_url
2529
+	 */
2530
+	public $remote_logging_url;
2531
+
2532
+	/**
2533
+	 * @var boolean $show_reg_footer
2534
+	 */
2535
+	public $show_reg_footer;
2536
+
2537
+	/**
2538
+	 * @var string $affiliate_id
2539
+	 */
2540
+	public $affiliate_id;
2541
+
2542
+	/**
2543
+	 * help tours on or off (global setting)
2544
+	 *
2545
+	 * @var boolean
2546
+	 */
2547
+	public $help_tour_activation;
2548
+
2549
+	/**
2550
+	 * adds extra layer of encoding to session data to prevent serialization errors
2551
+	 * but is incompatible with some server configuration errors
2552
+	 * if you get "500 internal server errors" during registration, try turning this on
2553
+	 * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2554
+	 *
2555
+	 * @var boolean $encode_session_data
2556
+	 */
2557
+	private $encode_session_data = false;
2558
+
2559
+
2560
+
2561
+	/**
2562
+	 *    class constructor
2563
+	 *
2564
+	 * @access    public
2565
+	 */
2566
+	public function __construct()
2567
+	{
2568
+		// set default general admin settings
2569
+		$this->use_personnel_manager = true;
2570
+		$this->use_dashboard_widget = true;
2571
+		$this->events_in_dashboard = 30;
2572
+		$this->use_event_timezones = false;
2573
+		$this->use_full_logging = false;
2574
+		$this->use_remote_logging = false;
2575
+		$this->remote_logging_url = null;
2576
+		$this->show_reg_footer = true;
2577
+		$this->affiliate_id = 'default';
2578
+		$this->help_tour_activation = true;
2579
+		$this->encode_session_data = false;
2580
+	}
2581
+
2582
+
2583
+
2584
+	/**
2585
+	 * @param bool $reset
2586
+	 * @return string
2587
+	 */
2588
+	public function log_file_name($reset = false)
2589
+	{
2590
+		if (empty($this->log_file_name) || $reset) {
2591
+			$this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2592
+			EE_Config::instance()->update_espresso_config(false, false);
2593
+		}
2594
+		return $this->log_file_name;
2595
+	}
2596
+
2597
+
2598
+
2599
+	/**
2600
+	 * @param bool $reset
2601
+	 * @return string
2602
+	 */
2603
+	public function debug_file_name($reset = false)
2604
+	{
2605
+		if (empty($this->debug_file_name) || $reset) {
2606
+			$this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2607
+			EE_Config::instance()->update_espresso_config(false, false);
2608
+		}
2609
+		return $this->debug_file_name;
2610
+	}
2611
+
2612
+
2613
+
2614
+	/**
2615
+	 * @return string
2616
+	 */
2617
+	public function affiliate_id()
2618
+	{
2619
+		return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2620
+	}
2621
+
2622
+
2623
+
2624
+	/**
2625
+	 * @return boolean
2626
+	 */
2627
+	public function encode_session_data()
2628
+	{
2629
+		return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2630
+	}
2631
+
2632
+
2633
+
2634
+	/**
2635
+	 * @param boolean $encode_session_data
2636
+	 */
2637
+	public function set_encode_session_data($encode_session_data)
2638
+	{
2639
+		$this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2640
+	}
2641 2641
 
2642 2642
 
2643 2643
 
@@ -2651,71 +2651,71 @@  discard block
 block discarded – undo
2651 2651
 class EE_Template_Config extends EE_Config_Base
2652 2652
 {
2653 2653
 
2654
-    /**
2655
-     * @var boolean $enable_default_style
2656
-     */
2657
-    public $enable_default_style;
2658
-
2659
-    /**
2660
-     * @var string $custom_style_sheet
2661
-     */
2662
-    public $custom_style_sheet;
2663
-
2664
-    /**
2665
-     * @var boolean $display_address_in_regform
2666
-     */
2667
-    public $display_address_in_regform;
2668
-
2669
-    /**
2670
-     * @var int $display_description_on_multi_reg_page
2671
-     */
2672
-    public $display_description_on_multi_reg_page;
2673
-
2674
-    /**
2675
-     * @var boolean $use_custom_templates
2676
-     */
2677
-    public $use_custom_templates;
2678
-
2679
-    /**
2680
-     * @var string $current_espresso_theme
2681
-     */
2682
-    public $current_espresso_theme;
2683
-
2684
-    /**
2685
-     * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2686
-     */
2687
-    public $EED_Ticket_Selector;
2688
-
2689
-    /**
2690
-     * @var EE_Event_Single_Config $EED_Event_Single
2691
-     */
2692
-    public $EED_Event_Single;
2693
-
2694
-    /**
2695
-     * @var EE_Events_Archive_Config $EED_Events_Archive
2696
-     */
2697
-    public $EED_Events_Archive;
2698
-
2699
-
2700
-
2701
-    /**
2702
-     *    class constructor
2703
-     *
2704
-     * @access    public
2705
-     */
2706
-    public function __construct()
2707
-    {
2708
-        // set default template settings
2709
-        $this->enable_default_style = true;
2710
-        $this->custom_style_sheet = null;
2711
-        $this->display_address_in_regform = true;
2712
-        $this->display_description_on_multi_reg_page = false;
2713
-        $this->use_custom_templates = false;
2714
-        $this->current_espresso_theme = 'Espresso_Arabica_2014';
2715
-        $this->EED_Event_Single = null;
2716
-        $this->EED_Events_Archive = null;
2717
-        $this->EED_Ticket_Selector = null;
2718
-    }
2654
+	/**
2655
+	 * @var boolean $enable_default_style
2656
+	 */
2657
+	public $enable_default_style;
2658
+
2659
+	/**
2660
+	 * @var string $custom_style_sheet
2661
+	 */
2662
+	public $custom_style_sheet;
2663
+
2664
+	/**
2665
+	 * @var boolean $display_address_in_regform
2666
+	 */
2667
+	public $display_address_in_regform;
2668
+
2669
+	/**
2670
+	 * @var int $display_description_on_multi_reg_page
2671
+	 */
2672
+	public $display_description_on_multi_reg_page;
2673
+
2674
+	/**
2675
+	 * @var boolean $use_custom_templates
2676
+	 */
2677
+	public $use_custom_templates;
2678
+
2679
+	/**
2680
+	 * @var string $current_espresso_theme
2681
+	 */
2682
+	public $current_espresso_theme;
2683
+
2684
+	/**
2685
+	 * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2686
+	 */
2687
+	public $EED_Ticket_Selector;
2688
+
2689
+	/**
2690
+	 * @var EE_Event_Single_Config $EED_Event_Single
2691
+	 */
2692
+	public $EED_Event_Single;
2693
+
2694
+	/**
2695
+	 * @var EE_Events_Archive_Config $EED_Events_Archive
2696
+	 */
2697
+	public $EED_Events_Archive;
2698
+
2699
+
2700
+
2701
+	/**
2702
+	 *    class constructor
2703
+	 *
2704
+	 * @access    public
2705
+	 */
2706
+	public function __construct()
2707
+	{
2708
+		// set default template settings
2709
+		$this->enable_default_style = true;
2710
+		$this->custom_style_sheet = null;
2711
+		$this->display_address_in_regform = true;
2712
+		$this->display_description_on_multi_reg_page = false;
2713
+		$this->use_custom_templates = false;
2714
+		$this->current_espresso_theme = 'Espresso_Arabica_2014';
2715
+		$this->EED_Event_Single = null;
2716
+		$this->EED_Events_Archive = null;
2717
+		$this->EED_Ticket_Selector = null;
2718
+	}
2719 2719
 
2720 2720
 }
2721 2721
 
@@ -2727,115 +2727,115 @@  discard block
 block discarded – undo
2727 2727
 class EE_Map_Config extends EE_Config_Base
2728 2728
 {
2729 2729
 
2730
-    /**
2731
-     * @var boolean $use_google_maps
2732
-     */
2733
-    public $use_google_maps;
2734
-
2735
-    /**
2736
-     * @var string $api_key
2737
-     */
2738
-    public $google_map_api_key;
2739
-
2740
-    /**
2741
-     * @var int $event_details_map_width
2742
-     */
2743
-    public $event_details_map_width;
2744
-
2745
-    /**
2746
-     * @var int $event_details_map_height
2747
-     */
2748
-    public $event_details_map_height;
2749
-
2750
-    /**
2751
-     * @var int $event_details_map_zoom
2752
-     */
2753
-    public $event_details_map_zoom;
2754
-
2755
-    /**
2756
-     * @var boolean $event_details_display_nav
2757
-     */
2758
-    public $event_details_display_nav;
2759
-
2760
-    /**
2761
-     * @var boolean $event_details_nav_size
2762
-     */
2763
-    public $event_details_nav_size;
2764
-
2765
-    /**
2766
-     * @var string $event_details_control_type
2767
-     */
2768
-    public $event_details_control_type;
2769
-
2770
-    /**
2771
-     * @var string $event_details_map_align
2772
-     */
2773
-    public $event_details_map_align;
2774
-
2775
-    /**
2776
-     * @var int $event_list_map_width
2777
-     */
2778
-    public $event_list_map_width;
2779
-
2780
-    /**
2781
-     * @var int $event_list_map_height
2782
-     */
2783
-    public $event_list_map_height;
2784
-
2785
-    /**
2786
-     * @var int $event_list_map_zoom
2787
-     */
2788
-    public $event_list_map_zoom;
2789
-
2790
-    /**
2791
-     * @var boolean $event_list_display_nav
2792
-     */
2793
-    public $event_list_display_nav;
2794
-
2795
-    /**
2796
-     * @var boolean $event_list_nav_size
2797
-     */
2798
-    public $event_list_nav_size;
2799
-
2800
-    /**
2801
-     * @var string $event_list_control_type
2802
-     */
2803
-    public $event_list_control_type;
2804
-
2805
-    /**
2806
-     * @var string $event_list_map_align
2807
-     */
2808
-    public $event_list_map_align;
2809
-
2810
-
2811
-
2812
-    /**
2813
-     *    class constructor
2814
-     *
2815
-     * @access    public
2816
-     */
2817
-    public function __construct()
2818
-    {
2819
-        // set default map settings
2820
-        $this->use_google_maps = true;
2821
-        $this->google_map_api_key = '';
2822
-        // for event details pages (reg page)
2823
-        $this->event_details_map_width = 585;            // ee_map_width_single
2824
-        $this->event_details_map_height = 362;            // ee_map_height_single
2825
-        $this->event_details_map_zoom = 14;            // ee_map_zoom_single
2826
-        $this->event_details_display_nav = true;            // ee_map_nav_display_single
2827
-        $this->event_details_nav_size = false;            // ee_map_nav_size_single
2828
-        $this->event_details_control_type = 'default';        // ee_map_type_control_single
2829
-        $this->event_details_map_align = 'center';            // ee_map_align_single
2830
-        // for event list pages
2831
-        $this->event_list_map_width = 300;            // ee_map_width
2832
-        $this->event_list_map_height = 185;        // ee_map_height
2833
-        $this->event_list_map_zoom = 12;            // ee_map_zoom
2834
-        $this->event_list_display_nav = false;        // ee_map_nav_display
2835
-        $this->event_list_nav_size = true;            // ee_map_nav_size
2836
-        $this->event_list_control_type = 'dropdown';        // ee_map_type_control
2837
-        $this->event_list_map_align = 'center';            // ee_map_align
2838
-    }
2730
+	/**
2731
+	 * @var boolean $use_google_maps
2732
+	 */
2733
+	public $use_google_maps;
2734
+
2735
+	/**
2736
+	 * @var string $api_key
2737
+	 */
2738
+	public $google_map_api_key;
2739
+
2740
+	/**
2741
+	 * @var int $event_details_map_width
2742
+	 */
2743
+	public $event_details_map_width;
2744
+
2745
+	/**
2746
+	 * @var int $event_details_map_height
2747
+	 */
2748
+	public $event_details_map_height;
2749
+
2750
+	/**
2751
+	 * @var int $event_details_map_zoom
2752
+	 */
2753
+	public $event_details_map_zoom;
2754
+
2755
+	/**
2756
+	 * @var boolean $event_details_display_nav
2757
+	 */
2758
+	public $event_details_display_nav;
2759
+
2760
+	/**
2761
+	 * @var boolean $event_details_nav_size
2762
+	 */
2763
+	public $event_details_nav_size;
2764
+
2765
+	/**
2766
+	 * @var string $event_details_control_type
2767
+	 */
2768
+	public $event_details_control_type;
2769
+
2770
+	/**
2771
+	 * @var string $event_details_map_align
2772
+	 */
2773
+	public $event_details_map_align;
2774
+
2775
+	/**
2776
+	 * @var int $event_list_map_width
2777
+	 */
2778
+	public $event_list_map_width;
2779
+
2780
+	/**
2781
+	 * @var int $event_list_map_height
2782
+	 */
2783
+	public $event_list_map_height;
2784
+
2785
+	/**
2786
+	 * @var int $event_list_map_zoom
2787
+	 */
2788
+	public $event_list_map_zoom;
2789
+
2790
+	/**
2791
+	 * @var boolean $event_list_display_nav
2792
+	 */
2793
+	public $event_list_display_nav;
2794
+
2795
+	/**
2796
+	 * @var boolean $event_list_nav_size
2797
+	 */
2798
+	public $event_list_nav_size;
2799
+
2800
+	/**
2801
+	 * @var string $event_list_control_type
2802
+	 */
2803
+	public $event_list_control_type;
2804
+
2805
+	/**
2806
+	 * @var string $event_list_map_align
2807
+	 */
2808
+	public $event_list_map_align;
2809
+
2810
+
2811
+
2812
+	/**
2813
+	 *    class constructor
2814
+	 *
2815
+	 * @access    public
2816
+	 */
2817
+	public function __construct()
2818
+	{
2819
+		// set default map settings
2820
+		$this->use_google_maps = true;
2821
+		$this->google_map_api_key = '';
2822
+		// for event details pages (reg page)
2823
+		$this->event_details_map_width = 585;            // ee_map_width_single
2824
+		$this->event_details_map_height = 362;            // ee_map_height_single
2825
+		$this->event_details_map_zoom = 14;            // ee_map_zoom_single
2826
+		$this->event_details_display_nav = true;            // ee_map_nav_display_single
2827
+		$this->event_details_nav_size = false;            // ee_map_nav_size_single
2828
+		$this->event_details_control_type = 'default';        // ee_map_type_control_single
2829
+		$this->event_details_map_align = 'center';            // ee_map_align_single
2830
+		// for event list pages
2831
+		$this->event_list_map_width = 300;            // ee_map_width
2832
+		$this->event_list_map_height = 185;        // ee_map_height
2833
+		$this->event_list_map_zoom = 12;            // ee_map_zoom
2834
+		$this->event_list_display_nav = false;        // ee_map_nav_display
2835
+		$this->event_list_nav_size = true;            // ee_map_nav_size
2836
+		$this->event_list_control_type = 'dropdown';        // ee_map_type_control
2837
+		$this->event_list_map_align = 'center';            // ee_map_align
2838
+	}
2839 2839
 
2840 2840
 }
2841 2841
 
@@ -2847,47 +2847,47 @@  discard block
 block discarded – undo
2847 2847
 class EE_Events_Archive_Config extends EE_Config_Base
2848 2848
 {
2849 2849
 
2850
-    public $display_status_banner;
2850
+	public $display_status_banner;
2851 2851
 
2852
-    public $display_description;
2852
+	public $display_description;
2853 2853
 
2854
-    public $display_ticket_selector;
2854
+	public $display_ticket_selector;
2855 2855
 
2856
-    public $display_datetimes;
2856
+	public $display_datetimes;
2857 2857
 
2858
-    public $display_venue;
2858
+	public $display_venue;
2859 2859
 
2860
-    public $display_expired_events;
2860
+	public $display_expired_events;
2861 2861
 
2862
-    public $use_sortable_display_order;
2862
+	public $use_sortable_display_order;
2863 2863
 
2864
-    public $display_order_tickets;
2864
+	public $display_order_tickets;
2865 2865
 
2866
-    public $display_order_datetimes;
2866
+	public $display_order_datetimes;
2867 2867
 
2868
-    public $display_order_event;
2868
+	public $display_order_event;
2869 2869
 
2870
-    public $display_order_venue;
2870
+	public $display_order_venue;
2871 2871
 
2872 2872
 
2873 2873
 
2874
-    /**
2875
-     *    class constructor
2876
-     */
2877
-    public function __construct()
2878
-    {
2879
-        $this->display_status_banner = 0;
2880
-        $this->display_description = 1;
2881
-        $this->display_ticket_selector = 0;
2882
-        $this->display_datetimes = 1;
2883
-        $this->display_venue = 0;
2884
-        $this->display_expired_events = 0;
2885
-        $this->use_sortable_display_order = false;
2886
-        $this->display_order_tickets = 100;
2887
-        $this->display_order_datetimes = 110;
2888
-        $this->display_order_event = 120;
2889
-        $this->display_order_venue = 130;
2890
-    }
2874
+	/**
2875
+	 *    class constructor
2876
+	 */
2877
+	public function __construct()
2878
+	{
2879
+		$this->display_status_banner = 0;
2880
+		$this->display_description = 1;
2881
+		$this->display_ticket_selector = 0;
2882
+		$this->display_datetimes = 1;
2883
+		$this->display_venue = 0;
2884
+		$this->display_expired_events = 0;
2885
+		$this->use_sortable_display_order = false;
2886
+		$this->display_order_tickets = 100;
2887
+		$this->display_order_datetimes = 110;
2888
+		$this->display_order_event = 120;
2889
+		$this->display_order_venue = 130;
2890
+	}
2891 2891
 }
2892 2892
 
2893 2893
 
@@ -2898,35 +2898,35 @@  discard block
 block discarded – undo
2898 2898
 class EE_Event_Single_Config extends EE_Config_Base
2899 2899
 {
2900 2900
 
2901
-    public $display_status_banner_single;
2901
+	public $display_status_banner_single;
2902 2902
 
2903
-    public $display_venue;
2903
+	public $display_venue;
2904 2904
 
2905
-    public $use_sortable_display_order;
2905
+	public $use_sortable_display_order;
2906 2906
 
2907
-    public $display_order_tickets;
2907
+	public $display_order_tickets;
2908 2908
 
2909
-    public $display_order_datetimes;
2909
+	public $display_order_datetimes;
2910 2910
 
2911
-    public $display_order_event;
2911
+	public $display_order_event;
2912 2912
 
2913
-    public $display_order_venue;
2913
+	public $display_order_venue;
2914 2914
 
2915 2915
 
2916 2916
 
2917
-    /**
2918
-     *    class constructor
2919
-     */
2920
-    public function __construct()
2921
-    {
2922
-        $this->display_status_banner_single = 0;
2923
-        $this->display_venue = 1;
2924
-        $this->use_sortable_display_order = false;
2925
-        $this->display_order_tickets = 100;
2926
-        $this->display_order_datetimes = 110;
2927
-        $this->display_order_event = 120;
2928
-        $this->display_order_venue = 130;
2929
-    }
2917
+	/**
2918
+	 *    class constructor
2919
+	 */
2920
+	public function __construct()
2921
+	{
2922
+		$this->display_status_banner_single = 0;
2923
+		$this->display_venue = 1;
2924
+		$this->use_sortable_display_order = false;
2925
+		$this->display_order_tickets = 100;
2926
+		$this->display_order_datetimes = 110;
2927
+		$this->display_order_event = 120;
2928
+		$this->display_order_venue = 130;
2929
+	}
2930 2930
 }
2931 2931
 
2932 2932
 
@@ -2937,152 +2937,152 @@  discard block
 block discarded – undo
2937 2937
 class EE_Ticket_Selector_Config extends EE_Config_Base
2938 2938
 {
2939 2939
 
2940
-    /**
2941
-     * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
2942
-     */
2943
-    const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
2944
-
2945
-    /**
2946
-     * constant to indicate that a datetime selector should only be shown for ticket selectors
2947
-     * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
2948
-     */
2949
-    const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
2950
-
2951
-    /**
2952
-     * @var boolean $show_ticket_sale_columns
2953
-     */
2954
-    public $show_ticket_sale_columns;
2955
-
2956
-    /**
2957
-     * @var boolean $show_ticket_details
2958
-     */
2959
-    public $show_ticket_details;
2960
-
2961
-    /**
2962
-     * @var boolean $show_expired_tickets
2963
-     */
2964
-    public $show_expired_tickets;
2965
-
2966
-    /**
2967
-     * whether or not to display a dropdown box populated with event datetimes
2968
-     * that toggles which tickets are displayed for a ticket selector.
2969
-     * uses one of the *_DATETIME_SELECTOR constants defined above
2970
-     *
2971
-     * @var string $show_datetime_selector
2972
-     */
2973
-    private $show_datetime_selector = 'no_datetime_selector';
2974
-
2975
-    /**
2976
-     * the number of datetimes an event has to have before conditionally displaying a datetime selector
2977
-     *
2978
-     * @var int $datetime_selector_threshold
2979
-     */
2980
-    private $datetime_selector_threshold = 3;
2981
-
2982
-
2983
-
2984
-    /**
2985
-     *    class constructor
2986
-     */
2987
-    public function __construct()
2988
-    {
2989
-        $this->show_ticket_sale_columns = true;
2990
-        $this->show_ticket_details = true;
2991
-        $this->show_expired_tickets = true;
2992
-        $this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
2993
-        $this->datetime_selector_threshold = 3;
2994
-    }
2995
-
2996
-
2997
-
2998
-    /**
2999
-     * returns true if a datetime selector should be displayed
3000
-     *
3001
-     * @param array $datetimes
3002
-     * @return bool
3003
-     */
3004
-    public function showDatetimeSelector(array $datetimes)
3005
-    {
3006
-        // if the settings are NOT: don't show OR below threshold, THEN active = true
3007
-        return ! (
3008
-            $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
3009
-            || (
3010
-                $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
3011
-                && count($datetimes) < $this->getDatetimeSelectorThreshold()
3012
-            )
3013
-        );
3014
-    }
3015
-
3016
-
3017
-
3018
-    /**
3019
-     * @return string
3020
-     */
3021
-    public function getShowDatetimeSelector()
3022
-    {
3023
-        return $this->show_datetime_selector;
3024
-    }
3025
-
3026
-
3027
-
3028
-    /**
3029
-     * @param bool $keys_only
3030
-     * @return array
3031
-     */
3032
-    public function getShowDatetimeSelectorOptions($keys_only = true)
3033
-    {
3034
-        return $keys_only
3035
-            ? array(
3036
-                \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
3037
-                \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
3038
-            )
3039
-            : array(
3040
-                \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
3041
-                    'Do not show date & time filter', 'event_espresso'
3042
-                ),
3043
-                \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3044
-                    'Maybe show date & time filter', 'event_espresso'
3045
-                ),
3046
-            );
3047
-    }
3048
-
3049
-
3050
-
3051
-    /**
3052
-     * @param string $show_datetime_selector
3053
-     */
3054
-    public function setShowDatetimeSelector($show_datetime_selector)
3055
-    {
3056
-        $this->show_datetime_selector = in_array(
3057
-            $show_datetime_selector,
3058
-            $this->getShowDatetimeSelectorOptions(),
3059
-            true
3060
-        )
3061
-            ? $show_datetime_selector
3062
-            : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3063
-    }
3064
-
3065
-
3066
-
3067
-    /**
3068
-     * @return int
3069
-     */
3070
-    public function getDatetimeSelectorThreshold()
3071
-    {
3072
-        return $this->datetime_selector_threshold;
3073
-    }
3074
-
3075
-
3076
-
3077
-
3078
-    /**
3079
-     * @param int $datetime_selector_threshold
3080
-     */
3081
-    public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3082
-    {
3083
-        $datetime_selector_threshold = absint($datetime_selector_threshold);
3084
-        $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3085
-    }
2940
+	/**
2941
+	 * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
2942
+	 */
2943
+	const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
2944
+
2945
+	/**
2946
+	 * constant to indicate that a datetime selector should only be shown for ticket selectors
2947
+	 * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
2948
+	 */
2949
+	const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
2950
+
2951
+	/**
2952
+	 * @var boolean $show_ticket_sale_columns
2953
+	 */
2954
+	public $show_ticket_sale_columns;
2955
+
2956
+	/**
2957
+	 * @var boolean $show_ticket_details
2958
+	 */
2959
+	public $show_ticket_details;
2960
+
2961
+	/**
2962
+	 * @var boolean $show_expired_tickets
2963
+	 */
2964
+	public $show_expired_tickets;
2965
+
2966
+	/**
2967
+	 * whether or not to display a dropdown box populated with event datetimes
2968
+	 * that toggles which tickets are displayed for a ticket selector.
2969
+	 * uses one of the *_DATETIME_SELECTOR constants defined above
2970
+	 *
2971
+	 * @var string $show_datetime_selector
2972
+	 */
2973
+	private $show_datetime_selector = 'no_datetime_selector';
2974
+
2975
+	/**
2976
+	 * the number of datetimes an event has to have before conditionally displaying a datetime selector
2977
+	 *
2978
+	 * @var int $datetime_selector_threshold
2979
+	 */
2980
+	private $datetime_selector_threshold = 3;
2981
+
2982
+
2983
+
2984
+	/**
2985
+	 *    class constructor
2986
+	 */
2987
+	public function __construct()
2988
+	{
2989
+		$this->show_ticket_sale_columns = true;
2990
+		$this->show_ticket_details = true;
2991
+		$this->show_expired_tickets = true;
2992
+		$this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
2993
+		$this->datetime_selector_threshold = 3;
2994
+	}
2995
+
2996
+
2997
+
2998
+	/**
2999
+	 * returns true if a datetime selector should be displayed
3000
+	 *
3001
+	 * @param array $datetimes
3002
+	 * @return bool
3003
+	 */
3004
+	public function showDatetimeSelector(array $datetimes)
3005
+	{
3006
+		// if the settings are NOT: don't show OR below threshold, THEN active = true
3007
+		return ! (
3008
+			$this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
3009
+			|| (
3010
+				$this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
3011
+				&& count($datetimes) < $this->getDatetimeSelectorThreshold()
3012
+			)
3013
+		);
3014
+	}
3015
+
3016
+
3017
+
3018
+	/**
3019
+	 * @return string
3020
+	 */
3021
+	public function getShowDatetimeSelector()
3022
+	{
3023
+		return $this->show_datetime_selector;
3024
+	}
3025
+
3026
+
3027
+
3028
+	/**
3029
+	 * @param bool $keys_only
3030
+	 * @return array
3031
+	 */
3032
+	public function getShowDatetimeSelectorOptions($keys_only = true)
3033
+	{
3034
+		return $keys_only
3035
+			? array(
3036
+				\EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
3037
+				\EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
3038
+			)
3039
+			: array(
3040
+				\EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
3041
+					'Do not show date & time filter', 'event_espresso'
3042
+				),
3043
+				\EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3044
+					'Maybe show date & time filter', 'event_espresso'
3045
+				),
3046
+			);
3047
+	}
3048
+
3049
+
3050
+
3051
+	/**
3052
+	 * @param string $show_datetime_selector
3053
+	 */
3054
+	public function setShowDatetimeSelector($show_datetime_selector)
3055
+	{
3056
+		$this->show_datetime_selector = in_array(
3057
+			$show_datetime_selector,
3058
+			$this->getShowDatetimeSelectorOptions(),
3059
+			true
3060
+		)
3061
+			? $show_datetime_selector
3062
+			: \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3063
+	}
3064
+
3065
+
3066
+
3067
+	/**
3068
+	 * @return int
3069
+	 */
3070
+	public function getDatetimeSelectorThreshold()
3071
+	{
3072
+		return $this->datetime_selector_threshold;
3073
+	}
3074
+
3075
+
3076
+
3077
+
3078
+	/**
3079
+	 * @param int $datetime_selector_threshold
3080
+	 */
3081
+	public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3082
+	{
3083
+		$datetime_selector_threshold = absint($datetime_selector_threshold);
3084
+		$this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3085
+	}
3086 3086
 
3087 3087
 
3088 3088
 
@@ -3100,85 +3100,85 @@  discard block
 block discarded – undo
3100 3100
 class EE_Environment_Config extends EE_Config_Base
3101 3101
 {
3102 3102
 
3103
-    /**
3104
-     * Hold any php environment variables that we want to track.
3105
-     *
3106
-     * @var stdClass;
3107
-     */
3108
-    public $php;
3109
-
3110
-
3111
-
3112
-    /**
3113
-     *    constructor
3114
-     */
3115
-    public function __construct()
3116
-    {
3117
-        $this->php = new stdClass();
3118
-        $this->_set_php_values();
3119
-    }
3120
-
3121
-
3122
-
3123
-    /**
3124
-     * This sets the php environment variables.
3125
-     *
3126
-     * @since 4.4.0
3127
-     * @return void
3128
-     */
3129
-    protected function _set_php_values()
3130
-    {
3131
-        $this->php->max_input_vars = ini_get('max_input_vars');
3132
-        $this->php->version = phpversion();
3133
-    }
3134
-
3135
-
3136
-
3137
-    /**
3138
-     * helper method for determining whether input_count is
3139
-     * reaching the potential maximum the server can handle
3140
-     * according to max_input_vars
3141
-     *
3142
-     * @param int   $input_count the count of input vars.
3143
-     * @return array {
3144
-     *                           An array that represents whether available space and if no available space the error
3145
-     *                           message.
3146
-     * @type bool   $has_space   whether more inputs can be added.
3147
-     * @type string $msg         Any message to be displayed.
3148
-     *                           }
3149
-     */
3150
-    public function max_input_vars_limit_check($input_count = 0)
3151
-    {
3152
-        if (! empty($this->php->max_input_vars)
3153
-            && ($input_count >= $this->php->max_input_vars)
3154
-            && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)
3155
-        ) {
3156
-            return sprintf(
3157
-                __(
3158
-                    'The maximum number of inputs on this page has been exceeded.  You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.',
3159
-                    'event_espresso'
3160
-                ),
3161
-                '<br>',
3162
-                $input_count,
3163
-                $this->php->max_input_vars
3164
-            );
3165
-        } else {
3166
-            return '';
3167
-        }
3168
-    }
3169
-
3170
-
3171
-
3172
-    /**
3173
-     * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3174
-     *
3175
-     * @since 4.4.1
3176
-     * @return void
3177
-     */
3178
-    public function recheck_values()
3179
-    {
3180
-        $this->_set_php_values();
3181
-    }
3103
+	/**
3104
+	 * Hold any php environment variables that we want to track.
3105
+	 *
3106
+	 * @var stdClass;
3107
+	 */
3108
+	public $php;
3109
+
3110
+
3111
+
3112
+	/**
3113
+	 *    constructor
3114
+	 */
3115
+	public function __construct()
3116
+	{
3117
+		$this->php = new stdClass();
3118
+		$this->_set_php_values();
3119
+	}
3120
+
3121
+
3122
+
3123
+	/**
3124
+	 * This sets the php environment variables.
3125
+	 *
3126
+	 * @since 4.4.0
3127
+	 * @return void
3128
+	 */
3129
+	protected function _set_php_values()
3130
+	{
3131
+		$this->php->max_input_vars = ini_get('max_input_vars');
3132
+		$this->php->version = phpversion();
3133
+	}
3134
+
3135
+
3136
+
3137
+	/**
3138
+	 * helper method for determining whether input_count is
3139
+	 * reaching the potential maximum the server can handle
3140
+	 * according to max_input_vars
3141
+	 *
3142
+	 * @param int   $input_count the count of input vars.
3143
+	 * @return array {
3144
+	 *                           An array that represents whether available space and if no available space the error
3145
+	 *                           message.
3146
+	 * @type bool   $has_space   whether more inputs can be added.
3147
+	 * @type string $msg         Any message to be displayed.
3148
+	 *                           }
3149
+	 */
3150
+	public function max_input_vars_limit_check($input_count = 0)
3151
+	{
3152
+		if (! empty($this->php->max_input_vars)
3153
+			&& ($input_count >= $this->php->max_input_vars)
3154
+			&& (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)
3155
+		) {
3156
+			return sprintf(
3157
+				__(
3158
+					'The maximum number of inputs on this page has been exceeded.  You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.',
3159
+					'event_espresso'
3160
+				),
3161
+				'<br>',
3162
+				$input_count,
3163
+				$this->php->max_input_vars
3164
+			);
3165
+		} else {
3166
+			return '';
3167
+		}
3168
+	}
3169
+
3170
+
3171
+
3172
+	/**
3173
+	 * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3174
+	 *
3175
+	 * @since 4.4.1
3176
+	 * @return void
3177
+	 */
3178
+	public function recheck_values()
3179
+	{
3180
+		$this->_set_php_values();
3181
+	}
3182 3182
 
3183 3183
 
3184 3184
 
@@ -3196,22 +3196,22 @@  discard block
 block discarded – undo
3196 3196
 class EE_Tax_Config extends EE_Config_Base
3197 3197
 {
3198 3198
 
3199
-    /*
3199
+	/*
3200 3200
      * flag to indicate whether or not to display ticket prices with the taxes included
3201 3201
      *
3202 3202
      * @var boolean $prices_displayed_including_taxes
3203 3203
      */
3204
-    public $prices_displayed_including_taxes;
3204
+	public $prices_displayed_including_taxes;
3205 3205
 
3206 3206
 
3207 3207
 
3208
-    /**
3209
-     *    class constructor
3210
-     */
3211
-    public function __construct()
3212
-    {
3213
-        $this->prices_displayed_including_taxes = true;
3214
-    }
3208
+	/**
3209
+	 *    class constructor
3210
+	 */
3211
+	public function __construct()
3212
+	{
3213
+		$this->prices_displayed_including_taxes = true;
3214
+	}
3215 3215
 }
3216 3216
 
3217 3217
 
@@ -3226,17 +3226,17 @@  discard block
 block discarded – undo
3226 3226
 class EE_Messages_Config extends EE_Config_Base
3227 3227
 {
3228 3228
 
3229
-    /**
3230
-     * This is an integer representing the deletion threshold in months for when old messages will get deleted.
3231
-     * A value of 0 represents never deleting.  Default is 0.
3232
-     *
3233
-     * @var integer
3234
-     */
3235
-    public $delete_threshold;
3236
-
3237
-    public function __construct() {
3238
-        $this->delete_threshold = 0;
3239
-    }
3229
+	/**
3230
+	 * This is an integer representing the deletion threshold in months for when old messages will get deleted.
3231
+	 * A value of 0 represents never deleting.  Default is 0.
3232
+	 *
3233
+	 * @var integer
3234
+	 */
3235
+	public $delete_threshold;
3236
+
3237
+	public function __construct() {
3238
+		$this->delete_threshold = 0;
3239
+	}
3240 3240
 }
3241 3241
 
3242 3242
 
@@ -3248,34 +3248,34 @@  discard block
 block discarded – undo
3248 3248
 class EE_Gateway_Config extends EE_Config_Base
3249 3249
 {
3250 3250
 
3251
-    /**
3252
-     * Array with keys that are payment gateways slugs, and values are arrays
3253
-     * with any config info the gateway wants to store
3254
-     *
3255
-     * @var array
3256
-     */
3257
-    public $payment_settings;
3258
-
3259
-    /**
3260
-     * Where keys are gateway slugs, and values are booleans indicating whether or not
3261
-     * the gateway is stored in the uploads directory
3262
-     *
3263
-     * @var array
3264
-     */
3265
-    public $active_gateways;
3266
-
3267
-
3268
-
3269
-    /**
3270
-     *    class constructor
3271
-     *
3272
-     * @deprecated
3273
-     */
3274
-    public function __construct()
3275
-    {
3276
-        $this->payment_settings = array();
3277
-        $this->active_gateways = array('Invoice' => false);
3278
-    }
3251
+	/**
3252
+	 * Array with keys that are payment gateways slugs, and values are arrays
3253
+	 * with any config info the gateway wants to store
3254
+	 *
3255
+	 * @var array
3256
+	 */
3257
+	public $payment_settings;
3258
+
3259
+	/**
3260
+	 * Where keys are gateway slugs, and values are booleans indicating whether or not
3261
+	 * the gateway is stored in the uploads directory
3262
+	 *
3263
+	 * @var array
3264
+	 */
3265
+	public $active_gateways;
3266
+
3267
+
3268
+
3269
+	/**
3270
+	 *    class constructor
3271
+	 *
3272
+	 * @deprecated
3273
+	 */
3274
+	public function __construct()
3275
+	{
3276
+		$this->payment_settings = array();
3277
+		$this->active_gateways = array('Invoice' => false);
3278
+	}
3279 3279
 }
3280 3280
 
3281 3281
 // End of file EE_Config.core.php
Please login to merge, or discard this patch.