Completed
Branch BUG/aim-no-send-currency (35a1e8)
by
unknown
14:38 queued 27s
created
core/EE_Deprecated.core.php 1 patch
Indentation   +1121 added lines, -1121 removed lines patch added patch discarded remove patch
@@ -37,31 +37,31 @@  discard block
 block discarded – undo
37 37
  * @param string $action_or_filter
38 38
  */
39 39
 function deprecated_espresso_action_or_filter_doing_it_wrong(
40
-    $deprecated_filter,
41
-    $replacement,
42
-    $replacement_location,
43
-    $version_deprecated,
44
-    $version_applies,
45
-    $action_or_filter = 'action'
40
+	$deprecated_filter,
41
+	$replacement,
42
+	$replacement_location,
43
+	$version_deprecated,
44
+	$version_applies,
45
+	$action_or_filter = 'action'
46 46
 ) {
47
-    $action_or_filter = $action_or_filter === 'action'
48
-        ? esc_html__('action', 'event_espresso')
49
-        : esc_html__('filter', 'event_espresso');
50
-    EE_Error::doing_it_wrong(
51
-        $deprecated_filter,
52
-        sprintf(
53
-            __(
54
-                'This %1$s is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new %1$s: %4$s"%2$s" found in "%3$s"',
55
-                'event_espresso'
56
-            ),
57
-            $action_or_filter,
58
-            $replacement,
59
-            $replacement_location,
60
-            '<br />'
61
-        ),
62
-        $version_deprecated,
63
-        $version_applies
64
-    );
47
+	$action_or_filter = $action_or_filter === 'action'
48
+		? esc_html__('action', 'event_espresso')
49
+		: esc_html__('filter', 'event_espresso');
50
+	EE_Error::doing_it_wrong(
51
+		$deprecated_filter,
52
+		sprintf(
53
+			__(
54
+				'This %1$s is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new %1$s: %4$s"%2$s" found in "%3$s"',
55
+				'event_espresso'
56
+			),
57
+			$action_or_filter,
58
+			$replacement,
59
+			$replacement_location,
60
+			'<br />'
61
+		),
62
+		$version_deprecated,
63
+		$version_applies
64
+	);
65 65
 }
66 66
 
67 67
 /**
@@ -73,90 +73,90 @@  discard block
 block discarded – undo
73 73
  */
74 74
 function ee_deprecated__registration_checkout__button_text($submit_button_text, EE_Checkout $checkout)
