Completed
Branch 973/fix-visible-recaptcha (0580c7)
by
unknown
03:03 queued 30s
created
admin/extend/messages/Custom_Messages_Template_List_Table.class.php 2 patches
Indentation   +232 added lines, -232 removed lines patch added patch discarded remove patch
@@ -12,259 +12,259 @@
 block discarded – undo
12 12
 class Custom_Messages_Template_List_Table extends Messages_Template_List_Table
13 13
 {
14 14
 
15
-    /**
16
-     * Setup initial data.
17
-     */
18
-    protected function _setup_data()
19
-    {
20
-        $this->_data = $this->get_admin_page()->get_message_templates(
21
-            $this->_per_page,
22
-            $this->_view,
23
-            false,
24
-            false,
25
-            false
26
-        );
27
-        $this->_all_data_count = $this->get_admin_page()->get_message_templates(
28
-            $this->_per_page,
29
-            $this->_view,
30
-            true,
31
-            true,
32
-            false
33
-        );
34
-    }
15
+	/**
16
+	 * Setup initial data.
17
+	 */
18
+	protected function _setup_data()
19
+	{
20
+		$this->_data = $this->get_admin_page()->get_message_templates(
21
+			$this->_per_page,
22
+			$this->_view,
23
+			false,
24
+			false,
25
+			false
26
+		);
27
+		$this->_all_data_count = $this->get_admin_page()->get_message_templates(
28
+			$this->_per_page,
29
+			$this->_view,
30
+			true,
31
+			true,
32
+			false
33
+		);
34
+	}
35 35
 
36 36
 
37
-    /**
38
-     * Set initial properties
39
-     */
40
-    protected function _set_properties()
41
-    {
42
-        parent::_set_properties();
43
-        $this->_wp_list_args = array(
44
-            'singular' => esc_html__('Message Template Group', 'event_espresso'),
45
-            'plural'   => esc_html__('Message Template', 'event_espresso'),
46
-            'ajax'     => true, // for now,
47
-            'screen'   => $this->get_admin_page()->get_current_screen()->id,
48
-        );
37
+	/**
38
+	 * Set initial properties
39
+	 */
40
+	protected function _set_properties()
41
+	{
42
+		parent::_set_properties();
43
+		$this->_wp_list_args = array(
44
+			'singular' => esc_html__('Message Template Group', 'event_espresso'),
45
+			'plural'   => esc_html__('Message Template', 'event_espresso'),
46
+			'ajax'     => true, // for now,
47
+			'screen'   => $this->get_admin_page()->get_current_screen()->id,
48
+		);
49 49
 
50
-        $this->_columns = array_merge(
51
-            array(
52
-                'cb'   => '<input type="checkbox" />',
53
-                'name' => esc_html__('Template Name', 'event_espresso'),
54
-            ),
55
-            $this->_columns,
56
-            array(
57
-                'events'  => esc_html__('Events', 'event_espresso'),
58
-                'actions' => '',
59
-            )
60
-        );
61
-    }
50
+		$this->_columns = array_merge(
51
+			array(
52
+				'cb'   => '<input type="checkbox" />',
53
+				'name' => esc_html__('Template Name', 'event_espresso'),
54
+			),
55
+			$this->_columns,
56
+			array(
57
+				'events'  => esc_html__('Events', 'event_espresso'),
58
+				'actions' => '',
59
+			)
60
+		);
61
+	}
62 62
 
63 63
 
64
-    /**
65
-     * Custom message for when there are no items found.
66
-     *
67
-     * @since 4.3.0
68
-     */
69
-    public function no_items()
70
-    {
71
-        if ($this->_view !== 'trashed') {
72
-            printf(
73
-                esc_html__(
74
-                    '%sNo Custom Templates found.%s To create your first custom message template, go to the "Default Message Templates" tab and click the "Create Custom" button next to the template you want to use as a base for the new one.',
75
-                    'event_espresso'
76
-                ),
77
-                '<strong>',
78
-                '</strong>'
79
-            );
80
-        } else {
81
-            parent::no_items();
82
-        }
83
-    }
64
+	/**
65
+	 * Custom message for when there are no items found.
66
+	 *
67
+	 * @since 4.3.0
68
+	 */
69
+	public function no_items()
70
+	{
71
+		if ($this->_view !== 'trashed') {
72
+			printf(
73
+				esc_html__(
74
+					'%sNo Custom Templates found.%s To create your first custom message template, go to the "Default Message Templates" tab and click the "Create Custom" button next to the template you want to use as a base for the new one.',
75
+					'event_espresso'
76
+				),
77
+				'<strong>',
78
+				'</strong>'
79
+			);
80
+		} else {
81
+			parent::no_items();
82
+		}
83
+	}
84 84
 
85 85
 
86
-    /**
87
-     * @param EE_Message_Template_Group $item
88
-     * @return string
89
-     */
90
-    public function column_cb($item)
91
-    {
92
-        return sprintf('<input type="checkbox" name="checkbox[%s]" value="1" />', $item->GRP_ID());
93
-    }
86
+	/**
87
+	 * @param EE_Message_Template_Group $item
88
+	 * @return string
89
+	 */
90
+	public function column_cb($item)
91
+	{
92
+		return sprintf('<input type="checkbox" name="checkbox[%s]" value="1" />', $item->GRP_ID());
93
+	}
94 94
 
95 95
 
96
-    /**
97
-     * @param EE_Message_Template_Group $item
98
-     * @return string
99
-     */
100
-    public function column_name($item)
101
-    {
102
-        return '<p>' . $item->name() . '</p>';
103
-    }
96
+	/**
97
+	 * @param EE_Message_Template_Group $item
98
+	 * @return string
99
+	 */
100
+	public function column_name($item)
101
+	{
102
+		return '<p>' . $item->name() . '</p>';
103
+	}
104 104
 
105 105
 
106
-    /**
107
-     * @param EE_Message_Template_Group $item
108
-     * @return string
109
-     */
110
-    public function column_actions($item)
111
-    {
112
-        if (
113
-            EE_Registry::instance()->CAP->current_user_can(
114
-                'ee_edit_messages',
115
-                'espresso_messages_add_new_message_template'
116
-            )
117
-        ) {
118
-            $create_args = array(
119
-                'GRP_ID'       => $item->ID(),
120
-                'messenger'    => $item->messenger(),
121
-                'message_type' => $item->message_type(),
122
-                'action'       => 'add_new_message_template',
123
-            );
124
-            $create_link = EE_Admin_Page::add_query_args_and_nonce($create_args, EE_MSG_ADMIN_URL);
125
-            return sprintf(
126
-                '<p><a href="%s" class="button button-small">%s</a></p>',
127
-                $create_link,
128
-                esc_html__('Create Custom', 'event_espresso')
129
-            );
130
-        }
131
-        return '';
132
-    }
106
+	/**
107
+	 * @param EE_Message_Template_Group $item
108
+	 * @return string
109
+	 */
110
+	public function column_actions($item)
111
+	{
112
+		if (
113
+			EE_Registry::instance()->CAP->current_user_can(
114
+				'ee_edit_messages',
115
+				'espresso_messages_add_new_message_template'
116
+			)
117
+		) {
118
+			$create_args = array(
119
+				'GRP_ID'       => $item->ID(),
120
+				'messenger'    => $item->messenger(),
121
+				'message_type' => $item->message_type(),
122
+				'action'       => 'add_new_message_template',
123
+			);
124
+			$create_link = EE_Admin_Page::add_query_args_and_nonce($create_args, EE_MSG_ADMIN_URL);
125
+			return sprintf(
126
+				'<p><a href="%s" class="button button-small">%s</a></p>',
127
+				$create_link,
128
+				esc_html__('Create Custom', 'event_espresso')
129
+			);
130
+		}
131
+		return '';
132
+	}
133 133
 
134
-    /**
135
-     * Set the view counts on the _views property
136
-     */
137
-    protected function _add_view_counts()
138
-    {
139
-        foreach ($this->_views as $view => $args) {
140
-            $this->_views[ $view ]['count'] = $this->get_admin_page()->get_message_templates(
141
-                $this->_per_page,
142
-                $view,
143
-                true,
144
-                true,
145
-                false
146
-            );
147
-        }
148
-    }
134
+	/**
135
+	 * Set the view counts on the _views property
136
+	 */
137
+	protected function _add_view_counts()
138
+	{
139
+		foreach ($this->_views as $view => $args) {
140
+			$this->_views[ $view ]['count'] = $this->get_admin_page()->get_message_templates(
141
+				$this->_per_page,
142
+				$view,
143
+				true,
144
+				true,
145
+				false
146
+			);
147
+		}
148
+	}
149 149
 
150 150
 
151
-    /**
152
-     * column_events
153
-     * This provides a count of events using this custom template
154
-     *
155
-     * @param  EE_Message_Template_Group $item message_template group data
156
-     * @return string column output
157
-     */
158
-    public function column_events($item)
159
-    {
160
-        return $item->count_events();
161
-    }
151
+	/**
152
+	 * column_events
153
+	 * This provides a count of events using this custom template
154
+	 *
155
+	 * @param  EE_Message_Template_Group $item message_template group data
156
+	 * @return string column output
157
+	 */
158
+	public function column_events($item)
159
+	{
160
+		return $item->count_events();
161
+	}
162 162
 
163 163
 
164
-    /**
165
-     * Add additional actions for custom message template list view.
166
-     *
167
-     * @param EE_Message_Template_Group $item
168
-     * @return array
169
-     * @throws EE_Error
170
-     */
171
-    protected function _get_actions_for_messenger_column(EE_Message_Template_Group $item)
172
-    {
173
-        $actions = parent::_get_actions_for_messenger_column($item);
164
+	/**
165
+	 * Add additional actions for custom message template list view.
166
+	 *
167
+	 * @param EE_Message_Template_Group $item
168
+	 * @return array
169
+	 * @throws EE_Error
170
+	 */
171
+	protected function _get_actions_for_messenger_column(EE_Message_Template_Group $item)
172
+	{
173
+		$actions = parent::_get_actions_for_messenger_column($item);
174 174
 
175
-        // add additional actions for trash/restore etc.
176
-        $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
177
-            'action'   => 'trash_message_template',
178
-            'id'       => $item->GRP_ID(),
179
-            'noheader' => true,
180
-        ), EE_MSG_ADMIN_URL);
181
-        // restore link
182
-        $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
183
-            'action'   => 'restore_message_template',
184
-            'id'       => $item->GRP_ID(),
185
-            'noheader' => true,
186
-        ), EE_MSG_ADMIN_URL);
187
-        // delete price link
188
-        $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
189
-            'action'   => 'delete_message_template',
190
-            'id'       => $item->GRP_ID(),
191
-            'noheader' => true,
192
-        ), EE_MSG_ADMIN_URL);
175
+		// add additional actions for trash/restore etc.
176
+		$trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
177
+			'action'   => 'trash_message_template',
178
+			'id'       => $item->GRP_ID(),
179
+			'noheader' => true,
180
+		), EE_MSG_ADMIN_URL);
181
+		// restore link
182
+		$restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
183
+			'action'   => 'restore_message_template',
184
+			'id'       => $item->GRP_ID(),
185
+			'noheader' => true,
186
+		), EE_MSG_ADMIN_URL);
187
+		// delete price link
188
+		$delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
189
+			'action'   => 'delete_message_template',
190
+			'id'       => $item->GRP_ID(),
191
+			'noheader' => true,
192
+		), EE_MSG_ADMIN_URL);
193 193
 
194
-        if (
195
-            ! $item->get('MTP_deleted')
196
-            && EE_Registry::instance()->CAP->current_user_can(
197
-                'ee_delete_message',
198
-                'espresso_messages_trash_message_template',
199
-                $item->ID()
200
-            )
201
-        ) {
202
-            $actions['trash'] = '<a href="'
203
-                                . $trash_lnk_url
204
-                                . '" title="'
205
-                                . esc_attr__('Move Template Group to Trash', 'event_espresso')
206
-                                . '">'
207
-                                . esc_html__('Move to Trash', 'event_espresso')
208
-                                . '</a>';
209
-        } else {
210
-            if (
211
-                EE_Registry::instance()->CAP->current_user_can(
212
-                    'ee_delete_message',
213
-                    'espresso_messages_restore_message_template',
214
-                    $item->ID()
215
-                )
216
-            ) {
217
-                $actions['restore'] = '<a href="'
218
-                                      . $restore_lnk_url
219
-                                      . '" title="'
220
-                                      . esc_attr__('Restore Message Template', 'event_espresso')
221
-                                      . '">'
222
-                                      . esc_html__('Restore', 'event_espresso') . '</a>';
223
-            }
194
+		if (
195
+			! $item->get('MTP_deleted')
196
+			&& EE_Registry::instance()->CAP->current_user_can(
197
+				'ee_delete_message',
198
+				'espresso_messages_trash_message_template',
199
+				$item->ID()
200
+			)
201
+		) {
202
+			$actions['trash'] = '<a href="'
203
+								. $trash_lnk_url
204
+								. '" title="'
205
+								. esc_attr__('Move Template Group to Trash', 'event_espresso')
206
+								. '">'
207
+								. esc_html__('Move to Trash', 'event_espresso')
208
+								. '</a>';
209
+		} else {
210
+			if (
211
+				EE_Registry::instance()->CAP->current_user_can(
212
+					'ee_delete_message',
213
+					'espresso_messages_restore_message_template',
214
+					$item->ID()
215
+				)
216
+			) {
217
+				$actions['restore'] = '<a href="'
218
+									  . $restore_lnk_url
219
+									  . '" title="'
220
+									  . esc_attr__('Restore Message Template', 'event_espresso')
221
+									  . '">'
222
+									  . esc_html__('Restore', 'event_espresso') . '</a>';
223
+			}
224 224
 
225
-            if (
226
-                $this->_view === 'trashed'
227
-                && EE_Registry::instance()->CAP->current_user_can(
228
-                    'ee_delete_message',
229
-                    'espresso_messages_delete_message_template',
230
-                    $item->ID()
231
-                )
232
-            ) {
233
-                $actions['delete'] = '<a href="'
234
-                                     . $delete_lnk_url
235
-                                     . '" title="'
236
-                                     . esc_attr__('Delete Template Group Permanently', 'event_espresso')
237
-                                     . '">'
238
-                                     . esc_html__('Delete Permanently', 'event_espresso')
239
-                                     . '</a>';
240
-            }
241
-        }
242
-        return $actions;
243
-    }
225
+			if (
226
+				$this->_view === 'trashed'
227
+				&& EE_Registry::instance()->CAP->current_user_can(
228
+					'ee_delete_message',
229
+					'espresso_messages_delete_message_template',
230
+					$item->ID()
231
+				)
232
+			) {
233
+				$actions['delete'] = '<a href="'
234
+									 . $delete_lnk_url
235
+									 . '" title="'
236
+									 . esc_attr__('Delete Template Group Permanently', 'event_espresso')
237
+									 . '">'
238
+									 . esc_html__('Delete Permanently', 'event_espresso')
239
+									 . '</a>';
240
+			}
241
+		}
242
+		return $actions;
243
+	}
244 244
 
245 245
 
246
-    /**
247
-     * Generate dropdown filter select input for messengers
248
-     *
249
-     * @param bool $global
250
-     * @return string
251
-     * @throws EE_Error
252
-     */
253
-    protected function _get_messengers_dropdown_filter($global = true)
254
-    {
255
-        return parent::_get_messengers_dropdown_filter(false);
256
-    }
246
+	/**
247
+	 * Generate dropdown filter select input for messengers
248
+	 *
249
+	 * @param bool $global
250
+	 * @return string
251
+	 * @throws EE_Error
252
+	 */
253
+	protected function _get_messengers_dropdown_filter($global = true)
254
+	{
255
+		return parent::_get_messengers_dropdown_filter(false);
256
+	}
257 257
 
258 258
 
259
-    /**
260
-     * Generate dropdown filter select input for message types
261
-     *
262
-     * @param bool $global
263
-     * @return string
264
-     * @throws EE_Error
265
-     */
266
-    protected function _get_message_types_dropdown_filter($global = true)
267
-    {
268
-        return parent::_get_message_types_dropdown_filter(false);
269
-    }
259
+	/**
260
+	 * Generate dropdown filter select input for message types
261
+	 *
262
+	 * @param bool $global
263
+	 * @return string
264
+	 * @throws EE_Error
265
+	 */
266
+	protected function _get_message_types_dropdown_filter($global = true)
267
+	{
268
+		return parent::_get_message_types_dropdown_filter(false);
269
+	}
270 270
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
      */
100 100
     public function column_name($item)
101 101
     {
102
-        return '<p>' . $item->name() . '</p>';
102
+        return '<p>'.$item->name().'</p>';
103 103
     }
104 104
 
105 105
 
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
     protected function _add_view_counts()
