Completed
Branch dev (da6344)
by
unknown
30:14 queued 22:49
created
core/helpers/EEH_Form_Fields.helper.php 1 patch
Indentation   +2063 added lines, -2063 removed lines patch added patch discarded remove patch
@@ -27,1056 +27,1056 @@  discard block
 block discarded – undo
27 27
  */
28 28
 class EEH_Form_Fields
29 29
 {
30
-    /**
31
-     *  Generates HTML for the forms used on admin pages
32
-     *
33
-     *
34
-     * @static
35
-     * @access public
36
-     * @param array $input_vars - array of input field details
37
-     *                          format:
38
-     *                          $template_form_fields['field-id'] = array(
39
-     *                          'name' => 'name_attribute',
40
-     *                          'label' => esc_html__('Field Label', 'event_espresso'), //or false
41
-     *                          'input' => 'hidden', //field input type can be 'text', 'select', 'textarea', 'hidden',
42
-     *                          'checkbox', 'wp_editor'
43
-     *                          'type' => 'int', //what "type" the value is (i.e. string, int etc)
44
-     *                          'required' => false, //boolean for whether the field is required
45
-     *                          'validation' => true, //boolean, whether to validate the field (todo)
46
-     *                          'value' => 'some_value_for_field', //what value is used for field
47
-     *                          'format' => '%d', //what format the value is (%d, %f, or %s)
48
-     *                          'db-col' => 'column_in_db' //used to indicate which column the field corresponds with
49
-     *                          in the db
50
-     *                          'options' => optiona, optionb || array('value' => 'label', '') //if the input type is
51
-     *                          "select", this allows you to set the args for the different <option> tags.
52
-     *                          'tabindex' => 1 //this allows you to set the tabindex for the field.
53
-     *                          'append_content' => '' //this allows you to send in html content to append to the
54
-     *                          field.
55
-     *                          )
56
-     * @param array $form_id    - used for defining unique identifiers for the form.
57
-     * @return string
58
-     * @todo   : at some point we can break this down into other static methods to abstract it a bit better.
59
-     */
60
-    public static function get_form_fields($input_vars = [], $form_id = false)
61
-    {
62
-
63
-        if (empty($input_vars)) {
64
-            EE_Error::add_error(
65
-                esc_html__('missing required variables for the form field generator', 'event_espresso'),
66
-                __FILE__,
67
-                __FUNCTION__,
68
-                __LINE__
69
-            );
70
-            return false;
71
-        }
72
-
73
-        $output        = "";
74
-        $inputs        = [];
75
-        $hidden_inputs = [];
76
-
77
-        // cycle thru inputs
78
-        foreach ($input_vars as $input_key => $input_value) {
79
-            $defaults = [
80
-                'append_content' => '',
81
-                'css_class'      => '',
82
-                'cols'           => 80,
83
-                'db-col'         => 'column_in_db',
84
-                'format'         => '%d',
85
-                'input'          => 'hidden',
86
-                'label'          => esc_html__('No label', 'event_espresso'),
87
-                'name'           => $input_key,
88
-                'options'        => [],
89
-                'required'       => false,
90
-                'tabindex'       => 0,
91
-                'rows'           => 10,
92
-                'type'           => 'int',
93
-                'validation'     => true,
94
-                'value'          => 'some_value_for_field',
95
-            ];
96
-
97
-            $input_value = wp_parse_args($input_value, $defaults);
98
-
99
-            $append_content = $input_value['append_content'];
100
-            $css_class      = $input_value['css_class'];
101
-            $cols           = $input_value['cols'];
102
-            $label          = $input_value['label'];
103
-            $name           = $input_value['name'];
104
-            $options        = $input_value['options'];
105
-            $required       = $input_value['required'];
106
-            $tab_index      = $input_value['tabindex'];
107
-            $rows           = $input_value['rows'];
108
-            $type           = $input_value['input'];
109
-            $value          = $input_value['value'];
110
-
111
-            $id    = $form_id ? $form_id . '-' . $input_key : $input_key;
112
-            $class = $required ? 'required ' . $css_class : $css_class;
113
-
114
-            // what type of input are we dealing with ?
115
-            switch ($type) {
116
-                case 'checkbox':
117
-                case 'radio':
118
-                    $field = self::adminMulti($value, $class, $id, $name, $required, $tab_index, $type, 1, $label);
119
-                    $field .= $append_content ?: '';
120
-                    break;
121
-
122
-                case 'hidden':
123
-                    $field           = null;
124
-                    $hidden_inputs[] = self::adminHidden($css_class, $id, $name, $value);
125
-                    break;
126
-
127
-                case 'select':
128
-                    $options = is_array($options) ? $options : explode(',', $options);
129
-                    $field   = self::adminLabel($id, $label, $required);
130
-                    $field   .= self::adminSelect($value, $class, $id, $name, $required, $tab_index, $options);
131
-                    $field   .= $append_content ?: '';
132
-                    break;
133
-
134
-                case 'textarea':
135
-                    $field = self::adminLabel($id, $label, $required);
136
-                    $field .= self::adminTextarea($class, $cols, $id, $name, $required, $rows, $tab_index, $value);
137
-                    $field .= $append_content ?: '';
138
-                    break;
139
-
140
-                case 'wp_editor':
141
-                    $label = esc_html($label);
142
-                    $field = "<h4>{$label}</h4>";
143
-                    $field .= $append_content ?: '';
144
-                    $field .= self::adminWpEditor(
145
-                        $class,
146
-                        $id,
147
-                        $name,
148
-                        $rows,
149
-                        $tab_index,
150
-                        $value
151
-                    );
152
-                    break;
153
-
154
-                default:
155
-                    $field = self::adminLabel($id, $label, $required);
156
-                    $field .= self::adminText($class, $id, $name, $required, $tab_index, $value);
157
-                    $field .= $append_content ?: '';
158
-            }
159
-            if ($field) {
160
-                $inputs[] = $field;
161
-            }
162
-        } // end foreach( $input_vars as $input_key => $input_value )
163
-
164
-        if (! empty($inputs)) {
165
-            $glue   = "
30
+	/**
31
+	 *  Generates HTML for the forms used on admin pages
32
+	 *
33
+	 *
34
+	 * @static
35
+	 * @access public
36
+	 * @param array $input_vars - array of input field details
37
+	 *                          format:
38
+	 *                          $template_form_fields['field-id'] = array(
39
+	 *                          'name' => 'name_attribute',
40
+	 *                          'label' => esc_html__('Field Label', 'event_espresso'), //or false
41
+	 *                          'input' => 'hidden', //field input type can be 'text', 'select', 'textarea', 'hidden',
42
+	 *                          'checkbox', 'wp_editor'
43
+	 *                          'type' => 'int', //what "type" the value is (i.e. string, int etc)
44
+	 *                          'required' => false, //boolean for whether the field is required
45
+	 *                          'validation' => true, //boolean, whether to validate the field (todo)
46
+	 *                          'value' => 'some_value_for_field', //what value is used for field
47
+	 *                          'format' => '%d', //what format the value is (%d, %f, or %s)
48
+	 *                          'db-col' => 'column_in_db' //used to indicate which column the field corresponds with
49
+	 *                          in the db
50
+	 *                          'options' => optiona, optionb || array('value' => 'label', '') //if the input type is
51
+	 *                          "select", this allows you to set the args for the different <option> tags.
52
+	 *                          'tabindex' => 1 //this allows you to set the tabindex for the field.
53
+	 *                          'append_content' => '' //this allows you to send in html content to append to the
54
+	 *                          field.
55
+	 *                          )
56
+	 * @param array $form_id    - used for defining unique identifiers for the form.
57
+	 * @return string
58
+	 * @todo   : at some point we can break this down into other static methods to abstract it a bit better.
59
+	 */
60
+	public static function get_form_fields($input_vars = [], $form_id = false)
61
+	{
62
+
63
+		if (empty($input_vars)) {
64
+			EE_Error::add_error(
65
+				esc_html__('missing required variables for the form field generator', 'event_espresso'),
66
+				__FILE__,
67
+				__FUNCTION__,
68
+				__LINE__
69
+			);
70
+			return false;
71
+		}
72
+
73
+		$output        = "";
74
+		$inputs        = [];
75
+		$hidden_inputs = [];
76
+
77
+		// cycle thru inputs
78
+		foreach ($input_vars as $input_key => $input_value) {
79
+			$defaults = [
80
+				'append_content' => '',
81
+				'css_class'      => '',
82
+				'cols'           => 80,
83
+				'db-col'         => 'column_in_db',
84
+				'format'         => '%d',
85
+				'input'          => 'hidden',
86
+				'label'          => esc_html__('No label', 'event_espresso'),
87
+				'name'           => $input_key,
88
+				'options'        => [],
89
+				'required'       => false,
90
+				'tabindex'       => 0,
91
+				'rows'           => 10,
92
+				'type'           => 'int',
93
+				'validation'     => true,
94
+				'value'          => 'some_value_for_field',
95
+			];
96
+
97
+			$input_value = wp_parse_args($input_value, $defaults);
98
+
99
+			$append_content = $input_value['append_content'];
100
+			$css_class      = $input_value['css_class'];
101
+			$cols           = $input_value['cols'];
102
+			$label          = $input_value['label'];
103
+			$name           = $input_value['name'];
104
+			$options        = $input_value['options'];
105
+			$required       = $input_value['required'];
106
+			$tab_index      = $input_value['tabindex'];
107
+			$rows           = $input_value['rows'];
108
+			$type           = $input_value['input'];
109
+			$value          = $input_value['value'];
110
+
111
+			$id    = $form_id ? $form_id . '-' . $input_key : $input_key;
112
+			$class = $required ? 'required ' . $css_class : $css_class;
113
+
114
+			// what type of input are we dealing with ?
115
+			switch ($type) {
116
+				case 'checkbox':
117
+				case 'radio':
118
+					$field = self::adminMulti($value, $class, $id, $name, $required, $tab_index, $type, 1, $label);
119
+					$field .= $append_content ?: '';
120
+					break;
121
+
122
+				case 'hidden':
123
+					$field           = null;
124
+					$hidden_inputs[] = self::adminHidden($css_class, $id, $name, $value);
125
+					break;
126
+
127
+				case 'select':
128
+					$options = is_array($options) ? $options : explode(',', $options);
129
+					$field   = self::adminLabel($id, $label, $required);
130
+					$field   .= self::adminSelect($value, $class, $id, $name, $required, $tab_index, $options);
131
+					$field   .= $append_content ?: '';
132
+					break;
133
+
134
+				case 'textarea':
135
+					$field = self::adminLabel($id, $label, $required);
136
+					$field .= self::adminTextarea($class, $cols, $id, $name, $required, $rows, $tab_index, $value);
137
+					$field .= $append_content ?: '';
138
+					break;
139
+
140
+				case 'wp_editor':
141
+					$label = esc_html($label);
142
+					$field = "<h4>{$label}</h4>";
143
+					$field .= $append_content ?: '';
144
+					$field .= self::adminWpEditor(
145
+						$class,
146
+						$id,
147
+						$name,
148
+						$rows,
149
+						$tab_index,
150
+						$value
151
+					);
152
+					break;
153
+
154
+				default:
155
+					$field = self::adminLabel($id, $label, $required);
156
+					$field .= self::adminText($class, $id, $name, $required, $tab_index, $value);
157
+					$field .= $append_content ?: '';
158
+			}
159
+			if ($field) {
160
+				$inputs[] = $field;
161
+			}
162
+		} // end foreach( $input_vars as $input_key => $input_value )
163
+
164
+		if (! empty($inputs)) {
165
+			$glue   = "
166 166
                 </li>
167 167
                 <li>
168 168
                     ";
169
-            $inputs = implode($glue, $inputs);
170
-            $output = "
169
+			$inputs = implode($glue, $inputs);
170
+			$output = "
171 171
             <ul>
172 172
                 <li>
173 173
                 {$inputs}
174 174
                 </li>
175 175
             </ul>
176 176
             ";
177
-        }
178
-        return $output . implode("\n", $hidden_inputs);
179
-    }
180
-
181
-
182
-    /**
183
-     * form_fields_array
184
-     * This utility function assembles form fields from a given structured array with field information.
185
-     * //TODO: This is an alternate generator that we may want to use instead.
186
-     *
187
-     * @param array $fields structured array of fields to assemble in the following format:
188
-     *                      [field_name] => array(
189
-     *                      ['label'] => 'label for field',
190
-     *                      ['labels'] => array('label_1', 'label_2'); //optional - if the field type is a multi select
191
-     *                      type of field you can indicated the labels for each option via this index
192
-     *                      ['extra_desc'] => 'extra description for the field', //optional
193
-     *                      ['type'] => 'textarea'|'text'|'wp_editor'|'checkbox'|'radio'|'hidden'|'select', //defaults
194
-     *                      to text
195
-     *                      ['value'] => 'value that goes in the field', //(if multi then this is an array of values
196
-     *                      and the 'default' paramater will be used for what is selected)
197
-     *                      ['default'] => 'default if the field type is multi (i.e. select or radios or checkboxes)',
198
-     *                      ['class'] => 'name-of-class(es)-for-input',
199
-     *                      ['classes'] => array('class_1', 'class_2'); //optional - if the field type is a multi
200
-     *                      select type of field you can indicate the css class for each option via this index.
201
-     *                      ['id'] => 'css-id-for-input') //defaults to 'field_name'
202
-     *                      ['unique_id'] => 1 //defaults to empty string.  This is useful for when the fields
203
-     *                      generated are going to be used in a loop and you want to make sure that the field
204
-     *                      identifiers are unique from each other.
205
-     *                      ['dimensions'] => array(100,300), //defaults to empty array.  This is used by field types
206
-     *                      such as textarea to indicate cols/rows.
207
-     *                      ['tabindex'] => '' //this allows you to set the tabindex for the field.
208
-     *                      ['wpeditor_args'] => array() //if the type of field is wpeditor then this can optionally
209
-     *                      contain an array of arguments for the editor setup.
210
-     *
211
-     * @return array         an array of inputs for form indexed by field name, and in the following structure:
212
-     *     [field_name] => array( 'label' => '{label_html}', 'field' => '{input_html}'
213
-     */
214
-    public static function get_form_fields_array($fields)
215
-    {
216
-
217
-        $form_fields = [];
218
-        $fields      = (array) $fields;
219
-
220
-        foreach ($fields as $field_name => $field_atts) {
221
-            // defaults:
222
-            $defaults = [
223
-                'class'         => '',
224
-                'classes'       => '',
225
-                'default'       => '',
226
-                'dimensions'    => ['10', '5'],
227
-                'extra_desc'    => '',
228
-                'id'            => $field_name,
229
-                'label'         => '',
230
-                'labels'        => '',
231
-                'required'      => false,
232
-                'tabindex'      => 0,
233
-                'type'          => 'text',
234
-                'unique_id'     => '',
235
-                'value'         => '',
236
-                'wpeditor_args' => [],
237
-            ];
238
-            // merge defaults with passed arguments
239
-            $_fields = wp_parse_args($field_atts, $defaults);
240
-
241
-            $class          = $_fields['class'];
242
-            $classes        = $_fields['classes'];
243
-            $default        = $_fields['default'];
244
-            $dims           = $_fields['dimensions'];
245
-            $extra_desc     = $_fields['extra_desc'];
246
-            $id             = $_fields['id'];
247
-            $label          = $_fields['label'];
248
-            $labels         = $_fields['labels'];
249
-            $required       = $_fields['required'];
250
-            $tab_index      = $_fields['tabindex'];
251
-            $type           = $_fields['type'];
252
-            $unique_id      = $_fields['unique_id'];
253
-            $value          = $_fields['value'];
254
-            $wp_editor_args = $_fields['wpeditor_args'];
255
-
256
-            // generate label
257
-            $label = ! empty($label) ? self::adminLabel($id, $label, $required) : '';
258
-            // generate field name
259
-            $name = ! empty($unique_id) ? $field_name . '[' . $unique_id . ']' : $field_name;
260
-
261
-            // we determine what we're building based on the type
262
-            switch ($type) {
263
-                case 'checkbox':
264
-                case 'radio':
265
-                    if (is_array($value)) {
266
-                        $c_input = '';
267
-                        foreach ($value as $key => $val) {
268
-                            $c_input .= self::adminMulti(
269
-                                $default,
270
-                                isset($classes[ $key ]) ? $classes[ $key ] : '',
271
-                                $field_name . '_' . $value,
272
-                                $name,
273
-                                $required,
274
-                                $tab_index,
275
-                                $type,
276
-                                $val,
277
-                                isset($labels[ $key ]) ? $labels[ $key ] : ''
278
-                            );
279
-                        }
280
-                        $field = $c_input;
281
-                    } else {
282
-                        $field = self::adminMulti(
283
-                            $default,
284
-                            $class,
285
-                            $id,
286
-                            $name,
287
-                            $required,
288
-                            $tab_index,
289
-                            $type,
290
-                            $value,
291
-                            $_fields['label']
292
-                        );
293
-                    }
294
-                    break;
295
-
296
-                case 'hidden':
297
-                    $field = self::adminHidden($class, $id, $name, $value);
298
-                    break;
299
-
300
-                case 'select':
301
-                    $options = [];
302
-                    foreach ($value as $key => $val) {
303
-                        $options[ $val ] = isset($labels[ $key ]) ? $labels[ $key ] : '';
304
-                    }
305
-                    $field = self::adminSelect($default, $class, $id, $name, $required, $tab_index, $options);
306
-                    break;
307
-
308
-                case 'textarea':
309
-                    $field =
310
-                        self::adminTextarea($class, $dims[0], $id, $name, $required, $dims[1], $tab_index, $value);
311
-                    break;
312
-
313
-                case 'wp_editor':
314
-                    $field = self::adminWpEditor(
315
-                        $class,
316
-                        $_fields['id'],
317
-                        $name,
318
-                        $dims[1],
319
-                        $tab_index,
320
-                        $value,
321
-                        $wp_editor_args
322
-                    );
323
-                    break;
324
-
325
-                default:
326
-                    $field = self::adminText($class, $id, $name, $required, $tab_index, $value);
327
-            }
328
-
329
-            $form_fields[ $field_name ] = ['label' => $label, 'field' => $field . $extra_desc];
330
-        }
331
-
332
-        return $form_fields;
333
-    }
334
-
335
-
336
-    /**
337
-     * @param string $class
338
-     * @param string $id
339
-     * @param string $name
340
-     * @param string $value
341
-     * @return string
342
-     * @since   4.10.14.p
343
-     */
344
-    private static function adminHidden($class, $id, $name, $value)
345
-    {
346
-        $id    = esc_attr($id);
347
-        $name  = esc_attr($name);
348
-        $class = esc_attr($class);
349
-        return "
177
+		}
178
+		return $output . implode("\n", $hidden_inputs);
179
+	}
180
+
181
+
182
+	/**
183
+	 * form_fields_array
184
+	 * This utility function assembles form fields from a given structured array with field information.
185
+	 * //TODO: This is an alternate generator that we may want to use instead.
186
+	 *
187
+	 * @param array $fields structured array of fields to assemble in the following format:
188
+	 *                      [field_name] => array(
189
+	 *                      ['label'] => 'label for field',
190
+	 *                      ['labels'] => array('label_1', 'label_2'); //optional - if the field type is a multi select
191
+	 *                      type of field you can indicated the labels for each option via this index
192
+	 *                      ['extra_desc'] => 'extra description for the field', //optional
193
+	 *                      ['type'] => 'textarea'|'text'|'wp_editor'|'checkbox'|'radio'|'hidden'|'select', //defaults
194
+	 *                      to text
195
+	 *                      ['value'] => 'value that goes in the field', //(if multi then this is an array of values
196
+	 *                      and the 'default' paramater will be used for what is selected)
197
+	 *                      ['default'] => 'default if the field type is multi (i.e. select or radios or checkboxes)',
198
+	 *                      ['class'] => 'name-of-class(es)-for-input',
199
+	 *                      ['classes'] => array('class_1', 'class_2'); //optional - if the field type is a multi
200
+	 *                      select type of field you can indicate the css class for each option via this index.
201
+	 *                      ['id'] => 'css-id-for-input') //defaults to 'field_name'
202
+	 *                      ['unique_id'] => 1 //defaults to empty string.  This is useful for when the fields
203
+	 *                      generated are going to be used in a loop and you want to make sure that the field
204
+	 *                      identifiers are unique from each other.
205
+	 *                      ['dimensions'] => array(100,300), //defaults to empty array.  This is used by field types
206
+	 *                      such as textarea to indicate cols/rows.
207
+	 *                      ['tabindex'] => '' //this allows you to set the tabindex for the field.
208
+	 *                      ['wpeditor_args'] => array() //if the type of field is wpeditor then this can optionally
209
+	 *                      contain an array of arguments for the editor setup.
210
+	 *
211
+	 * @return array         an array of inputs for form indexed by field name, and in the following structure:
212
+	 *     [field_name] => array( 'label' => '{label_html}', 'field' => '{input_html}'
213
+	 */
214
+	public static function get_form_fields_array($fields)
215
+	{
216
+
217
+		$form_fields = [];
218
+		$fields      = (array) $fields;
219
+
220
+		foreach ($fields as $field_name => $field_atts) {
221
+			// defaults:
222
+			$defaults = [
223
+				'class'         => '',
224
+				'classes'       => '',
225
+				'default'       => '',
226
+				'dimensions'    => ['10', '5'],
227
+				'extra_desc'    => '',
228
+				'id'            => $field_name,
229
+				'label'         => '',
230
+				'labels'        => '',
231
+				'required'      => false,
232
+				'tabindex'      => 0,
233
+				'type'          => 'text',
234
+				'unique_id'     => '',
235
+				'value'         => '',
236
+				'wpeditor_args' => [],
237
+			];
238
+			// merge defaults with passed arguments
239
+			$_fields = wp_parse_args($field_atts, $defaults);
240
+
241
+			$class          = $_fields['class'];
242
+			$classes        = $_fields['classes'];
243
+			$default        = $_fields['default'];
244
+			$dims           = $_fields['dimensions'];
245
+			$extra_desc     = $_fields['extra_desc'];
246
+			$id             = $_fields['id'];
247
+			$label          = $_fields['label'];
248
+			$labels         = $_fields['labels'];
249
+			$required       = $_fields['required'];
250
+			$tab_index      = $_fields['tabindex'];
251
+			$type           = $_fields['type'];
252
+			$unique_id      = $_fields['unique_id'];
253
+			$value          = $_fields['value'];
254
+			$wp_editor_args = $_fields['wpeditor_args'];
255
+
256
+			// generate label
257
+			$label = ! empty($label) ? self::adminLabel($id, $label, $required) : '';
258
+			// generate field name
259
+			$name = ! empty($unique_id) ? $field_name . '[' . $unique_id . ']' : $field_name;
260
+
261
+			// we determine what we're building based on the type
262
+			switch ($type) {
263
+				case 'checkbox':
264
+				case 'radio':
265
+					if (is_array($value)) {
266
+						$c_input = '';
267
+						foreach ($value as $key => $val) {
268
+							$c_input .= self::adminMulti(
269
+								$default,
270
+								isset($classes[ $key ]) ? $classes[ $key ] : '',
271
+								$field_name . '_' . $value,
272
+								$name,
273
+								$required,
274
+								$tab_index,
275
+								$type,
276
+								$val,
277
+								isset($labels[ $key ]) ? $labels[ $key ] : ''
278
+							);
279
+						}
280
+						$field = $c_input;
281
+					} else {
282
+						$field = self::adminMulti(
283
+							$default,
284
+							$class,
285
+							$id,
286
+							$name,
287
+							$required,
288
+							$tab_index,
289
+							$type,
290
+							$value,
291
+							$_fields['label']
292
+						);
293
+					}
294
+					break;
295
+
296
+				case 'hidden':
297
+					$field = self::adminHidden($class, $id, $name, $value);
298
+					break;
299
+
300
+				case 'select':
301
+					$options = [];
302
+					foreach ($value as $key => $val) {
303
+						$options[ $val ] = isset($labels[ $key ]) ? $labels[ $key ] : '';
304
+					}
305
+					$field = self::adminSelect($default, $class, $id, $name, $required, $tab_index, $options);
306
+					break;
307
+
308
+				case 'textarea':
309
+					$field =
310
+						self::adminTextarea($class, $dims[0], $id, $name, $required, $dims[1], $tab_index, $value);
311
+					break;
312
+
313
+				case 'wp_editor':
314
+					$field = self::adminWpEditor(
315
+						$class,
316
+						$_fields['id'],
317
+						$name,
318
+						$dims[1],
319
+						$tab_index,
320
+						$value,
321
+						$wp_editor_args
322
+					);
323
+					break;
324
+
325
+				default:
326
+					$field = self::adminText($class, $id, $name, $required, $tab_index, $value);
327
+			}
328
+
329
+			$form_fields[ $field_name ] = ['label' => $label, 'field' => $field . $extra_desc];
330
+		}
331
+
332
+		return $form_fields;
333
+	}
334
+
335
+
336
+	/**
337
+	 * @param string $class
338
+	 * @param string $id
339
+	 * @param string $name
340
+	 * @param string $value
341
+	 * @return string
342
+	 * @since   4.10.14.p
343
+	 */
344
+	private static function adminHidden($class, $id, $name, $value)
345
+	{
346
+		$id    = esc_attr($id);
347
+		$name  = esc_attr($name);
348
+		$class = esc_attr($class);
349
+		return "
350 350
         <input name='{$name}' type='hidden' id='{$id}' class='{$class}' value='{$value}' />";
351
-    }
352
-
353
-
354
-    /**
355
-     * @param string $id
356
-     * @param string $label
357
-     * @param string $required
358
-     * @return string
359
-     * @since   4.10.14.p
360
-     */
361
-    private static function adminLabel($id, $label, $required)
362
-    {
363
-        $id       = esc_attr($id);
364
-        $label    = esc_html($label);
365
-        $required = filter_var($required, FILTER_VALIDATE_BOOLEAN) ? " <span>*</span>" : '';
366
-        return "<label for='{$id}'>{$label}{$required}</label>";
367
-    }
368
-
369
-
370
-    /**
371
-     * @param string $default
372
-     * @param string $class
373
-     * @param string $id
374
-     * @param string $name
375
-     * @param string $required
376
-     * @param int    $tab_index
377
-     * @param string $type
378
-     * @param string $value
379
-     * @param string $label
380
-     * @return string
381
-     * @since   4.10.14.p
382
-     */
383
-    private static function adminMulti($default, $class, $id, $name, $required, $tab_index, $type, $value, $label = '')
384
-    {
385
-        $id        = esc_attr($id);
386
-        $name      = esc_attr($name);
387
-        $class     = esc_attr($class);
388
-        $tab_index = absint($tab_index);
389
-        $checked   = ! empty($default) && $default == $value ? 'checked="checked" ' : '';
390
-        $required  = filter_var($required, FILTER_VALIDATE_BOOLEAN) ? 'required' : '';
391
-        $input     = "
351
+	}
352
+
353
+
354
+	/**
355
+	 * @param string $id
356
+	 * @param string $label
357
+	 * @param string $required
358
+	 * @return string
359
+	 * @since   4.10.14.p
360
+	 */
361
+	private static function adminLabel($id, $label, $required)
362
+	{
363
+		$id       = esc_attr($id);
364
+		$label    = esc_html($label);
365
+		$required = filter_var($required, FILTER_VALIDATE_BOOLEAN) ? " <span>*</span>" : '';
366
+		return "<label for='{$id}'>{$label}{$required}</label>";
367
+	}
368
+
369
+
370
+	/**
371
+	 * @param string $default
372
+	 * @param string $class
373
+	 * @param string $id
374
+	 * @param string $name
375
+	 * @param string $required
376
+	 * @param int    $tab_index
377
+	 * @param string $type
378
+	 * @param string $value
379
+	 * @param string $label
380
+	 * @return string
381
+	 * @since   4.10.14.p
382
+	 */
383
+	private static function adminMulti($default, $class, $id, $name, $required, $tab_index, $type, $value, $label = '')
384
+	{
385
+		$id        = esc_attr($id);
386
+		$name      = esc_attr($name);
387
+		$class     = esc_attr($class);
388
+		$tab_index = absint($tab_index);
389
+		$checked   = ! empty($default) && $default == $value ? 'checked="checked" ' : '';
390
+		$required  = filter_var($required, FILTER_VALIDATE_BOOLEAN) ? 'required' : '';
391
+		$input     = "
392 392
         <input name='{$name}[]' type='{$type}' id='{$id}' class='{$class}' value='{$value}' {$checked} {$required} tabindex='{$tab_index}'/>";
393
-        if ($label === '') {
394
-            return $input;
395
-        }
396
-        $label = esc_html($label);
397
-        $label_class = self::appendInputSizeClass('', $label);
398
-        $label_class = $label_class ? ' class="' . $label_class . '"' : '';
399
-        return "
393
+		if ($label === '') {
394
+			return $input;
395
+		}
396
+		$label = esc_html($label);
397
+		$label_class = self::appendInputSizeClass('', $label);
398
+		$label_class = $label_class ? ' class="' . $label_class . '"' : '';
399
+		return "
400 400
         <label for='$id'{$label_class}>
401 401
             {$input}
402 402
             {$label}
403 403
         </label>";
404
-    }
405
-
406
-
407
-    /**
408
-     * @param string $default
409
-     * @param string $class
410
-     * @param string $id
411
-     * @param string $name
412
-     * @param string $required
413
-     * @param int    $tab_index
414
-     * @param array  $options
415
-     * @return string
416
-     * @since   4.10.14.p
417
-     */
418
-    private static function adminSelect($default, $class, $id, $name, $required, $tab_index, $options = [])
419
-    {
420
-        $options_array = [];
421
-        foreach ($options as $value => $label) {
422
-            $selected        = ! empty($default) && $default == $value ? 'selected="selected"' : '';
423
-            $value           = esc_attr($value);
424
-            $label           = wp_strip_all_tags($label);
425
-            $options_array[] = "<option value='{$value}' {$selected}>{$label}</option>";
426
-        }
427
-        $options_html = implode($options_array, "\n");
428
-        $id           = esc_attr($id);
429
-        $name         = esc_attr($name);
430
-        $class        = esc_attr($class);
431
-        $tab_index    = absint($tab_index);
432
-        $required     = filter_var($required, FILTER_VALIDATE_BOOLEAN) ? 'required' : '';
433
-
434
-        $class = self::appendInputSizeClass($class, $options);
435
-
436
-        return "
404
+	}
405
+
406
+
407
+	/**
408
+	 * @param string $default
409
+	 * @param string $class
410
+	 * @param string $id
411
+	 * @param string $name
412
+	 * @param string $required
413
+	 * @param int    $tab_index
414
+	 * @param array  $options
415
+	 * @return string
416
+	 * @since   4.10.14.p
417
+	 */
418
+	private static function adminSelect($default, $class, $id, $name, $required, $tab_index, $options = [])
419
+	{
420
+		$options_array = [];
421
+		foreach ($options as $value => $label) {
422
+			$selected        = ! empty($default) && $default == $value ? 'selected="selected"' : '';
423
+			$value           = esc_attr($value);
424
+			$label           = wp_strip_all_tags($label);
425
+			$options_array[] = "<option value='{$value}' {$selected}>{$label}</option>";
426
+		}
427
+		$options_html = implode($options_array, "\n");
428
+		$id           = esc_attr($id);
429
+		$name         = esc_attr($name);
430
+		$class        = esc_attr($class);
431
+		$tab_index    = absint($tab_index);
432
+		$required     = filter_var($required, FILTER_VALIDATE_BOOLEAN) ? 'required' : '';
433
+
434
+		$class = self::appendInputSizeClass($class, $options);
435
+
436
+		return "
437 437
         <select name='{$name}' id='{$id}' class='{$class}' {$required} tabindex='{$tab_index}'>
438 438
             {$options_html}
439 439
         </select>";
440
-    }
441
-
442
-
443
-    /**
444
-     * @param string $class
445
-     * @param string $id
446
-     * @param string $name
447
-     * @param string $required
448
-     * @param int    $tab_index
449
-     * @param string $value
450
-     * @return string
451
-     * @since   4.10.14.p
452
-     */
453
-    private static function adminText($class, $id, $name, $required, $tab_index, $value)
454
-    {
455
-        $id        = esc_attr($id);
456
-        $name      = esc_attr($name);
457
-        $class     = esc_attr($class);
458
-        $tab_index = absint($tab_index);
459
-        $required  = filter_var($required, FILTER_VALIDATE_BOOLEAN) ? 'required' : '';
460
-        $class     = self::appendInputSizeClass($class, $value);
461
-        return "
440
+	}
441
+
442
+
443
+	/**
444
+	 * @param string $class
445
+	 * @param string $id
446
+	 * @param string $name
447
+	 * @param string $required
448
+	 * @param int    $tab_index
449
+	 * @param string $value
450
+	 * @return string
451
+	 * @since   4.10.14.p
452
+	 */
453
+	private static function adminText($class, $id, $name, $required, $tab_index, $value)
454
+	{
455
+		$id        = esc_attr($id);
456
+		$name      = esc_attr($name);
457
+		$class     = esc_attr($class);
458
+		$tab_index = absint($tab_index);
459
+		$required  = filter_var($required, FILTER_VALIDATE_BOOLEAN) ? 'required' : '';
460
+		$class     = self::appendInputSizeClass($class, $value);
461
+		return "
462 462
         <input name='{$name}' type='text' id='{$id}' class='{$class}' value='{$value}' {$required} tabindex='{$tab_index}'/>";
463
-    }
464
-
465
-
466
-    /**
467
-     * @param string $class
468
-     * @param int    $cols
469
-     * @param string $id
470
-     * @param string $name
471
-     * @param string $required
472
-     * @param int    $rows
473
-     * @param int    $tab_index
474
-     * @param string $value
475
-     * @return string
476
-     * @since   4.10.14.p
477
-     */
478
-    private static function adminTextarea($class, $cols, $id, $name, $required, $rows, $tab_index, $value)
479
-    {
480
-        $id        = esc_attr($id);
481
-        $name      = esc_attr($name);
482
-        $class     = esc_attr($class);
483
-        $cols      = absint($cols);
484
-        $rows      = absint($rows);
485
-        $value     = esc_textarea($value);
486
-        $tab_index = absint($tab_index);
487
-        $required  = filter_var($required, FILTER_VALIDATE_BOOLEAN) ? 'required' : '';
488
-        return "
463
+	}
464
+
465
+
466
+	/**
467
+	 * @param string $class
468
+	 * @param int    $cols
469
+	 * @param string $id
470
+	 * @param string $name
471
+	 * @param string $required
472
+	 * @param int    $rows
473
+	 * @param int    $tab_index
474
+	 * @param string $value
475
+	 * @return string
476
+	 * @since   4.10.14.p
477
+	 */
478
+	private static function adminTextarea($class, $cols, $id, $name, $required, $rows, $tab_index, $value)
479
+	{
480
+		$id        = esc_attr($id);
481
+		$name      = esc_attr($name);
482
+		$class     = esc_attr($class);
483
+		$cols      = absint($cols);
484
+		$rows      = absint($rows);
485
+		$value     = esc_textarea($value);
486
+		$tab_index = absint($tab_index);
487
+		$required  = filter_var($required, FILTER_VALIDATE_BOOLEAN) ? 'required' : '';
488
+		return "
489 489
         <textarea name='{$name}' id='{$id}' class='{$class}' rows='{$rows}' cols='{$cols}' {$required} tabindex='{$tab_index}'>{$value}</textarea>";
490
-    }
491
-
492
-
493
-    /**
494
-     * @param string $class
495
-     * @param string $id
496
-     * @param string $name
497
-     * @param int    $rows
498
-     * @param int    $tab_index
499
-     * @param string $value
500
-     * @param array  $wp_editor_args
501
-     * @return false|string
502
-     * @since   4.10.14.p
503
-     */
504
-    private static function adminWpEditor($class, $id, $name, $rows, $tab_index, $value, $wp_editor_args = [])
505
-    {
506
-        $editor_settings = $wp_editor_args + [
507
-                'textarea_name' => esc_attr($name),
508
-                'textarea_rows' => absint($rows),
509
-                'editor_class'  => esc_attr($class),
510
-                'tabindex'      => absint($tab_index),
511
-            ];
512
-        ob_start();
513
-        wp_editor($value, esc_attr($id), $editor_settings);
514
-        return ob_get_clean();
515
-    }
516
-
517
-
518
-    /**
519
-     * espresso admin page select_input
520
-     * Turns an array into a select fields
521
-     *
522
-     * @static
523
-     * @access public
524
-     * @param string  $name       field name
525
-     * @param array   $values     option values, numbered array starting at 0, where each value is an array with a key
526
-     *                            'text' (meaning text to display' and 'id' (meaning the internal value) eg:
527
-     *                            array(1=>array('text'=>'Monday','id'=>1),2=>array('text'=>'Tuesday','id'=>2)...). or
528
-     *                            as an array of key-value pairs, where the key is to be used for the select input's
529
-     *                            name, and the value will be the text shown to the user.  Optionally you can also
530
-     *                            include an additional key of "class" which will add a specific class to the option
531
-     *                            for that value.
532
-     * @param string  $default    default value
533
-     * @param string  $parameters extra parameters
534
-     * @param string  $class      css class
535
-     * @param boolean $autosize   whether to autosize the select or not
536
-     * @return string              html string for the select input
537
-     */
538
-    public static function select_input(
539
-        $name,
540
-        $values,
541
-        $default = '',
542
-        $parameters = '',
543
-        $class = '',
544
-        $autosize = true
545
-    ) {
546
-        // if $values was submitted in the wrong format, convert it over
547
-        if (! empty($values) && (! array_key_exists(0, $values) || ! is_array($values[0]))) {
548
-            $converted_values = [];
549
-            foreach ($values as $id => $text) {
550
-                $converted_values[] = ['id' => $id, 'text' => $text];
551
-            }
552
-            $values = $converted_values;
553
-        }
554
-
555
-        $field =
556
-            '<select id="' . EEH_Formatter::ee_tep_output_string($name)
557
-            . '" name="' . EEH_Formatter::ee_tep_output_string($name)
558
-            . '"';
559
-
560
-        if (EEH_Formatter::ee_tep_not_null($parameters)) {
561
-            $field .= ' ' . $parameters;
562
-        }
563
-        $class = $autosize ? self::appendInputSizeClass($class, $values) : '';
564
-
565
-        $field .= ' class="' . $class . '">';
566
-
567
-        if (empty($default) && isset($GLOBALS[ $name ])) {
568
-            $default = stripslashes($GLOBALS[ $name ]);
569
-        }
570
-
571
-        $field .= self::selectInputOption($values, $default);
572
-        $field .= '</select>';
573
-
574
-        return $field;
575
-    }
576
-
577
-
578
-    private static function selectInputOption(array $values, $default): string
579
-    {
580
-        if (isset($values['id'], $values['text'])) {
581
-            $id = is_scalar($values['id']) ? $values['id'] : '';
582
-            $text = is_scalar($values['text']) ? $values['text'] : '';
583
-            $selected = $default == $values['id'] ? ' selected = "selected"' : '';
584
-            $html_class = isset($values['class']) ? ' class="' . $values['class'] . '"' : '';
585
-            return "<option value='{$id}'{$selected}{$html_class}>{$text}</option>";
586
-        }
587
-        $options = '';
588
-        foreach ($values as $value) {
589
-            $options .= self::selectInputOption($value, $default);
590
-        }
591
-        return $options;
592
-    }
593
-
594
-
595
-    /**
596
-     * @param mixed $value
597
-     * @return int
598
-     * @since   $VID:$
599
-     */
600
-    private static function getInputValueLength($value): int
601
-    {
602
-        if ($value instanceof EE_Question_Option) {
603
-            return self::getInputValueLength($value->desc());
604
-        }
605
-        if (is_array($value)) {
606
-            $chars = 0;
607
-            foreach ($value as $val) {
608
-                $length = self::getInputValueLength($val);
609
-                $chars = $length > $chars ? $length : $chars;
610
-            }
611
-            return $chars;
612
-        }
613
-        // not a primitive? return something big
614
-        if (! is_scalar($value)) {
615
-            return 500;
616
-        }
617
-        return strlen((string) $value);
618
-    }
619
-
620
-
621
-    /**
622
-     * @param string $class
623
-     * @param mixed $value
624
-     * @return string
625
-     * @since   $VID:$
626
-     */
627
-    private static function appendInputSizeClass(string $class, $value): string
628
-    {
629
-        if (strpos($class, 'ee-input-width--') !== false) {
630
-            return $class;
631
-        }
632
-        $chars = self::getInputValueLength($value);
633
-        if ($chars && $chars < 5) {
634
-            return "{$class} ee-input-width--tiny";
635
-        }
636
-        if ($chars && $chars < 15) {
637
-            return "{$class} ee-input-width--small";
638
-        }
639
-        if ($chars && $chars > 100) {
640
-            return "{$class} ee-input-width--big";
641
-        }
642
-        return "{$class} ee-input-width--reg";
643
-    }
644
-
645
-
646
-    /**
647
-     * generate_question_groups_html
648
-     *
649
-     * @param array  $question_groups
650
-     * @param string $group_wrapper
651
-     * @return string HTML
652
-     * @throws EE_Error
653
-     * @throws ReflectionException
654
-     */
655
-    public static function generate_question_groups_html($question_groups = [], $group_wrapper = 'fieldset')
656
-    {
657
-
658
-        $html                            = '';
659
-        $before_question_group_questions =
660
-            apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '');
661
-        $after_question_group_questions  =
662
-            apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '');
663
-
664
-        if (! empty($question_groups)) {
665
-            // loop thru question groups
666
-            foreach ($question_groups as $QSG) {
667
-                // check that questions exist
668
-                if (! empty($QSG['QSG_questions'])) {
669
-                    // use fieldsets
670
-                    $html .= "\n\t"
671
-                             . '<'
672
-                             . $group_wrapper
673
-                             . ' class="espresso-question-group-wrap" id="'
674
-                             . $QSG['QSG_identifier']
675
-                             . '">';
676
-                    // group_name
677
-                    $html .= $QSG['QSG_show_group_name']
678
-                        ? "\n\t\t"
679
-                          . '<h5 class="espresso-question-group-title-h5 section-title">'
680
-                          . self::prep_answer($QSG['QSG_name'])
681
-                          . '</h5>'
682
-                        : '';
683
-                    // group_desc
684
-                    $html .= $QSG['QSG_show_group_desc'] && ! empty($QSG['QSG_desc'])
685
-                        ? '<div class="espresso-question-group-desc-pg">'
686
-                          . self::prep_answer($QSG['QSG_desc'])
687
-                          . '</div>'
688
-                        : '';
689
-
690
-                    $html .= $before_question_group_questions;
691
-                    // loop thru questions
692
-                    foreach ($QSG['QSG_questions'] as $question) {
693
-                        $QFI  = new EE_Question_Form_Input(
694
-                            $question['qst_obj'],
695
-                            $question['ans_obj'],
696
-                            $question
697
-                        );
698
-                        $html .= self::generate_form_input($QFI);
699
-                    }
700
-                    $html .= $after_question_group_questions;
701
-                    $html .= "\n\t" . '</' . $group_wrapper . '>';
702
-                }
703
-            }
704
-        }
705
-
706
-        return $html;
707
-    }
708
-
709
-
710
-    /**
711
-     * generate_question_groups_html
712
-     *
713
-     * @param array  $question_groups
714
-     * @param array  $q_meta
715
-     * @param bool   $from_admin
716
-     * @param string $group_wrapper
717
-     * @return string HTML
718
-     * @throws EE_Error
719
-     * @throws ReflectionException
720
-     */
721
-    public static function generate_question_groups_html2(
722
-        $question_groups = [],
723
-        $q_meta = [],
724
-        $from_admin = false,
725
-        $group_wrapper = 'fieldset'
726
-    ) {
727
-
728
-        $html                            = '';
729
-        $before_question_group_questions =
730
-            apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '');
731
-        $after_question_group_questions  =
732
-            apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '');
733
-
734
-        $default_q_meta = [
735
-            'att_nmbr'    => 1,
736
-            'ticket_id'   => '',
737
-            'input_name'  => '',
738
-            'input_id'    => '',
739
-            'input_class' => '',
740
-        ];
741
-        $q_meta         = array_merge($default_q_meta, $q_meta);
742
-
743
-        if (! empty($question_groups)) {
744
-            // loop thru question groups
745
-            foreach ($question_groups as $QSG) {
746
-                if ($QSG instanceof EE_Question_Group) {
747
-                    // check that questions exist
748
-
749
-                    $where = ['QST_deleted' => 0];
750
-                    if (! $from_admin) {
751
-                        $where['QST_admin_only'] = 0;
752
-                    }
753
-                    $questions =
754
-                        $QSG->questions([$where, 'order_by' => ['Question_Group_Question.QGQ_order' => 'ASC']]);
755
-                    if (! empty($questions)) {
756
-                        // use fieldsets
757
-                        $html .= "\n\t"
758
-                                 . '<' . $group_wrapper . ' class="espresso-question-group-wrap" '
759
-                                 . 'id="' . $QSG->get('QSG_identifier') . '">';
760
-                        // group_name
761
-                        if ($QSG->show_group_name()) {
762
-                            $html .= "\n\t\t"
763
-                                     . '<h5 class="espresso-question-group-title-h5 section-title">'
764
-                                     . $QSG->get_pretty('QSG_name')
765
-                                     . '</h5>';
766
-                        }
767
-                        // group_desc
768
-                        if ($QSG->show_group_desc()) {
769
-                            $html .= '<div class="espresso-question-group-desc-pg">'
770
-                                     . $QSG->get_pretty('QSG_desc')
771
-                                     . '</div>';
772
-                        }
773
-
774
-                        $html .= $before_question_group_questions;
775
-                        // loop thru questions
776
-                        foreach ($questions as $QST) {
777
-                            $qstn_id = $QST->is_system_question() ? $QST->system_ID() : $QST->ID();
778
-
779
-                            $answer = null;
780
-
781
-                            /** @var RequestInterface $request */
782
-                            $request      = LoaderFactory::getLoader()->getShared(RequestInterface::class);
783
-                            $request_qstn = $request->getRequestParam('qstn', [], 'string', true);
784
-                            if (! empty($request_qstn) && isset($q_meta['input_id']) && isset($q_meta['att_nmbr'])) {
785
-                                // check for answer in $request_qstn in case we are reprocessing a form after an error
786
-                                if (isset($request_qstn[ $q_meta['input_id'] ][ $qstn_id ])) {
787
-                                    $answer = is_array($request_qstn[ $q_meta['input_id'] ][ $qstn_id ])
788
-                                        ? $request_qstn[ $q_meta['input_id'] ][ $qstn_id ]
789
-                                        : sanitize_text_field($request_qstn[ $q_meta['input_id'] ][ $qstn_id ]);
790
-                                }
791
-                            } elseif (isset($q_meta['attendee']) && $q_meta['attendee']) {
792
-                                // attendee data from the session
793
-                                $answer =
794
-                                    isset($q_meta['attendee'][ $qstn_id ]) ? $q_meta['attendee'][ $qstn_id ] : null;
795
-                            }
796
-
797
-
798
-                            $QFI  = new EE_Question_Form_Input(
799
-                                $QST,
800
-                                EE_Answer::new_instance(
801
-                                    [
802
-                                        'ANS_ID'    => 0,
803
-                                        'QST_ID'    => 0,
804
-                                        'REG_ID'    => 0,
805
-                                        'ANS_value' => $answer,
806
-                                    ]
807
-                                ),
808
-                                $q_meta
809
-                            );
810
-                            $html .= self::generate_form_input($QFI);
811
-                        }
812
-                        $html .= $after_question_group_questions;
813
-                        $html .= "\n\t" . '</' . $group_wrapper . '>';
814
-                    }
815
-                }
816
-            }
817
-        }
818
-        return $html;
819
-    }
820
-
821
-
822
-    /**
823
-     * generate_form_input
824
-     *
825
-     * @param EE_Question_Form_Input $QFI
826
-     * @return string HTML
827
-     * @throws EE_Error
828
-     * @throws ReflectionException
829
-     */
830
-    public static function generate_form_input(EE_Question_Form_Input $QFI)
831
-    {
832
-        if (isset($QFI->QST_admin_only) && $QFI->QST_admin_only && ! is_admin()) {
833
-            return '';
834
-        }
835
-        /** @var RequestInterface $request */
836
-        $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
837
-
838
-        $QFI = self::_load_system_dropdowns($QFI);
839
-        $QFI = self::_load_specialized_dropdowns($QFI);
840
-
841
-        // we also need to verify
842
-
843
-        $display_text = $QFI->get('QST_display_text');
844
-        $input_name   = $QFI->get('QST_input_name');
845
-        $answer       = $request->getRequestParam($input_name, $QFI->get('ANS_value'));
846
-        $input_id     = $QFI->get('QST_input_id');
847
-        $input_class  = $QFI->get('QST_input_class');
848
-        //      $disabled = $QFI->get('QST_disabled') ? ' disabled="disabled"' : '';
849
-        $disabled          = $QFI->get('QST_disabled');
850
-        $required_label    = apply_filters(' FHEE__EEH_Form_Fields__generate_form_input__required_label', '<em>*</em>');
851
-        $QST_required      = $QFI->get('QST_required');
852
-        $required          =
853
-            $QST_required
854
-                ? ['label' => $required_label, 'class' => 'required needs-value', 'title' => $QST_required]
855
-                : [];
856
-        $use_html_entities = $QFI->get_meta('htmlentities');
857
-        $required_text     =
858
-            $QFI->get('QST_required_text') != ''
859
-                ? $QFI->get('QST_required_text')
860
-                : esc_html__('This field is required', 'event_espresso');
861
-        $required_text     = $QST_required
862
-            ? "\n\t\t\t"
863
-              . '<div class="required-text hidden">'
864
-              . self::prep_answer($required_text, $use_html_entities)
865
-              . '</div>'
866
-            : '';
867
-        $label_class       = $QFI->get('label_class');
868
-        $label_class       = $label_class ? "{$label_class} espresso-form-input-lbl" : 'espresso-form-input-lbl';
869
-        $QST_options       = $QFI->options(true, $answer);
870
-        $options           = is_array($QST_options) ? self::prep_answer_options($QST_options) : [];
871
-        $system_ID         = $QFI->get('QST_system');
872
-        $label_b4          = $QFI->get_meta('label_b4');
873
-        $use_desc_4_label  = $QFI->get_meta('use_desc_4_label');
874
-        $add_mobile_label  = $QFI->get_meta('add_mobile_label');
875
-
876
-
877
-        switch ($QFI->get('QST_type')) {
878
-            case 'TEXTAREA':
879
-                return EEH_Form_Fields::textarea(
880
-                    $display_text,
881
-                    $answer,
882
-                    $input_name,
883
-                    $input_id,
884
-                    $input_class,
885
-                    [],
886
-                    $required,
887
-                    $required_text,
888
-                    $label_class,
889
-                    $disabled,
890
-                    $system_ID,
891
-                    $use_html_entities,
892
-                    $add_mobile_label
893
-                );
894
-
895
-            case 'DROPDOWN':
896
-                return EEH_Form_Fields::select(
897
-                    $display_text,
898
-                    $answer,
899
-                    $options,
900
-                    $input_name,
901
-                    $input_id,
902
-                    $input_class,
903
-                    $required,
904
-                    $required_text,
905
-                    $label_class,
906
-                    $disabled,
907
-                    $system_ID,
908
-                    $use_html_entities,
909
-                    true,
910
-                    $add_mobile_label
911
-                );
912
-
913
-
914
-            case 'RADIO_BTN':
915
-                return EEH_Form_Fields::radio(
916
-                    $display_text,
917
-                    $answer,
918
-                    $options,
919
-                    $input_name,
920
-                    $input_id,
921
-                    $input_class,
922
-                    $required,
923
-                    $required_text,
924
-                    $label_class,
925
-                    $disabled,
926
-                    $system_ID,
927
-                    $use_html_entities,
928
-                    $label_b4,
929
-                    $use_desc_4_label,
930
-                    $add_mobile_label
931
-                );
932
-
933
-            case 'CHECKBOX':
934
-                return EEH_Form_Fields::checkbox(
935
-                    $display_text,
936
-                    $answer,
937
-                    $options,
938
-                    $input_name,
939
-                    $input_id,
940
-                    $input_class,
941
-                    $required,
942
-                    $required_text,
943
-                    $label_class,
944
-                    $disabled,
945
-                    $label_b4,
946
-                    $system_ID,
947
-                    $use_html_entities,
948
-                    $add_mobile_label
949
-                );
950
-
951
-            case 'DATE':
952
-                return EEH_Form_Fields::datepicker(
953
-                    $display_text,
954
-                    $answer,
955
-                    $input_name,
956
-                    $input_id,
957
-                    $input_class,
958
-                    $required,
959
-                    $required_text,
960
-                    $label_class,
961
-                    $disabled,
962
-                    $system_ID,
963
-                    $use_html_entities,
964
-                    $add_mobile_label
965
-                );
966
-
967
-            case 'TEXT':
968
-            default:
969
-                return EEH_Form_Fields::text(
970
-                    $display_text,
971
-                    $answer,
972
-                    $input_name,
973
-                    $input_id,
974
-                    $input_class,
975
-                    $required,
976
-                    $required_text,
977
-                    $label_class,
978
-                    $disabled,
979
-                    $system_ID,
980
-                    $use_html_entities,
981
-                    $add_mobile_label
982
-                );
983
-        }
984
-    }
985
-
986
-
987
-    public static function label(
988
-        string $question,
989
-        string $required_text = '',
990
-        string $required_label = '',
991
-        string $name = '',
992
-        string $label_class = '',
993
-        bool $filter = true
994
-    ): string {
995
-        $for   = ! empty($name) ? " for='{$name}'" : '';
996
-        $class = ! empty($label_class) ? " class='{$label_class}'" : '';
997
-        $label = self::prep_question($question) . $required_label;
998
-        $label_html = "
490
+	}
491
+
492
+
493
+	/**
494
+	 * @param string $class
495
+	 * @param string $id
496
+	 * @param string $name
497
+	 * @param int    $rows
498
+	 * @param int    $tab_index
499
+	 * @param string $value
500
+	 * @param array  $wp_editor_args
501
+	 * @return false|string
502
+	 * @since   4.10.14.p
503
+	 */
504
+	private static function adminWpEditor($class, $id, $name, $rows, $tab_index, $value, $wp_editor_args = [])
505
+	{
506
+		$editor_settings = $wp_editor_args + [
507
+				'textarea_name' => esc_attr($name),
508
+				'textarea_rows' => absint($rows),
509
+				'editor_class'  => esc_attr($class),
510
+				'tabindex'      => absint($tab_index),
511
+			];
512
+		ob_start();
513
+		wp_editor($value, esc_attr($id), $editor_settings);
514
+		return ob_get_clean();
515
+	}
516
+
517
+
518
+	/**
519
+	 * espresso admin page select_input
520
+	 * Turns an array into a select fields
521
+	 *
522
+	 * @static
523
+	 * @access public
524
+	 * @param string  $name       field name
525
+	 * @param array   $values     option values, numbered array starting at 0, where each value is an array with a key
526
+	 *                            'text' (meaning text to display' and 'id' (meaning the internal value) eg:
527
+	 *                            array(1=>array('text'=>'Monday','id'=>1),2=>array('text'=>'Tuesday','id'=>2)...). or
528
+	 *                            as an array of key-value pairs, where the key is to be used for the select input's
529
+	 *                            name, and the value will be the text shown to the user.  Optionally you can also
530
+	 *                            include an additional key of "class" which will add a specific class to the option
531
+	 *                            for that value.
532
+	 * @param string  $default    default value
533
+	 * @param string  $parameters extra parameters
534
+	 * @param string  $class      css class
535
+	 * @param boolean $autosize   whether to autosize the select or not
536
+	 * @return string              html string for the select input
537
+	 */
538
+	public static function select_input(
539
+		$name,
540
+		$values,
541
+		$default = '',
542
+		$parameters = '',
543
+		$class = '',
544
+		$autosize = true
545
+	) {
546
+		// if $values was submitted in the wrong format, convert it over
547
+		if (! empty($values) && (! array_key_exists(0, $values) || ! is_array($values[0]))) {
548
+			$converted_values = [];
549
+			foreach ($values as $id => $text) {
550
+				$converted_values[] = ['id' => $id, 'text' => $text];
551
+			}
552
+			$values = $converted_values;
553
+		}
554
+
555
+		$field =
556
+			'<select id="' . EEH_Formatter::ee_tep_output_string($name)
557
+			. '" name="' . EEH_Formatter::ee_tep_output_string($name)
558
+			. '"';
559
+
560
+		if (EEH_Formatter::ee_tep_not_null($parameters)) {
561
+			$field .= ' ' . $parameters;
562
+		}
563
+		$class = $autosize ? self::appendInputSizeClass($class, $values) : '';
564
+
565
+		$field .= ' class="' . $class . '">';
566
+
567
+		if (empty($default) && isset($GLOBALS[ $name ])) {
568
+			$default = stripslashes($GLOBALS[ $name ]);
569
+		}
570
+
571
+		$field .= self::selectInputOption($values, $default);
572
+		$field .= '</select>';
573
+
574
+		return $field;
575
+	}
576
+
577
+
578
+	private static function selectInputOption(array $values, $default): string
579
+	{
580
+		if (isset($values['id'], $values['text'])) {
581
+			$id = is_scalar($values['id']) ? $values['id'] : '';
582
+			$text = is_scalar($values['text']) ? $values['text'] : '';
583
+			$selected = $default == $values['id'] ? ' selected = "selected"' : '';
584
+			$html_class = isset($values['class']) ? ' class="' . $values['class'] . '"' : '';
585
+			return "<option value='{$id}'{$selected}{$html_class}>{$text}</option>";
586
+		}
587
+		$options = '';
588
+		foreach ($values as $value) {
589
+			$options .= self::selectInputOption($value, $default);
590
+		}
591
+		return $options;
592
+	}
593
+
594
+
595
+	/**
596
+	 * @param mixed $value
597
+	 * @return int
598
+	 * @since   $VID:$
599
+	 */
600
+	private static function getInputValueLength($value): int
601
+	{
602
+		if ($value instanceof EE_Question_Option) {
603
+			return self::getInputValueLength($value->desc());
604
+		}
605
+		if (is_array($value)) {
606
+			$chars = 0;
607
+			foreach ($value as $val) {
608
+				$length = self::getInputValueLength($val);
609
+				$chars = $length > $chars ? $length : $chars;
610
+			}
611
+			return $chars;
612
+		}
613
+		// not a primitive? return something big
614
+		if (! is_scalar($value)) {
615
+			return 500;
616
+		}
617
+		return strlen((string) $value);
618
+	}
619
+
620
+
621
+	/**
622
+	 * @param string $class
623
+	 * @param mixed $value
624
+	 * @return string
625
+	 * @since   $VID:$
626
+	 */
627
+	private static function appendInputSizeClass(string $class, $value): string
628
+	{
629
+		if (strpos($class, 'ee-input-width--') !== false) {
630
+			return $class;
631
+		}
632
+		$chars = self::getInputValueLength($value);
633
+		if ($chars && $chars < 5) {
634
+			return "{$class} ee-input-width--tiny";
635
+		}
636
+		if ($chars && $chars < 15) {
637
+			return "{$class} ee-input-width--small";
638
+		}
639
+		if ($chars && $chars > 100) {
640
+			return "{$class} ee-input-width--big";
641
+		}
642
+		return "{$class} ee-input-width--reg";
643
+	}
644
+
645
+
646
+	/**
647
+	 * generate_question_groups_html
648
+	 *
649
+	 * @param array  $question_groups
650
+	 * @param string $group_wrapper
651
+	 * @return string HTML
652
+	 * @throws EE_Error
653
+	 * @throws ReflectionException
654
+	 */
655
+	public static function generate_question_groups_html($question_groups = [], $group_wrapper = 'fieldset')
656
+	{
657
+
658
+		$html                            = '';
659
+		$before_question_group_questions =
660
+			apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '');
661
+		$after_question_group_questions  =
662
+			apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '');
663
+
664
+		if (! empty($question_groups)) {
665
+			// loop thru question groups
666
+			foreach ($question_groups as $QSG) {
667
+				// check that questions exist
668
+				if (! empty($QSG['QSG_questions'])) {
669
+					// use fieldsets
670
+					$html .= "\n\t"
671
+							 . '<'
672
+							 . $group_wrapper
673
+							 . ' class="espresso-question-group-wrap" id="'
674
+							 . $QSG['QSG_identifier']
675
+							 . '">';
676
+					// group_name
677
+					$html .= $QSG['QSG_show_group_name']
678
+						? "\n\t\t"
679
+						  . '<h5 class="espresso-question-group-title-h5 section-title">'
680
+						  . self::prep_answer($QSG['QSG_name'])
681
+						  . '</h5>'
682
+						: '';
683
+					// group_desc
684
+					$html .= $QSG['QSG_show_group_desc'] && ! empty($QSG['QSG_desc'])
685
+						? '<div class="espresso-question-group-desc-pg">'
686
+						  . self::prep_answer($QSG['QSG_desc'])
687
+						  . '</div>'
688
+						: '';
689
+
690
+					$html .= $before_question_group_questions;
691
+					// loop thru questions
692
+					foreach ($QSG['QSG_questions'] as $question) {
693
+						$QFI  = new EE_Question_Form_Input(
694
+							$question['qst_obj'],
695
+							$question['ans_obj'],
696
+							$question
697
+						);
698
+						$html .= self::generate_form_input($QFI);
699
+					}
700
+					$html .= $after_question_group_questions;
701
+					$html .= "\n\t" . '</' . $group_wrapper . '>';
702
+				}
703
+			}
704
+		}
705
+
706
+		return $html;
707
+	}
708
+
709
+
710
+	/**
711
+	 * generate_question_groups_html
712
+	 *
713
+	 * @param array  $question_groups
714
+	 * @param array  $q_meta
715
+	 * @param bool   $from_admin
716
+	 * @param string $group_wrapper
717
+	 * @return string HTML
718
+	 * @throws EE_Error
719
+	 * @throws ReflectionException
720
+	 */
721
+	public static function generate_question_groups_html2(
722
+		$question_groups = [],
723
+		$q_meta = [],
724
+		$from_admin = false,
725
+		$group_wrapper = 'fieldset'
726
+	) {
727
+
728
+		$html                            = '';
729
+		$before_question_group_questions =
730
+			apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '');
731
+		$after_question_group_questions  =
732
+			apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '');
733
+
734
+		$default_q_meta = [
735
+			'att_nmbr'    => 1,
736
+			'ticket_id'   => '',
737
+			'input_name'  => '',
738
+			'input_id'    => '',
739
+			'input_class' => '',
740
+		];
741
+		$q_meta         = array_merge($default_q_meta, $q_meta);
742
+
743
+		if (! empty($question_groups)) {
744
+			// loop thru question groups
745
+			foreach ($question_groups as $QSG) {
746
+				if ($QSG instanceof EE_Question_Group) {
747
+					// check that questions exist
748
+
749
+					$where = ['QST_deleted' => 0];
750
+					if (! $from_admin) {
751
+						$where['QST_admin_only'] = 0;
752
+					}
753
+					$questions =
754
+						$QSG->questions([$where, 'order_by' => ['Question_Group_Question.QGQ_order' => 'ASC']]);
755
+					if (! empty($questions)) {
756
+						// use fieldsets
757
+						$html .= "\n\t"
758
+								 . '<' . $group_wrapper . ' class="espresso-question-group-wrap" '
759
+								 . 'id="' . $QSG->get('QSG_identifier') . '">';
760
+						// group_name
761
+						if ($QSG->show_group_name()) {
762
+							$html .= "\n\t\t"
763
+									 . '<h5 class="espresso-question-group-title-h5 section-title">'
764
+									 . $QSG->get_pretty('QSG_name')
765
+									 . '</h5>';
766
+						}
767
+						// group_desc
768
+						if ($QSG->show_group_desc()) {
769
+							$html .= '<div class="espresso-question-group-desc-pg">'
770
+									 . $QSG->get_pretty('QSG_desc')
771
+									 . '</div>';
772
+						}
773
+
774
+						$html .= $before_question_group_questions;
775
+						// loop thru questions
776
+						foreach ($questions as $QST) {
777
+							$qstn_id = $QST->is_system_question() ? $QST->system_ID() : $QST->ID();
778
+
779
+							$answer = null;
780
+
781
+							/** @var RequestInterface $request */
782
+							$request      = LoaderFactory::getLoader()->getShared(RequestInterface::class);
783
+							$request_qstn = $request->getRequestParam('qstn', [], 'string', true);
784
+							if (! empty($request_qstn) && isset($q_meta['input_id']) && isset($q_meta['att_nmbr'])) {
785
+								// check for answer in $request_qstn in case we are reprocessing a form after an error
786
+								if (isset($request_qstn[ $q_meta['input_id'] ][ $qstn_id ])) {
787
+									$answer = is_array($request_qstn[ $q_meta['input_id'] ][ $qstn_id ])
788
+										? $request_qstn[ $q_meta['input_id'] ][ $qstn_id ]
789
+										: sanitize_text_field($request_qstn[ $q_meta['input_id'] ][ $qstn_id ]);
790
+								}
791
+							} elseif (isset($q_meta['attendee']) && $q_meta['attendee']) {
792
+								// attendee data from the session
793
+								$answer =
794
+									isset($q_meta['attendee'][ $qstn_id ]) ? $q_meta['attendee'][ $qstn_id ] : null;
795
+							}
796
+
797
+
798
+							$QFI  = new EE_Question_Form_Input(
799
+								$QST,
800
+								EE_Answer::new_instance(
801
+									[
802
+										'ANS_ID'    => 0,
803
+										'QST_ID'    => 0,
804
+										'REG_ID'    => 0,
805
+										'ANS_value' => $answer,
806
+									]
807
+								),
808
+								$q_meta
809
+							);
810
+							$html .= self::generate_form_input($QFI);
811
+						}
812
+						$html .= $after_question_group_questions;
813
+						$html .= "\n\t" . '</' . $group_wrapper . '>';
814
+					}
815
+				}
816
+			}
817
+		}
818
+		return $html;
819
+	}
820
+
821
+
822
+	/**
823
+	 * generate_form_input
824
+	 *
825
+	 * @param EE_Question_Form_Input $QFI
826
+	 * @return string HTML
827
+	 * @throws EE_Error
828
+	 * @throws ReflectionException
829
+	 */
830
+	public static function generate_form_input(EE_Question_Form_Input $QFI)
831
+	{
832
+		if (isset($QFI->QST_admin_only) && $QFI->QST_admin_only && ! is_admin()) {
833
+			return '';
834
+		}
835
+		/** @var RequestInterface $request */
836
+		$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
837
+
838
+		$QFI = self::_load_system_dropdowns($QFI);
839
+		$QFI = self::_load_specialized_dropdowns($QFI);
840
+
841
+		// we also need to verify
842
+
843
+		$display_text = $QFI->get('QST_display_text');
844
+		$input_name   = $QFI->get('QST_input_name');
845
+		$answer       = $request->getRequestParam($input_name, $QFI->get('ANS_value'));
846
+		$input_id     = $QFI->get('QST_input_id');
847
+		$input_class  = $QFI->get('QST_input_class');
848
+		//      $disabled = $QFI->get('QST_disabled') ? ' disabled="disabled"' : '';
849
+		$disabled          = $QFI->get('QST_disabled');
850
+		$required_label    = apply_filters(' FHEE__EEH_Form_Fields__generate_form_input__required_label', '<em>*</em>');
851
+		$QST_required      = $QFI->get('QST_required');
852
+		$required          =
853
+			$QST_required
854
+				? ['label' => $required_label, 'class' => 'required needs-value', 'title' => $QST_required]
855
+				: [];
856
+		$use_html_entities = $QFI->get_meta('htmlentities');
857
+		$required_text     =
858
+			$QFI->get('QST_required_text') != ''
859
+				? $QFI->get('QST_required_text')
860
+				: esc_html__('This field is required', 'event_espresso');
861
+		$required_text     = $QST_required
862
+			? "\n\t\t\t"
863
+			  . '<div class="required-text hidden">'
864
+			  . self::prep_answer($required_text, $use_html_entities)
865
+			  . '</div>'
866
+			: '';
867
+		$label_class       = $QFI->get('label_class');
868
+		$label_class       = $label_class ? "{$label_class} espresso-form-input-lbl" : 'espresso-form-input-lbl';
869
+		$QST_options       = $QFI->options(true, $answer);
870
+		$options           = is_array($QST_options) ? self::prep_answer_options($QST_options) : [];
871
+		$system_ID         = $QFI->get('QST_system');
872
+		$label_b4          = $QFI->get_meta('label_b4');
873
+		$use_desc_4_label  = $QFI->get_meta('use_desc_4_label');
874
+		$add_mobile_label  = $QFI->get_meta('add_mobile_label');
875
+
876
+
877
+		switch ($QFI->get('QST_type')) {
878
+			case 'TEXTAREA':
879
+				return EEH_Form_Fields::textarea(
880
+					$display_text,
881
+					$answer,
882
+					$input_name,
883
+					$input_id,
884
+					$input_class,
885
+					[],
886
+					$required,
887
+					$required_text,
888
+					$label_class,
889
+					$disabled,
890
+					$system_ID,
891
+					$use_html_entities,
892
+					$add_mobile_label
893
+				);
894
+
895
+			case 'DROPDOWN':
896
+				return EEH_Form_Fields::select(
897
+					$display_text,
898
+					$answer,
899
+					$options,
900
+					$input_name,
901
+					$input_id,
902
+					$input_class,
903
+					$required,
904
+					$required_text,
905
+					$label_class,
906
+					$disabled,
907
+					$system_ID,
908
+					$use_html_entities,
909
+					true,
910
+					$add_mobile_label
911
+				);
912
+
913
+
914
+			case 'RADIO_BTN':
915
+				return EEH_Form_Fields::radio(
916
+					$display_text,
917
+					$answer,
918
+					$options,
919
+					$input_name,
920
+					$input_id,
921
+					$input_class,
922
+					$required,
923
+					$required_text,
924
+					$label_class,
925
+					$disabled,
926
+					$system_ID,
927
+					$use_html_entities,
928
+					$label_b4,
929
+					$use_desc_4_label,
930
+					$add_mobile_label
931
+				);
932
+
933
+			case 'CHECKBOX':
934
+				return EEH_Form_Fields::checkbox(
935
+					$display_text,
936
+					$answer,
937
+					$options,
938
+					$input_name,
939
+					$input_id,
940
+					$input_class,
941
+					$required,
942
+					$required_text,
943
+					$label_class,
944
+					$disabled,
945
+					$label_b4,
946
+					$system_ID,
947
+					$use_html_entities,
948
+					$add_mobile_label
949
+				);
950
+
951
+			case 'DATE':
952
+				return EEH_Form_Fields::datepicker(
953
+					$display_text,
954
+					$answer,
955
+					$input_name,
956
+					$input_id,
957
+					$input_class,
958
+					$required,
959
+					$required_text,
960
+					$label_class,
961
+					$disabled,
962
+					$system_ID,
963
+					$use_html_entities,
964
+					$add_mobile_label
965
+				);
966
+
967
+			case 'TEXT':
968
+			default:
969
+				return EEH_Form_Fields::text(
970
+					$display_text,
971
+					$answer,
972
+					$input_name,
973
+					$input_id,
974
+					$input_class,
975
+					$required,
976
+					$required_text,
977
+					$label_class,
978
+					$disabled,
979
+					$system_ID,
980
+					$use_html_entities,
981
+					$add_mobile_label
982
+				);
983
+		}
984
+	}
985
+
986
+
987
+	public static function label(
988
+		string $question,
989
+		string $required_text = '',
990
+		string $required_label = '',
991
+		string $name = '',
992
+		string $label_class = '',
993
+		bool $filter = true
994
+	): string {
995
+		$for   = ! empty($name) ? " for='{$name}'" : '';
996
+		$class = ! empty($label_class) ? " class='{$label_class}'" : '';
997
+		$label = self::prep_question($question) . $required_label;
998
+		$label_html = "
999 999
             {$required_text}
1000 1000
             <label{$for}{$class}>{$label}</label>";
1001
-        // filter label but ensure required text comes before it
1002
-        return $filter
1003
-            ? apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text)
1004
-            : $label_html;
1005
-    }
1006
-
1007
-
1008
-
1009
-    public static function mobileLabel(
1010
-        bool $add_mobile_label,
1011
-        string $question,
1012
-        string $required_text = '',
1013
-        string $required_label = '',
1014
-        string $label_class = '',
1015
-        string $name = ''
1016
-    ): string {
1017
-        return $add_mobile_label
1018
-            ? self::label($question, $required_text, $required_label, $name, $label_class, false)
1019
-            : '';
1020
-    }
1021
-
1022
-
1023
-    /**
1024
-     * generates HTML for a form text input
1025
-     *
1026
-     * @param string $question    label content
1027
-     * @param string $answer      form input value attribute
1028
-     * @param string $name        form input name attribute
1029
-     * @param string $id          form input css id attribute
1030
-     * @param string $class       form input css class attribute
1031
-     * @param array  $required    'label', 'class', and 'msg' - array of values for required "label" content, css
1032
-     *                            required 'class', and required 'msg' attribute
1033
-     * @param string $label_class css class attribute for the label
1034
-     * @param string $disabled    disabled="disabled" or null
1035
-     * @return string HTML
1036
-     */
1037
-    public static function text(
1038
-        $question = false,
1039
-        $answer = null,
1040
-        $name = false,
1041
-        $id = '',
1042
-        $class = '',
1043
-        $required = false,
1044
-        $required_text = '',
1045
-        $label_class = '',
1046
-        $disabled = false,
1047
-        $system_ID = false,
1048
-        $use_html_entities = true,
1049
-        $add_mobile_label = false
1050
-    ) {
1051
-        // need these
1052
-        if (! $question || ! $name) {
1053
-            return null;
1054
-        }
1055
-        // prep the answer
1056
-        $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities);
1057
-        // prep the required array
1058
-        $required = self::prep_required($required);
1059
-        // set disabled tag
1060
-        $disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
1061
-        // ya gots ta have style man!!!
1062
-        $txt_class = is_admin() ? 'regular-text' : 'espresso-text-inp';
1063
-        $class     = empty($class) ? $txt_class : $class;
1064
-        $class     .= ! empty($system_ID) ? ' ' . $system_ID : '';
1065
-        $class = self::appendInputSizeClass($class, $answer);
1066
-        $class .= ! empty($required['class']) ? ' ' . $required['class'] : '';
1067
-        $extra     = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1068
-
1069
-        $label_html = self::label($question, $required_text, $required['label'], $name, $label_class);
1070
-        $mobile_label = self::mobileLabel(
1071
-            $add_mobile_label,
1072
-            $question,
1073
-            $required_text,
1074
-            $required['label'],
1075
-            $label_class,
1076
-            $name
1077
-        );
1078
-
1079
-        $input_html = $mobile_label . '
1001
+		// filter label but ensure required text comes before it
1002
+		return $filter
1003
+			? apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text)
1004
+			: $label_html;
1005
+	}
1006
+
1007
+
1008
+
1009
+	public static function mobileLabel(
1010
+		bool $add_mobile_label,
1011
+		string $question,
1012
+		string $required_text = '',
1013
+		string $required_label = '',
1014
+		string $label_class = '',
1015
+		string $name = ''
1016
+	): string {
1017
+		return $add_mobile_label
1018
+			? self::label($question, $required_text, $required_label, $name, $label_class, false)
1019
+			: '';
1020
+	}
1021
+
1022
+
1023
+	/**
1024
+	 * generates HTML for a form text input
1025
+	 *
1026
+	 * @param string $question    label content
1027
+	 * @param string $answer      form input value attribute
1028
+	 * @param string $name        form input name attribute
1029
+	 * @param string $id          form input css id attribute
1030
+	 * @param string $class       form input css class attribute
1031
+	 * @param array  $required    'label', 'class', and 'msg' - array of values for required "label" content, css
1032
+	 *                            required 'class', and required 'msg' attribute
1033
+	 * @param string $label_class css class attribute for the label
1034
+	 * @param string $disabled    disabled="disabled" or null
1035
+	 * @return string HTML
1036
+	 */
1037
+	public static function text(
1038
+		$question = false,
1039
+		$answer = null,
1040
+		$name = false,
1041
+		$id = '',
1042
+		$class = '',
1043
+		$required = false,
1044
+		$required_text = '',
1045
+		$label_class = '',
1046
+		$disabled = false,
1047
+		$system_ID = false,
1048
+		$use_html_entities = true,
1049
+		$add_mobile_label = false
1050
+	) {
1051
+		// need these
1052
+		if (! $question || ! $name) {
1053
+			return null;
1054
+		}
1055
+		// prep the answer
1056
+		$answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities);
1057
+		// prep the required array
1058
+		$required = self::prep_required($required);
1059
+		// set disabled tag
1060
+		$disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
1061
+		// ya gots ta have style man!!!
1062
+		$txt_class = is_admin() ? 'regular-text' : 'espresso-text-inp';
1063
+		$class     = empty($class) ? $txt_class : $class;
1064
+		$class     .= ! empty($system_ID) ? ' ' . $system_ID : '';
1065
+		$class = self::appendInputSizeClass($class, $answer);
1066
+		$class .= ! empty($required['class']) ? ' ' . $required['class'] : '';
1067
+		$extra     = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1068
+
1069
+		$label_html = self::label($question, $required_text, $required['label'], $name, $label_class);
1070
+		$mobile_label = self::mobileLabel(
1071
+			$add_mobile_label,
1072
+			$question,
1073
+			$required_text,
1074
+			$required['label'],
1075
+			$label_class,
1076
+			$name
1077
+		);
1078
+
1079
+		$input_html = $mobile_label . '
1080 1080
             <input  type="text"
1081 1081
                     name="' . $name . '"
1082 1082
                     id="' . $id . '"
@@ -1086,1039 +1086,1039 @@  discard block
 block discarded – undo
1086 1086
                     ' . $disabled . ' ' . $extra . '
1087 1087
             />';
1088 1088
 
1089
-        $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1090
-        return $label_html . $input_html;
1091
-    }
1092
-
1093
-
1094
-    /**
1095
-     * generates HTML for a form textarea
1096
-     *
1097
-     * @param string $question    label content
1098
-     * @param string $answer      form input value attribute
1099
-     * @param string $name        form input name attribute
1100
-     * @param string $id          form input css id attribute
1101
-     * @param string $class       form input css class attribute
1102
-     * @param array  $dimensions  array of form input rows and cols attributes : array( 'rows' => 3, 'cols' => 40 )
1103
-     * @param array  $required    'label', 'class', and 'msg' - array of values for required "label" content, css
1104
-     *                            required 'class', and required 'msg' attribute
1105
-     * @param string $label_class css class attribute for the label
1106
-     * @param string $disabled    disabled="disabled" or null
1107
-     * @return string HTML
1108
-     */
1109
-    public static function textarea(
1110
-        $question = false,
1111
-        $answer = null,
1112
-        $name = false,
1113
-        $id = '',
1114
-        $class = '',
1115
-        $dimensions = false,
1116
-        $required = false,
1117
-        $required_text = '',
1118
-        $label_class = '',
1119
-        $disabled = false,
1120
-        $system_ID = false,
1121
-        $use_html_entities = true,
1122
-        $add_mobile_label = false
1123
-    ) {
1124
-        // need these
1125
-        if (! $question || ! $name) {
1126
-            return null;
1127
-        }
1128
-        // prep the answer
1129
-        $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities);
1130
-        // prep the required array
1131
-        $required = self::prep_required($required);
1132
-        // make sure $dimensions is an array
1133
-        $dimensions = is_array($dimensions) ? $dimensions : [];
1134
-        // and set some defaults
1135
-        $dimensions = array_merge(['rows' => 3, 'cols' => 40], $dimensions);
1136
-        // set disabled tag
1137
-        $disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
1138
-        // ya gots ta have style man!!!
1139
-        $class     .= ! empty($system_ID) ? ' ' . $system_ID : '';
1140
-        $class     .= ! empty($required['class']) ? ' ' . $required['class'] : '';
1141
-        $extra     = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1142
-
1143
-        $label_html   = self::label($question, $required_text, $required['label'], $name, $label_class);
1144
-        $mobile_label = self::mobileLabel(
1145
-            $add_mobile_label,
1146
-            $question,
1147
-            $required_text,
1148
-            $required['label'],
1149
-            $label_class,
1150
-            $name
1151
-        );
1152
-
1153
-        $input_html = $mobile_label
1154
-            . '<textarea name="' . $name . '" id="' . $id . '" class="' . trim($class) . '" '
1155
-            . 'rows="' . $dimensions['rows'] . '" cols="' . $dimensions['cols'] . '"  '
1156
-            . 'aria-label="' . $required['msg'] . '" ' . $disabled . ' ' . $extra . '>'
1157
-             . esc_textarea($answer)
1158
-              . '</textarea>';
1159
-
1160
-        $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1161
-        return $label_html . $input_html;
1162
-    }
1163
-
1164
-
1165
-    /**
1166
-     * generates HTML for a form select input
1167
-     *
1168
-     * @param string $question    label content
1169
-     * @param string $answer      form input value attribute
1170
-     * @param array  $options     array of answer options where array key = option value and array value = option
1171
-     *                            display text
1172
-     * @param string $name        form input name attribute
1173
-     * @param string $id          form input css id attribute
1174
-     * @param string $class       form input css class attribute
1175
-     * @param array  $required    'label', 'class', and 'msg' - array of values for required "label" content, css
1176
-     *                            required 'class', and required 'msg' attribute
1177
-     * @param string $label_class css class attribute for the label
1178
-     * @param string $disabled    disabled="disabled" or null
1179
-     * @return string HTML
1180
-     */
1181
-    public static function select(
1182
-        $question = false,
1183
-        $answer = null,
1184
-        $options = false,
1185
-        $name = false,
1186
-        $id = '',
1187
-        $class = '',
1188
-        $required = false,
1189
-        $required_text = '',
1190
-        $label_class = '',
1191
-        $disabled = false,
1192
-        $system_ID = false,
1193
-        $use_html_entities = true,
1194
-        $add_please_select_option = false,
1195
-        $add_mobile_label = false
1196
-    ) {
1197
-
1198
-        // need these
1199
-        if (! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
1200
-            return null;
1201
-        }
1202
-        // prep the answer
1203
-        $answer = is_array($answer)
1204
-            ? self::prep_answer(array_shift($answer), $use_html_entities)
1205
-            : self::prep_answer($answer, $use_html_entities);
1206
-        // prep the required array
1207
-        $required = self::prep_required($required);
1208
-        // set disabled tag
1209
-        $disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
1210
-        // ya gots ta have style man!!!
1211
-        $class     .= ! empty($system_ID) ? ' ' . $system_ID : '';
1212
-        $class = self::appendInputSizeClass($class, $options);
1213
-        $extra     = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1214
-
1215
-        $label_html   = self::label($question, $required_text, $required['label'], $name, $label_class);
1216
-        $mobile_label = self::mobileLabel(
1217
-            $add_mobile_label,
1218
-            $question,
1219
-            $required_text,
1220
-            $required['label'],
1221
-            $label_class,
1222
-            $name
1223
-        );
1224
-
1225
-        $input_html = $mobile_label
1226
-            . '<select name="' . $name . '" id="' . $id . '" class="' . trim($class) . ' ' . $required['class'] . '" '
1227
-            . 'aria-label="' . esc_attr($required['msg']) . '"' . $disabled . ' ' . $extra . '>';
1228
-        // recursively count array elements, to determine total number of options
1229
-        $only_option = count($options, 1) == 1;
1230
-        if (! $only_option) {
1231
-            // if there is NO answer set and there are multiple options to choose from, then set the "please select" message as selected
1232
-            $selected   = $answer === null ? ' selected="selected"' : '';
1233
-            $input_html .= $add_please_select_option
1234
-                ? "\n\t\t\t\t"
1235
-                  . '<option value=""' . $selected . '>'
1236
-                  . esc_html__(' - please select - ', 'event_espresso')
1237
-                  . '</option>'
1238
-                : '';
1239
-        }
1240
-        foreach ($options as $key => $value) {
1241
-            // if value is an array, then create option groups, else create regular ol' options
1242
-            $input_html .= is_array($value)
1243
-                ? self::_generate_select_option_group(
1244
-                    $key,
1245
-                    $value,
1246
-                    $answer,
1247
-                    $use_html_entities
1248
-                )
1249
-                : self::_generate_select_option(
1250
-                    $value->value(),
1251
-                    $value->desc(),
1252
-                    $answer,
1253
-                    $only_option,
1254
-                    $use_html_entities
1255
-                );
1256
-        }
1257
-
1258
-        $input_html .= "\n\t\t\t" . '</select>';
1259
-
1260
-        $input_html =
1261
-            apply_filters(
1262
-                'FHEE__EEH_Form_Fields__select__before_end_wrapper',
1263
-                $input_html,
1264
-                $question,
1265
-                $answer,
1266
-                $name,
1267
-                $id,
1268
-                $class,
1269
-                $system_ID
1270
-            );
1271
-
1272
-        $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1273
-        return $label_html . $input_html;
1274
-    }
1275
-
1276
-
1277
-    /**
1278
-     *  _generate_select_option_group
1279
-     *
1280
-     *  if  $value for a select box is an array, then the key will be used as the optgroup label
1281
-     *  and the value array will be looped thru and the elements sent to _generate_select_option
1282
-     *
1283
-     * @param mixed   $opt_group
1284
-     * @param mixed   $QSOs
1285
-     * @param mixed   $answer
1286
-     * @param boolean $use_html_entities
1287
-     * @return string
1288
-     */
1289
-    private static function _generate_select_option_group($opt_group, $QSOs, $answer, $use_html_entities = true)
1290
-    {
1291
-        $html = "\n\t\t\t\t" . '<optgroup label="' . self::prep_option_value($opt_group) . '">';
1292
-        foreach ($QSOs as $QSO) {
1293
-            $html .= self::_generate_select_option($QSO->value(), $QSO->desc(), $answer, false, $use_html_entities);
1294
-        }
1295
-        $html .= "\n\t\t\t\t" . '</optgroup>';
1296
-        return $html;
1297
-    }
1298
-
1299
-
1300
-    /**
1301
-     *  _generate_select_option
1302
-     *
1303
-     * @param mixed   $key
1304
-     * @param mixed   $value
1305
-     * @param mixed   $answer
1306
-     * @param int     $only_option
1307
-     * @param boolean $use_html_entities
1308
-     * @return string
1309
-     */
1310
-    private static function _generate_select_option(
1311
-        $key,
1312
-        $value,
1313
-        $answer,
1314
-        $only_option = false,
1315
-        $use_html_entities = true
1316
-    ) {
1317
-        $key      = self::prep_answer($key, $use_html_entities);
1318
-        $value    = self::prep_answer($value, $use_html_entities);
1319
-        $value    = ! empty($value) ? $value : $key;
1320
-        $selected = ($answer == $key || $only_option) ? 'selected="selected"' : '';
1321
-        return "\n\t\t\t\t"
1322
-               . '<option value="' . self::prep_option_value($key) . '" ' . $selected . '> '
1323
-               . $value
1324
-               . '&nbsp;&nbsp;&nbsp;</option>';
1325
-    }
1326
-
1327
-
1328
-    /**
1329
-     * generates HTML for form radio button inputs
1330
-     *
1331
-     * @param bool|string $question    label content
1332
-     * @param string      $answer      form input value attribute
1333
-     * @param array|bool  $options     array of answer options where array key = option value and array value = option
1334
-     *                                 display text
1335
-     * @param bool|string $name        form input name attribute
1336
-     * @param string      $id          form input css id attribute
1337
-     * @param string      $class       form input css class attribute
1338
-     * @param array|bool  $required    'label', 'class', and 'msg' - array of values for required "label" content, css
1339
-     *                                 required 'class', and required 'msg' attribute
1340
-     * @param string      $required_text
1341
-     * @param string      $label_class css class attribute for the label
1342
-     * @param bool|string $disabled    disabled="disabled" or null
1343
-     * @param bool        $system_ID
1344
-     * @param bool        $use_html_entities
1345
-     * @param bool        $label_b4
1346
-     * @param bool        $use_desc_4_label
1347
-     * @return string HTML
1348
-     */
1349
-    public static function radio(
1350
-        $question = false,
1351
-        $answer = null,
1352
-        $options = false,
1353
-        $name = false,
1354
-        $id = '',
1355
-        $class = '',
1356
-        $required = false,
1357
-        $required_text = '',
1358
-        $label_class = '',
1359
-        $disabled = false,
1360
-        $system_ID = false,
1361
-        $use_html_entities = true,
1362
-        $label_b4 = false,
1363
-        $use_desc_4_label = false,
1364
-        $add_mobile_label = false
1365
-    ) {
1366
-        // need these
1367
-        if (! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
1368
-            return null;
1369
-        }
1370
-        // prep the answer
1371
-        $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities);
1372
-        // prep the required array
1373
-        $required = self::prep_required($required);
1374
-        // set disabled tag
1375
-        $disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
1376
-        // ya gots ta have style man!!!
1377
-        $radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class;
1378
-        $class       = ! empty($class) ? $class : 'espresso-radio-btn-inp';
1379
-        $extra       = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1380
-
1381
-        $label_html = self::label($question, $required_text, $required['label'], '', $label_class);
1382
-        $mobile_label = self::mobileLabel(
1383
-            $add_mobile_label,
1384
-            $question,
1385
-            $required_text,
1386
-            $required['label'],
1387
-            $label_class
1388
-        );
1389
-
1390
-        $input_html = $mobile_label
1391
-            . '<ul id="' . $id . '-ul" class="espresso-radio-btn-options-ul ' . $class . '-ul">';
1392
-
1393
-        $class .= ! empty($system_ID) ? ' ' . $system_ID : '';
1394
-        $class .= ! empty($required['class']) ? ' ' . $required['class'] : '';
1395
-
1396
-        foreach ($options as $OPT) {
1397
-            if ($OPT instanceof EE_Question_Option) {
1398
-                $value   = self::prep_option_value($OPT->value());
1399
-                $label   = $use_desc_4_label ? $OPT->desc() : $OPT->value();
1400
-                $size    = $use_desc_4_label
1401
-                    ? self::get_label_size_class($OPT->value() . ' ' . $OPT->desc())
1402
-                    : self::get_label_size_class($OPT->value());
1403
-                $desc    = $OPT->desc();// no self::prep_answer
1404
-                $answer  = is_numeric($value) && empty($answer) ? 0 : $answer;
1405
-                $checked = (string) $value == (string) $answer ? ' checked="checked"' : '';
1406
-                $opt     = '-' . sanitize_key($value);
1407
-
1408
-                $input_html .= "\n\t\t\t\t" . '<li' . $size . '>';
1409
-                $input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-radio-btn-lbl">';
1410
-                $input_html .= $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $label . '</span>&nbsp;&nbsp;' : '';
1411
-                $input_html .= "\n\t\t\t\t\t\t"
1412
-                               . '<input type="radio" name="' . $name . '" id="' . $id . $opt . '" '
1413
-                               . 'class="' . $class . '" value="' . $value . '" '
1414
-                               . 'aria-label="' . esc_attr($required['msg']) . '" ' . $disabled
1415
-                               . $checked . ' ' . $extra . '/>';
1416
-                $input_html .= ! $label_b4
1417
-                    ? "\n\t\t\t\t\t\t"
1418
-                      . '&nbsp;&nbsp;<span class="espresso-radio-btn-desc">'
1419
-                      . $label
1420
-                      . '</span>'
1421
-                    : '';
1422
-                $input_html .= "\n\t\t\t\t\t" . '</label>';
1423
-                $input_html .= $use_desc_4_label
1424
-                    ? ''
1425
-                    : '<span class="espresso-radio-btn-option-desc small-text grey-text">' . $desc . '</span>';
1426
-                $input_html .= "\n\t\t\t\t" . '</li>';
1427
-            }
1428
-        }
1429
-
1430
-        $input_html .= "\n\t\t\t" . '</ul>';
1431
-
1432
-        $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1433
-        return $label_html . $input_html;
1434
-    }
1435
-
1436
-
1437
-    /**
1438
-     * generates HTML for form checkbox inputs
1439
-     *
1440
-     * @param string $question    label content
1441
-     * @param string $answer      form input value attribute
1442
-     * @param array  $options     array of options where array key = option value and array value = option display text
1443
-     * @param string $name        form input name attribute
1444
-     * @param string $id          form input css id attribute
1445
-     * @param string $class       form input css class attribute
1446
-     * @param array  $required    'label', 'class', and 'msg' - array of values for required "label" content, css
1447
-     *                            required 'class', and required 'msg' attribute
1448
-     * @param string $label_class css class attribute for the label
1449
-     * @param string $disabled    disabled="disabled" or null
1450
-     * @return string HTML
1451
-     */
1452
-    public static function checkbox(
1453
-        $question = false,
1454
-        $answer = null,
1455
-        $options = false,
1456
-        $name = false,
1457
-        $id = '',
1458
-        $class = '',
1459
-        $required = false,
1460
-        $required_text = '',
1461
-        $label_class = '',
1462
-        $disabled = false,
1463
-        $label_b4 = false,
1464
-        $system_ID = false,
1465
-        $use_html_entities = true,
1466
-        $add_mobile_label = false
1467
-    ) {
1468
-        // need these
1469
-        if (! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
1470
-            return null;
1471
-        }
1472
-        $answer = maybe_unserialize($answer);
1473
-
1474
-        // prep the answer(s)
1475
-        $answer = is_array($answer) ? $answer : [sanitize_key($answer) => $answer];
1476
-
1477
-        foreach ($answer as $key => $value) {
1478
-            $key            = self::prep_option_value($key);
1479
-            $answer[ $key ] = self::prep_answer($value, $use_html_entities);
1480
-        }
1481
-
1482
-        // prep the required array
1483
-        $required = self::prep_required($required);
1484
-        // set disabled tag
1485
-        $disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
1486
-        // ya gots ta have style man!!!
1487
-        $radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class;
1488
-        $class       = empty($class) ? 'espresso-radio-btn-inp' : $class;
1489
-        $extra       = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1490
-
1491
-        $label_html   = self::label($question, $required_text, $required['label'], '', $label_class);
1492
-        $mobile_label = self::mobileLabel(
1493
-            $add_mobile_label,
1494
-            $question,
1495
-            $required_text,
1496
-            $required['label'],
1497
-            $label_class
1498
-        );
1499
-
1500
-        $input_html = $mobile_label
1501
-            . '<ul id="' . $id . '-ul" class="espresso-checkbox-options-ul ' . $class . '-ul">';
1502
-
1503
-        $class .= ! empty($system_ID) ? ' ' . $system_ID : '';
1504
-        $class .= ! empty($required['class']) ? ' ' . $required['class'] : '';
1505
-
1506
-        foreach ($options as $OPT) {
1507
-            $value = $OPT->value();// self::prep_option_value( $OPT->value() );
1508
-            $size  = self::get_label_size_class($OPT->value() . ' ' . $OPT->desc());
1509
-            $text  = self::prep_answer($OPT->value());
1510
-            $desc  = $OPT->desc();
1511
-            $opt   = '-' . sanitize_key($value);
1512
-
1513
-            $checked = is_array($answer) && in_array($text, $answer) ? ' checked="checked"' : '';
1514
-
1515
-            $input_html .= "\n\t\t\t\t" . '<li' . $size . '>';
1516
-            $input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-checkbox-lbl">';
1517
-            $input_html .= $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>&nbsp;&nbsp;' : '';
1518
-            $input_html .= "\n\t\t\t\t\t\t"
1519
-                           . '<input type="checkbox" name="' . $name . '[' . $OPT->ID() . ']" '
1520
-                           . 'id="' . $id . $opt . '" class="' . $class . '" value="' . $value . '" '
1521
-                           . 'aria-label="' . esc_attr($required['msg']) . '" ' . $disabled . $checked . ' ' . $extra . '/>';
1522
-            $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t" . '&nbsp;&nbsp;<span>' . $text . '</span>' : '';
1523
-            $input_html .= "\n\t\t\t\t\t" . '</label>';
1524
-            if (! empty($desc) && $desc != $text) {
1525
-                $input_html .= "\n\t\t\t\t\t"
1526
-                               . ' &nbsp; <br/><div class="espresso-checkbox-option-desc small-text grey-text">'
1527
-                               . $desc
1528
-                               . '</div>';
1529
-            }
1530
-            $input_html .= "\n\t\t\t\t" . '</li>';
1531
-        }
1532
-
1533
-        $input_html .= "\n\t\t\t" . '</ul>';
1534
-
1535
-        $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1536
-        return $label_html . $input_html;
1537
-    }
1538
-
1539
-
1540
-    /**
1541
-     * generates HTML for a form datepicker input
1542
-     *
1543
-     * @param string $question    label content
1544
-     * @param string $answer      form input value attribute
1545
-     * @param string $name        form input name attribute
1546
-     * @param string $id          form input css id attribute
1547
-     * @param string $class       form input css class attribute
1548
-     * @param array  $required    'label', 'class', and 'msg' - array of values for required "label" content, css
1549
-     *                            required 'class', and required 'msg' attribute
1550
-     * @param string $label_class css class attribute for the label
1551
-     * @param string $disabled    disabled="disabled" or null
1552
-     * @return string HTML
1553
-     */
1554
-    public static function datepicker(
1555
-        $question = false,
1556
-        $answer = null,
1557
-        $name = false,
1558
-        $id = '',
1559
-        $class = '',
1560
-        $required = false,
1561
-        $required_text = '',
1562
-        $label_class = '',
1563
-        $disabled = false,
1564
-        $system_ID = false,
1565
-        $use_html_entities = true,
1566
-        $add_mobile_label = false
1567
-    ) {
1568
-        // need these
1569
-        if (! $question || ! $name) {
1570
-            return null;
1571
-        }
1572
-        // prep the answer
1573
-        $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities);
1574
-        // prep the required array
1575
-        $required = self::prep_required($required);
1576
-        // set disabled tag
1577
-        $disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
1578
-        // ya gots ta have style man!!!
1579
-        $txt_class = is_admin() ? 'regular-text' : 'espresso-datepicker-inp';
1580
-        $class     = empty($class) ? $txt_class : $class;
1581
-        $class     .= ! empty($system_ID) ? ' ' . $system_ID : '';
1582
-        $class = self::appendInputSizeClass($class, $answer);
1583
-        $extra     = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1584
-
1585
-        $label_html   = self::label($question, $required_text, $required['label'], '', $label_class);
1586
-        $mobile_label = self::mobileLabel(
1587
-            $add_mobile_label,
1588
-            $question,
1589
-            $required_text,
1590
-            $required['label'],
1591
-            $label_class,
1592
-            $name
1593
-        );
1594
-
1595
-        $input_html = $mobile_label
1596
-            . '<input type="text" name="' . $name . '" id="' . $id . '" '
1597
-            . 'class="' . $class . ' ' . $required['class'] . ' datepicker" value="' . $answer . '"  '
1598
-            . 'aria-label="' . esc_attr($required['msg']) . '" ' . $disabled . ' ' . $extra . '/>';
1599
-
1600
-        // enqueue scripts
1601
-        wp_register_style(
1602
-            'espresso-ui-theme',
1603
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1604
-            [],
1605
-            EVENT_ESPRESSO_VERSION
1606
-        );
1607
-        wp_enqueue_style('espresso-ui-theme');
1608
-        wp_enqueue_script('jquery-ui-datepicker');
1609
-
1610
-        $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1611
-        return $label_html . $input_html;
1612
-    }
1613
-
1614
-
1615
-    /**
1616
-     *  remove_label_keep_required_msg
1617
-     *  this will strip out a form input's label HTML while keeping the required text HTML that MUST be before the label
1618
-     *
1619
-     * @access public
1620
-     * @return     string
1621
-     */
1622
-    public static function remove_label_keep_required_msg($label_html, $required_text)
1623
-    {
1624
-        return $required_text;
1625
-    }
1626
-
1627
-
1628
-    /**
1629
-     * Simply returns the HTML for a hidden input of the given name and value.
1630
-     *
1631
-     * @param string $name
1632
-     * @param string $value
1633
-     * @return string HTML
1634
-     */
1635
-    public static function hidden_input($name, $value, $id = '')
1636
-    {
1637
-        $id = ! empty($id) ? $id : $name;
1638
-        return '<input id="' . $id . '" type="hidden" name="' . $name . '" value="' . $value . '"/>';
1639
-    }
1640
-
1641
-
1642
-    /**
1643
-     * prep_question
1644
-     *
1645
-     * @param string $question
1646
-     * @return string
1647
-     */
1648
-    public static function prep_question($question)
1649
-    {
1650
-        return $question;
1651
-    }
1652
-
1653
-
1654
-    /**
1655
-     *  prep_answer
1656
-     *
1657
-     * @param mixed $answer
1658
-     * @return string
1659
-     */
1660
-    public static function prep_answer($answer, $use_html_entities = true)
1661
-    {
1662
-        // make sure we convert bools first.  Otherwise (bool) false becomes an empty string which is NOT desired,
1663
-        // we want "0".
1664
-        if (is_bool($answer)) {
1665
-            $answer = $answer ? 1 : 0;
1666
-        }
1667
-        $answer = trim(stripslashes(str_replace('&#039;', "'", $answer)));
1668
-        return $use_html_entities ? htmlentities($answer, ENT_QUOTES, 'UTF-8') : $answer;
1669
-    }
1670
-
1671
-
1672
-    /**
1673
-     *  prep_answer_options
1674
-     *
1675
-     * @param array $QSOs array of EE_Question_Option objects
1676
-     * @return array
1677
-     */
1678
-    public static function prep_answer_options($QSOs = [])
1679
-    {
1680
-        $prepped_answer_options = [];
1681
-        if (is_array($QSOs) && ! empty($QSOs)) {
1682
-            foreach ($QSOs as $key => $QSO) {
1683
-                if (! $QSO instanceof EE_Question_Option) {
1684
-                    $QSO = EE_Question_Option::new_instance(
1685
-                        [
1686
-                            'QSO_value' => is_array($QSO) && isset($QSO['id'])
1687
-                                ? (string) $QSO['id']
1688
-                                : (string) $key,
1689
-                            'QSO_desc'  => is_array($QSO) && isset($QSO['text'])
1690
-                                ? (string) $QSO['text']
1691
-                                : (string) $QSO,
1692
-                        ]
1693
-                    );
1694
-                }
1695
-                if ($QSO->opt_group()) {
1696
-                    $prepped_answer_options[ $QSO->opt_group() ][] = $QSO;
1697
-                } else {
1698
-                    $prepped_answer_options[] = $QSO;
1699
-                }
1700
-            }
1701
-        }
1702
-        //      d( $prepped_answer_options );
1703
-        return $prepped_answer_options;
1704
-    }
1705
-
1706
-
1707
-    /**
1708
-     *  prep_option_value
1709
-     *
1710
-     * @param string $option_value
1711
-     * @return string
1712
-     */
1713
-    public static function prep_option_value($option_value)
1714
-    {
1715
-        return esc_attr(trim(stripslashes($option_value)));
1716
-    }
1717
-
1718
-
1719
-    /**
1720
-     *  prep_required
1721
-     *
1722
-     * @param string|array $required
1723
-     * @return array
1724
-     */
1725
-    public static function prep_required($required = [])
1726
-    {
1727
-        // make sure required is an array
1728
-        $required = is_array($required) ? $required : [];
1729
-        // and set some defaults
1730
-        return array_merge(['label' => '', 'class' => '', 'msg' => ''], $required);
1731
-    }
1732
-
1733
-
1734
-    /**
1735
-     *  get_label_size_class
1736
-     *
1737
-     * @param string $value
1738
-     * @return string
1739
-     */
1740
-    public static function get_label_size_class($value = false)
1741
-    {
1742
-        if ($value === false || $value === '') {
1743
-            return ' class="medium-lbl"';
1744
-        }
1745
-        // determine length of option value
1746
-        $val_size = strlen($value);
1747
-        switch ($val_size) {
1748
-            case $val_size < 3:
1749
-                $size = ' class="nano-lbl"';
1750
-                break;
1751
-            case $val_size < 6:
1752
-                $size = ' class="micro-lbl"';
1753
-                break;
1754
-            case $val_size < 12:
1755
-                $size = ' class="tiny-lbl"';
1756
-                break;
1757
-            case $val_size < 25:
1758
-                $size = ' class="small-lbl"';
1759
-                break;
1760
-            case $val_size > 100:
1761
-                $size = ' class="big-lbl"';
1762
-                break;
1763
-            default:
1764
-                $size = ' class="medium-lbl"';
1765
-                break;
1766
-        }
1767
-        return $size;
1768
-    }
1769
-
1770
-
1771
-    /**
1772
-     *  _load_system_dropdowns
1773
-     *
1774
-     * @param EE_Question_Form_Input $QFI
1775
-     * @return array
1776
-     * @throws EE_Error
1777
-     * @throws ReflectionException
1778
-     */
1779
-    private static function _load_system_dropdowns($QFI)
1780
-    {
1781
-        $QST_system = $QFI->get('QST_system');
1782
-        switch ($QST_system) {
1783
-            case 'state':
1784
-                $QFI = self::generate_state_dropdown($QFI);
1785
-                break;
1786
-            case 'country':
1787
-                $QFI = self::generate_country_dropdown($QFI);
1788
-                break;
1789
-            case 'admin-state':
1790
-                $QFI = self::generate_state_dropdown($QFI, true);
1791
-                break;
1792
-            case 'admin-country':
1793
-                $QFI = self::generate_country_dropdown($QFI, true);
1794
-                break;
1795
-        }
1796
-        return $QFI;
1797
-    }
1798
-
1799
-
1800
-    /**
1801
-     * This preps dropdowns that are specialized.
1802
-     *
1803
-     * @param EE_Question_Form_Input $QFI
1804
-     *
1805
-     * @return EE_Question_Form_Input
1806
-     * @throws EE_Error
1807
-     * @throws ReflectionException
1808
-     * @since  4.6.0
1809
-     */
1810
-    protected static function _load_specialized_dropdowns($QFI)
1811
-    {
1812
-        switch ($QFI->get('QST_type')) {
1813
-            case 'STATE':
1814
-                $QFI = self::generate_state_dropdown($QFI);
1815
-                break;
1816
-            case 'COUNTRY':
1817
-                $QFI = self::generate_country_dropdown($QFI);
1818
-                break;
1819
-        }
1820
-        return $QFI;
1821
-    }
1822
-
1823
-
1824
-    /**
1825
-     *    generate_state_dropdown
1826
-     *
1827
-     * @param EE_Question_Form_Input $QST
1828
-     * @param bool                   $get_all
1829
-     * @return EE_Question_Form_Input
1830
-     * @throws EE_Error
1831
-     * @throws ReflectionException
1832
-     */
1833
-    public static function generate_state_dropdown($QST, $get_all = false)
1834
-    {
1835
-        $states = $get_all
1836
-            ? EEM_State::instance()->get_all_states()
1837
-            : EEM_State::instance()->get_all_states_of_active_countries();
1838
-        if ($states && count($states) != count($QST->options())) {
1839
-            $QST->set('QST_type', 'DROPDOWN');
1840
-            // if multiple countries, we'll create option groups within the dropdown
1841
-            foreach ($states as $state) {
1842
-                if ($state instanceof EE_State) {
1843
-                    $QSO = EE_Question_Option::new_instance(
1844
-                        [
1845
-                            'QSO_value'   => $state->ID(),
1846
-                            'QSO_desc'    => $state->name(),
1847
-                            'QST_ID'      => $QST->get('QST_ID'),
1848
-                            'QSO_deleted' => false,
1849
-                        ]
1850
-                    );
1851
-                    // set option group
1852
-                    $QSO->set_opt_group($state->country()->name());
1853
-                    // add option to question
1854
-                    $QST->add_temp_option($QSO);
1855
-                }
1856
-            }
1857
-        }
1858
-        return $QST;
1859
-    }
1860
-
1861
-
1862
-    /**
1863
-     *    generate_country_dropdown
1864
-     *
1865
-     * @param      $QST
1866
-     * @param bool $get_all
1867
-     * @return array
1868
-     * @throws EE_Error
1869
-     * @throws ReflectionException
1870
-     * @internal param array $question
1871
-     */
1872
-    public static function generate_country_dropdown($QST, $get_all = false)
1873
-    {
1874
-        $countries = $get_all
1875
-            ? EEM_Country::instance()->get_all_countries()
1876
-            : EEM_Country::instance()->get_all_active_countries();
1877
-        if ($countries && count($countries) != count($QST->options())) {
1878
-            $QST->set('QST_type', 'DROPDOWN');
1879
-            // now add countries
1880
-            foreach ($countries as $country) {
1881
-                if ($country instanceof EE_Country) {
1882
-                    $QSO = EE_Question_Option::new_instance(
1883
-                        [
1884
-                            'QSO_value'   => $country->ID(),
1885
-                            'QSO_desc'    => $country->name(),
1886
-                            'QST_ID'      => $QST->get('QST_ID'),
1887
-                            'QSO_deleted' => false,
1888
-                        ]
1889
-                    );
1890
-                    $QST->add_temp_option($QSO);
1891
-                }
1892
-            }
1893
-        }
1894
-        return $QST;
1895
-    }
1896
-
1897
-
1898
-    /**
1899
-     *  generates options for a month dropdown selector with numbers from 01 to 12
1900
-     *
1901
-     * @return array()
1902
-     */
1903
-    public static function two_digit_months_dropdown_options()
1904
-    {
1905
-        $options = [];
1906
-        for ($x = 1; $x <= 12; $x++) {
1907
-            $mm             = str_pad($x, 2, '0', STR_PAD_LEFT);
1908
-            $options[ $mm ] = $mm;
1909
-        }
1910
-        return EEH_Form_Fields::prep_answer_options($options);
1911
-    }
1912
-
1913
-
1914
-    /**
1915
-     *  generates a year dropdown selector with numbers for the next ten years
1916
-     *
1917
-     * @return array
1918
-     */
1919
-    public static function next_decade_two_digit_year_dropdown_options()
1920
-    {
1921
-        $options      = [];
1922
-        $current_year = date('y');
1923
-        $next_decade  = $current_year + 10;
1924
-        for ($x = $current_year; $x <= $next_decade; $x++) {
1925
-            $yy             = str_pad($x, 2, '0', STR_PAD_LEFT);
1926
-            $options[ $yy ] = $yy;
1927
-        }
1928
-        return EEH_Form_Fields::prep_answer_options($options);
1929
-    }
1930
-
1931
-
1932
-    /**
1933
-     * generates a month/year dropdown selector for all registrations matching the given criteria.  Typically used for
1934
-     * list table filter.
1935
-     *
1936
-     * @param string  $cur_date     any currently selected date can be entered here.
1937
-     * @param string  $status       Registration status
1938
-     * @param integer $evt_category Event Category ID if the Event Category filter is selected
1939
-     * @return string                html
1940
-     * @throws EE_Error
1941
-     */
1942
-    public static function generate_registration_months_dropdown($cur_date = '', $status = '', $evt_category = 0)
1943
-    {
1944
-        $_where = [];
1945
-        if (! empty($status)) {
1946
-            $_where['STS_ID'] = $status;
1947
-        }
1948
-
1949
-        if ($evt_category > 0) {
1950
-            $_where['Event.Term_Taxonomy.term_id'] = $evt_category;
1951
-        }
1952
-
1953
-        $regdtts = EEM_Registration::instance()->get_reg_months_and_years($_where);
1954
-
1955
-        // setup vals for select input helper
1956
-        $options = [
1957
-            0 => [
1958
-                'text' => esc_html__('Select a Month/Year', 'event_espresso'),
1959
-                'id'   => '',
1960
-            ],
1961
-        ];
1962
-
1963
-        foreach ($regdtts as $regdtt) {
1964
-            $date      = $regdtt->reg_month . ' ' . $regdtt->reg_year;
1965
-            $options[] = [
1966
-                'text' => $date,
1967
-                'id'   => $date,
1968
-            ];
1969
-        }
1970
-
1971
-        return self::select_input('month_range', $options, $cur_date);
1972
-    }
1973
-
1974
-
1975
-    /**
1976
-     * generates a month/year dropdown selector for all events matching the given criteria
1977
-     * Typically used for list table filter
1978
-     *
1979
-     * @param string $cur_date          any currently selected date can be entered here.
1980
-     * @param string $status            "view" (i.e. all, today, month, draft)
1981
-     * @param int    $evt_category      category event belongs to
1982
-     * @param string $evt_active_status "upcoming", "expired", "active", or "inactive"
1983
-     * @return string                    html
1984
-     * @throws EE_Error
1985
-     */
1986
-    public static function generate_event_months_dropdown(
1987
-        $cur_date = '',
1988
-        $status = null,
1989
-        $evt_category = null,
1990
-        $evt_active_status = null
1991
-    ) {
1992
-        // determine what post_status our condition will have for the query.
1993
-        // phpcs:disable PSR2.ControlStructures.SwitchDeclaration.TerminatingComment
1994
-        switch ($status) {
1995
-            case 'month':
1996
-            case 'today':
1997
-            case null:
1998
-            case 'all':
1999
-                $where['Event.status'] = ['NOT IN', ['trash']];
2000
-                break;
2001
-            case 'draft':
2002
-                $where['Event.status'] = ['IN', ['draft', 'auto-draft']];
2003
-                break;
2004
-            default:
2005
-                $where['Event.status'] = $status;
2006
-        }
2007
-
2008
-        // phpcs:enable
2009
-
2010
-        // categories?
2011
-
2012
-
2013
-        if (! empty($evt_category)) {
2014
-            $where['Event.Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
2015
-            $where['Event.Term_Taxonomy.term_id']  = $evt_category;
2016
-        }
2017
-
2018
-
2019
-        //      $where['DTT_is_primary'] = 1;
2020
-
2021
-        $DTTS = EEM_Datetime::instance()->get_dtt_months_and_years($where, $evt_active_status);
2022
-
2023
-        // let's setup vals for select input helper
2024
-        $options = [
2025
-            0 => [
2026
-                'text' => esc_html__('Select a Month/Year', 'event_espresso'),
2027
-                'id'   => "",
2028
-            ],
2029
-        ];
2030
-
2031
-
2032
-        // translate month and date
2033
-        global $wp_locale;
2034
-
2035
-        foreach ($DTTS as $DTT) {
2036
-            $localized_date = $wp_locale->get_month($DTT->dtt_month_num) . ' ' . $DTT->dtt_year;
2037
-            $id             = $DTT->dtt_month . ' ' . $DTT->dtt_year;
2038
-            $options[]      = [
2039
-                'text' => $localized_date,
2040
-                'id'   => $id,
2041
-            ];
2042
-        }
2043
-
2044
-
2045
-        return self::select_input('month_range', $options, $cur_date);
2046
-    }
2047
-
2048
-
2049
-    /**
2050
-     * generates the dropdown selector for event categories
2051
-     * typically used as a filter on list tables.
2052
-     *
2053
-     * @param integer $current_cat currently selected category
2054
-     * @return string               html for dropdown
2055
-     * @throws EE_Error
2056
-     * @throws ReflectionException
2057
-     */
2058
-    public static function generate_event_category_dropdown($current_cat = -1)
2059
-    {
2060
-        $categories = EEM_Term::instance()->get_all_ee_categories(true);
2061
-        $options    = [
2062
-            '0' => [
2063
-                'text' => esc_html__('All Categories', 'event_espresso'),
2064
-                'id'   => -1,
2065
-            ],
2066
-        ];
2067
-
2068
-        // setup categories for dropdown
2069
-        foreach ($categories as $category) {
2070
-            $options[] = [
2071
-                'text' => $category->get('name'),
2072
-                'id'   => $category->ID(),
2073
-            ];
2074
-        }
2075
-
2076
-        return self::select_input('EVT_CAT', $options, $current_cat);
2077
-    }
2078
-
2079
-
2080
-    /**
2081
-     *    generate a submit button with or without it's own microform
2082
-     *    this is the only way to create buttons that are compatible across all themes
2083
-     *
2084
-     * @access    public
2085
-     * @param string      $url              - the form action
2086
-     * @param string      $ID               - some kind of unique ID, appended with "-sbmt" for the input and "-frm"
2087
-     *                                      for the form
2088
-     * @param string      $class            - css classes (separated by spaces if more than one)
2089
-     * @param string      $text             - what appears on the button
2090
-     * @param string      $nonce_action     - if using nonces
2091
-     * @param bool|string $input_only       - whether to print form header and footer. TRUE returns the input without
2092
-     *                                      the form
2093
-     * @param string      $extra_attributes - any extra attributes that need to be attached to the form input
2094
-     * @return    string
2095
-     */
2096
-    public static function submit_button(
2097
-        $url = '',
2098
-        $ID = '',
2099
-        $class = '',
2100
-        $text = '',
2101
-        $nonce_action = '',
2102
-        $input_only = false,
2103
-        $extra_attributes = ''
2104
-    ) {
2105
-        $btn = '';
2106
-        if (empty($url) || empty($ID)) {
2107
-            return $btn;
2108
-        }
2109
-        $text = ! empty($text) ? $text : esc_html__('Submit', 'event_espresso');
2110
-        $btn  .= '<input id="' . $ID . '-btn" class="' . $class . '" '
2111
-                 . 'type="submit" value="' . $text . '" ' . $extra_attributes . '/>';
2112
-        if (! $input_only) {
2113
-            $btn_frm = '<form id="' . $ID . '-frm" method="POST" action="' . $url . '">';
2114
-            $btn_frm .= ! empty($nonce_action)
2115
-                ? wp_nonce_field($nonce_action, $nonce_action . '_nonce', true, false)
2116
-                : '';
2117
-            $btn_frm .= $btn;
2118
-            $btn_frm .= '</form>';
2119
-            $btn     = $btn_frm;
2120
-            unset($btn_frm);
2121
-        }
2122
-        return $btn;
2123
-    }
1089
+		$input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1090
+		return $label_html . $input_html;
1091
+	}
1092
+
1093
+
1094
+	/**
1095
+	 * generates HTML for a form textarea
1096
+	 *
1097
+	 * @param string $question    label content
1098
+	 * @param string $answer      form input value attribute
1099
+	 * @param string $name        form input name attribute
1100
+	 * @param string $id          form input css id attribute
1101
+	 * @param string $class       form input css class attribute
1102
+	 * @param array  $dimensions  array of form input rows and cols attributes : array( 'rows' => 3, 'cols' => 40 )
1103
+	 * @param array  $required    'label', 'class', and 'msg' - array of values for required "label" content, css
1104
+	 *                            required 'class', and required 'msg' attribute
1105
+	 * @param string $label_class css class attribute for the label
1106
+	 * @param string $disabled    disabled="disabled" or null
1107
+	 * @return string HTML
1108
+	 */
1109
+	public static function textarea(
1110
+		$question = false,
1111
+		$answer = null,
1112
+		$name = false,
1113
+		$id = '',
1114
+		$class = '',
1115
+		$dimensions = false,
1116
+		$required = false,
1117
+		$required_text = '',
1118
+		$label_class = '',
1119
+		$disabled = false,
1120
+		$system_ID = false,
1121
+		$use_html_entities = true,
1122
+		$add_mobile_label = false
1123
+	) {
1124
+		// need these
1125
+		if (! $question || ! $name) {
1126
+			return null;
1127
+		}
1128
+		// prep the answer
1129
+		$answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities);
1130
+		// prep the required array
1131
+		$required = self::prep_required($required);
1132
+		// make sure $dimensions is an array
1133
+		$dimensions = is_array($dimensions) ? $dimensions : [];
1134
+		// and set some defaults
1135
+		$dimensions = array_merge(['rows' => 3, 'cols' => 40], $dimensions);
1136
+		// set disabled tag
1137
+		$disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
1138
+		// ya gots ta have style man!!!
1139
+		$class     .= ! empty($system_ID) ? ' ' . $system_ID : '';
1140
+		$class     .= ! empty($required['class']) ? ' ' . $required['class'] : '';
1141
+		$extra     = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1142
+
1143
+		$label_html   = self::label($question, $required_text, $required['label'], $name, $label_class);
1144
+		$mobile_label = self::mobileLabel(
1145
+			$add_mobile_label,
1146
+			$question,
1147
+			$required_text,
1148
+			$required['label'],
1149
+			$label_class,
1150
+			$name
1151
+		);
1152
+
1153
+		$input_html = $mobile_label
1154
+			. '<textarea name="' . $name . '" id="' . $id . '" class="' . trim($class) . '" '
1155
+			. 'rows="' . $dimensions['rows'] . '" cols="' . $dimensions['cols'] . '"  '
1156
+			. 'aria-label="' . $required['msg'] . '" ' . $disabled . ' ' . $extra . '>'
1157
+			 . esc_textarea($answer)
1158
+			  . '</textarea>';
1159
+
1160
+		$input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1161
+		return $label_html . $input_html;
1162
+	}
1163
+
1164
+
1165
+	/**
1166
+	 * generates HTML for a form select input
1167
+	 *
1168
+	 * @param string $question    label content
1169
+	 * @param string $answer      form input value attribute
1170
+	 * @param array  $options     array of answer options where array key = option value and array value = option
1171
+	 *                            display text
1172
+	 * @param string $name        form input name attribute
1173
+	 * @param string $id          form input css id attribute
1174
+	 * @param string $class       form input css class attribute
1175
+	 * @param array  $required    'label', 'class', and 'msg' - array of values for required "label" content, css
1176
+	 *                            required 'class', and required 'msg' attribute
1177
+	 * @param string $label_class css class attribute for the label
1178
+	 * @param string $disabled    disabled="disabled" or null
1179
+	 * @return string HTML
1180
+	 */
1181
+	public static function select(
1182
+		$question = false,
1183
+		$answer = null,
1184
+		$options = false,
1185
+		$name = false,
1186
+		$id = '',
1187
+		$class = '',
1188
+		$required = false,
1189
+		$required_text = '',
1190
+		$label_class = '',
1191
+		$disabled = false,
1192
+		$system_ID = false,
1193
+		$use_html_entities = true,
1194
+		$add_please_select_option = false,
1195
+		$add_mobile_label = false
1196
+	) {
1197
+
1198
+		// need these
1199
+		if (! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
1200
+			return null;
1201
+		}
1202
+		// prep the answer
1203
+		$answer = is_array($answer)
1204
+			? self::prep_answer(array_shift($answer), $use_html_entities)
1205
+			: self::prep_answer($answer, $use_html_entities);
1206
+		// prep the required array
1207
+		$required = self::prep_required($required);
1208
+		// set disabled tag
1209
+		$disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
1210
+		// ya gots ta have style man!!!
1211
+		$class     .= ! empty($system_ID) ? ' ' . $system_ID : '';
1212
+		$class = self::appendInputSizeClass($class, $options);
1213
+		$extra     = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1214
+
1215
+		$label_html   = self::label($question, $required_text, $required['label'], $name, $label_class);
1216
+		$mobile_label = self::mobileLabel(
1217
+			$add_mobile_label,
1218
+			$question,
1219
+			$required_text,
1220
+			$required['label'],
1221
+			$label_class,
1222
+			$name
1223
+		);
1224
+
1225
+		$input_html = $mobile_label
1226
+			. '<select name="' . $name . '" id="' . $id . '" class="' . trim($class) . ' ' . $required['class'] . '" '
1227
+			. 'aria-label="' . esc_attr($required['msg']) . '"' . $disabled . ' ' . $extra . '>';
1228
+		// recursively count array elements, to determine total number of options
1229
+		$only_option = count($options, 1) == 1;
1230
+		if (! $only_option) {
1231
+			// if there is NO answer set and there are multiple options to choose from, then set the "please select" message as selected
1232
+			$selected   = $answer === null ? ' selected="selected"' : '';
1233
+			$input_html .= $add_please_select_option
1234
+				? "\n\t\t\t\t"
1235
+				  . '<option value=""' . $selected . '>'
1236
+				  . esc_html__(' - please select - ', 'event_espresso')
1237
+				  . '</option>'
1238
+				: '';
1239
+		}
1240
+		foreach ($options as $key => $value) {
1241
+			// if value is an array, then create option groups, else create regular ol' options
1242
+			$input_html .= is_array($value)
1243
+				? self::_generate_select_option_group(
1244
+					$key,
1245
+					$value,
1246
+					$answer,
1247
+					$use_html_entities
1248
+				)
1249
+				: self::_generate_select_option(
1250
+					$value->value(),
1251
+					$value->desc(),
1252
+					$answer,
1253
+					$only_option,
1254
+					$use_html_entities
1255
+				);
1256
+		}
1257
+
1258
+		$input_html .= "\n\t\t\t" . '</select>';
1259
+
1260
+		$input_html =
1261
+			apply_filters(
1262
+				'FHEE__EEH_Form_Fields__select__before_end_wrapper',
1263
+				$input_html,
1264
+				$question,
1265
+				$answer,
1266
+				$name,
1267
+				$id,
1268
+				$class,
1269
+				$system_ID
1270
+			);
1271
+
1272
+		$input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1273
+		return $label_html . $input_html;
1274
+	}
1275
+
1276
+
1277
+	/**
1278
+	 *  _generate_select_option_group
1279
+	 *
1280
+	 *  if  $value for a select box is an array, then the key will be used as the optgroup label
1281
+	 *  and the value array will be looped thru and the elements sent to _generate_select_option
1282
+	 *
1283
+	 * @param mixed   $opt_group
1284
+	 * @param mixed   $QSOs
1285
+	 * @param mixed   $answer
1286
+	 * @param boolean $use_html_entities
1287
+	 * @return string
1288
+	 */
1289
+	private static function _generate_select_option_group($opt_group, $QSOs, $answer, $use_html_entities = true)
1290
+	{
1291
+		$html = "\n\t\t\t\t" . '<optgroup label="' . self::prep_option_value($opt_group) . '">';
1292
+		foreach ($QSOs as $QSO) {
1293
+			$html .= self::_generate_select_option($QSO->value(), $QSO->desc(), $answer, false, $use_html_entities);
1294
+		}
1295
+		$html .= "\n\t\t\t\t" . '</optgroup>';
1296
+		return $html;
1297
+	}
1298
+
1299
+
1300
+	/**
1301
+	 *  _generate_select_option
1302
+	 *
1303
+	 * @param mixed   $key
1304
+	 * @param mixed   $value
1305
+	 * @param mixed   $answer
1306
+	 * @param int     $only_option
1307
+	 * @param boolean $use_html_entities
1308
+	 * @return string
1309
+	 */
1310
+	private static function _generate_select_option(
1311
+		$key,
1312
+		$value,
1313
+		$answer,
1314
+		$only_option = false,
1315
+		$use_html_entities = true
1316
+	) {
1317
+		$key      = self::prep_answer($key, $use_html_entities);
1318
+		$value    = self::prep_answer($value, $use_html_entities);
1319
+		$value    = ! empty($value) ? $value : $key;
1320
+		$selected = ($answer == $key || $only_option) ? 'selected="selected"' : '';
1321
+		return "\n\t\t\t\t"
1322
+			   . '<option value="' . self::prep_option_value($key) . '" ' . $selected . '> '
1323
+			   . $value
1324
+			   . '&nbsp;&nbsp;&nbsp;</option>';
1325
+	}
1326
+
1327
+
1328
+	/**
1329
+	 * generates HTML for form radio button inputs
1330
+	 *
1331
+	 * @param bool|string $question    label content
1332
+	 * @param string      $answer      form input value attribute
1333
+	 * @param array|bool  $options     array of answer options where array key = option value and array value = option
1334
+	 *                                 display text
1335
+	 * @param bool|string $name        form input name attribute
1336
+	 * @param string      $id          form input css id attribute
1337
+	 * @param string      $class       form input css class attribute
1338
+	 * @param array|bool  $required    'label', 'class', and 'msg' - array of values for required "label" content, css
1339
+	 *                                 required 'class', and required 'msg' attribute
1340
+	 * @param string      $required_text
1341
+	 * @param string      $label_class css class attribute for the label
1342
+	 * @param bool|string $disabled    disabled="disabled" or null
1343
+	 * @param bool        $system_ID
1344
+	 * @param bool        $use_html_entities
1345
+	 * @param bool        $label_b4
1346
+	 * @param bool        $use_desc_4_label
1347
+	 * @return string HTML
1348
+	 */
1349
+	public static function radio(
1350
+		$question = false,
1351
+		$answer = null,
1352
+		$options = false,
1353
+		$name = false,
1354
+		$id = '',
1355
+		$class = '',
1356
+		$required = false,
1357
+		$required_text = '',
1358
+		$label_class = '',
1359
+		$disabled = false,
1360
+		$system_ID = false,
1361
+		$use_html_entities = true,
1362
+		$label_b4 = false,
1363
+		$use_desc_4_label = false,
1364
+		$add_mobile_label = false
1365
+	) {
1366
+		// need these
1367
+		if (! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
1368
+			return null;
1369
+		}
1370
+		// prep the answer
1371
+		$answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities);
1372
+		// prep the required array
1373
+		$required = self::prep_required($required);
1374
+		// set disabled tag
1375
+		$disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
1376
+		// ya gots ta have style man!!!
1377
+		$radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class;
1378
+		$class       = ! empty($class) ? $class : 'espresso-radio-btn-inp';
1379
+		$extra       = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1380
+
1381
+		$label_html = self::label($question, $required_text, $required['label'], '', $label_class);
1382
+		$mobile_label = self::mobileLabel(
1383
+			$add_mobile_label,
1384
+			$question,
1385
+			$required_text,
1386
+			$required['label'],
1387
+			$label_class
1388
+		);
1389
+
1390
+		$input_html = $mobile_label
1391
+			. '<ul id="' . $id . '-ul" class="espresso-radio-btn-options-ul ' . $class . '-ul">';
1392
+
1393
+		$class .= ! empty($system_ID) ? ' ' . $system_ID : '';
1394
+		$class .= ! empty($required['class']) ? ' ' . $required['class'] : '';
1395
+
1396
+		foreach ($options as $OPT) {
1397
+			if ($OPT instanceof EE_Question_Option) {
1398
+				$value   = self::prep_option_value($OPT->value());
1399
+				$label   = $use_desc_4_label ? $OPT->desc() : $OPT->value();
1400
+				$size    = $use_desc_4_label
1401
+					? self::get_label_size_class($OPT->value() . ' ' . $OPT->desc())
1402
+					: self::get_label_size_class($OPT->value());
1403
+				$desc    = $OPT->desc();// no self::prep_answer
1404
+				$answer  = is_numeric($value) && empty($answer) ? 0 : $answer;
1405
+				$checked = (string) $value == (string) $answer ? ' checked="checked"' : '';
1406
+				$opt     = '-' . sanitize_key($value);
1407
+
1408
+				$input_html .= "\n\t\t\t\t" . '<li' . $size . '>';
1409
+				$input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-radio-btn-lbl">';
1410
+				$input_html .= $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $label . '</span>&nbsp;&nbsp;' : '';
1411
+				$input_html .= "\n\t\t\t\t\t\t"
1412
+							   . '<input type="radio" name="' . $name . '" id="' . $id . $opt . '" '
1413
+							   . 'class="' . $class . '" value="' . $value . '" '
1414
+							   . 'aria-label="' . esc_attr($required['msg']) . '" ' . $disabled
1415
+							   . $checked . ' ' . $extra . '/>';
1416
+				$input_html .= ! $label_b4
1417
+					? "\n\t\t\t\t\t\t"
1418
+					  . '&nbsp;&nbsp;<span class="espresso-radio-btn-desc">'
1419
+					  . $label
1420
+					  . '</span>'
1421
+					: '';
1422
+				$input_html .= "\n\t\t\t\t\t" . '</label>';
1423
+				$input_html .= $use_desc_4_label
1424
+					? ''
1425
+					: '<span class="espresso-radio-btn-option-desc small-text grey-text">' . $desc . '</span>';
1426
+				$input_html .= "\n\t\t\t\t" . '</li>';
1427
+			}
1428
+		}
1429
+
1430
+		$input_html .= "\n\t\t\t" . '</ul>';
1431
+
1432
+		$input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1433
+		return $label_html . $input_html;
1434
+	}
1435
+
1436
+
1437
+	/**
1438
+	 * generates HTML for form checkbox inputs
1439
+	 *
1440
+	 * @param string $question    label content
1441
+	 * @param string $answer      form input value attribute
1442
+	 * @param array  $options     array of options where array key = option value and array value = option display text
1443
+	 * @param string $name        form input name attribute
1444
+	 * @param string $id          form input css id attribute
1445
+	 * @param string $class       form input css class attribute
1446
+	 * @param array  $required    'label', 'class', and 'msg' - array of values for required "label" content, css
1447
+	 *                            required 'class', and required 'msg' attribute
1448
+	 * @param string $label_class css class attribute for the label
1449
+	 * @param string $disabled    disabled="disabled" or null
1450
+	 * @return string HTML
1451
+	 */
1452
+	public static function checkbox(
1453
+		$question = false,
1454
+		$answer = null,
1455
+		$options = false,
1456
+		$name = false,
1457
+		$id = '',
1458
+		$class = '',
1459
+		$required = false,
1460
+		$required_text = '',
1461
+		$label_class = '',
1462
+		$disabled = false,
1463
+		$label_b4 = false,
1464
+		$system_ID = false,
1465
+		$use_html_entities = true,
1466
+		$add_mobile_label = false
1467
+	) {
1468
+		// need these
1469
+		if (! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
1470
+			return null;
1471
+		}
1472
+		$answer = maybe_unserialize($answer);
1473
+
1474
+		// prep the answer(s)
1475
+		$answer = is_array($answer) ? $answer : [sanitize_key($answer) => $answer];
1476
+
1477
+		foreach ($answer as $key => $value) {
1478
+			$key            = self::prep_option_value($key);
1479
+			$answer[ $key ] = self::prep_answer($value, $use_html_entities);
1480
+		}
1481
+
1482
+		// prep the required array
1483
+		$required = self::prep_required($required);
1484
+		// set disabled tag
1485
+		$disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
1486
+		// ya gots ta have style man!!!
1487
+		$radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class;
1488
+		$class       = empty($class) ? 'espresso-radio-btn-inp' : $class;
1489
+		$extra       = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1490
+
1491
+		$label_html   = self::label($question, $required_text, $required['label'], '', $label_class);
1492
+		$mobile_label = self::mobileLabel(
1493
+			$add_mobile_label,
1494
+			$question,
1495
+			$required_text,
1496
+			$required['label'],
1497
+			$label_class
1498
+		);
1499
+
1500
+		$input_html = $mobile_label
1501
+			. '<ul id="' . $id . '-ul" class="espresso-checkbox-options-ul ' . $class . '-ul">';
1502
+
1503
+		$class .= ! empty($system_ID) ? ' ' . $system_ID : '';
1504
+		$class .= ! empty($required['class']) ? ' ' . $required['class'] : '';
1505
+
1506
+		foreach ($options as $OPT) {
1507
+			$value = $OPT->value();// self::prep_option_value( $OPT->value() );
1508
+			$size  = self::get_label_size_class($OPT->value() . ' ' . $OPT->desc());
1509
+			$text  = self::prep_answer($OPT->value());
1510
+			$desc  = $OPT->desc();
1511
+			$opt   = '-' . sanitize_key($value);
1512
+
1513
+			$checked = is_array($answer) && in_array($text, $answer) ? ' checked="checked"' : '';
1514
+
1515
+			$input_html .= "\n\t\t\t\t" . '<li' . $size . '>';
1516
+			$input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-checkbox-lbl">';
1517
+			$input_html .= $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>&nbsp;&nbsp;' : '';
1518
+			$input_html .= "\n\t\t\t\t\t\t"
1519
+						   . '<input type="checkbox" name="' . $name . '[' . $OPT->ID() . ']" '
1520
+						   . 'id="' . $id . $opt . '" class="' . $class . '" value="' . $value . '" '
1521
+						   . 'aria-label="' . esc_attr($required['msg']) . '" ' . $disabled . $checked . ' ' . $extra . '/>';
1522
+			$input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t" . '&nbsp;&nbsp;<span>' . $text . '</span>' : '';
1523
+			$input_html .= "\n\t\t\t\t\t" . '</label>';
1524
+			if (! empty($desc) && $desc != $text) {
1525
+				$input_html .= "\n\t\t\t\t\t"
1526
+							   . ' &nbsp; <br/><div class="espresso-checkbox-option-desc small-text grey-text">'
1527
+							   . $desc
1528
+							   . '</div>';
1529
+			}
1530
+			$input_html .= "\n\t\t\t\t" . '</li>';
1531
+		}
1532
+
1533
+		$input_html .= "\n\t\t\t" . '</ul>';
1534
+
1535
+		$input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1536
+		return $label_html . $input_html;
1537
+	}
1538
+
1539
+
1540
+	/**
1541
+	 * generates HTML for a form datepicker input
1542
+	 *
1543
+	 * @param string $question    label content
1544
+	 * @param string $answer      form input value attribute
1545
+	 * @param string $name        form input name attribute
1546
+	 * @param string $id          form input css id attribute
1547
+	 * @param string $class       form input css class attribute
1548
+	 * @param array  $required    'label', 'class', and 'msg' - array of values for required "label" content, css
1549
+	 *                            required 'class', and required 'msg' attribute
1550
+	 * @param string $label_class css class attribute for the label
1551
+	 * @param string $disabled    disabled="disabled" or null
1552
+	 * @return string HTML
1553
+	 */
1554
+	public static function datepicker(
1555
+		$question = false,
1556
+		$answer = null,
1557
+		$name = false,
1558
+		$id = '',
1559
+		$class = '',
1560
+		$required = false,
1561
+		$required_text = '',
1562
+		$label_class = '',
1563
+		$disabled = false,
1564
+		$system_ID = false,
1565
+		$use_html_entities = true,
1566
+		$add_mobile_label = false
1567
+	) {
1568
+		// need these
1569
+		if (! $question || ! $name) {
1570
+			return null;
1571
+		}
1572
+		// prep the answer
1573
+		$answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities);
1574
+		// prep the required array
1575
+		$required = self::prep_required($required);
1576
+		// set disabled tag
1577
+		$disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
1578
+		// ya gots ta have style man!!!
1579
+		$txt_class = is_admin() ? 'regular-text' : 'espresso-datepicker-inp';
1580
+		$class     = empty($class) ? $txt_class : $class;
1581
+		$class     .= ! empty($system_ID) ? ' ' . $system_ID : '';
1582
+		$class = self::appendInputSizeClass($class, $answer);
1583
+		$extra     = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1584
+
1585
+		$label_html   = self::label($question, $required_text, $required['label'], '', $label_class);
1586
+		$mobile_label = self::mobileLabel(
1587
+			$add_mobile_label,
1588
+			$question,
1589
+			$required_text,
1590
+			$required['label'],
1591
+			$label_class,
1592
+			$name
1593
+		);
1594
+
1595
+		$input_html = $mobile_label
1596
+			. '<input type="text" name="' . $name . '" id="' . $id . '" '
1597
+			. 'class="' . $class . ' ' . $required['class'] . ' datepicker" value="' . $answer . '"  '
1598
+			. 'aria-label="' . esc_attr($required['msg']) . '" ' . $disabled . ' ' . $extra . '/>';
1599
+
1600
+		// enqueue scripts
1601
+		wp_register_style(
1602
+			'espresso-ui-theme',
1603
+			EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1604
+			[],
1605
+			EVENT_ESPRESSO_VERSION
1606
+		);
1607
+		wp_enqueue_style('espresso-ui-theme');
1608
+		wp_enqueue_script('jquery-ui-datepicker');
1609
+
1610
+		$input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1611
+		return $label_html . $input_html;
1612
+	}
1613
+
1614
+
1615
+	/**
1616
+	 *  remove_label_keep_required_msg
1617
+	 *  this will strip out a form input's label HTML while keeping the required text HTML that MUST be before the label
1618
+	 *
1619
+	 * @access public
1620
+	 * @return     string
1621
+	 */
1622
+	public static function remove_label_keep_required_msg($label_html, $required_text)
1623
+	{
1624
+		return $required_text;
1625
+	}
1626
+
1627
+
1628
+	/**
1629
+	 * Simply returns the HTML for a hidden input of the given name and value.
1630
+	 *
1631
+	 * @param string $name
1632
+	 * @param string $value
1633
+	 * @return string HTML
1634
+	 */
1635
+	public static function hidden_input($name, $value, $id = '')
1636
+	{
1637
+		$id = ! empty($id) ? $id : $name;
1638
+		return '<input id="' . $id . '" type="hidden" name="' . $name . '" value="' . $value . '"/>';
1639
+	}
1640
+
1641
+
1642
+	/**
1643
+	 * prep_question
1644
+	 *
1645
+	 * @param string $question
1646
+	 * @return string
1647
+	 */
1648
+	public static function prep_question($question)
1649
+	{
1650
+		return $question;
1651
+	}
1652
+
1653
+
1654
+	/**
1655
+	 *  prep_answer
1656
+	 *
1657
+	 * @param mixed $answer
1658
+	 * @return string
1659
+	 */
1660
+	public static function prep_answer($answer, $use_html_entities = true)
1661
+	{
1662
+		// make sure we convert bools first.  Otherwise (bool) false becomes an empty string which is NOT desired,
1663
+		// we want "0".
1664
+		if (is_bool($answer)) {
1665
+			$answer = $answer ? 1 : 0;
1666
+		}
1667
+		$answer = trim(stripslashes(str_replace('&#039;', "'", $answer)));
1668
+		return $use_html_entities ? htmlentities($answer, ENT_QUOTES, 'UTF-8') : $answer;
1669
+	}
1670
+
1671
+
1672
+	/**
1673
+	 *  prep_answer_options
1674
+	 *
1675
+	 * @param array $QSOs array of EE_Question_Option objects
1676
+	 * @return array
1677
+	 */
1678
+	public static function prep_answer_options($QSOs = [])
1679
+	{
1680
+		$prepped_answer_options = [];
1681
+		if (is_array($QSOs) && ! empty($QSOs)) {
1682
+			foreach ($QSOs as $key => $QSO) {
1683
+				if (! $QSO instanceof EE_Question_Option) {
1684
+					$QSO = EE_Question_Option::new_instance(
1685
+						[
1686
+							'QSO_value' => is_array($QSO) && isset($QSO['id'])
1687
+								? (string) $QSO['id']
1688
+								: (string) $key,
1689
+							'QSO_desc'  => is_array($QSO) && isset($QSO['text'])
1690
+								? (string) $QSO['text']
1691
+								: (string) $QSO,
1692
+						]
1693
+					);
1694
+				}
1695
+				if ($QSO->opt_group()) {
1696
+					$prepped_answer_options[ $QSO->opt_group() ][] = $QSO;
1697
+				} else {
1698
+					$prepped_answer_options[] = $QSO;
1699
+				}
1700
+			}
1701
+		}
1702
+		//      d( $prepped_answer_options );
1703
+		return $prepped_answer_options;
1704
+	}
1705
+
1706
+
1707
+	/**
1708
+	 *  prep_option_value
1709
+	 *
1710
+	 * @param string $option_value
1711
+	 * @return string
1712
+	 */
1713
+	public static function prep_option_value($option_value)
1714
+	{
1715
+		return esc_attr(trim(stripslashes($option_value)));
1716
+	}
1717
+
1718
+
1719
+	/**
1720
+	 *  prep_required
1721
+	 *
1722
+	 * @param string|array $required
1723
+	 * @return array
1724
+	 */
1725
+	public static function prep_required($required = [])
1726
+	{
1727
+		// make sure required is an array
1728
+		$required = is_array($required) ? $required : [];
1729
+		// and set some defaults
1730
+		return array_merge(['label' => '', 'class' => '', 'msg' => ''], $required);
1731
+	}
1732
+
1733
+
1734
+	/**
1735
+	 *  get_label_size_class
1736
+	 *
1737
+	 * @param string $value
1738
+	 * @return string
1739
+	 */
1740
+	public static function get_label_size_class($value = false)
1741
+	{
1742
+		if ($value === false || $value === '') {
1743
+			return ' class="medium-lbl"';
1744
+		}
1745
+		// determine length of option value
1746
+		$val_size = strlen($value);
1747
+		switch ($val_size) {
1748
+			case $val_size < 3:
1749
+				$size = ' class="nano-lbl"';
1750
+				break;
1751
+			case $val_size < 6:
1752
+				$size = ' class="micro-lbl"';
1753
+				break;
1754
+			case $val_size < 12:
1755
+				$size = ' class="tiny-lbl"';
1756
+				break;
1757
+			case $val_size < 25:
1758
+				$size = ' class="small-lbl"';
1759
+				break;
1760
+			case $val_size > 100:
1761
+				$size = ' class="big-lbl"';
1762
+				break;
1763
+			default:
1764
+				$size = ' class="medium-lbl"';
1765
+				break;
1766
+		}
1767
+		return $size;
1768
+	}
1769
+
1770
+
1771
+	/**
1772
+	 *  _load_system_dropdowns
1773
+	 *
1774
+	 * @param EE_Question_Form_Input $QFI
1775
+	 * @return array
1776
+	 * @throws EE_Error
1777
+	 * @throws ReflectionException
1778
+	 */
1779
+	private static function _load_system_dropdowns($QFI)
1780
+	{
1781
+		$QST_system = $QFI->get('QST_system');
1782
+		switch ($QST_system) {
1783
+			case 'state':
1784
+				$QFI = self::generate_state_dropdown($QFI);
1785
+				break;
1786
+			case 'country':
1787
+				$QFI = self::generate_country_dropdown($QFI);
1788
+				break;
1789
+			case 'admin-state':
1790
+				$QFI = self::generate_state_dropdown($QFI, true);
1791
+				break;
1792
+			case 'admin-country':
1793
+				$QFI = self::generate_country_dropdown($QFI, true);
1794
+				break;
1795
+		}
1796
+		return $QFI;
1797
+	}
1798
+
1799
+
1800
+	/**
1801
+	 * This preps dropdowns that are specialized.
1802
+	 *
1803
+	 * @param EE_Question_Form_Input $QFI
1804
+	 *
1805
+	 * @return EE_Question_Form_Input
1806
+	 * @throws EE_Error
1807
+	 * @throws ReflectionException
1808
+	 * @since  4.6.0
1809
+	 */
1810
+	protected static function _load_specialized_dropdowns($QFI)
1811
+	{
1812
+		switch ($QFI->get('QST_type')) {
1813
+			case 'STATE':
1814
+				$QFI = self::generate_state_dropdown($QFI);
1815
+				break;
1816
+			case 'COUNTRY':
1817
+				$QFI = self::generate_country_dropdown($QFI);
1818
+				break;
1819
+		}
1820
+		return $QFI;
1821
+	}
1822
+
1823
+
1824
+	/**
1825
+	 *    generate_state_dropdown
1826
+	 *
1827
+	 * @param EE_Question_Form_Input $QST
1828
+	 * @param bool                   $get_all
1829
+	 * @return EE_Question_Form_Input
1830
+	 * @throws EE_Error
1831
+	 * @throws ReflectionException
1832
+	 */
1833
+	public static function generate_state_dropdown($QST, $get_all = false)
1834
+	{
1835
+		$states = $get_all
1836
+			? EEM_State::instance()->get_all_states()
1837
+			: EEM_State::instance()->get_all_states_of_active_countries();
1838
+		if ($states && count($states) != count($QST->options())) {
1839
+			$QST->set('QST_type', 'DROPDOWN');
1840
+			// if multiple countries, we'll create option groups within the dropdown
1841
+			foreach ($states as $state) {
1842
+				if ($state instanceof EE_State) {
1843
+					$QSO = EE_Question_Option::new_instance(
1844
+						[
1845
+							'QSO_value'   => $state->ID(),
1846
+							'QSO_desc'    => $state->name(),
1847
+							'QST_ID'      => $QST->get('QST_ID'),
1848
+							'QSO_deleted' => false,
1849
+						]
1850
+					);
1851
+					// set option group
1852
+					$QSO->set_opt_group($state->country()->name());
1853
+					// add option to question
1854
+					$QST->add_temp_option($QSO);
1855
+				}
1856
+			}
1857
+		}
1858
+		return $QST;
1859
+	}
1860
+
1861
+
1862
+	/**
1863
+	 *    generate_country_dropdown
1864
+	 *
1865
+	 * @param      $QST
1866
+	 * @param bool $get_all
1867
+	 * @return array
1868
+	 * @throws EE_Error
1869
+	 * @throws ReflectionException
1870
+	 * @internal param array $question
1871
+	 */
1872
+	public static function generate_country_dropdown($QST, $get_all = false)
1873
+	{
1874
+		$countries = $get_all
1875
+			? EEM_Country::instance()->get_all_countries()
1876
+			: EEM_Country::instance()->get_all_active_countries();
1877
+		if ($countries && count($countries) != count($QST->options())) {
1878
+			$QST->set('QST_type', 'DROPDOWN');
1879
+			// now add countries
1880
+			foreach ($countries as $country) {
1881
+				if ($country instanceof EE_Country) {
1882
+					$QSO = EE_Question_Option::new_instance(
1883
+						[
1884
+							'QSO_value'   => $country->ID(),
1885
+							'QSO_desc'    => $country->name(),
1886
+							'QST_ID'      => $QST->get('QST_ID'),
1887
+							'QSO_deleted' => false,
1888
+						]
1889
+					);
1890
+					$QST->add_temp_option($QSO);
1891
+				}
1892
+			}
1893
+		}
1894
+		return $QST;
1895
+	}
1896
+
1897
+
1898
+	/**
1899
+	 *  generates options for a month dropdown selector with numbers from 01 to 12
1900
+	 *
1901
+	 * @return array()
1902
+	 */
1903
+	public static function two_digit_months_dropdown_options()
1904
+	{
1905
+		$options = [];
1906
+		for ($x = 1; $x <= 12; $x++) {
1907
+			$mm             = str_pad($x, 2, '0', STR_PAD_LEFT);
1908
+			$options[ $mm ] = $mm;
1909
+		}
1910
+		return EEH_Form_Fields::prep_answer_options($options);
1911
+	}
1912
+
1913
+
1914
+	/**
1915
+	 *  generates a year dropdown selector with numbers for the next ten years
1916
+	 *
1917
+	 * @return array
1918
+	 */
1919
+	public static function next_decade_two_digit_year_dropdown_options()
1920
+	{
1921
+		$options      = [];
1922
+		$current_year = date('y');
1923
+		$next_decade  = $current_year + 10;
1924
+		for ($x = $current_year; $x <= $next_decade; $x++) {
1925
+			$yy             = str_pad($x, 2, '0', STR_PAD_LEFT);
1926
+			$options[ $yy ] = $yy;
1927
+		}
1928
+		return EEH_Form_Fields::prep_answer_options($options);
1929
+	}
1930
+
1931
+
1932
+	/**
1933
+	 * generates a month/year dropdown selector for all registrations matching the given criteria.  Typically used for
1934
+	 * list table filter.
1935
+	 *
1936
+	 * @param string  $cur_date     any currently selected date can be entered here.
1937
+	 * @param string  $status       Registration status
1938
+	 * @param integer $evt_category Event Category ID if the Event Category filter is selected
1939
+	 * @return string                html
1940
+	 * @throws EE_Error
1941
+	 */
1942
+	public static function generate_registration_months_dropdown($cur_date = '', $status = '', $evt_category = 0)
1943
+	{
1944
+		$_where = [];
1945
+		if (! empty($status)) {
1946
+			$_where['STS_ID'] = $status;
1947
+		}
1948
+
1949
+		if ($evt_category > 0) {
1950
+			$_where['Event.Term_Taxonomy.term_id'] = $evt_category;
1951
+		}
1952
+
1953
+		$regdtts = EEM_Registration::instance()->get_reg_months_and_years($_where);
1954
+
1955
+		// setup vals for select input helper
1956
+		$options = [
1957
+			0 => [
1958
+				'text' => esc_html__('Select a Month/Year', 'event_espresso'),
1959
+				'id'   => '',
1960
+			],
1961
+		];
1962
+
1963
+		foreach ($regdtts as $regdtt) {
1964
+			$date      = $regdtt->reg_month . ' ' . $regdtt->reg_year;
1965
+			$options[] = [
1966
+				'text' => $date,
1967
+				'id'   => $date,
1968
+			];
1969
+		}
1970
+
1971
+		return self::select_input('month_range', $options, $cur_date);
1972
+	}
1973
+
1974
+
1975
+	/**
1976
+	 * generates a month/year dropdown selector for all events matching the given criteria
1977
+	 * Typically used for list table filter
1978
+	 *
1979
+	 * @param string $cur_date          any currently selected date can be entered here.
1980
+	 * @param string $status            "view" (i.e. all, today, month, draft)
1981
+	 * @param int    $evt_category      category event belongs to
1982
+	 * @param string $evt_active_status "upcoming", "expired", "active", or "inactive"
1983
+	 * @return string                    html
1984
+	 * @throws EE_Error
1985
+	 */
1986
+	public static function generate_event_months_dropdown(
1987
+		$cur_date = '',
1988
+		$status = null,
1989
+		$evt_category = null,
1990
+		$evt_active_status = null
1991
+	) {
1992
+		// determine what post_status our condition will have for the query.
1993
+		// phpcs:disable PSR2.ControlStructures.SwitchDeclaration.TerminatingComment
1994
+		switch ($status) {
1995
+			case 'month':
1996
+			case 'today':
1997
+			case null:
1998
+			case 'all':
1999
+				$where['Event.status'] = ['NOT IN', ['trash']];
2000
+				break;
2001
+			case 'draft':
2002
+				$where['Event.status'] = ['IN', ['draft', 'auto-draft']];
2003
+				break;
2004
+			default:
2005
+				$where['Event.status'] = $status;
2006
+		}
2007
+
2008
+		// phpcs:enable
2009
+
2010
+		// categories?
2011
+
2012
+
2013
+		if (! empty($evt_category)) {
2014
+			$where['Event.Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
2015
+			$where['Event.Term_Taxonomy.term_id']  = $evt_category;
2016
+		}
2017
+
2018
+
2019
+		//      $where['DTT_is_primary'] = 1;
2020
+
2021
+		$DTTS = EEM_Datetime::instance()->get_dtt_months_and_years($where, $evt_active_status);
2022
+
2023
+		// let's setup vals for select input helper
2024
+		$options = [
2025
+			0 => [
2026
+				'text' => esc_html__('Select a Month/Year', 'event_espresso'),
2027
+				'id'   => "",
2028
+			],
2029
+		];
2030
+
2031
+
2032
+		// translate month and date
2033
+		global $wp_locale;
2034
+
2035
+		foreach ($DTTS as $DTT) {
2036
+			$localized_date = $wp_locale->get_month($DTT->dtt_month_num) . ' ' . $DTT->dtt_year;
2037
+			$id             = $DTT->dtt_month . ' ' . $DTT->dtt_year;
2038
+			$options[]      = [
2039
+				'text' => $localized_date,
2040
+				'id'   => $id,
2041
+			];
2042
+		}
2043
+
2044
+
2045
+		return self::select_input('month_range', $options, $cur_date);
2046
+	}
2047
+
2048
+
2049
+	/**
2050
+	 * generates the dropdown selector for event categories
2051
+	 * typically used as a filter on list tables.
2052
+	 *
2053
+	 * @param integer $current_cat currently selected category
2054
+	 * @return string               html for dropdown
2055
+	 * @throws EE_Error
2056
+	 * @throws ReflectionException
2057
+	 */
2058
+	public static function generate_event_category_dropdown($current_cat = -1)
2059
+	{
2060
+		$categories = EEM_Term::instance()->get_all_ee_categories(true);
2061
+		$options    = [
2062
+			'0' => [
2063
+				'text' => esc_html__('All Categories', 'event_espresso'),
2064
+				'id'   => -1,
2065
+			],
2066
+		];
2067
+
2068
+		// setup categories for dropdown
2069
+		foreach ($categories as $category) {
2070
+			$options[] = [
2071
+				'text' => $category->get('name'),
2072
+				'id'   => $category->ID(),
2073
+			];
2074
+		}
2075
+
2076
+		return self::select_input('EVT_CAT', $options, $current_cat);
2077
+	}
2078
+
2079
+
2080
+	/**
2081
+	 *    generate a submit button with or without it's own microform
2082
+	 *    this is the only way to create buttons that are compatible across all themes
2083
+	 *
2084
+	 * @access    public
2085
+	 * @param string      $url              - the form action
2086
+	 * @param string      $ID               - some kind of unique ID, appended with "-sbmt" for the input and "-frm"
2087
+	 *                                      for the form
2088
+	 * @param string      $class            - css classes (separated by spaces if more than one)
2089
+	 * @param string      $text             - what appears on the button
2090
+	 * @param string      $nonce_action     - if using nonces
2091
+	 * @param bool|string $input_only       - whether to print form header and footer. TRUE returns the input without
2092
+	 *                                      the form
2093
+	 * @param string      $extra_attributes - any extra attributes that need to be attached to the form input
2094
+	 * @return    string
2095
+	 */
2096
+	public static function submit_button(
2097
+		$url = '',
2098
+		$ID = '',
2099
+		$class = '',
2100
+		$text = '',
2101
+		$nonce_action = '',
2102
+		$input_only = false,
2103
+		$extra_attributes = ''
2104
+	) {
2105
+		$btn = '';
2106
+		if (empty($url) || empty($ID)) {
2107
+			return $btn;
2108
+		}
2109
+		$text = ! empty($text) ? $text : esc_html__('Submit', 'event_espresso');
2110
+		$btn  .= '<input id="' . $ID . '-btn" class="' . $class . '" '
2111
+				 . 'type="submit" value="' . $text . '" ' . $extra_attributes . '/>';
2112
+		if (! $input_only) {
2113
+			$btn_frm = '<form id="' . $ID . '-frm" method="POST" action="' . $url . '">';
2114
+			$btn_frm .= ! empty($nonce_action)
2115
+				? wp_nonce_field($nonce_action, $nonce_action . '_nonce', true, false)
2116
+				: '';
2117
+			$btn_frm .= $btn;
2118
+			$btn_frm .= '</form>';
2119
+			$btn     = $btn_frm;
2120
+			unset($btn_frm);
2121
+		}
2122
+		return $btn;
2123
+	}
2124 2124
 }
Please login to merge, or discard this patch.
core/helpers/EEH_Template.helper.php 2 patches
Indentation   +917 added lines, -917 removed lines patch added patch discarded remove patch
@@ -7,36 +7,36 @@  discard block
 block discarded – undo
7 7
 use EventEspresso\core\services\request\sanitizers\AllowedTags;
8 8
 
9 9
 if (! function_exists('espresso_get_template_part')) {
10
-    /**
11
-     * espresso_get_template_part
12
-     * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files
13
-     * so not a very useful function at all except that it adds familiarity PLUS filtering based off of the entire template part name
14
-     *
15
-     * @param string $slug The slug name for the generic template.
16
-     * @param string $name The name of the specialised template.
17
-     */
18
-    function espresso_get_template_part($slug = null, $name = null)
19
-    {
20
-        EEH_Template::get_template_part($slug, $name);
21
-    }
10
+	/**
11
+	 * espresso_get_template_part
12
+	 * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files
13
+	 * so not a very useful function at all except that it adds familiarity PLUS filtering based off of the entire template part name
14
+	 *
15
+	 * @param string $slug The slug name for the generic template.
16
+	 * @param string $name The name of the specialised template.
17
+	 */
18
+	function espresso_get_template_part($slug = null, $name = null)
19
+	{
20
+		EEH_Template::get_template_part($slug, $name);
21
+	}
22 22
 }
23 23
 
24 24
 
25 25
 if (! function_exists('espresso_get_object_css_class')) {
26
-    /**
27
-     * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed
28
-     *
29
-     * @param EE_Base_Class $object the EE object the css class is being generated for
30
-     * @param string        $prefix added to the beginning of the generated class
31
-     * @param string        $suffix added to the end of the generated class
32
-     * @return string
33
-     * @throws EE_Error
34
-     * @throws ReflectionException
35
-     */
36
-    function espresso_get_object_css_class($object = null, $prefix = '', $suffix = '')
37
-    {
38
-        return EEH_Template::get_object_css_class($object, $prefix, $suffix);
39
-    }
26
+	/**
27
+	 * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed
28
+	 *
29
+	 * @param EE_Base_Class $object the EE object the css class is being generated for
30
+	 * @param string        $prefix added to the beginning of the generated class
31
+	 * @param string        $suffix added to the end of the generated class
32
+	 * @return string
33
+	 * @throws EE_Error
34
+	 * @throws ReflectionException
35
+	 */
36
+	function espresso_get_object_css_class($object = null, $prefix = '', $suffix = '')
37
+	{
38
+		return EEH_Template::get_object_css_class($object, $prefix, $suffix);
39
+	}
40 40
 }
41 41
 
42 42
 
@@ -50,640 +50,640 @@  discard block
 block discarded – undo
50 50
  */
51 51
 class EEH_Template
52 52
 {
53
-    private static $_espresso_themes = [];
54
-
55
-
56
-    /**
57
-     *    is_espresso_theme - returns TRUE or FALSE on whether the currently active WP theme is an espresso theme
58
-     *
59
-     * @return boolean
60
-     */
61
-    public static function is_espresso_theme()
62
-    {
63
-        return wp_get_theme()->get('TextDomain') === 'event_espresso';
64
-    }
65
-
66
-
67
-    /**
68
-     *    load_espresso_theme_functions - if current theme is an espresso theme, or uses ee theme template parts, then
69
-     *    load its functions.php file ( if not already loaded )
70
-     *
71
-     * @return void
72
-     */
73
-    public static function load_espresso_theme_functions()
74
-    {
75
-        if (! defined('EE_THEME_FUNCTIONS_LOADED')) {
76
-            if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php')) {
77
-                require_once(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php');
78
-            }
79
-        }
80
-    }
81
-
82
-
83
-    /**
84
-     *    get_espresso_themes - returns an array of Espresso Child themes located in the /templates/ directory
85
-     *
86
-     * @return array
87
-     */
88
-    public static function get_espresso_themes()
89
-    {
90
-        if (empty(EEH_Template::$_espresso_themes)) {
91
-            $espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR);
92
-            if (empty($espresso_themes)) {
93
-                return [];
94
-            }
95
-            if (($key = array_search('global_assets', $espresso_themes)) !== false) {
96
-                unset($espresso_themes[ $key ]);
97
-            }
98
-            EEH_Template::$_espresso_themes = [];
99
-            foreach ($espresso_themes as $espresso_theme) {
100
-                EEH_Template::$_espresso_themes[ basename($espresso_theme) ] = $espresso_theme;
101
-            }
102
-        }
103
-        return EEH_Template::$_espresso_themes;
104
-    }
105
-
106
-
107
-    /**
108
-     * EEH_Template::get_template_part
109
-     * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead,
110
-     * and doesn't add base versions of files so not a very useful function at all except that it adds familiarity PLUS
111
-     * filtering based off of the entire template part name
112
-     *
113
-     * @param string $slug The slug name for the generic template.
114
-     * @param string $name The name of the specialised template.
115
-     * @param array  $template_args
116
-     * @param bool   $return_string
117
-     * @return string        the html output for the formatted money value
118
-     */
119
-    public static function get_template_part(
120
-        $slug = null,
121
-        $name = null,
122
-        $template_args = [],
123
-        $return_string = false
124
-    ) {
125
-        do_action("get_template_part_{$slug}-{$name}", $slug, $name);
126
-        $templates = [];
127
-        $name      = (string) $name;
128
-        if ($name != '') {
129
-            $templates[] = "{$slug}-{$name}.php";
130
-        }
131
-        // allow template parts to be turned off via something like:
132
-        // add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' );
133
-        if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", true)) {
134
-            return EEH_Template::locate_template($templates, $template_args, true, $return_string);
135
-        }
136
-        return '';
137
-    }
138
-
139
-
140
-    /**
141
-     *    locate_template
142
-     *    locate a template file by looking in the following places, in the following order:
143
-     *        <server path up to>/wp-content/themes/<current active WordPress theme>/
144
-     *        <assumed full absolute server path>
145
-     *        <server path up to>/wp-content/uploads/espresso/templates/<current EE theme>/
146
-     *        <server path up to>/wp-content/uploads/espresso/templates/
147
-     *        <server path up to>/wp-content/plugins/<EE4 folder>/public/<current EE theme>/
148
-     *        <server path up to>/wp-content/plugins/<EE4 folder>/core/templates/<current EE theme>/
149
-     *        <server path up to>/wp-content/plugins/<EE4 folder>/
150
-     *    as soon as the template is found in one of these locations, it will be returned or loaded
151
-     *        Example:
152
-     *          You are using the WordPress Twenty Sixteen theme,
153
-     *        and you want to customize the "some-event.template.php" template,
154
-     *          which is located in the "/relative/path/to/" folder relative to the main EE plugin folder.
155
-     *          Assuming WP is installed on your server in the "/home/public_html/" folder,
156
-     *        EEH_Template::locate_template() will look at the following paths in order until the template is found:
157
-     *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
158
-     *        /relative/path/to/some-event.template.php
159
-     *        /home/public_html/wp-content/uploads/espresso/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
160
-     *        /home/public_html/wp-content/uploads/espresso/templates/relative/path/to/some-event.template.php
161
-     *        /home/public_html/wp-content/plugins/event-espresso-core-reg/public/Espresso_Arabica_2014/relative/path/to/some-event.template.php
162
-     *        /home/public_html/wp-content/plugins/event-espresso-core-reg/core/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
163
-     *        /home/public_html/wp-content/plugins/event-espresso-core-reg/relative/path/to/some-event.template.php
164
-     *          Had you passed an absolute path to your template that was in some other location,
165
-     *        ie: "/absolute/path/to/some-event.template.php"
166
-     *          then the search would have been :
167
-     *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
168
-     *        /absolute/path/to/some-event.template.php
169
-     *          and stopped there upon finding it in the second location
170
-     *
171
-     * @param array|string $templates       array of template file names including extension (or just a single string)
172
-     * @param array        $template_args   an array of arguments to be extracted for use in the template
173
-     * @param boolean      $load            whether to pass the located template path on to the
174
-     *                                      EEH_Template::display_template() method or simply return it
175
-     * @param boolean      $return_string   whether to send output immediately to screen, or capture and return as a
176
-     *                                      string
177
-     * @param boolean      $check_if_custom If TRUE, this flags this method to return boolean for whether this will
178
-     *                                      generate a custom template or not. Used in places where you don't actually
179
-     *                                      load the template, you just want to know if there's a custom version of it.
180
-     * @return mixed
181
-     * @throws DomainException
182
-     * @throws InvalidArgumentException
183
-     * @throws InvalidDataTypeException
184
-     * @throws InvalidInterfaceException
185
-     */
186
-    public static function locate_template(
187
-        $templates = [],
188
-        $template_args = [],
189
-        $load = true,
190
-        $return_string = true,
191
-        $check_if_custom = false
192
-    ) {
193
-        // first use WP locate_template to check for template in the current theme folder
194
-        $template_path = locate_template($templates);
195
-
196
-        if ($check_if_custom && ! empty($template_path)) {
197
-            return true;
198
-        }
199
-
200
-        // not in the theme
201
-        if (empty($template_path)) {
202
-            // not even a template to look for ?
203
-            if (empty($templates)) {
204
-                $loader = LoaderFactory::getLoader();
205
-                /** @var RequestInterface $request */
206
-                $request = $loader->getShared(RequestInterface::class);
207
-                // get post_type
208
-                $post_type = $request->getRequestParam('post_type');
209
-                /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
210
-                $custom_post_types = $loader->getShared(
211
-                    'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
212
-                );
213
-                // get array of EE Custom Post Types
214
-                $EE_CPTs = $custom_post_types->getDefinitions();
215
-                // build template name based on request
216
-                if (isset($EE_CPTs[ $post_type ])) {
217
-                    $archive_or_single = is_archive() ? 'archive' : '';
218
-                    $archive_or_single = is_single() ? 'single' : $archive_or_single;
219
-                    $templates         = $archive_or_single . '-' . $post_type . '.php';
220
-                }
221
-            }
222
-            // currently active EE template theme
223
-            $current_theme = EE_Config::get_current_theme();
224
-
225
-            // array of paths to folders that may contain templates
226
-            $template_folder_paths = [
227
-                // first check the /wp-content/uploads/espresso/templates/(current EE theme)/  folder for an EE theme template file
228
-                EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme,
229
-                // then in the root of the /wp-content/uploads/espresso/templates/ folder
230
-                EVENT_ESPRESSO_TEMPLATE_DIR,
231
-            ];
232
-
233
-            // add core plugin folders for checking only if we're not $check_if_custom
234
-            if (! $check_if_custom) {
235
-                $core_paths            = [
236
-                    // in the  /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin
237
-                    EE_PUBLIC . $current_theme,
238
-                    // in the  /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin
239
-                    EE_TEMPLATES . $current_theme,
240
-                    // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/
241
-                    EE_PLUGIN_DIR_PATH,
242
-                ];
243
-                $template_folder_paths = array_merge($template_folder_paths, $core_paths);
244
-            }
245
-
246
-            // now filter that array
247
-            $template_folder_paths = apply_filters(
248
-                'FHEE__EEH_Template__locate_template__template_folder_paths',
249
-                $template_folder_paths
250
-            );
251
-            $templates             = is_array($templates) ? $templates : [$templates];
252
-            $template_folder_paths =
253
-                is_array($template_folder_paths) ? $template_folder_paths : [$template_folder_paths];
254
-            // array to hold all possible template paths
255
-            $full_template_paths = [];
256
-            $file_name           = '';
257
-
258
-            // loop through $templates
259
-            foreach ($templates as $template) {
260
-                // normalize directory separators
261
-                $template                      = EEH_File::standardise_directory_separators($template);
262
-                $file_name                     = basename($template);
263
-                $template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1));
264
-                // while looping through all template folder paths
265
-                foreach ($template_folder_paths as $template_folder_path) {
266
-                    // normalize directory separators
267
-                    $template_folder_path = EEH_File::standardise_directory_separators($template_folder_path);
268
-                    // determine if any common base path exists between the two paths
269
-                    $common_base_path = EEH_Template::_find_common_base_path(
270
-                        [$template_folder_path, $template_path_minus_file_name]
271
-                    );
272
-                    if ($common_base_path !== '') {
273
-                        // both paths have a common base, so just tack the filename onto our search path
274
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name;
275
-                    } else {
276
-                        // no common base path, so let's just concatenate
277
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template;
278
-                    }
279
-                    // build up our template locations array by adding our resolved paths
280
-                    $full_template_paths[] = $resolved_path;
281
-                }
282
-                // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first
283
-                array_unshift($full_template_paths, $template);
284
-                // path to the directory of the current theme: /wp-content/themes/(current WP theme)/
285
-                array_unshift($full_template_paths, get_stylesheet_directory() . '/' . $file_name);
286
-            }
287
-            // filter final array of full template paths
288
-            $full_template_paths = apply_filters(
289
-                'FHEE__EEH_Template__locate_template__full_template_paths',
290
-                $full_template_paths,
291
-                $file_name
292
-            );
293
-            // now loop through our final array of template location paths and check each location
294
-            foreach ((array) $full_template_paths as $full_template_path) {
295
-                if (is_readable($full_template_path)) {
296
-                    $template_path = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $full_template_path);
297
-                    break;
298
-                }
299
-            }
300
-        }
301
-
302
-        // hook that can be used to display the full template path that will be used
303
-        do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path);
304
-
305
-        // if we got it and you want to see it...
306
-        if ($template_path && $load && ! $check_if_custom) {
307
-            if ($return_string) {
308
-                return EEH_Template::display_template($template_path, $template_args, true);
309
-            }
310
-            EEH_Template::display_template($template_path, $template_args);
311
-        }
312
-        return $check_if_custom && ! empty($template_path) ? true : $template_path;
313
-    }
314
-
315
-
316
-    /**
317
-     * _find_common_base_path
318
-     * given two paths, this determines if there is a common base path between the two
319
-     *
320
-     * @param array $paths
321
-     * @return string
322
-     */
323
-    protected static function _find_common_base_path($paths)
324
-    {
325
-        $last_offset      = 0;
326
-        $common_base_path = '';
327
-        while (($index = strpos($paths[0], '/', $last_offset)) !== false) {
328
-            $dir_length = $index - $last_offset + 1;
329
-            $directory  = substr($paths[0], $last_offset, $dir_length);
330
-            foreach ($paths as $path) {
331
-                if (substr($path, $last_offset, $dir_length) != $directory) {
332
-                    return $common_base_path;
333
-                }
334
-            }
335
-            $common_base_path .= $directory;
336
-            $last_offset      = $index + 1;
337
-        }
338
-        return substr($common_base_path, 0, -1);
339
-    }
340
-
341
-
342
-    /**
343
-     * load and display a template
344
-     *
345
-     * @param bool|string $template_path    server path to the file to be loaded, including file name and extension
346
-     * @param array       $template_args    an array of arguments to be extracted for use in the template
347
-     * @param boolean     $return_string    whether to send output immediately to screen, or capture and return as a
348
-     *                                      string
349
-     * @param bool        $throw_exceptions if set to true, will throw an exception if the template is either
350
-     *                                      not found or is not readable
351
-     * @return string
352
-     * @throws DomainException
353
-     */
354
-    public static function display_template(
355
-        $template_path = false,
356
-        $template_args = [],
357
-        $return_string = false,
358
-        $throw_exceptions = false
359
-    ) {
360
-
361
-        /**
362
-         * These two filters are intended for last minute changes to templates being loaded and/or template arg
363
-         * modifications.  NOTE... modifying these things can cause breakage as most templates running through
364
-         * the display_template method are templates we DON'T want modified (usually because of js
365
-         * dependencies etc).  So unless you know what you are doing, do NOT filter templates or template args
366
-         * using this.
367
-         *
368
-         * @since 4.6.0
369
-         */
370
-        $template_path = (string) apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path);
371
-        $template_args = (array) apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args);
372
-
373
-        // you gimme nuttin - YOU GET NUTTIN !!
374
-        if (! $template_path || ! is_readable($template_path)) {
375
-            // ignore whether template is accessible ?
376
-            if ($throw_exceptions) {
377
-                throw new DomainException(
378
-                    esc_html__('Invalid, unreadable, or missing file.', 'event_espresso')
379
-                );
380
-            }
381
-            return '';
382
-        }
383
-        // if $template_args are not in an array, then make it so
384
-        if (! is_array($template_args) && ! is_object($template_args)) {
385
-            $template_args = [$template_args];
386
-        }
387
-        extract($template_args, EXTR_SKIP);
388
-
389
-        if ($return_string) {
390
-            // because we want to return a string, we are going to capture the output
391
-            ob_start();
392
-            include($template_path);
393
-            return ob_get_clean();
394
-        }
395
-        include($template_path);
396
-        return '';
397
-    }
398
-
399
-
400
-    /**
401
-     * get_object_css_class - attempts to generate a css class based on the type of EE object passed
402
-     *
403
-     * @param EE_Base_Class $object the EE object the css class is being generated for
404
-     * @param string        $prefix added to the beginning of the generated class
405
-     * @param string        $suffix added to the end of the generated class
406
-     * @return string
407
-     * @throws EE_Error
408
-     * @throws ReflectionException
409
-     */
410
-    public static function get_object_css_class($object = null, $prefix = '', $suffix = '')
411
-    {
412
-        // in the beginning...
413
-        $prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : '';
414
-        // da muddle
415
-        $class = '';
416
-        // the end
417
-        $suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : '';
418
-        // is the passed object an EE object ?
419
-        if ($object instanceof EE_Base_Class) {
420
-            // grab the exact type of object
421
-            $obj_class = get_class($object);
422
-            // depending on the type of object...
423
-            switch ($obj_class) {
424
-                // no specifics just yet...
425
-                default:
426
-                    $class = strtolower(str_replace('_', '-', $obj_class));
427
-                    $class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : '';
428
-            }
429
-        }
430
-        return $prefix . $class . $suffix;
431
-    }
432
-
433
-
434
-    /**
435
-     * EEH_Template::format_currency
436
-     * This helper takes a raw float value and formats it according to the default config country currency settings, or
437
-     * the country currency settings from the supplied country ISO code
438
-     *
439
-     * @param float   $amount       raw money value
440
-     * @param boolean $return_raw   whether to return the formatted float value only with no currency sign or code
441
-     * @param boolean $display_code whether to display the country code (USD). Default = TRUE
442
-     * @param string  $CNT_ISO      2 letter ISO code for a country
443
-     * @param string  $cur_code_span_class
444
-     * @return string        the html output for the formatted money value
445
-     */
446
-    public static function format_currency(
447
-        $amount = null,
448
-        $return_raw = false,
449
-        $display_code = true,
450
-        $CNT_ISO = '',
451
-        $cur_code_span_class = 'currency-code'
452
-    ) {
453
-        // ensure amount was received
454
-        if ($amount === null) {
455
-            $msg = esc_html__('In order to format currency, an amount needs to be passed.', 'event_espresso');
456
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
457
-            return '';
458
-        }
459
-        // ensure amount is float
460
-        $amount  = (float) apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float) $amount);
461
-        $CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount);
462
-        // filter raw amount (allows 0.00 to be changed to "free" for example)
463
-        $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw);
464
-        // still a number, or was amount converted to a string like "free" ?
465
-        if (! is_float($amount_formatted)) {
466
-            return esc_html($amount_formatted);
467
-        }
468
-        try {
469
-            // was a country ISO code passed ? if so generate currency config object for that country
470
-            $mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null;
471
-        } catch (Exception $e) {
472
-            // eat exception
473
-            $mny = null;
474
-        }
475
-        // verify results
476
-        if (! $mny instanceof EE_Currency_Config) {
477
-            // set default config country currency settings
478
-            $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config
479
-                ? EE_Registry::instance()->CFG->currency
480
-                : new EE_Currency_Config();
481
-        }
482
-        // format float
483
-        $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds);
484
-        // add formatting ?
485
-        if (! $return_raw) {
486
-            // add currency sign
487
-            if ($mny->sign_b4) {
488
-                if ($amount >= 0) {
489
-                    $amount_formatted = $mny->sign . $amount_formatted;
490
-                } else {
491
-                    $amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted);
492
-                }
493
-            } else {
494
-                $amount_formatted = $amount_formatted . $mny->sign;
495
-            }
496
-
497
-            // filter to allow global setting of display_code
498
-            $display_code = (bool) apply_filters(
499
-                'FHEE__EEH_Template__format_currency__display_code',
500
-                $display_code
501
-            );
502
-
503
-            // add currency code ?
504
-            $amount_formatted = $display_code
505
-                ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>'
506
-                : $amount_formatted;
507
-        }
508
-        // filter results
509
-        $amount_formatted = apply_filters(
510
-            'FHEE__EEH_Template__format_currency__amount_formatted',
511
-            $amount_formatted,
512
-            $mny,
513
-            $return_raw
514
-        );
515
-        // clean up vars
516
-        unset($mny);
517
-        // return formatted currency amount
518
-        return $amount_formatted;
519
-    }
520
-
521
-
522
-    /**
523
-     * This function is used for outputting the localized label for a given status id in the schema requested (and
524
-     * possibly plural).  The intended use of this function is only for cases where wanting a label outside of a
525
-     * related status model or model object (i.e. in documentation etc.)
526
-     *
527
-     * @param string  $status_id  Status ID matching a registered status in the esp_status table.  If there is no
528
-     *                            match, then 'Unknown' will be returned.
529
-     * @param boolean $plural     Whether to return plural or not
530
-     * @param string  $schema     'UPPER', 'lower', or 'Sentence'
531
-     * @return string             The localized label for the status id.
532
-     * @throws EE_Error
533
-     */
534
-    public static function pretty_status($status_id, $plural = false, $schema = 'upper')
535
-    {
536
-        $status = EEM_Status::instance()->localized_status(
537
-            [$status_id => esc_html__('unknown', 'event_espresso')],
538
-            $plural,
539
-            $schema
540
-        );
541
-        return $status[ $status_id ];
542
-    }
543
-
544
-
545
-    /**
546
-     * This helper just returns a button or link for the given parameters
547
-     *
548
-     * @param string $url   the url for the link, note that `esc_url` will be called on it
549
-     * @param string $label What is the label you want displayed for the button
550
-     * @param string $class what class is used for the button (defaults to 'button--primary')
551
-     * @param string $icon
552
-     * @param string $title
553
-     * @return string the html output for the button
554
-     */
555
-    public static function get_button_or_link($url, $label, $class = 'button button--primary', $icon = '', $title = '')
556
-    {
557
-        $icon_html = '';
558
-        if (! empty($icon)) {
559
-            $dashicons = preg_split("(ee-icon |dashicons )", $icon);
560
-            $dashicons = array_filter($dashicons);
561
-            $count     = count($dashicons);
562
-            $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : '';
563
-            foreach ($dashicons as $dashicon) {
564
-                $type      = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons ';
565
-                $icon_html .= '<span class="' . $type . $dashicon . '"></span>';
566
-            }
567
-            $icon_html .= $count > 1 ? '</span>' : '';
568
-        }
569
-        // sanitize & escape
570
-        $id    = sanitize_title_with_dashes($label);
571
-        $url   = esc_url_raw($url);
572
-        $class = esc_attr($class);
573
-        $title = esc_attr($title);
574
-        $class .= $title ? ' ee-aria-tooltip' : '';
575
-        $title = $title ? " aria-label='{$title}'" : '';
576
-        $label = esc_html($label);
577
-        return "<a id='{$id}' href='{$url}' class='{$class}'{$title}>{$icon_html}{$label}</a>";
578
-    }
579
-
580
-
581
-    /**
582
-     * This returns a generated link that will load the related help tab on admin pages.
583
-     *
584
-     * @param string      $help_tab_id the id for the connected help tab
585
-     * @param bool|string $page        The page identifier for the page the help tab is on
586
-     * @param bool|string $action      The action (route) for the admin page the help tab is on.
587
-     * @param bool|string $icon_style  (optional) include css class for the style you want to use for the help icon.
588
-     * @param bool|string $help_text   (optional) send help text you want to use for the link if default not to be used
589
-     * @return string              generated link
590
-     */
591
-    public static function get_help_tab_link(
592
-        $help_tab_id,
593
-        $page = false,
594
-        $action = false,
595
-        $icon_style = false,
596
-        $help_text = false
597
-    ) {
598
-        $allowedtags = AllowedTags::getAllowedTags();
599
-        /** @var RequestInterface $request */
600
-        $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
601
-        $page    = $page ?: $request->getRequestParam('page', '', 'key');
602
-        $action  = $action ?: $request->getRequestParam('action', 'default', 'key');
603
-
604
-
605
-        $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id;
606
-        $icon      = ! $icon_style ? 'dashicons-editor-help' : $icon_style;
607
-        $help_text = ! $help_text ? '' : $help_text;
608
-        return '
53
+	private static $_espresso_themes = [];
54
+
55
+
56
+	/**
57
+	 *    is_espresso_theme - returns TRUE or FALSE on whether the currently active WP theme is an espresso theme
58
+	 *
59
+	 * @return boolean
60
+	 */
61
+	public static function is_espresso_theme()
62
+	{
63
+		return wp_get_theme()->get('TextDomain') === 'event_espresso';
64
+	}
65
+
66
+
67
+	/**
68
+	 *    load_espresso_theme_functions - if current theme is an espresso theme, or uses ee theme template parts, then
69
+	 *    load its functions.php file ( if not already loaded )
70
+	 *
71
+	 * @return void
72
+	 */
73
+	public static function load_espresso_theme_functions()
74
+	{
75
+		if (! defined('EE_THEME_FUNCTIONS_LOADED')) {
76
+			if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php')) {
77
+				require_once(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php');
78
+			}
79
+		}
80
+	}
81
+
82
+
83
+	/**
84
+	 *    get_espresso_themes - returns an array of Espresso Child themes located in the /templates/ directory
85
+	 *
86
+	 * @return array
87
+	 */
88
+	public static function get_espresso_themes()
89
+	{
90
+		if (empty(EEH_Template::$_espresso_themes)) {
91
+			$espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR);
92
+			if (empty($espresso_themes)) {
93
+				return [];
94
+			}
95
+			if (($key = array_search('global_assets', $espresso_themes)) !== false) {
96
+				unset($espresso_themes[ $key ]);
97
+			}
98
+			EEH_Template::$_espresso_themes = [];
99
+			foreach ($espresso_themes as $espresso_theme) {
100
+				EEH_Template::$_espresso_themes[ basename($espresso_theme) ] = $espresso_theme;
101
+			}
102
+		}
103
+		return EEH_Template::$_espresso_themes;
104
+	}
105
+
106
+
107
+	/**
108
+	 * EEH_Template::get_template_part
109
+	 * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead,
110
+	 * and doesn't add base versions of files so not a very useful function at all except that it adds familiarity PLUS
111
+	 * filtering based off of the entire template part name
112
+	 *
113
+	 * @param string $slug The slug name for the generic template.
114
+	 * @param string $name The name of the specialised template.
115
+	 * @param array  $template_args
116
+	 * @param bool   $return_string
117
+	 * @return string        the html output for the formatted money value
118
+	 */
119
+	public static function get_template_part(
120
+		$slug = null,
121
+		$name = null,
122
+		$template_args = [],
123
+		$return_string = false
124
+	) {
125
+		do_action("get_template_part_{$slug}-{$name}", $slug, $name);
126
+		$templates = [];
127
+		$name      = (string) $name;
128
+		if ($name != '') {
129
+			$templates[] = "{$slug}-{$name}.php";
130
+		}
131
+		// allow template parts to be turned off via something like:
132
+		// add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' );
133
+		if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", true)) {
134
+			return EEH_Template::locate_template($templates, $template_args, true, $return_string);
135
+		}
136
+		return '';
137
+	}
138
+
139
+
140
+	/**
141
+	 *    locate_template
142
+	 *    locate a template file by looking in the following places, in the following order:
143
+	 *        <server path up to>/wp-content/themes/<current active WordPress theme>/
144
+	 *        <assumed full absolute server path>
145
+	 *        <server path up to>/wp-content/uploads/espresso/templates/<current EE theme>/
146
+	 *        <server path up to>/wp-content/uploads/espresso/templates/
147
+	 *        <server path up to>/wp-content/plugins/<EE4 folder>/public/<current EE theme>/
148
+	 *        <server path up to>/wp-content/plugins/<EE4 folder>/core/templates/<current EE theme>/
149
+	 *        <server path up to>/wp-content/plugins/<EE4 folder>/
150
+	 *    as soon as the template is found in one of these locations, it will be returned or loaded
151
+	 *        Example:
152
+	 *          You are using the WordPress Twenty Sixteen theme,
153
+	 *        and you want to customize the "some-event.template.php" template,
154
+	 *          which is located in the "/relative/path/to/" folder relative to the main EE plugin folder.
155
+	 *          Assuming WP is installed on your server in the "/home/public_html/" folder,
156
+	 *        EEH_Template::locate_template() will look at the following paths in order until the template is found:
157
+	 *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
158
+	 *        /relative/path/to/some-event.template.php
159
+	 *        /home/public_html/wp-content/uploads/espresso/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
160
+	 *        /home/public_html/wp-content/uploads/espresso/templates/relative/path/to/some-event.template.php
161
+	 *        /home/public_html/wp-content/plugins/event-espresso-core-reg/public/Espresso_Arabica_2014/relative/path/to/some-event.template.php
162
+	 *        /home/public_html/wp-content/plugins/event-espresso-core-reg/core/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
163
+	 *        /home/public_html/wp-content/plugins/event-espresso-core-reg/relative/path/to/some-event.template.php
164
+	 *          Had you passed an absolute path to your template that was in some other location,
165
+	 *        ie: "/absolute/path/to/some-event.template.php"
166
+	 *          then the search would have been :
167
+	 *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
168
+	 *        /absolute/path/to/some-event.template.php
169
+	 *          and stopped there upon finding it in the second location
170
+	 *
171
+	 * @param array|string $templates       array of template file names including extension (or just a single string)
172
+	 * @param array        $template_args   an array of arguments to be extracted for use in the template
173
+	 * @param boolean      $load            whether to pass the located template path on to the
174
+	 *                                      EEH_Template::display_template() method or simply return it
175
+	 * @param boolean      $return_string   whether to send output immediately to screen, or capture and return as a
176
+	 *                                      string
177
+	 * @param boolean      $check_if_custom If TRUE, this flags this method to return boolean for whether this will
178
+	 *                                      generate a custom template or not. Used in places where you don't actually
179
+	 *                                      load the template, you just want to know if there's a custom version of it.
180
+	 * @return mixed
181
+	 * @throws DomainException
182
+	 * @throws InvalidArgumentException
183
+	 * @throws InvalidDataTypeException
184
+	 * @throws InvalidInterfaceException
185
+	 */
186
+	public static function locate_template(
187
+		$templates = [],
188
+		$template_args = [],
189
+		$load = true,
190
+		$return_string = true,
191
+		$check_if_custom = false
192
+	) {
193
+		// first use WP locate_template to check for template in the current theme folder
194
+		$template_path = locate_template($templates);
195
+
196
+		if ($check_if_custom && ! empty($template_path)) {
197
+			return true;
198
+		}
199
+
200
+		// not in the theme
201
+		if (empty($template_path)) {
202
+			// not even a template to look for ?
203
+			if (empty($templates)) {
204
+				$loader = LoaderFactory::getLoader();
205
+				/** @var RequestInterface $request */
206
+				$request = $loader->getShared(RequestInterface::class);
207
+				// get post_type
208
+				$post_type = $request->getRequestParam('post_type');
209
+				/** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
210
+				$custom_post_types = $loader->getShared(
211
+					'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
212
+				);
213
+				// get array of EE Custom Post Types
214
+				$EE_CPTs = $custom_post_types->getDefinitions();
215
+				// build template name based on request
216
+				if (isset($EE_CPTs[ $post_type ])) {
217
+					$archive_or_single = is_archive() ? 'archive' : '';
218
+					$archive_or_single = is_single() ? 'single' : $archive_or_single;
219
+					$templates         = $archive_or_single . '-' . $post_type . '.php';
220
+				}
221
+			}
222
+			// currently active EE template theme
223
+			$current_theme = EE_Config::get_current_theme();
224
+
225
+			// array of paths to folders that may contain templates
226
+			$template_folder_paths = [
227
+				// first check the /wp-content/uploads/espresso/templates/(current EE theme)/  folder for an EE theme template file
228
+				EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme,
229
+				// then in the root of the /wp-content/uploads/espresso/templates/ folder
230
+				EVENT_ESPRESSO_TEMPLATE_DIR,
231
+			];
232
+
233
+			// add core plugin folders for checking only if we're not $check_if_custom
234
+			if (! $check_if_custom) {
235
+				$core_paths            = [
236
+					// in the  /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin
237
+					EE_PUBLIC . $current_theme,
238
+					// in the  /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin
239
+					EE_TEMPLATES . $current_theme,
240
+					// or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/
241
+					EE_PLUGIN_DIR_PATH,
242
+				];
243
+				$template_folder_paths = array_merge($template_folder_paths, $core_paths);
244
+			}
245
+
246
+			// now filter that array
247
+			$template_folder_paths = apply_filters(
248
+				'FHEE__EEH_Template__locate_template__template_folder_paths',
249
+				$template_folder_paths
250
+			);
251
+			$templates             = is_array($templates) ? $templates : [$templates];
252
+			$template_folder_paths =
253
+				is_array($template_folder_paths) ? $template_folder_paths : [$template_folder_paths];
254
+			// array to hold all possible template paths
255
+			$full_template_paths = [];
256
+			$file_name           = '';
257
+
258
+			// loop through $templates
259
+			foreach ($templates as $template) {
260
+				// normalize directory separators
261
+				$template                      = EEH_File::standardise_directory_separators($template);
262
+				$file_name                     = basename($template);
263
+				$template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1));
264
+				// while looping through all template folder paths
265
+				foreach ($template_folder_paths as $template_folder_path) {
266
+					// normalize directory separators
267
+					$template_folder_path = EEH_File::standardise_directory_separators($template_folder_path);
268
+					// determine if any common base path exists between the two paths
269
+					$common_base_path = EEH_Template::_find_common_base_path(
270
+						[$template_folder_path, $template_path_minus_file_name]
271
+					);
272
+					if ($common_base_path !== '') {
273
+						// both paths have a common base, so just tack the filename onto our search path
274
+						$resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name;
275
+					} else {
276
+						// no common base path, so let's just concatenate
277
+						$resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template;
278
+					}
279
+					// build up our template locations array by adding our resolved paths
280
+					$full_template_paths[] = $resolved_path;
281
+				}
282
+				// if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first
283
+				array_unshift($full_template_paths, $template);
284
+				// path to the directory of the current theme: /wp-content/themes/(current WP theme)/
285
+				array_unshift($full_template_paths, get_stylesheet_directory() . '/' . $file_name);
286
+			}
287
+			// filter final array of full template paths
288
+			$full_template_paths = apply_filters(
289
+				'FHEE__EEH_Template__locate_template__full_template_paths',
290
+				$full_template_paths,
291
+				$file_name
292
+			);
293
+			// now loop through our final array of template location paths and check each location
294
+			foreach ((array) $full_template_paths as $full_template_path) {
295
+				if (is_readable($full_template_path)) {
296
+					$template_path = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $full_template_path);
297
+					break;
298
+				}
299
+			}
300
+		}
301
+
302
+		// hook that can be used to display the full template path that will be used
303
+		do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path);
304
+
305
+		// if we got it and you want to see it...
306
+		if ($template_path && $load && ! $check_if_custom) {
307
+			if ($return_string) {
308
+				return EEH_Template::display_template($template_path, $template_args, true);
309
+			}
310
+			EEH_Template::display_template($template_path, $template_args);
311
+		}
312
+		return $check_if_custom && ! empty($template_path) ? true : $template_path;
313
+	}
314
+
315
+
316
+	/**
317
+	 * _find_common_base_path
318
+	 * given two paths, this determines if there is a common base path between the two
319
+	 *
320
+	 * @param array $paths
321
+	 * @return string
322
+	 */
323
+	protected static function _find_common_base_path($paths)
324
+	{
325
+		$last_offset      = 0;
326
+		$common_base_path = '';
327
+		while (($index = strpos($paths[0], '/', $last_offset)) !== false) {
328
+			$dir_length = $index - $last_offset + 1;
329
+			$directory  = substr($paths[0], $last_offset, $dir_length);
330
+			foreach ($paths as $path) {
331
+				if (substr($path, $last_offset, $dir_length) != $directory) {
332
+					return $common_base_path;
333
+				}
334
+			}
335
+			$common_base_path .= $directory;
336
+			$last_offset      = $index + 1;
337
+		}
338
+		return substr($common_base_path, 0, -1);
339
+	}
340
+
341
+
342
+	/**
343
+	 * load and display a template
344
+	 *
345
+	 * @param bool|string $template_path    server path to the file to be loaded, including file name and extension
346
+	 * @param array       $template_args    an array of arguments to be extracted for use in the template
347
+	 * @param boolean     $return_string    whether to send output immediately to screen, or capture and return as a
348
+	 *                                      string
349
+	 * @param bool        $throw_exceptions if set to true, will throw an exception if the template is either
350
+	 *                                      not found or is not readable
351
+	 * @return string
352
+	 * @throws DomainException
353
+	 */
354
+	public static function display_template(
355
+		$template_path = false,
356
+		$template_args = [],
357
+		$return_string = false,
358
+		$throw_exceptions = false
359
+	) {
360
+
361
+		/**
362
+		 * These two filters are intended for last minute changes to templates being loaded and/or template arg
363
+		 * modifications.  NOTE... modifying these things can cause breakage as most templates running through
364
+		 * the display_template method are templates we DON'T want modified (usually because of js
365
+		 * dependencies etc).  So unless you know what you are doing, do NOT filter templates or template args
366
+		 * using this.
367
+		 *
368
+		 * @since 4.6.0
369
+		 */
370
+		$template_path = (string) apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path);
371
+		$template_args = (array) apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args);
372
+
373
+		// you gimme nuttin - YOU GET NUTTIN !!
374
+		if (! $template_path || ! is_readable($template_path)) {
375
+			// ignore whether template is accessible ?
376
+			if ($throw_exceptions) {
377
+				throw new DomainException(
378
+					esc_html__('Invalid, unreadable, or missing file.', 'event_espresso')
379
+				);
380
+			}
381
+			return '';
382
+		}
383
+		// if $template_args are not in an array, then make it so
384
+		if (! is_array($template_args) && ! is_object($template_args)) {
385
+			$template_args = [$template_args];
386
+		}
387
+		extract($template_args, EXTR_SKIP);
388
+
389
+		if ($return_string) {
390
+			// because we want to return a string, we are going to capture the output
391
+			ob_start();
392
+			include($template_path);
393
+			return ob_get_clean();
394
+		}
395
+		include($template_path);
396
+		return '';
397
+	}
398
+
399
+
400
+	/**
401
+	 * get_object_css_class - attempts to generate a css class based on the type of EE object passed
402
+	 *
403
+	 * @param EE_Base_Class $object the EE object the css class is being generated for
404
+	 * @param string        $prefix added to the beginning of the generated class
405
+	 * @param string        $suffix added to the end of the generated class
406
+	 * @return string
407
+	 * @throws EE_Error
408
+	 * @throws ReflectionException
409
+	 */
410
+	public static function get_object_css_class($object = null, $prefix = '', $suffix = '')
411
+	{
412
+		// in the beginning...
413
+		$prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : '';
414
+		// da muddle
415
+		$class = '';
416
+		// the end
417
+		$suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : '';
418
+		// is the passed object an EE object ?
419
+		if ($object instanceof EE_Base_Class) {
420
+			// grab the exact type of object
421
+			$obj_class = get_class($object);
422
+			// depending on the type of object...
423
+			switch ($obj_class) {
424
+				// no specifics just yet...
425
+				default:
426
+					$class = strtolower(str_replace('_', '-', $obj_class));
427
+					$class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : '';
428
+			}
429
+		}
430
+		return $prefix . $class . $suffix;
431
+	}
432
+
433
+
434
+	/**
435
+	 * EEH_Template::format_currency
436
+	 * This helper takes a raw float value and formats it according to the default config country currency settings, or
437
+	 * the country currency settings from the supplied country ISO code
438
+	 *
439
+	 * @param float   $amount       raw money value
440
+	 * @param boolean $return_raw   whether to return the formatted float value only with no currency sign or code
441
+	 * @param boolean $display_code whether to display the country code (USD). Default = TRUE
442
+	 * @param string  $CNT_ISO      2 letter ISO code for a country
443
+	 * @param string  $cur_code_span_class
444
+	 * @return string        the html output for the formatted money value
445
+	 */
446
+	public static function format_currency(
447
+		$amount = null,
448
+		$return_raw = false,
449
+		$display_code = true,
450
+		$CNT_ISO = '',
451
+		$cur_code_span_class = 'currency-code'
452
+	) {
453
+		// ensure amount was received
454
+		if ($amount === null) {
455
+			$msg = esc_html__('In order to format currency, an amount needs to be passed.', 'event_espresso');
456
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
457
+			return '';
458
+		}
459
+		// ensure amount is float
460
+		$amount  = (float) apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float) $amount);
461
+		$CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount);
462
+		// filter raw amount (allows 0.00 to be changed to "free" for example)
463
+		$amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw);
464
+		// still a number, or was amount converted to a string like "free" ?
465
+		if (! is_float($amount_formatted)) {
466
+			return esc_html($amount_formatted);
467
+		}
468
+		try {
469
+			// was a country ISO code passed ? if so generate currency config object for that country
470
+			$mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null;
471
+		} catch (Exception $e) {
472
+			// eat exception
473
+			$mny = null;
474
+		}
475
+		// verify results
476
+		if (! $mny instanceof EE_Currency_Config) {
477
+			// set default config country currency settings
478
+			$mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config
479
+				? EE_Registry::instance()->CFG->currency
480
+				: new EE_Currency_Config();
481
+		}
482
+		// format float
483
+		$amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds);
484
+		// add formatting ?
485
+		if (! $return_raw) {
486
+			// add currency sign
487
+			if ($mny->sign_b4) {
488
+				if ($amount >= 0) {
489
+					$amount_formatted = $mny->sign . $amount_formatted;
490
+				} else {
491
+					$amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted);
492
+				}
493
+			} else {
494
+				$amount_formatted = $amount_formatted . $mny->sign;
495
+			}
496
+
497
+			// filter to allow global setting of display_code
498
+			$display_code = (bool) apply_filters(
499
+				'FHEE__EEH_Template__format_currency__display_code',
500
+				$display_code
501
+			);
502
+
503
+			// add currency code ?
504
+			$amount_formatted = $display_code
505
+				? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>'
506
+				: $amount_formatted;
507
+		}
508
+		// filter results
509
+		$amount_formatted = apply_filters(
510
+			'FHEE__EEH_Template__format_currency__amount_formatted',
511
+			$amount_formatted,
512
+			$mny,
513
+			$return_raw
514
+		);
515
+		// clean up vars
516
+		unset($mny);
517
+		// return formatted currency amount
518
+		return $amount_formatted;
519
+	}
520
+
521
+
522
+	/**
523
+	 * This function is used for outputting the localized label for a given status id in the schema requested (and
524
+	 * possibly plural).  The intended use of this function is only for cases where wanting a label outside of a
525
+	 * related status model or model object (i.e. in documentation etc.)
526
+	 *
527
+	 * @param string  $status_id  Status ID matching a registered status in the esp_status table.  If there is no
528
+	 *                            match, then 'Unknown' will be returned.
529
+	 * @param boolean $plural     Whether to return plural or not
530
+	 * @param string  $schema     'UPPER', 'lower', or 'Sentence'
531
+	 * @return string             The localized label for the status id.
532
+	 * @throws EE_Error
533
+	 */
534
+	public static function pretty_status($status_id, $plural = false, $schema = 'upper')
535
+	{
536
+		$status = EEM_Status::instance()->localized_status(
537
+			[$status_id => esc_html__('unknown', 'event_espresso')],
538
+			$plural,
539
+			$schema
540
+		);
541
+		return $status[ $status_id ];
542
+	}
543
+
544
+
545
+	/**
546
+	 * This helper just returns a button or link for the given parameters
547
+	 *
548
+	 * @param string $url   the url for the link, note that `esc_url` will be called on it
549
+	 * @param string $label What is the label you want displayed for the button
550
+	 * @param string $class what class is used for the button (defaults to 'button--primary')
551
+	 * @param string $icon
552
+	 * @param string $title
553
+	 * @return string the html output for the button
554
+	 */
555
+	public static function get_button_or_link($url, $label, $class = 'button button--primary', $icon = '', $title = '')
556
+	{
557
+		$icon_html = '';
558
+		if (! empty($icon)) {
559
+			$dashicons = preg_split("(ee-icon |dashicons )", $icon);
560
+			$dashicons = array_filter($dashicons);
561
+			$count     = count($dashicons);
562
+			$icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : '';
563
+			foreach ($dashicons as $dashicon) {
564
+				$type      = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons ';
565
+				$icon_html .= '<span class="' . $type . $dashicon . '"></span>';
566
+			}
567
+			$icon_html .= $count > 1 ? '</span>' : '';
568
+		}
569
+		// sanitize & escape
570
+		$id    = sanitize_title_with_dashes($label);
571
+		$url   = esc_url_raw($url);
572
+		$class = esc_attr($class);
573
+		$title = esc_attr($title);
574
+		$class .= $title ? ' ee-aria-tooltip' : '';
575
+		$title = $title ? " aria-label='{$title}'" : '';
576
+		$label = esc_html($label);
577
+		return "<a id='{$id}' href='{$url}' class='{$class}'{$title}>{$icon_html}{$label}</a>";
578
+	}
579
+
580
+
581
+	/**
582
+	 * This returns a generated link that will load the related help tab on admin pages.
583
+	 *
584
+	 * @param string      $help_tab_id the id for the connected help tab
585
+	 * @param bool|string $page        The page identifier for the page the help tab is on
586
+	 * @param bool|string $action      The action (route) for the admin page the help tab is on.
587
+	 * @param bool|string $icon_style  (optional) include css class for the style you want to use for the help icon.
588
+	 * @param bool|string $help_text   (optional) send help text you want to use for the link if default not to be used
589
+	 * @return string              generated link
590
+	 */
591
+	public static function get_help_tab_link(
592
+		$help_tab_id,
593
+		$page = false,
594
+		$action = false,
595
+		$icon_style = false,
596
+		$help_text = false
597
+	) {
598
+		$allowedtags = AllowedTags::getAllowedTags();
599
+		/** @var RequestInterface $request */
600
+		$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
601
+		$page    = $page ?: $request->getRequestParam('page', '', 'key');
602
+		$action  = $action ?: $request->getRequestParam('action', 'default', 'key');
603
+
604
+
605
+		$help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id;
606
+		$icon      = ! $icon_style ? 'dashicons-editor-help' : $icon_style;
607
+		$help_text = ! $help_text ? '' : $help_text;
608
+		return '
609 609
         	<a 	id="' . esc_attr($help_tab_lnk) . '" 
610 610
         		class="espresso-help-tab-lnk ee-help-btn ee-aria-tooltip dashicons ' . esc_attr($icon) . '" 
611 611
         		aria-label="' . esc_attr__(
612
-                    'Click to open the \'Help\' tab for more information about this feature.',
613
-                    'event_espresso'
614
-                ) . '" 
612
+					'Click to open the \'Help\' tab for more information about this feature.',
613
+					'event_espresso'
614
+				) . '" 
615 615
 		    >
616 616
 		    	' . wp_kses($help_text, $allowedtags) . '
617 617
 			</a>';
618
-    }
619
-
620
-
621
-    /**
622
-     * This is a helper method to generate a status legend for a given status array.
623
-     * Note this will only work if the incoming statuses have a key in the EEM_Status->localized_status() methods
624
-     * status_array.
625
-     *
626
-     * @param array  $status_array   array of statuses that will make up the legend. In format:
627
-     *                               array(
628
-     *                               'status_item' => 'status_name'
629
-     *                               )
630
-     * @param string $active_status  This is used to indicate what the active status is IF that is to be highlighted in
631
-     *                               the legend.
632
-     * @return string               html structure for status.
633
-     * @throws EE_Error
634
-     */
635
-    public static function status_legend($status_array, $active_status = '')
636
-    {
637
-        if (! is_array($status_array)) {
638
-            throw new EE_Error(
639
-                esc_html__(
640
-                    'The EEH_Template::status_legend helper required the incoming status_array argument to be an array!',
641
-                    'event_espresso'
642
-                )
643
-            );
644
-        }
645
-
646
-        $content = '
618
+	}
619
+
620
+
621
+	/**
622
+	 * This is a helper method to generate a status legend for a given status array.
623
+	 * Note this will only work if the incoming statuses have a key in the EEM_Status->localized_status() methods
624
+	 * status_array.
625
+	 *
626
+	 * @param array  $status_array   array of statuses that will make up the legend. In format:
627
+	 *                               array(
628
+	 *                               'status_item' => 'status_name'
629
+	 *                               )
630
+	 * @param string $active_status  This is used to indicate what the active status is IF that is to be highlighted in
631
+	 *                               the legend.
632
+	 * @return string               html structure for status.
633
+	 * @throws EE_Error
634
+	 */
635
+	public static function status_legend($status_array, $active_status = '')
636
+	{
637
+		if (! is_array($status_array)) {
638
+			throw new EE_Error(
639
+				esc_html__(
640
+					'The EEH_Template::status_legend helper required the incoming status_array argument to be an array!',
641
+					'event_espresso'
642
+				)
643
+			);
644
+		}
645
+
646
+		$content = '
647 647
             <div class="ee-list-table-legend-container">
648 648
                 <h4 class="status-legend-title">
649 649
                     ' . esc_html__('Status Legend', 'event_espresso') . '
650 650
                 </h4>
651 651
                 <dl class="ee-list-table-legend">';
652 652
 
653
-        foreach ($status_array as $item => $status) {
654
-            $active_class = $active_status == $status ? 'class="ee-is-active-status"' : '';
655
-            $content      .= '
653
+		foreach ($status_array as $item => $status) {
654
+			$active_class = $active_status == $status ? 'class="ee-is-active-status"' : '';
655
+			$content      .= '
656 656
                     <dt id="' . esc_attr('ee-legend-item-tooltip-' . $item) . '" ' . $active_class . '>
657 657
                         <span class="' . esc_attr('ee-status-legend ee-status-bg--' . $status) . '"></span>
658 658
                         <span class="ee-legend-description">
659 659
                             ' . EEH_Template::pretty_status($status, false, 'sentence') . '
660 660
                         </span>
661 661
                     </dt>';
662
-        }
662
+		}
663 663
 
664
-        $content .= '
664
+		$content .= '
665 665
                 </dl>
666 666
             </div>
667 667
 ';
668
-        return $content;
669
-    }
670
-
671
-
672
-    /**
673
-     * Gets HTML for laying out a deeply-nested array (and objects) in a format
674
-     * that's nice for presenting in the wp admin
675
-     *
676
-     * @param mixed $data
677
-     * @return string
678
-     */
679
-    public static function layout_array_as_table($data)
680
-    {
681
-        if (is_object($data) || $data instanceof __PHP_Incomplete_Class) {
682
-            $data = (array) $data;
683
-        }
684
-        ob_start();
685
-        if (is_array($data)) {
686
-            if (EEH_Array::is_associative_array($data)) { ?>
668
+		return $content;
669
+	}
670
+
671
+
672
+	/**
673
+	 * Gets HTML for laying out a deeply-nested array (and objects) in a format
674
+	 * that's nice for presenting in the wp admin
675
+	 *
676
+	 * @param mixed $data
677
+	 * @return string
678
+	 */
679
+	public static function layout_array_as_table($data)
680
+	{
681
+		if (is_object($data) || $data instanceof __PHP_Incomplete_Class) {
682
+			$data = (array) $data;
683
+		}
684
+		ob_start();
685
+		if (is_array($data)) {
686
+			if (EEH_Array::is_associative_array($data)) { ?>
687 687
                 <table class="widefat">
688 688
                     <tbody>
689 689
                     <?php foreach ($data as $data_key => $data_values) { ?>
@@ -701,289 +701,289 @@  discard block
 block discarded – undo
701 701
             <?php } else { ?>
702 702
                 <ul>
703 703
                     <?php
704
-                    foreach ($data as $datum) {
705
-                        echo "<li>";
706
-                        echo self::layout_array_as_table($datum);
707
-                        echo "</li>";
708
-                    } ?>
704
+					foreach ($data as $datum) {
705
+						echo "<li>";
706
+						echo self::layout_array_as_table($datum);
707
+						echo "</li>";
708
+					} ?>
709 709
                 </ul>
710 710
             <?php }
711
-        } else {
712
-            // simple value
713
-            echo esc_html($data);
714
-        }
715
-        return ob_get_clean();
716
-    }
717
-
718
-
719
-    /**
720
-     * wrapper for self::get_paging_html() that simply echos the generated paging html
721
-     *
722
-     * @param        $total_items
723
-     * @param        $current
724
-     * @param        $per_page
725
-     * @param        $url
726
-     * @param bool   $show_num_field
727
-     * @param string $paged_arg_name
728
-     * @param array  $items_label
729
-     * @see   self:get_paging_html() for argument docs.
730
-     * @since 4.4.0
731
-     */
732
-    public static function paging_html(
733
-        $total_items,
734
-        $current,
735
-        $per_page,
736
-        $url,
737
-        $show_num_field = true,
738
-        $paged_arg_name = 'paged',
739
-        $items_label = []
740
-    ) {
741
-        echo self::get_paging_html(
742
-            $total_items,
743
-            $current,
744
-            $per_page,
745
-            $url,
746
-            $show_num_field,
747
-            $paged_arg_name,
748
-            $items_label
749
-        );
750
-    }
751
-
752
-
753
-    /**
754
-     * A method for generating paging similar to WP_List_Table
755
-     *
756
-     * @param integer $total_items      How many total items there are to page.
757
-     * @param integer $current          What the current page is.
758
-     * @param integer $per_page         How many items per page.
759
-     * @param string  $url              What the base url for page links is.
760
-     * @param boolean $show_num_field   Whether to show the input for changing page number.
761
-     * @param string  $paged_arg_name   The name of the key for the paged query argument.
762
-     * @param array   $items_label      An array of singular/plural values for the items label:
763
-     *                                  array(
764
-     *                                  'single' => 'item',
765
-     *                                  'plural' => 'items'
766
-     *                                  )
767
-     * @return  string
768
-     * @since    4.4.0
769
-     * @see      wp-admin/includes/class-wp-list-table.php WP_List_Table::pagination()
770
-     */
771
-    public static function get_paging_html(
772
-        $total_items,
773
-        $current,
774
-        $per_page,
775
-        $url,
776
-        $show_num_field = true,
777
-        $paged_arg_name = 'paged',
778
-        $items_label = []
779
-    ) {
780
-        $page_links     = [];
781
-        $disable_first  = $disable_last = '';
782
-        $total_items    = (int) $total_items;
783
-        $per_page       = (int) $per_page;
784
-        $current        = (int) $current;
785
-        $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name);
786
-
787
-        // filter items_label
788
-        $items_label = apply_filters(
789
-            'FHEE__EEH_Template__get_paging_html__items_label',
790
-            $items_label
791
-        );
792
-
793
-        if (
794
-            empty($items_label)
795
-            || ! is_array($items_label)
796
-            || ! isset($items_label['single'])
797
-            || ! isset($items_label['plural'])
798
-        ) {
799
-            $items_label = [
800
-                'single' => esc_html__('1 item', 'event_espresso'),
801
-                'plural' => esc_html__('%s items', 'event_espresso'),
802
-            ];
803
-        } else {
804
-            $items_label = [
805
-                'single' => '1 ' . esc_html($items_label['single']),
806
-                'plural' => '%s ' . esc_html($items_label['plural']),
807
-            ];
808
-        }
809
-
810
-        $total_pages = ceil($total_items / $per_page);
811
-
812
-        if ($total_pages <= 1) {
813
-            return '';
814
-        }
815
-
816
-        $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single'];
817
-
818
-        $output = '<span class="displaying-num">' . $item_label . '</span>';
819
-
820
-        $disable_first = $current === 1 ? 'disabled' : '';
821
-        $disable_last  = $current === $total_pages ? 'disabled' : '';
822
-
823
-        $button_classes = 'button button--secondary button--icon-only button--small';
824
-
825
-        $page_links[] = sprintf(
826
-            '<a class="%s" aria-label="%s" href="%s"><span class="ee-pagination-arrow">%s</span></a>',
827
-            "first-page $button_classes $disable_first",
828
-            esc_attr__('Go to the first page', 'event_espresso'),
829
-            esc_url_raw(remove_query_arg($paged_arg_name, $url)),
830
-            '&laquo;'
831
-        );
832
-
833
-        $page_links[] = sprintf(
834
-            '<a class="%s" aria-label="%s" href="%s"><span class="ee-pagination-arrow">%s</span></a>',
835
-            "prev-page $button_classes $disable_first",
836
-            esc_attr__('Go to the previous page', 'event_espresso'),
837
-            esc_url_raw(add_query_arg($paged_arg_name, max(1, $current - 1), $url)),
838
-            '&lsaquo;'
839
-        );
840
-
841
-        if (! $show_num_field) {
842
-            $html_current_page = $current;
843
-        } else {
844
-            $html_current_page = sprintf(
845
-                "<input class='current-page ee-input-size--small' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />",
846
-                esc_attr__('Current page', 'event_espresso'),
847
-                esc_attr($current),
848
-                strlen($total_pages)
849
-            );
850
-        }
851
-
852
-        $html_total_pages = sprintf(
853
-            '<span class="total-pages">%s</span>',
854
-            number_format_i18n($total_pages)
855
-        );
856
-        $page_links[]     = sprintf(
857
-            _x('%3$s%1$s of %2$s%4$s', 'paging', 'event_espresso'),
858
-            "{$html_current_page}<span class='paging-input-of'>",
859
-            "</span>{$html_total_pages}",
860
-            '<span class="paging-input">',
861
-            '</span>'
862
-        );
863
-
864
-        $page_links[] = sprintf(
865
-            '<a class="%s" aria-label="%s" href="%s"><span class="ee-pagination-arrow">%s</span></a>',
866
-            "next-page $button_classes $disable_last",
867
-            esc_attr__('Go to the next page', 'event_espresso'),
868
-            esc_url_raw(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)),
869
-            '&rsaquo;'
870
-        );
871
-
872
-        $page_links[] = sprintf(
873
-            '<a class="%s" aria-label="%s" href="%s"><span class="ee-pagination-arrow">%s</span></a>',
874
-            "last-page $button_classes $disable_last",
875
-            esc_attr__('Go to the last page', 'event_espresso'),
876
-            esc_url_raw(add_query_arg($paged_arg_name, $total_pages, $url)),
877
-            '&raquo;'
878
-        );
879
-
880
-        $output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>';
881
-
882
-        $page_class = ' no-pages';
883
-        if ($total_pages) {
884
-            $page_class = $total_pages < 2 ? ' one-page' : '';
885
-        }
886
-
887
-        return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>';
888
-    }
889
-
890
-
891
-    /**
892
-     * @param string $wrap_class
893
-     * @param string $wrap_id
894
-     * @return string
895
-     */
896
-    public static function powered_by_event_espresso($wrap_class = '', $wrap_id = '', array $query_args = [])
897
-    {
898
-        $admin = is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX);
899
-        if (
900
-            ! $admin
901
-            && ! apply_filters(
902
-                'FHEE__EEH_Template__powered_by_event_espresso__show_reg_footer',
903
-                EE_Registry::instance()->CFG->admin->show_reg_footer
904
-            )
905
-        ) {
906
-            return '';
907
-        }
908
-        $tag        = $admin ? 'span' : 'div';
909
-        $attributes = ! empty($wrap_id) ? " id=\"{$wrap_id}\"" : '';
910
-        $wrap_class = $admin ? "{$wrap_class} float-left" : $wrap_class;
911
-        $attributes .= ! empty($wrap_class)
912
-            ? " class=\"{$wrap_class} powered-by-event-espresso-credit\""
913
-            : ' class="powered-by-event-espresso-credit"';
914
-        $query_args = array_merge(
915
-            [
916
-                'ap_id'        => EE_Registry::instance()->CFG->admin->affiliate_id(),
917
-                'utm_source'   => 'powered_by_event_espresso',
918
-                'utm_medium'   => 'link',
919
-                'utm_campaign' => 'powered_by',
920
-            ],
921
-            $query_args
922
-        );
923
-        $powered_by = apply_filters(
924
-            'FHEE__EEH_Template__powered_by_event_espresso_text',
925
-            $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso'
926
-        );
927
-        $url        = add_query_arg($query_args, 'https://eventespresso.com/');
928
-        $url        = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url);
929
-        return (string) apply_filters(
930
-            'FHEE__EEH_Template__powered_by_event_espresso__html',
931
-            sprintf(
932
-                esc_html_x(
933
-                    '%3$s%1$sOnline event registration and ticketing powered by %2$s%3$s',
934
-                    'Online event registration and ticketing powered by [link to eventespresso.com]',
935
-                    'event_espresso'
936
-                ),
937
-                "<{$tag}{$attributes}>",
938
-                "<a href=\"{$url}\" target=\"_blank\" rel=\"nofollow\">{$powered_by}</a></{$tag}>",
939
-                $admin ? '' : '<br />'
940
-            ),
941
-            $wrap_class,
942
-            $wrap_id
943
-        );
944
-    }
945
-
946
-
947
-    /**
948
-     * @param string $image_name
949
-     * @return string|null
950
-     * @since   4.10.14.p
951
-     */
952
-    public static function getScreenshotUrl($image_name)
953
-    {
954
-        return esc_url_raw(EE_GLOBAL_ASSETS_URL . 'images/screenshots/' . $image_name . '.jpg');
955
-    }
711
+		} else {
712
+			// simple value
713
+			echo esc_html($data);
714
+		}
715
+		return ob_get_clean();
716
+	}
717
+
718
+
719
+	/**
720
+	 * wrapper for self::get_paging_html() that simply echos the generated paging html
721
+	 *
722
+	 * @param        $total_items
723
+	 * @param        $current
724
+	 * @param        $per_page
725
+	 * @param        $url
726
+	 * @param bool   $show_num_field
727
+	 * @param string $paged_arg_name
728
+	 * @param array  $items_label
729
+	 * @see   self:get_paging_html() for argument docs.
730
+	 * @since 4.4.0
731
+	 */
732
+	public static function paging_html(
733
+		$total_items,
734
+		$current,
735
+		$per_page,
736
+		$url,
737
+		$show_num_field = true,
738
+		$paged_arg_name = 'paged',
739
+		$items_label = []
740
+	) {
741
+		echo self::get_paging_html(
742
+			$total_items,
743
+			$current,
744
+			$per_page,
745
+			$url,
746
+			$show_num_field,
747
+			$paged_arg_name,
748
+			$items_label
749
+		);
750
+	}
751
+
752
+
753
+	/**
754
+	 * A method for generating paging similar to WP_List_Table
755
+	 *
756
+	 * @param integer $total_items      How many total items there are to page.
757
+	 * @param integer $current          What the current page is.
758
+	 * @param integer $per_page         How many items per page.
759
+	 * @param string  $url              What the base url for page links is.
760
+	 * @param boolean $show_num_field   Whether to show the input for changing page number.
761
+	 * @param string  $paged_arg_name   The name of the key for the paged query argument.
762
+	 * @param array   $items_label      An array of singular/plural values for the items label:
763
+	 *                                  array(
764
+	 *                                  'single' => 'item',
765
+	 *                                  'plural' => 'items'
766
+	 *                                  )
767
+	 * @return  string
768
+	 * @since    4.4.0
769
+	 * @see      wp-admin/includes/class-wp-list-table.php WP_List_Table::pagination()
770
+	 */
771
+	public static function get_paging_html(
772
+		$total_items,
773
+		$current,
774
+		$per_page,
775
+		$url,
776
+		$show_num_field = true,
777
+		$paged_arg_name = 'paged',
778
+		$items_label = []
779
+	) {
780
+		$page_links     = [];
781
+		$disable_first  = $disable_last = '';
782
+		$total_items    = (int) $total_items;
783
+		$per_page       = (int) $per_page;
784
+		$current        = (int) $current;
785
+		$paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name);
786
+
787
+		// filter items_label
788
+		$items_label = apply_filters(
789
+			'FHEE__EEH_Template__get_paging_html__items_label',
790
+			$items_label
791
+		);
792
+
793
+		if (
794
+			empty($items_label)
795
+			|| ! is_array($items_label)
796
+			|| ! isset($items_label['single'])
797
+			|| ! isset($items_label['plural'])
798
+		) {
799
+			$items_label = [
800
+				'single' => esc_html__('1 item', 'event_espresso'),
801
+				'plural' => esc_html__('%s items', 'event_espresso'),
802
+			];
803
+		} else {
804
+			$items_label = [
805
+				'single' => '1 ' . esc_html($items_label['single']),
806
+				'plural' => '%s ' . esc_html($items_label['plural']),
807
+			];
808
+		}
809
+
810
+		$total_pages = ceil($total_items / $per_page);
811
+
812
+		if ($total_pages <= 1) {
813
+			return '';
814
+		}
815
+
816
+		$item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single'];
817
+
818
+		$output = '<span class="displaying-num">' . $item_label . '</span>';
819
+
820
+		$disable_first = $current === 1 ? 'disabled' : '';
821
+		$disable_last  = $current === $total_pages ? 'disabled' : '';
822
+
823
+		$button_classes = 'button button--secondary button--icon-only button--small';
824
+
825
+		$page_links[] = sprintf(
826
+			'<a class="%s" aria-label="%s" href="%s"><span class="ee-pagination-arrow">%s</span></a>',
827
+			"first-page $button_classes $disable_first",
828
+			esc_attr__('Go to the first page', 'event_espresso'),
829
+			esc_url_raw(remove_query_arg($paged_arg_name, $url)),
830
+			'&laquo;'
831
+		);
832
+
833
+		$page_links[] = sprintf(
834
+			'<a class="%s" aria-label="%s" href="%s"><span class="ee-pagination-arrow">%s</span></a>',
835
+			"prev-page $button_classes $disable_first",
836
+			esc_attr__('Go to the previous page', 'event_espresso'),
837
+			esc_url_raw(add_query_arg($paged_arg_name, max(1, $current - 1), $url)),
838
+			'&lsaquo;'
839
+		);
840
+
841
+		if (! $show_num_field) {
842
+			$html_current_page = $current;
843
+		} else {
844
+			$html_current_page = sprintf(
845
+				"<input class='current-page ee-input-size--small' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />",
846
+				esc_attr__('Current page', 'event_espresso'),
847
+				esc_attr($current),
848
+				strlen($total_pages)
849
+			);
850
+		}
851
+
852
+		$html_total_pages = sprintf(
853
+			'<span class="total-pages">%s</span>',
854
+			number_format_i18n($total_pages)
855
+		);
856
+		$page_links[]     = sprintf(
857
+			_x('%3$s%1$s of %2$s%4$s', 'paging', 'event_espresso'),
858
+			"{$html_current_page}<span class='paging-input-of'>",
859
+			"</span>{$html_total_pages}",
860
+			'<span class="paging-input">',
861
+			'</span>'
862
+		);
863
+
864
+		$page_links[] = sprintf(
865
+			'<a class="%s" aria-label="%s" href="%s"><span class="ee-pagination-arrow">%s</span></a>',
866
+			"next-page $button_classes $disable_last",
867
+			esc_attr__('Go to the next page', 'event_espresso'),
868
+			esc_url_raw(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)),
869
+			'&rsaquo;'
870
+		);
871
+
872
+		$page_links[] = sprintf(
873
+			'<a class="%s" aria-label="%s" href="%s"><span class="ee-pagination-arrow">%s</span></a>',
874
+			"last-page $button_classes $disable_last",
875
+			esc_attr__('Go to the last page', 'event_espresso'),
876
+			esc_url_raw(add_query_arg($paged_arg_name, $total_pages, $url)),
877
+			'&raquo;'
878
+		);
879
+
880
+		$output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>';
881
+
882
+		$page_class = ' no-pages';
883
+		if ($total_pages) {
884
+			$page_class = $total_pages < 2 ? ' one-page' : '';
885
+		}
886
+
887
+		return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>';
888
+	}
889
+
890
+
891
+	/**
892
+	 * @param string $wrap_class
893
+	 * @param string $wrap_id
894
+	 * @return string
895
+	 */
896
+	public static function powered_by_event_espresso($wrap_class = '', $wrap_id = '', array $query_args = [])
897
+	{
898
+		$admin = is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX);
899
+		if (
900
+			! $admin
901
+			&& ! apply_filters(
902
+				'FHEE__EEH_Template__powered_by_event_espresso__show_reg_footer',
903
+				EE_Registry::instance()->CFG->admin->show_reg_footer
904
+			)
905
+		) {
906
+			return '';
907
+		}
908
+		$tag        = $admin ? 'span' : 'div';
909
+		$attributes = ! empty($wrap_id) ? " id=\"{$wrap_id}\"" : '';
910
+		$wrap_class = $admin ? "{$wrap_class} float-left" : $wrap_class;
911
+		$attributes .= ! empty($wrap_class)
912
+			? " class=\"{$wrap_class} powered-by-event-espresso-credit\""
913
+			: ' class="powered-by-event-espresso-credit"';
914
+		$query_args = array_merge(
915
+			[
916
+				'ap_id'        => EE_Registry::instance()->CFG->admin->affiliate_id(),
917
+				'utm_source'   => 'powered_by_event_espresso',
918
+				'utm_medium'   => 'link',
919
+				'utm_campaign' => 'powered_by',
920
+			],
921
+			$query_args
922
+		);
923
+		$powered_by = apply_filters(
924
+			'FHEE__EEH_Template__powered_by_event_espresso_text',
925
+			$admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso'
926
+		);
927
+		$url        = add_query_arg($query_args, 'https://eventespresso.com/');
928
+		$url        = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url);
929
+		return (string) apply_filters(
930
+			'FHEE__EEH_Template__powered_by_event_espresso__html',
931
+			sprintf(
932
+				esc_html_x(
933
+					'%3$s%1$sOnline event registration and ticketing powered by %2$s%3$s',
934
+					'Online event registration and ticketing powered by [link to eventespresso.com]',
935
+					'event_espresso'
936
+				),
937
+				"<{$tag}{$attributes}>",
938
+				"<a href=\"{$url}\" target=\"_blank\" rel=\"nofollow\">{$powered_by}</a></{$tag}>",
939
+				$admin ? '' : '<br />'
940
+			),
941
+			$wrap_class,
942
+			$wrap_id
943
+		);
944
+	}
945
+
946
+
947
+	/**
948
+	 * @param string $image_name
949
+	 * @return string|null
950
+	 * @since   4.10.14.p
951
+	 */
952
+	public static function getScreenshotUrl($image_name)
953
+	{
954
+		return esc_url_raw(EE_GLOBAL_ASSETS_URL . 'images/screenshots/' . $image_name . '.jpg');
955
+	}
956 956
 }
957 957
 
958 958
 
959 959
 if (! function_exists('espresso_pagination')) {
960
-    /**
961
-     *    espresso_pagination
962
-     *
963
-     * @access    public
964
-     * @return    void
965
-     */
966
-    function espresso_pagination()
967
-    {
968
-        global $wp_query;
969
-        $big        = 999999999; // need an unlikely integer
970
-        $pagination = paginate_links(
971
-            [
972
-                'base'         => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
973
-                'format'       => '?paged=%#%',
974
-                'current'      => max(1, get_query_var('paged')),
975
-                'total'        => $wp_query->max_num_pages,
976
-                'show_all'     => true,
977
-                'end_size'     => 10,
978
-                'mid_size'     => 6,
979
-                'prev_next'    => true,
980
-                'prev_text'    => esc_html__('&lsaquo; PREV', 'event_espresso'),
981
-                'next_text'    => esc_html__('NEXT &rsaquo;', 'event_espresso'),
982
-                'type'         => 'plain',
983
-                'add_args'     => false,
984
-                'add_fragment' => '',
985
-            ]
986
-        );
987
-        echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : '';
988
-    }
960
+	/**
961
+	 *    espresso_pagination
962
+	 *
963
+	 * @access    public
964
+	 * @return    void
965
+	 */
966
+	function espresso_pagination()
967
+	{
968
+		global $wp_query;
969
+		$big        = 999999999; // need an unlikely integer
970
+		$pagination = paginate_links(
971
+			[
972
+				'base'         => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
973
+				'format'       => '?paged=%#%',
974
+				'current'      => max(1, get_query_var('paged')),
975
+				'total'        => $wp_query->max_num_pages,
976
+				'show_all'     => true,
977
+				'end_size'     => 10,
978
+				'mid_size'     => 6,
979
+				'prev_next'    => true,
980
+				'prev_text'    => esc_html__('&lsaquo; PREV', 'event_espresso'),
981
+				'next_text'    => esc_html__('NEXT &rsaquo;', 'event_espresso'),
982
+				'type'         => 'plain',
983
+				'add_args'     => false,
984
+				'add_fragment' => '',
985
+			]
986
+		);
987
+		echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : '';
988
+	}
989 989
 }
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
 use EventEspresso\core\services\request\RequestInterface;
7 7
 use EventEspresso\core\services\request\sanitizers\AllowedTags;
8 8
 
9
-if (! function_exists('espresso_get_template_part')) {
9
+if ( ! function_exists('espresso_get_template_part')) {
10 10
     /**
11 11
      * espresso_get_template_part
12 12
      * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 }
23 23
 
24 24
 
25
-if (! function_exists('espresso_get_object_css_class')) {
25
+if ( ! function_exists('espresso_get_object_css_class')) {
26 26
     /**
27 27
      * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed
28 28
      *
@@ -72,9 +72,9 @@  discard block
 block discarded – undo
72 72
      */
73 73
     public static function load_espresso_theme_functions()
74 74
     {
75
-        if (! defined('EE_THEME_FUNCTIONS_LOADED')) {
76
-            if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php')) {
77
-                require_once(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php');
75
+        if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) {
76
+            if (is_readable(EE_PUBLIC.EE_Config::get_current_theme().'/functions.php')) {
77
+                require_once(EE_PUBLIC.EE_Config::get_current_theme().'/functions.php');
78 78
             }
79 79
         }
80 80
     }
@@ -88,16 +88,16 @@  discard block
 block discarded – undo
88 88
     public static function get_espresso_themes()
89 89
     {
90 90
         if (empty(EEH_Template::$_espresso_themes)) {
91
-            $espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR);
91
+            $espresso_themes = glob(EE_PUBLIC.'*', GLOB_ONLYDIR);
92 92
             if (empty($espresso_themes)) {
93 93
                 return [];
94 94
             }
95 95
             if (($key = array_search('global_assets', $espresso_themes)) !== false) {
96
-                unset($espresso_themes[ $key ]);
96
+                unset($espresso_themes[$key]);
97 97
             }
98 98
             EEH_Template::$_espresso_themes = [];
99 99
             foreach ($espresso_themes as $espresso_theme) {
100
-                EEH_Template::$_espresso_themes[ basename($espresso_theme) ] = $espresso_theme;
100
+                EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme;
101 101
             }
102 102
         }
103 103
         return EEH_Template::$_espresso_themes;
@@ -213,10 +213,10 @@  discard block
 block discarded – undo
213 213
                 // get array of EE Custom Post Types
214 214
                 $EE_CPTs = $custom_post_types->getDefinitions();
215 215
                 // build template name based on request
216
-                if (isset($EE_CPTs[ $post_type ])) {
216
+                if (isset($EE_CPTs[$post_type])) {
217 217
                     $archive_or_single = is_archive() ? 'archive' : '';
218 218
                     $archive_or_single = is_single() ? 'single' : $archive_or_single;
219
-                    $templates         = $archive_or_single . '-' . $post_type . '.php';
219
+                    $templates         = $archive_or_single.'-'.$post_type.'.php';
220 220
                 }
221 221
             }
222 222
             // currently active EE template theme
@@ -225,18 +225,18 @@  discard block
 block discarded – undo
225 225
             // array of paths to folders that may contain templates
226 226
             $template_folder_paths = [
227 227
                 // first check the /wp-content/uploads/espresso/templates/(current EE theme)/  folder for an EE theme template file
228
-                EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme,
228
+                EVENT_ESPRESSO_TEMPLATE_DIR.$current_theme,
229 229
                 // then in the root of the /wp-content/uploads/espresso/templates/ folder
230 230
                 EVENT_ESPRESSO_TEMPLATE_DIR,
231 231
             ];
232 232
 
233 233
             // add core plugin folders for checking only if we're not $check_if_custom
234
-            if (! $check_if_custom) {
235
-                $core_paths            = [
234
+            if ( ! $check_if_custom) {
235
+                $core_paths = [
236 236
                     // in the  /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin
237
-                    EE_PUBLIC . $current_theme,
237
+                    EE_PUBLIC.$current_theme,
238 238
                     // in the  /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin
239
-                    EE_TEMPLATES . $current_theme,
239
+                    EE_TEMPLATES.$current_theme,
240 240
                     // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/
241 241
                     EE_PLUGIN_DIR_PATH,
242 242
                 ];
@@ -271,10 +271,10 @@  discard block
 block discarded – undo
271 271
                     );
272 272
                     if ($common_base_path !== '') {
273 273
                         // both paths have a common base, so just tack the filename onto our search path
274
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name;
274
+                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$file_name;
275 275
                     } else {
276 276
                         // no common base path, so let's just concatenate
277
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template;
277
+                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$template;
278 278
                     }
279 279
                     // build up our template locations array by adding our resolved paths
280 280
                     $full_template_paths[] = $resolved_path;
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
                 // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first
283 283
                 array_unshift($full_template_paths, $template);
284 284
                 // path to the directory of the current theme: /wp-content/themes/(current WP theme)/
285
-                array_unshift($full_template_paths, get_stylesheet_directory() . '/' . $file_name);
285
+                array_unshift($full_template_paths, get_stylesheet_directory().'/'.$file_name);
286 286
             }
287 287
             // filter final array of full template paths
288 288
             $full_template_paths = apply_filters(
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
                 }
334 334
             }
335 335
             $common_base_path .= $directory;
336
-            $last_offset      = $index + 1;
336
+            $last_offset = $index + 1;
337 337
         }
338 338
         return substr($common_base_path, 0, -1);
339 339
     }
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
         $template_args = (array) apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args);
372 372
 
373 373
         // you gimme nuttin - YOU GET NUTTIN !!
374
-        if (! $template_path || ! is_readable($template_path)) {
374
+        if ( ! $template_path || ! is_readable($template_path)) {
375 375
             // ignore whether template is accessible ?
376 376
             if ($throw_exceptions) {
377 377
                 throw new DomainException(
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
             return '';
382 382
         }
383 383
         // if $template_args are not in an array, then make it so
384
-        if (! is_array($template_args) && ! is_object($template_args)) {
384
+        if ( ! is_array($template_args) && ! is_object($template_args)) {
385 385
             $template_args = [$template_args];
386 386
         }
387 387
         extract($template_args, EXTR_SKIP);
@@ -410,11 +410,11 @@  discard block
 block discarded – undo
410 410
     public static function get_object_css_class($object = null, $prefix = '', $suffix = '')
411 411
     {
412 412
         // in the beginning...
413
-        $prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : '';
413
+        $prefix = ! empty($prefix) ? rtrim($prefix, '-').'-' : '';
414 414
         // da muddle
415 415
         $class = '';
416 416
         // the end
417
-        $suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : '';
417
+        $suffix = ! empty($suffix) ? '-'.ltrim($suffix, '-') : '';
418 418
         // is the passed object an EE object ?
419 419
         if ($object instanceof EE_Base_Class) {
420 420
             // grab the exact type of object
@@ -424,10 +424,10 @@  discard block
 block discarded – undo
424 424
                 // no specifics just yet...
425 425
                 default:
426 426
                     $class = strtolower(str_replace('_', '-', $obj_class));
427
-                    $class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : '';
427
+                    $class .= method_exists($obj_class, 'name') ? '-'.sanitize_title($object->name()) : '';
428 428
             }
429 429
         }
430
-        return $prefix . $class . $suffix;
430
+        return $prefix.$class.$suffix;
431 431
     }
432 432
 
433 433
 
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
         // filter raw amount (allows 0.00 to be changed to "free" for example)
463 463
         $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw);
464 464
         // still a number, or was amount converted to a string like "free" ?
465
-        if (! is_float($amount_formatted)) {
465
+        if ( ! is_float($amount_formatted)) {
466 466
             return esc_html($amount_formatted);
467 467
         }
468 468
         try {
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
             $mny = null;
474 474
         }
475 475
         // verify results
476
-        if (! $mny instanceof EE_Currency_Config) {
476
+        if ( ! $mny instanceof EE_Currency_Config) {
477 477
             // set default config country currency settings
478 478
             $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config
479 479
                 ? EE_Registry::instance()->CFG->currency
@@ -482,16 +482,16 @@  discard block
 block discarded – undo
482 482
         // format float
483 483
         $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds);
484 484
         // add formatting ?
485
-        if (! $return_raw) {
485
+        if ( ! $return_raw) {
486 486
             // add currency sign
487 487
             if ($mny->sign_b4) {
488 488
                 if ($amount >= 0) {
489
-                    $amount_formatted = $mny->sign . $amount_formatted;
489
+                    $amount_formatted = $mny->sign.$amount_formatted;
490 490
                 } else {
491
-                    $amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted);
491
+                    $amount_formatted = '-'.$mny->sign.str_replace('-', '', $amount_formatted);
492 492
                 }
493 493
             } else {
494
-                $amount_formatted = $amount_formatted . $mny->sign;
494
+                $amount_formatted = $amount_formatted.$mny->sign;
495 495
             }
496 496
 
497 497
             // filter to allow global setting of display_code
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
 
503 503
             // add currency code ?
504 504
             $amount_formatted = $display_code
505
-                ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>'
505
+                ? $amount_formatted.' <span class="'.$cur_code_span_class.'">('.$mny->code.')</span>'
506 506
                 : $amount_formatted;
507 507
         }
508 508
         // filter results
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
             $plural,
539 539
             $schema
540 540
         );
541
-        return $status[ $status_id ];
541
+        return $status[$status_id];
542 542
     }
543 543
 
544 544
 
@@ -555,14 +555,14 @@  discard block
 block discarded – undo
555 555
     public static function get_button_or_link($url, $label, $class = 'button button--primary', $icon = '', $title = '')
556 556
     {
557 557
         $icon_html = '';
558
-        if (! empty($icon)) {
558
+        if ( ! empty($icon)) {
559 559
             $dashicons = preg_split("(ee-icon |dashicons )", $icon);
560 560
             $dashicons = array_filter($dashicons);
561 561
             $count     = count($dashicons);
562 562
             $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : '';
563 563
             foreach ($dashicons as $dashicon) {
564
-                $type      = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons ';
565
-                $icon_html .= '<span class="' . $type . $dashicon . '"></span>';
564
+                $type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons ';
565
+                $icon_html .= '<span class="'.$type.$dashicon.'"></span>';
566 566
             }
567 567
             $icon_html .= $count > 1 ? '</span>' : '';
568 568
         }
@@ -602,18 +602,18 @@  discard block
 block discarded – undo
602 602
         $action  = $action ?: $request->getRequestParam('action', 'default', 'key');
603 603
 
604 604
 
605
-        $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id;
605
+        $help_tab_lnk = $page.'-'.$action.'-'.$help_tab_id;
606 606
         $icon      = ! $icon_style ? 'dashicons-editor-help' : $icon_style;
607 607
         $help_text = ! $help_text ? '' : $help_text;
608 608
         return '
609
-        	<a 	id="' . esc_attr($help_tab_lnk) . '" 
610
-        		class="espresso-help-tab-lnk ee-help-btn ee-aria-tooltip dashicons ' . esc_attr($icon) . '" 
609
+        	<a 	id="' . esc_attr($help_tab_lnk).'" 
610
+        		class="espresso-help-tab-lnk ee-help-btn ee-aria-tooltip dashicons ' . esc_attr($icon).'" 
611 611
         		aria-label="' . esc_attr__(
612 612
                     'Click to open the \'Help\' tab for more information about this feature.',
613 613
                     'event_espresso'
614
-                ) . '" 
614
+                ).'" 
615 615
 		    >
616
-		    	' . wp_kses($help_text, $allowedtags) . '
616
+		    	' . wp_kses($help_text, $allowedtags).'
617 617
 			</a>';
618 618
     }
619 619
 
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
      */
635 635
     public static function status_legend($status_array, $active_status = '')
636 636
     {
637
-        if (! is_array($status_array)) {
637
+        if ( ! is_array($status_array)) {
638 638
             throw new EE_Error(
639 639
                 esc_html__(
640 640
                     'The EEH_Template::status_legend helper required the incoming status_array argument to be an array!',
@@ -646,17 +646,17 @@  discard block
 block discarded – undo
646 646
         $content = '
647 647
             <div class="ee-list-table-legend-container">
648 648
                 <h4 class="status-legend-title">
649
-                    ' . esc_html__('Status Legend', 'event_espresso') . '
649
+                    ' . esc_html__('Status Legend', 'event_espresso').'
650 650
                 </h4>
651 651
                 <dl class="ee-list-table-legend">';
652 652
 
653 653
         foreach ($status_array as $item => $status) {
654 654
             $active_class = $active_status == $status ? 'class="ee-is-active-status"' : '';
655
-            $content      .= '
656
-                    <dt id="' . esc_attr('ee-legend-item-tooltip-' . $item) . '" ' . $active_class . '>
657
-                        <span class="' . esc_attr('ee-status-legend ee-status-bg--' . $status) . '"></span>
655
+            $content .= '
656
+                    <dt id="' . esc_attr('ee-legend-item-tooltip-'.$item).'" '.$active_class.'>
657
+                        <span class="' . esc_attr('ee-status-legend ee-status-bg--'.$status).'"></span>
658 658
                         <span class="ee-legend-description">
659
-                            ' . EEH_Template::pretty_status($status, false, 'sentence') . '
659
+                            ' . EEH_Template::pretty_status($status, false, 'sentence').'
660 660
                         </span>
661 661
                     </dt>';
662 662
         }
@@ -802,8 +802,8 @@  discard block
 block discarded – undo
802 802
             ];
803 803
         } else {
804 804
             $items_label = [
805
-                'single' => '1 ' . esc_html($items_label['single']),
806
-                'plural' => '%s ' . esc_html($items_label['plural']),
805
+                'single' => '1 '.esc_html($items_label['single']),
806
+                'plural' => '%s '.esc_html($items_label['plural']),
807 807
             ];
808 808
         }
809 809
 
@@ -815,7 +815,7 @@  discard block
 block discarded – undo
815 815
 
816 816
         $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single'];
817 817
 
818
-        $output = '<span class="displaying-num">' . $item_label . '</span>';
818
+        $output = '<span class="displaying-num">'.$item_label.'</span>';
819 819
 
820 820
         $disable_first = $current === 1 ? 'disabled' : '';
821 821
         $disable_last  = $current === $total_pages ? 'disabled' : '';
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
             '&lsaquo;'
839 839
         );
840 840
 
841
-        if (! $show_num_field) {
841
+        if ( ! $show_num_field) {
842 842
             $html_current_page = $current;
843 843
         } else {
844 844
             $html_current_page = sprintf(
@@ -853,7 +853,7 @@  discard block
 block discarded – undo
853 853
             '<span class="total-pages">%s</span>',
854 854
             number_format_i18n($total_pages)
855 855
         );
856
-        $page_links[]     = sprintf(
856
+        $page_links[] = sprintf(
857 857
             _x('%3$s%1$s of %2$s%4$s', 'paging', 'event_espresso'),
858 858
             "{$html_current_page}<span class='paging-input-of'>",
859 859
             "</span>{$html_total_pages}",
@@ -877,14 +877,14 @@  discard block
 block discarded – undo
877 877
             '&raquo;'
878 878
         );
879 879
 
880
-        $output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>';
880
+        $output .= "\n".'<span class="pagination-links">'.join("\n", $page_links).'</span>';
881 881
 
882 882
         $page_class = ' no-pages';
883 883
         if ($total_pages) {
884 884
             $page_class = $total_pages < 2 ? ' one-page' : '';
885 885
         }
886 886
 
887
-        return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>';
887
+        return '<div class="tablenav"><div class="tablenav-pages'.$page_class.'">'.$output.'</div></div>';
888 888
     }
889 889
 
890 890
 
@@ -922,7 +922,7 @@  discard block
 block discarded – undo
922 922
         );
923 923
         $powered_by = apply_filters(
924 924
             'FHEE__EEH_Template__powered_by_event_espresso_text',
925
-            $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso'
925
+            $admin ? 'Event Espresso - '.EVENT_ESPRESSO_VERSION : 'Event Espresso'
926 926
         );
927 927
         $url        = add_query_arg($query_args, 'https://eventespresso.com/');
928 928
         $url        = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url);
@@ -951,12 +951,12 @@  discard block
 block discarded – undo
951 951
      */
952 952
     public static function getScreenshotUrl($image_name)
953 953
     {
954
-        return esc_url_raw(EE_GLOBAL_ASSETS_URL . 'images/screenshots/' . $image_name . '.jpg');
954
+        return esc_url_raw(EE_GLOBAL_ASSETS_URL.'images/screenshots/'.$image_name.'.jpg');
955 955
     }
956 956
 }
957 957
 
958 958
 
959
-if (! function_exists('espresso_pagination')) {
959
+if ( ! function_exists('espresso_pagination')) {
960 960
     /**
961 961
      *    espresso_pagination
962 962
      *
@@ -984,6 +984,6 @@  discard block
 block discarded – undo
984 984
                 'add_fragment' => '',
985 985
             ]
986 986
         );
987
-        echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : '';
987
+        echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">'.$pagination.'</div>' : '';
988 988
     }
989 989
 }
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Yes_No_Input.input.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -9,18 +9,18 @@
 block discarded – undo
9 9
  */
10 10
 class EE_Yes_No_Input extends EE_Select_Input
11 11
 {
12
-    /**
13
-     * @param array $options
14
-     */
15
-    public function __construct($options = [])
16
-    {
17
-        parent::__construct(
18
-            [
19
-                true  => esc_html__('Yes', 'event_espresso'),
20
-                false => esc_html__('No', 'event_espresso')
21
-            ],
22
-            $options
23
-        );
24
-        $this->set_html_class($this->html_class() . ' ee-input-width--tiny');
25
-    }
12
+	/**
13
+	 * @param array $options
14
+	 */
15
+	public function __construct($options = [])
16
+	{
17
+		parent::__construct(
18
+			[
19
+				true  => esc_html__('Yes', 'event_espresso'),
20
+				false => esc_html__('No', 'event_espresso')
21
+			],
22
+			$options
23
+		);
24
+		$this->set_html_class($this->html_class() . ' ee-input-width--tiny');
25
+	}
26 26
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,6 +21,6 @@
 block discarded – undo
21 21
             ],
22 22
             $options
23 23
         );
24
-        $this->set_html_class($this->html_class() . ' ee-input-width--tiny');
24
+        $this->set_html_class($this->html_class().' ee-input-width--tiny');
25 25
     }
26 26
 }
Please login to merge, or discard this patch.
registration_form/templates/question_groups_main_meta_box.template.php 1 patch
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -17,8 +17,8 @@  discard block
 block discarded – undo
17 17
 assert(is_array($values));
18 18
 
19 19
 foreach ($all_questions as $unused_question) {
20
-    assert($unused_question);
21
-    assert($unused_question instanceof EE_Question);
20
+	assert($unused_question);
21
+	assert($unused_question instanceof EE_Question);
22 22
 }
23 23
 
24 24
 $question_order           = 0;
@@ -28,10 +28,10 @@  discard block
 block discarded – undo
28 28
 $disabled = ! empty($QSG_system) ? 'disabled' : '';
29 29
 $id = ! empty($QST_system) ? '_disabled' : '';
30 30
 $required_question_group_questions = EEM_Question::instance()->required_system_questions_in_system_question_group(
31
-    $QSG_system
31
+	$QSG_system
32 32
 );
33 33
 $allowed_question_group_questions  = EEM_Question::instance()->allowed_system_questions_in_system_question_group(
34
-    $QSG_system
34
+	$QSG_system
35 35
 );
36 36
 ?>
37 37
 
@@ -78,9 +78,9 @@  discard block
 block discarded – undo
78 78
                             <p>
79 79
                                 <span class="description" style="color:#D54E21;">
80 80
                                 <?php esc_html_e(
81
-                                    'System question group! This field cannot be changed.',
82
-                                    'event_espresso'
83
-                                ) ?>
81
+									'System question group! This field cannot be changed.',
82
+									'event_espresso'
83
+								) ?>
84 84
                                 </span><br />
85 85
                             </p>
86 86
                         <?php } ?>
@@ -128,12 +128,12 @@  discard block
 block discarded – undo
128 128
                     </th>
129 129
                     <td>
130 130
                         <?php echo EEH_Form_Fields::select_input(
131
-                            'QSG_show_group_name',
132
-                            $values,
133
-                            $question_group->show_group_name(),
134
-                            '',
135
-                            'ee-input-width--small'
136
-                        ); ?>
131
+							'QSG_show_group_name',
132
+							$values,
133
+							$question_group->show_group_name(),
134
+							'',
135
+							'ee-input-width--small'
136
+						); ?>
137 137
                         <p class="description">
138 138
                             <?php esc_html_e('Show Group Name on Registration Page?', 'event_espresso'); ?>
139 139
                         </p>
@@ -149,15 +149,15 @@  discard block
 block discarded – undo
149 149
                     </th>
150 150
                     <td>
151 151
                         <?php echo EEH_Form_Fields::select_input(
152
-                            'QSG_show_group_desc',
153
-                            $values,
154
-                            $question_group->show_group_desc(),
155
-                            '',
156
-                            'ee-input-width--small'
157
-                        ); ?>
152
+							'QSG_show_group_desc',
153
+							$values,
154
+							$question_group->show_group_desc(),
155
+							'',
156
+							'ee-input-width--small'
157
+						); ?>
158 158
                         <p class="description"><?php
159
-                            esc_html_e(' Show Group Description on Registration Page?', 'event_espresso');
160
-                        ?></p>
159
+							esc_html_e(' Show Group Description on Registration Page?', 'event_espresso');
160
+						?></p>
161 161
                         <input type="hidden" name="QSG_system" value="<?php echo esc_attr($question_group->system_group()); ?>">
162 162
                     </td>
163 163
                 </tr>
@@ -171,40 +171,40 @@  discard block
 block discarded – undo
171 171
         <div class="question-group-questions">
172 172
             <p class='ee-status-outline ee-status-bg--info'>
173 173
                 <?php
174
-                esc_html_e(
175
-                    'Select which questions should be shown in this group by checking or unchecking boxes. You can drag and drop questions to reorder them. Your changes will be updated when you save.',
176
-                    'event_espresso'
177
-                ); ?>
174
+				esc_html_e(
175
+					'Select which questions should be shown in this group by checking or unchecking boxes. You can drag and drop questions to reorder them. Your changes will be updated when you save.',
176
+					'event_espresso'
177
+				); ?>
178 178
             </p>
179 179
             <div>
180 180
                 <ul class="question-list-sortable">
181 181
                     <?php
182
-                    foreach ($all_questions as $question_ID => $question) {
183
-                        if (! $question instanceof EE_Question) {
184
-                            continue;
185
-                        }
186
-                        $checked = isset($question_group_questions[ $question_ID ])
187
-                            ? ' checked'
188
-                            : '';
189
-                        // disable questions from the personal information question group
190
-                        // is it required in the current question group? if so don't allow admins to remove it
191
-                        $disabled = in_array($question->system_ID(), $required_question_group_questions)
192
-                            ? ' disabled'
193
-                            : '';
194
-                        // limit where system questions can appear
195
-                        if (
196
-                            $question->system_ID()
197
-                            && ! in_array($question->system_ID(), $allowed_question_group_questions)
198
-                        ) {
199
-                            // skip over system question not assigned to this group
200
-                            // except for the address system group cause we want the address questions to display
201
-                            // even if they aren't selected (but still not show the personal system questions).
202
-                            // The third condition checks if we're displaying a non system question group
203
-                            // and the question is a system question, then we skip
204
-                            // because for non-system question groups we only want to show non-system questions.
205
-                            continue;
206
-                        }
207
-                        ?>
182
+					foreach ($all_questions as $question_ID => $question) {
183
+						if (! $question instanceof EE_Question) {
184
+							continue;
185
+						}
186
+						$checked = isset($question_group_questions[ $question_ID ])
187
+							? ' checked'
188
+							: '';
189
+						// disable questions from the personal information question group
190
+						// is it required in the current question group? if so don't allow admins to remove it
191
+						$disabled = in_array($question->system_ID(), $required_question_group_questions)
192
+							? ' disabled'
193
+							: '';
194
+						// limit where system questions can appear
195
+						if (
196
+							$question->system_ID()
197
+							&& ! in_array($question->system_ID(), $allowed_question_group_questions)
198
+						) {
199
+							// skip over system question not assigned to this group
200
+							// except for the address system group cause we want the address questions to display
201
+							// even if they aren't selected (but still not show the personal system questions).
202
+							// The third condition checks if we're displaying a non system question group
203
+							// and the question is a system question, then we skip
204
+							// because for non-system question groups we only want to show non-system questions.
205
+							continue;
206
+						}
207
+						?>
208 208
                         <li class="ee-question-sortable">
209 209
                             <label for="question-<?php echo absint($question_ID); ?>">
210 210
                                 <input id="question-<?php echo absint($question_ID); ?>"
@@ -216,10 +216,10 @@  discard block
 block discarded – undo
216 216
                                 />
217 217
                                 <span class="question-text">
218 218
                                     <?php
219
-                                        $trimmed_text = trim($question->display_text());
220
-                                        $trimmed_text .= strlen($trimmed_text) >= 95 ? "&hellip;" : '';
221
-                                        echo esc_html($trimmed_text);
222
-                                    ?>
219
+										$trimmed_text = trim($question->display_text());
220
+										$trimmed_text .= strlen($trimmed_text) >= 95 ? "&hellip;" : '';
221
+										echo esc_html($trimmed_text);
222
+									?>
223 223
                                 </span>
224 224
                                 <input class="question-group-QGQ_order"
225 225
                                        name="question_orders[<?php echo absint($question_ID); ?>]"
@@ -228,40 +228,40 @@  discard block
 block discarded – undo
228 228
                                 >
229 229
                             </label>
230 230
                             <?php
231
-                            if (
232
-                                EE_Registry::instance()->CAP->current_user_can(
233
-                                    'ee_edit_question',
234
-                                    'espresso_registration_form_edit_question',
235
-                                    $question->ID()
236
-                                )
237
-                            ) {
238
-                                $edit_link = EE_Admin_Page::add_query_args_and_nonce(
239
-                                    [
240
-                                        'action' => 'edit_question',
241
-                                        'QST_ID' => $question->ID(),
242
-                                    ],
243
-                                    EE_FORMS_ADMIN_URL
244
-                                );
231
+							if (
232
+								EE_Registry::instance()->CAP->current_user_can(
233
+									'ee_edit_question',
234
+									'espresso_registration_form_edit_question',
235
+									$question->ID()
236
+								)
237
+							) {
238
+								$edit_link = EE_Admin_Page::add_query_args_and_nonce(
239
+									[
240
+										'action' => 'edit_question',
241
+										'QST_ID' => $question->ID(),
242
+									],
243
+									EE_FORMS_ADMIN_URL
244
+								);
245 245
 
246
-                                echo '
246
+								echo '
247 247
                                     <a href="' . esc_url_raw($edit_link) . '"
248 248
                                          class="button button--small button--icon-only"
249 249
                                          target="_blank"
250 250
                                          title="' .
251
-                                    sprintf(
252
-                                        esc_attr__('Edit %s', 'event_espresso'),
253
-                                        $question->admin_label()
254
-                                    ) . '"
251
+									sprintf(
252
+										esc_attr__('Edit %s', 'event_espresso'),
253
+										$question->admin_label()
254
+									) . '"
255 255
                                     >
256 256
                                         <span class="dashicons dashicons-edit"></span>
257 257
                                     </a>';
258
-                            }
259
-                            ?>
258
+							}
259
+							?>
260 260
                         </li>
261 261
                         <?php
262
-                        $question_order++;
263
-                    }
264
-                    ?>
262
+						$question_order++;
263
+					}
264
+					?>
265 265
                 </ul>
266 266
             </div>
267 267
         </div>
Please login to merge, or discard this patch.
registration_form/templates/questions_main_meta_box.template.php 2 patches
Indentation   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -27,23 +27,23 @@  discard block
 block discarded – undo
27 27
 global $allowedposttags;
28 28
 $info_box = '';
29 29
 if ($QST_system === 'country') {
30
-    // already escaped
31
-    $info_box = EEH_HTML::div(
32
-        EEH_HTML::h3(
33
-            '<span class="dashicons dashicons-info"></span> '
34
-            . esc_html__('Did you know...', 'event_espresso'),
35
-            '',
36
-            'ee-status--info'
37
-        ) .
38
-        EEH_HTML::p(
39
-            esc_html__(
40
-                'If you add a State/Province Select input immediately after this Country Select input when building your registration form, then the State/Province Select input options will change to correspond with the choice made in this input. So for example, choosing "United States" in this Country Select input will populate the State/Province Select input with just the state options for the United States.',
41
-                'event_espresso'
42
-            )
43
-        ),
44
-        '',
45
-        'ee-info-box'
46
-    );
30
+	// already escaped
31
+	$info_box = EEH_HTML::div(
32
+		EEH_HTML::h3(
33
+			'<span class="dashicons dashicons-info"></span> '
34
+			. esc_html__('Did you know...', 'event_espresso'),
35
+			'',
36
+			'ee-status--info'
37
+		) .
38
+		EEH_HTML::p(
39
+			esc_html__(
40
+				'If you add a State/Province Select input immediately after this Country Select input when building your registration form, then the State/Province Select input options will change to correspond with the choice made in this input. So for example, choosing "United States" in this Country Select input will populate the State/Province Select input with just the state options for the United States.',
41
+				'event_espresso'
42
+			)
43
+		),
44
+		'',
45
+		'ee-info-box'
46
+	);
47 47
 }
48 48
 ?>
49 49
 
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
                     </th>
80 80
                     <td>
81 81
                         <?php
82
-                        $id            = ! empty($QST_system) ? '_disabled' : '';
83
-                        $disabled_attr = ! empty($QST_system) ? 'disabled' : '';
84
-                        ?>
82
+						$id            = ! empty($QST_system) ? '_disabled' : '';
83
+						$disabled_attr = ! empty($QST_system) ? 'disabled' : '';
84
+						?>
85 85
                         <input id="QST_admin_label<?php echo absint($id); ?>"
86 86
                                name="QST_admin_label<?php echo absint($id); ?>"
87 87
                                type="text"
@@ -119,29 +119,29 @@  discard block
 block discarded – undo
119 119
                     </th>
120 120
                     <td>
121 121
                         <?php
122
-                        $id            = ! empty($QST_system) ? '_disabled' : '';
123
-                        $disabled_attr = ! empty($QST_system) ? 'disabled' : '';
124
-                        $admin_only    = $question->get('QST_admin_only');
125
-                        $checked       = ! empty($admin_only) ? ' checked' : '';
126
-                        ?>
122
+						$id            = ! empty($QST_system) ? '_disabled' : '';
123
+						$disabled_attr = ! empty($QST_system) ? 'disabled' : '';
124
+						$admin_only    = $question->get('QST_admin_only');
125
+						$checked       = ! empty($admin_only) ? ' checked' : '';
126
+						?>
127 127
                         <input class="QST_admin_only"
128 128
                                id="QST_admin_only<?php echo absint($id); ?>"
129 129
                                name="QST_admin_only<?php echo absint($id); ?>"
130 130
                                type="checkbox"
131 131
                                value="1"
132 132
                             <?php
133
-                            echo esc_attr($disabled_attr);
134
-                            echo esc_attr($checked);
135
-                            ?>
133
+							echo esc_attr($disabled_attr);
134
+							echo esc_attr($checked);
135
+							?>
136 136
                         />
137 137
                         <br />
138 138
                             <?php
139
-                            if (! empty($QST_system)) { ?>
139
+							if (! empty($QST_system)) { ?>
140 140
                                 <p class="description" style="color:#D54E21;">
141 141
                                     <?php esc_html_e(
142
-                                        'System question! This field cannot be changed.',
143
-                                        'event_espresso'
144
-                                    ); ?>
142
+										'System question! This field cannot be changed.',
143
+										'event_espresso'
144
+									); ?>
145 145
                                 </p>
146 146
                             <?php } ?>
147 147
                     </td>
@@ -156,44 +156,44 @@  discard block
 block discarded – undo
156 156
                     </th>
157 157
                     <td>
158 158
                         <?php
159
-                        $disabled = ! empty($QST_system) && $QST_system !== EEM_Attendee::system_question_phone;
160
-                        if ($disabled) {
161
-                            $disabled_attr = 'disabled="disabled"';
162
-                            $id            = '_disabled';
163
-                        } else {
164
-                            $disabled_attr = '';
165
-                            $id            = '';
166
-                        }
159
+						$disabled = ! empty($QST_system) && $QST_system !== EEM_Attendee::system_question_phone;
160
+						if ($disabled) {
161
+							$disabled_attr = 'disabled="disabled"';
162
+							$id            = '_disabled';
163
+						} else {
164
+							$disabled_attr = '';
165
+							$id            = '';
166
+						}
167 167
 
168
-                        // Only display Confirm email for
169
-                        if (empty($QST_system) || $QST_system !== EEM_Attendee::system_question_email_confirm) {
170
-                            unset($question_types[ EEM_Question::QST_type_email_confirm ]);
171
-                        }
168
+						// Only display Confirm email for
169
+						if (empty($QST_system) || $QST_system !== EEM_Attendee::system_question_email_confirm) {
170
+							unset($question_types[ EEM_Question::QST_type_email_confirm ]);
171
+						}
172 172
 
173
-                        echo EEH_Form_Fields::select_input(
174
-                            'QST_type' . $id,
175
-                            $question_types,
176
-                            $question->type(),
177
-                            'id="QST_type' . $id . '"' . $disabled_attr
178
-                        ); // already escaped
179
-                        if ($disabled) { ?>
173
+						echo EEH_Form_Fields::select_input(
174
+							'QST_type' . $id,
175
+							$question_types,
176
+							$question->type(),
177
+							'id="QST_type' . $id . '"' . $disabled_attr
178
+						); // already escaped
179
+						if ($disabled) { ?>
180 180
                             <input id='QST_type'
181 181
                                    name="QST_type"
182 182
                                    type="hidden"
183 183
                                    value="<?php echo esc_attr($question->type()); ?>"
184 184
                             />
185 185
                             <?php
186
-                            $explanatory_text = esc_html__(
187
-                                'System question! This field cannot be changed.',
188
-                                'event_espresso'
189
-                            );
190
-                        } else {
191
-                            $explanatory_text = esc_html__(
192
-                                'Because there are currently answers for this question in the database, your options to change the question type have been limited to similar question-types.',
193
-                                'event_espresso'
194
-                            );
195
-                        }
196
-                        if ($disabled || $has_answers) { ?>
186
+							$explanatory_text = esc_html__(
187
+								'System question! This field cannot be changed.',
188
+								'event_espresso'
189
+							);
190
+						} else {
191
+							$explanatory_text = esc_html__(
192
+								'Because there are currently answers for this question in the database, your options to change the question type have been limited to similar question-types.',
193
+								'event_espresso'
194
+							);
195
+						}
196
+						if ($disabled || $has_answers) { ?>
197 197
                             <p class="description" style="color:#D54E21;">
198 198
                                     <?php echo esc_html($explanatory_text); ?>
199 199
                             </p>
@@ -221,21 +221,21 @@  discard block
 block discarded – undo
221 221
                         <p>
222 222
                             <span class="description">
223 223
                                 <?php esc_html_e(
224
-                                    'Maximum number of characters allowed when answering this question',
225
-                                    'event_espresso'
226
-                                ); ?>
224
+									'Maximum number of characters allowed when answering this question',
225
+									'event_espresso'
226
+								); ?>
227 227
                             </span>
228 228
                         </p>
229 229
                         <?php if ($QST_system) { ?>
230 230
                         <p>
231 231
                             <span class="description" style="color:#D54E21;">
232 232
                                 <?php printf(
233
-                                    esc_html__(
234
-                                        'System question! The maximum number of characters that can be used for this question is %1$s',
235
-                                        'event_espresso'
236
-                                    ),
237
-                                    $max_max
238
-                                ); ?>
233
+									esc_html__(
234
+										'System question! The maximum number of characters that can be used for this question is %1$s',
235
+										'event_espresso'
236
+									),
237
+									$max_max
238
+								); ?>
239 239
                             </span>
240 240
                         </p>
241 241
                         <?php } ?>
@@ -260,9 +260,9 @@  discard block
 block discarded – undo
260 260
                                     <th class="option-desc-header">
261 261
                                         <label>
262 262
                                         <?php esc_html_e(
263
-                                            'Description (optional, only shown on registration form)',
264
-                                            'event_espresso'
265
-                                        ) ?>
263
+											'Description (optional, only shown on registration form)',
264
+											'event_espresso'
265
+										) ?>
266 266
                                         </label>
267 267
                                     </th>
268 268
                                     <th>
@@ -305,9 +305,9 @@  discard block
 block discarded – undo
305 305
                                         </a>
306 306
                                         <a class="button button--icon-only sortable-drag-handle ee-aria-tooltip"
307 307
                                             aria-label="<?php esc_html_e(
308
-                                                'click and drag to change the order of this option',
309
-                                                'event_espresso'
310
-                                            ) ?>"
308
+												'click and drag to change the order of this option',
309
+												'event_espresso'
310
+											) ?>"
311 311
                                         >
312 312
                                             <span class='dashicons dashicons-image-flip-vertical '></span>
313 313
                                         </a>
@@ -315,14 +315,14 @@  discard block
 block discarded – undo
315 315
                                 </tr>
316 316
 
317 317
                                 <?php
318
-                                $count            = 0;
319
-                                $question_options = $question->options();
320
-                                if (! empty($question_options)) {
321
-                                    foreach ($question_options as $option_id => $option) {
322
-                                        $disabled_attr = $has_answers || $option->get('QSO_system')
323
-                                            ? 'disabled'
324
-                                            : '';
325
-                                        ?>
318
+								$count            = 0;
319
+								$question_options = $question->options();
320
+								if (! empty($question_options)) {
321
+									foreach ($question_options as $option_id => $option) {
322
+										$disabled_attr = $has_answers || $option->get('QSO_system')
323
+											? 'disabled'
324
+											: '';
325
+										?>
326 326
                                         <tr class="question-option ee-options-sortable">
327 327
                                             <td class="option-value-cell">
328 328
                                                 <label class='screen-reader-text'
@@ -372,29 +372,29 @@  discard block
 block discarded – undo
372 372
                                             <?php } ?>
373 373
                                                 <a class='button button--icon-only sortable-drag-handle ee-aria-tooltip'
374 374
                                                    aria-label="<?php esc_html_e(
375
-                                                       'click and drag to change the order of this option',
376
-                                                       'event_espresso'
377
-                                                   ) ?>"
375
+													   'click and drag to change the order of this option',
376
+													   'event_espresso'
377
+												   ) ?>"
378 378
                                                 >
379 379
                                                     <span class='dashicons dashicons-image-flip-vertical '></span>
380 380
                                                 </a>
381 381
                                             <?php
382
-                                            echo EEH_Form_Fields::hidden_input(
383
-                                                "question_options[{$count}][QST_ID])",
384
-                                                $option->question_ID()
385
-                                            ); // already escaped
386
-                                            echo EEH_Form_Fields::hidden_input(
387
-                                                "question_options[{$count}][QSO_ID])",
388
-                                                $option->ID()
389
-                                            ); // already escaped
390
-                                            $count++;
391
-                                            ?>
382
+											echo EEH_Form_Fields::hidden_input(
383
+												"question_options[{$count}][QST_ID])",
384
+												$option->question_ID()
385
+											); // already escaped
386
+											echo EEH_Form_Fields::hidden_input(
387
+												"question_options[{$count}][QSO_ID])",
388
+												$option->ID()
389
+											); // already escaped
390
+											$count++;
391
+											?>
392 392
                                             </td>
393 393
                                         </tr>
394 394
                                         <?php
395
-                                    }
396
-                                } else {
397
-                                    ?>
395
+									}
396
+								} else {
397
+									?>
398 398
                                     <tr class="question-option ee-options-sortable">
399 399
                                         <td class="option-value-cell">
400 400
                                             <input type="text"
@@ -418,8 +418,8 @@  discard block
 block discarded – undo
418 418
                                         </td>
419 419
                                     </tr>
420 420
                                     <?php
421
-                                }
422
-                                ?>
421
+								}
422
+								?>
423 423
                             </tbody>
424 424
                         </table>
425 425
                         <div class="ee-admin-button-row">
@@ -427,24 +427,24 @@  discard block
 block discarded – undo
427 427
                                 <?php esc_html_e('Add Another Answer Option', 'event_espresso') ?>
428 428
                             </a>
429 429
                             <?php echo EEH_Form_Fields::hidden_input(
430
-                                'question_options_count',
431
-                                $count
432
-                            ); // already escaped ?>
430
+								'question_options_count',
431
+								$count
432
+							); // already escaped ?>
433 433
                         </div>
434 434
                         <br />
435 435
 
436 436
                         <p class="description">
437 437
                             <?php esc_html_e(
438
-                                'Answer Options are the choices that you give people to select from for RADIO_BTN, CHECKBOX or DROPDOWN questions. The Value is a simple key that will be saved to the database and the description is optional. Note that values CANNOT contain any HTML, but descriptions can.',
439
-                                'event_espresso'
440
-                            ) ?>
438
+								'Answer Options are the choices that you give people to select from for RADIO_BTN, CHECKBOX or DROPDOWN questions. The Value is a simple key that will be saved to the database and the description is optional. Note that values CANNOT contain any HTML, but descriptions can.',
439
+								'event_espresso'
440
+							) ?>
441 441
                         </p>
442 442
                         <?php if ($has_answers) : ?>
443 443
                             <p class="description" style="color:#D54E21;">
444 444
                                 <?php esc_html_e(
445
-                                    'Answer values that are uneditable are this way because there are registrations in the database that have answers for this question.  If you need to correct a mistake, or edit an existing option value, then trash the existing one and create a new option with the changes.  This will ensure that the existing registrations that chose the original answer will preserve that answer.',
446
-                                    'event_espresso'
447
-                                ); ?>
445
+									'Answer values that are uneditable are this way because there are registrations in the database that have answers for this question.  If you need to correct a mistake, or edit an existing option value, then trash the existing one and create a new option with the changes.  This will ensure that the existing registrations that chose the original answer will preserve that answer.',
446
+									'event_espresso'
447
+								); ?>
448 448
                             </p>
449 449
                         <?php endif; ?>
450 450
                     </td>
@@ -459,38 +459,38 @@  discard block
 block discarded – undo
459 459
                     </th>
460 460
                     <td>
461 461
                         <?php
462
-                        $system_required   = ['fname', 'email'];
463
-                        $disabled_attr     = in_array($QST_system, $system_required) ? ' disabled="disabled"' : '';
464
-                        $required_on       = $question->get('QST_admin_only');
465
-                        $show_required_msg = $required_on ? '' : ' display:none;';
466
-                        $disabled_attr     = $required_on || ! empty($disabled_attr) ? ' disabled="disabled"' : '';
467
-                        $id                =
468
-                            ! empty($disabled_attr) && in_array($QST_system, $system_required) ? '_disabled' : '';
469
-                        $requiredOptions   = [
470
-                            ['text' => esc_html__('Optional', 'event_espresso'), 'id' => 0],
471
-                            ['text' => esc_html__('Required', 'event_espresso'), 'id' => 1],
472
-                        ];
473
-                        echo EEH_Form_Fields::select_input(
474
-                            'QST_required' . $id,
475
-                            $requiredOptions,
476
-                            $question->required(),
477
-                            'id="QST_required' . $id . '"' . $disabled_attr,
478
-                            'ee-input-width--small'
479
-                        ); // already escaped
480
-                        ?>
462
+						$system_required   = ['fname', 'email'];
463
+						$disabled_attr     = in_array($QST_system, $system_required) ? ' disabled="disabled"' : '';
464
+						$required_on       = $question->get('QST_admin_only');
465
+						$show_required_msg = $required_on ? '' : ' display:none;';
466
+						$disabled_attr     = $required_on || ! empty($disabled_attr) ? ' disabled="disabled"' : '';
467
+						$id                =
468
+							! empty($disabled_attr) && in_array($QST_system, $system_required) ? '_disabled' : '';
469
+						$requiredOptions   = [
470
+							['text' => esc_html__('Optional', 'event_espresso'), 'id' => 0],
471
+							['text' => esc_html__('Required', 'event_espresso'), 'id' => 1],
472
+						];
473
+						echo EEH_Form_Fields::select_input(
474
+							'QST_required' . $id,
475
+							$requiredOptions,
476
+							$question->required(),
477
+							'id="QST_required' . $id . '"' . $disabled_attr,
478
+							'ee-input-width--small'
479
+						); // already escaped
480
+						?>
481 481
                         <p id="required_toggled_on" class="description"
482 482
                                   style="color:#D54E21;<?php echo esc_attr($show_required_msg); ?>"
483 483
                             >
484 484
                                 <?php esc_html_e(
485
-                                    'Required is set to optional, and this field is disabled, because the question is Admin-Only.',
486
-                                    'event_espresso'
487
-                                ) ?>
485
+									'Required is set to optional, and this field is disabled, because the question is Admin-Only.',
486
+									'event_espresso'
487
+								) ?>
488 488
                         </p>
489 489
                         <p id="required_toggled_off" class="description" style="color:#D54E21; display: none;">
490 490
                                 <?php esc_html_e(
491
-                                    'Required option field is no longer disabled because the question is not Admin-Only',
492
-                                    'event_espresso'
493
-                                ) ?>
491
+									'Required option field is no longer disabled because the question is not Admin-Only',
492
+									'event_espresso'
493
+								) ?>
494 494
                         </p>
495 495
                         <?php if (! empty($disabled_attr) && in_array($QST_system, $system_required)) { ?>
496 496
                             <input id="QST_required"
@@ -524,8 +524,8 @@  discard block
 block discarded – undo
524 524
                     </td>
525 525
                 </tr>
526 526
                 <?php
527
-                do_action('AHEE__questions_main_meta_box__template__after_table_form_table', $question);
528
-                ?>
527
+				do_action('AHEE__questions_main_meta_box__template__after_table_form_table', $question);
528
+				?>
529 529
             </tbody>
530 530
         </table>
531 531
 
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
             . esc_html__('Did you know...', 'event_espresso'),
35 35
             '',
36 36
             'ee-status--info'
37
-        ) .
37
+        ).
38 38
         EEH_HTML::p(
39 39
             esc_html__(
40 40
                 'If you add a State/Province Select input immediately after this Country Select input when building your registration form, then the State/Province Select input options will change to correspond with the choice made in this input. So for example, choosing "United States" in this Country Select input will populate the State/Province Select input with just the state options for the United States.',
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
                                value="<?php echo esc_attr($question->get_f('QST_admin_label')); ?>"
89 89
                                <?php echo esc_attr($disabled_attr); ?>
90 90
                         />
91
-                        <?php if (! empty($QST_system)) { ?>
91
+                        <?php if ( ! empty($QST_system)) { ?>
92 92
                             <input id='QST_admin_label'
93 93
                                    name="QST_admin_label"
94 94
                                    type="hidden"
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
                             />
97 97
                         <?php } ?>
98 98
                         <br />
99
-                        <?php if (! empty($QST_system)) { ?>
99
+                        <?php if ( ! empty($QST_system)) { ?>
100 100
                             <p class="description" style="color:#D54E21;">
101 101
                                 <?php esc_html_e('System question! This field cannot be changed.', 'event_espresso') ?>
102 102
                             </p>
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
                         />
137 137
                         <br />
138 138
                             <?php
139
-                            if (! empty($QST_system)) { ?>
139
+                            if ( ! empty($QST_system)) { ?>
140 140
                                 <p class="description" style="color:#D54E21;">
141 141
                                     <?php esc_html_e(
142 142
                                         'System question! This field cannot be changed.',
@@ -167,14 +167,14 @@  discard block
 block discarded – undo
167 167
 
168 168
                         // Only display Confirm email for
169 169
                         if (empty($QST_system) || $QST_system !== EEM_Attendee::system_question_email_confirm) {
170
-                            unset($question_types[ EEM_Question::QST_type_email_confirm ]);
170
+                            unset($question_types[EEM_Question::QST_type_email_confirm]);
171 171
                         }
172 172
 
173 173
                         echo EEH_Form_Fields::select_input(
174
-                            'QST_type' . $id,
174
+                            'QST_type'.$id,
175 175
                             $question_types,
176 176
                             $question->type(),
177
-                            'id="QST_type' . $id . '"' . $disabled_attr
177
+                            'id="QST_type'.$id.'"'.$disabled_attr
178 178
                         ); // already escaped
179 179
                         if ($disabled) { ?>
180 180
                             <input id='QST_type'
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
                     </th>
212 212
                     <td>
213 213
                         <input id="QST_max"
214
-                            <?php echo $max_max === EE_INF ? '' : 'max="' . esc_attr($max_max) . '"'; ?>
214
+                            <?php echo $max_max === EE_INF ? '' : 'max="'.esc_attr($max_max).'"'; ?>
215 215
                                min="1"
216 216
                                name="QST_max"
217 217
                                type="number"
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
                                 <?php
318 318
                                 $count            = 0;
319 319
                                 $question_options = $question->options();
320
-                                if (! empty($question_options)) {
320
+                                if ( ! empty($question_options)) {
321 321
                                     foreach ($question_options as $option_id => $option) {
322 322
                                         $disabled_attr = $has_answers || $option->get('QSO_system')
323 323
                                             ? 'disabled'
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
                                                 />
364 364
                                             </td>
365 365
                                             <td>
366
-                                            <?php if (! $option->system()) { ?>
366
+                                            <?php if ( ! $option->system()) { ?>
367 367
                                                 <a class='button button--icon-only remove-option remove-item ee-aria-tooltip'
368 368
                                                    aria-label="<?php esc_html_e('click to delete this option', 'event_espresso') ?>"
369 369
                                                 >
@@ -471,10 +471,10 @@  discard block
 block discarded – undo
471 471
                             ['text' => esc_html__('Required', 'event_espresso'), 'id' => 1],
472 472
                         ];
473 473
                         echo EEH_Form_Fields::select_input(
474
-                            'QST_required' . $id,
474
+                            'QST_required'.$id,
475 475
                             $requiredOptions,
476 476
                             $question->required(),
477
-                            'id="QST_required' . $id . '"' . $disabled_attr,
477
+                            'id="QST_required'.$id.'"'.$disabled_attr,
478 478
                             'ee-input-width--small'
479 479
                         ); // already escaped
480 480
                         ?>
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
                                     'event_espresso'
493 493
                                 ) ?>
494 494
                         </p>
495
-                        <?php if (! empty($disabled_attr) && in_array($QST_system, $system_required)) { ?>
495
+                        <?php if ( ! empty($disabled_attr) && in_array($QST_system, $system_required)) { ?>
496 496
                             <input id="QST_required"
497 497
                                    name="QST_required"
498 498
                                    type='hidden'
Please login to merge, or discard this patch.
admin_pages/general_settings/General_Settings_Admin_Page.core.php 1 patch
Indentation   +1405 added lines, -1405 removed lines patch added patch discarded remove patch
@@ -20,1422 +20,1422 @@
 block discarded – undo
20 20
 class General_Settings_Admin_Page extends EE_Admin_Page
21 21
 {
22 22
 
23
-    /**
24
-     * @var EE_Core_Config
25
-     */
26
-    public $core_config;
27
-
28
-
29
-    /**
30
-     * Initialize basic properties.
31
-     */
32
-    protected function _init_page_props()
33
-    {
34
-        $this->page_slug        = GEN_SET_PG_SLUG;
35
-        $this->page_label       = GEN_SET_LABEL;
36
-        $this->_admin_base_url  = GEN_SET_ADMIN_URL;
37
-        $this->_admin_base_path = GEN_SET_ADMIN;
38
-    }
39
-
40
-
41
-    /**
42
-     * Set ajax hooks
43
-     */
44
-    protected function _ajax_hooks()
45
-    {
46
-        add_action('wp_ajax_espresso_display_country_settings', [$this, 'display_country_settings']);
47
-        add_action('wp_ajax_espresso_display_country_states', [$this, 'display_country_states']);
48
-        add_action('wp_ajax_espresso_delete_state', [$this, 'delete_state'], 10, 3);
49
-        add_action('wp_ajax_espresso_add_new_state', [$this, 'add_new_state']);
50
-    }
51
-
52
-
53
-    /**
54
-     * More page properties initialization.
55
-     */
56
-    protected function _define_page_props()
57
-    {
58
-        $this->_admin_page_title = GEN_SET_LABEL;
59
-        $this->_labels           = ['publishbox' => esc_html__('Update Settings', 'event_espresso')];
60
-    }
61
-
62
-
63
-    /**
64
-     * Set page routes property.
65
-     */
66
-    protected function _set_page_routes()
67
-    {
68
-        $this->_page_routes = [
69
-            'critical_pages'                => [
70
-                'func'       => '_espresso_page_settings',
71
-                'capability' => 'manage_options',
72
-            ],
73
-            'update_espresso_page_settings' => [
74
-                'func'       => '_update_espresso_page_settings',
75
-                'capability' => 'manage_options',
76
-                'noheader'   => true,
77
-            ],
78
-            'default'                       => [
79
-                'func'       => '_your_organization_settings',
80
-                'capability' => 'manage_options',
81
-            ],
82
-
83
-            'update_your_organization_settings' => [
84
-                'func'       => '_update_your_organization_settings',
85
-                'capability' => 'manage_options',
86
-                'noheader'   => true,
87
-            ],
88
-
89
-            'admin_option_settings' => [
90
-                'func'       => '_admin_option_settings',
91
-                'capability' => 'manage_options',
92
-            ],
93
-
94
-            'update_admin_option_settings' => [
95
-                'func'       => '_update_admin_option_settings',
96
-                'capability' => 'manage_options',
97
-                'noheader'   => true,
98
-            ],
99
-
100
-            'country_settings' => [
101
-                'func'       => '_country_settings',
102
-                'capability' => 'manage_options',
103
-            ],
104
-
105
-            'update_country_settings' => [
106
-                'func'       => '_update_country_settings',
107
-                'capability' => 'manage_options',
108
-                'noheader'   => true,
109
-            ],
110
-
111
-            'display_country_settings' => [
112
-                'func'       => 'display_country_settings',
113
-                'capability' => 'manage_options',
114
-                'noheader'   => true,
115
-            ],
116
-
117
-            'add_new_state' => [
118
-                'func'       => 'add_new_state',
119
-                'capability' => 'manage_options',
120
-                'noheader'   => true,
121
-            ],
122
-
123
-            'delete_state'            => [
124
-                'func'       => 'delete_state',
125
-                'capability' => 'manage_options',
126
-                'noheader'   => true,
127
-            ],
128
-            'privacy_settings'        => [
129
-                'func'       => 'privacySettings',
130
-                'capability' => 'manage_options',
131
-            ],
132
-            'update_privacy_settings' => [
133
-                'func'               => 'updatePrivacySettings',
134
-                'capability'         => 'manage_options',
135
-                'noheader'           => true,
136
-                'headers_sent_route' => 'privacy_settings',
137
-            ],
138
-        ];
139
-    }
140
-
141
-
142
-    /**
143
-     * Set page configuration property
144
-     */
145
-    protected function _set_page_config()
146
-    {
147
-        $this->_page_config = [
148
-            'critical_pages'        => [
149
-                'nav'           => [
150
-                    'label' => esc_html__('Critical Pages', 'event_espresso'),
151
-                    'order' => 50,
152
-                ],
153
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
154
-                'help_tabs'     => [
155
-                    'general_settings_critical_pages_help_tab' => [
156
-                        'title'    => esc_html__('Critical Pages', 'event_espresso'),
157
-                        'filename' => 'general_settings_critical_pages',
158
-                    ],
159
-                ],
160
-                'require_nonce' => false,
161
-            ],
162
-            'default'               => [
163
-                'nav'           => [
164
-                    'label' => esc_html__('Your Organization', 'event_espresso'),
165
-                    'order' => 20,
166
-                ],
167
-                'help_tabs'     => [
168
-                    'general_settings_your_organization_help_tab' => [
169
-                        'title'    => esc_html__('Your Organization', 'event_espresso'),
170
-                        'filename' => 'general_settings_your_organization',
171
-                    ],
172
-                ],
173
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
174
-                'require_nonce' => false,
175
-            ],
176
-            'admin_option_settings' => [
177
-                'nav'           => [
178
-                    'label' => esc_html__('Admin Options', 'event_espresso'),
179
-                    'order' => 60,
180
-                ],
181
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
182
-                'help_tabs'     => [
183
-                    'general_settings_admin_options_help_tab' => [
184
-                        'title'    => esc_html__('Admin Options', 'event_espresso'),
185
-                        'filename' => 'general_settings_admin_options',
186
-                    ],
187
-                ],
188
-                'require_nonce' => false,
189
-            ],
190
-            'country_settings'      => [
191
-                'nav'           => [
192
-                    'label' => esc_html__('Countries', 'event_espresso'),
193
-                    'order' => 70,
194
-                ],
195
-                'help_tabs'     => [
196
-                    'general_settings_countries_help_tab' => [
197
-                        'title'    => esc_html__('Countries', 'event_espresso'),
198
-                        'filename' => 'general_settings_countries',
199
-                    ],
200
-                ],
201
-                'require_nonce' => false,
202
-            ],
203
-            'privacy_settings'      => [
204
-                'nav'           => [
205
-                    'label' => esc_html__('Privacy', 'event_espresso'),
206
-                    'order' => 80,
207
-                ],
208
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
209
-                'require_nonce' => false,
210
-            ],
211
-        ];
212
-    }
213
-
214
-
215
-    protected function _add_screen_options()
216
-    {
217
-    }
218
-
219
-
220
-    protected function _add_feature_pointers()
221
-    {
222
-    }
223
-
224
-
225
-    /**
226
-     * Enqueue global scripts and styles for all routes in the General Settings Admin Pages.
227
-     */
228
-    public function load_scripts_styles()
229
-    {
230
-        // styles
231
-        wp_enqueue_style('espresso-ui-theme');
232
-        // scripts
233
-        wp_enqueue_script('ee_admin_js');
234
-    }
235
-
236
-
237
-    /**
238
-     * Execute logic running on `admin_init`
239
-     */
240
-    public function admin_init()
241
-    {
242
-        $this->core_config = EE_Registry::instance()->CFG->core;
243
-
244
-        EE_Registry::$i18n_js_strings['invalid_server_response'] = wp_strip_all_tags(
245
-            esc_html__(
246
-                '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.',
247
-                'event_espresso'
248
-            )
249
-        );
250
-        EE_Registry::$i18n_js_strings['error_occurred']          = wp_strip_all_tags(
251
-            esc_html__(
252
-                'An error occurred! Please refresh the page and try again.',
253
-                'event_espresso'
254
-            )
255
-        );
256
-        EE_Registry::$i18n_js_strings['confirm_delete_state']    = wp_strip_all_tags(
257
-            esc_html__(
258
-                'Are you sure you want to delete this State / Province?',
259
-                'event_espresso'
260
-            )
261
-        );
262
-        EE_Registry::$i18n_js_strings['ajax_url']                = admin_url(
263
-            'admin-ajax.php?page=espresso_general_settings',
264
-            is_ssl() ? 'https://' : 'http://'
265
-        );
266
-    }
267
-
268
-
269
-    public function admin_notices()
270
-    {
271
-    }
272
-
273
-
274
-    public function admin_footer_scripts()
275
-    {
276
-    }
277
-
278
-
279
-    /**
280
-     * Enqueue scripts and styles for the default route.
281
-     */
282
-    public function load_scripts_styles_default()
283
-    {
284
-        // styles
285
-        wp_enqueue_style('thickbox');
286
-        // scripts
287
-        wp_enqueue_script('media-upload');
288
-        wp_enqueue_script('thickbox');
289
-        wp_register_script(
290
-            'organization_settings',
291
-            GEN_SET_ASSETS_URL . 'your_organization_settings.js',
292
-            ['jquery', 'media-upload', 'thickbox'],
293
-            EVENT_ESPRESSO_VERSION,
294
-            true
295
-        );
296
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
297
-        wp_enqueue_script('organization_settings');
298
-        wp_enqueue_style('organization-css');
299
-        $confirm_image_delete = [
300
-            'text' => wp_strip_all_tags(
301
-                esc_html__(
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
-        ];
307
-        wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
308
-    }
309
-
310
-
311
-    /**
312
-     * Enqueue scripts and styles for the country settings route.
313
-     */
314
-    public function load_scripts_styles_country_settings()
315
-    {
316
-        // scripts
317
-        wp_register_script(
318
-            'gen_settings_countries',
319
-            GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
320
-            ['ee_admin_js'],
321
-            EVENT_ESPRESSO_VERSION,
322
-            true
323
-        );
324
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
325
-        wp_enqueue_script('gen_settings_countries');
326
-        wp_enqueue_style('organization-css');
327
-    }
328
-
329
-
330
-    /*************        Espresso Pages        *************/
331
-    /**
332
-     * _espresso_page_settings
333
-     *
334
-     * @throws EE_Error
335
-     * @throws DomainException
336
-     * @throws DomainException
337
-     * @throws InvalidDataTypeException
338
-     * @throws InvalidArgumentException
339
-     */
340
-    protected function _espresso_page_settings()
341
-    {
342
-        // Check to make sure all of the main pages are set up properly,
343
-        // if not create the default pages and display an admin notice
344
-        EEH_Activation::verify_default_pages_exist();
345
-        $this->_transient_garbage_collection();
346
-
347
-        $this->_template_args['values']             = $this->_yes_no_values;
348
-
349
-        $this->_template_args['reg_page_id']        = $this->core_config->reg_page_id ?? null;
350
-        $this->_template_args['reg_page_obj']       = isset($this->core_config->reg_page_id)
351
-            ? get_post($this->core_config->reg_page_id)
352
-            : false;
353
-
354
-        $this->_template_args['txn_page_id']        = $this->core_config->txn_page_id ?? null;
355
-        $this->_template_args['txn_page_obj']       = isset($this->core_config->txn_page_id)
356
-            ? get_post($this->core_config->txn_page_id)
357
-            : false;
358
-
359
-        $this->_template_args['thank_you_page_id']  = $this->core_config->thank_you_page_id ?? null;
360
-        $this->_template_args['thank_you_page_obj'] = isset($this->core_config->thank_you_page_id)
361
-            ? get_post($this->core_config->thank_you_page_id)
362
-            : false;
363
-
364
-        $this->_template_args['cancel_page_id']     = $this->core_config->cancel_page_id ?? null;
365
-        $this->_template_args['cancel_page_obj']    = isset($this->core_config->cancel_page_id)
366
-            ? get_post($this->core_config->cancel_page_id)
367
-            : false;
368
-
369
-        $this->_set_add_edit_form_tags('update_espresso_page_settings');
370
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
371
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
372
-            GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
373
-            $this->_template_args,
374
-            true
375
-        );
376
-        $this->display_admin_page_with_sidebar();
377
-    }
378
-
379
-
380
-    /**
381
-     * Handler for updating espresso page settings.
382
-     *
383
-     * @throws EE_Error
384
-     */
385
-    protected function _update_espresso_page_settings()
386
-    {
387
-        // capture incoming request data && set page IDs
388
-        $this->core_config->reg_page_id       = $this->request->getRequestParam(
389
-            'reg_page_id',
390
-            $this->core_config->reg_page_id,
391
-            DataType::INT
392
-        );
393
-        $this->core_config->txn_page_id       = $this->request->getRequestParam(
394
-            'txn_page_id',
395
-            $this->core_config->txn_page_id,
396
-            DataType::INT
397
-        );
398
-        $this->core_config->thank_you_page_id = $this->request->getRequestParam(
399
-            'thank_you_page_id',
400
-            $this->core_config->thank_you_page_id,
401
-            DataType::INT
402
-        );
403
-        $this->core_config->cancel_page_id    = $this->request->getRequestParam(
404
-            'cancel_page_id',
405
-            $this->core_config->cancel_page_id,
406
-            DataType::INT
407
-        );
408
-
409
-        $this->core_config = apply_filters(
410
-            'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core',
411
-            $this->core_config,
412
-            $this->request->requestParams()
413
-        );
414
-
415
-        $what = esc_html__('Critical Pages & Shortcodes', 'event_espresso');
416
-        $this->_redirect_after_action(
417
-            $this->_update_espresso_configuration(
418
-                $what,
419
-                $this->core_config,
420
-                __FILE__,
421
-                __FUNCTION__,
422
-                __LINE__
423
-            ),
424
-            $what,
425
-            '',
426
-            [
427
-                'action' => 'critical_pages',
428
-            ],
429
-            true
430
-        );
431
-    }
432
-
433
-
434
-    /*************        Your Organization        *************/
435
-
436
-
437
-    /**
438
-     * @throws DomainException
439
-     * @throws EE_Error
440
-     * @throws InvalidArgumentException
441
-     * @throws InvalidDataTypeException
442
-     * @throws InvalidInterfaceException
443
-     */
444
-    protected function _your_organization_settings()
445
-    {
446
-        $this->_template_args['admin_page_content'] = '';
447
-        try {
448
-            /** @var OrganizationSettings $organization_settings_form */
449
-            $organization_settings_form = $this->loader->getShared(OrganizationSettings::class);
450
-
451
-            $this->_template_args['admin_page_content'] = EEH_HTML::div(
452
-                $organization_settings_form->display(),
453
-                '',
454
-                'padding'
455
-            );
456
-        } catch (Exception $e) {
457
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
458
-        }
459
-        $this->_set_add_edit_form_tags('update_your_organization_settings');
460
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
461
-        $this->display_admin_page_with_sidebar();
462
-    }
463
-
464
-
465
-    /**
466
-     * Handler for updating organization settings.
467
-     *
468
-     * @throws EE_Error
469
-     */
470
-    protected function _update_your_organization_settings()
471
-    {
472
-        try {
473
-            /** @var OrganizationSettings $organization_settings_form */
474
-            $organization_settings_form = $this->loader->getShared(OrganizationSettings::class);
475
-
476
-            $success = $organization_settings_form->process($this->request->requestParams());
477
-
478
-            EE_Registry::instance()->CFG = apply_filters(
479
-                'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG',
480
-                EE_Registry::instance()->CFG
481
-            );
482
-        } catch (Exception $e) {
483
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
484
-            $success = false;
485
-        }
486
-
487
-        if ($success) {
488
-            $success = $this->_update_espresso_configuration(
489
-                esc_html__('Your Organization Settings', 'event_espresso'),
490
-                EE_Registry::instance()->CFG,
491
-                __FILE__,
492
-                __FUNCTION__,
493
-                __LINE__
494
-            );
495
-        }
496
-
497
-        $this->_redirect_after_action($success, '', '', ['action' => 'default'], true);
498
-    }
499
-
500
-
501
-
502
-    /*************        Admin Options        *************/
503
-
504
-
505
-    /**
506
-     * _admin_option_settings
507
-     *
508
-     * @throws EE_Error
509
-     * @throws LogicException
510
-     */
511
-    protected function _admin_option_settings()
512
-    {
513
-        $this->_template_args['admin_page_content'] = '';
514
-        try {
515
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
516
-            // still need this for the old school form in Extend_General_Settings_Admin_Page
517
-            $this->_template_args['values'] = $this->_yes_no_values;
518
-            // also need to account for the do_action that was in the old template
519
-            $admin_options_settings_form->setTemplateArgs($this->_template_args);
520
-            $this->_template_args['admin_page_content'] = EEH_HTML::div(
521
-                $admin_options_settings_form->display(),
522
-                '',
523
-                'padding'
524
-            );
525
-        } catch (Exception $e) {
526
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
527
-        }
528
-        $this->_set_add_edit_form_tags('update_admin_option_settings');
529
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
530
-        $this->display_admin_page_with_sidebar();
531
-    }
532
-
533
-
534
-    /**
535
-     * _update_admin_option_settings
536
-     *
537
-     * @throws EE_Error
538
-     * @throws InvalidDataTypeException
539
-     * @throws InvalidFormSubmissionException
540
-     * @throws InvalidArgumentException
541
-     * @throws LogicException
542
-     */
543
-    protected function _update_admin_option_settings()
544
-    {
545
-        try {
546
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
547
-            $admin_options_settings_form->process(
548
-                $this->request->getRequestParam(
549
-                    $admin_options_settings_form->slug(),
550
-                    [],
551
-                    DataType::STRING,
552
-                    true
553
-                )
554
-            );
555
-            EE_Registry::instance()->CFG->admin = apply_filters(
556
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
557
-                EE_Registry::instance()->CFG->admin
558
-            );
559
-        } catch (Exception $e) {
560
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
561
-        }
562
-        $this->_redirect_after_action(
563
-            apply_filters(
564
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
565
-                $this->_update_espresso_configuration(
566
-                    esc_html__('Admin Options', 'event_espresso'),
567
-                    EE_Registry::instance()->CFG->admin,
568
-                    __FILE__,
569
-                    __FUNCTION__,
570
-                    __LINE__
571
-                )
572
-            ),
573
-            esc_html__('Admin Options', 'event_espresso'),
574
-            'updated',
575
-            ['action' => 'admin_option_settings']
576
-        );
577
-    }
578
-
579
-
580
-    /*************        Countries        *************/
581
-
582
-
583
-    /**
584
-     * @param string|null $default
585
-     * @return string
586
-     */
587
-    protected function getCountryISO(?string $default = null): string
588
-    {
589
-        $default = $default ?? $this->getCountryIsoForSite();
590
-        $CNT_ISO = $this->request->getRequestParam('country', $default);
591
-        return strtoupper($CNT_ISO);
592
-    }
593
-
594
-
595
-    /**
596
-     * @return string
597
-     */
598
-    protected function getCountryIsoForSite(): string
599
-    {
600
-        return ! empty(EE_Registry::instance()->CFG->organization->CNT_ISO)
601
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
602
-            : 'US';
603
-    }
604
-
605
-
606
-    /**
607
-     * @param string          $CNT_ISO
608
-     * @param EE_Country|null $country
609
-     * @return EE_Base_Class|EE_Country
610
-     * @throws EE_Error
611
-     * @throws InvalidArgumentException
612
-     * @throws InvalidDataTypeException
613
-     * @throws InvalidInterfaceException
614
-     * @throws ReflectionException
615
-     */
616
-    protected function verifyOrGetCountryFromIso(string $CNT_ISO, ?EE_Country $country = null)
617
-    {
618
-        /** @var EE_Country $country */
619
-        return $country instanceof EE_Country && $country->ID() === $CNT_ISO
620
-            ? $country
621
-            : EEM_Country::instance()->get_one_by_ID($CNT_ISO);
622
-    }
623
-
624
-
625
-    /**
626
-     * Output Country Settings view.
627
-     *
628
-     * @throws DomainException
629
-     * @throws EE_Error
630
-     * @throws InvalidArgumentException
631
-     * @throws InvalidDataTypeException
632
-     * @throws InvalidInterfaceException
633
-     * @throws ReflectionException
634
-     */
635
-    protected function _country_settings()
636
-    {
637
-        $CNT_ISO = $this->getCountryISO();
638
-
639
-        $this->_template_args['values']    = $this->_yes_no_values;
640
-        $this->_template_args['countries'] = new EE_Question_Form_Input(
641
-            EE_Question::new_instance(
642
-                [
643
-                  'QST_ID'           => 0,
644
-                  'QST_display_text' => esc_html__('Select Country', 'event_espresso'),
645
-                  'QST_system'       => 'admin-country',
646
-                ]
647
-            ),
648
-            EE_Answer::new_instance(
649
-                [
650
-                    'ANS_ID'    => 0,
651
-                    'ANS_value' => $CNT_ISO,
652
-                ]
653
-            ),
654
-            [
655
-                'input_id'       => 'country',
656
-                'input_name'     => 'country',
657
-                'input_prefix'   => '',
658
-                'append_qstn_id' => false,
659
-            ]
660
-        );
661
-
662
-        $country = $this->verifyOrGetCountryFromIso($CNT_ISO);
663
-        add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10);
664
-        add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10);
665
-        $this->_template_args['country_details_settings'] = $this->display_country_settings(
666
-            $country->ID(),
667
-            $country
668
-        );
669
-        $this->_template_args['country_states_settings']  = $this->display_country_states(
670
-            $country->ID(),
671
-            $country
672
-        );
673
-        $this->_template_args['CNT_name_for_site']        = $country->name();
674
-
675
-        $this->_set_add_edit_form_tags('update_country_settings');
676
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
677
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
678
-            GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
679
-            $this->_template_args,
680
-            true
681
-        );
682
-        $this->display_admin_page_with_no_sidebar();
683
-    }
684
-
685
-
686
-    /**
687
-     * @param string          $CNT_ISO
688
-     * @param EE_Country|null $country
689
-     * @return string
690
-     * @throws DomainException
691
-     * @throws EE_Error
692
-     * @throws InvalidArgumentException
693
-     * @throws InvalidDataTypeException
694
-     * @throws InvalidInterfaceException
695
-     * @throws ReflectionException
696
-     */
697
-    public function display_country_settings(string $CNT_ISO = '', ?EE_Country $country = null): string
698
-    {
699
-        $CNT_ISO          = $this->getCountryISO($CNT_ISO);
700
-        $CNT_ISO_for_site = $this->getCountryIsoForSite();
701
-
702
-        if (! $CNT_ISO) {
703
-            return '';
704
-        }
705
-
706
-        // for ajax
707
-        remove_all_filters('FHEE__EEH_Form_Fields__label_html');
708
-        remove_all_filters('FHEE__EEH_Form_Fields__input_html');
709
-        add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10, 2);
710
-        add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10, 2);
711
-        $country                                  = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
712
-        $CNT_cur_disabled                         = $CNT_ISO !== $CNT_ISO_for_site;
713
-        $this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled;
714
-
715
-        $country_input_types            = [
716
-            'CNT_active'      => [
717
-                'type'             => 'RADIO_BTN',
718
-                'input_name'       => "cntry[$CNT_ISO]",
719
-                'class'            => '',
720
-                'options'          => $this->_yes_no_values,
721
-                'use_desc_4_label' => true,
722
-            ],
723
-            'CNT_ISO'         => [
724
-                'type'       => 'TEXT',
725
-                'input_name' => "cntry[$CNT_ISO]",
726
-                'class'      => 'ee-input-width--small',
727
-            ],
728
-            'CNT_ISO3'        => [
729
-                'type'       => 'TEXT',
730
-                'input_name' => "cntry[$CNT_ISO]",
731
-                'class'      => 'ee-input-width--small',
732
-            ],
733
-            // 'RGN_ID'          => [
734
-            //     'type'       => 'TEXT',
735
-            //     'input_name' => "cntry[$CNT_ISO]",
736
-            //     'class'      => 'ee-input-width--small',
737
-            // ],
738
-            'CNT_name'        => [
739
-                'type'       => 'TEXT',
740
-                'input_name' => "cntry[$CNT_ISO]",
741
-                'class'      => 'ee-input-width--big',
742
-            ],
743
-            'CNT_cur_code'    => [
744
-                'type'       => 'TEXT',
745
-                'input_name' => "cntry[$CNT_ISO]",
746
-                'class'      => 'ee-input-width--small',
747
-                'disabled'   => $CNT_cur_disabled,
748
-            ],
749
-            'CNT_cur_single'  => [
750
-                'type'       => 'TEXT',
751
-                'input_name' => "cntry[$CNT_ISO]",
752
-                'class'      => 'ee-input-width--reg',
753
-                'disabled'   => $CNT_cur_disabled,
754
-            ],
755
-            'CNT_cur_plural'  => [
756
-                'type'       => 'TEXT',
757
-                'input_name' => "cntry[$CNT_ISO]",
758
-                'class'      => 'ee-input-width--reg',
759
-                'disabled'   => $CNT_cur_disabled,
760
-            ],
761
-            'CNT_cur_sign'    => [
762
-                'type'         => 'TEXT',
763
-                'input_name'   => "cntry[$CNT_ISO]",
764
-                'class'        => 'ee-input-width--small',
765
-                'htmlentities' => false,
766
-                'disabled'     => $CNT_cur_disabled,
767
-            ],
768
-            'CNT_cur_sign_b4' => [
769
-                'type'             => 'RADIO_BTN',
770
-                'input_name'       => "cntry[$CNT_ISO]",
771
-                'class'            => '',
772
-                'options'          => $this->_yes_no_values,
773
-                'use_desc_4_label' => true,
774
-                'disabled'         => $CNT_cur_disabled,
775
-            ],
776
-            'CNT_cur_dec_plc' => [
777
-                'type'       => 'RADIO_BTN',
778
-                'input_name' => "cntry[$CNT_ISO]",
779
-                'class'      => '',
780
-                'options'    => [
781
-                    ['id' => 0, 'text' => ''],
782
-                    ['id' => 1, 'text' => ''],
783
-                    ['id' => 2, 'text' => ''],
784
-                    ['id' => 3, 'text' => ''],
785
-                ],
786
-                'disabled'   => $CNT_cur_disabled,
787
-            ],
788
-            'CNT_cur_dec_mrk' => [
789
-                'type'             => 'RADIO_BTN',
790
-                'input_name'       => "cntry[$CNT_ISO]",
791
-                'class'            => '',
792
-                'options'          => [
793
-                    [
794
-                        'id'   => ',',
795
-                        'text' => esc_html__(', (comma)', 'event_espresso'),
796
-                    ],
797
-                    ['id' => '.', 'text' => esc_html__('. (decimal)', 'event_espresso')],
798
-                ],
799
-                'use_desc_4_label' => true,
800
-                'disabled'         => $CNT_cur_disabled,
801
-            ],
802
-            'CNT_cur_thsnds'  => [
803
-                'type'             => 'RADIO_BTN',
804
-                'input_name'       => "cntry[$CNT_ISO]",
805
-                'class'            => '',
806
-                'options'          => [
807
-                    [
808
-                        'id'   => ',',
809
-                        'text' => esc_html__(', (comma)', 'event_espresso'),
810
-                    ],
811
-                    [
812
-                        'id'   => '.',
813
-                        'text' => esc_html__('. (decimal)', 'event_espresso'),
814
-                    ],
815
-                    [
816
-                        'id'   => '&nbsp;',
817
-                        'text' => esc_html__('(space)', 'event_espresso'),
818
-                    ],
819
-                ],
820
-                'use_desc_4_label' => true,
821
-                'disabled'         => $CNT_cur_disabled,
822
-            ],
823
-            'CNT_tel_code'    => [
824
-                'type'       => 'TEXT',
825
-                'input_name' => "cntry[$CNT_ISO]",
826
-                'class'      => 'ee-input-width--small',
827
-            ],
828
-            'CNT_is_EU'       => [
829
-                'type'             => 'RADIO_BTN',
830
-                'input_name'       => "cntry[$CNT_ISO]",
831
-                'class'            => '',
832
-                'options'          => $this->_yes_no_values,
833
-                'use_desc_4_label' => true,
834
-            ],
835
-        ];
836
-        $this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object(
837
-            $country,
838
-            $country_input_types
839
-        );
840
-        $country_details_settings       = EEH_Template::display_template(
841
-            GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
842
-            $this->_template_args,
843
-            true
844
-        );
845
-
846
-        if (defined('DOING_AJAX')) {
847
-            $notices = EE_Error::get_notices(false, false, false);
848
-            echo wp_json_encode(
849
-                [
850
-                    'return_data' => $country_details_settings,
851
-                    'success'     => $notices['success'],
852
-                    'errors'      => $notices['errors'],
853
-                ]
854
-            );
855
-            die();
856
-        }
857
-        return $country_details_settings;
858
-    }
859
-
860
-
861
-    /**
862
-     * @param string          $CNT_ISO
863
-     * @param EE_Country|null $country
864
-     * @return string
865
-     * @throws DomainException
866
-     * @throws EE_Error
867
-     * @throws InvalidArgumentException
868
-     * @throws InvalidDataTypeException
869
-     * @throws InvalidInterfaceException
870
-     * @throws ReflectionException
871
-     */
872
-    public function display_country_states(string $CNT_ISO = '', ?EE_Country $country = null): string
873
-    {
874
-        $CNT_ISO = $this->getCountryISO($CNT_ISO);
875
-        if (! $CNT_ISO) {
876
-            return '';
877
-        }
878
-        // for ajax
879
-        remove_all_filters('FHEE__EEH_Form_Fields__label_html');
880
-        remove_all_filters('FHEE__EEH_Form_Fields__input_html');
881
-        add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'state_form_field_label_wrap'], 10, 2);
882
-        add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'state_form_field_input__wrap'], 10);
883
-        $states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
884
-        if (empty($states)) {
885
-            /** @var EventEspresso\core\services\address\CountrySubRegionDao $countrySubRegionDao */
886
-            $countrySubRegionDao = $this->loader->getShared(
887
-                'EventEspresso\core\services\address\CountrySubRegionDao'
888
-            );
889
-            if ($countrySubRegionDao instanceof EventEspresso\core\services\address\CountrySubRegionDao) {
890
-                $country = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
891
-                if ($countrySubRegionDao->saveCountrySubRegions($country)) {
892
-                    $states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
893
-                }
894
-            }
895
-        }
896
-        if (is_array($states)) {
897
-            foreach ($states as $STA_ID => $state) {
898
-                if ($state instanceof EE_State) {
899
-                    $inputs = EE_Question_Form_Input::generate_question_form_inputs_for_object(
900
-                        $state,
901
-                        [
902
-                            'STA_abbrev' => [
903
-                                'type'             => 'TEXT',
904
-                                'label'            => esc_html__('Code', 'event_espresso'),
905
-                                'input_name'       => "states[$STA_ID]",
906
-                                'class'            => 'ee-input-width--tiny',
907
-                                'add_mobile_label' => true,
908
-                            ],
909
-                            'STA_name'   => [
910
-                                'type'             => 'TEXT',
911
-                                'label'            => esc_html__('Name', 'event_espresso'),
912
-                                'input_name'       => "states[$STA_ID]",
913
-                                'class'            => 'ee-input-width--big',
914
-                                'add_mobile_label' => true,
915
-                            ],
916
-                            'STA_active' => [
917
-                                'type'             => 'RADIO_BTN',
918
-                                'label'            => esc_html__('State Appears in Dropdown Select Lists', 'event_espresso'),
919
-                                'input_name'       => "states[$STA_ID]",
920
-                                'options'          => $this->_yes_no_values,
921
-                                'use_desc_4_label' => true,
922
-                                'add_mobile_label' => true,
923
-                            ],
924
-                        ]
925
-                    );
926
-
927
-                    $delete_state_url = EE_Admin_Page::add_query_args_and_nonce(
928
-                        [
929
-                            'action'     => 'delete_state',
930
-                            'STA_ID'     => $STA_ID,
931
-                            'CNT_ISO'    => $CNT_ISO,
932
-                            'STA_abbrev' => $state->abbrev(),
933
-                        ],
934
-                        GEN_SET_ADMIN_URL
935
-                    );
936
-
937
-                    $this->_template_args['states'][$STA_ID]['inputs']           = $inputs;
938
-                    $this->_template_args['states'][$STA_ID]['delete_state_url'] = $delete_state_url;
939
-                }
940
-            }
941
-        } else {
942
-            $this->_template_args['states'] = false;
943
-        }
944
-
945
-        $this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(
946
-            ['action' => 'add_new_state'],
947
-            GEN_SET_ADMIN_URL
948
-        );
949
-
950
-        $state_details_settings = EEH_Template::display_template(
951
-            GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
952
-            $this->_template_args,
953
-            true
954
-        );
955
-
956
-        if (defined('DOING_AJAX')) {
957
-            $notices = EE_Error::get_notices(false, false, false);
958
-            echo wp_json_encode(
959
-                [
960
-                    'return_data' => $state_details_settings,
961
-                    'success'     => $notices['success'],
962
-                    'errors'      => $notices['errors'],
963
-                ]
964
-            );
965
-            die();
966
-        }
967
-        return $state_details_settings;
968
-    }
969
-
970
-
971
-    /**
972
-     * @return void
973
-     * @throws EE_Error
974
-     * @throws InvalidArgumentException
975
-     * @throws InvalidDataTypeException
976
-     * @throws InvalidInterfaceException
977
-     * @throws ReflectionException
978
-     */
979
-    public function add_new_state()
980
-    {
981
-        $success = true;
982
-        $CNT_ISO = $this->getCountryISO('');
983
-        if (! $CNT_ISO) {
984
-            EE_Error::add_error(
985
-                esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
986
-                __FILE__,
987
-                __FUNCTION__,
988
-                __LINE__
989
-            );
990
-            $success = false;
991
-        }
992
-        $STA_abbrev = $this->request->getRequestParam('STA_abbrev');
993
-        if (! $STA_abbrev) {
994
-            EE_Error::add_error(
995
-                esc_html__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
996
-                __FILE__,
997
-                __FUNCTION__,
998
-                __LINE__
999
-            );
1000
-            $success = false;
1001
-        }
1002
-        $STA_name = $this->request->getRequestParam('STA_name');
1003
-        if (! $STA_name) {
1004
-            EE_Error::add_error(
1005
-                esc_html__('No State name or an invalid State name was received.', 'event_espresso'),
1006
-                __FILE__,
1007
-                __FUNCTION__,
1008
-                __LINE__
1009
-            );
1010
-            $success = false;
1011
-        }
1012
-
1013
-        if ($success) {
1014
-            $cols_n_values = [
1015
-                'CNT_ISO'    => $CNT_ISO,
1016
-                'STA_abbrev' => $STA_abbrev,
1017
-                'STA_name'   => $STA_name,
1018
-                'STA_active' => true,
1019
-            ];
1020
-            $success       = EEM_State::instance()->insert($cols_n_values);
1021
-            EE_Error::add_success(esc_html__('The State was added successfully.', 'event_espresso'));
1022
-        }
1023
-
1024
-        if (defined('DOING_AJAX')) {
1025
-            $notices = EE_Error::get_notices(false, false, false);
1026
-            echo wp_json_encode(array_merge($notices, ['return_data' => $CNT_ISO]));
1027
-            die();
1028
-        }
1029
-        $this->_redirect_after_action(
1030
-            $success,
1031
-            esc_html__('State', 'event_espresso'),
1032
-            'added',
1033
-            ['action' => 'country_settings']
1034
-        );
1035
-    }
1036
-
1037
-
1038
-    /**
1039
-     * @return void
1040
-     * @throws EE_Error
1041
-     * @throws InvalidArgumentException
1042
-     * @throws InvalidDataTypeException
1043
-     * @throws InvalidInterfaceException
1044
-     * @throws ReflectionException
1045
-     */
1046
-    public function delete_state()
1047
-    {
1048
-        $CNT_ISO    = $this->getCountryISO();
1049
-        $STA_ID     = $this->request->getRequestParam('STA_ID');
1050
-        $STA_abbrev = $this->request->getRequestParam('STA_abbrev');
1051
-
1052
-        if (! $STA_ID) {
1053
-            EE_Error::add_error(
1054
-                esc_html__('No State ID or an invalid State ID was received.', 'event_espresso'),
1055
-                __FILE__,
1056
-                __FUNCTION__,
1057
-                __LINE__
1058
-            );
1059
-            return;
1060
-        }
1061
-
1062
-        $success = EEM_State::instance()->delete_by_ID($STA_ID);
1063
-        if ($success !== false) {
1064
-            do_action('AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
1065
-                      $CNT_ISO,
1066
-                      $STA_ID,
1067
-                      ['STA_abbrev' => $STA_abbrev]);
1068
-            EE_Error::add_success(esc_html__('The State was deleted successfully.', 'event_espresso'));
1069
-        }
1070
-        if (defined('DOING_AJAX')) {
1071
-            $notices                = EE_Error::get_notices(false);
1072
-            $notices['return_data'] = true;
1073
-            echo wp_json_encode($notices);
1074
-            die();
1075
-        }
1076
-        $this->_redirect_after_action(
1077
-            $success,
1078
-            esc_html__('State', 'event_espresso'),
1079
-            'deleted',
1080
-            ['action' => 'country_settings']
1081
-        );
1082
-    }
1083
-
1084
-
1085
-    /**
1086
-     * @return void
1087
-     * @throws EE_Error
1088
-     * @throws InvalidArgumentException
1089
-     * @throws InvalidDataTypeException
1090
-     * @throws InvalidInterfaceException
1091
-     * @throws ReflectionException
1092
-     */
1093
-    protected function _update_country_settings()
1094
-    {
1095
-        $CNT_ISO = $this->getCountryISO();
1096
-        if (! $CNT_ISO) {
1097
-            EE_Error::add_error(
1098
-                esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1099
-                __FILE__,
1100
-                __FUNCTION__,
1101
-                __LINE__
1102
-            );
1103
-            return;
1104
-        }
1105
-
1106
-        $country = $this->verifyOrGetCountryFromIso($CNT_ISO);
1107
-
1108
-        $cols_n_values                    = [];
1109
-        $cols_n_values['CNT_ISO3']        = strtoupper(
1110
-            $this->request->getRequestParam('cntry', '', $country->ISO3())
1111
-        );
1112
-        $cols_n_values['CNT_name']        =
1113
-            $this->request->getRequestParam("cntry[$CNT_ISO][CNT_name]", $country->name());
1114
-        $cols_n_values['CNT_cur_code']    = strtoupper(
1115
-            $this->request->getRequestParam(
1116
-                "cntry[$CNT_ISO][CNT_cur_code]",
1117
-                $country->currency_code()
1118
-            )
1119
-        );
1120
-        $cols_n_values['CNT_cur_single']  = $this->request->getRequestParam(
1121
-            "cntry[$CNT_ISO][CNT_cur_single]",
1122
-            $country->currency_name_single()
1123
-        );
1124
-        $cols_n_values['CNT_cur_plural']  = $this->request->getRequestParam(
1125
-            "cntry[$CNT_ISO][CNT_cur_plural]",
1126
-            $country->currency_name_plural()
1127
-        );
1128
-        $cols_n_values['CNT_cur_sign']    = $this->request->getRequestParam(
1129
-            "cntry[$CNT_ISO][CNT_cur_sign]",
1130
-            $country->currency_sign()
1131
-        );
1132
-        $cols_n_values['CNT_cur_sign_b4'] = $this->request->getRequestParam(
1133
-            "cntry[$CNT_ISO][CNT_cur_sign_b4]",
1134
-            $country->currency_sign_before(),
1135
-            DataType::BOOL
1136
-        );
1137
-        $cols_n_values['CNT_cur_dec_plc'] = $this->request->getRequestParam(
1138
-            "cntry[$CNT_ISO][CNT_cur_dec_plc]",
1139
-            $country->currency_decimal_places()
1140
-        );
1141
-        $cols_n_values['CNT_cur_dec_mrk'] = $this->request->getRequestParam(
1142
-            "cntry[$CNT_ISO][CNT_cur_dec_mrk]",
1143
-            $country->currency_decimal_mark()
1144
-        );
1145
-        $cols_n_values['CNT_cur_thsnds']  = $this->request->getRequestParam(
1146
-            "cntry[$CNT_ISO][CNT_cur_thsnds]",
1147
-            $country->currency_thousands_separator()
1148
-        );
1149
-        $cols_n_values['CNT_tel_code']    = $this->request->getRequestParam(
1150
-            "cntry[$CNT_ISO][CNT_tel_code]",
1151
-            $country->telephoneCode()
1152
-        );
1153
-        $cols_n_values['CNT_active']      = $this->request->getRequestParam(
1154
-            "cntry[$CNT_ISO][CNT_active]",
1155
-            $country->isActive(),
1156
-            DataType::BOOL
1157
-        );
1158
-
1159
-        // allow filtering of country data
1160
-        $cols_n_values = apply_filters(
1161
-            'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values',
1162
-            $cols_n_values
1163
-        );
1164
-
1165
-        // where values
1166
-        $where_cols_n_values = [['CNT_ISO' => $CNT_ISO]];
1167
-        // run the update
1168
-        $success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
1169
-
1170
-        // allow filtering of states data
1171
-        $states = apply_filters(
1172
-            'FHEE__General_Settings_Admin_Page___update_country_settings__states',
1173
-            $this->request->getRequestParam('states', [], DataType::STRING, true)
1174
-        );
1175
-
1176
-        if (! empty($states) && $success !== false) {
1177
-            // loop thru state data ( looks like : states[75][STA_name] )
1178
-            foreach ($states as $STA_ID => $state) {
1179
-                $cols_n_values = [
1180
-                    'CNT_ISO'    => $CNT_ISO,
1181
-                    'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
1182
-                    'STA_name'   => sanitize_text_field($state['STA_name']),
1183
-                    'STA_active' => filter_var($state['STA_active'], FILTER_VALIDATE_BOOLEAN),
1184
-                ];
1185
-                // where values
1186
-                $where_cols_n_values = [['STA_ID' => $STA_ID]];
1187
-                // run the update
1188
-                $success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
1189
-                if ($success !== false) {
1190
-                    do_action(
1191
-                        'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
1192
-                        $CNT_ISO,
1193
-                        $STA_ID,
1194
-                        $cols_n_values
1195
-                    );
1196
-                }
1197
-            }
1198
-        }
1199
-        // check if country being edited matches org option country, and if so, then  update EE_Config with new settings
1200
-        if (
1201
-            isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
1202
-            && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO
1203
-        ) {
1204
-            EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
1205
-            EE_Registry::instance()->CFG->update_espresso_config();
1206
-        }
1207
-
1208
-        if ($success !== false) {
1209
-            EE_Error::add_success(
1210
-                esc_html__('Country Settings updated successfully.', 'event_espresso')
1211
-            );
1212
-        }
1213
-        $this->_redirect_after_action(
1214
-            $success,
1215
-            '',
1216
-            '',
1217
-            ['action' => 'country_settings', 'country' => $CNT_ISO],
1218
-            true
1219
-        );
1220
-    }
1221
-
1222
-
1223
-    /**
1224
-     * form_form_field_label_wrap
1225
-     *
1226
-     * @param string $label
1227
-     * @return string
1228
-     */
1229
-    public function country_form_field_label_wrap(string $label): string
1230
-    {
1231
-        return '
23
+	/**
24
+	 * @var EE_Core_Config
25
+	 */
26
+	public $core_config;
27
+
28
+
29
+	/**
30
+	 * Initialize basic properties.
31
+	 */
32
+	protected function _init_page_props()
33
+	{
34
+		$this->page_slug        = GEN_SET_PG_SLUG;
35
+		$this->page_label       = GEN_SET_LABEL;
36
+		$this->_admin_base_url  = GEN_SET_ADMIN_URL;
37
+		$this->_admin_base_path = GEN_SET_ADMIN;
38
+	}
39
+
40
+
41
+	/**
42
+	 * Set ajax hooks
43
+	 */
44
+	protected function _ajax_hooks()
45
+	{
46
+		add_action('wp_ajax_espresso_display_country_settings', [$this, 'display_country_settings']);
47
+		add_action('wp_ajax_espresso_display_country_states', [$this, 'display_country_states']);
48
+		add_action('wp_ajax_espresso_delete_state', [$this, 'delete_state'], 10, 3);
49
+		add_action('wp_ajax_espresso_add_new_state', [$this, 'add_new_state']);
50
+	}
51
+
52
+
53
+	/**
54
+	 * More page properties initialization.
55
+	 */
56
+	protected function _define_page_props()
57
+	{
58
+		$this->_admin_page_title = GEN_SET_LABEL;
59
+		$this->_labels           = ['publishbox' => esc_html__('Update Settings', 'event_espresso')];
60
+	}
61
+
62
+
63
+	/**
64
+	 * Set page routes property.
65
+	 */
66
+	protected function _set_page_routes()
67
+	{
68
+		$this->_page_routes = [
69
+			'critical_pages'                => [
70
+				'func'       => '_espresso_page_settings',
71
+				'capability' => 'manage_options',
72
+			],
73
+			'update_espresso_page_settings' => [
74
+				'func'       => '_update_espresso_page_settings',
75
+				'capability' => 'manage_options',
76
+				'noheader'   => true,
77
+			],
78
+			'default'                       => [
79
+				'func'       => '_your_organization_settings',
80
+				'capability' => 'manage_options',
81
+			],
82
+
83
+			'update_your_organization_settings' => [
84
+				'func'       => '_update_your_organization_settings',
85
+				'capability' => 'manage_options',
86
+				'noheader'   => true,
87
+			],
88
+
89
+			'admin_option_settings' => [
90
+				'func'       => '_admin_option_settings',
91
+				'capability' => 'manage_options',
92
+			],
93
+
94
+			'update_admin_option_settings' => [
95
+				'func'       => '_update_admin_option_settings',
96
+				'capability' => 'manage_options',
97
+				'noheader'   => true,
98
+			],
99
+
100
+			'country_settings' => [
101
+				'func'       => '_country_settings',
102
+				'capability' => 'manage_options',
103
+			],
104
+
105
+			'update_country_settings' => [
106
+				'func'       => '_update_country_settings',
107
+				'capability' => 'manage_options',
108
+				'noheader'   => true,
109
+			],
110
+
111
+			'display_country_settings' => [
112
+				'func'       => 'display_country_settings',
113
+				'capability' => 'manage_options',
114
+				'noheader'   => true,
115
+			],
116
+
117
+			'add_new_state' => [
118
+				'func'       => 'add_new_state',
119
+				'capability' => 'manage_options',
120
+				'noheader'   => true,
121
+			],
122
+
123
+			'delete_state'            => [
124
+				'func'       => 'delete_state',
125
+				'capability' => 'manage_options',
126
+				'noheader'   => true,
127
+			],
128
+			'privacy_settings'        => [
129
+				'func'       => 'privacySettings',
130
+				'capability' => 'manage_options',
131
+			],
132
+			'update_privacy_settings' => [
133
+				'func'               => 'updatePrivacySettings',
134
+				'capability'         => 'manage_options',
135
+				'noheader'           => true,
136
+				'headers_sent_route' => 'privacy_settings',
137
+			],
138
+		];
139
+	}
140
+
141
+
142
+	/**
143
+	 * Set page configuration property
144
+	 */
145
+	protected function _set_page_config()
146
+	{
147
+		$this->_page_config = [
148
+			'critical_pages'        => [
149
+				'nav'           => [
150
+					'label' => esc_html__('Critical Pages', 'event_espresso'),
151
+					'order' => 50,
152
+				],
153
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
154
+				'help_tabs'     => [
155
+					'general_settings_critical_pages_help_tab' => [
156
+						'title'    => esc_html__('Critical Pages', 'event_espresso'),
157
+						'filename' => 'general_settings_critical_pages',
158
+					],
159
+				],
160
+				'require_nonce' => false,
161
+			],
162
+			'default'               => [
163
+				'nav'           => [
164
+					'label' => esc_html__('Your Organization', 'event_espresso'),
165
+					'order' => 20,
166
+				],
167
+				'help_tabs'     => [
168
+					'general_settings_your_organization_help_tab' => [
169
+						'title'    => esc_html__('Your Organization', 'event_espresso'),
170
+						'filename' => 'general_settings_your_organization',
171
+					],
172
+				],
173
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
174
+				'require_nonce' => false,
175
+			],
176
+			'admin_option_settings' => [
177
+				'nav'           => [
178
+					'label' => esc_html__('Admin Options', 'event_espresso'),
179
+					'order' => 60,
180
+				],
181
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
182
+				'help_tabs'     => [
183
+					'general_settings_admin_options_help_tab' => [
184
+						'title'    => esc_html__('Admin Options', 'event_espresso'),
185
+						'filename' => 'general_settings_admin_options',
186
+					],
187
+				],
188
+				'require_nonce' => false,
189
+			],
190
+			'country_settings'      => [
191
+				'nav'           => [
192
+					'label' => esc_html__('Countries', 'event_espresso'),
193
+					'order' => 70,
194
+				],
195
+				'help_tabs'     => [
196
+					'general_settings_countries_help_tab' => [
197
+						'title'    => esc_html__('Countries', 'event_espresso'),
198
+						'filename' => 'general_settings_countries',
199
+					],
200
+				],
201
+				'require_nonce' => false,
202
+			],
203
+			'privacy_settings'      => [
204
+				'nav'           => [
205
+					'label' => esc_html__('Privacy', 'event_espresso'),
206
+					'order' => 80,
207
+				],
208
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
209
+				'require_nonce' => false,
210
+			],
211
+		];
212
+	}
213
+
214
+
215
+	protected function _add_screen_options()
216
+	{
217
+	}
218
+
219
+
220
+	protected function _add_feature_pointers()
221
+	{
222
+	}
223
+
224
+
225
+	/**
226
+	 * Enqueue global scripts and styles for all routes in the General Settings Admin Pages.
227
+	 */
228
+	public function load_scripts_styles()
229
+	{
230
+		// styles
231
+		wp_enqueue_style('espresso-ui-theme');
232
+		// scripts
233
+		wp_enqueue_script('ee_admin_js');
234
+	}
235
+
236
+
237
+	/**
238
+	 * Execute logic running on `admin_init`
239
+	 */
240
+	public function admin_init()
241
+	{
242
+		$this->core_config = EE_Registry::instance()->CFG->core;
243
+
244
+		EE_Registry::$i18n_js_strings['invalid_server_response'] = wp_strip_all_tags(
245
+			esc_html__(
246
+				'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.',
247
+				'event_espresso'
248
+			)
249
+		);
250
+		EE_Registry::$i18n_js_strings['error_occurred']          = wp_strip_all_tags(
251
+			esc_html__(
252
+				'An error occurred! Please refresh the page and try again.',
253
+				'event_espresso'
254
+			)
255
+		);
256
+		EE_Registry::$i18n_js_strings['confirm_delete_state']    = wp_strip_all_tags(
257
+			esc_html__(
258
+				'Are you sure you want to delete this State / Province?',
259
+				'event_espresso'
260
+			)
261
+		);
262
+		EE_Registry::$i18n_js_strings['ajax_url']                = admin_url(
263
+			'admin-ajax.php?page=espresso_general_settings',
264
+			is_ssl() ? 'https://' : 'http://'
265
+		);
266
+	}
267
+
268
+
269
+	public function admin_notices()
270
+	{
271
+	}
272
+
273
+
274
+	public function admin_footer_scripts()
275
+	{
276
+	}
277
+
278
+
279
+	/**
280
+	 * Enqueue scripts and styles for the default route.
281
+	 */
282
+	public function load_scripts_styles_default()
283
+	{
284
+		// styles
285
+		wp_enqueue_style('thickbox');
286
+		// scripts
287
+		wp_enqueue_script('media-upload');
288
+		wp_enqueue_script('thickbox');
289
+		wp_register_script(
290
+			'organization_settings',
291
+			GEN_SET_ASSETS_URL . 'your_organization_settings.js',
292
+			['jquery', 'media-upload', 'thickbox'],
293
+			EVENT_ESPRESSO_VERSION,
294
+			true
295
+		);
296
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
297
+		wp_enqueue_script('organization_settings');
298
+		wp_enqueue_style('organization-css');
299
+		$confirm_image_delete = [
300
+			'text' => wp_strip_all_tags(
301
+				esc_html__(
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
+		];
307
+		wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
308
+	}
309
+
310
+
311
+	/**
312
+	 * Enqueue scripts and styles for the country settings route.
313
+	 */
314
+	public function load_scripts_styles_country_settings()
315
+	{
316
+		// scripts
317
+		wp_register_script(
318
+			'gen_settings_countries',
319
+			GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
320
+			['ee_admin_js'],
321
+			EVENT_ESPRESSO_VERSION,
322
+			true
323
+		);
324
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
325
+		wp_enqueue_script('gen_settings_countries');
326
+		wp_enqueue_style('organization-css');
327
+	}
328
+
329
+
330
+	/*************        Espresso Pages        *************/
331
+	/**
332
+	 * _espresso_page_settings
333
+	 *
334
+	 * @throws EE_Error
335
+	 * @throws DomainException
336
+	 * @throws DomainException
337
+	 * @throws InvalidDataTypeException
338
+	 * @throws InvalidArgumentException
339
+	 */
340
+	protected function _espresso_page_settings()
341
+	{
342
+		// Check to make sure all of the main pages are set up properly,
343
+		// if not create the default pages and display an admin notice
344
+		EEH_Activation::verify_default_pages_exist();
345
+		$this->_transient_garbage_collection();
346
+
347
+		$this->_template_args['values']             = $this->_yes_no_values;
348
+
349
+		$this->_template_args['reg_page_id']        = $this->core_config->reg_page_id ?? null;
350
+		$this->_template_args['reg_page_obj']       = isset($this->core_config->reg_page_id)
351
+			? get_post($this->core_config->reg_page_id)
352
+			: false;
353
+
354
+		$this->_template_args['txn_page_id']        = $this->core_config->txn_page_id ?? null;
355
+		$this->_template_args['txn_page_obj']       = isset($this->core_config->txn_page_id)
356
+			? get_post($this->core_config->txn_page_id)
357
+			: false;
358
+
359
+		$this->_template_args['thank_you_page_id']  = $this->core_config->thank_you_page_id ?? null;
360
+		$this->_template_args['thank_you_page_obj'] = isset($this->core_config->thank_you_page_id)
361
+			? get_post($this->core_config->thank_you_page_id)
362
+			: false;
363
+
364
+		$this->_template_args['cancel_page_id']     = $this->core_config->cancel_page_id ?? null;
365
+		$this->_template_args['cancel_page_obj']    = isset($this->core_config->cancel_page_id)
366
+			? get_post($this->core_config->cancel_page_id)
367
+			: false;
368
+
369
+		$this->_set_add_edit_form_tags('update_espresso_page_settings');
370
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
371
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
372
+			GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
373
+			$this->_template_args,
374
+			true
375
+		);
376
+		$this->display_admin_page_with_sidebar();
377
+	}
378
+
379
+
380
+	/**
381
+	 * Handler for updating espresso page settings.
382
+	 *
383
+	 * @throws EE_Error
384
+	 */
385
+	protected function _update_espresso_page_settings()
386
+	{
387
+		// capture incoming request data && set page IDs
388
+		$this->core_config->reg_page_id       = $this->request->getRequestParam(
389
+			'reg_page_id',
390
+			$this->core_config->reg_page_id,
391
+			DataType::INT
392
+		);
393
+		$this->core_config->txn_page_id       = $this->request->getRequestParam(
394
+			'txn_page_id',
395
+			$this->core_config->txn_page_id,
396
+			DataType::INT
397
+		);
398
+		$this->core_config->thank_you_page_id = $this->request->getRequestParam(
399
+			'thank_you_page_id',
400
+			$this->core_config->thank_you_page_id,
401
+			DataType::INT
402
+		);
403
+		$this->core_config->cancel_page_id    = $this->request->getRequestParam(
404
+			'cancel_page_id',
405
+			$this->core_config->cancel_page_id,
406
+			DataType::INT
407
+		);
408
+
409
+		$this->core_config = apply_filters(
410
+			'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core',
411
+			$this->core_config,
412
+			$this->request->requestParams()
413
+		);
414
+
415
+		$what = esc_html__('Critical Pages & Shortcodes', 'event_espresso');
416
+		$this->_redirect_after_action(
417
+			$this->_update_espresso_configuration(
418
+				$what,
419
+				$this->core_config,
420
+				__FILE__,
421
+				__FUNCTION__,
422
+				__LINE__
423
+			),
424
+			$what,
425
+			'',
426
+			[
427
+				'action' => 'critical_pages',
428
+			],
429
+			true
430
+		);
431
+	}
432
+
433
+
434
+	/*************        Your Organization        *************/
435
+
436
+
437
+	/**
438
+	 * @throws DomainException
439
+	 * @throws EE_Error
440
+	 * @throws InvalidArgumentException
441
+	 * @throws InvalidDataTypeException
442
+	 * @throws InvalidInterfaceException
443
+	 */
444
+	protected function _your_organization_settings()
445
+	{
446
+		$this->_template_args['admin_page_content'] = '';
447
+		try {
448
+			/** @var OrganizationSettings $organization_settings_form */
449
+			$organization_settings_form = $this->loader->getShared(OrganizationSettings::class);
450
+
451
+			$this->_template_args['admin_page_content'] = EEH_HTML::div(
452
+				$organization_settings_form->display(),
453
+				'',
454
+				'padding'
455
+			);
456
+		} catch (Exception $e) {
457
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
458
+		}
459
+		$this->_set_add_edit_form_tags('update_your_organization_settings');
460
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
461
+		$this->display_admin_page_with_sidebar();
462
+	}
463
+
464
+
465
+	/**
466
+	 * Handler for updating organization settings.
467
+	 *
468
+	 * @throws EE_Error
469
+	 */
470
+	protected function _update_your_organization_settings()
471
+	{
472
+		try {
473
+			/** @var OrganizationSettings $organization_settings_form */
474
+			$organization_settings_form = $this->loader->getShared(OrganizationSettings::class);
475
+
476
+			$success = $organization_settings_form->process($this->request->requestParams());
477
+
478
+			EE_Registry::instance()->CFG = apply_filters(
479
+				'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG',
480
+				EE_Registry::instance()->CFG
481
+			);
482
+		} catch (Exception $e) {
483
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
484
+			$success = false;
485
+		}
486
+
487
+		if ($success) {
488
+			$success = $this->_update_espresso_configuration(
489
+				esc_html__('Your Organization Settings', 'event_espresso'),
490
+				EE_Registry::instance()->CFG,
491
+				__FILE__,
492
+				__FUNCTION__,
493
+				__LINE__
494
+			);
495
+		}
496
+
497
+		$this->_redirect_after_action($success, '', '', ['action' => 'default'], true);
498
+	}
499
+
500
+
501
+
502
+	/*************        Admin Options        *************/
503
+
504
+
505
+	/**
506
+	 * _admin_option_settings
507
+	 *
508
+	 * @throws EE_Error
509
+	 * @throws LogicException
510
+	 */
511
+	protected function _admin_option_settings()
512
+	{
513
+		$this->_template_args['admin_page_content'] = '';
514
+		try {
515
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
516
+			// still need this for the old school form in Extend_General_Settings_Admin_Page
517
+			$this->_template_args['values'] = $this->_yes_no_values;
518
+			// also need to account for the do_action that was in the old template
519
+			$admin_options_settings_form->setTemplateArgs($this->_template_args);
520
+			$this->_template_args['admin_page_content'] = EEH_HTML::div(
521
+				$admin_options_settings_form->display(),
522
+				'',
523
+				'padding'
524
+			);
525
+		} catch (Exception $e) {
526
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
527
+		}
528
+		$this->_set_add_edit_form_tags('update_admin_option_settings');
529
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
530
+		$this->display_admin_page_with_sidebar();
531
+	}
532
+
533
+
534
+	/**
535
+	 * _update_admin_option_settings
536
+	 *
537
+	 * @throws EE_Error
538
+	 * @throws InvalidDataTypeException
539
+	 * @throws InvalidFormSubmissionException
540
+	 * @throws InvalidArgumentException
541
+	 * @throws LogicException
542
+	 */
543
+	protected function _update_admin_option_settings()
544
+	{
545
+		try {
546
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
547
+			$admin_options_settings_form->process(
548
+				$this->request->getRequestParam(
549
+					$admin_options_settings_form->slug(),
550
+					[],
551
+					DataType::STRING,
552
+					true
553
+				)
554
+			);
555
+			EE_Registry::instance()->CFG->admin = apply_filters(
556
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
557
+				EE_Registry::instance()->CFG->admin
558
+			);
559
+		} catch (Exception $e) {
560
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
561
+		}
562
+		$this->_redirect_after_action(
563
+			apply_filters(
564
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
565
+				$this->_update_espresso_configuration(
566
+					esc_html__('Admin Options', 'event_espresso'),
567
+					EE_Registry::instance()->CFG->admin,
568
+					__FILE__,
569
+					__FUNCTION__,
570
+					__LINE__
571
+				)
572
+			),
573
+			esc_html__('Admin Options', 'event_espresso'),
574
+			'updated',
575
+			['action' => 'admin_option_settings']
576
+		);
577
+	}
578
+
579
+
580
+	/*************        Countries        *************/
581
+
582
+
583
+	/**
584
+	 * @param string|null $default
585
+	 * @return string
586
+	 */
587
+	protected function getCountryISO(?string $default = null): string
588
+	{
589
+		$default = $default ?? $this->getCountryIsoForSite();
590
+		$CNT_ISO = $this->request->getRequestParam('country', $default);
591
+		return strtoupper($CNT_ISO);
592
+	}
593
+
594
+
595
+	/**
596
+	 * @return string
597
+	 */
598
+	protected function getCountryIsoForSite(): string
599
+	{
600
+		return ! empty(EE_Registry::instance()->CFG->organization->CNT_ISO)
601
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
602
+			: 'US';
603
+	}
604
+
605
+
606
+	/**
607
+	 * @param string          $CNT_ISO
608
+	 * @param EE_Country|null $country
609
+	 * @return EE_Base_Class|EE_Country
610
+	 * @throws EE_Error
611
+	 * @throws InvalidArgumentException
612
+	 * @throws InvalidDataTypeException
613
+	 * @throws InvalidInterfaceException
614
+	 * @throws ReflectionException
615
+	 */
616
+	protected function verifyOrGetCountryFromIso(string $CNT_ISO, ?EE_Country $country = null)
617
+	{
618
+		/** @var EE_Country $country */
619
+		return $country instanceof EE_Country && $country->ID() === $CNT_ISO
620
+			? $country
621
+			: EEM_Country::instance()->get_one_by_ID($CNT_ISO);
622
+	}
623
+
624
+
625
+	/**
626
+	 * Output Country Settings view.
627
+	 *
628
+	 * @throws DomainException
629
+	 * @throws EE_Error
630
+	 * @throws InvalidArgumentException
631
+	 * @throws InvalidDataTypeException
632
+	 * @throws InvalidInterfaceException
633
+	 * @throws ReflectionException
634
+	 */
635
+	protected function _country_settings()
636
+	{
637
+		$CNT_ISO = $this->getCountryISO();
638
+
639
+		$this->_template_args['values']    = $this->_yes_no_values;
640
+		$this->_template_args['countries'] = new EE_Question_Form_Input(
641
+			EE_Question::new_instance(
642
+				[
643
+				  'QST_ID'           => 0,
644
+				  'QST_display_text' => esc_html__('Select Country', 'event_espresso'),
645
+				  'QST_system'       => 'admin-country',
646
+				]
647
+			),
648
+			EE_Answer::new_instance(
649
+				[
650
+					'ANS_ID'    => 0,
651
+					'ANS_value' => $CNT_ISO,
652
+				]
653
+			),
654
+			[
655
+				'input_id'       => 'country',
656
+				'input_name'     => 'country',
657
+				'input_prefix'   => '',
658
+				'append_qstn_id' => false,
659
+			]
660
+		);
661
+
662
+		$country = $this->verifyOrGetCountryFromIso($CNT_ISO);
663
+		add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10);
664
+		add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10);
665
+		$this->_template_args['country_details_settings'] = $this->display_country_settings(
666
+			$country->ID(),
667
+			$country
668
+		);
669
+		$this->_template_args['country_states_settings']  = $this->display_country_states(
670
+			$country->ID(),
671
+			$country
672
+		);
673
+		$this->_template_args['CNT_name_for_site']        = $country->name();
674
+
675
+		$this->_set_add_edit_form_tags('update_country_settings');
676
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
677
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
678
+			GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
679
+			$this->_template_args,
680
+			true
681
+		);
682
+		$this->display_admin_page_with_no_sidebar();
683
+	}
684
+
685
+
686
+	/**
687
+	 * @param string          $CNT_ISO
688
+	 * @param EE_Country|null $country
689
+	 * @return string
690
+	 * @throws DomainException
691
+	 * @throws EE_Error
692
+	 * @throws InvalidArgumentException
693
+	 * @throws InvalidDataTypeException
694
+	 * @throws InvalidInterfaceException
695
+	 * @throws ReflectionException
696
+	 */
697
+	public function display_country_settings(string $CNT_ISO = '', ?EE_Country $country = null): string
698
+	{
699
+		$CNT_ISO          = $this->getCountryISO($CNT_ISO);
700
+		$CNT_ISO_for_site = $this->getCountryIsoForSite();
701
+
702
+		if (! $CNT_ISO) {
703
+			return '';
704
+		}
705
+
706
+		// for ajax
707
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
708
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
709
+		add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10, 2);
710
+		add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10, 2);
711
+		$country                                  = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
712
+		$CNT_cur_disabled                         = $CNT_ISO !== $CNT_ISO_for_site;
713
+		$this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled;
714
+
715
+		$country_input_types            = [
716
+			'CNT_active'      => [
717
+				'type'             => 'RADIO_BTN',
718
+				'input_name'       => "cntry[$CNT_ISO]",
719
+				'class'            => '',
720
+				'options'          => $this->_yes_no_values,
721
+				'use_desc_4_label' => true,
722
+			],
723
+			'CNT_ISO'         => [
724
+				'type'       => 'TEXT',
725
+				'input_name' => "cntry[$CNT_ISO]",
726
+				'class'      => 'ee-input-width--small',
727
+			],
728
+			'CNT_ISO3'        => [
729
+				'type'       => 'TEXT',
730
+				'input_name' => "cntry[$CNT_ISO]",
731
+				'class'      => 'ee-input-width--small',
732
+			],
733
+			// 'RGN_ID'          => [
734
+			//     'type'       => 'TEXT',
735
+			//     'input_name' => "cntry[$CNT_ISO]",
736
+			//     'class'      => 'ee-input-width--small',
737
+			// ],
738
+			'CNT_name'        => [
739
+				'type'       => 'TEXT',
740
+				'input_name' => "cntry[$CNT_ISO]",
741
+				'class'      => 'ee-input-width--big',
742
+			],
743
+			'CNT_cur_code'    => [
744
+				'type'       => 'TEXT',
745
+				'input_name' => "cntry[$CNT_ISO]",
746
+				'class'      => 'ee-input-width--small',
747
+				'disabled'   => $CNT_cur_disabled,
748
+			],
749
+			'CNT_cur_single'  => [
750
+				'type'       => 'TEXT',
751
+				'input_name' => "cntry[$CNT_ISO]",
752
+				'class'      => 'ee-input-width--reg',
753
+				'disabled'   => $CNT_cur_disabled,
754
+			],
755
+			'CNT_cur_plural'  => [
756
+				'type'       => 'TEXT',
757
+				'input_name' => "cntry[$CNT_ISO]",
758
+				'class'      => 'ee-input-width--reg',
759
+				'disabled'   => $CNT_cur_disabled,
760
+			],
761
+			'CNT_cur_sign'    => [
762
+				'type'         => 'TEXT',
763
+				'input_name'   => "cntry[$CNT_ISO]",
764
+				'class'        => 'ee-input-width--small',
765
+				'htmlentities' => false,
766
+				'disabled'     => $CNT_cur_disabled,
767
+			],
768
+			'CNT_cur_sign_b4' => [
769
+				'type'             => 'RADIO_BTN',
770
+				'input_name'       => "cntry[$CNT_ISO]",
771
+				'class'            => '',
772
+				'options'          => $this->_yes_no_values,
773
+				'use_desc_4_label' => true,
774
+				'disabled'         => $CNT_cur_disabled,
775
+			],
776
+			'CNT_cur_dec_plc' => [
777
+				'type'       => 'RADIO_BTN',
778
+				'input_name' => "cntry[$CNT_ISO]",
779
+				'class'      => '',
780
+				'options'    => [
781
+					['id' => 0, 'text' => ''],
782
+					['id' => 1, 'text' => ''],
783
+					['id' => 2, 'text' => ''],
784
+					['id' => 3, 'text' => ''],
785
+				],
786
+				'disabled'   => $CNT_cur_disabled,
787
+			],
788
+			'CNT_cur_dec_mrk' => [
789
+				'type'             => 'RADIO_BTN',
790
+				'input_name'       => "cntry[$CNT_ISO]",
791
+				'class'            => '',
792
+				'options'          => [
793
+					[
794
+						'id'   => ',',
795
+						'text' => esc_html__(', (comma)', 'event_espresso'),
796
+					],
797
+					['id' => '.', 'text' => esc_html__('. (decimal)', 'event_espresso')],
798
+				],
799
+				'use_desc_4_label' => true,
800
+				'disabled'         => $CNT_cur_disabled,
801
+			],
802
+			'CNT_cur_thsnds'  => [
803
+				'type'             => 'RADIO_BTN',
804
+				'input_name'       => "cntry[$CNT_ISO]",
805
+				'class'            => '',
806
+				'options'          => [
807
+					[
808
+						'id'   => ',',
809
+						'text' => esc_html__(', (comma)', 'event_espresso'),
810
+					],
811
+					[
812
+						'id'   => '.',
813
+						'text' => esc_html__('. (decimal)', 'event_espresso'),
814
+					],
815
+					[
816
+						'id'   => '&nbsp;',
817
+						'text' => esc_html__('(space)', 'event_espresso'),
818
+					],
819
+				],
820
+				'use_desc_4_label' => true,
821
+				'disabled'         => $CNT_cur_disabled,
822
+			],
823
+			'CNT_tel_code'    => [
824
+				'type'       => 'TEXT',
825
+				'input_name' => "cntry[$CNT_ISO]",
826
+				'class'      => 'ee-input-width--small',
827
+			],
828
+			'CNT_is_EU'       => [
829
+				'type'             => 'RADIO_BTN',
830
+				'input_name'       => "cntry[$CNT_ISO]",
831
+				'class'            => '',
832
+				'options'          => $this->_yes_no_values,
833
+				'use_desc_4_label' => true,
834
+			],
835
+		];
836
+		$this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object(
837
+			$country,
838
+			$country_input_types
839
+		);
840
+		$country_details_settings       = EEH_Template::display_template(
841
+			GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
842
+			$this->_template_args,
843
+			true
844
+		);
845
+
846
+		if (defined('DOING_AJAX')) {
847
+			$notices = EE_Error::get_notices(false, false, false);
848
+			echo wp_json_encode(
849
+				[
850
+					'return_data' => $country_details_settings,
851
+					'success'     => $notices['success'],
852
+					'errors'      => $notices['errors'],
853
+				]
854
+			);
855
+			die();
856
+		}
857
+		return $country_details_settings;
858
+	}
859
+
860
+
861
+	/**
862
+	 * @param string          $CNT_ISO
863
+	 * @param EE_Country|null $country
864
+	 * @return string
865
+	 * @throws DomainException
866
+	 * @throws EE_Error
867
+	 * @throws InvalidArgumentException
868
+	 * @throws InvalidDataTypeException
869
+	 * @throws InvalidInterfaceException
870
+	 * @throws ReflectionException
871
+	 */
872
+	public function display_country_states(string $CNT_ISO = '', ?EE_Country $country = null): string
873
+	{
874
+		$CNT_ISO = $this->getCountryISO($CNT_ISO);
875
+		if (! $CNT_ISO) {
876
+			return '';
877
+		}
878
+		// for ajax
879
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
880
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
881
+		add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'state_form_field_label_wrap'], 10, 2);
882
+		add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'state_form_field_input__wrap'], 10);
883
+		$states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
884
+		if (empty($states)) {
885
+			/** @var EventEspresso\core\services\address\CountrySubRegionDao $countrySubRegionDao */
886
+			$countrySubRegionDao = $this->loader->getShared(
887
+				'EventEspresso\core\services\address\CountrySubRegionDao'
888
+			);
889
+			if ($countrySubRegionDao instanceof EventEspresso\core\services\address\CountrySubRegionDao) {
890
+				$country = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
891
+				if ($countrySubRegionDao->saveCountrySubRegions($country)) {
892
+					$states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
893
+				}
894
+			}
895
+		}
896
+		if (is_array($states)) {
897
+			foreach ($states as $STA_ID => $state) {
898
+				if ($state instanceof EE_State) {
899
+					$inputs = EE_Question_Form_Input::generate_question_form_inputs_for_object(
900
+						$state,
901
+						[
902
+							'STA_abbrev' => [
903
+								'type'             => 'TEXT',
904
+								'label'            => esc_html__('Code', 'event_espresso'),
905
+								'input_name'       => "states[$STA_ID]",
906
+								'class'            => 'ee-input-width--tiny',
907
+								'add_mobile_label' => true,
908
+							],
909
+							'STA_name'   => [
910
+								'type'             => 'TEXT',
911
+								'label'            => esc_html__('Name', 'event_espresso'),
912
+								'input_name'       => "states[$STA_ID]",
913
+								'class'            => 'ee-input-width--big',
914
+								'add_mobile_label' => true,
915
+							],
916
+							'STA_active' => [
917
+								'type'             => 'RADIO_BTN',
918
+								'label'            => esc_html__('State Appears in Dropdown Select Lists', 'event_espresso'),
919
+								'input_name'       => "states[$STA_ID]",
920
+								'options'          => $this->_yes_no_values,
921
+								'use_desc_4_label' => true,
922
+								'add_mobile_label' => true,
923
+							],
924
+						]
925
+					);
926
+
927
+					$delete_state_url = EE_Admin_Page::add_query_args_and_nonce(
928
+						[
929
+							'action'     => 'delete_state',
930
+							'STA_ID'     => $STA_ID,
931
+							'CNT_ISO'    => $CNT_ISO,
932
+							'STA_abbrev' => $state->abbrev(),
933
+						],
934
+						GEN_SET_ADMIN_URL
935
+					);
936
+
937
+					$this->_template_args['states'][$STA_ID]['inputs']           = $inputs;
938
+					$this->_template_args['states'][$STA_ID]['delete_state_url'] = $delete_state_url;
939
+				}
940
+			}
941
+		} else {
942
+			$this->_template_args['states'] = false;
943
+		}
944
+
945
+		$this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(
946
+			['action' => 'add_new_state'],
947
+			GEN_SET_ADMIN_URL
948
+		);
949
+
950
+		$state_details_settings = EEH_Template::display_template(
951
+			GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
952
+			$this->_template_args,
953
+			true
954
+		);
955
+
956
+		if (defined('DOING_AJAX')) {
957
+			$notices = EE_Error::get_notices(false, false, false);
958
+			echo wp_json_encode(
959
+				[
960
+					'return_data' => $state_details_settings,
961
+					'success'     => $notices['success'],
962
+					'errors'      => $notices['errors'],
963
+				]
964
+			);
965
+			die();
966
+		}
967
+		return $state_details_settings;
968
+	}
969
+
970
+
971
+	/**
972
+	 * @return void
973
+	 * @throws EE_Error
974
+	 * @throws InvalidArgumentException
975
+	 * @throws InvalidDataTypeException
976
+	 * @throws InvalidInterfaceException
977
+	 * @throws ReflectionException
978
+	 */
979
+	public function add_new_state()
980
+	{
981
+		$success = true;
982
+		$CNT_ISO = $this->getCountryISO('');
983
+		if (! $CNT_ISO) {
984
+			EE_Error::add_error(
985
+				esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
986
+				__FILE__,
987
+				__FUNCTION__,
988
+				__LINE__
989
+			);
990
+			$success = false;
991
+		}
992
+		$STA_abbrev = $this->request->getRequestParam('STA_abbrev');
993
+		if (! $STA_abbrev) {
994
+			EE_Error::add_error(
995
+				esc_html__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
996
+				__FILE__,
997
+				__FUNCTION__,
998
+				__LINE__
999
+			);
1000
+			$success = false;
1001
+		}
1002
+		$STA_name = $this->request->getRequestParam('STA_name');
1003
+		if (! $STA_name) {
1004
+			EE_Error::add_error(
1005
+				esc_html__('No State name or an invalid State name was received.', 'event_espresso'),
1006
+				__FILE__,
1007
+				__FUNCTION__,
1008
+				__LINE__
1009
+			);
1010
+			$success = false;
1011
+		}
1012
+
1013
+		if ($success) {
1014
+			$cols_n_values = [
1015
+				'CNT_ISO'    => $CNT_ISO,
1016
+				'STA_abbrev' => $STA_abbrev,
1017
+				'STA_name'   => $STA_name,
1018
+				'STA_active' => true,
1019
+			];
1020
+			$success       = EEM_State::instance()->insert($cols_n_values);
1021
+			EE_Error::add_success(esc_html__('The State was added successfully.', 'event_espresso'));
1022
+		}
1023
+
1024
+		if (defined('DOING_AJAX')) {
1025
+			$notices = EE_Error::get_notices(false, false, false);
1026
+			echo wp_json_encode(array_merge($notices, ['return_data' => $CNT_ISO]));
1027
+			die();
1028
+		}
1029
+		$this->_redirect_after_action(
1030
+			$success,
1031
+			esc_html__('State', 'event_espresso'),
1032
+			'added',
1033
+			['action' => 'country_settings']
1034
+		);
1035
+	}
1036
+
1037
+
1038
+	/**
1039
+	 * @return void
1040
+	 * @throws EE_Error
1041
+	 * @throws InvalidArgumentException
1042
+	 * @throws InvalidDataTypeException
1043
+	 * @throws InvalidInterfaceException
1044
+	 * @throws ReflectionException
1045
+	 */
1046
+	public function delete_state()
1047
+	{
1048
+		$CNT_ISO    = $this->getCountryISO();
1049
+		$STA_ID     = $this->request->getRequestParam('STA_ID');
1050
+		$STA_abbrev = $this->request->getRequestParam('STA_abbrev');
1051
+
1052
+		if (! $STA_ID) {
1053
+			EE_Error::add_error(
1054
+				esc_html__('No State ID or an invalid State ID was received.', 'event_espresso'),
1055
+				__FILE__,
1056
+				__FUNCTION__,
1057
+				__LINE__
1058
+			);
1059
+			return;
1060
+		}
1061
+
1062
+		$success = EEM_State::instance()->delete_by_ID($STA_ID);
1063
+		if ($success !== false) {
1064
+			do_action('AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
1065
+					  $CNT_ISO,
1066
+					  $STA_ID,
1067
+					  ['STA_abbrev' => $STA_abbrev]);
1068
+			EE_Error::add_success(esc_html__('The State was deleted successfully.', 'event_espresso'));
1069
+		}
1070
+		if (defined('DOING_AJAX')) {
1071
+			$notices                = EE_Error::get_notices(false);
1072
+			$notices['return_data'] = true;
1073
+			echo wp_json_encode($notices);
1074
+			die();
1075
+		}
1076
+		$this->_redirect_after_action(
1077
+			$success,
1078
+			esc_html__('State', 'event_espresso'),
1079
+			'deleted',
1080
+			['action' => 'country_settings']
1081
+		);
1082
+	}
1083
+
1084
+
1085
+	/**
1086
+	 * @return void
1087
+	 * @throws EE_Error
1088
+	 * @throws InvalidArgumentException
1089
+	 * @throws InvalidDataTypeException
1090
+	 * @throws InvalidInterfaceException
1091
+	 * @throws ReflectionException
1092
+	 */
1093
+	protected function _update_country_settings()
1094
+	{
1095
+		$CNT_ISO = $this->getCountryISO();
1096
+		if (! $CNT_ISO) {
1097
+			EE_Error::add_error(
1098
+				esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1099
+				__FILE__,
1100
+				__FUNCTION__,
1101
+				__LINE__
1102
+			);
1103
+			return;
1104
+		}
1105
+
1106
+		$country = $this->verifyOrGetCountryFromIso($CNT_ISO);
1107
+
1108
+		$cols_n_values                    = [];
1109
+		$cols_n_values['CNT_ISO3']        = strtoupper(
1110
+			$this->request->getRequestParam('cntry', '', $country->ISO3())
1111
+		);
1112
+		$cols_n_values['CNT_name']        =
1113
+			$this->request->getRequestParam("cntry[$CNT_ISO][CNT_name]", $country->name());
1114
+		$cols_n_values['CNT_cur_code']    = strtoupper(
1115
+			$this->request->getRequestParam(
1116
+				"cntry[$CNT_ISO][CNT_cur_code]",
1117
+				$country->currency_code()
1118
+			)
1119
+		);
1120
+		$cols_n_values['CNT_cur_single']  = $this->request->getRequestParam(
1121
+			"cntry[$CNT_ISO][CNT_cur_single]",
1122
+			$country->currency_name_single()
1123
+		);
1124
+		$cols_n_values['CNT_cur_plural']  = $this->request->getRequestParam(
1125
+			"cntry[$CNT_ISO][CNT_cur_plural]",
1126
+			$country->currency_name_plural()
1127
+		);
1128
+		$cols_n_values['CNT_cur_sign']    = $this->request->getRequestParam(
1129
+			"cntry[$CNT_ISO][CNT_cur_sign]",
1130
+			$country->currency_sign()
1131
+		);
1132
+		$cols_n_values['CNT_cur_sign_b4'] = $this->request->getRequestParam(
1133
+			"cntry[$CNT_ISO][CNT_cur_sign_b4]",
1134
+			$country->currency_sign_before(),
1135
+			DataType::BOOL
1136
+		);
1137
+		$cols_n_values['CNT_cur_dec_plc'] = $this->request->getRequestParam(
1138
+			"cntry[$CNT_ISO][CNT_cur_dec_plc]",
1139
+			$country->currency_decimal_places()
1140
+		);
1141
+		$cols_n_values['CNT_cur_dec_mrk'] = $this->request->getRequestParam(
1142
+			"cntry[$CNT_ISO][CNT_cur_dec_mrk]",
1143
+			$country->currency_decimal_mark()
1144
+		);
1145
+		$cols_n_values['CNT_cur_thsnds']  = $this->request->getRequestParam(
1146
+			"cntry[$CNT_ISO][CNT_cur_thsnds]",
1147
+			$country->currency_thousands_separator()
1148
+		);
1149
+		$cols_n_values['CNT_tel_code']    = $this->request->getRequestParam(
1150
+			"cntry[$CNT_ISO][CNT_tel_code]",
1151
+			$country->telephoneCode()
1152
+		);
1153
+		$cols_n_values['CNT_active']      = $this->request->getRequestParam(
1154
+			"cntry[$CNT_ISO][CNT_active]",
1155
+			$country->isActive(),
1156
+			DataType::BOOL
1157
+		);
1158
+
1159
+		// allow filtering of country data
1160
+		$cols_n_values = apply_filters(
1161
+			'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values',
1162
+			$cols_n_values
1163
+		);
1164
+
1165
+		// where values
1166
+		$where_cols_n_values = [['CNT_ISO' => $CNT_ISO]];
1167
+		// run the update
1168
+		$success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
1169
+
1170
+		// allow filtering of states data
1171
+		$states = apply_filters(
1172
+			'FHEE__General_Settings_Admin_Page___update_country_settings__states',
1173
+			$this->request->getRequestParam('states', [], DataType::STRING, true)
1174
+		);
1175
+
1176
+		if (! empty($states) && $success !== false) {
1177
+			// loop thru state data ( looks like : states[75][STA_name] )
1178
+			foreach ($states as $STA_ID => $state) {
1179
+				$cols_n_values = [
1180
+					'CNT_ISO'    => $CNT_ISO,
1181
+					'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
1182
+					'STA_name'   => sanitize_text_field($state['STA_name']),
1183
+					'STA_active' => filter_var($state['STA_active'], FILTER_VALIDATE_BOOLEAN),
1184
+				];
1185
+				// where values
1186
+				$where_cols_n_values = [['STA_ID' => $STA_ID]];
1187
+				// run the update
1188
+				$success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
1189
+				if ($success !== false) {
1190
+					do_action(
1191
+						'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
1192
+						$CNT_ISO,
1193
+						$STA_ID,
1194
+						$cols_n_values
1195
+					);
1196
+				}
1197
+			}
1198
+		}
1199
+		// check if country being edited matches org option country, and if so, then  update EE_Config with new settings
1200
+		if (
1201
+			isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
1202
+			&& $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO
1203
+		) {
1204
+			EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
1205
+			EE_Registry::instance()->CFG->update_espresso_config();
1206
+		}
1207
+
1208
+		if ($success !== false) {
1209
+			EE_Error::add_success(
1210
+				esc_html__('Country Settings updated successfully.', 'event_espresso')
1211
+			);
1212
+		}
1213
+		$this->_redirect_after_action(
1214
+			$success,
1215
+			'',
1216
+			'',
1217
+			['action' => 'country_settings', 'country' => $CNT_ISO],
1218
+			true
1219
+		);
1220
+	}
1221
+
1222
+
1223
+	/**
1224
+	 * form_form_field_label_wrap
1225
+	 *
1226
+	 * @param string $label
1227
+	 * @return string
1228
+	 */
1229
+	public function country_form_field_label_wrap(string $label): string
1230
+	{
1231
+		return '
1232 1232
 			<tr>
1233 1233
 				<th>
1234 1234
 					' . $label . '
1235 1235
 				</th>';
1236
-    }
1237
-
1238
-
1239
-    /**
1240
-     * form_form_field_input__wrap
1241
-     *
1242
-     * @param string $input
1243
-     * @return string
1244
-     */
1245
-    public function country_form_field_input__wrap(string $input): string
1246
-    {
1247
-        return '
1236
+	}
1237
+
1238
+
1239
+	/**
1240
+	 * form_form_field_input__wrap
1241
+	 *
1242
+	 * @param string $input
1243
+	 * @return string
1244
+	 */
1245
+	public function country_form_field_input__wrap(string $input): string
1246
+	{
1247
+		return '
1248 1248
 				<td class="general-settings-country-input-td">
1249 1249
 					' . $input . '
1250 1250
 				</td>
1251 1251
 			</tr>';
1252
-    }
1253
-
1254
-
1255
-    /**
1256
-     * form_form_field_label_wrap
1257
-     *
1258
-     * @param string $label
1259
-     * @param string $required_text
1260
-     * @return string
1261
-     */
1262
-    public function state_form_field_label_wrap(string $label, string $required_text): string
1263
-    {
1264
-        return $required_text;
1265
-    }
1266
-
1267
-
1268
-    /**
1269
-     * form_form_field_input__wrap
1270
-     *
1271
-     * @param string $input
1272
-     * @return string
1273
-     */
1274
-    public function state_form_field_input__wrap(string $input): string
1275
-    {
1276
-        return '
1252
+	}
1253
+
1254
+
1255
+	/**
1256
+	 * form_form_field_label_wrap
1257
+	 *
1258
+	 * @param string $label
1259
+	 * @param string $required_text
1260
+	 * @return string
1261
+	 */
1262
+	public function state_form_field_label_wrap(string $label, string $required_text): string
1263
+	{
1264
+		return $required_text;
1265
+	}
1266
+
1267
+
1268
+	/**
1269
+	 * form_form_field_input__wrap
1270
+	 *
1271
+	 * @param string $input
1272
+	 * @return string
1273
+	 */
1274
+	public function state_form_field_input__wrap(string $input): string
1275
+	{
1276
+		return '
1277 1277
 				<td class="general-settings-country-state-input-td">
1278 1278
 					' . $input . '
1279 1279
 				</td>';
1280
-    }
1281
-
1282
-
1283
-    /***********/
1284
-
1285
-
1286
-    /**
1287
-     * displays edit and view links for critical EE pages
1288
-     *
1289
-     * @param int $ee_page_id
1290
-     * @return string
1291
-     */
1292
-    public static function edit_view_links(int $ee_page_id): string
1293
-    {
1294
-        $edit_url = add_query_arg(
1295
-            ['post' => $ee_page_id, 'action' => 'edit'],
1296
-            admin_url('post.php')
1297
-        );
1298
-        $links    = '<a href="' . esc_url_raw($edit_url) . '" >' . esc_html__('Edit', 'event_espresso') . '</a>';
1299
-        $links    .= ' &nbsp;|&nbsp; ';
1300
-        $links    .= '<a href="' . get_permalink($ee_page_id) . '" >' . esc_html__('View', 'event_espresso') . '</a>';
1301
-
1302
-        return $links;
1303
-    }
1304
-
1305
-
1306
-    /**
1307
-     * displays page and shortcode status for critical EE pages
1308
-     *
1309
-     * @param WP_Post $ee_page
1310
-     * @param string  $shortcode
1311
-     * @return string
1312
-     */
1313
-    public static function page_and_shortcode_status(WP_Post $ee_page, string $shortcode): string
1314
-    {
1315
-        // page status
1316
-        if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
1317
-            $pg_class  = 'ee-status-bg--success';
1318
-            $pg_status = sprintf(esc_html__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
1319
-        } else {
1320
-            $pg_class  = 'ee-status-bg--error';
1321
-            $pg_status = sprintf(esc_html__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
1322
-        }
1323
-
1324
-        // shortcode status
1325
-        if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) {
1326
-            $sc_class  = 'ee-status-bg--success';
1327
-            $sc_status = sprintf(esc_html__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
1328
-        } else {
1329
-            $sc_class  = 'ee-status-bg--error';
1330
-            $sc_status = sprintf(esc_html__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1331
-        }
1332
-
1333
-        return '
1280
+	}
1281
+
1282
+
1283
+	/***********/
1284
+
1285
+
1286
+	/**
1287
+	 * displays edit and view links for critical EE pages
1288
+	 *
1289
+	 * @param int $ee_page_id
1290
+	 * @return string
1291
+	 */
1292
+	public static function edit_view_links(int $ee_page_id): string
1293
+	{
1294
+		$edit_url = add_query_arg(
1295
+			['post' => $ee_page_id, 'action' => 'edit'],
1296
+			admin_url('post.php')
1297
+		);
1298
+		$links    = '<a href="' . esc_url_raw($edit_url) . '" >' . esc_html__('Edit', 'event_espresso') . '</a>';
1299
+		$links    .= ' &nbsp;|&nbsp; ';
1300
+		$links    .= '<a href="' . get_permalink($ee_page_id) . '" >' . esc_html__('View', 'event_espresso') . '</a>';
1301
+
1302
+		return $links;
1303
+	}
1304
+
1305
+
1306
+	/**
1307
+	 * displays page and shortcode status for critical EE pages
1308
+	 *
1309
+	 * @param WP_Post $ee_page
1310
+	 * @param string  $shortcode
1311
+	 * @return string
1312
+	 */
1313
+	public static function page_and_shortcode_status(WP_Post $ee_page, string $shortcode): string
1314
+	{
1315
+		// page status
1316
+		if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
1317
+			$pg_class  = 'ee-status-bg--success';
1318
+			$pg_status = sprintf(esc_html__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
1319
+		} else {
1320
+			$pg_class  = 'ee-status-bg--error';
1321
+			$pg_status = sprintf(esc_html__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
1322
+		}
1323
+
1324
+		// shortcode status
1325
+		if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) {
1326
+			$sc_class  = 'ee-status-bg--success';
1327
+			$sc_status = sprintf(esc_html__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
1328
+		} else {
1329
+			$sc_class  = 'ee-status-bg--error';
1330
+			$sc_status = sprintf(esc_html__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1331
+		}
1332
+
1333
+		return '
1334 1334
         <span class="ee-page-status ' . $pg_class . '"><strong>' . $pg_status . '</strong></span>
1335 1335
         <span class="ee-page-status ' . $sc_class . '"><strong>' . $sc_status . '</strong></span>';
1336
-    }
1337
-
1338
-
1339
-    /**
1340
-     * generates a dropdown of all parent pages - copied from WP core
1341
-     *
1342
-     * @param int  $default
1343
-     * @param int  $parent
1344
-     * @param int  $level
1345
-     * @param bool $echo
1346
-     * @return string;
1347
-     */
1348
-    public static function page_settings_dropdown(
1349
-        int $default = 0,
1350
-        int $parent = 0,
1351
-        int $level = 0,
1352
-        bool $echo = true
1353
-    ): string {
1354
-        global $wpdb;
1355
-        $items  = $wpdb->get_results(
1356
-            $wpdb->prepare(
1357
-                "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",
1358
-                $parent
1359
-            )
1360
-        );
1361
-        $output = '';
1362
-
1363
-        if ($items) {
1364
-            $level = absint($level);
1365
-            foreach ($items as $item) {
1366
-                $ID         = absint($item->ID);
1367
-                $post_title = wp_strip_all_tags($item->post_title);
1368
-                $pad        = str_repeat('&nbsp;', $level * 3);
1369
-                $option     = "\n\t";
1370
-                $option     .= '<option class="level-' . $level . '" ';
1371
-                $option     .= 'value="' . $ID . '" ';
1372
-                $option     .= $ID === absint($default) ? ' selected="selected"' : '';
1373
-                $option     .= '>';
1374
-                $option     .= "$pad $post_title";
1375
-                $option     .= '</option>';
1376
-                $output     .= $option;
1377
-                ob_start();
1378
-                parent_dropdown($default, $item->ID, $level + 1);
1379
-                $output .= ob_get_clean();
1380
-            }
1381
-        }
1382
-        if ($echo) {
1383
-            echo wp_kses($output, AllowedTags::getWithFormTags());
1384
-            return '';
1385
-        }
1386
-        return $output;
1387
-    }
1388
-
1389
-
1390
-    /**
1391
-     * Loads the scripts for the privacy settings form
1392
-     */
1393
-    public function load_scripts_styles_privacy_settings()
1394
-    {
1395
-        $form_handler = $this->loader->getShared(
1396
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1397
-        );
1398
-        $form_handler->enqueueStylesAndScripts();
1399
-    }
1400
-
1401
-
1402
-    /**
1403
-     * display the privacy settings form
1404
-     *
1405
-     * @throws EE_Error
1406
-     */
1407
-    public function privacySettings()
1408
-    {
1409
-        $this->_set_add_edit_form_tags('update_privacy_settings');
1410
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
1411
-        $form_handler                               = $this->loader->getShared(
1412
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1413
-        );
1414
-        $this->_template_args['admin_page_content'] = EEH_HTML::div(
1415
-            $form_handler->display(),
1416
-            '',
1417
-            'padding'
1418
-        );
1419
-        $this->display_admin_page_with_sidebar();
1420
-    }
1421
-
1422
-
1423
-    /**
1424
-     * Update the privacy settings from form data
1425
-     *
1426
-     * @throws EE_Error
1427
-     */
1428
-    public function updatePrivacySettings()
1429
-    {
1430
-        $form_handler = $this->loader->getShared(
1431
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1432
-        );
1433
-        $success      = $form_handler->process($this->get_request_data());
1434
-        $this->_redirect_after_action(
1435
-            $success,
1436
-            esc_html__('Registration Form Options', 'event_espresso'),
1437
-            'updated',
1438
-            ['action' => 'privacy_settings']
1439
-        );
1440
-    }
1336
+	}
1337
+
1338
+
1339
+	/**
1340
+	 * generates a dropdown of all parent pages - copied from WP core
1341
+	 *
1342
+	 * @param int  $default
1343
+	 * @param int  $parent
1344
+	 * @param int  $level
1345
+	 * @param bool $echo
1346
+	 * @return string;
1347
+	 */
1348
+	public static function page_settings_dropdown(
1349
+		int $default = 0,
1350
+		int $parent = 0,
1351
+		int $level = 0,
1352
+		bool $echo = true
1353
+	): string {
1354
+		global $wpdb;
1355
+		$items  = $wpdb->get_results(
1356
+			$wpdb->prepare(
1357
+				"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",
1358
+				$parent
1359
+			)
1360
+		);
1361
+		$output = '';
1362
+
1363
+		if ($items) {
1364
+			$level = absint($level);
1365
+			foreach ($items as $item) {
1366
+				$ID         = absint($item->ID);
1367
+				$post_title = wp_strip_all_tags($item->post_title);
1368
+				$pad        = str_repeat('&nbsp;', $level * 3);
1369
+				$option     = "\n\t";
1370
+				$option     .= '<option class="level-' . $level . '" ';
1371
+				$option     .= 'value="' . $ID . '" ';
1372
+				$option     .= $ID === absint($default) ? ' selected="selected"' : '';
1373
+				$option     .= '>';
1374
+				$option     .= "$pad $post_title";
1375
+				$option     .= '</option>';
1376
+				$output     .= $option;
1377
+				ob_start();
1378
+				parent_dropdown($default, $item->ID, $level + 1);
1379
+				$output .= ob_get_clean();
1380
+			}
1381
+		}
1382
+		if ($echo) {
1383
+			echo wp_kses($output, AllowedTags::getWithFormTags());
1384
+			return '';
1385
+		}
1386
+		return $output;
1387
+	}
1388
+
1389
+
1390
+	/**
1391
+	 * Loads the scripts for the privacy settings form
1392
+	 */
1393
+	public function load_scripts_styles_privacy_settings()
1394
+	{
1395
+		$form_handler = $this->loader->getShared(
1396
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1397
+		);
1398
+		$form_handler->enqueueStylesAndScripts();
1399
+	}
1400
+
1401
+
1402
+	/**
1403
+	 * display the privacy settings form
1404
+	 *
1405
+	 * @throws EE_Error
1406
+	 */
1407
+	public function privacySettings()
1408
+	{
1409
+		$this->_set_add_edit_form_tags('update_privacy_settings');
1410
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
1411
+		$form_handler                               = $this->loader->getShared(
1412
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1413
+		);
1414
+		$this->_template_args['admin_page_content'] = EEH_HTML::div(
1415
+			$form_handler->display(),
1416
+			'',
1417
+			'padding'
1418
+		);
1419
+		$this->display_admin_page_with_sidebar();
1420
+	}
1421
+
1422
+
1423
+	/**
1424
+	 * Update the privacy settings from form data
1425
+	 *
1426
+	 * @throws EE_Error
1427
+	 */
1428
+	public function updatePrivacySettings()
1429
+	{
1430
+		$form_handler = $this->loader->getShared(
1431
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1432
+		);
1433
+		$success      = $form_handler->process($this->get_request_data());
1434
+		$this->_redirect_after_action(
1435
+			$success,
1436
+			esc_html__('Registration Form Options', 'event_espresso'),
1437
+			'updated',
1438
+			['action' => 'privacy_settings']
1439
+		);
1440
+	}
1441 1441
 }
Please login to merge, or discard this patch.