75 75
 {
76
-    // list of old filters
77
-    $deprecated_filters = array(
78
-        'update_registration_details' => true,
79
-        'process_payment'             => true,
80
-        'finalize_registration'       => true,
81
-        'and_proceed_to_payment'      => true,
82
-        'proceed_to'                  => true,
83
-    );
84
-    // loop thru and call doing_it_wrong() or remove any that aren't being used
85
-    foreach ($deprecated_filters as $deprecated_filter => $on) {
86
-        // was this filter called ?
87
-        if (has_action('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter)) {
88
-            // only display doing_it_wrong() notice to Event Admins during non-AJAX requests
89
-            if (EE_Registry::instance()->CAP->current_user_can(
90
-                    'ee_read_ee',
91
-                    'hide_doing_it_wrong_for_deprecated_SPCO_filter'
92
-                ) && ! defined('DOING_AJAX')) {
93
-                EE_Error::doing_it_wrong(
94
-                    'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter,
95
-                    sprintf(
96
-                        __(
97
-                            'The %1$s filter is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"',
98
-                            'event_espresso'
99
-                        ),
100
-                        'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter,
101
-                        '<br />',
102
-                        'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text',
103
-                        '/modules/single_page_checkout/inc/EE_SPCO_Reg_Step.class.php'
104
-                    ),
105
-                    '4.6.10'
106
-                );
107
-            }
108
-        } else {
109
-            unset($deprecated_filters[ $deprecated_filter ]);
110
-        }
111
-    }
112
-    if (! empty($deprecated_filters)) {
113
-
114
-        if ($checkout->current_step->slug(
115
-            ) == 'attendee_information' && $checkout->revisit && isset($deprecated_filters['update_registration_details'])) {
116
-            $submit_button_text = apply_filters(
117
-                'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details',
118
-                $submit_button_text
119
-            );
120
-        } elseif ($checkout->current_step->slug(
121
-            ) == 'payment_options' && $checkout->revisit && isset($deprecated_filters['process_payment'])) {
122
-            $submit_button_text = apply_filters(
123
-                'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment',
124
-                $submit_button_text
125
-            );
126
-        } elseif ($checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug(
127
-            ) == 'finalize_registration' && isset($deprecated_filters['finalize_registration'])) {
128
-            $submit_button_text = apply_filters(
129
-                'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration',
130
-                $submit_button_text
131
-            );
132
-        }
133
-        if ($checkout->next_step instanceof EE_SPCO_Reg_Step) {
134
-            if ($checkout->payment_required() && $checkout->next_step->slug(
135
-                ) == 'payment_options' && isset($deprecated_filters['and_proceed_to_payment'])) {
136
-                $submit_button_text .= apply_filters(
137
-                    'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment',
138
-                    $submit_button_text
139
-                );
140
-            }
141
-            if ($checkout->next_step->slug(
142
-                ) != 'finalize_registration' && ! $checkout->revisit && isset($deprecated_filters['proceed_to'])) {
143
-                $submit_button_text = apply_filters(
144
-                                          'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to',
145
-                                          $submit_button_text
146
-                                      ) . $checkout->next_step->name();
147
-            }
148
-        }
149
-
150
-    }
151
-    return $submit_button_text;
76
+	// list of old filters
77
+	$deprecated_filters = array(
78
+		'update_registration_details' => true,
79
+		'process_payment'             => true,
80
+		'finalize_registration'       => true,
81
+		'and_proceed_to_payment'      => true,
82
+		'proceed_to'                  => true,
83
+	);
84
+	// loop thru and call doing_it_wrong() or remove any that aren't being used
85
+	foreach ($deprecated_filters as $deprecated_filter => $on) {
86
+		// was this filter called ?
87
+		if (has_action('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter)) {
88
+			// only display doing_it_wrong() notice to Event Admins during non-AJAX requests
89
+			if (EE_Registry::instance()->CAP->current_user_can(
90
+					'ee_read_ee',
91
+					'hide_doing_it_wrong_for_deprecated_SPCO_filter'
92
+				) && ! defined('DOING_AJAX')) {
93
+				EE_Error::doing_it_wrong(
94
+					'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter,
95
+					sprintf(
96
+						__(
97
+							'The %1$s filter is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"',
98
+							'event_espresso'
99
+						),
100
+						'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter,
101
+						'<br />',
102
+						'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text',
103
+						'/modules/single_page_checkout/inc/EE_SPCO_Reg_Step.class.php'
104
+					),
105
+					'4.6.10'
106
+				);
107
+			}
108
+		} else {
109
+			unset($deprecated_filters[ $deprecated_filter ]);
110
+		}
111
+	}
112
+	if (! empty($deprecated_filters)) {
113
+
114
+		if ($checkout->current_step->slug(
115
+			) == 'attendee_information' && $checkout->revisit && isset($deprecated_filters['update_registration_details'])) {
116
+			$submit_button_text = apply_filters(
117
+				'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details',
118
+				$submit_button_text
119
+			);
120
+		} elseif ($checkout->current_step->slug(
121
+			) == 'payment_options' && $checkout->revisit && isset($deprecated_filters['process_payment'])) {
122
+			$submit_button_text = apply_filters(
123
+				'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment',
124
+				$submit_button_text
125
+			);
126
+		} elseif ($checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug(
127
+			) == 'finalize_registration' && isset($deprecated_filters['finalize_registration'])) {
128
+			$submit_button_text = apply_filters(
129
+				'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration',
130
+				$submit_button_text
131
+			);
132
+		}
133
+		if ($checkout->next_step instanceof EE_SPCO_Reg_Step) {
134
+			if ($checkout->payment_required() && $checkout->next_step->slug(
135
+				) == 'payment_options' && isset($deprecated_filters['and_proceed_to_payment'])) {
136
+				$submit_button_text .= apply_filters(
137
+					'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment',
138
+					$submit_button_text
139
+				);
140
+			}
141
+			if ($checkout->next_step->slug(
142
+				) != 'finalize_registration' && ! $checkout->revisit && isset($deprecated_filters['proceed_to'])) {
143
+				$submit_button_text = apply_filters(
144
+										  'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to',
145
+										  $submit_button_text
146
+									  ) . $checkout->next_step->name();
147
+			}
148
+		}
149
+
150
+	}
151
+	return $submit_button_text;
152 152
 
153 153
 }
154 154
 
155 155
 add_filter(
156
-    'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text',
157
-    'ee_deprecated__registration_checkout__button_text',
158
-    10,
159
-    2
156
+	'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text',
157
+	'ee_deprecated__registration_checkout__button_text',
158
+	10,
159
+	2
160 160
 );
161 161
 
162 162
 
@@ -168,54 +168,54 @@  discard block
 block discarded – undo
168 168
  */
169 169
 function ee_deprecated_finalize_transaction(EE_Checkout $checkout, $status_updates)
170 170
 {
171
-    $action_ref = null;
172
-    $action_ref = has_action('AHEE__EE_Transaction__finalize__new_transaction')
173
-        ? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref;
174
-    $action_ref = has_action('AHEE__EE_Transaction__finalize__all_transaction')
175
-        ? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref;
176
-    if ($action_ref) {
177
-
178
-        EE_Error::doing_it_wrong(
179
-            $action_ref,
180
-            sprintf(
181
-                __(
182
-                    'This action is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"',
183
-                    'event_espresso'
184
-                ),
185
-                '<br />',
186
-                '/core/business/EE_Transaction_Processor.class.php',
187
-                'AHEE__EE_Transaction_Processor__finalize',
188
-                'AHEE__EE_Transaction_Processor__manually_update_registration_statuses',
189
-                'AHEE__EE_Transaction_Processor__toggle_registration_statuses_for_default_approved_events',
190
-                'AHEE__EE_Transaction_Processor__toggle_registration_statuses_if_no_monies_owing'
191
-            ),
192
-            '4.6.0'
193
-        );
194
-        switch ($action_ref) {
195
-            case 'AHEE__EE_Transaction__finalize__new_transaction' :
196
-                do_action(
197
-                    'AHEE__EE_Transaction__finalize__new_transaction',
198
-                    $checkout->transaction,
199
-                    $checkout->admin_request
200
-                );
201
-                break;
202
-            case 'AHEE__EE_Transaction__finalize__all_transaction' :
203
-                do_action(
204
-                    'AHEE__EE_Transaction__finalize__new_transaction',
205
-                    $checkout->transaction,
206
-                    array('new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates),
207
-                    $checkout->admin_request
208
-                );
209
-                break;
210
-        }
211
-    }
171
+	$action_ref = null;
172
+	$action_ref = has_action('AHEE__EE_Transaction__finalize__new_transaction')
173
+		? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref;
174
+	$action_ref = has_action('AHEE__EE_Transaction__finalize__all_transaction')
175
+		? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref;
176
+	if ($action_ref) {
177
+
178
+		EE_Error::doing_it_wrong(
179
+			$action_ref,
180
+			sprintf(
181
+				__(
182
+					'This action is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"',
183
+					'event_espresso'
184
+				),
185
+				'<br />',
186
+				'/core/business/EE_Transaction_Processor.class.php',
187
+				'AHEE__EE_Transaction_Processor__finalize',
188
+				'AHEE__EE_Transaction_Processor__manually_update_registration_statuses',
189
+				'AHEE__EE_Transaction_Processor__toggle_registration_statuses_for_default_approved_events',
190
+				'AHEE__EE_Transaction_Processor__toggle_registration_statuses_if_no_monies_owing'
191
+			),
192
+			'4.6.0'
193
+		);
194
+		switch ($action_ref) {
195
+			case 'AHEE__EE_Transaction__finalize__new_transaction' :
196
+				do_action(
197
+					'AHEE__EE_Transaction__finalize__new_transaction',
198
+					$checkout->transaction,
199
+					$checkout->admin_request
200
+				);
201
+				break;
202
+			case 'AHEE__EE_Transaction__finalize__all_transaction' :
203
+				do_action(
204
+					'AHEE__EE_Transaction__finalize__new_transaction',
205
+					$checkout->transaction,
206
+					array('new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates),
207
+					$checkout->admin_request
208
+				);
209
+				break;
210
+		}
211
+	}
212 212
 }
213 213
 
214 214
 add_action(
215
-    'AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed',
216
-    'ee_deprecated_finalize_transaction',
217
-    10,
218
-    2
215
+	'AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed',
216
+	'ee_deprecated_finalize_transaction',
217
+	10,
218
+	2
219 219
 );
220 220
 /**
221 221
  * ee_deprecated_finalize_registration
@@ -224,35 +224,35 @@  discard block
 block discarded – undo
224 224
  */
225 225
 function ee_deprecated_finalize_registration(EE_Registration $registration)
226 226
 {
227
-    $action_ref = has_action('AHEE__EE_Registration__finalize__update_and_new_reg')
228
-        ? 'AHEE__EE_Registration__finalize__update_and_new_reg' : null;
229
-    if ($action_ref) {
230
-        EE_Error::doing_it_wrong(
231
-            $action_ref,
232
-            sprintf(
233
-                __(
234
-                    'This action is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"',
235
-                    'event_espresso'
236
-                ),
237
-                '<br />',
238
-                '/core/business/EE_Registration_Processor.class.php',
239
-                'AHEE__EE_Registration_Processor__trigger_registration_update_notifications'
240
-            ),
241
-            '4.6.0'
242
-        );
243
-        do_action(
244
-            'AHEE__EE_Registration__finalize__update_and_new_reg',
245
-            $registration,
246
-            (is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX))
247
-        );
248
-    }
227
+	$action_ref = has_action('AHEE__EE_Registration__finalize__update_and_new_reg')
228
+		? 'AHEE__EE_Registration__finalize__update_and_new_reg' : null;
229
+	if ($action_ref) {
230
+		EE_Error::doing_it_wrong(
231
+			$action_ref,
232
+			sprintf(
233
+				__(
234
+					'This action is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"',
235
+					'event_espresso'
236
+				),
237
+				'<br />',
238
+				'/core/business/EE_Registration_Processor.class.php',
239
+				'AHEE__EE_Registration_Processor__trigger_registration_update_notifications'
240
+			),
241
+			'4.6.0'
242
+		);
243
+		do_action(
244
+			'AHEE__EE_Registration__finalize__update_and_new_reg',
245
+			$registration,
246
+			(is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX))
247
+		);
248
+	}
249 249
 }
250 250
 
251 251
 add_action(
252
-    'AHEE__EE_Registration_Processor__trigger_registration_update_notifications',
253
-    'ee_deprecated_finalize_registration',
254
-    10,
255
-    1
252
+	'AHEE__EE_Registration_Processor__trigger_registration_update_notifications',
253
+	'ee_deprecated_finalize_registration',
254
+	10,
255
+	1
256 256
 );
257 257
 
258 258
 
@@ -262,44 +262,44 @@  discard block
 block discarded – undo
262 262
  */
263 263
 function ee_deprecated_hooks()
264 264
 {
265
-    /**
266
-     * @var          $hooks       array where keys are hook names, and their values are array{
267
-     * @type string  $version     when deprecated
268
-     * @type string  $alternative saying what to use instead
269
-     * @type boolean $still_works whether or not the hook still works
270
-     *        }
271
-     */
272
-    $hooks = array(
273
-        'AHEE__EE_System___do_setup_validations' => array(
274
-            'version'     => '4.6.0',
275
-            'alternative' => __(
276
-                'Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)',
277
-                'event_espresso'
278
-            ),
279
-            'still_works' => false,
280
-        ),
281
-    );
282
-    foreach ($hooks as $name => $deprecation_info) {
283
-        if (has_action($name)) {
284
-            EE_Error::doing_it_wrong(
285
-                $name,
286
-                sprintf(
287
-                    __('This filter is deprecated. %1$s%2$s', 'event_espresso'),
288
-                    $deprecation_info['still_works'] ? __(
289
-                        'It *may* work as an attempt to build in backwards compatibility.',
290
-                        'event_espresso'
291
-                    ) : __('It has been completely removed.', 'event_espresso'),
292
-                    isset($deprecation_info['alternative'])
293
-                        ? $deprecation_info['alternative']
294
-                        : __(
295
-                        'Please read the current EE4 documentation further or contact Support.',
296
-                        'event_espresso'
297
-                    )
298
-                ),
299
-                isset($deprecation_info['version']) ? $deprecation_info['version'] : __('recently', 'event_espresso')
300
-            );
301
-        }
302
-    }
265
+	/**
266
+	 * @var          $hooks       array where keys are hook names, and their values are array{
267
+	 * @type string  $version     when deprecated
268
+	 * @type string  $alternative saying what to use instead
269
+	 * @type boolean $still_works whether or not the hook still works
270
+	 *        }
271
+	 */
272
+	$hooks = array(
273
+		'AHEE__EE_System___do_setup_validations' => array(
274
+			'version'     => '4.6.0',
275
+			'alternative' => __(
276
+				'Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)',
277
+				'event_espresso'
278
+			),
279
+			'still_works' => false,
280
+		),
281
+	);
282
+	foreach ($hooks as $name => $deprecation_info) {
283
+		if (has_action($name)) {
284
+			EE_Error::doing_it_wrong(
285
+				$name,
286
+				sprintf(
287
+					__('This filter is deprecated. %1$s%2$s', 'event_espresso'),
288
+					$deprecation_info['still_works'] ? __(
289
+						'It *may* work as an attempt to build in backwards compatibility.',
290
+						'event_espresso'
291
+					) : __('It has been completely removed.', 'event_espresso'),
292
+					isset($deprecation_info['alternative'])
293
+						? $deprecation_info['alternative']
294
+						: __(
295
+						'Please read the current EE4 documentation further or contact Support.',
296
+						'event_espresso'
297
+					)
298
+				),
299
+				isset($deprecation_info['version']) ? $deprecation_info['version'] : __('recently', 'event_espresso')
300
+			);
301
+		}
302
+	}
303 303
 }
304 304
 
305 305
 add_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', 'ee_deprecated_hooks');
@@ -314,34 +314,34 @@  discard block
 block discarded – undo
314 314
  */
315 315
 function ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
316 316
 {
317
-    $in_use = has_filter('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns')
318
-              || has_action(
319
-                  'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save'
320
-              );
321
-    if ($in_use) {
322
-        $msg = __(
323
-            'We detected you are using the filter FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns or AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save.'
324
-            . 'Both of these have been deprecated and should not be used anymore. You should instead use FHEE__EE_Form_Section_Proper___construct__options_array to customize the contents of the form,'
325
-            . 'use FHEE__EE_Form_Section_Proper__receive_form_submission__req_data to customize the submission data, or AHEE__EE_Form_Section_Proper__receive_form_submission__end '
326
-            . 'to add other actions after a form submission has been received.',
327
-            'event_espresso'
328
-        );
329
-        EE_Error::doing_it_wrong(
330
-            __CLASS__ . '::' . __FUNCTION__,
331
-            $msg,
332
-            '4.8.32.rc.000'
333
-        );
334
-        // it seems the doing_it_wrong messages get output during some hidden html tags, so add an error to make sure this gets noticed
335
-        if (is_admin() && ! defined('DOING_AJAX')) {
336
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
337
-        }
338
-    }
339
-    return $in_use;
317
+	$in_use = has_filter('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns')
318
+			  || has_action(
319
+				  'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save'
320
+			  );
321
+	if ($in_use) {
322
+		$msg = __(
323
+			'We detected you are using the filter FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns or AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save.'
324
+			. 'Both of these have been deprecated and should not be used anymore. You should instead use FHEE__EE_Form_Section_Proper___construct__options_array to customize the contents of the form,'
325
+			. 'use FHEE__EE_Form_Section_Proper__receive_form_submission__req_data to customize the submission data, or AHEE__EE_Form_Section_Proper__receive_form_submission__end '
326
+			. 'to add other actions after a form submission has been received.',
327
+			'event_espresso'
328
+		);
329
+		EE_Error::doing_it_wrong(
330
+			__CLASS__ . '::' . __FUNCTION__,
331
+			$msg,
332
+			'4.8.32.rc.000'
333
+		);
334
+		// it seems the doing_it_wrong messages get output during some hidden html tags, so add an error to make sure this gets noticed
335
+		if (is_admin() && ! defined('DOING_AJAX')) {
336
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
337
+		}
338
+	}
339
+	return $in_use;
340 340
 }
341 341
 
342 342
 add_action(
343
-    'AHEE__Registrations_Admin_Page___registration_details_metabox__start',
344
-    'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks'
343
+	'AHEE__Registrations_Admin_Page___registration_details_metabox__start',
344
+	'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks'
345 345
 );
346 346
 
347 347
 /**
@@ -353,77 +353,77 @@  discard block
 block discarded – undo
353 353
  */
354 354
 function ee_deprecated_update_attendee_registration_form_old($admin_page)
355 355
 {
356
-    // check if the old hooks are in use. If not, do the default
357
-    if (! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
358
-        || ! $admin_page instanceof EE_Admin_Page) {
359
-        return;
360
-    }
361
-    $req_data = $admin_page->get_request_data();
362
-    $qstns = isset($req_data['qstn']) ? $req_data['qstn'] : false;
363
-    $REG_ID = isset($req_data['_REG_ID']) ? absint($req_data['_REG_ID']) : false;
364
-    $qstns = apply_filters('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns);
365
-    if (! $REG_ID || ! $qstns) {
366
-        EE_Error::add_error(
367
-            __('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'),
368
-            __FILE__,
369
-            __FUNCTION__,
370
-            __LINE__
371
-        );
372
-    }
373
-    $success = true;
374
-
375
-    // allow others to get in on this awesome fun   :D
376
-    do_action(
377
-        'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save',
378
-        $REG_ID,
379
-        $qstns
380
-    );
381
-    // loop thru questions... FINALLY!!!
382
-
383
-    foreach ($qstns as $QST_ID => $qstn) {
384
-        // if $qstn isn't an array then it doesn't already have an answer, so let's create the answer
385
-        if (! is_array($qstn)) {
386
-            $success = $this->_save_new_answer($REG_ID, $QST_ID, $qstn);
387
-            continue;
388
-        }
389
-
390
-
391
-        foreach ($qstn as $ANS_ID => $ANS_value) {
392
-            // get answer
393
-            $query_params = array(
394
-                0 => array(
395
-                    'ANS_ID' => $ANS_ID,
396
-                    'REG_ID' => $REG_ID,
397
-                    'QST_ID' => $QST_ID,
398
-                ),
399
-            );
400
-            $answer = EEM_Answer::instance()->get_one($query_params);
401
-            // this MAY be an array but NOT have an answer because its multi select.  If so then we need to create the answer
402
-            if (! $answer instanceof EE_Answer) {
403
-                $set_values = array(
404
-                    'QST_ID'    => $QST_ID,
405
-                    'REG_ID'    => $REG_ID,
406
-                    'ANS_value' => $qstn,
407
-                );
408
-                $success = EEM_Answer::instance()->insert($set_values);
409
-                continue 2;
410
-            }
411
-
412
-            $answer->set('ANS_value', $ANS_value);
413
-            $success = $answer->save();
414
-        }
415
-    }
416
-    $what = __('Registration Form', 'event_espresso');
417
-    $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) : array('action' => 'default');
418
-    $admin_page->redirect_after_action($success, $what, __('updated', 'event_espresso'), $route);
419
-    exit;
356
+	// check if the old hooks are in use. If not, do the default
357
+	if (! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
358
+		|| ! $admin_page instanceof EE_Admin_Page) {
359
+		return;
360
+	}
361
+	$req_data = $admin_page->get_request_data();
362
+	$qstns = isset($req_data['qstn']) ? $req_data['qstn'] : false;
363
+	$REG_ID = isset($req_data['_REG_ID']) ? absint($req_data['_REG_ID']) : false;
364
+	$qstns = apply_filters('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns);
365
+	if (! $REG_ID || ! $qstns) {
366
+		EE_Error::add_error(
367
+			__('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'),
368
+			__FILE__,
369
+			__FUNCTION__,
370
+			__LINE__
371
+		);
372
+	}
373
+	$success = true;
374
+
375
+	// allow others to get in on this awesome fun   :D
376
+	do_action(
377
+		'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save',
378
+		$REG_ID,
379
+		$qstns
380
+	);
381
+	// loop thru questions... FINALLY!!!
382
+
383
+	foreach ($qstns as $QST_ID => $qstn) {
384
+		// if $qstn isn't an array then it doesn't already have an answer, so let's create the answer
385
+		if (! is_array($qstn)) {
386
+			$success = $this->_save_new_answer($REG_ID, $QST_ID, $qstn);
387
+			continue;
388
+		}
389
+
390
+
391
+		foreach ($qstn as $ANS_ID => $ANS_value) {
392
+			// get answer
393
+			$query_params = array(
394
+				0 => array(
395
+					'ANS_ID' => $ANS_ID,
396
+					'REG_ID' => $REG_ID,
397
+					'QST_ID' => $QST_ID,
398
+				),
399
+			);
400
+			$answer = EEM_Answer::instance()->get_one($query_params);
401
+			// this MAY be an array but NOT have an answer because its multi select.  If so then we need to create the answer
402
+			if (! $answer instanceof EE_Answer) {
403
+				$set_values = array(
404
+					'QST_ID'    => $QST_ID,
405
+					'REG_ID'    => $REG_ID,
406
+					'ANS_value' => $qstn,
407
+				);
408
+				$success = EEM_Answer::instance()->insert($set_values);
409
+				continue 2;
410
+			}
411
+
412
+			$answer->set('ANS_value', $ANS_value);
413
+			$success = $answer->save();
414
+		}
415
+	}
416
+	$what = __('Registration Form', 'event_espresso');
417
+	$route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) : array('action' => 'default');
418
+	$admin_page->redirect_after_action($success, $what, __('updated', 'event_espresso'), $route);
419
+	exit;
420 420
 }
421 421
 
422 422
 add_action(
423
-    'AHEE__Registrations_Admin_Page___update_attendee_registration_form__start',
424
-    'ee_deprecated_update_attendee_registration_form_old',
425
-    10,
426
-    1
423
+	'AHEE__Registrations_Admin_Page___update_attendee_registration_form__start',
424
+	'ee_deprecated_update_attendee_registration_form_old',
425
+	10,
426
+	1
427 427
 );
428 428
 /**
429 429
  * Render the registration admin page's custom questions area in the old fashion
@@ -439,50 +439,50 @@  discard block
 block discarded – undo
439 439
  */
440 440
 function ee_deprecated_reg_questions_meta_box_old($do_default_action, $admin_page, $registration)
441 441
 {
442
-    // check if the old hooks are in use. If not, do the default
443
-    if (! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
444
-        || ! $admin_page instanceof EE_Admin_Page) {
445
-        return $do_default_action;
446
-    }
447
-    add_filter(
448
-        'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions',
449
-        array($admin_page, 'form_before_question_group'),
450
-        10,
451
-        1
452
-    );
453
-    add_filter(
454
-        'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions',
455
-        array($admin_page, 'form_after_question_group'),
456
-        10,
457
-        1
458
-    );
459
-    add_filter('FHEE__EEH_Form_Fields__label_html', array($admin_page, 'form_form_field_label_wrap'), 10, 1);
460
-    add_filter('FHEE__EEH_Form_Fields__input_html', array($admin_page, 'form_form_field_input__wrap'), 10, 1);
461
-
462
-    $question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options(
463
-        $registration,
464
-        $registration->get(
465
-            'EVT_ID'
466
-        )
467
-    );
468
-
469
-    EE_Registry::instance()->load_helper('Form_Fields');
470
-    $template_args = array(
471
-        'att_questions'             => EEH_Form_Fields::generate_question_groups_html($question_groups),
472
-        'reg_questions_form_action' => 'edit_registration',
473
-        'REG_ID'                    => $registration->ID(),
474
-    );
475
-    $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
476
-    echo EEH_Template::display_template($template_path, $template_args, true);
477
-    // indicate that we should not do the default admin page code
478
-    return false;
442
+	// check if the old hooks are in use. If not, do the default
443
+	if (! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
444
+		|| ! $admin_page instanceof EE_Admin_Page) {
445
+		return $do_default_action;
446
+	}
447
+	add_filter(
448
+		'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions',
449
+		array($admin_page, 'form_before_question_group'),
450
+		10,
451
+		1
452
+	);
453
+	add_filter(
454
+		'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions',
455
+		array($admin_page, 'form_after_question_group'),
456
+		10,
457
+		1
458
+	);
459
+	add_filter('FHEE__EEH_Form_Fields__label_html', array($admin_page, 'form_form_field_label_wrap'), 10, 1);
460
+	add_filter('FHEE__EEH_Form_Fields__input_html', array($admin_page, 'form_form_field_input__wrap'), 10, 1);
461
+
462
+	$question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options(
463
+		$registration,
464
+		$registration->get(
465
+			'EVT_ID'
466
+		)
467
+	);
468
+
469
+	EE_Registry::instance()->load_helper('Form_Fields');
470
+	$template_args = array(
471
+		'att_questions'             => EEH_Form_Fields::generate_question_groups_html($question_groups),
472
+		'reg_questions_form_action' => 'edit_registration',
473
+		'REG_ID'                    => $registration->ID(),
474
+	);
475
+	$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
476
+	echo EEH_Template::display_template($template_path, $template_args, true);
477
+	// indicate that we should not do the default admin page code
478
+	return false;
479 479
 }
480 480
 
481 481
 add_action(
482
-    'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default',
483
-    'ee_deprecated_reg_questions_meta_box_old',
484
-    10,
485
-    3
482
+	'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default',
483
+	'ee_deprecated_reg_questions_meta_box_old',
484
+	10,
485
+	3
486 486
 );
487 487
 
488 488
 
@@ -499,42 +499,42 @@  discard block
 block discarded – undo
499 499
 class EE_Message_Template_Defaults extends EE_Base
500 500
 {
501 501
 
502
-    /**
503
-     * EE_Message_Template_Defaults constructor.
504
-     *
505
-     * @param EE_messages $messages
506
-     * @param             $messenger_name
507
-     * @param             $message_type_name
508
-     * @param int         $GRP_ID
509
-     * @return EE_Messages_Template_Defaults
510
-     */
511
-    public function __construct(
512
-        EE_messages $messages,
513
-        $messenger_name,
514
-        $message_type_name,
515
-        $GRP_ID = 0
516
-    ) {
517
-        EE_Error::doing_it_wrong(
518
-            __FUNCTION__,
519
-            __(
520
-                'The class EE_Message_Template_Defaults has been deprecated and replaced by EE_Messages_Template_Defaults.',
521
-                'event_espresso'
522
-            ),
523
-            '4.9.0'
524
-        );
525
-        /** @var EE_Message_Resource_Manager $message_resource_manager */
526
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
527
-        $messenger = $message_resource_manager->get_messenger($messenger_name);
528
-        $message_type = $message_resource_manager->get_message_type($message_type_name);
529
-        return EE_Registry::instance()->load_lib(
530
-            'Messages_Template_Defaults',
531
-            array(
532
-                $GRP_ID,
533
-                $messenger,
534
-                $message_type,
535
-            )
536
-        );
537
-    }
502
+	/**
503
+	 * EE_Message_Template_Defaults constructor.
504
+	 *
505
+	 * @param EE_messages $messages
506
+	 * @param             $messenger_name
507
+	 * @param             $message_type_name
508
+	 * @param int         $GRP_ID
509
+	 * @return EE_Messages_Template_Defaults
510
+	 */
511
+	public function __construct(
512
+		EE_messages $messages,
513
+		$messenger_name,
514
+		$message_type_name,
515
+		$GRP_ID = 0
516
+	) {
517
+		EE_Error::doing_it_wrong(
518
+			__FUNCTION__,
519
+			__(
520
+				'The class EE_Message_Template_Defaults has been deprecated and replaced by EE_Messages_Template_Defaults.',
521
+				'event_espresso'
522
+			),
523
+			'4.9.0'
524
+		);
525
+		/** @var EE_Message_Resource_Manager $message_resource_manager */
526
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
527
+		$messenger = $message_resource_manager->get_messenger($messenger_name);
528
+		$message_type = $message_resource_manager->get_message_type($message_type_name);
529
+		return EE_Registry::instance()->load_lib(
530
+			'Messages_Template_Defaults',
531
+			array(
532
+				$GRP_ID,
533
+				$messenger,
534
+				$message_type,
535
+			)
536
+		);
537
+	}
538 538
 }
539 539
 
540 540
 
@@ -552,525 +552,525 @@  discard block
 block discarded – undo
552 552
 class EE_messages
553 553
 {
554 554
 
555
-    /** @type EE_messenger[] */
556
-    protected $_active_messengers = array();
557
-
558
-    /** @type array */
559
-    protected $_active_message_types = array();
560
-
561
-    /** @type EE_message_type[] */
562
-    protected $_installed_message_types = array();
563
-
564
-    /** @type EE_messenger */
565
-    protected $_messenger;
566
-
567
-    /** @type EE_message_type */
568
-    protected $_message_type;
569
-
570
-    /** @type array */
571
-    protected $_contexts = array();
572
-
573
-    /** @type EE_Message_Resource_Manager $_message_resource_manager */
574
-    protected $_message_resource_manager;
575
-
576
-
577
-    /**
578
-     * EE_messages constructor.
579
-     *
580
-     * @deprecated 4.9.0
581
-     */
582
-    public function __construct()
583
-    {
584
-    }
585
-
586
-
587
-    /**
588
-     * @param string $method
589
-     */
590
-    public function _class_is_deprecated($method)
591
-    {
592
-        EE_Error::doing_it_wrong(
593
-            'EE_messages::' . $method,
594
-            __('EE_messages has been deprecated.  Please use EE_Message_Resource_Manager instead.'),
595
-            '4.9.0',
596
-            '4.10.0.p'
597
-        );
598
-        // Please use EE_Message_Resource_Manager instead
599
-        $this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
600
-    }
601
-
602
-
603
-    /**
604
-     * @deprecated 4.9.0
605
-     * @param string $messenger_name
606
-     * @return boolean TRUE if it was PREVIOUSLY active, and FALSE if it was previously inactive
607
-     */
608
-    public function ensure_messenger_is_active($messenger_name)
609
-    {
610
-        // EE_messages has been deprecated
611
-        $this->_class_is_deprecated(__FUNCTION__);
612
-        return $this->_message_resource_manager->ensure_messenger_is_active($messenger_name);
613
-    }
614
-
615
-
616
-    /**
617
-     * @deprecated 4.9.0
618
-     * @param string $message_type message type name
619
-     * @param        $messenger
620
-     * @return bool true if it got activated (or was active) and false if not.
621
-     * @throws \EE_Error
622
-     */
623
-    public function ensure_message_type_is_active($message_type, $messenger)
624
-    {
625
-        // EE_messages has been deprecated
626
-        $this->_class_is_deprecated(__FUNCTION__);
627
-        return $this->_message_resource_manager->ensure_message_type_is_active($message_type, $messenger);
628
-    }
629
-
630
-
631
-    /**
632
-     * @deprecated 4.9.0
633
-     * @param string $messenger_name
634
-     * @param array  $mts_to_activate             (optional) An array of message types to activate with this messenger.
635
-     *                                             If included we do NOT setup the default message types (assuming they
636
-     *                                             are already setup.)
637
-     * @return boolean an array of generated templates or false if nothing generated/activated.
638
-     */
639
-    public function activate_messenger($messenger_name, $mts_to_activate = array())
640
-    {
641
-        // EE_messages has been deprecated
642
-        $this->_class_is_deprecated(__FUNCTION__);
643
-        return $this->_message_resource_manager->activate_messenger($messenger_name, $mts_to_activate);
644
-    }
645
-
646
-
647
-    /**
648
-     * @deprecated 4.9.0
649
-     * @param EE_messenger    $messenger    messenger used in trigger
650
-     * @param EE_message_type $message_type message type used in trigger
651
-     *
652
-     * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send.
653
-     */
654
-    public function is_generating_messenger_and_active(EE_messenger $messenger, EE_message_type $message_type)
655
-    {
656
-        // EE_messages has been deprecated
657
-        $this->_class_is_deprecated(__FUNCTION__);
658
-        return $this->_message_resource_manager->is_generating_messenger_and_active($messenger, $message_type);
659
-    }
660
-
661
-
662
-    /**
663
-     * @deprecated 4.9.0
664
-     * @param string $messenger
665
-     * @return EE_messenger | null
666
-     */
667
-    public function get_messenger_if_active($messenger)
668
-    {
669
-        // EE_messages has been deprecated
670
-        $this->_class_is_deprecated(__FUNCTION__);
671
-        return $this->_message_resource_manager->get_active_messenger($messenger);
672
-    }
673
-
674
-
675
-    /**
676
-     * @deprecated 4.9.0
677
-     * @param EE_Message $message
678
-     * @return array  An array with 'messenger' and 'message_type' as the index and the corresponding valid object if
679
-     *                  available.
680
-     *                  Eg. Valid Messenger and Message Type:
681
-     *                  array(
682
-     *                  'messenger' => new EE_Email_messenger(),
683
-     *                  'message_type' => new EE_Registration_Approved_message_type()
684
-     *                  )
685
-     *                  Valid Messenger and Invalid Message Type:
686
-     *                  array(
687
-     *                  'messenger' => new EE_Email_messenger(),
688
-     *                  'message_type' => null
689
-     *                  )
690
-     */
691
-    public function validate_for_use(EE_Message $message)
692
-    {
693
-        // EE_messages has been deprecated
694
-        $this->_class_is_deprecated(__FUNCTION__);
695
-        return array(
696
-            'messenger'    => $message->messenger_object(),
697
-            'message_type' => $message->message_type_object(),
698
-        );
699
-    }
700
-
701
-
702
-    /**
703
-     * @deprecated 4.9.0
704
-     * @param  string $type                 What type of message are we sending (corresponds to message types)
705
-     * @param  mixed  $vars                 Data being sent for parsing in the message
706
-     * @param  string $sending_messenger    if included then we ONLY use the specified messenger for delivery.
707
-     *                                      Otherwise we cycle through all active messengers.
708
-     * @param string  $generating_messenger if included then this messenger is used for generating the message
709
-     *                                      templates (but not for sending).
710
-     * @param string  $context              If included then only a message type for a specific context will be
711
-     *                                      generated.
712
-     * @param bool    $send                 Default TRUE.  If false, then this will just return the generated
713
-     *                                      EE_messages objects which might be used by the trigger to setup a batch
714
-     *                                      message (typically html messenger uses it).
715
-     * @return bool
716
-     */
717
-    public function send_message(
718
-        $type,
719
-        $vars,
720
-        $sending_messenger = '',
721
-        $generating_messenger = '',
722
-        $context = '',
723
-        $send = true
724
-    ) {
725
-        // EE_messages has been deprecated
726
-        $this->_class_is_deprecated(__FUNCTION__);
727
-        /** @type EE_Messages_Processor $processor */
728
-        $processor = EE_Registry::instance()->load_lib('Messages_Processor');
729
-        $error = false;
730
-        // try to intelligently determine what method we'll call based on the incoming data.
731
-        // if generating and sending are different then generate and send immediately.
732
-        if (! empty($sending_messenger) && $sending_messenger != $generating_messenger && $send) {
733
-            // in the legacy system, when generating and sending were different, that means all the
734
-            // vars are already in the request object.  So let's just use that.
735
-            try {
736
-                /** @type EE_Message_To_Generate_From_Request $mtg */
737
-                $mtg = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request');
738
-                $processor->generate_and_send_now($mtg);
739
-            } catch (EE_Error $e) {
740
-                $error_msg = __(
741
-                    'Please note that a system message failed to send due to a technical issue.',
742
-                    'event_espresso'
743
-                );
744
-                // add specific message for developers if WP_DEBUG in on
745
-                $error_msg .= '||' . $e->getMessage();
746
-                EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
747
-                $error = true;
748
-            }
749
-        } else {
750
-            $processor->generate_for_all_active_messengers($type, $vars, $send);
751
-            // let's find out if there were any errors and how many successfully were queued.
752
-            $count_errors = $processor->get_queue()->count_STS_in_queue(
753
-                array(EEM_Message::status_failed, EEM_Message::status_debug_only)
754
-            );
755
-            $count_queued = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_incomplete);
756
-            $count_retry = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_retry);
757
-            $count_errors = $count_errors + $count_retry;
758
-            if ($count_errors > 0) {
759
-                $error = true;
760
-                if ($count_errors > 1 && $count_retry > 1 && $count_queued > 1) {
761
-                    $message = sprintf(
762
-                        __(
763
-                            'There were %d errors and %d messages successfully queued for generation and sending',
764
-                            'event_espresso'
765
-                        ),
766
-                        $count_errors,
767
-                        $count_queued
768
-                    );
769
-                } elseif ($count_errors > 1 && $count_queued === 1) {
770
-                    $message = sprintf(
771
-                        __(
772
-                            'There were %d errors and %d message successfully queued for generation.',
773
-                            'event_espresso'
774
-                        ),
775
-                        $count_errors,
776
-                        $count_queued
777
-                    );
778
-                } elseif ($count_errors === 1 && $count_queued > 1) {
779
-                    $message = sprintf(
780
-                        __(
781
-                            'There was %d error and %d messages successfully queued for generation.',
782
-                            'event_espresso'
783
-                        ),
784
-                        $count_errors,
785
-                        $count_queued
786
-                    );
787
-                } else {
788
-                    $message = sprintf(
789
-                        __(
790
-                            'There was %d message that failed to be queued for generation.',
791
-                            'event_espresso'
792
-                        ),
793
-                        $count_errors
794
-                    );
795
-                }
796
-                EE_Error::add_error($message, __FILE__, __FUNCTION__, __LINE__);
797
-            } else {
798
-                if ($count_queued === 1) {
799
-                    $message = sprintf(
800
-                        __(
801
-                            '%d message successfully queued for generation.',
802
-                            'event_espresso'
803
-                        ),
804
-                        $count_queued
805
-                    );
806
-                } else {
807
-                    $message = sprintf(
808
-                        __(
809
-                            '%d messages were successfully queued for generation.',
810
-                            'event_espresso'
811
-                        ),
812
-                        $count_queued
813
-                    );
814
-                }
815
-                EE_Error::add_success($message);
816
-            }
817
-        }
818
-        // if no error then return the generated message(s).
819
-        if (! $error && ! $send) {
820
-            $generated_queue = $processor->generate_queue(false);
821
-            // get message and return.
822
-            $generated_queue->get_message_repository()->rewind();
823
-            $messages = array();
824
-            while ($generated_queue->get_message_repository()->valid()) {
825
-                $message = $generated_queue->get_message_repository()->current();
826
-                if ($message instanceof EE_Message) {
827
-                    // set properties that might be expected by add-ons (backward compat)
828
-                    $message->content = $message->content();
829
-                    $message->template_pack = $message->get_template_pack();
830
-                    $message->template_variation = $message->get_template_pack_variation();
831
-                    $messages[] = $message;
832
-                }
833
-                $generated_queue->get_message_repository()->next();
834
-            }
835
-            return $messages;
836
-        }
837
-        return $error ? false
838
-            : true; // yeah backwards eh?  Really what we're returning is if there is a total success for all the messages or not.  We'll modify this once we get message recording in place.
839
-    }
840
-
841
-
842
-    /**
843
-     * @deprecated 4.9.0
844
-     * @param  string $type      This should correspond with a valid message type
845
-     * @param  string $context   This should correspond with a valid context for the message type
846
-     * @param  string $messenger This should correspond with a valid messenger.
847
-     * @param bool    $send      true we will do a test send using the messenger delivery, false we just do a regular
848
-     *                           preview
849
-     * @return string          The body of the message.
850
-     */
851
-    public function preview_message($type, $context, $messenger, $send = false)
852
-    {
853
-        // EE_messages has been deprecated
854
-        $this->_class_is_deprecated(__FUNCTION__);
855
-        return EED_Messages::preview_message($type, $context, $messenger, $send);
856
-    }
857
-
858
-
859
-    /**
860
-     * @since      4.5.0
861
-     * @deprecated 4.9.0   Moved to EED_Messages Module
862
-     * @param string   $messenger    a string matching a valid active messenger in the system
863
-     * @param string   $message_type Although it seems contrary to the name of the method, a message type name is still
864
-     *                               required to send along the message type to the messenger because this is used for
865
-     *                               determining what specific variations might be loaded for the generated message.
866
-     * @param stdClass $message      a stdClass object in the format expected by the messenger.
867
-     *
868
-     * @return bool          success or fail.
869
-     */
870
-    public function send_message_with_messenger_only($messenger, $message_type, $message)
871
-    {
872
-        // EE_messages has been deprecated
873
-        $this->_class_is_deprecated(__FUNCTION__);
874
-        // setup for sending to new method.
875
-        /** @type EE_Messages_Queue $queue */
876
-        $queue = EE_Registry::instance()->load_lib('Messages_Queue');
877
-        // make sure we have a proper message object
878
-        if (! $message instanceof EE_Message && is_object($message) && isset($message->content)) {
879
-            $msg = EE_Message_Factory::create(
880
-                array(
881
-                    'MSG_messenger'    => $messenger,
882
-                    'MSG_message_type' => $message_type,
883
-                    'MSG_content'      => $message->content,
884
-                    'MSG_subject'      => $message->subject,
885
-                )
886
-            );
887
-        } else {
888
-            $msg = $message;
889
-        }
890
-        if (! $msg instanceof EE_Message) {
891
-            return false;
892
-        }
893
-        // make sure any content in a content property (if not empty) is set on the MSG_content.
894
-        if (! empty($msg->content)) {
895
-            $msg->set('MSG_content', $msg->content);
896
-        }
897
-        $queue->add($msg);
898
-        return EED_Messages::send_message_with_messenger_only($messenger, $message_type, $queue);
899
-    }
900
-
901
-
902
-    /**
903
-     * @deprecated 4.9.0
904
-     * @param         $messenger
905
-     * @param  string $message_type message type that the templates are being created for
906
-     * @param int     $GRP_ID
907
-     * @param bool    $is_global
908
-     * @return array|object if creation is successful then we return an array of info, otherwise an error_object is
909
-     *                      returned.
910
-     * @throws \EE_Error
911
-     */
912
-    public function create_new_templates($messenger, $message_type, $GRP_ID = 0, $is_global = false)
913
-    {
914
-        // EE_messages has been deprecated
915
-        $this->_class_is_deprecated(__FUNCTION__);
916
-        EE_Registry::instance()->load_helper('MSG_Template');
917
-        return EEH_MSG_Template::create_new_templates($messenger, $message_type, $GRP_ID, $is_global);
918
-    }
919
-
920
-
921
-    /**
922
-     * @deprecated 4.9.0
923
-     * @param  string $messenger_name    name of EE_messenger
924
-     * @param  string $message_type_name name of EE_message_type
925
-     * @return array
926
-     */
927
-    public function get_fields($messenger_name, $message_type_name)
928
-    {
929
-        // EE_messages has been deprecated
930
-        $this->_class_is_deprecated(__FUNCTION__);
931
-        EE_Registry::instance()->load_helper('MSG_Template');
932
-        return EEH_MSG_Template::get_fields($messenger_name, $message_type_name);
933
-    }
934
-
935
-
936
-    /**
937
-     * @deprecated 4.9.0
938
-     * @access     public
939
-     * @param string $type                we can indicate just returning installed message types
940
-     *                                    or messengers (or both) via this parameter.
941
-     * @param bool   $skip_cache          if true then we skip the cache and retrieve via files.
942
-     * @return array                    multidimensional array of messenger and message_type objects
943
-     *                                    (messengers index, and message_type index);
944
-     */
945
-    public function get_installed($type = 'all', $skip_cache = false)
946
-    {
947
-        // EE_messages has been deprecated
948
-        $this->_class_is_deprecated(__FUNCTION__);
949
-        if ($skip_cache) {
950
-            $this->_message_resource_manager->reset_active_messengers_and_message_types();
951
-        }
952
-        switch ($type) {
953
-            case 'messengers' :
954
-                return array(
955
-                    'messenger' => $this->_message_resource_manager->installed_messengers(),
956
-                );
957
-                break;
958
-            case 'message_types' :
959
-                return array(
960
-                    'message_type' => $this->_message_resource_manager->installed_message_types(),
961
-                );
962
-                break;
963
-            case 'all' :
964
-            default :
965
-                return array(
966
-                    'messenger'    => $this->_message_resource_manager->installed_messengers(),
967
-                    'message_type' => $this->_message_resource_manager->installed_message_types(),
968
-                );
969
-                break;
970
-        }
971
-    }
972
-
973
-
974
-    /**
975
-     * @deprecated 4.9.0
976
-     * @return \EE_messenger[]
977
-     */
978
-    public function get_active_messengers()
979
-    {
980
-        // EE_messages has been deprecated
981
-        $this->_class_is_deprecated(__FUNCTION__);
982
-        return $this->_message_resource_manager->active_messengers();
983
-    }
984
-
985
-
986
-    /**
987
-     * @deprecated 4.9.0
988
-     * @return array array of message_type references (string)
989
-     */
990
-    public function get_active_message_types()
991
-    {
992
-        // EE_messages has been deprecated
993
-        $this->_class_is_deprecated(__FUNCTION__);
994
-        return $this->_message_resource_manager->list_of_active_message_types();
995
-    }
996
-
997
-
998
-    /**
999
-     * @deprecated 4.9.0
1000
-     * @return EE_message_type[]
1001
-     */
1002
-    public function get_active_message_type_objects()
1003
-    {
1004
-        // EE_messages has been deprecated
1005
-        $this->_class_is_deprecated(__FUNCTION__);
1006
-        return $this->_message_resource_manager->get_active_message_type_objects();
1007
-    }
1008
-
1009
-
1010
-    /**
1011
-     * @deprecated 4.9.0
1012
-     * @since      4.5.0
1013
-     * @param string $messenger The messenger being checked
1014
-     * @return EE_message_type[]    (or empty array if none present)
1015
-     */
1016
-    public function get_active_message_types_per_messenger($messenger)
1017
-    {
1018
-        // EE_messages has been deprecated
1019
-        $this->_class_is_deprecated(__FUNCTION__);
1020
-        return $this->_message_resource_manager->get_active_message_types_for_messenger($messenger);
1021
-    }
1022
-
1023
-
1024
-    /**
1025
-     * @deprecated 4.9.0
1026
-     * @param string $messenger    The string should correspond to the messenger (message types are
1027
-     * @param string $message_type The string should correspond to a message type.
1028
-     * @return EE_message_type|null
1029
-     */
1030
-    public function get_active_message_type($messenger, $message_type)
1031
-    {
1032
-        // EE_messages has been deprecated
1033
-        $this->_class_is_deprecated(__FUNCTION__);
1034
-        return $this->_message_resource_manager->get_active_message_type_for_messenger($messenger, $message_type);
1035
-    }
1036
-
1037
-
1038
-    /**
1039
-     * @deprecated 4.9.0
1040
-     * @return array|\EE_message_type[]
1041
-     */
1042
-    public function get_installed_message_types()
1043
-    {
1044
-        // EE_messages has been deprecated
1045
-        $this->_class_is_deprecated(__FUNCTION__);
1046
-        return $this->_message_resource_manager->installed_message_types();
1047
-    }
1048
-
1049
-
1050
-    /**
1051
-     * @deprecated 4.9.0
1052
-     * @return array
1053
-     */
1054
-    public function get_installed_messengers()
1055
-    {
1056
-        // EE_messages has been deprecated
1057
-        $this->_class_is_deprecated(__FUNCTION__);
1058
-        return $this->_message_resource_manager->installed_messengers();
1059
-    }
1060
-
1061
-
1062
-    /**
1063
-     * @deprecated 4.9.0
1064
-     * @param   bool $slugs_only Whether to return an array of just slugs and labels (true) or all contexts indexed by
1065
-     *                           message type.
1066
-     * @return array
1067
-     */
1068
-    public function get_all_contexts($slugs_only = true)
1069
-    {
1070
-        // EE_messages has been deprecated
1071
-        $this->_class_is_deprecated(__FUNCTION__);
1072
-        return $this->_message_resource_manager->get_all_contexts($slugs_only);
1073
-    }
555
+	/** @type EE_messenger[] */
556
+	protected $_active_messengers = array();
557
+
558
+	/** @type array */
559
+	protected $_active_message_types = array();
560
+
561
+	/** @type EE_message_type[] */
562
+	protected $_installed_message_types = array();
563
+
564
+	/** @type EE_messenger */
565
+	protected $_messenger;
566
+
567
+	/** @type EE_message_type */
568
+	protected $_message_type;
569
+
570
+	/** @type array */
571
+	protected $_contexts = array();
572
+
573
+	/** @type EE_Message_Resource_Manager $_message_resource_manager */
574
+	protected $_message_resource_manager;
575
+
576
+
577
+	/**
578
+	 * EE_messages constructor.
579
+	 *
580
+	 * @deprecated 4.9.0
581
+	 */
582
+	public function __construct()
583
+	{
584
+	}
585
+
586
+
587
+	/**
588
+	 * @param string $method
589
+	 */
590
+	public function _class_is_deprecated($method)
591
+	{
592
+		EE_Error::doing_it_wrong(
593
+			'EE_messages::' . $method,
594
+			__('EE_messages has been deprecated.  Please use EE_Message_Resource_Manager instead.'),
595
+			'4.9.0',
596
+			'4.10.0.p'
597
+		);
598
+		// Please use EE_Message_Resource_Manager instead
599
+		$this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
600
+	}
601
+
602
+
603
+	/**
604
+	 * @deprecated 4.9.0
605
+	 * @param string $messenger_name
606
+	 * @return boolean TRUE if it was PREVIOUSLY active, and FALSE if it was previously inactive
607
+	 */
608
+	public function ensure_messenger_is_active($messenger_name)
609
+	{
610
+		// EE_messages has been deprecated
611
+		$this->_class_is_deprecated(__FUNCTION__);
612
+		return $this->_message_resource_manager->ensure_messenger_is_active($messenger_name);
613
+	}
614
+
615
+
616
+	/**
617
+	 * @deprecated 4.9.0
618
+	 * @param string $message_type message type name
619
+	 * @param        $messenger
620
+	 * @return bool true if it got activated (or was active) and false if not.
621
+	 * @throws \EE_Error
622
+	 */
623
+	public function ensure_message_type_is_active($message_type, $messenger)
624
+	{
625
+		// EE_messages has been deprecated
626
+		$this->_class_is_deprecated(__FUNCTION__);
627
+		return $this->_message_resource_manager->ensure_message_type_is_active($message_type, $messenger);
628
+	}
629
+
630
+
631
+	/**
632
+	 * @deprecated 4.9.0
633
+	 * @param string $messenger_name
634
+	 * @param array  $mts_to_activate             (optional) An array of message types to activate with this messenger.
635
+	 *                                             If included we do NOT setup the default message types (assuming they
636
+	 *                                             are already setup.)
637
+	 * @return boolean an array of generated templates or false if nothing generated/activated.
638
+	 */
639
+	public function activate_messenger($messenger_name, $mts_to_activate = array())
640
+	{
641
+		// EE_messages has been deprecated
642
+		$this->_class_is_deprecated(__FUNCTION__);
643
+		return $this->_message_resource_manager->activate_messenger($messenger_name, $mts_to_activate);
644
+	}
645
+
646
+
647
+	/**
648
+	 * @deprecated 4.9.0
649
+	 * @param EE_messenger    $messenger    messenger used in trigger
650
+	 * @param EE_message_type $message_type message type used in trigger
651
+	 *
652
+	 * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send.
653
+	 */
654
+	public function is_generating_messenger_and_active(EE_messenger $messenger, EE_message_type $message_type)
655
+	{
656
+		// EE_messages has been deprecated
657
+		$this->_class_is_deprecated(__FUNCTION__);
658
+		return $this->_message_resource_manager->is_generating_messenger_and_active($messenger, $message_type);
659
+	}
660
+
661
+
662
+	/**
663
+	 * @deprecated 4.9.0
664
+	 * @param string $messenger
665
+	 * @return EE_messenger | null
666
+	 */
667
+	public function get_messenger_if_active($messenger)
668
+	{
669
+		// EE_messages has been deprecated
670
+		$this->_class_is_deprecated(__FUNCTION__);
671
+		return $this->_message_resource_manager->get_active_messenger($messenger);
672
+	}
673
+
674
+
675
+	/**
676
+	 * @deprecated 4.9.0
677
+	 * @param EE_Message $message
678
+	 * @return array  An array with 'messenger' and 'message_type' as the index and the corresponding valid object if
679
+	 *                  available.
680
+	 *                  Eg. Valid Messenger and Message Type:
681
+	 *                  array(
682
+	 *                  'messenger' => new EE_Email_messenger(),
683
+	 *                  'message_type' => new EE_Registration_Approved_message_type()
684
+	 *                  )
685
+	 *                  Valid Messenger and Invalid Message Type:
686
+	 *                  array(
687
+	 *                  'messenger' => new EE_Email_messenger(),
688
+	 *                  'message_type' => null
689
+	 *                  )
690
+	 */
691
+	public function validate_for_use(EE_Message $message)
692
+	{
693
+		// EE_messages has been deprecated
694
+		$this->_class_is_deprecated(__FUNCTION__);
695
+		return array(
696
+			'messenger'    => $message->messenger_object(),
697
+			'message_type' => $message->message_type_object(),
698
+		);
699
+	}
700
+
701
+
702
+	/**
703
+	 * @deprecated 4.9.0
704
+	 * @param  string $type                 What type of message are we sending (corresponds to message types)
705
+	 * @param  mixed  $vars                 Data being sent for parsing in the message
706
+	 * @param  string $sending_messenger    if included then we ONLY use the specified messenger for delivery.
707
+	 *                                      Otherwise we cycle through all active messengers.
708
+	 * @param string  $generating_messenger if included then this messenger is used for generating the message
709
+	 *                                      templates (but not for sending).
710
+	 * @param string  $context              If included then only a message type for a specific context will be
711
+	 *                                      generated.
712
+	 * @param bool    $send                 Default TRUE.  If false, then this will just return the generated
713
+	 *                                      EE_messages objects which might be used by the trigger to setup a batch
714
+	 *                                      message (typically html messenger uses it).
715
+	 * @return bool
716
+	 */
717
+	public function send_message(
718
+		$type,
719
+		$vars,
720
+		$sending_messenger = '',
721
+		$generating_messenger = '',
722
+		$context = '',
723
+		$send = true
724
+	) {
725
+		// EE_messages has been deprecated
726
+		$this->_class_is_deprecated(__FUNCTION__);
727
+		/** @type EE_Messages_Processor $processor */
728
+		$processor = EE_Registry::instance()->load_lib('Messages_Processor');
729
+		$error = false;
730
+		// try to intelligently determine what method we'll call based on the incoming data.
731
+		// if generating and sending are different then generate and send immediately.
732
+		if (! empty($sending_messenger) && $sending_messenger != $generating_messenger && $send) {
733
+			// in the legacy system, when generating and sending were different, that means all the
734
+			// vars are already in the request object.  So let's just use that.
735
+			try {
736
+				/** @type EE_Message_To_Generate_From_Request $mtg */
737
+				$mtg = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request');
738
+				$processor->generate_and_send_now($mtg);
739
+			} catch (EE_Error $e) {
740
+				$error_msg = __(
741
+					'Please note that a system message failed to send due to a technical issue.',
742
+					'event_espresso'
743
+				);
744
+				// add specific message for developers if WP_DEBUG in on
745
+				$error_msg .= '||' . $e->getMessage();
746
+				EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
747
+				$error = true;
748
+			}
749
+		} else {
750
+			$processor->generate_for_all_active_messengers($type, $vars, $send);
751
+			// let's find out if there were any errors and how many successfully were queued.
752
+			$count_errors = $processor->get_queue()->count_STS_in_queue(
753
+				array(EEM_Message::status_failed, EEM_Message::status_debug_only)
754
+			);
755
+			$count_queued = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_incomplete);
756
+			$count_retry = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_retry);
757
+			$count_errors = $count_errors + $count_retry;
758
+			if ($count_errors > 0) {
759
+				$error = true;
760
+				if ($count_errors > 1 && $count_retry > 1 && $count_queued > 1) {
761
+					$message = sprintf(
762
+						__(
763
+							'There were %d errors and %d messages successfully queued for generation and sending',
764
+							'event_espresso'
765
+						),
766
+						$count_errors,
767
+						$count_queued
768
+					);
769
+				} elseif ($count_errors > 1 && $count_queued === 1) {
770
+					$message = sprintf(
771
+						__(
772
+							'There were %d errors and %d message successfully queued for generation.',
773
+							'event_espresso'
774
+						),
775
+						$count_errors,
776
+						$count_queued
777
+					);
778
+				} elseif ($count_errors === 1 && $count_queued > 1) {
779
+					$message = sprintf(
780
+						__(
781
+							'There was %d error and %d messages successfully queued for generation.',
782
+							'event_espresso'
783
+						),
784
+						$count_errors,
785
+						$count_queued
786
+					);
787
+				} else {
788
+					$message = sprintf(
789
+						__(
790
+							'There was %d message that failed to be queued for generation.',
791
+							'event_espresso'
792
+						),
793
+						$count_errors
794
+					);
795
+				}
796
+				EE_Error::add_error($message, __FILE__, __FUNCTION__, __LINE__);
797
+			} else {
798
+				if ($count_queued === 1) {
799
+					$message = sprintf(
800
+						__(
801
+							'%d message successfully queued for generation.',
802
+							'event_espresso'
803
+						),
804
+						$count_queued
805
+					);
806
+				} else {
807
+					$message = sprintf(
808
+						__(
809
+							'%d messages were successfully queued for generation.',
810
+							'event_espresso'
811
+						),
812
+						$count_queued
813
+					);
814
+				}
815
+				EE_Error::add_success($message);
816
+			}
817
+		}
818
+		// if no error then return the generated message(s).
819
+		if (! $error && ! $send) {
820
+			$generated_queue = $processor->generate_queue(false);
821
+			// get message and return.
822
+			$generated_queue->get_message_repository()->rewind();
823
+			$messages = array();
824
+			while ($generated_queue->get_message_repository()->valid()) {
825
+				$message = $generated_queue->get_message_repository()->current();
826
+				if ($message instanceof EE_Message) {
827
+					// set properties that might be expected by add-ons (backward compat)
828
+					$message->content = $message->content();
829
+					$message->template_pack = $message->get_template_pack();
830
+					$message->template_variation = $message->get_template_pack_variation();
831
+					$messages[] = $message;
832
+				}
833
+				$generated_queue->get_message_repository()->next();
834
+			}
835
+			return $messages;
836
+		}
837
+		return $error ? false
838
+			: true; // yeah backwards eh?  Really what we're returning is if there is a total success for all the messages or not.  We'll modify this once we get message recording in place.
839
+	}
840
+
841
+
842
+	/**
843
+	 * @deprecated 4.9.0
844
+	 * @param  string $type      This should correspond with a valid message type
845
+	 * @param  string $context   This should correspond with a valid context for the message type
846
+	 * @param  string $messenger This should correspond with a valid messenger.
847
+	 * @param bool    $send      true we will do a test send using the messenger delivery, false we just do a regular
848
+	 *                           preview
849
+	 * @return string          The body of the message.
850
+	 */
851
+	public function preview_message($type, $context, $messenger, $send = false)
852
+	{
853
+		// EE_messages has been deprecated
854
+		$this->_class_is_deprecated(__FUNCTION__);
855
+		return EED_Messages::preview_message($type, $context, $messenger, $send);
856
+	}
857
+
858
+
859
+	/**
860
+	 * @since      4.5.0
861
+	 * @deprecated 4.9.0   Moved to EED_Messages Module
862
+	 * @param string   $messenger    a string matching a valid active messenger in the system
863
+	 * @param string   $message_type Although it seems contrary to the name of the method, a message type name is still
864
+	 *                               required to send along the message type to the messenger because this is used for
865
+	 *                               determining what specific variations might be loaded for the generated message.
866
+	 * @param stdClass $message      a stdClass object in the format expected by the messenger.
867
+	 *
868
+	 * @return bool          success or fail.
869
+	 */
870
+	public function send_message_with_messenger_only($messenger, $message_type, $message)
871
+	{
872
+		// EE_messages has been deprecated
873
+		$this->_class_is_deprecated(__FUNCTION__);
874
+		// setup for sending to new method.
875
+		/** @type EE_Messages_Queue $queue */
876
+		$queue = EE_Registry::instance()->load_lib('Messages_Queue');
877
+		// make sure we have a proper message object
878
+		if (! $message instanceof EE_Message && is_object($message) && isset($message->content)) {
879
+			$msg = EE_Message_Factory::create(
880
+				array(
881
+					'MSG_messenger'    => $messenger,
882
+					'MSG_message_type' => $message_type,
883
+					'MSG_content'      => $message->content,
884
+					'MSG_subject'      => $message->subject,
885
+				)
886
+			);
887
+		} else {
888
+			$msg = $message;
889
+		}
890
+		if (! $msg instanceof EE_Message) {
891
+			return false;
892
+		}
893
+		// make sure any content in a content property (if not empty) is set on the MSG_content.
894
+		if (! empty($msg->content)) {
895
+			$msg->set('MSG_content', $msg->content);
896
+		}
897
+		$queue->add($msg);
898
+		return EED_Messages::send_message_with_messenger_only($messenger, $message_type, $queue);
899
+	}
900
+
901
+
902
+	/**
903
+	 * @deprecated 4.9.0
904
+	 * @param         $messenger
905
+	 * @param  string $message_type message type that the templates are being created for
906
+	 * @param int     $GRP_ID
907
+	 * @param bool    $is_global
908
+	 * @return array|object if creation is successful then we return an array of info, otherwise an error_object is
909
+	 *                      returned.
910
+	 * @throws \EE_Error
911
+	 */
912
+	public function create_new_templates($messenger, $message_type, $GRP_ID = 0, $is_global = false)
913
+	{
914
+		// EE_messages has been deprecated
915
+		$this->_class_is_deprecated(__FUNCTION__);
916
+		EE_Registry::instance()->load_helper('MSG_Template');
917
+		return EEH_MSG_Template::create_new_templates($messenger, $message_type, $GRP_ID, $is_global);
918
+	}
919
+
920
+
921
+	/**
922
+	 * @deprecated 4.9.0
923
+	 * @param  string $messenger_name    name of EE_messenger
924
+	 * @param  string $message_type_name name of EE_message_type
925
+	 * @return array
926
+	 */
927
+	public function get_fields($messenger_name, $message_type_name)
928
+	{
929
+		// EE_messages has been deprecated
930
+		$this->_class_is_deprecated(__FUNCTION__);
931
+		EE_Registry::instance()->load_helper('MSG_Template');
932
+		return EEH_MSG_Template::get_fields($messenger_name, $message_type_name);
933
+	}
934
+
935
+
936
+	/**
937
+	 * @deprecated 4.9.0
938
+	 * @access     public
939
+	 * @param string $type                we can indicate just returning installed message types
940
+	 *                                    or messengers (or both) via this parameter.
941
+	 * @param bool   $skip_cache          if true then we skip the cache and retrieve via files.
942
+	 * @return array                    multidimensional array of messenger and message_type objects
943
+	 *                                    (messengers index, and message_type index);
944
+	 */
945
+	public function get_installed($type = 'all', $skip_cache = false)
946
+	{
947
+		// EE_messages has been deprecated
948
+		$this->_class_is_deprecated(__FUNCTION__);
949
+		if ($skip_cache) {
950
+			$this->_message_resource_manager->reset_active_messengers_and_message_types();
951
+		}
952
+		switch ($type) {
953
+			case 'messengers' :
954
+				return array(
955
+					'messenger' => $this->_message_resource_manager->installed_messengers(),
956
+				);
957
+				break;
958
+			case 'message_types' :
959
+				return array(
960
+					'message_type' => $this->_message_resource_manager->installed_message_types(),
961
+				);
962
+				break;
963
+			case 'all' :
964
+			default :
965
+				return array(
966
+					'messenger'    => $this->_message_resource_manager->installed_messengers(),
967
+					'message_type' => $this->_message_resource_manager->installed_message_types(),
968
+				);
969
+				break;
970
+		}
971
+	}
972
+
973
+
974
+	/**
975
+	 * @deprecated 4.9.0
976
+	 * @return \EE_messenger[]
977
+	 */
978
+	public function get_active_messengers()
979
+	{
980
+		// EE_messages has been deprecated
981
+		$this->_class_is_deprecated(__FUNCTION__);
982
+		return $this->_message_resource_manager->active_messengers();
983
+	}
984
+
985
+
986
+	/**
987
+	 * @deprecated 4.9.0
988
+	 * @return array array of message_type references (string)
989
+	 */
990
+	public function get_active_message_types()
991
+	{
992
+		// EE_messages has been deprecated
993
+		$this->_class_is_deprecated(__FUNCTION__);
994
+		return $this->_message_resource_manager->list_of_active_message_types();
995
+	}
996
+
997
+
998
+	/**
999
+	 * @deprecated 4.9.0
1000
+	 * @return EE_message_type[]
1001
+	 */
1002
+	public function get_active_message_type_objects()
1003
+	{
1004
+		// EE_messages has been deprecated
1005
+		$this->_class_is_deprecated(__FUNCTION__);
1006
+		return $this->_message_resource_manager->get_active_message_type_objects();
1007
+	}
1008
+
1009
+
1010
+	/**
1011
+	 * @deprecated 4.9.0
1012
+	 * @since      4.5.0
1013
+	 * @param string $messenger The messenger being checked
1014
+	 * @return EE_message_type[]    (or empty array if none present)
1015
+	 */
1016
+	public function get_active_message_types_per_messenger($messenger)
1017
+	{
1018
+		// EE_messages has been deprecated
1019
+		$this->_class_is_deprecated(__FUNCTION__);
1020
+		return $this->_message_resource_manager->get_active_message_types_for_messenger($messenger);
1021
+	}
1022
+
1023
+
1024
+	/**
1025
+	 * @deprecated 4.9.0
1026
+	 * @param string $messenger    The string should correspond to the messenger (message types are
1027
+	 * @param string $message_type The string should correspond to a message type.
1028
+	 * @return EE_message_type|null
1029
+	 */
1030
+	public function get_active_message_type($messenger, $message_type)
1031
+	{
1032
+		// EE_messages has been deprecated
1033
+		$this->_class_is_deprecated(__FUNCTION__);
1034
+		return $this->_message_resource_manager->get_active_message_type_for_messenger($messenger, $message_type);
1035
+	}
1036
+
1037
+
1038
+	/**
1039
+	 * @deprecated 4.9.0
1040
+	 * @return array|\EE_message_type[]
1041
+	 */
1042
+	public function get_installed_message_types()
1043
+	{
1044
+		// EE_messages has been deprecated
1045
+		$this->_class_is_deprecated(__FUNCTION__);
1046
+		return $this->_message_resource_manager->installed_message_types();
1047
+	}
1048
+
1049
+
1050
+	/**
1051
+	 * @deprecated 4.9.0
1052
+	 * @return array
1053
+	 */
1054
+	public function get_installed_messengers()
1055
+	{
1056
+		// EE_messages has been deprecated
1057
+		$this->_class_is_deprecated(__FUNCTION__);
1058
+		return $this->_message_resource_manager->installed_messengers();
1059
+	}
1060
+
1061
+
1062
+	/**
1063
+	 * @deprecated 4.9.0
1064
+	 * @param   bool $slugs_only Whether to return an array of just slugs and labels (true) or all contexts indexed by
1065
+	 *                           message type.
1066
+	 * @return array
1067
+	 */
1068
+	public function get_all_contexts($slugs_only = true)
1069
+	{
1070
+		// EE_messages has been deprecated
1071
+		$this->_class_is_deprecated(__FUNCTION__);
1072
+		return $this->_message_resource_manager->get_all_contexts($slugs_only);
1073
+	}
1074 1074
 
