Completed
Branch master (6d1405)
by
unknown
13:57 queued 12:03
created
admin/new/pricing/templates/pricing_details_main_meta_box.template.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -4,40 +4,40 @@  discard block
 block discarded – undo
4 4
         <tbody>
5 5
         <tr valign="top">
6 6
             <th><label for="PRT_ID"><?php
7
-                    esc_html_e(
8
-                        'Type',
9
-                        'event_espresso'
10
-                    ); ?></label> <?php echo EEH_Template::get_help_tab_link('type_field_info'); ?></th>
7
+					esc_html_e(
8
+						'Type',
9
+						'event_espresso'
10
+					); ?></label> <?php echo EEH_Template::get_help_tab_link('type_field_info'); ?></th>
11 11
             <td>
12 12
                 <?php if ($price->type_obj() && $price->type_obj()->base_type() === 1) : ?>
13 13
                     <input type="hidden" name="PRT_ID" id="PRT_ID" value="<?php echo esc_attr($price->type()); ?>"/>
14 14
                     <p><strong><?php esc_html_e('Price', 'event_espresso'); ?></strong></p>
15 15
                     <p class="description">
16 16
                         <?php
17
-                        esc_html_e(
18
-                            'This is the default base price. Every new ticket created will start off with this base price.',
19
-                            'event_espresso'
20
-                        );
21
-                        ?>
17
+						esc_html_e(
18
+							'This is the default base price. Every new ticket created will start off with this base price.',
19
+							'event_espresso'
20
+						);
21
+						?>
22 22
                     </p>
23 23
                 <?php else : ?>
24 24
                     <?php echo EEH_Form_Fields::select_input('PRT_ID', $price_types, $price->type(), 'id="PRT_ID"'); ?>
25 25
                     <p class="description">
26 26
                         <?php
27
-                            esc_html_e(
28
-                                'Price Modifier. Default items will apply to ALL new events you create.',
29
-                                'event_espresso'
30
-                            );
31
-                        ?></p>
27
+							esc_html_e(
28
+								'Price Modifier. Default items will apply to ALL new events you create.',
29
+								'event_espresso'
30
+							);
31
+						?></p>
32 32
                 <?php endif; ?>
33 33
             </td>
34 34
         </tr>
35 35
         <tr valign="top">
36 36
             <th><label for="PRC_name"><?php
37
-                    esc_html_e(
38
-                        'Name',
39
-                        'event_espresso'
40
-                    ); ?></label> <?php echo EEH_Template::get_help_tab_link('name_field_info'); ?></th>
37
+					esc_html_e(
38
+						'Name',
39
+						'event_espresso'
40
+					); ?></label> <?php echo EEH_Template::get_help_tab_link('name_field_info'); ?></th>
41 41
             <td>
42 42
                 <input class="regular-text" type="text" id="PRC_name" name="PRC_name"
43 43
                        value="<?php $price->f('PRC_name'); ?>"/>
@@ -45,22 +45,22 @@  discard block
 block discarded – undo
45 45
         </tr>
46 46
         <tr valign="top">
47 47
             <th><label for="PRC_desc"><?php
48
-                    esc_html_e(
49
-                        'Description',
50
-                        'event_espresso'
51
-                    ); ?></label> <?php echo EEH_Template::get_help_tab_link('description_field_info'); ?></th>
48
+					esc_html_e(
49
+						'Description',
50
+						'event_espresso'
51
+					); ?></label> <?php echo EEH_Template::get_help_tab_link('description_field_info'); ?></th>
52 52
             <td>
53 53
                     <textarea class="regular-text" id="PRC_desc" name="PRC_desc" rows="5"><?php
54
-                        echo esc_textarea($price->get_f('PRC_desc'));
55
-                    ?></textarea><br/>
54
+						echo esc_textarea($price->get_f('PRC_desc'));
55
+					?></textarea><br/>
56 56
             </td>
57 57
         </tr>
58 58
         <tr valign="top">
59 59
             <th><label for="PRC_amount"><?php
60
-                    esc_html_e(
61
-                        'Amount',
62
-                        'event_espresso'
63
-                    ); ?><?php echo EEH_Template::get_help_tab_link('amount_field_info'); ?></label></th>
60
+					esc_html_e(
61
+						'Amount',
62
+						'event_espresso'
63
+					); ?><?php echo EEH_Template::get_help_tab_link('amount_field_info'); ?></label></th>
64 64
             <td>
65 65
                 <input class="small-text ee-numeric" type="text" id="PRC_amount" name="PRC_amount"
66 66
                        value="<?php echo esc_attr($price->amount()); ?>"/>
Please login to merge, or discard this patch.
core/helpers/EEH_Form_Fields.helper.php 2 patches
Indentation   +1971 added lines, -1971 removed lines patch added patch discarded remove patch
@@ -29,1997 +29,1997 @@
 block discarded – undo
