Completed
Branch master (9f32eb)
by
unknown
07:23 queued 05:06
created
modules/single_page_checkout/inc/EE_SPCO_JSON_Response.php 1 patch
Indentation   +399 added lines, -399 removed lines patch added patch discarded remove patch
@@ -15,403 +15,403 @@
 block discarded – undo
15 15
 class EE_SPCO_JSON_Response
16 16
 {
17 17
 
18
-    /**
19
-     * @var string
20
-     */
21
-    protected $_errors = '';
22
-
23
-    /**
24
-     * @var string
25
-     */
26
-    protected $_unexpected_errors = '';
27
-
28
-    /**
29
-     * @var string
30
-     */
31
-    protected $_attention = '';
32
-
33
-    /**
34
-     * @var string
35
-     */
36
-    protected $_success = '';
37
-
38
-    /**
39
-     * @var string
40
-     */
41
-    protected $_plz_select_method_of_payment = '';
42
-
43
-    /**
44
-     * @var string
45
-     */
46
-    protected $_redirect_url = '';
47
-
48
-    /**
49
-     * @var string
50
-     */
51
-    protected $_registration_time_limit = '';
52
-
53
-    /**
54
-     * @var string
55
-     */
56
-    protected $_redirect_form = '';
57
-
58
-    /**
59
-     * @var string
60
-     */
61
-    protected $_reg_step_html = '';
62
-
63
-    /**
64
-     * @var string
65
-     */
66
-    protected $_method_of_payment = '';
67
-
68
-    /**
69
-     * @var float
70
-     */
71
-    protected $_payment_amount;
72
-
73
-    /**
74
-     * @var array
75
-     */
76
-    protected $_return_data = array();
77
-
78
-
79
-    /**
80
-     * @var array
81
-     */
82
-    protected $_validation_rules = array();
83
-
84
-
85
-    /**
86
-     *    class constructor
87
-     */
88
-    public function __construct()
89
-    {
90
-    }
91
-
92
-
93
-    /**
94
-     *    __toString
95
-     *
96
-     *        allows you to simply echo or print an EE_SPCO_JSON_Response object to produce a  JSON encoded string
97
-     *        ie: $json_response = new EE_SPCO_JSON_Response();
98
-     *        echo $json_response;
99
-     *
100
-     * @access    public
101
-     * @return    string
102
-     */
103
-    public function __toString()
104
-    {
105
-        $JSON_response = array();
106
-        // grab notices
107
-        $notices = EE_Error::get_notices(false);
108
-        $this->set_attention(isset($notices['attention']) ? $notices['attention'] : '');
109
-        $this->set_errors(isset($notices['errors']) ? $notices['errors'] : '');
110
-        $this->set_success(isset($notices['success']) ? $notices['success'] : '');
111
-        // add notices to JSON response, but only if they exist
112
-        if ($this->attention()) {
113
-            $JSON_response['attention'] = $this->attention();
114
-        }
115
-        if ($this->errors()) {
116
-            $JSON_response['errors'] = $this->errors();
117
-        }
118
-        if ($this->unexpected_errors()) {
119
-            $JSON_response['unexpected_errors'] = $this->unexpected_errors();
120
-        }
121
-        if ($this->success()) {
122
-            $JSON_response['success'] = $this->success();
123
-        }
124
-        // but if NO notices are set... at least set the "success" as a key so that the JS knows everything worked
125
-        if (! isset($JSON_response['attention']) && ! isset($JSON_response['errors']) && ! isset($JSON_response['success'])) {
126
-            $JSON_response['success'] = null;
127
-        }
128
-        // set redirect_url, IF it exists
129
-        if ($this->redirect_url()) {
130
-            $JSON_response['redirect_url'] = $this->redirect_url();
131
-        }
132
-        // set registration_time_limit, IF it exists
133
-        if ($this->registration_time_limit()) {
134
-            $JSON_response['registration_time_limit'] = $this->registration_time_limit();
135
-        }
136
-        // set payment_amount, IF it exists
137
-        if ($this->payment_amount() !== null) {
138
-            $JSON_response['payment_amount'] = $this->payment_amount();
139
-        }
140
-        // grab generic return data
141
-        $return_data = $this->return_data();
142
-        // add billing form validation rules
143
-        if ($this->validation_rules()) {
144
-            $return_data['validation_rules'] = $this->validation_rules();
145
-        }
146
-        // set reg_step_html, IF it exists
147
-        if ($this->reg_step_html()) {
148
-            $return_data['reg_step_html'] = $this->reg_step_html();
149
-        }
150
-        // set method of payment, IF it exists
151
-        if ($this->method_of_payment()) {
152
-            $return_data['method_of_payment'] = $this->method_of_payment();
153
-        }
154
-        // set "plz_select_method_of_payment" message, IF it exists
155
-        if ($this->plz_select_method_of_payment()) {
156
-            $return_data['plz_select_method_of_payment'] = $this->plz_select_method_of_payment();
157
-        }
158
-        // set redirect_form, IF it exists
159
-        if ($this->redirect_form()) {
160
-            $return_data['redirect_form'] = $this->redirect_form();
161
-        }
162
-        // and finally, add return_data array to main JSON response array, IF it contains anything
163
-        // why did we add some of the above properties to the return data array?
164
-        // because it is easier and cleaner in the Javascript to deal with this way
165
-        if (! empty($return_data)) {
166
-            $JSON_response['return_data'] = $return_data;
167
-        }
168
-        // filter final array
169
-        $JSON_response = apply_filters('FHEE__EE_SPCO_JSON_Response___toString__JSON_response', $JSON_response);
170
-        // return encoded array
171
-        return (string) wp_json_encode($JSON_response);
172
-    }
173
-
174
-
175
-    /**
176
-     * @param string $attention
177
-     */
178
-    public function set_attention($attention)
179
-    {
180
-        $this->_attention = $attention;
181
-    }
182
-
183
-
184
-    /**
185
-     * @return string
186
-     */
187
-    public function attention()
188
-    {
189
-        return $this->_attention;
190
-    }
191
-
192
-
193
-    /**
194
-     * @param string $errors
195
-     */
196
-    public function set_errors($errors)
197
-    {
198
-        $this->_errors = $errors;
199
-    }
200
-
201
-
202
-    /**
203
-     * @return string
204
-     */
205
-    public function errors()
206
-    {
207
-        return $this->_errors;
208
-    }
209
-
210
-
211
-    /**
212
-     * @return string
213
-     */
214
-    public function unexpected_errors()
215
-    {
216
-        return $this->_unexpected_errors;
217
-    }
218
-
219
-
220
-    /**
221
-     * @param string $unexpected_errors
222
-     */
223
-    public function set_unexpected_errors($unexpected_errors)
224
-    {
225
-        $this->_unexpected_errors = $unexpected_errors;
226
-    }
227
-
228
-
229
-    /**
230
-     * @param string $success
231
-     */
232
-    public function set_success($success)
233
-    {
234
-        $this->_success = $success;
235
-    }
236
-
237
-
238
-    /**
239
-     * @return string
240
-     */
241
-    public function success()
242
-    {
243
-        return $this->_success;
244
-    }
245
-
246
-
247
-    /**
248
-     * @param string $method_of_payment
249
-     */
250
-    public function set_method_of_payment($method_of_payment)
251
-    {
252
-        $this->_method_of_payment = $method_of_payment;
253
-    }
254
-
255
-
256
-    /**
257
-     * @return string
258
-     */
259
-    public function method_of_payment()
260
-    {
261
-        return $this->_method_of_payment;
262
-    }
263
-
264
-
265
-    /**
266
-     * @return float
267
-     */
268
-    public function payment_amount()
269
-    {
270
-        return $this->_payment_amount;
271
-    }
272
-
273
-
274
-    /**
275
-     * @param float $payment_amount
276
-     * @throws EE_Error
277
-     */
278
-    public function set_payment_amount($payment_amount)
279
-    {
280
-        $this->_payment_amount = (float) $payment_amount;
281
-    }
282
-
283
-
284
-    /**
285
-     * @param string $next_step_html
286
-     */
287
-    public function set_reg_step_html($next_step_html)
288
-    {
289
-        $this->_reg_step_html = $next_step_html;
290
-    }
291
-
292
-
293
-    /**
294
-     * @return string
295
-     */
296
-    public function reg_step_html()
297
-    {
298
-        return $this->_reg_step_html;
299
-    }
300
-
301
-
302
-    /**
303
-     * @param string $redirect_form
304
-     */
305
-    public function set_redirect_form($redirect_form)
306
-    {
307
-        $this->_redirect_form = $redirect_form;
308
-    }
309
-
310
-
311
-    /**
312
-     * @return string
313
-     */
314
-    public function redirect_form()
315
-    {
316
-        return ! empty($this->_redirect_form) ? $this->_redirect_form : false;
317
-    }
318
-
319
-
320
-    /**
321
-     * @param string $plz_select_method_of_payment
322
-     */
323
-    public function set_plz_select_method_of_payment($plz_select_method_of_payment)
324
-    {
325
-        $this->_plz_select_method_of_payment = $plz_select_method_of_payment;
326
-    }
327
-
328
-
329
-    /**
330
-     * @return string
331
-     */
332
-    public function plz_select_method_of_payment()
333
-    {
334
-        return $this->_plz_select_method_of_payment;
335
-    }
336
-
337
-
338
-    /**
339
-     * @param string $redirect_url
340
-     */
341
-    public function set_redirect_url($redirect_url)
342
-    {
343
-        $this->_redirect_url = $redirect_url;
344
-    }
345
-
346
-
347
-    /**
348
-     * @return string
349
-     */
350
-    public function redirect_url()
351
-    {
352
-        return $this->_redirect_url;
353
-    }
354
-
355
-
356
-    /**
357
-     * @return string
358
-     */
359
-    public function registration_time_limit()
360
-    {
361
-        return $this->_registration_time_limit;
362
-    }
363
-
364
-
365
-    /**
366
-     * @param string $registration_time_limit
367
-     */
368
-    public function set_registration_time_limit($registration_time_limit)
369
-    {
370
-        $this->_registration_time_limit = $registration_time_limit;
371
-    }
372
-
373
-
374
-    /**
375
-     * @param array $return_data
376
-     */
377
-    public function set_return_data($return_data)
378
-    {
379
-        $this->_return_data = array_merge($this->_return_data, $return_data);
380
-    }
381
-
382
-
383
-    /**
384
-     * @return array
385
-     */
386
-    public function return_data()
387
-    {
388
-        return $this->_return_data;
389
-    }
390
-
391
-
392
-    /**
393
-     * @param array $validation_rules
394
-     */
395
-    public function add_validation_rules(array $validation_rules = array())
396
-    {
397
-        if (is_array($validation_rules) && ! empty($validation_rules)) {
398
-            $this->_validation_rules = array_merge($this->_validation_rules, $validation_rules);
399
-        }
400
-    }
401
-
402
-
403
-    /**
404
-     * @return array | bool
405
-     */
406
-    public function validation_rules()
407
-    {
408
-        return ! empty($this->_validation_rules) ? $this->_validation_rules : false;
409
-    }
410
-
411
-
412
-    public function echoAndExit()
413
-    {
414
-        echo $this;
415
-        exit();
416
-    }
18
+	/**
19
+	 * @var string
20
+	 */
21
+	protected $_errors = '';
22
+
23
+	/**
24
+	 * @var string
25
+	 */
26
+	protected $_unexpected_errors = '';
27
+
28
+	/**
29
+	 * @var string
30
+	 */
31
+	protected $_attention = '';
32
+
33
+	/**
34
+	 * @var string
35
+	 */
36
+	protected $_success = '';
37
+
38
+	/**
39
+	 * @var string
40
+	 */
41
+	protected $_plz_select_method_of_payment = '';
42
+
43
+	/**
44
+	 * @var string
45
+	 */
46
+	protected $_redirect_url = '';
47
+
48
+	/**
49
+	 * @var string
50
+	 */
51
+	protected $_registration_time_limit = '';
52
+
53
+	/**
54
+	 * @var string
55
+	 */
56
+	protected $_redirect_form = '';
57
+
58
+	/**
59
+	 * @var string
60
+	 */
61
+	protected $_reg_step_html = '';
62
+
63
+	/**
64
+	 * @var string
65
+	 */
66
+	protected $_method_of_payment = '';
67
+
68
+	/**
69
+	 * @var float
70
+	 */
71
+	protected $_payment_amount;
72
+
73
+	/**
74
+	 * @var array
75
+	 */
76
+	protected $_return_data = array();
77
+
78
+
79
+	/**
80
+	 * @var array
81
+	 */
82
+	protected $_validation_rules = array();
83
+
84
+
85
+	/**
86
+	 *    class constructor
87
+	 */
88
+	public function __construct()
89
+	{
90
+	}
91
+
92
+
93
+	/**
94
+	 *    __toString
95
+	 *
96
+	 *        allows you to simply echo or print an EE_SPCO_JSON_Response object to produce a  JSON encoded string
97
+	 *        ie: $json_response = new EE_SPCO_JSON_Response();
98
+	 *        echo $json_response;
99
+	 *
100
+	 * @access    public
101
+	 * @return    string
102
+	 */
103
+	public function __toString()
104
+	{
105
+		$JSON_response = array();
106
+		// grab notices
107
+		$notices = EE_Error::get_notices(false);
108
+		$this->set_attention(isset($notices['attention']) ? $notices['attention'] : '');
109
+		$this->set_errors(isset($notices['errors']) ? $notices['errors'] : '');
110
+		$this->set_success(isset($notices['success']) ? $notices['success'] : '');
111
+		// add notices to JSON response, but only if they exist
112
+		if ($this->attention()) {
113
+			$JSON_response['attention'] = $this->attention();
114
+		}
115
+		if ($this->errors()) {
116
+			$JSON_response['errors'] = $this->errors();
117
+		}
118
+		if ($this->unexpected_errors()) {
119
+			$JSON_response['unexpected_errors'] = $this->unexpected_errors();
120
+		}
121
+		if ($this->success()) {
122
+			$JSON_response['success'] = $this->success();
123
+		}
124
+		// but if NO notices are set... at least set the "success" as a key so that the JS knows everything worked
125
+		if (! isset($JSON_response['attention']) && ! isset($JSON_response['errors']) && ! isset($JSON_response['success'])) {
126
+			$JSON_response['success'] = null;
127
+		}
128
+		// set redirect_url, IF it exists
129
+		if ($this->redirect_url()) {
130
+			$JSON_response['redirect_url'] = $this->redirect_url();
131
+		}
132
+		// set registration_time_limit, IF it exists
133
+		if ($this->registration_time_limit()) {
134
+			$JSON_response['registration_time_limit'] = $this->registration_time_limit();
135
+		}
136
+		// set payment_amount, IF it exists
137
+		if ($this->payment_amount() !== null) {
138
+			$JSON_response['payment_amount'] = $this->payment_amount();
139
+		}
140
+		// grab generic return data
141
+		$return_data = $this->return_data();
142
+		// add billing form validation rules
143
+		if ($this->validation_rules()) {
144
+			$return_data['validation_rules'] = $this->validation_rules();
145
+		}
146
+		// set reg_step_html, IF it exists
147
+		if ($this->reg_step_html()) {
148
+			$return_data['reg_step_html'] = $this->reg_step_html();
149
+		}
150
+		// set method of payment, IF it exists
151
+		if ($this->method_of_payment()) {
152
+			$return_data['method_of_payment'] = $this->method_of_payment();
153
+		}
154
+		// set "plz_select_method_of_payment" message, IF it exists
155
+		if ($this->plz_select_method_of_payment()) {
156
+			$return_data['plz_select_method_of_payment'] = $this->plz_select_method_of_payment();
157
+		}
158
+		// set redirect_form, IF it exists
159
+		if ($this->redirect_form()) {
160
+			$return_data['redirect_form'] = $this->redirect_form();
161
+		}
162
+		// and finally, add return_data array to main JSON response array, IF it contains anything
163
+		// why did we add some of the above properties to the return data array?
164
+		// because it is easier and cleaner in the Javascript to deal with this way
165
+		if (! empty($return_data)) {
166
+			$JSON_response['return_data'] = $return_data;
167
+		}
168
+		// filter final array
169
+		$JSON_response = apply_filters('FHEE__EE_SPCO_JSON_Response___toString__JSON_response', $JSON_response);
170
+		// return encoded array
171
+		return (string) wp_json_encode($JSON_response);
172
+	}
173
+
174
+
175
+	/**
176
+	 * @param string $attention
177
+	 */
178
+	public function set_attention($attention)
179
+	{
180
+		$this->_attention = $attention;
181
+	}
182
+
183
+
184
+	/**
185
+	 * @return string
186
+	 */
187
+	public function attention()
188
+	{
189
+		return $this->_attention;
190
+	}
191
+
192
+
193
+	/**
194
+	 * @param string $errors
195
+	 */
196
+	public function set_errors($errors)
197
+	{
198
+		$this->_errors = $errors;
199
+	}
200
+
201
+
202
+	/**
203
+	 * @return string
204
+	 */
205
+	public function errors()
206
+	{
207
+		return $this->_errors;
208
+	}
209
+
210
+
211
+	/**
212
+	 * @return string
213
+	 */
214
+	public function unexpected_errors()
215
+	{
216
+		return $this->_unexpected_errors;
217
+	}
218
+
219
+
220
+	/**
221
+	 * @param string $unexpected_errors
222
+	 */
223
+	public function set_unexpected_errors($unexpected_errors)
224
+	{
225
+		$this->_unexpected_errors = $unexpected_errors;
226
+	}
227
+
228
+
229
+	/**
230
+	 * @param string $success
231
+	 */
232
+	public function set_success($success)
233
+	{
234
+		$this->_success = $success;
235
+	}
236
+
237
+
238
+	/**
239
+	 * @return string
240
+	 */
241
+	public function success()
242
+	{
243
+		return $this->_success;
244
+	}
245
+
246
+
247
+	/**
248
+	 * @param string $method_of_payment
249
+	 */
250
+	public function set_method_of_payment($method_of_payment)
251
+	{
252
+		$this->_method_of_payment = $method_of_payment;
253
+	}
254
+
255
+
256
+	/**
257
+	 * @return string
258
+	 */
259
+	public function method_of_payment()
260
+	{
261
+		return $this->_method_of_payment;
262
+	}
263
+
264
+
265
+	/**
266
+	 * @return float
267
+	 */
268
+	public function payment_amount()
269
+	{
270
+		return $this->_payment_amount;
271
+	}
272
+
273
+
274
+	/**
275
+	 * @param float $payment_amount
276
+	 * @throws EE_Error
277
+	 */
278
+	public function set_payment_amount($payment_amount)
279
+	{
280
+		$this->_payment_amount = (float) $payment_amount;
281
+	}
282
+
283
+
284
+	/**
285
+	 * @param string $next_step_html
286
+	 */
287
+	public function set_reg_step_html($next_step_html)
288
+	{
289
+		$this->_reg_step_html = $next_step_html;
290
+	}
291
+
292
+
293
+	/**
294
+	 * @return string
295
+	 */
296
+	public function reg_step_html()
297
+	{
298
+		return $this->_reg_step_html;
299
+	}
300
+
301
+
302
+	/**
303
+	 * @param string $redirect_form
304
+	 */
305
+	public function set_redirect_form($redirect_form)
306
+	{
307
+		$this->_redirect_form = $redirect_form;
308
+	}
309
+
310
+
311
+	/**
312
+	 * @return string
313
+	 */
314
+	public function redirect_form()
315
+	{
316
+		return ! empty($this->_redirect_form) ? $this->_redirect_form : false;
317
+	}
318
+
319
+
320
+	/**
321
+	 * @param string $plz_select_method_of_payment
322
+	 */
323
+	public function set_plz_select_method_of_payment($plz_select_method_of_payment)
324
+	{
325
+		$this->_plz_select_method_of_payment = $plz_select_method_of_payment;
326
+	}
327
+
328
+
329
+	/**
330
+	 * @return string
331
+	 */
332
+	public function plz_select_method_of_payment()
333
+	{
334
+		return $this->_plz_select_method_of_payment;
335
+	}
336
+
337
+
338
+	/**
339
+	 * @param string $redirect_url
340
+	 */
341
+	public function set_redirect_url($redirect_url)
342
+	{
343
+		$this->_redirect_url = $redirect_url;
344
+	}
345
+
346
+
347
+	/**
348
+	 * @return string
349
+	 */
350
+	public function redirect_url()
351
+	{
352
+		return $this->_redirect_url;
353
+	}
354
+
355
+
356
+	/**
357
+	 * @return string
358
+	 */
359
+	public function registration_time_limit()
360
+	{
361
+		return $this->_registration_time_limit;
362
+	}
363
+
364
+
365
+	/**
366
+	 * @param string $registration_time_limit
367
+	 */
368
+	public function set_registration_time_limit($registration_time_limit)
369
+	{
370
+		$this->_registration_time_limit = $registration_time_limit;
371
+	}
372
+
373
+
374
+	/**
375
+	 * @param array $return_data
376
+	 */
377
+	public function set_return_data($return_data)
378
+	{
379
+		$this->_return_data = array_merge($this->_return_data, $return_data);
380
+	}
381
+
382
+
383
+	/**
384
+	 * @return array
385
+	 */
386
+	public function return_data()
387
+	{
388
+		return $this->_return_data;
389
+	}
390
+
391
+
392
+	/**
393
+	 * @param array $validation_rules
394
+	 */
395
+	public function add_validation_rules(array $validation_rules = array())
396
+	{
397
+		if (is_array($validation_rules) && ! empty($validation_rules)) {
398
+			$this->_validation_rules = array_merge($this->_validation_rules, $validation_rules);
399
+		}
400
+	}
401
+
402
+
403
+	/**
404
+	 * @return array | bool
405
+	 */
406
+	public function validation_rules()
407
+	{
408
+		return ! empty($this->_validation_rules) ? $this->_validation_rules : false;
409
+	}
410
+
411
+
412
+	public function echoAndExit()
413
+	{
414
+		echo $this;
415
+		exit();
416
+	}
417 417
 }
Please login to merge, or discard this patch.
modules/ical/EED_Ical.module.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -86,24 +86,24 @@  discard block
 block discarded – undo
86 86
             switch ($iCal_type) {
87 87
                 // submit buttons appear as buttons and are very compatible with a theme's style
88 88
                 case 'submit':
89
-                    $html .= '<form id="download-iCal-frm-' . $datetime->ID();
90
-                    $html .= '" class="download-iCal-frm" action="' . $URL . '" method="post" >';
89
+                    $html .= '<form id="download-iCal-frm-'.$datetime->ID();
90
+                    $html .= '" class="download-iCal-frm" action="'.$URL.'" method="post" >';
91 91
                     $html .= '<input type="submit" class="ee-ical-sbmt" value="&#xf145;" title="';
92
-                    $html .= esc_html__('Add to iCal Calendar', 'event_espresso') . '"/>';
92
+                    $html .= esc_html__('Add to iCal Calendar', 'event_espresso').'"/>';
93 93
                     $html .= '</form>';
94 94
                     break;
95 95
                 // buttons are just links that have been styled to appear as buttons,
96 96
                 // but may not be blend with a theme as well as submit buttons
97 97
                 case 'button':
98
-                    $html .= '<a class="ee-ical-btn small ee-button ee-roundish" href="' . $URL;
99
-                    $html .= '" title="' . esc_html__('Add to iCal Calendar', 'event_espresso') . '">';
98
+                    $html .= '<a class="ee-ical-btn small ee-button ee-roundish" href="'.$URL;
99
+                    $html .= '" title="'.esc_html__('Add to iCal Calendar', 'event_espresso').'">';
100 100
                     $html .= ' <span class="dashicons dashicons-calendar"></span>';
101 101
                     $html .= '</a>';
102 102
                     break;
103 103
                 // links are just links that use the calendar dashicon
104 104
                 case 'icon':
105
-                    $html .= '<a class="ee-ical-lnk" href="' . $URL . '" title="';
106
-                    $html .= esc_html__('Add to iCal Calendar', 'event_espresso') . '">';
105
+                    $html .= '<a class="ee-ical-lnk" href="'.$URL.'" title="';
106
+                    $html .= esc_html__('Add to iCal Calendar', 'event_espresso').'">';
107 107
                     $html .= ' <span class="dashicons dashicons-calendar"></span>';
108 108
                     $html .= '</a>';
109 109
                     break;
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
                     }
145 145
 
146 146
                     // Generate filename
147
-                    $filename = $event->slug() . '-' . $datetime->start_date('Y-m-d') . '.ics';
147
+                    $filename = $event->slug().'-'.$datetime->start_date('Y-m-d').'.ics';
148 148
 
149 149
                     // Check the datetime status has not been cancelled and set the ics value accordingly
150 150
                     $status = $datetime->get_active_status();
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
                     // Create array of ics details, escape strings, convert timestamps to ics format, etc
