Completed
Branch sideload-all-language-files (c3c966)
by
unknown
55:51 queued 48:00
created
core/db_classes/EE_Question.class.php 1 patch
Indentation   +661 added lines, -661 removed lines patch added patch discarded remove patch
@@ -14,665 +14,665 @@
 block discarded – undo
14 14
 class EE_Question extends EE_Soft_Delete_Base_Class implements EEI_Duplicatable
15 15
 {
16 16
 
17
-    /**
18
-     *
19
-     * @param array  $props_n_values          incoming values
20
-     * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
21
-     *                                        used.)
22
-     * @param array  $date_formats            incoming date_formats in an array where the first value is the
23
-     *                                        date_format and the second value is the time format
24
-     * @return EE_Question
25
-     */
26
-    public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
27
-    {
28
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
29
-        return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
30
-    }
31
-
32
-
33
-    /**
34
-     * @param array  $props_n_values  incoming values from the database
35
-     * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
36
-     *                                the website will be used.
37
-     * @return EE_Question
38
-     */
39
-    public static function new_instance_from_db($props_n_values = array(), $timezone = null)
40
-    {
41
-        return new self($props_n_values, true, $timezone);
42
-    }
43
-
44
-
45
-    /**
46
-     *        Set    Question display text
47
-     *
48
-     * @access        public
49
-     * @param string $QST_display_text
50
-     */
51
-    public function set_display_text($QST_display_text = '')
52
-    {
53
-        $this->set('QST_display_text', $QST_display_text);
54
-    }
55
-
56
-
57
-    /**
58
-     *        Set    Question admin text
59
-     *
60
-     * @access        public
61
-     * @param        string $QST_admin_label
62
-     */
63
-    public function set_admin_label($QST_admin_label = '')
64
-    {
65
-        $this->set('QST_admin_label', $QST_admin_label);
66
-    }
67
-
68
-
69
-    /**
70
-     *        Set    system name
71
-     *
72
-     * @access        public
73
-     * @param        mixed $QST_system
74
-     */
75
-    public function set_system_ID($QST_system = '')
76
-    {
77
-        $this->set('QST_system', $QST_system);
78
-    }
79
-
80
-
81
-    /**
82
-     *        Set    question's type
83
-     *
84
-     * @access        public
85
-     * @param        string $QST_type
86
-     */
87
-    public function set_question_type($QST_type = '')
88
-    {
89
-        $this->set('QST_type', $QST_type);
90
-    }
91
-
92
-
93
-    /**
94
-     *        Sets whether this question must be answered when presented in a form
95
-     *
96
-     * @access        public
97
-     * @param        bool $QST_required
98
-     */
99
-    public function set_required($QST_required = false)
100
-    {
101
-        $this->set('QST_required', $QST_required);
102
-    }
103
-
104
-
105
-    /**
106
-     *        Set    Question display text
107
-     *
108
-     * @access        public
109
-     * @param        string $QST_required_text
110
-     */
111
-    public function set_required_text($QST_required_text = '')
112
-    {
113
-        $this->set('QST_required_text', $QST_required_text);
114
-    }
115
-
116
-
117
-    /**
118
-     *        Sets the order of this question when placed in a sequence of questions
119
-     *
120
-     * @access        public
121
-     * @param        int $QST_order
122
-     */
123
-    public function set_order($QST_order = 0)
124
-    {
125
-        $this->set('QST_order', $QST_order);
126
-    }
127
-
128
-
129
-    /**
130
-     *        Sets whether the question is admin-only
131
-     *
132
-     * @access        public
133
-     * @param        bool $QST_admin_only
134
-     */
135
-    public function set_admin_only($QST_admin_only = false)
136
-    {
137
-        $this->set('QST_admin_only', $QST_admin_only);
138
-    }
139
-
140
-
141
-    /**
142
-     *        Sets the wordpress user ID on the question
143
-     *
144
-     * @access        public
145
-     * @param        int $QST_wp_user
146
-     */
147
-    public function set_wp_user($QST_wp_user = 1)
148
-    {
149
-        $this->set('QST_wp_user', $QST_wp_user);
150
-    }
151
-
152
-
153
-    /**
154
-     *        Sets whether the question has been deleted
155
-     *        (we use this boolean instead of actually
156
-     *        deleting it because when users delete this question
157
-     *        they really want to remove the question from future
158
-     *        forms, BUT keep their old answers which depend
159
-     *        on this record actually existing.
160
-     *
161
-     * @access        public
162
-     * @param    bool $QST_deleted
163
-     */
164
-    public function set_deleted($QST_deleted = false)
165
-    {
166
-        $this->set('QST_deleted', $QST_deleted);
167
-    }
168
-
169
-
170
-    /**
171
-     * returns the text for displaying the question to users
172
-     *
173
-     * @access public
174
-     * @return string
175
-     */
176
-    public function display_text()
177
-    {
178
-        return $this->get('QST_display_text');
179
-    }
180
-
181
-
182
-    /**
183
-     * returns the text for the administrative label
184
-     *
185
-     * @access public
186
-     * @return string
187
-     */
188
-    public function admin_label()
189
-    {
190
-        return $this->get('QST_admin_label');
191
-    }
192
-
193
-
194
-    /**
195
-     * returns the attendee column name for this question
196
-     *
197
-     * @access public
198
-     * @return string
199
-     */
200
-    public function system_ID()
201
-    {
202
-        return $this->get('QST_system');
203
-    }
204
-
205
-
206
-    /**
207
-     * returns either a string of 'text', 'textfield', etc.
208
-     *
209
-     * @access public
210
-     * @return boolean
211
-     */
212
-    public function required()
213
-    {
214
-        return $this->get('QST_required');
215
-    }
216
-
217
-
218
-    /**
219
-     * returns the text which should be displayed when a user
220
-     * doesn't answer this question in a form
221
-     *
222
-     * @access public
223
-     * @return string
224
-     */
225
-    public function required_text()
226
-    {
227
-        return $this->get('QST_required_text');
228
-    }
229
-
230
-
231
-    /**
232
-     * returns the type of this question
233
-     *
234
-     * @access public
235
-     * @return string
236
-     */
237
-    public function type()
238
-    {
239
-        return $this->get('QST_type');
240
-    }
241
-
242
-
243
-    /**
244
-     * returns an integer showing where this question should
245
-     * be placed in a sequence of questions
246
-     *
247
-     * @access public
248
-     * @return int
249
-     */
250
-    public function order()
251
-    {
252
-        return $this->get('QST_order');
253
-    }
254
-
255
-
256
-    /**
257
-     * returns whether this question should only appears to admins,
258
-     * or to everyone
259
-     *
260
-     * @access public
261
-     * @return boolean
262
-     */
263
-    public function admin_only()
264
-    {
265
-        return $this->get('QST_admin_only');
266
-    }
267
-
268
-
269
-    /**
270
-     * returns the id the wordpress user who created this question
271
-     *
272
-     * @access public
273
-     * @return int
274
-     */
275
-    public function wp_user()
276
-    {
277
-        return $this->get('QST_wp_user');
278
-    }
279
-
280
-
281
-    /**
282
-     * returns whether this question has been marked as 'deleted'
283
-     *
284
-     * @access public
285
-     * @return boolean
286
-     */
287
-    public function deleted()
288
-    {
289
-        return $this->get('QST_deleted');
290
-    }
291
-
292
-
293
-    /**
294
-     * Gets an array of related EE_Answer  to this EE_Question
295
-     *
296
-     * @return EE_Answer[]
297
-     */
298
-    public function answers()
299
-    {
300
-        return $this->get_many_related('Answer');
301
-    }
302
-
303
-
304
-    /**
305
-     * Boolean check for if there are answers on this question in th db
306
-     *
307
-     * @return boolean true = has answers, false = no answers.
308
-     */
309
-    public function has_answers()
310
-    {
311
-        return $this->count_related('Answer') > 0 ? true : false;
312
-    }
313
-
314
-
315
-    /**
316
-     * gets an array of EE_Question_Group which relate to this question
317
-     *
318
-     * @return EE_Question_Group[]
319
-     */
320
-    public function question_groups()
321
-    {
322
-        return $this->get_many_related('Question_Group');
323
-    }
324
-
325
-
326
-    /**
327
-     * Returns all the options for this question. By default, it returns only the not-yet-deleted ones.
328
-     *
329
-     * @param boolean      $notDeletedOptionsOnly            1
330
-     *                                                       whether to return ALL options, or only the ones which have
331
-     *                                                       not yet been deleleted
332
-     * @param string|array $selected_value_to_always_include , when retrieving options to an ANSWERED question,
333
-     *                                                       we want to usually only show non-deleted options AND the
334
-     *                                                       value that was selected for the answer, whether it was
335
-     *                                                       trashed or not.
336
-     * @return EE_Question_Option[]
337
-     */
338
-    public function options($notDeletedOptionsOnly = true, $selected_value_to_always_include = null)
339
-    {
340
-        if (! $this->ID()) {
341
-            return array();
342
-        }
343
-        $query_params = array();
344
-        if ($selected_value_to_always_include) {
345
-            if (is_array($selected_value_to_always_include)) {
346
-                $query_params[0]['OR*options-query']['QSO_value'] = array('IN', $selected_value_to_always_include);
347
-            } else {
348
-                $query_params[0]['OR*options-query']['QSO_value'] = $selected_value_to_always_include;
349
-            }
350
-        }
351
-        if ($notDeletedOptionsOnly) {
352
-            $query_params[0]['OR*options-query']['QSO_deleted'] = false;
353
-        }
354
-        // order by QSO_order
355
-        $query_params['order_by'] = array('QSO_order' => 'ASC');
356
-        return $this->get_many_related('Question_Option', $query_params);
357
-    }
358
-
359
-
360
-    /**
361
-     * returns an array of EE_Question_Options which relate to this question
362
-     *
363
-     * @return \EE_Question_Option[]
364
-     */
365
-    public function temp_options()
366
-    {
367
-        return $this->_model_relations['Question_Option'];
368
-    }
369
-
370
-
371
-    /**
372
-     * Adds an option for this question. Note: if the option were previously associated with a different
373
-     * Question, that relationship will be overwritten.
374
-     *
375
-     * @param EE_Question_Option $option
376
-     * @return boolean success
377
-     */
378
-    public function add_option(EE_Question_Option $option)
379
-    {
380
-        return $this->_add_relation_to($option, 'Question_Option');
381
-    }
382
-
383
-
384
-    /**
385
-     * Adds an option directly to this question without saving to the db
386
-     *
387
-     * @param EE_Question_Option $option
388
-     * @return boolean success
389
-     */
390
-    public function add_temp_option(EE_Question_Option $option)
391
-    {
392
-        $this->_model_relations['Question_Option'][] = $option;
393
-        return true;
394
-    }
395
-
396
-
397
-    /**
398
-     * Marks the option as deleted.
399
-     *
400
-     * @param EE_Question_Option $option
401
-     * @return boolean success
402
-     */
403
-    public function remove_option(EE_Question_Option $option)
404
-    {
405
-        return $this->_remove_relation_to($option, 'Question_Option');
406
-    }
407
-
408
-
409
-    /**
410
-     * @return bool
411
-     */
412
-    public function is_system_question()
413
-    {
414
-        $system_ID = $this->get('QST_system');
415
-        return ! empty($system_ID) ? true : false;
416
-    }
417
-
418
-
419
-    /**
420
-     * The purpose of this method is set the question order this question order to be the max out of all questions
421
-     *
422
-     * @access public
423
-     * @return void
424
-     */
425
-    public function set_order_to_latest()
426
-    {
427
-        $latest_order = $this->get_model()->get_latest_question_order();
428
-        $latest_order++;
429
-        $this->set('QST_order', $latest_order);
430
-    }
431
-
432
-
433
-    /**
434
-     * Retrieves the list of allowed question types from the model.
435
-     *
436
-     * @return string[]
437
-     */
438
-    private function _allowed_question_types()
439
-    {
440
-        $questionModel = $this->get_model();
441
-        /* @var $questionModel EEM_Question */
442
-        return $questionModel->allowed_question_types();
443
-    }
444
-
445
-    /**
446
-     * Duplicates this question and its question options
447
-     *
448
-     * @return \EE_Question
449
-     */
450
-    public function duplicate($options = array())
451
-    {
452
-        $new_question = clone $this;
453
-        $new_question->set('QST_ID', null);
454
-        $new_question->set_display_text(sprintf(__('%s **Duplicate**', 'event_espresso'), $this->display_text()));
455
-        $new_question->set_admin_label(sprintf(__('%s **Duplicate**', 'event_espresso'), $this->admin_label()));
456
-        $new_question->set_system_ID(null);
457
-        $new_question->set_wp_user(get_current_user_id());
458
-        // if we're duplicating a trashed question, assume we don't want the new one to be trashed
459
-        $new_question->set_deleted(false);
460
-        $success = $new_question->save();
461
-        if ($success) {
462
-            // we don't totally want to duplicate the question options, because we want them to be for the NEW question
463
-            foreach ($this->options() as $question_option) {
464
-                $question_option->duplicate(array('QST_ID' => $new_question->ID()));
465
-            }
466
-            return $new_question;
467
-        } else {
468
-            return null;
469
-        }
470
-    }
471
-
472
-    /**
473
-     * Returns the question's maximum allowed response size
474
-     *
475
-     * @return int|float
476
-     */
477
-    public function max()
478
-    {
479
-        return $this->get('QST_max');
480
-    }
481
-
482
-    /**
483
-     * Sets the question's maximum allowed response size
484
-     *
485
-     * @param int|float $new_max
486
-     * @return void
487
-     */
488
-    public function set_max($new_max)
489
-    {
490
-        $this->set('QST_max', $new_max);
491
-    }
492
-
493
-
494
-    /**
495
-     * Creates a form input from this question which can be used in HTML forms
496
-     *
497
-     * @param EE_Registration $registration
498
-     * @param EE_Answer       $answer
499
-     * @param array           $input_constructor_args
500
-     * @return EE_Form_Input_Base
501
-     */
502
-    public function generate_form_input($registration = null, $answer = null, $input_constructor_args = array())
503
-    {
504
-        $identifier = $this->is_system_question() ? $this->system_ID() : $this->ID();
505
-
506
-        $input_constructor_args = array_merge(
507
-            array(
508
-                'required'                          => $this->required() ? true : false,
509
-                'html_label_text'                   => $this->display_text(),
510
-                'required_validation_error_message' => $this->required_text(),
511
-            ),
512
-            $input_constructor_args
513
-        );
514
-        if (! $answer instanceof EE_Answer && $registration instanceof EE_Registration) {
515
-            $answer = EEM_Answer::instance()->get_registration_question_answer_object($registration, $this->ID());
516
-        }
517
-        // has this question been answered ?
518
-        if ($answer instanceof EE_Answer
519
-            && $answer->value() !== ''
520
-        ) {
521
-            // answer gets htmlspecialchars called on it, undo that please
522
-            // because the form input's display strategy may call esc_attr too
523
-            // which also does html special characters
524
-            $values_with_html_special_chars = $answer->value();
525
-            if (is_array($values_with_html_special_chars)) {
526
-                $default_value = array_map('htmlspecialchars_decode', $values_with_html_special_chars);
527
-            } else {
528
-                $default_value = htmlspecialchars_decode($values_with_html_special_chars);
529
-            }
530
-            $input_constructor_args['default'] = $default_value;
531
-        }
532
-        $max_max_for_question = EEM_Question::instance()->absolute_max_for_system_question($this->system_ID());
533
-        if (in_array(
534
-            $this->type(),
535
-            EEM_Question::instance()->questionTypesWithMaxLength(),
536
-            true
537
-        )) {
538
-            $input_constructor_args['validation_strategies'][] = new EE_Max_Length_Validation_Strategy(
539
-                null,
540
-                min($max_max_for_question, $this->max())
541
-            );
542
-        }
543
-        $input_constructor_args = apply_filters(
544
-            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__input_constructor_args',
545
-            $input_constructor_args,
546
-            $registration,
547
-            $this,
548
-            $answer
549
-        );
550
-
551
-        $result = null;
552
-        switch ($this->type()) {
553
-            // Text
554
-            case EEM_Question::QST_type_text:
555
-                $result = new EE_Text_Input($input_constructor_args);
556
-                break;
557
-            // Textarea
558
-            case EEM_Question::QST_type_textarea:
559
-                $result = new EE_Text_Area_Input($input_constructor_args);
560
-                break;
561
-            // Radio Buttons
562
-            case EEM_Question::QST_type_radio:
563
-                $result = new EE_Radio_Button_Input($this->options(), $input_constructor_args);
564
-                break;
565
-            // Dropdown
566
-            case EEM_Question::QST_type_dropdown:
567
-                $result = new EE_Select_Input($this->options(), $input_constructor_args);
568
-                break;
569
-            // State Dropdown
570
-            case EEM_Question::QST_type_state:
571
-                $state_options = apply_filters(
572
-                    'FHEE__EE_Question__generate_form_input__state_options',
573
-                    null,
574
-                    $this,
575
-                    $registration,
576
-                    $answer
577
-                );
578
-                $result = new EE_State_Select_Input($state_options, $input_constructor_args);
579
-                break;
580
-            // Country Dropdown
581
-            case EEM_Question::QST_type_country:
582
-                $country_options = apply_filters(
583
-                    'FHEE__EE_Question__generate_form_input__country_options',
584
-                    null,
585
-                    $this,
586
-                    $registration,
587
-                    $answer
588
-                );
589
-                $result = new EE_Country_Select_Input($country_options, $input_constructor_args);
590
-                break;
591
-            // Checkboxes
592
-            case EEM_Question::QST_type_checkbox:
593
-                $result = new EE_Checkbox_Multi_Input($this->options(), $input_constructor_args);
594
-                break;
595
-            // Date
596
-            case EEM_Question::QST_type_date:
597
-                $result = new EE_Datepicker_Input($input_constructor_args);
598
-                break;
599
-            case EEM_Question::QST_type_html_textarea:
600
-                $input_constructor_args['validation_strategies'][] = new EE_Simple_HTML_Validation_Strategy();
601
-                $result = new EE_Text_Area_Input($input_constructor_args);
602
-                $result->remove_validation_strategy('EE_Plaintext_Validation_Strategy');
603
-                break;
604
-            case EEM_Question::QST_type_email:
605
-                    $result = new EE_Email_Input($input_constructor_args);
606
-                break;
607
-            // Email confirm
608
-            case EEM_Question::QST_type_email_confirm:
609
-                $result = new EE_Email_Confirm_Input($input_constructor_args);
610
-                break;
611
-            case EEM_Question::QST_type_us_phone:
612
-                $result = new EE_Phone_Input($input_constructor_args);
613
-                break;
614
-            case EEM_Question::QST_type_int:
615
-                $result = new EE_Integer_Input($input_constructor_args);
616
-                break;
617
-            case EEM_Question::QST_type_decimal:
618
-                $result = new EE_Float_Input($input_constructor_args);
619
-                break;
620
-            case EEM_Question::QST_type_url:
621
-                $input_constructor_args['validation_strategies'][] = LoaderFactory::getLoader()->getNew('EE_URL_Validation_Strategy');
622
-                $result = new EE_Text_Input($input_constructor_args);
623
-                break;
624
-            case EEM_Question::QST_type_year:
625
-                $result = new EE_Year_Input(
626
-                    $input_constructor_args,
627
-                    apply_filters(
628
-                        'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__four_digit',
629
-                        true,
630
-                        $this
631
-                    ),
632
-                    apply_filters(
633
-                        'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__early_range',
634
-                        100,
635
-                        $this
636
-                    ),
637
-                    apply_filters(
638
-                        'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__end_range',
639
-                        100,
640
-                        $this
641
-                    )
642
-                );
643
-                break;
644
-            case EEM_Question::QST_type_multi_select:
645
-                $result = new EE_Select_Multiple_Input($this->options(), $input_constructor_args);
646
-                break;
647
-            // fallback
648
-            default:
649
-                $default_input = apply_filters(
650
-                    'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__default',
651
-                    null,
652
-                    $this->type(),
653
-                    $this,
654
-                    $input_constructor_args
655
-                );
656
-                if (! $default_input) {
657
-                    $default_input = new EE_Text_Input($input_constructor_args);
658
-                }
659
-                $result = $default_input;
660
-        }
661
-        return apply_filters('FHEE__EE_Question__generate_form_input__return', $result, $registration, $this, $answer);
662
-    }
663
-
664
-
665
-    /**
666
-     * Returns whether or not this question type should have question option entries
667
-     *
668
-     * @return bool
669
-     */
670
-    public function should_have_question_options()
671
-    {
672
-        return in_array(
673
-            $this->type(),
674
-            $this->_model->question_types_with_options(),
675
-            true
676
-        );
677
-    }
17
+	/**
18
+	 *
19
+	 * @param array  $props_n_values          incoming values
20
+	 * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
21
+	 *                                        used.)
22
+	 * @param array  $date_formats            incoming date_formats in an array where the first value is the
23
+	 *                                        date_format and the second value is the time format
24
+	 * @return EE_Question
25
+	 */
26
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
27
+	{
28
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
29
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
30
+	}
31
+
32
+
33
+	/**
34
+	 * @param array  $props_n_values  incoming values from the database
35
+	 * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
36
+	 *                                the website will be used.
37
+	 * @return EE_Question
38
+	 */
39
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null)
40
+	{
41
+		return new self($props_n_values, true, $timezone);
42
+	}
43
+
44
+
45
+	/**
46
+	 *        Set    Question display text
47
+	 *
48
+	 * @access        public
49
+	 * @param string $QST_display_text
50
+	 */
51
+	public function set_display_text($QST_display_text = '')
52
+	{
53
+		$this->set('QST_display_text', $QST_display_text);
54
+	}
55
+
56
+
57
+	/**
58
+	 *        Set    Question admin text
59
+	 *
60
+	 * @access        public
61
+	 * @param        string $QST_admin_label
62
+	 */
63
+	public function set_admin_label($QST_admin_label = '')
64
+	{
65
+		$this->set('QST_admin_label', $QST_admin_label);
66
+	}
67
+
68
+
69
+	/**
70
+	 *        Set    system name
71
+	 *
72
+	 * @access        public
73
+	 * @param        mixed $QST_system
74
+	 */
75
+	public function set_system_ID($QST_system = '')
76
+	{
77
+		$this->set('QST_system', $QST_system);
78
+	}
79
+
80
+
81
+	/**
82
+	 *        Set    question's type
83
+	 *
84
+	 * @access        public
85
+	 * @param        string $QST_type
86
+	 */
87
+	public function set_question_type($QST_type = '')
88
+	{
89
+		$this->set('QST_type', $QST_type);
90
+	}
91
+
92
+
93
+	/**
94
+	 *        Sets whether this question must be answered when presented in a form
95
+	 *
96
+	 * @access        public
97
+	 * @param        bool $QST_required
98
+	 */
99
+	public function set_required($QST_required = false)
100
+	{
101
+		$this->set('QST_required', $QST_required);
102
+	}
103
+
104
+
105
+	/**
106
+	 *        Set    Question display text
107
+	 *
108
+	 * @access        public
109
+	 * @param        string $QST_required_text
110
+	 */
111
+	public function set_required_text($QST_required_text = '')
112
+	{
113
+		$this->set('QST_required_text', $QST_required_text);
114
+	}
115
+
116
+
117
+	/**
118
+	 *        Sets the order of this question when placed in a sequence of questions
119
+	 *
120
+	 * @access        public
121
+	 * @param        int $QST_order
122
+	 */
123
+	public function set_order($QST_order = 0)
124
+	{
125
+		$this->set('QST_order', $QST_order);
126
+	}
127
+
128
+
129
+	/**
130
+	 *        Sets whether the question is admin-only
131
+	 *
132
+	 * @access        public
133
+	 * @param        bool $QST_admin_only
134
+	 */
135
+	public function set_admin_only($QST_admin_only = false)
136
+	{
137
+		$this->set('QST_admin_only', $QST_admin_only);
138
+	}
139
+
140
+
141
+	/**
142
+	 *        Sets the wordpress user ID on the question
143
+	 *
144
+	 * @access        public
145
+	 * @param        int $QST_wp_user
146
+	 */
147
+	public function set_wp_user($QST_wp_user = 1)
148
+	{
149
+		$this->set('QST_wp_user', $QST_wp_user);
150
+	}
151
+
152
+
153
+	/**
154
+	 *        Sets whether the question has been deleted
155
+	 *        (we use this boolean instead of actually
156
+	 *        deleting it because when users delete this question
157
+	 *        they really want to remove the question from future
158
+	 *        forms, BUT keep their old answers which depend
159
+	 *        on this record actually existing.
160
+	 *
161
+	 * @access        public
162
+	 * @param    bool $QST_deleted
163
+	 */
164
+	public function set_deleted($QST_deleted = false)
165
+	{
166
+		$this->set('QST_deleted', $QST_deleted);
167
+	}
168
+
169
+
170
+	/**
171
+	 * returns the text for displaying the question to users
172
+	 *
173
+	 * @access public
174
+	 * @return string
175
+	 */
176
+	public function display_text()
177
+	{
178
+		return $this->get('QST_display_text');
179
+	}
180
+
181
+
182
+	/**
183
+	 * returns the text for the administrative label
184
+	 *
185
+	 * @access public
186
+	 * @return string
187
+	 */
188
+	public function admin_label()
189
+	{
190
+		return $this->get('QST_admin_label');
191
+	}
192
+
193
+
194
+	/**
195
+	 * returns the attendee column name for this question
196
+	 *
197
+	 * @access public
198
+	 * @return string
199
+	 */
200
+	public function system_ID()
201
+	{
202
+		return $this->get('QST_system');
203
+	}
204
+
205
+
206
+	/**
207
+	 * returns either a string of 'text', 'textfield', etc.
208
+	 *
209
+	 * @access public
210
+	 * @return boolean
211
+	 */
212
+	public function required()
213
+	{
214
+		return $this->get('QST_required');
215
+	}
216
+
217
+
218
+	/**
219
+	 * returns the text which should be displayed when a user
220
+	 * doesn't answer this question in a form
221
+	 *
222
+	 * @access public
223
+	 * @return string
224
+	 */
225
+	public function required_text()
226
+	{
227
+		return $this->get('QST_required_text');
228
+	}
229
+
230
+
231
+	/**
232
+	 * returns the type of this question
233
+	 *
234
+	 * @access public
235
+	 * @return string
236
+	 */
237
+	public function type()
238
+	{
239
+		return $this->get('QST_type');
240
+	}
241
+
242
+
243
+	/**
244
+	 * returns an integer showing where this question should
245
+	 * be placed in a sequence of questions
246
+	 *
247
+	 * @access public
248
+	 * @return int
249
+	 */
250
+	public function order()
251
+	{
252
+		return $this->get('QST_order');
253
+	}
254
+
255
+
256
+	/**
257
+	 * returns whether this question should only appears to admins,
258
+	 * or to everyone
259
+	 *
260
+	 * @access public
261
+	 * @return boolean
262
+	 */
263
+	public function admin_only()
264
+	{
265
+		return $this->get('QST_admin_only');
266
+	}
267
+
268
+
269
+	/**
270
+	 * returns the id the wordpress user who created this question
271
+	 *
272
+	 * @access public
273
+	 * @return int
274
+	 */
275
+	public function wp_user()
276
+	{
277
+		return $this->get('QST_wp_user');
278
+	}
279
+
280
+
281
+	/**
282
+	 * returns whether this question has been marked as 'deleted'
283
+	 *
284
+	 * @access public
285
+	 * @return boolean
286
+	 */
287
+	public function deleted()
288
+	{
289
+		return $this->get('QST_deleted');
290
+	}
291
+
292
+
293
+	/**
294
+	 * Gets an array of related EE_Answer  to this EE_Question
295
+	 *
296
+	 * @return EE_Answer[]
297
+	 */
298
+	public function answers()
299
+	{
300
+		return $this->get_many_related('Answer');
301
+	}
302
+
303
+
304
+	/**
305
+	 * Boolean check for if there are answers on this question in th db
306
+	 *
307
+	 * @return boolean true = has answers, false = no answers.
308
+	 */
309
+	public function has_answers()
310
+	{
311
+		return $this->count_related('Answer') > 0 ? true : false;
312
+	}
313
+
314
+
315
+	/**
316
+	 * gets an array of EE_Question_Group which relate to this question
317
+	 *
318
+	 * @return EE_Question_Group[]
319
+	 */
320
+	public function question_groups()
321
+	{
322
+		return $this->get_many_related('Question_Group');
323
+	}
324
+
325
+
326
+	/**
327
+	 * Returns all the options for this question. By default, it returns only the not-yet-deleted ones.
328
+	 *
329
+	 * @param boolean      $notDeletedOptionsOnly            1
330
+	 *                                                       whether to return ALL options, or only the ones which have
331
+	 *                                                       not yet been deleleted
332
+	 * @param string|array $selected_value_to_always_include , when retrieving options to an ANSWERED question,
333
+	 *                                                       we want to usually only show non-deleted options AND the
334
+	 *                                                       value that was selected for the answer, whether it was
335
+	 *                                                       trashed or not.
336
+	 * @return EE_Question_Option[]
337
+	 */
338
+	public function options($notDeletedOptionsOnly = true, $selected_value_to_always_include = null)
339
+	{
340
+		if (! $this->ID()) {
341
+			return array();
342
+		}
343
+		$query_params = array();
344
+		if ($selected_value_to_always_include) {
345
+			if (is_array($selected_value_to_always_include)) {
346
+				$query_params[0]['OR*options-query']['QSO_value'] = array('IN', $selected_value_to_always_include);
347
+			} else {
348
+				$query_params[0]['OR*options-query']['QSO_value'] = $selected_value_to_always_include;
349
+			}
350
+		}
351
+		if ($notDeletedOptionsOnly) {
352
+			$query_params[0]['OR*options-query']['QSO_deleted'] = false;
353
+		}
354
+		// order by QSO_order
355
+		$query_params['order_by'] = array('QSO_order' => 'ASC');
356
+		return $this->get_many_related('Question_Option', $query_params);
357
+	}
358
+
359
+
360
+	/**
361
+	 * returns an array of EE_Question_Options which relate to this question
362
+	 *
363
+	 * @return \EE_Question_Option[]
364
+	 */
365
+	public function temp_options()
366
+	{
367
+		return $this->_model_relations['Question_Option'];
368
+	}
369
+
370
+
371
+	/**
372
+	 * Adds an option for this question. Note: if the option were previously associated with a different
373
+	 * Question, that relationship will be overwritten.
374
+	 *
375
+	 * @param EE_Question_Option $option
376
+	 * @return boolean success
377
+	 */
378
+	public function add_option(EE_Question_Option $option)
379
+	{
380
+		return $this->_add_relation_to($option, 'Question_Option');
381
+	}
382
+
383
+
384
+	/**
385
+	 * Adds an option directly to this question without saving to the db
386
+	 *
387
+	 * @param EE_Question_Option $option
388
+	 * @return boolean success
389
+	 */
390
+	public function add_temp_option(EE_Question_Option $option)
391
+	{
392
+		$this->_model_relations['Question_Option'][] = $option;
393
+		return true;
394
+	}
395
+
396
+
397
+	/**
398
+	 * Marks the option as deleted.
399
+	 *
400
+	 * @param EE_Question_Option $option
401
+	 * @return boolean success
402
+	 */
403
+	public function remove_option(EE_Question_Option $option)
404
+	{
405
+		return $this->_remove_relation_to($option, 'Question_Option');
406
+	}
407
+
408
+
409
+	/**
410
+	 * @return bool
411
+	 */
412
+	public function is_system_question()
413
+	{
414
+		$system_ID = $this->get('QST_system');
415
+		return ! empty($system_ID) ? true : false;
416
+	}
417
+
418
+
419
+	/**
420
+	 * The purpose of this method is set the question order this question order to be the max out of all questions
421
+	 *
422
+	 * @access public
423
+	 * @return void
424
+	 */
425
+	public function set_order_to_latest()
426
+	{
427
+		$latest_order = $this->get_model()->get_latest_question_order();
428
+		$latest_order++;
429
+		$this->set('QST_order', $latest_order);
430
+	}
431
+
432
+
433
+	/**
434
+	 * Retrieves the list of allowed question types from the model.
435
+	 *
436
+	 * @return string[]
437
+	 */
438
+	private function _allowed_question_types()
439
+	{
440
+		$questionModel = $this->get_model();
441
+		/* @var $questionModel EEM_Question */
442
+		return $questionModel->allowed_question_types();
443
+	}
444
+
445
+	/**
446
+	 * Duplicates this question and its question options
447
+	 *
448
+	 * @return \EE_Question
449
+	 */
450
+	public function duplicate($options = array())
451
+	{
452
+		$new_question = clone $this;
453
+		$new_question->set('QST_ID', null);
454
+		$new_question->set_display_text(sprintf(__('%s **Duplicate**', 'event_espresso'), $this->display_text()));
455
+		$new_question->set_admin_label(sprintf(__('%s **Duplicate**', 'event_espresso'), $this->admin_label()));
456
+		$new_question->set_system_ID(null);
457
+		$new_question->set_wp_user(get_current_user_id());
458
+		// if we're duplicating a trashed question, assume we don't want the new one to be trashed
459
+		$new_question->set_deleted(false);
460
+		$success = $new_question->save();
461
+		if ($success) {
462
+			// we don't totally want to duplicate the question options, because we want them to be for the NEW question
463
+			foreach ($this->options() as $question_option) {
464
+				$question_option->duplicate(array('QST_ID' => $new_question->ID()));
465
+			}
466
+			return $new_question;
467
+		} else {
468
+			return null;
469
+		}
470
+	}
471
+
472
+	/**
473
+	 * Returns the question's maximum allowed response size
474
+	 *
475
+	 * @return int|float
476
+	 */
477
+	public function max()
478
+	{
479
+		return $this->get('QST_max');
480
+	}
481
+
482
+	/**
483
+	 * Sets the question's maximum allowed response size
484
+	 *
485
+	 * @param int|float $new_max
486
+	 * @return void
487
+	 */
488
+	public function set_max($new_max)
489
+	{
490
+		$this->set('QST_max', $new_max);
491
+	}
492
+
493
+
494
+	/**
495
+	 * Creates a form input from this question which can be used in HTML forms
496
+	 *
497
+	 * @param EE_Registration $registration
498
+	 * @param EE_Answer       $answer
499
+	 * @param array           $input_constructor_args
500
+	 * @return EE_Form_Input_Base
501
+	 */
502
+	public function generate_form_input($registration = null, $answer = null, $input_constructor_args = array())
503
+	{
504
+		$identifier = $this->is_system_question() ? $this->system_ID() : $this->ID();
505
+
506
+		$input_constructor_args = array_merge(
507
+			array(
508
+				'required'                          => $this->required() ? true : false,
509
+				'html_label_text'                   => $this->display_text(),
510
+				'required_validation_error_message' => $this->required_text(),
511
+			),
512
+			$input_constructor_args
513
+		);
514
+		if (! $answer instanceof EE_Answer && $registration instanceof EE_Registration) {
515
+			$answer = EEM_Answer::instance()->get_registration_question_answer_object($registration, $this->ID());
516
+		}
517
+		// has this question been answered ?
518
+		if ($answer instanceof EE_Answer
519
+			&& $answer->value() !== ''
520
+		) {
521
+			// answer gets htmlspecialchars called on it, undo that please
522
+			// because the form input's display strategy may call esc_attr too
523
+			// which also does html special characters
524
+			$values_with_html_special_chars = $answer->value();
525
+			if (is_array($values_with_html_special_chars)) {
526
+				$default_value = array_map('htmlspecialchars_decode', $values_with_html_special_chars);
527
+			} else {
528
+				$default_value = htmlspecialchars_decode($values_with_html_special_chars);
529
+			}
530
+			$input_constructor_args['default'] = $default_value;
531
+		}
532
+		$max_max_for_question = EEM_Question::instance()->absolute_max_for_system_question($this->system_ID());
533
+		if (in_array(
534
+			$this->type(),
535
+			EEM_Question::instance()->questionTypesWithMaxLength(),
536
+			true
537
+		)) {
538
+			$input_constructor_args['validation_strategies'][] = new EE_Max_Length_Validation_Strategy(
539
+				null,
540
+				min($max_max_for_question, $this->max())
541
+			);
542
+		}
543
+		$input_constructor_args = apply_filters(
544
+			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__input_constructor_args',
545
+			$input_constructor_args,
546
+			$registration,
547
+			$this,
548
+			$answer
549
+		);
550
+
551
+		$result = null;
552
+		switch ($this->type()) {
553
+			// Text
554
+			case EEM_Question::QST_type_text:
555
+				$result = new EE_Text_Input($input_constructor_args);
556
+				break;
557
+			// Textarea
558
+			case EEM_Question::QST_type_textarea:
559
+				$result = new EE_Text_Area_Input($input_constructor_args);
560
+				break;
561
+			// Radio Buttons
562
+			case EEM_Question::QST_type_radio:
563
+				$result = new EE_Radio_Button_Input($this->options(), $input_constructor_args);
564
+				break;
565
+			// Dropdown
566
+			case EEM_Question::QST_type_dropdown:
567
+				$result = new EE_Select_Input($this->options(), $input_constructor_args);
568
+				break;
569
+			// State Dropdown
570
+			case EEM_Question::QST_type_state:
571
+				$state_options = apply_filters(
572
+					'FHEE__EE_Question__generate_form_input__state_options',
573
+					null,
574
+					$this,
575
+					$registration,
576
+					$answer
577
+				);
578
+				$result = new EE_State_Select_Input($state_options, $input_constructor_args);
579
+				break;
580
+			// Country Dropdown
581
+			case EEM_Question::QST_type_country:
582
+				$country_options = apply_filters(
583
+					'FHEE__EE_Question__generate_form_input__country_options',
584
+					null,
585
+					$this,
586
+					$registration,
587
+					$answer
588
+				);
589
+				$result = new EE_Country_Select_Input($country_options, $input_constructor_args);
590
+				break;
591
+			// Checkboxes
592
+			case EEM_Question::QST_type_checkbox:
593
+				$result = new EE_Checkbox_Multi_Input($this->options(), $input_constructor_args);
594
+				break;
595
+			// Date
596
+			case EEM_Question::QST_type_date:
597
+				$result = new EE_Datepicker_Input($input_constructor_args);
598
+				break;
599
+			case EEM_Question::QST_type_html_textarea:
600
+				$input_constructor_args['validation_strategies'][] = new EE_Simple_HTML_Validation_Strategy();
601
+				$result = new EE_Text_Area_Input($input_constructor_args);
602
+				$result->remove_validation_strategy('EE_Plaintext_Validation_Strategy');
603
+				break;
604
+			case EEM_Question::QST_type_email:
605
+					$result = new EE_Email_Input($input_constructor_args);
606
+				break;
607
+			// Email confirm
608
+			case EEM_Question::QST_type_email_confirm:
609
+				$result = new EE_Email_Confirm_Input($input_constructor_args);
610
+				break;
611
+			case EEM_Question::QST_type_us_phone:
612
+				$result = new EE_Phone_Input($input_constructor_args);
613
+				break;
614
+			case EEM_Question::QST_type_int:
615
+				$result = new EE_Integer_Input($input_constructor_args);
616
+				break;
617
+			case EEM_Question::QST_type_decimal:
618
+				$result = new EE_Float_Input($input_constructor_args);
619
+				break;
620
+			case EEM_Question::QST_type_url:
621
+				$input_constructor_args['validation_strategies'][] = LoaderFactory::getLoader()->getNew('EE_URL_Validation_Strategy');
622
+				$result = new EE_Text_Input($input_constructor_args);
623
+				break;
624
+			case EEM_Question::QST_type_year:
625
+				$result = new EE_Year_Input(
626
+					$input_constructor_args,
627
+					apply_filters(
628
+						'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__four_digit',
629
+						true,
630
+						$this
631
+					),
632
+					apply_filters(
633
+						'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__early_range',
634
+						100,
635
+						$this
636
+					),
637
+					apply_filters(
638
+						'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__end_range',
639
+						100,
640
+						$this
641
+					)
642
+				);
643
+				break;
644
+			case EEM_Question::QST_type_multi_select:
645
+				$result = new EE_Select_Multiple_Input($this->options(), $input_constructor_args);
646
+				break;
647
+			// fallback
648
+			default:
649
+				$default_input = apply_filters(
650
+					'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__default',
651
+					null,
652
+					$this->type(),
653
+					$this,
654
+					$input_constructor_args
655
+				);
656
+				if (! $default_input) {
657
+					$default_input = new EE_Text_Input($input_constructor_args);
658
+				}
659
+				$result = $default_input;
660
+		}
661
+		return apply_filters('FHEE__EE_Question__generate_form_input__return', $result, $registration, $this, $answer);
662
+	}
663
+
664
+
665
+	/**
666
+	 * Returns whether or not this question type should have question option entries
667
+	 *
668
+	 * @return bool
669
+	 */
670
+	public function should_have_question_options()
671
+	{
672
+		return in_array(
673
+			$this->type(),
674
+			$this->_model->question_types_with_options(),
675
+			true
676
+		);
677
+	}
678 678
 }
