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