Completed
Branch CASC/base (2987bb)
by
unknown
19:02 queued 10:52
created
admin/extend/registrations/Extend_Registrations_Admin_Page.core.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -924,7 +924,7 @@
 block discarded – undo
924 924
      * handles toggling the checkin status for the registration,
925 925
      *
926 926
      * @access protected
927
-     * @return int|void
927
+     * @return integer
928 928
      * @throws EE_Error
929 929
      * @throws InvalidArgumentException
930 930
      * @throws InvalidDataTypeException
Please login to merge, or discard this patch.
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -32,10 +32,10 @@  discard block
 block discarded – undo
32 32
     public function __construct($routing = true)
33 33
     {
34 34
         parent::__construct($routing);
35
-        if (! defined('REG_CAF_TEMPLATE_PATH')) {
36
-            define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/');
37
-            define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/');
38
-            define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/');
35
+        if ( ! defined('REG_CAF_TEMPLATE_PATH')) {
36
+            define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'registrations/templates/');
37
+            define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'registrations/assets/');
38
+            define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registrations/assets/');
39 39
         }
40 40
     }
41 41
 
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
      */
46 46
     protected function _extend_page_config()
47 47
     {
48
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations';
48
+        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'registrations';
49 49
         $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
50 50
             ? $this->_req_data['_REG_ID']
51 51
             : 0;
@@ -185,14 +185,14 @@  discard block
 block discarded – undo
185 185
             // enqueue newsletter js
186 186
             wp_enqueue_script(
187 187
                 'ee-newsletter-trigger',
188
-                REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js',
188
+                REG_CAF_ASSETS_URL.'ee-newsletter-trigger.js',
189 189
                 array('ee-dialog'),
190 190
                 EVENT_ESPRESSO_VERSION,
191 191
                 true
192 192
             );
193 193
             wp_enqueue_style(
194 194
                 'ee-newsletter-trigger-css',
195
-                REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css',
195
+                REG_CAF_ASSETS_URL.'ee-newsletter-trigger.css',
196 196
                 array(),
197 197
                 EVENT_ESPRESSO_VERSION
198 198
             );
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
     {
214 214
         wp_register_script(
215 215
             'ee-reg-reports-js',
216
-            REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js',
216
+            REG_CAF_ASSETS_URL.'ee-registration-admin-reports.js',
217 217
             array('google-charts'),
218 218
             EVENT_ESPRESSO_VERSION,
219 219
             true
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
         $nonce_ref = 'get_newsletter_form_content_nonce';
300 300
         $this->_verify_nonce($nonce, $nonce_ref);
301 301
         // let's get the mtp for the incoming MTP_ ID
302
-        if (! isset($this->_req_data['GRP_ID'])) {
302
+        if ( ! isset($this->_req_data['GRP_ID'])) {
303 303
             EE_Error::add_error(
304 304
                 esc_html__(
305 305
                     'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).',
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
             $this->_return_json();
315 315
         }
316 316
         $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']);
317
-        if (! $MTPG instanceof EE_Message_Template_Group) {
317
+        if ( ! $MTPG instanceof EE_Message_Template_Group) {
318 318
             EE_Error::add_error(
319 319
                 sprintf(
320 320
                     esc_html__(
@@ -339,12 +339,12 @@  discard block
 block discarded – undo
339 339
             $field = $MTP->get('MTP_template_field');
340 340
             if ($field === 'content') {
341 341
                 $content = $MTP->get('MTP_content');
342
-                if (! empty($content['newsletter_content'])) {
342
+                if ( ! empty($content['newsletter_content'])) {
343 343
                     $template_fields['newsletter_content'] = $content['newsletter_content'];
344 344
                 }
345 345
                 continue;
346 346
             }
347
-            $template_fields[ $MTP->get('MTP_template_field') ] = $MTP->get('MTP_content');
347
+            $template_fields[$MTP->get('MTP_template_field')] = $MTP->get('MTP_content');
348 348
         }
349 349
         $this->_template_args['success'] = true;
350 350
         $this->_template_args['error'] = false;
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
      */
376 376
     public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table)
377 377
     {
378
-        if (! EE_Registry::instance()->CAP->current_user_can(
378
+        if ( ! EE_Registry::instance()->CAP->current_user_can(
379 379
             'ee_send_message',
380 380
             'espresso_registrations_newsletter_selected_send'
381 381
         )
@@ -444,17 +444,17 @@  discard block
 block discarded – undo
444 444
                 $field_id = $field === '[NEWSLETTER_CONTENT]'
445 445
                     ? 'content'
446 446
                     : $field;
447
-                $field_id = 'batch-message-' . strtolower($field_id);
447
+                $field_id = 'batch-message-'.strtolower($field_id);
448 448
                 $available_shortcodes[] = '<span class="js-shortcode-selection" data-value="'
449 449
                                           . $shortcode
450
-                                          . '" data-linked-input-id="' . $field_id . '">'
450
+                                          . '" data-linked-input-id="'.$field_id.'">'
451 451
                                           . $shortcode
452 452
                                           . '</span>';
453 453
             }
454
-            $codes[ $field ] = implode(', ', $available_shortcodes);
454
+            $codes[$field] = implode(', ', $available_shortcodes);
455 455
         }
456 456
         $shortcodes = $codes;
457
-        $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php';
457
+        $form_template = REG_CAF_TEMPLATE_PATH.'newsletter-send-form.template.php';
458 458
         $form_template_args = array(
459 459
             'form_action'       => admin_url('admin.php?page=espresso_registrations'),
460 460
             'form_route'        => 'newsletter_selected_send',
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
      */
623 623
     protected function _registration_reports()
624 624
     {
625
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
625
+        $template_path = EE_ADMIN_TEMPLATE.'admin_reports.template.php';
626 626
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
627 627
             $template_path,
628 628
             $this->_reports_template_data,
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
             array_unshift($regs, $column_titles);
678 678
             // setup the date range.
679 679
             $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
680
-            $beginning_date = new DateTime("now " . $period, $DateTimeZone);
680
+            $beginning_date = new DateTime("now ".$period, $DateTimeZone);
681 681
             $ending_date = new DateTime("now", $DateTimeZone);
682 682
             $subtitle = sprintf(
683 683
                 _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'),
@@ -697,7 +697,7 @@  discard block
 block discarded – undo
697 697
                     '%sThere are currently no registration records in the last month for this report.%s',
698 698
                     'event_espresso'
699 699
                 ),
700
-                '<h2>' . $report_title . '</h2><p>',
700
+                '<h2>'.$report_title.'</h2><p>',
701 701
                 '</p>'
702 702
             ),
703 703
         );
@@ -750,7 +750,7 @@  discard block
 block discarded – undo
750 750
             array_unshift($regs, $column_titles);
751 751
             // setup the date range.
752 752
             $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
753
-            $beginning_date = new DateTime("now " . $period, $DateTimeZone);
753
+            $beginning_date = new DateTime("now ".$period, $DateTimeZone);
754 754
             $ending_date = new DateTime("now", $DateTimeZone);
755 755
             $subtitle = sprintf(
756 756
                 _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'),
@@ -770,7 +770,7 @@  discard block
 block discarded – undo
770 770
                     '%sThere are currently no registration records in the last month for this report.%s',
771 771
                     'event_espresso'
772 772
                 ),
773
-                '<h2>' . $report_title . '</h2><p>',
773
+                '<h2>'.$report_title.'</h2><p>',
774 774
                 '</p>'
775 775
             ),
776 776
         );
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
         $reg_id = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : null;
797 797
         /** @var EE_Registration $registration */
798 798
         $registration = EEM_Registration::instance()->get_one_by_ID($reg_id);
799
-        if (! $registration instanceof EE_Registration) {
799
+        if ( ! $registration instanceof EE_Registration) {
800 800
             throw new EE_Error(
801 801
                 sprintf(
802 802
                     esc_html__('An error occurred. There is no registration with ID (%d)', 'event_espresso'),
@@ -831,7 +831,7 @@  discard block
 block discarded – undo
831 831
         if ($datetime instanceof EE_Datetime) {
832 832
             $datetime_label = $datetime->get_dtt_display_name(true);
833 833
             $datetime_label .= ! empty($datetime_label)
834
-                ? ' (' . $datetime->get_dtt_display_name() . ')'
834
+                ? ' ('.$datetime->get_dtt_display_name().')'
835 835
                 : $datetime->get_dtt_display_name();
836 836
         }
837 837
         $datetime_link = ! empty($dtt_id) && $registration instanceof EE_Registration
@@ -845,7 +845,7 @@  discard block
 block discarded – undo
845 845
             )
846 846
             : '';
847 847
         $datetime_link = ! empty($datetime_link)
848
-            ? '<a href="' . $datetime_link . '">'
848
+            ? '<a href="'.$datetime_link.'">'
849 849
               . '<span id="checkin-dtt">'
850 850
               . $datetime_label
851 851
               . '</span></a>'
@@ -857,8 +857,8 @@  discard block
 block discarded – undo
857 857
             ? $attendee->get_admin_details_link()
858 858
             : '';
859 859
         $attendee_link = ! empty($attendee_link)
860
-            ? '<a href="' . $attendee->get_admin_details_link() . '"'
861
-              . ' title="' . esc_html__('Click for attendee details', 'event_espresso') . '">'
860
+            ? '<a href="'.$attendee->get_admin_details_link().'"'
861
+              . ' title="'.esc_html__('Click for attendee details', 'event_espresso').'">'
862 862
               . '<span id="checkin-attendee-name">'
863 863
               . $attendee_name
864 864
               . '</span></a>'
@@ -867,25 +867,25 @@  discard block
 block discarded – undo
867 867
             ? $registration->event()->get_admin_details_link()
868 868
             : '';
869 869
         $event_link = ! empty($event_link)
870
-            ? '<a href="' . $event_link . '"'
871
-              . ' title="' . esc_html__('Click here to edit event.', 'event_espresso') . '">'
870
+            ? '<a href="'.$event_link.'"'
871
+              . ' title="'.esc_html__('Click here to edit event.', 'event_espresso').'">'
872 872
               . '<span id="checkin-event-name">'
873 873
               . $registration->event_name()
874 874
               . '</span>'
875 875
               . '</a>'
876 876
             : '';
877 877
         $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id)
878
-            ? '<h2>' . sprintf(
878
+            ? '<h2>'.sprintf(
879 879
                 esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'),
880 880
                 $attendee_link,
881 881
                 $datetime_link,
882 882
                 $event_link
883
-            ) . '</h2>'
883
+            ).'</h2>'
884 884
             : '';
885 885
         $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id)
886
-            ? '<input type="hidden" name="_REG_ID" value="' . $reg_id . '">' : '';
886
+            ? '<input type="hidden" name="_REG_ID" value="'.$reg_id.'">' : '';
887 887
         $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id)
888
-            ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : '';
888
+            ? '<input type="hidden" name="DTT_ID" value="'.$dtt_id.'">' : '';
889 889
         $this->display_admin_list_table_page_with_no_sidebar();
890 890
     }
891 891
 
@@ -902,7 +902,7 @@  discard block
 block discarded – undo
902 902
     public function toggle_checkin_status()
903 903
     {
904 904
         // first make sure we have the necessary data
905
-        if (! isset($this->_req_data['_regid'])) {
905
+        if ( ! isset($this->_req_data['_regid'])) {
906 906
             EE_Error::add_error(
907 907
                 esc_html__(
908 908
                     'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax',
@@ -924,7 +924,7 @@  discard block
 block discarded – undo
924 924
         // beautiful! Made it this far so let's get the status.
925 925
         $new_status = new CheckinStatusDashicon($this->_toggle_checkin_status());
926 926
         // setup new class to return via ajax
927
-        $this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses();
927
+        $this->_template_args['admin_page_content'] = 'clickable trigger-checkin '.$new_status->cssClasses();
928 928
         $this->_template_args['success'] = true;
929 929
         $this->_return_json();
930 930
     }
@@ -950,7 +950,7 @@  discard block
 block discarded – undo
950 950
         );
951 951
         $new_status = false;
952 952
         // bulk action check in toggle
953
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
953
+        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
954 954
             // cycle thru checkboxes
955 955
             while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) {
956 956
                 $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
@@ -1020,9 +1020,9 @@  discard block
 block discarded – undo
1020 1020
             '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0,
1021 1021
         );
1022 1022
         $errors = 0;
1023
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1023
+        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1024 1024
             while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) {
1025
-                if (! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) {
1025
+                if ( ! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) {
1026 1026
                     $errors++;
1027 1027
                 }
1028 1028
             }
@@ -1068,8 +1068,8 @@  discard block
 block discarded – undo
1068 1068
             'DTT_ID'  => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1069 1069
             '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0,
1070 1070
         );
1071
-        if (! empty($this->_req_data['CHK_ID'])) {
1072
-            if (! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) {
1071
+        if ( ! empty($this->_req_data['CHK_ID'])) {
1072
+            if ( ! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) {
1073 1073
                 EE_Error::add_error(
1074 1074
                     esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'),
1075 1075
                     __FILE__,
@@ -1138,27 +1138,27 @@  discard block
 block discarded – undo
1138 1138
                 'desc'  => $checked_never->legendLabel(),
1139 1139
             ),
1140 1140
             'approved_status'  => array(
1141
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1141
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_approved,
1142 1142
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'),
1143 1143
             ),
1144 1144
             'cancelled_status' => array(
1145
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1145
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_cancelled,
1146 1146
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'),
1147 1147
             ),
1148 1148
             'declined_status'  => array(
1149
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1149
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_declined,
1150 1150
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'),
1151 1151
             ),
1152 1152
             'not_approved'     => array(
1153
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1153
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_not_approved,
1154 1154
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'),
1155 1155
             ),
1156 1156
             'pending_status'   => array(
1157
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1157
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_pending_payment,
1158 1158
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'),
1159 1159
             ),
1160 1160
             'wait_list'        => array(
1161
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1161
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_wait_list,
1162 1162
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'),
1163 1163
             ),
1164 1164
         );
@@ -1167,10 +1167,10 @@  discard block
 block discarded – undo
1167 1167
         /** @var EE_Event $event */
1168 1168
         $event = EEM_Event::instance()->get_one_by_ID($event_id);
1169 1169
         $this->_template_args['before_list_table'] = $event instanceof EE_Event
1170
-            ? '<h2>' . sprintf(
1170
+            ? '<h2>'.sprintf(
1171 1171
                 esc_html__('Viewing Registrations for Event: %s', 'event_espresso'),
1172 1172
                 EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name')
1173
-            ) . '</h2>'
1173
+            ).'</h2>'
1174 1174
             : '';
1175 1175
         // need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on
1176 1176
         // the event.
@@ -1188,12 +1188,12 @@  discard block
 block discarded – undo
1188 1188
             $this->_template_args['before_list_table'] .= ' &nbsp;<span class="drk-grey-text">';
1189 1189
             $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>';
1190 1190
             $this->_template_args['before_list_table'] .= $datetime->name();
1191
-            $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )';
1191
+            $this->_template_args['before_list_table'] .= ' ( '.$datetime->date_and_time_range().' )';
1192 1192
             $this->_template_args['before_list_table'] .= '</span></h2>';
1193 1193
         }
1194 1194
         // if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status
1195 1195
         // column represents
1196
-        if (! $datetime instanceof EE_Datetime) {
1196
+        if ( ! $datetime instanceof EE_Datetime) {
1197 1197
             $this->_template_args['before_list_table'] .= '<br><p class="description">'
1198 1198
                                                           . esc_html__(
1199 1199
                                                               'In this view, the check-in status represents the latest check-in record for the registration in that row.',
Please login to merge, or discard this patch.
Indentation   +1211 added lines, -1211 removed lines patch added patch discarded remove patch
@@ -16,1268 +16,1268 @@
 block discarded – undo
16 16
 {
17 17
 
18 18
 
19
-    /**
20
-     * This is used to hold the reports template data which is setup early in the request.
21
-     *
22
-     * @type array
23
-     */
24
-    protected $_reports_template_data = array();
19
+	/**
20
+	 * This is used to hold the reports template data which is setup early in the request.
21
+	 *
22
+	 * @type array
23
+	 */
24
+	protected $_reports_template_data = array();
25 25
 
26 26
 
27
-    /**
28
-     * Extend_Registrations_Admin_Page constructor.
29
-     *
30
-     * @param bool $routing
31
-     */
32
-    public function __construct($routing = true)
33
-    {
34
-        parent::__construct($routing);
35
-        if (! defined('REG_CAF_TEMPLATE_PATH')) {
36
-            define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/');
37
-            define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/');
38
-            define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/');
39
-        }
40
-    }
27
+	/**
28
+	 * Extend_Registrations_Admin_Page constructor.
29
+	 *
30
+	 * @param bool $routing
31
+	 */
32
+	public function __construct($routing = true)
33
+	{
34
+		parent::__construct($routing);
35
+		if (! defined('REG_CAF_TEMPLATE_PATH')) {
36
+			define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/');
37
+			define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/');
38
+			define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/');
39
+		}
40
+	}
41 41
 
42 42
 
43
-    /**
44
-     * Extending page configuration.
45
-     */
46
-    protected function _extend_page_config()
47
-    {
48
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations';
49
-        $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
50
-            ? $this->_req_data['_REG_ID']
51
-            : 0;
52
-        $new_page_routes = array(
53
-            'reports'                      => array(
54
-                'func'       => '_registration_reports',
55
-                'capability' => 'ee_read_registrations',
56
-            ),
57
-            'registration_checkins'        => array(
58
-                'func'       => '_registration_checkin_list_table',
59
-                'capability' => 'ee_read_checkins',
60
-            ),
61
-            'newsletter_selected_send'     => array(
62
-                'func'       => '_newsletter_selected_send',
63
-                'noheader'   => true,
64
-                'capability' => 'ee_send_message',
65
-            ),
66
-            'delete_checkin_rows'          => array(
67
-                'func'       => '_delete_checkin_rows',
68
-                'noheader'   => true,
69
-                'capability' => 'ee_delete_checkins',
70
-            ),
71
-            'delete_checkin_row'           => array(
72
-                'func'       => '_delete_checkin_row',
73
-                'noheader'   => true,
74
-                'capability' => 'ee_delete_checkin',
75
-                'obj_id'     => $reg_id,
76
-            ),
77
-            'toggle_checkin_status'        => array(
78
-                'func'       => '_toggle_checkin_status',
79
-                'noheader'   => true,
80
-                'capability' => 'ee_edit_checkin',
81
-                'obj_id'     => $reg_id,
82
-            ),
83
-            'toggle_checkin_status_bulk'   => array(
84
-                'func'       => '_toggle_checkin_status',
85
-                'noheader'   => true,
86
-                'capability' => 'ee_edit_checkins',
87
-            ),
88
-            'event_registrations'          => array(
89
-                'func'       => '_event_registrations_list_table',
90
-                'capability' => 'ee_read_checkins',
91
-            ),
92
-            'registrations_checkin_report' => array(
93
-                'func'       => '_registrations_checkin_report',
94
-                'noheader'   => true,
95
-                'capability' => 'ee_read_registrations',
96
-            ),
97
-        );
98
-        $this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
99
-        $new_page_config = array(
100
-            'reports'               => array(
101
-                'nav'           => array(
102
-                    'label' => esc_html__('Reports', 'event_espresso'),
103
-                    'order' => 30,
104
-                ),
105
-                'help_tabs'     => array(
106
-                    'registrations_reports_help_tab' => array(
107
-                        'title'    => esc_html__('Registration Reports', 'event_espresso'),
108
-                        'filename' => 'registrations_reports',
109
-                    ),
110
-                ),
111
-                /*'help_tour' => array( 'Registration_Reports_Help_Tour' ),*/
112
-                'require_nonce' => false,
113
-            ),
114
-            'event_registrations'   => array(
115
-                'nav'           => array(
116
-                    'label'      => esc_html__('Event Check-In', 'event_espresso'),
117
-                    'order'      => 10,
118
-                    'persistent' => true,
119
-                ),
120
-                'help_tabs'     => array(
121
-                    'registrations_event_checkin_help_tab'                       => array(
122
-                        'title'    => esc_html__('Registrations Event Check-In', 'event_espresso'),
123
-                        'filename' => 'registrations_event_checkin',
124
-                    ),
125
-                    'registrations_event_checkin_table_column_headings_help_tab' => array(
126
-                        'title'    => esc_html__('Event Check-In Table Column Headings', 'event_espresso'),
127
-                        'filename' => 'registrations_event_checkin_table_column_headings',
128
-                    ),
129
-                    'registrations_event_checkin_filters_help_tab'               => array(
130
-                        'title'    => esc_html__('Event Check-In Filters', 'event_espresso'),
131
-                        'filename' => 'registrations_event_checkin_filters',
132
-                    ),
133
-                    'registrations_event_checkin_views_help_tab'                 => array(
134
-                        'title'    => esc_html__('Event Check-In Views', 'event_espresso'),
135
-                        'filename' => 'registrations_event_checkin_views',
136
-                    ),
137
-                    'registrations_event_checkin_other_help_tab'                 => array(
138
-                        'title'    => esc_html__('Event Check-In Other', 'event_espresso'),
139
-                        'filename' => 'registrations_event_checkin_other',
140
-                    ),
141
-                ),
142
-                // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
143
-                // 'help_tour'     => array('Event_Checkin_Help_Tour'),
144
-                'qtips'         => array('Registration_List_Table_Tips'),
145
-                'list_table'    => 'EE_Event_Registrations_List_Table',
146
-                'metaboxes'     => array(),
147
-                'require_nonce' => false,
148
-            ),
149
-            'registration_checkins' => array(
150
-                'nav'           => array(
151
-                    'label'      => esc_html__('Check-In Records', 'event_espresso'),
152
-                    'order'      => 15,
153
-                    'persistent' => false,
154
-                    'url'        => '',
155
-                ),
156
-                'list_table'    => 'EE_Registration_CheckIn_List_Table',
157
-                // 'help_tour' => array( 'Checkin_Toggle_View_Help_Tour' ),
158
-                'metaboxes'     => array(),
159
-                'require_nonce' => false,
160
-            ),
161
-        );
162
-        $this->_page_config = array_merge($this->_page_config, $new_page_config);
163
-        $this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table';
164
-        $this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table';
165
-    }
43
+	/**
44
+	 * Extending page configuration.
45
+	 */
46
+	protected function _extend_page_config()
47
+	{
48
+		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations';
49
+		$reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
50
+			? $this->_req_data['_REG_ID']
51
+			: 0;
52
+		$new_page_routes = array(
53
+			'reports'                      => array(
54
+				'func'       => '_registration_reports',
55
+				'capability' => 'ee_read_registrations',
56
+			),
57
+			'registration_checkins'        => array(
58
+				'func'       => '_registration_checkin_list_table',
59
+				'capability' => 'ee_read_checkins',
60
+			),
61
+			'newsletter_selected_send'     => array(
62
+				'func'       => '_newsletter_selected_send',
63
+				'noheader'   => true,
64
+				'capability' => 'ee_send_message',
65
+			),
66
+			'delete_checkin_rows'          => array(
67
+				'func'       => '_delete_checkin_rows',
68
+				'noheader'   => true,
69
+				'capability' => 'ee_delete_checkins',
70
+			),
71
+			'delete_checkin_row'           => array(
72
+				'func'       => '_delete_checkin_row',
73
+				'noheader'   => true,
74
+				'capability' => 'ee_delete_checkin',
75
+				'obj_id'     => $reg_id,
76
+			),
77
+			'toggle_checkin_status'        => array(
78
+				'func'       => '_toggle_checkin_status',
79
+				'noheader'   => true,
80
+				'capability' => 'ee_edit_checkin',
81
+				'obj_id'     => $reg_id,
82
+			),
83
+			'toggle_checkin_status_bulk'   => array(
84
+				'func'       => '_toggle_checkin_status',
85
+				'noheader'   => true,
86
+				'capability' => 'ee_edit_checkins',
87
+			),
88
+			'event_registrations'          => array(
89
+				'func'       => '_event_registrations_list_table',
90
+				'capability' => 'ee_read_checkins',
91
+			),
92
+			'registrations_checkin_report' => array(
93
+				'func'       => '_registrations_checkin_report',
94
+				'noheader'   => true,
95
+				'capability' => 'ee_read_registrations',
96
+			),
97
+		);
98
+		$this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
99
+		$new_page_config = array(
100
+			'reports'               => array(
101
+				'nav'           => array(
102
+					'label' => esc_html__('Reports', 'event_espresso'),
103
+					'order' => 30,
104
+				),
105
+				'help_tabs'     => array(
106
+					'registrations_reports_help_tab' => array(
107
+						'title'    => esc_html__('Registration Reports', 'event_espresso'),
108
+						'filename' => 'registrations_reports',
109
+					),
110
+				),
111
+				/*'help_tour' => array( 'Registration_Reports_Help_Tour' ),*/
112
+				'require_nonce' => false,
113
+			),
114
+			'event_registrations'   => array(
115
+				'nav'           => array(
116
+					'label'      => esc_html__('Event Check-In', 'event_espresso'),
117
+					'order'      => 10,
118
+					'persistent' => true,
119
+				),
120
+				'help_tabs'     => array(
121
+					'registrations_event_checkin_help_tab'                       => array(
122
+						'title'    => esc_html__('Registrations Event Check-In', 'event_espresso'),
123
+						'filename' => 'registrations_event_checkin',
124
+					),
125
+					'registrations_event_checkin_table_column_headings_help_tab' => array(
126
+						'title'    => esc_html__('Event Check-In Table Column Headings', 'event_espresso'),
127
+						'filename' => 'registrations_event_checkin_table_column_headings',
128
+					),
129
+					'registrations_event_checkin_filters_help_tab'               => array(
130
+						'title'    => esc_html__('Event Check-In Filters', 'event_espresso'),
131
+						'filename' => 'registrations_event_checkin_filters',
132
+					),
133
+					'registrations_event_checkin_views_help_tab'                 => array(
134
+						'title'    => esc_html__('Event Check-In Views', 'event_espresso'),
135
+						'filename' => 'registrations_event_checkin_views',
136
+					),
137
+					'registrations_event_checkin_other_help_tab'                 => array(
138
+						'title'    => esc_html__('Event Check-In Other', 'event_espresso'),
139
+						'filename' => 'registrations_event_checkin_other',
140
+					),
141
+				),
142
+				// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
143
+				// 'help_tour'     => array('Event_Checkin_Help_Tour'),
144
+				'qtips'         => array('Registration_List_Table_Tips'),
145
+				'list_table'    => 'EE_Event_Registrations_List_Table',
146
+				'metaboxes'     => array(),
147
+				'require_nonce' => false,
148
+			),
149
+			'registration_checkins' => array(
150
+				'nav'           => array(
151
+					'label'      => esc_html__('Check-In Records', 'event_espresso'),
152
+					'order'      => 15,
153
+					'persistent' => false,
154
+					'url'        => '',
155
+				),
156
+				'list_table'    => 'EE_Registration_CheckIn_List_Table',
157
+				// 'help_tour' => array( 'Checkin_Toggle_View_Help_Tour' ),
158
+				'metaboxes'     => array(),
159
+				'require_nonce' => false,
160
+			),
161
+		);
162
+		$this->_page_config = array_merge($this->_page_config, $new_page_config);
163
+		$this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table';
164
+		$this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table';
165
+	}
166 166
 
167 167
 
168
-    /**
169
-     * Ajax hooks for all routes in this page.
170
-     */
171
-    protected function _ajax_hooks()
172
-    {
173
-        parent::_ajax_hooks();
174
-        add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content'));
175
-    }
168
+	/**
169
+	 * Ajax hooks for all routes in this page.
170
+	 */
171
+	protected function _ajax_hooks()
172
+	{
173
+		parent::_ajax_hooks();
174
+		add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content'));
175
+	}
176 176
 
177 177
 
178
-    /**
179
-     * Global scripts for all routes in this page.
180
-     */
181
-    public function load_scripts_styles()
182
-    {
183
-        parent::load_scripts_styles();
184
-        // if newsletter message type is active then let's add filter and load js for it.
185
-        if (EEH_MSG_Template::is_mt_active('newsletter')) {
186
-            // enqueue newsletter js
187
-            wp_enqueue_script(
188
-                'ee-newsletter-trigger',
189
-                REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js',
190
-                array('ee-dialog'),
191
-                EVENT_ESPRESSO_VERSION,
192
-                true
193
-            );
194
-            wp_enqueue_style(
195
-                'ee-newsletter-trigger-css',
196
-                REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css',
197
-                array(),
198
-                EVENT_ESPRESSO_VERSION
199
-            );
200
-            // hook in buttons for newsletter message type trigger.
201
-            add_action(
202
-                'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons',
203
-                array($this, 'add_newsletter_action_buttons'),
204
-                10
205
-            );
206
-        }
207
-    }
178
+	/**
179
+	 * Global scripts for all routes in this page.
180
+	 */
181
+	public function load_scripts_styles()
182
+	{
183
+		parent::load_scripts_styles();
184
+		// if newsletter message type is active then let's add filter and load js for it.
185
+		if (EEH_MSG_Template::is_mt_active('newsletter')) {
186
+			// enqueue newsletter js
187
+			wp_enqueue_script(
188
+				'ee-newsletter-trigger',
189
+				REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js',
190
+				array('ee-dialog'),
191
+				EVENT_ESPRESSO_VERSION,
192
+				true
193
+			);
194
+			wp_enqueue_style(
195
+				'ee-newsletter-trigger-css',
196
+				REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css',
197
+				array(),
198
+				EVENT_ESPRESSO_VERSION
199
+			);
200
+			// hook in buttons for newsletter message type trigger.
201
+			add_action(
202
+				'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons',
203
+				array($this, 'add_newsletter_action_buttons'),
204
+				10
205
+			);
206
+		}
207
+	}
208 208
 
209 209
 
210
-    /**
211
-     * Scripts and styles for just the reports route.
212
-     */
213
-    public function load_scripts_styles_reports()
214
-    {
215
-        wp_register_script(
216
-            'ee-reg-reports-js',
217
-            REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js',
218
-            array('google-charts'),
219
-            EVENT_ESPRESSO_VERSION,
220
-            true
221
-        );
222
-        wp_enqueue_script('ee-reg-reports-js');
223
-        $this->_registration_reports_js_setup();
224
-    }
210
+	/**
211
+	 * Scripts and styles for just the reports route.
212
+	 */
213
+	public function load_scripts_styles_reports()
214
+	{
215
+		wp_register_script(
216
+			'ee-reg-reports-js',
217
+			REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js',
218
+			array('google-charts'),
219
+			EVENT_ESPRESSO_VERSION,
220
+			true
221
+		);
222
+		wp_enqueue_script('ee-reg-reports-js');
223
+		$this->_registration_reports_js_setup();
224
+	}
225 225
 
226 226
 
227
-    /**
228
-     * Register screen options for event_registrations route.
229
-     */
230
-    protected function _add_screen_options_event_registrations()
231
-    {
232
-        $this->_per_page_screen_option();
233
-    }
227
+	/**
228
+	 * Register screen options for event_registrations route.
229
+	 */
230
+	protected function _add_screen_options_event_registrations()
231
+	{
232
+		$this->_per_page_screen_option();
233
+	}
234 234
 
235 235
 
236
-    /**
237
-     * Register screen options for registration_checkins route
238
-     */
239
-    protected function _add_screen_options_registration_checkins()
240
-    {
241
-        $page_title = $this->_admin_page_title;
242
-        $this->_admin_page_title = esc_html__('Check-In Records', 'event_espresso');
243
-        $this->_per_page_screen_option();
244
-        $this->_admin_page_title = $page_title;
245
-    }
236
+	/**
237
+	 * Register screen options for registration_checkins route
238
+	 */
239
+	protected function _add_screen_options_registration_checkins()
240
+	{
241
+		$page_title = $this->_admin_page_title;
242
+		$this->_admin_page_title = esc_html__('Check-In Records', 'event_espresso');
243
+		$this->_per_page_screen_option();
244
+		$this->_admin_page_title = $page_title;
245
+	}
246 246
 
247 247
 
248
-    /**
249
-     * Set views property for event_registrations route.
250
-     */
251
-    protected function _set_list_table_views_event_registrations()
252
-    {
253
-        $this->_views = array(
254
-            'all' => array(
255
-                'slug'        => 'all',
256
-                'label'       => esc_html__('All', 'event_espresso'),
257
-                'count'       => 0,
258
-                'bulk_action' => ! isset($this->_req_data['event_id'])
259
-                    ? array()
260
-                    : array(
261
-                        'toggle_checkin_status_bulk' => esc_html__('Toggle Check-In', 'event_espresso'),
262
-                    ),
263
-            ),
264
-        );
265
-    }
248
+	/**
249
+	 * Set views property for event_registrations route.
250
+	 */
251
+	protected function _set_list_table_views_event_registrations()
252
+	{
253
+		$this->_views = array(
254
+			'all' => array(
255
+				'slug'        => 'all',
256
+				'label'       => esc_html__('All', 'event_espresso'),
257
+				'count'       => 0,
258
+				'bulk_action' => ! isset($this->_req_data['event_id'])
259
+					? array()
260
+					: array(
261
+						'toggle_checkin_status_bulk' => esc_html__('Toggle Check-In', 'event_espresso'),
262
+					),
263
+			),
264
+		);
265
+	}
266 266
 
267 267
 
268
-    /**
269
-     * Set views property for registration_checkins route.
270
-     */
271
-    protected function _set_list_table_views_registration_checkins()
272
-    {
273
-        $this->_views = array(
274
-            'all' => array(
275
-                'slug'        => 'all',
276
-                'label'       => esc_html__('All', 'event_espresso'),
277
-                'count'       => 0,
278
-                'bulk_action' => array('delete_checkin_rows' => esc_html__('Delete Check-In Rows', 'event_espresso')),
279
-            ),
280
-        );
281
-    }
268
+	/**
269
+	 * Set views property for registration_checkins route.
270
+	 */
271
+	protected function _set_list_table_views_registration_checkins()
272
+	{
273
+		$this->_views = array(
274
+			'all' => array(
275
+				'slug'        => 'all',
276
+				'label'       => esc_html__('All', 'event_espresso'),
277
+				'count'       => 0,
278
+				'bulk_action' => array('delete_checkin_rows' => esc_html__('Delete Check-In Rows', 'event_espresso')),
279
+			),
280
+		);
281
+	}
282 282
 
283 283
 
284
-    /**
285
-     * callback for ajax action.
286
-     *
287
-     * @since 4.3.0
288
-     * @return void (JSON)
289
-     * @throws EE_Error
290
-     * @throws InvalidArgumentException
291
-     * @throws InvalidDataTypeException
292
-     * @throws InvalidInterfaceException
293
-     */
294
-    public function get_newsletter_form_content()
295
-    {
296
-        // do a nonce check cause we're not coming in from an normal route here.
297
-        $nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field(
298
-            $this->_req_data['get_newsletter_form_content_nonce']
299
-        ) : '';
300
-        $nonce_ref = 'get_newsletter_form_content_nonce';
301
-        $this->_verify_nonce($nonce, $nonce_ref);
302
-        // let's get the mtp for the incoming MTP_ ID
303
-        if (! isset($this->_req_data['GRP_ID'])) {
304
-            EE_Error::add_error(
305
-                esc_html__(
306
-                    'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).',
307
-                    'event_espresso'
308
-                ),
309
-                __FILE__,
310
-                __FUNCTION__,
311
-                __LINE__
312
-            );
313
-            $this->_template_args['success'] = false;
314
-            $this->_template_args['error'] = true;
315
-            $this->_return_json();
316
-        }
317
-        $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']);
318
-        if (! $MTPG instanceof EE_Message_Template_Group) {
319
-            EE_Error::add_error(
320
-                sprintf(
321
-                    esc_html__(
322
-                        'The GRP_ID given (%d) does not appear to have a corresponding row in the database.',
323
-                        'event_espresso'
324
-                    ),
325
-                    $this->_req_data['GRP_ID']
326
-                ),
327
-                __FILE__,
328
-                __FUNCTION__,
329
-                __LINE__
330
-            );
331
-            $this->_template_args['success'] = false;
332
-            $this->_template_args['error'] = true;
333
-            $this->_return_json();
334
-        }
335
-        $MTPs = $MTPG->context_templates();
336
-        $MTPs = $MTPs['attendee'];
337
-        $template_fields = array();
338
-        /** @var EE_Message_Template $MTP */
339
-        foreach ($MTPs as $MTP) {
340
-            $field = $MTP->get('MTP_template_field');
341
-            if ($field === 'content') {
342
-                $content = $MTP->get('MTP_content');
343
-                if (! empty($content['newsletter_content'])) {
344
-                    $template_fields['newsletter_content'] = $content['newsletter_content'];
345
-                }
346
-                continue;
347
-            }
348
-            $template_fields[ $MTP->get('MTP_template_field') ] = $MTP->get('MTP_content');
349
-        }
350
-        $this->_template_args['success'] = true;
351
-        $this->_template_args['error'] = false;
352
-        $this->_template_args['data'] = array(
353
-            'batch_message_from'    => isset($template_fields['from'])
354
-                ? $template_fields['from']
355
-                : '',
356
-            'batch_message_subject' => isset($template_fields['subject'])
357
-                ? $template_fields['subject']
358
-                : '',
359
-            'batch_message_content' => isset($template_fields['newsletter_content'])
360
-                ? $template_fields['newsletter_content']
361
-                : '',
362
-        );
363
-        $this->_return_json();
364
-    }
284
+	/**
285
+	 * callback for ajax action.
286
+	 *
287
+	 * @since 4.3.0
288
+	 * @return void (JSON)
289
+	 * @throws EE_Error
290
+	 * @throws InvalidArgumentException
291
+	 * @throws InvalidDataTypeException
292
+	 * @throws InvalidInterfaceException
293
+	 */
294
+	public function get_newsletter_form_content()
295
+	{
296
+		// do a nonce check cause we're not coming in from an normal route here.
297
+		$nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field(
298
+			$this->_req_data['get_newsletter_form_content_nonce']
299
+		) : '';
300
+		$nonce_ref = 'get_newsletter_form_content_nonce';
301
+		$this->_verify_nonce($nonce, $nonce_ref);
302
+		// let's get the mtp for the incoming MTP_ ID
303
+		if (! isset($this->_req_data['GRP_ID'])) {
304
+			EE_Error::add_error(
305
+				esc_html__(
306
+					'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).',
307
+					'event_espresso'
308
+				),
309
+				__FILE__,
310
+				__FUNCTION__,
311
+				__LINE__
312
+			);
313
+			$this->_template_args['success'] = false;
314
+			$this->_template_args['error'] = true;
315
+			$this->_return_json();
316
+		}
317
+		$MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']);
318
+		if (! $MTPG instanceof EE_Message_Template_Group) {
319
+			EE_Error::add_error(
320
+				sprintf(
321
+					esc_html__(
322
+						'The GRP_ID given (%d) does not appear to have a corresponding row in the database.',
323
+						'event_espresso'
324
+					),
325
+					$this->_req_data['GRP_ID']
326
+				),
327
+				__FILE__,
328
+				__FUNCTION__,
329
+				__LINE__
330
+			);
331
+			$this->_template_args['success'] = false;
332
+			$this->_template_args['error'] = true;
333
+			$this->_return_json();
334
+		}
335
+		$MTPs = $MTPG->context_templates();
336
+		$MTPs = $MTPs['attendee'];
337
+		$template_fields = array();
338
+		/** @var EE_Message_Template $MTP */
339
+		foreach ($MTPs as $MTP) {
340
+			$field = $MTP->get('MTP_template_field');
341
+			if ($field === 'content') {
342
+				$content = $MTP->get('MTP_content');
343
+				if (! empty($content['newsletter_content'])) {
344
+					$template_fields['newsletter_content'] = $content['newsletter_content'];
345
+				}
346
+				continue;
347
+			}
348
+			$template_fields[ $MTP->get('MTP_template_field') ] = $MTP->get('MTP_content');
349
+		}
350
+		$this->_template_args['success'] = true;
351
+		$this->_template_args['error'] = false;
352
+		$this->_template_args['data'] = array(
353
+			'batch_message_from'    => isset($template_fields['from'])
354
+				? $template_fields['from']
355
+				: '',
356
+			'batch_message_subject' => isset($template_fields['subject'])
357
+				? $template_fields['subject']
358
+				: '',
359
+			'batch_message_content' => isset($template_fields['newsletter_content'])
360
+				? $template_fields['newsletter_content']
361
+				: '',
362
+		);
363
+		$this->_return_json();
364
+	}
365 365
 
366 366
 
367
-    /**
368
-     * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action
369
-     *
370
-     * @since 4.3.0
371
-     * @param EE_Admin_List_Table $list_table
372
-     * @return void
373
-     * @throws InvalidArgumentException
374
-     * @throws InvalidDataTypeException
375
-     * @throws InvalidInterfaceException
376
-     */
377
-    public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table)
378
-    {
379
-        if (! EE_Registry::instance()->CAP->current_user_can(
380
-            'ee_send_message',
381
-            'espresso_registrations_newsletter_selected_send'
382
-        )
383
-        ) {
384
-            return;
385
-        }
386
-        $routes_to_add_to = array(
387
-            'contact_list',
388
-            'event_registrations',
389
-            'default',
390
-        );
391
-        if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) {
392
-            if (($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id']))
393
-                || (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash')
394
-            ) {
395
-                echo '';
396
-            } else {
397
-                $button_text = sprintf(
398
-                    esc_html__('Send Batch Message (%s selected)', 'event_espresso'),
399
-                    '<span class="send-selected-newsletter-count">0</span>'
400
-                );
401
-                echo '<button id="selected-batch-send-trigger" class="button secondary-button">'
402
-                     . '<span class="dashicons dashicons-email "></span>'
403
-                     . $button_text
404
-                     . '</button>';
405
-                add_action('admin_footer', array($this, 'newsletter_send_form_skeleton'));
406
-            }
407
-        }
408
-    }
367
+	/**
368
+	 * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action
369
+	 *
370
+	 * @since 4.3.0
371
+	 * @param EE_Admin_List_Table $list_table
372
+	 * @return void
373
+	 * @throws InvalidArgumentException
374
+	 * @throws InvalidDataTypeException
375
+	 * @throws InvalidInterfaceException
376
+	 */
377
+	public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table)
378
+	{
379
+		if (! EE_Registry::instance()->CAP->current_user_can(
380
+			'ee_send_message',
381
+			'espresso_registrations_newsletter_selected_send'
382
+		)
383
+		) {
384
+			return;
385
+		}
386
+		$routes_to_add_to = array(
387
+			'contact_list',
388
+			'event_registrations',
389
+			'default',
390
+		);
391
+		if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) {
392
+			if (($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id']))
393
+				|| (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash')
394
+			) {
395
+				echo '';
396
+			} else {
397
+				$button_text = sprintf(
398
+					esc_html__('Send Batch Message (%s selected)', 'event_espresso'),
399
+					'<span class="send-selected-newsletter-count">0</span>'
400
+				);
401
+				echo '<button id="selected-batch-send-trigger" class="button secondary-button">'
402
+					 . '<span class="dashicons dashicons-email "></span>'
403
+					 . $button_text
404
+					 . '</button>';
405
+				add_action('admin_footer', array($this, 'newsletter_send_form_skeleton'));
406
+			}
407
+		}
408
+	}
409 409
 
410 410
 
411
-    /**
412
-     * @throws DomainException
413
-     * @throws EE_Error
414
-     * @throws InvalidArgumentException
415
-     * @throws InvalidDataTypeException
416
-     * @throws InvalidInterfaceException
417
-     */
418
-    public function newsletter_send_form_skeleton()
419
-    {
420
-        $list_table = $this->_list_table_object;
421
-        $codes = array();
422
-        // need to templates for the newsletter message type for the template selector.
423
-        $values[] = array('text' => esc_html__('Select Template to Use', 'event_espresso'), 'id' => 0);
424
-        $mtps = EEM_Message_Template_Group::instance()->get_all(
425
-            array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email'))
426
-        );
427
-        foreach ($mtps as $mtp) {
428
-            $name = $mtp->name();
429
-            $values[] = array(
430
-                'text' => empty($name) ? esc_html__('Global', 'event_espresso') : $name,
431
-                'id'   => $mtp->ID(),
432
-            );
433
-        }
434
-        // need to get a list of shortcodes that are available for the newsletter message type.
435
-        $shortcodes = EEH_MSG_Template::get_shortcodes(
436
-            'newsletter',
437
-            'email',
438
-            array(),
439
-            'attendee',
440
-            false
441
-        );
442
-        foreach ($shortcodes as $field => $shortcode_array) {
443
-            $available_shortcodes = array();
444
-            foreach ($shortcode_array as $shortcode => $shortcode_details) {
445
-                $field_id = $field === '[NEWSLETTER_CONTENT]'
446
-                    ? 'content'
447
-                    : $field;
448
-                $field_id = 'batch-message-' . strtolower($field_id);
449
-                $available_shortcodes[] = '<span class="js-shortcode-selection" data-value="'
450
-                                          . $shortcode
451
-                                          . '" data-linked-input-id="' . $field_id . '">'
452
-                                          . $shortcode
453
-                                          . '</span>';
454
-            }
455
-            $codes[ $field ] = implode(', ', $available_shortcodes);
456
-        }
457
-        $shortcodes = $codes;
458
-        $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php';
459
-        $form_template_args = array(
460
-            'form_action'       => admin_url('admin.php?page=espresso_registrations'),
461
-            'form_route'        => 'newsletter_selected_send',
462
-            'form_nonce_name'   => 'newsletter_selected_send_nonce',
463
-            'form_nonce'        => wp_create_nonce('newsletter_selected_send_nonce'),
464
-            'redirect_back_to'  => $this->_req_action,
465
-            'ajax_nonce'        => wp_create_nonce('get_newsletter_form_content_nonce'),
466
-            'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values),
467
-            'shortcodes'        => $shortcodes,
468
-            'id_type'           => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration',
469
-        );
470
-        EEH_Template::display_template($form_template, $form_template_args);
471
-    }
411
+	/**
412
+	 * @throws DomainException
413
+	 * @throws EE_Error
414
+	 * @throws InvalidArgumentException
415
+	 * @throws InvalidDataTypeException
416
+	 * @throws InvalidInterfaceException
417
+	 */
418
+	public function newsletter_send_form_skeleton()
419
+	{
420
+		$list_table = $this->_list_table_object;
421
+		$codes = array();
422
+		// need to templates for the newsletter message type for the template selector.
423
+		$values[] = array('text' => esc_html__('Select Template to Use', 'event_espresso'), 'id' => 0);
424
+		$mtps = EEM_Message_Template_Group::instance()->get_all(
425
+			array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email'))
426
+		);
427
+		foreach ($mtps as $mtp) {
428
+			$name = $mtp->name();
429
+			$values[] = array(
430
+				'text' => empty($name) ? esc_html__('Global', 'event_espresso') : $name,
431
+				'id'   => $mtp->ID(),
432
+			);
433
+		}
434
+		// need to get a list of shortcodes that are available for the newsletter message type.
435
+		$shortcodes = EEH_MSG_Template::get_shortcodes(
436
+			'newsletter',
437
+			'email',
438
+			array(),
439
+			'attendee',
440
+			false
441
+		);
442
+		foreach ($shortcodes as $field => $shortcode_array) {
443
+			$available_shortcodes = array();
444
+			foreach ($shortcode_array as $shortcode => $shortcode_details) {
445
+				$field_id = $field === '[NEWSLETTER_CONTENT]'
446
+					? 'content'
447
+					: $field;
448
+				$field_id = 'batch-message-' . strtolower($field_id);
449
+				$available_shortcodes[] = '<span class="js-shortcode-selection" data-value="'
450
+										  . $shortcode
451
+										  . '" data-linked-input-id="' . $field_id . '">'
452
+										  . $shortcode
453
+										  . '</span>';
454
+			}
455
+			$codes[ $field ] = implode(', ', $available_shortcodes);
456
+		}
457
+		$shortcodes = $codes;
458
+		$form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php';
459
+		$form_template_args = array(
460
+			'form_action'       => admin_url('admin.php?page=espresso_registrations'),
461
+			'form_route'        => 'newsletter_selected_send',
462
+			'form_nonce_name'   => 'newsletter_selected_send_nonce',
463
+			'form_nonce'        => wp_create_nonce('newsletter_selected_send_nonce'),
464
+			'redirect_back_to'  => $this->_req_action,
465
+			'ajax_nonce'        => wp_create_nonce('get_newsletter_form_content_nonce'),
466
+			'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values),
467
+			'shortcodes'        => $shortcodes,
468
+			'id_type'           => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration',
469
+		);
470
+		EEH_Template::display_template($form_template, $form_template_args);
471
+	}
472 472
 
473 473
 
474
-    /**
475
-     * Handles sending selected registrations/contacts a newsletter.
476
-     *
477
-     * @since  4.3.0
478
-     * @return void
479
-     * @throws EE_Error
480
-     * @throws InvalidArgumentException
481
-     * @throws InvalidDataTypeException
482
-     * @throws InvalidInterfaceException
483
-     */
484
-    protected function _newsletter_selected_send()
485
-    {
486
-        $success = true;
487
-        // first we need to make sure we have a GRP_ID so we know what template we're sending and updating!
488
-        if (empty($this->_req_data['newsletter_mtp_selected'])) {
489
-            EE_Error::add_error(
490
-                esc_html__(
491
-                    'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.',
492
-                    'event_espresso'
493
-                ),
494
-                __FILE__,
495
-                __FUNCTION__,
496
-                __LINE__
497
-            );
498
-            $success = false;
499
-        }
500
-        if ($success) {
501
-            // update Message template in case there are any changes
502
-            $Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID(
503
-                $this->_req_data['newsletter_mtp_selected']
504
-            );
505
-            $Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group
506
-                ? $Message_Template_Group->context_templates()
507
-                : array();
508
-            if (empty($Message_Templates)) {
509
-                EE_Error::add_error(
510
-                    esc_html__(
511
-                        'Unable to retrieve message template fields from the db. Messages not sent.',
512
-                        'event_espresso'
513
-                    ),
514
-                    __FILE__,
515
-                    __FUNCTION__,
516
-                    __LINE__
517
-                );
518
-            }
519
-            // let's just update the specific fields
520
-            foreach ($Message_Templates['attendee'] as $Message_Template) {
521
-                if ($Message_Template instanceof EE_Message_Template) {
522
-                    $field = $Message_Template->get('MTP_template_field');
523
-                    $content = $Message_Template->get('MTP_content');
524
-                    $new_content = $content;
525
-                    switch ($field) {
526
-                        case 'from':
527
-                            $new_content = ! empty($this->_req_data['batch_message']['from'])
528
-                                ? $this->_req_data['batch_message']['from']
529
-                                : $content;
530
-                            break;
531
-                        case 'subject':
532
-                            $new_content = ! empty($this->_req_data['batch_message']['subject'])
533
-                                ? $this->_req_data['batch_message']['subject']
534
-                                : $content;
535
-                            break;
536
-                        case 'content':
537
-                            $new_content = $content;
538
-                            $new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content'])
539
-                                ? $this->_req_data['batch_message']['content']
540
-                                : $content['newsletter_content'];
541
-                            break;
542
-                        default:
543
-                            // continue the foreach loop, we don't want to set $new_content nor save.
544
-                            continue 2;
545
-                    }
546
-                    $Message_Template->set('MTP_content', $new_content);
547
-                    $Message_Template->save();
548
-                }
549
-            }
550
-            // great fields are updated!  now let's make sure we just have contact objects (EE_Attendee).
551
-            $id_type = ! empty($this->_req_data['batch_message']['id_type'])
552
-                ? $this->_req_data['batch_message']['id_type']
553
-                : 'registration';
554
-            // id_type will affect how we assemble the ids.
555
-            $ids = ! empty($this->_req_data['batch_message']['ids'])
556
-                ? json_decode(stripslashes($this->_req_data['batch_message']['ids']))
557
-                : array();
558
-            $registrations_used_for_contact_data = array();
559
-            // using switch because eventually we'll have other contexts that will be used for generating messages.
560
-            switch ($id_type) {
561
-                case 'registration':
562
-                    $registrations_used_for_contact_data = EEM_Registration::instance()->get_all(
563
-                        array(
564
-                            array(
565
-                                'REG_ID' => array('IN', $ids),
566
-                            ),
567
-                        )
568
-                    );
569
-                    break;
570
-                case 'contact':
571
-                    $registrations_used_for_contact_data = EEM_Registration::instance()
572
-                                                                           ->get_latest_registration_for_each_of_given_contacts(
573
-                                                                               $ids
574
-                                                                           );
575
-                    break;
576
-            }
577
-            do_action_ref_array(
578
-                'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations',
579
-                array(
580
-                    $registrations_used_for_contact_data,
581
-                    $Message_Template_Group->ID(),
582
-                )
583
-            );
584
-            // kept for backward compat, internally we no longer use this action.
585
-            // @deprecated 4.8.36.rc.002
586
-            $contacts = $id_type === 'registration'
587
-                ? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids)
588
-                : EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids))));
589
-            do_action_ref_array(
590
-                'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send',
591
-                array(
592
-                    $contacts,
593
-                    $Message_Template_Group->ID(),
594
-                )
595
-            );
596
-        }
597
-        $query_args = array(
598
-            'action' => ! empty($this->_req_data['redirect_back_to'])
599
-                ? $this->_req_data['redirect_back_to']
600
-                : 'default',
601
-        );
602
-        $this->_redirect_after_action(false, '', '', $query_args, true);
603
-    }
474
+	/**
475
+	 * Handles sending selected registrations/contacts a newsletter.
476
+	 *
477
+	 * @since  4.3.0
478
+	 * @return void
479
+	 * @throws EE_Error
480
+	 * @throws InvalidArgumentException
481
+	 * @throws InvalidDataTypeException
482
+	 * @throws InvalidInterfaceException
483
+	 */
484
+	protected function _newsletter_selected_send()
485
+	{
486
+		$success = true;
487
+		// first we need to make sure we have a GRP_ID so we know what template we're sending and updating!
488
+		if (empty($this->_req_data['newsletter_mtp_selected'])) {
489
+			EE_Error::add_error(
490
+				esc_html__(
491
+					'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.',
492
+					'event_espresso'
493
+				),
494
+				__FILE__,
495
+				__FUNCTION__,
496
+				__LINE__
497
+			);
498
+			$success = false;
499
+		}
500
+		if ($success) {
501
+			// update Message template in case there are any changes
502
+			$Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID(
503
+				$this->_req_data['newsletter_mtp_selected']
504
+			);
505
+			$Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group
506
+				? $Message_Template_Group->context_templates()
507
+				: array();
508
+			if (empty($Message_Templates)) {
509
+				EE_Error::add_error(
510
+					esc_html__(
511
+						'Unable to retrieve message template fields from the db. Messages not sent.',
512
+						'event_espresso'
513
+					),
514
+					__FILE__,
515
+					__FUNCTION__,
516
+					__LINE__
517
+				);
518
+			}
519
+			// let's just update the specific fields
520
+			foreach ($Message_Templates['attendee'] as $Message_Template) {
521
+				if ($Message_Template instanceof EE_Message_Template) {
522
+					$field = $Message_Template->get('MTP_template_field');
523
+					$content = $Message_Template->get('MTP_content');
524
+					$new_content = $content;
525
+					switch ($field) {
526
+						case 'from':
527
+							$new_content = ! empty($this->_req_data['batch_message']['from'])
528
+								? $this->_req_data['batch_message']['from']
529
+								: $content;
530
+							break;
531
+						case 'subject':
532
+							$new_content = ! empty($this->_req_data['batch_message']['subject'])
533
+								? $this->_req_data['batch_message']['subject']
534
+								: $content;
535
+							break;
536
+						case 'content':
537
+							$new_content = $content;
538
+							$new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content'])
539
+								? $this->_req_data['batch_message']['content']
540
+								: $content['newsletter_content'];
541
+							break;
542
+						default:
543
+							// continue the foreach loop, we don't want to set $new_content nor save.
544
+							continue 2;
545
+					}
546
+					$Message_Template->set('MTP_content', $new_content);
547
+					$Message_Template->save();
548
+				}
549
+			}
550
+			// great fields are updated!  now let's make sure we just have contact objects (EE_Attendee).
551
+			$id_type = ! empty($this->_req_data['batch_message']['id_type'])
552
+				? $this->_req_data['batch_message']['id_type']
553
+				: 'registration';
554
+			// id_type will affect how we assemble the ids.
555
+			$ids = ! empty($this->_req_data['batch_message']['ids'])
556
+				? json_decode(stripslashes($this->_req_data['batch_message']['ids']))
557
+				: array();
558
+			$registrations_used_for_contact_data = array();
559
+			// using switch because eventually we'll have other contexts that will be used for generating messages.
560
+			switch ($id_type) {
561
+				case 'registration':
562
+					$registrations_used_for_contact_data = EEM_Registration::instance()->get_all(
563
+						array(
564
+							array(
565
+								'REG_ID' => array('IN', $ids),
566
+							),
567
+						)
568
+					);
569
+					break;
570
+				case 'contact':
571
+					$registrations_used_for_contact_data = EEM_Registration::instance()
572
+																		   ->get_latest_registration_for_each_of_given_contacts(
573
+																			   $ids
574
+																		   );
575
+					break;
576
+			}
577
+			do_action_ref_array(
578
+				'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations',
579
+				array(
580
+					$registrations_used_for_contact_data,
581
+					$Message_Template_Group->ID(),
582
+				)
583
+			);
584
+			// kept for backward compat, internally we no longer use this action.
585
+			// @deprecated 4.8.36.rc.002
586
+			$contacts = $id_type === 'registration'
587
+				? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids)
588
+				: EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids))));
589
+			do_action_ref_array(
590
+				'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send',
591
+				array(
592
+					$contacts,
593
+					$Message_Template_Group->ID(),
594
+				)
595
+			);
596
+		}
597
+		$query_args = array(
598
+			'action' => ! empty($this->_req_data['redirect_back_to'])
599
+				? $this->_req_data['redirect_back_to']
600
+				: 'default',
601
+		);
602
+		$this->_redirect_after_action(false, '', '', $query_args, true);
603
+	}
604 604
 
605 605
 
606
-    /**
607
-     * This is called when javascript is being enqueued to setup the various data needed for the reports js.
608
-     * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method.
609
-     */
610
-    protected function _registration_reports_js_setup()
611
-    {
612
-        $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report();
613
-        $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report();
614
-    }
606
+	/**
607
+	 * This is called when javascript is being enqueued to setup the various data needed for the reports js.
608
+	 * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method.
609
+	 */
610
+	protected function _registration_reports_js_setup()
611
+	{
612
+		$this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report();
613
+		$this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report();
614
+	}
615 615
 
616 616
 
617
-    /**
618
-     *        generates Business Reports regarding Registrations
619
-     *
620
-     * @access protected
621
-     * @return void
622
-     * @throws DomainException
623
-     */
624
-    protected function _registration_reports()
625
-    {
626
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
627
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
628
-            $template_path,
629
-            $this->_reports_template_data,
630
-            true
631
-        );
632
-        // the final template wrapper
633
-        $this->display_admin_page_with_no_sidebar();
634
-    }
617
+	/**
618
+	 *        generates Business Reports regarding Registrations
619
+	 *
620
+	 * @access protected
621
+	 * @return void
622
+	 * @throws DomainException
623
+	 */
624
+	protected function _registration_reports()
625
+	{
626
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
627
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
628
+			$template_path,
629
+			$this->_reports_template_data,
630
+			true
631
+		);
632
+		// the final template wrapper
633
+		$this->display_admin_page_with_no_sidebar();
634
+	}
635 635
 
636 636
 
637
-    /**
638
-     * Generates Business Report showing total registrations per day.
639
-     *
640
-     * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
641
-     * @return string
642
-     * @throws EE_Error
643
-     * @throws InvalidArgumentException
644
-     * @throws InvalidDataTypeException
645
-     * @throws InvalidInterfaceException
646
-     */
647
-    private function _registrations_per_day_report($period = '-1 month')
648
-    {
649
-        $report_ID = 'reg-admin-registrations-per-day-report-dv';
650
-        $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period);
651
-        $results = (array) $results;
652
-        $regs = array();
653
-        $subtitle = '';
654
-        if ($results) {
655
-            $column_titles = array();
656
-            $tracker = 0;
657
-            foreach ($results as $result) {
658
-                $report_column_values = array();
659
-                foreach ($result as $property_name => $property_value) {
660
-                    $property_value = $property_name === 'Registration_REG_date' ? $property_value
661
-                        : (int) $property_value;
662
-                    $report_column_values[] = $property_value;
663
-                    if ($tracker === 0) {
664
-                        if ($property_name === 'Registration_REG_date') {
665
-                            $column_titles[] = esc_html__(
666
-                                'Date (only days with registrations are shown)',
667
-                                'event_espresso'
668
-                            );
669
-                        } else {
670
-                            $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
671
-                        }
672
-                    }
673
-                }
674
-                $tracker++;
675
-                $regs[] = $report_column_values;
676
-            }
677
-            // make sure the column_titles is pushed to the beginning of the array
678
-            array_unshift($regs, $column_titles);
679
-            // setup the date range.
680
-            $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
681
-            $beginning_date = new DateTime("now " . $period, $DateTimeZone);
682
-            $ending_date = new DateTime("now", $DateTimeZone);
683
-            $subtitle = sprintf(
684
-                _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'),
685
-                $beginning_date->format('Y-m-d'),
686
-                $ending_date->format('Y-m-d')
687
-            );
688
-        }
689
-        $report_title = esc_html__('Total Registrations per Day', 'event_espresso');
690
-        $report_params = array(
691
-            'title'     => $report_title,
692
-            'subtitle'  => $subtitle,
693
-            'id'        => $report_ID,
694
-            'regs'      => $regs,
695
-            'noResults' => empty($regs),
696
-            'noRegsMsg' => sprintf(
697
-                esc_html__(
698
-                    '%sThere are currently no registration records in the last month for this report.%s',
699
-                    'event_espresso'
700
-                ),
701
-                '<h2>' . $report_title . '</h2><p>',
702
-                '</p>'
703
-            ),
704
-        );
705
-        wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params);
706
-        return $report_ID;
707
-    }
637
+	/**
638
+	 * Generates Business Report showing total registrations per day.
639
+	 *
640
+	 * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
641
+	 * @return string
642
+	 * @throws EE_Error
643
+	 * @throws InvalidArgumentException
644
+	 * @throws InvalidDataTypeException
645
+	 * @throws InvalidInterfaceException
646
+	 */
647
+	private function _registrations_per_day_report($period = '-1 month')
648
+	{
649
+		$report_ID = 'reg-admin-registrations-per-day-report-dv';
650
+		$results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period);
651
+		$results = (array) $results;
652
+		$regs = array();
653
+		$subtitle = '';
654
+		if ($results) {
655
+			$column_titles = array();
656
+			$tracker = 0;
657
+			foreach ($results as $result) {
658
+				$report_column_values = array();
659
+				foreach ($result as $property_name => $property_value) {
660
+					$property_value = $property_name === 'Registration_REG_date' ? $property_value
661
+						: (int) $property_value;
662
+					$report_column_values[] = $property_value;
663
+					if ($tracker === 0) {
664
+						if ($property_name === 'Registration_REG_date') {
665
+							$column_titles[] = esc_html__(
666
+								'Date (only days with registrations are shown)',
667
+								'event_espresso'
668
+							);
669
+						} else {
670
+							$column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
671
+						}
672
+					}
673
+				}
674
+				$tracker++;
675
+				$regs[] = $report_column_values;
676
+			}
677
+			// make sure the column_titles is pushed to the beginning of the array
678
+			array_unshift($regs, $column_titles);
679
+			// setup the date range.
680
+			$DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
681
+			$beginning_date = new DateTime("now " . $period, $DateTimeZone);
682
+			$ending_date = new DateTime("now", $DateTimeZone);
683
+			$subtitle = sprintf(
684
+				_x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'),
685
+				$beginning_date->format('Y-m-d'),
686
+				$ending_date->format('Y-m-d')
687
+			);
688
+		}
689
+		$report_title = esc_html__('Total Registrations per Day', 'event_espresso');
690
+		$report_params = array(
691
+			'title'     => $report_title,
692
+			'subtitle'  => $subtitle,
693
+			'id'        => $report_ID,
694
+			'regs'      => $regs,
695
+			'noResults' => empty($regs),
696
+			'noRegsMsg' => sprintf(
697
+				esc_html__(
698
+					'%sThere are currently no registration records in the last month for this report.%s',
699
+					'event_espresso'
700
+				),
701
+				'<h2>' . $report_title . '</h2><p>',
702
+				'</p>'
703
+			),
704
+		);
705
+		wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params);
706
+		return $report_ID;
707
+	}
708 708
 