Please login to merge, or discard this patch.
venues/templates/venue_virtual_location_metabox_content.template.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
                         <?php esc_html_e('URL of Event:', 'event_espresso'); ?>
8 8
                     </label>
9 9
                     <?php //phpcs:disable Generic.Files.LineLength.TooLong
10
-                    // no new lines within <textarea> here because they'll output whitespace ?>
10
+					// no new lines within <textarea> here because they'll output whitespace ?>
11 11
                     <textarea id="url-event" cols="30" rows="4" tabindex="112" name="vnu_virtual_url"><?php $_venue->f('VNU_virtual_url'); ?></textarea>
12 12
                     <?php //phpcs:enable ?>
13 13
                 </p>
Please login to merge, or discard this patch.
admin/extend/registrations/EE_Event_Registrations_List_Table.class.php 2 patches
Indentation   +557 added lines, -557 removed lines patch added patch discarded remove patch
@@ -12,566 +12,566 @@
 block discarded – undo
12 12
 class EE_Event_Registrations_List_Table extends EE_Admin_List_Table
13 13
 {
14 14
 
15
-    /**
16
-     * This property will hold the related Datetimes on an event IF the event id is included in the request.
17
-     *
18
-     * @var EE_Datetime[]
19
-     */
20
-    protected $_dtts_for_event = array();
21
-
22
-
23
-    /**
24
-     * The event if one is specified in the request
25
-     *
26
-     * @var EE_Event
27
-     */
28
-    protected $_evt = null;
29
-
30
-
31
-    /**
32
-     * The DTT_ID if the current view has a specified datetime.
33
-     *
34
-     * @var int $_cur_dtt_id
35
-     */
36
-    protected $_cur_dtt_id = 0;
37
-
38
-
39
-    /**
40
-     * EE_Event_Registrations_List_Table constructor.
41
-     *
42
-     * @param \Registrations_Admin_Page $admin_page
43
-     */
44
-    public function __construct($admin_page)
45
-    {
46
-        parent::__construct($admin_page);
47
-        $this->_status = $this->_admin_page->get_registration_status_array();
48
-    }
49
-
50
-
51
-    protected function _setup_data()
52
-    {
53
-        $this->_data = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees($this->_per_page)
54
-            : $this->_admin_page->get_event_attendees($this->_per_page, false, true);
55
-        $this->_all_data_count = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees(
56
-            $this->_per_page,
57
-            true
58
-        ) : $this->_admin_page->get_event_attendees($this->_per_page, true, true);
59
-    }
60
-
61
-
62
-    protected function _set_properties()
63
-    {
64
-        $evt_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null;
65
-        $this->_wp_list_args = array(
66
-            'singular' => __('registrant', 'event_espresso'),
67
-            'plural'   => __('registrants', 'event_espresso'),
68
-            'ajax'     => true,
69
-            'screen'   => $this->_admin_page->get_current_screen()->id,
70
-        );
71
-        $columns = array();
72
-        // $columns['_Reg_Status'] = '';
73
-        $this->_columns = array(
74
-            '_REG_att_checked_in' => '<span class="dashicons dashicons-yes ee-icon-size-18"></span>',
75
-            'ATT_name'            => __('Registrant', 'event_espresso'),
76
-            'ATT_email'           => __('Email Address', 'event_espresso'),
77
-            'Event'               => __('Event', 'event_espresso'),
78
-            'PRC_name'            => __('TKT Option', 'event_espresso'),
79
-            '_REG_final_price'    => __('Price', 'event_espresso'),
80
-            'TXN_paid'            => __('Paid', 'event_espresso'),
81
-            'TXN_total'           => __('Total', 'event_espresso'),
82
-        );
83
-        // Add/remove columns when an event has been selected
84
-        if (! empty($evt_id)) {
85
-            // Render a checkbox column
86
-            $columns['cb'] = '<input type="checkbox" />';
87
-            $this->_has_checkbox_column = true;
88
-            // Remove the 'Event' column
89
-            unset($this->_columns['Event']);
90
-        }
91
-        $this->_columns = array_merge($columns, $this->_columns);
92
-        $this->_primary_column = '_REG_att_checked_in';
93
-        if (! empty($evt_id)
94
-            && EE_Registry::instance()->CAP->current_user_can(
95
-                'ee_read_registrations',
96
-                'espresso_registrations_registrations_reports',
97
-                $evt_id
98
-            )
99
-        ) {
100
-            $this->_bottom_buttons = array(
101
-                'report' => array(
102
-                    'route'         => 'registrations_report',
103
-                    'extra_request' =>
104
-                        array(
105
-                            'EVT_ID'     => $evt_id,
106
-                            'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
107
-                        ),
108
-                ),
109
-            );
110
-        }
111
-        $this->_bottom_buttons['report_filtered'] = array(
112
-            'route'         => 'registrations_checkin_report',
113
-            'extra_request' => array(
114
-                'use_filters' => true,
115
-                'filters'     => array_merge(
116
-                    array(
117
-                        'EVT_ID' => $evt_id,
118
-                    ),
119
-                    array_diff_key(
120
-                        $this->_req_data,
121
-                        array_flip(
122
-                            array(
123
-                                'page',
124
-                                'action',
125
-                                'default_nonce',
126
-                            )
127
-                        )
128
-                    )
129
-                ),
130
-                'return_url'  => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
131
-            ),
132
-        );
133
-        $this->_sortable_columns = array(
134
-            /**
135
-             * Allows users to change the default sort if they wish.
136
-             * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name.
137
-             *
138
-             * Note: usual naming conventions for filters aren't followed here so that just one filter can be used to
139
-             * change the sorts on any list table involving registration contacts.  If you want to only change the filter
140
-             * for a specific list table you can use the provided reference to this object instance.
141
-             */
142
-            'ATT_name' => array(
143
-                'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
144
-                true,
145
-                $this,
146
-            )
147
-                ? array('ATT_lname' => true)
148
-                : array('ATT_fname' => true),
149
-            'Event'    => array('Event.EVT_name' => false),
150
-        );
151
-        $this->_hidden_columns = array();
152
-        $this->_evt = EEM_Event::instance()->get_one_by_ID($evt_id);
153
-        $this->_dtts_for_event = $this->_evt instanceof EE_Event ? $this->_evt->datetimes_ordered() : array();
154
-    }
155
-
156
-
157
-    /**
158
-     * @param \EE_Registration $item
159
-     * @return string
160
-     */
161
-    protected function _get_row_class($item)
162
-    {
163
-        $class = parent::_get_row_class($item);
164
-        // add status class
165
-        $class .= ' ee-status-strip reg-status-' . $item->status_ID();
166
-        if ($this->_has_checkbox_column) {
167
-            $class .= ' has-checkbox-column';
168
-        }
169
-        return $class;
170
-    }
171
-
172
-
173
-    /**
174
-     * @return array
175
-     * @throws \EE_Error
176
-     */
177
-    protected function _get_table_filters()
178
-    {
179
-        $filters = $where = array();
180
-        $current_EVT_ID = isset($this->_req_data['event_id']) ? (int) $this->_req_data['event_id'] : 0;
181
-        if (empty($this->_dtts_for_event) || count($this->_dtts_for_event) === 1) {
182
-            // this means we don't have an event so let's setup a filter dropdown for all the events to select
183
-            // note possible capability restrictions
184
-            if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
185
-                $where['status**'] = array('!=', 'private');
186
-            }
187
-            if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
188
-                $where['EVT_wp_user'] = get_current_user_id();
189
-            }
190
-            $events = EEM_Event::instance()->get_all(
191
-                array(
192
-                    $where,
193
-                    'order_by' => array('Datetime.DTT_EVT_start' => 'DESC'),
194
-                )
195
-            );
196
-            $evts[] = array(
197
-                'id'   => 0,
198
-                'text' => __('To toggle Check-in status, select an event', 'event_espresso'),
199
-            );
200
-            $checked = 'checked';
201
-            /** @var EE_Event $evt */
202
-            foreach ($events as $evt) {
203
-                // any registrations for this event?
204
-                if (! $evt->get_count_of_all_registrations()) {
205
-                    continue;
206
-                }
207
-                $evts[] = array(
208
-                    'id'    => $evt->ID(),
209
-                    'text'  => apply_filters(
210
-                        'FHEE__EE_Event_Registrations___get_table_filters__event_name',
211
-                        $evt->get('EVT_name'),
212
-                        $evt
213
-                    ),
214
-                    'class' => $evt->is_expired() ? 'ee-expired-event' : '',
215
-                );
216
-                if ($evt->ID() === $current_EVT_ID && $evt->is_expired()) {
217
-                    $checked = '';
218
-                }
219
-            }
220
-            $event_filter = '<div class="ee-event-filter">';
221
-            $event_filter .= EEH_Form_Fields::select_input('event_id', $evts, $current_EVT_ID);
222
-            $event_filter .= '<span class="ee-event-filter-toggle">';
223
-            $event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" ' . $checked . '> ';
224
-            $event_filter .= __('Hide Expired Events', 'event_espresso');
225
-            $event_filter .= '</span>';
226
-            $event_filter .= '</div>';
227
-            $filters[] = $event_filter;
228
-        }
229
-        if (! empty($this->_dtts_for_event)) {
230
-            // DTT datetimes filter
231
-            $this->_cur_dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0;
232
-            if (count($this->_dtts_for_event) > 1) {
233
-                $dtts[0] = __('To toggle check-in status, select a datetime.', 'event_espresso');
234
-                foreach ($this->_dtts_for_event as $dtt) {
235
-                    $datetime_string = $dtt->name();
236
-                    $datetime_string = ! empty($datetime_string) ? ' (' . $datetime_string . ')' : '';
237
-                    $datetime_string = $dtt->start_date_and_time() . ' - ' . $dtt->end_date_and_time() . $datetime_string;
238
-                    $dtts[ $dtt->ID() ] = $datetime_string;
239
-                }
240
-                $input = new EE_Select_Input(
241
-                    $dtts,
242
-                    array(
243
-                        'html_name' => 'DTT_ID',
244
-                        'html_id'   => 'DTT_ID',
245
-                        'default'   => $this->_cur_dtt_id,
246
-                    )
247
-                );
248
-                $filters[] = $input->get_html_for_input();
249
-                $filters[] = '<input type="hidden" name="event_id" value="' . $current_EVT_ID . '">';
250
-            }
251
-        }
252
-        return $filters;
253
-    }
254
-
255
-
256
-    protected function _add_view_counts()
257
-    {
258
-        $this->_views['all']['count'] = $this->_get_total_event_attendees();
259
-    }
260
-
261
-
262
-    /**
263
-     * @return int
264
-     * @throws \EE_Error
265
-     */
266
-    protected function _get_total_event_attendees()
267
-    {
268
-        $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
269
-        $DTT_ID = $this->_cur_dtt_id;
270
-        $query_params = array();
271
-        if ($EVT_ID) {
272
-            $query_params[0]['EVT_ID'] = $EVT_ID;
273
-        }
274
-        // if DTT is included we only show for that datetime.  Otherwise we're showing for all datetimes (the event).
275
-        if ($DTT_ID) {
276
-            $query_params[0]['Ticket.Datetime.DTT_ID'] = $DTT_ID;
277
-        }
278
-        $status_ids_array = apply_filters(
279
-            'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
280
-            array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved)
281
-        );
282
-        $query_params[0]['STS_ID'] = array('IN', $status_ids_array);
283
-        return EEM_Registration::instance()->count($query_params);
284
-    }
285
-
286
-
287
-    /**
288
-     * @param \EE_Registration $item
289
-     * @return string
290
-     */
291
-    public function column__Reg_Status(EE_Registration $item)
292
-    {
293
-        return '<span class="ee-status-strip ee-status-strip-td reg-status-' . $item->status_ID() . '"></span>';
294
-    }
295
-
296
-
297
-    /**
298
-     * @param \EE_Registration $item
299
-     * @return string
300
-     * @throws \EE_Error
301
-     */
302
-    public function column_cb($item)
303
-    {
304
-        return sprintf('<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID());
305
-    }
306
-
307
-
308
-    /**
309
-     * column_REG_att_checked_in
310
-     *
311
-     * @param EE_Registration $item
312
-     * @return string
313
-     * @throws EE_Error
314
-     * @throws InvalidArgumentException
315
-     * @throws InvalidDataTypeException
316
-     * @throws InvalidInterfaceException
317
-     */
318
-    public function column__REG_att_checked_in(EE_Registration $item)
319
-    {
320
-        $attendee = $item->attendee();
321
-        $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
322
-
323
-        if ($this->_cur_dtt_id === 0 && count($this->_dtts_for_event) === 1) {
324
-            $latest_related_datetime = $item->get_latest_related_datetime();
325
-            if ($latest_related_datetime instanceof EE_Datetime) {
326
-                $this->_cur_dtt_id = $latest_related_datetime->ID();
327
-            }
328
-        }
329
-        $checkin_status_dashicon = CheckinStatusDashicon::fromRegistrationAndDatetimeId(
330
-            $item,
331
-            $this->_cur_dtt_id
332
-        );
333
-        $nonce = wp_create_nonce('checkin_nonce');
334
-        $toggle_active = ! empty($this->_cur_dtt_id)
335
-                         && EE_Registry::instance()->CAP->current_user_can(
336
-                             'ee_edit_checkin',
337
-                             'espresso_registrations_toggle_checkin_status',
338
-                             $item->ID()
339
-                         )
340
-            ? ' clickable trigger-checkin'
341
-            : '';
342
-        $mobile_view_content = ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>';
343
-        return '<span class="' . $checkin_status_dashicon->cssClasses() . $toggle_active . '"'
344
-               . ' data-_regid="' . $item->ID() . '"'
345
-               . ' data-dttid="' . $this->_cur_dtt_id . '"'
346
-               . ' data-nonce="' . $nonce . '">'
347
-               . '</span>'
348
-               . $mobile_view_content;
349
-    }
350
-
351
-
352
-    /**
353
-     * @param \EE_Registration $item
354
-     * @return mixed|string|void
355
-     * @throws \EE_Error
356
-     */
357
-    public function column_ATT_name(EE_Registration $item)
358
-    {
359
-        $attendee = $item->attendee();
360
-        if (! $attendee instanceof EE_Attendee) {
361
-            return __('No contact record for this registration.', 'event_espresso');
362
-        }
363
-        // edit attendee link
364
-        $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
365
-            array('action' => 'view_registration', '_REG_ID' => $item->ID()),
366
-            REG_ADMIN_URL
367
-        );
368
-        $name_link = EE_Registry::instance()->CAP->current_user_can(
369
-            'ee_edit_contacts',
370
-            'espresso_registrations_edit_attendee'
371
-        )
372
-            ? '<a href="' . $edit_lnk_url . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '">'
373
-              . $item->attendee()->full_name()
374
-              . '</a>'
375
-            : $item->attendee()->full_name();
376
-        $name_link .= $item->count() === 1
377
-            ? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>	'
378
-            : '';
379
-        // add group details
380
-        $name_link .= '&nbsp;' . sprintf(__('(%s of %s)', 'event_espresso'), $item->count(), $item->group_size());
381
-        // add regcode
382
-        $link = EE_Admin_Page::add_query_args_and_nonce(
383
-            array('action' => 'view_registration', '_REG_ID' => $item->ID()),
384
-            REG_ADMIN_URL
385
-        );
386
-        $name_link .= '<br>';
387
-        $name_link .= EE_Registry::instance()->instance()->CAP->current_user_can(
388
-            'ee_read_registration',
389
-            'view_registration',
390
-            $item->ID()
391
-        )
392
-            ? '<a href="' . $link . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '">'
393
-              . $item->reg_code()
394
-              . '</a>'
395
-            : $item->reg_code();
396
-        // status
397
-        $name_link .= '<br><span class="ee-status-text-small">';
398
-        $name_link .= EEH_Template::pretty_status($item->status_ID(), false, 'sentence');
399
-        $name_link .= '</span>';
400
-        $actions = array();
401
-        $DTT_ID = $this->_cur_dtt_id;
402
-        $latest_related_datetime = empty($DTT_ID) && ! empty($this->_req_data['event_id']) && $item instanceof EE_Registration
403
-            ? $item->get_latest_related_datetime()
404
-            : null;
405
-        $DTT_ID = $latest_related_datetime instanceof EE_Datetime
406
-            ? $latest_related_datetime->ID()
407
-            : $DTT_ID;
408
-        if (! empty($DTT_ID)
409
-            && EE_Registry::instance()->CAP->current_user_can(
410
-                'ee_read_checkins',
411
-                'espresso_registrations_registration_checkins'
412
-            )
413
-        ) {
414
-            $checkin_list_url = EE_Admin_Page::add_query_args_and_nonce(
415
-                array('action' => 'registration_checkins', '_REG_ID' => $item->ID(), 'DTT_ID' => $DTT_ID),
416
-                REG_ADMIN_URL
417
-            );
418
-            // get the timestamps for this registration's checkins, related to the selected datetime
419
-            $timestamps = $item->get_many_related('Checkin', array(array('DTT_ID' => $DTT_ID)));
420
-            if (! empty($timestamps)) {
421
-                // get the last timestamp
422
-                $last_timestamp = end($timestamps);
423
-                // checked in or checked out?
424
-                $checkin_status = $last_timestamp->get('CHK_in')
425
-                    ? esc_html__('Checked In', 'event_espresso')
426
-                    : esc_html__('Checked Out', 'event_espresso');
427
-                // get timestamp string
428
-                $timestamp_string = $last_timestamp->get_datetime('CHK_timestamp');
429
-                $actions['checkin'] = '<a href="' . $checkin_list_url . '" title="'
430
-                                      . esc_attr__(
431
-                                          'View this registrant\'s check-ins/checkouts for the datetime',
432
-                                          'event_espresso'
433
-                                      ) . '">' . $checkin_status . ': ' . $timestamp_string . '</a>';
434
-            }
435
-        }
436
-        return (! empty($DTT_ID) && ! empty($timestamps))
437
-            ? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions, true))
438
-            : $name_link;
439
-    }
440
-
441
-
442
-    /**
443
-     * @param \EE_Registration $item
444
-     * @return string
445
-     */
446
-    public function column_ATT_email(EE_Registration $item)
447
-    {
448
-        $attendee = $item->attendee();
449
-        return $attendee instanceof EE_Attendee ? $attendee->email() : '';
450
-    }
451
-
452
-
453
-    /**
454
-     * @param \EE_Registration $item
455
-     * @return bool|string
456
-     * @throws \EE_Error
457
-     */
458
-    public function column_Event(EE_Registration $item)
459
-    {
460
-        try {
461
-            $event = $this->_evt instanceof EE_Event ? $this->_evt : $item->event();
462
-            $chkin_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
463
-                array('action' => 'event_registrations', 'event_id' => $event->ID()),
464
-                REG_ADMIN_URL
465
-            );
466
-            $event_label = EE_Registry::instance()->CAP->current_user_can(
467
-                'ee_read_checkins',
468
-                'espresso_registrations_registration_checkins'
469
-            ) ? '<a href="' . $chkin_lnk_url . '" title="'
470
-                . esc_attr__(
471
-                    'View Checkins for this Event',
472
-                    'event_espresso'
473
-                ) . '">' . $event->name() . '</a>' : $event->name();
474
-        } catch (\EventEspresso\core\exceptions\EntityNotFoundException $e) {
475
-            $event_label = esc_html__('Unknown', 'event_espresso');
476
-        }
477
-        return $event_label;
478
-    }
479
-
480
-
481
-    /**
482
-     * @param \EE_Registration $item
483
-     * @return mixed|string|void
484
-     */
485
-    public function column_PRC_name(EE_Registration $item)
486
-    {
487
-        return $item->ticket() instanceof EE_Ticket ? $item->ticket()->name() : __("Unknown", "event_espresso");
488
-    }
489
-
490
-
491
-    /**
492
-     * column_REG_final_price
493
-     *
494
-     * @param \EE_Registration $item
495
-     * @return string
496
-     */
497
-    public function column__REG_final_price(EE_Registration $item)
498
-    {
499
-        return '<span class="reg-pad-rght">' . ' ' . $item->pretty_final_price() . '</span>';
500
-    }
501
-
502
-
503
-    /**
504
-     * column_TXN_paid
505
-     *
506
-     * @param \EE_Registration $item
507
-     * @return string
508
-     * @throws \EE_Error
509
-     */
510
-    public function column_TXN_paid(EE_Registration $item)
511
-    {
512
-        if ($item->count() === 1) {
513
-            if ($item->transaction()->paid() >= $item->transaction()->total()) {
514
-                return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>';
515
-            } else {
516
-                $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
517
-                    array('action' => 'view_transaction', 'TXN_ID' => $item->transaction_ID()),
518
-                    TXN_ADMIN_URL
519
-                );
520
-                return EE_Registry::instance()->CAP->current_user_can(
521
-                    'ee_read_transaction',
522
-                    'espresso_transactions_view_transaction'
523
-                ) ? '
15
+	/**
16
+	 * This property will hold the related Datetimes on an event IF the event id is included in the request.
17
+	 *
18
+	 * @var EE_Datetime[]
19
+	 */
20
+	protected $_dtts_for_event = array();
21
+
22
+
23
+	/**
24
+	 * The event if one is specified in the request
25
+	 *
26
+	 * @var EE_Event
27
+	 */
28
+	protected $_evt = null;
29
+
30
+
31
+	/**
32
+	 * The DTT_ID if the current view has a specified datetime.
33
+	 *
34
+	 * @var int $_cur_dtt_id
35
+	 */
36
+	protected $_cur_dtt_id = 0;
37
+
38
+
39
+	/**
40
+	 * EE_Event_Registrations_List_Table constructor.
41
+	 *
42
+	 * @param \Registrations_Admin_Page $admin_page
43
+	 */
44
+	public function __construct($admin_page)
45
+	{
46
+		parent::__construct($admin_page);
47
+		$this->_status = $this->_admin_page->get_registration_status_array();
48
+	}
49
+
50
+
51
+	protected function _setup_data()
52
+	{
53
+		$this->_data = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees($this->_per_page)
54
+			: $this->_admin_page->get_event_attendees($this->_per_page, false, true);
55
+		$this->_all_data_count = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees(
56
+			$this->_per_page,
57
+			true
58
+		) : $this->_admin_page->get_event_attendees($this->_per_page, true, true);
59
+	}
60
+
61
+
62
+	protected function _set_properties()
63
+	{
64
+		$evt_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null;
65
+		$this->_wp_list_args = array(
66
+			'singular' => __('registrant', 'event_espresso'),
67
+			'plural'   => __('registrants', 'event_espresso'),
68
+			'ajax'     => true,
69
+			'screen'   => $this->_admin_page->get_current_screen()->id,
70
+		);
71
+		$columns = array();
72
+		// $columns['_Reg_Status'] = '';
73
+		$this->_columns = array(
74
+			'_REG_att_checked_in' => '<span class="dashicons dashicons-yes ee-icon-size-18"></span>',
75
+			'ATT_name'            => __('Registrant', 'event_espresso'),
76
+			'ATT_email'           => __('Email Address', 'event_espresso'),
77
+			'Event'               => __('Event', 'event_espresso'),
78
+			'PRC_name'            => __('TKT Option', 'event_espresso'),
79
+			'_REG_final_price'    => __('Price', 'event_espresso'),
80
+			'TXN_paid'            => __('Paid', 'event_espresso'),
81
+			'TXN_total'           => __('Total', 'event_espresso'),
82
+		);
83
+		// Add/remove columns when an event has been selected
84
+		if (! empty($evt_id)) {
85
+			// Render a checkbox column
86
+			$columns['cb'] = '<input type="checkbox" />';
87
+			$this->_has_checkbox_column = true;
88
+			// Remove the 'Event' column
89
+			unset($this->_columns['Event']);
90
+		}
91
+		$this->_columns = array_merge($columns, $this->_columns);
92
+		$this->_primary_column = '_REG_att_checked_in';
93
+		if (! empty($evt_id)
94
+			&& EE_Registry::instance()->CAP->current_user_can(
95
+				'ee_read_registrations',
96
+				'espresso_registrations_registrations_reports',
97
+				$evt_id
98
+			)
99
+		) {
100
+			$this->_bottom_buttons = array(
101
+				'report' => array(
102
+					'route'         => 'registrations_report',
103
+					'extra_request' =>
104
+						array(
105
+							'EVT_ID'     => $evt_id,
106
+							'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
107
+						),
108
+				),
109
+			);
110
+		}
111
+		$this->_bottom_buttons['report_filtered'] = array(
112
+			'route'         => 'registrations_checkin_report',
113
+			'extra_request' => array(
114
+				'use_filters' => true,
115
+				'filters'     => array_merge(
116
+					array(
117
+						'EVT_ID' => $evt_id,
118
+					),
119
+					array_diff_key(
120
+						$this->_req_data,
121
+						array_flip(
122
+							array(
123
+								'page',
124
+								'action',
125
+								'default_nonce',
126
+							)
127
+						)
128
+					)
129
+				),
130
+				'return_url'  => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
131
+			),
132
+		);
133
+		$this->_sortable_columns = array(
134
+			/**
135
+			 * Allows users to change the default sort if they wish.
136
+			 * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name.
137
+			 *
138
+			 * Note: usual naming conventions for filters aren't followed here so that just one filter can be used to
139
+			 * change the sorts on any list table involving registration contacts.  If you want to only change the filter
140
+			 * for a specific list table you can use the provided reference to this object instance.
141
+			 */
142
+			'ATT_name' => array(
143
+				'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
144
+				true,
145
+				$this,
146
+			)
147
+				? array('ATT_lname' => true)
148
+				: array('ATT_fname' => true),
149
+			'Event'    => array('Event.EVT_name' => false),
150
+		);
151
+		$this->_hidden_columns = array();
152
+		$this->_evt = EEM_Event::instance()->get_one_by_ID($evt_id);
153
+		$this->_dtts_for_event = $this->_evt instanceof EE_Event ? $this->_evt->datetimes_ordered() : array();
154
+	}
155
+
156
+
157
+	/**
158
+	 * @param \EE_Registration $item
159
+	 * @return string
160
+	 */
161
+	protected function _get_row_class($item)
162
+	{
163
+		$class = parent::_get_row_class($item);
164
+		// add status class
165
+		$class .= ' ee-status-strip reg-status-' . $item->status_ID();
166
+		if ($this->_has_checkbox_column) {
167
+			$class .= ' has-checkbox-column';
168
+		}
169
+		return $class;
170
+	}
171
+
172
+
173
+	/**
174
+	 * @return array
175
+	 * @throws \EE_Error
176
+	 */
177
+	protected function _get_table_filters()
178
+	{
179
+		$filters = $where = array();
180
+		$current_EVT_ID = isset($this->_req_data['event_id']) ? (int) $this->_req_data['event_id'] : 0;
181
+		if (empty($this->_dtts_for_event) || count($this->_dtts_for_event) === 1) {
182
+			// this means we don't have an event so let's setup a filter dropdown for all the events to select
183
+			// note possible capability restrictions
184
+			if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
185
+				$where['status**'] = array('!=', 'private');
186
+			}
187
+			if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
188
+				$where['EVT_wp_user'] = get_current_user_id();
189
+			}
190
+			$events = EEM_Event::instance()->get_all(
191
+				array(
192
+					$where,
193
+					'order_by' => array('Datetime.DTT_EVT_start' => 'DESC'),
194
+				)
195
+			);
196
+			$evts[] = array(
197
+				'id'   => 0,
198
+				'text' => __('To toggle Check-in status, select an event', 'event_espresso'),
199
+			);
200
+			$checked = 'checked';
201
+			/** @var EE_Event $evt */
202
+			foreach ($events as $evt) {
203
+				// any registrations for this event?
204
+				if (! $evt->get_count_of_all_registrations()) {
205
+					continue;
206
+				}
207
+				$evts[] = array(
208
+					'id'    => $evt->ID(),
209
+					'text'  => apply_filters(
210
+						'FHEE__EE_Event_Registrations___get_table_filters__event_name',
211
+						$evt->get('EVT_name'),
212
+						$evt
213
+					),
214
+					'class' => $evt->is_expired() ? 'ee-expired-event' : '',
215
+				);
216
+				if ($evt->ID() === $current_EVT_ID && $evt->is_expired()) {
217
+					$checked = '';
218
+				}
219
+			}
220
+			$event_filter = '<div class="ee-event-filter">';
221
+			$event_filter .= EEH_Form_Fields::select_input('event_id', $evts, $current_EVT_ID);
222
+			$event_filter .= '<span class="ee-event-filter-toggle">';
223
+			$event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" ' . $checked . '> ';
224
+			$event_filter .= __('Hide Expired Events', 'event_espresso');
225
+			$event_filter .= '</span>';
226
+			$event_filter .= '</div>';
227
+			$filters[] = $event_filter;
228
+		}
229
+		if (! empty($this->_dtts_for_event)) {
230
+			// DTT datetimes filter
231
+			$this->_cur_dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0;
232
+			if (count($this->_dtts_for_event) > 1) {
233
+				$dtts[0] = __('To toggle check-in status, select a datetime.', 'event_espresso');
234
+				foreach ($this->_dtts_for_event as $dtt) {
235
+					$datetime_string = $dtt->name();
236
+					$datetime_string = ! empty($datetime_string) ? ' (' . $datetime_string . ')' : '';
237
+					$datetime_string = $dtt->start_date_and_time() . ' - ' . $dtt->end_date_and_time() . $datetime_string;
238
+					$dtts[ $dtt->ID() ] = $datetime_string;
239
+				}
240
+				$input = new EE_Select_Input(
241
+					$dtts,
242
+					array(
243
+						'html_name' => 'DTT_ID',
244
+						'html_id'   => 'DTT_ID',
245
+						'default'   => $this->_cur_dtt_id,
246
+					)
247
+				);
248
+				$filters[] = $input->get_html_for_input();
249
+				$filters[] = '<input type="hidden" name="event_id" value="' . $current_EVT_ID . '">';
250
+			}
251
+		}
252
+		return $filters;
253
+	}
254
+
255
+
256
+	protected function _add_view_counts()
257
+	{
258
+		$this->_views['all']['count'] = $this->_get_total_event_attendees();
259
+	}
260
+
261
+
262
+	/**
263
+	 * @return int
264
+	 * @throws \EE_Error
265
+	 */
266
+	protected function _get_total_event_attendees()
267
+	{
268
+		$EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
269
+		$DTT_ID = $this->_cur_dtt_id;
270
+		$query_params = array();
271
+		if ($EVT_ID) {
272
+			$query_params[0]['EVT_ID'] = $EVT_ID;
273
+		}
274
+		// if DTT is included we only show for that datetime.  Otherwise we're showing for all datetimes (the event).
275
+		if ($DTT_ID) {
276
+			$query_params[0]['Ticket.Datetime.DTT_ID'] = $DTT_ID;
277
+		}
278
+		$status_ids_array = apply_filters(
279
+			'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
280
+			array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved)
281
+		);
282
+		$query_params[0]['STS_ID'] = array('IN', $status_ids_array);
283
+		return EEM_Registration::instance()->count($query_params);
284
+	}
285
+
286
+
287
+	/**
288
+	 * @param \EE_Registration $item
289
+	 * @return string
290
+	 */
291
+	public function column__Reg_Status(EE_Registration $item)
292
+	{
293
+		return '<span class="ee-status-strip ee-status-strip-td reg-status-' . $item->status_ID() . '"></span>';
294
+	}
295
+
296
+
297
+	/**
298
+	 * @param \EE_Registration $item
299
+	 * @return string
300
+	 * @throws \EE_Error
301
+	 */
302
+	public function column_cb($item)
303
+	{
304
+		return sprintf('<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID());
305
+	}
306
+
307
+
308
+	/**
309
+	 * column_REG_att_checked_in
310
+	 *
311
+	 * @param EE_Registration $item
312
+	 * @return string
313
+	 * @throws EE_Error
314
+	 * @throws InvalidArgumentException
315
+	 * @throws InvalidDataTypeException
316
+	 * @throws InvalidInterfaceException
317
+	 */
318
+	public function column__REG_att_checked_in(EE_Registration $item)
319
+	{
320
+		$attendee = $item->attendee();
321
+		$attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
322
+
323
+		if ($this->_cur_dtt_id === 0 && count($this->_dtts_for_event) === 1) {
324
+			$latest_related_datetime = $item->get_latest_related_datetime();
325
+			if ($latest_related_datetime instanceof EE_Datetime) {
326
+				$this->_cur_dtt_id = $latest_related_datetime->ID();
327
+			}
328
+		}
329
+		$checkin_status_dashicon = CheckinStatusDashicon::fromRegistrationAndDatetimeId(
330
+			$item,
331
+			$this->_cur_dtt_id
332
+		);
333
+		$nonce = wp_create_nonce('checkin_nonce');
334
+		$toggle_active = ! empty($this->_cur_dtt_id)
335
+						 && EE_Registry::instance()->CAP->current_user_can(
336
+							 'ee_edit_checkin',
337
+							 'espresso_registrations_toggle_checkin_status',
338
+							 $item->ID()
339
+						 )
340
+			? ' clickable trigger-checkin'
341
+			: '';
342
+		$mobile_view_content = ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>';
343
+		return '<span class="' . $checkin_status_dashicon->cssClasses() . $toggle_active . '"'
344
+			   . ' data-_regid="' . $item->ID() . '"'
345
+			   . ' data-dttid="' . $this->_cur_dtt_id . '"'
346
+			   . ' data-nonce="' . $nonce . '">'
347
+			   . '</span>'
348
+			   . $mobile_view_content;
349
+	}
350
+
351
+
352
+	/**
353
+	 * @param \EE_Registration $item
354
+	 * @return mixed|string|void
355
+	 * @throws \EE_Error
356
+	 */
357
+	public function column_ATT_name(EE_Registration $item)
358
+	{
359
+		$attendee = $item->attendee();
360
+		if (! $attendee instanceof EE_Attendee) {
361
+			return __('No contact record for this registration.', 'event_espresso');
362
+		}
363
+		// edit attendee link
364
+		$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
365
+			array('action' => 'view_registration', '_REG_ID' => $item->ID()),
366
+			REG_ADMIN_URL
367
+		);
368
+		$name_link = EE_Registry::instance()->CAP->current_user_can(
369
+			'ee_edit_contacts',
370
+			'espresso_registrations_edit_attendee'
371
+		)
372
+			? '<a href="' . $edit_lnk_url . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '">'
373
+			  . $item->attendee()->full_name()
374
+			  . '</a>'
375
+			: $item->attendee()->full_name();
376
+		$name_link .= $item->count() === 1
377
+			? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>	'
378
+			: '';
379
+		// add group details
380
+		$name_link .= '&nbsp;' . sprintf(__('(%s of %s)', 'event_espresso'), $item->count(), $item->group_size());
381
+		// add regcode
382
+		$link = EE_Admin_Page::add_query_args_and_nonce(
383
+			array('action' => 'view_registration', '_REG_ID' => $item->ID()),
384
+			REG_ADMIN_URL
385
+		);
386
+		$name_link .= '<br>';
387
+		$name_link .= EE_Registry::instance()->instance()->CAP->current_user_can(
388
+			'ee_read_registration',
389
+			'view_registration',
390
+			$item->ID()
391
+		)
392
+			? '<a href="' . $link . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '">'
393
+			  . $item->reg_code()
394
+			  . '</a>'
395
+			: $item->reg_code();
396
+		// status
397
+		$name_link .= '<br><span class="ee-status-text-small">';
398
+		$name_link .= EEH_Template::pretty_status($item->status_ID(), false, 'sentence');
399
+		$name_link .= '</span>';
400
+		$actions = array();
401
+		$DTT_ID = $this->_cur_dtt_id;
402
+		$latest_related_datetime = empty($DTT_ID) && ! empty($this->_req_data['event_id']) && $item instanceof EE_Registration
403
+			? $item->get_latest_related_datetime()
404
+			: null;
405
+		$DTT_ID = $latest_related_datetime instanceof EE_Datetime
406
+			? $latest_related_datetime->ID()
407
+			: $DTT_ID;
408
+		if (! empty($DTT_ID)
409
+			&& EE_Registry::instance()->CAP->current_user_can(
410
+				'ee_read_checkins',
411
+				'espresso_registrations_registration_checkins'
412
+			)
413
+		) {
414
+			$checkin_list_url = EE_Admin_Page::add_query_args_and_nonce(
415
+				array('action' => 'registration_checkins', '_REG_ID' => $item->ID(), 'DTT_ID' => $DTT_ID),
416
+				REG_ADMIN_URL
417
+			);
418
+			// get the timestamps for this registration's checkins, related to the selected datetime
419
+			$timestamps = $item->get_many_related('Checkin', array(array('DTT_ID' => $DTT_ID)));
420
+			if (! empty($timestamps)) {
421
+				// get the last timestamp
422
+				$last_timestamp = end($timestamps);
423
+				// checked in or checked out?
424
+				$checkin_status = $last_timestamp->get('CHK_in')
425
+					? esc_html__('Checked In', 'event_espresso')
426
+					: esc_html__('Checked Out', 'event_espresso');
427
+				// get timestamp string
428
+				$timestamp_string = $last_timestamp->get_datetime('CHK_timestamp');
429
+				$actions['checkin'] = '<a href="' . $checkin_list_url . '" title="'
430
+									  . esc_attr__(
431
+										  'View this registrant\'s check-ins/checkouts for the datetime',
432
+										  'event_espresso'
433
+									  ) . '">' . $checkin_status . ': ' . $timestamp_string . '</a>';
434
+			}
435
+		}
436
+		return (! empty($DTT_ID) && ! empty($timestamps))
437
+			? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions, true))
438
+			: $name_link;
439
+	}
440
+
441
+
442
+	/**
443
+	 * @param \EE_Registration $item
444
+	 * @return string
445
+	 */
446
+	public function column_ATT_email(EE_Registration $item)
447
+	{
448
+		$attendee = $item->attendee();
449
+		return $attendee instanceof EE_Attendee ? $attendee->email() : '';
450
+	}
451
+
452
+
453
+	/**
454
+	 * @param \EE_Registration $item
455
+	 * @return bool|string
456
+	 * @throws \EE_Error
457
+	 */
458
+	public function column_Event(EE_Registration $item)
459
+	{
460
+		try {
461
+			$event = $this->_evt instanceof EE_Event ? $this->_evt : $item->event();
462
+			$chkin_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
463
+				array('action' => 'event_registrations', 'event_id' => $event->ID()),
464
+				REG_ADMIN_URL
465
+			);
466
+			$event_label = EE_Registry::instance()->CAP->current_user_can(
467
+				'ee_read_checkins',
468
+				'espresso_registrations_registration_checkins'
469
+			) ? '<a href="' . $chkin_lnk_url . '" title="'
470
+				. esc_attr__(
471
+					'View Checkins for this Event',
472
+					'event_espresso'
473
+				) . '">' . $event->name() . '</a>' : $event->name();
474
+		} catch (\EventEspresso\core\exceptions\EntityNotFoundException $e) {
475
+			$event_label = esc_html__('Unknown', 'event_espresso');
476
+		}
477
+		return $event_label;
478
+	}
479
+
480
+
481
+	/**
482
+	 * @param \EE_Registration $item
483
+	 * @return mixed|string|void
484
+	 */
485
+	public function column_PRC_name(EE_Registration $item)
486
+	{
487
+		return $item->ticket() instanceof EE_Ticket ? $item->ticket()->name() : __("Unknown", "event_espresso");
488
+	}
489
+
490
+
491
+	/**
492
+	 * column_REG_final_price
493
+	 *
494
+	 * @param \EE_Registration $item
495
+	 * @return string
496
+	 */
497
+	public function column__REG_final_price(EE_Registration $item)
498
+	{
499
+		return '<span class="reg-pad-rght">' . ' ' . $item->pretty_final_price() . '</span>';
500
+	}
501
+
502
+
503
+	/**
504
+	 * column_TXN_paid
505
+	 *
506
+	 * @param \EE_Registration $item
507
+	 * @return string
508
+	 * @throws \EE_Error
509
+	 */
510
+	public function column_TXN_paid(EE_Registration $item)
511
+	{
512
+		if ($item->count() === 1) {
513
+			if ($item->transaction()->paid() >= $item->transaction()->total()) {
514
+				return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>';
515
+			} else {
516
+				$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
517
+					array('action' => 'view_transaction', 'TXN_ID' => $item->transaction_ID()),
518
+					TXN_ADMIN_URL
519
+				);
520
+				return EE_Registry::instance()->CAP->current_user_can(
521
+					'ee_read_transaction',
522
+					'espresso_transactions_view_transaction'
523
+				) ? '
524 524
 				<span class="reg-pad-rght">
525 525
 					<a class="status-'
526
-                    . $item->transaction()->status_ID()
527
-                    . '" href="'
528
-                    . $view_txn_lnk_url
529
-                    . '"  title="'
530
-                    . esc_attr__('View Transaction', 'event_espresso')
531
-                    . '">
526
+					. $item->transaction()->status_ID()
527
+					. '" href="'
528
+					. $view_txn_lnk_url
529
+					. '"  title="'
530
+					. esc_attr__('View Transaction', 'event_espresso')
531
+					. '">
532 532
 						'
533
-                    . $item->transaction()->pretty_paid()
534
-                    . '
533
+					. $item->transaction()->pretty_paid()
534
+					. '
535 535
 					</a>
536 536
 				<span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
537
-            }
538
-        } else {
539
-            return '<span class="reg-pad-rght"></span>';
540
-        }
541
-    }
542
-
543
-
544
-    /**
545
-     *        column_TXN_total
546
-     *
547
-     * @param \EE_Registration $item
548
-     * @return string
549
-     * @throws \EE_Error
550
-     */
551
-    public function column_TXN_total(EE_Registration $item)
552
-    {
553
-        $txn = $item->transaction();
554
-        $view_txn_url = add_query_arg(array('action' => 'view_transaction', 'TXN_ID' => $txn->ID()), TXN_ADMIN_URL);
555
-        if ($item->get('REG_count') === 1) {
556
-            $line_total_obj = $txn->total_line_item();
557
-            $txn_total = $line_total_obj instanceof EE_Line_Item
558
-                ? $line_total_obj->get_pretty('LIN_total')
559
-                : __(
560
-                    'View Transaction',
561
-                    'event_espresso'
562
-                );
563
-            return EE_Registry::instance()->CAP->current_user_can(
564
-                'ee_read_transaction',
565
-                'espresso_transactions_view_transaction'
566
-            ) ? '<a href="'
567
-                . $view_txn_url
568
-                . '" title="'
569
-                . esc_attr__('View Transaction', 'event_espresso')
570
-                . '"><span class="reg-pad-rght">'
571
-                . $txn_total
572
-                . '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>';
573
-        } else {
574
-            return '<span class="reg-pad-rght"></span>';
575
-        }
576
-    }
537
+			}
538
+		} else {
539
+			return '<span class="reg-pad-rght"></span>';
540
+		}
541
+	}
542
+
543
+
544
+	/**
545
+	 *        column_TXN_total
546
+	 *
547
+	 * @param \EE_Registration $item
548
+	 * @return string
549
+	 * @throws \EE_Error
550
+	 */
551
+	public function column_TXN_total(EE_Registration $item)
552
+	{
553
+		$txn = $item->transaction();
554
+		$view_txn_url = add_query_arg(array('action' => 'view_transaction', 'TXN_ID' => $txn->ID()), TXN_ADMIN_URL);
555
+		if ($item->get('REG_count') === 1) {
556
+			$line_total_obj = $txn->total_line_item();
557
+			$txn_total = $line_total_obj instanceof EE_Line_Item
558
+				? $line_total_obj->get_pretty('LIN_total')
559
+				: __(
560
+					'View Transaction',
561
+					'event_espresso'
562
+				);
563
+			return EE_Registry::instance()->CAP->current_user_can(
564
+				'ee_read_transaction',
565
+				'espresso_transactions_view_transaction'
566
+			) ? '<a href="'
567
+				. $view_txn_url
568
+				. '" title="'
569
+				. esc_attr__('View Transaction', 'event_espresso')
570
+				. '"><span class="reg-pad-rght">'
571
+				. $txn_total
572
+				. '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>';
573
+		} else {
574
+			return '<span class="reg-pad-rght"></span>';
575
+		}
576
+	}
577 577
 }
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
             'TXN_total'           => __('Total', 'event_espresso'),