138 138
     {
139 139
         foreach ($this->_views as $view => $args) {
140
-            $this->_views[ $view ]['count'] = $this->get_admin_page()->get_message_templates(
140
+            $this->_views[$view]['count'] = $this->get_admin_page()->get_message_templates(
141 141
                 $this->_per_page,
142 142
                 $view,
143 143
                 true,
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
                                       . '" title="'
220 220
                                       . esc_attr__('Restore Message Template', 'event_espresso')
221 221
                                       . '">'
222
-                                      . esc_html__('Restore', 'event_espresso') . '</a>';
222
+                                      . esc_html__('Restore', 'event_espresso').'</a>';
223 223
             }
224 224
 
225 225
             if (
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
@@ -12,806 +12,806 @@
 block discarded – undo
12 12
 {
13 13
 
14 14
 
15
-    /**
16
-     * constructor.
17
-     */
18
-    public function __construct()
19
-    {
20
-        $this->_caf_hooks();
21
-    }
22
-
23
-
24
-    /**
25
-     * Contains all the hooks filters for setting up caffeinated messages functionality.
26
-     *
27
-     * @since 4.3.2
28
-     *
29
-     * @return void
30
-     */
31
-    private function _caf_hooks()
32
-    {
33
-        add_filter('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array($this, 'messages_autoload_paths'), 5);
34
-        add_filter(
35
-            'FHEE__EE_Email_messenger__get_validator_config',
36
-            array($this, 'email_messenger_validator_config'),
37
-            5,
38
-            2
39
-        );
40
-        add_filter(
41
-            'FHEE__EE_Email_messenger__get_template_fields',
42
-            array($this, 'email_messenger_template_fields'),
43
-            5,
44
-            2
45
-        );
46
-        add_filter(
47
-            'FHEE__EE_Html_messenger__get_template_fields',
48
-            array($this, 'html_messenger_template_fields'),
49
-            5,
50
-            2
51
-        );
52
-        add_filter(
53
-            'FHEE__EE_Html_messenger__get_validator_config',
54
-            array($this, 'html_messenger_validator_config'),
55
-            5,
56
-            2
57
-        );
58
-        add_filter('FHEE__EE_Pdf_messenger__get_template_fields', array($this, 'pdf_messenger_template_fields'), 5, 2);
59
-        add_filter(
60
-            'FHEE__EE_Pdf_messenger__get_validator_config',
61
-            array($this, 'pdf_messenger_validator_config'),
62
-            5,
63
-            2
64
-        );
65
-        add_filter(
66
-            'FHEE__EE_Messages_Template_Pack__get_specific_template__contents',
67
-            array($this, 'new_default_templates'),
68
-            5,
69
-            7
70
-        );
71
-        add_filter(
72
-            'FHEE__EE_Messages_Base__get_valid_shortcodes',
73
-            array($this, 'message_types_valid_shortcodes'),
74
-            5,
75
-            2
76
-        );
77
-
78
-        // shortcode parsers
79
-        add_filter('FHEE__EE_Attendee_Shortcodes__shortcodes', array($this, 'additional_attendee_shortcodes'), 5, 2);
80
-        add_filter('FHEE__EE_Attendee_Shortcodes__parser_after', array($this, 'additional_attendee_parser'), 5, 5);
81
-        add_filter(
82
-            'FHEE__EE_Recipient_List_Shortcodes__shortcodes',
83
-            array($this, 'additional_recipient_details_shortcodes'),
84
-            5,
85
-            2
86
-        );
87
-        add_filter(
88
-            'FHEE__EE_Recipient_List_Shortcodes__parser_after',
89
-            array($this, 'additional_recipient_details_parser'),
90
-            5,
91
-            5
92
-        );
93
-        add_filter(
94
-            'FHEE__EE_Primary_Registration_List_Shortcodes__shortcodes',
95
-            array($this, 'additional_primary_registration_details_shortcodes'),
96
-            5,
97
-            2
98
-        );
99
-        add_filter(
100
-            'FHEE__EE_Primary_Registration_List_Shortcodes__parser_after',
101
-            array($this, 'additional_primary_registration_details_parser'),
102
-            5,
103
-            5
104
-        );
105
-
106
-        /**
107
-         * @since 4.2.0
108
-         */
109
-        add_filter('FHEE__EE_Datetime_Shortcodes__shortcodes', array($this, 'additional_datetime_shortcodes'), 10, 2);
110
-        add_filter('FHEE__EE_Datetime_Shortcodes__parser_after', array($this, 'additional_datetime_parser'), 10, 5);
111
-
112
-        /**
113
-         * @since 4.3.0
114
-         */
115
-        // eat our own dog food!
116
-        add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_message_types'));
117
-        add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_shortcodes'));
118
-        do_action('EE_Brewing_Regular___messages_caf');
119
-    }
120
-
121
-
122
-    /**
123
-     * This just allows us to add additional paths to the autoloader (EED_Messages::autoload_messages()) for the
124
-     * messages system.
125
-     *
126
-     * @param  array $dir_ref original array of paths
127
-     *
128
-     * @return array           appended paths
129
-     */
130
-    public function messages_autoload_paths($dir_ref)
131
-    {
132
-        $dir_ref[] = EE_CAF_LIBRARIES . 'shortcodes/';
133
-
134
-        return $dir_ref;
135
-    }
136
-
137
-
138
-    public function email_messenger_validator_config($validator_config, EE_Email_messenger $messenger)
139
-    {
140
-        $validator_config['attendee_list'] = array(
141
-            'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'),
142
-            'required'   => array('[ATTENDEE_LIST]'),
143
-        );
144
-        $validator_config['question_list'] = array(
145
-            'shortcodes' => array('question'),
146
-            'required'   => array('[QUESTION_LIST]'),
147
-        );
148
-
149
-        return $validator_config;
150
-    }
151
-
152
-
153
-    public function html_messenger_validator_config($validator_config, EE_Html_messenger $messenger)
154
-    {
155
-        $validator_config['attendee_list'] = array(
156
-            'shortcodes' => array('attendee', 'question_list'),
157
-            'required'   => array('[ATTENDEE_LIST]'),
158
-        );
159
-        $validator_config['question_list'] = array(
160
-            'shortcodes' => array('question'),
161
-            'required'   => array('[QUESTION_LIST]'),
162
-        );
163
-
164
-        return $validator_config;
165
-    }
166
-
167
-
168
-    public function pdf_messenger_validator_config($validator_config, EE_Pdf_messenger $messenger)
169
-    {
170
-        $validator_config['attendee_list'] = array(
171
-            'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'),
172
-            'required'   => array('[ATTENDEE_LIST]'),
173
-        );
174
-        $validator_config['question_list'] = array(
175
-            'shortcodes' => array('question'),
176
-            'required'   => array('[QUESTION_LIST]'),
177
-        );
178
-
179
-        return $validator_config;
180
-    }
181
-
182
-
183
-    public function email_messenger_template_fields($template_fields, EE_Email_messenger $messenger)
184
-    {
185
-        $template_fields['extra']['content']['question_list'] = array(
186
-            'input'               => 'textarea',
187
-            'label'               => '[QUESTION_LIST]',
188
-            'type'                => 'string',
189
-            'required'            => true,
190
-            'validation'          => true,
191
-            'format'              => '%s',
192
-            'css_class'           => 'large-text',
193
-            'rows'                => '5',
194
-            'shortcodes_required' => array('[QUESTION_LIST]'),
195
-        );
196
-
197
-        return $template_fields;
198
-    }
199
-
200
-
201
-    public function html_messenger_template_fields($template_fields, EE_Html_messenger $messenger)
202
-    {
203
-        $template_fields['extra']['content']['question_list'] = array(
204
-            'input'               => 'textarea',
205
-            'label'               => '[QUESTION_LIST]',
206
-            'type'                => 'string',
207
-            'required'            => true,
208
-            'validation'          => true,
209
-            'format'              => '%s',
210
-            'css_class'           => 'large-text',
211
-            'rows'                => '5',
212
-            'shortcodes_required' => array('[QUESTION_LIST]'),
213
-        );
214
-
215
-        return $template_fields;
216
-    }
217
-
218
-
219
-    public function pdf_messenger_template_fields($template_fields, EE_Pdf_messenger $messenger)
220
-    {
221
-        $template_fields['extra']['content']['question_list'] = array(
222
-            'input'               => 'textarea',
223
-            'label'               => '[QUESTION_LIST]',
224
-            'type'                => 'string',
225
-            'required'            => true,
226
-            'validation'          => true,
227
-            'format'              => '%s',
228
-            'css_class'           => 'large-text',
229
-            'rows'                => '5',
230
-            'shortcodes_required' => array('[QUESTION_LIST]'),
231
-        );
232
-
233
-        return $template_fields;
234
-    }
235
-
236
-
237
-    public function new_default_templates(
238
-        $contents,
239
-        $actual_path,
240
-        EE_messenger $messenger,
241
-        EE_message_type $message_type,
242
-        $field,
243
-        $context,
244
-        EE_Messages_Template_Pack $template_pack
245
-    ) {
246
-
247
-        // we're only modifying templates for the default template pack
248
-        if (! $template_pack instanceof EE_Messages_Template_Pack_Default) {
249
-            return $contents;
250
-        }
251
-
252
-        // the template file name we're replacing contents for.
253
-        $template_file_prefix = $field . '_' . $context;
254
-        $msg_prefix = $messenger->name . '_' . $message_type->name . '_';
255
-
256
-        $base_path = EE_CAF_LIBRARIES . 'messages/defaults/default/';
257
-
258
-        if ($messenger->name == 'email' && $message_type->name == 'registration') {
259
-            switch ($template_file_prefix) {
260
-                case 'question_list_admin':
261
-                case 'question_list_attendee':
262
-                case 'question_list_primary_attendee':
263
-                    $path = $base_path . $msg_prefix . 'question_list.template.php';
264
-                    $contents = EEH_Template::display_template($path, array(), true);
265
-                    break;
266
-
267
-                case 'attendee_list_primary_attendee':
268
-                    $path = $base_path . $msg_prefix . 'attendee_list.template.php';
269
-                    $contents = EEH_Template::display_template($path, array(), true);
270
-                    break;
271
-
272
-                case 'attendee_list_admin':
273
-                    $path = $base_path . $msg_prefix . 'attendee_list_admin.template.php';
274
-                    $contents = EEH_Template::display_template(
275
-                        $path,
276
-                        array(),
277
-                        true
278
-                    );
279
-                    break;
280
-
281
-                case 'attendee_list_attendee':
282
-                    $contents = '';
283
-                    break;
284
-
285
-                case 'event_list_attendee':
286
-                    $path = $base_path . $msg_prefix . 'event_list_attendee.template.php';
287
-                    $contents = EEH_Template::display_template($path, array(), true);
288
-                    break;
289
-            }
290
-        } elseif ($messenger->name == 'email' && $message_type->name == 'newsletter') {
291
-            switch ($template_file_prefix) {
292
-                case 'content_attendee':
293
-                    $path = $base_path . $msg_prefix . 'content.template.php';
294
-                    $contents = EEH_Template::display_template($path, array(), true);
295
-                    break;
296
-
297
-                case 'newsletter_content_attendee':
298
-                    $path = $base_path . $msg_prefix . 'newsletter_content.template.php';
299
-                    $contents = EEH_Template::display_template($path, array(), true);
300
-                    break;
301
-
302
-                case 'newsletter_subject_attendee':
303
-                    $path = $base_path . $msg_prefix . 'subject.template.php';
304
-                    $contents = EEH_Template::display_template($path, array(), true);
305
-                    break;
306
-            }
307
-        } elseif ($messenger->name == 'html' && $message_type->name == 'receipt') {
308
-            switch ($template_file_prefix) {
309
-                case 'attendee_list_purchaser':
310
-                    $path = $base_path . $msg_prefix . 'attendee_list.template.php';
311
-                    $contents = EEH_Template::display_template($path, array(), true);
312
-                    break;
313
-            }
314
-        }
315
-
316
-        return $contents;
317
-    }
318
-
319
-
320
-    public function message_types_valid_shortcodes($valid_shortcodes, EE_Messages_Base $msg)
321
-    {
322
-        // 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.
323
-        $include_with = array(
324
-            'registration',
325
-            'cancelled_registration',
326
-            'declined_registration',
327
-            'not_approved_registration',
328
-            'payment_declined',
329
-            'payment_failed',
330
-            'payment_cancelled',
331
-            'payment',
332
-            'payment_reminder',
333
-            'pending_approval',
334
-            'registration_summary',
335
-            'invoice',
336
-            'receipt',
337
-        );
338
-        if ($msg instanceof EE_message_type && in_array($msg->name, $include_with)) {
339
-            $contexts = array_keys($msg->get_contexts());
340
-            foreach ($contexts as $context) {
341
-                $valid_shortcodes[ $context ][] = 'question_list';
342
-                $valid_shortcodes[ $context ][] = 'question';
343
-            }
344
-        }
345
-
346
-        return $valid_shortcodes;
347
-    }
348
-
349
-
350
-    public function additional_attendee_shortcodes($shortcodes, $shortcode_parser)
351
-    {
352
-        $shortcodes['[ANSWER_*]'] = esc_html__(
353
-            '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.',
354
-            'event_espresso'
355
-        );
356
-
357
-        return $shortcodes;
358
-    }
359
-
360
-
361
-    public function additional_attendee_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
362
-    {
363
-
364
-        if (
365
-            strpos($shortcode, '[ANSWER_*') === false
366
-            || ! isset($extra_data['data']->questions)
367
-            || ! isset($extra_data['data']->registrations)
368
-        ) {
369
-            return $parsed;
370
-        }
371
-
372
-        // let's get the question from the code.
373
-        $shortcode = str_replace('[ANSWER_*', '', $shortcode);
374
-        $shortcode = trim(str_replace(']', '', $shortcode));
375
-
376
-        $registration = $data instanceof EE_Registration ? $data : null;
377
-        $registration = ! $registration instanceof EE_Registration && is_array(
378
-            $extra_data
379
-        ) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Registration ? $extra_data['data'] : $registration;
380
-
381
-        $aee = $data instanceof EE_Messages_Addressee ? $data : null;
382
-        $aee = ! $aee instanceof EE_Messages_Addressee && is_array(
383
-            $extra_data
384
-        ) && isset($extra_data['data']) ? $extra_data['data'] : $aee;
385
-
386
-        if (! $registration instanceof EE_Registration || ! $aee instanceof EE_Messages_Addressee) {
387
-            return $parsed;
388
-        }
389
-
390
-        // now let's figure out which question has this text.
391
-        foreach ($aee->questions as $ansid => $question) {
392
-            if (
393
-                $question instanceof EE_Question
394
-                && trim($question->display_text()) == trim($shortcode)
395
-                && isset($aee->registrations[ $registration->ID() ]['ans_objs'][ $ansid ])
396
-            ) {
397
-                return $aee->registrations[ $registration->ID() ]['ans_objs'][ $ansid ]->get_pretty(
398
-                    'ANS_value',
399
-                    'no_wpautop'
400
-                );
401
-            }
402
-        }
403
-
404
-        // nothing!
405
-        return $parsed;
406
-    }
407
-
408
-
409
-    /**
410
-     * Callback for additional shortcodes filter for adding additional datetime shortcodes.
411
-     *
412
-     * @since  4.2
413
-     *
414
-     * @param  array                  $shortcodes         array of shortcodes and
415
-     *                                                    descriptions
416
-     * @param  EE_Datetime_Shortcodes $shortcode_parser   EE_Shortcodes object
417
-     *
418
-     * @return array                                        array of shortcodes and
419
-     *                                                        descriptions
420
-     */
421
-    public function additional_datetime_shortcodes($shortcodes, $shortcode_parser)
422
-    {
423
-        $shortcodes['[DTT_NAME]'] = esc_html__(
424
-            'This will be parsed to the Title given for a Datetime',
425
-            'event_espresso'
426
-        );
427
-        $shortcodes['[DTT_DESCRIPTION]'] = esc_html__(
428
-            'This will be parsed to the description for a Datetime',
429
-            'event_espresso'
430
-        );
431
-        $shortcodes['[DTT_NAME_OR_DATES]'] = esc_html__(
432
-            '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.',
433
-            'event_espresso'
434
-        );
435
-
436
-        return $shortcodes;
437
-    }
438
-
439
-
440
-    /**
441
-     * Callback for additional shortcodes parser filter used for adding parser for new
442
-     * Datetime shortcodes
443
-     *
444
-     * @since  4.2
445
-     *
446
-     * @param  string                 $parsed     The finished parsed string for the given shortcode.
447
-     * @param  string                 $shortcode  The shortcode being parsed.
448
-     * @param  object                 $data       The incoming data object for the Shortcode Parser.
449
-     * @param  object                 $extra_data The incoming extra date object for the Shortcode
450
-     *                                            Parser.
451
-     * @param  EE_Datetime_Shortcodes $shortcode_parser
452
-     *
453
-     * @return string                   The new parsed string.
454
-     */
455
-    public function additional_datetime_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
456
-    {
457
-
458
-        if (! $data instanceof EE_Datetime) {
459
-            return ''; // get out because we can only parse with the datetime object.
460
-        }
461
-
462
-        switch ($shortcode) {
463
-            case '[DTT_NAME]':
464
-                return $data->name();
465
-                break;
466
-            case '[DTT_DESCRIPTION]':
467
-                return $data->description();
468
-                break;
469
-            case '[DTT_NAME_OR_DATES]':
470
-                return $data->get_dtt_display_name(true);
471
-                break;
472
-            default:
473
-                return $parsed;
474
-                break;
475
-        }
476
-    }
477
-
478
-
479
-    public function additional_recipient_details_shortcodes($shortcodes, $shortcode_parser)
480
-    {
481
-        $shortcodes['[RECIPIENT_QUESTION_LIST]'] = esc_html__(
482
-            'This is used to indicate where you want the list of questions and answers to show for the person receiving the message.',
483
-            'event_espresso'
484
-        );
485
-
486
-        return $shortcodes;
487
-    }
488
-
489
-
490
-    /**
491
-     * Callback for FHEE__EE_Recipient_List_Shortcodes__parser_after filter (dynamic filter).
492
-     *
493
-     * @param string         $parsed           The original parsed content for the shortcode
494
-     * @param string         $shortcode        The shortcode being parsed
495
-     * @param array          $data             The shortcode parser data array
496
-     * @param array          $extra_data       The shortcode parser extra data array
497
-     * @param \EE_Shortcodes $shortcode_parser Shortcode parser.
498
-     *
499
-     * @return string
500
-     */
501
-    public function additional_recipient_details_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
502
-    {
503
-
504
-        if (array($data) && ! isset($data['data'])) {
505
-            return $parsed;
506
-        }
507
-
508
-        $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
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
-
511
-        if (! $recipient instanceof EE_Messages_Addressee) {
512
-            return $parsed;
513
-        }
514
-
515
-        switch ($shortcode) {
516
-            case '[RECIPIENT_QUESTION_LIST]':
517
-                $att = $recipient->att_obj;
518
-                $registrations_on_attendee = $att instanceof EE_Attendee
519
-                    ? $recipient->attendees[ $att->ID() ]['reg_objs']
520
-                    : array();
521
-                $registrations_on_attendee = empty($registrations_on_attendee) && $recipient->reg_obj instanceof EE_Registration ? array($recipient->reg_obj) : $registrations_on_attendee;
522
-                $answers = array();
523
-
524
-                $template = is_array($data['template']) && isset($data['template']['question_list'])
525
-                    ? $data['template']['question_list']
526
-                    : $extra_data['template']['question_list'];
527
-                $valid_shortcodes = array('question');
528
-
529
-                // if the context is main_content then get all answers for all registrations on this attendee
530
-                if ($data['data'] instanceof EE_Messages_Addressee) {
531
-                    foreach ($registrations_on_attendee as $reg) {
532
-                        if ($reg instanceof EE_Registration) {
533
-                            $anss = ! empty($recipient->registrations[ $reg->ID() ]['ans_objs'])
534
-                                ? $recipient->registrations[ $reg->ID() ]['ans_objs']
535
-                                : array();
536
-                            foreach ($anss as $ans) {
537
-                                if ($ans instanceof EE_Answer) {
538
-                                    $answers[ $ans->ID() ] = $ans;
539
-                                }
540
-                            }
541
-                        }
542
-                    }
543
-                }
544
-
545
-                // 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.
546
-                if ($data['data'] instanceof EE_Event) {
547
-                    $event = $data['data'];
548
-                    foreach ($registrations_on_attendee as $reg) {
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']
552
-                                : array();
553
-                            foreach ($anss as $ans) {
554
-                                if ($ans instanceof EE_Answer) {
555
-                                    $answers[ $ans->ID() ] = $ans;
556
-                                }
557
-                            }
558
-                        }
559
-                    }
560
-                }
561
-
562
-                $questions = $questions = isset($recipient->questions) ? $recipient->questions : array();
563
-
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
-                // object on it.
566
-                if (! isset($extra_data['data'])) {
567
-                    $extra_data['data'] = $recipient;
568
-                }
569
-
570
-                return $this->_parse_question_list_for_primary_or_recipient_registration(
571
-                    $shortcode_parser,
572
-                    $questions,
573
-                    $answers,
574
-                    $template,
575
-                    $valid_shortcodes,
576
-                    $extra_data
577
-                );
578
-                break;
579
-
580
-            default:
581
-                return $parsed;
582
-                break;
583
-        }
584
-    }
585
-
586
-
587
-    public function additional_primary_registration_details_shortcodes($shortcodes, $shortcode_parser)
588
-    {
589
-        $shortcodes['[PRIMARY_REGISTRANT_QUESTION_LIST]'] = esc_html__(
590
-            'This is used to indicate the questions and answers for the primary_registrant. It should be placed in the "[attendee_list]" field',
591
-            'event_espresso'
592
-        );
593
-
594
-        return $shortcodes;
595
-    }
596
-
597
-
598
-    /**
599
-     * Callback for FHEE__EE_Primary_Registration_List_Shortcodes__parser_after filter (dynamic filter).
600
-     *
601
-     * @param string         $parsed           The original parsed content for the shortcode
602
-     * @param string         $shortcode        The shortcode being parsed
603
-     * @param array          $data             The shortcode parser data array
604
-     * @param array          $extra_data       The shortcode parser extra data array
605
-     * @param \EE_Shortcodes $shortcode_parser Shortcode parser.
606
-     *
607
-     * @return string
608
-     */
609
-    public function additional_primary_registration_details_parser(
610
-        $parsed,
611
-        $shortcode,
612
-        $data,
613
-        $extra_data,
614
-        $shortcode_parser
615
-    ) {
616
-        if (array($data) && ! isset($data['data'])) {
617
-            return $parsed;
618
-        }
619
-
620
-        $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
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
-
623
-        if (! $recipient instanceof EE_Messages_Addressee) {
624
-            return $parsed;
625
-        }
626
-
627
-        switch ($shortcode) {
628
-            case '[PRIMARY_REGISTRANT_QUESTION_LIST]':
629
-                if (! $recipient->primary_att_obj instanceof EE_Attendee || ! $recipient->primary_reg_obj instanceof EE_Registration) {
630
-                    return '';
631
-                }
632
-                $registration = $recipient->primary_reg_obj;
633
-                $answers = isset($recipient->registrations[ $registration->ID() ]['ans_objs'])
634
-                    ? $recipient->registrations[ $registration->ID() ]['ans_objs']
635
-                    : array();
636
-                if (empty($answers)) {
637
-                    return '';
638
-                }
639
-                $template = is_array($data['template']) && isset($data['template']['question_list'])
640
-                    ? $data['template']['question_list']
641
-                    : $extra_data['template']['question_list'];
642
-                $valid_shortcodes = array('question');
643
-                $answers = $recipient->registrations[ $registration->ID() ]['ans_objs'];
644
-                $questions = isset($recipient->questions) ? $recipient->questions : array();
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
-                // object on it.
647
-                if (! isset($extra_data['data'])) {
648
-                    $extra_data['data'] = $recipient;
649
-                }
650
-                return $this->_parse_question_list_for_primary_or_recipient_registration(
651
-                    $shortcode_parser,
652
-                    $questions,
653
-                    $answers,
654
-                    $template,
655
-                    $valid_shortcodes,
656
-                    $extra_data
657
-                );
658
-                break;
659
-
660
-            default:
661
-                return $parsed;
662
-                break;
663
-        }
664
-    }
665
-
666
-
667
-    /**
668
-     * Takes care of registering the  message types that are only available in caffeinated EE.
669
-     *
670
-     * @since   4.3.2
671
-     *
672
-     * @return  void
673
-     */
674
-    public function register_caf_message_types()
675
-    {
676
-        // register newsletter message type
677
-        $setup_args = array(
678
-            'mtfilename'                                       => 'EE_Newsletter_message_type.class.php',
679
-            'autoloadpaths'                                    => array(
680
-                EE_CAF_LIBRARIES . 'messages/message_type/newsletter/',
681
-            ),
682
-            'messengers_to_activate_with'                      => array('email'),
683
-            'messengers_to_validate_with'                      => array('email'),
684
-            'messengers_supporting_default_template_pack_with' => array('email'),
685
-        );
686
-        EE_Register_Message_Type::register('newsletter', $setup_args);
687
-
688
-        // register payment reminder message type
689
-        $setup_args = array(
690
-            'mtfilename'                                       => 'EE_Payment_Reminder_message_type.class.php',
691
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'),
692
-            'messengers_to_activate_with'                      => array('email'),
693
-            'messengers_to_validate_with'                      => array('email'),
694
-            'messengers_supporting_default_template_pack_with' => array('email'),
695
-        );
696
-        EE_Register_Message_Type::register('payment_reminder', $setup_args);
697
-
698
-        // register payment declined message type
699
-        $setup_args = array(
700
-            'mtfilename'                                       => 'EE_Payment_Declined_message_type.class.php',
701
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'),
702
-            'messengers_to_activate_with'                      => array('email'),
703
-            'messengers_to_validate_with'                      => array('email'),
704
-            'messengers_supporting_default_template_pack_with' => array('email'),
705
-        );
706
-        EE_Register_Message_Type::register('payment_declined', $setup_args);
707
-
708
-        // register registration declined message type
709
-        $setup_args = array(
710
-            'mtfilename'                                       => 'EE_Declined_Registration_message_type.class.php',
711
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'),
712
-            'messengers_to_activate_with'                      => array('email'),
713
-            'messengers_to_validate_with'                      => array('email'),
714
-            'messengers_supporting_default_template_pack_with' => array('email'),
715
-        );
716
-        EE_Register_Message_Type::register('declined_registration', $setup_args);
717
-
718
-        // register registration cancelled message type
719
-        $setup_args = array(
720
-            'mtfilename'                                       => 'EE_Cancelled_Registration_message_type.class.php',
721
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'),
722
-            'messengers_to_activate_with'                      => array('email'),
723
-            'messengers_to_validate_with'                      => array('email'),
724
-            'messengers_supporting_default_template_pack_with' => array('email'),
725
-        );
726
-        EE_Register_Message_Type::register('cancelled_registration', $setup_args);
727
-
728
-
729
-        // register payment failed message type
730
-        $setup_args = array(
731
-            'mtfilename'                                       => 'EE_Payment_Failed_message_type.class.php',
732
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'),
733
-            'messengers_to_activate_with'                      => array('email'),
734
-            'messengers_to_validate_with'                      => array('email'),
735
-            'messengers_supporting_default_template_pack_with' => array('email'),
736
-        );
737
-        EE_Register_Message_Type::register('payment_failed', $setup_args);
738
-
739
-        // register payment declined message type
740
-        $setup_args = array(
741
-            'mtfilename'                                       => 'EE_Payment_Cancelled_message_type.class.php',
742
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'),
743
-            'messengers_to_activate_with'                      => array('email'),
744
-            'messengers_to_validate_with'                      => array('email'),
745
-            'messengers_supporting_default_template_pack_with' => array('email'),
746
-        );
747
-        EE_Register_Message_Type::register('payment_cancelled', $setup_args);
748
-    }
749
-
750
-
751
-    /**
752
-     * Takes care of registering the  shortcode libraries implemented with caffeinated EE and set up related items.
753
-     *
754
-     * @since   4.3.2
755
-     *
756
-     * @return void
757
-     */
758
-    public function register_caf_shortcodes()
759
-    {
760
-        $setup_args = array(
761
-            'autoloadpaths'                 => array(
762
-                EE_CAF_LIBRARIES . 'shortcodes/',
763
-            ),
764
-            'msgr_validator_callback'       => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'),
765
-            'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'),
766
-            'list_type_shortcodes'          => array('[NEWSLETTER_CONTENT]'),
767
-        );
768
-        EE_Register_Messages_Shortcode_Library::register('newsletter', $setup_args);
769
-    }
770
-
771
-
772
-    /**
773
-     * Parses a question list shortcode using given data and template
774
-     *
775
-     * @param \EE_Shortcodes $shortcode_parser
776
-     * @param EE_Question[]  $questions        An array of questions indexed by answer id.
777
-     * @param EE_Answer[]    $answers          An array of answer objects
778
-     * @param string         $template         Template content to be parsed.
779
-     * @param array          $valid_shortcodes Valid shortcodes for the template being parsed.
780
-     * @param array          $extra_data       Extra data that might be used when parsing the template.
781
-     */
782
-    protected function _parse_question_list_for_primary_or_recipient_registration(
783
-        $shortcode_parser,
784
-        $questions,
785
-        $answers,
786
-        $template,
787
-        $valid_shortcodes,
788
-        $extra_data
789
-    ) {
790
-        $question_list = '';
791
-        /** @var EEH_Parse_Shortcodes $shortcode_helper */
792
-        $shortcode_helper = $shortcode_parser->get_shortcode_helper();
793
-        foreach ($answers as $answer) {
794
-            if ($answer instanceof EE_Answer) {
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;
797
-                $question = ! $question instanceof EE_Question ? $answer->question() : $question;
798
-                if (
799
-                    ! $question instanceof EE_Question
800
-                    || (
801
-                        $question instanceof EE_Question
802
-                        && $question->admin_only()
803
-                    )
804
-                ) {
805
-                    continue;
806
-                }
807
-                $question_list .= $shortcode_helper->parse_question_list_template(
808
-                    $template,
809
-                    $answer,
810
-                    $valid_shortcodes,
811
-                    $extra_data
812
-                );
813
-            }
814
-        }
815
-        return $question_list;
816
-    }
15
+	/**
16
+	 * constructor.
17
+	 */
18
+	public function __construct()
19
+	{
20
+		$this->_caf_hooks();
21
+	}
22
+
23
+
24
+	/**
25
+	 * Contains all the hooks filters for setting up caffeinated messages functionality.
26
+	 *
27
+	 * @since 4.3.2
28
+	 *
29
+	 * @return void
30
+	 */
31
+	private function _caf_hooks()
32
+	{
33
+		add_filter('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array($this, 'messages_autoload_paths'), 5);
34
+		add_filter(
35
+			'FHEE__EE_Email_messenger__get_validator_config',
36
+			array($this, 'email_messenger_validator_config'),
37
+			5,
38
+			2
39
+		);
40
+		add_filter(
41
+			'FHEE__EE_Email_messenger__get_template_fields',
42
+			array($this, 'email_messenger_template_fields'),
43
+			5,
44
+			2
45
+		);
46
+		add_filter(
47
+			'FHEE__EE_Html_messenger__get_template_fields',
48
+			array($this, 'html_messenger_template_fields'),
49
+			5,
50
+			2
51
+		);
52
+		add_filter(
53
+			'FHEE__EE_Html_messenger__get_validator_config',
54
+			array($this, 'html_messenger_validator_config'),
55
+			5,
56
+			2
57
+		);
58
+		add_filter('FHEE__EE_Pdf_messenger__get_template_fields', array($this, 'pdf_messenger_template_fields'), 5, 2);
59
+		add_filter(
60
+			'FHEE__EE_Pdf_messenger__get_validator_config',
61
+			array($this, 'pdf_messenger_validator_config'),
62
+			5,
63
+			2
64
+		);
65
+		add_filter(
66
+			'FHEE__EE_Messages_Template_Pack__get_specific_template__contents',
67
+			array($this, 'new_default_templates'),
68
+			5,
69
+			7
70
+		);
71
+		add_filter(
72
+			'FHEE__EE_Messages_Base__get_valid_shortcodes',
73
+			array($this, 'message_types_valid_shortcodes'),
74
+			5,
75
+			2
76
+		);
77
+
78
+		// shortcode parsers
79
+		add_filter('FHEE__EE_Attendee_Shortcodes__shortcodes', array($this, 'additional_attendee_shortcodes'), 5, 2);
80
+		add_filter('FHEE__EE_Attendee_Shortcodes__parser_after', array($this, 'additional_attendee_parser'), 5, 5);
81
+		add_filter(
82
+			'FHEE__EE_Recipient_List_Shortcodes__shortcodes',
83
+			array($this, 'additional_recipient_details_shortcodes'),
84
+			5,
85
+			2
86
+		);
87
+		add_filter(
88
+			'FHEE__EE_Recipient_List_Shortcodes__parser_after',
89
+			array($this, 'additional_recipient_details_parser'),
90
+			5,
91
+			5
92
+		);
93
+		add_filter(
94
+			'FHEE__EE_Primary_Registration_List_Shortcodes__shortcodes',
95
+			array($this, 'additional_primary_registration_details_shortcodes'),
96
+			5,
97
+			2
98
+		);
99
+		add_filter(
100
+			'FHEE__EE_Primary_Registration_List_Shortcodes__parser_after',
101
+			array($this, 'additional_primary_registration_details_parser'),
102
+			5,
103
+			5
104
+		);
105
+
106
+		/**
107
+		 * @since 4.2.0
108
+		 */
109
+		add_filter('FHEE__EE_Datetime_Shortcodes__shortcodes', array($this, 'additional_datetime_shortcodes'), 10, 2);
110
+		add_filter('FHEE__EE_Datetime_Shortcodes__parser_after', array($this, 'additional_datetime_parser'), 10, 5);
111
+
112
+		/**
113
+		 * @since 4.3.0
114
+		 */
115
+		// eat our own dog food!
116
+		add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_message_types'));
117
+		add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_shortcodes'));
118
+		do_action('EE_Brewing_Regular___messages_caf');
119
+	}
120
+
121
+
122
+	/**
123
+	 * This just allows us to add additional paths to the autoloader (EED_Messages::autoload_messages()) for the
124
+	 * messages system.
125
+	 *
126
+	 * @param  array $dir_ref original array of paths
127
+	 *
128
+	 * @return array           appended paths
129
+	 */
130
+	public function messages_autoload_paths($dir_ref)
131
+	{
132
+		$dir_ref[] = EE_CAF_LIBRARIES . 'shortcodes/';
133
+
134
+		return $dir_ref;
135
+	}
136
+
137
+
138
+	public function email_messenger_validator_config($validator_config, EE_Email_messenger $messenger)
139
+	{
140
+		$validator_config['attendee_list'] = array(
141
+			'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'),
142
+			'required'   => array('[ATTENDEE_LIST]'),
143
+		);
144
+		$validator_config['question_list'] = array(
145
+			'shortcodes' => array('question'),
146
+			'required'   => array('[QUESTION_LIST]'),
147
+		);
148
+
149
+		return $validator_config;
150
+	}
151
+
152
+
153
+	public function html_messenger_validator_config($validator_config, EE_Html_messenger $messenger)
154
+	{
155
+		$validator_config['attendee_list'] = array(
156
+			'shortcodes' => array('attendee', 'question_list'),
157
+			'required'   => array('[ATTENDEE_LIST]'),
158
+		);
159
+		$validator_config['question_list'] = array(
160
+			'shortcodes' => array('question'),
161
+			'required'   => array('[QUESTION_LIST]'),
162
+		);
163
+
164
+		return $validator_config;
165
+	}
166
+
167
+
168
+	public function pdf_messenger_validator_config($validator_config, EE_Pdf_messenger $messenger)
169
+	{
170
+		$validator_config['attendee_list'] = array(
171
+			'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'),
172
+			'required'   => array('[ATTENDEE_LIST]'),
173
+		);
174
+		$validator_config['question_list'] = array(
175
+			'shortcodes' => array('question'),
176
+			'required'   => array('[QUESTION_LIST]'),
177
+		);
178
+
179
+		return $validator_config;
180
+	}
181
+
182
+
183
+	public function email_messenger_template_fields($template_fields, EE_Email_messenger $messenger)
184
+	{
185
+		$template_fields['extra']['content']['question_list'] = array(
186
+			'input'               => 'textarea',
187
+			'label'               => '[QUESTION_LIST]',
188
+			'type'                => 'string',
189
+			'required'            => true,
190
+			'validation'          => true,
191
+			'format'              => '%s',
192
+			'css_class'           => 'large-text',
193
+			'rows'                => '5',
194
+			'shortcodes_required' => array('[QUESTION_LIST]'),
195
+		);
196
+
197
+		return $template_fields;
198
+	}
199
+
200
+
201
+	public function html_messenger_template_fields($template_fields, EE_Html_messenger $messenger)
202
+	{
203
+		$template_fields['extra']['content']['question_list'] = array(
204
+			'input'               => 'textarea',
205
+			'label'               => '[QUESTION_LIST]',
206
+			'type'                => 'string',
207
+			'required'            => true,
208
+			'validation'          => true,
209
+			'format'              => '%s',
210
+			'css_class'           => 'large-text',
211
+			'rows'                => '5',
212
+			'shortcodes_required' => array('[QUESTION_LIST]'),
213
+		);
214
+
215
+		return $template_fields;
216
+	}
217
+
218
+
219
+	public function pdf_messenger_template_fields($template_fields, EE_Pdf_messenger $messenger)
220
+	{
221
+		$template_fields['extra']['content']['question_list'] = array(
222
+			'input'               => 'textarea',
223
+			'label'               => '[QUESTION_LIST]',
224
+			'type'                => 'string',
225
+			'required'            => true,
226
+			'validation'          => true,
227
+			'format'              => '%s',
228
+			'css_class'           => 'large-text',
229
+			'rows'                => '5',
230
+			'shortcodes_required' => array('[QUESTION_LIST]'),
231
+		);
232
+
233
+		return $template_fields;
234
+	}
235
+
236
+
237
+	public function new_default_templates(
238
+		$contents,
239
+		$actual_path,
240
+		EE_messenger $messenger,
241
+		EE_message_type $message_type,
242
+		$field,
243
+		$context,
244
+		EE_Messages_Template_Pack $template_pack
245
+	) {
246
+
247
+		// we're only modifying templates for the default template pack
248
+		if (! $template_pack instanceof EE_Messages_Template_Pack_Default) {
249
+			return $contents;
250
+		}
251
+
252
+		// the template file name we're replacing contents for.
253
+		$template_file_prefix = $field . '_' . $context;
254
+		$msg_prefix = $messenger->name . '_' . $message_type->name . '_';
255
+
256
+		$base_path = EE_CAF_LIBRARIES . 'messages/defaults/default/';
257
+
258
+		if ($messenger->name == 'email' && $message_type->name == 'registration') {
259
+			switch ($template_file_prefix) {
260
+				case 'question_list_admin':
261
+				case 'question_list_attendee':
262
+				case 'question_list_primary_attendee':
263
+					$path = $base_path . $msg_prefix . 'question_list.template.php';
264
+					$contents = EEH_Template::display_template($path, array(), true);
265
+					break;
266
+
267
+				case 'attendee_list_primary_attendee':
268
+					$path = $base_path . $msg_prefix . 'attendee_list.template.php';
269
+					$contents = EEH_Template::display_template($path, array(), true);
270
+					break;
271
+
272
+				case 'attendee_list_admin':
273
+					$path = $base_path . $msg_prefix . 'attendee_list_admin.template.php';
274
+					$contents = EEH_Template::display_template(
275
+						$path,
276
+						array(),
277
+						true
278
+					);
279
+					break;
280
+
281
+				case 'attendee_list_attendee':
282
+					$contents = '';
283
+					break;
284
+
285
+				case 'event_list_attendee':
286
+					$path = $base_path . $msg_prefix . 'event_list_attendee.template.php';
287
+					$contents = EEH_Template::display_template($path, array(), true);
288
+					break;
289
+			}
290
+		} elseif ($messenger->name == 'email' && $message_type->name == 'newsletter') {
291
+			switch ($template_file_prefix) {
292
+				case 'content_attendee':
293
+					$path = $base_path . $msg_prefix . 'content.template.php';
294
+					$contents = EEH_Template::display_template($path, array(), true);
295
+					break;
296
+
297
+				case 'newsletter_content_attendee':
298
+					$path = $base_path . $msg_prefix . 'newsletter_content.template.php';
299
+					$contents = EEH_Template::display_template($path, array(), true);
300
+					break;
301
+
302
+				case 'newsletter_subject_attendee':
303
+					$path = $base_path . $msg_prefix . 'subject.template.php';
304
+					$contents = EEH_Template::display_template($path, array(), true);
305
+					break;
306
+			}
307
+		} elseif ($messenger->name == 'html' && $message_type->name == 'receipt') {
308
+			switch ($template_file_prefix) {
309
+				case 'attendee_list_purchaser':
310
+					$path = $base_path . $msg_prefix . 'attendee_list.template.php';
311
+					$contents = EEH_Template::display_template($path, array(), true);
312
+					break;
313
+			}
314
+		}
315
+
316
+		return $contents;
317
+	}
318
+
319
+
320
+	public function message_types_valid_shortcodes($valid_shortcodes, EE_Messages_Base $msg)
321
+	{
322
+		// 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.
323
+		$include_with = array(
324
+			'registration',
325
+			'cancelled_registration',
326
+			'declined_registration',
327
+			'not_approved_registration',
328
+			'payment_declined',
329
+			'payment_failed',
330
+			'payment_cancelled',
331
+			'payment',
332
+			'payment_reminder',
333
+			'pending_approval',
334
+			'registration_summary',
335
+			'invoice',
336
+			'receipt',
337
+		);
338
+		if ($msg instanceof EE_message_type && in_array($msg->name, $include_with)) {
339
+			$contexts = array_keys($msg->get_contexts());
340
+			foreach ($contexts as $context) {
341
+				$valid_shortcodes[ $context ][] = 'question_list';
342
+				$valid_shortcodes[ $context ][] = 'question';
343
+			}
344
+		}
345
+
346
+		return $valid_shortcodes;
347
+	}
348
+
349
+
350
+	public function additional_attendee_shortcodes($shortcodes, $shortcode_parser)
351
+	{
352
+		$shortcodes['[ANSWER_*]'] = esc_html__(
353
+			'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.',
354
+			'event_espresso'
355
+		);
356
+
357
+		return $shortcodes;
358
+	}
359
+
360
+
361
+	public function additional_attendee_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
362
+	{
363
+
364
+		if (
365
+			strpos($shortcode, '[ANSWER_*') === false
366
+			|| ! isset($extra_data['data']->questions)
367
+			|| ! isset($extra_data['data']->registrations)
368
+		) {
369
+			return $parsed;
370
+		}
371
+
372
+		// let's get the question from the code.
373
+		$shortcode = str_replace('[ANSWER_*', '', $shortcode);
374
+		$shortcode = trim(str_replace(']', '', $shortcode));
375
+
376
+		$registration = $data instanceof EE_Registration ? $data : null;
377
+		$registration = ! $registration instanceof EE_Registration && is_array(
378
+			$extra_data
379
+		) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Registration ? $extra_data['data'] : $registration;
380
+
381
+		$aee = $data instanceof EE_Messages_Addressee ? $data : null;
382
+		$aee = ! $aee instanceof EE_Messages_Addressee && is_array(
383
+			$extra_data
384
+		) && isset($extra_data['data']) ? $extra_data['data'] : $aee;
385
+
386
+		if (! $registration instanceof EE_Registration || ! $aee instanceof EE_Messages_Addressee) {
387
+			return $parsed;
388
+		}
389
+
390
+		// now let's figure out which question has this text.
391
+		foreach ($aee->questions as $ansid => $question) {
392
+			if (
393
+				$question instanceof EE_Question
394
+				&& trim($question->display_text()) == trim($shortcode)
395
+				&& isset($aee->registrations[ $registration->ID() ]['ans_objs'][ $ansid ])
396
+			) {
397
+				return $aee->registrations[ $registration->ID() ]['ans_objs'][ $ansid ]->get_pretty(
398
+					'ANS_value',
399
+					'no_wpautop'
400
+				);
401
+			}
402
+		}
403
+
404
+		// nothing!
405
+		return $parsed;
406
+	}
407
+
408
+
409
+	/**
410
+	 * Callback for additional shortcodes filter for adding additional datetime shortcodes.
411
+	 *
412
+	 * @since  4.2
413
+	 *
414
+	 * @param  array                  $shortcodes         array of shortcodes and
415
+	 *                                                    descriptions
416
+	 * @param  EE_Datetime_Shortcodes $shortcode_parser   EE_Shortcodes object
417
+	 *
418
+	 * @return array                                        array of shortcodes and
419
+	 *                                                        descriptions
420
+	 */
421
+	public function additional_datetime_shortcodes($shortcodes, $shortcode_parser)
422
+	{
423
+		$shortcodes['[DTT_NAME]'] = esc_html__(
424
+			'This will be parsed to the Title given for a Datetime',
425
+			'event_espresso'
426
+		);
427
+		$shortcodes['[DTT_DESCRIPTION]'] = esc_html__(
428
+			'This will be parsed to the description for a Datetime',
429
+			'event_espresso'
430
+		);
431
+		$shortcodes['[DTT_NAME_OR_DATES]'] = esc_html__(
432
+			'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.',
433
+			'event_espresso'
434
+		);
435
+
436
+		return $shortcodes;
437
+	}
438
+
439
+
440
+	/**
441
+	 * Callback for additional shortcodes parser filter used for adding parser for new
442
+	 * Datetime shortcodes
443
+	 *
444
+	 * @since  4.2
445
+	 *
446
+	 * @param  string                 $parsed     The finished parsed string for the given shortcode.
447
+	 * @param  string                 $shortcode  The shortcode being parsed.
448
+	 * @param  object                 $data       The incoming data object for the Shortcode Parser.
449
+	 * @param  object                 $extra_data The incoming extra date object for the Shortcode
450
+	 *                                            Parser.
451
+	 * @param  EE_Datetime_Shortcodes $shortcode_parser
452
+	 *
453
+	 * @return string                   The new parsed string.
454
+	 */
455
+	public function additional_datetime_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
456
+	{
457
+
458
+		if (! $data instanceof EE_Datetime) {
459
+			return ''; // get out because we can only parse with the datetime object.
460
+		}
461
+
462
+		switch ($shortcode) {
463
+			case '[DTT_NAME]':
464
+				return $data->name();
465
+				break;
466
+			case '[DTT_DESCRIPTION]':
467
+				return $data->description();
468
+				break;
469
+			case '[DTT_NAME_OR_DATES]':
470
+				return $data->get_dtt_display_name(true);
471
+				break;
472
+			default:
473
+				return $parsed;
474
+				break;
475
+		}
476
+	}
477
+
478
+
479
+	public function additional_recipient_details_shortcodes($shortcodes, $shortcode_parser)
480
+	{
481
+		$shortcodes['[RECIPIENT_QUESTION_LIST]'] = esc_html__(
482
+			'This is used to indicate where you want the list of questions and answers to show for the person receiving the message.',
483
+			'event_espresso'
484
+		);
485
+
486
+		return $shortcodes;
487
+	}
488
+
489
+
490
+	/**
491
+	 * Callback for FHEE__EE_Recipient_List_Shortcodes__parser_after filter (dynamic filter).
492
+	 *
493
+	 * @param string         $parsed           The original parsed content for the shortcode
494
+	 * @param string         $shortcode        The shortcode being parsed
495
+	 * @param array          $data             The shortcode parser data array
496
+	 * @param array          $extra_data       The shortcode parser extra data array
497
+	 * @param \EE_Shortcodes $shortcode_parser Shortcode parser.
498
+	 *
499
+	 * @return string
500
+	 */
501
+	public function additional_recipient_details_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
502
+	{
503
+
504
+		if (array($data) && ! isset($data['data'])) {
505
+			return $parsed;
506
+		}
507
+
508
+		$recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
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
+
511
+		if (! $recipient instanceof EE_Messages_Addressee) {
512
+			return $parsed;
513
+		}
514
+
515
+		switch ($shortcode) {
516
+			case '[RECIPIENT_QUESTION_LIST]':
517
+				$att = $recipient->att_obj;
518
+				$registrations_on_attendee = $att instanceof EE_Attendee
519
+					? $recipient->attendees[ $att->ID() ]['reg_objs']
520
+					: array();
521
+				$registrations_on_attendee = empty($registrations_on_attendee) && $recipient->reg_obj instanceof EE_Registration ? array($recipient->reg_obj) : $registrations_on_attendee;
522
+				$answers = array();
523
+
524
+				$template = is_array($data['template']) && isset($data['template']['question_list'])
525
+					? $data['template']['question_list']
526
+					: $extra_data['template']['question_list'];
527
+				$valid_shortcodes = array('question');
528
+
529
+				// if the context is main_content then get all answers for all registrations on this attendee
530
+				if ($data['data'] instanceof EE_Messages_Addressee) {
531
+					foreach ($registrations_on_attendee as $reg) {
532
+						if ($reg instanceof EE_Registration) {
533
+							$anss = ! empty($recipient->registrations[ $reg->ID() ]['ans_objs'])
534
+								? $recipient->registrations[ $reg->ID() ]['ans_objs']
535
+								: array();
536
+							foreach ($anss as $ans) {
537
+								if ($ans instanceof EE_Answer) {
538
+									$answers[ $ans->ID() ] = $ans;
539
+								}
540
+							}
541
+						}
542
+					}
543
+				}
544
+
545
+				// 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.
546
+				if ($data['data'] instanceof EE_Event) {
547
+					$event = $data['data'];
548
+					foreach ($registrations_on_attendee as $reg) {
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']
552
+								: array();
553
+							foreach ($anss as $ans) {
554
+								if ($ans instanceof EE_Answer) {
555
+									$answers[ $ans->ID() ] = $ans;
556
+								}
557
+							}
558
+						}
559
+					}
560
+				}
561
+
562
+				$questions = $questions = isset($recipient->questions) ? $recipient->questions : array();
563
+
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
+				// object on it.
566
+				if (! isset($extra_data['data'])) {
567
+					$extra_data['data'] = $recipient;
568
+				}
569
+
570
+				return $this->_parse_question_list_for_primary_or_recipient_registration(
571
+					$shortcode_parser,
572
+					$questions,
573
+					$answers,
574
+					$template,
575
+					$valid_shortcodes,
576
+					$extra_data
577
+				);
578
+				break;
579
+
580
+			default:
581
+				return $parsed;
582
+				break;
583
+		}
584
+	}
585
+
586
+
587
+	public function additional_primary_registration_details_shortcodes($shortcodes, $shortcode_parser)
588
+	{
589
+		$shortcodes['[PRIMARY_REGISTRANT_QUESTION_LIST]'] = esc_html__(
590
+			'This is used to indicate the questions and answers for the primary_registrant. It should be placed in the "[attendee_list]" field',
591
+			'event_espresso'
592
+		);
593
+
594
+		return $shortcodes;
595
+	}
596
+
597
+
598
+	/**
599
+	 * Callback for FHEE__EE_Primary_Registration_List_Shortcodes__parser_after filter (dynamic filter).
600
+	 *
601
+	 * @param string         $parsed           The original parsed content for the shortcode
602
+	 * @param string         $shortcode        The shortcode being parsed
603
+	 * @param array          $data             The shortcode parser data array
604
+	 * @param array          $extra_data       The shortcode parser extra data array
605
+	 * @param \EE_Shortcodes $shortcode_parser Shortcode parser.
606
+	 *
607
+	 * @return string
608
+	 */
609
+	public function additional_primary_registration_details_parser(
610
+		$parsed,
611
+		$shortcode,
612
+		$data,
613
+		$extra_data,
614
+		$shortcode_parser
615
+	) {
616
+		if (array($data) && ! isset($data['data'])) {
617
+			return $parsed;
618
+		}
619
+
620
+		$recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
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
+
623
+		if (! $recipient instanceof EE_Messages_Addressee) {
624
+			return $parsed;
625
+		}
626
+
627
+		switch ($shortcode) {
628
+			case '[PRIMARY_REGISTRANT_QUESTION_LIST]':
629
+				if (! $recipient->primary_att_obj instanceof EE_Attendee || ! $recipient->primary_reg_obj instanceof EE_Registration) {
630
+					return '';
631
+				}
632
+				$registration = $recipient->primary_reg_obj;
633
+				$answers = isset($recipient->registrations[ $registration->ID() ]['ans_objs'])
634
+					? $recipient->registrations[ $registration->ID() ]['ans_objs']
635
+					: array();
636
+				if (empty($answers)) {
637
+					return '';
638
+				}
639
+				$template = is_array($data['template']) && isset($data['template']['question_list'])
640
+					? $data['template']['question_list']
641
+					: $extra_data['template']['question_list'];
642
+				$valid_shortcodes = array('question');
643
+				$answers = $recipient->registrations[ $registration->ID() ]['ans_objs'];
644
+				$questions = isset($recipient->questions) ? $recipient->questions : array();
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
+				// object on it.
647
+				if (! isset($extra_data['data'])) {
648
+					$extra_data['data'] = $recipient;
649
+				}
650
+				return $this->_parse_question_list_for_primary_or_recipient_registration(
651
+					$shortcode_parser,
652
+					$questions,
653
+					$answers,
654
+					$template,
655
+					$valid_shortcodes,
656
+					$extra_data
657
+				);
658
+				break;
659
+
660
+			default:
661
+				return $parsed;
662
+				break;
663
+		}
664
+	}
665
+
666
+
667
+	/**
668
+	 * Takes care of registering the  message types that are only available in caffeinated EE.
669
+	 *
670
+	 * @since   4.3.2
671
+	 *
672
+	 * @return  void
673
+	 */
674
+	public function register_caf_message_types()
675
+	{
676
+		// register newsletter message type
677
+		$setup_args = array(
678
+			'mtfilename'                                       => 'EE_Newsletter_message_type.class.php',
679
+			'autoloadpaths'                                    => array(
680
+				EE_CAF_LIBRARIES . 'messages/message_type/newsletter/',
681
+			),
682
+			'messengers_to_activate_with'                      => array('email'),
683
+			'messengers_to_validate_with'                      => array('email'),
684
+			'messengers_supporting_default_template_pack_with' => array('email'),
685
+		);
686
+		EE_Register_Message_Type::register('newsletter', $setup_args);
687
+
688
+		// register payment reminder message type
689
+		$setup_args = array(
690
+			'mtfilename'                                       => 'EE_Payment_Reminder_message_type.class.php',
691
+			'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'),
692
+			'messengers_to_activate_with'                      => array('email'),
693
+			'messengers_to_validate_with'                      => array('email'),
694
+			'messengers_supporting_default_template_pack_with' => array('email'),
695
+		);
696
+		EE_Register_Message_Type::register('payment_reminder', $setup_args);
697
+
698
+		// register payment declined message type
699
+		$setup_args = array(
700
+			'mtfilename'                                       => 'EE_Payment_Declined_message_type.class.php',
701
+			'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'),
702
+			'messengers_to_activate_with'                      => array('email'),
703
+			'messengers_to_validate_with'                      => array('email'),
704
+			'messengers_supporting_default_template_pack_with' => array('email'),
705
+		);
706
+		EE_Register_Message_Type::register('payment_declined', $setup_args);
707
+
708
+		// register registration declined message type
709
+		$setup_args = array(
710
+			'mtfilename'                                       => 'EE_Declined_Registration_message_type.class.php',
711
+			'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'),
712
+			'messengers_to_activate_with'                      => array('email'),
713
+			'messengers_to_validate_with'                      => array('email'),
714
+			'messengers_supporting_default_template_pack_with' => array('email'),
715
+		);
716
+		EE_Register_Message_Type::register('declined_registration', $setup_args);
717
+
718
+		// register registration cancelled message type
719
+		$setup_args = array(
720
+			'mtfilename'                                       => 'EE_Cancelled_Registration_message_type.class.php',
721
+			'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'),
722
+			'messengers_to_activate_with'                      => array('email'),
723
+			'messengers_to_validate_with'                      => array('email'),
724
+			'messengers_supporting_default_template_pack_with' => array('email'),
725
+		);
726
+		EE_Register_Message_Type::register('cancelled_registration', $setup_args);
727
+
728
+
729
+		// register payment failed message type
730
+		$setup_args = array(
731
+			'mtfilename'                                       => 'EE_Payment_Failed_message_type.class.php',
732
+			'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'),
733
+			'messengers_to_activate_with'                      => array('email'),
734
+			'messengers_to_validate_with'                      => array('email'),
735
+			'messengers_supporting_default_template_pack_with' => array('email'),
736
+		);
737
+		EE_Register_Message_Type::register('payment_failed', $setup_args);
738
+
739
+		// register payment declined message type
740
+		$setup_args = array(
741
+			'mtfilename'                                       => 'EE_Payment_Cancelled_message_type.class.php',
742
+			'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'),
743
+			'messengers_to_activate_with'                      => array('email'),
744
+			'messengers_to_validate_with'                      => array('email'),
745
+			'messengers_supporting_default_template_pack_with' => array('email'),
746
+		);
747
+		EE_Register_Message_Type::register('payment_cancelled', $setup_args);
748
+	}
749
+
750
+
751
+	/**
752
+	 * Takes care of registering the  shortcode libraries implemented with caffeinated EE and set up related items.
753
+	 *
754
+	 * @since   4.3.2
755
+	 *
756
+	 * @return void
757
+	 */
758
+	public function register_caf_shortcodes()
759
+	{
760
+		$setup_args = array(
761
+			'autoloadpaths'                 => array(
762
+				EE_CAF_LIBRARIES . 'shortcodes/',
763
+			),
764
+			'msgr_validator_callback'       => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'),
765
+			'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'),
766
+			'list_type_shortcodes'          => array('[NEWSLETTER_CONTENT]'),
767
+		);
768
+		EE_Register_Messages_Shortcode_Library::register('newsletter', $setup_args);
769
+	}
770
+
771
+
772
+	/**
773
+	 * Parses a question list shortcode using given data and template
774
+	 *
775
+	 * @param \EE_Shortcodes $shortcode_parser
776
+	 * @param EE_Question[]  $questions        An array of questions indexed by answer id.
777
+	 * @param EE_Answer[]    $answers          An array of answer objects
778
+	 * @param string         $template         Template content to be parsed.
779
+	 * @param array          $valid_shortcodes Valid shortcodes for the template being parsed.
780
+	 * @param array          $extra_data       Extra data that might be used when parsing the template.
781
+	 */
782
+	protected function _parse_question_list_for_primary_or_recipient_registration(
783
+		$shortcode_parser,
784
+		$questions,
785
+		$answers,
786
+		$template,
787
+		$valid_shortcodes,
788
+		$extra_data
789
+	) {
790
+		$question_list = '';
791
+		/** @var EEH_Parse_Shortcodes $shortcode_helper */
792
+		$shortcode_helper = $shortcode_parser->get_shortcode_helper();
793
+		foreach ($answers as $answer) {
794
+			if ($answer instanceof EE_Answer) {
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;
797
+				$question = ! $question instanceof EE_Question ? $answer->question() : $question;
798
+				if (
799
+					! $question instanceof EE_Question
800
+					|| (
801
+						$question instanceof EE_Question
802
+						&& $question->admin_only()
803
+					)
804
+				) {
805
+					continue;
806
+				}
807
+				$question_list .= $shortcode_helper->parse_question_list_template(
808
+					$template,
809
+					$answer,
810
+					$valid_shortcodes,
811
+					$extra_data
812
+				);
813
+			}
814
+		}
815
+		return $question_list;
816
+	}
817 817
 }
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/Paypal_Pro/EE_PMT_Paypal_Pro.pm.php 2 patches
Indentation   +178 added lines, -178 removed lines patch added patch discarded remove patch
@@ -14,182 +14,182 @@
 block discarded – undo