1075 1075
 
1076 1076
 }
@@ -1129,88 +1129,88 @@  discard block
 block discarded – undo
1129 1129
 
1130 1130
 
1131 1131
 add_filter(
1132
-    'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
1133
-    function ($event_list_iframe_css) {
1134
-        if (! has_filter('FHEE__EventsArchiveIframe__event_list_iframe__css')) {
1135
-            return $event_list_iframe_css;
1136
-        }
1137
-        deprecated_espresso_action_or_filter_doing_it_wrong(
1138
-            'FHEE__EventsArchiveIframe__event_list_iframe__css',
1139
-            'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
1140
-            '\EventEspresso\modules\events_archive\EventsArchiveIframe::display()',
1141
-            '4.9.14',
1142
-            '5.0.0',
1143
-            'filter'
1144
-        );
1145
-        return apply_filters(
1146
-            'FHEE__EventsArchiveIframe__event_list_iframe__css',
1147
-            $event_list_iframe_css
1148
-        );
1149
-    }
1132
+	'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
1133
+	function ($event_list_iframe_css) {
1134
+		if (! has_filter('FHEE__EventsArchiveIframe__event_list_iframe__css')) {
1135
+			return $event_list_iframe_css;
1136
+		}
1137
+		deprecated_espresso_action_or_filter_doing_it_wrong(
1138
+			'FHEE__EventsArchiveIframe__event_list_iframe__css',
1139
+			'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
1140
+			'\EventEspresso\modules\events_archive\EventsArchiveIframe::display()',
1141
+			'4.9.14',
1142
+			'5.0.0',
1143
+			'filter'
1144
+		);
1145
+		return apply_filters(
1146
+			'FHEE__EventsArchiveIframe__event_list_iframe__css',
1147
+			$event_list_iframe_css
1148
+		);
1149
+	}
1150 1150
 );