82 82
         );
83 83
         // Add/remove columns when an event has been selected
84
-        if (! empty($evt_id)) {
84
+        if ( ! empty($evt_id)) {
85 85
             // Render a checkbox column
86 86
             $columns['cb'] = '<input type="checkbox" />';
87 87
             $this->_has_checkbox_column = true;
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
         }
91 91
         $this->_columns = array_merge($columns, $this->_columns);
92 92
         $this->_primary_column = '_REG_att_checked_in';
93
-        if (! empty($evt_id)
93
+        if ( ! empty($evt_id)
94 94
             && EE_Registry::instance()->CAP->current_user_can(
95 95
                 'ee_read_registrations',
96 96
                 'espresso_registrations_registrations_reports',
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
     {
163 163
         $class = parent::_get_row_class($item);
164 164
         // add status class
165
-        $class .= ' ee-status-strip reg-status-' . $item->status_ID();
165
+        $class .= ' ee-status-strip reg-status-'.$item->status_ID();
166 166
         if ($this->_has_checkbox_column) {
167 167
             $class .= ' has-checkbox-column';
168 168
         }
@@ -181,10 +181,10 @@  discard block
 block discarded – undo
181 181
         if (empty($this->_dtts_for_event) || count($this->_dtts_for_event) === 1) {
182 182
             // this means we don't have an event so let's setup a filter dropdown for all the events to select
183 183
             // note possible capability restrictions
184
-            if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
184
+            if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
185 185
                 $where['status**'] = array('!=', 'private');
186 186
             }
187
-            if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
187
+            if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
188 188
                 $where['EVT_wp_user'] = get_current_user_id();
189 189
             }
190 190
             $events = EEM_Event::instance()->get_all(
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
             /** @var EE_Event $evt */
202 202
             foreach ($events as $evt) {
203 203
                 // any registrations for this event?
204
-                if (! $evt->get_count_of_all_registrations()) {
204
+                if ( ! $evt->get_count_of_all_registrations()) {
205 205
                     continue;
206 206
                 }
207 207
                 $evts[] = array(
@@ -220,22 +220,22 @@  discard block
 block discarded – undo
220 220
             $event_filter = '<div class="ee-event-filter">';
221 221
             $event_filter .= EEH_Form_Fields::select_input('event_id', $evts, $current_EVT_ID);
222 222
             $event_filter .= '<span class="ee-event-filter-toggle">';
223
-            $event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" ' . $checked . '> ';
223
+            $event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" '.$checked.'> ';
224 224
             $event_filter .= __('Hide Expired Events', 'event_espresso');
225 225
             $event_filter .= '</span>';
226 226
             $event_filter .= '</div>';
227 227
             $filters[] = $event_filter;
228 228
         }
229
-        if (! empty($this->_dtts_for_event)) {
229
+        if ( ! empty($this->_dtts_for_event)) {
230 230
             // DTT datetimes filter
231 231
             $this->_cur_dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0;
232 232
             if (count($this->_dtts_for_event) > 1) {
233 233
                 $dtts[0] = __('To toggle check-in status, select a datetime.', 'event_espresso');
234 234
                 foreach ($this->_dtts_for_event as $dtt) {
235 235
                     $datetime_string = $dtt->name();
236
-                    $datetime_string = ! empty($datetime_string) ? ' (' . $datetime_string . ')' : '';
237
-                    $datetime_string = $dtt->start_date_and_time() . ' - ' . $dtt->end_date_and_time() . $datetime_string;
238
-                    $dtts[ $dtt->ID() ] = $datetime_string;
236
+                    $datetime_string = ! empty($datetime_string) ? ' ('.$datetime_string.')' : '';
237
+                    $datetime_string = $dtt->start_date_and_time().' - '.$dtt->end_date_and_time().$datetime_string;
238
+                    $dtts[$dtt->ID()] = $datetime_string;
239 239
                 }
240 240
                 $input = new EE_Select_Input(
241 241
                     $dtts,
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
                     )
247 247
                 );
248 248
                 $filters[] = $input->get_html_for_input();
249
-                $filters[] = '<input type="hidden" name="event_id" value="' . $current_EVT_ID . '">';
249
+                $filters[] = '<input type="hidden" name="event_id" value="'.$current_EVT_ID.'">';
250 250
             }
251 251
         }
252 252
         return $filters;
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
      */
291 291
     public function column__Reg_Status(EE_Registration $item)
292 292
     {
293
-        return '<span class="ee-status-strip ee-status-strip-td reg-status-' . $item->status_ID() . '"></span>';
293
+        return '<span class="ee-status-strip ee-status-strip-td reg-status-'.$item->status_ID().'"></span>';
294 294
     }
295 295
 
296 296
 
@@ -339,11 +339,11 @@  discard block
 block discarded – undo
339 339
                          )
340 340
             ? ' clickable trigger-checkin'
341 341
             : '';
342
-        $mobile_view_content = ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>';
343
-        return '<span class="' . $checkin_status_dashicon->cssClasses() . $toggle_active . '"'
344
-               . ' data-_regid="' . $item->ID() . '"'
345
-               . ' data-dttid="' . $this->_cur_dtt_id . '"'
346
-               . ' data-nonce="' . $nonce . '">'
342
+        $mobile_view_content = ' <span class="show-on-mobile-view-only">'.$attendee_name.'</span>';
343
+        return '<span class="'.$checkin_status_dashicon->cssClasses().$toggle_active.'"'
344
+               . ' data-_regid="'.$item->ID().'"'
345
+               . ' data-dttid="'.$this->_cur_dtt_id.'"'
346
+               . ' data-nonce="'.$nonce.'">'
347 347
                . '</span>'
348 348
                . $mobile_view_content;
349 349
     }
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
     public function column_ATT_name(EE_Registration $item)
358 358
     {
359 359
         $attendee = $item->attendee();
360
-        if (! $attendee instanceof EE_Attendee) {
360
+        if ( ! $attendee instanceof EE_Attendee) {
361 361
             return __('No contact record for this registration.', 'event_espresso');
362 362
         }
363 363
         // edit attendee link
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
             'ee_edit_contacts',
370 370
             'espresso_registrations_edit_attendee'
371 371
         )
372
-            ? '<a href="' . $edit_lnk_url . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '">'
372
+            ? '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'">'
373 373
               . $item->attendee()->full_name()
374 374
               . '</a>'
375 375
             : $item->attendee()->full_name();
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
             ? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>	'
378 378
             : '';
379 379
         // add group details
380
-        $name_link .= '&nbsp;' . sprintf(__('(%s of %s)', 'event_espresso'), $item->count(), $item->group_size());
380
+        $name_link .= '&nbsp;'.sprintf(__('(%s of %s)', 'event_espresso'), $item->count(), $item->group_size());
381 381
         // add regcode
382 382
         $link = EE_Admin_Page::add_query_args_and_nonce(
383 383
             array('action' => 'view_registration', '_REG_ID' => $item->ID()),
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
             'view_registration',
390 390
             $item->ID()
391 391
         )
392
-            ? '<a href="' . $link . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '">'
392
+            ? '<a href="'.$link.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'">'
393 393
               . $item->reg_code()
394 394
               . '</a>'
395 395
             : $item->reg_code();
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
         $DTT_ID = $latest_related_datetime instanceof EE_Datetime
406 406
             ? $latest_related_datetime->ID()
407 407
             : $DTT_ID;
408
-        if (! empty($DTT_ID)
408
+        if ( ! empty($DTT_ID)
409 409
             && EE_Registry::instance()->CAP->current_user_can(
410 410
                 'ee_read_checkins',
411 411
                 'espresso_registrations_registration_checkins'
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
             );
418 418
             // get the timestamps for this registration's checkins, related to the selected datetime
419 419
             $timestamps = $item->get_many_related('Checkin', array(array('DTT_ID' => $DTT_ID)));
420
-            if (! empty($timestamps)) {
420
+            if ( ! empty($timestamps)) {
421 421
                 // get the last timestamp
422 422
                 $last_timestamp = end($timestamps);
423 423
                 // checked in or checked out?
@@ -426,14 +426,14 @@  discard block
 block discarded – undo
426 426
                     : esc_html__('Checked Out', 'event_espresso');
427 427
                 // get timestamp string
428 428
                 $timestamp_string = $last_timestamp->get_datetime('CHK_timestamp');
429
-                $actions['checkin'] = '<a href="' . $checkin_list_url . '" title="'
429
+                $actions['checkin'] = '<a href="'.$checkin_list_url.'" title="'
430 430
                                       . esc_attr__(
431 431
                                           'View this registrant\'s check-ins/checkouts for the datetime',
432 432
                                           'event_espresso'
433
-                                      ) . '">' . $checkin_status . ': ' . $timestamp_string . '</a>';
433
+                                      ).'">'.$checkin_status.': '.$timestamp_string.'</a>';
434 434
             }
435 435
         }
436
-        return (! empty($DTT_ID) && ! empty($timestamps))
436
+        return ( ! empty($DTT_ID) && ! empty($timestamps))
437 437
             ? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions, true))
438 438
             : $name_link;
439 439
     }
@@ -466,11 +466,11 @@  discard block
 block discarded – undo
466 466
             $event_label = EE_Registry::instance()->CAP->current_user_can(
467 467
                 'ee_read_checkins',
468 468
                 'espresso_registrations_registration_checkins'
469
-            ) ? '<a href="' . $chkin_lnk_url . '" title="'
469
+            ) ? '<a href="'.$chkin_lnk_url.'" title="'
470 470
                 . esc_attr__(
471 471
                     'View Checkins for this Event',
472 472
                     'event_espresso'
473
-                ) . '">' . $event->name() . '</a>' : $event->name();
473
+                ).'">'.$event->name().'</a>' : $event->name();
474 474
         } catch (\EventEspresso\core\exceptions\EntityNotFoundException $e) {
475 475
             $event_label = esc_html__('Unknown', 'event_espresso');
476 476
         }
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
      */
497 497
     public function column__REG_final_price(EE_Registration $item)
498 498
     {
499
-        return '<span class="reg-pad-rght">' . ' ' . $item->pretty_final_price() . '</span>';
499
+        return '<span class="reg-pad-rght">'.' '.$item->pretty_final_price().'</span>';
500 500
     }
501 501
 
502 502
 
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
                     . $item->transaction()->pretty_paid()
534 534
                     . '
535 535
 					</a>
536
-				<span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
536
+				<span>' : '<span class="reg-pad-rght">'.$item->transaction()->pretty_paid().'</span>';
537 537
             }