14 14
 class EE_PMT_Paypal_Pro extends EE_PMT_Base
15 15
 {
16 16
 
17
-    /**
18
-     * @param EE_Payment_Method $pm_instance
19
-     * @return EE_PMT_Paypal_Pro
20
-     */
21
-    public function __construct($pm_instance = null)
22
-    {
23
-        require_once($this->file_folder() . 'EEG_Paypal_Pro.gateway.php');
24
-        $this->_gateway = new EEG_Paypal_Pro();
25
-        $this->_pretty_name = esc_html__("Paypal Pro", 'event_espresso');
26
-        $this->_default_description = esc_html__('Please provide the following billing information.', 'event_espresso');
27
-        $this->_requires_https = true;
28
-        parent::__construct($pm_instance);
29
-    }
30
-
31
-
32
-    /**
33
-     * Gets the form for all the settings related to this payment method type
34
-     * @return EE_Payment_Method_Form
35
-     * @throws InvalidArgumentException
36
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
37
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
38
-     */
39
-    public function generate_new_settings_form()
40
-    {
41
-        return new PayPalProSettingsForm(array(), $this->get_help_tab_link());
42
-    }
43
-
44
-
45
-    /**
46
-     * Creates the billing form for this payment method type
47
-     * @param \EE_Transaction $transaction
48
-     * @throws \EE_Error
49
-     * @return EE_Billing_Info_Form
50
-     */
51
-    public function generate_new_billing_form(EE_Transaction $transaction = null)
52
-    {
53
-        $allowed_types = $this->_pm_instance->get_extra_meta('credit_card_types', true);
54
-        // if allowed types is a string or empty array or null...
55
-        if (empty($allowed_types)) {
56
-            $allowed_types = array();
57
-        }
58
-
59
-        $billing_form = new EE_Billing_Attendee_Info_Form(
60
-            $this->_pm_instance,
61
-            array(
62
-                'name' => 'Paypal_Pro_Billing_Form',
63
-            //              'html_id'=> 'ee-Paypal_Pro-billing-form',
64
-                'subsections' => array(
65
-                    'credit_card' => new EE_Credit_Card_Input(
66
-                        array( 'required' => true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => esc_html__('Card Number', 'event_espresso'))
67
-                    ),
68
-                    'credit_card_type' => new EE_Select_Input(
69
-                        // the options are set dynamically
70
-                        array_intersect_key(EE_PMT_Paypal_Pro::card_types_supported(), array_flip($allowed_types)),
71
-                        array( 'required' => true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => esc_html__('Card Type', 'event_espresso'))
72
-                    ),
73
-                    'exp_month' => new EE_Credit_Card_Month_Input(
74
-                        true,
75
-                        array( 'required' => true, 'html_class' => 'ee-billing-qstn', 'html_label_text' =>  esc_html__('Expiry Month', 'event_espresso')  )
76
-                    ),
77
-                    'exp_year' => new EE_Credit_Card_Year_Input(
78
-                        array( 'required' => true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => esc_html__('Expiry Year', 'event_espresso')  )
79
-                    ),
80
-                    'cvv' => new EE_CVV_Input(
81
-                        array( 'required' => true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => esc_html__('CVV', 'event_espresso') )
82
-                    ),
83
-                )
84
-            )
85
-        );
86
-        return $this->apply_billing_form_debug_settings($billing_form);
87
-    }
88
-
89
-
90
-
91
-    /**
92
-     * apply_billing_form_debug_settings
93
-     * applies debug data to the form
94
-     *
95
-     * @param \EE_Billing_Info_Form $billing_form
96
-     * @return \EE_Billing_Info_Form
97
-     */
98
-    public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form)
99
-    {
100
-        if ($this->_pm_instance->debug_mode()) {
101
-            $billing_form->add_subsections(
102
-                array( 'fyi_about_autofill' => $billing_form->payment_fields_autofilled_notice_html() ),
103
-                'credit_card'
104
-            );
105
-            $billing_form->add_subsections(
106
-                array( 'debug_content' => new EE_Form_Section_HTML_From_Template(dirname(__FILE__) . '/templates/paypal_pro_debug_info.template.php')),
107
-                'first_name'
108
-            );
109
-            $billing_form->get_input('credit_card_type')->set_default('Visa');
110
-            $billing_form->get_input('exp_year')->set_default(2018);
111
-            $billing_form->get_input('cvv')->set_default('115');
112
-        }
113
-        return $billing_form;
114
-    }
115
-
116
-
117
-
118
-    /**
119
-     * Returns an array of all the payment cards possibly supported by paypal pro.
120
-     * Keys are their values, values are their pretty names.
121
-     * @return array
122
-     */
123
-    public static function card_types_supported()
124
-    {
125
-        return array(
126
-            'Visa' =>  esc_html__("Visa", 'event_espresso'),
127
-            'MasterCard' =>  esc_html__("MasterCard", 'event_espresso'),
128
-            'Amex' =>  esc_html__("American Express", 'event_espresso'),
129
-            'Discover' =>  esc_html__("Discover", 'event_espresso')
130
-            );
131
-    }
132
-
133
-
134
-
135
-    /**
136
-     * Adds the help tab
137
-     * @see EE_PMT_Base::help_tabs_config()
138
-     * @return array
139
-     */
140
-    public function help_tabs_config()
141
-    {
142
-        return array(
143
-            $this->get_help_tab_name() => array(
144
-                        'title' => esc_html__('PayPal Pro Settings', 'event_espresso'),
145
-                        'filename' => 'payment_methods_overview_paypalpro'
146
-                        ),
147
-        );
148
-    }
149
-
150
-    /**
151
-     * Overrides parent's _get_billing_values_from_form because we want to
152
-     * get the country's 2-character ISO code, not the name like most gateways
153
-     * @param EE_Billing_Info_Form $billing_form
154
-     * @return array
155
-     */
156
-    protected function _get_billing_values_from_form($billing_form)
157
-    {
158
-        $billing_values = parent::_get_billing_values_from_form($billing_form);
159
-        $billing_values['country'] = $billing_form->get_input_value('country');
160
-        $billing_values['credit_card_type'] = $billing_form->get_input_value('credit_card_type');
161
-        return $billing_values;
162
-    }
163
-
164
-    /**
165
-     * Override parent to account for a change in extra meta inputs in 4.9.75.p
166
-     * @since 4.9.79.p
167
-     * @param EE_Payment_Method $payment_method_instance
168
-     * @throws EE_Error
169
-     * @throws InvalidArgumentException
170
-     * @throws ReflectionException
171
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
172
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
173
-     */
174
-    public function set_instance($payment_method_instance)
175
-    {
176
-        // Check for the old extra meta inputs
177
-        $old_extra_metas = EEM_Extra_Meta::instance()->get_all(
178
-            [
179
-                [
180
-                    'EXM_type' => 'Payment_Method',
181
-                    'OBJ_ID' => $payment_method_instance->ID(),
182
-                    'EXM_key' => ['IN', ['username', 'password', 'signature']],
183
-                ]
184
-            ]
185
-        );
186
-        // If they existed, set the new ones instead
187
-        if (!empty($old_extra_metas)) {
188
-            foreach ($old_extra_metas as $old_extra_meta) {
189
-                $old_extra_meta->set('EXM_key', 'api_' . $old_extra_meta->get('EXM_key'));
190
-                $old_extra_meta->save();
191
-            }
192
-        }
193
-        return parent::set_instance($payment_method_instance);
194
-    }
17
+	/**
18
+	 * @param EE_Payment_Method $pm_instance
19
+	 * @return EE_PMT_Paypal_Pro
20
+	 */
21
+	public function __construct($pm_instance = null)
22
+	{
23
+		require_once($this->file_folder() . 'EEG_Paypal_Pro.gateway.php');
24
+		$this->_gateway = new EEG_Paypal_Pro();
25
+		$this->_pretty_name = esc_html__("Paypal Pro", 'event_espresso');
26
+		$this->_default_description = esc_html__('Please provide the following billing information.', 'event_espresso');
27
+		$this->_requires_https = true;
28
+		parent::__construct($pm_instance);
29
+	}
30
+
31
+
32
+	/**
33
+	 * Gets the form for all the settings related to this payment method type
34
+	 * @return EE_Payment_Method_Form
35
+	 * @throws InvalidArgumentException
36
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
37
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
38
+	 */
39
+	public function generate_new_settings_form()
40
+	{
41
+		return new PayPalProSettingsForm(array(), $this->get_help_tab_link());
42
+	}
43
+
44
+
45
+	/**
46
+	 * Creates the billing form for this payment method type
47
+	 * @param \EE_Transaction $transaction
48
+	 * @throws \EE_Error
49
+	 * @return EE_Billing_Info_Form
50
+	 */
51
+	public function generate_new_billing_form(EE_Transaction $transaction = null)
52
+	{
53
+		$allowed_types = $this->_pm_instance->get_extra_meta('credit_card_types', true);
54
+		// if allowed types is a string or empty array or null...
55
+		if (empty($allowed_types)) {
56
+			$allowed_types = array();
57
+		}
58
+
59
+		$billing_form = new EE_Billing_Attendee_Info_Form(
60
+			$this->_pm_instance,
61
+			array(
62
+				'name' => 'Paypal_Pro_Billing_Form',
63
+			//              'html_id'=> 'ee-Paypal_Pro-billing-form',
64
+				'subsections' => array(
65
+					'credit_card' => new EE_Credit_Card_Input(
66
+						array( 'required' => true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => esc_html__('Card Number', 'event_espresso'))
67
+					),
68
+					'credit_card_type' => new EE_Select_Input(
69
+						// the options are set dynamically
70
+						array_intersect_key(EE_PMT_Paypal_Pro::card_types_supported(), array_flip($allowed_types)),
71
+						array( 'required' => true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => esc_html__('Card Type', 'event_espresso'))
72
+					),
73
+					'exp_month' => new EE_Credit_Card_Month_Input(
74
+						true,
75
+						array( 'required' => true, 'html_class' => 'ee-billing-qstn', 'html_label_text' =>  esc_html__('Expiry Month', 'event_espresso')  )
76
+					),
77
+					'exp_year' => new EE_Credit_Card_Year_Input(
78
+						array( 'required' => true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => esc_html__('Expiry Year', 'event_espresso')  )
79
+					),
80
+					'cvv' => new EE_CVV_Input(
81
+						array( 'required' => true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => esc_html__('CVV', 'event_espresso') )
82
+					),
83
+				)
84
+			)
85
+		);
86
+		return $this->apply_billing_form_debug_settings($billing_form);
87
+	}
88
+
89
+
90
+
91
+	/**
92
+	 * apply_billing_form_debug_settings
93
+	 * applies debug data to the form
94
+	 *
95
+	 * @param \EE_Billing_Info_Form $billing_form
96
+	 * @return \EE_Billing_Info_Form
97
+	 */
98
+	public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form)
99
+	{
100
+		if ($this->_pm_instance->debug_mode()) {
101
+			$billing_form->add_subsections(
102
+				array( 'fyi_about_autofill' => $billing_form->payment_fields_autofilled_notice_html() ),
103
+				'credit_card'
104
+			);
105
+			$billing_form->add_subsections(
106
+				array( 'debug_content' => new EE_Form_Section_HTML_From_Template(dirname(__FILE__) . '/templates/paypal_pro_debug_info.template.php')),
107
+				'first_name'
108
+			);
109
+			$billing_form->get_input('credit_card_type')->set_default('Visa');
110
+			$billing_form->get_input('exp_year')->set_default(2018);
111
+			$billing_form->get_input('cvv')->set_default('115');
112
+		}
113
+		return $billing_form;
114
+	}
115
+
116
+
117
+
118
+	/**
119
+	 * Returns an array of all the payment cards possibly supported by paypal pro.
120
+	 * Keys are their values, values are their pretty names.
121
+	 * @return array
122
+	 */
123
+	public static function card_types_supported()
124
+	{
125
+		return array(
126
+			'Visa' =>  esc_html__("Visa", 'event_espresso'),
127
+			'MasterCard' =>  esc_html__("MasterCard", 'event_espresso'),
128
+			'Amex' =>  esc_html__("American Express", 'event_espresso'),
129
+			'Discover' =>  esc_html__("Discover", 'event_espresso')
130
+			);
131
+	}
132
+
133
+
134
+
135
+	/**
136
+	 * Adds the help tab
137
+	 * @see EE_PMT_Base::help_tabs_config()
138
+	 * @return array
139
+	 */
140
+	public function help_tabs_config()
141
+	{
142
+		return array(
143
+			$this->get_help_tab_name() => array(
144
+						'title' => esc_html__('PayPal Pro Settings', 'event_espresso'),
145
+						'filename' => 'payment_methods_overview_paypalpro'
146
+						),
147
+		);
148
+	}
149
+
150
+	/**
151
+	 * Overrides parent's _get_billing_values_from_form because we want to
152
+	 * get the country's 2-character ISO code, not the name like most gateways
153
+	 * @param EE_Billing_Info_Form $billing_form
154
+	 * @return array
155
+	 */
156
+	protected function _get_billing_values_from_form($billing_form)
157
+	{
158
+		$billing_values = parent::_get_billing_values_from_form($billing_form);
159
+		$billing_values['country'] = $billing_form->get_input_value('country');
160
+		$billing_values['credit_card_type'] = $billing_form->get_input_value('credit_card_type');
161
+		return $billing_values;
162
+	}
163
+
164
+	/**
165
+	 * Override parent to account for a change in extra meta inputs in 4.9.75.p
166
+	 * @since 4.9.79.p
167
+	 * @param EE_Payment_Method $payment_method_instance
168
+	 * @throws EE_Error
169
+	 * @throws InvalidArgumentException
170
+	 * @throws ReflectionException
171
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
172
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
173
+	 */
174
+	public function set_instance($payment_method_instance)
175
+	{
176
+		// Check for the old extra meta inputs
177
+		$old_extra_metas = EEM_Extra_Meta::instance()->get_all(
178
+			[
179
+				[
180
+					'EXM_type' => 'Payment_Method',
181
+					'OBJ_ID' => $payment_method_instance->ID(),
182
+					'EXM_key' => ['IN', ['username', 'password', 'signature']],
183
+				]
184
+			]
185
+		);
186
+		// If they existed, set the new ones instead
187
+		if (!empty($old_extra_metas)) {
188
+			foreach ($old_extra_metas as $old_extra_meta) {
189
+				$old_extra_meta->set('EXM_key', 'api_' . $old_extra_meta->get('EXM_key'));
190
+				$old_extra_meta->save();
191
+			}
192
+		}
193
+		return parent::set_instance($payment_method_instance);
194
+	}
195 195
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
      */