154 154
                     $ics_data = [
155 155
                         'ORGANIZER_NAME' => EE_Registry::instance()->CFG->organization->name,
156
-                        'UID'            => md5($event->name() . $event->ID() . $datetime->ID()),
156
+                        'UID'            => md5($event->name().$event->ID().$datetime->ID()),
157 157
                         'ORGANIZER'      => EE_Registry::instance()->CFG->organization->email,
158 158
                         'DTSTAMP'        => date(EED_Ical::iCal_datetime_format),
159 159
                         'LOCATION'       => $location,
@@ -174,9 +174,9 @@  discard block
 block discarded – undo
174 174
                     foreach ($ics_data as $key => $value) {
175 175
                         // Description is escaped differently from all all values
176 176
                         if ($key === 'DESCRIPTION') {
177
-                            $ics_data[ $key ] = EED_Ical::_escape_ICal_description(wp_strip_all_tags($value));
177
+                            $ics_data[$key] = EED_Ical::_escape_ICal_description(wp_strip_all_tags($value));
178 178
                         } else {
179
-                            $ics_data[ $key ] = EED_Ical::_escape_ICal_data($value);
179
+                            $ics_data[$key] = EED_Ical::_escape_ICal_data($value);
180 180
                         }
181 181
                     }
182 182
 
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 
187 187
                     // set headers
188 188
                     header('Content-type: text/calendar; charset=utf-8');
189
-                    header('Content-Disposition: attachment; filename="' . $filename . '"');
189
+                    header('Content-Disposition: attachment; filename="'.$filename.'"');
190 190
                     header('Cache-Control: private, max-age=0, must-revalidate');
191 191
                     header('Pragma: public');
192 192
                     header('Content-Type: application/octet-stream');
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 
205 205
                     // Output all remaining values from ics_data.
206 206
                     foreach ($ics_data as $key => $value) {
207
-                        echo $key . ':' . $value . "\r\n";
207
+                        echo $key.':'.$value."\r\n";
208 208
                     }
209 209
 
210 210
                     echo "END:VEVENT\r\n";
Please login to merge, or discard this patch.
Indentation   +231 added lines, -231 removed lines patch added patch discarded remove patch
@@ -13,235 +13,235 @@
 block discarded – undo
13 13
 class EED_Ical extends EED_Module
14 14
 {
15 15
 
16
-    const iCal_datetime_format = 'Ymd\THis\Z';
17
-
18
-
19
-    /**
20
-     * @return EED_Ical|EED_Module
21
-     * @throws EE_Error
22
-     * @throws ReflectionException
23
-     */
24
-    public static function instance()
25
-    {
26
-        return parent::get_instance(__CLASS__);
27
-    }
28
-
29
-
30
-    /**
31
-     *    set_hooks - for hooking into EE Core, other modules, etc
32
-     *
33
-     * @return    void
34
-     */
35
-    public static function set_hooks()
36
-    {
37
-        // create download buttons
38
-        add_filter(
39
-            'FHEE__espresso_list_of_event_dates__datetime_html',
40
-            ['EED_Ical', 'generate_add_to_iCal_button'],
41
-            10,
42
-            2
43
-        );
44
-        // process ics download request
45
-        EE_Config::register_route('download_ics_file', 'EED_Ical', 'download_ics_file');
46
-    }
47
-
48
-
49
-    /**
50
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
51
-     *
52
-     * @return    void
53
-     */
54
-    public static function set_hooks_admin()
55
-    {
56
-    }
57
-
58
-
59
-    /**
60
-     *    run - initial module setup
61
-     *
62
-     * @param WP $WP
63
-     * @return    void
64
-     */
65
-    public function run($WP)
66
-    {
67
-    }
68
-
69
-
70
-    /**
71
-     * @param $html
72
-     * @param $datetime
73
-     * @return string
74
-     * @throws EE_Error
75
-     * @throws ReflectionException
76
-     */
77
-    public static function generate_add_to_iCal_button($html, $datetime)
78
-    {
79
-        // first verify a proper datetime object has been received
80
-        if ($datetime instanceof EE_Datetime) {
81
-            // set whether a link or submit button is shown
82
-            $iCal_type = apply_filters('FHEE__EED_Ical__generate_add_to_iCal_button__iCal_type', 'submit');
83
-            // generate a link to the route we registered in set_hooks()
84
-            $URL = add_query_arg(['ee' => 'download_ics_file', 'ics_id' => $datetime->ID()], site_url());
85
-            $URL = esc_url_Raw($URL);
86
-            // what type ?
87
-            switch ($iCal_type) {
88
-                // submit buttons appear as buttons and are very compatible with a theme's style
89
-                case 'submit':
90
-                    $html .= '<form id="download-iCal-frm-' . $datetime->ID();
91
-                    $html .= '" class="download-iCal-frm" action="' . $URL . '" method="post" >';
92
-                    $html .= '<input type="submit" class="ee-ical-sbmt" value="&#xf145;" title="';
93
-                    $html .= esc_html__('Add to iCal Calendar', 'event_espresso') . '"/>';
94
-                    $html .= '</form>';
95
-                    break;
96
-                // buttons are just links that have been styled to appear as buttons,
97
-                // but may not be blend with a theme as well as submit buttons
98
-                case 'button':
99
-                    $html .= '<a class="ee-ical-btn small ee-button ee-roundish" href="' . $URL;
100
-                    $html .= '" title="' . esc_html__('Add to iCal Calendar', 'event_espresso') . '">';
101
-                    $html .= ' <span class="dashicons dashicons-calendar"></span>';
102
-                    $html .= '</a>';
103
-                    break;
104
-                // links are just links that use the calendar dashicon
105
-                case 'icon':
106
-                    $html .= '<a class="ee-ical-lnk" href="' . $URL . '" title="';
107
-                    $html .= esc_html__('Add to iCal Calendar', 'event_espresso') . '">';
108
-                    $html .= ' <span class="dashicons dashicons-calendar"></span>';
109
-                    $html .= '</a>';
110
-                    break;
111
-            }
112
-        }
113
-        return $html;
114
-    }
115
-
116
-
117
-    /**
118
-     * @return void
119
-     * @throws EE_Error
120
-     * @throws ReflectionException
121
-     */
122
-    public static function download_ics_file()
123
-    {
124
-        $request = self::getRequest();
125
-        if ($request->requestParamIsSet('ics_id')) {
126
-            $DTT_ID   = $request->getRequestParam('ics_id', 0, 'int');
127
-            $datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
128
-            if ($datetime instanceof EE_Datetime) {
129
-                // get related event, venues, and event categories
130
-                $event = $datetime->event();
131
-                if ($event instanceof EE_Event) {
132
-                    // get related category Term object and it's name
133
-                    $category = $event->first_event_category();
134
-                    if ($category instanceof EE_Term) {
135
-                        $category = $category->name();
136
-                    }
137
-                    $location = '';
138
-                    // get first related venue and convert to CSV string
139
-                    $venue = $event->venues(['limit' => 1]);
140
-                    if (is_array($venue) && ! empty($venue)) {
141
-                        $venue = array_shift($venue);
142
-                        if ($venue instanceof EE_Venue) {
143
-                            $location = espresso_venue_raw_address('inline', $venue->ID(), false);
144
-                        }
145
-                    }
146
-
147
-                    // Generate filename
148
-                    $filename = $event->slug() . '-' . $datetime->start_date('Y-m-d') . '.ics';
149
-
150
-                    // Check the datetime status has not been cancelled and set the ics value accordingly
151
-                    $status = $datetime->get_active_status();
152
-                    $status = $status === EE_Datetime::cancelled ? 'CANCELLED' : 'CONFIRMED';
153
-
154
-                    // Create array of ics details, escape strings, convert timestamps to ics format, etc
155
-                    $ics_data = [
156
-                        'ORGANIZER_NAME' => EE_Registry::instance()->CFG->organization->name,
157
-                        'UID'            => md5($event->name() . $event->ID() . $datetime->ID()),
158
-                        'ORGANIZER'      => EE_Registry::instance()->CFG->organization->email,
159
-                        'DTSTAMP'        => date(EED_Ical::iCal_datetime_format),
160
-                        'LOCATION'       => $location,
161
-                        'SUMMARY'        => $event->name(),
162
-                        'DESCRIPTION'    => wp_strip_all_tags($event->description()),
163
-                        'STATUS'         => $status,
164
-                        'CATEGORIES'     => $category,
165
-                        'URL;VALUE=URI'  => get_permalink($event->ID()),
166
-                        'DTSTART'        => date(EED_Ical::iCal_datetime_format, $datetime->start()),
167
-                        'DTEND'          => date(EED_Ical::iCal_datetime_format, $datetime->end()),
168
-                    ];
169
-
170
-                    // Filter the values used within the ics output.
171
-                    // NOTE - all values within ics_data will be escaped automatically.
172
-                    $ics_data = apply_filters('FHEE__EED_Ical__download_ics_file_ics_data', $ics_data, $datetime);
173
-
174
-                    // Escape all ics data
175
-                    foreach ($ics_data as $key => $value) {
176
-                        // Description is escaped differently from all all values
177
-                        if ($key === 'DESCRIPTION') {
178
-                            $ics_data[ $key ] = EED_Ical::_escape_ICal_description(wp_strip_all_tags($value));
179
-                        } else {
180
-                            $ics_data[ $key ] = EED_Ical::_escape_ICal_data($value);
181
-                        }
182
-                    }
183
-
184
-                    // Pull the organizer name from ics_data and remove it from the array.
185
-                    $organizer_name = isset($ics_data['ORGANIZER_NAME'])
186
-                        ? $ics_data['ORGANIZER_NAME']
187
-                        : '';
188
-                    unset($ics_data['ORGANIZER_NAME']);
189
-
190
-                    // set headers
191
-                    header('Content-type: text/calendar; charset=utf-8');
192
-                    header('Content-Disposition: attachment; filename="' . $filename . '"');
193
-                    header('Cache-Control: private, max-age=0, must-revalidate');
194
-                    header('Pragma: public');
195
-                    header('Content-Type: application/octet-stream');
196
-                    header('Content-Type: application/force-download');
197
-                    header('Cache-Control: no-cache, must-revalidate');
198
-                    header('Content-Transfer-Encoding: binary');
199
-                    header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // past date
200
-                    ini_set('zlib.output_compression', '0');
201
-                    // echo the output
202
-                    echo "BEGIN:VCALENDAR\r\n";
203
-                    echo "VERSION:2.0\r\n";
204
-                    echo "PRODID:-//{$organizer_name}//NONSGML PDA Calendar Version 1.0//EN\r\n";
205
-                    echo "CALSCALE:GREGORIAN\r\n";
206
-                    echo "BEGIN:VEVENT\r\n";
207
-
208
-                    // Output all remaining values from ics_data.
209
-                    foreach ($ics_data as $key => $value) {
210
-                        echo $key . ':' . $value . "\r\n";
211
-                    }
212
-
213
-                    echo "END:VEVENT\r\n";
214
-                    echo "END:VCALENDAR\r\n";
215
-                }
216
-            }
217
-        }
218
-        die();
219
-    }
220
-
221
-
222
-    /**
223
-     *    _escape_ICal_data
224
-     *
225
-     * @param string $string
226
-     * @return    string
227
-     */
228
-    private static function _escape_ICal_data($string = '')
229
-    {
230
-        return preg_replace('/([\,;])/', '\\\$1', $string);
231
-    }
232
-
233
-
234
-    /**
235
-     *    _escape_ICal_description
236
-     *
237
-     * @param string $description
238
-     * @return    string
239
-     */
240
-    private static function _escape_ICal_description($description = '')
241
-    {
242
-        // Escape special chars within the description
243
-        $description = EED_Ical::_escape_ICal_data($description);
244
-        // Remove line breaks and output in iCal format
245
-        return str_replace(["\r\n", "\n"], '\n', $description);
246
-    }
16
+	const iCal_datetime_format = 'Ymd\THis\Z';
17
+
18
+
19
+	/**
20
+	 * @return EED_Ical|EED_Module
21
+	 * @throws EE_Error
22
+	 * @throws ReflectionException
23
+	 */
24
+	public static function instance()
25
+	{
26
+		return parent::get_instance(__CLASS__);
27
+	}
28
+
29
+
30
+	/**
31
+	 *    set_hooks - for hooking into EE Core, other modules, etc
32
+	 *
33
+	 * @return    void
34
+	 */
35
+	public static function set_hooks()
36
+	{
37
+		// create download buttons
38
+		add_filter(
39
+			'FHEE__espresso_list_of_event_dates__datetime_html',
40
+			['EED_Ical', 'generate_add_to_iCal_button'],
41
+			10,
42
+			2
43
+		);
44
+		// process ics download request
45
+		EE_Config::register_route('download_ics_file', 'EED_Ical', 'download_ics_file');
46
+	}
47
+
48
+
49
+	/**
50
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
51
+	 *
52
+	 * @return    void
53
+	 */
54
+	public static function set_hooks_admin()
55
+	{
56
+	}
57
+
58
+
59
+	/**
60
+	 *    run - initial module setup
61
+	 *
62
+	 * @param WP $WP
63
+	 * @return    void
64
+	 */
65
+	public function run($WP)
66
+	{
67
+	}
68
+
69
+
70
+	/**
71
+	 * @param $html
72
+	 * @param $datetime
73
+	 * @return string
74
+	 * @throws EE_Error
75
+	 * @throws ReflectionException
76
+	 */
77
+	public static function generate_add_to_iCal_button($html, $datetime)
78
+	{
79
+		// first verify a proper datetime object has been received
80
+		if ($datetime instanceof EE_Datetime) {
81
+			// set whether a link or submit button is shown
82
+			$iCal_type = apply_filters('FHEE__EED_Ical__generate_add_to_iCal_button__iCal_type', 'submit');
83
+			// generate a link to the route we registered in set_hooks()
84
+			$URL = add_query_arg(['ee' => 'download_ics_file', 'ics_id' => $datetime->ID()], site_url());
85
+			$URL = esc_url_Raw($URL);
86
+			// what type ?
87
+			switch ($iCal_type) {
88
+				// submit buttons appear as buttons and are very compatible with a theme's style
89
+				case 'submit':
90
+					$html .= '<form id="download-iCal-frm-' . $datetime->ID();
91
+					$html .= '" class="download-iCal-frm" action="' . $URL . '" method="post" >';
92
+					$html .= '<input type="submit" class="ee-ical-sbmt" value="&#xf145;" title="';
93
+					$html .= esc_html__('Add to iCal Calendar', 'event_espresso') . '"/>';
94
+					$html .= '</form>';
95
+					break;
96
+				// buttons are just links that have been styled to appear as buttons,
97
+				// but may not be blend with a theme as well as submit buttons
98
+				case 'button':
99
+					$html .= '<a class="ee-ical-btn small ee-button ee-roundish" href="' . $URL;
100
+					$html .= '" title="' . esc_html__('Add to iCal Calendar', 'event_espresso') . '">';
101
+					$html .= ' <span class="dashicons dashicons-calendar"></span>';
102
+					$html .= '</a>';
103
+					break;
104
+				// links are just links that use the calendar dashicon
105
+				case 'icon':
106
+					$html .= '<a class="ee-ical-lnk" href="' . $URL . '" title="';
107
+					$html .= esc_html__('Add to iCal Calendar', 'event_espresso') . '">';
108
+					$html .= ' <span class="dashicons dashicons-calendar"></span>';
109
+					$html .= '</a>';
110
+					break;
111
+			}
112
+		}
113
+		return $html;
114
+	}
115
+
116
+
117
+	/**
118
+	 * @return void
119
+	 * @throws EE_Error
120
+	 * @throws ReflectionException
121
+	 */
122
+	public static function download_ics_file()
123
+	{
124
+		$request = self::getRequest();
125
+		if ($request->requestParamIsSet('ics_id')) {
126
+			$DTT_ID   = $request->getRequestParam('ics_id', 0, 'int');
127
+			$datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
128
+			if ($datetime instanceof EE_Datetime) {
129
+				// get related event, venues, and event categories
130
+				$event = $datetime->event();
131
+				if ($event instanceof EE_Event) {
132
+					// get related category Term object and it's name
133
+					$category = $event->first_event_category();
134
+					if ($category instanceof EE_Term) {
135
+						$category = $category->name();
136
+					}
137
+					$location = '';
138
+					// get first related venue and convert to CSV string
139
+					$venue = $event->venues(['limit' => 1]);
140
+					if (is_array($venue) && ! empty($venue)) {
141
+						$venue = array_shift($venue);
142
+						if ($venue instanceof EE_Venue) {
143
+							$location = espresso_venue_raw_address('inline', $venue->ID(), false);
144
+						}
145
+					}
146
+
147
+					// Generate filename
148
+					$filename = $event->slug() . '-' . $datetime->start_date('Y-m-d') . '.ics';
149
+
150
+					// Check the datetime status has not been cancelled and set the ics value accordingly
151
+					$status = $datetime->get_active_status();
152
+					$status = $status === EE_Datetime::cancelled ? 'CANCELLED' : 'CONFIRMED';
153
+
154
+					// Create array of ics details, escape strings, convert timestamps to ics format, etc
155
+					$ics_data = [
156
+						'ORGANIZER_NAME' => EE_Registry::instance()->CFG->organization->name,
157
+						'UID'            => md5($event->name() . $event->ID() . $datetime->ID()),
158
+						'ORGANIZER'      => EE_Registry::instance()->CFG->organization->email,
159
+						'DTSTAMP'        => date(EED_Ical::iCal_datetime_format),
160
+						'LOCATION'       => $location,
161
+						'SUMMARY'        => $event->name(),
162
+						'DESCRIPTION'    => wp_strip_all_tags($event->description()),
163
+						'STATUS'         => $status,
164
+						'CATEGORIES'     => $category,
165
+						'URL;VALUE=URI'  => get_permalink($event->ID()),
166
+						'DTSTART'        => date(EED_Ical::iCal_datetime_format, $datetime->start()),
167
+						'DTEND'          => date(EED_Ical::iCal_datetime_format, $datetime->end()),
168
+					];
169
+
170
+					// Filter the values used within the ics output.
171
+					// NOTE - all values within ics_data will be escaped automatically.
172
+					$ics_data = apply_filters('FHEE__EED_Ical__download_ics_file_ics_data', $ics_data, $datetime);
173
+
174
+					// Escape all ics data
175
+					foreach ($ics_data as $key => $value) {
176
+						// Description is escaped differently from all all values
177
+						if ($key === 'DESCRIPTION') {
178
+							$ics_data[ $key ] = EED_Ical::_escape_ICal_description(wp_strip_all_tags($value));
179
+						} else {
180
+							$ics_data[ $key ] = EED_Ical::_escape_ICal_data($value);
181
+						}
182
+					}
183
+
184
+					// Pull the organizer name from ics_data and remove it from the array.
185
+					$organizer_name = isset($ics_data['ORGANIZER_NAME'])
186
+						? $ics_data['ORGANIZER_NAME']
187
+						: '';
188
+					unset($ics_data['ORGANIZER_NAME']);
189
+
190
+					// set headers
191
+					header('Content-type: text/calendar; charset=utf-8');
192
+					header('Content-Disposition: attachment; filename="' . $filename . '"');
193
+					header('Cache-Control: private, max-age=0, must-revalidate');
194
+					header('Pragma: public');
195
+					header('Content-Type: application/octet-stream');
196
+					header('Content-Type: application/force-download');
197
+					header('Cache-Control: no-cache, must-revalidate');
198
+					header('Content-Transfer-Encoding: binary');
199
+					header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // past date
200
+					ini_set('zlib.output_compression', '0');
201
+					// echo the output
202
+					echo "BEGIN:VCALENDAR\r\n";
203
+					echo "VERSION:2.0\r\n";
204
+					echo "PRODID:-//{$organizer_name}//NONSGML PDA Calendar Version 1.0//EN\r\n";
205
+					echo "CALSCALE:GREGORIAN\r\n";
206
+					echo "BEGIN:VEVENT\r\n";
207
+
208
+					// Output all remaining values from ics_data.
209
+					foreach ($ics_data as $key => $value) {
210
+						echo $key . ':' . $value . "\r\n";
211
+					}
212
+
213
+					echo "END:VEVENT\r\n";
214
+					echo "END:VCALENDAR\r\n";
215
+				}
216
+			}
217
+		}
218
+		die();
219
+	}
220
+
221
+
222
+	/**
223
+	 *    _escape_ICal_data
224
+	 *
225
+	 * @param string $string
226
+	 * @return    string
227
+	 */
228
+	private static function _escape_ICal_data($string = '')
229
+	{
230
+		return preg_replace('/([\,;])/', '\\\$1', $string);
231
+	}
232
+
233
+
234
+	/**
235
+	 *    _escape_ICal_description
236
+	 *
237
+	 * @param string $description
238
+	 * @return    string
239
+	 */
240
+	private static function _escape_ICal_description($description = '')
241
+	{
242
+		// Escape special chars within the description
243
+		$description = EED_Ical::_escape_ICal_data($description);
244
+		// Remove line breaks and output in iCal format
245
+		return str_replace(["\r\n", "\n"], '\n', $description);
246
+	}
247 247
 }
Please login to merge, or discard this patch.
core/libraries/shortcodes/EE_Transaction_Shortcodes.lib.php 2 patches
Indentation   +775 added lines, -775 removed lines patch added patch discarded remove patch
@@ -17,783 +17,783 @@
 block discarded – undo
17 17
 class EE_Transaction_Shortcodes extends EE_Shortcodes
18 18
 {
19 19
 
20
-    /**
21
-     * @var EE_Payment_Method $_invoice_pm the invoice payment method for use in invoices etc
22
-     */
23
-    protected $_invoice_pm;
24
-
25
-
26
-    protected function _init_props()
27
-    {
28
-        $this->label = esc_html__('Transaction Shortcodes', 'event_espresso');
29
-        $this->description = esc_html__('All shortcodes specific to transaction related data', 'event_espresso');
30
-        $this->_shortcodes = array(
31
-            '[TXN_ID]'                          => esc_html__('The transaction id for the purchase.', 'event_espresso'),
32
-            '[PAYMENT_URL]'                     => esc_html__(
33
-                'This is a link to make a payment for the event',
34
-                'event_espresso'
35
-            ),
36
-            '[PAYMENT_LINK_IF_NEEDED_*]'        => esc_html__(
37
-                'This is a special dynamic shortcode that allows one to insert a payment link conditional on there being amount owing on the transaction. Three params are available on this shortcode:',
38
-                'event_espresso'
39
-            )
40
-                                                   . '<ul>'
41
-                                                   . '<li>'
42
-                                                   . sprintf(
43
-                                                       esc_html__(
44
-                                                           '%sclass:%s This can be used to indicate css class is given to the containing css element (default is "callout").',
45
-                                                           'event_espresso'
46
-                                                       ),
47
-                                                       '<strong>',
48
-                                                       '</strong>'
49
-                                                   )
50
-                                                   . '</li>'
51
-                                                   . '<li>'
52
-                                                   . sprintf(
53
-                                                       esc_html__(
54
-                                                           '%scustom_text:%s This should be a sprintf format text string (with %%s for where the hyperlink tags go) that is used for the generated link text (The default is "You can %%smake a payment here »%%s.)',
55
-                                                           'event_espresso'
56
-                                                       ),
57
-                                                       '<strong>',
58
-                                                       '</strong>'
59
-                                                   )
60
-                                                   . '</li>'
61
-                                                   . '<li>'
62
-                                                   . sprintf(
63
-                                                       esc_html__(
64
-                                                           '%scontainer_tag:%s Use this to indicate what container tag you want surrounding the payment link (default is "p").',
65
-                                                           'event_espresso'
66
-                                                       ),
67
-                                                       '<strong>',
68
-                                                       '</strong>'
69
-                                                   )
70
-                                                   . '</li>'
71
-                                                   . '</ul>',
72
-            '[PAYMENT_DUE_DATE_*]'              => esc_html__(
73
-                'This is a special dynamic shortcode that allows one to output a payment due date.  It will only result in a date shown if there is money owing.  Three parameters are available on this shortcode:',
74
-                'event_espresso'
75
-            )
76
-                                                   . '<ul>'
77
-                                                   . '<li>'
78
-                                                   . sprintf(
79
-                                                       esc_html__(
80
-                                                           '%sformat:%s This is used to indicate what format the date is in.  Default is whatever is set as date formats for your website.',
81
-                                                           'event_espresso'
82
-                                                       ),
83
-                                                       '<strong>',
84
-                                                       '</strong>'
85
-                                                   )
86
-                                                   . '</li>'
87
-                                                   . '<li>'
88
-                                                   . sprintf(
89
-                                                       esc_html__(
90
-                                                           '%sdays_until_due:%s This is the number of days form the transaction creation date that the payment is due.  Defaults to 30.',
91
-                                                           'event_espresso'
92
-                                                       ),
93
-                                                       '<strong>',
94
-                                                       '</strong>'
95
-                                                   )
96
-                                                   . '</li>'
97
-                                                   . '<li>'
98
-                                                   . sprintf(
99
-                                                       esc_html__(
100
-                                                           '%sprefix_text:%s You can use this to indicate what text will prefix the date string.  Defaults to "Payment in full due by:"',
101
-                                                           'event_espresso'
102
-                                                       ),
103
-                                                       '<strong>',
104
-                                                       '</strong>'
105
-                                                   )
106
-                                                   . '</li>',
107
-            '[INVOICE_LINK]'                    => esc_html__(
108
-                'This is a full html link to the invoice',
109
-                'event_espresso'
110
-            ),
111
-            '[INVOICE_URL]'                     => esc_html__(
112
-                'This is just the url for the invoice',
113
-                'event_espresso'
114
-            ),
115
-            '[INVOICE_LOGO_URL]'                => esc_html__(
116
-                'This returns the url for the logo uploaded via the invoice settings page.',
117
-                'event_espresso'
118
-            ),
119
-            '[INVOICE_LOGO]'                    => esc_html__(
120
-                'This returns the logo uploaded via the invoice settings page wrapped in img_tags and with a "logo screen" classes. The image size is also set in the img tags automatically to match the uploaded logo.',
121
-                'event_espresso'
122
-            ),
123
-            '[INVOICE_PAYEE_NAME]'              => esc_html__(
124
-                'This will parse to either: the value of the "Company Name" field in the invoice payment method settings; if that is blank, then the value of the Company Name in the "Your Organization Settings", if that is blank then an empty string.',
125
-                'event_espresso'
126
-            ),
127
-            '[INVOICE_PAYEE_ADDRESS]'           => esc_html__(
128
-                'This will parse to either: the value of the "Company Address" field in the invoice payment method settings; if that is blank, then the value of the Company Address in the "Your Organization Settings", if that is blank then an empty string.',
129
-                'event_espresso'
130
-            ),
131
-            '[INVOICE_PAYMENT_INSTRUCTIONS]'    => esc_html__(
132
-                'This will parse to the value of the "Payment Instructions" field found on the Invoice payment methods settings page',
133
-                'event_espresso'
134
-            ),
135
-            '[INVOICE_PAYEE_EMAIL]'             => esc_html__(
136
-                'This will parse to either: the value of the "Company Email" field in the invoice payment method settings; if that is blank, then the value of the Company Email in the "Your Organization Settings", if that is blank then an empty string.',
137
-                'event_espresso'
138
-            ),
139
-            '[INVOICE_PAYEE_TAX_NUMBER_*]'      => sprintf(
140
-                esc_html__(
141
-                    'This will parse to either: the value of the "Company Tax Number" field in the invoice payment method settings; if that is blank, then the value of the Company Tax Number in the "Your Organization Settings", if that is blank then an empty string. Note this is also a special dynamic shortcode. You can use the "prefix" parameter to indicate what text you want to use as a prefix before this tax number.  It defaults to "VAT/Tax Number:". To change this prefix you do the following format for this shortcode: %1$s[INVOICE_PAYEE_TAX_NUMBER_* prefix="GST:"]%2$s and that will output: GST: 12345t56.  If you have no tax number in your settings, then no prefix will be output either.',
142
-                    'event_espresso'
143
-                ),
144
-                '<code>',
145
-                '</code>'
146
-            ),
147
-            '[TOTAL_COST]'                      => esc_html__('The total cost for the transaction', 'event_espresso'),
148
-            '[TXN_STATUS]'                      => esc_html__(
149
-                'The transaction status for the transaction.',
150
-                'event_espresso'
151
-            ),
152
-            '[TXN_STATUS_ID]'                   => esc_html__(
153
-                'The ID representing the transaction status as saved in the db.  This tends to be useful for including with css classes for styling certain statuses differently from others.',
154
-                'event_espresso'
155
-            ),
156
-            '[PAYMENT_STATUS]'                  => esc_html__(
157
-                'The transaction status for the transaction. This parses to the same value as the [TXN_STATUS] shortcode and still remains here for legacy support.',
158
-                'event_espresso'
159
-            ),
160
-            '[PAYMENT_GATEWAY]'                 => esc_html__(
161
-                'The payment gateway used for the transaction',
162
-                'event_espresso'
163
-            ),
164
-            '[AMOUNT_PAID]'                     => esc_html__(
165
-                'The amount paid or refunded.  This will only have a value if there was a payment or refund at the time of generating the message.',
166
-                'event_espresso'
167
-            ),
168
-            '[LAST_AMOUNT_PAID]'                => esc_html__(
169
-                'This is the last payment or refund made on the transaction related to the message being generated.',
170
-                'event_espresso'
171
-            ),
172
-            '[TOTAL_AMOUNT_PAID]'               => esc_html__(
173
-                'This parses to the total amount paid over all payments',
174
-                'event_espresso'
175
-            ),
176
-            '[TOTAL_OWING]'                     => esc_html__(
177
-                'The total owing on a transaction with no attributes.',
178
-                'event_espresso'
179
-            ),
180
-            '[TXN_SUBTOTAL]'                    => esc_html__('The subtotal for all txn line items.', 'event_espresso'),
181
-            '[TXN_TAX_SUBTOTAL]'                => esc_html__('The subtotal for all tax line items.', 'event_espresso'),
182
-            '[OWING_STATUS_MESSAGE_*]'          => esc_html__(
183
-                'A dynamic shortcode for adjusting how total owing gets shown. The acceptable attributes on the shortcode are:',
184
-                'event_espresso'
185
-            )
186
-                                                   . '<p></ul>'
187
-                                                   . '<li><strong>still_owing</strong>:'
188
-                                                   . esc_html__(
189
-                                                       'If the transaction is not paid in full, then whatever is set for this attribute is shown (otherwise its just the amount owing). The default is:',
190
-                                                       'event_espresso'
191
-                                                   )
192
-                                                   . sprintf(
193
-                                                       esc_html__('%sPlease make a payment.%s', 'event_espresso'),
194
-                                                       '<a href="[PAYMENT_URL]" class="noPrint">',
195
-                                                       '</a>'
196
-                                                   )
197
-                                                   . '</li>'
198
-                                                   .
199
-                                                   '<li><strong>none_owing</strong>:'
200
-                                                   . esc_html__(
201
-                                                       'If the transaction is paid in full, then you can indicate how this gets displayed.  Note, that it defaults to just be the total owing.',
202
-                                                       'event_espresso'
203
-                                                   )
204
-                                                   . '</li></ul></p>',
205
-            '[TXN_TOTAL_TICKETS]'               => esc_html__(
206
-                'The total number of all tickets purchased in a transaction',
207
-                'event_espresso'
208
-            ),
209
-            '[TKT_QTY_PURCHASED]'               => sprintf(
210
-                esc_html__(
211
-                    'The total number of all tickets purchased in a transaction. %1$sNOTE: This shortcode is good to use in the "[TICKET_LIST]" field but has been deprecated from all other contexts in favor of the more explicit [TXN_TOTAL_TICKETS] shortcode.%2$s',
212
-                    'event_espresso'
213
-                ),
214
-                '<strong>',
215
-                '</strong>'
216
-            ),
217
-            '[TRANSACTION_ADMIN_URL]'           => esc_html__(
218
-                'The url to the admin page for this transaction',
219
-                'event_espresso'
220
-            ),
221
-            '[RECEIPT_URL]'                     => esc_html__(
222
-                'This parses to the generated url for retrieving the receipt for the transaction',
223
-                'event_espresso'
224
-            ),
225
-            '[INVOICE_RECEIPT_SWITCHER_URL]'    => esc_html__(
226
-                'This parses to the url that will switch to the receipt if an invoice is displayed, and switch to the invoice if receipt is displayed. If a message type OTHER than invoice or receipt is displayed then this will just return the url for the invoice. If the related message type is not active  then will parse to an empty string.',
227
-                'event_espresso'
228
-            ),
229
-            '[INVOICE_RECEIPT_SWITCHER_BUTTON]' => sprintf(
230
-                esc_html__(
231
-                    'The same as %1$s%2$s except this returns the html for a button linked to the invoice or receipt.',
232
-                    'event_espresso'
233
-                ),
234
-                '<code>[INVOICE_RECEIPT_SWITCHER_URL]',
235
-                '</code>'
236
-            ),
237
-            '[LAST_PAYMENT_TRANSACTION_ID]'     => esc_html__(
238
-                'This will output the value of the payment transaction id for the last payment made on the transaction. Note, if a specific payment was included for message generation, that will be used when parsing the shortcode.',
239
-                'event_espresso'
240
-            ),
241
-        );
242
-    }
243
-
244
-
245
-    /**
246
-     * @param  string $shortcode the shortcode to be parsed.
247
-     * @return string parsed shortcode
248
-     * @throws EE_Error
249
-     * @throws InvalidArgumentException
250
-     * @throws ReflectionException
251
-     * @throws InvalidDataTypeException
252
-     * @throws InvalidInterfaceException
253
-     */
254
-    protected function _parser($shortcode)
255
-    {
256
-        // attempt to get the transaction.  Since this is potentially used in more fields, we may have to look in the
257
-        // _extra_data for the transaction.
258
-        $transaction = $this->_data->txn instanceof EE_Transaction ? $this->_data->txn : null;
259
-        $transaction = ! $transaction instanceof EE_Transaction
260
-                       && is_array($this->_extra_data)
261
-                       && isset($this->_extra_data['data'])
262
-                       && $this->_extra_data['data'] instanceof EE_Messages_Addressee
263
-            ? $this->_extra_data['data']->txn
264
-            : $transaction;
265
-        // payment
266
-        $payment = $this->_data->payment instanceof EE_Payment ? $this->_data->payment : null;
267
-        $payment = ! $payment instanceof EE_Payment
268
-                   && is_array($this->_extra_data)
269
-                   && isset($this->_extra_data['data'])
270
-                   && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->payment
271
-            : $payment;
272
-        if (! $transaction instanceof EE_Transaction) {
273
-            return '';
274
-        }
275
-        switch ($shortcode) {
276
-            case '[TXN_ID]':
277
-                return $transaction->ID();
278
-                break;
279
-            case '[PAYMENT_URL]':
280
-                $payment_url = $transaction->payment_overview_url();
281
-                return empty($payment_url)
282
-                    ? esc_html__('http://dummypaymenturlforpreview.com', 'event_espresso')
283
-                    : $payment_url;
284
-                break;
285
-            case '[INVOICE_LINK]':
286
-                $invoice_url = $transaction->invoice_url();
287
-                $invoice_url = empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url;
288
-                return sprintf(
289
-                    esc_html__('%sClick here for Invoice%s', 'event_espresso'),
290
-                    '<a href="' . $invoice_url . '">',
291
-                    '</a>'
292
-                );
293
-                break;
294
-            case '[INVOICE_URL]':
295
-                $invoice_url = $transaction->invoice_url();
296
-                return empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url;
297
-                break;
298
-            case '[INVOICE_LOGO_URL]':
299
-                return $this->_get_invoice_logo();
300
-                break;
301
-            case '[INVOICE_LOGO]':
302
-                return $this->_get_invoice_logo(true);
303
-                break;
304
-            case '[INVOICE_PAYEE_NAME]':
305
-                return $this->_get_invoice_payee_name();
306
-                break;
307
-            case '[INVOICE_PAYEE_ADDRESS]':
308
-                return $this->_get_invoice_payee_address();
309
-                break;
310
-            case '[INVOICE_PAYMENT_INSTRUCTIONS]':
311
-                return $this->_get_invoice_payment_instructions();
312
-                break;
313
-            case '[INVOICE_PAYEE_EMAIL]':
314
-                return $this->_get_invoice_payee_email();
315
-                break;
316
-            case '[TOTAL_COST]':
317
-                $total = $transaction->total();
318
-                return ! empty($total) ? EEH_Template::format_currency($total) : '';
319
-                break;
320
-            case '[PAYMENT_STATUS]':
321
-                $status = $transaction->pretty_status();
322
-                return ! empty($status) ? $status : esc_html__('Unknown', 'event_espresso');
323
-                break; /**/
324
-            // note the [payment_status] shortcode is kind of misleading because payment status might be different
325
-            // from txn status so I'm adding this here for clarity.
326
-            case '[TXN_STATUS]':
327
-                $status = $transaction->pretty_status();
328
-                return ! empty($status) ? $status : esc_html__('Unknown', 'event_espresso');
329
-                break;
330
-            case '[TXN_STATUS_ID]':
331
-                return $transaction->status_ID();
332
-                break;
333
-            case '[PAYMENT_GATEWAY]':
334
-                return $this->_get_payment_gateway($transaction);
335
-                break;
336
-            case '[AMOUNT_PAID]':
337
-                return $payment instanceof EE_Payment
338
-                    ? EEH_Template::format_currency($payment->amount())
339
-                    : EEH_Template::format_currency(0);
340
-                break;
341
-            case '[LAST_AMOUNT_PAID]':
342
-                $last_payment = $transaction->last_payment();
343
-                return $last_payment instanceof EE_Payment
344
-                    ? EEH_Template::format_currency($last_payment->amount())
345
-                    : EEH_Template::format_currency(0);
346
-            case '[TOTAL_AMOUNT_PAID]':
347
-                return EEH_Template::format_currency($transaction->paid());
348
-                break;
349
-            case '[TOTAL_OWING]':
350
-                $total_owing = $transaction->remaining();
351
-                return EEH_Template::format_currency($total_owing);
352
-                break;
353
-            case '[TXN_SUBTOTAL]':
354
-                return EEH_Template::format_currency($this->_get_subtotal());
355
-                break;
356
-            case '[TXN_TAX_SUBTOTAL]':
357
-                return EEH_Template::format_currency($this->_get_subtotal(true));
358
-                break;
359
-            case '[TKT_QTY_PURCHASED]':
360
-            case '[TXN_TOTAL_TICKETS]':
361
-                return $this->_data->total_ticket_count;
362
-                break;
363
-            case '[TRANSACTION_ADMIN_URL]':
364
-                require_once EE_CORE . 'admin/EE_Admin_Page.core.php';
365
-                $query_args = array(
366
-                    'page'   => 'espresso_transactions',
367
-                    'action' => 'view_transaction',
368
-                    'TXN_ID' => $transaction->ID(),
369
-                );
370
-                $url = EE_Admin_Page::add_query_args_and_nonce($query_args, admin_url('admin.php'));
371
-                return $url;
372
-                break;
373
-            case '[RECEIPT_URL]':
374
-                // get primary_registration
375
-                $reg = $this->_data->primary_reg_obj;
376
-                if (! $reg instanceof EE_Registration) {
377
-                    return '';
378
-                }
379
-                return $reg->receipt_url();
380
-                break;
381
-            case '[INVOICE_RECEIPT_SWITCHER_URL]':
382
-                return $this->_get_invoice_receipt_switcher(false);
383
-                break;
384
-            case '[INVOICE_RECEIPT_SWITCHER_BUTTON]':
385
-                return $this->_get_invoice_receipt_switcher();
386
-                break;
387
-            case '[LAST_PAYMENT_TRANSACTION_ID]':
388
-                $id = '';
389
-                $payment = $payment instanceof EE_Payment && $payment->ID() !== 0
390
-                    ? $payment
391
-                    : $transaction->last_payment();
392
-                if ($payment instanceof EE_Payment) {
393
-                    $id = $payment->txn_id_chq_nmbr();
394
-                }
395
-                return $id;
396
-                break;
397
-        }
398
-        if (strpos($shortcode, '[OWING_STATUS_MESSAGE_*') !== false) {
399
-            return $this->_get_custom_total_owing($shortcode);
400
-        }
401
-        if (strpos($shortcode, '[INVOICE_PAYEE_TAX_NUMBER_*') !== false) {
402
-            return $this->_get_invoice_payee_tax_number($shortcode);
403
-        }
404
-        if (strpos($shortcode, '[PAYMENT_LINK_IF_NEEDED_*') !== false) {
405
-            return $this->_get_payment_link_if_needed($shortcode);
406
-        }
407
-        if (strpos($shortcode, '[PAYMENT_DUE_DATE_*') !== false) {
408
-            return $this->_get_payment_due_date($shortcode, $transaction);
409
-        }
410
-        return '';
411
-    }
412
-
413
-
414
-    /**
415
-     * parser for the [OWING_STATUS_MESSAGE_*] attribute type shortcode
416
-     *
417
-     * @since 4.5.0
418
-     * @param string $shortcode the incoming shortcode
419
-     * @return string parsed.
420
-     * @throws EE_Error
421
-     */
422
-    private function _get_custom_total_owing($shortcode)
423
-    {
424
-        $valid_shortcodes = array('transaction');
425
-        $attrs = $this->_get_shortcode_attrs($shortcode);
426
-        // ensure default is set.
427
-        $addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
428
-        $total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction
429
-            ? $addressee->txn->remaining() : 0;
430
-        if ($total_owing > 0) {
431
-            $owing_content = ! empty($attrs['still_owing'])
432
-                ? $attrs['still_owing']
433
-                : sprintf(
434
-                    esc_html__('%sPlease make a payment.%s', 'event_espresso'),
435
-                    '<a href="[PAYMENT_URL]" class="noPrint">',
436
-                    '</a>'
437
-                );
438
-            $owing_content = $this->_shortcode_helper->parse_message_template(
439
-                $owing_content,
440
-                $addressee,
441
-                $valid_shortcodes,
442
-                $this->_message_type,
443
-                $this->_messenger,
444
-                $this->_message
445
-            );
446
-        } else {
447
-            $owing_content = ! empty($attrs['none_owing']) ? $attrs['none_owing'] : '';
448
-        }
449
-        return $owing_content;
450
-    }
451
-
452
-
453
-    /**
454
-     * @param EE_Transaction $transaction
455
-     * @return string
456
-     * @throws EE_Error
457
-     */
458
-    private function _get_payment_gateway($transaction)
459
-    {
460
-        if ($transaction instanceof EE_Transaction) {
461
-            $pm = $transaction->payment_method();
462
-        } else {
463
-            $pm = null;
464
-        }
465
-        return $pm instanceof EE_Payment_Method ? $pm->name() : '';
466
-    }
467
-
468
-
469
-    /**
470
-     * This retrieves a logo to be used for the invoice from whatever is set on the invoice logo settings page.  If its
471
-     * not present then the organization logo is used if its found (set on the organization settings page).
472
-     *
473
-     * @since 4.5.0
474
-     * @param bool $img_tags TRUE means to return with the img tag wrappers.  False just returns the url to the image.
475
-     * @return string url or html
476
-     * @throws EE_Error
477
-     * @throws InvalidArgumentException
478
-     * @throws InvalidDataTypeException
479
-     * @throws InvalidInterfaceException
480
-     */
481
-    private function _get_invoice_logo($img_tags = false)
482
-    {
483
-        $invoice_logo_url = '';
484
-        // try to get the invoice payment method's logo for this transaction image first
485
-        $pm = $this->_get_invoice_payment_method();
486
-        if ($pm instanceof EE_Payment_Method) {
487
-            $invoice_logo_url = $pm->get_extra_meta('pdf_logo_image', true);
488
-        }
489
-        if (empty($invoice_logo_url)) {
490
-            $invoice_logo_url = EE_Registry::instance()->CFG->organization->logo_url;
491
-        }
492
-        if (empty($invoice_logo_url)) {
493
-            return '';
494
-        }
495
-        if (! $img_tags) {
496
-            return $invoice_logo_url;
497
-        }
498
-        // image tags have been requested.
499
-        $image_size = getimagesize($invoice_logo_url);
500
-        // if image is wider than 300px, set the width to 300
501
-        if ($image_size[0] > 300) {
502
-            $image_width = 300;
503
-        } else {
504
-            $image_width = $image_size[0];
505
-        }
506
-        return '<img class="logo screen" src="' . esc_url_raw($invoice_logo_url) . '" width="' . esc_attr($image_width) . '" alt="logo" />';
507
-    }
508
-
509
-
510
-    /**
511
-     * Used to retrieve the appropriate content for the invoice payee name shortcode
512
-     *
513
-     * @since 4.5.0
514
-     * @return string
515
-     * @throws EE_Error
516
-     * @throws InvalidArgumentException
517
-     * @throws InvalidDataTypeException
518
-     * @throws InvalidInterfaceException
519
-     */
520
-    private function _get_invoice_payee_name()
521
-    {
522
-        $payee_name = null;
523
-        $pm = $this->_get_invoice_payment_method();
524
-        if ($pm instanceof EE_Payment_Method) {
525
-            $payee_name = $pm->get_extra_meta('pdf_payee_name', true);
526
-        }
527
-        $payee_name = empty($payee_name) ? EE_Registry::instance()->CFG->organization->get_pretty('name') : $payee_name;
528
-        return $payee_name;
529
-    }
530
-
531
-
532
-    /**
533
-     * gets the default invoice payment method, but has a filter so it can be overridden
534
-     *
535
-     * @return EE_Payment_Method|null
536
-     * @throws EE_Error
537
-     * @throws InvalidArgumentException
538
-     * @throws InvalidDataTypeException
539
-     * @throws InvalidInterfaceException
540
-     */
541
-    private function _get_invoice_payment_method()
542
-    {
543
-        if (! $this->_invoice_pm instanceof EE_Payment_Method) {
544
-            $transaction = $this->_data->txn instanceof EE_Transaction ? $this->_data->txn : null;
545
-            $transaction = ! $transaction instanceof EE_Transaction
546
-                           && is_array($this->_extra_data)
547
-                           && isset($this->_extra_data['data'])
548
-                           && $this->_extra_data['data'] instanceof EE_Messages_Addressee
549
-                ? $this->_extra_data['data']->txn : $transaction;
550
-            // get the invoice payment method, and remember it for the next call too
551
-            $this->_invoice_pm = apply_filters(
552
-                'FHEE__EE_Transaction_Shortcodes__get_payment_method__default',
553
-                EEM_Payment_Method::instance()->get_one_of_type('Invoice'),
554
-                $transaction
555
-            );
556
-        }
557
-        return $this->_invoice_pm;
558
-    }
559
-
560
-
561
-    /**
562
-     * Used to retrieve the appropriate content for the invoice payee email shortcode
563
-     *
564
-     * @since 4.5.0
565
-     * @return string
566
-     * @throws EE_Error
567
-     * @throws InvalidArgumentException
568
-     * @throws InvalidDataTypeException
569
-     * @throws InvalidInterfaceException
570
-     */
571
-    private function _get_invoice_payee_email()
572
-    {
573
-        $payee_email = null;
574
-        $pm = $this->_get_invoice_payment_method();
575
-        if ($pm instanceof EE_Payment_Method) {
576
-            $payee_email = $pm->get_extra_meta('pdf_payee_email', true);
577
-        }
578
-        $payee_email = empty($payee_email) ? EE_Registry::instance()->CFG->organization->get_pretty('email')
579
-            : $payee_email;
580
-        return $payee_email;
581
-    }
582
-
583
-
584
-    /**
585
-     * Used to retrieve the appropriate content for the invoice payee tax number shortcode
586
-     *
587
-     * @since 4.5.0
588
-     * @param string $shortcode
589
-     * @return string
590
-     * @throws EE_Error
591
-     * @throws InvalidArgumentException
592
-     * @throws InvalidDataTypeException
593
-     * @throws InvalidInterfaceException
594
-     */
595
-    private function _get_invoice_payee_tax_number($shortcode)
596
-    {
597
-        $payee_tax_number = null;
598
-        $pm = $this->_get_invoice_payment_method();
599
-        if ($pm instanceof EE_Payment_Method) {
600
-            $payee_tax_number = $pm->get_extra_meta('pdf_payee_tax_number', true);
601
-        }
602
-        $payee_tax_number = empty($payee_tax_number) ? EE_Registry::instance()->CFG->organization->vat
603
-            : $payee_tax_number;
604
-        if (empty($payee_tax_number)) {
605
-            return '';
606
-        }
607
-        // any attributes?
608
-        $attrs = $this->_get_shortcode_attrs($shortcode);
609
-        // prefix?
610
-        $prefix = isset($attrs['prefix']) ? $attrs['prefix'] : esc_html__('VAT/Tax Number: ', 'event_espresso');
611
-        return $prefix . $payee_tax_number;
612
-    }
613
-
614
-
615
-    /**
616
-     * Used to retrieve the appropriate content for the invoice payee address shortcode.
617
-     *
618
-     * @since 4.5.0
619
-     * @return string
620
-     * @throws EE_Error
621
-     * @throws InvalidArgumentException
622
-     * @throws ReflectionException
623
-     * @throws InvalidDataTypeException
624
-     * @throws InvalidInterfaceException
625
-     */
626
-    private function _get_invoice_payee_address()
627
-    {
628
-        $payee_address = null;
629
-        $pm = $this->_get_invoice_payment_method();
630
-        if ($pm instanceof EE_Payment_Method) {
631
-            $payee_address = $pm->get_extra_meta('pdf_payee_address', true);
632
-        }
633
-        if (empty($payee_address)) {
634
-            $organization = EE_Registry::instance()->CFG->organization;
635
-            $payee_address = $organization->get_pretty('address_1') . '<br>';
636
-            $payee_address .= ! empty($organization->address_2)
637
-                ? $organization->get_pretty('address_2') . '<br>'
638
-                : '';
639
-            $payee_address .= $organization->get_pretty('city') . '<br>';
640
-            // state
641
-            $state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID);
642
-            $payee_address .= $state instanceof EE_State ? $state->name() : '';
643
-            // Country
644
-            $payee_address .= ! empty($organization->CNT_ISO) ? ', ' . $organization->CNT_ISO . '<br>' : '';
645
-            $payee_address .= ! empty($organization->zip) ? $organization->zip : '';
646
-        }
647
-        return $payee_address;
648
-    }
649
-
650
-
651
-    /**
652
-     * Used to retrieve the appropriate content for the invoice payment instructions shortcode.
653
-     *
654
-     * @since 4.5.0
655
-     * @return string
656
-     * @throws EE_Error
657
-     * @throws InvalidArgumentException
658
-     * @throws InvalidDataTypeException
659
-     * @throws InvalidInterfaceException
660
-     */
661
-    private function _get_invoice_payment_instructions()
662
-    {
663
-        $instructions = null;
664
-        $pm = $this->_get_invoice_payment_method();
665
-        return ($pm instanceof EE_Payment_Method) ? $pm->get_extra_meta('pdf_instructions', true) : '';
666
-    }
667
-
668
-
669
-    /**
670
-     * get invoice/receipt switch button or url.
671
-     *
672
-     * @param bool $button true (default) returns the html for a button, false just returns the url.
673
-     * @return string
674
-     * @throws EE_Error
675
-     */
676
-    protected function _get_invoice_receipt_switcher($button = true)
677
-    {
678
-        $reg = $this->_data->primary_reg_obj;
679
-        $message_type = isset($this->_extra_data['message_type']) ? $this->_extra_data['message_type'] : '';
680
-        if (! $reg instanceof EE_Registration || empty($message_type)) {
681
-            return '';
682
-        }
683
-        $switch_to_invoice = ! $message_type instanceof EE_Invoice_message_type ? true : false;
684
-        $switch_to_label = $switch_to_invoice && ! $message_type instanceof EE_Receipt_message_type
685
-            ? esc_html__('View Invoice', 'event_espresso') : esc_html__('Switch to Invoice', 'event_espresso');
686
-        $switch_to_label = ! $switch_to_invoice ? esc_html__('Switch to Receipt', 'event_espresso') : $switch_to_label;
687
-        $switch_to_url = $switch_to_invoice ? $reg->invoice_url() : $reg->receipt_url();
688
-        if (! $button) {
689
-            return $switch_to_url;
690
-        }
691
-        if (! empty($switch_to_url)) {
692
-            return '
20
+	/**
21
+	 * @var EE_Payment_Method $_invoice_pm the invoice payment method for use in invoices etc
22
+	 */
23
+	protected $_invoice_pm;
24
+
25
+
26
+	protected function _init_props()
27
+	{
28
+		$this->label = esc_html__('Transaction Shortcodes', 'event_espresso');
29
+		$this->description = esc_html__('All shortcodes specific to transaction related data', 'event_espresso');
30
+		$this->_shortcodes = array(
31
+			'[TXN_ID]'                          => esc_html__('The transaction id for the purchase.', 'event_espresso'),
32
+			'[PAYMENT_URL]'                     => esc_html__(
33
+				'This is a link to make a payment for the event',
34
+				'event_espresso'
35
+			),
36
+			'[PAYMENT_LINK_IF_NEEDED_*]'        => esc_html__(
37
+				'This is a special dynamic shortcode that allows one to insert a payment link conditional on there being amount owing on the transaction. Three params are available on this shortcode:',
38
+				'event_espresso'
39
+			)
40
+												   . '<ul>'
41
+												   . '<li>'
42
+												   . sprintf(
43
+													   esc_html__(
44
+														   '%sclass:%s This can be used to indicate css class is given to the containing css element (default is "callout").',
45
+														   'event_espresso'
46
+													   ),
47
+													   '<strong>',
48
+													   '</strong>'
49
+												   )
50
+												   . '</li>'
51
+												   . '<li>'
52
+												   . sprintf(
53
+													   esc_html__(
54
+														   '%scustom_text:%s This should be a sprintf format text string (with %%s for where the hyperlink tags go) that is used for the generated link text (The default is "You can %%smake a payment here »%%s.)',
55
+														   'event_espresso'
56
+													   ),
57
+													   '<strong>',
58
+													   '</strong>'
59
+												   )
60
+												   . '</li>'
61
+												   . '<li>'
62
+												   . sprintf(
63
+													   esc_html__(
64
+														   '%scontainer_tag:%s Use this to indicate what container tag you want surrounding the payment link (default is "p").',
65
+														   'event_espresso'
66
+													   ),
67
+													   '<strong>',
68
+													   '</strong>'
69
+												   )
70
+												   . '</li>'
71
+												   . '</ul>',
72
+			'[PAYMENT_DUE_DATE_*]'              => esc_html__(
73
+				'This is a special dynamic shortcode that allows one to output a payment due date.  It will only result in a date shown if there is money owing.  Three parameters are available on this shortcode:',
74
+				'event_espresso'
75
+			)
76
+												   . '<ul>'
77
+												   . '<li>'
78
+												   . sprintf(
79
+													   esc_html__(
80
+														   '%sformat:%s This is used to indicate what format the date is in.  Default is whatever is set as date formats for your website.',
81
+														   'event_espresso'
82
+													   ),
83
+													   '<strong>',
84
+													   '</strong>'
85
+												   )
86
+												   . '</li>'
87
+												   . '<li>'
88
+												   . sprintf(
89
+													   esc_html__(
90
+														   '%sdays_until_due:%s This is the number of days form the transaction creation date that the payment is due.  Defaults to 30.',
91
+														   'event_espresso'
92
+													   ),
93
+													   '<strong>',
94
+													   '</strong>'
95
+												   )
96
+												   . '</li>'
97
+												   . '<li>'
98
+												   . sprintf(
99
+													   esc_html__(
100
+														   '%sprefix_text:%s You can use this to indicate what text will prefix the date string.  Defaults to "Payment in full due by:"',
101
+														   'event_espresso'
102
+													   ),
103
+													   '<strong>',
104
+													   '</strong>'
105
+												   )
106
+												   . '</li>',
107
+			'[INVOICE_LINK]'                    => esc_html__(
108
+				'This is a full html link to the invoice',
109
+				'event_espresso'
110
+			),
111
+			'[INVOICE_URL]'                     => esc_html__(
112
+				'This is just the url for the invoice',
113
+				'event_espresso'
114
+			),
115
+			'[INVOICE_LOGO_URL]'                => esc_html__(
116
+				'This returns the url for the logo uploaded via the invoice settings page.',
117
+				'event_espresso'
118
+			),
119
+			'[INVOICE_LOGO]'                    => esc_html__(
120
+				'This returns the logo uploaded via the invoice settings page wrapped in img_tags and with a "logo screen" classes. The image size is also set in the img tags automatically to match the uploaded logo.',
121
+				'event_espresso'
122
+			),
123
+			'[INVOICE_PAYEE_NAME]'              => esc_html__(
124
+				'This will parse to either: the value of the "Company Name" field in the invoice payment method settings; if that is blank, then the value of the Company Name in the "Your Organization Settings", if that is blank then an empty string.',
125
+				'event_espresso'
126
+			),
127
+			'[INVOICE_PAYEE_ADDRESS]'           => esc_html__(
128
+				'This will parse to either: the value of the "Company Address" field in the invoice payment method settings; if that is blank, then the value of the Company Address in the "Your Organization Settings", if that is blank then an empty string.',
129
+				'event_espresso'
130
+			),
131
+			'[INVOICE_PAYMENT_INSTRUCTIONS]'    => esc_html__(
132
+				'This will parse to the value of the "Payment Instructions" field found on the Invoice payment methods settings page',
133
+				'event_espresso'
134
+			),
135
+			'[INVOICE_PAYEE_EMAIL]'             => esc_html__(
136
+				'This will parse to either: the value of the "Company Email" field in the invoice payment method settings; if that is blank, then the value of the Company Email in the "Your Organization Settings", if that is blank then an empty string.',
137
+				'event_espresso'
138
+			),
139
+			'[INVOICE_PAYEE_TAX_NUMBER_*]'      => sprintf(
140
+				esc_html__(
141
+					'This will parse to either: the value of the "Company Tax Number" field in the invoice payment method settings; if that is blank, then the value of the Company Tax Number in the "Your Organization Settings", if that is blank then an empty string. Note this is also a special dynamic shortcode. You can use the "prefix" parameter to indicate what text you want to use as a prefix before this tax number.  It defaults to "VAT/Tax Number:". To change this prefix you do the following format for this shortcode: %1$s[INVOICE_PAYEE_TAX_NUMBER_* prefix="GST:"]%2$s and that will output: GST: 12345t56.  If you have no tax number in your settings, then no prefix will be output either.',
142
+					'event_espresso'
143
+				),
144
+				'<code>',
145
+				'</code>'
146
+			),
147
+			'[TOTAL_COST]'                      => esc_html__('The total cost for the transaction', 'event_espresso'),
148
+			'[TXN_STATUS]'                      => esc_html__(
149
+				'The transaction status for the transaction.',
150
+				'event_espresso'
151
+			),
152
+			'[TXN_STATUS_ID]'                   => esc_html__(
153
+				'The ID representing the transaction status as saved in the db.  This tends to be useful for including with css classes for styling certain statuses differently from others.',
154
+				'event_espresso'
155
+			),
156
+			'[PAYMENT_STATUS]'                  => esc_html__(
157
+				'The transaction status for the transaction. This parses to the same value as the [TXN_STATUS] shortcode and still remains here for legacy support.',
158
+				'event_espresso'
159
+			),
160
+			'[PAYMENT_GATEWAY]'                 => esc_html__(
161
+				'The payment gateway used for the transaction',
162
+				'event_espresso'
163
+			),
164
+			'[AMOUNT_PAID]'                     => esc_html__(
165
+				'The amount paid or refunded.  This will only have a value if there was a payment or refund at the time of generating the message.',
166
+				'event_espresso'
167
+			),
168
+			'[LAST_AMOUNT_PAID]'                => esc_html__(
169
+				'This is the last payment or refund made on the transaction related to the message being generated.',
170
+				'event_espresso'
171
+			),
172
+			'[TOTAL_AMOUNT_PAID]'               => esc_html__(
173
+				'This parses to the total amount paid over all payments',
174
+				'event_espresso'
175
+			),
176
+			'[TOTAL_OWING]'                     => esc_html__(
177
+				'The total owing on a transaction with no attributes.',
178
+				'event_espresso'
179
+			),
180
+			'[TXN_SUBTOTAL]'                    => esc_html__('The subtotal for all txn line items.', 'event_espresso'),
181
+			'[TXN_TAX_SUBTOTAL]'                => esc_html__('The subtotal for all tax line items.', 'event_espresso'),
182
+			'[OWING_STATUS_MESSAGE_*]'          => esc_html__(
183
+				'A dynamic shortcode for adjusting how total owing gets shown. The acceptable attributes on the shortcode are:',
184
+				'event_espresso'
185
+			)
186
+												   . '<p></ul>'
187
+												   . '<li><strong>still_owing</strong>:'
188
+												   . esc_html__(
189
+													   'If the transaction is not paid in full, then whatever is set for this attribute is shown (otherwise its just the amount owing). The default is:',
190
+													   'event_espresso'
191
+												   )
192
+												   . sprintf(
193
+													   esc_html__('%sPlease make a payment.%s', 'event_espresso'),
194
+													   '<a href="[PAYMENT_URL]" class="noPrint">',
195
+													   '</a>'
196
+												   )
197
+												   . '</li>'
198
+												   .
199
+												   '<li><strong>none_owing</strong>:'
200
+												   . esc_html__(
201
+													   'If the transaction is paid in full, then you can indicate how this gets displayed.  Note, that it defaults to just be the total owing.',
202
+													   'event_espresso'
203
+												   )
204
+												   . '</li></ul></p>',
205
+			'[TXN_TOTAL_TICKETS]'               => esc_html__(
206
+				'The total number of all tickets purchased in a transaction',
207
+				'event_espresso'
208
+			),
209
+			'[TKT_QTY_PURCHASED]'               => sprintf(
210
+				esc_html__(
211
+					'The total number of all tickets purchased in a transaction. %1$sNOTE: This shortcode is good to use in the "[TICKET_LIST]" field but has been deprecated from all other contexts in favor of the more explicit [TXN_TOTAL_TICKETS] shortcode.%2$s',
212
+					'event_espresso'
213
+				),
214
+				'<strong>',
215
+				'</strong>'
216
+			),
217
+			'[TRANSACTION_ADMIN_URL]'           => esc_html__(
218
+				'The url to the admin page for this transaction',
219
+				'event_espresso'
220
+			),
221
+			'[RECEIPT_URL]'                     => esc_html__(
222
+				'This parses to the generated url for retrieving the receipt for the transaction',
223
+				'event_espresso'
224
+			),
225
+			'[INVOICE_RECEIPT_SWITCHER_URL]'    => esc_html__(
226
+				'This parses to the url that will switch to the receipt if an invoice is displayed, and switch to the invoice if receipt is displayed. If a message type OTHER than invoice or receipt is displayed then this will just return the url for the invoice. If the related message type is not active  then will parse to an empty string.',
227
+				'event_espresso'
228
+			),
229
+			'[INVOICE_RECEIPT_SWITCHER_BUTTON]' => sprintf(
230
+				esc_html__(
231
+					'The same as %1$s%2$s except this returns the html for a button linked to the invoice or receipt.',
232
+					'event_espresso'
233
+				),
234
+				'<code>[INVOICE_RECEIPT_SWITCHER_URL]',
235
+				'</code>'
236
+			),
237
+			'[LAST_PAYMENT_TRANSACTION_ID]'     => esc_html__(
238
+				'This will output the value of the payment transaction id for the last payment made on the transaction. Note, if a specific payment was included for message generation, that will be used when parsing the shortcode.',
239
+				'event_espresso'
240
+			),
241
+		);
242
+	}
243
+
244
+
245
+	/**
246
+	 * @param  string $shortcode the shortcode to be parsed.
247
+	 * @return string parsed shortcode
248
+	 * @throws EE_Error
249
+	 * @throws InvalidArgumentException
250
+	 * @throws ReflectionException
251
+	 * @throws InvalidDataTypeException
252
+	 * @throws InvalidInterfaceException
253
+	 */
254
+	protected function _parser($shortcode)
255
+	{
256
+		// attempt to get the transaction.  Since this is potentially used in more fields, we may have to look in the
257
+		// _extra_data for the transaction.
258
+		$transaction = $this->_data->txn instanceof EE_Transaction ? $this->_data->txn : null;
259
+		$transaction = ! $transaction instanceof EE_Transaction
260
+					   && is_array($this->_extra_data)
261
+					   && isset($this->_extra_data['data'])
262
+					   && $this->_extra_data['data'] instanceof EE_Messages_Addressee
263
+			? $this->_extra_data['data']->txn
264
+			: $transaction;
265
+		// payment
266
+		$payment = $this->_data->payment instanceof EE_Payment ? $this->_data->payment : null;
267
+		$payment = ! $payment instanceof EE_Payment
268
+				   && is_array($this->_extra_data)
269
+				   && isset($this->_extra_data['data'])
270
+				   && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->payment
271
+			: $payment;
272
+		if (! $transaction instanceof EE_Transaction) {
273
+			return '';
274
+		}
275
+		switch ($shortcode) {
276
+			case '[TXN_ID]':
277
+				return $transaction->ID();
278
+				break;
279
+			case '[PAYMENT_URL]':
280
+				$payment_url = $transaction->payment_overview_url();
281
+				return empty($payment_url)
282
+					? esc_html__('http://dummypaymenturlforpreview.com', 'event_espresso')
283
+					: $payment_url;
284
+				break;
285
+			case '[INVOICE_LINK]':
286
+				$invoice_url = $transaction->invoice_url();
287
+				$invoice_url = empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url;
288
+				return sprintf(
289
+					esc_html__('%sClick here for Invoice%s', 'event_espresso'),
290
+					'<a href="' . $invoice_url . '">',
291
+					'</a>'
292
+				);
293
+				break;
294
+			case '[INVOICE_URL]':
295
+				$invoice_url = $transaction->invoice_url();
296
+				return empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url;
297
+				break;
298
+			case '[INVOICE_LOGO_URL]':
299
+				return $this->_get_invoice_logo();
300
+				break;
301
+			case '[INVOICE_LOGO]':
302
+				return $this->_get_invoice_logo(true);
303
+				break;
304
+			case '[INVOICE_PAYEE_NAME]':
305
+				return $this->_get_invoice_payee_name();
306
+				break;
307
+			case '[INVOICE_PAYEE_ADDRESS]':
308
+				return $this->_get_invoice_payee_address();
309
+				break;
310
+			case '[INVOICE_PAYMENT_INSTRUCTIONS]':
311
+				return $this->_get_invoice_payment_instructions();
312
+				break;
313
+			case '[INVOICE_PAYEE_EMAIL]':
314
+				return $this->_get_invoice_payee_email();
315
+				break;
316
+			case '[TOTAL_COST]':
317
+				$total = $transaction->total();
318
+				return ! empty($total) ? EEH_Template::format_currency($total) : '';
319
+				break;
320
+			case '[PAYMENT_STATUS]':
321
+				$status = $transaction->pretty_status();
322
+				return ! empty($status) ? $status : esc_html__('Unknown', 'event_espresso');
323
+				break; /**/
324
+			// note the [payment_status] shortcode is kind of misleading because payment status might be different
325
+			// from txn status so I'm adding this here for clarity.
326
+			case '[TXN_STATUS]':
327
+				$status = $transaction->pretty_status();
328
+				return ! empty($status) ? $status : esc_html__('Unknown', 'event_espresso');
329
+				break;
330
+			case '[TXN_STATUS_ID]':
331
+				return $transaction->status_ID();
332
+				break;
333
+			case '[PAYMENT_GATEWAY]':
334
+				return $this->_get_payment_gateway($transaction);
335
+				break;
336
+			case '[AMOUNT_PAID]':
337
+				return $payment instanceof EE_Payment
338
+					? EEH_Template::format_currency($payment->amount())
339
+					: EEH_Template::format_currency(0);
340
+				break;
341
+			case '[LAST_AMOUNT_PAID]':
342
+				$last_payment = $transaction->last_payment();
343
+				return $last_payment instanceof EE_Payment
344
+					? EEH_Template::format_currency($last_payment->amount())
345
+					: EEH_Template::format_currency(0);
346
+			case '[TOTAL_AMOUNT_PAID]':
347
+				return EEH_Template::format_currency($transaction->paid());
348
+				break;
349
+			case '[TOTAL_OWING]':
350
+				$total_owing = $transaction->remaining();
351
+				return EEH_Template::format_currency($total_owing);
352
+				break;
353
+			case '[TXN_SUBTOTAL]':
354
+				return EEH_Template::format_currency($this->_get_subtotal());
355
+				break;
356
+			case '[TXN_TAX_SUBTOTAL]':
357
+				return EEH_Template::format_currency($this->_get_subtotal(true));
358
+				break;
359
+			case '[TKT_QTY_PURCHASED]':
360
+			case '[TXN_TOTAL_TICKETS]':
361
+				return $this->_data->total_ticket_count;
362
+				break;
363
+			case '[TRANSACTION_ADMIN_URL]':
364
+				require_once EE_CORE . 'admin/EE_Admin_Page.core.php';
365
+				$query_args = array(
366
+					'page'   => 'espresso_transactions',
367
+					'action' => 'view_transaction',
368
+					'TXN_ID' => $transaction->ID(),
369
+				);
370
+				$url = EE_Admin_Page::add_query_args_and_nonce($query_args, admin_url('admin.php'));
371
+				return $url;
372
+				break;
373
+			case '[RECEIPT_URL]':
374
+				// get primary_registration
375
+				$reg = $this->_data->primary_reg_obj;
376
+				if (! $reg instanceof EE_Registration) {
377
+					return '';
378
+				}
379
+				return $reg->receipt_url();
380
+				break;
381
+			case '[INVOICE_RECEIPT_SWITCHER_URL]':
382
+				return $this->_get_invoice_receipt_switcher(false);
383
+				break;
384
+			case '[INVOICE_RECEIPT_SWITCHER_BUTTON]':
385
+				return $this->_get_invoice_receipt_switcher();
386
+				break;
387
+			case '[LAST_PAYMENT_TRANSACTION_ID]':
388
+				$id = '';
389
+				$payment = $payment instanceof EE_Payment && $payment->ID() !== 0
390
+					? $payment
391
+					: $transaction->last_payment();
392
+				if ($payment instanceof EE_Payment) {
393
+					$id = $payment->txn_id_chq_nmbr();
394
+				}
395
+				return $id;
396
+				break;
397
+		}
398
+		if (strpos($shortcode, '[OWING_STATUS_MESSAGE_*') !== false) {
399
+			return $this->_get_custom_total_owing($shortcode);
400
+		}
401
+		if (strpos($shortcode, '[INVOICE_PAYEE_TAX_NUMBER_*') !== false) {
402
+			return $this->_get_invoice_payee_tax_number($shortcode);
403
+		}
404
+		if (strpos($shortcode, '[PAYMENT_LINK_IF_NEEDED_*') !== false) {
405
+			return $this->_get_payment_link_if_needed($shortcode);
406
+		}
407
+		if (strpos($shortcode, '[PAYMENT_DUE_DATE_*') !== false) {
408
+			return $this->_get_payment_due_date($shortcode, $transaction);
409
+		}
410
+		return '';
411
+	}
412
+
413
+
414
+	/**
415
+	 * parser for the [OWING_STATUS_MESSAGE_*] attribute type shortcode
416
+	 *
417
+	 * @since 4.5.0
418
+	 * @param string $shortcode the incoming shortcode
419
+	 * @return string parsed.
420
+	 * @throws EE_Error
421
+	 */
422
+	private function _get_custom_total_owing($shortcode)
423
+	{
424
+		$valid_shortcodes = array('transaction');
425
+		$attrs = $this->_get_shortcode_attrs($shortcode);
426
+		// ensure default is set.
427
+		$addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
428
+		$total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction
429
+			? $addressee->txn->remaining() : 0;
430
+		if ($total_owing > 0) {
431
+			$owing_content = ! empty($attrs['still_owing'])
432
+				? $attrs['still_owing']
433
+				: sprintf(
434
+					esc_html__('%sPlease make a payment.%s', 'event_espresso'),
435
+					'<a href="[PAYMENT_URL]" class="noPrint">',
436
+					'</a>'
437
+				);
438
+			$owing_content = $this->_shortcode_helper->parse_message_template(
439
+				$owing_content,
440
+				$addressee,
441
+				$valid_shortcodes,
442
+				$this->_message_type,
443
+				$this->_messenger,
444
+				$this->_message
445
+			);
446
+		} else {
447
+			$owing_content = ! empty($attrs['none_owing']) ? $attrs['none_owing'] : '';
448
+		}
449
+		return $owing_content;
450
+	}
451
+
452
+
453
+	/**
454
+	 * @param EE_Transaction $transaction
455
+	 * @return string
456
+	 * @throws EE_Error
457
+	 */
458
+	private function _get_payment_gateway($transaction)
459
+	{
460
+		if ($transaction instanceof EE_Transaction) {
461
+			$pm = $transaction->payment_method();
462
+		} else {
463
+			$pm = null;
464
+		}
465
+		return $pm instanceof EE_Payment_Method ? $pm->name() : '';
466
+	}
467
+
468
+
469
+	/**
470
+	 * This retrieves a logo to be used for the invoice from whatever is set on the invoice logo settings page.  If its
471
+	 * not present then the organization logo is used if its found (set on the organization settings page).
472
+	 *
473
+	 * @since 4.5.0
474
+	 * @param bool $img_tags TRUE means to return with the img tag wrappers.  False just returns the url to the image.
475
+	 * @return string url or html
476
+	 * @throws EE_Error
477
+	 * @throws InvalidArgumentException
478
+	 * @throws InvalidDataTypeException
479
+	 * @throws InvalidInterfaceException
480
+	 */
481
+	private function _get_invoice_logo($img_tags = false)
482
+	{
483
+		$invoice_logo_url = '';
484
+		// try to get the invoice payment method's logo for this transaction image first
485
+		$pm = $this->_get_invoice_payment_method();
486
+		if ($pm instanceof EE_Payment_Method) {
487
+			$invoice_logo_url = $pm->get_extra_meta('pdf_logo_image', true);
488
+		}
489
+		if (empty($invoice_logo_url)) {
490
+			$invoice_logo_url = EE_Registry::instance()->CFG->organization->logo_url;
491
+		}
492
+		if (empty($invoice_logo_url)) {
493
+			return '';
494
+		}
495
+		if (! $img_tags) {
496
+			return $invoice_logo_url;
497
+		}
498
+		// image tags have been requested.
499
+		$image_size = getimagesize($invoice_logo_url);
500
+		// if image is wider than 300px, set the width to 300
501
+		if ($image_size[0] > 300) {
502
+			$image_width = 300;
503
+		} else {
504
+			$image_width = $image_size[0];
505
+		}
506
+		return '<img class="logo screen" src="' . esc_url_raw($invoice_logo_url) . '" width="' . esc_attr($image_width) . '" alt="logo" />';
507
+	}
508
+
509
+
510
+	/**
511
+	 * Used to retrieve the appropriate content for the invoice payee name shortcode
512
+	 *
513
+	 * @since 4.5.0
514
+	 * @return string
515
+	 * @throws EE_Error
516
+	 * @throws InvalidArgumentException
517
+	 * @throws InvalidDataTypeException
518
+	 * @throws InvalidInterfaceException
519
+	 */
520
+	private function _get_invoice_payee_name()
521
+	{
522
+		$payee_name = null;
523
+		$pm = $this->_get_invoice_payment_method();
524
+		if ($pm instanceof EE_Payment_Method) {
525
+			$payee_name = $pm->get_extra_meta('pdf_payee_name', true);
526
+		}
527
+		$payee_name = empty($payee_name) ? EE_Registry::instance()->CFG->organization->get_pretty('name') : $payee_name;
528
+		return $payee_name;
529
+	}
530
+
531
+
532
+	/**
533
+	 * gets the default invoice payment method, but has a filter so it can be overridden
534
+	 *
535
+	 * @return EE_Payment_Method|null
536
+	 * @throws EE_Error
537
+	 * @throws InvalidArgumentException
538
+	 * @throws InvalidDataTypeException
539
+	 * @throws InvalidInterfaceException
540
+	 */
541
+	private function _get_invoice_payment_method()
542
+	{
543
+		if (! $this->_invoice_pm instanceof EE_Payment_Method) {
544
+			$transaction = $this->_data->txn instanceof EE_Transaction ? $this->_data->txn : null;
545
+			$transaction = ! $transaction instanceof EE_Transaction
546
+						   && is_array($this->_extra_data)
547
+						   && isset($this->_extra_data['data'])
548
+						   && $this->_extra_data['data'] instanceof EE_Messages_Addressee
549
+				? $this->_extra_data['data']->txn : $transaction;
550
+			// get the invoice payment method, and remember it for the next call too
551
+			$this->_invoice_pm = apply_filters(
552
+				'FHEE__EE_Transaction_Shortcodes__get_payment_method__default',
553
+				EEM_Payment_Method::instance()->get_one_of_type('Invoice'),
554
+				$transaction
555
+			);
556
+		}
557
+		return $this->_invoice_pm;
558
+	}
559
+
560
+
561
+	/**
562
+	 * Used to retrieve the appropriate content for the invoice payee email shortcode
563
+	 *
564
+	 * @since 4.5.0
565
+	 * @return string
566
+	 * @throws EE_Error
567
+	 * @throws InvalidArgumentException
568
+	 * @throws InvalidDataTypeException
569
+	 * @throws InvalidInterfaceException
570
+	 */
571
+	private function _get_invoice_payee_email()
572
+	{
573
+		$payee_email = null;
574
+		$pm = $this->_get_invoice_payment_method();
575
+		if ($pm instanceof EE_Payment_Method) {
576
+			$payee_email = $pm->get_extra_meta('pdf_payee_email', true);
577
+		}
578
+		$payee_email = empty($payee_email) ? EE_Registry::instance()->CFG->organization->get_pretty('email')
579
+			: $payee_email;
580
+		return $payee_email;
581
+	}
582
+
583
+
584
+	/**
585
+	 * Used to retrieve the appropriate content for the invoice payee tax number shortcode
586
+	 *
587
+	 * @since 4.5.0
588
+	 * @param string $shortcode
589
+	 * @return string
590
+	 * @throws EE_Error
591
+	 * @throws InvalidArgumentException
592
+	 * @throws InvalidDataTypeException
593
+	 * @throws InvalidInterfaceException
594
+	 */
595
+	private function _get_invoice_payee_tax_number($shortcode)
596
+	{
597
+		$payee_tax_number = null;
598
+		$pm = $this->_get_invoice_payment_method();
599
+		if ($pm instanceof EE_Payment_Method) {
600
+			$payee_tax_number = $pm->get_extra_meta('pdf_payee_tax_number', true);
601
+		}
602
+		$payee_tax_number = empty($payee_tax_number) ? EE_Registry::instance()->CFG->organization->vat
603
+			: $payee_tax_number;
604
+		if (empty($payee_tax_number)) {
605
+			return '';
606
+		}
607
+		// any attributes?
608
+		$attrs = $this->_get_shortcode_attrs($shortcode);
609
+		// prefix?
610
+		$prefix = isset($attrs['prefix']) ? $attrs['prefix'] : esc_html__('VAT/Tax Number: ', 'event_espresso');
611
+		return $prefix . $payee_tax_number;
612
+	}
613
+
614
+
615
+	/**
616
+	 * Used to retrieve the appropriate content for the invoice payee address shortcode.
617
+	 *
618
+	 * @since 4.5.0
619
+	 * @return string
620
+	 * @throws EE_Error
621
+	 * @throws InvalidArgumentException
622
+	 * @throws ReflectionException
623
+	 * @throws InvalidDataTypeException
624
+	 * @throws InvalidInterfaceException
625
+	 */
626
+	private function _get_invoice_payee_address()
627
+	{
628
+		$payee_address = null;
629
+		$pm = $this->_get_invoice_payment_method();
630
+		if ($pm instanceof EE_Payment_Method) {
631
+			$payee_address = $pm->get_extra_meta('pdf_payee_address', true);
632
+		}
633
+		if (empty($payee_address)) {
634
+			$organization = EE_Registry::instance()->CFG->organization;
635
+			$payee_address = $organization->get_pretty('address_1') . '<br>';
636
+			$payee_address .= ! empty($organization->address_2)
637
+				? $organization->get_pretty('address_2') . '<br>'
638
+				: '';
639
+			$payee_address .= $organization->get_pretty('city') . '<br>';
640
+			// state
641
+			$state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID);
642
+			$payee_address .= $state instanceof EE_State ? $state->name() : '';
643
+			// Country
644
+			$payee_address .= ! empty($organization->CNT_ISO) ? ', ' . $organization->CNT_ISO . '<br>' : '';
645
+			$payee_address .= ! empty($organization->zip) ? $organization->zip : '';
646
+		}
647
+		return $payee_address;
648
+	}
649
+
650
+
651
+	/**
652
+	 * Used to retrieve the appropriate content for the invoice payment instructions shortcode.
653
+	 *
654
+	 * @since 4.5.0
655
+	 * @return string
656
+	 * @throws EE_Error
657
+	 * @throws InvalidArgumentException
658
+	 * @throws InvalidDataTypeException
659
+	 * @throws InvalidInterfaceException
660
+	 */
661
+	private function _get_invoice_payment_instructions()
662
+	{
663
+		$instructions = null;
664
+		$pm = $this->_get_invoice_payment_method();
665
+		return ($pm instanceof EE_Payment_Method) ? $pm->get_extra_meta('pdf_instructions', true) : '';
666
+	}
667
+
668
+
669
+	/**
670
+	 * get invoice/receipt switch button or url.
671
+	 *
672
+	 * @param bool $button true (default) returns the html for a button, false just returns the url.
673
+	 * @return string
674
+	 * @throws EE_Error
675
+	 */
676
+	protected function _get_invoice_receipt_switcher($button = true)
677
+	{
678
+		$reg = $this->_data->primary_reg_obj;
679
+		$message_type = isset($this->_extra_data['message_type']) ? $this->_extra_data['message_type'] : '';
680
+		if (! $reg instanceof EE_Registration || empty($message_type)) {
681
+			return '';
682
+		}
683
+		$switch_to_invoice = ! $message_type instanceof EE_Invoice_message_type ? true : false;
684
+		$switch_to_label = $switch_to_invoice && ! $message_type instanceof EE_Receipt_message_type
685
+			? esc_html__('View Invoice', 'event_espresso') : esc_html__('Switch to Invoice', 'event_espresso');
686
+		$switch_to_label = ! $switch_to_invoice ? esc_html__('Switch to Receipt', 'event_espresso') : $switch_to_label;
687
+		$switch_to_url = $switch_to_invoice ? $reg->invoice_url() : $reg->receipt_url();
688
+		if (! $button) {
689
+			return $switch_to_url;
690
+		}
691
+		if (! empty($switch_to_url)) {
692
+			return '
693 693
 	<form method="post" action="' . $switch_to_url . '" >
694 694
 		<input class="print_button" type="submit" value="' . $switch_to_label . '" />
695 695
 	</form>
696 696
 			';
697
-        }
698
-        return '';
699
-    }
700
-
701
-
702
-    /**
703
-     * This returns a subtotal.
704
-     *
705
-     * @param bool $tax if true then return the subtotal for tax otherwise return subtotal.
706
-     * @return int
707
-     * @throws EE_Error
708
-     */
709
-    private function _get_subtotal($tax = false)
710
-    {
711
-        $grand_total = isset($this->_data->grand_total_line_item) ? $this->_data->grand_total_line_item : null;
712
-        if (! $grand_total instanceof EE_Line_Item) {
713
-            return 0;
714
-        }
715
-        return $tax ? $grand_total->get_total_tax() : $grand_total->get_items_total();
716
-    }
717
-
718
-
719
-    /**
720
-     * parser for the [PAYMENT_LINK_IF_NEEDED_*] attribute type shortcode
721
-     *
722
-     * @since 4.7.0
723
-     * @param string $shortcode the incoming shortcode
724
-     * @return string parsed.
725
-     * @throws EE_Error
726
-     */
727
-    private function _get_payment_link_if_needed($shortcode)
728
-    {
729
-        $valid_shortcodes = array('transaction');
730
-        $attrs = $this->_get_shortcode_attrs($shortcode);
731
-        // ensure default is set.
732
-        $addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
733
-        $total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction
734
-            ? $addressee->txn->remaining() : 0;
735
-        if ($total_owing > 0) {
736
-            $class = isset($attrs['class']) ? $attrs['class'] : 'callout';
737
-            $custom_text = isset($attrs['custom_text']) ? $attrs['custom_text'] : 'You can %smake a payment here »%s.';
738
-            $container_tag = isset($attrs['container_tag']) ? $attrs['container_tag'] : 'p';
739
-            $opening_tag = ! empty($container_tag) ? '<' . $container_tag : '';
740
-            $opening_tag .= ! empty($opening_tag) && ! empty($class) ? ' class="' . $class . '"' : $opening_tag;
741
-            $opening_tag .= ! empty($opening_tag) ? '>' : $opening_tag;
742
-            $closing_tag = ! empty($container_tag) ? '</' . $container_tag . '>' : '';
743
-            $content = $opening_tag . sprintf($custom_text, '<a href="[PAYMENT_URL]">', '</a>') . $closing_tag;
744
-            // we need to re run this string through the parser to catch any shortcodes that are in it.
745
-            $owing_content = $this->_shortcode_helper->parse_message_template(
746
-                $content,
747
-                $addressee,
748
-                $valid_shortcodes,
749
-                $this->_message_type,
750
-                $this->_messenger,
751
-                $this->_message
752
-            );
753
-        } else {
754
-            return '';
755
-        }
756
-        return $owing_content;
757
-    }
758
-
759
-
760
-    /**
761
-     * Parser for the [PAYMENT_DUE_DATE_*] attribute type shortcode
762
-     *
763
-     * @since 4.8.28.rc.011
764
-     * @param string         $shortcode The shortcode being parsed.
765
-     * @param EE_Transaction $transaction
766
-     * @return string
767
-     * @throws EE_Error
768
-     */
769
-    protected function _get_payment_due_date($shortcode, EE_Transaction $transaction)
770
-    {
771
-        // if transaction is paid in full then we can just return an empty string
772
-        if ($transaction->remaining() === 0) {
773
-            return '';
774
-        }
775
-        $attrs = $this->_get_shortcode_attrs($shortcode);
776
-        $format = isset($attrs['format']) ? $attrs['format'] : get_option('date_format');
777
-        $days_until_due = isset($attrs['days_until_due']) ? (int) $attrs['days_until_due'] : 30;
778
-        $prefix_text = isset($attrs['prefix_text']) ? $attrs['prefix_text']
779
-            : esc_html__('Payment in full due by: ', 'event_espresso');
780
-        $transaction_created = $transaction->get_DateTime_object('TXN_timestamp');
781
-        // setup date due:
782
-        try {
783
-            if ($transaction_created instanceof DateTime) {
784
-                $date_due = $transaction_created->add(
785
-                    new DateInterval('P' . $days_until_due . 'D')
786
-                )->format($format);
787
-            } else {
788
-                throw new Exception();
789
-            }
790
-        } catch (Exception $e) {
791
-            // format was likely invalid.
792
-            $date_due = esc_html__(
793
-                'Unable to calculate date due, likely the format string is invalid.',
794
-                'event_espresso'
795
-            );
796
-        }
797
-        return $prefix_text . $date_due;
798
-    }
697
+		}
698
+		return '';
699
+	}
700
+
701
+
702
+	/**
703
+	 * This returns a subtotal.
704
+	 *
705
+	 * @param bool $tax if true then return the subtotal for tax otherwise return subtotal.
706
+	 * @return int
707
+	 * @throws EE_Error
708
+	 */
709
+	private function _get_subtotal($tax = false)
710
+	{
711
+		$grand_total = isset($this->_data->grand_total_line_item) ? $this->_data->grand_total_line_item : null;
712
+		if (! $grand_total instanceof EE_Line_Item) {
713
+			return 0;
714
+		}
715
+		return $tax ? $grand_total->get_total_tax() : $grand_total->get_items_total();
716
+	}
717
+
718
+
719
+	/**
720
+	 * parser for the [PAYMENT_LINK_IF_NEEDED_*] attribute type shortcode
721
+	 *
722
+	 * @since 4.7.0
723
+	 * @param string $shortcode the incoming shortcode
724
+	 * @return string parsed.
725
+	 * @throws EE_Error
726
+	 */
727
+	private function _get_payment_link_if_needed($shortcode)
728
+	{
729
+		$valid_shortcodes = array('transaction');
730
+		$attrs = $this->_get_shortcode_attrs($shortcode);
731
+		// ensure default is set.
732
+		$addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
733
+		$total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction
734
+			? $addressee->txn->remaining() : 0;
735
+		if ($total_owing > 0) {
736
+			$class = isset($attrs['class']) ? $attrs['class'] : 'callout';
737
+			$custom_text = isset($attrs['custom_text']) ? $attrs['custom_text'] : 'You can %smake a payment here »%s.';
738
+			$container_tag = isset($attrs['container_tag']) ? $attrs['container_tag'] : 'p';
739
+			$opening_tag = ! empty($container_tag) ? '<' . $container_tag : '';
740
+			$opening_tag .= ! empty($opening_tag) && ! empty($class) ? ' class="' . $class . '"' : $opening_tag;
741
+			$opening_tag .= ! empty($opening_tag) ? '>' : $opening_tag;
742
+			$closing_tag = ! empty($container_tag) ? '</' . $container_tag . '>' : '';
743
+			$content = $opening_tag . sprintf($custom_text, '<a href="[PAYMENT_URL]">', '</a>') . $closing_tag;
744
+			// we need to re run this string through the parser to catch any shortcodes that are in it.
745
+			$owing_content = $this->_shortcode_helper->parse_message_template(
746
+				$content,
747
+				$addressee,
748
+				$valid_shortcodes,
749
+				$this->_message_type,
750
+				$this->_messenger,
751
+				$this->_message
752
+			);
753
+		} else {
754
+			return '';
755
+		}
756
+		return $owing_content;
757
+	}
758
+
759
+
760
+	/**
761
+	 * Parser for the [PAYMENT_DUE_DATE_*] attribute type shortcode
762
+	 *
763
+	 * @since 4.8.28.rc.011
764
+	 * @param string         $shortcode The shortcode being parsed.
765
+	 * @param EE_Transaction $transaction
766
+	 * @return string
767
+	 * @throws EE_Error
768
+	 */
769
+	protected function _get_payment_due_date($shortcode, EE_Transaction $transaction)
770
+	{
771
+		// if transaction is paid in full then we can just return an empty string
772
+		if ($transaction->remaining() === 0) {
773
+			return '';
774
+		}
775
+		$attrs = $this->_get_shortcode_attrs($shortcode);
776
+		$format = isset($attrs['format']) ? $attrs['format'] : get_option('date_format');
777
+		$days_until_due = isset($attrs['days_until_due']) ? (int) $attrs['days_until_due'] : 30;
778
+		$prefix_text = isset($attrs['prefix_text']) ? $attrs['prefix_text']
779
+			: esc_html__('Payment in full due by: ', 'event_espresso');
780
+		$transaction_created = $transaction->get_DateTime_object('TXN_timestamp');
781
+		// setup date due:
782
+		try {
783
+			if ($transaction_created instanceof DateTime) {
784
+				$date_due = $transaction_created->add(
785
+					new DateInterval('P' . $days_until_due . 'D')
786
+				)->format($format);
787
+			} else {
788
+				throw new Exception();
789
+			}
790
+		} catch (Exception $e) {
791
+			// format was likely invalid.
792
+			$date_due = esc_html__(
793
+				'Unable to calculate date due, likely the format string is invalid.',
794
+				'event_espresso'
795
+			);
796
+		}
797
+		return $prefix_text . $date_due;
798
+	}
799 799
 }
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
                    && isset($this->_extra_data['data'])