538 538
         } else {
539 539
             return '<span class="reg-pad-rght"></span>';
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
                 . esc_attr__('View Transaction', 'event_espresso')
570 570
                 . '"><span class="reg-pad-rght">'
571 571
                 . $txn_total
572
-                . '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>';
572
+                . '</span></a>' : '<span class="reg-pad-rght">'.$txn_total.'</span>';
573 573
         } else {
574 574
             return '<span class="reg-pad-rght"></span>';
575 575
         }
Please login to merge, or discard this patch.
core/templates/json_linked_data_for_event.template.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -26,8 +26,8 @@  discard block
 block discarded – undo
26 26
   "eventStatus": "https://schema.org/<?php echo $event_status; ?>",
27 27
   "offers": [
28 28
     <?php
29
-    $i = 0;
30
-    foreach ($event_tickets as $ticket) {?>
29
+	$i = 0;
30
+	foreach ($event_tickets as $ticket) {?>
31 31
     {
32 32
       "@type": "Offer",
33 33
       "url": "<?php echo $event_permalink; ?>",
@@ -36,18 +36,18 @@  discard block
 block discarded – undo
36 36
       "price": "<?php echo $ticket['price']; ?>",
37 37
       "priceCurrency": "<?php echo $currency; ?>"
38 38
         <?php if (isset($ticket['availability'])) {
39
-            ?>,"availability": "http://schema.org/<?php echo $ticket['availability']; ?>"
39
+			?>,"availability": "http://schema.org/<?php echo $ticket['availability']; ?>"
40 40
         <?php } ?>
41 41
     }<?php
42
-    $i++;
43
-    if ($i < count($event_tickets)) {
44
-        echo ',';
45
-    }
46
-    }
47
-    ?>
42
+	$i++;
43
+	if ($i < count($event_tickets)) {
44
+		echo ',';
45
+	}
46
+	}
47
+	?>
48 48
     ]<?php