21 21
     public function __construct($pm_instance = null)
22 22
     {
23
-        require_once($this->file_folder() . 'EEG_Paypal_Pro.gateway.php');
23
+        require_once($this->file_folder().'EEG_Paypal_Pro.gateway.php');
24 24
         $this->_gateway = new EEG_Paypal_Pro();
25 25
         $this->_pretty_name = esc_html__("Paypal Pro", 'event_espresso');
26 26
         $this->_default_description = esc_html__('Please provide the following billing information.', 'event_espresso');
@@ -63,22 +63,22 @@  discard block
 block discarded – undo
63 63
             //              'html_id'=> 'ee-Paypal_Pro-billing-form',
64 64
                 'subsections' => array(
65 65
                     'credit_card' => new EE_Credit_Card_Input(
66
-                        array( 'required' => true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => esc_html__('Card Number', 'event_espresso'))
66
+                        array('required' => true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => esc_html__('Card Number', 'event_espresso'))
67 67
                     ),
68 68
                     'credit_card_type' => new EE_Select_Input(
69 69
                         // the options are set dynamically
70 70
                         array_intersect_key(EE_PMT_Paypal_Pro::card_types_supported(), array_flip($allowed_types)),
71
-                        array( 'required' => true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => esc_html__('Card Type', 'event_espresso'))
71
+                        array('required' => true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => esc_html__('Card Type', 'event_espresso'))
72 72
                     ),
73 73
                     'exp_month' => new EE_Credit_Card_Month_Input(
74 74
                         true,
75
-                        array( 'required' => true, 'html_class' => 'ee-billing-qstn', 'html_label_text' =>  esc_html__('Expiry Month', 'event_espresso')  )
75
+                        array('required' => true, 'html_class' => 'ee-billing-qstn', 'html_label_text' =>  esc_html__('Expiry Month', 'event_espresso'))
76 76
                     ),
77 77
                     'exp_year' => new EE_Credit_Card_Year_Input(
78
-                        array( 'required' => true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => esc_html__('Expiry Year', 'event_espresso')  )
78
+                        array('required' => true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => esc_html__('Expiry Year', 'event_espresso'))
79 79
                     ),
80 80
                     'cvv' => new EE_CVV_Input(
81
-                        array( 'required' => true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => esc_html__('CVV', 'event_espresso') )
81
+                        array('required' => true, 'html_class' => 'ee-billing-qstn', 'html_label_text' => esc_html__('CVV', 'event_espresso'))
82 82
                     ),
83 83
                 )
84 84
             )