29 29
 {
30 30
 
31 31
 
32
-    /**
33
-     *  Generates HTML for the forms used on admin pages
34
-     *
35
-     *
36
-     * @static
37
-     * @access public
38
-     * @param array $input_vars - array of input field details
39
-     *                          format:
40
-     *                          $template_form_fields['field-id'] = array(
41
-     *                          'name' => 'name_attribute',
42
-     *                          'label' => esc_html__('Field Label', 'event_espresso'), //or false
43
-     *                          'input' => 'hidden', //field input type can be 'text', 'select', 'textarea', 'hidden',
44
-     *                          'checkbox', 'wp_editor'
45
-     *                          'type' => 'int', //what "type" the value is (i.e. string, int etc)
46
-     *                          'required' => false, //boolean for whether the field is required
47
-     *                          'validation' => true, //boolean, whether to validate the field (todo)
48
-     *                          'value' => 'some_value_for_field', //what value is used for field
49
-     *                          'format' => '%d', //what format the value is (%d, %f, or %s)
50
-     *                          'db-col' => 'column_in_db' //used to indicate which column the field corresponds with
51
-     *                          in the db
52
-     *                          'options' => optiona, optionb || array('value' => 'label', '') //if the input type is
53
-     *                          "select", this allows you to set the args for the different <option> tags.
54
-     *                          'tabindex' => 1 //this allows you to set the tabindex for the field.
55
-     *                          'append_content' => '' //this allows you to send in html content to append to the
56
-     *                          field.
57
-     *                          )
58
-     * @param array $form_id    - used for defining unique identifiers for the form.
59
-     * @return string
60
-     * @todo   : at some point we can break this down into other static methods to abstract it a bit better.
61
-     */
62
-    public static function get_form_fields($input_vars = [], $form_id = false)
63
-    {
64
-
65
-        if (empty($input_vars)) {
66
-            EE_Error::add_error(
67
-                esc_html__('missing required variables for the form field generator', 'event_espresso'),
68
-                __FILE__,
69
-                __FUNCTION__,
70
-                __LINE__
71
-            );
72
-            return false;
73
-        }
74
-
75
-        $output        = "";
76
-        $inputs        = [];
77
-        $hidden_inputs = [];
78
-
79
-        // cycle thru inputs
80
-        foreach ($input_vars as $input_key => $input_value) {
81
-            $defaults = [
82
-                'append_content' => '',
83
-                'css_class'      => '',
84
-                'cols'           => 80,
85
-                'db-col'         => 'column_in_db',
86
-                'format'         => '%d',
87
-                'input'          => 'hidden',
88
-                'label'          => esc_html__('No label', 'event_espresso'),
89
-                'name'           => $input_key,
90
-                'options'        => [],
91
-                'required'       => false,
92
-                'tabindex'       => 0,
93
-                'rows'           => 10,
94
-                'type'           => 'int',
95
-                'validation'     => true,
96
-                'value'          => 'some_value_for_field',
97
-            ];
98
-
99
-            $input_value = wp_parse_args($input_value, $defaults);
100
-
101
-            $append_content = $input_value['append_content'];
102
-            $css_class      = $input_value['css_class'];
103
-            $cols           = $input_value['cols'];
104
-            $label          = $input_value['label'];
105
-            $name           = $input_value['name'];
106
-            $options        = $input_value['options'];
107
-            $required       = $input_value['required'];
108
-            $tab_index      = $input_value['tabindex'];
109
-            $rows           = $input_value['rows'];
110
-            $type           = $input_value['input'];
111
-            $value          = $input_value['value'];
112
-
113
-            $id    = $form_id ? $form_id . '-' . $input_key : $input_key;
114
-            $class = $required ? 'required ' . $css_class : $css_class;
115
-
116
-            // what type of input are we dealing with ?
117
-            switch ($type) {
118
-                case 'checkbox':
119
-                case 'radio':
120
-                    $field = self::adminMulti($value, $class, $id, $name, $required, $tab_index, $type, 1, $label);
121
-                    $field .= $append_content ?: '';
122
-                    break;
123
-
124
-                case 'hidden':
125
-                    $field           = null;
126
-                    $hidden_inputs[] = self::adminHidden($css_class, $id, $name, $value);
127
-                    break;
128
-
129
-                case 'select':
130
-                    $options = is_array($options) ? $options : explode(',', $options);
131
-                    $field   = self::adminLabel($id, $label, $required);
132
-                    $field   .= self::adminSelect($value, $class, $id, $name, $required, $tab_index, $options);
133
-                    $field   .= $append_content ?: '';
134
-                    break;
135
-
136
-                case 'textarea':
137
-                    $field = self::adminLabel($id, $label, $required);
138
-                    $field .= self::adminTextarea($class, $cols, $id, $name, $required, $rows, $tab_index, $value);
139
-                    $field .= $append_content ?: '';
140
-                    break;
141
-
142
-                case 'wp_editor':
143
-                    $label = esc_html($label);
144
-                    $field = "<h4>{$label}</h4>";
145
-                    $field .= $append_content ?: '';
146
-                    $field .= self::adminWpEditor(
147
-                        $class,
148
-                        $id,
149
-                        $name,
150
-                        $rows,
151
-                        $tab_index,
152
-                        $value
153
-                    );
154
-                    break;
155
-
156
-                default:
157
-                    $field = self::adminLabel($id, $label, $required);
158
-                    $field .= self::adminText($class, $id, $name, $required, $tab_index, $value);
159
-                    $field .= $append_content ?: '';
160
-            }
161
-            if ($field) {
162
-                $inputs[] = $field;
163
-            }
164
-        } // end foreach( $input_vars as $input_key => $input_value )
165
-
166
-        if (! empty($inputs)) {
167
-            $glue   = "
32
+	/**
33
+	 *  Generates HTML for the forms used on admin pages
34
+	 *
35
+	 *
36
+	 * @static
37
+	 * @access public
38
+	 * @param array $input_vars - array of input field details
39
+	 *                          format:
40
+	 *                          $template_form_fields['field-id'] = array(
41
+	 *                          'name' => 'name_attribute',
42
+	 *                          'label' => esc_html__('Field Label', 'event_espresso'), //or false
43
+	 *                          'input' => 'hidden', //field input type can be 'text', 'select', 'textarea', 'hidden',
44
+	 *                          'checkbox', 'wp_editor'
45
+	 *                          'type' => 'int', //what "type" the value is (i.e. string, int etc)
46
+	 *                          'required' => false, //boolean for whether the field is required
47
+	 *                          'validation' => true, //boolean, whether to validate the field (todo)
48
+	 *                          'value' => 'some_value_for_field', //what value is used for field
49
+	 *                          'format' => '%d', //what format the value is (%d, %f, or %s)
50
+	 *                          'db-col' => 'column_in_db' //used to indicate which column the field corresponds with
51
+	 *                          in the db
52
+	 *                          'options' => optiona, optionb || array('value' => 'label', '') //if the input type is
53
+	 *                          "select", this allows you to set the args for the different <option> tags.
54
+	 *                          'tabindex' => 1 //this allows you to set the tabindex for the field.
55
+	 *                          'append_content' => '' //this allows you to send in html content to append to the
56
+	 *                          field.
57
+	 *                          )
58
+	 * @param array $form_id    - used for defining unique identifiers for the form.
59
+	 * @return string
60
+	 * @todo   : at some point we can break this down into other static methods to abstract it a bit better.
61
+	 */
62
+	public static function get_form_fields($input_vars = [], $form_id = false)
63
+	{
64
+
65
+		if (empty($input_vars)) {
66
+			EE_Error::add_error(
67
+				esc_html__('missing required variables for the form field generator', 'event_espresso'),
68
+				__FILE__,
69
+				__FUNCTION__,
70
+				__LINE__
71
+			);
72
+			return false;
73
+		}
74
+
75
+		$output        = "";
76
+		$inputs        = [];
77
+		$hidden_inputs = [];
78
+
79
+		// cycle thru inputs
80
+		foreach ($input_vars as $input_key => $input_value) {
81
+			$defaults = [
82
+				'append_content' => '',
83
+				'css_class'      => '',
84
+				'cols'           => 80,
85
+				'db-col'         => 'column_in_db',
86
+				'format'         => '%d',
87
+				'input'          => 'hidden',
88
+				'label'          => esc_html__('No label', 'event_espresso'),
89
+				'name'           => $input_key,
90
+				'options'        => [],
91
+				'required'       => false,
92
+				'tabindex'       => 0,
93
+				'rows'           => 10,
94
+				'type'           => 'int',
95
+				'validation'     => true,
96
+				'value'          => 'some_value_for_field',
97
+			];
98
+
99
+			$input_value = wp_parse_args($input_value, $defaults);
100
+
101
+			$append_content = $input_value['append_content'];
102
+			$css_class      = $input_value['css_class'];
103
+			$cols           = $input_value['cols'];
104
+			$label          = $input_value['label'];
105
+			$name           = $input_value['name'];
106
+			$options        = $input_value['options'];
107
+			$required       = $input_value['required'];
108
+			$tab_index      = $input_value['tabindex'];
109
+			$rows           = $input_value['rows'];
110
+			$type           = $input_value['input'];
111
+			$value          = $input_value['value'];
112
+
113
+			$id    = $form_id ? $form_id . '-' . $input_key : $input_key;
114
+			$class = $required ? 'required ' . $css_class : $css_class;
115
+
116
+			// what type of input are we dealing with ?
117
+			switch ($type) {
118
+				case 'checkbox':
119
+				case 'radio':
120
+					$field = self::adminMulti($value, $class, $id, $name, $required, $tab_index, $type, 1, $label);
121
+					$field .= $append_content ?: '';
122
+					break;
123
+
124
+				case 'hidden':
125
+					$field           = null;
126
+					$hidden_inputs[] = self::adminHidden($css_class, $id, $name, $value);
127
+					break;
128
+
129
+				case 'select':
130
+					$options = is_array($options) ? $options : explode(',', $options);
131
+					$field   = self::adminLabel($id, $label, $required);
132
+					$field   .= self::adminSelect($value, $class, $id, $name, $required, $tab_index, $options);
133
+					$field   .= $append_content ?: '';
134
+					break;
135
+
136
+				case 'textarea':
137
+					$field = self::adminLabel($id, $label, $required);
138
+					$field .= self::adminTextarea($class, $cols, $id, $name, $required, $rows, $tab_index, $value);
139
+					$field .= $append_content ?: '';
140
+					break;
141
+
142
+				case 'wp_editor':
143
+					$label = esc_html($label);
144
+					$field = "<h4>{$label}</h4>";
145
+					$field .= $append_content ?: '';
146
+					$field .= self::adminWpEditor(
147
+						$class,
148
+						$id,
149
+						$name,
150
+						$rows,
151
+						$tab_index,
152
+						$value
153
+					);
154
+					break;
155
+
156
+				default:
157
+					$field = self::adminLabel($id, $label, $required);
158
+					$field .= self::adminText($class, $id, $name, $required, $tab_index, $value);
159
+					$field .= $append_content ?: '';
160
+			}
161
+			if ($field) {
162
+				$inputs[] = $field;
163
+			}
164
+		} // end foreach( $input_vars as $input_key => $input_value )
165
+
166
+		if (! empty($inputs)) {
167
+			$glue   = "
168 168
                 </li>
169 169
                 <li>
170 170
                     ";
171
-            $inputs = implode($glue, $inputs);
172
-            $output = "
171
+			$inputs = implode($glue, $inputs);
172
+			$output = "
173 173
             <ul>
174 174
                 <li>
175 175
                 {$inputs} 
176 176
                 </li>
177 177
             </ul>
178 178
             ";
179
-        }
180
-        return $output . implode("\n", $hidden_inputs);
181
-    }
182
-
183
-
184
-    /**
185
-     * form_fields_array
186
-     * This utility function assembles form fields from a given structured array with field information.
187
-     * //TODO: This is an alternate generator that we may want to use instead.
188
-     *
189
-     * @param array $fields structured array of fields to assemble in the following format:
190
-     *                      [field_name] => array(
191
-     *                      ['label'] => 'label for field',
192
-     *                      ['labels'] => array('label_1', 'label_2'); //optional - if the field type is a multi select
193
-     *                      type of field you can indicated the labels for each option via this index
194
-     *                      ['extra_desc'] => 'extra description for the field', //optional
195
-     *                      ['type'] => 'textarea'|'text'|'wp_editor'|'checkbox'|'radio'|'hidden'|'select', //defaults
196
-     *                      to text
197
-     *                      ['value'] => 'value that goes in the field', //(if multi then this is an array of values
198
-     *                      and the 'default' paramater will be used for what is selected)
199
-     *                      ['default'] => 'default if the field type is multi (i.e. select or radios or checkboxes)',
200
-     *                      ['class'] => 'name-of-class(es)-for-input',
201
-     *                      ['classes'] => array('class_1', 'class_2'); //optional - if the field type is a multi
202
-     *                      select type of field you can indicate the css class for each option via this index.
203
-     *                      ['id'] => 'css-id-for-input') //defaults to 'field_name'
204
-     *                      ['unique_id'] => 1 //defaults to empty string.  This is useful for when the fields
205
-     *                      generated are going to be used in a loop and you want to make sure that the field
206
-     *                      identifiers are unique from each other.
207
-     *                      ['dimensions'] => array(100,300), //defaults to empty array.  This is used by field types
208
-     *                      such as textarea to indicate cols/rows.
209
-     *                      ['tabindex'] => '' //this allows you to set the tabindex for the field.
210
-     *                      ['wpeditor_args'] => array() //if the type of field is wpeditor then this can optionally
211
-     *                      contain an array of arguments for the editor setup.
212
-     *
213
-     * @return array         an array of inputs for form indexed by field name, and in the following structure:
214
-     *     [field_name] => array( 'label' => '{label_html}', 'field' => '{input_html}'
215
-     */
216
-    public static function get_form_fields_array($fields)
217
-    {
218
-
219
-        $form_fields = [];
220
-        $fields      = (array) $fields;
221
-
222
-        foreach ($fields as $field_name => $field_atts) {
223
-            // defaults:
224
-            $defaults = [
225
-                'class'         => '',
226
-                'classes'       => '',
227
-                'default'       => '',
228
-                'dimensions'    => ['10', '5'],
229
-                'extra_desc'    => '',
230
-                'id'            => $field_name,
231
-                'label'         => '',
232
-                'labels'        => '',
233
-                'required'      => false,
234
-                'tabindex'      => 0,
235
-                'type'          => 'text',
236
-                'unique_id'     => '',
237
-                'value'         => '',
238
-                'wpeditor_args' => [],
239
-            ];
240
-            // merge defaults with passed arguments
241
-            $_fields = wp_parse_args($field_atts, $defaults);
242
-
243
-            $class          = $_fields['class'];
244
-            $classes        = $_fields['classes'];
245
-            $default        = $_fields['default'];
246
-            $dims           = $_fields['dimensions'];
247
-            $extra_desc     = $_fields['extra_desc'];
248
-            $id             = $_fields['id'];
249
-            $label          = $_fields['label'];
250
-            $labels         = $_fields['labels'];
251
-            $required       = $_fields['required'];
252
-            $tab_index      = $_fields['tabindex'];
253
-            $type           = $_fields['type'];
254
-            $unique_id      = $_fields['unique_id'];
255
-            $value          = $_fields['value'];
256
-            $wp_editor_args = $_fields['wpeditor_args'];
257
-
258
-            // generate label
259
-            $label = ! empty($label) ? self::adminLabel($id, $label, $required) : '';
260
-            // generate field name
261
-            $name = ! empty($unique_id) ? $field_name . '[' . $unique_id . ']' : $field_name;
262
-
263
-            // we determine what we're building based on the type
264
-            switch ($type) {
265
-                case 'checkbox':
266
-                case 'radio':
267
-                    if (is_array($value)) {
268
-                        $c_input = '';
269
-                        foreach ($value as $key => $val) {
270
-                            $c_input .= self::adminMulti(
271
-                                $default,
272
-                                isset($classes[ $key ]) ? $classes[ $key ] : '',
273
-                                $field_name . '_' . $value,
274
-                                $name,
275
-                                $required,
276
-                                $tab_index,
277
-                                $type,
278
-                                $val,
279
-                                isset($labels[ $key ]) ? $labels[ $key ] : ''
280
-                            );
281
-                        }
282
-                        $field = $c_input;
283
-                    } else {
284
-                        $field = self::adminMulti(
285
-                            $default,
286
-                            $class,
287
-                            $id,
288
-                            $name,
289
-                            $required,
290
-                            $tab_index,
291
-                            $type,
292
-                            $value,
293
-                            $_fields['label']
294
-                        );
295
-                    }
296
-                    break;
297
-
298
-                case 'hidden':
299
-                    $field = self::adminHidden($class, $id, $name, $value);
300
-                    break;
301
-
302
-                case 'select':
303
-                    $options = [];
304
-                    foreach ($value as $key => $val) {
305
-                        $options[ $val ] = isset($labels[ $key ]) ? $labels[ $key ] : '';
306
-                    }
307
-                    $field = self::adminSelect($default, $class, $id, $name, $required, $tab_index, $options);
308
-                    break;
309
-
310
-                case 'textarea':
311
-                    $field =
312
-                        self::adminTextarea($class, $dims[0], $id, $name, $required, $dims[1], $tab_index, $value);
313
-                    break;
314
-
315
-                case 'wp_editor':
316
-                    $field = self::adminWpEditor(
317
-                        $class,
318
-                        $_fields['id'],
319
-                        $name,
320
-                        $dims[1],
321
-                        $tab_index,
322
-                        $value,
323
-                        $wp_editor_args
324
-                    );
325
-                    break;
326
-
327
-                default:
328
-                    $field = self::adminText($class, $id, $name, $required, $tab_index, $value);
329
-            }
330
-
331
-            $form_fields[ $field_name ] = ['label' => $label, 'field' => $field . $extra_desc];
332
-        }
333
-
334
-        return $form_fields;
335
-    }
336
-
337
-
338
-    /**
339
-     * @param string $class
340
-     * @param string $id
341
-     * @param string $name
342
-     * @param string $value
343
-     * @return string
344
-     * @since   4.10.14.p
345
-     */
346
-    private static function adminHidden($class, $id, $name, $value)
347
-    {
348
-        $id    = esc_attr($id);
349
-        $name  = esc_attr($name);
350
-        $class = esc_attr($class);
351
-        return "
179
+		}
180
+		return $output . implode("\n", $hidden_inputs);
181
+	}
182
+
183
+
184
+	/**
185
+	 * form_fields_array
186
+	 * This utility function assembles form fields from a given structured array with field information.
187
+	 * //TODO: This is an alternate generator that we may want to use instead.
188
+	 *
189
+	 * @param array $fields structured array of fields to assemble in the following format:
190
+	 *                      [field_name] => array(
191
+	 *                      ['label'] => 'label for field',
192
+	 *                      ['labels'] => array('label_1', 'label_2'); //optional - if the field type is a multi select
193
+	 *                      type of field you can indicated the labels for each option via this index
194
+	 *                      ['extra_desc'] => 'extra description for the field', //optional
195
+	 *                      ['type'] => 'textarea'|'text'|'wp_editor'|'checkbox'|'radio'|'hidden'|'select', //defaults
196
+	 *                      to text
197
+	 *                      ['value'] => 'value that goes in the field', //(if multi then this is an array of values
198
+	 *                      and the 'default' paramater will be used for what is selected)
199
+	 *                      ['default'] => 'default if the field type is multi (i.e. select or radios or checkboxes)',
200
+	 *                      ['class'] => 'name-of-class(es)-for-input',
201
+	 *                      ['classes'] => array('class_1', 'class_2'); //optional - if the field type is a multi
202
+	 *                      select type of field you can indicate the css class for each option via this index.
203
+	 *                      ['id'] => 'css-id-for-input') //defaults to 'field_name'
204
+	 *                      ['unique_id'] => 1 //defaults to empty string.  This is useful for when the fields
205
+	 *                      generated are going to be used in a loop and you want to make sure that the field
206
+	 *                      identifiers are unique from each other.
207
+	 *                      ['dimensions'] => array(100,300), //defaults to empty array.  This is used by field types
208
+	 *                      such as textarea to indicate cols/rows.
209
+	 *                      ['tabindex'] => '' //this allows you to set the tabindex for the field.
210
+	 *                      ['wpeditor_args'] => array() //if the type of field is wpeditor then this can optionally
211
+	 *                      contain an array of arguments for the editor setup.
212
+	 *
213
+	 * @return array         an array of inputs for form indexed by field name, and in the following structure:
214
+	 *     [field_name] => array( 'label' => '{label_html}', 'field' => '{input_html}'
215
+	 */
216
+	public static function get_form_fields_array($fields)
217
+	{
218
+
219
+		$form_fields = [];
220
+		$fields      = (array) $fields;
221
+
222
+		foreach ($fields as $field_name => $field_atts) {
223
+			// defaults:
224
+			$defaults = [
225
+				'class'         => '',
226
+				'classes'       => '',
227
+				'default'       => '',
228
+				'dimensions'    => ['10', '5'],
229
+				'extra_desc'    => '',
230
+				'id'            => $field_name,
231
+				'label'         => '',
232
+				'labels'        => '',
233
+				'required'      => false,
234
+				'tabindex'      => 0,
235
+				'type'          => 'text',
236
+				'unique_id'     => '',
237
+				'value'         => '',
238
+				'wpeditor_args' => [],
239
+			];
240
+			// merge defaults with passed arguments
241
+			$_fields = wp_parse_args($field_atts, $defaults);
242
+
243
+			$class          = $_fields['class'];
244
+			$classes        = $_fields['classes'];
245
+			$default        = $_fields['default'];
246
+			$dims           = $_fields['dimensions'];
247
+			$extra_desc     = $_fields['extra_desc'];
248
+			$id             = $_fields['id'];
249
+			$label          = $_fields['label'];
250
+			$labels         = $_fields['labels'];
251
+			$required       = $_fields['required'];
252
+			$tab_index      = $_fields['tabindex'];
253
+			$type           = $_fields['type'];
254
+			$unique_id      = $_fields['unique_id'];
255
+			$value          = $_fields['value'];
256
+			$wp_editor_args = $_fields['wpeditor_args'];
257
+
258
+			// generate label
259
+			$label = ! empty($label) ? self::adminLabel($id, $label, $required) : '';
260
+			// generate field name
261
+			$name = ! empty($unique_id) ? $field_name . '[' . $unique_id . ']' : $field_name;
262
+
263
+			// we determine what we're building based on the type
264
+			switch ($type) {
265
+				case 'checkbox':
266
+				case 'radio':
267
+					if (is_array($value)) {
268
+						$c_input = '';
269
+						foreach ($value as $key => $val) {
270
+							$c_input .= self::adminMulti(
271
+								$default,
272
+								isset($classes[ $key ]) ? $classes[ $key ] : '',
273
+								$field_name . '_' . $value,
274
+								$name,
275
+								$required,
276
+								$tab_index,
277
+								$type,
278
+								$val,
279
+								isset($labels[ $key ]) ? $labels[ $key ] : ''
280
+							);
281
+						}
282
+						$field = $c_input;
283
+					} else {
284
+						$field = self::adminMulti(
285
+							$default,
286
+							$class,
287
+							$id,
288
+							$name,
289
+							$required,
290
+							$tab_index,
291
+							$type,
292
+							$value,
293
+							$_fields['label']
294
+						);
295
+					}
296
+					break;
297
+
298
+				case 'hidden':
299
+					$field = self::adminHidden($class, $id, $name, $value);
300
+					break;
301
+
302
+				case 'select':
303
+					$options = [];
304
+					foreach ($value as $key => $val) {
305
+						$options[ $val ] = isset($labels[ $key ]) ? $labels[ $key ] : '';
306
+					}
307
+					$field = self::adminSelect($default, $class, $id, $name, $required, $tab_index, $options);
308
+					break;
309
+
310
+				case 'textarea':
311
+					$field =
312
+						self::adminTextarea($class, $dims[0], $id, $name, $required, $dims[1], $tab_index, $value);
313
+					break;
314
+
315
+				case 'wp_editor':
316
+					$field = self::adminWpEditor(
317
+						$class,
318
+						$_fields['id'],
319
+						$name,
320
+						$dims[1],
321
+						$tab_index,
322
+						$value,
323
+						$wp_editor_args
324
+					);
325
+					break;
326
+
327
+				default:
328
+					$field = self::adminText($class, $id, $name, $required, $tab_index, $value);
329
+			}
330
+
331
+			$form_fields[ $field_name ] = ['label' => $label, 'field' => $field . $extra_desc];
332
+		}
333
+
334
+		return $form_fields;
335
+	}
336
+
337
+
338
+	/**
339
+	 * @param string $class
340
+	 * @param string $id
341
+	 * @param string $name
342
+	 * @param string $value
343
+	 * @return string
344
+	 * @since   4.10.14.p
345
+	 */
346
+	private static function adminHidden($class, $id, $name, $value)
347
+	{
348
+		$id    = esc_attr($id);
349
+		$name  = esc_attr($name);
350
+		$class = esc_attr($class);
351
+		return "
352 352
         <input name='{$name}' type='hidden' id='{$id}' class='{$class}' value='{$value}' />";
353
-    }
354
-
355
-
356
-    /**
357
-     * @param string $id
358
-     * @param string $label
359
-     * @param string $required
360
-     * @return string
361
-     * @since   4.10.14.p
362
-     */
363
-    private static function adminLabel($id, $label, $required)
364
-    {
365
-        $id       = esc_attr($id);
366
-        $label    = esc_html($label);
367
-        $required = filter_var($required, FILTER_VALIDATE_BOOLEAN) ? " <span>*</span>" : '';
368
-        return "<label for='{$id}'>{$label}{$required}</label>";
369
-    }
370
-
371
-
372
-    /**
373
-     * @param string $default
374
-     * @param string $class
375
-     * @param string $id
376
-     * @param string $name
377
-     * @param string $required
378
-     * @param int    $tab_index
379
-     * @param string $type
380
-     * @param string $value
381
-     * @param string $label
382
-     * @return string
383
-     * @since   4.10.14.p
384
-     */
385
-    private static function adminMulti($default, $class, $id, $name, $required, $tab_index, $type, $value, $label = '')
386
-    {
387
-        $id        = esc_attr($id);
388
-        $name      = esc_attr($name);
389
-        $class     = esc_attr($class);
390
-        $tab_index = absint($tab_index);
391
-        $checked   = ! empty($default) && $default == $value ? 'checked="checked" ' : '';
392
-        $required  = filter_var($required, FILTER_VALIDATE_BOOLEAN) ? 'required' : '';
393
-        $input     = "
353
+	}
354
+
355
+
356
+	/**
357
+	 * @param string $id
358
+	 * @param string $label
359
+	 * @param string $required
360
+	 * @return string
361
+	 * @since   4.10.14.p
362
+	 */
363
+	private static function adminLabel($id, $label, $required)
364
+	{
365
+		$id       = esc_attr($id);
366
+		$label    = esc_html($label);
367
+		$required = filter_var($required, FILTER_VALIDATE_BOOLEAN) ? " <span>*</span>" : '';
368
+		return "<label for='{$id}'>{$label}{$required}</label>";
369
+	}
370
+
371
+
372
+	/**
373
+	 * @param string $default
374
+	 * @param string $class
375
+	 * @param string $id
376
+	 * @param string $name
377
+	 * @param string $required
378
+	 * @param int    $tab_index
379
+	 * @param string $type
380
+	 * @param string $value
381
+	 * @param string $label
382
+	 * @return string
383
+	 * @since   4.10.14.p
384
+	 */
385
+	private static function adminMulti($default, $class, $id, $name, $required, $tab_index, $type, $value, $label = '')
386
+	{
387
+		$id        = esc_attr($id);
388
+		$name      = esc_attr($name);
389
+		$class     = esc_attr($class);
390
+		$tab_index = absint($tab_index);
391
+		$checked   = ! empty($default) && $default == $value ? 'checked="checked" ' : '';
392
+		$required  = filter_var($required, FILTER_VALIDATE_BOOLEAN) ? 'required' : '';
393
+		$input     = "
394 394
         <input name='{$name}[]' type='{$type}' id='{$id}' class='{$class}' value='{$value}' {$checked} {$required} tabindex='{$tab_index}'/>";
395
-        if ($label === '') {
396
-            return $input;
397
-        }
398
-        $label = esc_html($label);
399
-        return "
395
+		if ($label === '') {
396
+			return $input;
397
+		}
398
+		$label = esc_html($label);
399
+		return "
400 400
         <label for='$id'>
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
-        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
+		return "
434 434
         <select name='{$name}' id='{$id}' class='{$class}' {$required} tabindex='{$tab_index}'>
435 435
             {$options_html}
436 436
         </select>";
437
-    }
438
-
439
-
440
-    /**
441
-     * @param string $class
442
-     * @param string $id
443
-     * @param string $name
444
-     * @param string $required
445
-     * @param int    $tab_index
446
-     * @param string $value
447
-     * @return string
448
-     * @since   4.10.14.p
449
-     */
450
-    private static function adminText($class, $id, $name, $required, $tab_index, $value)
451
-    {
452
-        $id        = esc_attr($id);
453
-        $name      = esc_attr($name);
454
-        $class     = esc_attr($class);
455
-        $tab_index = absint($tab_index);
456
-        $required  = filter_var($required, FILTER_VALIDATE_BOOLEAN) ? 'required' : '';
457
-        return "
437
+	}
438
+
439
+
440
+	/**
441
+	 * @param string $class
442
+	 * @param string $id
443
+	 * @param string $name
444
+	 * @param string $required
445
+	 * @param int    $tab_index
446
+	 * @param string $value
447
+	 * @return string
448
+	 * @since   4.10.14.p
449
+	 */
450
+	private static function adminText($class, $id, $name, $required, $tab_index, $value)
451
+	{
452
+		$id        = esc_attr($id);
453
+		$name      = esc_attr($name);
454
+		$class     = esc_attr($class);
455
+		$tab_index = absint($tab_index);
456
+		$required  = filter_var($required, FILTER_VALIDATE_BOOLEAN) ? 'required' : '';
457
+		return "
458 458
         <input name='{$name}' type='text' id='{$id}' class='{$class}' value='{$value}' {$required} tabindex='{$tab_index}'/>";
459
-    }
460
-
461
-
462
-    /**
463
-     * @param string $class
464
-     * @param int    $cols
465
-     * @param string $id
466
-     * @param string $name
467
-     * @param string $required
468
-     * @param int    $rows
469
-     * @param int    $tab_index
470
-     * @param string $value
471
-     * @return string
472
-     * @since   4.10.14.p
473
-     */
474
-    private static function adminTextarea($class, $cols, $id, $name, $required, $rows, $tab_index, $value)
475
-    {
476
-        $id        = esc_attr($id);
477
-        $name      = esc_attr($name);
478
-        $class     = esc_attr($class);
479
-        $cols      = absint($cols);
480
-        $rows      = absint($rows);
481
-        $value     = esc_textarea($value);
482
-        $tab_index = absint($tab_index);
483
-        $required  = filter_var($required, FILTER_VALIDATE_BOOLEAN) ? 'required' : '';
484
-        return "
459
+	}
460
+
461
+
462
+	/**
463
+	 * @param string $class
464
+	 * @param int    $cols
465
+	 * @param string $id
466
+	 * @param string $name
467
+	 * @param string $required
468
+	 * @param int    $rows
469
+	 * @param int    $tab_index
470
+	 * @param string $value
471
+	 * @return string
472
+	 * @since   4.10.14.p
473
+	 */
474
+	private static function adminTextarea($class, $cols, $id, $name, $required, $rows, $tab_index, $value)
475
+	{
476
+		$id        = esc_attr($id);
477
+		$name      = esc_attr($name);
478
+		$class     = esc_attr($class);
479
+		$cols      = absint($cols);
480
+		$rows      = absint($rows);
481
+		$value     = esc_textarea($value);
482
+		$tab_index = absint($tab_index);
483
+		$required  = filter_var($required, FILTER_VALIDATE_BOOLEAN) ? 'required' : '';
484
+		return "
485 485
         <textarea name='{$name}' id='{$id}' class='{$class}' rows='{$rows}' cols='{$cols}' {$required} tabindex='{$tab_index}'>
486 486
             {$value}
487 487
         </textarea>";
488
-    }
489
-
490
-
491
-    /**
492
-     * @param string $class
493
-     * @param string $id
494
-     * @param string $name
495
-     * @param int    $rows
496
-     * @param int    $tab_index
497
-     * @param string $value
498
-     * @param array  $wp_editor_args
499
-     * @return false|string
500
-     * @since   4.10.14.p
501
-     */
502
-    private static function adminWpEditor($class, $id, $name, $rows, $tab_index, $value, $wp_editor_args = [])
503
-    {
504
-        $editor_settings = $wp_editor_args + [
505
-                'textarea_name' => esc_attr($name),
506
-                'textarea_rows' => absint($rows),
507
-                'editor_class'  => esc_attr($class),
508
-                'tabindex'      => absint($tab_index),
509
-            ];
510
-        ob_start();
511
-        wp_editor($value, esc_attr($id), $editor_settings);
512
-        return ob_get_clean();
513
-    }
514
-
515
-
516
-    /**
517
-     * espresso admin page select_input
518
-     * Turns an array into a select fields
519
-     *
520
-     * @static
521
-     * @access public
522
-     * @param string  $name       field name
523
-     * @param array   $values     option values, numbered array starting at 0, where each value is an array with a key
524
-     *                            'text' (meaning text to display' and 'id' (meaning the internal value) eg:
525
-     *                            array(1=>array('text'=>'Monday','id'=>1),2=>array('text'=>'Tuesday','id'=>2)...). or
526
-     *                            as an array of key-value pairs, where the key is to be used for the select input's
527
-     *                            name, and the value will be the text shown to the user.  Optionally you can also
528
-     *                            include an additional key of "class" which will add a specific class to the option
529
-     *                            for that value.
530
-     * @param string  $default    default value
531
-     * @param string  $parameters extra parameters
532
-     * @param string  $class      css class
533
-     * @param boolean $autosize   whether to autosize the select or not
534
-     * @return string              html string for the select input
535
-     */
536
-    public static function select_input($name, $values, $default = '', $parameters = '', $class = '', $autosize = true)
537
-    {
538
-        // if $values was submitted in the wrong format, convert it over
539
-        if (! empty($values) && (! array_key_exists(0, $values) || ! is_array($values[0]))) {
540
-            $converted_values = [];
541
-            foreach ($values as $id => $text) {
542
-                $converted_values[] = ['id' => $id, 'text' => $text];
543
-            }
544
-            $values = $converted_values;
545
-        }
546
-
547
-        $field =
548
-            '<select id="' . EEH_Formatter::ee_tep_output_string($name)
549
-            . '" name="' . EEH_Formatter::ee_tep_output_string($name)
550
-            . '"';
551
-
552
-        if (EEH_Formatter::ee_tep_not_null($parameters)) {
553
-            $field .= ' ' . $parameters;
554
-        }
555
-        if ($autosize) {
556
-            $size = 'med';
557
-            for ($ii = 0, $ni = sizeof($values); $ii < $ni; $ii++) {
558
-                if ($values[ $ii ]['text']) {
559
-                    if (strlen($values[ $ii ]['text']) > 5) {
560
-                        $size = 'wide';
561
-                    }
562
-                }
563
-            }
564
-        } else {
565
-            $size = '';
566
-        }
567
-
568
-        $field .= ' class="' . $class . ' ' . $size . '">';
569
-
570
-        if (empty($default) && isset($GLOBALS[ $name ])) {
571
-            $default = stripslashes($GLOBALS[ $name ]);
572
-        }
573
-
574
-
575
-        for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
576
-            $field .= '<option value="' . $values[ $i ]['id'] . '"';
577
-            if ($default == $values[ $i ]['id']) {
578
-                $field .= ' selected = "selected"';
579
-            }
580
-            if (isset($values[ $i ]['class'])) {
581
-                $field .= ' class="' . $values[ $i ]['class'] . '"';
582
-            }
583
-            $field .= '>' . $values[ $i ]['text'] . '</option>';
584
-        }
585
-        $field .= '</select>';
586
-
587
-        return $field;
588
-    }
589
-
590
-
591
-    /**
592
-     * generate_question_groups_html
593
-     *
594
-     * @param array  $question_groups
595
-     * @param string $group_wrapper
596
-     * @return string HTML
597
-     * @throws EE_Error
598
-     * @throws ReflectionException
599
-     */
600
-    public static function generate_question_groups_html($question_groups = [], $group_wrapper = 'fieldset')
601
-    {
602
-
603
-        $html                            = '';
604
-        $before_question_group_questions =
605
-            apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '');
606
-        $after_question_group_questions  =
607
-            apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '');
608
-
609
-        if (! empty($question_groups)) {
610
-            // loop thru question groups
611
-            foreach ($question_groups as $QSG) {
612
-                // check that questions exist
613
-                if (! empty($QSG['QSG_questions'])) {
614
-                    // use fieldsets
615
-                    $html .= "\n\t"
616
-                             . '<'
617
-                             . $group_wrapper
618
-                             . ' class="espresso-question-group-wrap" id="'
619
-                             . $QSG['QSG_identifier']
620
-                             . '">';
621
-                    // group_name
622
-                    $html .= $QSG['QSG_show_group_name']
623
-                        ? "\n\t\t"
624
-                          . '<h5 class="espresso-question-group-title-h5 section-title">'
625
-                          . self::prep_answer($QSG['QSG_name'])
626
-                          . '</h5>'
627
-                        : '';
628
-                    // group_desc
629
-                    $html .= $QSG['QSG_show_group_desc'] && ! empty($QSG['QSG_desc'])
630
-                        ? '<div class="espresso-question-group-desc-pg">'
631
-                          . self::prep_answer($QSG['QSG_desc'])
632
-                          . '</div>'
633
-                        : '';
634
-
635
-                    $html .= $before_question_group_questions;
636
-                    // loop thru questions
637
-                    foreach ($QSG['QSG_questions'] as $question) {
638
-                        $QFI  = new EE_Question_Form_Input(
639
-                            $question['qst_obj'],
640
-                            $question['ans_obj'],
641
-                            $question
642
-                        );
643
-                        $html .= self::generate_form_input($QFI);
644
-                    }
645
-                    $html .= $after_question_group_questions;
646
-                    $html .= "\n\t" . '</' . $group_wrapper . '>';
647
-                }
648
-            }
649
-        }
650
-
651
-        return $html;
652
-    }
653
-
654
-
655
-    /**
656
-     * generate_question_groups_html
657
-     *
658
-     * @param array  $question_groups
659
-     * @param array  $q_meta
660
-     * @param bool   $from_admin
661
-     * @param string $group_wrapper
662
-     * @return string HTML
663
-     * @throws EE_Error
664
-     * @throws ReflectionException
665
-     */
666
-    public static function generate_question_groups_html2(
667
-        $question_groups = [],
668
-        $q_meta = [],
669
-        $from_admin = false,
670
-        $group_wrapper = 'fieldset'
671
-    ) {
672
-
673
-        $html                            = '';
674
-        $before_question_group_questions =
675
-            apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '');
676
-        $after_question_group_questions  =
677
-            apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '');
678
-
679
-        $default_q_meta = [
680
-            'att_nmbr'    => 1,
681
-            'ticket_id'   => '',
682
-            'input_name'  => '',
683
-            'input_id'    => '',
684
-            'input_class' => '',
685
-        ];
686
-        $q_meta         = array_merge($default_q_meta, $q_meta);
687
-
688
-        if (! empty($question_groups)) {
689
-            // loop thru question groups
690
-            foreach ($question_groups as $QSG) {
691
-                if ($QSG instanceof EE_Question_Group) {
692
-                    // check that questions exist
693
-
694
-                    $where = ['QST_deleted' => 0];
695
-                    if (! $from_admin) {
696
-                        $where['QST_admin_only'] = 0;
697
-                    }
698
-                    $questions =
699
-                        $QSG->questions([$where, 'order_by' => ['Question_Group_Question.QGQ_order' => 'ASC']]);
700
-                    if (! empty($questions)) {
701
-                        // use fieldsets
702
-                        $html .= "\n\t"
703
-                                 . '<' . $group_wrapper . ' class="espresso-question-group-wrap" '
704
-                                 . 'id="' . $QSG->get('QSG_identifier') . '">';
705
-                        // group_name
706
-                        if ($QSG->show_group_name()) {
707
-                            $html .= "\n\t\t"
708
-                                     . '<h5 class="espresso-question-group-title-h5 section-title">'
709
-                                     . $QSG->get_pretty('QSG_name')
710
-                                     . '</h5>';
711
-                        }
712
-                        // group_desc
713
-                        if ($QSG->show_group_desc()) {
714
-                            $html .= '<div class="espresso-question-group-desc-pg">'
715
-                                     . $QSG->get_pretty('QSG_desc')
716
-                                     . '</div>';
717
-                        }
718
-
719
-                        $html .= $before_question_group_questions;
720
-                        // loop thru questions
721
-                        foreach ($questions as $QST) {
722
-                            $qstn_id = $QST->is_system_question() ? $QST->system_ID() : $QST->ID();
723
-
724
-                            $answer = null;
725
-
726
-                            /** @var RequestInterface $request */
727
-                            $request      = LoaderFactory::getLoader()->getShared(RequestInterface::class);
728
-                            $request_qstn = $request->getRequestParam('qstn', [], 'string', true);
729
-                            if (! empty($request_qstn) && isset($q_meta['input_id']) && isset($q_meta['att_nmbr'])) {
730
-                                // check for answer in $request_qstn in case we are reprocessing a form after an error
731
-                                if (isset($request_qstn[ $q_meta['input_id'] ][ $qstn_id ])) {
732
-                                    $answer = is_array($request_qstn[ $q_meta['input_id'] ][ $qstn_id ])
733
-                                        ? $request_qstn[ $q_meta['input_id'] ][ $qstn_id ]
734
-                                        : sanitize_text_field($request_qstn[ $q_meta['input_id'] ][ $qstn_id ]);
735
-                                }
736
-                            } elseif (isset($q_meta['attendee']) && $q_meta['attendee']) {
737
-                                // attendee data from the session
738
-                                $answer =
739
-                                    isset($q_meta['attendee'][ $qstn_id ]) ? $q_meta['attendee'][ $qstn_id ] : null;
740
-                            }
741
-
742
-
743
-                            $QFI  = new EE_Question_Form_Input(
744
-                                $QST,
745
-                                EE_Answer::new_instance(
746
-                                    [
747
-                                        'ANS_ID'    => 0,
748
-                                        'QST_ID'    => 0,
749
-                                        'REG_ID'    => 0,
750
-                                        'ANS_value' => $answer,
751
-                                    ]
752
-                                ),
753
-                                $q_meta
754
-                            );
755
-                            $html .= self::generate_form_input($QFI);
756
-                        }
757
-                        $html .= $after_question_group_questions;
758
-                        $html .= "\n\t" . '</' . $group_wrapper . '>';
759
-                    }
760
-                }
761
-            }
762
-        }
763
-        return $html;
764
-    }
765
-
766
-
767
-    /**
768
-     * generate_form_input
769
-     *
770
-     * @param EE_Question_Form_Input $QFI
771
-     * @return string HTML
772
-     * @throws EE_Error
773
-     * @throws ReflectionException
774
-     */
775
-    public static function generate_form_input(EE_Question_Form_Input $QFI)
776
-    {
777
-        if (isset($QFI->QST_admin_only) && $QFI->QST_admin_only && ! is_admin()) {
778
-            return '';
779
-        }
780
-        /** @var RequestInterface $request */
781
-        $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
782
-
783
-        $QFI = self::_load_system_dropdowns($QFI);
784
-        $QFI = self::_load_specialized_dropdowns($QFI);
785
-
786
-        // we also need to verify
787
-
788
-        $display_text = $QFI->get('QST_display_text');
789
-        $input_name   = $QFI->get('QST_input_name');
790
-        $answer       = $request->getRequestParam($input_name, $QFI->get('ANS_value'));
791
-        $input_id     = $QFI->get('QST_input_id');
792
-        $input_class  = $QFI->get('QST_input_class');
793
-        //      $disabled = $QFI->get('QST_disabled') ? ' disabled="disabled"' : '';
794
-        $disabled          = $QFI->get('QST_disabled');
795
-        $required_label    = apply_filters(' FHEE__EEH_Form_Fields__generate_form_input__required_label', '<em>*</em>');
796
-        $QST_required      = $QFI->get('QST_required');
797
-        $required          =
798
-            $QST_required
799
-                ? ['label' => $required_label, 'class' => 'required needs-value', 'title' => $QST_required]
800
-                : [];
801
-        $use_html_entities = $QFI->get_meta('htmlentities');
802
-        $required_text     =
803
-            $QFI->get('QST_required_text') != ''
804
-                ? $QFI->get('QST_required_text')
805
-                : esc_html__('This field is required', 'event_espresso');
806
-        $required_text     = $QST_required
807
-            ? "\n\t\t\t"
808
-              . '<div class="required-text hidden">'
809
-              . self::prep_answer($required_text, $use_html_entities)
810
-              . '</div>'
811
-            : '';
812
-        $label_class       = 'espresso-form-input-lbl';
813
-        $QST_options       = $QFI->options(true, $answer);
814
-        $options           = is_array($QST_options) ? self::prep_answer_options($QST_options) : [];
815
-        $system_ID         = $QFI->get('QST_system');
816
-        $label_b4          = $QFI->get_meta('label_b4');
817
-        $use_desc_4_label  = $QFI->get_meta('use_desc_4_label');
818
-
819
-
820
-        switch ($QFI->get('QST_type')) {
821
-            case 'TEXTAREA':
822
-                return EEH_Form_Fields::textarea(
823
-                    $display_text,
824
-                    $answer,
825
-                    $input_name,
826
-                    $input_id,
827
-                    $input_class,
828
-                    [],
829
-                    $required,
830
-                    $required_text,
831
-                    $label_class,
832
-                    $disabled,
833
-                    $system_ID,
834
-                    $use_html_entities
835
-                );
836
-
837
-            case 'DROPDOWN':
838
-                return EEH_Form_Fields::select(
839
-                    $display_text,
840
-                    $answer,
841
-                    $options,
842
-                    $input_name,
843
-                    $input_id,
844
-                    $input_class,
845
-                    $required,
846
-                    $required_text,
847
-                    $label_class,
848
-                    $disabled,
849
-                    $system_ID,
850
-                    $use_html_entities,
851
-                    true
852
-                );
853
-
854
-
855
-            case 'RADIO_BTN':
856
-                return EEH_Form_Fields::radio(
857
-                    $display_text,
858
-                    $answer,
859
-                    $options,
860
-                    $input_name,
861
-                    $input_id,
862
-                    $input_class,
863
-                    $required,
864
-                    $required_text,
865
-                    $label_class,
866
-                    $disabled,
867
-                    $system_ID,
868
-                    $use_html_entities,
869
-                    $label_b4,
870
-                    $use_desc_4_label
871
-                );
872
-
873
-            case 'CHECKBOX':
874
-                return EEH_Form_Fields::checkbox(
875
-                    $display_text,
876
-                    $answer,
877
-                    $options,
878
-                    $input_name,
879
-                    $input_id,
880
-                    $input_class,
881
-                    $required,
882
-                    $required_text,
883
-                    $label_class,
884
-                    $disabled,
885
-                    $label_b4,
886
-                    $system_ID,
887
-                    $use_html_entities
888
-                );
889
-
890
-            case 'DATE':
891
-                return EEH_Form_Fields::datepicker(
892
-                    $display_text,
893
-                    $answer,
894
-                    $input_name,
895
-                    $input_id,
896
-                    $input_class,
897
-                    $required,
898
-                    $required_text,
899
-                    $label_class,
900
-                    $disabled,
901
-                    $system_ID,
902
-                    $use_html_entities
903
-                );
904
-
905
-            case 'TEXT':
906
-            default:
907
-                return EEH_Form_Fields::text(
908
-                    $display_text,
909
-                    $answer,
910
-                    $input_name,
911
-                    $input_id,
912
-                    $input_class,
913
-                    $required,
914
-                    $required_text,
915
-                    $label_class,
916
-                    $disabled,
917
-                    $system_ID,
918
-                    $use_html_entities
919
-                );
920
-        }
921
-    }
922
-
923
-
924
-    /**
925
-     * generates HTML for a form text input
926
-     *
927
-     * @param string $question    label content
928
-     * @param string $answer      form input value attribute
929
-     * @param string $name        form input name attribute
930
-     * @param string $id          form input css id attribute
931
-     * @param string $class       form input css class attribute
932
-     * @param array  $required    'label', 'class', and 'msg' - array of values for required "label" content, css
933
-     *                            required 'class', and required 'msg' attribute
934
-     * @param string $label_class css class attribute for the label
935
-     * @param string $disabled    disabled="disabled" or null
936
-     * @return string HTML
937
-     */
938
-    public static function text(
939
-        $question = false,
940
-        $answer = null,
941
-        $name = false,
942
-        $id = '',
943
-        $class = '',
944
-        $required = false,
945
-        $required_text = '',
946
-        $label_class = '',
947
-        $disabled = false,
948
-        $system_ID = false,
949
-        $use_html_entities = true
950
-    ) {
951
-        // need these
952
-        if (! $question || ! $name) {
953
-            return null;
954
-        }
955
-        // prep the answer
956
-        $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities);
957
-        // prep the required array
958
-        $required = self::prep_required($required);
959
-        // set disabled tag
960
-        $disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
961
-        // ya gots ta have style man!!!
962
-        $txt_class = is_admin() ? 'regular-text' : 'espresso-text-inp';
963
-        $class     = empty($class) ? $txt_class : $class;
964
-        $class     .= ! empty($system_ID) ? ' ' . $system_ID : '';
965
-        $extra     = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
966
-
967
-        $label_html =
968
-            $required_text
969
-            . "\n\t\t\t"
970
-            . '<label for="' . $name . '" class="' . $label_class . '">'
971
-            . self::prep_question($question)
972
-            . $required['label']
973
-            . '</label><br/>';
974
-        // filter label but ensure required text comes before it
975
-        $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
976
-
977
-        $input_html =
978
-            "\n\t\t\t"
979
-            . '<input type="text" name="' . $name . '" id="' . $id . '" '
980
-            . 'class="' . $class . ' ' . $required['class'] . '" value="' . esc_attr($answer) . '"  '
981
-            . 'title="' . esc_attr($required['msg']) . '" ' . $disabled . ' ' . $extra . '/>';
982
-
983
-        $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
984
-        return $label_html . $input_html;
985
-    }
986
-
987
-
988
-    /**
989
-     * generates HTML for a form textarea
990
-     *
991
-     * @param string $question    label content
992
-     * @param string $answer      form input value attribute
993
-     * @param string $name        form input name attribute
994
-     * @param string $id          form input css id attribute
995
-     * @param string $class       form input css class attribute
996
-     * @param array  $dimensions  array of form input rows and cols attributes : array( 'rows' => 3, 'cols' => 40 )
997
-     * @param array  $required    'label', 'class', and 'msg' - array of values for required "label" content, css
998
-     *                            required 'class', and required 'msg' attribute
999
-     * @param string $label_class css class attribute for the label
1000
-     * @param string $disabled    disabled="disabled" or null
1001
-     * @return string HTML
1002
-     */
1003
-    public static function textarea(
1004
-        $question = false,
1005
-        $answer = null,
1006
-        $name = false,
1007
-        $id = '',
1008
-        $class = '',
1009
-        $dimensions = false,
1010
-        $required = false,
1011
-        $required_text = '',
1012
-        $label_class = '',
1013
-        $disabled = false,
1014
-        $system_ID = false,
1015
-        $use_html_entities = true
1016
-    ) {
1017
-        // need these
1018
-        if (! $question || ! $name) {
1019
-            return null;
1020
-        }
1021
-        // prep the answer
1022
-        $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities);
1023
-        // prep the required array
1024
-        $required = self::prep_required($required);
1025
-        // make sure $dimensions is an array
1026
-        $dimensions = is_array($dimensions) ? $dimensions : [];
1027
-        // and set some defaults
1028
-        $dimensions = array_merge(['rows' => 3, 'cols' => 40], $dimensions);
1029
-        // set disabled tag
1030
-        $disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
1031
-        // ya gots ta have style man!!!
1032
-        $txt_class = is_admin() ? 'regular-text' : 'espresso-textarea-inp';
1033
-        $class     = empty($class) ? $txt_class : $class;
1034
-        $class     .= ! empty($system_ID) ? ' ' . $system_ID : '';
1035
-        $extra     = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1036
-
1037
-        $label_html =
1038
-            $required_text
1039
-            . "\n\t\t\t"
1040
-            . '<label for="' . $name . '" class="' . $label_class . '">'
1041
-            . self::prep_question($question)
1042
-            . $required['label']
1043
-            . '</label><br/>';
1044
-        // filter label but ensure required text comes before it
1045
-        $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
1046
-
1047
-        $input_html =
1048
-            "\n\t\t\t"
1049
-            . '<textarea name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" '
1050
-            . 'rows="' . $dimensions['rows'] . '" cols="' . $dimensions['cols'] . '"  '
1051
-            . 'title="' . $required['msg'] . '" ' . $disabled . ' ' . $extra . '>'
1052
-            . esc_textarea($answer)
1053
-            . '</textarea>';
1054
-
1055
-        $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1056
-        return $label_html . $input_html;
1057
-    }
1058
-
1059
-
1060
-    /**
1061
-     * generates HTML for a form select input
1062
-     *
1063
-     * @param string $question    label content
1064
-     * @param string $answer      form input value attribute
1065
-     * @param array  $options     array of answer options where array key = option value and array value = option
1066
-     *                            display text
1067
-     * @param string $name        form input name attribute
1068
-     * @param string $id          form input css id attribute
1069
-     * @param string $class       form input css class attribute
1070
-     * @param array  $required    'label', 'class', and 'msg' - array of values for required "label" content, css
1071
-     *                            required 'class', and required 'msg' attribute
1072
-     * @param string $label_class css class attribute for the label
1073
-     * @param string $disabled    disabled="disabled" or null
1074
-     * @return string HTML
1075
-     */
1076
-    public static function select(
1077
-        $question = false,
1078
-        $answer = null,
1079
-        $options = false,
1080
-        $name = false,
1081
-        $id = '',
1082
-        $class = '',
1083
-        $required = false,
1084
-        $required_text = '',
1085
-        $label_class = '',
1086
-        $disabled = false,
1087
-        $system_ID = false,
1088
-        $use_html_entities = true,
1089
-        $add_please_select_option = false
1090
-    ) {
1091
-
1092
-        // need these
1093
-        if (! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
1094
-            return null;
1095
-        }
1096
-        // prep the answer
1097
-        $answer =
1098
-            is_array($answer)
1099
-                ? self::prep_answer(array_shift($answer), $use_html_entities)
1100
-                : self::prep_answer(
1101
-                    $answer,
1102
-                    $use_html_entities
1103
-                );
1104
-        // prep the required array
1105
-        $required = self::prep_required($required);
1106
-        // set disabled tag
1107
-        $disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
1108
-        // ya gots ta have style man!!!
1109
-        $txt_class = is_admin() ? 'wide' : 'espresso-select-inp';
1110
-        $class     = empty($class) ? $txt_class : $class;
1111
-        $class     .= ! empty($system_ID) ? ' ' . $system_ID : '';
1112
-        $extra     = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1113
-
1114
-        $label_html =
1115
-            $required_text
1116
-            . "\n\t\t\t"
1117
-            . '<label for="' . $name . '" class="' . $label_class . '">'
1118
-            . self::prep_question($question)
1119
-            . $required['label']
1120
-            . '</label><br/>';
1121
-        // filter label but ensure required text comes before it
1122
-        $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
1123
-
1124
-        $input_html =
1125
-            "\n\t\t\t"
1126
-            . '<select name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" '
1127
-            . 'title="' . esc_attr($required['msg']) . '"' . $disabled . ' ' . $extra . '>';
1128
-        // recursively count array elements, to determine total number of options
1129
-        $only_option = count($options, 1) == 1;
1130
-        if (! $only_option) {
1131
-            // if there is NO answer set and there are multiple options to choose from, then set the "please select" message as selected
1132
-            $selected   = $answer === null ? ' selected="selected"' : '';
1133
-            $input_html .= $add_please_select_option
1134
-                ? "\n\t\t\t\t"
1135
-                  . '<option value=""' . $selected . '>'
1136
-                  . esc_html__(' - please select - ', 'event_espresso')
1137
-                  . '</option>'
1138
-                : '';
1139
-        }
1140
-        foreach ($options as $key => $value) {
1141
-            // if value is an array, then create option groups, else create regular ol' options
1142
-            $input_html .= is_array($value)
1143
-                ? self::_generate_select_option_group(
1144
-                    $key,
1145
-                    $value,
1146
-                    $answer,
1147
-                    $use_html_entities
1148
-                )
1149
-                : self::_generate_select_option(
1150
-                    $value->value(),
1151
-                    $value->desc(),
1152
-                    $answer,
1153
-                    $only_option,
1154
-                    $use_html_entities
1155
-                );
1156
-        }
1157
-
1158
-        $input_html .= "\n\t\t\t" . '</select>';
1159
-
1160
-        $input_html =
1161
-            apply_filters(
1162
-                'FHEE__EEH_Form_Fields__select__before_end_wrapper',
1163
-                $input_html,
1164
-                $question,
1165
-                $answer,
1166
-                $name,
1167
-                $id,
1168
-                $class,
1169
-                $system_ID
1170
-            );
1171
-
1172
-        $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1173
-        return $label_html . $input_html;
1174
-    }
1175
-
1176
-
1177
-    /**
1178
-     *  _generate_select_option_group
1179
-     *
1180
-     *  if  $value for a select box is an array, then the key will be used as the optgroup label
1181
-     *  and the value array will be looped thru and the elements sent to _generate_select_option
1182
-     *
1183
-     * @param mixed   $opt_group
1184
-     * @param mixed   $QSOs
1185
-     * @param mixed   $answer
1186
-     * @param boolean $use_html_entities
1187
-     * @return string
1188
-     */
1189
-    private static function _generate_select_option_group($opt_group, $QSOs, $answer, $use_html_entities = true)
1190
-    {
1191
-        $html = "\n\t\t\t\t" . '<optgroup label="' . self::prep_option_value($opt_group) . '">';
1192
-        foreach ($QSOs as $QSO) {
1193
-            $html .= self::_generate_select_option($QSO->value(), $QSO->desc(), $answer, false, $use_html_entities);
1194
-        }
1195
-        $html .= "\n\t\t\t\t" . '</optgroup>';
1196
-        return $html;
1197
-    }
1198
-
1199
-
1200
-    /**
1201
-     *  _generate_select_option
1202
-     *
1203
-     * @param mixed   $key
1204
-     * @param mixed   $value
1205
-     * @param mixed   $answer
1206
-     * @param int     $only_option
1207
-     * @param boolean $use_html_entities
1208
-     * @return string
1209
-     */
1210
-    private static function _generate_select_option(
1211
-        $key,
1212
-        $value,
1213
-        $answer,
1214
-        $only_option = false,
1215
-        $use_html_entities = true
1216
-    ) {
1217
-        $key      = self::prep_answer($key, $use_html_entities);
1218
-        $value    = self::prep_answer($value, $use_html_entities);
1219
-        $value    = ! empty($value) ? $value : $key;
1220
-        $selected = ($answer == $key || $only_option) ? 'selected="selected"' : '';
1221
-        return "\n\t\t\t\t"
1222
-               . '<option value="' . self::prep_option_value($key) . '" ' . $selected . '> '
1223
-               . $value
1224
-               . '&nbsp;&nbsp;&nbsp;</option>';
1225
-    }
1226
-
1227
-
1228
-    /**
1229
-     * generates HTML for form radio button inputs
1230
-     *
1231
-     * @param bool|string $question    label content
1232
-     * @param string      $answer      form input value attribute
1233
-     * @param array|bool  $options     array of answer options where array key = option value and array value = option
1234
-     *                                 display text
1235
-     * @param bool|string $name        form input name attribute
1236
-     * @param string      $id          form input css id attribute
1237
-     * @param string      $class       form input css class attribute
1238
-     * @param array|bool  $required    'label', 'class', and 'msg' - array of values for required "label" content, css
1239
-     *                                 required 'class', and required 'msg' attribute
1240
-     * @param string      $required_text
1241
-     * @param string      $label_class css class attribute for the label
1242
-     * @param bool|string $disabled    disabled="disabled" or null
1243
-     * @param bool        $system_ID
1244
-     * @param bool        $use_html_entities
1245
-     * @param bool        $label_b4
1246
-     * @param bool        $use_desc_4_label
1247
-     * @return string HTML
1248
-     */
1249
-    public static function radio(
1250
-        $question = false,
1251
-        $answer = null,
1252
-        $options = false,
1253
-        $name = false,
1254
-        $id = '',
1255
-        $class = '',
1256
-        $required = false,
1257
-        $required_text = '',
1258
-        $label_class = '',
1259
-        $disabled = false,
1260
-        $system_ID = false,
1261
-        $use_html_entities = true,
1262
-        $label_b4 = false,
1263
-        $use_desc_4_label = false
1264
-    ) {
1265
-        // need these
1266
-        if (! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
1267
-            return null;
1268
-        }
1269
-        // prep the answer
1270
-        $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities);
1271
-        // prep the required array
1272
-        $required = self::prep_required($required);
1273
-        // set disabled tag
1274
-        $disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
1275
-        // ya gots ta have style man!!!
1276
-        $radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class;
1277
-        $class       = ! empty($class) ? $class : 'espresso-radio-btn-inp';
1278
-        $extra       = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1279
-
1280
-        $label_html =
1281
-            $required_text
1282
-            . "\n\t\t\t"
1283
-            . '<label class="' . $label_class . '">'
1284
-            . self::prep_question($question)
1285
-            . $required['label']
1286
-            . '</label> ';
1287
-        // filter label but ensure required text comes before it
1288
-        $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
1289
-
1290
-        $input_html =
1291
-            "\n\t\t\t"
1292
-            . '<ul id="' . $id . '-ul" class="espresso-radio-btn-options-ul ' . $label_class . ' ' . $class . '-ul">';
1293
-
1294
-        $class .= ! empty($system_ID) ? ' ' . $system_ID : '';
1295
-        $class .= ! empty($required['class']) ? ' ' . $required['class'] : '';
1296
-
1297
-        foreach ($options as $OPT) {
1298
-            if ($OPT instanceof EE_Question_Option) {
1299
-                $value   = self::prep_option_value($OPT->value());
1300
-                $label   = $use_desc_4_label ? $OPT->desc() : $OPT->value();
1301
-                $size    = $use_desc_4_label
1302
-                    ? self::get_label_size_class($OPT->value() . ' ' . $OPT->desc())
1303
-                    : self::get_label_size_class($OPT->value());
1304
-                $desc    = $OPT->desc();// no self::prep_answer
1305
-                $answer  = is_numeric($value) && empty($answer) ? 0 : $answer;
1306
-                $checked = (string) $value == (string) $answer ? ' checked="checked"' : '';
1307
-                $opt     = '-' . sanitize_key($value);
1308
-
1309
-                $input_html .= "\n\t\t\t\t" . '<li' . $size . '>';
1310
-                $input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-radio-btn-lbl">';
1311
-                $input_html .= $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $label . '</span>' : '';
1312
-                $input_html .= "\n\t\t\t\t\t\t"
1313
-                               . '<input type="radio" name="' . $name . '" id="' . $id . $opt . '" '
1314
-                               . 'class="' . $class . '" value="' . $value . '" '
1315
-                               . 'title="' . esc_attr($required['msg']) . '" ' . $disabled
1316
-                               . $checked . ' ' . $extra . '/>';
1317
-                $input_html .= ! $label_b4
1318
-                    ? "\n\t\t\t\t\t\t"
1319
-                      . '<span class="espresso-radio-btn-desc">'
1320
-                      . $label
1321
-                      . '</span>'
1322
-                    : '';
1323
-                $input_html .= "\n\t\t\t\t\t" . '</label>';
1324
-                $input_html .= $use_desc_4_label
1325
-                    ? ''
1326
-                    : '<span class="espresso-radio-btn-option-desc small-text grey-text">' . $desc . '</span>';
1327
-                $input_html .= "\n\t\t\t\t" . '</li>';
1328
-            }
1329
-        }
1330
-
1331
-        $input_html .= "\n\t\t\t" . '</ul>';
1332
-
1333
-        $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1334
-        return $label_html . $input_html;
1335
-    }
1336
-
1337
-
1338
-    /**
1339
-     * generates HTML for form checkbox inputs
1340
-     *
1341
-     * @param string $question    label content
1342
-     * @param string $answer      form input value attribute
1343
-     * @param array  $options     array of options where array key = option value and array value = option display text
1344
-     * @param string $name        form input name attribute
1345
-     * @param string $id          form input css id attribute
1346
-     * @param string $class       form input css class attribute
1347
-     * @param array  $required    'label', 'class', and 'msg' - array of values for required "label" content, css
1348
-     *                            required 'class', and required 'msg' attribute
1349
-     * @param string $label_class css class attribute for the label
1350
-     * @param string $disabled    disabled="disabled" or null
1351
-     * @return string HTML
1352
-     */
1353
-    public static function checkbox(
1354
-        $question = false,
1355
-        $answer = null,
1356
-        $options = false,
1357
-        $name = false,
1358
-        $id = '',
1359
-        $class = '',
1360
-        $required = false,
1361
-        $required_text = '',
1362
-        $label_class = '',
1363
-        $disabled = false,
1364
-        $label_b4 = false,
1365
-        $system_ID = false,
1366
-        $use_html_entities = true
1367
-    ) {
1368
-        // need these
1369
-        if (! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
1370
-            return null;
1371
-        }
1372
-        $answer = maybe_unserialize($answer);
1373
-
1374
-        // prep the answer(s)
1375
-        $answer = is_array($answer) ? $answer : [sanitize_key($answer) => $answer];
1376
-
1377
-        foreach ($answer as $key => $value) {
1378
-            $key            = self::prep_option_value($key);
1379
-            $answer[ $key ] = self::prep_answer($value, $use_html_entities);
1380
-        }
1381
-
1382
-        // prep the required array
1383
-        $required = self::prep_required($required);
1384
-        // set disabled tag
1385
-        $disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
1386
-        // ya gots ta have style man!!!
1387
-        $radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class;
1388
-        $class       = empty($class) ? 'espresso-radio-btn-inp' : $class;
1389
-        $extra       = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1390
-
1391
-        $label_html =
1392
-            $required_text
1393
-            . "\n\t\t\t"
1394
-            . '<label class="' . $label_class . '">'
1395
-            . self::prep_question($question)
1396
-            . $required['label']
1397
-            . '</label> ';
1398
-        // filter label but ensure required text comes before it
1399
-        $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
1400
-
1401
-        $input_html =
1402
-            "\n\t\t\t"
1403
-            . '<ul id="' . $id . '-ul" class="espresso-checkbox-options-ul ' . $label_class . ' ' . $class . '-ul">';
1404
-
1405
-        $class .= ! empty($system_ID) ? ' ' . $system_ID : '';
1406
-        $class .= ! empty($required['class']) ? ' ' . $required['class'] : '';
1407
-
1408
-        foreach ($options as $OPT) {
1409
-            $value = $OPT->value();// self::prep_option_value( $OPT->value() );
1410
-            $size  = self::get_label_size_class($OPT->value() . ' ' . $OPT->desc());
1411
-            $text  = self::prep_answer($OPT->value());
1412
-            $desc  = $OPT->desc();
1413
-            $opt   = '-' . sanitize_key($value);
1414
-
1415
-            $checked = is_array($answer) && in_array($text, $answer) ? ' checked="checked"' : '';
1416
-
1417
-            $input_html .= "\n\t\t\t\t" . '<li' . $size . '>';
1418
-            $input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-checkbox-lbl">';
1419
-            $input_html .= $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : '';
1420
-            $input_html .= "\n\t\t\t\t\t\t"
1421
-                           . '<input type="checkbox" name="' . $name . '[' . $OPT->ID() . ']" '
1422
-                           . 'id="' . $id . $opt . '" class="' . $class . '" value="' . $value . '" '
1423
-                           . 'title="' . esc_attr($required['msg']) . '" ' . $disabled . $checked . ' ' . $extra . '/>';
1424
-            $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : '';
1425
-            $input_html .= "\n\t\t\t\t\t" . '</label>';
1426
-            if (! empty($desc) && $desc != $text) {
1427
-                $input_html .= "\n\t\t\t\t\t"
1428
-                               . ' &nbsp; <br/><div class="espresso-checkbox-option-desc small-text grey-text">'
1429
-                               . $desc
1430
-                               . '</div>';
1431
-            }
1432
-            $input_html .= "\n\t\t\t\t" . '</li>';
1433
-        }
1434
-
1435
-        $input_html .= "\n\t\t\t" . '</ul>';
1436
-
1437
-        $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1438
-        return $label_html . $input_html;
1439
-    }
1440
-
1441
-
1442
-    /**
1443
-     * generates HTML for a form datepicker input
1444
-     *
1445
-     * @param string $question    label content
1446
-     * @param string $answer      form input value attribute
1447
-     * @param string $name        form input name attribute
1448
-     * @param string $id          form input css id attribute
1449
-     * @param string $class       form input css class attribute
1450
-     * @param array  $required    'label', 'class', and 'msg' - array of values for required "label" content, css
1451
-     *                            required 'class', and required 'msg' attribute
1452
-     * @param string $label_class css class attribute for the label
1453
-     * @param string $disabled    disabled="disabled" or null
1454
-     * @return string HTML
1455
-     */
1456
-    public static function datepicker(
1457
-        $question = false,
1458
-        $answer = null,
1459
-        $name = false,
1460
-        $id = '',
1461
-        $class = '',
1462
-        $required = false,
1463
-        $required_text = '',
1464
-        $label_class = '',
1465
-        $disabled = false,
1466
-        $system_ID = false,
1467
-        $use_html_entities = true
1468
-    ) {
1469
-        // need these
1470
-        if (! $question || ! $name) {
1471
-            return null;
1472
-        }
1473
-        // prep the answer
1474
-        $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities);
1475
-        // prep the required array
1476
-        $required = self::prep_required($required);
1477
-        // set disabled tag
1478
-        $disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
1479
-        // ya gots ta have style man!!!
1480
-        $txt_class = is_admin() ? 'regular-text' : 'espresso-datepicker-inp';
1481
-        $class     = empty($class) ? $txt_class : $class;
1482
-        $class     .= ! empty($system_ID) ? ' ' . $system_ID : '';
1483
-        $extra     = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1484
-
1485
-        $label_html =
1486
-            $required_text
1487
-            . "\n\t\t\t"
1488
-            . '<label for="' . $name . '" class="' . $label_class . '">'
1489
-            . self::prep_question($question)
1490
-            . $required['label']
1491
-            . '</label><br/>';
1492
-        // filter label but ensure required text comes before it
1493
-        $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
1494
-
1495
-        $input_html =
1496
-            "\n\t\t\t"
1497
-            . '<input type="text" name="' . $name . '" id="' . $id . '" '
1498
-            . 'class="' . $class . ' ' . $required['class'] . ' datepicker" value="' . $answer . '"  '
1499
-            . 'title="' . esc_attr($required['msg']) . '" ' . $disabled . ' ' . $extra . '/>';
1500
-
1501
-        // enqueue scripts
1502
-        wp_register_style(
1503
-            'espresso-ui-theme',
1504
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1505
-            [],
1506
-            EVENT_ESPRESSO_VERSION
1507
-        );
1508
-        wp_enqueue_style('espresso-ui-theme');
1509
-        wp_enqueue_script('jquery-ui-datepicker');
1510
-
1511
-        $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1512
-        return $label_html . $input_html;
1513
-    }
1514
-
1515
-
1516
-    /**
1517
-     *  remove_label_keep_required_msg
1518
-     *  this will strip out a form input's label HTML while keeping the required text HTML that MUST be before the label
1519
-     *
1520
-     * @access public
1521
-     * @return     string
1522
-     */
1523
-    public static function remove_label_keep_required_msg($label_html, $required_text)
1524
-    {
1525
-        return $required_text;
1526
-    }
1527
-
1528
-
1529
-    /**
1530
-     * Simply returns the HTML for a hidden input of the given name and value.
1531
-     *
1532
-     * @param string $name
1533
-     * @param string $value
1534
-     * @return string HTML
1535
-     */
1536
-    public static function hidden_input($name, $value, $id = '')
1537
-    {
1538
-        $id = ! empty($id) ? $id : $name;
1539
-        return '<input id="' . $id . '" type="hidden" name="' . $name . '" value="' . $value . '"/>';
1540
-    }
1541
-
1542
-
1543
-    /**
1544
-     * prep_question
1545
-     *
1546
-     * @param string $question
1547
-     * @return string
1548
-     */
1549
-    public static function prep_question($question)
1550
-    {
1551
-        return $question;
1552
-    }
1553
-
1554
-
1555
-    /**
1556
-     *  prep_answer
1557
-     *
1558
-     * @param mixed $answer
1559
-     * @return string
1560
-     */
1561
-    public static function prep_answer($answer, $use_html_entities = true)
1562
-    {
1563
-        // make sure we convert bools first.  Otherwise (bool) false becomes an empty string which is NOT desired,
1564
-        // we want "0".
1565
-        if (is_bool($answer)) {
1566
-            $answer = $answer ? 1 : 0;
1567
-        }
1568
-        $answer = trim(stripslashes(str_replace('&#039;', "'", $answer)));
1569
-        return $use_html_entities ? htmlentities($answer, ENT_QUOTES, 'UTF-8') : $answer;
1570
-    }
1571
-
1572
-
1573
-    /**
1574
-     *  prep_answer_options
1575
-     *
1576
-     * @param array $QSOs array of EE_Question_Option objects
1577
-     * @return array
1578
-     */
1579
-    public static function prep_answer_options($QSOs = [])
1580
-    {
1581
-        $prepped_answer_options = [];
1582
-        if (is_array($QSOs) && ! empty($QSOs)) {
1583
-            foreach ($QSOs as $key => $QSO) {
1584
-                if (! $QSO instanceof EE_Question_Option) {
1585
-                    $QSO = EE_Question_Option::new_instance(
1586
-                        [
1587
-                            'QSO_value' => is_array($QSO) && isset($QSO['id'])
1588
-                                ? (string) $QSO['id']
1589
-                                : (string) $key,
1590
-                            'QSO_desc'  => is_array($QSO) && isset($QSO['text'])
1591
-                                ? (string) $QSO['text']
1592
-                                : (string) $QSO,
1593
-                        ]
1594
-                    );
1595
-                }
1596
-                if ($QSO->opt_group()) {
1597
-                    $prepped_answer_options[ $QSO->opt_group() ][] = $QSO;
1598
-                } else {
1599
-                    $prepped_answer_options[] = $QSO;
1600
-                }
1601
-            }
1602
-        }
1603
-        //      d( $prepped_answer_options );
1604
-        return $prepped_answer_options;
1605
-    }
1606
-
1607
-
1608
-    /**
1609
-     *  prep_option_value
1610
-     *
1611
-     * @param string $option_value
1612
-     * @return string
1613
-     */
1614
-    public static function prep_option_value($option_value)
1615
-    {
1616
-        return esc_attr(trim(stripslashes($option_value)));
1617
-    }
1618
-
1619
-
1620
-    /**
1621
-     *  prep_required
1622
-     *
1623
-     * @param string|array $required
1624
-     * @return array
1625
-     */
1626
-    public static function prep_required($required = [])
1627
-    {
1628
-        // make sure required is an array
1629
-        $required = is_array($required) ? $required : [];
1630
-        // and set some defaults
1631
-        return array_merge(['label' => '', 'class' => '', 'msg' => ''], $required);
1632
-    }
1633
-
1634
-
1635
-    /**
1636
-     *  get_label_size_class
1637
-     *
1638
-     * @param string $value
1639
-     * @return string
1640
-     */
1641
-    public static function get_label_size_class($value = false)
1642
-    {
1643
-        if ($value === false || $value === '') {
1644
-            return ' class="medium-lbl"';
1645
-        }
1646
-        // determine length of option value
1647
-        $val_size = strlen($value);
1648
-        switch ($val_size) {
1649
-            case $val_size < 3:
1650
-                $size = ' class="nano-lbl"';
1651
-                break;
1652
-            case $val_size < 6:
1653
-                $size = ' class="micro-lbl"';
1654
-                break;
1655
-            case $val_size < 12:
1656
-                $size = ' class="tiny-lbl"';
1657
-                break;
1658
-            case $val_size < 25:
1659
-                $size = ' class="small-lbl"';
1660
-                break;
1661
-            case $val_size > 100:
1662
-                $size = ' class="big-lbl"';
1663
-                break;
1664
-            default:
1665
-                $size = ' class="medium-lbl"';
1666
-                break;
1667
-        }
1668
-        return $size;
1669
-    }
1670
-
1671
-
1672
-    /**
1673
-     *  _load_system_dropdowns
1674
-     *
1675
-     * @param EE_Question_Form_Input $QFI
1676
-     * @return array
1677
-     * @throws EE_Error
1678
-     * @throws ReflectionException
1679
-     */
1680
-    private static function _load_system_dropdowns($QFI)
1681
-    {
1682
-        $QST_system = $QFI->get('QST_system');
1683
-        switch ($QST_system) {
1684
-            case 'state':
1685
-                $QFI = self::generate_state_dropdown($QFI);
1686
-                break;
1687
-            case 'country':
1688
-                $QFI = self::generate_country_dropdown($QFI);
1689
-                break;
1690
-            case 'admin-state':
1691
-                $QFI = self::generate_state_dropdown($QFI, true);
1692
-                break;
1693
-            case 'admin-country':
1694
-                $QFI = self::generate_country_dropdown($QFI, true);
1695
-                break;
1696
-        }
1697
-        return $QFI;
1698
-    }
1699
-
1700
-
1701
-    /**
1702
-     * This preps dropdowns that are specialized.
1703
-     *
1704
-     * @param EE_Question_Form_Input $QFI
1705
-     *
1706
-     * @return EE_Question_Form_Input
1707
-     * @throws EE_Error
1708
-     * @throws ReflectionException
1709
-     * @since  4.6.0
1710
-     */
1711
-    protected static function _load_specialized_dropdowns($QFI)
1712
-    {
1713
-        switch ($QFI->get('QST_type')) {
1714
-            case 'STATE':
1715
-                $QFI = self::generate_state_dropdown($QFI);
1716
-                break;
1717
-            case 'COUNTRY':
1718
-                $QFI = self::generate_country_dropdown($QFI);
1719
-                break;
1720
-        }
1721
-        return $QFI;
1722
-    }
1723
-
1724
-
1725
-    /**
1726
-     *    generate_state_dropdown
1727
-     *
1728
-     * @param EE_Question_Form_Input $QST
1729
-     * @param bool                   $get_all
1730
-     * @return EE_Question_Form_Input
1731
-     * @throws EE_Error
1732
-     * @throws ReflectionException
1733
-     */
1734
-    public static function generate_state_dropdown($QST, $get_all = false)
1735
-    {
1736
-        $states = $get_all
1737
-            ? EEM_State::instance()->get_all_states()
1738
-            : EEM_State::instance()->get_all_states_of_active_countries();
1739
-        if ($states && count($states) != count($QST->options())) {
1740
-            $QST->set('QST_type', 'DROPDOWN');
1741
-            // if multiple countries, we'll create option groups within the dropdown
1742
-            foreach ($states as $state) {
1743
-                if ($state instanceof EE_State) {
1744
-                    $QSO = EE_Question_Option::new_instance(
1745
-                        [
1746
-                            'QSO_value'   => $state->ID(),
1747
-                            'QSO_desc'    => $state->name(),
1748
-                            'QST_ID'      => $QST->get('QST_ID'),
1749
-                            'QSO_deleted' => false,
1750
-                        ]
1751
-                    );
1752
-                    // set option group
1753
-                    $QSO->set_opt_group($state->country()->name());
1754
-                    // add option to question
1755
-                    $QST->add_temp_option($QSO);
1756
-                }
1757
-            }
1758
-        }
1759
-        return $QST;
1760
-    }
1761
-
1762
-
1763
-    /**
1764
-     *    generate_country_dropdown
1765
-     *
1766
-     * @param      $QST
1767
-     * @param bool $get_all
1768
-     * @return array
1769
-     * @throws EE_Error
1770
-     * @throws ReflectionException
1771
-     * @internal param array $question
1772
-     */
1773
-    public static function generate_country_dropdown($QST, $get_all = false)
1774
-    {
1775
-        $countries = $get_all
1776
-            ? EEM_Country::instance()->get_all_countries()
1777
-            : EEM_Country::instance()->get_all_active_countries();
1778
-        if ($countries && count($countries) != count($QST->options())) {
1779
-            $QST->set('QST_type', 'DROPDOWN');
1780
-            // now add countries
1781
-            foreach ($countries as $country) {
1782
-                if ($country instanceof EE_Country) {
1783
-                    $QSO = EE_Question_Option::new_instance(
1784
-                        [
1785
-                            'QSO_value'   => $country->ID(),
1786
-                            'QSO_desc'    => $country->name(),
1787
-                            'QST_ID'      => $QST->get('QST_ID'),
1788
-                            'QSO_deleted' => false,
1789
-                        ]
1790
-                    );
1791
-                    $QST->add_temp_option($QSO);
1792
-                }
1793
-            }
1794
-        }
1795
-        return $QST;
1796
-    }
1797
-
1798
-
1799
-    /**
1800
-     *  generates options for a month dropdown selector with numbers from 01 to 12
1801
-     *
1802
-     * @return array()
1803
-     */
1804
-    public static function two_digit_months_dropdown_options()
1805
-    {
1806
-        $options = [];
1807
-        for ($x = 1; $x <= 12; $x++) {
1808
-            $mm             = str_pad($x, 2, '0', STR_PAD_LEFT);
1809
-            $options[ $mm ] = $mm;
1810
-        }
1811
-        return EEH_Form_Fields::prep_answer_options($options);
1812
-    }
1813
-
1814
-
1815
-    /**
1816
-     *  generates a year dropdown selector with numbers for the next ten years
1817
-     *
1818
-     * @return array
1819
-     */
1820
-    public static function next_decade_two_digit_year_dropdown_options()
1821
-    {
1822
-        $options      = [];
1823
-        $current_year = date('y');
1824
-        $next_decade  = $current_year + 10;
1825
-        for ($x = $current_year; $x <= $next_decade; $x++) {
1826
-            $yy             = str_pad($x, 2, '0', STR_PAD_LEFT);
1827
-            $options[ $yy ] = $yy;
1828
-        }
1829
-        return EEH_Form_Fields::prep_answer_options($options);
1830
-    }
1831
-
1832
-
1833
-    /**
1834
-     * generates a month/year dropdown selector for all registrations matching the given criteria.  Typically used for
1835
-     * list table filter.
1836
-     *
1837
-     * @param string  $cur_date     any currently selected date can be entered here.
1838
-     * @param string  $status       Registration status
1839
-     * @param integer $evt_category Event Category ID if the Event Category filter is selected
1840
-     * @return string                html
1841
-     * @throws EE_Error
1842
-     */
1843
-    public static function generate_registration_months_dropdown($cur_date = '', $status = '', $evt_category = 0)
1844
-    {
1845
-        $_where = [];
1846
-        if (! empty($status)) {
1847
-            $_where['STS_ID'] = $status;
1848
-        }
1849
-
1850
-        if ($evt_category > 0) {
1851
-            $_where['Event.Term_Taxonomy.term_id'] = $evt_category;
1852
-        }
1853
-
1854
-        $regdtts = EEM_Registration::instance()->get_reg_months_and_years($_where);
1855
-
1856
-        // setup vals for select input helper
1857
-        $options = [
1858
-            0 => [
1859
-                'text' => esc_html__('Select a Month/Year', 'event_espresso'),
1860
-                'id'   => '',
1861
-            ],
1862
-        ];
1863
-
1864
-        foreach ($regdtts as $regdtt) {
1865
-            $date      = $regdtt->reg_month . ' ' . $regdtt->reg_year;
1866
-            $options[] = [
1867
-                'text' => $date,
1868
-                'id'   => $date,
1869
-            ];
1870
-        }
1871
-
1872
-        return self::select_input('month_range', $options, $cur_date, '', 'wide');
1873
-    }
1874
-
1875
-
1876
-    /**
1877
-     * generates a month/year dropdown selector for all events matching the given criteria
1878
-     * Typically used for list table filter
1879
-     *
1880
-     * @param string $cur_date          any currently selected date can be entered here.
1881
-     * @param string $status            "view" (i.e. all, today, month, draft)
1882
-     * @param int    $evt_category      category event belongs to
1883
-     * @param string $evt_active_status "upcoming", "expired", "active", or "inactive"
1884
-     * @return string                    html
1885
-     * @throws EE_Error
1886
-     */
1887
-    public static function generate_event_months_dropdown(
1888
-        $cur_date = '',
1889
-        $status = null,
1890
-        $evt_category = null,
1891
-        $evt_active_status = null
1892
-    ) {
1893
-        // determine what post_status our condition will have for the query.
1894
-        // phpcs:disable PSR2.ControlStructures.SwitchDeclaration.TerminatingComment
1895
-        switch ($status) {
1896
-            case 'month':
1897
-            case 'today':
1898
-            case null:
1899
-            case 'all':
1900
-                $where['Event.status'] = ['NOT IN', ['trash']];
1901
-                break;
1902
-            case 'draft':
1903
-                $where['Event.status'] = ['IN', ['draft', 'auto-draft']];
1904
-                break;
1905
-            default:
1906
-                $where['Event.status'] = $status;
1907
-        }
1908
-
1909
-        // phpcs:enable
1910
-
1911
-        // categories?
1912
-
1913
-
1914
-        if (! empty($evt_category)) {
1915
-            $where['Event.Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
1916
-            $where['Event.Term_Taxonomy.term_id']  = $evt_category;
1917
-        }
1918
-
1919
-
1920
-        //      $where['DTT_is_primary'] = 1;
1921
-
1922
-        $DTTS = EEM_Datetime::instance()->get_dtt_months_and_years($where, $evt_active_status);
1923
-
1924
-        // let's setup vals for select input helper
1925
-        $options = [
1926
-            0 => [
1927
-                'text' => esc_html__('Select a Month/Year', 'event_espresso'),
1928
-                'id'   => "",
1929
-            ],
1930
-        ];
1931
-
1932
-
1933
-        // translate month and date
1934
-        global $wp_locale;
1935
-
1936
-        foreach ($DTTS as $DTT) {
1937
-            $localized_date = $wp_locale->get_month($DTT->dtt_month_num) . ' ' . $DTT->dtt_year;
1938
-            $id             = $DTT->dtt_month . ' ' . $DTT->dtt_year;
1939
-            $options[]      = [
1940
-                'text' => $localized_date,
1941
-                'id'   => $id,
1942
-            ];
1943
-        }
1944
-
1945
-
1946
-        return self::select_input('month_range', $options, $cur_date, '', 'wide');
1947
-    }
1948
-
1949
-
1950
-    /**
1951
-     * generates the dropdown selector for event categories
1952
-     * typically used as a filter on list tables.
1953
-     *
1954
-     * @param integer $current_cat currently selected category
1955
-     * @return string               html for dropdown
1956
-     * @throws EE_Error
1957
-     * @throws ReflectionException
1958
-     */
1959
-    public static function generate_event_category_dropdown($current_cat = -1)
1960
-    {
1961
-        $categories = EEM_Term::instance()->get_all_ee_categories(true);
1962
-        $options    = [
1963
-            '0' => [
1964
-                'text' => esc_html__('All Categories', 'event_espresso'),
1965
-                'id'   => -1,
1966
-            ],
1967
-        ];
1968
-
1969
-        // setup categories for dropdown
1970
-        foreach ($categories as $category) {
1971
-            $options[] = [
1972
-                'text' => $category->get('name'),
1973
-                'id'   => $category->ID(),
1974
-            ];
1975
-        }
1976
-
1977
-        return self::select_input('EVT_CAT', $options, $current_cat);
1978
-    }
1979
-
1980
-
1981
-    /**
1982
-     *    generate a submit button with or without it's own microform
1983
-     *    this is the only way to create buttons that are compatible across all themes
1984
-     *
1985
-     * @access    public
1986
-     * @param string      $url              - the form action
1987
-     * @param string      $ID               - some kind of unique ID, appended with "-sbmt" for the input and "-frm"
1988
-     *                                      for the form
1989
-     * @param string      $class            - css classes (separated by spaces if more than one)
1990
-     * @param string      $text             - what appears on the button
1991
-     * @param string      $nonce_action     - if using nonces
1992
-     * @param bool|string $input_only       - whether to print form header and footer. TRUE returns the input without
1993
-     *                                      the form
1994
-     * @param string      $extra_attributes - any extra attributes that need to be attached to the form input
1995
-     * @return    string
1996
-     */
1997
-    public static function submit_button(
1998
-        $url = '',
1999
-        $ID = '',
2000
-        $class = '',
2001
-        $text = '',
2002
-        $nonce_action = '',
2003
-        $input_only = false,
2004
-        $extra_attributes = ''
2005
-    ) {
2006
-        $btn = '';
2007
-        if (empty($url) || empty($ID)) {
2008
-            return $btn;
2009
-        }
2010
-        $text = ! empty($text) ? $text : esc_html__('Submit', 'event_espresso');
2011
-        $btn  .= '<input id="' . $ID . '-btn" class="' . $class . '" '
2012
-                 . 'type="submit" value="' . $text . '" ' . $extra_attributes . '/>';
2013
-        if (! $input_only) {
2014
-            $btn_frm = '<form id="' . $ID . '-frm" method="POST" action="' . $url . '">';
2015
-            $btn_frm .= ! empty($nonce_action)
2016
-                ? wp_nonce_field($nonce_action, $nonce_action . '_nonce', true, false)
2017
-                : '';
2018
-            $btn_frm .= $btn;
2019
-            $btn_frm .= '</form>';
2020
-            $btn     = $btn_frm;
2021
-            unset($btn_frm);
2022
-        }
2023
-        return $btn;
2024
-    }
488
+	}
489
+
490
+
491
+	/**
492
+	 * @param string $class
493
+	 * @param string $id
494
+	 * @param string $name
495
+	 * @param int    $rows
496
+	 * @param int    $tab_index
497
+	 * @param string $value
498
+	 * @param array  $wp_editor_args
499
+	 * @return false|string
500
+	 * @since   4.10.14.p
501
+	 */
502
+	private static function adminWpEditor($class, $id, $name, $rows, $tab_index, $value, $wp_editor_args = [])
503
+	{
504
+		$editor_settings = $wp_editor_args + [
505
+				'textarea_name' => esc_attr($name),
506
+				'textarea_rows' => absint($rows),
507
+				'editor_class'  => esc_attr($class),
508
+				'tabindex'      => absint($tab_index),
509
+			];
510
+		ob_start();
511
+		wp_editor($value, esc_attr($id), $editor_settings);
512
+		return ob_get_clean();
513
+	}
514
+
515
+
516
+	/**
517
+	 * espresso admin page select_input
518
+	 * Turns an array into a select fields
519
+	 *
520
+	 * @static
521
+	 * @access public
522
+	 * @param string  $name       field name
523
+	 * @param array   $values     option values, numbered array starting at 0, where each value is an array with a key
524
+	 *                            'text' (meaning text to display' and 'id' (meaning the internal value) eg:
525
+	 *                            array(1=>array('text'=>'Monday','id'=>1),2=>array('text'=>'Tuesday','id'=>2)...). or
526
+	 *                            as an array of key-value pairs, where the key is to be used for the select input's
527
+	 *                            name, and the value will be the text shown to the user.  Optionally you can also
528
+	 *                            include an additional key of "class" which will add a specific class to the option
529
+	 *                            for that value.
530
+	 * @param string  $default    default value
531
+	 * @param string  $parameters extra parameters
532
+	 * @param string  $class      css class
533
+	 * @param boolean $autosize   whether to autosize the select or not
534
+	 * @return string              html string for the select input
535
+	 */
536
+	public static function select_input($name, $values, $default = '', $parameters = '', $class = '', $autosize = true)
537
+	{
538
+		// if $values was submitted in the wrong format, convert it over
539
+		if (! empty($values) && (! array_key_exists(0, $values) || ! is_array($values[0]))) {
540
+			$converted_values = [];
541
+			foreach ($values as $id => $text) {
542
+				$converted_values[] = ['id' => $id, 'text' => $text];
543
+			}
544
+			$values = $converted_values;
545
+		}
546
+
547
+		$field =
548
+			'<select id="' . EEH_Formatter::ee_tep_output_string($name)
549
+			. '" name="' . EEH_Formatter::ee_tep_output_string($name)
550
+			. '"';
551
+
552
+		if (EEH_Formatter::ee_tep_not_null($parameters)) {
553
+			$field .= ' ' . $parameters;
554
+		}
555
+		if ($autosize) {
556
+			$size = 'med';
557
+			for ($ii = 0, $ni = sizeof($values); $ii < $ni; $ii++) {
558
+				if ($values[ $ii ]['text']) {
559
+					if (strlen($values[ $ii ]['text']) > 5) {
560
+						$size = 'wide';
561
+					}
562
+				}
563
+			}
564
+		} else {
565
+			$size = '';
566
+		}
567
+
568
+		$field .= ' class="' . $class . ' ' . $size . '">';
569
+
570
+		if (empty($default) && isset($GLOBALS[ $name ])) {
571
+			$default = stripslashes($GLOBALS[ $name ]);
572
+		}
573
+
574
+
575
+		for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
576
+			$field .= '<option value="' . $values[ $i ]['id'] . '"';
577
+			if ($default == $values[ $i ]['id']) {
578
+				$field .= ' selected = "selected"';
579
+			}
580
+			if (isset($values[ $i ]['class'])) {
581
+				$field .= ' class="' . $values[ $i ]['class'] . '"';
582
+			}
583
+			$field .= '>' . $values[ $i ]['text'] . '</option>';
584
+		}
585
+		$field .= '</select>';
586
+
587
+		return $field;
588
+	}
589
+
590
+
591
+	/**
592
+	 * generate_question_groups_html
593
+	 *
594
+	 * @param array  $question_groups
595
+	 * @param string $group_wrapper
596
+	 * @return string HTML
597
+	 * @throws EE_Error
598
+	 * @throws ReflectionException
599
+	 */
600
+	public static function generate_question_groups_html($question_groups = [], $group_wrapper = 'fieldset')
601
+	{
602
+
603
+		$html                            = '';
604
+		$before_question_group_questions =
605
+			apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '');
606
+		$after_question_group_questions  =
607
+			apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '');
608
+
609
+		if (! empty($question_groups)) {
610
+			// loop thru question groups
611
+			foreach ($question_groups as $QSG) {
612
+				// check that questions exist
613
+				if (! empty($QSG['QSG_questions'])) {
614
+					// use fieldsets
615
+					$html .= "\n\t"
616
+							 . '<'
617
+							 . $group_wrapper
618
+							 . ' class="espresso-question-group-wrap" id="'
619
+							 . $QSG['QSG_identifier']
620
+							 . '">';
621
+					// group_name
622
+					$html .= $QSG['QSG_show_group_name']
623
+						? "\n\t\t"
624
+						  . '<h5 class="espresso-question-group-title-h5 section-title">'
625
+						  . self::prep_answer($QSG['QSG_name'])
626
+						  . '</h5>'
627
+						: '';
628
+					// group_desc
629
+					$html .= $QSG['QSG_show_group_desc'] && ! empty($QSG['QSG_desc'])
630
+						? '<div class="espresso-question-group-desc-pg">'
631
+						  . self::prep_answer($QSG['QSG_desc'])
632
+						  . '</div>'
633
+						: '';
634
+
635
+					$html .= $before_question_group_questions;
636
+					// loop thru questions
637
+					foreach ($QSG['QSG_questions'] as $question) {
638
+						$QFI  = new EE_Question_Form_Input(
639
+							$question['qst_obj'],
640
+							$question['ans_obj'],
641
+							$question
642
+						);
643
+						$html .= self::generate_form_input($QFI);
644
+					}
645
+					$html .= $after_question_group_questions;
646
+					$html .= "\n\t" . '</' . $group_wrapper . '>';
647
+				}
648
+			}
649
+		}
650
+
651
+		return $html;
652
+	}
653
+
654
+
655
+	/**
656
+	 * generate_question_groups_html
657
+	 *
658
+	 * @param array  $question_groups
659
+	 * @param array  $q_meta
660
+	 * @param bool   $from_admin
661
+	 * @param string $group_wrapper
662
+	 * @return string HTML
663
+	 * @throws EE_Error
664
+	 * @throws ReflectionException
665
+	 */
666
+	public static function generate_question_groups_html2(
667
+		$question_groups = [],
668
+		$q_meta = [],
669
+		$from_admin = false,
670
+		$group_wrapper = 'fieldset'
671
+	) {
672
+
673
+		$html                            = '';
674
+		$before_question_group_questions =
675
+			apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '');
676
+		$after_question_group_questions  =
677
+			apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '');
678
+
679
+		$default_q_meta = [
680
+			'att_nmbr'    => 1,
681
+			'ticket_id'   => '',
682
+			'input_name'  => '',
683
+			'input_id'    => '',
684
+			'input_class' => '',
685
+		];
686
+		$q_meta         = array_merge($default_q_meta, $q_meta);
687
+
688
+		if (! empty($question_groups)) {
689
+			// loop thru question groups
690
+			foreach ($question_groups as $QSG) {
691
+				if ($QSG instanceof EE_Question_Group) {
692
+					// check that questions exist
693
+
694
+					$where = ['QST_deleted' => 0];
695
+					if (! $from_admin) {
696
+						$where['QST_admin_only'] = 0;
697
+					}
698
+					$questions =
699
+						$QSG->questions([$where, 'order_by' => ['Question_Group_Question.QGQ_order' => 'ASC']]);
700
+					if (! empty($questions)) {
701
+						// use fieldsets
702
+						$html .= "\n\t"
703
+								 . '<' . $group_wrapper . ' class="espresso-question-group-wrap" '
704
+								 . 'id="' . $QSG->get('QSG_identifier') . '">';
705
+						// group_name
706
+						if ($QSG->show_group_name()) {
707
+							$html .= "\n\t\t"
708
+									 . '<h5 class="espresso-question-group-title-h5 section-title">'
709
+									 . $QSG->get_pretty('QSG_name')
710
+									 . '</h5>';
711
+						}
712
+						// group_desc
713
+						if ($QSG->show_group_desc()) {
714
+							$html .= '<div class="espresso-question-group-desc-pg">'
715
+									 . $QSG->get_pretty('QSG_desc')
716
+									 . '</div>';
717
+						}
718
+
719
+						$html .= $before_question_group_questions;
720
+						// loop thru questions
721
+						foreach ($questions as $QST) {
722
+							$qstn_id = $QST->is_system_question() ? $QST->system_ID() : $QST->ID();
723
+
724
+							$answer = null;
725
+
726
+							/** @var RequestInterface $request */
727
+							$request      = LoaderFactory::getLoader()->getShared(RequestInterface::class);
728
+							$request_qstn = $request->getRequestParam('qstn', [], 'string', true);
729
+							if (! empty($request_qstn) && isset($q_meta['input_id']) && isset($q_meta['att_nmbr'])) {
730
+								// check for answer in $request_qstn in case we are reprocessing a form after an error
731
+								if (isset($request_qstn[ $q_meta['input_id'] ][ $qstn_id ])) {
732
+									$answer = is_array($request_qstn[ $q_meta['input_id'] ][ $qstn_id ])
733
+										? $request_qstn[ $q_meta['input_id'] ][ $qstn_id ]
734
+										: sanitize_text_field($request_qstn[ $q_meta['input_id'] ][ $qstn_id ]);
735
+								}
736
+							} elseif (isset($q_meta['attendee']) && $q_meta['attendee']) {
737
+								// attendee data from the session
738
+								$answer =
739
+									isset($q_meta['attendee'][ $qstn_id ]) ? $q_meta['attendee'][ $qstn_id ] : null;
740
+							}
741
+
742
+
743
+							$QFI  = new EE_Question_Form_Input(
744
+								$QST,
745
+								EE_Answer::new_instance(
746
+									[
747
+										'ANS_ID'    => 0,
748
+										'QST_ID'    => 0,
749
+										'REG_ID'    => 0,
750
+										'ANS_value' => $answer,
751
+									]
752
+								),
753
+								$q_meta
754
+							);
755
+							$html .= self::generate_form_input($QFI);
756
+						}
757
+						$html .= $after_question_group_questions;
758
+						$html .= "\n\t" . '</' . $group_wrapper . '>';
759
+					}
760
+				}
761
+			}
762
+		}
763
+		return $html;
764
+	}
765
+
766
+
767
+	/**
768
+	 * generate_form_input
769
+	 *
770
+	 * @param EE_Question_Form_Input $QFI
771
+	 * @return string HTML
772
+	 * @throws EE_Error
773
+	 * @throws ReflectionException
774
+	 */
775
+	public static function generate_form_input(EE_Question_Form_Input $QFI)
776
+	{
777
+		if (isset($QFI->QST_admin_only) && $QFI->QST_admin_only && ! is_admin()) {
778
+			return '';
779
+		}
780
+		/** @var RequestInterface $request */
781
+		$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
782
+
783
+		$QFI = self::_load_system_dropdowns($QFI);
784
+		$QFI = self::_load_specialized_dropdowns($QFI);
785
+
786
+		// we also need to verify
787
+
788
+		$display_text = $QFI->get('QST_display_text');
789
+		$input_name   = $QFI->get('QST_input_name');
790
+		$answer       = $request->getRequestParam($input_name, $QFI->get('ANS_value'));
791
+		$input_id     = $QFI->get('QST_input_id');
792
+		$input_class  = $QFI->get('QST_input_class');
793
+		//      $disabled = $QFI->get('QST_disabled') ? ' disabled="disabled"' : '';
794
+		$disabled          = $QFI->get('QST_disabled');
795
+		$required_label    = apply_filters(' FHEE__EEH_Form_Fields__generate_form_input__required_label', '<em>*</em>');
796
+		$QST_required      = $QFI->get('QST_required');
797
+		$required          =
798
+			$QST_required
799
+				? ['label' => $required_label, 'class' => 'required needs-value', 'title' => $QST_required]
800
+				: [];
801
+		$use_html_entities = $QFI->get_meta('htmlentities');
802
+		$required_text     =
803
+			$QFI->get('QST_required_text') != ''
804
+				? $QFI->get('QST_required_text')
805
+				: esc_html__('This field is required', 'event_espresso');
806
+		$required_text     = $QST_required
807
+			? "\n\t\t\t"
808
+			  . '<div class="required-text hidden">'
809
+			  . self::prep_answer($required_text, $use_html_entities)
810
+			  . '</div>'
811
+			: '';
812
+		$label_class       = 'espresso-form-input-lbl';
813
+		$QST_options       = $QFI->options(true, $answer);
814
+		$options           = is_array($QST_options) ? self::prep_answer_options($QST_options) : [];
815
+		$system_ID         = $QFI->get('QST_system');
816
+		$label_b4          = $QFI->get_meta('label_b4');
817
+		$use_desc_4_label  = $QFI->get_meta('use_desc_4_label');
818
+
819
+
820
+		switch ($QFI->get('QST_type')) {
821
+			case 'TEXTAREA':
822
+				return EEH_Form_Fields::textarea(
823
+					$display_text,
824
+					$answer,
825
+					$input_name,
826
+					$input_id,
827
+					$input_class,
828
+					[],
829
+					$required,
830
+					$required_text,
831
+					$label_class,
832
+					$disabled,
833
+					$system_ID,
834
+					$use_html_entities
835
+				);
836
+
837
+			case 'DROPDOWN':
838
+				return EEH_Form_Fields::select(
839
+					$display_text,
840
+					$answer,
841
+					$options,
842
+					$input_name,
843
+					$input_id,
844
+					$input_class,
845
+					$required,
846
+					$required_text,
847
+					$label_class,
848
+					$disabled,
849
+					$system_ID,
850
+					$use_html_entities,
851
+					true
852
+				);
853
+
854
+
855
+			case 'RADIO_BTN':
856
+				return EEH_Form_Fields::radio(
857
+					$display_text,
858
+					$answer,
859
+					$options,
860
+					$input_name,
861
+					$input_id,
862
+					$input_class,
863
+					$required,
864
+					$required_text,
865
+					$label_class,
866
+					$disabled,
867
+					$system_ID,
868
+					$use_html_entities,
869
+					$label_b4,
870
+					$use_desc_4_label
871
+				);
872
+
873
+			case 'CHECKBOX':
874
+				return EEH_Form_Fields::checkbox(
875
+					$display_text,
876
+					$answer,
877
+					$options,
878
+					$input_name,
879
+					$input_id,
880
+					$input_class,
881
+					$required,
882
+					$required_text,
883
+					$label_class,
884
+					$disabled,
885
+					$label_b4,
886
+					$system_ID,
887
+					$use_html_entities
888
+				);
889
+
890
+			case 'DATE':
891
+				return EEH_Form_Fields::datepicker(
892
+					$display_text,
893
+					$answer,
894
+					$input_name,
895
+					$input_id,
896
+					$input_class,
897
+					$required,
898
+					$required_text,
899
+					$label_class,
900
+					$disabled,
901
+					$system_ID,
902
+					$use_html_entities
903
+				);
904
+
905
+			case 'TEXT':
906
+			default:
907
+				return EEH_Form_Fields::text(
908
+					$display_text,
909
+					$answer,
910
+					$input_name,
911
+					$input_id,
912
+					$input_class,
913
+					$required,
914
+					$required_text,
915
+					$label_class,
916
+					$disabled,
917
+					$system_ID,
918
+					$use_html_entities
919
+				);
920
+		}
921
+	}
922
+
923
+
924
+	/**
925
+	 * generates HTML for a form text input
926
+	 *
927
+	 * @param string $question    label content
928
+	 * @param string $answer      form input value attribute
929
+	 * @param string $name        form input name attribute
930
+	 * @param string $id          form input css id attribute
931
+	 * @param string $class       form input css class attribute
932
+	 * @param array  $required    'label', 'class', and 'msg' - array of values for required "label" content, css
933
+	 *                            required 'class', and required 'msg' attribute
934
+	 * @param string $label_class css class attribute for the label
935
+	 * @param string $disabled    disabled="disabled" or null
936
+	 * @return string HTML
937
+	 */
938
+	public static function text(
939
+		$question = false,
940
+		$answer = null,
941
+		$name = false,
942
+		$id = '',
943
+		$class = '',
944
+		$required = false,
945
+		$required_text = '',
946
+		$label_class = '',
947
+		$disabled = false,
948
+		$system_ID = false,
949
+		$use_html_entities = true
950
+	) {
951
+		// need these
952
+		if (! $question || ! $name) {
953
+			return null;
954
+		}
955
+		// prep the answer
956
+		$answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities);
957
+		// prep the required array
958
+		$required = self::prep_required($required);
959
+		// set disabled tag
960
+		$disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
961
+		// ya gots ta have style man!!!
962
+		$txt_class = is_admin() ? 'regular-text' : 'espresso-text-inp';
963
+		$class     = empty($class) ? $txt_class : $class;
964
+		$class     .= ! empty($system_ID) ? ' ' . $system_ID : '';
965
+		$extra     = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
966
+
967
+		$label_html =
968
+			$required_text
969
+			. "\n\t\t\t"
970
+			. '<label for="' . $name . '" class="' . $label_class . '">'
971
+			. self::prep_question($question)
972
+			. $required['label']
973
+			. '</label><br/>';
974
+		// filter label but ensure required text comes before it
975
+		$label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
976
+
977
+		$input_html =
978
+			"\n\t\t\t"
979
+			. '<input type="text" name="' . $name . '" id="' . $id . '" '
980
+			. 'class="' . $class . ' ' . $required['class'] . '" value="' . esc_attr($answer) . '"  '
981
+			. 'title="' . esc_attr($required['msg']) . '" ' . $disabled . ' ' . $extra . '/>';
982
+
983
+		$input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
984
+		return $label_html . $input_html;
985
+	}
986
+
987
+
988
+	/**
989
+	 * generates HTML for a form textarea
990
+	 *
991
+	 * @param string $question    label content
992
+	 * @param string $answer      form input value attribute
993
+	 * @param string $name        form input name attribute
994
+	 * @param string $id          form input css id attribute
995
+	 * @param string $class       form input css class attribute
996
+	 * @param array  $dimensions  array of form input rows and cols attributes : array( 'rows' => 3, 'cols' => 40 )
997
+	 * @param array  $required    'label', 'class', and 'msg' - array of values for required "label" content, css
998
+	 *                            required 'class', and required 'msg' attribute
999
+	 * @param string $label_class css class attribute for the label
1000
+	 * @param string $disabled    disabled="disabled" or null
1001
+	 * @return string HTML
1002
+	 */
1003
+	public static function textarea(
1004
+		$question = false,
1005
+		$answer = null,
1006
+		$name = false,
1007
+		$id = '',
1008
+		$class = '',
1009
+		$dimensions = false,
1010
+		$required = false,
1011
+		$required_text = '',
1012
+		$label_class = '',
1013
+		$disabled = false,
1014
+		$system_ID = false,
1015
+		$use_html_entities = true
1016
+	) {
1017
+		// need these
1018
+		if (! $question || ! $name) {
1019
+			return null;
1020
+		}
1021
+		// prep the answer
1022
+		$answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities);
1023
+		// prep the required array
1024
+		$required = self::prep_required($required);
1025
+		// make sure $dimensions is an array
1026
+		$dimensions = is_array($dimensions) ? $dimensions : [];
1027
+		// and set some defaults
1028
+		$dimensions = array_merge(['rows' => 3, 'cols' => 40], $dimensions);
1029
+		// set disabled tag
1030
+		$disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
1031
+		// ya gots ta have style man!!!
1032
+		$txt_class = is_admin() ? 'regular-text' : 'espresso-textarea-inp';
1033
+		$class     = empty($class) ? $txt_class : $class;
1034
+		$class     .= ! empty($system_ID) ? ' ' . $system_ID : '';
1035
+		$extra     = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1036
+
1037
+		$label_html =
1038
+			$required_text
1039
+			. "\n\t\t\t"
1040
+			. '<label for="' . $name . '" class="' . $label_class . '">'
1041
+			. self::prep_question($question)
1042
+			. $required['label']
1043
+			. '</label><br/>';
1044
+		// filter label but ensure required text comes before it
1045
+		$label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
1046
+
1047
+		$input_html =
1048
+			"\n\t\t\t"
1049
+			. '<textarea name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" '
1050
+			. 'rows="' . $dimensions['rows'] . '" cols="' . $dimensions['cols'] . '"  '
1051
+			. 'title="' . $required['msg'] . '" ' . $disabled . ' ' . $extra . '>'
1052
+			. esc_textarea($answer)
1053
+			. '</textarea>';
1054
+
1055
+		$input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1056
+		return $label_html . $input_html;
1057
+	}
1058
+
1059
+
1060
+	/**
1061
+	 * generates HTML for a form select input
1062
+	 *
1063
+	 * @param string $question    label content
1064
+	 * @param string $answer      form input value attribute
1065
+	 * @param array  $options     array of answer options where array key = option value and array value = option
1066
+	 *                            display text
1067
+	 * @param string $name        form input name attribute
1068
+	 * @param string $id          form input css id attribute
1069
+	 * @param string $class       form input css class attribute
1070
+	 * @param array  $required    'label', 'class', and 'msg' - array of values for required "label" content, css
1071
+	 *                            required 'class', and required 'msg' attribute
1072
+	 * @param string $label_class css class attribute for the label
1073
+	 * @param string $disabled    disabled="disabled" or null
1074
+	 * @return string HTML
1075
+	 */
1076
+	public static function select(
1077
+		$question = false,
1078
+		$answer = null,
1079
+		$options = false,
1080
+		$name = false,
1081
+		$id = '',
1082
+		$class = '',
1083
+		$required = false,
1084
+		$required_text = '',
1085
+		$label_class = '',
1086
+		$disabled = false,
1087
+		$system_ID = false,
1088
+		$use_html_entities = true,
1089
+		$add_please_select_option = false
1090
+	) {
1091
+
1092
+		// need these
1093
+		if (! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
1094
+			return null;
1095
+		}
1096
+		// prep the answer
1097
+		$answer =
1098
+			is_array($answer)
1099
+				? self::prep_answer(array_shift($answer), $use_html_entities)
1100
+				: self::prep_answer(
1101
+					$answer,
1102
+					$use_html_entities
1103
+				);
1104
+		// prep the required array
1105
+		$required = self::prep_required($required);
1106
+		// set disabled tag
1107
+		$disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
1108
+		// ya gots ta have style man!!!
1109
+		$txt_class = is_admin() ? 'wide' : 'espresso-select-inp';
1110
+		$class     = empty($class) ? $txt_class : $class;
1111
+		$class     .= ! empty($system_ID) ? ' ' . $system_ID : '';
1112
+		$extra     = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1113
+
1114
+		$label_html =
1115
+			$required_text
1116
+			. "\n\t\t\t"
1117
+			. '<label for="' . $name . '" class="' . $label_class . '">'
1118
+			. self::prep_question($question)
1119
+			. $required['label']
1120
+			. '</label><br/>';
1121
+		// filter label but ensure required text comes before it
1122
+		$label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
1123
+
1124
+		$input_html =
1125
+			"\n\t\t\t"
1126
+			. '<select name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" '
1127
+			. 'title="' . esc_attr($required['msg']) . '"' . $disabled . ' ' . $extra . '>';
1128
+		// recursively count array elements, to determine total number of options
1129
+		$only_option = count($options, 1) == 1;
1130
+		if (! $only_option) {
1131
+			// if there is NO answer set and there are multiple options to choose from, then set the "please select" message as selected
1132
+			$selected   = $answer === null ? ' selected="selected"' : '';
1133
+			$input_html .= $add_please_select_option
1134
+				? "\n\t\t\t\t"
1135
+				  . '<option value=""' . $selected . '>'
1136
+				  . esc_html__(' - please select - ', 'event_espresso')
1137
+				  . '</option>'
1138
+				: '';
1139
+		}
1140
+		foreach ($options as $key => $value) {
1141
+			// if value is an array, then create option groups, else create regular ol' options
1142
+			$input_html .= is_array($value)
1143
+				? self::_generate_select_option_group(
1144
+					$key,
1145
+					$value,
1146
+					$answer,
1147
+					$use_html_entities
1148
+				)
1149
+				: self::_generate_select_option(
1150
+					$value->value(),
1151
+					$value->desc(),
1152
+					$answer,
1153
+					$only_option,
1154
+					$use_html_entities
1155
+				);
1156
+		}
1157
+
1158
+		$input_html .= "\n\t\t\t" . '</select>';
1159
+
1160
+		$input_html =
1161
+			apply_filters(
1162
+				'FHEE__EEH_Form_Fields__select__before_end_wrapper',
1163
+				$input_html,
1164
+				$question,
1165
+				$answer,
1166
+				$name,
1167
+				$id,
1168
+				$class,
1169
+				$system_ID
1170
+			);
1171
+
1172
+		$input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1173
+		return $label_html . $input_html;
1174
+	}
1175
+
1176
+
1177
+	/**
1178
+	 *  _generate_select_option_group
1179
+	 *
1180
+	 *  if  $value for a select box is an array, then the key will be used as the optgroup label
1181
+	 *  and the value array will be looped thru and the elements sent to _generate_select_option
1182
+	 *
1183
+	 * @param mixed   $opt_group
1184
+	 * @param mixed   $QSOs
1185
+	 * @param mixed   $answer
1186
+	 * @param boolean $use_html_entities
1187
+	 * @return string
1188
+	 */
1189
+	private static function _generate_select_option_group($opt_group, $QSOs, $answer, $use_html_entities = true)
1190
+	{
1191
+		$html = "\n\t\t\t\t" . '<optgroup label="' . self::prep_option_value($opt_group) . '">';
1192
+		foreach ($QSOs as $QSO) {
1193
+			$html .= self::_generate_select_option($QSO->value(), $QSO->desc(), $answer, false, $use_html_entities);
1194
+		}
1195
+		$html .= "\n\t\t\t\t" . '</optgroup>';
1196
+		return $html;
1197
+	}
1198
+
1199
+
1200
+	/**
1201
+	 *  _generate_select_option
1202
+	 *
1203
+	 * @param mixed   $key
1204
+	 * @param mixed   $value
1205
+	 * @param mixed   $answer
1206
+	 * @param int     $only_option
1207
+	 * @param boolean $use_html_entities
1208
+	 * @return string
1209
+	 */
1210
+	private static function _generate_select_option(
1211
+		$key,
1212
+		$value,
1213
+		$answer,
1214
+		$only_option = false,
1215
+		$use_html_entities = true
1216
+	) {
1217
+		$key      = self::prep_answer($key, $use_html_entities);
1218
+		$value    = self::prep_answer($value, $use_html_entities);
1219
+		$value    = ! empty($value) ? $value : $key;
1220
+		$selected = ($answer == $key || $only_option) ? 'selected="selected"' : '';
1221
+		return "\n\t\t\t\t"
1222
+			   . '<option value="' . self::prep_option_value($key) . '" ' . $selected . '> '
1223
+			   . $value
1224
+			   . '&nbsp;&nbsp;&nbsp;</option>';
1225
+	}
1226
+
1227
+
1228
+	/**
1229
+	 * generates HTML for form radio button inputs
1230
+	 *
1231
+	 * @param bool|string $question    label content
1232
+	 * @param string      $answer      form input value attribute
1233
+	 * @param array|bool  $options     array of answer options where array key = option value and array value = option
1234
+	 *                                 display text
1235
+	 * @param bool|string $name        form input name attribute
1236
+	 * @param string      $id          form input css id attribute
1237
+	 * @param string      $class       form input css class attribute
1238
+	 * @param array|bool  $required    'label', 'class', and 'msg' - array of values for required "label" content, css
1239
+	 *                                 required 'class', and required 'msg' attribute
1240
+	 * @param string      $required_text
1241
+	 * @param string      $label_class css class attribute for the label
1242
+	 * @param bool|string $disabled    disabled="disabled" or null
1243
+	 * @param bool        $system_ID
1244
+	 * @param bool        $use_html_entities
1245
+	 * @param bool        $label_b4
1246
+	 * @param bool        $use_desc_4_label
1247
+	 * @return string HTML
1248
+	 */
1249
+	public static function radio(
1250
+		$question = false,
1251
+		$answer = null,
1252
+		$options = false,
1253
+		$name = false,
1254
+		$id = '',
1255
+		$class = '',
1256
+		$required = false,
1257
+		$required_text = '',
1258
+		$label_class = '',
1259
+		$disabled = false,
1260
+		$system_ID = false,
1261
+		$use_html_entities = true,
1262
+		$label_b4 = false,
1263
+		$use_desc_4_label = false
1264
+	) {
1265
+		// need these
1266
+		if (! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
1267
+			return null;
1268
+		}
1269
+		// prep the answer
1270
+		$answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities);
1271
+		// prep the required array
1272
+		$required = self::prep_required($required);
1273
+		// set disabled tag
1274
+		$disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
1275
+		// ya gots ta have style man!!!
1276
+		$radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class;
1277
+		$class       = ! empty($class) ? $class : 'espresso-radio-btn-inp';
1278
+		$extra       = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1279
+
1280
+		$label_html =
1281
+			$required_text
1282
+			. "\n\t\t\t"
1283
+			. '<label class="' . $label_class . '">'
1284
+			. self::prep_question($question)
1285
+			. $required['label']
1286
+			. '</label> ';
1287
+		// filter label but ensure required text comes before it
1288
+		$label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
1289
+
1290
+		$input_html =
1291
+			"\n\t\t\t"
1292
+			. '<ul id="' . $id . '-ul" class="espresso-radio-btn-options-ul ' . $label_class . ' ' . $class . '-ul">';
1293
+
1294
+		$class .= ! empty($system_ID) ? ' ' . $system_ID : '';
1295
+		$class .= ! empty($required['class']) ? ' ' . $required['class'] : '';
1296
+
1297
+		foreach ($options as $OPT) {
1298
+			if ($OPT instanceof EE_Question_Option) {
1299
+				$value   = self::prep_option_value($OPT->value());
1300
+				$label   = $use_desc_4_label ? $OPT->desc() : $OPT->value();
1301
+				$size    = $use_desc_4_label
1302
+					? self::get_label_size_class($OPT->value() . ' ' . $OPT->desc())
1303
+					: self::get_label_size_class($OPT->value());
1304
+				$desc    = $OPT->desc();// no self::prep_answer
1305
+				$answer  = is_numeric($value) && empty($answer) ? 0 : $answer;
1306
+				$checked = (string) $value == (string) $answer ? ' checked="checked"' : '';
1307
+				$opt     = '-' . sanitize_key($value);
1308
+
1309
+				$input_html .= "\n\t\t\t\t" . '<li' . $size . '>';
1310
+				$input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-radio-btn-lbl">';
1311
+				$input_html .= $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $label . '</span>' : '';
1312
+				$input_html .= "\n\t\t\t\t\t\t"
1313
+							   . '<input type="radio" name="' . $name . '" id="' . $id . $opt . '" '
1314
+							   . 'class="' . $class . '" value="' . $value . '" '
1315
+							   . 'title="' . esc_attr($required['msg']) . '" ' . $disabled
1316
+							   . $checked . ' ' . $extra . '/>';
1317
+				$input_html .= ! $label_b4
1318
+					? "\n\t\t\t\t\t\t"
1319
+					  . '<span class="espresso-radio-btn-desc">'
1320
+					  . $label
1321
+					  . '</span>'
1322
+					: '';
1323
+				$input_html .= "\n\t\t\t\t\t" . '</label>';
1324
+				$input_html .= $use_desc_4_label
1325
+					? ''
1326
+					: '<span class="espresso-radio-btn-option-desc small-text grey-text">' . $desc . '</span>';
1327
+				$input_html .= "\n\t\t\t\t" . '</li>';
1328
+			}
1329
+		}
1330
+
1331
+		$input_html .= "\n\t\t\t" . '</ul>';
1332
+
1333
+		$input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1334
+		return $label_html . $input_html;
1335
+	}
1336
+
1337
+
1338
+	/**
1339
+	 * generates HTML for form checkbox inputs
1340
+	 *
1341
+	 * @param string $question    label content
1342
+	 * @param string $answer      form input value attribute
1343
+	 * @param array  $options     array of options where array key = option value and array value = option display text
1344
+	 * @param string $name        form input name attribute
1345
+	 * @param string $id          form input css id attribute
1346
+	 * @param string $class       form input css class attribute
1347
+	 * @param array  $required    'label', 'class', and 'msg' - array of values for required "label" content, css
1348
+	 *                            required 'class', and required 'msg' attribute
1349
+	 * @param string $label_class css class attribute for the label
1350
+	 * @param string $disabled    disabled="disabled" or null
1351
+	 * @return string HTML
1352
+	 */
1353
+	public static function checkbox(
1354
+		$question = false,
1355
+		$answer = null,
1356
+		$options = false,
1357
+		$name = false,
1358
+		$id = '',
1359
+		$class = '',
1360
+		$required = false,
1361
+		$required_text = '',
1362
+		$label_class = '',
1363
+		$disabled = false,
1364
+		$label_b4 = false,
1365
+		$system_ID = false,
1366
+		$use_html_entities = true
1367
+	) {
1368
+		// need these
1369
+		if (! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
1370
+			return null;
1371
+		}
1372
+		$answer = maybe_unserialize($answer);
1373
+
1374
+		// prep the answer(s)
1375
+		$answer = is_array($answer) ? $answer : [sanitize_key($answer) => $answer];
1376
+
1377
+		foreach ($answer as $key => $value) {
1378
+			$key            = self::prep_option_value($key);
1379
+			$answer[ $key ] = self::prep_answer($value, $use_html_entities);
1380
+		}
1381
+
1382
+		// prep the required array
1383
+		$required = self::prep_required($required);
1384
+		// set disabled tag
1385
+		$disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
1386
+		// ya gots ta have style man!!!
1387
+		$radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class;
1388
+		$class       = empty($class) ? 'espresso-radio-btn-inp' : $class;
1389
+		$extra       = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1390
+
1391
+		$label_html =
1392
+			$required_text
1393
+			. "\n\t\t\t"
1394
+			. '<label class="' . $label_class . '">'
1395
+			. self::prep_question($question)
1396
+			. $required['label']
1397
+			. '</label> ';
1398
+		// filter label but ensure required text comes before it
1399
+		$label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
1400
+
1401
+		$input_html =
1402
+			"\n\t\t\t"
1403
+			. '<ul id="' . $id . '-ul" class="espresso-checkbox-options-ul ' . $label_class . ' ' . $class . '-ul">';
1404
+
1405
+		$class .= ! empty($system_ID) ? ' ' . $system_ID : '';
1406
+		$class .= ! empty($required['class']) ? ' ' . $required['class'] : '';
1407
+
1408
+		foreach ($options as $OPT) {
1409
+			$value = $OPT->value();// self::prep_option_value( $OPT->value() );
1410
+			$size  = self::get_label_size_class($OPT->value() . ' ' . $OPT->desc());
1411
+			$text  = self::prep_answer($OPT->value());
1412
+			$desc  = $OPT->desc();
1413
+			$opt   = '-' . sanitize_key($value);
1414
+
1415
+			$checked = is_array($answer) && in_array($text, $answer) ? ' checked="checked"' : '';
1416
+
1417
+			$input_html .= "\n\t\t\t\t" . '<li' . $size . '>';
1418
+			$input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-checkbox-lbl">';
1419
+			$input_html .= $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : '';
1420
+			$input_html .= "\n\t\t\t\t\t\t"
1421
+						   . '<input type="checkbox" name="' . $name . '[' . $OPT->ID() . ']" '
1422
+						   . 'id="' . $id . $opt . '" class="' . $class . '" value="' . $value . '" '
1423
+						   . 'title="' . esc_attr($required['msg']) . '" ' . $disabled . $checked . ' ' . $extra . '/>';
1424
+			$input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : '';
1425
+			$input_html .= "\n\t\t\t\t\t" . '</label>';
1426
+			if (! empty($desc) && $desc != $text) {
1427
+				$input_html .= "\n\t\t\t\t\t"
1428
+							   . ' &nbsp; <br/><div class="espresso-checkbox-option-desc small-text grey-text">'
1429
+							   . $desc
1430
+							   . '</div>';
1431
+			}
1432
+			$input_html .= "\n\t\t\t\t" . '</li>';
1433
+		}
1434
+
1435
+		$input_html .= "\n\t\t\t" . '</ul>';
1436
+
1437
+		$input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1438
+		return $label_html . $input_html;
1439
+	}
1440
+
1441
+
1442
+	/**
1443
+	 * generates HTML for a form datepicker input
1444
+	 *
1445
+	 * @param string $question    label content
1446
+	 * @param string $answer      form input value attribute
1447
+	 * @param string $name        form input name attribute
1448
+	 * @param string $id          form input css id attribute
1449
+	 * @param string $class       form input css class attribute
1450
+	 * @param array  $required    'label', 'class', and 'msg' - array of values for required "label" content, css
1451
+	 *                            required 'class', and required 'msg' attribute
1452
+	 * @param string $label_class css class attribute for the label
1453
+	 * @param string $disabled    disabled="disabled" or null
1454
+	 * @return string HTML
1455
+	 */
1456
+	public static function datepicker(
1457
+		$question = false,
1458
+		$answer = null,
1459
+		$name = false,
1460
+		$id = '',
1461
+		$class = '',
1462
+		$required = false,
1463
+		$required_text = '',
1464
+		$label_class = '',
1465
+		$disabled = false,
1466
+		$system_ID = false,
1467
+		$use_html_entities = true
1468
+	) {
1469
+		// need these
1470
+		if (! $question || ! $name) {
1471
+			return null;
1472
+		}
1473
+		// prep the answer
1474
+		$answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities);
1475
+		// prep the required array
1476
+		$required = self::prep_required($required);
1477
+		// set disabled tag
1478
+		$disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
1479
+		// ya gots ta have style man!!!
1480
+		$txt_class = is_admin() ? 'regular-text' : 'espresso-datepicker-inp';
1481
+		$class     = empty($class) ? $txt_class : $class;
1482
+		$class     .= ! empty($system_ID) ? ' ' . $system_ID : '';
1483
+		$extra     = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1484
+
1485
+		$label_html =
1486
+			$required_text
1487
+			. "\n\t\t\t"
1488
+			. '<label for="' . $name . '" class="' . $label_class . '">'
1489
+			. self::prep_question($question)
1490
+			. $required['label']
1491
+			. '</label><br/>';
1492
+		// filter label but ensure required text comes before it
1493
+		$label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
1494
+
1495
+		$input_html =
1496
+			"\n\t\t\t"
1497
+			. '<input type="text" name="' . $name . '" id="' . $id . '" '
1498
+			. 'class="' . $class . ' ' . $required['class'] . ' datepicker" value="' . $answer . '"  '
1499
+			. 'title="' . esc_attr($required['msg']) . '" ' . $disabled . ' ' . $extra . '/>';
1500
+
1501
+		// enqueue scripts
1502
+		wp_register_style(
1503
+			'espresso-ui-theme',
1504
+			EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1505
+			[],
1506
+			EVENT_ESPRESSO_VERSION
1507
+		);
1508
+		wp_enqueue_style('espresso-ui-theme');
1509
+		wp_enqueue_script('jquery-ui-datepicker');
1510
+
1511
+		$input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1512
+		return $label_html . $input_html;
1513
+	}
1514
+
1515
+
1516
+	/**
1517
+	 *  remove_label_keep_required_msg
1518
+	 *  this will strip out a form input's label HTML while keeping the required text HTML that MUST be before the label
1519
+	 *
1520
+	 * @access public
1521
+	 * @return     string
1522
+	 */
1523
+	public static function remove_label_keep_required_msg($label_html, $required_text)
1524
+	{
1525
+		return $required_text;
1526
+	}
1527
+
1528
+
1529
+	/**
1530
+	 * Simply returns the HTML for a hidden input of the given name and value.
1531
+	 *
1532
+	 * @param string $name
1533
+	 * @param string $value
1534
+	 * @return string HTML
1535
+	 */
1536
+	public static function hidden_input($name, $value, $id = '')
1537
+	{
1538
+		$id = ! empty($id) ? $id : $name;
1539
+		return '<input id="' . $id . '" type="hidden" name="' . $name . '" value="' . $value . '"/>';
1540
+	}
1541
+
1542
+
1543
+	/**
1544
+	 * prep_question
1545
+	 *
1546
+	 * @param string $question
1547
+	 * @return string
1548
+	 */
1549
+	public static function prep_question($question)
1550
+	{
1551
+		return $question;
1552
+	}
1553
+
1554
+
1555
+	/**
1556
+	 *  prep_answer
1557
+	 *
1558
+	 * @param mixed $answer
1559
+	 * @return string
1560
+	 */
1561
+	public static function prep_answer($answer, $use_html_entities = true)
1562
+	{
1563
+		// make sure we convert bools first.  Otherwise (bool) false becomes an empty string which is NOT desired,
1564
+		// we want "0".
1565
+		if (is_bool($answer)) {
1566
+			$answer = $answer ? 1 : 0;
1567
+		}
1568
+		$answer = trim(stripslashes(str_replace('&#039;', "'", $answer)));
1569
+		return $use_html_entities ? htmlentities($answer, ENT_QUOTES, 'UTF-8') : $answer;
1570
+	}
1571
+
1572
+
1573
+	/**
1574
+	 *  prep_answer_options
1575
+	 *
1576
+	 * @param array $QSOs array of EE_Question_Option objects
1577
+	 * @return array
1578
+	 */
1579
+	public static function prep_answer_options($QSOs = [])
1580
+	{
1581
+		$prepped_answer_options = [];
1582
+		if (is_array($QSOs) && ! empty($QSOs)) {
1583
+			foreach ($QSOs as $key => $QSO) {
1584
+				if (! $QSO instanceof EE_Question_Option) {
1585
+					$QSO = EE_Question_Option::new_instance(
1586
+						[
1587
+							'QSO_value' => is_array($QSO) && isset($QSO['id'])
1588
+								? (string) $QSO['id']
1589
+								: (string) $key,
1590
+							'QSO_desc'  => is_array($QSO) && isset($QSO['text'])
1591
+								? (string) $QSO['text']
1592
+								: (string) $QSO,
1593
+						]
1594
+					);
1595
+				}
1596
+				if ($QSO->opt_group()) {
1597
+					$prepped_answer_options[ $QSO->opt_group() ][] = $QSO;
1598
+				} else {
1599
+					$prepped_answer_options[] = $QSO;
1600
+				}
1601
+			}
1602
+		}
1603
+		//      d( $prepped_answer_options );
1604
+		return $prepped_answer_options;
1605
+	}
1606
+
1607
+
1608
+	/**
1609
+	 *  prep_option_value
1610
+	 *
1611
+	 * @param string $option_value
1612
+	 * @return string
1613
+	 */
1614
+	public static function prep_option_value($option_value)
1615
+	{
1616
+		return esc_attr(trim(stripslashes($option_value)));
1617
+	}
1618
+
1619
+
1620
+	/**
1621
+	 *  prep_required
1622
+	 *
1623
+	 * @param string|array $required
1624
+	 * @return array
1625
+	 */
1626
+	public static function prep_required($required = [])
1627
+	{
1628
+		// make sure required is an array
1629
+		$required = is_array($required) ? $required : [];
1630
+		// and set some defaults
1631
+		return array_merge(['label' => '', 'class' => '', 'msg' => ''], $required);
1632
+	}
1633
+
1634
+
1635
+	/**
1636
+	 *  get_label_size_class
1637
+	 *
1638
+	 * @param string $value
1639
+	 * @return string
1640
+	 */
1641
+	public static function get_label_size_class($value = false)
1642
+	{
1643
+		if ($value === false || $value === '') {
1644
+			return ' class="medium-lbl"';
1645
+		}
1646
+		// determine length of option value
1647
+		$val_size = strlen($value);
1648
+		switch ($val_size) {
1649
+			case $val_size < 3:
1650
+				$size = ' class="nano-lbl"';
1651
+				break;
1652
+			case $val_size < 6:
1653
+				$size = ' class="micro-lbl"';
1654
+				break;
1655
+			case $val_size < 12:
1656
+				$size = ' class="tiny-lbl"';
1657
+				break;
1658
+			case $val_size < 25:
1659
+				$size = ' class="small-lbl"';
1660
+				break;
1661
+			case $val_size > 100:
1662
+				$size = ' class="big-lbl"';
1663
+				break;
1664
+			default:
1665
+				$size = ' class="medium-lbl"';
1666
+				break;
1667
+		}
1668
+		return $size;
1669
+	}
1670
+
1671
+
1672
+	/**
1673
+	 *  _load_system_dropdowns
1674
+	 *
1675
+	 * @param EE_Question_Form_Input $QFI
1676
+	 * @return array
1677
+	 * @throws EE_Error
1678
+	 * @throws ReflectionException
1679
+	 */
1680
+	private static function _load_system_dropdowns($QFI)
1681
+	{
1682
+		$QST_system = $QFI->get('QST_system');
1683
+		switch ($QST_system) {
1684
+			case 'state':
1685
+				$QFI = self::generate_state_dropdown($QFI);
1686
+				break;
1687
+			case 'country':
1688
+				$QFI = self::generate_country_dropdown($QFI);
1689
+				break;
1690
+			case 'admin-state':
1691
+				$QFI = self::generate_state_dropdown($QFI, true);
1692
+				break;
1693
+			case 'admin-country':
1694
+				$QFI = self::generate_country_dropdown($QFI, true);
1695
+				break;
1696
+		}
1697
+		return $QFI;
1698
+	}
1699
+
1700
+
1701
+	/**
1702
+	 * This preps dropdowns that are specialized.
1703
+	 *
1704
+	 * @param EE_Question_Form_Input $QFI
1705
+	 *
1706
+	 * @return EE_Question_Form_Input
1707
+	 * @throws EE_Error
1708
+	 * @throws ReflectionException
1709
+	 * @since  4.6.0
1710
+	 */
1711
+	protected static function _load_specialized_dropdowns($QFI)
1712
+	{
1713
+		switch ($QFI->get('QST_type')) {
1714
+			case 'STATE':
1715
+				$QFI = self::generate_state_dropdown($QFI);
1716
+				break;
1717
+			case 'COUNTRY':
1718
+				$QFI = self::generate_country_dropdown($QFI);
1719
+				break;
1720
+		}
1721
+		return $QFI;
1722
+	}
1723
+
1724
+
1725
+	/**
1726
+	 *    generate_state_dropdown
1727
+	 *
1728
+	 * @param EE_Question_Form_Input $QST
1729
+	 * @param bool                   $get_all
1730
+	 * @return EE_Question_Form_Input
1731
+	 * @throws EE_Error
1732
+	 * @throws ReflectionException
1733
+	 */
1734
+	public static function generate_state_dropdown($QST, $get_all = false)
1735
+	{
1736
+		$states = $get_all
1737
+			? EEM_State::instance()->get_all_states()
1738
+			: EEM_State::instance()->get_all_states_of_active_countries();
1739
+		if ($states && count($states) != count($QST->options())) {
1740
+			$QST->set('QST_type', 'DROPDOWN');
1741
+			// if multiple countries, we'll create option groups within the dropdown
1742
+			foreach ($states as $state) {
1743
+				if ($state instanceof EE_State) {
1744
+					$QSO = EE_Question_Option::new_instance(
1745
+						[
1746
+							'QSO_value'   => $state->ID(),
1747
+							'QSO_desc'    => $state->name(),
1748
+							'QST_ID'      => $QST->get('QST_ID'),
1749
+							'QSO_deleted' => false,
1750
+						]
1751
+					);
1752
+					// set option group
1753
+					$QSO->set_opt_group($state->country()->name());
1754
+					// add option to question
1755
+					$QST->add_temp_option($QSO);
1756
+				}
1757
+			}
1758
+		}
1759
+		return $QST;
1760
+	}
1761
+
1762
+
1763
+	/**
1764
+	 *    generate_country_dropdown
1765
+	 *
1766
+	 * @param      $QST
1767
+	 * @param bool $get_all
1768
+	 * @return array
1769
+	 * @throws EE_Error
1770
+	 * @throws ReflectionException
1771
+	 * @internal param array $question
1772
+	 */
1773
+	public static function generate_country_dropdown($QST, $get_all = false)
1774
+	{
1775
+		$countries = $get_all
1776
+			? EEM_Country::instance()->get_all_countries()
1777
+			: EEM_Country::instance()->get_all_active_countries();
1778
+		if ($countries && count($countries) != count($QST->options())) {
1779
+			$QST->set('QST_type', 'DROPDOWN');
1780
+			// now add countries
1781
+			foreach ($countries as $country) {
1782
+				if ($country instanceof EE_Country) {
1783
+					$QSO = EE_Question_Option::new_instance(
1784
+						[
1785
+							'QSO_value'   => $country->ID(),
1786
+							'QSO_desc'    => $country->name(),
1787
+							'QST_ID'      => $QST->get('QST_ID'),
1788
+							'QSO_deleted' => false,
1789
+						]
1790
+					);
1791
+					$QST->add_temp_option($QSO);
1792
+				}
1793
+			}
1794
+		}
1795
+		return $QST;
1796
+	}
1797
+
1798
+
1799
+	/**
1800
+	 *  generates options for a month dropdown selector with numbers from 01 to 12
1801
+	 *
1802
+	 * @return array()
1803
+	 */
1804
+	public static function two_digit_months_dropdown_options()
1805
+	{
1806
+		$options = [];
1807
+		for ($x = 1; $x <= 12; $x++) {
1808
+			$mm             = str_pad($x, 2, '0', STR_PAD_LEFT);
1809
+			$options[ $mm ] = $mm;
1810
+		}
1811
+		return EEH_Form_Fields::prep_answer_options($options);
1812
+	}
1813
+
1814
+
1815
+	/**
1816
+	 *  generates a year dropdown selector with numbers for the next ten years
1817
+	 *
1818
+	 * @return array
1819
+	 */
1820
+	public static function next_decade_two_digit_year_dropdown_options()
1821
+	{
1822
+		$options      = [];
1823
+		$current_year = date('y');
1824
+		$next_decade  = $current_year + 10;
1825
+		for ($x = $current_year; $x <= $next_decade; $x++) {
1826
+			$yy             = str_pad($x, 2, '0', STR_PAD_LEFT);
1827
+			$options[ $yy ] = $yy;
1828
+		}
1829
+		return EEH_Form_Fields::prep_answer_options($options);
1830
+	}
1831
+
1832
+
1833
+	/**
1834
+	 * generates a month/year dropdown selector for all registrations matching the given criteria.  Typically used for
1835
+	 * list table filter.
1836
+	 *
1837
+	 * @param string  $cur_date     any currently selected date can be entered here.
1838
+	 * @param string  $status       Registration status
1839
+	 * @param integer $evt_category Event Category ID if the Event Category filter is selected
1840
+	 * @return string                html
1841
+	 * @throws EE_Error
1842
+	 */
1843
+	public static function generate_registration_months_dropdown($cur_date = '', $status = '', $evt_category = 0)
1844
+	{
1845
+		$_where = [];
1846
+		if (! empty($status)) {
1847
+			$_where['STS_ID'] = $status;
1848
+		}
1849
+
1850
+		if ($evt_category > 0) {
1851
+			$_where['Event.Term_Taxonomy.term_id'] = $evt_category;
1852
+		}
1853
+
1854
+		$regdtts = EEM_Registration::instance()->get_reg_months_and_years($_where);
1855
+
1856
+		// setup vals for select input helper
1857
+		$options = [
1858
+			0 => [
1859
+				'text' => esc_html__('Select a Month/Year', 'event_espresso'),
1860
+				'id'   => '',
1861
+			],
1862
+		];
1863
+
1864
+		foreach ($regdtts as $regdtt) {
1865
+			$date      = $regdtt->reg_month . ' ' . $regdtt->reg_year;
1866
+			$options[] = [
1867
+				'text' => $date,
1868
+				'id'   => $date,
1869
+			];
1870
+		}
1871
+
1872
+		return self::select_input('month_range', $options, $cur_date, '', 'wide');
1873
+	}
1874
+
1875
+
1876
+	/**
1877
+	 * generates a month/year dropdown selector for all events matching the given criteria
1878
+	 * Typically used for list table filter
1879
+	 *
1880
+	 * @param string $cur_date          any currently selected date can be entered here.
1881
+	 * @param string $status            "view" (i.e. all, today, month, draft)
1882
+	 * @param int    $evt_category      category event belongs to
1883
+	 * @param string $evt_active_status "upcoming", "expired", "active", or "inactive"
1884
+	 * @return string                    html
1885
+	 * @throws EE_Error
1886
+	 */
1887
+	public static function generate_event_months_dropdown(
1888
+		$cur_date = '',
1889
+		$status = null,
1890
+		$evt_category = null,
1891
+		$evt_active_status = null
1892
+	) {
1893
+		// determine what post_status our condition will have for the query.
1894
+		// phpcs:disable PSR2.ControlStructures.SwitchDeclaration.TerminatingComment
1895
+		switch ($status) {
1896
+			case 'month':
1897
+			case 'today':
1898
+			case null:
1899
+			case 'all':
1900
+				$where['Event.status'] = ['NOT IN', ['trash']];
1901
+				break;
1902
+			case 'draft':
1903
+				$where['Event.status'] = ['IN', ['draft', 'auto-draft']];
1904
+				break;
1905
+			default:
1906
+				$where['Event.status'] = $status;
1907
+		}
1908
+
1909
+		// phpcs:enable
1910
+
1911
+		// categories?
1912
+
1913
+
1914
+		if (! empty($evt_category)) {
1915
+			$where['Event.Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
1916
+			$where['Event.Term_Taxonomy.term_id']  = $evt_category;
1917
+		}
1918
+
1919
+
1920
+		//      $where['DTT_is_primary'] = 1;
1921
+
1922
+		$DTTS = EEM_Datetime::instance()->get_dtt_months_and_years($where, $evt_active_status);
1923
+
1924
+		// let's setup vals for select input helper
1925
+		$options = [
1926
+			0 => [
1927
+				'text' => esc_html__('Select a Month/Year', 'event_espresso'),
1928
+				'id'   => "",
1929
+			],
1930
+		];
1931
+
1932
+
1933
+		// translate month and date
1934
+		global $wp_locale;
1935
+
1936
+		foreach ($DTTS as $DTT) {
1937
+			$localized_date = $wp_locale->get_month($DTT->dtt_month_num) . ' ' . $DTT->dtt_year;
1938
+			$id             = $DTT->dtt_month . ' ' . $DTT->dtt_year;
1939
+			$options[]      = [
1940
+				'text' => $localized_date,
1941
+				'id'   => $id,
1942
+			];
1943
+		}
1944
+
1945
+
1946
+		return self::select_input('month_range', $options, $cur_date, '', 'wide');
1947
+	}
1948
+
1949
+
1950
+	/**
1951
+	 * generates the dropdown selector for event categories
1952
+	 * typically used as a filter on list tables.
1953
+	 *
1954
+	 * @param integer $current_cat currently selected category
1955
+	 * @return string               html for dropdown
1956
+	 * @throws EE_Error
1957
+	 * @throws ReflectionException
1958
+	 */
1959
+	public static function generate_event_category_dropdown($current_cat = -1)
1960
+	{
1961
+		$categories = EEM_Term::instance()->get_all_ee_categories(true);
1962
+		$options    = [
1963
+			'0' => [
1964
+				'text' => esc_html__('All Categories', 'event_espresso'),
1965
+				'id'   => -1,
1966
+			],
1967
+		];
1968
+
1969
+		// setup categories for dropdown
1970
+		foreach ($categories as $category) {
1971
+			$options[] = [
1972
+				'text' => $category->get('name'),
1973
+				'id'   => $category->ID(),
1974
+			];
1975
+		}
1976
+
1977
+		return self::select_input('EVT_CAT', $options, $current_cat);
1978
+	}
1979
+
1980
+
1981
+	/**
1982
+	 *    generate a submit button with or without it's own microform
1983
+	 *    this is the only way to create buttons that are compatible across all themes
1984
+	 *
1985
+	 * @access    public
1986
+	 * @param string      $url              - the form action
1987
+	 * @param string      $ID               - some kind of unique ID, appended with "-sbmt" for the input and "-frm"
1988
+	 *                                      for the form
1989
+	 * @param string      $class            - css classes (separated by spaces if more than one)
1990
+	 * @param string      $text             - what appears on the button
1991
+	 * @param string      $nonce_action     - if using nonces
1992
+	 * @param bool|string $input_only       - whether to print form header and footer. TRUE returns the input without
1993
+	 *                                      the form
1994
+	 * @param string      $extra_attributes - any extra attributes that need to be attached to the form input
1995
+	 * @return    string
1996
+	 */
1997
+	public static function submit_button(
1998
+		$url = '',
1999
+		$ID = '',
2000
+		$class = '',
2001
+		$text = '',
2002
+		$nonce_action = '',
2003
+		$input_only = false,
2004
+		$extra_attributes = ''
2005
+	) {
2006
+		$btn = '';
2007
+		if (empty($url) || empty($ID)) {
2008
+			return $btn;
2009
+		}
2010
+		$text = ! empty($text) ? $text : esc_html__('Submit', 'event_espresso');
2011
+		$btn  .= '<input id="' . $ID . '-btn" class="' . $class . '" '
2012
+				 . 'type="submit" value="' . $text . '" ' . $extra_attributes . '/>';
2013
+		if (! $input_only) {
2014
+			$btn_frm = '<form id="' . $ID . '-frm" method="POST" action="' . $url . '">';
2015
+			$btn_frm .= ! empty($nonce_action)
2016
+				? wp_nonce_field($nonce_action, $nonce_action . '_nonce', true, false)
2017
+				: '';
2018
+			$btn_frm .= $btn;
2019
+			$btn_frm .= '</form>';
2020
+			$btn     = $btn_frm;
2021
+			unset($btn_frm);
2022
+		}
2023
+		return $btn;
2024
+	}
2025 2025
 }