709 709
 
710
-    /**
711
-     * Generates Business Report showing total registrations per event.
712
-     *
713
-     * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
714
-     * @return string
715
-     * @throws EE_Error
716
-     * @throws InvalidArgumentException
717
-     * @throws InvalidDataTypeException
718
-     * @throws InvalidInterfaceException
719
-     */
720
-    private function _registrations_per_event_report($period = '-1 month')
721
-    {
722
-        $report_ID = 'reg-admin-registrations-per-event-report-dv';
723
-        $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period);
724
-        $results = (array) $results;
725
-        $regs = array();
726
-        $subtitle = '';
727
-        if ($results) {
728
-            $column_titles = array();
729
-            $tracker = 0;
730
-            foreach ($results as $result) {
731
-                $report_column_values = array();
732
-                foreach ($result as $property_name => $property_value) {
733
-                    $property_value = $property_name === 'Registration_Event' ? wp_trim_words(
734
-                        $property_value,
735
-                        4,
736
-                        '...'
737
-                    ) : (int) $property_value;
738
-                    $report_column_values[] = $property_value;
739
-                    if ($tracker === 0) {
740
-                        if ($property_name === 'Registration_Event') {
741
-                            $column_titles[] = esc_html__('Event', 'event_espresso');
742
-                        } else {
743
-                            $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
744
-                        }
745
-                    }
746
-                }
747
-                $tracker++;
748
-                $regs[] = $report_column_values;
749
-            }
750
-            // make sure the column_titles is pushed to the beginning of the array
751
-            array_unshift($regs, $column_titles);
752
-            // setup the date range.
753
-            $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
754
-            $beginning_date = new DateTime("now " . $period, $DateTimeZone);
755
-            $ending_date = new DateTime("now", $DateTimeZone);
756
-            $subtitle = sprintf(
757
-                _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'),
758
-                $beginning_date->format('Y-m-d'),
759
-                $ending_date->format('Y-m-d')
760
-            );
761
-        }
762
-        $report_title = esc_html__('Total Registrations per Event', 'event_espresso');
763
-        $report_params = array(
764
-            'title'     => $report_title,
765
-            'subtitle'  => $subtitle,
766
-            'id'        => $report_ID,
767
-            'regs'      => $regs,
768
-            'noResults' => empty($regs),
769
-            'noRegsMsg' => sprintf(
770
-                esc_html__(
771
-                    '%sThere are currently no registration records in the last month for this report.%s',
772
-                    'event_espresso'
773
-                ),
774
-                '<h2>' . $report_title . '</h2><p>',
775
-                '</p>'
776
-            ),
777
-        );
778
-        wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params);
779
-        return $report_ID;
780
-    }
710
+	/**
711
+	 * Generates Business Report showing total registrations per event.
712
+	 *
713
+	 * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
714
+	 * @return string
715
+	 * @throws EE_Error
716
+	 * @throws InvalidArgumentException
717
+	 * @throws InvalidDataTypeException
718
+	 * @throws InvalidInterfaceException
719
+	 */
720
+	private function _registrations_per_event_report($period = '-1 month')
721
+	{
722
+		$report_ID = 'reg-admin-registrations-per-event-report-dv';
723
+		$results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period);
724
+		$results = (array) $results;
725
+		$regs = array();
726
+		$subtitle = '';
727
+		if ($results) {
728
+			$column_titles = array();
729
+			$tracker = 0;
730
+			foreach ($results as $result) {
731
+				$report_column_values = array();
732
+				foreach ($result as $property_name => $property_value) {
733
+					$property_value = $property_name === 'Registration_Event' ? wp_trim_words(
734
+						$property_value,
735
+						4,
736
+						'...'
737
+					) : (int) $property_value;
738
+					$report_column_values[] = $property_value;
739
+					if ($tracker === 0) {
740
+						if ($property_name === 'Registration_Event') {
741
+							$column_titles[] = esc_html__('Event', 'event_espresso');
742
+						} else {
743
+							$column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
744
+						}
745
+					}
746
+				}
747
+				$tracker++;
748
+				$regs[] = $report_column_values;
749
+			}
750
+			// make sure the column_titles is pushed to the beginning of the array
751
+			array_unshift($regs, $column_titles);
752
+			// setup the date range.
753
+			$DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
754
+			$beginning_date = new DateTime("now " . $period, $DateTimeZone);
755
+			$ending_date = new DateTime("now", $DateTimeZone);
756
+			$subtitle = sprintf(
757
+				_x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'),
758
+				$beginning_date->format('Y-m-d'),
759
+				$ending_date->format('Y-m-d')
760
+			);
761
+		}
762
+		$report_title = esc_html__('Total Registrations per Event', 'event_espresso');
763
+		$report_params = array(
764
+			'title'     => $report_title,
765
+			'subtitle'  => $subtitle,
766
+			'id'        => $report_ID,
767
+			'regs'      => $regs,
768
+			'noResults' => empty($regs),
769
+			'noRegsMsg' => sprintf(
770
+				esc_html__(
771
+					'%sThere are currently no registration records in the last month for this report.%s',
772
+					'event_espresso'
773
+				),
774
+				'<h2>' . $report_title . '</h2><p>',
775
+				'</p>'
776
+			),
777
+		);
778
+		wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params);
779
+		return $report_ID;
780
+	}
781 781
 