@@ -99,11 +99,11 @@  discard block
 block discarded – undo
99 99
     {
100 100
         if ($this->_pm_instance->debug_mode()) {
101 101
             $billing_form->add_subsections(
102
-                array( 'fyi_about_autofill' => $billing_form->payment_fields_autofilled_notice_html() ),
102
+                array('fyi_about_autofill' => $billing_form->payment_fields_autofilled_notice_html()),
103 103
                 'credit_card'
104 104
             );
105 105
             $billing_form->add_subsections(
106
-                array( 'debug_content' => new EE_Form_Section_HTML_From_Template(dirname(__FILE__) . '/templates/paypal_pro_debug_info.template.php')),
106
+                array('debug_content' => new EE_Form_Section_HTML_From_Template(dirname(__FILE__).'/templates/paypal_pro_debug_info.template.php')),
107 107
                 'first_name'
108 108
             );
109 109
             $billing_form->get_input('credit_card_type')->set_default('Visa');
@@ -184,9 +184,9 @@  discard block
 block discarded – undo
184 184
             ]
185 185
         );
186 186
         // If they existed, set the new ones instead
187
-        if (!empty($old_extra_metas)) {
187
+        if ( ! empty($old_extra_metas)) {
188 188
             foreach ($old_extra_metas as $old_extra_meta) {
189
-                $old_extra_meta->set('EXM_key', 'api_' . $old_extra_meta->get('EXM_key'));
189
+                $old_extra_meta->set('EXM_key', 'api_'.$old_extra_meta->get('EXM_key'));
190 190
                 $old_extra_meta->save();
191 191
             }
192 192
         }
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   +595 added lines, -595 removed lines patch added patch discarded remove patch
@@ -26,417 +26,417 @@  discard block
 block discarded – undo
26 26
 class EEG_Aim extends EE_Onsite_Gateway
27 27
 {
28 28
 
29
-    const LIVE_URL    = 'https://secure2.authorize.net/gateway/transact.dll'; // Authnet URL
30
-
31
-    const SANDBOX_URL = 'https://test.authorize.net/gateway/transact.dll';
32
-
33
-    protected $_login_id;
34
-
35
-    protected $_transaction_key;
36
-
37
-    protected $_currencies_supported = array(
38
-        'AUD',
39
-        'USD',
40
-        'CAD',
41
-        'EUR',
42
-        'GBP',
43
-        'NZD',
44
-    );
45
-
46
-    /**
47
-     * Whether to send test transactions (even to live site)
48
-     *
49
-     * @var boolean
50
-     */
51
-    protected $_test_transactions;
52
-
53
-    private $VERIFY_PEER = false;
54
-
55
-    private $_x_post_fields = array(
56
-        "version"        => "3.1",
57
-        "delim_char"     => ",",
58
-        "delim_data"     => "TRUE",
59
-        "relay_response" => "FALSE",
60
-        "encap_char"     => "|",
61
-    );
62
-
63
-    private $_additional_line_items = array();
64
-
65
-    /**
66
-     * A list of all fields in the AIM API.
67
-     * Used to warn user if they try to set a field not offered in the API.
68
-     */
69
-    private $_all_aim_fields = array(
70
-        "address",
71
-        "allow_partial_auth",
72
-        "amount",
73
-        "auth_code",
74
-        "authentication_indicator",
75
-        "bank_aba_code",
76
-        "bank_acct_name",
77
-        "bank_acct_num",
78
-        "bank_acct_type",
79
-        "bank_check_number",
80
-        "bank_name",
81
-        "card_code",
82
-        "card_num",
83
-        "cardholder_authentication_value",
84
-        "city",
85
-        "company",
86
-        "country",
87
-        "cust_id",
88
-        "customer_ip",
89
-        "delim_char",
90
-        "delim_data",
91
-        "description",
92
-        "duplicate_window",
93
-        "duty",
94
-        "echeck_type",
95
-        "email",
96
-        "email_customer",
97
-        "encap_char",
98
-        "exp_date",
99
-        "fax",
100
-        "first_name",
101
-        "footer_email_receipt",
102
-        "freight",
103
-        "header_email_receipt",
104
-        "invoice_num",
105
-        "last_name",
106
-        "line_item",
107
-        "login",
108
-        "method",
109
-        "phone",
110
-        "po_num",
111
-        "recurring_billing",
112
-        "relay_response",
113
-        "ship_to_address",
114
-        "ship_to_city",
115
-        "ship_to_company",
116
-        "ship_to_country",
117
-        "ship_to_first_name",
118
-        "ship_to_last_name",
119
-        "ship_to_state",
120
-        "ship_to_zip",
121
-        "split_tender_id",
122
-        "state",
123
-        "tax",
124
-        "tax_exempt",
125
-        "test_request",
126
-        "tran_key",
127
-        "trans_id",
128
-        "type",
129
-        "version",
130
-        "zip",
131
-        "solution_id",
132
-        "currency_code"
133
-    );
134
-
135
-
136
-    /**
137
-     * Gets the URL where the request should go. This is filterable
138
-     *
139
-     * @return string
140
-     */
141
-    protected function _get_server_url()
142
-    {
143
-        return apply_filters(
144
-            'FHEE__EEG_Aim___get_server_url',
145
-            $this->_debug_mode ? self::SANDBOX_URL : self::LIVE_URL,
146
-            $this
147
-        );
148
-    }
149
-
150
-
151
-    /**
152
-     * Asks the gateway to do whatever it does to process the payment. Onsite gateways will
153
-     * usually send a request directly to the payment provider and update the payment's status based on that;
154
-     * whereas offsite gateways will usually just update the payment with the URL and query parameters to use
155
-     * for sending the request via http_remote_request()
156
-     *
157
-     * @param EEI_Payment $payment
158
-     * @param array $billing_info {
159
-     *  @type $credit_card string
160
-     *  @type $cvv string
161
-     *  @type $exp_month string
162
-     *  @type $exp_year string
163
-     *  @see parent::do_direct_payment
164
-     * }
165
-     * @return EEI_Payment updated
166
-     */
167
-    public function do_direct_payment($payment, $billing_info = null)
168
-    {
169
-        // Enable test mode if needed
170
-        // 4007000000027  <-- test successful visa
171
-        // 4222222222222  <-- test failure card number
172
-
173
-        $item_num = 1;
174
-        $transaction = $payment->transaction();
175
-        $gateway_formatter = $this->_get_gateway_formatter();
176
-        $order_description = $this->prepareStringForAuthnet($gateway_formatter->formatOrderDescription($payment));
177
-        $primary_registrant = $transaction->primary_registration();
178
-        // if we're are charging for the full amount, show the normal line items
179
-        // and the itemized total adds up properly
180
-        if ($this->_can_easily_itemize_transaction_for($payment)) {
181
-            $total_line_item = $transaction->total_line_item();
182
-            foreach ($total_line_item->get_items() as $line_item) {
183
-                if ($line_item->quantity() == 0) {
184
-                    continue;
185
-                }
186
-                $this->addLineItem(
187
-                    $item_num++,
188
-                    $gateway_formatter->formatLineItemName($line_item, $payment),
189
-                    $gateway_formatter->formatLineItemDesc($line_item, $payment),
190
-                    $line_item->quantity(),
191
-                    $line_item->unit_price(),
192
-                    'N'
193
-                );
194
-                $order_description .= $this->prepareStringForAuthnet($line_item->desc()) . ', ';
195
-            }
196
-            foreach ($total_line_item->tax_descendants() as $tax_line_item) {
197
-                $this->addLineItem(
198
-                    $item_num++,
199
-                    $tax_line_item->name(),
200
-                    $tax_line_item->desc(),
201
-                    1,
202
-                    $tax_line_item->total(),
203
-                    'N'
204
-                );
205
-            }
206
-        }
207
-
208
-        // start transaction
209
-        // if in debug mode, use authorize.net's sandbox id; otherwise use the Event Espresso partner id
210
-        $partner_id = $this->_debug_mode ? 'AAA100302' : 'AAA105363';
211
-        $this->setField('solution_id', $partner_id);
212
-        $this->setField('amount', $gateway_formatter->formatCurrency($payment->amount()));
213
-        $this->setField('description', substr(rtrim($order_description, ', '), 0, 255));
214
-        $this->_set_sensitive_billing_data($billing_info);
215
-        $this->setField('first_name', $billing_info['first_name']);
216
-        $this->setField('last_name', $billing_info['last_name']);
217
-        $this->setField('email', $billing_info['email']);
218
-        $this->setField('company', $billing_info['company']);
219
-        $this->setField('address', $billing_info['address'] . ' ' . $billing_info['address2']);
220
-        $this->setField('city', $billing_info['city']);
221
-        $this->setField('state', $billing_info['state']);
222
-        $this->setField('country', $billing_info['country']);
223
-        $this->setField('zip', $billing_info['zip']);
224
-        $this->setField('fax', $billing_info['fax']);
225
-        $this->setField('cust_id', $primary_registrant->ID());
226
-        $this->setField('phone', $billing_info['phone']);
227
-        $currency_config = LoaderFactory::getLoader()->load('EE_Currency_Config');
228
-        $this->setField('currency_code', $currency_config->code);
229
-        // invoice_num would be nice to have it be unique per SPCO page-load, that way if users
230
-        // press back, they don't submit a duplicate. However, we may be keeping the user on teh same spco page
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']);
233
-        // tell AIM that any duplicates sent in the next 5 minutes are to be ignored
234
-        $this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS);
235
-
236
-        if ($this->_test_transactions) {
237
-            $this->test_request = "true";
238
-        }
239
-
240
-        // Capture response
241
-        $this->type = "AUTH_CAPTURE";
242
-        $response = $this->_sendRequest($payment);
243
-        if (! empty($response)) {
244
-            if ($response->error_message) {
245
-                $payment->set_status($this->_pay_model->failed_status());
246
-                $payment->set_gateway_response($response->error_message);
247
-            } else {
248
-                $payment_status = $response->approved
249
-                    ? $this->_pay_model->approved_status()
250
-                    : $this->_pay_model->declined_status();
251
-                $payment->set_status($payment_status);
252
-                // make sure we interpret the AMT as a float, not an international string (where periods are thousand separators)
253
-                $payment->set_amount((float) $response->amount);
254
-                $payment->set_gateway_response(
255
-                    sprintf(
256
-                        esc_html__('%1$s (Reason Code: %2$s)', 'event_espresso'),
257
-                        $response->response_reason_text,
258
-                        $response->response_reason_code
259
-                    )
260
-                );
261
-                if ($this->_debug_mode) {
262
-                    $txn_id = $response->invoice_number;
263
-                } else {
264
-                    $txn_id = $response->transaction_id;
265
-                }
266
-                $payment->set_txn_id_chq_nmbr($txn_id);
267
-            }
268
-            $payment->set_extra_accntng($primary_registrant->reg_code());
269
-            $payment->set_details(print_r($response, true));
270
-        } else {
271
-            $payment->set_status($this->_pay_model->failed_status());
272
-            $payment->set_gateway_response(esc_html__("There was no response from Authorize.net", 'event_espresso'));
273
-            $payment->set_details(print_r($response, true));
274
-        }
275
-        return $payment;
276
-    }
277
-
278
-
279
-    /**
280
-     * Sets billing data for the upcoming request to AIM that is considered sensitive;
281
-     * also this method can be overridden by children classes to easily change
282
-     * what billing data gets sent
283
-     *
284
-     * @param array $billing_info
285
-     */
286
-    protected function _set_sensitive_billing_data($billing_info)
287
-    {
288
-        $this->setField('card_num', $billing_info['credit_card']);
289
-        $this->setField('exp_date', $billing_info['exp_month'] . $billing_info['exp_year']);
290
-        $this->setField('card_code', $billing_info['cvv']);
291
-    }
292
-
293
-
294
-    /**
295
-     * Add a line item.
296
-     *
297
-     * @param string $item_id
298
-     * @param string $item_name
299
-     * @param string $item_description
300
-     * @param string $item_quantity
301
-     * @param string $item_unit_price
302
-     * @param string $item_taxable
303
-     */
304
-    public function addLineItem($item_id, $item_name, $item_description, $item_quantity, $item_unit_price, $item_taxable)
305
-    {
306
-        $args = array(
307
-            substr($item_id, 0, 31),
308
-            substr($this->prepareStringForAuthnet($item_name), 0, 31),
309
-            substr($this->prepareStringForAuthnet($item_description), 0, 255),
310
-            number_format(abs($item_quantity), 2, '.', ''),
311
-            number_format(abs($item_unit_price), 2, '.', ''),
312
-            $item_taxable === 'N' ? 'N' : 'Y'
313
-        );
314
-        $this->_additional_line_items[] = implode('<|>', $args);
315
-    }
316
-
317
-
318
-    /**
319
-     * Set an individual name/value pair. This will append x_ to the name
320
-     * before posting.
321
-     *
322
-     * @param string $name
323
-     * @param string $value
324
-     * @throws AuthorizeNetException
325
-     */
326
-    protected function setField($name, $value)
327
-    {
328
-        if (in_array($name, $this->_all_aim_fields)) {
329
-            $this->_x_post_fields[ $name ] = $value;
330
-        } else {
331
-            throw new AuthorizeNetException("Error: no field $name exists in the AIM API.
29
+	const LIVE_URL    = 'https://secure2.authorize.net/gateway/transact.dll'; // Authnet URL
30
+
31
+	const SANDBOX_URL = 'https://test.authorize.net/gateway/transact.dll';
32
+
33
+	protected $_login_id;
34
+
35
+	protected $_transaction_key;
36
+
37
+	protected $_currencies_supported = array(
38
+		'AUD',
39
+		'USD',
40
+		'CAD',
41
+		'EUR',
42
+		'GBP',
43
+		'NZD',
44
+	);
45
+
46
+	/**
47
+	 * Whether to send test transactions (even to live site)
48
+	 *
49
+	 * @var boolean
50
+	 */
51
+	protected $_test_transactions;
52
+
53
+	private $VERIFY_PEER = false;
54
+
55
+	private $_x_post_fields = array(
56
+		"version"        => "3.1",
57
+		"delim_char"     => ",",
58
+		"delim_data"     => "TRUE",
59
+		"relay_response" => "FALSE",
60
+		"encap_char"     => "|",
61
+	);
62
+
63
+	private $_additional_line_items = array();
64
+
65
+	/**
66
+	 * A list of all fields in the AIM API.
67
+	 * Used to warn user if they try to set a field not offered in the API.
68
+	 */
69
+	private $_all_aim_fields = array(
70
+		"address",
71
+		"allow_partial_auth",
72
+		"amount",
73
+		"auth_code",
74
+		"authentication_indicator",
75
+		"bank_aba_code",
76
+		"bank_acct_name",
77
+		"bank_acct_num",
78
+		"bank_acct_type",
79
+		"bank_check_number",
80
+		"bank_name",
81
+		"card_code",
82
+		"card_num",
83
+		"cardholder_authentication_value",
84
+		"city",
85
+		"company",
86
+		"country",
87
+		"cust_id",
88
+		"customer_ip",
89
+		"delim_char",
90
+		"delim_data",
91
+		"description",
92
+		"duplicate_window",
93
+		"duty",
94
+		"echeck_type",
95
+		"email",
96
+		"email_customer",
97
+		"encap_char",
98
+		"exp_date",
99
+		"fax",
100
+		"first_name",
101
+		"footer_email_receipt",
102
+		"freight",
103
+		"header_email_receipt",
104
+		"invoice_num",
105
+		"last_name",
106
+		"line_item",
107
+		"login",
108
+		"method",
109
+		"phone",
110
+		"po_num",
111
+		"recurring_billing",
112
+		"relay_response",
113
+		"ship_to_address",
114
+		"ship_to_city",
115
+		"ship_to_company",
116
+		"ship_to_country",
117
+		"ship_to_first_name",
118
+		"ship_to_last_name",
119
+		"ship_to_state",
120
+		"ship_to_zip",
121
+		"split_tender_id",
122
+		"state",
123
+		"tax",
124
+		"tax_exempt",
125
+		"test_request",
126
+		"tran_key",
127
+		"trans_id",
128
+		"type",
129
+		"version",
130
+		"zip",
131
+		"solution_id",
132
+		"currency_code"
133
+	);
134
+
135
+
136
+	/**
137
+	 * Gets the URL where the request should go. This is filterable
138
+	 *
139
+	 * @return string
140
+	 */
141
+	protected function _get_server_url()
142
+	{
143
+		return apply_filters(
144
+			'FHEE__EEG_Aim___get_server_url',
145
+			$this->_debug_mode ? self::SANDBOX_URL : self::LIVE_URL,
146
+			$this
147
+		);
148
+	}
149
+
150
+
151
+	/**
152
+	 * Asks the gateway to do whatever it does to process the payment. Onsite gateways will
153
+	 * usually send a request directly to the payment provider and update the payment's status based on that;
154
+	 * whereas offsite gateways will usually just update the payment with the URL and query parameters to use
155
+	 * for sending the request via http_remote_request()
156
+	 *
157
+	 * @param EEI_Payment $payment
158
+	 * @param array $billing_info {
159
+	 *  @type $credit_card string
160
+	 *  @type $cvv string
161
+	 *  @type $exp_month string
162
+	 *  @type $exp_year string
163
+	 *  @see parent::do_direct_payment
164
+	 * }
165
+	 * @return EEI_Payment updated
166
+	 */
167
+	public function do_direct_payment($payment, $billing_info = null)
168
+	{
169
+		// Enable test mode if needed
170
+		// 4007000000027  <-- test successful visa
171
+		// 4222222222222  <-- test failure card number
172
+
173
+		$item_num = 1;
174
+		$transaction = $payment->transaction();
175
+		$gateway_formatter = $this->_get_gateway_formatter();
176
+		$order_description = $this->prepareStringForAuthnet($gateway_formatter->formatOrderDescription($payment));
177
+		$primary_registrant = $transaction->primary_registration();
178
+		// if we're are charging for the full amount, show the normal line items
179
+		// and the itemized total adds up properly
180
+		if ($this->_can_easily_itemize_transaction_for($payment)) {
181
+			$total_line_item = $transaction->total_line_item();
182
+			foreach ($total_line_item->get_items() as $line_item) {
183
+				if ($line_item->quantity() == 0) {
184
+					continue;
185
+				}
186
+				$this->addLineItem(
187
+					$item_num++,
188
+					$gateway_formatter->formatLineItemName($line_item, $payment),
189
+					$gateway_formatter->formatLineItemDesc($line_item, $payment),
190
+					$line_item->quantity(),
191
+					$line_item->unit_price(),
192
+					'N'
193
+				);
194
+				$order_description .= $this->prepareStringForAuthnet($line_item->desc()) . ', ';
195
+			}
196
+			foreach ($total_line_item->tax_descendants() as $tax_line_item) {
197
+				$this->addLineItem(
198
+					$item_num++,
199
+					$tax_line_item->name(),
200
+					$tax_line_item->desc(),
201
+					1,
202
+					$tax_line_item->total(),
203
+					'N'
204
+				);
205
+			}
206
+		}
207
+
208
+		// start transaction
209
+		// if in debug mode, use authorize.net's sandbox id; otherwise use the Event Espresso partner id
210
+		$partner_id = $this->_debug_mode ? 'AAA100302' : 'AAA105363';
211
+		$this->setField('solution_id', $partner_id);
212
+		$this->setField('amount', $gateway_formatter->formatCurrency($payment->amount()));
213
+		$this->setField('description', substr(rtrim($order_description, ', '), 0, 255));
214
+		$this->_set_sensitive_billing_data($billing_info);
215
+		$this->setField('first_name', $billing_info['first_name']);
216
+		$this->setField('last_name', $billing_info['last_name']);
217
+		$this->setField('email', $billing_info['email']);
218
+		$this->setField('company', $billing_info['company']);
219
+		$this->setField('address', $billing_info['address'] . ' ' . $billing_info['address2']);
220
+		$this->setField('city', $billing_info['city']);
221
+		$this->setField('state', $billing_info['state']);
222
+		$this->setField('country', $billing_info['country']);
223
+		$this->setField('zip', $billing_info['zip']);
224
+		$this->setField('fax', $billing_info['fax']);
225
+		$this->setField('cust_id', $primary_registrant->ID());
226
+		$this->setField('phone', $billing_info['phone']);
227
+		$currency_config = LoaderFactory::getLoader()->load('EE_Currency_Config');
228
+		$this->setField('currency_code', $currency_config->code);
229
+		// invoice_num would be nice to have it be unique per SPCO page-load, that way if users
230
+		// press back, they don't submit a duplicate. However, we may be keeping the user on teh same spco page
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']);
233
+		// tell AIM that any duplicates sent in the next 5 minutes are to be ignored
234
+		$this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS);
235
+
236
+		if ($this->_test_transactions) {
237
+			$this->test_request = "true";
238
+		}
239
+
240
+		// Capture response
241
+		$this->type = "AUTH_CAPTURE";
242
+		$response = $this->_sendRequest($payment);
243
+		if (! empty($response)) {
244
+			if ($response->error_message) {
245
+				$payment->set_status($this->_pay_model->failed_status());
246
+				$payment->set_gateway_response($response->error_message);
247
+			} else {
248
+				$payment_status = $response->approved
249
+					? $this->_pay_model->approved_status()
250
+					: $this->_pay_model->declined_status();
251
+				$payment->set_status($payment_status);
252
+				// make sure we interpret the AMT as a float, not an international string (where periods are thousand separators)
253
+				$payment->set_amount((float) $response->amount);
254
+				$payment->set_gateway_response(
255
+					sprintf(
256
+						esc_html__('%1$s (Reason Code: %2$s)', 'event_espresso'),
257
+						$response->response_reason_text,
258
+						$response->response_reason_code
259
+					)
260
+				);
261
+				if ($this->_debug_mode) {
262
+					$txn_id = $response->invoice_number;
263
+				} else {
264
+					$txn_id = $response->transaction_id;
265
+				}
266
+				$payment->set_txn_id_chq_nmbr($txn_id);
267
+			}
268
+			$payment->set_extra_accntng($primary_registrant->reg_code());
269
+			$payment->set_details(print_r($response, true));
270
+		} else {
271
+			$payment->set_status($this->_pay_model->failed_status());
272
+			$payment->set_gateway_response(esc_html__("There was no response from Authorize.net", 'event_espresso'));
273
+			$payment->set_details(print_r($response, true));
274
+		}
275
+		return $payment;
276
+	}
277
+
278
+
279
+	/**
280
+	 * Sets billing data for the upcoming request to AIM that is considered sensitive;
281
+	 * also this method can be overridden by children classes to easily change
282
+	 * what billing data gets sent
283
+	 *
284
+	 * @param array $billing_info
285
+	 */
286
+	protected function _set_sensitive_billing_data($billing_info)
287
+	{
288
+		$this->setField('card_num', $billing_info['credit_card']);
289
+		$this->setField('exp_date', $billing_info['exp_month'] . $billing_info['exp_year']);
290
+		$this->setField('card_code', $billing_info['cvv']);
291
+	}
292
+
293
+
294
+	/**
295
+	 * Add a line item.
296
+	 *
297
+	 * @param string $item_id
298
+	 * @param string $item_name
299
+	 * @param string $item_description
300
+	 * @param string $item_quantity
301
+	 * @param string $item_unit_price
302
+	 * @param string $item_taxable
303
+	 */
304
+	public function addLineItem($item_id, $item_name, $item_description, $item_quantity, $item_unit_price, $item_taxable)
305
+	{
306
+		$args = array(
307
+			substr($item_id, 0, 31),
308
+			substr($this->prepareStringForAuthnet($item_name), 0, 31),
309
+			substr($this->prepareStringForAuthnet($item_description), 0, 255),
310
+			number_format(abs($item_quantity), 2, '.', ''),
311
+			number_format(abs($item_unit_price), 2, '.', ''),
312
+			$item_taxable === 'N' ? 'N' : 'Y'
313
+		);
314
+		$this->_additional_line_items[] = implode('<|>', $args);
315
+	}
316
+
317
+
318
+	/**
319
+	 * Set an individual name/value pair. This will append x_ to the name
320
+	 * before posting.
321
+	 *
322
+	 * @param string $name
323
+	 * @param string $value
324
+	 * @throws AuthorizeNetException
325
+	 */
326
+	protected function setField($name, $value)
327
+	{
328
+		if (in_array($name, $this->_all_aim_fields)) {
329
+			$this->_x_post_fields[ $name ] = $value;
330
+		} else {
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.");
333
-        }
334
-    }
335
-
336
-
337
-    /**
338
-     * Posts the request to AuthorizeNet & returns response.
339
-     *
340
-     * @param $payment
341
-     * @return \EE_AuthorizeNetAIM_Response
342
-     */
343
-    private function _sendRequest($payment)
344
-    {
345
-        $this->_x_post_fields['login'] = $this->_login_id;
346
-        $this->_x_post_fields['tran_key'] = $this->_transaction_key;
347
-        $x_keys = array();
348
-        foreach ($this->_x_post_fields as $key => $value) {
349
-            $x_keys[] = "x_$key=" . urlencode($this->_get_unsupported_character_remover()->format($value));
350
-        }
351
-        // Add line items
352
-        foreach ($this->_additional_line_items as $key => $value) {
353
-            $x_keys[] =  "x_line_item=" . urlencode($this->_get_unsupported_character_remover()->format($value));
354
-        }
355
-        $this->_log_clean_request($x_keys, $payment);
356
-        $post_url = $this->_get_server_url();
357
-        $curl_request = curl_init($post_url);
358
-        $post_body = implode("&", $x_keys);
359
-        curl_setopt($curl_request, CURLOPT_POSTFIELDS, $post_body);
360
-        curl_setopt($curl_request, CURLOPT_HEADER, 0);
361
-        curl_setopt($curl_request, CURLOPT_TIMEOUT, 45);
362
-        curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1);
363
-        curl_setopt($curl_request, CURLOPT_SSL_VERIFYHOST, 2);
364
-        if ($this->VERIFY_PEER) {
365
-            curl_setopt($curl_request, CURLOPT_CAINFO, dirname(__DIR__) . '/ssl/cert.pem');
366
-        } else {
367
-            curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false);
368
-        }
369
-
370
-        if (preg_match('/xml/', $post_url)) {
371
-            curl_setopt($curl_request, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
372
-        }
373
-
374
-        $response = curl_exec($curl_request);
375
-
376
-        curl_close($curl_request);
377
-        $response_obj =  new EE_AuthorizeNetAIM_Response($response);
378
-
379
-        return $this->_log_and_clean_response($response_obj, $payment);
380
-    }
381
-
382
-
383
-    /**
384
-     * Logs the clean data only
385
-     *
386
-     * @param array $request_array
387
-     * @param EEI_Payment $payment
388
-     */
389
-    protected function _log_clean_request($request_array, $payment)
390
-    {
391
-        $keys_to_filter_out = array('x_card_num', 'x_card_code', 'x_exp_date');
392
-        foreach ($request_array as $index => $keyvaltogether) {
393
-            foreach ($keys_to_filter_out as $key) {
394
-                if (strpos($keyvaltogether, $key) === 0) {
395
-                    // found it at the first character
396
-                    // so its one of them
397
-                    unset($request_array[ $index ]);
398
-                }
399
-            }
400
-        }
401
-        $this->log(
402
-            array(
403
-                'AIM Request sent:' => $request_array,
404
-                'Server URL'        => $this->_get_server_url()
405
-            ),
406
-            $payment
407
-        );
408
-    }
409
-
410
-
411
-
412
-    /**
413
-     * Logs the response and cleans it
414
-     *
415
-     * @param EE_AuthorizeNetAIM_Response $response_obj
416
-     * @param EE_Payment                  $payment
417
-     * @return \EE_AuthorizeNetAIM_Response
418
-     */
419
-    private function _log_and_clean_response($response_obj, $payment)
420
-    {
421
-        $response_obj->account_number = '';
422
-        $this->log(array('AIM Response received:' => (array) $response_obj), $payment);
423
-        return $response_obj;
424
-    }
425
-
426
-    /**
427
-     * Removes characters Authorize.net doesn't handle well.
428
-     * @since 4.9.82.p
429
-     * @param $text
430
-     * @return string
431
-     */
432
-    private function prepareStringForAuthnet($text)
433
-    {
434
-        return str_replace(
435
-            '\'',
436
-            '',
437
-            $text
438
-        );
439
-    }
333
+		}
334
+	}
335
+
336
+
337
+	/**
338
+	 * Posts the request to AuthorizeNet & returns response.
339
+	 *
340
+	 * @param $payment
341
+	 * @return \EE_AuthorizeNetAIM_Response
342
+	 */
343
+	private function _sendRequest($payment)
344
+	{
345
+		$this->_x_post_fields['login'] = $this->_login_id;
346
+		$this->_x_post_fields['tran_key'] = $this->_transaction_key;
347
+		$x_keys = array();
348
+		foreach ($this->_x_post_fields as $key => $value) {
349
+			$x_keys[] = "x_$key=" . urlencode($this->_get_unsupported_character_remover()->format($value));
350
+		}
351
+		// Add line items
352
+		foreach ($this->_additional_line_items as $key => $value) {
353
+			$x_keys[] =  "x_line_item=" . urlencode($this->_get_unsupported_character_remover()->format($value));
354
+		}
355
+		$this->_log_clean_request($x_keys, $payment);
356
+		$post_url = $this->_get_server_url();
357
+		$curl_request = curl_init($post_url);
358
+		$post_body = implode("&", $x_keys);
359
+		curl_setopt($curl_request, CURLOPT_POSTFIELDS, $post_body);
360
+		curl_setopt($curl_request, CURLOPT_HEADER, 0);
361
+		curl_setopt($curl_request, CURLOPT_TIMEOUT, 45);
362
+		curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1);
363
+		curl_setopt($curl_request, CURLOPT_SSL_VERIFYHOST, 2);
364
+		if ($this->VERIFY_PEER) {
365
+			curl_setopt($curl_request, CURLOPT_CAINFO, dirname(__DIR__) . '/ssl/cert.pem');
366
+		} else {
367
+			curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false);
368
+		}
369
+
370
+		if (preg_match('/xml/', $post_url)) {
371
+			curl_setopt($curl_request, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
372
+		}
373
+
374
+		$response = curl_exec($curl_request);
375
+
376
+		curl_close($curl_request);
377
+		$response_obj =  new EE_AuthorizeNetAIM_Response($response);
378
+
379
+		return $this->_log_and_clean_response($response_obj, $payment);
380
+	}
381
+
382
+
383
+	/**
384
+	 * Logs the clean data only
385
+	 *
386
+	 * @param array $request_array
387
+	 * @param EEI_Payment $payment
388
+	 */
389
+	protected function _log_clean_request($request_array, $payment)
390
+	{
391
+		$keys_to_filter_out = array('x_card_num', 'x_card_code', 'x_exp_date');
392
+		foreach ($request_array as $index => $keyvaltogether) {
393
+			foreach ($keys_to_filter_out as $key) {
394
+				if (strpos($keyvaltogether, $key) === 0) {
395
+					// found it at the first character
396
+					// so its one of them
397
+					unset($request_array[ $index ]);
398
+				}
399
+			}
400
+		}
401
+		$this->log(
402
+			array(
403
+				'AIM Request sent:' => $request_array,
404
+				'Server URL'        => $this->_get_server_url()
405
+			),
406
+			$payment
407
+		);
408
+	}
409
+
410
+
411
+
412
+	/**
413
+	 * Logs the response and cleans it
414
+	 *
415
+	 * @param EE_AuthorizeNetAIM_Response $response_obj
416
+	 * @param EE_Payment                  $payment
417
+	 * @return \EE_AuthorizeNetAIM_Response
418
+	 */
419
+	private function _log_and_clean_response($response_obj, $payment)
420
+	{
421
+		$response_obj->account_number = '';
422
+		$this->log(array('AIM Response received:' => (array) $response_obj), $payment);
423
+		return $response_obj;
424
+	}
425
+
426
+	/**
427
+	 * Removes characters Authorize.net doesn't handle well.
428
+	 * @since 4.9.82.p
429
+	 * @param $text
430
+	 * @return string
431
+	 */
432
+	private function prepareStringForAuthnet($text)
433
+	{
434
+		return str_replace(
435
+			'\'',
436
+			'',
437
+			$text
438
+		);
439
+	}
440 440
 }