Please login to merge, or discard this patch.
Spacing   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
             $type           = $input_value['input'];
111 111
             $value          = $input_value['value'];
112 112
 
113
-            $id    = $form_id ? $form_id . '-' . $input_key : $input_key;
114
-            $class = $required ? 'required ' . $css_class : $css_class;
113
+            $id    = $form_id ? $form_id.'-'.$input_key : $input_key;
114
+            $class = $required ? 'required '.$css_class : $css_class;
115 115
 
116 116
             // what type of input are we dealing with ?
117 117
             switch ($type) {
@@ -163,8 +163,8 @@  discard block
 block discarded – undo
163 163
             }
164 164
         } // end foreach( $input_vars as $input_key => $input_value )
165 165
 
166
-        if (! empty($inputs)) {
167
-            $glue   = "
166
+        if ( ! empty($inputs)) {
167
+            $glue = "
168 168
                 </li>
169 169
                 <li>
170 170
                     ";
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
             </ul>
178 178
             ";
179 179
         }
180
-        return $output . implode("\n", $hidden_inputs);
180
+        return $output.implode("\n", $hidden_inputs);
181 181
     }
182 182
 
183 183
 
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
             // generate label
259 259
             $label = ! empty($label) ? self::adminLabel($id, $label, $required) : '';