270 270
                    && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->payment
271 271
             : $payment;
272
-        if (! $transaction instanceof EE_Transaction) {
272
+        if ( ! $transaction instanceof EE_Transaction) {
273 273
             return '';
274 274
         }
275 275
         switch ($shortcode) {
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
                 $invoice_url = empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url;
288 288
                 return sprintf(
289 289
                     esc_html__('%sClick here for Invoice%s', 'event_espresso'),
290
-                    '<a href="' . $invoice_url . '">',
290
+                    '<a href="'.$invoice_url.'">',
291 291
                     '</a>'
292 292
                 );
293 293
                 break;
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
                 return $this->_data->total_ticket_count;
362 362
                 break;
363 363
             case '[TRANSACTION_ADMIN_URL]':
364
-                require_once EE_CORE . 'admin/EE_Admin_Page.core.php';
364
+                require_once EE_CORE.'admin/EE_Admin_Page.core.php';
365 365
                 $query_args = array(
366 366
                     'page'   => 'espresso_transactions',
367 367
                     'action' => 'view_transaction',
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
             case '[RECEIPT_URL]':
374 374
                 // get primary_registration
375 375
                 $reg = $this->_data->primary_reg_obj;
376
-                if (! $reg instanceof EE_Registration) {
376
+                if ( ! $reg instanceof EE_Registration) {
377 377
                     return '';
378 378
                 }
379 379
                 return $reg->receipt_url();
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
         if (empty($invoice_logo_url)) {
493 493
             return '';
494 494
         }
495
-        if (! $img_tags) {
495
+        if ( ! $img_tags) {
496 496
             return $invoice_logo_url;
497 497
         }
498 498
         // image tags have been requested.
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
         } else {
504 504
             $image_width = $image_size[0];
505 505
         }
506
-        return '<img class="logo screen" src="' . esc_url_raw($invoice_logo_url) . '" width="' . esc_attr($image_width) . '" alt="logo" />';
506
+        return '<img class="logo screen" src="'.esc_url_raw($invoice_logo_url).'" width="'.esc_attr($image_width).'" alt="logo" />';
507 507
     }
508 508
 
509 509
 
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
      */
541 541
     private function _get_invoice_payment_method()
542 542
     {
543
-        if (! $this->_invoice_pm instanceof EE_Payment_Method) {
543
+        if ( ! $this->_invoice_pm instanceof EE_Payment_Method) {
544 544
             $transaction = $this->_data->txn instanceof EE_Transaction ? $this->_data->txn : null;
545 545
             $transaction = ! $transaction instanceof EE_Transaction
546 546
                            && is_array($this->_extra_data)
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
         $attrs = $this->_get_shortcode_attrs($shortcode);
609 609
         // prefix?
610 610
         $prefix = isset($attrs['prefix']) ? $attrs['prefix'] : esc_html__('VAT/Tax Number: ', 'event_espresso');
611
-        return $prefix . $payee_tax_number;
611
+        return $prefix.$payee_tax_number;
612 612
     }
613 613
 
614 614
 
@@ -632,16 +632,16 @@  discard block
 block discarded – undo
632 632
         }
633 633
         if (empty($payee_address)) {
634 634
             $organization = EE_Registry::instance()->CFG->organization;
635
-            $payee_address = $organization->get_pretty('address_1') . '<br>';
635
+            $payee_address = $organization->get_pretty('address_1').'<br>';
636 636
             $payee_address .= ! empty($organization->address_2)
637
-                ? $organization->get_pretty('address_2') . '<br>'
637
+                ? $organization->get_pretty('address_2').'<br>'
638 638
                 : '';
639
-            $payee_address .= $organization->get_pretty('city') . '<br>';
639
+            $payee_address .= $organization->get_pretty('city').'<br>';
640 640
             // state
641 641
             $state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID);
642 642
             $payee_address .= $state instanceof EE_State ? $state->name() : '';
643 643
             // Country
644
-            $payee_address .= ! empty($organization->CNT_ISO) ? ', ' . $organization->CNT_ISO . '<br>' : '';
644
+            $payee_address .= ! empty($organization->CNT_ISO) ? ', '.$organization->CNT_ISO.'<br>' : '';
645 645
             $payee_address .= ! empty($organization->zip) ? $organization->zip : '';
646 646
         }
647 647
         return $payee_address;
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
     {
678 678
         $reg = $this->_data->primary_reg_obj;
679 679
         $message_type = isset($this->_extra_data['message_type']) ? $this->_extra_data['message_type'] : '';
680
-        if (! $reg instanceof EE_Registration || empty($message_type)) {
680
+        if ( ! $reg instanceof EE_Registration || empty($message_type)) {
681 681
             return '';
682 682
         }
683 683
         $switch_to_invoice = ! $message_type instanceof EE_Invoice_message_type ? true : false;
@@ -685,13 +685,13 @@  discard block
 block discarded – undo
685 685
             ? esc_html__('View Invoice', 'event_espresso') : esc_html__('Switch to Invoice', 'event_espresso');
686 686
         $switch_to_label = ! $switch_to_invoice ? esc_html__('Switch to Receipt', 'event_espresso') : $switch_to_label;
687 687
         $switch_to_url = $switch_to_invoice ? $reg->invoice_url() : $reg->receipt_url();
688
-        if (! $button) {
688
+        if ( ! $button) {
689 689
             return $switch_to_url;
690 690
         }
691
-        if (! empty($switch_to_url)) {
691
+        if ( ! empty($switch_to_url)) {
692 692
             return '
693
-	<form method="post" action="' . $switch_to_url . '" >
694
-		<input class="print_button" type="submit" value="' . $switch_to_label . '" />
693
+	<form method="post" action="' . $switch_to_url.'" >
694
+		<input class="print_button" type="submit" value="' . $switch_to_label.'" />
695 695
 	</form>
696 696
 			';
697 697
         }
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
     private function _get_subtotal($tax = false)
710 710
     {
711 711
         $grand_total = isset($this->_data->grand_total_line_item) ? $this->_data->grand_total_line_item : null;
712
-        if (! $grand_total instanceof EE_Line_Item) {
712
+        if ( ! $grand_total instanceof EE_Line_Item) {
713 713
             return 0;
714 714
         }
715 715
         return $tax ? $grand_total->get_total_tax() : $grand_total->get_items_total();
@@ -736,11 +736,11 @@  discard block
 block discarded – undo
736 736
             $class = isset($attrs['class']) ? $attrs['class'] : 'callout';
737 737
             $custom_text = isset($attrs['custom_text']) ? $attrs['custom_text'] : 'You can %smake a payment here »%s.';
738 738
             $container_tag = isset($attrs['container_tag']) ? $attrs['container_tag'] : 'p';
739
-            $opening_tag = ! empty($container_tag) ? '<' . $container_tag : '';
740
-            $opening_tag .= ! empty($opening_tag) && ! empty($class) ? ' class="' . $class . '"' : $opening_tag;
739
+            $opening_tag = ! empty($container_tag) ? '<'.$container_tag : '';
740
+            $opening_tag .= ! empty($opening_tag) && ! empty($class) ? ' class="'.$class.'"' : $opening_tag;
741 741
             $opening_tag .= ! empty($opening_tag) ? '>' : $opening_tag;
742
-            $closing_tag = ! empty($container_tag) ? '</' . $container_tag . '>' : '';
743
-            $content = $opening_tag . sprintf($custom_text, '<a href="[PAYMENT_URL]">', '</a>') . $closing_tag;
742
+            $closing_tag = ! empty($container_tag) ? '</'.$container_tag.'>' : '';
743
+            $content = $opening_tag.sprintf($custom_text, '<a href="[PAYMENT_URL]">', '</a>').$closing_tag;
744 744
             // we need to re run this string through the parser to catch any shortcodes that are in it.
745 745
             $owing_content = $this->_shortcode_helper->parse_message_template(
746 746
                 $content,
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
         try {
783 783
             if ($transaction_created instanceof DateTime) {
784 784
                 $date_due = $transaction_created->add(
785
-                    new DateInterval('P' . $days_until_due . 'D')
785
+                    new DateInterval('P'.$days_until_due.'D')
786 786
                 )->format($format);
787 787
             } else {
788 788
                 throw new Exception();
@@ -794,6 +794,6 @@  discard block
 block discarded – undo
794 794
                 'event_espresso'
795 795
             );
796 796
         }
797
-        return $prefix_text . $date_due;
797
+        return $prefix_text.$date_due;
798 798
     }
799 799
 }
Please login to merge, or discard this patch.
modules/gateways/Invoice/lib/templates/invoice_body.template.php 2 patches
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -76,20 +76,20 @@  discard block
 block discarded – undo
76 76
         </thead>
77 77
         <tbody>
78 78
         <?php
79
-        /**
80
-         * Recursive function for traversing all the sub-items of each line item
81
-         * and displaying them in the table
82
-         *
83
-         * @param EE_Line_Item $line_item
84
-         * @param boolean      $odd for indicating whether to style this line item as an 'odd' or 'even'
85
-         */
86
-        function ee_invoice_display_line_item(EE_Line_Item $line_item, $show_line_item_description, $odd = false)
87
-        {
88
-            switch ($line_item->type()) {
89
-                case EEM_Line_Item::type_total:
90
-                    foreach ($line_item->children() as $child_line_item) {
91
-                        ee_invoice_display_line_item($child_line_item, $show_line_item_description);
92
-                    } ?>
79
+		/**
80
+		 * Recursive function for traversing all the sub-items of each line item
81
+		 * and displaying them in the table
82
+		 *
83
+		 * @param EE_Line_Item $line_item
84
+		 * @param boolean      $odd for indicating whether to style this line item as an 'odd' or 'even'
85
+		 */
86
+		function ee_invoice_display_line_item(EE_Line_Item $line_item, $show_line_item_description, $odd = false)
87
+		{
88
+			switch ($line_item->type()) {
89
+				case EEM_Line_Item::type_total:
90
+					foreach ($line_item->children() as $child_line_item) {
91
+						ee_invoice_display_line_item($child_line_item, $show_line_item_description);
92
+					} ?>
93 93
                     <tr>
94 94
                         <td colspan="<?php echo ($show_line_item_description ? 5 : 4) ?>">
95 95
                             <hr>
@@ -101,50 +101,50 @@  discard block
 block discarded – undo
101 101
                         <td class="total"><?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); ?></td>
102 102
                     </tr>
103 103
                     <?php
104
-                    break;
104
+					break;
105 105
 
106 106
 
107
-                case EEM_Line_Item::type_sub_total:
108
-                    foreach ($line_item->children() as $child_line_item) {
109
-                        // $odd = !$odd;
110
-                        ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd);
111
-                    } ?>
107
+				case EEM_Line_Item::type_sub_total:
108
+					foreach ($line_item->children() as $child_line_item) {
109
+						// $odd = !$odd;
110
+						ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd);
111
+					} ?>
112 112
                     <tr class="total_tr odd">
113 113
                         <td colspan="<?php echo ($show_line_item_description ? 2 : 1) ?>">&nbsp;</td>
114 114
                         <td colspan="2" class="total" id="total_currency">
115 115
                             <?php esc_html_e(
116
-                                'Sub-Total',
117
-                                'event_espresso'
118
-                            ); ?></td>
116
+								'Sub-Total',
117
+								'event_espresso'
118
+							); ?></td>
119 119
                         <td class="total"><?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); ?></td>
120 120
                     </tr>
121 121
                     <?php
122
-                    break;
122
+					break;
123 123
 
124 124
 
125
-                case EEM_Line_Item::type_tax_sub_total:
126
-                    foreach ($line_item->children() as $child_line_item) {
127
-                        $odd = ! $odd;
128
-                        ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd);
129
-                    } ?>
125
+				case EEM_Line_Item::type_tax_sub_total:
126
+					foreach ($line_item->children() as $child_line_item) {
127
+						$odd = ! $odd;
128
+						ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd);
129
+					} ?>
130 130
                     <tr class="total_tr odd">
131 131
                         <td colspan="<?php echo ($show_line_item_description ? 2 : 1) ?>">&nbsp;</td>
132 132
                         <td colspan="2" class="total" id="total_currency">
133 133
                             <?php esc_html_e(
134
-                                'Tax Total',
135
-                                'event_espresso'
136
-                            ); ?></td>
134
+								'Tax Total',
135
+								'event_espresso'
136
+							); ?></td>
137 137
                         <td class="total"><?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); ?></td>
138 138
                     </tr>
139 139
                     <?php
140
-                    break;
140
+					break;
141 141
 
142 142
 
143
-                case EEM_Line_Item::type_line_item:
144
-                    $subitems = $line_item->children();
145
-                    $has_subitems = count($subitems) > 1;
146
-                    if ($has_subitems) {
147
-                        ?>
143
+				case EEM_Line_Item::type_line_item:
144
+					$subitems = $line_item->children();
145
+					$has_subitems = count($subitems) > 1;
146
+					if ($has_subitems) {
147
+						?>
148 148
                         <tr class="item <?php echo ($odd ? 'odd' : ''); ?>">
149 149
                             <td class="item_l"><?php echo esc_html($line_item->name()) ?></td>
150 150
                             <?php if ($show_line_item_description) { ?>
@@ -155,18 +155,18 @@  discard block
 block discarded – undo
155 155
                             <td class="item_c"><?php echo esc_html($line_item->unit_price_no_code()) ?></td>
156 156
 
157 157
                             <td class="item_r"> <?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags());
158
-                                echo ($line_item->is_taxable() ? '*' : ''); ?> </td>
158
+								echo ($line_item->is_taxable() ? '*' : ''); ?> </td>
159 159
                             <?php // <td class="item_l"><?php  $datetimes_strings = array(); foreach($datetimes as $datetime){ $datetimes_strings[]= $datetime->start_date_and_time();} echo implode(", ",$datetimes_strings);
160
-                            ?>
160
+							?>
161 161
                         </tr>
162 162
                         <?php
163
-                        if ($has_subitems) {
164
-                            foreach ($line_item->children() as $child_line_item) {
165
-                                ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd);
166
-                            }
167
-                        }
168
-                    } else {// no subitems - just show this line item
169
-                        ?>
163
+						if ($has_subitems) {
164
+							foreach ($line_item->children() as $child_line_item) {
165
+								ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd);
166
+							}
167
+						}
168
+					} else {// no subitems - just show this line item
169
+						?>
170 170
                         <tr class="item <?php echo ($odd ? 'odd' : ''); ?>">
171 171
                             <td class="item_l"><?php echo esc_html($line_item->name()); ?></td>
172 172
                             <?php if ($show_line_item_description) { ?>
@@ -175,15 +175,15 @@  discard block
 block discarded – undo
175 175
                             <td class="item_l"><?php echo esc_html($line_item->quantity()); ?></td>
176 176
                             <td class="item_c"><?php echo wp_kses($line_item->unit_price_no_code(), AllowedTags::getAllowedTags()); ?></td>
177 177
                             <td class="item_r"> <?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags());
178
-                                echo ($line_item->is_taxable() ? '*' : ''); ?> </td>
178
+								echo ($line_item->is_taxable() ? '*' : ''); ?> </td>
179 179
                             <?php // <td class="item_l"><?php  $datetimes_strings = array(); foreach($datetimes as $datetime){ $datetimes_strings[]= $datetime->start_date_and_time();} echo implode(", ",$datetimes_strings);
180
-                            ?>
180
+							?>
181 181
                         </tr>
182 182
                     <?php }
183 183
 
184
-                    break;
185
-                case EEM_Line_Item::type_sub_line_item:
186
-                    ?>
184
+					break;
185
+				case EEM_Line_Item::type_sub_line_item:
186
+					?>
187 187
                     <tr class="item subitem-row">
188 188
                         <td class="item_l subitem"><?php echo esc_html($line_item->name()); ?></td>
189 189
                         <?php if ($show_line_item_description) { ?>
@@ -199,9 +199,9 @@  discard block
 block discarded – undo
199 199
                         <td class="item_r"><?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); ?></td>
200 200
                     </tr>
201 201
                     <?php
202
-                    break;
203
-                case EEM_Line_Item::type_tax:
204
-                    ?>
202
+					break;
203
+				case EEM_Line_Item::type_tax:
204
+					?>
205 205
                     <tr class="item sub-item tax-total">
206 206
                     <td class="item_l"><?php echo esc_html($line_item->name()); ?></td>
207 207
                     <?php if ($show_line_item_description) { ?>
@@ -211,15 +211,15 @@  discard block
 block discarded – undo
211 211
 
212 212
                     <td class="item_r"><?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); ?></td>
213 213
                     </tr><?php
214
-                    break;
215
-            }
216
-        }
214
+					break;
215
+			}
216
+		}
217 217
 