441 441
 
442 442
 
@@ -452,192 +452,192 @@  discard block
 block discarded – undo
452 452
 class EE_AuthorizeNetAIM_Response
453 453
 {
454 454
 
455
-    const APPROVED = '1';
456
-    const DECLINED = '2';
457
-    const ERROR = '3';
458
-    const HELD = '4';
459
-
460
-    protected $_x_post_fields = array(
461
-        "version"        => "3.1",
462
-        "delim_char"     => ",",
463
-        "delim_data"     => "TRUE",
464
-        "relay_response" => "FALSE",
465
-        "encap_char"     => "|",
466
-    );
467
-    public $approved;
468
-    public $declined;
469
-    public $error;
470
-    public $held;
471
-    public $response_code;
472
-    public $response_subcode;
473
-    public $response_reason_code;
474
-    public $response_reason_text;
475
-    public $authorization_code;
476
-    public $avs_response;
477
-    public $transaction_id;
478
-    public $invoice_number;
479
-    public $description;
480
-    public $amount;
481
-    public $method;
482
-    public $transaction_type;
483
-    public $customer_id;
484
-    public $first_name;
485
-    public $last_name;
486
-    public $company;
487
-    public $address;
488
-    public $city;
489
-    public $state;
490
-    public $zip_code;
491
-    public $country;
492
-    public $phone;
493
-    public $fax;
494
-    public $email_address;
495
-    public $ship_to_first_name;
496
-    public $ship_to_last_name;
497
-    public $ship_to_company;
498
-    public $ship_to_address;
499
-    public $ship_to_city;
500
-    public $ship_to_state;
501
-    public $ship_to_zip_code;
502
-    public $ship_to_country;
503
-    public $tax;
504
-    public $duty;
505
-    public $freight;
506
-    public $tax_exempt;
507
-    public $purchase_order_number;
508
-    public $md5_hash;
509
-    public $card_code_response;
510
-    public $cavv_response; // cardholder_authentication_verification_response
511
-    public $account_number;
512
-    public $card_type;
513
-    public $split_tender_id;
514
-    public $requested_amount;
515
-    public $balance_on_card;
516
-    public $response; // The response string from AuthorizeNet.
517
-    public $error_message;
518
-    private $_response_array = array(); // An array with the split response.
519
-
520
-
521
-    /**
522
-     * Constructor. Parses the AuthorizeNet response string
523
-     *
524
-     * @param string $response The response from the AuthNet server.
525
-     * @var string   $delimiter The delimiter used (default is ",")
526
-     * @var string   $encap_char The encap_char used (default is "|")
527
-     * @var array    $custom_fields Any custom fields set in the request.
528
-     */
529
-
530
-    public function __construct($response)
531
-    {
532
-        $encap_char = $this->_x_post_fields['encap_char'];
533
-        $delimiter = $this->_x_post_fields['delim_char'];
534
-        if ($response) {
535
-            // Split Array
536
-            $this->response = $response;
537
-            if ($encap_char) {
538
-                $this->_response_array = explode($encap_char . $delimiter . $encap_char, substr($response, 1, -1));
539
-            } else {
540
-                $this->_response_array = explode($delimiter, $response);
541
-            }
542
-
543
-            /**
544
-             * If AuthorizeNet doesn't return a delimited response.
545
-             */
546
-            if (count($this->_response_array) < 10) {
547
-                $this->approved = false;
548
-                $this->error = true;
549
-                $this->error_message = sprintf(
550
-                    esc_html__('Unrecognized response from Authorize.net: %1$s', 'event_espresso'),
551
-                    esc_html($response)
552
-                );
553
-                return;
554
-            }
555
-
556
-
557
-
558
-            // Set all fields
559
-            $this->response_code = $this->_response_array[0];
560
-            $this->response_subcode = $this->_response_array[1];
561
-            $this->response_reason_code = $this->_response_array[2];
562
-            $this->response_reason_text = $this->_response_array[3];
563
-            $this->authorization_code = $this->_response_array[4];
564
-            $this->avs_response = $this->_response_array[5];
565
-            $this->transaction_id = $this->_response_array[6];
566
-            $this->invoice_number = $this->_response_array[7];
567
-            $this->description = $this->_response_array[8];
568
-            $this->amount = $this->_response_array[9];
569
-            $this->method = $this->_response_array[10];
570
-            $this->transaction_type = $this->_response_array[11];
571
-            $this->customer_id = $this->_response_array[12];
572
-            $this->first_name = $this->_response_array[13];
573
-            $this->last_name = $this->_response_array[14];
574
-            $this->company = $this->_response_array[15];
575
-            $this->address = $this->_response_array[16];
576
-            $this->city = $this->_response_array[17];
577
-            $this->state = $this->_response_array[18];
578
-            $this->zip_code = $this->_response_array[19];
579
-            $this->country = $this->_response_array[20];
580
-            $this->phone = $this->_response_array[21];
581
-            $this->fax = $this->_response_array[22];
582
-            $this->email_address = $this->_response_array[23];
583
-            $this->ship_to_first_name = $this->_response_array[24];
584
-            $this->ship_to_last_name = $this->_response_array[25];
585
-            $this->ship_to_company = $this->_response_array[26];
586
-            $this->ship_to_address = $this->_response_array[27];
587
-            $this->ship_to_city = $this->_response_array[28];
588
-            $this->ship_to_state = $this->_response_array[29];
589
-            $this->ship_to_zip_code = $this->_response_array[30];
590
-            $this->ship_to_country = $this->_response_array[31];
591
-            $this->tax = $this->_response_array[32];
592
-            $this->duty = $this->_response_array[33];
593
-            $this->freight = $this->_response_array[34];
594
-            $this->tax_exempt = $this->_response_array[35];
595
-            $this->purchase_order_number = $this->_response_array[36];
596
-            $this->md5_hash = $this->_response_array[37];
597
-            $this->card_code_response = $this->_response_array[38];
598
-            $this->cavv_response = $this->_response_array[39];
599
-            $this->account_number = $this->_response_array[50];
600
-            $this->card_type = $this->_response_array[51];
601
-            $this->split_tender_id = $this->_response_array[52];
602
-            $this->requested_amount = $this->_response_array[53];
603
-            $this->balance_on_card = $this->_response_array[54];
604
-
605
-            $this->approved = ($this->response_code === self::APPROVED);
606
-            $this->declined = ($this->response_code === self::DECLINED);
607
-            $this->error = ($this->response_code === self::ERROR);
608
-            $this->held = ($this->response_code === self::HELD);
609
-        } else {
610
-            $this->approved = false;
611
-            $this->error = true;
612
-            $this->error_message = esc_html__(
613
-                'Error connecting to Authorize.net',
614
-                'event_espresso'
615
-            );
616
-        }
617
-    }
455
+	const APPROVED = '1';
456
+	const DECLINED = '2';
457
+	const ERROR = '3';
458
+	const HELD = '4';
459
+
460
+	protected $_x_post_fields = array(
461
+		"version"        => "3.1",
462
+		"delim_char"     => ",",
463
+		"delim_data"     => "TRUE",
464
+		"relay_response" => "FALSE",
465
+		"encap_char"     => "|",
466
+	);
467
+	public $approved;
468
+	public $declined;
469
+	public $error;
470
+	public $held;
471
+	public $response_code;
472
+	public $response_subcode;
473
+	public $response_reason_code;
474
+	public $response_reason_text;
475
+	public $authorization_code;
476
+	public $avs_response;
477
+	public $transaction_id;
478
+	public $invoice_number;
479
+	public $description;
480
+	public $amount;
481
+	public $method;
482
+	public $transaction_type;
483
+	public $customer_id;
484
+	public $first_name;
485
+	public $last_name;
486
+	public $company;
487
+	public $address;
488
+	public $city;
489
+	public $state;
490
+	public $zip_code;
491
+	public $country;
492
+	public $phone;
493
+	public $fax;
494
+	public $email_address;
495
+	public $ship_to_first_name;
496
+	public $ship_to_last_name;
497
+	public $ship_to_company;
498
+	public $ship_to_address;
499
+	public $ship_to_city;
500
+	public $ship_to_state;
501
+	public $ship_to_zip_code;
502
+	public $ship_to_country;
503
+	public $tax;
504
+	public $duty;
505
+	public $freight;
506
+	public $tax_exempt;
507
+	public $purchase_order_number;
508
+	public $md5_hash;
509
+	public $card_code_response;
510
+	public $cavv_response; // cardholder_authentication_verification_response
511
+	public $account_number;
512
+	public $card_type;
513
+	public $split_tender_id;
514
+	public $requested_amount;
515
+	public $balance_on_card;
516
+	public $response; // The response string from AuthorizeNet.
517
+	public $error_message;
518
+	private $_response_array = array(); // An array with the split response.
519
+
520
+
521
+	/**
522
+	 * Constructor. Parses the AuthorizeNet response string
523
+	 *
524
+	 * @param string $response The response from the AuthNet server.
525
+	 * @var string   $delimiter The delimiter used (default is ",")
526
+	 * @var string   $encap_char The encap_char used (default is "|")
527
+	 * @var array    $custom_fields Any custom fields set in the request.
528
+	 */
529
+
530
+	public function __construct($response)
531
+	{
532
+		$encap_char = $this->_x_post_fields['encap_char'];
533
+		$delimiter = $this->_x_post_fields['delim_char'];
534
+		if ($response) {
535
+			// Split Array
536
+			$this->response = $response;
537
+			if ($encap_char) {
538
+				$this->_response_array = explode($encap_char . $delimiter . $encap_char, substr($response, 1, -1));
539
+			} else {
540
+				$this->_response_array = explode($delimiter, $response);
541
+			}
542
+
543
+			/**
544
+			 * If AuthorizeNet doesn't return a delimited response.
545
+			 */
546
+			if (count($this->_response_array) < 10) {
547
+				$this->approved = false;
548
+				$this->error = true;
549
+				$this->error_message = sprintf(
550
+					esc_html__('Unrecognized response from Authorize.net: %1$s', 'event_espresso'),
551
+					esc_html($response)
552
+				);
553
+				return;
554
+			}
555
+
556
+
557
+
558
+			// Set all fields
559
+			$this->response_code = $this->_response_array[0];
560
+			$this->response_subcode = $this->_response_array[1];
561
+			$this->response_reason_code = $this->_response_array[2];
562
+			$this->response_reason_text = $this->_response_array[3];
563
+			$this->authorization_code = $this->_response_array[4];
564
+			$this->avs_response = $this->_response_array[5];
565
+			$this->transaction_id = $this->_response_array[6];
566
+			$this->invoice_number = $this->_response_array[7];
567
+			$this->description = $this->_response_array[8];
568
+			$this->amount = $this->_response_array[9];
569
+			$this->method = $this->_response_array[10];
570
+			$this->transaction_type = $this->_response_array[11];
571
+			$this->customer_id = $this->_response_array[12];
572
+			$this->first_name = $this->_response_array[13];
573
+			$this->last_name = $this->_response_array[14];
574
+			$this->company = $this->_response_array[15];
575
+			$this->address = $this->_response_array[16];
576
+			$this->city = $this->_response_array[17];
577
+			$this->state = $this->_response_array[18];
578
+			$this->zip_code = $this->_response_array[19];
579
+			$this->country = $this->_response_array[20];
580
+			$this->phone = $this->_response_array[21];
581
+			$this->fax = $this->_response_array[22];
582
+			$this->email_address = $this->_response_array[23];
583
+			$this->ship_to_first_name = $this->_response_array[24];
584
+			$this->ship_to_last_name = $this->_response_array[25];
585
+			$this->ship_to_company = $this->_response_array[26];
586
+			$this->ship_to_address = $this->_response_array[27];
587
+			$this->ship_to_city = $this->_response_array[28];
588
+			$this->ship_to_state = $this->_response_array[29];
589
+			$this->ship_to_zip_code = $this->_response_array[30];
590
+			$this->ship_to_country = $this->_response_array[31];
591
+			$this->tax = $this->_response_array[32];
592
+			$this->duty = $this->_response_array[33];
593
+			$this->freight = $this->_response_array[34];
594
+			$this->tax_exempt = $this->_response_array[35];
595
+			$this->purchase_order_number = $this->_response_array[36];
596
+			$this->md5_hash = $this->_response_array[37];
597
+			$this->card_code_response = $this->_response_array[38];
598
+			$this->cavv_response = $this->_response_array[39];
599
+			$this->account_number = $this->_response_array[50];
600
+			$this->card_type = $this->_response_array[51];
601
+			$this->split_tender_id = $this->_response_array[52];
602
+			$this->requested_amount = $this->_response_array[53];
603
+			$this->balance_on_card = $this->_response_array[54];
604
+
605
+			$this->approved = ($this->response_code === self::APPROVED);
606
+			$this->declined = ($this->response_code === self::DECLINED);
607
+			$this->error = ($this->response_code === self::ERROR);
608
+			$this->held = ($this->response_code === self::HELD);
609
+		} else {
610
+			$this->approved = false;
611
+			$this->error = true;
612
+			$this->error_message = esc_html__(
613
+				'Error connecting to Authorize.net',
614
+				'event_espresso'
615
+			);
616
+		}
617
+	}
618 618
 }