260 260
             // generate field name
261
-            $name = ! empty($unique_id) ? $field_name . '[' . $unique_id . ']' : $field_name;
261
+            $name = ! empty($unique_id) ? $field_name.'['.$unique_id.']' : $field_name;
262 262
 
263 263
             // we determine what we're building based on the type
264 264
             switch ($type) {
@@ -269,14 +269,14 @@  discard block
 block discarded – undo
269 269
                         foreach ($value as $key => $val) {
270 270
                             $c_input .= self::adminMulti(
271 271
                                 $default,
272
-                                isset($classes[ $key ]) ? $classes[ $key ] : '',
273
-                                $field_name . '_' . $value,
272
+                                isset($classes[$key]) ? $classes[$key] : '',
273
+                                $field_name.'_'.$value,
274 274
                                 $name,
275 275
                                 $required,
276 276
                                 $tab_index,
277 277
                                 $type,
278 278
                                 $val,
279
-                                isset($labels[ $key ]) ? $labels[ $key ] : ''
279
+                                isset($labels[$key]) ? $labels[$key] : ''
280 280
                             );
281 281
                         }
282 282
                         $field = $c_input;
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
                 case 'select':
303 303
                     $options = [];
304 304
                     foreach ($value as $key => $val) {
305
-                        $options[ $val ] = isset($labels[ $key ]) ? $labels[ $key ] : '';
305
+                        $options[$val] = isset($labels[$key]) ? $labels[$key] : '';
306 306
                     }
307 307
                     $field = self::adminSelect($default, $class, $id, $name, $required, $tab_index, $options);
308 308
                     break;
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
                     $field = self::adminText($class, $id, $name, $required, $tab_index, $value);
329 329
             }