1151 1151
 add_filter(
1152
-    'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
1153
-    function ($event_list_iframe_js) {
1154
-        if (! has_filter('FHEE__EED_Ticket_Selector__ticket_selector_iframe__js')) {
1155
-            return $event_list_iframe_js;
1156
-        }
1157
-        deprecated_espresso_action_or_filter_doing_it_wrong(
1158
-            'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
1159
-            'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
1160
-            '\EventEspresso\modules\events_archive\EventsArchiveIframe::display()',
1161
-            '4.9.14',
1162
-            '5.0.0',
1163
-            'filter'
1164
-        );
1165
-        return apply_filters(
1166
-            'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
1167
-            $event_list_iframe_js
1168
-        );
1169
-    }
1152
+	'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
1153
+	function ($event_list_iframe_js) {
1154
+		if (! has_filter('FHEE__EED_Ticket_Selector__ticket_selector_iframe__js')) {
1155
+			return $event_list_iframe_js;
1156
+		}
1157
+		deprecated_espresso_action_or_filter_doing_it_wrong(
1158
+			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
1159
+			'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
1160
+			'\EventEspresso\modules\events_archive\EventsArchiveIframe::display()',
1161
+			'4.9.14',
1162
+			'5.0.0',
1163
+			'filter'
1164
+		);
1165
+		return apply_filters(
1166
+			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
1167
+			$event_list_iframe_js
1168
+		);
1169
+	}
1170 1170
 );