782 782
 
783
-    /**
784
-     * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration)
785
-     *
786
-     * @access protected
787
-     * @return void
788
-     * @throws EE_Error
789
-     * @throws InvalidArgumentException
790
-     * @throws InvalidDataTypeException
791
-     * @throws InvalidInterfaceException
792
-     * @throws \EventEspresso\core\exceptions\EntityNotFoundException
793
-     */
794
-    protected function _registration_checkin_list_table()
795
-    {
796
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
797
-        $reg_id = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : null;
798
-        /** @var EE_Registration $registration */
799
-        $registration = EEM_Registration::instance()->get_one_by_ID($reg_id);
800
-        if (! $registration instanceof EE_Registration) {
801
-            throw new EE_Error(
802
-                sprintf(
803
-                    esc_html__('An error occurred. There is no registration with ID (%d)', 'event_espresso'),
804
-                    $reg_id
805
-                )
806
-            );
807
-        }
808
-        $attendee = $registration->attendee();
809
-        $this->_admin_page_title .= $this->get_action_link_or_button(
810
-            'new_registration',
811
-            'add-registrant',
812
-            array('event_id' => $registration->event_ID()),
813
-            'add-new-h2'
814
-        );
815
-        $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in);
816
-        $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out);
817
-        $legend_items = array(
818
-            'checkin'  => array(
819
-                'class' => $checked_in->cssClasses(),
820
-                'desc'  => $checked_in->legendLabel(),
821
-            ),
822
-            'checkout' => array(
823
-                'class' => $checked_out->cssClasses(),
824
-                'desc'  => $checked_out->legendLabel(),
825
-            ),
826
-        );
827
-        $this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
828
-        $dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
829
-        /** @var EE_Datetime $datetime */
830
-        $datetime = EEM_Datetime::instance()->get_one_by_ID($dtt_id);
831
-        $datetime_label = '';
832
-        if ($datetime instanceof EE_Datetime) {
833
-            $datetime_label = $datetime->get_dtt_display_name(true);
834
-            $datetime_label .= ! empty($datetime_label)
835
-                ? ' (' . $datetime->get_dtt_display_name() . ')'
836
-                : $datetime->get_dtt_display_name();
837
-        }
838
-        $datetime_link = ! empty($dtt_id) && $registration instanceof EE_Registration
839
-            ? EE_Admin_Page::add_query_args_and_nonce(
840
-                array(
841
-                    'action'   => 'event_registrations',
842
-                    'event_id' => $registration->event_ID(),
843
-                    'DTT_ID'   => $dtt_id,
844
-                ),
845
-                $this->_admin_base_url
846
-            )
847
-            : '';
848
-        $datetime_link = ! empty($datetime_link)
849
-            ? '<a href="' . $datetime_link . '">'
850
-              . '<span id="checkin-dtt">'
851
-              . $datetime_label
852
-              . '</span></a>'
853
-            : $datetime_label;
854
-        $attendee_name = $attendee instanceof EE_Attendee
855
-            ? $attendee->full_name()
856
-            : '';
857
-        $attendee_link = $attendee instanceof EE_Attendee
858
-            ? $attendee->get_admin_details_link()
859
-            : '';
860
-        $attendee_link = ! empty($attendee_link)
861
-            ? '<a href="' . $attendee->get_admin_details_link() . '"'
862
-              . ' title="' . esc_html__('Click for attendee details', 'event_espresso') . '">'
863
-              . '<span id="checkin-attendee-name">'
864
-              . $attendee_name
865
-              . '</span></a>'
866
-            : '';
867
-        $event_link = $registration->event() instanceof EE_Event
868
-            ? $registration->event()->get_admin_details_link()
869
-            : '';
870
-        $event_link = ! empty($event_link)
871
-            ? '<a href="' . $event_link . '"'
872
-              . ' title="' . esc_html__('Click here to edit event.', 'event_espresso') . '">'
873
-              . '<span id="checkin-event-name">'
874
-              . $registration->event_name()
875
-              . '</span>'
876
-              . '</a>'
877
-            : '';
878
-        $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id)
879
-            ? '<h2>' . sprintf(
880
-                esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'),
881
-                $attendee_link,
882
-                $datetime_link,
883
-                $event_link
884
-            ) . '</h2>'
885
-            : '';
886
-        $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id)
887
-            ? '<input type="hidden" name="_REG_ID" value="' . $reg_id . '">' : '';
888
-        $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id)
889
-            ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : '';
890
-        $this->display_admin_list_table_page_with_no_sidebar();
891
-    }
783
+	/**
784
+	 * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration)
785
+	 *
786
+	 * @access protected
787
+	 * @return void
788
+	 * @throws EE_Error
789
+	 * @throws InvalidArgumentException
790
+	 * @throws InvalidDataTypeException
791
+	 * @throws InvalidInterfaceException
792
+	 * @throws \EventEspresso\core\exceptions\EntityNotFoundException
793
+	 */
794
+	protected function _registration_checkin_list_table()
795
+	{
796
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
797
+		$reg_id = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : null;
798
+		/** @var EE_Registration $registration */
799
+		$registration = EEM_Registration::instance()->get_one_by_ID($reg_id);
800
+		if (! $registration instanceof EE_Registration) {
801
+			throw new EE_Error(
802
+				sprintf(
803
+					esc_html__('An error occurred. There is no registration with ID (%d)', 'event_espresso'),
804
+					$reg_id
805
+				)
806
+			);
807
+		}
808
+		$attendee = $registration->attendee();
809
+		$this->_admin_page_title .= $this->get_action_link_or_button(
810
+			'new_registration',
811
+			'add-registrant',
812
+			array('event_id' => $registration->event_ID()),
813
+			'add-new-h2'
814
+		);
815
+		$checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in);
816
+		$checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out);
817
+		$legend_items = array(
818
+			'checkin'  => array(
819
+				'class' => $checked_in->cssClasses(),
820
+				'desc'  => $checked_in->legendLabel(),
821
+			),
822
+			'checkout' => array(
823
+				'class' => $checked_out->cssClasses(),
824
+				'desc'  => $checked_out->legendLabel(),
825
+			),
826
+		);
827
+		$this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
828
+		$dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
829
+		/** @var EE_Datetime $datetime */
830
+		$datetime = EEM_Datetime::instance()->get_one_by_ID($dtt_id);
831
+		$datetime_label = '';
832
+		if ($datetime instanceof EE_Datetime) {
833
+			$datetime_label = $datetime->get_dtt_display_name(true);
834
+			$datetime_label .= ! empty($datetime_label)
835
+				? ' (' . $datetime->get_dtt_display_name() . ')'
836
+				: $datetime->get_dtt_display_name();
837
+		}
838
+		$datetime_link = ! empty($dtt_id) && $registration instanceof EE_Registration
839
+			? EE_Admin_Page::add_query_args_and_nonce(
840
+				array(
841
+					'action'   => 'event_registrations',
842
+					'event_id' => $registration->event_ID(),
843
+					'DTT_ID'   => $dtt_id,
844
+				),
845
+				$this->_admin_base_url
846
+			)
847
+			: '';
848
+		$datetime_link = ! empty($datetime_link)
849
+			? '<a href="' . $datetime_link . '">'
850
+			  . '<span id="checkin-dtt">'
851
+			  . $datetime_label
852
+			  . '</span></a>'
853
+			: $datetime_label;
854
+		$attendee_name = $attendee instanceof EE_Attendee
855
+			? $attendee->full_name()
856
+			: '';
857
+		$attendee_link = $attendee instanceof EE_Attendee
858
+			? $attendee->get_admin_details_link()
859
+			: '';
860
+		$attendee_link = ! empty($attendee_link)
861
+			? '<a href="' . $attendee->get_admin_details_link() . '"'
862
+			  . ' title="' . esc_html__('Click for attendee details', 'event_espresso') . '">'
863
+			  . '<span id="checkin-attendee-name">'
864
+			  . $attendee_name
865
+			  . '</span></a>'
866
+			: '';
867
+		$event_link = $registration->event() instanceof EE_Event
868
+			? $registration->event()->get_admin_details_link()
869
+			: '';
870
+		$event_link = ! empty($event_link)
871
+			? '<a href="' . $event_link . '"'
872
+			  . ' title="' . esc_html__('Click here to edit event.', 'event_espresso') . '">'
873
+			  . '<span id="checkin-event-name">'
874
+			  . $registration->event_name()
875
+			  . '</span>'
876
+			  . '</a>'
877
+			: '';
878
+		$this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id)
879
+			? '<h2>' . sprintf(
880
+				esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'),
881
+				$attendee_link,
882
+				$datetime_link,
883
+				$event_link
884
+			) . '</h2>'
885
+			: '';
886
+		$this->_template_args['list_table_hidden_fields'] = ! empty($reg_id)
887
+			? '<input type="hidden" name="_REG_ID" value="' . $reg_id . '">' : '';
888
+		$this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id)
889
+			? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : '';
890
+		$this->display_admin_list_table_page_with_no_sidebar();
891
+	}
892 892
 
893 893
 
894
-    /**
895
-     * toggle the Check-in status for the given registration (coming from ajax)
896
-     *
897
-     * @return void (JSON)
898
-     * @throws EE_Error
899
-     * @throws InvalidArgumentException
900
-     * @throws InvalidDataTypeException
901
-     * @throws InvalidInterfaceException
902
-     */
903
-    public function toggle_checkin_status()
904
-    {
905
-        // first make sure we have the necessary data
906
-        if (! isset($this->_req_data['_regid'])) {
907
-            EE_Error::add_error(
908
-                esc_html__(
909
-                    'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax',
910
-                    'event_espresso'
911
-                ),
912
-                __FILE__,
913
-                __FUNCTION__,
914
-                __LINE__
915
-            );
916
-            $this->_template_args['success'] = false;
917
-            $this->_template_args['error'] = true;
918
-            $this->_return_json();
919
-        };
920
-        // do a nonce check cause we're not coming in from an normal route here.
921
-        $nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce'])
922
-            : '';
923
-        $nonce_ref = 'checkin_nonce';
924
-        $this->_verify_nonce($nonce, $nonce_ref);
925
-        // beautiful! Made it this far so let's get the status.
926
-        $new_status = new CheckinStatusDashicon($this->_toggle_checkin_status());
927
-        // setup new class to return via ajax
928
-        $this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses();
929
-        $this->_template_args['success'] = true;
930
-        $this->_return_json();
931
-    }
894
+	/**
895
+	 * toggle the Check-in status for the given registration (coming from ajax)
896
+	 *
897
+	 * @return void (JSON)
898
+	 * @throws EE_Error
899
+	 * @throws InvalidArgumentException
900
+	 * @throws InvalidDataTypeException
901
+	 * @throws InvalidInterfaceException
902
+	 */
903
+	public function toggle_checkin_status()
904
+	{
905
+		// first make sure we have the necessary data
906
+		if (! isset($this->_req_data['_regid'])) {
907
+			EE_Error::add_error(
908
+				esc_html__(
909
+					'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax',
910
+					'event_espresso'
911
+				),
912
+				__FILE__,
913
+				__FUNCTION__,
914
+				__LINE__
915
+			);
916
+			$this->_template_args['success'] = false;
917
+			$this->_template_args['error'] = true;
918
+			$this->_return_json();
919
+		};
920
+		// do a nonce check cause we're not coming in from an normal route here.
921
+		$nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce'])
922
+			: '';
923
+		$nonce_ref = 'checkin_nonce';
924
+		$this->_verify_nonce($nonce, $nonce_ref);
925
+		// beautiful! Made it this far so let's get the status.
926
+		$new_status = new CheckinStatusDashicon($this->_toggle_checkin_status());
927
+		// setup new class to return via ajax
928
+		$this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses();
929
+		$this->_template_args['success'] = true;
930
+		$this->_return_json();
931
+	}
932 932
 
933 933
 
934
-    /**
935
-     * handles toggling the checkin status for the registration,
936
-     *
937
-     * @access protected
938
-     * @return int|void
939
-     * @throws EE_Error
940
-     * @throws InvalidArgumentException
941
-     * @throws InvalidDataTypeException
942
-     * @throws InvalidInterfaceException
943
-     */
944
-    protected function _toggle_checkin_status()
945
-    {
946
-        // first let's get the query args out of the way for the redirect
947
-        $query_args = array(
948
-            'action'   => 'event_registrations',
949
-            'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null,
950
-            'DTT_ID'   => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null,
951
-        );
952
-        $new_status = false;
953
-        // bulk action check in toggle
954
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
955
-            // cycle thru checkboxes
956
-            while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) {
957
-                $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
958
-                $new_status = $this->_toggle_checkin($REG_ID, $DTT_ID);
959
-            }
960
-        } elseif (isset($this->_req_data['_regid'])) {
961
-            // coming from ajax request
962
-            $DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null;
963
-            $query_args['DTT_ID'] = $DTT_ID;
964
-            $new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID);
965
-        } else {
966
-            EE_Error::add_error(
967
-                esc_html__('Missing some required data to toggle the Check-in', 'event_espresso'),
968
-                __FILE__,
969
-                __FUNCTION__,
970
-                __LINE__
971
-            );
972
-        }
973
-        if (defined('DOING_AJAX')) {
974
-            return $new_status;
975
-        }
976
-        $this->_redirect_after_action(false, '', '', $query_args, true);
977
-    }
934
+	/**
935
+	 * handles toggling the checkin status for the registration,
936
+	 *
937
+	 * @access protected
938
+	 * @return int|void
939
+	 * @throws EE_Error
940
+	 * @throws InvalidArgumentException
941
+	 * @throws InvalidDataTypeException
942
+	 * @throws InvalidInterfaceException
943
+	 */
944
+	protected function _toggle_checkin_status()
945
+	{
946
+		// first let's get the query args out of the way for the redirect
947
+		$query_args = array(
948
+			'action'   => 'event_registrations',
949
+			'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null,
950
+			'DTT_ID'   => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null,
951
+		);
952
+		$new_status = false;
953
+		// bulk action check in toggle
954
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
955
+			// cycle thru checkboxes
956
+			while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) {
957
+				$DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
958
+				$new_status = $this->_toggle_checkin($REG_ID, $DTT_ID);
959
+			}
960
+		} elseif (isset($this->_req_data['_regid'])) {
961
+			// coming from ajax request
962
+			$DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null;
963
+			$query_args['DTT_ID'] = $DTT_ID;
964
+			$new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID);
965
+		} else {
966
+			EE_Error::add_error(
967
+				esc_html__('Missing some required data to toggle the Check-in', 'event_espresso'),
968
+				__FILE__,
969
+				__FUNCTION__,
970
+				__LINE__
971
+			);
972
+		}
973
+		if (defined('DOING_AJAX')) {
974
+			return $new_status;
975
+		}
976
+		$this->_redirect_after_action(false, '', '', $query_args, true);
977
+	}
978 978
 
979 979
 