330 330
 
331
-            $form_fields[ $field_name ] = ['label' => $label, 'field' => $field . $extra_desc];
331
+            $form_fields[$field_name] = ['label' => $label, 'field' => $field.$extra_desc];
332 332
         }
333 333
 
334 334
         return $form_fields;
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
     public static function select_input($name, $values, $default = '', $parameters = '', $class = '', $autosize = true)
537 537
     {
538 538
         // if $values was submitted in the wrong format, convert it over
539
-        if (! empty($values) && (! array_key_exists(0, $values) || ! is_array($values[0]))) {
539
+        if ( ! empty($values) && ( ! array_key_exists(0, $values) || ! is_array($values[0]))) {
540 540
             $converted_values = [];
541 541
             foreach ($values as $id => $text) {
542 542
                 $converted_values[] = ['id' => $id, 'text' => $text];
@@ -545,18 +545,18 @@  discard block
 block discarded – undo
545 545
         }
546 546
 
547 547
         $field =
548
-            '<select id="' . EEH_Formatter::ee_tep_output_string($name)
549
-            . '" name="' . EEH_Formatter::ee_tep_output_string($name)
548
+            '<select id="'.EEH_Formatter::ee_tep_output_string($name)
549
+            . '" name="'.EEH_Formatter::ee_tep_output_string($name)
550 550
             . '"';
551 551
 
552 552
         if (EEH_Formatter::ee_tep_not_null($parameters)) {
553
-            $field .= ' ' . $parameters;
553
+            $field .= ' '.$parameters;
554 554
         }
555 555
         if ($autosize) {
556 556
             $size = 'med';
557 557
             for ($ii = 0, $ni = sizeof($values); $ii < $ni; $ii++) {
558
-                if ($values[ $ii ]['text']) {
559
-                    if (strlen($values[ $ii ]['text']) > 5) {
558
+                if ($values[$ii]['text']) {
559
+                    if (strlen($values[$ii]['text']) > 5) {
560 560
                         $size = 'wide';
561 561
                     }
562 562
                 }
@@ -565,22 +565,22 @@  discard block
 block discarded – undo
565 565
             $size = '';
566 566
         }
567 567
 
568
-        $field .= ' class="' . $class . ' ' . $size . '">';
568
+        $field .= ' class="'.$class.' '.$size.'">';
569 569
 
570
-        if (empty($default) && isset($GLOBALS[ $name ])) {
571
-            $default = stripslashes($GLOBALS[ $name ]);
570
+        if (empty($default) && isset($GLOBALS[$name])) {
571
+            $default = stripslashes($GLOBALS[$name]);
572 572
         }
573 573
 
574 574
 
575 575
         for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
576
-            $field .= '<option value="' . $values[ $i ]['id'] . '"';
577
-            if ($default == $values[ $i ]['id']) {
576
+            $field .= '<option value="'.$values[$i]['id'].'"';
577
+            if ($default == $values[$i]['id']) {
578 578
                 $field .= ' selected = "selected"';
579 579
             }
580
-            if (isset($values[ $i ]['class'])) {
581
-                $field .= ' class="' . $values[ $i ]['class'] . '"';
580
+            if (isset($values[$i]['class'])) {
581
+                $field .= ' class="'.$values[$i]['class'].'"';
582 582
             }
583
-            $field .= '>' . $values[ $i ]['text'] . '</option>';
583
+            $field .= '>'.$values[$i]['text'].'</option>';
584 584
         }
585 585
         $field .= '</select>';
586 586
 
@@ -606,11 +606,11 @@  discard block
 block discarded – undo
606 606
         $after_question_group_questions  =
607 607
             apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '');
608 608
 
609
-        if (! empty($question_groups)) {
609
+        if ( ! empty($question_groups)) {
610 610
             // loop thru question groups
611 611
             foreach ($question_groups as $QSG) {
612 612
                 // check that questions exist
613
-                if (! empty($QSG['QSG_questions'])) {
613
+                if ( ! empty($QSG['QSG_questions'])) {
614 614
                     // use fieldsets
615 615
                     $html .= "\n\t"
616 616
                              . '<'
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
                     $html .= $before_question_group_questions;
636 636
                     // loop thru questions
637 637
                     foreach ($QSG['QSG_questions'] as $question) {
638
-                        $QFI  = new EE_Question_Form_Input(
638
+                        $QFI = new EE_Question_Form_Input(
639 639
                             $question['qst_obj'],
640 640
                             $question['ans_obj'],
641 641
                             $question
@@ -643,7 +643,7 @@  discard block
 block discarded – undo
643 643
                         $html .= self::generate_form_input($QFI);
644 644
                     }
645 645
                     $html .= $after_question_group_questions;
646
-                    $html .= "\n\t" . '</' . $group_wrapper . '>';
646
+                    $html .= "\n\t".'</'.$group_wrapper.'>';
647 647
                 }
648 648
             }
649 649
         }
@@ -683,25 +683,25 @@  discard block
 block discarded – undo
683 683
             'input_id'    => '',
684 684
             'input_class' => '',
685 685
         ];
686
-        $q_meta         = array_merge($default_q_meta, $q_meta);
686
+        $q_meta = array_merge($default_q_meta, $q_meta);
687 687
 
688
-        if (! empty($question_groups)) {
688
+        if ( ! empty($question_groups)) {
689 689
             // loop thru question groups
690 690
             foreach ($question_groups as $QSG) {
691 691
                 if ($QSG instanceof EE_Question_Group) {
692 692
                     // check that questions exist
693 693
 
694 694
                     $where = ['QST_deleted' => 0];
695
-                    if (! $from_admin) {
695
+                    if ( ! $from_admin) {
696 696
                         $where['QST_admin_only'] = 0;
697 697
                     }
698 698
                     $questions =
699 699
                         $QSG->questions([$where, 'order_by' => ['Question_Group_Question.QGQ_order' => 'ASC']]);
700
-                    if (! empty($questions)) {
700
+                    if ( ! empty($questions)) {
701 701
                         // use fieldsets
702 702
                         $html .= "\n\t"
703
-                                 . '<' . $group_wrapper . ' class="espresso-question-group-wrap" '
704
-                                 . 'id="' . $QSG->get('QSG_identifier') . '">';
703
+                                 . '<'.$group_wrapper.' class="espresso-question-group-wrap" '
704
+                                 . 'id="'.$QSG->get('QSG_identifier').'">';
705 705
                         // group_name
706 706
                         if ($QSG->show_group_name()) {
707 707
                             $html .= "\n\t\t"
@@ -726,21 +726,21 @@  discard block
 block discarded – undo
726 726
                             /** @var RequestInterface $request */
727 727
                             $request      = LoaderFactory::getLoader()->getShared(RequestInterface::class);
728 728
                             $request_qstn = $request->getRequestParam('qstn', [], 'string', true);
729
-                            if (! empty($request_qstn) && isset($q_meta['input_id']) && isset($q_meta['att_nmbr'])) {
729
+                            if ( ! empty($request_qstn) && isset($q_meta['input_id']) && isset($q_meta['att_nmbr'])) {
730 730
                                 // check for answer in $request_qstn in case we are reprocessing a form after an error
731
-                                if (isset($request_qstn[ $q_meta['input_id'] ][ $qstn_id ])) {
732
-                                    $answer = is_array($request_qstn[ $q_meta['input_id'] ][ $qstn_id ])
733
-                                        ? $request_qstn[ $q_meta['input_id'] ][ $qstn_id ]
734
-                                        : sanitize_text_field($request_qstn[ $q_meta['input_id'] ][ $qstn_id ]);
731
+                                if (isset($request_qstn[$q_meta['input_id']][$qstn_id])) {
732
+                                    $answer = is_array($request_qstn[$q_meta['input_id']][$qstn_id])
733
+                                        ? $request_qstn[$q_meta['input_id']][$qstn_id]
734
+                                        : sanitize_text_field($request_qstn[$q_meta['input_id']][$qstn_id]);
735 735
                                 }
736 736
                             } elseif (isset($q_meta['attendee']) && $q_meta['attendee']) {
737 737
                                 // attendee data from the session
738 738
                                 $answer =
739
-                                    isset($q_meta['attendee'][ $qstn_id ]) ? $q_meta['attendee'][ $qstn_id ] : null;
739
+                                    isset($q_meta['attendee'][$qstn_id]) ? $q_meta['attendee'][$qstn_id] : null;
740 740
                             }
741 741
 
742 742
 
743
-                            $QFI  = new EE_Question_Form_Input(
743
+                            $QFI = new EE_Question_Form_Input(
744 744
                                 $QST,
745 745
                                 EE_Answer::new_instance(
746 746
                                     [
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
                             $html .= self::generate_form_input($QFI);
756 756
                         }
757 757
                         $html .= $after_question_group_questions;
758
-                        $html .= "\n\t" . '</' . $group_wrapper . '>';
758
+                        $html .= "\n\t".'</'.$group_wrapper.'>';
759 759
                     }
760 760
                 }
761 761
             }
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
             $QFI->get('QST_required_text') != ''
804 804
                 ? $QFI->get('QST_required_text')
805 805
                 : esc_html__('This field is required', 'event_espresso');
806
-        $required_text     = $QST_required
806
+        $required_text = $QST_required
807 807
             ? "\n\t\t\t"
808 808
               . '<div class="required-text hidden">'
809 809
               . self::prep_answer($required_text, $use_html_entities)
@@ -949,7 +949,7 @@  discard block
 block discarded – undo
949 949
         $use_html_entities = true
950 950
     ) {
951 951
         // need these
952
-        if (! $question || ! $name) {
952
+        if ( ! $question || ! $name) {
953 953
             return null;
954 954
         }
955 955
         // prep the answer
@@ -961,13 +961,13 @@  discard block
 block discarded – undo
961 961
         // ya gots ta have style man!!!
962 962
         $txt_class = is_admin() ? 'regular-text' : 'espresso-text-inp';
963 963
         $class     = empty($class) ? $txt_class : $class;
964
-        $class     .= ! empty($system_ID) ? ' ' . $system_ID : '';
964
+        $class     .= ! empty($system_ID) ? ' '.$system_ID : '';
965 965
         $extra     = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
966 966
 
967 967
         $label_html =
968 968
             $required_text
969 969
             . "\n\t\t\t"
970
-            . '<label for="' . $name . '" class="' . $label_class . '">'
970
+            . '<label for="'.$name.'" class="'.$label_class.'">'
971 971
             . self::prep_question($question)
972 972
             . $required['label']
973 973
             . '</label><br/>';
@@ -976,12 +976,12 @@  discard block
 block discarded – undo
976 976
 
977 977
         $input_html =
978 978
             "\n\t\t\t"
979
-            . '<input type="text" name="' . $name . '" id="' . $id . '" '
980
-            . 'class="' . $class . ' ' . $required['class'] . '" value="' . esc_attr($answer) . '"  '
981
-            . 'title="' . esc_attr($required['msg']) . '" ' . $disabled . ' ' . $extra . '/>';
979
+            . '<input type="text" name="'.$name.'" id="'.$id.'" '
980
+            . 'class="'.$class.' '.$required['class'].'" value="'.esc_attr($answer).'"  '
981
+            . 'title="'.esc_attr($required['msg']).'" '.$disabled.' '.$extra.'/>';
982 982
 
983 983
         $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
984
-        return $label_html . $input_html;
984
+        return $label_html.$input_html;
985 985
     }
986 986
 
987 987
 
@@ -1015,7 +1015,7 @@  discard block
 block discarded – undo
1015 1015
         $use_html_entities = true
1016 1016
     ) {
1017 1017
         // need these
1018
-        if (! $question || ! $name) {
1018
+        if ( ! $question || ! $name) {
1019 1019
             return null;
1020 1020
         }
1021 1021
         // prep the answer
@@ -1031,13 +1031,13 @@  discard block
 block discarded – undo
1031 1031
         // ya gots ta have style man!!!
1032 1032
         $txt_class = is_admin() ? 'regular-text' : 'espresso-textarea-inp';
1033 1033
         $class     = empty($class) ? $txt_class : $class;
1034
-        $class     .= ! empty($system_ID) ? ' ' . $system_ID : '';
1034
+        $class     .= ! empty($system_ID) ? ' '.$system_ID : '';
1035 1035
         $extra     = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1036 1036
 
1037 1037
         $label_html =
1038 1038
             $required_text
1039 1039
             . "\n\t\t\t"
1040
-            . '<label for="' . $name . '" class="' . $label_class . '">'
1040
+            . '<label for="'.$name.'" class="'.$label_class.'">'
1041 1041
             . self::prep_question($question)
1042 1042
             . $required['label']
1043 1043
             . '</label><br/>';
@@ -1046,14 +1046,14 @@  discard block
 block discarded – undo
1046 1046
 
1047 1047
         $input_html =
1048 1048
             "\n\t\t\t"
1049
-            . '<textarea name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" '
1050
-            . 'rows="' . $dimensions['rows'] . '" cols="' . $dimensions['cols'] . '"  '
1051
-            . 'title="' . $required['msg'] . '" ' . $disabled . ' ' . $extra . '>'
1049
+            . '<textarea name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].'" '
1050
+            . 'rows="'.$dimensions['rows'].'" cols="'.$dimensions['cols'].'"  '
1051
+            . 'title="'.$required['msg'].'" '.$disabled.' '.$extra.'>'
1052 1052
             . esc_textarea($answer)
1053 1053
             . '</textarea>';
1054 1054
 
1055 1055
         $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1056
-        return $label_html . $input_html;
1056
+        return $label_html.$input_html;
1057 1057
     }
1058 1058
 
1059 1059
 
@@ -1090,7 +1090,7 @@  discard block
 block discarded – undo
1090 1090
     ) {
1091 1091
 
1092 1092
         // need these
1093
-        if (! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
1093
+        if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
1094 1094
             return null;
1095 1095
         }
1096 1096
         // prep the answer
@@ -1108,13 +1108,13 @@  discard block
 block discarded – undo
1108 1108
         // ya gots ta have style man!!!
1109 1109
         $txt_class = is_admin() ? 'wide' : 'espresso-select-inp';
1110 1110
         $class     = empty($class) ? $txt_class : $class;
1111
-        $class     .= ! empty($system_ID) ? ' ' . $system_ID : '';
1111
+        $class     .= ! empty($system_ID) ? ' '.$system_ID : '';
1112 1112
         $extra     = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1113 1113
 
1114 1114
         $label_html =
1115 1115
             $required_text
1116 1116
             . "\n\t\t\t"
1117
-            . '<label for="' . $name . '" class="' . $label_class . '">'
1117
+            . '<label for="'.$name.'" class="'.$label_class.'">'
1118 1118
             . self::prep_question($question)
1119 1119
             . $required['label']
1120 1120
             . '</label><br/>';
@@ -1123,16 +1123,16 @@  discard block
 block discarded – undo
1123 1123
 
1124 1124
         $input_html =
1125 1125
             "\n\t\t\t"
1126
-            . '<select name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" '
1127
-            . 'title="' . esc_attr($required['msg']) . '"' . $disabled . ' ' . $extra . '>';
1126
+            . '<select name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].'" '
1127
+            . 'title="'.esc_attr($required['msg']).'"'.$disabled.' '.$extra.'>';
1128 1128
         // recursively count array elements, to determine total number of options
1129 1129
         $only_option = count($options, 1) == 1;
1130
-        if (! $only_option) {
1130
+        if ( ! $only_option) {
1131 1131
             // if there is NO answer set and there are multiple options to choose from, then set the "please select" message as selected
1132
-            $selected   = $answer === null ? ' selected="selected"' : '';
1132
+            $selected = $answer === null ? ' selected="selected"' : '';
1133 1133
             $input_html .= $add_please_select_option
1134 1134
                 ? "\n\t\t\t\t"
1135
-                  . '<option value=""' . $selected . '>'
1135
+                  . '<option value=""'.$selected.'>'
1136 1136
                   . esc_html__(' - please select - ', 'event_espresso')
1137 1137
                   . '</option>'
1138 1138
                 : '';
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
                 );
1156 1156
         }
1157 1157
 
1158
-        $input_html .= "\n\t\t\t" . '</select>';
1158
+        $input_html .= "\n\t\t\t".'</select>';
1159 1159
 
1160 1160
         $input_html =
1161 1161
             apply_filters(
@@ -1170,7 +1170,7 @@  discard block
 block discarded – undo
1170 1170
             );
1171 1171
 
1172 1172
         $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1173
-        return $label_html . $input_html;
1173
+        return $label_html.$input_html;
1174 1174
     }
1175 1175
 
1176 1176
 
@@ -1188,11 +1188,11 @@  discard block
 block discarded – undo
1188 1188
      */
1189 1189
     private static function _generate_select_option_group($opt_group, $QSOs, $answer, $use_html_entities = true)
1190 1190
     {
1191
-        $html = "\n\t\t\t\t" . '<optgroup label="' . self::prep_option_value($opt_group) . '">';
1191
+        $html = "\n\t\t\t\t".'<optgroup label="'.self::prep_option_value($opt_group).'">';
1192 1192
         foreach ($QSOs as $QSO) {
1193 1193
             $html .= self::_generate_select_option($QSO->value(), $QSO->desc(), $answer, false, $use_html_entities);
1194 1194
         }
1195
-        $html .= "\n\t\t\t\t" . '</optgroup>';
1195
+        $html .= "\n\t\t\t\t".'</optgroup>';
1196 1196
         return $html;
1197 1197
     }
1198 1198
 
@@ -1219,7 +1219,7 @@  discard block
 block discarded – undo
1219 1219
         $value    = ! empty($value) ? $value : $key;
1220 1220
         $selected = ($answer == $key || $only_option) ? 'selected="selected"' : '';
1221 1221
         return "\n\t\t\t\t"
1222
-               . '<option value="' . self::prep_option_value($key) . '" ' . $selected . '> '
1222
+               . '<option value="'.self::prep_option_value($key).'" '.$selected.'> '
1223 1223
                . $value
1224 1224
                . '&nbsp;&nbsp;&nbsp;</option>';
1225 1225
     }
@@ -1263,7 +1263,7 @@  discard block
 block discarded – undo
1263 1263
         $use_desc_4_label = false
1264 1264
     ) {
1265 1265
         // need these
1266
-        if (! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
1266
+        if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
1267 1267
             return null;
1268 1268
         }
1269 1269
         // prep the answer
@@ -1280,7 +1280,7 @@  discard block
 block discarded – undo
1280 1280
         $label_html =
1281 1281
             $required_text
1282 1282
             . "\n\t\t\t"
1283
-            . '<label class="' . $label_class . '">'
1283
+            . '<label class="'.$label_class.'">'
1284 1284
             . self::prep_question($question)
1285 1285
             . $required['label']
1286 1286
             . '</label> ';
@@ -1289,49 +1289,49 @@  discard block
 block discarded – undo
1289 1289
 
1290 1290
         $input_html =
1291 1291
             "\n\t\t\t"
1292
-            . '<ul id="' . $id . '-ul" class="espresso-radio-btn-options-ul ' . $label_class . ' ' . $class . '-ul">';
1292
+            . '<ul id="'.$id.'-ul" class="espresso-radio-btn-options-ul '.$label_class.' '.$class.'-ul">';
1293 1293
 
1294
-        $class .= ! empty($system_ID) ? ' ' . $system_ID : '';
1295
-        $class .= ! empty($required['class']) ? ' ' . $required['class'] : '';
1294
+        $class .= ! empty($system_ID) ? ' '.$system_ID : '';
1295
+        $class .= ! empty($required['class']) ? ' '.$required['class'] : '';
1296 1296
 
1297 1297
         foreach ($options as $OPT) {
1298 1298
             if ($OPT instanceof EE_Question_Option) {
1299 1299
                 $value   = self::prep_option_value($OPT->value());
1300 1300
                 $label   = $use_desc_4_label ? $OPT->desc() : $OPT->value();
1301 1301
                 $size    = $use_desc_4_label
1302
-                    ? self::get_label_size_class($OPT->value() . ' ' . $OPT->desc())
1302
+                    ? self::get_label_size_class($OPT->value().' '.$OPT->desc())
1303 1303
                     : self::get_label_size_class($OPT->value());
1304
-                $desc    = $OPT->desc();// no self::prep_answer
1304
+                $desc    = $OPT->desc(); // no self::prep_answer
1305 1305
                 $answer  = is_numeric($value) && empty($answer) ? 0 : $answer;
1306 1306
                 $checked = (string) $value == (string) $answer ? ' checked="checked"' : '';
1307
-                $opt     = '-' . sanitize_key($value);
1307
+                $opt     = '-'.sanitize_key($value);
1308 1308
 
1309
-                $input_html .= "\n\t\t\t\t" . '<li' . $size . '>';
1310
-                $input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-radio-btn-lbl">';
1311
-                $input_html .= $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $label . '</span>' : '';
1309
+                $input_html .= "\n\t\t\t\t".'<li'.$size.'>';
1310
+                $input_html .= "\n\t\t\t\t\t".'<label class="'.$radio_class.' espresso-radio-btn-lbl">';
1311
+                $input_html .= $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$label.'</span>' : '';
1312 1312
                 $input_html .= "\n\t\t\t\t\t\t"
1313
-                               . '<input type="radio" name="' . $name . '" id="' . $id . $opt . '" '
1314
-                               . 'class="' . $class . '" value="' . $value . '" '
1315
-                               . 'title="' . esc_attr($required['msg']) . '" ' . $disabled
1316
-                               . $checked . ' ' . $extra . '/>';
1313
+                               . '<input type="radio" name="'.$name.'" id="'.$id.$opt.'" '
1314
+                               . 'class="'.$class.'" value="'.$value.'" '
1315
+                               . 'title="'.esc_attr($required['msg']).'" '.$disabled
1316
+                               . $checked.' '.$extra.'/>';
1317 1317
                 $input_html .= ! $label_b4
1318 1318
                     ? "\n\t\t\t\t\t\t"
1319 1319
                       . '<span class="espresso-radio-btn-desc">'
1320 1320
                       . $label
1321 1321
                       . '</span>'
1322 1322
                     : '';
1323
-                $input_html .= "\n\t\t\t\t\t" . '</label>';
1323
+                $input_html .= "\n\t\t\t\t\t".'</label>';
1324 1324
                 $input_html .= $use_desc_4_label
1325 1325
                     ? ''
1326
-                    : '<span class="espresso-radio-btn-option-desc small-text grey-text">' . $desc . '</span>';
1327
-                $input_html .= "\n\t\t\t\t" . '</li>';
1326
+                    : '<span class="espresso-radio-btn-option-desc small-text grey-text">'.$desc.'</span>';
1327
+                $input_html .= "\n\t\t\t\t".'</li>';
1328 1328
             }
1329 1329
         }
1330 1330
 
1331
-        $input_html .= "\n\t\t\t" . '</ul>';
1331
+        $input_html .= "\n\t\t\t".'</ul>';
1332 1332
 
1333 1333
         $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1334
-        return $label_html . $input_html;
1334
+        return $label_html.$input_html;
1335 1335
     }
1336 1336
 
1337 1337
 
@@ -1366,7 +1366,7 @@  discard block
 block discarded – undo
1366 1366
         $use_html_entities = true
1367 1367
     ) {
1368 1368
         // need these
1369
-        if (! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
1369
+        if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
1370 1370
             return null;
1371 1371
         }
1372 1372
         $answer = maybe_unserialize($answer);
@@ -1376,7 +1376,7 @@  discard block
 block discarded – undo
1376 1376
 
1377 1377
         foreach ($answer as $key => $value) {
1378 1378
             $key            = self::prep_option_value($key);
1379
-            $answer[ $key ] = self::prep_answer($value, $use_html_entities);
1379
+            $answer[$key] = self::prep_answer($value, $use_html_entities);
1380 1380
         }
1381 1381
 
1382 1382
         // prep the required array
@@ -1391,7 +1391,7 @@  discard block
 block discarded – undo
1391 1391
         $label_html =
1392 1392
             $required_text
1393 1393
             . "\n\t\t\t"
1394
-            . '<label class="' . $label_class . '">'
1394
+            . '<label class="'.$label_class.'">'
1395 1395
             . self::prep_question($question)
1396 1396
             . $required['label']
1397 1397
             . '</label> ';
@@ -1400,42 +1400,42 @@  discard block
 block discarded – undo
1400 1400
 
1401 1401
         $input_html =
1402 1402
             "\n\t\t\t"
1403
-            . '<ul id="' . $id . '-ul" class="espresso-checkbox-options-ul ' . $label_class . ' ' . $class . '-ul">';
1403
+            . '<ul id="'.$id.'-ul" class="espresso-checkbox-options-ul '.$label_class.' '.$class.'-ul">';
1404 1404
 
1405
-        $class .= ! empty($system_ID) ? ' ' . $system_ID : '';
1406
-        $class .= ! empty($required['class']) ? ' ' . $required['class'] : '';
1405
+        $class .= ! empty($system_ID) ? ' '.$system_ID : '';
1406
+        $class .= ! empty($required['class']) ? ' '.$required['class'] : '';
1407 1407
 
1408 1408
         foreach ($options as $OPT) {
1409
-            $value = $OPT->value();// self::prep_option_value( $OPT->value() );
1410
-            $size  = self::get_label_size_class($OPT->value() . ' ' . $OPT->desc());
1409
+            $value = $OPT->value(); // self::prep_option_value( $OPT->value() );
1410
+            $size  = self::get_label_size_class($OPT->value().' '.$OPT->desc());
1411 1411
             $text  = self::prep_answer($OPT->value());
1412 1412
             $desc  = $OPT->desc();
1413
-            $opt   = '-' . sanitize_key($value);
1413
+            $opt   = '-'.sanitize_key($value);
1414 1414
 
1415 1415
             $checked = is_array($answer) && in_array($text, $answer) ? ' checked="checked"' : '';
1416 1416
 
1417
-            $input_html .= "\n\t\t\t\t" . '<li' . $size . '>';
1418
-            $input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-checkbox-lbl">';
1419
-            $input_html .= $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : '';
1417
+            $input_html .= "\n\t\t\t\t".'<li'.$size.'>';
1418
+            $input_html .= "\n\t\t\t\t\t".'<label class="'.$radio_class.' espresso-checkbox-lbl">';
1419
+            $input_html .= $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$text.'</span>' : '';
1420 1420
             $input_html .= "\n\t\t\t\t\t\t"
1421
-                           . '<input type="checkbox" name="' . $name . '[' . $OPT->ID() . ']" '
1422
-                           . 'id="' . $id . $opt . '" class="' . $class . '" value="' . $value . '" '
1423
-                           . 'title="' . esc_attr($required['msg']) . '" ' . $disabled . $checked . ' ' . $extra . '/>';
1424
-            $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : '';
1425
-            $input_html .= "\n\t\t\t\t\t" . '</label>';
1426
-            if (! empty($desc) && $desc != $text) {
1421
+                           . '<input type="checkbox" name="'.$name.'['.$OPT->ID().']" '
1422
+                           . 'id="'.$id.$opt.'" class="'.$class.'" value="'.$value.'" '
1423
+                           . 'title="'.esc_attr($required['msg']).'" '.$disabled.$checked.' '.$extra.'/>';
1424
+            $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$text.'</span>' : '';
1425
+            $input_html .= "\n\t\t\t\t\t".'</label>';
1426
+            if ( ! empty($desc) && $desc != $text) {
1427 1427
                 $input_html .= "\n\t\t\t\t\t"
1428 1428
                                . ' &nbsp; <br/><div class="espresso-checkbox-option-desc small-text grey-text">'
1429 1429
                                . $desc
1430 1430
                                . '</div>';
1431 1431
             }
1432
-            $input_html .= "\n\t\t\t\t" . '</li>';
1432
+            $input_html .= "\n\t\t\t\t".'</li>';
1433 1433
         }
1434 1434
 
1435
-        $input_html .= "\n\t\t\t" . '</ul>';
1435
+        $input_html .= "\n\t\t\t".'</ul>';
1436 1436
 
1437 1437
         $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1438
-        return $label_html . $input_html;
1438
+        return $label_html.$input_html;
1439 1439
     }
1440 1440
 
1441 1441
 
@@ -1467,7 +1467,7 @@  discard block
 block discarded – undo
1467 1467
         $use_html_entities = true
1468 1468
     ) {
1469 1469
         // need these
1470
-        if (! $question || ! $name) {
1470
+        if ( ! $question || ! $name) {
1471 1471
             return null;
1472 1472
         }
1473 1473
         // prep the answer
@@ -1479,13 +1479,13 @@  discard block
 block discarded – undo
1479 1479
         // ya gots ta have style man!!!
1480 1480
         $txt_class = is_admin() ? 'regular-text' : 'espresso-datepicker-inp';
1481 1481
         $class     = empty($class) ? $txt_class : $class;
1482
-        $class     .= ! empty($system_ID) ? ' ' . $system_ID : '';
1482
+        $class     .= ! empty($system_ID) ? ' '.$system_ID : '';
1483 1483
         $extra     = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1484 1484
 
1485 1485
         $label_html =
1486 1486
             $required_text
1487 1487
             . "\n\t\t\t"
1488
-            . '<label for="' . $name . '" class="' . $label_class . '">'
1488
+            . '<label for="'.$name.'" class="'.$label_class.'">'
1489 1489
             . self::prep_question($question)
1490 1490
             . $required['label']
1491 1491
             . '</label><br/>';
@@ -1494,14 +1494,14 @@  discard block
 block discarded – undo
1494 1494
 
1495 1495
         $input_html =
1496 1496
             "\n\t\t\t"
1497
-            . '<input type="text" name="' . $name . '" id="' . $id . '" '
1498
-            . 'class="' . $class . ' ' . $required['class'] . ' datepicker" value="' . $answer . '"  '
1499
-            . 'title="' . esc_attr($required['msg']) . '" ' . $disabled . ' ' . $extra . '/>';
1497
+            . '<input type="text" name="'.$name.'" id="'.$id.'" '
1498
+            . 'class="'.$class.' '.$required['class'].' datepicker" value="'.$answer.'"  '
1499
+            . 'title="'.esc_attr($required['msg']).'" '.$disabled.' '.$extra.'/>';
1500 1500
 
1501 1501
         // enqueue scripts
1502 1502
         wp_register_style(
1503 1503
             'espresso-ui-theme',
1504
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1504
+            EE_GLOBAL_ASSETS_URL.'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1505 1505
             [],
1506 1506
             EVENT_ESPRESSO_VERSION
1507 1507
         );
@@ -1509,7 +1509,7 @@  discard block
 block discarded – undo
1509 1509
         wp_enqueue_script('jquery-ui-datepicker');
1510 1510
 
1511 1511
         $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1512
-        return $label_html . $input_html;
1512
+        return $label_html.$input_html;
1513 1513
     }
1514 1514
 
1515 1515
 
@@ -1536,7 +1536,7 @@  discard block
 block discarded – undo
1536 1536
     public static function hidden_input($name, $value, $id = '')
1537 1537
     {
1538 1538
         $id = ! empty($id) ? $id : $name;
1539
-        return '<input id="' . $id . '" type="hidden" name="' . $name . '" value="' . $value . '"/>';
1539
+        return '<input id="'.$id.'" type="hidden" name="'.$name.'" value="'.$value.'"/>';
1540 1540
     }
1541 1541
 
1542 1542
 
@@ -1581,7 +1581,7 @@  discard block
 block discarded – undo
1581 1581
         $prepped_answer_options = [];
1582 1582
         if (is_array($QSOs) && ! empty($QSOs)) {
1583 1583
             foreach ($QSOs as $key => $QSO) {
1584
-                if (! $QSO instanceof EE_Question_Option) {
1584
+                if ( ! $QSO instanceof EE_Question_Option) {
1585 1585
                     $QSO = EE_Question_Option::new_instance(
1586 1586
                         [
1587 1587
                             'QSO_value' => is_array($QSO) && isset($QSO['id'])
@@ -1594,7 +1594,7 @@  discard block
 block discarded – undo
1594 1594
                     );
1595 1595
                 }
1596 1596
                 if ($QSO->opt_group()) {
1597
-                    $prepped_answer_options[ $QSO->opt_group() ][] = $QSO;
1597
+                    $prepped_answer_options[$QSO->opt_group()][] = $QSO;
1598 1598
                 } else {
1599 1599
                     $prepped_answer_options[] = $QSO;
1600 1600
                 }
@@ -1806,7 +1806,7 @@  discard block
 block discarded – undo
1806 1806
         $options = [];
1807 1807
         for ($x = 1; $x <= 12; $x++) {
1808 1808
             $mm             = str_pad($x, 2, '0', STR_PAD_LEFT);
1809
-            $options[ $mm ] = $mm;
1809
+            $options[$mm] = $mm;
1810 1810
         }
1811 1811
         return EEH_Form_Fields::prep_answer_options($options);
1812 1812
     }
@@ -1824,7 +1824,7 @@  discard block
 block discarded – undo
1824 1824
         $next_decade  = $current_year + 10;
1825 1825
         for ($x = $current_year; $x <= $next_decade; $x++) {
1826 1826
             $yy             = str_pad($x, 2, '0', STR_PAD_LEFT);
1827
-            $options[ $yy ] = $yy;
1827
+            $options[$yy] = $yy;
1828 1828
         }
1829 1829
         return EEH_Form_Fields::prep_answer_options($options);
1830 1830
     }
@@ -1843,7 +1843,7 @@  discard block
 block discarded – undo
1843 1843
     public static function generate_registration_months_dropdown($cur_date = '', $status = '', $evt_category = 0)
1844 1844
     {
1845 1845
         $_where = [];
1846
-        if (! empty($status)) {
1846
+        if ( ! empty($status)) {
1847 1847
             $_where['STS_ID'] = $status;
1848 1848
         }
1849 1849
 
@@ -1862,7 +1862,7 @@  discard block
 block discarded – undo
1862 1862
         ];
1863 1863
 
1864 1864
         foreach ($regdtts as $regdtt) {
1865
-            $date      = $regdtt->reg_month . ' ' . $regdtt->reg_year;
1865
+            $date      = $regdtt->reg_month.' '.$regdtt->reg_year;
1866 1866
             $options[] = [
1867 1867
                 'text' => $date,
1868 1868
                 'id'   => $date,
@@ -1911,7 +1911,7 @@  discard block
 block discarded – undo
1911 1911
         // categories?
1912 1912
 
1913 1913
 
1914
-        if (! empty($evt_category)) {
1914
+        if ( ! empty($evt_category)) {
1915 1915
             $where['Event.Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
1916 1916
             $where['Event.Term_Taxonomy.term_id']  = $evt_category;
1917 1917
         }
@@ -1934,8 +1934,8 @@  discard block
 block discarded – undo
1934 1934
         global $wp_locale;
1935 1935
 
1936 1936
         foreach ($DTTS as $DTT) {
1937
-            $localized_date = $wp_locale->get_month($DTT->dtt_month_num) . ' ' . $DTT->dtt_year;
1938
-            $id             = $DTT->dtt_month . ' ' . $DTT->dtt_year;
1937
+            $localized_date = $wp_locale->get_month($DTT->dtt_month_num).' '.$DTT->dtt_year;
1938
+            $id             = $DTT->dtt_month.' '.$DTT->dtt_year;
1939 1939
             $options[]      = [
1940 1940
                 'text' => $localized_date,
1941 1941
                 'id'   => $id,
@@ -2008,16 +2008,16 @@  discard block
 block discarded – undo
2008 2008
             return $btn;
2009 2009
         }
2010 2010
         $text = ! empty($text) ? $text : esc_html__('Submit', 'event_espresso');
2011
-        $btn  .= '<input id="' . $ID . '-btn" class="' . $class . '" '
2012
-                 . 'type="submit" value="' . $text . '" ' . $extra_attributes . '/>';
2013
-        if (! $input_only) {
2014
-            $btn_frm = '<form id="' . $ID . '-frm" method="POST" action="' . $url . '">';
2011
+        $btn .= '<input id="'.$ID.'-btn" class="'.$class.'" '
2012
+                 . 'type="submit" value="'.$text.'" '.$extra_attributes.'/>';
2013
+        if ( ! $input_only) {
2014
+            $btn_frm = '<form id="'.$ID.'-frm" method="POST" action="'.$url.'">';
2015 2015
             $btn_frm .= ! empty($nonce_action)
2016
-                ? wp_nonce_field($nonce_action, $nonce_action . '_nonce', true, false)
2016
+                ? wp_nonce_field($nonce_action, $nonce_action.'_nonce', true, false)
2017 2017
                 : '';
2018 2018
             $btn_frm .= $btn;
2019 2019
             $btn_frm .= '</form>';
2020
-            $btn     = $btn_frm;
2020
+            $btn = $btn_frm;
2021 2021
             unset($btn_frm);
2022 2022
         }
2023 2023
         return $btn;
Please login to merge, or discard this patch.
core/admin/templates/admin_details_metabox_column_wrapper.template.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -19,11 +19,11 @@
 block discarded – undo
19 19
         </div> <!-- post-body-content -->
20 20
 
21 21
         <?php
22
-        // let's loop through the columns
23
-        for ($i = 1; $i <= $num_columns; $i++) {
24
-            $context = ($i === 1) ? 'normal' : 'side';
25
-            $context = ($i > 2) ? 'column' . $i : $context;
26
-            ?>
22
+		// let's loop through the columns
23
+		for ($i = 1; $i <= $num_columns; $i++) {
24
+			$context = ($i === 1) ? 'normal' : 'side';
25
+			$context = ($i > 2) ? 'column' . $i : $context;
26
+			?>
27 27
         <div id='postbox-container-<?php echo absint($i); ?>' class='postbox-container'>
28 28
             <?php do_meta_boxes($current_page, $context, null); ?>
29 29
         </div>
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
         // let's loop through the columns
23 23
         for ($i = 1; $i <= $num_columns; $i++) {
24 24
             $context = ($i === 1) ? 'normal' : 'side';
25
-            $context = ($i > 2) ? 'column' . $i : $context;
25
+            $context = ($i > 2) ? 'column'.$i : $context;
26 26
             ?>
27 27
         <div id='postbox-container-<?php echo absint($i); ?>' class='postbox-container'>
28 28
             <?php do_meta_boxes($current_page, $context, null); ?>
Please login to merge, or discard this patch.
widgets/upcoming_events/EEW_Upcoming_Events.widget.php 2 patches
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
             EE_Question_Option::new_instance(['QSO_value' => false, 'QSO_desc' => esc_html__('No', 'event_espresso')]),
110 110
             EE_Question_Option::new_instance(['QSO_value' => true, 'QSO_desc' => esc_html__('Yes', 'event_espresso')]),
111 111
         ];
112
-        $sort_values   = [
112
+        $sort_values = [
113 113
             EE_Question_Option::new_instance(['QSO_value' => 'ASC', 'QSO_desc' => esc_html__('ASC', 'event_espresso')]),
114 114
             EE_Question_Option::new_instance(['QSO_value' => 'DESC', 'QSO_desc' => esc_html__('DESC', 'event_espresso')]),
115 115
         ];
@@ -326,8 +326,8 @@  discard block
 block discarded – undo
326 326
                 // Before widget (defined by themes).
327 327
                 echo $before_widget;
328 328
                 // Display the widget title if one was input (before and after defined by themes).
329
-                if (! empty($title)) {
330
-                    echo $before_title . $title . $after_title;
329
+                if ( ! empty($title)) {
330
+                    echo $before_title.$title.$after_title;
331 331
                 }
332 332
                 echo $this->widgetContent($post);
333 333
                 // After widget (defined by themes).
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
      */
347 347
     public function make_the_title_a_link($title)
348 348
     {
349
-        return '<a href="' . EEH_Event_View::event_archive_url() . '">' . $title . '</a>';
349
+        return '<a href="'.EEH_Event_View::event_archive_url().'">'.$title.'</a>';
350 350
     }
351 351
 
352 352
 
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
             foreach ($sizes as $image_size) {
428 428
                 $image_size = trim($image_size);
429 429
                 // no big images plz
430
-                if (! in_array($image_size, ['large', 'post-thumbnail'])) {
430
+                if ( ! in_array($image_size, ['large', 'post-thumbnail'])) {
431 431
                     $image_sizes[] =
432 432
                         EE_Question_Option::new_instance(['QSO_value' => $image_size, 'QSO_desc' => $image_size]);
433 433
                 }
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
     private function parseWidgetSettings(array $instance)
455 455
     {
456 456
         $this->title = isset($instance['title']) && ! empty($instance['title']) ? $instance['title'] : '';
457
-        $this->events_category     = isset($instance['category_name']) && ! empty($instance['category_name'])
457
+        $this->events_category = isset($instance['category_name']) && ! empty($instance['category_name'])
458 458
             ? $instance['category_name']
459 459
             : false;
460 460
         $this->show_expired = isset($instance['show_expired'])
@@ -512,24 +512,24 @@  discard block
 block discarded – undo
512 512
         }
513 513
         $list_items = '';
514 514
         foreach ($events as $event) {
515
-            if ($event instanceof EE_Event && (! is_single() || $post->ID != $event->ID())) {
515
+            if ($event instanceof EE_Event && ( ! is_single() || $post->ID != $event->ID())) {
516 516
                 $event_url = $this->eventUrl($event);
517 517
                 $list_items .= '
518
-                <li id="ee-upcoming-events-widget-li-' . absint($event->ID()) . '" 
518
+                <li id="ee-upcoming-events-widget-li-' . absint($event->ID()).'" 
519 519
                     class="ee-upcoming-events-widget-li"
520 520
                 >
521 521
                     <h5 class="ee-upcoming-events-widget-title-h5">
522
-                        <a class="ee-widget-event-name-a' . $this->linkClass($event) . '" href="' . $event_url . '">
523
-                            ' . esc_html($event->name()) . '
522
+                        <a class="ee-widget-event-name-a' . $this->linkClass($event).'" href="'.$event_url.'">
523
+                            ' . esc_html($event->name()).'
524 524
                         </a>
525 525
                     </h5>
526
-                    ' . $this->eventWidgetContent($event, $event_url) . '
526
+                    ' . $this->eventWidgetContent($event, $event_url).'
527 527
                 </li>';
528 528
             }
529 529
         }
530 530
         return '
531 531
             <ul class="ee-upcoming-events-widget-ul">
532
-                ' . $list_items . '
532
+                ' . $list_items.'
533 533
             </ul>';
534 534
     }
535 535
 
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
         return EEM_Event::instance()->get_all(
562 562
             [
563 563
                 $this->queryWhereParams(),
564
-                'limit'    => '0,' . $this->limit,
564
+                'limit'    => '0,'.$this->limit,
565 565
                 'order_by' => 'Datetime.DTT_EVT_start',
566 566
                 'order'    => $this->order,
567 567
                 'group_by' => 'EVT_ID',
@@ -649,8 +649,8 @@  discard block
 block discarded – undo
649 649
         if (has_post_thumbnail($event->ID()) && $this->image_size != 'none') {
650 650
             $content .= '
651 651
                 <div class="ee-upcoming-events-widget-img-dv">
652
-                    <a class="ee-upcoming-events-widget-img" href="' . $event_url . '">
653
-                        ' . get_the_post_thumbnail($event->ID(), $this->image_size) . '
652
+                    <a class="ee-upcoming-events-widget-img" href="' . $event_url.'">
653
+                        ' . get_the_post_thumbnail($event->ID(), $this->image_size).'
654 654
                     </a>
655 655
                 </div>';
656 656
         }
@@ -661,8 +661,8 @@  discard block
 block discarded – undo
661 661
 
662 662
         if ($this->show_desc) {
663 663
             global $allowedtags;
664
-            $desc    = $event->short_description(25);
665
-            $content .= $desc ? '<p style="margin-top: .5em">' . wp_kses($desc, $allowedtags) . '</p>' : '';
664
+            $desc = $event->short_description(25);
665
+            $content .= $desc ? '<p style="margin-top: .5em">'.wp_kses($desc, $allowedtags).'</p>' : '';
666 666
         }
667 667
 
668 668
         return $content;
@@ -678,11 +678,11 @@  discard block
 block discarded – undo
678 678
      */
679 679
     private function eventDates(EE_Event $event)
680 680
     {
681
-        $date_format        = apply_filters(
681
+        $date_format = apply_filters(
682 682
             'FHEE__espresso_event_date_range__date_format',
683 683
             get_option('date_format')
684 684
         );
685
-        $time_format        = apply_filters(
685
+        $time_format = apply_filters(
686 686
             'FHEE__espresso_event_date_range__time_format',
687 687
             get_option('time_format')
688 688
         );
Please login to merge, or discard this patch.
Indentation   +594 added lines, -594 removed lines patch added patch discarded remove patch
@@ -12,109 +12,109 @@  discard block
 block discarded – undo
12 12
 class EEW_Upcoming_Events extends EspressoWidget
13 13
 {
14 14
 
15
-    /**
16
-     * @var string
17
-     */
18
-    private $title;
19
-    /**
20
-     * @var string
21
-     */
22
-    private $events_category;
23
-
24
-    /**
25
-     * @var bool
26
-     */
27
-    private $show_expired;
28
-
29
-    /**
30
-     * @var string
31
-     */
32
-    private $image_size;
33
-
34
-    /**
35
-     * @var bool
36
-     */
37
-    private $show_desc;
38
-
39
-    /**
40
-     * @var bool
41
-     */
42
-    private $show_dates;
43
-
44
-    /**
45
-     * @var string
46
-     */
47
-    private $date_limit;
48
-
49
-    /**
50
-     * @var string
51
-     */
52
-    private $date_range;
53
-
54
-    /**
55
-     * @var string
56
-     */
57
-    private $limit;
58
-
59
-    /**
60
-     * @var string
61
-     */
62
-    private $order;
63
-
64
-
65
-    /**
66
-     * Register widget with WordPress.
67
-     */
68
-    public function __construct()
69
-    {
70
-        parent::__construct(
71
-            esc_html__('Event Espresso Upcoming Events', 'event_espresso'),
72
-            ['description' => esc_html__('A widget to display your upcoming events.', 'event_espresso')]
73
-        );
74
-    }
75
-
76
-
77
-    /**
78
-     * Back-end widget form.
79
-     *
80
-     * @param array $instance Previously saved values from database.
81
-     * @return void
82
-     * @throws EE_Error
83
-     * @throws ReflectionException
84
-     * @see WP_Widget::form()
85
-     */
86
-    public function form($instance)
87
-    {
88
-
89
-        EE_Registry::instance()->load_class('Question_Option', [], false, false, true);
90
-        // Set up some default widget settings.
91
-        $defaults = [
92
-            'title'           => esc_html__('Upcoming Events', 'event_espresso'),
93
-            'category_name'   => '',
94
-            'show_expired'    => 0,
95
-            'show_desc'       => true,
96
-            'show_dates'      => true,
97
-            'show_everywhere' => false,
98
-            'date_limit'      => 2,
99
-            'limit'           => 10,
100
-            'sort'            => 'ASC',
101
-            'date_range'      => false,
102
-            'image_size'      => 'medium',
103
-        ];
104
-
105
-        $instance = wp_parse_args((array) $instance, $defaults);
106
-        // don't add HTML labels for EE_Form_Fields generated inputs
107
-        add_filter('FHEE__EEH_Form_Fields__label_html', '__return_empty_string');
108
-        $yes_no_values = [
109
-            EE_Question_Option::new_instance(['QSO_value' => false, 'QSO_desc' => esc_html__('No', 'event_espresso')]),
110
-            EE_Question_Option::new_instance(['QSO_value' => true, 'QSO_desc' => esc_html__('Yes', 'event_espresso')]),
111
-        ];
112
-        $sort_values   = [
113
-            EE_Question_Option::new_instance(['QSO_value' => 'ASC', 'QSO_desc' => esc_html__('ASC', 'event_espresso')]),
114
-            EE_Question_Option::new_instance(['QSO_value' => 'DESC', 'QSO_desc' => esc_html__('DESC', 'event_espresso')]),
115
-        ];
116
-
117
-        ?>
15
+	/**
16
+	 * @var string
17
+	 */
18
+	private $title;
19
+	/**
20
+	 * @var string
21
+	 */
22
+	private $events_category;
23
+
24
+	/**
25
+	 * @var bool
26
+	 */
27
+	private $show_expired;
28
+
29
+	/**
30
+	 * @var string
31
+	 */
32
+	private $image_size;
33
+
34
+	/**
35
+	 * @var bool
36
+	 */
37
+	private $show_desc;
38
+
39
+	/**
40
+	 * @var bool
41
+	 */
42
+	private $show_dates;
43
+
44
+	/**
45
+	 * @var string
46
+	 */
47
+	private $date_limit;
48
+
49
+	/**
50
+	 * @var string
51
+	 */
52
+	private $date_range;
53
+
54
+	/**
55
+	 * @var string
56
+	 */
57
+	private $limit;
58
+
59
+	/**
60
+	 * @var string
61
+	 */
62
+	private $order;
63
+
64
+
65
+	/**
66
+	 * Register widget with WordPress.
67
+	 */
68
+	public function __construct()
69
+	{
70
+		parent::__construct(
71
+			esc_html__('Event Espresso Upcoming Events', 'event_espresso'),
72
+			['description' => esc_html__('A widget to display your upcoming events.', 'event_espresso')]
73
+		);
74
+	}
75
+
76
+
77
+	/**
78
+	 * Back-end widget form.
79
+	 *
80
+	 * @param array $instance Previously saved values from database.
81
+	 * @return void
82
+	 * @throws EE_Error
83
+	 * @throws ReflectionException
84
+	 * @see WP_Widget::form()
85
+	 */
86
+	public function form($instance)
87
+	{
88
+
89
+		EE_Registry::instance()->load_class('Question_Option', [], false, false, true);
90
+		// Set up some default widget settings.
91
+		$defaults = [
92
+			'title'           => esc_html__('Upcoming Events', 'event_espresso'),
93
+			'category_name'   => '',
94
+			'show_expired'    => 0,
95
+			'show_desc'       => true,
96
+			'show_dates'      => true,
97
+			'show_everywhere' => false,
98
+			'date_limit'      => 2,
99
+			'limit'           => 10,
100
+			'sort'            => 'ASC',
101
+			'date_range'      => false,
102
+			'image_size'      => 'medium',
103
+		];
104
+
105
+		$instance = wp_parse_args((array) $instance, $defaults);
106
+		// don't add HTML labels for EE_Form_Fields generated inputs
107
+		add_filter('FHEE__EEH_Form_Fields__label_html', '__return_empty_string');
108
+		$yes_no_values = [
109
+			EE_Question_Option::new_instance(['QSO_value' => false, 'QSO_desc' => esc_html__('No', 'event_espresso')]),
110
+			EE_Question_Option::new_instance(['QSO_value' => true, 'QSO_desc' => esc_html__('Yes', 'event_espresso')]),
111
+		];
112
+		$sort_values   = [
113
+			EE_Question_Option::new_instance(['QSO_value' => 'ASC', 'QSO_desc' => esc_html__('ASC', 'event_espresso')]),
114
+			EE_Question_Option::new_instance(['QSO_value' => 'DESC', 'QSO_desc' => esc_html__('DESC', 'event_espresso')]),
115
+		];
116
+
117
+		?>
118 118
 
119 119
         <!-- Widget Title: Text Input -->
120 120
 
@@ -151,32 +151,32 @@  discard block
 block discarded – undo
151 151
                 <?php esc_html_e('Show Expired Events:', 'event_espresso'); ?>
152 152
             </label>
153 153
             <?php
154
-            $show_expired_options   = $yes_no_values;
155
-            $show_expired_options[] = EE_Question_Option::new_instance(
156
-                ['QSO_value' => 2, 'QSO_desc' => esc_html__('Show Only Expired', 'event_espresso')]
157
-            );
158
-            echo EEH_Form_Fields::select(
159
-                esc_html__('Show Expired Events:', 'event_espresso'),
160
-                $instance['show_expired'],
161
-                $show_expired_options,
162
-                $this->fieldName('show_expired'),
163
-                $this->fieldID('show_expired')
164
-            );
165
-            ?>
154
+			$show_expired_options   = $yes_no_values;
155
+			$show_expired_options[] = EE_Question_Option::new_instance(
156
+				['QSO_value' => 2, 'QSO_desc' => esc_html__('Show Only Expired', 'event_espresso')]
157
+			);
158
+			echo EEH_Form_Fields::select(
159
+				esc_html__('Show Expired Events:', 'event_espresso'),
160
+				$instance['show_expired'],
161
+				$show_expired_options,
162
+				$this->fieldName('show_expired'),
163
+				$this->fieldID('show_expired')
164
+			);
165
+			?>
166 166
         </p>
167 167
         <p>
168 168
             <label for="<?php echo esc_attr($this->fieldID('sort')); ?>">
169 169
                 <?php esc_html_e('Sort Events:', 'event_espresso'); ?>
170 170
             </label>
171 171
             <?php
172
-            echo EEH_Form_Fields::select(
173
-                esc_html__('Sort Events:', 'event_espresso'),
174
-                $instance['sort'],
175
-                $sort_values,
176
-                $this->fieldName('sort'),
177
-                $this->fieldID('sort')
178
-            );
179
-            ?>
172
+			echo EEH_Form_Fields::select(
173
+				esc_html__('Sort Events:', 'event_espresso'),
174
+				$instance['sort'],
175
+				$sort_values,
176
+				$this->fieldName('sort'),
177
+				$this->fieldID('sort')
178
+			);
179
+			?>
180 180
         </p>
181 181
         <p>
182 182
             <label for="<?php echo esc_attr($this->fieldID('image_size')); ?>">
@@ -190,42 +190,42 @@  discard block
 block discarded – undo
190 190
                 <?php esc_html_e('Show Description:', 'event_espresso'); ?>
191 191
             </label>
192 192
             <?php
193
-            echo EEH_Form_Fields::select(
194
-                esc_html__('Show Description:', 'event_espresso'),
195
-                $instance['show_desc'],
196
-                $yes_no_values,
197
-                $this->fieldName('show_desc'),
198
-                $this->fieldID('show_desc')
199
-            );
200
-            ?>
193
+			echo EEH_Form_Fields::select(
194
+				esc_html__('Show Description:', 'event_espresso'),
195
+				$instance['show_desc'],
196
+				$yes_no_values,
197
+				$this->fieldName('show_desc'),
198
+				$this->fieldID('show_desc')
199
+			);
200
+			?>
201 201
         </p>
202 202
         <p>
203 203
             <label for="<?php echo esc_attr($this->fieldID('show_dates')); ?>">
204 204
                 <?php esc_html_e('Show Dates:', 'event_espresso'); ?>
205 205
             </label>
206 206
             <?php
207
-            echo EEH_Form_Fields::select(
208
-                esc_html__('Show Dates:', 'event_espresso'),
209
-                $instance['show_dates'],
210
-                $yes_no_values,
211
-                $this->fieldName('show_dates'),
212
-                $this->fieldID('show_dates')
213
-            );
214
-            ?>
207
+			echo EEH_Form_Fields::select(
208
+				esc_html__('Show Dates:', 'event_espresso'),
209
+				$instance['show_dates'],
210
+				$yes_no_values,
211
+				$this->fieldName('show_dates'),
212
+				$this->fieldID('show_dates')
213
+			);
214
+			?>
215 215
         </p>
216 216
         <p>
217 217
             <label for="<?php echo esc_attr($this->fieldID('show_everywhere')); ?>">
218 218
                 <?php esc_html_e('Show on all Pages:', 'event_espresso'); ?>
219 219
             </label>
220 220
             <?php
221
-            echo EEH_Form_Fields::select(
222
-                esc_html__('Show on all Pages:', 'event_espresso'),
223
-                $instance['show_everywhere'],
224
-                $yes_no_values,
225
-                $this->fieldName('show_everywhere'),
226
-                $this->fieldID('show_everywhere')
227
-            );
228
-            ?>
221
+			echo EEH_Form_Fields::select(
222
+				esc_html__('Show on all Pages:', 'event_espresso'),
223
+				$instance['show_everywhere'],
224
+				$yes_no_values,
225
+				$this->fieldName('show_everywhere'),
226
+				$this->fieldID('show_everywhere')
227
+			);
228
+			?>
229 229
         </p>
230 230
         <p>
231 231
             <label for="<?php echo esc_attr($this->fieldID('date_limit')); ?>">
@@ -243,278 +243,278 @@  discard block
 block discarded – undo
243 243
                 <?php esc_html_e('Show Date Range:', 'event_espresso'); ?>
244 244
             </label>
245 245
             <?php
246
-            echo EEH_Form_Fields::select(
247
-                esc_html__('Show Date Range:', 'event_espresso'),
248
-                $instance['date_range'],
249
-                $yes_no_values,
250
-                $this->fieldName('date_range'),
251
-                $this->fieldID('date_range')
252
-            );
253
-            ?>
246
+			echo EEH_Form_Fields::select(
247
+				esc_html__('Show Date Range:', 'event_espresso'),
248
+				$instance['date_range'],
249
+				$yes_no_values,
250
+				$this->fieldName('date_range'),
251
+				$this->fieldID('date_range')
252
+			);
253
+			?>
254 254
             <span class="description">
255 255
                 <br />
256 256
                 <?php esc_html_e(
257
-                    'This setting will replace the list of dates in the widget.',
258
-                    'event_espresso'
259
-                ); ?>
257
+					'This setting will replace the list of dates in the widget.',
258
+					'event_espresso'
259
+				); ?>
260 260
             </span>
261 261
         </p>
262 262
 
263 263
         <?php
264
-    }
265
-
266
-
267
-    /**
268
-     * Sanitize widget form values as they are saved.
269
-     *
270
-     * @param array $new_instance Values just sent to be saved.
271
-     * @param array $old_instance Previously saved values from database.
272
-     *
273
-     * @return array Updated safe values to be saved.
274
-     * @see WP_Widget::update()
275
-     *
276
-     */
277
-    public function update($new_instance, $old_instance)
278
-    {
279
-        $instance                    = $old_instance;
280
-        $instance['title']           = ! empty($new_instance['title']) ? strip_tags($new_instance['title']) : '';
281
-        $instance['category_name']   = $new_instance['category_name'];
282
-        $instance['show_expired']    = $new_instance['show_expired'];
283
-        $instance['limit']           = $new_instance['limit'];
284
-        $instance['sort']            = $new_instance['sort'];
285
-        $instance['image_size']      = $new_instance['image_size'];
286
-        $instance['show_desc']       = $new_instance['show_desc'];
287
-        $instance['show_dates']      = $new_instance['show_dates'];
288
-        $instance['show_everywhere'] = $new_instance['show_everywhere'];
289
-        $instance['date_limit']      = $new_instance['date_limit'];
290
-        $instance['date_range']      = $new_instance['date_range'];
291
-        return $instance;
292
-    }
293
-
294
-
295
-    /**
296
-     * Front-end display of widget.
297
-     *
298
-     * @param array $args     Widget arguments.
299
-     * @param array $instance Saved values from database.
300
-     * @throws EE_Error
301
-     * @throws ReflectionException
302
-     * @see WP_Widget::widget()
303
-     *
304
-     */
305
-    public function widget($args, $instance)
306
-    {
307
-
308
-        global $post;
309
-        // make sure there is some kinda post object
310
-        if ($post instanceof WP_Post) {
311
-            $before_widget = '';
312
-            $before_title  = '';
313
-            $after_title   = '';
314
-            $after_widget  = '';
315
-            // but NOT an events archives page, cuz that would be like two event lists on the same page
316
-            $show_everywhere = ! isset($instance['show_everywhere']) || absint($instance['show_everywhere']);
317
-            if ($show_everywhere || ! ($post->post_type == 'espresso_events' && is_archive())) {
318
-                // let's use some of the event helper functions'
319
-                // make separate vars out of attributes
320
-                extract($args);
321
-
322
-                // grab widget settings
323
-                $this->parseWidgetSettings($instance);
324
-                $title = $this->widgetTitle();
325
-
326
-                // Before widget (defined by themes).
327
-                echo $before_widget;
328
-                // Display the widget title if one was input (before and after defined by themes).
329
-                if (! empty($title)) {
330
-                    echo $before_title . $title . $after_title;
331
-                }
332
-                echo $this->widgetContent($post);
333
-                // After widget (defined by themes).
334
-                echo $after_widget;
335
-            }
336
-        }
337
-    }
338
-
339
-
340
-    /**
341
-     * make_the_title_a_link
342
-     * callback for widget_title filter
343
-     *
344
-     * @param $title
345
-     * @return string
346
-     */
347
-    public function make_the_title_a_link($title)
348
-    {
349
-        return '<a href="' . EEH_Event_View::event_archive_url() . '">' . $title . '</a>';
350
-    }
351
-
352
-
353
-    /**
354
-     * @param string $field_name
355
-     * @return string
356
-     * @since   4.10.14.p
357
-     */
358
-    public function fieldID($field_name)
359
-    {
360
-        return parent::get_field_id($field_name);
361
-    }
362
-
363
-
364
-    /**
365
-     * @param string $field_name
366
-     * @return string
367
-     * @since   4.10.14.p
368
-     */
369
-    public function fieldName($field_name)
370
-    {
371
-        return parent::get_field_name($field_name);
372
-    }
373
-
374
-
375
-    /**
376
-     * @param array $instance
377
-     * @throws EE_Error
378
-     * @throws ReflectionException
379
-     * @since   4.10.14.p
380
-     */
381
-    private function eventCategoriesSelector(array $instance)
382
-    {
383
-        $event_categories = [];
384
-        $categories       = EEM_Term::instance()->get_all_ee_categories(true);
385
-        if ($categories) {
386
-            foreach ($categories as $category) {
387
-                if ($category instanceof EE_Term) {
388
-                    $event_categories[] =
389
-                        EE_Question_Option::new_instance(
390
-                            [
391
-                                'QSO_value' => $category->get('slug'),
392
-                                'QSO_desc'  => $category->get('name'),
393
-                            ]
394
-                        );
395
-                }
396
-            }
397
-        }
398
-        array_unshift(
399
-            $event_categories,
400
-            EE_Question_Option::new_instance(
401
-                [
402
-                    'QSO_value' => '',
403
-                    'QSO_desc'  => esc_html__(' - display all - ', 'event_espresso'),
404
-                ]
405
-            )
406
-        );
407
-        echo EEH_Form_Fields::select(
408
-            esc_html__('Event Category:', 'event_espresso'),
409
-            $instance['category_name'],
410
-            $event_categories,
411
-            $this->fieldName('category_name'),
412
-            $this->fieldID('category_name')
413
-        );
414
-    }
415
-
416
-
417
-    /**
418
-     * @param array $instance
419
-     * @since   4.10.14.p
420
-     */
421
-    private function imageSizeSelector(array $instance)
422
-    {
423
-        $image_sizes = [];
424
-        $sizes       = get_intermediate_image_sizes();
425
-        if ($sizes) {
426
-            // loop thru images and create option objects out of them
427
-            foreach ($sizes as $image_size) {
428
-                $image_size = trim($image_size);
429
-                // no big images plz
430
-                if (! in_array($image_size, ['large', 'post-thumbnail'])) {
431
-                    $image_sizes[] =
432
-                        EE_Question_Option::new_instance(['QSO_value' => $image_size, 'QSO_desc' => $image_size]);
433
-                }
434
-            }
435
-            $image_sizes[] =
436
-                EE_Question_Option::new_instance(
437
-                    ['QSO_value' => 'none', 'QSO_desc' => esc_html__('don\'t show images', 'event_espresso')]
438
-                );
439
-        }
440
-        echo EEH_Form_Fields::select(
441
-            esc_html__('Image Size:', 'event_espresso'),
442
-            $instance['image_size'],
443
-            $image_sizes,
444
-            $this->fieldName('image_size'),
445
-            $this->fieldID('image_size')
446
-        );
447
-    }
448
-
449
-
450
-    /**
451
-     * @param array $instance
452
-     * @since   4.10.14.p
453
-     */
454
-    private function parseWidgetSettings(array $instance)
455
-    {
456
-        $this->title = isset($instance['title']) && ! empty($instance['title']) ? $instance['title'] : '';
457
-        $this->events_category     = isset($instance['category_name']) && ! empty($instance['category_name'])
458
-            ? $instance['category_name']
459
-            : false;
460
-        $this->show_expired = isset($instance['show_expired'])
461
-            ? filter_var($instance['show_expired'], FILTER_VALIDATE_BOOLEAN)
462
-            : 0;
463
-        $this->image_size   = isset($instance['image_size']) && ! empty($instance['image_size'])
464
-            ? $instance['image_size']
465
-            : 'medium';
466
-        $this->show_desc    = ! isset($instance['show_desc'])
467
-                              || filter_var($instance['show_desc'], FILTER_VALIDATE_BOOLEAN);
468
-        $this->show_dates   = ! isset($instance['show_dates'])
469
-                              || filter_var($instance['show_dates'], FILTER_VALIDATE_BOOLEAN);
470
-        $this->date_limit   = isset($instance['date_limit']) && ! empty($instance['date_limit'])
471
-            ? $instance['date_limit']
472
-            : null;
473
-        $this->date_range   = isset($instance['date_range']) && ! empty($instance['date_range'])
474
-            ? $instance['date_range']
475
-            : false;
476
-        $this->limit        = isset($instance['limit']) ? absint($instance['limit']) : 10;
477
-        $this->order        = isset($instance['sort']) && $instance['sort'] === 'DESC'
478
-            ? 'DESC'
479
-            : 'ASC';
480
-    }
481
-
482
-
483
-    /**
484
-     * @return mixed|void
485
-     * @since   4.10.14.p
486
-     */
487
-    private function widgetTitle()
488
-    {
489
-        // add function to make the title a link
490
-        add_filter('widget_title', [$this, 'make_the_title_a_link'], 15);
491
-        // filter the title
492
-        $title = apply_filters('widget_title', $this->title);
493
-        // remove the function from the filter, so it does not affect other widgets
494
-        remove_filter('widget_title', [$this, 'make_the_title_a_link'], 15);
495
-        return $title;
496
-    }
497
-
498
-
499
-    /**
500
-     * @param WP_Post $post
501
-     * @return string
502
-     * @throws EE_Error
503
-     * @throws ReflectionException
504
-     * @since   4.10.14.p
505
-     */
506
-    private function widgetContent(WP_Post $post)
507
-    {
508
-        // run the query
509
-        $events = $this->getUpcomingEvents();
510
-        if (empty($events)) {
511
-            return '';
512
-        }
513
-        $list_items = '';
514
-        foreach ($events as $event) {
515
-            if ($event instanceof EE_Event && (! is_single() || $post->ID != $event->ID())) {
516
-                $event_url = $this->eventUrl($event);
517
-                $list_items .= '
264
+	}
265
+
266
+
267
+	/**
268
+	 * Sanitize widget form values as they are saved.
269
+	 *
270
+	 * @param array $new_instance Values just sent to be saved.
271
+	 * @param array $old_instance Previously saved values from database.
272
+	 *
273
+	 * @return array Updated safe values to be saved.
274
+	 * @see WP_Widget::update()
275
+	 *
276
+	 */
277
+	public function update($new_instance, $old_instance)
278
+	{
279
+		$instance                    = $old_instance;
280
+		$instance['title']           = ! empty($new_instance['title']) ? strip_tags($new_instance['title']) : '';
281
+		$instance['category_name']   = $new_instance['category_name'];
282
+		$instance['show_expired']    = $new_instance['show_expired'];
283
+		$instance['limit']           = $new_instance['limit'];
284
+		$instance['sort']            = $new_instance['sort'];
285
+		$instance['image_size']      = $new_instance['image_size'];
286
+		$instance['show_desc']       = $new_instance['show_desc'];
287
+		$instance['show_dates']      = $new_instance['show_dates'];
288
+		$instance['show_everywhere'] = $new_instance['show_everywhere'];
289
+		$instance['date_limit']      = $new_instance['date_limit'];
290
+		$instance['date_range']      = $new_instance['date_range'];
291
+		return $instance;
292
+	}
293
+
294
+
295
+	/**
296
+	 * Front-end display of widget.
297
+	 *
298
+	 * @param array $args     Widget arguments.
299
+	 * @param array $instance Saved values from database.
300
+	 * @throws EE_Error
301
+	 * @throws ReflectionException
302
+	 * @see WP_Widget::widget()
303
+	 *
304
+	 */
305
+	public function widget($args, $instance)
306
+	{
307
+
308
+		global $post;
309
+		// make sure there is some kinda post object
310
+		if ($post instanceof WP_Post) {
311
+			$before_widget = '';
312
+			$before_title  = '';
313
+			$after_title   = '';
314
+			$after_widget  = '';
315
+			// but NOT an events archives page, cuz that would be like two event lists on the same page
316
+			$show_everywhere = ! isset($instance['show_everywhere']) || absint($instance['show_everywhere']);
317
+			if ($show_everywhere || ! ($post->post_type == 'espresso_events' && is_archive())) {
318
+				// let's use some of the event helper functions'
319
+				// make separate vars out of attributes
320
+				extract($args);
321
+
322
+				// grab widget settings
323
+				$this->parseWidgetSettings($instance);
324
+				$title = $this->widgetTitle();
325
+
326
+				// Before widget (defined by themes).
327
+				echo $before_widget;
328
+				// Display the widget title if one was input (before and after defined by themes).
329
+				if (! empty($title)) {
330
+					echo $before_title . $title . $after_title;
331
+				}
332
+				echo $this->widgetContent($post);
333
+				// After widget (defined by themes).
334
+				echo $after_widget;
335
+			}
336
+		}
337
+	}
338
+
339
+
340
+	/**
341
+	 * make_the_title_a_link
342
+	 * callback for widget_title filter
343
+	 *
344
+	 * @param $title
345
+	 * @return string
346
+	 */
347
+	public function make_the_title_a_link($title)
348
+	{
349
+		return '<a href="' . EEH_Event_View::event_archive_url() . '">' . $title . '</a>';
350
+	}
351
+
352
+
353
+	/**
354
+	 * @param string $field_name
355
+	 * @return string
356
+	 * @since   4.10.14.p
357
+	 */
358
+	public function fieldID($field_name)
359
+	{
360
+		return parent::get_field_id($field_name);
361
+	}
362
+
363
+
364
+	/**
365
+	 * @param string $field_name
366
+	 * @return string
367
+	 * @since   4.10.14.p
368
+	 */
369
+	public function fieldName($field_name)
370
+	{
371
+		return parent::get_field_name($field_name);
372
+	}
373
+
374
+
375
+	/**
376
+	 * @param array $instance
377
+	 * @throws EE_Error
378
+	 * @throws ReflectionException
379
+	 * @since   4.10.14.p
380
+	 */
381
+	private function eventCategoriesSelector(array $instance)
382
+	{
383
+		$event_categories = [];
384
+		$categories       = EEM_Term::instance()->get_all_ee_categories(true);
385
+		if ($categories) {
386
+			foreach ($categories as $category) {
387
+				if ($category instanceof EE_Term) {
388
+					$event_categories[] =
389
+						EE_Question_Option::new_instance(
390
+							[
391
+								'QSO_value' => $category->get('slug'),
392
+								'QSO_desc'  => $category->get('name'),
393
+							]
394
+						);
395
+				}
396
+			}
397
+		}
398
+		array_unshift(
399
+			$event_categories,
400
+			EE_Question_Option::new_instance(
401
+				[
402
+					'QSO_value' => '',
403
+					'QSO_desc'  => esc_html__(' - display all - ', 'event_espresso'),
404
+				]
405
+			)
406
+		);
407
+		echo EEH_Form_Fields::select(
408
+			esc_html__('Event Category:', 'event_espresso'),
409
+			$instance['category_name'],
410
+			$event_categories,
411
+			$this->fieldName('category_name'),
412
+			$this->fieldID('category_name')
413
+		);
414
+	}
415
+
416
+
417
+	/**
418
+	 * @param array $instance
419
+	 * @since   4.10.14.p
420
+	 */
421
+	private function imageSizeSelector(array $instance)
422
+	{
423
+		$image_sizes = [];
424
+		$sizes       = get_intermediate_image_sizes();
425
+		if ($sizes) {
426
+			// loop thru images and create option objects out of them
427
+			foreach ($sizes as $image_size) {
428
+				$image_size = trim($image_size);
429
+				// no big images plz
430
+				if (! in_array($image_size, ['large', 'post-thumbnail'])) {
431
+					$image_sizes[] =
432
+						EE_Question_Option::new_instance(['QSO_value' => $image_size, 'QSO_desc' => $image_size]);
433
+				}
434
+			}
435
+			$image_sizes[] =
436
+				EE_Question_Option::new_instance(
437
+					['QSO_value' => 'none', 'QSO_desc' => esc_html__('don\'t show images', 'event_espresso')]
438
+				);
439
+		}
440
+		echo EEH_Form_Fields::select(
441
+			esc_html__('Image Size:', 'event_espresso'),
442
+			$instance['image_size'],
443
+			$image_sizes,
444
+			$this->fieldName('image_size'),
445
+			$this->fieldID('image_size')
446
+		);
447
+	}
448
+
449
+
450
+	/**
451
+	 * @param array $instance
452
+	 * @since   4.10.14.p
453
+	 */
454
+	private function parseWidgetSettings(array $instance)
455
+	{
456
+		$this->title = isset($instance['title']) && ! empty($instance['title']) ? $instance['title'] : '';
457
+		$this->events_category     = isset($instance['category_name']) && ! empty($instance['category_name'])
458
+			? $instance['category_name']
459
+			: false;
460
+		$this->show_expired = isset($instance['show_expired'])
461
+			? filter_var($instance['show_expired'], FILTER_VALIDATE_BOOLEAN)
462
+			: 0;
463
+		$this->image_size   = isset($instance['image_size']) && ! empty($instance['image_size'])
464
+			? $instance['image_size']
465
+			: 'medium';
466
+		$this->show_desc    = ! isset($instance['show_desc'])
467
+							  || filter_var($instance['show_desc'], FILTER_VALIDATE_BOOLEAN);
468
+		$this->show_dates   = ! isset($instance['show_dates'])
469
+							  || filter_var($instance['show_dates'], FILTER_VALIDATE_BOOLEAN);
470
+		$this->date_limit   = isset($instance['date_limit']) && ! empty($instance['date_limit'])
471
+			? $instance['date_limit']
472
+			: null;
473
+		$this->date_range   = isset($instance['date_range']) && ! empty($instance['date_range'])
474
+			? $instance['date_range']
475
+			: false;
476
+		$this->limit        = isset($instance['limit']) ? absint($instance['limit']) : 10;
477
+		$this->order        = isset($instance['sort']) && $instance['sort'] === 'DESC'
478
+			? 'DESC'
479
+			: 'ASC';
480
+	}
481
+
482
+
483
+	/**
484
+	 * @return mixed|void
485
+	 * @since   4.10.14.p
486
+	 */
487
+	private function widgetTitle()
488
+	{
489
+		// add function to make the title a link
490
+		add_filter('widget_title', [$this, 'make_the_title_a_link'], 15);
491
+		// filter the title
492
+		$title = apply_filters('widget_title', $this->title);
493
+		// remove the function from the filter, so it does not affect other widgets
494
+		remove_filter('widget_title', [$this, 'make_the_title_a_link'], 15);
495
+		return $title;
496
+	}
497
+
498
+
499
+	/**
500
+	 * @param WP_Post $post
501
+	 * @return string
502
+	 * @throws EE_Error
503
+	 * @throws ReflectionException
504
+	 * @since   4.10.14.p
505
+	 */
506
+	private function widgetContent(WP_Post $post)
507
+	{
508
+		// run the query
509
+		$events = $this->getUpcomingEvents();
510
+		if (empty($events)) {
511
+			return '';
512
+		}
513
+		$list_items = '';
514
+		foreach ($events as $event) {
515
+			if ($event instanceof EE_Event && (! is_single() || $post->ID != $event->ID())) {
516
+				$event_url = $this->eventUrl($event);
517
+				$list_items .= '
518 518
                 <li id="ee-upcoming-events-widget-li-' . absint($event->ID()) . '" 
519 519
                     class="ee-upcoming-events-widget-li"
520 520
                 >
@@ -525,194 +525,194 @@  discard block
 block discarded – undo
525 525
                     </h5>
526 526
                     ' . $this->eventWidgetContent($event, $event_url) . '
527 527
                 </li>';
528
-            }
529
-        }
530
-        return '
528
+			}
529
+		}
530
+		return '
531 531
             <ul class="ee-upcoming-events-widget-ul">
532 532
                 ' . $list_items . '
533 533
             </ul>';
534
-    }
535
-
536
-
537
-    /**
538
-     * @param EE_Event $event
539
-     * @return string|null
540
-     * @throws EE_Error
541
-     * @since   4.10.14.p
542
-     */
543
-    private function eventUrl(EE_Event $event)
544
-    {
545
-        return esc_url_raw(
546
-            apply_filters(
547
-                'FHEE_EEW_Upcoming_Events__widget__event_url',
548
-                $event->get_permalink(),
549
-                $event
550
-            )
551
-        );
552
-    }
553
-
554
-
555
-    /**
556
-     * @return EE_Base_Class[]
557
-     * @throws EE_Error
558
-     */
559
-    private function getUpcomingEvents()
560
-    {
561
-        return EEM_Event::instance()->get_all(
562
-            [
563
-                $this->queryWhereParams(),
564
-                'limit'    => '0,' . $this->limit,
565
-                'order_by' => 'Datetime.DTT_EVT_start',
566
-                'order'    => $this->order,
567
-                'group_by' => 'EVT_ID',
568
-            ]
569
-        );
570
-    }
571
-
572
-
573
-    /**
574
-     * @return mixed|void
575
-     * @throws EE_Error
576
-     * @since   4.10.14.p
577
-     */
578
-    private function queryWhereParams()
579
-    {
580
-        // start to build our where clause
581
-        $where = [
582
-            'status' => ['IN', ['publish', 'sold_out']],
583
-        ];
584
-        // add category
585
-        if ($this->events_category) {
586
-            $where['Term_Taxonomy.taxonomy']  = 'espresso_event_categories';
587
-            $where['Term_Taxonomy.Term.slug'] = $this->events_category;
588
-        }
589
-        // if NOT expired then we want events that start today or in the future
590
-        // if NOT show expired then we want events that start today or in the future
591
-        if ($this->show_expired == 0) {
592
-            $where['Datetime.DTT_EVT_end'] = [
593
-                '>=',
594
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
595
-            ];
596
-        }
597
-        // if show ONLY expired we want events that ended prior to today
598
-        if ($this->show_expired == 2) {
599
-            $where['Datetime.DTT_EVT_end'] = [
600
-                '<=',
601
-                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
602
-            ];
603
-        }
604
-        // allow $where to be filtered
605
-        return apply_filters('FHEE__EEW_Upcoming_Events__widget__where', $where, $this->events_category, $this->show_expired);
606
-    }
607
-
608
-
609
-    /**
610
-     * @param EE_Event $event
611
-     * @return string
612
-     * @throws EE_Error
613
-     * @throws ReflectionException
614
-     * @since   4.10.14.p
615
-     */
616
-    private function linkClass(EE_Event $event)
617
-    {
618
-        // how big is the event name ?
619
-        $name_length = strlen($event->name());
620
-        switch ($name_length) {
621
-            case $name_length > 70:
622
-                return ' three-line';
623
-            case $name_length > 35:
624
-                return ' two-line';
625
-        }
626
-        return ' one-line';
627
-    }
628
-
629
-
630
-    /**
631
-     * @param EE_Event $event
632
-     * @param string   $event_url
633
-     * @return mixed|string|void
634
-     * @throws EE_Error
635
-     * @throws ReflectionException
636
-     * @since   4.10.14.p
637
-     */
638
-    private function eventWidgetContent(EE_Event $event, $event_url = '')
639
-    {
640
-        if (post_password_required($event->ID())) {
641
-            return apply_filters(
642
-                'FHEE_EEW_Upcoming_Events__widget__password_form',
643
-                get_the_password_form($event->ID()),
644
-                $event
645
-            );
646
-        }
647
-
648
-        $content = '';
649
-        if (has_post_thumbnail($event->ID()) && $this->image_size != 'none') {
650
-            $content .= '
534
+	}
535
+
536
+
537
+	/**
538
+	 * @param EE_Event $event
539
+	 * @return string|null
540
+	 * @throws EE_Error
541
+	 * @since   4.10.14.p
542
+	 */
543
+	private function eventUrl(EE_Event $event)
544
+	{
545
+		return esc_url_raw(
546
+			apply_filters(
547
+				'FHEE_EEW_Upcoming_Events__widget__event_url',
548
+				$event->get_permalink(),
549
+				$event
550
+			)
551
+		);
552
+	}
553
+
554
+
555
+	/**
556
+	 * @return EE_Base_Class[]
557
+	 * @throws EE_Error
558
+	 */
559
+	private function getUpcomingEvents()
560
+	{
561
+		return EEM_Event::instance()->get_all(
562
+			[
563
+				$this->queryWhereParams(),
564
+				'limit'    => '0,' . $this->limit,
565
+				'order_by' => 'Datetime.DTT_EVT_start',
566
+				'order'    => $this->order,
567
+				'group_by' => 'EVT_ID',
568
+			]
569
+		);
570
+	}
571
+
572
+
573
+	/**
574
+	 * @return mixed|void
575
+	 * @throws EE_Error
576
+	 * @since   4.10.14.p
577
+	 */
578
+	private function queryWhereParams()
579
+	{
580
+		// start to build our where clause
581
+		$where = [
582
+			'status' => ['IN', ['publish', 'sold_out']],
583
+		];
584
+		// add category
585
+		if ($this->events_category) {
586
+			$where['Term_Taxonomy.taxonomy']  = 'espresso_event_categories';
587
+			$where['Term_Taxonomy.Term.slug'] = $this->events_category;
588
+		}
589
+		// if NOT expired then we want events that start today or in the future
590
+		// if NOT show expired then we want events that start today or in the future
591
+		if ($this->show_expired == 0) {
592
+			$where['Datetime.DTT_EVT_end'] = [
593
+				'>=',
594
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
595
+			];
596
+		}
597
+		// if show ONLY expired we want events that ended prior to today
598
+		if ($this->show_expired == 2) {
599
+			$where['Datetime.DTT_EVT_end'] = [
600
+				'<=',
601
+				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
602
+			];
603
+		}
604
+		// allow $where to be filtered
605
+		return apply_filters('FHEE__EEW_Upcoming_Events__widget__where', $where, $this->events_category, $this->show_expired);
606
+	}
607
+
608
+
609
+	/**
610
+	 * @param EE_Event $event
611
+	 * @return string
612
+	 * @throws EE_Error
613
+	 * @throws ReflectionException
614
+	 * @since   4.10.14.p
615
+	 */
616
+	private function linkClass(EE_Event $event)
617
+	{
618
+		// how big is the event name ?
619
+		$name_length = strlen($event->name());
620
+		switch ($name_length) {
621
+			case $name_length > 70:
622
+				return ' three-line';
623
+			case $name_length > 35:
624
+				return ' two-line';
625
+		}
626
+		return ' one-line';
627
+	}
628
+
629
+
630
+	/**
631
+	 * @param EE_Event $event
632
+	 * @param string   $event_url
633
+	 * @return mixed|string|void
634
+	 * @throws EE_Error
635
+	 * @throws ReflectionException
636
+	 * @since   4.10.14.p
637
+	 */
638
+	private function eventWidgetContent(EE_Event $event, $event_url = '')
639
+	{
640
+		if (post_password_required($event->ID())) {
641
+			return apply_filters(
642
+				'FHEE_EEW_Upcoming_Events__widget__password_form',
643
+				get_the_password_form($event->ID()),
644
+				$event
645
+			);
646
+		}
647
+
648
+		$content = '';
649
+		if (has_post_thumbnail($event->ID()) && $this->image_size != 'none') {
650
+			$content .= '
651 651
                 <div class="ee-upcoming-events-widget-img-dv">
652 652
                     <a class="ee-upcoming-events-widget-img" href="' . $event_url . '">
653 653
                         ' . get_the_post_thumbnail($event->ID(), $this->image_size) . '
654 654
                     </a>
655 655
                 </div>';
656
-        }
657
-
658
-        if ($this->show_dates) {
659
-            $content .= $this->eventDates($event);
660
-        }
661
-
662
-        if ($this->show_desc) {
663
-            global $allowedtags;
664
-            $desc    = $event->short_description(25);
665
-            $content .= $desc ? '<p style="margin-top: .5em">' . wp_kses($desc, $allowedtags) . '</p>' : '';
666
-        }
667
-
668
-        return $content;
669
-    }
670
-
671
-
672
-    /**
673
-     * @param EE_Event $event
674
-     * @return string
675
-     * @throws EE_Error
676
-     * @throws ReflectionException
677
-     * @since   4.10.14.p
678
-     */
679
-    private function eventDates(EE_Event $event)
680
-    {
681
-        $date_format        = apply_filters(
682
-            'FHEE__espresso_event_date_range__date_format',
683
-            get_option('date_format')
684
-        );
685
-        $time_format        = apply_filters(
686
-            'FHEE__espresso_event_date_range__time_format',
687
-            get_option('time_format')
688
-        );
689
-        $single_date_format = apply_filters(
690
-            'FHEE__espresso_event_date_range__single_date_format',
691
-            get_option('date_format')
692
-        );
693
-        $single_time_format = apply_filters(
694
-            'FHEE__espresso_event_date_range__single_time_format',
695
-            get_option('time_format')
696
-        );
697
-        if ($this->date_range == true) {
698
-            return espresso_event_date_range(
699
-                $date_format,
700
-                $time_format,
701
-                $single_date_format,
702
-                $single_time_format,
703
-                $event->ID(),
704
-                false
705
-            );
706
-        }
707
-        return espresso_list_of_event_dates(
708
-            $event->ID(),
709
-            $date_format,
710
-            $time_format,
711
-            false,
712
-            null,
713
-            true,
714
-            true,
715
-            $this->date_limit
716
-        );
717
-    }
656
+		}
657
+
658
+		if ($this->show_dates) {
659
+			$content .= $this->eventDates($event);
660
+		}
661
+
662
+		if ($this->show_desc) {
663
+			global $allowedtags;
664
+			$desc    = $event->short_description(25);
665
+			$content .= $desc ? '<p style="margin-top: .5em">' . wp_kses($desc, $allowedtags) . '</p>' : '';
666
+		}
667
+
668
+		return $content;
669
+	}
670
+
671
+
672
+	/**
673
+	 * @param EE_Event $event
674
+	 * @return string
675
+	 * @throws EE_Error
676
+	 * @throws ReflectionException
677
+	 * @since   4.10.14.p
678
+	 */
679
+	private function eventDates(EE_Event $event)
680
+	{
681
+		$date_format        = apply_filters(
682
+			'FHEE__espresso_event_date_range__date_format',
683
+			get_option('date_format')
684
+		);
685
+		$time_format        = apply_filters(
686
+			'FHEE__espresso_event_date_range__time_format',
687
+			get_option('time_format')
688
+		);
689
+		$single_date_format = apply_filters(
690
+			'FHEE__espresso_event_date_range__single_date_format',
691
+			get_option('date_format')
692
+		);
693
+		$single_time_format = apply_filters(
694
+			'FHEE__espresso_event_date_range__single_time_format',
695
+			get_option('time_format')
696
+		);
697
+		if ($this->date_range == true) {
698
+			return espresso_event_date_range(
699
+				$date_format,
700
+				$time_format,
701
+				$single_date_format,
702
+				$single_time_format,
703
+				$event->ID(),
704
+				false
705
+			);
706
+		}
707
+		return espresso_list_of_event_dates(
708
+			$event->ID(),
709
+			$date_format,
710
+			$time_format,
711
+			false,
712
+			null,
713
+			true,
714
+			true,
715
+			$this->date_limit
716
+		);
717
+	}
718 718
 }
Please login to merge, or discard this patch.
pricing/templates/event_tickets_datetime_attached_tickets_row.template.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -23,10 +23,10 @@  discard block
 block discarded – undo
23 23
                           placeholder="Datetime Description (optional)"><?php echo esc_textarea($DTT_description); ?></textarea>
24 24
             </div>
25 25
             <?php do_action(
26
-                'AHEE__event_tickets_datetime_attached_tickets_row_template__advanced_details_after_dtt_description',
27
-                $dtt_row,
28
-                $DTT_ID
29
-            ); ?>
26
+				'AHEE__event_tickets_datetime_attached_tickets_row_template__advanced_details_after_dtt_description',
27
+				$dtt_row,
28
+				$DTT_ID
29
+			); ?>
30 30
             <h4 class="datetime-tickets-heading"><?php esc_html_e('Assigned Tickets', 'event_espresso'); ?></h4>
31 31
 
32 32
             <ul class="datetime-tickets-list">
@@ -36,28 +36,28 @@  discard block
 block discarded – undo
36 36
 
37 37
             <div class="add-datetime-ticket-container">
38 38
                 <h4 class="datetime-tickets-heading"><?php
39
-                    esc_html_e(
40
-                        'Add New Ticket',
41
-                        'event_espresso'
42
-                    ); ?></h4><?php echo $add_new_datetime_ticket_help_link; ?><br>
39
+					esc_html_e(
40
+						'Add New Ticket',
41
+						'event_espresso'
42
+					); ?></h4><?php echo $add_new_datetime_ticket_help_link; ?><br>
43 43
                 <table class="add-new-ticket-table">
44 44
                     <thead>
45 45
                     <tr valign="top">
46 46
                         <td><span class="ANT_TKT_name_label"><?php
47
-                                esc_html_e(
48
-                                    'Ticket Name',
49
-                                    'event_espresso'
50
-                                ); ?></span></td>
47
+								esc_html_e(
48
+									'Ticket Name',
49
+									'event_espresso'
50
+								); ?></span></td>
51 51
                         <td><span class="ANT_TKT_goes_on_sale_label"><?php
52
-                                esc_html_e(
53
-                                    'Sale Starts',
54
-                                    'event_espresso'
55
-                                ); ?></span></td>
52
+								esc_html_e(
53
+									'Sale Starts',
54
+									'event_espresso'
55
+								); ?></span></td>
56 56
                         <td><span class="ANT_TKT_sell_until_label"><?php
57
-                                esc_html_e(
58
-                                    'Sell Until',
59
-                                    'event_espresso'
60
-                                ); ?></span></td>
57
+								esc_html_e(
58
+									'Sell Until',
59
+									'event_espresso'
60
+								); ?></span></td>
61 61
                         <td><span class="ANT_TKT_price_label"><?php esc_html_e('Price', 'event_espresso'); ?></span>
62 62
                         </td>
63 63
                         <td><span class="ANT_TKT_qty_label"><?php esc_html_e('Qty', 'event_espresso'); ?></span></td>
@@ -107,12 +107,12 @@  discard block
 block discarded – undo
107 107
                 <div class="ee-editor-footer-container">
108 108
                     <div class="ee-editor-id-container">
109 109
                         <span class="ee-item-id"><?php
110
-                            echo $DTT_ID
111
-                                ? sprintf(
112
-                                    esc_html__('Datetime ID: %d', 'event_espresso'),
113
-                                    $DTT_ID
114
-                                )
115
-                                : ''; ?></span>
110
+							echo $DTT_ID
111
+								? sprintf(
112
+									esc_html__('Datetime ID: %d', 'event_espresso'),
113
+									$DTT_ID
114
+								)
115
+								: ''; ?></span>
116 116
                     </div>
117 117
                     <div class="save-cancel-button-container">
118 118
                         <button data-context="short-ticket" data-datetime-row="<?php echo absint($dtt_row); ?>"
Please login to merge, or discard this patch.
new/pricing/templates/event_tickets_datetime_ticket_price_row.template.php 1 patch
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -61,9 +61,12 @@  discard block
 block discarded – undo
61 61
             <input type="text" size="1" class="edit-price-PRC_amount ee-numeric"
62 62
                    name="prices_archive[<?php echo absint($tkt_row); ?>][<?php echo absint($PRC_order); ?>][PRC_amount]"
63 63
                    value="<?php echo esc_attr($PRC_amount); ?>" disabled>
64
-        <?php else : ?>
64
+        <?php else {
65
+	: ?>
65 66
             <input type="text" size="1" class="edit-price-PRC_amount ee-numeric"
66
-                   name="<?php echo esc_attr($edit_prices_name); ?>[<?php echo absint($tkt_row); ?>][<?php echo absint($PRC_order); ?>][PRC_amount]"
67
+                   name="<?php echo esc_attr($edit_prices_name);
68
+}
69
+?>[<?php echo absint($tkt_row); ?>][<?php echo absint($PRC_order); ?>][PRC_amount]"
67 70
                    value="<?php echo esc_attr($PRC_amount); ?>">
68 71
         <?php endif; ?>
69 72
     </td>
@@ -74,8 +77,11 @@  discard block
 block discarded – undo
74 77
     <td>
75 78
         <?php if ($disabled) : ?>
76 79
             <span class="ee-lock-icon"></span>
77
-        <?php else : ?>
78
-            <!-- <span class="gear-icon dashicons dashicons-admin-generic clickable" data-ticket-row="<?php echo absint($tkt_row); ?>" data-context="price" data-price-row="<?php echo absint($PRC_order); ?>"></span> -->
80
+        <?php else {
81
+	: ?>
82
+            <!-- <span class="gear-icon dashicons dashicons-admin-generic clickable" data-ticket-row="<?php echo absint($tkt_row);
83
+}
84
+?>" data-context="price" data-price-row="<?php echo absint($PRC_order); ?>"></span> -->
79 85
             <span class="trash-icon dashicons dashicons-post-trash clickable" data-ticket-row="<?php echo absint($tkt_row); ?>"
80 86
                   data-context="price" data-price-row="<?php echo absint($PRC_order); ?>"<?php echo $show_trash_icon; ?>></span>
81 87
             <button data-ticket-row="<?php echo absint($tkt_row); ?>" data-price-row="<?php echo absint($PRC_order); ?>"
Please login to merge, or discard this patch.
new/pricing/templates/event_tickets_datetime_dtt_tickets_list.template.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
 
15 15
 <li data-datetime-row="<?php echo absint($dtt_row); ?>" data-context="datetime-ticket" data-ticket-row="<?php echo absint($tkt_row); ?>"
16 16
     class="datetime-ticket clickable<?php echo $ticket_selected;
17
-    echo $tkt_status_class; ?>">
17
+	echo $tkt_status_class; ?>">
18 18
     <input type="checkbox" name="datetime_ticket[<?php echo absint($dtt_row); ?>][<?php echo absint($tkt_row); ?>]"
19 19
            class="datetime-ticket-checkbox" value="1"<?php echo $datetime_ticket_checked; ?>>
20 20
     <span class="ee-icon ee-icon-tickets ticket-list-ticket-name"><?php echo $TKT_name; ?></span>
Please login to merge, or discard this patch.
admin/new/pricing/templates/event_tickets_datetime_ticket_row.template.php 3 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 
169 169
             <!--<div class="total-price-container"><?php printf(
170 170
                 esc_html__('Total Final Price: %s', 'event_espresso'),
171
-                '<span class="ticket-price-amount">' . $TKT_price . '</span>'
171
+                '<span class="ticket-price-amount">'.$TKT_price.'</span>'
172 172
             ); ?> </div>-->
173 173
             <textarea name="<?php echo esc_attr($edit_tickets_name); ?>[<?php echo absint($tkt_row); ?>][TKT_description]"
174 174
                       class="edit-ticket-TKT_description ee-full-textarea-inp"
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
                         ); ?></label>
268 268
                 </div>
269 269
                 <div class="ticket-is-taxable-container">
270
-                    <?php if (! empty($tax_rows)) { ?>
270
+                    <?php if ( ! empty($tax_rows)) { ?>
271 271
                         <?php if ($disabled) : ?>
272 272
                             <?php
273 273
                             $tax_value = ! empty($TKT_taxable) ? 1 : 0;
Please login to merge, or discard this patch.
Braces   +40 added lines, -16 removed lines patch added patch discarded remove patch
@@ -79,8 +79,11 @@  discard block
 block discarded – undo
79 79
                    class="edit-ticket-TKT_start_date ee-text-inp" value="<?php echo esc_attr($TKT_start_date); ?>">
80 80
             <input type="text" name="archived_ticket[TKT_start_date]" class="edit-ticket-TKT_start_date ee-text-inp"
81 81
                    value="<?php echo esc_attr($TKT_start_date); ?>" disabled>
82
-        <?php else : ?>
83
-            <input id="edit-ticket-TKT_start_date-<?php echo absint($tkt_row); ?>" type="text"
82
+        <?php else {
83
+	: ?>
84
+            <input id="edit-ticket-TKT_start_date-<?php echo absint($tkt_row);
85
+}
86
+?>" type="text"
84 87
                    name="<?php echo esc_attr($edit_tickets_name); ?>[<?php echo absint($tkt_row); ?>][TKT_start_date]"
85 88
                    class="edit-ticket-TKT_start_date ee-text-inp ee-datepicker" value="<?php echo esc_attr($TKT_start_date); ?>"
86 89
                    data-context="start-ticket" data-date-field-context="#display-ticketrow-<?php echo absint($tkt_row); ?>"
@@ -94,8 +97,11 @@  discard block
 block discarded – undo
94 97
                    class="edit-ticket-TKT_end_date ee-text-inp" value="<?php echo esc_attr($TKT_end_date); ?>">
95 98
             <input type="text" name="archived_ticket[TKT_end_date]" class="edit-ticket-TKT_end_date ee-text-inp"
96 99
                    value="<?php echo esc_attr($TKT_end_date); ?>" disabled>
97
-        <?php else : ?>
98
-            <input id="edit-ticket-TKT_end_date-<?php echo absint($tkt_row); ?>" type="text"
100
+        <?php else {
101
+	: ?>
102
+            <input id="edit-ticket-TKT_end_date-<?php echo absint($tkt_row);
103
+}
104
+?>" type="text"
99 105
                    name="<?php echo esc_attr($edit_tickets_name); ?>[<?php echo absint($tkt_row); ?>][TKT_end_date]"
100 106
                    class="edit-ticket-TKT_end_date ee-text-inp ee-datepicker" value="<?php echo esc_attr($TKT_end_date); ?>"
101 107
                    data-context="end-ticket" data-date-field-context="#display-ticketrow-<?php echo absint($tkt_row); ?>"
@@ -111,8 +117,11 @@  discard block
 block discarded – undo
111 117
             <input type="text" name="archived_ticket[<?php echo absint($tkt_row); ?>][TKT_base_price]"
112 118
                    class="edit-ticket-TKT_base_price ee-small-text-inp edit-price-PRC_amount ee-numeric"
113 119
                    value="<?php echo esc_attr($TKT_base_price); ?>" disabled>
114
-        <?php else : ?>
115
-            <input id="edit-ticket-TKT_base_price-<?php echo absint($tkt_row); ?>" type="text"
120
+        <?php else {
121
+	: ?>
122
+            <input id="edit-ticket-TKT_base_price-<?php echo absint($tkt_row);
123
+}
124
+?>" type="text"
116 125
                    name="<?php echo esc_attr($edit_tickets_name); ?>[<?php echo absint($tkt_row); ?>][TKT_base_price]"
117 126
                    class="edit-ticket-TKT_base_price ee-small-text-inp edit-price-PRC_amount ee-numeric"
118 127
                    value="<?php echo esc_attr($TKT_base_price); ?>">
@@ -129,8 +138,11 @@  discard block
 block discarded – undo
129 138
             <input type="text" class="edit-ticket-TKT_qty ee-small-text-inp ee-numeric"
130 139
                    name="archived_ticket[<?php echo absint($tkt_row); ?>][TKT_qty]" value="<?php echo esc_attr($TKT_qty_for_input); ?>"
131 140
                    disabled>
132
-        <?php else : ?>
133
-            <input type="text" id="edit-ticket-TKT_qty-<?php echo absint($tkt_row); ?>"
141
+        <?php else {
142
+	: ?>
143
+            <input type="text" id="edit-ticket-TKT_qty-<?php echo absint($tkt_row);
144
+}
145
+?>"
134 146
                    class="edit-ticket-TKT_qty ee-small-text-inp ee-numeric"
135 147
                    name="<?php echo esc_attr($edit_tickets_name); ?>[<?php echo absint($tkt_row); ?>][TKT_qty]"
136 148
                    value="<?php echo esc_attr($TKT_qty_for_input); ?>">
@@ -209,9 +221,12 @@  discard block
 block discarded – undo
209 221
                                 <input type="text" class="edit-ticket-TKT_uses ee-small-text-inp ee-numeric"
210 222
                                        name="archived_ticket[<?php echo absint($tkt_row); ?>][TKT_uses]"
211 223
                                        value="<?php echo esc_attr($TKT_uses); ?>" disabled>
212
-                            <?php else : ?>
224
+                            <?php else {
225
+	: ?>
213 226
                                 <input type="text" class="edit-ticket-TKT_uses ee-small-text-inp ee-numeric"
214
-                                       name="<?php echo esc_attr($edit_tickets_name); ?>[<?php echo absint($tkt_row); ?>][TKT_uses]"
227
+                                       name="<?php echo esc_attr($edit_tickets_name);
228
+}
229
+?>[<?php echo absint($tkt_row); ?>][TKT_uses]"
215 230
                                        value="<?php echo esc_attr($TKT_uses); ?>">
216 231
                             <?php endif; ?>
217 232
                         </td>
@@ -223,9 +238,12 @@  discard block
 block discarded – undo
223 238
                                 <input type="text" class="edit-ticket-TKT_min ee-small-text-inp ee-numeric"
224 239
                                        name="archived_ticket[<?php echo absint($tkt_row); ?>][TKT_min]"
225 240
                                        value="<?php echo esc_attr($TKT_min); ?>" disabled>
226
-                            <?php else : ?>
241
+                            <?php else {
242
+	: ?>
227 243
                                 <input type="text" class="edit-ticket-TKT_min ee-small-text-inp ee-numeric"
228
-                                       name="<?php echo esc_attr($edit_tickets_name); ?>[<?php echo absint($tkt_row); ?>][TKT_min]"
244
+                                       name="<?php echo esc_attr($edit_tickets_name);
245
+}
246
+?>[<?php echo absint($tkt_row); ?>][TKT_min]"
229 247
                                        value="<?php echo esc_attr($TKT_min); ?>">
230 248
                             <?php endif; ?>
231 249
                         </td>
@@ -237,9 +255,12 @@  discard block
 block discarded – undo
237 255
                                 <input type="text" class="edit-ticket-TKT_max ee-small-text-inp ee-numeric"
238 256
                                        name="<?php echo esc_attr($edit_tickets_name); ?>[<?php echo absint($tkt_row); ?>][TKT_max]"
239 257
                                        value="<?php echo esc_attr($TKT_max); ?>" disabled>
240
-                            <?php else : ?>
258
+                            <?php else {
259
+	: ?>
241 260
                                 <input type="text" class="edit-ticket-TKT_max ee-small-text-inp ee-numeric"
242
-                                       name="<?php echo esc_attr($edit_tickets_name); ?>[<?php echo absint($tkt_row); ?>][TKT_max]"
261
+                                       name="<?php echo esc_attr($edit_tickets_name);
262
+}
263
+?>[<?php echo absint($tkt_row); ?>][TKT_max]"
243 264
                                        value="<?php echo esc_attr($TKT_max); ?>">
244 265
                             <?php endif; ?>
245 266
                         </td>
@@ -278,8 +299,11 @@  discard block
 block discarded – undo
278 299
                         <input class="TKT-taxable-checkbox" id="edit-ticket-TKT_taxable-<?php echo absint($tkt_row); ?>"
279 300
                                type="checkbox" name="archived_ticket[<?php echo absint($tkt_row); ?>][TKT_taxable]"
280 301
                                value="1"<?php echo $TKT_taxable; ?> disabled>
281
-                        <?php else : ?>
282
-                        <input class="TKT-taxable-checkbox" id="edit-ticket-TKT_taxable-<?php echo absint($tkt_row); ?>"
302
+                        <?php else {
303
+	: ?>
304
+                        <input class="TKT-taxable-checkbox" id="edit-ticket-TKT_taxable-<?php echo absint($tkt_row);
305
+}
306
+?>"
283 307
                                type="checkbox"
284 308
                                name="<?php echo esc_attr($edit_tickets_name); ?>[<?php echo absint($tkt_row); ?>][TKT_taxable]"
285 309
                                value="1"<?php echo $TKT_taxable; ?>>
Please login to merge, or discard this patch.
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 ?>
59 59
 <tr valign="top" class="ee-ticket-sortable ticket-row <?php echo sanitize_html_class($ticket_archive_class);
60 60
 if (WP_DEBUG) {
61
-    echo ' ee-wp-debug';
61
+	echo ' ee-wp-debug';
62 62
 } ?>" id="display-ticketrow-<?php echo absint($tkt_row); ?>">
63 63
     <!--<td class="ee-tkt-order-field"><span class="dashicons dashicons-sort <?php echo sanitize_html_class($tkt_status_class); ?>">
64 64
     <input type="hidden" name="<?php echo esc_attr($edit_tickets_name); ?>[<?php echo absint($tkt_row); ?>][TKT_order]" class="edit-ticket-TKT_order" value ="<?php echo absint($TKT_order); ?>" ></span></td>-->
@@ -167,9 +167,9 @@  discard block
 block discarded – undo
167 167
                    class="edit-ticket-TKT_row" value="<?php echo absint($tkt_row); ?>">
168 168
 
169 169
             <!--<div class="total-price-container"><?php printf(
170
-                esc_html__('Total Final Price: %s', 'event_espresso'),
171
-                '<span class="ticket-price-amount">' . $TKT_price . '</span>'
172
-            ); ?> </div>-->
170
+				esc_html__('Total Final Price: %s', 'event_espresso'),
171
+				'<span class="ticket-price-amount">' . $TKT_price . '</span>'
172
+			); ?> </div>-->
173 173
             <textarea name="<?php echo esc_attr($edit_tickets_name); ?>[<?php echo absint($tkt_row); ?>][TKT_description]"
174 174
                       class="edit-ticket-TKT_description ee-full-textarea-inp"
175 175
                       placeholder="Ticket Description"><?php echo esc_textarea($TKT_description); ?></textarea>
@@ -183,20 +183,20 @@  discard block
 block discarded – undo
183 183
                     <thead>
184 184
                     <tr valign="bottom">
185 185
                         <td><span class="TD_TKT_number_datetimes_label"><?php
186
-                                esc_html_e(
187
-                                    '# Datetimes',
188
-                                    'event_espresso'
189
-                                ); ?></span></td>
186
+								esc_html_e(
187
+									'# Datetimes',
188
+									'event_espresso'
189
+								); ?></span></td>
190 190
                         <td><span class="TD_TKT_min_qty_label"><?php
191
-                                esc_html_e(
192
-                                    'Minimum Quantity',
193
-                                    'event_espresso'
194
-                                ); ?></span></td>
191
+								esc_html_e(
192
+									'Minimum Quantity',
193
+									'event_espresso'
194
+								); ?></span></td>
195 195
                         <td><span class="TD_TKT_max_qty_label"><?php
196
-                                esc_html_e(
197
-                                    'Maximum Quantity',
198
-                                    'event_espresso'
199
-                                ); ?></span></td>
196
+								esc_html_e(
197
+									'Maximum Quantity',
198
+									'event_espresso'
199
+								); ?></span></td>
200 200
                     </tr>
201 201
                     </thead>
202 202
                     <tbody>
@@ -254,24 +254,24 @@  discard block
 block discarded – undo
254 254
                     <input type="checkbox"
255 255
                            name="<?php echo esc_attr($edit_tickets_name); ?>[<?php echo absint($tkt_row); ?>][TKT_required]"
256 256
                            class="edit-ticket-TKT_required" value="1"<?php
257
-                            echo $TKT_required
258
-                                ? ' checked="checked"'
259
-                                : '';
260
-                            echo $disabled
261
-                                ? ' disabled'
262
-                                : ''; ?>>
257
+							echo $TKT_required
258
+								? ' checked="checked"'
259
+								: '';
260
+							echo $disabled
261
+								? ' disabled'
262
+								: ''; ?>>
263 263
                     <label for="edit-ticket-TKT_required"><?php
264
-                        esc_html_e(
265
-                            'This ticket is required (will appear first in frontend ticket lists).',
266
-                            'event_espresso'
267
-                        ); ?></label>
264
+						esc_html_e(
265
+							'This ticket is required (will appear first in frontend ticket lists).',
266
+							'event_espresso'
267
+						); ?></label>
268 268
                 </div>
269 269
                 <div class="ticket-is-taxable-container">
270 270
                     <?php if (! empty($tax_rows)) { ?>
271 271
                         <?php if ($disabled) : ?>
272 272
                             <?php
273
-                            $tax_value = ! empty($TKT_taxable) ? 1 : 0;
274
-                            ?>
273
+							$tax_value = ! empty($TKT_taxable) ? 1 : 0;
274
+							?>
275 275
                         <input class="TKT-taxable-checkbox" type="hidden"
276 276
                                name="<?php echo esc_attr($edit_tickets_name); ?>[<?php echo absint($tkt_row); ?>][TKT_taxable]"
277 277
                                value="<?php echo esc_attr($tax_value); ?>">
@@ -285,16 +285,16 @@  discard block
 block discarded – undo
285 285
                                value="1"<?php echo $TKT_taxable; ?>>
286 286
                         <?php endif; ?>
287 287
                     <label for="edit-ticket-TKT_taxable-<?php echo absint($tkt_row); ?>"> <?php
288
-                        esc_html_e('This ticket is taxable.', 'event_espresso'); ?>
288
+						esc_html_e('This ticket is taxable.', 'event_espresso'); ?>
289 289
                     <?php } //end tax_rows check ?>
290 290
                 </div>
291 291
             </div>
292 292
             <div class="price-table-container">
293 293
                 <h4 class="tickets-heading price-table-info"<?php echo $show_price_modifier; ?>><?php
294
-                    esc_html_e(
295
-                        'Price Modifiers',
296
-                        'event_espresso'
297
-                    ); ?></h4>
294
+					esc_html_e(
295
+						'Price Modifiers',
296
+						'event_espresso'
297
+					); ?></h4>
298 298
                 <table class="price-table">
299 299
                     <thead class="price-table-info"<?php echo $show_price_modifier; ?>>
300 300
                     <tr>
@@ -314,10 +314,10 @@  discard block
 block discarded – undo
314 314
                     <tr class="price-subtotal-row TKT-taxes-display"<?php echo $display_subtotal; ?>>
315 315
                         <td colspan="4" class="ee-numeric">
316 316
                             <span class="TKT-taxable-subtotal-label"><strong><?php
317
-                                    esc_html_e(
318
-                                        'Subtotal',
319
-                                        'event_espresso'
320
-                                    ); ?></strong></span>
317
+									esc_html_e(
318
+										'Subtotal',
319
+										'event_espresso'
320
+									); ?></strong></span>
321 321
                         </td>
322 322
                         <td class="ee-numeric">
323 323
                             <span
@@ -350,51 +350,51 @@  discard block
 block discarded – undo
350 350
             <div style="clear:both"></div>
351 351
             <h4 class="tickets-heading"><?php esc_html_e('Event Datetimes', 'event_espresso'); ?></h4>
352 352
             <p><?php
353
-                esc_html_e(
354
-                    'This ticket will be usable (allow entrance) for the following selected event datetimes (click to select).  The "# Datetimes" amount (above) indicates how many of the assigned datetimes the ticket holder can gain access to:',
355
-                    'event_espresso'
356
-                ); ?></p>
353
+				esc_html_e(
354
+					'This ticket will be usable (allow entrance) for the following selected event datetimes (click to select).  The "# Datetimes" amount (above) indicates how many of the assigned datetimes the ticket holder can gain access to:',
355
+					'event_espresso'
356
+				); ?></p>
357 357
             <ul class="datetime-tickets-list">
358 358
                 <?php echo $ticket_datetimes_list; ?>
359 359
             </ul>
360 360
 
361 361
             <?php do_action(
362
-                'AHEE__event_tickets_datetime_ticket_row_template__advanced_details_end',
363
-                $tkt_row,
364
-                $TKT_ID
365
-            ); ?>
362
+				'AHEE__event_tickets_datetime_ticket_row_template__advanced_details_end',
363
+				$tkt_row,
364
+				$TKT_ID
365
+			); ?>
366 366
             <div class="ee-editor-footer-container">
367 367
                 <div class="ee-editor-id-container">
368 368
                     <span class="ee-item-id"><?php echo
369
-                        $TKT_ID
370
-                            ? sprintf(
371
-                                esc_html__('Ticket ID: %d', 'event_espresso'),
372
-                                $TKT_ID
373
-                            )
374
-                                             : ''; ?></span>
369
+						$TKT_ID
370
+							? sprintf(
371
+								esc_html__('Ticket ID: %d', 'event_espresso'),
372
+								$TKT_ID
373
+							)
374
+											 : ''; ?></span>
375 375
                 </div>
376 376
                 <div class="save-cancel-button-container">
377 377
                     <label for="edit-ticket-TKT_is_default_selector"><?php
378
-                        esc_html_e(
379
-                            'use this new ticket as a default ticket for any new events',
380
-                            'event_espresso'
381
-                        ); ?></label>
378
+						esc_html_e(
379
+							'use this new ticket as a default ticket for any new events',
380
+							'event_espresso'
381
+						); ?></label>
382 382
                     <input type="checkbox"
383 383
                            name="<?php echo esc_attr($edit_tickets_name); ?>[<?php echo absint($tkt_row); ?>][TKT_is_default_selector]"
384 384
                            class="edit-ticket-TKT_is_default_selector" value="1"<?php
385
-                            echo $disabled
386
-                                ? ' disabled'
387
-                                : ''; ?>>
385
+							echo $disabled
386
+								? ' disabled'
387
+								: ''; ?>>
388 388
                     <input type="hidden"
389 389
                            name="<?php echo esc_attr($edit_tickets_name); ?>[<?php echo absint($tkt_row); ?>][TKT_is_default]"
390 390
                            class="edit-ticket-TKT_is_default" value="<?php echo esc_attr($TKT_is_default); ?>">
391 391
                     <!--<button class="button-primary ee-save-button" data-context="ticket" data-ticket-row="<?php echo absint($tkt_row); ?>"><?php esc_html_e(
392
-                        'Update Ticket',
393
-                        'event_espresso'
394
-                    ); ?></button>-->
392
+						'Update Ticket',
393
+						'event_espresso'
394
+					); ?></button>-->
395 395
                     <button class="button-secondary ee-cancel-button" data-context="ticket"
396 396
                             data-ticket-row="<?php echo absint($tkt_row); ?>"><?php
397
-                                    esc_html_e('Close', 'event_espresso'); ?></button>
397
+									esc_html_e('Close', 'event_espresso'); ?></button>
398 398
                 </div>
399 399
             </div>
400 400
             <!-- these hidden inputs are for tracking changes in dtts attached to tickets during a js session -->
Please login to merge, or discard this patch.
admin_pages/maintenance/templates/ee_system_stati_page.template.php 1 patch
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -18,38 +18,38 @@  discard block
 block discarded – undo
18 18
  */
19 19
 function ee_recurse_into_array_for_display($data, $depth = 0, $td = true)
20 20
 {
21
-    if (is_object($data) || $data instanceof __PHP_Incomplete_Class) {
22
-        // is_object($incomplete_class) actually returns false, hence why we check for it
23
-        $data = json_decode(json_encode($data), true);
24
-    }
25
-    if (empty($data)) {
26
-        return;
27
-    }
28
-    if (is_array($data)) {
29
-        $depth++;
30
-        ksort($data, SORT_NATURAL | SORT_FLAG_CASE);
31
-        if (EEH_Array::is_associative_array($data)) { ?>
21
+	if (is_object($data) || $data instanceof __PHP_Incomplete_Class) {
22
+		// is_object($incomplete_class) actually returns false, hence why we check for it
23
+		$data = json_decode(json_encode($data), true);
24
+	}
25
+	if (empty($data)) {
26
+		return;
27
+	}
28
+	if (is_array($data)) {
29
+		$depth++;
30
+		ksort($data, SORT_NATURAL | SORT_FLAG_CASE);
31
+		if (EEH_Array::is_associative_array($data)) { ?>
32 32
             <table class='ee-system-stati ee-system-stati-<?php echo absint($depth); ?>'>
33 33
                 <tbody>
34 34
                     <?php foreach ($data as $data_key => $data_value) {
35
-                        // if the value is a single element array with no key,
36
-                        // and the value is a primitive (not an array, object, etc.)
37
-                        if (
38
-                            is_array($data_value)
39
-                            && count($data_value) === 1
40
-                            && empty(key($data_value))
41
-                            && is_scalar(reset($data_value))
42
-                        ) {
43
-                            ?>
35
+						// if the value is a single element array with no key,
36
+						// and the value is a primitive (not an array, object, etc.)
37
+						if (
38
+							is_array($data_value)
39
+							&& count($data_value) === 1
40
+							&& empty(key($data_value))
41
+							&& is_scalar(reset($data_value))
42
+						) {
43
+							?>
44 44
                             <tr>
45 45
                                 <td class="ee-system-stati-value" colspan="2">
46 46
                                     <?php echo esc_html(reset($data_value)); ?>
47 47
                                 </td>
48 48
                             </tr>
49 49
                             <?php
50
-                            continue;
51
-                        }
52
-                        ?>
50
+							continue;
51
+						}
52
+						?>
53 53
                         <tr>
54 54
                             <td class='ee-system-stati-key'>
55 55
                                 <span class="ee-system-stati-label">
@@ -64,31 +64,31 @@  discard block
 block discarded – undo
64 64
                             <?php if (is_scalar($data_value)) { ?>
65 65
                                 <?php ee_recurse_into_array_for_display($data_value, $depth); ?>
66 66
                             <?php } else {
67
-                                if (is_array($data_value) && count($data_value) === 1) {
68
-                                    // verify that values have been set
69
-                                    $keys_only = empty(
70
-                                        array_filter(
71
-                                            array_values($data_value),
72
-                                            function ($v) {
73
-                                                return $v !== null && (is_array($v) || trim($v) !== '');
74
-                                            }
75
-                                        )
76
-                                    );
77
-                                    // if the array only consists of keys (no values)
78
-                                    if ($keys_only) {
79
-                                        // then use keys for values
80
-                                        $data_value = array_keys($data_value);
81
-                                        // but if there is only one value now
82
-                                        if (count($data_value) === 1) {
83
-                                            // then pass that single value back into this function
84
-                                            // this prevents extra empty layers of nothing being added to the output
85
-                                            ee_recurse_into_array_for_display(reset($data_value), $depth);
86
-                                            // need to finish the row off though
87
-                                            echo '</tr>';
88
-                                            continue;
89
-                                        }
90
-                                    }
91
-                                } ?>
67
+								if (is_array($data_value) && count($data_value) === 1) {
68
+									// verify that values have been set
69
+									$keys_only = empty(
70
+										array_filter(
71
+											array_values($data_value),
72
+											function ($v) {
73
+												return $v !== null && (is_array($v) || trim($v) !== '');
74
+											}
75
+										)
76
+									);
77
+									// if the array only consists of keys (no values)
78
+									if ($keys_only) {
79
+										// then use keys for values
80
+										$data_value = array_keys($data_value);
81
+										// but if there is only one value now
82
+										if (count($data_value) === 1) {
83
+											// then pass that single value back into this function
84
+											// this prevents extra empty layers of nothing being added to the output
85
+											ee_recurse_into_array_for_display(reset($data_value), $depth);
86
+											// need to finish the row off though
87
+											echo '</tr>';
88
+											continue;
89
+										}
90
+									}
91
+								} ?>
92 92
                                 <td class="ee-system-stati-sub-values">
93 93
                                     <?php ee_recurse_into_array_for_display($data_value, $depth); ?>
94 94
                                 </td>
@@ -106,19 +106,19 @@  discard block
 block discarded – undo
106 106
                 <?php } ?>
107 107
             </ul>
108 108
         <?php } else {
109
-            // there's no key (label) and there's only one value,
110
-            // so let's just pass that value back into this function,
111
-            // but reset the depth back to where it was.
112
-            // this prevents extra empty layers of nothing being added to the output
113
-            $depth--;
114
-            ee_recurse_into_array_for_display(reset($data), $depth, false);
115
-        }
116
-    } else {
117
-        echo $td ? '<td class="ee-system-stati-value">' : '';
118
-        // simple value
119
-        echo $data;
120
-        echo $td ? '</td>' : '';
121
-    }
109
+			// there's no key (label) and there's only one value,
110
+			// so let's just pass that value back into this function,
111
+			// but reset the depth back to where it was.
112
+			// this prevents extra empty layers of nothing being added to the output
113
+			$depth--;
114
+			ee_recurse_into_array_for_display(reset($data), $depth, false);
115
+		}
116
+	} else {
117
+		echo $td ? '<td class="ee-system-stati-value">' : '';
118
+		// simple value
119
+		echo $data;
120
+		echo $td ? '</td>' : '';
121
+	}
122 122
 }
123 123
 
124 124
 ?>
Please login to merge, or discard this patch.