Completed
Branch dependabot/composer/wp-graphql... (d51bd9)
by
unknown
05:53 queued 14s
created
payment_methods/Invoice/EE_PMT_Invoice.pm.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
             '<br />'
41 41
         );
42 42
         parent::__construct($pm_instance);
43
-        $this->_default_button_url = $this->file_url() . 'lib/invoice-logo.png';
43
+        $this->_default_button_url = $this->file_url().'lib/invoice-logo.png';
44 44
     }
45 45
 
46 46
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
     {
66 66
         $pdf_payee_input_name = 'pdf_payee_name';
67 67
         $confirmation_text_input_name = 'page_confirmation_text';
68
-        $form =  new EE_Payment_Method_Form(array(
68
+        $form = new EE_Payment_Method_Form(array(
69 69
 //              'payment_method_type' => $this,
70 70
                 'extra_meta_inputs' => array(
71 71
                     $pdf_payee_input_name => new EE_Text_Input(array(
@@ -79,12 +79,12 @@  discard block
 block discarded – undo
79 79
                         )),
80 80
                     'pdf_payee_address' => new EE_Text_Area_Input(array(
81 81
                         'html_label_text' => sprintf(esc_html__('Payee Address %s', 'event_espresso'), $this->get_help_tab_link()),
82
-                        'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
82
+                        'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
83 83
                     )),
84 84
                     'pdf_instructions' => new EE_Text_Area_Input(array(
85 85
                         'html_label_text' =>  sprintf(esc_html__("Instructions %s", "event_espresso"), $this->get_help_tab_link()),
86 86
                         'default' =>  esc_html__("Please send this invoice with payment attached to the address above, or use the payment link below. Payment must be received within 48 hours of event date.", 'event_espresso'),
87
-                        'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
87
+                        'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
88 88
                     )),
89 89
                     'pdf_logo_image' => new EE_Admin_File_Uploader_Input(array(
90 90
                         'html_label_text' =>  sprintf(esc_html__("Logo Image %s", "event_espresso"), $this->get_help_tab_link()),
@@ -94,24 +94,24 @@  discard block
 block discarded – undo
94 94
                     $confirmation_text_input_name => new EE_Text_Area_Input(array(
95 95
                         'html_label_text' =>  sprintf(esc_html__("Confirmation Text %s", "event_espresso"), $this->get_help_tab_link()),
96 96
                         'default' =>  esc_html__("Payment must be received within 48 hours of event date. Details about where to send the payment are included on the invoice.", 'event_espresso'),
97
-                        'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
97
+                        'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
98 98
                     )),
99 99
                     'page_extra_info' => new EE_Text_Area_Input(array(
100 100
                         'html_label_text' =>  sprintf(esc_html__("Extra Info %s", "event_espresso"), $this->get_help_tab_link()),
101
-                        'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
101
+                        'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
102 102
                     )),
103 103
                 ),
104 104
                 'include' => array(
105
-                    'PMD_ID', 'PMD_name','PMD_desc','PMD_admin_name','PMD_admin_desc', 'PMD_type','PMD_slug', 'PMD_open_by_default','PMD_button_url','PMD_scope','Currency','PMD_order',
106
-                    $pdf_payee_input_name, 'pdf_payee_email', 'pdf_payee_tax_number', 'pdf_payee_address', 'pdf_instructions','pdf_logo_image',
105
+                    'PMD_ID', 'PMD_name', 'PMD_desc', 'PMD_admin_name', 'PMD_admin_desc', 'PMD_type', 'PMD_slug', 'PMD_open_by_default', 'PMD_button_url', 'PMD_scope', 'Currency', 'PMD_order',
106
+                    $pdf_payee_input_name, 'pdf_payee_email', 'pdf_payee_tax_number', 'pdf_payee_address', 'pdf_instructions', 'pdf_logo_image',
107 107
                     $confirmation_text_input_name, 'page_extra_info'),
108 108
             ));
109 109
         $form->add_subsections(
110
-            array( 'header1' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_display.template.php')),
110
+            array('header1' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_display.template.php')),
111 111
             $pdf_payee_input_name
112 112
         );
113 113
         $form->add_subsections(
114
-            array( 'header2' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_gateway.template.php')),
114
+            array('header2' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_gateway.template.php')),
115 115
             $confirmation_text_input_name
116 116
         );
117 117
         return $form;
Please login to merge, or discard this patch.
Indentation   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -24,144 +24,144 @@
 block discarded – undo
24 24
  */
25 25
 class EE_PMT_Invoice extends EE_PMT_Base
26 26
 {
27
-    /**
28
-     * @param EE_Payment_Method|null $pm_instance
29
-     * @throws ReflectionException
30
-     * @throws EE_Error
31
-     */
32
-    public function __construct($pm_instance = null)
33
-    {
34
-        $this->_pretty_name = esc_html__("Invoice", 'event_espresso');
35
-        $this->_default_description = sprintf(
36
-            esc_html__('After clicking "Finalize Registration", you will be given instructions on how to access your invoice and complete your payment.%sPlease note that event spaces will not be reserved until payment is received in full, and any remaining tickets could be sold to others in the meantime.', 'event_espresso'),
37
-            '<br />'
38
-        );
39
-        parent::__construct($pm_instance);
40
-        $this->_default_button_url = $this->file_url() . 'lib/invoice-logo.png';
41
-    }
27
+	/**
28
+	 * @param EE_Payment_Method|null $pm_instance
29
+	 * @throws ReflectionException
30
+	 * @throws EE_Error
31
+	 */
32
+	public function __construct($pm_instance = null)
33
+	{
34
+		$this->_pretty_name = esc_html__("Invoice", 'event_espresso');
35
+		$this->_default_description = sprintf(
36
+			esc_html__('After clicking "Finalize Registration", you will be given instructions on how to access your invoice and complete your payment.%sPlease note that event spaces will not be reserved until payment is received in full, and any remaining tickets could be sold to others in the meantime.', 'event_espresso'),
37
+			'<br />'
38
+		);
39
+		parent::__construct($pm_instance);
40
+		$this->_default_button_url = $this->file_url() . 'lib/invoice-logo.png';
41
+	}
42 42
 
43 43
 
44 44
 
45
-    /**
46
-     * Creates the billing form for this payment method type
47
-     * @param EE_Transaction|null $transaction
48
-     * @return EE_Billing_Info_Form|null
49
-     * @throws EE_Error
50
-     * @throws ReflectionException
51
-     */
52
-    public function generate_new_billing_form(EE_Transaction $transaction = null)
53
-    {
54
-    return null;
55
-    }
45
+	/**
46
+	 * Creates the billing form for this payment method type
47
+	 * @param EE_Transaction|null $transaction
48
+	 * @return EE_Billing_Info_Form|null
49
+	 * @throws EE_Error
50
+	 * @throws ReflectionException
51
+	 */
52
+	public function generate_new_billing_form(EE_Transaction $transaction = null)
53
+	{
54
+	return null;
55
+	}
56 56
 
57 57
 
58 58
 
59
-    /**
60
-     * Gets the form for all the settings related to this payment method type
61
-     *
62
-     * @return EE_Payment_Method_Form
63
-     * @throws EE_Error
64
-     * @throws ReflectionException
65
-     */
66
-    public function generate_new_settings_form()
67
-    {
68
-        $pdf_payee_input_name = 'pdf_payee_name';
69
-        $confirmation_text_input_name = 'page_confirmation_text';
70
-        $form =  new EE_Payment_Method_Form(array(
59
+	/**
60
+	 * Gets the form for all the settings related to this payment method type
61
+	 *
62
+	 * @return EE_Payment_Method_Form
63
+	 * @throws EE_Error
64
+	 * @throws ReflectionException
65
+	 */
66
+	public function generate_new_settings_form()
67
+	{
68
+		$pdf_payee_input_name = 'pdf_payee_name';
69
+		$confirmation_text_input_name = 'page_confirmation_text';
70
+		$form =  new EE_Payment_Method_Form(array(
71 71
 //              'payment_method_type' => $this,
72
-                'extra_meta_inputs' => array(
73
-                    $pdf_payee_input_name => new EE_Text_Input(array(
74
-                        'html_label_text' => sprintf(esc_html__('Payee Name %s', 'event_espresso'), $this->get_help_tab_link())
75
-                    )),
76
-                    'pdf_payee_email' => new EE_Email_Input(array(
77
-                        'html_label_text' => sprintf(esc_html__('Payee Email %s', 'event_espresso'), $this->get_help_tab_link()),
78
-                    )),
79
-                    'pdf_payee_tax_number' => new EE_Text_Input(array(
80
-                        'html_label_text' => sprintf(esc_html__('Payee Tax Number %s', 'event_espresso'), $this->get_help_tab_link()),
81
-                        )),
82
-                    'pdf_payee_address' => new EE_Text_Area_Input(array(
83
-                        'html_label_text' => sprintf(esc_html__('Payee Address %s', 'event_espresso'), $this->get_help_tab_link()),
84
-                        'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
85
-                    )),
86
-                    'pdf_instructions' => new EE_Text_Area_Input(array(
87
-                        'html_label_text' =>  sprintf(esc_html__("Instructions %s", "event_espresso"), $this->get_help_tab_link()),
88
-                        'default' =>  esc_html__("Please send this invoice with payment attached to the address above, or use the payment link below. Payment must be received within 48 hours of event date.", 'event_espresso'),
89
-                        'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
90
-                    )),
91
-                    'pdf_logo_image' => new EE_Admin_File_Uploader_Input(array(
92
-                        'html_label_text' =>  sprintf(esc_html__("Logo Image %s", "event_espresso"), $this->get_help_tab_link()),
93
-                        'default' =>  EE_Config::instance()->organization->logo_url,
94
-                        'html_help_text' =>  esc_html__("(Logo for the top left of the invoice)", 'event_espresso'),
95
-                    )),
96
-                    $confirmation_text_input_name => new EE_Text_Area_Input(array(
97
-                        'html_label_text' =>  sprintf(esc_html__("Confirmation Text %s", "event_espresso"), $this->get_help_tab_link()),
98
-                        'default' =>  esc_html__("Payment must be received within 48 hours of event date. Details about where to send the payment are included on the invoice.", 'event_espresso'),
99
-                        'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
100
-                    )),
101
-                    'page_extra_info' => new EE_Text_Area_Input(array(
102
-                        'html_label_text' =>  sprintf(esc_html__("Extra Info %s", "event_espresso"), $this->get_help_tab_link()),
103
-                        'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
104
-                    )),
105
-                ),
106
-                'include' => array(
107
-                    'PMD_ID', 'PMD_name','PMD_desc','PMD_admin_name','PMD_admin_desc', 'PMD_type','PMD_slug', 'PMD_open_by_default','PMD_button_url','PMD_scope','Currency','PMD_order',
108
-                    $pdf_payee_input_name, 'pdf_payee_email', 'pdf_payee_tax_number', 'pdf_payee_address', 'pdf_instructions','pdf_logo_image',
109
-                    $confirmation_text_input_name, 'page_extra_info'),
110
-            ));
111
-        $form->add_subsections(
112
-            array( 'header1' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_display.template.php')),
113
-            $pdf_payee_input_name
114
-        );
115
-        $form->add_subsections(
116
-            array( 'header2' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_gateway.template.php')),
117
-            $confirmation_text_input_name
118
-        );
119
-        return $form;
120
-    }
72
+				'extra_meta_inputs' => array(
73
+					$pdf_payee_input_name => new EE_Text_Input(array(
74
+						'html_label_text' => sprintf(esc_html__('Payee Name %s', 'event_espresso'), $this->get_help_tab_link())
75
+					)),
76
+					'pdf_payee_email' => new EE_Email_Input(array(
77
+						'html_label_text' => sprintf(esc_html__('Payee Email %s', 'event_espresso'), $this->get_help_tab_link()),
78
+					)),
79
+					'pdf_payee_tax_number' => new EE_Text_Input(array(
80
+						'html_label_text' => sprintf(esc_html__('Payee Tax Number %s', 'event_espresso'), $this->get_help_tab_link()),
81
+						)),
82
+					'pdf_payee_address' => new EE_Text_Area_Input(array(
83
+						'html_label_text' => sprintf(esc_html__('Payee Address %s', 'event_espresso'), $this->get_help_tab_link()),
84
+						'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
85
+					)),
86
+					'pdf_instructions' => new EE_Text_Area_Input(array(
87
+						'html_label_text' =>  sprintf(esc_html__("Instructions %s", "event_espresso"), $this->get_help_tab_link()),
88
+						'default' =>  esc_html__("Please send this invoice with payment attached to the address above, or use the payment link below. Payment must be received within 48 hours of event date.", 'event_espresso'),
89
+						'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
90
+					)),
91
+					'pdf_logo_image' => new EE_Admin_File_Uploader_Input(array(
92
+						'html_label_text' =>  sprintf(esc_html__("Logo Image %s", "event_espresso"), $this->get_help_tab_link()),
93
+						'default' =>  EE_Config::instance()->organization->logo_url,
94
+						'html_help_text' =>  esc_html__("(Logo for the top left of the invoice)", 'event_espresso'),
95
+					)),
96
+					$confirmation_text_input_name => new EE_Text_Area_Input(array(
97
+						'html_label_text' =>  sprintf(esc_html__("Confirmation Text %s", "event_espresso"), $this->get_help_tab_link()),
98
+						'default' =>  esc_html__("Payment must be received within 48 hours of event date. Details about where to send the payment are included on the invoice.", 'event_espresso'),
99
+						'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
100
+					)),
101
+					'page_extra_info' => new EE_Text_Area_Input(array(
102
+						'html_label_text' =>  sprintf(esc_html__("Extra Info %s", "event_espresso"), $this->get_help_tab_link()),
103
+						'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
104
+					)),
105
+				),
106
+				'include' => array(
107
+					'PMD_ID', 'PMD_name','PMD_desc','PMD_admin_name','PMD_admin_desc', 'PMD_type','PMD_slug', 'PMD_open_by_default','PMD_button_url','PMD_scope','Currency','PMD_order',
108
+					$pdf_payee_input_name, 'pdf_payee_email', 'pdf_payee_tax_number', 'pdf_payee_address', 'pdf_instructions','pdf_logo_image',
109
+					$confirmation_text_input_name, 'page_extra_info'),
110
+			));
111
+		$form->add_subsections(
112
+			array( 'header1' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_display.template.php')),
113
+			$pdf_payee_input_name
114
+		);
115
+		$form->add_subsections(
116
+			array( 'header2' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_gateway.template.php')),
117
+			$confirmation_text_input_name
118
+		);
119
+		return $form;
120
+	}
121 121
 
122 122
 
123 123
 
124
-    /**
125
-     * Adds the help tab
126
-     *
127
-     * @return array
128
-     * @see EE_PMT_Base::help_tabs_config()
129
-     */
130
-    public function help_tabs_config()
131
-    {
132
-        return array(
133
-            $this->get_help_tab_name() => array(
134
-                'title' => esc_html__('Invoice Settings', 'event_espresso'),
135
-                'filename' => 'payment_methods_overview_invoice'
136
-            ),
137
-        );
138
-    }
124
+	/**
125
+	 * Adds the help tab
126
+	 *
127
+	 * @return array
128
+	 * @see EE_PMT_Base::help_tabs_config()
129
+	 */
130
+	public function help_tabs_config()
131
+	{
132
+		return array(
133
+			$this->get_help_tab_name() => array(
134
+				'title' => esc_html__('Invoice Settings', 'event_espresso'),
135
+				'filename' => 'payment_methods_overview_invoice'
136
+			),
137
+		);
138
+	}
139 139
 
140 140
 
141
-    /**
142
-     * For adding any html output above the payment overview.
143
-     * Many gateways won't want ot display anything, so this function just returns an empty string.
144
-     * Other gateways may want to override this, such as offline gateways.
145
-     *
146
-     * @param EE_Payment $payment
147
-     * @return string
148
-     * @throws EE_Error
149
-     * @throws ReflectionException
150
-     */
151
-    public function payment_overview_content(EE_Payment $payment)
152
-    {
153
-        return EEH_Template::locate_template(
154
-            'payment_methods/Invoice/templates/invoice_payment_details_content.template.php',
155
-            array_merge(
156
-                array(
157
-                    'payment_method'            => $this->_pm_instance,
158
-                    'payment'                       => $payment,
159
-                    'page_confirmation_text'                    => '',
160
-                    'page_extra_info'   => '',
161
-                    'invoice_url'                   => $payment->transaction()->primary_registration()->invoice_url('html')
162
-                ),
163
-                $this->_pm_instance->all_extra_meta_array()
164
-            )
165
-        );
166
-    }
141
+	/**
142
+	 * For adding any html output above the payment overview.
143
+	 * Many gateways won't want ot display anything, so this function just returns an empty string.
144
+	 * Other gateways may want to override this, such as offline gateways.
145
+	 *
146
+	 * @param EE_Payment $payment
147
+	 * @return string
148
+	 * @throws EE_Error
149
+	 * @throws ReflectionException
150
+	 */
151
+	public function payment_overview_content(EE_Payment $payment)
152
+	{
153
+		return EEH_Template::locate_template(
154
+			'payment_methods/Invoice/templates/invoice_payment_details_content.template.php',
155
+			array_merge(
156
+				array(
157
+					'payment_method'            => $this->_pm_instance,
158
+					'payment'                       => $payment,
159
+					'page_confirmation_text'                    => '',
160
+					'page_extra_info'   => '',
161
+					'invoice_url'                   => $payment->transaction()->primary_registration()->invoice_url('html')
162
+				),
163
+				$this->_pm_instance->all_extra_meta_array()
164
+			)
165
+		);
166
+	}
167 167
 }
Please login to merge, or discard this patch.
payment_methods/Invoice/templates/invoice_intro.template.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 esc_html_e(
4
-    'Invoice is an offline payment method for accepting payments. Payments are processed manually by providing your registrants/attendees with information on how to pay their invoice.',
5
-    'event_espresso'
4
+	'Invoice is an offline payment method for accepting payments. Payments are processed manually by providing your registrants/attendees with information on how to pay their invoice.',
5
+	'event_espresso'
6 6
 );
Please login to merge, or discard this patch.
caffeinated/EE_Caf_Messages.class.php 2 patches
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
      */
130 130
     public function messages_autoload_paths($dir_ref)
131 131
     {
132
-        $dir_ref[] = EE_CAF_LIBRARIES . 'shortcodes/';
132
+        $dir_ref[] = EE_CAF_LIBRARIES.'shortcodes/';
133 133
 
134 134
         return $dir_ref;
135 135
     }
@@ -245,32 +245,32 @@  discard block
 block discarded – undo
245 245
     ) {
246 246
 
247 247
         // we're only modifying templates for the default template pack
248
-        if (! $template_pack instanceof EE_Messages_Template_Pack_Default) {
248
+        if ( ! $template_pack instanceof EE_Messages_Template_Pack_Default) {
249 249
             return $contents;
250 250
         }
251 251
 
252 252
         // the template file name we're replacing contents for.
253
-        $template_file_prefix = $field . '_' . $context;
254
-        $msg_prefix = $messenger->name . '_' . $message_type->name . '_';
253
+        $template_file_prefix = $field.'_'.$context;
254
+        $msg_prefix = $messenger->name.'_'.$message_type->name.'_';
255 255
 
256
-        $base_path = EE_CAF_LIBRARIES . 'messages/defaults/default/';
256
+        $base_path = EE_CAF_LIBRARIES.'messages/defaults/default/';
257 257
 
258 258
         if ($messenger->name == 'email' && $message_type->name == 'registration') {
259 259
             switch ($template_file_prefix) {
260 260
                 case 'question_list_admin':
261 261
                 case 'question_list_attendee':
262 262
                 case 'question_list_primary_attendee':
263
-                    $path = $base_path . $msg_prefix . 'question_list.template.php';
263
+                    $path = $base_path.$msg_prefix.'question_list.template.php';
264 264
                     $contents = EEH_Template::display_template($path, array(), true);
265 265
                     break;
266 266
 
267 267
                 case 'attendee_list_primary_attendee':
268
-                    $path = $base_path . $msg_prefix . 'attendee_list.template.php';
268
+                    $path = $base_path.$msg_prefix.'attendee_list.template.php';
269 269
                     $contents = EEH_Template::display_template($path, array(), true);
270 270
                     break;
271 271
 
272 272
                 case 'attendee_list_admin':
273
-                    $path = $base_path . $msg_prefix . 'attendee_list_admin.template.php';
273
+                    $path = $base_path.$msg_prefix.'attendee_list_admin.template.php';
274 274
                     $contents = EEH_Template::display_template(
275 275
                         $path,
276 276
                         array(),
@@ -283,31 +283,31 @@  discard block
 block discarded – undo
283 283
                     break;
284 284
 
285 285
                 case 'event_list_attendee':
286
-                    $path = $base_path . $msg_prefix . 'event_list_attendee.template.php';
286
+                    $path = $base_path.$msg_prefix.'event_list_attendee.template.php';
287 287
                     $contents = EEH_Template::display_template($path, array(), true);
288 288
                     break;
289 289
             }
290 290
         } elseif ($messenger->name == 'email' && $message_type->name == 'newsletter') {
291 291
             switch ($template_file_prefix) {
292 292
                 case 'content_attendee':
293
-                    $path = $base_path . $msg_prefix . 'content.template.php';
293
+                    $path = $base_path.$msg_prefix.'content.template.php';
294 294
                     $contents = EEH_Template::display_template($path, array(), true);
295 295
                     break;
296 296
 
297 297
                 case 'newsletter_content_attendee':
298
-                    $path = $base_path . $msg_prefix . 'newsletter_content.template.php';
298
+                    $path = $base_path.$msg_prefix.'newsletter_content.template.php';
299 299
                     $contents = EEH_Template::display_template($path, array(), true);
300 300
                     break;
301 301
 
302 302
                 case 'newsletter_subject_attendee':
303
-                    $path = $base_path . $msg_prefix . 'subject.template.php';
303
+                    $path = $base_path.$msg_prefix.'subject.template.php';
304 304
                     $contents = EEH_Template::display_template($path, array(), true);
305 305
                     break;
306 306
             }
307 307
         } elseif ($messenger->name == 'html' && $message_type->name == 'receipt') {
308 308
             switch ($template_file_prefix) {
309 309
                 case 'attendee_list_purchaser':
310
-                    $path = $base_path . $msg_prefix . 'attendee_list.template.php';
310
+                    $path = $base_path.$msg_prefix.'attendee_list.template.php';
311 311
                     $contents = EEH_Template::display_template($path, array(), true);
312 312
                     break;
313 313
             }
@@ -338,8 +338,8 @@  discard block
 block discarded – undo
338 338
         if ($msg instanceof EE_message_type && in_array($msg->name, $include_with)) {
339 339
             $contexts = array_keys($msg->get_contexts());
340 340
             foreach ($contexts as $context) {
341
-                $valid_shortcodes[ $context ][] = 'question_list';
342
-                $valid_shortcodes[ $context ][] = 'question';
341
+                $valid_shortcodes[$context][] = 'question_list';
342
+                $valid_shortcodes[$context][] = 'question';
343 343
             }
344 344
         }
345 345
 
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
             $extra_data
384 384
         ) && isset($extra_data['data']) ? $extra_data['data'] : $aee;
385 385
 
386
-        if (! $registration instanceof EE_Registration || ! $aee instanceof EE_Messages_Addressee) {
386
+        if ( ! $registration instanceof EE_Registration || ! $aee instanceof EE_Messages_Addressee) {
387 387
             return $parsed;
388 388
         }
389 389
 
@@ -392,9 +392,9 @@  discard block
 block discarded – undo
392 392
             if (
393 393
                 $question instanceof EE_Question
394 394
                 && trim($question->display_text()) == trim($shortcode)
395
-                && isset($aee->registrations[ $registration->ID() ]['ans_objs'][ $ansid ])
395
+                && isset($aee->registrations[$registration->ID()]['ans_objs'][$ansid])
396 396
             ) {
397
-                return $aee->registrations[ $registration->ID() ]['ans_objs'][ $ansid ]->get_pretty(
397
+                return $aee->registrations[$registration->ID()]['ans_objs'][$ansid]->get_pretty(
398 398
                     'ANS_value',
399 399
                     'no_wpautop'
400 400
                 );
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
     public function additional_datetime_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
456 456
     {
457 457
 
458
-        if (! $data instanceof EE_Datetime) {
458
+        if ( ! $data instanceof EE_Datetime) {
459 459
             return ''; // get out because we can only parse with the datetime object.
460 460
         }
461 461
 
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
         $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
509 509
         $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient;
510 510
 
511
-        if (! $recipient instanceof EE_Messages_Addressee) {
511
+        if ( ! $recipient instanceof EE_Messages_Addressee) {
512 512
             return $parsed;
513 513
         }
514 514
 
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
             case '[RECIPIENT_QUESTION_LIST]':
517 517
                 $att = $recipient->att_obj;
518 518
                 $registrations_on_attendee = $att instanceof EE_Attendee
519
-                    ? $recipient->attendees[ $att->ID() ]['reg_objs']
519
+                    ? $recipient->attendees[$att->ID()]['reg_objs']
520 520
                     : array();
521 521
                 $registrations_on_attendee = empty($registrations_on_attendee) && $recipient->reg_obj instanceof EE_Registration ? array($recipient->reg_obj) : $registrations_on_attendee;
522 522
                 $answers = array();
@@ -530,12 +530,12 @@  discard block
 block discarded – undo
530 530
                 if ($data['data'] instanceof EE_Messages_Addressee) {
531 531
                     foreach ($registrations_on_attendee as $reg) {
532 532
                         if ($reg instanceof EE_Registration) {
533
-                            $anss = ! empty($recipient->registrations[ $reg->ID() ]['ans_objs'])
534
-                                ? $recipient->registrations[ $reg->ID() ]['ans_objs']
533
+                            $anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs'])
534
+                                ? $recipient->registrations[$reg->ID()]['ans_objs']
535 535
                                 : array();
536 536
                             foreach ($anss as $ans) {
537 537
                                 if ($ans instanceof EE_Answer) {
538
-                                    $answers[ $ans->ID() ] = $ans;
538
+                                    $answers[$ans->ID()] = $ans;
539 539
                                 }
540 540
                             }
541 541
                         }
@@ -547,12 +547,12 @@  discard block
 block discarded – undo
547 547
                     $event = $data['data'];
548 548
                     foreach ($registrations_on_attendee as $reg) {
549 549
                         if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) {
550
-                            $anss = ! empty($recipient->registrations[ $reg->ID() ]['ans_objs'])
551
-                                ? $recipient->registrations[ $reg->ID() ]['ans_objs']
550
+                            $anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs'])
551
+                                ? $recipient->registrations[$reg->ID()]['ans_objs']
552 552
                                 : array();
553 553
                             foreach ($anss as $ans) {
554 554
                                 if ($ans instanceof EE_Answer) {
555
-                                    $answers[ $ans->ID() ] = $ans;
555
+                                    $answers[$ans->ID()] = $ans;
556 556
                                 }
557 557
                             }
558 558
                         }
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
 
564 564
                 // if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
565 565
                 // object on it.
566
-                if (! isset($extra_data['data'])) {
566
+                if ( ! isset($extra_data['data'])) {
567 567
                     $extra_data['data'] = $recipient;
568 568
                 }
569 569
 
@@ -620,18 +620,18 @@  discard block
 block discarded – undo
620 620
         $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
621 621
         $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient;
622 622
 
623
-        if (! $recipient instanceof EE_Messages_Addressee) {
623
+        if ( ! $recipient instanceof EE_Messages_Addressee) {
624 624
             return $parsed;
625 625
         }
626 626
 
627 627
         switch ($shortcode) {
628 628
             case '[PRIMARY_REGISTRANT_QUESTION_LIST]':
629
-                if (! $recipient->primary_att_obj instanceof EE_Attendee || ! $recipient->primary_reg_obj instanceof EE_Registration) {
629
+                if ( ! $recipient->primary_att_obj instanceof EE_Attendee || ! $recipient->primary_reg_obj instanceof EE_Registration) {
630 630
                     return '';
631 631
                 }
632 632
                 $registration = $recipient->primary_reg_obj;
633
-                $answers = isset($recipient->registrations[ $registration->ID() ]['ans_objs'])
634
-                    ? $recipient->registrations[ $registration->ID() ]['ans_objs']
633
+                $answers = isset($recipient->registrations[$registration->ID()]['ans_objs'])
634
+                    ? $recipient->registrations[$registration->ID()]['ans_objs']
635 635
                     : array();
636 636
                 if (empty($answers)) {
637 637
                     return '';
@@ -640,11 +640,11 @@  discard block
 block discarded – undo
640 640
                     ? $data['template']['question_list']
641 641
                     : $extra_data['template']['question_list'];
642 642
                 $valid_shortcodes = array('question');
643
-                $answers = $recipient->registrations[ $registration->ID() ]['ans_objs'];
643
+                $answers = $recipient->registrations[$registration->ID()]['ans_objs'];
644 644
                 $questions = isset($recipient->questions) ? $recipient->questions : array();
645 645
                 // if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
646 646
                 // object on it.
647
-                if (! isset($extra_data['data'])) {
647
+                if ( ! isset($extra_data['data'])) {
648 648
                     $extra_data['data'] = $recipient;
649 649
                 }
650 650
                 return $this->_parse_question_list_for_primary_or_recipient_registration(
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
         $setup_args = array(
678 678
             'mtfilename'                                       => 'EE_Newsletter_message_type.class.php',
679 679
             'autoloadpaths'                                    => array(
680
-                EE_CAF_LIBRARIES . 'messages/message_type/newsletter/',
680
+                EE_CAF_LIBRARIES.'messages/message_type/newsletter/',
681 681
             ),
682 682
             'messengers_to_activate_with'                      => array('email'),
683 683
             'messengers_to_validate_with'                      => array('email'),
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
         // register payment reminder message type
689 689
         $setup_args = array(
690 690
             'mtfilename'                                       => 'EE_Payment_Reminder_message_type.class.php',
691
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'),
691
+            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES.'messages/message_type/payment_reminder/'),
692 692
             'messengers_to_activate_with'                      => array('email'),
693 693
             'messengers_to_validate_with'                      => array('email'),
694 694
             'messengers_supporting_default_template_pack_with' => array('email'),
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
         // register payment declined message type
699 699
         $setup_args = array(
700 700
             'mtfilename'                                       => 'EE_Payment_Declined_message_type.class.php',
701
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'),
701
+            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES.'messages/message_type/payment_declined/'),
702 702
             'messengers_to_activate_with'                      => array('email'),
703 703
             'messengers_to_validate_with'                      => array('email'),
704 704
             'messengers_supporting_default_template_pack_with' => array('email'),
@@ -708,7 +708,7 @@  discard block
 block discarded – undo
708 708
         // register registration declined message type
709 709
         $setup_args = array(
710 710
             'mtfilename'                                       => 'EE_Declined_Registration_message_type.class.php',
711
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'),
711
+            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES.'messages/message_type/declined_registration/'),
712 712
             'messengers_to_activate_with'                      => array('email'),
713 713
             'messengers_to_validate_with'                      => array('email'),
714 714
             'messengers_supporting_default_template_pack_with' => array('email'),
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
         // register registration cancelled message type
719 719
         $setup_args = array(
720 720
             'mtfilename'                                       => 'EE_Cancelled_Registration_message_type.class.php',
721
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'),
721
+            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES.'messages/message_type/cancelled_registration/'),
722 722
             'messengers_to_activate_with'                      => array('email'),
723 723
             'messengers_to_validate_with'                      => array('email'),
724 724
             'messengers_supporting_default_template_pack_with' => array('email'),
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
         // register payment failed message type
730 730
         $setup_args = array(
731 731
             'mtfilename'                                       => 'EE_Payment_Failed_message_type.class.php',
732
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'),
732
+            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES.'messages/message_type/payment_failed/'),
733 733
             'messengers_to_activate_with'                      => array('email'),
734 734
             'messengers_to_validate_with'                      => array('email'),
735 735
             'messengers_supporting_default_template_pack_with' => array('email'),
@@ -739,7 +739,7 @@  discard block
 block discarded – undo
739 739
         // register payment declined message type
740 740
         $setup_args = array(
741 741
             'mtfilename'                                       => 'EE_Payment_Cancelled_message_type.class.php',
742
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'),
742
+            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES.'messages/message_type/payment_cancelled/'),
743 743
             'messengers_to_activate_with'                      => array('email'),
744 744
             'messengers_to_validate_with'                      => array('email'),
745 745
             'messengers_supporting_default_template_pack_with' => array('email'),
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
     {
760 760
         $setup_args = array(
761 761
             'autoloadpaths'                 => array(
762
-                EE_CAF_LIBRARIES . 'shortcodes/',
762
+                EE_CAF_LIBRARIES.'shortcodes/',
763 763
             ),
764 764
             'msgr_validator_callback'       => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'),
765 765
             'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'),
@@ -793,7 +793,7 @@  discard block
 block discarded – undo
793 793
         foreach ($answers as $answer) {
794 794
             if ($answer instanceof EE_Answer) {
795 795
                 // first see if the question is in our $questions array. If not then try to get from answer object.
796
-                $question = isset($questions[ $answer->ID() ]) ? $questions[ $answer->ID() ] : null;
796
+                $question = isset($questions[$answer->ID()]) ? $questions[$answer->ID()] : null;
797 797
                 $question = ! $question instanceof EE_Question ? $answer->question() : $question;
798 798
                 if (
799 799
                     ! $question instanceof EE_Question
Please login to merge, or discard this patch.
Indentation   +802 added lines, -802 removed lines patch added patch discarded remove patch
@@ -10,806 +10,806 @@
 block discarded – undo
10 10
  */
11 11
 class EE_Caf_Messages
12 12
 {
13
-    /**
14
-     * constructor.
15
-     */
16
-    public function __construct()
17
-    {
18
-        $this->_caf_hooks();
19
-    }
20
-
21
-
22
-    /**
23
-     * Contains all the hooks filters for setting up caffeinated messages functionality.
24
-     *
25
-     * @since 4.3.2
26
-     *
27
-     * @return void
28
-     */
29
-    private function _caf_hooks()
30
-    {
31
-        add_filter('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array($this, 'messages_autoload_paths'), 5);
32
-        add_filter(
33
-            'FHEE__EE_Email_messenger__get_validator_config',
34
-            array($this, 'email_messenger_validator_config'),
35
-            5,
36
-            2
37
-        );
38
-        add_filter(
39
-            'FHEE__EE_Email_messenger__get_template_fields',
40
-            array($this, 'email_messenger_template_fields'),
41
-            5,
42
-            2
43
-        );
44
-        add_filter(
45
-            'FHEE__EE_Html_messenger__get_template_fields',
46
-            array($this, 'html_messenger_template_fields'),
47
-            5,
48
-            2
49
-        );
50
-        add_filter(
51
-            'FHEE__EE_Html_messenger__get_validator_config',
52
-            array($this, 'html_messenger_validator_config'),
53
-            5,
54
-            2
55
-        );
56
-        add_filter('FHEE__EE_Pdf_messenger__get_template_fields', array($this, 'pdf_messenger_template_fields'), 5, 2);
57
-        add_filter(
58
-            'FHEE__EE_Pdf_messenger__get_validator_config',
59
-            array($this, 'pdf_messenger_validator_config'),
60
-            5,
61
-            2
62
-        );
63
-        add_filter(
64
-            'FHEE__EE_Messages_Template_Pack__get_specific_template__contents',
65
-            array($this, 'new_default_templates'),
66
-            5,
67
-            7
68
-        );
69
-        add_filter(
70
-            'FHEE__EE_Messages_Base__get_valid_shortcodes',
71
-            array($this, 'message_types_valid_shortcodes'),
72
-            5,
73
-            2
74
-        );
75
-
76
-        // shortcode parsers
77
-        add_filter('FHEE__EE_Attendee_Shortcodes__shortcodes', array($this, 'additional_attendee_shortcodes'), 5, 2);
78
-        add_filter('FHEE__EE_Attendee_Shortcodes__parser_after', array($this, 'additional_attendee_parser'), 5, 5);
79
-        add_filter(
80
-            'FHEE__EE_Recipient_List_Shortcodes__shortcodes',
81
-            array($this, 'additional_recipient_details_shortcodes'),
82
-            5,
83
-            2
84
-        );
85
-        add_filter(
86
-            'FHEE__EE_Recipient_List_Shortcodes__parser_after',
87
-            array($this, 'additional_recipient_details_parser'),
88
-            5,
89
-            5
90
-        );
91
-        add_filter(
92
-            'FHEE__EE_Primary_Registration_List_Shortcodes__shortcodes',
93
-            array($this, 'additional_primary_registration_details_shortcodes'),
94
-            5,
95
-            2
96
-        );
97
-        add_filter(
98
-            'FHEE__EE_Primary_Registration_List_Shortcodes__parser_after',
99
-            array($this, 'additional_primary_registration_details_parser'),
100
-            5,
101
-            5
102
-        );
103
-
104
-        /**
105
-         * @since 4.2.0
106
-         */
107
-        add_filter('FHEE__EE_Datetime_Shortcodes__shortcodes', array($this, 'additional_datetime_shortcodes'), 10, 2);
108
-        add_filter('FHEE__EE_Datetime_Shortcodes__parser_after', array($this, 'additional_datetime_parser'), 10, 5);
109
-
110
-        /**
111
-         * @since 4.3.0
112
-         */
113
-        // eat our own dog food!
114
-        add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_message_types'));
115
-        add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_shortcodes'));
116
-        do_action('EE_Brewing_Regular___messages_caf');
117
-    }
118
-
119
-
120
-    /**
121
-     * This just allows us to add additional paths to the autoloader (EED_Messages::autoload_messages()) for the
122
-     * messages system.
123
-     *
124
-     * @param  array $dir_ref original array of paths
125
-     *
126
-     * @return array           appended paths
127
-     */
128
-    public function messages_autoload_paths($dir_ref)
129
-    {
130
-        $dir_ref[] = EE_CAF_LIBRARIES . 'shortcodes/';
131
-
132
-        return $dir_ref;
133
-    }
134
-
135
-
136
-    public function email_messenger_validator_config($validator_config, EE_Email_messenger $messenger)
137
-    {
138
-        $validator_config['attendee_list'] = array(
139
-            'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'),
140
-            'required'   => array('[ATTENDEE_LIST]'),
141
-        );
142
-        $validator_config['question_list'] = array(
143
-            'shortcodes' => array('question'),
144
-            'required'   => array('[QUESTION_LIST]'),
145
-        );
146
-
147
-        return $validator_config;
148
-    }
149
-
150
-
151
-    public function html_messenger_validator_config($validator_config, EE_Html_messenger $messenger)
152
-    {
153
-        $validator_config['attendee_list'] = array(
154
-            'shortcodes' => array('attendee', 'question_list'),
155
-            'required'   => array('[ATTENDEE_LIST]'),
156
-        );
157
-        $validator_config['question_list'] = array(
158
-            'shortcodes' => array('question'),
159
-            'required'   => array('[QUESTION_LIST]'),
160
-        );
161
-
162
-        return $validator_config;
163
-    }
164
-
165
-
166
-    public function pdf_messenger_validator_config($validator_config, EE_Pdf_messenger $messenger)
167
-    {
168
-        $validator_config['attendee_list'] = array(
169
-            'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'),
170
-            'required'   => array('[ATTENDEE_LIST]'),
171
-        );
172
-        $validator_config['question_list'] = array(
173
-            'shortcodes' => array('question'),
174
-            'required'   => array('[QUESTION_LIST]'),
175
-        );
176
-
177
-        return $validator_config;
178
-    }
179
-
180
-
181
-    public function email_messenger_template_fields($template_fields, EE_Email_messenger $messenger)
182
-    {
183
-        $template_fields['extra']['content']['question_list'] = array(
184
-            'input'               => 'textarea',
185
-            'label'               => '[QUESTION_LIST]',
186
-            'type'                => 'string',
187
-            'required'            => false,
188
-            'validation'          => true,
189
-            'format'              => '%s',
190
-            'css_class'           => 'large-text',
191
-            'rows'                => '5',
192
-            'shortcodes_required' => array('[QUESTION_LIST]'),
193
-        );
194
-
195
-        return $template_fields;
196
-    }
197
-
198
-
199
-    public function html_messenger_template_fields($template_fields, EE_Html_messenger $messenger)
200
-    {
201
-        $template_fields['extra']['content']['question_list'] = array(
202
-            'input'               => 'textarea',
203
-            'label'               => '[QUESTION_LIST]',
204
-            'type'                => 'string',
205
-            'required'            => false,
206
-            'validation'          => true,
207
-            'format'              => '%s',
208
-            'css_class'           => 'large-text',
209
-            'rows'                => '5',
210
-            'shortcodes_required' => array('[QUESTION_LIST]'),
211
-        );
212
-
213
-        return $template_fields;
214
-    }
215
-
216
-
217
-    public function pdf_messenger_template_fields($template_fields, EE_Pdf_messenger $messenger)
218
-    {
219
-        $template_fields['extra']['content']['question_list'] = array(
220
-            'input'               => 'textarea',
221
-            'label'               => '[QUESTION_LIST]',
222
-            'type'                => 'string',
223
-            'required'            => false,
224
-            'validation'          => true,
225
-            'format'              => '%s',
226
-            'css_class'           => 'large-text',
227
-            'rows'                => '5',
228
-            'shortcodes_required' => array('[QUESTION_LIST]'),
229
-        );
230
-
231
-        return $template_fields;
232
-    }
233
-
234
-
235
-    public function new_default_templates(
236
-        $contents,
237
-        $actual_path,
238
-        EE_messenger $messenger,
239
-        EE_message_type $message_type,
240
-        $field,
241
-        $context,
242
-        EE_Messages_Template_Pack $template_pack
243
-    ) {
244
-
245
-        // we're only modifying templates for the default template pack
246
-        if (! $template_pack instanceof EE_Messages_Template_Pack_Default) {
247
-            return $contents;
248
-        }
249
-
250
-        // the template file name we're replacing contents for.
251
-        $template_file_prefix = $field . '_' . $context;
252
-        $msg_prefix = $messenger->name . '_' . $message_type->name . '_';
253
-
254
-        $base_path = EE_CAF_LIBRARIES . 'messages/defaults/default/';
255
-
256
-        if ($messenger->name == 'email' && $message_type->name == 'registration') {
257
-            switch ($template_file_prefix) {
258
-                case 'question_list_admin':
259
-                case 'question_list_attendee':
260
-                case 'question_list_primary_attendee':
261
-                    $path = $base_path . $msg_prefix . 'question_list.template.php';
262
-                    $contents = EEH_Template::display_template($path, array(), true);
263
-                    break;
264
-
265
-                case 'attendee_list_primary_attendee':
266
-                    $path = $base_path . $msg_prefix . 'attendee_list.template.php';
267
-                    $contents = EEH_Template::display_template($path, array(), true);
268
-                    break;
269
-
270
-                case 'attendee_list_admin':
271
-                    $path = $base_path . $msg_prefix . 'attendee_list_admin.template.php';
272
-                    $contents = EEH_Template::display_template(
273
-                        $path,
274
-                        array(),
275
-                        true
276
-                    );
277
-                    break;
278
-
279
-                case 'attendee_list_attendee':
280
-                    $contents = '';
281
-                    break;
282
-
283
-                case 'event_list_attendee':
284
-                    $path = $base_path . $msg_prefix . 'event_list_attendee.template.php';
285
-                    $contents = EEH_Template::display_template($path, array(), true);
286
-                    break;
287
-            }
288
-        } elseif ($messenger->name == 'email' && $message_type->name == 'newsletter') {
289
-            switch ($template_file_prefix) {
290
-                case 'content_attendee':
291
-                    $path = $base_path . $msg_prefix . 'content.template.php';
292
-                    $contents = EEH_Template::display_template($path, array(), true);
293
-                    break;
294
-
295
-                case 'newsletter_content_attendee':
296
-                    $path = $base_path . $msg_prefix . 'newsletter_content.template.php';
297
-                    $contents = EEH_Template::display_template($path, array(), true);
298
-                    break;
299
-
300
-                case 'newsletter_subject_attendee':
301
-                    $path = $base_path . $msg_prefix . 'subject.template.php';
302
-                    $contents = EEH_Template::display_template($path, array(), true);
303
-                    break;
304
-            }
305
-        } elseif ($messenger->name == 'html' && $message_type->name == 'receipt') {
306
-            switch ($template_file_prefix) {
307
-                case 'attendee_list_purchaser':
308
-                    $path = $base_path . $msg_prefix . 'attendee_list.template.php';
309
-                    $contents = EEH_Template::display_template($path, array(), true);
310
-                    break;
311
-            }
312
-        }
313
-
314
-        return $contents;
315
-    }
316
-
317
-
318
-    public function message_types_valid_shortcodes($valid_shortcodes, EE_Messages_Base $msg)
319
-    {
320
-        // make sure question_list and question are ONLY added for the core message types.  Any other message types will have to explicitly set question_list as a valid shortcode.
321
-        $include_with = array(
322
-            'registration',
323
-            'cancelled_registration',
324
-            'declined_registration',
325
-            'not_approved_registration',
326
-            'payment_declined',
327
-            'payment_failed',
328
-            'payment_cancelled',
329
-            'payment',
330
-            'payment_reminder',
331
-            'pending_approval',
332
-            'registration_summary',
333
-            'invoice',
334
-            'receipt',
335
-        );
336
-        if ($msg instanceof EE_message_type && in_array($msg->name, $include_with)) {
337
-            $contexts = array_keys($msg->get_contexts());
338
-            foreach ($contexts as $context) {
339
-                $valid_shortcodes[ $context ][] = 'question_list';
340
-                $valid_shortcodes[ $context ][] = 'question';
341
-            }
342
-        }
343
-
344
-        return $valid_shortcodes;
345
-    }
346
-
347
-
348
-    public function additional_attendee_shortcodes($shortcodes, $shortcode_parser)
349
-    {
350
-        $shortcodes['[ANSWER_*]'] = esc_html__(
351
-            'This is a special dynamic shortcode. Right after the "*", add the exact text of a existing question, and if there is an answer for that question for this registrant, that will take the place of this shortcode.',
352
-            'event_espresso'
353
-        );
354
-
355
-        return $shortcodes;
356
-    }
357
-
358
-
359
-    public function additional_attendee_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
360
-    {
361
-
362
-        if (
363
-            strpos($shortcode, '[ANSWER_*') === false
364
-            || ! isset($extra_data['data']->questions)
365
-            || ! isset($extra_data['data']->registrations)
366
-        ) {
367
-            return $parsed;
368
-        }
369
-
370
-        // let's get the question from the code.
371
-        $shortcode = str_replace('[ANSWER_*', '', $shortcode);
372
-        $shortcode = trim(str_replace(']', '', $shortcode));
373
-
374
-        $registration = $data instanceof EE_Registration ? $data : null;
375
-        $registration = ! $registration instanceof EE_Registration && is_array(
376
-            $extra_data
377
-        ) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Registration ? $extra_data['data'] : $registration;
378
-
379
-        $aee = $data instanceof EE_Messages_Addressee ? $data : null;
380
-        $aee = ! $aee instanceof EE_Messages_Addressee && is_array(
381
-            $extra_data
382
-        ) && isset($extra_data['data']) ? $extra_data['data'] : $aee;
383
-
384
-        if (! $registration instanceof EE_Registration || ! $aee instanceof EE_Messages_Addressee) {
385
-            return $parsed;
386
-        }
387
-
388
-        // now let's figure out which question has this text.
389
-        foreach ($aee->questions as $ansid => $question) {
390
-            if (
391
-                $question instanceof EE_Question
392
-                && trim($question->display_text()) == trim($shortcode)
393
-                && isset($aee->registrations[ $registration->ID() ]['ans_objs'][ $ansid ])
394
-            ) {
395
-                return $aee->registrations[ $registration->ID() ]['ans_objs'][ $ansid ]->get_pretty(
396
-                    'ANS_value',
397
-                    'no_wpautop'
398
-                );
399
-            }
400
-        }
401
-
402
-        // nothing!
403
-        return $parsed;
404
-    }
405
-
406
-
407
-    /**
408
-     * Callback for additional shortcodes filter for adding additional datetime shortcodes.
409
-     *
410
-     * @since  4.2
411
-     *
412
-     * @param  array                  $shortcodes         array of shortcodes and
413
-     *                                                    descriptions
414
-     * @param  EE_Datetime_Shortcodes $shortcode_parser   EE_Shortcodes object
415
-     *
416
-     * @return array                                        array of shortcodes and
417
-     *                                                        descriptions
418
-     */
419
-    public function additional_datetime_shortcodes($shortcodes, $shortcode_parser)
420
-    {
421
-        $shortcodes['[DTT_NAME]'] = esc_html__(
422
-            'This will be parsed to the Title given for a Datetime',
423
-            'event_espresso'
424
-        );
425
-        $shortcodes['[DTT_DESCRIPTION]'] = esc_html__(
426
-            'This will be parsed to the description for a Datetime',
427
-            'event_espresso'
428
-        );
429
-        $shortcodes['[DTT_NAME_OR_DATES]'] = esc_html__(
430
-            'When parsed, if the Datetime has a name, it is used, otherwise a formatted string including the start date and end date will be used.',
431
-            'event_espresso'
432
-        );
433
-
434
-        return $shortcodes;
435
-    }
436
-
437
-
438
-    /**
439
-     * Callback for additional shortcodes parser filter used for adding parser for new
440
-     * Datetime shortcodes
441
-     *
442
-     * @since  4.2
443
-     *
444
-     * @param  string                 $parsed     The finished parsed string for the given shortcode.
445
-     * @param  string                 $shortcode  The shortcode being parsed.
446
-     * @param  object                 $data       The incoming data object for the Shortcode Parser.
447
-     * @param  object                 $extra_data The incoming extra date object for the Shortcode
448
-     *                                            Parser.
449
-     * @param  EE_Datetime_Shortcodes $shortcode_parser
450
-     *
451
-     * @return string                   The new parsed string.
452
-     */
453
-    public function additional_datetime_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
454
-    {
455
-
456
-        if (! $data instanceof EE_Datetime) {
457
-            return ''; // get out because we can only parse with the datetime object.
458
-        }
459
-
460
-        switch ($shortcode) {
461
-            case '[DTT_NAME]':
462
-                return $data->name();
463
-                break;
464
-            case '[DTT_DESCRIPTION]':
465
-                return $data->description();
466
-                break;
467
-            case '[DTT_NAME_OR_DATES]':
468
-                return $data->get_dtt_display_name(true);
469
-                break;
470
-            default:
471
-                return $parsed;
472
-                break;
473
-        }
474
-    }
475
-
476
-
477
-    public function additional_recipient_details_shortcodes($shortcodes, $shortcode_parser)
478
-    {
479
-        $shortcodes['[RECIPIENT_QUESTION_LIST]'] = esc_html__(
480
-            'This is used to indicate where you want the list of questions and answers to show for the person receiving the message.',
481
-            'event_espresso'
482
-        );
483
-
484
-        return $shortcodes;
485
-    }
486
-
487
-
488
-    /**
489
-     * Callback for FHEE__EE_Recipient_List_Shortcodes__parser_after filter (dynamic filter).
490
-     *
491
-     * @param string         $parsed           The original parsed content for the shortcode
492
-     * @param string         $shortcode        The shortcode being parsed
493
-     * @param array          $data             The shortcode parser data array
494
-     * @param array          $extra_data       The shortcode parser extra data array
495
-     * @param \EE_Shortcodes $shortcode_parser Shortcode parser.
496
-     *
497
-     * @return string
498
-     */
499
-    public function additional_recipient_details_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
500
-    {
501
-
502
-        if (array($data) && ! isset($data['data'])) {
503
-            return $parsed;
504
-        }
505
-
506
-        $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
507
-        $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient;
508
-
509
-        if (! $recipient instanceof EE_Messages_Addressee) {
510
-            return $parsed;
511
-        }
512
-
513
-        switch ($shortcode) {
514
-            case '[RECIPIENT_QUESTION_LIST]':
515
-                $att = $recipient->att_obj;
516
-                $registrations_on_attendee = $att instanceof EE_Attendee
517
-                    ? $recipient->attendees[ $att->ID() ]['reg_objs']
518
-                    : array();
519
-                $registrations_on_attendee = empty($registrations_on_attendee) && $recipient->reg_obj instanceof EE_Registration ? array($recipient->reg_obj) : $registrations_on_attendee;
520
-                $answers = array();
521
-
522
-                $template = is_array($data['template']) && isset($data['template']['question_list'])
523
-                    ? $data['template']['question_list']
524
-                    : $extra_data['template']['question_list'];
525
-                $valid_shortcodes = array('question');
526
-
527
-                // if the context is main_content then get all answers for all registrations on this attendee
528
-                if ($data['data'] instanceof EE_Messages_Addressee) {
529
-                    foreach ($registrations_on_attendee as $reg) {
530
-                        if ($reg instanceof EE_Registration) {
531
-                            $anss = ! empty($recipient->registrations[ $reg->ID() ]['ans_objs'])
532
-                                ? $recipient->registrations[ $reg->ID() ]['ans_objs']
533
-                                : array();
534
-                            foreach ($anss as $ans) {
535
-                                if ($ans instanceof EE_Answer) {
536
-                                    $answers[ $ans->ID() ] = $ans;
537
-                                }
538
-                            }
539
-                        }
540
-                    }
541
-                }
542
-
543
-                // if the context is the event list parser, then let's return just the answers for all registrations attached to the recipient for that event.
544
-                if ($data['data'] instanceof EE_Event) {
545
-                    $event = $data['data'];
546
-                    foreach ($registrations_on_attendee as $reg) {
547
-                        if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) {
548
-                            $anss = ! empty($recipient->registrations[ $reg->ID() ]['ans_objs'])
549
-                                ? $recipient->registrations[ $reg->ID() ]['ans_objs']
550
-                                : array();
551
-                            foreach ($anss as $ans) {
552
-                                if ($ans instanceof EE_Answer) {
553
-                                    $answers[ $ans->ID() ] = $ans;
554
-                                }
555
-                            }
556
-                        }
557
-                    }
558
-                }
559
-
560
-                $questions = $questions = isset($recipient->questions) ? $recipient->questions : array();
561
-
562
-                // if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
563
-                // object on it.
564
-                if (! isset($extra_data['data'])) {
565
-                    $extra_data['data'] = $recipient;
566
-                }
567
-
568
-                return $this->_parse_question_list_for_primary_or_recipient_registration(
569
-                    $shortcode_parser,
570
-                    $questions,
571
-                    $answers,
572
-                    $template,
573
-                    $valid_shortcodes,
574
-                    $extra_data
575
-                );
576
-                break;
577
-
578
-            default:
579
-                return $parsed;
580
-                break;
581
-        }
582
-    }
583
-
584
-
585
-    public function additional_primary_registration_details_shortcodes($shortcodes, $shortcode_parser)
586
-    {
587
-        $shortcodes['[PRIMARY_REGISTRANT_QUESTION_LIST]'] = esc_html__(
588
-            'This is used to indicate the questions and answers for the primary_registrant. It should be placed in the "[attendee_list]" field',
589
-            'event_espresso'
590
-        );
591
-
592
-        return $shortcodes;
593
-    }
594
-
595
-
596
-    /**
597
-     * Callback for FHEE__EE_Primary_Registration_List_Shortcodes__parser_after filter (dynamic filter).
598
-     *
599
-     * @param string         $parsed           The original parsed content for the shortcode
600
-     * @param string         $shortcode        The shortcode being parsed
601
-     * @param array          $data             The shortcode parser data array
602
-     * @param array          $extra_data       The shortcode parser extra data array
603
-     * @param \EE_Shortcodes $shortcode_parser Shortcode parser.
604
-     *
605
-     * @return string
606
-     */
607
-    public function additional_primary_registration_details_parser(
608
-        $parsed,
609
-        $shortcode,
610
-        $data,
611
-        $extra_data,
612
-        $shortcode_parser
613
-    ) {
614
-        if (array($data) && ! isset($data['data'])) {
615
-            return $parsed;
616
-        }
617
-
618
-        $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
619
-        $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient;
620
-
621
-        if (! $recipient instanceof EE_Messages_Addressee) {
622
-            return $parsed;
623
-        }
624
-
625
-        switch ($shortcode) {
626
-            case '[PRIMARY_REGISTRANT_QUESTION_LIST]':
627
-                if (! $recipient->primary_att_obj instanceof EE_Attendee || ! $recipient->primary_reg_obj instanceof EE_Registration) {
628
-                    return '';
629
-                }
630
-                $registration = $recipient->primary_reg_obj;
631
-                $answers = isset($recipient->registrations[ $registration->ID() ]['ans_objs'])
632
-                    ? $recipient->registrations[ $registration->ID() ]['ans_objs']
633
-                    : array();
634
-                if (empty($answers)) {
635
-                    return '';
636
-                }
637
-                $template = is_array($data['template']) && isset($data['template']['question_list'])
638
-                    ? $data['template']['question_list']
639
-                    : $extra_data['template']['question_list'];
640
-                $valid_shortcodes = array('question');
641
-                $answers = $recipient->registrations[ $registration->ID() ]['ans_objs'];
642
-                $questions = isset($recipient->questions) ? $recipient->questions : array();
643
-                // if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
644
-                // object on it.
645
-                if (! isset($extra_data['data'])) {
646
-                    $extra_data['data'] = $recipient;
647
-                }
648
-                return $this->_parse_question_list_for_primary_or_recipient_registration(
649
-                    $shortcode_parser,
650
-                    $questions,
651
-                    $answers,
652
-                    $template,
653
-                    $valid_shortcodes,
654
-                    $extra_data
655
-                );
656
-                break;
657
-
658
-            default:
659
-                return $parsed;
660
-                break;
661
-        }
662
-    }
663
-
664
-
665
-    /**
666
-     * Takes care of registering the  message types that are only available in caffeinated EE.
667
-     *
668
-     * @since   4.3.2
669
-     *
670
-     * @return  void
671
-     */
672
-    public function register_caf_message_types()
673
-    {
674
-        // register newsletter message type
675
-        $setup_args = array(
676
-            'mtfilename'                                       => 'EE_Newsletter_message_type.class.php',
677
-            'autoloadpaths'                                    => array(
678
-                EE_CAF_LIBRARIES . 'messages/message_type/newsletter/',
679
-            ),
680
-            'messengers_to_activate_with'                      => array('email'),
681
-            'messengers_to_validate_with'                      => array('email'),
682
-            'messengers_supporting_default_template_pack_with' => array('email'),
683
-        );
684
-        EE_Register_Message_Type::register('newsletter', $setup_args);
685
-
686
-        // register payment reminder message type
687
-        $setup_args = array(
688
-            'mtfilename'                                       => 'EE_Payment_Reminder_message_type.class.php',
689
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'),
690
-            'messengers_to_activate_with'                      => array('email'),
691
-            'messengers_to_validate_with'                      => array('email'),
692
-            'messengers_supporting_default_template_pack_with' => array('email'),
693
-        );
694
-        EE_Register_Message_Type::register('payment_reminder', $setup_args);
695
-
696
-        // register payment declined message type
697
-        $setup_args = array(
698
-            'mtfilename'                                       => 'EE_Payment_Declined_message_type.class.php',
699
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'),
700
-            'messengers_to_activate_with'                      => array('email'),
701
-            'messengers_to_validate_with'                      => array('email'),
702
-            'messengers_supporting_default_template_pack_with' => array('email'),
703
-        );
704
-        EE_Register_Message_Type::register('payment_declined', $setup_args);
705
-
706
-        // register registration declined message type
707
-        $setup_args = array(
708
-            'mtfilename'                                       => 'EE_Declined_Registration_message_type.class.php',
709
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'),
710
-            'messengers_to_activate_with'                      => array('email'),
711
-            'messengers_to_validate_with'                      => array('email'),
712
-            'messengers_supporting_default_template_pack_with' => array('email'),
713
-        );
714
-        EE_Register_Message_Type::register('declined_registration', $setup_args);
715
-
716
-        // register registration cancelled message type
717
-        $setup_args = array(
718
-            'mtfilename'                                       => 'EE_Cancelled_Registration_message_type.class.php',
719
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'),
720
-            'messengers_to_activate_with'                      => array('email'),
721
-            'messengers_to_validate_with'                      => array('email'),
722
-            'messengers_supporting_default_template_pack_with' => array('email'),
723
-        );
724
-        EE_Register_Message_Type::register('cancelled_registration', $setup_args);
725
-
726
-
727
-        // register payment failed message type
728
-        $setup_args = array(
729
-            'mtfilename'                                       => 'EE_Payment_Failed_message_type.class.php',
730
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'),
731
-            'messengers_to_activate_with'                      => array('email'),
732
-            'messengers_to_validate_with'                      => array('email'),
733
-            'messengers_supporting_default_template_pack_with' => array('email'),
734
-        );
735
-        EE_Register_Message_Type::register('payment_failed', $setup_args);
736
-
737
-        // register payment declined message type
738
-        $setup_args = array(
739
-            'mtfilename'                                       => 'EE_Payment_Cancelled_message_type.class.php',
740
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'),
741
-            'messengers_to_activate_with'                      => array('email'),
742
-            'messengers_to_validate_with'                      => array('email'),
743
-            'messengers_supporting_default_template_pack_with' => array('email'),
744
-        );
745
-        EE_Register_Message_Type::register('payment_cancelled', $setup_args);
746
-    }
747
-
748
-
749
-    /**
750
-     * Takes care of registering the  shortcode libraries implemented with caffeinated EE and set up related items.
751
-     *
752
-     * @since   4.3.2
753
-     *
754
-     * @return void
755
-     */
756
-    public function register_caf_shortcodes()
757
-    {
758
-        $setup_args = array(
759
-            'autoloadpaths'                 => array(
760
-                EE_CAF_LIBRARIES . 'shortcodes/',
761
-            ),
762
-            'msgr_validator_callback'       => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'),
763
-            'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'),
764
-            'list_type_shortcodes'          => array('[NEWSLETTER_CONTENT]'),
765
-        );
766
-        EE_Register_Messages_Shortcode_Library::register('newsletter', $setup_args);
767
-    }
768
-
769
-
770
-    /**
771
-     * Parses a question list shortcode using given data and template
772
-     *
773
-     * @param \EE_Shortcodes $shortcode_parser
774
-     * @param EE_Question[]  $questions        An array of questions indexed by answer id.
775
-     * @param EE_Answer[]    $answers          An array of answer objects
776
-     * @param string         $template         Template content to be parsed.
777
-     * @param array          $valid_shortcodes Valid shortcodes for the template being parsed.
778
-     * @param array          $extra_data       Extra data that might be used when parsing the template.
779
-     */
780
-    protected function _parse_question_list_for_primary_or_recipient_registration(
781
-        $shortcode_parser,
782
-        $questions,
783
-        $answers,
784
-        $template,
785
-        $valid_shortcodes,
786
-        $extra_data
787
-    ) {
788
-        $question_list = '';
789
-        /** @var EEH_Parse_Shortcodes $shortcode_helper */
790
-        $shortcode_helper = $shortcode_parser->get_shortcode_helper();
791
-        foreach ($answers as $answer) {
792
-            if ($answer instanceof EE_Answer) {
793
-                // first see if the question is in our $questions array. If not then try to get from answer object.
794
-                $question = isset($questions[ $answer->ID() ]) ? $questions[ $answer->ID() ] : null;
795
-                $question = ! $question instanceof EE_Question ? $answer->question() : $question;
796
-                if (
797
-                    ! $question instanceof EE_Question
798
-                    || (
799
-                        $question instanceof EE_Question
800
-                        && $question->admin_only()
801
-                    )
802
-                ) {
803
-                    continue;
804
-                }
805
-                $question_list .= $shortcode_helper->parse_question_list_template(
806
-                    $template,
807
-                    $answer,
808
-                    $valid_shortcodes,
809
-                    $extra_data
810
-                );
811
-            }
812
-        }
813
-        return $question_list;
814
-    }
13
+	/**
14
+	 * constructor.
15
+	 */
16
+	public function __construct()
17
+	{
18
+		$this->_caf_hooks();
19
+	}
20
+
21
+
22
+	/**
23
+	 * Contains all the hooks filters for setting up caffeinated messages functionality.
24
+	 *
25
+	 * @since 4.3.2
26
+	 *
27
+	 * @return void
28
+	 */
29
+	private function _caf_hooks()
30
+	{
31
+		add_filter('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array($this, 'messages_autoload_paths'), 5);
32
+		add_filter(
33
+			'FHEE__EE_Email_messenger__get_validator_config',
34
+			array($this, 'email_messenger_validator_config'),
35
+			5,
36
+			2
37
+		);
38
+		add_filter(
39
+			'FHEE__EE_Email_messenger__get_template_fields',
40
+			array($this, 'email_messenger_template_fields'),
41
+			5,
42
+			2
43
+		);
44
+		add_filter(
45
+			'FHEE__EE_Html_messenger__get_template_fields',
46
+			array($this, 'html_messenger_template_fields'),
47
+			5,
48
+			2
49
+		);
50
+		add_filter(
51
+			'FHEE__EE_Html_messenger__get_validator_config',
52
+			array($this, 'html_messenger_validator_config'),
53
+			5,
54
+			2
55
+		);
56
+		add_filter('FHEE__EE_Pdf_messenger__get_template_fields', array($this, 'pdf_messenger_template_fields'), 5, 2);
57
+		add_filter(
58
+			'FHEE__EE_Pdf_messenger__get_validator_config',
59
+			array($this, 'pdf_messenger_validator_config'),
60
+			5,
61
+			2
62
+		);
63
+		add_filter(
64
+			'FHEE__EE_Messages_Template_Pack__get_specific_template__contents',
65
+			array($this, 'new_default_templates'),
66
+			5,
67
+			7
68
+		);
69
+		add_filter(
70
+			'FHEE__EE_Messages_Base__get_valid_shortcodes',
71
+			array($this, 'message_types_valid_shortcodes'),
72
+			5,
73
+			2
74
+		);
75
+
76
+		// shortcode parsers
77
+		add_filter('FHEE__EE_Attendee_Shortcodes__shortcodes', array($this, 'additional_attendee_shortcodes'), 5, 2);
78
+		add_filter('FHEE__EE_Attendee_Shortcodes__parser_after', array($this, 'additional_attendee_parser'), 5, 5);
79
+		add_filter(
80
+			'FHEE__EE_Recipient_List_Shortcodes__shortcodes',
81
+			array($this, 'additional_recipient_details_shortcodes'),
82
+			5,
83
+			2
84
+		);
85
+		add_filter(
86
+			'FHEE__EE_Recipient_List_Shortcodes__parser_after',
87
+			array($this, 'additional_recipient_details_parser'),
88
+			5,
89
+			5
90
+		);
91
+		add_filter(
92
+			'FHEE__EE_Primary_Registration_List_Shortcodes__shortcodes',
93
+			array($this, 'additional_primary_registration_details_shortcodes'),
94
+			5,
95
+			2
96
+		);
97
+		add_filter(
98
+			'FHEE__EE_Primary_Registration_List_Shortcodes__parser_after',
99
+			array($this, 'additional_primary_registration_details_parser'),
100
+			5,
101
+			5
102
+		);
103
+
104
+		/**
105
+		 * @since 4.2.0
106
+		 */
107
+		add_filter('FHEE__EE_Datetime_Shortcodes__shortcodes', array($this, 'additional_datetime_shortcodes'), 10, 2);
108
+		add_filter('FHEE__EE_Datetime_Shortcodes__parser_after', array($this, 'additional_datetime_parser'), 10, 5);
109
+
110
+		/**
111
+		 * @since 4.3.0
112
+		 */
113
+		// eat our own dog food!
114
+		add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_message_types'));
115
+		add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_shortcodes'));
116
+		do_action('EE_Brewing_Regular___messages_caf');
117
+	}
118
+
119
+
120
+	/**
121
+	 * This just allows us to add additional paths to the autoloader (EED_Messages::autoload_messages()) for the
122
+	 * messages system.
123
+	 *
124
+	 * @param  array $dir_ref original array of paths
125
+	 *
126
+	 * @return array           appended paths
127
+	 */
128
+	public function messages_autoload_paths($dir_ref)
129
+	{
130
+		$dir_ref[] = EE_CAF_LIBRARIES . 'shortcodes/';
131
+
132
+		return $dir_ref;
133
+	}
134
+
135
+
136
+	public function email_messenger_validator_config($validator_config, EE_Email_messenger $messenger)
137
+	{
138
+		$validator_config['attendee_list'] = array(
139
+			'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'),
140
+			'required'   => array('[ATTENDEE_LIST]'),
141
+		);
142
+		$validator_config['question_list'] = array(
143
+			'shortcodes' => array('question'),
144
+			'required'   => array('[QUESTION_LIST]'),
145
+		);
146
+
147
+		return $validator_config;
148
+	}
149
+
150
+
151
+	public function html_messenger_validator_config($validator_config, EE_Html_messenger $messenger)
152
+	{
153
+		$validator_config['attendee_list'] = array(
154
+			'shortcodes' => array('attendee', 'question_list'),
155
+			'required'   => array('[ATTENDEE_LIST]'),
156
+		);
157
+		$validator_config['question_list'] = array(
158
+			'shortcodes' => array('question'),
159
+			'required'   => array('[QUESTION_LIST]'),
160
+		);
161
+
162
+		return $validator_config;
163
+	}
164
+
165
+
166
+	public function pdf_messenger_validator_config($validator_config, EE_Pdf_messenger $messenger)
167
+	{
168
+		$validator_config['attendee_list'] = array(
169
+			'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'),
170
+			'required'   => array('[ATTENDEE_LIST]'),
171
+		);
172
+		$validator_config['question_list'] = array(
173
+			'shortcodes' => array('question'),
174
+			'required'   => array('[QUESTION_LIST]'),
175
+		);
176
+
177
+		return $validator_config;
178
+	}
179
+
180
+
181
+	public function email_messenger_template_fields($template_fields, EE_Email_messenger $messenger)
182
+	{
183
+		$template_fields['extra']['content']['question_list'] = array(
184
+			'input'               => 'textarea',
185
+			'label'               => '[QUESTION_LIST]',
186
+			'type'                => 'string',
187
+			'required'            => false,
188
+			'validation'          => true,
189
+			'format'              => '%s',
190
+			'css_class'           => 'large-text',
191
+			'rows'                => '5',
192
+			'shortcodes_required' => array('[QUESTION_LIST]'),
193
+		);
194
+
195
+		return $template_fields;
196
+	}
197
+
198
+
199
+	public function html_messenger_template_fields($template_fields, EE_Html_messenger $messenger)
200
+	{
201
+		$template_fields['extra']['content']['question_list'] = array(
202
+			'input'               => 'textarea',
203
+			'label'               => '[QUESTION_LIST]',
204
+			'type'                => 'string',
205
+			'required'            => false,
206
+			'validation'          => true,
207
+			'format'              => '%s',
208
+			'css_class'           => 'large-text',
209
+			'rows'                => '5',
210
+			'shortcodes_required' => array('[QUESTION_LIST]'),
211
+		);
212
+
213
+		return $template_fields;
214
+	}
215
+
216
+
217
+	public function pdf_messenger_template_fields($template_fields, EE_Pdf_messenger $messenger)
218
+	{
219
+		$template_fields['extra']['content']['question_list'] = array(
220
+			'input'               => 'textarea',
221
+			'label'               => '[QUESTION_LIST]',
222
+			'type'                => 'string',
223
+			'required'            => false,
224
+			'validation'          => true,
225
+			'format'              => '%s',
226
+			'css_class'           => 'large-text',
227
+			'rows'                => '5',
228
+			'shortcodes_required' => array('[QUESTION_LIST]'),
229
+		);
230
+
231
+		return $template_fields;
232
+	}
233
+
234
+
235
+	public function new_default_templates(
236
+		$contents,
237
+		$actual_path,
238
+		EE_messenger $messenger,
239
+		EE_message_type $message_type,
240
+		$field,
241
+		$context,
242
+		EE_Messages_Template_Pack $template_pack
243
+	) {
244
+
245
+		// we're only modifying templates for the default template pack
246
+		if (! $template_pack instanceof EE_Messages_Template_Pack_Default) {
247
+			return $contents;
248
+		}
249
+
250
+		// the template file name we're replacing contents for.
251
+		$template_file_prefix = $field . '_' . $context;
252
+		$msg_prefix = $messenger->name . '_' . $message_type->name . '_';
253
+
254
+		$base_path = EE_CAF_LIBRARIES . 'messages/defaults/default/';
255
+
256
+		if ($messenger->name == 'email' && $message_type->name == 'registration') {
257
+			switch ($template_file_prefix) {
258
+				case 'question_list_admin':
259
+				case 'question_list_attendee':
260
+				case 'question_list_primary_attendee':
261
+					$path = $base_path . $msg_prefix . 'question_list.template.php';
262
+					$contents = EEH_Template::display_template($path, array(), true);
263
+					break;
264
+
265
+				case 'attendee_list_primary_attendee':
266
+					$path = $base_path . $msg_prefix . 'attendee_list.template.php';
267
+					$contents = EEH_Template::display_template($path, array(), true);
268
+					break;
269
+
270
+				case 'attendee_list_admin':
271
+					$path = $base_path . $msg_prefix . 'attendee_list_admin.template.php';
272
+					$contents = EEH_Template::display_template(
273
+						$path,
274
+						array(),
275
+						true
276
+					);
277
+					break;
278
+
279
+				case 'attendee_list_attendee':
280
+					$contents = '';
281
+					break;
282
+
283
+				case 'event_list_attendee':
284
+					$path = $base_path . $msg_prefix . 'event_list_attendee.template.php';
285
+					$contents = EEH_Template::display_template($path, array(), true);
286
+					break;
287
+			}
288
+		} elseif ($messenger->name == 'email' && $message_type->name == 'newsletter') {
289
+			switch ($template_file_prefix) {
290
+				case 'content_attendee':
291
+					$path = $base_path . $msg_prefix . 'content.template.php';
292
+					$contents = EEH_Template::display_template($path, array(), true);
293
+					break;
294
+
295
+				case 'newsletter_content_attendee':
296
+					$path = $base_path . $msg_prefix . 'newsletter_content.template.php';
297
+					$contents = EEH_Template::display_template($path, array(), true);
298
+					break;
299
+
300
+				case 'newsletter_subject_attendee':
301
+					$path = $base_path . $msg_prefix . 'subject.template.php';
302
+					$contents = EEH_Template::display_template($path, array(), true);
303
+					break;
304
+			}
305
+		} elseif ($messenger->name == 'html' && $message_type->name == 'receipt') {
306
+			switch ($template_file_prefix) {
307
+				case 'attendee_list_purchaser':
308
+					$path = $base_path . $msg_prefix . 'attendee_list.template.php';
309
+					$contents = EEH_Template::display_template($path, array(), true);
310
+					break;
311
+			}
312
+		}
313
+
314
+		return $contents;
315
+	}
316
+
317
+
318
+	public function message_types_valid_shortcodes($valid_shortcodes, EE_Messages_Base $msg)
319
+	{
320
+		// make sure question_list and question are ONLY added for the core message types.  Any other message types will have to explicitly set question_list as a valid shortcode.
321
+		$include_with = array(
322
+			'registration',
323
+			'cancelled_registration',
324
+			'declined_registration',
325
+			'not_approved_registration',
326
+			'payment_declined',
327
+			'payment_failed',
328
+			'payment_cancelled',
329
+			'payment',
330
+			'payment_reminder',
331
+			'pending_approval',
332
+			'registration_summary',
333
+			'invoice',
334
+			'receipt',
335
+		);
336
+		if ($msg instanceof EE_message_type && in_array($msg->name, $include_with)) {
337
+			$contexts = array_keys($msg->get_contexts());
338
+			foreach ($contexts as $context) {
339
+				$valid_shortcodes[ $context ][] = 'question_list';
340
+				$valid_shortcodes[ $context ][] = 'question';
341
+			}
342
+		}
343
+
344
+		return $valid_shortcodes;
345
+	}
346
+
347
+
348
+	public function additional_attendee_shortcodes($shortcodes, $shortcode_parser)
349
+	{
350
+		$shortcodes['[ANSWER_*]'] = esc_html__(
351
+			'This is a special dynamic shortcode. Right after the "*", add the exact text of a existing question, and if there is an answer for that question for this registrant, that will take the place of this shortcode.',
352
+			'event_espresso'
353
+		);
354
+
355
+		return $shortcodes;
356
+	}
357
+
358
+
359
+	public function additional_attendee_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
360
+	{
361
+
362
+		if (
363
+			strpos($shortcode, '[ANSWER_*') === false
364
+			|| ! isset($extra_data['data']->questions)
365
+			|| ! isset($extra_data['data']->registrations)
366
+		) {
367
+			return $parsed;
368
+		}
369
+
370
+		// let's get the question from the code.
371
+		$shortcode = str_replace('[ANSWER_*', '', $shortcode);
372
+		$shortcode = trim(str_replace(']', '', $shortcode));
373
+
374
+		$registration = $data instanceof EE_Registration ? $data : null;
375
+		$registration = ! $registration instanceof EE_Registration && is_array(
376
+			$extra_data
377
+		) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Registration ? $extra_data['data'] : $registration;
378
+
379
+		$aee = $data instanceof EE_Messages_Addressee ? $data : null;
380
+		$aee = ! $aee instanceof EE_Messages_Addressee && is_array(
381
+			$extra_data
382
+		) && isset($extra_data['data']) ? $extra_data['data'] : $aee;
383
+
384
+		if (! $registration instanceof EE_Registration || ! $aee instanceof EE_Messages_Addressee) {
385
+			return $parsed;
386
+		}
387
+
388
+		// now let's figure out which question has this text.
389
+		foreach ($aee->questions as $ansid => $question) {
390
+			if (
391
+				$question instanceof EE_Question
392
+				&& trim($question->display_text()) == trim($shortcode)
393
+				&& isset($aee->registrations[ $registration->ID() ]['ans_objs'][ $ansid ])
394
+			) {
395
+				return $aee->registrations[ $registration->ID() ]['ans_objs'][ $ansid ]->get_pretty(
396
+					'ANS_value',
397
+					'no_wpautop'
398
+				);
399
+			}
400
+		}
401
+
402
+		// nothing!
403
+		return $parsed;
404
+	}
405
+
406
+
407
+	/**
408
+	 * Callback for additional shortcodes filter for adding additional datetime shortcodes.
409
+	 *
410
+	 * @since  4.2
411
+	 *
412
+	 * @param  array                  $shortcodes         array of shortcodes and
413
+	 *                                                    descriptions
414
+	 * @param  EE_Datetime_Shortcodes $shortcode_parser   EE_Shortcodes object
415
+	 *
416
+	 * @return array                                        array of shortcodes and
417
+	 *                                                        descriptions
418
+	 */
419
+	public function additional_datetime_shortcodes($shortcodes, $shortcode_parser)
420
+	{
421
+		$shortcodes['[DTT_NAME]'] = esc_html__(
422
+			'This will be parsed to the Title given for a Datetime',
423
+			'event_espresso'
424
+		);
425
+		$shortcodes['[DTT_DESCRIPTION]'] = esc_html__(
426
+			'This will be parsed to the description for a Datetime',
427
+			'event_espresso'
428
+		);
429
+		$shortcodes['[DTT_NAME_OR_DATES]'] = esc_html__(
430
+			'When parsed, if the Datetime has a name, it is used, otherwise a formatted string including the start date and end date will be used.',
431
+			'event_espresso'
432
+		);
433
+
434
+		return $shortcodes;
435
+	}
436
+
437
+
438
+	/**
439
+	 * Callback for additional shortcodes parser filter used for adding parser for new
440
+	 * Datetime shortcodes
441
+	 *
442
+	 * @since  4.2
443
+	 *
444
+	 * @param  string                 $parsed     The finished parsed string for the given shortcode.
445
+	 * @param  string                 $shortcode  The shortcode being parsed.
446
+	 * @param  object                 $data       The incoming data object for the Shortcode Parser.
447
+	 * @param  object                 $extra_data The incoming extra date object for the Shortcode
448
+	 *                                            Parser.
449
+	 * @param  EE_Datetime_Shortcodes $shortcode_parser
450
+	 *
451
+	 * @return string                   The new parsed string.
452
+	 */
453
+	public function additional_datetime_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
454
+	{
455
+
456
+		if (! $data instanceof EE_Datetime) {
457
+			return ''; // get out because we can only parse with the datetime object.
458
+		}
459
+
460
+		switch ($shortcode) {
461
+			case '[DTT_NAME]':
462
+				return $data->name();
463
+				break;
464
+			case '[DTT_DESCRIPTION]':
465
+				return $data->description();
466
+				break;
467
+			case '[DTT_NAME_OR_DATES]':
468
+				return $data->get_dtt_display_name(true);
469
+				break;
470
+			default:
471
+				return $parsed;
472
+				break;
473
+		}
474
+	}
475
+
476
+
477
+	public function additional_recipient_details_shortcodes($shortcodes, $shortcode_parser)
478
+	{
479
+		$shortcodes['[RECIPIENT_QUESTION_LIST]'] = esc_html__(
480
+			'This is used to indicate where you want the list of questions and answers to show for the person receiving the message.',
481
+			'event_espresso'
482
+		);
483
+
484
+		return $shortcodes;
485
+	}
486
+
487
+
488
+	/**
489
+	 * Callback for FHEE__EE_Recipient_List_Shortcodes__parser_after filter (dynamic filter).
490
+	 *
491
+	 * @param string         $parsed           The original parsed content for the shortcode
492
+	 * @param string         $shortcode        The shortcode being parsed
493
+	 * @param array          $data             The shortcode parser data array
494
+	 * @param array          $extra_data       The shortcode parser extra data array
495
+	 * @param \EE_Shortcodes $shortcode_parser Shortcode parser.
496
+	 *
497
+	 * @return string
498
+	 */
499
+	public function additional_recipient_details_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
500
+	{
501
+
502
+		if (array($data) && ! isset($data['data'])) {
503
+			return $parsed;
504
+		}
505
+
506
+		$recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
507
+		$recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient;
508
+
509
+		if (! $recipient instanceof EE_Messages_Addressee) {
510
+			return $parsed;
511
+		}
512
+
513
+		switch ($shortcode) {
514
+			case '[RECIPIENT_QUESTION_LIST]':
515
+				$att = $recipient->att_obj;
516
+				$registrations_on_attendee = $att instanceof EE_Attendee
517
+					? $recipient->attendees[ $att->ID() ]['reg_objs']
518
+					: array();
519
+				$registrations_on_attendee = empty($registrations_on_attendee) && $recipient->reg_obj instanceof EE_Registration ? array($recipient->reg_obj) : $registrations_on_attendee;
520
+				$answers = array();
521
+
522
+				$template = is_array($data['template']) && isset($data['template']['question_list'])
523
+					? $data['template']['question_list']
524
+					: $extra_data['template']['question_list'];
525
+				$valid_shortcodes = array('question');
526
+
527
+				// if the context is main_content then get all answers for all registrations on this attendee
528
+				if ($data['data'] instanceof EE_Messages_Addressee) {
529
+					foreach ($registrations_on_attendee as $reg) {
530
+						if ($reg instanceof EE_Registration) {
531
+							$anss = ! empty($recipient->registrations[ $reg->ID() ]['ans_objs'])
532
+								? $recipient->registrations[ $reg->ID() ]['ans_objs']
533
+								: array();
534
+							foreach ($anss as $ans) {
535
+								if ($ans instanceof EE_Answer) {
536
+									$answers[ $ans->ID() ] = $ans;
537
+								}
538
+							}
539
+						}
540
+					}
541
+				}
542
+
543
+				// if the context is the event list parser, then let's return just the answers for all registrations attached to the recipient for that event.
544
+				if ($data['data'] instanceof EE_Event) {
545
+					$event = $data['data'];
546
+					foreach ($registrations_on_attendee as $reg) {
547
+						if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) {
548
+							$anss = ! empty($recipient->registrations[ $reg->ID() ]['ans_objs'])
549
+								? $recipient->registrations[ $reg->ID() ]['ans_objs']
550
+								: array();
551
+							foreach ($anss as $ans) {
552
+								if ($ans instanceof EE_Answer) {
553
+									$answers[ $ans->ID() ] = $ans;
554
+								}
555
+							}
556
+						}
557
+					}
558
+				}
559
+
560
+				$questions = $questions = isset($recipient->questions) ? $recipient->questions : array();
561
+
562
+				// if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
563
+				// object on it.
564
+				if (! isset($extra_data['data'])) {
565
+					$extra_data['data'] = $recipient;
566
+				}
567
+
568
+				return $this->_parse_question_list_for_primary_or_recipient_registration(
569
+					$shortcode_parser,
570
+					$questions,
571
+					$answers,
572
+					$template,
573
+					$valid_shortcodes,
574
+					$extra_data
575
+				);
576
+				break;
577
+
578
+			default:
579
+				return $parsed;
580
+				break;
581
+		}
582
+	}
583
+
584
+
585
+	public function additional_primary_registration_details_shortcodes($shortcodes, $shortcode_parser)
586
+	{
587
+		$shortcodes['[PRIMARY_REGISTRANT_QUESTION_LIST]'] = esc_html__(
588
+			'This is used to indicate the questions and answers for the primary_registrant. It should be placed in the "[attendee_list]" field',
589
+			'event_espresso'
590
+		);
591
+
592
+		return $shortcodes;
593
+	}
594
+
595
+
596
+	/**
597
+	 * Callback for FHEE__EE_Primary_Registration_List_Shortcodes__parser_after filter (dynamic filter).
598
+	 *
599
+	 * @param string         $parsed           The original parsed content for the shortcode
600
+	 * @param string         $shortcode        The shortcode being parsed
601
+	 * @param array          $data             The shortcode parser data array
602
+	 * @param array          $extra_data       The shortcode parser extra data array
603
+	 * @param \EE_Shortcodes $shortcode_parser Shortcode parser.
604
+	 *
605
+	 * @return string
606
+	 */
607
+	public function additional_primary_registration_details_parser(
608
+		$parsed,
609
+		$shortcode,
610
+		$data,
611
+		$extra_data,
612
+		$shortcode_parser
613
+	) {
614
+		if (array($data) && ! isset($data['data'])) {
615
+			return $parsed;
616
+		}
617
+
618
+		$recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
619
+		$recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient;
620
+
621
+		if (! $recipient instanceof EE_Messages_Addressee) {
622
+			return $parsed;
623
+		}
624
+
625
+		switch ($shortcode) {
626
+			case '[PRIMARY_REGISTRANT_QUESTION_LIST]':
627
+				if (! $recipient->primary_att_obj instanceof EE_Attendee || ! $recipient->primary_reg_obj instanceof EE_Registration) {
628
+					return '';
629
+				}
630
+				$registration = $recipient->primary_reg_obj;
631
+				$answers = isset($recipient->registrations[ $registration->ID() ]['ans_objs'])
632
+					? $recipient->registrations[ $registration->ID() ]['ans_objs']
633
+					: array();
634
+				if (empty($answers)) {
635
+					return '';
636
+				}
637
+				$template = is_array($data['template']) && isset($data['template']['question_list'])
638
+					? $data['template']['question_list']
639
+					: $extra_data['template']['question_list'];
640
+				$valid_shortcodes = array('question');
641
+				$answers = $recipient->registrations[ $registration->ID() ]['ans_objs'];
642
+				$questions = isset($recipient->questions) ? $recipient->questions : array();
643
+				// if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
644
+				// object on it.
645
+				if (! isset($extra_data['data'])) {
646
+					$extra_data['data'] = $recipient;
647
+				}
648
+				return $this->_parse_question_list_for_primary_or_recipient_registration(
649
+					$shortcode_parser,
650
+					$questions,
651
+					$answers,
652
+					$template,
653
+					$valid_shortcodes,
654
+					$extra_data
655
+				);
656
+				break;
657
+
658
+			default:
659
+				return $parsed;
660
+				break;
661
+		}
662
+	}
663
+
664
+
665
+	/**
666
+	 * Takes care of registering the  message types that are only available in caffeinated EE.
667
+	 *
668
+	 * @since   4.3.2
669
+	 *
670
+	 * @return  void
671
+	 */
672
+	public function register_caf_message_types()
673
+	{
674
+		// register newsletter message type
675
+		$setup_args = array(
676
+			'mtfilename'                                       => 'EE_Newsletter_message_type.class.php',
677
+			'autoloadpaths'                                    => array(
678
+				EE_CAF_LIBRARIES . 'messages/message_type/newsletter/',
679
+			),
680
+			'messengers_to_activate_with'                      => array('email'),
681
+			'messengers_to_validate_with'                      => array('email'),
682
+			'messengers_supporting_default_template_pack_with' => array('email'),
683
+		);
684
+		EE_Register_Message_Type::register('newsletter', $setup_args);
685
+
686
+		// register payment reminder message type
687
+		$setup_args = array(
688
+			'mtfilename'                                       => 'EE_Payment_Reminder_message_type.class.php',
689
+			'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'),
690
+			'messengers_to_activate_with'                      => array('email'),
691
+			'messengers_to_validate_with'                      => array('email'),
692
+			'messengers_supporting_default_template_pack_with' => array('email'),
693
+		);
694
+		EE_Register_Message_Type::register('payment_reminder', $setup_args);
695
+
696
+		// register payment declined message type
697
+		$setup_args = array(
698
+			'mtfilename'                                       => 'EE_Payment_Declined_message_type.class.php',
699
+			'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'),
700
+			'messengers_to_activate_with'                      => array('email'),
701
+			'messengers_to_validate_with'                      => array('email'),
702
+			'messengers_supporting_default_template_pack_with' => array('email'),
703
+		);
704
+		EE_Register_Message_Type::register('payment_declined', $setup_args);
705
+
706
+		// register registration declined message type
707
+		$setup_args = array(
708
+			'mtfilename'                                       => 'EE_Declined_Registration_message_type.class.php',
709
+			'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'),
710
+			'messengers_to_activate_with'                      => array('email'),
711
+			'messengers_to_validate_with'                      => array('email'),
712
+			'messengers_supporting_default_template_pack_with' => array('email'),
713
+		);
714
+		EE_Register_Message_Type::register('declined_registration', $setup_args);
715
+
716
+		// register registration cancelled message type
717
+		$setup_args = array(
718
+			'mtfilename'                                       => 'EE_Cancelled_Registration_message_type.class.php',
719
+			'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'),
720
+			'messengers_to_activate_with'                      => array('email'),
721
+			'messengers_to_validate_with'                      => array('email'),
722
+			'messengers_supporting_default_template_pack_with' => array('email'),
723
+		);
724
+		EE_Register_Message_Type::register('cancelled_registration', $setup_args);
725
+
726
+
727
+		// register payment failed message type
728
+		$setup_args = array(
729
+			'mtfilename'                                       => 'EE_Payment_Failed_message_type.class.php',
730
+			'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'),
731
+			'messengers_to_activate_with'                      => array('email'),
732
+			'messengers_to_validate_with'                      => array('email'),
733
+			'messengers_supporting_default_template_pack_with' => array('email'),
734
+		);
735
+		EE_Register_Message_Type::register('payment_failed', $setup_args);
736
+
737
+		// register payment declined message type
738
+		$setup_args = array(
739
+			'mtfilename'                                       => 'EE_Payment_Cancelled_message_type.class.php',
740
+			'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'),
741
+			'messengers_to_activate_with'                      => array('email'),
742
+			'messengers_to_validate_with'                      => array('email'),
743
+			'messengers_supporting_default_template_pack_with' => array('email'),
744
+		);
745
+		EE_Register_Message_Type::register('payment_cancelled', $setup_args);
746
+	}
747
+
748
+
749
+	/**
750
+	 * Takes care of registering the  shortcode libraries implemented with caffeinated EE and set up related items.
751
+	 *
752
+	 * @since   4.3.2
753
+	 *
754
+	 * @return void
755
+	 */
756
+	public function register_caf_shortcodes()
757
+	{
758
+		$setup_args = array(
759
+			'autoloadpaths'                 => array(
760
+				EE_CAF_LIBRARIES . 'shortcodes/',
761
+			),
762
+			'msgr_validator_callback'       => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'),
763
+			'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'),
764
+			'list_type_shortcodes'          => array('[NEWSLETTER_CONTENT]'),
765
+		);
766
+		EE_Register_Messages_Shortcode_Library::register('newsletter', $setup_args);
767
+	}
768
+
769
+
770
+	/**
771
+	 * Parses a question list shortcode using given data and template
772
+	 *
773
+	 * @param \EE_Shortcodes $shortcode_parser
774
+	 * @param EE_Question[]  $questions        An array of questions indexed by answer id.
775
+	 * @param EE_Answer[]    $answers          An array of answer objects
776
+	 * @param string         $template         Template content to be parsed.
777
+	 * @param array          $valid_shortcodes Valid shortcodes for the template being parsed.
778
+	 * @param array          $extra_data       Extra data that might be used when parsing the template.
779
+	 */
780
+	protected function _parse_question_list_for_primary_or_recipient_registration(
781
+		$shortcode_parser,
782
+		$questions,
783
+		$answers,
784
+		$template,
785
+		$valid_shortcodes,
786
+		$extra_data
787
+	) {
788
+		$question_list = '';
789
+		/** @var EEH_Parse_Shortcodes $shortcode_helper */
790
+		$shortcode_helper = $shortcode_parser->get_shortcode_helper();
791
+		foreach ($answers as $answer) {
792
+			if ($answer instanceof EE_Answer) {
793
+				// first see if the question is in our $questions array. If not then try to get from answer object.
794
+				$question = isset($questions[ $answer->ID() ]) ? $questions[ $answer->ID() ] : null;
795
+				$question = ! $question instanceof EE_Question ? $answer->question() : $question;
796
+				if (
797
+					! $question instanceof EE_Question
798
+					|| (
799
+						$question instanceof EE_Question
800
+						&& $question->admin_only()
801
+					)
802
+				) {
803
+					continue;
804
+				}
805
+				$question_list .= $shortcode_helper->parse_question_list_template(
806
+					$template,
807
+					$answer,
808
+					$valid_shortcodes,
809
+					$extra_data
810
+				);
811
+			}
812
+		}
813
+		return $question_list;
814
+	}
815 815
 }
Please login to merge, or discard this patch.
payment_methods/Paypal_Pro/templates/paypal_pro_intro.template.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 printf(
4
-    esc_html__(
5
-        'PayPal Pro (Website Payments Pro) is an on-site payment method for accepting credit and debit cards and is available to event organizers in the United States, United Kingdom, and Canada. An account with PayPal is required to accept payments. Need a PayPal Pro account? Call 1-855-456-1338 or %1$sclick here to sign up for a merchant account%2$s.',
6
-        'event_espresso'
7
-    ),
8
-    '<a href="https://eventespresso.com/go/paypalpro/" target="_blank">',
9
-    '</a>'
4
+	esc_html__(
5
+		'PayPal Pro (Website Payments Pro) is an on-site payment method for accepting credit and debit cards and is available to event organizers in the United States, United Kingdom, and Canada. An account with PayPal is required to accept payments. Need a PayPal Pro account? Call 1-855-456-1338 or %1$sclick here to sign up for a merchant account%2$s.',
6
+		'event_espresso'
7
+	),
8
+	'<a href="https://eventespresso.com/go/paypalpro/" target="_blank">',
9
+	'</a>'
10 10
 );
Please login to merge, or discard this patch.
caffeinated/payment_methods/Aim/EEG_Aim.gateway.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
                     $line_item->unit_price(),
192 192
                     'N'
193 193
                 );
194
-                $order_description .= $this->prepareStringForAuthnet($line_item->desc()) . ', ';
194
+                $order_description .= $this->prepareStringForAuthnet($line_item->desc()).', ';
195 195
             }
196 196
             foreach ($total_line_item->tax_descendants() as $tax_line_item) {
197 197
                 $this->addLineItem(
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
         $this->setField('last_name', $billing_info['last_name']);
217 217
         $this->setField('email', $billing_info['email']);
218 218
         $this->setField('company', $billing_info['company']);
219
-        $this->setField('address', $billing_info['address'] . ' ' . $billing_info['address2']);
219
+        $this->setField('address', $billing_info['address'].' '.$billing_info['address2']);
220 220
         $this->setField('city', $billing_info['city']);
221 221
         $this->setField('state', $billing_info['state']);
222 222
         $this->setField('country', $billing_info['country']);
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
         // invoice_num would be nice to have it be unique per SPCO page-load, that way if users
230 230
         // press back, they don't submit a duplicate. However, we may be keeping the user on teh same spco page
231 231
         // in which case, we need to generate teh invoice num per request right here...
232
-        $this->setField('invoice_num', wp_generate_password(12, false));// $billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']);
232
+        $this->setField('invoice_num', wp_generate_password(12, false)); // $billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']);
233 233
         // tell AIM that any duplicates sent in the next 5 minutes are to be ignored
234 234
         $this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS);
235 235
 
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
         // Capture response
241 241
         $this->type = "AUTH_CAPTURE";
242 242
         $response = $this->_sendRequest($payment);
243
-        if (! empty($response)) {
243
+        if ( ! empty($response)) {
244 244
             if ($response->error_message) {
245 245
                 $payment->set_status($this->_pay_model->failed_status());
246 246
                 $payment->set_gateway_response($response->error_message);
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
     protected function _set_sensitive_billing_data($billing_info)
287 287
     {
288 288
         $this->setField('card_num', $billing_info['credit_card']);
289
-        $this->setField('exp_date', $billing_info['exp_month'] . $billing_info['exp_year']);
289
+        $this->setField('exp_date', $billing_info['exp_month'].$billing_info['exp_year']);
290 290
         $this->setField('card_code', $billing_info['cvv']);
291 291
     }
292 292
 
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
     protected function setField($name, $value)
327 327
     {
328 328
         if (in_array($name, $this->_all_aim_fields)) {
329
-            $this->_x_post_fields[ $name ] = $value;
329
+            $this->_x_post_fields[$name] = $value;
330 330
         } else {
331 331
             throw new AuthorizeNetException("Error: no field $name exists in the AIM API.
332 332
             To set a custom field use setCustomField('field','value') instead.");
@@ -346,11 +346,11 @@  discard block
 block discarded – undo
346 346
         $this->_x_post_fields['tran_key'] = $this->_transaction_key;
347 347
         $x_keys = array();
348 348
         foreach ($this->_x_post_fields as $key => $value) {
349
-            $x_keys[] = "x_$key=" . urlencode($this->_get_unsupported_character_remover()->format($value));
349
+            $x_keys[] = "x_$key=".urlencode($this->_get_unsupported_character_remover()->format($value));
350 350
         }
351 351
         // Add line items
352 352
         foreach ($this->_additional_line_items as $key => $value) {
353
-            $x_keys[] =  "x_line_item=" . urlencode($this->_get_unsupported_character_remover()->format($value));
353
+            $x_keys[] = "x_line_item=".urlencode($this->_get_unsupported_character_remover()->format($value));
354 354
         }
355 355
         $this->_log_clean_request($x_keys, $payment);
356 356
         $post_url = $this->_get_server_url();
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
         curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1);
363 363
         curl_setopt($curl_request, CURLOPT_SSL_VERIFYHOST, 2);
364 364
         if ($this->VERIFY_PEER) {
365
-            curl_setopt($curl_request, CURLOPT_CAINFO, dirname(__DIR__) . '/ssl/cert.pem');
365
+            curl_setopt($curl_request, CURLOPT_CAINFO, dirname(__DIR__).'/ssl/cert.pem');
366 366
         } else {
367 367
             curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false);
368 368
         }
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
         $response = curl_exec($curl_request);
375 375
 
376 376
         curl_close($curl_request);
377
-        $response_obj =  new EE_AuthorizeNetAIM_Response($response);
377
+        $response_obj = new EE_AuthorizeNetAIM_Response($response);
378 378
 
379 379
         return $this->_log_and_clean_response($response_obj, $payment);
380 380
     }
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
                 if (strpos($keyvaltogether, $key) === 0) {
395 395
                     // found it at the first character
396 396
                     // so its one of them
397
-                    unset($request_array[ $index ]);
397
+                    unset($request_array[$index]);
398 398
                 }
399 399
             }
400 400
         }
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
             // Split Array
536 536
             $this->response = $response;
537 537
             if ($encap_char) {
538
-                $this->_response_array = explode($encap_char . $delimiter . $encap_char, substr($response, 1, -1));
538
+                $this->_response_array = explode($encap_char.$delimiter.$encap_char, substr($response, 1, -1));
539 539
             } else {
540 540
                 $this->_response_array = explode($delimiter, $response);
541 541
             }
@@ -617,7 +617,7 @@  discard block
 block discarded – undo
617 617
     }
618 618
 }
619 619
 
620
-if (! class_exists('AuthorizeNetException')) {
620
+if ( ! class_exists('AuthorizeNetException')) {
621 621
     /**
622 622
      * Class AuthorizeNetException
623 623
      *
Please login to merge, or discard this patch.
Indentation   +590 added lines, -590 removed lines patch added patch discarded remove patch
@@ -25,413 +25,413 @@  discard block
 block discarded – undo
25 25
  */
26 26
 class EEG_Aim extends EE_Onsite_Gateway
27 27
 {
28
-    const LIVE_URL    = 'https://secure2.authorize.net/gateway/transact.dll'; // Authnet URL
29
-
30
-    const SANDBOX_URL = 'https://test.authorize.net/gateway/transact.dll';
31
-
32
-    protected $_login_id;
33
-
34
-    protected $_transaction_key;
35
-
36
-    protected $_currencies_supported = array(
37
-        'AUD',
38
-        'USD',
39
-        'CAD',
40
-        'EUR',
41
-        'GBP',
42
-        'NZD',
43
-    );
44
-
45
-    /**
46
-     * Whether to send test transactions (even to live site)
47
-     *
48
-     * @var boolean
49
-     */
50
-    protected $_test_transactions;
51
-
52
-    private $VERIFY_PEER = false;
53
-
54
-    private $_x_post_fields = array(
55
-        "version"        => "3.1",
56
-        "delim_char"     => ",",
57
-        "delim_data"     => "TRUE",
58
-        "relay_response" => "FALSE",
59
-        "encap_char"     => "|",
60
-    );
61
-
62
-    private $_additional_line_items = array();
63
-
64
-    /**
65
-     * A list of all fields in the AIM API.
66
-     * Used to warn user if they try to set a field not offered in the API.
67
-     */
68
-    private $_all_aim_fields = array(
69
-        "address",
70
-        "allow_partial_auth",
71
-        "amount",
72
-        "auth_code",
73
-        "authentication_indicator",
74
-        "bank_aba_code",
75
-        "bank_acct_name",
76
-        "bank_acct_num",
77
-        "bank_acct_type",
78
-        "bank_check_number",
79
-        "bank_name",
80
-        "card_code",
81
-        "card_num",
82
-        "cardholder_authentication_value",
83
-        "city",
84
-        "company",
85
-        "country",
86
-        "cust_id",
87
-        "customer_ip",
88
-        "delim_char",
89
-        "delim_data",
90
-        "description",
91
-        "duplicate_window",
92
-        "duty",
93
-        "echeck_type",
94
-        "email",
95
-        "email_customer",
96
-        "encap_char",
97
-        "exp_date",
98
-        "fax",
99
-        "first_name",
100
-        "footer_email_receipt",
101
-        "freight",
102
-        "header_email_receipt",
103
-        "invoice_num",
104
-        "last_name",
105
-        "line_item",
106
-        "login",
107
-        "method",
108
-        "phone",
109
-        "po_num",
110
-        "recurring_billing",
111
-        "relay_response",
112
-        "ship_to_address",
113
-        "ship_to_city",
114
-        "ship_to_company",
115
-        "ship_to_country",
116
-        "ship_to_first_name",
117
-        "ship_to_last_name",
118
-        "ship_to_state",
119
-        "ship_to_zip",
120
-        "split_tender_id",
121
-        "state",
122
-        "tax",
123
-        "tax_exempt",
124
-        "test_request",
125
-        "tran_key",
126
-        "trans_id",
127
-        "type",
128
-        "version",
129
-        "zip",
130
-        "solution_id",
131
-        "currency_code"
132
-    );
133
-
134
-
135
-    /**
136
-     * Gets the URL where the request should go. This is filterable
137
-     *
138
-     * @return string
139
-     */
140
-    protected function _get_server_url()
141
-    {
142
-        return apply_filters(
143
-            'FHEE__EEG_Aim___get_server_url',
144
-            $this->_debug_mode ? self::SANDBOX_URL : self::LIVE_URL,
145
-            $this
146
-        );
147
-    }
148
-
149
-
150
-    /**
151
-     * Asks the gateway to do whatever it does to process the payment. Onsite gateways will
152
-     * usually send a request directly to the payment provider and update the payment's status based on that;
153
-     * whereas offsite gateways will usually just update the payment with the URL and query parameters to use
154
-     * for sending the request via http_remote_request()
155
-     *
156
-     * @param EE_Payment|null $payment
157
-     * @param array|null $billing_info
158
-     * @return EE_Payment
159
-     * @throws EE_Error
160
-     * @throws ReflectionException
161
-     */
162
-    public function do_direct_payment($payment, $billing_info = null)
163
-    {
164
-        // Enable test mode if needed
165
-        // 4007000000027  <-- test successful visa
166
-        // 4222222222222  <-- test failure card number
167
-
168
-        $item_num = 1;
169
-        $transaction = $payment->transaction();
170
-        $gateway_formatter = $this->_get_gateway_formatter();
171
-        $order_description = $this->prepareStringForAuthnet($gateway_formatter->formatOrderDescription($payment));
172
-        $primary_registrant = $transaction->primary_registration();
173
-        // if we're are charging for the full amount, show the normal line items
174
-        // and the itemized total adds up properly
175
-        if ($this->_can_easily_itemize_transaction_for($payment)) {
176
-            $total_line_item = $transaction->total_line_item();
177
-            foreach ($total_line_item->get_items() as $line_item) {
178
-                if ($line_item->quantity() == 0) {
179
-                    continue;
180
-                }
181
-                $this->addLineItem(
182
-                    $item_num++,
183
-                    $gateway_formatter->formatLineItemName($line_item, $payment),
184
-                    $gateway_formatter->formatLineItemDesc($line_item, $payment),
185
-                    $line_item->quantity(),
186
-                    $line_item->unit_price(),
187
-                    'N'
188
-                );
189
-                $order_description .= $this->prepareStringForAuthnet($line_item->desc()) . ', ';
190
-            }
191
-            foreach ($total_line_item->tax_descendants() as $tax_line_item) {
192
-                $this->addLineItem(
193
-                    $item_num++,
194
-                    $tax_line_item->name(),
195
-                    $tax_line_item->desc(),
196
-                    1,
197
-                    $tax_line_item->total(),
198
-                    'N'
199
-                );
200
-            }
201
-        }
202
-
203
-        // start transaction
204
-        // if in debug mode, use authorize.net's sandbox id; otherwise use the Event Espresso partner id
205
-        $partner_id = $this->_debug_mode ? 'AAA100302' : 'AAA105363';
206
-        $this->setField('solution_id', $partner_id);
207
-        $this->setField('amount', $gateway_formatter->formatCurrency($payment->amount()));
208
-        $this->setField('description', substr(rtrim($order_description, ', '), 0, 255));
209
-        $this->_set_sensitive_billing_data($billing_info);
210
-        $this->setField('first_name', $billing_info['first_name']);
211
-        $this->setField('last_name', $billing_info['last_name']);
212
-        $this->setField('email', $billing_info['email']);
213
-        $this->setField('company', $billing_info['company']);
214
-        $this->setField('address', $billing_info['address'] . ' ' . $billing_info['address2']);
215
-        $this->setField('city', $billing_info['city']);
216
-        $this->setField('state', $billing_info['state']);
217
-        $this->setField('country', $billing_info['country']);
218
-        $this->setField('zip', $billing_info['zip']);
219
-        $this->setField('fax', $billing_info['fax']);
220
-        $this->setField('cust_id', $primary_registrant->ID());
221
-        $this->setField('phone', $billing_info['phone']);
222
-        $currency_config = LoaderFactory::getLoader()->load('EE_Currency_Config');
223
-        $this->setField('currency_code', $currency_config->code);
224
-        // invoice_num would be nice to have it be unique per SPCO page-load, that way if users
225
-        // press back, they don't submit a duplicate. However, we may be keeping the user on teh same spco page
226
-        // in which case, we need to generate teh invoice num per request right here...
227
-        $this->setField('invoice_num', wp_generate_password(12, false));// $billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']);
228
-        // tell AIM that any duplicates sent in the next 5 minutes are to be ignored
229
-        $this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS);
230
-
231
-        if ($this->_test_transactions) {
232
-            $this->test_request = "true";
233
-        }
234
-
235
-        // Capture response
236
-        $this->type = "AUTH_CAPTURE";
237
-        $response = $this->_sendRequest($payment);
238
-        if (! empty($response)) {
239
-            if ($response->error_message) {
240
-                $payment->set_status($this->_pay_model->failed_status());
241
-                $payment->set_gateway_response($response->error_message);
242
-            } else {
243
-                $payment_status = $response->approved
244
-                    ? $this->_pay_model->approved_status()
245
-                    : $this->_pay_model->declined_status();
246
-                $payment->set_status($payment_status);
247
-                // make sure we interpret the AMT as a float, not an international string (where periods are thousand separators)
248
-                $payment->set_amount((float) $response->amount);
249
-                $payment->set_gateway_response(
250
-                    sprintf(
251
-                        esc_html__('%1$s (Reason Code: %2$s)', 'event_espresso'),
252
-                        $response->response_reason_text,
253
-                        $response->response_reason_code
254
-                    )
255
-                );
256
-                if ($this->_debug_mode) {
257
-                    $txn_id = $response->invoice_number;
258
-                } else {
259
-                    $txn_id = $response->transaction_id;
260
-                }
261
-                $payment->set_txn_id_chq_nmbr($txn_id);
262
-            }
263
-            $payment->set_extra_accntng($primary_registrant->reg_code());
264
-            $payment->set_details(print_r($response, true));
265
-        } else {
266
-            $payment->set_status($this->_pay_model->failed_status());
267
-            $payment->set_gateway_response(esc_html__("There was no response from Authorize.net", 'event_espresso'));
268
-            $payment->set_details(print_r($response, true));
269
-        }
270
-        return $payment;
271
-    }
272
-
273
-
274
-    /**
275
-     * Sets billing data for the upcoming request to AIM that is considered sensitive;
276
-     * also this method can be overridden by children classes to easily change
277
-     * what billing data gets sent
278
-     *
279
-     * @param array $billing_info
280
-     */
281
-    protected function _set_sensitive_billing_data($billing_info)
282
-    {
283
-        $this->setField('card_num', $billing_info['credit_card']);
284
-        $this->setField('exp_date', $billing_info['exp_month'] . $billing_info['exp_year']);
285
-        $this->setField('card_code', $billing_info['cvv']);
286
-    }
287
-
288
-
289
-    /**
290
-     * Add a line item.
291
-     *
292
-     * @param string $item_id
293
-     * @param string $item_name
294
-     * @param string $item_description
295
-     * @param string $item_quantity
296
-     * @param string $item_unit_price
297
-     * @param string $item_taxable
298
-     */
299
-    public function addLineItem($item_id, $item_name, $item_description, $item_quantity, $item_unit_price, $item_taxable)
300
-    {
301
-        $args = array(
302
-            substr($item_id, 0, 31),
303
-            substr($this->prepareStringForAuthnet($item_name), 0, 31),
304
-            substr($this->prepareStringForAuthnet($item_description), 0, 255),
305
-            number_format(abs($item_quantity), 2, '.', ''),
306
-            number_format(abs($item_unit_price), 2, '.', ''),
307
-            $item_taxable === 'N' ? 'N' : 'Y'
308
-        );
309
-        $this->_additional_line_items[] = implode('<|>', $args);
310
-    }
311
-
312
-
313
-    /**
314
-     * Set an individual name/value pair. This will append x_ to the name
315
-     * before posting.
316
-     *
317
-     * @param string $name
318
-     * @param string $value
319
-     * @throws AuthorizeNetException
320
-     */
321
-    protected function setField($name, $value)
322
-    {
323
-        if (in_array($name, $this->_all_aim_fields)) {
324
-            $this->_x_post_fields[ $name ] = $value;
325
-        } else {
326
-            throw new AuthorizeNetException("Error: no field $name exists in the AIM API.
28
+	const LIVE_URL    = 'https://secure2.authorize.net/gateway/transact.dll'; // Authnet URL
29
+
30
+	const SANDBOX_URL = 'https://test.authorize.net/gateway/transact.dll';
31
+
32
+	protected $_login_id;
33
+
34
+	protected $_transaction_key;
35
+
36
+	protected $_currencies_supported = array(
37
+		'AUD',
38
+		'USD',
39
+		'CAD',
40
+		'EUR',
41
+		'GBP',
42
+		'NZD',
43
+	);
44
+
45
+	/**
46
+	 * Whether to send test transactions (even to live site)
47
+	 *
48
+	 * @var boolean
49
+	 */
50
+	protected $_test_transactions;
51
+
52
+	private $VERIFY_PEER = false;
53
+
54
+	private $_x_post_fields = array(
55
+		"version"        => "3.1",
56
+		"delim_char"     => ",",
57
+		"delim_data"     => "TRUE",
58
+		"relay_response" => "FALSE",
59
+		"encap_char"     => "|",
60
+	);
61
+
62
+	private $_additional_line_items = array();
63
+
64
+	/**
65
+	 * A list of all fields in the AIM API.
66
+	 * Used to warn user if they try to set a field not offered in the API.
67
+	 */
68
+	private $_all_aim_fields = array(
69
+		"address",
70
+		"allow_partial_auth",
71
+		"amount",
72
+		"auth_code",
73
+		"authentication_indicator",
74
+		"bank_aba_code",
75
+		"bank_acct_name",
76
+		"bank_acct_num",
77
+		"bank_acct_type",
78
+		"bank_check_number",
79
+		"bank_name",
80
+		"card_code",
81
+		"card_num",
82
+		"cardholder_authentication_value",
83
+		"city",
84
+		"company",
85
+		"country",
86
+		"cust_id",
87
+		"customer_ip",
88
+		"delim_char",
89
+		"delim_data",
90
+		"description",
91
+		"duplicate_window",
92
+		"duty",
93
+		"echeck_type",
94
+		"email",
95
+		"email_customer",
96
+		"encap_char",
97
+		"exp_date",
98
+		"fax",
99
+		"first_name",
100
+		"footer_email_receipt",
101
+		"freight",
102
+		"header_email_receipt",
103
+		"invoice_num",
104
+		"last_name",
105
+		"line_item",
106
+		"login",
107
+		"method",
108
+		"phone",
109
+		"po_num",
110
+		"recurring_billing",
111
+		"relay_response",
112
+		"ship_to_address",
113
+		"ship_to_city",
114
+		"ship_to_company",
115
+		"ship_to_country",
116
+		"ship_to_first_name",
117
+		"ship_to_last_name",
118
+		"ship_to_state",
119
+		"ship_to_zip",
120
+		"split_tender_id",
121
+		"state",
122
+		"tax",
123
+		"tax_exempt",
124
+		"test_request",
125
+		"tran_key",
126
+		"trans_id",
127
+		"type",
128
+		"version",
129
+		"zip",
130
+		"solution_id",
131
+		"currency_code"
132
+	);
133
+
134
+
135
+	/**
136
+	 * Gets the URL where the request should go. This is filterable
137
+	 *
138
+	 * @return string
139
+	 */
140
+	protected function _get_server_url()
141
+	{
142
+		return apply_filters(
143
+			'FHEE__EEG_Aim___get_server_url',
144
+			$this->_debug_mode ? self::SANDBOX_URL : self::LIVE_URL,
145
+			$this
146
+		);
147
+	}
148
+
149
+
150
+	/**
151
+	 * Asks the gateway to do whatever it does to process the payment. Onsite gateways will
152
+	 * usually send a request directly to the payment provider and update the payment's status based on that;
153
+	 * whereas offsite gateways will usually just update the payment with the URL and query parameters to use
154
+	 * for sending the request via http_remote_request()
155
+	 *
156
+	 * @param EE_Payment|null $payment
157
+	 * @param array|null $billing_info
158
+	 * @return EE_Payment
159
+	 * @throws EE_Error
160
+	 * @throws ReflectionException
161
+	 */
162
+	public function do_direct_payment($payment, $billing_info = null)
163
+	{
164
+		// Enable test mode if needed
165
+		// 4007000000027  <-- test successful visa
166
+		// 4222222222222  <-- test failure card number
167
+
168
+		$item_num = 1;
169
+		$transaction = $payment->transaction();
170
+		$gateway_formatter = $this->_get_gateway_formatter();
171
+		$order_description = $this->prepareStringForAuthnet($gateway_formatter->formatOrderDescription($payment));
172
+		$primary_registrant = $transaction->primary_registration();
173
+		// if we're are charging for the full amount, show the normal line items
174
+		// and the itemized total adds up properly
175
+		if ($this->_can_easily_itemize_transaction_for($payment)) {
176
+			$total_line_item = $transaction->total_line_item();
177
+			foreach ($total_line_item->get_items() as $line_item) {
178
+				if ($line_item->quantity() == 0) {
179
+					continue;
180
+				}
181
+				$this->addLineItem(
182
+					$item_num++,
183
+					$gateway_formatter->formatLineItemName($line_item, $payment),
184
+					$gateway_formatter->formatLineItemDesc($line_item, $payment),
185
+					$line_item->quantity(),
186
+					$line_item->unit_price(),
187
+					'N'
188
+				);
189
+				$order_description .= $this->prepareStringForAuthnet($line_item->desc()) . ', ';
190
+			}
191
+			foreach ($total_line_item->tax_descendants() as $tax_line_item) {
192
+				$this->addLineItem(
193
+					$item_num++,
194
+					$tax_line_item->name(),
195
+					$tax_line_item->desc(),
196
+					1,
197
+					$tax_line_item->total(),
198
+					'N'
199
+				);
200
+			}
201
+		}
202
+
203
+		// start transaction
204
+		// if in debug mode, use authorize.net's sandbox id; otherwise use the Event Espresso partner id
205
+		$partner_id = $this->_debug_mode ? 'AAA100302' : 'AAA105363';
206
+		$this->setField('solution_id', $partner_id);
207
+		$this->setField('amount', $gateway_formatter->formatCurrency($payment->amount()));
208
+		$this->setField('description', substr(rtrim($order_description, ', '), 0, 255));
209
+		$this->_set_sensitive_billing_data($billing_info);
210
+		$this->setField('first_name', $billing_info['first_name']);
211
+		$this->setField('last_name', $billing_info['last_name']);
212
+		$this->setField('email', $billing_info['email']);
213
+		$this->setField('company', $billing_info['company']);
214
+		$this->setField('address', $billing_info['address'] . ' ' . $billing_info['address2']);
215
+		$this->setField('city', $billing_info['city']);
216
+		$this->setField('state', $billing_info['state']);
217
+		$this->setField('country', $billing_info['country']);
218
+		$this->setField('zip', $billing_info['zip']);
219
+		$this->setField('fax', $billing_info['fax']);
220
+		$this->setField('cust_id', $primary_registrant->ID());
221
+		$this->setField('phone', $billing_info['phone']);
222
+		$currency_config = LoaderFactory::getLoader()->load('EE_Currency_Config');
223
+		$this->setField('currency_code', $currency_config->code);
224
+		// invoice_num would be nice to have it be unique per SPCO page-load, that way if users
225
+		// press back, they don't submit a duplicate. However, we may be keeping the user on teh same spco page
226
+		// in which case, we need to generate teh invoice num per request right here...
227
+		$this->setField('invoice_num', wp_generate_password(12, false));// $billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']);
228
+		// tell AIM that any duplicates sent in the next 5 minutes are to be ignored
229
+		$this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS);
230
+
231
+		if ($this->_test_transactions) {
232
+			$this->test_request = "true";
233
+		}
234
+
235
+		// Capture response
236
+		$this->type = "AUTH_CAPTURE";
237
+		$response = $this->_sendRequest($payment);
238
+		if (! empty($response)) {
239
+			if ($response->error_message) {
240
+				$payment->set_status($this->_pay_model->failed_status());
241
+				$payment->set_gateway_response($response->error_message);
242
+			} else {
243
+				$payment_status = $response->approved
244
+					? $this->_pay_model->approved_status()
245
+					: $this->_pay_model->declined_status();
246
+				$payment->set_status($payment_status);
247
+				// make sure we interpret the AMT as a float, not an international string (where periods are thousand separators)
248
+				$payment->set_amount((float) $response->amount);
249
+				$payment->set_gateway_response(
250
+					sprintf(
251
+						esc_html__('%1$s (Reason Code: %2$s)', 'event_espresso'),
252
+						$response->response_reason_text,
253
+						$response->response_reason_code
254
+					)
255
+				);
256
+				if ($this->_debug_mode) {
257
+					$txn_id = $response->invoice_number;
258
+				} else {
259
+					$txn_id = $response->transaction_id;
260
+				}
261
+				$payment->set_txn_id_chq_nmbr($txn_id);
262
+			}
263
+			$payment->set_extra_accntng($primary_registrant->reg_code());
264
+			$payment->set_details(print_r($response, true));
265
+		} else {
266
+			$payment->set_status($this->_pay_model->failed_status());
267
+			$payment->set_gateway_response(esc_html__("There was no response from Authorize.net", 'event_espresso'));
268
+			$payment->set_details(print_r($response, true));
269
+		}
270
+		return $payment;
271
+	}
272
+
273
+
274
+	/**
275
+	 * Sets billing data for the upcoming request to AIM that is considered sensitive;
276
+	 * also this method can be overridden by children classes to easily change
277
+	 * what billing data gets sent
278
+	 *
279
+	 * @param array $billing_info
280
+	 */
281
+	protected function _set_sensitive_billing_data($billing_info)
282
+	{
283
+		$this->setField('card_num', $billing_info['credit_card']);
284
+		$this->setField('exp_date', $billing_info['exp_month'] . $billing_info['exp_year']);
285
+		$this->setField('card_code', $billing_info['cvv']);
286
+	}
287
+
288
+
289
+	/**
290
+	 * Add a line item.
291
+	 *
292
+	 * @param string $item_id
293
+	 * @param string $item_name
294
+	 * @param string $item_description
295
+	 * @param string $item_quantity
296
+	 * @param string $item_unit_price
297
+	 * @param string $item_taxable
298
+	 */
299
+	public function addLineItem($item_id, $item_name, $item_description, $item_quantity, $item_unit_price, $item_taxable)
300
+	{
301
+		$args = array(
302
+			substr($item_id, 0, 31),
303
+			substr($this->prepareStringForAuthnet($item_name), 0, 31),
304
+			substr($this->prepareStringForAuthnet($item_description), 0, 255),
305
+			number_format(abs($item_quantity), 2, '.', ''),
306
+			number_format(abs($item_unit_price), 2, '.', ''),
307
+			$item_taxable === 'N' ? 'N' : 'Y'
308
+		);
309
+		$this->_additional_line_items[] = implode('<|>', $args);
310
+	}
311
+
312
+
313
+	/**
314
+	 * Set an individual name/value pair. This will append x_ to the name
315
+	 * before posting.
316
+	 *
317
+	 * @param string $name
318
+	 * @param string $value
319
+	 * @throws AuthorizeNetException
320
+	 */
321
+	protected function setField($name, $value)
322
+	{
323
+		if (in_array($name, $this->_all_aim_fields)) {
324
+			$this->_x_post_fields[ $name ] = $value;
325
+		} else {
326
+			throw new AuthorizeNetException("Error: no field $name exists in the AIM API.
327 327
             To set a custom field use setCustomField('field','value') instead.");
328
-        }
329
-    }
330
-
331
-
332
-    /**
333
-     * Posts the request to AuthorizeNet & returns response.
334
-     *
335
-     * @param $payment
336
-     * @return \EE_AuthorizeNetAIM_Response
337
-     */
338
-    private function _sendRequest($payment)
339
-    {
340
-        $this->_x_post_fields['login'] = $this->_login_id;
341
-        $this->_x_post_fields['tran_key'] = $this->_transaction_key;
342
-        $x_keys = array();
343
-        foreach ($this->_x_post_fields as $key => $value) {
344
-            $x_keys[] = "x_$key=" . urlencode($this->_get_unsupported_character_remover()->format($value));
345
-        }
346
-        // Add line items
347
-        foreach ($this->_additional_line_items as $key => $value) {
348
-            $x_keys[] =  "x_line_item=" . urlencode($this->_get_unsupported_character_remover()->format($value));
349
-        }
350
-        $this->_log_clean_request($x_keys, $payment);
351
-        $post_url = $this->_get_server_url();
352
-        $curl_request = curl_init($post_url);
353
-        $post_body = implode("&", $x_keys);
354
-        curl_setopt($curl_request, CURLOPT_POSTFIELDS, $post_body);
355
-        curl_setopt($curl_request, CURLOPT_HEADER, 0);
356
-        curl_setopt($curl_request, CURLOPT_TIMEOUT, 45);
357
-        curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1);
358
-        curl_setopt($curl_request, CURLOPT_SSL_VERIFYHOST, 2);
359
-        if ($this->VERIFY_PEER) {
360
-            curl_setopt($curl_request, CURLOPT_CAINFO, dirname(__DIR__) . '/ssl/cert.pem');
361
-        } else {
362
-            curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false);
363
-        }
364
-
365
-        if (preg_match('/xml/', $post_url)) {
366
-            curl_setopt($curl_request, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
367
-        }
368
-
369
-        $response = curl_exec($curl_request);
370
-
371
-        curl_close($curl_request);
372
-        $response_obj =  new EE_AuthorizeNetAIM_Response($response);
373
-
374
-        return $this->_log_and_clean_response($response_obj, $payment);
375
-    }
376
-
377
-
378
-    /**
379
-     * Logs the clean data only
380
-     *
381
-     * @param array $request_array
382
-     * @param EE_Payment $payment
383
-     */
384
-    protected function _log_clean_request($request_array, $payment)
385
-    {
386
-        $keys_to_filter_out = array('x_card_num', 'x_card_code', 'x_exp_date');
387
-        foreach ($request_array as $index => $keyvaltogether) {
388
-            foreach ($keys_to_filter_out as $key) {
389
-                if (strpos($keyvaltogether, $key) === 0) {
390
-                    // found it at the first character
391
-                    // so its one of them
392
-                    unset($request_array[ $index ]);
393
-                }
394
-            }
395
-        }
396
-        $this->log(
397
-            array(
398
-                'AIM Request sent:' => $request_array,
399
-                'Server URL'        => $this->_get_server_url()
400
-            ),
401
-            $payment
402
-        );
403
-    }
404
-
405
-
406
-
407
-    /**
408
-     * Logs the response and cleans it
409
-     *
410
-     * @param EE_AuthorizeNetAIM_Response $response_obj
411
-     * @param EE_Payment                  $payment
412
-     * @return \EE_AuthorizeNetAIM_Response
413
-     */
414
-    private function _log_and_clean_response($response_obj, $payment)
415
-    {
416
-        $response_obj->account_number = '';
417
-        $this->log(array('AIM Response received:' => (array) $response_obj), $payment);
418
-        return $response_obj;
419
-    }
420
-
421
-    /**
422
-     * Removes characters Authorize.net doesn't handle well.
423
-     * @since 4.9.82.p
424
-     * @param $text
425
-     * @return string
426
-     */
427
-    private function prepareStringForAuthnet($text)
428
-    {
429
-        return str_replace(
430
-            '\'',
431
-            '',
432
-            $text
433
-        );
434
-    }
328
+		}
329
+	}
330
+
331
+
332
+	/**
333
+	 * Posts the request to AuthorizeNet & returns response.
334
+	 *
335
+	 * @param $payment
336
+	 * @return \EE_AuthorizeNetAIM_Response
337
+	 */
338
+	private function _sendRequest($payment)
339
+	{
340
+		$this->_x_post_fields['login'] = $this->_login_id;
341
+		$this->_x_post_fields['tran_key'] = $this->_transaction_key;
342
+		$x_keys = array();
343
+		foreach ($this->_x_post_fields as $key => $value) {
344
+			$x_keys[] = "x_$key=" . urlencode($this->_get_unsupported_character_remover()->format($value));
345
+		}
346
+		// Add line items
347
+		foreach ($this->_additional_line_items as $key => $value) {
348
+			$x_keys[] =  "x_line_item=" . urlencode($this->_get_unsupported_character_remover()->format($value));
349
+		}
350
+		$this->_log_clean_request($x_keys, $payment);
351
+		$post_url = $this->_get_server_url();
352
+		$curl_request = curl_init($post_url);
353
+		$post_body = implode("&", $x_keys);
354
+		curl_setopt($curl_request, CURLOPT_POSTFIELDS, $post_body);
355
+		curl_setopt($curl_request, CURLOPT_HEADER, 0);
356
+		curl_setopt($curl_request, CURLOPT_TIMEOUT, 45);
357
+		curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1);
358
+		curl_setopt($curl_request, CURLOPT_SSL_VERIFYHOST, 2);
359
+		if ($this->VERIFY_PEER) {
360
+			curl_setopt($curl_request, CURLOPT_CAINFO, dirname(__DIR__) . '/ssl/cert.pem');
361
+		} else {
362
+			curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false);
363
+		}
364
+
365
+		if (preg_match('/xml/', $post_url)) {
366
+			curl_setopt($curl_request, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
367
+		}
368
+
369
+		$response = curl_exec($curl_request);
370
+
371
+		curl_close($curl_request);
372
+		$response_obj =  new EE_AuthorizeNetAIM_Response($response);
373
+
374
+		return $this->_log_and_clean_response($response_obj, $payment);
375
+	}
376
+
377
+
378
+	/**
379
+	 * Logs the clean data only
380
+	 *
381
+	 * @param array $request_array
382
+	 * @param EE_Payment $payment
383
+	 */
384
+	protected function _log_clean_request($request_array, $payment)
385
+	{
386
+		$keys_to_filter_out = array('x_card_num', 'x_card_code', 'x_exp_date');
387
+		foreach ($request_array as $index => $keyvaltogether) {
388
+			foreach ($keys_to_filter_out as $key) {
389
+				if (strpos($keyvaltogether, $key) === 0) {
390
+					// found it at the first character
391
+					// so its one of them
392
+					unset($request_array[ $index ]);
393
+				}
394
+			}
395
+		}
396
+		$this->log(
397
+			array(
398
+				'AIM Request sent:' => $request_array,
399
+				'Server URL'        => $this->_get_server_url()
400
+			),
401
+			$payment
402
+		);
403
+	}
404
+
405
+
406
+
407
+	/**
408
+	 * Logs the response and cleans it
409
+	 *
410
+	 * @param EE_AuthorizeNetAIM_Response $response_obj
411
+	 * @param EE_Payment                  $payment
412
+	 * @return \EE_AuthorizeNetAIM_Response
413
+	 */
414
+	private function _log_and_clean_response($response_obj, $payment)
415
+	{
416
+		$response_obj->account_number = '';
417
+		$this->log(array('AIM Response received:' => (array) $response_obj), $payment);
418
+		return $response_obj;
419
+	}
420
+
421
+	/**
422
+	 * Removes characters Authorize.net doesn't handle well.
423
+	 * @since 4.9.82.p
424
+	 * @param $text
425
+	 * @return string
426
+	 */
427
+	private function prepareStringForAuthnet($text)
428
+	{
429
+		return str_replace(
430
+			'\'',
431
+			'',
432
+			$text
433
+		);
434
+	}
435 435
 }
436 436
 
437 437
 
@@ -446,191 +446,191 @@  discard block
 block discarded – undo
446 446
  */
447 447
 class EE_AuthorizeNetAIM_Response
448 448
 {
449
-    const APPROVED = '1';
450
-    const DECLINED = '2';
451
-    const ERROR = '3';
452
-    const HELD = '4';
453
-
454
-    protected $_x_post_fields = array(
455
-        "version"        => "3.1",
456
-        "delim_char"     => ",",
457
-        "delim_data"     => "TRUE",
458
-        "relay_response" => "FALSE",
459
-        "encap_char"     => "|",
460
-    );
461
-    public $approved;
462
-    public $declined;
463
-    public $error;
464
-    public $held;
465
-    public $response_code;
466
-    public $response_subcode;
467
-    public $response_reason_code;
468
-    public $response_reason_text;
469
-    public $authorization_code;
470
-    public $avs_response;
471
-    public $transaction_id;
472
-    public $invoice_number;
473
-    public $description;
474
-    public $amount;
475
-    public $method;
476
-    public $transaction_type;
477
-    public $customer_id;
478
-    public $first_name;
479
-    public $last_name;
480
-    public $company;
481
-    public $address;
482
-    public $city;
483
-    public $state;
484
-    public $zip_code;
485
-    public $country;
486
-    public $phone;
487
-    public $fax;
488
-    public $email_address;
489
-    public $ship_to_first_name;
490
-    public $ship_to_last_name;
491
-    public $ship_to_company;
492
-    public $ship_to_address;
493
-    public $ship_to_city;
494
-    public $ship_to_state;
495
-    public $ship_to_zip_code;
496
-    public $ship_to_country;
497
-    public $tax;
498
-    public $duty;
499
-    public $freight;
500
-    public $tax_exempt;
501
-    public $purchase_order_number;
502
-    public $md5_hash;
503
-    public $card_code_response;
504
-    public $cavv_response; // cardholder_authentication_verification_response
505
-    public $account_number;
506
-    public $card_type;
507
-    public $split_tender_id;
508
-    public $requested_amount;
509
-    public $balance_on_card;
510
-    public $response; // The response string from AuthorizeNet.
511
-    public $error_message;
512
-    private $_response_array = array(); // An array with the split response.
513
-
514
-
515
-    /**
516
-     * Constructor. Parses the AuthorizeNet response string
517
-     *
518
-     * @param string $response The response from the AuthNet server.
519
-     * @var string   $delimiter The delimiter used (default is ",")
520
-     * @var string   $encap_char The encap_char used (default is "|")
521
-     * @var array    $custom_fields Any custom fields set in the request.
522
-     */
523
-
524
-    public function __construct($response)
525
-    {
526
-        $encap_char = $this->_x_post_fields['encap_char'];
527
-        $delimiter = $this->_x_post_fields['delim_char'];
528
-        if ($response) {
529
-            // Split Array
530
-            $this->response = $response;
531
-            if ($encap_char) {
532
-                $this->_response_array = explode($encap_char . $delimiter . $encap_char, substr($response, 1, -1));
533
-            } else {
534
-                $this->_response_array = explode($delimiter, $response);
535
-            }
536
-
537
-            /**
538
-             * If AuthorizeNet doesn't return a delimited response.
539
-             */
540
-            if (count($this->_response_array) < 10) {
541
-                $this->approved = false;
542
-                $this->error = true;
543
-                $this->error_message = sprintf(
544
-                    esc_html__('Unrecognized response from Authorize.net: %1$s', 'event_espresso'),
545
-                    esc_html($response)
546
-                );
547
-                return;
548
-            }
549
-
550
-
551
-
552
-            // Set all fields
553
-            $this->response_code = $this->_response_array[0];
554
-            $this->response_subcode = $this->_response_array[1];
555
-            $this->response_reason_code = $this->_response_array[2];
556
-            $this->response_reason_text = $this->_response_array[3];
557
-            $this->authorization_code = $this->_response_array[4];
558
-            $this->avs_response = $this->_response_array[5];
559
-            $this->transaction_id = $this->_response_array[6];
560
-            $this->invoice_number = $this->_response_array[7];
561
-            $this->description = $this->_response_array[8];
562
-            $this->amount = $this->_response_array[9];
563
-            $this->method = $this->_response_array[10];
564
-            $this->transaction_type = $this->_response_array[11];
565
-            $this->customer_id = $this->_response_array[12];
566
-            $this->first_name = $this->_response_array[13];
567
-            $this->last_name = $this->_response_array[14];
568
-            $this->company = $this->_response_array[15];
569
-            $this->address = $this->_response_array[16];
570
-            $this->city = $this->_response_array[17];
571
-            $this->state = $this->_response_array[18];
572
-            $this->zip_code = $this->_response_array[19];
573
-            $this->country = $this->_response_array[20];
574
-            $this->phone = $this->_response_array[21];
575
-            $this->fax = $this->_response_array[22];
576
-            $this->email_address = $this->_response_array[23];
577
-            $this->ship_to_first_name = $this->_response_array[24];
578
-            $this->ship_to_last_name = $this->_response_array[25];
579
-            $this->ship_to_company = $this->_response_array[26];
580
-            $this->ship_to_address = $this->_response_array[27];
581
-            $this->ship_to_city = $this->_response_array[28];
582
-            $this->ship_to_state = $this->_response_array[29];
583
-            $this->ship_to_zip_code = $this->_response_array[30];
584
-            $this->ship_to_country = $this->_response_array[31];
585
-            $this->tax = $this->_response_array[32];
586
-            $this->duty = $this->_response_array[33];
587
-            $this->freight = $this->_response_array[34];
588
-            $this->tax_exempt = $this->_response_array[35];
589
-            $this->purchase_order_number = $this->_response_array[36];
590
-            $this->md5_hash = $this->_response_array[37];
591
-            $this->card_code_response = $this->_response_array[38];
592
-            $this->cavv_response = $this->_response_array[39];
593
-            $this->account_number = $this->_response_array[50];
594
-            $this->card_type = $this->_response_array[51];
595
-            $this->split_tender_id = $this->_response_array[52];
596
-            $this->requested_amount = $this->_response_array[53];
597
-            $this->balance_on_card = $this->_response_array[54];
598
-
599
-            $this->approved = ($this->response_code === self::APPROVED);
600
-            $this->declined = ($this->response_code === self::DECLINED);
601
-            $this->error = ($this->response_code === self::ERROR);
602
-            $this->held = ($this->response_code === self::HELD);
603
-        } else {
604
-            $this->approved = false;
605
-            $this->error = true;
606
-            $this->error_message = esc_html__(
607
-                'Error connecting to Authorize.net',
608
-                'event_espresso'
609
-            );
610
-        }
611
-    }
449
+	const APPROVED = '1';
450
+	const DECLINED = '2';
451
+	const ERROR = '3';
452
+	const HELD = '4';
453
+
454
+	protected $_x_post_fields = array(
455
+		"version"        => "3.1",
456
+		"delim_char"     => ",",
457
+		"delim_data"     => "TRUE",
458
+		"relay_response" => "FALSE",
459
+		"encap_char"     => "|",
460
+	);
461
+	public $approved;
462
+	public $declined;
463
+	public $error;
464
+	public $held;
465
+	public $response_code;
466
+	public $response_subcode;
467
+	public $response_reason_code;
468
+	public $response_reason_text;
469
+	public $authorization_code;
470
+	public $avs_response;
471
+	public $transaction_id;
472
+	public $invoice_number;
473
+	public $description;
474
+	public $amount;
475
+	public $method;
476
+	public $transaction_type;
477
+	public $customer_id;
478
+	public $first_name;
479
+	public $last_name;
480
+	public $company;
481
+	public $address;
482
+	public $city;
483
+	public $state;
484
+	public $zip_code;
485
+	public $country;
486
+	public $phone;
487
+	public $fax;
488
+	public $email_address;
489
+	public $ship_to_first_name;
490
+	public $ship_to_last_name;
491
+	public $ship_to_company;
492
+	public $ship_to_address;
493
+	public $ship_to_city;
494
+	public $ship_to_state;
495
+	public $ship_to_zip_code;
496
+	public $ship_to_country;
497
+	public $tax;
498
+	public $duty;
499
+	public $freight;
500
+	public $tax_exempt;
501
+	public $purchase_order_number;
502
+	public $md5_hash;
503
+	public $card_code_response;
504
+	public $cavv_response; // cardholder_authentication_verification_response
505
+	public $account_number;
506
+	public $card_type;
507
+	public $split_tender_id;
508
+	public $requested_amount;
509
+	public $balance_on_card;
510
+	public $response; // The response string from AuthorizeNet.
511
+	public $error_message;
512
+	private $_response_array = array(); // An array with the split response.
513
+
514
+
515
+	/**
516
+	 * Constructor. Parses the AuthorizeNet response string
517
+	 *
518
+	 * @param string $response The response from the AuthNet server.
519
+	 * @var string   $delimiter The delimiter used (default is ",")
520
+	 * @var string   $encap_char The encap_char used (default is "|")
521
+	 * @var array    $custom_fields Any custom fields set in the request.
522
+	 */
523
+
524
+	public function __construct($response)
525
+	{
526
+		$encap_char = $this->_x_post_fields['encap_char'];
527
+		$delimiter = $this->_x_post_fields['delim_char'];
528
+		if ($response) {
529
+			// Split Array
530
+			$this->response = $response;
531
+			if ($encap_char) {
532
+				$this->_response_array = explode($encap_char . $delimiter . $encap_char, substr($response, 1, -1));
533
+			} else {
534
+				$this->_response_array = explode($delimiter, $response);
535
+			}
536
+
537
+			/**
538
+			 * If AuthorizeNet doesn't return a delimited response.
539
+			 */
540
+			if (count($this->_response_array) < 10) {
541
+				$this->approved = false;
542
+				$this->error = true;
543
+				$this->error_message = sprintf(
544
+					esc_html__('Unrecognized response from Authorize.net: %1$s', 'event_espresso'),
545
+					esc_html($response)
546
+				);
547
+				return;
548
+			}
549
+
550
+
551
+
552
+			// Set all fields
553
+			$this->response_code = $this->_response_array[0];
554
+			$this->response_subcode = $this->_response_array[1];
555
+			$this->response_reason_code = $this->_response_array[2];
556
+			$this->response_reason_text = $this->_response_array[3];
557
+			$this->authorization_code = $this->_response_array[4];
558
+			$this->avs_response = $this->_response_array[5];
559
+			$this->transaction_id = $this->_response_array[6];
560
+			$this->invoice_number = $this->_response_array[7];
561
+			$this->description = $this->_response_array[8];
562
+			$this->amount = $this->_response_array[9];
563
+			$this->method = $this->_response_array[10];
564
+			$this->transaction_type = $this->_response_array[11];
565
+			$this->customer_id = $this->_response_array[12];
566
+			$this->first_name = $this->_response_array[13];
567
+			$this->last_name = $this->_response_array[14];
568
+			$this->company = $this->_response_array[15];
569
+			$this->address = $this->_response_array[16];
570
+			$this->city = $this->_response_array[17];
571
+			$this->state = $this->_response_array[18];
572
+			$this->zip_code = $this->_response_array[19];
573
+			$this->country = $this->_response_array[20];
574
+			$this->phone = $this->_response_array[21];
575
+			$this->fax = $this->_response_array[22];
576
+			$this->email_address = $this->_response_array[23];
577
+			$this->ship_to_first_name = $this->_response_array[24];
578
+			$this->ship_to_last_name = $this->_response_array[25];
579
+			$this->ship_to_company = $this->_response_array[26];
580
+			$this->ship_to_address = $this->_response_array[27];
581
+			$this->ship_to_city = $this->_response_array[28];
582
+			$this->ship_to_state = $this->_response_array[29];
583
+			$this->ship_to_zip_code = $this->_response_array[30];
584
+			$this->ship_to_country = $this->_response_array[31];
585
+			$this->tax = $this->_response_array[32];
586
+			$this->duty = $this->_response_array[33];
587
+			$this->freight = $this->_response_array[34];
588
+			$this->tax_exempt = $this->_response_array[35];
589
+			$this->purchase_order_number = $this->_response_array[36];
590
+			$this->md5_hash = $this->_response_array[37];
591
+			$this->card_code_response = $this->_response_array[38];
592
+			$this->cavv_response = $this->_response_array[39];
593
+			$this->account_number = $this->_response_array[50];
594
+			$this->card_type = $this->_response_array[51];
595
+			$this->split_tender_id = $this->_response_array[52];
596
+			$this->requested_amount = $this->_response_array[53];
597
+			$this->balance_on_card = $this->_response_array[54];
598
+
599
+			$this->approved = ($this->response_code === self::APPROVED);
600
+			$this->declined = ($this->response_code === self::DECLINED);
601
+			$this->error = ($this->response_code === self::ERROR);
602
+			$this->held = ($this->response_code === self::HELD);
603
+		} else {
604
+			$this->approved = false;
605
+			$this->error = true;
606
+			$this->error_message = esc_html__(
607
+				'Error connecting to Authorize.net',
608
+				'event_espresso'
609
+			);
610
+		}
611
+	}
612 612
 }
613 613
 
614 614
 if (! class_exists('AuthorizeNetException')) {
615
-    /**
616
-     * Class AuthorizeNetException
617
-     *
618
-     * @package    AuthorizeNet
619
-     */
620
-    class AuthorizeNetException extends Exception
621
-    {
622
-        /**
623
-         * Construct the exception. Note: The message is NOT binary safe.
624
-         *
625
-         * @link http://php.net/manual/en/exception.construct.php
626
-         * @param string $message [optional] The Exception message to throw.
627
-         * @param int $code [optional] The Exception code.
628
-         * @param Exception $previous [optional] The previous exception used for the exception chaining. Since 5.3.0
629
-         * @since 5.1.0
630
-         */
631
-        public function __construct($message = "", $code = 0, Exception $previous = null)
632
-        {
633
-            parent::__construct($message, $code, $previous);
634
-        }
635
-    }
615
+	/**
616
+	 * Class AuthorizeNetException
617
+	 *
618
+	 * @package    AuthorizeNet
619
+	 */
620
+	class AuthorizeNetException extends Exception
621
+	{
622
+		/**
623
+		 * Construct the exception. Note: The message is NOT binary safe.
624
+		 *
625
+		 * @link http://php.net/manual/en/exception.construct.php
626
+		 * @param string $message [optional] The Exception message to throw.
627
+		 * @param int $code [optional] The Exception code.
628
+		 * @param Exception $previous [optional] The previous exception used for the exception chaining. Since 5.3.0
629
+		 * @since 5.1.0
630
+		 */
631
+		public function __construct($message = "", $code = 0, Exception $previous = null)
632
+		{
633
+			parent::__construct($message, $code, $previous);
634
+		}
635
+	}
636 636
 }
Please login to merge, or discard this patch.
caffeinated/payment_methods/Aim/templates/aim_intro.template.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 printf(
4
-    esc_html__(
5
-        'Authorize.Net AIM is an on-site payment method for accepting credit and debit card payments and is available to event organizers in the United States, Canada, United Kingdom, and Australia. An account with Authorize.Net is required to accept payments. Need an Authorize.Net account? %1$sClick here to sign up for a merchant account%2$s.',
6
-        'event_espresso'
7
-    ),
8
-    '<a href="https://eventespresso.com/go/authorizenetaim/" target="_blank">',
9
-    '</a>'
4
+	esc_html__(
5
+		'Authorize.Net AIM is an on-site payment method for accepting credit and debit card payments and is available to event organizers in the United States, Canada, United Kingdom, and Australia. An account with Authorize.Net is required to accept payments. Need an Authorize.Net account? %1$sClick here to sign up for a merchant account%2$s.',
6
+		'event_espresso'
7
+	),
8
+	'<a href="https://eventespresso.com/go/authorizenetaim/" target="_blank">',
9
+	'</a>'
10 10
 );
Please login to merge, or discard this patch.
caffeinated/modules/recaptcha/autoload.php 2 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -7,33 +7,33 @@
 block discarded – undo
7 7
  */
8 8
 
9 9
 spl_autoload_register(function ($class) {
10
-    if (substr($class, 0, 10) !== 'ReCaptcha\\') {
11
-        /* If the class does not lie under the "ReCaptcha" namespace,
10
+	if (substr($class, 0, 10) !== 'ReCaptcha\\') {
11
+		/* If the class does not lie under the "ReCaptcha" namespace,
12 12
          * then we can exit immediately.
13 13
          */
14
-        return;
15
-    }
14
+		return;
15
+	}
16 16
 
17
-    /* All of the classes have names like "ReCaptcha\Foo", so we need
17
+	/* All of the classes have names like "ReCaptcha\Foo", so we need
18 18
      * to replace the backslashes with frontslashes if we want the
19 19
      * name to map directly to a location in the filesystem.
20 20
      */
21
-    $class = str_replace('\\', '/', $class);
21
+	$class = str_replace('\\', '/', $class);
22 22
 
23
-    /* First, check under the current directory. It is important that
23
+	/* First, check under the current directory. It is important that
24 24
      * we look here first, so that we don't waste time searching for
25 25
      * test classes in the common case.
26 26
      */
27
-    $path = dirname(__FILE__) . '/' . $class . '.php';
28
-    if (is_readable($path)) {
29
-        require_once $path;
30
-    }
27
+	$path = dirname(__FILE__) . '/' . $class . '.php';
28
+	if (is_readable($path)) {
29
+		require_once $path;
30
+	}
31 31
 
32
-    /* If we didn't find what we're looking for already, maybe it's
32
+	/* If we didn't find what we're looking for already, maybe it's
33 33
      * a test class?
34 34
      */
35
-    $path = dirname(__FILE__) . '/../tests/' . $class . '.php';
36
-    if (is_readable($path)) {
37
-        require_once $path;
38
-    }
35
+	$path = dirname(__FILE__) . '/../tests/' . $class . '.php';
36
+	if (is_readable($path)) {
37
+		require_once $path;
38
+	}
39 39
 });
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * classes.
7 7
  */
8 8
 
9
-spl_autoload_register(function ($class) {
9
+spl_autoload_register(function($class) {
10 10
     if (substr($class, 0, 10) !== 'ReCaptcha\\') {
11 11
         /* If the class does not lie under the "ReCaptcha" namespace,
12 12
          * then we can exit immediately.
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
      * we look here first, so that we don't waste time searching for
25 25
      * test classes in the common case.
26 26
      */
27
-    $path = dirname(__FILE__) . '/' . $class . '.php';
27
+    $path = dirname(__FILE__).'/'.$class.'.php';
28 28
     if (is_readable($path)) {
29 29
         require_once $path;
30 30
     }
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
     /* If we didn't find what we're looking for already, maybe it's
33 33
      * a test class?
34 34
      */
35
-    $path = dirname(__FILE__) . '/../tests/' . $class . '.php';
35
+    $path = dirname(__FILE__).'/../tests/'.$class.'.php';
36 36
     if (is_readable($path)) {
37 37
         require_once $path;
38 38
     }
Please login to merge, or discard this patch.
core/libraries/rest_api/changes/ChangesIn40834.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -12,39 +12,39 @@
 block discarded – undo
12 12
 class ChangesIn40834 extends ChangesInBase
13 13
 {
14 14
 
15
-    /**
16
-     * Adds hooks so requests to 4.8.29 don't have the checkin endpoints
17
-     */
18
-    public function setHooks()
19
-    {
20
-        // set a hook to remove the checkout/checkout endpoints if the request
21
-        // is for lower than 4.8.33
22
-        add_filter(
23
-            'FHEE__EventEspresso\core\libraries\rest_api\controllers\Base___get_response_headers',
24
-            array($this, 'removeResponseHeaders'),
25
-            10,
26
-            3
27
-        );
28
-    }
15
+	/**
16
+	 * Adds hooks so requests to 4.8.29 don't have the checkin endpoints
17
+	 */
18
+	public function setHooks()
19
+	{
20
+		// set a hook to remove the checkout/checkout endpoints if the request
21
+		// is for lower than 4.8.33
22
+		add_filter(
23
+			'FHEE__EventEspresso\core\libraries\rest_api\controllers\Base___get_response_headers',
24
+			array($this, 'removeResponseHeaders'),
25
+			10,
26
+			3
27
+		);
28
+	}
29 29
 
30 30
 
31
-    /**
32
-     * Removes the checkin and checkout endpoints from the index for requests
33
-     * to api versions lowers than 4.8.33
34
-     *
35
-     * @param array  $response_headers
36
-     * @param Base   $controller
37
-     * @param string $requested_version
38
-     * @return array like $routes_on_this_version
39
-     */
40
-    public function removeResponseHeaders($response_headers, $controller, $requested_version)
41
-    {
42
-        if (
43
-            $controller instanceof Base
44
-            && $this->appliesToVersion($requested_version)
45
-        ) {
46
-            return array();
47
-        }
48
-        return $response_headers;
49
-    }
31
+	/**
32
+	 * Removes the checkin and checkout endpoints from the index for requests
33
+	 * to api versions lowers than 4.8.33
34
+	 *
35
+	 * @param array  $response_headers
36
+	 * @param Base   $controller
37
+	 * @param string $requested_version
38
+	 * @return array like $routes_on_this_version
39
+	 */
40
+	public function removeResponseHeaders($response_headers, $controller, $requested_version)
41
+	{
42
+		if (
43
+			$controller instanceof Base
44
+			&& $this->appliesToVersion($requested_version)
45
+		) {
46
+			return array();
47
+		}
48
+		return $response_headers;
49
+	}
50 50
 }
Please login to merge, or discard this patch.
core/libraries/messages/EE_Messages_Base.lib.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -196,11 +196,11 @@  discard block
 block discarded – undo
196 196
             ! empty($messenger)
197 197
             && $Message_Resource_Manager->is_message_type_active_for_messenger($messenger, $this->name)
198 198
         ) {
199
-            $settings_to_use = $active_messengers[ $messenger ]['settings'][ $messenger . '-message_types' ];
199
+            $settings_to_use = $active_messengers[$messenger]['settings'][$messenger.'-message_types'];
200 200
         }
201 201
 
202
-        $this->_existing_admin_settings = isset($settings_to_use[ $this->name ]['settings'])
203
-            ? $settings_to_use[ $this->name ]['settings']
202
+        $this->_existing_admin_settings = isset($settings_to_use[$this->name]['settings'])
203
+            ? $settings_to_use[$this->name]['settings']
204 204
             : null;
205 205
     }
206 206
 
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
     public function get_valid_shortcodes()
241 241
     {
242 242
         $valid_shortcodes = apply_filters(
243
-            'FHEE__' . get_class($this) . '__get_valid_shortcodes',
243
+            'FHEE__'.get_class($this).'__get_valid_shortcodes',
244 244
             $this->_valid_shortcodes,
245 245
             $this
246 246
         );
@@ -283,19 +283,19 @@  discard block
 block discarded – undo
283 283
     protected function _get_admin_page_content($page, $action, $extra, $actives)
284 284
     {
285 285
         // we can also further refine the context by action (if present).
286
-        if (!empty($action)) {
287
-            $page = $page . '_' . $action;
286
+        if ( ! empty($action)) {
287
+            $page = $page.'_'.$action;
288 288
         }
289 289
 
290
-        if (!isset($this->admin_registered_pages[ $page ])) {
290
+        if ( ! isset($this->admin_registered_pages[$page])) {
291 291
             // todo: a place to throw an exception?
292 292
             // We need to indicate there is no registered page so this function is not being called correctly.
293 293
             return false;
294 294
         }
295 295
         // k made it here so let's call the method
296 296
         $content = call_user_func_array(
297
-            array( $this, '_get_admin_content_' . $page ),
298
-            array( $actives, $extra )
297
+            array($this, '_get_admin_content_'.$page),
298
+            array($actives, $extra)
299 299
         );
300 300
         if ($content === false) {
301 301
             // todo this needs to be an exception once we've got exceptions in place.
Please login to merge, or discard this patch.
Indentation   +265 added lines, -265 removed lines patch added patch discarded remove patch
@@ -13,44 +13,44 @@  discard block
 block discarded – undo
13 13
  */
14 14
 abstract class EE_Messages_Base extends EE_Base
15 15
 {
16
-    /** DETAILS PROPERTIES **/
17
-    /**
18
-     * The following are used to hold details on the type for reference (i.e. on admin screens)
19
-     * and also used by the EE_message_type object to figure out where to get template data.
20
-     */
21
-    public $name;
22
-    public $description;
23
-    protected $_messages_item_type; // messenger OR message_type?
24
-
25
-
26
-    /**
27
-     * This is an array describing the ui facing labels
28
-     * that will be used whenever the messenger is referenced in the ui
29
-     *
30
-     * array(
31
-     *  'singular' => esc_html__('something'),
32
-     *  'plural' => esc_html__('somethings')
33
-     * )
34
-     *
35
-     * @var array
36
-     */
37
-    public $label;
38
-
39
-
40
-
41
-
42
-    /**
43
-     * This property when set will hold the slugs of all EE admin pages that we will need to retrieve fields for
44
-     * (and used to determine which callback method to call from the child class)
45
-     *
46
-     * structure should be
47
-     * array(
48
-     * 'page_action' => true
49
-     * )
50
-     *
16
+	/** DETAILS PROPERTIES **/
17
+	/**
18
+	 * The following are used to hold details on the type for reference (i.e. on admin screens)
19
+	 * and also used by the EE_message_type object to figure out where to get template data.
20
+	 */
21
+	public $name;
22
+	public $description;
23
+	protected $_messages_item_type; // messenger OR message_type?
24
+
25
+
26
+	/**
27
+	 * This is an array describing the ui facing labels
28
+	 * that will be used whenever the messenger is referenced in the ui
29
+	 *
30
+	 * array(
31
+	 *  'singular' => esc_html__('something'),
32
+	 *  'plural' => esc_html__('somethings')
33
+	 * )
34
+	 *
35
+	 * @var array
36
+	 */
37
+	public $label;
38
+
39
+
40
+
41
+
42
+	/**
43
+	 * This property when set will hold the slugs of all EE admin pages that we will need to retrieve fields for
44
+	 * (and used to determine which callback method to call from the child class)
45
+	 *
46
+	 * structure should be
47
+	 * array(
48
+	 * 'page_action' => true
49
+	 * )
50
+	 *
51 51
 *@var array
52
-     */
53
-    public $admin_registered_pages = array();
52
+	 */
53
+	public $admin_registered_pages = array();
54 54
 
55 55
 
56 56
 
@@ -59,265 +59,265 @@  discard block
 block discarded – undo
59 59
 
60 60
 
61 61
 
62
-    /**
63
-     * this property holds any specific fields for holding any settings related to a messenger (if any needed)
64
-     * @var array
65
-     */
66
-    protected $_admin_settings_fields = array();
62
+	/**
63
+	 * this property holds any specific fields for holding any settings related to a messenger (if any needed)
64
+	 * @var array
65
+	 */
66
+	protected $_admin_settings_fields = array();
67 67
 
68 68
 
69 69
 
70 70
 
71 71
 
72
-    /**
73
-     * this property will hold any existing settings that may have been set in the admin.
74
-     * @var array
75
-     */
76
-    protected $_existing_admin_settings = array();
72
+	/**
73
+	 * this property will hold any existing settings that may have been set in the admin.
74
+	 * @var array
75
+	 */
76
+	protected $_existing_admin_settings = array();
77 77
 
78 78
 
79 79
 
80 80
 
81 81
 
82
-    /**
83
-     * this property will hold an array of valid shortcodes for this message type and messengers.
84
-     * #For Message Types:
85
-     * This is an array of strings that correspond to defined EE_Shortcode libraries and per context.
86
-     * For example:
87
-     * array( 'admin' => array('transaction', 'event', 'attendee') )
88
-     * corresponds to 'EE_Transaction_Shortcodes.lib.php, EE_Event_Shortcodes.lib.php, EE_Attendee_Shortcodes.lib.php'
89
-     * for the admin context;
90
-     *
91
-     *
92
-     * #For Messengers:
93
-     * For example:
94
-     * array('subject' => array('transaction', 'event', 'attendee'))
95
-     * corresponds to 'EE_Transaction_Shortcodes.lib.php, EE_Event_Shortcodes.lib.php, EE_Attendee_Shortcodes.lib.php'
96
-     * for the 'subject' field;
97
-     * NOTE:  by default, with messengers, if the valid shortcodes for a field is left blank,
98
-     * that field will inherit whatever are set as valid shortcodes by message_type.
99
-     * This is so messenger can set specific valid codes for fields and leave other
100
-     * valid shortcodes up to the message type matched with the messenger.
101
-     *
102
-     * @access protected
103
-     * @var array
104
-     */
105
-    protected $_valid_shortcodes = array();
82
+	/**
83
+	 * this property will hold an array of valid shortcodes for this message type and messengers.
84
+	 * #For Message Types:
85
+	 * This is an array of strings that correspond to defined EE_Shortcode libraries and per context.
86
+	 * For example:
87
+	 * array( 'admin' => array('transaction', 'event', 'attendee') )
88
+	 * corresponds to 'EE_Transaction_Shortcodes.lib.php, EE_Event_Shortcodes.lib.php, EE_Attendee_Shortcodes.lib.php'
89
+	 * for the admin context;
90
+	 *
91
+	 *
92
+	 * #For Messengers:
93
+	 * For example:
94
+	 * array('subject' => array('transaction', 'event', 'attendee'))
95
+	 * corresponds to 'EE_Transaction_Shortcodes.lib.php, EE_Event_Shortcodes.lib.php, EE_Attendee_Shortcodes.lib.php'
96
+	 * for the 'subject' field;
97
+	 * NOTE:  by default, with messengers, if the valid shortcodes for a field is left blank,
98
+	 * that field will inherit whatever are set as valid shortcodes by message_type.
99
+	 * This is so messenger can set specific valid codes for fields and leave other
100
+	 * valid shortcodes up to the message type matched with the messenger.
101
+	 *
102
+	 * @access protected
103
+	 * @var array
104
+	 */
105
+	protected $_valid_shortcodes = array();
106 106
 
107 107
 
108 108
 
109 109
 
110 110
 
111
-    public function __construct()
112
-    {
113
-        $this->_set_admin_settings_fields();
114
-        $this->_set_valid_shortcodes();
115
-        $this->_set_admin_pages();
116
-    }
111
+	public function __construct()
112
+	{
113
+		$this->_set_admin_settings_fields();
114
+		$this->_set_valid_shortcodes();
115
+		$this->_set_admin_pages();
116
+	}
117 117
 
118 118
 
119 119
 
120 120
 
121 121
 
122
-    /**
123
-     * sets the _admin_settings_fields property which needs to be defined by child classes.
124
-     * You will want to set the _admin_settings_fields properties as a multi-dimensional array with the following format
125
-     * array(
126
-     *      {field_name - also used for setting index} => array(
127
-     *          'field_type' => {type of field: 'text', 'textarea', 'checkbox'},
128
-     *          'value_type' => {type of value: 'string', 'int', 'array', 'bool'},
129
-     *          'required' => {bool, required or not},
130
-     *          'validation' => {bool, true if we want validation, false if not},
131
-     *          'format' => {%d, or %s},
132
-     *          'label' => {label for the field, make sure it's localized},
133
-     *          'default' => {default value for the setting}
134
-     *      ),
135
-     * );
136
-     *
137
-     * @abstract
138
-     * @access protected
139
-     * @return void
140
-     */
141
-    abstract protected function _set_admin_settings_fields();
122
+	/**
123
+	 * sets the _admin_settings_fields property which needs to be defined by child classes.
124
+	 * You will want to set the _admin_settings_fields properties as a multi-dimensional array with the following format
125
+	 * array(
126
+	 *      {field_name - also used for setting index} => array(
127
+	 *          'field_type' => {type of field: 'text', 'textarea', 'checkbox'},
128
+	 *          'value_type' => {type of value: 'string', 'int', 'array', 'bool'},
129
+	 *          'required' => {bool, required or not},
130
+	 *          'validation' => {bool, true if we want validation, false if not},
131
+	 *          'format' => {%d, or %s},
132
+	 *          'label' => {label for the field, make sure it's localized},
133
+	 *          'default' => {default value for the setting}
134
+	 *      ),
135
+	 * );
136
+	 *
137
+	 * @abstract
138
+	 * @access protected
139
+	 * @return void
140
+	 */
141
+	abstract protected function _set_admin_settings_fields();
142 142
 
143 143
 
144 144
 
145 145
 
146 146
 
147
-    /**
148
-     * sets any properties on whether a message type or messenger interface shows up on a ee administration page.
149
-     * Child classes have to define this method but don't necessarily have to set the flags
150
-     * as they will be set to false by default.
151
-     *
152
-     * Child classes use this method to set the `_admin_registered_page` property.
153
-     * That property is to indicate what EE admin pages we have a corresponding callback for in the child class
154
-     * so Message Type/messenger fields/content is included on that admin page.
155
-     *
156
-     * @abstract
157
-     * @access protected
158
-     * @return void
159
-     */
160
-    abstract protected function _set_admin_pages();
147
+	/**
148
+	 * sets any properties on whether a message type or messenger interface shows up on a ee administration page.
149
+	 * Child classes have to define this method but don't necessarily have to set the flags
150
+	 * as they will be set to false by default.
151
+	 *
152
+	 * Child classes use this method to set the `_admin_registered_page` property.
153
+	 * That property is to indicate what EE admin pages we have a corresponding callback for in the child class
154
+	 * so Message Type/messenger fields/content is included on that admin page.
155
+	 *
156
+	 * @abstract
157
+	 * @access protected
158
+	 * @return void
159
+	 */
160
+	abstract protected function _set_admin_pages();
161 161
 
162 162
 
163 163
 
164 164
 
165 165
 
166
-    /**
167
-     * Child classes must declare the $_valid_shortcodes property using this method.
168
-     * See comments for $_valid_shortcodes property for details on what it is used for.
169
-     *
170
-     * @access protected
171
-     * @return void
172
-     */
173
-    abstract protected function _set_valid_shortcodes();
166
+	/**
167
+	 * Child classes must declare the $_valid_shortcodes property using this method.
168
+	 * See comments for $_valid_shortcodes property for details on what it is used for.
169
+	 *
170
+	 * @access protected
171
+	 * @return void
172
+	 */
173
+	abstract protected function _set_valid_shortcodes();
174 174
 
175 175
 
176 176
 
177
-    /**
178
-     * sets the _existing_admin_settings property can be overridden by child classes.
179
-     * We do this so we only do database calls if needed.
180
-     *
181
-     * @access protected
182
-     * @param string $messenger
183
-     */
184
-    protected function _set_existing_admin_settings($messenger = '')
185
-    {
186
-        /** @var EE_Message_Resource_Manager $Message_Resource_Manager */
187
-        $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
188
-        $active_messengers = $Message_Resource_Manager->get_active_messengers_option();
189
-        $settings_to_use = $active_messengers;
190
-
191
-        /**
192
-         * This determines what will be used for the getting the settings.
193
-         */
194
-        if (
195
-            ! empty($messenger)
196
-            && $Message_Resource_Manager->is_message_type_active_for_messenger($messenger, $this->name)
197
-        ) {
198
-            $settings_to_use = $active_messengers[ $messenger ]['settings'][ $messenger . '-message_types' ];
199
-        }
200
-
201
-        $this->_existing_admin_settings = isset($settings_to_use[ $this->name ]['settings'])
202
-            ? $settings_to_use[ $this->name ]['settings']
203
-            : null;
204
-    }
205
-
206
-
207
-
208
-
209
-
210
-
211
-    /**
212
-     * get_existing_admin_settings
213
-     * (if needed) sets and returns the _existing_admin_settings property.
214
-     *
215
-     * @access public
216
-     * @param string $messenger
217
-     * @return array          settings
218
-     */
219
-    public function get_existing_admin_settings($messenger = '')
220
-    {
221
-        // if admin_settings property empty lets try setting it.
222
-        if (method_exists($this, '_set_existing_admin_settings') && empty($this->_existing_admin_settings)) {
223
-            $this->_set_existing_admin_settings($messenger);
224
-        }
225
-        return property_exists($this, '_existing_admin_settings')
226
-            ? $this->_existing_admin_settings
227
-            : null;
228
-    }
229
-
230
-
231
-
232
-
233
-
234
-
235
-    /**
236
-     * This returns the array of valid shortcodes for a message type or messenger as set by the child in the $_valid_shortcode property.
237
-     * @return array   an array of valid shortcodes.
238
-     */
239
-    public function get_valid_shortcodes()
240
-    {
241
-        $valid_shortcodes = apply_filters(
242
-            'FHEE__' . get_class($this) . '__get_valid_shortcodes',
243
-            $this->_valid_shortcodes,
244
-            $this
245
-        );
246
-        // The below filter applies to ALL messengers and message types so use with care!
247
-        $valid_shortcodes = apply_filters('FHEE__EE_Messages_Base__get_valid_shortcodes', $valid_shortcodes, $this);
248
-        return $valid_shortcodes;
249
-    }
250
-
251
-
252
-
253
-
254
-    /**
255
-     * getter that returns the protected admin_settings_fields property
256
-     *
257
-     * @access public
258
-     * @return array admin settings fields
259
-     */
260
-    public function get_admin_settings_fields()
261
-    {
262
-        return $this->_admin_settings_fields;
263
-    }
264
-
265
-
266
-
267
-
268
-
269
-    /**
270
-     * this public method accepts a page slug (for an EE_admin page)
271
-     * and will return the response from the child class callback function
272
-     * if that page is registered via the `_admin_registered_page` property set by the child class.
273
-     *
274
-     * @param string $page the slug of the EE admin page
275
-     * @param array $actives an array of active message type (or messenger) objects.
276
-     * @param string $action the page action (to allow for more specific handling - i.e. edit vs. add pages)
277
-     * @param array $extra This is just an extra argument that can be used
278
-     *                     to pass additional data for setting up page content.
279
-     * @access protected
280
-     * @return string $content for page.
281
-     */
282
-    protected function _get_admin_page_content($page, $action, $extra, $actives)
283
-    {
284
-        // we can also further refine the context by action (if present).
285
-        if (!empty($action)) {
286
-            $page = $page . '_' . $action;
287
-        }
288
-
289
-        if (!isset($this->admin_registered_pages[ $page ])) {
290
-            // todo: a place to throw an exception?
291
-            // We need to indicate there is no registered page so this function is not being called correctly.
292
-            return false;
293
-        }
294
-        // k made it here so let's call the method
295
-        $content = call_user_func_array(
296
-            array( $this, '_get_admin_content_' . $page ),
297
-            array( $actives, $extra )
298
-        );
299
-        if ($content === false) {
300
-            // todo this needs to be an exception once we've got exceptions in place.
301
-            return false;
302
-        }
303
-        return $content;
304
-    }
305
-
306
-
307
-    /**
308
-     * Allows a message type to specifically exclude template fields for the provided messenger.
309
-     * Filtered so this can be programmatically altered as well.
310
-     * @param string $messenger_name name of messenger
311
-     * @return array
312
-     */
313
-    public function excludedFieldsForMessenger($messenger_name)
314
-    {
315
-        return apply_filters(
316
-            'FHEE__EE_Messages_Base__excludedFieldForMessenger',
317
-            array(),
318
-            $messenger_name,
319
-            $this->name,
320
-            $this
321
-        );
322
-    }
177
+	/**
178
+	 * sets the _existing_admin_settings property can be overridden by child classes.
179
+	 * We do this so we only do database calls if needed.
180
+	 *
181
+	 * @access protected
182
+	 * @param string $messenger
183
+	 */
184
+	protected function _set_existing_admin_settings($messenger = '')
185
+	{
186
+		/** @var EE_Message_Resource_Manager $Message_Resource_Manager */
187
+		$Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
188
+		$active_messengers = $Message_Resource_Manager->get_active_messengers_option();
189
+		$settings_to_use = $active_messengers;
190
+
191
+		/**
192
+		 * This determines what will be used for the getting the settings.
193
+		 */
194
+		if (
195
+			! empty($messenger)
196
+			&& $Message_Resource_Manager->is_message_type_active_for_messenger($messenger, $this->name)
197
+		) {
198
+			$settings_to_use = $active_messengers[ $messenger ]['settings'][ $messenger . '-message_types' ];
199
+		}
200
+
201
+		$this->_existing_admin_settings = isset($settings_to_use[ $this->name ]['settings'])
202
+			? $settings_to_use[ $this->name ]['settings']
203
+			: null;
204
+	}
205
+
206
+
207
+
208
+
209
+
210
+
211
+	/**
212
+	 * get_existing_admin_settings
213
+	 * (if needed) sets and returns the _existing_admin_settings property.
214
+	 *
215
+	 * @access public
216
+	 * @param string $messenger
217
+	 * @return array          settings
218
+	 */
219
+	public function get_existing_admin_settings($messenger = '')
220
+	{
221
+		// if admin_settings property empty lets try setting it.
222
+		if (method_exists($this, '_set_existing_admin_settings') && empty($this->_existing_admin_settings)) {
223
+			$this->_set_existing_admin_settings($messenger);
224
+		}
225
+		return property_exists($this, '_existing_admin_settings')
226
+			? $this->_existing_admin_settings
227
+			: null;
228
+	}
229
+
230
+
231
+
232
+
233
+
234
+
235
+	/**
236
+	 * This returns the array of valid shortcodes for a message type or messenger as set by the child in the $_valid_shortcode property.
237
+	 * @return array   an array of valid shortcodes.
238
+	 */
239
+	public function get_valid_shortcodes()
240
+	{
241
+		$valid_shortcodes = apply_filters(
242
+			'FHEE__' . get_class($this) . '__get_valid_shortcodes',
243
+			$this->_valid_shortcodes,
244
+			$this
245
+		);
246
+		// The below filter applies to ALL messengers and message types so use with care!
247
+		$valid_shortcodes = apply_filters('FHEE__EE_Messages_Base__get_valid_shortcodes', $valid_shortcodes, $this);
248
+		return $valid_shortcodes;
249
+	}
250
+
251
+
252
+
253
+
254
+	/**
255
+	 * getter that returns the protected admin_settings_fields property
256
+	 *
257
+	 * @access public
258
+	 * @return array admin settings fields
259
+	 */
260
+	public function get_admin_settings_fields()
261
+	{
262
+		return $this->_admin_settings_fields;
263
+	}
264
+
265
+
266
+
267
+
268
+
269
+	/**
270
+	 * this public method accepts a page slug (for an EE_admin page)
271
+	 * and will return the response from the child class callback function
272
+	 * if that page is registered via the `_admin_registered_page` property set by the child class.
273
+	 *
274
+	 * @param string $page the slug of the EE admin page
275
+	 * @param array $actives an array of active message type (or messenger) objects.
276
+	 * @param string $action the page action (to allow for more specific handling - i.e. edit vs. add pages)
277
+	 * @param array $extra This is just an extra argument that can be used
278
+	 *                     to pass additional data for setting up page content.
279
+	 * @access protected
280
+	 * @return string $content for page.
281
+	 */
282
+	protected function _get_admin_page_content($page, $action, $extra, $actives)
283
+	{
284
+		// we can also further refine the context by action (if present).
285
+		if (!empty($action)) {
286
+			$page = $page . '_' . $action;
287
+		}
288
+
289
+		if (!isset($this->admin_registered_pages[ $page ])) {
290
+			// todo: a place to throw an exception?
291
+			// We need to indicate there is no registered page so this function is not being called correctly.
292
+			return false;
293
+		}
294
+		// k made it here so let's call the method
295
+		$content = call_user_func_array(
296
+			array( $this, '_get_admin_content_' . $page ),
297
+			array( $actives, $extra )
298
+		);
299
+		if ($content === false) {
300
+			// todo this needs to be an exception once we've got exceptions in place.
301
+			return false;
302
+		}
303
+		return $content;
304
+	}
305
+
306
+
307
+	/**
308
+	 * Allows a message type to specifically exclude template fields for the provided messenger.
309
+	 * Filtered so this can be programmatically altered as well.
310
+	 * @param string $messenger_name name of messenger
311
+	 * @return array
312
+	 */
313
+	public function excludedFieldsForMessenger($messenger_name)
314
+	{
315
+		return apply_filters(
316
+			'FHEE__EE_Messages_Base__excludedFieldForMessenger',
317
+			array(),
318
+			$messenger_name,
319
+			$this->name,
320
+			$this
321
+		);
322
+	}
323 323
 }
Please login to merge, or discard this patch.