1171 1171
 add_action(
1172
-    'AHEE__EE_Capabilities__addCaps__complete',
1173
-    function ($capabilities_map) {
1174
-        if (! has_action('AHEE__EE_Capabilities__init_role_caps__complete')) {
1175
-            return;
1176
-        }
1177
-        deprecated_espresso_action_or_filter_doing_it_wrong(
1178
-            'AHEE__EE_Capabilities__init_role_caps__complete',
1179
-            'AHEE__EE_Capabilities__addCaps__complete',
1180
-            '\EE_Capabilities::addCaps()',
1181
-            '4.9.42',
1182
-            '5.0.0'
1183
-        );
1184
-        do_action(
1185
-            'AHEE__EE_Capabilities__init_role_caps__complete',
1186
-            $capabilities_map
1187
-        );
1188
-    }
1172
+	'AHEE__EE_Capabilities__addCaps__complete',
1173
+	function ($capabilities_map) {
1174
+		if (! has_action('AHEE__EE_Capabilities__init_role_caps__complete')) {
1175
+			return;
1176
+		}
1177
+		deprecated_espresso_action_or_filter_doing_it_wrong(
1178
+			'AHEE__EE_Capabilities__init_role_caps__complete',
1179
+			'AHEE__EE_Capabilities__addCaps__complete',
1180
+			'\EE_Capabilities::addCaps()',
1181
+			'4.9.42',
1182
+			'5.0.0'
1183
+		);
1184
+		do_action(
1185
+			'AHEE__EE_Capabilities__init_role_caps__complete',
1186
+			$capabilities_map
1187
+		);
1188
+	}
1189 1189
 );
1190 1190
 
1191 1191
 add_filter(
1192
-    'FHEE_EventEspresso_core_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee',
1193
-    function ($existing_attendee, $registration, $attendee_data) {
1194
-        if (! has_filter('FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee')) {
1195
-            return $existing_attendee;
1196
-        }
1197
-        deprecated_espresso_action_or_filter_doing_it_wrong(
1198
-            'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee',
1199
-            'FHEE_EventEspresso_core_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee',
1200
-            '\EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler::findExistingAttendee()',
1201
-            '4.9.34',
1202
-            '5.0.0',
1203
-            'filter'
1204
-        );
1205
-        return apply_filters(
1206
-            'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee',
1207
-            $existing_attendee,
1208
-            $registration,
1209
-            $attendee_data
1210
-        );
1211
-    },
1212
-    10,
1213
-    3
1192
+	'FHEE_EventEspresso_core_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee',
1193
+	function ($existing_attendee, $registration, $attendee_data) {
1194
+		if (! has_filter('FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee')) {
1195
+			return $existing_attendee;
1196
+		}
1197
+		deprecated_espresso_action_or_filter_doing_it_wrong(
1198
+			'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee',
1199
+			'FHEE_EventEspresso_core_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee',
1200
+			'\EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler::findExistingAttendee()',
1201
+			'4.9.34',
1202
+			'5.0.0',
1203
+			'filter'
1204
+		);
1205
+		return apply_filters(
1206
+			'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee',
1207
+			$existing_attendee,
1208
+			$registration,
1209
+			$attendee_data
1210
+		);
1211
+	},
1212
+	10,
1213
+	3
1214 1214
 );
1215 1215
 
1216 1216
 /**
@@ -1221,88 +1221,88 @@  discard block
 block discarded – undo
1221 1221
 class EE_Event_List_Query extends WP_Query
1222 1222
 {
1223 1223
 
1224
-    private $title;
1225
-
1226
-    private $css_class;
1227
-
1228
-    private $category_slug;
1229
-
1230
-    /**
1231
-     * EE_Event_List_Query constructor.
1232
-     *
1233
-     * @param array $args
1234
-     */
1235
-    public function __construct($args = array())
1236
-    {
1237
-        \EE_Error::doing_it_wrong(
1238
-            __METHOD__,
1239
-            __(
1240
-                'Usage is deprecated. Please use \EventEspresso\core\domain\services\wp_queries\EventListQuery instead.',
1241
-                'event_espresso'
1242
-            ),
1243
-            '4.9.27',
1244
-            '5.0.0'
1245
-        );
1246
-        $this->title = isset($args['title']) ? $args['title'] : '';
1247
-        $this->css_class = isset($args['css_class']) ? $args['css_class'] : '';
1248
-        $this->category_slug = isset($args['category_slug']) ? $args['category_slug'] : '';
1249
-        $limit = isset($args['limit']) && absint($args['limit']) ? $args['limit'] : 10;
1250
-        // the current "page" we are viewing
1251
-        $paged = max(1, get_query_var('paged'));
1252
-        // Force these args
1253
-        $args = array_merge(
1254
-            $args,
1255
-            array(
1256
-                'post_type'              => 'espresso_events',
1257
-                'posts_per_page'         => $limit,
1258
-                'update_post_term_cache' => false,
1259
-                'update_post_meta_cache' => false,
1260
-                'paged'                  => $paged,
1261
-                'offset'                 => ($paged - 1) * $limit,
1262
-            )
1263
-        );
1264
-        // run the query
1265
-        parent::__construct($args);
1266
-    }
1267
-
1268
-
1269
-    /**
1270
-     * event_list_title
1271
-     *
1272
-     * @param string $event_list_title
1273
-     * @return string
1274
-     */
1275
-    public function event_list_title($event_list_title = '')
1276
-    {
1277
-        if (! empty($this->title)) {
1278
-            return $this->title;
1279
-        }
1280
-        return $event_list_title;
1281
-    }
1282
-
1283
-
1284
-    /**
1285
-     * event_list_css
1286
-     *
1287
-     * @param string $event_list_css
1288
-     * @return string
1289
-     */
1290
-    public function event_list_css($event_list_css = '')
1291
-    {
1292
-        $event_list_css .= ! empty($event_list_css)
1293
-            ? ' '
1294
-            : '';
1295
-        $event_list_css .= ! empty($this->css_class)
1296
-            ? $this->css_class
1297
-            : '';
1298
-        $event_list_css .= ! empty($event_list_css)
1299
-            ? ' '
1300
-            : '';
1301
-        $event_list_css .= ! empty($this->category_slug)
1302
-            ? $this->category_slug
1303
-            : '';
1304
-        return $event_list_css;
1305
-    }
1224
+	private $title;
1225
+
1226
+	private $css_class;
1227
+
1228
+	private $category_slug;
1229
+
1230
+	/**
1231
+	 * EE_Event_List_Query constructor.
1232
+	 *
1233
+	 * @param array $args
1234
+	 */
1235
+	public function __construct($args = array())
1236
+	{
1237
+		\EE_Error::doing_it_wrong(
1238
+			__METHOD__,
1239
+			__(
1240
+				'Usage is deprecated. Please use \EventEspresso\core\domain\services\wp_queries\EventListQuery instead.',
1241
+				'event_espresso'
1242
+			),
1243
+			'4.9.27',
1244
+			'5.0.0'
1245
+		);
1246
+		$this->title = isset($args['title']) ? $args['title'] : '';
1247
+		$this->css_class = isset($args['css_class']) ? $args['css_class'] : '';
1248
+		$this->category_slug = isset($args['category_slug']) ? $args['category_slug'] : '';
1249
+		$limit = isset($args['limit']) && absint($args['limit']) ? $args['limit'] : 10;
1250
+		// the current "page" we are viewing
1251
+		$paged = max(1, get_query_var('paged'));
1252
+		// Force these args
1253
+		$args = array_merge(
1254
+			$args,
1255
+			array(
1256
+				'post_type'              => 'espresso_events',
1257
+				'posts_per_page'         => $limit,
1258
+				'update_post_term_cache' => false,
1259
+				'update_post_meta_cache' => false,
1260
+				'paged'                  => $paged,
1261
+				'offset'                 => ($paged - 1) * $limit,
1262
+			)
1263
+		);
1264
+		// run the query
1265
+		parent::__construct($args);
1266
+	}
1267
+
1268
+
1269
+	/**
1270
+	 * event_list_title
1271
+	 *
1272
+	 * @param string $event_list_title
1273
+	 * @return string
1274
+	 */
1275
+	public function event_list_title($event_list_title = '')
1276
+	{
1277
+		if (! empty($this->title)) {
1278
+			return $this->title;
1279
+		}
1280
+		return $event_list_title;
1281
+	}
1282
+
1283
+
1284
+	/**
1285
+	 * event_list_css
1286
+	 *
1287
+	 * @param string $event_list_css
1288
+	 * @return string
1289
+	 */
1290
+	public function event_list_css($event_list_css = '')
1291
+	{
1292
+		$event_list_css .= ! empty($event_list_css)
1293
+			? ' '
1294
+			: '';
1295
+		$event_list_css .= ! empty($this->css_class)
1296
+			? $this->css_class
1297
+			: '';
1298
+		$event_list_css .= ! empty($event_list_css)
1299
+			? ' '
1300
+			: '';
1301
+		$event_list_css .= ! empty($this->category_slug)
1302
+			? $this->category_slug
1303
+			: '';
1304
+		return $event_list_css;
1305
+	}
1306 1306
 
1307 1307
 }
1308 1308
 
@@ -1319,66 +1319,66 @@  discard block
 block discarded – undo
1319 1319
 {
1320 1320
 
1321 1321
 
1322
-    /**
1323
-     *    class constructor
1324
-     *
1325
-     * @deprecated 4.9.59.p
1326
-     */
1327
-    public function __construct()
1328
-    {
1329
-        EE_Error::doing_it_wrong(
1330
-            __METHOD__,
1331
-            sprintf(
1332
-                esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'),
1333
-                __CLASS__,
1334
-                'EventEspresso\core\services\licensing\LicenseServices'
1335
-            ),
1336
-            '4.9.59.p'
1337
-        );
1338
-    }
1339
-
1340
-
1341
-    /**
1342
-     * The purpose of this function is to display information about Event Espresso data collection
1343
-     * and a optin selection for extra data collecting by users.
1344
-     *
1345
-     * @param bool $extra
1346
-     * @return string html.
1347
-     * @deprecated 4.9.59.p
1348
-     */
1349
-    public static function espresso_data_collection_optin_text($extra = true)
1350
-    {
1351
-        EE_Error::doing_it_wrong(
1352
-            __METHOD__,
1353
-            sprintf(
1354
-                esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'),
1355
-                __METHOD__,
1356
-                'EventEspresso\core\domain\services\Stats::optinText'
1357
-            ),
1358
-            '4.9.59.p'
1359
-        );
1360
-        Stats::optinText($extra);
1361
-    }
1362
-
1363
-    /**
1364
-     * This is a handy helper method for retrieving whether there is an update available for the given plugin.
1365
-     *
1366
-     * @param  string $basename Use the equivalent result from plugin_basename() for this param as WP uses that to
1367
-     *                          identify plugins. Defaults to core update
1368
-     * @return boolean           True if update available, false if not.
1369
-     * @deprecated 4.9.59.p
1370
-     */
1371
-    public static function is_update_available($basename = '')
1372
-    {
1373
-        EE_Error::doing_it_wrong(
1374
-            __METHOD__,
1375
-            sprintf(
1376
-                esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'),
1377
-                __METHOD__,
1378
-                'EventEspresso\core\services\licensing\LicenseService::isUpdateAvailable'
1379
-            ),
1380
-            '4.9.59.p'
1381
-        );
1382
-        return LicenseService::isUpdateAvailable($basename);
1383
-    }
1322
+	/**
1323
+	 *    class constructor
1324
+	 *
1325
+	 * @deprecated 4.9.59.p
1326
+	 */
1327
+	public function __construct()
1328
+	{
1329
+		EE_Error::doing_it_wrong(
1330
+			__METHOD__,
1331
+			sprintf(
1332
+				esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'),
1333
+				__CLASS__,
1334
+				'EventEspresso\core\services\licensing\LicenseServices'
1335
+			),
1336
+			'4.9.59.p'
1337
+		);
1338
+	}
1339
+
1340
+
1341
+	/**
1342
+	 * The purpose of this function is to display information about Event Espresso data collection
1343
+	 * and a optin selection for extra data collecting by users.
1344
+	 *
1345
+	 * @param bool $extra
1346
+	 * @return string html.
1347
+	 * @deprecated 4.9.59.p
1348
+	 */
1349
+	public static function espresso_data_collection_optin_text($extra = true)
1350
+	{
1351
+		EE_Error::doing_it_wrong(
1352
+			__METHOD__,
1353
+			sprintf(
1354
+				esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'),
1355
+				__METHOD__,
1356
+				'EventEspresso\core\domain\services\Stats::optinText'
1357
+			),
1358
+			'4.9.59.p'
1359
+		);
1360
+		Stats::optinText($extra);
1361
+	}
1362
+
1363
+	/**
1364
+	 * This is a handy helper method for retrieving whether there is an update available for the given plugin.
1365
+	 *
1366
+	 * @param  string $basename Use the equivalent result from plugin_basename() for this param as WP uses that to
1367
+	 *                          identify plugins. Defaults to core update
1368
+	 * @return boolean           True if update available, false if not.
1369
+	 * @deprecated 4.9.59.p
1370
+	 */
1371
+	public static function is_update_available($basename = '')
1372
+	{
1373
+		EE_Error::doing_it_wrong(
1374
+			__METHOD__,
1375
+			sprintf(
1376
+				esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'),
1377
+				__METHOD__,
1378
+				'EventEspresso\core\services\licensing\LicenseService::isUpdateAvailable'
1379
+			),
1380
+			'4.9.59.p'
1381
+		);
1382
+		return LicenseService::isUpdateAvailable($basename);
1383
+	}
1384 1384
 }
1385 1385
\ No newline at end of file
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -38,103 +38,103 @@
 block discarded – undo
38 38
  * @since           4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
65
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
65
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                        esc_html__(
79
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                            'event_espresso'
81
-                        ),
82
-                        EE_MIN_PHP_VER_REQUIRED,
83
-                        PHP_VERSION,
84
-                        '<br/>',
85
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+						esc_html__(
79
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+							'event_espresso'
81
+						),
82
+						EE_MIN_PHP_VER_REQUIRED,
83
+						PHP_VERSION,
84
+						'<br/>',
85
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
-        /**
98
-         * espresso_version
99
-         * Returns the plugin version
100
-         *
101
-         * @return string
102
-         */
103
-        function espresso_version()
104
-        {
105
-            return apply_filters('FHEE__espresso__espresso_version', '4.9.66.rc.002');
106
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
+		/**
98
+		 * espresso_version
99
+		 * Returns the plugin version
100
+		 *
101
+		 * @return string
102
+		 */
103
+		function espresso_version()
104
+		{
105
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.66.rc.002');
106
+		}
107 107
 
108
-        /**
109
-         * espresso_plugin_activation
110
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
-         */
112
-        function espresso_plugin_activation()
113
-        {
114
-            update_option('ee_espresso_activation', true);
115
-        }
108
+		/**
109
+		 * espresso_plugin_activation
110
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
+		 */
112
+		function espresso_plugin_activation()
113
+		{
114
+			update_option('ee_espresso_activation', true);
115
+		}
116 116
 
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
120
-        bootstrap_espresso();
121
-    }
119
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
120
+		bootstrap_espresso();
121
+	}
122 122
 }
