Completed
Branch BUG-10851-events-shortcode (6a6497)
by
unknown
44:06 queued 32:50
created
core/libraries/messages/messenger/EE_Email_messenger.class.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -456,7 +456,7 @@
 block discarded – undo
456 456
      * be empty
457 457
      *
458 458
      * @since 4.3.1
459
-     * @return array
459
+     * @return string[]
460 460
      */
461 461
     private function _parse_from()
462 462
     {
Please login to merge, or discard this patch.
Indentation   +543 added lines, -543 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if (! defined('EVENT_ESPRESSO_VERSION')) {
4
-    exit('NO direct script access allowed');
4
+	exit('NO direct script access allowed');
5 5
 }
6 6
 
7 7
 /**
@@ -28,548 +28,548 @@  discard block
 block discarded – undo
28 28
 class EE_Email_messenger extends EE_messenger
29 29
 {
30 30
 
31
-    /**
32
-     * The following are the properties that email requires for the message going out.
33
-     */
34
-    protected $_to;
35
-    protected $_from;
36
-    protected $_subject;
37
-    protected $_content;
38
-
39
-
40
-    /**
41
-     * constructor
42
-     *
43
-     * @access public
44
-     */
45
-    public function __construct()
46
-    {
47
-        //set name and description properties
48
-        $this->name                = 'email';
49
-        $this->description         = __('This messenger delivers messages via email using the built-in <code>wp_mail</code> function included with WordPress',
50
-            'event_espresso');
51
-        $this->label               = array(
52
-            'singular' => __('email', 'event_espresso'),
53
-            'plural'   => __('emails', 'event_espresso'),
54
-        );
55
-        $this->activate_on_install = true;
56
-
57
-        //we're using defaults so let's call parent constructor that will take care of setting up all the other properties
58
-        parent::__construct();
59
-    }
60
-
61
-
62
-    /**
63
-     * see abstract declaration in parent class for details.
64
-     */
65
-    protected function _set_admin_pages()
66
-    {
67
-        $this->admin_registered_pages = array(
68
-            'events_edit' => true,
69
-        );
70
-    }
71
-
72
-
73
-    /**
74
-     * see abstract declaration in parent class for details
75
-     */
76
-    protected function _set_valid_shortcodes()
77
-    {
78
-        //remember by leaving the other fields not set, those fields will inherit the valid shortcodes from the message type.
79
-        $this->_valid_shortcodes = array(
80
-            'to'   => array('email', 'event_author', 'primary_registration_details', 'recipient_details'),
81
-            'from' => array('email', 'event_author', 'primary_registration_details', 'recipient_details'),
82
-        );
83
-    }
84
-
85
-
86
-    /**
87
-     * see abstract declaration in parent class for details
88
-     *
89
-     * @access protected
90
-     * @return void
91
-     */
92
-    protected function _set_validator_config()
93
-    {
94
-        $valid_shortcodes = $this->get_valid_shortcodes();
95
-
96
-        $this->_validator_config = array(
97
-            'to'            => array(
98
-                'shortcodes' => $valid_shortcodes['to'],
99
-                'type'       => 'email',
100
-            ),
101
-            'from'          => array(
102
-                'shortcodes' => $valid_shortcodes['from'],
103
-                'type'       => 'email',
104
-            ),
105
-            'subject'       => array(
106
-                'shortcodes' => array(
107
-                    'organization',
108
-                    'primary_registration_details',
109
-                    'event_author',
110
-                    'primary_registration_details',
111
-                    'recipient_details',
112
-                ),
113
-            ),
114
-            'content'       => array(
115
-                'shortcodes' => array(
116
-                    'event_list',
117
-                    'attendee_list',
118
-                    'ticket_list',
119
-                    'organization',
120
-                    'primary_registration_details',
121
-                    'primary_registration_list',
122
-                    'event_author',
123
-                    'recipient_details',
124
-                    'recipient_list',
125
-                    'transaction',
126
-                    'messenger',
127
-                ),
128
-            ),
129
-            'attendee_list' => array(
130
-                'shortcodes' => array('attendee', 'event_list', 'ticket_list'),
131
-                'required'   => array('[ATTENDEE_LIST]'),
132
-            ),
133
-            'event_list'    => array(
134
-                'shortcodes' => array(
135
-                    'event',
136
-                    'attendee_list',
137
-                    'ticket_list',
138
-                    'venue',
139
-                    'datetime_list',
140
-                    'attendee',
141
-                    'primary_registration_details',
142
-                    'primary_registration_list',
143
-                    'event_author',
144
-                    'recipient_details',
145
-                    'recipient_list',
146
-                ),
147
-                'required'   => array('[EVENT_LIST]'),
148
-            ),
149
-            'ticket_list'   => array(
150
-                'shortcodes' => array(
151
-                    'event_list',
152
-                    'attendee_list',
153
-                    'ticket',
154
-                    'datetime_list',
155
-                    'primary_registration_details',
156
-                    'recipient_details',
157
-                ),
158
-                'required'   => array('[TICKET_LIST]'),
159
-            ),
160
-            'datetime_list' => array(
161
-                'shortcodes' => array('datetime'),
162
-                'required'   => array('[DATETIME_LIST]'),
163
-            ),
164
-        );
165
-    }
166
-
167
-
168
-    /**
169
-     * @see   parent EE_messenger class for docs
170
-     * @since 4.5.0
171
-     */
172
-    public function do_secondary_messenger_hooks($sending_messenger_name)
173
-    {
174
-        if ($sending_messenger_name = 'html') {
175
-            add_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10, 8);
176
-        }
177
-    }
178
-
179
-
180
-    public function add_email_css(
181
-        $variation_path,
182
-        $messenger,
183
-        $message_type,
184
-        $type,
185
-        $variation,
186
-        $file_extension,
187
-        $url,
188
-        EE_Messages_Template_Pack $template_pack
189
-    ) {
190
-        //prevent recursion on this callback.
191
-        remove_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10);
192
-        $variation = $this->get_variation($template_pack, $message_type, $url, 'main', $variation, false);
193
-
194
-        add_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10, 8);
195
-        return $variation;
196
-    }
197
-
198
-
199
-    /**
200
-     * See parent for details
201
-     *
202
-     * @access protected
203
-     * @return void
204
-     */
205
-    protected function _set_test_settings_fields()
206
-    {
207
-        $this->_test_settings_fields = array(
208
-            'to'      => array(
209
-                'input'      => 'text',
210
-                'label'      => __('Send a test email to', 'event_espresso'),
211
-                'type'       => 'email',
212
-                'required'   => true,
213
-                'validation' => true,
214
-                'css_class'  => 'large-text',
215
-                'format'     => '%s',
216
-                'default'    => get_bloginfo('admin_email'),
217
-            ),
218
-            'subject' => array(
219
-                'input'      => 'hidden',
220
-                'label'      => '',
221
-                'type'       => 'string',
222
-                'required'   => false,
223
-                'validation' => false,
224
-                'format'     => '%s',
225
-                'value'      => sprintf(__('Test email sent from %s', 'event_espresso'), get_bloginfo('name')),
226
-                'default'    => '',
227
-                'css_class'  => '',
228
-            ),
229
-        );
230
-    }
231
-
232
-
233
-    /**
234
-     * _set_template_fields
235
-     * This sets up the fields that a messenger requires for the message to go out.
236
-     *
237
-     * @access  protected
238
-     * @return void
239
-     */
240
-    protected function _set_template_fields()
241
-    {
242
-        // any extra template fields that are NOT used by the messenger but will get used by a messenger field for shortcode replacement get added to the 'extra' key in an associated array indexed by the messenger field they relate to.  This is important for the Messages_admin to know what fields to display to the user.  Also, notice that the "values" are equal to the field type that messages admin will use to know what kind of field to display. The values ALSO have one index labeled "shortcode".  the values in that array indicate which ACTUAL SHORTCODE (i.e. [SHORTCODE]) is required in order for this extra field to be displayed.  If the required shortcode isn't part of the shortcodes array then the field is not needed and will not be displayed/parsed.
243
-        $this->_template_fields = array(
244
-            'to'      => array(
245
-                'input'      => 'text',
246
-                'label'      => __('To', 'event_espresso'),
247
-                'type'       => 'string',
248
-                'required'   => true,
249
-                'validation' => true,
250
-                'css_class'  => 'large-text',
251
-                'format'     => '%s',
252
-            ),
253
-            'from'    => array(
254
-                'input'      => 'text',
255
-                'label'      => __('From', 'event_espresso'),
256
-                'type'       => 'string',
257
-                'required'   => true,
258
-                'validation' => true,
259
-                'css_class'  => 'large-text',
260
-                'format'     => '%s',
261
-            ),
262
-            'subject' => array(
263
-                'input'      => 'text',
264
-                'label'      => __('Subject', 'event_espresso'),
265
-                'type'       => 'string',
266
-                'required'   => true,
267
-                'validation' => true,
268
-                'css_class'  => 'large-text',
269
-                'format'     => '%s',
270
-            ),
271
-            'content' => '',
272
-            //left empty b/c it is in the "extra array" but messenger still needs needs to know this is a field.
273
-            'extra'   => array(
274
-                'content' => array(
275
-                    'main'          => array(
276
-                        'input'      => 'wp_editor',
277
-                        'label'      => __('Main Content', 'event_espresso'),
278
-                        'type'       => 'string',
279
-                        'required'   => true,
280
-                        'validation' => true,
281
-                        'format'     => '%s',
282
-                        'rows'       => '15',
283
-                    ),
284
-                    'event_list'    => array(
285
-                        'input'               => 'wp_editor',
286
-                        'label'               => '[EVENT_LIST]',
287
-                        'type'                => 'string',
288
-                        'required'            => true,
289
-                        'validation'          => true,
290
-                        'format'              => '%s',
291
-                        'rows'                => '15',
292
-                        'shortcodes_required' => array('[EVENT_LIST]'),
293
-                    ),
294
-                    'attendee_list' => array(
295
-                        'input'               => 'textarea',
296
-                        'label'               => '[ATTENDEE_LIST]',
297
-                        'type'                => 'string',
298
-                        'required'            => true,
299
-                        'validation'          => true,
300
-                        'format'              => '%s',
301
-                        'css_class'           => 'large-text',
302
-                        'rows'                => '5',
303
-                        'shortcodes_required' => array('[ATTENDEE_LIST]'),
304
-                    ),
305
-                    'ticket_list'   => array(
306
-                        'input'               => 'textarea',
307
-                        'label'               => '[TICKET_LIST]',
308
-                        'type'                => 'string',
309
-                        'required'            => true,
310
-                        'validation'          => true,
311
-                        'format'              => '%s',
312
-                        'css_class'           => 'large-text',
313
-                        'rows'                => '10',
314
-                        'shortcodes_required' => array('[TICKET_LIST]'),
315
-                    ),
316
-                    'datetime_list' => array(
317
-                        'input'               => 'textarea',
318
-                        'label'               => '[DATETIME_LIST]',
319
-                        'type'                => 'string',
320
-                        'required'            => true,
321
-                        'validation'          => true,
322
-                        'format'              => '%s',
323
-                        'css_class'           => 'large-text',
324
-                        'rows'                => '10',
325
-                        'shortcodes_required' => array('[DATETIME_LIST]'),
326
-                    ),
327
-                ),
328
-            ),
329
-        );
330
-    }
331
-
332
-
333
-    /**
334
-     * See definition of this class in parent
335
-     */
336
-    protected function _set_default_message_types()
337
-    {
338
-        $this->_default_message_types = array(
339
-            'payment',
340
-            'payment_refund',
341
-            'registration',
342
-            'not_approved_registration',
343
-            'pending_approval',
344
-        );
345
-    }
346
-
347
-
348
-    /**
349
-     * @see   definition of this class in parent
350
-     * @since 4.5.0
351
-     */
352
-    protected function _set_valid_message_types()
353
-    {
354
-        $this->_valid_message_types = array(
355
-            'payment',
356
-            'registration',
357
-            'not_approved_registration',
358
-            'declined_registration',
359
-            'cancelled_registration',
360
-            'pending_approval',
361
-            'registration_summary',
362
-            'payment_reminder',
363
-            'payment_declined',
364
-            'payment_refund',
365
-        );
366
-    }
367
-
368
-
369
-    /**
370
-     * setting up admin_settings_fields for messenger.
371
-     */
372
-    protected function _set_admin_settings_fields()
373
-    {
374
-    }
375
-
376
-    /**
377
-     * We just deliver the messages don't kill us!!
378
-     *
379
-     * @return bool | WP_Error  true if message delivered, false if it didn't deliver OR bubble up any error object if
380
-     *              present.
381
-     */
382
-    protected function _send_message()
383
-    {
384
-        $success = wp_mail(
385
-            html_entity_decode($this->_to, ENT_QUOTES, "UTF-8"),
386
-            stripslashes(html_entity_decode($this->_subject, ENT_QUOTES, "UTF-8")),
387
-            $this->_body(),
388
-            $this->_headers()
389
-        );
390
-        if (! $success) {
391
-            EE_Error::add_error(
392
-                sprintf(
393
-                    __('The email did not send successfully.%3$sThe WordPress wp_mail function is used for sending mails but does not give any useful information when an email fails to send.%3$sIt is possible the "to" address (%1$s) or "from" address (%2$s) is invalid.%3$s',
394
-                        'event_espresso'),
395
-                    $this->_to,
396
-                    $this->_from,
397
-                    '<br />'
398
-                ),
399
-                __FILE__, __FUNCTION__, __LINE__
400
-            );
401
-        }
402
-        return $success;
403
-    }
404
-
405
-
406
-    /**
407
-     * see parent for definition
408
-     *
409
-     * @return string html body of the message content and the related css.
410
-     */
411
-    protected function _preview()
412
-    {
413
-        return $this->_body(true);
414
-    }
415
-
416
-
417
-    /**
418
-     * Setup headers for email
419
-     *
420
-     * @access protected
421
-     * @return string formatted header for email
422
-     */
423
-    protected function _headers()
424
-    {
425
-        $this->_ensure_has_from_email_address();
426
-        $from    = stripslashes_deep(html_entity_decode($this->_from, ENT_QUOTES, "UTF-8"));
427
-        $headers = array(
428
-            'MIME-Version: 1.0',
429
-            'From:' . $from,
430
-            'Reply-To:' . $from,
431
-            'Content-Type:text/html; charset=utf-8',
432
-        );
433
-
434
-        //but wait!  Header's for the from is NOT reliable because some plugins don't respect From: as set in the header.
435
-        add_filter('wp_mail_from', array($this, 'set_from_address'), 100);
436
-        add_filter('wp_mail_from_name', array($this, 'set_from_name'), 100);
437
-        return apply_filters('FHEE__EE_Email_messenger___headers', $headers, $this->_incoming_message_type, $this);
438
-    }
439
-
440
-
441
-    /**
442
-     * This simply ensures that the from address is not empty.  If it is, then we use whatever is set as the site email
443
-     * address for the from address to avoid problems with sending emails.
444
-     */
445
-    protected function _ensure_has_from_email_address()
446
-    {
447
-        if (empty($this->_from)) {
448
-            $this->_from = get_bloginfo('admin_email');
449
-        }
450
-    }
451
-
452
-
453
-    /**
454
-     * This simply parses whatever is set as the $_from address and determines if it is in the format {name} <{email}>
455
-     * or just {email} and returns an array with the "from_name" and "from_email" as the values. Note from_name *MAY*
456
-     * be empty
457
-     *
458
-     * @since 4.3.1
459
-     * @return array
460
-     */
461
-    private function _parse_from()
462
-    {
463
-        if (strpos($this->_from, '<') !== false) {
464
-            $from_name = substr($this->_from, 0, strpos($this->_from, '<') - 1);
465
-            $from_name = str_replace('"', '', $from_name);
466
-            $from_name = trim($from_name);
467
-
468
-            $from_email = substr($this->_from, strpos($this->_from, '<') + 1);
469
-            $from_email = str_replace('>', '', $from_email);
470
-            $from_email = trim($from_email);
471
-        } elseif (trim($this->_from) !== '') {
472
-            $from_name  = '';
473
-            $from_email = trim($this->_from);
474
-        } else {
475
-            $from_name = $from_email = '';
476
-        }
477
-        return array($from_name, $from_email);
478
-    }
479
-
480
-
481
-    /**
482
-     * Callback for the wp_mail_from filter.
483
-     *
484
-     * @since 4.3.1
485
-     * @param string $from_email What the original from_email is.
486
-     */
487
-    public function set_from_address($from_email)
488
-    {
489
-        $parsed_from = $this->_parse_from();
490
-        //includes fallback if the parsing failed.
491
-        $from_email = is_array($parsed_from) && ! empty($parsed_from[1]) ? $parsed_from[1] : get_bloginfo('admin_email');
492
-        return $from_email;
493
-    }
494
-
495
-
496
-    /**
497
-     * Callback fro the wp_mail_from_name filter.
498
-     *
499
-     * @since 4.3.1
500
-     * @param string $from_name The original from_name.
501
-     */
502
-    public function set_from_name($from_name)
503
-    {
504
-        $parsed_from = $this->_parse_from();
505
-        if (is_array($parsed_from) && ! empty($parsed_from[0])) {
506
-            $from_name = $parsed_from[0];
507
-        }
508
-
509
-        //if from name is "WordPress" let's sub in the site name instead (more friendly!)
510
-        $from_name = $from_name == 'WordPress' ? get_bloginfo() : $from_name;
511
-
512
-        return stripslashes_deep(html_entity_decode($from_name, ENT_QUOTES, "UTF-8"));
513
-    }
514
-
515
-
516
-    /**
517
-     * setup body for email
518
-     *
519
-     * @param bool $preview will determine whether this is preview template or not.
520
-     * @return string formatted body for email.
521
-     */
522
-    protected function _body($preview = false)
523
-    {
524
-        //setup template args!
525
-        $this->_template_args = array(
526
-            'subject'   => $this->_subject,
527
-            'from'      => $this->_from,
528
-            'main_body' => wpautop(stripslashes_deep(html_entity_decode($this->_content, ENT_QUOTES, "UTF-8"))),
529
-        );
530
-        $body                 = $this->_get_main_template($preview);
531
-
532
-        /**
533
-         * This filter allows one to bypass the CSSToInlineStyles tool and leave the body untouched.
534
-         *
535
-         * @type    bool $preview Indicates whether a preview is being generated or not.
536
-         * @return  bool    true  indicates to use the inliner, false bypasses it.
537
-         */
538
-        if (apply_filters('FHEE__EE_Email_messenger__apply_CSSInliner ', true, $preview)) {
539
-
540
-            //require CssToInlineStyles library and its dependencies via composer autoloader
541
-            require_once EE_THIRD_PARTY . 'cssinliner/vendor/autoload.php';
542
-
543
-            //now if this isn't a preview, let's setup the body so it has inline styles
544
-            if (! $preview || ($preview && defined('DOING_AJAX'))) {
545
-                $style = file_get_contents($this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name,
546
-                    false, 'main', $this->_variation), true);
547
-                $CSS   = new TijsVerkoyen\CssToInlineStyles\CssToInlineStyles($body, $style);
548
-                $body  = ltrim($CSS->convert(true),
549
-                    ">\n"); //for some reason the library has a bracket and new line at the beginning.  This takes care of that.
550
-                $body  = ltrim($body, "<?"); //see https://events.codebasehq.com/projects/event-espresso/tickets/8609
551
-            }
552
-
553
-        }
554
-        return $body;
555
-    }
556
-
557
-
558
-    /**
559
-     * This just returns any existing test settings that might be saved in the database
560
-     *
561
-     * @access public
562
-     * @return array
563
-     */
564
-    public function get_existing_test_settings()
565
-    {
566
-        $settings = parent::get_existing_test_settings();
567
-        //override subject if present because we always want it to be fresh.
568
-        if (is_array($settings) && ! empty($settings['subject'])) {
569
-            $settings['subject'] = sprintf(__('Test email sent from %s', 'event_espresso'), get_bloginfo('name'));
570
-        }
571
-        return $settings;
572
-    }
31
+	/**
32
+	 * The following are the properties that email requires for the message going out.
33
+	 */
34
+	protected $_to;
35
+	protected $_from;
36
+	protected $_subject;
37
+	protected $_content;
38
+
39
+
40
+	/**
41
+	 * constructor
42
+	 *
43
+	 * @access public
44
+	 */
45
+	public function __construct()
46
+	{
47
+		//set name and description properties
48
+		$this->name                = 'email';
49
+		$this->description         = __('This messenger delivers messages via email using the built-in <code>wp_mail</code> function included with WordPress',
50
+			'event_espresso');
51
+		$this->label               = array(
52
+			'singular' => __('email', 'event_espresso'),
53
+			'plural'   => __('emails', 'event_espresso'),
54
+		);
55
+		$this->activate_on_install = true;
56
+
57
+		//we're using defaults so let's call parent constructor that will take care of setting up all the other properties
58
+		parent::__construct();
59
+	}
60
+
61
+
62
+	/**
63
+	 * see abstract declaration in parent class for details.
64
+	 */
65
+	protected function _set_admin_pages()
66
+	{
67
+		$this->admin_registered_pages = array(
68
+			'events_edit' => true,
69
+		);
70
+	}
71
+
72
+
73
+	/**
74
+	 * see abstract declaration in parent class for details
75
+	 */
76
+	protected function _set_valid_shortcodes()
77
+	{
78
+		//remember by leaving the other fields not set, those fields will inherit the valid shortcodes from the message type.
79
+		$this->_valid_shortcodes = array(
80
+			'to'   => array('email', 'event_author', 'primary_registration_details', 'recipient_details'),
81
+			'from' => array('email', 'event_author', 'primary_registration_details', 'recipient_details'),
82
+		);
83
+	}
84
+
85
+
86
+	/**
87
+	 * see abstract declaration in parent class for details
88
+	 *
89
+	 * @access protected
90
+	 * @return void
91
+	 */
92
+	protected function _set_validator_config()
93
+	{
94
+		$valid_shortcodes = $this->get_valid_shortcodes();
95
+
96
+		$this->_validator_config = array(
97
+			'to'            => array(
98
+				'shortcodes' => $valid_shortcodes['to'],
99
+				'type'       => 'email',
100
+			),
101
+			'from'          => array(
102
+				'shortcodes' => $valid_shortcodes['from'],
103
+				'type'       => 'email',
104
+			),
105
+			'subject'       => array(
106
+				'shortcodes' => array(
107
+					'organization',
108
+					'primary_registration_details',
109
+					'event_author',
110
+					'primary_registration_details',
111
+					'recipient_details',
112
+				),
113
+			),
114
+			'content'       => array(
115
+				'shortcodes' => array(
116
+					'event_list',
117
+					'attendee_list',
118
+					'ticket_list',
119
+					'organization',
120
+					'primary_registration_details',
121
+					'primary_registration_list',
122
+					'event_author',
123
+					'recipient_details',
124
+					'recipient_list',
125
+					'transaction',
126
+					'messenger',
127
+				),
128
+			),
129
+			'attendee_list' => array(
130
+				'shortcodes' => array('attendee', 'event_list', 'ticket_list'),
131
+				'required'   => array('[ATTENDEE_LIST]'),
132
+			),
133
+			'event_list'    => array(
134
+				'shortcodes' => array(
135
+					'event',
136
+					'attendee_list',
137
+					'ticket_list',
138
+					'venue',
139
+					'datetime_list',
140
+					'attendee',
141
+					'primary_registration_details',
142
+					'primary_registration_list',
143
+					'event_author',
144
+					'recipient_details',
145
+					'recipient_list',
146
+				),
147
+				'required'   => array('[EVENT_LIST]'),
148
+			),
149
+			'ticket_list'   => array(
150
+				'shortcodes' => array(
151
+					'event_list',
152
+					'attendee_list',
153
+					'ticket',
154
+					'datetime_list',
155
+					'primary_registration_details',
156
+					'recipient_details',
157
+				),
158
+				'required'   => array('[TICKET_LIST]'),
159
+			),
160
+			'datetime_list' => array(
161
+				'shortcodes' => array('datetime'),
162
+				'required'   => array('[DATETIME_LIST]'),
163
+			),
164
+		);
165
+	}
166
+
167
+
168
+	/**
169
+	 * @see   parent EE_messenger class for docs
170
+	 * @since 4.5.0
171
+	 */
172
+	public function do_secondary_messenger_hooks($sending_messenger_name)
173
+	{
174
+		if ($sending_messenger_name = 'html') {
175
+			add_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10, 8);
176
+		}
177
+	}
178
+
179
+
180
+	public function add_email_css(
181
+		$variation_path,
182
+		$messenger,
183
+		$message_type,
184
+		$type,
185
+		$variation,
186
+		$file_extension,
187
+		$url,
188
+		EE_Messages_Template_Pack $template_pack
189
+	) {
190
+		//prevent recursion on this callback.
191
+		remove_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10);
192
+		$variation = $this->get_variation($template_pack, $message_type, $url, 'main', $variation, false);
193
+
194
+		add_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10, 8);
195
+		return $variation;
196
+	}
197
+
198
+
199
+	/**
200
+	 * See parent for details
201
+	 *
202
+	 * @access protected
203
+	 * @return void
204
+	 */
205
+	protected function _set_test_settings_fields()
206
+	{
207
+		$this->_test_settings_fields = array(
208
+			'to'      => array(
209
+				'input'      => 'text',
210
+				'label'      => __('Send a test email to', 'event_espresso'),
211
+				'type'       => 'email',
212
+				'required'   => true,
213
+				'validation' => true,
214
+				'css_class'  => 'large-text',
215
+				'format'     => '%s',
216
+				'default'    => get_bloginfo('admin_email'),
217
+			),
218
+			'subject' => array(
219
+				'input'      => 'hidden',
220
+				'label'      => '',
221
+				'type'       => 'string',
222
+				'required'   => false,
223
+				'validation' => false,
224
+				'format'     => '%s',
225
+				'value'      => sprintf(__('Test email sent from %s', 'event_espresso'), get_bloginfo('name')),
226
+				'default'    => '',
227
+				'css_class'  => '',
228
+			),
229
+		);
230
+	}
231
+
232
+
233
+	/**
234
+	 * _set_template_fields
235
+	 * This sets up the fields that a messenger requires for the message to go out.
236
+	 *
237
+	 * @access  protected
238
+	 * @return void
239
+	 */
240
+	protected function _set_template_fields()
241
+	{
242
+		// any extra template fields that are NOT used by the messenger but will get used by a messenger field for shortcode replacement get added to the 'extra' key in an associated array indexed by the messenger field they relate to.  This is important for the Messages_admin to know what fields to display to the user.  Also, notice that the "values" are equal to the field type that messages admin will use to know what kind of field to display. The values ALSO have one index labeled "shortcode".  the values in that array indicate which ACTUAL SHORTCODE (i.e. [SHORTCODE]) is required in order for this extra field to be displayed.  If the required shortcode isn't part of the shortcodes array then the field is not needed and will not be displayed/parsed.
243
+		$this->_template_fields = array(
244
+			'to'      => array(
245
+				'input'      => 'text',
246
+				'label'      => __('To', 'event_espresso'),
247
+				'type'       => 'string',
248
+				'required'   => true,
249
+				'validation' => true,
250
+				'css_class'  => 'large-text',
251
+				'format'     => '%s',
252
+			),
253
+			'from'    => array(
254
+				'input'      => 'text',
255
+				'label'      => __('From', 'event_espresso'),
256
+				'type'       => 'string',
257
+				'required'   => true,
258
+				'validation' => true,
259
+				'css_class'  => 'large-text',
260
+				'format'     => '%s',
261
+			),
262
+			'subject' => array(
263
+				'input'      => 'text',
264
+				'label'      => __('Subject', 'event_espresso'),
265
+				'type'       => 'string',
266
+				'required'   => true,
267
+				'validation' => true,
268
+				'css_class'  => 'large-text',
269
+				'format'     => '%s',
270
+			),
271
+			'content' => '',
272
+			//left empty b/c it is in the "extra array" but messenger still needs needs to know this is a field.
273
+			'extra'   => array(
274
+				'content' => array(
275
+					'main'          => array(
276
+						'input'      => 'wp_editor',
277
+						'label'      => __('Main Content', 'event_espresso'),
278
+						'type'       => 'string',
279
+						'required'   => true,
280
+						'validation' => true,
281
+						'format'     => '%s',
282
+						'rows'       => '15',
283
+					),
284
+					'event_list'    => array(
285
+						'input'               => 'wp_editor',
286
+						'label'               => '[EVENT_LIST]',
287
+						'type'                => 'string',
288
+						'required'            => true,
289
+						'validation'          => true,
290
+						'format'              => '%s',
291
+						'rows'                => '15',
292
+						'shortcodes_required' => array('[EVENT_LIST]'),
293
+					),
294
+					'attendee_list' => array(
295
+						'input'               => 'textarea',
296
+						'label'               => '[ATTENDEE_LIST]',
297
+						'type'                => 'string',
298
+						'required'            => true,
299
+						'validation'          => true,
300
+						'format'              => '%s',
301
+						'css_class'           => 'large-text',
302
+						'rows'                => '5',
303
+						'shortcodes_required' => array('[ATTENDEE_LIST]'),
304
+					),
305
+					'ticket_list'   => array(
306
+						'input'               => 'textarea',
307
+						'label'               => '[TICKET_LIST]',
308
+						'type'                => 'string',
309
+						'required'            => true,
310
+						'validation'          => true,
311
+						'format'              => '%s',
312
+						'css_class'           => 'large-text',
313
+						'rows'                => '10',
314
+						'shortcodes_required' => array('[TICKET_LIST]'),
315
+					),
316
+					'datetime_list' => array(
317
+						'input'               => 'textarea',
318
+						'label'               => '[DATETIME_LIST]',
319
+						'type'                => 'string',
320
+						'required'            => true,
321
+						'validation'          => true,
322
+						'format'              => '%s',
323
+						'css_class'           => 'large-text',
324
+						'rows'                => '10',
325
+						'shortcodes_required' => array('[DATETIME_LIST]'),
326
+					),
327
+				),
328
+			),
329
+		);
330
+	}
331
+
332
+
333
+	/**
334
+	 * See definition of this class in parent
335
+	 */
336
+	protected function _set_default_message_types()
337
+	{
338
+		$this->_default_message_types = array(
339
+			'payment',
340
+			'payment_refund',
341
+			'registration',
342
+			'not_approved_registration',
343
+			'pending_approval',
344
+		);
345
+	}
346
+
347
+
348
+	/**
349
+	 * @see   definition of this class in parent
350
+	 * @since 4.5.0
351
+	 */
352
+	protected function _set_valid_message_types()
353
+	{
354
+		$this->_valid_message_types = array(
355
+			'payment',
356
+			'registration',
357
+			'not_approved_registration',
358
+			'declined_registration',
359
+			'cancelled_registration',
360
+			'pending_approval',
361
+			'registration_summary',
362
+			'payment_reminder',
363
+			'payment_declined',
364
+			'payment_refund',
365
+		);
366
+	}
367
+
368
+
369
+	/**
370
+	 * setting up admin_settings_fields for messenger.
371
+	 */
372
+	protected function _set_admin_settings_fields()
373
+	{
374
+	}
375
+
376
+	/**
377
+	 * We just deliver the messages don't kill us!!
378
+	 *
379
+	 * @return bool | WP_Error  true if message delivered, false if it didn't deliver OR bubble up any error object if
380
+	 *              present.
381
+	 */
382
+	protected function _send_message()
383
+	{
384
+		$success = wp_mail(
385
+			html_entity_decode($this->_to, ENT_QUOTES, "UTF-8"),
386
+			stripslashes(html_entity_decode($this->_subject, ENT_QUOTES, "UTF-8")),
387
+			$this->_body(),
388
+			$this->_headers()
389
+		);
390
+		if (! $success) {
391
+			EE_Error::add_error(
392
+				sprintf(
393
+					__('The email did not send successfully.%3$sThe WordPress wp_mail function is used for sending mails but does not give any useful information when an email fails to send.%3$sIt is possible the "to" address (%1$s) or "from" address (%2$s) is invalid.%3$s',
394
+						'event_espresso'),
395
+					$this->_to,
396
+					$this->_from,
397
+					'<br />'
398
+				),
399
+				__FILE__, __FUNCTION__, __LINE__
400
+			);
401
+		}
402
+		return $success;
403
+	}
404
+
405
+
406
+	/**
407
+	 * see parent for definition
408
+	 *
409
+	 * @return string html body of the message content and the related css.
410
+	 */
411
+	protected function _preview()
412
+	{
413
+		return $this->_body(true);
414
+	}
415
+
416
+
417
+	/**
418
+	 * Setup headers for email
419
+	 *
420
+	 * @access protected
421
+	 * @return string formatted header for email
422
+	 */
423
+	protected function _headers()
424
+	{
425
+		$this->_ensure_has_from_email_address();
426
+		$from    = stripslashes_deep(html_entity_decode($this->_from, ENT_QUOTES, "UTF-8"));
427
+		$headers = array(
428
+			'MIME-Version: 1.0',
429
+			'From:' . $from,
430
+			'Reply-To:' . $from,
431
+			'Content-Type:text/html; charset=utf-8',
432
+		);
433
+
434
+		//but wait!  Header's for the from is NOT reliable because some plugins don't respect From: as set in the header.
435
+		add_filter('wp_mail_from', array($this, 'set_from_address'), 100);
436
+		add_filter('wp_mail_from_name', array($this, 'set_from_name'), 100);
437
+		return apply_filters('FHEE__EE_Email_messenger___headers', $headers, $this->_incoming_message_type, $this);
438
+	}
439
+
440
+
441
+	/**
442
+	 * This simply ensures that the from address is not empty.  If it is, then we use whatever is set as the site email
443
+	 * address for the from address to avoid problems with sending emails.
444
+	 */
445
+	protected function _ensure_has_from_email_address()
446
+	{
447
+		if (empty($this->_from)) {
448
+			$this->_from = get_bloginfo('admin_email');
449
+		}
450
+	}
451
+
452
+
453
+	/**
454
+	 * This simply parses whatever is set as the $_from address and determines if it is in the format {name} <{email}>
455
+	 * or just {email} and returns an array with the "from_name" and "from_email" as the values. Note from_name *MAY*
456
+	 * be empty
457
+	 *
458
+	 * @since 4.3.1
459
+	 * @return array
460
+	 */
461
+	private function _parse_from()
462
+	{
463
+		if (strpos($this->_from, '<') !== false) {
464
+			$from_name = substr($this->_from, 0, strpos($this->_from, '<') - 1);
465
+			$from_name = str_replace('"', '', $from_name);
466
+			$from_name = trim($from_name);
467
+
468
+			$from_email = substr($this->_from, strpos($this->_from, '<') + 1);
469
+			$from_email = str_replace('>', '', $from_email);
470
+			$from_email = trim($from_email);
471
+		} elseif (trim($this->_from) !== '') {
472
+			$from_name  = '';
473
+			$from_email = trim($this->_from);
474
+		} else {
475
+			$from_name = $from_email = '';
476
+		}
477
+		return array($from_name, $from_email);
478
+	}
479
+
480
+
481
+	/**
482
+	 * Callback for the wp_mail_from filter.
483
+	 *
484
+	 * @since 4.3.1
485
+	 * @param string $from_email What the original from_email is.
486
+	 */
487
+	public function set_from_address($from_email)
488
+	{
489
+		$parsed_from = $this->_parse_from();
490
+		//includes fallback if the parsing failed.
491
+		$from_email = is_array($parsed_from) && ! empty($parsed_from[1]) ? $parsed_from[1] : get_bloginfo('admin_email');
492
+		return $from_email;
493
+	}
494
+
495
+
496
+	/**
497
+	 * Callback fro the wp_mail_from_name filter.
498
+	 *
499
+	 * @since 4.3.1
500
+	 * @param string $from_name The original from_name.
501
+	 */
502
+	public function set_from_name($from_name)
503
+	{
504
+		$parsed_from = $this->_parse_from();
505
+		if (is_array($parsed_from) && ! empty($parsed_from[0])) {
506
+			$from_name = $parsed_from[0];
507
+		}
508
+
509
+		//if from name is "WordPress" let's sub in the site name instead (more friendly!)
510
+		$from_name = $from_name == 'WordPress' ? get_bloginfo() : $from_name;
511
+
512
+		return stripslashes_deep(html_entity_decode($from_name, ENT_QUOTES, "UTF-8"));
513
+	}
514
+
515
+
516
+	/**
517
+	 * setup body for email
518
+	 *
519
+	 * @param bool $preview will determine whether this is preview template or not.
520
+	 * @return string formatted body for email.
521
+	 */
522
+	protected function _body($preview = false)
523
+	{
524
+		//setup template args!
525
+		$this->_template_args = array(
526
+			'subject'   => $this->_subject,
527
+			'from'      => $this->_from,
528
+			'main_body' => wpautop(stripslashes_deep(html_entity_decode($this->_content, ENT_QUOTES, "UTF-8"))),
529
+		);
530
+		$body                 = $this->_get_main_template($preview);
531
+
532
+		/**
533
+		 * This filter allows one to bypass the CSSToInlineStyles tool and leave the body untouched.
534
+		 *
535
+		 * @type    bool $preview Indicates whether a preview is being generated or not.
536
+		 * @return  bool    true  indicates to use the inliner, false bypasses it.
537
+		 */
538
+		if (apply_filters('FHEE__EE_Email_messenger__apply_CSSInliner ', true, $preview)) {
539
+
540
+			//require CssToInlineStyles library and its dependencies via composer autoloader
541
+			require_once EE_THIRD_PARTY . 'cssinliner/vendor/autoload.php';
542
+
543
+			//now if this isn't a preview, let's setup the body so it has inline styles
544
+			if (! $preview || ($preview && defined('DOING_AJAX'))) {
545
+				$style = file_get_contents($this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name,
546
+					false, 'main', $this->_variation), true);
547
+				$CSS   = new TijsVerkoyen\CssToInlineStyles\CssToInlineStyles($body, $style);
548
+				$body  = ltrim($CSS->convert(true),
549
+					">\n"); //for some reason the library has a bracket and new line at the beginning.  This takes care of that.
550
+				$body  = ltrim($body, "<?"); //see https://events.codebasehq.com/projects/event-espresso/tickets/8609
551
+			}
552
+
553
+		}
554
+		return $body;
555
+	}
556
+
557
+
558
+	/**
559
+	 * This just returns any existing test settings that might be saved in the database
560
+	 *
561
+	 * @access public
562
+	 * @return array
563
+	 */
564
+	public function get_existing_test_settings()
565
+	{
566
+		$settings = parent::get_existing_test_settings();
567
+		//override subject if present because we always want it to be fresh.
568
+		if (is_array($settings) && ! empty($settings['subject'])) {
569
+			$settings['subject'] = sprintf(__('Test email sent from %s', 'event_espresso'), get_bloginfo('name'));
570
+		}
571
+		return $settings;
572
+	}
573 573
 
574 574
 
575 575
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (! defined('EVENT_ESPRESSO_VERSION')) {
3
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
4 4
     exit('NO direct script access allowed');
5 5
 }
6 6
 
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
             $this->_body(),
388 388
             $this->_headers()
389 389
         );
390
-        if (! $success) {
390
+        if ( ! $success) {
391 391
             EE_Error::add_error(
392 392
                 sprintf(
393 393
                     __('The email did not send successfully.%3$sThe WordPress wp_mail function is used for sending mails but does not give any useful information when an email fails to send.%3$sIt is possible the "to" address (%1$s) or "from" address (%2$s) is invalid.%3$s',
@@ -426,8 +426,8 @@  discard block
 block discarded – undo
426 426
         $from    = stripslashes_deep(html_entity_decode($this->_from, ENT_QUOTES, "UTF-8"));
427 427
         $headers = array(
428 428
             'MIME-Version: 1.0',
429
-            'From:' . $from,
430
-            'Reply-To:' . $from,
429
+            'From:'.$from,
430
+            'Reply-To:'.$from,
431 431
             'Content-Type:text/html; charset=utf-8',
432 432
         );
433 433
 
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
             'from'      => $this->_from,
528 528
             'main_body' => wpautop(stripslashes_deep(html_entity_decode($this->_content, ENT_QUOTES, "UTF-8"))),
529 529
         );
530
-        $body                 = $this->_get_main_template($preview);
530
+        $body = $this->_get_main_template($preview);
531 531
 
532 532
         /**
533 533
          * This filter allows one to bypass the CSSToInlineStyles tool and leave the body untouched.
@@ -538,10 +538,10 @@  discard block
 block discarded – undo
538 538
         if (apply_filters('FHEE__EE_Email_messenger__apply_CSSInliner ', true, $preview)) {
539 539
 
540 540
             //require CssToInlineStyles library and its dependencies via composer autoloader
541
-            require_once EE_THIRD_PARTY . 'cssinliner/vendor/autoload.php';
541
+            require_once EE_THIRD_PARTY.'cssinliner/vendor/autoload.php';
542 542
 
543 543
             //now if this isn't a preview, let's setup the body so it has inline styles
544
-            if (! $preview || ($preview && defined('DOING_AJAX'))) {
544
+            if ( ! $preview || ($preview && defined('DOING_AJAX'))) {
545 545
                 $style = file_get_contents($this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name,
546 546
                     false, 'main', $this->_variation), true);
547 547
                 $CSS   = new TijsVerkoyen\CssToInlineStyles\CssToInlineStyles($body, $style);
Please login to merge, or discard this patch.
core/EE_Error.core.php 1 patch
Indentation   +1090 added lines, -1090 removed lines patch added patch discarded remove patch
@@ -5,8 +5,8 @@  discard block
 block discarded – undo
5 5
 // if you're a dev and want to receive all errors via email
6 6
 // add this to your wp-config.php: define( 'EE_ERROR_EMAILS', TRUE );
7 7
 if (defined('WP_DEBUG') && WP_DEBUG === true && defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS === true) {
8
-    set_error_handler(array('EE_Error', 'error_handler'));
9
-    register_shutdown_function(array('EE_Error', 'fatal_error_handler'));
8
+	set_error_handler(array('EE_Error', 'error_handler'));
9
+	register_shutdown_function(array('EE_Error', 'fatal_error_handler'));
10 10
 }
11 11
 
12 12
 
@@ -23,259 +23,259 @@  discard block
 block discarded – undo
23 23
 {
24 24
 
25 25
 
26
-    /**
27
-     *    name of the file to log exceptions to
28
-     *
29
-     * @var string
30
-     */
31
-    private static $_exception_log_file = 'espresso_error_log.txt';
32
-
33
-    /**
34
-     *    stores details for all exception
35
-     *
36
-     * @var array
37
-     */
38
-    private static $_all_exceptions = array();
39
-
40
-    /**
41
-     *    tracks number of errors
42
-     *
43
-     * @var int
44
-     */
45
-    private static $_error_count = 0;
46
-
47
-    /**
48
-     *    has shutdown action been added ?
49
-     *
50
-     * @var array $_espresso_notices
51
-     */
52
-    private static $_espresso_notices = array('success' => false, 'errors' => false, 'attention' => false);
53
-
54
-
55
-
56
-    /**
57
-     * @override default exception handling
58
-     * @param string         $message
59
-     * @param int            $code
60
-     * @param Exception|null $previous
61
-     */
62
-    public function __construct($message, $code = 0, Exception $previous = null)
63
-    {
64
-        if (version_compare(PHP_VERSION, '5.3.0', '<')) {
65
-            parent::__construct($message, $code);
66
-        } else {
67
-            parent::__construct($message, $code, $previous);
68
-        }
69
-    }
70
-
71
-
72
-
73
-    /**
74
-     *    error_handler
75
-     *
76
-     * @param $code
77
-     * @param $message
78
-     * @param $file
79
-     * @param $line
80
-     * @return void
81
-     */
82
-    public static function error_handler($code, $message, $file, $line)
83
-    {
84
-        $type = EE_Error::error_type($code);
85
-        $site = site_url();
86
-        switch ($site) {
87
-            case 'http://ee4.eventespresso.com/' :
88
-            case 'http://ee4decaf.eventespresso.com/' :
89
-            case 'http://ee4hf.eventespresso.com/' :
90
-            case 'http://ee4a.eventespresso.com/' :
91
-            case 'http://ee4ad.eventespresso.com/' :
92
-            case 'http://ee4b.eventespresso.com/' :
93
-            case 'http://ee4bd.eventespresso.com/' :
94
-            case 'http://ee4d.eventespresso.com/' :
95
-            case 'http://ee4dd.eventespresso.com/' :
96
-                $to = '[email protected]';
97
-                break;
98
-            default :
99
-                $to = get_option('admin_email');
100
-        }
101
-        $subject = $type . ' ' . $message . ' in ' . EVENT_ESPRESSO_VERSION . ' on ' . site_url();
102
-        $msg = EE_Error::_format_error($type, $message, $file, $line);
103
-        if (function_exists('wp_mail')) {
104
-            add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type'));
105
-            wp_mail($to, $subject, $msg);
106
-        }
107
-        echo '<div id="message" class="espresso-notices error"><p>';
108
-        echo $type . ': ' . $message . '<br />' . $file . ' line ' . $line;
109
-        echo '<br /></p></div>';
110
-    }
111
-
112
-
113
-
114
-    /**
115
-     * error_type
116
-     * http://www.php.net/manual/en/errorfunc.constants.php#109430
117
-     *
118
-     * @param $code
119
-     * @return string
120
-     */
121
-    public static function error_type($code)
122
-    {
123
-        switch ($code) {
124
-            case E_ERROR: // 1 //
125
-                return 'E_ERROR';
126
-            case E_WARNING: // 2 //
127
-                return 'E_WARNING';
128
-            case E_PARSE: // 4 //
129
-                return 'E_PARSE';
130
-            case E_NOTICE: // 8 //
131
-                return 'E_NOTICE';
132
-            case E_CORE_ERROR: // 16 //
133
-                return 'E_CORE_ERROR';
134
-            case E_CORE_WARNING: // 32 //
135
-                return 'E_CORE_WARNING';
136
-            case E_COMPILE_ERROR: // 64 //
137
-                return 'E_COMPILE_ERROR';
138
-            case E_COMPILE_WARNING: // 128 //
139
-                return 'E_COMPILE_WARNING';
140
-            case E_USER_ERROR: // 256 //
141
-                return 'E_USER_ERROR';
142
-            case E_USER_WARNING: // 512 //
143
-                return 'E_USER_WARNING';
144
-            case E_USER_NOTICE: // 1024 //
145
-                return 'E_USER_NOTICE';
146
-            case E_STRICT: // 2048 //
147
-                return 'E_STRICT';
148
-            case E_RECOVERABLE_ERROR: // 4096 //
149
-                return 'E_RECOVERABLE_ERROR';
150
-            case E_DEPRECATED: // 8192 //
151
-                return 'E_DEPRECATED';
152
-            case E_USER_DEPRECATED: // 16384 //
153
-                return 'E_USER_DEPRECATED';
154
-            case E_ALL: // 16384 //
155
-                return 'E_ALL';
156
-        }
157
-        return '';
158
-    }
159
-
160
-
161
-
162
-    /**
163
-     *    fatal_error_handler
164
-     *
165
-     * @return void
166
-     */
167
-    public static function fatal_error_handler()
168
-    {
169
-        $last_error = error_get_last();
170
-        if ($last_error['type'] === E_ERROR) {
171
-            EE_Error::error_handler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']);
172
-        }
173
-    }
174
-
175
-
176
-
177
-    /**
178
-     * _format_error
179
-     *
180
-     * @param $code
181
-     * @param $message
182
-     * @param $file
183
-     * @param $line
184
-     * @return string
185
-     */
186
-    private static function _format_error($code, $message, $file, $line)
187
-    {
188
-        $html = "<table cellpadding='5'><thead bgcolor='#f8f8f8'><th>Item</th><th align='left'>Details</th></thead><tbody>";
189
-        $html .= "<tr valign='top'><td><b>Code</b></td><td>$code</td></tr>";
190
-        $html .= "<tr valign='top'><td><b>Error</b></td><td>$message</td></tr>";
191
-        $html .= "<tr valign='top'><td><b>File</b></td><td>$file</td></tr>";
192
-        $html .= "<tr valign='top'><td><b>Line</b></td><td>$line</td></tr>";
193
-        $html .= '</tbody></table>';
194
-        return $html;
195
-    }
196
-
197
-
198
-
199
-    /**
200
-     * set_content_type
201
-     *
202
-     * @param $content_type
203
-     * @return string
204
-     */
205
-    public static function set_content_type($content_type)
206
-    {
207
-        return 'text/html';
208
-    }
209
-
210
-
211
-
212
-    /**
213
-     * @return void
214
-     * @throws EE_Error
215
-     * @throws ReflectionException
216
-     */
217
-    public function get_error()
218
-    {
219
-        if (apply_filters('FHEE__EE_Error__get_error__show_normal_exceptions', false)) {
220
-            throw $this;
221
-        }
222
-        // get separate user and developer messages if they exist
223
-        $msg = explode('||', $this->getMessage());
224
-        $user_msg = $msg[0];
225
-        $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0];
226
-        $msg = WP_DEBUG ? $dev_msg : $user_msg;
227
-        // add details to _all_exceptions array
228
-        $x_time = time();
229
-        self::$_all_exceptions[$x_time]['name'] = get_class($this);
230
-        self::$_all_exceptions[$x_time]['file'] = $this->getFile();
231
-        self::$_all_exceptions[$x_time]['line'] = $this->getLine();
232
-        self::$_all_exceptions[$x_time]['msg'] = $msg;
233
-        self::$_all_exceptions[$x_time]['code'] = $this->getCode();
234
-        self::$_all_exceptions[$x_time]['trace'] = $this->getTrace();
235
-        self::$_all_exceptions[$x_time]['string'] = $this->getTraceAsString();
236
-        self::$_error_count++;
237
-        //add_action( 'shutdown', array( $this, 'display_errors' ));
238
-        $this->display_errors();
239
-    }
240
-
241
-
242
-
243
-    /**
244
-     *    has_error
245
-     *
246
-     * @param bool   $check_stored
247
-     * @param string $type_to_check
248
-     * @return bool
249
-     */
250
-    public static function has_error($check_stored = false, $type_to_check = 'errors')
251
-    {
252
-        $has_error = isset(self::$_espresso_notices[$type_to_check])
253
-                     && ! empty(self::$_espresso_notices[$type_to_check])
254
-            ? true
255
-            : false;
256
-        if ($check_stored && ! $has_error) {
257
-            $notices = (array)get_option('ee_notices', array());
258
-            foreach ($notices as $type => $notice) {
259
-                if ($type === $type_to_check && $notice) {
260
-                    return true;
261
-                }
262
-            }
263
-        }
264
-        return $has_error;
265
-    }
266
-
267
-
268
-
269
-    /**
270
-     *    display_errors
271
-     *
272
-     * @echo   string
273
-     * @throws \ReflectionException
274
-     */
275
-    public function display_errors()
276
-    {
277
-        $trace_details = '';
278
-        $output = '
26
+	/**
27
+	 *    name of the file to log exceptions to
28
+	 *
29
+	 * @var string
30
+	 */
31
+	private static $_exception_log_file = 'espresso_error_log.txt';
32
+
33
+	/**
34
+	 *    stores details for all exception
35
+	 *
36
+	 * @var array
37
+	 */
38
+	private static $_all_exceptions = array();
39
+
40
+	/**
41
+	 *    tracks number of errors
42
+	 *
43
+	 * @var int
44
+	 */
45
+	private static $_error_count = 0;
46
+
47
+	/**
48
+	 *    has shutdown action been added ?
49
+	 *
50
+	 * @var array $_espresso_notices
51
+	 */
52
+	private static $_espresso_notices = array('success' => false, 'errors' => false, 'attention' => false);
53
+
54
+
55
+
56
+	/**
57
+	 * @override default exception handling
58
+	 * @param string         $message
59
+	 * @param int            $code
60
+	 * @param Exception|null $previous
61
+	 */
62
+	public function __construct($message, $code = 0, Exception $previous = null)
63
+	{
64
+		if (version_compare(PHP_VERSION, '5.3.0', '<')) {
65
+			parent::__construct($message, $code);
66
+		} else {
67
+			parent::__construct($message, $code, $previous);
68
+		}
69
+	}
70
+
71
+
72
+
73
+	/**
74
+	 *    error_handler
75
+	 *
76
+	 * @param $code
77
+	 * @param $message
78
+	 * @param $file
79
+	 * @param $line
80
+	 * @return void
81
+	 */
82
+	public static function error_handler($code, $message, $file, $line)
83
+	{
84
+		$type = EE_Error::error_type($code);
85
+		$site = site_url();
86
+		switch ($site) {
87
+			case 'http://ee4.eventespresso.com/' :
88
+			case 'http://ee4decaf.eventespresso.com/' :
89
+			case 'http://ee4hf.eventespresso.com/' :
90
+			case 'http://ee4a.eventespresso.com/' :
91
+			case 'http://ee4ad.eventespresso.com/' :
92
+			case 'http://ee4b.eventespresso.com/' :
93
+			case 'http://ee4bd.eventespresso.com/' :
94
+			case 'http://ee4d.eventespresso.com/' :
95
+			case 'http://ee4dd.eventespresso.com/' :
96
+				$to = '[email protected]';
97
+				break;
98
+			default :
99
+				$to = get_option('admin_email');
100
+		}
101
+		$subject = $type . ' ' . $message . ' in ' . EVENT_ESPRESSO_VERSION . ' on ' . site_url();
102
+		$msg = EE_Error::_format_error($type, $message, $file, $line);
103
+		if (function_exists('wp_mail')) {
104
+			add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type'));
105
+			wp_mail($to, $subject, $msg);
106
+		}
107
+		echo '<div id="message" class="espresso-notices error"><p>';
108
+		echo $type . ': ' . $message . '<br />' . $file . ' line ' . $line;
109
+		echo '<br /></p></div>';
110
+	}
111
+
112
+
113
+
114
+	/**
115
+	 * error_type
116
+	 * http://www.php.net/manual/en/errorfunc.constants.php#109430
117
+	 *
118
+	 * @param $code
119
+	 * @return string
120
+	 */
121
+	public static function error_type($code)
122
+	{
123
+		switch ($code) {
124
+			case E_ERROR: // 1 //
125
+				return 'E_ERROR';
126
+			case E_WARNING: // 2 //
127
+				return 'E_WARNING';
128
+			case E_PARSE: // 4 //
129
+				return 'E_PARSE';
130
+			case E_NOTICE: // 8 //
131
+				return 'E_NOTICE';
132
+			case E_CORE_ERROR: // 16 //
133
+				return 'E_CORE_ERROR';
134
+			case E_CORE_WARNING: // 32 //
135
+				return 'E_CORE_WARNING';
136
+			case E_COMPILE_ERROR: // 64 //
137
+				return 'E_COMPILE_ERROR';
138
+			case E_COMPILE_WARNING: // 128 //
139
+				return 'E_COMPILE_WARNING';
140
+			case E_USER_ERROR: // 256 //
141
+				return 'E_USER_ERROR';
142
+			case E_USER_WARNING: // 512 //
143
+				return 'E_USER_WARNING';
144
+			case E_USER_NOTICE: // 1024 //
145
+				return 'E_USER_NOTICE';
146
+			case E_STRICT: // 2048 //
147
+				return 'E_STRICT';
148
+			case E_RECOVERABLE_ERROR: // 4096 //
149
+				return 'E_RECOVERABLE_ERROR';
150
+			case E_DEPRECATED: // 8192 //
151
+				return 'E_DEPRECATED';
152
+			case E_USER_DEPRECATED: // 16384 //
153
+				return 'E_USER_DEPRECATED';
154
+			case E_ALL: // 16384 //
155
+				return 'E_ALL';
156
+		}
157
+		return '';
158
+	}
159
+
160
+
161
+
162
+	/**
163
+	 *    fatal_error_handler
164
+	 *
165
+	 * @return void
166
+	 */
167
+	public static function fatal_error_handler()
168
+	{
169
+		$last_error = error_get_last();
170
+		if ($last_error['type'] === E_ERROR) {
171
+			EE_Error::error_handler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']);
172
+		}
173
+	}
174
+
175
+
176
+
177
+	/**
178
+	 * _format_error
179
+	 *
180
+	 * @param $code
181
+	 * @param $message
182
+	 * @param $file
183
+	 * @param $line
184
+	 * @return string
185
+	 */
186
+	private static function _format_error($code, $message, $file, $line)
187
+	{
188
+		$html = "<table cellpadding='5'><thead bgcolor='#f8f8f8'><th>Item</th><th align='left'>Details</th></thead><tbody>";
189
+		$html .= "<tr valign='top'><td><b>Code</b></td><td>$code</td></tr>";
190
+		$html .= "<tr valign='top'><td><b>Error</b></td><td>$message</td></tr>";
191
+		$html .= "<tr valign='top'><td><b>File</b></td><td>$file</td></tr>";
192
+		$html .= "<tr valign='top'><td><b>Line</b></td><td>$line</td></tr>";
193
+		$html .= '</tbody></table>';
194
+		return $html;
195
+	}
196
+
197
+
198
+
199
+	/**
200
+	 * set_content_type
201
+	 *
202
+	 * @param $content_type
203
+	 * @return string
204
+	 */
205
+	public static function set_content_type($content_type)
206
+	{
207
+		return 'text/html';
208
+	}
209
+
210
+
211
+
212
+	/**
213
+	 * @return void
214
+	 * @throws EE_Error
215
+	 * @throws ReflectionException
216
+	 */
217
+	public function get_error()
218
+	{
219
+		if (apply_filters('FHEE__EE_Error__get_error__show_normal_exceptions', false)) {
220
+			throw $this;
221
+		}
222
+		// get separate user and developer messages if they exist
223
+		$msg = explode('||', $this->getMessage());
224
+		$user_msg = $msg[0];
225
+		$dev_msg = isset($msg[1]) ? $msg[1] : $msg[0];
226
+		$msg = WP_DEBUG ? $dev_msg : $user_msg;
227
+		// add details to _all_exceptions array
228
+		$x_time = time();
229
+		self::$_all_exceptions[$x_time]['name'] = get_class($this);
230
+		self::$_all_exceptions[$x_time]['file'] = $this->getFile();
231
+		self::$_all_exceptions[$x_time]['line'] = $this->getLine();
232
+		self::$_all_exceptions[$x_time]['msg'] = $msg;
233
+		self::$_all_exceptions[$x_time]['code'] = $this->getCode();
234
+		self::$_all_exceptions[$x_time]['trace'] = $this->getTrace();
235
+		self::$_all_exceptions[$x_time]['string'] = $this->getTraceAsString();
236
+		self::$_error_count++;
237
+		//add_action( 'shutdown', array( $this, 'display_errors' ));
238
+		$this->display_errors();
239
+	}
240
+
241
+
242
+
243
+	/**
244
+	 *    has_error
245
+	 *
246
+	 * @param bool   $check_stored
247
+	 * @param string $type_to_check
248
+	 * @return bool
249
+	 */
250
+	public static function has_error($check_stored = false, $type_to_check = 'errors')
251
+	{
252
+		$has_error = isset(self::$_espresso_notices[$type_to_check])
253
+					 && ! empty(self::$_espresso_notices[$type_to_check])
254
+			? true
255
+			: false;
256
+		if ($check_stored && ! $has_error) {
257
+			$notices = (array)get_option('ee_notices', array());
258
+			foreach ($notices as $type => $notice) {
259
+				if ($type === $type_to_check && $notice) {
260
+					return true;
261
+				}
262
+			}
263
+		}
264
+		return $has_error;
265
+	}
266
+
267
+
268
+
269
+	/**
270
+	 *    display_errors
271
+	 *
272
+	 * @echo   string
273
+	 * @throws \ReflectionException
274
+	 */
275
+	public function display_errors()
276
+	{
277
+		$trace_details = '';
278
+		$output = '
279 279
 <style type="text/css">
280 280
 	#ee-error-message {
281 281
 		max-width:90% !important;
@@ -331,19 +331,19 @@  discard block
 block discarded – undo
331 331
 	}
332 332
 </style>
333 333
 <div id="ee-error-message" class="error">';
334
-        if (! WP_DEBUG) {
335
-            $output .= '
334
+		if (! WP_DEBUG) {
335
+			$output .= '
336 336
 	<p>';
337
-        }
338
-        // cycle thru errors
339
-        foreach (self::$_all_exceptions as $time => $ex) {
340
-            $error_code = '';
341
-            // process trace info
342
-            if (empty($ex['trace'])) {
343
-                $trace_details .= __('Sorry, but no trace information was available for this exception.',
344
-                    'event_espresso');
345
-            } else {
346
-                $trace_details .= '
337
+		}
338
+		// cycle thru errors
339
+		foreach (self::$_all_exceptions as $time => $ex) {
340
+			$error_code = '';
341
+			// process trace info
342
+			if (empty($ex['trace'])) {
343
+				$trace_details .= __('Sorry, but no trace information was available for this exception.',
344
+					'event_espresso');
345
+			} else {
346
+				$trace_details .= '
347 347
 			<div id="ee-trace-details">
348 348
 			<table width="100%" border="0" cellpadding="5" cellspacing="0">
349 349
 				<tr>
@@ -353,38 +353,38 @@  discard block
 block discarded – undo
353 353
 					<th scope="col" align="left">Class</th>
354 354
 					<th scope="col" align="left">Method( arguments )</th>
355 355
 				</tr>';
356
-                $last_on_stack = count($ex['trace']) - 1;
357
-                // reverse array so that stack is in proper chronological order
358
-                $sorted_trace = array_reverse($ex['trace']);
359
-                foreach ($sorted_trace as $nmbr => $trace) {
360
-                    $file = isset($trace['file']) ? $trace['file'] : '';
361
-                    $class = isset($trace['class']) ? $trace['class'] : '';
362
-                    $type = isset($trace['type']) ? $trace['type'] : '';
363
-                    $function = isset($trace['function']) ? $trace['function'] : '';
364
-                    $args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : '';
365
-                    $line = isset($trace['line']) ? $trace['line'] : '';
366
-                    $zebra = ($nmbr % 2) ? ' odd' : '';
367
-                    if (empty($file) && ! empty($class)) {
368
-                        $a = new ReflectionClass($class);
369
-                        $file = $a->getFileName();
370
-                        if (empty($line) && ! empty($function)) {
371
-                            $b = new ReflectionMethod($class, $function);
372
-                            $line = $b->getStartLine();
373
-                        }
374
-                    }
375
-                    if ($nmbr === $last_on_stack) {
376
-                        $file = $ex['file'] !== '' ? $ex['file'] : $file;
377
-                        $line = $ex['line'] !== '' ? $ex['line'] : $line;
378
-                        $error_code = self::generate_error_code($file, $trace['function'], $line);
379
-                    }
380
-                    $nmbr_dsply = ! empty($nmbr) ? $nmbr : '&nbsp;';
381
-                    $line_dsply = ! empty($line) ? $line : '&nbsp;';
382
-                    $file_dsply = ! empty($file) ? $file : '&nbsp;';
383
-                    $class_dsply = ! empty($class) ? $class : '&nbsp;';
384
-                    $type_dsply = ! empty($type) ? $type : '&nbsp;';
385
-                    $function_dsply = ! empty($function) ? $function : '&nbsp;';
386
-                    $args_dsply = ! empty($args) ? '( ' . $args . ' )' : '';
387
-                    $trace_details .= '
356
+				$last_on_stack = count($ex['trace']) - 1;
357
+				// reverse array so that stack is in proper chronological order
358
+				$sorted_trace = array_reverse($ex['trace']);
359
+				foreach ($sorted_trace as $nmbr => $trace) {
360
+					$file = isset($trace['file']) ? $trace['file'] : '';
361
+					$class = isset($trace['class']) ? $trace['class'] : '';
362
+					$type = isset($trace['type']) ? $trace['type'] : '';
363
+					$function = isset($trace['function']) ? $trace['function'] : '';
364
+					$args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : '';
365
+					$line = isset($trace['line']) ? $trace['line'] : '';
366
+					$zebra = ($nmbr % 2) ? ' odd' : '';
367
+					if (empty($file) && ! empty($class)) {
368
+						$a = new ReflectionClass($class);
369
+						$file = $a->getFileName();
370
+						if (empty($line) && ! empty($function)) {
371
+							$b = new ReflectionMethod($class, $function);
372
+							$line = $b->getStartLine();
373
+						}
374
+					}
375
+					if ($nmbr === $last_on_stack) {
376
+						$file = $ex['file'] !== '' ? $ex['file'] : $file;
377
+						$line = $ex['line'] !== '' ? $ex['line'] : $line;
378
+						$error_code = self::generate_error_code($file, $trace['function'], $line);
379
+					}
380
+					$nmbr_dsply = ! empty($nmbr) ? $nmbr : '&nbsp;';
381
+					$line_dsply = ! empty($line) ? $line : '&nbsp;';
382
+					$file_dsply = ! empty($file) ? $file : '&nbsp;';
383
+					$class_dsply = ! empty($class) ? $class : '&nbsp;';
384
+					$type_dsply = ! empty($type) ? $type : '&nbsp;';
385
+					$function_dsply = ! empty($function) ? $function : '&nbsp;';
386
+					$args_dsply = ! empty($args) ? '( ' . $args . ' )' : '';
387
+					$trace_details .= '
388 388
 					<tr>
389 389
 						<td align="right" class="' . $zebra . '">' . $nmbr_dsply . '</td>
390 390
 						<td align="right" class="' . $zebra . '">' . $line_dsply . '</td>
@@ -392,674 +392,674 @@  discard block
 block discarded – undo
392 392
 						<td align="left" class="' . $zebra . '">' . $class_dsply . '</td>
393 393
 						<td align="left" class="' . $zebra . '">' . $type_dsply . $function_dsply . $args_dsply . '</td>
394 394
 					</tr>';
395
-                }
396
-                $trace_details .= '
395
+				}
396
+				$trace_details .= '
397 397
 			 </table>
398 398
 			</div>';
399
-            }
400
-            $ex['code'] = $ex['code'] ? $ex['code'] : $error_code;
401
-            // add generic non-identifying messages for non-privileged users
402
-            if (! WP_DEBUG) {
403
-                $output .= '<span class="ee-error-user-msg-spn">'
404
-                           . trim($ex['msg'])
405
-                           . '</span> &nbsp; <sup>'
406
-                           . $ex['code']
407
-                           . '</sup><br />';
408
-            } else {
409
-                // or helpful developer messages if debugging is on
410
-                $output .= '
399
+			}
400
+			$ex['code'] = $ex['code'] ? $ex['code'] : $error_code;
401
+			// add generic non-identifying messages for non-privileged users
402
+			if (! WP_DEBUG) {
403
+				$output .= '<span class="ee-error-user-msg-spn">'
404
+						   . trim($ex['msg'])
405
+						   . '</span> &nbsp; <sup>'
406
+						   . $ex['code']
407
+						   . '</sup><br />';
408
+			} else {
409
+				// or helpful developer messages if debugging is on
410
+				$output .= '
411 411
 		<div class="ee-error-dev-msg-dv">
412 412
 			<p class="ee-error-dev-msg-pg">
413 413
 				<strong class="ee-error-dev-msg-str">An '
414
-                           . $ex['name']
415
-                           . ' exception was thrown!</strong>  &nbsp; <span>code: '
416
-                           . $ex['code']
417
-                           . '</span><br />
414
+						   . $ex['name']
415
+						   . ' exception was thrown!</strong>  &nbsp; <span>code: '
416
+						   . $ex['code']
417
+						   . '</span><br />
418 418
 				<span class="big-text">"'
419
-                           . trim($ex['msg'])
420
-                           . '"</span><br/>
419
+						   . trim($ex['msg'])
420
+						   . '"</span><br/>
421 421
 				<a id="display-ee-error-trace-'
422
-                           . self::$_error_count
423
-                           . $time
424
-                           . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-'
425
-                           . self::$_error_count
426
-                           . $time
427
-                           . '">
422
+						   . self::$_error_count
423
+						   . $time
424
+						   . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-'
425
+						   . self::$_error_count
426
+						   . $time
427
+						   . '">
428 428
 					'
429
-                           . __('click to view backtrace and class/method details', 'event_espresso')
430
-                           . '
429
+						   . __('click to view backtrace and class/method details', 'event_espresso')
430
+						   . '
431 431
 				</a><br />
432 432
 				<span class="small-text lt-grey-text">'
433
-                           . $ex['file']
434
-                           . ' &nbsp; ( line no: '
435
-                           . $ex['line']
436
-                           . ' )</span>
433
+						   . $ex['file']
434
+						   . ' &nbsp; ( line no: '
435
+						   . $ex['line']
436
+						   . ' )</span>
437 437
 			</p>
438 438
 			<div id="ee-error-trace-'
439
-                           . self::$_error_count
440
-                           . $time
441
-                           . '-dv" class="ee-error-trace-dv" style="display: none;">
439
+						   . self::$_error_count
440
+						   . $time
441
+						   . '-dv" class="ee-error-trace-dv" style="display: none;">
442 442
 				'
443
-                           . $trace_details;
444
-                if (! empty($class)) {
445
-                    $output .= '
443
+						   . $trace_details;
444
+				if (! empty($class)) {
445
+					$output .= '
446 446
 				<div style="padding:3px; margin:0 0 1em; border:1px solid #666; background:#fff; border-radius:3px;">
447 447
 					<div style="padding:1em 2em; border:1px solid #666; background:#f9f9f9;">
448 448
 						<h3>Class Details</h3>';
449
-                    $a = new ReflectionClass($class);
450
-                    $output .= '
449
+					$a = new ReflectionClass($class);
450
+					$output .= '
451 451
 						<pre>' . $a . '</pre>
452 452
 					</div>
453 453
 				</div>';
454
-                }
455
-                $output .= '
454
+				}
455
+				$output .= '
456 456
 			</div>
457 457
 		</div>
458 458
 		<br />';
459
-            }
460
-            $this->write_to_error_log($time, $ex);
461
-        }
462
-        // remove last linebreak
463
-        $output = substr($output, 0, -6);
464
-        if (! WP_DEBUG) {
465
-            $output .= '
459
+			}
460
+			$this->write_to_error_log($time, $ex);
461
+		}
462
+		// remove last linebreak
463
+		$output = substr($output, 0, -6);
464
+		if (! WP_DEBUG) {
465
+			$output .= '
466 466
 	</p>';
467
-        }
468
-        $output .= '
467
+		}
468
+		$output .= '
469 469
 </div>';
470
-        $output .= self::_print_scripts(true);
471
-        if (defined('DOING_AJAX')) {
472
-            echo wp_json_encode(array('error' => $output));
473
-            exit();
474
-        }
475
-        echo $output;
476
-        die();
477
-    }
478
-
479
-
480
-
481
-    /**
482
-     *    generate string from exception trace args
483
-     *
484
-     * @param array $arguments
485
-     * @param bool  $array
486
-     * @return string
487
-     */
488
-    private function _convert_args_to_string($arguments = array(), $array = false)
489
-    {
490
-        $arg_string = '';
491
-        if (! empty($arguments)) {
492
-            $args = array();
493
-            foreach ($arguments as $arg) {
494
-                if (! empty($arg)) {
495
-                    if (is_string($arg)) {
496
-                        $args[] = " '" . $arg . "'";
497
-                    } elseif (is_array($arg)) {
498
-                        $args[] = 'ARRAY(' . $this->_convert_args_to_string($arg, true);
499
-                    } elseif ($arg === null) {
500
-                        $args[] = ' NULL';
501
-                    } elseif (is_bool($arg)) {
502
-                        $args[] = ($arg) ? ' TRUE' : ' FALSE';
503
-                    } elseif (is_object($arg)) {
504
-                        $args[] = ' OBJECT ' . get_class($arg);
505
-                    } elseif (is_resource($arg)) {
506
-                        $args[] = get_resource_type($arg);
507
-                    } else {
508
-                        $args[] = $arg;
509
-                    }
510
-                }
511
-            }
512
-            $arg_string = implode(', ', $args);
513
-        }
514
-        if ($array) {
515
-            $arg_string .= ' )';
516
-        }
517
-        return $arg_string;
518
-    }
519
-
520
-
521
-
522
-    /**
523
-     *    add error message
524
-     *
525
-     * @param        string $msg  the message to display to users or developers - adding a double pipe || (OR) creates
526
-     *                            separate messages for user || dev
527
-     * @param        string $file the file that the error occurred in - just use __FILE__
528
-     * @param        string $func the function/method that the error occurred in - just use __FUNCTION__
529
-     * @param        string $line the line number where the error occurred - just use __LINE__
530
-     * @return        void
531
-     */
532
-    public static function add_error($msg = null, $file = null, $func = null, $line = null)
533
-    {
534
-        self::_add_notice('errors', $msg, $file, $func, $line);
535
-        self::$_error_count++;
536
-    }
537
-
538
-
539
-
540
-    /**
541
-     * If WP_DEBUG is active, throws an exception. If WP_DEBUG is off, just
542
-     * adds an error
543
-     *
544
-     * @param string $msg
545
-     * @param string $file
546
-     * @param string $func
547
-     * @param string $line
548
-     * @throws EE_Error
549
-     */
550
-    public static function throw_exception_if_debugging($msg = null, $file = null, $func = null, $line = null)
551
-    {
552
-        if (WP_DEBUG) {
553
-            throw new EE_Error($msg);
554
-        }
555
-        EE_Error::add_error($msg, $file, $func, $line);
556
-    }
557
-
558
-
559
-
560
-    /**
561
-     *    add success message
562
-     *
563
-     * @param        string $msg  the message to display to users or developers - adding a double pipe || (OR) creates
564
-     *                            separate messages for user || dev
565
-     * @param        string $file the file that the error occurred in - just use __FILE__
566
-     * @param        string $func the function/method that the error occurred in - just use __FUNCTION__
567
-     * @param        string $line the line number where the error occurred - just use __LINE__
568
-     * @return        void
569
-     */
570
-    public static function add_success($msg = null, $file = null, $func = null, $line = null)
571
-    {
572
-        self::_add_notice('success', $msg, $file, $func, $line);
573
-    }
574
-
575
-
576
-
577
-    /**
578
-     *    add attention message
579
-     *
580
-     * @param        string $msg  the message to display to users or developers - adding a double pipe || (OR) creates
581
-     *                            separate messages for user || dev
582
-     * @param        string $file the file that the error occurred in - just use __FILE__
583
-     * @param        string $func the function/method that the error occurred in - just use __FUNCTION__
584
-     * @param        string $line the line number where the error occurred - just use __LINE__
585
-     * @return        void
586
-     */
587
-    public static function add_attention($msg = null, $file = null, $func = null, $line = null)
588
-    {
589
-        self::_add_notice('attention', $msg, $file, $func, $line);
590
-    }
591
-
592
-
593
-
594
-    /**
595
-     *    add success message
596
-     *
597
-     * @param        string $type whether the message is for a success or error notification
598
-     * @param        string $msg  the message to display to users or developers - adding a double pipe || (OR) creates
599
-     *                            separate messages for user || dev
600
-     * @param        string $file the file that the error occurred in - just use __FILE__
601
-     * @param        string $func the function/method that the error occurred in - just use __FUNCTION__
602
-     * @param        string $line the line number where the error occurred - just use __LINE__
603
-     * @return        void
604
-     */
605
-    private static function _add_notice($type = 'success', $msg = null, $file = null, $func = null, $line = null)
606
-    {
607
-        if (empty($msg)) {
608
-            EE_Error::doing_it_wrong(
609
-                'EE_Error::add_' . $type . '()',
610
-                sprintf(
611
-                    __('Notifications are not much use without a message! Please add a message to the EE_Error::add_%s() call made in %s on line %d',
612
-                        'event_espresso'),
613
-                    $type,
614
-                    $file,
615
-                    $line
616
-                ),
617
-                EVENT_ESPRESSO_VERSION
618
-            );
619
-        }
620
-        if ($type === 'errors' && (empty($file) || empty($func) || empty($line))) {
621
-            EE_Error::doing_it_wrong(
622
-                'EE_Error::add_error()',
623
-                __('You need to provide the file name, function name, and line number that the error occurred on in order to better assist with debugging.',
624
-                    'event_espresso'),
625
-                EVENT_ESPRESSO_VERSION
626
-            );
627
-        }
628
-        // get separate user and developer messages if they exist
629
-        $msg = explode('||', $msg);
630
-        $user_msg = $msg[0];
631
-        $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0];
632
-        /**
633
-         * Do an action so other code can be triggered when a notice is created
634
-         *
635
-         * @param string $type     can be 'errors', 'attention', or 'success'
636
-         * @param string $user_msg message displayed to user when WP_DEBUG is off
637
-         * @param string $user_msg message displayed to user when WP_DEBUG is on
638
-         * @param string $file     file where error was generated
639
-         * @param string $func     function where error was generated
640
-         * @param string $line     line where error was generated
641
-         */
642
-        do_action('AHEE__EE_Error___add_notice', $type, $user_msg, $dev_msg, $file, $func, $line);
643
-        $msg = WP_DEBUG ? $dev_msg : $user_msg;
644
-        // add notice if message exists
645
-        if (! empty($msg)) {
646
-            // get error code
647
-            $notice_code = EE_Error::generate_error_code($file, $func, $line);
648
-            if (WP_DEBUG && $type === 'errors') {
649
-                $msg .= '<br/><span class="tiny-text">' . $notice_code . '</span>';
650
-            }
651
-            // add notice. Index by code if it's not blank
652
-            if ($notice_code) {
653
-                self::$_espresso_notices[$type][$notice_code] = $msg;
654
-            } else {
655
-                self::$_espresso_notices[$type][] = $msg;
656
-            }
657
-            add_action('wp_footer', array('EE_Error', 'enqueue_error_scripts'), 1);
658
-        }
659
-    }
660
-
661
-
662
-
663
-    /**
664
-     *    in some case it may be necessary to overwrite the existing success messages
665
-     *
666
-     * @return        void
667
-     */
668
-    public static function overwrite_success()
669
-    {
670
-        self::$_espresso_notices['success'] = false;
671
-    }
672
-
673
-
674
-
675
-    /**
676
-     *    in some case it may be necessary to overwrite the existing attention messages
677
-     *
678
-     * @return        void
679
-     */
680
-    public static function overwrite_attention()
681
-    {
682
-        self::$_espresso_notices['attention'] = false;
683
-    }
684
-
685
-
686
-
687
-    /**
688
-     *    in some case it may be necessary to overwrite the existing error messages
689
-     *
690
-     * @return        void
691
-     */
692
-    public static function overwrite_errors()
693
-    {
694
-        self::$_espresso_notices['errors'] = false;
695
-    }
696
-
697
-
698
-
699
-    /**
700
-     *    reset_notices
701
-     *
702
-     * @return void
703
-     */
704
-    public static function reset_notices()
705
-    {
706
-        self::$_espresso_notices['success'] = false;
707
-        self::$_espresso_notices['attention'] = false;
708
-        self::$_espresso_notices['errors'] = false;
709
-    }
710
-
711
-
712
-
713
-    /**
714
-     *    has_errors
715
-     *
716
-     * @return int
717
-     */
718
-    public static function has_notices()
719
-    {
720
-        $has_notices = 0;
721
-        // check for success messages
722
-        $has_notices = self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success']) ? 3
723
-            : $has_notices;
724
-        // check for attention messages
725
-        $has_notices = self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention']) ? 2
726
-            : $has_notices;
727
-        // check for error messages
728
-        $has_notices = self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors']) ? 1
729
-            : $has_notices;
730
-        return $has_notices;
731
-    }
732
-
733
-
734
-
735
-    /**
736
-     * This simply returns non formatted error notices as they were sent into the EE_Error object.
737
-     *
738
-     * @since 4.9.0
739
-     * @return array
740
-     */
741
-    public static function get_vanilla_notices()
742
-    {
743
-        return array(
744
-            'success'   => isset(self::$_espresso_notices['success']) ? self::$_espresso_notices['success'] : array(),
745
-            'attention' => isset(self::$_espresso_notices['attention']) ? self::$_espresso_notices['attention']
746
-                : array(),
747
-            'errors'    => isset(self::$_espresso_notices['errors']) ? self::$_espresso_notices['errors'] : array(),
748
-        );
749
-    }
750
-
751
-
752
-
753
-    /**
754
-     *    compile all error or success messages into one string
755
-     *
756
-     * @see EE_Error::get_raw_notices if you want the raw notices without any preparations made to them
757
-     * @param        boolean $format_output     whether or not to format the messages for display in the WP admin
758
-     * @param        boolean $save_to_transient whether or not to save notices to the db for retrieval on next request
759
-     *                                          - ONLY do this just before redirecting
760
-     * @param        boolean $remove_empty      whether or not to unset empty messages
761
-     * @return        array
762
-     */
763
-    public static function get_notices($format_output = true, $save_to_transient = false, $remove_empty = true)
764
-    {
765
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
766
-        $success_messages = '';
767
-        $attention_messages = '';
768
-        $error_messages = '';
769
-        $print_scripts = false;
770
-        // either save notices to the db
771
-        if ($save_to_transient) {
772
-            update_option('ee_notices', self::$_espresso_notices);
773
-            return array();
774
-        }
775
-        // grab any notices that have been previously saved
776
-        if ($notices = get_option('ee_notices', false)) {
777
-            foreach ($notices as $type => $notice) {
778
-                if (is_array($notice) && ! empty($notice)) {
779
-                    // make sure that existing notice type is an array
780
-                    self::$_espresso_notices[$type] = is_array(self::$_espresso_notices[$type])
781
-                                                      && ! empty(self::$_espresso_notices[$type])
782
-                        ? self::$_espresso_notices[$type] : array();
783
-                    // merge stored notices with any newly created ones
784
-                    self::$_espresso_notices[$type] = array_merge(self::$_espresso_notices[$type], $notice);
785
-                    $print_scripts = true;
786
-                }
787
-            }
788
-            // now clear any stored notices
789
-            update_option('ee_notices', false);
790
-        }
791
-        // check for success messages
792
-        if (self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success'])) {
793
-            // combine messages
794
-            $success_messages .= implode(self::$_espresso_notices['success'], '<br /><br />');
795
-            $print_scripts = true;
796
-        }
797
-        // check for attention messages
798
-        if (self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention'])) {
799
-            // combine messages
800
-            $attention_messages .= implode(self::$_espresso_notices['attention'], '<br /><br />');
801
-            $print_scripts = true;
802
-        }
803
-        // check for error messages
804
-        if (self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors'])) {
805
-            $error_messages .= count(self::$_espresso_notices['errors']) > 1
806
-                ? __('The following errors have occurred:<br />', 'event_espresso')
807
-                : __('An error has occurred:<br />', 'event_espresso');
808
-            // combine messages
809
-            $error_messages .= implode(self::$_espresso_notices['errors'], '<br /><br />');
810
-            $print_scripts = true;
811
-        }
812
-        if ($format_output) {
813
-            $notices = '<div id="espresso-notices">';
814
-            $close = is_admin() ? ''
815
-                : '<a class="close-espresso-notice hide-if-no-js"><span class="dashicons dashicons-no"></span></a>';
816
-            if ($success_messages !== '') {
817
-                $css_id = is_admin() ? 'message' : 'espresso-notices-success';
818
-                $css_class = is_admin() ? 'updated fade' : 'success fade-away';
819
-                //showMessage( $success_messages );
820
-                $notices .= '<div id="'
821
-                            . $css_id
822
-                            . '" class="espresso-notices '
823
-                            . $css_class
824
-                            . '" style="display:none;"><p>'
825
-                            . $success_messages
826
-                            . '</p>'
827
-                            . $close
828
-                            . '</div>';
829
-            }
830
-            if ($attention_messages !== '') {
831
-                $css_id = is_admin() ? 'message' : 'espresso-notices-attention';
832
-                $css_class = is_admin() ? 'updated ee-notices-attention' : 'attention fade-away';
833
-                //showMessage( $error_messages, TRUE );
834
-                $notices .= '<div id="'
835
-                            . $css_id
836
-                            . '" class="espresso-notices '
837
-                            . $css_class
838
-                            . '" style="display:none;"><p>'
839
-                            . $attention_messages
840
-                            . '</p>'
841
-                            . $close
842
-                            . '</div>';
843
-            }
844
-            if ($error_messages !== '') {
845
-                $css_id = is_admin() ? 'message' : 'espresso-notices-error';
846
-                $css_class = is_admin() ? 'error' : 'error fade-away';
847
-                //showMessage( $error_messages, TRUE );
848
-                $notices .= '<div id="'
849
-                            . $css_id
850
-                            . '" class="espresso-notices '
851
-                            . $css_class
852
-                            . '" style="display:none;"><p>'
853
-                            . $error_messages
854
-                            . '</p>'
855
-                            . $close
856
-                            . '</div>';
857
-            }
858
-            $notices .= '</div>';
859
-        } else {
860
-            $notices = array(
861
-                'success'   => $success_messages,
862
-                'attention' => $attention_messages,
863
-                'errors'    => $error_messages,
864
-            );
865
-            if ($remove_empty) {
866
-                // remove empty notices
867
-                foreach ($notices as $type => $notice) {
868
-                    if (empty($notice)) {
869
-                        unset($notices[$type]);
870
-                    }
871
-                }
872
-            }
873
-        }
874
-        if ($print_scripts) {
875
-            self::_print_scripts();
876
-        }
877
-        return $notices;
878
-    }
879
-
880
-
881
-
882
-    /**
883
-     *    add_persistent_admin_notice
884
-     *
885
-     * @param        string $pan_name     the name, or key of the Persistent Admin Notice to be stored
886
-     * @param        string $pan_message  the message to be stored persistently until dismissed
887
-     * @param bool          $force_update allows one to enforce the reappearance of a persistent message.
888
-     * @return        void
889
-     */
890
-    public static function add_persistent_admin_notice($pan_name = '', $pan_message, $force_update = false)
891
-    {
892
-        if (! empty($pan_name) && ! empty($pan_message)) {
893
-            $persistent_admin_notices = get_option('ee_pers_admin_notices', array());
894
-            //maybe initialize persistent_admin_notices
895
-            if (empty($persistent_admin_notices)) {
896
-                add_option('ee_pers_admin_notices', array(), '', 'no');
897
-            }
898
-            $pan_name = sanitize_key($pan_name);
899
-            if (! array_key_exists($pan_name, $persistent_admin_notices) || $force_update) {
900
-                $persistent_admin_notices[$pan_name] = $pan_message;
901
-                update_option('ee_pers_admin_notices', $persistent_admin_notices);
902
-            }
903
-        }
904
-    }
905
-
906
-
907
-
908
-    /**
909
-     *    dismiss_persistent_admin_notice
910
-     *
911
-     * @param        string $pan_name the name, or key of the Persistent Admin Notice to be dismissed
912
-     * @param bool          $purge
913
-     * @param bool          $return_immediately
914
-     * @return        void
915
-     */
916
-    public static function dismiss_persistent_admin_notice($pan_name = '', $purge = false, $return_immediately = false)
917
-    {
918
-        $pan_name = EE_Registry::instance()->REQ->is_set('ee_nag_notice')
919
-            ? EE_Registry::instance()->REQ->get('ee_nag_notice') : $pan_name;
920
-        if (! empty($pan_name)) {
921
-            $persistent_admin_notices = get_option('ee_pers_admin_notices', array());
922
-            // check if notice we wish to dismiss is actually in the $persistent_admin_notices array
923
-            if (is_array($persistent_admin_notices) && isset($persistent_admin_notices[$pan_name])) {
924
-                // completely delete nag notice, or just NULL message so that it can NOT be added again ?
925
-                if ($purge) {
926
-                    unset($persistent_admin_notices[$pan_name]);
927
-                } else {
928
-                    $persistent_admin_notices[$pan_name] = null;
929
-                }
930
-                if (update_option('ee_pers_admin_notices', $persistent_admin_notices) === false) {
931
-                    EE_Error::add_error(sprintf(__('The persistent admin notice for "%s" could not be deleted.',
932
-                        'event_espresso'), $pan_name), __FILE__, __FUNCTION__, __LINE__);
933
-                }
934
-            }
935
-        }
936
-        if ($return_immediately) {
937
-            return;
938
-        }
939
-        if (EE_Registry::instance()->REQ->ajax) {
940
-            // grab any notices and concatenate into string
941
-            echo wp_json_encode(array('errors' => implode('<br />', EE_Error::get_notices(false))));
942
-            exit();
943
-        }
944
-        // save errors to a transient to be displayed on next request (after redirect)
945
-        EE_Error::get_notices(false, true);
946
-        $return_url = EE_Registry::instance()->REQ->is_set('return_url')
947
-            ? EE_Registry::instance()->REQ->get('return_url') : '';
948
-        wp_safe_redirect(urldecode($return_url));
949
-    }
950
-
951
-
952
-
953
-    /**
954
-     * display_persistent_admin_notices
955
-     *
956
-     * @param  string $pan_name    the name, or key of the Persistent Admin Notice to be stored
957
-     * @param  string $pan_message the message to be stored persistently until dismissed
958
-     * @param  string $return_url  URL to go back to after nag notice is dismissed
959
-     * @return string
960
-     */
961
-    public static function display_persistent_admin_notices($pan_name = '', $pan_message = '', $return_url = '')
962
-    {
963
-        if (! empty($pan_name) && ! empty($pan_message)) {
964
-            $args = array(
965
-                'nag_notice'    => $pan_name,
966
-                'return_url'    => urlencode($return_url),
967
-                'ajax_url'      => WP_AJAX_URL,
968
-                'unknown_error' => esc_html__(
969
-                    'An unknown error has occurred on the server while attempting to dismiss this notice.',
970
-                    'event_espresso'
971
-                ),
972
-            );
973
-            EE_Registry::$i18n_js_strings = array_merge(
974
-                EE_Registry::$i18n_js_strings,
975
-                array('ee_dismiss' => $args)
976
-            );
977
-            return '
470
+		$output .= self::_print_scripts(true);
471
+		if (defined('DOING_AJAX')) {
472
+			echo wp_json_encode(array('error' => $output));
473
+			exit();
474
+		}
475
+		echo $output;
476
+		die();
477
+	}
478
+
479
+
480
+
481
+	/**
482
+	 *    generate string from exception trace args
483
+	 *
484
+	 * @param array $arguments
485
+	 * @param bool  $array
486
+	 * @return string
487
+	 */
488
+	private function _convert_args_to_string($arguments = array(), $array = false)
489
+	{
490
+		$arg_string = '';
491
+		if (! empty($arguments)) {
492
+			$args = array();
493
+			foreach ($arguments as $arg) {
494
+				if (! empty($arg)) {
495
+					if (is_string($arg)) {
496
+						$args[] = " '" . $arg . "'";
497
+					} elseif (is_array($arg)) {
498
+						$args[] = 'ARRAY(' . $this->_convert_args_to_string($arg, true);
499
+					} elseif ($arg === null) {
500
+						$args[] = ' NULL';
501
+					} elseif (is_bool($arg)) {
502
+						$args[] = ($arg) ? ' TRUE' : ' FALSE';
503
+					} elseif (is_object($arg)) {
504
+						$args[] = ' OBJECT ' . get_class($arg);
505
+					} elseif (is_resource($arg)) {
506
+						$args[] = get_resource_type($arg);
507
+					} else {
508
+						$args[] = $arg;
509
+					}
510
+				}
511
+			}
512
+			$arg_string = implode(', ', $args);
513
+		}
514
+		if ($array) {
515
+			$arg_string .= ' )';
516
+		}
517
+		return $arg_string;
518
+	}
519
+
520
+
521
+
522
+	/**
523
+	 *    add error message
524
+	 *
525
+	 * @param        string $msg  the message to display to users or developers - adding a double pipe || (OR) creates
526
+	 *                            separate messages for user || dev
527
+	 * @param        string $file the file that the error occurred in - just use __FILE__
528
+	 * @param        string $func the function/method that the error occurred in - just use __FUNCTION__
529
+	 * @param        string $line the line number where the error occurred - just use __LINE__
530
+	 * @return        void
531
+	 */
532
+	public static function add_error($msg = null, $file = null, $func = null, $line = null)
533
+	{
534
+		self::_add_notice('errors', $msg, $file, $func, $line);
535
+		self::$_error_count++;
536
+	}
537
+
538
+
539
+
540
+	/**
541
+	 * If WP_DEBUG is active, throws an exception. If WP_DEBUG is off, just
542
+	 * adds an error
543
+	 *
544
+	 * @param string $msg
545
+	 * @param string $file
546
+	 * @param string $func
547
+	 * @param string $line
548
+	 * @throws EE_Error
549
+	 */
550
+	public static function throw_exception_if_debugging($msg = null, $file = null, $func = null, $line = null)
551
+	{
552
+		if (WP_DEBUG) {
553
+			throw new EE_Error($msg);
554
+		}
555
+		EE_Error::add_error($msg, $file, $func, $line);
556
+	}
557
+
558
+
559
+
560
+	/**
561
+	 *    add success message
562
+	 *
563
+	 * @param        string $msg  the message to display to users or developers - adding a double pipe || (OR) creates
564
+	 *                            separate messages for user || dev
565
+	 * @param        string $file the file that the error occurred in - just use __FILE__
566
+	 * @param        string $func the function/method that the error occurred in - just use __FUNCTION__
567
+	 * @param        string $line the line number where the error occurred - just use __LINE__
568
+	 * @return        void
569
+	 */
570
+	public static function add_success($msg = null, $file = null, $func = null, $line = null)
571
+	{
572
+		self::_add_notice('success', $msg, $file, $func, $line);
573
+	}
574
+
575
+
576
+
577
+	/**
578
+	 *    add attention message
579
+	 *
580
+	 * @param        string $msg  the message to display to users or developers - adding a double pipe || (OR) creates
581
+	 *                            separate messages for user || dev
582
+	 * @param        string $file the file that the error occurred in - just use __FILE__
583
+	 * @param        string $func the function/method that the error occurred in - just use __FUNCTION__
584
+	 * @param        string $line the line number where the error occurred - just use __LINE__
585
+	 * @return        void
586
+	 */
587
+	public static function add_attention($msg = null, $file = null, $func = null, $line = null)
588
+	{
589
+		self::_add_notice('attention', $msg, $file, $func, $line);
590
+	}
591
+
592
+
593
+
594
+	/**
595
+	 *    add success message
596
+	 *
597
+	 * @param        string $type whether the message is for a success or error notification
598
+	 * @param        string $msg  the message to display to users or developers - adding a double pipe || (OR) creates
599
+	 *                            separate messages for user || dev
600
+	 * @param        string $file the file that the error occurred in - just use __FILE__
601
+	 * @param        string $func the function/method that the error occurred in - just use __FUNCTION__
602
+	 * @param        string $line the line number where the error occurred - just use __LINE__
603
+	 * @return        void
604
+	 */
605
+	private static function _add_notice($type = 'success', $msg = null, $file = null, $func = null, $line = null)
606
+	{
607
+		if (empty($msg)) {
608
+			EE_Error::doing_it_wrong(
609
+				'EE_Error::add_' . $type . '()',
610
+				sprintf(
611
+					__('Notifications are not much use without a message! Please add a message to the EE_Error::add_%s() call made in %s on line %d',
612
+						'event_espresso'),
613
+					$type,
614
+					$file,
615
+					$line
616
+				),
617
+				EVENT_ESPRESSO_VERSION
618
+			);
619
+		}
620
+		if ($type === 'errors' && (empty($file) || empty($func) || empty($line))) {
621
+			EE_Error::doing_it_wrong(
622
+				'EE_Error::add_error()',
623
+				__('You need to provide the file name, function name, and line number that the error occurred on in order to better assist with debugging.',
624
+					'event_espresso'),
625
+				EVENT_ESPRESSO_VERSION
626
+			);
627
+		}
628
+		// get separate user and developer messages if they exist
629
+		$msg = explode('||', $msg);
630
+		$user_msg = $msg[0];
631
+		$dev_msg = isset($msg[1]) ? $msg[1] : $msg[0];
632
+		/**
633
+		 * Do an action so other code can be triggered when a notice is created
634
+		 *
635
+		 * @param string $type     can be 'errors', 'attention', or 'success'
636
+		 * @param string $user_msg message displayed to user when WP_DEBUG is off
637
+		 * @param string $user_msg message displayed to user when WP_DEBUG is on
638
+		 * @param string $file     file where error was generated
639
+		 * @param string $func     function where error was generated
640
+		 * @param string $line     line where error was generated
641
+		 */
642
+		do_action('AHEE__EE_Error___add_notice', $type, $user_msg, $dev_msg, $file, $func, $line);
643
+		$msg = WP_DEBUG ? $dev_msg : $user_msg;
644
+		// add notice if message exists
645
+		if (! empty($msg)) {
646
+			// get error code
647
+			$notice_code = EE_Error::generate_error_code($file, $func, $line);
648
+			if (WP_DEBUG && $type === 'errors') {
649
+				$msg .= '<br/><span class="tiny-text">' . $notice_code . '</span>';
650
+			}
651
+			// add notice. Index by code if it's not blank
652
+			if ($notice_code) {
653
+				self::$_espresso_notices[$type][$notice_code] = $msg;
654
+			} else {
655
+				self::$_espresso_notices[$type][] = $msg;
656
+			}
657
+			add_action('wp_footer', array('EE_Error', 'enqueue_error_scripts'), 1);
658
+		}
659
+	}
660
+
661
+
662
+
663
+	/**
664
+	 *    in some case it may be necessary to overwrite the existing success messages
665
+	 *
666
+	 * @return        void
667
+	 */
668
+	public static function overwrite_success()
669
+	{
670
+		self::$_espresso_notices['success'] = false;
671
+	}
672
+
673
+
674
+
675
+	/**
676
+	 *    in some case it may be necessary to overwrite the existing attention messages
677
+	 *
678
+	 * @return        void
679
+	 */
680
+	public static function overwrite_attention()
681
+	{
682
+		self::$_espresso_notices['attention'] = false;
683
+	}
684
+
685
+
686
+
687
+	/**
688
+	 *    in some case it may be necessary to overwrite the existing error messages
689
+	 *
690
+	 * @return        void
691
+	 */
692
+	public static function overwrite_errors()
693
+	{
694
+		self::$_espresso_notices['errors'] = false;
695
+	}
696
+
697
+
698
+
699
+	/**
700
+	 *    reset_notices
701
+	 *
702
+	 * @return void
703
+	 */
704
+	public static function reset_notices()
705
+	{
706
+		self::$_espresso_notices['success'] = false;
707
+		self::$_espresso_notices['attention'] = false;
708
+		self::$_espresso_notices['errors'] = false;
709
+	}
710
+
711
+
712
+
713
+	/**
714
+	 *    has_errors
715
+	 *
716
+	 * @return int
717
+	 */
718
+	public static function has_notices()
719
+	{
720
+		$has_notices = 0;
721
+		// check for success messages
722
+		$has_notices = self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success']) ? 3
723
+			: $has_notices;
724
+		// check for attention messages
725
+		$has_notices = self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention']) ? 2
726
+			: $has_notices;
727
+		// check for error messages
728
+		$has_notices = self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors']) ? 1
729
+			: $has_notices;
730
+		return $has_notices;
731
+	}
732
+
733
+
734
+
735
+	/**
736
+	 * This simply returns non formatted error notices as they were sent into the EE_Error object.
737
+	 *
738
+	 * @since 4.9.0
739
+	 * @return array
740
+	 */
741
+	public static function get_vanilla_notices()
742
+	{
743
+		return array(
744
+			'success'   => isset(self::$_espresso_notices['success']) ? self::$_espresso_notices['success'] : array(),
745
+			'attention' => isset(self::$_espresso_notices['attention']) ? self::$_espresso_notices['attention']
746
+				: array(),
747
+			'errors'    => isset(self::$_espresso_notices['errors']) ? self::$_espresso_notices['errors'] : array(),
748
+		);
749
+	}
750
+
751
+
752
+
753
+	/**
754
+	 *    compile all error or success messages into one string
755
+	 *
756
+	 * @see EE_Error::get_raw_notices if you want the raw notices without any preparations made to them
757
+	 * @param        boolean $format_output     whether or not to format the messages for display in the WP admin
758
+	 * @param        boolean $save_to_transient whether or not to save notices to the db for retrieval on next request
759
+	 *                                          - ONLY do this just before redirecting
760
+	 * @param        boolean $remove_empty      whether or not to unset empty messages
761
+	 * @return        array
762
+	 */
763
+	public static function get_notices($format_output = true, $save_to_transient = false, $remove_empty = true)
764
+	{
765
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
766
+		$success_messages = '';
767
+		$attention_messages = '';
768
+		$error_messages = '';
769
+		$print_scripts = false;
770
+		// either save notices to the db
771
+		if ($save_to_transient) {
772
+			update_option('ee_notices', self::$_espresso_notices);
773
+			return array();
774
+		}
775
+		// grab any notices that have been previously saved
776
+		if ($notices = get_option('ee_notices', false)) {
777
+			foreach ($notices as $type => $notice) {
778
+				if (is_array($notice) && ! empty($notice)) {
779
+					// make sure that existing notice type is an array
780
+					self::$_espresso_notices[$type] = is_array(self::$_espresso_notices[$type])
781
+													  && ! empty(self::$_espresso_notices[$type])
782
+						? self::$_espresso_notices[$type] : array();
783
+					// merge stored notices with any newly created ones
784
+					self::$_espresso_notices[$type] = array_merge(self::$_espresso_notices[$type], $notice);
785
+					$print_scripts = true;
786
+				}
787
+			}
788
+			// now clear any stored notices
789
+			update_option('ee_notices', false);
790
+		}
791
+		// check for success messages
792
+		if (self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success'])) {
793
+			// combine messages
794
+			$success_messages .= implode(self::$_espresso_notices['success'], '<br /><br />');
795
+			$print_scripts = true;
796
+		}
797
+		// check for attention messages
798
+		if (self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention'])) {
799
+			// combine messages
800
+			$attention_messages .= implode(self::$_espresso_notices['attention'], '<br /><br />');
801
+			$print_scripts = true;
802
+		}
803
+		// check for error messages
804
+		if (self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors'])) {
805
+			$error_messages .= count(self::$_espresso_notices['errors']) > 1
806
+				? __('The following errors have occurred:<br />', 'event_espresso')
807
+				: __('An error has occurred:<br />', 'event_espresso');
808
+			// combine messages
809
+			$error_messages .= implode(self::$_espresso_notices['errors'], '<br /><br />');
810
+			$print_scripts = true;
811
+		}
812
+		if ($format_output) {
813
+			$notices = '<div id="espresso-notices">';
814
+			$close = is_admin() ? ''
815
+				: '<a class="close-espresso-notice hide-if-no-js"><span class="dashicons dashicons-no"></span></a>';
816
+			if ($success_messages !== '') {
817
+				$css_id = is_admin() ? 'message' : 'espresso-notices-success';
818
+				$css_class = is_admin() ? 'updated fade' : 'success fade-away';
819
+				//showMessage( $success_messages );
820
+				$notices .= '<div id="'
821
+							. $css_id
822
+							. '" class="espresso-notices '
823
+							. $css_class
824
+							. '" style="display:none;"><p>'
825
+							. $success_messages
826
+							. '</p>'
827
+							. $close
828
+							. '</div>';
829
+			}
830
+			if ($attention_messages !== '') {
831
+				$css_id = is_admin() ? 'message' : 'espresso-notices-attention';
832
+				$css_class = is_admin() ? 'updated ee-notices-attention' : 'attention fade-away';
833
+				//showMessage( $error_messages, TRUE );
834
+				$notices .= '<div id="'
835
+							. $css_id
836
+							. '" class="espresso-notices '
837
+							. $css_class
838
+							. '" style="display:none;"><p>'
839
+							. $attention_messages
840
+							. '</p>'
841
+							. $close
842
+							. '</div>';
843
+			}
844
+			if ($error_messages !== '') {
845
+				$css_id = is_admin() ? 'message' : 'espresso-notices-error';
846
+				$css_class = is_admin() ? 'error' : 'error fade-away';
847
+				//showMessage( $error_messages, TRUE );
848
+				$notices .= '<div id="'
849
+							. $css_id
850
+							. '" class="espresso-notices '
851
+							. $css_class
852
+							. '" style="display:none;"><p>'
853
+							. $error_messages
854
+							. '</p>'
855
+							. $close
856
+							. '</div>';
857
+			}
858
+			$notices .= '</div>';
859
+		} else {
860
+			$notices = array(
861
+				'success'   => $success_messages,
862
+				'attention' => $attention_messages,
863
+				'errors'    => $error_messages,
864
+			);
865
+			if ($remove_empty) {
866
+				// remove empty notices
867
+				foreach ($notices as $type => $notice) {
868
+					if (empty($notice)) {
869
+						unset($notices[$type]);
870
+					}
871
+				}
872
+			}
873
+		}
874
+		if ($print_scripts) {
875
+			self::_print_scripts();
876
+		}
877
+		return $notices;
878
+	}
879
+
880
+
881
+
882
+	/**
883
+	 *    add_persistent_admin_notice
884
+	 *
885
+	 * @param        string $pan_name     the name, or key of the Persistent Admin Notice to be stored
886
+	 * @param        string $pan_message  the message to be stored persistently until dismissed
887
+	 * @param bool          $force_update allows one to enforce the reappearance of a persistent message.
888
+	 * @return        void
889
+	 */
890
+	public static function add_persistent_admin_notice($pan_name = '', $pan_message, $force_update = false)
891
+	{
892
+		if (! empty($pan_name) && ! empty($pan_message)) {
893
+			$persistent_admin_notices = get_option('ee_pers_admin_notices', array());
894
+			//maybe initialize persistent_admin_notices
895
+			if (empty($persistent_admin_notices)) {
896
+				add_option('ee_pers_admin_notices', array(), '', 'no');
897
+			}
898
+			$pan_name = sanitize_key($pan_name);
899
+			if (! array_key_exists($pan_name, $persistent_admin_notices) || $force_update) {
900
+				$persistent_admin_notices[$pan_name] = $pan_message;
901
+				update_option('ee_pers_admin_notices', $persistent_admin_notices);
902
+			}
903
+		}
904
+	}
905
+
906
+
907
+
908
+	/**
909
+	 *    dismiss_persistent_admin_notice
910
+	 *
911
+	 * @param        string $pan_name the name, or key of the Persistent Admin Notice to be dismissed
912
+	 * @param bool          $purge
913
+	 * @param bool          $return_immediately
914
+	 * @return        void
915
+	 */
916
+	public static function dismiss_persistent_admin_notice($pan_name = '', $purge = false, $return_immediately = false)
917
+	{
918
+		$pan_name = EE_Registry::instance()->REQ->is_set('ee_nag_notice')
919
+			? EE_Registry::instance()->REQ->get('ee_nag_notice') : $pan_name;
920
+		if (! empty($pan_name)) {
921
+			$persistent_admin_notices = get_option('ee_pers_admin_notices', array());
922
+			// check if notice we wish to dismiss is actually in the $persistent_admin_notices array
923
+			if (is_array($persistent_admin_notices) && isset($persistent_admin_notices[$pan_name])) {
924
+				// completely delete nag notice, or just NULL message so that it can NOT be added again ?
925
+				if ($purge) {
926
+					unset($persistent_admin_notices[$pan_name]);
927
+				} else {
928
+					$persistent_admin_notices[$pan_name] = null;
929
+				}
930
+				if (update_option('ee_pers_admin_notices', $persistent_admin_notices) === false) {
931
+					EE_Error::add_error(sprintf(__('The persistent admin notice for "%s" could not be deleted.',
932
+						'event_espresso'), $pan_name), __FILE__, __FUNCTION__, __LINE__);
933
+				}
934
+			}
935
+		}
936
+		if ($return_immediately) {
937
+			return;
938
+		}
939
+		if (EE_Registry::instance()->REQ->ajax) {
940
+			// grab any notices and concatenate into string
941
+			echo wp_json_encode(array('errors' => implode('<br />', EE_Error::get_notices(false))));
942
+			exit();
943
+		}
944
+		// save errors to a transient to be displayed on next request (after redirect)
945
+		EE_Error::get_notices(false, true);
946
+		$return_url = EE_Registry::instance()->REQ->is_set('return_url')
947
+			? EE_Registry::instance()->REQ->get('return_url') : '';
948
+		wp_safe_redirect(urldecode($return_url));
949
+	}
950
+
951
+
952
+
953
+	/**
954
+	 * display_persistent_admin_notices
955
+	 *
956
+	 * @param  string $pan_name    the name, or key of the Persistent Admin Notice to be stored
957
+	 * @param  string $pan_message the message to be stored persistently until dismissed
958
+	 * @param  string $return_url  URL to go back to after nag notice is dismissed
959
+	 * @return string
960
+	 */
961
+	public static function display_persistent_admin_notices($pan_name = '', $pan_message = '', $return_url = '')
962
+	{
963
+		if (! empty($pan_name) && ! empty($pan_message)) {
964
+			$args = array(
965
+				'nag_notice'    => $pan_name,
966
+				'return_url'    => urlencode($return_url),
967
+				'ajax_url'      => WP_AJAX_URL,
968
+				'unknown_error' => esc_html__(
969
+					'An unknown error has occurred on the server while attempting to dismiss this notice.',
970
+					'event_espresso'
971
+				),
972
+			);
973
+			EE_Registry::$i18n_js_strings = array_merge(
974
+				EE_Registry::$i18n_js_strings,
975
+				array('ee_dismiss' => $args)
976
+			);
977
+			return '
978 978
 			<div id="'
979
-                   . $pan_name
980
-                   . '" class="espresso-notices updated ee-nag-notice clearfix" style="border-left: 4px solid #fcb93c;">
979
+				   . $pan_name
980
+				   . '" class="espresso-notices updated ee-nag-notice clearfix" style="border-left: 4px solid #fcb93c;">
981 981
 				<p>'
982
-                   . $pan_message
983
-                   . '</p>
982
+				   . $pan_message
983
+				   . '</p>
984 984
 				<a class="dismiss-ee-nag-notice hide-if-no-js" style="float: right; cursor: pointer; text-decoration:none;" rel="'
985
-                   . $pan_name
986
-                   . '">
985
+				   . $pan_name
986
+				   . '">
987 987
 					<span class="dashicons dashicons-dismiss" style="position:relative; top:-1px; margin-right:.25em;"></span>'
988
-                   . __('Dismiss', 'event_espresso')
989
-                   . '
988
+				   . __('Dismiss', 'event_espresso')
989
+				   . '
990 990
 				</a>
991 991
 				<div style="clear:both;"></div>
992 992
 			</div>';
993
-        }
994
-        return '';
995
-    }
996
-
997
-
998
-
999
-    /**
1000
-     *    get_persistent_admin_notices
1001
-     *
1002
-     * @param string $return_url
1003
-     * @return string
1004
-     */
1005
-    public static function get_persistent_admin_notices($return_url = '')
1006
-    {
1007
-        $notices = '';
1008
-        // check for persistent admin notices
1009
-        //filter the list though so plugins can notify the admin in a different way if they want
1010
-        $persistent_admin_notices = apply_filters(
1011
-            'FHEE__EE_Error__get_persistent_admin_notices',
1012
-            get_option('ee_pers_admin_notices', false),
1013
-            'ee_pers_admin_notices',
1014
-            $return_url
1015
-        );
1016
-        if ($persistent_admin_notices) {
1017
-            // load scripts
1018
-            wp_register_script(
1019
-                'espresso_core',
1020
-                EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
1021
-                array('jquery'),
1022
-                EVENT_ESPRESSO_VERSION,
1023
-                true
1024
-            );
1025
-            wp_register_script(
1026
-                'ee_error_js',
1027
-                EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js',
1028
-                array('espresso_core'),
1029
-                EVENT_ESPRESSO_VERSION,
1030
-                true
1031
-            );
1032
-            wp_enqueue_script('ee_error_js');
1033
-            // and display notices
1034
-            foreach ($persistent_admin_notices as $pan_name => $pan_message) {
1035
-                $notices .= self::display_persistent_admin_notices($pan_name, $pan_message, $return_url);
1036
-            }
1037
-        }
1038
-        return $notices;
1039
-    }
1040
-
1041
-
1042
-
1043
-    /**
1044
-     * _print_scripts
1045
-     *
1046
-     * @param    bool $force_print
1047
-     * @return    string
1048
-     */
1049
-    private static function _print_scripts($force_print = false)
1050
-    {
1051
-        if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) {
1052
-            if (wp_script_is('ee_error_js', 'enqueued')) {
1053
-                return '';
1054
-            }
1055
-            if (wp_script_is('ee_error_js', 'registered')) {
1056
-                wp_enqueue_style('espresso_default');
1057
-                wp_enqueue_style('espresso_custom_css');
1058
-                wp_enqueue_script('ee_error_js');
1059
-                wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug' => WP_DEBUG));
1060
-            }
1061
-        } else {
1062
-            return '
993
+		}
994
+		return '';
995
+	}
996
+
997
+
998
+
999
+	/**
1000
+	 *    get_persistent_admin_notices
1001
+	 *
1002
+	 * @param string $return_url
1003
+	 * @return string
1004
+	 */
1005
+	public static function get_persistent_admin_notices($return_url = '')
1006
+	{
1007
+		$notices = '';
1008
+		// check for persistent admin notices
1009
+		//filter the list though so plugins can notify the admin in a different way if they want
1010
+		$persistent_admin_notices = apply_filters(
1011
+			'FHEE__EE_Error__get_persistent_admin_notices',
1012
+			get_option('ee_pers_admin_notices', false),
1013
+			'ee_pers_admin_notices',
1014
+			$return_url
1015
+		);
1016
+		if ($persistent_admin_notices) {
1017
+			// load scripts
1018
+			wp_register_script(
1019
+				'espresso_core',
1020
+				EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
1021
+				array('jquery'),
1022
+				EVENT_ESPRESSO_VERSION,
1023
+				true
1024
+			);
1025
+			wp_register_script(
1026
+				'ee_error_js',
1027
+				EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js',
1028
+				array('espresso_core'),
1029
+				EVENT_ESPRESSO_VERSION,
1030
+				true
1031
+			);
1032
+			wp_enqueue_script('ee_error_js');
1033
+			// and display notices
1034
+			foreach ($persistent_admin_notices as $pan_name => $pan_message) {
1035
+				$notices .= self::display_persistent_admin_notices($pan_name, $pan_message, $return_url);
1036
+			}
1037
+		}
1038
+		return $notices;
1039
+	}
1040
+
1041
+
1042
+
1043
+	/**
1044
+	 * _print_scripts
1045
+	 *
1046
+	 * @param    bool $force_print
1047
+	 * @return    string
1048
+	 */
1049
+	private static function _print_scripts($force_print = false)
1050
+	{
1051
+		if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) {
1052
+			if (wp_script_is('ee_error_js', 'enqueued')) {
1053
+				return '';
1054
+			}
1055
+			if (wp_script_is('ee_error_js', 'registered')) {
1056
+				wp_enqueue_style('espresso_default');
1057
+				wp_enqueue_style('espresso_custom_css');
1058
+				wp_enqueue_script('ee_error_js');
1059
+				wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug' => WP_DEBUG));
1060
+			}
1061
+		} else {
1062
+			return '
1063 1063
 <script>
1064 1064
 /* <![CDATA[ */
1065 1065
 var ee_settings = {"wp_debug":"' . WP_DEBUG . '"};
@@ -1069,143 +1069,143 @@  discard block
 block discarded – undo
1069 1069
 <script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script>
1070 1070
 <script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script>
1071 1071
 ';
1072
-        }
1073
-        return '';
1074
-    }
1075
-
1076
-
1077
-
1078
-    /**
1079
-     *    enqueue_error_scripts
1080
-     *
1081
-     * @return        void
1082
-     */
1083
-    public static function enqueue_error_scripts()
1084
-    {
1085
-        self::_print_scripts();
1086
-    }
1087
-
1088
-
1089
-
1090
-    /**
1091
-     *    create error code from filepath, function name,
1092
-     *    and line number where exception or error was thrown
1093
-     *
1094
-     * @param string $file
1095
-     * @param string $func
1096
-     * @param string $line
1097
-     * @return string
1098
-     */
1099
-    public static function generate_error_code($file = '', $func = '', $line = '')
1100
-    {
1101
-        $file = explode('.', basename($file));
1102
-        $error_code = ! empty($file[0]) ? $file[0] : '';
1103
-        $error_code .= ! empty($func) ? ' - ' . $func : '';
1104
-        $error_code .= ! empty($line) ? ' - ' . $line : '';
1105
-        return $error_code;
1106
-    }
1107
-
1108
-
1109
-
1110
-    /**
1111
-     *    write exception details to log file
1112
-     *
1113
-     * @param int   $time
1114
-     * @param array $ex
1115
-     * @param bool  $clear
1116
-     * @return void
1117
-     */
1118
-    public function write_to_error_log($time = 0, $ex = array(), $clear = false)
1119
-    {
1120
-        if (empty($ex)) {
1121
-            return;
1122
-        }
1123
-        if (! $time) {
1124
-            $time = time();
1125
-        }
1126
-        $exception_log = '----------------------------------------------------------------------------------------'
1127
-                         . PHP_EOL;
1128
-        $exception_log .= '[' . date('Y-m-d H:i:s', $time) . ']  Exception Details' . PHP_EOL;
1129
-        $exception_log .= 'Message: ' . $ex['msg'] . PHP_EOL;
1130
-        $exception_log .= 'Code: ' . $ex['code'] . PHP_EOL;
1131
-        $exception_log .= 'File: ' . $ex['file'] . PHP_EOL;
1132
-        $exception_log .= 'Line No: ' . $ex['line'] . PHP_EOL;
1133
-        $exception_log .= 'Stack trace: ' . PHP_EOL;
1134
-        $exception_log .= $ex['string'] . PHP_EOL;
1135
-        $exception_log .= '----------------------------------------------------------------------------------------'
1136
-                          . PHP_EOL;
1137
-        try {
1138
-            EEH_File::ensure_file_exists_and_is_writable(
1139
-                EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file
1140
-            );
1141
-            EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR . 'logs');
1142
-            if (! $clear) {
1143
-                //get existing log file and append new log info
1144
-                $exception_log = EEH_File::get_file_contents(
1145
-                    EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file
1146
-                ) . $exception_log;
1147
-            }
1148
-            EEH_File::write_to_file(
1149
-                EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file,
1150
-                $exception_log
1151
-            );
1152
-        } catch (EE_Error $e) {
1153
-            EE_Error::add_error(sprintf(__('Event Espresso error logging could not be setup because: %s',
1154
-                'event_espresso'), $e->getMessage()));
1155
-            return;
1156
-        }
1157
-    }
1158
-
1159
-
1160
-
1161
-    /**
1162
-     * This is just a wrapper for the EEH_Debug_Tools::instance()->doing_it_wrong() method.
1163
-     * doing_it_wrong() is used in those cases where a normal PHP error won't get thrown,
1164
-     * but the code execution is done in a manner that could lead to unexpected results
1165
-     * (i.e. running to early, or too late in WP or EE loading process).
1166
-     * A good test for knowing whether to use this method is:
1167
-     * 1. Is there going to be a PHP error if something isn't setup/used correctly?
1168
-     * Yes -> use EE_Error::add_error() or throw new EE_Error()
1169
-     * 2. If this is loaded before something else, it won't break anything,
1170
-     * but just wont' do what its supposed to do? Yes -> use EE_Error::doing_it_wrong()
1171
-     *
1172
-     * @uses   constant WP_DEBUG test if wp_debug is on or not
1173
-     * @param string $function      The function that was called
1174
-     * @param string $message       A message explaining what has been done incorrectly
1175
-     * @param string $version       The version of Event Espresso where the error was added
1176
-     * @param string $applies_when  a version string for when you want the doing_it_wrong notice to begin appearing
1177
-     *                              for a deprecated function. This allows deprecation to occur during one version,
1178
-     *                              but not have any notices appear until a later version. This allows developers
1179
-     *                              extra time to update their code before notices appear.
1180
-     * @param int    $error_type
1181
-     */
1182
-    public static function doing_it_wrong(
1183
-        $function,
1184
-        $message,
1185
-        $version,
1186
-        $applies_when = '',
1187
-        $error_type = null
1188
-    ) {
1189
-        if (defined('WP_DEBUG') && WP_DEBUG) {
1190
-            EEH_Debug_Tools::instance()->doing_it_wrong($function, $message, $version, $applies_when, $error_type);
1191
-        }
1192
-    }
1193
-
1194
-
1195
-
1196
-    /**
1197
-     * Like get_notices, but returns an array of all the notices of the given type.
1198
-     *
1199
-     * @return array {
1200
-     * @type array $success   all the success messages
1201
-     * @type array $errors    all the error messages
1202
-     * @type array $attention all the attention messages
1203
-     * }
1204
-     */
1205
-    public static function get_raw_notices()
1206
-    {
1207
-        return self::$_espresso_notices;
1208
-    }
1072
+		}
1073
+		return '';
1074
+	}
1075
+
1076
+
1077
+
1078
+	/**
1079
+	 *    enqueue_error_scripts
1080
+	 *
1081
+	 * @return        void
1082
+	 */
1083
+	public static function enqueue_error_scripts()
1084
+	{
1085
+		self::_print_scripts();
1086
+	}
1087
+
1088
+
1089
+
1090
+	/**
1091
+	 *    create error code from filepath, function name,
1092
+	 *    and line number where exception or error was thrown
1093
+	 *
1094
+	 * @param string $file
1095
+	 * @param string $func
1096
+	 * @param string $line
1097
+	 * @return string
1098
+	 */
1099
+	public static function generate_error_code($file = '', $func = '', $line = '')
1100
+	{
1101
+		$file = explode('.', basename($file));
1102
+		$error_code = ! empty($file[0]) ? $file[0] : '';
1103
+		$error_code .= ! empty($func) ? ' - ' . $func : '';
1104
+		$error_code .= ! empty($line) ? ' - ' . $line : '';
1105
+		return $error_code;
1106
+	}
1107
+
1108
+
1109
+
1110
+	/**
1111
+	 *    write exception details to log file
1112
+	 *
1113
+	 * @param int   $time
1114
+	 * @param array $ex
1115
+	 * @param bool  $clear
1116
+	 * @return void
1117
+	 */
1118
+	public function write_to_error_log($time = 0, $ex = array(), $clear = false)
1119
+	{
1120
+		if (empty($ex)) {
1121
+			return;
1122
+		}
1123
+		if (! $time) {
1124
+			$time = time();
1125
+		}
1126
+		$exception_log = '----------------------------------------------------------------------------------------'
1127
+						 . PHP_EOL;
1128
+		$exception_log .= '[' . date('Y-m-d H:i:s', $time) . ']  Exception Details' . PHP_EOL;
1129
+		$exception_log .= 'Message: ' . $ex['msg'] . PHP_EOL;
1130
+		$exception_log .= 'Code: ' . $ex['code'] . PHP_EOL;
1131
+		$exception_log .= 'File: ' . $ex['file'] . PHP_EOL;
1132
+		$exception_log .= 'Line No: ' . $ex['line'] . PHP_EOL;
1133
+		$exception_log .= 'Stack trace: ' . PHP_EOL;
1134
+		$exception_log .= $ex['string'] . PHP_EOL;
1135
+		$exception_log .= '----------------------------------------------------------------------------------------'
1136
+						  . PHP_EOL;
1137
+		try {
1138
+			EEH_File::ensure_file_exists_and_is_writable(
1139
+				EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file
1140
+			);
1141
+			EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR . 'logs');
1142
+			if (! $clear) {
1143
+				//get existing log file and append new log info
1144
+				$exception_log = EEH_File::get_file_contents(
1145
+					EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file
1146
+				) . $exception_log;
1147
+			}
1148
+			EEH_File::write_to_file(
1149
+				EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file,
1150
+				$exception_log
1151
+			);
1152
+		} catch (EE_Error $e) {
1153
+			EE_Error::add_error(sprintf(__('Event Espresso error logging could not be setup because: %s',
1154
+				'event_espresso'), $e->getMessage()));
1155
+			return;
1156
+		}
1157
+	}
1158
+
1159
+
1160
+
1161
+	/**
1162
+	 * This is just a wrapper for the EEH_Debug_Tools::instance()->doing_it_wrong() method.
1163
+	 * doing_it_wrong() is used in those cases where a normal PHP error won't get thrown,
1164
+	 * but the code execution is done in a manner that could lead to unexpected results
1165
+	 * (i.e. running to early, or too late in WP or EE loading process).
1166
+	 * A good test for knowing whether to use this method is:
1167
+	 * 1. Is there going to be a PHP error if something isn't setup/used correctly?
1168
+	 * Yes -> use EE_Error::add_error() or throw new EE_Error()
1169
+	 * 2. If this is loaded before something else, it won't break anything,
1170
+	 * but just wont' do what its supposed to do? Yes -> use EE_Error::doing_it_wrong()
1171
+	 *
1172
+	 * @uses   constant WP_DEBUG test if wp_debug is on or not
1173
+	 * @param string $function      The function that was called
1174
+	 * @param string $message       A message explaining what has been done incorrectly
1175
+	 * @param string $version       The version of Event Espresso where the error was added
1176
+	 * @param string $applies_when  a version string for when you want the doing_it_wrong notice to begin appearing
1177
+	 *                              for a deprecated function. This allows deprecation to occur during one version,
1178
+	 *                              but not have any notices appear until a later version. This allows developers
1179
+	 *                              extra time to update their code before notices appear.
1180
+	 * @param int    $error_type
1181
+	 */
1182
+	public static function doing_it_wrong(
1183
+		$function,
1184
+		$message,
1185
+		$version,
1186
+		$applies_when = '',
1187
+		$error_type = null
1188
+	) {
1189
+		if (defined('WP_DEBUG') && WP_DEBUG) {
1190
+			EEH_Debug_Tools::instance()->doing_it_wrong($function, $message, $version, $applies_when, $error_type);
1191
+		}
1192
+	}
1193
+
1194
+
1195
+
1196
+	/**
1197
+	 * Like get_notices, but returns an array of all the notices of the given type.
1198
+	 *
1199
+	 * @return array {
1200
+	 * @type array $success   all the success messages
1201
+	 * @type array $errors    all the error messages
1202
+	 * @type array $attention all the attention messages
1203
+	 * }
1204
+	 */
1205
+	public static function get_raw_notices()
1206
+	{
1207
+		return self::$_espresso_notices;
1208
+	}
1209 1209
 
1210 1210
 
1211 1211
 
@@ -1221,27 +1221,27 @@  discard block
 block discarded – undo
1221 1221
  */
1222 1222
 function espresso_error_enqueue_scripts()
1223 1223
 {
1224
-    // js for error handling
1225
-    wp_register_script(
1226
-        'espresso_core',
1227
-        EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
1228
-        array('jquery'),
1229
-        EVENT_ESPRESSO_VERSION,
1230
-        false
1231
-    );
1232
-    wp_register_script(
1233
-        'ee_error_js',
1234
-        EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js',
1235
-        array('espresso_core'),
1236
-        EVENT_ESPRESSO_VERSION,
1237
-        false
1238
-    );
1224
+	// js for error handling
1225
+	wp_register_script(
1226
+		'espresso_core',
1227
+		EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
1228
+		array('jquery'),
1229
+		EVENT_ESPRESSO_VERSION,
1230
+		false
1231
+	);
1232
+	wp_register_script(
1233
+		'ee_error_js',
1234
+		EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js',
1235
+		array('espresso_core'),
1236
+		EVENT_ESPRESSO_VERSION,
1237
+		false
1238
+	);
1239 1239
 }
1240 1240
 
1241 1241
 if (is_admin()) {
1242
-    add_action('admin_enqueue_scripts', 'espresso_error_enqueue_scripts', 2);
1242
+	add_action('admin_enqueue_scripts', 'espresso_error_enqueue_scripts', 2);
1243 1243
 } else {
1244
-    add_action('wp_enqueue_scripts', 'espresso_error_enqueue_scripts', 2);
1244
+	add_action('wp_enqueue_scripts', 'espresso_error_enqueue_scripts', 2);
1245 1245
 }
1246 1246
 
1247 1247
 
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +219 added lines, -219 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('ABSPATH')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /*
5 5
   Plugin Name:		Event Espresso
@@ -40,243 +40,243 @@  discard block
 block discarded – undo
40 40
  * @since            4.0
41 41
  */
42 42
 if (function_exists('espresso_version')) {
43
-    /**
44
-     *    espresso_duplicate_plugin_error
45
-     *    displays if more than one version of EE is activated at the same time
46
-     */
47
-    function espresso_duplicate_plugin_error()
48
-    {
49
-        ?>
43
+	/**
44
+	 *    espresso_duplicate_plugin_error
45
+	 *    displays if more than one version of EE is activated at the same time
46
+	 */
47
+	function espresso_duplicate_plugin_error()
48
+	{
49
+		?>
50 50
         <div class="error">
51 51
             <p>
52 52
                 <?php echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                ); ?>
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+				); ?>
56 56
             </p>
57 57
         </div>
58 58
         <?php
59
-        espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-    }
59
+		espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+	}
61 61
 
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
65
-    if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
65
+	if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                            esc_html__(
79
-                                    'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                                    'event_espresso'
81
-                            ),
82
-                            EE_MIN_PHP_VER_REQUIRED,
83
-                            PHP_VERSION,
84
-                            '<br/>',
85
-                            '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+							esc_html__(
79
+									'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+									'event_espresso'
81
+							),
82
+							EE_MIN_PHP_VER_REQUIRED,
83
+							PHP_VERSION,
84
+							'<br/>',
85
+							'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        /**
97
-         * espresso_version
98
-         * Returns the plugin version
99
-         *
100
-         * @return string
101
-         */
102
-        function espresso_version()
103
-        {
104
-            return apply_filters('FHEE__espresso__espresso_version', '4.9.44.rc.028');
105
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		/**
97
+		 * espresso_version
98
+		 * Returns the plugin version
99
+		 *
100
+		 * @return string
101
+		 */
102
+		function espresso_version()
103
+		{
104
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.44.rc.028');
105
+		}
106 106
 
107
-        // define versions
108
-        define('EVENT_ESPRESSO_VERSION', espresso_version());
109
-        define('EE_MIN_WP_VER_REQUIRED', '4.1');
110
-        define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
111
-        define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
112
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
113
-        //used to be DIRECTORY_SEPARATOR, but that caused issues on windows
114
-        if ( ! defined('DS')) {
115
-            define('DS', '/');
116
-        }
117
-        if ( ! defined('PS')) {
118
-            define('PS', PATH_SEPARATOR);
119
-        }
120
-        if ( ! defined('SP')) {
121
-            define('SP', ' ');
122
-        }
123
-        if ( ! defined('EENL')) {
124
-            define('EENL', "\n");
125
-        }
126
-        define('EE_SUPPORT_EMAIL', '[email protected]');
127
-        // define the plugin directory and URL
128
-        define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
129
-        define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
130
-        define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
131
-        // main root folder paths
132
-        define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS);
133
-        define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS);
134
-        define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS);
135
-        define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS);
136
-        define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS);
137
-        define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS);
138
-        define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS);
139
-        define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS);
140
-        // core system paths
141
-        define('EE_ADMIN', EE_CORE . 'admin' . DS);
142
-        define('EE_CPTS', EE_CORE . 'CPTs' . DS);
143
-        define('EE_CLASSES', EE_CORE . 'db_classes' . DS);
144
-        define('EE_INTERFACES', EE_CORE . 'interfaces' . DS);
145
-        define('EE_BUSINESS', EE_CORE . 'business' . DS);
146
-        define('EE_MODELS', EE_CORE . 'db_models' . DS);
147
-        define('EE_HELPERS', EE_CORE . 'helpers' . DS);
148
-        define('EE_LIBRARIES', EE_CORE . 'libraries' . DS);
149
-        define('EE_TEMPLATES', EE_CORE . 'templates' . DS);
150
-        define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS);
151
-        define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS);
152
-        define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS);
153
-        // gateways
154
-        define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS);
155
-        define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS);
156
-        // asset URL paths
157
-        define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS);
158
-        define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS);
159
-        define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS);
160
-        define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS);
161
-        define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/');
162
-        define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/');
163
-        // define upload paths
164
-        $uploads = wp_upload_dir();
165
-        // define the uploads directory and URL
166
-        define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS);
167
-        define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS);
168
-        // define the templates directory and URL
169
-        define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS);
170
-        define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS);
171
-        // define the gateway directory and URL
172
-        define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS);
173
-        define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS);
174
-        // languages folder/path
175
-        define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS);
176
-        define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS);
177
-        //check for dompdf fonts in uploads
178
-        if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) {
179
-            define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS);
180
-        }
181
-        //ajax constants
182
-        define(
183
-                'EE_FRONT_AJAX',
184
-                isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false
185
-        );
186
-        define(
187
-                'EE_ADMIN_AJAX',
188
-                isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false
189
-        );
190
-        //just a handy constant occasionally needed for finding values representing infinity in the DB
191
-        //you're better to use this than its straight value (currently -1) in case you ever
192
-        //want to change its default value! or find when -1 means infinity
193
-        define('EE_INF_IN_DB', -1);
194
-        define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX);
195
-        define('EE_DEBUG', false);
196
-        // for older WP versions
197
-        if ( ! defined('MONTH_IN_SECONDS')) {
198
-            define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
199
-        }
200
-        /**
201
-         *    espresso_plugin_activation
202
-         *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
203
-         */
204
-        function espresso_plugin_activation()
205
-        {
206
-            update_option('ee_espresso_activation', true);
207
-        }
107
+		// define versions
108
+		define('EVENT_ESPRESSO_VERSION', espresso_version());
109
+		define('EE_MIN_WP_VER_REQUIRED', '4.1');
110
+		define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
111
+		define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
112
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
113
+		//used to be DIRECTORY_SEPARATOR, but that caused issues on windows
114
+		if ( ! defined('DS')) {
115
+			define('DS', '/');
116
+		}
117
+		if ( ! defined('PS')) {
118
+			define('PS', PATH_SEPARATOR);
119
+		}
120
+		if ( ! defined('SP')) {
121
+			define('SP', ' ');
122
+		}
123
+		if ( ! defined('EENL')) {
124
+			define('EENL', "\n");
125
+		}
126
+		define('EE_SUPPORT_EMAIL', '[email protected]');
127
+		// define the plugin directory and URL
128
+		define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
129
+		define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
130
+		define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
131
+		// main root folder paths
132
+		define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS);
133
+		define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS);
134
+		define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS);
135
+		define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS);
136
+		define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS);
137
+		define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS);
138
+		define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS);
139
+		define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS);
140
+		// core system paths
141
+		define('EE_ADMIN', EE_CORE . 'admin' . DS);
142
+		define('EE_CPTS', EE_CORE . 'CPTs' . DS);
143
+		define('EE_CLASSES', EE_CORE . 'db_classes' . DS);
144
+		define('EE_INTERFACES', EE_CORE . 'interfaces' . DS);
145
+		define('EE_BUSINESS', EE_CORE . 'business' . DS);
146
+		define('EE_MODELS', EE_CORE . 'db_models' . DS);
147
+		define('EE_HELPERS', EE_CORE . 'helpers' . DS);
148
+		define('EE_LIBRARIES', EE_CORE . 'libraries' . DS);
149
+		define('EE_TEMPLATES', EE_CORE . 'templates' . DS);
150
+		define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS);
151
+		define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS);
152
+		define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS);
153
+		// gateways
154
+		define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS);
155
+		define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS);
156
+		// asset URL paths
157
+		define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS);
158
+		define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS);
159
+		define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS);
160
+		define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS);
161
+		define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/');
162
+		define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/');
163
+		// define upload paths
164
+		$uploads = wp_upload_dir();
165
+		// define the uploads directory and URL
166
+		define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS);
167
+		define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS);
168
+		// define the templates directory and URL
169
+		define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS);
170
+		define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS);
171
+		// define the gateway directory and URL
172
+		define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS);
173
+		define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS);
174
+		// languages folder/path
175
+		define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS);
176
+		define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS);
177
+		//check for dompdf fonts in uploads
178
+		if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) {
179
+			define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS);
180
+		}
181
+		//ajax constants
182
+		define(
183
+				'EE_FRONT_AJAX',
184
+				isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false
185
+		);
186
+		define(
187
+				'EE_ADMIN_AJAX',
188
+				isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false
189
+		);
190
+		//just a handy constant occasionally needed for finding values representing infinity in the DB
191
+		//you're better to use this than its straight value (currently -1) in case you ever
192
+		//want to change its default value! or find when -1 means infinity
193
+		define('EE_INF_IN_DB', -1);
194
+		define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX);
195
+		define('EE_DEBUG', false);
196
+		// for older WP versions
197
+		if ( ! defined('MONTH_IN_SECONDS')) {
198
+			define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
199
+		}
200
+		/**
201
+		 *    espresso_plugin_activation
202
+		 *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
203
+		 */
204
+		function espresso_plugin_activation()
205
+		{
206
+			update_option('ee_espresso_activation', true);
207
+		}
208 208
 
209
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
210
-        /**
211
-         *    espresso_load_error_handling
212
-         *    this function loads EE's class for handling exceptions and errors
213
-         */
214
-        function espresso_load_error_handling()
215
-        {
216
-            // load debugging tools
217
-            if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
218
-                require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
219
-                EEH_Debug_Tools::instance();
220
-            }
221
-            // load error handling
222
-            if (is_readable(EE_CORE . 'EE_Error.core.php')) {
223
-                require_once(EE_CORE . 'EE_Error.core.php');
224
-            } else {
225
-                wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
226
-            }
227
-        }
209
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
210
+		/**
211
+		 *    espresso_load_error_handling
212
+		 *    this function loads EE's class for handling exceptions and errors
213
+		 */
214
+		function espresso_load_error_handling()
215
+		{
216
+			// load debugging tools
217
+			if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
218
+				require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
219
+				EEH_Debug_Tools::instance();
220
+			}
221
+			// load error handling
222
+			if (is_readable(EE_CORE . 'EE_Error.core.php')) {
223
+				require_once(EE_CORE . 'EE_Error.core.php');
224
+			} else {
225
+				wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
226
+			}
227
+		}
228 228
 
229
-        /**
230
-         *    espresso_load_required
231
-         *    given a class name and path, this function will load that file or throw an exception
232
-         *
233
-         * @param    string $classname
234
-         * @param    string $full_path_to_file
235
-         * @throws    EE_Error
236
-         */
237
-        function espresso_load_required($classname, $full_path_to_file)
238
-        {
239
-            static $error_handling_loaded = false;
240
-            if ( ! $error_handling_loaded) {
241
-                espresso_load_error_handling();
242
-                $error_handling_loaded = true;
243
-            }
244
-            if (is_readable($full_path_to_file)) {
245
-                require_once($full_path_to_file);
246
-            } else {
247
-                throw new EE_Error (
248
-                        sprintf(
249
-                                esc_html__(
250
-                                        'The %s class file could not be located or is not readable due to file permissions.',
251
-                                        'event_espresso'
252
-                                ),
253
-                                $classname
254
-                        )
255
-                );
256
-            }
257
-        }
229
+		/**
230
+		 *    espresso_load_required
231
+		 *    given a class name and path, this function will load that file or throw an exception
232
+		 *
233
+		 * @param    string $classname
234
+		 * @param    string $full_path_to_file
235
+		 * @throws    EE_Error
236
+		 */
237
+		function espresso_load_required($classname, $full_path_to_file)
238
+		{
239
+			static $error_handling_loaded = false;
240
+			if ( ! $error_handling_loaded) {
241
+				espresso_load_error_handling();
242
+				$error_handling_loaded = true;
243
+			}
244
+			if (is_readable($full_path_to_file)) {
245
+				require_once($full_path_to_file);
246
+			} else {
247
+				throw new EE_Error (
248
+						sprintf(
249
+								esc_html__(
250
+										'The %s class file could not be located or is not readable due to file permissions.',
251
+										'event_espresso'
252
+								),
253
+								$classname
254
+						)
255
+				);
256
+			}
257
+		}
258 258
 
259
-        espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
260
-        espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
261
-        espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
262
-        new EE_Bootstrap();
263
-    }
259
+		espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
260
+		espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
261
+		espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
262
+		new EE_Bootstrap();
263
+	}
264 264
 }
265 265
 if ( ! function_exists('espresso_deactivate_plugin')) {
266
-    /**
267
-     *    deactivate_plugin
268
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
269
-     *
270
-     * @access public
271
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
272
-     * @return    void
273
-     */
274
-    function espresso_deactivate_plugin($plugin_basename = '')
275
-    {
276
-        if ( ! function_exists('deactivate_plugins')) {
277
-            require_once(ABSPATH . 'wp-admin/includes/plugin.php');
278
-        }
279
-        unset($_GET['activate'], $_REQUEST['activate']);
280
-        deactivate_plugins($plugin_basename);
281
-    }
266
+	/**
267
+	 *    deactivate_plugin
268
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
269
+	 *
270
+	 * @access public
271
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
272
+	 * @return    void
273
+	 */
274
+	function espresso_deactivate_plugin($plugin_basename = '')
275
+	{
276
+		if ( ! function_exists('deactivate_plugins')) {
277
+			require_once(ABSPATH . 'wp-admin/includes/plugin.php');
278
+		}
279
+		unset($_GET['activate'], $_REQUEST['activate']);
280
+		deactivate_plugins($plugin_basename);
281
+	}
282 282
 }
283 283
\ No newline at end of file
Please login to merge, or discard this patch.
core/helpers/EEH_Event_View.helper.php 2 patches
Indentation   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -32,51 +32,51 @@  discard block
 block discarded – undo
32 32
 
33 33
 
34 34
 
35
-    /**
36
-     * get_event
37
-     * attempts to retrieve an EE_Event object any way it can
38
-     *
39
-     * @param int|WP_Post $EVT_ID
40
-     * @return EE_Event|null
41
-     * @throws \EE_Error
42
-     */
43
-    public static function get_event($EVT_ID = 0)
44
-    {
45
-        // international newspaper?
46
-        global $post;
47
-        $EVT_ID = $EVT_ID instanceof WP_Post && $EVT_ID->post_type === 'espresso_events'
48
-            ? $EVT_ID->ID
49
-            : absint($EVT_ID);
50
-        // do we already have the Event  you are looking for?
51
-        if (EEH_Event_View::$_event instanceof EE_Event && $EVT_ID && EEH_Event_View::$_event->ID() === $EVT_ID) {
52
-            return EEH_Event_View::$_event;
53
-        }
54
-        //reset property so that the new event is cached.
55
-        EEH_Event_View::$_event = null;
56
-        if (! $EVT_ID && $post instanceof EE_Event) {
57
-            EEH_Event_View::$_event = $post;
58
-            return EEH_Event_View::$_event;
59
-        }
60
-        //if the post type is for an event and it has a cached event and we don't have a different incoming $EVT_ID
61
-        //then let's just use that cached event on the $post object.
62
-        if (
63
-            $post instanceof WP_Post
64
-            && $post->post_type === 'espresso_events'
65
-            && isset($post->EE_Event)
66
-            && (
67
-                $EVT_ID === 0
68
-                || $EVT_ID === $post->ID
69
-            )
70
-        ) {
71
-            EEH_Event_View::$_event = $post->EE_Event;
72
-            return EEH_Event_View::$_event;
73
-        }
74
-        //If the event we have isn't an event but we do have an EVT_ID, let's try getting the event using the ID.
75
-        if (! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) {
76
-            EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
77
-        }
78
-        return EEH_Event_View::$_event;
79
-    }
35
+	/**
36
+	 * get_event
37
+	 * attempts to retrieve an EE_Event object any way it can
38
+	 *
39
+	 * @param int|WP_Post $EVT_ID
40
+	 * @return EE_Event|null
41
+	 * @throws \EE_Error
42
+	 */
43
+	public static function get_event($EVT_ID = 0)
44
+	{
45
+		// international newspaper?
46
+		global $post;
47
+		$EVT_ID = $EVT_ID instanceof WP_Post && $EVT_ID->post_type === 'espresso_events'
48
+			? $EVT_ID->ID
49
+			: absint($EVT_ID);
50
+		// do we already have the Event  you are looking for?
51
+		if (EEH_Event_View::$_event instanceof EE_Event && $EVT_ID && EEH_Event_View::$_event->ID() === $EVT_ID) {
52
+			return EEH_Event_View::$_event;
53
+		}
54
+		//reset property so that the new event is cached.
55
+		EEH_Event_View::$_event = null;
56
+		if (! $EVT_ID && $post instanceof EE_Event) {
57
+			EEH_Event_View::$_event = $post;
58
+			return EEH_Event_View::$_event;
59
+		}
60
+		//if the post type is for an event and it has a cached event and we don't have a different incoming $EVT_ID
61
+		//then let's just use that cached event on the $post object.
62
+		if (
63
+			$post instanceof WP_Post
64
+			&& $post->post_type === 'espresso_events'
65
+			&& isset($post->EE_Event)
66
+			&& (
67
+				$EVT_ID === 0
68
+				|| $EVT_ID === $post->ID
69
+			)
70
+		) {
71
+			EEH_Event_View::$_event = $post->EE_Event;
72
+			return EEH_Event_View::$_event;
73
+		}
74
+		//If the event we have isn't an event but we do have an EVT_ID, let's try getting the event using the ID.
75
+		if (! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) {
76
+			EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
77
+		}
78
+		return EEH_Event_View::$_event;
79
+	}
80 80
 
81 81
 
82 82
 
@@ -152,58 +152,58 @@  discard block
 block discarded – undo
152 152
 	 * @return    string
153 153
 	 */
154 154
 	public static function event_content_or_excerpt( $num_words = NULL, $more = NULL ) {
155
-        global $post;
155
+		global $post;
156 156
 		ob_start();
157 157
 		if (( is_single() ) || ( is_archive() && espresso_display_full_description_in_event_list() )) {
158 158
 			// admin has chosen "full description"
159
-            // for the "Event Espresso - Events > Templates > Display Description" option
159
+			// for the "Event Espresso - Events > Templates > Display Description" option
160 160
 			the_content();
161 161
 		} else if (( is_archive() && espresso_display_excerpt_in_event_list() ) ) {
162
-            if ( has_excerpt( $post->ID )) {
163
-                // admin has chosen "excerpt (short desc)"
164
-                // for the "Event Espresso - Events > Templates > Display Description" option
165
-                // AND an excerpt actually exists
166
-                the_excerpt();
167
-            } else {
168
-                // admin has chosen "excerpt (short desc)"
169
-                // for the "Event Espresso - Events > Templates > Display Description" option
170
-                // but NO excerpt actually exists, so we need to create one
171
-                if ( ! empty( $num_words )) {
172
-                    if ( empty( $more )) {
173
-                        $more_link_text = __( '(more&hellip;)' );
174
-                        $more = ' <a href="' . get_permalink() . '"';
175
-                        $more .= ' class="more-link"';
176
-                        $more .= \EED_Events_Archive::link_target();
177
-                        $more .= '>' . $more_link_text . '</a>';
178
-                        $more = apply_filters( 'the_content_more_link', $more, $more_link_text );
179
-                    }
180
-                    $content = str_replace( 'NOMORELINK', '', get_the_content( 'NOMORELINK' ));
181
-
182
-                    $content =  wp_trim_words( $content, $num_words, ' ' ) . $more;
183
-                } else {
184
-                    $content =  get_the_content();
185
-                }
186
-                global $allowedtags;
187
-                // make sure links are allowed
188
-                $allowedtags['a'] = isset($allowedtags['a'])
189
-                    ? $allowedtags['a']
190
-                    : array();
191
-                // as well as target attribute
192
-                $allowedtags['a']['target'] = isset($allowedtags['a']['target'])
193
-                    ? $allowedtags['a']['target']
194
-                    : false;
195
-                // but get previous value so we can reset it
196
-                $prev_value = $allowedtags['a']['target'];
197
-                $allowedtags['a']['target'] = true;
198
-                $content = wp_kses( $content, $allowedtags );
199
-                $content = strip_shortcodes( $content );
200
-                echo apply_filters( 'the_content', $content );
201
-                $allowedtags['a']['target'] = $prev_value;
202
-            }
203
-        } else {
204
-            // admin has chosen "none"
205
-            // for the "Event Espresso - Events > Templates > Display Description" option
206
-            echo apply_filters( 'the_content', '' );
162
+			if ( has_excerpt( $post->ID )) {
163
+				// admin has chosen "excerpt (short desc)"
164
+				// for the "Event Espresso - Events > Templates > Display Description" option
165
+				// AND an excerpt actually exists
166
+				the_excerpt();
167
+			} else {
168
+				// admin has chosen "excerpt (short desc)"
169
+				// for the "Event Espresso - Events > Templates > Display Description" option
170
+				// but NO excerpt actually exists, so we need to create one
171
+				if ( ! empty( $num_words )) {
172
+					if ( empty( $more )) {
173
+						$more_link_text = __( '(more&hellip;)' );
174
+						$more = ' <a href="' . get_permalink() . '"';
175
+						$more .= ' class="more-link"';
176
+						$more .= \EED_Events_Archive::link_target();
177
+						$more .= '>' . $more_link_text . '</a>';
178
+						$more = apply_filters( 'the_content_more_link', $more, $more_link_text );
179
+					}
180
+					$content = str_replace( 'NOMORELINK', '', get_the_content( 'NOMORELINK' ));
181
+
182
+					$content =  wp_trim_words( $content, $num_words, ' ' ) . $more;
183
+				} else {
184
+					$content =  get_the_content();
185
+				}
186
+				global $allowedtags;
187
+				// make sure links are allowed
188
+				$allowedtags['a'] = isset($allowedtags['a'])
189
+					? $allowedtags['a']
190
+					: array();
191
+				// as well as target attribute
192
+				$allowedtags['a']['target'] = isset($allowedtags['a']['target'])
193
+					? $allowedtags['a']['target']
194
+					: false;
195
+				// but get previous value so we can reset it
196
+				$prev_value = $allowedtags['a']['target'];
197
+				$allowedtags['a']['target'] = true;
198
+				$content = wp_kses( $content, $allowedtags );
199
+				$content = strip_shortcodes( $content );
200
+				echo apply_filters( 'the_content', $content );
201
+				$allowedtags['a']['target'] = $prev_value;
202
+			}
203
+		} else {
204
+			// admin has chosen "none"
205
+			// for the "Event Espresso - Events > Templates > Display Description" option
206
+			echo apply_filters( 'the_content', '' );
207 207
 		}
208 208
 		return ob_get_clean();
209 209
 	}
@@ -250,11 +250,11 @@  discard block
 block discarded – undo
250 250
 					$url = get_term_link( $term, 'espresso_venue_categories' );
251 251
 					if ( ! is_wp_error( $url ) && (( $hide_uncategorized && strtolower( $term->name ) != __( 'uncategorized', 'event_espresso' )) || ! $hide_uncategorized )) {
252 252
 						$category_links[] = '<a href="' . esc_url( $url )
253
-                                            . '" rel="tag"'
254
-                                            . \EED_Events_Archive::link_target()
255
-                                            .'>'
256
-                                            . $term->name
257
-                                            . '</a>';
253
+											. '" rel="tag"'
254
+											. \EED_Events_Archive::link_target()
255
+											.'>'
256
+											. $term->name
257
+											. '</a>';
258 258
 					}
259 259
 				}
260 260
 			}
Please login to merge, or discard this patch.
Spacing   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
         }
54 54
         //reset property so that the new event is cached.
55 55
         EEH_Event_View::$_event = null;
56
-        if (! $EVT_ID && $post instanceof EE_Event) {
56
+        if ( ! $EVT_ID && $post instanceof EE_Event) {
57 57
             EEH_Event_View::$_event = $post;
58 58
             return EEH_Event_View::$_event;
59 59
         }
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
             return EEH_Event_View::$_event;
73 73
         }
74 74
         //If the event we have isn't an event but we do have an EVT_ID, let's try getting the event using the ID.
75
-        if (! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) {
75
+        if ( ! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) {
76 76
             EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
77 77
         }
78 78
         return EEH_Event_View::$_event;
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 	 * @param    int $EVT_ID
88 88
 	 * @return    boolean
89 89
 	 */
90
-	public static function display_ticket_selector( $EVT_ID = 0 ) {
91
-		$event = EEH_Event_View::get_event( $EVT_ID );
90
+	public static function display_ticket_selector($EVT_ID = 0) {
91
+		$event = EEH_Event_View::get_event($EVT_ID);
92 92
 		return $event instanceof EE_Event ? $event->display_ticket_selector() : FALSE;
93 93
 	}
94 94
 
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
 	 * @param    int $EVT_ID
102 102
 	 * @return    string
103 103
 	 */
104
-	public static function event_status( $EVT_ID = 0 ) {
105
-		$event = EEH_Event_View::get_event( $EVT_ID );
106
-		return $event instanceof EE_Event ? $event->pretty_active_status( FALSE ) : '';
104
+	public static function event_status($EVT_ID = 0) {
105
+		$event = EEH_Event_View::get_event($EVT_ID);
106
+		return $event instanceof EE_Event ? $event->pretty_active_status(FALSE) : '';
107 107
 	}
108 108
 
109 109
 
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
 	 * @param    int $EVT_ID
116 116
 	 *  @return 	string
117 117
 	 */
118
-	public static function event_active_status( $EVT_ID = 0 ) {
119
-		$event = EEH_Event_View::get_event( $EVT_ID );
118
+	public static function event_active_status($EVT_ID = 0) {
119
+		$event = EEH_Event_View::get_event($EVT_ID);
120 120
 		return $event instanceof EE_Event ? $event->pretty_active_status() : 'inactive';
121 121
 	}
122 122
 
@@ -129,13 +129,13 @@  discard block
 block discarded – undo
129 129
 	 * @param    int $EVT_ID
130 130
 	 *  @return 	string
131 131
 	 */
132
-	public static function event_has_content_or_excerpt( $EVT_ID = 0 ) {
133
-		$event = EEH_Event_View::get_event( $EVT_ID );
132
+	public static function event_has_content_or_excerpt($EVT_ID = 0) {
133
+		$event = EEH_Event_View::get_event($EVT_ID);
134 134
 		$has_content_or_excerpt = FALSE;
135
-		if ( $event instanceof EE_Event ) {
136
-			$has_content_or_excerpt = $event->description() != '' || $event->short_description( NULL, NULL, TRUE ) != '' ? TRUE : FALSE;
135
+		if ($event instanceof EE_Event) {
136
+			$has_content_or_excerpt = $event->description() != '' || $event->short_description(NULL, NULL, TRUE) != '' ? TRUE : FALSE;
137 137
 		}
138
-		if ( is_archive() && ! ( espresso_display_full_description_in_event_list() || espresso_display_excerpt_in_event_list() )) {
138
+		if (is_archive() && ! (espresso_display_full_description_in_event_list() || espresso_display_excerpt_in_event_list())) {
139 139
 			$has_content_or_excerpt = FALSE;
140 140
 		}
141 141
 		return $has_content_or_excerpt;
@@ -151,15 +151,15 @@  discard block
 block discarded – undo
151 151
 	 * @param null $more
152 152
 	 * @return    string
153 153
 	 */
154
-	public static function event_content_or_excerpt( $num_words = NULL, $more = NULL ) {
154
+	public static function event_content_or_excerpt($num_words = NULL, $more = NULL) {
155 155
         global $post;
156 156
 		ob_start();
157
-		if (( is_single() ) || ( is_archive() && espresso_display_full_description_in_event_list() )) {
157
+		if ((is_single()) || (is_archive() && espresso_display_full_description_in_event_list())) {
158 158
 			// admin has chosen "full description"
159 159
             // for the "Event Espresso - Events > Templates > Display Description" option
160 160
 			the_content();
161
-		} else if (( is_archive() && espresso_display_excerpt_in_event_list() ) ) {
162
-            if ( has_excerpt( $post->ID )) {
161
+		} else if ((is_archive() && espresso_display_excerpt_in_event_list())) {
162
+            if (has_excerpt($post->ID)) {
163 163
                 // admin has chosen "excerpt (short desc)"
164 164
                 // for the "Event Espresso - Events > Templates > Display Description" option
165 165
                 // AND an excerpt actually exists
@@ -168,20 +168,20 @@  discard block
 block discarded – undo
168 168
                 // admin has chosen "excerpt (short desc)"
169 169
                 // for the "Event Espresso - Events > Templates > Display Description" option
170 170
                 // but NO excerpt actually exists, so we need to create one
171
-                if ( ! empty( $num_words )) {
172
-                    if ( empty( $more )) {
173
-                        $more_link_text = __( '(more&hellip;)' );
174
-                        $more = ' <a href="' . get_permalink() . '"';
171
+                if ( ! empty($num_words)) {
172
+                    if (empty($more)) {
173
+                        $more_link_text = __('(more&hellip;)');
174
+                        $more = ' <a href="'.get_permalink().'"';
175 175
                         $more .= ' class="more-link"';
176 176
                         $more .= \EED_Events_Archive::link_target();
177
-                        $more .= '>' . $more_link_text . '</a>';
178
-                        $more = apply_filters( 'the_content_more_link', $more, $more_link_text );
177
+                        $more .= '>'.$more_link_text.'</a>';
178
+                        $more = apply_filters('the_content_more_link', $more, $more_link_text);
179 179
                     }
180
-                    $content = str_replace( 'NOMORELINK', '', get_the_content( 'NOMORELINK' ));
180
+                    $content = str_replace('NOMORELINK', '', get_the_content('NOMORELINK'));
181 181
 
182
-                    $content =  wp_trim_words( $content, $num_words, ' ' ) . $more;
182
+                    $content = wp_trim_words($content, $num_words, ' ').$more;
183 183
                 } else {
184
-                    $content =  get_the_content();
184
+                    $content = get_the_content();
185 185
                 }
186 186
                 global $allowedtags;
187 187
                 // make sure links are allowed
@@ -195,15 +195,15 @@  discard block
 block discarded – undo
195 195
                 // but get previous value so we can reset it
196 196
                 $prev_value = $allowedtags['a']['target'];
197 197
                 $allowedtags['a']['target'] = true;
198
-                $content = wp_kses( $content, $allowedtags );
199
-                $content = strip_shortcodes( $content );
200
-                echo apply_filters( 'the_content', $content );
198
+                $content = wp_kses($content, $allowedtags);
199
+                $content = strip_shortcodes($content);
200
+                echo apply_filters('the_content', $content);
201 201
                 $allowedtags['a']['target'] = $prev_value;
202 202
             }
203 203
         } else {
204 204
             // admin has chosen "none"
205 205
             // for the "Event Espresso - Events > Templates > Display Description" option
206
-            echo apply_filters( 'the_content', '' );
206
+            echo apply_filters('the_content', '');
207 207
 		}
208 208
 		return ob_get_clean();
209 209
 	}
@@ -217,13 +217,13 @@  discard block
 block discarded – undo
217 217
 	 * @param    int $EVT_ID
218 218
 	 *  @return 	EE_Ticket[]
219 219
 	 */
220
-	public static function event_tickets_available( $EVT_ID = 0 ) {
221
-		$event = EEH_Event_View::get_event( $EVT_ID );
220
+	public static function event_tickets_available($EVT_ID = 0) {
221
+		$event = EEH_Event_View::get_event($EVT_ID);
222 222
 		$tickets_available_for_purchase = array();
223
-		if( $event instanceof EE_Event ) {
224
-			$datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID, FALSE );
225
-			foreach( $datetimes as $datetime ) {
226
-				$tickets_available_for_purchase = array_merge( $tickets_available_for_purchase, $datetime->ticket_types_available_for_purchase() );
223
+		if ($event instanceof EE_Event) {
224
+			$datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, FALSE);
225
+			foreach ($datetimes as $datetime) {
226
+				$tickets_available_for_purchase = array_merge($tickets_available_for_purchase, $datetime->ticket_types_available_for_purchase());
227 227
 			}
228 228
 		}
229 229
 		return $tickets_available_for_purchase;
@@ -239,17 +239,17 @@  discard block
 block discarded – undo
239 239
 	 * @param 	  bool   $hide_uncategorized
240 240
 	 * @return    string
241 241
 	 */
242
-	public static function event_categories( $EVT_ID = 0, $hide_uncategorized = TRUE ) {
242
+	public static function event_categories($EVT_ID = 0, $hide_uncategorized = TRUE) {
243 243
 		$category_links = array();
244
-		$event = EEH_Event_View::get_event( $EVT_ID );
245
-		if ( $event instanceof EE_Event ) {
246
-			$event_categories = get_the_terms( $event->ID(), 'espresso_event_categories' );
247
-			if ( $event_categories ) {
244
+		$event = EEH_Event_View::get_event($EVT_ID);
245
+		if ($event instanceof EE_Event) {
246
+			$event_categories = get_the_terms($event->ID(), 'espresso_event_categories');
247
+			if ($event_categories) {
248 248
 				// loop thru terms and create links
249
-				foreach ( $event_categories as $term ) {
250
-					$url = get_term_link( $term, 'espresso_venue_categories' );
251
-					if ( ! is_wp_error( $url ) && (( $hide_uncategorized && strtolower( $term->name ) != __( 'uncategorized', 'event_espresso' )) || ! $hide_uncategorized )) {
252
-						$category_links[] = '<a href="' . esc_url( $url )
249
+				foreach ($event_categories as $term) {
250
+					$url = get_term_link($term, 'espresso_venue_categories');
251
+					if ( ! is_wp_error($url) && (($hide_uncategorized && strtolower($term->name) != __('uncategorized', 'event_espresso')) || ! $hide_uncategorized)) {
252
+						$category_links[] = '<a href="'.esc_url($url)
253 253
                                             . '" rel="tag"'
254 254
                                             . \EED_Events_Archive::link_target()
255 255
                                             .'>'
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 				}
260 260
 			}
261 261
 		}
262
-		return implode( ', ', $category_links );
262
+		return implode(', ', $category_links);
263 263
 	}
264 264
 
265 265
 
@@ -273,10 +273,10 @@  discard block
 block discarded – undo
273 273
 	 * @param int    $EVT_ID
274 274
 	 * @return    string
275 275
 	 */
276
-	public static function the_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) {
277
-		$datetime = EEH_Event_View::get_primary_date_obj( $EVT_ID );
278
-		$format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt;
279
-		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_start', $format ) :  '';
276
+	public static function the_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) {
277
+		$datetime = EEH_Event_View::get_primary_date_obj($EVT_ID);
278
+		$format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt;
279
+		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_start', $format) : '';
280 280
 	}
281 281
 
282 282
 
@@ -290,10 +290,10 @@  discard block
 block discarded – undo
290 290
 	 * @param int    $EVT_ID
291 291
 	 * @return    string
292 292
 	 */
293
-	public static function the_event_end_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) {
294
-		$datetime = EEH_Event_View::get_last_date_obj( $EVT_ID );
295
-		$format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt;
296
-		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_end', $format ) : '';
293
+	public static function the_event_end_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) {
294
+		$datetime = EEH_Event_View::get_last_date_obj($EVT_ID);
295
+		$format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt;
296
+		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_end', $format) : '';
297 297
 	}
298 298
 
299 299
 
@@ -307,10 +307,10 @@  discard block
 block discarded – undo
307 307
 	 * @param int    $EVT_ID
308 308
 	 * @return    string
309 309
 	 */
310
-	public static function the_earliest_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) {
311
-		$datetime = EEH_Event_View::get_earliest_date_obj( $EVT_ID );
312
-		$format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt;
313
-		return $datetime instanceof EE_Datetime ?  $datetime->get_i18n_datetime( 'DTT_EVT_start', $format ) : '';
310
+	public static function the_earliest_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) {
311
+		$datetime = EEH_Event_View::get_earliest_date_obj($EVT_ID);
312
+		$format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt;
313
+		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_start', $format) : '';
314 314
 	}
315 315
 
316 316
 
@@ -324,10 +324,10 @@  discard block
 block discarded – undo
324 324
 	 * @param int    $EVT_ID
325 325
 	 * @return    string
326 326
 	 */
327
-	public static function the_latest_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) {
328
-		$datetime = EEH_Event_View::get_latest_date_obj( $EVT_ID );
329
-		$format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt;
330
-		return $datetime instanceof EE_Datetime ?  $datetime->get_i18n_datetime( 'DTT_EVT_end', $format ) : '';
327
+	public static function the_latest_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) {
328
+		$datetime = EEH_Event_View::get_latest_date_obj($EVT_ID);
329
+		$format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt;
330
+		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_end', $format) : '';
331 331
 	}
332 332
 
333 333
 
@@ -339,13 +339,13 @@  discard block
 block discarded – undo
339 339
 	 * @param int $EVT_ID
340 340
 	 * @return    string
341 341
 	 */
342
-	public static function event_date_as_calendar_page( $EVT_ID = 0 ) {
343
-		$datetime = EEH_Event_View::get_primary_date_obj( $EVT_ID );
344
-		if ( $datetime instanceof EE_Datetime ) {
342
+	public static function event_date_as_calendar_page($EVT_ID = 0) {
343
+		$datetime = EEH_Event_View::get_primary_date_obj($EVT_ID);
344
+		if ($datetime instanceof EE_Datetime) {
345 345
 	?>
346 346
 		<div class="event-date-calendar-page-dv">
347
-			<div class="event-date-calendar-page-month-dv"><?php echo $datetime->get_i18n_datetime( 'DTT_EVT_start', 'M' );?></div>
348
-			<div class="event-date-calendar-page-day-dv"><?php echo $datetime->start_date( 'd' );?></div>
347
+			<div class="event-date-calendar-page-month-dv"><?php echo $datetime->get_i18n_datetime('DTT_EVT_start', 'M'); ?></div>
348
+			<div class="event-date-calendar-page-day-dv"><?php echo $datetime->start_date('d'); ?></div>
349 349
 		</div>
350 350
 	<?php
351 351
 		}
@@ -360,17 +360,17 @@  discard block
 block discarded – undo
360 360
 	 * @param int $EVT_ID
361 361
 	 * @return    string
362 362
 	 */
363
-	public static function get_primary_date_obj( $EVT_ID = 0 ) {
364
-		$event = EEH_Event_View::get_event( $EVT_ID );
365
-		if ( $event instanceof EE_Event ) {
363
+	public static function get_primary_date_obj($EVT_ID = 0) {
364
+		$event = EEH_Event_View::get_event($EVT_ID);
365
+		if ($event instanceof EE_Event) {
366 366
 			$datetimes = $event->get_many_related(
367 367
 				'Datetime',
368 368
 				array(
369 369
 					'limit' => 1,
370
-					'order_by' => array( 'DTT_order' => 'ASC' )
370
+					'order_by' => array('DTT_order' => 'ASC')
371 371
 				)
372 372
 			);
373
-			return reset( $datetimes );
373
+			return reset($datetimes);
374 374
 		} else {
375 375
 			 return FALSE;
376 376
 		}
@@ -385,17 +385,17 @@  discard block
 block discarded – undo
385 385
 	 * @param int $EVT_ID
386 386
 	 * @return    string
387 387
 	 */
388
-	public static function get_last_date_obj( $EVT_ID = 0 ) {
389
-		$event = EEH_Event_View::get_event( $EVT_ID );
390
-		if ( $event instanceof EE_Event ) {
388
+	public static function get_last_date_obj($EVT_ID = 0) {
389
+		$event = EEH_Event_View::get_event($EVT_ID);
390
+		if ($event instanceof EE_Event) {
391 391
 			$datetimes = $event->get_many_related(
392 392
 				'Datetime',
393 393
 				array(
394 394
 					'limit' => 1,
395
-					'order_by' => array( 'DTT_order' => 'DESC' )
395
+					'order_by' => array('DTT_order' => 'DESC')
396 396
 				)
397 397
 			);
398
-			return end( $datetimes );
398
+			return end($datetimes);
399 399
 		} else {
400 400
 			return FALSE;
401 401
 		}
@@ -410,17 +410,17 @@  discard block
 block discarded – undo
410 410
 	 * @param int $EVT_ID
411 411
 	 * @return    string
412 412
 	 */
413
-	public static function get_earliest_date_obj( $EVT_ID = 0 ) {
414
-		$event = EEH_Event_View::get_event( $EVT_ID );
415
-		if ( $event instanceof EE_Event ) {
413
+	public static function get_earliest_date_obj($EVT_ID = 0) {
414
+		$event = EEH_Event_View::get_event($EVT_ID);
415
+		if ($event instanceof EE_Event) {
416 416
 			$datetimes = $event->get_many_related(
417 417
 				'Datetime',
418 418
 				array(
419 419
 					'limit' => 1,
420
-					'order_by' => array( 'DTT_EVT_start' => 'ASC' )
420
+					'order_by' => array('DTT_EVT_start' => 'ASC')
421 421
 				)
422 422
 			);
423
-			return reset( $datetimes );
423
+			return reset($datetimes);
424 424
 		} else {
425 425
 			 return FALSE;
426 426
 		}
@@ -435,17 +435,17 @@  discard block
 block discarded – undo
435 435
 	 * @param int $EVT_ID
436 436
 	 * @return    string
437 437
 	 */
438
-	public static function get_latest_date_obj( $EVT_ID = 0 ) {
439
-		$event = EEH_Event_View::get_event( $EVT_ID );
440
-		if ( $event instanceof EE_Event ) {
438
+	public static function get_latest_date_obj($EVT_ID = 0) {
439
+		$event = EEH_Event_View::get_event($EVT_ID);
440
+		if ($event instanceof EE_Event) {
441 441
 			$datetimes = $event->get_many_related(
442 442
 				'Datetime',
443 443
 				array(
444 444
 					'limit' => 1,
445
-					'order_by' => array( 'DTT_EVT_start' => 'DESC' )
445
+					'order_by' => array('DTT_EVT_start' => 'DESC')
446 446
 				)
447 447
 			);
448
-			return end( $datetimes );
448
+			return end($datetimes);
449 449
 		} else {
450 450
 			return FALSE;
451 451
 		}
@@ -463,17 +463,17 @@  discard block
 block discarded – undo
463 463
 	 * @param null $limit
464 464
 	 * @return EE_Datetime[]
465 465
 	 */
466
-	public static function get_all_date_obj( $EVT_ID = 0, $include_expired = null, $include_deleted = false, $limit = NULL ) {
467
-		$event = EEH_Event_View::get_event( $EVT_ID );
468
-		if($include_expired === null){
469
-			if($event instanceof EE_Event && $event->is_expired()){
466
+	public static function get_all_date_obj($EVT_ID = 0, $include_expired = null, $include_deleted = false, $limit = NULL) {
467
+		$event = EEH_Event_View::get_event($EVT_ID);
468
+		if ($include_expired === null) {
469
+			if ($event instanceof EE_Event && $event->is_expired()) {
470 470
 				$include_expired = true;
471
-			}else{
471
+			} else {
472 472
 				$include_expired = false;
473 473
 			}
474 474
 		}
475 475
 
476
-		if ( $event instanceof EE_Event ) {
476
+		if ($event instanceof EE_Event) {
477 477
 			return $event->datetimes_ordered($include_expired, $include_deleted, $limit);
478 478
 		} else {
479 479
 			 return array();
@@ -489,11 +489,11 @@  discard block
 block discarded – undo
489 489
 	 * @param int $EVT_ID
490 490
 	 * @return    string
491 491
 	 */
492
-	public static function event_link_url( $EVT_ID = 0 ) {
493
-		$event = EEH_Event_View::get_event( $EVT_ID );
494
-		if ( $event instanceof EE_Event ) {
495
-			$url = $event->external_url() !== NULL && $event->external_url() !== '' ? $event->external_url() : get_permalink( $event->ID() );
496
-			return preg_match( "~^(?:f|ht)tps?://~i", $url ) ? $url : 'http://' . $url;
492
+	public static function event_link_url($EVT_ID = 0) {
493
+		$event = EEH_Event_View::get_event($EVT_ID);
494
+		if ($event instanceof EE_Event) {
495
+			$url = $event->external_url() !== NULL && $event->external_url() !== '' ? $event->external_url() : get_permalink($event->ID());
496
+			return preg_match("~^(?:f|ht)tps?://~i", $url) ? $url : 'http://'.$url;
497 497
 		}
498 498
 		return NULL;
499 499
 	}
@@ -507,10 +507,10 @@  discard block
 block discarded – undo
507 507
 	 * @param int $EVT_ID
508 508
 	 * @return    string
509 509
 	 */
510
-	public static function event_phone( $EVT_ID = 0 ) {
511
-		$event = EEH_Event_View::get_event( $EVT_ID );
512
-		if ( $event instanceof EE_Event ) {
513
-			return EEH_Schema::telephone( $event->phone() );
510
+	public static function event_phone($EVT_ID = 0) {
511
+		$event = EEH_Event_View::get_event($EVT_ID);
512
+		if ($event instanceof EE_Event) {
513
+			return EEH_Schema::telephone($event->phone());
514 514
 		}
515 515
 		return NULL;
516 516
 	}
@@ -527,26 +527,26 @@  discard block
 block discarded – undo
527 527
 	 * @param string $after
528 528
 	 * @return    string
529 529
 	 */
530
-	public static function edit_event_link( $EVT_ID = 0, $link = '', $before = '', $after = '' ) {
531
-		$event = EEH_Event_View::get_event( $EVT_ID );
532
-		if ( $event instanceof EE_Event ) {
530
+	public static function edit_event_link($EVT_ID = 0, $link = '', $before = '', $after = '') {
531
+		$event = EEH_Event_View::get_event($EVT_ID);
532
+		if ($event instanceof EE_Event) {
533 533
 			// can the user edit this post ?
534
-			if ( current_user_can( 'edit_post', $event->ID() )) {
534
+			if (current_user_can('edit_post', $event->ID())) {
535 535
 				// set link text
536
-				$link_text = ! empty( $link ) ? $link : __('edit this event');
536
+				$link_text = ! empty($link) ? $link : __('edit this event');
537 537
 				// generate nonce
538
-				$nonce = wp_create_nonce( 'edit_nonce' );
538
+				$nonce = wp_create_nonce('edit_nonce');
539 539
 				// generate url to event editor for this event
540
-				$url = add_query_arg( array( 'page' => 'espresso_events', 'action' => 'edit', 'post' => $event->ID(), 'edit_nonce' => $nonce ), admin_url() );
540
+				$url = add_query_arg(array('page' => 'espresso_events', 'action' => 'edit', 'post' => $event->ID(), 'edit_nonce' => $nonce), admin_url());
541 541
 				// get edit CPT text
542
-				$post_type_obj = get_post_type_object( 'espresso_events' );
542
+				$post_type_obj = get_post_type_object('espresso_events');
543 543
 				// build final link html
544
-				$link = '<a class="post-edit-link" href="' . $url . '" ';
545
-				$link .= ' title="' . esc_attr( $post_type_obj->labels->edit_item ) . '"';
544
+				$link = '<a class="post-edit-link" href="'.$url.'" ';
545
+				$link .= ' title="'.esc_attr($post_type_obj->labels->edit_item).'"';
546 546
 				$link .= \EED_Events_Archive::link_target();
547
-				$link .='>' . $link_text . '</a>';
547
+				$link .= '>'.$link_text.'</a>';
548 548
 				// put it all together
549
-				return $before . apply_filters( 'edit_post_link', $link, $event->ID() ) . $after;
549
+				return $before.apply_filters('edit_post_link', $link, $event->ID()).$after;
550 550
 			}
551 551
 		}
552 552
 		return '';
Please login to merge, or discard this patch.
core/services/shortcodes/EspressoShortcode.php 1 patch
Indentation   +217 added lines, -217 removed lines patch added patch discarded remove patch
@@ -23,223 +23,223 @@
 block discarded – undo
23 23
 abstract class EspressoShortcode implements ShortcodeInterface
24 24
 {
25 25
 
26
-    /**
27
-     * transient prefix
28
-     *
29
-     * @type string
30
-     */
31
-    const CACHE_TRANSIENT_PREFIX = 'ee_sc_';
32
-
33
-    /**
34
-     * @var PostRelatedCacheManager $cache_manager
35
-     */
36
-    private $cache_manager;
37
-
38
-    /**
39
-     * true if ShortcodeInterface::initializeShortcode() has been called
40
-     * if false, then that will get called before processing
41
-     *
42
-     * @var boolean $initialized
43
-     */
44
-    private $initialized = false;
45
-
46
-
47
-
48
-    /**
49
-     * EspressoShortcode constructor
50
-     *
51
-     * @param PostRelatedCacheManager $cache_manager
52
-     */
53
-    public function __construct(PostRelatedCacheManager $cache_manager)
54
-    {
55
-        $this->cache_manager = $cache_manager;
56
-    }
57
-
58
-
59
-
60
-    /**
61
-     * @return void
62
-     */
63
-    public function shortcodeHasBeenInitialized()
64
-    {
65
-        $this->initialized = true;
66
-    }
67
-
68
-
69
-
70
-    /**
71
-     * enqueues scripts then processes the shortcode
72
-     *
73
-     * @param array $attributes
74
-     * @return string
75
-     * @throws EE_Error
76
-     */
77
-    final public function processShortcodeCallback($attributes = array())
78
-    {
79
-        if ($this instanceof EnqueueAssetsInterface) {
80
-            if (is_admin()) {
81
-                $this->enqueueAdminScripts();
82
-            } else {
83
-                $this->enqueueScripts();
84
-            }
85
-        }
86
-        return $this->shortcodeContent(
87
-            $this->sanitizeAttributes((array)$attributes)
88
-        );
89
-    }
90
-
91
-
92
-
93
-    /**
94
-     * If shortcode caching is enabled for the shortcode,
95
-     * and cached results exist, then that will be returned
96
-     * else new content will be generated.
97
-     * If caching is enabled, then the new content will be cached for later.
98
-     *
99
-     * @param array $attributes
100
-     * @return mixed|string
101
-     * @throws EE_Error
102
-     */
103
-    private function shortcodeContent(array $attributes)
104
-    {
105
-        $shortcode = $this;
106
-        $post_ID = $this->currentPostID();
107
-        // something like "SC_EVENTS-123"
108
-        $cache_ID = $this->shortcodeCacheID($post_ID);
109
-        $this->cache_manager->clearPostRelatedCacheOnUpdate($post_ID, $cache_ID);
110
-        return $this->cache_manager->get(
111
-            $cache_ID,
112
-            // serialized attributes
113
-            wp_json_encode($attributes),
114
-            // Closure for generating content if cache is expired
115
-            function () use ($shortcode, $attributes) {
116
-                if($shortcode->initialized === false){
117
-                    $shortcode->initializeShortcode();
118
-                }
119
-                return $shortcode->processShortcode($attributes);
120
-            },
121
-            // filterable cache expiration set by each shortcode
122
-            apply_filters(
123
-                'FHEE__EventEspresso_core_services_shortcodes_EspressoShortcode__shortcodeContent__cache_expiration',
124
-                $this->cacheExpiration(),
125
-                $this->getTag(),
126
-                $this
127
-            )
128
-        );
129
-    }
130
-
131
-
132
-
133
-    /**
134
-     * @return int
135
-     * @throws EE_Error
136
-     */
137
-    private function currentPostID()
138
-    {
139
-        // try to get EE_Event any way we can
140
-        $event = EEH_Event_View::get_event();
141
-        // then get some kind of ID
142
-        if ($event instanceof EE_Event) {
143
-            return $event->ID();
144
-        }
145
-        global $post;
146
-        if ($post instanceof EE_Event) {
147
-            return $post->ID();
148
-        }
149
-        if ($post instanceof WP_Post) {
150
-            return $post->ID;
151
-        }
152
-        return 0;
153
-    }
154
-
155
-
156
-
157
-    /**
158
-     * @param int $post_ID
159
-     * @return string
160
-     * @throws EE_Error
161
-     */
162
-    private function shortcodeCacheID($post_ID)
163
-    {
164
-        $tag = str_replace('ESPRESSO_', '', $this->getTag());
165
-        return "SC_{$tag}-{$post_ID}";
166
-    }
167
-
168
-
169
-
170
-    /**
171
-     * array for defining custom attribute sanitization callbacks,
172
-     * where keys match keys in your attributes array,
173
-     * and values represent the sanitization function you wish to be applied to that attribute.
174
-     * So for example, if you had an integer attribute named "event_id"
175
-     * that you wanted to be sanitized using absint(),
176
-     * then you would return the following:
177
-     *      array('event_id' => 'absint')
178
-     * Entering 'skip_sanitization' for the callback value
179
-     * means that no sanitization will be applied
180
-     * on the assumption that the attribute
181
-     * will be sanitized at some point... right?
182
-     * You wouldn't pass around unsanitized attributes would you?
183
-     * That would be very Tom Foolery of you!!!
184
-     *
185
-     * @return array
186
-     */
187
-    protected function customAttributeSanitizationMap()
188
-    {
189
-        return array();
190
-    }
191
-
192
-
193
-
194
-    /**
195
-     * Performs basic sanitization on shortcode attributes
196
-     * Since incoming attributes from the shortcode usage in the WP editor will all be strings,
197
-     * most attributes will by default be sanitized using the sanitize_text_field() function.
198
-     * This can be overridden using the customAttributeSanitizationMap() method (see above),
199
-     * all other attributes would be sanitized using the defaults in the switch statement below
200
-     *
201
-     * @param array $attributes
202
-     * @return array
203
-     */
204
-    private function sanitizeAttributes(array $attributes)
205
-    {
206
-        $custom_sanitization = $this->customAttributeSanitizationMap();
207
-        foreach ($attributes as $key => $value) {
208
-            // is a custom sanitization callback specified ?
209
-            if (isset($custom_sanitization[$key])) {
210
-                $callback = $custom_sanitization[$key];
211
-                if ($callback === 'skip_sanitization') {
212
-                    $attributes[$key] = $value;
213
-                    continue;
214
-                }
215
-                if (function_exists($callback)) {
216
-                    $attributes[$key] = $callback($value);
217
-                    continue;
218
-                }
219
-            }
220
-            switch (true) {
221
-                case $value === null :
222
-                case is_int($value) :
223
-                case is_float($value) :
224
-                    // typical booleans
225
-                case in_array($value, array(true, 'true', '1', 'on', 'yes', false, 'false', '0', 'off', 'no'), true) :
226
-                    $attributes[$key] = $value;
227
-                    break;
228
-                case is_string($value) :
229
-                    $attributes[$key] = sanitize_text_field($value);
230
-                    break;
231
-                case is_array($value) :
232
-                    $attributes[$key] = $this->sanitizeAttributes($value);
233
-                    break;
234
-                default :
235
-                    // only remaining data types are Object and Resource
236
-                    // which are not allowed as shortcode attributes
237
-                    $attributes[$key] = null;
238
-                    break;
239
-            }
240
-        }
241
-        return $attributes;
242
-    }
26
+	/**
27
+	 * transient prefix
28
+	 *
29
+	 * @type string
30
+	 */
31
+	const CACHE_TRANSIENT_PREFIX = 'ee_sc_';
32
+
33
+	/**
34
+	 * @var PostRelatedCacheManager $cache_manager
35
+	 */
36
+	private $cache_manager;
37
+
38
+	/**
39
+	 * true if ShortcodeInterface::initializeShortcode() has been called
40
+	 * if false, then that will get called before processing
41
+	 *
42
+	 * @var boolean $initialized
43
+	 */
44
+	private $initialized = false;
45
+
46
+
47
+
48
+	/**
49
+	 * EspressoShortcode constructor
50
+	 *
51
+	 * @param PostRelatedCacheManager $cache_manager
52
+	 */
53
+	public function __construct(PostRelatedCacheManager $cache_manager)
54
+	{
55
+		$this->cache_manager = $cache_manager;
56
+	}
57
+
58
+
59
+
60
+	/**
61
+	 * @return void
62
+	 */
63
+	public function shortcodeHasBeenInitialized()
64
+	{
65
+		$this->initialized = true;
66
+	}
67
+
68
+
69
+
70
+	/**
71
+	 * enqueues scripts then processes the shortcode
72
+	 *
73
+	 * @param array $attributes
74
+	 * @return string
75
+	 * @throws EE_Error
76
+	 */
77
+	final public function processShortcodeCallback($attributes = array())
78
+	{
79
+		if ($this instanceof EnqueueAssetsInterface) {
80
+			if (is_admin()) {
81
+				$this->enqueueAdminScripts();
82
+			} else {
83
+				$this->enqueueScripts();
84
+			}
85
+		}
86
+		return $this->shortcodeContent(
87
+			$this->sanitizeAttributes((array)$attributes)
88
+		);
89
+	}
90
+
91
+
92
+
93
+	/**
94
+	 * If shortcode caching is enabled for the shortcode,
95
+	 * and cached results exist, then that will be returned
96
+	 * else new content will be generated.
97
+	 * If caching is enabled, then the new content will be cached for later.
98
+	 *
99
+	 * @param array $attributes
100
+	 * @return mixed|string
101
+	 * @throws EE_Error
102
+	 */
103
+	private function shortcodeContent(array $attributes)
104
+	{
105
+		$shortcode = $this;
106
+		$post_ID = $this->currentPostID();
107
+		// something like "SC_EVENTS-123"
108
+		$cache_ID = $this->shortcodeCacheID($post_ID);
109
+		$this->cache_manager->clearPostRelatedCacheOnUpdate($post_ID, $cache_ID);
110
+		return $this->cache_manager->get(
111
+			$cache_ID,
112
+			// serialized attributes
113
+			wp_json_encode($attributes),
114
+			// Closure for generating content if cache is expired
115
+			function () use ($shortcode, $attributes) {
116
+				if($shortcode->initialized === false){
117
+					$shortcode->initializeShortcode();
118
+				}
119
+				return $shortcode->processShortcode($attributes);
120
+			},
121
+			// filterable cache expiration set by each shortcode
122
+			apply_filters(
123
+				'FHEE__EventEspresso_core_services_shortcodes_EspressoShortcode__shortcodeContent__cache_expiration',
124
+				$this->cacheExpiration(),
125
+				$this->getTag(),
126
+				$this
127
+			)
128
+		);
129
+	}
130
+
131
+
132
+
133
+	/**
134
+	 * @return int
135
+	 * @throws EE_Error
136
+	 */
137
+	private function currentPostID()
138
+	{
139
+		// try to get EE_Event any way we can
140
+		$event = EEH_Event_View::get_event();
141
+		// then get some kind of ID
142
+		if ($event instanceof EE_Event) {
143
+			return $event->ID();
144
+		}
145
+		global $post;
146
+		if ($post instanceof EE_Event) {
147
+			return $post->ID();
148
+		}
149
+		if ($post instanceof WP_Post) {
150
+			return $post->ID;
151
+		}
152
+		return 0;
153
+	}
154
+
155
+
156
+
157
+	/**
158
+	 * @param int $post_ID
159
+	 * @return string
160
+	 * @throws EE_Error
161
+	 */
162
+	private function shortcodeCacheID($post_ID)
163
+	{
164
+		$tag = str_replace('ESPRESSO_', '', $this->getTag());
165
+		return "SC_{$tag}-{$post_ID}";
166
+	}
167
+
168
+
169
+
170
+	/**
171
+	 * array for defining custom attribute sanitization callbacks,
172
+	 * where keys match keys in your attributes array,
173
+	 * and values represent the sanitization function you wish to be applied to that attribute.
174
+	 * So for example, if you had an integer attribute named "event_id"
175
+	 * that you wanted to be sanitized using absint(),
176
+	 * then you would return the following:
177
+	 *      array('event_id' => 'absint')
178
+	 * Entering 'skip_sanitization' for the callback value
179
+	 * means that no sanitization will be applied
180
+	 * on the assumption that the attribute
181
+	 * will be sanitized at some point... right?
182
+	 * You wouldn't pass around unsanitized attributes would you?
183
+	 * That would be very Tom Foolery of you!!!
184
+	 *
185
+	 * @return array
186
+	 */
187
+	protected function customAttributeSanitizationMap()
188
+	{
189
+		return array();
190
+	}
191
+
192
+
193
+
194
+	/**
195
+	 * Performs basic sanitization on shortcode attributes
196
+	 * Since incoming attributes from the shortcode usage in the WP editor will all be strings,
197
+	 * most attributes will by default be sanitized using the sanitize_text_field() function.
198
+	 * This can be overridden using the customAttributeSanitizationMap() method (see above),
199
+	 * all other attributes would be sanitized using the defaults in the switch statement below
200
+	 *
201
+	 * @param array $attributes
202
+	 * @return array
203
+	 */
204
+	private function sanitizeAttributes(array $attributes)
205
+	{
206
+		$custom_sanitization = $this->customAttributeSanitizationMap();
207
+		foreach ($attributes as $key => $value) {
208
+			// is a custom sanitization callback specified ?
209
+			if (isset($custom_sanitization[$key])) {
210
+				$callback = $custom_sanitization[$key];
211
+				if ($callback === 'skip_sanitization') {
212
+					$attributes[$key] = $value;
213
+					continue;
214
+				}
215
+				if (function_exists($callback)) {
216
+					$attributes[$key] = $callback($value);
217
+					continue;
218
+				}
219
+			}
220
+			switch (true) {
221
+				case $value === null :
222
+				case is_int($value) :
223
+				case is_float($value) :
224
+					// typical booleans
225
+				case in_array($value, array(true, 'true', '1', 'on', 'yes', false, 'false', '0', 'off', 'no'), true) :
226
+					$attributes[$key] = $value;
227
+					break;
228
+				case is_string($value) :
229
+					$attributes[$key] = sanitize_text_field($value);
230
+					break;
231
+				case is_array($value) :
232
+					$attributes[$key] = $this->sanitizeAttributes($value);
233
+					break;
234
+				default :
235
+					// only remaining data types are Object and Resource
236
+					// which are not allowed as shortcode attributes
237
+					$attributes[$key] = null;
238
+					break;
239
+			}
240
+		}
241
+		return $attributes;
242
+	}
243 243
 
244 244
 
245 245
 
Please login to merge, or discard this patch.
core/domain/entities/shortcodes/EspressoEventAttendees.php 2 patches
Indentation   +239 added lines, -239 removed lines patch added patch discarded remove patch
@@ -28,245 +28,245 @@
 block discarded – undo
28 28
 class EspressoEventAttendees extends EspressoShortcode
29 29
 {
30 30
 
31
-    private $query_params = array(
32
-        0 => array()
33
-    );
34
-
35
-    private $template_args = array(
36
-        'contacts'      => array(),
37
-        'event'         => null,
38
-        'datetime'      => null,
39
-        'ticket'        => null,
40
-    );
41
-
42
-    /**
43
-     * the actual shortcode tag that gets registered with WordPress
44
-     *
45
-     * @return string
46
-     */
47
-    public function getTag()
48
-    {
49
-        return 'ESPRESSO_EVENT_ATTENDEES';
50
-    }
51
-
52
-
53
-
54
-    /**
55
-     * the time in seconds to cache the results of the processShortcode() method
56
-     * 0 means the processShortcode() results will NOT be cached at all
57
-     *
58
-     * @return int
59
-     */
60
-    public function cacheExpiration()
61
-    {
62
-        return 0;
63
-    }
64
-
65
-
66
-
67
-    /**
68
-     * a place for adding any initialization code that needs to run prior to wp_header().
69
-     * this may be required for shortcodes that utilize a corresponding module,
70
-     * and need to enqueue assets for that module
71
-     *
72
-     * @return void
73
-     */
74
-    public function initializeShortcode()
75
-    {
76
-        $this->shortcodeHasBeenInitialized();
77
-    }
78
-
79
-
80
-
81
-    /**
82
-     * process_shortcode - ESPRESSO_EVENT_ATTENDEES - Returns a list of attendees to an event.
83
-     *  [ESPRESSO_EVENT_ATTENDEES] - defaults to attendees for earliest active event, or earliest upcoming event.
84
-     *  [ESPRESSO_EVENT_ATTENDEES event_id=123] - attendees for specific event.
85
-     *  [ESPRESSO_EVENT_ATTENDEES datetime_id=245] - attendees for a specific datetime.
86
-     *  [ESPRESSO_EVENT_ATTENDEES ticket_id=123] - attendees for a specific ticket.
87
-     *  [ESPRESSO_EVENT_ATTENDEES status=all] - specific registration status (use status id) or all for all attendees
88
-     *                                          regardless of status.  Note default is to only return approved attendees
89
-     *  [ESPRESSO_EVENT_ATTENDEES show_gravatar=true] - default is to not return gravatar.  Otherwise if this is set
90
-     *                                                  then return gravatar for email address given.
91
-     *  Note: because of the relationship between event_id, ticket_id, and datetime_id.
92
-     * If more than one of those params is included then preference is given to the following:
93
-     *  - event_id is used whenever its present and any others are ignored.
94
-     *  - if no event_id then datetime is used whenever its present and any others are ignored.
95
-     *  - otherwise ticket_id is used if present.
96
-     *
97
-     * @param array $attributes
98
-     * @return string
99
-     * @throws \EE_Error
100
-     */
101
-    public function processShortcode($attributes = array())
102
-    {
103
-        // grab attributes and merge with defaults
104
-        $attributes = $this->getAttributes((array)$attributes);
105
-        // add attributes to template args
106
-        $this->template_args['show_gravatar'] = $attributes['show_gravatar'];
107
-        // add required objects: event, datetime, and ticket
108
-        $this->template_args['event'] = $this->getEventAndQueryParams($attributes);
109
-        $this->template_args['datetime'] = $this->getDatetimeAndQueryParams($attributes);
110
-        $this->template_args['ticket'] = $this->getTicketAndQueryParams($attributes);
111
-
112
-        // if any of the above objects is invalid or missing,
113
-        // then there was an invalid parameter or the shortcode was used incorrectly
114
-        // so when WP_DEBUG is set and true, we'll show a message,
115
-        // otherwise we'll just return an empty string.
116
-         if (
117
-            ! $this->template_args['event'] instanceof EE_Event
118
-            || empty($this->query_params[0])
119
-            || ($attributes['datetime_id'] && ! $this->template_args['datetime'] instanceof EE_Datetime)
120
-            || ($attributes['ticket_id'] && ! $this->template_args['ticket'] instanceof EE_Ticket)
121
-        ) {
122
-            if (WP_DEBUG) {
123
-                return '<div class="important-notice ee-attention">'
124
-                       . esc_html__('The [ESPRESSO_EVENT_ATTENDEES] shortcode has been used incorrectly.  Please double check the arguments you used for any typos.  In the case of ID type arguments, its possible the given ID does not correspond to existing data in the database.',
125
-                        'event_espresso')
126
-                       . '</div>';
127
-            } else {
128
-                return '';
129
-            }
130
-        }
131
-        $this->setAdditionalQueryParams($attributes);
132
-        //get contacts!
133
-        $this->template_args['contacts'] = EEM_Attendee::instance()->get_all($this->query_params);
134
-        //all set let's load up the template and return.
135
-        return EEH_Template::locate_template('loop-espresso_event_attendees.php', $this->template_args, true, true);
136
-    }
137
-
138
-
139
-
140
-    /**
141
-     * merge incoming attributes with filtered defaults
142
-     *
143
-     * @param array $attributes
144
-     * @return array
145
-     */
146
-    private function getAttributes(array $attributes)
147
-    {
148
-        return array_merge(
149
-            (array) apply_filters(
150
-                'EES_Espresso_Event_Attendees__process_shortcode__default_shortcode_atts',
151
-                array(
152
-                    'event_id'      => null,
153
-                    'datetime_id'   => null,
154
-                    'ticket_id'     => null,
155
-                    'status'        => EEM_Registration::status_id_approved,
156
-                    'show_gravatar' => false
157
-                )
158
-            ),
159
-            $attributes
160
-        );
161
-    }
162
-
163
-
164
-
165
-    /**
166
-     * @param array $attributes
167
-     * @return EE_Event|null
168
-     * @throws \EE_Error
169
-     */
170
-    private function getEventAndQueryParams(array $attributes){
171
-        if ( ! empty($attributes['event_id'])) {
172
-            $event = EEM_Event::instance()->get_one_by_ID($attributes['event_id']);
173
-            if ($event instanceof EE_Event) {
174
-                $this->query_params[0]['Registration.EVT_ID'] = $attributes['event_id'];
175
-                return $event;
176
-            }
177
-        }
178
-        //seems like is_espresso_event_single() isn't working as expected. So using alternate method.
179
-        if ( is_espresso_event()) {
180
-            $event = EEH_Event_View::get_event();
181
-            if ($event instanceof EE_Event) {
182
-                $this->query_params[0]['Registration.EVT_ID'] = $event->ID();
183
-                return $event;
184
-            }
185
-        }
186
-        // one last shot...
187
-        // try getting the earliest active event
188
-        $events = EEM_Event::instance()->get_active_events(array(
189
-            'limit'    => 1,
190
-            'order_by' => array('Datetime.DTT_EVT_start' => 'ASC')
191
-        ));
192
-        //  if none then get the next upcoming
193
-        $events = empty($events)
194
-            ? EEM_Event::instance()->get_upcoming_events(array(
195
-                'limit'    => 1,
196
-                'order_by' => array('Datetime.DTT_EVT_start' => 'ASC')
197
-            ))
198
-            : $events;
199
-        $event = reset($events);
200
-        if ($event instanceof EE_Event) {
201
-            $this->query_params[0]['Registration.EVT_ID'] = $event->ID();
202
-            return $event;
203
-        }
204
-        return null;
205
-    }
206
-
207
-
208
-
209
-    /**
210
-     * @param array $attributes
211
-     * @return EE_Datetime|null
212
-     */
213
-    private function getDatetimeAndQueryParams(array $attributes)
214
-    {
215
-        if ( ! empty($attributes['datetime_id'])) {
216
-            $datetime = EEM_Datetime::instance()->get_one_by_ID($attributes['datetime_id']);
217
-            if ($datetime instanceof EE_Datetime) {
218
-                $this->query_params[0]['Registration.Ticket.Datetime.DTT_ID'] = $attributes['datetime_id'];
219
-                $this->query_params['default_where_conditions'] = 'this_model_only';
220
-                if ( ! $this->template_args['event'] instanceof EE_Event) {
221
-                    $this->template_args['event'] = $datetime->event();
222
-                }
223
-                return $datetime;
224
-            }
225
-        }
226
-        return null;
227
-    }
228
-
229
-
230
-
231
-    /**
232
-     * @param array $attributes
233
-     * @return \EE_Base_Class|null
234
-     * @throws \EE_Error
235
-     */
236
-    private function getTicketAndQueryParams(array $attributes)
237
-    {
238
-        if ( ! empty($attributes['ticket_id']) && empty($attributes['event_id']) && empty($attributes['datetime_id'])) {
239
-            $ticket = EEM_Ticket::instance()->get_one_by_ID($attributes['ticket_id']);
240
-            if ($ticket instanceof EE_Ticket) {
241
-                $this->query_params[0]['Registration.TKT_ID'] = $attributes['ticket_id'];
242
-                if ( ! $this->template_args['event'] instanceof EE_Event) {
243
-                    $this->template_args['event'] = $ticket->first_datetime() instanceof EE_Datetime
244
-                        ? $ticket->first_datetime()->event()
245
-                        : null;
246
-                }
247
-                return $ticket;
248
-            }
249
-        }
250
-        return null;
251
-    }
252
-
253
-
254
-
255
-    /**
256
-     * @param array $attributes
257
-     */
258
-    private function setAdditionalQueryParams(array $attributes)
259
-    {
260
-        $reg_status_array = EEM_Registration::reg_status_array();
261
-        if ($attributes['status'] !== 'all' && isset($reg_status_array[$attributes['status']])) {
262
-            $this->query_params[0]['Registration.STS_ID'] = $attributes['status'];
263
-        }
264
-        $this->query_params['group_by'] = array('ATT_ID');
265
-        $this->query_params['order_by'] = (array) apply_filters(
266
-            'FHEE__EES_Espresso_Event_Attendees__process_shortcode__order_by',
267
-            array('ATT_lname' => 'ASC', 'ATT_fname' => 'ASC')
268
-        );
269
-    }
31
+	private $query_params = array(
32
+		0 => array()
33
+	);
34
+
35
+	private $template_args = array(
36
+		'contacts'      => array(),
37
+		'event'         => null,
38
+		'datetime'      => null,
39
+		'ticket'        => null,
40
+	);
41
+
42
+	/**
43
+	 * the actual shortcode tag that gets registered with WordPress
44
+	 *
45
+	 * @return string
46
+	 */
47
+	public function getTag()
48
+	{
49
+		return 'ESPRESSO_EVENT_ATTENDEES';
50
+	}
51
+
52
+
53
+
54
+	/**
55
+	 * the time in seconds to cache the results of the processShortcode() method
56
+	 * 0 means the processShortcode() results will NOT be cached at all
57
+	 *
58
+	 * @return int
59
+	 */
60
+	public function cacheExpiration()
61
+	{
62
+		return 0;
63
+	}
64
+
65
+
66
+
67
+	/**
68
+	 * a place for adding any initialization code that needs to run prior to wp_header().
69
+	 * this may be required for shortcodes that utilize a corresponding module,
70
+	 * and need to enqueue assets for that module
71
+	 *
72
+	 * @return void
73
+	 */
74
+	public function initializeShortcode()
75
+	{
76
+		$this->shortcodeHasBeenInitialized();
77
+	}
78
+
79
+
80
+
81
+	/**
82
+	 * process_shortcode - ESPRESSO_EVENT_ATTENDEES - Returns a list of attendees to an event.
83
+	 *  [ESPRESSO_EVENT_ATTENDEES] - defaults to attendees for earliest active event, or earliest upcoming event.
84
+	 *  [ESPRESSO_EVENT_ATTENDEES event_id=123] - attendees for specific event.
85
+	 *  [ESPRESSO_EVENT_ATTENDEES datetime_id=245] - attendees for a specific datetime.
86
+	 *  [ESPRESSO_EVENT_ATTENDEES ticket_id=123] - attendees for a specific ticket.
87
+	 *  [ESPRESSO_EVENT_ATTENDEES status=all] - specific registration status (use status id) or all for all attendees
88
+	 *                                          regardless of status.  Note default is to only return approved attendees
89
+	 *  [ESPRESSO_EVENT_ATTENDEES show_gravatar=true] - default is to not return gravatar.  Otherwise if this is set
90
+	 *                                                  then return gravatar for email address given.
91
+	 *  Note: because of the relationship between event_id, ticket_id, and datetime_id.
92
+	 * If more than one of those params is included then preference is given to the following:
93
+	 *  - event_id is used whenever its present and any others are ignored.
94
+	 *  - if no event_id then datetime is used whenever its present and any others are ignored.
95
+	 *  - otherwise ticket_id is used if present.
96
+	 *
97
+	 * @param array $attributes
98
+	 * @return string
99
+	 * @throws \EE_Error
100
+	 */
101
+	public function processShortcode($attributes = array())
102
+	{
103
+		// grab attributes and merge with defaults
104
+		$attributes = $this->getAttributes((array)$attributes);
105
+		// add attributes to template args
106
+		$this->template_args['show_gravatar'] = $attributes['show_gravatar'];
107
+		// add required objects: event, datetime, and ticket
108
+		$this->template_args['event'] = $this->getEventAndQueryParams($attributes);
109
+		$this->template_args['datetime'] = $this->getDatetimeAndQueryParams($attributes);
110
+		$this->template_args['ticket'] = $this->getTicketAndQueryParams($attributes);
111
+
112
+		// if any of the above objects is invalid or missing,
113
+		// then there was an invalid parameter or the shortcode was used incorrectly
114
+		// so when WP_DEBUG is set and true, we'll show a message,
115
+		// otherwise we'll just return an empty string.
116
+		 if (
117
+			! $this->template_args['event'] instanceof EE_Event
118
+			|| empty($this->query_params[0])
119
+			|| ($attributes['datetime_id'] && ! $this->template_args['datetime'] instanceof EE_Datetime)
120
+			|| ($attributes['ticket_id'] && ! $this->template_args['ticket'] instanceof EE_Ticket)
121
+		) {
122
+			if (WP_DEBUG) {
123
+				return '<div class="important-notice ee-attention">'
124
+					   . esc_html__('The [ESPRESSO_EVENT_ATTENDEES] shortcode has been used incorrectly.  Please double check the arguments you used for any typos.  In the case of ID type arguments, its possible the given ID does not correspond to existing data in the database.',
125
+						'event_espresso')
126
+					   . '</div>';
127
+			} else {
128
+				return '';
129
+			}
130
+		}
131
+		$this->setAdditionalQueryParams($attributes);
132
+		//get contacts!
133
+		$this->template_args['contacts'] = EEM_Attendee::instance()->get_all($this->query_params);
134
+		//all set let's load up the template and return.
135
+		return EEH_Template::locate_template('loop-espresso_event_attendees.php', $this->template_args, true, true);
136
+	}
137
+
138
+
139
+
140
+	/**
141
+	 * merge incoming attributes with filtered defaults
142
+	 *
143
+	 * @param array $attributes
144
+	 * @return array
145
+	 */
146
+	private function getAttributes(array $attributes)
147
+	{
148
+		return array_merge(
149
+			(array) apply_filters(
150
+				'EES_Espresso_Event_Attendees__process_shortcode__default_shortcode_atts',
151
+				array(
152
+					'event_id'      => null,
153
+					'datetime_id'   => null,
154
+					'ticket_id'     => null,
155
+					'status'        => EEM_Registration::status_id_approved,
156
+					'show_gravatar' => false
157
+				)
158
+			),
159
+			$attributes
160
+		);
161
+	}
162
+
163
+
164
+
165
+	/**
166
+	 * @param array $attributes
167
+	 * @return EE_Event|null
168
+	 * @throws \EE_Error
169
+	 */
170
+	private function getEventAndQueryParams(array $attributes){
171
+		if ( ! empty($attributes['event_id'])) {
172
+			$event = EEM_Event::instance()->get_one_by_ID($attributes['event_id']);
173
+			if ($event instanceof EE_Event) {
174
+				$this->query_params[0]['Registration.EVT_ID'] = $attributes['event_id'];
175
+				return $event;
176
+			}
177
+		}
178
+		//seems like is_espresso_event_single() isn't working as expected. So using alternate method.
179
+		if ( is_espresso_event()) {
180
+			$event = EEH_Event_View::get_event();
181
+			if ($event instanceof EE_Event) {
182
+				$this->query_params[0]['Registration.EVT_ID'] = $event->ID();
183
+				return $event;
184
+			}
185
+		}
186
+		// one last shot...
187
+		// try getting the earliest active event
188
+		$events = EEM_Event::instance()->get_active_events(array(
189
+			'limit'    => 1,
190
+			'order_by' => array('Datetime.DTT_EVT_start' => 'ASC')
191
+		));
192
+		//  if none then get the next upcoming
193
+		$events = empty($events)
194
+			? EEM_Event::instance()->get_upcoming_events(array(
195
+				'limit'    => 1,
196
+				'order_by' => array('Datetime.DTT_EVT_start' => 'ASC')
197
+			))
198
+			: $events;
199
+		$event = reset($events);
200
+		if ($event instanceof EE_Event) {
201
+			$this->query_params[0]['Registration.EVT_ID'] = $event->ID();
202
+			return $event;
203
+		}
204
+		return null;
205
+	}
206
+
207
+
208
+
209
+	/**
210
+	 * @param array $attributes
211
+	 * @return EE_Datetime|null
212
+	 */
213
+	private function getDatetimeAndQueryParams(array $attributes)
214
+	{
215
+		if ( ! empty($attributes['datetime_id'])) {
216
+			$datetime = EEM_Datetime::instance()->get_one_by_ID($attributes['datetime_id']);
217
+			if ($datetime instanceof EE_Datetime) {
218
+				$this->query_params[0]['Registration.Ticket.Datetime.DTT_ID'] = $attributes['datetime_id'];
219
+				$this->query_params['default_where_conditions'] = 'this_model_only';
220
+				if ( ! $this->template_args['event'] instanceof EE_Event) {
221
+					$this->template_args['event'] = $datetime->event();
222
+				}
223
+				return $datetime;
224
+			}
225
+		}
226
+		return null;
227
+	}
228
+
229
+
230
+
231
+	/**
232
+	 * @param array $attributes
233
+	 * @return \EE_Base_Class|null
234
+	 * @throws \EE_Error
235
+	 */
236
+	private function getTicketAndQueryParams(array $attributes)
237
+	{
238
+		if ( ! empty($attributes['ticket_id']) && empty($attributes['event_id']) && empty($attributes['datetime_id'])) {
239
+			$ticket = EEM_Ticket::instance()->get_one_by_ID($attributes['ticket_id']);
240
+			if ($ticket instanceof EE_Ticket) {
241
+				$this->query_params[0]['Registration.TKT_ID'] = $attributes['ticket_id'];
242
+				if ( ! $this->template_args['event'] instanceof EE_Event) {
243
+					$this->template_args['event'] = $ticket->first_datetime() instanceof EE_Datetime
244
+						? $ticket->first_datetime()->event()
245
+						: null;
246
+				}
247
+				return $ticket;
248
+			}
249
+		}
250
+		return null;
251
+	}
252
+
253
+
254
+
255
+	/**
256
+	 * @param array $attributes
257
+	 */
258
+	private function setAdditionalQueryParams(array $attributes)
259
+	{
260
+		$reg_status_array = EEM_Registration::reg_status_array();
261
+		if ($attributes['status'] !== 'all' && isset($reg_status_array[$attributes['status']])) {
262
+			$this->query_params[0]['Registration.STS_ID'] = $attributes['status'];
263
+		}
264
+		$this->query_params['group_by'] = array('ATT_ID');
265
+		$this->query_params['order_by'] = (array) apply_filters(
266
+			'FHEE__EES_Espresso_Event_Attendees__process_shortcode__order_by',
267
+			array('ATT_lname' => 'ASC', 'ATT_fname' => 'ASC')
268
+		);
269
+	}
270 270
 
271 271
 
272 272
 
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
     public function processShortcode($attributes = array())
102 102
     {
103 103
         // grab attributes and merge with defaults
104
-        $attributes = $this->getAttributes((array)$attributes);
104
+        $attributes = $this->getAttributes((array) $attributes);
105 105
         // add attributes to template args
106 106
         $this->template_args['show_gravatar'] = $attributes['show_gravatar'];
107 107
         // add required objects: event, datetime, and ticket
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
      * @return EE_Event|null
168 168
      * @throws \EE_Error
169 169
      */
170
-    private function getEventAndQueryParams(array $attributes){
170
+    private function getEventAndQueryParams(array $attributes) {
171 171
         if ( ! empty($attributes['event_id'])) {
172 172
             $event = EEM_Event::instance()->get_one_by_ID($attributes['event_id']);
173 173
             if ($event instanceof EE_Event) {
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
             }
177 177
         }
178 178
         //seems like is_espresso_event_single() isn't working as expected. So using alternate method.
179
-        if ( is_espresso_event()) {
179
+        if (is_espresso_event()) {
180 180
             $event = EEH_Event_View::get_event();
181 181
             if ($event instanceof EE_Event) {
182 182
                 $this->query_params[0]['Registration.EVT_ID'] = $event->ID();
Please login to merge, or discard this patch.
public/template_tags.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -206,7 +206,7 @@
 block discarded – undo
206 206
 	function espresso_ticket_selector( $event = NULL ) {
207 207
 		if (  ! apply_filters( 'FHEE_disable_espresso_ticket_selector', FALSE ) ) {
208 208
 			espresso_load_ticket_selector();
209
-            \EED_Ticket_Selector::set_definitions();
209
+			\EED_Ticket_Selector::set_definitions();
210 210
 			echo EED_Ticket_Selector::display_ticket_selector( $event );
211 211
 		}
212 212
 	}
Please login to merge, or discard this patch.
Spacing   +276 added lines, -276 removed lines patch added patch discarded remove patch
@@ -14,12 +14,12 @@  discard block
 block discarded – undo
14 14
  * @param int | \EE_Event $event
15 15
  * @return bool
16 16
  */
17
-function is_espresso_event( $event = NULL ) {
18
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
17
+function is_espresso_event($event = NULL) {
18
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
19 19
 		// extract EE_Event object from passed param regardless of what it is (within reason of course)
20
-		$event = EEH_Event_View::get_event( $event );
20
+		$event = EEH_Event_View::get_event($event);
21 21
 		// do we have a valid event ?
22
-		return $event instanceof EE_Event  ? TRUE : FALSE;
22
+		return $event instanceof EE_Event ? TRUE : FALSE;
23 23
 	}
24 24
 	return FALSE;
25 25
 }
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
  * @return bool
32 32
  */
33 33
 function is_espresso_event_single() {
34
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
34
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
35 35
 		global $wp_query;
36 36
 		// return conditionals set by CPTs
37 37
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_single : FALSE;
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
  * @return bool
47 47
  */
48 48
 function is_espresso_event_archive() {
49
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
49
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
50 50
 		global $wp_query;
51 51
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_archive : FALSE;
52 52
 	}
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
  * @return bool
61 61
  */
62 62
 function is_espresso_event_taxonomy() {
63
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
63
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
64 64
 		global $wp_query;
65 65
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_taxonomy : FALSE;
66 66
 	}
@@ -74,10 +74,10 @@  discard block
 block discarded – undo
74 74
  * @param int | \EE_Venue $venue
75 75
  * @return bool
76 76
  */
77
-function is_espresso_venue( $venue = NULL ) {
78
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
77
+function is_espresso_venue($venue = NULL) {
78
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
79 79
 		// extract EE_Venue object from passed param regardless of what it is (within reason of course)
80
-		$venue = EEH_Venue_View::get_venue( $venue, FALSE );
80
+		$venue = EEH_Venue_View::get_venue($venue, FALSE);
81 81
 		// do we have a valid event ?
82 82
 		return $venue instanceof EE_Venue ? TRUE : FALSE;
83 83
 	}
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
  * @return bool
92 92
  */
93 93
 function is_espresso_venue_single() {
94
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
94
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
95 95
 		global $wp_query;
96 96
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_single : FALSE;
97 97
 	}
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
  * @return bool
106 106
  */
107 107
 function is_espresso_venue_archive() {
108
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
108
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
109 109
 		global $wp_query;
110 110
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_archive : FALSE;
111 111
 	}
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
  * @return bool
120 120
  */
121 121
 function is_espresso_venue_taxonomy() {
122
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
122
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
123 123
 		global $wp_query;
124 124
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_taxonomy : FALSE;
125 125
 	}
@@ -133,12 +133,12 @@  discard block
 block discarded – undo
133 133
  * @param $conditional_tag
134 134
  * @return bool
135 135
  */
136
-function can_use_espresso_conditionals( $conditional_tag ) {
137
-	if ( ! did_action( 'AHEE__EE_System__initialize' )) {
136
+function can_use_espresso_conditionals($conditional_tag) {
137
+	if ( ! did_action('AHEE__EE_System__initialize')) {
138 138
 		EE_Error::doing_it_wrong(
139 139
 			__FUNCTION__,
140 140
 			sprintf(
141
-				__( 'The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.','event_espresso'),
141
+				__('The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.', 'event_espresso'),
142 142
 				$conditional_tag
143 143
 			),
144 144
 			'4.4.0'
@@ -153,13 +153,13 @@  discard block
 block discarded – undo
153 153
 
154 154
 /*************************** Event Queries ***************************/
155 155
 
156
-if ( ! function_exists( 'espresso_get_events' )) {
156
+if ( ! function_exists('espresso_get_events')) {
157 157
 	/**
158 158
 	 * 	espresso_get_events
159 159
 	 * @param array $params
160 160
 	 * @return array
161 161
 	 */
162
-	function espresso_get_events( $params = array() ) {
162
+	function espresso_get_events($params = array()) {
163 163
 		//set default params
164 164
 		$default_espresso_events_params = array(
165 165
 			'limit' => 10,
@@ -170,18 +170,18 @@  discard block
 block discarded – undo
170 170
 			'sort' => 'ASC'
171 171
 		);
172 172
 		// allow the defaults to be filtered
173
-		$default_espresso_events_params = apply_filters( 'espresso_get_events__default_espresso_events_params', $default_espresso_events_params );
173
+		$default_espresso_events_params = apply_filters('espresso_get_events__default_espresso_events_params', $default_espresso_events_params);
174 174
 		// grab params and merge with defaults, then extract
175
-		$params = array_merge( $default_espresso_events_params, $params );
175
+		$params = array_merge($default_espresso_events_params, $params);
176 176
 		// run the query
177
-		$events_query = new EventEspresso\core\domain\services\wp_queries\EventListQuery( $params );
177
+		$events_query = new EventEspresso\core\domain\services\wp_queries\EventListQuery($params);
178 178
 		// assign results to a variable so we can return it
179 179
 		$events = $events_query->have_posts() ? $events_query->posts : array();
180 180
 		// but first reset the query and postdata
181 181
 		wp_reset_query();
182 182
 		wp_reset_postdata();
183 183
 		EED_Events_Archive::remove_all_events_archive_filters();
184
-		unset( $events_query );
184
+		unset($events_query);
185 185
 		return $events;
186 186
 	}
187 187
 }
@@ -195,33 +195,33 @@  discard block
 block discarded – undo
195 195
  * espresso_load_ticket_selector
196 196
  */
197 197
 function espresso_load_ticket_selector() {
198
-	EE_Registry::instance()->load_file( EE_MODULES . 'ticket_selector', 'EED_Ticket_Selector', 'module' );
198
+	EE_Registry::instance()->load_file(EE_MODULES.'ticket_selector', 'EED_Ticket_Selector', 'module');
199 199
 }
200 200
 
201
-if ( ! function_exists( 'espresso_ticket_selector' )) {
201
+if ( ! function_exists('espresso_ticket_selector')) {
202 202
 	/**
203 203
 	 * espresso_ticket_selector
204 204
 	 * @param null $event
205 205
 	 */
206
-	function espresso_ticket_selector( $event = NULL ) {
207
-		if (  ! apply_filters( 'FHEE_disable_espresso_ticket_selector', FALSE ) ) {
206
+	function espresso_ticket_selector($event = NULL) {
207
+		if ( ! apply_filters('FHEE_disable_espresso_ticket_selector', FALSE)) {
208 208
 			espresso_load_ticket_selector();
209 209
             \EED_Ticket_Selector::set_definitions();
210
-			echo EED_Ticket_Selector::display_ticket_selector( $event );
210
+			echo EED_Ticket_Selector::display_ticket_selector($event);
211 211
 		}
212 212
 	}
213 213
 }
214 214
 
215 215
 
216
-	if ( ! function_exists( 'espresso_view_details_btn' )) {
216
+	if ( ! function_exists('espresso_view_details_btn')) {
217 217
 	/**
218 218
 	 * espresso_view_details_btn
219 219
 	 * @param null $event
220 220
 	 */
221
-	function espresso_view_details_btn( $event = NULL ) {
222
-		if (  ! apply_filters( 'FHEE_disable_espresso_view_details_btn', FALSE ) ) {
221
+	function espresso_view_details_btn($event = NULL) {
222
+		if ( ! apply_filters('FHEE_disable_espresso_view_details_btn', FALSE)) {
223 223
 			espresso_load_ticket_selector();
224
-			echo EED_Ticket_Selector::display_ticket_selector( $event, TRUE );
224
+			echo EED_Ticket_Selector::display_ticket_selector($event, TRUE);
225 225
 		}
226 226
 	}
227 227
 }
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 
232 232
 /*************************** EEH_Event_View ***************************/
233 233
 
234
-if ( ! function_exists( 'espresso_load_event_list_assets' )) {
234
+if ( ! function_exists('espresso_load_event_list_assets')) {
235 235
 	/**
236 236
 	 * espresso_load_event_list_assets
237 237
 	 * ensures that event list styles and scripts are loaded
@@ -240,13 +240,13 @@  discard block
 block discarded – undo
240 240
 	 */
241 241
 	function espresso_load_event_list_assets() {
242 242
 		$event_list = EED_Events_Archive::instance();
243
-		add_action( 'AHEE__EE_System__initialize_last', array( $event_list, 'load_event_list_assets' ), 10 );
244
-		add_filter( 'FHEE_enable_default_espresso_css', '__return_true' );
243
+		add_action('AHEE__EE_System__initialize_last', array($event_list, 'load_event_list_assets'), 10);
244
+		add_filter('FHEE_enable_default_espresso_css', '__return_true');
245 245
 	}
246 246
 }
247 247
 
248 248
 
249
-if ( ! function_exists( 'espresso_event_reg_button' )) {
249
+if ( ! function_exists('espresso_event_reg_button')) {
250 250
 	/**
251 251
 	 * espresso_event_reg_button
252 252
 	 * returns the "Register Now" button if event is active,
@@ -258,9 +258,9 @@  discard block
 block discarded – undo
258 258
 	 * @param bool $EVT_ID
259 259
 	 * @return string
260 260
 	 */
261
-	function espresso_event_reg_button( $btn_text_if_active = NULL, $btn_text_if_inactive = FALSE, $EVT_ID = FALSE ) {
262
-		$event_status = EEH_Event_View::event_active_status( $EVT_ID );
263
-		switch ( $event_status ) {
261
+	function espresso_event_reg_button($btn_text_if_active = NULL, $btn_text_if_inactive = FALSE, $EVT_ID = FALSE) {
262
+		$event_status = EEH_Event_View::event_active_status($EVT_ID);
263
+		switch ($event_status) {
264 264
 			case EE_Datetime::sold_out :
265 265
 				$btn_text = __('Sold Out', 'event_espresso');
266 266
 				$class = 'ee-pink';
@@ -276,10 +276,10 @@  discard block
 block discarded – undo
276 276
 			case EE_Datetime::upcoming :
277 277
 			case EE_Datetime::active :
278 278
 			default :
279
-				$btn_text =! empty( $btn_text_if_active ) ? $btn_text_if_active : __( 'Register Now', 'event_espresso' );
279
+				$btn_text = ! empty($btn_text_if_active) ? $btn_text_if_active : __('Register Now', 'event_espresso');
280 280
 				$class = 'ee-green';
281 281
 		}
282
-		if ( $event_status < 1 && ! empty( $btn_text_if_inactive )) {
282
+		if ($event_status < 1 && ! empty($btn_text_if_inactive)) {
283 283
 			$btn_text = $btn_text_if_inactive;
284 284
 			$class = 'ee-grey';
285 285
 		}
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 
294 294
 
295 295
 
296
-if ( ! function_exists( 'espresso_display_ticket_selector' )) {
296
+if ( ! function_exists('espresso_display_ticket_selector')) {
297 297
 	/**
298 298
 	 * espresso_display_ticket_selector
299 299
 	 * whether or not to display the Ticket Selector for an event
@@ -301,14 +301,14 @@  discard block
 block discarded – undo
301 301
 	 * @param bool $EVT_ID
302 302
 	 * @return boolean
303 303
 	 */
304
-	function espresso_display_ticket_selector( $EVT_ID = FALSE ) {
305
-		return EEH_Event_View::display_ticket_selector( $EVT_ID );
304
+	function espresso_display_ticket_selector($EVT_ID = FALSE) {
305
+		return EEH_Event_View::display_ticket_selector($EVT_ID);
306 306
 	}
307 307
 }
308 308
 
309 309
 
310 310
 
311
-if ( ! function_exists( 'espresso_event_status_banner' )) {
311
+if ( ! function_exists('espresso_event_status_banner')) {
312 312
 	/**
313 313
 	 * espresso_event_status
314 314
 	 * returns a banner showing the event status if it is sold out, expired, or inactive
@@ -316,13 +316,13 @@  discard block
 block discarded – undo
316 316
 	 * @param bool $EVT_ID
317 317
 	 * @return string
318 318
 	 */
319
-	function espresso_event_status_banner( $EVT_ID = FALSE ) {
320
-		return EEH_Event_View::event_status( $EVT_ID );
319
+	function espresso_event_status_banner($EVT_ID = FALSE) {
320
+		return EEH_Event_View::event_status($EVT_ID);
321 321
 	}
322 322
 }
323 323
 
324 324
 
325
-if ( ! function_exists( 'espresso_event_status' )) {
325
+if ( ! function_exists('espresso_event_status')) {
326 326
 	/**
327 327
 	 * espresso_event_status
328 328
 	 * returns the event status if it is sold out, expired, or inactive
@@ -331,17 +331,17 @@  discard block
 block discarded – undo
331 331
 	 * @param bool $echo
332 332
 	 * @return string
333 333
 	 */
334
-	function espresso_event_status( $EVT_ID = 0, $echo = TRUE ) {
335
-		if ( $echo ) {
336
-			echo EEH_Event_View::event_active_status( $EVT_ID );
334
+	function espresso_event_status($EVT_ID = 0, $echo = TRUE) {
335
+		if ($echo) {
336
+			echo EEH_Event_View::event_active_status($EVT_ID);
337 337
 			return '';
338 338
 		}
339
-		return EEH_Event_View::event_active_status( $EVT_ID );
339
+		return EEH_Event_View::event_active_status($EVT_ID);
340 340
 	}
341 341
 }
342 342
 
343 343
 
344
-if ( ! function_exists( 'espresso_event_categories' )) {
344
+if ( ! function_exists('espresso_event_categories')) {
345 345
 	/**
346 346
 	 * espresso_event_categories
347 347
 	 * returns the terms associated with an event
@@ -351,17 +351,17 @@  discard block
 block discarded – undo
351 351
 	 * @param bool $echo
352 352
 	 * @return string
353 353
 	 */
354
-	function espresso_event_categories( $EVT_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE ) {
355
-		if ( $echo ) {
356
-			echo EEH_Event_View::event_categories( $EVT_ID, $hide_uncategorized );
354
+	function espresso_event_categories($EVT_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE) {
355
+		if ($echo) {
356
+			echo EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized);
357 357
 			return '';
358 358
 		}
359
-		return EEH_Event_View::event_categories( $EVT_ID, $hide_uncategorized );
359
+		return EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized);
360 360
 	}
361 361
 }
362 362
 
363 363
 
364
-if ( ! function_exists( 'espresso_event_tickets_available' )) {
364
+if ( ! function_exists('espresso_event_tickets_available')) {
365 365
 	/**
366 366
 	 * espresso_event_tickets_available
367 367
 	 * returns the ticket types available for purchase for an event
@@ -371,26 +371,26 @@  discard block
 block discarded – undo
371 371
 	 * @param bool $format
372 372
 	 * @return string
373 373
 	 */
374
-	function espresso_event_tickets_available( $EVT_ID = 0, $echo = TRUE, $format = TRUE ) {
375
-		$tickets = EEH_Event_View::event_tickets_available( $EVT_ID );
376
-		if ( is_array( $tickets ) && ! empty( $tickets )) {
374
+	function espresso_event_tickets_available($EVT_ID = 0, $echo = TRUE, $format = TRUE) {
375
+		$tickets = EEH_Event_View::event_tickets_available($EVT_ID);
376
+		if (is_array($tickets) && ! empty($tickets)) {
377 377
 			// if formatting then $html will be a string, else it will be an array of ticket objects
378
-			$html = $format ? '<ul id="ee-event-tickets-ul-' . $EVT_ID . '" class="ee-event-tickets-ul">' : array();
379
-			foreach ( $tickets as $ticket ) {
380
-				if ( $ticket instanceof EE_Ticket ) {
381
-					if ( $format ) {
382
-						$html .= '<li id="ee-event-tickets-li-' . $ticket->ID() . '" class="ee-event-tickets-li">';
383
-						$html .= $ticket->name() . ' ' . EEH_Template::format_currency( $ticket->get_ticket_total_with_taxes() );
378
+			$html = $format ? '<ul id="ee-event-tickets-ul-'.$EVT_ID.'" class="ee-event-tickets-ul">' : array();
379
+			foreach ($tickets as $ticket) {
380
+				if ($ticket instanceof EE_Ticket) {
381
+					if ($format) {
382
+						$html .= '<li id="ee-event-tickets-li-'.$ticket->ID().'" class="ee-event-tickets-li">';
383
+						$html .= $ticket->name().' '.EEH_Template::format_currency($ticket->get_ticket_total_with_taxes());
384 384
 						$html .= '</li>';
385 385
 					} else {
386 386
 						$html[] = $ticket;
387 387
 					}
388 388
 				}
389 389
 			}
390
-			if ( $format ) {
390
+			if ($format) {
391 391
 				$html .= '</ul>';
392 392
 			}
393
-			if ( $echo && ! $format ) {
393
+			if ($echo && ! $format) {
394 394
 				echo $html;
395 395
 				return '';
396 396
 			}
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
 	}
401 401
 }
402 402
 
403
-if ( ! function_exists( 'espresso_event_date_obj' )) {
403
+if ( ! function_exists('espresso_event_date_obj')) {
404 404
 	/**
405 405
 	 * espresso_event_date_obj
406 406
 	 * returns the primary date object for an event
@@ -408,13 +408,13 @@  discard block
 block discarded – undo
408 408
 	 * @param bool $EVT_ID
409 409
 	 * @return object
410 410
 	 */
411
-	function espresso_event_date_obj( $EVT_ID = FALSE ) {
412
-		return EEH_Event_View::get_primary_date_obj( $EVT_ID );
411
+	function espresso_event_date_obj($EVT_ID = FALSE) {
412
+		return EEH_Event_View::get_primary_date_obj($EVT_ID);
413 413
 	}
414 414
 }
415 415
 
416 416
 
417
-if ( ! function_exists( 'espresso_event_date' )) {
417
+if ( ! function_exists('espresso_event_date')) {
418 418
 	/**
419 419
 	 * espresso_event_date
420 420
 	 * returns the primary date for an event
@@ -425,22 +425,22 @@  discard block
 block discarded – undo
425 425
 	 * @param bool $echo
426 426
 	 * @return string
427 427
 	 */
428
-	function espresso_event_date( $date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE ) {
429
-		$date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' );
430
-		$time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' );
431
-		$date_format = apply_filters( 'FHEE__espresso_event_date__date_format', $date_format );
432
-		$time_format = apply_filters( 'FHEE__espresso_event_date__time_format', $time_format );
433
-		if($echo){
434
-			echo EEH_Event_View::the_event_date( $date_format, $time_format, $EVT_ID );
428
+	function espresso_event_date($date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE) {
429
+		$date_format = ! empty($date_format) ? $date_format : get_option('date_format');
430
+		$time_format = ! empty($time_format) ? $time_format : get_option('time_format');
431
+		$date_format = apply_filters('FHEE__espresso_event_date__date_format', $date_format);
432
+		$time_format = apply_filters('FHEE__espresso_event_date__time_format', $time_format);
433
+		if ($echo) {
434
+			echo EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID);
435 435
 			return '';
436 436
 		}
437
-		return EEH_Event_View::the_event_date( $date_format, $time_format, $EVT_ID );
437
+		return EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID);
438 438
 
439 439
 	}
440 440
 }
441 441
 
442 442
 
443
-if ( ! function_exists( 'espresso_list_of_event_dates' )) {
443
+if ( ! function_exists('espresso_list_of_event_dates')) {
444 444
 	/**
445 445
 	 * espresso_list_of_event_dates
446 446
 	 * returns a unordered list of dates for an event
@@ -455,40 +455,40 @@  discard block
 block discarded – undo
455 455
 	 * @param null   $limit
456 456
 	 * @return string
457 457
 	 */
458
-	function espresso_list_of_event_dates( $EVT_ID = 0, $date_format = '', $time_format = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE, $limit = NULL ) {
459
-		$date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' );
460
-		$time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' );
461
-		$date_format = apply_filters( 'FHEE__espresso_list_of_event_dates__date_format', $date_format );
462
-		$time_format = apply_filters( 'FHEE__espresso_list_of_event_dates__time_format', $time_format );
463
-		$datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID, $show_expired, FALSE, $limit );
464
-		if ( ! $format ) {
465
-			return apply_filters( 'FHEE__espresso_list_of_event_dates__datetimes', $datetimes );
458
+	function espresso_list_of_event_dates($EVT_ID = 0, $date_format = '', $time_format = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE, $limit = NULL) {
459
+		$date_format = ! empty($date_format) ? $date_format : get_option('date_format');
460
+		$time_format = ! empty($time_format) ? $time_format : get_option('time_format');
461
+		$date_format = apply_filters('FHEE__espresso_list_of_event_dates__date_format', $date_format);
462
+		$time_format = apply_filters('FHEE__espresso_list_of_event_dates__time_format', $time_format);
463
+		$datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, $show_expired, FALSE, $limit);
464
+		if ( ! $format) {
465
+			return apply_filters('FHEE__espresso_list_of_event_dates__datetimes', $datetimes);
466 466
 		}
467 467
 		//d( $datetimes );
468
-		if ( is_array( $datetimes ) && ! empty( $datetimes )) {
468
+		if (is_array($datetimes) && ! empty($datetimes)) {
469 469
 			global $post;
470
-			$html = $format ? '<ul id="ee-event-datetimes-ul-' . $post->ID . '" class="ee-event-datetimes-ul ee-clearfix">' : '';
471
-			foreach ( $datetimes as $datetime ) {
472
-				if ( $datetime instanceof EE_Datetime ) {
473
-					$html .= '<li id="ee-event-datetimes-li-' . $datetime->ID();
474
-					$html .= '" class="ee-event-datetimes-li ee-event-datetimes-li-' . $datetime->get_active_status() . '">';
470
+			$html = $format ? '<ul id="ee-event-datetimes-ul-'.$post->ID.'" class="ee-event-datetimes-ul ee-clearfix">' : '';
471
+			foreach ($datetimes as $datetime) {
472
+				if ($datetime instanceof EE_Datetime) {
473
+					$html .= '<li id="ee-event-datetimes-li-'.$datetime->ID();
474
+					$html .= '" class="ee-event-datetimes-li ee-event-datetimes-li-'.$datetime->get_active_status().'">';
475 475
 					$datetime_name = $datetime->name();
476
-					$html .= ! empty( $datetime_name ) ? '<strong>' . $datetime_name . '</strong>' : '';
477
-					$html .= ! empty( $datetime_name )  && $add_breaks ? '<br />' : '';
478
-					$html .= '<span class="dashicons dashicons-calendar"></span><span class="ee-event-datetimes-li-daterange">' . $datetime->date_range( $date_format ) . '</span><br/>';
479
-					$html .= '<span class="dashicons dashicons-clock"></span><span class="ee-event-datetimes-li-timerange">' . $datetime->time_range( $time_format ) . '</span>';
476
+					$html .= ! empty($datetime_name) ? '<strong>'.$datetime_name.'</strong>' : '';
477
+					$html .= ! empty($datetime_name) && $add_breaks ? '<br />' : '';
478
+					$html .= '<span class="dashicons dashicons-calendar"></span><span class="ee-event-datetimes-li-daterange">'.$datetime->date_range($date_format).'</span><br/>';
479
+					$html .= '<span class="dashicons dashicons-clock"></span><span class="ee-event-datetimes-li-timerange">'.$datetime->time_range($time_format).'</span>';
480 480
 					$datetime_description = $datetime->description();
481
-					$html .= ! empty( $datetime_description )  && $add_breaks ? '<br />' : '';
482
-					$html .= ! empty( $datetime_description ) ? ' - ' . $datetime_description : '';
483
-					$html = apply_filters( 'FHEE__espresso_list_of_event_dates__datetime_html', $html, $datetime );
481
+					$html .= ! empty($datetime_description) && $add_breaks ? '<br />' : '';
482
+					$html .= ! empty($datetime_description) ? ' - '.$datetime_description : '';
483
+					$html = apply_filters('FHEE__espresso_list_of_event_dates__datetime_html', $html, $datetime);
484 484
 					$html .= '</li>';
485 485
 				}
486 486
 			}
487 487
 			$html .= $format ? '</ul>' : '';
488 488
 		} else {
489
-			$html = $format ?  '<p><span class="dashicons dashicons-marker pink-text"></span>' . __( 'There are no upcoming dates for this event.', 'event_espresso' ) . '</p><br/>' : '';
489
+			$html = $format ? '<p><span class="dashicons dashicons-marker pink-text"></span>'.__('There are no upcoming dates for this event.', 'event_espresso').'</p><br/>' : '';
490 490
 		}
491
-		if ( $echo ) {
491
+		if ($echo) {
492 492
 			echo $html;
493 493
 			return '';
494 494
 		}
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
 }
498 498
 
499 499
 
500
-if ( ! function_exists( 'espresso_event_end_date' )) {
500
+if ( ! function_exists('espresso_event_end_date')) {
501 501
 	/**
502 502
 	 * espresso_event_end_date
503 503
 	 * returns the last date for an event
@@ -508,20 +508,20 @@  discard block
 block discarded – undo
508 508
 	 * @param bool   $echo
509 509
 	 * @return string
510 510
 	 */
511
-	function espresso_event_end_date( $date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE ) {
512
-		$date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' );
513
-		$time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' );
514
-		$date_format = apply_filters( 'FHEE__espresso_event_end_date__date_format', $date_format );
515
-		$time_format = apply_filters( 'FHEE__espresso_event_end_date__time_format', $time_format );
516
-		if($echo){
517
-			echo EEH_Event_View::the_event_end_date( $date_format, $time_format, $EVT_ID );
511
+	function espresso_event_end_date($date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE) {
512
+		$date_format = ! empty($date_format) ? $date_format : get_option('date_format');
513
+		$time_format = ! empty($time_format) ? $time_format : get_option('time_format');
514
+		$date_format = apply_filters('FHEE__espresso_event_end_date__date_format', $date_format);
515
+		$time_format = apply_filters('FHEE__espresso_event_end_date__time_format', $time_format);
516
+		if ($echo) {
517
+			echo EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID);
518 518
 			return '';
519 519
 		}
520
-		return EEH_Event_View::the_event_end_date( $date_format, $time_format, $EVT_ID );
520
+		return EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID);
521 521
 	}
522 522
 }
523 523
 
524
-if ( ! function_exists( 'espresso_event_date_range' )) {
524
+if ( ! function_exists('espresso_event_date_range')) {
525 525
 	/**
526 526
 	 * espresso_event_date_range
527 527
 	 * returns the first and last chronologically ordered dates for an event (if different)
@@ -534,31 +534,31 @@  discard block
 block discarded – undo
534 534
 	 * @param bool   $echo
535 535
 	 * @return string
536 536
 	 */
537
-	function espresso_event_date_range( $date_format = '', $time_format = '', $single_date_format = '', $single_time_format = '', $EVT_ID = FALSE, $echo = TRUE ) {
537
+	function espresso_event_date_range($date_format = '', $time_format = '', $single_date_format = '', $single_time_format = '', $EVT_ID = FALSE, $echo = TRUE) {
538 538
 		// set and filter date and time formats when a range is returned
539
-		$date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' );
540
-		$date_format = apply_filters( 'FHEE__espresso_event_date_range__date_format', $date_format );
539
+		$date_format = ! empty($date_format) ? $date_format : get_option('date_format');
540
+		$date_format = apply_filters('FHEE__espresso_event_date_range__date_format', $date_format);
541 541
 		// get the start and end date with NO time portion
542
-		$the_event_date = EEH_Event_View::the_earliest_event_date( $date_format, '', $EVT_ID );
543
-		$the_event_end_date = EEH_Event_View::the_latest_event_date( $date_format, '', $EVT_ID );
542
+		$the_event_date = EEH_Event_View::the_earliest_event_date($date_format, '', $EVT_ID);
543
+		$the_event_end_date = EEH_Event_View::the_latest_event_date($date_format, '', $EVT_ID);
544 544
 		// now we can determine if date range spans more than one day
545
-		if ( $the_event_date != $the_event_end_date ) {
546
-			$time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' );
547
-			$time_format = apply_filters( 'FHEE__espresso_event_date_range__time_format', $time_format );
545
+		if ($the_event_date != $the_event_end_date) {
546
+			$time_format = ! empty($time_format) ? $time_format : get_option('time_format');
547
+			$time_format = apply_filters('FHEE__espresso_event_date_range__time_format', $time_format);
548 548
 			$html = sprintf(
549
-				__( '%1$s - %2$s', 'event_espresso' ),
550
-				EEH_Event_View::the_earliest_event_date( $date_format, $time_format, $EVT_ID ),
551
-				EEH_Event_View::the_latest_event_date( $date_format, $time_format, $EVT_ID )
549
+				__('%1$s - %2$s', 'event_espresso'),
550
+				EEH_Event_View::the_earliest_event_date($date_format, $time_format, $EVT_ID),
551
+				EEH_Event_View::the_latest_event_date($date_format, $time_format, $EVT_ID)
552 552
 			);
553 553
 		} else {
554 554
 			// set and filter date and time formats when only a single datetime is returned
555
-			$single_date_format = ! empty( $single_date_format ) ? $single_date_format : get_option( 'date_format' );
556
-			$single_time_format = ! empty( $single_time_format ) ? $single_time_format : get_option( 'time_format' );
557
-			$single_date_format = apply_filters( 'FHEE__espresso_event_date_range__single_date_format', $single_date_format );
558
-			$single_time_format = apply_filters( 'FHEE__espresso_event_date_range__single_time_format', $single_time_format );
559
-			$html = EEH_Event_View::the_earliest_event_date( $single_date_format, $single_time_format, $EVT_ID );
555
+			$single_date_format = ! empty($single_date_format) ? $single_date_format : get_option('date_format');
556
+			$single_time_format = ! empty($single_time_format) ? $single_time_format : get_option('time_format');
557
+			$single_date_format = apply_filters('FHEE__espresso_event_date_range__single_date_format', $single_date_format);
558
+			$single_time_format = apply_filters('FHEE__espresso_event_date_range__single_time_format', $single_time_format);
559
+			$html = EEH_Event_View::the_earliest_event_date($single_date_format, $single_time_format, $EVT_ID);
560 560
 		}
561
-		if ( $echo ) {
561
+		if ($echo) {
562 562
 			echo $html;
563 563
 			return '';
564 564
 		}
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
 }
568 568
 
569 569
 
570
-if ( ! function_exists( 'espresso_event_date_as_calendar_page' )) {
570
+if ( ! function_exists('espresso_event_date_as_calendar_page')) {
571 571
 	/**
572 572
 	 * espresso_event_date_as_calendar_page
573 573
 	 * returns the primary date for an event, stylized to appear as the page of a calendar
@@ -575,15 +575,15 @@  discard block
 block discarded – undo
575 575
 	 * @param bool $EVT_ID
576 576
 	 * @return string
577 577
 	 */
578
-	function espresso_event_date_as_calendar_page( $EVT_ID = FALSE ) {
579
-		EEH_Event_View::event_date_as_calendar_page( $EVT_ID );
578
+	function espresso_event_date_as_calendar_page($EVT_ID = FALSE) {
579
+		EEH_Event_View::event_date_as_calendar_page($EVT_ID);
580 580
 	}
581 581
 }
582 582
 
583 583
 
584 584
 
585 585
 
586
-if ( ! function_exists( 'espresso_event_link_url' )) {
586
+if ( ! function_exists('espresso_event_link_url')) {
587 587
 	/**
588 588
 	 * espresso_event_link_url
589 589
 	 *
@@ -591,18 +591,18 @@  discard block
 block discarded – undo
591 591
 	 * @param bool $echo
592 592
 	 * @return string
593 593
 	 */
594
-	function espresso_event_link_url( $EVT_ID = 0, $echo = TRUE ) {
595
-		if ( $echo ) {
596
-			echo EEH_Event_View::event_link_url( $EVT_ID );
594
+	function espresso_event_link_url($EVT_ID = 0, $echo = TRUE) {
595
+		if ($echo) {
596
+			echo EEH_Event_View::event_link_url($EVT_ID);
597 597
 			return '';
598 598
 		}
599
-		return EEH_Event_View::event_link_url( $EVT_ID );
599
+		return EEH_Event_View::event_link_url($EVT_ID);
600 600
 	}
601 601
 }
602 602
 
603 603
 
604 604
 
605
-if ( ! function_exists( 'espresso_event_has_content_or_excerpt' )) {
605
+if ( ! function_exists('espresso_event_has_content_or_excerpt')) {
606 606
 	/**
607 607
 	 *    espresso_event_has_content_or_excerpt
608 608
 	 *
@@ -610,15 +610,15 @@  discard block
 block discarded – undo
610 610
 	 * @param bool $EVT_ID
611 611
 	 * @return    boolean
612 612
 	 */
613
-	function espresso_event_has_content_or_excerpt( $EVT_ID = FALSE ) {
614
-		return EEH_Event_View::event_has_content_or_excerpt( $EVT_ID );
613
+	function espresso_event_has_content_or_excerpt($EVT_ID = FALSE) {
614
+		return EEH_Event_View::event_has_content_or_excerpt($EVT_ID);
615 615
 	}
616 616
 }
617 617
 
618 618
 
619 619
 
620 620
 
621
-if ( ! function_exists( 'espresso_event_content_or_excerpt' )) {
621
+if ( ! function_exists('espresso_event_content_or_excerpt')) {
622 622
 	/**
623 623
 	 * espresso_event_content_or_excerpt
624 624
 	 *
@@ -627,18 +627,18 @@  discard block
 block discarded – undo
627 627
 	 * @param bool $echo
628 628
 	 * @return string
629 629
 	 */
630
-	function espresso_event_content_or_excerpt( $num_words = 55, $more = NULL, $echo = TRUE ) {
631
-		if ( $echo ) {
632
-			echo EEH_Event_View::event_content_or_excerpt( $num_words, $more );
630
+	function espresso_event_content_or_excerpt($num_words = 55, $more = NULL, $echo = TRUE) {
631
+		if ($echo) {
632
+			echo EEH_Event_View::event_content_or_excerpt($num_words, $more);
633 633
 			return '';
634 634
 		}
635
-		return EEH_Event_View::event_content_or_excerpt( $num_words, $more );
635
+		return EEH_Event_View::event_content_or_excerpt($num_words, $more);
636 636
 	}
637 637
 }
638 638
 
639 639
 
640 640
 
641
-if ( ! function_exists( 'espresso_event_phone' )) {
641
+if ( ! function_exists('espresso_event_phone')) {
642 642
 	/**
643 643
 	 * espresso_event_phone
644 644
 	 *
@@ -646,18 +646,18 @@  discard block
 block discarded – undo
646 646
 	 * @param bool $echo
647 647
 	 * @return string
648 648
 	 */
649
-	function espresso_event_phone( $EVT_ID = 0, $echo = TRUE ) {
650
-		if ( $echo ) {
651
-			echo EEH_Event_View::event_phone( $EVT_ID );
649
+	function espresso_event_phone($EVT_ID = 0, $echo = TRUE) {
650
+		if ($echo) {
651
+			echo EEH_Event_View::event_phone($EVT_ID);
652 652
 			return '';
653 653
 		}
654
-		return EEH_Event_View::event_phone( $EVT_ID );
654
+		return EEH_Event_View::event_phone($EVT_ID);
655 655
 	}
656 656
 }
657 657
 
658 658
 
659 659
 
660
-if ( ! function_exists( 'espresso_edit_event_link' )) {
660
+if ( ! function_exists('espresso_edit_event_link')) {
661 661
 	/**
662 662
 	 * espresso_edit_event_link
663 663
 	 * returns a link to edit an event
@@ -666,39 +666,39 @@  discard block
 block discarded – undo
666 666
 	 * @param bool $echo
667 667
 	 * @return string
668 668
 	 */
669
-	function espresso_edit_event_link( $EVT_ID = 0, $echo = TRUE ) {
670
-		if ( $echo ) {
671
-			echo EEH_Event_View::edit_event_link( $EVT_ID );
669
+	function espresso_edit_event_link($EVT_ID = 0, $echo = TRUE) {
670
+		if ($echo) {
671
+			echo EEH_Event_View::edit_event_link($EVT_ID);
672 672
 			return '';
673 673
 		}
674
-		return EEH_Event_View::edit_event_link( $EVT_ID );
674
+		return EEH_Event_View::edit_event_link($EVT_ID);
675 675
 	}
676 676
 }
677 677
 
678 678
 
679
-if ( ! function_exists( 'espresso_organization_name' )) {
679
+if ( ! function_exists('espresso_organization_name')) {
680 680
 	/**
681 681
 	 * espresso_organization_name
682 682
 	 * @param bool $echo
683 683
 	 * @return string
684 684
 	 */
685 685
 	function espresso_organization_name($echo = TRUE) {
686
-		if($echo){
687
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'name' );
686
+		if ($echo) {
687
+			echo EE_Registry::instance()->CFG->organization->get_pretty('name');
688 688
 			return '';
689 689
 		}
690
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'name' );
690
+		return EE_Registry::instance()->CFG->organization->get_pretty('name');
691 691
 	}
692 692
 }
693 693
 
694
-if ( ! function_exists( 'espresso_organization_address' )) {
694
+if ( ! function_exists('espresso_organization_address')) {
695 695
 	/**
696 696
 	 * espresso_organization_address
697 697
 	 * @param string $type
698 698
 	 * @return string
699 699
 	 */
700
-	function espresso_organization_address( $type = 'inline' ) {
701
-		if ( EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config ) {
700
+	function espresso_organization_address($type = 'inline') {
701
+		if (EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config) {
702 702
 			$address = new EventEspresso\core\domain\entities\GenericAddress(
703 703
 				EE_Registry::instance()->CFG->organization->address_1,
704 704
 				EE_Registry::instance()->CFG->organization->address_2,
@@ -707,129 +707,129 @@  discard block
 block discarded – undo
707 707
 				EE_Registry::instance()->CFG->organization->zip,
708 708
 				EE_Registry::instance()->CFG->organization->CNT_ISO
709 709
 			);
710
-			return EEH_Address::format( $address, $type );
710
+			return EEH_Address::format($address, $type);
711 711
 		}
712 712
 		return '';
713 713
 	}
714 714
 }
715 715
 
716
-if ( ! function_exists( 'espresso_organization_email' )) {
716
+if ( ! function_exists('espresso_organization_email')) {
717 717
 	/**
718 718
 	 * espresso_organization_email
719 719
 	 * @param bool $echo
720 720
 	 * @return string
721 721
 	 */
722
-	function espresso_organization_email( $echo = TRUE ) {
723
-		if($echo){
724
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'email' );
722
+	function espresso_organization_email($echo = TRUE) {
723
+		if ($echo) {
724
+			echo EE_Registry::instance()->CFG->organization->get_pretty('email');
725 725
 			return '';
726 726
 		}
727
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'email' );
727
+		return EE_Registry::instance()->CFG->organization->get_pretty('email');
728 728
 	}
729 729
 }
730 730
 
731
-if ( ! function_exists( 'espresso_organization_logo_url' )) {
731
+if ( ! function_exists('espresso_organization_logo_url')) {
732 732
 	/**
733 733
 	 * espresso_organization_logo_url
734 734
 	 * @param bool $echo
735 735
 	 * @return string
736 736
 	 */
737
-	function espresso_organization_logo_url( $echo = TRUE ) {
738
-		if($echo){
739
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' );
737
+	function espresso_organization_logo_url($echo = TRUE) {
738
+		if ($echo) {
739
+			echo EE_Registry::instance()->CFG->organization->get_pretty('logo_url');
740 740
 			return '';
741 741
 		}
742
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' );
742
+		return EE_Registry::instance()->CFG->organization->get_pretty('logo_url');
743 743
 	}
744 744
 }
745 745
 
746
-if ( ! function_exists( 'espresso_organization_facebook' )) {
746
+if ( ! function_exists('espresso_organization_facebook')) {
747 747
 	/**
748 748
 	 * espresso_organization_facebook
749 749
 	 * @param bool $echo
750 750
 	 * @return string
751 751
 	 */
752
-	function espresso_organization_facebook( $echo = TRUE ) {
753
-		if($echo){
754
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' );
752
+	function espresso_organization_facebook($echo = TRUE) {
753
+		if ($echo) {
754
+			echo EE_Registry::instance()->CFG->organization->get_pretty('facebook');
755 755
 			return '';
756 756
 		}
757
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' );
757
+		return EE_Registry::instance()->CFG->organization->get_pretty('facebook');
758 758
 	}
759 759
 }
760 760
 
761
-if ( ! function_exists( 'espresso_organization_twitter' )) {
761
+if ( ! function_exists('espresso_organization_twitter')) {
762 762
 	/**
763 763
 	 * espresso_organization_twitter
764 764
 	 * @param bool $echo
765 765
 	 * @return string
766 766
 	 */
767
-	function espresso_organization_twitter( $echo = TRUE ) {
768
-		if($echo){
769
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' );
767
+	function espresso_organization_twitter($echo = TRUE) {
768
+		if ($echo) {
769
+			echo EE_Registry::instance()->CFG->organization->get_pretty('twitter');
770 770
 			return '';
771 771
 		}
772
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' );
772
+		return EE_Registry::instance()->CFG->organization->get_pretty('twitter');
773 773
 	}
774 774
 }
775 775
 
776
-if ( ! function_exists( 'espresso_organization_linkedin' )) {
776
+if ( ! function_exists('espresso_organization_linkedin')) {
777 777
 	/**
778 778
 	 * espresso_organization_linkedin
779 779
 	 * @param bool $echo
780 780
 	 * @return string
781 781
 	 */
782
-	function espresso_organization_linkedin( $echo = TRUE ) {
783
-		if($echo){
784
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'linkedin' );
782
+	function espresso_organization_linkedin($echo = TRUE) {
783
+		if ($echo) {
784
+			echo EE_Registry::instance()->CFG->organization->get_pretty('linkedin');
785 785
 			return '';
786 786
 		}
787
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'linkedin' );
787
+		return EE_Registry::instance()->CFG->organization->get_pretty('linkedin');
788 788
 	}
789 789
 }
790 790
 
791
-if ( ! function_exists( 'espresso_organization_pinterest' )) {
791
+if ( ! function_exists('espresso_organization_pinterest')) {
792 792
 	/**
793 793
 	 * espresso_organization_pinterest
794 794
 	 * @param bool $echo
795 795
 	 * @return string
796 796
 	 */
797
-	function espresso_organization_pinterest( $echo = TRUE ) {
798
-		if($echo){
799
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'pinterest' );
797
+	function espresso_organization_pinterest($echo = TRUE) {
798
+		if ($echo) {
799
+			echo EE_Registry::instance()->CFG->organization->get_pretty('pinterest');
800 800
 			return '';
801 801
 		}
802
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'pinterest' );
802
+		return EE_Registry::instance()->CFG->organization->get_pretty('pinterest');
803 803
 	}
804 804
 }
805 805
 
806
-if ( ! function_exists( 'espresso_organization_google' )) {
806
+if ( ! function_exists('espresso_organization_google')) {
807 807
 	/**
808 808
 	 * espresso_organization_google
809 809
 	 * @param bool $echo
810 810
 	 * @return string
811 811
 	 */
812
-	function espresso_organization_google( $echo = TRUE ) {
813
-		if($echo){
814
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'google' );
812
+	function espresso_organization_google($echo = TRUE) {
813
+		if ($echo) {
814
+			echo EE_Registry::instance()->CFG->organization->get_pretty('google');
815 815
 			return '';
816 816
 		}
817
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'google' );
817
+		return EE_Registry::instance()->CFG->organization->get_pretty('google');
818 818
 	}
819 819
 }
820 820
 
821
-if ( ! function_exists( 'espresso_organization_instagram' )) {
821
+if ( ! function_exists('espresso_organization_instagram')) {
822 822
 	/**
823 823
 	 * espresso_organization_instagram
824 824
 	 * @param bool $echo
825 825
 	 * @return string
826 826
 	 */
827
-	function espresso_organization_instagram( $echo = TRUE ) {
828
-		if($echo){
829
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'instagram' );
827
+	function espresso_organization_instagram($echo = TRUE) {
828
+		if ($echo) {
829
+			echo EE_Registry::instance()->CFG->organization->get_pretty('instagram');
830 830
 			return '';
831 831
 		}
832
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'instagram' );
832
+		return EE_Registry::instance()->CFG->organization->get_pretty('instagram');
833 833
 	}
834 834
 }
835 835
 
@@ -839,7 +839,7 @@  discard block
 block discarded – undo
839 839
 
840 840
 
841 841
 
842
-if ( ! function_exists( 'espresso_event_venues' )) {
842
+if ( ! function_exists('espresso_event_venues')) {
843 843
 	/**
844 844
 	 * espresso_event_venues
845 845
 	 *
@@ -853,7 +853,7 @@  discard block
 block discarded – undo
853 853
 
854 854
 
855 855
 
856
-if ( ! function_exists( 'espresso_venue_id' )) {
856
+if ( ! function_exists('espresso_venue_id')) {
857 857
 	/**
858 858
 	 *    espresso_venue_name
859 859
 	 *
@@ -861,15 +861,15 @@  discard block
 block discarded – undo
861 861
 	 * @param     int $EVT_ID
862 862
 	 * @return    string
863 863
 	 */
864
-	function espresso_venue_id( $EVT_ID = 0 ) {
865
-		$venue = EEH_Venue_View::get_venue( $EVT_ID );
864
+	function espresso_venue_id($EVT_ID = 0) {
865
+		$venue = EEH_Venue_View::get_venue($EVT_ID);
866 866
 		return $venue instanceof EE_Venue ? $venue->ID() : 0;
867 867
 	}
868 868
 }
869 869
 
870 870
 
871 871
 
872
-if ( ! function_exists( 'espresso_is_venue_private' ) ) {
872
+if ( ! function_exists('espresso_is_venue_private')) {
873 873
 	/**
874 874
 	 * Return whether a venue is private or not.
875 875
 	 * @see EEH_Venue_View::get_venue() for more info on expected return results.
@@ -878,45 +878,45 @@  discard block
 block discarded – undo
878 878
 	 *
879 879
 	 * @return bool | null
880 880
 	 */
881
-	function espresso_is_venue_private( $VNU_ID = 0 ) {
882
-		return EEH_Venue_View::is_venue_private( $VNU_ID );
881
+	function espresso_is_venue_private($VNU_ID = 0) {
882
+		return EEH_Venue_View::is_venue_private($VNU_ID);
883 883
 	}
884 884
 }
885 885
 
886 886
 
887 887
 
888
-if ( ! function_exists( 'espresso_venue_is_password_protected' ) ) {
888
+if ( ! function_exists('espresso_venue_is_password_protected')) {
889 889
 	/**
890 890
 	 * returns true or false if a venue is password protected or not
891 891
 	 *
892 892
 	 * @param int     $VNU_ID optional, the venue id to check.
893 893
 	 * @return string
894 894
 	 */
895
-	function espresso_venue_is_password_protected( $VNU_ID = 0 ) {
896
-		EE_Registry::instance()->load_helper( 'Venue_View' );
897
-		return EEH_Venue_View::is_venue_password_protected( $VNU_ID );
895
+	function espresso_venue_is_password_protected($VNU_ID = 0) {
896
+		EE_Registry::instance()->load_helper('Venue_View');
897
+		return EEH_Venue_View::is_venue_password_protected($VNU_ID);
898 898
 	}
899 899
 }
900 900
 
901 901
 
902 902
 
903
-if ( ! function_exists( 'espresso_password_protected_venue_form' ) ) {
903
+if ( ! function_exists('espresso_password_protected_venue_form')) {
904 904
 	/**
905 905
 	 * Returns a password form if venue is password protected.
906 906
 	 *
907 907
 	 * @param int     $VNU_ID optional, the venue id to check.
908 908
 	 * @return string
909 909
 	 */
910
-	function espresso_password_protected_venue_form( $VNU_ID = 0 ) {
911
-		EE_Registry::instance()->load_helper( 'Venue_View' );
912
-		return EEH_Venue_View::password_protected_venue_form( $VNU_ID );
910
+	function espresso_password_protected_venue_form($VNU_ID = 0) {
911
+		EE_Registry::instance()->load_helper('Venue_View');
912
+		return EEH_Venue_View::password_protected_venue_form($VNU_ID);
913 913
 	}
914 914
 }
915 915
 
916 916
 
917 917
 
918 918
 
919
-if ( ! function_exists( 'espresso_venue_name' )) {
919
+if ( ! function_exists('espresso_venue_name')) {
920 920
 	/**
921 921
 	 *    espresso_venue_name
922 922
 	 *
@@ -926,19 +926,19 @@  discard block
 block discarded – undo
926 926
 	 * @param bool   $echo
927 927
 	 * @return    string
928 928
 	 */
929
-	function espresso_venue_name( $VNU_ID = 0, $link_to = 'details', $echo = TRUE ) {
930
-		if($echo){
931
-			echo EEH_Venue_View::venue_name( $link_to, $VNU_ID );
929
+	function espresso_venue_name($VNU_ID = 0, $link_to = 'details', $echo = TRUE) {
930
+		if ($echo) {
931
+			echo EEH_Venue_View::venue_name($link_to, $VNU_ID);
932 932
 			return '';
933 933
 		}
934
-		return EEH_Venue_View::venue_name( $link_to, $VNU_ID );
934
+		return EEH_Venue_View::venue_name($link_to, $VNU_ID);
935 935
 	}
936 936
 }
937 937
 
938 938
 
939 939
 
940 940
 
941
-if ( ! function_exists( 'espresso_venue_link' )) {
941
+if ( ! function_exists('espresso_venue_link')) {
942 942
 	/**
943 943
 	 * 	espresso_venue_link
944 944
 	 *
@@ -947,14 +947,14 @@  discard block
 block discarded – undo
947 947
 	 *  @param 	string 	$text
948 948
 	 *  @return 	string
949 949
 	 */
950
-	function espresso_venue_link( $VNU_ID = 0, $text = '' ) {
951
-		return EEH_Venue_View::venue_details_link( $VNU_ID, $text );
950
+	function espresso_venue_link($VNU_ID = 0, $text = '') {
951
+		return EEH_Venue_View::venue_details_link($VNU_ID, $text);
952 952
 	}
953 953
 }
954 954
 
955 955
 
956 956
 
957
-if ( ! function_exists( 'espresso_venue_description' )) {
957
+if ( ! function_exists('espresso_venue_description')) {
958 958
 	/**
959 959
 	 *    espresso_venue_description
960 960
 	 *
@@ -963,17 +963,17 @@  discard block
 block discarded – undo
963 963
 	 * @param bool $echo
964 964
 	 * @return    string
965 965
 	 */
966
-	function espresso_venue_description( $VNU_ID = FALSE, $echo = TRUE ) {
967
-		if($echo){
968
-			echo EEH_Venue_View::venue_description( $VNU_ID );
966
+	function espresso_venue_description($VNU_ID = FALSE, $echo = TRUE) {
967
+		if ($echo) {
968
+			echo EEH_Venue_View::venue_description($VNU_ID);
969 969
 			return '';
970 970
 		}
971
-		return EEH_Venue_View::venue_description( $VNU_ID );
971
+		return EEH_Venue_View::venue_description($VNU_ID);
972 972
 	}
973 973
 }
974 974
 
975 975
 
976
-if ( ! function_exists( 'espresso_venue_excerpt' )) {
976
+if ( ! function_exists('espresso_venue_excerpt')) {
977 977
 	/**
978 978
 	 *    espresso_venue_excerpt
979 979
 	 *
@@ -982,18 +982,18 @@  discard block
 block discarded – undo
982 982
 	 * @param bool $echo
983 983
 	 * @return    string
984 984
 	 */
985
-	function espresso_venue_excerpt( $VNU_ID = 0,  $echo = TRUE ) {
986
-		if ( $echo ) {
987
-			echo EEH_Venue_View::venue_excerpt( $VNU_ID );
985
+	function espresso_venue_excerpt($VNU_ID = 0, $echo = TRUE) {
986
+		if ($echo) {
987
+			echo EEH_Venue_View::venue_excerpt($VNU_ID);
988 988
 			return '';
989 989
 		}
990
-		return EEH_Venue_View::venue_excerpt( $VNU_ID );
990
+		return EEH_Venue_View::venue_excerpt($VNU_ID);
991 991
 	}
992 992
 }
993 993
 
994 994
 
995 995
 
996
-if ( ! function_exists( 'espresso_venue_categories' )) {
996
+if ( ! function_exists('espresso_venue_categories')) {
997 997
 	/**
998 998
 	 * espresso_venue_categories
999 999
 	 * returns the terms associated with a venue
@@ -1003,17 +1003,17 @@  discard block
 block discarded – undo
1003 1003
 	 * @param bool $echo
1004 1004
 	 * @return string
1005 1005
 	 */
1006
-	function espresso_venue_categories( $VNU_ID = 0, $hide_uncategorized = TRUE,  $echo = TRUE ) {
1007
-		if ( $echo ) {
1008
-			echo EEH_Venue_View::venue_categories( $VNU_ID, $hide_uncategorized );
1006
+	function espresso_venue_categories($VNU_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE) {
1007
+		if ($echo) {
1008
+			echo EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized);
1009 1009
 			return '';
1010 1010
 		}
1011
-		return EEH_Venue_View::venue_categories( $VNU_ID, $hide_uncategorized );
1011
+		return EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized);
1012 1012
 	}
1013 1013
 }
1014 1014
 
1015 1015
 
1016
-if ( ! function_exists( 'espresso_venue_address' )) {
1016
+if ( ! function_exists('espresso_venue_address')) {
1017 1017
 	/**
1018 1018
 	 * espresso_venue_address
1019 1019
 	 * returns a formatted block of html  for displaying a venue's address
@@ -1023,17 +1023,17 @@  discard block
 block discarded – undo
1023 1023
 	 * @param bool   $echo
1024 1024
 	 * @return string
1025 1025
 	 */
1026
-	function espresso_venue_address( $type = 'multiline', $VNU_ID = 0, $echo = TRUE ) {
1027
-		if ( $echo ) {
1028
-			echo EEH_Venue_View::venue_address( $type, $VNU_ID );
1026
+	function espresso_venue_address($type = 'multiline', $VNU_ID = 0, $echo = TRUE) {
1027
+		if ($echo) {
1028
+			echo EEH_Venue_View::venue_address($type, $VNU_ID);
1029 1029
 			return '';
1030 1030
 		}
1031
-		return EEH_Venue_View::venue_address( $type, $VNU_ID );
1031
+		return EEH_Venue_View::venue_address($type, $VNU_ID);
1032 1032
 	}
1033 1033
 }
1034 1034
 
1035 1035
 
1036
-if ( ! function_exists( 'espresso_venue_raw_address' )) {
1036
+if ( ! function_exists('espresso_venue_raw_address')) {
1037 1037
 	/**
1038 1038
 	 * espresso_venue_address
1039 1039
 	 * returns an UN-formatted string containing a venue's address
@@ -1043,17 +1043,17 @@  discard block
 block discarded – undo
1043 1043
 	 * @param bool     $echo
1044 1044
 	 * @return string
1045 1045
 	 */
1046
-	function espresso_venue_raw_address( $type = 'multiline', $VNU_ID = 0, $echo = TRUE ) {
1047
-		if ( $echo ) {
1048
-			echo EEH_Venue_View::venue_address( $type, $VNU_ID, FALSE, FALSE );
1046
+	function espresso_venue_raw_address($type = 'multiline', $VNU_ID = 0, $echo = TRUE) {
1047
+		if ($echo) {
1048
+			echo EEH_Venue_View::venue_address($type, $VNU_ID, FALSE, FALSE);
1049 1049
 			return '';
1050 1050
 		}
1051
-		return EEH_Venue_View::venue_address( $type, $VNU_ID, FALSE, FALSE );
1051
+		return EEH_Venue_View::venue_address($type, $VNU_ID, FALSE, FALSE);
1052 1052
 	}
1053 1053
 }
1054 1054
 
1055 1055
 
1056
-if ( ! function_exists( 'espresso_venue_has_address' )) {
1056
+if ( ! function_exists('espresso_venue_has_address')) {
1057 1057
 	/**
1058 1058
 	 * espresso_venue_has_address
1059 1059
 	 * returns TRUE or FALSE if a Venue has address information
@@ -1061,13 +1061,13 @@  discard block
 block discarded – undo
1061 1061
 	 * @param int $VNU_ID
1062 1062
 	 * @return bool
1063 1063
 	 */
1064
-	function espresso_venue_has_address( $VNU_ID = 0 ) {
1065
-		return EEH_Venue_View::venue_has_address( $VNU_ID );
1064
+	function espresso_venue_has_address($VNU_ID = 0) {
1065
+		return EEH_Venue_View::venue_has_address($VNU_ID);
1066 1066
 	}
1067 1067
 }
1068 1068
 
1069 1069
 
1070
-if ( ! function_exists( 'espresso_venue_gmap' )) {
1070
+if ( ! function_exists('espresso_venue_gmap')) {
1071 1071
 	/**
1072 1072
 	 * espresso_venue_gmap
1073 1073
 	 * returns a google map for the venue address
@@ -1078,17 +1078,17 @@  discard block
 block discarded – undo
1078 1078
 	 * @param bool     $echo
1079 1079
 	 * @return string
1080 1080
 	 */
1081
-	function espresso_venue_gmap( $VNU_ID = 0, $map_ID = FALSE, $gmap = array(), $echo = TRUE  ) {
1082
-		if ( $echo ) {
1083
-			echo EEH_Venue_View::venue_gmap( $VNU_ID, $map_ID, $gmap );
1081
+	function espresso_venue_gmap($VNU_ID = 0, $map_ID = FALSE, $gmap = array(), $echo = TRUE) {
1082
+		if ($echo) {
1083
+			echo EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap);
1084 1084
 			return '';
1085 1085
 		}
1086
-		return EEH_Venue_View::venue_gmap( $VNU_ID, $map_ID, $gmap );
1086
+		return EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap);
1087 1087
 	}
1088 1088
 }
1089 1089
 
1090 1090
 
1091
-if ( ! function_exists( 'espresso_venue_phone' )) {
1091
+if ( ! function_exists('espresso_venue_phone')) {
1092 1092
 	/**
1093 1093
 	 * espresso_venue_phone
1094 1094
 	 *
@@ -1096,18 +1096,18 @@  discard block
 block discarded – undo
1096 1096
 	 * @param bool $echo
1097 1097
 	 * @return string
1098 1098
 	 */
1099
-	function espresso_venue_phone( $VNU_ID = 0, $echo = TRUE ) {
1100
-		if ( $echo ) {
1101
-			echo EEH_Venue_View::venue_phone( $VNU_ID );
1099
+	function espresso_venue_phone($VNU_ID = 0, $echo = TRUE) {
1100
+		if ($echo) {
1101
+			echo EEH_Venue_View::venue_phone($VNU_ID);
1102 1102
 			return '';
1103 1103
 		}
1104
-		return EEH_Venue_View::venue_phone( $VNU_ID );
1104
+		return EEH_Venue_View::venue_phone($VNU_ID);
1105 1105
 	}
1106 1106
 }
1107 1107
 
1108 1108
 
1109 1109
 
1110
-if ( ! function_exists( 'espresso_venue_website' )) {
1110
+if ( ! function_exists('espresso_venue_website')) {
1111 1111
 	/**
1112 1112
 	 * espresso_venue_website
1113 1113
 	 *
@@ -1115,18 +1115,18 @@  discard block
 block discarded – undo
1115 1115
 	 * @param bool $echo
1116 1116
 	 * @return string
1117 1117
 	 */
1118
-	function espresso_venue_website( $VNU_ID = 0, $echo = TRUE ) {
1119
-		if ( $echo ) {
1120
-			echo EEH_Venue_View::venue_website_link( $VNU_ID );
1118
+	function espresso_venue_website($VNU_ID = 0, $echo = TRUE) {
1119
+		if ($echo) {
1120
+			echo EEH_Venue_View::venue_website_link($VNU_ID);
1121 1121
 			return '';
1122 1122
 		}
1123
-		return EEH_Venue_View::venue_website_link( $VNU_ID );
1123
+		return EEH_Venue_View::venue_website_link($VNU_ID);
1124 1124
 	}
1125 1125
 }
1126 1126
 
1127 1127
 
1128 1128
 
1129
-if ( ! function_exists( 'espresso_edit_venue_link' )) {
1129
+if ( ! function_exists('espresso_edit_venue_link')) {
1130 1130
 	/**
1131 1131
 	 * espresso_edit_venue_link
1132 1132
 	 *
@@ -1134,12 +1134,12 @@  discard block
 block discarded – undo
1134 1134
 	 * @param bool $echo
1135 1135
 	 * @return string
1136 1136
 	 */
1137
-	function espresso_edit_venue_link( $VNU_ID = 0, $echo = TRUE ) {
1138
-		if($echo){
1139
-			echo EEH_Venue_View::edit_venue_link( $VNU_ID );
1137
+	function espresso_edit_venue_link($VNU_ID = 0, $echo = TRUE) {
1138
+		if ($echo) {
1139
+			echo EEH_Venue_View::edit_venue_link($VNU_ID);
1140 1140
 			return '';
1141 1141
 		}
1142
-		return EEH_Venue_View::edit_venue_link( $VNU_ID );
1142
+		return EEH_Venue_View::edit_venue_link($VNU_ID);
1143 1143
 	}
1144 1144
 }
1145 1145
 
Please login to merge, or discard this patch.
modules/ticket_selector/EED_Ticket_Selector.module.php 2 patches
Indentation   +266 added lines, -266 removed lines patch added patch discarded remove patch
@@ -22,15 +22,15 @@  discard block
 block discarded – undo
22 22
  */
23 23
 class EED_Ticket_Selector extends  EED_Module {
24 24
 
25
-    /**
26
-     * @var EventEspresso\modules\ticket_selector\DisplayTicketSelector $ticket_selector
27
-     */
28
-    private static $ticket_selector;
25
+	/**
26
+	 * @var EventEspresso\modules\ticket_selector\DisplayTicketSelector $ticket_selector
27
+	 */
28
+	private static $ticket_selector;
29 29
 
30
-    /**
31
-     * @var EventEspresso\modules\ticket_selector\TicketSelectorIframeEmbedButton $iframe_embed_button
32
-     */
33
-    private static $iframe_embed_button;
30
+	/**
31
+	 * @var EventEspresso\modules\ticket_selector\TicketSelectorIframeEmbedButton $iframe_embed_button
32
+	 */
33
+	private static $iframe_embed_button;
34 34
 
35 35
 
36 36
 
@@ -61,13 +61,13 @@  discard block
 block discarded – undo
61 61
 		// routing
62 62
 		EE_Config::register_route( 'iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector' );
63 63
 		EE_Config::register_route( 'process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections' );
64
-        EE_Config::register_route('cancel_ticket_selections', 'EED_Ticket_Selector', 'cancel_ticket_selections');
65
-        add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 );
64
+		EE_Config::register_route('cancel_ticket_selections', 'EED_Ticket_Selector', 'cancel_ticket_selections');
65
+		add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 );
66 66
 		add_action( 'AHEE_event_details_header_bottom', array( 'EED_Ticket_Selector', 'display_ticket_selector' ), 10, 1 );
67
-        add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'translate_js_strings' ), 0 );
68
-        add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets' ), 10 );
69
-        EED_Ticket_Selector::loadIframeAssets();
70
-    }
67
+		add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'translate_js_strings' ), 0 );
68
+		add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets' ), 10 );
69
+		EED_Ticket_Selector::loadIframeAssets();
70
+	}
71 71
 
72 72
 
73 73
 
@@ -86,16 +86,16 @@  discard block
 block discarded – undo
86 86
 			10
87 87
 		);
88 88
 
89
-        /**
90
-         * Make sure assets for the ticket selector are loaded on the espresso registrations route so  admin side
91
-         * registrations work.
92
-         */
89
+		/**
90
+		 * Make sure assets for the ticket selector are loaded on the espresso registrations route so  admin side
91
+		 * registrations work.
92
+		 */
93 93
 		add_action(
94
-		    'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_registrations__new_registration',
95
-            array('EED_Ticket_Selector', 'set_definitions'),
96
-            10
97
-        );
98
-    }
94
+			'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_registrations__new_registration',
95
+			array('EED_Ticket_Selector', 'set_definitions'),
96
+			10
97
+		);
98
+	}
99 99
 
100 100
 
101 101
 
@@ -106,34 +106,34 @@  discard block
 block discarded – undo
106 106
 	 *  @return 	void
107 107
 	 */
108 108
 	public static function set_definitions() {
109
-	    // don't do this twice
110
-	    if(defined('TICKET_SELECTOR_ASSETS_URL')) {
111
-	        return;
112
-        }
109
+		// don't do this twice
110
+		if(defined('TICKET_SELECTOR_ASSETS_URL')) {
111
+			return;
112
+		}
113 113
 		define( 'TICKET_SELECTOR_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS );
114 114
 		define(
115
-		    'TICKET_SELECTOR_TEMPLATES_PATH',
116
-            str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS
117
-        );
115
+			'TICKET_SELECTOR_TEMPLATES_PATH',
116
+			str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS
117
+		);
118 118
 		//if config is not set, initialize
119 119
 		if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config ) {
120
-            \EED_Ticket_Selector::instance()->set_config();
121
-            \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = \EED_Ticket_Selector::instance()->config();
120
+			\EED_Ticket_Selector::instance()->set_config();
121
+			\EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = \EED_Ticket_Selector::instance()->config();
122 122
 		}
123 123
 	}
124 124
 
125 125
 
126 126
 
127 127
 	/**
128
-     * @return \EventEspresso\modules\ticket_selector\DisplayTicketSelector
129
-     */
130
-    public static function ticketSelector()
131
-    {
132
-        if ( ! EED_Ticket_Selector::$ticket_selector instanceof DisplayTicketSelector) {
133
-            EED_Ticket_Selector::$ticket_selector = new DisplayTicketSelector();
134
-        }
135
-        return EED_Ticket_Selector::$ticket_selector;
136
-    }
128
+	 * @return \EventEspresso\modules\ticket_selector\DisplayTicketSelector
129
+	 */
130
+	public static function ticketSelector()
131
+	{
132
+		if ( ! EED_Ticket_Selector::$ticket_selector instanceof DisplayTicketSelector) {
133
+			EED_Ticket_Selector::$ticket_selector = new DisplayTicketSelector();
134
+		}
135
+		return EED_Ticket_Selector::$ticket_selector;
136
+	}
137 137
 
138 138
 
139 139
 	/**
@@ -186,15 +186,15 @@  discard block
 block discarded – undo
186 186
 
187 187
 
188 188
 
189
-    /**
190
-     *    creates buttons for selecting number of attendees for an event
191
-     *
192
-     * @access    public
193
-     * @param    WP_Post|int $event
194
-     * @param    bool        $view_details
195
-     * @return    string
196
-     * @throws \EE_Error
197
-     */
189
+	/**
190
+	 *    creates buttons for selecting number of attendees for an event
191
+	 *
192
+	 * @access    public
193
+	 * @param    WP_Post|int $event
194
+	 * @param    bool        $view_details
195
+	 * @return    string
196
+	 * @throws \EE_Error
197
+	 */
198 198
 	public static function display_ticket_selector( $event = NULL, $view_details = FALSE ) {
199 199
 		return EED_Ticket_Selector::ticketSelector()->display( $event, $view_details );
200 200
 	}
@@ -215,244 +215,244 @@  discard block
 block discarded – undo
215 215
 
216 216
 
217 217
 
218
-    /**
219
-     * cancel_ticket_selections
220
-     *
221
-     * @access        public
222
-     * @return        string
223
-     */
224
-    public static function cancel_ticket_selections()
225
-    {
226
-        $form = new ProcessTicketSelector();
227
-        return $form->cancelTicketSelections();
228
-    }
218
+	/**
219
+	 * cancel_ticket_selections
220
+	 *
221
+	 * @access        public
222
+	 * @return        string
223
+	 */
224
+	public static function cancel_ticket_selections()
225
+	{
226
+		$form = new ProcessTicketSelector();
227
+		return $form->cancelTicketSelections();
228
+	}
229 229
 
230 230
 
231 231
 
232 232
 	/**
233
-	* @return void
234
-	*/
233
+	 * @return void
234
+	 */
235 235
 	public static function translate_js_strings() {
236
-        EE_Registry::$i18n_js_strings['please_select_date_filter_notice'] = esc_html__(
237
-            'please select a datetime', 'event_espresso'
238
-        );
239
-    }
236
+		EE_Registry::$i18n_js_strings['please_select_date_filter_notice'] = esc_html__(
237
+			'please select a datetime', 'event_espresso'
238
+		);
239
+	}
240 240
 
241 241
 
242 242
 
243 243
 	/**
244
-	* 	load js
245
-	*
246
-	* 	@access 		public
247
-	* 	@return 		void
248
-	*/
244
+	 * 	load js
245
+	 *
246
+	 * 	@access 		public
247
+	 * 	@return 		void
248
+	 */
249 249
 	public static function load_tckt_slctr_assets() {
250 250
 		if ( apply_filters( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE ) ) {
251
-            // add some style
252
-            wp_register_style(
253
-                'ticket_selector',
254
-                TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css',
255
-                array(),
256
-                EVENT_ESPRESSO_VERSION
257
-            );
258
-            wp_enqueue_style('ticket_selector');
259
-            // make it dance
260
-            wp_register_script(
261
-                'ticket_selector',
262
-                TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js',
263
-                array('espresso_core'),
264
-                EVENT_ESPRESSO_VERSION,
265
-                TRUE
266
-            );
251
+			// add some style
252
+			wp_register_style(
253
+				'ticket_selector',
254
+				TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css',
255
+				array(),
256
+				EVENT_ESPRESSO_VERSION
257
+			);
258
+			wp_enqueue_style('ticket_selector');
259
+			// make it dance
260
+			wp_register_script(
261
+				'ticket_selector',
262
+				TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js',
263
+				array('espresso_core'),
264
+				EVENT_ESPRESSO_VERSION,
265
+				TRUE
266
+			);
267 267
 			wp_enqueue_script('ticket_selector');
268
-            require_once( EE_LIBRARIES.'form_sections/strategies/display/EE_Checkbox_Dropdown_Selector_Display_Strategy.strategy.php');
269
-            \EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts();
270
-        }
268
+			require_once( EE_LIBRARIES.'form_sections/strategies/display/EE_Checkbox_Dropdown_Selector_Display_Strategy.strategy.php');
269
+			\EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts();
270
+		}
271
+	}
272
+
273
+
274
+
275
+	/**
276
+	 * @return void
277
+	 */
278
+	public static function loadIframeAssets()
279
+	{
280
+		// for event lists
281
+		add_filter(
282
+			'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
283
+			array('EED_Ticket_Selector', 'iframeCss')
284
+		);
285
+		add_filter(
286
+			'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
287
+			array('EED_Ticket_Selector', 'iframeJs')
288
+		);
289
+		// for ticket selectors
290
+		add_filter(
291
+			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css',
292
+			array('EED_Ticket_Selector', 'iframeCss')
293
+		);
294
+		add_filter(
295
+			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
296
+			array('EED_Ticket_Selector', 'iframeJs')
297
+		);
298
+	}
299
+
300
+
301
+
302
+	/**
303
+	 * Informs the rest of the forms system what CSS and JS is needed to display the input
304
+	 *
305
+	 * @param array $iframe_css
306
+	 * @return array
307
+	 */
308
+	public static function iframeCss(array $iframe_css)
309
+	{
310
+		$iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css';
311
+		return $iframe_css;
271 312
 	}
272 313
 
273 314
 
274 315
 
275
-    /**
276
-     * @return void
277
-     */
278
-    public static function loadIframeAssets()
279
-    {
280
-        // for event lists
281
-        add_filter(
282
-            'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
283
-            array('EED_Ticket_Selector', 'iframeCss')
284
-        );
285
-        add_filter(
286
-            'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
287
-            array('EED_Ticket_Selector', 'iframeJs')
288
-        );
289
-        // for ticket selectors
290
-        add_filter(
291
-            'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css',
292
-            array('EED_Ticket_Selector', 'iframeCss')
293
-        );
294
-        add_filter(
295
-            'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
296
-            array('EED_Ticket_Selector', 'iframeJs')
297
-        );
298
-    }
299
-
300
-
301
-
302
-    /**
303
-     * Informs the rest of the forms system what CSS and JS is needed to display the input
304
-     *
305
-     * @param array $iframe_css
306
-     * @return array
307
-     */
308
-    public static function iframeCss(array $iframe_css)
309
-    {
310
-        $iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css';
311
-        return $iframe_css;
312
-    }
313
-
314
-
315
-
316
-    /**
317
-     * Informs the rest of the forms system what CSS and JS is needed to display the input
318
-     *
319
-     * @param array $iframe_js
320
-     * @return array
321
-     */
322
-    public static function iframeJs(array $iframe_js)
323
-    {
324
-        $iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js';
325
-        return $iframe_js;
326
-    }
316
+	/**
317
+	 * Informs the rest of the forms system what CSS and JS is needed to display the input
318
+	 *
319
+	 * @param array $iframe_js
320
+	 * @return array
321
+	 */
322
+	public static function iframeJs(array $iframe_js)
323
+	{
324
+		$iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js';
325
+		return $iframe_js;
326
+	}
327 327
 
328 328
 
329 329
 	/****************************** DEPRECATED ******************************/
330 330
 
331 331
 
332 332
 
333
-    /**
334
-     * @deprecated
335
-     * @return string
336
-     * @throws \EE_Error
337
-     */
338
-    public static function display_view_details_btn()
339
-    {
340
-        // todo add doing_it_wrong() notice during next major version
341
-        return EED_Ticket_Selector::ticketSelector()->displayViewDetailsButton();
342
-    }
343
-
344
-
345
-
346
-    /**
347
-     * @deprecated
348
-     * @return string
349
-     * @throws \EE_Error
350
-     */
351
-    public static function display_ticket_selector_submit()
352
-    {
353
-        // todo add doing_it_wrong() notice during next major version
354
-        return EED_Ticket_Selector::ticketSelector()->displaySubmitButton();
355
-    }
356
-
357
-
358
-
359
-    /**
360
-     * @deprecated
361
-     * @param string $permalink_string
362
-     * @param int    $id
363
-     * @param string $new_title
364
-     * @param string $new_slug
365
-     * @return string
366
-     */
367
-    public static function iframe_code_button($permalink_string, $id, $new_title = '', $new_slug = '')
368
-    {
369
-        // todo add doing_it_wrong() notice during next major version
370
-        if (
371
-        	\EE_Registry::instance()->REQ->get('page') === 'espresso_events'
372
-        	&& \EE_Registry::instance()->REQ->get('action') === 'edit'
373
-        ) {
374
-            $iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton();
375
-            $iframe_embed_button->addEventEditorIframeEmbedButton();
376
-        }
377
-        return '';
378
-    }
379
-
380
-
381
-
382
-    /**
383
-     * @deprecated
384
-     * @param int    $ID
385
-     * @param string $external_url
386
-     * @return string
387
-     */
388
-    public static function ticket_selector_form_open($ID = 0, $external_url = '')
389
-    {
390
-        // todo add doing_it_wrong() notice during next major version
391
-        return EED_Ticket_Selector::ticketSelector()->formOpen($ID, $external_url);
392
-    }
393
-
394
-
395
-
396
-    /**
397
-     * @deprecated
398
-     * @return string
399
-     */
400
-    public static function ticket_selector_form_close()
401
-    {
402
-        // todo add doing_it_wrong() notice during next major version
403
-        return EED_Ticket_Selector::ticketSelector()->formClose();
404
-    }
405
-
406
-
407
-
408
-    /**
409
-     * @deprecated
410
-     * @return string
411
-     */
412
-    public static function no_tkt_slctr_end_dv()
413
-    {
414
-        // todo add doing_it_wrong() notice during next major version
415
-        return EED_Ticket_Selector::ticketSelector()->ticketSelectorEndDiv();
416
-    }
417
-
418
-
419
-
420
-    /**
421
-     * @deprecated 4.9.13
422
-     * @return string
423
-     */
424
-    public static function tkt_slctr_end_dv()
425
-    {
426
-        return EED_Ticket_Selector::ticketSelector()->clearTicketSelector();
427
-    }
428
-
429
-
430
-
431
-    /**
432
-     * @deprecated
433
-     * @return string
434
-     */
435
-    public static function clear_tkt_slctr()
436
-    {
437
-        return EED_Ticket_Selector::ticketSelector()->clearTicketSelector();
438
-    }
439
-
440
-
441
-
442
-    /**
443
-     * @deprecated
444
-     */
445
-    public static function load_tckt_slctr_assets_admin()
446
-    {
447
-        // todo add doing_it_wrong() notice during next major version
448
-	    if (
449
-		    \EE_Registry::instance()->REQ->get( 'page' ) === 'espresso_events'
450
-		    && \EE_Registry::instance()->REQ->get( 'action' ) === 'edit'
451
-	    ) {
452
-		    $iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton();
453
-            $iframe_embed_button->embedButtonAssets();
454
-        }
455
-    }
333
+	/**
334
+	 * @deprecated
335
+	 * @return string
336
+	 * @throws \EE_Error
337
+	 */
338
+	public static function display_view_details_btn()
339
+	{
340
+		// todo add doing_it_wrong() notice during next major version
341
+		return EED_Ticket_Selector::ticketSelector()->displayViewDetailsButton();
342
+	}
343
+
344
+
345
+
346
+	/**
347
+	 * @deprecated
348
+	 * @return string
349
+	 * @throws \EE_Error
350
+	 */
351
+	public static function display_ticket_selector_submit()
352
+	{
353
+		// todo add doing_it_wrong() notice during next major version
354
+		return EED_Ticket_Selector::ticketSelector()->displaySubmitButton();
355
+	}
356
+
357
+
358
+
359
+	/**
360
+	 * @deprecated
361
+	 * @param string $permalink_string
362
+	 * @param int    $id
363
+	 * @param string $new_title
364
+	 * @param string $new_slug
365
+	 * @return string
366
+	 */
367
+	public static function iframe_code_button($permalink_string, $id, $new_title = '', $new_slug = '')
368
+	{
369
+		// todo add doing_it_wrong() notice during next major version
370
+		if (
371
+			\EE_Registry::instance()->REQ->get('page') === 'espresso_events'
372
+			&& \EE_Registry::instance()->REQ->get('action') === 'edit'
373
+		) {
374
+			$iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton();
375
+			$iframe_embed_button->addEventEditorIframeEmbedButton();
376
+		}
377
+		return '';
378
+	}
379
+
380
+
381
+
382
+	/**
383
+	 * @deprecated
384
+	 * @param int    $ID
385
+	 * @param string $external_url
386
+	 * @return string
387
+	 */
388
+	public static function ticket_selector_form_open($ID = 0, $external_url = '')
389
+	{
390
+		// todo add doing_it_wrong() notice during next major version
391
+		return EED_Ticket_Selector::ticketSelector()->formOpen($ID, $external_url);
392
+	}
393
+
394
+
395
+
396
+	/**
397
+	 * @deprecated
398
+	 * @return string
399
+	 */
400
+	public static function ticket_selector_form_close()
401
+	{
402
+		// todo add doing_it_wrong() notice during next major version
403
+		return EED_Ticket_Selector::ticketSelector()->formClose();
404
+	}
405
+
406
+
407
+
408
+	/**
409
+	 * @deprecated
410
+	 * @return string
411
+	 */
412
+	public static function no_tkt_slctr_end_dv()
413
+	{
414
+		// todo add doing_it_wrong() notice during next major version
415
+		return EED_Ticket_Selector::ticketSelector()->ticketSelectorEndDiv();
416
+	}
417
+
418
+
419
+
420
+	/**
421
+	 * @deprecated 4.9.13
422
+	 * @return string
423
+	 */
424
+	public static function tkt_slctr_end_dv()
425
+	{
426
+		return EED_Ticket_Selector::ticketSelector()->clearTicketSelector();
427
+	}
428
+
429
+
430
+
431
+	/**
432
+	 * @deprecated
433
+	 * @return string
434
+	 */
435
+	public static function clear_tkt_slctr()
436
+	{
437
+		return EED_Ticket_Selector::ticketSelector()->clearTicketSelector();
438
+	}
439
+
440
+
441
+
442
+	/**
443
+	 * @deprecated
444
+	 */
445
+	public static function load_tckt_slctr_assets_admin()
446
+	{
447
+		// todo add doing_it_wrong() notice during next major version
448
+		if (
449
+			\EE_Registry::instance()->REQ->get( 'page' ) === 'espresso_events'
450
+			&& \EE_Registry::instance()->REQ->get( 'action' ) === 'edit'
451
+		) {
452
+			$iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton();
453
+			$iframe_embed_button->embedButtonAssets();
454
+		}
455
+	}
456 456
 
457 457
 
458 458
 }
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@  discard block
 block discarded – undo
3 3
 use EventEspresso\modules\ticket_selector\TicketSelectorIframe;
4 4
 use EventEspresso\modules\ticket_selector\TicketSelectorIframeEmbedButton;
5 5
 
6
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
7
-	exit( 'No direct script access allowed' );
6
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
7
+	exit('No direct script access allowed');
8 8
 }
9 9
 
10 10
 
@@ -38,15 +38,15 @@  discard block
 block discarded – undo
38 38
 	 * @return EED_Ticket_Selector
39 39
 	 */
40 40
 	public static function instance() {
41
-		return parent::get_instance( __CLASS__ );
41
+		return parent::get_instance(__CLASS__);
42 42
 	}
43 43
 
44 44
 
45 45
 
46
-	protected function set_config(){
47
-		$this->set_config_section( 'template_settings' );
48
-		$this->set_config_class( 'EE_Ticket_Selector_Config' );
49
-		$this->set_config_name( 'EED_Ticket_Selector' );
46
+	protected function set_config() {
47
+		$this->set_config_section('template_settings');
48
+		$this->set_config_class('EE_Ticket_Selector_Config');
49
+		$this->set_config_name('EED_Ticket_Selector');
50 50
 	}
51 51
 
52 52
 
@@ -59,13 +59,13 @@  discard block
 block discarded – undo
59 59
 	 */
60 60
 	public static function set_hooks() {
61 61
 		// routing
62
-		EE_Config::register_route( 'iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector' );
63
-		EE_Config::register_route( 'process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections' );
62
+		EE_Config::register_route('iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector');
63
+		EE_Config::register_route('process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections');
64 64
         EE_Config::register_route('cancel_ticket_selections', 'EED_Ticket_Selector', 'cancel_ticket_selections');
65
-        add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 );
66
-		add_action( 'AHEE_event_details_header_bottom', array( 'EED_Ticket_Selector', 'display_ticket_selector' ), 10, 1 );
67
-        add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'translate_js_strings' ), 0 );
68
-        add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets' ), 10 );
65
+        add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2);
66
+		add_action('AHEE_event_details_header_bottom', array('EED_Ticket_Selector', 'display_ticket_selector'), 10, 1);
67
+        add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'translate_js_strings'), 0);
68
+        add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets'), 10);
69 69
         EED_Ticket_Selector::loadIframeAssets();
70 70
     }
71 71
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 		// to load assets for "espresso_events" page on the "edit" route (action)
83 83
 		add_action(
84 84
 			'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__edit',
85
-			array( 'EED_Ticket_Selector', 'ticket_selector_iframe_embed_button' ),
85
+			array('EED_Ticket_Selector', 'ticket_selector_iframe_embed_button'),
86 86
 			10
87 87
 		);
88 88
 
@@ -107,16 +107,16 @@  discard block
 block discarded – undo
107 107
 	 */
108 108
 	public static function set_definitions() {
109 109
 	    // don't do this twice
110
-	    if(defined('TICKET_SELECTOR_ASSETS_URL')) {
110
+	    if (defined('TICKET_SELECTOR_ASSETS_URL')) {
111 111
 	        return;
112 112
         }
113
-		define( 'TICKET_SELECTOR_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS );
113
+		define('TICKET_SELECTOR_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS);
114 114
 		define(
115 115
 		    'TICKET_SELECTOR_TEMPLATES_PATH',
116
-            str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS
116
+            str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS
117 117
         );
118 118
 		//if config is not set, initialize
119
-		if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config ) {
119
+		if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config) {
120 120
             \EED_Ticket_Selector::instance()->set_config();
121 121
             \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = \EED_Ticket_Selector::instance()->config();
122 122
 		}
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	 * 	@param	WP $WP
144 144
 	 * 	@return void
145 145
 	 */
146
-	public function run( $WP ) {}
146
+	public function run($WP) {}
147 147
 
148 148
 
149 149
 
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	 * @return \EventEspresso\modules\ticket_selector\TicketSelectorIframeEmbedButton
152 152
 	 */
153 153
 	public static function getIframeEmbedButton() {
154
-		if ( ! self::$iframe_embed_button instanceof TicketSelectorIframeEmbedButton ) {
154
+		if ( ! self::$iframe_embed_button instanceof TicketSelectorIframeEmbedButton) {
155 155
 			self::$iframe_embed_button = new TicketSelectorIframeEmbedButton();
156 156
 		}
157 157
 		return self::$iframe_embed_button;
@@ -195,8 +195,8 @@  discard block
 block discarded – undo
195 195
      * @return    string
196 196
      * @throws \EE_Error
197 197
      */
198
-	public static function display_ticket_selector( $event = NULL, $view_details = FALSE ) {
199
-		return EED_Ticket_Selector::ticketSelector()->display( $event, $view_details );
198
+	public static function display_ticket_selector($event = NULL, $view_details = FALSE) {
199
+		return EED_Ticket_Selector::ticketSelector()->display($event, $view_details);
200 200
 	}
201 201
 
202 202
 
@@ -247,11 +247,11 @@  discard block
 block discarded – undo
247 247
 	* 	@return 		void
248 248
 	*/
249 249
 	public static function load_tckt_slctr_assets() {
250
-		if ( apply_filters( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE ) ) {
250
+		if (apply_filters('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE)) {
251 251
             // add some style
252 252
             wp_register_style(
253 253
                 'ticket_selector',
254
-                TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css',
254
+                TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css',
255 255
                 array(),
256 256
                 EVENT_ESPRESSO_VERSION
257 257
             );
@@ -259,13 +259,13 @@  discard block
 block discarded – undo
259 259
             // make it dance
260 260
             wp_register_script(
261 261
                 'ticket_selector',
262
-                TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js',
262
+                TICKET_SELECTOR_ASSETS_URL.'ticket_selector.js',
263 263
                 array('espresso_core'),
264 264
                 EVENT_ESPRESSO_VERSION,
265 265
                 TRUE
266 266
             );
267 267
 			wp_enqueue_script('ticket_selector');
268
-            require_once( EE_LIBRARIES.'form_sections/strategies/display/EE_Checkbox_Dropdown_Selector_Display_Strategy.strategy.php');
268
+            require_once(EE_LIBRARIES.'form_sections/strategies/display/EE_Checkbox_Dropdown_Selector_Display_Strategy.strategy.php');
269 269
             \EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts();
270 270
         }
271 271
 	}
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
      */
308 308
     public static function iframeCss(array $iframe_css)
309 309
     {
310
-        $iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css';
310
+        $iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css';
311 311
         return $iframe_css;
312 312
     }
313 313
 
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
      */
322 322
     public static function iframeJs(array $iframe_js)
323 323
     {
324
-        $iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js';
324
+        $iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL.'ticket_selector.js';
325 325
         return $iframe_js;
326 326
     }
327 327
 
@@ -446,8 +446,8 @@  discard block
 block discarded – undo
446 446
     {
447 447
         // todo add doing_it_wrong() notice during next major version
448 448
 	    if (
449
-		    \EE_Registry::instance()->REQ->get( 'page' ) === 'espresso_events'
450
-		    && \EE_Registry::instance()->REQ->get( 'action' ) === 'edit'
449
+		    \EE_Registry::instance()->REQ->get('page') === 'espresso_events'
450
+		    && \EE_Registry::instance()->REQ->get('action') === 'edit'
451 451
 	    ) {
452 452
 		    $iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton();
453 453
             $iframe_embed_button->embedButtonAssets();
Please login to merge, or discard this patch.
modules/ticket_selector/DisplayTicketSelector.php 1 patch
Indentation   +676 added lines, -676 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 use WP_Post;
18 18
 
19 19
 if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
20
-    exit( 'No direct script access allowed' );
20
+	exit( 'No direct script access allowed' );
21 21
 }
22 22
 
23 23
 
@@ -34,684 +34,684 @@  discard block
 block discarded – undo
34 34
 class DisplayTicketSelector
35 35
 {
36 36
 
37
-    /**
38
-     * event that ticket selector is being generated for
39
-     *
40
-     * @access protected
41
-     * @var EE_Event $event
42
-     */
43
-    protected $event;
44
-
45
-    /**
46
-     * Used to flag when the ticket selector is being called from an external iframe.
47
-     *
48
-     * @var bool $iframe
49
-     */
50
-    protected $iframe = false;
51
-
52
-    /**
53
-     * max attendees that can register for event at one time
54
-     *
55
-     * @var int $max_attendees
56
-     */
57
-    private $max_attendees = EE_INF;
58
-
59
-    /**
60
-     *@var string $date_format
61
-     */
62
-    private $date_format;
63
-
64
-    /**
65
-     *@var string $time_format
66
-     */
67
-    private $time_format;
68
-
69
-
70
-
71
-    /**
72
-     * DisplayTicketSelector constructor.
73
-     */
74
-    public function __construct()
75
-    {
76
-        $this->date_format = apply_filters(
77
-            'FHEE__EED_Ticket_Selector__display_ticket_selector__date_format',
78
-            get_option('date_format')
79
-        );
80
-        $this->time_format = apply_filters(
81
-            'FHEE__EED_Ticket_Selector__display_ticket_selector__time_format',
82
-            get_option('time_format')
83
-        );
84
-    }
85
-
86
-
87
-
88
-    /**
89
-     * @param boolean $iframe
90
-     */
91
-    public function setIframe( $iframe = true )
92
-    {
93
-        $this->iframe = filter_var( $iframe, FILTER_VALIDATE_BOOLEAN );
94
-    }
95
-
96
-
97
-    /**
98
-     * finds and sets the \EE_Event object for use throughout class
99
-     *
100
-     * @param mixed $event
101
-     * @return bool
102
-     * @throws EE_Error
103
-     */
104
-    protected function setEvent( $event = null )
105
-    {
106
-        if ( $event === null ) {
107
-            global $post;
108
-            $event = $post;
109
-        }
110
-        if ( $event instanceof EE_Event ) {
111
-            $this->event = $event;
112
-        } else if ( $event instanceof WP_Post ) {
113
-            if ( isset( $event->EE_Event ) && $event->EE_Event instanceof EE_Event ) {
114
-                $this->event = $event->EE_Event;
115
-            } else if ( $event->post_type === 'espresso_events' ) {
116
-                $event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object( $event );
117
-                $this->event = $event->EE_Event;
118
-            }
119
-        } else {
120
-            $user_msg = __( 'No Event object or an invalid Event object was supplied.', 'event_espresso' );
121
-            $dev_msg = $user_msg . __(
122
-                    'In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.',
123
-                    'event_espresso'
124
-                );
125
-            EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ );
126
-            return false;
127
-        }
128
-        return true;
129
-    }
130
-
131
-
132
-
133
-    /**
134
-     * @return int
135
-     */
136
-    public function getMaxAttendees()
137
-    {
138
-        return $this->max_attendees;
139
-    }
140
-
141
-
142
-
143
-    /**
144
-     * @param int $max_attendees
145
-     */
146
-    public function setMaxAttendees($max_attendees)
147
-    {
148
-        $this->max_attendees = absint(
149
-            apply_filters(
150
-                'FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets',
151
-                $max_attendees
152
-            )
153
-        );
154
-    }
155
-
156
-
157
-
158
-    /**
159
-     * creates buttons for selecting number of attendees for an event
160
-     *
161
-     * @param WP_Post|int $event
162
-     * @param bool         $view_details
163
-     * @return string
164
-     * @throws EE_Error
165
-     */
166
-    public function display( $event = null, $view_details = false )
167
-    {
168
-        // reset filter for displaying submit button
169
-        remove_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' );
170
-        // poke and prod incoming event till it tells us what it is
171
-        if ( ! $this->setEvent( $event ) ) {
172
-            return false;
173
-        }
174
-        // begin gathering template arguments by getting event status
175
-        $template_args = array( 'event_status' => $this->event->get_active_status() );
176
-        if ( $this->activeEventAndShowTicketSelector($event, $template_args['event_status'], $view_details) ) {
177
-            return ! is_single() ? $this->displayViewDetailsButton() : '';
178
-        }
179
-        // filter the maximum qty that can appear in the Ticket Selector qty dropdowns
180
-        $this->setMaxAttendees($this->event->additional_limit());
181
-        if ($this->getMaxAttendees() < 1) {
182
-            return $this->ticketSalesClosedMessage();
183
-        }
184
-        // is the event expired ?
185
-        $template_args['event_is_expired'] = $this->event->is_expired();
186
-        if ( $template_args[ 'event_is_expired' ] ) {
187
-            return $this->expiredEventMessage();
188
-        }
189
-        // get all tickets for this event ordered by the datetime
190
-        $tickets = $this->getTickets();
191
-        if (count($tickets) < 1) {
192
-            return $this->noTicketAvailableMessage();
193
-        }
194
-        if (EED_Events_Archive::is_iframe()){
195
-            $this->setIframe();
196
-        }
197
-        // redirecting to another site for registration ??
198
-        $external_url = (string) $this->event->external_url();
199
-        // if redirecting to another site for registration, then we don't load the TS
200
-        $ticket_selector = $external_url
201
-            ? $this->externalEventRegistration()
202
-            : $this->loadTicketSelector($tickets,$template_args);
203
-        // now set up the form (but not for the admin)
204
-        $ticket_selector = ! is_admin()
205
-            ? $this->formOpen($this->event->ID(), $external_url) . $ticket_selector
206
-            : $ticket_selector;
207
-        // submit button and form close tag
208
-        $ticket_selector .= ! is_admin() ? $this->displaySubmitButton($external_url) : '';
209
-        return $ticket_selector;
210
-    }
211
-
212
-
213
-
214
-    /**
215
-     * displayTicketSelector
216
-     * examines the event properties and determines whether a Ticket Selector should be displayed
217
-     *
218
-     * @param WP_Post|int $event
219
-     * @param string       $_event_active_status
220
-     * @param bool         $view_details
221
-     * @return bool
222
-     * @throws EE_Error
223
-     */
224
-    protected function activeEventAndShowTicketSelector($event, $_event_active_status, $view_details)
225
-    {
226
-        $event_post = $this->event instanceof EE_Event ? $this->event->ID() : $event;
227
-        return ! is_admin()
228
-               && (
229
-                   ! $this->event->display_ticket_selector()
230
-                   || $view_details
231
-                   || post_password_required($event_post)
232
-                   || (
233
-                       $_event_active_status !== EE_Datetime::active
234
-                       && $_event_active_status !== EE_Datetime::upcoming
235
-                       && $_event_active_status !== EE_Datetime::sold_out
236
-                       && ! (
237
-                           $_event_active_status === EE_Datetime::inactive
238
-                           && is_user_logged_in()
239
-                       )
240
-                   )
241
-               );
242
-    }
243
-
244
-
245
-
246
-    /**
247
-     * noTicketAvailableMessage
248
-     * notice displayed if event is expired
249
-     *
250
-     * @return string
251
-     * @throws EE_Error
252
-     */
253
-    protected function expiredEventMessage()
254
-    {
255
-        return '<div class="ee-event-expired-notice"><span class="important-notice">' . esc_html__(
256
-            'We\'re sorry, but all tickets sales have ended because the event is expired.',
257
-            'event_espresso'
258
-        ) . '</span></div><!-- .ee-event-expired-notice -->';
259
-    }
260
-
261
-
262
-
263
-    /**
264
-     * noTicketAvailableMessage
265
-     * notice displayed if event has no more tickets available
266
-     *
267
-     * @return string
268
-     * @throws EE_Error
269
-     */
270
-    protected function noTicketAvailableMessage()
271
-    {
272
-        $no_ticket_available_msg = esc_html__( 'We\'re sorry, but all ticket sales have ended.', 'event_espresso' );
273
-        if (current_user_can('edit_post', $this->event->ID())) {
274
-            $no_ticket_available_msg .= sprintf(
275
-                esc_html__(
276
-                    '%1$sNote to Event Admin:%2$sNo tickets were found for this event. This effectively turns off ticket sales. Please ensure that at least one ticket is available for if you want people to be able to register.%3$s(click to edit this event)%4$s',
277
-                    'event_espresso'
278
-                ),
279
-                '<div class="ee-attention" style="text-align: left;"><b>',
280
-                '</b><br />',
281
-                '<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link($this->event->ID()).'">',
282
-                '</a></span></div><!-- .ee-attention noTicketAvailableMessage -->'
283
-            );
284
-        }
285
-        return '
37
+	/**
38
+	 * event that ticket selector is being generated for
39
+	 *
40
+	 * @access protected
41
+	 * @var EE_Event $event
42
+	 */
43
+	protected $event;
44
+
45
+	/**
46
+	 * Used to flag when the ticket selector is being called from an external iframe.
47
+	 *
48
+	 * @var bool $iframe
49
+	 */
50
+	protected $iframe = false;
51
+
52
+	/**
53
+	 * max attendees that can register for event at one time
54
+	 *
55
+	 * @var int $max_attendees
56
+	 */
57
+	private $max_attendees = EE_INF;
58
+
59
+	/**
60
+	 *@var string $date_format
61
+	 */
62
+	private $date_format;
63
+
64
+	/**
65
+	 *@var string $time_format
66
+	 */
67
+	private $time_format;
68
+
69
+
70
+
71
+	/**
72
+	 * DisplayTicketSelector constructor.
73
+	 */
74
+	public function __construct()
75
+	{
76
+		$this->date_format = apply_filters(
77
+			'FHEE__EED_Ticket_Selector__display_ticket_selector__date_format',
78
+			get_option('date_format')
79
+		);
80
+		$this->time_format = apply_filters(
81
+			'FHEE__EED_Ticket_Selector__display_ticket_selector__time_format',
82
+			get_option('time_format')
83
+		);
84
+	}
85
+
86
+
87
+
88
+	/**
89
+	 * @param boolean $iframe
90
+	 */
91
+	public function setIframe( $iframe = true )
92
+	{
93
+		$this->iframe = filter_var( $iframe, FILTER_VALIDATE_BOOLEAN );
94
+	}
95
+
96
+
97
+	/**
98
+	 * finds and sets the \EE_Event object for use throughout class
99
+	 *
100
+	 * @param mixed $event
101
+	 * @return bool
102
+	 * @throws EE_Error
103
+	 */
104
+	protected function setEvent( $event = null )
105
+	{
106
+		if ( $event === null ) {
107
+			global $post;
108
+			$event = $post;
109
+		}
110
+		if ( $event instanceof EE_Event ) {
111
+			$this->event = $event;
112
+		} else if ( $event instanceof WP_Post ) {
113
+			if ( isset( $event->EE_Event ) && $event->EE_Event instanceof EE_Event ) {
114
+				$this->event = $event->EE_Event;
115
+			} else if ( $event->post_type === 'espresso_events' ) {
116
+				$event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object( $event );
117
+				$this->event = $event->EE_Event;
118
+			}
119
+		} else {
120
+			$user_msg = __( 'No Event object or an invalid Event object was supplied.', 'event_espresso' );
121
+			$dev_msg = $user_msg . __(
122
+					'In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.',
123
+					'event_espresso'
124
+				);
125
+			EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ );
126
+			return false;
127
+		}
128
+		return true;
129
+	}
130
+
131
+
132
+
133
+	/**
134
+	 * @return int
135
+	 */
136
+	public function getMaxAttendees()
137
+	{
138
+		return $this->max_attendees;
139
+	}
140
+
141
+
142
+
143
+	/**
144
+	 * @param int $max_attendees
145
+	 */
146
+	public function setMaxAttendees($max_attendees)
147
+	{
148
+		$this->max_attendees = absint(
149
+			apply_filters(
150
+				'FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets',
151
+				$max_attendees
152
+			)
153
+		);
154
+	}
155
+
156
+
157
+
158
+	/**
159
+	 * creates buttons for selecting number of attendees for an event
160
+	 *
161
+	 * @param WP_Post|int $event
162
+	 * @param bool         $view_details
163
+	 * @return string
164
+	 * @throws EE_Error
165
+	 */
166
+	public function display( $event = null, $view_details = false )
167
+	{
168
+		// reset filter for displaying submit button
169
+		remove_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' );
170
+		// poke and prod incoming event till it tells us what it is
171
+		if ( ! $this->setEvent( $event ) ) {
172
+			return false;
173
+		}
174
+		// begin gathering template arguments by getting event status
175
+		$template_args = array( 'event_status' => $this->event->get_active_status() );
176
+		if ( $this->activeEventAndShowTicketSelector($event, $template_args['event_status'], $view_details) ) {
177
+			return ! is_single() ? $this->displayViewDetailsButton() : '';
178
+		}
179
+		// filter the maximum qty that can appear in the Ticket Selector qty dropdowns
180
+		$this->setMaxAttendees($this->event->additional_limit());
181
+		if ($this->getMaxAttendees() < 1) {
182
+			return $this->ticketSalesClosedMessage();
183
+		}
184
+		// is the event expired ?
185
+		$template_args['event_is_expired'] = $this->event->is_expired();
186
+		if ( $template_args[ 'event_is_expired' ] ) {
187
+			return $this->expiredEventMessage();
188
+		}
189
+		// get all tickets for this event ordered by the datetime
190
+		$tickets = $this->getTickets();
191
+		if (count($tickets) < 1) {
192
+			return $this->noTicketAvailableMessage();
193
+		}
194
+		if (EED_Events_Archive::is_iframe()){
195
+			$this->setIframe();
196
+		}
197
+		// redirecting to another site for registration ??
198
+		$external_url = (string) $this->event->external_url();
199
+		// if redirecting to another site for registration, then we don't load the TS
200
+		$ticket_selector = $external_url
201
+			? $this->externalEventRegistration()
202
+			: $this->loadTicketSelector($tickets,$template_args);
203
+		// now set up the form (but not for the admin)
204
+		$ticket_selector = ! is_admin()
205
+			? $this->formOpen($this->event->ID(), $external_url) . $ticket_selector
206
+			: $ticket_selector;
207
+		// submit button and form close tag
208
+		$ticket_selector .= ! is_admin() ? $this->displaySubmitButton($external_url) : '';
209
+		return $ticket_selector;
210
+	}
211
+
212
+
213
+
214
+	/**
215
+	 * displayTicketSelector
216
+	 * examines the event properties and determines whether a Ticket Selector should be displayed
217
+	 *
218
+	 * @param WP_Post|int $event
219
+	 * @param string       $_event_active_status
220
+	 * @param bool         $view_details
221
+	 * @return bool
222
+	 * @throws EE_Error
223
+	 */
224
+	protected function activeEventAndShowTicketSelector($event, $_event_active_status, $view_details)
225
+	{
226
+		$event_post = $this->event instanceof EE_Event ? $this->event->ID() : $event;
227
+		return ! is_admin()
228
+			   && (
229
+				   ! $this->event->display_ticket_selector()
230
+				   || $view_details
231
+				   || post_password_required($event_post)
232
+				   || (
233
+					   $_event_active_status !== EE_Datetime::active
234
+					   && $_event_active_status !== EE_Datetime::upcoming
235
+					   && $_event_active_status !== EE_Datetime::sold_out
236
+					   && ! (
237
+						   $_event_active_status === EE_Datetime::inactive
238
+						   && is_user_logged_in()
239
+					   )
240
+				   )
241
+			   );
242
+	}
243
+
244
+
245
+
246
+	/**
247
+	 * noTicketAvailableMessage
248
+	 * notice displayed if event is expired
249
+	 *
250
+	 * @return string
251
+	 * @throws EE_Error
252
+	 */
253
+	protected function expiredEventMessage()
254
+	{
255
+		return '<div class="ee-event-expired-notice"><span class="important-notice">' . esc_html__(
256
+			'We\'re sorry, but all tickets sales have ended because the event is expired.',
257
+			'event_espresso'
258
+		) . '</span></div><!-- .ee-event-expired-notice -->';
259
+	}
260
+
261
+
262
+
263
+	/**
264
+	 * noTicketAvailableMessage
265
+	 * notice displayed if event has no more tickets available
266
+	 *
267
+	 * @return string
268
+	 * @throws EE_Error
269
+	 */
270
+	protected function noTicketAvailableMessage()
271
+	{
272
+		$no_ticket_available_msg = esc_html__( 'We\'re sorry, but all ticket sales have ended.', 'event_espresso' );
273
+		if (current_user_can('edit_post', $this->event->ID())) {
274
+			$no_ticket_available_msg .= sprintf(
275
+				esc_html__(
276
+					'%1$sNote to Event Admin:%2$sNo tickets were found for this event. This effectively turns off ticket sales. Please ensure that at least one ticket is available for if you want people to be able to register.%3$s(click to edit this event)%4$s',
277
+					'event_espresso'
278
+				),
279
+				'<div class="ee-attention" style="text-align: left;"><b>',
280
+				'</b><br />',
281
+				'<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link($this->event->ID()).'">',
282
+				'</a></span></div><!-- .ee-attention noTicketAvailableMessage -->'
283
+			);
284
+		}
285
+		return '
286 286
             <div class="ee-event-expired-notice">
287 287
                 <span class="important-notice">' . $no_ticket_available_msg . '</span>
288 288
             </div><!-- .ee-event-expired-notice -->';
289
-    }
290
-
291
-
292
-
293
-    /**
294
-     * ticketSalesClosed
295
-     * notice displayed if event ticket sales are turned off
296
-     *
297
-     * @return string
298
-     * @throws EE_Error
299
-     */
300
-    protected function ticketSalesClosedMessage()
301
-    {
302
-        $sales_closed_msg = esc_html__(
303
-            'We\'re sorry, but ticket sales have been closed at this time. Please check back again later.',
304
-            'event_espresso'
305
-        );
306
-        if (current_user_can('edit_post', $this->event->ID())) {
307
-            $sales_closed_msg .= sprintf(
308
-                esc_html__(
309
-                    '%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s',
310
-                    'event_espresso'
311
-                ),
312
-                '<div class="ee-attention" style="text-align: left;"><b>',
313
-                '</b><br />',
314
-                '<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link($this->event->ID()).'">',
315
-                '</a></span></div><!-- .ee-attention ticketSalesClosedMessage -->'
316
-            );
317
-        }
318
-        return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>';
319
-    }
320
-
321
-
322
-
323
-    /**
324
-     * getTickets
325
-     *
326
-     * @return \EE_Base_Class[]|\EE_Ticket[]
327
-     * @throws EE_Error
328
-     */
329
-    protected function getTickets()
330
-    {
331
-        $ticket_query_args = array(
332
-            array('Datetime.EVT_ID' => $this->event->ID()),
333
-            'order_by' => array(
334
-                'TKT_order'              => 'ASC',
335
-                'TKT_required'           => 'DESC',
336
-                'TKT_start_date'         => 'ASC',
337
-                'TKT_end_date'           => 'ASC',
338
-                'Datetime.DTT_EVT_start' => 'DESC',
339
-            ),
340
-        );
341
-        if (
342
-            ! (
343
-                EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config
344
-                && EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets
345
-            )
346
-        ) {
347
-            //use the correct applicable time query depending on what version of core is being run.
348
-            $current_time = method_exists('EEM_Datetime', 'current_time_for_query')
349
-                ? time()
350
-                : current_time('timestamp');
351
-            $ticket_query_args[0]['TKT_end_date'] = array('>', $current_time);
352
-        }
353
-        return EEM_Ticket::instance()->get_all($ticket_query_args);
354
-    }
355
-
356
-
357
-
358
-    /**
359
-     * loadTicketSelector
360
-     * begins to assemble template arguments
361
-     * and decides whether to load a "simple" ticket selector, or the standard
362
-     *
363
-     * @param \EE_Ticket[] $tickets
364
-     * @param array $template_args
365
-     * @return string
366
-     * @throws EE_Error
367
-     */
368
-    protected function loadTicketSelector(array $tickets, array $template_args)
369
-    {
370
-        $template_args['event'] = $this->event;
371
-        $template_args['EVT_ID'] = $this->event->ID();
372
-        $template_args['event_is_expired'] = $this->event->is_expired();
373
-        $template_args['max_atndz'] = $this->getMaxAttendees();
374
-        $template_args['date_format'] = $this->date_format;
375
-        $template_args['time_format'] = $this->time_format;
376
-        /**
377
-         * Filters the anchor ID used when redirecting to the Ticket Selector if no quantity selected
378
-         *
379
-         * @since 4.9.13
380
-         * @param     string  '#tkt-slctr-tbl-' . $EVT_ID The html ID to anchor to
381
-         * @param int $EVT_ID The Event ID
382
-         */
383
-        $template_args['anchor_id'] = apply_filters(
384
-            'FHEE__EE_Ticket_Selector__redirect_anchor_id',
385
-            '#tkt-slctr-tbl-' . $this->event->ID(),
386
-            $this->event->ID()
387
-        );
388
-        $template_args['tickets'] = $tickets;
389
-        $template_args['ticket_count'] = count($tickets);
390
-        $ticket_selector = $this->simpleTicketSelector( $tickets, $template_args);
391
-        return $ticket_selector instanceof TicketSelectorSimple
392
-            ? $ticket_selector
393
-            : new TicketSelectorStandard(
394
-                $this->event,
395
-                $tickets,
396
-                $this->getMaxAttendees(),
397
-                $template_args,
398
-                $this->date_format,
399
-                $this->time_format
400
-            );
401
-    }
402
-
403
-
404
-
405
-    /**
406
-     * simpleTicketSelector
407
-     * there's one ticket, and max attendees is set to one,
408
-     * so if the event is free, then this is a "simple" ticket selector
409
-     * a.k.a. "Dude Where's my Ticket Selector?"
410
-     *
411
-     * @param \EE_Ticket[] $tickets
412
-     * @param array  $template_args
413
-     * @return string
414
-     * @throws EE_Error
415
-     */
416
-    protected function simpleTicketSelector($tickets, array $template_args)
417
-    {
418
-        // if there is only ONE ticket with a max qty of ONE
419
-        if (count($tickets) > 1 || $this->getMaxAttendees() !== 1) {
420
-            return '';
421
-        }
422
-        /** @var \EE_Ticket $ticket */
423
-        $ticket = reset($tickets);
424
-        // if the ticket is free... then not much need for the ticket selector
425
-        if (
426
-            apply_filters(
427
-                'FHEE__ticket_selector_chart_template__hide_ticket_selector',
428
-                $ticket->is_free(),
429
-                $this->event->ID()
430
-            )
431
-        ) {
432
-            return new TicketSelectorSimple(
433
-                $this->event,
434
-                $ticket,
435
-                $this->getMaxAttendees(),
436
-                $template_args
437
-            );
438
-        }
439
-        return '';
440
-    }
441
-
442
-
443
-
444
-    /**
445
-     * externalEventRegistration
446
-     *
447
-     * @return string
448
-     */
449
-    public function externalEventRegistration()
450
-    {
451
-        // if not we still need to trigger the display of the submit button
452
-        add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
453
-        //display notice to admin that registration is external
454
-        return is_admin()
455
-            ? esc_html__(
456
-                'Registration is at an external URL for this event.',
457
-                'event_espresso'
458
-            )
459
-            : '';
460
-    }
461
-
462
-
463
-
464
-    /**
465
-     * formOpen
466
-     *
467
-     * @param        int    $ID
468
-     * @param        string $external_url
469
-     * @return        string
470
-     */
471
-    public function formOpen( $ID = 0, $external_url = '' )
472
-    {
473
-        // if redirecting, we don't need any anything else
474
-        if ( $external_url ) {
475
-            $html = '<form method="GET" action="' . EEH_URL::refactor_url($external_url) . '"';
476
-            // open link in new window ?
477
-            $html .= apply_filters(
478
-                'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__formOpen__external_url_target_blank',
479
-                EED_Events_Archive::is_iframe()
480
-            )
481
-                ? ' target="_blank"'
482
-                : '';
483
-            $html .= '>';
484
-            $query_args = EEH_URL::get_query_string( $external_url );
485
-            foreach ( (array)$query_args as $query_arg => $value ) {
486
-                $html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">';
487
-            }
488
-            return $html;
489
-        }
490
-        // if there is no submit button, then don't start building a form
491
-        // because the "View Details" button will build its own form
492
-        if ( ! apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) {
493
-            return '';
494
-        }
495
-        $checkout_url = EEH_Event_View::event_link_url( $ID );
496
-        if ( ! $checkout_url ) {
497
-            EE_Error::add_error(
498
-                esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ),
499
-                __FILE__,
500
-                __FUNCTION__,
501
-                __LINE__
502
-            );
503
-        }
504
-        // set no cache headers and constants
505
-        EE_System::do_not_cache();
506
-        $extra_params = $this->iframe ? ' target="_blank"' : '';
507
-        $html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>';
508
-        $html .= '<input type="hidden" name="ee" value="process_ticket_selections">';
509
-        $html = apply_filters( 'FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, $this->event );
510
-        return $html;
511
-    }
512
-
513
-
514
-
515
-    /**
516
-     * displaySubmitButton
517
-     *
518
-     * @param  string $external_url
519
-     * @return string
520
-     * @throws EE_Error
521
-     */
522
-    public function displaySubmitButton($external_url = '')
523
-    {
524
-        $html = '';
525
-        if ( ! is_admin()) {
526
-            // standard TS displayed with submit button, ie: "Register Now"
527
-            if (apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) {
528
-                $html .= $this->displayRegisterNowButton();
529
-                $html .= empty($external_url)
530
-                    ? $this->ticketSelectorEndDiv()
531
-                    : $this->clearTicketSelector();
532
-                $html .= '<br/>' . $this->formClose();
533
-            } else if ($this->getMaxAttendees() === 1) {
534
-                // its a "Dude Where's my Ticket Selector?" (DWMTS) type event (ie: $_max_atndz === 1)
535
-                if ($this->event->is_sold_out()) {
536
-                    // then instead of a View Details or Submit button, just display a "Sold Out" message
537
-                    $html .= apply_filters(
538
-                        'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__sold_out_msg',
539
-                        sprintf(
540
-                            __(
541
-                                '%1$s"%2$s" is currently sold out.%4$sPlease check back again later, as spots may become available.%3$s',
542
-                                'event_espresso'
543
-                            ),
544
-                            '<p class="no-ticket-selector-msg clear-float">',
545
-                            $this->event->name(),
546
-                            '</p>',
547
-                            '<br />'
548
-                        ),
549
-                        $this->event
550
-                    );
551
-                    if (
552
-                        apply_filters(
553
-                            'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button',
554
-                            false,
555
-                            $this->event
556
-                        )
557
-                    ) {
558
-                        $html .= $this->displayRegisterNowButton();
559
-                    }
560
-                    // sold out DWMTS event, no TS, no submit or view details button, but has additional content
561
-                    $html .=  $this->ticketSelectorEndDiv();
562
-                } else if (
563
-                    apply_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector', false)
564
-                    && ! is_single()
565
-                ) {
566
-                    // this is a "Dude Where's my Ticket Selector?" (DWMTS) type event,
567
-                    // but no tickets are available, so display event's "View Details" button.
568
-                    // it is being viewed via somewhere other than a single post
569
-                    $html .= $this->displayViewDetailsButton(true);
570
-                } else {
571
-                    $html .= $this->ticketSelectorEndDiv();
572
-                }
573
-            } else if (is_archive()) {
574
-                // event list, no tickets available so display event's "View Details" button
575
-                $html .= $this->ticketSelectorEndDiv();
576
-                $html .= $this->displayViewDetailsButton();
577
-            } else {
578
-                if (
579
-                    apply_filters(
580
-                        'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button',
581
-                        false,
582
-                        $this->event
583
-                    )
584
-                ) {
585
-                    $html .= $this->displayRegisterNowButton();
586
-                }
587
-                // no submit or view details button, and no additional content
588
-                $html .= $this->ticketSelectorEndDiv();
589
-            }
590
-            if ( ! $this->iframe && ! is_archive()) {
591
-                $html .= EEH_Template::powered_by_event_espresso('', '', array('utm_content' => 'ticket_selector'));
592
-            }
593
-        }
594
-        return $html;
595
-    }
596
-
597
-
598
-
599
-    /**
600
-     * @return string
601
-     * @throws EE_Error
602
-     */
603
-    public function displayRegisterNowButton()
604
-    {
605
-        $btn_text = apply_filters(
606
-            'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text',
607
-            __('Register Now', 'event_espresso'),
608
-            $this->event
609
-        );
610
-        $external_url = $this->event->external_url();
611
-        $html = EEH_HTML::div(
612
-            '', 'ticket-selector-submit-' . $this->event->ID() . '-btn-wrap', 'ticket-selector-submit-btn-wrap'
613
-        );
614
-        $html .= '<input id="ticket-selector-submit-' . $this->event->ID() . '-btn"';
615
-        $html .= ' class="ticket-selector-submit-btn ';
616
-        $html .= empty($external_url) ? 'ticket-selector-submit-ajax"' : '"';
617
-        $html .= ' type="submit" value="' . $btn_text . '" />';
618
-        $html .= EEH_HTML::divx() . '<!-- .ticket-selector-submit-btn-wrap -->';
619
-        $html .= apply_filters(
620
-            'FHEE__EE_Ticket_Selector__after_ticket_selector_submit',
621
-            '',
622
-            $this->event
623
-        );
624
-        return $html;
625
-    }
626
-
627
-
628
-    /**
629
-     * displayViewDetailsButton
630
-     *
631
-     * @param bool $DWMTS indicates a "Dude Where's my Ticket Selector?" (DWMTS) type event
632
-     *                    (ie: $_max_atndz === 1) where there are no available tickets,
633
-     *                    either because they are sold out, expired, or not yet on sale.
634
-     *                    In this case, we need to close the form BEFORE adding any closing divs
635
-     * @return string
636
-     * @throws EE_Error
637
-     */
638
-    public function displayViewDetailsButton( $DWMTS = false )
639
-    {
640
-        if ( ! $this->event->get_permalink() ) {
641
-            EE_Error::add_error(
642
-                esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ),
643
-                __FILE__, __FUNCTION__, __LINE__
644
-            );
645
-        }
646
-        $view_details_btn = '<form method="POST" action="';
647
-        $view_details_btn .= apply_filters(
648
-            'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_url',
649
-            $this->event->get_permalink(),
650
-            $this->event
651
-        );
652
-        $view_details_btn .= '"';
653
-        // open link in new window ?
654
-        $view_details_btn .= apply_filters(
655
-            'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__displayViewDetailsButton__url_target_blank',
656
-            EED_Events_Archive::is_iframe()
657
-        )
658
-            ? ' target="_blank"'
659
-            : '';
660
-        $view_details_btn .='>';
661
-        $btn_text = apply_filters(
662
-            'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text',
663
-            esc_html__('View Details', 'event_espresso'),
664
-            $this->event
665
-        );
666
-        $view_details_btn .= '<input id="ticket-selector-submit-'
667
-                             . $this->event->ID()
668
-                             . '-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="'
669
-                             . $btn_text
670
-                             . '" />';
671
-        $view_details_btn .= apply_filters( 'FHEE__EE_Ticket_Selector__after_view_details_btn', '', $this->event );
672
-        if ($DWMTS) {
673
-            $view_details_btn .= $this->formClose();
674
-            $view_details_btn .= $this->ticketSelectorEndDiv();
675
-            $view_details_btn .= '<br/>';
676
-        } else {
677
-            $view_details_btn .= $this->clearTicketSelector();
678
-            $view_details_btn .= '<br/>';
679
-            $view_details_btn .= $this->formClose();
680
-        }
681
-        return $view_details_btn;
682
-    }
683
-
684
-
685
-
686
-    /**
687
-     * @return string
688
-     */
689
-    public function ticketSelectorEndDiv()
690
-    {
691
-        return $this->clearTicketSelector() . '</div><!-- ticketSelectorEndDiv -->';
692
-    }
693
-
694
-
695
-
696
-    /**
697
-     * @return string
698
-     */
699
-    public function clearTicketSelector()
700
-    {
701
-        // standard TS displayed, appears after a "Register Now" or "view Details" button
702
-        return '<div class="clear"></div><!-- clearTicketSelector -->';
703
-    }
704
-
705
-
706
-
707
-    /**
708
-     * @access        public
709
-     * @return        string
710
-     */
711
-    public function formClose()
712
-    {
713
-        return '</form>';
714
-    }
289
+	}
290
+
291
+
292
+
293
+	/**
294
+	 * ticketSalesClosed
295
+	 * notice displayed if event ticket sales are turned off
296
+	 *
297
+	 * @return string
298
+	 * @throws EE_Error
299
+	 */
300
+	protected function ticketSalesClosedMessage()
301
+	{
302
+		$sales_closed_msg = esc_html__(
303
+			'We\'re sorry, but ticket sales have been closed at this time. Please check back again later.',
304
+			'event_espresso'
305
+		);
306
+		if (current_user_can('edit_post', $this->event->ID())) {
307
+			$sales_closed_msg .= sprintf(
308
+				esc_html__(
309
+					'%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s',
310
+					'event_espresso'
311
+				),
312
+				'<div class="ee-attention" style="text-align: left;"><b>',
313
+				'</b><br />',
314
+				'<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link($this->event->ID()).'">',
315
+				'</a></span></div><!-- .ee-attention ticketSalesClosedMessage -->'
316
+			);
317
+		}
318
+		return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>';
319
+	}
320
+
321
+
322
+
323
+	/**
324
+	 * getTickets
325
+	 *
326
+	 * @return \EE_Base_Class[]|\EE_Ticket[]
327
+	 * @throws EE_Error
328
+	 */
329
+	protected function getTickets()
330
+	{
331
+		$ticket_query_args = array(
332
+			array('Datetime.EVT_ID' => $this->event->ID()),
333
+			'order_by' => array(
334
+				'TKT_order'              => 'ASC',
335
+				'TKT_required'           => 'DESC',
336
+				'TKT_start_date'         => 'ASC',
337
+				'TKT_end_date'           => 'ASC',
338
+				'Datetime.DTT_EVT_start' => 'DESC',
339
+			),
340
+		);
341
+		if (
342
+			! (
343
+				EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config
344
+				&& EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets
345
+			)
346
+		) {
347
+			//use the correct applicable time query depending on what version of core is being run.
348
+			$current_time = method_exists('EEM_Datetime', 'current_time_for_query')
349
+				? time()
350
+				: current_time('timestamp');
351
+			$ticket_query_args[0]['TKT_end_date'] = array('>', $current_time);
352
+		}
353
+		return EEM_Ticket::instance()->get_all($ticket_query_args);
354
+	}
355
+
356
+
357
+
358
+	/**
359
+	 * loadTicketSelector
360
+	 * begins to assemble template arguments
361
+	 * and decides whether to load a "simple" ticket selector, or the standard
362
+	 *
363
+	 * @param \EE_Ticket[] $tickets
364
+	 * @param array $template_args
365
+	 * @return string
366
+	 * @throws EE_Error
367
+	 */
368
+	protected function loadTicketSelector(array $tickets, array $template_args)
369
+	{
370
+		$template_args['event'] = $this->event;
371
+		$template_args['EVT_ID'] = $this->event->ID();
372
+		$template_args['event_is_expired'] = $this->event->is_expired();
373
+		$template_args['max_atndz'] = $this->getMaxAttendees();
374
+		$template_args['date_format'] = $this->date_format;
375
+		$template_args['time_format'] = $this->time_format;
376
+		/**
377
+		 * Filters the anchor ID used when redirecting to the Ticket Selector if no quantity selected
378
+		 *
379
+		 * @since 4.9.13
380
+		 * @param     string  '#tkt-slctr-tbl-' . $EVT_ID The html ID to anchor to
381
+		 * @param int $EVT_ID The Event ID
382
+		 */
383
+		$template_args['anchor_id'] = apply_filters(
384
+			'FHEE__EE_Ticket_Selector__redirect_anchor_id',
385
+			'#tkt-slctr-tbl-' . $this->event->ID(),
386
+			$this->event->ID()
387
+		);
388
+		$template_args['tickets'] = $tickets;
389
+		$template_args['ticket_count'] = count($tickets);
390
+		$ticket_selector = $this->simpleTicketSelector( $tickets, $template_args);
391
+		return $ticket_selector instanceof TicketSelectorSimple
392
+			? $ticket_selector
393
+			: new TicketSelectorStandard(
394
+				$this->event,
395
+				$tickets,
396
+				$this->getMaxAttendees(),
397
+				$template_args,
398
+				$this->date_format,
399
+				$this->time_format
400
+			);
401
+	}
402
+
403
+
404
+
405
+	/**
406
+	 * simpleTicketSelector
407
+	 * there's one ticket, and max attendees is set to one,
408
+	 * so if the event is free, then this is a "simple" ticket selector
409
+	 * a.k.a. "Dude Where's my Ticket Selector?"
410
+	 *
411
+	 * @param \EE_Ticket[] $tickets
412
+	 * @param array  $template_args
413
+	 * @return string
414
+	 * @throws EE_Error
415
+	 */
416
+	protected function simpleTicketSelector($tickets, array $template_args)
417
+	{
418
+		// if there is only ONE ticket with a max qty of ONE
419
+		if (count($tickets) > 1 || $this->getMaxAttendees() !== 1) {
420
+			return '';
421
+		}
422
+		/** @var \EE_Ticket $ticket */
423
+		$ticket = reset($tickets);
424
+		// if the ticket is free... then not much need for the ticket selector
425
+		if (
426
+			apply_filters(
427
+				'FHEE__ticket_selector_chart_template__hide_ticket_selector',
428
+				$ticket->is_free(),
429
+				$this->event->ID()
430
+			)
431
+		) {
432
+			return new TicketSelectorSimple(
433
+				$this->event,
434
+				$ticket,
435
+				$this->getMaxAttendees(),
436
+				$template_args
437
+			);
438
+		}
439
+		return '';
440
+	}
441
+
442
+
443
+
444
+	/**
445
+	 * externalEventRegistration
446
+	 *
447
+	 * @return string
448
+	 */
449
+	public function externalEventRegistration()
450
+	{
451
+		// if not we still need to trigger the display of the submit button
452
+		add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
453
+		//display notice to admin that registration is external
454
+		return is_admin()
455
+			? esc_html__(
456
+				'Registration is at an external URL for this event.',
457
+				'event_espresso'
458
+			)
459
+			: '';
460
+	}
461
+
462
+
463
+
464
+	/**
465
+	 * formOpen
466
+	 *
467
+	 * @param        int    $ID
468
+	 * @param        string $external_url
469
+	 * @return        string
470
+	 */
471
+	public function formOpen( $ID = 0, $external_url = '' )
472
+	{
473
+		// if redirecting, we don't need any anything else
474
+		if ( $external_url ) {
475
+			$html = '<form method="GET" action="' . EEH_URL::refactor_url($external_url) . '"';
476
+			// open link in new window ?
477
+			$html .= apply_filters(
478
+				'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__formOpen__external_url_target_blank',
479
+				EED_Events_Archive::is_iframe()
480
+			)
481
+				? ' target="_blank"'
482
+				: '';
483
+			$html .= '>';
484
+			$query_args = EEH_URL::get_query_string( $external_url );
485
+			foreach ( (array)$query_args as $query_arg => $value ) {
486
+				$html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">';
487
+			}
488
+			return $html;
489
+		}
490
+		// if there is no submit button, then don't start building a form
491
+		// because the "View Details" button will build its own form
492
+		if ( ! apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) {
493
+			return '';
494
+		}
495
+		$checkout_url = EEH_Event_View::event_link_url( $ID );
496
+		if ( ! $checkout_url ) {
497
+			EE_Error::add_error(
498
+				esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ),
499
+				__FILE__,
500
+				__FUNCTION__,
501
+				__LINE__
502
+			);
503
+		}
504
+		// set no cache headers and constants
505
+		EE_System::do_not_cache();
506
+		$extra_params = $this->iframe ? ' target="_blank"' : '';
507
+		$html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>';
508
+		$html .= '<input type="hidden" name="ee" value="process_ticket_selections">';
509
+		$html = apply_filters( 'FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, $this->event );
510
+		return $html;
511
+	}
512
+
513
+
514
+
515
+	/**
516
+	 * displaySubmitButton
517
+	 *
518
+	 * @param  string $external_url
519
+	 * @return string
520
+	 * @throws EE_Error
521
+	 */
522
+	public function displaySubmitButton($external_url = '')
523
+	{
524
+		$html = '';
525
+		if ( ! is_admin()) {
526
+			// standard TS displayed with submit button, ie: "Register Now"
527
+			if (apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) {
528
+				$html .= $this->displayRegisterNowButton();
529
+				$html .= empty($external_url)
530
+					? $this->ticketSelectorEndDiv()
531
+					: $this->clearTicketSelector();
532
+				$html .= '<br/>' . $this->formClose();
533
+			} else if ($this->getMaxAttendees() === 1) {
534
+				// its a "Dude Where's my Ticket Selector?" (DWMTS) type event (ie: $_max_atndz === 1)
535
+				if ($this->event->is_sold_out()) {
536
+					// then instead of a View Details or Submit button, just display a "Sold Out" message
537
+					$html .= apply_filters(
538
+						'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__sold_out_msg',
539
+						sprintf(
540
+							__(
541
+								'%1$s"%2$s" is currently sold out.%4$sPlease check back again later, as spots may become available.%3$s',
542
+								'event_espresso'
543
+							),
544
+							'<p class="no-ticket-selector-msg clear-float">',
545
+							$this->event->name(),
546
+							'</p>',
547
+							'<br />'
548
+						),
549
+						$this->event
550
+					);
551
+					if (
552
+						apply_filters(
553
+							'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button',
554
+							false,
555
+							$this->event
556
+						)
557
+					) {
558
+						$html .= $this->displayRegisterNowButton();
559
+					}
560
+					// sold out DWMTS event, no TS, no submit or view details button, but has additional content
561
+					$html .=  $this->ticketSelectorEndDiv();
562
+				} else if (
563
+					apply_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector', false)
564
+					&& ! is_single()
565
+				) {
566
+					// this is a "Dude Where's my Ticket Selector?" (DWMTS) type event,
567
+					// but no tickets are available, so display event's "View Details" button.
568
+					// it is being viewed via somewhere other than a single post
569
+					$html .= $this->displayViewDetailsButton(true);
570
+				} else {
571
+					$html .= $this->ticketSelectorEndDiv();
572
+				}
573
+			} else if (is_archive()) {
574
+				// event list, no tickets available so display event's "View Details" button
575
+				$html .= $this->ticketSelectorEndDiv();
576
+				$html .= $this->displayViewDetailsButton();
577
+			} else {
578
+				if (
579
+					apply_filters(
580
+						'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button',
581
+						false,
582
+						$this->event
583
+					)
584
+				) {
585
+					$html .= $this->displayRegisterNowButton();
586
+				}
587
+				// no submit or view details button, and no additional content
588
+				$html .= $this->ticketSelectorEndDiv();
589
+			}
590
+			if ( ! $this->iframe && ! is_archive()) {
591
+				$html .= EEH_Template::powered_by_event_espresso('', '', array('utm_content' => 'ticket_selector'));
592
+			}
593
+		}
594
+		return $html;
595
+	}
596
+
597
+
598
+
599
+	/**
600
+	 * @return string
601
+	 * @throws EE_Error
602
+	 */
603
+	public function displayRegisterNowButton()
604
+	{
605
+		$btn_text = apply_filters(
606
+			'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text',
607
+			__('Register Now', 'event_espresso'),
608
+			$this->event
609
+		);
610
+		$external_url = $this->event->external_url();
611
+		$html = EEH_HTML::div(
612
+			'', 'ticket-selector-submit-' . $this->event->ID() . '-btn-wrap', 'ticket-selector-submit-btn-wrap'
613
+		);
614
+		$html .= '<input id="ticket-selector-submit-' . $this->event->ID() . '-btn"';
615
+		$html .= ' class="ticket-selector-submit-btn ';
616
+		$html .= empty($external_url) ? 'ticket-selector-submit-ajax"' : '"';
617
+		$html .= ' type="submit" value="' . $btn_text . '" />';
618
+		$html .= EEH_HTML::divx() . '<!-- .ticket-selector-submit-btn-wrap -->';
619
+		$html .= apply_filters(
620
+			'FHEE__EE_Ticket_Selector__after_ticket_selector_submit',
621
+			'',
622
+			$this->event
623
+		);
624
+		return $html;
625
+	}
626
+
627
+
628
+	/**
629
+	 * displayViewDetailsButton
630
+	 *
631
+	 * @param bool $DWMTS indicates a "Dude Where's my Ticket Selector?" (DWMTS) type event
632
+	 *                    (ie: $_max_atndz === 1) where there are no available tickets,
633
+	 *                    either because they are sold out, expired, or not yet on sale.
634
+	 *                    In this case, we need to close the form BEFORE adding any closing divs
635
+	 * @return string
636
+	 * @throws EE_Error
637
+	 */
638
+	public function displayViewDetailsButton( $DWMTS = false )
639
+	{
640
+		if ( ! $this->event->get_permalink() ) {
641
+			EE_Error::add_error(
642
+				esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ),
643
+				__FILE__, __FUNCTION__, __LINE__
644
+			);
645
+		}
646
+		$view_details_btn = '<form method="POST" action="';
647
+		$view_details_btn .= apply_filters(
648
+			'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_url',
649
+			$this->event->get_permalink(),
650
+			$this->event
651
+		);
652
+		$view_details_btn .= '"';
653
+		// open link in new window ?
654
+		$view_details_btn .= apply_filters(
655
+			'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__displayViewDetailsButton__url_target_blank',
656
+			EED_Events_Archive::is_iframe()
657
+		)
658
+			? ' target="_blank"'
659
+			: '';
660
+		$view_details_btn .='>';
661
+		$btn_text = apply_filters(
662
+			'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text',
663
+			esc_html__('View Details', 'event_espresso'),
664
+			$this->event
665
+		);
666
+		$view_details_btn .= '<input id="ticket-selector-submit-'
667
+							 . $this->event->ID()
668
+							 . '-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="'
669
+							 . $btn_text
670
+							 . '" />';
671
+		$view_details_btn .= apply_filters( 'FHEE__EE_Ticket_Selector__after_view_details_btn', '', $this->event );
672
+		if ($DWMTS) {
673
+			$view_details_btn .= $this->formClose();
674
+			$view_details_btn .= $this->ticketSelectorEndDiv();
675
+			$view_details_btn .= '<br/>';
676
+		} else {
677
+			$view_details_btn .= $this->clearTicketSelector();
678
+			$view_details_btn .= '<br/>';
679
+			$view_details_btn .= $this->formClose();
680
+		}
681
+		return $view_details_btn;
682
+	}
683
+
684
+
685
+
686
+	/**
687
+	 * @return string
688
+	 */
689
+	public function ticketSelectorEndDiv()
690
+	{
691
+		return $this->clearTicketSelector() . '</div><!-- ticketSelectorEndDiv -->';
692
+	}
693
+
694
+
695
+
696
+	/**
697
+	 * @return string
698
+	 */
699
+	public function clearTicketSelector()
700
+	{
701
+		// standard TS displayed, appears after a "Register Now" or "view Details" button
702
+		return '<div class="clear"></div><!-- clearTicketSelector -->';
703
+	}
704
+
705
+
706
+
707
+	/**
708
+	 * @access        public
709
+	 * @return        string
710
+	 */
711
+	public function formClose()
712
+	{
713
+		return '</form>';
714
+	}
715 715
 
716 716
 
717 717
 
Please login to merge, or discard this patch.