980
-    /**
981
-     * This is toggles a single Check-in for the given registration and datetime.
982
-     *
983
-     * @param  int $REG_ID The registration we're toggling
984
-     * @param  int $DTT_ID The datetime we're toggling
985
-     * @return int The new status toggled to.
986
-     * @throws EE_Error
987
-     * @throws InvalidArgumentException
988
-     * @throws InvalidDataTypeException
989
-     * @throws InvalidInterfaceException
990
-     */
991
-    private function _toggle_checkin($REG_ID, $DTT_ID)
992
-    {
993
-        /** @var EE_Registration $REG */
994
-        $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID);
995
-        $new_status = $REG->toggle_checkin_status($DTT_ID);
996
-        if ($new_status !== false) {
997
-            EE_Error::add_success($REG->get_checkin_msg($DTT_ID));
998
-        } else {
999
-            EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__);
1000
-            $new_status = false;
1001
-        }
1002
-        return $new_status;
1003
-    }
980
+	/**
981
+	 * This is toggles a single Check-in for the given registration and datetime.
982
+	 *
983
+	 * @param  int $REG_ID The registration we're toggling
984
+	 * @param  int $DTT_ID The datetime we're toggling
985
+	 * @return int The new status toggled to.
986
+	 * @throws EE_Error
987
+	 * @throws InvalidArgumentException
988
+	 * @throws InvalidDataTypeException
989
+	 * @throws InvalidInterfaceException
990
+	 */
991
+	private function _toggle_checkin($REG_ID, $DTT_ID)
992
+	{
993
+		/** @var EE_Registration $REG */
994
+		$REG = EEM_Registration::instance()->get_one_by_ID($REG_ID);
995
+		$new_status = $REG->toggle_checkin_status($DTT_ID);
996
+		if ($new_status !== false) {
997
+			EE_Error::add_success($REG->get_checkin_msg($DTT_ID));
998
+		} else {
999
+			EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__);
1000
+			$new_status = false;
1001
+		}
1002
+		return $new_status;
1003
+	}
1004 1004
 
1005 1005
 
1006
-    /**
1007
-     * Takes care of deleting multiple EE_Checkin table rows
1008
-     *
1009
-     * @access protected
1010
-     * @return void
1011
-     * @throws EE_Error
1012
-     * @throws InvalidArgumentException
1013
-     * @throws InvalidDataTypeException
1014
-     * @throws InvalidInterfaceException
1015
-     */
1016
-    protected function _delete_checkin_rows()
1017
-    {
1018
-        $query_args = array(
1019
-            'action'  => 'registration_checkins',
1020
-            'DTT_ID'  => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1021
-            '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0,
1022
-        );
1023
-        $errors = 0;
1024
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1025
-            while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) {
1026
-                if (! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) {
1027
-                    $errors++;
1028
-                }
1029
-            }
1030
-        } else {
1031
-            EE_Error::add_error(
1032
-                esc_html__(
1033
-                    'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!',
1034
-                    'event_espresso'
1035
-                ),
1036
-                __FILE__,
1037
-                __FUNCTION__,
1038
-                __LINE__
1039
-            );
1040
-            $this->_redirect_after_action(false, '', '', $query_args, true);
1041
-        }
1042
-        if ($errors > 0) {
1043
-            EE_Error::add_error(
1044
-                sprintf(__('There were %d records that did not delete successfully', 'event_espresso'), $errors),
1045
-                __FILE__,
1046
-                __FUNCTION__,
1047
-                __LINE__
1048
-            );
1049
-        } else {
1050
-            EE_Error::add_success(__('Records were successfully deleted', 'event_espresso'));
1051
-        }
1052
-        $this->_redirect_after_action(false, '', '', $query_args, true);
1053
-    }
1006
+	/**
1007
+	 * Takes care of deleting multiple EE_Checkin table rows
1008
+	 *
1009
+	 * @access protected
1010
+	 * @return void
1011
+	 * @throws EE_Error
1012
+	 * @throws InvalidArgumentException
1013
+	 * @throws InvalidDataTypeException
1014
+	 * @throws InvalidInterfaceException
1015
+	 */
1016
+	protected function _delete_checkin_rows()
1017
+	{
1018
+		$query_args = array(
1019
+			'action'  => 'registration_checkins',
1020
+			'DTT_ID'  => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1021
+			'_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0,
1022
+		);
1023
+		$errors = 0;
1024
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1025
+			while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) {
1026
+				if (! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) {
1027
+					$errors++;
1028
+				}
1029
+			}
1030
+		} else {
1031
+			EE_Error::add_error(
1032
+				esc_html__(
1033
+					'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!',
1034
+					'event_espresso'
1035
+				),
1036
+				__FILE__,
1037
+				__FUNCTION__,
1038
+				__LINE__
1039
+			);
1040
+			$this->_redirect_after_action(false, '', '', $query_args, true);
1041
+		}
1042
+		if ($errors > 0) {
1043
+			EE_Error::add_error(
1044
+				sprintf(__('There were %d records that did not delete successfully', 'event_espresso'), $errors),
1045
+				__FILE__,
1046
+				__FUNCTION__,
1047
+				__LINE__
1048
+			);
1049
+		} else {
1050
+			EE_Error::add_success(__('Records were successfully deleted', 'event_espresso'));
1051
+		}
1052
+		$this->_redirect_after_action(false, '', '', $query_args, true);
1053
+	}
1054 1054
 
1055 1055
 
1056
-    /**
1057
-     * Deletes a single EE_Checkin row
1058
-     *
1059
-     * @return void
1060
-     * @throws EE_Error
1061
-     * @throws InvalidArgumentException
1062
-     * @throws InvalidDataTypeException
1063
-     * @throws InvalidInterfaceException
1064
-     */
1065
-    protected function _delete_checkin_row()
1066
-    {
1067
-        $query_args = array(
1068
-            'action'  => 'registration_checkins',
1069
-            'DTT_ID'  => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1070
-            '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0,
1071
-        );
1072
-        if (! empty($this->_req_data['CHK_ID'])) {
1073
-            if (! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) {
1074
-                EE_Error::add_error(
1075
-                    esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'),
1076
-                    __FILE__,
1077
-                    __FUNCTION__,
1078
-                    __LINE__
1079
-                );
1080
-            } else {
1081
-                EE_Error::add_success(__('Check-In record successfully deleted', 'event_espresso'));
1082
-            }
1083
-        } else {
1084
-            EE_Error::add_error(
1085
-                esc_html__(
1086
-                    'In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code',
1087
-                    'event_espresso'
1088
-                ),
1089
-                __FILE__,
1090
-                __FUNCTION__,
1091
-                __LINE__
1092
-            );
1093
-        }
1094
-        $this->_redirect_after_action(false, '', '', $query_args, true);
1095
-    }
1056
+	/**
1057
+	 * Deletes a single EE_Checkin row
1058
+	 *
1059
+	 * @return void
1060
+	 * @throws EE_Error
1061
+	 * @throws InvalidArgumentException
1062
+	 * @throws InvalidDataTypeException
1063
+	 * @throws InvalidInterfaceException
1064
+	 */
1065
+	protected function _delete_checkin_row()
1066
+	{
1067
+		$query_args = array(
1068
+			'action'  => 'registration_checkins',
1069
+			'DTT_ID'  => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1070
+			'_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0,
1071
+		);
1072
+		if (! empty($this->_req_data['CHK_ID'])) {
1073
+			if (! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) {
1074
+				EE_Error::add_error(
1075
+					esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'),
1076
+					__FILE__,
1077
+					__FUNCTION__,
1078
+					__LINE__
1079
+				);
1080
+			} else {
1081
+				EE_Error::add_success(__('Check-In record successfully deleted', 'event_espresso'));
1082
+			}
1083
+		} else {
1084
+			EE_Error::add_error(
1085
+				esc_html__(
1086
+					'In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code',
1087
+					'event_espresso'
1088
+				),
1089
+				__FILE__,
1090
+				__FUNCTION__,
1091
+				__LINE__
1092
+			);
1093
+		}
1094
+		$this->_redirect_after_action(false, '', '', $query_args, true);
1095
+	}
1096 1096
 
1097 1097
 
1098
-    /**
1099
-     *        generates HTML for the Event Registrations List Table
1100
-     *
1101
-     * @access protected
1102
-     * @return void
1103
-     * @throws EE_Error
1104
-     * @throws InvalidArgumentException
1105
-     * @throws InvalidDataTypeException
1106
-     * @throws InvalidInterfaceException
1107
-     */
1108
-    protected function _event_registrations_list_table()
1109
-    {
1110
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1111
-        $this->_admin_page_title .= isset($this->_req_data['event_id'])
1112
-            ? $this->get_action_link_or_button(
1113
-                'new_registration',
1114
-                'add-registrant',
1115
-                array('event_id' => $this->_req_data['event_id']),
1116
-                'add-new-h2',
1117
-                '',
1118
-                false
1119
-            )
1120
-            : '';
1121
-        $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in);
1122
-        $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out);
1123
-        $checked_never = new CheckinStatusDashicon(EE_Checkin::status_checked_never);
1124
-        $legend_items = array(
1125
-            'star-icon'        => array(
1126
-                'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
1127
-                'desc'  => esc_html__('This Registrant is the Primary Registrant', 'event_espresso'),
1128
-            ),
1129
-            'checkin'          => array(
1130
-                'class' => $checked_in->cssClasses(),
1131
-                'desc'  => $checked_in->legendLabel(),
1132
-            ),
1133
-            'checkout'         => array(
1134
-                'class' => $checked_out->cssClasses(),
1135
-                'desc'  => $checked_out->legendLabel(),
1136
-            ),
1137
-            'nocheckinrecord'  => array(
1138
-                'class' => $checked_never->cssClasses(),
1139
-                'desc'  => $checked_never->legendLabel(),
1140
-            ),
1141
-            'approved_status'  => array(
1142
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1143
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'),
1144
-            ),
1145
-            'cancelled_status' => array(
1146
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1147
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'),
1148
-            ),
1149
-            'declined_status'  => array(
1150
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1151
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'),
1152
-            ),
1153
-            'not_approved'     => array(
1154
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1155
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'),
1156
-            ),
1157
-            'pending_status'   => array(
1158
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1159
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'),
1160
-            ),
1161
-            'wait_list'        => array(
1162
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1163
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'),
1164
-            ),
1165
-        );
1166
-        $this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
1167
-        $event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null;
1168
-        /** @var EE_Event $event */
1169
-        $event = EEM_Event::instance()->get_one_by_ID($event_id);
1170
-        $this->_template_args['before_list_table'] = $event instanceof EE_Event
1171
-            ? '<h2>' . sprintf(
1172
-                esc_html__('Viewing Registrations for Event: %s', 'event_espresso'),
1173
-                EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name')
1174
-            ) . '</h2>'
1175
-            : '';
1176
-        // need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on
1177
-        // the event.
1178
-        $DTT_ID = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0;
1179
-        $datetime = null;
1180
-        if ($event instanceof EE_Event) {
1181
-            $datetimes_on_event = $event->datetimes();
1182
-            if (count($datetimes_on_event) === 1) {
1183
-                $datetime = reset($datetimes_on_event);
1184
-            }
1185
-        }
1186
-        $datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
1187
-        if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') {
1188
-            $this->_template_args['before_list_table'] = substr($this->_template_args['before_list_table'], 0, -5);
1189
-            $this->_template_args['before_list_table'] .= ' &nbsp;<span class="drk-grey-text">';
1190
-            $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>';
1191
-            $this->_template_args['before_list_table'] .= $datetime->name();
1192
-            $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )';
1193
-            $this->_template_args['before_list_table'] .= '</span></h2>';
1194
-        }
1195
-        // if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status
1196
-        // column represents
1197
-        if (! $datetime instanceof EE_Datetime) {
1198
-            $this->_template_args['before_list_table'] .= '<br><p class="description">'
1199
-                                                          . esc_html__(
1200
-                                                              'In this view, the check-in status represents the latest check-in record for the registration in that row.',
1201
-                                                              'event_espresso'
1202
-                                                          )
1203
-                                                          . '</p>';
1204
-        }
1205
-        $this->display_admin_list_table_page_with_no_sidebar();
1206
-    }
1098
+	/**
1099
+	 *        generates HTML for the Event Registrations List Table
1100
+	 *
1101
+	 * @access protected
1102
+	 * @return void
1103
+	 * @throws EE_Error
1104
+	 * @throws InvalidArgumentException
1105
+	 * @throws InvalidDataTypeException
1106
+	 * @throws InvalidInterfaceException
1107
+	 */
1108
+	protected function _event_registrations_list_table()
1109
+	{
1110
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1111
+		$this->_admin_page_title .= isset($this->_req_data['event_id'])
1112
+			? $this->get_action_link_or_button(
1113
+				'new_registration',
1114
+				'add-registrant',
1115
+				array('event_id' => $this->_req_data['event_id']),
1116
+				'add-new-h2',
1117
+				'',
1118
+				false
1119
+			)
1120
+			: '';
1121
+		$checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in);
1122
+		$checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out);
1123
+		$checked_never = new CheckinStatusDashicon(EE_Checkin::status_checked_never);
1124
+		$legend_items = array(
1125
+			'star-icon'        => array(
1126
+				'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
1127
+				'desc'  => esc_html__('This Registrant is the Primary Registrant', 'event_espresso'),
1128
+			),
1129
+			'checkin'          => array(
1130
+				'class' => $checked_in->cssClasses(),
1131
+				'desc'  => $checked_in->legendLabel(),
1132
+			),
1133
+			'checkout'         => array(
1134
+				'class' => $checked_out->cssClasses(),
1135
+				'desc'  => $checked_out->legendLabel(),
1136
+			),
1137
+			'nocheckinrecord'  => array(
1138
+				'class' => $checked_never->cssClasses(),
1139
+				'desc'  => $checked_never->legendLabel(),
1140
+			),
1141
+			'approved_status'  => array(
1142
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1143
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'),
1144
+			),
1145
+			'cancelled_status' => array(
1146
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1147
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'),
1148
+			),
1149
+			'declined_status'  => array(
1150
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1151
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'),
1152
+			),
1153
+			'not_approved'     => array(
1154
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1155
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'),
1156
+			),
1157
+			'pending_status'   => array(
1158
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1159
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'),
1160
+			),
1161
+			'wait_list'        => array(
1162
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1163
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'),
1164
+			),
1165
+		);
1166
+		$this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
1167
+		$event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null;
1168
+		/** @var EE_Event $event */
1169
+		$event = EEM_Event::instance()->get_one_by_ID($event_id);
1170
+		$this->_template_args['before_list_table'] = $event instanceof EE_Event
1171
+			? '<h2>' . sprintf(
1172
+				esc_html__('Viewing Registrations for Event: %s', 'event_espresso'),
1173
+				EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name')
1174
+			) . '</h2>'
1175
+			: '';
1176
+		// need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on
1177
+		// the event.
1178
+		$DTT_ID = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0;
1179
+		$datetime = null;
1180
+		if ($event instanceof EE_Event) {
1181
+			$datetimes_on_event = $event->datetimes();
1182
+			if (count($datetimes_on_event) === 1) {
1183
+				$datetime = reset($datetimes_on_event);
1184
+			}
1185
+		}
1186
+		$datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
1187
+		if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') {
1188
+			$this->_template_args['before_list_table'] = substr($this->_template_args['before_list_table'], 0, -5);
1189
+			$this->_template_args['before_list_table'] .= ' &nbsp;<span class="drk-grey-text">';
1190
+			$this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>';
1191
+			$this->_template_args['before_list_table'] .= $datetime->name();
1192
+			$this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )';
1193
+			$this->_template_args['before_list_table'] .= '</span></h2>';
1194
+		}
1195
+		// if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status
1196
+		// column represents
1197
+		if (! $datetime instanceof EE_Datetime) {
1198
+			$this->_template_args['before_list_table'] .= '<br><p class="description">'
1199
+														  . esc_html__(
1200
+															  'In this view, the check-in status represents the latest check-in record for the registration in that row.',
1201
+															  'event_espresso'
1202
+														  )
1203
+														  . '</p>';
1204
+		}
1205
+		$this->display_admin_list_table_page_with_no_sidebar();
1206
+	}
1207 1207
 
1208
-    /**
1209
-     * Download the registrations check-in report (same as the normal registration report, but with different where
1210
-     * conditions)
1211
-     *
1212
-     * @return void ends the request by a redirect or download
1213
-     */
1214
-    public function _registrations_checkin_report()
1215
-    {
1216
-        $this->_registrations_report_base('_get_checkin_query_params_from_request');
1217
-    }
1208
+	/**
1209
+	 * Download the registrations check-in report (same as the normal registration report, but with different where
1210
+	 * conditions)
1211
+	 *
1212
+	 * @return void ends the request by a redirect or download
1213
+	 */
1214
+	public function _registrations_checkin_report()
1215
+	{
1216
+		$this->_registrations_report_base('_get_checkin_query_params_from_request');
1217
+	}
1218 1218
 
1219
-    /**
1220
-     * Gets the query params from the request, plus adds a where condition for the registration status,
1221
-     * because on the checkin page we only ever want to see approved and pending-approval registrations
1222
-     *
1223
-     * @param array $request
1224
-     * @param int   $per_page
1225
-     * @param bool  $count
1226
-     * @return array
1227
-     * @throws EE_Error
1228
-     */
1229
-    protected function _get_checkin_query_params_from_request(
1230
-        $request,
1231
-        $per_page = 10,
1232
-        $count = false
1233
-    ) {
1234
-        $query_params = $this->_get_registration_query_parameters($request, $per_page, $count);
1235
-        // unlike the regular registrations list table,
1236
-        $status_ids_array = apply_filters(
1237
-            'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
1238
-            array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved)
1239
-        );
1240
-        $query_params[0]['STS_ID'] = array('IN', $status_ids_array);
1241
-        return $query_params;
1242
-    }
1219
+	/**
1220
+	 * Gets the query params from the request, plus adds a where condition for the registration status,
1221
+	 * because on the checkin page we only ever want to see approved and pending-approval registrations
1222
+	 *
1223
+	 * @param array $request
1224
+	 * @param int   $per_page
1225
+	 * @param bool  $count
1226
+	 * @return array
1227
+	 * @throws EE_Error
1228
+	 */
1229
+	protected function _get_checkin_query_params_from_request(
1230
+		$request,
1231
+		$per_page = 10,
1232
+		$count = false
1233
+	) {
1234
+		$query_params = $this->_get_registration_query_parameters($request, $per_page, $count);
1235
+		// unlike the regular registrations list table,
1236
+		$status_ids_array = apply_filters(
1237
+			'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
1238
+			array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved)
1239
+		);
1240
+		$query_params[0]['STS_ID'] = array('IN', $status_ids_array);
1241
+		return $query_params;
1242
+	}
1243 1243
 
1244 1244
 