619 619
 
620 620
 if (! class_exists('AuthorizeNetException')) {
621
-    /**
622
-     * Class AuthorizeNetException
623
-     *
624
-     * @package    AuthorizeNet
625
-     */
626
-    class AuthorizeNetException extends Exception
627
-    {
628
-
629
-        /**
630
-         * Construct the exception. Note: The message is NOT binary safe.
631
-         *
632
-         * @link http://php.net/manual/en/exception.construct.php
633
-         * @param string $message [optional] The Exception message to throw.
634
-         * @param int $code [optional] The Exception code.
635
-         * @param Exception $previous [optional] The previous exception used for the exception chaining. Since 5.3.0
636
-         * @since 5.1.0
637
-         */
638
-        public function __construct($message = "", $code = 0, Exception $previous = null)
639
-        {
640
-            parent::__construct($message, $code, $previous);
641
-        }
642
-    }
621
+	/**
622
+	 * Class AuthorizeNetException
623
+	 *
624
+	 * @package    AuthorizeNet
625
+	 */
626
+	class AuthorizeNetException extends Exception
627
+	{
628
+
629
+		/**
630
+		 * Construct the exception. Note: The message is NOT binary safe.
631
+		 *
632
+		 * @link http://php.net/manual/en/exception.construct.php
633
+		 * @param string $message [optional] The Exception message to throw.
634
+		 * @param int $code [optional] The Exception code.
635
+		 * @param Exception $previous [optional] The previous exception used for the exception chaining. Since 5.3.0
636
+		 * @since 5.1.0
637
+		 */
638
+		public function __construct($message = "", $code = 0, Exception $previous = null)
639
+		{
640
+			parent::__construct($message, $code, $previous);
641
+		}
642
+	}
643 643
 }
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.
modules/ticket_selector_caff/EED_Ticket_Selector_Caff.module.php 2 patches
Indentation   +294 added lines, -294 removed lines patch added patch discarded remove patch
@@ -17,319 +17,319 @@
 block discarded – undo