218
-        $c = false;
219
-        /* @var $transaction EE_Transaction */
220
-        $total_line_item = $transaction->total_line_item();
221
-        ee_invoice_display_line_item($total_line_item, $show_line_item_description);
222
-        /* foreach($transaction->registrations() as $registration){
218
+		$c = false;
219
+		/* @var $transaction EE_Transaction */
220
+		$total_line_item = $transaction->total_line_item();
221
+		ee_invoice_display_line_item($total_line_item, $show_line_item_description);
222
+		/* foreach($transaction->registrations() as $registration){
223 223
              ?>
224 224
             <tr class="item <?php echo ($c = !$c) ? ' odd' : ''; ?>">
225 225
                 <td class="item_l">1</td>
@@ -248,11 +248,11 @@  discard block
 block discarded – undo
248 248
         </thead>
249 249
         <tbody>
250 250
         <?php
251
-        $c = false;
252
-        if (! empty($payments)) {
253
-            foreach ($payments as $payment) {
254
-                /* @var $payment EE_Payment */
255
-                ?>
251
+		$c = false;
252
+		if (! empty($payments)) {
253
+			foreach ($payments as $payment) {
254
+				/* @var $payment EE_Payment */
255
+				?>
256 256
                 <tr class='item <?php echo(($c = ! $c) ? ' odd' : '') ?>'>
257 257
                     <td><?php $payment->e('PAY_gateway') ?></td>
258 258
                     <td><?php echo esc_html($payment->timestamp('D M j, Y')); ?></td>
@@ -262,17 +262,17 @@  discard block
 block discarded – undo
262 262
                     <td class='item_r'><?php echo EEH_Template::format_currency($payment->amount()); ?></td>
263 263
                 </tr>
264 264
             <?php }
265
-        } else {
266
-            ?>
265
+		} else {
266
+			?>
267 267
             <tr class='item'>
268 268
                 <td class='aln-cntr' colspan=6>
269 269
                     <?php esc_html_e(
270
-                        "No approved payments have been received",
271
-                        'event_espresso'
272
-                    ) ?></td>
270
+						"No approved payments have been received",
271
+						'event_espresso'
272
+					) ?></td>
273 273
             </tr>