49
-    if ($venue_name) {
50
-        ?>,
49
+	if ($venue_name) {
50
+		?>,
51 51
   "location": {
52 52
     "@type": "Place",
53 53
     "name": <?php echo wp_json_encode($venue_name); ?>,
@@ -60,13 +60,13 @@  discard block
 block discarded – undo
60 60
     }
61 61
   }
62 62
     <?php
63
-    } ?>
63
+	} ?>
64 64
     <?php
65
-    if ($event_image) {
66
-        ?>,
65
+	if ($event_image) {
66
+		?>,
67 67
   "image": "<?php echo $event_image; ?>"
68 68
     <?php
69
-    } ?>
69
+	} ?>
70 70
     <?php do_action('AHEE__json_linked_data_for_event__template'); ?>
71 71
 }
72 72
 
Please login to merge, or discard this patch.
core/helpers/EEH_Schema.helper.php 1 patch
Indentation   +292 added lines, -292 removed lines patch added patch discarded remove patch
@@ -12,296 +12,296 @@
 block discarded – undo
12 12
 {
13 13
 
14 14
 
15
-    /**
16
-     * generates JSON-based linked data for an event
17
-     *
18
-     * @param EE_Event $event
19
-     * @throws EE_Error
20
-     */
21
-    public static function add_json_linked_data_for_event(EE_Event $event)
22
-    {
23
-        // Check we have a valid datetime for the event
24
-        if (! $event->primary_datetime() instanceof EE_Datetime) {
25
-            return;
26
-        }
27
-
28
-        $template_args = array(
29
-            'event_permalink' => '',
30
-            'event_name' => '',
31
-            'event_description' => '',
32
-            'event_start' => '',
33
-            'event_end' => '',
34
-            'event_attendance_mode' => '',
35
-            'event_status' => '',
36
-            'currency' => '',
37
-            'event_tickets' => array(),
38
-            'venue_name' => '',
39
-            'venue_url' => '',
40
-            'venue_locality' => '',
41
-            'venue_region' => '',
42
-            'venue_address' => '',
43
-            'event_image' => '',
44
-        );
45
-        $template_args['event_permalink'] = $event->get_permalink();
46
-        $template_args['event_name'] = $event->name();
47
-        $template_args['event_description'] = wp_strip_all_tags($event->short_description(200));
48
-        // clone datetime so that date formats don't override those for the original datetime
49
-        $primary_datetime = clone $event->primary_datetime();
50
-        $template_args['event_start'] = $primary_datetime->start_date(DateTime::ATOM);
51
-        $template_args['event_end'] = $primary_datetime->end_date(DateTime::ATOM);
52
-        unset($primary_datetime);
53
-        switch ($event->status()) {
54
-            case EEM_Event::cancelled:
55
-                $event_status = 'EventCancelled';
56
-                break;
57
-            case EEM_Event::postponed:
58
-                $event_status = 'EventPostponed';
59
-                break;
60
-            default:
61
-                $event_status = 'EventScheduled';
62
-        }
63
-        $template_args['event_attendance_mode'] = 'OfflineEventAttendanceMode';
64
-        $template_args['event_status'] = $event_status;
65
-        $template_args['currency'] = EE_Registry::instance()->CFG->currency->code;
66
-        foreach ($event->tickets() as $original_ticket) {
67
-            // clone tickets so that date formats don't override those for the original ticket
68
-            $ticket= clone $original_ticket;
69
-            $ID = $ticket->ID();
70
-            $template_args['event_tickets'][ $ID ]['start_date'] = $ticket->start_date(DateTime::ATOM, null);
71
-            $template_args['event_tickets'][ $ID ]['end_date'] = $ticket->end_date(DateTime::ATOM, null);
72
-            $template_args['event_tickets'][ $ID ]['price'] = number_format(
73
-                $ticket->price(),
74
-                EE_Registry::instance()->CFG->currency->dec_plc,
75
-                EE_Registry::instance()->CFG->currency->dec_mrk,
76
-                ''
77
-            );
78
-            switch ($ticket->ticket_status()) {
79
-                case 'TKO':
80
-                    $availability = 'InStock';
81
-                    break;
82
-                case 'TKS':
83
-                    $availability = 'SoldOut';
84
-                    break;
85
-                default:
86
-                    $availability = null;
87
-                    break;
88
-            }
89
-            $template_args['event_tickets'][ $ID ]['availability'] = $availability;
90
-            unset($ticket);
91
-        }
92
-        $VNU_ID = espresso_venue_id();
93
-        if (! empty($VNU_ID) && ! espresso_is_venue_private($VNU_ID)) {
94
-            $venue = EEH_Venue_View::get_venue($VNU_ID);
95
-            $template_args['venue_name'] = get_the_title($VNU_ID);
96
-            $template_args['venue_url'] = get_permalink($VNU_ID);
97
-            $template_args['venue_locality'] = $venue->city();
98
-            $template_args['venue_region'] = $venue->state_name();
99
-            $template_args['venue_address'] = $venue->address();
100
-            if ($venue->virtual_url() !== '') {
101
-                $template_args['event_attendance_mode'] = 'OnlineEventAttendanceMode';
102
-            }
103
-            if ($venue->virtual_url() !== '' && $venue->address() !== '') {
104
-                $template_args['event_attendance_mode'] = 'MixedEventAttendanceMode';
105
-            }
106
-        }
107
-        $template_args['event_image'] = $event->feature_image_url();
108
-        $template_args = apply_filters(
109
-            'FHEE__EEH_Schema__add_json_linked_data_for_event__template_args',
110
-            $template_args,
111
-            $event,
112
-            $VNU_ID
113
-        );
114
-        extract($template_args, EXTR_OVERWRITE);
115
-        include EE_TEMPLATES . 'json_linked_data_for_event.template.php';
116
-    }
117
-
118
-
119
-    /**
120
-     *    location
121
-     *    The location of the event, organization or action.
122
-     *    Should include the Venue name AND schema formatted address info
123
-     *
124
-     * @access public
125
-     * @param string $location
126
-     * @return string
127
-     */
128
-    public static function location($location = null)
129
-    {
130
-        return ! empty($location) ? '<div itemprop="location" itemscope itemtype="http://schema.org/Place">'
131
-                                      . $location
132
-                                      . '</div>' : '';
133
-    }
134
-
135
-
136
-
137
-    /**
138
-     *    name
139
-     *    The name of the Event or Venue.
140
-     *
141
-     * @access public
142
-     * @param string $name
143
-     * @return string
144
-     */
145
-    public static function name($name = null)
146
-    {
147
-        return ! empty($name) ? '<span itemprop="name">' . $name . '</span>' : '';
148
-    }
149
-
150
-
151
-
152
-    /**
153
-     *    streetAddress
154
-     *    The street address. For example, 1600 Amphitheatre Pkwy.
155
-     *
156
-     * @access public
157
-     * @param EEI_Address $obj_with_address
158
-     * @return string
159
-     */
160
-    public static function streetAddress(EEI_Address $obj_with_address = null)
161
-    {
162
-        return $obj_with_address->address() !== null && $obj_with_address->address() !== ''
163
-            ? '<span itemprop="streetAddress">' . $obj_with_address->address() . '</span>' : '';
164
-    }
165
-
166
-
167
-
168
-    /**
169
-     *    postOfficeBoxNumber
170
-     *    The post office box number for PO box addresses.
171
-     *
172
-     * @access public
173
-     * @param EEI_Address $obj_with_address
174
-     * @return string
175
-     */
176
-    public static function postOfficeBoxNumber(EEI_Address $obj_with_address = null)
177
-    {
178
-        // regex check for some form of PO Box or P.O. Box, etc, etc, etc
179
-        if (preg_match(
180
-            "/^\s*((P(OST)?.?\s*(O(FF(ICE)?)?)?.?\s+(B(IN|OX))?)|B(IN|OX))/i",
181
-            $obj_with_address->address2()
182
-        ) ) {
183
-            return $obj_with_address->address2() !== null && $obj_with_address->address2() !== ''
184
-                ? '<span itemprop="postOfficeBoxNumber">' . $obj_with_address->address2() . '</span>' : '';
185
-        } else {
186
-            return $obj_with_address->address2();
187
-        }
188
-    }
189
-
190
-
191
-
192
-    /**
193
-     *    addressLocality
194
-     *    The locality (city, town, etc). For example, Mountain View.
195
-     *
196
-     * @access public
197
-     * @param EEI_Address $obj_with_address
198
-     * @return string
199
-     */
200
-    public static function addressLocality(EEI_Address $obj_with_address = null)
201
-    {
202
-        return $obj_with_address->city() !== null && $obj_with_address->city() !== ''
203
-            ? '<span itemprop="addressLocality">' . $obj_with_address->city() . '</span>' : '';
204
-    }
205
-
206
-
207
-
208
-    /**
209
-     *    addressRegion
210
-     *    The region (state, province, etc). For example, CA.
211
-     *
212
-     * @access public
213
-     * @param EEI_Address $obj_with_address
214
-     * @return string
215
-     */
216
-    public static function addressRegion(EEI_Address $obj_with_address = null)
217
-    {
218
-        $state = $obj_with_address->state_name();
219
-        if (! empty($state)) {
220
-            return '<span itemprop="addressRegion">' . $state . '</span>';
221
-        } else {
222
-            return '';
223
-        }
224
-    }
225
-
226
-
227
-
228
-    /**
229
-     *    addressCountry
230
-     *    The country. For example, USA. You can also provide the two-letter ISO 3166-1 alpha-2 country code.
231
-     *
232
-     * @access public
233
-     * @param EEI_Address $obj_with_address
234
-     * @return string
235
-     */
236
-    public static function addressCountry(EEI_Address $obj_with_address = null)
237
-    {
238
-        $country = $obj_with_address->country_name();
239
-        if (! empty($country)) {
240
-            return '<span itemprop="addressCountry">' . $country . '</span>';
241
-        } else {
242
-            return '';
243
-        }
244
-    }
245
-
246
-
247
-
248
-    /**
249
-     *    postalCode
250
-     *    The postal code. For example, 94043.
251
-     *
252
-     * @access public
253
-     * @param EEI_Address $obj_with_address
254
-     * @return string
255
-     */
256
-    public static function postalCode(EEI_Address $obj_with_address = null)
257
-    {
258
-        return $obj_with_address->zip() !== null && $obj_with_address->zip() !== '' ? '<span itemprop="postalCode">'
259
-                                                                                      . $obj_with_address->zip()
260
-                                                                                      . '</span>' : '';
261
-    }
262
-
263
-
264
-
265
-    /**
266
-     *    telephone
267
-     *    The telephone number.
268
-     *
269
-     * @access public
270
-     * @param string $phone_nmbr
271
-     * @return string
272
-     */
273
-    public static function telephone($phone_nmbr = null)
274
-    {
275
-        return $phone_nmbr !== null && $phone_nmbr !== '' ? '<span itemprop="telephone">' . $phone_nmbr . '</span>'
276
-            : '';
277
-    }
278
-
279
-
280
-
281
-    /**
282
-     *    URL
283
-     *    URL of the item as a clickable link
284
-     *
285
-     * @access public
286
-     * @param string $url        - the URL that the link will resolve to
287
-     * @param string $text       - the text that will be used for the visible link
288
-     * @param array  $attributes - array of additional link attributes in  attribute_name => value pairs. ie: array( 'title' => 'click here', 'class' => 'link-class' )
289
-     * @return string (link)
290
-     */
291
-    public static function url($url = null, $text = null, $attributes = array())
292
-    {
293
-        // Check the URL includes a scheme
294
-        $parsed_url = parse_url($url);
295
-        if (empty($parsed_url['scheme'])) {
296
-            $url = 'http://' . ltrim($url, '/');
297
-        }
298
-
299
-        $atts = '';
300
-        foreach ($attributes as $attribute => $value) {
301
-            $atts .= ' ' . $attribute . '="' . $value . '"';
302
-        }
303
-        $text = $text !== null && $text !== '' ? $text : $url;
304
-        return $url !== null && $url !== '' ? '<a itemprop="url" href="' . $url . '"' . $atts . '>' . $text . '</a>'
305
-            : '';
306
-    }
15
+	/**
16
+	 * generates JSON-based linked data for an event
17
+	 *
18
+	 * @param EE_Event $event
19
+	 * @throws EE_Error
20
+	 */
21
+	public static function add_json_linked_data_for_event(EE_Event $event)
22
+	{
23
+		// Check we have a valid datetime for the event
24
+		if (! $event->primary_datetime() instanceof EE_Datetime) {
25
+			return;
26
+		}
27
+
28
+		$template_args = array(
29
+			'event_permalink' => '',
30
+			'event_name' => '',
31
+			'event_description' => '',
32
+			'event_start' => '',
33
+			'event_end' => '',
34
+			'event_attendance_mode' => '',
35
+			'event_status' => '',
36
+			'currency' => '',
37
+			'event_tickets' => array(),
38
+			'venue_name' => '',
39
+			'venue_url' => '',
40
+			'venue_locality' => '',
41
+			'venue_region' => '',
42
+			'venue_address' => '',
43
+			'event_image' => '',
44
+		);
45
+		$template_args['event_permalink'] = $event->get_permalink();
46
+		$template_args['event_name'] = $event->name();
47
+		$template_args['event_description'] = wp_strip_all_tags($event->short_description(200));
48
+		// clone datetime so that date formats don't override those for the original datetime
49
+		$primary_datetime = clone $event->primary_datetime();
50
+		$template_args['event_start'] = $primary_datetime->start_date(DateTime::ATOM);
51
+		$template_args['event_end'] = $primary_datetime->end_date(DateTime::ATOM);
52
+		unset($primary_datetime);
53
+		switch ($event->status()) {
54
+			case EEM_Event::cancelled:
55
+				$event_status = 'EventCancelled';
56
+				break;
57
+			case EEM_Event::postponed:
58
+				$event_status = 'EventPostponed';
59
+				break;
60
+			default:
61
+				$event_status = 'EventScheduled';
62
+		}
63
+		$template_args['event_attendance_mode'] = 'OfflineEventAttendanceMode';
64
+		$template_args['event_status'] = $event_status;
65
+		$template_args['currency'] = EE_Registry::instance()->CFG->currency->code;
66
+		foreach ($event->tickets() as $original_ticket) {
67
+			// clone tickets so that date formats don't override those for the original ticket
68
+			$ticket= clone $original_ticket;
69
+			$ID = $ticket->ID();
70
+			$template_args['event_tickets'][ $ID ]['start_date'] = $ticket->start_date(DateTime::ATOM, null);
71
+			$template_args['event_tickets'][ $ID ]['end_date'] = $ticket->end_date(DateTime::ATOM, null);
72
+			$template_args['event_tickets'][ $ID ]['price'] = number_format(
73
+				$ticket->price(),
74
+				EE_Registry::instance()->CFG->currency->dec_plc,
75
+				EE_Registry::instance()->CFG->currency->dec_mrk,
76
+				''
77
+			);
78
+			switch ($ticket->ticket_status()) {
79
+				case 'TKO':
80
+					$availability = 'InStock';
81
+					break;
82
+				case 'TKS':
83
+					$availability = 'SoldOut';
84
+					break;
85
+				default:
86
+					$availability = null;
87
+					break;
88
+			}
89
+			$template_args['event_tickets'][ $ID ]['availability'] = $availability;
90
+			unset($ticket);
91
+		}
92
+		$VNU_ID = espresso_venue_id();
93
+		if (! empty($VNU_ID) && ! espresso_is_venue_private($VNU_ID)) {
94
+			$venue = EEH_Venue_View::get_venue($VNU_ID);
95
+			$template_args['venue_name'] = get_the_title($VNU_ID);
96
+			$template_args['venue_url'] = get_permalink($VNU_ID);
97
+			$template_args['venue_locality'] = $venue->city();
98
+			$template_args['venue_region'] = $venue->state_name();
99
+			$template_args['venue_address'] = $venue->address();
100
+			if ($venue->virtual_url() !== '') {
101
+				$template_args['event_attendance_mode'] = 'OnlineEventAttendanceMode';
102
+			}
103
+			if ($venue->virtual_url() !== '' && $venue->address() !== '') {
104
+				$template_args['event_attendance_mode'] = 'MixedEventAttendanceMode';
105
+			}
106
+		}
107
+		$template_args['event_image'] = $event->feature_image_url();
108
+		$template_args = apply_filters(
109
+			'FHEE__EEH_Schema__add_json_linked_data_for_event__template_args',
110
+			$template_args,
111
+			$event,
112
+			$VNU_ID
113
+		);
114
+		extract($template_args, EXTR_OVERWRITE);
115
+		include EE_TEMPLATES . 'json_linked_data_for_event.template.php';
116
+	}
117
+
118
+
119
+	/**
120
+	 *    location
121
+	 *    The location of the event, organization or action.
122
+	 *    Should include the Venue name AND schema formatted address info
123
+	 *
124
+	 * @access public
125
+	 * @param string $location
126
+	 * @return string
127
+	 */
128
+	public static function location($location = null)
129
+	{
130
+		return ! empty($location) ? '<div itemprop="location" itemscope itemtype="http://schema.org/Place">'
131
+									  . $location
132
+									  . '</div>' : '';
133
+	}
134
+
135
+
136
+
137
+	/**
138
+	 *    name
139
+	 *    The name of the Event or Venue.
140
+	 *
141
+	 * @access public
142
+	 * @param string $name
143
+	 * @return string
144
+	 */
145
+	public static function name($name = null)
146
+	{
147
+		return ! empty($name) ? '<span itemprop="name">' . $name . '</span>' : '';
148
+	}
149
+
150
+
151
+
152
+	/**
153
+	 *    streetAddress
154
+	 *    The street address. For example, 1600 Amphitheatre Pkwy.
155
+	 *
156
+	 * @access public
157
+	 * @param EEI_Address $obj_with_address
158
+	 * @return string
159
+	 */
160
+	public static function streetAddress(EEI_Address $obj_with_address = null)
161
+	{
162
+		return $obj_with_address->address() !== null && $obj_with_address->address() !== ''
163
+			? '<span itemprop="streetAddress">' . $obj_with_address->address() . '</span>' : '';
164
+	}
165
+
166
+
167
+
168
+	/**
169
+	 *    postOfficeBoxNumber
170
+	 *    The post office box number for PO box addresses.
171
+	 *
172
+	 * @access public
173
+	 * @param EEI_Address $obj_with_address
174
+	 * @return string
175
+	 */
176
+	public static function postOfficeBoxNumber(EEI_Address $obj_with_address = null)
177
+	{
178
+		// regex check for some form of PO Box or P.O. Box, etc, etc, etc
179
+		if (preg_match(
180
+			"/^\s*((P(OST)?.?\s*(O(FF(ICE)?)?)?.?\s+(B(IN|OX))?)|B(IN|OX))/i",
181
+			$obj_with_address->address2()
182
+		) ) {
183
+			return $obj_with_address->address2() !== null && $obj_with_address->address2() !== ''
184
+				? '<span itemprop="postOfficeBoxNumber">' . $obj_with_address->address2() . '</span>' : '';
185
+		} else {
186
+			return $obj_with_address->address2();
187
+		}
188
+	}
189
+
190
+
191
+
192
+	/**
193
+	 *    addressLocality
194
+	 *    The locality (city, town, etc). For example, Mountain View.
195
+	 *
196
+	 * @access public
197
+	 * @param EEI_Address $obj_with_address
198
+	 * @return string
199
+	 */
200
+	public static function addressLocality(EEI_Address $obj_with_address = null)
201
+	{
202
+		return $obj_with_address->city() !== null && $obj_with_address->city() !== ''
203
+			? '<span itemprop="addressLocality">' . $obj_with_address->city() . '</span>' : '';
204
+	}
205
+
206
+
207
+
208
+	/**
209
+	 *    addressRegion
210
+	 *    The region (state, province, etc). For example, CA.
211
+	 *
212
+	 * @access public
213
+	 * @param EEI_Address $obj_with_address
214
+	 * @return string
215
+	 */
216
+	public static function addressRegion(EEI_Address $obj_with_address = null)
217
+	{
218
+		$state = $obj_with_address->state_name();
219
+		if (! empty($state)) {
220
+			return '<span itemprop="addressRegion">' . $state . '</span>';
221
+		} else {
222
+			return '';
223
+		}
224
+	}
225
+
226
+
227
+
228
+	/**
229
+	 *    addressCountry
230
+	 *    The country. For example, USA. You can also provide the two-letter ISO 3166-1 alpha-2 country code.
231
+	 *
232
+	 * @access public
233
+	 * @param EEI_Address $obj_with_address
234
+	 * @return string
235
+	 */
236
+	public static function addressCountry(EEI_Address $obj_with_address = null)
237
+	{
238
+		$country = $obj_with_address->country_name();
239
+		if (! empty($country)) {
240
+			return '<span itemprop="addressCountry">' . $country . '</span>';
241
+		} else {
242
+			return '';
243
+		}
244
+	}
245
+
246
+
247
+
248
+	/**
249
+	 *    postalCode
250
+	 *    The postal code. For example, 94043.
251
+	 *
252
+	 * @access public
253
+	 * @param EEI_Address $obj_with_address
254
+	 * @return string
255
+	 */
256
+	public static function postalCode(EEI_Address $obj_with_address = null)
257
+	{
258
+		return $obj_with_address->zip() !== null && $obj_with_address->zip() !== '' ? '<span itemprop="postalCode">'
259
+																					  . $obj_with_address->zip()
260
+																					  . '</span>' : '';
261
+	}
262
+
263
+
264
+
265
+	/**
266
+	 *    telephone
267
+	 *    The telephone number.
268
+	 *
269
+	 * @access public
270
+	 * @param string $phone_nmbr
271
+	 * @return string
272
+	 */
273
+	public static function telephone($phone_nmbr = null)
274
+	{
275
+		return $phone_nmbr !== null && $phone_nmbr !== '' ? '<span itemprop="telephone">' . $phone_nmbr . '</span>'
276
+			: '';
277
+	}
278
+
279
+
280
+
281
+	/**
282
+	 *    URL
283
+	 *    URL of the item as a clickable link
284
+	 *
285
+	 * @access public
286
+	 * @param string $url        - the URL that the link will resolve to
287
+	 * @param string $text       - the text that will be used for the visible link
288
+	 * @param array  $attributes - array of additional link attributes in  attribute_name => value pairs. ie: array( 'title' => 'click here', 'class' => 'link-class' )
289
+	 * @return string (link)
290
+	 */
291
+	public static function url($url = null, $text = null, $attributes = array())
292
+	{
293
+		// Check the URL includes a scheme
294
+		$parsed_url = parse_url($url);
295
+		if (empty($parsed_url['scheme'])) {
296
+			$url = 'http://' . ltrim($url, '/');
297
+		}
298
+
299
+		$atts = '';
300
+		foreach ($attributes as $attribute => $value) {
301
+			$atts .= ' ' . $attribute . '="' . $value . '"';
302
+		}
303
+		$text = $text !== null && $text !== '' ? $text : $url;
304
+		return $url !== null && $url !== '' ? '<a itemprop="url" href="' . $url . '"' . $atts . '>' . $text . '</a>'
305
+			: '';
306
+	}
307 307
 }
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -38,103 +38,103 @@
 block discarded – undo