123 123
 if (! function_exists('espresso_deactivate_plugin')) {
124
-    /**
125
-     *    deactivate_plugin
126
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
-     *
128
-     * @access public
129
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
-     * @return    void
131
-     */
132
-    function espresso_deactivate_plugin($plugin_basename = '')
133
-    {
134
-        if (! function_exists('deactivate_plugins')) {
135
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
-        }
137
-        unset($_GET['activate'], $_REQUEST['activate']);
138
-        deactivate_plugins($plugin_basename);
139
-    }
124
+	/**
125
+	 *    deactivate_plugin
126
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
+	 *
128
+	 * @access public
129
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
+	 * @return    void
131
+	 */
132
+	function espresso_deactivate_plugin($plugin_basename = '')
133
+	{
134
+		if (! function_exists('deactivate_plugins')) {
135
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
+		}
137
+		unset($_GET['activate'], $_REQUEST['activate']);
138
+		deactivate_plugins($plugin_basename);
139
+	}
140 140
 }
Please login to merge, or discard this patch.
caffeinated/payment_methods/Aim/EEG_Aim.gateway.php 2 patches
Indentation   +605 added lines, -605 removed lines patch added patch discarded remove patch
@@ -25,427 +25,427 @@  discard block
 block discarded – undo
25 25
 class EEG_Aim extends EE_Onsite_Gateway