1245
-    /**
1246
-     * Gets registrations for an event
1247
-     *
1248
-     * @param int    $per_page
1249
-     * @param bool   $count whether to return count or data.
1250
-     * @param bool   $trash
1251
-     * @param string $orderby
1252
-     * @return EE_Registration[]|int
1253
-     * @throws EE_Error
1254
-     * @throws InvalidArgumentException
1255
-     * @throws InvalidDataTypeException
1256
-     * @throws InvalidInterfaceException
1257
-     */
1258
-    public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname')
1259
-    {
1260
-        // normalize some request params that get setup by the parent `get_registrations` method.
1261
-        $request = $this->_req_data;
1262
-        $request['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : $orderby;
1263
-        $request['order'] = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC';
1264
-        if ($trash) {
1265
-            $request['status'] = 'trash';
1266
-        }
1267
-        $query_params = $this->_get_checkin_query_params_from_request($request, $per_page, $count);
1268
-        /**
1269
-         * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1270
-         *
1271
-         * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1272
-         * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1273
-         *                             or if you have the development copy of EE you can view this at the path:
1274
-         *                             /docs/G--Model-System/model-query-params.md
1275
-         */
1276
-        $query_params['group_by'] = '';
1245
+	/**
1246
+	 * Gets registrations for an event
1247
+	 *
1248
+	 * @param int    $per_page
1249
+	 * @param bool   $count whether to return count or data.
1250
+	 * @param bool   $trash
1251
+	 * @param string $orderby
1252
+	 * @return EE_Registration[]|int
1253
+	 * @throws EE_Error
1254
+	 * @throws InvalidArgumentException
1255
+	 * @throws InvalidDataTypeException
1256
+	 * @throws InvalidInterfaceException
1257
+	 */
1258
+	public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname')
1259
+	{
1260
+		// normalize some request params that get setup by the parent `get_registrations` method.
1261
+		$request = $this->_req_data;
1262
+		$request['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : $orderby;
1263
+		$request['order'] = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC';
1264
+		if ($trash) {
1265
+			$request['status'] = 'trash';
1266
+		}
1267
+		$query_params = $this->_get_checkin_query_params_from_request($request, $per_page, $count);
1268
+		/**
1269
+		 * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1270
+		 *
1271
+		 * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1272
+		 * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1273
+		 *                             or if you have the development copy of EE you can view this at the path:
1274
+		 *                             /docs/G--Model-System/model-query-params.md
1275
+		 */
1276
+		$query_params['group_by'] = '';
1277 1277
 
1278
-        return $count
1279
-            ? EEM_Registration::instance()->count($query_params)
1280
-            /** @type EE_Registration[] */
1281
-            : EEM_Registration::instance()->get_all($query_params);
1282
-    }
1278
+		return $count
1279
+			? EEM_Registration::instance()->count($query_params)
1280
+			/** @type EE_Registration[] */
1281
+			: EEM_Registration::instance()->get_all($query_params);
1282
+	}
1283 1283
 }
Please login to merge, or discard this patch.
form_sections/strategies/display/EE_Button_Display_Strategy.strategy.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -12,32 +12,32 @@
 block discarded – undo
12 12
 class EE_Button_Display_Strategy extends EE_Display_Strategy_Base
13 13
 {
14 14
 
15
-    /**
16
-     * @return string of html to display the input
17
-     */
18
-    public function display()
19
-    {
20
-        $default_value = $this->_input->get_default();
21
-        if ($this->_input->get_normalization_strategy() instanceof EE_Normalization_Strategy_Base) {
22
-            $default_value = $this->_input->get_normalization_strategy()->unnormalize($default_value);
23
-        }
24
-        $html = $this->_opening_tag('button');
25
-        $html .= $this->_attributes_string(
26
-            array_merge(
27
-                $this->_standard_attributes_array(),
28
-                array(
29
-                    'value' => $default_value,
30
-                )
31
-            )
32
-        );
33
-        if ($this->_input instanceof EE_Button_Input) {
34
-            $button_content = $this->_input->button_content();
35
-        } else {
36
-            $button_content = $this->_input->get_default();
37
-        }
38
-        $html .= '>';
39
-        $html .= $button_content;
40
-        $html .= $this->_closing_tag();
41
-        return $html;
42
-    }
15
+	/**
16
+	 * @return string of html to display the input
17
+	 */
18
+	public function display()
19
+	{
20
+		$default_value = $this->_input->get_default();
21
+		if ($this->_input->get_normalization_strategy() instanceof EE_Normalization_Strategy_Base) {
22
+			$default_value = $this->_input->get_normalization_strategy()->unnormalize($default_value);
23
+		}
24
+		$html = $this->_opening_tag('button');
25
+		$html .= $this->_attributes_string(
26
+			array_merge(
27
+				$this->_standard_attributes_array(),
28
+				array(
29
+					'value' => $default_value,
30
+				)
31
+			)
32
+		);
33
+		if ($this->_input instanceof EE_Button_Input) {
34
+			$button_content = $this->_input->button_content();
35
+		} else {
36
+			$button_content = $this->_input->get_default();
37
+		}
38
+		$html .= '>';
39
+		$html .= $button_content;
40
+		$html .= $this->_closing_tag();
41
+		return $html;
42
+	}
43 43
 }
Please login to merge, or discard this patch.
core/domain/DomainFactory.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
      */
41 41
     public static function getShared(FullyQualifiedName $domain_fqcn, array $arguments)
42 42
     {
43
-        if (! isset($arguments[0], $arguments[1])) {
43
+        if ( ! isset($arguments[0], $arguments[1])) {
44 44
             throw new InvalidArgumentException(
45 45
                 esc_html__(
46 46
                     'You need to pass at least two arguments, representing the addon plugin file and version, in order to generate a Domain class',
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
             );
50 50
         }
51 51
         $domain = LoaderFactory::getLoader()->getShared($domain_fqcn, $arguments);
52
-        if (! $domain instanceof $domain_fqcn && ! $domain instanceof DomainBase) {
52
+        if ( ! $domain instanceof $domain_fqcn && ! $domain instanceof DomainBase) {
53 53
             throw new DomainException(
54 54
                 sprintf(
55 55
                     esc_html__(
Please login to merge, or discard this patch.
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -28,63 +28,63 @@
 block discarded – undo
28 28
 class DomainFactory
29 29
 {
30 30
 
31
-    /**
32
-     * @param FullyQualifiedName $domain_fqcn   [required] Fully Qualified Class Name for the Domain class
33
-     * @param array $arguments                  [required] array of arguments to be passed to the Domain class
34
-     *                                          constructor. Must at least include the following two value objects:
35
-     *                                          array(
36
-     *                                              EventEspresso\core\domain\values\FilePath $plugin_file
37
-     *                                              EventEspresso\core\domain\values\Version $version
38
-     *                                          )
39
-     * @return mixed
40
-     * @throws DomainException
41
-     * @throws InvalidArgumentException
42
-     * @throws InvalidDataTypeException
43
-     * @throws InvalidInterfaceException
44
-     */
45
-    public static function getShared(FullyQualifiedName $domain_fqcn, array $arguments)
46
-    {
47
-        if (! isset($arguments[0], $arguments[1])) {
48
-            throw new InvalidArgumentException(
49
-                esc_html__(
50
-                    'You need to pass at least two arguments, representing the addon plugin file and version, in order to generate a Domain class',
51
-                    'event_espresso'
52
-                )
53
-            );
54
-        }
55
-        $domain = LoaderFactory::getLoader()->getShared($domain_fqcn, $arguments);
56
-        if (! $domain instanceof $domain_fqcn && ! $domain instanceof DomainBase) {
57
-            throw new DomainException(
58
-                sprintf(
59
-                    esc_html__(
60
-                        'The requested Domain class "%1$s" could not be loaded.',
61
-                        'event_espresso'
62
-                    ),
63
-                    $domain_fqcn
64
-                )
65
-            );
66
-        }
67
-        return $domain;
68
-    }
31
+	/**
32
+	 * @param FullyQualifiedName $domain_fqcn   [required] Fully Qualified Class Name for the Domain class
33
+	 * @param array $arguments                  [required] array of arguments to be passed to the Domain class
34
+	 *                                          constructor. Must at least include the following two value objects:
35
+	 *                                          array(
36
+	 *                                              EventEspresso\core\domain\values\FilePath $plugin_file
37
+	 *                                              EventEspresso\core\domain\values\Version $version
38
+	 *                                          )
39
+	 * @return mixed
40
+	 * @throws DomainException
41
+	 * @throws InvalidArgumentException
42
+	 * @throws InvalidDataTypeException
43
+	 * @throws InvalidInterfaceException
44
+	 */
45
+	public static function getShared(FullyQualifiedName $domain_fqcn, array $arguments)
46
+	{
47
+		if (! isset($arguments[0], $arguments[1])) {
48
+			throw new InvalidArgumentException(
49
+				esc_html__(
50
+					'You need to pass at least two arguments, representing the addon plugin file and version, in order to generate a Domain class',
51
+					'event_espresso'
52
+				)
53
+			);
54
+		}
55
+		$domain = LoaderFactory::getLoader()->getShared($domain_fqcn, $arguments);
56
+		if (! $domain instanceof $domain_fqcn && ! $domain instanceof DomainBase) {
57
+			throw new DomainException(
58
+				sprintf(
59
+					esc_html__(
60
+						'The requested Domain class "%1$s" could not be loaded.',
61
+						'event_espresso'
62
+					),
63
+					$domain_fqcn
64
+				)
65
+			);
66
+		}
67
+		return $domain;
68
+	}
69 69
 
70 70
 
71
-    /**
72
-     * @return Domain
73
-     * @throws DomainException
74
-     * @throws InvalidArgumentException
75
-     * @throws InvalidDataTypeException
76
-     * @throws InvalidFilePathException
77
-     * @throws InvalidInterfaceException
78
-     */
79
-    public static function getEventEspressoCoreDomain()
80
-    {
81
-        $domain = new Domain(
82
-            new FilePath(EVENT_ESPRESSO_MAIN_FILE),
83
-            Version::fromString(espresso_version())
84
-        );
85
-        LoaderFactory::getLoader()->share('EventEspresso\core\domain\Domain', $domain);
86
-        return $domain;
87
-    }
71
+	/**
72
+	 * @return Domain
73
+	 * @throws DomainException
74
+	 * @throws InvalidArgumentException
75
+	 * @throws InvalidDataTypeException
76
+	 * @throws InvalidFilePathException
77
+	 * @throws InvalidInterfaceException
78
+	 */
79
+	public static function getEventEspressoCoreDomain()
80
+	{
81
+		$domain = new Domain(
82
+			new FilePath(EVENT_ESPRESSO_MAIN_FILE),
83
+			Version::fromString(espresso_version())
84
+		);
85
+		LoaderFactory::getLoader()->share('EventEspresso\core\domain\Domain', $domain);
86
+		return $domain;
87
+	}
88 88
 }
89 89
 
90 90
 
Please login to merge, or discard this patch.
core/domain/values/FilePath.php 2 patches
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -20,42 +20,42 @@
 block discarded – undo
20 20
 class FilePath
21 21
 {
22 22
 
23
-    /**
24
-     * @var string file_path
25
-     */
26
-    private $file_path;
27
-
28
-
29
-    /**
30
-     * FilePath constructor.
31
-     *
32
-     * @param string $file_path
33
-     * @throws InvalidDataTypeException
34
-     * @throws InvalidFilePathException
35
-     */
36
-    public function __construct($file_path)
37
-    {
38
-        if (! is_string($file_path)) {
39
-            throw new InvalidDataTypeException(
40
-                '$file_path',
41
-                $file_path,
42
-                'string'
43
-            );
44
-        }
45
-        if (! is_readable($file_path)) {
46
-            throw new InvalidFilePathException($file_path);
47
-        }
48
-        $this->file_path = $file_path;
49
-    }
50
-
51
-
52
-    /**
53
-     * @return string
54
-     */
55
-    public function __toString()
56
-    {
57
-        return $this->file_path;
58
-    }
23
+	/**
24
+	 * @var string file_path
25
+	 */
26
+	private $file_path;
27
+
28
+
29
+	/**
30
+	 * FilePath constructor.
31
+	 *
32
+	 * @param string $file_path
33
+	 * @throws InvalidDataTypeException
34
+	 * @throws InvalidFilePathException
35
+	 */
36
+	public function __construct($file_path)
37
+	{
38
+		if (! is_string($file_path)) {
39
+			throw new InvalidDataTypeException(
40
+				'$file_path',
41
+				$file_path,
42
+				'string'
43
+			);
44
+		}
45
+		if (! is_readable($file_path)) {
46
+			throw new InvalidFilePathException($file_path);
47
+		}
48
+		$this->file_path = $file_path;
49
+	}
50
+
51
+
52
+	/**
53
+	 * @return string
54
+	 */
55
+	public function __toString()
56
+	{
57
+		return $this->file_path;
58
+	}
59 59
 
60 60
 
61 61
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -35,14 +35,14 @@
 block discarded – undo
35 35
      */
36 36
     public function __construct($file_path)
37 37
     {
38
-        if (! is_string($file_path)) {
38
+        if ( ! is_string($file_path)) {
39 39
             throw new InvalidDataTypeException(
40 40
                 '$file_path',
41 41
                 $file_path,
42 42
                 'string'
43 43
             );
44 44
         }
45
-        if (! is_readable($file_path)) {
45
+        if ( ! is_readable($file_path)) {
46 46
             throw new InvalidFilePathException($file_path);
47 47
         }
48 48
         $this->file_path = $file_path;
Please login to merge, or discard this patch.
core/domain/values/FullyQualifiedName.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,14 +37,14 @@
 block discarded – undo
37 37
      */
38 38
     public function __construct($fully_qualified_name)
39 39
     {
40
-        if (! is_string($fully_qualified_name)) {
40
+        if ( ! is_string($fully_qualified_name)) {
41 41
             throw new InvalidDataTypeException(
42 42
                 '$fully_qualified_name',
43 43
                 $fully_qualified_name,
44 44
                 'string'
45 45
             );
46 46
         }
47
-        if (! class_exists($fully_qualified_name) && ! interface_exists($fully_qualified_name)) {
47
+        if ( ! class_exists($fully_qualified_name) && ! interface_exists($fully_qualified_name)) {
48 48
             if (strpos($fully_qualified_name, 'Interface') !== false) {
49 49
                 throw new InvalidInterfaceException($fully_qualified_name);
50 50
             }
Please login to merge, or discard this patch.
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -21,54 +21,54 @@
 block discarded – undo
21 21
 class FullyQualifiedName
22 22
 {
23 23
 
24
-    /**
25
-     * @var string $fully_qualified_name
26
-     */
27
-    private $fully_qualified_name;
24
+	/**
25
+	 * @var string $fully_qualified_name
26
+	 */
27
+	private $fully_qualified_name;
28 28
 
29 29
 
30
-    /**
31
-     * FullyQualifiedName constructor.
32
-     *
33
-     * @param string $fully_qualified_name
34
-     * @throws InvalidClassException
35
-     * @throws InvalidInterfaceException
36
-     * @throws InvalidDataTypeException
37
-     */
38
-    public function __construct($fully_qualified_name)
39
-    {
40
-        if (! is_string($fully_qualified_name)) {
41
-            throw new InvalidDataTypeException(
42
-                '$fully_qualified_name',
43
-                $fully_qualified_name,
44
-                'string'
45
-            );
46
-        }
47
-        if (! class_exists($fully_qualified_name) && ! interface_exists($fully_qualified_name)) {
48
-            if (strpos($fully_qualified_name, 'Interface') !== false) {
49
-                throw new InvalidInterfaceException($fully_qualified_name);
50
-            }
51
-            throw new InvalidClassException($fully_qualified_name);
52
-        }
53
-        $this->fully_qualified_name = $fully_qualified_name;
54
-    }
30
+	/**
31
+	 * FullyQualifiedName constructor.
32
+	 *
33
+	 * @param string $fully_qualified_name
34
+	 * @throws InvalidClassException
35
+	 * @throws InvalidInterfaceException
36
+	 * @throws InvalidDataTypeException
37
+	 */
38
+	public function __construct($fully_qualified_name)
39
+	{
40
+		if (! is_string($fully_qualified_name)) {
41
+			throw new InvalidDataTypeException(
42
+				'$fully_qualified_name',
43
+				$fully_qualified_name,
44
+				'string'
45
+			);
46
+		}
47
+		if (! class_exists($fully_qualified_name) && ! interface_exists($fully_qualified_name)) {
48
+			if (strpos($fully_qualified_name, 'Interface') !== false) {
49
+				throw new InvalidInterfaceException($fully_qualified_name);
50
+			}
51
+			throw new InvalidClassException($fully_qualified_name);
52
+		}
53
+		$this->fully_qualified_name = $fully_qualified_name;
54
+	}
55 55
 
56 56
 
57
-    /**
58
-     * @return string
59
-     */
60
-    public function string()
61
-    {
62
-        return $this->fully_qualified_name;
63
-    }
57
+	/**
58
+	 * @return string
59
+	 */
60
+	public function string()
61
+	{
62
+		return $this->fully_qualified_name;
63
+	}
64 64
 
65 65
 
66
-    /**
67
-     * @return string
68
-     */
69
-    public function __toString()
70
-    {
71
-        return $this->fully_qualified_name;
72
-    }
66
+	/**
67
+	 * @return string
68
+	 */
69
+	public function __toString()
70
+	{
71
+		return $this->fully_qualified_name;
72
+	}
73 73
 
74 74
 }
Please login to merge, or discard this patch.
core/domain/DomainBase.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -121,7 +121,7 @@
 block discarded – undo
121 121
 
122 122
 
123 123
     /**
124
-     * @return Version
124
+     * @return string
125 125
      */
126 126
     public function versionValueObject()
127 127
     {
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
      */
137 137
     public function distributionAssetsPath()
138 138
     {
139
-        return $this->pluginPath() . 'assets/dist/';
139
+        return $this->pluginPath().'assets/dist/';
140 140
     }
141 141
 
142 142
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
      */
146 146
     public function distributionAssetsUrl()
147 147
     {
148
-        return $this->pluginUrl() . 'assets/dist/';
148
+        return $this->pluginUrl().'assets/dist/';
149 149
     }
150 150
 
151 151
 
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,6 @@
 block discarded – undo
4 4
 
5 5
 use EventEspresso\core\domain\values\FilePath;
6 6
 use EventEspresso\core\domain\values\Version;
7
-use EventEspresso\core\services\assets\Registry;
8 7
 
9 8
 /**
10 9
  * DomainBase Class
Please login to merge, or discard this patch.
Indentation   +149 added lines, -149 removed lines patch added patch discarded remove patch
@@ -16,153 +16,153 @@
 block discarded – undo
16 16
 abstract class DomainBase implements DomainInterface
17 17
 {
18 18
 
19
-    /**
20
-     * Equivalent to `__FILE__` for main plugin file.
21
-     *
22
-     * @var FilePath
23
-     */
24
-    private $plugin_file;
25
-
26
-    /**
27
-     * String indicating version for plugin
28
-     *
29
-     * @var string
30
-     */
31
-    private $version;
32
-
33
-    /**
34
-     * @var string $plugin_basename
35
-     */
36
-    private $plugin_basename;
37
-
38
-    /**
39
-     * @var string $plugin_path
40
-     */
41
-    private $plugin_path;
42
-
43
-    /**
44
-     * @var string $plugin_url
45
-     */
46
-    private $plugin_url;
47
-
48
-    /**
49
-     * @var string $asset_namespace
50
-     */
51
-    private $asset_namespace;
52
-
53
-
54
-
55
-    /**
56
-     * Initializes internal properties.
57
-     *
58
-     * @param FilePath $plugin_file
59
-     * @param Version  $version
60
-     */
61
-    public function __construct(FilePath $plugin_file, Version $version)
62
-    {
63
-        $this->plugin_file = $plugin_file;
64
-        $this->version = $version;
65
-        $this->plugin_basename = plugin_basename($this->pluginFile());
66
-        $this->plugin_path = plugin_dir_path($this->pluginFile());
67
-        $this->plugin_url = plugin_dir_url($this->pluginFile());
68
-        $this->setAssetNamespace();
69
-    }
70
-
71
-
72
-    /**
73
-     * @return string
74
-     */
75
-    public function pluginFile()
76
-    {
77
-        return (string) $this->plugin_file;
78
-    }
79
-
80
-
81
-
82
-    /**
83
-     * @return string
84
-     */
85
-    public function pluginBasename()
86
-    {
87
-        return $this->plugin_basename;
88
-    }
89
-
90
-
91
-
92
-    /**
93
-     * @return string
94
-     */
95
-    public function pluginPath()
96
-    {
97
-        return $this->plugin_path;
98
-    }
99
-
100
-
101
-
102
-    /**
103
-     * @return string
104
-     */
105
-    public function pluginUrl()
106
-    {
107
-        return $this->plugin_url;
108
-    }
109
-
110
-
111
-
112
-    /**
113
-     * @return string
114
-     */
115
-    public function version()
116
-    {
117
-        return (string) $this->version;
118
-    }
119
-
120
-
121
-
122
-    /**
123
-     * @return Version
124
-     */
125
-    public function versionValueObject()
126
-    {
127
-        return $this->version;
128
-    }
129
-
130
-
131
-    /**
132
-     * @return string
133
-     */
134
-    public function distributionAssetsPath()
135
-    {
136
-        return $this->pluginPath() . 'assets/dist/';
137
-    }
138
-
139
-
140
-    /**
141
-     * @return string
142
-     */
143
-    public function distributionAssetsUrl()
144
-    {
145
-        return $this->pluginUrl() . 'assets/dist/';
146
-    }
147
-
148
-
149
-    /**
150
-     * @return string
151
-     */
152
-    public function assetNamespace()
153
-    {
154
-        return $this->asset_namespace;
155
-    }
156
-
157
-
158
-    /**
159
-     * @return void
160
-     */
161
-    private function setAssetNamespace()
162
-    {
163
-        $this->asset_namespace = sanitize_key(
164
-            // convert directory separators to dashes and remove file extension
165
-            str_replace(array('/', '.php'), array('-', ''), $this->plugin_basename)
166
-        );
167
-    }
19
+	/**
20
+	 * Equivalent to `__FILE__` for main plugin file.
21
+	 *
22
+	 * @var FilePath
23
+	 */
24
+	private $plugin_file;
25
+
26
+	/**
27
+	 * String indicating version for plugin
28
+	 *
29
+	 * @var string
30
+	 */
31
+	private $version;
32
+
33
+	/**
34
+	 * @var string $plugin_basename
35
+	 */
36
+	private $plugin_basename;
37
+
38
+	/**
39
+	 * @var string $plugin_path
40
+	 */
41
+	private $plugin_path;
42
+
43
+	/**
44
+	 * @var string $plugin_url
45
+	 */
46
+	private $plugin_url;
47
+
48
+	/**
49
+	 * @var string $asset_namespace
50
+	 */
51
+	private $asset_namespace;
52
+
53
+
54
+
55
+	/**
56
+	 * Initializes internal properties.
57
+	 *
58
+	 * @param FilePath $plugin_file
59
+	 * @param Version  $version
60
+	 */
61
+	public function __construct(FilePath $plugin_file, Version $version)
62
+	{
63
+		$this->plugin_file = $plugin_file;
64
+		$this->version = $version;
65
+		$this->plugin_basename = plugin_basename($this->pluginFile());
66
+		$this->plugin_path = plugin_dir_path($this->pluginFile());
67
+		$this->plugin_url = plugin_dir_url($this->pluginFile());
68
+		$this->setAssetNamespace();
69
+	}
70
+
71
+
72
+	/**
73
+	 * @return string
74
+	 */
75
+	public function pluginFile()
76
+	{
77
+		return (string) $this->plugin_file;
78
+	}
79
+
80
+
81
+
82
+	/**
83
+	 * @return string
84
+	 */
85
+	public function pluginBasename()
86
+	{
87
+		return $this->plugin_basename;
88
+	}
89
+
90
+
91
+
92
+	/**
93
+	 * @return string
94
+	 */
95
+	public function pluginPath()
96
+	{
97
+		return $this->plugin_path;
98
+	}
99
+
100
+
101
+
102
+	/**
103
+	 * @return string
104
+	 */
105
+	public function pluginUrl()
106
+	{
107
+		return $this->plugin_url;
108
+	}
109
+
110
+
111
+
112
+	/**
113
+	 * @return string
114
+	 */
115
+	public function version()
116
+	{
117
+		return (string) $this->version;
118
+	}
119
+
120
+
121
+
122
+	/**
123
+	 * @return Version
124
+	 */
125
+	public function versionValueObject()
126
+	{
127
+		return $this->version;
128
+	}
129
+
130
+
131
+	/**
132
+	 * @return string
133
+	 */
134
+	public function distributionAssetsPath()
135
+	{
136
+		return $this->pluginPath() . 'assets/dist/';
137
+	}
138
+
139
+
140
+	/**
141
+	 * @return string
142
+	 */
143
+	public function distributionAssetsUrl()
144
+	{
145
+		return $this->pluginUrl() . 'assets/dist/';
146
+	}
147
+
148
+
149
+	/**
150
+	 * @return string
151
+	 */
152
+	public function assetNamespace()
153
+	{
154
+		return $this->asset_namespace;
155
+	}
156
+
157
+
158
+	/**
159
+	 * @return void
160
+	 */
161
+	private function setAssetNamespace()
162
+	{
163
+		$this->asset_namespace = sanitize_key(
164
+			// convert directory separators to dashes and remove file extension
165
+			str_replace(array('/', '.php'), array('-', ''), $this->plugin_basename)
166
+		);
167
+	}
168 168
 }
Please login to merge, or discard this patch.
core/domain/entities/contexts/RequestTypeContext.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@
 block discarded – undo
91 91
     public function __construct($slug, $description)
92 92
     {
93 93
         parent::__construct($slug, $description);
94
-        if (! in_array($this->slug(), $this->validRequestTypes(), true)) {
94
+        if ( ! in_array($this->slug(), $this->validRequestTypes(), true)) {
95 95
             throw new InvalidArgumentException(
96 96
                 sprintf(
97 97
                     esc_html__(
Please login to merge, or discard this patch.
Indentation   +151 added lines, -151 removed lines patch added patch discarded remove patch
@@ -16,155 +16,155 @@
 block discarded – undo
16 16
 class RequestTypeContext extends Context
17 17
 {
18 18
 
19
-    /**
20
-     * indicates that the current request involves some form of activation
21
-     */
22
-    const ACTIVATION = 'activation-request';
23
-
24
-    /**
25
-     * indicates that the current request is for the admin but is not being made via AJAX
26
-     */
27
-    const ADMIN = 'non-ajax-admin-request';
28
-
29
-    /**
30
-     * indicates that the current request is for the admin AND is being made via AJAX
31
-     */
32
-    const AJAX_ADMIN = 'admin-ajax-request';
33
-
34
-    /**
35
-     * indicates that the current request is for the frontend AND is being made via AJAX
36
-     */
37
-    const AJAX_FRONT = 'frontend-ajax-request';
38
-
39
-    /**
40
-     * indicates that the current request is for the WP Heartbeat
41
-     */
42
-    const AJAX_HEARTBEAT = 'admin-ajax-heartbeat';
43
-
44
-    /**
45
-     * indicates that the current request is being made via AJAX, but is NOT for EE
46
-     */
47
-    const AJAX_OTHER = 'other-ajax-request';
48
-
49
-    /**
50
-     * indicates that the current request is for the EE REST API
51
-     */
52
-    const API = 'rest-api';
53
-
54
-    /**
55
-     * indicates that the current request is from the command line
56
-     */
57
-    const CLI = 'command-line';
58
-
59
-    /**
60
-     * indicates that the current request is for a WP_Cron
61
-     */
62
-    const CRON = 'wp-cron';
63
-
64
-    /**
65
-     * indicates that the current request is for a feed (ie: RSS)
66
-     */
67
-    const FEED = 'feed-request';
68
-
69
-    /**
70
-     * indicates that the current request is for the frontend but is not being made via AJAX
71
-     */
72
-    const FRONTEND = 'non-ajax-frontend-request';
73
-
74
-    /**
75
-     * indicates that the current request is for content that is to be displayed within an iframe
76
-     */
77
-    const IFRAME = 'iframe-request';
78
-
79
-    /**
80
-     * indicates that the current request is for the WP REST API
81
-     */
82
-    const WP_API = 'wp-rest-api';
83
-
84
-    /**
85
-     * indicates that the current request is a loopback sent from WP core to test for errors
86
-     */
87
-    const WP_SCRAPE = 'wordpress-scrape';
88
-
89
-    /**
90
-     * @var boolean $is_activation
91
-     */
92
-    private $is_activation = false;
93
-
94
-    /**
95
-     * @var array $valid_request_types
96
-     */
97
-    private $valid_request_types = array();
98
-
99
-
100
-    /**
101
-     * RequestTypeContext constructor.
102
-     *
103
-     * @param string $slug
104
-     * @param string $description
105
-     * @throws InvalidArgumentException
106
-     */
107
-    public function __construct($slug, $description)
108
-    {
109
-        parent::__construct($slug, $description);
110
-        if (! in_array($this->slug(), $this->validRequestTypes(), true)) {
111
-            throw new InvalidArgumentException(
112
-                sprintf(
113
-                    esc_html__(
114
-                        'The RequestTypeContext slug must be one of the following values: %1$s %2$s',
115
-                        'event_espresso'
116
-                    ),
117
-                    var_export($this->validRequestTypes(), true)
118
-                )
119
-            );
120
-        }
121
-    }
122
-
123
-
124
-    /**
125
-     * @return array
126
-     */
127
-    public function validRequestTypes()
128
-    {
129
-        if (empty($this->valid_request_types)) {
130
-            $this->valid_request_types = apply_filters(
131
-                'FHEE__EventEspresso_core_domain_entities_contexts_RequestTypeContext__validRequestTypes',
132
-                array(
133
-                    RequestTypeContext::ACTIVATION,
134
-                    RequestTypeContext::ADMIN,
135
-                    RequestTypeContext::AJAX_ADMIN,
136
-                    RequestTypeContext::AJAX_FRONT,
137
-                    RequestTypeContext::AJAX_HEARTBEAT,
138
-                    RequestTypeContext::AJAX_OTHER,
139
-                    RequestTypeContext::API,
140
-                    RequestTypeContext::CLI,
141
-                    RequestTypeContext::CRON,
142
-                    RequestTypeContext::FEED,
143
-                    RequestTypeContext::FRONTEND,
144
-                    RequestTypeContext::IFRAME,
145
-                    RequestTypeContext::WP_API,
146
-                    RequestTypeContext::WP_SCRAPE,
147
-                )
148
-            );
149
-        }
150
-        return $this->valid_request_types;
151
-    }
152
-
153
-
154
-    /**
155
-     * @return bool
156
-     */
157
-    public function isActivation()
158
-    {
159
-        return $this->is_activation;
160
-    }
161
-
162
-
163
-    /**
164
-     * @param bool $is_activation
165
-     */
166
-    public function setIsActivation($is_activation)
167
-    {
168
-        $this->is_activation = filter_var($is_activation, FILTER_VALIDATE_BOOLEAN);
169
-    }
19
+	/**
20
+	 * indicates that the current request involves some form of activation
21
+	 */
22
+	const ACTIVATION = 'activation-request';
23
+
24
+	/**
25
+	 * indicates that the current request is for the admin but is not being made via AJAX
26
+	 */
27
+	const ADMIN = 'non-ajax-admin-request';
28
+
29
+	/**
30
+	 * indicates that the current request is for the admin AND is being made via AJAX
31
+	 */
32
+	const AJAX_ADMIN = 'admin-ajax-request';
33
+
34
+	/**
35
+	 * indicates that the current request is for the frontend AND is being made via AJAX
36
+	 */
37
+	const AJAX_FRONT = 'frontend-ajax-request';
38
+
39
+	/**
40
+	 * indicates that the current request is for the WP Heartbeat
41
+	 */
42
+	const AJAX_HEARTBEAT = 'admin-ajax-heartbeat';
43
+
44
+	/**
45
+	 * indicates that the current request is being made via AJAX, but is NOT for EE
46
+	 */
47
+	const AJAX_OTHER = 'other-ajax-request';
48
+
49
+	/**
50
+	 * indicates that the current request is for the EE REST API
51
+	 */
52
+	const API = 'rest-api';
53
+
54
+	/**
55
+	 * indicates that the current request is from the command line
56
+	 */
57
+	const CLI = 'command-line';
58
+
59
+	/**
60
+	 * indicates that the current request is for a WP_Cron
61
+	 */
62
+	const CRON = 'wp-cron';
63
+
64
+	/**
65
+	 * indicates that the current request is for a feed (ie: RSS)
66
+	 */
67
+	const FEED = 'feed-request';
68
+
69
+	/**
70
+	 * indicates that the current request is for the frontend but is not being made via AJAX
71
+	 */
72
+	const FRONTEND = 'non-ajax-frontend-request';
73
+
74
+	/**
75
+	 * indicates that the current request is for content that is to be displayed within an iframe
76
+	 */
77
+	const IFRAME = 'iframe-request';
78
+
79
+	/**
80
+	 * indicates that the current request is for the WP REST API
81
+	 */
82
+	const WP_API = 'wp-rest-api';
83
+
84
+	/**
85
+	 * indicates that the current request is a loopback sent from WP core to test for errors
86
+	 */
87
+	const WP_SCRAPE = 'wordpress-scrape';
88
+
89
+	/**
90
+	 * @var boolean $is_activation
91
+	 */
92
+	private $is_activation = false;
93
+
94
+	/**
95
+	 * @var array $valid_request_types
96
+	 */
97
+	private $valid_request_types = array();
98
+
99
+
100
+	/**
101
+	 * RequestTypeContext constructor.
102
+	 *
103
+	 * @param string $slug
104
+	 * @param string $description
105
+	 * @throws InvalidArgumentException
106
+	 */
107
+	public function __construct($slug, $description)
108
+	{
109
+		parent::__construct($slug, $description);
110
+		if (! in_array($this->slug(), $this->validRequestTypes(), true)) {
111
+			throw new InvalidArgumentException(
112
+				sprintf(
113
+					esc_html__(
114
+						'The RequestTypeContext slug must be one of the following values: %1$s %2$s',
115
+						'event_espresso'
116
+					),
117
+					var_export($this->validRequestTypes(), true)
118
+				)
119
+			);
120
+		}
121
+	}
122
+
123
+
124
+	/**
125
+	 * @return array
126
+	 */
127
+	public function validRequestTypes()
128
+	{
129
+		if (empty($this->valid_request_types)) {
130
+			$this->valid_request_types = apply_filters(
131
+				'FHEE__EventEspresso_core_domain_entities_contexts_RequestTypeContext__validRequestTypes',
132
+				array(
133
+					RequestTypeContext::ACTIVATION,
134
+					RequestTypeContext::ADMIN,
135
+					RequestTypeContext::AJAX_ADMIN,
136
+					RequestTypeContext::AJAX_FRONT,
137
+					RequestTypeContext::AJAX_HEARTBEAT,
138
+					RequestTypeContext::AJAX_OTHER,
139
+					RequestTypeContext::API,
140
+					RequestTypeContext::CLI,
141
+					RequestTypeContext::CRON,
142
+					RequestTypeContext::FEED,
143
+					RequestTypeContext::FRONTEND,
144
+					RequestTypeContext::IFRAME,
145
+					RequestTypeContext::WP_API,
146
+					RequestTypeContext::WP_SCRAPE,
147
+				)
148
+			);
149
+		}
150
+		return $this->valid_request_types;
151
+	}
152
+
153
+
154
+	/**
155
+	 * @return bool
156
+	 */
157
+	public function isActivation()
158
+	{
159
+		return $this->is_activation;
160
+	}
161
+
162
+
163
+	/**
164
+	 * @param bool $is_activation
165
+	 */
166
+	public function setIsActivation($is_activation)
167
+	{
168
+		$this->is_activation = filter_var($is_activation, FILTER_VALIDATE_BOOLEAN);
169
+	}
170 170
 }
Please login to merge, or discard this patch.
core/helpers/EEH_URL.helper.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -251,7 +251,7 @@
 block discarded – undo
251 251
     /**
252 252
      * Identical in functionality to EEH_current_url except it removes any provided query_parameters from it.
253 253
      *
254
-     * @param array $query_parameters An array of query_parameters to remove from the current url.
254
+     * @param string[] $query_parameters An array of query_parameters to remove from the current url.
255 255
      * @since 4.9.46.rc.029
256 256
      * @return string
257 257
      */
Please login to merge, or discard this patch.
Indentation   +245 added lines, -245 removed lines patch added patch discarded remove patch
@@ -12,270 +12,270 @@
 block discarded – undo
12 12
 class EEH_URL
13 13
 {
14 14
 
15
-    /**
16
-     * _add_query_arg
17
-     * adds nonce to array of arguments then calls WP add_query_arg function
18
-     *
19
-     * @access public
20
-     * @param array  $args
21
-     * @param string $url
22
-     * @param bool   $exclude_nonce If true then the nonce will be excluded from the generated url.
23
-     * @return string
24
-     */
25
-    public static function add_query_args_and_nonce($args = array(), $url = '', $exclude_nonce = false)
26
-    {
27
-        // check that an action exists and add nonce
28
-        if (! $exclude_nonce) {
29
-            if (isset($args['action']) && ! empty($args['action'])) {
30
-                $args = array_merge(
31
-                    $args,
32
-                    array(
33
-                        $args['action'] . '_nonce' => wp_create_nonce($args['action'] . '_nonce')
34
-                    )
35
-                );
36
-            } else {
37
-                $args = array_merge(
38
-                    $args,
39
-                    array(
40
-                        'action' => 'default', 'default_nonce' => wp_create_nonce('default_nonce')
41
-                    )
42
-                );
43
-            }
44
-        }
15
+	/**
16
+	 * _add_query_arg
17
+	 * adds nonce to array of arguments then calls WP add_query_arg function
18
+	 *
19
+	 * @access public
20
+	 * @param array  $args
21
+	 * @param string $url
22
+	 * @param bool   $exclude_nonce If true then the nonce will be excluded from the generated url.
23
+	 * @return string
24
+	 */
25
+	public static function add_query_args_and_nonce($args = array(), $url = '', $exclude_nonce = false)
26
+	{
27
+		// check that an action exists and add nonce
28
+		if (! $exclude_nonce) {
29
+			if (isset($args['action']) && ! empty($args['action'])) {
30
+				$args = array_merge(
31
+					$args,
32
+					array(
33
+						$args['action'] . '_nonce' => wp_create_nonce($args['action'] . '_nonce')
34
+					)
35
+				);
36
+			} else {
37
+				$args = array_merge(
38
+					$args,
39
+					array(
40
+						'action' => 'default', 'default_nonce' => wp_create_nonce('default_nonce')
41
+					)
42
+				);
43
+			}
44
+		}
45 45
 
46
-        // finally, let's always add a return address (if present) :)
47
-        $args = ! empty($_REQUEST['action']) && ! isset($_REQUEST['return'])
48
-            ? array_merge($args, array('return' => $_REQUEST['action']))
49
-            : $args;
46
+		// finally, let's always add a return address (if present) :)
47
+		$args = ! empty($_REQUEST['action']) && ! isset($_REQUEST['return'])
48
+			? array_merge($args, array('return' => $_REQUEST['action']))
49
+			: $args;
50 50
 
51
-        return add_query_arg($args, $url);
52
-    }
51
+		return add_query_arg($args, $url);
52
+	}
53 53
 
54 54
 
55
-    /**
56
-     * Returns whether not the remote file exists.
57
-     * Checking via GET because HEAD requests are blocked on some server configurations.
58
-     *
59
-     * @param string  $url
60
-     * @param array $args  the arguments that should be passed through to the wp_remote_request call.
61
-     * @return boolean
62
-     */
63
-    public static function remote_file_exists($url, $args = array())
64
-    {
65
-        $results = wp_remote_request(
66
-            $url,
67
-            array_merge(
68
-                array(
69
-                    'method'      => 'GET',
70
-                    'redirection' => 1,
71
-                ),
72
-                $args
73
-            )
74
-        );
75
-        if (! $results instanceof WP_Error &&
76
-            isset($results['response']) &&
77
-            isset($results['response']['code']) &&
78
-            $results['response']['code'] == '200') {
79
-            return true;
80
-        } else {
81
-            return false;
82
-        }
83
-    }
55
+	/**
56
+	 * Returns whether not the remote file exists.
57
+	 * Checking via GET because HEAD requests are blocked on some server configurations.
58
+	 *
59
+	 * @param string  $url
60
+	 * @param array $args  the arguments that should be passed through to the wp_remote_request call.
61
+	 * @return boolean
62
+	 */
63
+	public static function remote_file_exists($url, $args = array())
64
+	{
65
+		$results = wp_remote_request(
66
+			$url,
67
+			array_merge(
68
+				array(
69
+					'method'      => 'GET',
70
+					'redirection' => 1,
71
+				),
72
+				$args
73
+			)
74
+		);
75
+		if (! $results instanceof WP_Error &&
76
+			isset($results['response']) &&
77
+			isset($results['response']['code']) &&
78
+			$results['response']['code'] == '200') {
79
+			return true;
80
+		} else {
81
+			return false;
82
+		}
83
+	}
84 84
 
85 85
 
86
-    /**
87
-     * refactor_url
88
-     * primarily used for removing the query string from a URL
89
-     *
90
-     * @param string $url
91
-     * @param bool   $remove_query  - TRUE (default) will strip off any URL params, ie: ?this=1&that=2
92
-     * @param bool   $base_url_only - TRUE will only return the scheme and host with no other parameters
93
-     * @return string
94
-     */
95
-    public static function refactor_url($url = '', $remove_query = true, $base_url_only = false)
96
-    {
97
-        // break apart incoming URL
98
-        $url_bits = parse_url($url);
99
-        // HTTP or HTTPS ?
100
-        $scheme = isset($url_bits['scheme']) ? $url_bits['scheme'] . '://' : 'http://';
101
-        // domain
102
-        $host = isset($url_bits['host']) ? $url_bits['host'] : '';
103
-        // if only the base URL is requested, then return that now
104
-        if ($base_url_only) {
105
-            return $scheme . $host;
106
-        }
107
-        $port = isset($url_bits['port']) ? ':' . $url_bits['port'] : '';
108
-        $user = isset($url_bits['user']) ? $url_bits['user'] : '';
109
-        $pass = isset($url_bits['pass']) ? ':' . $url_bits['pass'] : '';
110
-        $pass = ($user || $pass) ? $pass . '@' : '';
111
-        $path = isset($url_bits['path']) ? $url_bits['path'] : '';
112
-        // if the query string is not required, then return what we have so far
113
-        if ($remove_query) {
114
-            return $scheme . $user . $pass . $host . $port . $path;
115
-        }
116
-        $query    = isset($url_bits['query']) ? '?' . $url_bits['query'] : '';
117
-        $fragment = isset($url_bits['fragment']) ? '#' . $url_bits['fragment'] : '';
118
-        return $scheme . $user . $pass . $host . $port . $path . $query . $fragment;
119
-    }
86
+	/**
87
+	 * refactor_url
88
+	 * primarily used for removing the query string from a URL
89
+	 *
90
+	 * @param string $url
91
+	 * @param bool   $remove_query  - TRUE (default) will strip off any URL params, ie: ?this=1&that=2
92
+	 * @param bool   $base_url_only - TRUE will only return the scheme and host with no other parameters
93
+	 * @return string
94
+	 */
95
+	public static function refactor_url($url = '', $remove_query = true, $base_url_only = false)
96
+	{
97
+		// break apart incoming URL
98
+		$url_bits = parse_url($url);
99
+		// HTTP or HTTPS ?
100
+		$scheme = isset($url_bits['scheme']) ? $url_bits['scheme'] . '://' : 'http://';
101
+		// domain
102
+		$host = isset($url_bits['host']) ? $url_bits['host'] : '';
103
+		// if only the base URL is requested, then return that now
104
+		if ($base_url_only) {
105
+			return $scheme . $host;
106
+		}
107
+		$port = isset($url_bits['port']) ? ':' . $url_bits['port'] : '';
108
+		$user = isset($url_bits['user']) ? $url_bits['user'] : '';
109
+		$pass = isset($url_bits['pass']) ? ':' . $url_bits['pass'] : '';
110
+		$pass = ($user || $pass) ? $pass . '@' : '';
111
+		$path = isset($url_bits['path']) ? $url_bits['path'] : '';
112
+		// if the query string is not required, then return what we have so far
113
+		if ($remove_query) {
114
+			return $scheme . $user . $pass . $host . $port . $path;
115
+		}
116
+		$query    = isset($url_bits['query']) ? '?' . $url_bits['query'] : '';
117
+		$fragment = isset($url_bits['fragment']) ? '#' . $url_bits['fragment'] : '';
118
+		return $scheme . $user . $pass . $host . $port . $path . $query . $fragment;
119
+	}
120 120
 
121 121
 
122
-    /**
123
-     * get_query_string
124
-     * returns just the query string from a URL, formatted by default into an array of key value pairs
125
-     *
126
-     * @param string $url
127
-     * @param bool   $as_array TRUE (default) will return query params as an array of key value pairs, FALSE will
128
-     *                         simply return the query string
129
-     * @return string|array
130
-     */
131
-    public static function get_query_string($url = '', $as_array = true)
132
-    {
133
-        // decode, then break apart incoming URL
134
-        $url_bits = parse_url(html_entity_decode($url));
135
-        // grab query string from URL
136
-        $query = isset($url_bits['query']) ? $url_bits['query'] : '';
137
-        // if we don't want the query string formatted into an array of key => value pairs, then just return it as is
138
-        if (! $as_array) {
139
-            return $query;
140
-        }
141
-        // if no query string exists then just return an empty array now
142
-        if (empty($query)) {
143
-            return array();
144
-        }
145
-        // empty array to hold results
146
-        $query_params = array();
147
-        // now break apart the query string into separate params
148
-        $query = explode('&', $query);
149
-        // loop thru our query params
150
-        foreach ($query as $query_args) {
151
-            // break apart the key value pairs
152
-            $query_args = explode('=', $query_args);
153
-            // and add to our results array
154
-            $query_params[ $query_args[0] ] = $query_args[1];
155
-        }
156
-        return $query_params;
157
-    }
122
+	/**
123
+	 * get_query_string
124
+	 * returns just the query string from a URL, formatted by default into an array of key value pairs
125
+	 *
126
+	 * @param string $url
127
+	 * @param bool   $as_array TRUE (default) will return query params as an array of key value pairs, FALSE will
128
+	 *                         simply return the query string
129
+	 * @return string|array
130
+	 */
131
+	public static function get_query_string($url = '', $as_array = true)
132
+	{
133
+		// decode, then break apart incoming URL
134
+		$url_bits = parse_url(html_entity_decode($url));
135
+		// grab query string from URL
136
+		$query = isset($url_bits['query']) ? $url_bits['query'] : '';
137
+		// if we don't want the query string formatted into an array of key => value pairs, then just return it as is
138
+		if (! $as_array) {
139
+			return $query;
140
+		}
141
+		// if no query string exists then just return an empty array now
142
+		if (empty($query)) {
143
+			return array();
144
+		}
145
+		// empty array to hold results
146
+		$query_params = array();
147
+		// now break apart the query string into separate params
148
+		$query = explode('&', $query);
149
+		// loop thru our query params
150
+		foreach ($query as $query_args) {
151
+			// break apart the key value pairs
152
+			$query_args = explode('=', $query_args);
153
+			// and add to our results array
154
+			$query_params[ $query_args[0] ] = $query_args[1];
155
+		}
156
+		return $query_params;
157
+	}
158 158
 
159 159
 
160
-    /**
161
-     * prevent_prefetching
162
-     *
163
-     * @return void
164
-     */
165
-    public static function prevent_prefetching()
166
-    {
167
-        // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes
168
-        // with the registration process
169
-        remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
170
-    }
160
+	/**
161
+	 * prevent_prefetching
162
+	 *
163
+	 * @return void
164
+	 */
165
+	public static function prevent_prefetching()
166
+	{
167
+		// prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes
168
+		// with the registration process
169
+		remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
170
+	}
171 171
 
172 172
 
173
-    /**
174
-     * This generates a unique site-specific string.
175
-     * An example usage for this string would be to save as a unique identifier for a record in the db for usage in
176
-     * urls.
177
-     *
178
-     * @param   string $prefix Use this to prefix the string with something.
179
-     * @return string
180
-     */
181
-    public static function generate_unique_token($prefix = '')
182
-    {
183
-        $token = md5(uniqid() . mt_rand());
184
-        return $prefix ? $prefix . '_' . $token : $token;
185
-    }
173
+	/**
174
+	 * This generates a unique site-specific string.
175
+	 * An example usage for this string would be to save as a unique identifier for a record in the db for usage in
176
+	 * urls.
177
+	 *
178
+	 * @param   string $prefix Use this to prefix the string with something.
179
+	 * @return string
180
+	 */
181
+	public static function generate_unique_token($prefix = '')
182
+	{
183
+		$token = md5(uniqid() . mt_rand());
184
+		return $prefix ? $prefix . '_' . $token : $token;
185
+	}
186 186
 
187 187
 
188
-    /**
189
-     * filter_input_server_url
190
-     * uses filter_input() to sanitize one of the INPUT_SERVER URL values
191
-     * but adds a backup in case filter_input() returns nothing, which can erringly happen on some servers
192
-     *
193
-     * @param string $server_variable
194
-     * @return string
195
-     */
196
-    public static function filter_input_server_url($server_variable = 'REQUEST_URI')
197
-    {
198
-        $URL              = '';
199
-        $server_variables = array(
200
-            'REQUEST_URI' => 1,
201
-            'HTTP_HOST'   => 1,
202
-            'PHP_SELF'    => 1,
203
-        );
204
-        $server_variable  = strtoupper($server_variable);
205
-        // whitelist INPUT_SERVER var
206
-        if (isset($server_variables[ $server_variable ])) {
207
-            $URL = filter_input(INPUT_SERVER, $server_variable, FILTER_SANITIZE_URL, FILTER_NULL_ON_FAILURE);
208
-            if (empty($URL)) {
209
-                // fallback sanitization if the above fails
210
-                $URL = wp_sanitize_redirect($_SERVER[ $server_variable ]);
211
-            }
212
-        }
213
-        return $URL;
214
-    }
188
+	/**
189
+	 * filter_input_server_url
190
+	 * uses filter_input() to sanitize one of the INPUT_SERVER URL values
191
+	 * but adds a backup in case filter_input() returns nothing, which can erringly happen on some servers
192
+	 *
193
+	 * @param string $server_variable
194
+	 * @return string
195
+	 */
196
+	public static function filter_input_server_url($server_variable = 'REQUEST_URI')
197
+	{
198
+		$URL              = '';
199
+		$server_variables = array(
200
+			'REQUEST_URI' => 1,
201
+			'HTTP_HOST'   => 1,
202
+			'PHP_SELF'    => 1,
203
+		);
204
+		$server_variable  = strtoupper($server_variable);
205
+		// whitelist INPUT_SERVER var
206
+		if (isset($server_variables[ $server_variable ])) {
207
+			$URL = filter_input(INPUT_SERVER, $server_variable, FILTER_SANITIZE_URL, FILTER_NULL_ON_FAILURE);
208
+			if (empty($URL)) {
209
+				// fallback sanitization if the above fails
210
+				$URL = wp_sanitize_redirect($_SERVER[ $server_variable ]);
211
+			}
212
+		}
213
+		return $URL;
214
+	}
215 215
 
216 216
 
217
-    /**
218
-     * Gets the current page's full URL.
219
-     *
220
-     * @return string
221
-     */
222
-    public static function current_url()
223
-    {
224
-        $url = '';
225
-        if (isset($_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'])) {
226
-            $url = is_ssl() ? 'https://' : 'http://';
227
-            $url .= \EEH_URL::filter_input_server_url('HTTP_HOST');
228
-            $url .= \EEH_URL::filter_input_server_url('REQUEST_URI');
229
-        }
230
-        return $url;
231
-    }
217
+	/**
218
+	 * Gets the current page's full URL.
219
+	 *
220
+	 * @return string
221
+	 */
222
+	public static function current_url()
223
+	{
224
+		$url = '';
225
+		if (isset($_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'])) {
226
+			$url = is_ssl() ? 'https://' : 'http://';
227
+			$url .= \EEH_URL::filter_input_server_url('HTTP_HOST');
228
+			$url .= \EEH_URL::filter_input_server_url('REQUEST_URI');
229
+		}
230
+		return $url;
231
+	}
232 232
 
233 233
 
234
-    /**
235
-     * Identical in functionality to EEH_current_url except it removes any provided query_parameters from it.
236
-     *
237
-     * @param array $query_parameters An array of query_parameters to remove from the current url.
238
-     * @since 4.9.46.rc.029
239
-     * @return string
240
-     */
241
-    public static function current_url_without_query_paramaters(array $query_parameters)
242
-    {
243
-        return remove_query_arg($query_parameters, EEH_URL::current_url());
244
-    }
234
+	/**
235
+	 * Identical in functionality to EEH_current_url except it removes any provided query_parameters from it.
236
+	 *
237
+	 * @param array $query_parameters An array of query_parameters to remove from the current url.
238
+	 * @since 4.9.46.rc.029
239
+	 * @return string
240
+	 */
241
+	public static function current_url_without_query_paramaters(array $query_parameters)
242
+	{
243
+		return remove_query_arg($query_parameters, EEH_URL::current_url());
244
+	}
245 245
 
246 246
 
247
-    /**
248
-     * @param string $location
249
-     * @param int    $status
250
-     * @param string $exit_notice
251
-     */
252
-    public static function safeRedirectAndExit($location, $status = 302, $exit_notice = '')
253
-    {
254
-        EE_Error::get_notices(false, true);
255
-        wp_safe_redirect($location, $status);
256
-        exit($exit_notice);
257
-    }
247
+	/**
248
+	 * @param string $location
249
+	 * @param int    $status
250
+	 * @param string $exit_notice
251
+	 */
252
+	public static function safeRedirectAndExit($location, $status = 302, $exit_notice = '')
253
+	{
254
+		EE_Error::get_notices(false, true);
255
+		wp_safe_redirect($location, $status);
256
+		exit($exit_notice);
257
+	}
258 258
 
259
-    /**
260
-     * Slugifies text for usage in a URL.
261
-     *
262
-     * Currently, this isn't just calling `sanitize_title()` on it, because that percent-encodes unicode characters,
263
-     * and WordPress chokes on them when used as CPT and custom taxonomy slugs.
264
-     *
265
-     * @since 4.9.66.p
266
-     * @param string $text
267
-     * @param string $fallback
268
-     * @return string which can be used in a URL
269
-     */
270
-    public static function slugify($text, $fallback)
271
-    {
272
-        // url decode after sanitizing title to restore unicode characters,
273
-        // see https://github.com/eventespresso/event-espresso-core/issues/575
274
-        return urldecode(
275
-            sanitize_title(
276
-                $text,
277
-                $fallback
278
-            )
279
-        );
280
-    }
259
+	/**
260
+	 * Slugifies text for usage in a URL.
261
+	 *
262
+	 * Currently, this isn't just calling `sanitize_title()` on it, because that percent-encodes unicode characters,
263
+	 * and WordPress chokes on them when used as CPT and custom taxonomy slugs.
264
+	 *
265
+	 * @since 4.9.66.p
266
+	 * @param string $text
267
+	 * @param string $fallback
268
+	 * @return string which can be used in a URL
269
+	 */
270
+	public static function slugify($text, $fallback)
271
+	{
272
+		// url decode after sanitizing title to restore unicode characters,
273
+		// see https://github.com/eventespresso/event-espresso-core/issues/575
274
+		return urldecode(
275
+			sanitize_title(
276
+				$text,
277
+				$fallback
278
+			)
279
+		);
280
+	}
281 281
 }
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -25,12 +25,12 @@  discard block
 block discarded – undo
25 25
     public static function add_query_args_and_nonce($args = array(), $url = '', $exclude_nonce = false)
26 26
     {
27 27
         // check that an action exists and add nonce
28
-        if (! $exclude_nonce) {
28
+        if ( ! $exclude_nonce) {
29 29
             if (isset($args['action']) && ! empty($args['action'])) {
30 30
                 $args = array_merge(
31 31
                     $args,
32 32
                     array(
33
-                        $args['action'] . '_nonce' => wp_create_nonce($args['action'] . '_nonce')
33
+                        $args['action'].'_nonce' => wp_create_nonce($args['action'].'_nonce')
34 34
                     )
35 35
                 );
36 36
             } else {
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
                 $args
73 73
             )
74 74
         );
75
-        if (! $results instanceof WP_Error &&
75
+        if ( ! $results instanceof WP_Error &&
76 76
             isset($results['response']) &&
77 77
             isset($results['response']['code']) &&
78 78
             $results['response']['code'] == '200') {
@@ -97,25 +97,25 @@  discard block
 block discarded – undo
97 97
         // break apart incoming URL
98 98
         $url_bits = parse_url($url);
99 99
         // HTTP or HTTPS ?
100
-        $scheme = isset($url_bits['scheme']) ? $url_bits['scheme'] . '://' : 'http://';
100
+        $scheme = isset($url_bits['scheme']) ? $url_bits['scheme'].'://' : 'http://';
101 101
         // domain
102 102
         $host = isset($url_bits['host']) ? $url_bits['host'] : '';
103 103
         // if only the base URL is requested, then return that now
104 104
         if ($base_url_only) {
105
-            return $scheme . $host;
105
+            return $scheme.$host;
106 106
         }
107
-        $port = isset($url_bits['port']) ? ':' . $url_bits['port'] : '';
107
+        $port = isset($url_bits['port']) ? ':'.$url_bits['port'] : '';
108 108
         $user = isset($url_bits['user']) ? $url_bits['user'] : '';
109
-        $pass = isset($url_bits['pass']) ? ':' . $url_bits['pass'] : '';
110
-        $pass = ($user || $pass) ? $pass . '@' : '';
109
+        $pass = isset($url_bits['pass']) ? ':'.$url_bits['pass'] : '';
110
+        $pass = ($user || $pass) ? $pass.'@' : '';
111 111
         $path = isset($url_bits['path']) ? $url_bits['path'] : '';
112 112
         // if the query string is not required, then return what we have so far
113 113
         if ($remove_query) {
114
-            return $scheme . $user . $pass . $host . $port . $path;
114
+            return $scheme.$user.$pass.$host.$port.$path;
115 115
         }
116
-        $query    = isset($url_bits['query']) ? '?' . $url_bits['query'] : '';
117
-        $fragment = isset($url_bits['fragment']) ? '#' . $url_bits['fragment'] : '';
118
-        return $scheme . $user . $pass . $host . $port . $path . $query . $fragment;
116
+        $query    = isset($url_bits['query']) ? '?'.$url_bits['query'] : '';
117
+        $fragment = isset($url_bits['fragment']) ? '#'.$url_bits['fragment'] : '';
118
+        return $scheme.$user.$pass.$host.$port.$path.$query.$fragment;
119 119
     }
120 120
 
121 121
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
         // grab query string from URL
136 136
         $query = isset($url_bits['query']) ? $url_bits['query'] : '';
137 137
         // if we don't want the query string formatted into an array of key => value pairs, then just return it as is
138
-        if (! $as_array) {
138
+        if ( ! $as_array) {
139 139
             return $query;
140 140
         }
141 141
         // if no query string exists then just return an empty array now
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
             // break apart the key value pairs
152 152
             $query_args = explode('=', $query_args);
153 153
             // and add to our results array
154
-            $query_params[ $query_args[0] ] = $query_args[1];
154
+            $query_params[$query_args[0]] = $query_args[1];
155 155
         }
156 156
         return $query_params;
157 157
     }
@@ -180,8 +180,8 @@  discard block
 block discarded – undo
180 180
      */
181 181
     public static function generate_unique_token($prefix = '')
182 182
     {
183
-        $token = md5(uniqid() . mt_rand());
184
-        return $prefix ? $prefix . '_' . $token : $token;
183
+        $token = md5(uniqid().mt_rand());
184
+        return $prefix ? $prefix.'_'.$token : $token;
185 185
     }
186 186
 
187 187
 
@@ -201,13 +201,13 @@  discard block
 block discarded – undo
201 201
             'HTTP_HOST'   => 1,
202 202
             'PHP_SELF'    => 1,
203 203
         );
204
-        $server_variable  = strtoupper($server_variable);
204
+        $server_variable = strtoupper($server_variable);
205 205
         // whitelist INPUT_SERVER var
206
-        if (isset($server_variables[ $server_variable ])) {
206
+        if (isset($server_variables[$server_variable])) {
207 207
             $URL = filter_input(INPUT_SERVER, $server_variable, FILTER_SANITIZE_URL, FILTER_NULL_ON_FAILURE);
208 208
             if (empty($URL)) {
209 209
                 // fallback sanitization if the above fails
210
-                $URL = wp_sanitize_redirect($_SERVER[ $server_variable ]);
210
+                $URL = wp_sanitize_redirect($_SERVER[$server_variable]);
211 211
             }
212 212
         }
213 213
         return $URL;
Please login to merge, or discard this patch.
core/libraries/messages/validators/EE_Messages_Validator.core.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -505,7 +505,7 @@
 block discarded – undo
505 505
      *
506 506
      * @param  string $value            string to evaluate
507 507
      * @param  array  $valid_shortcodes array of shortcodes that are acceptable.
508
-     * @return mixed (bool|string)  return either a list of invalid shortcodes OR false if the shortcodes validate.
508
+     * @return false|string (bool|string)  return either a list of invalid shortcodes OR false if the shortcodes validate.
509 509
      */
510 510
     protected function _invalid_shortcodes($value, $valid_shortcodes)
511 511
     {
Please login to merge, or discard this patch.
Indentation   +622 added lines, -622 removed lines patch added patch discarded remove patch
@@ -18,626 +18,626 @@
 block discarded – undo
18 18
 {
19 19
 
20 20
 
21
-    /**
22
-     * These properties just hold the name for the Messenger and Message Type (defined by child classes).
23
-     * These are used for retrieving objects etc.
24
-     *
25
-     * @var string
26
-     */
27
-    protected $_m_name;
28
-    protected $_mt_name;
29
-
30
-
31
-    /**
32
-     * This will hold any error messages from the validation process.
33
-     * The _errors property holds an associative array of error messages
34
-     * listing the field as the key and the message as the value.
35
-     *
36
-     * @var array()
37
-     */
38
-    private $_errors = array();
39
-
40
-
41
-    /**
42
-     * holds an array of fields being validated
43
-     *
44
-     * @var array
45
-     */
46
-    protected $_fields;
47
-
48
-
49
-    /**
50
-     * this will hold the incoming context
51
-     *
52
-     * @var string
53
-     */
54
-    protected $_context;
55
-
56
-
57
-    /**
58
-     * this holds an array of fields and the relevant validation information
59
-     * that the incoming fields data get validated against.
60
-     * This gets setup in the _set_props() method.
61
-     *
62
-     * @var array
63
-     */
64
-    protected $_validators;
65
-
66
-
67
-    /**
68
-     * holds the messenger object
69
-     *
70
-     * @var object
71
-     */
72
-    protected $_messenger;
73
-
74
-
75
-    /**
76
-     * holds the message type object
77
-     *
78
-     * @var object
79
-     */
80
-    protected $_message_type;
81
-
82
-
83
-    /**
84
-     * will hold any valid_shortcode modifications made by the _modify_validator() method.
85
-     *
86
-     * @var array
87
-     */
88
-    protected $_valid_shortcodes_modifier;
89
-
90
-
91
-    /**
92
-     * There may be times where a message type wants to include a shortcode group but exclude specific
93
-     * shortcodes.  If that's the case then it can set this property as an array of shortcodes to exclude and
94
-     * they will not be allowed.
95
-     * Array should be indexed by field and values are an array of specific shortcodes to exclude.
96
-     *
97
-     * @var array
98
-     */
99
-    protected $_specific_shortcode_excludes = array();
100
-
101
-
102
-    /**
103
-     * Runs the validator using the incoming fields array as the fields/values to check.
104
-     *
105
-     * @param array $fields The fields sent by the EEM object.
106
-     * @param       $context
107
-     * @throws EE_Error
108
-     * @throws ReflectionException
109
-     */
110
-    public function __construct($fields, $context)
111
-    {
112
-        // check that _m_name and _mt_name have been set by child class otherwise we get out.
113
-        if (empty($this->_m_name) || empty($this->_mt_name)) {
114
-            throw new EE_Error(
115
-                esc_html__(
116
-                    'EE_Messages_Validator child classes MUST set the $_m_name and $_mt_name property.  Check that the child class is doing this',
117
-                    'event_espresso'
118
-                )
119
-            );
120
-        }
121
-        $this->_fields  = $fields;
122
-        $this->_context = $context;
123
-
124
-        // load messenger and message_type objects and the related shortcode objects.
125
-        $this->_load_objects();
126
-
127
-
128
-        // modify any messenger/message_type specific validation instructions.  This is what child classes define.
129
-        $this->_modify_validator();
130
-
131
-
132
-        // let's set validators property
133
-        $this->_set_validators();
134
-    }
135
-
136
-
137
-    /**
138
-     * Child classes instantiate this and use it to modify the _validator_config array property
139
-     * for the messenger using messengers set_validate_config() method.
140
-     * This is so we can specify specific validation instructions for a messenger/message_type combo
141
-     * that aren't handled by the defaults setup in the messenger.
142
-     *
143
-     * @abstract
144
-     * @access protected
145
-     * @return void
146
-     */
147
-    abstract protected function _modify_validator();
148
-
149
-
150
-    /**
151
-     * loads all objects used by validator
152
-     *
153
-     * @access private
154
-     * @throws \EE_Error
155
-     */
156
-    private function _load_objects()
157
-    {
158
-        // load messenger
159
-        $messenger = ucwords(str_replace('_', ' ', $this->_m_name));
160
-        $messenger = str_replace(' ', '_', $messenger);
161
-        $messenger = 'EE_' . $messenger . '_messenger';
162
-
163
-        if (! class_exists($messenger)) {
164
-            throw new EE_Error(
165
-                sprintf(
166
-                    esc_html__('There is no messenger class for the given string (%s)', 'event_espresso'),
167
-                    $this->_m_name
168
-                )
169
-            );
170
-        }
171
-
172
-        $this->_messenger = new $messenger();
173
-
174
-        // load message type
175
-        $message_type = ucwords(str_replace('_', ' ', $this->_mt_name));
176
-        $message_type = str_replace(' ', '_', $message_type);
177
-        $message_type = 'EE_' . $message_type . '_message_type';
178
-
179
-        if (! class_exists($message_type)) {
180
-            throw new EE_Error(
181
-                sprintf(
182
-                    esc_html__('There is no message type class for the given string (%s)', 'event_espresso'),
183
-                    $this->_mt_name
184
-                )
185
-            );
186
-        }
187
-
188
-        $this->_message_type = new $message_type();
189
-    }
190
-
191
-
192
-    /**
193
-     * used to set the $_validators property
194
-     *
195
-     * @access private
196
-     * @return void
197
-     * @throws ReflectionException
198
-     */
199
-    private function _set_validators()
200
-    {
201
-        // let's get all valid shortcodes from mt and message type
202
-        // (messenger will have its set in the _validator_config property for the messenger)
203
-        $mt_codes = $this->_message_type->get_valid_shortcodes();
204
-
205
-
206
-        // get messenger validator_config
207
-        $msgr_validator = $this->_messenger->get_validator_config();
208
-
209
-
210
-        // we only want the valid shortcodes for the given context!
211
-        $context  = $this->_context;
212
-        $mt_codes = $mt_codes[ $context ];
213
-
214
-        // in this first loop we're just getting all shortcode group indexes from the msgr_validator
215
-        // into a single array (so we can get the appropriate shortcode objects for the groups)
216
-        $shortcode_groups = $mt_codes;
217
-        $groups_per_field = array();
218
-
219
-        foreach ($msgr_validator as $field => $config) {
220
-            if (empty($config) || ! isset($config['shortcodes'])) {
221
-                continue;
222
-            }  //Nothing to see here.
223
-            $groups_per_field[ $field ] = array_intersect($config['shortcodes'], $mt_codes);
224
-            $shortcode_groups         = array_merge($config['shortcodes'], $shortcode_groups);
225
-        }
226
-
227
-        $shortcode_groups = array_unique($shortcode_groups);
228
-
229
-        // okay now we've got our groups.
230
-        // Let's get the codes from the objects into an array indexed by group for easy retrieval later.
231
-        $codes_from_objs = array();
232
-
233
-        foreach ($shortcode_groups as $group) {
234
-            $ref       = ucwords(str_replace('_', ' ', $group));
235
-            $ref       = str_replace(' ', '_', $ref);
236
-            $classname = 'EE_' . $ref . '_Shortcodes';
237
-            if (class_exists($classname)) {
238
-                $a                       = new ReflectionClass($classname);
239
-                $obj                     = $a->newInstance();
240
-                $codes_from_objs[ $group ] = $obj->get_shortcodes();
241
-            }
242
-        }
243
-
244
-
245
-        // let's just replace the $mt shortcode group indexes with the actual shortcodes (unique)
246
-        $final_mt_codes = array();
247
-        foreach ($mt_codes as $group) {
248
-            $final_mt_codes = array_merge($final_mt_codes, $codes_from_objs[ $group ]);
249
-        }
250
-
251
-        $mt_codes = $final_mt_codes;
252
-
253
-
254
-        // k now in this next loop we're going to loop through $msgr_validator again
255
-        // and setup the _validators property from the data we've setup so far.
256
-        foreach ($msgr_validator as $field => $config) {
257
-            // if required shortcode is not in our list of codes for the given field, then we skip this field.
258
-            $required = isset($config['required'])
259
-                ? array_intersect($config['required'], array_keys($mt_codes))
260
-                : true;
261
-            if (empty($required)) {
262
-                continue;
263
-            }
264
-
265
-            // If we have an override then we use it to indicate the codes we want.
266
-            if (isset($this->_valid_shortcodes_modifier[ $context ][ $field ])) {
267
-                $this->_validators[ $field ]['shortcodes'] = $this->_reassemble_valid_shortcodes_from_group(
268
-                    $this->_valid_shortcodes_modifier[ $context ][ $field ],
269
-                    $codes_from_objs
270
-                );
271
-            } //if we have specific shortcodes for a field then we need to use them
272
-            elseif (isset($groups_per_field[ $field ])) {
273
-                $this->_validators[ $field ]['shortcodes'] = $this->_reassemble_valid_shortcodes_from_group(
274
-                    $groups_per_field[ $field ],
275
-                    $codes_from_objs
276
-                );
277
-            } //if empty config then we're assuming we're just going to use the shortcodes from the message type context
278
-            elseif (empty($config)) {
279
-                $this->_validators[ $field ]['shortcodes'] = $mt_codes;
280
-            } //if we have specific shortcodes then we need to use them
281
-            elseif (isset($config['specific_shortcodes'])) {
282
-                $this->_validators[ $field ]['shortcodes'] = $config['specific_shortcodes'];
283
-            } //otherwise the shortcodes are what is set by the messenger for that field
284
-            else {
285
-                foreach ($config['shortcodes'] as $group) {
286
-                    $this->_validators[ $field ]['shortcodes'] = isset($this->_validators[ $field ]['shortcodes'])
287
-                        ? array_merge($this->_validators[ $field ]['shortcodes'], $codes_from_objs[ $group ])
288
-                        : $codes_from_objs[ $group ];
289
-                }
290
-            }
291
-
292
-            // now let's just make sure that any excluded specific shortcodes are removed.
293
-            $specific_excludes = $this->get_specific_shortcode_excludes();
294
-            if (isset($specific_excludes[ $field ])) {
295
-                foreach ($specific_excludes[ $field ] as $sex) {
296
-                    if (isset($this->_validators[ $field ]['shortcodes'][ $sex ])) {
297
-                        unset($this->_validators[ $field ]['shortcodes'][ $sex ]);
298
-                    }
299
-                }
300
-            }
301
-
302
-            // hey! don't forget to include the type if present!
303
-            $this->_validators[ $field ]['type'] = isset($config['type']) ? $config['type'] : null;
304
-        }
305
-    }
306
-
307
-
308
-    /**
309
-     * This just returns the validators property that contains information
310
-     * about the various shortcodes and their availability with each field
311
-     *
312
-     * @return array
313
-     */
314
-    public function get_validators()
315
-    {
316
-        return $this->_validators;
317
-    }
318
-
319
-
320
-    /**
321
-     * This simply returns the specific shortcode_excludes property that is set.
322
-     *
323
-     * @since 4.5.0
324
-     * @return array
325
-     */
326
-    public function get_specific_shortcode_excludes()
327
-    {
328
-        // specific validator filter
329
-        $shortcode_excludes = apply_filters(
330
-            'FHEE__' . get_class($this) . '__get_specific_shortcode_excludes;',
331
-            $this->_specific_shortcode_excludes,
332
-            $this->_context
333
-        );
334
-        // global filter
335
-        return apply_filters(
336
-            'FHEE__EE_Messages_Validator__get_specific_shortcode_excludes',
337
-            $shortcode_excludes,
338
-            $this->_context,
339
-            $this
340
-        );
341
-    }
342
-
343
-
344
-    /**
345
-     * This is the main method that handles validation
346
-     * What it does is loop through the _fields (the ones that get validated)
347
-     * and checks them against the shortcodes array for the field and the 'type' indicated by the
348
-     *
349
-     * @access public
350
-     * @return mixed (bool|array)  if errors present we return the array otherwise true
351
-     */
352
-    public function validate()
353
-    {
354
-        // some defaults
355
-        $template_fields = $this->_messenger->get_template_fields();
356
-        // loop through the fields and check!
357
-        foreach ($this->_fields as $field => $value) {
358
-            $this->_errors[ $field ] = array();
359
-            $err_msg               = '';
360
-            $field_label           = '';
361
-            // if field is not present in the _validators array then we continue
362
-            if (! isset($this->_validators[ $field ])) {
363
-                unset($this->_errors[ $field ]);
364
-                continue;
365
-            }
366
-
367
-            // get the translated field label!
368
-            // first check if it's in the main fields list
369
-            if (isset($template_fields[ $field ])) {
370
-                if (empty($template_fields[ $field ])) {
371
-                    $field_label = $field;
372
-                } //most likely the field is found in the 'extra' array.
373
-                else {
374
-                    $field_label = $template_fields[ $field ]['label'];
375
-                }
376
-            }
377
-
378
-            // if field label is empty OR is equal to the current field
379
-            // then we need to loop through the 'extra' fields in the template_fields config (if present)
380
-            if (isset($template_fields['extra']) && (empty($field_label) || $field_label === $field)) {
381
-                foreach ($template_fields['extra'] as $main_field => $secondary_field) {
382
-                    foreach ($secondary_field as $name => $values) {
383
-                        if ($name === $field) {
384
-                            $field_label = $values['label'];
385
-                        }
386
-
387
-                        // if we've got a 'main' secondary field, let's see if that matches what field we're on
388
-                        // which means it contains the label for this field.
389
-                        if ($name === 'main' && $main_field === $field_label) {
390
-                            $field_label = $values['label'];
391
-                        }
392
-                    }
393
-                }
394
-            }
395
-
396
-            // field is present. Let's validate shortcodes first (but only if shortcodes present).
397
-            if (isset($this->_validators[ $field ]['shortcodes'])
398
-                && ! empty($this->_validators[ $field ]['shortcodes'])
399
-            ) {
400
-                $invalid_shortcodes = $this->_invalid_shortcodes($value, $this->_validators[ $field ]['shortcodes']);
401
-                // if true then that means there is a returned error message
402
-                // that we'll need to add to the _errors array for this field.
403
-                if ($invalid_shortcodes) {
404
-                    $v_s     = array_keys($this->_validators[ $field ]['shortcodes']);
405
-                    $err_msg = sprintf(
406
-                        esc_html__(
407
-                            '%3$sThe following shortcodes were found in the "%1$s" field that ARE not valid: %2$s%4$s',
408
-                            'event_espresso'
409
-                        ),
410
-                        '<strong>' . $field_label . '</strong>',
411
-                        $invalid_shortcodes,
412
-                        '<p>',
413
-                        '</p >'
414
-                    );
415
-                    $err_msg .= sprintf(
416
-                        esc_html__('%2$sValid shortcodes for this field are: %1$s%3$s', 'event_espresso'),
417
-                        implode(', ', $v_s),
418
-                        '<strong>',
419
-                        '</strong>'
420
-                    );
421
-                }
422
-            }
423
-
424
-            // if there's a "type" to be validated then let's do that too.
425
-            if (isset($this->_validators[ $field ]['type']) && ! empty($this->_validators[ $field ]['type'])) {
426
-                switch ($this->_validators[ $field ]['type']) {
427
-                    case 'number':
428
-                        if (! is_numeric($value)) {
429
-                            $err_msg .= sprintf(
430
-                                esc_html__(
431
-                                    '%3$sThe %1$s field is supposed to be a number. The value given (%2$s)  is not.  Please double-check and make sure the field contains a number%4$s',
432
-                                    'event_espresso'
433
-                                ),
434
-                                $field_label,
435
-                                $value,
436
-                                '<p>',
437
-                                '</p >'
438
-                            );
439
-                        }
440
-                        break;
441
-                    case 'email':
442
-                        $valid_email = $this->_validate_email($value);
443
-                        if (! $valid_email) {
444
-                            $err_msg .= htmlentities(
445
-                                sprintf(
446
-                                    esc_html__(
447
-                                        'The %1$s field has at least one string that is not a valid email address record.  Valid emails are in the format: "Name <[email protected]>" or "[email protected]" and multiple emails can be separated by a comma.',
448
-                                        'event_espresso'
449
-                                    ),
450
-                                    $field_label
451
-                                )
452
-                            );
453
-                        }
454
-                        break;
455
-                    default:
456
-                        break;
457
-                }
458
-            }
459
-
460
-            // if $err_msg isn't empty let's setup the _errors array for this field.
461
-            if (! empty($err_msg)) {
462
-                $this->_errors[ $field ]['msg'] = $err_msg;
463
-            } else {
464
-                unset($this->_errors[ $field ]);
465
-            }
466
-        }
467
-
468
-        // if we have ANY errors, then we want to make sure we return the values
469
-        // for ALL the fields so the user doesn't have to retype them all.
470
-        if (! empty($this->_errors)) {
471
-            foreach ($this->_fields as $field => $value) {
472
-                $this->_errors[ $field ]['value'] = stripslashes($value);
473
-            }
474
-        }
475
-
476
-        // return any errors or just TRUE if everything validates
477
-        return empty($this->_errors) ? true : $this->_errors;
478
-    }
479
-
480
-
481
-    /**
482
-     * Reassembles and returns an array of valid shortcodes
483
-     * given the array of groups and array of shortcodes indexed by group.
484
-     *
485
-     * @param  array $groups          array of shortcode groups that we want shortcodes for
486
-     * @param  array $codes_from_objs All the codes available.
487
-     * @return array                   an array of actual shortcodes (that will be used for validation).
488
-     */
489
-    private function _reassemble_valid_shortcodes_from_group($groups, $codes_from_objs)
490
-    {
491
-        $shortcodes = array();
492
-        foreach ($groups as $group) {
493
-            $shortcodes = array_merge($shortcodes, $codes_from_objs[ $group ]);
494
-        }
495
-        return $shortcodes;
496
-    }
497
-
498
-
499
-    /**
500
-     * Validates a string against a list of accepted shortcodes
501
-     * This function takes in an array of shortcodes
502
-     * and makes sure that the given string ONLY contains shortcodes in that array.
503
-     *
504
-     * @param  string $value            string to evaluate
505
-     * @param  array  $valid_shortcodes array of shortcodes that are acceptable.
506
-     * @return mixed (bool|string)  return either a list of invalid shortcodes OR false if the shortcodes validate.
507
-     */
508
-    protected function _invalid_shortcodes($value, $valid_shortcodes)
509
-    {
510
-        // first we need to go through the string and get the shortcodes in the string
511
-        preg_match_all('/(\[.+?\])/', $value, $matches);
512
-        $incoming_shortcodes = (array) $matches[0];
513
-
514
-        // get a diff of the shortcodes in the string vs the valid shortcodes
515
-        $diff = array_diff($incoming_shortcodes, array_keys($valid_shortcodes));
516
-
517
-        // we need to account for custom codes so let's loop through the diff and remove any of those type of codes
518
-        foreach ($diff as $ind => $code) {
519
-            if (preg_match('/(\[[A-Za-z0-9\_]+_\*)/', $code)) {
520
-                // strip the shortcode so we just have the BASE string (i.e. [ANSWER_*] )
521
-                $dynamic_sc = preg_replace('/(_\*+.+)/', '_*]', $code);
522
-                // does this exist in the $valid_shortcodes?  If so then unset.
523
-                if (isset($valid_shortcodes[ $dynamic_sc ])) {
524
-                    unset($diff[ $ind ]);
525
-                }
526
-            }
527
-        }
528
-
529
-        if (empty($diff)) {
530
-            return false;
531
-        } //there is no diff, we have no invalid shortcodes, so return
532
-
533
-        // made it here? then let's assemble the error message
534
-        $invalid_shortcodes = implode('</strong>,<strong>', $diff);
535
-        $invalid_shortcodes = '<strong>' . $invalid_shortcodes . '</strong>';
536
-        return $invalid_shortcodes;
537
-    }
538
-
539
-
540
-    /**
541
-     * Validates an incoming string and makes sure we have valid emails in the string.
542
-     *
543
-     * @param  string $value incoming value to validate
544
-     * @return bool        true if the string validates, false if it doesn't
545
-     */
546
-    protected function _validate_email($value)
547
-    {
548
-        $validate = true;
549
-        $or_val   = $value;
550
-
551
-        // empty strings will validate because this is how a message template
552
-        // for a particular context can be "turned off" (if there is no email then no message)
553
-        if (empty($value)) {
554
-            return $validate;
555
-        }
556
-
557
-        // first determine if there ARE any shortcodes.
558
-        // If there are shortcodes and then later we find that there were no other valid emails
559
-        // but the field isn't empty...
560
-        // that means we've got extra commas that were left after stripping out shortcodes so probably still valid.
561
-        $has_shortcodes = preg_match('/(\[.+?\])/', $value);
562
-
563
-        // first we need to strip out all the shortcodes!
564
-        $value = preg_replace('/(\[.+?\])/', '', $value);
565
-
566
-        // if original value is not empty and new value is, then we've parsed out a shortcode
567
-        // and we now have an empty string which DOES validate.
568
-        // We also validate complete empty field for email because
569
-        // its possible that this message is being "turned off" for a particular context
570
-
571
-
572
-        if (! empty($or_val) && empty($value)) {
573
-            return $validate;
574
-        }
575
-
576
-        // trim any commas from beginning and end of string ( after whitespace trimmed );
577
-        $value = trim(trim($value), ',');
578
-
579
-
580
-        // next we need to split up the string if its comma delimited.
581
-        $emails = explode(',', $value);
582
-        $empty  = false; // used to indicate that there is an empty comma.
583
-        // now let's loop through the emails and do our checks
584
-        foreach ($emails as $email) {
585
-            if (empty($email)) {
586
-                $empty = true;
587
-                continue;
588
-            }
589
-
590
-            // trim whitespace
591
-            $email = trim($email);
592
-            // either its of type "[email protected]", or its of type "fname lname <[email protected]>"
593
-            if (is_email($email)) {
594
-                continue;
595
-            }
596
-            $matches  = array();
597
-            $validate = preg_match('/(.*)<(.+)>/', $email, $matches) ? true : false;
598
-            if ($validate && is_email($matches[2])) {
599
-                continue;
600
-            }
601
-            return false;
602
-        }
603
-
604
-        $validate = $empty && ! $has_shortcodes ? false : $validate;
605
-
606
-        return $validate;
607
-    }
608
-
609
-
610
-    /**
611
-     * Magic getter
612
-     * Using this to provide back compat with add-ons referencing deprecated properties.
613
-     *
614
-     * @param string $property Property being requested
615
-     * @throws Exception
616
-     * @return mixed
617
-     */
618
-    public function __get($property)
619
-    {
620
-        $expected_properties_map = array(
621
-            /**
622
-             * @deprecated 4.9.0
623
-             */
624
-            '_MSGR'   => '_messenger',
625
-            /**
626
-             * @deprecated 4.9.0
627
-             */
628
-            '_MSGTYP' => '_message_type',
629
-        );
630
-
631
-        if (isset($expected_properties_map[ $property ])) {
632
-            return $this->{$expected_properties_map[ $property ]};
633
-        }
634
-
635
-        throw new Exception(
636
-            sprintf(
637
-                esc_html__('The property %1$s being requested on %2$s does not exist', 'event_espresso'),
638
-                $property,
639
-                get_class($this)
640
-            )
641
-        );
642
-    }
21
+	/**
22
+	 * These properties just hold the name for the Messenger and Message Type (defined by child classes).
23
+	 * These are used for retrieving objects etc.
24
+	 *
25
+	 * @var string
26
+	 */
27
+	protected $_m_name;
28
+	protected $_mt_name;
29
+
30
+
31
+	/**
32
+	 * This will hold any error messages from the validation process.
33
+	 * The _errors property holds an associative array of error messages
34
+	 * listing the field as the key and the message as the value.
35
+	 *
36
+	 * @var array()
37
+	 */
38
+	private $_errors = array();
39
+
40
+
41
+	/**
42
+	 * holds an array of fields being validated
43
+	 *
44
+	 * @var array
45
+	 */
46
+	protected $_fields;
47
+
48
+
49
+	/**
50
+	 * this will hold the incoming context
51
+	 *
52
+	 * @var string
53
+	 */
54
+	protected $_context;
55
+
56
+
57
+	/**
58
+	 * this holds an array of fields and the relevant validation information
59
+	 * that the incoming fields data get validated against.
60
+	 * This gets setup in the _set_props() method.
61
+	 *
62
+	 * @var array
63
+	 */
64
+	protected $_validators;
65
+
66
+
67
+	/**
68
+	 * holds the messenger object
69
+	 *
70
+	 * @var object
71
+	 */
72
+	protected $_messenger;
73
+
74
+
75
+	/**
76
+	 * holds the message type object
77
+	 *
78
+	 * @var object
79
+	 */
80
+	protected $_message_type;
81
+
82
+
83
+	/**
84
+	 * will hold any valid_shortcode modifications made by the _modify_validator() method.
85
+	 *
86
+	 * @var array
87
+	 */
88
+	protected $_valid_shortcodes_modifier;
89
+
90
+
91
+	/**
92
+	 * There may be times where a message type wants to include a shortcode group but exclude specific
93
+	 * shortcodes.  If that's the case then it can set this property as an array of shortcodes to exclude and
94
+	 * they will not be allowed.
95
+	 * Array should be indexed by field and values are an array of specific shortcodes to exclude.
96
+	 *
97
+	 * @var array
98
+	 */
99
+	protected $_specific_shortcode_excludes = array();
100
+
101
+
102
+	/**
103
+	 * Runs the validator using the incoming fields array as the fields/values to check.
104
+	 *
105
+	 * @param array $fields The fields sent by the EEM object.
106
+	 * @param       $context
107
+	 * @throws EE_Error
108
+	 * @throws ReflectionException
109
+	 */
110
+	public function __construct($fields, $context)
111
+	{
112
+		// check that _m_name and _mt_name have been set by child class otherwise we get out.
113
+		if (empty($this->_m_name) || empty($this->_mt_name)) {
114
+			throw new EE_Error(
115
+				esc_html__(
116
+					'EE_Messages_Validator child classes MUST set the $_m_name and $_mt_name property.  Check that the child class is doing this',
117
+					'event_espresso'
118
+				)
119
+			);
120
+		}
121
+		$this->_fields  = $fields;
122
+		$this->_context = $context;
123
+
124
+		// load messenger and message_type objects and the related shortcode objects.
125
+		$this->_load_objects();
126
+
127
+
128
+		// modify any messenger/message_type specific validation instructions.  This is what child classes define.
129
+		$this->_modify_validator();
130
+
131
+
132
+		// let's set validators property
133
+		$this->_set_validators();
134
+	}
135
+
136
+
137
+	/**
138
+	 * Child classes instantiate this and use it to modify the _validator_config array property
139
+	 * for the messenger using messengers set_validate_config() method.
140
+	 * This is so we can specify specific validation instructions for a messenger/message_type combo
141
+	 * that aren't handled by the defaults setup in the messenger.
142
+	 *
143
+	 * @abstract
144
+	 * @access protected
145
+	 * @return void
146
+	 */
147
+	abstract protected function _modify_validator();
148
+
149
+
150
+	/**
151
+	 * loads all objects used by validator
152
+	 *
153
+	 * @access private
154
+	 * @throws \EE_Error
155
+	 */
156
+	private function _load_objects()
157
+	{
158
+		// load messenger
159
+		$messenger = ucwords(str_replace('_', ' ', $this->_m_name));
160
+		$messenger = str_replace(' ', '_', $messenger);
161
+		$messenger = 'EE_' . $messenger . '_messenger';
162
+
163
+		if (! class_exists($messenger)) {
164
+			throw new EE_Error(
165
+				sprintf(
166
+					esc_html__('There is no messenger class for the given string (%s)', 'event_espresso'),
167
+					$this->_m_name
168
+				)
169
+			);
170
+		}
171
+
172
+		$this->_messenger = new $messenger();
173
+
174
+		// load message type
175
+		$message_type = ucwords(str_replace('_', ' ', $this->_mt_name));
176
+		$message_type = str_replace(' ', '_', $message_type);
177
+		$message_type = 'EE_' . $message_type . '_message_type';
178
+
179
+		if (! class_exists($message_type)) {
180
+			throw new EE_Error(
181
+				sprintf(
182
+					esc_html__('There is no message type class for the given string (%s)', 'event_espresso'),
183
+					$this->_mt_name
184
+				)
185
+			);
186
+		}
187
+
188
+		$this->_message_type = new $message_type();
189
+	}
190
+
191
+
192
+	/**
193
+	 * used to set the $_validators property
194
+	 *
195
+	 * @access private
196
+	 * @return void
197
+	 * @throws ReflectionException
198
+	 */
199
+	private function _set_validators()
200
+	{
201
+		// let's get all valid shortcodes from mt and message type
202
+		// (messenger will have its set in the _validator_config property for the messenger)
203
+		$mt_codes = $this->_message_type->get_valid_shortcodes();
204
+
205
+
206
+		// get messenger validator_config
207
+		$msgr_validator = $this->_messenger->get_validator_config();
208
+
209
+
210
+		// we only want the valid shortcodes for the given context!
211
+		$context  = $this->_context;
212
+		$mt_codes = $mt_codes[ $context ];
213
+
214
+		// in this first loop we're just getting all shortcode group indexes from the msgr_validator
215
+		// into a single array (so we can get the appropriate shortcode objects for the groups)
216
+		$shortcode_groups = $mt_codes;
217
+		$groups_per_field = array();
218
+
219
+		foreach ($msgr_validator as $field => $config) {
220
+			if (empty($config) || ! isset($config['shortcodes'])) {
221
+				continue;
222
+			}  //Nothing to see here.
223
+			$groups_per_field[ $field ] = array_intersect($config['shortcodes'], $mt_codes);
224
+			$shortcode_groups         = array_merge($config['shortcodes'], $shortcode_groups);
225
+		}
226
+
227
+		$shortcode_groups = array_unique($shortcode_groups);
228
+
229
+		// okay now we've got our groups.
230
+		// Let's get the codes from the objects into an array indexed by group for easy retrieval later.
231
+		$codes_from_objs = array();
232
+
233
+		foreach ($shortcode_groups as $group) {
234
+			$ref       = ucwords(str_replace('_', ' ', $group));
235
+			$ref       = str_replace(' ', '_', $ref);
236
+			$classname = 'EE_' . $ref . '_Shortcodes';
237
+			if (class_exists($classname)) {
238
+				$a                       = new ReflectionClass($classname);
239
+				$obj                     = $a->newInstance();
240
+				$codes_from_objs[ $group ] = $obj->get_shortcodes();
241
+			}
242
+		}
243
+
244
+
245
+		// let's just replace the $mt shortcode group indexes with the actual shortcodes (unique)
246
+		$final_mt_codes = array();
247
+		foreach ($mt_codes as $group) {
248
+			$final_mt_codes = array_merge($final_mt_codes, $codes_from_objs[ $group ]);
249
+		}
250
+
251
+		$mt_codes = $final_mt_codes;
252
+
253
+
254
+		// k now in this next loop we're going to loop through $msgr_validator again
255
+		// and setup the _validators property from the data we've setup so far.
256
+		foreach ($msgr_validator as $field => $config) {
257
+			// if required shortcode is not in our list of codes for the given field, then we skip this field.
258
+			$required = isset($config['required'])
259
+				? array_intersect($config['required'], array_keys($mt_codes))
260
+				: true;
261
+			if (empty($required)) {
262
+				continue;
263
+			}
264
+
265
+			// If we have an override then we use it to indicate the codes we want.
266
+			if (isset($this->_valid_shortcodes_modifier[ $context ][ $field ])) {
267
+				$this->_validators[ $field ]['shortcodes'] = $this->_reassemble_valid_shortcodes_from_group(
268
+					$this->_valid_shortcodes_modifier[ $context ][ $field ],
269
+					$codes_from_objs
270
+				);
271
+			} //if we have specific shortcodes for a field then we need to use them
272
+			elseif (isset($groups_per_field[ $field ])) {
273
+				$this->_validators[ $field ]['shortcodes'] = $this->_reassemble_valid_shortcodes_from_group(
274
+					$groups_per_field[ $field ],
275
+					$codes_from_objs
276
+				);
277
+			} //if empty config then we're assuming we're just going to use the shortcodes from the message type context
278
+			elseif (empty($config)) {
279
+				$this->_validators[ $field ]['shortcodes'] = $mt_codes;
280
+			} //if we have specific shortcodes then we need to use them
281
+			elseif (isset($config['specific_shortcodes'])) {
282
+				$this->_validators[ $field ]['shortcodes'] = $config['specific_shortcodes'];
283
+			} //otherwise the shortcodes are what is set by the messenger for that field
284
+			else {
285
+				foreach ($config['shortcodes'] as $group) {
286
+					$this->_validators[ $field ]['shortcodes'] = isset($this->_validators[ $field ]['shortcodes'])
287
+						? array_merge($this->_validators[ $field ]['shortcodes'], $codes_from_objs[ $group ])
288
+						: $codes_from_objs[ $group ];
289
+				}
290
+			}
291
+
292
+			// now let's just make sure that any excluded specific shortcodes are removed.
293
+			$specific_excludes = $this->get_specific_shortcode_excludes();
294
+			if (isset($specific_excludes[ $field ])) {
295
+				foreach ($specific_excludes[ $field ] as $sex) {
296
+					if (isset($this->_validators[ $field ]['shortcodes'][ $sex ])) {
297
+						unset($this->_validators[ $field ]['shortcodes'][ $sex ]);
298
+					}
299
+				}
300
+			}
301
+
302
+			// hey! don't forget to include the type if present!
303
+			$this->_validators[ $field ]['type'] = isset($config['type']) ? $config['type'] : null;
304
+		}
305
+	}
306
+
307
+
308
+	/**
309
+	 * This just returns the validators property that contains information
310
+	 * about the various shortcodes and their availability with each field
311
+	 *
312
+	 * @return array
313
+	 */
314
+	public function get_validators()
315
+	{
316
+		return $this->_validators;
317
+	}
318
+
319
+
320
+	/**
321
+	 * This simply returns the specific shortcode_excludes property that is set.
322
+	 *
323
+	 * @since 4.5.0
324
+	 * @return array
325
+	 */
326
+	public function get_specific_shortcode_excludes()
327
+	{
328
+		// specific validator filter
329
+		$shortcode_excludes = apply_filters(
330
+			'FHEE__' . get_class($this) . '__get_specific_shortcode_excludes;',
331
+			$this->_specific_shortcode_excludes,
332
+			$this->_context
333
+		);
334
+		// global filter
335
+		return apply_filters(
336
+			'FHEE__EE_Messages_Validator__get_specific_shortcode_excludes',
337
+			$shortcode_excludes,
338
+			$this->_context,
339
+			$this
340
+		);
341
+	}
342
+
343
+
344
+	/**
345
+	 * This is the main method that handles validation
346
+	 * What it does is loop through the _fields (the ones that get validated)
347
+	 * and checks them against the shortcodes array for the field and the 'type' indicated by the
348
+	 *
349
+	 * @access public
350
+	 * @return mixed (bool|array)  if errors present we return the array otherwise true
351
+	 */
352
+	public function validate()
353
+	{
354
+		// some defaults
355
+		$template_fields = $this->_messenger->get_template_fields();
356
+		// loop through the fields and check!
357
+		foreach ($this->_fields as $field => $value) {
358
+			$this->_errors[ $field ] = array();
359
+			$err_msg               = '';
360
+			$field_label           = '';
361
+			// if field is not present in the _validators array then we continue
362
+			if (! isset($this->_validators[ $field ])) {
363
+				unset($this->_errors[ $field ]);
364
+				continue;
365
+			}
366
+
367
+			// get the translated field label!
368
+			// first check if it's in the main fields list
369
+			if (isset($template_fields[ $field ])) {
370
+				if (empty($template_fields[ $field ])) {
371
+					$field_label = $field;
372
+				} //most likely the field is found in the 'extra' array.
373
+				else {
374
+					$field_label = $template_fields[ $field ]['label'];
375
+				}
376
+			}
377
+
378
+			// if field label is empty OR is equal to the current field
379
+			// then we need to loop through the 'extra' fields in the template_fields config (if present)
380
+			if (isset($template_fields['extra']) && (empty($field_label) || $field_label === $field)) {
381
+				foreach ($template_fields['extra'] as $main_field => $secondary_field) {
382
+					foreach ($secondary_field as $name => $values) {
383
+						if ($name === $field) {
384
+							$field_label = $values['label'];
385
+						}
386
+
387
+						// if we've got a 'main' secondary field, let's see if that matches what field we're on
388
+						// which means it contains the label for this field.
389
+						if ($name === 'main' && $main_field === $field_label) {
390
+							$field_label = $values['label'];
391
+						}
392
+					}
393
+				}
394
+			}
395
+
396
+			// field is present. Let's validate shortcodes first (but only if shortcodes present).
397
+			if (isset($this->_validators[ $field ]['shortcodes'])
398
+				&& ! empty($this->_validators[ $field ]['shortcodes'])
399
+			) {
400
+				$invalid_shortcodes = $this->_invalid_shortcodes($value, $this->_validators[ $field ]['shortcodes']);
401
+				// if true then that means there is a returned error message
402
+				// that we'll need to add to the _errors array for this field.
403
+				if ($invalid_shortcodes) {
404
+					$v_s     = array_keys($this->_validators[ $field ]['shortcodes']);
405
+					$err_msg = sprintf(
406
+						esc_html__(
407
+							'%3$sThe following shortcodes were found in the "%1$s" field that ARE not valid: %2$s%4$s',
408
+							'event_espresso'
409
+						),
410
+						'<strong>' . $field_label . '</strong>',
411
+						$invalid_shortcodes,
412
+						'<p>',
413
+						'</p >'
414
+					);
415
+					$err_msg .= sprintf(
416
+						esc_html__('%2$sValid shortcodes for this field are: %1$s%3$s', 'event_espresso'),
417
+						implode(', ', $v_s),
418
+						'<strong>',
419
+						'</strong>'
420
+					);
421
+				}
422
+			}
423
+
424
+			// if there's a "type" to be validated then let's do that too.
425
+			if (isset($this->_validators[ $field ]['type']) && ! empty($this->_validators[ $field ]['type'])) {
426
+				switch ($this->_validators[ $field ]['type']) {
427
+					case 'number':
428
+						if (! is_numeric($value)) {
429
+							$err_msg .= sprintf(
430
+								esc_html__(
431
+									'%3$sThe %1$s field is supposed to be a number. The value given (%2$s)  is not.  Please double-check and make sure the field contains a number%4$s',
432
+									'event_espresso'
433
+								),
434
+								$field_label,
435
+								$value,
436
+								'<p>',
437
+								'</p >'
438
+							);
439
+						}
440
+						break;
441
+					case 'email':
442
+						$valid_email = $this->_validate_email($value);
443
+						if (! $valid_email) {
444
+							$err_msg .= htmlentities(
445
+								sprintf(
446
+									esc_html__(
447
+										'The %1$s field has at least one string that is not a valid email address record.  Valid emails are in the format: "Name <[email protected]>" or "[email protected]" and multiple emails can be separated by a comma.',
448
+										'event_espresso'
449
+									),
450
+									$field_label
451
+								)
452
+							);
453
+						}
454
+						break;
455
+					default:
456
+						break;
457
+				}
458
+			}
459
+
460
+			// if $err_msg isn't empty let's setup the _errors array for this field.
461
+			if (! empty($err_msg)) {
462
+				$this->_errors[ $field ]['msg'] = $err_msg;
463
+			} else {
464
+				unset($this->_errors[ $field ]);
465
+			}
466
+		}
467
+
468
+		// if we have ANY errors, then we want to make sure we return the values
469
+		// for ALL the fields so the user doesn't have to retype them all.
470
+		if (! empty($this->_errors)) {
471
+			foreach ($this->_fields as $field => $value) {
472
+				$this->_errors[ $field ]['value'] = stripslashes($value);
473
+			}
474
+		}
475
+
476
+		// return any errors or just TRUE if everything validates
477
+		return empty($this->_errors) ? true : $this->_errors;
478
+	}
479
+
480
+
481
+	/**
482
+	 * Reassembles and returns an array of valid shortcodes
483
+	 * given the array of groups and array of shortcodes indexed by group.
484
+	 *
485
+	 * @param  array $groups          array of shortcode groups that we want shortcodes for
486
+	 * @param  array $codes_from_objs All the codes available.
487
+	 * @return array                   an array of actual shortcodes (that will be used for validation).
488
+	 */
489
+	private function _reassemble_valid_shortcodes_from_group($groups, $codes_from_objs)
490
+	{
491
+		$shortcodes = array();
492
+		foreach ($groups as $group) {
493
+			$shortcodes = array_merge($shortcodes, $codes_from_objs[ $group ]);
494
+		}
495
+		return $shortcodes;
496
+	}
497
+
498
+
499
+	/**
500
+	 * Validates a string against a list of accepted shortcodes
501
+	 * This function takes in an array of shortcodes
502
+	 * and makes sure that the given string ONLY contains shortcodes in that array.
503
+	 *
504
+	 * @param  string $value            string to evaluate
505
+	 * @param  array  $valid_shortcodes array of shortcodes that are acceptable.
506
+	 * @return mixed (bool|string)  return either a list of invalid shortcodes OR false if the shortcodes validate.
507
+	 */
508
+	protected function _invalid_shortcodes($value, $valid_shortcodes)
509
+	{
510
+		// first we need to go through the string and get the shortcodes in the string
511
+		preg_match_all('/(\[.+?\])/', $value, $matches);
512
+		$incoming_shortcodes = (array) $matches[0];
513
+
514
+		// get a diff of the shortcodes in the string vs the valid shortcodes
515
+		$diff = array_diff($incoming_shortcodes, array_keys($valid_shortcodes));
516
+
517
+		// we need to account for custom codes so let's loop through the diff and remove any of those type of codes
518
+		foreach ($diff as $ind => $code) {
519
+			if (preg_match('/(\[[A-Za-z0-9\_]+_\*)/', $code)) {
520
+				// strip the shortcode so we just have the BASE string (i.e. [ANSWER_*] )
521
+				$dynamic_sc = preg_replace('/(_\*+.+)/', '_*]', $code);
522
+				// does this exist in the $valid_shortcodes?  If so then unset.
523
+				if (isset($valid_shortcodes[ $dynamic_sc ])) {
524
+					unset($diff[ $ind ]);
525
+				}
526
+			}
527
+		}
528
+
529
+		if (empty($diff)) {
530
+			return false;
531
+		} //there is no diff, we have no invalid shortcodes, so return
532
+
533
+		// made it here? then let's assemble the error message
534
+		$invalid_shortcodes = implode('</strong>,<strong>', $diff);
535
+		$invalid_shortcodes = '<strong>' . $invalid_shortcodes . '</strong>';
536
+		return $invalid_shortcodes;
537
+	}
538
+
539
+
540
+	/**
541
+	 * Validates an incoming string and makes sure we have valid emails in the string.
542
+	 *
543
+	 * @param  string $value incoming value to validate
544
+	 * @return bool        true if the string validates, false if it doesn't
545
+	 */
546
+	protected function _validate_email($value)
547
+	{
548
+		$validate = true;
549
+		$or_val   = $value;
550
+
551
+		// empty strings will validate because this is how a message template
552
+		// for a particular context can be "turned off" (if there is no email then no message)
553
+		if (empty($value)) {
554
+			return $validate;
555
+		}
556
+
557
+		// first determine if there ARE any shortcodes.
558
+		// If there are shortcodes and then later we find that there were no other valid emails
559
+		// but the field isn't empty...
560
+		// that means we've got extra commas that were left after stripping out shortcodes so probably still valid.
561
+		$has_shortcodes = preg_match('/(\[.+?\])/', $value);
562
+
563
+		// first we need to strip out all the shortcodes!
564
+		$value = preg_replace('/(\[.+?\])/', '', $value);
565
+
566
+		// if original value is not empty and new value is, then we've parsed out a shortcode
567
+		// and we now have an empty string which DOES validate.
568
+		// We also validate complete empty field for email because
569
+		// its possible that this message is being "turned off" for a particular context
570
+
571
+
572
+		if (! empty($or_val) && empty($value)) {
573
+			return $validate;
574
+		}
575
+
576
+		// trim any commas from beginning and end of string ( after whitespace trimmed );
577
+		$value = trim(trim($value), ',');
578
+
579
+
580
+		// next we need to split up the string if its comma delimited.
581
+		$emails = explode(',', $value);
582
+		$empty  = false; // used to indicate that there is an empty comma.
583
+		// now let's loop through the emails and do our checks
584
+		foreach ($emails as $email) {
585
+			if (empty($email)) {
586
+				$empty = true;
587
+				continue;
588
+			}
589
+
590
+			// trim whitespace
591
+			$email = trim($email);
592
+			// either its of type "[email protected]", or its of type "fname lname <[email protected]>"
593
+			if (is_email($email)) {
594
+				continue;
595
+			}
596
+			$matches  = array();
597
+			$validate = preg_match('/(.*)<(.+)>/', $email, $matches) ? true : false;
598
+			if ($validate && is_email($matches[2])) {
599
+				continue;
600
+			}
601
+			return false;
602
+		}
603
+
604
+		$validate = $empty && ! $has_shortcodes ? false : $validate;
605
+
606
+		return $validate;
607
+	}
608
+
609
+
610
+	/**
611
+	 * Magic getter
612
+	 * Using this to provide back compat with add-ons referencing deprecated properties.
613
+	 *
614
+	 * @param string $property Property being requested
615
+	 * @throws Exception
616
+	 * @return mixed
617
+	 */
618
+	public function __get($property)
619
+	{
620
+		$expected_properties_map = array(
621
+			/**
622
+			 * @deprecated 4.9.0
623
+			 */
624
+			'_MSGR'   => '_messenger',
625
+			/**
626
+			 * @deprecated 4.9.0
627
+			 */
628
+			'_MSGTYP' => '_message_type',
629
+		);
630
+
631
+		if (isset($expected_properties_map[ $property ])) {
632
+			return $this->{$expected_properties_map[ $property ]};
633
+		}
634
+
635
+		throw new Exception(
636
+			sprintf(
637
+				esc_html__('The property %1$s being requested on %2$s does not exist', 'event_espresso'),
638
+				$property,
639
+				get_class($this)
640
+			)
641
+		);
642
+	}
643 643
 }
Please login to merge, or discard this patch.
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -158,9 +158,9 @@  discard block
 block discarded – undo
158 158
         // load messenger
159 159
         $messenger = ucwords(str_replace('_', ' ', $this->_m_name));
160 160
         $messenger = str_replace(' ', '_', $messenger);
161
-        $messenger = 'EE_' . $messenger . '_messenger';
161
+        $messenger = 'EE_'.$messenger.'_messenger';
162 162
 
163
-        if (! class_exists($messenger)) {
163
+        if ( ! class_exists($messenger)) {
164 164
             throw new EE_Error(
165 165
                 sprintf(
166 166
                     esc_html__('There is no messenger class for the given string (%s)', 'event_espresso'),
@@ -174,9 +174,9 @@  discard block
 block discarded – undo
174 174
         // load message type
175 175
         $message_type = ucwords(str_replace('_', ' ', $this->_mt_name));
176 176
         $message_type = str_replace(' ', '_', $message_type);
177
-        $message_type = 'EE_' . $message_type . '_message_type';
177
+        $message_type = 'EE_'.$message_type.'_message_type';
178 178
 
179
-        if (! class_exists($message_type)) {
179
+        if ( ! class_exists($message_type)) {
180 180
             throw new EE_Error(
181 181
                 sprintf(
182 182
                     esc_html__('There is no message type class for the given string (%s)', 'event_espresso'),
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 
210 210
         // we only want the valid shortcodes for the given context!
211 211
         $context  = $this->_context;
212
-        $mt_codes = $mt_codes[ $context ];
212
+        $mt_codes = $mt_codes[$context];
213 213
 
214 214
         // in this first loop we're just getting all shortcode group indexes from the msgr_validator
215 215
         // into a single array (so we can get the appropriate shortcode objects for the groups)
@@ -220,8 +220,8 @@  discard block
 block discarded – undo
220 220
             if (empty($config) || ! isset($config['shortcodes'])) {
221 221
                 continue;
222 222
             }  //Nothing to see here.
223
-            $groups_per_field[ $field ] = array_intersect($config['shortcodes'], $mt_codes);
224
-            $shortcode_groups         = array_merge($config['shortcodes'], $shortcode_groups);
223
+            $groups_per_field[$field] = array_intersect($config['shortcodes'], $mt_codes);
224
+            $shortcode_groups = array_merge($config['shortcodes'], $shortcode_groups);
225 225
         }
226 226
 
227 227
         $shortcode_groups = array_unique($shortcode_groups);
@@ -233,11 +233,11 @@  discard block
 block discarded – undo
233 233
         foreach ($shortcode_groups as $group) {
234 234
             $ref       = ucwords(str_replace('_', ' ', $group));
235 235
             $ref       = str_replace(' ', '_', $ref);
236
-            $classname = 'EE_' . $ref . '_Shortcodes';
236
+            $classname = 'EE_'.$ref.'_Shortcodes';
237 237
             if (class_exists($classname)) {
238 238
                 $a                       = new ReflectionClass($classname);
239 239
                 $obj                     = $a->newInstance();
240
-                $codes_from_objs[ $group ] = $obj->get_shortcodes();
240
+                $codes_from_objs[$group] = $obj->get_shortcodes();
241 241
             }
242 242
         }
243 243
 
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
         // let's just replace the $mt shortcode group indexes with the actual shortcodes (unique)
246 246
         $final_mt_codes = array();
247 247
         foreach ($mt_codes as $group) {
248
-            $final_mt_codes = array_merge($final_mt_codes, $codes_from_objs[ $group ]);
248
+            $final_mt_codes = array_merge($final_mt_codes, $codes_from_objs[$group]);
249 249
         }
250 250
 
251 251
         $mt_codes = $final_mt_codes;
@@ -263,44 +263,44 @@  discard block
 block discarded – undo
263 263
             }
264 264
 
265 265
             // If we have an override then we use it to indicate the codes we want.
266
-            if (isset($this->_valid_shortcodes_modifier[ $context ][ $field ])) {
267
-                $this->_validators[ $field ]['shortcodes'] = $this->_reassemble_valid_shortcodes_from_group(
268
-                    $this->_valid_shortcodes_modifier[ $context ][ $field ],
266
+            if (isset($this->_valid_shortcodes_modifier[$context][$field])) {
267
+                $this->_validators[$field]['shortcodes'] = $this->_reassemble_valid_shortcodes_from_group(
268
+                    $this->_valid_shortcodes_modifier[$context][$field],
269 269
                     $codes_from_objs
270 270
                 );
271 271
             } //if we have specific shortcodes for a field then we need to use them
272
-            elseif (isset($groups_per_field[ $field ])) {
273
-                $this->_validators[ $field ]['shortcodes'] = $this->_reassemble_valid_shortcodes_from_group(
274
-                    $groups_per_field[ $field ],
272
+            elseif (isset($groups_per_field[$field])) {
273
+                $this->_validators[$field]['shortcodes'] = $this->_reassemble_valid_shortcodes_from_group(
274
+                    $groups_per_field[$field],
275 275
                     $codes_from_objs
276 276
                 );
277 277
             } //if empty config then we're assuming we're just going to use the shortcodes from the message type context
278 278
             elseif (empty($config)) {
279
-                $this->_validators[ $field ]['shortcodes'] = $mt_codes;
279
+                $this->_validators[$field]['shortcodes'] = $mt_codes;
280 280
             } //if we have specific shortcodes then we need to use them
281 281
             elseif (isset($config['specific_shortcodes'])) {
282
-                $this->_validators[ $field ]['shortcodes'] = $config['specific_shortcodes'];
282
+                $this->_validators[$field]['shortcodes'] = $config['specific_shortcodes'];
283 283
             } //otherwise the shortcodes are what is set by the messenger for that field
284 284
             else {
285 285
                 foreach ($config['shortcodes'] as $group) {
286
-                    $this->_validators[ $field ]['shortcodes'] = isset($this->_validators[ $field ]['shortcodes'])
287
-                        ? array_merge($this->_validators[ $field ]['shortcodes'], $codes_from_objs[ $group ])
288
-                        : $codes_from_objs[ $group ];
286
+                    $this->_validators[$field]['shortcodes'] = isset($this->_validators[$field]['shortcodes'])
287
+                        ? array_merge($this->_validators[$field]['shortcodes'], $codes_from_objs[$group])
288
+                        : $codes_from_objs[$group];
289 289
                 }
290 290
             }
291 291
 
292 292
             // now let's just make sure that any excluded specific shortcodes are removed.
293 293
             $specific_excludes = $this->get_specific_shortcode_excludes();
294
-            if (isset($specific_excludes[ $field ])) {
295
-                foreach ($specific_excludes[ $field ] as $sex) {
296
-                    if (isset($this->_validators[ $field ]['shortcodes'][ $sex ])) {
297
-                        unset($this->_validators[ $field ]['shortcodes'][ $sex ]);
294
+            if (isset($specific_excludes[$field])) {
295
+                foreach ($specific_excludes[$field] as $sex) {
296
+                    if (isset($this->_validators[$field]['shortcodes'][$sex])) {
297
+                        unset($this->_validators[$field]['shortcodes'][$sex]);
298 298
                     }
299 299
                 }
300 300
             }
301 301
 
302 302
             // hey! don't forget to include the type if present!
303
-            $this->_validators[ $field ]['type'] = isset($config['type']) ? $config['type'] : null;
303
+            $this->_validators[$field]['type'] = isset($config['type']) ? $config['type'] : null;
304 304
         }
305 305
     }
306 306
 
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
     {
328 328
         // specific validator filter
329 329
         $shortcode_excludes = apply_filters(
330
-            'FHEE__' . get_class($this) . '__get_specific_shortcode_excludes;',
330
+            'FHEE__'.get_class($this).'__get_specific_shortcode_excludes;',
331 331
             $this->_specific_shortcode_excludes,
332 332
             $this->_context
333 333
         );
@@ -355,23 +355,23 @@  discard block
 block discarded – undo
355 355
         $template_fields = $this->_messenger->get_template_fields();
356 356
         // loop through the fields and check!
357 357
         foreach ($this->_fields as $field => $value) {
358
-            $this->_errors[ $field ] = array();
358
+            $this->_errors[$field] = array();
359 359
             $err_msg               = '';
360 360
             $field_label           = '';
361 361
             // if field is not present in the _validators array then we continue
362
-            if (! isset($this->_validators[ $field ])) {
363
-                unset($this->_errors[ $field ]);
362
+            if ( ! isset($this->_validators[$field])) {
363
+                unset($this->_errors[$field]);
364 364
                 continue;
365 365
             }
366 366
 
367 367
             // get the translated field label!
368 368
             // first check if it's in the main fields list
369
-            if (isset($template_fields[ $field ])) {
370
-                if (empty($template_fields[ $field ])) {
369
+            if (isset($template_fields[$field])) {
370
+                if (empty($template_fields[$field])) {
371 371
                     $field_label = $field;
372 372
                 } //most likely the field is found in the 'extra' array.
373 373
                 else {
374
-                    $field_label = $template_fields[ $field ]['label'];
374
+                    $field_label = $template_fields[$field]['label'];
375 375
                 }
376 376
             }
377 377
 
@@ -394,20 +394,20 @@  discard block
 block discarded – undo
394 394
             }
395 395
 
396 396
             // field is present. Let's validate shortcodes first (but only if shortcodes present).
397
-            if (isset($this->_validators[ $field ]['shortcodes'])
398
-                && ! empty($this->_validators[ $field ]['shortcodes'])
397
+            if (isset($this->_validators[$field]['shortcodes'])
398
+                && ! empty($this->_validators[$field]['shortcodes'])
399 399
             ) {
400
-                $invalid_shortcodes = $this->_invalid_shortcodes($value, $this->_validators[ $field ]['shortcodes']);
400
+                $invalid_shortcodes = $this->_invalid_shortcodes($value, $this->_validators[$field]['shortcodes']);
401 401
                 // if true then that means there is a returned error message
402 402
                 // that we'll need to add to the _errors array for this field.
403 403
                 if ($invalid_shortcodes) {
404
-                    $v_s     = array_keys($this->_validators[ $field ]['shortcodes']);
404
+                    $v_s     = array_keys($this->_validators[$field]['shortcodes']);
405 405
                     $err_msg = sprintf(
406 406
                         esc_html__(
407 407
                             '%3$sThe following shortcodes were found in the "%1$s" field that ARE not valid: %2$s%4$s',
408 408
                             'event_espresso'
409 409
                         ),
410
-                        '<strong>' . $field_label . '</strong>',
410
+                        '<strong>'.$field_label.'</strong>',
411 411
                         $invalid_shortcodes,
412 412
                         '<p>',
413 413
                         '</p >'
@@ -422,10 +422,10 @@  discard block
 block discarded – undo
422 422
             }
423 423
 
424 424
             // if there's a "type" to be validated then let's do that too.
425
-            if (isset($this->_validators[ $field ]['type']) && ! empty($this->_validators[ $field ]['type'])) {
426
-                switch ($this->_validators[ $field ]['type']) {
425
+            if (isset($this->_validators[$field]['type']) && ! empty($this->_validators[$field]['type'])) {
426
+                switch ($this->_validators[$field]['type']) {
427 427
                     case 'number':
428
-                        if (! is_numeric($value)) {
428
+                        if ( ! is_numeric($value)) {
429 429
                             $err_msg .= sprintf(
430 430
                                 esc_html__(
431 431
                                     '%3$sThe %1$s field is supposed to be a number. The value given (%2$s)  is not.  Please double-check and make sure the field contains a number%4$s',
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
                         break;
441 441
                     case 'email':
442 442
                         $valid_email = $this->_validate_email($value);
443
-                        if (! $valid_email) {
443
+                        if ( ! $valid_email) {
444 444
                             $err_msg .= htmlentities(
445 445
                                 sprintf(
446 446
                                     esc_html__(
@@ -458,18 +458,18 @@  discard block
 block discarded – undo
458 458
             }
459 459
 
460 460
             // if $err_msg isn't empty let's setup the _errors array for this field.
461
-            if (! empty($err_msg)) {
462
-                $this->_errors[ $field ]['msg'] = $err_msg;
461
+            if ( ! empty($err_msg)) {
462
+                $this->_errors[$field]['msg'] = $err_msg;
463 463
             } else {
464
-                unset($this->_errors[ $field ]);
464
+                unset($this->_errors[$field]);
465 465
             }
466 466
         }
467 467
 
468 468
         // if we have ANY errors, then we want to make sure we return the values
469 469
         // for ALL the fields so the user doesn't have to retype them all.
470
-        if (! empty($this->_errors)) {
470
+        if ( ! empty($this->_errors)) {
471 471
             foreach ($this->_fields as $field => $value) {
472
-                $this->_errors[ $field ]['value'] = stripslashes($value);
472
+                $this->_errors[$field]['value'] = stripslashes($value);
473 473
             }
474 474
         }
475 475
 
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
     {
491 491
         $shortcodes = array();
492 492
         foreach ($groups as $group) {
493
-            $shortcodes = array_merge($shortcodes, $codes_from_objs[ $group ]);
493
+            $shortcodes = array_merge($shortcodes, $codes_from_objs[$group]);
494 494
         }
495 495
         return $shortcodes;
496 496
     }
@@ -520,8 +520,8 @@  discard block
 block discarded – undo
520 520
                 // strip the shortcode so we just have the BASE string (i.e. [ANSWER_*] )
521 521
                 $dynamic_sc = preg_replace('/(_\*+.+)/', '_*]', $code);
522 522
                 // does this exist in the $valid_shortcodes?  If so then unset.
523
-                if (isset($valid_shortcodes[ $dynamic_sc ])) {
524
-                    unset($diff[ $ind ]);
523
+                if (isset($valid_shortcodes[$dynamic_sc])) {
524
+                    unset($diff[$ind]);
525 525
                 }
526 526
             }
527 527
         }
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
 
533 533
         // made it here? then let's assemble the error message
534 534
         $invalid_shortcodes = implode('</strong>,<strong>', $diff);
535
-        $invalid_shortcodes = '<strong>' . $invalid_shortcodes . '</strong>';
535
+        $invalid_shortcodes = '<strong>'.$invalid_shortcodes.'</strong>';
536 536
         return $invalid_shortcodes;
537 537
     }
538 538
 
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
         // its possible that this message is being "turned off" for a particular context
570 570
 
571 571
 
572
-        if (! empty($or_val) && empty($value)) {
572
+        if ( ! empty($or_val) && empty($value)) {
573 573
             return $validate;
574 574
         }
575 575
 
@@ -628,8 +628,8 @@  discard block
 block discarded – undo
628 628
             '_MSGTYP' => '_message_type',
629 629
         );
630 630
 
631
-        if (isset($expected_properties_map[ $property ])) {
632
-            return $this->{$expected_properties_map[ $property ]};
631
+        if (isset($expected_properties_map[$property])) {
632
+            return $this->{$expected_properties_map[$property]};
633 633
         }
634 634
 
635 635
         throw new Exception(
Please login to merge, or discard this patch.