274 274
         <?php }
275
-        ?>
275
+		?>
276 276
         </tbody>
277 277
         <tfoot>
278 278
         <tr class='total_tr'>
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
         <div class="fn">[name]</div>
55 55
         <div class="adr">
56 56
             <div class="street-address"><?php echo wp_kses($attendee_address, AllowedTags::getAllowedTags()); ?></div>
57
-            <div class="locality"><?php echo wp_kses($attendee_city . ' ' . $attendee_state, AllowedTags::getAllowedTags()); ?></div>
57
+            <div class="locality"><?php echo wp_kses($attendee_city.' '.$attendee_state, AllowedTags::getAllowedTags()); ?></div>
58 58
             <div id="client-postcode"><?php echo wp_kses($attendee_zip, AllowedTags::getAllowedTags()); ?></div>
59 59
         </div>
60 60
     </div>
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
         <tbody>
250 250
         <?php
251 251
         $c = false;
252
-        if (! empty($payments)) {
252
+        if ( ! empty($payments)) {
253 253
             foreach ($payments as $payment) {
254 254
                 /* @var $payment EE_Payment */
255 255
                 ?>
Please login to merge, or discard this patch.
modules/gateways/Invoice/lib/templates/receipt_body.template.php 2 patches
Indentation   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -64,10 +64,10 @@  discard block
 block discarded – undo
64 64
             <h3 class="section-title event-name">
65 65
                 <img class="icon" src="<?php echo EE_IMAGES_URL . 'calendar_year-24x24.png'; ?>">
66 66
                 <?php
67
-                esc_html_e(
68
-                    "Event Name:",
69
-                    "event_espresso"
70
-                ) ?>
67
+				esc_html_e(
68
+					"Event Name:",
69
+					"event_espresso"
70
+				) ?>
71 71
                 <span class="plain-text"><?php echo wp_kses($event->name(), AllowedTags::getAllowedTags()); ?></span>
72 72
                 <span class="small-text link">
73 73
                 [ <a href='<?php echo esc_url_raw($event->get_permalink()) ?>'><?php esc_html_e('view', 'event_espresso'); ?></a> ]
@@ -78,14 +78,14 @@  discard block
 block discarded – undo
78 78
             <?php } ?>
79 79
             <ul class="tickets-per-event">
80 80
                 <?php
81
-                foreach ($ticket_line_items_per_event[ $event_id ] as $line_item_id => $line_item) {
82
-                    $ticket       = $line_item->ticket();
83
-                    $taxable_html = $ticket->taxable()
84
-                            ? '*'
85
-                            : '';
86
-                    $subitems     = $line_item->children();
87
-                    $ticket_uses  = $ticket->get_pretty('TKT_uses', esc_html__("any", "event_espresso"));
88
-                    ?>
81
+				foreach ($ticket_line_items_per_event[ $event_id ] as $line_item_id => $line_item) {
82
+					$ticket       = $line_item->ticket();
83
+					$taxable_html = $ticket->taxable()
84
+							? '*'
85
+							: '';
86
+					$subitems     = $line_item->children();
87
+					$ticket_uses  = $ticket->get_pretty('TKT_uses', esc_html__("any", "event_espresso"));
88
+					?>
89 89
                     <li class="event-ticket">
90 90
                         <div class="ticket-details">
91 91
                             <table class="invoice-amount">
@@ -94,10 +94,10 @@  discard block
 block discarded – undo
94 94
                                     <th class="name-column"><?php esc_html_e("Ticket", "event_espresso"); ?></th>
95 95
                                     <th colspan="2" class="desc-column">
96 96
                                         <?php
97
-                                        esc_html_e(
98
-                                            "Description",
99
-                                            "event_espresso"
100
-                                        ); ?></th>
97
+										esc_html_e(
98
+											"Description",
99
+											"event_espresso"
100
+										); ?></th>
101 101
                                     <th class="number-column item_c"><?php esc_html_e("Quantity", "event_espresso"); ?></th>
102 102
                                     <th class="number-column item_c"><?php esc_html_e("Price", "event_espresso"); ?></th>
103 103
                                     <th class="number-column item_r"><?php esc_html_e("Total", "event_espresso"); ?></th>
@@ -105,20 +105,20 @@  discard block
 block discarded – undo
105 105
                                 </thead>
106 106
                                 <tbody>
107 107
                                 <?php
108
-                                if (count($subitems) < 2) { ?>
108
+								if (count($subitems) < 2) { ?>
109 109
                                     <tr class="item">
110 110
                                         <td><?php echo esc_html($line_item->name() . $taxable_html); ?></td>
111 111
                                         <td colspan="2">
112 112
                                             <?php echo esc_html($line_item->desc()); ?>
113 113
                                             <p class="ticket-note">
114 114
                                                 <?php
115
-                                                echo sprintf(
116
-                                                    esc_html__(
117
-                                                        'This ticket can be used once at %s of the dates/times below.',
118
-                                                        'event_espresso'
119
-                                                    ),
120
-                                                    $ticket_uses
121
-                                                ); ?>
115
+												echo sprintf(
116
+													esc_html__(
117
+														'This ticket can be used once at %s of the dates/times below.',
118
+														'event_espresso'
119
+													),
120
+													$ticket_uses
121
+												); ?>
122 122
                                             </p>
123 123
                                         </td>
124 124
                                         <td class="item_c"><?php echo esc_html($line_item->quantity()); ?></td>
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
                                         <td class="item_r"><?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags());  ?></td>
127 127
                                     </tr>
128 128
                                     <?php
129
-                                } else { ?>
129
+								} else { ?>
130 130
                                     <tr class="item">
131 131
                                         <td class="aln-left">
132 132
                                             <?php echo esc_html($line_item->name() . $taxable_html); ?>
@@ -134,13 +134,13 @@  discard block
 block discarded – undo
134 134
                                         <td colspan="2"><?php echo esc_html($line_item->desc()); ?>
135 135
                                             <p class="ticket-note">
136 136
                                                 <?php
137
-                                                echo sprintf(
138
-                                                    esc_html__(
139
-                                                        'This ticket can be used once at %s of the dates/times below.',
140
-                                                        'event_espresso'
141
-                                                    ),
142
-                                                    $ticket_uses
143
-                                                ); ?>
137
+												echo sprintf(
138
+													esc_html__(
139
+														'This ticket can be used once at %s of the dates/times below.',
140
+														'event_espresso'
141
+													),
142
+													$ticket_uses
143
+												); ?>
144 144
                                             </p>
145 145
                                         </td>
146 146
                                         <td class="item_c">
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
                                         </td>
155 155
                                     </tr>
156 156
                                     <?php
157
-                                    foreach ($subitems as $sub_line_item) {
158
-                                        $is_percent = $sub_line_item->is_percent(); ?>
157
+									foreach ($subitems as $sub_line_item) {
158
+										$is_percent = $sub_line_item->is_percent(); ?>
159 159
                                         <tr class="subitem-row">
160 160
                                             <td class="subitem">
161 161
                                                 <?php echo esc_html($sub_line_item->name()); ?>
@@ -167,14 +167,14 @@  discard block
 block discarded – undo
167 167
                                                 <?php // echo $is_percent ? '' : $sub_line_item->quantity()?>
168 168
                                             </td>
169 169
                                             <td class="item_c"><?php
170
-                                                echo ($is_percent
171
-                                                    ? $sub_line_item->percent() . "%"
172
-                                                    : $sub_line_item->unit_price_no_code()); ?>
170
+												echo ($is_percent
171
+													? $sub_line_item->percent() . "%"
172
+													: $sub_line_item->unit_price_no_code()); ?>
173 173
                                             </td>
174 174
                                             <td class="item_r"><?php echo wp_kses($sub_line_item->total_no_code(), AllowedTags::getAllowedTags()); ?></td>
175 175
                                         </tr>
176 176
                                         <?php
177
-                                    } ?>
177
+									} ?>
178 178
                                     <tr class="total_tr odd">
179 179
                                         <td colspan="4"></td>
180 180
                                         <td class="total" nowrap="nowrap">
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
                                         </td>
186 186
                                     </tr>
187 187
                                     <?php
188
-                                } ?>
188
+								} ?>
189 189
                                 </tbody>
190 190
                             </table>
191 191
 
@@ -196,49 +196,49 @@  discard block
 block discarded – undo
196 196
                                     <h4 class="sub-section-title no-bottom-margin">
197 197
                                         <img class="icon" src="<?php echo esc_url_raw(EE_IMAGES_URL . 'clock-16x16.png'); ?>">
198 198
                                         <?php
199
-                                        echo _n(
200
-                                            "Date/Time:",
201
-                                            "Dates/Times:",
202
-                                            count($ticket->datetimes()),
203
-                                            "event_espresso"
204
-                                        ); ?></h4>
199
+										echo _n(
200
+											"Date/Time:",
201
+											"Dates/Times:",
202
+											count($ticket->datetimes()),
203
+											"event_espresso"
204
+										); ?></h4>
205 205
                                     <ul class="event-dates">
206 206
                                         <?php
207
-                                        foreach ($ticket->datetimes_ordered() as $datetime) {
208
-                                            /* @var $datetime EE_Datetime */ ?>
207
+										foreach ($ticket->datetimes_ordered() as $datetime) {
208
+											/* @var $datetime EE_Datetime */ ?>
209 209
                                             <li><?php
210
-                                                echo ($datetime->name()
211
-                                                    ? '<b>' . esc_html($datetime->name()) . ' </b>'
212
-                                                    : '');
213
-                                                echo sprintf(
214
-                                                    esc_html__("%s - %s (%s)", "event_espresso"),
215
-                                                    $datetime->start_date_and_time(),
216
-                                                    $datetime->end_date_and_time(),
217
-                                                    $datetime->get_timezone()
218
-                                                );
219
-                                                echo ($datetime->description()
220
-                                                    ? '<p class="ticket-note">' . wp_kses($datetime->description(), AllowedTags::getAllowedTags()) . '</p>'
221
-                                                    : ''); ?></li>
210
+												echo ($datetime->name()
211
+													? '<b>' . esc_html($datetime->name()) . ' </b>'
212
+													: '');
213
+												echo sprintf(
214
+													esc_html__("%s - %s (%s)", "event_espresso"),
215
+													$datetime->start_date_and_time(),
216
+													$datetime->end_date_and_time(),
217
+													$datetime->get_timezone()
218
+												);
219
+												echo ($datetime->description()
220
+													? '<p class="ticket-note">' . wp_kses($datetime->description(), AllowedTags::getAllowedTags()) . '</p>'
221
+													: ''); ?></li>
222 222
                                             <?php
223
-                                        } ?>
223
+										} ?>
224 224
                                     </ul>
225 225
                                 </div>
226 226
                                 <?php
227
-                                if ($event->venues()) { ?>
227
+								if ($event->venues()) { ?>
228 228
                                     <div class="ticket-place-details">
229 229
                                         <h4 class="sub-section-title no-bottom-margin">
230 230
                                             <img class="icon" src="<?php
231
-                                            echo esc_url_raw(EE_IMAGES_URL . 'location-pin-16x16.png'); ?>">
231
+											echo esc_url_raw(EE_IMAGES_URL . 'location-pin-16x16.png'); ?>">
232 232
                                             <?php
233
-                                            echo _n(
234
-                                                "Venue:",
235
-                                                "Venues:",
236
-                                                count($event->venues()),
237
-                                                "event_espresso"
238
-                                            ); ?></h4>
233
+											echo _n(
234
+												"Venue:",
235
+												"Venues:",
236
+												count($event->venues()),
237
+												"event_espresso"
238
+											); ?></h4>
239 239
                                         <ul class="event-venues">
240 240
                                             <?php
241
-                                            foreach ($event->venues() as $venue) { ?>
241
+											foreach ($event->venues() as $venue) { ?>
242 242
                                                 <li><?php echo esc_html($venue->name()) ?>
243 243
                                                     <span class="small-text">
244 244
                                                 [
@@ -249,18 +249,18 @@  discard block
 block discarded – undo
249 249
                                             </span>
250 250
                                                 </li>
251 251
                                                 <?php
252
-                                            } ?>
252
+											} ?>
253 253
                                         </ul>
254 254
                                     </div>
255 255
                                     <?php
256
-                                } ?>
256
+								} ?>
257 257
                             </div>
258 258
                             <div class="ticket-registrations-area">
259 259
                                 <h4 class="sub-section-title">
260 260
                                     <img class="icon" src="<?php
261
-                                    echo esc_url_raw(EE_IMAGES_URL . 'users-16x16.png'); ?>">
261
+									echo esc_url_raw(EE_IMAGES_URL . 'users-16x16.png'); ?>">
262 262
                                     <?php
263
-                                    echo esc_html__("Registration Details", "event_espresso"); ?>
263
+									echo esc_html__("Registration Details", "event_espresso"); ?>
264 264
                                     <span class="small-text link">[
265 265
                                 <a class="print_button noPrint" href="<?php echo esc_url_raw($edit_reg_info_url); ?>">
266 266
                                     <?php esc_html_e('edit', 'event_espresso'); ?>
@@ -270,12 +270,12 @@  discard block
 block discarded – undo
270 270
                                 </h4>
271 271
                                 <ul class="ticket-registrations-list">
272 272
                                     <?php
273
-                                    foreach ($registrations_per_line_item[ $line_item_id ] as $registration) {
274
-                                        /* @var $registration EE_Registration */
275
-                                        $attendee = $registration->attendee();
276
-                                        $answers  = $registration->answers(
277
-                                            ['order_by' => ['Question.Question_Group_Question.QGQ_order' => 'ASC']]
278
-                                        ); ?>
273
+									foreach ($registrations_per_line_item[ $line_item_id ] as $registration) {
274
+										/* @var $registration EE_Registration */
275
+										$attendee = $registration->attendee();
276
+										$answers  = $registration->answers(
277
+											['order_by' => ['Question.Question_Group_Question.QGQ_order' => 'ASC']]
278
+										); ?>
279 279
                                         <li class="ticket-registration">
280 280
                                             <table class="registration-details">
281 281
                                                 <tr class="odd">
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
                                                     </td>
291 291
                                                 </tr>
292 292
                                                 <?php
293
-                                                foreach ($event->question_groups() as $question_group) { ?>
293
+												foreach ($event->question_groups() as $question_group) { ?>
294 294
                                                     <tr>
295 295
                                                         <th>
296 296
                                                             <?php $question_group->e('QSG_name'); ?>
@@ -298,12 +298,12 @@  discard block
 block discarded – undo
298 298
                                                         <td></td>
299 299
                                                     </tr>
300 300
                                                     <?php $has_personal_info = false;
301
-                                                    foreach ($question_group->questions() as $question) {
302
-                                                        if (in_array($question->system_ID(), $questions_to_skip)) {
303
-                                                            $has_personal_info = true;
304
-                                                            continue;
305
-                                                        }
306
-                                                        ?>
301
+													foreach ($question_group->questions() as $question) {
302
+														if (in_array($question->system_ID(), $questions_to_skip)) {
303
+															$has_personal_info = true;
304
+															continue;
305
+														}
306
+														?>
307 307
                                                         <tr>
308 308
                                                             <th>
309 309
                                                                 <?php echo wp_kses($question->display_text(), AllowedTags::getAllowedTags()); ?>
@@ -313,26 +313,26 @@  discard block
 block discarded – undo
313 313
                                                             </td>
314 314
                                                         </tr>
315 315
                                                     <?php }
316
-                                                    if ($has_personal_info) { ?>
316
+													if ($has_personal_info) { ?>
317 317
                                                         <tr>
318 318
                                                             <th><?php esc_html_e('Attendee', 'event_espresso'); ?></th>
319 319
                                                             <td>
320 320
                                                                 <?php
321
-                                                                echo sprintf(
322
-                                                                    esc_html__('%s (%s)', "event_espresso"),
323
-                                                                    esc_html($attendee->full_name()),
324
-                                                                    sanitize_email($attendee->email())
325
-                                                                ) ?>
321
+																echo sprintf(
322
+																	esc_html__('%s (%s)', "event_espresso"),
323
+																	esc_html($attendee->full_name()),
324
+																	sanitize_email($attendee->email())
325
+																) ?>
326 326
                                                             </td>
327 327
                                                         </tr>
328 328
                                                         <?php
329
-                                                    }
330
-                                                }
331
-                                                ?>
329
+													}
330
+												}
331
+												?>
332 332
                                             </table>
333 333
                                         </li>
334 334
                                         <?php
335
-                                    } ?>
335
+									} ?>
336 336
                                 </ul>
337 337
                             </div>
338 338
                         </div>
@@ -376,10 +376,10 @@  discard block
 block discarded – undo
376 376
     <div class="grand-total-dv">
377 377
         <h2 class="grand-total">
378 378
             <?php
379
-            printf(
380
-                esc_html__("Grand Total: %s", "event_espresso"),
381
-                EEH_Template::format_currency($total_cost)
382
-            ); ?>
379
+			printf(
380
+				esc_html__("Grand Total: %s", "event_espresso"),
381
+				EEH_Template::format_currency($total_cost)
382
+			); ?>
383 383
         </h2>
384 384
     </div>
385 385
     <div class="payment-dv">
@@ -398,13 +398,13 @@  discard block
 block discarded – undo
398 398
             </thead>
399 399
             <tbody>
400 400
             <?php
401
-            $c = false;
402
-            if (! empty($payments)) {
403
-                foreach ($payments as $payment) {
404
-                    /* @var $payment EE_Payment */ ?>
401
+			$c = false;
402
+			if (! empty($payments)) {
403
+				foreach ($payments as $payment) {
404
+					/* @var $payment EE_Payment */ ?>
405 405
                     <tr class='item <?php echo(($c = ! $c)
406
-                        ? ' odd'
407
-                        : '') ?>'>
406
+						? ' odd'
407
+						: '') ?>'>
408 408
                         <td><?php $payment->e('PAY_gateway') ?></td>
409 409
                         <td><?php echo esc_html($payment->timestamp()); ?></td>
410 410
                         <td><?php $payment->e('PAY_txn_id_chq_nmbr') ?></td>
@@ -413,14 +413,14 @@  discard block
 block discarded – undo
413 413
                         <td class='item_r'><?php echo wp_kses($payment->amount_no_code(), AllowedTags::getAllowedTags()); ?></td>
414 414
                     </tr>
415 415
                 <?php }
416
-            } else { ?>
416
+			} else { ?>
417 417
                 <tr class='item'>
418 418
                     <td class='aln-cntr' colspan="6">
419 419
                         <?php
420
-                        esc_html_e(
421
-                            "No approved payments have been received.",
422
-                            'event_espresso'
423
-                        ) ?>
420
+						esc_html_e(
421
+							"No approved payments have been received.",
422
+							'event_espresso'
423
+						) ?>
424 424
                     </td>
425 425
                 </tr>
426 426
             <?php } ?>
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
             <?php if ($venues_for_events) { ?>
458 458
             <h2>
459 459
                 <?php
460
-                echo _n("Venue Details:", "Venues Details:", count($venues_for_events), "event_espresso"); ?>
460
+				echo _n("Venue Details:", "Venues Details:", count($venues_for_events), "event_espresso"); ?>
461 461
             </h2>
462 462
             <table class="venue-list">
463 463
                 <?php foreach ($venues_for_events as $venue) { ?>
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
     <div class="events">
63 63
         <?php foreach ($events_for_txn as $event_id => $event) { ?>
64 64
             <h3 class="section-title event-name">
65
-                <img class="icon" src="<?php echo EE_IMAGES_URL . 'calendar_year-24x24.png'; ?>">
65
+                <img class="icon" src="<?php echo EE_IMAGES_URL.'calendar_year-24x24.png'; ?>">
66 66
                 <?php
67 67
                 esc_html_e(
68 68
                     "Event Name:",
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
             <?php } ?>
79 79
             <ul class="tickets-per-event">
80 80
                 <?php
81
-                foreach ($ticket_line_items_per_event[ $event_id ] as $line_item_id => $line_item) {
81
+                foreach ($ticket_line_items_per_event[$event_id] as $line_item_id => $line_item) {
82 82
                     $ticket       = $line_item->ticket();
83 83
                     $taxable_html = $ticket->taxable()
84 84
                             ? '*'
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
                                 <?php
108 108
                                 if (count($subitems) < 2) { ?>
109 109
                                     <tr class="item">
110
-                                        <td><?php echo esc_html($line_item->name() . $taxable_html); ?></td>
110
+                                        <td><?php echo esc_html($line_item->name().$taxable_html); ?></td>
111 111
                                         <td colspan="2">
112 112
                                             <?php echo esc_html($line_item->desc()); ?>
113 113
                                             <p class="ticket-note">
@@ -123,13 +123,13 @@  discard block
 block discarded – undo
123 123
                                         </td>
124 124
                                         <td class="item_c"><?php echo esc_html($line_item->quantity()); ?></td>
125 125
                                         <td class="item_c"><?php echo wp_kses($line_item->unit_price_no_code(), AllowedTags::getAllowedTags()); ?></td>
126
-                                        <td class="item_r"><?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags());  ?></td>
126
+                                        <td class="item_r"><?php echo wp_kses($line_item->total_no_code(), AllowedTags::getAllowedTags()); ?></td>
127 127
                                     </tr>
128 128
                                     <?php
129 129
                                 } else { ?>
130 130
                                     <tr class="item">
131 131
                                         <td class="aln-left">
132
-                                            <?php echo esc_html($line_item->name() . $taxable_html); ?>
132
+                                            <?php echo esc_html($line_item->name().$taxable_html); ?>
133 133
                                         </td>
134 134
                                         <td colspan="2"><?php echo esc_html($line_item->desc()); ?>
135 135
                                             <p class="ticket-note">
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
                                             </td>
169 169
                                             <td class="item_c"><?php
170 170
                                                 echo ($is_percent
171
-                                                    ? $sub_line_item->percent() . "%"
171
+                                                    ? $sub_line_item->percent()."%"
172 172
                                                     : $sub_line_item->unit_price_no_code()); ?>
173 173
                                             </td>
174 174
                                             <td class="item_r"><?php echo wp_kses($sub_line_item->total_no_code(), AllowedTags::getAllowedTags()); ?></td>
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
                             <div class="ticket-time-and-place-details">
195 195
                                 <div class="ticket-time-details">
196 196
                                     <h4 class="sub-section-title no-bottom-margin">
197
-                                        <img class="icon" src="<?php echo esc_url_raw(EE_IMAGES_URL . 'clock-16x16.png'); ?>">
197
+                                        <img class="icon" src="<?php echo esc_url_raw(EE_IMAGES_URL.'clock-16x16.png'); ?>">
198 198
                                         <?php
199 199
                                         echo _n(
200 200
                                             "Date/Time:",
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
                                             /* @var $datetime EE_Datetime */ ?>
209 209
                                             <li><?php
210 210
                                                 echo ($datetime->name()
211
-                                                    ? '<b>' . esc_html($datetime->name()) . ' </b>'
211
+                                                    ? '<b>'.esc_html($datetime->name()).' </b>'
212 212
                                                     : '');
213 213
                                                 echo sprintf(
214 214
                                                     esc_html__("%s - %s (%s)", "event_espresso"),
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
                                                     $datetime->get_timezone()
218 218
                                                 );
219 219
                                                 echo ($datetime->description()
220
-                                                    ? '<p class="ticket-note">' . wp_kses($datetime->description(), AllowedTags::getAllowedTags()) . '</p>'
220
+                                                    ? '<p class="ticket-note">'.wp_kses($datetime->description(), AllowedTags::getAllowedTags()).'</p>'
221 221
                                                     : ''); ?></li>
222 222
                                             <?php
223 223
                                         } ?>
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
                                     <div class="ticket-place-details">
229 229
                                         <h4 class="sub-section-title no-bottom-margin">
230 230
                                             <img class="icon" src="<?php
231
-                                            echo esc_url_raw(EE_IMAGES_URL . 'location-pin-16x16.png'); ?>">
231
+                                            echo esc_url_raw(EE_IMAGES_URL.'location-pin-16x16.png'); ?>">
232 232
                                             <?php
233 233
                                             echo _n(
234 234
                                                 "Venue:",
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
                             <div class="ticket-registrations-area">
259 259
                                 <h4 class="sub-section-title">
260 260
                                     <img class="icon" src="<?php
261
-                                    echo esc_url_raw(EE_IMAGES_URL . 'users-16x16.png'); ?>">
261
+                                    echo esc_url_raw(EE_IMAGES_URL.'users-16x16.png'); ?>">
262 262
                                     <?php
263 263
                                     echo esc_html__("Registration Details", "event_espresso"); ?>
264 264
                                     <span class="small-text link">[
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
                                 </h4>
271 271
                                 <ul class="ticket-registrations-list">
272 272
                                     <?php
273
-                                    foreach ($registrations_per_line_item[ $line_item_id ] as $registration) {
273
+                                    foreach ($registrations_per_line_item[$line_item_id] as $registration) {
274 274
                                         /* @var $registration EE_Registration */
275 275
                                         $attendee = $registration->attendee();
276 276
                                         $answers  = $registration->answers(
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
             <tbody>
400 400
             <?php
401 401
             $c = false;
402
-            if (! empty($payments)) {
402
+            if ( ! empty($payments)) {
403 403
                 foreach ($payments as $payment) {
404 404
                     /* @var $payment EE_Payment */ ?>
405 405
                     <tr class='item <?php echo(($c = ! $c)
Please login to merge, or discard this patch.
modules/gateways/Invoice/lib/Invoice.class.php 2 patches
Indentation   +429 added lines, -429 removed lines patch added patch discarded remove patch
@@ -13,433 +13,433 @@
 block discarded – undo
13 13
 class Invoice
14 14
 {
15 15
 
16
-    /**
17
-     *
18
-     * @var EE_Registration
19
-     */
20
-    private $registration;
21
-
22
-    /**
23
-     *
24
-     * @var EE_Transaction
25
-     */
26
-    private $transaction;
27
-
28
-    /**
29
-     *
30
-     * @var EE_Payment_Method
31
-     */
32
-    private $invoice_payment_method;
33
-
34
-
35
-    /**
36
-     * Invoice constructor.
37
-     *
38
-     * @param int $url_link
39
-     * @throws EE_Error
40
-     * @throws ReflectionException
41
-     * @deprecated 4.9.13
42
-     */
43
-    public function __construct($url_link = 0)
44
-    {
45
-        EE_Error::doing_it_wrong(
46
-            __CLASS__,
47
-            esc_html__(
48
-                'This class has been deprecated and replaced by the new Messages library.',
49
-                'event_espresso'
50
-            ),
51
-            '4.9.12',
52
-            '5.0.0'
53
-        );
54
-        /** @var EEM_Registration $reg_model */
55
-        $reg_model = EE_Registry::instance()->load_model('Registration');
56
-        if ($this->registration = $reg_model->get_registration_for_reg_url_link($url_link)) {
57
-            $this->transaction = $this->registration->transaction();
58
-            EE_Config::instance()->gateway->payment_settings;
59
-            $this->invoice_payment_method = EEM_Payment_Method::instance()->get_one_of_type('Invoice');
60
-        } else {
61
-            EE_Error::add_error(
62
-                esc_html__(
63
-                    'Your request appears to be missing some required data, and no information for your transaction could be retrieved.',
64
-                    'event_espresso'
65
-                ),
66
-                __FILE__,
67
-                __FUNCTION__,
68
-                __LINE__
69
-            );
70
-        }
71
-    }
72
-
73
-
74
-    /**
75
-     * @param false $download
76
-     * @throws EE_Error
77
-     * @throws ReflectionException
78
-     */
79
-    public function send_invoice($download = false)
80
-    {
81
-        $template_args = [];
82
-        $EE            = EE_Registry::instance();
83
-        /** @var RequestInterface $request */
84
-        $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
85
-        $theme   = $request->getRequestParam('theme', 0, 'int');
86
-        // allow the request to override the default theme defined in the invoice settings
87
-        $theme_requested = $theme > 0 && $theme < 8
88
-                ? $theme
89
-                : null;
90
-        $themes          = [
91
-            1 => "simple.css",
92
-            2 => "bauhaus.css",
93
-            3 => "ejs.css",
94
-            4 => "horizon.css",
95
-            5 => "lola.css",
96
-            6 => "tranquility.css",
97
-            7 => "union.css",
98
-        ];
99
-        // Get the CSS file
100
-        if (isset($themes[ $theme_requested ])) {
101
-            $template_args['invoice_css'] = $themes[ $theme_requested ];
102
-        } else {
103
-            $template_args['invoice_css'] = $this->invoice_payment_method->get_extra_meta(
104
-                'legacy_invoice_css',
105
-                true,
106
-                'simple.css'
107
-            );
108
-        }
109
-
110
-        if (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) {
111
-            $template_args['base_url'] = EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/';
112
-        } else {
113
-            $template_args['base_url'] = EE_GATEWAYS . '/Invoice/lib/templates/';
114
-        }
115
-        $primary_attendee = $this->transaction->primary_registration()->attendee();
116
-
117
-        $template_args['organization'] = $EE->CFG->organization->get_pretty('name');
118
-        $template_args['street']       = empty($EE->CFG->organization->address_2)
119
-                ? $EE->CFG->organization->get_pretty('address_1')
120
-                : $EE->CFG->organization->get_pretty('address_1')
121
-                  . '<br>'
122
-                  . $EE->CFG->organization->get_pretty('address_2');
123
-        $template_args['city']         = $EE->CFG->organization->get_pretty('city');
124
-        $template_args['state']        = EE_Registry::instance()->load_model('State')->get_one_by_ID(
125
-            $EE->CFG->organization->STA_ID
126
-        );
127
-        $template_args['country']      = EE_Registry::instance()->load_model('Country')->get_one_by_ID(
128
-            $EE->CFG->organization->CNT_ISO
129
-        );
130
-        $template_args['zip']          = $EE->CFG->organization->get_pretty('zip');
131
-        $template_args['email']        = $EE->CFG->organization->get_pretty('email');
132
-
133
-        $template_args['registration_code'] = $this->registration->reg_code();
134
-        $template_args['registration_date'] = $this->registration->date();
135
-        $template_args['name']              = $primary_attendee->full_name();
136
-        $template_args['attendee_address']  = $primary_attendee->address();
137
-        $template_args['attendee_address2'] = $primary_attendee->address2();
138
-        $template_args['attendee_city']     = $primary_attendee->city();
139
-        $attendee_state                     = $primary_attendee->state_obj();
140
-        if ($attendee_state) {
141
-            $attendee_state_name = $attendee_state->name();
142
-        } else {
143
-            $attendee_state_name = '';
144
-        }
145
-        $template_args['attendee_state'] = $attendee_state_name;
146
-        $template_args['attendee_zip']   = $primary_attendee->zip();
147
-
148
-        $template_args['ship_name']    = $template_args['name'];
149
-        $template_args['ship_address'] = $template_args['attendee_address'];
150
-        $template_args['ship_city']    = $template_args['attendee_city'];
151
-        $template_args['ship_state']   = $template_args['attendee_state'];
152
-        $template_args['ship_zip']     = $template_args['attendee_zip'];
153
-
154
-        $template_args['total_cost']                 = number_format($this->transaction->total(), 2, '.', '');
155
-        $template_args['transaction']                = $this->transaction;
156
-        $template_args['amount_pd']                  = $this->transaction->paid();
157
-        $template_args['amount_owed']                = $this->transaction->total() - $this->transaction->paid();
158
-        $template_args['payments']                   = $this->transaction->approved_payments();
159
-        $template_args['net_total']                  = '';
160
-        $template_args['edit_reg_info_url']          = $this->registration->edit_attendee_information_url();
161
-        $template_args['retry_payment_url']          = $this->registration->payment_overview_url();
162
-        $template_args['show_line_item_description'] = $this->check_if_any_line_items_have_a_description(
163
-            $this->transaction->total_line_item()
164
-        );
165
-        if ($template_args['amount_pd'] != $template_args['total_cost']) {
166
-            // $template_args['net_total'] = $this->espressoInvoiceTotals(
167
-            //      esc_html__('SubTotal', 'event_espresso'),
168
-            //      $this->transaction->total());
169
-            //      $this->session_data['cart']['REG']['sub_total']
170
-            // );
171
-            $tax_items = $this->transaction->tax_items();
172
-            if (! empty($tax_items)) {
173
-                foreach ($tax_items as $tax) {
174
-                    $template_args['net_total'] .= $this->espressoInvoiceTotals($tax->name(), $tax->total());
175
-                }
176
-            }
177
-
178
-            $difference = $template_args['amount_pd'] - $template_args['total_cost'];
179
-            if ($difference < 0) {
180
-                $text = esc_html__('Discount', 'event_espresso');
181
-            } else {
182
-                $text = esc_html__('Extra', 'event_espresso');
183
-            }
184
-            $template_args['discount'] = $this->espressoInvoiceTotals($text, $difference);
185
-        }
186
-
187
-        $template_args['currency_symbol']               = $EE->CFG->currency->sign;
188
-        $template_args['template_payment_instructions'] = wpautop(
189
-            stripslashes_deep(
190
-                html_entity_decode($this->invoice_payment_method->get_extra_meta('pdf_instructions', true), ENT_QUOTES)
191
-            )
192
-        );
193
-        $template_args['shameless_plug']                = apply_filters(
194
-            'FHEE_Invoice__send_invoice__shameless_plug',
195
-            true
196
-        );
197
-        $receipt = $request->getRequestParam('receipt');
198
-        if ($receipt) {
199
-            // receipt-specific stuff
200
-            $events_for_txn              = EEM_Event::instance()->get_all(
201
-                [['Registration.TXN_ID' => $this->transaction->ID()]]
202
-            );
203
-            $ticket_line_items_per_event = [];
204
-            $registrations_per_line_item = [];
205
-            $venues_for_events           = [];
206
-            foreach ($events_for_txn as $event_id => $event) {
207
-                $line_items_for_this_event                = EEM_Line_Item::instance()->get_all(
208
-                    [['Ticket.Datetime.EVT_ID' => $event_id, 'TXN_ID' => $this->transaction->ID()]]
209
-                );
210
-                $ticket_line_items_per_event[ $event_id ] = $line_items_for_this_event;
211
-                foreach ($line_items_for_this_event as $line_item_id => $line_item) {
212
-                    if (! $line_item instanceof EE_Line_Item) {
213
-                        continue;
214
-                    }
215
-                    $ticket                                       = $line_item->ticket();
216
-                    $registrations_for_this_ticket                = EEM_Registration::instance()->get_all(
217
-                        [['TKT_ID' => $ticket->ID(), 'TXN_ID' => $this->transaction->ID()]]
218
-                    );
219
-                    $registrations_per_line_item[ $line_item_id ] = $registrations_for_this_ticket;
220
-                }
221
-                if ($event instanceof EE_Event) {
222
-                    $venues_for_events += $event->venues();
223
-                }
224
-            }
225
-            $tax_total_line_item = EEM_Line_Item::instance()->get_one(
226
-                [['TXN_ID' => $this->transaction->ID(), 'LIN_type' => EEM_Line_Item::type_tax_sub_total]]
227
-            );
228
-            $questions_to_skip   = [
229
-                EEM_Attendee::system_question_fname,
230
-                EEM_Attendee::system_question_lname,
231
-                EEM_Attendee::system_question_email,
232
-            ];
233
-
234
-
235
-            $template_args['events_for_txn']              = $events_for_txn;
236
-            $template_args['ticket_line_items_per_event'] = $ticket_line_items_per_event;
237
-            $template_args['registrations_per_line_item'] = $registrations_per_line_item;
238
-            $template_args['venues_for_events']           = $venues_for_events;
239
-            $template_args['tax_total_line_item']         = $tax_total_line_item;
240
-            $template_args['questions_to_skip']           = $questions_to_skip;
241
-            // d($template_args);
242
-            $template_args['download_link'] = $this->registration->receipt_url('download');
243
-        } else {
244
-            // it's just an invoice we're accessing
245
-            $template_args['download_link'] = $this->registration->invoice_url('download');
246
-        }
247
-
248
-        // Get the HTML as an object
249
-        $templates_relative_path = 'modules/gateways/Invoice/lib/templates/';
250
-        $template_header         = EEH_Template::locate_template(
251
-            $templates_relative_path . 'invoice_header.template.php',
252
-            $template_args
253
-        );
254
-        if ($receipt) {
255
-            $template_body = EEH_Template::locate_template(
256
-                $templates_relative_path . 'receipt_body.template.php',
257
-                $template_args
258
-            );
259
-        } else {
260
-            $template_body = EEH_Template::locate_template(
261
-                $templates_relative_path . 'invoice_body.template.php',
262
-                $template_args
263
-            );
264
-        }
265
-
266
-
267
-        $template_footer = EEH_Template::locate_template(
268
-            $templates_relative_path . 'invoice_footer.template.php',
269
-            $template_args
270
-        );
271
-
272
-        $copies = $request->getRequestParam('copies', 1, 'int');
273
-
274
-        $content = $this->espresso_replace_invoice_shortcodes($template_header);
275
-        for ($x = 1; $x <= $copies; $x++) {
276
-            $content .= $this->espresso_replace_invoice_shortcodes($template_body);
277
-        }
278
-        $content .= $this->espresso_replace_invoice_shortcodes($template_footer);
279
-
280
-        // Check if debugging or mobile is set
281
-        if ($request->getRequestParam('html')) {
282
-            echo wp_kses($content, AllowedTags::getWithFormTags());
283
-            exit(0);
284
-        }
285
-        $invoice_name = $template_args['organization'] . ' ';
286
-        $invoice_name .= esc_html__('Invoice #', 'event_espresso');
287
-        $invoice_name .= $template_args['registration_code'];
288
-        $invoice_name .= esc_html__(' for ', 'event_espresso') . $template_args['name'];
289
-        $invoice_name = str_replace(' ', '_', $invoice_name);
290
-        // Create the PDF
291
-        if ($request->requestParamIsSet('html')) {
292
-            echo wp_kses($content, AllowedTags::getWithFormTags());
293
-        } else {
294
-            // only load dompdf if nobody else has yet...
295
-            if (! class_exists('Dompdf\Dompdf')) {
296
-                require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php');
297
-                Dompdf\Autoloader::register();
298
-            }
299
-            $options = new Dompdf\Options();
300
-            $options->set('isRemoteEnabled', true);
301
-            $options->set('isJavascriptEnabled', false);
302
-            if (defined('DOMPDF_FONT_DIR')) {
303
-                $options->setFontDir(DOMPDF_FONT_DIR);
304
-                $options->setFontCache(DOMPDF_FONT_DIR);
305
-            }
306
-            $dompdf = new Dompdf\Dompdf($options);
307
-            $dompdf->loadHtml($content);
308
-            $dompdf->render();
309
-            $dompdf->stream($invoice_name . ".pdf", ['Attachment' => $download]);
310
-        }
311
-        exit(0);
312
-    }
313
-
314
-
315
-    /**
316
-     * Checks if this line item, or any of its children, actually has a description.
317
-     * If none do, then the template can decide to not show any description column
318
-     *
319
-     * @param EE_Line_Item $line_item
320
-     * @return boolean
321
-     * @throws EE_Error
322
-     * @throws ReflectionException
323
-     */
324
-    public function check_if_any_line_items_have_a_description(EE_Line_Item $line_item)
325
-    {
326
-        if ($line_item->desc()) {
327
-            return true;
328
-        } else {
329
-            foreach ($line_item->children() as $child_line_item) {
330
-                if ($this->check_if_any_line_items_have_a_description($child_line_item)) {
331
-                    return true;
332
-                }
333
-            }
334
-            // well, if I and my children don't have descriptions, I guess not
335
-            return false;
336
-        }
337
-    }
338
-
339
-
340
-    /**
341
-     * Perform the shortcode replacement
342
-     *
343
-     * @param $content
344
-     * @return array|string|string[]
345
-     * @throws EE_Error
346
-     * @throws ReflectionException
347
-     */
348
-    public function espresso_replace_invoice_shortcodes($content)
349
-    {
350
-
351
-        $EE = EE_Registry::instance();
352
-        // Create the logo
353
-        $invoice_logo_url = $this->invoice_payment_method->get_extra_meta(
354
-            'pdf_logo_image',
355
-            true,
356
-            $EE->CFG->organization->logo_url
357
-        );
358
-        if (! empty($invoice_logo_url)) {
359
-            $image_size         = getimagesize($invoice_logo_url);
360
-            $invoice_logo_image =
361
-                '<img class="logo screen" src="' . $invoice_logo_url . '" ' . $image_size[3] . ' alt="logo" /> ';
362
-        } else {
363
-            $invoice_logo_image = '';
364
-        }
365
-        $SearchValues     = [
366
-            "[organization]",
367
-            "[registration_code]",
368
-            "[transaction_id]",
369
-            "[name]",
370
-            "[base_url]",
371
-            "[download_link]",
372
-            "[invoice_logo_image]",
373
-            "[street]",
374
-            "[city]",
375
-            "[state]",
376
-            "[zip]",
377
-            "[email]",
378
-            "[vat]",
379
-            "[registration_date]",
380
-            "[instructions]",
381
-        ];
382
-        $primary_attendee = $this->transaction->primary_registration()->attendee();
383
-        $org_state        = EE_Registry::instance()->load_model('State')->get_one_by_ID($EE->CFG->organization->STA_ID);
384
-        if ($org_state) {
385
-            $org_state_name = $org_state->name();
386
-        } else {
387
-            $org_state_name = '';
388
-        }
389
-        $ReplaceValues = [
390
-            $EE->CFG->organization->get_pretty('name'),
391
-            $this->registration->reg_code(),
392
-            $this->transaction->ID(),
393
-            $primary_attendee->full_name(),
394
-            (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice'))
395
-                ? EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/'
396
-                : EE_GATEWAYS_URL . 'Invoice/lib/templates/',
397
-            $this->registration->invoice_url(),
398
-            // home_url() . '/?download_invoice=true&amp;id=' . $this->registration->reg_url_link(),
399
-            $invoice_logo_image,
400
-            empty($EE->CFG->organization->address_2)
401
-                ? $EE->CFG->organization->get_pretty('address_1')
402
-                : $EE->CFG->organization->get_pretty('address_1') . '<br>' . $EE->CFG->organization->get_pretty(
403
-                    'address_2'
404
-                ),
405
-            $EE->CFG->organization->get_pretty('city'),
406
-            $org_state_name,
407
-            $EE->CFG->organization->get_pretty('zip'),
408
-            $EE->CFG->organization->get_pretty('email'),
409
-            $EE->CFG->organization->vat,
410
-            $this->registration->get_i18n_datetime('REG_date', get_option('date_format')),
411
-            $this->invoice_payment_method->get_extra_meta('pdf_instructions', true),
412
-        ];
413
-
414
-        return str_replace($SearchValues, $ReplaceValues, $content);
415
-    }
416
-
417
-
418
-    public function espressoLoadData($items)
419
-    {
420
-        $lines = $items;
421
-        $data  = [];
422
-        foreach ($lines as $line) {
423
-            $data[] = explode(';', chop($line));
424
-        }
425
-
426
-        return $data;
427
-    }
428
-
429
-
430
-    public function espressoInvoiceTotals($text, $total_cost)
431
-    {
432
-        $html = '';
433
-        if ($total_cost < 0) {
434
-            $total_cost = (-1) * $total_cost;
435
-        }
436
-        $find    = [' '];
437
-        $replace = ['-'];
438
-        $row_id  = strtolower(str_replace($find, $replace, $text));
439
-        $html    .= '<tr id="' . $row_id . '-tr"><td colspan="4">&nbsp;</td>';
440
-        $html    .= '<td class="item_r">' . $text . '</td>';
441
-        $html    .= '<td class="item_r">' . $total_cost . '</td>';
442
-        $html    .= '</tr>';
443
-        return $html;
444
-    }
16
+	/**
17
+	 *
18
+	 * @var EE_Registration
19
+	 */
20
+	private $registration;
21
+
22
+	/**
23
+	 *
24
+	 * @var EE_Transaction
25
+	 */
26
+	private $transaction;
27
+
28
+	/**
29
+	 *
30
+	 * @var EE_Payment_Method
31
+	 */
32
+	private $invoice_payment_method;
33
+
34
+
35
+	/**
36
+	 * Invoice constructor.
37
+	 *
38
+	 * @param int $url_link
39
+	 * @throws EE_Error
40
+	 * @throws ReflectionException
41
+	 * @deprecated 4.9.13
42
+	 */
43
+	public function __construct($url_link = 0)
44
+	{
45
+		EE_Error::doing_it_wrong(
46
+			__CLASS__,
47
+			esc_html__(
48
+				'This class has been deprecated and replaced by the new Messages library.',
49
+				'event_espresso'
50
+			),
51
+			'4.9.12',
52
+			'5.0.0'
53
+		);
54
+		/** @var EEM_Registration $reg_model */
55
+		$reg_model = EE_Registry::instance()->load_model('Registration');
56
+		if ($this->registration = $reg_model->get_registration_for_reg_url_link($url_link)) {
57
+			$this->transaction = $this->registration->transaction();
58
+			EE_Config::instance()->gateway->payment_settings;
59
+			$this->invoice_payment_method = EEM_Payment_Method::instance()->get_one_of_type('Invoice');
60
+		} else {
61
+			EE_Error::add_error(
62
+				esc_html__(
63
+					'Your request appears to be missing some required data, and no information for your transaction could be retrieved.',
64
+					'event_espresso'
65
+				),
66
+				__FILE__,
67
+				__FUNCTION__,
68
+				__LINE__
69
+			);
70
+		}
71
+	}
72
+
73
+
74
+	/**
75
+	 * @param false $download
76
+	 * @throws EE_Error
77
+	 * @throws ReflectionException
78
+	 */
79
+	public function send_invoice($download = false)
80
+	{
81
+		$template_args = [];
82
+		$EE            = EE_Registry::instance();
83
+		/** @var RequestInterface $request */
84
+		$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
85
+		$theme   = $request->getRequestParam('theme', 0, 'int');
86
+		// allow the request to override the default theme defined in the invoice settings
87
+		$theme_requested = $theme > 0 && $theme < 8
88
+				? $theme
89
+				: null;
90
+		$themes          = [
91
+			1 => "simple.css",
92
+			2 => "bauhaus.css",
93
+			3 => "ejs.css",
94
+			4 => "horizon.css",
95
+			5 => "lola.css",
96
+			6 => "tranquility.css",
97
+			7 => "union.css",
98
+		];
99
+		// Get the CSS file
100
+		if (isset($themes[ $theme_requested ])) {
101
+			$template_args['invoice_css'] = $themes[ $theme_requested ];
102
+		} else {
103
+			$template_args['invoice_css'] = $this->invoice_payment_method->get_extra_meta(
104
+				'legacy_invoice_css',
105
+				true,
106
+				'simple.css'
107
+			);
108
+		}
109
+
110
+		if (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) {
111
+			$template_args['base_url'] = EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/';
112
+		} else {
113
+			$template_args['base_url'] = EE_GATEWAYS . '/Invoice/lib/templates/';
114
+		}
115
+		$primary_attendee = $this->transaction->primary_registration()->attendee();
116
+
117
+		$template_args['organization'] = $EE->CFG->organization->get_pretty('name');
118
+		$template_args['street']       = empty($EE->CFG->organization->address_2)
119
+				? $EE->CFG->organization->get_pretty('address_1')
120
+				: $EE->CFG->organization->get_pretty('address_1')
121
+				  . '<br>'
122
+				  . $EE->CFG->organization->get_pretty('address_2');
123
+		$template_args['city']         = $EE->CFG->organization->get_pretty('city');
124
+		$template_args['state']        = EE_Registry::instance()->load_model('State')->get_one_by_ID(
125
+			$EE->CFG->organization->STA_ID
126
+		);
127
+		$template_args['country']      = EE_Registry::instance()->load_model('Country')->get_one_by_ID(
128
+			$EE->CFG->organization->CNT_ISO
129
+		);
130
+		$template_args['zip']          = $EE->CFG->organization->get_pretty('zip');
131
+		$template_args['email']        = $EE->CFG->organization->get_pretty('email');
132
+
133
+		$template_args['registration_code'] = $this->registration->reg_code();
134
+		$template_args['registration_date'] = $this->registration->date();
135
+		$template_args['name']              = $primary_attendee->full_name();
136
+		$template_args['attendee_address']  = $primary_attendee->address();
137
+		$template_args['attendee_address2'] = $primary_attendee->address2();
138
+		$template_args['attendee_city']     = $primary_attendee->city();
139
+		$attendee_state                     = $primary_attendee->state_obj();
140
+		if ($attendee_state) {
141
+			$attendee_state_name = $attendee_state->name();
142
+		} else {
143
+			$attendee_state_name = '';
144
+		}
145
+		$template_args['attendee_state'] = $attendee_state_name;
146
+		$template_args['attendee_zip']   = $primary_attendee->zip();
147
+
148
+		$template_args['ship_name']    = $template_args['name'];
149
+		$template_args['ship_address'] = $template_args['attendee_address'];
150
+		$template_args['ship_city']    = $template_args['attendee_city'];
151
+		$template_args['ship_state']   = $template_args['attendee_state'];
152
+		$template_args['ship_zip']     = $template_args['attendee_zip'];
153
+
154
+		$template_args['total_cost']                 = number_format($this->transaction->total(), 2, '.', '');
155
+		$template_args['transaction']                = $this->transaction;
156
+		$template_args['amount_pd']                  = $this->transaction->paid();
157
+		$template_args['amount_owed']                = $this->transaction->total() - $this->transaction->paid();
158
+		$template_args['payments']                   = $this->transaction->approved_payments();
159
+		$template_args['net_total']                  = '';
160
+		$template_args['edit_reg_info_url']          = $this->registration->edit_attendee_information_url();
161
+		$template_args['retry_payment_url']          = $this->registration->payment_overview_url();
162
+		$template_args['show_line_item_description'] = $this->check_if_any_line_items_have_a_description(
163
+			$this->transaction->total_line_item()
164
+		);
165
+		if ($template_args['amount_pd'] != $template_args['total_cost']) {
166
+			// $template_args['net_total'] = $this->espressoInvoiceTotals(
167
+			//      esc_html__('SubTotal', 'event_espresso'),
168
+			//      $this->transaction->total());
169
+			//      $this->session_data['cart']['REG']['sub_total']
170
+			// );
171
+			$tax_items = $this->transaction->tax_items();
172
+			if (! empty($tax_items)) {
173
+				foreach ($tax_items as $tax) {
174
+					$template_args['net_total'] .= $this->espressoInvoiceTotals($tax->name(), $tax->total());
175
+				}
176
+			}
177
+
178
+			$difference = $template_args['amount_pd'] - $template_args['total_cost'];
179
+			if ($difference < 0) {
180
+				$text = esc_html__('Discount', 'event_espresso');
181
+			} else {
182
+				$text = esc_html__('Extra', 'event_espresso');
183
+			}
184
+			$template_args['discount'] = $this->espressoInvoiceTotals($text, $difference);
185
+		}
186
+
187
+		$template_args['currency_symbol']               = $EE->CFG->currency->sign;
188
+		$template_args['template_payment_instructions'] = wpautop(
189
+			stripslashes_deep(
190
+				html_entity_decode($this->invoice_payment_method->get_extra_meta('pdf_instructions', true), ENT_QUOTES)
191
+			)
192
+		);
193
+		$template_args['shameless_plug']                = apply_filters(
194
+			'FHEE_Invoice__send_invoice__shameless_plug',
195
+			true
196
+		);
197
+		$receipt = $request->getRequestParam('receipt');
198
+		if ($receipt) {
199
+			// receipt-specific stuff
200
+			$events_for_txn              = EEM_Event::instance()->get_all(
201
+				[['Registration.TXN_ID' => $this->transaction->ID()]]
202
+			);
203
+			$ticket_line_items_per_event = [];
204
+			$registrations_per_line_item = [];
205
+			$venues_for_events           = [];
206
+			foreach ($events_for_txn as $event_id => $event) {
207
+				$line_items_for_this_event                = EEM_Line_Item::instance()->get_all(
208
+					[['Ticket.Datetime.EVT_ID' => $event_id, 'TXN_ID' => $this->transaction->ID()]]
209
+				);
210
+				$ticket_line_items_per_event[ $event_id ] = $line_items_for_this_event;
211
+				foreach ($line_items_for_this_event as $line_item_id => $line_item) {
212
+					if (! $line_item instanceof EE_Line_Item) {
213
+						continue;
214
+					}
215
+					$ticket                                       = $line_item->ticket();
216
+					$registrations_for_this_ticket                = EEM_Registration::instance()->get_all(
217
+						[['TKT_ID' => $ticket->ID(), 'TXN_ID' => $this->transaction->ID()]]
218
+					);
219
+					$registrations_per_line_item[ $line_item_id ] = $registrations_for_this_ticket;
220
+				}
221
+				if ($event instanceof EE_Event) {
222
+					$venues_for_events += $event->venues();
223
+				}
224
+			}
225
+			$tax_total_line_item = EEM_Line_Item::instance()->get_one(
226
+				[['TXN_ID' => $this->transaction->ID(), 'LIN_type' => EEM_Line_Item::type_tax_sub_total]]
227
+			);
228
+			$questions_to_skip   = [
229
+				EEM_Attendee::system_question_fname,
230
+				EEM_Attendee::system_question_lname,
231
+				EEM_Attendee::system_question_email,
232
+			];
233
+
234
+
235
+			$template_args['events_for_txn']              = $events_for_txn;
236
+			$template_args['ticket_line_items_per_event'] = $ticket_line_items_per_event;
237
+			$template_args['registrations_per_line_item'] = $registrations_per_line_item;
238
+			$template_args['venues_for_events']           = $venues_for_events;
239
+			$template_args['tax_total_line_item']         = $tax_total_line_item;
240
+			$template_args['questions_to_skip']           = $questions_to_skip;
241
+			// d($template_args);
242
+			$template_args['download_link'] = $this->registration->receipt_url('download');
243
+		} else {
244
+			// it's just an invoice we're accessing
245
+			$template_args['download_link'] = $this->registration->invoice_url('download');
246
+		}
247
+
248
+		// Get the HTML as an object
249
+		$templates_relative_path = 'modules/gateways/Invoice/lib/templates/';
250
+		$template_header         = EEH_Template::locate_template(
251
+			$templates_relative_path . 'invoice_header.template.php',
252
+			$template_args
253
+		);
254
+		if ($receipt) {
255
+			$template_body = EEH_Template::locate_template(
256
+				$templates_relative_path . 'receipt_body.template.php',
257
+				$template_args
258
+			);
259
+		} else {
260
+			$template_body = EEH_Template::locate_template(
261
+				$templates_relative_path . 'invoice_body.template.php',
262
+				$template_args
263
+			);
264
+		}
265
+
266
+
267
+		$template_footer = EEH_Template::locate_template(
268
+			$templates_relative_path . 'invoice_footer.template.php',
269
+			$template_args
270
+		);
271
+
272
+		$copies = $request->getRequestParam('copies', 1, 'int');
273
+
274
+		$content = $this->espresso_replace_invoice_shortcodes($template_header);
275
+		for ($x = 1; $x <= $copies; $x++) {
276
+			$content .= $this->espresso_replace_invoice_shortcodes($template_body);
277
+		}
278
+		$content .= $this->espresso_replace_invoice_shortcodes($template_footer);
279
+
280
+		// Check if debugging or mobile is set
281
+		if ($request->getRequestParam('html')) {
282
+			echo wp_kses($content, AllowedTags::getWithFormTags());
283
+			exit(0);
284
+		}
285
+		$invoice_name = $template_args['organization'] . ' ';
286
+		$invoice_name .= esc_html__('Invoice #', 'event_espresso');
287
+		$invoice_name .= $template_args['registration_code'];
288
+		$invoice_name .= esc_html__(' for ', 'event_espresso') . $template_args['name'];
289
+		$invoice_name = str_replace(' ', '_', $invoice_name);
290
+		// Create the PDF
291
+		if ($request->requestParamIsSet('html')) {
292
+			echo wp_kses($content, AllowedTags::getWithFormTags());
293
+		} else {
294
+			// only load dompdf if nobody else has yet...
295
+			if (! class_exists('Dompdf\Dompdf')) {
296
+				require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php');
297
+				Dompdf\Autoloader::register();
298
+			}
299
+			$options = new Dompdf\Options();
300
+			$options->set('isRemoteEnabled', true);
301
+			$options->set('isJavascriptEnabled', false);
302
+			if (defined('DOMPDF_FONT_DIR')) {
303
+				$options->setFontDir(DOMPDF_FONT_DIR);
304
+				$options->setFontCache(DOMPDF_FONT_DIR);
305
+			}
306
+			$dompdf = new Dompdf\Dompdf($options);
307
+			$dompdf->loadHtml($content);
308
+			$dompdf->render();
309
+			$dompdf->stream($invoice_name . ".pdf", ['Attachment' => $download]);
310
+		}
311
+		exit(0);
312
+	}
313
+
314
+
315
+	/**
316
+	 * Checks if this line item, or any of its children, actually has a description.
317
+	 * If none do, then the template can decide to not show any description column
318
+	 *
319
+	 * @param EE_Line_Item $line_item
320
+	 * @return boolean
321
+	 * @throws EE_Error
322
+	 * @throws ReflectionException
323
+	 */
324
+	public function check_if_any_line_items_have_a_description(EE_Line_Item $line_item)
325
+	{
326
+		if ($line_item->desc()) {
327
+			return true;
328
+		} else {
329
+			foreach ($line_item->children() as $child_line_item) {
330
+				if ($this->check_if_any_line_items_have_a_description($child_line_item)) {
331
+					return true;
332
+				}
333
+			}
334
+			// well, if I and my children don't have descriptions, I guess not
335
+			return false;
336
+		}
337
+	}
338
+
339
+
340
+	/**
341
+	 * Perform the shortcode replacement
342
+	 *
343
+	 * @param $content
344
+	 * @return array|string|string[]
345
+	 * @throws EE_Error
346
+	 * @throws ReflectionException
347
+	 */
348
+	public function espresso_replace_invoice_shortcodes($content)
349
+	{
350
+
351
+		$EE = EE_Registry::instance();
352
+		// Create the logo
353
+		$invoice_logo_url = $this->invoice_payment_method->get_extra_meta(
354
+			'pdf_logo_image',
355
+			true,
356
+			$EE->CFG->organization->logo_url
357
+		);
358
+		if (! empty($invoice_logo_url)) {
359
+			$image_size         = getimagesize($invoice_logo_url);
360
+			$invoice_logo_image =
361
+				'<img class="logo screen" src="' . $invoice_logo_url . '" ' . $image_size[3] . ' alt="logo" /> ';
362
+		} else {
363
+			$invoice_logo_image = '';
364
+		}
365
+		$SearchValues     = [
366
+			"[organization]",
367
+			"[registration_code]",
368
+			"[transaction_id]",
369
+			"[name]",
370
+			"[base_url]",
371
+			"[download_link]",
372
+			"[invoice_logo_image]",
373
+			"[street]",
374
+			"[city]",
375
+			"[state]",
376
+			"[zip]",
377
+			"[email]",
378
+			"[vat]",
379
+			"[registration_date]",
380
+			"[instructions]",
381
+		];
382
+		$primary_attendee = $this->transaction->primary_registration()->attendee();
383
+		$org_state        = EE_Registry::instance()->load_model('State')->get_one_by_ID($EE->CFG->organization->STA_ID);
384
+		if ($org_state) {
385
+			$org_state_name = $org_state->name();
386
+		} else {
387
+			$org_state_name = '';
388
+		}
389
+		$ReplaceValues = [
390
+			$EE->CFG->organization->get_pretty('name'),
391
+			$this->registration->reg_code(),
392
+			$this->transaction->ID(),
393
+			$primary_attendee->full_name(),
394
+			(is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice'))
395
+				? EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/'
396
+				: EE_GATEWAYS_URL . 'Invoice/lib/templates/',
397
+			$this->registration->invoice_url(),
398
+			// home_url() . '/?download_invoice=true&amp;id=' . $this->registration->reg_url_link(),
399
+			$invoice_logo_image,
400
+			empty($EE->CFG->organization->address_2)
401
+				? $EE->CFG->organization->get_pretty('address_1')
402
+				: $EE->CFG->organization->get_pretty('address_1') . '<br>' . $EE->CFG->organization->get_pretty(
403
+					'address_2'
404
+				),
405
+			$EE->CFG->organization->get_pretty('city'),
406
+			$org_state_name,
407
+			$EE->CFG->organization->get_pretty('zip'),
408
+			$EE->CFG->organization->get_pretty('email'),
409
+			$EE->CFG->organization->vat,
410
+			$this->registration->get_i18n_datetime('REG_date', get_option('date_format')),
411
+			$this->invoice_payment_method->get_extra_meta('pdf_instructions', true),
412
+		];
413
+
414
+		return str_replace($SearchValues, $ReplaceValues, $content);
415
+	}
416
+
417
+
418
+	public function espressoLoadData($items)
419
+	{
420
+		$lines = $items;
421
+		$data  = [];
422
+		foreach ($lines as $line) {
423
+			$data[] = explode(';', chop($line));
424
+		}
425
+
426
+		return $data;
427
+	}
428
+
429
+
430
+	public function espressoInvoiceTotals($text, $total_cost)
431
+	{
432
+		$html = '';
433
+		if ($total_cost < 0) {
434
+			$total_cost = (-1) * $total_cost;
435
+		}
436
+		$find    = [' '];
437
+		$replace = ['-'];
438
+		$row_id  = strtolower(str_replace($find, $replace, $text));
439
+		$html    .= '<tr id="' . $row_id . '-tr"><td colspan="4">&nbsp;</td>';
440
+		$html    .= '<td class="item_r">' . $text . '</td>';
441
+		$html    .= '<td class="item_r">' . $total_cost . '</td>';
442
+		$html    .= '</tr>';
443
+		return $html;
444
+	}
445 445
 }
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -97,8 +97,8 @@  discard block
 block discarded – undo
97 97
             7 => "union.css",
98 98
         ];
99 99
         // Get the CSS file
100
-        if (isset($themes[ $theme_requested ])) {
101
-            $template_args['invoice_css'] = $themes[ $theme_requested ];
100
+        if (isset($themes[$theme_requested])) {
101
+            $template_args['invoice_css'] = $themes[$theme_requested];
102 102
         } else {
103 103
             $template_args['invoice_css'] = $this->invoice_payment_method->get_extra_meta(
104 104
                 'legacy_invoice_css',
@@ -107,10 +107,10 @@  discard block
 block discarded – undo
107 107
             );
108 108
         }
109 109
 
110
-        if (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) {
111
-            $template_args['base_url'] = EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/';
110
+        if (is_dir(EVENT_ESPRESSO_GATEWAY_DIR.'/invoice')) {
111
+            $template_args['base_url'] = EVENT_ESPRESSO_GATEWAY_URL.'Invoice/lib/templates/';
112 112
         } else {
113
-            $template_args['base_url'] = EE_GATEWAYS . '/Invoice/lib/templates/';
113
+            $template_args['base_url'] = EE_GATEWAYS.'/Invoice/lib/templates/';
114 114
         }
115 115
         $primary_attendee = $this->transaction->primary_registration()->attendee();
116 116
 
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
             //      $this->session_data['cart']['REG']['sub_total']
170 170
             // );
171 171
             $tax_items = $this->transaction->tax_items();
172
-            if (! empty($tax_items)) {
172
+            if ( ! empty($tax_items)) {
173 173
                 foreach ($tax_items as $tax) {
174 174
                     $template_args['net_total'] .= $this->espressoInvoiceTotals($tax->name(), $tax->total());
175 175
                 }
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
                 html_entity_decode($this->invoice_payment_method->get_extra_meta('pdf_instructions', true), ENT_QUOTES)
191 191
             )
192 192
         );
193
-        $template_args['shameless_plug']                = apply_filters(
193
+        $template_args['shameless_plug'] = apply_filters(
194 194
             'FHEE_Invoice__send_invoice__shameless_plug',
195 195
             true
196 196
         );
@@ -207,16 +207,16 @@  discard block
 block discarded – undo
207 207
                 $line_items_for_this_event                = EEM_Line_Item::instance()->get_all(
208 208
                     [['Ticket.Datetime.EVT_ID' => $event_id, 'TXN_ID' => $this->transaction->ID()]]
209 209
                 );
210
-                $ticket_line_items_per_event[ $event_id ] = $line_items_for_this_event;
210
+                $ticket_line_items_per_event[$event_id] = $line_items_for_this_event;
211 211
                 foreach ($line_items_for_this_event as $line_item_id => $line_item) {
212
-                    if (! $line_item instanceof EE_Line_Item) {
212
+                    if ( ! $line_item instanceof EE_Line_Item) {
213 213
                         continue;
214 214
                     }
215 215
                     $ticket                                       = $line_item->ticket();
216 216
                     $registrations_for_this_ticket                = EEM_Registration::instance()->get_all(
217 217
                         [['TKT_ID' => $ticket->ID(), 'TXN_ID' => $this->transaction->ID()]]
218 218
                     );
219
-                    $registrations_per_line_item[ $line_item_id ] = $registrations_for_this_ticket;
219
+                    $registrations_per_line_item[$line_item_id] = $registrations_for_this_ticket;
220 220
                 }
221 221
                 if ($event instanceof EE_Event) {
222 222
                     $venues_for_events += $event->venues();
@@ -248,24 +248,24 @@  discard block
 block discarded – undo
248 248
         // Get the HTML as an object
249 249
         $templates_relative_path = 'modules/gateways/Invoice/lib/templates/';
250 250
         $template_header         = EEH_Template::locate_template(
251
-            $templates_relative_path . 'invoice_header.template.php',
251
+            $templates_relative_path.'invoice_header.template.php',
252 252
             $template_args
253 253
         );
254 254
         if ($receipt) {
255 255
             $template_body = EEH_Template::locate_template(
256
-                $templates_relative_path . 'receipt_body.template.php',
256
+                $templates_relative_path.'receipt_body.template.php',
257 257
                 $template_args
258 258
             );
259 259
         } else {
260 260
             $template_body = EEH_Template::locate_template(
261
-                $templates_relative_path . 'invoice_body.template.php',
261
+                $templates_relative_path.'invoice_body.template.php',
262 262
                 $template_args
263 263
             );
264 264
         }
265 265
 
266 266
 
267 267
         $template_footer = EEH_Template::locate_template(
268
-            $templates_relative_path . 'invoice_footer.template.php',
268
+            $templates_relative_path.'invoice_footer.template.php',
269 269
             $template_args
270 270
         );
271 271
 
@@ -282,18 +282,18 @@  discard block
 block discarded – undo
282 282
             echo wp_kses($content, AllowedTags::getWithFormTags());
283 283
             exit(0);
284 284
         }
285
-        $invoice_name = $template_args['organization'] . ' ';
285
+        $invoice_name = $template_args['organization'].' ';
286 286
         $invoice_name .= esc_html__('Invoice #', 'event_espresso');
287 287
         $invoice_name .= $template_args['registration_code'];
288
-        $invoice_name .= esc_html__(' for ', 'event_espresso') . $template_args['name'];
288
+        $invoice_name .= esc_html__(' for ', 'event_espresso').$template_args['name'];
289 289
         $invoice_name = str_replace(' ', '_', $invoice_name);
290 290
         // Create the PDF
291 291
         if ($request->requestParamIsSet('html')) {
292 292
             echo wp_kses($content, AllowedTags::getWithFormTags());
293 293
         } else {
294 294
             // only load dompdf if nobody else has yet...
295
-            if (! class_exists('Dompdf\Dompdf')) {
296
-                require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php');
295
+            if ( ! class_exists('Dompdf\Dompdf')) {
296
+                require_once(EE_THIRD_PARTY.'dompdf/src/Autoloader.php');
297 297
                 Dompdf\Autoloader::register();
298 298
             }
299 299
             $options = new Dompdf\Options();
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
             $dompdf = new Dompdf\Dompdf($options);
307 307
             $dompdf->loadHtml($content);
308 308
             $dompdf->render();
309
-            $dompdf->stream($invoice_name . ".pdf", ['Attachment' => $download]);
309
+            $dompdf->stream($invoice_name.".pdf", ['Attachment' => $download]);
310 310
         }
311 311
         exit(0);
312 312
     }
@@ -355,14 +355,14 @@  discard block
 block discarded – undo
355 355
             true,
356 356
             $EE->CFG->organization->logo_url
357 357
         );
358
-        if (! empty($invoice_logo_url)) {
358
+        if ( ! empty($invoice_logo_url)) {
359 359
             $image_size         = getimagesize($invoice_logo_url);
360 360
             $invoice_logo_image =
361
-                '<img class="logo screen" src="' . $invoice_logo_url . '" ' . $image_size[3] . ' alt="logo" /> ';
361
+                '<img class="logo screen" src="'.$invoice_logo_url.'" '.$image_size[3].' alt="logo" /> ';
362 362
         } else {
363 363
             $invoice_logo_image = '';
364 364
         }
365
-        $SearchValues     = [
365
+        $SearchValues = [
366 366
             "[organization]",
367 367
             "[registration_code]",
368 368
             "[transaction_id]",
@@ -391,15 +391,15 @@  discard block
 block discarded – undo
391 391
             $this->registration->reg_code(),
392 392
             $this->transaction->ID(),
393 393
             $primary_attendee->full_name(),
394
-            (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice'))
394
+            (is_dir(EVENT_ESPRESSO_GATEWAY_DIR.'/invoice'))
395 395
                 ? EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/'
396
-                : EE_GATEWAYS_URL . 'Invoice/lib/templates/',
396
+                : EE_GATEWAYS_URL.'Invoice/lib/templates/',
397 397
             $this->registration->invoice_url(),
398 398
             // home_url() . '/?download_invoice=true&amp;id=' . $this->registration->reg_url_link(),
399 399
             $invoice_logo_image,
400 400
             empty($EE->CFG->organization->address_2)
401 401
                 ? $EE->CFG->organization->get_pretty('address_1')
402
-                : $EE->CFG->organization->get_pretty('address_1') . '<br>' . $EE->CFG->organization->get_pretty(
402
+                : $EE->CFG->organization->get_pretty('address_1').'<br>'.$EE->CFG->organization->get_pretty(
403 403
                     'address_2'
404 404
                 ),
405 405
             $EE->CFG->organization->get_pretty('city'),
@@ -436,9 +436,9 @@  discard block
 block discarded – undo
436 436
         $find    = [' '];
437 437
         $replace = ['-'];
438 438
         $row_id  = strtolower(str_replace($find, $replace, $text));
439
-        $html    .= '<tr id="' . $row_id . '-tr"><td colspan="4">&nbsp;</td>';
440
-        $html    .= '<td class="item_r">' . $text . '</td>';
441
-        $html    .= '<td class="item_r">' . $total_cost . '</td>';
439
+        $html    .= '<tr id="'.$row_id.'-tr"><td colspan="4">&nbsp;</td>';
440
+        $html    .= '<td class="item_r">'.$text.'</td>';
441
+        $html    .= '<td class="item_r">'.$total_cost.'</td>';
442 442
         $html    .= '</tr>';
443 443
         return $html;
444 444
     }
Please login to merge, or discard this patch.
modules/ticket_selector/templates/simple_ticket_selector.template.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 if ($ticket instanceof EE_Ticket) {
28 28
     do_action('AHEE__ticket_selector_chart__template__before_ticket_selector', $event);
29 29
     $ticket_description .= ! empty($ticket_description)
30
-        ? '<br />' . $ticket_status_display
30
+        ? '<br />'.$ticket_status_display
31 31
         : $ticket_status_display;
32 32
     if (strpos($ticket_description, '<div') === false) {
33 33
         $ticket_description = "<p>{$ticket_description}</p>";
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 <div id="no-tkt-slctr-ticket-dv-<?php echo esc_attr($EVT_ID); ?>" class="no-tkt-slctr-ticket-dv">
37 37
     <div class="no-tkt-slctr-ticket-content-dv">
38 38
         <h5><?php echo esc_html($ticket->name()); ?></h5>
39
-        <?php if (! empty($ticket_description)) { ?>
39
+        <?php if ( ! empty($ticket_description)) { ?>
40 40
             <?php echo wp_kses($ticket_description, AllowedTags::getAllowedTags()); ?>
41 41
         <?php } ?>
42 42
     </div><!-- .no-tkt-slctr-ticket-content-dv -->
Please login to merge, or discard this patch.
modules/ticket_selector/templates/ticket_details.template.php 2 patches
Indentation   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -21,28 +21,28 @@  discard block
 block discarded – undo
21 21
 use EventEspresso\modules\ticket_selector\TicketDetails;
22 22
 
23 23
 $event_date_label = apply_filters(
24
-    'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date',
25
-    esc_html__('Event Date ', 'event_espresso')
24
+	'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date',
25
+	esc_html__('Event Date ', 'event_espresso')
26 26
 );
27 27
 
28 28
 $sold_label = apply_filters(
29
-    'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold',
30
-    esc_html__('Sold', 'event_espresso')
29
+	'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold',
30
+	esc_html__('Sold', 'event_espresso')
31 31
 );
32 32
 
33 33
 $remaining_label = apply_filters(
34
-    'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left',
35
-    esc_html__('Remaining', 'event_espresso')
34
+	'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left',
35
+	esc_html__('Remaining', 'event_espresso')
36 36
 );
37 37
 
38 38
 $total_sold_label = apply_filters(
39
-    'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold',
40
-    esc_html__('Total Sold', 'event_espresso')
39
+	'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold',
40
+	esc_html__('Total Sold', 'event_espresso')
41 41
 );
42 42
 
43 43
 $spaces_left_label = apply_filters(
44
-    'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left',
45
-    esc_html__('Total Spaces Left', 'event_espresso')
44
+	'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left',
45
+	esc_html__('Total Spaces Left', 'event_espresso')
46 46
 );
47 47
 
48 48
 ?>
@@ -56,32 +56,32 @@  discard block
 block discarded – undo
56 56
                     <p><?php echo wp_kses($ticket->description(), AllowedTags::getAllowedTags()); ?></p>
57 57
 
58 58
                     <?php
59
-                    do_action(
60
-                        'AHEE__ticket_selector_chart_template__ticket_details__after_description',
61
-                        $ticket,
62
-                        $ticket_price,
63
-                        $display_ticket_price
64
-                    );
65
-                    ?>
59
+					do_action(
60
+						'AHEE__ticket_selector_chart_template__ticket_details__after_description',
61
+						$ticket,
62
+						$ticket_price,
63
+						$display_ticket_price
64
+					);
65
+					?>
66 66
                     <section class="tckt-slctr-tkt-sale-dates-sctn">
67 67
                         <h5>
68 68
                             <?php echo apply_filters(
69
-                                'FHEE__ticket_selector_chart_template__ticket_details_sales_date_heading',
70
-                                esc_html__('Sale Dates', 'event_espresso')
71
-                            ); ?>
69
+								'FHEE__ticket_selector_chart_template__ticket_details_sales_date_heading',
70
+								esc_html__('Sale Dates', 'event_espresso')
71
+							); ?>
72 72
                         </h5>
73 73
                         <span class="drk-grey-text small-text no-bold"> -
74 74
                             <?php echo apply_filters(
75
-                                'FHEE__ticket_selector_chart_template__ticket_details_dates_available_message',
76
-                                esc_html__('The dates when this option is available for purchase.', 'event_espresso')
77
-                            ); ?>
75
+								'FHEE__ticket_selector_chart_template__ticket_details_dates_available_message',
76
+								esc_html__('The dates when this option is available for purchase.', 'event_espresso')
77
+							); ?>
78 78
                         </span>
79 79
                         <br />
80 80
                         <span class="ticket-details-label-spn drk-grey-text">
81 81
                             <?php echo apply_filters(
82
-                                'FHEE__ticket_selector_chart_template__ticket_details_goes_on_sale',
83
-                                esc_html__('Goes On Sale:', 'event_espresso')
84
-                            ); ?>
82
+								'FHEE__ticket_selector_chart_template__ticket_details_goes_on_sale',
83
+								esc_html__('Goes On Sale:', 'event_espresso')
84
+							); ?>
85 85
                         </span>
86 86
                         <span class="dashicons dashicons-calendar"></span>
87 87
                         <?php echo esc_html($ticket->get_i18n_datetime('TKT_start_date', $date_format)) . ' &nbsp; '; ?>
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
                         <br />
91 91
                         <span class="ticket-details-label-spn drk-grey-text">
92 92
                             <?php echo apply_filters(
93
-                                'FHEE__ticket_selector_chart_template__ticket_details_sales_end',
94
-                                esc_html__('Sales End:', 'event_espresso')
95
-                            ); ?>
93
+								'FHEE__ticket_selector_chart_template__ticket_details_sales_end',
94
+								esc_html__('Sales End:', 'event_espresso')
95
+							); ?>
96 96
                         </span>
97 97
                         <span class="dashicons dashicons-calendar"></span>
98 98
                         <?php echo esc_html($ticket->get_i18n_datetime('TKT_end_date', $date_format)) . ' &nbsp; '; ?>
@@ -108,53 +108,53 @@  discard block
 block discarded – undo
108 108
                         <section class="tckt-slctr-tkt-quantities-sctn">
109 109
                             <h5>
110 110
                                 <?php echo apply_filters(
111
-                                    'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_heading',
112
-                                    esc_html__('Purchasable Quantities', 'event_espresso')
113
-                                ); ?>
111
+									'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_heading',
112
+									esc_html__('Purchasable Quantities', 'event_espresso')
113
+								); ?>
114 114
                             </h5>
115 115
                             <span class="drk-grey-text small-text no-bold"> -
116 116
                                 <?php echo apply_filters(
117
-                                    'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_message',
118
-                                    esc_html__(
119
-                                        'The number of tickets that can be purchased per transaction (if available).',
120
-                                        'event_espresso'
121
-                                    )
122
-                                ); ?>
117
+									'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_message',
118
+									esc_html__(
119
+										'The number of tickets that can be purchased per transaction (if available).',
120
+										'event_espresso'
121
+									)
122
+								); ?>
123 123
                             </span>
124 124
                             <br />
125 125
                             <span class="ticket-details-label-spn drk-grey-text">
126 126
                                 <?php echo apply_filters(
127
-                                    'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty',
128
-                                    esc_html__('Minimum Qty:', 'event_espresso')
129
-                                ); ?>
127
+									'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty',
128
+									esc_html__('Minimum Qty:', 'event_espresso')
129
+								); ?>
130 130
                             </span>
131 131
                             <?php
132
-                            echo ($ticket->min() > 0 ? $ticket->min() : 0);
132
+							echo ($ticket->min() > 0 ? $ticket->min() : 0);
133 133
 
134
-                            if ($ticket->min() > $remaining) {
135
-                                ?> &nbsp;
134
+							if ($ticket->min() > $remaining) {
135
+								?> &nbsp;
136 136
                                 <span class="important-notice small-text">
137 137
                                 <?php echo apply_filters(
138
-                                    'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty_message',
139
-                                    esc_html__(
140
-                                        'The Minimum Quantity purchasable for this ticket exceeds the number of spaces remaining',
141
-                                        'event_espresso'
142
-                                    )
143
-                                ); ?>
138
+									'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty_message',
139
+									esc_html__(
140
+										'The Minimum Quantity purchasable for this ticket exceeds the number of spaces remaining',
141
+										'event_espresso'
142
+									)
143
+								); ?>
144 144
                                 </span>
145 145
                             <?php } ?>
146 146
                             <br />
147 147
                             <?php // $max = min( $max, $max_atndz );?>
148 148
                             <span class="ticket-details-label-spn drk-grey-text">
149 149
                                 <?php echo apply_filters(
150
-                                    'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_max_qty',
151
-                                    esc_html__('Maximum Qty:', 'event_espresso')
152
-                                ); ?>
150
+									'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_max_qty',
151
+									esc_html__('Maximum Qty:', 'event_espresso')
152
+								); ?>
153 153
                             </span>
154 154
                             <?php echo ($ticket->max() === EE_INF
155
-                                ? esc_html__('no limit', 'event_espresso')
156
-                                : max($ticket->max(), 1));
157
-                            ?>
155
+								? esc_html__('no limit', 'event_espresso')
156
+								: max($ticket->max(), 1));
157
+							?>
158 158
                             <br />
159 159
                         </section>
160 160
                         <br />
@@ -164,31 +164,31 @@  discard block
 block discarded – undo
164 164
                         <section class="tckt-slctr-tkt-uses-sctn">
165 165
                             <h5>
166 166
                                 <?php echo apply_filters(
167
-                                    'FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_heading',
168
-                                    esc_html__('Event Date Ticket Uses', 'event_espresso')
169
-                                ); ?>
167
+									'FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_heading',
168
+									esc_html__('Event Date Ticket Uses', 'event_espresso')
169
+								); ?>
170 170
                             </h5>
171 171
                             <span class="drk-grey-text small-text no-bold"> -
172 172
                                 <?php echo apply_filters(
173
-                                    'FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_message',
174
-                                    sprintf(
175
-                                        esc_html__(
176
-                                            'The number of separate event datetimes (see table below) that this ticket can be used to gain admittance to.%1$s%2$sAdmission is always one person per ticket.%3$s',
177
-                                            'event_espresso'
178
-                                        ),
179
-                                        '<br/>',
180
-                                        '<strong>',
181
-                                        '</strong>'
182
-                                    )
183
-                                );
184
-                                ?>
173
+									'FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_message',
174
+									sprintf(
175
+										esc_html__(
176
+											'The number of separate event datetimes (see table below) that this ticket can be used to gain admittance to.%1$s%2$sAdmission is always one person per ticket.%3$s',
177
+											'event_espresso'
178
+										),
179
+										'<br/>',
180
+										'<strong>',
181
+										'</strong>'
182
+									)
183
+								);
184
+								?>
185 185
                             </span>
186 186
                             <br />
187 187
                             <span class="ticket-details-label-spn drk-grey-text">
188 188
                                 <?php echo apply_filters(
189
-                                    'FHEE__ticket_selector_chart_template__ticket_details_event_date_number_datetimes',
190
-                                    esc_html__('# Datetimes:', 'event_espresso')
191
-                                ); ?>
189
+									'FHEE__ticket_selector_chart_template__ticket_details_event_date_number_datetimes',
190
+									esc_html__('# Datetimes:', 'event_espresso')
191
+								); ?>
192 192
                             </span>
193 193
                             <?php echo wp_kses($ticket->uses(), AllowedTags::getAllowedTags()); ?>
194 194
                             <br />
@@ -196,24 +196,24 @@  discard block
 block discarded – undo
196 196
                     <?php } ?>
197 197
 
198 198
                     <?php
199
-                    $datetimes          = $ticket->datetimes_ordered($event_is_expired, false);
200
-                    $chart_column_width = $show_ticket_sale_columns ? ' ee-fourth-width' : ' ee-half-width';
201
-                    if (! empty($datetimes)) { ?>
199
+					$datetimes          = $ticket->datetimes_ordered($event_is_expired, false);
200
+					$chart_column_width = $show_ticket_sale_columns ? ' ee-fourth-width' : ' ee-half-width';
201
+					if (! empty($datetimes)) { ?>
202 202
                         <section class="tckt-slctr-tkt-datetimes-sctn">
203 203
                             <h5>
204 204
                                 <?php echo apply_filters(
205
-                                    'FHEE__ticket_selector_chart_template__ticket_details_event_access_heading',
206
-                                    esc_html__('Access', 'event_espresso')
207
-                                ); ?>
205
+									'FHEE__ticket_selector_chart_template__ticket_details_event_access_heading',
206
+									esc_html__('Access', 'event_espresso')
207
+								); ?>
208 208
                             </h5>
209 209
                             <span class="drk-grey-text small-text no-bold"> -
210 210
                                 <?php echo apply_filters(
211
-                                    'FHEE__ticket_selector_chart_template__ticket_details_event_access_message',
212
-                                    esc_html__(
213
-                                        'This option allows access to the following dates and times.',
214
-                                        'event_espresso'
215
-                                    )
216
-                                ); ?>
211
+									'FHEE__ticket_selector_chart_template__ticket_details_event_access_message',
212
+									esc_html__(
213
+										'This option allows access to the following dates and times.',
214
+										'event_espresso'
215
+									)
216
+								); ?>
217 217
                             </span>
218 218
                         <div class="tckt-slctr-tkt-details-tbl-wrap-dv">
219 219
                             <table class="tckt-slctr-tkt-details-tbl">
@@ -223,9 +223,9 @@  discard block
 block discarded – undo
223 223
                                             <span class="dashicons dashicons-calendar"></span>
224 224
                                             <span class="small-text">
225 225
                                             <?php echo apply_filters(
226
-                                                'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date',
227
-                                                esc_html__('Date ', 'event_espresso')
228
-                                            ); ?>
226
+												'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date',
227
+												esc_html__('Date ', 'event_espresso')
228
+											); ?>
229 229
                                         </span>
230 230
                                         </th>
231 231
                                         <th class="tckt-slctr-tkt-details-time-th <?php echo esc_attr($chart_column_width); ?>">
@@ -238,33 +238,33 @@  discard block
 block discarded – undo
238 238
                                         <th class="tckt-slctr-tkt-details-this-ticket-sold-th ee-fourth-width cntr">
239 239
                                             <span class="smaller-text">
240 240
                                                 <?php echo apply_filters(
241
-                                                    'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold',
242
-                                                    sprintf(esc_html__('Sold', 'event_espresso'), '<br/>')
243
-                                                ); ?>
241
+													'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold',
242
+													sprintf(esc_html__('Sold', 'event_espresso'), '<br/>')
243
+												); ?>
244 244
                                             </span>
245 245
                                         </th>
246 246
                                         <th class="tckt-slctr-tkt-details-this-ticket-left-th ee-fourth-width cntr">
247 247
                                             <span class="smaller-text">
248 248
                                                 <?php echo apply_filters(
249
-                                                    'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left',
250
-                                                    sprintf(esc_html__('Remaining', 'event_espresso'), '<br/>')
251
-                                                ); ?>
249
+													'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left',
250
+													sprintf(esc_html__('Remaining', 'event_espresso'), '<br/>')
251
+												); ?>
252 252
                                             </span>
253 253
                                         </th>
254 254
                                         <th class="tckt-slctr-tkt-details-total-tickets-sold-th ee-fourth-width cntr">
255 255
                                             <span class="smaller-text">
256 256
                                                 <?php echo apply_filters(
257
-                                                    'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold',
258
-                                                    sprintf(esc_html__('Total%sSold', 'event_espresso'), '<br/>')
259
-                                                ); ?>
257
+													'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold',
258
+													sprintf(esc_html__('Total%sSold', 'event_espresso'), '<br/>')
259
+												); ?>
260 260
                                             </span>
261 261
                                         </th>
262 262
                                         <th class="tckt-slctr-tkt-details-total-tickets-left-th ee-fourth-width cntr">
263 263
                                             <span class="smaller-text">
264 264
                                                 <?php echo apply_filters(
265
-                                                    'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left',
266
-                                                    sprintf(esc_html__('Total Spaces%sLeft', 'event_espresso'), '<br/>')
267
-                                                ); ?>
265
+													'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left',
266
+													sprintf(esc_html__('Total Spaces%sLeft', 'event_espresso'), '<br/>')
267
+												); ?>
268 268
                                             </span>
269 269
                                         </th>
270 270
                                         <?php endif; // end $show_ticket_sale_columns conditional ?>
@@ -272,25 +272,25 @@  discard block
 block discarded – undo
272 272
                                 </thead>
273 273
                                 <tbody>
274 274
                                 <?php foreach ($datetimes as $datetime) {
275
-                                    if ($datetime instanceof EE_Datetime) { ?>
275
+									if ($datetime instanceof EE_Datetime) { ?>
276 276
                                     <tr>
277 277
                                         <td data-th="<?php echo esc_attr($event_date_label); ?>" class="small-text">
278 278
                                             <?php $datetime_name = $datetime->name(); ?>
279 279
                                             <?php echo ! empty($datetime_name)
280
-                                            ? '<b>' . esc_html($datetime_name) . '</b><br/>'
281
-                                            : ''; ?>
280
+											? '<b>' . esc_html($datetime_name) . '</b><br/>'
281
+											: ''; ?>
282 282
                                             <?php echo esc_html($datetime->date_range(
283
-                                                $date_format,
284
-                                                esc_html__(' to  ', 'event_espresso')
285
-                                            )); ?>
283
+												$date_format,
284
+												esc_html__(' to  ', 'event_espresso')
285
+											)); ?>
286 286
                                         </td>
287 287
                                         <td data-th="<?php esc_html_e('Time ', 'event_espresso'); ?>"
288 288
                                             class="cntr small-text"
289 289
                                         >
290 290
                                             <?php echo esc_html($datetime->time_range(
291
-                                                $time_format,
292
-                                                esc_html__(' to  ', 'event_espresso')
293
-                                            )); ?>
291
+												$time_format,
292
+												esc_html__(' to  ', 'event_espresso')
293
+											)); ?>
294 294
                                         </td>
295 295
                                         <?php if ($show_ticket_sale_columns) : ?>
296 296
                                         <td data-th="<?php echo esc_attr($sold_label); ?>" class="cntr small-text">
@@ -298,25 +298,25 @@  discard block
 block discarded – undo
298 298
                                         </td>
299 299
                                         <td data-th="<?php echo esc_attr($remaining_label); ?>" class="cntr small-text">
300 300
                                             <?php echo ($remaining === EE_INF
301
-                                                ? '<span class="smaller-text">'
302
-                                                  . esc_html__('unlimited ', 'event_espresso')
303
-                                                  . '</span>'
304
-                                                : $remaining); ?>
301
+												? '<span class="smaller-text">'
302
+												  . esc_html__('unlimited ', 'event_espresso')
303
+												  . '</span>'
304
+												: $remaining); ?>
305 305
                                         </td>
306 306
                                         <td data-th="<?php echo esc_attr($total_sold_label); ?>" class="cntr small-text">
307 307
                                             <?php echo esc_html($datetime->sold()); ?>
308 308
                                         </td>
309 309
                                             <?php $tkts_left = $datetime->sold_out()
310
-                                                ? '<span class="sold-out smaller-text">'
311
-                                                  . esc_html__('Sold&nbsp;Out', 'event_espresso')
312
-                                                  . '</span>'
313
-                                                : $datetime->spaces_remaining(); ?>
310
+												? '<span class="sold-out smaller-text">'
311
+												  . esc_html__('Sold&nbsp;Out', 'event_espresso')
312
+												  . '</span>'
313
+												: $datetime->spaces_remaining(); ?>
314 314
                                         <td data-th="<?php echo esc_attr($spaces_left_label); ?>" class="cntr small-text">
315 315
                                             <?php echo ($tkts_left === EE_INF
316
-                                                ? '<span class="smaller-text">'
317
-                                                  . esc_html__('unlimited ', 'event_espresso')
318
-                                                  . '</span>'
319
-                                                : $tkts_left); ?>
316
+												? '<span class="smaller-text">'
317
+												  . esc_html__('unlimited ', 'event_espresso')
318
+												  . '</span>'
319
+												: $tkts_left); ?>
320 320
                                         </td>
321 321
                                         <?php endif; // end $show_ticket_sale_columns conditional ?>
322 322
                                     </tr>
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
                             ); ?>
85 85
                         </span>
86 86
                         <span class="dashicons dashicons-calendar"></span>
87
-                        <?php echo esc_html($ticket->get_i18n_datetime('TKT_start_date', $date_format)) . ' &nbsp; '; ?>
87
+                        <?php echo esc_html($ticket->get_i18n_datetime('TKT_start_date', $date_format)).' &nbsp; '; ?>
88 88
                         <span class="dashicons dashicons-clock"></span>
89 89
                         <?php echo esc_html($ticket->get_i18n_datetime('TKT_start_date', $time_format)); ?>
90 90
                         <br />
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
                             ); ?>
96 96
                         </span>
97 97
                         <span class="dashicons dashicons-calendar"></span>
98
-                        <?php echo esc_html($ticket->get_i18n_datetime('TKT_end_date', $date_format)) . ' &nbsp; '; ?>
98
+                        <?php echo esc_html($ticket->get_i18n_datetime('TKT_end_date', $date_format)).' &nbsp; '; ?>
99 99
                         <span class="dashicons dashicons-clock"></span>
100 100
                         <?php echo esc_html($ticket->get_i18n_datetime('TKT_end_date', $time_format)); ?>
101 101
                         <br />
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
                         <br />
161 161
                     <?php } ?>
162 162
 
163
-                    <?php if ((! defined('EE_DECAF') || EE_DECAF !== true) && $ticket->uses() !== EE_INF) { ?>
163
+                    <?php if (( ! defined('EE_DECAF') || EE_DECAF !== true) && $ticket->uses() !== EE_INF) { ?>
164 164
                         <section class="tckt-slctr-tkt-uses-sctn">
165 165
                             <h5>
166 166
                                 <?php echo apply_filters(
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
                     <?php
199 199
                     $datetimes          = $ticket->datetimes_ordered($event_is_expired, false);
200 200
                     $chart_column_width = $show_ticket_sale_columns ? ' ee-fourth-width' : ' ee-half-width';
201
-                    if (! empty($datetimes)) { ?>
201
+                    if ( ! empty($datetimes)) { ?>
202 202
                         <section class="tckt-slctr-tkt-datetimes-sctn">
203 203
                             <h5>
204 204
                                 <?php echo apply_filters(
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
                                         <td data-th="<?php echo esc_attr($event_date_label); ?>" class="small-text">
278 278
                                             <?php $datetime_name = $datetime->name(); ?>
279 279
                                             <?php echo ! empty($datetime_name)
280
-                                            ? '<b>' . esc_html($datetime_name) . '</b><br/>'
280
+                                            ? '<b>'.esc_html($datetime_name).'</b><br/>'
281 281
                                             : ''; ?>
282 282
                                             <?php echo esc_html($datetime->date_range(
283 283
                                                 $date_format,
@@ -334,4 +334,4 @@  discard block
 block discarded – undo
334 334
             </div>
335 335
         </td>
336 336
     </tr>
337
-<?php endif;  // end template_settings->show_ticket_details check
337
+<?php endif; // end template_settings->show_ticket_details check
Please login to merge, or discard this patch.
modules/bot_trap/EED_Bot_Trap.module.php 2 patches
Indentation   +276 added lines, -276 removed lines patch added patch discarded remove patch
@@ -18,305 +18,305 @@
 block discarded – undo
18 18
 class EED_Bot_Trap extends EED_Module
19 19
 {
20 20
 
21
-    /**
22
-     * @return EED_Module|EED_Bot_Trap
23
-     * @throws EE_Error
24
-     * @throws ReflectionException
25
-     */
26
-    public static function instance()
27
-    {
28
-        return parent::get_instance(__CLASS__);
29
-    }
21
+	/**
22
+	 * @return EED_Module|EED_Bot_Trap
23
+	 * @throws EE_Error
24
+	 * @throws ReflectionException
25
+	 */
26
+	public static function instance()
27
+	{
28
+		return parent::get_instance(__CLASS__);
29
+	}
30 30
 
31 31
 
32
-    /**
33
-     * set_hooks - for hooking into EE Core, other modules, etc
34
-     *
35
-     * @return void
36
-     */
37
-    public static function set_hooks()
38
-    {
39
-        if (
40
-            apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) &&
41
-            EE_Registry::instance()->CFG->registration->use_bot_trap
42
-        ) {
43
-            EED_Bot_Trap::set_trap();
44
-            // redirect bots to bogus success page
45
-            EE_Config::register_route(
46
-                'ticket_selection_received',
47
-                'EED_Bot_Trap',
48
-                'display_bot_trap_success'
49
-            );
50
-        }
51
-    }
32
+	/**
33
+	 * set_hooks - for hooking into EE Core, other modules, etc
34
+	 *
35
+	 * @return void
36
+	 */
37
+	public static function set_hooks()
38
+	{
39
+		if (
40
+			apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) &&
41
+			EE_Registry::instance()->CFG->registration->use_bot_trap
42
+		) {
43
+			EED_Bot_Trap::set_trap();
44
+			// redirect bots to bogus success page
45
+			EE_Config::register_route(
46
+				'ticket_selection_received',
47
+				'EED_Bot_Trap',
48
+				'display_bot_trap_success'
49
+			);
50
+		}
51
+	}
52 52
 
53 53
 
54
-    /**
55
-     * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
56
-     *
57
-     * @return void
58
-     */
59
-    public static function set_trap()
60
-    {
61
-        define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . '/');
62
-        add_action(
63
-            'AHEE__ticket_selector_chart__template__after_ticket_selector',
64
-            array('EED_Bot_Trap', 'generate_bot_trap'),
65
-            10,
66
-            2
67
-        );
68
-        add_action(
69
-            'EED_Ticket_Selector__process_ticket_selections__before',
70
-            array('EED_Bot_Trap', 'process_bot_trap'),
71
-            1,
72
-            2
73
-        );
74
-    }
54
+	/**
55
+	 * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
56
+	 *
57
+	 * @return void
58
+	 */
59
+	public static function set_trap()
60
+	{
61
+		define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . '/');
62
+		add_action(
63
+			'AHEE__ticket_selector_chart__template__after_ticket_selector',
64
+			array('EED_Bot_Trap', 'generate_bot_trap'),
65
+			10,
66
+			2
67
+		);
68
+		add_action(
69
+			'EED_Ticket_Selector__process_ticket_selections__before',
70
+			array('EED_Bot_Trap', 'process_bot_trap'),
71
+			1,
72
+			2
73
+		);
74
+	}
75 75
 
76 76
 
77
-    /**
78
-     * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
79
-     *
80
-     * @return void
81
-     */
82
-    public static function set_hooks_admin()
83
-    {
84
-        if (
85
-            EED_Bot_Trap::getRequest()->isAjax()
86
-            && apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true)
87
-            && EE_Registry::instance()->CFG->registration->use_bot_trap
88
-        ) {
89
-            EED_Bot_Trap::set_trap();
90
-        }
91
-        add_action(
92
-            'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
93
-            array('EED_Bot_Trap', 'bot_trap_settings_form'),
94
-            5
95
-        );
96
-        add_filter(
97
-            'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration',
98
-            array('EED_Bot_Trap', 'update_bot_trap_settings_form'),
99
-            10,
100
-            1
101
-        );
102
-    }
77
+	/**
78
+	 * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
79
+	 *
80
+	 * @return void
81
+	 */
82
+	public static function set_hooks_admin()
83
+	{
84
+		if (
85
+			EED_Bot_Trap::getRequest()->isAjax()
86
+			&& apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true)
87
+			&& EE_Registry::instance()->CFG->registration->use_bot_trap
88
+		) {
89
+			EED_Bot_Trap::set_trap();
90
+		}
91
+		add_action(
92
+			'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
93
+			array('EED_Bot_Trap', 'bot_trap_settings_form'),
94
+			5
95
+		);
96
+		add_filter(
97
+			'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration',
98
+			array('EED_Bot_Trap', 'update_bot_trap_settings_form'),
99
+			10,
100
+			1
101
+		);
102
+	}
103 103
 
104 104
 
105
-    /**
106
-     * run - initial module setup
107
-     *
108
-     * @param WP $WP
109
-     * @return void
110
-     */
111
-    public function run($WP)
112
-    {
113
-    }
105
+	/**
106
+	 * run - initial module setup
107
+	 *
108
+	 * @param WP $WP
109
+	 * @return void
110
+	 */
111
+	public function run($WP)
112
+	{
113
+	}
114 114
 
115 115
 
116
-    /**
117
-     * generate_bot_trap
118
-     *
119
-     * @return void
120
-     * @throws RuntimeException
121
-     */
122
-    public static function generate_bot_trap()
123
-    {
124
-        $time = microtime(true);
125
-        $html = '<div class="tkt-slctr-request-processor-dv" style="float:left; margin:0 0 0 -999em; height: 0;">';
126
-        $html .= '<label for="tkt-slctr-request-processor-email-' . esc_attr($time) . '">' . esc_html__('please do not enter anything in this input', 'event_espresso') . '</label>';
127
-        $html .= '<input type="email" id="tkt-slctr-request-processor-email-';
128
-        $html .= esc_attr($time) . '" name="tkt-slctr-request-processor-email" value=""/>';
129
-        $html .= '</div>';
130
-        echo wp_kses($html, AllowedTags::getWithFormTags());
131
-    }
116
+	/**
117
+	 * generate_bot_trap
118
+	 *
119
+	 * @return void
120
+	 * @throws RuntimeException
121
+	 */
122
+	public static function generate_bot_trap()
123
+	{
124
+		$time = microtime(true);
125
+		$html = '<div class="tkt-slctr-request-processor-dv" style="float:left; margin:0 0 0 -999em; height: 0;">';
126
+		$html .= '<label for="tkt-slctr-request-processor-email-' . esc_attr($time) . '">' . esc_html__('please do not enter anything in this input', 'event_espresso') . '</label>';
127
+		$html .= '<input type="email" id="tkt-slctr-request-processor-email-';
128
+		$html .= esc_attr($time) . '" name="tkt-slctr-request-processor-email" value=""/>';
129
+		$html .= '</div>';
130
+		echo wp_kses($html, AllowedTags::getWithFormTags());
131
+	}
132 132
 
133 133
 
134
-    /**
135
-     * process_bot_trap
136
-     *
137
-     * @param array|string $triggered_trap_callback Callback that will be executed for handling the
138
-     *                                              response if the bot trap is triggered.
139
-     *                                              It should receive one argument: a boolean indicating
140
-     *                                              whether the trap was triggered by suspicious timing or not.
141
-     * @throws RuntimeException
142
-     */
143
-    public static function process_bot_trap($triggered_trap_callback = array())
144
-    {
145
-        // what's your email address Mr. Bot ?
146
-        $empty_trap = EED_Bot_Trap::getRequest()->getRequestParam('tkt-slctr-request-processor-email') === '';
147
-        // are we human ?
148
-        if ($empty_trap) {
149
-            do_action('AHEE__EED_Bot_Trap__process_bot_trap__trap_not_triggered');
150
-            return;
151
-        }
152
-        // check the given callback is valid first before executing
153
-        if (! is_callable($triggered_trap_callback)) {
154
-            // invalid callback so lets just sub in our default.
155
-            $triggered_trap_callback = array('EED_Bot_Trap', 'triggered_trap_response');
156
-        }
157
-        call_user_func($triggered_trap_callback);
158
-    }
134
+	/**
135
+	 * process_bot_trap
136
+	 *
137
+	 * @param array|string $triggered_trap_callback Callback that will be executed for handling the
138
+	 *                                              response if the bot trap is triggered.
139
+	 *                                              It should receive one argument: a boolean indicating
140
+	 *                                              whether the trap was triggered by suspicious timing or not.
141
+	 * @throws RuntimeException
142
+	 */
143
+	public static function process_bot_trap($triggered_trap_callback = array())
144
+	{
145
+		// what's your email address Mr. Bot ?
146
+		$empty_trap = EED_Bot_Trap::getRequest()->getRequestParam('tkt-slctr-request-processor-email') === '';
147
+		// are we human ?
148
+		if ($empty_trap) {
149
+			do_action('AHEE__EED_Bot_Trap__process_bot_trap__trap_not_triggered');
150
+			return;
151
+		}
152
+		// check the given callback is valid first before executing
153
+		if (! is_callable($triggered_trap_callback)) {
154
+			// invalid callback so lets just sub in our default.
155
+			$triggered_trap_callback = array('EED_Bot_Trap', 'triggered_trap_response');
156
+		}
157
+		call_user_func($triggered_trap_callback);
158
+	}
159 159
 
160 160
 
161
-    /**
162
-     * This is the default callback executed by EED_Bot_Trap::process_bot_trap that handles the response.
163
-     *
164
-     * @throws InvalidArgumentException
165
-     * @throws InvalidDataTypeException
166
-     * @throws InvalidInterfaceException
167
-     */
168
-    public static function triggered_trap_response()
169
-    {
170
-        // UH OH...
171
-        $redirect_url = apply_filters(
172
-            'FHEE__EED_Bot_Trap__process_bot_trap__redirect_url',
173
-            add_query_arg(
174
-                array('ee' => 'ticket_selection_received'),
175
-                EE_Registry::instance()->CFG->core->reg_page_url()
176
-            )
177
-        );
178
-        // if AJAX, return the redirect URL
179
-        if (EED_Bot_Trap::getRequest()->isAjax()) {
180
-            echo wp_json_encode(
181
-                array_merge(
182
-                    EE_Error::get_notices(false),
183
-                    array(
184
-                        'redirect_url' => $redirect_url,
185
-                    )
186
-                )
187
-            );
188
-            exit();
189
-        }
190
-        wp_safe_redirect($redirect_url);
191
-        exit();
192
-    }
161
+	/**
162
+	 * This is the default callback executed by EED_Bot_Trap::process_bot_trap that handles the response.
163
+	 *
164
+	 * @throws InvalidArgumentException
165
+	 * @throws InvalidDataTypeException
166
+	 * @throws InvalidInterfaceException
167
+	 */
168
+	public static function triggered_trap_response()
169
+	{
170
+		// UH OH...
171
+		$redirect_url = apply_filters(
172
+			'FHEE__EED_Bot_Trap__process_bot_trap__redirect_url',
173
+			add_query_arg(
174
+				array('ee' => 'ticket_selection_received'),
175
+				EE_Registry::instance()->CFG->core->reg_page_url()
176
+			)
177
+		);
178
+		// if AJAX, return the redirect URL
179
+		if (EED_Bot_Trap::getRequest()->isAjax()) {
180
+			echo wp_json_encode(
181
+				array_merge(
182
+					EE_Error::get_notices(false),
183
+					array(
184
+						'redirect_url' => $redirect_url,
185
+					)
186
+				)
187
+			);
188
+			exit();
189
+		}
190
+		wp_safe_redirect($redirect_url);
191
+		exit();
192
+	}
193 193
 
194 194
 
195
-    /**
196
-     * display_bot_trap_success
197
-     * shows a "success" screen to bots so that they (ie: the ppl managing them)
198
-     * think the form was submitted successfully
199
-     *
200
-     * @return void
201
-     */
202
-    public static function display_bot_trap_success()
203
-    {
204
-        add_filter('FHEE__EED_Single_Page_Checkout__run', '__return_false');
205
-        $bot_notice = EED_Bot_Trap::getRequest()->getRequestParam(
206
-            'ee-notice',
207
-            esc_html__(
208
-                'Thank you so much. Your ticket selections have been received for consideration.',
209
-                'event_espresso'
210
-            )
211
-        );
212
-        EED_Bot_Trap::getResponse()->addOutput(EEH_HTML::div($bot_notice, '', 'ee-attention'));
213
-    }
195
+	/**
196
+	 * display_bot_trap_success
197
+	 * shows a "success" screen to bots so that they (ie: the ppl managing them)
198
+	 * think the form was submitted successfully
199
+	 *
200
+	 * @return void
201
+	 */
202
+	public static function display_bot_trap_success()
203
+	{
204
+		add_filter('FHEE__EED_Single_Page_Checkout__run', '__return_false');
205
+		$bot_notice = EED_Bot_Trap::getRequest()->getRequestParam(
206
+			'ee-notice',
207
+			esc_html__(
208
+				'Thank you so much. Your ticket selections have been received for consideration.',
209
+				'event_espresso'
210
+			)
211
+		);
212
+		EED_Bot_Trap::getResponse()->addOutput(EEH_HTML::div($bot_notice, '', 'ee-attention'));
213
+	}
214 214
 
215 215
 
216 216
 
217
-    /***********************************    ADMIN    **********************************/
217
+	/***********************************    ADMIN    **********************************/
218 218
 
219 219
 
220
-    /**
221
-     * bot_trap_settings_form
222
-     *
223
-     * @return void
224
-     * @throws EE_Error
225
-     * @throws InvalidArgumentException
226
-     * @throws InvalidDataTypeException
227
-     * @throws InvalidInterfaceException
228
-     */
229
-    public static function bot_trap_settings_form()
230
-    {
231
-        EED_Bot_Trap::_bot_trap_settings_form()->enqueue_js();
232
-        echo EED_Bot_Trap::_bot_trap_settings_form()->get_html(); // already escaped
233
-    }
220
+	/**
221
+	 * bot_trap_settings_form
222
+	 *
223
+	 * @return void
224
+	 * @throws EE_Error
225
+	 * @throws InvalidArgumentException
226
+	 * @throws InvalidDataTypeException
227
+	 * @throws InvalidInterfaceException
228
+	 */
229
+	public static function bot_trap_settings_form()
230
+	{
231
+		EED_Bot_Trap::_bot_trap_settings_form()->enqueue_js();
232
+		echo EED_Bot_Trap::_bot_trap_settings_form()->get_html(); // already escaped
233
+	}
234 234
 
235 235
 
236
-    /**
237
-     * _bot_trap_settings_form
238
-     *
239
-     * @return EE_Form_Section_Proper
240
-     * @throws EE_Error
241
-     */
242
-    protected static function _bot_trap_settings_form()
243
-    {
244
-        return new EE_Form_Section_Proper(
245
-            array(
246
-                'name'            => 'bot_trap_settings',
247
-                'html_id'         => 'bot_trap_settings',
248
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
249
-                'subsections'     => array(
250
-                    'bot_trap_hdr' => new EE_Form_Section_HTML(
251
-                        EEH_HTML::h2(esc_html__('Bot Trap Settings', 'event_espresso'))
252
-                    ),
253
-                    'use_bot_trap' => new EE_Yes_No_Input(
254
-                        array(
255
-                            'html_label_text' => esc_html__('Enable Bot Trap', 'event_espresso'),
256
-                            'html_help_text'  => esc_html__(
257
-                                'The Event Espresso Bot Trap will insert a fake input into your Ticket Selector forms that is hidden from regular site visitors, but visible to spam bots. Because the input asks for an email address, it is irresistible to spam bots who will of course enter text into it. Since regular site visitors can not see this input, any value detected during form submission means a bot has been detected, which will then be blocked from submitting the form.',
258
-                                'event_espresso'
259
-                            ),
260
-                            'default'         => EE_Registry::instance()->CFG->registration->use_bot_trap !== null
261
-                                ? EE_Registry::instance()->CFG->registration->use_bot_trap
262
-                                : true,
263
-                            'required'        => false,
264
-                        )
265
-                    ),
266
-                ),
267
-            )
268
-        );
269
-    }
236
+	/**
237
+	 * _bot_trap_settings_form
238
+	 *
239
+	 * @return EE_Form_Section_Proper
240
+	 * @throws EE_Error
241
+	 */
242
+	protected static function _bot_trap_settings_form()
243
+	{
244
+		return new EE_Form_Section_Proper(
245
+			array(
246
+				'name'            => 'bot_trap_settings',
247
+				'html_id'         => 'bot_trap_settings',
248
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
249
+				'subsections'     => array(
250
+					'bot_trap_hdr' => new EE_Form_Section_HTML(
251
+						EEH_HTML::h2(esc_html__('Bot Trap Settings', 'event_espresso'))
252
+					),
253
+					'use_bot_trap' => new EE_Yes_No_Input(
254
+						array(
255
+							'html_label_text' => esc_html__('Enable Bot Trap', 'event_espresso'),
256
+							'html_help_text'  => esc_html__(
257
+								'The Event Espresso Bot Trap will insert a fake input into your Ticket Selector forms that is hidden from regular site visitors, but visible to spam bots. Because the input asks for an email address, it is irresistible to spam bots who will of course enter text into it. Since regular site visitors can not see this input, any value detected during form submission means a bot has been detected, which will then be blocked from submitting the form.',
258
+								'event_espresso'
259
+							),
260
+							'default'         => EE_Registry::instance()->CFG->registration->use_bot_trap !== null
261
+								? EE_Registry::instance()->CFG->registration->use_bot_trap
262
+								: true,
263
+							'required'        => false,
264
+						)
265
+					),
266
+				),
267
+			)
268
+		);
269
+	}
270 270
 
271 271
 
272
-    /**
273
-     * update_bot_trap_settings_form
274
-     *
275
-     * @param EE_Registration_Config $EE_Registration_Config
276
-     * @return EE_Registration_Config
277
-     * @throws EE_Error
278
-     * @throws InvalidArgumentException
279
-     * @throws ReflectionException
280
-     * @throws InvalidDataTypeException
281
-     * @throws InvalidInterfaceException
282
-     */
283
-    public static function update_bot_trap_settings_form(EE_Registration_Config $EE_Registration_Config)
284
-    {
285
-        try {
286
-            $bot_trap_settings_form = EED_Bot_Trap::_bot_trap_settings_form();
287
-            // if not displaying a form, then check for form submission
288
-            if ($bot_trap_settings_form->was_submitted()) {
289
-                // capture form data
290
-                $bot_trap_settings_form->receive_form_submission();
291
-                // validate form data
292
-                if ($bot_trap_settings_form->is_valid()) {
293
-                    // grab validated data from form
294
-                    $valid_data = $bot_trap_settings_form->valid_data();
295
-                    if (isset($valid_data['use_bot_trap'])) {
296
-                        $EE_Registration_Config->use_bot_trap = $valid_data['use_bot_trap'];
297
-                    } else {
298
-                        EE_Error::add_error(
299
-                            esc_html__(
300
-                                'Invalid or missing Bot Trap settings. Please refresh the form and try again.',
301
-                                'event_espresso'
302
-                            ),
303
-                            __FILE__,
304
-                            __FUNCTION__,
305
-                            __LINE__
306
-                        );
307
-                    }
308
-                } elseif ($bot_trap_settings_form->submission_error_message() !== '') {
309
-                    EE_Error::add_error(
310
-                        $bot_trap_settings_form->submission_error_message(),
311
-                        __FILE__,
312
-                        __FUNCTION__,
313
-                        __LINE__
314
-                    );
315
-                }
316
-            }
317
-        } catch (EE_Error $e) {
318
-            $e->get_error();
319
-        }
320
-        return $EE_Registration_Config;
321
-    }
272
+	/**
273
+	 * update_bot_trap_settings_form
274
+	 *
275
+	 * @param EE_Registration_Config $EE_Registration_Config
276
+	 * @return EE_Registration_Config
277
+	 * @throws EE_Error
278
+	 * @throws InvalidArgumentException
279
+	 * @throws ReflectionException
280
+	 * @throws InvalidDataTypeException
281
+	 * @throws InvalidInterfaceException
282
+	 */
283
+	public static function update_bot_trap_settings_form(EE_Registration_Config $EE_Registration_Config)
284
+	{
285
+		try {
286
+			$bot_trap_settings_form = EED_Bot_Trap::_bot_trap_settings_form();
287
+			// if not displaying a form, then check for form submission
288
+			if ($bot_trap_settings_form->was_submitted()) {
289
+				// capture form data
290
+				$bot_trap_settings_form->receive_form_submission();
291
+				// validate form data
292
+				if ($bot_trap_settings_form->is_valid()) {
293
+					// grab validated data from form
294
+					$valid_data = $bot_trap_settings_form->valid_data();
295
+					if (isset($valid_data['use_bot_trap'])) {
296
+						$EE_Registration_Config->use_bot_trap = $valid_data['use_bot_trap'];
297
+					} else {
298
+						EE_Error::add_error(
299
+							esc_html__(
300
+								'Invalid or missing Bot Trap settings. Please refresh the form and try again.',
301
+								'event_espresso'
302
+							),
303
+							__FILE__,
304
+							__FUNCTION__,
305
+							__LINE__
306
+						);
307
+					}
308
+				} elseif ($bot_trap_settings_form->submission_error_message() !== '') {
309
+					EE_Error::add_error(
310
+						$bot_trap_settings_form->submission_error_message(),
311
+						__FILE__,
312
+						__FUNCTION__,
313
+						__LINE__
314
+					);
315
+				}
316
+			}
317
+		} catch (EE_Error $e) {
318
+			$e->get_error();
319
+		}
320
+		return $EE_Registration_Config;
321
+	}
322 322
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
      */
59 59
     public static function set_trap()
60 60
     {
61
-        define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . '/');
61
+        define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__).'/');
62 62
         add_action(
63 63
             'AHEE__ticket_selector_chart__template__after_ticket_selector',
64 64
             array('EED_Bot_Trap', 'generate_bot_trap'),
@@ -123,9 +123,9 @@  discard block
 block discarded – undo
123 123
     {
124 124
         $time = microtime(true);
125 125
         $html = '<div class="tkt-slctr-request-processor-dv" style="float:left; margin:0 0 0 -999em; height: 0;">';
126
-        $html .= '<label for="tkt-slctr-request-processor-email-' . esc_attr($time) . '">' . esc_html__('please do not enter anything in this input', 'event_espresso') . '</label>';
126
+        $html .= '<label for="tkt-slctr-request-processor-email-'.esc_attr($time).'">'.esc_html__('please do not enter anything in this input', 'event_espresso').'</label>';
127 127
         $html .= '<input type="email" id="tkt-slctr-request-processor-email-';
128
-        $html .= esc_attr($time) . '" name="tkt-slctr-request-processor-email" value=""/>';
128
+        $html .= esc_attr($time).'" name="tkt-slctr-request-processor-email" value=""/>';
129 129
         $html .= '</div>';
130 130
         echo wp_kses($html, AllowedTags::getWithFormTags());
131 131
     }
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
             return;
151 151
         }
152 152
         // check the given callback is valid first before executing
153
-        if (! is_callable($triggered_trap_callback)) {
153
+        if ( ! is_callable($triggered_trap_callback)) {
154 154
             // invalid callback so lets just sub in our default.
155 155
             $triggered_trap_callback = array('EED_Bot_Trap', 'triggered_trap_response');
156 156
         }
Please login to merge, or discard this patch.