26 26
 {
27 27
 
28
-    const LIVE_URL    = 'https://secure2.authorize.net/gateway/transact.dll'; // Authnet URL
29
-
30
-    const SANDBOX_URL = 'https://test.authorize.net/gateway/transact.dll';
31
-
32
-    protected $_login_id;
33
-
34
-    protected $_transaction_key;
35
-
36
-    protected $_server;
37
-
38
-    protected $_currencies_supported = array(
39
-        'AUD',
40
-        'USD',
41
-        'CAD',
42
-        'EUR',
43
-        'GBP',
44
-        'NZD',
45
-    );
46
-
47
-    /**
48
-     * Whether to send test transactions (even to live site)
49
-     *
50
-     * @var boolean
51
-     */
52
-    protected $_test_transactions;
53
-
54
-    private $VERIFY_PEER = false;
55
-
56
-    private $_x_post_fields = array(
57
-        "version"        => "3.1",
58
-        "delim_char"     => ",",
59
-        "delim_data"     => "TRUE",
60
-        "relay_response" => "FALSE",
61
-        "encap_char"     => "|",
62
-    );
63
-
64
-    private $_additional_line_items = array();
65
-
66
-    /**
67
-     * A list of all fields in the AIM API.
68
-     * Used to warn user if they try to set a field not offered in the API.
69
-     */
70
-    private $_all_aim_fields = array(
71
-        "address",
72
-        "allow_partial_auth",
73
-        "amount",
74
-        "auth_code",
75
-        "authentication_indicator",
76
-        "bank_aba_code",
77
-        "bank_acct_name",
78
-        "bank_acct_num",
79
-        "bank_acct_type",
80
-        "bank_check_number",
81
-        "bank_name",
82
-        "card_code",
83
-        "card_num",
84
-        "cardholder_authentication_value",
85
-        "city",
86
-        "company",
87
-        "country",
88
-        "cust_id",
89
-        "customer_ip",
90
-        "delim_char",
91
-        "delim_data",
92
-        "description",
93
-        "duplicate_window",
94
-        "duty",
95
-        "echeck_type",
96
-        "email",
97
-        "email_customer",
98
-        "encap_char",
99
-        "exp_date",
100
-        "fax",
101
-        "first_name",
102
-        "footer_email_receipt",
103
-        "freight",
104
-        "header_email_receipt",
105
-        "invoice_num",
106
-        "last_name",
107
-        "line_item",
108
-        "login",
109
-        "method",
110
-        "phone",
111
-        "po_num",
112
-        "recurring_billing",
113
-        "relay_response",
114
-        "ship_to_address",
115
-        "ship_to_city",
116
-        "ship_to_company",
117
-        "ship_to_country",
118
-        "ship_to_first_name",
119
-        "ship_to_last_name",
120
-        "ship_to_state",
121
-        "ship_to_zip",
122
-        "split_tender_id",
123
-        "state",
124
-        "tax",
125
-        "tax_exempt",
126
-        "test_request",
127
-        "tran_key",
128
-        "trans_id",
129
-        "type",
130
-        "version",
131
-        "zip",
132
-        "solution_id",
133
-        "currency_code"
134
-    );
135
-
136
-
137
-    /**
138
-     * Gets the URL where the request should go. This is filterable
139
-     *
140
-     * @return string
141
-     */
142
-    protected function _get_server_url()
143
-    {
144
-        return apply_filters(
145
-            'FHEE__EEG_Aim___get_server_url',
146
-            $this->_debug_mode ? self::SANDBOX_URL : self::LIVE_URL,
147
-            $this
148
-        );
149
-    }
150
-
151
-
152
-    /**
153
-     * TEMPORARY CALLBACK! Do not use
154
-     * Callback which filters the server url. This is added so site admins can revert to using
155
-     * the old AIM server in case Akamai service breaks their integration.
156
-     * Using Akamai will, however, be mandatory on June 30th 2016 Authorize.net
157
-     * (see http://www.authorize.net/support/akamaifaqs/#firewall?utm_campaign=April%202016%20Technical%20Updates%20for%20Merchants.html&utm_medium=email&utm_source=Eloqua&elqTrackId=46103bdc375c411a979c2f658fc99074&elq=7026706360154fee9b6d588b27d8eb6a&elqaid=506&elqat=1&elqCampaignId=343)
158
-     * Once that happens, this will be obsolete and WILL BE REMOVED.
159
-     *
160
-     * @param string $url
161
-     * @param EEG_Aim $gateway_object
162
-     * @return string
163
-     */
164
-    public function possibly_use_deprecated_aim_server($url, EEG_Aim $gateway_object)
165
-    {
166
-        if ($gateway_object->_server === 'authorize.net' && ! $gateway_object->_debug_mode) {
167
-            return 'https://secure.authorize.net/gateway/transact.dll';
168
-        } else {
169
-            return $url;
170
-        }
171
-    }
172
-
173
-
174
-    /**
175
-     * Asks the gateway to do whatever it does to process the payment. Onsite gateways will
176
-     * usually send a request directly to the payment provider and update the payment's status based on that;
177
-     * whereas offsite gateways will usually just update the payment with the URL and query parameters to use
178
-     * for sending the request via http_remote_request()
179
-     *
180
-     * @param EEI_Payment $payment
181
-     * @param array $billing_info {
182
-     *  @type $credit_card string
183
-     *  @type $cvv string
184
-     *  @type $exp_month string
185
-     *  @type $exp_year string
186
-     *  @see parent::do_direct_payment
187
-     * }
188
-     * @return EEI_Payment updated
189
-     */
190
-    public function do_direct_payment($payment, $billing_info = null)
191
-    {
192
-        add_filter('FHEE__EEG_Aim___get_server_url', array($this, 'possibly_use_deprecated_aim_server'), 10, 2);
193
-        // Enable test mode if needed
194
-        // 4007000000027  <-- test successful visa
195
-        // 4222222222222  <-- test failure card number
196
-
197
-        $item_num = 1;
198
-        $transaction = $payment->transaction();
199
-        $gateway_formatter = $this->_get_gateway_formatter();
200
-        $order_description = $gateway_formatter->formatOrderDescription($payment);
201
-        $primary_registrant = $transaction->primary_registration();
202
-        // if we're are charging for the full amount, show the normal line items
203
-        // and the itemized total adds up properly
204
-        if ($this->_can_easily_itemize_transaction_for($payment)) {
205
-            $total_line_item = $transaction->total_line_item();
206
-            foreach ($total_line_item->get_items() as $line_item) {
207
-                if ($line_item->quantity() == 0) {
208
-                    continue;
209
-                }
210
-                $this->addLineItem(
211
-                    $item_num++,
212
-                    $gateway_formatter->formatLineItemName($line_item, $payment),
213
-                    $gateway_formatter->formatLineItemDesc($line_item, $payment),
214
-                    $line_item->quantity(),
215
-                    $line_item->unit_price(),
216
-                    'N'
217
-                );
218
-                $order_description .= $line_item->desc().', ';
219
-            }
220
-            foreach ($total_line_item->tax_descendants() as $tax_line_item) {
221
-                $this->addLineItem(
222
-                    $item_num++,
223
-                    $tax_line_item->name(),
224
-                    $tax_line_item->desc(),
225
-                    1,
226
-                    $tax_line_item->total(),
227
-                    'N'
228
-                );
229
-            }
230
-        }
231
-
232
-        // start transaction
233
-        // if in debug mode, use authorize.net's sandbox id; otherwise use the Event Espresso partner id
234
-        $partner_id = $this->_debug_mode ? 'AAA100302' : 'AAA105363';
235
-        $this->setField('solution_id', $partner_id);
236
-        $this->setField('amount', $gateway_formatter->formatCurrency($payment->amount()));
237
-        $this->setField('description', substr(rtrim($order_description, ', '), 0, 255));
238
-        $this->_set_sensitive_billing_data($billing_info);
239
-        $this->setField('first_name', $billing_info['first_name']);
240
-        $this->setField('last_name', $billing_info['last_name']);
241
-        $this->setField('email', $billing_info['email']);
242
-        $this->setField('company', $billing_info['company']);
243
-        $this->setField('address', $billing_info['address'].' '.$billing_info['address2']);
244
-        $this->setField('city', $billing_info['city']);
245
-        $this->setField('state', $billing_info['state']);
246
-        $this->setField('country', $billing_info['country']);
247
-        $this->setField('zip', $billing_info['zip']);
248
-        $this->setField('fax', $billing_info['fax']);
249
-        $this->setField('cust_id', $primary_registrant->ID());
250
-        $this->setField('phone', $billing_info['phone']);
251
-        $currency_config = LoaderFactory::getLoader()->load('EE_Currency_Config');
252
-        $this->setField('currency_code',$currency_config->code);
253
-        // invoice_num would be nice to have it be unique per SPCO page-load, that way if users
254
-        // press back, they don't submit a duplicate. However, we may be keeping the user on teh same spco page
255
-        // in which case, we need to generate teh invoice num per request right here...
256
-        $this->setField('invoice_num', wp_generate_password(12, false));// $billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']);
257
-        // tell AIM that any duplicates sent in the next 5 minutes are to be ignored
258
-        $this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS);
259
-
260
-        if ($this->_test_transactions) {
261
-            $this->test_request = "true";
262
-        }
263
-
264
-        // Capture response
265
-        $this->type = "AUTH_CAPTURE";
266
-        $response = $this->_sendRequest($payment);
267
-        if (! empty($response)) {
268
-            if ($response->error_message) {
269
-                $payment->set_status($this->_pay_model->failed_status());
270
-                $payment->set_gateway_response($response->error_message);
271
-            } else {
272
-                $payment_status = $response->approved
273
-                    ? $this->_pay_model->approved_status()
274
-                    : $this->_pay_model->declined_status();
275
-                $payment->set_status($payment_status);
276
-                // make sure we interpret the AMT as a float, not an international string (where periods are thousand separators)
277
-                $payment->set_amount((float) $response->amount);
278
-                $payment->set_gateway_response(
279
-                    sprintf(
280
-                        esc_html__('%1$s (Reason Code: %2$s)', 'event_espresso'),
281
-                        $response->response_reason_text,
282
-                        $response->response_reason_code
283
-                    )
284
-                );
285
-                if ($this->_debug_mode) {
286
-                    $txn_id = $response->invoice_number;
287
-                } else {
288
-                    $txn_id = $response->transaction_id;
289
-                }
290
-                $payment->set_txn_id_chq_nmbr($txn_id);
291
-            }
292
-            $payment->set_extra_accntng($primary_registrant->reg_code());
293
-            $payment->set_details(print_r($response, true));
294
-        } else {
295
-            $payment->set_status($this->_pay_model->failed_status());
296
-            $payment->set_gateway_response(__("There was no response from Authorize.net", 'event_espresso'));
297
-            $payment->set_details(print_r($response, true));
298
-        }
299
-        return $payment;
300
-    }
301
-
302
-
303
-    /**
304
-     * Sets billing data for the upcoming request to AIM that is considered sensitive;
305
-     * also this method can be overridden by children classes to easily change
306
-     * what billing data gets sent
307
-     *
308
-     * @param array $billing_info
309
-     */
310
-    protected function _set_sensitive_billing_data($billing_info)
311
-    {
312
-        $this->setField('card_num', $billing_info['credit_card']);
313
-        $this->setField('exp_date', $billing_info['exp_month'] . $billing_info['exp_year']);
314
-        $this->setField('card_code', $billing_info['cvv']);
315
-    }
316
-
317
-
318
-    /**
319
-     * Add a line item.
320
-     *
321
-     * @param string $item_id
322
-     * @param string $item_name
323
-     * @param string $item_description
324
-     * @param string $item_quantity
325
-     * @param string $item_unit_price
326
-     * @param string $item_taxable
327
-     */
328
-    public function addLineItem($item_id, $item_name, $item_description, $item_quantity, $item_unit_price, $item_taxable)
329
-    {
330
-        $args = array(
331
-            substr($item_id, 0, 31),
332
-            substr($item_name, 0, 31),
333
-            substr($item_description, 0, 255),
334
-            number_format(abs($item_quantity), 2, '.', ''),
335
-            number_format(abs($item_unit_price), 2, '.', ''),
336
-            $item_taxable === 'N' ? 'N' : 'Y'
337
-        );
338
-        $this->_additional_line_items[] = implode('<|>', $args);
339
-    }
340
-
341
-
342
-    /**
343
-     * Set an individual name/value pair. This will append x_ to the name
344
-     * before posting.
345
-     *
346
-     * @param string $name
347
-     * @param string $value
348
-     * @throws AuthorizeNetException
349
-     */
350
-    protected function setField($name, $value)
351
-    {
352
-        if (in_array($name, $this->_all_aim_fields)) {
353
-            $this->_x_post_fields[ $name ] = $value;
354
-        } else {
355
-            throw new AuthorizeNetException("Error: no field $name exists in the AIM API.
28
+	const LIVE_URL    = 'https://secure2.authorize.net/gateway/transact.dll'; // Authnet URL
29
+
30
+	const SANDBOX_URL = 'https://test.authorize.net/gateway/transact.dll';
31
+
32
+	protected $_login_id;
33
+
34
+	protected $_transaction_key;
35
+
36
+	protected $_server;
37
+
38
+	protected $_currencies_supported = array(
39
+		'AUD',
40
+		'USD',
41
+		'CAD',
42
+		'EUR',
43
+		'GBP',
44
+		'NZD',
45
+	);
46
+
47
+	/**
48
+	 * Whether to send test transactions (even to live site)
49
+	 *
50
+	 * @var boolean
51
+	 */
52
+	protected $_test_transactions;
53
+
54
+	private $VERIFY_PEER = false;
55
+
56
+	private $_x_post_fields = array(
57
+		"version"        => "3.1",
58
+		"delim_char"     => ",",
59
+		"delim_data"     => "TRUE",
60
+		"relay_response" => "FALSE",
61
+		"encap_char"     => "|",
62
+	);
63
+
64
+	private $_additional_line_items = array();
65
+
66
+	/**
67
+	 * A list of all fields in the AIM API.
68
+	 * Used to warn user if they try to set a field not offered in the API.
69
+	 */
70
+	private $_all_aim_fields = array(
71
+		"address",
72
+		"allow_partial_auth",
73
+		"amount",
74
+		"auth_code",
75
+		"authentication_indicator",
76
+		"bank_aba_code",
77
+		"bank_acct_name",
78
+		"bank_acct_num",
79
+		"bank_acct_type",
80
+		"bank_check_number",
81
+		"bank_name",
82
+		"card_code",
83
+		"card_num",
84
+		"cardholder_authentication_value",
85
+		"city",
86
+		"company",
87
+		"country",
88
+		"cust_id",
89
+		"customer_ip",
90
+		"delim_char",
91
+		"delim_data",
92
+		"description",
93
+		"duplicate_window",
94
+		"duty",
95
+		"echeck_type",
96
+		"email",
97
+		"email_customer",
98
+		"encap_char",
99
+		"exp_date",
100
+		"fax",
101
+		"first_name",
102
+		"footer_email_receipt",
103
+		"freight",
104
+		"header_email_receipt",
105
+		"invoice_num",
106
+		"last_name",
107
+		"line_item",
108
+		"login",
109
+		"method",
110
+		"phone",
111
+		"po_num",
112
+		"recurring_billing",
113
+		"relay_response",
114
+		"ship_to_address",
115
+		"ship_to_city",
116
+		"ship_to_company",
117
+		"ship_to_country",
118
+		"ship_to_first_name",
119
+		"ship_to_last_name",
120
+		"ship_to_state",
121
+		"ship_to_zip",
122
+		"split_tender_id",
123
+		"state",
124
+		"tax",
125
+		"tax_exempt",
126
+		"test_request",
127
+		"tran_key",
128
+		"trans_id",
129
+		"type",
130
+		"version",
131
+		"zip",
132
+		"solution_id",
133
+		"currency_code"
134
+	);
135
+
136
+
137
+	/**
138
+	 * Gets the URL where the request should go. This is filterable
139
+	 *
140
+	 * @return string
141
+	 */
142
+	protected function _get_server_url()
143
+	{
144
+		return apply_filters(
145
+			'FHEE__EEG_Aim___get_server_url',
146
+			$this->_debug_mode ? self::SANDBOX_URL : self::LIVE_URL,
147
+			$this
148
+		);
149
+	}
150
+
151
+
152
+	/**
153
+	 * TEMPORARY CALLBACK! Do not use
154
+	 * Callback which filters the server url. This is added so site admins can revert to using
155
+	 * the old AIM server in case Akamai service breaks their integration.
156
+	 * Using Akamai will, however, be mandatory on June 30th 2016 Authorize.net
157
+	 * (see http://www.authorize.net/support/akamaifaqs/#firewall?utm_campaign=April%202016%20Technical%20Updates%20for%20Merchants.html&utm_medium=email&utm_source=Eloqua&elqTrackId=46103bdc375c411a979c2f658fc99074&elq=7026706360154fee9b6d588b27d8eb6a&elqaid=506&elqat=1&elqCampaignId=343)
158
+	 * Once that happens, this will be obsolete and WILL BE REMOVED.
159
+	 *
160
+	 * @param string $url
161
+	 * @param EEG_Aim $gateway_object
162
+	 * @return string
163
+	 */
164
+	public function possibly_use_deprecated_aim_server($url, EEG_Aim $gateway_object)
165
+	{
166
+		if ($gateway_object->_server === 'authorize.net' && ! $gateway_object->_debug_mode) {
167
+			return 'https://secure.authorize.net/gateway/transact.dll';
168
+		} else {
169
+			return $url;
170
+		}
171
+	}
172
+
173
+
174
+	/**
175
+	 * Asks the gateway to do whatever it does to process the payment. Onsite gateways will
176
+	 * usually send a request directly to the payment provider and update the payment's status based on that;
177
+	 * whereas offsite gateways will usually just update the payment with the URL and query parameters to use
178
+	 * for sending the request via http_remote_request()
179
+	 *
180
+	 * @param EEI_Payment $payment
181
+	 * @param array $billing_info {
182
+	 *  @type $credit_card string
183
+	 *  @type $cvv string
184
+	 *  @type $exp_month string
185
+	 *  @type $exp_year string
186
+	 *  @see parent::do_direct_payment
187
+	 * }
188
+	 * @return EEI_Payment updated
189
+	 */
190
+	public function do_direct_payment($payment, $billing_info = null)
191
+	{
192
+		add_filter('FHEE__EEG_Aim___get_server_url', array($this, 'possibly_use_deprecated_aim_server'), 10, 2);
193
+		// Enable test mode if needed
194
+		// 4007000000027  <-- test successful visa
195
+		// 4222222222222  <-- test failure card number
196
+
197
+		$item_num = 1;
198
+		$transaction = $payment->transaction();
199
+		$gateway_formatter = $this->_get_gateway_formatter();
200
+		$order_description = $gateway_formatter->formatOrderDescription($payment);
201
+		$primary_registrant = $transaction->primary_registration();
202
+		// if we're are charging for the full amount, show the normal line items
203
+		// and the itemized total adds up properly
204
+		if ($this->_can_easily_itemize_transaction_for($payment)) {
205
+			$total_line_item = $transaction->total_line_item();
206
+			foreach ($total_line_item->get_items() as $line_item) {
207
+				if ($line_item->quantity() == 0) {
208
+					continue;
209
+				}
210
+				$this->addLineItem(
211
+					$item_num++,
212
+					$gateway_formatter->formatLineItemName($line_item, $payment),
213
+					$gateway_formatter->formatLineItemDesc($line_item, $payment),
214
+					$line_item->quantity(),
215
+					$line_item->unit_price(),
216
+					'N'
217
+				);
218
+				$order_description .= $line_item->desc().', ';
219
+			}
220
+			foreach ($total_line_item->tax_descendants() as $tax_line_item) {
221
+				$this->addLineItem(
222
+					$item_num++,
223
+					$tax_line_item->name(),
224
+					$tax_line_item->desc(),
225
+					1,
226
+					$tax_line_item->total(),
227
+					'N'
228
+				);
229
+			}
230
+		}
231
+
232
+		// start transaction
233
+		// if in debug mode, use authorize.net's sandbox id; otherwise use the Event Espresso partner id
234
+		$partner_id = $this->_debug_mode ? 'AAA100302' : 'AAA105363';
235
+		$this->setField('solution_id', $partner_id);
236
+		$this->setField('amount', $gateway_formatter->formatCurrency($payment->amount()));
237
+		$this->setField('description', substr(rtrim($order_description, ', '), 0, 255));
238
+		$this->_set_sensitive_billing_data($billing_info);
239
+		$this->setField('first_name', $billing_info['first_name']);
240
+		$this->setField('last_name', $billing_info['last_name']);
241
+		$this->setField('email', $billing_info['email']);
242
+		$this->setField('company', $billing_info['company']);
243
+		$this->setField('address', $billing_info['address'].' '.$billing_info['address2']);
244
+		$this->setField('city', $billing_info['city']);
245
+		$this->setField('state', $billing_info['state']);
246
+		$this->setField('country', $billing_info['country']);
247
+		$this->setField('zip', $billing_info['zip']);
248
+		$this->setField('fax', $billing_info['fax']);
249
+		$this->setField('cust_id', $primary_registrant->ID());
250
+		$this->setField('phone', $billing_info['phone']);
251
+		$currency_config = LoaderFactory::getLoader()->load('EE_Currency_Config');
252
+		$this->setField('currency_code',$currency_config->code);
253
+		// invoice_num would be nice to have it be unique per SPCO page-load, that way if users
254
+		// press back, they don't submit a duplicate. However, we may be keeping the user on teh same spco page
255
+		// in which case, we need to generate teh invoice num per request right here...
256
+		$this->setField('invoice_num', wp_generate_password(12, false));// $billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']);
257
+		// tell AIM that any duplicates sent in the next 5 minutes are to be ignored
258
+		$this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS);
259
+
260
+		if ($this->_test_transactions) {
261
+			$this->test_request = "true";
262
+		}
263
+
264
+		// Capture response
265
+		$this->type = "AUTH_CAPTURE";
266
+		$response = $this->_sendRequest($payment);
267
+		if (! empty($response)) {
268
+			if ($response->error_message) {
269
+				$payment->set_status($this->_pay_model->failed_status());
270
+				$payment->set_gateway_response($response->error_message);
271
+			} else {
272
+				$payment_status = $response->approved
273
+					? $this->_pay_model->approved_status()
274
+					: $this->_pay_model->declined_status();
275
+				$payment->set_status($payment_status);
276
+				// make sure we interpret the AMT as a float, not an international string (where periods are thousand separators)
277
+				$payment->set_amount((float) $response->amount);
278
+				$payment->set_gateway_response(
279
+					sprintf(
280
+						esc_html__('%1$s (Reason Code: %2$s)', 'event_espresso'),
281
+						$response->response_reason_text,
282
+						$response->response_reason_code
283
+					)
284
+				);
285
+				if ($this->_debug_mode) {
286
+					$txn_id = $response->invoice_number;
287
+				} else {
288
+					$txn_id = $response->transaction_id;
289
+				}
290
+				$payment->set_txn_id_chq_nmbr($txn_id);
291
+			}
292
+			$payment->set_extra_accntng($primary_registrant->reg_code());
293
+			$payment->set_details(print_r($response, true));
294
+		} else {
295
+			$payment->set_status($this->_pay_model->failed_status());
296
+			$payment->set_gateway_response(__("There was no response from Authorize.net", 'event_espresso'));
297
+			$payment->set_details(print_r($response, true));
298
+		}
299
+		return $payment;
300
+	}
301
+
302
+
303
+	/**
304
+	 * Sets billing data for the upcoming request to AIM that is considered sensitive;
305
+	 * also this method can be overridden by children classes to easily change
306
+	 * what billing data gets sent
307
+	 *
308
+	 * @param array $billing_info
309
+	 */
310
+	protected function _set_sensitive_billing_data($billing_info)
311
+	{
312
+		$this->setField('card_num', $billing_info['credit_card']);
313
+		$this->setField('exp_date', $billing_info['exp_month'] . $billing_info['exp_year']);
314
+		$this->setField('card_code', $billing_info['cvv']);
315
+	}
316
+
317
+
318
+	/**
319
+	 * Add a line item.
320
+	 *
321
+	 * @param string $item_id
322
+	 * @param string $item_name
323
+	 * @param string $item_description
324
+	 * @param string $item_quantity
325
+	 * @param string $item_unit_price
326
+	 * @param string $item_taxable
327
+	 */
328
+	public function addLineItem($item_id, $item_name, $item_description, $item_quantity, $item_unit_price, $item_taxable)
329
+	{
330
+		$args = array(
331
+			substr($item_id, 0, 31),
332
+			substr($item_name, 0, 31),
333
+			substr($item_description, 0, 255),
334
+			number_format(abs($item_quantity), 2, '.', ''),
335
+			number_format(abs($item_unit_price), 2, '.', ''),
336
+			$item_taxable === 'N' ? 'N' : 'Y'
337
+		);
338
+		$this->_additional_line_items[] = implode('<|>', $args);
339
+	}
340
+
341
+
342
+	/**
343
+	 * Set an individual name/value pair. This will append x_ to the name
344
+	 * before posting.
345
+	 *
346
+	 * @param string $name
347
+	 * @param string $value
348
+	 * @throws AuthorizeNetException
349
+	 */
350
+	protected function setField($name, $value)
351
+	{
352
+		if (in_array($name, $this->_all_aim_fields)) {
353
+			$this->_x_post_fields[ $name ] = $value;
354
+		} else {
355
+			throw new AuthorizeNetException("Error: no field $name exists in the AIM API.
356 356
             To set a custom field use setCustomField('field','value') instead.");
357
-        }
358
-    }
359
-
360
-
361
-    /**
362
-     * Posts the request to AuthorizeNet & returns response.
363
-     *
364
-     * @param $payment
365
-     * @return \EE_AuthorizeNetAIM_Response
366
-     */
367
-    private function _sendRequest($payment)
368
-    {
369
-        $this->_x_post_fields['login'] = $this->_login_id;
370
-        $this->_x_post_fields['tran_key'] = $this->_transaction_key;
371
-        $x_keys = array();
372
-        foreach ($this->_x_post_fields as $key => $value) {
373
-            $x_keys[] = "x_$key=" . urlencode($this->_get_unsupported_character_remover()->format($value));
374
-        }
375
-        // Add line items
376
-        foreach ($this->_additional_line_items as $key => $value) {
377
-            $x_keys[] =  "x_line_item=" . urlencode($this->_get_unsupported_character_remover()->format($value));
378
-        }
379
-        $this->_log_clean_request($x_keys, $payment);
380
-        $post_url = $this->_get_server_url();
381
-        $curl_request = curl_init($post_url);
382
-        $post_body = implode("&", $x_keys);
383
-        curl_setopt($curl_request, CURLOPT_POSTFIELDS, $post_body);
384
-        curl_setopt($curl_request, CURLOPT_HEADER, 0);
385
-        curl_setopt($curl_request, CURLOPT_TIMEOUT, 45);
386
-        curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1);
387
-        curl_setopt($curl_request, CURLOPT_SSL_VERIFYHOST, 2);
388
-        if ($this->VERIFY_PEER) {
389
-            curl_setopt($curl_request, CURLOPT_CAINFO, dirname(__DIR__) . '/ssl/cert.pem');
390
-        } else {
391
-            curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false);
392
-        }
393
-
394
-        if (preg_match('/xml/', $post_url)) {
395
-            curl_setopt($curl_request, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
396
-        }
397
-
398
-        $response = curl_exec($curl_request);
399
-
400
-        curl_close($curl_request);
401
-        $response_obj =  new EE_AuthorizeNetAIM_Response($response);
402
-
403
-        return $this->_log_and_clean_response($response_obj, $payment);
404
-    }
405
-
406
-
407
-    /**
408
-     * Logs the clean data only
409
-     *
410
-     * @param array $request_array
411
-     * @param EEI_Payment $payment
412
-     */
413
-    protected function _log_clean_request($request_array, $payment)
414
-    {
415
-        $keys_to_filter_out = array('x_card_num', 'x_card_code', 'x_exp_date');
416
-        foreach ($request_array as $index => $keyvaltogether) {
417
-            foreach ($keys_to_filter_out as $key) {
418
-                if (strpos($keyvaltogether, $key) === 0) {
419
-                    // found it at the first character
420
-                    // so its one of them
421
-                    unset($request_array[ $index ]);
422
-                }
423
-            }
424
-        }
425
-        $this->log(
426
-            array(
427
-                'AIM Request sent:' => $request_array,
428
-                'Server URL'        => $this->_get_server_url()
429
-            ),
430
-            $payment
431
-        );
432
-    }
433
-
434
-
435
-
436
-    /**
437
-     * Logs the response and cleans it
438
-     *
439
-     * @param EE_AuthorizeNetAIM_Response $response_obj
440
-     * @param EE_Payment                  $payment
441
-     * @return \EE_AuthorizeNetAIM_Response
442
-     */
443
-    private function _log_and_clean_response($response_obj, $payment)
444
-    {
445
-        $response_obj->account_number = '';
446
-        $this->log(array('AIM Response received:' => (array) $response_obj), $payment);
447
-        return $response_obj;
448
-    }
357
+		}
358
+	}
359
+
360
+
361
+	/**
362
+	 * Posts the request to AuthorizeNet & returns response.
363
+	 *
364
+	 * @param $payment
365
+	 * @return \EE_AuthorizeNetAIM_Response
366
+	 */
367
+	private function _sendRequest($payment)
368
+	{
369
+		$this->_x_post_fields['login'] = $this->_login_id;
370
+		$this->_x_post_fields['tran_key'] = $this->_transaction_key;
371
+		$x_keys = array();
372
+		foreach ($this->_x_post_fields as $key => $value) {
373
+			$x_keys[] = "x_$key=" . urlencode($this->_get_unsupported_character_remover()->format($value));
374
+		}
375
+		// Add line items
376
+		foreach ($this->_additional_line_items as $key => $value) {
377
+			$x_keys[] =  "x_line_item=" . urlencode($this->_get_unsupported_character_remover()->format($value));
378
+		}
379
+		$this->_log_clean_request($x_keys, $payment);
380
+		$post_url = $this->_get_server_url();
381
+		$curl_request = curl_init($post_url);
382
+		$post_body = implode("&", $x_keys);
383
+		curl_setopt($curl_request, CURLOPT_POSTFIELDS, $post_body);
384
+		curl_setopt($curl_request, CURLOPT_HEADER, 0);
385
+		curl_setopt($curl_request, CURLOPT_TIMEOUT, 45);
386
+		curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1);
387
+		curl_setopt($curl_request, CURLOPT_SSL_VERIFYHOST, 2);
388
+		if ($this->VERIFY_PEER) {
389
+			curl_setopt($curl_request, CURLOPT_CAINFO, dirname(__DIR__) . '/ssl/cert.pem');
390
+		} else {
391
+			curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false);
392
+		}
393
+
394
+		if (preg_match('/xml/', $post_url)) {
395
+			curl_setopt($curl_request, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
396
+		}
397
+
398
+		$response = curl_exec($curl_request);
399
+
400
+		curl_close($curl_request);
401
+		$response_obj =  new EE_AuthorizeNetAIM_Response($response);
402
+
403
+		return $this->_log_and_clean_response($response_obj, $payment);
404
+	}
405
+
406
+
407
+	/**
408
+	 * Logs the clean data only
409
+	 *
410
+	 * @param array $request_array
411
+	 * @param EEI_Payment $payment
412
+	 */
413
+	protected function _log_clean_request($request_array, $payment)
414
+	{
415
+		$keys_to_filter_out = array('x_card_num', 'x_card_code', 'x_exp_date');
416
+		foreach ($request_array as $index => $keyvaltogether) {
417
+			foreach ($keys_to_filter_out as $key) {
418
+				if (strpos($keyvaltogether, $key) === 0) {
419
+					// found it at the first character
420
+					// so its one of them
421
+					unset($request_array[ $index ]);
422
+				}
423
+			}
424
+		}
425
+		$this->log(
426
+			array(
427
+				'AIM Request sent:' => $request_array,
428
+				'Server URL'        => $this->_get_server_url()
429
+			),
430
+			$payment
431
+		);
432
+	}
433
+
434
+
435
+
436
+	/**
437
+	 * Logs the response and cleans it
438
+	 *
439
+	 * @param EE_AuthorizeNetAIM_Response $response_obj
440
+	 * @param EE_Payment                  $payment
441
+	 * @return \EE_AuthorizeNetAIM_Response
442
+	 */
443
+	private function _log_and_clean_response($response_obj, $payment)
444
+	{
445
+		$response_obj->account_number = '';
446
+		$this->log(array('AIM Response received:' => (array) $response_obj), $payment);
447
+		return $response_obj;
448
+	}
449 449
 }
450 450
 
451 451
 
@@ -461,192 +461,192 @@  discard block
 block discarded – undo
461 461
 class EE_AuthorizeNetAIM_Response
