@@ -774,7 +774,7 @@ discard block |
||
774 | 774 | * |
775 | 775 | * @param mixed $opt_group |
776 | 776 | * @param mixed $QSOs |
777 | - * @param mixed $answer |
|
777 | + * @param string $answer |
|
778 | 778 | * @return string |
779 | 779 | */ |
780 | 780 | private static function _generate_select_option_group( $opt_group, $QSOs, $answer ){ |
@@ -1122,7 +1122,7 @@ discard block |
||
1122 | 1122 | /** |
1123 | 1123 | * prep_required |
1124 | 1124 | * @param string|array $required |
1125 | - * @return array |
|
1125 | + * @return string |
|
1126 | 1126 | */ |
1127 | 1127 | static function prep_required( $required = array() ){ |
1128 | 1128 | // make sure required is an array |
@@ -1173,8 +1173,8 @@ discard block |
||
1173 | 1173 | |
1174 | 1174 | /** |
1175 | 1175 | * _load_system_dropdowns |
1176 | - * @param array $QFI |
|
1177 | - * @return array |
|
1176 | + * @param EE_Question_Form_Input $QFI |
|
1177 | + * @return EE_Question_Form_Input |
|
1178 | 1178 | */ |
1179 | 1179 | private static function _load_system_dropdowns( $QFI ){ |
1180 | 1180 | $QST_system = $QFI->get('QST_system'); |
@@ -1463,7 +1463,7 @@ discard block |
||
1463 | 1463 | * @param string $nonce_action - if using nonces |
1464 | 1464 | * @param bool|string $input_only - whether to print form header and footer. TRUE returns the input without the form |
1465 | 1465 | * @param string $extra_attributes - any extra attributes that need to be attached to the form input |
1466 | - * @return void |
|
1466 | + * @return string |
|
1467 | 1467 | */ |
1468 | 1468 | public static function submit_button( $url = '', $ID = '', $class = '', $text = '', $nonce_action = '', $input_only = FALSE, $extra_attributes = '' ) { |
1469 | 1469 | $btn = ''; |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | |
394 | 394 | /** |
395 | 395 | * generate_question_groups_html |
396 | - * |
|
396 | + * |
|
397 | 397 | * @param string $question_groups |
398 | 398 | * @return string HTML |
399 | 399 | */ |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | |
538 | 538 | /** |
539 | 539 | * generate_form_input |
540 | - * |
|
540 | + * |
|
541 | 541 | * @param EE_Question_Form_Input $QFI |
542 | 542 | * @return string HTML |
543 | 543 | */ |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | |
613 | 613 | /** |
614 | 614 | * generates HTML for a form text input |
615 | - * |
|
615 | + * |
|
616 | 616 | * @param string $question label content |
617 | 617 | * @param string $answer form input value attribute |
618 | 618 | * @param string $name form input name attribute |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | |
658 | 658 | /** |
659 | 659 | * generates HTML for a form textarea |
660 | - * |
|
660 | + * |
|
661 | 661 | * @param string $question label content |
662 | 662 | * @param string $answer form input value attribute |
663 | 663 | * @param string $name form input name attribute |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | |
709 | 709 | /** |
710 | 710 | * generates HTML for a form select input |
711 | - * |
|
711 | + * |
|
712 | 712 | * @param string $question label content |
713 | 713 | * @param string $answer form input value attribute |
714 | 714 | * @param array $options array of answer options where array key = option value and array value = option display text |
@@ -885,7 +885,7 @@ discard block |
||
885 | 885 | |
886 | 886 | /** |
887 | 887 | * generates HTML for form checkbox inputs |
888 | - * |
|
888 | + * |
|
889 | 889 | * @param string $question label content |
890 | 890 | * @param string $answer form input value attribute |
891 | 891 | * @param array $options array of options where array key = option value and array value = option display text |
@@ -966,7 +966,7 @@ discard block |
||
966 | 966 | |
967 | 967 | /** |
968 | 968 | * generates HTML for a form datepicker input |
969 | - * |
|
969 | + * |
|
970 | 970 | * @param string $question label content |
971 | 971 | * @param string $answer form input value attribute |
972 | 972 | * @param string $name form input name attribute |
@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | * @return string |
58 | 58 | * @todo: at some point we can break this down into other static methods to abstract it a bit better. |
59 | 59 | */ |
60 | - static public function get_form_fields( $input_vars = array(), $id = FALSE ) { |
|
60 | + static public function get_form_fields($input_vars = array(), $id = FALSE) { |
|
61 | 61 | |
62 | - if ( empty($input_vars) ) { |
|
63 | - EE_Error::add_error( __('missing required variables for the form field generator', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
62 | + if (empty($input_vars)) { |
|
63 | + EE_Error::add_error(__('missing required variables for the form field generator', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
64 | 64 | return FALSE; |
65 | 65 | } |
66 | 66 | |
@@ -85,22 +85,22 @@ discard block |
||
85 | 85 | 'tabindex' => '' |
86 | 86 | ); |
87 | 87 | |
88 | - $input_value = wp_parse_args( $input_value, $defaults ); |
|
88 | + $input_value = wp_parse_args($input_value, $defaults); |
|
89 | 89 | |
90 | 90 | // required fields get a * |
91 | 91 | $required = isset($input_value['required']) && $input_value['required'] ? ' <span>*</span>: ' : ': '; |
92 | 92 | // and the css class "required" |
93 | - $css_class = isset( $input_value['css_class'] ) ? $input_value['css_class'] : ''; |
|
94 | - $styles = $input_value['required'] ? 'required ' . $css_class : $css_class; |
|
93 | + $css_class = isset($input_value['css_class']) ? $input_value['css_class'] : ''; |
|
94 | + $styles = $input_value['required'] ? 'required '.$css_class : $css_class; |
|
95 | 95 | |
96 | - $field_id = ($id) ? $id . '-' . $input_key : $input_key; |
|
97 | - $tabindex = !empty($input_value['tabindex']) ? ' tabindex="' . $input_value['tabindex'] . '"' : ''; |
|
96 | + $field_id = ($id) ? $id.'-'.$input_key : $input_key; |
|
97 | + $tabindex = ! empty($input_value['tabindex']) ? ' tabindex="'.$input_value['tabindex'].'"' : ''; |
|
98 | 98 | |
99 | 99 | //rows or cols? |
100 | - $rows = isset($input_value['rows'] ) ? $input_value['rows'] : '10'; |
|
101 | - $cols = isset($input_value['cols'] ) ? $input_value['cols'] : '80'; |
|
100 | + $rows = isset($input_value['rows']) ? $input_value['rows'] : '10'; |
|
101 | + $cols = isset($input_value['cols']) ? $input_value['cols'] : '80'; |
|
102 | 102 | |
103 | - $output .= (!$close) ? '<ul>' : ''; |
|
103 | + $output .= ( ! $close) ? '<ul>' : ''; |
|
104 | 104 | $output .= '<li>'; |
105 | 105 | |
106 | 106 | // what type of input are we dealing with ? |
@@ -108,15 +108,15 @@ discard block |
||
108 | 108 | |
109 | 109 | // text inputs |
110 | 110 | case 'text' : |
111 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
112 | - $output .= "\n\t\t\t" . '<input id="' . $field_id . '" class="' . $styles . '" type="text" value="' . $input_value['value'] . '" name="' . $input_value['name'] . '"' . $tabindex . '>'; |
|
111 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
112 | + $output .= "\n\t\t\t".'<input id="'.$field_id.'" class="'.$styles.'" type="text" value="'.$input_value['value'].'" name="'.$input_value['name'].'"'.$tabindex.'>'; |
|
113 | 113 | break; |
114 | 114 | |
115 | 115 | // dropdowns |
116 | 116 | case 'select' : |
117 | 117 | |
118 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
119 | - $output .= "\n\t\t\t" . '<select id="' . $field_id . '" class="' . $styles . '" name="' . $input_value['name'] . '"' . $tabindex . '>'; |
|
118 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
119 | + $output .= "\n\t\t\t".'<select id="'.$field_id.'" class="'.$styles.'" name="'.$input_value['name'].'"'.$tabindex.'>'; |
|
120 | 120 | |
121 | 121 | if (is_array($input_value['options'])) { |
122 | 122 | $options = $input_value['options']; |
@@ -125,30 +125,30 @@ discard block |
||
125 | 125 | } |
126 | 126 | |
127 | 127 | foreach ($options as $key => $value) { |
128 | - $selected = isset( $input_value['value'] ) && $input_value['value'] == $key ? 'selected=selected' : ''; |
|
128 | + $selected = isset($input_value['value']) && $input_value['value'] == $key ? 'selected=selected' : ''; |
|
129 | 129 | //$key = str_replace( ' ', '_', sanitize_key( $value )); |
130 | - $output .= "\n\t\t\t\t" . '<option '. $selected . ' value="' . $key . '">' . $value . '</option>'; |
|
130 | + $output .= "\n\t\t\t\t".'<option '.$selected.' value="'.$key.'">'.$value.'</option>'; |
|
131 | 131 | } |
132 | - $output .= "\n\t\t\t" . '</select>'; |
|
132 | + $output .= "\n\t\t\t".'</select>'; |
|
133 | 133 | |
134 | 134 | break; |
135 | 135 | |
136 | 136 | case 'textarea' : |
137 | 137 | |
138 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
139 | - $output .= "\n\t\t\t" . '<textarea id="' . $field_id . '" class="' . $styles . '" rows="'.$rows.'" cols="'.$cols.'" name="' . $input_value['name'] . '"' . $tabindex . '>' . $input_value['value'] . '</textarea>'; |
|
138 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
139 | + $output .= "\n\t\t\t".'<textarea id="'.$field_id.'" class="'.$styles.'" rows="'.$rows.'" cols="'.$cols.'" name="'.$input_value['name'].'"'.$tabindex.'>'.$input_value['value'].'</textarea>'; |
|
140 | 140 | break; |
141 | 141 | |
142 | 142 | case 'hidden' : |
143 | 143 | $close = false; |
144 | 144 | $output .= "</li></ul>"; |
145 | - $output .= "\n\t\t\t" . '<input id="' . $field_id . '" type="hidden" name="' . $input_value['name'] . '" value="' . $input_value['value'] . '">'; |
|
145 | + $output .= "\n\t\t\t".'<input id="'.$field_id.'" type="hidden" name="'.$input_value['name'].'" value="'.$input_value['value'].'">'; |
|
146 | 146 | break; |
147 | 147 | |
148 | 148 | case 'checkbox' : |
149 | - $checked = ( $input_value['value'] == 1 ) ? 'checked="checked"' : ''; |
|
150 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
151 | - $output .= "\n\t\t\t" . '<input id="' . $field_id. '" type="checkbox" name="' . $input_value['name'] . '" value="1"' . $checked . $tabindex . ' />'; |
|
149 | + $checked = ($input_value['value'] == 1) ? 'checked="checked"' : ''; |
|
150 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
151 | + $output .= "\n\t\t\t".'<input id="'.$field_id.'" type="checkbox" name="'.$input_value['name'].'" value="1"'.$checked.$tabindex.' />'; |
|
152 | 152 | break; |
153 | 153 | |
154 | 154 | case 'wp_editor' : |
@@ -161,9 +161,9 @@ discard block |
||
161 | 161 | ); |
162 | 162 | $output .= '</li>'; |
163 | 163 | $output .= '</ul>'; |
164 | - $output .= '<h4>' . $input_value['label'] . '</h4>'; |
|
164 | + $output .= '<h4>'.$input_value['label'].'</h4>'; |
|
165 | 165 | ob_start(); |
166 | - wp_editor( $input_value['value'], $field_id, $editor_settings); |
|
166 | + wp_editor($input_value['value'], $field_id, $editor_settings); |
|
167 | 167 | $editor = ob_get_contents(); |
168 | 168 | ob_end_clean(); |
169 | 169 | $output .= $editor; |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | $form_fields = array(); |
209 | 209 | $fields = (array) $fields; |
210 | 210 | |
211 | - foreach ( $fields as $field_name => $field_atts ) { |
|
211 | + foreach ($fields as $field_name => $field_atts) { |
|
212 | 212 | //defaults: |
213 | 213 | $defaults = array( |
214 | 214 | 'label' => '', |
@@ -226,67 +226,67 @@ discard block |
||
226 | 226 | 'wpeditor_args' => array() |
227 | 227 | ); |
228 | 228 | // merge defaults with passed arguments |
229 | - $_fields = wp_parse_args( $field_atts, $defaults); |
|
230 | - extract( $_fields ); |
|
229 | + $_fields = wp_parse_args($field_atts, $defaults); |
|
230 | + extract($_fields); |
|
231 | 231 | // generate label |
232 | - $label = empty($label) ? '' : '<label for="' . $id . '">' . $label . '</label>'; |
|
232 | + $label = empty($label) ? '' : '<label for="'.$id.'">'.$label.'</label>'; |
|
233 | 233 | // generate field name |
234 | - $f_name = !empty($unique_id) ? $field_name . '[' . $unique_id . ']' : $field_name; |
|
234 | + $f_name = ! empty($unique_id) ? $field_name.'['.$unique_id.']' : $field_name; |
|
235 | 235 | |
236 | 236 | //tabindex |
237 | - $tabindex_str = !empty( $tabindex ) ? ' tabindex="' . $tabindex . '"' : ''; |
|
237 | + $tabindex_str = ! empty($tabindex) ? ' tabindex="'.$tabindex.'"' : ''; |
|
238 | 238 | |
239 | 239 | //we determine what we're building based on the type |
240 | - switch ( $type ) { |
|
240 | + switch ($type) { |
|
241 | 241 | |
242 | 242 | case 'textarea' : |
243 | - $fld = '<textarea id="' . $id . '" class="' . $class . '" rows="' . $dimensions[1] . '" cols="' . $dimensions[0] . '" name="' . $f_name . '"' . $tabindex_str . '>' . $value . '</textarea>'; |
|
243 | + $fld = '<textarea id="'.$id.'" class="'.$class.'" rows="'.$dimensions[1].'" cols="'.$dimensions[0].'" name="'.$f_name.'"'.$tabindex_str.'>'.$value.'</textarea>'; |
|
244 | 244 | $fld .= $extra_desc; |
245 | 245 | break; |
246 | 246 | |
247 | 247 | case 'checkbox' : |
248 | 248 | $c_input = ''; |
249 | - if ( is_array($value) ) { |
|
250 | - foreach ( $value as $key => $val ) { |
|
251 | - $c_id = $field_name . '_' . $value; |
|
252 | - $c_class = isset($classes[$key]) ? ' class="' . $classes[$key] . '" ' : ''; |
|
253 | - $c_label = isset($labels[$key]) ? '<label for="' . $c_id . '">' . $labels[$key] . '</label>' : ''; |
|
254 | - $checked = !empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
255 | - $c_input .= '<input name="' . $f_name . '[]" type="checkbox" id="' . $c_id . '"' . $c_class . 'value="' . $val . '"' . $checked . $tabindex_str . ' />' . "\n" . $c_label; |
|
249 | + if (is_array($value)) { |
|
250 | + foreach ($value as $key => $val) { |
|
251 | + $c_id = $field_name.'_'.$value; |
|
252 | + $c_class = isset($classes[$key]) ? ' class="'.$classes[$key].'" ' : ''; |
|
253 | + $c_label = isset($labels[$key]) ? '<label for="'.$c_id.'">'.$labels[$key].'</label>' : ''; |
|
254 | + $checked = ! empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
255 | + $c_input .= '<input name="'.$f_name.'[]" type="checkbox" id="'.$c_id.'"'.$c_class.'value="'.$val.'"'.$checked.$tabindex_str.' />'."\n".$c_label; |
|
256 | 256 | } |
257 | 257 | $fld = $c_input; |
258 | 258 | } else { |
259 | - $checked = !empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
260 | - $fld = '<input name="'. $f_name . '" type="checkbox" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $checked . $tabindex_str . ' />' . "\n"; |
|
259 | + $checked = ! empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
260 | + $fld = '<input name="'.$f_name.'" type="checkbox" id="'.$id.'" class="'.$class.'" value="'.$value.'"'.$checked.$tabindex_str.' />'."\n"; |
|
261 | 261 | } |
262 | 262 | break; |
263 | 263 | |
264 | 264 | case 'radio' : |
265 | 265 | $c_input = ''; |
266 | - if ( is_array($value) ) { |
|
267 | - foreach ( $value as $key => $val ) { |
|
268 | - $c_id = $field_name . '_' . $value; |
|
269 | - $c_class = isset($classes[$key]) ? 'class="' . $classes[$key] . '" ' : ''; |
|
270 | - $c_label = isset($labels[$key]) ? '<label for="' . $c_id . '">' . $labels[$key] . '</label>' : ''; |
|
271 | - $checked = !empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
272 | - $c_input .= '<input name="' . $f_name . '" type="checkbox" id="' . $c_id . '"' . $c_class . 'value="' . $val . '"' . $checked . $tabindex_str . ' />' . "\n" . $c_label; |
|
266 | + if (is_array($value)) { |
|
267 | + foreach ($value as $key => $val) { |
|
268 | + $c_id = $field_name.'_'.$value; |
|
269 | + $c_class = isset($classes[$key]) ? 'class="'.$classes[$key].'" ' : ''; |
|
270 | + $c_label = isset($labels[$key]) ? '<label for="'.$c_id.'">'.$labels[$key].'</label>' : ''; |
|
271 | + $checked = ! empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
272 | + $c_input .= '<input name="'.$f_name.'" type="checkbox" id="'.$c_id.'"'.$c_class.'value="'.$val.'"'.$checked.$tabindex_str.' />'."\n".$c_label; |
|
273 | 273 | } |
274 | 274 | $fld = $c_input; |
275 | 275 | } else { |
276 | - $checked = !empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
277 | - $fld = '<input name="'. $f_name . '" type="checkbox" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $checked . $tabindex_str . ' />' . "\n"; |
|
276 | + $checked = ! empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
277 | + $fld = '<input name="'.$f_name.'" type="checkbox" id="'.$id.'" class="'.$class.'" value="'.$value.'"'.$checked.$tabindex_str.' />'."\n"; |
|
278 | 278 | } |
279 | 279 | break; |
280 | 280 | |
281 | 281 | case 'hidden' : |
282 | - $fld = '<input name="' . $f_name . '" type="hidden" id="' . $id . '" class="' . $class . '" value="' . $value . '" />' . "\n"; |
|
282 | + $fld = '<input name="'.$f_name.'" type="hidden" id="'.$id.'" class="'.$class.'" value="'.$value.'" />'."\n"; |
|
283 | 283 | break; |
284 | 284 | |
285 | 285 | case 'select' : |
286 | - $fld = '<select name="' . $f_name . '" class="' . $class . '" id="' . $id . '"' . $tabindex_str . '>' . "\n"; |
|
287 | - foreach ( $value as $key => $val ) { |
|
288 | - $checked = !empty($default) && $default == $val ? ' selected="selected"' : ''; |
|
289 | - $fld .= "\t" . '<option value="' . $val . '"' . $checked . '>' . $labels[$key] . '</option>' . "\n"; |
|
286 | + $fld = '<select name="'.$f_name.'" class="'.$class.'" id="'.$id.'"'.$tabindex_str.'>'."\n"; |
|
287 | + foreach ($value as $key => $val) { |
|
288 | + $checked = ! empty($default) && $default == $val ? ' selected="selected"' : ''; |
|
289 | + $fld .= "\t".'<option value="'.$val.'"'.$checked.'>'.$labels[$key].'</option>'."\n"; |
|
290 | 290 | } |
291 | 291 | $fld .= '</select>'; |
292 | 292 | break; |
@@ -298,21 +298,21 @@ discard block |
||
298 | 298 | 'editor_class' => $class, |
299 | 299 | 'tabindex' => $tabindex |
300 | 300 | ); |
301 | - $editor_settings = array_merge( $wpeditor_args, $editor_settings ); |
|
301 | + $editor_settings = array_merge($wpeditor_args, $editor_settings); |
|
302 | 302 | ob_start(); |
303 | - wp_editor( $value, $id, $editor_settings ); |
|
303 | + wp_editor($value, $id, $editor_settings); |
|
304 | 304 | $editor = ob_get_contents(); |
305 | 305 | ob_end_clean(); |
306 | 306 | $fld = $editor; |
307 | 307 | break; |
308 | 308 | |
309 | 309 | default : //'text fields' |
310 | - $fld = '<input name="' . $f_name . '" type="text" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $tabindex_str . ' />' . "\n"; |
|
310 | + $fld = '<input name="'.$f_name.'" type="text" id="'.$id.'" class="'.$class.'" value="'.$value.'"'.$tabindex_str.' />'."\n"; |
|
311 | 311 | $fld .= $extra_desc; |
312 | 312 | |
313 | 313 | } |
314 | 314 | |
315 | - $form_fields[ $field_name ] = array( 'label' => $label, 'field' => $fld ); |
|
315 | + $form_fields[$field_name] = array('label' => $label, 'field' => $fld); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | return $form_fields; |
@@ -341,22 +341,22 @@ discard block |
||
341 | 341 | */ |
342 | 342 | static public function select_input($name, $values, $default = '', $parameters = '', $class = '', $autosize = true) { |
343 | 343 | //if $values was submitted in the wrong format, convert it over |
344 | - if(!empty($values) && (!array_key_exists(0,$values) || !is_array($values[0]))){ |
|
345 | - $converted_values=array(); |
|
346 | - foreach($values as $id=>$text){ |
|
347 | - $converted_values[]=array('id'=>$id,'text'=>$text); |
|
344 | + if ( ! empty($values) && ( ! array_key_exists(0, $values) || ! is_array($values[0]))) { |
|
345 | + $converted_values = array(); |
|
346 | + foreach ($values as $id=>$text) { |
|
347 | + $converted_values[] = array('id'=>$id, 'text'=>$text); |
|
348 | 348 | } |
349 | - $values=$converted_values; |
|
349 | + $values = $converted_values; |
|
350 | 350 | } |
351 | 351 | //load formatter helper |
352 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
352 | + EE_Registry::instance()->load_helper('Formatter'); |
|
353 | 353 | //EE_Registry::instance()->load_helper( 'Formatter' ); |
354 | 354 | |
355 | - $field = '<select id="' . EEH_Formatter::ee_tep_output_string($name) . '" name="' . EEH_Formatter::ee_tep_output_string($name) . '"'; |
|
355 | + $field = '<select id="'.EEH_Formatter::ee_tep_output_string($name).'" name="'.EEH_Formatter::ee_tep_output_string($name).'"'; |
|
356 | 356 | //Debug |
357 | 357 | //EEH_Debug_Tools::printr( $values, '$values <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
358 | - if ( EEH_Formatter::ee_tep_not_null($parameters)) |
|
359 | - $field .= ' ' . $parameters; |
|
358 | + if (EEH_Formatter::ee_tep_not_null($parameters)) |
|
359 | + $field .= ' '.$parameters; |
|
360 | 360 | if ($autosize) { |
361 | 361 | $size = 'med'; |
362 | 362 | for ($ii = 0, $ni = sizeof($values); $ii < $ni; $ii++) { |
@@ -368,18 +368,18 @@ discard block |
||
368 | 368 | } else |
369 | 369 | $size = ''; |
370 | 370 | |
371 | - $field .= ' class="' . $class . ' ' . $size . '">'; |
|
371 | + $field .= ' class="'.$class.' '.$size.'">'; |
|
372 | 372 | |
373 | 373 | if (empty($default) && isset($GLOBALS[$name])) |
374 | 374 | $default = stripslashes($GLOBALS[$name]); |
375 | 375 | |
376 | 376 | |
377 | 377 | for ($i = 0, $n = sizeof($values); $i < $n; $i++) { |
378 | - $field .= '<option value="' . $values[$i]['id'] . '"'; |
|
378 | + $field .= '<option value="'.$values[$i]['id'].'"'; |
|
379 | 379 | if ($default == $values[$i]['id']) { |
380 | 380 | $field .= ' selected = "selected"'; |
381 | 381 | } |
382 | - $field .= '>' . $values[$i]['text'] . '</option>'; |
|
382 | + $field .= '>'.$values[$i]['text'].'</option>'; |
|
383 | 383 | } |
384 | 384 | $field .= '</select>'; |
385 | 385 | |
@@ -397,38 +397,38 @@ discard block |
||
397 | 397 | * @param string $question_groups |
398 | 398 | * @return string HTML |
399 | 399 | */ |
400 | - static function generate_question_groups_html( $question_groups = array(), $group_wrapper = 'fieldset' ) { |
|
400 | + static function generate_question_groups_html($question_groups = array(), $group_wrapper = 'fieldset') { |
|
401 | 401 | |
402 | 402 | $html = ''; |
403 | - $before_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '' ); |
|
404 | - $after_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '' ); |
|
403 | + $before_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', ''); |
|
404 | + $after_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', ''); |
|
405 | 405 | |
406 | - if ( ! empty( $question_groups )) { |
|
406 | + if ( ! empty($question_groups)) { |
|
407 | 407 | //EEH_Debug_Tools::printr( $question_groups, '$question_groups <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
408 | 408 | // loop thru question groups |
409 | - foreach ( $question_groups as $QSG ) { |
|
409 | + foreach ($question_groups as $QSG) { |
|
410 | 410 | // check that questions exist |
411 | - if ( ! empty( $QSG['QSG_questions'] )) { |
|
411 | + if ( ! empty($QSG['QSG_questions'])) { |
|
412 | 412 | // use fieldsets |
413 | - $html .= "\n\t" . '<' . $group_wrapper . ' class="espresso-question-group-wrap" id="' . $QSG['QSG_identifier'] . '">'; |
|
413 | + $html .= "\n\t".'<'.$group_wrapper.' class="espresso-question-group-wrap" id="'.$QSG['QSG_identifier'].'">'; |
|
414 | 414 | // group_name |
415 | - $html .= $QSG['QSG_show_group_name'] ? "\n\t\t" . '<h5 class="espresso-question-group-title-h5 section-title">' . self::prep_answer( $QSG['QSG_name'] ) . '</h5>' : ''; |
|
415 | + $html .= $QSG['QSG_show_group_name'] ? "\n\t\t".'<h5 class="espresso-question-group-title-h5 section-title">'.self::prep_answer($QSG['QSG_name']).'</h5>' : ''; |
|
416 | 416 | // group_desc |
417 | - $html .= $QSG['QSG_show_group_desc'] && ! empty( $QSG['QSG_desc'] ) ? '<div class="espresso-question-group-desc-pg">' . self::prep_answer( $QSG['QSG_desc'] ) . '</div>' : ''; |
|
417 | + $html .= $QSG['QSG_show_group_desc'] && ! empty($QSG['QSG_desc']) ? '<div class="espresso-question-group-desc-pg">'.self::prep_answer($QSG['QSG_desc']).'</div>' : ''; |
|
418 | 418 | |
419 | 419 | $html .= $before_question_group_questions; |
420 | 420 | // loop thru questions |
421 | - foreach ( $QSG['QSG_questions'] as $question ) { |
|
421 | + foreach ($QSG['QSG_questions'] as $question) { |
|
422 | 422 | // EEH_Debug_Tools::printr( $question, '$question <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
423 | 423 | $QFI = new EE_Question_Form_Input( |
424 | 424 | $question['qst_obj'], |
425 | 425 | $question['ans_obj'], |
426 | 426 | $question |
427 | 427 | ); |
428 | - $html .= self::generate_form_input( $QFI ); |
|
428 | + $html .= self::generate_form_input($QFI); |
|
429 | 429 | } |
430 | 430 | $html .= $after_question_group_questions; |
431 | - $html .= "\n\t" . '</' . $group_wrapper . '>'; |
|
431 | + $html .= "\n\t".'</'.$group_wrapper.'>'; |
|
432 | 432 | } |
433 | 433 | } |
434 | 434 | } |
@@ -448,11 +448,11 @@ discard block |
||
448 | 448 | * @param string $group_wrapper |
449 | 449 | * @return string HTML |
450 | 450 | */ |
451 | - static function generate_question_groups_html2( $question_groups = array(), $q_meta = array(), $from_admin = FALSE, $group_wrapper = 'fieldset' ) { |
|
451 | + static function generate_question_groups_html2($question_groups = array(), $q_meta = array(), $from_admin = FALSE, $group_wrapper = 'fieldset') { |
|
452 | 452 | |
453 | 453 | $html = ''; |
454 | - $before_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '' ); |
|
455 | - $after_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '' ); |
|
454 | + $before_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', ''); |
|
455 | + $after_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', ''); |
|
456 | 456 | |
457 | 457 | $default_q_meta = array( |
458 | 458 | 'att_nmbr' => 1, |
@@ -461,55 +461,55 @@ discard block |
||
461 | 461 | 'input_id' => '', |
462 | 462 | 'input_class' => '' |
463 | 463 | ); |
464 | - $q_meta = array_merge( $default_q_meta, $q_meta ); |
|
464 | + $q_meta = array_merge($default_q_meta, $q_meta); |
|
465 | 465 | //EEH_Debug_Tools::printr( $q_meta, '$q_meta <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
466 | 466 | |
467 | - if ( ! empty( $question_groups )) { |
|
467 | + if ( ! empty($question_groups)) { |
|
468 | 468 | // EEH_Debug_Tools::printr( $question_groups, '$question_groups <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
469 | 469 | // loop thru question groups |
470 | - foreach ( $question_groups as $QSG ) { |
|
471 | - if ( $QSG instanceof EE_Question_Group ) { |
|
470 | + foreach ($question_groups as $QSG) { |
|
471 | + if ($QSG instanceof EE_Question_Group) { |
|
472 | 472 | // check that questions exist |
473 | 473 | |
474 | - $where = array( 'QST_deleted' => 0 ); |
|
475 | - if ( ! $from_admin ) { |
|
474 | + $where = array('QST_deleted' => 0); |
|
475 | + if ( ! $from_admin) { |
|
476 | 476 | $where['QST_admin_only'] = 0; |
477 | 477 | } |
478 | - $questions = $QSG->questions( array( $where, 'order_by' => array( 'Question_Group_Question.QGQ_order' => 'ASC' ))); |
|
479 | - if ( ! empty( $questions )) { |
|
478 | + $questions = $QSG->questions(array($where, 'order_by' => array('Question_Group_Question.QGQ_order' => 'ASC'))); |
|
479 | + if ( ! empty($questions)) { |
|
480 | 480 | // use fieldsets |
481 | - $html .= "\n\t" . '<' . $group_wrapper . ' class="espresso-question-group-wrap" id="' . $QSG->get( 'QSG_identifier' ) . '">'; |
|
481 | + $html .= "\n\t".'<'.$group_wrapper.' class="espresso-question-group-wrap" id="'.$QSG->get('QSG_identifier').'">'; |
|
482 | 482 | // group_name |
483 | - if ( $QSG->show_group_name() ) { |
|
484 | - $html .= "\n\t\t" . '<h5 class="espresso-question-group-title-h5 section-title">' . $QSG->get_pretty( 'QSG_name' ) . '</h5>'; |
|
483 | + if ($QSG->show_group_name()) { |
|
484 | + $html .= "\n\t\t".'<h5 class="espresso-question-group-title-h5 section-title">'.$QSG->get_pretty('QSG_name').'</h5>'; |
|
485 | 485 | } |
486 | 486 | // group_desc |
487 | - if ( $QSG->show_group_desc() ) { |
|
488 | - $html .= '<div class="espresso-question-group-desc-pg">' . $QSG->get_pretty( 'QSG_desc' ) . '</div>'; |
|
487 | + if ($QSG->show_group_desc()) { |
|
488 | + $html .= '<div class="espresso-question-group-desc-pg">'.$QSG->get_pretty('QSG_desc').'</div>'; |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | $html .= $before_question_group_questions; |
492 | 492 | // loop thru questions |
493 | - foreach ( $questions as $QST ) { |
|
493 | + foreach ($questions as $QST) { |
|
494 | 494 | $qstn_id = $QST->is_system_question() ? $QST->system_ID() : $QST->ID(); |
495 | 495 | |
496 | 496 | $answer = NULL; |
497 | 497 | |
498 | - if ( isset( $_GET['qstn'] ) && isset( $q_meta['input_id'] ) && isset( $q_meta['att_nmbr'] )) { |
|
498 | + if (isset($_GET['qstn']) && isset($q_meta['input_id']) && isset($q_meta['att_nmbr'])) { |
|
499 | 499 | // check for answer in $_GET in case we are reprocessing a form after an error |
500 | - if ( isset( $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] )) { |
|
501 | - $answer = is_array( $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] ) ? $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] : sanitize_text_field( $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] ); |
|
500 | + if (isset($_GET['qstn'][$q_meta['input_id']][$qstn_id])) { |
|
501 | + $answer = is_array($_GET['qstn'][$q_meta['input_id']][$qstn_id]) ? $_GET['qstn'][$q_meta['input_id']][$qstn_id] : sanitize_text_field($_GET['qstn'][$q_meta['input_id']][$qstn_id]); |
|
502 | 502 | } |
503 | - } else if ( isset( $q_meta['attendee'] ) && $q_meta['attendee'] ) { |
|
503 | + } else if (isset($q_meta['attendee']) && $q_meta['attendee']) { |
|
504 | 504 | //attendee data from the session |
505 | - $answer = isset( $q_meta['attendee'][ $qstn_id ] ) ? $q_meta['attendee'][ $qstn_id ] : NULL; |
|
505 | + $answer = isset($q_meta['attendee'][$qstn_id]) ? $q_meta['attendee'][$qstn_id] : NULL; |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | |
509 | 509 | |
510 | 510 | $QFI = new EE_Question_Form_Input( |
511 | 511 | $QST, |
512 | - EE_Answer::new_instance ( array( |
|
512 | + EE_Answer::new_instance(array( |
|
513 | 513 | 'ANS_ID'=> 0, |
514 | 514 | 'QST_ID'=> 0, |
515 | 515 | 'REG_ID'=> 0, |
@@ -518,10 +518,10 @@ discard block |
||
518 | 518 | $q_meta |
519 | 519 | ); |
520 | 520 | //EEH_Debug_Tools::printr( $QFI, '$QFI <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
521 | - $html .= self::generate_form_input( $QFI ); |
|
521 | + $html .= self::generate_form_input($QFI); |
|
522 | 522 | } |
523 | 523 | $html .= $after_question_group_questions; |
524 | - $html .= "\n\t" . '</' . $group_wrapper . '>'; |
|
524 | + $html .= "\n\t".'</'.$group_wrapper.'>'; |
|
525 | 525 | } |
526 | 526 | } |
527 | 527 | } |
@@ -541,63 +541,63 @@ discard block |
||
541 | 541 | * @param EE_Question_Form_Input $QFI |
542 | 542 | * @return string HTML |
543 | 543 | */ |
544 | - static function generate_form_input( EE_Question_Form_Input $QFI ) { |
|
545 | - if ( isset( $QFI->QST_admin_only) && $QFI->QST_admin_only && ! is_admin() ) { |
|
544 | + static function generate_form_input(EE_Question_Form_Input $QFI) { |
|
545 | + if (isset($QFI->QST_admin_only) && $QFI->QST_admin_only && ! is_admin()) { |
|
546 | 546 | return ''; |
547 | 547 | } |
548 | 548 | |
549 | - $QFI = self::_load_system_dropdowns( $QFI ); |
|
550 | - $QFI = self::_load_specialized_dropdowns( $QFI ); |
|
549 | + $QFI = self::_load_system_dropdowns($QFI); |
|
550 | + $QFI = self::_load_specialized_dropdowns($QFI); |
|
551 | 551 | |
552 | 552 | //we also need to verify |
553 | 553 | |
554 | 554 | $display_text = $QFI->get('QST_display_text'); |
555 | 555 | $input_name = $QFI->get('QST_input_name'); |
556 | - $answer = EE_Registry::instance()->REQ->is_set( $input_name ) ? EE_Registry::instance()->REQ->get( $input_name ) : $QFI->get('ANS_value'); |
|
556 | + $answer = EE_Registry::instance()->REQ->is_set($input_name) ? EE_Registry::instance()->REQ->get($input_name) : $QFI->get('ANS_value'); |
|
557 | 557 | $input_id = $QFI->get('QST_input_id'); |
558 | 558 | $input_class = $QFI->get('QST_input_class'); |
559 | 559 | // $disabled = $QFI->get('QST_disabled') ? ' disabled="disabled"' : ''; |
560 | 560 | $disabled = $QFI->get('QST_disabled') ? TRUE : FALSE; |
561 | - $required_label = apply_filters(' FHEE__EEH_Form_Fields__generate_form_input__required_label', '<em>*</em>' ); |
|
561 | + $required_label = apply_filters(' FHEE__EEH_Form_Fields__generate_form_input__required_label', '<em>*</em>'); |
|
562 | 562 | $QST_required = $QFI->get('QST_required'); |
563 | - $required = $QST_required ? array( 'label' => $required_label, 'class' => 'required needs-value', 'title' => $QST_required ) : array(); |
|
564 | - $use_html_entities = $QFI->get_meta( 'htmlentities' ); |
|
565 | - $required_text = $QFI->get('QST_required_text') != '' ? $QFI->get('QST_required_text') : __( 'This field is required', 'event_espresso' ); |
|
566 | - $required_text = $QST_required ? "\n\t\t\t" . '<div class="required-text hidden">' . self::prep_answer( $required_text, $use_html_entities ) . '</div>' : ''; |
|
563 | + $required = $QST_required ? array('label' => $required_label, 'class' => 'required needs-value', 'title' => $QST_required) : array(); |
|
564 | + $use_html_entities = $QFI->get_meta('htmlentities'); |
|
565 | + $required_text = $QFI->get('QST_required_text') != '' ? $QFI->get('QST_required_text') : __('This field is required', 'event_espresso'); |
|
566 | + $required_text = $QST_required ? "\n\t\t\t".'<div class="required-text hidden">'.self::prep_answer($required_text, $use_html_entities).'</div>' : ''; |
|
567 | 567 | $label_class = 'espresso-form-input-lbl'; |
568 | - $QST_options = $QFI->options(true,$answer); |
|
569 | - $options = is_array( $QST_options ) ? self::prep_answer_options( $QST_options ) : array(); |
|
568 | + $QST_options = $QFI->options(true, $answer); |
|
569 | + $options = is_array($QST_options) ? self::prep_answer_options($QST_options) : array(); |
|
570 | 570 | $system_ID = $QFI->get('QST_system'); |
571 | - $label_b4 = $QFI->get_meta( 'label_b4' ); |
|
572 | - $use_desc_4_label = $QFI->get_meta( 'use_desc_4_label' ); |
|
571 | + $label_b4 = $QFI->get_meta('label_b4'); |
|
572 | + $use_desc_4_label = $QFI->get_meta('use_desc_4_label'); |
|
573 | 573 | |
574 | 574 | |
575 | - switch ( $QFI->get('QST_type') ){ |
|
575 | + switch ($QFI->get('QST_type')) { |
|
576 | 576 | |
577 | 577 | case 'TEXTAREA' : |
578 | - return EEH_Form_Fields::textarea( $display_text, $answer, $input_name, $input_id, $input_class, array(), $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities ); |
|
578 | + return EEH_Form_Fields::textarea($display_text, $answer, $input_name, $input_id, $input_class, array(), $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities); |
|
579 | 579 | break; |
580 | 580 | |
581 | 581 | case 'DROPDOWN' : |
582 | - return EEH_Form_Fields::select( $display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities, TRUE ); |
|
582 | + return EEH_Form_Fields::select($display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities, TRUE); |
|
583 | 583 | break; |
584 | 584 | |
585 | 585 | |
586 | 586 | case 'RADIO_BTN' : |
587 | - return EEH_Form_Fields::radio( $display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities, $label_b4, $use_desc_4_label ); |
|
587 | + return EEH_Form_Fields::radio($display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities, $label_b4, $use_desc_4_label); |
|
588 | 588 | break; |
589 | 589 | |
590 | 590 | case 'CHECKBOX' : |
591 | - return EEH_Form_Fields::checkbox( $display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities ); |
|
591 | + return EEH_Form_Fields::checkbox($display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities); |
|
592 | 592 | break; |
593 | 593 | |
594 | 594 | case 'DATE' : |
595 | - return EEH_Form_Fields::datepicker( $display_text, $answer, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities ); |
|
595 | + return EEH_Form_Fields::datepicker($display_text, $answer, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities); |
|
596 | 596 | break; |
597 | 597 | |
598 | 598 | case 'TEXT' : |
599 | 599 | default: |
600 | - return EEH_Form_Fields::text( $display_text, $answer, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities ); |
|
600 | + return EEH_Form_Fields::text($display_text, $answer, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities); |
|
601 | 601 | break; |
602 | 602 | |
603 | 603 | } |
@@ -623,31 +623,31 @@ discard block |
||
623 | 623 | * @param string $disabled disabled="disabled" or null |
624 | 624 | * @return string HTML |
625 | 625 | */ |
626 | - static function text( $question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE ) { |
|
626 | + static function text($question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE) { |
|
627 | 627 | // need these |
628 | - if ( ! $question || ! $name ) { |
|
628 | + if ( ! $question || ! $name) { |
|
629 | 629 | return NULL; |
630 | 630 | } |
631 | 631 | // prep the answer |
632 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
632 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
633 | 633 | // prep the required array |
634 | - $required = self::prep_required( $required ); |
|
634 | + $required = self::prep_required($required); |
|
635 | 635 | // set disabled tag |
636 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
636 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
637 | 637 | // ya gots ta have style man!!! |
638 | 638 | $txt_class = is_admin() ? 'regular-text' : 'espresso-text-inp'; |
639 | - $class = empty( $class ) ? $txt_class : $class; |
|
640 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
641 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
639 | + $class = empty($class) ? $txt_class : $class; |
|
640 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
641 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
642 | 642 | |
643 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
643 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
644 | 644 | // filter label but ensure required text comes before it |
645 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
645 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
646 | 646 | |
647 | - $input_html = "\n\t\t\t" . '<input type="text" name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" value="' . $answer . '" title="' . esc_attr( $required['msg'] ) . '" ' . $disabled .' ' . $extra . '/>'; |
|
647 | + $input_html = "\n\t\t\t".'<input type="text" name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].'" value="'.$answer.'" title="'.esc_attr($required['msg']).'" '.$disabled.' '.$extra.'/>'; |
|
648 | 648 | |
649 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
650 | - return $label_html . $input_html; |
|
649 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
650 | + return $label_html.$input_html; |
|
651 | 651 | |
652 | 652 | } |
653 | 653 | |
@@ -669,35 +669,35 @@ discard block |
||
669 | 669 | * @param string $disabled disabled="disabled" or null |
670 | 670 | * @return string HTML |
671 | 671 | */ |
672 | - static function textarea( $question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $dimensions = FALSE, $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE ) { |
|
672 | + static function textarea($question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $dimensions = FALSE, $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE) { |
|
673 | 673 | // need these |
674 | - if ( ! $question || ! $name ) { |
|
674 | + if ( ! $question || ! $name) { |
|
675 | 675 | return NULL; |
676 | 676 | } |
677 | 677 | // prep the answer |
678 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
678 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
679 | 679 | // prep the required array |
680 | - $required = self::prep_required( $required ); |
|
680 | + $required = self::prep_required($required); |
|
681 | 681 | // make sure $dimensions is an array |
682 | - $dimensions = is_array( $dimensions ) ? $dimensions : array(); |
|
682 | + $dimensions = is_array($dimensions) ? $dimensions : array(); |
|
683 | 683 | // and set some defaults |
684 | - $dimensions = array_merge( array( 'rows' => 3, 'cols' => 40 ), $dimensions ); |
|
684 | + $dimensions = array_merge(array('rows' => 3, 'cols' => 40), $dimensions); |
|
685 | 685 | // set disabled tag |
686 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
686 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
687 | 687 | // ya gots ta have style man!!! |
688 | 688 | $txt_class = is_admin() ? 'regular-text' : 'espresso-textarea-inp'; |
689 | - $class = empty( $class ) ? $txt_class : $class; |
|
690 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
691 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
689 | + $class = empty($class) ? $txt_class : $class; |
|
690 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
691 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
692 | 692 | |
693 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
693 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
694 | 694 | // filter label but ensure required text comes before it |
695 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
695 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
696 | 696 | |
697 | - $input_html = "\n\t\t\t" . '<textarea name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" rows="' . $dimensions['rows'] . '" cols="' . $dimensions['cols'] . '" title="' . $required['msg'] . '" ' . $disabled . ' ' . $extra . '>' . $answer . '</textarea>'; |
|
697 | + $input_html = "\n\t\t\t".'<textarea name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].'" rows="'.$dimensions['rows'].'" cols="'.$dimensions['cols'].'" title="'.$required['msg'].'" '.$disabled.' '.$extra.'>'.$answer.'</textarea>'; |
|
698 | 698 | |
699 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
700 | - return $label_html . $input_html; |
|
699 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
700 | + return $label_html.$input_html; |
|
701 | 701 | |
702 | 702 | } |
703 | 703 | |
@@ -720,47 +720,47 @@ discard block |
||
720 | 720 | * @param string $disabled disabled="disabled" or null |
721 | 721 | * @return string HTML |
722 | 722 | */ |
723 | - static function select( $question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE, $add_please_select_option = FALSE ) { |
|
723 | + static function select($question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE, $add_please_select_option = FALSE) { |
|
724 | 724 | |
725 | 725 | // need these |
726 | - if ( ! $question || ! $name || ! $options || empty( $options ) || ! is_array( $options )) { |
|
726 | + if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) { |
|
727 | 727 | return NULL; |
728 | 728 | } |
729 | 729 | // prep the answer |
730 | - $answer = is_array( $answer ) ? self::prep_answer( array_shift( $answer )) : self::prep_answer( $answer, $use_html_entities ); |
|
730 | + $answer = is_array($answer) ? self::prep_answer(array_shift($answer)) : self::prep_answer($answer, $use_html_entities); |
|
731 | 731 | // prep the required array |
732 | - $required = self::prep_required( $required ); |
|
732 | + $required = self::prep_required($required); |
|
733 | 733 | // set disabled tag |
734 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
734 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
735 | 735 | // ya gots ta have style man!!! |
736 | 736 | $txt_class = is_admin() ? 'wide' : 'espresso-select-inp'; |
737 | - $class = empty( $class ) ? $txt_class : $class; |
|
738 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
739 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
737 | + $class = empty($class) ? $txt_class : $class; |
|
738 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
739 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
740 | 740 | |
741 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
741 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
742 | 742 | // filter label but ensure required text comes before it |
743 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
743 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
744 | 744 | |
745 | - $input_html = "\n\t\t\t" . '<select name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" title="' . esc_attr( $required['msg'] ) . '"' . $disabled . ' ' . $extra . '>'; |
|
745 | + $input_html = "\n\t\t\t".'<select name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].'" title="'.esc_attr($required['msg']).'"'.$disabled.' '.$extra.'>'; |
|
746 | 746 | // recursively count array elements, to determine total number of options |
747 | - $only_option = count( $options, 1 ) == 1 ? TRUE : FALSE; |
|
748 | - if ( ! $only_option ) { |
|
747 | + $only_option = count($options, 1) == 1 ? TRUE : FALSE; |
|
748 | + if ( ! $only_option) { |
|
749 | 749 | // if there is NO answer set and there are multiple options to choose from, then set the "please select" message as selected |
750 | 750 | $selected = $answer === NULL ? ' selected="selected"' : ''; |
751 | - $input_html .= $add_please_select_option ? "\n\t\t\t\t" . '<option value=""' . $selected . '>' . __(' - please select - ', 'event_espresso') . '</option>' : ''; |
|
751 | + $input_html .= $add_please_select_option ? "\n\t\t\t\t".'<option value=""'.$selected.'>'.__(' - please select - ', 'event_espresso').'</option>' : ''; |
|
752 | 752 | } |
753 | - foreach ( $options as $key => $value ) { |
|
753 | + foreach ($options as $key => $value) { |
|
754 | 754 | // if value is an array, then create option groups, else create regular ol' options |
755 | - $input_html .= is_array( $value ) ? self::_generate_select_option_group( $key, $value, $answer ) : self::_generate_select_option( $value->value(), $value->desc(), $answer, $only_option ); |
|
755 | + $input_html .= is_array($value) ? self::_generate_select_option_group($key, $value, $answer) : self::_generate_select_option($value->value(), $value->desc(), $answer, $only_option); |
|
756 | 756 | } |
757 | 757 | |
758 | - $input_html .= "\n\t\t\t" . '</select>'; |
|
758 | + $input_html .= "\n\t\t\t".'</select>'; |
|
759 | 759 | |
760 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__select__before_end_wrapper', $input_html, $question, $answer, $name, $id, $class, $system_ID ); |
|
760 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__select__before_end_wrapper', $input_html, $question, $answer, $name, $id, $class, $system_ID); |
|
761 | 761 | |
762 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
763 | - return $label_html . $input_html; |
|
762 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
763 | + return $label_html.$input_html; |
|
764 | 764 | |
765 | 765 | } |
766 | 766 | |
@@ -777,12 +777,12 @@ discard block |
||
777 | 777 | * @param mixed $answer |
778 | 778 | * @return string |
779 | 779 | */ |
780 | - private static function _generate_select_option_group( $opt_group, $QSOs, $answer ){ |
|
781 | - $html = "\n\t\t\t\t" . '<optgroup label="' . self::prep_option_value( $opt_group ) . '">'; |
|
782 | - foreach ( $QSOs as $QSO ) { |
|
783 | - $html .= self::_generate_select_option( $QSO->value(), $QSO->desc(), $answer ); |
|
780 | + private static function _generate_select_option_group($opt_group, $QSOs, $answer) { |
|
781 | + $html = "\n\t\t\t\t".'<optgroup label="'.self::prep_option_value($opt_group).'">'; |
|
782 | + foreach ($QSOs as $QSO) { |
|
783 | + $html .= self::_generate_select_option($QSO->value(), $QSO->desc(), $answer); |
|
784 | 784 | } |
785 | - $html .= "\n\t\t\t\t" . '</optgroup>'; |
|
785 | + $html .= "\n\t\t\t\t".'</optgroup>'; |
|
786 | 786 | return $html; |
787 | 787 | } |
788 | 788 | |
@@ -796,12 +796,12 @@ discard block |
||
796 | 796 | * @param int $only_option |
797 | 797 | * @return string |
798 | 798 | */ |
799 | - private static function _generate_select_option( $key, $value, $answer, $only_option = FALSE ){ |
|
800 | - $key = self::prep_answer( $key ); |
|
801 | - $value = self::prep_answer( $value ); |
|
802 | - $value = ! empty( $value ) ? $value : $key; |
|
803 | - $selected = ( $answer == $key || $only_option ) ? ' selected="selected"' : ''; |
|
804 | - return "\n\t\t\t\t" . '<option value="' . self::prep_option_value( $key ) . '"' . $selected . '> ' . $value . ' </option>'; |
|
799 | + private static function _generate_select_option($key, $value, $answer, $only_option = FALSE) { |
|
800 | + $key = self::prep_answer($key); |
|
801 | + $value = self::prep_answer($value); |
|
802 | + $value = ! empty($value) ? $value : $key; |
|
803 | + $selected = ($answer == $key || $only_option) ? ' selected="selected"' : ''; |
|
804 | + return "\n\t\t\t\t".'<option value="'.self::prep_option_value($key).'"'.$selected.'> '.$value.' </option>'; |
|
805 | 805 | } |
806 | 806 | |
807 | 807 | |
@@ -825,56 +825,56 @@ discard block |
||
825 | 825 | * @param bool $use_desc_4_label |
826 | 826 | * @return string HTML |
827 | 827 | */ |
828 | - static function radio( $question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE, $label_b4 = FALSE, $use_desc_4_label = FALSE ) { |
|
828 | + static function radio($question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE, $label_b4 = FALSE, $use_desc_4_label = FALSE) { |
|
829 | 829 | // need these |
830 | - if ( ! $question || ! $name || ! $options || empty( $options ) || ! is_array( $options )) { |
|
830 | + if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) { |
|
831 | 831 | return NULL; |
832 | 832 | } |
833 | 833 | // prep the answer |
834 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
834 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
835 | 835 | // prep the required array |
836 | - $required = self::prep_required( $required ); |
|
836 | + $required = self::prep_required($required); |
|
837 | 837 | // set disabled tag |
838 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
838 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
839 | 839 | // ya gots ta have style man!!! |
840 | 840 | $radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class; |
841 | - $class = ! empty( $class ) ? $class : 'espresso-radio-btn-inp'; |
|
842 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
841 | + $class = ! empty($class) ? $class : 'espresso-radio-btn-inp'; |
|
842 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
843 | 843 | |
844 | - $label_html = $required_text . "\n\t\t\t" . '<label class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label> '; |
|
844 | + $label_html = $required_text."\n\t\t\t".'<label class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label> '; |
|
845 | 845 | // filter label but ensure required text comes before it |
846 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
846 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
847 | 847 | |
848 | - $input_html = "\n\t\t\t" . '<ul id="' . $id . '-ul" class="espresso-radio-btn-options-ul ' . $label_class . ' ' . $class . '-ul">'; |
|
848 | + $input_html = "\n\t\t\t".'<ul id="'.$id.'-ul" class="espresso-radio-btn-options-ul '.$label_class.' '.$class.'-ul">'; |
|
849 | 849 | |
850 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
851 | - $class .= ! empty( $required['class'] ) ? ' ' . $required['class'] : ''; |
|
850 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
851 | + $class .= ! empty($required['class']) ? ' '.$required['class'] : ''; |
|
852 | 852 | |
853 | - foreach ( $options as $OPT ) { |
|
854 | - if ( $OPT instanceof EE_Question_Option ) { |
|
855 | - $value = self::prep_option_value( $OPT->value() ); |
|
853 | + foreach ($options as $OPT) { |
|
854 | + if ($OPT instanceof EE_Question_Option) { |
|
855 | + $value = self::prep_option_value($OPT->value()); |
|
856 | 856 | $label = $use_desc_4_label ? $OPT->desc() : $OPT->value(); |
857 | - $size = $use_desc_4_label ? self::get_label_size_class( $OPT->value() . ' ' . $OPT->desc() ) : self::get_label_size_class( $OPT->value() ); |
|
858 | - $desc = $OPT->desc();//no self::prep_answer |
|
859 | - $answer = is_numeric( $value ) && empty( $answer ) ? 0 : $answer; |
|
860 | - $checked = (string)$value == (string)$answer ? ' checked="checked"' : ''; |
|
861 | - $opt = '-' . sanitize_key( $value ); |
|
862 | - |
|
863 | - $input_html .= "\n\t\t\t\t" . '<li' . $size . '>'; |
|
864 | - $input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-radio-btn-lbl">'; |
|
865 | - $input_html .= $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $label . '</span>' : ''; |
|
866 | - $input_html .= "\n\t\t\t\t\t\t" . '<input type="radio" name="' . $name . '" id="' . $id . $opt . '" class="' . $class . '" value="' . $value . '" title="' . esc_attr( $required['msg'] ) . '" ' . $disabled . $checked . ' ' . $extra . '/>'; |
|
867 | - $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t" . '<span class="espresso-radio-btn-desc">' . $label . '</span>' : ''; |
|
868 | - $input_html .= "\n\t\t\t\t\t" . '</label>'; |
|
869 | - $input_html .= $use_desc_4_label ? '' : '<span class="espresso-radio-btn-option-desc small-text grey-text">' . $desc . '</span>'; |
|
870 | - $input_html .= "\n\t\t\t\t" . '</li>'; |
|
857 | + $size = $use_desc_4_label ? self::get_label_size_class($OPT->value().' '.$OPT->desc()) : self::get_label_size_class($OPT->value()); |
|
858 | + $desc = $OPT->desc(); //no self::prep_answer |
|
859 | + $answer = is_numeric($value) && empty($answer) ? 0 : $answer; |
|
860 | + $checked = (string) $value == (string) $answer ? ' checked="checked"' : ''; |
|
861 | + $opt = '-'.sanitize_key($value); |
|
862 | + |
|
863 | + $input_html .= "\n\t\t\t\t".'<li'.$size.'>'; |
|
864 | + $input_html .= "\n\t\t\t\t\t".'<label class="'.$radio_class.' espresso-radio-btn-lbl">'; |
|
865 | + $input_html .= $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$label.'</span>' : ''; |
|
866 | + $input_html .= "\n\t\t\t\t\t\t".'<input type="radio" name="'.$name.'" id="'.$id.$opt.'" class="'.$class.'" value="'.$value.'" title="'.esc_attr($required['msg']).'" '.$disabled.$checked.' '.$extra.'/>'; |
|
867 | + $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t".'<span class="espresso-radio-btn-desc">'.$label.'</span>' : ''; |
|
868 | + $input_html .= "\n\t\t\t\t\t".'</label>'; |
|
869 | + $input_html .= $use_desc_4_label ? '' : '<span class="espresso-radio-btn-option-desc small-text grey-text">'.$desc.'</span>'; |
|
870 | + $input_html .= "\n\t\t\t\t".'</li>'; |
|
871 | 871 | } |
872 | 872 | } |
873 | 873 | |
874 | - $input_html .= "\n\t\t\t" . '</ul>'; |
|
874 | + $input_html .= "\n\t\t\t".'</ul>'; |
|
875 | 875 | |
876 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
877 | - return $label_html . $input_html; |
|
876 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
877 | + return $label_html.$input_html; |
|
878 | 878 | |
879 | 879 | } |
880 | 880 | |
@@ -897,65 +897,65 @@ discard block |
||
897 | 897 | * @param string $disabled disabled="disabled" or null |
898 | 898 | * @return string HTML |
899 | 899 | */ |
900 | - static function checkbox( $question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $label_b4 = FALSE, $system_ID = FALSE, $use_html_entities = TRUE ) { |
|
900 | + static function checkbox($question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $label_b4 = FALSE, $system_ID = FALSE, $use_html_entities = TRUE) { |
|
901 | 901 | // need these |
902 | - if ( ! $question || ! $name || ! $options || empty( $options ) || ! is_array( $options )) { |
|
902 | + if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) { |
|
903 | 903 | return NULL; |
904 | 904 | } |
905 | - $answer = maybe_unserialize( $answer ); |
|
905 | + $answer = maybe_unserialize($answer); |
|
906 | 906 | |
907 | 907 | // prep the answer(s) |
908 | - $answer = is_array( $answer ) ? $answer : array( sanitize_key( $answer ) => $answer ); |
|
908 | + $answer = is_array($answer) ? $answer : array(sanitize_key($answer) => $answer); |
|
909 | 909 | |
910 | - foreach ( $answer as $key => $value ) { |
|
911 | - $key = self::prep_option_value( $key ); |
|
912 | - $answer[$key] = self::prep_answer( $value ); |
|
910 | + foreach ($answer as $key => $value) { |
|
911 | + $key = self::prep_option_value($key); |
|
912 | + $answer[$key] = self::prep_answer($value); |
|
913 | 913 | } |
914 | 914 | |
915 | 915 | // prep the required array |
916 | - $required = self::prep_required( $required ); |
|
916 | + $required = self::prep_required($required); |
|
917 | 917 | // set disabled tag |
918 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
918 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
919 | 919 | // ya gots ta have style man!!! |
920 | 920 | $radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class; |
921 | - $class = empty( $class ) ? 'espresso-radio-btn-inp' : $class; |
|
922 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
921 | + $class = empty($class) ? 'espresso-radio-btn-inp' : $class; |
|
922 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
923 | 923 | |
924 | - $label_html = $required_text . "\n\t\t\t" . '<label class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label> '; |
|
924 | + $label_html = $required_text."\n\t\t\t".'<label class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label> '; |
|
925 | 925 | // filter label but ensure required text comes before it |
926 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
927 | - |
|
928 | - $input_html = "\n\t\t\t" . '<ul id="' . $id . '-ul" class="espresso-checkbox-options-ul ' . $label_class . ' ' . $class . '-ul">'; |
|
929 | - |
|
930 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
931 | - $class .= ! empty( $required['class'] ) ? ' ' . $required['class'] : ''; |
|
932 | - |
|
933 | - foreach ( $options as $OPT ) { |
|
934 | - $value = $OPT->value();//self::prep_option_value( $OPT->value() ); |
|
935 | - $size = self::get_label_size_class( $OPT->value() . ' ' . $OPT->desc() ); |
|
936 | - $text = self::prep_answer( $OPT->value() ); |
|
937 | - $desc = $OPT->desc() ; |
|
938 | - $opt = '-' . sanitize_key( $value ); |
|
939 | - |
|
940 | - $checked = is_array( $answer ) && in_array( $text, $answer ) ? ' checked="checked"' : ''; |
|
941 | - |
|
942 | - $input_html .= "\n\t\t\t\t" . '<li' . $size . '>'; |
|
943 | - $input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-checkbox-lbl">'; |
|
944 | - $input_html .= $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : ''; |
|
945 | - $input_html .= "\n\t\t\t\t\t\t" . '<input type="checkbox" name="' . $name . '[' . $OPT->ID() . ']" id="' . $id . $opt . '" class="' . $class . '" value="' . $value . '" title="' . esc_attr( $required['msg'] ) . '" ' . $disabled . $checked . ' ' . $extra . '/>'; |
|
946 | - $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : ''; |
|
947 | - $input_html .= "\n\t\t\t\t\t" . '</label>'; |
|
948 | - if ( ! empty( $desc ) && $desc != $text ) { |
|
949 | - $input_html .= "\n\t\t\t\t\t" . ' <br/><div class="espresso-checkbox-option-desc small-text grey-text">' . $desc . '</div>'; |
|
926 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
927 | + |
|
928 | + $input_html = "\n\t\t\t".'<ul id="'.$id.'-ul" class="espresso-checkbox-options-ul '.$label_class.' '.$class.'-ul">'; |
|
929 | + |
|
930 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
931 | + $class .= ! empty($required['class']) ? ' '.$required['class'] : ''; |
|
932 | + |
|
933 | + foreach ($options as $OPT) { |
|
934 | + $value = $OPT->value(); //self::prep_option_value( $OPT->value() ); |
|
935 | + $size = self::get_label_size_class($OPT->value().' '.$OPT->desc()); |
|
936 | + $text = self::prep_answer($OPT->value()); |
|
937 | + $desc = $OPT->desc(); |
|
938 | + $opt = '-'.sanitize_key($value); |
|
939 | + |
|
940 | + $checked = is_array($answer) && in_array($text, $answer) ? ' checked="checked"' : ''; |
|
941 | + |
|
942 | + $input_html .= "\n\t\t\t\t".'<li'.$size.'>'; |
|
943 | + $input_html .= "\n\t\t\t\t\t".'<label class="'.$radio_class.' espresso-checkbox-lbl">'; |
|
944 | + $input_html .= $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$text.'</span>' : ''; |
|
945 | + $input_html .= "\n\t\t\t\t\t\t".'<input type="checkbox" name="'.$name.'['.$OPT->ID().']" id="'.$id.$opt.'" class="'.$class.'" value="'.$value.'" title="'.esc_attr($required['msg']).'" '.$disabled.$checked.' '.$extra.'/>'; |
|
946 | + $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$text.'</span>' : ''; |
|
947 | + $input_html .= "\n\t\t\t\t\t".'</label>'; |
|
948 | + if ( ! empty($desc) && $desc != $text) { |
|
949 | + $input_html .= "\n\t\t\t\t\t".' <br/><div class="espresso-checkbox-option-desc small-text grey-text">'.$desc.'</div>'; |
|
950 | 950 | } |
951 | - $input_html .= "\n\t\t\t\t" . '</li>'; |
|
951 | + $input_html .= "\n\t\t\t\t".'</li>'; |
|
952 | 952 | |
953 | 953 | } |
954 | 954 | |
955 | - $input_html .= "\n\t\t\t" . '</ul>'; |
|
955 | + $input_html .= "\n\t\t\t".'</ul>'; |
|
956 | 956 | |
957 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
958 | - return $label_html . $input_html; |
|
957 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
958 | + return $label_html.$input_html; |
|
959 | 959 | |
960 | 960 | } |
961 | 961 | |
@@ -977,36 +977,36 @@ discard block |
||
977 | 977 | * @param string $disabled disabled="disabled" or null |
978 | 978 | * @return string HTML |
979 | 979 | */ |
980 | - static function datepicker( $question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE ) { |
|
980 | + static function datepicker($question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE) { |
|
981 | 981 | // need these |
982 | - if ( ! $question || ! $name ) { |
|
982 | + if ( ! $question || ! $name) { |
|
983 | 983 | return NULL; |
984 | 984 | } |
985 | 985 | // prep the answer |
986 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
986 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
987 | 987 | // prep the required array |
988 | - $required = self::prep_required( $required ); |
|
988 | + $required = self::prep_required($required); |
|
989 | 989 | // set disabled tag |
990 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
990 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
991 | 991 | // ya gots ta have style man!!! |
992 | 992 | $txt_class = is_admin() ? 'regular-text' : 'espresso-datepicker-inp'; |
993 | - $class = empty( $class ) ? $txt_class : $class; |
|
994 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
995 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
993 | + $class = empty($class) ? $txt_class : $class; |
|
994 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
995 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
996 | 996 | |
997 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
997 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
998 | 998 | // filter label but ensure required text comes before it |
999 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
999 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
1000 | 1000 | |
1001 | - $input_html = "\n\t\t\t" . '<input type="text" name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . ' datepicker" value="' . $answer . '" title="' . esc_attr( $required['msg'] ) . '" ' . $disabled . ' ' . $extra . '/>'; |
|
1001 | + $input_html = "\n\t\t\t".'<input type="text" name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].' datepicker" value="'.$answer.'" title="'.esc_attr($required['msg']).'" '.$disabled.' '.$extra.'/>'; |
|
1002 | 1002 | |
1003 | 1003 | // enqueue scripts |
1004 | - wp_register_style( 'espresso-ui-theme', EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION ); |
|
1005 | - wp_enqueue_style( 'espresso-ui-theme'); |
|
1006 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
1004 | + wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL.'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION); |
|
1005 | + wp_enqueue_style('espresso-ui-theme'); |
|
1006 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
1007 | 1007 | |
1008 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
1009 | - return $label_html . $input_html; |
|
1008 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
1009 | + return $label_html.$input_html; |
|
1010 | 1010 | |
1011 | 1011 | } |
1012 | 1012 | |
@@ -1018,7 +1018,7 @@ discard block |
||
1018 | 1018 | * @access public |
1019 | 1019 | * @return string |
1020 | 1020 | */ |
1021 | - public static function remove_label_keep_required_msg( $label_html, $required_text ) { |
|
1021 | + public static function remove_label_keep_required_msg($label_html, $required_text) { |
|
1022 | 1022 | return $required_text; |
1023 | 1023 | } |
1024 | 1024 | |
@@ -1032,9 +1032,9 @@ discard block |
||
1032 | 1032 | * @param string $value |
1033 | 1033 | * @return string HTML |
1034 | 1034 | */ |
1035 | - static function hidden_input( $name, $value, $id = '' ){ |
|
1036 | - $id = ! empty( $id ) ? $id : $name; |
|
1037 | - return '<input id="' . $id . '" type="hidden" name="'.$name.'" value="' . $value . '"/>'; |
|
1035 | + static function hidden_input($name, $value, $id = '') { |
|
1036 | + $id = ! empty($id) ? $id : $name; |
|
1037 | + return '<input id="'.$id.'" type="hidden" name="'.$name.'" value="'.$value.'"/>'; |
|
1038 | 1038 | } |
1039 | 1039 | |
1040 | 1040 | |
@@ -1046,7 +1046,7 @@ discard block |
||
1046 | 1046 | * @param string $question |
1047 | 1047 | * @return string |
1048 | 1048 | */ |
1049 | - static function prep_question( $question ){ |
|
1049 | + static function prep_question($question) { |
|
1050 | 1050 | return $question; |
1051 | 1051 | // $link = ''; |
1052 | 1052 | // // does this label have a help link attached ? |
@@ -1069,13 +1069,13 @@ discard block |
||
1069 | 1069 | * @param mixed $answer |
1070 | 1070 | * @return string |
1071 | 1071 | */ |
1072 | - static function prep_answer( $answer, $use_html_entities = TRUE ){ |
|
1072 | + static function prep_answer($answer, $use_html_entities = TRUE) { |
|
1073 | 1073 | //make sure we convert bools first. Otherwise (bool) false becomes an empty string which is NOT desired, we want "0". |
1074 | - if ( is_bool( $answer ) ) { |
|
1074 | + if (is_bool($answer)) { |
|
1075 | 1075 | $answer = $answer ? 1 : 0; |
1076 | 1076 | } |
1077 | - $answer = trim( stripslashes( str_replace( ''', "'", $answer ))); |
|
1078 | - return $use_html_entities ? htmlentities( $answer, ENT_QUOTES, 'UTF-8' ) : $answer; |
|
1077 | + $answer = trim(stripslashes(str_replace(''', "'", $answer))); |
|
1078 | + return $use_html_entities ? htmlentities($answer, ENT_QUOTES, 'UTF-8') : $answer; |
|
1079 | 1079 | } |
1080 | 1080 | |
1081 | 1081 | |
@@ -1085,18 +1085,18 @@ discard block |
||
1085 | 1085 | * @param array $QSOs array of EE_Question_Option objects |
1086 | 1086 | * @return array |
1087 | 1087 | */ |
1088 | - public static function prep_answer_options( $QSOs = array() ){ |
|
1088 | + public static function prep_answer_options($QSOs = array()) { |
|
1089 | 1089 | $prepped_answer_options = array(); |
1090 | - if ( is_array( $QSOs ) && ! empty( $QSOs )) { |
|
1091 | - foreach( $QSOs as $key => $QSO ) { |
|
1092 | - if ( ! $QSO instanceof EE_Question_Option ) { |
|
1093 | - $QSO = EE_Question_Option::new_instance( array( |
|
1094 | - 'QSO_value' => is_array( $QSO ) && isset( $QSO['id'] ) ? (string)$QSO['id'] : (string)$key, |
|
1095 | - 'QSO_desc' => is_array( $QSO ) && isset( $QSO['text'] ) ? (string)$QSO['text'] : (string)$QSO |
|
1090 | + if (is_array($QSOs) && ! empty($QSOs)) { |
|
1091 | + foreach ($QSOs as $key => $QSO) { |
|
1092 | + if ( ! $QSO instanceof EE_Question_Option) { |
|
1093 | + $QSO = EE_Question_Option::new_instance(array( |
|
1094 | + 'QSO_value' => is_array($QSO) && isset($QSO['id']) ? (string) $QSO['id'] : (string) $key, |
|
1095 | + 'QSO_desc' => is_array($QSO) && isset($QSO['text']) ? (string) $QSO['text'] : (string) $QSO |
|
1096 | 1096 | )); |
1097 | 1097 | } |
1098 | - if ( $QSO->opt_group() ) { |
|
1099 | - $prepped_answer_options[ $QSO->opt_group() ][] = $QSO; |
|
1098 | + if ($QSO->opt_group()) { |
|
1099 | + $prepped_answer_options[$QSO->opt_group()][] = $QSO; |
|
1100 | 1100 | } else { |
1101 | 1101 | $prepped_answer_options[] = $QSO; |
1102 | 1102 | } |
@@ -1112,8 +1112,8 @@ discard block |
||
1112 | 1112 | * @param string $option_value |
1113 | 1113 | * @return string |
1114 | 1114 | */ |
1115 | - static function prep_option_value( $option_value ){ |
|
1116 | - return trim( stripslashes( $option_value )); |
|
1115 | + static function prep_option_value($option_value) { |
|
1116 | + return trim(stripslashes($option_value)); |
|
1117 | 1117 | } |
1118 | 1118 | |
1119 | 1119 | |
@@ -1124,11 +1124,11 @@ discard block |
||
1124 | 1124 | * @param string|array $required |
1125 | 1125 | * @return array |
1126 | 1126 | */ |
1127 | - static function prep_required( $required = array() ){ |
|
1127 | + static function prep_required($required = array()) { |
|
1128 | 1128 | // make sure required is an array |
1129 | - $required = is_array( $required ) ? $required : array(); |
|
1129 | + $required = is_array($required) ? $required : array(); |
|
1130 | 1130 | // and set some defaults |
1131 | - $required = array_merge( array( 'label' => '', 'class' => '', 'msg' => '' ), $required ); |
|
1131 | + $required = array_merge(array('label' => '', 'class' => '', 'msg' => ''), $required); |
|
1132 | 1132 | return $required; |
1133 | 1133 | } |
1134 | 1134 | |
@@ -1139,30 +1139,30 @@ discard block |
||
1139 | 1139 | * @param string $value |
1140 | 1140 | * @return string |
1141 | 1141 | */ |
1142 | - static function get_label_size_class( $value = FALSE ){ |
|
1143 | - if ( $value === FALSE || $value == '' ) { |
|
1142 | + static function get_label_size_class($value = FALSE) { |
|
1143 | + if ($value === FALSE || $value == '') { |
|
1144 | 1144 | return ' class="medium-lbl"'; |
1145 | 1145 | } |
1146 | 1146 | // determine length of option value |
1147 | - $val_size = strlen( $value ); |
|
1148 | - switch( $val_size ){ |
|
1147 | + $val_size = strlen($value); |
|
1148 | + switch ($val_size) { |
|
1149 | 1149 | case $val_size < 3 : |
1150 | - $size = ' class="nano-lbl"'; |
|
1150 | + $size = ' class="nano-lbl"'; |
|
1151 | 1151 | break; |
1152 | 1152 | case $val_size < 6 : |
1153 | - $size = ' class="micro-lbl"'; |
|
1153 | + $size = ' class="micro-lbl"'; |
|
1154 | 1154 | break; |
1155 | 1155 | case $val_size < 12 : |
1156 | - $size = ' class="tiny-lbl"'; |
|
1156 | + $size = ' class="tiny-lbl"'; |
|
1157 | 1157 | break; |
1158 | 1158 | case $val_size < 25 : |
1159 | - $size = ' class="small-lbl"'; |
|
1159 | + $size = ' class="small-lbl"'; |
|
1160 | 1160 | break; |
1161 | 1161 | case $val_size > 100 : |
1162 | - $size = ' class="big-lbl"'; |
|
1162 | + $size = ' class="big-lbl"'; |
|
1163 | 1163 | break; |
1164 | 1164 | default: |
1165 | - $size = ' class="medium-lbl"'; |
|
1165 | + $size = ' class="medium-lbl"'; |
|
1166 | 1166 | break; |
1167 | 1167 | } |
1168 | 1168 | return $size; |
@@ -1176,20 +1176,20 @@ discard block |
||
1176 | 1176 | * @param array $QFI |
1177 | 1177 | * @return array |
1178 | 1178 | */ |
1179 | - private static function _load_system_dropdowns( $QFI ){ |
|
1179 | + private static function _load_system_dropdowns($QFI) { |
|
1180 | 1180 | $QST_system = $QFI->get('QST_system'); |
1181 | - switch ( $QST_system ) { |
|
1181 | + switch ($QST_system) { |
|
1182 | 1182 | case 'state' : |
1183 | - $QFI = self::generate_state_dropdown( $QFI ); |
|
1183 | + $QFI = self::generate_state_dropdown($QFI); |
|
1184 | 1184 | break; |
1185 | 1185 | case 'country' : |
1186 | - $QFI = self::generate_country_dropdown( $QFI ); |
|
1186 | + $QFI = self::generate_country_dropdown($QFI); |
|
1187 | 1187 | break; |
1188 | 1188 | case 'admin-state' : |
1189 | - $QFI = self::generate_state_dropdown( $QFI, TRUE ); |
|
1189 | + $QFI = self::generate_state_dropdown($QFI, TRUE); |
|
1190 | 1190 | break; |
1191 | 1191 | case 'admin-country' : |
1192 | - $QFI = self::generate_country_dropdown( $QFI, TRUE ); |
|
1192 | + $QFI = self::generate_country_dropdown($QFI, TRUE); |
|
1193 | 1193 | break; |
1194 | 1194 | } |
1195 | 1195 | return $QFI; |
@@ -1206,13 +1206,13 @@ discard block |
||
1206 | 1206 | * |
1207 | 1207 | * @return EE_Question_Form_Input |
1208 | 1208 | */ |
1209 | - protected static function _load_specialized_dropdowns( $QFI ) { |
|
1210 | - switch( $QFI->get( 'QST_type' ) ) { |
|
1209 | + protected static function _load_specialized_dropdowns($QFI) { |
|
1210 | + switch ($QFI->get('QST_type')) { |
|
1211 | 1211 | case 'STATE' : |
1212 | - $QFI = self::generate_state_dropdown( $QFI ); |
|
1212 | + $QFI = self::generate_state_dropdown($QFI); |
|
1213 | 1213 | break; |
1214 | 1214 | case 'COUNTRY' : |
1215 | - $QFI = self::generate_country_dropdown( $QFI ); |
|
1215 | + $QFI = self::generate_country_dropdown($QFI); |
|
1216 | 1216 | break; |
1217 | 1217 | } |
1218 | 1218 | return $QFI; |
@@ -1226,23 +1226,23 @@ discard block |
||
1226 | 1226 | * @param bool $get_all |
1227 | 1227 | * @return array |
1228 | 1228 | */ |
1229 | - public static function generate_state_dropdown( $QST, $get_all = FALSE ){ |
|
1229 | + public static function generate_state_dropdown($QST, $get_all = FALSE) { |
|
1230 | 1230 | $states = $get_all ? EEM_State::instance()->get_all_states() : EEM_State::instance()->get_all_states_of_active_countries(); |
1231 | - if ( $states && count( $states ) != count( $QST->options() )) { |
|
1232 | - $QST->set( 'QST_type', 'DROPDOWN' ); |
|
1231 | + if ($states && count($states) != count($QST->options())) { |
|
1232 | + $QST->set('QST_type', 'DROPDOWN'); |
|
1233 | 1233 | // if multiple countries, we'll create option groups within the dropdown |
1234 | - foreach ( $states as $state ) { |
|
1235 | - if ( $state instanceof EE_State ) { |
|
1236 | - $QSO = EE_Question_Option::new_instance ( array ( |
|
1234 | + foreach ($states as $state) { |
|
1235 | + if ($state instanceof EE_State) { |
|
1236 | + $QSO = EE_Question_Option::new_instance(array( |
|
1237 | 1237 | 'QSO_value' => $state->ID(), |
1238 | 1238 | 'QSO_desc' => $state->name(), |
1239 | - 'QST_ID' => $QST->get( 'QST_ID' ), |
|
1239 | + 'QST_ID' => $QST->get('QST_ID'), |
|
1240 | 1240 | 'QSO_deleted' => FALSE |
1241 | 1241 | )); |
1242 | 1242 | // set option group |
1243 | - $QSO->set_opt_group( $state->country()->name() ); |
|
1243 | + $QSO->set_opt_group($state->country()->name()); |
|
1244 | 1244 | // add option to question |
1245 | - $QST->add_temp_option( $QSO ); |
|
1245 | + $QST->add_temp_option($QSO); |
|
1246 | 1246 | } |
1247 | 1247 | } |
1248 | 1248 | } |
@@ -1258,20 +1258,20 @@ discard block |
||
1258 | 1258 | * @internal param array $question |
1259 | 1259 | * @return array |
1260 | 1260 | */ |
1261 | - public static function generate_country_dropdown( $QST, $get_all = FALSE ){ |
|
1261 | + public static function generate_country_dropdown($QST, $get_all = FALSE) { |
|
1262 | 1262 | $countries = $get_all ? EEM_Country::instance()->get_all_countries() : EEM_Country::instance()->get_all_active_countries(); |
1263 | - if ( $countries && count( $countries ) != count( $QST->options() ) ) { |
|
1264 | - $QST->set( 'QST_type', 'DROPDOWN' ); |
|
1263 | + if ($countries && count($countries) != count($QST->options())) { |
|
1264 | + $QST->set('QST_type', 'DROPDOWN'); |
|
1265 | 1265 | // now add countries |
1266 | - foreach ( $countries as $country ) { |
|
1267 | - if ( $country instanceof EE_Country ) { |
|
1268 | - $QSO = EE_Question_Option::new_instance ( array ( |
|
1266 | + foreach ($countries as $country) { |
|
1267 | + if ($country instanceof EE_Country) { |
|
1268 | + $QSO = EE_Question_Option::new_instance(array( |
|
1269 | 1269 | 'QSO_value' => $country->ID(), |
1270 | 1270 | 'QSO_desc' => $country->name(), |
1271 | - 'QST_ID' => $QST->get( 'QST_ID' ), |
|
1271 | + 'QST_ID' => $QST->get('QST_ID'), |
|
1272 | 1272 | 'QSO_deleted' => FALSE |
1273 | 1273 | )); |
1274 | - $QST->add_temp_option( $QSO ); |
|
1274 | + $QST->add_temp_option($QSO); |
|
1275 | 1275 | } |
1276 | 1276 | } |
1277 | 1277 | } |
@@ -1288,11 +1288,11 @@ discard block |
||
1288 | 1288 | */ |
1289 | 1289 | public static function two_digit_months_dropdown_options() { |
1290 | 1290 | $options = array(); |
1291 | - for ( $x = 1; $x <= 12; $x++ ) { |
|
1292 | - $mm = str_pad( $x, 2, '0', STR_PAD_LEFT ); |
|
1293 | - $options[ (string)$mm ] = (string)$mm; |
|
1291 | + for ($x = 1; $x <= 12; $x++) { |
|
1292 | + $mm = str_pad($x, 2, '0', STR_PAD_LEFT); |
|
1293 | + $options[(string) $mm] = (string) $mm; |
|
1294 | 1294 | } |
1295 | - return EEH_Form_Fields::prep_answer_options( $options ); |
|
1295 | + return EEH_Form_Fields::prep_answer_options($options); |
|
1296 | 1296 | } |
1297 | 1297 | |
1298 | 1298 | |
@@ -1307,11 +1307,11 @@ discard block |
||
1307 | 1307 | $options = array(); |
1308 | 1308 | $current_year = date('y'); |
1309 | 1309 | $next_decade = $current_year + 10; |
1310 | - for ( $x = $current_year; $x <= $next_decade; $x++ ) { |
|
1311 | - $yy = str_pad( $x, 2, '0', STR_PAD_LEFT ); |
|
1312 | - $options[ (string)$yy ] = (string)$yy; |
|
1310 | + for ($x = $current_year; $x <= $next_decade; $x++) { |
|
1311 | + $yy = str_pad($x, 2, '0', STR_PAD_LEFT); |
|
1312 | + $options[(string) $yy] = (string) $yy; |
|
1313 | 1313 | } |
1314 | - return EEH_Form_Fields::prep_answer_options( $options ); |
|
1314 | + return EEH_Form_Fields::prep_answer_options($options); |
|
1315 | 1315 | } |
1316 | 1316 | |
1317 | 1317 | |
@@ -1325,17 +1325,17 @@ discard block |
||
1325 | 1325 | * @param integer $evt_category Event Category ID if the Event Category filter is selected |
1326 | 1326 | * @return string html |
1327 | 1327 | */ |
1328 | - public static function generate_registration_months_dropdown( $cur_date = '', $status = '', $evt_category = 0 ) { |
|
1328 | + public static function generate_registration_months_dropdown($cur_date = '', $status = '', $evt_category = 0) { |
|
1329 | 1329 | $_where = array(); |
1330 | - if ( !empty( $status ) ) { |
|
1330 | + if ( ! empty($status)) { |
|
1331 | 1331 | $_where['STS_ID'] = $status; |
1332 | 1332 | } |
1333 | 1333 | |
1334 | - if ( $evt_category > 0 ) { |
|
1334 | + if ($evt_category > 0) { |
|
1335 | 1335 | $_where['Event.Term_Taxonomy.term_id'] = $evt_category; |
1336 | 1336 | } |
1337 | 1337 | |
1338 | - $regdtts = EEM_Registration::instance()->get_reg_months_and_years( $_where ); |
|
1338 | + $regdtts = EEM_Registration::instance()->get_reg_months_and_years($_where); |
|
1339 | 1339 | |
1340 | 1340 | //setup vals for select input helper |
1341 | 1341 | $options = array( |
@@ -1345,15 +1345,15 @@ discard block |
||
1345 | 1345 | ) |
1346 | 1346 | ); |
1347 | 1347 | |
1348 | - foreach ( $regdtts as $regdtt ) { |
|
1349 | - $date = $regdtt->reg_month. ' ' . $regdtt->reg_year; |
|
1348 | + foreach ($regdtts as $regdtt) { |
|
1349 | + $date = $regdtt->reg_month.' '.$regdtt->reg_year; |
|
1350 | 1350 | $options[] = array( |
1351 | 1351 | 'text' => $date, |
1352 | 1352 | 'id' => $date |
1353 | 1353 | ); |
1354 | 1354 | } |
1355 | 1355 | |
1356 | - return self::select_input('month_range', $options, $cur_date, '', 'wide' ); |
|
1356 | + return self::select_input('month_range', $options, $cur_date, '', 'wide'); |
|
1357 | 1357 | } |
1358 | 1358 | |
1359 | 1359 | |
@@ -1367,18 +1367,18 @@ discard block |
||
1367 | 1367 | * @param string $evt_active_status "upcoming", "expired", "active", or "inactive" |
1368 | 1368 | * @return string html |
1369 | 1369 | */ |
1370 | - public static function generate_event_months_dropdown( $cur_date = '', $status = NULL, $evt_category = NULL, $evt_active_status = NULL ) { |
|
1370 | + public static function generate_event_months_dropdown($cur_date = '', $status = NULL, $evt_category = NULL, $evt_active_status = NULL) { |
|
1371 | 1371 | //determine what post_status our condition will have for the query. |
1372 | - switch ( $status ) { |
|
1372 | + switch ($status) { |
|
1373 | 1373 | case 'month' : |
1374 | 1374 | case 'today' : |
1375 | 1375 | case NULL : |
1376 | 1376 | case 'all' : |
1377 | - $where['Event.status'] = array( 'NOT IN', array('trash') ); |
|
1377 | + $where['Event.status'] = array('NOT IN', array('trash')); |
|
1378 | 1378 | break; |
1379 | 1379 | |
1380 | 1380 | case 'draft' : |
1381 | - $where['Event.status'] = array( 'IN', array('draft', 'auto-draft') ); |
|
1381 | + $where['Event.status'] = array('IN', array('draft', 'auto-draft')); |
|
1382 | 1382 | |
1383 | 1383 | default : |
1384 | 1384 | $where['Event.status'] = $status; |
@@ -1387,7 +1387,7 @@ discard block |
||
1387 | 1387 | //categories? |
1388 | 1388 | |
1389 | 1389 | |
1390 | - if ( !empty ( $evt_category ) ) { |
|
1390 | + if ( ! empty ($evt_category)) { |
|
1391 | 1391 | $where['Event.Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
1392 | 1392 | $where['Event.Term_Taxonomy.term_id'] = $evt_category; |
1393 | 1393 | } |
@@ -1395,7 +1395,7 @@ discard block |
||
1395 | 1395 | |
1396 | 1396 | // $where['DTT_is_primary'] = 1; |
1397 | 1397 | |
1398 | - $DTTS = EE_Registry::instance()->load_model('Datetime')->get_dtt_months_and_years($where, $evt_active_status ); |
|
1398 | + $DTTS = EE_Registry::instance()->load_model('Datetime')->get_dtt_months_and_years($where, $evt_active_status); |
|
1399 | 1399 | |
1400 | 1400 | //let's setup vals for select input helper |
1401 | 1401 | $options = array( |
@@ -1408,9 +1408,9 @@ discard block |
||
1408 | 1408 | //translate month and date |
1409 | 1409 | global $wp_locale; |
1410 | 1410 | |
1411 | - foreach ( $DTTS as $DTT ) { |
|
1412 | - $localized_date = $wp_locale->get_month( date('m', strtotime($DTT->dtt_month)) ) . ' ' . $DTT->dtt_year; |
|
1413 | - $id = $DTT->dtt_month . ' ' . $DTT->dtt_year; |
|
1411 | + foreach ($DTTS as $DTT) { |
|
1412 | + $localized_date = $wp_locale->get_month(date('m', strtotime($DTT->dtt_month))).' '.$DTT->dtt_year; |
|
1413 | + $id = $DTT->dtt_month.' '.$DTT->dtt_year; |
|
1414 | 1414 | $options[] = array( |
1415 | 1415 | 'text' => $localized_date, |
1416 | 1416 | 'id' => $id |
@@ -1418,7 +1418,7 @@ discard block |
||
1418 | 1418 | } |
1419 | 1419 | |
1420 | 1420 | |
1421 | - return self::select_input( 'month_range', $options, $cur_date, '', 'wide' ); |
|
1421 | + return self::select_input('month_range', $options, $cur_date, '', 'wide'); |
|
1422 | 1422 | } |
1423 | 1423 | |
1424 | 1424 | |
@@ -1429,7 +1429,7 @@ discard block |
||
1429 | 1429 | * @param integer $current_cat currently selected category |
1430 | 1430 | * @return string html for dropdown |
1431 | 1431 | */ |
1432 | - public static function generate_event_category_dropdown( $current_cat = -1 ) { |
|
1432 | + public static function generate_event_category_dropdown($current_cat = -1) { |
|
1433 | 1433 | $categories = EEM_Term::instance()->get_all_ee_categories(TRUE); |
1434 | 1434 | $options = array( |
1435 | 1435 | '0' => array( |
@@ -1439,14 +1439,14 @@ discard block |
||
1439 | 1439 | ); |
1440 | 1440 | |
1441 | 1441 | //setup categories for dropdown |
1442 | - foreach ( $categories as $category ) { |
|
1442 | + foreach ($categories as $category) { |
|
1443 | 1443 | $options[] = array( |
1444 | 1444 | 'text' => $category->get('name'), |
1445 | 1445 | 'id' => $category->ID() |
1446 | 1446 | ); |
1447 | 1447 | } |
1448 | 1448 | |
1449 | - return self::select_input( 'EVT_CAT', $options, $current_cat ); |
|
1449 | + return self::select_input('EVT_CAT', $options, $current_cat); |
|
1450 | 1450 | } |
1451 | 1451 | |
1452 | 1452 | |
@@ -1465,20 +1465,20 @@ discard block |
||
1465 | 1465 | * @param string $extra_attributes - any extra attributes that need to be attached to the form input |
1466 | 1466 | * @return void |
1467 | 1467 | */ |
1468 | - public static function submit_button( $url = '', $ID = '', $class = '', $text = '', $nonce_action = '', $input_only = FALSE, $extra_attributes = '' ) { |
|
1468 | + public static function submit_button($url = '', $ID = '', $class = '', $text = '', $nonce_action = '', $input_only = FALSE, $extra_attributes = '') { |
|
1469 | 1469 | $btn = ''; |
1470 | - if ( empty( $url ) || empty( $ID )) { |
|
1470 | + if (empty($url) || empty($ID)) { |
|
1471 | 1471 | return $btn; |
1472 | 1472 | } |
1473 | - $text = ! empty( $text ) ? $text : __('Submit', 'event_espresso' ); |
|
1474 | - $btn .= '<input id="' . $ID . '-btn" class="' . $class . '" type="submit" value="' . $text . '" ' . $extra_attributes . '/>'; |
|
1475 | - if ( ! $input_only ) { |
|
1476 | - $btn_frm = '<form id="' . $ID . '-frm" method="POST" action="' . $url . '">'; |
|
1477 | - $btn_frm .= ! empty( $nonce_action ) ? wp_nonce_field( $nonce_action, $nonce_action . '_nonce', TRUE, FALSE ) : ''; |
|
1473 | + $text = ! empty($text) ? $text : __('Submit', 'event_espresso'); |
|
1474 | + $btn .= '<input id="'.$ID.'-btn" class="'.$class.'" type="submit" value="'.$text.'" '.$extra_attributes.'/>'; |
|
1475 | + if ( ! $input_only) { |
|
1476 | + $btn_frm = '<form id="'.$ID.'-frm" method="POST" action="'.$url.'">'; |
|
1477 | + $btn_frm .= ! empty($nonce_action) ? wp_nonce_field($nonce_action, $nonce_action.'_nonce', TRUE, FALSE) : ''; |
|
1478 | 1478 | $btn_frm .= $btn; |
1479 | 1479 | $btn_frm .= '</form>'; |
1480 | 1480 | $btn = $btn_frm; |
1481 | - unset ( $btn_frm ); |
|
1481 | + unset ($btn_frm); |
|
1482 | 1482 | } |
1483 | 1483 | return $btn; |
1484 | 1484 | } |
@@ -355,23 +355,27 @@ |
||
355 | 355 | $field = '<select id="' . EEH_Formatter::ee_tep_output_string($name) . '" name="' . EEH_Formatter::ee_tep_output_string($name) . '"'; |
356 | 356 | //Debug |
357 | 357 | //EEH_Debug_Tools::printr( $values, '$values <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
358 | - if ( EEH_Formatter::ee_tep_not_null($parameters)) |
|
359 | - $field .= ' ' . $parameters; |
|
358 | + if ( EEH_Formatter::ee_tep_not_null($parameters)) { |
|
359 | + $field .= ' ' . $parameters; |
|
360 | + } |
|
360 | 361 | if ($autosize) { |
361 | 362 | $size = 'med'; |
362 | 363 | for ($ii = 0, $ni = sizeof($values); $ii < $ni; $ii++) { |
363 | 364 | if ($values[$ii]['text']) { |
364 | - if (strlen($values[$ii]['text']) > 5) |
|
365 | - $size = 'wide'; |
|
365 | + if (strlen($values[$ii]['text']) > 5) { |
|
366 | + $size = 'wide'; |
|
367 | + } |
|
366 | 368 | } |
367 | 369 | } |
368 | - } else |
|
369 | - $size = ''; |
|
370 | + } else { |
|
371 | + $size = ''; |
|
372 | + } |
|
370 | 373 | |
371 | 374 | $field .= ' class="' . $class . ' ' . $size . '">'; |
372 | 375 | |
373 | - if (empty($default) && isset($GLOBALS[$name])) |
|
374 | - $default = stripslashes($GLOBALS[$name]); |
|
376 | + if (empty($default) && isset($GLOBALS[$name])) { |
|
377 | + $default = stripslashes($GLOBALS[$name]); |
|
378 | + } |
|
375 | 379 | |
376 | 380 | |
377 | 381 | for ($i = 0, $n = sizeof($values); $i < $n; $i++) { |
@@ -88,6 +88,7 @@ discard block |
||
88 | 88 | /** |
89 | 89 | * [ee_tep_not_null description] |
90 | 90 | * @param string | array $value [description] |
91 | + * @param string $value |
|
91 | 92 | * @return bool [description] |
92 | 93 | */ |
93 | 94 | static public function ee_tep_not_null($value) { |
@@ -573,6 +574,8 @@ discard block |
||
573 | 574 | * @param EE_State | string $state |
574 | 575 | * @param EE_Country | string $country |
575 | 576 | * @param string $zip |
577 | + * @param integer $state |
|
578 | + * @param string $country |
|
576 | 579 | * @return EE_Generic_Address |
577 | 580 | */ |
578 | 581 | public function __construct( $address, $address2, $city, $state, $country, $zip ) { |
@@ -660,7 +663,7 @@ discard block |
||
660 | 663 | |
661 | 664 | |
662 | 665 | /** |
663 | - * @return \EE_State |
|
666 | + * @return string |
|
664 | 667 | */ |
665 | 668 | public function state_obj() { |
666 | 669 | return $this->_state_obj; |
@@ -709,7 +712,7 @@ discard block |
||
709 | 712 | |
710 | 713 | |
711 | 714 | /** |
712 | - * @return \EE_Country |
|
715 | + * @return string |
|
713 | 716 | */ |
714 | 717 | public function country_obj() { |
715 | 718 | return $this->_country_obj; |
@@ -297,12 +297,12 @@ discard block |
||
297 | 297 | |
298 | 298 | |
299 | 299 | /** |
300 | - * _get_formatter - obtain the requester formatter class |
|
301 | - * |
|
302 | - * @access private |
|
303 | - * @param string $type how the address is formatted. for example: 'multiline' or 'inline' |
|
304 | - * @return EEI_Address_Formatter |
|
305 | - */ |
|
300 | + * _get_formatter - obtain the requester formatter class |
|
301 | + * |
|
302 | + * @access private |
|
303 | + * @param string $type how the address is formatted. for example: 'multiline' or 'inline' |
|
304 | + * @return EEI_Address_Formatter |
|
305 | + */ |
|
306 | 306 | private static function _get_formatter( $type ) { |
307 | 307 | switch( $type ) { |
308 | 308 | |
@@ -348,14 +348,14 @@ discard block |
||
348 | 348 | |
349 | 349 | |
350 | 350 | /** |
351 | - * _schema_formatting |
|
352 | - * adds schema.org formatting to an address |
|
353 | - * |
|
354 | - * @access private |
|
355 | - * @param object EEI_Address_Formatter $formatter |
|
356 | - * @param object EEI_Address $obj_with_address |
|
357 | - * @return string |
|
358 | - */ |
|
351 | + * _schema_formatting |
|
352 | + * adds schema.org formatting to an address |
|
353 | + * |
|
354 | + * @access private |
|
355 | + * @param object EEI_Address_Formatter $formatter |
|
356 | + * @param object EEI_Address $obj_with_address |
|
357 | + * @return string |
|
358 | + */ |
|
359 | 359 | private static function _schema_formatting( EEI_Address_Formatter $formatter, EEI_Address $obj_with_address ){ |
360 | 360 | $formatted_address = '<div itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">'; |
361 | 361 | $formatted_address .= $formatter->format( |
@@ -396,50 +396,50 @@ discard block |
||
396 | 396 | |
397 | 397 | |
398 | 398 | /** |
399 | - * location |
|
400 | - * The location of the event, organization or action. |
|
401 | - * Should include the Venue name AND schema formatted address info |
|
402 | - * |
|
403 | - * @access public |
|
404 | - * @param string $location |
|
405 | - * @return string |
|
406 | - */ |
|
399 | + * location |
|
400 | + * The location of the event, organization or action. |
|
401 | + * Should include the Venue name AND schema formatted address info |
|
402 | + * |
|
403 | + * @access public |
|
404 | + * @param string $location |
|
405 | + * @return string |
|
406 | + */ |
|
407 | 407 | public static function location ( $location = NULL ) { |
408 | 408 | return ! empty( $location ) ? '<div itemprop="location" itemscope itemtype="http://schema.org/Place">' . $location . '</div>' : ''; |
409 | 409 | } |
410 | 410 | |
411 | 411 | /** |
412 | - * name |
|
413 | - * The name of the Event or Venue. |
|
414 | - * |
|
415 | - * @access public |
|
416 | - * @param string $name |
|
417 | - * @return string |
|
418 | - */ |
|
412 | + * name |
|
413 | + * The name of the Event or Venue. |
|
414 | + * |
|
415 | + * @access public |
|
416 | + * @param string $name |
|
417 | + * @return string |
|
418 | + */ |
|
419 | 419 | public static function name ( $name = NULL ) { |
420 | 420 | return ! empty( $name ) ? '<span itemprop="name">' . $name . '</span>' : ''; |
421 | 421 | } |
422 | 422 | |
423 | 423 | /** |
424 | - * streetAddress |
|
425 | - * The street address. For example, 1600 Amphitheatre Pkwy. |
|
426 | - * |
|
427 | - * @access public |
|
428 | - * @param EEI_Address $obj_with_address |
|
429 | - * @return string |
|
430 | - */ |
|
424 | + * streetAddress |
|
425 | + * The street address. For example, 1600 Amphitheatre Pkwy. |
|
426 | + * |
|
427 | + * @access public |
|
428 | + * @param EEI_Address $obj_with_address |
|
429 | + * @return string |
|
430 | + */ |
|
431 | 431 | public static function streetAddress ( EEI_Address $obj_with_address = NULL ) { |
432 | 432 | return $obj_with_address->address() !== NULL && $obj_with_address->address() !== '' ? '<span itemprop="streetAddress">' . $obj_with_address->address() . '</span>' : ''; |
433 | 433 | } |
434 | 434 | |
435 | 435 | /** |
436 | - * postOfficeBoxNumber |
|
437 | - * The post office box number for PO box addresses. |
|
438 | - * |
|
439 | - * @access public |
|
440 | - * @param EEI_Address $obj_with_address |
|
441 | - * @return string |
|
442 | - */ |
|
436 | + * postOfficeBoxNumber |
|
437 | + * The post office box number for PO box addresses. |
|
438 | + * |
|
439 | + * @access public |
|
440 | + * @param EEI_Address $obj_with_address |
|
441 | + * @return string |
|
442 | + */ |
|
443 | 443 | public static function postOfficeBoxNumber ( EEI_Address $obj_with_address = NULL ) { |
444 | 444 | // regex check for some form of PO Box or P.O. Box, etc, etc, etc |
445 | 445 | if ( preg_match("/^\s*((P(OST)?.?\s*(O(FF(ICE)?)?)?.?\s+(B(IN|OX))?)|B(IN|OX))/i", $obj_with_address->address2() )) { |
@@ -450,25 +450,25 @@ discard block |
||
450 | 450 | } |
451 | 451 | |
452 | 452 | /** |
453 | - * addressLocality |
|
454 | - * The locality (city, town, etc). For example, Mountain View. |
|
455 | - * |
|
456 | - * @access public |
|
457 | - * @param EEI_Address $obj_with_address |
|
458 | - * @return string |
|
459 | - */ |
|
453 | + * addressLocality |
|
454 | + * The locality (city, town, etc). For example, Mountain View. |
|
455 | + * |
|
456 | + * @access public |
|
457 | + * @param EEI_Address $obj_with_address |
|
458 | + * @return string |
|
459 | + */ |
|
460 | 460 | public static function addressLocality ( EEI_Address $obj_with_address = NULL ) { |
461 | 461 | return $obj_with_address->city() !== NULL && $obj_with_address->city() !== '' ? '<span itemprop="addressLocality">' . $obj_with_address->city() . '</span>' : ''; |
462 | 462 | } |
463 | 463 | |
464 | 464 | /** |
465 | - * addressRegion |
|
466 | - * The region (state, province, etc). For example, CA. |
|
467 | - * |
|
468 | - * @access public |
|
469 | - * @param EEI_Address $obj_with_address |
|
470 | - * @return string |
|
471 | - */ |
|
465 | + * addressRegion |
|
466 | + * The region (state, province, etc). For example, CA. |
|
467 | + * |
|
468 | + * @access public |
|
469 | + * @param EEI_Address $obj_with_address |
|
470 | + * @return string |
|
471 | + */ |
|
472 | 472 | public static function addressRegion ( EEI_Address $obj_with_address = NULL ) { |
473 | 473 | $state = $obj_with_address->state(); |
474 | 474 | if ( ! empty( $state ) ) { |
@@ -479,13 +479,13 @@ discard block |
||
479 | 479 | } |
480 | 480 | |
481 | 481 | /** |
482 | - * addressCountry |
|
483 | - * The country. For example, USA. You can also provide the two-letter ISO 3166-1 alpha-2 country code. |
|
484 | - * |
|
485 | - * @access public |
|
486 | - * @param EEI_Address $obj_with_address |
|
487 | - * @return string |
|
488 | - */ |
|
482 | + * addressCountry |
|
483 | + * The country. For example, USA. You can also provide the two-letter ISO 3166-1 alpha-2 country code. |
|
484 | + * |
|
485 | + * @access public |
|
486 | + * @param EEI_Address $obj_with_address |
|
487 | + * @return string |
|
488 | + */ |
|
489 | 489 | public static function addressCountry ( EEI_Address $obj_with_address = NULL ) { |
490 | 490 | $country = $obj_with_address->country(); |
491 | 491 | if ( ! empty( $country ) ) { |
@@ -496,39 +496,39 @@ discard block |
||
496 | 496 | } |
497 | 497 | |
498 | 498 | /** |
499 | - * postalCode |
|
500 | - * The postal code. For example, 94043. |
|
501 | - * |
|
502 | - * @access public |
|
503 | - * @param EEI_Address $obj_with_address |
|
504 | - * @return string |
|
505 | - */ |
|
499 | + * postalCode |
|
500 | + * The postal code. For example, 94043. |
|
501 | + * |
|
502 | + * @access public |
|
503 | + * @param EEI_Address $obj_with_address |
|
504 | + * @return string |
|
505 | + */ |
|
506 | 506 | public static function postalCode ( EEI_Address $obj_with_address = NULL ) { |
507 | 507 | return $obj_with_address->zip() !== NULL && $obj_with_address->zip() !== '' ? '<span itemprop="postalCode">' . $obj_with_address->zip() . '</span>' : ''; |
508 | 508 | } |
509 | 509 | |
510 | 510 | /** |
511 | - * telephone |
|
512 | - * The telephone number. |
|
513 | - * |
|
514 | - * @access public |
|
515 | - * @param string $phone_nmbr |
|
516 | - * @return string |
|
517 | - */ |
|
511 | + * telephone |
|
512 | + * The telephone number. |
|
513 | + * |
|
514 | + * @access public |
|
515 | + * @param string $phone_nmbr |
|
516 | + * @return string |
|
517 | + */ |
|
518 | 518 | public static function telephone ( $phone_nmbr = NULL ) { |
519 | 519 | return $phone_nmbr !== NULL && $phone_nmbr !== '' ? '<span itemprop="telephone">' . $phone_nmbr . '</span>' : ''; |
520 | 520 | } |
521 | 521 | |
522 | 522 | /** |
523 | - * URL |
|
524 | - * URL of the item as a clickable link |
|
525 | - * |
|
526 | - * @access public |
|
527 | - * @param string $url - the URL that the link will resolve to |
|
528 | - * @param string $text - the text that will be used for the visible link |
|
529 | - * @param array $attributes - array of additional link attributes in attribute_name => value pairs. ie: array( 'title' => 'click here', 'class' => 'link-class' ) |
|
530 | - * @return string (link) |
|
531 | - */ |
|
523 | + * URL |
|
524 | + * URL of the item as a clickable link |
|
525 | + * |
|
526 | + * @access public |
|
527 | + * @param string $url - the URL that the link will resolve to |
|
528 | + * @param string $text - the text that will be used for the visible link |
|
529 | + * @param array $attributes - array of additional link attributes in attribute_name => value pairs. ie: array( 'title' => 'click here', 'class' => 'link-class' ) |
|
530 | + * @return string (link) |
|
531 | + */ |
|
532 | 532 | public static function url ( $url = NULL, $text = NULL, $attributes = array() ) { |
533 | 533 | $atts = ''; |
534 | 534 | foreach ( $attributes as $attribute => $value ) { |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @param string $content content to format |
40 | 40 | * @return string formatted content |
41 | 41 | */ |
42 | - static public function admin_format_content($content='') { |
|
42 | + static public function admin_format_content($content = '') { |
|
43 | 43 | return wpautop(stripslashes_deep(html_entity_decode($content, ENT_QUOTES, "UTF-8"))); |
44 | 44 | } |
45 | 45 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * @return string |
80 | 80 | */ |
81 | 81 | static public function ee_tep_parse_input_field_data($data, $parse) { |
82 | - return strtr( trim($data), $parse); |
|
82 | + return strtr(trim($data), $parse); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | |
@@ -118,8 +118,8 @@ discard block |
||
118 | 118 | * @return string |
119 | 119 | * @deprecated v4.6.21 |
120 | 120 | */ |
121 | - static public function event_date_display( $date, $format = '' ) { |
|
122 | - EE_Error::doing_it_wrong( __METHOD__, 'This method is deprecated as of EE 4.6.12. Currently it does not reformat as with prior behaviour but just returns the incoming string. Please use the EE_Datetime helpers for Datetime on the event to display as desired.', 'event_espresso' ); |
|
121 | + static public function event_date_display($date, $format = '') { |
|
122 | + EE_Error::doing_it_wrong(__METHOD__, 'This method is deprecated as of EE 4.6.12. Currently it does not reformat as with prior behaviour but just returns the incoming string. Please use the EE_Datetime helpers for Datetime on the event to display as desired.', 'event_espresso'); |
|
123 | 123 | |
124 | 124 | return $date; |
125 | 125 | } |
@@ -157,14 +157,14 @@ discard block |
||
157 | 157 | * @param string $zip |
158 | 158 | * @return string |
159 | 159 | */ |
160 | - public function format( $address, $address2, $city, $state, $country, $zip ) { |
|
160 | + public function format($address, $address2, $city, $state, $country, $zip) { |
|
161 | 161 | $formatted_address = $address; |
162 | - $formatted_address .= ! empty( $address2 ) ? '<br/>' . $address2 : ''; |
|
163 | - $formatted_address .= ! empty( $city ) ? '<br/>' . $city : ''; |
|
164 | - $formatted_address .= ! empty( $city ) && ! empty( $state ) ? ', ' : ''; |
|
165 | - $formatted_address .= ! empty( $state ) ? $state : ''; |
|
166 | - $formatted_address .= ! empty( $zip ) ? '<br/>' . $zip : ''; |
|
167 | - $formatted_address .= ! empty( $country ) ? '<br/>' . $country : ''; |
|
162 | + $formatted_address .= ! empty($address2) ? '<br/>'.$address2 : ''; |
|
163 | + $formatted_address .= ! empty($city) ? '<br/>'.$city : ''; |
|
164 | + $formatted_address .= ! empty($city) && ! empty($state) ? ', ' : ''; |
|
165 | + $formatted_address .= ! empty($state) ? $state : ''; |
|
166 | + $formatted_address .= ! empty($zip) ? '<br/>'.$zip : ''; |
|
167 | + $formatted_address .= ! empty($country) ? '<br/>'.$country : ''; |
|
168 | 168 | return $formatted_address; |
169 | 169 | } |
170 | 170 | } |
@@ -196,18 +196,18 @@ discard block |
||
196 | 196 | * @param string $zip |
197 | 197 | * @return string |
198 | 198 | */ |
199 | - public function format( $address, $address2, $city, $state, $country, $zip ) { |
|
199 | + public function format($address, $address2, $city, $state, $country, $zip) { |
|
200 | 200 | $formatted_address = $address; |
201 | - $formatted_address .= substr( $formatted_address, -2 ) != ', ' ? ', ' : ''; |
|
202 | - $formatted_address .= ! empty( $address2 ) ? $address2 : ''; |
|
203 | - $formatted_address .= substr( $formatted_address, -2 ) != ', ' ? ', ' : ''; |
|
204 | - $formatted_address .= ! empty( $city ) ? $city : ''; |
|
205 | - $formatted_address .= substr( $formatted_address, -2 ) != ', ' ? ', ' : ''; |
|
206 | - $formatted_address .= ! empty( $state ) ? $state : ''; |
|
207 | - $formatted_address .= substr( $formatted_address, -2 ) != ', ' ? ', ' : ''; |
|
208 | - $formatted_address .= ! empty( $country ) ? $country : ''; |
|
209 | - $formatted_address .= substr( $formatted_address, -2 ) != ', ' ? ', ' : ''; |
|
210 | - $formatted_address .= ! empty( $zip ) ? $zip : ''; |
|
201 | + $formatted_address .= substr($formatted_address, -2) != ', ' ? ', ' : ''; |
|
202 | + $formatted_address .= ! empty($address2) ? $address2 : ''; |
|
203 | + $formatted_address .= substr($formatted_address, -2) != ', ' ? ', ' : ''; |
|
204 | + $formatted_address .= ! empty($city) ? $city : ''; |
|
205 | + $formatted_address .= substr($formatted_address, -2) != ', ' ? ', ' : ''; |
|
206 | + $formatted_address .= ! empty($state) ? $state : ''; |
|
207 | + $formatted_address .= substr($formatted_address, -2) != ', ' ? ', ' : ''; |
|
208 | + $formatted_address .= ! empty($country) ? $country : ''; |
|
209 | + $formatted_address .= substr($formatted_address, -2) != ', ' ? ', ' : ''; |
|
210 | + $formatted_address .= ! empty($zip) ? $zip : ''; |
|
211 | 211 | return $formatted_address; |
212 | 212 | } |
213 | 213 | } |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * @param string $zip |
241 | 241 | * @return string |
242 | 242 | */ |
243 | - public function format( $address, $address2, $city, $state, $country, $zip ) { |
|
243 | + public function format($address, $address2, $city, $state, $country, $zip) { |
|
244 | 244 | return NULL; |
245 | 245 | } |
246 | 246 | } |
@@ -276,20 +276,20 @@ discard block |
||
276 | 276 | * @param bool $add_wrapper |
277 | 277 | * @return string |
278 | 278 | */ |
279 | - public static function format ( $obj_with_address = null, $type = 'multiline', $use_schema = true, $add_wrapper = true ) { |
|
279 | + public static function format($obj_with_address = null, $type = 'multiline', $use_schema = true, $add_wrapper = true) { |
|
280 | 280 | // check that incoming object implements the EEI_Address interface |
281 | - if ( ! $obj_with_address instanceof EEI_Address ) { |
|
282 | - $msg = __( 'The address could not be formatted.', 'event_espresso' ); |
|
283 | - $dev_msg = __( 'The EE_Address_Formatter requires passed objects to implement the EEI_Address interface.', 'event_espresso' ); |
|
284 | - EE_Error::add_error( $msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
281 | + if ( ! $obj_with_address instanceof EEI_Address) { |
|
282 | + $msg = __('The address could not be formatted.', 'event_espresso'); |
|
283 | + $dev_msg = __('The EE_Address_Formatter requires passed objects to implement the EEI_Address interface.', 'event_espresso'); |
|
284 | + EE_Error::add_error($msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__); |
|
285 | 285 | return null; |
286 | 286 | } |
287 | 287 | // obtain an address formatter |
288 | - $formatter = EEH_Address::_get_formatter( $type ); |
|
288 | + $formatter = EEH_Address::_get_formatter($type); |
|
289 | 289 | // apply schema.org formatting ? |
290 | 290 | $use_schema = ! is_admin() ? $use_schema : false; |
291 | - $formatted_address = $use_schema ? EEH_Address::_schema_formatting( $formatter, $obj_with_address ) : EEH_Address::_regular_formatting( $formatter, $obj_with_address, $add_wrapper ) ; |
|
292 | - $formatted_address = $add_wrapper && ! $use_schema ? '<div class="espresso-address-dv">' . $formatted_address . '</div>' : $formatted_address; |
|
291 | + $formatted_address = $use_schema ? EEH_Address::_schema_formatting($formatter, $obj_with_address) : EEH_Address::_regular_formatting($formatter, $obj_with_address, $add_wrapper); |
|
292 | + $formatted_address = $add_wrapper && ! $use_schema ? '<div class="espresso-address-dv">'.$formatted_address.'</div>' : $formatted_address; |
|
293 | 293 | // return the formatted address |
294 | 294 | return $formatted_address; |
295 | 295 | } |
@@ -303,8 +303,8 @@ discard block |
||
303 | 303 | * @param string $type how the address is formatted. for example: 'multiline' or 'inline' |
304 | 304 | * @return EEI_Address_Formatter |
305 | 305 | */ |
306 | - private static function _get_formatter( $type ) { |
|
307 | - switch( $type ) { |
|
306 | + private static function _get_formatter($type) { |
|
307 | + switch ($type) { |
|
308 | 308 | |
309 | 309 | case 'multiline' : |
310 | 310 | return new EE_MultiLine_Address_Formatter(); |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | * @param bool $add_wrapper |
331 | 331 | * @return string |
332 | 332 | */ |
333 | - private static function _regular_formatting( EEI_Address_Formatter $formatter, EEI_Address $obj_with_address, $add_wrapper = TRUE ){ |
|
333 | + private static function _regular_formatting(EEI_Address_Formatter $formatter, EEI_Address $obj_with_address, $add_wrapper = TRUE) { |
|
334 | 334 | $formatted_address = $add_wrapper ? '<div>' : ''; |
335 | 335 | $formatted_address .= $formatter->format( |
336 | 336 | $obj_with_address->address(), |
@@ -356,15 +356,15 @@ discard block |
||
356 | 356 | * @param object EEI_Address $obj_with_address |
357 | 357 | * @return string |
358 | 358 | */ |
359 | - private static function _schema_formatting( EEI_Address_Formatter $formatter, EEI_Address $obj_with_address ){ |
|
359 | + private static function _schema_formatting(EEI_Address_Formatter $formatter, EEI_Address $obj_with_address) { |
|
360 | 360 | $formatted_address = '<div itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">'; |
361 | 361 | $formatted_address .= $formatter->format( |
362 | - EEH_Schema::streetAddress( $obj_with_address ), |
|
363 | - EEH_Schema::postOfficeBoxNumber( $obj_with_address ), |
|
364 | - EEH_Schema::addressLocality( $obj_with_address ), |
|
365 | - EEH_Schema::addressRegion( $obj_with_address ), |
|
366 | - EEH_Schema::addressCountry( $obj_with_address ), |
|
367 | - EEH_Schema::postalCode( $obj_with_address ) |
|
362 | + EEH_Schema::streetAddress($obj_with_address), |
|
363 | + EEH_Schema::postOfficeBoxNumber($obj_with_address), |
|
364 | + EEH_Schema::addressLocality($obj_with_address), |
|
365 | + EEH_Schema::addressRegion($obj_with_address), |
|
366 | + EEH_Schema::addressCountry($obj_with_address), |
|
367 | + EEH_Schema::postalCode($obj_with_address) |
|
368 | 368 | ); |
369 | 369 | $formatted_address .= '</div>'; |
370 | 370 | // return the formatted address |
@@ -404,8 +404,8 @@ discard block |
||
404 | 404 | * @param string $location |
405 | 405 | * @return string |
406 | 406 | */ |
407 | - public static function location ( $location = NULL ) { |
|
408 | - return ! empty( $location ) ? '<div itemprop="location" itemscope itemtype="http://schema.org/Place">' . $location . '</div>' : ''; |
|
407 | + public static function location($location = NULL) { |
|
408 | + return ! empty($location) ? '<div itemprop="location" itemscope itemtype="http://schema.org/Place">'.$location.'</div>' : ''; |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | /** |
@@ -416,8 +416,8 @@ discard block |
||
416 | 416 | * @param string $name |
417 | 417 | * @return string |
418 | 418 | */ |
419 | - public static function name ( $name = NULL ) { |
|
420 | - return ! empty( $name ) ? '<span itemprop="name">' . $name . '</span>' : ''; |
|
419 | + public static function name($name = NULL) { |
|
420 | + return ! empty($name) ? '<span itemprop="name">'.$name.'</span>' : ''; |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | /** |
@@ -428,8 +428,8 @@ discard block |
||
428 | 428 | * @param EEI_Address $obj_with_address |
429 | 429 | * @return string |
430 | 430 | */ |
431 | - public static function streetAddress ( EEI_Address $obj_with_address = NULL ) { |
|
432 | - return $obj_with_address->address() !== NULL && $obj_with_address->address() !== '' ? '<span itemprop="streetAddress">' . $obj_with_address->address() . '</span>' : ''; |
|
431 | + public static function streetAddress(EEI_Address $obj_with_address = NULL) { |
|
432 | + return $obj_with_address->address() !== NULL && $obj_with_address->address() !== '' ? '<span itemprop="streetAddress">'.$obj_with_address->address().'</span>' : ''; |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | /** |
@@ -440,10 +440,10 @@ discard block |
||
440 | 440 | * @param EEI_Address $obj_with_address |
441 | 441 | * @return string |
442 | 442 | */ |
443 | - public static function postOfficeBoxNumber ( EEI_Address $obj_with_address = NULL ) { |
|
443 | + public static function postOfficeBoxNumber(EEI_Address $obj_with_address = NULL) { |
|
444 | 444 | // regex check for some form of PO Box or P.O. Box, etc, etc, etc |
445 | - if ( preg_match("/^\s*((P(OST)?.?\s*(O(FF(ICE)?)?)?.?\s+(B(IN|OX))?)|B(IN|OX))/i", $obj_with_address->address2() )) { |
|
446 | - return $obj_with_address->address2() !== NULL && $obj_with_address->address2() !== '' ? '<span itemprop="postOfficeBoxNumber">' . $obj_with_address->address2() . '</span>' : ''; |
|
445 | + if (preg_match("/^\s*((P(OST)?.?\s*(O(FF(ICE)?)?)?.?\s+(B(IN|OX))?)|B(IN|OX))/i", $obj_with_address->address2())) { |
|
446 | + return $obj_with_address->address2() !== NULL && $obj_with_address->address2() !== '' ? '<span itemprop="postOfficeBoxNumber">'.$obj_with_address->address2().'</span>' : ''; |
|
447 | 447 | } else { |
448 | 448 | return $obj_with_address->address2(); |
449 | 449 | } |
@@ -457,8 +457,8 @@ discard block |
||
457 | 457 | * @param EEI_Address $obj_with_address |
458 | 458 | * @return string |
459 | 459 | */ |
460 | - public static function addressLocality ( EEI_Address $obj_with_address = NULL ) { |
|
461 | - return $obj_with_address->city() !== NULL && $obj_with_address->city() !== '' ? '<span itemprop="addressLocality">' . $obj_with_address->city() . '</span>' : ''; |
|
460 | + public static function addressLocality(EEI_Address $obj_with_address = NULL) { |
|
461 | + return $obj_with_address->city() !== NULL && $obj_with_address->city() !== '' ? '<span itemprop="addressLocality">'.$obj_with_address->city().'</span>' : ''; |
|
462 | 462 | } |
463 | 463 | |
464 | 464 | /** |
@@ -469,10 +469,10 @@ discard block |
||
469 | 469 | * @param EEI_Address $obj_with_address |
470 | 470 | * @return string |
471 | 471 | */ |
472 | - public static function addressRegion ( EEI_Address $obj_with_address = NULL ) { |
|
472 | + public static function addressRegion(EEI_Address $obj_with_address = NULL) { |
|
473 | 473 | $state = $obj_with_address->state(); |
474 | - if ( ! empty( $state ) ) { |
|
475 | - return '<span itemprop="addressRegion">' . $state . '</span>'; |
|
474 | + if ( ! empty($state)) { |
|
475 | + return '<span itemprop="addressRegion">'.$state.'</span>'; |
|
476 | 476 | } else { |
477 | 477 | return ''; |
478 | 478 | } |
@@ -486,10 +486,10 @@ discard block |
||
486 | 486 | * @param EEI_Address $obj_with_address |
487 | 487 | * @return string |
488 | 488 | */ |
489 | - public static function addressCountry ( EEI_Address $obj_with_address = NULL ) { |
|
489 | + public static function addressCountry(EEI_Address $obj_with_address = NULL) { |
|
490 | 490 | $country = $obj_with_address->country(); |
491 | - if ( ! empty( $country ) ) { |
|
492 | - return '<span itemprop="addressCountry">' . $country . '</span>'; |
|
491 | + if ( ! empty($country)) { |
|
492 | + return '<span itemprop="addressCountry">'.$country.'</span>'; |
|
493 | 493 | } else { |
494 | 494 | return ''; |
495 | 495 | } |
@@ -503,8 +503,8 @@ discard block |
||
503 | 503 | * @param EEI_Address $obj_with_address |
504 | 504 | * @return string |
505 | 505 | */ |
506 | - public static function postalCode ( EEI_Address $obj_with_address = NULL ) { |
|
507 | - return $obj_with_address->zip() !== NULL && $obj_with_address->zip() !== '' ? '<span itemprop="postalCode">' . $obj_with_address->zip() . '</span>' : ''; |
|
506 | + public static function postalCode(EEI_Address $obj_with_address = NULL) { |
|
507 | + return $obj_with_address->zip() !== NULL && $obj_with_address->zip() !== '' ? '<span itemprop="postalCode">'.$obj_with_address->zip().'</span>' : ''; |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | /** |
@@ -515,8 +515,8 @@ discard block |
||
515 | 515 | * @param string $phone_nmbr |
516 | 516 | * @return string |
517 | 517 | */ |
518 | - public static function telephone ( $phone_nmbr = NULL ) { |
|
519 | - return $phone_nmbr !== NULL && $phone_nmbr !== '' ? '<span itemprop="telephone">' . $phone_nmbr . '</span>' : ''; |
|
518 | + public static function telephone($phone_nmbr = NULL) { |
|
519 | + return $phone_nmbr !== NULL && $phone_nmbr !== '' ? '<span itemprop="telephone">'.$phone_nmbr.'</span>' : ''; |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | /** |
@@ -529,13 +529,13 @@ discard block |
||
529 | 529 | * @param array $attributes - array of additional link attributes in attribute_name => value pairs. ie: array( 'title' => 'click here', 'class' => 'link-class' ) |
530 | 530 | * @return string (link) |
531 | 531 | */ |
532 | - public static function url ( $url = NULL, $text = NULL, $attributes = array() ) { |
|
532 | + public static function url($url = NULL, $text = NULL, $attributes = array()) { |
|
533 | 533 | $atts = ''; |
534 | - foreach ( $attributes as $attribute => $value ) { |
|
535 | - $atts .= ' ' . $attribute . '="' . $value . '"'; |
|
534 | + foreach ($attributes as $attribute => $value) { |
|
535 | + $atts .= ' '.$attribute.'="'.$value.'"'; |
|
536 | 536 | } |
537 | 537 | $text = $text !== NULL && $text !== '' ? $text : $url; |
538 | - return $url !== NULL && $url !== '' ? '<a itemprop="url" href="' . $url . '"' . $atts . '>' . $text . '</a>' : ''; |
|
538 | + return $url !== NULL && $url !== '' ? '<a itemprop="url" href="'.$url.'"'.$atts.'>'.$text.'</a>' : ''; |
|
539 | 539 | } |
540 | 540 | |
541 | 541 | |
@@ -575,17 +575,17 @@ discard block |
||
575 | 575 | * @param string $zip |
576 | 576 | * @return EE_Generic_Address |
577 | 577 | */ |
578 | - public function __construct( $address, $address2, $city, $state, $country, $zip ) { |
|
578 | + public function __construct($address, $address2, $city, $state, $country, $zip) { |
|
579 | 579 | $this->_address = $address; |
580 | 580 | $this->_address2 = $address2; |
581 | 581 | $this->_city = $city; |
582 | - if ( $state instanceof EE_State ) { |
|
582 | + if ($state instanceof EE_State) { |
|
583 | 583 | $this->_state_obj = $state; |
584 | 584 | } else { |
585 | 585 | $this->_state_ID = $state; |
586 | 586 | $this->_state_obj = $this->_get_state_obj(); |
587 | 587 | } |
588 | - if ( $country instanceof EE_Country ) { |
|
588 | + if ($country instanceof EE_Country) { |
|
589 | 589 | $this->_country_obj = $country; |
590 | 590 | } else { |
591 | 591 | $this->_country_ID = $country; |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | * @return \EE_State |
628 | 628 | */ |
629 | 629 | private function _get_state_obj() { |
630 | - return $this->_state_obj instanceof EE_State ? $this->_state_obj : EE_Registry::instance()->load_model( 'State' )->get_one_by_ID( $this->_state_ID ); |
|
630 | + return $this->_state_obj instanceof EE_State ? $this->_state_obj : EE_Registry::instance()->load_model('State')->get_one_by_ID($this->_state_ID); |
|
631 | 631 | } |
632 | 632 | |
633 | 633 | |
@@ -645,7 +645,7 @@ discard block |
||
645 | 645 | * @return string |
646 | 646 | */ |
647 | 647 | public function state_abbrev() { |
648 | - return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : __( 'Unknown', 'event_espresso' ); |
|
648 | + return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : __('Unknown', 'event_espresso'); |
|
649 | 649 | } |
650 | 650 | |
651 | 651 | |
@@ -654,7 +654,7 @@ discard block |
||
654 | 654 | * @return string |
655 | 655 | */ |
656 | 656 | public function state_name() { |
657 | - return $this->state_obj() instanceof EE_State ? $this->state_obj()->name() : __( 'Unknown', 'event_espresso' ); |
|
657 | + return $this->state_obj() instanceof EE_State ? $this->state_obj()->name() : __('Unknown', 'event_espresso'); |
|
658 | 658 | } |
659 | 659 | |
660 | 660 | |
@@ -672,7 +672,7 @@ discard block |
||
672 | 672 | * @return string |
673 | 673 | */ |
674 | 674 | public function state() { |
675 | - if ( apply_filters( 'FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj() ) ) { |
|
675 | + if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) { |
|
676 | 676 | return $this->state_obj()->abbrev(); |
677 | 677 | } else { |
678 | 678 | return $this->state_name(); |
@@ -685,7 +685,7 @@ discard block |
||
685 | 685 | * @return EE_Country |
686 | 686 | */ |
687 | 687 | private function _get_country_obj() { |
688 | - return $this->_country_obj instanceof EE_Country ? $this->_country_obj : EE_Registry::instance()->load_model( 'Country' )->get_one_by_ID( $this->_country_ID ); |
|
688 | + return $this->_country_obj instanceof EE_Country ? $this->_country_obj : EE_Registry::instance()->load_model('Country')->get_one_by_ID($this->_country_ID); |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | * @return string |
704 | 704 | */ |
705 | 705 | public function country_name() { |
706 | - return $this->country_obj() instanceof EE_Country ? $this->country_obj()->name() : __( 'Unknown', 'event_espresso' ); |
|
706 | + return $this->country_obj() instanceof EE_Country ? $this->country_obj()->name() : __('Unknown', 'event_espresso'); |
|
707 | 707 | } |
708 | 708 | |
709 | 709 | |
@@ -721,7 +721,7 @@ discard block |
||
721 | 721 | * @return string |
722 | 722 | */ |
723 | 723 | public function country() { |
724 | - if ( apply_filters( 'FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj() ) ) { |
|
724 | + if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) { |
|
725 | 725 | return $this->country_ID(); |
726 | 726 | } else { |
727 | 727 | return $this->country_name(); |
@@ -1,6 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | +} |
|
4 | 5 | |
5 | 6 | /** |
6 | 7 | * Event Espresso |
@@ -31,7 +31,6 @@ discard block |
||
31 | 31 | |
32 | 32 | /** |
33 | 33 | * google_map - creates a Google Map Link |
34 | - * @param array $atts aray of attributes required for the map link generation |
|
35 | 34 | * @return string (link to map!) |
36 | 35 | */ |
37 | 36 | public static function google_map( $ee_gmaps_opts ){ |
@@ -116,7 +115,6 @@ discard block |
||
116 | 115 | |
117 | 116 | /** |
118 | 117 | * creates a Google Map Link |
119 | - * @param array $atts aray of attributes required for the map link generation |
|
120 | 118 | * @return string (link to map!) |
121 | 119 | */ |
122 | 120 | public static function espresso_google_map_js() { |
@@ -34,20 +34,20 @@ discard block |
||
34 | 34 | * @param array $atts aray of attributes required for the map link generation |
35 | 35 | * @return string (link to map!) |
36 | 36 | */ |
37 | - public static function google_map( $ee_gmaps_opts ){ |
|
37 | + public static function google_map($ee_gmaps_opts) { |
|
38 | 38 | |
39 | 39 | //d( $ee_gmaps_opts ); |
40 | 40 | |
41 | - $ee_map_width = isset( $ee_gmaps_opts['ee_map_width'] ) && ! empty( $ee_gmaps_opts['ee_map_width'] ) ? $ee_gmaps_opts['ee_map_width'] : '300'; |
|
42 | - $ee_map_height = isset( $ee_gmaps_opts['ee_map_height'] ) && ! empty( $ee_gmaps_opts['ee_map_height'] ) ? $ee_gmaps_opts['ee_map_height'] : '185'; |
|
43 | - $ee_map_zoom = isset( $ee_gmaps_opts['ee_map_zoom'] ) && ! empty( $ee_gmaps_opts['ee_map_zoom'] ) ? $ee_gmaps_opts['ee_map_zoom'] : '12'; |
|
44 | - $ee_map_nav_display = isset( $ee_gmaps_opts['ee_map_nav_display'] ) && ! empty( $ee_gmaps_opts['ee_map_nav_display'] ) ? 'true' : 'false'; |
|
45 | - $ee_map_nav_size = isset( $ee_gmaps_opts['ee_map_nav_size'] ) && ! empty( $ee_gmaps_opts['ee_map_nav_size'] )? $ee_gmaps_opts['ee_map_nav_size'] : 'default'; |
|
46 | - $ee_map_type_control = isset( $ee_gmaps_opts['ee_map_type_control'] ) && ! empty( $ee_gmaps_opts['ee_map_type_control'] )? $ee_gmaps_opts['ee_map_type_control'] : 'default'; |
|
47 | - $static_url = isset( $ee_gmaps_opts['ee_static_url'] ) && ! empty( $ee_gmaps_opts['ee_static_url'] )? $ee_gmaps_opts['ee_static_url'] : FALSE; |
|
41 | + $ee_map_width = isset($ee_gmaps_opts['ee_map_width']) && ! empty($ee_gmaps_opts['ee_map_width']) ? $ee_gmaps_opts['ee_map_width'] : '300'; |
|
42 | + $ee_map_height = isset($ee_gmaps_opts['ee_map_height']) && ! empty($ee_gmaps_opts['ee_map_height']) ? $ee_gmaps_opts['ee_map_height'] : '185'; |
|
43 | + $ee_map_zoom = isset($ee_gmaps_opts['ee_map_zoom']) && ! empty($ee_gmaps_opts['ee_map_zoom']) ? $ee_gmaps_opts['ee_map_zoom'] : '12'; |
|
44 | + $ee_map_nav_display = isset($ee_gmaps_opts['ee_map_nav_display']) && ! empty($ee_gmaps_opts['ee_map_nav_display']) ? 'true' : 'false'; |
|
45 | + $ee_map_nav_size = isset($ee_gmaps_opts['ee_map_nav_size']) && ! empty($ee_gmaps_opts['ee_map_nav_size']) ? $ee_gmaps_opts['ee_map_nav_size'] : 'default'; |
|
46 | + $ee_map_type_control = isset($ee_gmaps_opts['ee_map_type_control']) && ! empty($ee_gmaps_opts['ee_map_type_control']) ? $ee_gmaps_opts['ee_map_type_control'] : 'default'; |
|
47 | + $static_url = isset($ee_gmaps_opts['ee_static_url']) && ! empty($ee_gmaps_opts['ee_static_url']) ? $ee_gmaps_opts['ee_static_url'] : FALSE; |
|
48 | 48 | |
49 | - if( isset( $ee_gmaps_opts['ee_map_align'] ) && ! empty( $ee_gmaps_opts['ee_map_align'] )){ |
|
50 | - switch( $ee_gmaps_opts['ee_map_align'] ){ |
|
49 | + if (isset($ee_gmaps_opts['ee_map_align']) && ! empty($ee_gmaps_opts['ee_map_align'])) { |
|
50 | + switch ($ee_gmaps_opts['ee_map_align']) { |
|
51 | 51 | case "left": |
52 | 52 | $map_align = 'ee-gmap-align-left left'; |
53 | 53 | break; |
@@ -68,18 +68,18 @@ discard block |
||
68 | 68 | |
69 | 69 | // Determine whether user has set a hardoded url to use and |
70 | 70 | // if so display a Google static iframe map else run V3 api |
71 | - if( $static_url ) { |
|
71 | + if ($static_url) { |
|
72 | 72 | |
73 | - $html = '<div class="ee-gmap-iframewrap ee-gmap-wrapper ' . $map_align . '">'; |
|
74 | - $html .= '<iframe src="' . $static_url . '&output=embed" style="width: ' . $ee_map_width .'px; height: ' . $ee_map_height . 'px;" frameborder="0" scrolling="no">'; |
|
73 | + $html = '<div class="ee-gmap-iframewrap ee-gmap-wrapper '.$map_align.'">'; |
|
74 | + $html .= '<iframe src="'.$static_url.'&output=embed" style="width: '.$ee_map_width.'px; height: '.$ee_map_height.'px;" frameborder="0" scrolling="no">'; |
|
75 | 75 | $html .= '</iframe>'; |
76 | - $html .= '<a href="' . $static_url . '">View Large map</a>'; |
|
76 | + $html .= '<a href="'.$static_url.'">View Large map</a>'; |
|
77 | 77 | $html .= '</div>'; |
78 | 78 | return $html; |
79 | 79 | |
80 | 80 | } else { |
81 | 81 | |
82 | - EEH_Maps::$gmap_vars[ $ee_gmaps_opts['map_ID'] ] = array( |
|
82 | + EEH_Maps::$gmap_vars[$ee_gmaps_opts['map_ID']] = array( |
|
83 | 83 | 'map_ID' => $ee_gmaps_opts['map_ID'], |
84 | 84 | 'ee_map_zoom' => $ee_map_zoom, |
85 | 85 | 'ee_map_nav_display' => $ee_map_nav_display, |
@@ -89,12 +89,12 @@ discard block |
||
89 | 89 | ); |
90 | 90 | |
91 | 91 | $html = '<div class="ee-gmap-wrapper '.$map_align.';">'; |
92 | - $html .= '<div class="ee-gmap" id="map_canvas_' . $ee_gmaps_opts['map_ID'] .'" style="width: '.$ee_map_width.'px; height: '.$ee_map_height.'px;"></div>'; // |
|
92 | + $html .= '<div class="ee-gmap" id="map_canvas_'.$ee_gmaps_opts['map_ID'].'" style="width: '.$ee_map_width.'px; height: '.$ee_map_height.'px;"></div>'; // |
|
93 | 93 | $html .= '</div>'; |
94 | 94 | |
95 | - wp_enqueue_script( 'gmap_api' ); |
|
96 | - wp_enqueue_script( 'ee_gmap' ); |
|
97 | - add_action( 'wp_footer', array( 'EEH_Maps', 'footer_enqueue_script' )); |
|
95 | + wp_enqueue_script('gmap_api'); |
|
96 | + wp_enqueue_script('ee_gmap'); |
|
97 | + add_action('wp_footer', array('EEH_Maps', 'footer_enqueue_script')); |
|
98 | 98 | |
99 | 99 | return $html; |
100 | 100 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @return void |
110 | 110 | */ |
111 | 111 | public static function footer_enqueue_script() { |
112 | - wp_localize_script( 'ee_gmap', 'ee_gmap_vars', EEH_Maps::$gmap_vars ); |
|
112 | + wp_localize_script('ee_gmap', 'ee_gmap_vars', EEH_Maps::$gmap_vars); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public static function espresso_google_map_js() { |
123 | 123 | $scheme = is_ssl() ? 'https://' : 'http://'; |
124 | - wp_register_script( 'gmap_api', $scheme . 'maps.google.com/maps/api/js?sensor=false', array('jquery'), NULL, TRUE ); |
|
125 | - wp_register_script( 'ee_gmap', plugin_dir_url(__FILE__) . 'assets/ee_gmap.js', array('gmap_api'), '1.0', TRUE ); |
|
124 | + wp_register_script('gmap_api', $scheme.'maps.google.com/maps/api/js?sensor=false', array('jquery'), NULL, TRUE); |
|
125 | + wp_register_script('ee_gmap', plugin_dir_url(__FILE__).'assets/ee_gmap.js', array('gmap_api'), '1.0', TRUE); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * @return string (link to map!) |
132 | 132 | */ |
133 | 133 | public static function google_map_link($atts) { |
134 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
134 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
135 | 135 | extract($atts); |
136 | 136 | |
137 | 137 | $address = "{$address}"; |
@@ -146,9 +146,9 @@ discard block |
||
146 | 146 | $id = isset($id) ? $id : 'not_set'; |
147 | 147 | $map_image_class = isset($map_image_class) ? $map_image_class : 'ee_google_map_view'; |
148 | 148 | |
149 | - $address_string = ($address != '' ? $address : '') . ($city != '' ? ',' . $city : '') . ($state != '' ? ',' . $state : '') . ($zip != '' ? ',' . $zip : '') . ($country != '' ? ',' . $country : ''); |
|
149 | + $address_string = ($address != '' ? $address : '').($city != '' ? ','.$city : '').($state != '' ? ','.$state : '').($zip != '' ? ','.$zip : '').($country != '' ? ','.$country : ''); |
|
150 | 150 | |
151 | - $google_map = htmlentities2('http://maps.google.com/maps?q=' . urlencode( $address_string )); |
|
151 | + $google_map = htmlentities2('http://maps.google.com/maps?q='.urlencode($address_string)); |
|
152 | 152 | |
153 | 153 | switch ($type) { |
154 | 154 | case 'text': |
@@ -162,10 +162,10 @@ discard block |
||
162 | 162 | |
163 | 163 | case 'map': |
164 | 164 | $scheme = is_ssl() ? 'https://' : 'http://'; |
165 | - return '<a class="a_map_image_link" href="' . $google_map . '" target="_blank">' . '<img class="map_image_link" id="venue_map_' . $id . '" ' . $map_image_class . ' src="' . htmlentities2( $scheme . 'maps.googleapis.com/maps/api/staticmap?center=' . urlencode( $address_string ) . '&zoom=14&size=' . $map_w . 'x' . $map_h . '&markers=color:green|label:|' . urlencode( $address_string ) . '&sensor=false' ) . '" /></a>'; |
|
165 | + return '<a class="a_map_image_link" href="'.$google_map.'" target="_blank">'.'<img class="map_image_link" id="venue_map_'.$id.'" '.$map_image_class.' src="'.htmlentities2($scheme.'maps.googleapis.com/maps/api/staticmap?center='.urlencode($address_string).'&zoom=14&size='.$map_w.'x'.$map_h.'&markers=color:green|label:|'.urlencode($address_string).'&sensor=false').'" /></a>'; |
|
166 | 166 | } |
167 | 167 | |
168 | - return '<a href="' . $google_map . '" target="_blank">' . $text . '</a>'; |
|
168 | + return '<a href="'.$google_map.'" target="_blank">'.$text.'</a>'; |
|
169 | 169 | } |
170 | 170 | |
171 | 171 |
@@ -109,7 +109,7 @@ |
||
109 | 109 | * - registers and enqueues the qtip scripts and styles. |
110 | 110 | * |
111 | 111 | * @access public |
112 | - * @param array $paths Array of paths to check for the EE_Qtip class. If present we check these path(s) first. If not present (empty array), then it's assumed it's either in core/libraries/qtips OR the file is already loaded. |
|
112 | + * @param string[] $paths Array of paths to check for the EE_Qtip class. If present we check these path(s) first. If not present (empty array), then it's assumed it's either in core/libraries/qtips OR the file is already loaded. |
|
113 | 113 | * @param string|array $configname name of the Qtip class (full class name is expected and will be used for looking for file, Qtip config classes must extend EE_Qtip_Config) [if this is an array, then we loop through the array to instantiate and setup the qtips] |
114 | 114 | * @return void |
115 | 115 | */ |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public static function instance() { |
34 | 34 | // check if class object is instantiated |
35 | - if ( self::$_instance === NULL or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EEH_Qtip_Loader )) { |
|
35 | + if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EEH_Qtip_Loader)) { |
|
36 | 36 | self::$_instance = new self(); |
37 | 37 | } |
38 | 38 | return self::$_instance; |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | */ |
49 | 49 | private function __construct() { |
50 | 50 | //let's just make sure this is instantiated in the right place. |
51 | - if ( did_action( 'wp_print_styles' ) || did_action( 'admin_head' )) { |
|
52 | - EE_Error::doing_it_wrong( 'EEH_Qtip_Loader', __('This helper must be instantiated before or within a callback for the WordPress wp_enqueue_scripts hook action hook.', 'event_espresso' ), '4.1' ); |
|
51 | + if (did_action('wp_print_styles') || did_action('admin_head')) { |
|
52 | + EE_Error::doing_it_wrong('EEH_Qtip_Loader', __('This helper must be instantiated before or within a callback for the WordPress wp_enqueue_scripts hook action hook.', 'event_espresso'), '4.1'); |
|
53 | 53 | } |
54 | 54 | } |
55 | 55 | |
@@ -61,27 +61,27 @@ discard block |
||
61 | 61 | * @return void |
62 | 62 | */ |
63 | 63 | public function register_and_enqueue() { |
64 | - $qtips_js = !defined('SCRIPT_DEBUG') ? EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.js' : EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.js'; |
|
65 | - $qtip_images_loaded = EE_THIRD_PARTY_URL . 'qtip/imagesloaded.pkg.min.js'; |
|
66 | - $qtip_map = EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.map'; |
|
67 | - $qtipcss = !defined('SCRIPT_DEBUG') ? EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.css' : EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.css'; |
|
64 | + $qtips_js = ! defined('SCRIPT_DEBUG') ? EE_THIRD_PARTY_URL.'qtip/jquery.qtip.min.js' : EE_THIRD_PARTY_URL.'qtip/jquery.qtip.js'; |
|
65 | + $qtip_images_loaded = EE_THIRD_PARTY_URL.'qtip/imagesloaded.pkg.min.js'; |
|
66 | + $qtip_map = EE_THIRD_PARTY_URL.'qtip/jquery.qtip.min.map'; |
|
67 | + $qtipcss = ! defined('SCRIPT_DEBUG') ? EE_THIRD_PARTY_URL.'qtip/jquery.qtip.min.css' : EE_THIRD_PARTY_URL.'qtip/jquery.qtip.css'; |
|
68 | 68 | |
69 | - wp_register_script('qtip-map', $qtip_map, array(), '3', TRUE ); |
|
70 | - wp_register_script('qtip-images-loaded', $qtip_images_loaded, array(), '2.2.0', TRUE ); |
|
71 | - wp_register_script('qtip', $qtips_js, array('jquery'), '2.2.0', TRUE ); |
|
72 | - wp_register_script('ee-qtip-helper', EE_HELPERS_ASSETS . 'ee-qtip-helper.js', array('qtip', 'jquery-cookie'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
69 | + wp_register_script('qtip-map', $qtip_map, array(), '3', TRUE); |
|
70 | + wp_register_script('qtip-images-loaded', $qtip_images_loaded, array(), '2.2.0', TRUE); |
|
71 | + wp_register_script('qtip', $qtips_js, array('jquery'), '2.2.0', TRUE); |
|
72 | + wp_register_script('ee-qtip-helper', EE_HELPERS_ASSETS.'ee-qtip-helper.js', array('qtip', 'jquery-cookie'), EVENT_ESPRESSO_VERSION, TRUE); |
|
73 | 73 | |
74 | - wp_register_style('qtip-css', $qtipcss, array(), '2.2' ); |
|
74 | + wp_register_style('qtip-css', $qtipcss, array(), '2.2'); |
|
75 | 75 | |
76 | 76 | //k now let's see if there are any registered qtips. If there are, then we need to setup the localized script for ee-qtip-helper.js (and enqueue ee-qtip-helper.js of course!) |
77 | - if ( !empty( $this->_qtips ) ) { |
|
77 | + if ( ! empty($this->_qtips)) { |
|
78 | 78 | wp_enqueue_script('ee-qtip-helper'); |
79 | 79 | wp_enqueue_style('qtip-css'); |
80 | 80 | $qtips = array(); |
81 | - foreach ( $this->_qtips as $qtip ) { |
|
81 | + foreach ($this->_qtips as $qtip) { |
|
82 | 82 | $qts = $qtip->get_tips(); |
83 | - foreach ( $qts as $qt ) { |
|
84 | - if ( ! $qt instanceof EE_Qtip ) |
|
83 | + foreach ($qts as $qt) { |
|
84 | + if ( ! $qt instanceof EE_Qtip) |
|
85 | 85 | continue; |
86 | 86 | $qtips[] = array( |
87 | 87 | 'content_id' => $qt->content_id, |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | ); |
91 | 91 | } |
92 | 92 | } |
93 | - if ( !empty($qtips) ) |
|
94 | - wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array( 'qtips' => $qtips ) ); |
|
93 | + if ( ! empty($qtips)) |
|
94 | + wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array('qtips' => $qtips)); |
|
95 | 95 | |
96 | 96 | } else { |
97 | 97 | //qtips has been requested without any registration (so assuming its just directly used in the admin). |
@@ -113,24 +113,24 @@ discard block |
||
113 | 113 | * @param string|array $configname name of the Qtip class (full class name is expected and will be used for looking for file, Qtip config classes must extend EE_Qtip_Config) [if this is an array, then we loop through the array to instantiate and setup the qtips] |
114 | 114 | * @return void |
115 | 115 | */ |
116 | - public function register( $configname, $paths = array() ) { |
|
116 | + public function register($configname, $paths = array()) { |
|
117 | 117 | |
118 | 118 | //let's just make sure this is instantiated in the right place. |
119 | - if ( did_action('wp_enqueue_scripts') || did_action('admin_enqueue_scripts') ) { |
|
120 | - EE_Error::doing_it_wrong( 'EEH_Qtip_Loader->register()', __('EE_Qtip_Config objects must be registered before wp_enqueue_scripts is called.', 'event_espresso' ), '4.1' ); |
|
119 | + if (did_action('wp_enqueue_scripts') || did_action('admin_enqueue_scripts')) { |
|
120 | + EE_Error::doing_it_wrong('EEH_Qtip_Loader->register()', __('EE_Qtip_Config objects must be registered before wp_enqueue_scripts is called.', 'event_espresso'), '4.1'); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | $configname = (array) $configname; //typecast to array |
124 | - foreach ( $configname as $config ) { |
|
125 | - $this->_register( $config, $paths ); |
|
124 | + foreach ($configname as $config) { |
|
125 | + $this->_register($config, $paths); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | //hook into appropriate footer |
129 | 129 | $footer_action = is_admin() ? 'admin_footer' : 'wp_footer'; |
130 | - add_action($footer_action, array($this, 'setup_qtip'), 10 ); |
|
130 | + add_action($footer_action, array($this, 'setup_qtip'), 10); |
|
131 | 131 | |
132 | 132 | //make sure we "turn on" qtip js. |
133 | - add_filter('FHEE_load_qtip', '__return_true' ); |
|
133 | + add_filter('FHEE_load_qtip', '__return_true'); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | |
@@ -144,15 +144,15 @@ discard block |
||
144 | 144 | * @throws EE_Error |
145 | 145 | * @return void |
146 | 146 | */ |
147 | - private function _register( $config, $paths ) { |
|
147 | + private function _register($config, $paths) { |
|
148 | 148 | //before doing anything we have to make sure that EE_Qtip_Config parent is required. |
149 | - EE_Registry::instance()->load_lib( 'Qtip_Config', array(), TRUE ); |
|
149 | + EE_Registry::instance()->load_lib('Qtip_Config', array(), TRUE); |
|
150 | 150 | |
151 | - if ( !empty( $paths ) ) { |
|
151 | + if ( ! empty($paths)) { |
|
152 | 152 | $paths = (array) $paths; |
153 | - foreach ( $paths as $path ) { |
|
154 | - $path = $path . $config . '.lib.php'; |
|
155 | - if ( !is_readable($path ) ) { |
|
153 | + foreach ($paths as $path) { |
|
154 | + $path = $path.$config.'.lib.php'; |
|
155 | + if ( ! is_readable($path)) { |
|
156 | 156 | continue; |
157 | 157 | } else { |
158 | 158 | require_once $path; |
@@ -161,26 +161,26 @@ discard block |
||
161 | 161 | } |
162 | 162 | |
163 | 163 | //does class exist at this point? If it does then let's instantiate. If it doesn't then let's continue with other paths. |
164 | - if ( !class_exists($config) ) { |
|
165 | - $path = EE_LIBRARIES . 'qtips/' . $config . '.lib.php'; |
|
166 | - if ( !is_readable($path ) ) { |
|
167 | - throw new EE_Error( sprintf( __('Unable to load the Qtip Config registered for this page (%s) because none of the file paths attempted are readable. Please check the spelling of the paths you\'ve used in the registration', 'event_espresso'), $config ) ); |
|
164 | + if ( ! class_exists($config)) { |
|
165 | + $path = EE_LIBRARIES.'qtips/'.$config.'.lib.php'; |
|
166 | + if ( ! is_readable($path)) { |
|
167 | + throw new EE_Error(sprintf(__('Unable to load the Qtip Config registered for this page (%s) because none of the file paths attempted are readable. Please check the spelling of the paths you\'ve used in the registration', 'event_espresso'), $config)); |
|
168 | 168 | } else { |
169 | 169 | require_once $path; |
170 | 170 | } |
171 | 171 | } |
172 | 172 | |
173 | 173 | //now we attempt a class_exists one more time. |
174 | - if ( !class_exists( $config ) ) |
|
175 | - throw new EE_Error( sprintf( __('The Qtip_Config class being registered (%s) does not exist, please check the spelling.', 'event_espresso'), $config ) ); |
|
174 | + if ( ! class_exists($config)) |
|
175 | + throw new EE_Error(sprintf(__('The Qtip_Config class being registered (%s) does not exist, please check the spelling.', 'event_espresso'), $config)); |
|
176 | 176 | |
177 | 177 | //made it HERE? FINALLY, let's get things setup. |
178 | 178 | $a = new ReflectionClass($config); |
179 | 179 | $qtip = $a->newInstance(); |
180 | 180 | |
181 | 181 | //verify that $qtip is a valid object |
182 | - if ( ! $qtip instanceof EE_Qtip_Config ) |
|
183 | - throw new EE_Error( sprintf( __( 'The class given for the Qtip loader (%s) is not a child of the <strong>EE_Qtip_Config</strong> class. Please make sure you are extending EE_Qtip_Config.', 'event_espresso'), $config ) ); |
|
182 | + if ( ! $qtip instanceof EE_Qtip_Config) |
|
183 | + throw new EE_Error(sprintf(__('The class given for the Qtip loader (%s) is not a child of the <strong>EE_Qtip_Config</strong> class. Please make sure you are extending EE_Qtip_Config.', 'event_espresso'), $config)); |
|
184 | 184 | |
185 | 185 | $this->_qtips[] = $a->newInstance(); |
186 | 186 | |
@@ -196,12 +196,12 @@ discard block |
||
196 | 196 | * @return void |
197 | 197 | */ |
198 | 198 | public function setup_qtip() { |
199 | - if ( empty( $this->_qtips ) ) |
|
199 | + if (empty($this->_qtips)) |
|
200 | 200 | return; //no qtips! |
201 | 201 | |
202 | 202 | $content = array(); |
203 | 203 | |
204 | - foreach ( $this->_qtips as $qtip ) { |
|
204 | + foreach ($this->_qtips as $qtip) { |
|
205 | 205 | $content[] = $this->_generate_content_container($qtip); |
206 | 206 | } |
207 | 207 | |
@@ -218,10 +218,10 @@ discard block |
||
218 | 218 | private function _generate_content_container($qtip) { |
219 | 219 | $qts = $qtip->get_tips(); |
220 | 220 | $content = array(); |
221 | - foreach ( $qts as $qt ) { |
|
222 | - if ( ! $qt instanceof EE_Qtip ) |
|
221 | + foreach ($qts as $qt) { |
|
222 | + if ( ! $qt instanceof EE_Qtip) |
|
223 | 223 | continue; |
224 | - $content[] = '<div class="ee-qtip-helper-content hidden" id="' . $qt->content_id . '">' . $qt->content . '</div>'; |
|
224 | + $content[] = '<div class="ee-qtip-helper-content hidden" id="'.$qt->content_id.'">'.$qt->content.'</div>'; |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | return implode('<br />', $content); |
@@ -81,8 +81,9 @@ discard block |
||
81 | 81 | foreach ( $this->_qtips as $qtip ) { |
82 | 82 | $qts = $qtip->get_tips(); |
83 | 83 | foreach ( $qts as $qt ) { |
84 | - if ( ! $qt instanceof EE_Qtip ) |
|
85 | - continue; |
|
84 | + if ( ! $qt instanceof EE_Qtip ) { |
|
85 | + continue; |
|
86 | + } |
|
86 | 87 | $qtips[] = array( |
87 | 88 | 'content_id' => $qt->content_id, |
88 | 89 | 'options' => $qt->options, |
@@ -90,8 +91,9 @@ discard block |
||
90 | 91 | ); |
91 | 92 | } |
92 | 93 | } |
93 | - if ( !empty($qtips) ) |
|
94 | - wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array( 'qtips' => $qtips ) ); |
|
94 | + if ( !empty($qtips) ) { |
|
95 | + wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array( 'qtips' => $qtips ) ); |
|
96 | + } |
|
95 | 97 | |
96 | 98 | } else { |
97 | 99 | //qtips has been requested without any registration (so assuming its just directly used in the admin). |
@@ -171,16 +173,18 @@ discard block |
||
171 | 173 | } |
172 | 174 | |
173 | 175 | //now we attempt a class_exists one more time. |
174 | - if ( !class_exists( $config ) ) |
|
175 | - throw new EE_Error( sprintf( __('The Qtip_Config class being registered (%s) does not exist, please check the spelling.', 'event_espresso'), $config ) ); |
|
176 | + if ( !class_exists( $config ) ) { |
|
177 | + throw new EE_Error( sprintf( __('The Qtip_Config class being registered (%s) does not exist, please check the spelling.', 'event_espresso'), $config ) ); |
|
178 | + } |
|
176 | 179 | |
177 | 180 | //made it HERE? FINALLY, let's get things setup. |
178 | 181 | $a = new ReflectionClass($config); |
179 | 182 | $qtip = $a->newInstance(); |
180 | 183 | |
181 | 184 | //verify that $qtip is a valid object |
182 | - if ( ! $qtip instanceof EE_Qtip_Config ) |
|
183 | - throw new EE_Error( sprintf( __( 'The class given for the Qtip loader (%s) is not a child of the <strong>EE_Qtip_Config</strong> class. Please make sure you are extending EE_Qtip_Config.', 'event_espresso'), $config ) ); |
|
185 | + if ( ! $qtip instanceof EE_Qtip_Config ) { |
|
186 | + throw new EE_Error( sprintf( __( 'The class given for the Qtip loader (%s) is not a child of the <strong>EE_Qtip_Config</strong> class. Please make sure you are extending EE_Qtip_Config.', 'event_espresso'), $config ) ); |
|
187 | + } |
|
184 | 188 | |
185 | 189 | $this->_qtips[] = $a->newInstance(); |
186 | 190 | |
@@ -196,8 +200,10 @@ discard block |
||
196 | 200 | * @return void |
197 | 201 | */ |
198 | 202 | public function setup_qtip() { |
199 | - if ( empty( $this->_qtips ) ) |
|
200 | - return; //no qtips! |
|
203 | + if ( empty( $this->_qtips ) ) { |
|
204 | + return; |
|
205 | + } |
|
206 | + //no qtips! |
|
201 | 207 | |
202 | 208 | $content = array(); |
203 | 209 | |
@@ -219,8 +225,9 @@ discard block |
||
219 | 225 | $qts = $qtip->get_tips(); |
220 | 226 | $content = array(); |
221 | 227 | foreach ( $qts as $qt ) { |
222 | - if ( ! $qt instanceof EE_Qtip ) |
|
223 | - continue; |
|
228 | + if ( ! $qt instanceof EE_Qtip ) { |
|
229 | + continue; |
|
230 | + } |
|
224 | 231 | $content[] = '<div class="ee-qtip-helper-content hidden" id="' . $qt->content_id . '">' . $qt->content . '</div>'; |
225 | 232 | } |
226 | 233 |
@@ -131,7 +131,7 @@ |
||
131 | 131 | /** |
132 | 132 | * this just returns the properly formatted tab content for our tab box. |
133 | 133 | * @param string $name name of tab (used for selector) |
134 | - * @param string $content content of tab |
|
134 | + * @param string $tab_content content of tab |
|
135 | 135 | * @return string html for content area |
136 | 136 | */ |
137 | 137 | private static function tab_content($name, $tab_content, $active = false) { |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -43,22 +43,22 @@ discard block |
||
43 | 43 | * @param array $tabs_content an array of the content for each tab [required] |
44 | 44 | * @return string the assembled html string containing the tabbed content for display. |
45 | 45 | */ |
46 | - public static function display($tabs_contents, $tabs_names = array(), $small_tabs = true, $tabs_content = TRUE ) { |
|
46 | + public static function display($tabs_contents, $tabs_names = array(), $small_tabs = true, $tabs_content = TRUE) { |
|
47 | 47 | |
48 | 48 | //first check if $tabs_names is not empty then the count must match the count of $tabs_content otherwise we've got a problem houston |
49 | - if ( !empty( $tabs_names) && ( count( (array) $tabs_names) != count( (array) $tabs_content) ) ) { |
|
50 | - throw new EE_Error( __('The count for $tabs_names and $tabs_content does not match.', 'event_espresso') ); |
|
49 | + if ( ! empty($tabs_names) && (count((array) $tabs_names) != count((array) $tabs_content))) { |
|
50 | + throw new EE_Error(__('The count for $tabs_names and $tabs_content does not match.', 'event_espresso')); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | //make sure we've got incoming data setup properly |
54 | - $tabs = !empty( $tabs_names ) ? (array) $tabs_names : array_keys( (array) $tabs_contents ); |
|
55 | - $tabs_content = !empty( $tabs_names ) ? array_combine( (array) $tabs_names, (array) $tabs_content ) : $tabs_contents; |
|
54 | + $tabs = ! empty($tabs_names) ? (array) $tabs_names : array_keys((array) $tabs_contents); |
|
55 | + $tabs_content = ! empty($tabs_names) ? array_combine((array) $tabs_names, (array) $tabs_content) : $tabs_contents; |
|
56 | 56 | |
57 | - $all_tabs = '<h2 class="nav-tab-wrapper">' . "\n"; |
|
57 | + $all_tabs = '<h2 class="nav-tab-wrapper">'."\n"; |
|
58 | 58 | $all_tabs_content = ''; |
59 | 59 | |
60 | 60 | $index = 0; |
61 | - foreach ( $tabs as $tab ) { |
|
61 | + foreach ($tabs as $tab) { |
|
62 | 62 | $active = $index === 0 ? true : false; |
63 | 63 | $all_tabs .= self::tab($tab, $active); |
64 | 64 | $all_tabs_content .= self::tab_content($tab, $tabs_content[$tab], $active); |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | |
76 | 76 | $tab_container_class = $small_tabs ? 'ee-nav-tabs ee-nav-tabs-small' : 'ee-nav-tabs'; |
77 | 77 | |
78 | - return '<div class="'. $tab_container_class . '">' . "\n\t" . $all_tabs . $all_tabs_content . "\n" . '</div>'; |
|
78 | + return '<div class="'.$tab_container_class.'">'."\n\t".$all_tabs.$all_tabs_content."\n".'</div>'; |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | * @param array $nav_tabs tab array for nav tabs |
99 | 99 | */ |
100 | 100 | public static function display_admin_nav_tabs($nav_tabs = array()) { |
101 | - if ( empty($nav_tabs) ) |
|
102 | - throw new EE_Error( __('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso' ) ); |
|
101 | + if (empty($nav_tabs)) |
|
102 | + throw new EE_Error(__('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso')); |
|
103 | 103 | |
104 | - $all_tabs = '<h2 class="nav-tab-wrapper">' . "\n"; |
|
105 | - foreach ( $nav_tabs as $slug => $tab ) { |
|
104 | + $all_tabs = '<h2 class="nav-tab-wrapper">'."\n"; |
|
105 | + foreach ($nav_tabs as $slug => $tab) { |
|
106 | 106 | $all_tabs .= self::tab($slug, false, $tab['link_text'], $tab['url'], $tab['css_class']); |
107 | 107 | } |
108 | 108 | $all_tabs .= '</h2>'; |
@@ -118,13 +118,13 @@ discard block |
||
118 | 118 | * @param bool|string $css If string given then the generated tab will include that as the class. |
119 | 119 | * @return string html for tab |
120 | 120 | */ |
121 | - private static function tab($name, $active = false, $nice_name = FALSE, $url = FALSE, $css = FALSE ) { |
|
121 | + private static function tab($name, $active = false, $nice_name = FALSE, $url = FALSE, $css = FALSE) { |
|
122 | 122 | $name = str_replace(' ', '-', $name); |
123 | 123 | $class = $active ? 'nav-tab nav-tab-active' : 'nav-tab'; |
124 | - $class = $css ? $class . ' ' . $css : $class; |
|
125 | - $nice_name = $nice_name ? $nice_name : ucwords( preg_replace('/(-|_)/', ' ', $name) ); |
|
126 | - $url = $url ? $url : '#' . $name; |
|
127 | - $tab = '<a class="' . $class . '" rel="ee-tab-' . $name . '" href="' . $url . '">' . $nice_name . '</a>' . "\n\t"; |
|
124 | + $class = $css ? $class.' '.$css : $class; |
|
125 | + $nice_name = $nice_name ? $nice_name : ucwords(preg_replace('/(-|_)/', ' ', $name)); |
|
126 | + $url = $url ? $url : '#'.$name; |
|
127 | + $tab = '<a class="'.$class.'" rel="ee-tab-'.$name.'" href="'.$url.'">'.$nice_name.'</a>'."\n\t"; |
|
128 | 128 | return $tab; |
129 | 129 | } |
130 | 130 | |
@@ -136,9 +136,9 @@ discard block |
||
136 | 136 | */ |
137 | 137 | private static function tab_content($name, $tab_content, $active = false) { |
138 | 138 | $class = $active ? 'nav-tab-content' : 'nav-tab-content hidden'; |
139 | - $name = str_replace( ' ', '-', $name); |
|
140 | - $content = "\t" . '<div class="'. $class . '" id="ee-tab-' . $name . '">' . "\n"; |
|
141 | - $content .= "\t" . $tab_content . "\n"; |
|
139 | + $name = str_replace(' ', '-', $name); |
|
140 | + $content = "\t".'<div class="'.$class.'" id="ee-tab-'.$name.'">'."\n"; |
|
141 | + $content .= "\t".$tab_content."\n"; |
|
142 | 142 | $content .= '<div style="clear:both"></div></div>'; |
143 | 143 | return $content; |
144 | 144 | } |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | * @param string $default You can include a string for the item that will receive the "item_display" class for the js. |
165 | 165 | * @return string a html snippet of of all the formatted link elements. |
166 | 166 | */ |
167 | - public static function tab_text_links( $item_array, $container_class = '', $sep = '|', $default = '' ) { |
|
168 | - if ( !is_array($item_array) || empty( $item_array ) ) |
|
167 | + public static function tab_text_links($item_array, $container_class = '', $sep = '|', $default = '') { |
|
168 | + if ( ! is_array($item_array) || empty($item_array)) |
|
169 | 169 | return false; //get out we don't have even the basic thing we need! |
170 | 170 | |
171 | 171 | |
@@ -176,15 +176,15 @@ discard block |
||
176 | 176 | 'title' => esc_attr__('Link for Item', 'event_espresso'), |
177 | 177 | 'slug' => 'item_slug' |
178 | 178 | ); |
179 | - $container_class = !empty($container_class) ? 'ee-text-links ' . $container_class : 'ee-text-links'; |
|
180 | - $list = '<ul class="' . $container_class . '">'; |
|
179 | + $container_class = ! empty($container_class) ? 'ee-text-links '.$container_class : 'ee-text-links'; |
|
180 | + $list = '<ul class="'.$container_class.'">'; |
|
181 | 181 | |
182 | 182 | $ci = 1; |
183 | - foreach ( $item_array as $item ) { |
|
184 | - $item = wp_parse_args( $item, $defaults ); |
|
185 | - $item['class'] = !empty($default) && $default == $item['slug'] ? 'item_display ' . $item['class'] : $item['class']; |
|
183 | + foreach ($item_array as $item) { |
|
184 | + $item = wp_parse_args($item, $defaults); |
|
185 | + $item['class'] = ! empty($default) && $default == $item['slug'] ? 'item_display '.$item['class'] : $item['class']; |
|
186 | 186 | $list .= self::_text_link_item($item); |
187 | - if ( !empty($sep) && $ci != count($item_array) ) |
|
187 | + if ( ! empty($sep) && $ci != count($item_array)) |
|
188 | 188 | $list .= self::_text_link_item($sep); |
189 | 189 | $ci++; |
190 | 190 | } |
@@ -195,9 +195,9 @@ discard block |
||
195 | 195 | |
196 | 196 | |
197 | 197 | |
198 | - private static function _text_link_item( $item ) { |
|
198 | + private static function _text_link_item($item) { |
|
199 | 199 | //if this isn't an array then we're doing a separator |
200 | - if ( !is_array( $item ) ) { |
|
200 | + if ( ! is_array($item)) { |
|
201 | 201 | $label = $item; |
202 | 202 | $class = 'ee-text-link-sep'; |
203 | 203 | $href = ''; |
@@ -206,12 +206,12 @@ discard block |
||
206 | 206 | extract($item); |
207 | 207 | } |
208 | 208 | |
209 | - $class = $class != 'ee-text-link-sep' ? 'class="ee-text-link-li ' . $class . '"' : 'class="ee-text-link-sep"'; |
|
209 | + $class = $class != 'ee-text-link-sep' ? 'class="ee-text-link-li '.$class.'"' : 'class="ee-text-link-sep"'; |
|
210 | 210 | |
211 | - $content = '<li ' . $class . '>'; |
|
212 | - $content .= !empty($href) ? '<a class="ee-text-link" href="#' . $href . '" title="' . $title . '">' : ''; |
|
211 | + $content = '<li '.$class.'>'; |
|
212 | + $content .= ! empty($href) ? '<a class="ee-text-link" href="#'.$href.'" title="'.$title.'">' : ''; |
|
213 | 213 | $content .= $label; |
214 | - $content .= !empty($href) ? '</a>' : ''; |
|
214 | + $content .= ! empty($href) ? '</a>' : ''; |
|
215 | 215 | $content .= '</li>'; |
216 | 216 | return $content; |
217 | 217 | } |
@@ -1,6 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | +} |
|
4 | 5 | |
5 | 6 | /** |
6 | 7 | * Event Espresso |
@@ -98,8 +99,9 @@ discard block |
||
98 | 99 | * @param array $nav_tabs tab array for nav tabs |
99 | 100 | */ |
100 | 101 | public static function display_admin_nav_tabs($nav_tabs = array()) { |
101 | - if ( empty($nav_tabs) ) |
|
102 | - throw new EE_Error( __('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso' ) ); |
|
102 | + if ( empty($nav_tabs) ) { |
|
103 | + throw new EE_Error( __('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso' ) ); |
|
104 | + } |
|
103 | 105 | |
104 | 106 | $all_tabs = '<h2 class="nav-tab-wrapper">' . "\n"; |
105 | 107 | foreach ( $nav_tabs as $slug => $tab ) { |
@@ -165,8 +167,10 @@ discard block |
||
165 | 167 | * @return string a html snippet of of all the formatted link elements. |
166 | 168 | */ |
167 | 169 | public static function tab_text_links( $item_array, $container_class = '', $sep = '|', $default = '' ) { |
168 | - if ( !is_array($item_array) || empty( $item_array ) ) |
|
169 | - return false; //get out we don't have even the basic thing we need! |
|
170 | + if ( !is_array($item_array) || empty( $item_array ) ) { |
|
171 | + return false; |
|
172 | + } |
|
173 | + //get out we don't have even the basic thing we need! |
|
170 | 174 | |
171 | 175 | |
172 | 176 | $defaults = array( |
@@ -184,8 +188,9 @@ discard block |
||
184 | 188 | $item = wp_parse_args( $item, $defaults ); |
185 | 189 | $item['class'] = !empty($default) && $default == $item['slug'] ? 'item_display ' . $item['class'] : $item['class']; |
186 | 190 | $list .= self::_text_link_item($item); |
187 | - if ( !empty($sep) && $ci != count($item_array) ) |
|
188 | - $list .= self::_text_link_item($sep); |
|
191 | + if ( !empty($sep) && $ci != count($item_array) ) { |
|
192 | + $list .= self::_text_link_item($sep); |
|
193 | + } |
|
189 | 194 | $ci++; |
190 | 195 | } |
191 | 196 |
@@ -248,7 +248,7 @@ |
||
248 | 248 | * @param bool|string $template_path server path to the file to be loaded, including file name and extension |
249 | 249 | * @param array $template_args an array of arguments to be extracted for use in the template |
250 | 250 | * @param boolean $return_string whether to send output immediately to screen, or capture and return as a string |
251 | - * @return mixed string |
|
251 | + * @return string string |
|
252 | 252 | */ |
253 | 253 | public static function display_template( $template_path = FALSE, $template_args = array(), $return_string = FALSE ) { |
254 | 254 | //require the template validator for verifying variables are set according to how the template requires |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | return array(); |
100 | 100 | } |
101 | 101 | if (( $key = array_search( 'global_assets', $espresso_themes )) !== FALSE ) { |
102 | - unset( $espresso_themes[ $key ] ); |
|
102 | + unset( $espresso_themes[ $key ] ); |
|
103 | 103 | } |
104 | 104 | EEH_Template::$_espresso_themes = array(); |
105 | 105 | foreach ( $espresso_themes as $espresso_theme ) { |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | foreach ( (array)$full_template_paths as $full_template_path ) { |
227 | 227 | if ( is_readable( $full_template_path )) { |
228 | 228 | $template_path = str_replace( array( '\\', '/' ), DIRECTORY_SEPARATOR, $full_template_path ); |
229 | - break; |
|
229 | + break; |
|
230 | 230 | } |
231 | 231 | } |
232 | 232 | } |
@@ -648,9 +648,9 @@ discard block |
||
648 | 648 | ); |
649 | 649 | |
650 | 650 | if ( empty( $items_label ) |
651 | - || ! is_array( $items_label ) |
|
652 | - || ! isset( $items_label['single'] ) |
|
653 | - || ! isset( $items_label['plural'] ) ) { |
|
651 | + || ! is_array( $items_label ) |
|
652 | + || ! isset( $items_label['single'] ) |
|
653 | + || ! isset( $items_label['plural'] ) ) { |
|
654 | 654 | $items_label = array( |
655 | 655 | 'single' => __( '1 item', 'event_espresso' ), |
656 | 656 | 'plural' => __( '%s items', 'event_espresso' ) |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | |
17 | 17 | |
18 | -if ( ! function_exists( 'espresso_get_template_part' )) { |
|
18 | +if ( ! function_exists('espresso_get_template_part')) { |
|
19 | 19 | /** |
20 | 20 | * espresso_get_template_part |
21 | 21 | * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files |
@@ -25,14 +25,14 @@ discard block |
||
25 | 25 | * @param string $name The name of the specialised template. |
26 | 26 | * @return string the html output for the formatted money value |
27 | 27 | */ |
28 | - function espresso_get_template_part( $slug = NULL, $name = NULL ) { |
|
29 | - EEH_Template::get_template_part( $slug, $name ); |
|
28 | + function espresso_get_template_part($slug = NULL, $name = NULL) { |
|
29 | + EEH_Template::get_template_part($slug, $name); |
|
30 | 30 | } |
31 | 31 | } |
32 | 32 | |
33 | 33 | |
34 | 34 | |
35 | -if ( ! function_exists( 'espresso_get_object_css_class' )) { |
|
35 | +if ( ! function_exists('espresso_get_object_css_class')) { |
|
36 | 36 | /** |
37 | 37 | * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed |
38 | 38 | * |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | * @param string $suffix added to the end of the generated class |
43 | 43 | * @return string |
44 | 44 | */ |
45 | - function espresso_get_object_css_class( $object = NULL, $prefix = '', $suffix = '' ) { |
|
46 | - return EEH_Template::get_object_css_class( $object, $prefix, $suffix ); |
|
45 | + function espresso_get_object_css_class($object = NULL, $prefix = '', $suffix = '') { |
|
46 | + return EEH_Template::get_object_css_class($object, $prefix, $suffix); |
|
47 | 47 | } |
48 | 48 | } |
49 | 49 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @return boolean |
71 | 71 | */ |
72 | 72 | public static function is_espresso_theme() { |
73 | - return wp_get_theme()->get( 'TextDomain' ) == 'event_espresso' ? TRUE : FALSE; |
|
73 | + return wp_get_theme()->get('TextDomain') == 'event_espresso' ? TRUE : FALSE; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | * @return void |
80 | 80 | */ |
81 | 81 | public static function load_espresso_theme_functions() { |
82 | - if ( ! defined( 'EE_THEME_FUNCTIONS_LOADED' )) { |
|
83 | - if ( is_readable( EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php' )) { |
|
84 | - require_once( EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php' ); |
|
82 | + if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) { |
|
83 | + if (is_readable(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php')) { |
|
84 | + require_once(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php'); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | } |
@@ -93,17 +93,17 @@ discard block |
||
93 | 93 | * @return array |
94 | 94 | */ |
95 | 95 | public static function get_espresso_themes() { |
96 | - if ( empty( EEH_Template::$_espresso_themes )) { |
|
97 | - $espresso_themes = glob( EE_PUBLIC . '*', GLOB_ONLYDIR ); |
|
98 | - if ( empty( $espresso_themes ) ) { |
|
96 | + if (empty(EEH_Template::$_espresso_themes)) { |
|
97 | + $espresso_themes = glob(EE_PUBLIC.'*', GLOB_ONLYDIR); |
|
98 | + if (empty($espresso_themes)) { |
|
99 | 99 | return array(); |
100 | 100 | } |
101 | - if (( $key = array_search( 'global_assets', $espresso_themes )) !== FALSE ) { |
|
102 | - unset( $espresso_themes[ $key ] ); |
|
101 | + if (($key = array_search('global_assets', $espresso_themes)) !== FALSE) { |
|
102 | + unset($espresso_themes[$key]); |
|
103 | 103 | } |
104 | 104 | EEH_Template::$_espresso_themes = array(); |
105 | - foreach ( $espresso_themes as $espresso_theme ) { |
|
106 | - EEH_Template::$_espresso_themes[ basename( $espresso_theme ) ] = $espresso_theme; |
|
105 | + foreach ($espresso_themes as $espresso_theme) { |
|
106 | + EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme; |
|
107 | 107 | } |
108 | 108 | } |
109 | 109 | return EEH_Template::$_espresso_themes; |
@@ -122,16 +122,16 @@ discard block |
||
122 | 122 | * @param bool $return_string |
123 | 123 | * @return string the html output for the formatted money value |
124 | 124 | */ |
125 | - public static function get_template_part( $slug = NULL, $name = NULL, $template_args = array(), $return_string = FALSE ) { |
|
126 | - do_action( "get_template_part_{$slug}-{$name}", $slug, $name ); |
|
125 | + public static function get_template_part($slug = NULL, $name = NULL, $template_args = array(), $return_string = FALSE) { |
|
126 | + do_action("get_template_part_{$slug}-{$name}", $slug, $name); |
|
127 | 127 | $templates = array(); |
128 | 128 | $name = (string) $name; |
129 | - if ( $name != '' ) { |
|
129 | + if ($name != '') { |
|
130 | 130 | $templates[] = "{$slug}-{$name}.php"; |
131 | 131 | } |
132 | 132 | // allow template parts to be turned off via something like: add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' ); |
133 | - if ( apply_filters( "FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", TRUE )) { |
|
134 | - EEH_Template::locate_template( $templates, $template_args, TRUE, $return_string ); |
|
133 | + if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", TRUE)) { |
|
134 | + EEH_Template::locate_template($templates, $template_args, TRUE, $return_string); |
|
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
@@ -156,26 +156,26 @@ discard block |
||
156 | 156 | * Used in places where you don't actually load the template, you just want to know if there's a custom version of it. |
157 | 157 | * @return mixed |
158 | 158 | */ |
159 | - public static function locate_template( $templates = array(), $template_args = array(), $load = TRUE, $return_string = TRUE, $check_if_custom = FALSE ) { |
|
159 | + public static function locate_template($templates = array(), $template_args = array(), $load = TRUE, $return_string = TRUE, $check_if_custom = FALSE) { |
|
160 | 160 | // first use WP locate_template to check for template in the current theme folder |
161 | - $template_path = locate_template( $templates ); |
|
161 | + $template_path = locate_template($templates); |
|
162 | 162 | |
163 | - if ( $check_if_custom && !empty( $template_path ) ) |
|
163 | + if ($check_if_custom && ! empty($template_path)) |
|
164 | 164 | return TRUE; |
165 | 165 | |
166 | 166 | // not in the theme |
167 | - if ( empty( $template_path )) { |
|
167 | + if (empty($template_path)) { |
|
168 | 168 | // not even a template to look for ? |
169 | - if ( empty( $templates )) { |
|
169 | + if (empty($templates)) { |
|
170 | 170 | // get post_type |
171 | - $post_type = EE_Registry::instance()->REQ->get( 'post_type' ); |
|
171 | + $post_type = EE_Registry::instance()->REQ->get('post_type'); |
|
172 | 172 | // get array of EE Custom Post Types |
173 | 173 | $EE_CPTs = EE_Register_CPTs::get_CPTs(); |
174 | 174 | // build template name based on request |
175 | - if ( isset( $EE_CPTs[ $post_type ] )) { |
|
176 | - $archive_or_single = is_archive() ? 'archive' : ''; |
|
177 | - $archive_or_single = is_single() ? 'single' : $archive_or_single; |
|
178 | - $templates = $archive_or_single . '-' . $post_type . '.php'; |
|
175 | + if (isset($EE_CPTs[$post_type])) { |
|
176 | + $archive_or_single = is_archive() ? 'archive' : ''; |
|
177 | + $archive_or_single = is_single() ? 'single' : $archive_or_single; |
|
178 | + $templates = $archive_or_single.'-'.$post_type.'.php'; |
|
179 | 179 | } |
180 | 180 | } |
181 | 181 | // currently active EE template theme |
@@ -184,61 +184,61 @@ discard block |
||
184 | 184 | // array of paths to folders that may contain templates |
185 | 185 | $template_folder_paths = array( |
186 | 186 | // first check the /wp-content/uploads/espresso/templates/(current EE theme)/ folder for an EE theme template file |
187 | - EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme, |
|
187 | + EVENT_ESPRESSO_TEMPLATE_DIR.$current_theme, |
|
188 | 188 | // then in the root of the /wp-content/uploads/espresso/templates/ folder |
189 | 189 | EVENT_ESPRESSO_TEMPLATE_DIR |
190 | 190 | ); |
191 | 191 | |
192 | 192 | //add core plugin folders for checking only if we're not $check_if_custom |
193 | - if ( ! $check_if_custom ) { |
|
193 | + if ( ! $check_if_custom) { |
|
194 | 194 | $core_paths = array( |
195 | 195 | // in the /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin |
196 | - EE_PUBLIC . $current_theme, |
|
196 | + EE_PUBLIC.$current_theme, |
|
197 | 197 | // in the /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin |
198 | - EE_TEMPLATES . $current_theme, |
|
198 | + EE_TEMPLATES.$current_theme, |
|
199 | 199 | // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/ |
200 | 200 | EE_PLUGIN_DIR_PATH |
201 | 201 | ); |
202 | - $template_folder_paths = array_merge( $template_folder_paths, $core_paths ); |
|
202 | + $template_folder_paths = array_merge($template_folder_paths, $core_paths); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | // now filter that array |
206 | - $template_folder_paths = apply_filters( 'FHEE__EEH_Template__locate_template__template_folder_paths', $template_folder_paths ); |
|
206 | + $template_folder_paths = apply_filters('FHEE__EEH_Template__locate_template__template_folder_paths', $template_folder_paths); |
|
207 | 207 | |
208 | 208 | // array to hold all possible template paths |
209 | 209 | $full_template_paths = array(); |
210 | 210 | |
211 | 211 | // loop through $templates |
212 | - foreach ( (array)$templates as $template ) { |
|
212 | + foreach ((array) $templates as $template) { |
|
213 | 213 | // while looping through all template folder paths |
214 | - foreach ( (array)$template_folder_paths as $template_folder_path ) { |
|
214 | + foreach ((array) $template_folder_paths as $template_folder_path) { |
|
215 | 215 | // build up our template locations array by combining our template folder paths with our templates |
216 | - $full_template_paths[] = rtrim( $template_folder_path, DS ) . DS . $template; |
|
216 | + $full_template_paths[] = rtrim($template_folder_path, DS).DS.$template; |
|
217 | 217 | } |
218 | 218 | // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first |
219 | - array_unshift( $full_template_paths, $template ); |
|
219 | + array_unshift($full_template_paths, $template); |
|
220 | 220 | } |
221 | 221 | // filter final array of full template paths |
222 | - $full_template_paths = apply_filters( 'FHEE__EEH_Template__locate_template__full_template_paths', $full_template_paths ); |
|
222 | + $full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths', $full_template_paths); |
|
223 | 223 | |
224 | 224 | |
225 | 225 | // now loop through our final array of template location paths and check each location |
226 | - foreach ( (array)$full_template_paths as $full_template_path ) { |
|
227 | - if ( is_readable( $full_template_path )) { |
|
228 | - $template_path = str_replace( array( '\\', '/' ), DIRECTORY_SEPARATOR, $full_template_path ); |
|
226 | + foreach ((array) $full_template_paths as $full_template_path) { |
|
227 | + if (is_readable($full_template_path)) { |
|
228 | + $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path); |
|
229 | 229 | break; |
230 | 230 | } |
231 | 231 | } |
232 | 232 | } |
233 | 233 | // if we got it and you want to see it... |
234 | - if ( $template_path && $load && ! $check_if_custom ) { |
|
235 | - if ( $return_string ) { |
|
236 | - return EEH_Template::display_template( $template_path, $template_args, TRUE ); |
|
234 | + if ($template_path && $load && ! $check_if_custom) { |
|
235 | + if ($return_string) { |
|
236 | + return EEH_Template::display_template($template_path, $template_args, TRUE); |
|
237 | 237 | } else { |
238 | - EEH_Template::display_template( $template_path, $template_args, FALSE ); |
|
238 | + EEH_Template::display_template($template_path, $template_args, FALSE); |
|
239 | 239 | } |
240 | 240 | } |
241 | - return $check_if_custom && ! empty( $template_path ) ? TRUE : $template_path; |
|
241 | + return $check_if_custom && ! empty($template_path) ? TRUE : $template_path; |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | |
@@ -250,9 +250,9 @@ discard block |
||
250 | 250 | * @param boolean $return_string whether to send output immediately to screen, or capture and return as a string |
251 | 251 | * @return mixed string |
252 | 252 | */ |
253 | - public static function display_template( $template_path = FALSE, $template_args = array(), $return_string = FALSE ) { |
|
253 | + public static function display_template($template_path = FALSE, $template_args = array(), $return_string = FALSE) { |
|
254 | 254 | //require the template validator for verifying variables are set according to how the template requires |
255 | - EE_Registry::instance()->load_helper( 'Template_Validator' ); |
|
255 | + EE_Registry::instance()->load_helper('Template_Validator'); |
|
256 | 256 | |
257 | 257 | /** |
258 | 258 | * These two filters are intended for last minute changes to templates being loaded and/or template arg |
@@ -263,26 +263,26 @@ discard block |
||
263 | 263 | * |
264 | 264 | * @since 4.6.0 |
265 | 265 | */ |
266 | - $template_path = apply_filters( 'FHEE__EEH_Template__display_template__template_path', $template_path ); |
|
267 | - $template_args = apply_filters( 'FHEE__EEH_Template__display_template__template_args', $template_args ); |
|
266 | + $template_path = apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path); |
|
267 | + $template_args = apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args); |
|
268 | 268 | |
269 | 269 | // you gimme nuttin - YOU GET NUTTIN !! |
270 | - if ( ! $template_path || ! is_readable( $template_path )) { |
|
270 | + if ( ! $template_path || ! is_readable($template_path)) { |
|
271 | 271 | return ''; |
272 | 272 | } |
273 | 273 | // if $template_args are not in an array, then make it so |
274 | - if ( ! is_array( $template_args ) && ! is_object( $template_args )) { |
|
275 | - $template_args = array( $template_args ); |
|
274 | + if ( ! is_array($template_args) && ! is_object($template_args)) { |
|
275 | + $template_args = array($template_args); |
|
276 | 276 | } |
277 | - extract( (array) $template_args); |
|
277 | + extract((array) $template_args); |
|
278 | 278 | |
279 | - if ( $return_string ) { |
|
279 | + if ($return_string) { |
|
280 | 280 | // because we want to return a string, we are going to capture the output |
281 | 281 | ob_start(); |
282 | - include( $template_path ); |
|
282 | + include($template_path); |
|
283 | 283 | return ob_get_clean(); |
284 | 284 | } else { |
285 | - include( $template_path ); |
|
285 | + include($template_path); |
|
286 | 286 | } |
287 | 287 | return ''; |
288 | 288 | } |
@@ -300,27 +300,27 @@ discard block |
||
300 | 300 | * @param string $suffix added to the end of the generated class |
301 | 301 | * @return string |
302 | 302 | */ |
303 | - public static function get_object_css_class( $object = NULL, $prefix = '', $suffix = '' ) { |
|
303 | + public static function get_object_css_class($object = NULL, $prefix = '', $suffix = '') { |
|
304 | 304 | // in the beginning... |
305 | - $prefix = ! empty( $prefix ) ? rtrim( $prefix, '-' ) . '-' : ''; |
|
305 | + $prefix = ! empty($prefix) ? rtrim($prefix, '-').'-' : ''; |
|
306 | 306 | // da muddle |
307 | 307 | $class = ''; |
308 | 308 | // the end |
309 | - $suffix = ! empty( $suffix ) ? '-' . ltrim( $suffix, '-' ) : ''; |
|
309 | + $suffix = ! empty($suffix) ? '-'.ltrim($suffix, '-') : ''; |
|
310 | 310 | // is the passed object an EE object ? |
311 | - if ( $object instanceof EE_Base_Class ) { |
|
311 | + if ($object instanceof EE_Base_Class) { |
|
312 | 312 | // grab the exact type of object |
313 | - $obj_class = get_class( $object ); |
|
313 | + $obj_class = get_class($object); |
|
314 | 314 | // depending on the type of object... |
315 | - switch ( $obj_class ) { |
|
315 | + switch ($obj_class) { |
|
316 | 316 | // no specifics just yet... |
317 | 317 | default : |
318 | - $class = strtolower( str_replace( '_', '-', $obj_class )); |
|
319 | - $class .= method_exists( $obj_class, 'name' ) ? '-' . sanitize_title( $object->name() ) : ''; |
|
318 | + $class = strtolower(str_replace('_', '-', $obj_class)); |
|
319 | + $class .= method_exists($obj_class, 'name') ? '-'.sanitize_title($object->name()) : ''; |
|
320 | 320 | |
321 | 321 | } |
322 | 322 | } |
323 | - return $prefix . $class . $suffix; |
|
323 | + return $prefix.$class.$suffix; |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | |
@@ -336,50 +336,50 @@ discard block |
||
336 | 336 | * @param string $cur_code_span_class |
337 | 337 | * @return string the html output for the formatted money value |
338 | 338 | */ |
339 | - public static function format_currency( $amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code' ) { |
|
339 | + public static function format_currency($amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code') { |
|
340 | 340 | // ensure amount was received |
341 | - if ( is_null( $amount ) ) { |
|
342 | - $msg = __( 'In order to format currency, an amount needs to be passed.', 'event_espresso' ); |
|
343 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
341 | + if (is_null($amount)) { |
|
342 | + $msg = __('In order to format currency, an amount needs to be passed.', 'event_espresso'); |
|
343 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
344 | 344 | return ''; |
345 | 345 | } |
346 | 346 | //ensure amount is float |
347 | 347 | $amount = (float) $amount; |
348 | 348 | // filter raw amount (allows 0.00 to be changed to "free" for example) |
349 | - $amount_formatted = apply_filters( 'FHEE__EEH_Template__format_currency__amount', $amount, $return_raw ); |
|
349 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw); |
|
350 | 350 | // still a number or was amount converted to a string like "free" ? |
351 | - if ( is_float( $amount_formatted )) { |
|
351 | + if (is_float($amount_formatted)) { |
|
352 | 352 | // was a country ISO code passed ? if so generate currency config object for that country |
353 | - $mny = $CNT_ISO !== '' ? new EE_Currency_Config( $CNT_ISO ) : NULL; |
|
353 | + $mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : NULL; |
|
354 | 354 | // verify results |
355 | - if ( ! $mny instanceof EE_Currency_Config ) { |
|
355 | + if ( ! $mny instanceof EE_Currency_Config) { |
|
356 | 356 | // set default config country currency settings |
357 | 357 | $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config ? EE_Registry::instance()->CFG->currency : new EE_Currency_Config(); |
358 | 358 | } |
359 | 359 | // format float |
360 | - $amount_formatted = number_format( $amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds ); |
|
360 | + $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds); |
|
361 | 361 | // add formatting ? |
362 | - if ( ! $return_raw ) { |
|
362 | + if ( ! $return_raw) { |
|
363 | 363 | // add currency sign |
364 | - if( $mny->sign_b4 ){ |
|
365 | - if( $amount >= 0 ){ |
|
366 | - $amount_formatted = $mny->sign . $amount_formatted; |
|
367 | - }else{ |
|
368 | - $amount_formatted = '-' . $mny->sign . str_replace( '-', '', $amount_formatted ); |
|
364 | + if ($mny->sign_b4) { |
|
365 | + if ($amount >= 0) { |
|
366 | + $amount_formatted = $mny->sign.$amount_formatted; |
|
367 | + } else { |
|
368 | + $amount_formatted = '-'.$mny->sign.str_replace('-', '', $amount_formatted); |
|
369 | 369 | } |
370 | 370 | |
371 | - }else{ |
|
372 | - $amount_formatted = $amount_formatted . $mny->sign; |
|
371 | + } else { |
|
372 | + $amount_formatted = $amount_formatted.$mny->sign; |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | // add currency code ? |
376 | - $amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted; |
|
376 | + $amount_formatted = $display_code ? $amount_formatted.' <span class="'.$cur_code_span_class.'">('.$mny->code.')</span>' : $amount_formatted; |
|
377 | 377 | } |
378 | 378 | // filter results |
379 | - $amount_formatted = apply_filters( 'FHEE__EEH_Template__format_currency__amount_formatted', $amount_formatted, $mny, $return_raw ); |
|
379 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted', $amount_formatted, $mny, $return_raw); |
|
380 | 380 | } |
381 | 381 | // clean up vars |
382 | - unset( $mny ); |
|
382 | + unset($mny); |
|
383 | 383 | // return formatted currency amount |
384 | 384 | return $amount_formatted; |
385 | 385 | } |
@@ -394,11 +394,11 @@ discard block |
||
394 | 394 | * @param string $schema 'UPPER', 'lower', or 'Sentence' |
395 | 395 | * @return string The localized label for the status id. |
396 | 396 | */ |
397 | - public static function pretty_status( $status_id, $plural = FALSE, $schema = 'upper' ) { |
|
397 | + public static function pretty_status($status_id, $plural = FALSE, $schema = 'upper') { |
|
398 | 398 | /** @type EEM_Status $EEM_Status */ |
399 | - $EEM_Status = EE_Registry::instance()->load_model( 'Status' ); |
|
400 | - $status = $EEM_Status->localized_status( array( $status_id => __( 'unknown', 'event_espresso' )), $plural, $schema ); |
|
401 | - return $status[ $status_id ]; |
|
399 | + $EEM_Status = EE_Registry::instance()->load_model('Status'); |
|
400 | + $status = $EEM_Status->localized_status(array($status_id => __('unknown', 'event_espresso')), $plural, $schema); |
|
401 | + return $status[$status_id]; |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | |
@@ -411,9 +411,9 @@ discard block |
||
411 | 411 | * @param string $icon |
412 | 412 | * @return string the html output for the button |
413 | 413 | */ |
414 | - public static function get_button_or_link( $url, $label, $class = 'button-primary', $icon = '' ) { |
|
415 | - $label = ! empty( $icon ) ? '<span class="' . $icon . '"></span>' . $label : $label; |
|
416 | - $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . $url . '" class="' . $class . '">' . $label . '</a>'; |
|
414 | + public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '') { |
|
415 | + $label = ! empty($icon) ? '<span class="'.$icon.'"></span>'.$label : $label; |
|
416 | + $button = '<a id="'.sanitize_title_with_dashes($label).'" href="'.$url.'" class="'.$class.'">'.$label.'</a>'; |
|
417 | 417 | return $button; |
418 | 418 | } |
419 | 419 | |
@@ -430,21 +430,21 @@ discard block |
||
430 | 430 | * @param bool|string $help_text (optional) send help text you want to use for the link if default not to be used |
431 | 431 | * @return string generated link |
432 | 432 | */ |
433 | - public static function get_help_tab_link( $help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE ) { |
|
433 | + public static function get_help_tab_link($help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE) { |
|
434 | 434 | |
435 | - if ( ! $page ) |
|
436 | - $page = isset( $_REQUEST['page'] ) && ! empty( $_REQUEST['page'] ) ? sanitize_key( $_REQUEST['page'] ) : $page; |
|
435 | + if ( ! $page) |
|
436 | + $page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page; |
|
437 | 437 | |
438 | - if ( ! $action ) |
|
439 | - $action = isset( $_REQUEST['action'] ) && ! empty( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : $action; |
|
438 | + if ( ! $action) |
|
439 | + $action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action; |
|
440 | 440 | |
441 | 441 | $action = empty($action) ? 'default' : $action; |
442 | 442 | |
443 | 443 | |
444 | - $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id; |
|
445 | - $icon = !$icon_style ? ' dashicons-editor-help' : $icon_style; |
|
446 | - $help_text = !$help_text ? '' : $help_text; |
|
447 | - return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.', 'event_espresso') . '" > ' . $help_text . ' </a>'; |
|
444 | + $help_tab_lnk = $page.'-'.$action.'-'.$help_tab_id; |
|
445 | + $icon = ! $icon_style ? ' dashicons-editor-help' : $icon_style; |
|
446 | + $help_text = ! $help_text ? '' : $help_text; |
|
447 | + return '<a id="'.$help_tab_lnk.'" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22'.$icon.'" title="'.esc_attr__('Click to open the \'Help\' tab for more information about this feature.', 'event_espresso').'" > '.$help_text.' </a>'; |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | |
@@ -456,31 +456,31 @@ discard block |
||
456 | 456 | * @param EE_Help_Tour |
457 | 457 | * @return string html |
458 | 458 | */ |
459 | - public static function help_tour_stops_generator( EE_Help_Tour $tour ) { |
|
459 | + public static function help_tour_stops_generator(EE_Help_Tour $tour) { |
|
460 | 460 | $id = $tour->get_slug(); |
461 | 461 | $stops = $tour->get_stops(); |
462 | 462 | |
463 | - $content = '<ol style="display:none" id="' . $id . '">'; |
|
463 | + $content = '<ol style="display:none" id="'.$id.'">'; |
|
464 | 464 | |
465 | - foreach ( $stops as $stop ) { |
|
466 | - $data_id = !empty( $stop['id'] ) ? ' data-id="' . $stop['id'] . '"' : ''; |
|
467 | - $data_class = empty( $data_id ) && !empty( $stop['class'] ) ? ' data-class="' . $stop['class'] . '"' : ''; |
|
465 | + foreach ($stops as $stop) { |
|
466 | + $data_id = ! empty($stop['id']) ? ' data-id="'.$stop['id'].'"' : ''; |
|
467 | + $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="'.$stop['class'].'"' : ''; |
|
468 | 468 | |
469 | 469 | //if container is set to modal then let's make sure we set the options accordingly |
470 | - if ( empty( $data_id ) && empty( $data_class ) ) { |
|
470 | + if (empty($data_id) && empty($data_class)) { |
|
471 | 471 | $stop['options']['modal'] = true; |
472 | 472 | $stop['options']['expose'] = true; |
473 | 473 | } |
474 | 474 | |
475 | - $custom_class = !empty( $stop['custom_class'] ) ? ' class="' . $stop['custom_class'] . '"' : ''; |
|
476 | - $button_text = !empty( $stop['button_text'] ) ? ' data-button="' . $stop['button_text'] . '"' : ''; |
|
475 | + $custom_class = ! empty($stop['custom_class']) ? ' class="'.$stop['custom_class'].'"' : ''; |
|
476 | + $button_text = ! empty($stop['button_text']) ? ' data-button="'.$stop['button_text'].'"' : ''; |
|
477 | 477 | $inner_content = isset($stop['content']) ? $stop['content'] : ''; |
478 | 478 | |
479 | 479 | //options |
480 | - if ( isset( $stop['options'] ) && is_array( $stop['options'] ) ) { |
|
480 | + if (isset($stop['options']) && is_array($stop['options'])) { |
|
481 | 481 | $options = ' data-options="'; |
482 | - foreach ( $stop['options'] as $option => $value ) { |
|
483 | - $options .= $option . ':' . $value . ';'; |
|
482 | + foreach ($stop['options'] as $option => $value) { |
|
483 | + $options .= $option.':'.$value.';'; |
|
484 | 484 | } |
485 | 485 | $options .= '"'; |
486 | 486 | } else { |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | } |
489 | 489 | |
490 | 490 | //let's put all together |
491 | - $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>'; |
|
491 | + $content .= '<li'.$data_id.$data_class.$custom_class.$button_text.$options.'>'.$inner_content.'</li>'; |
|
492 | 492 | } |
493 | 493 | |
494 | 494 | $content .= '</ol>'; |
@@ -509,31 +509,31 @@ discard block |
||
509 | 509 | * @throws EE_Error |
510 | 510 | * @return string html structure for status. |
511 | 511 | */ |
512 | - public static function status_legend( $status_array, $active_status = '' ) { |
|
513 | - if ( !is_array( $status_array ) ) |
|
514 | - throw new EE_Error( __('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso') ); |
|
512 | + public static function status_legend($status_array, $active_status = '') { |
|
513 | + if ( ! is_array($status_array)) |
|
514 | + throw new EE_Error(__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso')); |
|
515 | 515 | |
516 | 516 | $setup_array = array(); |
517 | - foreach ( $status_array as $item => $status ) { |
|
517 | + foreach ($status_array as $item => $status) { |
|
518 | 518 | $setup_array[$item] = array( |
519 | - 'class' => 'ee-status-legend ee-status-legend-' . $status, |
|
520 | - 'desc' => EEH_Template::pretty_status( $status, FALSE, 'sentence' ), |
|
519 | + 'class' => 'ee-status-legend ee-status-legend-'.$status, |
|
520 | + 'desc' => EEH_Template::pretty_status($status, FALSE, 'sentence'), |
|
521 | 521 | 'status' => $status |
522 | 522 | ); |
523 | 523 | } |
524 | 524 | |
525 | - $content = '<div class="ee-list-table-legend-container">' . "\n"; |
|
526 | - $content .= '<h4>' . __('Status Legend', 'event_espresso') . '</h4>' . "\n"; |
|
527 | - $content .= '<dl class="ee-list-table-legend">' . "\n\t"; |
|
528 | - foreach ( $setup_array as $item => $details ) { |
|
525 | + $content = '<div class="ee-list-table-legend-container">'."\n"; |
|
526 | + $content .= '<h4>'.__('Status Legend', 'event_espresso').'</h4>'."\n"; |
|
527 | + $content .= '<dl class="ee-list-table-legend">'."\n\t"; |
|
528 | + foreach ($setup_array as $item => $details) { |
|
529 | 529 | $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : ''; |
530 | - $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t"; |
|
531 | - $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t"; |
|
532 | - $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t"; |
|
533 | - $content .= '</dt>' . "\n"; |
|
530 | + $content .= '<dt id="ee-legend-item-tooltip-'.$item.'"'.$active_class.'>'."\n\t\t"; |
|
531 | + $content .= '<span class="'.$details['class'].'"></span>'."\n\t\t"; |
|
532 | + $content .= '<span class="ee-legend-description">'.$details['desc'].'</span>'."\n\t"; |
|
533 | + $content .= '</dt>'."\n"; |
|
534 | 534 | } |
535 | - $content .= '</dl>' . "\n"; |
|
536 | - $content .= '</div>' . "\n"; |
|
535 | + $content .= '</dl>'."\n"; |
|
536 | + $content .= '</div>'."\n"; |
|
537 | 537 | return $content; |
538 | 538 | } |
539 | 539 | |
@@ -546,8 +546,8 @@ discard block |
||
546 | 546 | * @return string |
547 | 547 | */ |
548 | 548 | public static function layout_array_as_table($data) { |
549 | - if (is_object($data) || $data instanceof __PHP_Incomplete_Class ) { |
|
550 | - $data = (array)$data; |
|
549 | + if (is_object($data) || $data instanceof __PHP_Incomplete_Class) { |
|
550 | + $data = (array) $data; |
|
551 | 551 | } |
552 | 552 | EE_Registry::instance()->load_helper('Array'); |
553 | 553 | ob_start(); |
@@ -561,10 +561,10 @@ discard block |
||
561 | 561 | ?> |
562 | 562 | <tr> |
563 | 563 | <td> |
564 | - <?php echo $data_key;?> |
|
564 | + <?php echo $data_key; ?> |
|
565 | 565 | </td> |
566 | 566 | <td> |
567 | - <?php echo self::layout_array_as_table($data_values);?> |
|
567 | + <?php echo self::layout_array_as_table($data_values); ?> |
|
568 | 568 | </td> |
569 | 569 | </tr> |
570 | 570 | <?php |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | <ul> |
579 | 579 | <?php |
580 | 580 | foreach ($data as $datum) { |
581 | - echo "<li>"; echo self::layout_array_as_table($datum);echo "</li>"; |
|
581 | + echo "<li>"; echo self::layout_array_as_table($datum); echo "</li>"; |
|
582 | 582 | }?> |
583 | 583 | </ul> |
584 | 584 | <?php |
@@ -608,8 +608,8 @@ discard block |
||
608 | 608 | * |
609 | 609 | * @return string |
610 | 610 | */ |
611 | - public static function paging_html( $total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array() ) { |
|
612 | - echo self::get_paging_html( $total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, $items_label ); |
|
611 | + public static function paging_html($total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array()) { |
|
612 | + echo self::get_paging_html($total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, $items_label); |
|
613 | 613 | } |
614 | 614 | |
615 | 615 | |
@@ -633,13 +633,13 @@ discard block |
||
633 | 633 | * ) |
634 | 634 | * @return string |
635 | 635 | */ |
636 | - public static function get_paging_html( $total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array() ) { |
|
636 | + public static function get_paging_html($total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array()) { |
|
637 | 637 | $page_links = array(); |
638 | 638 | $disable_first = $disable_last = ''; |
639 | 639 | $total_items = (int) $total_items; |
640 | 640 | $per_page = (int) $per_page; |
641 | 641 | $current = (int) $current; |
642 | - $paged_arg_name = empty( $paged_arg_name ) ? 'paged' : sanitize_key( $paged_arg_name ); |
|
642 | + $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name); |
|
643 | 643 | |
644 | 644 | //filter items_label |
645 | 645 | $items_label = apply_filters( |
@@ -647,68 +647,68 @@ discard block |
||
647 | 647 | $items_label |
648 | 648 | ); |
649 | 649 | |
650 | - if ( empty( $items_label ) |
|
651 | - || ! is_array( $items_label ) |
|
652 | - || ! isset( $items_label['single'] ) |
|
653 | - || ! isset( $items_label['plural'] ) ) { |
|
650 | + if (empty($items_label) |
|
651 | + || ! is_array($items_label) |
|
652 | + || ! isset($items_label['single']) |
|
653 | + || ! isset($items_label['plural'])) { |
|
654 | 654 | $items_label = array( |
655 | - 'single' => __( '1 item', 'event_espresso' ), |
|
656 | - 'plural' => __( '%s items', 'event_espresso' ) |
|
655 | + 'single' => __('1 item', 'event_espresso'), |
|
656 | + 'plural' => __('%s items', 'event_espresso') |
|
657 | 657 | ); |
658 | 658 | } else { |
659 | 659 | $items_label = array( |
660 | - 'single' => '1 ' . esc_html( $items_label['single'] ), |
|
661 | - 'plural' => '%s ' . esc_html( $items_label['plural'] ) |
|
660 | + 'single' => '1 '.esc_html($items_label['single']), |
|
661 | + 'plural' => '%s '.esc_html($items_label['plural']) |
|
662 | 662 | ); |
663 | 663 | } |
664 | 664 | |
665 | - $total_pages = ceil( $total_items / $per_page ); |
|
665 | + $total_pages = ceil($total_items / $per_page); |
|
666 | 666 | |
667 | - if ( $total_pages <= 1 ) |
|
667 | + if ($total_pages <= 1) |
|
668 | 668 | return ''; |
669 | 669 | |
670 | - $item_label = $total_items > 1 ? sprintf( $items_label['plural'], $total_items ) : $items_label['single']; |
|
670 | + $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single']; |
|
671 | 671 | |
672 | - $output = '<span class="displaying-num">' . $item_label . '</span>'; |
|
672 | + $output = '<span class="displaying-num">'.$item_label.'</span>'; |
|
673 | 673 | |
674 | - if ( $current === 1 ) { |
|
674 | + if ($current === 1) { |
|
675 | 675 | $disable_first = ' disabled'; |
676 | 676 | } |
677 | - if ( $current == $total_pages ) { |
|
677 | + if ($current == $total_pages) { |
|
678 | 678 | $disable_last = ' disabled'; |
679 | 679 | } |
680 | 680 | |
681 | - $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>", |
|
682 | - 'first-page' . $disable_first, |
|
683 | - esc_attr__( 'Go to the first page' ), |
|
684 | - esc_url( remove_query_arg( $paged_arg_name, $url ) ), |
|
681 | + $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>", |
|
682 | + 'first-page'.$disable_first, |
|
683 | + esc_attr__('Go to the first page'), |
|
684 | + esc_url(remove_query_arg($paged_arg_name, $url)), |
|
685 | 685 | '«' |
686 | 686 | ); |
687 | 687 | |
688 | 688 | $page_links[] = sprintf( |
689 | 689 | '<a class="%s" title="%s" href="%s">%s</a>', |
690 | - 'prev-page' . $disable_first, |
|
691 | - esc_attr__( 'Go to the previous page' ), |
|
692 | - esc_url( add_query_arg( $paged_arg_name, max( 1, $current-1 ), $url ) ), |
|
690 | + 'prev-page'.$disable_first, |
|
691 | + esc_attr__('Go to the previous page'), |
|
692 | + esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)), |
|
693 | 693 | '‹' |
694 | 694 | ); |
695 | 695 | |
696 | - if ( ! $show_num_field ) { |
|
696 | + if ( ! $show_num_field) { |
|
697 | 697 | $html_current_page = $current; |
698 | 698 | } else { |
699 | - $html_current_page = sprintf( "<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
700 | - esc_attr__( 'Current page' ), |
|
699 | + $html_current_page = sprintf("<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
700 | + esc_attr__('Current page'), |
|
701 | 701 | $current, |
702 | - strlen( $total_pages ) |
|
702 | + strlen($total_pages) |
|
703 | 703 | ); |
704 | 704 | } |
705 | 705 | |
706 | 706 | $html_total_pages = sprintf( |
707 | 707 | '<span class="total-pages">%s</span>', |
708 | - number_format_i18n( $total_pages ) |
|
708 | + number_format_i18n($total_pages) |
|
709 | 709 | ); |
710 | 710 | $page_links[] = sprintf( |
711 | - _x( '%3$s%1$s of %2$s%4$s', 'paging' ), |
|
711 | + _x('%3$s%1$s of %2$s%4$s', 'paging'), |
|
712 | 712 | $html_current_page, |
713 | 713 | $html_total_pages, |
714 | 714 | '<span class="paging-input">', |
@@ -717,29 +717,29 @@ discard block |
||
717 | 717 | |
718 | 718 | $page_links[] = sprintf( |
719 | 719 | '<a class="%s" title="%s" href="%s">%s</a>', |
720 | - 'next-page' . $disable_last, |
|
721 | - esc_attr__( 'Go to the next page' ), |
|
722 | - esc_url( add_query_arg( $paged_arg_name, min( $total_pages, $current+1 ), $url ) ), |
|
720 | + 'next-page'.$disable_last, |
|
721 | + esc_attr__('Go to the next page'), |
|
722 | + esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)), |
|
723 | 723 | '›' |
724 | 724 | ); |
725 | 725 | |
726 | 726 | $page_links[] = sprintf( |
727 | 727 | '<a class="%s" title="%s" href="%s">%s</a>', |
728 | - 'last-page' . $disable_last, |
|
729 | - esc_attr__( 'Go to the last page' ), |
|
730 | - esc_url( add_query_arg( $paged_arg_name, $total_pages, $url ) ), |
|
728 | + 'last-page'.$disable_last, |
|
729 | + esc_attr__('Go to the last page'), |
|
730 | + esc_url(add_query_arg($paged_arg_name, $total_pages, $url)), |
|
731 | 731 | '»' |
732 | 732 | ); |
733 | 733 | |
734 | - $output .= "\n" . '<span class="pagination-links">' . join( "\n", $page_links ) . '</span>'; |
|
734 | + $output .= "\n".'<span class="pagination-links">'.join("\n", $page_links).'</span>'; |
|
735 | 735 | // set page class |
736 | - if ( $total_pages ) { |
|
736 | + if ($total_pages) { |
|
737 | 737 | $page_class = $total_pages < 2 ? ' one-page' : ''; |
738 | 738 | } else { |
739 | 739 | $page_class = ' no-pages'; |
740 | 740 | } |
741 | 741 | |
742 | - return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>'; |
|
742 | + return '<div class="tablenav"><div class="tablenav-pages'.$page_class.'">'.$output.'</div></div>'; |
|
743 | 743 | } |
744 | 744 | |
745 | 745 |
@@ -160,8 +160,9 @@ discard block |
||
160 | 160 | // first use WP locate_template to check for template in the current theme folder |
161 | 161 | $template_path = locate_template( $templates ); |
162 | 162 | |
163 | - if ( $check_if_custom && !empty( $template_path ) ) |
|
164 | - return TRUE; |
|
163 | + if ( $check_if_custom && !empty( $template_path ) ) { |
|
164 | + return TRUE; |
|
165 | + } |
|
165 | 166 | |
166 | 167 | // not in the theme |
167 | 168 | if ( empty( $template_path )) { |
@@ -364,11 +365,11 @@ discard block |
||
364 | 365 | if( $mny->sign_b4 ){ |
365 | 366 | if( $amount >= 0 ){ |
366 | 367 | $amount_formatted = $mny->sign . $amount_formatted; |
367 | - }else{ |
|
368 | + } else{ |
|
368 | 369 | $amount_formatted = '-' . $mny->sign . str_replace( '-', '', $amount_formatted ); |
369 | 370 | } |
370 | 371 | |
371 | - }else{ |
|
372 | + } else{ |
|
372 | 373 | $amount_formatted = $amount_formatted . $mny->sign; |
373 | 374 | } |
374 | 375 | |
@@ -432,11 +433,13 @@ discard block |
||
432 | 433 | */ |
433 | 434 | public static function get_help_tab_link( $help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE ) { |
434 | 435 | |
435 | - if ( ! $page ) |
|
436 | - $page = isset( $_REQUEST['page'] ) && ! empty( $_REQUEST['page'] ) ? sanitize_key( $_REQUEST['page'] ) : $page; |
|
436 | + if ( ! $page ) { |
|
437 | + $page = isset( $_REQUEST['page'] ) && ! empty( $_REQUEST['page'] ) ? sanitize_key( $_REQUEST['page'] ) : $page; |
|
438 | + } |
|
437 | 439 | |
438 | - if ( ! $action ) |
|
439 | - $action = isset( $_REQUEST['action'] ) && ! empty( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : $action; |
|
440 | + if ( ! $action ) { |
|
441 | + $action = isset( $_REQUEST['action'] ) && ! empty( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : $action; |
|
442 | + } |
|
440 | 443 | |
441 | 444 | $action = empty($action) ? 'default' : $action; |
442 | 445 | |
@@ -510,8 +513,9 @@ discard block |
||
510 | 513 | * @return string html structure for status. |
511 | 514 | */ |
512 | 515 | public static function status_legend( $status_array, $active_status = '' ) { |
513 | - if ( !is_array( $status_array ) ) |
|
514 | - throw new EE_Error( __('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso') ); |
|
516 | + if ( !is_array( $status_array ) ) { |
|
517 | + throw new EE_Error( __('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso') ); |
|
518 | + } |
|
515 | 519 | |
516 | 520 | $setup_array = array(); |
517 | 521 | foreach ( $status_array as $item => $status ) { |
@@ -572,8 +576,7 @@ discard block |
||
572 | 576 | </tbody> |
573 | 577 | </table> |
574 | 578 | <?php |
575 | - } |
|
576 | - else { |
|
579 | + } else { |
|
577 | 580 | ?> |
578 | 581 | <ul> |
579 | 582 | <?php |
@@ -583,8 +586,7 @@ discard block |
||
583 | 586 | </ul> |
584 | 587 | <?php |
585 | 588 | } |
586 | - } |
|
587 | - else { |
|
589 | + } else { |
|
588 | 590 | //simple value |
589 | 591 | echo $data; |
590 | 592 | } |
@@ -664,8 +666,9 @@ discard block |
||
664 | 666 | |
665 | 667 | $total_pages = ceil( $total_items / $per_page ); |
666 | 668 | |
667 | - if ( $total_pages <= 1 ) |
|
668 | - return ''; |
|
669 | + if ( $total_pages <= 1 ) { |
|
670 | + return ''; |
|
671 | + } |
|
669 | 672 | |
670 | 673 | $item_label = $total_items > 1 ? sprintf( $items_label['plural'], $total_items ) : $items_label['single']; |
671 | 674 |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | /** |
132 | 132 | * For verifying that a variable is indeed an array, else throw an EE_Error |
133 | 133 | * @param type $variable_to_test |
134 | - * @param type $variable_name |
|
134 | + * @param string $variable_name |
|
135 | 135 | * @param type $allow_empty one of 'allow_empty' or 'do_not_allow_empty' |
136 | 136 | * @return void |
137 | 137 | * @throws EE_Error |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | * for verifying that a variable is one of the string optiosn supplied |
160 | 160 | * @param mixed $variable_to_test |
161 | 161 | * @param mixed $variable_name the name you've given the variable. Eg, '$foo'. THis helps in producing better error messages |
162 | - * @param array $string_options an array of acceptable values |
|
162 | + * @param string[] $string_options an array of acceptable values |
|
163 | 163 | * @return void |
164 | 164 | * @throws EE_Error |
165 | 165 | */ |
@@ -50,14 +50,14 @@ discard block |
||
50 | 50 | * @return void |
51 | 51 | * @throws EE_Error (indirectly) |
52 | 52 | */ |
53 | - static function verify_is_array_of($variable_to_test,$name_of_variable,$class_name,$allow_null='allow_null'){ |
|
54 | - if(!WP_DEBUG)return; |
|
55 | - self::verify_argument_is_one_of($allow_null, 'allow_null', array('allow_null','do_not_allow_null')); |
|
56 | - if('allow_null' == $allow_null && is_null($variable_to_test)){ |
|
53 | + static function verify_is_array_of($variable_to_test, $name_of_variable, $class_name, $allow_null = 'allow_null') { |
|
54 | + if ( ! WP_DEBUG)return; |
|
55 | + self::verify_argument_is_one_of($allow_null, 'allow_null', array('allow_null', 'do_not_allow_null')); |
|
56 | + if ('allow_null' == $allow_null && is_null($variable_to_test)) { |
|
57 | 57 | return; |
58 | 58 | } |
59 | 59 | self::verify_is_array($variable_to_test, $name_of_variable); |
60 | - foreach($variable_to_test as $key=>$array_element){ |
|
60 | + foreach ($variable_to_test as $key=>$array_element) { |
|
61 | 61 | self::verify_instanceof($array_element, $key, $class_name); |
62 | 62 | } |
63 | 63 | } |
@@ -73,12 +73,12 @@ discard block |
||
73 | 73 | * @return void |
74 | 74 | * @throws EE_Error |
75 | 75 | */ |
76 | - static function verify_isnt_null($variable_to_test,$name_of_variable){ |
|
77 | - if(!WP_DEBUG)return; |
|
78 | - if($variable_to_test==null && $variable_to_test!=0 && $variable_to_test!=FALSE){ |
|
79 | - $error[]=__('Variable named %s is null.','event_espresso'); |
|
80 | - $error[]=__("Consider looking at the stack trace to see why it wasn't set.",'event_espresso'); |
|
81 | - throw new EE_Error(sprintf(implode(",",$error),$name_of_variable,$name_of_variable)); |
|
76 | + static function verify_isnt_null($variable_to_test, $name_of_variable) { |
|
77 | + if ( ! WP_DEBUG)return; |
|
78 | + if ($variable_to_test == null && $variable_to_test != 0 && $variable_to_test != FALSE) { |
|
79 | + $error[] = __('Variable named %s is null.', 'event_espresso'); |
|
80 | + $error[] = __("Consider looking at the stack trace to see why it wasn't set.", 'event_espresso'); |
|
81 | + throw new EE_Error(sprintf(implode(",", $error), $name_of_variable, $name_of_variable)); |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
@@ -90,12 +90,12 @@ discard block |
||
90 | 90 | * @return void |
91 | 91 | * @throws EE_Error |
92 | 92 | */ |
93 | - static function verify_is_true($expression_to_test,$expression_string_representation){ |
|
94 | - if(!WP_DEBUG)return; |
|
95 | - if(!$expression_to_test){ |
|
96 | - $error[]=__('Template error.','event_espresso'); |
|
97 | - $error[]=__("%s evaluated to false, but it must be true!",'event_espresso'); |
|
98 | - throw new EE_Error(sprintf(implode(",",$error),$expression_string_representation)); |
|
93 | + static function verify_is_true($expression_to_test, $expression_string_representation) { |
|
94 | + if ( ! WP_DEBUG)return; |
|
95 | + if ( ! $expression_to_test) { |
|
96 | + $error[] = __('Template error.', 'event_espresso'); |
|
97 | + $error[] = __("%s evaluated to false, but it must be true!", 'event_espresso'); |
|
98 | + throw new EE_Error(sprintf(implode(",", $error), $expression_string_representation)); |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
@@ -111,16 +111,16 @@ discard block |
||
111 | 111 | * @return void |
112 | 112 | * @throws EE_Error |
113 | 113 | */ |
114 | - static function verify_instanceof($variable_to_test,$name_of_variable,$class_name, $allow_null = 'do_not_allow_null'){ |
|
115 | - if(!WP_DEBUG)return; |
|
116 | - self::verify_argument_is_one_of($allow_null, 'allow_null', array('allow_null','do_not_allow_null')); |
|
117 | - if($allow_null == 'allow_null' && is_null($variable_to_test)){ |
|
114 | + static function verify_instanceof($variable_to_test, $name_of_variable, $class_name, $allow_null = 'do_not_allow_null') { |
|
115 | + if ( ! WP_DEBUG)return; |
|
116 | + self::verify_argument_is_one_of($allow_null, 'allow_null', array('allow_null', 'do_not_allow_null')); |
|
117 | + if ($allow_null == 'allow_null' && is_null($variable_to_test)) { |
|
118 | 118 | return; |
119 | 119 | } |
120 | - if( $variable_to_test == NULL || ! ( $variable_to_test instanceof $class_name )){ |
|
121 | - $msg[]=__('Variable %s is not of the correct type.','event_espresso'); |
|
122 | - $msg[]=__("It should be of type %s",'event_espresso'); |
|
123 | - throw new EE_Error(sprintf(implode(",",$msg),$name_of_variable,$name_of_variable,$class_name)); |
|
120 | + if ($variable_to_test == NULL || ! ($variable_to_test instanceof $class_name)) { |
|
121 | + $msg[] = __('Variable %s is not of the correct type.', 'event_espresso'); |
|
122 | + $msg[] = __("It should be of type %s", 'event_espresso'); |
|
123 | + throw new EE_Error(sprintf(implode(",", $msg), $name_of_variable, $name_of_variable, $class_name)); |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | |
@@ -136,16 +136,16 @@ discard block |
||
136 | 136 | * @return void |
137 | 137 | * @throws EE_Error |
138 | 138 | */ |
139 | - static function verify_is_array($variable_to_test,$variable_name,$allow_empty='allow_empty'){ |
|
140 | - if(!WP_DEBUG)return; |
|
141 | - self::verify_argument_is_one_of($allow_empty, $variable_name, array('allow_empty','do_not_allow_empty')); |
|
142 | - if(empty($variable_to_test) && 'allow_empty'==$allow_empty){ |
|
139 | + static function verify_is_array($variable_to_test, $variable_name, $allow_empty = 'allow_empty') { |
|
140 | + if ( ! WP_DEBUG)return; |
|
141 | + self::verify_argument_is_one_of($allow_empty, $variable_name, array('allow_empty', 'do_not_allow_empty')); |
|
142 | + if (empty($variable_to_test) && 'allow_empty' == $allow_empty) { |
|
143 | 143 | return; |
144 | 144 | } |
145 | - if(!is_array($variable_to_test)){ |
|
146 | - $error[]=__('Variable %s should be an array, but it is not.'); |
|
147 | - $error[]=__("Its value is, instead '%s'",'event_espresso'); |
|
148 | - throw new EE_Error(sprintf(implode(",",$error),$variable_name,$variable_name,$variable_to_test)); |
|
145 | + if ( ! is_array($variable_to_test)) { |
|
146 | + $error[] = __('Variable %s should be an array, but it is not.'); |
|
147 | + $error[] = __("Its value is, instead '%s'", 'event_espresso'); |
|
148 | + throw new EE_Error(sprintf(implode(",", $error), $variable_name, $variable_name, $variable_to_test)); |
|
149 | 149 | } |
150 | 150 | } |
151 | 151 | |
@@ -163,12 +163,12 @@ discard block |
||
163 | 163 | * @return void |
164 | 164 | * @throws EE_Error |
165 | 165 | */ |
166 | - static function verify_argument_is_one_of($variable_to_test,$variable_name,$string_options){ |
|
167 | - if(!WP_DEBUG)return; |
|
168 | - if(!in_array($variable_to_test,$string_options)){ |
|
169 | - $msg[0]=__('Malconfigured template.','event_espresso'); |
|
170 | - $msg[1]=__("Variable named '%s' was set to '%s'. It can only be one of '%s'",'event_espresso'); |
|
171 | - throw new EE_Error(sprintf(implode("||",$msg),$variable_name,$variable_to_test, implode("', '",$string_options))); |
|
166 | + static function verify_argument_is_one_of($variable_to_test, $variable_name, $string_options) { |
|
167 | + if ( ! WP_DEBUG)return; |
|
168 | + if ( ! in_array($variable_to_test, $string_options)) { |
|
169 | + $msg[0] = __('Malconfigured template.', 'event_espresso'); |
|
170 | + $msg[1] = __("Variable named '%s' was set to '%s'. It can only be one of '%s'", 'event_espresso'); |
|
171 | + throw new EE_Error(sprintf(implode("||", $msg), $variable_name, $variable_to_test, implode("', '", $string_options))); |
|
172 | 172 | } |
173 | 173 | } |
174 | 174 |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | |
3 | 5 | /** |
4 | 6 | * Event Espresso |
@@ -51,7 +53,9 @@ discard block |
||
51 | 53 | * @throws EE_Error (indirectly) |
52 | 54 | */ |
53 | 55 | static function verify_is_array_of($variable_to_test,$name_of_variable,$class_name,$allow_null='allow_null'){ |
54 | - if(!WP_DEBUG)return; |
|
56 | + if(!WP_DEBUG) { |
|
57 | + return; |
|
58 | + } |
|
55 | 59 | self::verify_argument_is_one_of($allow_null, 'allow_null', array('allow_null','do_not_allow_null')); |
56 | 60 | if('allow_null' == $allow_null && is_null($variable_to_test)){ |
57 | 61 | return; |
@@ -74,7 +78,9 @@ discard block |
||
74 | 78 | * @throws EE_Error |
75 | 79 | */ |
76 | 80 | static function verify_isnt_null($variable_to_test,$name_of_variable){ |
77 | - if(!WP_DEBUG)return; |
|
81 | + if(!WP_DEBUG) { |
|
82 | + return; |
|
83 | + } |
|
78 | 84 | if($variable_to_test==null && $variable_to_test!=0 && $variable_to_test!=FALSE){ |
79 | 85 | $error[]=__('Variable named %s is null.','event_espresso'); |
80 | 86 | $error[]=__("Consider looking at the stack trace to see why it wasn't set.",'event_espresso'); |
@@ -91,7 +97,9 @@ discard block |
||
91 | 97 | * @throws EE_Error |
92 | 98 | */ |
93 | 99 | static function verify_is_true($expression_to_test,$expression_string_representation){ |
94 | - if(!WP_DEBUG)return; |
|
100 | + if(!WP_DEBUG) { |
|
101 | + return; |
|
102 | + } |
|
95 | 103 | if(!$expression_to_test){ |
96 | 104 | $error[]=__('Template error.','event_espresso'); |
97 | 105 | $error[]=__("%s evaluated to false, but it must be true!",'event_espresso'); |
@@ -112,7 +120,9 @@ discard block |
||
112 | 120 | * @throws EE_Error |
113 | 121 | */ |
114 | 122 | static function verify_instanceof($variable_to_test,$name_of_variable,$class_name, $allow_null = 'do_not_allow_null'){ |
115 | - if(!WP_DEBUG)return; |
|
123 | + if(!WP_DEBUG) { |
|
124 | + return; |
|
125 | + } |
|
116 | 126 | self::verify_argument_is_one_of($allow_null, 'allow_null', array('allow_null','do_not_allow_null')); |
117 | 127 | if($allow_null == 'allow_null' && is_null($variable_to_test)){ |
118 | 128 | return; |
@@ -137,7 +147,9 @@ discard block |
||
137 | 147 | * @throws EE_Error |
138 | 148 | */ |
139 | 149 | static function verify_is_array($variable_to_test,$variable_name,$allow_empty='allow_empty'){ |
140 | - if(!WP_DEBUG)return; |
|
150 | + if(!WP_DEBUG) { |
|
151 | + return; |
|
152 | + } |
|
141 | 153 | self::verify_argument_is_one_of($allow_empty, $variable_name, array('allow_empty','do_not_allow_empty')); |
142 | 154 | if(empty($variable_to_test) && 'allow_empty'==$allow_empty){ |
143 | 155 | return; |
@@ -164,7 +176,9 @@ discard block |
||
164 | 176 | * @throws EE_Error |
165 | 177 | */ |
166 | 178 | static function verify_argument_is_one_of($variable_to_test,$variable_name,$string_options){ |
167 | - if(!WP_DEBUG)return; |
|
179 | + if(!WP_DEBUG) { |
|
180 | + return; |
|
181 | + } |
|
168 | 182 | if(!in_array($variable_to_test,$string_options)){ |
169 | 183 | $msg[0]=__('Malconfigured template.','event_espresso'); |
170 | 184 | $msg[1]=__("Variable named '%s' was set to '%s'. It can only be one of '%s'",'event_espresso'); |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | |
186 | 186 | /** |
187 | 187 | * _prep_name_for_html_id |
188 | - * @param $name |
|
188 | + * @param string $name |
|
189 | 189 | * @return string |
190 | 190 | */ |
191 | 191 | private function _prep_name_for_html_id( $name ) { |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | |
232 | 232 | |
233 | 233 | /** |
234 | - * @param mixed $html_class |
|
234 | + * @param string $html_class |
|
235 | 235 | */ |
236 | 236 | public function set_html_class( $html_class ) { |
237 | 237 | $this->_html_class = $html_class; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('No direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -95,13 +95,13 @@ discard block |
||
95 | 95 | * @type $name string the name for this form section, if you want to explicitly define it |
96 | 96 | * } |
97 | 97 | */ |
98 | - function __construct( $options_array = array() ) { |
|
98 | + function __construct($options_array = array()) { |
|
99 | 99 | // used by display strategies |
100 | 100 | EE_Registry::instance()->load_helper('HTML'); |
101 | 101 | // assign incoming values to properties |
102 | - foreach( $options_array as $key => $value ) { |
|
103 | - $key = '_' . $key; |
|
104 | - if ( property_exists( $this, $key ) && empty( $this->$key )) { |
|
102 | + foreach ($options_array as $key => $value) { |
|
103 | + $key = '_'.$key; |
|
104 | + if (property_exists($this, $key) && empty($this->$key)) { |
|
105 | 105 | $this->$key = $value; |
106 | 106 | } |
107 | 107 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * @param $parent_form_section |
114 | 114 | * @param $name |
115 | 115 | */ |
116 | - protected function _construct_finalize( $parent_form_section, $name ){ |
|
116 | + protected function _construct_finalize($parent_form_section, $name) { |
|
117 | 117 | $this->_construction_finalized = TRUE; |
118 | 118 | $this->_parent_section = $parent_form_section; |
119 | 119 | $this->_name = $name; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | /** |
135 | 135 | * @param string $action |
136 | 136 | */ |
137 | - public function set_action( $action ) { |
|
137 | + public function set_action($action) { |
|
138 | 138 | $this->_action = $action; |
139 | 139 | } |
140 | 140 | |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * @return string |
145 | 145 | */ |
146 | 146 | public function method() { |
147 | - return ! empty( $this->_method ) ? $this->_method : 'POST'; |
|
147 | + return ! empty($this->_method) ? $this->_method : 'POST'; |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | /** |
153 | 153 | * @param string $method |
154 | 154 | */ |
155 | - public function set_method( $method ) { |
|
156 | - switch ( $method ) { |
|
155 | + public function set_method($method) { |
|
156 | + switch ($method) { |
|
157 | 157 | case 'get' : |
158 | 158 | case 'GET' : |
159 | 159 | $this->_method = 'GET'; |
@@ -171,12 +171,12 @@ discard block |
||
171 | 171 | * Calculation involves using the name and the parent's html id |
172 | 172 | * return void |
173 | 173 | */ |
174 | - protected function _set_default_html_id_if_empty(){ |
|
175 | - if( ! $this->_html_id ){ |
|
176 | - if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper ){ |
|
177 | - $this->_html_id = $this->_parent_section->html_id() . '-' . $this->_prep_name_for_html_id( $this->name() ); |
|
178 | - }else{ |
|
179 | - $this->_html_id = $this->_prep_name_for_html_id( $this->name() ); |
|
174 | + protected function _set_default_html_id_if_empty() { |
|
175 | + if ( ! $this->_html_id) { |
|
176 | + if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
|
177 | + $this->_html_id = $this->_parent_section->html_id().'-'.$this->_prep_name_for_html_id($this->name()); |
|
178 | + } else { |
|
179 | + $this->_html_id = $this->_prep_name_for_html_id($this->name()); |
|
180 | 180 | } |
181 | 181 | } |
182 | 182 | } |
@@ -188,8 +188,8 @@ discard block |
||
188 | 188 | * @param $name |
189 | 189 | * @return string |
190 | 190 | */ |
191 | - private function _prep_name_for_html_id( $name ) { |
|
192 | - return sanitize_key( str_replace( array( ' ', ' ', '_' ), '-', $name )); |
|
191 | + private function _prep_name_for_html_id($name) { |
|
192 | + return sanitize_key(str_replace(array(' ', ' ', '_'), '-', $name)); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | |
@@ -206,8 +206,8 @@ discard block |
||
206 | 206 | * @param bool $add_pound_sign |
207 | 207 | * @return string |
208 | 208 | */ |
209 | - public function html_id( $add_pound_sign = FALSE ){ |
|
210 | - return $add_pound_sign ? '#' . $this->_html_id : $this->_html_id; |
|
209 | + public function html_id($add_pound_sign = FALSE) { |
|
210 | + return $add_pound_sign ? '#'.$this->_html_id : $this->_html_id; |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | /** |
216 | 216 | * @return string |
217 | 217 | */ |
218 | - public function html_class(){ |
|
218 | + public function html_class() { |
|
219 | 219 | return $this->_html_class; |
220 | 220 | } |
221 | 221 | |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | /** |
225 | 225 | * @return string |
226 | 226 | */ |
227 | - public function html_style(){ |
|
227 | + public function html_style() { |
|
228 | 228 | return $this->_html_style; |
229 | 229 | } |
230 | 230 | |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | /** |
234 | 234 | * @param mixed $html_class |
235 | 235 | */ |
236 | - public function set_html_class( $html_class ) { |
|
236 | + public function set_html_class($html_class) { |
|
237 | 237 | $this->_html_class = $html_class; |
238 | 238 | } |
239 | 239 | |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | /** |
243 | 243 | * @param mixed $html_id |
244 | 244 | */ |
245 | - public function set_html_id( $html_id ) { |
|
245 | + public function set_html_id($html_id) { |
|
246 | 246 | $this->_html_id = $html_id; |
247 | 247 | } |
248 | 248 | |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | /** |
252 | 252 | * @param mixed $html_style |
253 | 253 | */ |
254 | - public function set_html_style( $html_style ) { |
|
254 | + public function set_html_style($html_style) { |
|
255 | 255 | $this->_html_style = $html_style; |
256 | 256 | } |
257 | 257 | |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | /** |
261 | 261 | * @param string $other_html_attributes |
262 | 262 | */ |
263 | - public function set_other_html_attributes( $other_html_attributes ) { |
|
263 | + public function set_other_html_attributes($other_html_attributes) { |
|
264 | 264 | $this->_other_html_attributes = $other_html_attributes; |
265 | 265 | } |
266 | 266 | |
@@ -280,9 +280,9 @@ discard block |
||
280 | 280 | * @throws EE_Error |
281 | 281 | * @return string |
282 | 282 | */ |
283 | - function name(){ |
|
284 | - if( ! $this->_construction_finalized ){ |
|
285 | - throw new EE_Error(sprintf( __( 'You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'', 'event_espresso' ), get_class($this) ) ); |
|
283 | + function name() { |
|
284 | + if ( ! $this->_construction_finalized) { |
|
285 | + throw new EE_Error(sprintf(__('You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'', 'event_espresso'), get_class($this))); |
|
286 | 286 | } |
287 | 287 | return $this->_name; |
288 | 288 | } |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | * Gets the parent section |
294 | 294 | * @return EE_Form_Section_Proper |
295 | 295 | */ |
296 | - function parent_section(){ |
|
296 | + function parent_section() { |
|
297 | 297 | return $this->_parent_section; |
298 | 298 | } |
299 | 299 | |
@@ -306,18 +306,18 @@ discard block |
||
306 | 306 | * @param string $other_attributes anything else added to the form open tag, MUST BE VALID HTML |
307 | 307 | * @return string |
308 | 308 | */ |
309 | - public function form_open( $action = '', $method = '', $other_attributes = '' ) { |
|
310 | - if ( ! empty( $action )) { |
|
311 | - $this->set_action( $action ); |
|
309 | + public function form_open($action = '', $method = '', $other_attributes = '') { |
|
310 | + if ( ! empty($action)) { |
|
311 | + $this->set_action($action); |
|
312 | 312 | } |
313 | - if ( ! empty( $method )) { |
|
314 | - $this->set_method( $method ); |
|
313 | + if ( ! empty($method)) { |
|
314 | + $this->set_method($method); |
|
315 | 315 | } |
316 | - $html = EEH_HTML::nl( 1, 'form' ) . '<form'; |
|
317 | - $html .= $this->html_id() !== '' ? ' id="' . $this->html_id() . '"' : ''; |
|
318 | - $html .= ' action="' . $this->action() . '"'; |
|
319 | - $html .= ' method="' . $this->method() . '"'; |
|
320 | - $html .= $other_attributes . '>'; |
|
316 | + $html = EEH_HTML::nl(1, 'form').'<form'; |
|
317 | + $html .= $this->html_id() !== '' ? ' id="'.$this->html_id().'"' : ''; |
|
318 | + $html .= ' action="'.$this->action().'"'; |
|
319 | + $html .= ' method="'.$this->method().'"'; |
|
320 | + $html .= $other_attributes.'>'; |
|
321 | 321 | return $html; |
322 | 322 | } |
323 | 323 | |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | * @return string |
329 | 329 | */ |
330 | 330 | public function form_close() { |
331 | - return EEH_HTML::nl( -1, 'form' ) . '</form>' . EEH_HTML::nl() . '<!-- end of ee-' . $this->html_id() . '-form -->' . EEH_HTML::nl(); |
|
331 | + return EEH_HTML::nl( -1, 'form' ).'</form>'.EEH_HTML::nl().'<!-- end of ee-'.$this->html_id().'-form -->'.EEH_HTML::nl(); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 |
@@ -1,7 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | 4 | exit('No direct script access allowed'); |
5 | +} |
|
5 | 6 | |
6 | 7 | /** |
7 | 8 | * Event Espresso |
@@ -175,7 +176,7 @@ discard block |
||
175 | 176 | if( ! $this->_html_id ){ |
176 | 177 | if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper ){ |
177 | 178 | $this->_html_id = $this->_parent_section->html_id() . '-' . $this->_prep_name_for_html_id( $this->name() ); |
178 | - }else{ |
|
179 | + } else{ |
|
179 | 180 | $this->_html_id = $this->_prep_name_for_html_id( $this->name() ); |
180 | 181 | } |
181 | 182 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | * leave this as TRUE so that the inputs will be properly configured. However, |
226 | 226 | * some client code may be ok with construction finalize being called later |
227 | 227 | * (realizing that the subsections' html names might not be set yet, etc.) |
228 | - * @return EE_Form_Section_Base |
|
228 | + * @return EE_Form_Section_Validatable|null |
|
229 | 229 | */ |
230 | 230 | public function get_subsection($name, $require_construction_to_be_finalized = TRUE ){ |
231 | 231 | if( $require_construction_to_be_finalized ){ |
@@ -712,7 +712,7 @@ discard block |
||
712 | 712 | /** |
713 | 713 | * Equivalent to passing 'exclude' in the constructor's options array. |
714 | 714 | * Removes the listed inputs from the form |
715 | - * @param array $inputs_to_exclude values are the input names |
|
715 | + * @param string[] $inputs_to_exclude values are the input names |
|
716 | 716 | * @return void |
717 | 717 | */ |
718 | 718 | public function exclude($inputs_to_exclude = array()){ |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * before the hook wp_enqueue_scripts is called (so that the form section can enqueue its needed scripts). |
8 | 8 | * However, you may output the form (usually by calling get_html_and_js) anywhere you like. |
9 | 9 | */ |
10 | -class EE_Form_Section_Proper extends EE_Form_Section_Validatable{ |
|
10 | +class EE_Form_Section_Proper extends EE_Form_Section_Validatable { |
|
11 | 11 | |
12 | 12 | /** |
13 | 13 | * Subsections |
@@ -68,37 +68,37 @@ discard block |
||
68 | 68 | * } @see EE_Form_Section_Validatable::__construct() |
69 | 69 | * |
70 | 70 | */ |
71 | - public function __construct( $options_array = array() ){ |
|
71 | + public function __construct($options_array = array()) { |
|
72 | 72 | EE_Registry::instance()->load_helper('Formatter'); |
73 | 73 | //call parent first, as it may be setting the name |
74 | 74 | parent::__construct($options_array); |
75 | 75 | //if they've included subsections in the constructor, add them now |
76 | - if( isset( $options_array['include'] )){ |
|
76 | + if (isset($options_array['include'])) { |
|
77 | 77 | //we are going to make sure we ONLY have those subsections to include |
78 | 78 | //AND we are going to make sure they're in that specified order |
79 | 79 | $reordered_subsections = array(); |
80 | - foreach($options_array['include'] as $input_name){ |
|
81 | - if(isset($this->_subsections[$input_name])){ |
|
80 | + foreach ($options_array['include'] as $input_name) { |
|
81 | + if (isset($this->_subsections[$input_name])) { |
|
82 | 82 | $reordered_subsections[$input_name] = $this->_subsections[$input_name]; |
83 | 83 | } |
84 | 84 | } |
85 | 85 | $this->_subsections = $reordered_subsections; |
86 | 86 | } |
87 | - if(isset($options_array['exclude'])){ |
|
87 | + if (isset($options_array['exclude'])) { |
|
88 | 88 | $exclude = $options_array['exclude']; |
89 | 89 | $this->_subsections = array_diff_key($this->_subsections, array_flip($exclude)); |
90 | 90 | } |
91 | - if(isset($options_array['layout_strategy'])){ |
|
91 | + if (isset($options_array['layout_strategy'])) { |
|
92 | 92 | $this->_layout_strategy = $options_array['layout_strategy']; |
93 | 93 | } |
94 | - if( ! $this->_layout_strategy){ |
|
94 | + if ( ! $this->_layout_strategy) { |
|
95 | 95 | $this->_layout_strategy = new EE_Two_Column_Layout(); |
96 | 96 | } |
97 | 97 | $this->_layout_strategy->_construct_finalize($this); |
98 | 98 | |
99 | - add_action( 'wp_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_enqueue_scripts' )); |
|
100 | - add_action( 'admin_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_enqueue_scripts' )); |
|
101 | - add_action( 'wp_footer', array( $this, 'ensure_scripts_localized' ), 1 ); |
|
99 | + add_action('wp_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts')); |
|
100 | + add_action('admin_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts')); |
|
101 | + add_action('wp_footer', array($this, 'ensure_scripts_localized'), 1); |
|
102 | 102 | |
103 | 103 | |
104 | 104 | } |
@@ -112,20 +112,20 @@ discard block |
||
112 | 112 | * @param string $name |
113 | 113 | * @throws \EE_Error |
114 | 114 | */ |
115 | - public function _construct_finalize( $parent_form_section, $name ) { |
|
115 | + public function _construct_finalize($parent_form_section, $name) { |
|
116 | 116 | parent::_construct_finalize($parent_form_section, $name); |
117 | 117 | $this->_set_default_name_if_empty(); |
118 | 118 | $this->_set_default_html_id_if_empty(); |
119 | - foreach( $this->_subsections as $subsection_name => $subsection ){ |
|
120 | - if ( $subsection instanceof EE_Form_Section_Base ) { |
|
121 | - $subsection->_construct_finalize( $this, $subsection_name ); |
|
119 | + foreach ($this->_subsections as $subsection_name => $subsection) { |
|
120 | + if ($subsection instanceof EE_Form_Section_Base) { |
|
121 | + $subsection->_construct_finalize($this, $subsection_name); |
|
122 | 122 | } else { |
123 | 123 | throw new EE_Error( |
124 | 124 | sprintf( |
125 | - __( 'Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"', 'event_espresso' ), |
|
125 | + __('Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"', 'event_espresso'), |
|
126 | 126 | $subsection_name, |
127 | 127 | get_class($this), |
128 | - $subsection ? get_class($subsection) : __( 'NULL', 'event_espresso' ) |
|
128 | + $subsection ? get_class($subsection) : __('NULL', 'event_espresso') |
|
129 | 129 | ) |
130 | 130 | ); |
131 | 131 | } |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * Gets the layout strategy for this form section |
139 | 139 | * @return EE_Form_Section_Layout_Base |
140 | 140 | */ |
141 | - public function get_layout_strategy(){ |
|
141 | + public function get_layout_strategy() { |
|
142 | 142 | return $this->_layout_strategy; |
143 | 143 | } |
144 | 144 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * @param EE_Form_Input_Base $input |
151 | 151 | * @return string |
152 | 152 | */ |
153 | - public function get_html_for_input($input){ |
|
153 | + public function get_html_for_input($input) { |
|
154 | 154 | return $this->_layout_strategy->layout_input($input); |
155 | 155 | } |
156 | 156 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * @param null $form_data |
164 | 164 | * @return boolean |
165 | 165 | */ |
166 | - public function was_submitted($form_data = NULL){ |
|
166 | + public function was_submitted($form_data = NULL) { |
|
167 | 167 | return $this->form_data_present_in($form_data); |
168 | 168 | } |
169 | 169 | |
@@ -184,12 +184,12 @@ discard block |
||
184 | 184 | * to skip this step. |
185 | 185 | * @return void |
186 | 186 | */ |
187 | - public function receive_form_submission($req_data = NULL, $validate = TRUE){ |
|
188 | - if( $req_data === NULL){ |
|
187 | + public function receive_form_submission($req_data = NULL, $validate = TRUE) { |
|
188 | + if ($req_data === NULL) { |
|
189 | 189 | $req_data = $_REQUEST; |
190 | 190 | } |
191 | 191 | $this->_normalize($req_data); |
192 | - if( $validate ){ |
|
192 | + if ($validate) { |
|
193 | 193 | $this->_validate(); |
194 | 194 | } |
195 | 195 | } |
@@ -204,12 +204,12 @@ discard block |
||
204 | 204 | * the value being an array formatted in teh same way |
205 | 205 | * @param array $default_data |
206 | 206 | */ |
207 | - public function populate_defaults($default_data){ |
|
208 | - foreach($this->subsections() as $subsection_name => $subsection){ |
|
209 | - if(isset($default_data[$subsection_name])){ |
|
210 | - if($subsection instanceof EE_Form_Input_Base){ |
|
207 | + public function populate_defaults($default_data) { |
|
208 | + foreach ($this->subsections() as $subsection_name => $subsection) { |
|
209 | + if (isset($default_data[$subsection_name])) { |
|
210 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
211 | 211 | $subsection->set_default($default_data[$subsection_name]); |
212 | - }elseif($subsection instanceof EE_Form_Section_Proper){ |
|
212 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
213 | 213 | $subsection->populate_defaults($default_data[$subsection_name]); |
214 | 214 | } |
215 | 215 | } |
@@ -227,8 +227,8 @@ discard block |
||
227 | 227 | * (realizing that the subsections' html names might not be set yet, etc.) |
228 | 228 | * @return EE_Form_Section_Base |
229 | 229 | */ |
230 | - public function get_subsection($name, $require_construction_to_be_finalized = TRUE ){ |
|
231 | - if( $require_construction_to_be_finalized ){ |
|
230 | + public function get_subsection($name, $require_construction_to_be_finalized = TRUE) { |
|
231 | + if ($require_construction_to_be_finalized) { |
|
232 | 232 | $this->ensure_construct_finalized_called(); |
233 | 233 | } |
234 | 234 | return isset($this->_subsections[$name]) ? $this->_subsections[$name] : NULL; |
@@ -240,10 +240,10 @@ discard block |
||
240 | 240 | * Gets all the validatable subsections of this form section |
241 | 241 | * @return EE_Form_Section_Validatable[] |
242 | 242 | */ |
243 | - public function get_validatable_subsections(){ |
|
243 | + public function get_validatable_subsections() { |
|
244 | 244 | $validatable_subsections = array(); |
245 | - foreach($this->subsections() as $name=>$obj){ |
|
246 | - if($obj instanceof EE_Form_Section_Validatable){ |
|
245 | + foreach ($this->subsections() as $name=>$obj) { |
|
246 | + if ($obj instanceof EE_Form_Section_Validatable) { |
|
247 | 247 | $validatable_subsections[$name] = $obj; |
248 | 248 | } |
249 | 249 | } |
@@ -263,10 +263,10 @@ discard block |
||
263 | 263 | * @return EE_Form_Input_Base |
264 | 264 | * @throws EE_Error |
265 | 265 | */ |
266 | - public function get_input($name, $require_construction_to_be_finalized = TRUE ){ |
|
266 | + public function get_input($name, $require_construction_to_be_finalized = TRUE) { |
|
267 | 267 | $subsection = $this->get_subsection($name, $require_construction_to_be_finalized); |
268 | - if( ! $subsection instanceof EE_Form_Input_Base){ |
|
269 | - throw new EE_Error(sprintf(__("Subsection '%s' is not an instanceof EE_Form_Input_Base on form '%s'. It is a '%s'", 'event_espresso'),$name, get_class($this),$subsection ? get_class($subsection) : __("NULL", 'event_espresso'))); |
|
268 | + if ( ! $subsection instanceof EE_Form_Input_Base) { |
|
269 | + throw new EE_Error(sprintf(__("Subsection '%s' is not an instanceof EE_Form_Input_Base on form '%s'. It is a '%s'", 'event_espresso'), $name, get_class($this), $subsection ? get_class($subsection) : __("NULL", 'event_espresso'))); |
|
270 | 270 | } |
271 | 271 | return $subsection; |
272 | 272 | } |
@@ -284,10 +284,10 @@ discard block |
||
284 | 284 | * @return EE_Form_Section_Proper |
285 | 285 | * @throws EE_Error |
286 | 286 | */ |
287 | - public function get_proper_subsection($name, $require_construction_to_be_finalized = TRUE ){ |
|
288 | - $subsection = $this->get_subsection( $name, $require_construction_to_be_finalized ); |
|
289 | - if( ! $subsection instanceof EE_Form_Section_Proper){ |
|
290 | - throw new EE_Error(sprintf(__("Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso'),$name, get_class($this))); |
|
287 | + public function get_proper_subsection($name, $require_construction_to_be_finalized = TRUE) { |
|
288 | + $subsection = $this->get_subsection($name, $require_construction_to_be_finalized); |
|
289 | + if ( ! $subsection instanceof EE_Form_Section_Proper) { |
|
290 | + throw new EE_Error(sprintf(__("Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso'), $name, get_class($this))); |
|
291 | 291 | } |
292 | 292 | return $subsection; |
293 | 293 | } |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | * @param string $name |
301 | 301 | * @return mixed depending on the input's type and its normalization strategy |
302 | 302 | */ |
303 | - public function get_input_value($name){ |
|
303 | + public function get_input_value($name) { |
|
304 | 304 | $input = $this->get_input($name); |
305 | 305 | return $input->normalized_value(); |
306 | 306 | } |
@@ -313,16 +313,16 @@ discard block |
||
313 | 313 | * @return boolean |
314 | 314 | */ |
315 | 315 | public function is_valid() { |
316 | - if( ! $this->has_received_submission()){ |
|
316 | + if ( ! $this->has_received_submission()) { |
|
317 | 317 | throw new EE_Error(sprintf(__("You cannot check if a form is valid before receiving the form submission using receive_form_submission", "event_espresso"))); |
318 | 318 | } |
319 | - if( ! parent::is_valid()){ |
|
319 | + if ( ! parent::is_valid()) { |
|
320 | 320 | return false; |
321 | 321 | } |
322 | 322 | //ok so no errors general to this entire form section. so let's check the subsections |
323 | - foreach( $this->get_validatable_subsections() as $subsection ){ |
|
324 | - if( ! $subsection->is_valid() || $subsection->get_validation_error_string() != '' ){ |
|
325 | - $this->set_submission_error_message( $subsection->get_validation_error_string() ); |
|
323 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
324 | + if ( ! $subsection->is_valid() || $subsection->get_validation_error_string() != '') { |
|
325 | + $this->set_submission_error_message($subsection->get_validation_error_string()); |
|
326 | 326 | return false; |
327 | 327 | } |
328 | 328 | } |
@@ -335,11 +335,11 @@ discard block |
||
335 | 335 | * gets teh default name of this form section if none is specified |
336 | 336 | * @return string |
337 | 337 | */ |
338 | - protected function _set_default_name_if_empty(){ |
|
339 | - if( ! $this->_name ){ |
|
338 | + protected function _set_default_name_if_empty() { |
|
339 | + if ( ! $this->_name) { |
|
340 | 340 | $classname = get_class($this); |
341 | 341 | $default_name = str_replace("EE_", "", $classname); |
342 | - $this->_name = $default_name; |
|
342 | + $this->_name = $default_name; |
|
343 | 343 | } |
344 | 344 | } |
345 | 345 | |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | * Also returns the HTML for the form, except for the form opening and closing tags |
351 | 351 | * (as the form section doesn't know where you necessarily want to send the information to), and except for a submit button. |
352 | 352 | */ |
353 | - public function get_html_and_js(){ |
|
353 | + public function get_html_and_js() { |
|
354 | 354 | $this->enqueue_js(); |
355 | 355 | return $this->get_html(); |
356 | 356 | } |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | * returns HTML for displaying this form section. recursively calls display_section() on all subsections |
362 | 362 | * @return string |
363 | 363 | */ |
364 | - public function get_html(){ |
|
364 | + public function get_html() { |
|
365 | 365 | $this->ensure_construct_finalized_called(); |
366 | 366 | return $this->_layout_strategy->layout_form(); |
367 | 367 | } |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | * enqueues JS for the form |
373 | 373 | * @return string |
374 | 374 | */ |
375 | - public function enqueue_js(){ |
|
375 | + public function enqueue_js() { |
|
376 | 376 | $this->_enqueue_and_localize_form_js(); |
377 | 377 | } |
378 | 378 | |
@@ -387,9 +387,9 @@ discard block |
||
387 | 387 | * could change until it's actually outputted) |
388 | 388 | * @return void |
389 | 389 | */ |
390 | - public static function wp_enqueue_scripts(){ |
|
391 | - add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
|
392 | - wp_register_script( 'ee_form_section_validation', EE_GLOBAL_ASSETS_URL . 'scripts' . DS . 'form_section_validation.js', array( 'jquery-validate', 'jquery-ui-datepicker' ), EVENT_ESPRESSO_VERSION, TRUE ); |
|
390 | + public static function wp_enqueue_scripts() { |
|
391 | + add_filter('FHEE_load_jquery_validate', '__return_true'); |
|
392 | + wp_register_script('ee_form_section_validation', EE_GLOBAL_ASSETS_URL.'scripts'.DS.'form_section_validation.js', array('jquery-validate', 'jquery-ui-datepicker'), EVENT_ESPRESSO_VERSION, TRUE); |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | |
@@ -399,14 +399,14 @@ discard block |
||
399 | 399 | * This needs to be called AFTER we've called $this->_enqueue_jquery_validate_script, |
400 | 400 | * but before the wordpress hook wp_loaded |
401 | 401 | */ |
402 | - public function _enqueue_and_localize_form_js(){ |
|
402 | + public function _enqueue_and_localize_form_js() { |
|
403 | 403 | $this->ensure_construct_finalized_called(); |
404 | 404 | //actually, we don't want to localize just yet. There may be other forms on the page. |
405 | 405 | //so we need to add our form section data to a static variable accessible by all form sections |
406 | 406 | //and localize it just before the footer |
407 | 407 | $this->localize_validation_rules(); |
408 | - add_action( 'wp_footer', array( 'EE_Form_Section_Proper', 'localize_script_for_all_forms' ), 2 ); |
|
409 | - add_action( 'admin_footer', array( 'EE_Form_Section_Proper', 'localize_script_for_all_forms' ) ); |
|
408 | + add_action('wp_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'), 2); |
|
409 | + add_action('admin_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms')); |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | |
@@ -416,11 +416,11 @@ discard block |
||
416 | 416 | * @param bool $return_for_subsection |
417 | 417 | * @return void |
418 | 418 | */ |
419 | - public function localize_validation_rules( $return_for_subsection = FALSE ){ |
|
419 | + public function localize_validation_rules($return_for_subsection = FALSE) { |
|
420 | 420 | // we only want to localize vars ONCE for the entire form, so if the form section doesn't have a parent, then it must be the top dog |
421 | - if ( ! $this->parent_section() || $return_for_subsection ) { |
|
422 | - EE_Form_Section_Proper::$_js_localization['form_data'][ $this->html_id() ] = array( |
|
423 | - 'form_section_id'=> $this->html_id( TRUE ), |
|
421 | + if ( ! $this->parent_section() || $return_for_subsection) { |
|
422 | + EE_Form_Section_Proper::$_js_localization['form_data'][$this->html_id()] = array( |
|
423 | + 'form_section_id'=> $this->html_id(TRUE), |
|
424 | 424 | 'validation_rules'=> $this->get_jquery_validation_rules(), |
425 | 425 | 'errors'=> $this->subsection_validation_errors_by_html_name() |
426 | 426 | ); |
@@ -435,12 +435,12 @@ discard block |
||
435 | 435 | * Keys are their form names, and values are the inputs themselves |
436 | 436 | * @return EE_Form_Input_Base |
437 | 437 | */ |
438 | - public function inputs_in_subsections(){ |
|
438 | + public function inputs_in_subsections() { |
|
439 | 439 | $inputs = array(); |
440 | - foreach($this->subsections() as $subsection){ |
|
441 | - if( $subsection instanceof EE_Form_Input_Base ){ |
|
442 | - $inputs[ $subsection->html_name() ] = $subsection; |
|
443 | - }elseif($subsection instanceof EE_Form_Section_Proper ){ |
|
440 | + foreach ($this->subsections() as $subsection) { |
|
441 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
442 | + $inputs[$subsection->html_name()] = $subsection; |
|
443 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
444 | 444 | $inputs += $subsection->inputs_in_subsections(); |
445 | 445 | } |
446 | 446 | } |
@@ -453,12 +453,12 @@ discard block |
||
453 | 453 | * and values are a string of all their validation errors |
454 | 454 | * @return string[] |
455 | 455 | */ |
456 | - public function subsection_validation_errors_by_html_name(){ |
|
456 | + public function subsection_validation_errors_by_html_name() { |
|
457 | 457 | $inputs = $this->inputs(); |
458 | 458 | $errors = array(); |
459 | - foreach( $inputs as $form_input ){ |
|
460 | - if ( $form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors() ){ |
|
461 | - $errors[ $form_input->html_name() ] = $form_input->get_validation_error_string(); |
|
459 | + foreach ($inputs as $form_input) { |
|
460 | + if ($form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors()) { |
|
461 | + $errors[$form_input->html_name()] = $form_input->get_validation_error_string(); |
|
462 | 462 | } |
463 | 463 | } |
464 | 464 | return $errors; |
@@ -470,12 +470,12 @@ discard block |
||
470 | 470 | * passes all the form data required by the JS to the JS, and enqueues the few required JS files. |
471 | 471 | * Should be setup by each form during the _enqueues_and_localize_form_js |
472 | 472 | */ |
473 | - public static function localize_script_for_all_forms(){ |
|
473 | + public static function localize_script_for_all_forms() { |
|
474 | 474 | //allow inputs and stuff to hook in their JS and stuff here |
475 | 475 | do_action('AHEE__EE_Form_Section_Proper__localize_script_for_all_forms__begin'); |
476 | 476 | EE_Form_Section_Proper::$_js_localization['localized_error_messages'] = EE_Form_Section_Proper::_get_localized_error_messages(); |
477 | - wp_enqueue_script( 'ee_form_section_validation' ); |
|
478 | - wp_localize_script( 'ee_form_section_validation', 'ee_form_section_vars', EE_Form_Section_Proper::$_js_localization ); |
|
477 | + wp_enqueue_script('ee_form_section_validation'); |
|
478 | + wp_localize_script('ee_form_section_validation', 'ee_form_section_vars', EE_Form_Section_Proper::$_js_localization); |
|
479 | 479 | } |
480 | 480 | |
481 | 481 | |
@@ -483,8 +483,8 @@ discard block |
||
483 | 483 | /** |
484 | 484 | * ensure_scripts_localized |
485 | 485 | */ |
486 | - public function ensure_scripts_localized(){ |
|
487 | - if ( ! EE_Form_Section_Proper::$_scripts_localized ) { |
|
486 | + public function ensure_scripts_localized() { |
|
487 | + if ( ! EE_Form_Section_Proper::$_scripts_localized) { |
|
488 | 488 | $this->_enqueue_and_localize_form_js(); |
489 | 489 | } |
490 | 490 | } |
@@ -496,10 +496,10 @@ discard block |
||
496 | 496 | * is that the key here should be the same as the custom validation rule put in the JS file |
497 | 497 | * @return array keys are custom validation rules, and values are internationalized strings |
498 | 498 | */ |
499 | - private static function _get_localized_error_messages(){ |
|
499 | + private static function _get_localized_error_messages() { |
|
500 | 500 | return array( |
501 | 501 | 'validUrl'=> __("This is not a valid absolute URL. Eg, http://domain.com/monkey.jpg", "event_espresso"), |
502 | - 'regex' => __( 'Please check your input', 'event_espresso' ), |
|
502 | + 'regex' => __('Please check your input', 'event_espresso'), |
|
503 | 503 | ); |
504 | 504 | } |
505 | 505 | |
@@ -527,10 +527,10 @@ discard block |
||
527 | 527 | * Gets the JS to put inside the jquery validation rules for subsection of this form section. See parent function for more... |
528 | 528 | * @return array |
529 | 529 | */ |
530 | - function get_jquery_validation_rules(){ |
|
530 | + function get_jquery_validation_rules() { |
|
531 | 531 | $jquery_validation_rules = array(); |
532 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
533 | - $jquery_validation_rules = array_merge( $jquery_validation_rules, $subsection->get_jquery_validation_rules() ); |
|
532 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
533 | + $jquery_validation_rules = array_merge($jquery_validation_rules, $subsection->get_jquery_validation_rules()); |
|
534 | 534 | } |
535 | 535 | return $jquery_validation_rules; |
536 | 536 | } |
@@ -545,11 +545,11 @@ discard block |
||
545 | 545 | protected function _normalize($req_data) { |
546 | 546 | $this->_received_submission = TRUE; |
547 | 547 | $this->_validation_errors = array(); |
548 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
549 | - try{ |
|
548 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
549 | + try { |
|
550 | 550 | $subsection->_normalize($req_data); |
551 | - }catch( EE_Validation_Error $e ){ |
|
552 | - $subsection->add_validation_error( $e ); |
|
551 | + } catch (EE_Validation_Error $e) { |
|
552 | + $subsection->add_validation_error($e); |
|
553 | 553 | } |
554 | 554 | } |
555 | 555 | } |
@@ -563,9 +563,9 @@ discard block |
||
563 | 563 | * calling parent::_validate() first. |
564 | 564 | */ |
565 | 565 | protected function _validate() { |
566 | - foreach($this->get_validatable_subsections() as $subsection_name => $subsection){ |
|
567 | - if(method_exists($this,'_validate_'.$subsection_name)){ |
|
568 | - call_user_func_array(array($this,'_validate_'.$subsection_name), array($subsection)); |
|
566 | + foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) { |
|
567 | + if (method_exists($this, '_validate_'.$subsection_name)) { |
|
568 | + call_user_func_array(array($this, '_validate_'.$subsection_name), array($subsection)); |
|
569 | 569 | } |
570 | 570 | $subsection->_validate(); |
571 | 571 | } |
@@ -577,13 +577,13 @@ discard block |
||
577 | 577 | * Gets all the validated inputs for the form section |
578 | 578 | * @return array |
579 | 579 | */ |
580 | - public function valid_data(){ |
|
580 | + public function valid_data() { |
|
581 | 581 | $inputs = array(); |
582 | - foreach( $this->subsections() as $subsection_name =>$subsection ){ |
|
583 | - if ( $subsection instanceof EE_Form_Section_Proper ) { |
|
584 | - $inputs[ $subsection_name ] = $subsection->valid_data(); |
|
585 | - } else if ( $subsection instanceof EE_Form_Input_Base ){ |
|
586 | - $inputs[ $subsection_name ] = $subsection->normalized_value(); |
|
582 | + foreach ($this->subsections() as $subsection_name =>$subsection) { |
|
583 | + if ($subsection instanceof EE_Form_Section_Proper) { |
|
584 | + $inputs[$subsection_name] = $subsection->valid_data(); |
|
585 | + } else if ($subsection instanceof EE_Form_Input_Base) { |
|
586 | + $inputs[$subsection_name] = $subsection->normalized_value(); |
|
587 | 587 | } |
588 | 588 | } |
589 | 589 | return $inputs; |
@@ -595,11 +595,11 @@ discard block |
||
595 | 595 | * Gets all the inputs on this form section |
596 | 596 | * @return EE_Form_Input_Base[] |
597 | 597 | */ |
598 | - public function inputs(){ |
|
598 | + public function inputs() { |
|
599 | 599 | $inputs = array(); |
600 | - foreach( $this->subsections() as $subsection_name =>$subsection ){ |
|
601 | - if ( $subsection instanceof EE_Form_Input_Base ){ |
|
602 | - $inputs[ $subsection_name ] = $subsection; |
|
600 | + foreach ($this->subsections() as $subsection_name =>$subsection) { |
|
601 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
602 | + $inputs[$subsection_name] = $subsection; |
|
603 | 603 | } |
604 | 604 | } |
605 | 605 | return $inputs; |
@@ -611,10 +611,10 @@ discard block |
||
611 | 611 | * Gets all the subsections which are a proper form |
612 | 612 | * @return EE_Form_Section_Proper[] |
613 | 613 | */ |
614 | - public function subforms(){ |
|
614 | + public function subforms() { |
|
615 | 615 | $form_sections = array(); |
616 | - foreach($this->subsections() as $name=>$obj){ |
|
617 | - if($obj instanceof EE_Form_Section_Proper){ |
|
616 | + foreach ($this->subsections() as $name=>$obj) { |
|
617 | + if ($obj instanceof EE_Form_Section_Proper) { |
|
618 | 618 | $form_sections[$name] = $obj; |
619 | 619 | } |
620 | 620 | } |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | * if you only want form inputs or proper form sections. |
630 | 630 | * @return EE_Form_Section_Proper[] |
631 | 631 | */ |
632 | - public function subsections(){ |
|
632 | + public function subsections() { |
|
633 | 633 | $this->ensure_construct_finalized_called(); |
634 | 634 | return $this->_subsections; |
635 | 635 | } |
@@ -647,8 +647,8 @@ discard block |
||
647 | 647 | * it can be a multidimensional array where keys are always subsection names and values are either the |
648 | 648 | * input's normalized value, or an array like the top-level array |
649 | 649 | */ |
650 | - public function input_values( $include_subform_inputs = false, $flatten = false ){ |
|
651 | - return $this->_input_values( false, $include_subform_inputs, $flatten ); |
|
650 | + public function input_values($include_subform_inputs = false, $flatten = false) { |
|
651 | + return $this->_input_values(false, $include_subform_inputs, $flatten); |
|
652 | 652 | } |
653 | 653 | |
654 | 654 | /** |
@@ -664,8 +664,8 @@ discard block |
||
664 | 664 | * it can be a multidimensional array where keys are always subsection names and values are either the |
665 | 665 | * input's normalized value, or an array like the top-level array |
666 | 666 | */ |
667 | - public function input_pretty_values( $include_subform_inputs = false, $flatten = false ){ |
|
668 | - return $this->_input_values( true, $include_subform_inputs, $flatten ); |
|
667 | + public function input_pretty_values($include_subform_inputs = false, $flatten = false) { |
|
668 | + return $this->_input_values(true, $include_subform_inputs, $flatten); |
|
669 | 669 | } |
670 | 670 | |
671 | 671 | /** |
@@ -678,17 +678,17 @@ discard block |
||
678 | 678 | * it can be a multidimensional array where keys are always subsection names and values are either the |
679 | 679 | * input's normalized value, or an array like the top-level array |
680 | 680 | */ |
681 | - public function _input_values( $pretty = false, $include_subform_inputs = false, $flatten = false ) { |
|
681 | + public function _input_values($pretty = false, $include_subform_inputs = false, $flatten = false) { |
|
682 | 682 | $input_values = array(); |
683 | - foreach( $this->subsections() as $subsection_name => $subsection ) { |
|
684 | - if( $subsection instanceof EE_Form_Input_Base ) { |
|
685 | - $input_values[ $subsection_name ] = $pretty ? $subsection->pretty_value() : $subsection->normalized_value(); |
|
686 | - } else if( $subsection instanceof EE_Form_Section_Proper && $include_subform_inputs ) { |
|
687 | - $subform_input_values = $subsection->_input_values( $pretty, $include_subform_inputs, $flatten ); |
|
688 | - if( $flatten ) { |
|
689 | - $input_values = array_merge( $input_values, $subform_input_values ); |
|
683 | + foreach ($this->subsections() as $subsection_name => $subsection) { |
|
684 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
685 | + $input_values[$subsection_name] = $pretty ? $subsection->pretty_value() : $subsection->normalized_value(); |
|
686 | + } else if ($subsection instanceof EE_Form_Section_Proper && $include_subform_inputs) { |
|
687 | + $subform_input_values = $subsection->_input_values($pretty, $include_subform_inputs, $flatten); |
|
688 | + if ($flatten) { |
|
689 | + $input_values = array_merge($input_values, $subform_input_values); |
|
690 | 690 | } else { |
691 | - $input_values[ $subsection_name ] = $subform_input_values; |
|
691 | + $input_values[$subsection_name] = $subform_input_values; |
|
692 | 692 | } |
693 | 693 | } |
694 | 694 | } |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | * (ie, had receive_form_submission called on it yet) |
703 | 703 | * @return boolean |
704 | 704 | */ |
705 | - public function has_received_submission(){ |
|
705 | + public function has_received_submission() { |
|
706 | 706 | $this->ensure_construct_finalized_called(); |
707 | 707 | return $this->_received_submission; |
708 | 708 | } |
@@ -715,8 +715,8 @@ discard block |
||
715 | 715 | * @param array $inputs_to_exclude values are the input names |
716 | 716 | * @return void |
717 | 717 | */ |
718 | - public function exclude($inputs_to_exclude = array()){ |
|
719 | - foreach($inputs_to_exclude as $input_to_exclude_name){ |
|
718 | + public function exclude($inputs_to_exclude = array()) { |
|
719 | + foreach ($inputs_to_exclude as $input_to_exclude_name) { |
|
720 | 720 | unset($this->_subsections[$input_to_exclude_name]); |
721 | 721 | } |
722 | 722 | } |
@@ -726,8 +726,8 @@ discard block |
||
726 | 726 | /** |
727 | 727 | * @param array $inputs_to_hide |
728 | 728 | */ |
729 | - public function hide($inputs_to_hide= array()){ |
|
730 | - foreach($inputs_to_hide as $input_to_hide){ |
|
729 | + public function hide($inputs_to_hide = array()) { |
|
730 | + foreach ($inputs_to_hide as $input_to_hide) { |
|
731 | 731 | $input = $this->get_input($input_to_hide); |
732 | 732 | |
733 | 733 | $input->set_display_strategy(new EE_Hidden_Display_Strategy()); |
@@ -743,13 +743,13 @@ discard block |
||
743 | 743 | * @param string $subsection_name_to_add_before name of the section to add these subsections in front of, or null to add at the very end |
744 | 744 | * @return void |
745 | 745 | */ |
746 | - public function add_subsections($subsections,$subsection_name_to_add_before = NULL){ |
|
747 | - foreach($subsections as $subsection_name => $subsection){ |
|
748 | - if( ! $subsection instanceof EE_Form_Section_Base){ |
|
746 | + public function add_subsections($subsections, $subsection_name_to_add_before = NULL) { |
|
747 | + foreach ($subsections as $subsection_name => $subsection) { |
|
748 | + if ( ! $subsection instanceof EE_Form_Section_Base) { |
|
749 | 749 | EE_Error::add_error( |
750 | 750 | sprintf( |
751 | 751 | __("Trying to add a %s as a subsection (it was named '%s') to the form section '%s'. It was removed.", "event_espresso"), |
752 | - get_class( $subsection ), |
|
752 | + get_class($subsection), |
|
753 | 753 | $subsection_name, |
754 | 754 | $this->name() |
755 | 755 | ) |
@@ -758,23 +758,23 @@ discard block |
||
758 | 758 | } |
759 | 759 | } |
760 | 760 | $subsections_before = array(); |
761 | - if( $subsection_name_to_add_before ){ |
|
762 | - foreach( $this->_subsections as $subsection_name => $subsection ) { |
|
763 | - if ( $subsection_name == $subsection_name_to_add_before ) { |
|
761 | + if ($subsection_name_to_add_before) { |
|
762 | + foreach ($this->_subsections as $subsection_name => $subsection) { |
|
763 | + if ($subsection_name == $subsection_name_to_add_before) { |
|
764 | 764 | break; |
765 | 765 | } |
766 | 766 | $subsections_before[$subsection_name] = $subsection; |
767 | 767 | } |
768 | 768 | $subsections_after = array_diff_key($this->_subsections, $subsections_before); |
769 | - $this->_subsections = array_merge($subsections_before,$subsections,$subsections_after); |
|
770 | - }else{ |
|
769 | + $this->_subsections = array_merge($subsections_before, $subsections, $subsections_after); |
|
770 | + } else { |
|
771 | 771 | //don't use array_merge because keys might be numeric and we want to preserve their keys |
772 | - foreach( $subsections as $key => $subsection ){ |
|
773 | - $this->_subsections[ $key ] = $subsection; |
|
772 | + foreach ($subsections as $key => $subsection) { |
|
773 | + $this->_subsections[$key] = $subsection; |
|
774 | 774 | } |
775 | 775 | } |
776 | - if( $this->_construction_finalized ){ |
|
777 | - foreach($this->_subsections as $name => $subsection){ |
|
776 | + if ($this->_construction_finalized) { |
|
777 | + foreach ($this->_subsections as $name => $subsection) { |
|
778 | 778 | $subsection->_construct_finalize($this, $name); |
779 | 779 | } |
780 | 780 | } |
@@ -785,8 +785,8 @@ discard block |
||
785 | 785 | /** |
786 | 786 | * Just gets all validatable subsections to clean their sensitive data |
787 | 787 | */ |
788 | - public function clean_sensitive_data(){ |
|
789 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
788 | + public function clean_sensitive_data() { |
|
789 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
790 | 790 | $subsection->clean_sensitive_data(); |
791 | 791 | } |
792 | 792 | } |
@@ -796,8 +796,8 @@ discard block |
||
796 | 796 | /** |
797 | 797 | * @param string $form_submission_error_message |
798 | 798 | */ |
799 | - public function set_submission_error_message( $form_submission_error_message = '' ) { |
|
800 | - $this->_form_submission_error_message .= ! empty( $form_submission_error_message ) ? $form_submission_error_message : __( 'Form submission failed due to errors', 'event_espresso' ); |
|
799 | + public function set_submission_error_message($form_submission_error_message = '') { |
|
800 | + $this->_form_submission_error_message .= ! empty($form_submission_error_message) ? $form_submission_error_message : __('Form submission failed due to errors', 'event_espresso'); |
|
801 | 801 | } |
802 | 802 | |
803 | 803 | |
@@ -814,8 +814,8 @@ discard block |
||
814 | 814 | /** |
815 | 815 | * @param string $form_submission_success_message |
816 | 816 | */ |
817 | - public function set_submission_success_message( $form_submission_success_message ) { |
|
818 | - $this->_form_submission_success_message .= ! empty( $form_submission_success_message ) ? $form_submission_success_message : __( 'Form submitted successfully', 'event_espresso' ); |
|
817 | + public function set_submission_success_message($form_submission_success_message) { |
|
818 | + $this->_form_submission_success_message .= ! empty($form_submission_success_message) ? $form_submission_success_message : __('Form submitted successfully', 'event_espresso'); |
|
819 | 819 | } |
820 | 820 | |
821 | 821 | |
@@ -837,10 +837,10 @@ discard block |
||
837 | 837 | * EE_Form_Input_Base::_set_default_html_name_if_empty |
838 | 838 | * @return string |
839 | 839 | */ |
840 | - public function html_name_prefix(){ |
|
841 | - if( $this->parent_section() instanceof EE_Form_Section_Proper ){ |
|
842 | - return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']'; |
|
843 | - }else{ |
|
840 | + public function html_name_prefix() { |
|
841 | + if ($this->parent_section() instanceof EE_Form_Section_Proper) { |
|
842 | + return $this->parent_section()->html_name_prefix().'['.$this->name().']'; |
|
843 | + } else { |
|
844 | 844 | return $this->name(); |
845 | 845 | } |
846 | 846 | } |
@@ -851,7 +851,7 @@ discard block |
||
851 | 851 | * was set, which is probably nothing, or the classname) |
852 | 852 | * @return string |
853 | 853 | */ |
854 | - public function name(){ |
|
854 | + public function name() { |
|
855 | 855 | $this->ensure_construct_finalized_called(); |
856 | 856 | return parent::name(); |
857 | 857 | } |
@@ -860,7 +860,7 @@ discard block |
||
860 | 860 | * |
861 | 861 | * @return EE_Form_Section_Proper |
862 | 862 | */ |
863 | - public function parent_section(){ |
|
863 | + public function parent_section() { |
|
864 | 864 | $this->ensure_construct_finalized_called(); |
865 | 865 | return parent::parent_section(); |
866 | 866 | } |
@@ -869,9 +869,9 @@ discard block |
||
869 | 869 | * make sure construction finalized was called, otherwise children might not be ready |
870 | 870 | * @return void |
871 | 871 | */ |
872 | - public function ensure_construct_finalized_called(){ |
|
873 | - if( ! $this->_construction_finalized ){ |
|
874 | - $this->_construct_finalize($this->_parent_section, $this->_name ); |
|
872 | + public function ensure_construct_finalized_called() { |
|
873 | + if ( ! $this->_construction_finalized) { |
|
874 | + $this->_construct_finalize($this->_parent_section, $this->_name); |
|
875 | 875 | } |
876 | 876 | } |
877 | 877 | |
@@ -883,17 +883,17 @@ discard block |
||
883 | 883 | * @param array $req_data |
884 | 884 | * @return boolean |
885 | 885 | */ |
886 | - public function form_data_present_in( $req_data = NULL ) { |
|
887 | - if( $req_data === NULL){ |
|
886 | + public function form_data_present_in($req_data = NULL) { |
|
887 | + if ($req_data === NULL) { |
|
888 | 888 | $req_data = $_POST; |
889 | 889 | } |
890 | - foreach( $this->subsections() as $subsection ) { |
|
891 | - if($subsection instanceof EE_Form_Input_Base ) { |
|
892 | - if( $subsection->form_data_present_in( $req_data ) ) { |
|
890 | + foreach ($this->subsections() as $subsection) { |
|
891 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
892 | + if ($subsection->form_data_present_in($req_data)) { |
|
893 | 893 | return TRUE; |
894 | 894 | } |
895 | - }elseif( $subsection instanceof EE_Form_Section_Proper ) { |
|
896 | - if( $subsection->form_data_present_in( $req_data ) ) { |
|
895 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
896 | + if ($subsection->form_data_present_in($req_data)) { |
|
897 | 897 | return TRUE; |
898 | 898 | } |
899 | 899 | } |
@@ -910,14 +910,14 @@ discard block |
||
910 | 910 | */ |
911 | 911 | public function get_validation_errors_accumulated() { |
912 | 912 | $validation_errors = $this->get_validation_errors(); |
913 | - foreach($this->get_validatable_subsections() as $subsection ) { |
|
914 | - if( $subsection instanceof EE_Form_Section_Proper ) { |
|
913 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
914 | + if ($subsection instanceof EE_Form_Section_Proper) { |
|
915 | 915 | $validation_errors_on_this_subsection = $subsection->get_validation_errors_accumulated(); |
916 | 916 | } else { |
917 | - $validation_errors_on_this_subsection = $subsection->get_validation_errors(); |
|
917 | + $validation_errors_on_this_subsection = $subsection->get_validation_errors(); |
|
918 | 918 | } |
919 | - if( $validation_errors_on_this_subsection ){ |
|
920 | - $validation_errors = array_merge( $validation_errors, $validation_errors_on_this_subsection ); |
|
919 | + if ($validation_errors_on_this_subsection) { |
|
920 | + $validation_errors = array_merge($validation_errors, $validation_errors_on_this_subsection); |
|
921 | 921 | } |
922 | 922 | } |
923 | 923 | return $validation_errors; |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | if(isset($default_data[$subsection_name])){ |
210 | 210 | if($subsection instanceof EE_Form_Input_Base){ |
211 | 211 | $subsection->set_default($default_data[$subsection_name]); |
212 | - }elseif($subsection instanceof EE_Form_Section_Proper){ |
|
212 | + } elseif($subsection instanceof EE_Form_Section_Proper){ |
|
213 | 213 | $subsection->populate_defaults($default_data[$subsection_name]); |
214 | 214 | } |
215 | 215 | } |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | foreach($this->subsections() as $subsection){ |
441 | 441 | if( $subsection instanceof EE_Form_Input_Base ){ |
442 | 442 | $inputs[ $subsection->html_name() ] = $subsection; |
443 | - }elseif($subsection instanceof EE_Form_Section_Proper ){ |
|
443 | + } elseif($subsection instanceof EE_Form_Section_Proper ){ |
|
444 | 444 | $inputs += $subsection->inputs_in_subsections(); |
445 | 445 | } |
446 | 446 | } |
@@ -548,7 +548,7 @@ discard block |
||
548 | 548 | foreach($this->get_validatable_subsections() as $subsection){ |
549 | 549 | try{ |
550 | 550 | $subsection->_normalize($req_data); |
551 | - }catch( EE_Validation_Error $e ){ |
|
551 | + } catch( EE_Validation_Error $e ){ |
|
552 | 552 | $subsection->add_validation_error( $e ); |
553 | 553 | } |
554 | 554 | } |
@@ -767,7 +767,7 @@ discard block |
||
767 | 767 | } |
768 | 768 | $subsections_after = array_diff_key($this->_subsections, $subsections_before); |
769 | 769 | $this->_subsections = array_merge($subsections_before,$subsections,$subsections_after); |
770 | - }else{ |
|
770 | + } else{ |
|
771 | 771 | //don't use array_merge because keys might be numeric and we want to preserve their keys |
772 | 772 | foreach( $subsections as $key => $subsection ){ |
773 | 773 | $this->_subsections[ $key ] = $subsection; |
@@ -840,7 +840,7 @@ discard block |
||
840 | 840 | public function html_name_prefix(){ |
841 | 841 | if( $this->parent_section() instanceof EE_Form_Section_Proper ){ |
842 | 842 | return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']'; |
843 | - }else{ |
|
843 | + } else{ |
|
844 | 844 | return $this->name(); |
845 | 845 | } |
846 | 846 | } |
@@ -892,7 +892,7 @@ discard block |
||
892 | 892 | if( $subsection->form_data_present_in( $req_data ) ) { |
893 | 893 | return TRUE; |
894 | 894 | } |
895 | - }elseif( $subsection instanceof EE_Form_Section_Proper ) { |
|
895 | + } elseif( $subsection instanceof EE_Form_Section_Proper ) { |
|
896 | 896 | if( $subsection->form_data_present_in( $req_data ) ) { |
897 | 897 | return TRUE; |
898 | 898 | } |