38 38
  * @since           4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
65
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
65
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                        esc_html__(
79
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                            'event_espresso'
81
-                        ),
82
-                        EE_MIN_PHP_VER_REQUIRED,
83
-                        PHP_VERSION,
84
-                        '<br/>',
85
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+						esc_html__(
79
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+							'event_espresso'
81
+						),
82
+						EE_MIN_PHP_VER_REQUIRED,
83
+						PHP_VERSION,
84
+						'<br/>',
85
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
-        /**
98
-         * espresso_version
99
-         * Returns the plugin version
100
-         *
101
-         * @return string
102
-         */
103
-        function espresso_version()
104
-        {
105
-            return apply_filters('FHEE__espresso__espresso_version', '4.10.5.rc.009');
106
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
+		/**
98
+		 * espresso_version
99
+		 * Returns the plugin version
100
+		 *
101
+		 * @return string
102
+		 */
103
+		function espresso_version()
104
+		{
105
+			return apply_filters('FHEE__espresso__espresso_version', '4.10.5.rc.009');
106
+		}
107 107
 
108
-        /**
109
-         * espresso_plugin_activation
110
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
-         */
112
-        function espresso_plugin_activation()
113
-        {
114
-            update_option('ee_espresso_activation', true);
115
-        }
108
+		/**
109
+		 * espresso_plugin_activation
110
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
+		 */
112
+		function espresso_plugin_activation()
113
+		{
114
+			update_option('ee_espresso_activation', true);
115
+		}
116 116
 
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
120
-        bootstrap_espresso();
121
-    }
119
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
120
+		bootstrap_espresso();
121
+	}
122 122
 }
123 123
 if (! function_exists('espresso_deactivate_plugin')) {
124
-    /**
125
-     *    deactivate_plugin
126
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
-     *
128
-     * @access public
129
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
-     * @return    void
131
-     */
132
-    function espresso_deactivate_plugin($plugin_basename = '')
133
-    {
134
-        if (! function_exists('deactivate_plugins')) {
135
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
-        }
137
-        unset($_GET['activate'], $_REQUEST['activate']);
138
-        deactivate_plugins($plugin_basename);
139
-    }
124
+	/**
125
+	 *    deactivate_plugin
126
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
+	 *
128
+	 * @access public
129
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
+	 * @return    void
131
+	 */
132
+	function espresso_deactivate_plugin($plugin_basename = '')
133
+	{
134
+		if (! function_exists('deactivate_plugins')) {
135
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
+		}
137
+		unset($_GET['activate'], $_REQUEST['activate']);
138
+		deactivate_plugins($plugin_basename);
139
+	}
140 140
 }
Please login to merge, or discard this patch.