17 17
 {
18 18
 
19 19
 
20
-    /**
21
-     * @return EED_Module|EED_Ticket_Selector_Caff
22
-     */
23
-    public static function instance()
24
-    {
25
-        return parent::get_instance(__CLASS__);
26
-    }
20
+	/**
21
+	 * @return EED_Module|EED_Ticket_Selector_Caff
22
+	 */
23
+	public static function instance()
24
+	{
25
+		return parent::get_instance(__CLASS__);
26
+	}
27 27
 
28 28
 
29
-    /**
30
-     *    set_hooks - for hooking into EE Core, other modules, etc
31
-     *
32
-     * @access    public
33
-     * @return    void
34
-     */
35
-    public static function set_hooks()
36
-    {
37
-        add_action(
38
-            'AHEE__ticket_selector_chart_template__ticket_details__after_description',
39
-            array('EED_Ticket_Selector_Caff', 'ticket_price_details'),
40
-            10,
41
-            3
42
-        );
43
-    }
29
+	/**
30
+	 *    set_hooks - for hooking into EE Core, other modules, etc
31
+	 *
32
+	 * @access    public
33
+	 * @return    void
34
+	 */
35
+	public static function set_hooks()
36
+	{
37
+		add_action(
38
+			'AHEE__ticket_selector_chart_template__ticket_details__after_description',
39
+			array('EED_Ticket_Selector_Caff', 'ticket_price_details'),
40
+			10,
41
+			3
42
+		);
43
+	}
44 44
 
45
-    /**
46
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
47
-     *
48
-     * @access    public
49
-     * @return    void
50
-     */
51
-    public static function set_hooks_admin()
52
-    {
53
-        define(
54
-            'TICKET_SELECTOR_CAFF_TEMPLATES_PATH',
55
-            str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/'
56
-        );
57
-        add_action(
58
-            'AHEE__template_settings__template__before_settings_form',
59
-            array('EED_Ticket_Selector_Caff', 'template_settings_form'),
60
-            10
61
-        );
62
-        add_filter(
63
-            'FHEE__General_Settings_Admin_Page__update_template_settings__data',
64
-            array('EED_Ticket_Selector_Caff', 'update_template_settings'),
65
-            10,
66
-            2
67
-        );
68
-    }
45
+	/**
46
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
47
+	 *
48
+	 * @access    public
49
+	 * @return    void
50
+	 */
51
+	public static function set_hooks_admin()
52
+	{
53
+		define(
54
+			'TICKET_SELECTOR_CAFF_TEMPLATES_PATH',
55
+			str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/'
56
+		);
57
+		add_action(
58
+			'AHEE__template_settings__template__before_settings_form',
59
+			array('EED_Ticket_Selector_Caff', 'template_settings_form'),
60
+			10
61
+		);
62
+		add_filter(
63
+			'FHEE__General_Settings_Admin_Page__update_template_settings__data',
64
+			array('EED_Ticket_Selector_Caff', 'update_template_settings'),
65
+			10,
66
+			2
67
+		);
68
+	}
69 69
 
70 70
 
71
-    /**
72
-     * @param \WP $WP
73
-     */
74
-    public function run($WP)
75
-    {
76
-        $this->set_config();
77
-    }
71
+	/**
72
+	 * @param \WP $WP
73
+	 */
74
+	public function run($WP)
75
+	{
76
+		$this->set_config();
77
+	}
78 78
 
79 79
 
80
-    /**
81
-     * @static
82
-     * @return void
83
-     * @throws EE_Error
84
-     * @throws InvalidArgumentException
85
-     * @throws InvalidDataTypeException
86
-     * @throws InvalidInterfaceException
87
-     */
88
-    public static function template_settings_form()
89
-    {
90
-        echo EED_Ticket_Selector_Caff::_ticket_selector_settings_form()->get_html();
91
-    }
80
+	/**
81
+	 * @static
82
+	 * @return void
83
+	 * @throws EE_Error
84
+	 * @throws InvalidArgumentException
85
+	 * @throws InvalidDataTypeException
86
+	 * @throws InvalidInterfaceException
87
+	 */
88
+	public static function template_settings_form()
89
+	{
90
+		echo EED_Ticket_Selector_Caff::_ticket_selector_settings_form()->get_html();
91
+	}
92 92
 
93 93
 
94
-    /**
95
-     * @return \EE_Form_Section_Proper
96
-     * @throws \EE_Error
97
-     */
98
-    public static function _ticket_selector_settings_form()
99
-    {
94
+	/**
95
+	 * @return \EE_Form_Section_Proper
96
+	 * @throws \EE_Error
97
+	 */
98
+	public static function _ticket_selector_settings_form()
99
+	{
100 100
 
101
-        return new EE_Form_Section_Proper(
102
-            array(
103
-                'name'            => 'ticket_selector_settings_form',
104
-                'html_id'         => 'ticket_selector_settings_form',
105
-                'layout_strategy' => new EE_Div_Per_Section_Layout(),
106
-                'subsections'     => apply_filters(
107
-                    'FHEE__EED_Ticket_Selector_Caff___ticket_selector_settings_form__form_subsections',
108
-                    array(
109
-                        'appearance_settings_hdr' => new EE_Form_Section_HTML(
110
-                            EEH_HTML::br(2) .
111
-                            EEH_HTML::h2(esc_html__('Ticket Selector Template Settings', 'event_espresso'))
112
-                        ),
113
-                        'appearance_settings'     => EED_Ticket_Selector_Caff::_ticket_selector_appearance_settings(),
114
-                    )
115
-                ),
116
-            )
117
-        );
118
-    }
101
+		return new EE_Form_Section_Proper(
102
+			array(
103
+				'name'            => 'ticket_selector_settings_form',
104
+				'html_id'         => 'ticket_selector_settings_form',
105
+				'layout_strategy' => new EE_Div_Per_Section_Layout(),
106
+				'subsections'     => apply_filters(
107
+					'FHEE__EED_Ticket_Selector_Caff___ticket_selector_settings_form__form_subsections',
108
+					array(
109
+						'appearance_settings_hdr' => new EE_Form_Section_HTML(
110
+							EEH_HTML::br(2) .
111
+							EEH_HTML::h2(esc_html__('Ticket Selector Template Settings', 'event_espresso'))
112
+						),
113
+						'appearance_settings'     => EED_Ticket_Selector_Caff::_ticket_selector_appearance_settings(),
114
+					)
115
+				),
116
+			)
117
+		);
118
+	}
119 119
 
120 120
 
121
-    /**
122
-     * @return \EE_Form_Section_Proper
123
-     * @throws \EE_Error
124
-     */
125
-    public static function _ticket_selector_appearance_settings()
126
-    {
127
-        if (
128
-            ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config
129
-        ) {
130
-            EED_Ticket_Selector::instance()->set_config();
131
-            EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = EED_Ticket_Selector::instance()
132
-                                                                                                      ->config();
133
-        }
134
-        $EE_Ticket_Selector_Config = EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector;
135
-        // get option for whether to show datetime selector in TS
136
-        $show_datetime_selector = $EE_Ticket_Selector_Config->getShowDatetimeSelector();
137
-        // and option for how may datetimes must exist if display is conditional
138
-        $datetime_selector_threshold = $EE_Ticket_Selector_Config->getDatetimeSelectorThreshold();
121
+	/**
122
+	 * @return \EE_Form_Section_Proper
123
+	 * @throws \EE_Error
124
+	 */
125
+	public static function _ticket_selector_appearance_settings()
126
+	{
127
+		if (
128
+			! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config
129
+		) {
130
+			EED_Ticket_Selector::instance()->set_config();
131
+			EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = EED_Ticket_Selector::instance()
132
+																									  ->config();
133
+		}
134
+		$EE_Ticket_Selector_Config = EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector;
135
+		// get option for whether to show datetime selector in TS
136
+		$show_datetime_selector = $EE_Ticket_Selector_Config->getShowDatetimeSelector();
137
+		// and option for how may datetimes must exist if display is conditional
138
+		$datetime_selector_threshold = $EE_Ticket_Selector_Config->getDatetimeSelectorThreshold();
139 139
 
140
-        return new EE_Form_Section_Proper(
141
-            array(
142
-                'name'            => 'ticket_selector_settings_tbl',
143
-                'html_id'         => 'ticket_selector_settings_tbl',
144
-                'html_class'      => 'form-table',
145
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
146
-                'subsections'     => apply_filters(
147
-                    'FHEE__EED_Ticket_Selector_Caff___ticket_selector_appearance_settings__form_subsections',
148
-                    array(
149
-                        'show_ticket_details'         => new EE_Yes_No_Input(
150
-                            array(
151
-                                'html_label_text'         => esc_html__(
152
-                                    'Show Ticket Details?',
153
-                                    'event_espresso'
154
-                                ),
155
-                                'html_help_text'          => esc_html__(
156
-                                    'This lets you choose whether the extra ticket details section is displayed with the ticket selector.',
157
-                                    'event_espresso'
158
-                                ),
159
-                                'default'                 => isset($EE_Ticket_Selector_Config->show_ticket_details)
160
-                                    ? $EE_Ticket_Selector_Config->show_ticket_details
161
-                                    : true,
162
-                                'display_html_label_text' => false,
163
-                            )
164
-                        ),
165
-                        'show_ticket_sale_columns'    => new EE_Yes_No_Input(
166
-                            array(
167
-                                'html_label_text'         => esc_html__(
168
-                                    'Show Ticket Sale Info?',
169
-                                    'event_espresso'
170
-                                ),
171
-                                'html_help_text'          => esc_html__(
172
-                                    'This lets you indicate whether information about ticket sales is shown with ticket details in the ticket selector.',
173
-                                    'event_espresso'
174
-                                ),
175
-                                'default'                 => isset($EE_Ticket_Selector_Config->show_ticket_sale_columns)
176
-                                    ? $EE_Ticket_Selector_Config->show_ticket_sale_columns
177
-                                    : true,
178
-                                'display_html_label_text' => false,
179
-                            )
180
-                        ),
181
-                        'show_expired_tickets'        => new EE_Yes_No_Input(
182
-                            array(
183
-                                'html_label_text'         => esc_html__(
184
-                                    'Show Expired Tickets?',
185
-                                    'event_espresso'
186
-                                ),
187
-                                'html_help_text'          => esc_html__(
188
-                                    'Indicate whether to show expired tickets in the ticket selector',
189
-                                    'event_espresso'
190
-                                ),
191
-                                'default'                 => isset($EE_Ticket_Selector_Config->show_expired_tickets)
192
-                                    ? $EE_Ticket_Selector_Config->show_expired_tickets
193
-                                    : true,
194
-                                'display_html_label_text' => false,
195
-                            )
196
-                        ),
197
-                        'show_datetime_selector'      => new EE_Select_Input(
198
-                            $EE_Ticket_Selector_Config->getShowDatetimeSelectorOptions(false),
199
-                            array(
200
-                                'html_label_text'         => esc_html__(
201
-                                    'Show Date & Time Filter?',
202
-                                    'event_espresso'
203
-                                ),
204
-                                'html_help_text'          => sprintf(
205
-                                    esc_html__(
206
-                                        'Indicates whether or not to display a dropdown select box above each ticket selector that displays dates and times for the available tickets. Ticket options can be unselected, which removes (hides) them from the list of tickets being displayed.%1$sOptions include:%1$s &bull; %2$sdo not show date & time filter%3$s%1$s &nbsp; this option will NEVER display a date filter, regardless of how many dates exist.%1$s &bull; %2$smaybe show date & time filter%3$s%1$s &nbsp; this option will conditionally display the date filter when the number of dates for the event matches the value set for "Date Filter Threshold".',
207
-                                        'event_espresso'
208
-                                    ),
209
-                                    '<br>',
210
-                                    '<strong>',
211
-                                    '</strong>'
212
-                                ),
213
-                                'default'                 => ! empty($show_datetime_selector)
214
-                                    ? $show_datetime_selector
215
-                                    : EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
216
-                                'display_html_label_text' => false,
217
-                            )
218
-                        ),
219
-                        'datetime_selector_threshold' => new EE_Select_Input(
220
-                            array_combine($r = range(1, 10), $r),
221
-                            array(
222
-                                'html_label_text'         => esc_html__(
223
-                                    'Date & Time Filter Threshold',
224
-                                    'event_espresso'
225
-                                ),
226
-                                'html_help_text'          => esc_html__(
227
-                                    'The number of unique dates an event has to have before conditionally displaying a date & time filter',
228
-                                    'event_espresso'
229
-                                ),
230
-                                'default'                 => ! empty($datetime_selector_threshold)
231
-                                    ? $datetime_selector_threshold
232
-                                    : 3,
233
-                                'display_html_label_text' => false,
234
-                            )
235
-                        ),
236
-                        'datetime_selector_max_checked' => new EE_Integer_Input(
237
-                            array(
238
-                                'html_label_text'         => esc_html__(
239
-                                    'Date & Time Filter Max Checked',
240
-                                    'event_espresso'
241
-                                ),
242
-                                'html_help_text'          => sprintf(
243
-                                    esc_html__(
244
-                                        'Determines the maximum number of dates that will be checked upon initial loading for a Date and Time Filter.%1$sIf set to zero or left blank, then ALL dates will be checked upon initial loading.',
245
-                                        'event_espresso'
246
-                                    ),
247
-                                    '<br>'
248
-                                ),
249
-                                'default'                 => $EE_Ticket_Selector_Config->getDatetimeSelectorMaxChecked(),
250
-                                'display_html_label_text' => false,
251
-                                'min_value'               => 0,
252
-                            )
253
-                        ),
254
-                    )
255
-                ),
256
-            )
257
-        );
258
-    }
140
+		return new EE_Form_Section_Proper(
141
+			array(
142
+				'name'            => 'ticket_selector_settings_tbl',
143
+				'html_id'         => 'ticket_selector_settings_tbl',
144
+				'html_class'      => 'form-table',
145
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
146
+				'subsections'     => apply_filters(
147
+					'FHEE__EED_Ticket_Selector_Caff___ticket_selector_appearance_settings__form_subsections',
148
+					array(
149
+						'show_ticket_details'         => new EE_Yes_No_Input(
150
+							array(
151
+								'html_label_text'         => esc_html__(
152
+									'Show Ticket Details?',
153
+									'event_espresso'
154
+								),
155
+								'html_help_text'          => esc_html__(
156
+									'This lets you choose whether the extra ticket details section is displayed with the ticket selector.',
157
+									'event_espresso'
158
+								),
159
+								'default'                 => isset($EE_Ticket_Selector_Config->show_ticket_details)
160
+									? $EE_Ticket_Selector_Config->show_ticket_details
161
+									: true,
162
+								'display_html_label_text' => false,
163
+							)
164
+						),
165
+						'show_ticket_sale_columns'    => new EE_Yes_No_Input(
166
+							array(
167
+								'html_label_text'         => esc_html__(
168
+									'Show Ticket Sale Info?',
169
+									'event_espresso'
170
+								),
171
+								'html_help_text'          => esc_html__(
172
+									'This lets you indicate whether information about ticket sales is shown with ticket details in the ticket selector.',
173
+									'event_espresso'
174
+								),
175
+								'default'                 => isset($EE_Ticket_Selector_Config->show_ticket_sale_columns)
176
+									? $EE_Ticket_Selector_Config->show_ticket_sale_columns
177
+									: true,
178
+								'display_html_label_text' => false,
179
+							)
180
+						),
181
+						'show_expired_tickets'        => new EE_Yes_No_Input(
182
+							array(
183
+								'html_label_text'         => esc_html__(
184
+									'Show Expired Tickets?',
185
+									'event_espresso'
186
+								),
187
+								'html_help_text'          => esc_html__(
188
+									'Indicate whether to show expired tickets in the ticket selector',
189
+									'event_espresso'
190
+								),
191
+								'default'                 => isset($EE_Ticket_Selector_Config->show_expired_tickets)
192
+									? $EE_Ticket_Selector_Config->show_expired_tickets
193
+									: true,
194
+								'display_html_label_text' => false,
195
+							)
196
+						),
197
+						'show_datetime_selector'      => new EE_Select_Input(
198
+							$EE_Ticket_Selector_Config->getShowDatetimeSelectorOptions(false),
199
+							array(
200
+								'html_label_text'         => esc_html__(
201
+									'Show Date & Time Filter?',
202
+									'event_espresso'
203
+								),
204
+								'html_help_text'          => sprintf(
205
+									esc_html__(
206
+										'Indicates whether or not to display a dropdown select box above each ticket selector that displays dates and times for the available tickets. Ticket options can be unselected, which removes (hides) them from the list of tickets being displayed.%1$sOptions include:%1$s &bull; %2$sdo not show date & time filter%3$s%1$s &nbsp; this option will NEVER display a date filter, regardless of how many dates exist.%1$s &bull; %2$smaybe show date & time filter%3$s%1$s &nbsp; this option will conditionally display the date filter when the number of dates for the event matches the value set for "Date Filter Threshold".',
207
+										'event_espresso'
208
+									),
209
+									'<br>',
210
+									'<strong>',
211
+									'</strong>'
212
+								),
213
+								'default'                 => ! empty($show_datetime_selector)
214
+									? $show_datetime_selector
215
+									: EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
216
+								'display_html_label_text' => false,
217
+							)
218
+						),
219
+						'datetime_selector_threshold' => new EE_Select_Input(
220
+							array_combine($r = range(1, 10), $r),
221
+							array(
222
+								'html_label_text'         => esc_html__(
223
+									'Date & Time Filter Threshold',
224
+									'event_espresso'
225
+								),
226
+								'html_help_text'          => esc_html__(
227
+									'The number of unique dates an event has to have before conditionally displaying a date & time filter',
228
+									'event_espresso'
229
+								),
230
+								'default'                 => ! empty($datetime_selector_threshold)
231
+									? $datetime_selector_threshold
232
+									: 3,
233
+								'display_html_label_text' => false,
234
+							)
235
+						),
236
+						'datetime_selector_max_checked' => new EE_Integer_Input(
237
+							array(
238
+								'html_label_text'         => esc_html__(
239
+									'Date & Time Filter Max Checked',
240
+									'event_espresso'
241
+								),
242
+								'html_help_text'          => sprintf(
243
+									esc_html__(
244
+										'Determines the maximum number of dates that will be checked upon initial loading for a Date and Time Filter.%1$sIf set to zero or left blank, then ALL dates will be checked upon initial loading.',
245
+										'event_espresso'
246
+									),
247
+									'<br>'
248
+								),
249
+								'default'                 => $EE_Ticket_Selector_Config->getDatetimeSelectorMaxChecked(),
250
+								'display_html_label_text' => false,
251
+								'min_value'               => 0,
252
+							)
253
+						),
254
+					)
255
+				),
256
+			)
257
+		);
258
+	}
259 259
 
260 260
 
261
-    /**
262
-     * callback for updating template settings
263
-     *
264
-     * @since 4.6.18.rc.006
265
-     * @param EE_Template_Config $CFG
266
-     * @param array              $REQ incoming request
267
-     * @return EE_Template_Config
268
-     * @throws EE_Error
269
-     * @throws InvalidArgumentException
270
-     * @throws ReflectionException
271
-     * @throws InvalidDataTypeException
272
-     * @throws InvalidInterfaceException
273
-     */
274
-    public static function update_template_settings(EE_Template_Config $CFG, $REQ)
275
-    {
276
-        if (! $CFG->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config) {
277
-            EED_Ticket_Selector::instance()->set_config();
278
-            $CFG->EED_Ticket_Selector = EED_Ticket_Selector::instance()->config();
279
-        }
280
-        try {
281
-            $ticket_selector_form = EED_Ticket_Selector_Caff::_ticket_selector_settings_form();
261
+	/**
262
+	 * callback for updating template settings
263
+	 *
264
+	 * @since 4.6.18.rc.006
265
+	 * @param EE_Template_Config $CFG
266
+	 * @param array              $REQ incoming request
267
+	 * @return EE_Template_Config
268
+	 * @throws EE_Error
269
+	 * @throws InvalidArgumentException
270
+	 * @throws ReflectionException
271
+	 * @throws InvalidDataTypeException
272
+	 * @throws InvalidInterfaceException
273
+	 */
274
+	public static function update_template_settings(EE_Template_Config $CFG, $REQ)
275
+	{
276
+		if (! $CFG->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config) {
277
+			EED_Ticket_Selector::instance()->set_config();
278
+			$CFG->EED_Ticket_Selector = EED_Ticket_Selector::instance()->config();
279
+		}
280
+		try {
281
+			$ticket_selector_form = EED_Ticket_Selector_Caff::_ticket_selector_settings_form();
282 282
 
283
-            // check for form submission
284
-            if ($ticket_selector_form->was_submitted()) {
285
-                // capture form data
286
-                $ticket_selector_form->receive_form_submission();
283
+			// check for form submission
284
+			if ($ticket_selector_form->was_submitted()) {
285
+				// capture form data
286
+				$ticket_selector_form->receive_form_submission();
287 287
 
288
-                // validate form data
289
-                if ($ticket_selector_form->is_valid()) {
290
-                    // grab validated data from form
291
-                    $valid_data = $ticket_selector_form->valid_data();
288
+				// validate form data
289
+				if ($ticket_selector_form->is_valid()) {
290
+					// grab validated data from form
291
+					$valid_data = $ticket_selector_form->valid_data();
292 292
 
293
-                    // set data on config
294
-                    $CFG->EED_Ticket_Selector->show_ticket_sale_columns = $valid_data['appearance_settings']['show_ticket_sale_columns'];
295
-                    $CFG->EED_Ticket_Selector->show_ticket_details = $valid_data['appearance_settings']['show_ticket_details'];
296
-                    $CFG->EED_Ticket_Selector->show_expired_tickets = $valid_data['appearance_settings']['show_expired_tickets'];
297
-                    $CFG->EED_Ticket_Selector->setShowDatetimeSelector(
298
-                        $valid_data['appearance_settings']['show_datetime_selector']
299
-                    );
300
-                    $CFG->EED_Ticket_Selector->setDatetimeSelectorThreshold(
301
-                        $valid_data['appearance_settings']['datetime_selector_threshold']
302
-                    );
303
-                    $CFG->EED_Ticket_Selector->setDatetimeSelectorMaxChecked(
304
-                        $valid_data['appearance_settings']['datetime_selector_max_checked']
305
-                    );
306
-                } else {
307
-                    if ($ticket_selector_form->submission_error_message() !== '') {
308
-                        EE_Error::add_error(
309
-                            $ticket_selector_form->submission_error_message(),
310
-                            __FILE__,
311
-                            __FUNCTION__,
312
-                            __LINE__
313
-                        );
314
-                    }
315
-                }
316
-            }
317
-        } catch (EE_Error $e) {
318
-            $e->get_error();
319
-        }
293
+					// set data on config
294
+					$CFG->EED_Ticket_Selector->show_ticket_sale_columns = $valid_data['appearance_settings']['show_ticket_sale_columns'];
295
+					$CFG->EED_Ticket_Selector->show_ticket_details = $valid_data['appearance_settings']['show_ticket_details'];
296
+					$CFG->EED_Ticket_Selector->show_expired_tickets = $valid_data['appearance_settings']['show_expired_tickets'];
297
+					$CFG->EED_Ticket_Selector->setShowDatetimeSelector(
298
+						$valid_data['appearance_settings']['show_datetime_selector']
299
+					);
300
+					$CFG->EED_Ticket_Selector->setDatetimeSelectorThreshold(
301
+						$valid_data['appearance_settings']['datetime_selector_threshold']
302
+					);
303
+					$CFG->EED_Ticket_Selector->setDatetimeSelectorMaxChecked(
304
+						$valid_data['appearance_settings']['datetime_selector_max_checked']
305
+					);
306
+				} else {
307
+					if ($ticket_selector_form->submission_error_message() !== '') {
308
+						EE_Error::add_error(
309
+							$ticket_selector_form->submission_error_message(),
310
+							__FILE__,
311
+							__FUNCTION__,
312
+							__LINE__
313
+						);
314
+					}
315
+				}
316
+			}
317
+		} catch (EE_Error $e) {
318
+			$e->get_error();
319
+		}
320 320
 
321
-        return $CFG;
322
-    }
321
+		return $CFG;
322
+	}
323 323
 
324 324
 
325
-    /**
326
-     * @param \EE_Ticket $ticket
327
-     * @param int        $ticket_price
328
-     * @param bool       $display_ticket_price
329
-     */
330
-    public static function ticket_price_details(EE_Ticket $ticket, $ticket_price = 0, $display_ticket_price = false)
331
-    {
332
-        require str_replace('\\', '/', plugin_dir_path(__FILE__))
333
-                . 'templates/ticket_selector_price_details.template.php';
334
-    }
325
+	/**
326
+	 * @param \EE_Ticket $ticket
327
+	 * @param int        $ticket_price
328
+	 * @param bool       $display_ticket_price
329
+	 */
330
+	public static function ticket_price_details(EE_Ticket $ticket, $ticket_price = 0, $display_ticket_price = false)
331
+	{
332
+		require str_replace('\\', '/', plugin_dir_path(__FILE__))
333
+				. 'templates/ticket_selector_price_details.template.php';
334
+	}
335 335
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
     {
53 53
         define(
54 54
             'TICKET_SELECTOR_CAFF_TEMPLATES_PATH',
55
-            str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/'
55
+            str_replace('\\', '/', plugin_dir_path(__FILE__)).'templates/'
56 56
         );
57 57
         add_action(
58 58
             'AHEE__template_settings__template__before_settings_form',
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
                     'FHEE__EED_Ticket_Selector_Caff___ticket_selector_settings_form__form_subsections',
108 108
                     array(
109 109
                         'appearance_settings_hdr' => new EE_Form_Section_HTML(
110
-                            EEH_HTML::br(2) .
110
+                            EEH_HTML::br(2).
111 111
                             EEH_HTML::h2(esc_html__('Ticket Selector Template Settings', 'event_espresso'))
112 112
                         ),
113 113
                         'appearance_settings'     => EED_Ticket_Selector_Caff::_ticket_selector_appearance_settings(),
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
      */
274 274
     public static function update_template_settings(EE_Template_Config $CFG, $REQ)
275 275
     {
276
-        if (! $CFG->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config) {
276
+        if ( ! $CFG->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config) {
277 277
             EED_Ticket_Selector::instance()->set_config();
278 278
             $CFG->EED_Ticket_Selector = EED_Ticket_Selector::instance()->config();
279 279
         }
Please login to merge, or discard this patch.
core/libraries/line_item_display/EE_Line_Item_Display.class.php 1 patch
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -15,63 +15,63 @@
 block discarded – undo
15 15
 class EE_Line_Item_Display
16 16
 {
17 17
 
18
-    private $strategy = null;
18
+	private $strategy = null;
19 19
 
20 20
 
21
-    /**
22
-     * @param string $context - where/how the line items are being displayed
23
-     * @param string $other_line_item_display_strategy
24
-     */
25
-    public function __construct($context = '', $other_line_item_display_strategy = '')
26
-    {
27
-        $context = strtolower($context);
28
-        switch ($context) {
29
-            case 'invoice':
30
-                $this->strategy = new EE_Invoice_Line_Item_Display_Strategy();
31
-                break;
32
-            case 'receipt':
33
-                $this->strategy = new EE_Receipt_Line_Item_Display_Strategy();
34
-                break;
35
-            case 'spco':
36
-                $this->strategy = new EE_SPCO_Line_Item_Display_Strategy();
37
-                break;
38
-            default:
39
-                if (
40
-                    ! empty($other_line_item_display_strategy) &&
41
-                    class_exists($other_line_item_display_strategy)
42
-                ) {
43
-                    $this->strategy = new  $other_line_item_display_strategy();
44
-                } else {
45
-                    $this->strategy = new EE_Default_Line_Item_Display_Strategy();
46
-                }
47
-        }
48
-    }
21
+	/**
22
+	 * @param string $context - where/how the line items are being displayed
23
+	 * @param string $other_line_item_display_strategy
24
+	 */
25
+	public function __construct($context = '', $other_line_item_display_strategy = '')
26
+	{
27
+		$context = strtolower($context);
28
+		switch ($context) {
29
+			case 'invoice':
30
+				$this->strategy = new EE_Invoice_Line_Item_Display_Strategy();
31
+				break;
32
+			case 'receipt':
33
+				$this->strategy = new EE_Receipt_Line_Item_Display_Strategy();
34
+				break;
35
+			case 'spco':
36
+				$this->strategy = new EE_SPCO_Line_Item_Display_Strategy();
37
+				break;
38
+			default:
39
+				if (
40
+					! empty($other_line_item_display_strategy) &&
41
+					class_exists($other_line_item_display_strategy)
42
+				) {
43
+					$this->strategy = new  $other_line_item_display_strategy();
44
+				} else {
45
+					$this->strategy = new EE_Default_Line_Item_Display_Strategy();
46
+				}
47
+		}
48
+	}
49 49
 
50
-    /**
51
-     * @param EE_Line_Item $line_item
52
-     * @param array        $options
53
-     * @return mixed
54
-     */
55
-    public function display_line_item(EE_Line_Item $line_item, $options = array())
56
-    {
57
-        return $this->strategy->display_line_item($line_item, $options);
58
-    }
50
+	/**
51
+	 * @param EE_Line_Item $line_item
52
+	 * @param array        $options
53
+	 * @return mixed
54
+	 */
55
+	public function display_line_item(EE_Line_Item $line_item, $options = array())
56
+	{
57
+		return $this->strategy->display_line_item($line_item, $options);
58
+	}
59 59
 
60 60
 
61
-    /**
62
-     * @return float
63
-     */
64
-    public function grand_total()
65
-    {
66
-        return $this->strategy->grand_total();
67
-    }
61
+	/**
62
+	 * @return float
63
+	 */
64
+	public function grand_total()
65
+	{
66
+		return $this->strategy->grand_total();
67
+	}
68 68
 
69 69
 
70
-    /**
71
-     * @return float
72
-     */
73
-    public function total_items()
74
-    {
75
-        return $this->strategy->total_items();
76
-    }
70
+	/**
71
+	 * @return float
72
+	 */
73
+	public function total_items()
74
+	{
75
+		return $this->strategy->total_items();
76
+	}
77 77
 }
Please login to merge, or discard this patch.