462 462
 {
463 463
 
464
-    const APPROVED = '1';
465
-    const DECLINED = '2';
466
-    const ERROR = '3';
467
-    const HELD = '4';
468
-
469
-    protected $_x_post_fields = array(
470
-        "version"        => "3.1",
471
-        "delim_char"     => ",",
472
-        "delim_data"     => "TRUE",
473
-        "relay_response" => "FALSE",
474
-        "encap_char"     => "|",
475
-    );
476
-    public $approved;
477
-    public $declined;
478
-    public $error;
479
-    public $held;
480
-    public $response_code;
481
-    public $response_subcode;
482
-    public $response_reason_code;
483
-    public $response_reason_text;
484
-    public $authorization_code;
485
-    public $avs_response;
486
-    public $transaction_id;
487
-    public $invoice_number;
488
-    public $description;
489
-    public $amount;
490
-    public $method;
491
-    public $transaction_type;
492
-    public $customer_id;
493
-    public $first_name;
494
-    public $last_name;
495
-    public $company;
496
-    public $address;
497
-    public $city;
498
-    public $state;
499
-    public $zip_code;
500
-    public $country;
501
-    public $phone;
502
-    public $fax;
503
-    public $email_address;
504
-    public $ship_to_first_name;
505
-    public $ship_to_last_name;
506
-    public $ship_to_company;
507
-    public $ship_to_address;
508
-    public $ship_to_city;
509
-    public $ship_to_state;
510
-    public $ship_to_zip_code;
511
-    public $ship_to_country;
512
-    public $tax;
513
-    public $duty;
514
-    public $freight;
515
-    public $tax_exempt;
516
-    public $purchase_order_number;
517
-    public $md5_hash;
518
-    public $card_code_response;
519
-    public $cavv_response; // cardholder_authentication_verification_response
520
-    public $account_number;
521
-    public $card_type;
522
-    public $split_tender_id;
523
-    public $requested_amount;
524
-    public $balance_on_card;
525
-    public $response; // The response string from AuthorizeNet.
526
-    public $error_message;
527
-    private $_response_array = array(); // An array with the split response.
528
-
529
-
530
-    /**
531
-     * Constructor. Parses the AuthorizeNet response string
532
-     *
533
-     * @param string $response The response from the AuthNet server.
534
-     * @var string   $delimiter The delimiter used (default is ",")
535
-     * @var string   $encap_char The encap_char used (default is "|")
536
-     * @var array    $custom_fields Any custom fields set in the request.
537
-     */
538
-
539
-    public function __construct($response)
540
-    {
541
-        $encap_char = $this->_x_post_fields['encap_char'];
542
-        $delimiter = $this->_x_post_fields['delim_char'];
543
-        if ($response) {
544
-            // Split Array
545
-            $this->response = $response;
546
-            if ($encap_char) {
547
-                $this->_response_array = explode($encap_char . $delimiter . $encap_char, substr($response, 1, -1));
548
-            } else {
549
-                $this->_response_array = explode($delimiter, $response);
550
-            }
551
-
552
-            /**
553
-             * If AuthorizeNet doesn't return a delimited response.
554
-             */
555
-            if (count($this->_response_array) < 10) {
556
-                $this->approved = false;
557
-                $this->error = true;
558
-                $this->error_message = sprintf(
559
-                    esc_html__('Unrecognized response from Authorize.net: %1$s', 'event_espresso'),
560
-                    esc_html($response)
561
-                );
562
-                return;
563
-            }
564
-
565
-
566
-
567
-            // Set all fields
568
-            $this->response_code = $this->_response_array[0];
569
-            $this->response_subcode = $this->_response_array[1];
570
-            $this->response_reason_code = $this->_response_array[2];
571
-            $this->response_reason_text = $this->_response_array[3];
572
-            $this->authorization_code = $this->_response_array[4];
573
-            $this->avs_response = $this->_response_array[5];
574
-            $this->transaction_id = $this->_response_array[6];
575
-            $this->invoice_number = $this->_response_array[7];
576
-            $this->description = $this->_response_array[8];
577
-            $this->amount = $this->_response_array[9];
578
-            $this->method = $this->_response_array[10];
579
-            $this->transaction_type = $this->_response_array[11];
580
-            $this->customer_id = $this->_response_array[12];
581
-            $this->first_name = $this->_response_array[13];
582
-            $this->last_name = $this->_response_array[14];
583
-            $this->company = $this->_response_array[15];
584
-            $this->address = $this->_response_array[16];
585
-            $this->city = $this->_response_array[17];
586
-            $this->state = $this->_response_array[18];
587
-            $this->zip_code = $this->_response_array[19];
588
-            $this->country = $this->_response_array[20];
589
-            $this->phone = $this->_response_array[21];
590
-            $this->fax = $this->_response_array[22];
591
-            $this->email_address = $this->_response_array[23];
592
-            $this->ship_to_first_name = $this->_response_array[24];
593
-            $this->ship_to_last_name = $this->_response_array[25];
594
-            $this->ship_to_company = $this->_response_array[26];
595
-            $this->ship_to_address = $this->_response_array[27];
596
-            $this->ship_to_city = $this->_response_array[28];
597
-            $this->ship_to_state = $this->_response_array[29];
598
-            $this->ship_to_zip_code = $this->_response_array[30];
599
-            $this->ship_to_country = $this->_response_array[31];
600
-            $this->tax = $this->_response_array[32];
601
-            $this->duty = $this->_response_array[33];
602
-            $this->freight = $this->_response_array[34];
603
-            $this->tax_exempt = $this->_response_array[35];
604
-            $this->purchase_order_number = $this->_response_array[36];
605
-            $this->md5_hash = $this->_response_array[37];
606
-            $this->card_code_response = $this->_response_array[38];
607
-            $this->cavv_response = $this->_response_array[39];
608
-            $this->account_number = $this->_response_array[50];
609
-            $this->card_type = $this->_response_array[51];
610
-            $this->split_tender_id = $this->_response_array[52];
611
-            $this->requested_amount = $this->_response_array[53];
612
-            $this->balance_on_card = $this->_response_array[54];
613
-
614
-            $this->approved = ($this->response_code === self::APPROVED);
615
-            $this->declined = ($this->response_code === self::DECLINED);
616
-            $this->error = ($this->response_code === self::ERROR);
617
-            $this->held = ($this->response_code === self::HELD);
618
-        } else {
619
-            $this->approved = false;
620
-            $this->error = true;
621
-            $this->error_message = esc_html__(
622
-                'Error connecting to Authorize.net',
623
-                'event_espresso'
624
-            );
625
-        }
626
-    }
464
+	const APPROVED = '1';
465
+	const DECLINED = '2';
466
+	const ERROR = '3';
467
+	const HELD = '4';
468
+
469
+	protected $_x_post_fields = array(
470
+		"version"        => "3.1",
471
+		"delim_char"     => ",",
472
+		"delim_data"     => "TRUE",
473
+		"relay_response" => "FALSE",
474
+		"encap_char"     => "|",
475
+	);
476
+	public $approved;
477
+	public $declined;
478
+	public $error;
479
+	public $held;
480
+	public $response_code;
481
+	public $response_subcode;
482
+	public $response_reason_code;
483
+	public $response_reason_text;
484
+	public $authorization_code;
485
+	public $avs_response;
486
+	public $transaction_id;
487
+	public $invoice_number;
488
+	public $description;
489
+	public $amount;
490
+	public $method;
491
+	public $transaction_type;
492
+	public $customer_id;
493
+	public $first_name;
494
+	public $last_name;
495
+	public $company;
496
+	public $address;
497
+	public $city;
498
+	public $state;
499
+	public $zip_code;
500
+	public $country;
501
+	public $phone;
502
+	public $fax;
503
+	public $email_address;
504
+	public $ship_to_first_name;
505
+	public $ship_to_last_name;
506
+	public $ship_to_company;
507
+	public $ship_to_address;
508
+	public $ship_to_city;
509
+	public $ship_to_state;
510
+	public $ship_to_zip_code;
511
+	public $ship_to_country;
512
+	public $tax;
513
+	public $duty;
514
+	public $freight;
515
+	public $tax_exempt;
516
+	public $purchase_order_number;
517
+	public $md5_hash;
518
+	public $card_code_response;
519
+	public $cavv_response; // cardholder_authentication_verification_response
520
+	public $account_number;
521
+	public $card_type;
522
+	public $split_tender_id;
523
+	public $requested_amount;
524
+	public $balance_on_card;
525
+	public $response; // The response string from AuthorizeNet.
526
+	public $error_message;
527
+	private $_response_array = array(); // An array with the split response.
528
+
529
+
530
+	/**
531
+	 * Constructor. Parses the AuthorizeNet response string
532
+	 *
533
+	 * @param string $response The response from the AuthNet server.
534
+	 * @var string   $delimiter The delimiter used (default is ",")
535
+	 * @var string   $encap_char The encap_char used (default is "|")
536
+	 * @var array    $custom_fields Any custom fields set in the request.
537
+	 */
538
+
539
+	public function __construct($response)
540
+	{
541
+		$encap_char = $this->_x_post_fields['encap_char'];
542
+		$delimiter = $this->_x_post_fields['delim_char'];
543
+		if ($response) {
544
+			// Split Array
545
+			$this->response = $response;
546
+			if ($encap_char) {
547
+				$this->_response_array = explode($encap_char . $delimiter . $encap_char, substr($response, 1, -1));
548
+			} else {
549
+				$this->_response_array = explode($delimiter, $response);
550
+			}
551
+
552
+			/**
553
+			 * If AuthorizeNet doesn't return a delimited response.
554
+			 */
555
+			if (count($this->_response_array) < 10) {
556
+				$this->approved = false;
557
+				$this->error = true;
558
+				$this->error_message = sprintf(
559
+					esc_html__('Unrecognized response from Authorize.net: %1$s', 'event_espresso'),
560
+					esc_html($response)
561
+				);
562
+				return;
563
+			}
564
+
565
+
566
+
567
+			// Set all fields
568
+			$this->response_code = $this->_response_array[0];
569
+			$this->response_subcode = $this->_response_array[1];
570
+			$this->response_reason_code = $this->_response_array[2];
571
+			$this->response_reason_text = $this->_response_array[3];
572
+			$this->authorization_code = $this->_response_array[4];
573
+			$this->avs_response = $this->_response_array[5];
574
+			$this->transaction_id = $this->_response_array[6];
575
+			$this->invoice_number = $this->_response_array[7];
576
+			$this->description = $this->_response_array[8];
577
+			$this->amount = $this->_response_array[9];
578
+			$this->method = $this->_response_array[10];
579
+			$this->transaction_type = $this->_response_array[11];
580
+			$this->customer_id = $this->_response_array[12];
581
+			$this->first_name = $this->_response_array[13];
582
+			$this->last_name = $this->_response_array[14];
583
+			$this->company = $this->_response_array[15];
584
+			$this->address = $this->_response_array[16];
585
+			$this->city = $this->_response_array[17];
586
+			$this->state = $this->_response_array[18];
587
+			$this->zip_code = $this->_response_array[19];
588
+			$this->country = $this->_response_array[20];
589
+			$this->phone = $this->_response_array[21];
590
+			$this->fax = $this->_response_array[22];
591
+			$this->email_address = $this->_response_array[23];
592
+			$this->ship_to_first_name = $this->_response_array[24];
593
+			$this->ship_to_last_name = $this->_response_array[25];
594
+			$this->ship_to_company = $this->_response_array[26];
595
+			$this->ship_to_address = $this->_response_array[27];
596
+			$this->ship_to_city = $this->_response_array[28];
597
+			$this->ship_to_state = $this->_response_array[29];
598
+			$this->ship_to_zip_code = $this->_response_array[30];
599
+			$this->ship_to_country = $this->_response_array[31];
600
+			$this->tax = $this->_response_array[32];
601
+			$this->duty = $this->_response_array[33];
602
+			$this->freight = $this->_response_array[34];
603
+			$this->tax_exempt = $this->_response_array[35];
604
+			$this->purchase_order_number = $this->_response_array[36];
605
+			$this->md5_hash = $this->_response_array[37];
606
+			$this->card_code_response = $this->_response_array[38];
607
+			$this->cavv_response = $this->_response_array[39];
608
+			$this->account_number = $this->_response_array[50];
609
+			$this->card_type = $this->_response_array[51];
610
+			$this->split_tender_id = $this->_response_array[52];
611
+			$this->requested_amount = $this->_response_array[53];
612
+			$this->balance_on_card = $this->_response_array[54];
613
+
614
+			$this->approved = ($this->response_code === self::APPROVED);
615
+			$this->declined = ($this->response_code === self::DECLINED);
616
+			$this->error = ($this->response_code === self::ERROR);
617
+			$this->held = ($this->response_code === self::HELD);
618
+		} else {
619
+			$this->approved = false;
620
+			$this->error = true;
621
+			$this->error_message = esc_html__(
622
+				'Error connecting to Authorize.net',
623
+				'event_espresso'
624
+			);
625
+		}
626
+	}
627 627
 }
628 628
 
629 629
 if (! class_exists('AuthorizeNetException')) {
630
-    /**
631
-     * Class AuthorizeNetException
632
-     *
633
-     * @package    AuthorizeNet
634
-     */
635
-    class AuthorizeNetException extends Exception
636
-    {
637
-
638
-        /**
639
-         * Construct the exception. Note: The message is NOT binary safe.
640
-         *
641
-         * @link http://php.net/manual/en/exception.construct.php
642
-         * @param string $message [optional] The Exception message to throw.
643
-         * @param int $code [optional] The Exception code.
644
-         * @param Exception $previous [optional] The previous exception used for the exception chaining. Since 5.3.0
645
-         * @since 5.1.0
646
-         */
647
-        public function __construct($message = "", $code = 0, Exception $previous = null)
648
-        {
649
-            parent::__construct($message, $code, $previous);
650
-        }
651
-    }
630
+	/**
631
+	 * Class AuthorizeNetException
632
+	 *
633
+	 * @package    AuthorizeNet
634
+	 */
635
+	class AuthorizeNetException extends Exception
636
+	{
637
+
638
+		/**
639
+		 * Construct the exception. Note: The message is NOT binary safe.
640
+		 *
641
+		 * @link http://php.net/manual/en/exception.construct.php
642
+		 * @param string $message [optional] The Exception message to throw.
643
+		 * @param int $code [optional] The Exception code.
644
+		 * @param Exception $previous [optional] The previous exception used for the exception chaining. Since 5.3.0
645
+		 * @since 5.1.0
646
+		 */
647
+		public function __construct($message = "", $code = 0, Exception $previous = null)
648
+		{
649
+			parent::__construct($message, $code, $previous);
650
+		}
651
+	}
652 652
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -249,11 +249,11 @@  discard block
 block discarded – undo
249 249
         $this->setField('cust_id', $primary_registrant->ID());
250 250
         $this->setField('phone', $billing_info['phone']);
251 251
         $currency_config = LoaderFactory::getLoader()->load('EE_Currency_Config');
252
-        $this->setField('currency_code',$currency_config->code);
252
+        $this->setField('currency_code', $currency_config->code);
253 253
         // invoice_num would be nice to have it be unique per SPCO page-load, that way if users
254 254
         // press back, they don't submit a duplicate. However, we may be keeping the user on teh same spco page
255 255
         // in which case, we need to generate teh invoice num per request right here...
256
-        $this->setField('invoice_num', wp_generate_password(12, false));// $billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']);
256
+        $this->setField('invoice_num', wp_generate_password(12, false)); // $billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']);
257 257
         // tell AIM that any duplicates sent in the next 5 minutes are to be ignored
258 258
         $this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS);
259 259
 
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
         // Capture response
265 265
         $this->type = "AUTH_CAPTURE";
266 266
         $response = $this->_sendRequest($payment);
267
-        if (! empty($response)) {
267
+        if ( ! empty($response)) {
268 268
             if ($response->error_message) {
269 269
                 $payment->set_status($this->_pay_model->failed_status());
270 270
                 $payment->set_gateway_response($response->error_message);
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
     protected function _set_sensitive_billing_data($billing_info)
311 311
     {
312 312
         $this->setField('card_num', $billing_info['credit_card']);
313
-        $this->setField('exp_date', $billing_info['exp_month'] . $billing_info['exp_year']);
313
+        $this->setField('exp_date', $billing_info['exp_month'].$billing_info['exp_year']);
314 314
         $this->setField('card_code', $billing_info['cvv']);
315 315
     }
316 316
 
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
     protected function setField($name, $value)
351 351
     {
352 352
         if (in_array($name, $this->_all_aim_fields)) {
353
-            $this->_x_post_fields[ $name ] = $value;
353
+            $this->_x_post_fields[$name] = $value;
354 354
         } else {
355 355
             throw new AuthorizeNetException("Error: no field $name exists in the AIM API.
356 356
             To set a custom field use setCustomField('field','value') instead.");
@@ -370,11 +370,11 @@  discard block
 block discarded – undo
370 370
         $this->_x_post_fields['tran_key'] = $this->_transaction_key;
371 371
         $x_keys = array();
372 372
         foreach ($this->_x_post_fields as $key => $value) {
373
-            $x_keys[] = "x_$key=" . urlencode($this->_get_unsupported_character_remover()->format($value));
373
+            $x_keys[] = "x_$key=".urlencode($this->_get_unsupported_character_remover()->format($value));
374 374
         }
375 375
         // Add line items
376 376
         foreach ($this->_additional_line_items as $key => $value) {
377
-            $x_keys[] =  "x_line_item=" . urlencode($this->_get_unsupported_character_remover()->format($value));
377
+            $x_keys[] = "x_line_item=".urlencode($this->_get_unsupported_character_remover()->format($value));
378 378
         }
379 379
         $this->_log_clean_request($x_keys, $payment);
380 380
         $post_url = $this->_get_server_url();
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
         curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1);
387 387
         curl_setopt($curl_request, CURLOPT_SSL_VERIFYHOST, 2);
388 388
         if ($this->VERIFY_PEER) {
389
-            curl_setopt($curl_request, CURLOPT_CAINFO, dirname(__DIR__) . '/ssl/cert.pem');
389
+            curl_setopt($curl_request, CURLOPT_CAINFO, dirname(__DIR__).'/ssl/cert.pem');
390 390
         } else {
391 391
             curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false);
392 392
         }
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
         $response = curl_exec($curl_request);
399 399
 
400 400
         curl_close($curl_request);
401
-        $response_obj =  new EE_AuthorizeNetAIM_Response($response);
401
+        $response_obj = new EE_AuthorizeNetAIM_Response($response);
402 402
 
403 403
         return $this->_log_and_clean_response($response_obj, $payment);
404 404
     }
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
                 if (strpos($keyvaltogether, $key) === 0) {
419 419
                     // found it at the first character
420 420
                     // so its one of them
421
-                    unset($request_array[ $index ]);
421
+                    unset($request_array[$index]);
422 422
                 }
423 423
             }
424 424
         }
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
             // Split Array
545 545
             $this->response = $response;
546 546
             if ($encap_char) {
547
-                $this->_response_array = explode($encap_char . $delimiter . $encap_char, substr($response, 1, -1));
547
+                $this->_response_array = explode($encap_char.$delimiter.$encap_char, substr($response, 1, -1));
548 548
             } else {
549 549
                 $this->_response_array = explode($delimiter, $response);
550 550
             }
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
     }
627 627
 }
628 628
 
629
-if (! class_exists('AuthorizeNetException')) {
629
+if ( ! class_exists('AuthorizeNetException')) {
630 630
     /**
631 631
      * Class AuthorizeNetException
632 632
      *
Please login to merge, or discard this patch.