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