Completed
Branch BUG/reg-status-change-recursio... (2db0c9)
by
unknown
20:03 queued 10:32
created
modules/ticket_selector_caff/EED_Ticket_Selector_Caff.module.php 2 patches
Indentation   +293 added lines, -293 removed lines patch added patch discarded remove patch
@@ -17,318 +17,318 @@
 block discarded – undo
17 17
 {
18 18
 
19 19
 
20
-    /**
21
-     * @return EED_Module|EED_Ticket_Selector_Caff
22
-     */
23
-    public static function instance()
24
-    {
25
-        return parent::get_instance(__CLASS__);
26
-    }
20
+	/**
21
+	 * @return EED_Module|EED_Ticket_Selector_Caff
22
+	 */
23
+	public static function instance()
24
+	{
25
+		return parent::get_instance(__CLASS__);
26
+	}
27 27
 
28 28
 
29
-    /**
30
-     *    set_hooks - for hooking into EE Core, other modules, etc
31
-     *
32
-     * @access    public
33
-     * @return    void
34
-     */
35
-    public static function set_hooks()
36
-    {
37
-        add_action(
38
-            'AHEE__ticket_selector_chart_template__ticket_details__after_description',
39
-            array('EED_Ticket_Selector_Caff', 'ticket_price_details'),
40
-            10,
41
-            3
42
-        );
43
-    }
29
+	/**
30
+	 *    set_hooks - for hooking into EE Core, other modules, etc
31
+	 *
32
+	 * @access    public
33
+	 * @return    void
34
+	 */
35
+	public static function set_hooks()
36
+	{
37
+		add_action(
38
+			'AHEE__ticket_selector_chart_template__ticket_details__after_description',
39
+			array('EED_Ticket_Selector_Caff', 'ticket_price_details'),
40
+			10,
41
+			3
42
+		);
43
+	}
44 44
 
45
-    /**
46
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
47
-     *
48
-     * @access    public
49
-     * @return    void
50
-     */
51
-    public static function set_hooks_admin()
52
-    {
53
-        define(
54
-            'TICKET_SELECTOR_CAFF_TEMPLATES_PATH',
55
-            str_replace('\\', DS, plugin_dir_path(__FILE__)) . 'templates' . DS
56
-        );
57
-        add_action(
58
-            'AHEE__template_settings__template__before_settings_form',
59
-            array('EED_Ticket_Selector_Caff', 'template_settings_form'),
60
-            10
61
-        );
62
-        add_filter(
63
-            'FHEE__General_Settings_Admin_Page__update_template_settings__data',
64
-            array('EED_Ticket_Selector_Caff', 'update_template_settings'),
65
-            10,
66
-            2
67
-        );
68
-    }
45
+	/**
46
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
47
+	 *
48
+	 * @access    public
49
+	 * @return    void
50
+	 */
51
+	public static function set_hooks_admin()
52
+	{
53
+		define(
54
+			'TICKET_SELECTOR_CAFF_TEMPLATES_PATH',
55
+			str_replace('\\', DS, plugin_dir_path(__FILE__)) . 'templates' . DS
56
+		);
57
+		add_action(
58
+			'AHEE__template_settings__template__before_settings_form',
59
+			array('EED_Ticket_Selector_Caff', 'template_settings_form'),
60
+			10
61
+		);
62
+		add_filter(
63
+			'FHEE__General_Settings_Admin_Page__update_template_settings__data',
64
+			array('EED_Ticket_Selector_Caff', 'update_template_settings'),
65
+			10,
66
+			2
67
+		);
68
+	}
69 69
 
70 70
 
71
-    /**
72
-     * @param \WP $WP
73
-     */
74
-    public function run($WP)
75
-    {
76
-        $this->set_config();
77
-    }
71
+	/**
72
+	 * @param \WP $WP
73
+	 */
74
+	public function run($WP)
75
+	{
76
+		$this->set_config();
77
+	}
78 78
 
79 79
 
80
-    /**
81
-     * @static
82
-     * @return void
83
-     * @throws EE_Error
84
-     * @throws InvalidArgumentException
85
-     * @throws InvalidDataTypeException
86
-     * @throws InvalidInterfaceException
87
-     */
88
-    public static function template_settings_form()
89
-    {
90
-        echo EED_Ticket_Selector_Caff::_ticket_selector_settings_form()->get_html();
91
-    }
80
+	/**
81
+	 * @static
82
+	 * @return void
83
+	 * @throws EE_Error
84
+	 * @throws InvalidArgumentException
85
+	 * @throws InvalidDataTypeException
86
+	 * @throws InvalidInterfaceException
87
+	 */
88
+	public static function template_settings_form()
89
+	{
90
+		echo EED_Ticket_Selector_Caff::_ticket_selector_settings_form()->get_html();
91
+	}
92 92
 
93 93
 
94
-    /**
95
-     * @return \EE_Form_Section_Proper
96
-     * @throws \EE_Error
97
-     */
98
-    public static function _ticket_selector_settings_form()
99
-    {
94
+	/**
95
+	 * @return \EE_Form_Section_Proper
96
+	 * @throws \EE_Error
97
+	 */
98
+	public static function _ticket_selector_settings_form()
99
+	{
100 100
 
101
-        return new EE_Form_Section_Proper(
102
-            array(
103
-                'name'            => 'ticket_selector_settings_form',
104
-                'html_id'         => 'ticket_selector_settings_form',
105
-                'layout_strategy' => new EE_Div_Per_Section_Layout(),
106
-                'subsections'     => apply_filters(
107
-                    'FHEE__EED_Ticket_Selector_Caff___ticket_selector_settings_form__form_subsections',
108
-                    array(
109
-                        'appearance_settings_hdr' => new EE_Form_Section_HTML(
110
-                            EEH_HTML::br(2) .
111
-                            EEH_HTML::h2(esc_html__('Ticket Selector Template Settings', 'event_espresso'))
112
-                        ),
113
-                        'appearance_settings'     => EED_Ticket_Selector_Caff::_ticket_selector_appearance_settings(),
114
-                    )
115
-                ),
116
-            )
117
-        );
118
-    }
101
+		return new EE_Form_Section_Proper(
102
+			array(
103
+				'name'            => 'ticket_selector_settings_form',
104
+				'html_id'         => 'ticket_selector_settings_form',
105
+				'layout_strategy' => new EE_Div_Per_Section_Layout(),
106
+				'subsections'     => apply_filters(
107
+					'FHEE__EED_Ticket_Selector_Caff___ticket_selector_settings_form__form_subsections',
108
+					array(
109
+						'appearance_settings_hdr' => new EE_Form_Section_HTML(
110
+							EEH_HTML::br(2) .
111
+							EEH_HTML::h2(esc_html__('Ticket Selector Template Settings', 'event_espresso'))
112
+						),
113
+						'appearance_settings'     => EED_Ticket_Selector_Caff::_ticket_selector_appearance_settings(),
114
+					)
115
+				),
116
+			)
117
+		);
118
+	}
119 119
 
120 120
 
121
-    /**
122
-     * @return \EE_Form_Section_Proper
123
-     * @throws \EE_Error
124
-     */
125
-    public static function _ticket_selector_appearance_settings()
126
-    {
127
-        if (! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config
128
-        ) {
129
-            EED_Ticket_Selector::instance()->set_config();
130
-            EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = EED_Ticket_Selector::instance()
131
-                                                                                                      ->config();
132
-        }
133
-        $EE_Ticket_Selector_Config = EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector;
134
-        // get option for whether to show datetime selector in TS
135
-        $show_datetime_selector = $EE_Ticket_Selector_Config->getShowDatetimeSelector();
136
-        // and option for how may datetimes must exist if display is conditional
137
-        $datetime_selector_threshold = $EE_Ticket_Selector_Config->getDatetimeSelectorThreshold();
121
+	/**
122
+	 * @return \EE_Form_Section_Proper
123
+	 * @throws \EE_Error
124
+	 */
125
+	public static function _ticket_selector_appearance_settings()
126
+	{
127
+		if (! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config
128
+		) {
129
+			EED_Ticket_Selector::instance()->set_config();
130
+			EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = EED_Ticket_Selector::instance()
131
+																									  ->config();
132
+		}
133
+		$EE_Ticket_Selector_Config = EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector;
134
+		// get option for whether to show datetime selector in TS
135
+		$show_datetime_selector = $EE_Ticket_Selector_Config->getShowDatetimeSelector();
136
+		// and option for how may datetimes must exist if display is conditional
137
+		$datetime_selector_threshold = $EE_Ticket_Selector_Config->getDatetimeSelectorThreshold();
138 138
 
139
-        return new EE_Form_Section_Proper(
140
-            array(
141
-                'name'            => 'ticket_selector_settings_tbl',
142
-                'html_id'         => 'ticket_selector_settings_tbl',
143
-                'html_class'      => 'form-table',
144
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
145
-                'subsections'     => apply_filters(
146
-                    'FHEE__EED_Ticket_Selector_Caff___ticket_selector_appearance_settings__form_subsections',
147
-                    array(
148
-                        'show_ticket_details'         => new EE_Yes_No_Input(
149
-                            array(
150
-                                'html_label_text'         => esc_html__(
151
-                                    'Show Ticket Details?',
152
-                                    'event_espresso'
153
-                                ),
154
-                                'html_help_text'          => esc_html__(
155
-                                    'This lets you choose whether the extra ticket details section is displayed with the ticket selector.',
156
-                                    'event_espresso'
157
-                                ),
158
-                                'default'                 => isset($EE_Ticket_Selector_Config->show_ticket_details)
159
-                                    ? $EE_Ticket_Selector_Config->show_ticket_details
160
-                                    : true,
161
-                                'display_html_label_text' => false,
162
-                            )
163
-                        ),
164
-                        'show_ticket_sale_columns'    => new EE_Yes_No_Input(
165
-                            array(
166
-                                'html_label_text'         => esc_html__(
167
-                                    'Show Ticket Sale Info?',
168
-                                    'event_espresso'
169
-                                ),
170
-                                'html_help_text'          => esc_html__(
171
-                                    'This lets you indicate whether information about ticket sales is shown with ticket details in the ticket selector.',
172
-                                    'event_espresso'
173
-                                ),
174
-                                'default'                 => isset($EE_Ticket_Selector_Config->show_ticket_sale_columns)
175
-                                    ? $EE_Ticket_Selector_Config->show_ticket_sale_columns
176
-                                    : true,
177
-                                'display_html_label_text' => false,
178
-                            )
179
-                        ),
180
-                        'show_expired_tickets'        => new EE_Yes_No_Input(
181
-                            array(
182
-                                'html_label_text'         => esc_html__(
183
-                                    'Show Expired Tickets?',
184
-                                    'event_espresso'
185
-                                ),
186
-                                'html_help_text'          => esc_html__(
187
-                                    'Indicate whether to show expired tickets in the ticket selector',
188
-                                    'event_espresso'
189
-                                ),
190
-                                'default'                 => isset($EE_Ticket_Selector_Config->show_expired_tickets)
191
-                                    ? $EE_Ticket_Selector_Config->show_expired_tickets
192
-                                    : true,
193
-                                'display_html_label_text' => false,
194
-                            )
195
-                        ),
196
-                        'show_datetime_selector'      => new EE_Select_Input(
197
-                            $EE_Ticket_Selector_Config->getShowDatetimeSelectorOptions(false),
198
-                            array(
199
-                                'html_label_text'         => esc_html__(
200
-                                    'Show Date & Time Filter?',
201
-                                    'event_espresso'
202
-                                ),
203
-                                'html_help_text'          => sprintf(
204
-                                    esc_html__(
205
-                                        '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 • %2$sdo not show date & time filter%3$s%1$s   this option will NEVER display a date filter, regardless of how many dates exist.%1$s • %2$smaybe show date & time filter%3$s%1$s   this option will conditionally display the date filter when the number of dates for the event matches the value set for "Date Filter Threshold".',
206
-                                        'event_espresso'
207
-                                    ),
208
-                                    '<br>',
209
-                                    '<strong>',
210
-                                    '</strong>'
211
-                                ),
212
-                                'default'                 => ! empty($show_datetime_selector)
213
-                                    ? $show_datetime_selector
214
-                                    : EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
215
-                                'display_html_label_text' => false,
216
-                            )
217
-                        ),
218
-                        'datetime_selector_threshold' => new EE_Select_Input(
219
-                            array_combine($r = range(1, 10), $r),
220
-                            array(
221
-                                'html_label_text'         => esc_html__(
222
-                                    'Date & Time Filter Threshold',
223
-                                    'event_espresso'
224
-                                ),
225
-                                'html_help_text'          => esc_html__(
226
-                                    'The number of unique dates an event has to have before conditionally displaying a date & time filter',
227
-                                    'event_espresso'
228
-                                ),
229
-                                'default'                 => ! empty($datetime_selector_threshold)
230
-                                    ? $datetime_selector_threshold
231
-                                    : 3,
232
-                                'display_html_label_text' => false,
233
-                            )
234
-                        ),
235
-                        'datetime_selector_max_checked' => new EE_Integer_Input(
236
-                            array(
237
-                                'html_label_text'         => esc_html__(
238
-                                    'Date & Time Filter Max Checked',
239
-                                    'event_espresso'
240
-                                ),
241
-                                'html_help_text'          => sprintf(
242
-                                    esc_html__(
243
-                                        '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.',
244
-                                        'event_espresso'
245
-                                    ),
246
-                                    '<br>'
247
-                                ),
248
-                                'default'                 => $EE_Ticket_Selector_Config->getDatetimeSelectorMaxChecked(),
249
-                                'display_html_label_text' => false,
250
-                                'min_value'               => 0,
251
-                            )
252
-                        ),
253
-                    )
254
-                ),
255
-            )
256
-        );
257
-    }
139
+		return new EE_Form_Section_Proper(
140
+			array(
141
+				'name'            => 'ticket_selector_settings_tbl',
142
+				'html_id'         => 'ticket_selector_settings_tbl',
143
+				'html_class'      => 'form-table',
144
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
145
+				'subsections'     => apply_filters(
146
+					'FHEE__EED_Ticket_Selector_Caff___ticket_selector_appearance_settings__form_subsections',
147
+					array(
148
+						'show_ticket_details'         => new EE_Yes_No_Input(
149
+							array(
150
+								'html_label_text'         => esc_html__(
151
+									'Show Ticket Details?',
152
+									'event_espresso'
153
+								),
154
+								'html_help_text'          => esc_html__(
155
+									'This lets you choose whether the extra ticket details section is displayed with the ticket selector.',
156
+									'event_espresso'
157
+								),
158
+								'default'                 => isset($EE_Ticket_Selector_Config->show_ticket_details)
159
+									? $EE_Ticket_Selector_Config->show_ticket_details
160
+									: true,
161
+								'display_html_label_text' => false,
162
+							)
163
+						),
164
+						'show_ticket_sale_columns'    => new EE_Yes_No_Input(
165
+							array(
166
+								'html_label_text'         => esc_html__(
167
+									'Show Ticket Sale Info?',
168
+									'event_espresso'
169
+								),
170
+								'html_help_text'          => esc_html__(
171
+									'This lets you indicate whether information about ticket sales is shown with ticket details in the ticket selector.',
172
+									'event_espresso'
173
+								),
174
+								'default'                 => isset($EE_Ticket_Selector_Config->show_ticket_sale_columns)
175
+									? $EE_Ticket_Selector_Config->show_ticket_sale_columns
176
+									: true,
177
+								'display_html_label_text' => false,
178
+							)
179
+						),
180
+						'show_expired_tickets'        => new EE_Yes_No_Input(
181
+							array(
182
+								'html_label_text'         => esc_html__(
183
+									'Show Expired Tickets?',
184
+									'event_espresso'
185
+								),
186
+								'html_help_text'          => esc_html__(
187
+									'Indicate whether to show expired tickets in the ticket selector',
188
+									'event_espresso'
189
+								),
190
+								'default'                 => isset($EE_Ticket_Selector_Config->show_expired_tickets)
191
+									? $EE_Ticket_Selector_Config->show_expired_tickets
192
+									: true,
193
+								'display_html_label_text' => false,
194
+							)
195
+						),
196
+						'show_datetime_selector'      => new EE_Select_Input(
197
+							$EE_Ticket_Selector_Config->getShowDatetimeSelectorOptions(false),
198
+							array(
199
+								'html_label_text'         => esc_html__(
200
+									'Show Date & Time Filter?',
201
+									'event_espresso'
202
+								),
203
+								'html_help_text'          => sprintf(
204
+									esc_html__(
205
+										'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".',
206
+										'event_espresso'
207
+									),
208
+									'<br>',
209
+									'<strong>',
210
+									'</strong>'
211
+								),
212
+								'default'                 => ! empty($show_datetime_selector)
213
+									? $show_datetime_selector
214
+									: EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
215
+								'display_html_label_text' => false,
216
+							)
217
+						),
218
+						'datetime_selector_threshold' => new EE_Select_Input(
219
+							array_combine($r = range(1, 10), $r),
220
+							array(
221
+								'html_label_text'         => esc_html__(
222
+									'Date & Time Filter Threshold',
223
+									'event_espresso'
224
+								),
225
+								'html_help_text'          => esc_html__(
226
+									'The number of unique dates an event has to have before conditionally displaying a date & time filter',
227
+									'event_espresso'
228
+								),
229
+								'default'                 => ! empty($datetime_selector_threshold)
230
+									? $datetime_selector_threshold
231
+									: 3,
232
+								'display_html_label_text' => false,
233
+							)
234
+						),
235
+						'datetime_selector_max_checked' => new EE_Integer_Input(
236
+							array(
237
+								'html_label_text'         => esc_html__(
238
+									'Date & Time Filter Max Checked',
239
+									'event_espresso'
240
+								),
241
+								'html_help_text'          => sprintf(
242
+									esc_html__(
243
+										'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.',
244
+										'event_espresso'
245
+									),
246
+									'<br>'
247
+								),
248
+								'default'                 => $EE_Ticket_Selector_Config->getDatetimeSelectorMaxChecked(),
249
+								'display_html_label_text' => false,
250
+								'min_value'               => 0,
251
+							)
252
+						),
253
+					)
254
+				),
255
+			)
256
+		);
257
+	}
258 258
 
259 259
 
260
-    /**
261
-     * callback for updating template settings
262
-     *
263
-     * @since 4.6.18.rc.006
264
-     * @param EE_Template_Config $CFG
265
-     * @param array              $REQ incoming request
266
-     * @return EE_Template_Config
267
-     * @throws EE_Error
268
-     * @throws InvalidArgumentException
269
-     * @throws ReflectionException
270
-     * @throws InvalidDataTypeException
271
-     * @throws InvalidInterfaceException
272
-     */
273
-    public static function update_template_settings(EE_Template_Config $CFG, $REQ)
274
-    {
275
-        if (! $CFG->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config) {
276
-            EED_Ticket_Selector::instance()->set_config();
277
-            $CFG->EED_Ticket_Selector = EED_Ticket_Selector::instance()->config();
278
-        }
279
-        try {
280
-            $ticket_selector_form = EED_Ticket_Selector_Caff::_ticket_selector_settings_form();
260
+	/**
261
+	 * callback for updating template settings
262
+	 *
263
+	 * @since 4.6.18.rc.006
264
+	 * @param EE_Template_Config $CFG
265
+	 * @param array              $REQ incoming request
266
+	 * @return EE_Template_Config
267
+	 * @throws EE_Error
268
+	 * @throws InvalidArgumentException
269
+	 * @throws ReflectionException
270
+	 * @throws InvalidDataTypeException
271
+	 * @throws InvalidInterfaceException
272
+	 */
273
+	public static function update_template_settings(EE_Template_Config $CFG, $REQ)
274
+	{
275
+		if (! $CFG->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config) {
276
+			EED_Ticket_Selector::instance()->set_config();
277
+			$CFG->EED_Ticket_Selector = EED_Ticket_Selector::instance()->config();
278
+		}
279
+		try {
280
+			$ticket_selector_form = EED_Ticket_Selector_Caff::_ticket_selector_settings_form();
281 281
 
282
-            // check for form submission
283
-            if ($ticket_selector_form->was_submitted()) {
284
-                // capture form data
285
-                $ticket_selector_form->receive_form_submission();
282
+			// check for form submission
283
+			if ($ticket_selector_form->was_submitted()) {
284
+				// capture form data
285
+				$ticket_selector_form->receive_form_submission();
286 286
 
287
-                // validate form data
288
-                if ($ticket_selector_form->is_valid()) {
289
-                    // grab validated data from form
290
-                    $valid_data = $ticket_selector_form->valid_data();
287
+				// validate form data
288
+				if ($ticket_selector_form->is_valid()) {
289
+					// grab validated data from form
290
+					$valid_data = $ticket_selector_form->valid_data();
291 291
 
292
-                    // set data on config
293
-                    $CFG->EED_Ticket_Selector->show_ticket_sale_columns = $valid_data['appearance_settings']['show_ticket_sale_columns'];
294
-                    $CFG->EED_Ticket_Selector->show_ticket_details = $valid_data['appearance_settings']['show_ticket_details'];
295
-                    $CFG->EED_Ticket_Selector->show_expired_tickets = $valid_data['appearance_settings']['show_expired_tickets'];
296
-                    $CFG->EED_Ticket_Selector->setShowDatetimeSelector(
297
-                        $valid_data['appearance_settings']['show_datetime_selector']
298
-                    );
299
-                    $CFG->EED_Ticket_Selector->setDatetimeSelectorThreshold(
300
-                        $valid_data['appearance_settings']['datetime_selector_threshold']
301
-                    );
302
-                    $CFG->EED_Ticket_Selector->setDatetimeSelectorMaxChecked(
303
-                        $valid_data['appearance_settings']['datetime_selector_max_checked']
304
-                    );
305
-                } else {
306
-                    if ($ticket_selector_form->submission_error_message() !== '') {
307
-                        EE_Error::add_error(
308
-                            $ticket_selector_form->submission_error_message(),
309
-                            __FILE__,
310
-                            __FUNCTION__,
311
-                            __LINE__
312
-                        );
313
-                    }
314
-                }
315
-            }
316
-        } catch (EE_Error $e) {
317
-            $e->get_error();
318
-        }
292
+					// set data on config
293
+					$CFG->EED_Ticket_Selector->show_ticket_sale_columns = $valid_data['appearance_settings']['show_ticket_sale_columns'];
294
+					$CFG->EED_Ticket_Selector->show_ticket_details = $valid_data['appearance_settings']['show_ticket_details'];
295
+					$CFG->EED_Ticket_Selector->show_expired_tickets = $valid_data['appearance_settings']['show_expired_tickets'];
296
+					$CFG->EED_Ticket_Selector->setShowDatetimeSelector(
297
+						$valid_data['appearance_settings']['show_datetime_selector']
298
+					);
299
+					$CFG->EED_Ticket_Selector->setDatetimeSelectorThreshold(
300
+						$valid_data['appearance_settings']['datetime_selector_threshold']
301
+					);
302
+					$CFG->EED_Ticket_Selector->setDatetimeSelectorMaxChecked(
303
+						$valid_data['appearance_settings']['datetime_selector_max_checked']
304
+					);
305
+				} else {
306
+					if ($ticket_selector_form->submission_error_message() !== '') {
307
+						EE_Error::add_error(
308
+							$ticket_selector_form->submission_error_message(),
309
+							__FILE__,
310
+							__FUNCTION__,
311
+							__LINE__
312
+						);
313
+					}
314
+				}
315
+			}
316
+		} catch (EE_Error $e) {
317
+			$e->get_error();
318
+		}
319 319
 
320
-        return $CFG;
321
-    }
320
+		return $CFG;
321
+	}
322 322
 
323 323
 
324
-    /**
325
-     * @param \EE_Ticket $ticket
326
-     * @param int        $ticket_price
327
-     * @param bool       $display_ticket_price
328
-     */
329
-    public static function ticket_price_details(EE_Ticket $ticket, $ticket_price = 0, $display_ticket_price = false)
330
-    {
331
-        require str_replace('\\', DS, plugin_dir_path(__FILE__))
332
-                . 'templates' . DS . 'ticket_selector_price_details.template.php';
333
-    }
324
+	/**
325
+	 * @param \EE_Ticket $ticket
326
+	 * @param int        $ticket_price
327
+	 * @param bool       $display_ticket_price
328
+	 */
329
+	public static function ticket_price_details(EE_Ticket $ticket, $ticket_price = 0, $display_ticket_price = false)
330
+	{
331
+		require str_replace('\\', DS, plugin_dir_path(__FILE__))
332
+				. 'templates' . DS . 'ticket_selector_price_details.template.php';
333
+	}
334 334
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 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('\\', DS, plugin_dir_path(__FILE__)) . 'templates' . DS
55
+            str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS
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(),
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
      */
125 125
     public static function _ticket_selector_appearance_settings()
126 126
     {
127
-        if (! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config
127
+        if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config
128 128
         ) {
129 129
             EED_Ticket_Selector::instance()->set_config();
130 130
             EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = EED_Ticket_Selector::instance()
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
      */
273 273
     public static function update_template_settings(EE_Template_Config $CFG, $REQ)
274 274
     {
275
-        if (! $CFG->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config) {
275
+        if ( ! $CFG->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config) {
276 276
             EED_Ticket_Selector::instance()->set_config();
277 277
             $CFG->EED_Ticket_Selector = EED_Ticket_Selector::instance()->config();
278 278
         }
@@ -329,6 +329,6 @@  discard block
 block discarded – undo
329 329
     public static function ticket_price_details(EE_Ticket $ticket, $ticket_price = 0, $display_ticket_price = false)
330 330
     {
331 331
         require str_replace('\\', DS, plugin_dir_path(__FILE__))
332
-                . 'templates' . DS . 'ticket_selector_price_details.template.php';
332
+                . 'templates'.DS.'ticket_selector_price_details.template.php';
333 333
     }
334 334
 }
Please login to merge, or discard this patch.
core/EE_Deprecated.core.php 2 patches
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -84,20 +84,20 @@  discard block
 block discarded – undo
84 84
     // loop thru and call doing_it_wrong() or remove any that aren't being used
85 85
     foreach ($deprecated_filters as $deprecated_filter => $on) {
86 86
         // was this filter called ?
87
-        if (has_action('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter)) {
87
+        if (has_action('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter)) {
88 88
             // only display doing_it_wrong() notice to Event Admins during non-AJAX requests
89 89
             if (EE_Registry::instance()->CAP->current_user_can(
90 90
                     'ee_read_ee',
91 91
                     'hide_doing_it_wrong_for_deprecated_SPCO_filter'
92 92
                 ) && ! defined('DOING_AJAX')) {
93 93
                 EE_Error::doing_it_wrong(
94
-                    'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter,
94
+                    'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter,
95 95
                     sprintf(
96 96
                         __(
97 97
                             'The %1$s filter is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"',
98 98
                             'event_espresso'
99 99
                         ),
100
-                        'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter,
100
+                        'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter,
101 101
                         '<br />',
102 102
                         'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text',
103 103
                         '/modules/single_page_checkout/inc/EE_SPCO_Reg_Step.class.php'
@@ -106,10 +106,10 @@  discard block
 block discarded – undo
106 106
                 );
107 107
             }
108 108
         } else {
109
-            unset($deprecated_filters[ $deprecated_filter ]);
109
+            unset($deprecated_filters[$deprecated_filter]);
110 110
         }
111 111
     }
112
-    if (! empty($deprecated_filters)) {
112
+    if ( ! empty($deprecated_filters)) {
113 113
 
114 114
         if ($checkout->current_step->slug(
115 115
             ) == 'attendee_information' && $checkout->revisit && isset($deprecated_filters['update_registration_details'])) {
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
                 $submit_button_text = apply_filters(
144 144
                                           'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to',
145 145
                                           $submit_button_text
146
-                                      ) . $checkout->next_step->name();
146
+                                      ).$checkout->next_step->name();
147 147
             }
148 148
         }
149 149
 
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
             'event_espresso'
328 328
         );
329 329
         EE_Error::doing_it_wrong(
330
-            __CLASS__ . '::' . __FUNCTION__,
330
+            __CLASS__.'::'.__FUNCTION__,
331 331
             $msg,
332 332
             '4.8.32.rc.000'
333 333
         );
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
 function ee_deprecated_update_attendee_registration_form_old($admin_page)
355 355
 {
356 356
     // check if the old hooks are in use. If not, do the default
357
-    if (! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
357
+    if ( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
358 358
         || ! $admin_page instanceof EE_Admin_Page) {
359 359
         return;
360 360
     }
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
     $qstns = isset($req_data['qstn']) ? $req_data['qstn'] : false;
363 363
     $REG_ID = isset($req_data['_REG_ID']) ? absint($req_data['_REG_ID']) : false;
364 364
     $qstns = apply_filters('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns);
365
-    if (! $REG_ID || ! $qstns) {
365
+    if ( ! $REG_ID || ! $qstns) {
366 366
         EE_Error::add_error(
367 367
             __('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'),
368 368
             __FILE__,
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 
383 383
     foreach ($qstns as $QST_ID => $qstn) {
384 384
         // if $qstn isn't an array then it doesn't already have an answer, so let's create the answer
385
-        if (! is_array($qstn)) {
385
+        if ( ! is_array($qstn)) {
386 386
             $success = $this->_save_new_answer($REG_ID, $QST_ID, $qstn);
387 387
             continue;
388 388
         }
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
             );
400 400
             $answer = EEM_Answer::instance()->get_one($query_params);
401 401
             // this MAY be an array but NOT have an answer because its multi select.  If so then we need to create the answer
402
-            if (! $answer instanceof EE_Answer) {
402
+            if ( ! $answer instanceof EE_Answer) {
403 403
                 $set_values = array(
404 404
                     'QST_ID'    => $QST_ID,
405 405
                     'REG_ID'    => $REG_ID,
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
 function ee_deprecated_reg_questions_meta_box_old($do_default_action, $admin_page, $registration)
441 441
 {
442 442
     // check if the old hooks are in use. If not, do the default
443
-    if (! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
443
+    if ( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
444 444
         || ! $admin_page instanceof EE_Admin_Page) {
445 445
         return $do_default_action;
446 446
     }
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
         'reg_questions_form_action' => 'edit_registration',
473 473
         'REG_ID'                    => $registration->ID(),
474 474
     );
475
-    $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
475
+    $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php';
476 476
     echo EEH_Template::display_template($template_path, $template_args, true);
477 477
     // indicate that we should not do the default admin page code
478 478
     return false;
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
     public function _class_is_deprecated($method)
591 591
     {
592 592
         EE_Error::doing_it_wrong(
593
-            'EE_messages::' . $method,
593
+            'EE_messages::'.$method,
594 594
             __('EE_messages has been deprecated.  Please use EE_Message_Resource_Manager instead.'),
595 595
             '4.9.0',
596 596
             '4.10.0.p'
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
         $error = false;
730 730
         // try to intelligently determine what method we'll call based on the incoming data.
731 731
         // if generating and sending are different then generate and send immediately.
732
-        if (! empty($sending_messenger) && $sending_messenger != $generating_messenger && $send) {
732
+        if ( ! empty($sending_messenger) && $sending_messenger != $generating_messenger && $send) {
733 733
             // in the legacy system, when generating and sending were different, that means all the
734 734
             // vars are already in the request object.  So let's just use that.
735 735
             try {
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
                     'event_espresso'
743 743
                 );
744 744
                 // add specific message for developers if WP_DEBUG in on
745
-                $error_msg .= '||' . $e->getMessage();
745
+                $error_msg .= '||'.$e->getMessage();
746 746
                 EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
747 747
                 $error = true;
748 748
             }
@@ -816,7 +816,7 @@  discard block
 block discarded – undo
816 816
             }
817 817
         }
818 818
         // if no error then return the generated message(s).
819
-        if (! $error && ! $send) {
819
+        if ( ! $error && ! $send) {
820 820
             $generated_queue = $processor->generate_queue(false);
821 821
             // get message and return.
822 822
             $generated_queue->get_message_repository()->rewind();
@@ -875,7 +875,7 @@  discard block
 block discarded – undo
875 875
         /** @type EE_Messages_Queue $queue */
876 876
         $queue = EE_Registry::instance()->load_lib('Messages_Queue');
877 877
         // make sure we have a proper message object
878
-        if (! $message instanceof EE_Message && is_object($message) && isset($message->content)) {
878
+        if ( ! $message instanceof EE_Message && is_object($message) && isset($message->content)) {
879 879
             $msg = EE_Message_Factory::create(
880 880
                 array(
881 881
                     'MSG_messenger'    => $messenger,
@@ -887,11 +887,11 @@  discard block
 block discarded – undo
887 887
         } else {
888 888
             $msg = $message;
889 889
         }
890
-        if (! $msg instanceof EE_Message) {
890
+        if ( ! $msg instanceof EE_Message) {
891 891
             return false;
892 892
         }
893 893
         // make sure any content in a content property (if not empty) is set on the MSG_content.
894
-        if (! empty($msg->content)) {
894
+        if ( ! empty($msg->content)) {
895 895
             $msg->set('MSG_content', $msg->content);
896 896
         }
897 897
         $queue->add($msg);
@@ -1130,8 +1130,8 @@  discard block
 block discarded – undo
1130 1130
 
1131 1131
 add_filter(
1132 1132
     'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
1133
-    function ($event_list_iframe_css) {
1134
-        if (! has_filter('FHEE__EventsArchiveIframe__event_list_iframe__css')) {
1133
+    function($event_list_iframe_css) {
1134
+        if ( ! has_filter('FHEE__EventsArchiveIframe__event_list_iframe__css')) {
1135 1135
             return $event_list_iframe_css;
1136 1136
         }
1137 1137
         deprecated_espresso_action_or_filter_doing_it_wrong(
@@ -1150,8 +1150,8 @@  discard block
 block discarded – undo
1150 1150
 );
1151 1151
 add_filter(
1152 1152
     'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
1153
-    function ($event_list_iframe_js) {
1154
-        if (! has_filter('FHEE__EED_Ticket_Selector__ticket_selector_iframe__js')) {
1153
+    function($event_list_iframe_js) {
1154
+        if ( ! has_filter('FHEE__EED_Ticket_Selector__ticket_selector_iframe__js')) {
1155 1155
             return $event_list_iframe_js;
1156 1156
         }
1157 1157
         deprecated_espresso_action_or_filter_doing_it_wrong(
@@ -1170,8 +1170,8 @@  discard block
 block discarded – undo
1170 1170
 );
1171 1171
 add_action(
1172 1172
     'AHEE__EE_Capabilities__addCaps__complete',
1173
-    function ($capabilities_map) {
1174
-        if (! has_action('AHEE__EE_Capabilities__init_role_caps__complete')) {
1173
+    function($capabilities_map) {
1174
+        if ( ! has_action('AHEE__EE_Capabilities__init_role_caps__complete')) {
1175 1175
             return;
1176 1176
         }
1177 1177
         deprecated_espresso_action_or_filter_doing_it_wrong(
@@ -1190,8 +1190,8 @@  discard block
 block discarded – undo
1190 1190
 
1191 1191
 add_filter(
1192 1192
     'FHEE_EventEspresso_core_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee',
1193
-    function ($existing_attendee, $registration, $attendee_data) {
1194
-        if (! has_filter('FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee')) {
1193
+    function($existing_attendee, $registration, $attendee_data) {
1194
+        if ( ! has_filter('FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee')) {
1195 1195
             return $existing_attendee;
1196 1196
         }
1197 1197
         deprecated_espresso_action_or_filter_doing_it_wrong(
@@ -1274,7 +1274,7 @@  discard block
 block discarded – undo
1274 1274
      */
1275 1275
     public function event_list_title($event_list_title = '')
1276 1276
     {
1277
-        if (! empty($this->title)) {
1277
+        if ( ! empty($this->title)) {
1278 1278
             return $this->title;
1279 1279
         }
1280 1280
         return $event_list_title;
@@ -1417,7 +1417,7 @@  discard block
 block discarded – undo
1417 1417
             foreach ($model_fields as $field) {
1418 1418
                 if ($label === EEH_Export::get_column_name_for_field($field)) {
1419 1419
                     // re-add the old field name
1420
-                    $new_label = $label . '[' . $field->get_name() . ']';
1420
+                    $new_label = $label.'['.$field->get_name().']';
1421 1421
                     break;
1422 1422
                 }
1423 1423
             }
Please login to merge, or discard this patch.
Indentation   +1217 added lines, -1217 removed lines patch added patch discarded remove patch
@@ -39,31 +39,31 @@  discard block
 block discarded – undo
39 39
  * @param string $action_or_filter
40 40
  */
41 41
 function deprecated_espresso_action_or_filter_doing_it_wrong(
42
-    $deprecated_filter,
43
-    $replacement,
44
-    $replacement_location,
45
-    $version_deprecated,
46
-    $version_applies,
47
-    $action_or_filter = 'action'
42
+	$deprecated_filter,
43
+	$replacement,
44
+	$replacement_location,
45
+	$version_deprecated,
46
+	$version_applies,
47
+	$action_or_filter = 'action'
48 48
 ) {
49
-    $action_or_filter = $action_or_filter === 'action'
50
-        ? esc_html__('action', 'event_espresso')
51
-        : esc_html__('filter', 'event_espresso');
52
-    EE_Error::doing_it_wrong(
53
-        $deprecated_filter,
54
-        sprintf(
55
-            __(
56
-                'This %1$s is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new %1$s: %4$s"%2$s" found in "%3$s"',
57
-                'event_espresso'
58
-            ),
59
-            $action_or_filter,
60
-            $replacement,
61
-            $replacement_location,
62
-            '<br />'
63
-        ),
64
-        $version_deprecated,
65
-        $version_applies
66
-    );
49
+	$action_or_filter = $action_or_filter === 'action'
50
+		? esc_html__('action', 'event_espresso')
51
+		: esc_html__('filter', 'event_espresso');
52
+	EE_Error::doing_it_wrong(
53
+		$deprecated_filter,
54
+		sprintf(
55
+			__(
56
+				'This %1$s is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new %1$s: %4$s"%2$s" found in "%3$s"',
57
+				'event_espresso'
58
+			),
59
+			$action_or_filter,
60
+			$replacement,
61
+			$replacement_location,
62
+			'<br />'
63
+		),
64
+		$version_deprecated,
65
+		$version_applies
66
+	);
67 67
 }
68 68
 
69 69
 /**
@@ -75,90 +75,90 @@  discard block
 block discarded – undo
75 75
  */
76 76
 function ee_deprecated__registration_checkout__button_text($submit_button_text, EE_Checkout $checkout)
77 77
 {
78
-    // list of old filters
79
-    $deprecated_filters = array(
80
-        'update_registration_details' => true,
81
-        'process_payment'             => true,
82
-        'finalize_registration'       => true,
83
-        'and_proceed_to_payment'      => true,
84
-        'proceed_to'                  => true,
85
-    );
86
-    // loop thru and call doing_it_wrong() or remove any that aren't being used
87
-    foreach ($deprecated_filters as $deprecated_filter => $on) {
88
-        // was this filter called ?
89
-        if (has_action('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter)) {
90
-            // only display doing_it_wrong() notice to Event Admins during non-AJAX requests
91
-            if (EE_Registry::instance()->CAP->current_user_can(
92
-                    'ee_read_ee',
93
-                    'hide_doing_it_wrong_for_deprecated_SPCO_filter'
94
-                ) && ! defined('DOING_AJAX')) {
95
-                EE_Error::doing_it_wrong(
96
-                    'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter,
97
-                    sprintf(
98
-                        __(
99
-                            'The %1$s filter is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"',
100
-                            'event_espresso'
101
-                        ),
102
-                        'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter,
103
-                        '<br />',
104
-                        'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text',
105
-                        '/modules/single_page_checkout/inc/EE_SPCO_Reg_Step.class.php'
106
-                    ),
107
-                    '4.6.10'
108
-                );
109
-            }
110
-        } else {
111
-            unset($deprecated_filters[ $deprecated_filter ]);
112
-        }
113
-    }
114
-    if (! empty($deprecated_filters)) {
115
-
116
-        if ($checkout->current_step->slug(
117
-            ) == 'attendee_information' && $checkout->revisit && isset($deprecated_filters['update_registration_details'])) {
118
-            $submit_button_text = apply_filters(
119
-                'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details',
120
-                $submit_button_text
121
-            );
122
-        } elseif ($checkout->current_step->slug(
123
-            ) == 'payment_options' && $checkout->revisit && isset($deprecated_filters['process_payment'])) {
124
-            $submit_button_text = apply_filters(
125
-                'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment',
126
-                $submit_button_text
127
-            );
128
-        } elseif ($checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug(
129
-            ) == 'finalize_registration' && isset($deprecated_filters['finalize_registration'])) {
130
-            $submit_button_text = apply_filters(
131
-                'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration',
132
-                $submit_button_text
133
-            );
134
-        }
135
-        if ($checkout->next_step instanceof EE_SPCO_Reg_Step) {
136
-            if ($checkout->payment_required() && $checkout->next_step->slug(
137
-                ) == 'payment_options' && isset($deprecated_filters['and_proceed_to_payment'])) {
138
-                $submit_button_text .= apply_filters(
139
-                    'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment',
140
-                    $submit_button_text
141
-                );
142
-            }
143
-            if ($checkout->next_step->slug(
144
-                ) != 'finalize_registration' && ! $checkout->revisit && isset($deprecated_filters['proceed_to'])) {
145
-                $submit_button_text = apply_filters(
146
-                                          'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to',
147
-                                          $submit_button_text
148
-                                      ) . $checkout->next_step->name();
149
-            }
150
-        }
151
-
152
-    }
153
-    return $submit_button_text;
78
+	// list of old filters
79
+	$deprecated_filters = array(
80
+		'update_registration_details' => true,
81
+		'process_payment'             => true,
82
+		'finalize_registration'       => true,
83
+		'and_proceed_to_payment'      => true,
84
+		'proceed_to'                  => true,
85
+	);
86
+	// loop thru and call doing_it_wrong() or remove any that aren't being used
87
+	foreach ($deprecated_filters as $deprecated_filter => $on) {
88
+		// was this filter called ?
89
+		if (has_action('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter)) {
90
+			// only display doing_it_wrong() notice to Event Admins during non-AJAX requests
91
+			if (EE_Registry::instance()->CAP->current_user_can(
92
+					'ee_read_ee',
93
+					'hide_doing_it_wrong_for_deprecated_SPCO_filter'
94
+				) && ! defined('DOING_AJAX')) {
95
+				EE_Error::doing_it_wrong(
96
+					'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter,
97
+					sprintf(
98
+						__(
99
+							'The %1$s filter is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"',
100
+							'event_espresso'
101
+						),
102
+						'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter,
103
+						'<br />',
104
+						'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text',
105
+						'/modules/single_page_checkout/inc/EE_SPCO_Reg_Step.class.php'
106
+					),
107
+					'4.6.10'
108
+				);
109
+			}
110
+		} else {
111
+			unset($deprecated_filters[ $deprecated_filter ]);
112
+		}
113
+	}
114
+	if (! empty($deprecated_filters)) {
115
+
116
+		if ($checkout->current_step->slug(
117
+			) == 'attendee_information' && $checkout->revisit && isset($deprecated_filters['update_registration_details'])) {
118
+			$submit_button_text = apply_filters(
119
+				'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details',
120
+				$submit_button_text
121
+			);
122
+		} elseif ($checkout->current_step->slug(
123
+			) == 'payment_options' && $checkout->revisit && isset($deprecated_filters['process_payment'])) {
124
+			$submit_button_text = apply_filters(
125
+				'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment',
126
+				$submit_button_text
127
+			);
128
+		} elseif ($checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug(
129
+			) == 'finalize_registration' && isset($deprecated_filters['finalize_registration'])) {
130
+			$submit_button_text = apply_filters(
131
+				'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration',
132
+				$submit_button_text
133
+			);
134
+		}
135
+		if ($checkout->next_step instanceof EE_SPCO_Reg_Step) {
136
+			if ($checkout->payment_required() && $checkout->next_step->slug(
137
+				) == 'payment_options' && isset($deprecated_filters['and_proceed_to_payment'])) {
138
+				$submit_button_text .= apply_filters(
139
+					'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment',
140
+					$submit_button_text
141
+				);
142
+			}
143
+			if ($checkout->next_step->slug(
144
+				) != 'finalize_registration' && ! $checkout->revisit && isset($deprecated_filters['proceed_to'])) {
145
+				$submit_button_text = apply_filters(
146
+										  'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to',
147
+										  $submit_button_text
148
+									  ) . $checkout->next_step->name();
149
+			}
150
+		}
151
+
152
+	}
153
+	return $submit_button_text;
154 154
 
155 155
 }
156 156
 
157 157
 add_filter(
158
-    'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text',
159
-    'ee_deprecated__registration_checkout__button_text',
160
-    10,
161
-    2
158
+	'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text',
159
+	'ee_deprecated__registration_checkout__button_text',
160
+	10,
161
+	2
162 162
 );
163 163
 
164 164
 
@@ -170,54 +170,54 @@  discard block
 block discarded – undo
170 170
  */
171 171
 function ee_deprecated_finalize_transaction(EE_Checkout $checkout, $status_updates)
172 172
 {
173
-    $action_ref = null;
174
-    $action_ref = has_action('AHEE__EE_Transaction__finalize__new_transaction')
175
-        ? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref;
176
-    $action_ref = has_action('AHEE__EE_Transaction__finalize__all_transaction')
177
-        ? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref;
178
-    if ($action_ref) {
179
-
180
-        EE_Error::doing_it_wrong(
181
-            $action_ref,
182
-            sprintf(
183
-                __(
184
-                    'This action is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"',
185
-                    'event_espresso'
186
-                ),
187
-                '<br />',
188
-                '/core/business/EE_Transaction_Processor.class.php',
189
-                'AHEE__EE_Transaction_Processor__finalize',
190
-                'AHEE__EE_Transaction_Processor__manually_update_registration_statuses',
191
-                'AHEE__EE_Transaction_Processor__toggle_registration_statuses_for_default_approved_events',
192
-                'AHEE__EE_Transaction_Processor__toggle_registration_statuses_if_no_monies_owing'
193
-            ),
194
-            '4.6.0'
195
-        );
196
-        switch ($action_ref) {
197
-            case 'AHEE__EE_Transaction__finalize__new_transaction' :
198
-                do_action(
199
-                    'AHEE__EE_Transaction__finalize__new_transaction',
200
-                    $checkout->transaction,
201
-                    $checkout->admin_request
202
-                );
203
-                break;
204
-            case 'AHEE__EE_Transaction__finalize__all_transaction' :
205
-                do_action(
206
-                    'AHEE__EE_Transaction__finalize__new_transaction',
207
-                    $checkout->transaction,
208
-                    array('new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates),
209
-                    $checkout->admin_request
210
-                );
211
-                break;
212
-        }
213
-    }
173
+	$action_ref = null;
174
+	$action_ref = has_action('AHEE__EE_Transaction__finalize__new_transaction')
175
+		? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref;
176
+	$action_ref = has_action('AHEE__EE_Transaction__finalize__all_transaction')
177
+		? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref;
178
+	if ($action_ref) {
179
+
180
+		EE_Error::doing_it_wrong(
181
+			$action_ref,
182
+			sprintf(
183
+				__(
184
+					'This action is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"',
185
+					'event_espresso'
186
+				),
187
+				'<br />',
188
+				'/core/business/EE_Transaction_Processor.class.php',
189
+				'AHEE__EE_Transaction_Processor__finalize',
190
+				'AHEE__EE_Transaction_Processor__manually_update_registration_statuses',
191
+				'AHEE__EE_Transaction_Processor__toggle_registration_statuses_for_default_approved_events',
192
+				'AHEE__EE_Transaction_Processor__toggle_registration_statuses_if_no_monies_owing'
193
+			),
194
+			'4.6.0'
195
+		);
196
+		switch ($action_ref) {
197
+			case 'AHEE__EE_Transaction__finalize__new_transaction' :
198
+				do_action(
199
+					'AHEE__EE_Transaction__finalize__new_transaction',
200
+					$checkout->transaction,
201
+					$checkout->admin_request
202
+				);
203
+				break;
204
+			case 'AHEE__EE_Transaction__finalize__all_transaction' :
205
+				do_action(
206
+					'AHEE__EE_Transaction__finalize__new_transaction',
207
+					$checkout->transaction,
208
+					array('new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates),
209
+					$checkout->admin_request
210
+				);
211
+				break;
212
+		}
213
+	}
214 214
 }
215 215
 
216 216
 add_action(
217
-    'AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed',
218
-    'ee_deprecated_finalize_transaction',
219
-    10,
220
-    2
217
+	'AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed',
218
+	'ee_deprecated_finalize_transaction',
219
+	10,
220
+	2
221 221
 );
222 222
 /**
223 223
  * ee_deprecated_finalize_registration
@@ -226,35 +226,35 @@  discard block
 block discarded – undo
226 226
  */
227 227
 function ee_deprecated_finalize_registration(EE_Registration $registration)
228 228
 {
229
-    $action_ref = has_action('AHEE__EE_Registration__finalize__update_and_new_reg')
230
-        ? 'AHEE__EE_Registration__finalize__update_and_new_reg' : null;
231
-    if ($action_ref) {
232
-        EE_Error::doing_it_wrong(
233
-            $action_ref,
234
-            sprintf(
235
-                __(
236
-                    'This action is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"',
237
-                    'event_espresso'
238
-                ),
239
-                '<br />',
240
-                '/core/business/EE_Registration_Processor.class.php',
241
-                'AHEE__EE_Registration_Processor__trigger_registration_update_notifications'
242
-            ),
243
-            '4.6.0'
244
-        );
245
-        do_action(
246
-            'AHEE__EE_Registration__finalize__update_and_new_reg',
247
-            $registration,
248
-            (is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX))
249
-        );
250
-    }
229
+	$action_ref = has_action('AHEE__EE_Registration__finalize__update_and_new_reg')
230
+		? 'AHEE__EE_Registration__finalize__update_and_new_reg' : null;
231
+	if ($action_ref) {
232
+		EE_Error::doing_it_wrong(
233
+			$action_ref,
234
+			sprintf(
235
+				__(
236
+					'This action is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"',
237
+					'event_espresso'
238
+				),
239
+				'<br />',
240
+				'/core/business/EE_Registration_Processor.class.php',
241
+				'AHEE__EE_Registration_Processor__trigger_registration_update_notifications'
242
+			),
243
+			'4.6.0'
244
+		);
245
+		do_action(
246
+			'AHEE__EE_Registration__finalize__update_and_new_reg',
247
+			$registration,
248
+			(is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX))
249
+		);
250
+	}
251 251
 }
252 252
 
253 253
 add_action(
254
-    'AHEE__EE_Registration_Processor__trigger_registration_update_notifications',
255
-    'ee_deprecated_finalize_registration',
256
-    10,
257
-    1
254
+	'AHEE__EE_Registration_Processor__trigger_registration_update_notifications',
255
+	'ee_deprecated_finalize_registration',
256
+	10,
257
+	1
258 258
 );
259 259
 
260 260
 
@@ -264,44 +264,44 @@  discard block
 block discarded – undo
264 264
  */
265 265
 function ee_deprecated_hooks()
266 266
 {
267
-    /**
268
-     * @var          $hooks       array where keys are hook names, and their values are array{
269
-     * @type string  $version     when deprecated
270
-     * @type string  $alternative saying what to use instead
271
-     * @type boolean $still_works whether or not the hook still works
272
-     *        }
273
-     */
274
-    $hooks = array(
275
-        'AHEE__EE_System___do_setup_validations' => array(
276
-            'version'     => '4.6.0',
277
-            'alternative' => __(
278
-                'Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)',
279
-                'event_espresso'
280
-            ),
281
-            'still_works' => false,
282
-        ),
283
-    );
284
-    foreach ($hooks as $name => $deprecation_info) {
285
-        if (has_action($name)) {
286
-            EE_Error::doing_it_wrong(
287
-                $name,
288
-                sprintf(
289
-                    __('This filter is deprecated. %1$s%2$s', 'event_espresso'),
290
-                    $deprecation_info['still_works'] ? __(
291
-                        'It *may* work as an attempt to build in backwards compatibility.',
292
-                        'event_espresso'
293
-                    ) : __('It has been completely removed.', 'event_espresso'),
294
-                    isset($deprecation_info['alternative'])
295
-                        ? $deprecation_info['alternative']
296
-                        : __(
297
-                        'Please read the current EE4 documentation further or contact Support.',
298
-                        'event_espresso'
299
-                    )
300
-                ),
301
-                isset($deprecation_info['version']) ? $deprecation_info['version'] : __('recently', 'event_espresso')
302
-            );
303
-        }
304
-    }
267
+	/**
268
+	 * @var          $hooks       array where keys are hook names, and their values are array{
269
+	 * @type string  $version     when deprecated
270
+	 * @type string  $alternative saying what to use instead
271
+	 * @type boolean $still_works whether or not the hook still works
272
+	 *        }
273
+	 */
274
+	$hooks = array(
275
+		'AHEE__EE_System___do_setup_validations' => array(
276
+			'version'     => '4.6.0',
277
+			'alternative' => __(
278
+				'Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)',
279
+				'event_espresso'
280
+			),
281
+			'still_works' => false,
282
+		),
283
+	);
284
+	foreach ($hooks as $name => $deprecation_info) {
285
+		if (has_action($name)) {
286
+			EE_Error::doing_it_wrong(
287
+				$name,
288
+				sprintf(
289
+					__('This filter is deprecated. %1$s%2$s', 'event_espresso'),
290
+					$deprecation_info['still_works'] ? __(
291
+						'It *may* work as an attempt to build in backwards compatibility.',
292
+						'event_espresso'
293
+					) : __('It has been completely removed.', 'event_espresso'),
294
+					isset($deprecation_info['alternative'])
295
+						? $deprecation_info['alternative']
296
+						: __(
297
+						'Please read the current EE4 documentation further or contact Support.',
298
+						'event_espresso'
299
+					)
300
+				),
301
+				isset($deprecation_info['version']) ? $deprecation_info['version'] : __('recently', 'event_espresso')
302
+			);
303
+		}
304
+	}
305 305
 }
306 306
 
307 307
 add_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', 'ee_deprecated_hooks');
@@ -316,34 +316,34 @@  discard block
 block discarded – undo
316 316
  */
317 317
 function ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
318 318
 {
319
-    $in_use = has_filter('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns')
320
-              || has_action(
321
-                  'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save'
322
-              );
323
-    if ($in_use) {
324
-        $msg = __(
325
-            'We detected you are using the filter FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns or AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save.'
326
-            . 'Both of these have been deprecated and should not be used anymore. You should instead use FHEE__EE_Form_Section_Proper___construct__options_array to customize the contents of the form,'
327
-            . 'use FHEE__EE_Form_Section_Proper__receive_form_submission__req_data to customize the submission data, or AHEE__EE_Form_Section_Proper__receive_form_submission__end '
328
-            . 'to add other actions after a form submission has been received.',
329
-            'event_espresso'
330
-        );
331
-        EE_Error::doing_it_wrong(
332
-            __CLASS__ . '::' . __FUNCTION__,
333
-            $msg,
334
-            '4.8.32.rc.000'
335
-        );
336
-        // it seems the doing_it_wrong messages get output during some hidden html tags, so add an error to make sure this gets noticed
337
-        if (is_admin() && ! defined('DOING_AJAX')) {
338
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
339
-        }
340
-    }
341
-    return $in_use;
319
+	$in_use = has_filter('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns')
320
+			  || has_action(
321
+				  'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save'
322
+			  );
323
+	if ($in_use) {
324
+		$msg = __(
325
+			'We detected you are using the filter FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns or AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save.'
326
+			. 'Both of these have been deprecated and should not be used anymore. You should instead use FHEE__EE_Form_Section_Proper___construct__options_array to customize the contents of the form,'
327
+			. 'use FHEE__EE_Form_Section_Proper__receive_form_submission__req_data to customize the submission data, or AHEE__EE_Form_Section_Proper__receive_form_submission__end '
328
+			. 'to add other actions after a form submission has been received.',
329
+			'event_espresso'
330
+		);
331
+		EE_Error::doing_it_wrong(
332
+			__CLASS__ . '::' . __FUNCTION__,
333
+			$msg,
334
+			'4.8.32.rc.000'
335
+		);
336
+		// it seems the doing_it_wrong messages get output during some hidden html tags, so add an error to make sure this gets noticed
337
+		if (is_admin() && ! defined('DOING_AJAX')) {
338
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
339
+		}
340
+	}
341
+	return $in_use;
342 342
 }
343 343
 
344 344
 add_action(
345
-    'AHEE__Registrations_Admin_Page___registration_details_metabox__start',
346
-    'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks'
345
+	'AHEE__Registrations_Admin_Page___registration_details_metabox__start',
346
+	'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks'
347 347
 );
348 348
 
349 349
 /**
@@ -355,77 +355,77 @@  discard block
 block discarded – undo
355 355
  */
356 356
 function ee_deprecated_update_attendee_registration_form_old($admin_page)
357 357
 {
358
-    // check if the old hooks are in use. If not, do the default
359
-    if (! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
360
-        || ! $admin_page instanceof EE_Admin_Page) {
361
-        return;
362
-    }
363
-    $req_data = $admin_page->get_request_data();
364
-    $qstns = isset($req_data['qstn']) ? $req_data['qstn'] : false;
365
-    $REG_ID = isset($req_data['_REG_ID']) ? absint($req_data['_REG_ID']) : false;
366
-    $qstns = apply_filters('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns);
367
-    if (! $REG_ID || ! $qstns) {
368
-        EE_Error::add_error(
369
-            __('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'),
370
-            __FILE__,
371
-            __FUNCTION__,
372
-            __LINE__
373
-        );
374
-    }
375
-    $success = true;
376
-
377
-    // allow others to get in on this awesome fun   :D
378
-    do_action(
379
-        'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save',
380
-        $REG_ID,
381
-        $qstns
382
-    );
383
-    // loop thru questions... FINALLY!!!
384
-
385
-    foreach ($qstns as $QST_ID => $qstn) {
386
-        // if $qstn isn't an array then it doesn't already have an answer, so let's create the answer
387
-        if (! is_array($qstn)) {
388
-            $success = $this->_save_new_answer($REG_ID, $QST_ID, $qstn);
389
-            continue;
390
-        }
391
-
392
-
393
-        foreach ($qstn as $ANS_ID => $ANS_value) {
394
-            // get answer
395
-            $query_params = array(
396
-                0 => array(
397
-                    'ANS_ID' => $ANS_ID,
398
-                    'REG_ID' => $REG_ID,
399
-                    'QST_ID' => $QST_ID,
400
-                ),
401
-            );
402
-            $answer = EEM_Answer::instance()->get_one($query_params);
403
-            // this MAY be an array but NOT have an answer because its multi select.  If so then we need to create the answer
404
-            if (! $answer instanceof EE_Answer) {
405
-                $set_values = array(
406
-                    'QST_ID'    => $QST_ID,
407
-                    'REG_ID'    => $REG_ID,
408
-                    'ANS_value' => $qstn,
409
-                );
410
-                $success = EEM_Answer::instance()->insert($set_values);
411
-                continue 2;
412
-            }
413
-
414
-            $answer->set('ANS_value', $ANS_value);
415
-            $success = $answer->save();
416
-        }
417
-    }
418
-    $what = __('Registration Form', 'event_espresso');
419
-    $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) : array('action' => 'default');
420
-    $admin_page->redirect_after_action($success, $what, __('updated', 'event_espresso'), $route);
421
-    exit;
358
+	// check if the old hooks are in use. If not, do the default
359
+	if (! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
360
+		|| ! $admin_page instanceof EE_Admin_Page) {
361
+		return;
362
+	}
363
+	$req_data = $admin_page->get_request_data();
364
+	$qstns = isset($req_data['qstn']) ? $req_data['qstn'] : false;
365
+	$REG_ID = isset($req_data['_REG_ID']) ? absint($req_data['_REG_ID']) : false;
366
+	$qstns = apply_filters('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns);
367
+	if (! $REG_ID || ! $qstns) {
368
+		EE_Error::add_error(
369
+			__('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'),
370
+			__FILE__,
371
+			__FUNCTION__,
372
+			__LINE__
373
+		);
374
+	}
375
+	$success = true;
376
+
377
+	// allow others to get in on this awesome fun   :D
378
+	do_action(
379
+		'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save',
380
+		$REG_ID,
381
+		$qstns
382
+	);
383
+	// loop thru questions... FINALLY!!!
384
+
385
+	foreach ($qstns as $QST_ID => $qstn) {
386
+		// if $qstn isn't an array then it doesn't already have an answer, so let's create the answer
387
+		if (! is_array($qstn)) {
388
+			$success = $this->_save_new_answer($REG_ID, $QST_ID, $qstn);
389
+			continue;
390
+		}
391
+
392
+
393
+		foreach ($qstn as $ANS_ID => $ANS_value) {
394
+			// get answer
395
+			$query_params = array(
396
+				0 => array(
397
+					'ANS_ID' => $ANS_ID,
398
+					'REG_ID' => $REG_ID,
399
+					'QST_ID' => $QST_ID,
400
+				),
401
+			);
402
+			$answer = EEM_Answer::instance()->get_one($query_params);
403
+			// this MAY be an array but NOT have an answer because its multi select.  If so then we need to create the answer
404
+			if (! $answer instanceof EE_Answer) {
405
+				$set_values = array(
406
+					'QST_ID'    => $QST_ID,
407
+					'REG_ID'    => $REG_ID,
408
+					'ANS_value' => $qstn,
409
+				);
410
+				$success = EEM_Answer::instance()->insert($set_values);
411
+				continue 2;
412
+			}
413
+
414
+			$answer->set('ANS_value', $ANS_value);
415
+			$success = $answer->save();
416
+		}
417
+	}
418
+	$what = __('Registration Form', 'event_espresso');
419
+	$route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) : array('action' => 'default');
420
+	$admin_page->redirect_after_action($success, $what, __('updated', 'event_espresso'), $route);
421
+	exit;
422 422
 }
423 423
 
424 424
 add_action(
425
-    'AHEE__Registrations_Admin_Page___update_attendee_registration_form__start',
426
-    'ee_deprecated_update_attendee_registration_form_old',
427
-    10,
428
-    1
425
+	'AHEE__Registrations_Admin_Page___update_attendee_registration_form__start',
426
+	'ee_deprecated_update_attendee_registration_form_old',
427
+	10,
428
+	1
429 429
 );
430 430
 /**
431 431
  * Render the registration admin page's custom questions area in the old fashion
@@ -441,50 +441,50 @@  discard block
 block discarded – undo
441 441
  */
442 442
 function ee_deprecated_reg_questions_meta_box_old($do_default_action, $admin_page, $registration)
443 443
 {
444
-    // check if the old hooks are in use. If not, do the default
445
-    if (! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
446
-        || ! $admin_page instanceof EE_Admin_Page) {
447
-        return $do_default_action;
448
-    }
449
-    add_filter(
450
-        'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions',
451
-        array($admin_page, 'form_before_question_group'),
452
-        10,
453
-        1
454
-    );
455
-    add_filter(
456
-        'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions',
457
-        array($admin_page, 'form_after_question_group'),
458
-        10,
459
-        1
460
-    );
461
-    add_filter('FHEE__EEH_Form_Fields__label_html', array($admin_page, 'form_form_field_label_wrap'), 10, 1);
462
-    add_filter('FHEE__EEH_Form_Fields__input_html', array($admin_page, 'form_form_field_input__wrap'), 10, 1);
463
-
464
-    $question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options(
465
-        $registration,
466
-        $registration->get(
467
-            'EVT_ID'
468
-        )
469
-    );
470
-
471
-    EE_Registry::instance()->load_helper('Form_Fields');
472
-    $template_args = array(
473
-        'att_questions'             => EEH_Form_Fields::generate_question_groups_html($question_groups),
474
-        'reg_questions_form_action' => 'edit_registration',
475
-        'REG_ID'                    => $registration->ID(),
476
-    );
477
-    $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
478
-    echo EEH_Template::display_template($template_path, $template_args, true);
479
-    // indicate that we should not do the default admin page code
480
-    return false;
444
+	// check if the old hooks are in use. If not, do the default
445
+	if (! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
446
+		|| ! $admin_page instanceof EE_Admin_Page) {
447
+		return $do_default_action;
448
+	}
449
+	add_filter(
450
+		'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions',
451
+		array($admin_page, 'form_before_question_group'),
452
+		10,
453
+		1
454
+	);
455
+	add_filter(
456
+		'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions',
457
+		array($admin_page, 'form_after_question_group'),
458
+		10,
459
+		1
460
+	);
461
+	add_filter('FHEE__EEH_Form_Fields__label_html', array($admin_page, 'form_form_field_label_wrap'), 10, 1);
462
+	add_filter('FHEE__EEH_Form_Fields__input_html', array($admin_page, 'form_form_field_input__wrap'), 10, 1);
463
+
464
+	$question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options(
465
+		$registration,
466
+		$registration->get(
467
+			'EVT_ID'
468
+		)
469
+	);
470
+
471
+	EE_Registry::instance()->load_helper('Form_Fields');
472
+	$template_args = array(
473
+		'att_questions'             => EEH_Form_Fields::generate_question_groups_html($question_groups),
474
+		'reg_questions_form_action' => 'edit_registration',
475
+		'REG_ID'                    => $registration->ID(),
476
+	);
477
+	$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
478
+	echo EEH_Template::display_template($template_path, $template_args, true);
479
+	// indicate that we should not do the default admin page code
480
+	return false;
481 481
 }
482 482
 
483 483
 add_action(
484
-    'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default',
485
-    'ee_deprecated_reg_questions_meta_box_old',
486
-    10,
487
-    3
484
+	'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default',
485
+	'ee_deprecated_reg_questions_meta_box_old',
486
+	10,
487
+	3
488 488
 );
489 489
 
490 490
 
@@ -501,42 +501,42 @@  discard block
 block discarded – undo
501 501
 class EE_Message_Template_Defaults extends EE_Base
502 502
 {
503 503
 
504
-    /**
505
-     * EE_Message_Template_Defaults constructor.
506
-     *
507
-     * @param EE_messages $messages
508
-     * @param             $messenger_name
509
-     * @param             $message_type_name
510
-     * @param int         $GRP_ID
511
-     * @return EE_Messages_Template_Defaults
512
-     */
513
-    public function __construct(
514
-        EE_messages $messages,
515
-        $messenger_name,
516
-        $message_type_name,
517
-        $GRP_ID = 0
518
-    ) {
519
-        EE_Error::doing_it_wrong(
520
-            __FUNCTION__,
521
-            __(
522
-                'The class EE_Message_Template_Defaults has been deprecated and replaced by EE_Messages_Template_Defaults.',
523
-                'event_espresso'
524
-            ),
525
-            '4.9.0'
526
-        );
527
-        /** @var EE_Message_Resource_Manager $message_resource_manager */
528
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
529
-        $messenger = $message_resource_manager->get_messenger($messenger_name);
530
-        $message_type = $message_resource_manager->get_message_type($message_type_name);
531
-        return EE_Registry::instance()->load_lib(
532
-            'Messages_Template_Defaults',
533
-            array(
534
-                $GRP_ID,
535
-                $messenger,
536
-                $message_type,
537
-            )
538
-        );
539
-    }
504
+	/**
505
+	 * EE_Message_Template_Defaults constructor.
506
+	 *
507
+	 * @param EE_messages $messages
508
+	 * @param             $messenger_name
509
+	 * @param             $message_type_name
510
+	 * @param int         $GRP_ID
511
+	 * @return EE_Messages_Template_Defaults
512
+	 */
513
+	public function __construct(
514
+		EE_messages $messages,
515
+		$messenger_name,
516
+		$message_type_name,
517
+		$GRP_ID = 0
518
+	) {
519
+		EE_Error::doing_it_wrong(
520
+			__FUNCTION__,
521
+			__(
522
+				'The class EE_Message_Template_Defaults has been deprecated and replaced by EE_Messages_Template_Defaults.',
523
+				'event_espresso'
524
+			),
525
+			'4.9.0'
526
+		);
527
+		/** @var EE_Message_Resource_Manager $message_resource_manager */
528
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
529
+		$messenger = $message_resource_manager->get_messenger($messenger_name);
530
+		$message_type = $message_resource_manager->get_message_type($message_type_name);
531
+		return EE_Registry::instance()->load_lib(
532
+			'Messages_Template_Defaults',
533
+			array(
534
+				$GRP_ID,
535
+				$messenger,
536
+				$message_type,
537
+			)
538
+		);
539
+	}
540 540
 }
541 541
 
542 542
 
@@ -554,525 +554,525 @@  discard block
 block discarded – undo
554 554
 class EE_messages
555 555
 {
556 556
 
557
-    /** @type EE_messenger[] */
558
-    protected $_active_messengers = array();
559
-
560
-    /** @type array */
561
-    protected $_active_message_types = array();
562
-
563
-    /** @type EE_message_type[] */
564
-    protected $_installed_message_types = array();
565
-
566
-    /** @type EE_messenger */
567
-    protected $_messenger;
568
-
569
-    /** @type EE_message_type */
570
-    protected $_message_type;
571
-
572
-    /** @type array */
573
-    protected $_contexts = array();
574
-
575
-    /** @type EE_Message_Resource_Manager $_message_resource_manager */
576
-    protected $_message_resource_manager;
577
-
578
-
579
-    /**
580
-     * EE_messages constructor.
581
-     *
582
-     * @deprecated 4.9.0
583
-     */
584
-    public function __construct()
585
-    {
586
-    }
587
-
588
-
589
-    /**
590
-     * @param string $method
591
-     */
592
-    public function _class_is_deprecated($method)
593
-    {
594
-        EE_Error::doing_it_wrong(
595
-            'EE_messages::' . $method,
596
-            __('EE_messages has been deprecated.  Please use EE_Message_Resource_Manager instead.'),
597
-            '4.9.0',
598
-            '4.10.0.p'
599
-        );
600
-        // Please use EE_Message_Resource_Manager instead
601
-        $this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
602
-    }
603
-
604
-
605
-    /**
606
-     * @deprecated 4.9.0
607
-     * @param string $messenger_name
608
-     * @return boolean TRUE if it was PREVIOUSLY active, and FALSE if it was previously inactive
609
-     */
610
-    public function ensure_messenger_is_active($messenger_name)
611
-    {
612
-        // EE_messages has been deprecated
613
-        $this->_class_is_deprecated(__FUNCTION__);
614
-        return $this->_message_resource_manager->ensure_messenger_is_active($messenger_name);
615
-    }
616
-
617
-
618
-    /**
619
-     * @deprecated 4.9.0
620
-     * @param string $message_type message type name
621
-     * @param        $messenger
622
-     * @return bool true if it got activated (or was active) and false if not.
623
-     * @throws \EE_Error
624
-     */
625
-    public function ensure_message_type_is_active($message_type, $messenger)
626
-    {
627
-        // EE_messages has been deprecated
628
-        $this->_class_is_deprecated(__FUNCTION__);
629
-        return $this->_message_resource_manager->ensure_message_type_is_active($message_type, $messenger);
630
-    }
631
-
632
-
633
-    /**
634
-     * @deprecated 4.9.0
635
-     * @param string $messenger_name
636
-     * @param array  $mts_to_activate             (optional) An array of message types to activate with this messenger.
637
-     *                                             If included we do NOT setup the default message types (assuming they
638
-     *                                             are already setup.)
639
-     * @return boolean an array of generated templates or false if nothing generated/activated.
640
-     */
641
-    public function activate_messenger($messenger_name, $mts_to_activate = array())
642
-    {
643
-        // EE_messages has been deprecated
644
-        $this->_class_is_deprecated(__FUNCTION__);
645
-        return $this->_message_resource_manager->activate_messenger($messenger_name, $mts_to_activate);
646
-    }
647
-
648
-
649
-    /**
650
-     * @deprecated 4.9.0
651
-     * @param EE_messenger    $messenger    messenger used in trigger
652
-     * @param EE_message_type $message_type message type used in trigger
653
-     *
654
-     * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send.
655
-     */
656
-    public function is_generating_messenger_and_active(EE_messenger $messenger, EE_message_type $message_type)
657
-    {
658
-        // EE_messages has been deprecated
659
-        $this->_class_is_deprecated(__FUNCTION__);
660
-        return $this->_message_resource_manager->is_generating_messenger_and_active($messenger, $message_type);
661
-    }
662
-
663
-
664
-    /**
665
-     * @deprecated 4.9.0
666
-     * @param string $messenger
667
-     * @return EE_messenger | null
668
-     */
669
-    public function get_messenger_if_active($messenger)
670
-    {
671
-        // EE_messages has been deprecated
672
-        $this->_class_is_deprecated(__FUNCTION__);
673
-        return $this->_message_resource_manager->get_active_messenger($messenger);
674
-    }
675
-
676
-
677
-    /**
678
-     * @deprecated 4.9.0
679
-     * @param EE_Message $message
680
-     * @return array  An array with 'messenger' and 'message_type' as the index and the corresponding valid object if
681
-     *                  available.
682
-     *                  Eg. Valid Messenger and Message Type:
683
-     *                  array(
684
-     *                  'messenger' => new EE_Email_messenger(),
685
-     *                  'message_type' => new EE_Registration_Approved_message_type()
686
-     *                  )
687
-     *                  Valid Messenger and Invalid Message Type:
688
-     *                  array(
689
-     *                  'messenger' => new EE_Email_messenger(),
690
-     *                  'message_type' => null
691
-     *                  )
692
-     */
693
-    public function validate_for_use(EE_Message $message)
694
-    {
695
-        // EE_messages has been deprecated
696
-        $this->_class_is_deprecated(__FUNCTION__);
697
-        return array(
698
-            'messenger'    => $message->messenger_object(),
699
-            'message_type' => $message->message_type_object(),
700
-        );
701
-    }
702
-
703
-
704
-    /**
705
-     * @deprecated 4.9.0
706
-     * @param  string $type                 What type of message are we sending (corresponds to message types)
707
-     * @param  mixed  $vars                 Data being sent for parsing in the message
708
-     * @param  string $sending_messenger    if included then we ONLY use the specified messenger for delivery.
709
-     *                                      Otherwise we cycle through all active messengers.
710
-     * @param string  $generating_messenger if included then this messenger is used for generating the message
711
-     *                                      templates (but not for sending).
712
-     * @param string  $context              If included then only a message type for a specific context will be
713
-     *                                      generated.
714
-     * @param bool    $send                 Default TRUE.  If false, then this will just return the generated
715
-     *                                      EE_messages objects which might be used by the trigger to setup a batch
716
-     *                                      message (typically html messenger uses it).
717
-     * @return bool
718
-     */
719
-    public function send_message(
720
-        $type,
721
-        $vars,
722
-        $sending_messenger = '',
723
-        $generating_messenger = '',
724
-        $context = '',
725
-        $send = true
726
-    ) {
727
-        // EE_messages has been deprecated
728
-        $this->_class_is_deprecated(__FUNCTION__);
729
-        /** @type EE_Messages_Processor $processor */
730
-        $processor = EE_Registry::instance()->load_lib('Messages_Processor');
731
-        $error = false;
732
-        // try to intelligently determine what method we'll call based on the incoming data.
733
-        // if generating and sending are different then generate and send immediately.
734
-        if (! empty($sending_messenger) && $sending_messenger != $generating_messenger && $send) {
735
-            // in the legacy system, when generating and sending were different, that means all the
736
-            // vars are already in the request object.  So let's just use that.
737
-            try {
738
-                /** @type EE_Message_To_Generate_From_Request $mtg */
739
-                $mtg = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request');
740
-                $processor->generate_and_send_now($mtg);
741
-            } catch (EE_Error $e) {
742
-                $error_msg = __(
743
-                    'Please note that a system message failed to send due to a technical issue.',
744
-                    'event_espresso'
745
-                );
746
-                // add specific message for developers if WP_DEBUG in on
747
-                $error_msg .= '||' . $e->getMessage();
748
-                EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
749
-                $error = true;
750
-            }
751
-        } else {
752
-            $processor->generate_for_all_active_messengers($type, $vars, $send);
753
-            // let's find out if there were any errors and how many successfully were queued.
754
-            $count_errors = $processor->get_queue()->count_STS_in_queue(
755
-                array(EEM_Message::status_failed, EEM_Message::status_debug_only)
756
-            );
757
-            $count_queued = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_incomplete);
758
-            $count_retry = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_retry);
759
-            $count_errors = $count_errors + $count_retry;
760
-            if ($count_errors > 0) {
761
-                $error = true;
762
-                if ($count_errors > 1 && $count_retry > 1 && $count_queued > 1) {
763
-                    $message = sprintf(
764
-                        __(
765
-                            'There were %d errors and %d messages successfully queued for generation and sending',
766
-                            'event_espresso'
767
-                        ),
768
-                        $count_errors,
769
-                        $count_queued
770
-                    );
771
-                } elseif ($count_errors > 1 && $count_queued === 1) {
772
-                    $message = sprintf(
773
-                        __(
774
-                            'There were %d errors and %d message successfully queued for generation.',
775
-                            'event_espresso'
776
-                        ),
777
-                        $count_errors,
778
-                        $count_queued
779
-                    );
780
-                } elseif ($count_errors === 1 && $count_queued > 1) {
781
-                    $message = sprintf(
782
-                        __(
783
-                            'There was %d error and %d messages successfully queued for generation.',
784
-                            'event_espresso'
785
-                        ),
786
-                        $count_errors,
787
-                        $count_queued
788
-                    );
789
-                } else {
790
-                    $message = sprintf(
791
-                        __(
792
-                            'There was %d message that failed to be queued for generation.',
793
-                            'event_espresso'
794
-                        ),
795
-                        $count_errors
796
-                    );
797
-                }
798
-                EE_Error::add_error($message, __FILE__, __FUNCTION__, __LINE__);
799
-            } else {
800
-                if ($count_queued === 1) {
801
-                    $message = sprintf(
802
-                        __(
803
-                            '%d message successfully queued for generation.',
804
-                            'event_espresso'
805
-                        ),
806
-                        $count_queued
807
-                    );
808
-                } else {
809
-                    $message = sprintf(
810
-                        __(
811
-                            '%d messages were successfully queued for generation.',
812
-                            'event_espresso'
813
-                        ),
814
-                        $count_queued
815
-                    );
816
-                }
817
-                EE_Error::add_success($message);
818
-            }
819
-        }
820
-        // if no error then return the generated message(s).
821
-        if (! $error && ! $send) {
822
-            $generated_queue = $processor->generate_queue(false);
823
-            // get message and return.
824
-            $generated_queue->get_message_repository()->rewind();
825
-            $messages = array();
826
-            while ($generated_queue->get_message_repository()->valid()) {
827
-                $message = $generated_queue->get_message_repository()->current();
828
-                if ($message instanceof EE_Message) {
829
-                    // set properties that might be expected by add-ons (backward compat)
830
-                    $message->content = $message->content();
831
-                    $message->template_pack = $message->get_template_pack();
832
-                    $message->template_variation = $message->get_template_pack_variation();
833
-                    $messages[] = $message;
834
-                }
835
-                $generated_queue->get_message_repository()->next();
836
-            }
837
-            return $messages;
838
-        }
839
-        return $error ? false
840
-            : true; // yeah backwards eh?  Really what we're returning is if there is a total success for all the messages or not.  We'll modify this once we get message recording in place.
841
-    }
842
-
843
-
844
-    /**
845
-     * @deprecated 4.9.0
846
-     * @param  string $type      This should correspond with a valid message type
847
-     * @param  string $context   This should correspond with a valid context for the message type
848
-     * @param  string $messenger This should correspond with a valid messenger.
849
-     * @param bool    $send      true we will do a test send using the messenger delivery, false we just do a regular
850
-     *                           preview
851
-     * @return string          The body of the message.
852
-     */
853
-    public function preview_message($type, $context, $messenger, $send = false)
854
-    {
855
-        // EE_messages has been deprecated
856
-        $this->_class_is_deprecated(__FUNCTION__);
857
-        return EED_Messages::preview_message($type, $context, $messenger, $send);
858
-    }
859
-
860
-
861
-    /**
862
-     * @since      4.5.0
863
-     * @deprecated 4.9.0   Moved to EED_Messages Module
864
-     * @param string   $messenger    a string matching a valid active messenger in the system
865
-     * @param string   $message_type Although it seems contrary to the name of the method, a message type name is still
866
-     *                               required to send along the message type to the messenger because this is used for
867
-     *                               determining what specific variations might be loaded for the generated message.
868
-     * @param stdClass $message      a stdClass object in the format expected by the messenger.
869
-     *
870
-     * @return bool          success or fail.
871
-     */
872
-    public function send_message_with_messenger_only($messenger, $message_type, $message)
873
-    {
874
-        // EE_messages has been deprecated
875
-        $this->_class_is_deprecated(__FUNCTION__);
876
-        // setup for sending to new method.
877
-        /** @type EE_Messages_Queue $queue */
878
-        $queue = EE_Registry::instance()->load_lib('Messages_Queue');
879
-        // make sure we have a proper message object
880
-        if (! $message instanceof EE_Message && is_object($message) && isset($message->content)) {
881
-            $msg = EE_Message_Factory::create(
882
-                array(
883
-                    'MSG_messenger'    => $messenger,
884
-                    'MSG_message_type' => $message_type,
885
-                    'MSG_content'      => $message->content,
886
-                    'MSG_subject'      => $message->subject,
887
-                )
888
-            );
889
-        } else {
890
-            $msg = $message;
891
-        }
892
-        if (! $msg instanceof EE_Message) {
893
-            return false;
894
-        }
895
-        // make sure any content in a content property (if not empty) is set on the MSG_content.
896
-        if (! empty($msg->content)) {
897
-            $msg->set('MSG_content', $msg->content);
898
-        }
899
-        $queue->add($msg);
900
-        return EED_Messages::send_message_with_messenger_only($messenger, $message_type, $queue);
901
-    }
902
-
903
-
904
-    /**
905
-     * @deprecated 4.9.0
906
-     * @param         $messenger
907
-     * @param  string $message_type message type that the templates are being created for
908
-     * @param int     $GRP_ID
909
-     * @param bool    $is_global
910
-     * @return array|object if creation is successful then we return an array of info, otherwise an error_object is
911
-     *                      returned.
912
-     * @throws \EE_Error
913
-     */
914
-    public function create_new_templates($messenger, $message_type, $GRP_ID = 0, $is_global = false)
915
-    {
916
-        // EE_messages has been deprecated
917
-        $this->_class_is_deprecated(__FUNCTION__);
918
-        EE_Registry::instance()->load_helper('MSG_Template');
919
-        return EEH_MSG_Template::create_new_templates($messenger, $message_type, $GRP_ID, $is_global);
920
-    }
921
-
922
-
923
-    /**
924
-     * @deprecated 4.9.0
925
-     * @param  string $messenger_name    name of EE_messenger
926
-     * @param  string $message_type_name name of EE_message_type
927
-     * @return array
928
-     */
929
-    public function get_fields($messenger_name, $message_type_name)
930
-    {
931
-        // EE_messages has been deprecated
932
-        $this->_class_is_deprecated(__FUNCTION__);
933
-        EE_Registry::instance()->load_helper('MSG_Template');
934
-        return EEH_MSG_Template::get_fields($messenger_name, $message_type_name);
935
-    }
936
-
937
-
938
-    /**
939
-     * @deprecated 4.9.0
940
-     * @access     public
941
-     * @param string $type                we can indicate just returning installed message types
942
-     *                                    or messengers (or both) via this parameter.
943
-     * @param bool   $skip_cache          if true then we skip the cache and retrieve via files.
944
-     * @return array                    multidimensional array of messenger and message_type objects
945
-     *                                    (messengers index, and message_type index);
946
-     */
947
-    public function get_installed($type = 'all', $skip_cache = false)
948
-    {
949
-        // EE_messages has been deprecated
950
-        $this->_class_is_deprecated(__FUNCTION__);
951
-        if ($skip_cache) {
952
-            $this->_message_resource_manager->reset_active_messengers_and_message_types();
953
-        }
954
-        switch ($type) {
955
-            case 'messengers' :
956
-                return array(
957
-                    'messenger' => $this->_message_resource_manager->installed_messengers(),
958
-                );
959
-                break;
960
-            case 'message_types' :
961
-                return array(
962
-                    'message_type' => $this->_message_resource_manager->installed_message_types(),
963
-                );
964
-                break;
965
-            case 'all' :
966
-            default :
967
-                return array(
968
-                    'messenger'    => $this->_message_resource_manager->installed_messengers(),
969
-                    'message_type' => $this->_message_resource_manager->installed_message_types(),
970
-                );
971
-                break;
972
-        }
973
-    }
974
-
975
-
976
-    /**
977
-     * @deprecated 4.9.0
978
-     * @return \EE_messenger[]
979
-     */
980
-    public function get_active_messengers()
981
-    {
982
-        // EE_messages has been deprecated
983
-        $this->_class_is_deprecated(__FUNCTION__);
984
-        return $this->_message_resource_manager->active_messengers();
985
-    }
986
-
987
-
988
-    /**
989
-     * @deprecated 4.9.0
990
-     * @return array array of message_type references (string)
991
-     */
992
-    public function get_active_message_types()
993
-    {
994
-        // EE_messages has been deprecated
995
-        $this->_class_is_deprecated(__FUNCTION__);
996
-        return $this->_message_resource_manager->list_of_active_message_types();
997
-    }
998
-
999
-
1000
-    /**
1001
-     * @deprecated 4.9.0
1002
-     * @return EE_message_type[]
1003
-     */
1004
-    public function get_active_message_type_objects()
1005
-    {
1006
-        // EE_messages has been deprecated
1007
-        $this->_class_is_deprecated(__FUNCTION__);
1008
-        return $this->_message_resource_manager->get_active_message_type_objects();
1009
-    }
1010
-
1011
-
1012
-    /**
1013
-     * @deprecated 4.9.0
1014
-     * @since      4.5.0
1015
-     * @param string $messenger The messenger being checked
1016
-     * @return EE_message_type[]    (or empty array if none present)
1017
-     */
1018
-    public function get_active_message_types_per_messenger($messenger)
1019
-    {
1020
-        // EE_messages has been deprecated
1021
-        $this->_class_is_deprecated(__FUNCTION__);
1022
-        return $this->_message_resource_manager->get_active_message_types_for_messenger($messenger);
1023
-    }
1024
-
1025
-
1026
-    /**
1027
-     * @deprecated 4.9.0
1028
-     * @param string $messenger    The string should correspond to the messenger (message types are
1029
-     * @param string $message_type The string should correspond to a message type.
1030
-     * @return EE_message_type|null
1031
-     */
1032
-    public function get_active_message_type($messenger, $message_type)
1033
-    {
1034
-        // EE_messages has been deprecated
1035
-        $this->_class_is_deprecated(__FUNCTION__);
1036
-        return $this->_message_resource_manager->get_active_message_type_for_messenger($messenger, $message_type);
1037
-    }
1038
-
1039
-
1040
-    /**
1041
-     * @deprecated 4.9.0
1042
-     * @return array|\EE_message_type[]
1043
-     */
1044
-    public function get_installed_message_types()
1045
-    {
1046
-        // EE_messages has been deprecated
1047
-        $this->_class_is_deprecated(__FUNCTION__);
1048
-        return $this->_message_resource_manager->installed_message_types();
1049
-    }
1050
-
1051
-
1052
-    /**
1053
-     * @deprecated 4.9.0
1054
-     * @return array
1055
-     */
1056
-    public function get_installed_messengers()
1057
-    {
1058
-        // EE_messages has been deprecated
1059
-        $this->_class_is_deprecated(__FUNCTION__);
1060
-        return $this->_message_resource_manager->installed_messengers();
1061
-    }
1062
-
1063
-
1064
-    /**
1065
-     * @deprecated 4.9.0
1066
-     * @param   bool $slugs_only Whether to return an array of just slugs and labels (true) or all contexts indexed by
1067
-     *                           message type.
1068
-     * @return array
1069
-     */
1070
-    public function get_all_contexts($slugs_only = true)
1071
-    {
1072
-        // EE_messages has been deprecated
1073
-        $this->_class_is_deprecated(__FUNCTION__);
1074
-        return $this->_message_resource_manager->get_all_contexts($slugs_only);
1075
-    }
557
+	/** @type EE_messenger[] */
558
+	protected $_active_messengers = array();
559
+
560
+	/** @type array */
561
+	protected $_active_message_types = array();
562
+
563
+	/** @type EE_message_type[] */
564
+	protected $_installed_message_types = array();
565
+
566
+	/** @type EE_messenger */
567
+	protected $_messenger;
568
+
569
+	/** @type EE_message_type */
570
+	protected $_message_type;
571
+
572
+	/** @type array */
573
+	protected $_contexts = array();
574
+
575
+	/** @type EE_Message_Resource_Manager $_message_resource_manager */
576
+	protected $_message_resource_manager;
577
+
578
+
579
+	/**
580
+	 * EE_messages constructor.
581
+	 *
582
+	 * @deprecated 4.9.0
583
+	 */
584
+	public function __construct()
585
+	{
586
+	}
587
+
588
+
589
+	/**
590
+	 * @param string $method
591
+	 */
592
+	public function _class_is_deprecated($method)
593
+	{
594
+		EE_Error::doing_it_wrong(
595
+			'EE_messages::' . $method,
596
+			__('EE_messages has been deprecated.  Please use EE_Message_Resource_Manager instead.'),
597
+			'4.9.0',
598
+			'4.10.0.p'
599
+		);
600
+		// Please use EE_Message_Resource_Manager instead
601
+		$this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
602
+	}
603
+
604
+
605
+	/**
606
+	 * @deprecated 4.9.0
607
+	 * @param string $messenger_name
608
+	 * @return boolean TRUE if it was PREVIOUSLY active, and FALSE if it was previously inactive
609
+	 */
610
+	public function ensure_messenger_is_active($messenger_name)
611
+	{
612
+		// EE_messages has been deprecated
613
+		$this->_class_is_deprecated(__FUNCTION__);
614
+		return $this->_message_resource_manager->ensure_messenger_is_active($messenger_name);
615
+	}
616
+
617
+
618
+	/**
619
+	 * @deprecated 4.9.0
620
+	 * @param string $message_type message type name
621
+	 * @param        $messenger
622
+	 * @return bool true if it got activated (or was active) and false if not.
623
+	 * @throws \EE_Error
624
+	 */
625
+	public function ensure_message_type_is_active($message_type, $messenger)
626
+	{
627
+		// EE_messages has been deprecated
628
+		$this->_class_is_deprecated(__FUNCTION__);
629
+		return $this->_message_resource_manager->ensure_message_type_is_active($message_type, $messenger);
630
+	}
631
+
632
+
633
+	/**
634
+	 * @deprecated 4.9.0
635
+	 * @param string $messenger_name
636
+	 * @param array  $mts_to_activate             (optional) An array of message types to activate with this messenger.
637
+	 *                                             If included we do NOT setup the default message types (assuming they
638
+	 *                                             are already setup.)
639
+	 * @return boolean an array of generated templates or false if nothing generated/activated.
640
+	 */
641
+	public function activate_messenger($messenger_name, $mts_to_activate = array())
642
+	{
643
+		// EE_messages has been deprecated
644
+		$this->_class_is_deprecated(__FUNCTION__);
645
+		return $this->_message_resource_manager->activate_messenger($messenger_name, $mts_to_activate);
646
+	}
647
+
648
+
649
+	/**
650
+	 * @deprecated 4.9.0
651
+	 * @param EE_messenger    $messenger    messenger used in trigger
652
+	 * @param EE_message_type $message_type message type used in trigger
653
+	 *
654
+	 * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send.
655
+	 */
656
+	public function is_generating_messenger_and_active(EE_messenger $messenger, EE_message_type $message_type)
657
+	{
658
+		// EE_messages has been deprecated
659
+		$this->_class_is_deprecated(__FUNCTION__);
660
+		return $this->_message_resource_manager->is_generating_messenger_and_active($messenger, $message_type);
661
+	}
662
+
663
+
664
+	/**
665
+	 * @deprecated 4.9.0
666
+	 * @param string $messenger
667
+	 * @return EE_messenger | null
668
+	 */
669
+	public function get_messenger_if_active($messenger)
670
+	{
671
+		// EE_messages has been deprecated
672
+		$this->_class_is_deprecated(__FUNCTION__);
673
+		return $this->_message_resource_manager->get_active_messenger($messenger);
674
+	}
675
+
676
+
677
+	/**
678
+	 * @deprecated 4.9.0
679
+	 * @param EE_Message $message
680
+	 * @return array  An array with 'messenger' and 'message_type' as the index and the corresponding valid object if
681
+	 *                  available.
682
+	 *                  Eg. Valid Messenger and Message Type:
683
+	 *                  array(
684
+	 *                  'messenger' => new EE_Email_messenger(),
685
+	 *                  'message_type' => new EE_Registration_Approved_message_type()
686
+	 *                  )
687
+	 *                  Valid Messenger and Invalid Message Type:
688
+	 *                  array(
689
+	 *                  'messenger' => new EE_Email_messenger(),
690
+	 *                  'message_type' => null
691
+	 *                  )
692
+	 */
693
+	public function validate_for_use(EE_Message $message)
694
+	{
695
+		// EE_messages has been deprecated
696
+		$this->_class_is_deprecated(__FUNCTION__);
697
+		return array(
698
+			'messenger'    => $message->messenger_object(),
699
+			'message_type' => $message->message_type_object(),
700
+		);
701
+	}
702
+
703
+
704
+	/**
705
+	 * @deprecated 4.9.0
706
+	 * @param  string $type                 What type of message are we sending (corresponds to message types)
707
+	 * @param  mixed  $vars                 Data being sent for parsing in the message
708
+	 * @param  string $sending_messenger    if included then we ONLY use the specified messenger for delivery.
709
+	 *                                      Otherwise we cycle through all active messengers.
710
+	 * @param string  $generating_messenger if included then this messenger is used for generating the message
711
+	 *                                      templates (but not for sending).
712
+	 * @param string  $context              If included then only a message type for a specific context will be
713
+	 *                                      generated.
714
+	 * @param bool    $send                 Default TRUE.  If false, then this will just return the generated
715
+	 *                                      EE_messages objects which might be used by the trigger to setup a batch
716
+	 *                                      message (typically html messenger uses it).
717
+	 * @return bool
718
+	 */
719
+	public function send_message(
720
+		$type,
721
+		$vars,
722
+		$sending_messenger = '',
723
+		$generating_messenger = '',
724
+		$context = '',
725
+		$send = true
726
+	) {
727
+		// EE_messages has been deprecated
728
+		$this->_class_is_deprecated(__FUNCTION__);
729
+		/** @type EE_Messages_Processor $processor */
730
+		$processor = EE_Registry::instance()->load_lib('Messages_Processor');
731
+		$error = false;
732
+		// try to intelligently determine what method we'll call based on the incoming data.
733
+		// if generating and sending are different then generate and send immediately.
734
+		if (! empty($sending_messenger) && $sending_messenger != $generating_messenger && $send) {
735
+			// in the legacy system, when generating and sending were different, that means all the
736
+			// vars are already in the request object.  So let's just use that.
737
+			try {
738
+				/** @type EE_Message_To_Generate_From_Request $mtg */
739
+				$mtg = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request');
740
+				$processor->generate_and_send_now($mtg);
741
+			} catch (EE_Error $e) {
742
+				$error_msg = __(
743
+					'Please note that a system message failed to send due to a technical issue.',
744
+					'event_espresso'
745
+				);
746
+				// add specific message for developers if WP_DEBUG in on
747
+				$error_msg .= '||' . $e->getMessage();
748
+				EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
749
+				$error = true;
750
+			}
751
+		} else {
752
+			$processor->generate_for_all_active_messengers($type, $vars, $send);
753
+			// let's find out if there were any errors and how many successfully were queued.
754
+			$count_errors = $processor->get_queue()->count_STS_in_queue(
755
+				array(EEM_Message::status_failed, EEM_Message::status_debug_only)
756
+			);
757
+			$count_queued = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_incomplete);
758
+			$count_retry = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_retry);
759
+			$count_errors = $count_errors + $count_retry;
760
+			if ($count_errors > 0) {
761
+				$error = true;
762
+				if ($count_errors > 1 && $count_retry > 1 && $count_queued > 1) {
763
+					$message = sprintf(
764
+						__(
765
+							'There were %d errors and %d messages successfully queued for generation and sending',
766
+							'event_espresso'
767
+						),
768
+						$count_errors,
769
+						$count_queued
770
+					);
771
+				} elseif ($count_errors > 1 && $count_queued === 1) {
772
+					$message = sprintf(
773
+						__(
774
+							'There were %d errors and %d message successfully queued for generation.',
775
+							'event_espresso'
776
+						),
777
+						$count_errors,
778
+						$count_queued
779
+					);
780
+				} elseif ($count_errors === 1 && $count_queued > 1) {
781
+					$message = sprintf(
782
+						__(
783
+							'There was %d error and %d messages successfully queued for generation.',
784
+							'event_espresso'
785
+						),
786
+						$count_errors,
787
+						$count_queued
788
+					);
789
+				} else {
790
+					$message = sprintf(
791
+						__(
792
+							'There was %d message that failed to be queued for generation.',
793
+							'event_espresso'
794
+						),
795
+						$count_errors
796
+					);
797
+				}
798
+				EE_Error::add_error($message, __FILE__, __FUNCTION__, __LINE__);
799
+			} else {
800
+				if ($count_queued === 1) {
801
+					$message = sprintf(
802
+						__(
803
+							'%d message successfully queued for generation.',
804
+							'event_espresso'
805
+						),
806
+						$count_queued
807
+					);
808
+				} else {
809
+					$message = sprintf(
810
+						__(
811
+							'%d messages were successfully queued for generation.',
812
+							'event_espresso'
813
+						),
814
+						$count_queued
815
+					);
816
+				}
817
+				EE_Error::add_success($message);
818
+			}
819
+		}
820
+		// if no error then return the generated message(s).
821
+		if (! $error && ! $send) {
822
+			$generated_queue = $processor->generate_queue(false);
823
+			// get message and return.
824
+			$generated_queue->get_message_repository()->rewind();
825
+			$messages = array();
826
+			while ($generated_queue->get_message_repository()->valid()) {
827
+				$message = $generated_queue->get_message_repository()->current();
828
+				if ($message instanceof EE_Message) {
829
+					// set properties that might be expected by add-ons (backward compat)
830
+					$message->content = $message->content();
831
+					$message->template_pack = $message->get_template_pack();
832
+					$message->template_variation = $message->get_template_pack_variation();
833
+					$messages[] = $message;
834
+				}
835
+				$generated_queue->get_message_repository()->next();
836
+			}
837
+			return $messages;
838
+		}
839
+		return $error ? false
840
+			: true; // yeah backwards eh?  Really what we're returning is if there is a total success for all the messages or not.  We'll modify this once we get message recording in place.
841
+	}
842
+
843
+
844
+	/**
845
+	 * @deprecated 4.9.0
846
+	 * @param  string $type      This should correspond with a valid message type
847
+	 * @param  string $context   This should correspond with a valid context for the message type
848
+	 * @param  string $messenger This should correspond with a valid messenger.
849
+	 * @param bool    $send      true we will do a test send using the messenger delivery, false we just do a regular
850
+	 *                           preview
851
+	 * @return string          The body of the message.
852
+	 */
853
+	public function preview_message($type, $context, $messenger, $send = false)
854
+	{
855
+		// EE_messages has been deprecated
856
+		$this->_class_is_deprecated(__FUNCTION__);
857
+		return EED_Messages::preview_message($type, $context, $messenger, $send);
858
+	}
859
+
860
+
861
+	/**
862
+	 * @since      4.5.0
863
+	 * @deprecated 4.9.0   Moved to EED_Messages Module
864
+	 * @param string   $messenger    a string matching a valid active messenger in the system
865
+	 * @param string   $message_type Although it seems contrary to the name of the method, a message type name is still
866
+	 *                               required to send along the message type to the messenger because this is used for
867
+	 *                               determining what specific variations might be loaded for the generated message.
868
+	 * @param stdClass $message      a stdClass object in the format expected by the messenger.
869
+	 *
870
+	 * @return bool          success or fail.
871
+	 */
872
+	public function send_message_with_messenger_only($messenger, $message_type, $message)
873
+	{
874
+		// EE_messages has been deprecated
875
+		$this->_class_is_deprecated(__FUNCTION__);
876
+		// setup for sending to new method.
877
+		/** @type EE_Messages_Queue $queue */
878
+		$queue = EE_Registry::instance()->load_lib('Messages_Queue');
879
+		// make sure we have a proper message object
880
+		if (! $message instanceof EE_Message && is_object($message) && isset($message->content)) {
881
+			$msg = EE_Message_Factory::create(
882
+				array(
883
+					'MSG_messenger'    => $messenger,
884
+					'MSG_message_type' => $message_type,
885
+					'MSG_content'      => $message->content,
886
+					'MSG_subject'      => $message->subject,
887
+				)
888
+			);
889
+		} else {
890
+			$msg = $message;
891
+		}
892
+		if (! $msg instanceof EE_Message) {
893
+			return false;
894
+		}
895
+		// make sure any content in a content property (if not empty) is set on the MSG_content.
896
+		if (! empty($msg->content)) {
897
+			$msg->set('MSG_content', $msg->content);
898
+		}
899
+		$queue->add($msg);
900
+		return EED_Messages::send_message_with_messenger_only($messenger, $message_type, $queue);
901
+	}
902
+
903
+
904
+	/**
905
+	 * @deprecated 4.9.0
906
+	 * @param         $messenger
907
+	 * @param  string $message_type message type that the templates are being created for
908
+	 * @param int     $GRP_ID
909
+	 * @param bool    $is_global
910
+	 * @return array|object if creation is successful then we return an array of info, otherwise an error_object is
911
+	 *                      returned.
912
+	 * @throws \EE_Error
913
+	 */
914
+	public function create_new_templates($messenger, $message_type, $GRP_ID = 0, $is_global = false)
915
+	{
916
+		// EE_messages has been deprecated
917
+		$this->_class_is_deprecated(__FUNCTION__);
918
+		EE_Registry::instance()->load_helper('MSG_Template');
919
+		return EEH_MSG_Template::create_new_templates($messenger, $message_type, $GRP_ID, $is_global);
920
+	}
921
+
922
+
923
+	/**
924
+	 * @deprecated 4.9.0
925
+	 * @param  string $messenger_name    name of EE_messenger
926
+	 * @param  string $message_type_name name of EE_message_type
927
+	 * @return array
928
+	 */
929
+	public function get_fields($messenger_name, $message_type_name)
930
+	{
931
+		// EE_messages has been deprecated
932
+		$this->_class_is_deprecated(__FUNCTION__);
933
+		EE_Registry::instance()->load_helper('MSG_Template');
934
+		return EEH_MSG_Template::get_fields($messenger_name, $message_type_name);
935
+	}
936
+
937
+
938
+	/**
939
+	 * @deprecated 4.9.0
940
+	 * @access     public
941
+	 * @param string $type                we can indicate just returning installed message types
942
+	 *                                    or messengers (or both) via this parameter.
943
+	 * @param bool   $skip_cache          if true then we skip the cache and retrieve via files.
944
+	 * @return array                    multidimensional array of messenger and message_type objects
945
+	 *                                    (messengers index, and message_type index);
946
+	 */
947
+	public function get_installed($type = 'all', $skip_cache = false)
948
+	{
949
+		// EE_messages has been deprecated
950
+		$this->_class_is_deprecated(__FUNCTION__);
951
+		if ($skip_cache) {
952
+			$this->_message_resource_manager->reset_active_messengers_and_message_types();
953
+		}
954
+		switch ($type) {
955
+			case 'messengers' :
956
+				return array(
957
+					'messenger' => $this->_message_resource_manager->installed_messengers(),
958
+				);
959
+				break;
960
+			case 'message_types' :
961
+				return array(
962
+					'message_type' => $this->_message_resource_manager->installed_message_types(),
963
+				);
964
+				break;
965
+			case 'all' :
966
+			default :
967
+				return array(
968
+					'messenger'    => $this->_message_resource_manager->installed_messengers(),
969
+					'message_type' => $this->_message_resource_manager->installed_message_types(),
970
+				);
971
+				break;
972
+		}
973
+	}
974
+
975
+
976
+	/**
977
+	 * @deprecated 4.9.0
978
+	 * @return \EE_messenger[]
979
+	 */
980
+	public function get_active_messengers()
981
+	{
982
+		// EE_messages has been deprecated
983
+		$this->_class_is_deprecated(__FUNCTION__);
984
+		return $this->_message_resource_manager->active_messengers();
985
+	}
986
+
987
+
988
+	/**
989
+	 * @deprecated 4.9.0
990
+	 * @return array array of message_type references (string)
991
+	 */
992
+	public function get_active_message_types()
993
+	{
994
+		// EE_messages has been deprecated
995
+		$this->_class_is_deprecated(__FUNCTION__);
996
+		return $this->_message_resource_manager->list_of_active_message_types();
997
+	}
998
+
999
+
1000
+	/**
1001
+	 * @deprecated 4.9.0
1002
+	 * @return EE_message_type[]
1003
+	 */
1004
+	public function get_active_message_type_objects()
1005
+	{
1006
+		// EE_messages has been deprecated
1007
+		$this->_class_is_deprecated(__FUNCTION__);
1008
+		return $this->_message_resource_manager->get_active_message_type_objects();
1009
+	}
1010
+
1011
+
1012
+	/**
1013
+	 * @deprecated 4.9.0
1014
+	 * @since      4.5.0
1015
+	 * @param string $messenger The messenger being checked
1016
+	 * @return EE_message_type[]    (or empty array if none present)
1017
+	 */
1018
+	public function get_active_message_types_per_messenger($messenger)
1019
+	{
1020
+		// EE_messages has been deprecated
1021
+		$this->_class_is_deprecated(__FUNCTION__);
1022
+		return $this->_message_resource_manager->get_active_message_types_for_messenger($messenger);
1023
+	}
1024
+
1025
+
1026
+	/**
1027
+	 * @deprecated 4.9.0
1028
+	 * @param string $messenger    The string should correspond to the messenger (message types are
1029
+	 * @param string $message_type The string should correspond to a message type.
1030
+	 * @return EE_message_type|null
1031
+	 */
1032
+	public function get_active_message_type($messenger, $message_type)
1033
+	{
1034
+		// EE_messages has been deprecated
1035
+		$this->_class_is_deprecated(__FUNCTION__);
1036
+		return $this->_message_resource_manager->get_active_message_type_for_messenger($messenger, $message_type);
1037
+	}
1038
+
1039
+
1040
+	/**
1041
+	 * @deprecated 4.9.0
1042
+	 * @return array|\EE_message_type[]
1043
+	 */
1044
+	public function get_installed_message_types()
1045
+	{
1046
+		// EE_messages has been deprecated
1047
+		$this->_class_is_deprecated(__FUNCTION__);
1048
+		return $this->_message_resource_manager->installed_message_types();
1049
+	}
1050
+
1051
+
1052
+	/**
1053
+	 * @deprecated 4.9.0
1054
+	 * @return array
1055
+	 */
1056
+	public function get_installed_messengers()
1057
+	{
1058
+		// EE_messages has been deprecated
1059
+		$this->_class_is_deprecated(__FUNCTION__);
1060
+		return $this->_message_resource_manager->installed_messengers();
1061
+	}
1062
+
1063
+
1064
+	/**
1065
+	 * @deprecated 4.9.0
1066
+	 * @param   bool $slugs_only Whether to return an array of just slugs and labels (true) or all contexts indexed by
1067
+	 *                           message type.
1068
+	 * @return array
1069
+	 */
1070
+	public function get_all_contexts($slugs_only = true)
1071
+	{
1072
+		// EE_messages has been deprecated
1073
+		$this->_class_is_deprecated(__FUNCTION__);
1074
+		return $this->_message_resource_manager->get_all_contexts($slugs_only);
1075
+	}
1076 1076
 
1077 1077
 
1078 1078
 }
@@ -1131,88 +1131,88 @@  discard block
 block discarded – undo
1131 1131
 
1132 1132
 
1133 1133
 add_filter(
1134
-    'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
1135
-    function ($event_list_iframe_css) {
1136
-        if (! has_filter('FHEE__EventsArchiveIframe__event_list_iframe__css')) {
1137
-            return $event_list_iframe_css;
1138
-        }
1139
-        deprecated_espresso_action_or_filter_doing_it_wrong(
1140
-            'FHEE__EventsArchiveIframe__event_list_iframe__css',
1141
-            'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
1142
-            '\EventEspresso\modules\events_archive\EventsArchiveIframe::display()',
1143
-            '4.9.14',
1144
-            '5.0.0',
1145
-            'filter'
1146
-        );
1147
-        return apply_filters(
1148
-            'FHEE__EventsArchiveIframe__event_list_iframe__css',
1149
-            $event_list_iframe_css
1150
-        );
1151
-    }
1134
+	'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
1135
+	function ($event_list_iframe_css) {
1136
+		if (! has_filter('FHEE__EventsArchiveIframe__event_list_iframe__css')) {
1137
+			return $event_list_iframe_css;
1138
+		}
1139
+		deprecated_espresso_action_or_filter_doing_it_wrong(
1140
+			'FHEE__EventsArchiveIframe__event_list_iframe__css',
1141
+			'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
1142
+			'\EventEspresso\modules\events_archive\EventsArchiveIframe::display()',
1143
+			'4.9.14',
1144
+			'5.0.0',
1145
+			'filter'
1146
+		);
1147
+		return apply_filters(
1148
+			'FHEE__EventsArchiveIframe__event_list_iframe__css',
1149
+			$event_list_iframe_css
1150
+		);
1151
+	}
1152 1152
 );
1153 1153
 add_filter(
1154
-    'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
1155
-    function ($event_list_iframe_js) {
1156
-        if (! has_filter('FHEE__EED_Ticket_Selector__ticket_selector_iframe__js')) {
1157
-            return $event_list_iframe_js;
1158
-        }
1159
-        deprecated_espresso_action_or_filter_doing_it_wrong(
1160
-            'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
1161
-            'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
1162
-            '\EventEspresso\modules\events_archive\EventsArchiveIframe::display()',
1163
-            '4.9.14',
1164
-            '5.0.0',
1165
-            'filter'
1166
-        );
1167
-        return apply_filters(
1168
-            'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
1169
-            $event_list_iframe_js
1170
-        );
1171
-    }
1154
+	'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
1155
+	function ($event_list_iframe_js) {
1156
+		if (! has_filter('FHEE__EED_Ticket_Selector__ticket_selector_iframe__js')) {
1157
+			return $event_list_iframe_js;
1158
+		}
1159
+		deprecated_espresso_action_or_filter_doing_it_wrong(
1160
+			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
1161
+			'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
1162
+			'\EventEspresso\modules\events_archive\EventsArchiveIframe::display()',
1163
+			'4.9.14',
1164
+			'5.0.0',
1165
+			'filter'
1166
+		);
1167
+		return apply_filters(
1168
+			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
1169
+			$event_list_iframe_js
1170
+		);
1171
+	}
1172 1172
 );
1173 1173
 add_action(
1174
-    'AHEE__EE_Capabilities__addCaps__complete',
1175
-    function ($capabilities_map) {
1176
-        if (! has_action('AHEE__EE_Capabilities__init_role_caps__complete')) {
1177
-            return;
1178
-        }
1179
-        deprecated_espresso_action_or_filter_doing_it_wrong(
1180
-            'AHEE__EE_Capabilities__init_role_caps__complete',
1181
-            'AHEE__EE_Capabilities__addCaps__complete',
1182
-            '\EE_Capabilities::addCaps()',
1183
-            '4.9.42',
1184
-            '5.0.0'
1185
-        );
1186
-        do_action(
1187
-            'AHEE__EE_Capabilities__init_role_caps__complete',
1188
-            $capabilities_map
1189
-        );
1190
-    }
1174
+	'AHEE__EE_Capabilities__addCaps__complete',
1175
+	function ($capabilities_map) {
1176
+		if (! has_action('AHEE__EE_Capabilities__init_role_caps__complete')) {
1177
+			return;
1178
+		}
1179
+		deprecated_espresso_action_or_filter_doing_it_wrong(
1180
+			'AHEE__EE_Capabilities__init_role_caps__complete',
1181
+			'AHEE__EE_Capabilities__addCaps__complete',
1182
+			'\EE_Capabilities::addCaps()',
1183
+			'4.9.42',
1184
+			'5.0.0'
1185
+		);
1186
+		do_action(
1187
+			'AHEE__EE_Capabilities__init_role_caps__complete',
1188
+			$capabilities_map
1189
+		);
1190
+	}
1191 1191
 );
1192 1192
 
1193 1193
 add_filter(
1194
-    'FHEE_EventEspresso_core_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee',
1195
-    function ($existing_attendee, $registration, $attendee_data) {
1196
-        if (! has_filter('FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee')) {
1197
-            return $existing_attendee;
1198
-        }
1199
-        deprecated_espresso_action_or_filter_doing_it_wrong(
1200
-            'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee',
1201
-            'FHEE_EventEspresso_core_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee',
1202
-            '\EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler::findExistingAttendee()',
1203
-            '4.9.34',
1204
-            '5.0.0',
1205
-            'filter'
1206
-        );
1207
-        return apply_filters(
1208
-            'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee',
1209
-            $existing_attendee,
1210
-            $registration,
1211
-            $attendee_data
1212
-        );
1213
-    },
1214
-    10,
1215
-    3
1194
+	'FHEE_EventEspresso_core_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee',
1195
+	function ($existing_attendee, $registration, $attendee_data) {
1196
+		if (! has_filter('FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee')) {
1197
+			return $existing_attendee;
1198
+		}
1199
+		deprecated_espresso_action_or_filter_doing_it_wrong(
1200
+			'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee',
1201
+			'FHEE_EventEspresso_core_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee',
1202
+			'\EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler::findExistingAttendee()',
1203
+			'4.9.34',
1204
+			'5.0.0',
1205
+			'filter'
1206
+		);
1207
+		return apply_filters(
1208
+			'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee',
1209
+			$existing_attendee,
1210
+			$registration,
1211
+			$attendee_data
1212
+		);
1213
+	},
1214
+	10,
1215
+	3
1216 1216
 );
1217 1217
 
1218 1218
 /**
@@ -1223,88 +1223,88 @@  discard block
 block discarded – undo
1223 1223
 class EE_Event_List_Query extends WP_Query
1224 1224
 {
1225 1225
 
1226
-    private $title;
1227
-
1228
-    private $css_class;
1229
-
1230
-    private $category_slug;
1231
-
1232
-    /**
1233
-     * EE_Event_List_Query constructor.
1234
-     *
1235
-     * @param array $args
1236
-     */
1237
-    public function __construct($args = array())
1238
-    {
1239
-        \EE_Error::doing_it_wrong(
1240
-            __METHOD__,
1241
-            __(
1242
-                'Usage is deprecated. Please use \EventEspresso\core\domain\services\wp_queries\EventListQuery instead.',
1243
-                'event_espresso'
1244
-            ),
1245
-            '4.9.27',
1246
-            '5.0.0'
1247
-        );
1248
-        $this->title = isset($args['title']) ? $args['title'] : '';
1249
-        $this->css_class = isset($args['css_class']) ? $args['css_class'] : '';
1250
-        $this->category_slug = isset($args['category_slug']) ? $args['category_slug'] : '';
1251
-        $limit = isset($args['limit']) && absint($args['limit']) ? $args['limit'] : 10;
1252
-        // the current "page" we are viewing
1253
-        $paged = max(1, get_query_var('paged'));
1254
-        // Force these args
1255
-        $args = array_merge(
1256
-            $args,
1257
-            array(
1258
-                'post_type'              => 'espresso_events',
1259
-                'posts_per_page'         => $limit,
1260
-                'update_post_term_cache' => false,
1261
-                'update_post_meta_cache' => false,
1262
-                'paged'                  => $paged,
1263
-                'offset'                 => ($paged - 1) * $limit,
1264
-            )
1265
-        );
1266
-        // run the query
1267
-        parent::__construct($args);
1268
-    }
1269
-
1270
-
1271
-    /**
1272
-     * event_list_title
1273
-     *
1274
-     * @param string $event_list_title
1275
-     * @return string
1276
-     */
1277
-    public function event_list_title($event_list_title = '')
1278
-    {
1279
-        if (! empty($this->title)) {
1280
-            return $this->title;
1281
-        }
1282
-        return $event_list_title;
1283
-    }
1284
-
1285
-
1286
-    /**
1287
-     * event_list_css
1288
-     *
1289
-     * @param string $event_list_css
1290
-     * @return string
1291
-     */
1292
-    public function event_list_css($event_list_css = '')
1293
-    {
1294
-        $event_list_css .= ! empty($event_list_css)
1295
-            ? ' '
1296
-            : '';
1297
-        $event_list_css .= ! empty($this->css_class)
1298
-            ? $this->css_class
1299
-            : '';
1300
-        $event_list_css .= ! empty($event_list_css)
1301
-            ? ' '
1302
-            : '';
1303
-        $event_list_css .= ! empty($this->category_slug)
1304
-            ? $this->category_slug
1305
-            : '';
1306
-        return $event_list_css;
1307
-    }
1226
+	private $title;
1227
+
1228
+	private $css_class;
1229
+
1230
+	private $category_slug;
1231
+
1232
+	/**
1233
+	 * EE_Event_List_Query constructor.
1234
+	 *
1235
+	 * @param array $args
1236
+	 */
1237
+	public function __construct($args = array())
1238
+	{
1239
+		\EE_Error::doing_it_wrong(
1240
+			__METHOD__,
1241
+			__(
1242
+				'Usage is deprecated. Please use \EventEspresso\core\domain\services\wp_queries\EventListQuery instead.',
1243
+				'event_espresso'
1244
+			),
1245
+			'4.9.27',
1246
+			'5.0.0'
1247
+		);
1248
+		$this->title = isset($args['title']) ? $args['title'] : '';
1249
+		$this->css_class = isset($args['css_class']) ? $args['css_class'] : '';
1250
+		$this->category_slug = isset($args['category_slug']) ? $args['category_slug'] : '';
1251
+		$limit = isset($args['limit']) && absint($args['limit']) ? $args['limit'] : 10;
1252
+		// the current "page" we are viewing
1253
+		$paged = max(1, get_query_var('paged'));
1254
+		// Force these args
1255
+		$args = array_merge(
1256
+			$args,
1257
+			array(
1258
+				'post_type'              => 'espresso_events',
1259
+				'posts_per_page'         => $limit,
1260
+				'update_post_term_cache' => false,
1261
+				'update_post_meta_cache' => false,
1262
+				'paged'                  => $paged,
1263
+				'offset'                 => ($paged - 1) * $limit,
1264
+			)
1265
+		);
1266
+		// run the query
1267
+		parent::__construct($args);
1268
+	}
1269
+
1270
+
1271
+	/**
1272
+	 * event_list_title
1273
+	 *
1274
+	 * @param string $event_list_title
1275
+	 * @return string
1276
+	 */
1277
+	public function event_list_title($event_list_title = '')
1278
+	{
1279
+		if (! empty($this->title)) {
1280
+			return $this->title;
1281
+		}
1282
+		return $event_list_title;
1283
+	}
1284
+
1285
+
1286
+	/**
1287
+	 * event_list_css
1288
+	 *
1289
+	 * @param string $event_list_css
1290
+	 * @return string
1291
+	 */
1292
+	public function event_list_css($event_list_css = '')
1293
+	{
1294
+		$event_list_css .= ! empty($event_list_css)
1295
+			? ' '
1296
+			: '';
1297
+		$event_list_css .= ! empty($this->css_class)
1298
+			? $this->css_class
1299
+			: '';
1300
+		$event_list_css .= ! empty($event_list_css)
1301
+			? ' '
1302
+			: '';
1303
+		$event_list_css .= ! empty($this->category_slug)
1304
+			? $this->category_slug
1305
+			: '';
1306
+		return $event_list_css;
1307
+	}
1308 1308
 
1309 1309
 }
1310 1310
 
@@ -1321,75 +1321,75 @@  discard block
 block discarded – undo
1321 1321
 {
1322 1322
 
1323 1323
 
1324
-    /**
1325
-     *    class constructor
1326
-     *
1327
-     * @deprecated 4.9.59.p
1328
-     */
1329
-    public function __construct()
1330
-    {
1331
-        EE_Error::doing_it_wrong(
1332
-            __METHOD__,
1333
-            sprintf(
1334
-                esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'),
1335
-                __CLASS__,
1336
-                'EventEspresso\core\services\licensing\LicenseServices'
1337
-            ),
1338
-            '4.9.59.p'
1339
-        );
1340
-    }
1341
-
1342
-
1343
-    /**
1344
-     * The purpose of this function is to display information about Event Espresso data collection
1345
-     * and a optin selection for extra data collecting by users.
1346
-     *
1347
-     * @param bool $extra
1348
-     * @return string html.
1349
-     * @deprecated 4.9.59.p
1350
-     */
1351
-    public static function espresso_data_collection_optin_text($extra = true)
1352
-    {
1353
-        EE_Error::doing_it_wrong(
1354
-            __METHOD__,
1355
-            sprintf(
1356
-                esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'),
1357
-                __METHOD__,
1358
-                'EventEspresso\core\domain\services\Stats::optinText'
1359
-            ),
1360
-            '4.9.59.p'
1361
-        );
1362
-        Stats::optinText($extra);
1363
-    }
1364
-
1365
-    /**
1366
-     * This is a handy helper method for retrieving whether there is an update available for the given plugin.
1367
-     *
1368
-     * @param  string $basename Use the equivalent result from plugin_basename() for this param as WP uses that to
1369
-     *                          identify plugins. Defaults to core update
1370
-     * @return boolean           True if update available, false if not.
1371
-     * @deprecated 4.9.59.p
1372
-     */
1373
-    public static function is_update_available($basename = '')
1374
-    {
1375
-        EE_Error::doing_it_wrong(
1376
-            __METHOD__,
1377
-            sprintf(
1378
-                esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'),
1379
-                __METHOD__,
1380
-                'EventEspresso\core\services\licensing\LicenseService::isUpdateAvailable'
1381
-            ),
1382
-            '4.9.59.p'
1383
-        );
1384
-        return LicenseService::isUpdateAvailable($basename);
1385
-    }
1324
+	/**
1325
+	 *    class constructor
1326
+	 *
1327
+	 * @deprecated 4.9.59.p
1328
+	 */
1329
+	public function __construct()
1330
+	{
1331
+		EE_Error::doing_it_wrong(
1332
+			__METHOD__,
1333
+			sprintf(
1334
+				esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'),
1335
+				__CLASS__,
1336
+				'EventEspresso\core\services\licensing\LicenseServices'
1337
+			),
1338
+			'4.9.59.p'
1339
+		);
1340
+	}
1341
+
1342
+
1343
+	/**
1344
+	 * The purpose of this function is to display information about Event Espresso data collection
1345
+	 * and a optin selection for extra data collecting by users.
1346
+	 *
1347
+	 * @param bool $extra
1348
+	 * @return string html.
1349
+	 * @deprecated 4.9.59.p
1350
+	 */
1351
+	public static function espresso_data_collection_optin_text($extra = true)
1352
+	{
1353
+		EE_Error::doing_it_wrong(
1354
+			__METHOD__,
1355
+			sprintf(
1356
+				esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'),
1357
+				__METHOD__,
1358
+				'EventEspresso\core\domain\services\Stats::optinText'
1359
+			),
1360
+			'4.9.59.p'
1361
+		);
1362
+		Stats::optinText($extra);
1363
+	}
1364
+
1365
+	/**
1366
+	 * This is a handy helper method for retrieving whether there is an update available for the given plugin.
1367
+	 *
1368
+	 * @param  string $basename Use the equivalent result from plugin_basename() for this param as WP uses that to
1369
+	 *                          identify plugins. Defaults to core update
1370
+	 * @return boolean           True if update available, false if not.
1371
+	 * @deprecated 4.9.59.p
1372
+	 */
1373
+	public static function is_update_available($basename = '')
1374
+	{
1375
+		EE_Error::doing_it_wrong(
1376
+			__METHOD__,
1377
+			sprintf(
1378
+				esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'),
1379
+				__METHOD__,
1380
+				'EventEspresso\core\services\licensing\LicenseService::isUpdateAvailable'
1381
+			),
1382
+			'4.9.59.p'
1383
+		);
1384
+		return LicenseService::isUpdateAvailable($basename);
1385
+	}
1386 1386
 }
1387 1387
 
1388 1388
 add_filter(
1389
-    'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array',
1390
-    'ee_deprecated_registrations_report_csv_legacy_fields',
1391
-    10,
1392
-    2
1389
+	'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array',
1390
+	'ee_deprecated_registrations_report_csv_legacy_fields',
1391
+	10,
1392
+	2
1393 1393
 );
1394 1394
 /**
1395 1395
  * Filters the CSV row to make it appear like the old labels (which were "$pretty_name[$field_name]").
@@ -1406,96 +1406,96 @@  discard block
 block discarded – undo
1406 1406
  */
1407 1407
 function ee_deprecated_registrations_report_csv_legacy_fields($csv_row_data, $reg_row)
1408 1408
 {
1409
-    // no need for all this if nobody is using the deprecated filter
1410
-    if (has_filter('FHEE__EE_Export__report_registrations__reg_csv_array')) {
1411
-        EE_Error::doing_it_wrong(
1412
-            __FUNCTION__,
1413
-            sprintf(
1414
-                // EE_Error::doing_it_wrong with escape HTML, so don't escape it twice by doing it here too.
1415
-                _x(
1416
-                    'The filter "%1$s" has been deprecated. Please use "%2$s" instead.',
1417
-                    'The filter "FHEE__EE_Export__report_registrations__reg_csv_array" has been deprecated. Please use "FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array" instead.',
1418
-                    'event_espresso'
1419
-                ),
1420
-                'FHEE__EE_Export__report_registrations__reg_csv_array',
1421
-                'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array'
1422
-            ),
1423
-            '4.9.69.p',
1424
-            '4.9.75.p'
1425
-        );
1426
-        // there's code that expected the old csv column headers/labels. Let's oblige. Put it back in the old format!
1427
-        // first: what model fields might be used as column headers? (whose format we need to change)
1428
-        $model_fields = array_merge(
1429
-            EEM_Registration::instance()->field_settings(),
1430
-            EEM_Attendee::instance()->field_settings()
1431
-        );
1432
-        // create an array that uses the legacy column headers/labels.
1433
-        $new_csv_row = array();
1434
-        foreach ($csv_row_data as $label => $value) {
1435
-            $new_label = $label;
1436
-            foreach ($model_fields as $field) {
1437
-                if ($label === EEH_Export::get_column_name_for_field($field)) {
1438
-                    // re-add the old field name
1439
-                    $new_label = $label . '[' . $field->get_name() . ']';
1440
-                    break;
1441
-                }
1442
-            }
1443
-            $new_csv_row[$new_label] = $value;
1444
-        }
1445
-        // before we run it through the deprecated filter, set the method `EEH_Export::get_column_name_for_field()`
1446
-        // to create the old column names, because that's what's in the row temporarily
1447
-        add_filter(
1448
-            'FHEE__EEH_Export__get_column_name_for_field__add_field_name',
1449
-            '__return_true',
1450
-            777
1451
-        );
1452
-        // now, those old filters can be run on this data. Have fun!
1453
-        /**
1454
-         * Deprecated. Use FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array instead.
1455
-         *
1456
-         * Filter to change the contents of each row of the registrations report CSV file.
1457
-         * This can be used to add or remote columns from the CSV file, or change their values.                 *
1458
-         * Note: it has this name because originally that's where this filter resided,
1459
-         * and we've left its name as-is for backward compatibility.
1460
-         * Note when using: all rows in the CSV should have the same columns.
1461
-         *
1462
-         * @param array $reg_csv_array keys are column-header names, and values are that columns' value
1463
-         *                             in this row
1464
-         * @param array $reg_row is the row from the database's wp_esp_registration table
1465
-         */
1466
-        $updated_row = apply_filters(
1467
-            'FHEE__EE_Export__report_registrations__reg_csv_array',
1468
-            $new_csv_row,
1469
-            $reg_row
1470
-        );
1471
-
1472
-        // ok now we can revert to normal for EEH_Export::get_column_name_for_field().
1473
-        remove_filter(
1474
-            'FHEE__EEH_Export__get_column_name_for_field__add_field_name',
1475
-            '__return_true',
1476
-            777
1477
-        );
1478
-
1479
-        // great. Now that the old filters are done, we can remove the ugly square brackets from column headers/labels.
1480
-        $updated_and_restored_row = array();
1481
-        foreach ($updated_row as $label => $value) {
1482
-            $matches = array();
1483
-            if (preg_match(
1484
-                    '~([^\[]*)\[(.*)\]~',
1485
-                    $label,
1486
-                    $matches
1487
-                )
1488
-                && isset(
1489
-                    $matches[0],
1490
-                    $matches[1],
1491
-                    $matches[2]
1492
-                )
1493
-            ) {
1494
-                $label = $matches[1];
1495
-            }
1496
-            $updated_and_restored_row[$label] = $value;
1497
-        }
1498
-        $csv_row_data = $updated_and_restored_row;
1499
-    }
1500
-    return $csv_row_data;
1409
+	// no need for all this if nobody is using the deprecated filter
1410
+	if (has_filter('FHEE__EE_Export__report_registrations__reg_csv_array')) {
1411
+		EE_Error::doing_it_wrong(
1412
+			__FUNCTION__,
1413
+			sprintf(
1414
+				// EE_Error::doing_it_wrong with escape HTML, so don't escape it twice by doing it here too.
1415
+				_x(
1416
+					'The filter "%1$s" has been deprecated. Please use "%2$s" instead.',
1417
+					'The filter "FHEE__EE_Export__report_registrations__reg_csv_array" has been deprecated. Please use "FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array" instead.',
1418
+					'event_espresso'
1419
+				),
1420
+				'FHEE__EE_Export__report_registrations__reg_csv_array',
1421
+				'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array'
1422
+			),
1423
+			'4.9.69.p',
1424
+			'4.9.75.p'
1425
+		);
1426
+		// there's code that expected the old csv column headers/labels. Let's oblige. Put it back in the old format!
1427
+		// first: what model fields might be used as column headers? (whose format we need to change)
1428
+		$model_fields = array_merge(
1429
+			EEM_Registration::instance()->field_settings(),
1430
+			EEM_Attendee::instance()->field_settings()
1431
+		);
1432
+		// create an array that uses the legacy column headers/labels.
1433
+		$new_csv_row = array();
1434
+		foreach ($csv_row_data as $label => $value) {
1435
+			$new_label = $label;
1436
+			foreach ($model_fields as $field) {
1437
+				if ($label === EEH_Export::get_column_name_for_field($field)) {
1438
+					// re-add the old field name
1439
+					$new_label = $label . '[' . $field->get_name() . ']';
1440
+					break;
1441
+				}
1442
+			}
1443
+			$new_csv_row[$new_label] = $value;
1444
+		}
1445
+		// before we run it through the deprecated filter, set the method `EEH_Export::get_column_name_for_field()`
1446
+		// to create the old column names, because that's what's in the row temporarily
1447
+		add_filter(
1448
+			'FHEE__EEH_Export__get_column_name_for_field__add_field_name',
1449
+			'__return_true',
1450
+			777
1451
+		);
1452
+		// now, those old filters can be run on this data. Have fun!
1453
+		/**
1454
+		 * Deprecated. Use FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array instead.
1455
+		 *
1456
+		 * Filter to change the contents of each row of the registrations report CSV file.
1457
+		 * This can be used to add or remote columns from the CSV file, or change their values.                 *
1458
+		 * Note: it has this name because originally that's where this filter resided,
1459
+		 * and we've left its name as-is for backward compatibility.
1460
+		 * Note when using: all rows in the CSV should have the same columns.
1461
+		 *
1462
+		 * @param array $reg_csv_array keys are column-header names, and values are that columns' value
1463
+		 *                             in this row
1464
+		 * @param array $reg_row is the row from the database's wp_esp_registration table
1465
+		 */
1466
+		$updated_row = apply_filters(
1467
+			'FHEE__EE_Export__report_registrations__reg_csv_array',
1468
+			$new_csv_row,
1469
+			$reg_row
1470
+		);
1471
+
1472
+		// ok now we can revert to normal for EEH_Export::get_column_name_for_field().
1473
+		remove_filter(
1474
+			'FHEE__EEH_Export__get_column_name_for_field__add_field_name',
1475
+			'__return_true',
1476
+			777
1477
+		);
1478
+
1479
+		// great. Now that the old filters are done, we can remove the ugly square brackets from column headers/labels.
1480
+		$updated_and_restored_row = array();
1481
+		foreach ($updated_row as $label => $value) {
1482
+			$matches = array();
1483
+			if (preg_match(
1484
+					'~([^\[]*)\[(.*)\]~',
1485
+					$label,
1486
+					$matches
1487
+				)
1488
+				&& isset(
1489
+					$matches[0],
1490
+					$matches[1],
1491
+					$matches[2]
1492
+				)
1493
+			) {
1494
+				$label = $matches[1];
1495
+			}
1496
+			$updated_and_restored_row[$label] = $value;
1497
+		}
1498
+		$csv_row_data = $updated_and_restored_row;
1499
+	}
1500
+	return $csv_row_data;
1501 1501
 }
1502 1502
\ No newline at end of file
Please login to merge, or discard this patch.
display/EE_Checkbox_Dropdown_Selector_Display_Strategy.strategy.php 2 patches
Indentation   +163 added lines, -163 removed lines patch added patch discarded remove patch
@@ -12,180 +12,180 @@
 block discarded – undo
12 12
 {
13 13
 
14 14
 
15
-    /**
16
-     * enqueues css and js, so that this can be called statically
17
-     */
18
-    public static function enqueue_styles_and_scripts()
19
-    {
20
-        wp_register_style(
21
-            'checkbox_dropdown_selector',
22
-            EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css',
23
-            array('espresso_default'),
24
-            EVENT_ESPRESSO_VERSION
25
-        );
26
-        wp_register_style(
27
-            'espresso_default',
28
-            EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css',
29
-            array('dashicons'),
30
-            EVENT_ESPRESSO_VERSION
31
-        );
32
-        wp_enqueue_style('checkbox_dropdown_selector');
33
-        wp_register_script(
34
-            'checkbox_dropdown_selector',
35
-            EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js',
36
-            array('jquery'),
37
-            EVENT_ESPRESSO_VERSION,
38
-            true
39
-        );
40
-        wp_localize_script(
41
-            'ticket_selector',
42
-            'eeDTS',
43
-            array(
44
-                'maxChecked' => EE_Registry::instance()
45
-                    ->CFG
46
-                    ->template_settings
47
-                    ->EED_Ticket_Selector
48
-                    ->getDatetimeSelectorMaxChecked()
49
-            )
50
-        );
51
-        wp_enqueue_script('checkbox_dropdown_selector');
52
-    }
15
+	/**
16
+	 * enqueues css and js, so that this can be called statically
17
+	 */
18
+	public static function enqueue_styles_and_scripts()
19
+	{
20
+		wp_register_style(
21
+			'checkbox_dropdown_selector',
22
+			EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css',
23
+			array('espresso_default'),
24
+			EVENT_ESPRESSO_VERSION
25
+		);
26
+		wp_register_style(
27
+			'espresso_default',
28
+			EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css',
29
+			array('dashicons'),
30
+			EVENT_ESPRESSO_VERSION
31
+		);
32
+		wp_enqueue_style('checkbox_dropdown_selector');
33
+		wp_register_script(
34
+			'checkbox_dropdown_selector',
35
+			EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js',
36
+			array('jquery'),
37
+			EVENT_ESPRESSO_VERSION,
38
+			true
39
+		);
40
+		wp_localize_script(
41
+			'ticket_selector',
42
+			'eeDTS',
43
+			array(
44
+				'maxChecked' => EE_Registry::instance()
45
+					->CFG
46
+					->template_settings
47
+					->EED_Ticket_Selector
48
+					->getDatetimeSelectorMaxChecked()
49
+			)
50
+		);
51
+		wp_enqueue_script('checkbox_dropdown_selector');
52
+	}
53 53
 
54 54
 
55 55
 
56
-    /**
57
-     * Informs the rest of the forms system what CSS and JS is needed to display the input
58
-     */
59
-    public function enqueue_js()
60
-    {
61
-        EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts();
62
-    }
56
+	/**
57
+	 * Informs the rest of the forms system what CSS and JS is needed to display the input
58
+	 */
59
+	public function enqueue_js()
60
+	{
61
+		EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts();
62
+	}
63 63
 
64 64
 
65 65
 
66
-    /**
67
-     * callback for Iframe::addStylesheets() child class methods
68
-     *
69
-     * @param array $iframe_css
70
-     * @return array
71
-     */
72
-    public function iframe_css(array $iframe_css)
73
-    {
74
-        $iframe_css['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css';
75
-        return $iframe_css;
76
-    }
66
+	/**
67
+	 * callback for Iframe::addStylesheets() child class methods
68
+	 *
69
+	 * @param array $iframe_css
70
+	 * @return array
71
+	 */
72
+	public function iframe_css(array $iframe_css)
73
+	{
74
+		$iframe_css['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css';
75
+		return $iframe_css;
76
+	}
77 77
 
78 78
 
79 79
 
80
-    /**
81
-     * callback for Iframe::addScripts() child class methods
82
-     *
83
-     * @param array $iframe_js
84
-     * @return array
85
-     */
86
-    public function iframe_js(array $iframe_js)
87
-    {
88
-        $iframe_js['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js';
89
-        return $iframe_js;
90
-    }
80
+	/**
81
+	 * callback for Iframe::addScripts() child class methods
82
+	 *
83
+	 * @param array $iframe_js
84
+	 * @return array
85
+	 */
86
+	public function iframe_js(array $iframe_js)
87
+	{
88
+		$iframe_js['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js';
89
+		return $iframe_js;
90
+	}
91 91
 
92 92
 
93
-    /**
94
-     * @throws EE_Error
95
-     * @return string of html to display the field
96
-     */
97
-    public function display()
98
-    {
99
-        $input = $this->get_input();
100
-        $select_button_text = $input instanceof EE_Checkbox_Dropdown_Selector_Input ? $input->select_button_text() : '';
101
-        // $multi = count( $input->options() ) > 1 ? TRUE : FALSE;
102
-        $input->set_label_sizes();
103
-        $label_size_class = $input->get_label_size_class();
104
-        if (! is_array($input->raw_value()) && $input->raw_value() !== null) {
105
-            EE_Error::doing_it_wrong(
106
-                'EE_Checkbox_Display_Strategy::display()',
107
-                sprintf(
108
-                    esc_html__(
109
-                        'Input values for checkboxes should be an array of values, but the value for input "%1$s" is "%2$s". Please verify that the input name is exactly "%3$s"',
110
-                        'event_espresso'
111
-                    ),
112
-                    $input->html_id(),
113
-                    var_export($input->raw_value(), true),
114
-                    $input->html_name() . '[]'
115
-                ),
116
-                '4.8.1'
117
-            );
118
-        }
93
+	/**
94
+	 * @throws EE_Error
95
+	 * @return string of html to display the field
96
+	 */
97
+	public function display()
98
+	{
99
+		$input = $this->get_input();
100
+		$select_button_text = $input instanceof EE_Checkbox_Dropdown_Selector_Input ? $input->select_button_text() : '';
101
+		// $multi = count( $input->options() ) > 1 ? TRUE : FALSE;
102
+		$input->set_label_sizes();
103
+		$label_size_class = $input->get_label_size_class();
104
+		if (! is_array($input->raw_value()) && $input->raw_value() !== null) {
105
+			EE_Error::doing_it_wrong(
106
+				'EE_Checkbox_Display_Strategy::display()',
107
+				sprintf(
108
+					esc_html__(
109
+						'Input values for checkboxes should be an array of values, but the value for input "%1$s" is "%2$s". Please verify that the input name is exactly "%3$s"',
110
+						'event_espresso'
111
+					),
112
+					$input->html_id(),
113
+					var_export($input->raw_value(), true),
114
+					$input->html_name() . '[]'
115
+				),
116
+				'4.8.1'
117
+			);
118
+		}
119 119
 
120 120
 
121
-        $html = \EEH_HTML::div('', '', 'checkbox-dropdown-selector-wrap-dv');
122
-        $html .= '<button id="' . $input->html_id() . '-btn"';
123
-        // $html .= ' name="' . $input->html_name() . '"';
124
-        $html .= ' class="' . $input->html_class() . ' checkbox-dropdown-selector-btn button-secondary button"';
125
-        $html .= ' style="' . $input->html_style() . '"';
126
-        $html .= ' data-target="' . $input->html_id() . '-options-dv"';
127
-        $html .= ' ' . $input->html_other_attributes() . '>';
128
-        $html .= '<span class="checkbox-dropdown-selector-selected-spn">';
129
-        $html .= $select_button_text;
130
-        $html .= '</span> <span class="dashicons dashicons-arrow-down"></span>';
131
-        $html .= '</button>';
132
-        $html .= EEH_HTML::div(
133
-            '',
134
-            $input->html_id() . '-options-dv',
135
-            'checkbox-dropdown-selector'
136
-        );
137
-        $html .= EEH_HTML::link(
138
-            '',
139
-            '<span class="dashicons dashicons-no"></span>',
140
-            esc_html__('close datetime selector', 'event_espresso'),
141
-            '',
142
-            'close-espresso-notice'
143
-        );
144
-        $html .= EEH_HTML::ul();
145
-        $input_raw_value = (array) $input->raw_value();
146
-        foreach ($input->options() as $value => $display_text) {
147
-            $html .= EEH_HTML::li();
148
-            $value = $input->get_normalization_strategy()->unnormalize_one($value);
149
-            $html_id = $this->get_sub_input_id($value);
150
-            $html .= EEH_HTML::nl(0, 'checkbox');
151
-            $html .= '<label for="'
152
-                     . $html_id
153
-                     . '" id="'
154
-                     . $html_id
155
-                     . '-lbl" class="ee-checkbox-label-after'
156
-                     . $label_size_class
157
-                     . '">';
158
-            $html .= EEH_HTML::nl(1, 'checkbox');
159
-            $html .= '<input type="checkbox"';
160
-            $html .= ' name="' . $input->html_name() . '[]"';
161
-            $html .= ' id="' . $html_id . '"';
162
-            $html .= ' class="' . $input->html_class() . '-option"';
163
-            $html .= $input->html_style() ? ' style="' . $input->html_style() . '"' : '';
164
-            $html .= ' value="' . esc_attr($value) . '"';
165
-            $html .= ! empty($input_raw_value) && in_array($value, $input_raw_value, true)
166
-                ? ' checked="checked"'
167
-                : '';
168
-            $html .= ' ' . $this->_input->other_html_attributes();
169
-            $html .= '>';
170
-            $html .= '<span class="datetime-selector-option-text-spn">' . $display_text . '</span>';
171
-            $html .= EEH_HTML::nl(-1, 'checkbox') . '</label>';
172
-            $html .= EEH_HTML::lix();
173
-        }
174
-        $html .= EEH_HTML::ulx();
175
-        $html .= EEH_HTML::divx();
176
-        $html .= EEH_HTML::divx();
177
-        $html .= EEH_HTML::p(
178
-            apply_filters(
179
-                'FHEE__EE_Checkbox_Dropdown_Selector_Display_Strategy__display__html',
180
-                esc_html__(
181
-                    'To view additional ticket options, click the "Filter by Date" button and select more dates.',
182
-                    'event_espresso'
183
-                )
184
-            ),
185
-            $input->html_id() . '-date-time-filter-notice-pg',
186
-            'date-time-filter-notice-pg small-text lt-grey-text'
187
-        );
188
-        $html .= \EEH_HTML::br();
189
-        return $html;
190
-    }
121
+		$html = \EEH_HTML::div('', '', 'checkbox-dropdown-selector-wrap-dv');
122
+		$html .= '<button id="' . $input->html_id() . '-btn"';
123
+		// $html .= ' name="' . $input->html_name() . '"';
124
+		$html .= ' class="' . $input->html_class() . ' checkbox-dropdown-selector-btn button-secondary button"';
125
+		$html .= ' style="' . $input->html_style() . '"';
126
+		$html .= ' data-target="' . $input->html_id() . '-options-dv"';
127
+		$html .= ' ' . $input->html_other_attributes() . '>';
128
+		$html .= '<span class="checkbox-dropdown-selector-selected-spn">';
129
+		$html .= $select_button_text;
130
+		$html .= '</span> <span class="dashicons dashicons-arrow-down"></span>';
131
+		$html .= '</button>';
132
+		$html .= EEH_HTML::div(
133
+			'',
134
+			$input->html_id() . '-options-dv',
135
+			'checkbox-dropdown-selector'
136
+		);
137
+		$html .= EEH_HTML::link(
138
+			'',
139
+			'<span class="dashicons dashicons-no"></span>',
140
+			esc_html__('close datetime selector', 'event_espresso'),
141
+			'',
142
+			'close-espresso-notice'
143
+		);
144
+		$html .= EEH_HTML::ul();
145
+		$input_raw_value = (array) $input->raw_value();
146
+		foreach ($input->options() as $value => $display_text) {
147
+			$html .= EEH_HTML::li();
148
+			$value = $input->get_normalization_strategy()->unnormalize_one($value);
149
+			$html_id = $this->get_sub_input_id($value);
150
+			$html .= EEH_HTML::nl(0, 'checkbox');
151
+			$html .= '<label for="'
152
+					 . $html_id
153
+					 . '" id="'
154
+					 . $html_id
155
+					 . '-lbl" class="ee-checkbox-label-after'
156
+					 . $label_size_class
157
+					 . '">';
158
+			$html .= EEH_HTML::nl(1, 'checkbox');
159
+			$html .= '<input type="checkbox"';
160
+			$html .= ' name="' . $input->html_name() . '[]"';
161
+			$html .= ' id="' . $html_id . '"';
162
+			$html .= ' class="' . $input->html_class() . '-option"';
163
+			$html .= $input->html_style() ? ' style="' . $input->html_style() . '"' : '';
164
+			$html .= ' value="' . esc_attr($value) . '"';
165
+			$html .= ! empty($input_raw_value) && in_array($value, $input_raw_value, true)
166
+				? ' checked="checked"'
167
+				: '';
168
+			$html .= ' ' . $this->_input->other_html_attributes();
169
+			$html .= '>';
170
+			$html .= '<span class="datetime-selector-option-text-spn">' . $display_text . '</span>';
171
+			$html .= EEH_HTML::nl(-1, 'checkbox') . '</label>';
172
+			$html .= EEH_HTML::lix();
173
+		}
174
+		$html .= EEH_HTML::ulx();
175
+		$html .= EEH_HTML::divx();
176
+		$html .= EEH_HTML::divx();
177
+		$html .= EEH_HTML::p(
178
+			apply_filters(
179
+				'FHEE__EE_Checkbox_Dropdown_Selector_Display_Strategy__display__html',
180
+				esc_html__(
181
+					'To view additional ticket options, click the "Filter by Date" button and select more dates.',
182
+					'event_espresso'
183
+				)
184
+			),
185
+			$input->html_id() . '-date-time-filter-notice-pg',
186
+			'date-time-filter-notice-pg small-text lt-grey-text'
187
+		);
188
+		$html .= \EEH_HTML::br();
189
+		return $html;
190
+	}
191 191
 }
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -19,20 +19,20 @@  discard block
 block discarded – undo
19 19
     {
20 20
         wp_register_style(
21 21
             'checkbox_dropdown_selector',
22
-            EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css',
22
+            EE_GLOBAL_ASSETS_URL.'css/checkbox_dropdown_selector.css',
23 23
             array('espresso_default'),
24 24
             EVENT_ESPRESSO_VERSION
25 25
         );
26 26
         wp_register_style(
27 27
             'espresso_default',
28
-            EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css',
28
+            EE_GLOBAL_ASSETS_URL.'css/espresso_default.css',
29 29
             array('dashicons'),
30 30
             EVENT_ESPRESSO_VERSION
31 31
         );
32 32
         wp_enqueue_style('checkbox_dropdown_selector');
33 33
         wp_register_script(
34 34
             'checkbox_dropdown_selector',
35
-            EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js',
35
+            EE_GLOBAL_ASSETS_URL.'scripts/checkbox_dropdown_selector.js',
36 36
             array('jquery'),
37 37
             EVENT_ESPRESSO_VERSION,
38 38
             true
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
      */
72 72
     public function iframe_css(array $iframe_css)
73 73
     {
74
-        $iframe_css['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css';
74
+        $iframe_css['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL.'css/checkbox_dropdown_selector.css';
75 75
         return $iframe_css;
76 76
     }
77 77
 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
      */
86 86
     public function iframe_js(array $iframe_js)
87 87
     {
88
-        $iframe_js['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js';
88
+        $iframe_js['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL.'scripts/checkbox_dropdown_selector.js';
89 89
         return $iframe_js;
90 90
     }
91 91
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
         // $multi = count( $input->options() ) > 1 ? TRUE : FALSE;
102 102
         $input->set_label_sizes();
103 103
         $label_size_class = $input->get_label_size_class();
104
-        if (! is_array($input->raw_value()) && $input->raw_value() !== null) {
104
+        if ( ! is_array($input->raw_value()) && $input->raw_value() !== null) {
105 105
             EE_Error::doing_it_wrong(
106 106
                 'EE_Checkbox_Display_Strategy::display()',
107 107
                 sprintf(
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
                     ),
112 112
                     $input->html_id(),
113 113
                     var_export($input->raw_value(), true),
114
-                    $input->html_name() . '[]'
114
+                    $input->html_name().'[]'
115 115
                 ),
116 116
                 '4.8.1'
117 117
             );
@@ -119,19 +119,19 @@  discard block
 block discarded – undo
119 119
 
120 120
 
121 121
         $html = \EEH_HTML::div('', '', 'checkbox-dropdown-selector-wrap-dv');
122
-        $html .= '<button id="' . $input->html_id() . '-btn"';
122
+        $html .= '<button id="'.$input->html_id().'-btn"';
123 123
         // $html .= ' name="' . $input->html_name() . '"';
124
-        $html .= ' class="' . $input->html_class() . ' checkbox-dropdown-selector-btn button-secondary button"';
125
-        $html .= ' style="' . $input->html_style() . '"';
126
-        $html .= ' data-target="' . $input->html_id() . '-options-dv"';
127
-        $html .= ' ' . $input->html_other_attributes() . '>';
124
+        $html .= ' class="'.$input->html_class().' checkbox-dropdown-selector-btn button-secondary button"';
125
+        $html .= ' style="'.$input->html_style().'"';
126
+        $html .= ' data-target="'.$input->html_id().'-options-dv"';
127
+        $html .= ' '.$input->html_other_attributes().'>';
128 128
         $html .= '<span class="checkbox-dropdown-selector-selected-spn">';
129 129
         $html .= $select_button_text;
130 130
         $html .= '</span> <span class="dashicons dashicons-arrow-down"></span>';
131 131
         $html .= '</button>';
132 132
         $html .= EEH_HTML::div(
133 133
             '',
134
-            $input->html_id() . '-options-dv',
134
+            $input->html_id().'-options-dv',
135 135
             'checkbox-dropdown-selector'
136 136
         );
137 137
         $html .= EEH_HTML::link(
@@ -157,18 +157,18 @@  discard block
 block discarded – undo
157 157
                      . '">';
158 158
             $html .= EEH_HTML::nl(1, 'checkbox');
159 159
             $html .= '<input type="checkbox"';
160
-            $html .= ' name="' . $input->html_name() . '[]"';
161
-            $html .= ' id="' . $html_id . '"';
162
-            $html .= ' class="' . $input->html_class() . '-option"';
163
-            $html .= $input->html_style() ? ' style="' . $input->html_style() . '"' : '';
164
-            $html .= ' value="' . esc_attr($value) . '"';
160
+            $html .= ' name="'.$input->html_name().'[]"';
161
+            $html .= ' id="'.$html_id.'"';
162
+            $html .= ' class="'.$input->html_class().'-option"';
163
+            $html .= $input->html_style() ? ' style="'.$input->html_style().'"' : '';
164
+            $html .= ' value="'.esc_attr($value).'"';
165 165
             $html .= ! empty($input_raw_value) && in_array($value, $input_raw_value, true)
166 166
                 ? ' checked="checked"'
167 167
                 : '';
168
-            $html .= ' ' . $this->_input->other_html_attributes();
168
+            $html .= ' '.$this->_input->other_html_attributes();
169 169
             $html .= '>';
170
-            $html .= '<span class="datetime-selector-option-text-spn">' . $display_text . '</span>';
171
-            $html .= EEH_HTML::nl(-1, 'checkbox') . '</label>';
170
+            $html .= '<span class="datetime-selector-option-text-spn">'.$display_text.'</span>';
171
+            $html .= EEH_HTML::nl(-1, 'checkbox').'</label>';
172 172
             $html .= EEH_HTML::lix();
173 173
         }
174 174
         $html .= EEH_HTML::ulx();
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
                     'event_espresso'
183 183
                 )
184 184
             ),
185
-            $input->html_id() . '-date-time-filter-notice-pg',
185
+            $input->html_id().'-date-time-filter-notice-pg',
186 186
             'date-time-filter-notice-pg small-text lt-grey-text'
187 187
         );
188 188
         $html .= \EEH_HTML::br();
Please login to merge, or discard this patch.
core/db_classes/EE_Event.class.php 2 patches
Indentation   +1351 added lines, -1351 removed lines patch added patch discarded remove patch
@@ -13,1355 +13,1355 @@
 block discarded – undo
13 13
 class EE_Event extends EE_CPT_Base implements EEI_Line_Item_Object, EEI_Admin_Links, EEI_Has_Icon, EEI_Event
14 14
 {
15 15
 
16
-    /**
17
-     * cached value for the the logical active status for the event
18
-     *
19
-     * @see get_active_status()
20
-     * @var string
21
-     */
22
-    protected $_active_status = '';
23
-
24
-    /**
25
-     * This is just used for caching the Primary Datetime for the Event on initial retrieval
26
-     *
27
-     * @var EE_Datetime
28
-     */
29
-    protected $_Primary_Datetime;
30
-
31
-    /**
32
-     * @var EventSpacesCalculator $available_spaces_calculator
33
-     */
34
-    protected $available_spaces_calculator;
35
-
36
-
37
-    /**
38
-     * @param array  $props_n_values          incoming values
39
-     * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
40
-     *                                        used.)
41
-     * @param array  $date_formats            incoming date_formats in an array where the first value is the
42
-     *                                        date_format and the second value is the time format
43
-     * @return EE_Event
44
-     * @throws EE_Error
45
-     */
46
-    public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
47
-    {
48
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
49
-        return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
50
-    }
51
-
52
-
53
-    /**
54
-     * @param array  $props_n_values  incoming values from the database
55
-     * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
56
-     *                                the website will be used.
57
-     * @return EE_Event
58
-     * @throws EE_Error
59
-     */
60
-    public static function new_instance_from_db($props_n_values = array(), $timezone = null)
61
-    {
62
-        return new self($props_n_values, true, $timezone);
63
-    }
64
-
65
-
66
-    /**
67
-     * @return EventSpacesCalculator
68
-     * @throws \EE_Error
69
-     */
70
-    public function getAvailableSpacesCalculator()
71
-    {
72
-        if (! $this->available_spaces_calculator instanceof EventSpacesCalculator) {
73
-            $this->available_spaces_calculator = new EventSpacesCalculator($this);
74
-        }
75
-        return $this->available_spaces_calculator;
76
-    }
77
-
78
-
79
-    /**
80
-     * Overrides parent set() method so that all calls to set( 'status', $status ) can be routed to internal methods
81
-     *
82
-     * @param string $field_name
83
-     * @param mixed  $field_value
84
-     * @param bool   $use_default
85
-     * @throws EE_Error
86
-     */
87
-    public function set($field_name, $field_value, $use_default = false)
88
-    {
89
-        switch ($field_name) {
90
-            case 'status':
91
-                $this->set_status($field_value, $use_default);
92
-                break;
93
-            default:
94
-                parent::set($field_name, $field_value, $use_default);
95
-        }
96
-    }
97
-
98
-
99
-    /**
100
-     *    set_status
101
-     * Checks if event status is being changed to SOLD OUT
102
-     * and updates event meta data with previous event status
103
-     * so that we can revert things if/when the event is no longer sold out
104
-     *
105
-     * @access public
106
-     * @param string $new_status
107
-     * @param bool   $use_default
108
-     * @return void
109
-     * @throws EE_Error
110
-     */
111
-    public function set_status($new_status = null, $use_default = false)
112
-    {
113
-        // if nothing is set, and we aren't explicitly wanting to reset the status, then just leave
114
-        if (empty($new_status) && ! $use_default) {
115
-            return;
116
-        }
117
-        // get current Event status
118
-        $old_status = $this->status();
119
-        // if status has changed
120
-        if ($old_status !== $new_status) {
121
-            // TO sold_out
122
-            if ($new_status === EEM_Event::sold_out) {
123
-                // save the previous event status so that we can revert if the event is no longer sold out
124
-                $this->add_post_meta('_previous_event_status', $old_status);
125
-                do_action('AHEE__EE_Event__set_status__to_sold_out', $this, $old_status, $new_status);
126
-                // OR FROM  sold_out
127
-            } elseif ($old_status === EEM_Event::sold_out) {
128
-                $this->delete_post_meta('_previous_event_status');
129
-                do_action('AHEE__EE_Event__set_status__from_sold_out', $this, $old_status, $new_status);
130
-            }
131
-            // clear out the active status so that it gets reset the next time it is requested
132
-            $this->_active_status = null;
133
-            // update status
134
-            parent::set('status', $new_status, $use_default);
135
-            do_action('AHEE__EE_Event__set_status__after_update', $this);
136
-            return;
137
-        }
138
-        // even though the old value matches the new value, it's still good to
139
-        // allow the parent set method to have a say
140
-        parent::set('status', $new_status, $use_default);
141
-    }
142
-
143
-
144
-    /**
145
-     * Gets all the datetimes for this event
146
-     *
147
-     * @param array $query_params like EEM_Base::get_all
148
-     * @return EE_Base_Class[]|EE_Datetime[]
149
-     * @throws EE_Error
150
-     */
151
-    public function datetimes($query_params = array())
152
-    {
153
-        return $this->get_many_related('Datetime', $query_params);
154
-    }
155
-
156
-
157
-    /**
158
-     * Gets all the datetimes for this event, ordered by DTT_EVT_start in ascending order
159
-     *
160
-     * @return EE_Base_Class[]|EE_Datetime[]
161
-     * @throws EE_Error
162
-     */
163
-    public function datetimes_in_chronological_order()
164
-    {
165
-        return $this->get_many_related('Datetime', array('order_by' => array('DTT_EVT_start' => 'ASC')));
166
-    }
167
-
168
-
169
-    /**
170
-     * Gets all the datetimes for this event, ordered by the DTT_order on the datetime.
171
-     * @darren, we should probably UNSET timezone on the EEM_Datetime model
172
-     * after running our query, so that this timezone isn't set for EVERY query
173
-     * on EEM_Datetime for the rest of the request, no?
174
-     *
175
-     * @param boolean $show_expired whether or not to include expired events
176
-     * @param boolean $show_deleted whether or not to include deleted events
177
-     * @param null    $limit
178
-     * @return EE_Datetime[]
179
-     * @throws EE_Error
180
-     */
181
-    public function datetimes_ordered($show_expired = true, $show_deleted = false, $limit = null)
182
-    {
183
-        return EEM_Datetime::instance($this->_timezone)->get_datetimes_for_event_ordered_by_DTT_order(
184
-            $this->ID(),
185
-            $show_expired,
186
-            $show_deleted,
187
-            $limit
188
-        );
189
-    }
190
-
191
-
192
-    /**
193
-     * Returns one related datetime. Mostly only used by some legacy code.
194
-     *
195
-     * @return EE_Base_Class|EE_Datetime
196
-     * @throws EE_Error
197
-     */
198
-    public function first_datetime()
199
-    {
200
-        return $this->get_first_related('Datetime');
201
-    }
202
-
203
-
204
-    /**
205
-     * Returns the 'primary' datetime for the event
206
-     *
207
-     * @param bool $try_to_exclude_expired
208
-     * @param bool $try_to_exclude_deleted
209
-     * @return EE_Datetime
210
-     * @throws EE_Error
211
-     */
212
-    public function primary_datetime($try_to_exclude_expired = true, $try_to_exclude_deleted = true)
213
-    {
214
-        if (! empty($this->_Primary_Datetime)) {
215
-            return $this->_Primary_Datetime;
216
-        }
217
-        $this->_Primary_Datetime = EEM_Datetime::instance($this->_timezone)->get_primary_datetime_for_event(
218
-            $this->ID(),
219
-            $try_to_exclude_expired,
220
-            $try_to_exclude_deleted
221
-        );
222
-        return $this->_Primary_Datetime;
223
-    }
224
-
225
-
226
-    /**
227
-     * Gets all the tickets available for purchase of this event
228
-     *
229
-     * @param array $query_params like EEM_Base::get_all
230
-     * @return EE_Base_Class[]|EE_Ticket[]
231
-     * @throws EE_Error
232
-     */
233
-    public function tickets($query_params = array())
234
-    {
235
-        // first get all datetimes
236
-        $datetimes = $this->datetimes_ordered();
237
-        if (! $datetimes) {
238
-            return array();
239
-        }
240
-        $datetime_ids = array();
241
-        foreach ($datetimes as $datetime) {
242
-            $datetime_ids[] = $datetime->ID();
243
-        }
244
-        $where_params = array('Datetime.DTT_ID' => array('IN', $datetime_ids));
245
-        // if incoming $query_params has where conditions let's merge but not override existing.
246
-        if (is_array($query_params) && isset($query_params[0])) {
247
-            $where_params = array_merge($query_params[0], $where_params);
248
-            unset($query_params[0]);
249
-        }
250
-        // now add $where_params to $query_params
251
-        $query_params[0] = $where_params;
252
-        return EEM_Ticket::instance()->get_all($query_params);
253
-    }
254
-
255
-
256
-    /**
257
-     * get all unexpired untrashed tickets
258
-     *
259
-     * @return EE_Ticket[]
260
-     * @throws EE_Error
261
-     */
262
-    public function active_tickets()
263
-    {
264
-        return $this->tickets(
265
-            array(
266
-                array(
267
-                    'TKT_end_date' => array('>=', EEM_Ticket::instance()->current_time_for_query('TKT_end_date')),
268
-                    'TKT_deleted'  => false,
269
-                ),
270
-            )
271
-        );
272
-    }
273
-
274
-
275
-    /**
276
-     * @return bool
277
-     * @throws EE_Error
278
-     */
279
-    public function additional_limit()
280
-    {
281
-        return $this->get('EVT_additional_limit');
282
-    }
283
-
284
-
285
-    /**
286
-     * @return bool
287
-     * @throws EE_Error
288
-     */
289
-    public function allow_overflow()
290
-    {
291
-        return $this->get('EVT_allow_overflow');
292
-    }
293
-
294
-
295
-    /**
296
-     * @return bool
297
-     * @throws EE_Error
298
-     */
299
-    public function created()
300
-    {
301
-        return $this->get('EVT_created');
302
-    }
303
-
304
-
305
-    /**
306
-     * @return bool
307
-     * @throws EE_Error
308
-     */
309
-    public function description()
310
-    {
311
-        return $this->get('EVT_desc');
312
-    }
313
-
314
-
315
-    /**
316
-     * Runs do_shortcode and wpautop on the description
317
-     *
318
-     * @return string of html
319
-     * @throws EE_Error
320
-     */
321
-    public function description_filtered()
322
-    {
323
-        return $this->get_pretty('EVT_desc');
324
-    }
325
-
326
-
327
-    /**
328
-     * @return bool
329
-     * @throws EE_Error
330
-     */
331
-    public function display_description()
332
-    {
333
-        return $this->get('EVT_display_desc');
334
-    }
335
-
336
-
337
-    /**
338
-     * @return bool
339
-     * @throws EE_Error
340
-     */
341
-    public function display_ticket_selector()
342
-    {
343
-        return (bool) $this->get('EVT_display_ticket_selector');
344
-    }
345
-
346
-
347
-    /**
348
-     * @return bool
349
-     * @throws EE_Error
350
-     */
351
-    public function external_url()
352
-    {
353
-        return $this->get('EVT_external_URL');
354
-    }
355
-
356
-
357
-    /**
358
-     * @return bool
359
-     * @throws EE_Error
360
-     */
361
-    public function member_only()
362
-    {
363
-        return $this->get('EVT_member_only');
364
-    }
365
-
366
-
367
-    /**
368
-     * @return bool
369
-     * @throws EE_Error
370
-     */
371
-    public function phone()
372
-    {
373
-        return $this->get('EVT_phone');
374
-    }
375
-
376
-
377
-    /**
378
-     * @return bool
379
-     * @throws EE_Error
380
-     */
381
-    public function modified()
382
-    {
383
-        return $this->get('EVT_modified');
384
-    }
385
-
386
-
387
-    /**
388
-     * @return bool
389
-     * @throws EE_Error
390
-     */
391
-    public function name()
392
-    {
393
-        return $this->get('EVT_name');
394
-    }
395
-
396
-
397
-    /**
398
-     * @return bool
399
-     * @throws EE_Error
400
-     */
401
-    public function order()
402
-    {
403
-        return $this->get('EVT_order');
404
-    }
405
-
406
-
407
-    /**
408
-     * @return bool|string
409
-     * @throws EE_Error
410
-     */
411
-    public function default_registration_status()
412
-    {
413
-        $event_default_registration_status = $this->get('EVT_default_registration_status');
414
-        return ! empty($event_default_registration_status)
415
-            ? $event_default_registration_status
416
-            : EE_Registry::instance()->CFG->registration->default_STS_ID;
417
-    }
418
-
419
-
420
-    /**
421
-     * @param int  $num_words
422
-     * @param null $more
423
-     * @param bool $not_full_desc
424
-     * @return bool|string
425
-     * @throws EE_Error
426
-     */
427
-    public function short_description($num_words = 55, $more = null, $not_full_desc = false)
428
-    {
429
-        $short_desc = $this->get('EVT_short_desc');
430
-        if (! empty($short_desc) || $not_full_desc) {
431
-            return $short_desc;
432
-        }
433
-        $full_desc = $this->get('EVT_desc');
434
-        return wp_trim_words($full_desc, $num_words, $more);
435
-    }
436
-
437
-
438
-    /**
439
-     * @return bool
440
-     * @throws EE_Error
441
-     */
442
-    public function slug()
443
-    {
444
-        return $this->get('EVT_slug');
445
-    }
446
-
447
-
448
-    /**
449
-     * @return bool
450
-     * @throws EE_Error
451
-     */
452
-    public function timezone_string()
453
-    {
454
-        return $this->get('EVT_timezone_string');
455
-    }
456
-
457
-
458
-    /**
459
-     * @return bool
460
-     * @throws EE_Error
461
-     */
462
-    public function visible_on()
463
-    {
464
-        return $this->get('EVT_visible_on');
465
-    }
466
-
467
-
468
-    /**
469
-     * @return int
470
-     * @throws EE_Error
471
-     */
472
-    public function wp_user()
473
-    {
474
-        return $this->get('EVT_wp_user');
475
-    }
476
-
477
-
478
-    /**
479
-     * @return bool
480
-     * @throws EE_Error
481
-     */
482
-    public function donations()
483
-    {
484
-        return $this->get('EVT_donations');
485
-    }
486
-
487
-
488
-    /**
489
-     * @param $limit
490
-     * @throws EE_Error
491
-     */
492
-    public function set_additional_limit($limit)
493
-    {
494
-        $this->set('EVT_additional_limit', $limit);
495
-    }
496
-
497
-
498
-    /**
499
-     * @param $created
500
-     * @throws EE_Error
501
-     */
502
-    public function set_created($created)
503
-    {
504
-        $this->set('EVT_created', $created);
505
-    }
506
-
507
-
508
-    /**
509
-     * @param $desc
510
-     * @throws EE_Error
511
-     */
512
-    public function set_description($desc)
513
-    {
514
-        $this->set('EVT_desc', $desc);
515
-    }
516
-
517
-
518
-    /**
519
-     * @param $display_desc
520
-     * @throws EE_Error
521
-     */
522
-    public function set_display_description($display_desc)
523
-    {
524
-        $this->set('EVT_display_desc', $display_desc);
525
-    }
526
-
527
-
528
-    /**
529
-     * @param $display_ticket_selector
530
-     * @throws EE_Error
531
-     */
532
-    public function set_display_ticket_selector($display_ticket_selector)
533
-    {
534
-        $this->set('EVT_display_ticket_selector', $display_ticket_selector);
535
-    }
536
-
537
-
538
-    /**
539
-     * @param $external_url
540
-     * @throws EE_Error
541
-     */
542
-    public function set_external_url($external_url)
543
-    {
544
-        $this->set('EVT_external_URL', $external_url);
545
-    }
546
-
547
-
548
-    /**
549
-     * @param $member_only
550
-     * @throws EE_Error
551
-     */
552
-    public function set_member_only($member_only)
553
-    {
554
-        $this->set('EVT_member_only', $member_only);
555
-    }
556
-
557
-
558
-    /**
559
-     * @param $event_phone
560
-     * @throws EE_Error
561
-     */
562
-    public function set_event_phone($event_phone)
563
-    {
564
-        $this->set('EVT_phone', $event_phone);
565
-    }
566
-
567
-
568
-    /**
569
-     * @param $modified
570
-     * @throws EE_Error
571
-     */
572
-    public function set_modified($modified)
573
-    {
574
-        $this->set('EVT_modified', $modified);
575
-    }
576
-
577
-
578
-    /**
579
-     * @param $name
580
-     * @throws EE_Error
581
-     */
582
-    public function set_name($name)
583
-    {
584
-        $this->set('EVT_name', $name);
585
-    }
586
-
587
-
588
-    /**
589
-     * @param $order
590
-     * @throws EE_Error
591
-     */
592
-    public function set_order($order)
593
-    {
594
-        $this->set('EVT_order', $order);
595
-    }
596
-
597
-
598
-    /**
599
-     * @param $short_desc
600
-     * @throws EE_Error
601
-     */
602
-    public function set_short_description($short_desc)
603
-    {
604
-        $this->set('EVT_short_desc', $short_desc);
605
-    }
606
-
607
-
608
-    /**
609
-     * @param $slug
610
-     * @throws EE_Error
611
-     */
612
-    public function set_slug($slug)
613
-    {
614
-        $this->set('EVT_slug', $slug);
615
-    }
616
-
617
-
618
-    /**
619
-     * @param $timezone_string
620
-     * @throws EE_Error
621
-     */
622
-    public function set_timezone_string($timezone_string)
623
-    {
624
-        $this->set('EVT_timezone_string', $timezone_string);
625
-    }
626
-
627
-
628
-    /**
629
-     * @param $visible_on
630
-     * @throws EE_Error
631
-     */
632
-    public function set_visible_on($visible_on)
633
-    {
634
-        $this->set('EVT_visible_on', $visible_on);
635
-    }
636
-
637
-
638
-    /**
639
-     * @param $wp_user
640
-     * @throws EE_Error
641
-     */
642
-    public function set_wp_user($wp_user)
643
-    {
644
-        $this->set('EVT_wp_user', $wp_user);
645
-    }
646
-
647
-
648
-    /**
649
-     * @param $default_registration_status
650
-     * @throws EE_Error
651
-     */
652
-    public function set_default_registration_status($default_registration_status)
653
-    {
654
-        $this->set('EVT_default_registration_status', $default_registration_status);
655
-    }
656
-
657
-
658
-    /**
659
-     * @param $donations
660
-     * @throws EE_Error
661
-     */
662
-    public function set_donations($donations)
663
-    {
664
-        $this->set('EVT_donations', $donations);
665
-    }
666
-
667
-
668
-    /**
669
-     * Adds a venue to this event
670
-     *
671
-     * @param EE_Venue /int $venue_id_or_obj
672
-     * @return EE_Base_Class|EE_Venue
673
-     * @throws EE_Error
674
-     */
675
-    public function add_venue($venue_id_or_obj)
676
-    {
677
-        return $this->_add_relation_to($venue_id_or_obj, 'Venue');
678
-    }
679
-
680
-
681
-    /**
682
-     * Removes a venue from the event
683
-     *
684
-     * @param EE_Venue /int $venue_id_or_obj
685
-     * @return EE_Base_Class|EE_Venue
686
-     * @throws EE_Error
687
-     */
688
-    public function remove_venue($venue_id_or_obj)
689
-    {
690
-        return $this->_remove_relation_to($venue_id_or_obj, 'Venue');
691
-    }
692
-
693
-
694
-    /**
695
-     * Gets all the venues related ot the event. May provide additional $query_params if desired
696
-     *
697
-     * @param array $query_params like EEM_Base::get_all's $query_params
698
-     * @return EE_Base_Class[]|EE_Venue[]
699
-     * @throws EE_Error
700
-     */
701
-    public function venues($query_params = array())
702
-    {
703
-        return $this->get_many_related('Venue', $query_params);
704
-    }
705
-
706
-
707
-    /**
708
-     * check if event id is present and if event is published
709
-     *
710
-     * @access public
711
-     * @return boolean true yes, false no
712
-     * @throws EE_Error
713
-     */
714
-    private function _has_ID_and_is_published()
715
-    {
716
-        // first check if event id is present and not NULL,
717
-        // then check if this event is published (or any of the equivalent "published" statuses)
718
-        return
719
-            $this->ID() && $this->ID() !== null
720
-            && (
721
-                $this->status() === 'publish'
722
-                || $this->status() === EEM_Event::sold_out
723
-                || $this->status() === EEM_Event::postponed
724
-                || $this->status() === EEM_Event::cancelled
725
-            );
726
-    }
727
-
728
-
729
-    /**
730
-     * This simply compares the internal dates with NOW and determines if the event is upcoming or not.
731
-     *
732
-     * @access public
733
-     * @return boolean true yes, false no
734
-     * @throws EE_Error
735
-     */
736
-    public function is_upcoming()
737
-    {
738
-        // check if event id is present and if this event is published
739
-        if ($this->is_inactive()) {
740
-            return false;
741
-        }
742
-        // set initial value
743
-        $upcoming = false;
744
-        // next let's get all datetimes and loop through them
745
-        $datetimes = $this->datetimes_in_chronological_order();
746
-        foreach ($datetimes as $datetime) {
747
-            if ($datetime instanceof EE_Datetime) {
748
-                // if this dtt is expired then we continue cause one of the other datetimes might be upcoming.
749
-                if ($datetime->is_expired()) {
750
-                    continue;
751
-                }
752
-                // if this dtt is active then we return false.
753
-                if ($datetime->is_active()) {
754
-                    return false;
755
-                }
756
-                // otherwise let's check upcoming status
757
-                $upcoming = $datetime->is_upcoming();
758
-            }
759
-        }
760
-        return $upcoming;
761
-    }
762
-
763
-
764
-    /**
765
-     * @return bool
766
-     * @throws EE_Error
767
-     */
768
-    public function is_active()
769
-    {
770
-        // check if event id is present and if this event is published
771
-        if ($this->is_inactive()) {
772
-            return false;
773
-        }
774
-        // set initial value
775
-        $active = false;
776
-        // next let's get all datetimes and loop through them
777
-        $datetimes = $this->datetimes_in_chronological_order();
778
-        foreach ($datetimes as $datetime) {
779
-            if ($datetime instanceof EE_Datetime) {
780
-                // if this dtt is expired then we continue cause one of the other datetimes might be active.
781
-                if ($datetime->is_expired()) {
782
-                    continue;
783
-                }
784
-                // if this dtt is upcoming then we return false.
785
-                if ($datetime->is_upcoming()) {
786
-                    return false;
787
-                }
788
-                // otherwise let's check active status
789
-                $active = $datetime->is_active();
790
-            }
791
-        }
792
-        return $active;
793
-    }
794
-
795
-
796
-    /**
797
-     * @return bool
798
-     * @throws EE_Error
799
-     */
800
-    public function is_expired()
801
-    {
802
-        // check if event id is present and if this event is published
803
-        if ($this->is_inactive()) {
804
-            return false;
805
-        }
806
-        // set initial value
807
-        $expired = false;
808
-        // first let's get all datetimes and loop through them
809
-        $datetimes = $this->datetimes_in_chronological_order();
810
-        foreach ($datetimes as $datetime) {
811
-            if ($datetime instanceof EE_Datetime) {
812
-                // if this dtt is upcoming or active then we return false.
813
-                if ($datetime->is_upcoming() || $datetime->is_active()) {
814
-                    return false;
815
-                }
816
-                // otherwise let's check active status
817
-                $expired = $datetime->is_expired();
818
-            }
819
-        }
820
-        return $expired;
821
-    }
822
-
823
-
824
-    /**
825
-     * @return bool
826
-     * @throws EE_Error
827
-     */
828
-    public function is_inactive()
829
-    {
830
-        // check if event id is present and if this event is published
831
-        if ($this->_has_ID_and_is_published()) {
832
-            return false;
833
-        }
834
-        return true;
835
-    }
836
-
837
-
838
-    /**
839
-     * calculate spaces remaining based on "saleable" tickets
840
-     *
841
-     * @param array $tickets
842
-     * @param bool  $filtered
843
-     * @return int|float
844
-     * @throws EE_Error
845
-     * @throws DomainException
846
-     * @throws UnexpectedEntityException
847
-     */
848
-    public function spaces_remaining($tickets = array(), $filtered = true)
849
-    {
850
-        $this->getAvailableSpacesCalculator()->setActiveTickets($tickets);
851
-        $spaces_remaining = $this->getAvailableSpacesCalculator()->spacesRemaining();
852
-        return $filtered
853
-            ? apply_filters(
854
-                'FHEE_EE_Event__spaces_remaining',
855
-                $spaces_remaining,
856
-                $this,
857
-                $tickets
858
-            )
859
-            : $spaces_remaining;
860
-    }
861
-
862
-
863
-    /**
864
-     *    perform_sold_out_status_check
865
-     *    checks all of this events's datetime  reg_limit - sold values to determine if ANY datetimes have spaces
866
-     *    available... if NOT, then the event status will get toggled to 'sold_out'
867
-     *
868
-     * @return bool    return the ACTUAL sold out state.
869
-     * @throws EE_Error
870
-     * @throws DomainException
871
-     * @throws UnexpectedEntityException
872
-     */
873
-    public function perform_sold_out_status_check()
874
-    {
875
-        // get all unexpired untrashed tickets
876
-        $tickets = $this->tickets(
877
-            array(
878
-                array('TKT_deleted' => false),
879
-                'order_by' => array('TKT_qty' => 'ASC'),
880
-            )
881
-        );
882
-        $all_expired = true;
883
-        foreach ($tickets as $ticket) {
884
-            if (! $ticket->is_expired()) {
885
-                $all_expired = false;
886
-                break;
887
-            }
888
-        }
889
-        // if all the tickets are just expired, then don't update the event status to sold out
890
-        if ($all_expired) {
891
-            return true;
892
-        }
893
-        $spaces_remaining = $this->spaces_remaining($tickets);
894
-        if ($spaces_remaining < 1) {
895
-            $this->set_status(EEM_Event::sold_out);
896
-            $this->save();
897
-            $sold_out = true;
898
-        } else {
899
-            $sold_out = false;
900
-            // was event previously marked as sold out ?
901
-            if ($this->status() === EEM_Event::sold_out) {
902
-                // revert status to previous value, if it was set
903
-                $previous_event_status = $this->get_post_meta('_previous_event_status', true);
904
-                if ($previous_event_status) {
905
-                    $this->set_status($previous_event_status);
906
-                    $this->save();
907
-                }
908
-            }
909
-        }
910
-        do_action('AHEE__EE_Event__perform_sold_out_status_check__end', $this, $sold_out, $spaces_remaining, $tickets);
911
-        return $sold_out;
912
-    }
913
-
914
-
915
-    /**
916
-     * This returns the total remaining spaces for sale on this event.
917
-     *
918
-     * @uses EE_Event::total_available_spaces()
919
-     * @return float|int
920
-     * @throws EE_Error
921
-     * @throws DomainException
922
-     * @throws UnexpectedEntityException
923
-     */
924
-    public function spaces_remaining_for_sale()
925
-    {
926
-        return $this->total_available_spaces(true);
927
-    }
928
-
929
-
930
-    /**
931
-     * This returns the total spaces available for an event
932
-     * while considering all the qtys on the tickets and the reg limits
933
-     * on the datetimes attached to this event.
934
-     *
935
-     * @param   bool $consider_sold Whether to consider any tickets that have already sold in our calculation.
936
-     *                              If this is false, then we return the most tickets that could ever be sold
937
-     *                              for this event with the datetime and tickets setup on the event under optimal
938
-     *                              selling conditions.  Otherwise we return a live calculation of spaces available
939
-     *                              based on tickets sold.  Depending on setup and stage of sales, this
940
-     *                              may appear to equal remaining tickets.  However, the more tickets are
941
-     *                              sold out, the more accurate the "live" total is.
942
-     * @return float|int
943
-     * @throws EE_Error
944
-     * @throws DomainException
945
-     * @throws UnexpectedEntityException
946
-     */
947
-    public function total_available_spaces($consider_sold = false)
948
-    {
949
-        $spaces_available = $consider_sold
950
-            ? $this->getAvailableSpacesCalculator()->spacesRemaining()
951
-            : $this->getAvailableSpacesCalculator()->totalSpacesAvailable();
952
-        return apply_filters(
953
-            'FHEE_EE_Event__total_available_spaces__spaces_available',
954
-            $spaces_available,
955
-            $this,
956
-            $this->getAvailableSpacesCalculator()->getDatetimes(),
957
-            $this->getAvailableSpacesCalculator()->getActiveTickets()
958
-        );
959
-    }
960
-
961
-
962
-    /**
963
-     * Checks if the event is set to sold out
964
-     *
965
-     * @param  bool $actual whether or not to perform calculations to not only figure the
966
-     *                      actual status but also to flip the status if necessary to sold
967
-     *                      out If false, we just check the existing status of the event
968
-     * @return boolean
969
-     * @throws EE_Error
970
-     */
971
-    public function is_sold_out($actual = false)
972
-    {
973
-        if (! $actual) {
974
-            return $this->status() === EEM_Event::sold_out;
975
-        }
976
-        return $this->perform_sold_out_status_check();
977
-    }
978
-
979
-
980
-    /**
981
-     * Checks if the event is marked as postponed
982
-     *
983
-     * @return boolean
984
-     */
985
-    public function is_postponed()
986
-    {
987
-        return $this->status() === EEM_Event::postponed;
988
-    }
989
-
990
-
991
-    /**
992
-     * Checks if the event is marked as cancelled
993
-     *
994
-     * @return boolean
995
-     */
996
-    public function is_cancelled()
997
-    {
998
-        return $this->status() === EEM_Event::cancelled;
999
-    }
1000
-
1001
-
1002
-    /**
1003
-     * Get the logical active status in a hierarchical order for all the datetimes.  Note
1004
-     * Basically, we order the datetimes by EVT_start_date.  Then first test on whether the event is published.  If its
1005
-     * NOT published then we test for whether its expired or not.  IF it IS published then we test first on whether an
1006
-     * event has any active dates.  If no active dates then we check for any upcoming dates.  If no upcoming dates then
1007
-     * the event is considered expired.
1008
-     * NOTE: this method does NOT calculate whether the datetimes are sold out when event is published.  Sold Out is a
1009
-     * status set on the EVENT when it is not published and thus is done
1010
-     *
1011
-     * @param bool $reset
1012
-     * @return bool | string - based on EE_Datetime active constants or FALSE if error.
1013
-     * @throws EE_Error
1014
-     */
1015
-    public function get_active_status($reset = false)
1016
-    {
1017
-        // if the active status has already been set, then just use that value (unless we are resetting it)
1018
-        if (! empty($this->_active_status) && ! $reset) {
1019
-            return $this->_active_status;
1020
-        }
1021
-        // first check if event id is present on this object
1022
-        if (! $this->ID()) {
1023
-            return false;
1024
-        }
1025
-        $where_params_for_event = array(array('EVT_ID' => $this->ID()));
1026
-        // if event is published:
1027
-        if ($this->status() === 'publish') {
1028
-            // active?
1029
-            if (EEM_Datetime::instance()->get_datetime_count_for_status(
1030
-                EE_Datetime::active,
1031
-                $where_params_for_event
1032
-            ) > 0) {
1033
-                $this->_active_status = EE_Datetime::active;
1034
-            } else {
1035
-                // upcoming?
1036
-                if (EEM_Datetime::instance()->get_datetime_count_for_status(
1037
-                    EE_Datetime::upcoming,
1038
-                    $where_params_for_event
1039
-                ) > 0) {
1040
-                    $this->_active_status = EE_Datetime::upcoming;
1041
-                } else {
1042
-                    // expired?
1043
-                    if (EEM_Datetime::instance()->get_datetime_count_for_status(
1044
-                        EE_Datetime::expired,
1045
-                        $where_params_for_event
1046
-                    ) > 0
1047
-                    ) {
1048
-                        $this->_active_status = EE_Datetime::expired;
1049
-                    } else {
1050
-                        // it would be odd if things make it this far because it basically means there are no datetime's
1051
-                        // attached to the event.  So in this case it will just be considered inactive.
1052
-                        $this->_active_status = EE_Datetime::inactive;
1053
-                    }
1054
-                }
1055
-            }
1056
-        } else {
1057
-            // the event is not published, so let's just set it's active status according to its' post status
1058
-            switch ($this->status()) {
1059
-                case EEM_Event::sold_out:
1060
-                    $this->_active_status = EE_Datetime::sold_out;
1061
-                    break;
1062
-                case EEM_Event::cancelled:
1063
-                    $this->_active_status = EE_Datetime::cancelled;
1064
-                    break;
1065
-                case EEM_Event::postponed:
1066
-                    $this->_active_status = EE_Datetime::postponed;
1067
-                    break;
1068
-                default:
1069
-                    $this->_active_status = EE_Datetime::inactive;
1070
-            }
1071
-        }
1072
-        return $this->_active_status;
1073
-    }
1074
-
1075
-
1076
-    /**
1077
-     *    pretty_active_status
1078
-     *
1079
-     * @access public
1080
-     * @param boolean $echo whether to return (FALSE), or echo out the result (TRUE)
1081
-     * @return mixed void|string
1082
-     * @throws EE_Error
1083
-     */
1084
-    public function pretty_active_status($echo = true)
1085
-    {
1086
-        $active_status = $this->get_active_status();
1087
-        $status = '<span class="ee-status event-active-status-'
1088
-                  . $active_status
1089
-                  . '">'
1090
-                  . EEH_Template::pretty_status($active_status, false, 'sentence')
1091
-                  . '</span>';
1092
-        if ($echo) {
1093
-            echo $status;
1094
-            return '';
1095
-        }
1096
-        return $status;
1097
-    }
1098
-
1099
-
1100
-    /**
1101
-     * @return bool|int
1102
-     * @throws EE_Error
1103
-     */
1104
-    public function get_number_of_tickets_sold()
1105
-    {
1106
-        $tkt_sold = 0;
1107
-        if (! $this->ID()) {
1108
-            return 0;
1109
-        }
1110
-        $datetimes = $this->datetimes();
1111
-        foreach ($datetimes as $datetime) {
1112
-            if ($datetime instanceof EE_Datetime) {
1113
-                $tkt_sold += $datetime->sold();
1114
-            }
1115
-        }
1116
-        return $tkt_sold;
1117
-    }
1118
-
1119
-
1120
-    /**
1121
-     * This just returns a count of all the registrations for this event
1122
-     *
1123
-     * @access  public
1124
-     * @return int
1125
-     * @throws EE_Error
1126
-     */
1127
-    public function get_count_of_all_registrations()
1128
-    {
1129
-        return EEM_Event::instance()->count_related($this, 'Registration');
1130
-    }
1131
-
1132
-
1133
-    /**
1134
-     * This returns the ticket with the earliest start time that is
1135
-     * available for this event (across all datetimes attached to the event)
1136
-     *
1137
-     * @return EE_Base_Class|EE_Ticket|null
1138
-     * @throws EE_Error
1139
-     */
1140
-    public function get_ticket_with_earliest_start_time()
1141
-    {
1142
-        $where['Datetime.EVT_ID'] = $this->ID();
1143
-        $query_params = array($where, 'order_by' => array('TKT_start_date' => 'ASC'));
1144
-        return EE_Registry::instance()->load_model('Ticket')->get_one($query_params);
1145
-    }
1146
-
1147
-
1148
-    /**
1149
-     * This returns the ticket with the latest end time that is available
1150
-     * for this event (across all datetimes attached to the event)
1151
-     *
1152
-     * @return EE_Base_Class|EE_Ticket|null
1153
-     * @throws EE_Error
1154
-     */
1155
-    public function get_ticket_with_latest_end_time()
1156
-    {
1157
-        $where['Datetime.EVT_ID'] = $this->ID();
1158
-        $query_params = array($where, 'order_by' => array('TKT_end_date' => 'DESC'));
1159
-        return EE_Registry::instance()->load_model('Ticket')->get_one($query_params);
1160
-    }
1161
-
1162
-
1163
-    /**
1164
-     * This returns the number of different ticket types currently on sale for this event.
1165
-     *
1166
-     * @return int
1167
-     * @throws EE_Error
1168
-     */
1169
-    public function countTicketsOnSale()
1170
-    {
1171
-        $where = array(
1172
-            'Datetime.EVT_ID' => $this->ID(),
1173
-            'TKT_start_date'  => array('<', time()),
1174
-            'TKT_end_date'    => array('>', time()),
1175
-        );
1176
-        return EEM_Ticket::instance()->count(array($where));
1177
-    }
1178
-
1179
-
1180
-    /**
1181
-     * This returns whether there are any tickets on sale for this event.
1182
-     *
1183
-     * @return bool true = YES tickets on sale.
1184
-     * @throws EE_Error
1185
-     */
1186
-    public function tickets_on_sale()
1187
-    {
1188
-        return $this->countTicketsOnSale() > 0;
1189
-    }
1190
-
1191
-
1192
-    /**
1193
-     * Gets the URL for viewing this event on the front-end. Overrides parent
1194
-     * to check for an external URL first
1195
-     *
1196
-     * @return string
1197
-     * @throws EE_Error
1198
-     */
1199
-    public function get_permalink()
1200
-    {
1201
-        if ($this->external_url()) {
1202
-            return $this->external_url();
1203
-        }
1204
-        return parent::get_permalink();
1205
-    }
1206
-
1207
-
1208
-    /**
1209
-     * Gets the first term for 'espresso_event_categories' we can find
1210
-     *
1211
-     * @param array $query_params like EEM_Base::get_all
1212
-     * @return EE_Base_Class|EE_Term|null
1213
-     * @throws EE_Error
1214
-     */
1215
-    public function first_event_category($query_params = array())
1216
-    {
1217
-        $query_params[0]['Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
1218
-        $query_params[0]['Term_Taxonomy.Event.EVT_ID'] = $this->ID();
1219
-        return EEM_Term::instance()->get_one($query_params);
1220
-    }
1221
-
1222
-
1223
-    /**
1224
-     * Gets all terms for 'espresso_event_categories' we can find
1225
-     *
1226
-     * @param array $query_params
1227
-     * @return EE_Base_Class[]|EE_Term[]
1228
-     * @throws EE_Error
1229
-     */
1230
-    public function get_all_event_categories($query_params = array())
1231
-    {
1232
-        $query_params[0]['Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
1233
-        $query_params[0]['Term_Taxonomy.Event.EVT_ID'] = $this->ID();
1234
-        return EEM_Term::instance()->get_all($query_params);
1235
-    }
1236
-
1237
-
1238
-    /**
1239
-     * Adds a question group to this event
1240
-     *
1241
-     * @param EE_Question_Group|int $question_group_id_or_obj
1242
-     * @param bool                  $for_primary if true, the question group will be added for the primary
1243
-     *                                           registrant, if false will be added for others. default: false
1244
-     * @return EE_Base_Class|EE_Question_Group
1245
-     * @throws EE_Error
1246
-     */
1247
-    public function add_question_group($question_group_id_or_obj, $for_primary = false)
1248
-    {
1249
-        $extra = $for_primary
1250
-            ? array('EQG_primary' => 1)
1251
-            : array();
1252
-        return $this->_add_relation_to($question_group_id_or_obj, 'Question_Group', $extra);
1253
-    }
1254
-
1255
-
1256
-    /**
1257
-     * Removes a question group from the event
1258
-     *
1259
-     * @param EE_Question_Group|int $question_group_id_or_obj
1260
-     * @param bool                  $for_primary if true, the question group will be removed from the primary
1261
-     *                                           registrant, if false will be removed from others. default: false
1262
-     * @return EE_Base_Class|EE_Question_Group
1263
-     * @throws EE_Error
1264
-     */
1265
-    public function remove_question_group($question_group_id_or_obj, $for_primary = false)
1266
-    {
1267
-        $where = $for_primary
1268
-            ? array('EQG_primary' => 1)
1269
-            : array();
1270
-        return $this->_remove_relation_to($question_group_id_or_obj, 'Question_Group', $where);
1271
-    }
1272
-
1273
-
1274
-    /**
1275
-     * Gets all the question groups, ordering them by QSG_order ascending
1276
-     *
1277
-     * @param array $query_params @see EEM_Base::get_all
1278
-     * @return EE_Base_Class[]|EE_Question_Group[]
1279
-     * @throws EE_Error
1280
-     */
1281
-    public function question_groups($query_params = array())
1282
-    {
1283
-        $query_params = ! empty($query_params) ? $query_params : array('order_by' => array('QSG_order' => 'ASC'));
1284
-        return $this->get_many_related('Question_Group', $query_params);
1285
-    }
1286
-
1287
-
1288
-    /**
1289
-     * Implementation for EEI_Has_Icon interface method.
1290
-     *
1291
-     * @see EEI_Visual_Representation for comments
1292
-     * @return string
1293
-     */
1294
-    public function get_icon()
1295
-    {
1296
-        return '<span class="dashicons dashicons-flag"></span>';
1297
-    }
1298
-
1299
-
1300
-    /**
1301
-     * Implementation for EEI_Admin_Links interface method.
1302
-     *
1303
-     * @see EEI_Admin_Links for comments
1304
-     * @return string
1305
-     * @throws EE_Error
1306
-     */
1307
-    public function get_admin_details_link()
1308
-    {
1309
-        return $this->get_admin_edit_link();
1310
-    }
1311
-
1312
-
1313
-    /**
1314
-     * Implementation for EEI_Admin_Links interface method.
1315
-     *
1316
-     * @see EEI_Admin_Links for comments
1317
-     * @return string
1318
-     * @throws EE_Error
1319
-     */
1320
-    public function get_admin_edit_link()
1321
-    {
1322
-        return EEH_URL::add_query_args_and_nonce(
1323
-            array(
1324
-                'page'   => 'espresso_events',
1325
-                'action' => 'edit',
1326
-                'post'   => $this->ID(),
1327
-            ),
1328
-            admin_url('admin.php')
1329
-        );
1330
-    }
1331
-
1332
-
1333
-    /**
1334
-     * Implementation for EEI_Admin_Links interface method.
1335
-     *
1336
-     * @see EEI_Admin_Links for comments
1337
-     * @return string
1338
-     */
1339
-    public function get_admin_settings_link()
1340
-    {
1341
-        return EEH_URL::add_query_args_and_nonce(
1342
-            array(
1343
-                'page'   => 'espresso_events',
1344
-                'action' => 'default_event_settings',
1345
-            ),
1346
-            admin_url('admin.php')
1347
-        );
1348
-    }
1349
-
1350
-
1351
-    /**
1352
-     * Implementation for EEI_Admin_Links interface method.
1353
-     *
1354
-     * @see EEI_Admin_Links for comments
1355
-     * @return string
1356
-     */
1357
-    public function get_admin_overview_link()
1358
-    {
1359
-        return EEH_URL::add_query_args_and_nonce(
1360
-            array(
1361
-                'page'   => 'espresso_events',
1362
-                'action' => 'default',
1363
-            ),
1364
-            admin_url('admin.php')
1365
-        );
1366
-    }
16
+	/**
17
+	 * cached value for the the logical active status for the event
18
+	 *
19
+	 * @see get_active_status()
20
+	 * @var string
21
+	 */
22
+	protected $_active_status = '';
23
+
24
+	/**
25
+	 * This is just used for caching the Primary Datetime for the Event on initial retrieval
26
+	 *
27
+	 * @var EE_Datetime
28
+	 */
29
+	protected $_Primary_Datetime;
30
+
31
+	/**
32
+	 * @var EventSpacesCalculator $available_spaces_calculator
33
+	 */
34
+	protected $available_spaces_calculator;
35
+
36
+
37
+	/**
38
+	 * @param array  $props_n_values          incoming values
39
+	 * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
40
+	 *                                        used.)
41
+	 * @param array  $date_formats            incoming date_formats in an array where the first value is the
42
+	 *                                        date_format and the second value is the time format
43
+	 * @return EE_Event
44
+	 * @throws EE_Error
45
+	 */
46
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
47
+	{
48
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
49
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
50
+	}
51
+
52
+
53
+	/**
54
+	 * @param array  $props_n_values  incoming values from the database
55
+	 * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
56
+	 *                                the website will be used.
57
+	 * @return EE_Event
58
+	 * @throws EE_Error
59
+	 */
60
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null)
61
+	{
62
+		return new self($props_n_values, true, $timezone);
63
+	}
64
+
65
+
66
+	/**
67
+	 * @return EventSpacesCalculator
68
+	 * @throws \EE_Error
69
+	 */
70
+	public function getAvailableSpacesCalculator()
71
+	{
72
+		if (! $this->available_spaces_calculator instanceof EventSpacesCalculator) {
73
+			$this->available_spaces_calculator = new EventSpacesCalculator($this);
74
+		}
75
+		return $this->available_spaces_calculator;
76
+	}
77
+
78
+
79
+	/**
80
+	 * Overrides parent set() method so that all calls to set( 'status', $status ) can be routed to internal methods
81
+	 *
82
+	 * @param string $field_name
83
+	 * @param mixed  $field_value
84
+	 * @param bool   $use_default
85
+	 * @throws EE_Error
86
+	 */
87
+	public function set($field_name, $field_value, $use_default = false)
88
+	{
89
+		switch ($field_name) {
90
+			case 'status':
91
+				$this->set_status($field_value, $use_default);
92
+				break;
93
+			default:
94
+				parent::set($field_name, $field_value, $use_default);
95
+		}
96
+	}
97
+
98
+
99
+	/**
100
+	 *    set_status
101
+	 * Checks if event status is being changed to SOLD OUT
102
+	 * and updates event meta data with previous event status
103
+	 * so that we can revert things if/when the event is no longer sold out
104
+	 *
105
+	 * @access public
106
+	 * @param string $new_status
107
+	 * @param bool   $use_default
108
+	 * @return void
109
+	 * @throws EE_Error
110
+	 */
111
+	public function set_status($new_status = null, $use_default = false)
112
+	{
113
+		// if nothing is set, and we aren't explicitly wanting to reset the status, then just leave
114
+		if (empty($new_status) && ! $use_default) {
115
+			return;
116
+		}
117
+		// get current Event status
118
+		$old_status = $this->status();
119
+		// if status has changed
120
+		if ($old_status !== $new_status) {
121
+			// TO sold_out
122
+			if ($new_status === EEM_Event::sold_out) {
123
+				// save the previous event status so that we can revert if the event is no longer sold out
124
+				$this->add_post_meta('_previous_event_status', $old_status);
125
+				do_action('AHEE__EE_Event__set_status__to_sold_out', $this, $old_status, $new_status);
126
+				// OR FROM  sold_out
127
+			} elseif ($old_status === EEM_Event::sold_out) {
128
+				$this->delete_post_meta('_previous_event_status');
129
+				do_action('AHEE__EE_Event__set_status__from_sold_out', $this, $old_status, $new_status);
130
+			}
131
+			// clear out the active status so that it gets reset the next time it is requested
132
+			$this->_active_status = null;
133
+			// update status
134
+			parent::set('status', $new_status, $use_default);
135
+			do_action('AHEE__EE_Event__set_status__after_update', $this);
136
+			return;
137
+		}
138
+		// even though the old value matches the new value, it's still good to
139
+		// allow the parent set method to have a say
140
+		parent::set('status', $new_status, $use_default);
141
+	}
142
+
143
+
144
+	/**
145
+	 * Gets all the datetimes for this event
146
+	 *
147
+	 * @param array $query_params like EEM_Base::get_all
148
+	 * @return EE_Base_Class[]|EE_Datetime[]
149
+	 * @throws EE_Error
150
+	 */
151
+	public function datetimes($query_params = array())
152
+	{
153
+		return $this->get_many_related('Datetime', $query_params);
154
+	}
155
+
156
+
157
+	/**
158
+	 * Gets all the datetimes for this event, ordered by DTT_EVT_start in ascending order
159
+	 *
160
+	 * @return EE_Base_Class[]|EE_Datetime[]
161
+	 * @throws EE_Error
162
+	 */
163
+	public function datetimes_in_chronological_order()
164
+	{
165
+		return $this->get_many_related('Datetime', array('order_by' => array('DTT_EVT_start' => 'ASC')));
166
+	}
167
+
168
+
169
+	/**
170
+	 * Gets all the datetimes for this event, ordered by the DTT_order on the datetime.
171
+	 * @darren, we should probably UNSET timezone on the EEM_Datetime model
172
+	 * after running our query, so that this timezone isn't set for EVERY query
173
+	 * on EEM_Datetime for the rest of the request, no?
174
+	 *
175
+	 * @param boolean $show_expired whether or not to include expired events
176
+	 * @param boolean $show_deleted whether or not to include deleted events
177
+	 * @param null    $limit
178
+	 * @return EE_Datetime[]
179
+	 * @throws EE_Error
180
+	 */
181
+	public function datetimes_ordered($show_expired = true, $show_deleted = false, $limit = null)
182
+	{
183
+		return EEM_Datetime::instance($this->_timezone)->get_datetimes_for_event_ordered_by_DTT_order(
184
+			$this->ID(),
185
+			$show_expired,
186
+			$show_deleted,
187
+			$limit
188
+		);
189
+	}
190
+
191
+
192
+	/**
193
+	 * Returns one related datetime. Mostly only used by some legacy code.
194
+	 *
195
+	 * @return EE_Base_Class|EE_Datetime
196
+	 * @throws EE_Error
197
+	 */
198
+	public function first_datetime()
199
+	{
200
+		return $this->get_first_related('Datetime');
201
+	}
202
+
203
+
204
+	/**
205
+	 * Returns the 'primary' datetime for the event
206
+	 *
207
+	 * @param bool $try_to_exclude_expired
208
+	 * @param bool $try_to_exclude_deleted
209
+	 * @return EE_Datetime
210
+	 * @throws EE_Error
211
+	 */
212
+	public function primary_datetime($try_to_exclude_expired = true, $try_to_exclude_deleted = true)
213
+	{
214
+		if (! empty($this->_Primary_Datetime)) {
215
+			return $this->_Primary_Datetime;
216
+		}
217
+		$this->_Primary_Datetime = EEM_Datetime::instance($this->_timezone)->get_primary_datetime_for_event(
218
+			$this->ID(),
219
+			$try_to_exclude_expired,
220
+			$try_to_exclude_deleted
221
+		);
222
+		return $this->_Primary_Datetime;
223
+	}
224
+
225
+
226
+	/**
227
+	 * Gets all the tickets available for purchase of this event
228
+	 *
229
+	 * @param array $query_params like EEM_Base::get_all
230
+	 * @return EE_Base_Class[]|EE_Ticket[]
231
+	 * @throws EE_Error
232
+	 */
233
+	public function tickets($query_params = array())
234
+	{
235
+		// first get all datetimes
236
+		$datetimes = $this->datetimes_ordered();
237
+		if (! $datetimes) {
238
+			return array();
239
+		}
240
+		$datetime_ids = array();
241
+		foreach ($datetimes as $datetime) {
242
+			$datetime_ids[] = $datetime->ID();
243
+		}
244
+		$where_params = array('Datetime.DTT_ID' => array('IN', $datetime_ids));
245
+		// if incoming $query_params has where conditions let's merge but not override existing.
246
+		if (is_array($query_params) && isset($query_params[0])) {
247
+			$where_params = array_merge($query_params[0], $where_params);
248
+			unset($query_params[0]);
249
+		}
250
+		// now add $where_params to $query_params
251
+		$query_params[0] = $where_params;
252
+		return EEM_Ticket::instance()->get_all($query_params);
253
+	}
254
+
255
+
256
+	/**
257
+	 * get all unexpired untrashed tickets
258
+	 *
259
+	 * @return EE_Ticket[]
260
+	 * @throws EE_Error
261
+	 */
262
+	public function active_tickets()
263
+	{
264
+		return $this->tickets(
265
+			array(
266
+				array(
267
+					'TKT_end_date' => array('>=', EEM_Ticket::instance()->current_time_for_query('TKT_end_date')),
268
+					'TKT_deleted'  => false,
269
+				),
270
+			)
271
+		);
272
+	}
273
+
274
+
275
+	/**
276
+	 * @return bool
277
+	 * @throws EE_Error
278
+	 */
279
+	public function additional_limit()
280
+	{
281
+		return $this->get('EVT_additional_limit');
282
+	}
283
+
284
+
285
+	/**
286
+	 * @return bool
287
+	 * @throws EE_Error
288
+	 */
289
+	public function allow_overflow()
290
+	{
291
+		return $this->get('EVT_allow_overflow');
292
+	}
293
+
294
+
295
+	/**
296
+	 * @return bool
297
+	 * @throws EE_Error
298
+	 */
299
+	public function created()
300
+	{
301
+		return $this->get('EVT_created');
302
+	}
303
+
304
+
305
+	/**
306
+	 * @return bool
307
+	 * @throws EE_Error
308
+	 */
309
+	public function description()
310
+	{
311
+		return $this->get('EVT_desc');
312
+	}
313
+
314
+
315
+	/**
316
+	 * Runs do_shortcode and wpautop on the description
317
+	 *
318
+	 * @return string of html
319
+	 * @throws EE_Error
320
+	 */
321
+	public function description_filtered()
322
+	{
323
+		return $this->get_pretty('EVT_desc');
324
+	}
325
+
326
+
327
+	/**
328
+	 * @return bool
329
+	 * @throws EE_Error
330
+	 */
331
+	public function display_description()
332
+	{
333
+		return $this->get('EVT_display_desc');
334
+	}
335
+
336
+
337
+	/**
338
+	 * @return bool
339
+	 * @throws EE_Error
340
+	 */
341
+	public function display_ticket_selector()
342
+	{
343
+		return (bool) $this->get('EVT_display_ticket_selector');
344
+	}
345
+
346
+
347
+	/**
348
+	 * @return bool
349
+	 * @throws EE_Error
350
+	 */
351
+	public function external_url()
352
+	{
353
+		return $this->get('EVT_external_URL');
354
+	}
355
+
356
+
357
+	/**
358
+	 * @return bool
359
+	 * @throws EE_Error
360
+	 */
361
+	public function member_only()
362
+	{
363
+		return $this->get('EVT_member_only');
364
+	}
365
+
366
+
367
+	/**
368
+	 * @return bool
369
+	 * @throws EE_Error
370
+	 */
371
+	public function phone()
372
+	{
373
+		return $this->get('EVT_phone');
374
+	}
375
+
376
+
377
+	/**
378
+	 * @return bool
379
+	 * @throws EE_Error
380
+	 */
381
+	public function modified()
382
+	{
383
+		return $this->get('EVT_modified');
384
+	}
385
+
386
+
387
+	/**
388
+	 * @return bool
389
+	 * @throws EE_Error
390
+	 */
391
+	public function name()
392
+	{
393
+		return $this->get('EVT_name');
394
+	}
395
+
396
+
397
+	/**
398
+	 * @return bool
399
+	 * @throws EE_Error
400
+	 */
401
+	public function order()
402
+	{
403
+		return $this->get('EVT_order');
404
+	}
405
+
406
+
407
+	/**
408
+	 * @return bool|string
409
+	 * @throws EE_Error
410
+	 */
411
+	public function default_registration_status()
412
+	{
413
+		$event_default_registration_status = $this->get('EVT_default_registration_status');
414
+		return ! empty($event_default_registration_status)
415
+			? $event_default_registration_status
416
+			: EE_Registry::instance()->CFG->registration->default_STS_ID;
417
+	}
418
+
419
+
420
+	/**
421
+	 * @param int  $num_words
422
+	 * @param null $more
423
+	 * @param bool $not_full_desc
424
+	 * @return bool|string
425
+	 * @throws EE_Error
426
+	 */
427
+	public function short_description($num_words = 55, $more = null, $not_full_desc = false)
428
+	{
429
+		$short_desc = $this->get('EVT_short_desc');
430
+		if (! empty($short_desc) || $not_full_desc) {
431
+			return $short_desc;
432
+		}
433
+		$full_desc = $this->get('EVT_desc');
434
+		return wp_trim_words($full_desc, $num_words, $more);
435
+	}
436
+
437
+
438
+	/**
439
+	 * @return bool
440
+	 * @throws EE_Error
441
+	 */
442
+	public function slug()
443
+	{
444
+		return $this->get('EVT_slug');
445
+	}
446
+
447
+
448
+	/**
449
+	 * @return bool
450
+	 * @throws EE_Error
451
+	 */
452
+	public function timezone_string()
453
+	{
454
+		return $this->get('EVT_timezone_string');
455
+	}
456
+
457
+
458
+	/**
459
+	 * @return bool
460
+	 * @throws EE_Error
461
+	 */
462
+	public function visible_on()
463
+	{
464
+		return $this->get('EVT_visible_on');
465
+	}
466
+
467
+
468
+	/**
469
+	 * @return int
470
+	 * @throws EE_Error
471
+	 */
472
+	public function wp_user()
473
+	{
474
+		return $this->get('EVT_wp_user');
475
+	}
476
+
477
+
478
+	/**
479
+	 * @return bool
480
+	 * @throws EE_Error
481
+	 */
482
+	public function donations()
483
+	{
484
+		return $this->get('EVT_donations');
485
+	}
486
+
487
+
488
+	/**
489
+	 * @param $limit
490
+	 * @throws EE_Error
491
+	 */
492
+	public function set_additional_limit($limit)
493
+	{
494
+		$this->set('EVT_additional_limit', $limit);
495
+	}
496
+
497
+
498
+	/**
499
+	 * @param $created
500
+	 * @throws EE_Error
501
+	 */
502
+	public function set_created($created)
503
+	{
504
+		$this->set('EVT_created', $created);
505
+	}
506
+
507
+
508
+	/**
509
+	 * @param $desc
510
+	 * @throws EE_Error
511
+	 */
512
+	public function set_description($desc)
513
+	{
514
+		$this->set('EVT_desc', $desc);
515
+	}
516
+
517
+
518
+	/**
519
+	 * @param $display_desc
520
+	 * @throws EE_Error
521
+	 */
522
+	public function set_display_description($display_desc)
523
+	{
524
+		$this->set('EVT_display_desc', $display_desc);
525
+	}
526
+
527
+
528
+	/**
529
+	 * @param $display_ticket_selector
530
+	 * @throws EE_Error
531
+	 */
532
+	public function set_display_ticket_selector($display_ticket_selector)
533
+	{
534
+		$this->set('EVT_display_ticket_selector', $display_ticket_selector);
535
+	}
536
+
537
+
538
+	/**
539
+	 * @param $external_url
540
+	 * @throws EE_Error
541
+	 */
542
+	public function set_external_url($external_url)
543
+	{
544
+		$this->set('EVT_external_URL', $external_url);
545
+	}
546
+
547
+
548
+	/**
549
+	 * @param $member_only
550
+	 * @throws EE_Error
551
+	 */
552
+	public function set_member_only($member_only)
553
+	{
554
+		$this->set('EVT_member_only', $member_only);
555
+	}
556
+
557
+
558
+	/**
559
+	 * @param $event_phone
560
+	 * @throws EE_Error
561
+	 */
562
+	public function set_event_phone($event_phone)
563
+	{
564
+		$this->set('EVT_phone', $event_phone);
565
+	}
566
+
567
+
568
+	/**
569
+	 * @param $modified
570
+	 * @throws EE_Error
571
+	 */
572
+	public function set_modified($modified)
573
+	{
574
+		$this->set('EVT_modified', $modified);
575
+	}
576
+
577
+
578
+	/**
579
+	 * @param $name
580
+	 * @throws EE_Error
581
+	 */
582
+	public function set_name($name)
583
+	{
584
+		$this->set('EVT_name', $name);
585
+	}
586
+
587
+
588
+	/**
589
+	 * @param $order
590
+	 * @throws EE_Error
591
+	 */
592
+	public function set_order($order)
593
+	{
594
+		$this->set('EVT_order', $order);
595
+	}
596
+
597
+
598
+	/**
599
+	 * @param $short_desc
600
+	 * @throws EE_Error
601
+	 */
602
+	public function set_short_description($short_desc)
603
+	{
604
+		$this->set('EVT_short_desc', $short_desc);
605
+	}
606
+
607
+
608
+	/**
609
+	 * @param $slug
610
+	 * @throws EE_Error
611
+	 */
612
+	public function set_slug($slug)
613
+	{
614
+		$this->set('EVT_slug', $slug);
615
+	}
616
+
617
+
618
+	/**
619
+	 * @param $timezone_string
620
+	 * @throws EE_Error
621
+	 */
622
+	public function set_timezone_string($timezone_string)
623
+	{
624
+		$this->set('EVT_timezone_string', $timezone_string);
625
+	}
626
+
627
+
628
+	/**
629
+	 * @param $visible_on
630
+	 * @throws EE_Error
631
+	 */
632
+	public function set_visible_on($visible_on)
633
+	{
634
+		$this->set('EVT_visible_on', $visible_on);
635
+	}
636
+
637
+
638
+	/**
639
+	 * @param $wp_user
640
+	 * @throws EE_Error
641
+	 */
642
+	public function set_wp_user($wp_user)
643
+	{
644
+		$this->set('EVT_wp_user', $wp_user);
645
+	}
646
+
647
+
648
+	/**
649
+	 * @param $default_registration_status
650
+	 * @throws EE_Error
651
+	 */
652
+	public function set_default_registration_status($default_registration_status)
653
+	{
654
+		$this->set('EVT_default_registration_status', $default_registration_status);
655
+	}
656
+
657
+
658
+	/**
659
+	 * @param $donations
660
+	 * @throws EE_Error
661
+	 */
662
+	public function set_donations($donations)
663
+	{
664
+		$this->set('EVT_donations', $donations);
665
+	}
666
+
667
+
668
+	/**
669
+	 * Adds a venue to this event
670
+	 *
671
+	 * @param EE_Venue /int $venue_id_or_obj
672
+	 * @return EE_Base_Class|EE_Venue
673
+	 * @throws EE_Error
674
+	 */
675
+	public function add_venue($venue_id_or_obj)
676
+	{
677
+		return $this->_add_relation_to($venue_id_or_obj, 'Venue');
678
+	}
679
+
680
+
681
+	/**
682
+	 * Removes a venue from the event
683
+	 *
684
+	 * @param EE_Venue /int $venue_id_or_obj
685
+	 * @return EE_Base_Class|EE_Venue
686
+	 * @throws EE_Error
687
+	 */
688
+	public function remove_venue($venue_id_or_obj)
689
+	{
690
+		return $this->_remove_relation_to($venue_id_or_obj, 'Venue');
691
+	}
692
+
693
+
694
+	/**
695
+	 * Gets all the venues related ot the event. May provide additional $query_params if desired
696
+	 *
697
+	 * @param array $query_params like EEM_Base::get_all's $query_params
698
+	 * @return EE_Base_Class[]|EE_Venue[]
699
+	 * @throws EE_Error
700
+	 */
701
+	public function venues($query_params = array())
702
+	{
703
+		return $this->get_many_related('Venue', $query_params);
704
+	}
705
+
706
+
707
+	/**
708
+	 * check if event id is present and if event is published
709
+	 *
710
+	 * @access public
711
+	 * @return boolean true yes, false no
712
+	 * @throws EE_Error
713
+	 */
714
+	private function _has_ID_and_is_published()
715
+	{
716
+		// first check if event id is present and not NULL,
717
+		// then check if this event is published (or any of the equivalent "published" statuses)
718
+		return
719
+			$this->ID() && $this->ID() !== null
720
+			&& (
721
+				$this->status() === 'publish'
722
+				|| $this->status() === EEM_Event::sold_out
723
+				|| $this->status() === EEM_Event::postponed
724
+				|| $this->status() === EEM_Event::cancelled
725
+			);
726
+	}
727
+
728
+
729
+	/**
730
+	 * This simply compares the internal dates with NOW and determines if the event is upcoming or not.
731
+	 *
732
+	 * @access public
733
+	 * @return boolean true yes, false no
734
+	 * @throws EE_Error
735
+	 */
736
+	public function is_upcoming()
737
+	{
738
+		// check if event id is present and if this event is published
739
+		if ($this->is_inactive()) {
740
+			return false;
741
+		}
742
+		// set initial value
743
+		$upcoming = false;
744
+		// next let's get all datetimes and loop through them
745
+		$datetimes = $this->datetimes_in_chronological_order();
746
+		foreach ($datetimes as $datetime) {
747
+			if ($datetime instanceof EE_Datetime) {
748
+				// if this dtt is expired then we continue cause one of the other datetimes might be upcoming.
749
+				if ($datetime->is_expired()) {
750
+					continue;
751
+				}
752
+				// if this dtt is active then we return false.
753
+				if ($datetime->is_active()) {
754
+					return false;
755
+				}
756
+				// otherwise let's check upcoming status
757
+				$upcoming = $datetime->is_upcoming();
758
+			}
759
+		}
760
+		return $upcoming;
761
+	}
762
+
763
+
764
+	/**
765
+	 * @return bool
766
+	 * @throws EE_Error
767
+	 */
768
+	public function is_active()
769
+	{
770
+		// check if event id is present and if this event is published
771
+		if ($this->is_inactive()) {
772
+			return false;
773
+		}
774
+		// set initial value
775
+		$active = false;
776
+		// next let's get all datetimes and loop through them
777
+		$datetimes = $this->datetimes_in_chronological_order();
778
+		foreach ($datetimes as $datetime) {
779
+			if ($datetime instanceof EE_Datetime) {
780
+				// if this dtt is expired then we continue cause one of the other datetimes might be active.
781
+				if ($datetime->is_expired()) {
782
+					continue;
783
+				}
784
+				// if this dtt is upcoming then we return false.
785
+				if ($datetime->is_upcoming()) {
786
+					return false;
787
+				}
788
+				// otherwise let's check active status
789
+				$active = $datetime->is_active();
790
+			}
791
+		}
792
+		return $active;
793
+	}
794
+
795
+
796
+	/**
797
+	 * @return bool
798
+	 * @throws EE_Error
799
+	 */
800
+	public function is_expired()
801
+	{
802
+		// check if event id is present and if this event is published
803
+		if ($this->is_inactive()) {
804
+			return false;
805
+		}
806
+		// set initial value
807
+		$expired = false;
808
+		// first let's get all datetimes and loop through them
809
+		$datetimes = $this->datetimes_in_chronological_order();
810
+		foreach ($datetimes as $datetime) {
811
+			if ($datetime instanceof EE_Datetime) {
812
+				// if this dtt is upcoming or active then we return false.
813
+				if ($datetime->is_upcoming() || $datetime->is_active()) {
814
+					return false;
815
+				}
816
+				// otherwise let's check active status
817
+				$expired = $datetime->is_expired();
818
+			}
819
+		}
820
+		return $expired;
821
+	}
822
+
823
+
824
+	/**
825
+	 * @return bool
826
+	 * @throws EE_Error
827
+	 */
828
+	public function is_inactive()
829
+	{
830
+		// check if event id is present and if this event is published
831
+		if ($this->_has_ID_and_is_published()) {
832
+			return false;
833
+		}
834
+		return true;
835
+	}
836
+
837
+
838
+	/**
839
+	 * calculate spaces remaining based on "saleable" tickets
840
+	 *
841
+	 * @param array $tickets
842
+	 * @param bool  $filtered
843
+	 * @return int|float
844
+	 * @throws EE_Error
845
+	 * @throws DomainException
846
+	 * @throws UnexpectedEntityException
847
+	 */
848
+	public function spaces_remaining($tickets = array(), $filtered = true)
849
+	{
850
+		$this->getAvailableSpacesCalculator()->setActiveTickets($tickets);
851
+		$spaces_remaining = $this->getAvailableSpacesCalculator()->spacesRemaining();
852
+		return $filtered
853
+			? apply_filters(
854
+				'FHEE_EE_Event__spaces_remaining',
855
+				$spaces_remaining,
856
+				$this,
857
+				$tickets
858
+			)
859
+			: $spaces_remaining;
860
+	}
861
+
862
+
863
+	/**
864
+	 *    perform_sold_out_status_check
865
+	 *    checks all of this events's datetime  reg_limit - sold values to determine if ANY datetimes have spaces
866
+	 *    available... if NOT, then the event status will get toggled to 'sold_out'
867
+	 *
868
+	 * @return bool    return the ACTUAL sold out state.
869
+	 * @throws EE_Error
870
+	 * @throws DomainException
871
+	 * @throws UnexpectedEntityException
872
+	 */
873
+	public function perform_sold_out_status_check()
874
+	{
875
+		// get all unexpired untrashed tickets
876
+		$tickets = $this->tickets(
877
+			array(
878
+				array('TKT_deleted' => false),
879
+				'order_by' => array('TKT_qty' => 'ASC'),
880
+			)
881
+		);
882
+		$all_expired = true;
883
+		foreach ($tickets as $ticket) {
884
+			if (! $ticket->is_expired()) {
885
+				$all_expired = false;
886
+				break;
887
+			}
888
+		}
889
+		// if all the tickets are just expired, then don't update the event status to sold out
890
+		if ($all_expired) {
891
+			return true;
892
+		}
893
+		$spaces_remaining = $this->spaces_remaining($tickets);
894
+		if ($spaces_remaining < 1) {
895
+			$this->set_status(EEM_Event::sold_out);
896
+			$this->save();
897
+			$sold_out = true;
898
+		} else {
899
+			$sold_out = false;
900
+			// was event previously marked as sold out ?
901
+			if ($this->status() === EEM_Event::sold_out) {
902
+				// revert status to previous value, if it was set
903
+				$previous_event_status = $this->get_post_meta('_previous_event_status', true);
904
+				if ($previous_event_status) {
905
+					$this->set_status($previous_event_status);
906
+					$this->save();
907
+				}
908
+			}
909
+		}
910
+		do_action('AHEE__EE_Event__perform_sold_out_status_check__end', $this, $sold_out, $spaces_remaining, $tickets);
911
+		return $sold_out;
912
+	}
913
+
914
+
915
+	/**
916
+	 * This returns the total remaining spaces for sale on this event.
917
+	 *
918
+	 * @uses EE_Event::total_available_spaces()
919
+	 * @return float|int
920
+	 * @throws EE_Error
921
+	 * @throws DomainException
922
+	 * @throws UnexpectedEntityException
923
+	 */
924
+	public function spaces_remaining_for_sale()
925
+	{
926
+		return $this->total_available_spaces(true);
927
+	}
928
+
929
+
930
+	/**
931
+	 * This returns the total spaces available for an event
932
+	 * while considering all the qtys on the tickets and the reg limits
933
+	 * on the datetimes attached to this event.
934
+	 *
935
+	 * @param   bool $consider_sold Whether to consider any tickets that have already sold in our calculation.
936
+	 *                              If this is false, then we return the most tickets that could ever be sold
937
+	 *                              for this event with the datetime and tickets setup on the event under optimal
938
+	 *                              selling conditions.  Otherwise we return a live calculation of spaces available
939
+	 *                              based on tickets sold.  Depending on setup and stage of sales, this
940
+	 *                              may appear to equal remaining tickets.  However, the more tickets are
941
+	 *                              sold out, the more accurate the "live" total is.
942
+	 * @return float|int
943
+	 * @throws EE_Error
944
+	 * @throws DomainException
945
+	 * @throws UnexpectedEntityException
946
+	 */
947
+	public function total_available_spaces($consider_sold = false)
948
+	{
949
+		$spaces_available = $consider_sold
950
+			? $this->getAvailableSpacesCalculator()->spacesRemaining()
951
+			: $this->getAvailableSpacesCalculator()->totalSpacesAvailable();
952
+		return apply_filters(
953
+			'FHEE_EE_Event__total_available_spaces__spaces_available',
954
+			$spaces_available,
955
+			$this,
956
+			$this->getAvailableSpacesCalculator()->getDatetimes(),
957
+			$this->getAvailableSpacesCalculator()->getActiveTickets()
958
+		);
959
+	}
960
+
961
+
962
+	/**
963
+	 * Checks if the event is set to sold out
964
+	 *
965
+	 * @param  bool $actual whether or not to perform calculations to not only figure the
966
+	 *                      actual status but also to flip the status if necessary to sold
967
+	 *                      out If false, we just check the existing status of the event
968
+	 * @return boolean
969
+	 * @throws EE_Error
970
+	 */
971
+	public function is_sold_out($actual = false)
972
+	{
973
+		if (! $actual) {
974
+			return $this->status() === EEM_Event::sold_out;
975
+		}
976
+		return $this->perform_sold_out_status_check();
977
+	}
978
+
979
+
980
+	/**
981
+	 * Checks if the event is marked as postponed
982
+	 *
983
+	 * @return boolean
984
+	 */
985
+	public function is_postponed()
986
+	{
987
+		return $this->status() === EEM_Event::postponed;
988
+	}
989
+
990
+
991
+	/**
992
+	 * Checks if the event is marked as cancelled
993
+	 *
994
+	 * @return boolean
995
+	 */
996
+	public function is_cancelled()
997
+	{
998
+		return $this->status() === EEM_Event::cancelled;
999
+	}
1000
+
1001
+
1002
+	/**
1003
+	 * Get the logical active status in a hierarchical order for all the datetimes.  Note
1004
+	 * Basically, we order the datetimes by EVT_start_date.  Then first test on whether the event is published.  If its
1005
+	 * NOT published then we test for whether its expired or not.  IF it IS published then we test first on whether an
1006
+	 * event has any active dates.  If no active dates then we check for any upcoming dates.  If no upcoming dates then
1007
+	 * the event is considered expired.
1008
+	 * NOTE: this method does NOT calculate whether the datetimes are sold out when event is published.  Sold Out is a
1009
+	 * status set on the EVENT when it is not published and thus is done
1010
+	 *
1011
+	 * @param bool $reset
1012
+	 * @return bool | string - based on EE_Datetime active constants or FALSE if error.
1013
+	 * @throws EE_Error
1014
+	 */
1015
+	public function get_active_status($reset = false)
1016
+	{
1017
+		// if the active status has already been set, then just use that value (unless we are resetting it)
1018
+		if (! empty($this->_active_status) && ! $reset) {
1019
+			return $this->_active_status;
1020
+		}
1021
+		// first check if event id is present on this object
1022
+		if (! $this->ID()) {
1023
+			return false;
1024
+		}
1025
+		$where_params_for_event = array(array('EVT_ID' => $this->ID()));
1026
+		// if event is published:
1027
+		if ($this->status() === 'publish') {
1028
+			// active?
1029
+			if (EEM_Datetime::instance()->get_datetime_count_for_status(
1030
+				EE_Datetime::active,
1031
+				$where_params_for_event
1032
+			) > 0) {
1033
+				$this->_active_status = EE_Datetime::active;
1034
+			} else {
1035
+				// upcoming?
1036
+				if (EEM_Datetime::instance()->get_datetime_count_for_status(
1037
+					EE_Datetime::upcoming,
1038
+					$where_params_for_event
1039
+				) > 0) {
1040
+					$this->_active_status = EE_Datetime::upcoming;
1041
+				} else {
1042
+					// expired?
1043
+					if (EEM_Datetime::instance()->get_datetime_count_for_status(
1044
+						EE_Datetime::expired,
1045
+						$where_params_for_event
1046
+					) > 0
1047
+					) {
1048
+						$this->_active_status = EE_Datetime::expired;
1049
+					} else {
1050
+						// it would be odd if things make it this far because it basically means there are no datetime's
1051
+						// attached to the event.  So in this case it will just be considered inactive.
1052
+						$this->_active_status = EE_Datetime::inactive;
1053
+					}
1054
+				}
1055
+			}
1056
+		} else {
1057
+			// the event is not published, so let's just set it's active status according to its' post status
1058
+			switch ($this->status()) {
1059
+				case EEM_Event::sold_out:
1060
+					$this->_active_status = EE_Datetime::sold_out;
1061
+					break;
1062
+				case EEM_Event::cancelled:
1063
+					$this->_active_status = EE_Datetime::cancelled;
1064
+					break;
1065
+				case EEM_Event::postponed:
1066
+					$this->_active_status = EE_Datetime::postponed;
1067
+					break;
1068
+				default:
1069
+					$this->_active_status = EE_Datetime::inactive;
1070
+			}
1071
+		}
1072
+		return $this->_active_status;
1073
+	}
1074
+
1075
+
1076
+	/**
1077
+	 *    pretty_active_status
1078
+	 *
1079
+	 * @access public
1080
+	 * @param boolean $echo whether to return (FALSE), or echo out the result (TRUE)
1081
+	 * @return mixed void|string
1082
+	 * @throws EE_Error
1083
+	 */
1084
+	public function pretty_active_status($echo = true)
1085
+	{
1086
+		$active_status = $this->get_active_status();
1087
+		$status = '<span class="ee-status event-active-status-'
1088
+				  . $active_status
1089
+				  . '">'
1090
+				  . EEH_Template::pretty_status($active_status, false, 'sentence')
1091
+				  . '</span>';
1092
+		if ($echo) {
1093
+			echo $status;
1094
+			return '';
1095
+		}
1096
+		return $status;
1097
+	}
1098
+
1099
+
1100
+	/**
1101
+	 * @return bool|int
1102
+	 * @throws EE_Error
1103
+	 */
1104
+	public function get_number_of_tickets_sold()
1105
+	{
1106
+		$tkt_sold = 0;
1107
+		if (! $this->ID()) {
1108
+			return 0;
1109
+		}
1110
+		$datetimes = $this->datetimes();
1111
+		foreach ($datetimes as $datetime) {
1112
+			if ($datetime instanceof EE_Datetime) {
1113
+				$tkt_sold += $datetime->sold();
1114
+			}
1115
+		}
1116
+		return $tkt_sold;
1117
+	}
1118
+
1119
+
1120
+	/**
1121
+	 * This just returns a count of all the registrations for this event
1122
+	 *
1123
+	 * @access  public
1124
+	 * @return int
1125
+	 * @throws EE_Error
1126
+	 */
1127
+	public function get_count_of_all_registrations()
1128
+	{
1129
+		return EEM_Event::instance()->count_related($this, 'Registration');
1130
+	}
1131
+
1132
+
1133
+	/**
1134
+	 * This returns the ticket with the earliest start time that is
1135
+	 * available for this event (across all datetimes attached to the event)
1136
+	 *
1137
+	 * @return EE_Base_Class|EE_Ticket|null
1138
+	 * @throws EE_Error
1139
+	 */
1140
+	public function get_ticket_with_earliest_start_time()
1141
+	{
1142
+		$where['Datetime.EVT_ID'] = $this->ID();
1143
+		$query_params = array($where, 'order_by' => array('TKT_start_date' => 'ASC'));
1144
+		return EE_Registry::instance()->load_model('Ticket')->get_one($query_params);
1145
+	}
1146
+
1147
+
1148
+	/**
1149
+	 * This returns the ticket with the latest end time that is available
1150
+	 * for this event (across all datetimes attached to the event)
1151
+	 *
1152
+	 * @return EE_Base_Class|EE_Ticket|null
1153
+	 * @throws EE_Error
1154
+	 */
1155
+	public function get_ticket_with_latest_end_time()
1156
+	{
1157
+		$where['Datetime.EVT_ID'] = $this->ID();
1158
+		$query_params = array($where, 'order_by' => array('TKT_end_date' => 'DESC'));
1159
+		return EE_Registry::instance()->load_model('Ticket')->get_one($query_params);
1160
+	}
1161
+
1162
+
1163
+	/**
1164
+	 * This returns the number of different ticket types currently on sale for this event.
1165
+	 *
1166
+	 * @return int
1167
+	 * @throws EE_Error
1168
+	 */
1169
+	public function countTicketsOnSale()
1170
+	{
1171
+		$where = array(
1172
+			'Datetime.EVT_ID' => $this->ID(),
1173
+			'TKT_start_date'  => array('<', time()),
1174
+			'TKT_end_date'    => array('>', time()),
1175
+		);
1176
+		return EEM_Ticket::instance()->count(array($where));
1177
+	}
1178
+
1179
+
1180
+	/**
1181
+	 * This returns whether there are any tickets on sale for this event.
1182
+	 *
1183
+	 * @return bool true = YES tickets on sale.
1184
+	 * @throws EE_Error
1185
+	 */
1186
+	public function tickets_on_sale()
1187
+	{
1188
+		return $this->countTicketsOnSale() > 0;
1189
+	}
1190
+
1191
+
1192
+	/**
1193
+	 * Gets the URL for viewing this event on the front-end. Overrides parent
1194
+	 * to check for an external URL first
1195
+	 *
1196
+	 * @return string
1197
+	 * @throws EE_Error
1198
+	 */
1199
+	public function get_permalink()
1200
+	{
1201
+		if ($this->external_url()) {
1202
+			return $this->external_url();
1203
+		}
1204
+		return parent::get_permalink();
1205
+	}
1206
+
1207
+
1208
+	/**
1209
+	 * Gets the first term for 'espresso_event_categories' we can find
1210
+	 *
1211
+	 * @param array $query_params like EEM_Base::get_all
1212
+	 * @return EE_Base_Class|EE_Term|null
1213
+	 * @throws EE_Error
1214
+	 */
1215
+	public function first_event_category($query_params = array())
1216
+	{
1217
+		$query_params[0]['Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
1218
+		$query_params[0]['Term_Taxonomy.Event.EVT_ID'] = $this->ID();
1219
+		return EEM_Term::instance()->get_one($query_params);
1220
+	}
1221
+
1222
+
1223
+	/**
1224
+	 * Gets all terms for 'espresso_event_categories' we can find
1225
+	 *
1226
+	 * @param array $query_params
1227
+	 * @return EE_Base_Class[]|EE_Term[]
1228
+	 * @throws EE_Error
1229
+	 */
1230
+	public function get_all_event_categories($query_params = array())
1231
+	{
1232
+		$query_params[0]['Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
1233
+		$query_params[0]['Term_Taxonomy.Event.EVT_ID'] = $this->ID();
1234
+		return EEM_Term::instance()->get_all($query_params);
1235
+	}
1236
+
1237
+
1238
+	/**
1239
+	 * Adds a question group to this event
1240
+	 *
1241
+	 * @param EE_Question_Group|int $question_group_id_or_obj
1242
+	 * @param bool                  $for_primary if true, the question group will be added for the primary
1243
+	 *                                           registrant, if false will be added for others. default: false
1244
+	 * @return EE_Base_Class|EE_Question_Group
1245
+	 * @throws EE_Error
1246
+	 */
1247
+	public function add_question_group($question_group_id_or_obj, $for_primary = false)
1248
+	{
1249
+		$extra = $for_primary
1250
+			? array('EQG_primary' => 1)
1251
+			: array();
1252
+		return $this->_add_relation_to($question_group_id_or_obj, 'Question_Group', $extra);
1253
+	}
1254
+
1255
+
1256
+	/**
1257
+	 * Removes a question group from the event
1258
+	 *
1259
+	 * @param EE_Question_Group|int $question_group_id_or_obj
1260
+	 * @param bool                  $for_primary if true, the question group will be removed from the primary
1261
+	 *                                           registrant, if false will be removed from others. default: false
1262
+	 * @return EE_Base_Class|EE_Question_Group
1263
+	 * @throws EE_Error
1264
+	 */
1265
+	public function remove_question_group($question_group_id_or_obj, $for_primary = false)
1266
+	{
1267
+		$where = $for_primary
1268
+			? array('EQG_primary' => 1)
1269
+			: array();
1270
+		return $this->_remove_relation_to($question_group_id_or_obj, 'Question_Group', $where);
1271
+	}
1272
+
1273
+
1274
+	/**
1275
+	 * Gets all the question groups, ordering them by QSG_order ascending
1276
+	 *
1277
+	 * @param array $query_params @see EEM_Base::get_all
1278
+	 * @return EE_Base_Class[]|EE_Question_Group[]
1279
+	 * @throws EE_Error
1280
+	 */
1281
+	public function question_groups($query_params = array())
1282
+	{
1283
+		$query_params = ! empty($query_params) ? $query_params : array('order_by' => array('QSG_order' => 'ASC'));
1284
+		return $this->get_many_related('Question_Group', $query_params);
1285
+	}
1286
+
1287
+
1288
+	/**
1289
+	 * Implementation for EEI_Has_Icon interface method.
1290
+	 *
1291
+	 * @see EEI_Visual_Representation for comments
1292
+	 * @return string
1293
+	 */
1294
+	public function get_icon()
1295
+	{
1296
+		return '<span class="dashicons dashicons-flag"></span>';
1297
+	}
1298
+
1299
+
1300
+	/**
1301
+	 * Implementation for EEI_Admin_Links interface method.
1302
+	 *
1303
+	 * @see EEI_Admin_Links for comments
1304
+	 * @return string
1305
+	 * @throws EE_Error
1306
+	 */
1307
+	public function get_admin_details_link()
1308
+	{
1309
+		return $this->get_admin_edit_link();
1310
+	}
1311
+
1312
+
1313
+	/**
1314
+	 * Implementation for EEI_Admin_Links interface method.
1315
+	 *
1316
+	 * @see EEI_Admin_Links for comments
1317
+	 * @return string
1318
+	 * @throws EE_Error
1319
+	 */
1320
+	public function get_admin_edit_link()
1321
+	{
1322
+		return EEH_URL::add_query_args_and_nonce(
1323
+			array(
1324
+				'page'   => 'espresso_events',
1325
+				'action' => 'edit',
1326
+				'post'   => $this->ID(),
1327
+			),
1328
+			admin_url('admin.php')
1329
+		);
1330
+	}
1331
+
1332
+
1333
+	/**
1334
+	 * Implementation for EEI_Admin_Links interface method.
1335
+	 *
1336
+	 * @see EEI_Admin_Links for comments
1337
+	 * @return string
1338
+	 */
1339
+	public function get_admin_settings_link()
1340
+	{
1341
+		return EEH_URL::add_query_args_and_nonce(
1342
+			array(
1343
+				'page'   => 'espresso_events',
1344
+				'action' => 'default_event_settings',
1345
+			),
1346
+			admin_url('admin.php')
1347
+		);
1348
+	}
1349
+
1350
+
1351
+	/**
1352
+	 * Implementation for EEI_Admin_Links interface method.
1353
+	 *
1354
+	 * @see EEI_Admin_Links for comments
1355
+	 * @return string
1356
+	 */
1357
+	public function get_admin_overview_link()
1358
+	{
1359
+		return EEH_URL::add_query_args_and_nonce(
1360
+			array(
1361
+				'page'   => 'espresso_events',
1362
+				'action' => 'default',
1363
+			),
1364
+			admin_url('admin.php')
1365
+		);
1366
+	}
1367 1367
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
      */
70 70
     public function getAvailableSpacesCalculator()
71 71
     {
72
-        if (! $this->available_spaces_calculator instanceof EventSpacesCalculator) {
72
+        if ( ! $this->available_spaces_calculator instanceof EventSpacesCalculator) {
73 73
             $this->available_spaces_calculator = new EventSpacesCalculator($this);
74 74
         }
75 75
         return $this->available_spaces_calculator;
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
      */
212 212
     public function primary_datetime($try_to_exclude_expired = true, $try_to_exclude_deleted = true)
213 213
     {
214
-        if (! empty($this->_Primary_Datetime)) {
214
+        if ( ! empty($this->_Primary_Datetime)) {
215 215
             return $this->_Primary_Datetime;
216 216
         }
217 217
         $this->_Primary_Datetime = EEM_Datetime::instance($this->_timezone)->get_primary_datetime_for_event(
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
     {
235 235
         // first get all datetimes
236 236
         $datetimes = $this->datetimes_ordered();
237
-        if (! $datetimes) {
237
+        if ( ! $datetimes) {
238 238
             return array();
239 239
         }
240 240
         $datetime_ids = array();
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
     public function short_description($num_words = 55, $more = null, $not_full_desc = false)
428 428
     {
429 429
         $short_desc = $this->get('EVT_short_desc');
430
-        if (! empty($short_desc) || $not_full_desc) {
430
+        if ( ! empty($short_desc) || $not_full_desc) {
431 431
             return $short_desc;
432 432
         }
433 433
         $full_desc = $this->get('EVT_desc');
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
         );
882 882
         $all_expired = true;
883 883
         foreach ($tickets as $ticket) {
884
-            if (! $ticket->is_expired()) {
884
+            if ( ! $ticket->is_expired()) {
885 885
                 $all_expired = false;
886 886
                 break;
887 887
             }
@@ -970,7 +970,7 @@  discard block
 block discarded – undo
970 970
      */
971 971
     public function is_sold_out($actual = false)
972 972
     {
973
-        if (! $actual) {
973
+        if ( ! $actual) {
974 974
             return $this->status() === EEM_Event::sold_out;
975 975
         }
976 976
         return $this->perform_sold_out_status_check();
@@ -1015,11 +1015,11 @@  discard block
 block discarded – undo
1015 1015
     public function get_active_status($reset = false)
1016 1016
     {
1017 1017
         // if the active status has already been set, then just use that value (unless we are resetting it)
1018
-        if (! empty($this->_active_status) && ! $reset) {
1018
+        if ( ! empty($this->_active_status) && ! $reset) {
1019 1019
             return $this->_active_status;
1020 1020
         }
1021 1021
         // first check if event id is present on this object
1022
-        if (! $this->ID()) {
1022
+        if ( ! $this->ID()) {
1023 1023
             return false;
1024 1024
         }
1025 1025
         $where_params_for_event = array(array('EVT_ID' => $this->ID()));
@@ -1104,7 +1104,7 @@  discard block
 block discarded – undo
1104 1104
     public function get_number_of_tickets_sold()
1105 1105
     {
1106 1106
         $tkt_sold = 0;
1107
-        if (! $this->ID()) {
1107
+        if ( ! $this->ID()) {
1108 1108
             return 0;
1109 1109
         }
1110 1110
         $datetimes = $this->datetimes();
Please login to merge, or discard this patch.
core/libraries/batch/JobHandlers/RegistrationsReport.php 1 patch
Indentation   +501 added lines, -501 removed lines patch added patch discarded remove patch
@@ -19,521 +19,521 @@
 block discarded – undo
19 19
  */
20 20
 class RegistrationsReport extends JobHandlerFile
21 21
 {
22
-    // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
23
-    // phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
24
-    /**
25
-     * Performs any necessary setup for starting the job. This is also a good
26
-     * place to setup the $job_arguments which will be used for subsequent HTTP requests
27
-     * when continue_job will be called
28
-     *
29
-     * @param JobParameters $job_parameters
30
-     * @throws BatchRequestException
31
-     * @return JobStepResponse
32
-     */
33
-    public function create_job(JobParameters $job_parameters)
34
-    {
35
-        $event_id = intval($job_parameters->request_datum('EVT_ID', '0'));
36
-        if (! \EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) {
37
-            throw new BatchRequestException(__('You do not have permission to view registrations', 'event_espresso'));
38
-        }
39
-        $filepath = $this->create_file_from_job_with_name(
40
-            $job_parameters->job_id(),
41
-            $this->get_filename($event_id)
42
-        );
43
-        $job_parameters->add_extra_data('filepath', $filepath);
44
-        if ($job_parameters->request_datum('use_filters', false)) {
45
-            $query_params = maybe_unserialize(stripslashes($job_parameters->request_datum('filters', array())));
46
-        } else {
47
-            $query_params = apply_filters('FHEE__EE_Export__report_registration_for_event', array(
48
-                array(
49
-                    'OR'                 => array(
50
-                        // don't include registrations from failed or abandoned transactions...
51
-                        'Transaction.STS_ID' => array(
52
-                            'NOT IN',
53
-                            array(
54
-                                \EEM_Transaction::failed_status_code,
55
-                                \EEM_Transaction::abandoned_status_code,
56
-                            ),
57
-                        ),
58
-                        // unless the registration is approved, in which case include it regardless of transaction status
59
-                        'STS_ID'             => \EEM_Registration::status_id_approved,
60
-                    ),
61
-                    'Ticket.TKT_deleted' => array('IN', array(true, false)),
62
-                ),
63
-                'order_by'   => array('Transaction.TXN_ID' => 'asc', 'REG_count' => 'asc'),
64
-                'force_join' => array('Transaction', 'Ticket', 'Attendee'),
65
-                'caps'       => \EEM_Base::caps_read_admin,
66
-            ), $event_id);
67
-            if ($event_id) {
68
-                $query_params[0]['EVT_ID'] = $event_id;
69
-            } else {
70
-                $query_params['force_join'][] = 'Event';
71
-            }
72
-        }
73
-        if (! isset($query_params['force_join'])) {
74
-            $query_params['force_join'] = array('Event', 'Transaction', 'Ticket', 'Attendee');
75
-        }
76
-        $job_parameters->add_extra_data('query_params', $query_params);
77
-        $question_labels = $this->_get_question_labels($query_params);
78
-        $job_parameters->add_extra_data('question_labels', $question_labels);
79
-        $job_parameters->set_job_size(
80
-            \EEM_Registration::instance()->count(
81
-                array_diff_key(
82
-                    $query_params,
83
-                    array_flip(
84
-                        array('limit')
85
-                    )
86
-                )
87
-            )
88
-        );
89
-        // we should also set the header columns
90
-        $csv_data_for_row = $this->get_csv_data_for(
91
-            $event_id,
92
-            0,
93
-            1,
94
-            $job_parameters->extra_datum('question_labels'),
95
-            $job_parameters->extra_datum('query_params')
96
-        );
97
-        \EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true);
98
-        // if we actually processed a row there, record it
99
-        if ($job_parameters->job_size()) {
100
-            $job_parameters->mark_processed(1);
101
-        }
102
-        return new JobStepResponse(
103
-            $job_parameters,
104
-            __('Registrations report started successfully...', 'event_espresso')
105
-        );
106
-    }
22
+	// phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
23
+	// phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
24
+	/**
25
+	 * Performs any necessary setup for starting the job. This is also a good
26
+	 * place to setup the $job_arguments which will be used for subsequent HTTP requests
27
+	 * when continue_job will be called
28
+	 *
29
+	 * @param JobParameters $job_parameters
30
+	 * @throws BatchRequestException
31
+	 * @return JobStepResponse
32
+	 */
33
+	public function create_job(JobParameters $job_parameters)
34
+	{
35
+		$event_id = intval($job_parameters->request_datum('EVT_ID', '0'));
36
+		if (! \EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) {
37
+			throw new BatchRequestException(__('You do not have permission to view registrations', 'event_espresso'));
38
+		}
39
+		$filepath = $this->create_file_from_job_with_name(
40
+			$job_parameters->job_id(),
41
+			$this->get_filename($event_id)
42
+		);
43
+		$job_parameters->add_extra_data('filepath', $filepath);
44
+		if ($job_parameters->request_datum('use_filters', false)) {
45
+			$query_params = maybe_unserialize(stripslashes($job_parameters->request_datum('filters', array())));
46
+		} else {
47
+			$query_params = apply_filters('FHEE__EE_Export__report_registration_for_event', array(
48
+				array(
49
+					'OR'                 => array(
50
+						// don't include registrations from failed or abandoned transactions...
51
+						'Transaction.STS_ID' => array(
52
+							'NOT IN',
53
+							array(
54
+								\EEM_Transaction::failed_status_code,
55
+								\EEM_Transaction::abandoned_status_code,
56
+							),
57
+						),
58
+						// unless the registration is approved, in which case include it regardless of transaction status
59
+						'STS_ID'             => \EEM_Registration::status_id_approved,
60
+					),
61
+					'Ticket.TKT_deleted' => array('IN', array(true, false)),
62
+				),
63
+				'order_by'   => array('Transaction.TXN_ID' => 'asc', 'REG_count' => 'asc'),
64
+				'force_join' => array('Transaction', 'Ticket', 'Attendee'),
65
+				'caps'       => \EEM_Base::caps_read_admin,
66
+			), $event_id);
67
+			if ($event_id) {
68
+				$query_params[0]['EVT_ID'] = $event_id;
69
+			} else {
70
+				$query_params['force_join'][] = 'Event';
71
+			}
72
+		}
73
+		if (! isset($query_params['force_join'])) {
74
+			$query_params['force_join'] = array('Event', 'Transaction', 'Ticket', 'Attendee');
75
+		}
76
+		$job_parameters->add_extra_data('query_params', $query_params);
77
+		$question_labels = $this->_get_question_labels($query_params);
78
+		$job_parameters->add_extra_data('question_labels', $question_labels);
79
+		$job_parameters->set_job_size(
80
+			\EEM_Registration::instance()->count(
81
+				array_diff_key(
82
+					$query_params,
83
+					array_flip(
84
+						array('limit')
85
+					)
86
+				)
87
+			)
88
+		);
89
+		// we should also set the header columns
90
+		$csv_data_for_row = $this->get_csv_data_for(
91
+			$event_id,
92
+			0,
93
+			1,
94
+			$job_parameters->extra_datum('question_labels'),
95
+			$job_parameters->extra_datum('query_params')
96
+		);
97
+		\EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true);
98
+		// if we actually processed a row there, record it
99
+		if ($job_parameters->job_size()) {
100
+			$job_parameters->mark_processed(1);
101
+		}
102
+		return new JobStepResponse(
103
+			$job_parameters,
104
+			__('Registrations report started successfully...', 'event_espresso')
105
+		);
106
+	}
107 107
 
108 108
 
109
-    /**
110
-     * Gets the filename
111
-     *
112
-     * @return string
113
-     */
114
-    protected function get_filename()
115
-    {
116
-        return sprintf("event-espresso-registrations-%s.csv", str_replace(':', '-', current_time('mysql')));
117
-    }
109
+	/**
110
+	 * Gets the filename
111
+	 *
112
+	 * @return string
113
+	 */
114
+	protected function get_filename()
115
+	{
116
+		return sprintf("event-espresso-registrations-%s.csv", str_replace(':', '-', current_time('mysql')));
117
+	}
118 118
 
119 119
 
120
-    /**
121
-     * Gets the questions which are to be used for this report, so they
122
-     * can be remembered for later
123
-     *
124
-     * @param array $registration_query_params
125
-     * @return array question admin labels to be used for this report
126
-     */
127
-    protected function _get_question_labels($registration_query_params)
128
-    {
129
-        $where = isset($registration_query_params[0]) ? $registration_query_params[0] : null;
130
-        $question_query_params = array();
131
-        if ($where !== null) {
132
-            $question_query_params = array(
133
-                $this->_change_registration_where_params_to_question_where_params($registration_query_params[0]),
134
-            );
135
-        }
136
-        $question_query_params[0]['QST_system'] = array(
137
-            'NOT_IN',
138
-            array_keys(\EEM_Attendee::instance()->system_question_to_attendee_field_mapping()),
139
-        );
140
-        if (apply_filters(
141
-            'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport___get_question_labels__only_include_answered_questions',
142
-            false,
143
-            $registration_query_params
144
-        )) {
145
-            $question_query_params[0]['Answer.ANS_ID'] = array('IS_NOT_NULL');
146
-        }
147
-        $question_query_params['group_by'] = array('QST_ID');
148
-        return array_unique(\EEM_Question::instance()->get_col($question_query_params, 'QST_admin_label'));
149
-    }
120
+	/**
121
+	 * Gets the questions which are to be used for this report, so they
122
+	 * can be remembered for later
123
+	 *
124
+	 * @param array $registration_query_params
125
+	 * @return array question admin labels to be used for this report
126
+	 */
127
+	protected function _get_question_labels($registration_query_params)
128
+	{
129
+		$where = isset($registration_query_params[0]) ? $registration_query_params[0] : null;
130
+		$question_query_params = array();
131
+		if ($where !== null) {
132
+			$question_query_params = array(
133
+				$this->_change_registration_where_params_to_question_where_params($registration_query_params[0]),
134
+			);
135
+		}
136
+		$question_query_params[0]['QST_system'] = array(
137
+			'NOT_IN',
138
+			array_keys(\EEM_Attendee::instance()->system_question_to_attendee_field_mapping()),
139
+		);
140
+		if (apply_filters(
141
+			'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport___get_question_labels__only_include_answered_questions',
142
+			false,
143
+			$registration_query_params
144
+		)) {
145
+			$question_query_params[0]['Answer.ANS_ID'] = array('IS_NOT_NULL');
146
+		}
147
+		$question_query_params['group_by'] = array('QST_ID');
148
+		return array_unique(\EEM_Question::instance()->get_col($question_query_params, 'QST_admin_label'));
149
+	}
150 150
 
151 151
 
152
-    /**
153
-     * Takes where params meant for registrations and changes them to work for questions
154
-     *
155
-     * @param array $reg_where_params
156
-     * @return array
157
-     */
158
-    protected function _change_registration_where_params_to_question_where_params($reg_where_params)
159
-    {
160
-        $question_where_params = array();
161
-        foreach ($reg_where_params as $key => $val) {
162
-            if (\EEM_Registration::instance()->is_logic_query_param_key($key)) {
163
-                $question_where_params[ $key ] = $this->_change_registration_where_params_to_question_where_params($val);
164
-            } else {
165
-                // it's a normal where condition
166
-                $question_where_params[ 'Question_Group.Event.Registration.' . $key ] = $val;
167
-            }
168
-        }
169
-        return $question_where_params;
170
-    }
152
+	/**
153
+	 * Takes where params meant for registrations and changes them to work for questions
154
+	 *
155
+	 * @param array $reg_where_params
156
+	 * @return array
157
+	 */
158
+	protected function _change_registration_where_params_to_question_where_params($reg_where_params)
159
+	{
160
+		$question_where_params = array();
161
+		foreach ($reg_where_params as $key => $val) {
162
+			if (\EEM_Registration::instance()->is_logic_query_param_key($key)) {
163
+				$question_where_params[ $key ] = $this->_change_registration_where_params_to_question_where_params($val);
164
+			} else {
165
+				// it's a normal where condition
166
+				$question_where_params[ 'Question_Group.Event.Registration.' . $key ] = $val;
167
+			}
168
+		}
169
+		return $question_where_params;
170
+	}
171 171
 
172 172
 
173
-    /**
174
-     * Performs another step of the job
175
-     *
176
-     * @param JobParameters $job_parameters
177
-     * @param int           $batch_size
178
-     * @return JobStepResponse
179
-     * @throws \EE_Error
180
-     */
181
-    public function continue_job(JobParameters $job_parameters, $batch_size = 50)
182
-    {
183
-        if ($job_parameters->units_processed() < $job_parameters->job_size()) {
184
-            $csv_data = $this->get_csv_data_for(
185
-                $job_parameters->request_datum('EVT_ID', '0'),
186
-                $job_parameters->units_processed(),
187
-                $batch_size,
188
-                $job_parameters->extra_datum('question_labels'),
189
-                $job_parameters->extra_datum('query_params')
190
-            );
191
-            \EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false);
192
-            $units_processed = count($csv_data);
193
-        } else {
194
-            $csv_data = array();
195
-            $units_processed = 0;
196
-        }
197
-        $job_parameters->mark_processed($units_processed);
198
-        $extra_response_data = array(
199
-            'file_url' => '',
200
-        );
201
-        if ($units_processed < $batch_size) {
202
-            $job_parameters->set_status(JobParameters::status_complete);
203
-            $extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath'));
204
-        }
173
+	/**
174
+	 * Performs another step of the job
175
+	 *
176
+	 * @param JobParameters $job_parameters
177
+	 * @param int           $batch_size
178
+	 * @return JobStepResponse
179
+	 * @throws \EE_Error
180
+	 */
181
+	public function continue_job(JobParameters $job_parameters, $batch_size = 50)
182
+	{
183
+		if ($job_parameters->units_processed() < $job_parameters->job_size()) {
184
+			$csv_data = $this->get_csv_data_for(
185
+				$job_parameters->request_datum('EVT_ID', '0'),
186
+				$job_parameters->units_processed(),
187
+				$batch_size,
188
+				$job_parameters->extra_datum('question_labels'),
189
+				$job_parameters->extra_datum('query_params')
190
+			);
191
+			\EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false);
192
+			$units_processed = count($csv_data);
193
+		} else {
194
+			$csv_data = array();
195
+			$units_processed = 0;
196
+		}
197
+		$job_parameters->mark_processed($units_processed);
198
+		$extra_response_data = array(
199
+			'file_url' => '',
200
+		);
201
+		if ($units_processed < $batch_size) {
202
+			$job_parameters->set_status(JobParameters::status_complete);
203
+			$extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath'));
204
+		}
205 205
 
206
-        return new JobStepResponse(
207
-            $job_parameters,
208
-            sprintf(__('Wrote %1$s rows to report CSV file...', 'event_espresso'), count((array) $csv_data)),
209
-            $extra_response_data
210
-        );
211
-    }
206
+		return new JobStepResponse(
207
+			$job_parameters,
208
+			sprintf(__('Wrote %1$s rows to report CSV file...', 'event_espresso'), count((array) $csv_data)),
209
+			$extra_response_data
210
+		);
211
+	}
212 212
 
213 213
 
214
-    /**
215
-     * Gets the csv data for a batch of registrations
216
-     *
217
-     * @param int|null $event_id
218
-     * @param int      $offset
219
-     * @param int      $limit
220
-     * @param array    $question_labels the IDs for all the questions which were answered by someone in this selection
221
-     * @param array    $query_params    for using where querying the model
222
-     * @return array top-level keys are numeric, next-level keys are column headers
223
-     */
224
-    public function get_csv_data_for($event_id, $offset, $limit, $question_labels, $query_params)
225
-    {
226
-        $reg_fields_to_include = array(
227
-            'TXN_ID',
228
-            'ATT_ID',
229
-            'REG_ID',
230
-            'REG_date',
231
-            'REG_code',
232
-            'REG_count',
233
-            'REG_final_price',
234
-        );
235
-        $att_fields_to_include = array(
236
-            'ATT_fname',
237
-            'ATT_lname',
238
-            'ATT_email',
239
-            'ATT_address',
240
-            'ATT_address2',
241
-            'ATT_city',
242
-            'STA_ID',
243
-            'CNT_ISO',
244
-            'ATT_zip',
245
-            'ATT_phone',
246
-        );
247
-        $registrations_csv_ready_array = array();
248
-        $reg_model = \EE_Registry::instance()->load_model('Registration');
249
-        $query_params['limit'] = array($offset, $limit);
250
-        $registration_rows = $reg_model->get_all_wpdb_results($query_params);
251
-        $registration_ids = array();
252
-        foreach ($registration_rows as $reg_row) {
253
-            $registration_ids[] = intval($reg_row['Registration.REG_ID']);
254
-        }
255
-        foreach ($registration_rows as $reg_row) {
256
-            if (is_array($reg_row)) {
257
-                $reg_csv_array = array();
258
-                if (! $event_id) {
259
-                    // get the event's name and Id
260
-                    $reg_csv_array[ __('Event', 'event_espresso') ] = sprintf(
261
-                        __('%1$s (%2$s)', 'event_espresso'),
262
-                        \EEH_Export::prepare_value_from_db_for_display(
263
-                            \EEM_Event::instance(),
264
-                            'EVT_name',
265
-                            $reg_row['Event_CPT.post_title']
266
-                        ),
267
-                        $reg_row['Event_CPT.ID']
268
-                    );
269
-                }
270
-                $is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false;
271
-                /*@var $reg_row EE_Registration */
272
-                foreach ($reg_fields_to_include as $field_name) {
273
-                    $field = $reg_model->field_settings_for($field_name);
274
-                    if ($field_name == 'REG_final_price') {
275
-                        $value = \EEH_Export::prepare_value_from_db_for_display(
276
-                            $reg_model,
277
-                            $field_name,
278
-                            $reg_row['Registration.REG_final_price'],
279
-                            'localized_float'
280
-                        );
281
-                    } elseif ($field_name == 'REG_count') {
282
-                        $value = sprintf(
283
-                            __('%1$s of %2$s', 'event_espresso'),
284
-                            \EEH_Export::prepare_value_from_db_for_display(
285
-                                $reg_model,
286
-                                'REG_count',
287
-                                $reg_row['Registration.REG_count']
288
-                            ),
289
-                            \EEH_Export::prepare_value_from_db_for_display(
290
-                                $reg_model,
291
-                                'REG_group_size',
292
-                                $reg_row['Registration.REG_group_size']
293
-                            )
294
-                        );
295
-                    } elseif ($field_name == 'REG_date') {
296
-                        $value = \EEH_Export::prepare_value_from_db_for_display(
297
-                            $reg_model,
298
-                            $field_name,
299
-                            $reg_row['Registration.REG_date'],
300
-                            'no_html'
301
-                        );
302
-                    } else {
303
-                        $value = \EEH_Export::prepare_value_from_db_for_display(
304
-                            $reg_model,
305
-                            $field_name,
306
-                            $reg_row[ $field->get_qualified_column() ]
307
-                        );
308
-                    }
309
-                    $reg_csv_array[ \EEH_Export::get_column_name_for_field($field) ] = $value;
310
-                    if ($field_name == 'REG_final_price') {
311
-                        // add a column named Currency after the final price
312
-                        $reg_csv_array[ __("Currency", "event_espresso") ] = \EE_Config::instance()->currency->code;
313
-                    }
314
-                }
315
-                // get pretty status
316
-                $stati = \EEM_Status::instance()->localized_status(
317
-                    array(
318
-                        $reg_row['Registration.STS_ID']     => __('unknown', 'event_espresso'),
319
-                        $reg_row['TransactionTable.STS_ID'] => __('unknown', 'event_espresso'),
320
-                    ),
321
-                    false,
322
-                    'sentence'
323
-                );
324
-                $reg_csv_array[ __("Registration Status", 'event_espresso') ] = $stati[ $reg_row['Registration.STS_ID'] ];
325
-                // get pretty transaction status
326
-                $reg_csv_array[ __("Transaction Status", 'event_espresso') ] = $stati[ $reg_row['TransactionTable.STS_ID'] ];
327
-                $reg_csv_array[ __('Transaction Amount Due', 'event_espresso') ] = $is_primary_reg
328
-                    ? \EEH_Export::prepare_value_from_db_for_display(
329
-                        \EEM_Transaction::instance(),
330
-                        'TXN_total',
331
-                        $reg_row['TransactionTable.TXN_total'],
332
-                        'localized_float'
333
-                    ) : '0.00';
334
-                $reg_csv_array[ __('Amount Paid', 'event_espresso') ] = $is_primary_reg
335
-                    ? \EEH_Export::prepare_value_from_db_for_display(
336
-                        \EEM_Transaction::instance(),
337
-                        'TXN_paid',
338
-                        $reg_row['TransactionTable.TXN_paid'],
339
-                        'localized_float'
340
-                    ) : '0.00';
341
-                $payment_methods = array();
342
-                $gateway_txn_ids_etc = array();
343
-                $payment_times = array();
344
-                if ($is_primary_reg && $reg_row['TransactionTable.TXN_ID']) {
345
-                    $payments_info = \EEM_Payment::instance()->get_all_wpdb_results(
346
-                        array(
347
-                            array(
348
-                                'TXN_ID' => $reg_row['TransactionTable.TXN_ID'],
349
-                                'STS_ID' => \EEM_Payment::status_id_approved,
350
-                            ),
351
-                            'force_join' => array('Payment_Method'),
352
-                        ),
353
-                        ARRAY_A,
354
-                        'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time'
355
-                    );
356
-                    foreach ($payments_info as $payment_method_and_gateway_txn_id) {
357
-                        $payment_methods[] = isset($payment_method_and_gateway_txn_id['name'])
358
-                            ? $payment_method_and_gateway_txn_id['name'] : __('Unknown', 'event_espresso');
359
-                        $gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id'])
360
-                            ? $payment_method_and_gateway_txn_id['gateway_txn_id'] : '';
361
-                        $payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time'])
362
-                            ? $payment_method_and_gateway_txn_id['payment_time'] : '';
363
-                    }
364
-                }
365
-                $reg_csv_array[ __('Payment Date(s)', 'event_espresso') ] = implode(',', $payment_times);
366
-                $reg_csv_array[ __('Payment Method(s)', 'event_espresso') ] = implode(",", $payment_methods);
367
-                $reg_csv_array[ __('Gateway Transaction ID(s)', 'event_espresso') ] = implode(
368
-                    ',',
369
-                    $gateway_txn_ids_etc
370
-                );
371
-                // get whether or not the user has checked in
372
-                $reg_csv_array[ __("Check-Ins", "event_espresso") ] = $reg_model->count_related(
373
-                    $reg_row['Registration.REG_ID'],
374
-                    'Checkin'
375
-                );
376
-                // get ticket of registration and its price
377
-                $ticket_model = \EE_Registry::instance()->load_model('Ticket');
378
-                if ($reg_row['Ticket.TKT_ID']) {
379
-                    $ticket_name = \EEH_Export::prepare_value_from_db_for_display(
380
-                        $ticket_model,
381
-                        'TKT_name',
382
-                        $reg_row['Ticket.TKT_name']
383
-                    );
384
-                    $datetimes_strings = array();
385
-                    foreach (\EEM_Datetime::instance()->get_all_wpdb_results(
386
-                        array(
387
-                            array('Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']),
388
-                            'order_by'                 => array('DTT_EVT_start' => 'ASC'),
389
-                            'default_where_conditions' => 'none',
390
-                        )
391
-                    ) as $datetime) {
392
-                        $datetimes_strings[] = \EEH_Export::prepare_value_from_db_for_display(
393
-                            \EEM_Datetime::instance(),
394
-                            'DTT_EVT_start',
395
-                            $datetime['Datetime.DTT_EVT_start']
396
-                        );
397
-                    }
398
-                } else {
399
-                    $ticket_name = __('Unknown', 'event_espresso');
400
-                    $datetimes_strings = array(__('Unknown', 'event_espresso'));
401
-                }
402
-                $reg_csv_array[ $ticket_model->field_settings_for('TKT_name')->get_nicename() ] = $ticket_name;
403
-                $reg_csv_array[ __("Datetimes of Ticket", "event_espresso") ] = implode(", ", $datetimes_strings);
404
-                // get datetime(s) of registration
405
-                // add attendee columns
406
-                foreach ($att_fields_to_include as $att_field_name) {
407
-                    $field_obj = \EEM_Attendee::instance()->field_settings_for($att_field_name);
408
-                    if ($reg_row['Attendee_CPT.ID']) {
409
-                        if ($att_field_name == 'STA_ID') {
410
-                            $value = \EEM_State::instance()->get_var(
411
-                                array(array('STA_ID' => $reg_row['Attendee_Meta.STA_ID'])),
412
-                                'STA_name'
413
-                            );
414
-                        } elseif ($att_field_name == 'CNT_ISO') {
415
-                            $value = \EEM_Country::instance()->get_var(
416
-                                array(array('CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO'])),
417
-                                'CNT_name'
418
-                            );
419
-                        } else {
420
-                            $value = \EEH_Export::prepare_value_from_db_for_display(
421
-                                \EEM_Attendee::instance(),
422
-                                $att_field_name,
423
-                                $reg_row[ $field_obj->get_qualified_column() ]
424
-                            );
425
-                        }
426
-                    } else {
427
-                        $value = '';
428
-                    }
429
-                    $reg_csv_array[ \EEH_Export::get_column_name_for_field($field_obj) ] = $value;
430
-                }
431
-                // make sure each registration has the same questions in the same order
432
-                foreach ($question_labels as $question_label) {
433
-                    if (! isset($reg_csv_array[ $question_label ])) {
434
-                        $reg_csv_array[ $question_label ] = null;
435
-                    }
436
-                }
437
-                $answers = \EEM_Answer::instance()->get_all_wpdb_results(array(
438
-                    array('REG_ID' => $reg_row['Registration.REG_ID']),
439
-                    'force_join' => array('Question'),
440
-                ));
441
-                // now fill out the questions THEY answered
442
-                foreach ($answers as $answer_row) {
443
-                    if ($answer_row['Question.QST_ID']) {
444
-                        $question_label = \EEH_Export::prepare_value_from_db_for_display(
445
-                            \EEM_Question::instance(),
446
-                            'QST_admin_label',
447
-                            $answer_row['Question.QST_admin_label']
448
-                        );
449
-                    } else {
450
-                        $question_label = sprintf(__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']);
451
-                    }
452
-                    if (isset($answer_row['Question.QST_type'])
453
-                        && $answer_row['Question.QST_type'] == \EEM_Question::QST_type_state
454
-                    ) {
455
-                        $reg_csv_array[ $question_label ] = \EEM_State::instance()->get_state_name_by_ID(
456
-                            $answer_row['Answer.ANS_value']
457
-                        );
458
-                    } else {
459
-                        // this isn't for html, so don't show html entities
460
-                        $reg_csv_array[ $question_label ] = html_entity_decode(
461
-                            \EEH_Export::prepare_value_from_db_for_display(
462
-                                \EEM_Answer::instance(),
463
-                                'ANS_value',
464
-                                $answer_row['Answer.ANS_value']
465
-                            )
466
-                        );
467
-                    }
468
-                }
214
+	/**
215
+	 * Gets the csv data for a batch of registrations
216
+	 *
217
+	 * @param int|null $event_id
218
+	 * @param int      $offset
219
+	 * @param int      $limit
220
+	 * @param array    $question_labels the IDs for all the questions which were answered by someone in this selection
221
+	 * @param array    $query_params    for using where querying the model
222
+	 * @return array top-level keys are numeric, next-level keys are column headers
223
+	 */
224
+	public function get_csv_data_for($event_id, $offset, $limit, $question_labels, $query_params)
225
+	{
226
+		$reg_fields_to_include = array(
227
+			'TXN_ID',
228
+			'ATT_ID',
229
+			'REG_ID',
230
+			'REG_date',
231
+			'REG_code',
232
+			'REG_count',
233
+			'REG_final_price',
234
+		);
235
+		$att_fields_to_include = array(
236
+			'ATT_fname',
237
+			'ATT_lname',
238
+			'ATT_email',
239
+			'ATT_address',
240
+			'ATT_address2',
241
+			'ATT_city',
242
+			'STA_ID',
243
+			'CNT_ISO',
244
+			'ATT_zip',
245
+			'ATT_phone',
246
+		);
247
+		$registrations_csv_ready_array = array();
248
+		$reg_model = \EE_Registry::instance()->load_model('Registration');
249
+		$query_params['limit'] = array($offset, $limit);
250
+		$registration_rows = $reg_model->get_all_wpdb_results($query_params);
251
+		$registration_ids = array();
252
+		foreach ($registration_rows as $reg_row) {
253
+			$registration_ids[] = intval($reg_row['Registration.REG_ID']);
254
+		}
255
+		foreach ($registration_rows as $reg_row) {
256
+			if (is_array($reg_row)) {
257
+				$reg_csv_array = array();
258
+				if (! $event_id) {
259
+					// get the event's name and Id
260
+					$reg_csv_array[ __('Event', 'event_espresso') ] = sprintf(
261
+						__('%1$s (%2$s)', 'event_espresso'),
262
+						\EEH_Export::prepare_value_from_db_for_display(
263
+							\EEM_Event::instance(),
264
+							'EVT_name',
265
+							$reg_row['Event_CPT.post_title']
266
+						),
267
+						$reg_row['Event_CPT.ID']
268
+					);
269
+				}
270
+				$is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false;
271
+				/*@var $reg_row EE_Registration */
272
+				foreach ($reg_fields_to_include as $field_name) {
273
+					$field = $reg_model->field_settings_for($field_name);
274
+					if ($field_name == 'REG_final_price') {
275
+						$value = \EEH_Export::prepare_value_from_db_for_display(
276
+							$reg_model,
277
+							$field_name,
278
+							$reg_row['Registration.REG_final_price'],
279
+							'localized_float'
280
+						);
281
+					} elseif ($field_name == 'REG_count') {
282
+						$value = sprintf(
283
+							__('%1$s of %2$s', 'event_espresso'),
284
+							\EEH_Export::prepare_value_from_db_for_display(
285
+								$reg_model,
286
+								'REG_count',
287
+								$reg_row['Registration.REG_count']
288
+							),
289
+							\EEH_Export::prepare_value_from_db_for_display(
290
+								$reg_model,
291
+								'REG_group_size',
292
+								$reg_row['Registration.REG_group_size']
293
+							)
294
+						);
295
+					} elseif ($field_name == 'REG_date') {
296
+						$value = \EEH_Export::prepare_value_from_db_for_display(
297
+							$reg_model,
298
+							$field_name,
299
+							$reg_row['Registration.REG_date'],
300
+							'no_html'
301
+						);
302
+					} else {
303
+						$value = \EEH_Export::prepare_value_from_db_for_display(
304
+							$reg_model,
305
+							$field_name,
306
+							$reg_row[ $field->get_qualified_column() ]
307
+						);
308
+					}
309
+					$reg_csv_array[ \EEH_Export::get_column_name_for_field($field) ] = $value;
310
+					if ($field_name == 'REG_final_price') {
311
+						// add a column named Currency after the final price
312
+						$reg_csv_array[ __("Currency", "event_espresso") ] = \EE_Config::instance()->currency->code;
313
+					}
314
+				}
315
+				// get pretty status
316
+				$stati = \EEM_Status::instance()->localized_status(
317
+					array(
318
+						$reg_row['Registration.STS_ID']     => __('unknown', 'event_espresso'),
319
+						$reg_row['TransactionTable.STS_ID'] => __('unknown', 'event_espresso'),
320
+					),
321
+					false,
322
+					'sentence'
323
+				);
324
+				$reg_csv_array[ __("Registration Status", 'event_espresso') ] = $stati[ $reg_row['Registration.STS_ID'] ];
325
+				// get pretty transaction status
326
+				$reg_csv_array[ __("Transaction Status", 'event_espresso') ] = $stati[ $reg_row['TransactionTable.STS_ID'] ];
327
+				$reg_csv_array[ __('Transaction Amount Due', 'event_espresso') ] = $is_primary_reg
328
+					? \EEH_Export::prepare_value_from_db_for_display(
329
+						\EEM_Transaction::instance(),
330
+						'TXN_total',
331
+						$reg_row['TransactionTable.TXN_total'],
332
+						'localized_float'
333
+					) : '0.00';
334
+				$reg_csv_array[ __('Amount Paid', 'event_espresso') ] = $is_primary_reg
335
+					? \EEH_Export::prepare_value_from_db_for_display(
336
+						\EEM_Transaction::instance(),
337
+						'TXN_paid',
338
+						$reg_row['TransactionTable.TXN_paid'],
339
+						'localized_float'
340
+					) : '0.00';
341
+				$payment_methods = array();
342
+				$gateway_txn_ids_etc = array();
343
+				$payment_times = array();
344
+				if ($is_primary_reg && $reg_row['TransactionTable.TXN_ID']) {
345
+					$payments_info = \EEM_Payment::instance()->get_all_wpdb_results(
346
+						array(
347
+							array(
348
+								'TXN_ID' => $reg_row['TransactionTable.TXN_ID'],
349
+								'STS_ID' => \EEM_Payment::status_id_approved,
350
+							),
351
+							'force_join' => array('Payment_Method'),
352
+						),
353
+						ARRAY_A,
354
+						'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time'
355
+					);
356
+					foreach ($payments_info as $payment_method_and_gateway_txn_id) {
357
+						$payment_methods[] = isset($payment_method_and_gateway_txn_id['name'])
358
+							? $payment_method_and_gateway_txn_id['name'] : __('Unknown', 'event_espresso');
359
+						$gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id'])
360
+							? $payment_method_and_gateway_txn_id['gateway_txn_id'] : '';
361
+						$payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time'])
362
+							? $payment_method_and_gateway_txn_id['payment_time'] : '';
363
+					}
364
+				}
365
+				$reg_csv_array[ __('Payment Date(s)', 'event_espresso') ] = implode(',', $payment_times);
366
+				$reg_csv_array[ __('Payment Method(s)', 'event_espresso') ] = implode(",", $payment_methods);
367
+				$reg_csv_array[ __('Gateway Transaction ID(s)', 'event_espresso') ] = implode(
368
+					',',
369
+					$gateway_txn_ids_etc
370
+				);
371
+				// get whether or not the user has checked in
372
+				$reg_csv_array[ __("Check-Ins", "event_espresso") ] = $reg_model->count_related(
373
+					$reg_row['Registration.REG_ID'],
374
+					'Checkin'
375
+				);
376
+				// get ticket of registration and its price
377
+				$ticket_model = \EE_Registry::instance()->load_model('Ticket');
378
+				if ($reg_row['Ticket.TKT_ID']) {
379
+					$ticket_name = \EEH_Export::prepare_value_from_db_for_display(
380
+						$ticket_model,
381
+						'TKT_name',
382
+						$reg_row['Ticket.TKT_name']
383
+					);
384
+					$datetimes_strings = array();
385
+					foreach (\EEM_Datetime::instance()->get_all_wpdb_results(
386
+						array(
387
+							array('Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']),
388
+							'order_by'                 => array('DTT_EVT_start' => 'ASC'),
389
+							'default_where_conditions' => 'none',
390
+						)
391
+					) as $datetime) {
392
+						$datetimes_strings[] = \EEH_Export::prepare_value_from_db_for_display(
393
+							\EEM_Datetime::instance(),
394
+							'DTT_EVT_start',
395
+							$datetime['Datetime.DTT_EVT_start']
396
+						);
397
+					}
398
+				} else {
399
+					$ticket_name = __('Unknown', 'event_espresso');
400
+					$datetimes_strings = array(__('Unknown', 'event_espresso'));
401
+				}
402
+				$reg_csv_array[ $ticket_model->field_settings_for('TKT_name')->get_nicename() ] = $ticket_name;
403
+				$reg_csv_array[ __("Datetimes of Ticket", "event_espresso") ] = implode(", ", $datetimes_strings);
404
+				// get datetime(s) of registration
405
+				// add attendee columns
406
+				foreach ($att_fields_to_include as $att_field_name) {
407
+					$field_obj = \EEM_Attendee::instance()->field_settings_for($att_field_name);
408
+					if ($reg_row['Attendee_CPT.ID']) {
409
+						if ($att_field_name == 'STA_ID') {
410
+							$value = \EEM_State::instance()->get_var(
411
+								array(array('STA_ID' => $reg_row['Attendee_Meta.STA_ID'])),
412
+								'STA_name'
413
+							);
414
+						} elseif ($att_field_name == 'CNT_ISO') {
415
+							$value = \EEM_Country::instance()->get_var(
416
+								array(array('CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO'])),
417
+								'CNT_name'
418
+							);
419
+						} else {
420
+							$value = \EEH_Export::prepare_value_from_db_for_display(
421
+								\EEM_Attendee::instance(),
422
+								$att_field_name,
423
+								$reg_row[ $field_obj->get_qualified_column() ]
424
+							);
425
+						}
426
+					} else {
427
+						$value = '';
428
+					}
429
+					$reg_csv_array[ \EEH_Export::get_column_name_for_field($field_obj) ] = $value;
430
+				}
431
+				// make sure each registration has the same questions in the same order
432
+				foreach ($question_labels as $question_label) {
433
+					if (! isset($reg_csv_array[ $question_label ])) {
434
+						$reg_csv_array[ $question_label ] = null;
435
+					}
436
+				}
437
+				$answers = \EEM_Answer::instance()->get_all_wpdb_results(array(
438
+					array('REG_ID' => $reg_row['Registration.REG_ID']),
439
+					'force_join' => array('Question'),
440
+				));
441
+				// now fill out the questions THEY answered
442
+				foreach ($answers as $answer_row) {
443
+					if ($answer_row['Question.QST_ID']) {
444
+						$question_label = \EEH_Export::prepare_value_from_db_for_display(
445
+							\EEM_Question::instance(),
446
+							'QST_admin_label',
447
+							$answer_row['Question.QST_admin_label']
448
+						);
449
+					} else {
450
+						$question_label = sprintf(__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']);
451
+					}
452
+					if (isset($answer_row['Question.QST_type'])
453
+						&& $answer_row['Question.QST_type'] == \EEM_Question::QST_type_state
454
+					) {
455
+						$reg_csv_array[ $question_label ] = \EEM_State::instance()->get_state_name_by_ID(
456
+							$answer_row['Answer.ANS_value']
457
+						);
458
+					} else {
459
+						// this isn't for html, so don't show html entities
460
+						$reg_csv_array[ $question_label ] = html_entity_decode(
461
+							\EEH_Export::prepare_value_from_db_for_display(
462
+								\EEM_Answer::instance(),
463
+								'ANS_value',
464
+								$answer_row['Answer.ANS_value']
465
+							)
466
+						);
467
+					}
468
+				}
469 469
 
470
-                /**
471
-                 * Filter to change the contents of each row of the registrations report CSV file.
472
-                 * This can be used to add or remote columns from the CSV file, or change their values.
473
-                 * Note when using: all rows in the CSV should have the same columns.
474
-                 * @param array $reg_csv_array keys are the column names, values are their cell values
475
-                 * @param array $reg_row one entry from EEM_Registration::get_all_wpdb_results()
476
-                 */
477
-                $registrations_csv_ready_array[] = apply_filters(
478
-                    'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array',
479
-                    $reg_csv_array,
480
-                    $reg_row
481
-                );
482
-            }
483
-        }
484
-        // if we couldn't export anything, we want to at least show the column headers
485
-        if (empty($registrations_csv_ready_array)) {
486
-            $reg_csv_array = array();
487
-            $model_and_fields_to_include = array(
488
-                'Registration' => $reg_fields_to_include,
489
-                'Attendee'     => $att_fields_to_include,
490
-            );
491
-            foreach ($model_and_fields_to_include as $model_name => $field_list) {
492
-                $model = \EE_Registry::instance()->load_model($model_name);
493
-                foreach ($field_list as $field_name) {
494
-                    $field = $model->field_settings_for($field_name);
495
-                    $reg_csv_array[ \EEH_Export::get_column_name_for_field($field) ] = null;
496
-                }
497
-            }
498
-            $registrations_csv_ready_array[] = $reg_csv_array;
499
-        }
500
-        return $registrations_csv_ready_array;
501
-    }
470
+				/**
471
+				 * Filter to change the contents of each row of the registrations report CSV file.
472
+				 * This can be used to add or remote columns from the CSV file, or change their values.
473
+				 * Note when using: all rows in the CSV should have the same columns.
474
+				 * @param array $reg_csv_array keys are the column names, values are their cell values
475
+				 * @param array $reg_row one entry from EEM_Registration::get_all_wpdb_results()
476
+				 */
477
+				$registrations_csv_ready_array[] = apply_filters(
478
+					'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array',
479
+					$reg_csv_array,
480
+					$reg_row
481
+				);
482
+			}
483
+		}
484
+		// if we couldn't export anything, we want to at least show the column headers
485
+		if (empty($registrations_csv_ready_array)) {
486
+			$reg_csv_array = array();
487
+			$model_and_fields_to_include = array(
488
+				'Registration' => $reg_fields_to_include,
489
+				'Attendee'     => $att_fields_to_include,
490
+			);
491
+			foreach ($model_and_fields_to_include as $model_name => $field_list) {
492
+				$model = \EE_Registry::instance()->load_model($model_name);
493
+				foreach ($field_list as $field_name) {
494
+					$field = $model->field_settings_for($field_name);
495
+					$reg_csv_array[ \EEH_Export::get_column_name_for_field($field) ] = null;
496
+				}
497
+			}
498
+			$registrations_csv_ready_array[] = $reg_csv_array;
499
+		}
500
+		return $registrations_csv_ready_array;
501
+	}
502 502
 
503 503
 
504
-    /**
505
-     * Counts total unit to process
506
-     *
507
-     * @deprecated since 4.9.19
508
-     * @param int|array $event_id
509
-     * @return int
510
-     */
511
-    public function count_units_to_process($event_id)
512
-    {
513
-        // use the legacy filter
514
-        if ($event_id) {
515
-            $query_params[0]['EVT_ID'] = $event_id;
516
-        } else {
517
-            $query_params['force_join'][] = 'Event';
518
-        }
519
-        return \EEM_Registration::instance()->count($query_params);
520
-    }
504
+	/**
505
+	 * Counts total unit to process
506
+	 *
507
+	 * @deprecated since 4.9.19
508
+	 * @param int|array $event_id
509
+	 * @return int
510
+	 */
511
+	public function count_units_to_process($event_id)
512
+	{
513
+		// use the legacy filter
514
+		if ($event_id) {
515
+			$query_params[0]['EVT_ID'] = $event_id;
516
+		} else {
517
+			$query_params['force_join'][] = 'Event';
518
+		}
519
+		return \EEM_Registration::instance()->count($query_params);
520
+	}
521 521
 
522 522
 
523
-    /**
524
-     * Performs any clean-up logic when we know the job is completed.
525
-     * In this case, we delete the temporary file
526
-     *
527
-     * @param JobParameters $job_parameters
528
-     * @return boolean
529
-     */
530
-    public function cleanup_job(JobParameters $job_parameters)
531
-    {
532
-        $this->_file_helper->delete(
533
-            \EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')),
534
-            true,
535
-            'd'
536
-        );
537
-        return new JobStepResponse($job_parameters, __('Cleaned up temporary file', 'event_espresso'));
538
-    }
523
+	/**
524
+	 * Performs any clean-up logic when we know the job is completed.
525
+	 * In this case, we delete the temporary file
526
+	 *
527
+	 * @param JobParameters $job_parameters
528
+	 * @return boolean
529
+	 */
530
+	public function cleanup_job(JobParameters $job_parameters)
531
+	{
532
+		$this->_file_helper->delete(
533
+			\EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')),
534
+			true,
535
+			'd'
536
+		);
537
+		return new JobStepResponse($job_parameters, __('Cleaned up temporary file', 'event_espresso'));
538
+	}
539 539
 }
Please login to merge, or discard this patch.
admin_pages/general_settings/General_Settings_Admin_Page.core.php 3 patches
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -289,12 +289,12 @@  discard block
 block discarded – undo
289 289
         wp_enqueue_script('thickbox');
290 290
         wp_register_script(
291 291
             'organization_settings',
292
-            GEN_SET_ASSETS_URL . 'your_organization_settings.js',
292
+            GEN_SET_ASSETS_URL.'your_organization_settings.js',
293 293
             array('jquery', 'media-upload', 'thickbox'),
294 294
             EVENT_ESPRESSO_VERSION,
295 295
             true
296 296
         );
297
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
297
+        wp_register_style('organization-css', GEN_SET_ASSETS_URL.'organization.css', array(), EVENT_ESPRESSO_VERSION);
298 298
         wp_enqueue_script('organization_settings');
299 299
         wp_enqueue_style('organization-css');
300 300
         $confirm_image_delete = array(
@@ -315,12 +315,12 @@  discard block
 block discarded – undo
315 315
         // scripts
316 316
         wp_register_script(
317 317
             'gen_settings_countries',
318
-            GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
318
+            GEN_SET_ASSETS_URL.'gen_settings_countries.js',
319 319
             array('ee_admin_js'),
320 320
             EVENT_ESPRESSO_VERSION,
321 321
             true
322 322
         );
323
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
323
+        wp_register_style('organization-css', GEN_SET_ASSETS_URL.'organization.css', array(), EVENT_ESPRESSO_VERSION);
324 324
         wp_enqueue_script('gen_settings_countries');
325 325
         wp_enqueue_style('organization-css');
326 326
     }
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
         $this->_set_add_edit_form_tags('update_espresso_page_settings');
371 371
         $this->_set_publish_post_box_vars(null, false, false, null, false);
372 372
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
373
-            GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
373
+            GEN_SET_TEMPLATE_PATH.'espresso_page_settings.template.php',
374 374
             $this->_template_args,
375 375
             true
376 376
         );
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
     {
535 535
         try {
536 536
             $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
537
-            $admin_options_settings_form->process($this->_req_data[ $admin_options_settings_form->slug() ]);
537
+            $admin_options_settings_form->process($this->_req_data[$admin_options_settings_form->slug()]);
538 538
             EE_Registry::instance()->CFG->admin = apply_filters(
539 539
                 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
540 540
                 EE_Registry::instance()->CFG->admin
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
         $this->_set_add_edit_form_tags('update_country_settings');
626 626
         $this->_set_publish_post_box_vars(null, false, false, null, false);
627 627
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
628
-            GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
628
+            GEN_SET_TEMPLATE_PATH.'countries_settings.template.php',
629 629
             $this->_template_args,
630 630
             true
631 631
         );
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
         $CNT_ISO = isset($this->_req_data['country'])
649 649
             ? strtoupper(sanitize_text_field($this->_req_data['country']))
650 650
             : $CNT_ISO;
651
-        if (! $CNT_ISO) {
651
+        if ( ! $CNT_ISO) {
652 652
             return '';
653 653
         }
654 654
 
@@ -666,59 +666,59 @@  discard block
 block discarded – undo
666 666
         $country_input_types = array(
667 667
             'CNT_active'      => array(
668 668
                 'type'             => 'RADIO_BTN',
669
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
669
+                'input_name'       => 'cntry['.$CNT_ISO.']',
670 670
                 'class'            => '',
671 671
                 'options'          => $this->_yes_no_values,
672 672
                 'use_desc_4_label' => true,
673 673
             ),
674 674
             'CNT_ISO'         => array(
675 675
                 'type'       => 'TEXT',
676
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
676
+                'input_name' => 'cntry['.$CNT_ISO.']',
677 677
                 'class'      => 'small-text',
678 678
             ),
679 679
             'CNT_ISO3'        => array(
680 680
                 'type'       => 'TEXT',
681
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
681
+                'input_name' => 'cntry['.$CNT_ISO.']',
682 682
                 'class'      => 'small-text',
683 683
             ),
684 684
             'RGN_ID'          => array(
685 685
                 'type'       => 'TEXT',
686
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
686
+                'input_name' => 'cntry['.$CNT_ISO.']',
687 687
                 'class'      => 'small-text',
688 688
             ),
689 689
             'CNT_name'        => array(
690 690
                 'type'       => 'TEXT',
691
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
691
+                'input_name' => 'cntry['.$CNT_ISO.']',
692 692
                 'class'      => 'regular-text',
693 693
             ),
694 694
             'CNT_cur_code'    => array(
695 695
                 'type'       => 'TEXT',
696
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
696
+                'input_name' => 'cntry['.$CNT_ISO.']',
697 697
                 'class'      => 'small-text',
698 698
                 'disabled'   => $CNT_cur_disabled
699 699
             ),
700 700
             'CNT_cur_single'  => array(
701 701
                 'type'       => 'TEXT',
702
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
702
+                'input_name' => 'cntry['.$CNT_ISO.']',
703 703
                 'class'      => 'medium-text',
704 704
                 'disabled' => $CNT_cur_disabled
705 705
             ),
706 706
             'CNT_cur_plural'  => array(
707 707
                 'type'       => 'TEXT',
708
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
708
+                'input_name' => 'cntry['.$CNT_ISO.']',
709 709
                 'class'      => 'medium-text',
710 710
                 'disabled' => $CNT_cur_disabled
711 711
             ),
712 712
             'CNT_cur_sign'    => array(
713 713
                 'type'         => 'TEXT',
714
-                'input_name'   => 'cntry[' . $CNT_ISO . ']',
714
+                'input_name'   => 'cntry['.$CNT_ISO.']',
715 715
                 'class'        => 'small-text',
716 716
                 'htmlentities' => false,
717 717
                 'disabled' => $CNT_cur_disabled
718 718
             ),
719 719
             'CNT_cur_sign_b4' => array(
720 720
                 'type'             => 'RADIO_BTN',
721
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
721
+                'input_name'       => 'cntry['.$CNT_ISO.']',
722 722
                 'class'            => '',
723 723
                 'options'          => $this->_yes_no_values,
724 724
                 'use_desc_4_label' => true,
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
             ),
727 727
             'CNT_cur_dec_plc' => array(
728 728
                 'type'       => 'RADIO_BTN',
729
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
729
+                'input_name' => 'cntry['.$CNT_ISO.']',
730 730
                 'class'      => '',
731 731
                 'options'    => array(
732 732
                     array('id' => 0, 'text' => ''),
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
             ),
739 739
             'CNT_cur_dec_mrk' => array(
740 740
                 'type'             => 'RADIO_BTN',
741
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
741
+                'input_name'       => 'cntry['.$CNT_ISO.']',
742 742
                 'class'            => '',
743 743
                 'options'          => array(
744 744
                     array(
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
             ),
753 753
             'CNT_cur_thsnds'  => array(
754 754
                 'type'             => 'RADIO_BTN',
755
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
755
+                'input_name'       => 'cntry['.$CNT_ISO.']',
756 756
                 'class'            => '',
757 757
                 'options'          => array(
758 758
                     array(
@@ -766,12 +766,12 @@  discard block
 block discarded – undo
766 766
             ),
767 767
             'CNT_tel_code'    => array(
768 768
                 'type'       => 'TEXT',
769
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
769
+                'input_name' => 'cntry['.$CNT_ISO.']',
770 770
                 'class'      => 'small-text',
771 771
             ),
772 772
             'CNT_is_EU'       => array(
773 773
                 'type'             => 'RADIO_BTN',
774
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
774
+                'input_name'       => 'cntry['.$CNT_ISO.']',
775 775
                 'class'            => '',
776 776
                 'options'          => $this->_yes_no_values,
777 777
                 'use_desc_4_label' => true,
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
             $country_input_types
783 783
         );
784 784
         $country_details_settings = EEH_Template::display_template(
785
-            GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
785
+            GEN_SET_TEMPLATE_PATH.'country_details_settings.template.php',
786 786
             $this->_template_args,
787 787
             true
788 788
         );
@@ -816,7 +816,7 @@  discard block
 block discarded – undo
816 816
 
817 817
         $CNT_ISO = isset($this->_req_data['country']) ? sanitize_text_field($this->_req_data['country']) : $CNT_ISO;
818 818
 
819
-        if (! $CNT_ISO) {
819
+        if ( ! $CNT_ISO) {
820 820
             return '';
821 821
         }
822 822
         // for ajax
@@ -833,22 +833,22 @@  discard block
 block discarded – undo
833 833
                     $state_input_types = array(
834 834
                         'STA_abbrev' => array(
835 835
                             'type'       => 'TEXT',
836
-                            'input_name' => 'states[' . $STA_ID . ']',
836
+                            'input_name' => 'states['.$STA_ID.']',
837 837
                             'class'      => 'mid-text',
838 838
                         ),
839 839
                         'STA_name'   => array(
840 840
                             'type'       => 'TEXT',
841
-                            'input_name' => 'states[' . $STA_ID . ']',
841
+                            'input_name' => 'states['.$STA_ID.']',
842 842
                             'class'      => 'regular-text',
843 843
                         ),
844 844
                         'STA_active' => array(
845 845
                             'type'             => 'RADIO_BTN',
846
-                            'input_name'       => 'states[' . $STA_ID . ']',
846
+                            'input_name'       => 'states['.$STA_ID.']',
847 847
                             'options'          => $this->_yes_no_values,
848 848
                             'use_desc_4_label' => true,
849 849
                         ),
850 850
                     );
851
-                    $this->_template_args['states'][ $STA_ID ]['inputs'] =
851
+                    $this->_template_args['states'][$STA_ID]['inputs'] =
852 852
                         EE_Question_Form_Input::generate_question_form_inputs_for_object(
853 853
                             $state,
854 854
                             $state_input_types
@@ -859,7 +859,7 @@  discard block
 block discarded – undo
859 859
                         'CNT_ISO'    => $CNT_ISO,
860 860
                         'STA_abbrev' => $state->abbrev(),
861 861
                     );
862
-                    $this->_template_args['states'][ $STA_ID ]['delete_state_url'] =
862
+                    $this->_template_args['states'][$STA_ID]['delete_state_url'] =
863 863
                         EE_Admin_Page::add_query_args_and_nonce(
864 864
                             $query_args,
865 865
                             GEN_SET_ADMIN_URL
@@ -876,7 +876,7 @@  discard block
 block discarded – undo
876 876
         );
877 877
 
878 878
         $state_details_settings = EEH_Template::display_template(
879
-            GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
879
+            GEN_SET_TEMPLATE_PATH.'state_details_settings.template.php',
880 880
             $this->_template_args,
881 881
             true
882 882
         );
@@ -912,7 +912,7 @@  discard block
 block discarded – undo
912 912
         $CNT_ISO = isset($this->_req_data['CNT_ISO'])
913 913
             ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
914 914
             : false;
915
-        if (! $CNT_ISO) {
915
+        if ( ! $CNT_ISO) {
916 916
             EE_Error::add_error(
917 917
                 __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
918 918
                 __FILE__,
@@ -924,7 +924,7 @@  discard block
 block discarded – undo
924 924
         $STA_abbrev = isset($this->_req_data['STA_abbrev'])
925 925
             ? sanitize_text_field($this->_req_data['STA_abbrev'])
926 926
             : false;
927
-        if (! $STA_abbrev) {
927
+        if ( ! $STA_abbrev) {
928 928
             EE_Error::add_error(
929 929
                 __('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
930 930
                 __FILE__,
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
         $STA_name = isset($this->_req_data['STA_name'])
937 937
             ? sanitize_text_field($this->_req_data['STA_name'])
938 938
             : false;
939
-        if (! $STA_name) {
939
+        if ( ! $STA_name) {
940 940
             EE_Error::add_error(
941 941
                 __('No State name or an invalid State name was received.', 'event_espresso'),
942 942
                 __FILE__,
@@ -986,7 +986,7 @@  discard block
 block discarded – undo
986 986
         $STA_abbrev = isset($this->_req_data['STA_abbrev'])
987 987
             ? sanitize_text_field($this->_req_data['STA_abbrev'])
988 988
             : false;
989
-        if (! $STA_ID) {
989
+        if ( ! $STA_ID) {
990 990
             EE_Error::add_error(
991 991
                 __('No State ID or an invalid State ID was received.', 'event_espresso'),
992 992
                 __FILE__,
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
         $CNT_ISO = isset($this->_req_data['country'])
1036 1036
             ? strtoupper(sanitize_text_field($this->_req_data['country']))
1037 1037
             : false;
1038
-        if (! $CNT_ISO) {
1038
+        if ( ! $CNT_ISO) {
1039 1039
             EE_Error::add_error(
1040 1040
                 __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1041 1041
                 __FILE__,
@@ -1046,63 +1046,63 @@  discard block
 block discarded – undo
1046 1046
             return;
1047 1047
         }
1048 1048
         $cols_n_values = array();
1049
-        $cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3'])
1050
-            ? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3']))
1049
+        $cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3'])
1050
+            ? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3']))
1051 1051
             : false;
1052
-        $cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID'])
1053
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID'])
1052
+        $cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][$CNT_ISO]['RGN_ID'])
1053
+            ? absint($this->_req_data['cntry'][$CNT_ISO]['RGN_ID'])
1054 1054
             : null;
1055
-        $cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name'])
1056
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name'])
1055
+        $cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_name'])
1056
+            ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_name'])
1057 1057
             : null;
1058
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])) {
1058
+        if (isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code'])) {
1059 1059
             $cols_n_values['CNT_cur_code'] = strtoupper(
1060
-                sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])
1060
+                sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code'])
1061 1061
             );
1062 1062
         }
1063
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single'])) {
1063
+        if (isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single'])) {
1064 1064
             $cols_n_values['CNT_cur_single'] = sanitize_text_field(
1065
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single']
1065
+                $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single']
1066 1066
             );
1067 1067
         }
1068
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural'])) {
1068
+        if (isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural'])) {
1069 1069
             $cols_n_values['CNT_cur_plural'] = sanitize_text_field(
1070
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural']
1070
+                $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural']
1071 1071
             );
1072 1072
         }
1073
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign'])) {
1073
+        if (isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign'])) {
1074 1074
             $cols_n_values['CNT_cur_sign'] = sanitize_text_field(
1075
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign']
1075
+                $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign']
1076 1076
             );
1077 1077
         }
1078
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4'])) {
1078
+        if (isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4'])) {
1079 1079
             $cols_n_values['CNT_cur_sign_b4'] = absint(
1080
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4']
1080
+                $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4']
1081 1081
             );
1082 1082
         }
1083
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc'])) {
1083
+        if (isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc'])) {
1084 1084
             $cols_n_values['CNT_cur_dec_plc'] = absint(
1085
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc']
1085
+                $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc']
1086 1086
             );
1087 1087
         }
1088
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk'])) {
1088
+        if (isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk'])) {
1089 1089
             $cols_n_values['CNT_cur_dec_mrk'] = sanitize_text_field(
1090
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk']
1090
+                $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk']
1091 1091
             );
1092 1092
         }
1093
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds'])) {
1093
+        if (isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds'])) {
1094 1094
             $cols_n_values['CNT_cur_thsnds'] = sanitize_text_field(
1095
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds']
1095
+                $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds']
1096 1096
             );
1097 1097
         }
1098
-        $cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code'])
1099
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code'])
1098
+        $cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code'])
1099
+            ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code'])
1100 1100
             : null;
1101
-        $cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU'])
1102
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU'])
1101
+        $cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU'])
1102
+            ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU'])
1103 1103
             : false;
1104
-        $cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active'])
1105
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active'])
1104
+        $cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_active'])
1105
+            ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_active'])
1106 1106
             : false;
1107 1107
         // allow filtering of country data
1108 1108
         $cols_n_values = apply_filters(
@@ -1179,7 +1179,7 @@  discard block
 block discarded – undo
1179 1179
         return '
1180 1180
 			<tr>
1181 1181
 				<th>
1182
-					' . $label . '
1182
+					' . $label.'
1183 1183
 				</th>';
1184 1184
     }
1185 1185
 
@@ -1195,7 +1195,7 @@  discard block
 block discarded – undo
1195 1195
     {
1196 1196
         return '
1197 1197
 				<td class="general-settings-country-input-td">
1198
-					' . $input . '
1198
+					' . $input.'
1199 1199
 				</td>
1200 1200
 			</tr>';
1201 1201
     }
@@ -1226,7 +1226,7 @@  discard block
 block discarded – undo
1226 1226
     {
1227 1227
         return '
1228 1228
 				<td class="general-settings-country-state-input-td">
1229
-					' . $input . '
1229
+					' . $input.'
1230 1230
 				</td>';
1231 1231
     }
1232 1232
 
@@ -1252,7 +1252,7 @@  discard block
 block discarded – undo
1252 1252
                  . __('Edit', 'event_espresso')
1253 1253
                  . '</a>';
1254 1254
         $links .= ' &nbsp;|&nbsp; ';
1255
-        $links .= '<a href="' . get_permalink($ee_page_id) . '" >' . __('View', 'event_espresso') . '</a>';
1255
+        $links .= '<a href="'.get_permalink($ee_page_id).'" >'.__('View', 'event_espresso').'</a>';
1256 1256
 
1257 1257
         return $links;
1258 1258
     }
@@ -1285,9 +1285,9 @@  discard block
 block discarded – undo
1285 1285
             $sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1286 1286
         }
1287 1287
 
1288
-        return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>'
1288
+        return '<span style="color:'.$pg_colour.'; margin-right:2em;"><strong>'
1289 1289
                . $pg_status
1290
-               . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>';
1290
+               . '</strong></span><span style="color:'.$sc_colour.'"><strong>'.$sc_status.'</strong></span>';
1291 1291
     }
1292 1292
 
1293 1293
 
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,6 @@
 block discarded – undo
5 5
 use EventEspresso\core\exceptions\InvalidDataTypeException;
6 6
 use EventEspresso\core\exceptions\InvalidFormSubmissionException;
7 7
 use EventEspresso\core\exceptions\InvalidInterfaceException;
8
-use EventEspresso\core\services\loaders\LoaderFactory;
9 8
 
10 9
 /**
11 10
  * General_Settings_Admin_Page
Please login to merge, or discard this patch.
Indentation   +1328 added lines, -1328 removed lines patch added patch discarded remove patch
@@ -21,1343 +21,1343 @@
 block discarded – undo
21 21
 {
22 22
 
23 23
 
24
-    /**
25
-     * _question_group
26
-     * holds the specific question group object for the question group details screen
27
-     *
28
-     * @var object
29
-     */
30
-    protected $_question_group;
31
-
32
-
33
-    /**
34
-     * Initialize basic properties.
35
-     */
36
-    protected function _init_page_props()
37
-    {
38
-        $this->page_slug = GEN_SET_PG_SLUG;
39
-        $this->page_label = GEN_SET_LABEL;
40
-        $this->_admin_base_url = GEN_SET_ADMIN_URL;
41
-        $this->_admin_base_path = GEN_SET_ADMIN;
42
-    }
43
-
44
-
45
-    /**
46
-     * Set ajax hooks
47
-     */
48
-    protected function _ajax_hooks()
49
-    {
50
-        add_action('wp_ajax_espresso_display_country_settings', array($this, 'display_country_settings'));
51
-        add_action('wp_ajax_espresso_display_country_states', array($this, 'display_country_states'));
52
-        add_action('wp_ajax_espresso_delete_state', array($this, 'delete_state'), 10, 3);
53
-        add_action('wp_ajax_espresso_add_new_state', array($this, 'add_new_state'));
54
-    }
55
-
56
-
57
-    /**
58
-     * More page properties initialization.
59
-     */
60
-    protected function _define_page_props()
61
-    {
62
-        $this->_admin_page_title = GEN_SET_LABEL;
63
-        $this->_labels = array(
64
-            'publishbox' => __('Update Settings', 'event_espresso'),
65
-        );
66
-    }
67
-
68
-
69
-    /**
70
-     * Set page routes property.
71
-     */
72
-    protected function _set_page_routes()
73
-    {
74
-        $this->_page_routes = array(
75
-
76
-            'critical_pages'                => array(
77
-                'func'       => '_espresso_page_settings',
78
-                'capability' => 'manage_options',
79
-            ),
80
-            'update_espresso_page_settings' => array(
81
-                'func'       => '_update_espresso_page_settings',
82
-                'capability' => 'manage_options',
83
-                'noheader'   => true,
84
-            ),
85
-            'default'                       => array(
86
-                'func'       => '_your_organization_settings',
87
-                'capability' => 'manage_options',
88
-            ),
89
-
90
-            'update_your_organization_settings' => array(
91
-                'func'       => '_update_your_organization_settings',
92
-                'capability' => 'manage_options',
93
-                'noheader'   => true,
94
-            ),
95
-
96
-            'admin_option_settings' => array(
97
-                'func'       => '_admin_option_settings',
98
-                'capability' => 'manage_options',
99
-            ),
100
-
101
-            'update_admin_option_settings' => array(
102
-                'func'       => '_update_admin_option_settings',
103
-                'capability' => 'manage_options',
104
-                'noheader'   => true,
105
-            ),
106
-
107
-            'country_settings' => array(
108
-                'func'       => '_country_settings',
109
-                'capability' => 'manage_options',
110
-            ),
111
-
112
-            'update_country_settings' => array(
113
-                'func'       => '_update_country_settings',
114
-                'capability' => 'manage_options',
115
-                'noheader'   => true,
116
-            ),
117
-
118
-            'display_country_settings' => array(
119
-                'func'       => 'display_country_settings',
120
-                'capability' => 'manage_options',
121
-                'noheader'   => true,
122
-            ),
123
-
124
-            'add_new_state' => array(
125
-                'func'       => 'add_new_state',
126
-                'capability' => 'manage_options',
127
-                'noheader'   => true,
128
-            ),
129
-
130
-            'delete_state' => array(
131
-                'func'       => 'delete_state',
132
-                'capability' => 'manage_options',
133
-                'noheader'   => true,
134
-            ),
135
-            'privacy_settings' => array(
136
-                'func' => 'privacySettings',
137
-                'capability' => 'manage_options',
138
-            ),
139
-            'update_privacy_settings' => array(
140
-                'func' => 'updatePrivacySettings',
141
-                'capability' => 'manage_options',
142
-                'noheader' => true,
143
-                'headers_sent_route' => 'privacy_settings'
144
-            )
145
-        );
146
-    }
147
-
148
-
149
-    /**
150
-     * Set page configuration property
151
-     */
152
-    protected function _set_page_config()
153
-    {
154
-        $this->_page_config = array(
155
-            'critical_pages'        => array(
156
-                'nav'           => array(
157
-                    'label' => __('Critical Pages', 'event_espresso'),
158
-                    'order' => 50,
159
-                ),
160
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
161
-                'help_tabs'     => array(
162
-                    'general_settings_critical_pages_help_tab' => array(
163
-                        'title'    => __('Critical Pages', 'event_espresso'),
164
-                        'filename' => 'general_settings_critical_pages',
165
-                    ),
166
-                ),
167
-                'help_tour'     => array('Critical_Pages_Help_Tour'),
168
-                'require_nonce' => false,
169
-            ),
170
-            'default'               => array(
171
-                'nav'           => array(
172
-                    'label' => __('Your Organization', 'event_espresso'),
173
-                    'order' => 20,
174
-                ),
175
-                'help_tabs'     => array(
176
-                    'general_settings_your_organization_help_tab' => array(
177
-                        'title'    => __('Your Organization', 'event_espresso'),
178
-                        'filename' => 'general_settings_your_organization',
179
-                    ),
180
-                ),
181
-                'help_tour'     => array('Your_Organization_Help_Tour'),
182
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
183
-                'require_nonce' => false,
184
-            ),
185
-            'admin_option_settings' => array(
186
-                'nav'           => array(
187
-                    'label' => __('Admin Options', 'event_espresso'),
188
-                    'order' => 60,
189
-                ),
190
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
191
-                'help_tabs'     => array(
192
-                    'general_settings_admin_options_help_tab' => array(
193
-                        'title'    => __('Admin Options', 'event_espresso'),
194
-                        'filename' => 'general_settings_admin_options',
195
-                    ),
196
-                ),
197
-                'help_tour'     => array('Admin_Options_Help_Tour'),
198
-                'require_nonce' => false,
199
-            ),
200
-            'country_settings'      => array(
201
-                'nav'           => array(
202
-                    'label' => __('Countries', 'event_espresso'),
203
-                    'order' => 70,
204
-                ),
205
-                'help_tabs'     => array(
206
-                    'general_settings_countries_help_tab' => array(
207
-                        'title'    => __('Countries', 'event_espresso'),
208
-                        'filename' => 'general_settings_countries',
209
-                    ),
210
-                ),
211
-                'help_tour'     => array('Countries_Help_Tour'),
212
-                'require_nonce' => false,
213
-            ),
214
-            'privacy_settings' => array(
215
-                'nav' => array(
216
-                    'label' => esc_html__('Privacy', 'event_espresso'),
217
-                    'order' => 80
218
-                ),
219
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
220
-                'require_nonce' => false
221
-            )
222
-        );
223
-    }
224
-
225
-
226
-    protected function _add_screen_options()
227
-    {
228
-    }
229
-
230
-    protected function _add_feature_pointers()
231
-    {
232
-    }
233
-
234
-
235
-    /**
236
-     * Enqueue global scripts and styles for all routes in the General Settings Admin Pages.
237
-     */
238
-    public function load_scripts_styles()
239
-    {
240
-        // styles
241
-        wp_enqueue_style('espresso-ui-theme');
242
-        // scripts
243
-        wp_enqueue_script('ee_admin_js');
244
-    }
245
-
246
-
247
-    /**
248
-     * Execute logic running on `admin_init`
249
-     */
250
-    public function admin_init()
251
-    {
252
-        EE_Registry::$i18n_js_strings['invalid_server_response'] = __(
253
-            'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.',
254
-            'event_espresso'
255
-        );
256
-        EE_Registry::$i18n_js_strings['error_occurred'] = __(
257
-            'An error occurred! Please refresh the page and try again.',
258
-            'event_espresso'
259
-        );
260
-        EE_Registry::$i18n_js_strings['confirm_delete_state'] = __(
261
-            'Are you sure you want to delete this State / Province?',
262
-            'event_espresso'
263
-        );
264
-        $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
265
-        EE_Registry::$i18n_js_strings['ajax_url'] = admin_url(
266
-            'admin-ajax.php?page=espresso_general_settings',
267
-            $protocol
268
-        );
269
-    }
270
-
271
-    public function admin_notices()
272
-    {
273
-    }
274
-
275
-    public function admin_footer_scripts()
276
-    {
277
-    }
278
-
279
-
280
-    /**
281
-     * Enqueue scripts and styles for the default route.
282
-     */
283
-    public function load_scripts_styles_default()
284
-    {
285
-        // styles
286
-        wp_enqueue_style('thickbox');
287
-        // scripts
288
-        wp_enqueue_script('media-upload');
289
-        wp_enqueue_script('thickbox');
290
-        wp_register_script(
291
-            'organization_settings',
292
-            GEN_SET_ASSETS_URL . 'your_organization_settings.js',
293
-            array('jquery', 'media-upload', 'thickbox'),
294
-            EVENT_ESPRESSO_VERSION,
295
-            true
296
-        );
297
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
298
-        wp_enqueue_script('organization_settings');
299
-        wp_enqueue_style('organization-css');
300
-        $confirm_image_delete = array(
301
-            'text' => __(
302
-                'Do you really want to delete this image? Please remember to save your settings to complete the removal.',
303
-                'event_espresso'
304
-            ),
305
-        );
306
-        wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
307
-    }
308
-
309
-
310
-    /**
311
-     * Enqueue scripts and styles for the country settings route.
312
-     */
313
-    public function load_scripts_styles_country_settings()
314
-    {
315
-        // scripts
316
-        wp_register_script(
317
-            'gen_settings_countries',
318
-            GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
319
-            array('ee_admin_js'),
320
-            EVENT_ESPRESSO_VERSION,
321
-            true
322
-        );
323
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
324
-        wp_enqueue_script('gen_settings_countries');
325
-        wp_enqueue_style('organization-css');
326
-    }
327
-
328
-
329
-    /*************        Espresso Pages        *************/
330
-    /**
331
-     * _espresso_page_settings
332
-     *
333
-     * @throws \EE_Error
334
-     * @throws DomainException
335
-     * @throws DomainException
336
-     * @throws InvalidDataTypeException
337
-     * @throws InvalidArgumentException
338
-     */
339
-    protected function _espresso_page_settings()
340
-    {
341
-        // Check to make sure all of the main pages are setup properly,
342
-        // if not create the default pages and display an admin notice
343
-        EEH_Activation::verify_default_pages_exist();
344
-        $this->_transient_garbage_collection();
345
-        $this->_template_args['values'] = $this->_yes_no_values;
346
-        $this->_template_args['reg_page_id'] = isset(EE_Registry::instance()->CFG->core->reg_page_id)
347
-            ? EE_Registry::instance()->CFG->core->reg_page_id
348
-            : null;
349
-        $this->_template_args['reg_page_obj'] = isset(EE_Registry::instance()->CFG->core->reg_page_id)
350
-            ? get_page(EE_Registry::instance()->CFG->core->reg_page_id)
351
-            : false;
352
-        $this->_template_args['txn_page_id'] = isset(EE_Registry::instance()->CFG->core->txn_page_id)
353
-            ? EE_Registry::instance()->CFG->core->txn_page_id
354
-            : null;
355
-        $this->_template_args['txn_page_obj'] = isset(EE_Registry::instance()->CFG->core->txn_page_id)
356
-            ? get_page(EE_Registry::instance()->CFG->core->txn_page_id)
357
-            : false;
358
-        $this->_template_args['thank_you_page_id'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id)
359
-            ? EE_Registry::instance()->CFG->core->thank_you_page_id
360
-            : null;
361
-        $this->_template_args['thank_you_page_obj'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id)
362
-            ? get_page(EE_Registry::instance()->CFG->core->thank_you_page_id)
363
-            : false;
364
-        $this->_template_args['cancel_page_id'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id)
365
-            ? EE_Registry::instance()->CFG->core->cancel_page_id
366
-            : null;
367
-        $this->_template_args['cancel_page_obj'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id)
368
-            ? get_page(EE_Registry::instance()->CFG->core->cancel_page_id)
369
-            : false;
370
-        $this->_set_add_edit_form_tags('update_espresso_page_settings');
371
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
372
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
373
-            GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
374
-            $this->_template_args,
375
-            true
376
-        );
377
-        $this->display_admin_page_with_sidebar();
378
-    }
379
-
380
-
381
-    /**
382
-     * Handler for updating espresso page settings.
383
-     *
384
-     * @throws EE_Error
385
-     */
386
-    protected function _update_espresso_page_settings()
387
-    {
388
-        // capture incoming request data && set page IDs
389
-        EE_Registry::instance()->CFG->core->reg_page_id = isset($this->_req_data['reg_page_id'])
390
-            ? absint($this->_req_data['reg_page_id'])
391
-            : EE_Registry::instance()->CFG->core->reg_page_id;
392
-        EE_Registry::instance()->CFG->core->txn_page_id = isset($this->_req_data['txn_page_id'])
393
-            ? absint($this->_req_data['txn_page_id'])
394
-            : EE_Registry::instance()->CFG->core->txn_page_id;
395
-        EE_Registry::instance()->CFG->core->thank_you_page_id = isset($this->_req_data['thank_you_page_id'])
396
-            ? absint($this->_req_data['thank_you_page_id'])
397
-            : EE_Registry::instance()->CFG->core->thank_you_page_id;
398
-        EE_Registry::instance()->CFG->core->cancel_page_id = isset($this->_req_data['cancel_page_id'])
399
-            ? absint($this->_req_data['cancel_page_id'])
400
-            : EE_Registry::instance()->CFG->core->cancel_page_id;
401
-
402
-        EE_Registry::instance()->CFG->core = apply_filters(
403
-            'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core',
404
-            EE_Registry::instance()->CFG->core,
405
-            $this->_req_data
406
-        );
407
-        $what = __('Critical Pages & Shortcodes', 'event_espresso');
408
-        $this->_redirect_after_action(
409
-            $this->_update_espresso_configuration(
410
-                $what,
411
-                EE_Registry::instance()->CFG->core,
412
-                __FILE__,
413
-                __FUNCTION__,
414
-                __LINE__
415
-            ),
416
-            $what,
417
-            '',
418
-            array(
419
-                'action' => 'critical_pages',
420
-            ),
421
-            true
422
-        );
423
-    }
424
-
425
-
426
-    /*************        Your Organization        *************/
427
-
428
-
429
-    /**
430
-     * @throws DomainException
431
-     * @throws EE_Error
432
-     * @throws InvalidArgumentException
433
-     * @throws InvalidDataTypeException
434
-     * @throws InvalidInterfaceException
435
-     */
436
-    protected function _your_organization_settings()
437
-    {
438
-        $this->_template_args['admin_page_content'] = '';
439
-        try {
440
-            /** @var EventEspresso\admin_pages\general_settings\OrganizationSettings $organization_settings_form */
441
-            $organization_settings_form = $this->loader->getShared(
442
-                'EventEspresso\admin_pages\general_settings\OrganizationSettings'
443
-            );
444
-            $this->_template_args['admin_page_content'] = $organization_settings_form->display();
445
-        } catch (Exception $e) {
446
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
447
-        }
448
-        $this->_set_add_edit_form_tags('update_your_organization_settings');
449
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
450
-        $this->display_admin_page_with_sidebar();
451
-    }
452
-
453
-
454
-
455
-    /**
456
-     * Handler for updating organization settings.
457
-     *
458
-     * @throws EE_Error
459
-     */
460
-    protected function _update_your_organization_settings()
461
-    {
462
-        try {
463
-            /** @var EventEspresso\admin_pages\general_settings\OrganizationSettings $organization_settings_form */
464
-            $organization_settings_form = $this->loader->getShared(
465
-                'EventEspresso\admin_pages\general_settings\OrganizationSettings'
466
-            );
467
-            $success = $organization_settings_form->process($this->_req_data);
468
-            EE_Registry::instance()->CFG = apply_filters(
469
-                'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG',
470
-                EE_Registry::instance()->CFG
471
-            );
472
-        } catch (Exception $e) {
473
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
474
-            $success = false;
475
-        }
476
-
477
-        if ($success) {
478
-            $success = $this->_update_espresso_configuration(
479
-                esc_html__('Your Organization Settings', 'event_espresso'),
480
-                EE_Registry::instance()->CFG,
481
-                __FILE__,
482
-                __FUNCTION__,
483
-                __LINE__
484
-            );
485
-        }
486
-
487
-        $this->_redirect_after_action($success, '', '', array('action' => 'default'), true);
488
-    }
489
-
490
-
491
-
492
-    /*************        Admin Options        *************/
493
-
494
-
495
-    /**
496
-     * _admin_option_settings
497
-     *
498
-     * @throws \EE_Error
499
-     * @throws \LogicException
500
-     */
501
-    protected function _admin_option_settings()
502
-    {
503
-        $this->_template_args['admin_page_content'] = '';
504
-        try {
505
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
506
-            // still need this for the old school form in Extend_General_Settings_Admin_Page
507
-            $this->_template_args['values'] = $this->_yes_no_values;
508
-            // also need to account for the do_action that was in the old template
509
-            $admin_options_settings_form->setTemplateArgs($this->_template_args);
510
-            $this->_template_args['admin_page_content'] = $admin_options_settings_form->display();
511
-        } catch (Exception $e) {
512
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
513
-        }
514
-        $this->_set_add_edit_form_tags('update_admin_option_settings');
515
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
516
-        $this->display_admin_page_with_sidebar();
517
-    }
518
-
519
-
520
-    /**
521
-     * _update_admin_option_settings
522
-     *
523
-     * @throws \EE_Error
524
-     * @throws InvalidDataTypeException
525
-     * @throws \EventEspresso\core\exceptions\InvalidFormSubmissionException
526
-     * @throws \InvalidArgumentException
527
-     * @throws \LogicException
528
-     */
529
-    protected function _update_admin_option_settings()
530
-    {
531
-        try {
532
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
533
-            $admin_options_settings_form->process($this->_req_data[ $admin_options_settings_form->slug() ]);
534
-            EE_Registry::instance()->CFG->admin = apply_filters(
535
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
536
-                EE_Registry::instance()->CFG->admin
537
-            );
538
-        } catch (Exception $e) {
539
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
540
-        }
541
-        $this->_redirect_after_action(
542
-            apply_filters(
543
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
544
-                $this->_update_espresso_configuration(
545
-                    'Admin Options',
546
-                    EE_Registry::instance()->CFG->admin,
547
-                    __FILE__,
548
-                    __FUNCTION__,
549
-                    __LINE__
550
-                )
551
-            ),
552
-            'Admin Options',
553
-            'updated',
554
-            array('action' => 'admin_option_settings')
555
-        );
556
-    }
557
-
558
-
559
-    /*************        Countries        *************/
560
-
561
-
562
-    /**
563
-     * @return string
564
-     */
565
-    protected function getCountryIsoForSite()
566
-    {
567
-        return ! empty(EE_Registry::instance()->CFG->organization->CNT_ISO)
568
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
569
-            : 'US';
570
-    }
571
-
572
-
573
-
574
-    /**
575
-     * Output Country Settings view.
576
-     *
577
-     * @throws DomainException
578
-     * @throws EE_Error
579
-     */
580
-    protected function _country_settings()
581
-    {
582
-        $CNT_ISO_for_site = $this->getCountryIsoForSite();
583
-        $CNT_ISO = isset($this->_req_data['country'])
584
-            ? strtoupper(sanitize_text_field($this->_req_data['country']))
585
-            : $CNT_ISO_for_site;
586
-
587
-        // load field generator helper
588
-
589
-        $this->_template_args['values'] = $this->_yes_no_values;
590
-
591
-        $this->_template_args['countries'] = new EE_Question_Form_Input(
592
-            EE_Question::new_instance(
593
-                array(
594
-                    'QST_ID'           => 0,
595
-                    'QST_display_text' => __('Select Country', 'event_espresso'),
596
-                    'QST_system'       => 'admin-country',
597
-                )
598
-            ),
599
-            EE_Answer::new_instance(
600
-                array(
601
-                    'ANS_ID'    => 0,
602
-                    'ANS_value' => $CNT_ISO,
603
-                )
604
-            ),
605
-            array(
606
-                'input_id'       => 'country',
607
-                'input_name'     => 'country',
608
-                'input_prefix'   => '',
609
-                'append_qstn_id' => false,
610
-            )
611
-        );
612
-
613
-        add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
614
-        add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
615
-        $this->_template_args['country_details_settings'] = $this->display_country_settings();
616
-        $this->_template_args['country_states_settings'] = $this->display_country_states();
617
-        $this->_template_args['CNT_name_for_site'] = EEM_Country::instance()->get_one_by_ID($CNT_ISO_for_site)
618
-                                                                            ->name();
619
-
620
-        $this->_set_add_edit_form_tags('update_country_settings');
621
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
622
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
623
-            GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
624
-            $this->_template_args,
625
-            true
626
-        );
627
-        $this->display_admin_page_with_no_sidebar();
628
-    }
629
-
630
-
631
-    /**
632
-     *        display_country_settings
633
-     *
634
-     * @access    public
635
-     * @param    string $CNT_ISO
636
-     * @return mixed string | array
637
-     * @throws DomainException
638
-     */
639
-    public function display_country_settings($CNT_ISO = '')
640
-    {
641
-        $CNT_ISO_for_site = $this->getCountryIsoForSite();
642
-
643
-        $CNT_ISO = isset($this->_req_data['country'])
644
-            ? strtoupper(sanitize_text_field($this->_req_data['country']))
645
-            : $CNT_ISO;
646
-        if (! $CNT_ISO) {
647
-            return '';
648
-        }
649
-
650
-        // for ajax
651
-        remove_all_filters('FHEE__EEH_Form_Fields__label_html');
652
-        remove_all_filters('FHEE__EEH_Form_Fields__input_html');
653
-        add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
654
-        add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
655
-        /** @var EE_Country $country */
656
-        $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
657
-
658
-        $CNT_cur_disabled = $CNT_ISO !== $CNT_ISO_for_site;
659
-        $this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled;
660
-
661
-        $country_input_types = array(
662
-            'CNT_active'      => array(
663
-                'type'             => 'RADIO_BTN',
664
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
665
-                'class'            => '',
666
-                'options'          => $this->_yes_no_values,
667
-                'use_desc_4_label' => true,
668
-            ),
669
-            'CNT_ISO'         => array(
670
-                'type'       => 'TEXT',
671
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
672
-                'class'      => 'small-text',
673
-            ),
674
-            'CNT_ISO3'        => array(
675
-                'type'       => 'TEXT',
676
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
677
-                'class'      => 'small-text',
678
-            ),
679
-            'RGN_ID'          => array(
680
-                'type'       => 'TEXT',
681
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
682
-                'class'      => 'small-text',
683
-            ),
684
-            'CNT_name'        => array(
685
-                'type'       => 'TEXT',
686
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
687
-                'class'      => 'regular-text',
688
-            ),
689
-            'CNT_cur_code'    => array(
690
-                'type'       => 'TEXT',
691
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
692
-                'class'      => 'small-text',
693
-                'disabled'   => $CNT_cur_disabled
694
-            ),
695
-            'CNT_cur_single'  => array(
696
-                'type'       => 'TEXT',
697
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
698
-                'class'      => 'medium-text',
699
-                'disabled' => $CNT_cur_disabled
700
-            ),
701
-            'CNT_cur_plural'  => array(
702
-                'type'       => 'TEXT',
703
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
704
-                'class'      => 'medium-text',
705
-                'disabled' => $CNT_cur_disabled
706
-            ),
707
-            'CNT_cur_sign'    => array(
708
-                'type'         => 'TEXT',
709
-                'input_name'   => 'cntry[' . $CNT_ISO . ']',
710
-                'class'        => 'small-text',
711
-                'htmlentities' => false,
712
-                'disabled' => $CNT_cur_disabled
713
-            ),
714
-            'CNT_cur_sign_b4' => array(
715
-                'type'             => 'RADIO_BTN',
716
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
717
-                'class'            => '',
718
-                'options'          => $this->_yes_no_values,
719
-                'use_desc_4_label' => true,
720
-                'disabled' => $CNT_cur_disabled
721
-            ),
722
-            'CNT_cur_dec_plc' => array(
723
-                'type'       => 'RADIO_BTN',
724
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
725
-                'class'      => '',
726
-                'options'    => array(
727
-                    array('id' => 0, 'text' => ''),
728
-                    array('id' => 1, 'text' => ''),
729
-                    array('id' => 2, 'text' => ''),
730
-                    array('id' => 3, 'text' => ''),
731
-                ),
732
-                'disabled' => $CNT_cur_disabled
733
-            ),
734
-            'CNT_cur_dec_mrk' => array(
735
-                'type'             => 'RADIO_BTN',
736
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
737
-                'class'            => '',
738
-                'options'          => array(
739
-                    array(
740
-                        'id'   => ',',
741
-                        'text' => __(', (comma)', 'event_espresso'),
742
-                    ),
743
-                    array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')),
744
-                ),
745
-                'use_desc_4_label' => true,
746
-                'disabled' => $CNT_cur_disabled
747
-            ),
748
-            'CNT_cur_thsnds'  => array(
749
-                'type'             => 'RADIO_BTN',
750
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
751
-                'class'            => '',
752
-                'options'          => array(
753
-                    array(
754
-                        'id'   => ',',
755
-                        'text' => __(', (comma)', 'event_espresso'),
756
-                    ),
757
-                    array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')),
758
-                ),
759
-                'use_desc_4_label' => true,
760
-                'disabled' => $CNT_cur_disabled
761
-            ),
762
-            'CNT_tel_code'    => array(
763
-                'type'       => 'TEXT',
764
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
765
-                'class'      => 'small-text',
766
-            ),
767
-            'CNT_is_EU'       => array(
768
-                'type'             => 'RADIO_BTN',
769
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
770
-                'class'            => '',
771
-                'options'          => $this->_yes_no_values,
772
-                'use_desc_4_label' => true,
773
-            ),
774
-        );
775
-        $this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object(
776
-            $country,
777
-            $country_input_types
778
-        );
779
-        $country_details_settings = EEH_Template::display_template(
780
-            GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
781
-            $this->_template_args,
782
-            true
783
-        );
784
-
785
-        if (defined('DOING_AJAX')) {
786
-            $notices = EE_Error::get_notices(false, false, false);
787
-            echo wp_json_encode(
788
-                array(
789
-                    'return_data' => $country_details_settings,
790
-                    'success'     => $notices['success'],
791
-                    'errors'      => $notices['errors'],
792
-                )
793
-            );
794
-            die();
795
-        } else {
796
-            return $country_details_settings;
797
-        }
798
-    }
799
-
800
-
801
-    /**
802
-     *        display_country_states
803
-     *
804
-     * @access    public
805
-     * @param    string $CNT_ISO
806
-     * @return string
807
-     * @throws DomainException
808
-     */
809
-    public function display_country_states($CNT_ISO = '')
810
-    {
811
-
812
-        $CNT_ISO = isset($this->_req_data['country']) ? sanitize_text_field($this->_req_data['country']) : $CNT_ISO;
813
-
814
-        if (! $CNT_ISO) {
815
-            return '';
816
-        }
817
-        // for ajax
818
-        remove_all_filters('FHEE__EEH_Form_Fields__label_html');
819
-        remove_all_filters('FHEE__EEH_Form_Fields__input_html');
820
-        add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'state_form_field_label_wrap'), 10, 2);
821
-        add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'state_form_field_input__wrap'), 10, 2);
822
-        $states = EEM_State::instance()->get_all_states_for_these_countries(array($CNT_ISO => $CNT_ISO));
823
-
824
-        if ($states) {
825
-            foreach ($states as $STA_ID => $state) {
826
-                if ($state instanceof EE_State) {
827
-                    // STA_abbrev    STA_name    STA_active
828
-                    $state_input_types = array(
829
-                        'STA_abbrev' => array(
830
-                            'type'       => 'TEXT',
831
-                            'input_name' => 'states[' . $STA_ID . ']',
832
-                            'class'      => 'mid-text',
833
-                        ),
834
-                        'STA_name'   => array(
835
-                            'type'       => 'TEXT',
836
-                            'input_name' => 'states[' . $STA_ID . ']',
837
-                            'class'      => 'regular-text',
838
-                        ),
839
-                        'STA_active' => array(
840
-                            'type'             => 'RADIO_BTN',
841
-                            'input_name'       => 'states[' . $STA_ID . ']',
842
-                            'options'          => $this->_yes_no_values,
843
-                            'use_desc_4_label' => true,
844
-                        ),
845
-                    );
846
-                    $this->_template_args['states'][ $STA_ID ]['inputs'] =
847
-                        EE_Question_Form_Input::generate_question_form_inputs_for_object(
848
-                            $state,
849
-                            $state_input_types
850
-                        );
851
-                    $query_args = array(
852
-                        'action'     => 'delete_state',
853
-                        'STA_ID'     => $STA_ID,
854
-                        'CNT_ISO'    => $CNT_ISO,
855
-                        'STA_abbrev' => $state->abbrev(),
856
-                    );
857
-                    $this->_template_args['states'][ $STA_ID ]['delete_state_url'] =
858
-                        EE_Admin_Page::add_query_args_and_nonce(
859
-                            $query_args,
860
-                            GEN_SET_ADMIN_URL
861
-                        );
862
-                }
863
-            }
864
-        } else {
865
-            $this->_template_args['states'] = false;
866
-        }
867
-
868
-        $this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(
869
-            array('action' => 'add_new_state'),
870
-            GEN_SET_ADMIN_URL
871
-        );
872
-
873
-        $state_details_settings = EEH_Template::display_template(
874
-            GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
875
-            $this->_template_args,
876
-            true
877
-        );
878
-
879
-        if (defined('DOING_AJAX')) {
880
-            $notices = EE_Error::get_notices(false, false, false);
881
-            echo wp_json_encode(
882
-                array(
883
-                    'return_data' => $state_details_settings,
884
-                    'success'     => $notices['success'],
885
-                    'errors'      => $notices['errors'],
886
-                )
887
-            );
888
-            die();
889
-        } else {
890
-            return $state_details_settings;
891
-        }
892
-    }
893
-
894
-
895
-    /**
896
-     *        add_new_state
897
-     *
898
-     * @access    public
899
-     * @return void
900
-     * @throws EE_Error
901
-     */
902
-    public function add_new_state()
903
-    {
904
-
905
-        $success = true;
906
-
907
-        $CNT_ISO = isset($this->_req_data['CNT_ISO'])
908
-            ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
909
-            : false;
910
-        if (! $CNT_ISO) {
911
-            EE_Error::add_error(
912
-                __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
913
-                __FILE__,
914
-                __FUNCTION__,
915
-                __LINE__
916
-            );
917
-            $success = false;
918
-        }
919
-        $STA_abbrev = isset($this->_req_data['STA_abbrev'])
920
-            ? sanitize_text_field($this->_req_data['STA_abbrev'])
921
-            : false;
922
-        if (! $STA_abbrev) {
923
-            EE_Error::add_error(
924
-                __('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
925
-                __FILE__,
926
-                __FUNCTION__,
927
-                __LINE__
928
-            );
929
-            $success = false;
930
-        }
931
-        $STA_name = isset($this->_req_data['STA_name'])
932
-            ? sanitize_text_field($this->_req_data['STA_name'])
933
-            : false;
934
-        if (! $STA_name) {
935
-            EE_Error::add_error(
936
-                __('No State name or an invalid State name was received.', 'event_espresso'),
937
-                __FILE__,
938
-                __FUNCTION__,
939
-                __LINE__
940
-            );
941
-            $success = false;
942
-        }
943
-
944
-        if ($success) {
945
-            $cols_n_values = array(
946
-                'CNT_ISO'    => $CNT_ISO,
947
-                'STA_abbrev' => $STA_abbrev,
948
-                'STA_name'   => $STA_name,
949
-                'STA_active' => true,
950
-            );
951
-            $success = EEM_State::instance()->insert($cols_n_values);
952
-            EE_Error::add_success(__('The State was added successfully.', 'event_espresso'));
953
-        }
954
-
955
-        if (defined('DOING_AJAX')) {
956
-            $notices = EE_Error::get_notices(false, false, false);
957
-            echo wp_json_encode(array_merge($notices, array('return_data' => $CNT_ISO)));
958
-            die();
959
-        } else {
960
-            $this->_redirect_after_action($success, 'State', 'added', array('action' => 'country_settings'));
961
-        }
962
-    }
963
-
964
-
965
-    /**
966
-     *        delete_state
967
-     *
968
-     * @access    public
969
-     * @return        boolean
970
-     * @throws EE_Error
971
-     * @throws EE_Error
972
-     */
973
-    public function delete_state()
974
-    {
975
-        $CNT_ISO = isset($this->_req_data['CNT_ISO'])
976
-            ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
977
-            : false;
978
-        $STA_ID = isset($this->_req_data['STA_ID'])
979
-            ? sanitize_text_field($this->_req_data['STA_ID'])
980
-            : false;
981
-        $STA_abbrev = isset($this->_req_data['STA_abbrev'])
982
-            ? sanitize_text_field($this->_req_data['STA_abbrev'])
983
-            : false;
984
-        if (! $STA_ID) {
985
-            EE_Error::add_error(
986
-                __('No State ID or an invalid State ID was received.', 'event_espresso'),
987
-                __FILE__,
988
-                __FUNCTION__,
989
-                __LINE__
990
-            );
991
-            return false;
992
-        }
993
-
994
-        $success = EEM_State::instance()->delete_by_ID($STA_ID);
995
-        if ($success !== false) {
996
-            do_action(
997
-                'AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
998
-                $CNT_ISO,
999
-                $STA_ID,
1000
-                array('STA_abbrev' => $STA_abbrev)
1001
-            );
1002
-            EE_Error::add_success(__('The State was deleted successfully.', 'event_espresso'));
1003
-        }
1004
-        if (defined('DOING_AJAX')) {
1005
-            $notices = EE_Error::get_notices(false, false);
1006
-            $notices['return_data'] = true;
1007
-            echo wp_json_encode($notices);
1008
-            die();
1009
-        } else {
1010
-            $this->_redirect_after_action(
1011
-                $success,
1012
-                'State',
1013
-                'deleted',
1014
-                array('action' => 'country_settings')
1015
-            );
1016
-        }
1017
-    }
1018
-
1019
-
1020
-    /**
1021
-     *        _update_country_settings
1022
-     *
1023
-     * @access    protected
1024
-     * @return void
1025
-     * @throws EE_Error
1026
-     */
1027
-    protected function _update_country_settings()
1028
-    {
1029
-        // grab the country ISO code
1030
-        $CNT_ISO = isset($this->_req_data['country'])
1031
-            ? strtoupper(sanitize_text_field($this->_req_data['country']))
1032
-            : false;
1033
-        if (! $CNT_ISO) {
1034
-            EE_Error::add_error(
1035
-                __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1036
-                __FILE__,
1037
-                __FUNCTION__,
1038
-                __LINE__
1039
-            );
1040
-
1041
-            return;
1042
-        }
1043
-        $cols_n_values = array();
1044
-        $cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3'])
1045
-            ? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3']))
1046
-            : false;
1047
-        $cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID'])
1048
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID'])
1049
-            : null;
1050
-        $cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name'])
1051
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name'])
1052
-            : null;
1053
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])) {
1054
-            $cols_n_values['CNT_cur_code'] = strtoupper(
1055
-                sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])
1056
-            );
1057
-        }
1058
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single'])) {
1059
-            $cols_n_values['CNT_cur_single'] = sanitize_text_field(
1060
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single']
1061
-            );
1062
-        }
1063
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural'])) {
1064
-            $cols_n_values['CNT_cur_plural'] = sanitize_text_field(
1065
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural']
1066
-            );
1067
-        }
1068
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign'])) {
1069
-            $cols_n_values['CNT_cur_sign'] = sanitize_text_field(
1070
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign']
1071
-            );
1072
-        }
1073
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4'])) {
1074
-            $cols_n_values['CNT_cur_sign_b4'] = absint(
1075
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4']
1076
-            );
1077
-        }
1078
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc'])) {
1079
-            $cols_n_values['CNT_cur_dec_plc'] = absint(
1080
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc']
1081
-            );
1082
-        }
1083
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk'])) {
1084
-            $cols_n_values['CNT_cur_dec_mrk'] = sanitize_text_field(
1085
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk']
1086
-            );
1087
-        }
1088
-        if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds'])) {
1089
-            $cols_n_values['CNT_cur_thsnds'] = sanitize_text_field(
1090
-                $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds']
1091
-            );
1092
-        }
1093
-        $cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code'])
1094
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code'])
1095
-            : null;
1096
-        $cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU'])
1097
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU'])
1098
-            : false;
1099
-        $cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active'])
1100
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active'])
1101
-            : false;
1102
-        // allow filtering of country data
1103
-        $cols_n_values = apply_filters(
1104
-            'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values',
1105
-            $cols_n_values
1106
-        );
1107
-
1108
-        // where values
1109
-        $where_cols_n_values = array(array('CNT_ISO' => $CNT_ISO));
1110
-        // run the update
1111
-        $success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
1112
-
1113
-        if (isset($this->_req_data['states']) && is_array($this->_req_data['states']) && $success !== false) {
1114
-            // allow filtering of states data
1115
-            $states = apply_filters(
1116
-                'FHEE__General_Settings_Admin_Page___update_country_settings__states',
1117
-                $this->_req_data['states']
1118
-            );
1119
-
1120
-            // loop thru state data ( looks like : states[75][STA_name] )
1121
-            foreach ($states as $STA_ID => $state) {
1122
-                $cols_n_values = array(
1123
-                    'CNT_ISO'    => $CNT_ISO,
1124
-                    'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
1125
-                    'STA_name'   => sanitize_text_field($state['STA_name']),
1126
-                    'STA_active' => (bool) absint($state['STA_active']),
1127
-                );
1128
-                // where values
1129
-                $where_cols_n_values = array(array('STA_ID' => $STA_ID));
1130
-                // run the update
1131
-                $success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
1132
-                if ($success !== false) {
1133
-                    do_action(
1134
-                        'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
1135
-                        $CNT_ISO,
1136
-                        $STA_ID,
1137
-                        $cols_n_values
1138
-                    );
1139
-                }
1140
-            }
1141
-        }
1142
-        // check if country being edited matches org option country, and if so, then  update EE_Config with new settings
1143
-        if (isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
1144
-            && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO
1145
-        ) {
1146
-            EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
1147
-            EE_Registry::instance()->CFG->update_espresso_config();
1148
-        }
1149
-
1150
-        if ($success !== false) {
1151
-            EE_Error::add_success(
1152
-                esc_html__('Country Settings updated successfully.', 'event_espresso')
1153
-            );
1154
-        }
1155
-        $this->_redirect_after_action(
1156
-            $success,
1157
-            '',
1158
-            '',
1159
-            array('action' => 'country_settings', 'country' => $CNT_ISO),
1160
-            true
1161
-        );
1162
-    }
1163
-
1164
-
1165
-    /**
1166
-     *        form_form_field_label_wrap
1167
-     *
1168
-     * @access        public
1169
-     * @param        string $label
1170
-     * @return        string
1171
-     */
1172
-    public function country_form_field_label_wrap($label, $required_text)
1173
-    {
1174
-        return '
24
+	/**
25
+	 * _question_group
26
+	 * holds the specific question group object for the question group details screen
27
+	 *
28
+	 * @var object
29
+	 */
30
+	protected $_question_group;
31
+
32
+
33
+	/**
34
+	 * Initialize basic properties.
35
+	 */
36
+	protected function _init_page_props()
37
+	{
38
+		$this->page_slug = GEN_SET_PG_SLUG;
39
+		$this->page_label = GEN_SET_LABEL;
40
+		$this->_admin_base_url = GEN_SET_ADMIN_URL;
41
+		$this->_admin_base_path = GEN_SET_ADMIN;
42
+	}
43
+
44
+
45
+	/**
46
+	 * Set ajax hooks
47
+	 */
48
+	protected function _ajax_hooks()
49
+	{
50
+		add_action('wp_ajax_espresso_display_country_settings', array($this, 'display_country_settings'));
51
+		add_action('wp_ajax_espresso_display_country_states', array($this, 'display_country_states'));
52
+		add_action('wp_ajax_espresso_delete_state', array($this, 'delete_state'), 10, 3);
53
+		add_action('wp_ajax_espresso_add_new_state', array($this, 'add_new_state'));
54
+	}
55
+
56
+
57
+	/**
58
+	 * More page properties initialization.
59
+	 */
60
+	protected function _define_page_props()
61
+	{
62
+		$this->_admin_page_title = GEN_SET_LABEL;
63
+		$this->_labels = array(
64
+			'publishbox' => __('Update Settings', 'event_espresso'),
65
+		);
66
+	}
67
+
68
+
69
+	/**
70
+	 * Set page routes property.
71
+	 */
72
+	protected function _set_page_routes()
73
+	{
74
+		$this->_page_routes = array(
75
+
76
+			'critical_pages'                => array(
77
+				'func'       => '_espresso_page_settings',
78
+				'capability' => 'manage_options',
79
+			),
80
+			'update_espresso_page_settings' => array(
81
+				'func'       => '_update_espresso_page_settings',
82
+				'capability' => 'manage_options',
83
+				'noheader'   => true,
84
+			),
85
+			'default'                       => array(
86
+				'func'       => '_your_organization_settings',
87
+				'capability' => 'manage_options',
88
+			),
89
+
90
+			'update_your_organization_settings' => array(
91
+				'func'       => '_update_your_organization_settings',
92
+				'capability' => 'manage_options',
93
+				'noheader'   => true,
94
+			),
95
+
96
+			'admin_option_settings' => array(
97
+				'func'       => '_admin_option_settings',
98
+				'capability' => 'manage_options',
99
+			),
100
+
101
+			'update_admin_option_settings' => array(
102
+				'func'       => '_update_admin_option_settings',
103
+				'capability' => 'manage_options',
104
+				'noheader'   => true,
105
+			),
106
+
107
+			'country_settings' => array(
108
+				'func'       => '_country_settings',
109
+				'capability' => 'manage_options',
110
+			),
111
+
112
+			'update_country_settings' => array(
113
+				'func'       => '_update_country_settings',
114
+				'capability' => 'manage_options',
115
+				'noheader'   => true,
116
+			),
117
+
118
+			'display_country_settings' => array(
119
+				'func'       => 'display_country_settings',
120
+				'capability' => 'manage_options',
121
+				'noheader'   => true,
122
+			),
123
+
124
+			'add_new_state' => array(
125
+				'func'       => 'add_new_state',
126
+				'capability' => 'manage_options',
127
+				'noheader'   => true,
128
+			),
129
+
130
+			'delete_state' => array(
131
+				'func'       => 'delete_state',
132
+				'capability' => 'manage_options',
133
+				'noheader'   => true,
134
+			),
135
+			'privacy_settings' => array(
136
+				'func' => 'privacySettings',
137
+				'capability' => 'manage_options',
138
+			),
139
+			'update_privacy_settings' => array(
140
+				'func' => 'updatePrivacySettings',
141
+				'capability' => 'manage_options',
142
+				'noheader' => true,
143
+				'headers_sent_route' => 'privacy_settings'
144
+			)
145
+		);
146
+	}
147
+
148
+
149
+	/**
150
+	 * Set page configuration property
151
+	 */
152
+	protected function _set_page_config()
153
+	{
154
+		$this->_page_config = array(
155
+			'critical_pages'        => array(
156
+				'nav'           => array(
157
+					'label' => __('Critical Pages', 'event_espresso'),
158
+					'order' => 50,
159
+				),
160
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
161
+				'help_tabs'     => array(
162
+					'general_settings_critical_pages_help_tab' => array(
163
+						'title'    => __('Critical Pages', 'event_espresso'),
164
+						'filename' => 'general_settings_critical_pages',
165
+					),
166
+				),
167
+				'help_tour'     => array('Critical_Pages_Help_Tour'),
168
+				'require_nonce' => false,
169
+			),
170
+			'default'               => array(
171
+				'nav'           => array(
172
+					'label' => __('Your Organization', 'event_espresso'),
173
+					'order' => 20,
174
+				),
175
+				'help_tabs'     => array(
176
+					'general_settings_your_organization_help_tab' => array(
177
+						'title'    => __('Your Organization', 'event_espresso'),
178
+						'filename' => 'general_settings_your_organization',
179
+					),
180
+				),
181
+				'help_tour'     => array('Your_Organization_Help_Tour'),
182
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
183
+				'require_nonce' => false,
184
+			),
185
+			'admin_option_settings' => array(
186
+				'nav'           => array(
187
+					'label' => __('Admin Options', 'event_espresso'),
188
+					'order' => 60,
189
+				),
190
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
191
+				'help_tabs'     => array(
192
+					'general_settings_admin_options_help_tab' => array(
193
+						'title'    => __('Admin Options', 'event_espresso'),
194
+						'filename' => 'general_settings_admin_options',
195
+					),
196
+				),
197
+				'help_tour'     => array('Admin_Options_Help_Tour'),
198
+				'require_nonce' => false,
199
+			),
200
+			'country_settings'      => array(
201
+				'nav'           => array(
202
+					'label' => __('Countries', 'event_espresso'),
203
+					'order' => 70,
204
+				),
205
+				'help_tabs'     => array(
206
+					'general_settings_countries_help_tab' => array(
207
+						'title'    => __('Countries', 'event_espresso'),
208
+						'filename' => 'general_settings_countries',
209
+					),
210
+				),
211
+				'help_tour'     => array('Countries_Help_Tour'),
212
+				'require_nonce' => false,
213
+			),
214
+			'privacy_settings' => array(
215
+				'nav' => array(
216
+					'label' => esc_html__('Privacy', 'event_espresso'),
217
+					'order' => 80
218
+				),
219
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
220
+				'require_nonce' => false
221
+			)
222
+		);
223
+	}
224
+
225
+
226
+	protected function _add_screen_options()
227
+	{
228
+	}
229
+
230
+	protected function _add_feature_pointers()
231
+	{
232
+	}
233
+
234
+
235
+	/**
236
+	 * Enqueue global scripts and styles for all routes in the General Settings Admin Pages.
237
+	 */
238
+	public function load_scripts_styles()
239
+	{
240
+		// styles
241
+		wp_enqueue_style('espresso-ui-theme');
242
+		// scripts
243
+		wp_enqueue_script('ee_admin_js');
244
+	}
245
+
246
+
247
+	/**
248
+	 * Execute logic running on `admin_init`
249
+	 */
250
+	public function admin_init()
251
+	{
252
+		EE_Registry::$i18n_js_strings['invalid_server_response'] = __(
253
+			'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.',
254
+			'event_espresso'
255
+		);
256
+		EE_Registry::$i18n_js_strings['error_occurred'] = __(
257
+			'An error occurred! Please refresh the page and try again.',
258
+			'event_espresso'
259
+		);
260
+		EE_Registry::$i18n_js_strings['confirm_delete_state'] = __(
261
+			'Are you sure you want to delete this State / Province?',
262
+			'event_espresso'
263
+		);
264
+		$protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
265
+		EE_Registry::$i18n_js_strings['ajax_url'] = admin_url(
266
+			'admin-ajax.php?page=espresso_general_settings',
267
+			$protocol
268
+		);
269
+	}
270
+
271
+	public function admin_notices()
272
+	{
273
+	}
274
+
275
+	public function admin_footer_scripts()
276
+	{
277
+	}
278
+
279
+
280
+	/**
281
+	 * Enqueue scripts and styles for the default route.
282
+	 */
283
+	public function load_scripts_styles_default()
284
+	{
285
+		// styles
286
+		wp_enqueue_style('thickbox');
287
+		// scripts
288
+		wp_enqueue_script('media-upload');
289
+		wp_enqueue_script('thickbox');
290
+		wp_register_script(
291
+			'organization_settings',
292
+			GEN_SET_ASSETS_URL . 'your_organization_settings.js',
293
+			array('jquery', 'media-upload', 'thickbox'),
294
+			EVENT_ESPRESSO_VERSION,
295
+			true
296
+		);
297
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
298
+		wp_enqueue_script('organization_settings');
299
+		wp_enqueue_style('organization-css');
300
+		$confirm_image_delete = array(
301
+			'text' => __(
302
+				'Do you really want to delete this image? Please remember to save your settings to complete the removal.',
303
+				'event_espresso'
304
+			),
305
+		);
306
+		wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
307
+	}
308
+
309
+
310
+	/**
311
+	 * Enqueue scripts and styles for the country settings route.
312
+	 */
313
+	public function load_scripts_styles_country_settings()
314
+	{
315
+		// scripts
316
+		wp_register_script(
317
+			'gen_settings_countries',
318
+			GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
319
+			array('ee_admin_js'),
320
+			EVENT_ESPRESSO_VERSION,
321
+			true
322
+		);
323
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
324
+		wp_enqueue_script('gen_settings_countries');
325
+		wp_enqueue_style('organization-css');
326
+	}
327
+
328
+
329
+	/*************        Espresso Pages        *************/
330
+	/**
331
+	 * _espresso_page_settings
332
+	 *
333
+	 * @throws \EE_Error
334
+	 * @throws DomainException
335
+	 * @throws DomainException
336
+	 * @throws InvalidDataTypeException
337
+	 * @throws InvalidArgumentException
338
+	 */
339
+	protected function _espresso_page_settings()
340
+	{
341
+		// Check to make sure all of the main pages are setup properly,
342
+		// if not create the default pages and display an admin notice
343
+		EEH_Activation::verify_default_pages_exist();
344
+		$this->_transient_garbage_collection();
345
+		$this->_template_args['values'] = $this->_yes_no_values;
346
+		$this->_template_args['reg_page_id'] = isset(EE_Registry::instance()->CFG->core->reg_page_id)
347
+			? EE_Registry::instance()->CFG->core->reg_page_id
348
+			: null;
349
+		$this->_template_args['reg_page_obj'] = isset(EE_Registry::instance()->CFG->core->reg_page_id)
350
+			? get_page(EE_Registry::instance()->CFG->core->reg_page_id)
351
+			: false;
352
+		$this->_template_args['txn_page_id'] = isset(EE_Registry::instance()->CFG->core->txn_page_id)
353
+			? EE_Registry::instance()->CFG->core->txn_page_id
354
+			: null;
355
+		$this->_template_args['txn_page_obj'] = isset(EE_Registry::instance()->CFG->core->txn_page_id)
356
+			? get_page(EE_Registry::instance()->CFG->core->txn_page_id)
357
+			: false;
358
+		$this->_template_args['thank_you_page_id'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id)
359
+			? EE_Registry::instance()->CFG->core->thank_you_page_id
360
+			: null;
361
+		$this->_template_args['thank_you_page_obj'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id)
362
+			? get_page(EE_Registry::instance()->CFG->core->thank_you_page_id)
363
+			: false;
364
+		$this->_template_args['cancel_page_id'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id)
365
+			? EE_Registry::instance()->CFG->core->cancel_page_id
366
+			: null;
367
+		$this->_template_args['cancel_page_obj'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id)
368
+			? get_page(EE_Registry::instance()->CFG->core->cancel_page_id)
369
+			: false;
370
+		$this->_set_add_edit_form_tags('update_espresso_page_settings');
371
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
372
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
373
+			GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
374
+			$this->_template_args,
375
+			true
376
+		);
377
+		$this->display_admin_page_with_sidebar();
378
+	}
379
+
380
+
381
+	/**
382
+	 * Handler for updating espresso page settings.
383
+	 *
384
+	 * @throws EE_Error
385
+	 */
386
+	protected function _update_espresso_page_settings()
387
+	{
388
+		// capture incoming request data && set page IDs
389
+		EE_Registry::instance()->CFG->core->reg_page_id = isset($this->_req_data['reg_page_id'])
390
+			? absint($this->_req_data['reg_page_id'])
391
+			: EE_Registry::instance()->CFG->core->reg_page_id;
392
+		EE_Registry::instance()->CFG->core->txn_page_id = isset($this->_req_data['txn_page_id'])
393
+			? absint($this->_req_data['txn_page_id'])
394
+			: EE_Registry::instance()->CFG->core->txn_page_id;
395
+		EE_Registry::instance()->CFG->core->thank_you_page_id = isset($this->_req_data['thank_you_page_id'])
396
+			? absint($this->_req_data['thank_you_page_id'])
397
+			: EE_Registry::instance()->CFG->core->thank_you_page_id;
398
+		EE_Registry::instance()->CFG->core->cancel_page_id = isset($this->_req_data['cancel_page_id'])
399
+			? absint($this->_req_data['cancel_page_id'])
400
+			: EE_Registry::instance()->CFG->core->cancel_page_id;
401
+
402
+		EE_Registry::instance()->CFG->core = apply_filters(
403
+			'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core',
404
+			EE_Registry::instance()->CFG->core,
405
+			$this->_req_data
406
+		);
407
+		$what = __('Critical Pages & Shortcodes', 'event_espresso');
408
+		$this->_redirect_after_action(
409
+			$this->_update_espresso_configuration(
410
+				$what,
411
+				EE_Registry::instance()->CFG->core,
412
+				__FILE__,
413
+				__FUNCTION__,
414
+				__LINE__
415
+			),
416
+			$what,
417
+			'',
418
+			array(
419
+				'action' => 'critical_pages',
420
+			),
421
+			true
422
+		);
423
+	}
424
+
425
+
426
+	/*************        Your Organization        *************/
427
+
428
+
429
+	/**
430
+	 * @throws DomainException
431
+	 * @throws EE_Error
432
+	 * @throws InvalidArgumentException
433
+	 * @throws InvalidDataTypeException
434
+	 * @throws InvalidInterfaceException
435
+	 */
436
+	protected function _your_organization_settings()
437
+	{
438
+		$this->_template_args['admin_page_content'] = '';
439
+		try {
440
+			/** @var EventEspresso\admin_pages\general_settings\OrganizationSettings $organization_settings_form */
441
+			$organization_settings_form = $this->loader->getShared(
442
+				'EventEspresso\admin_pages\general_settings\OrganizationSettings'
443
+			);
444
+			$this->_template_args['admin_page_content'] = $organization_settings_form->display();
445
+		} catch (Exception $e) {
446
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
447
+		}
448
+		$this->_set_add_edit_form_tags('update_your_organization_settings');
449
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
450
+		$this->display_admin_page_with_sidebar();
451
+	}
452
+
453
+
454
+
455
+	/**
456
+	 * Handler for updating organization settings.
457
+	 *
458
+	 * @throws EE_Error
459
+	 */
460
+	protected function _update_your_organization_settings()
461
+	{
462
+		try {
463
+			/** @var EventEspresso\admin_pages\general_settings\OrganizationSettings $organization_settings_form */
464
+			$organization_settings_form = $this->loader->getShared(
465
+				'EventEspresso\admin_pages\general_settings\OrganizationSettings'
466
+			);
467
+			$success = $organization_settings_form->process($this->_req_data);
468
+			EE_Registry::instance()->CFG = apply_filters(
469
+				'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG',
470
+				EE_Registry::instance()->CFG
471
+			);
472
+		} catch (Exception $e) {
473
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
474
+			$success = false;
475
+		}
476
+
477
+		if ($success) {
478
+			$success = $this->_update_espresso_configuration(
479
+				esc_html__('Your Organization Settings', 'event_espresso'),
480
+				EE_Registry::instance()->CFG,
481
+				__FILE__,
482
+				__FUNCTION__,
483
+				__LINE__
484
+			);
485
+		}
486
+
487
+		$this->_redirect_after_action($success, '', '', array('action' => 'default'), true);
488
+	}
489
+
490
+
491
+
492
+	/*************        Admin Options        *************/
493
+
494
+
495
+	/**
496
+	 * _admin_option_settings
497
+	 *
498
+	 * @throws \EE_Error
499
+	 * @throws \LogicException
500
+	 */
501
+	protected function _admin_option_settings()
502
+	{
503
+		$this->_template_args['admin_page_content'] = '';
504
+		try {
505
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
506
+			// still need this for the old school form in Extend_General_Settings_Admin_Page
507
+			$this->_template_args['values'] = $this->_yes_no_values;
508
+			// also need to account for the do_action that was in the old template
509
+			$admin_options_settings_form->setTemplateArgs($this->_template_args);
510
+			$this->_template_args['admin_page_content'] = $admin_options_settings_form->display();
511
+		} catch (Exception $e) {
512
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
513
+		}
514
+		$this->_set_add_edit_form_tags('update_admin_option_settings');
515
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
516
+		$this->display_admin_page_with_sidebar();
517
+	}
518
+
519
+
520
+	/**
521
+	 * _update_admin_option_settings
522
+	 *
523
+	 * @throws \EE_Error
524
+	 * @throws InvalidDataTypeException
525
+	 * @throws \EventEspresso\core\exceptions\InvalidFormSubmissionException
526
+	 * @throws \InvalidArgumentException
527
+	 * @throws \LogicException
528
+	 */
529
+	protected function _update_admin_option_settings()
530
+	{
531
+		try {
532
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
533
+			$admin_options_settings_form->process($this->_req_data[ $admin_options_settings_form->slug() ]);
534
+			EE_Registry::instance()->CFG->admin = apply_filters(
535
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
536
+				EE_Registry::instance()->CFG->admin
537
+			);
538
+		} catch (Exception $e) {
539
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
540
+		}
541
+		$this->_redirect_after_action(
542
+			apply_filters(
543
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
544
+				$this->_update_espresso_configuration(
545
+					'Admin Options',
546
+					EE_Registry::instance()->CFG->admin,
547
+					__FILE__,
548
+					__FUNCTION__,
549
+					__LINE__
550
+				)
551
+			),
552
+			'Admin Options',
553
+			'updated',
554
+			array('action' => 'admin_option_settings')
555
+		);
556
+	}
557
+
558
+
559
+	/*************        Countries        *************/
560
+
561
+
562
+	/**
563
+	 * @return string
564
+	 */
565
+	protected function getCountryIsoForSite()
566
+	{
567
+		return ! empty(EE_Registry::instance()->CFG->organization->CNT_ISO)
568
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
569
+			: 'US';
570
+	}
571
+
572
+
573
+
574
+	/**
575
+	 * Output Country Settings view.
576
+	 *
577
+	 * @throws DomainException
578
+	 * @throws EE_Error
579
+	 */
580
+	protected function _country_settings()
581
+	{
582
+		$CNT_ISO_for_site = $this->getCountryIsoForSite();
583
+		$CNT_ISO = isset($this->_req_data['country'])
584
+			? strtoupper(sanitize_text_field($this->_req_data['country']))
585
+			: $CNT_ISO_for_site;
586
+
587
+		// load field generator helper
588
+
589
+		$this->_template_args['values'] = $this->_yes_no_values;
590
+
591
+		$this->_template_args['countries'] = new EE_Question_Form_Input(
592
+			EE_Question::new_instance(
593
+				array(
594
+					'QST_ID'           => 0,
595
+					'QST_display_text' => __('Select Country', 'event_espresso'),
596
+					'QST_system'       => 'admin-country',
597
+				)
598
+			),
599
+			EE_Answer::new_instance(
600
+				array(
601
+					'ANS_ID'    => 0,
602
+					'ANS_value' => $CNT_ISO,
603
+				)
604
+			),
605
+			array(
606
+				'input_id'       => 'country',
607
+				'input_name'     => 'country',
608
+				'input_prefix'   => '',
609
+				'append_qstn_id' => false,
610
+			)
611
+		);
612
+
613
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
614
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
615
+		$this->_template_args['country_details_settings'] = $this->display_country_settings();
616
+		$this->_template_args['country_states_settings'] = $this->display_country_states();
617
+		$this->_template_args['CNT_name_for_site'] = EEM_Country::instance()->get_one_by_ID($CNT_ISO_for_site)
618
+																			->name();
619
+
620
+		$this->_set_add_edit_form_tags('update_country_settings');
621
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
622
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
623
+			GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
624
+			$this->_template_args,
625
+			true
626
+		);
627
+		$this->display_admin_page_with_no_sidebar();
628
+	}
629
+
630
+
631
+	/**
632
+	 *        display_country_settings
633
+	 *
634
+	 * @access    public
635
+	 * @param    string $CNT_ISO
636
+	 * @return mixed string | array
637
+	 * @throws DomainException
638
+	 */
639
+	public function display_country_settings($CNT_ISO = '')
640
+	{
641
+		$CNT_ISO_for_site = $this->getCountryIsoForSite();
642
+
643
+		$CNT_ISO = isset($this->_req_data['country'])
644
+			? strtoupper(sanitize_text_field($this->_req_data['country']))
645
+			: $CNT_ISO;
646
+		if (! $CNT_ISO) {
647
+			return '';
648
+		}
649
+
650
+		// for ajax
651
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
652
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
653
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
654
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
655
+		/** @var EE_Country $country */
656
+		$country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
657
+
658
+		$CNT_cur_disabled = $CNT_ISO !== $CNT_ISO_for_site;
659
+		$this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled;
660
+
661
+		$country_input_types = array(
662
+			'CNT_active'      => array(
663
+				'type'             => 'RADIO_BTN',
664
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
665
+				'class'            => '',
666
+				'options'          => $this->_yes_no_values,
667
+				'use_desc_4_label' => true,
668
+			),
669
+			'CNT_ISO'         => array(
670
+				'type'       => 'TEXT',
671
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
672
+				'class'      => 'small-text',
673
+			),
674
+			'CNT_ISO3'        => array(
675
+				'type'       => 'TEXT',
676
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
677
+				'class'      => 'small-text',
678
+			),
679
+			'RGN_ID'          => array(
680
+				'type'       => 'TEXT',
681
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
682
+				'class'      => 'small-text',
683
+			),
684
+			'CNT_name'        => array(
685
+				'type'       => 'TEXT',
686
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
687
+				'class'      => 'regular-text',
688
+			),
689
+			'CNT_cur_code'    => array(
690
+				'type'       => 'TEXT',
691
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
692
+				'class'      => 'small-text',
693
+				'disabled'   => $CNT_cur_disabled
694
+			),
695
+			'CNT_cur_single'  => array(
696
+				'type'       => 'TEXT',
697
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
698
+				'class'      => 'medium-text',
699
+				'disabled' => $CNT_cur_disabled
700
+			),
701
+			'CNT_cur_plural'  => array(
702
+				'type'       => 'TEXT',
703
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
704
+				'class'      => 'medium-text',
705
+				'disabled' => $CNT_cur_disabled
706
+			),
707
+			'CNT_cur_sign'    => array(
708
+				'type'         => 'TEXT',
709
+				'input_name'   => 'cntry[' . $CNT_ISO . ']',
710
+				'class'        => 'small-text',
711
+				'htmlentities' => false,
712
+				'disabled' => $CNT_cur_disabled
713
+			),
714
+			'CNT_cur_sign_b4' => array(
715
+				'type'             => 'RADIO_BTN',
716
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
717
+				'class'            => '',
718
+				'options'          => $this->_yes_no_values,
719
+				'use_desc_4_label' => true,
720
+				'disabled' => $CNT_cur_disabled
721
+			),
722
+			'CNT_cur_dec_plc' => array(
723
+				'type'       => 'RADIO_BTN',
724
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
725
+				'class'      => '',
726
+				'options'    => array(
727
+					array('id' => 0, 'text' => ''),
728
+					array('id' => 1, 'text' => ''),
729
+					array('id' => 2, 'text' => ''),
730
+					array('id' => 3, 'text' => ''),
731
+				),
732
+				'disabled' => $CNT_cur_disabled
733
+			),
734
+			'CNT_cur_dec_mrk' => array(
735
+				'type'             => 'RADIO_BTN',
736
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
737
+				'class'            => '',
738
+				'options'          => array(
739
+					array(
740
+						'id'   => ',',
741
+						'text' => __(', (comma)', 'event_espresso'),
742
+					),
743
+					array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')),
744
+				),
745
+				'use_desc_4_label' => true,
746
+				'disabled' => $CNT_cur_disabled
747
+			),
748
+			'CNT_cur_thsnds'  => array(
749
+				'type'             => 'RADIO_BTN',
750
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
751
+				'class'            => '',
752
+				'options'          => array(
753
+					array(
754
+						'id'   => ',',
755
+						'text' => __(', (comma)', 'event_espresso'),
756
+					),
757
+					array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')),
758
+				),
759
+				'use_desc_4_label' => true,
760
+				'disabled' => $CNT_cur_disabled
761
+			),
762
+			'CNT_tel_code'    => array(
763
+				'type'       => 'TEXT',
764
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
765
+				'class'      => 'small-text',
766
+			),
767
+			'CNT_is_EU'       => array(
768
+				'type'             => 'RADIO_BTN',
769
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
770
+				'class'            => '',
771
+				'options'          => $this->_yes_no_values,
772
+				'use_desc_4_label' => true,
773
+			),
774
+		);
775
+		$this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object(
776
+			$country,
777
+			$country_input_types
778
+		);
779
+		$country_details_settings = EEH_Template::display_template(
780
+			GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
781
+			$this->_template_args,
782
+			true
783
+		);
784
+
785
+		if (defined('DOING_AJAX')) {
786
+			$notices = EE_Error::get_notices(false, false, false);
787
+			echo wp_json_encode(
788
+				array(
789
+					'return_data' => $country_details_settings,
790
+					'success'     => $notices['success'],
791
+					'errors'      => $notices['errors'],
792
+				)
793
+			);
794
+			die();
795
+		} else {
796
+			return $country_details_settings;
797
+		}
798
+	}
799
+
800
+
801
+	/**
802
+	 *        display_country_states
803
+	 *
804
+	 * @access    public
805
+	 * @param    string $CNT_ISO
806
+	 * @return string
807
+	 * @throws DomainException
808
+	 */
809
+	public function display_country_states($CNT_ISO = '')
810
+	{
811
+
812
+		$CNT_ISO = isset($this->_req_data['country']) ? sanitize_text_field($this->_req_data['country']) : $CNT_ISO;
813
+
814
+		if (! $CNT_ISO) {
815
+			return '';
816
+		}
817
+		// for ajax
818
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
819
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
820
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'state_form_field_label_wrap'), 10, 2);
821
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'state_form_field_input__wrap'), 10, 2);
822
+		$states = EEM_State::instance()->get_all_states_for_these_countries(array($CNT_ISO => $CNT_ISO));
823
+
824
+		if ($states) {
825
+			foreach ($states as $STA_ID => $state) {
826
+				if ($state instanceof EE_State) {
827
+					// STA_abbrev    STA_name    STA_active
828
+					$state_input_types = array(
829
+						'STA_abbrev' => array(
830
+							'type'       => 'TEXT',
831
+							'input_name' => 'states[' . $STA_ID . ']',
832
+							'class'      => 'mid-text',
833
+						),
834
+						'STA_name'   => array(
835
+							'type'       => 'TEXT',
836
+							'input_name' => 'states[' . $STA_ID . ']',
837
+							'class'      => 'regular-text',
838
+						),
839
+						'STA_active' => array(
840
+							'type'             => 'RADIO_BTN',
841
+							'input_name'       => 'states[' . $STA_ID . ']',
842
+							'options'          => $this->_yes_no_values,
843
+							'use_desc_4_label' => true,
844
+						),
845
+					);
846
+					$this->_template_args['states'][ $STA_ID ]['inputs'] =
847
+						EE_Question_Form_Input::generate_question_form_inputs_for_object(
848
+							$state,
849
+							$state_input_types
850
+						);
851
+					$query_args = array(
852
+						'action'     => 'delete_state',
853
+						'STA_ID'     => $STA_ID,
854
+						'CNT_ISO'    => $CNT_ISO,
855
+						'STA_abbrev' => $state->abbrev(),
856
+					);
857
+					$this->_template_args['states'][ $STA_ID ]['delete_state_url'] =
858
+						EE_Admin_Page::add_query_args_and_nonce(
859
+							$query_args,
860
+							GEN_SET_ADMIN_URL
861
+						);
862
+				}
863
+			}
864
+		} else {
865
+			$this->_template_args['states'] = false;
866
+		}
867
+
868
+		$this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(
869
+			array('action' => 'add_new_state'),
870
+			GEN_SET_ADMIN_URL
871
+		);
872
+
873
+		$state_details_settings = EEH_Template::display_template(
874
+			GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
875
+			$this->_template_args,
876
+			true
877
+		);
878
+
879
+		if (defined('DOING_AJAX')) {
880
+			$notices = EE_Error::get_notices(false, false, false);
881
+			echo wp_json_encode(
882
+				array(
883
+					'return_data' => $state_details_settings,
884
+					'success'     => $notices['success'],
885
+					'errors'      => $notices['errors'],
886
+				)
887
+			);
888
+			die();
889
+		} else {
890
+			return $state_details_settings;
891
+		}
892
+	}
893
+
894
+
895
+	/**
896
+	 *        add_new_state
897
+	 *
898
+	 * @access    public
899
+	 * @return void
900
+	 * @throws EE_Error
901
+	 */
902
+	public function add_new_state()
903
+	{
904
+
905
+		$success = true;
906
+
907
+		$CNT_ISO = isset($this->_req_data['CNT_ISO'])
908
+			? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
909
+			: false;
910
+		if (! $CNT_ISO) {
911
+			EE_Error::add_error(
912
+				__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
913
+				__FILE__,
914
+				__FUNCTION__,
915
+				__LINE__
916
+			);
917
+			$success = false;
918
+		}
919
+		$STA_abbrev = isset($this->_req_data['STA_abbrev'])
920
+			? sanitize_text_field($this->_req_data['STA_abbrev'])
921
+			: false;
922
+		if (! $STA_abbrev) {
923
+			EE_Error::add_error(
924
+				__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
925
+				__FILE__,
926
+				__FUNCTION__,
927
+				__LINE__
928
+			);
929
+			$success = false;
930
+		}
931
+		$STA_name = isset($this->_req_data['STA_name'])
932
+			? sanitize_text_field($this->_req_data['STA_name'])
933
+			: false;
934
+		if (! $STA_name) {
935
+			EE_Error::add_error(
936
+				__('No State name or an invalid State name was received.', 'event_espresso'),
937
+				__FILE__,
938
+				__FUNCTION__,
939
+				__LINE__
940
+			);
941
+			$success = false;
942
+		}
943
+
944
+		if ($success) {
945
+			$cols_n_values = array(
946
+				'CNT_ISO'    => $CNT_ISO,
947
+				'STA_abbrev' => $STA_abbrev,
948
+				'STA_name'   => $STA_name,
949
+				'STA_active' => true,
950
+			);
951
+			$success = EEM_State::instance()->insert($cols_n_values);
952
+			EE_Error::add_success(__('The State was added successfully.', 'event_espresso'));
953
+		}
954
+
955
+		if (defined('DOING_AJAX')) {
956
+			$notices = EE_Error::get_notices(false, false, false);
957
+			echo wp_json_encode(array_merge($notices, array('return_data' => $CNT_ISO)));
958
+			die();
959
+		} else {
960
+			$this->_redirect_after_action($success, 'State', 'added', array('action' => 'country_settings'));
961
+		}
962
+	}
963
+
964
+
965
+	/**
966
+	 *        delete_state
967
+	 *
968
+	 * @access    public
969
+	 * @return        boolean
970
+	 * @throws EE_Error
971
+	 * @throws EE_Error
972
+	 */
973
+	public function delete_state()
974
+	{
975
+		$CNT_ISO = isset($this->_req_data['CNT_ISO'])
976
+			? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
977
+			: false;
978
+		$STA_ID = isset($this->_req_data['STA_ID'])
979
+			? sanitize_text_field($this->_req_data['STA_ID'])
980
+			: false;
981
+		$STA_abbrev = isset($this->_req_data['STA_abbrev'])
982
+			? sanitize_text_field($this->_req_data['STA_abbrev'])
983
+			: false;
984
+		if (! $STA_ID) {
985
+			EE_Error::add_error(
986
+				__('No State ID or an invalid State ID was received.', 'event_espresso'),
987
+				__FILE__,
988
+				__FUNCTION__,
989
+				__LINE__
990
+			);
991
+			return false;
992
+		}
993
+
994
+		$success = EEM_State::instance()->delete_by_ID($STA_ID);
995
+		if ($success !== false) {
996
+			do_action(
997
+				'AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
998
+				$CNT_ISO,
999
+				$STA_ID,
1000
+				array('STA_abbrev' => $STA_abbrev)
1001
+			);
1002
+			EE_Error::add_success(__('The State was deleted successfully.', 'event_espresso'));
1003
+		}
1004
+		if (defined('DOING_AJAX')) {
1005
+			$notices = EE_Error::get_notices(false, false);
1006
+			$notices['return_data'] = true;
1007
+			echo wp_json_encode($notices);
1008
+			die();
1009
+		} else {
1010
+			$this->_redirect_after_action(
1011
+				$success,
1012
+				'State',
1013
+				'deleted',
1014
+				array('action' => 'country_settings')
1015
+			);
1016
+		}
1017
+	}
1018
+
1019
+
1020
+	/**
1021
+	 *        _update_country_settings
1022
+	 *
1023
+	 * @access    protected
1024
+	 * @return void
1025
+	 * @throws EE_Error
1026
+	 */
1027
+	protected function _update_country_settings()
1028
+	{
1029
+		// grab the country ISO code
1030
+		$CNT_ISO = isset($this->_req_data['country'])
1031
+			? strtoupper(sanitize_text_field($this->_req_data['country']))
1032
+			: false;
1033
+		if (! $CNT_ISO) {
1034
+			EE_Error::add_error(
1035
+				__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1036
+				__FILE__,
1037
+				__FUNCTION__,
1038
+				__LINE__
1039
+			);
1040
+
1041
+			return;
1042
+		}
1043
+		$cols_n_values = array();
1044
+		$cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3'])
1045
+			? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3']))
1046
+			: false;
1047
+		$cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID'])
1048
+			? absint($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID'])
1049
+			: null;
1050
+		$cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name'])
1051
+			? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name'])
1052
+			: null;
1053
+		if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])) {
1054
+			$cols_n_values['CNT_cur_code'] = strtoupper(
1055
+				sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])
1056
+			);
1057
+		}
1058
+		if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single'])) {
1059
+			$cols_n_values['CNT_cur_single'] = sanitize_text_field(
1060
+				$this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single']
1061
+			);
1062
+		}
1063
+		if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural'])) {
1064
+			$cols_n_values['CNT_cur_plural'] = sanitize_text_field(
1065
+				$this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural']
1066
+			);
1067
+		}
1068
+		if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign'])) {
1069
+			$cols_n_values['CNT_cur_sign'] = sanitize_text_field(
1070
+				$this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign']
1071
+			);
1072
+		}
1073
+		if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4'])) {
1074
+			$cols_n_values['CNT_cur_sign_b4'] = absint(
1075
+				$this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4']
1076
+			);
1077
+		}
1078
+		if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc'])) {
1079
+			$cols_n_values['CNT_cur_dec_plc'] = absint(
1080
+				$this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc']
1081
+			);
1082
+		}
1083
+		if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk'])) {
1084
+			$cols_n_values['CNT_cur_dec_mrk'] = sanitize_text_field(
1085
+				$this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk']
1086
+			);
1087
+		}
1088
+		if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds'])) {
1089
+			$cols_n_values['CNT_cur_thsnds'] = sanitize_text_field(
1090
+				$this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds']
1091
+			);
1092
+		}
1093
+		$cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code'])
1094
+			? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code'])
1095
+			: null;
1096
+		$cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU'])
1097
+			? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU'])
1098
+			: false;
1099
+		$cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active'])
1100
+			? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active'])
1101
+			: false;
1102
+		// allow filtering of country data
1103
+		$cols_n_values = apply_filters(
1104
+			'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values',
1105
+			$cols_n_values
1106
+		);
1107
+
1108
+		// where values
1109
+		$where_cols_n_values = array(array('CNT_ISO' => $CNT_ISO));
1110
+		// run the update
1111
+		$success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
1112
+
1113
+		if (isset($this->_req_data['states']) && is_array($this->_req_data['states']) && $success !== false) {
1114
+			// allow filtering of states data
1115
+			$states = apply_filters(
1116
+				'FHEE__General_Settings_Admin_Page___update_country_settings__states',
1117
+				$this->_req_data['states']
1118
+			);
1119
+
1120
+			// loop thru state data ( looks like : states[75][STA_name] )
1121
+			foreach ($states as $STA_ID => $state) {
1122
+				$cols_n_values = array(
1123
+					'CNT_ISO'    => $CNT_ISO,
1124
+					'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
1125
+					'STA_name'   => sanitize_text_field($state['STA_name']),
1126
+					'STA_active' => (bool) absint($state['STA_active']),
1127
+				);
1128
+				// where values
1129
+				$where_cols_n_values = array(array('STA_ID' => $STA_ID));
1130
+				// run the update
1131
+				$success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
1132
+				if ($success !== false) {
1133
+					do_action(
1134
+						'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
1135
+						$CNT_ISO,
1136
+						$STA_ID,
1137
+						$cols_n_values
1138
+					);
1139
+				}
1140
+			}
1141
+		}
1142
+		// check if country being edited matches org option country, and if so, then  update EE_Config with new settings
1143
+		if (isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
1144
+			&& $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO
1145
+		) {
1146
+			EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
1147
+			EE_Registry::instance()->CFG->update_espresso_config();
1148
+		}
1149
+
1150
+		if ($success !== false) {
1151
+			EE_Error::add_success(
1152
+				esc_html__('Country Settings updated successfully.', 'event_espresso')
1153
+			);
1154
+		}
1155
+		$this->_redirect_after_action(
1156
+			$success,
1157
+			'',
1158
+			'',
1159
+			array('action' => 'country_settings', 'country' => $CNT_ISO),
1160
+			true
1161
+		);
1162
+	}
1163
+
1164
+
1165
+	/**
1166
+	 *        form_form_field_label_wrap
1167
+	 *
1168
+	 * @access        public
1169
+	 * @param        string $label
1170
+	 * @return        string
1171
+	 */
1172
+	public function country_form_field_label_wrap($label, $required_text)
1173
+	{
1174
+		return '
1175 1175
 			<tr>
1176 1176
 				<th>
1177 1177
 					' . $label . '
1178 1178
 				</th>';
1179
-    }
1180
-
1181
-
1182
-    /**
1183
-     *        form_form_field_input__wrap
1184
-     *
1185
-     * @access        public
1186
-     * @param        string $label
1187
-     * @return        string
1188
-     */
1189
-    public function country_form_field_input__wrap($input, $label)
1190
-    {
1191
-        return '
1179
+	}
1180
+
1181
+
1182
+	/**
1183
+	 *        form_form_field_input__wrap
1184
+	 *
1185
+	 * @access        public
1186
+	 * @param        string $label
1187
+	 * @return        string
1188
+	 */
1189
+	public function country_form_field_input__wrap($input, $label)
1190
+	{
1191
+		return '
1192 1192
 				<td class="general-settings-country-input-td">
1193 1193
 					' . $input . '
1194 1194
 				</td>
1195 1195
 			</tr>';
1196
-    }
1197
-
1198
-
1199
-    /**
1200
-     *        form_form_field_label_wrap
1201
-     *
1202
-     * @access        public
1203
-     * @param        string $label
1204
-     * @param        string $required_text
1205
-     * @return        string
1206
-     */
1207
-    public function state_form_field_label_wrap($label, $required_text)
1208
-    {
1209
-        return $required_text;
1210
-    }
1211
-
1212
-
1213
-    /**
1214
-     *        form_form_field_input__wrap
1215
-     *
1216
-     * @access        public
1217
-     * @param        string $label
1218
-     * @return        string
1219
-     */
1220
-    public function state_form_field_input__wrap($input, $label)
1221
-    {
1222
-        return '
1196
+	}
1197
+
1198
+
1199
+	/**
1200
+	 *        form_form_field_label_wrap
1201
+	 *
1202
+	 * @access        public
1203
+	 * @param        string $label
1204
+	 * @param        string $required_text
1205
+	 * @return        string
1206
+	 */
1207
+	public function state_form_field_label_wrap($label, $required_text)
1208
+	{
1209
+		return $required_text;
1210
+	}
1211
+
1212
+
1213
+	/**
1214
+	 *        form_form_field_input__wrap
1215
+	 *
1216
+	 * @access        public
1217
+	 * @param        string $label
1218
+	 * @return        string
1219
+	 */
1220
+	public function state_form_field_input__wrap($input, $label)
1221
+	{
1222
+		return '
1223 1223
 				<td class="general-settings-country-state-input-td">
1224 1224
 					' . $input . '
1225 1225
 				</td>';
1226
-    }
1227
-
1228
-
1229
-    /***********/
1230
-
1231
-
1232
-    /**
1233
-     * displays edit and view links for critical EE pages
1234
-     *
1235
-     * @access public
1236
-     * @param int $ee_page_id
1237
-     * @return string
1238
-     */
1239
-    public static function edit_view_links($ee_page_id)
1240
-    {
1241
-        $links = '<a href="'
1242
-                 . add_query_arg(
1243
-                     array('post' => $ee_page_id, 'action' => 'edit'),
1244
-                     admin_url('post.php')
1245
-                 )
1246
-                 . '" >'
1247
-                 . __('Edit', 'event_espresso')
1248
-                 . '</a>';
1249
-        $links .= ' &nbsp;|&nbsp; ';
1250
-        $links .= '<a href="' . get_permalink($ee_page_id) . '" >' . __('View', 'event_espresso') . '</a>';
1251
-
1252
-        return $links;
1253
-    }
1254
-
1255
-
1256
-    /**
1257
-     * displays page and shortcode status for critical EE pages
1258
-     *
1259
-     * @param WP page object $ee_page
1260
-     * @return string
1261
-     */
1262
-    public static function page_and_shortcode_status($ee_page, $shortcode)
1263
-    {
1264
-
1265
-        // page status
1266
-        if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
1267
-            $pg_colour = 'green';
1268
-            $pg_status = sprintf(__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
1269
-        } else {
1270
-            $pg_colour = 'red';
1271
-            $pg_status = sprintf(__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
1272
-        }
1273
-
1274
-        // shortcode status
1275
-        if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) {
1276
-            $sc_colour = 'green';
1277
-            $sc_status = sprintf(__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
1278
-        } else {
1279
-            $sc_colour = 'red';
1280
-            $sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1281
-        }
1282
-
1283
-        return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>'
1284
-               . $pg_status
1285
-               . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>';
1286
-    }
1287
-
1288
-
1289
-    /**
1290
-     * generates a dropdown of all parent pages - copied from WP core
1291
-     *
1292
-     * @param int $default
1293
-     * @param int $parent
1294
-     * @param int $level
1295
-     */
1296
-    public static function page_settings_dropdown($default = 0, $parent = 0, $level = 0)
1297
-    {
1298
-        global $wpdb;
1299
-        $items = $wpdb->get_results(
1300
-            $wpdb->prepare(
1301
-                "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order",
1302
-                $parent
1303
-            )
1304
-        );
1305
-
1306
-        if ($items) {
1307
-            foreach ($items as $item) {
1308
-                $pad = str_repeat('&nbsp;', $level * 3);
1309
-                if ($item->ID == $default) {
1310
-                    $current = ' selected="selected"';
1311
-                } else {
1312
-                    $current = '';
1313
-                }
1314
-
1315
-                echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad "
1316
-                     . esc_html($item->post_title)
1317
-                     . "</option>";
1318
-                parent_dropdown($default, $item->ID, $level + 1);
1319
-            }
1320
-        }
1321
-    }
1322
-
1323
-
1324
-    /**
1325
-     * Loads the scripts for the privacy settings form
1326
-     */
1327
-    public function load_scripts_styles_privacy_settings()
1328
-    {
1329
-        $form_handler = $this->loader->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler');
1330
-        $form_handler->enqueueStylesAndScripts();
1331
-    }
1332
-
1333
-
1334
-    /**
1335
-     * display the privacy settings form
1336
-     */
1337
-    public function privacySettings()
1338
-    {
1339
-        $this->_set_add_edit_form_tags('update_privacy_settings');
1340
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
1341
-        $form_handler = $this->loader->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler');
1342
-        $this->_template_args['admin_page_content'] = $form_handler->display();
1343
-        $this->display_admin_page_with_sidebar();
1344
-    }
1345
-
1346
-
1347
-    /**
1348
-     * Update the privacy settings from form data
1349
-     *
1350
-     * @throws EE_Error
1351
-     */
1352
-    public function updatePrivacySettings()
1353
-    {
1354
-        $form_handler = $this->loader->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler');
1355
-        $success = $form_handler->process($this->get_request_data());
1356
-        $this->_redirect_after_action(
1357
-            $success,
1358
-            esc_html__('Registration Form Options', 'event_espresso'),
1359
-            'updated',
1360
-            array('action' => 'privacy_settings')
1361
-        );
1362
-    }
1226
+	}
1227
+
1228
+
1229
+	/***********/
1230
+
1231
+
1232
+	/**
1233
+	 * displays edit and view links for critical EE pages
1234
+	 *
1235
+	 * @access public
1236
+	 * @param int $ee_page_id
1237
+	 * @return string
1238
+	 */
1239
+	public static function edit_view_links($ee_page_id)
1240
+	{
1241
+		$links = '<a href="'
1242
+				 . add_query_arg(
1243
+					 array('post' => $ee_page_id, 'action' => 'edit'),
1244
+					 admin_url('post.php')
1245
+				 )
1246
+				 . '" >'
1247
+				 . __('Edit', 'event_espresso')
1248
+				 . '</a>';
1249
+		$links .= ' &nbsp;|&nbsp; ';
1250
+		$links .= '<a href="' . get_permalink($ee_page_id) . '" >' . __('View', 'event_espresso') . '</a>';
1251
+
1252
+		return $links;
1253
+	}
1254
+
1255
+
1256
+	/**
1257
+	 * displays page and shortcode status for critical EE pages
1258
+	 *
1259
+	 * @param WP page object $ee_page
1260
+	 * @return string
1261
+	 */
1262
+	public static function page_and_shortcode_status($ee_page, $shortcode)
1263
+	{
1264
+
1265
+		// page status
1266
+		if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
1267
+			$pg_colour = 'green';
1268
+			$pg_status = sprintf(__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
1269
+		} else {
1270
+			$pg_colour = 'red';
1271
+			$pg_status = sprintf(__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
1272
+		}
1273
+
1274
+		// shortcode status
1275
+		if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) {
1276
+			$sc_colour = 'green';
1277
+			$sc_status = sprintf(__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
1278
+		} else {
1279
+			$sc_colour = 'red';
1280
+			$sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1281
+		}
1282
+
1283
+		return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>'
1284
+			   . $pg_status
1285
+			   . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>';
1286
+	}
1287
+
1288
+
1289
+	/**
1290
+	 * generates a dropdown of all parent pages - copied from WP core
1291
+	 *
1292
+	 * @param int $default
1293
+	 * @param int $parent
1294
+	 * @param int $level
1295
+	 */
1296
+	public static function page_settings_dropdown($default = 0, $parent = 0, $level = 0)
1297
+	{
1298
+		global $wpdb;
1299
+		$items = $wpdb->get_results(
1300
+			$wpdb->prepare(
1301
+				"SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order",
1302
+				$parent
1303
+			)
1304
+		);
1305
+
1306
+		if ($items) {
1307
+			foreach ($items as $item) {
1308
+				$pad = str_repeat('&nbsp;', $level * 3);
1309
+				if ($item->ID == $default) {
1310
+					$current = ' selected="selected"';
1311
+				} else {
1312
+					$current = '';
1313
+				}
1314
+
1315
+				echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad "
1316
+					 . esc_html($item->post_title)
1317
+					 . "</option>";
1318
+				parent_dropdown($default, $item->ID, $level + 1);
1319
+			}
1320
+		}
1321
+	}
1322
+
1323
+
1324
+	/**
1325
+	 * Loads the scripts for the privacy settings form
1326
+	 */
1327
+	public function load_scripts_styles_privacy_settings()
1328
+	{
1329
+		$form_handler = $this->loader->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler');
1330
+		$form_handler->enqueueStylesAndScripts();
1331
+	}
1332
+
1333
+
1334
+	/**
1335
+	 * display the privacy settings form
1336
+	 */
1337
+	public function privacySettings()
1338
+	{
1339
+		$this->_set_add_edit_form_tags('update_privacy_settings');
1340
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
1341
+		$form_handler = $this->loader->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler');
1342
+		$this->_template_args['admin_page_content'] = $form_handler->display();
1343
+		$this->display_admin_page_with_sidebar();
1344
+	}
1345
+
1346
+
1347
+	/**
1348
+	 * Update the privacy settings from form data
1349
+	 *
1350
+	 * @throws EE_Error
1351
+	 */
1352
+	public function updatePrivacySettings()
1353
+	{
1354
+		$form_handler = $this->loader->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler');
1355
+		$success = $form_handler->process($this->get_request_data());
1356
+		$this->_redirect_after_action(
1357
+			$success,
1358
+			esc_html__('Registration Form Options', 'event_espresso'),
1359
+			'updated',
1360
+			array('action' => 'privacy_settings')
1361
+		);
1362
+	}
1363 1363
 }
Please login to merge, or discard this patch.
core/domain/services/contexts/RequestTypeContextCheckerInterface.php 1 patch
Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -13,132 +13,132 @@
 block discarded – undo
13 13
 interface RequestTypeContextCheckerInterface
14 14
 {
15 15
 
16
-    /**
17
-     * true if the current request involves some form of activation
18
-     *
19
-     * @return bool
20
-     */
21
-    public function isActivation();
16
+	/**
17
+	 * true if the current request involves some form of activation
18
+	 *
19
+	 * @return bool
20
+	 */
21
+	public function isActivation();
22 22
 
23 23
 
24
-    /**
25
-     * @param $is_activation
26
-     * @return bool
27
-     */
28
-    public function setIsActivation($is_activation);
24
+	/**
25
+	 * @param $is_activation
26
+	 * @return bool
27
+	 */
28
+	public function setIsActivation($is_activation);
29 29
 
30 30
 
31
-    /**
32
-     * true if the current request is for the admin and is not being made via AJAX
33
-     *
34
-     * @return bool
35
-     */
36
-    public function isAdmin();
31
+	/**
32
+	 * true if the current request is for the admin and is not being made via AJAX
33
+	 *
34
+	 * @return bool
35
+	 */
36
+	public function isAdmin();
37 37
 
38 38
 
39
-    /**
40
-     * true if the current request is for the admin AND is being made via AJAX
41
-     * and the ajax request contains the request parameter "ee_admin_ajax"
42
-     *
43
-     * @return bool
44
-     */
45
-    public function isAdminAjax();
39
+	/**
40
+	 * true if the current request is for the admin AND is being made via AJAX
41
+	 * and the ajax request contains the request parameter "ee_admin_ajax"
42
+	 *
43
+	 * @return bool
44
+	 */
45
+	public function isAdminAjax();
46 46
 
47 47
 
48
-    /**
49
-     * true if the current request is being made via AJAX... any AJAX
50
-     *
51
-     * @return bool
52
-     */
53
-    public function isAjax();
48
+	/**
49
+	 * true if the current request is being made via AJAX... any AJAX
50
+	 *
51
+	 * @return bool
52
+	 */
53
+	public function isAjax();
54 54
 
55 55
 
56
-    /**
57
-     * true if the current request is for the EE REST API
58
-     *
59
-     * @return bool
60
-     */
61
-    public function isApi();
56
+	/**
57
+	 * true if the current request is for the EE REST API
58
+	 *
59
+	 * @return bool
60
+	 */
61
+	public function isApi();
62 62
 
63 63
 
64
-    /**
65
-     * true if the current request is from the command line
66
-     *
67
-     * @return bool
68
-     */
69
-    public function isCli();
64
+	/**
65
+	 * true if the current request is from the command line
66
+	 *
67
+	 * @return bool
68
+	 */
69
+	public function isCli();
70 70
 
71 71
 
72
-    /**
73
-     * true if the current request is for a WP_Cron
74
-     *
75
-     * @return bool
76
-     */
77
-    public function isCron();
72
+	/**
73
+	 * true if the current request is for a WP_Cron
74
+	 *
75
+	 * @return bool
76
+	 */
77
+	public function isCron();
78 78
 
79 79
 
80
-    /**
81
-     * true if the current request is for either the EE admin or EE frontend AND is being made via AJAX
82
-     *
83
-     * @return bool
84
-     */
85
-    public function isEeAjax();
80
+	/**
81
+	 * true if the current request is for either the EE admin or EE frontend AND is being made via AJAX
82
+	 *
83
+	 * @return bool
84
+	 */
85
+	public function isEeAjax();
86 86
 
87 87
 
88
-    /**
89
-     * true if the current request is for a feed (ie: RSS)
90
-     *
91
-     * @return bool
92
-     */
93
-    public function isFeed();
88
+	/**
89
+	 * true if the current request is for a feed (ie: RSS)
90
+	 *
91
+	 * @return bool
92
+	 */
93
+	public function isFeed();
94 94
 
95 95
 
96
-    /**
97
-     * true if the current request is for the frontend and is not being made via AJAX
98
-     *
99
-     * @return bool
100
-     */
101
-    public function isFrontend();
96
+	/**
97
+	 * true if the current request is for the frontend and is not being made via AJAX
98
+	 *
99
+	 * @return bool
100
+	 */
101
+	public function isFrontend();
102 102
 
103 103
 
104
-    /**
105
-     * @return bool
106
-     */
107
-    public function isFrontAjax();
104
+	/**
105
+	 * @return bool
106
+	 */
107
+	public function isFrontAjax();
108 108
 
109 109
 
110
-    /**
111
-     * @return bool
112
-     */
113
-    public function isIframe();
110
+	/**
111
+	 * @return bool
112
+	 */
113
+	public function isIframe();
114 114
 
115 115
 
116
-    /**
117
-     * true if the current request is being made via AJAX but is NOT for EE related logic
118
-     *
119
-     * @return bool
120
-     */
121
-    public function isOtherAjax();
116
+	/**
117
+	 * true if the current request is being made via AJAX but is NOT for EE related logic
118
+	 *
119
+	 * @return bool
120
+	 */
121
+	public function isOtherAjax();
122 122
 
123 123
 
124
-    /**
125
-     * true if the current request is for the WP REST API
126
-     *
127
-     * @return bool
128
-     */
129
-    public function isWordPressApi();
124
+	/**
125
+	 * true if the current request is for the WP REST API
126
+	 *
127
+	 * @return bool
128
+	 */
129
+	public function isWordPressApi();
130 130
 
131 131
 
132
-    /**
133
-     * true if the current request is a loopback sent from WP core to test for errors
134
-     *
135
-     * @return bool
136
-     */
137
-    public function isWordPressScrape();
132
+	/**
133
+	 * true if the current request is a loopback sent from WP core to test for errors
134
+	 *
135
+	 * @return bool
136
+	 */
137
+	public function isWordPressScrape();
138 138
 
139 139
 
140
-    /**
141
-     * @return string
142
-     */
143
-    public function slug();
140
+	/**
141
+	 * @return string
142
+	 */
143
+	public function slug();
144 144
 }
Please login to merge, or discard this patch.
core/domain/services/contexts/RequestTypeContextChecker.php 1 patch
Indentation   +202 added lines, -202 removed lines patch added patch discarded remove patch
@@ -16,206 +16,206 @@
 block discarded – undo
16 16
 class RequestTypeContextChecker extends ContextChecker implements RequestTypeContextCheckerInterface
17 17
 {
18 18
 
19
-    /**
20
-     * @var RequestTypeContext $request_type
21
-     */
22
-    private $request_type;
23
-
24
-
25
-    /**
26
-     * RequestTypeContextChecker constructor.
27
-     *
28
-     * @param RequestTypeContext $request_type
29
-     */
30
-    public function __construct(RequestTypeContext $request_type)
31
-    {
32
-        $this->request_type = $request_type;
33
-        parent::__construct(
34
-            'RequestTypeContextChecker',
35
-            $this->request_type->validRequestTypes()
36
-        );
37
-    }
38
-
39
-
40
-    /**
41
-     * true if the current request involves some form of activation
42
-     *
43
-     * @return bool
44
-     */
45
-    public function isActivation()
46
-    {
47
-        return $this->request_type->isActivation();
48
-    }
49
-
50
-
51
-    /**
52
-     * @param $is_activation
53
-     * @return bool
54
-     */
55
-    public function setIsActivation($is_activation)
56
-    {
57
-        return $this->request_type->setIsActivation($is_activation);
58
-    }
59
-
60
-
61
-    /**
62
-     * true if the current request is for the admin and is not being made via AJAX
63
-     *
64
-     * @return bool
65
-     */
66
-    public function isAdmin()
67
-    {
68
-        return $this->request_type->slug() === RequestTypeContext::ADMIN;
69
-    }
70
-
71
-
72
-    /**
73
-     * true if the current request is for the admin AND is being made via AJAX
74
-     *
75
-     * @return bool
76
-     */
77
-    public function isAdminAjax()
78
-    {
79
-        return $this->request_type->slug() === RequestTypeContext::AJAX_ADMIN;
80
-    }
81
-
82
-
83
-    /**
84
-     * true if the current request is being made via AJAX... any AJAX
85
-     *
86
-     * @return bool
87
-     */
88
-    public function isAjax()
89
-    {
90
-        return $this->isEeAjax() || $this->isOtherAjax();
91
-    }
92
-
93
-
94
-    /**
95
-     * true if the current request is for either the EE admin or EE frontend AND is being made via AJAX
96
-     *
97
-     * @return bool
98
-     */
99
-    public function isEeAjax()
100
-    {
101
-        return $this->isAdminAjax() || $this->isFrontAjax();
102
-    }
103
-
104
-
105
-    /**
106
-     * true if the current request is being made via AJAX but is NOT for EE related logic
107
-     *
108
-     * @return bool
109
-     */
110
-    public function isOtherAjax()
111
-    {
112
-        return $this->request_type->slug() === RequestTypeContext::AJAX_OTHER;
113
-    }
114
-
115
-    /**
116
-     * true if the current request is for the EE REST API
117
-     *
118
-     * @return bool
119
-     */
120
-    public function isApi()
121
-    {
122
-        return $this->request_type->slug() === RequestTypeContext::API;
123
-    }
124
-
125
-
126
-    /**
127
-     * true if the current request is from the command line
128
-     *
129
-     * @return bool
130
-     */
131
-    public function isCli()
132
-    {
133
-        return $this->request_type->slug() === RequestTypeContext::CLI;
134
-    }
135
-
136
-
137
-    /**
138
-     * true if the current request is for a WP_Cron
139
-     *
140
-     * @return bool
141
-     */
142
-    public function isCron()
143
-    {
144
-        return $this->request_type->slug() === RequestTypeContext::CRON;
145
-    }
146
-
147
-
148
-    /**
149
-     * true if the current request is for a feed (ie: RSS)
150
-     *
151
-     * @return bool
152
-     */
153
-    public function isFeed()
154
-    {
155
-        return $this->request_type->slug() === RequestTypeContext::FEED;
156
-    }
157
-
158
-
159
-    /**
160
-     * true if the current request is for the frontend and is not being made via AJAX
161
-     *
162
-     * @return bool
163
-     */
164
-    public function isFrontend()
165
-    {
166
-        return $this->request_type->slug() === RequestTypeContext::FRONTEND;
167
-    }
168
-
169
-
170
-    /**
171
-     * true if the current request is for the frontend AND is being made via AJAX
172
-     *
173
-     * @return bool
174
-     */
175
-    public function isFrontAjax()
176
-    {
177
-        return $this->request_type->slug() === RequestTypeContext::AJAX_FRONT;
178
-    }
179
-
180
-
181
-    /**
182
-     * true if the current request is for content that is to be displayed within an iframe
183
-     *
184
-     * @return bool
185
-     */
186
-    public function isIframe()
187
-    {
188
-        return $this->request_type->slug() === RequestTypeContext::IFRAME;
189
-    }
190
-
191
-
192
-    /**
193
-     * true if the current request is for the WP REST API
194
-     *
195
-     * @return bool
196
-     */
197
-    public function isWordPressApi()
198
-    {
199
-        return $this->request_type->slug() === RequestTypeContext::WP_API;
200
-    }
201
-
202
-
203
-    /**
204
-     * true if the current request is a loopback sent from WP core to test for errors
205
-     *
206
-     * @return bool
207
-     */
208
-    public function isWordPressScrape()
209
-    {
210
-        return $this->request_type->slug() === RequestTypeContext::WP_SCRAPE;
211
-    }
212
-
213
-
214
-    /**
215
-     * @return string
216
-     */
217
-    public function slug()
218
-    {
219
-        return $this->request_type->slug();
220
-    }
19
+	/**
20
+	 * @var RequestTypeContext $request_type
21
+	 */
22
+	private $request_type;
23
+
24
+
25
+	/**
26
+	 * RequestTypeContextChecker constructor.
27
+	 *
28
+	 * @param RequestTypeContext $request_type
29
+	 */
30
+	public function __construct(RequestTypeContext $request_type)
31
+	{
32
+		$this->request_type = $request_type;
33
+		parent::__construct(
34
+			'RequestTypeContextChecker',
35
+			$this->request_type->validRequestTypes()
36
+		);
37
+	}
38
+
39
+
40
+	/**
41
+	 * true if the current request involves some form of activation
42
+	 *
43
+	 * @return bool
44
+	 */
45
+	public function isActivation()
46
+	{
47
+		return $this->request_type->isActivation();
48
+	}
49
+
50
+
51
+	/**
52
+	 * @param $is_activation
53
+	 * @return bool
54
+	 */
55
+	public function setIsActivation($is_activation)
56
+	{
57
+		return $this->request_type->setIsActivation($is_activation);
58
+	}
59
+
60
+
61
+	/**
62
+	 * true if the current request is for the admin and is not being made via AJAX
63
+	 *
64
+	 * @return bool
65
+	 */
66
+	public function isAdmin()
67
+	{
68
+		return $this->request_type->slug() === RequestTypeContext::ADMIN;
69
+	}
70
+
71
+
72
+	/**
73
+	 * true if the current request is for the admin AND is being made via AJAX
74
+	 *
75
+	 * @return bool
76
+	 */
77
+	public function isAdminAjax()
78
+	{
79
+		return $this->request_type->slug() === RequestTypeContext::AJAX_ADMIN;
80
+	}
81
+
82
+
83
+	/**
84
+	 * true if the current request is being made via AJAX... any AJAX
85
+	 *
86
+	 * @return bool
87
+	 */
88
+	public function isAjax()
89
+	{
90
+		return $this->isEeAjax() || $this->isOtherAjax();
91
+	}
92
+
93
+
94
+	/**
95
+	 * true if the current request is for either the EE admin or EE frontend AND is being made via AJAX
96
+	 *
97
+	 * @return bool
98
+	 */
99
+	public function isEeAjax()
100
+	{
101
+		return $this->isAdminAjax() || $this->isFrontAjax();
102
+	}
103
+
104
+
105
+	/**
106
+	 * true if the current request is being made via AJAX but is NOT for EE related logic
107
+	 *
108
+	 * @return bool
109
+	 */
110
+	public function isOtherAjax()
111
+	{
112
+		return $this->request_type->slug() === RequestTypeContext::AJAX_OTHER;
113
+	}
114
+
115
+	/**
116
+	 * true if the current request is for the EE REST API
117
+	 *
118
+	 * @return bool
119
+	 */
120
+	public function isApi()
121
+	{
122
+		return $this->request_type->slug() === RequestTypeContext::API;
123
+	}
124
+
125
+
126
+	/**
127
+	 * true if the current request is from the command line
128
+	 *
129
+	 * @return bool
130
+	 */
131
+	public function isCli()
132
+	{
133
+		return $this->request_type->slug() === RequestTypeContext::CLI;
134
+	}
135
+
136
+
137
+	/**
138
+	 * true if the current request is for a WP_Cron
139
+	 *
140
+	 * @return bool
141
+	 */
142
+	public function isCron()
143
+	{
144
+		return $this->request_type->slug() === RequestTypeContext::CRON;
145
+	}
146
+
147
+
148
+	/**
149
+	 * true if the current request is for a feed (ie: RSS)
150
+	 *
151
+	 * @return bool
152
+	 */
153
+	public function isFeed()
154
+	{
155
+		return $this->request_type->slug() === RequestTypeContext::FEED;
156
+	}
157
+
158
+
159
+	/**
160
+	 * true if the current request is for the frontend and is not being made via AJAX
161
+	 *
162
+	 * @return bool
163
+	 */
164
+	public function isFrontend()
165
+	{
166
+		return $this->request_type->slug() === RequestTypeContext::FRONTEND;
167
+	}
168
+
169
+
170
+	/**
171
+	 * true if the current request is for the frontend AND is being made via AJAX
172
+	 *
173
+	 * @return bool
174
+	 */
175
+	public function isFrontAjax()
176
+	{
177
+		return $this->request_type->slug() === RequestTypeContext::AJAX_FRONT;
178
+	}
179
+
180
+
181
+	/**
182
+	 * true if the current request is for content that is to be displayed within an iframe
183
+	 *
184
+	 * @return bool
185
+	 */
186
+	public function isIframe()
187
+	{
188
+		return $this->request_type->slug() === RequestTypeContext::IFRAME;
189
+	}
190
+
191
+
192
+	/**
193
+	 * true if the current request is for the WP REST API
194
+	 *
195
+	 * @return bool
196
+	 */
197
+	public function isWordPressApi()
198
+	{
199
+		return $this->request_type->slug() === RequestTypeContext::WP_API;
200
+	}
201
+
202
+
203
+	/**
204
+	 * true if the current request is a loopback sent from WP core to test for errors
205
+	 *
206
+	 * @return bool
207
+	 */
208
+	public function isWordPressScrape()
209
+	{
210
+		return $this->request_type->slug() === RequestTypeContext::WP_SCRAPE;
211
+	}
212
+
213
+
214
+	/**
215
+	 * @return string
216
+	 */
217
+	public function slug()
218
+	{
219
+		return $this->request_type->slug();
220
+	}
221 221
 }
Please login to merge, or discard this patch.
core/domain/entities/contexts/RequestTypeContext.php 1 patch
Indentation   +145 added lines, -145 removed lines patch added patch discarded remove patch
@@ -16,149 +16,149 @@
 block discarded – undo
16 16
 class RequestTypeContext extends Context
17 17
 {
18 18
 
19
-    /**
20
-     * indicates that the current request involves some form of activation
21
-     */
22
-    const ACTIVATION = 'activation-request';
23
-
24
-    /**
25
-     * indicates that the current request is for the admin but is not being made via AJAX
26
-     */
27
-    const ADMIN = 'non-ajax-admin-request';
28
-
29
-    /**
30
-     * indicates that the current request is for the admin AND is being made via AJAX
31
-     */
32
-    const AJAX_ADMIN = 'admin-ajax-request';
33
-
34
-    /**
35
-     * indicates that the current request is for the frontend AND is being made via AJAX
36
-     */
37
-    const AJAX_FRONT = 'frontend-ajax-request';
38
-
39
-    /**
40
-     * indicates that the current request is being made via AJAX, but is NOT for EE
41
-     */
42
-    const AJAX_OTHER = 'other-ajax-request';
43
-
44
-    /**
45
-     * indicates that the current request is for the EE REST API
46
-     */
47
-    const API = 'rest-api';
48
-
49
-    /**
50
-     * indicates that the current request is from the command line
51
-     */
52
-    const CLI = 'command-line';
53
-
54
-    /**
55
-     * indicates that the current request is for a WP_Cron
56
-     */
57
-    const CRON = 'wp-cron';
58
-
59
-    /**
60
-     * indicates that the current request is for a feed (ie: RSS)
61
-     */
62
-    const FEED = 'feed-request';
63
-
64
-    /**
65
-     * indicates that the current request is for the frontend but is not being made via AJAX
66
-     */
67
-    const FRONTEND = 'non-ajax-frontend-request';
68
-
69
-    /**
70
-     * indicates that the current request is for content that is to be displayed within an iframe
71
-     */
72
-    const IFRAME = 'iframe-request';
73
-
74
-    /**
75
-     * indicates that the current request is for the WP REST API
76
-     */
77
-    const WP_API = 'wp-rest-api';
78
-
79
-    /**
80
-     * indicates that the current request is a loopback sent from WP core to test for errors
81
-     */
82
-    const WP_SCRAPE = 'wordpress-scrape';
83
-
84
-    /**
85
-     * @var boolean $is_activation
86
-     */
87
-    private $is_activation = false;
88
-
89
-    /**
90
-     * @var array $valid_request_types
91
-     */
92
-    private $valid_request_types = array();
93
-
94
-
95
-    /**
96
-     * RequestTypeContext constructor.
97
-     *
98
-     * @param string $slug
99
-     * @param string $description
100
-     * @throws InvalidArgumentException
101
-     */
102
-    public function __construct($slug, $description)
103
-    {
104
-        parent::__construct($slug, $description);
105
-        if (! in_array($this->slug(), $this->validRequestTypes(), true)) {
106
-            throw new InvalidArgumentException(
107
-                sprintf(
108
-                    esc_html__(
109
-                        'The RequestTypeContext slug must be one of the following values: %1$s %2$s',
110
-                        'event_espresso'
111
-                    ),
112
-                    var_export($this->validRequestTypes(), true)
113
-                )
114
-            );
115
-        }
116
-    }
117
-
118
-
119
-    /**
120
-     * @return array
121
-     */
122
-    public function validRequestTypes()
123
-    {
124
-        if (empty($this->valid_request_types)) {
125
-            $this->valid_request_types = apply_filters(
126
-                'FHEE__EventEspresso_core_domain_entities_contexts_RequestTypeContext__validRequestTypes',
127
-                array(
128
-                    RequestTypeContext::ACTIVATION,
129
-                    RequestTypeContext::ADMIN,
130
-                    RequestTypeContext::AJAX_ADMIN,
131
-                    RequestTypeContext::AJAX_FRONT,
132
-                    RequestTypeContext::AJAX_OTHER,
133
-                    RequestTypeContext::API,
134
-                    RequestTypeContext::CLI,
135
-                    RequestTypeContext::CRON,
136
-                    RequestTypeContext::FEED,
137
-                    RequestTypeContext::FRONTEND,
138
-                    RequestTypeContext::IFRAME,
139
-                    RequestTypeContext::WP_API,
140
-                    RequestTypeContext::WP_SCRAPE,
141
-                )
142
-            );
143
-        }
144
-        return $this->valid_request_types;
145
-    }
146
-
147
-
148
-    /**
149
-     * @return bool
150
-     */
151
-    public function isActivation()
152
-    {
153
-        return $this->is_activation;
154
-    }
155
-
156
-
157
-    /**
158
-     * @param bool $is_activation
159
-     */
160
-    public function setIsActivation($is_activation)
161
-    {
162
-        $this->is_activation = filter_var($is_activation, FILTER_VALIDATE_BOOLEAN);
163
-    }
19
+	/**
20
+	 * indicates that the current request involves some form of activation
21
+	 */
22
+	const ACTIVATION = 'activation-request';
23
+
24
+	/**
25
+	 * indicates that the current request is for the admin but is not being made via AJAX
26
+	 */
27
+	const ADMIN = 'non-ajax-admin-request';
28
+
29
+	/**
30
+	 * indicates that the current request is for the admin AND is being made via AJAX
31
+	 */
32
+	const AJAX_ADMIN = 'admin-ajax-request';
33
+
34
+	/**
35
+	 * indicates that the current request is for the frontend AND is being made via AJAX
36
+	 */
37
+	const AJAX_FRONT = 'frontend-ajax-request';
38
+
39
+	/**
40
+	 * indicates that the current request is being made via AJAX, but is NOT for EE
41
+	 */
42
+	const AJAX_OTHER = 'other-ajax-request';
43
+
44
+	/**
45
+	 * indicates that the current request is for the EE REST API
46
+	 */
47
+	const API = 'rest-api';
48
+
49
+	/**
50
+	 * indicates that the current request is from the command line
51
+	 */
52
+	const CLI = 'command-line';
53
+
54
+	/**
55
+	 * indicates that the current request is for a WP_Cron
56
+	 */
57
+	const CRON = 'wp-cron';
58
+
59
+	/**
60
+	 * indicates that the current request is for a feed (ie: RSS)
61
+	 */
62
+	const FEED = 'feed-request';
63
+
64
+	/**
65
+	 * indicates that the current request is for the frontend but is not being made via AJAX
66
+	 */
67
+	const FRONTEND = 'non-ajax-frontend-request';
68
+
69
+	/**
70
+	 * indicates that the current request is for content that is to be displayed within an iframe
71
+	 */
72
+	const IFRAME = 'iframe-request';
73
+
74
+	/**
75
+	 * indicates that the current request is for the WP REST API
76
+	 */
77
+	const WP_API = 'wp-rest-api';
78
+
79
+	/**
80
+	 * indicates that the current request is a loopback sent from WP core to test for errors
81
+	 */
82
+	const WP_SCRAPE = 'wordpress-scrape';
83
+
84
+	/**
85
+	 * @var boolean $is_activation
86
+	 */
87
+	private $is_activation = false;
88
+
89
+	/**
90
+	 * @var array $valid_request_types
91
+	 */
92
+	private $valid_request_types = array();
93
+
94
+
95
+	/**
96
+	 * RequestTypeContext constructor.
97
+	 *
98
+	 * @param string $slug
99
+	 * @param string $description
100
+	 * @throws InvalidArgumentException
101
+	 */
102
+	public function __construct($slug, $description)
103
+	{
104
+		parent::__construct($slug, $description);
105
+		if (! in_array($this->slug(), $this->validRequestTypes(), true)) {
106
+			throw new InvalidArgumentException(
107
+				sprintf(
108
+					esc_html__(
109
+						'The RequestTypeContext slug must be one of the following values: %1$s %2$s',
110
+						'event_espresso'
111
+					),
112
+					var_export($this->validRequestTypes(), true)
113
+				)
114
+			);
115
+		}
116
+	}
117
+
118
+
119
+	/**
120
+	 * @return array
121
+	 */
122
+	public function validRequestTypes()
123
+	{
124
+		if (empty($this->valid_request_types)) {
125
+			$this->valid_request_types = apply_filters(
126
+				'FHEE__EventEspresso_core_domain_entities_contexts_RequestTypeContext__validRequestTypes',
127
+				array(
128
+					RequestTypeContext::ACTIVATION,
129
+					RequestTypeContext::ADMIN,
130
+					RequestTypeContext::AJAX_ADMIN,
131
+					RequestTypeContext::AJAX_FRONT,
132
+					RequestTypeContext::AJAX_OTHER,
133
+					RequestTypeContext::API,
134
+					RequestTypeContext::CLI,
135
+					RequestTypeContext::CRON,
136
+					RequestTypeContext::FEED,
137
+					RequestTypeContext::FRONTEND,
138
+					RequestTypeContext::IFRAME,
139
+					RequestTypeContext::WP_API,
140
+					RequestTypeContext::WP_SCRAPE,
141
+				)
142
+			);
143
+		}
144
+		return $this->valid_request_types;
145
+	}
146
+
147
+
148
+	/**
149
+	 * @return bool
150
+	 */
151
+	public function isActivation()
152
+	{
153
+		return $this->is_activation;
154
+	}
155
+
156
+
157
+	/**
158
+	 * @param bool $is_activation
159
+	 */
160
+	public function setIsActivation($is_activation)
161
+	{
162
+		$this->is_activation = filter_var($is_activation, FILTER_VALIDATE_BOOLEAN);
163
+	}
164 164
 }
Please login to merge, or discard this patch.