@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined('ABSPATH') ) { |
|
| 2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | 3 | die( 'You are not allowed to call this page directly.' ); |
| 4 | 4 | } |
| 5 | 5 | |
@@ -7,12 +7,12 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | public static function setup_new_vars( $type = '', $form_id = '' ) { |
| 9 | 9 | |
| 10 | - if ( strpos($type, '|') ) { |
|
| 11 | - list($type, $setting) = explode('|', $type); |
|
| 10 | + if ( strpos( $type, '|' ) ) { |
|
| 11 | + list( $type, $setting ) = explode( '|', $type ); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | - $defaults = self::get_default_field_opts($type, $form_id); |
|
| 15 | - $defaults['field_options']['custom_html'] = self::get_default_html($type); |
|
| 14 | + $defaults = self::get_default_field_opts( $type, $form_id ); |
|
| 15 | + $defaults['field_options']['custom_html'] = self::get_default_html( $type ); |
|
| 16 | 16 | |
| 17 | 17 | $values = array(); |
| 18 | 18 | |
@@ -20,20 +20,20 @@ discard block |
||
| 20 | 20 | if ( $var == 'field_options' ) { |
| 21 | 21 | $values['field_options'] = array(); |
| 22 | 22 | foreach ( $default as $opt_var => $opt_default ) { |
| 23 | - $values['field_options'][ $opt_var ] = $opt_default; |
|
| 24 | - unset($opt_var, $opt_default); |
|
| 23 | + $values['field_options'][$opt_var] = $opt_default; |
|
| 24 | + unset( $opt_var, $opt_default ); |
|
| 25 | 25 | } |
| 26 | 26 | } else { |
| 27 | - $values[ $var ] = $default; |
|
| 27 | + $values[$var] = $default; |
|
| 28 | 28 | } |
| 29 | - unset($var, $default); |
|
| 29 | + unset( $var, $default ); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | if ( isset( $setting ) && ! empty( $setting ) ) { |
| 33 | 33 | if ( in_array( $type, array( 'data', 'lookup' ) ) ) { |
| 34 | 34 | $values['field_options']['data_type'] = $setting; |
| 35 | 35 | } else { |
| 36 | - $values['field_options'][ $setting ] = 1; |
|
| 36 | + $values['field_options'][$setting] = 1; |
|
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | |
@@ -56,13 +56,13 @@ discard block |
||
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | $fields = FrmField::field_selection(); |
| 59 | - $fields = array_merge($fields, FrmField::pro_field_selection()); |
|
| 59 | + $fields = array_merge( $fields, FrmField::pro_field_selection() ); |
|
| 60 | 60 | |
| 61 | - if ( isset( $fields[ $type ] ) ) { |
|
| 62 | - $values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ]; |
|
| 61 | + if ( isset( $fields[$type] ) ) { |
|
| 62 | + $values['name'] = is_array( $fields[$type] ) ? $fields[$type]['name'] : $fields[$type]; |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - unset($fields); |
|
| 65 | + unset( $fields ); |
|
| 66 | 66 | |
| 67 | 67 | return $values; |
| 68 | 68 | } |
@@ -88,8 +88,8 @@ discard block |
||
| 88 | 88 | $values['form_name'] = ''; |
| 89 | 89 | } else { |
| 90 | 90 | foreach ( $defaults as $var => $default ) { |
| 91 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' ); |
|
| 92 | - unset($var, $default); |
|
| 91 | + $values[$var] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' ); |
|
| 92 | + unset( $var, $default ); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | $values['form_name'] = $record->form_id ? FrmForm::getName( $record->form_id ) : ''; |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | $values['options'] = $record->options; |
| 101 | 101 | $values['field_options'] = $record->field_options; |
| 102 | 102 | |
| 103 | - $defaults = self::get_default_field_opts($values['type'], $record, true); |
|
| 103 | + $defaults = self::get_default_field_opts( $values['type'], $record, true ); |
|
| 104 | 104 | |
| 105 | 105 | if ( $values['type'] == 'captcha' ) { |
| 106 | 106 | $frm_settings = FrmAppHelper::get_settings(); |
@@ -108,11 +108,11 @@ discard block |
||
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | foreach ( $defaults as $opt => $default ) { |
| 111 | - $values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default; |
|
| 112 | - unset($opt, $default); |
|
| 111 | + $values[$opt] = isset( $record->field_options[$opt] ) ? $record->field_options[$opt] : $default; |
|
| 112 | + unset( $opt, $default ); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - $values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type); |
|
| 115 | + $values['custom_html'] = ( isset( $record->field_options['custom_html'] ) ) ? $record->field_options['custom_html'] : self::get_default_html( $record->type ); |
|
| 116 | 116 | |
| 117 | 117 | return apply_filters( 'frm_setup_edit_field_vars', $values, array( 'doing_ajax' => $doing_ajax ) ); |
| 118 | 118 | } |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | global $wpdb; |
| 133 | 133 | |
| 134 | - $form_id = (is_numeric($field)) ? $field : $field->form_id; |
|
| 134 | + $form_id = ( is_numeric( $field ) ) ? $field : $field->form_id; |
|
| 135 | 135 | |
| 136 | 136 | $key = is_numeric( $field ) ? FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_fields', 'field_key' ) : $field->field_key; |
| 137 | 137 | |
@@ -153,11 +153,11 @@ discard block |
||
| 153 | 153 | |
| 154 | 154 | $values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' ); |
| 155 | 155 | $values['form_id'] = $form_id; |
| 156 | - $values['options'] = maybe_serialize($field->options); |
|
| 157 | - $values['default_value'] = maybe_serialize($field->default_value); |
|
| 156 | + $values['options'] = maybe_serialize( $field->options ); |
|
| 157 | + $values['default_value'] = maybe_serialize( $field->default_value ); |
|
| 158 | 158 | |
| 159 | 159 | foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) { |
| 160 | - $values[ $col ] = $field->{$col}; |
|
| 160 | + $values[$col] = $field->{$col}; |
|
| 161 | 161 | } |
| 162 | 162 | } |
| 163 | 163 | |
@@ -171,21 +171,21 @@ discard block |
||
| 171 | 171 | |
| 172 | 172 | $conf_msg = __( 'The entered values do not match', 'formidable' ); |
| 173 | 173 | $defaults = array( |
| 174 | - 'unique_msg' => array( 'full' => $default_settings['unique_msg'], 'part' => sprintf( __('%s must be unique', 'formidable' ), $field_name ) ), |
|
| 175 | - 'invalid' => array( 'full' => __( 'This field is invalid', 'formidable' ), 'part' => sprintf( __('%s is invalid', 'formidable' ), $field_name ) ), |
|
| 174 | + 'unique_msg' => array( 'full' => $default_settings['unique_msg'], 'part' => sprintf( __( '%s must be unique', 'formidable' ), $field_name ) ), |
|
| 175 | + 'invalid' => array( 'full' => __( 'This field is invalid', 'formidable' ), 'part' => sprintf( __( '%s is invalid', 'formidable' ), $field_name ) ), |
|
| 176 | 176 | 'blank' => array( 'full' => $frm_settings->blank_msg, 'part' => $frm_settings->blank_msg ), |
| 177 | 177 | 'conf_msg' => array( 'full' => $conf_msg, 'part' => $conf_msg ), |
| 178 | 178 | ); |
| 179 | 179 | |
| 180 | 180 | $msg = FrmField::get_option( $field, $error ); |
| 181 | - $msg = empty( $msg ) ? $defaults[ $error ]['part'] : $msg; |
|
| 181 | + $msg = empty( $msg ) ? $defaults[$error]['part'] : $msg; |
|
| 182 | 182 | $msg = do_shortcode( $msg ); |
| 183 | 183 | return $msg; |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | public static function get_form_fields( $form_id, $error = false ) { |
| 187 | - $fields = FrmField::get_all_for_form($form_id); |
|
| 188 | - $fields = apply_filters('frm_get_paged_fields', $fields, $form_id, $error); |
|
| 187 | + $fields = FrmField::get_all_for_form( $form_id ); |
|
| 188 | + $fields = apply_filters( 'frm_get_paged_fields', $fields, $form_id, $error ); |
|
| 189 | 189 | return $fields; |
| 190 | 190 | } |
| 191 | 191 | |
@@ -208,14 +208,14 @@ discard block |
||
| 208 | 208 | </div> |
| 209 | 209 | DEFAULT_HTML; |
| 210 | 210 | } else { |
| 211 | - $default_html = apply_filters('frm_other_custom_html', '', $type); |
|
| 211 | + $default_html = apply_filters( 'frm_other_custom_html', '', $type ); |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | - return apply_filters('frm_custom_html', $default_html, $type); |
|
| 214 | + return apply_filters( 'frm_custom_html', $default_html, $type ); |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | public static function replace_shortcodes( $html, $field, $errors = array(), $form = false, $args = array() ) { |
| 218 | - $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form); |
|
| 218 | + $html = apply_filters( 'frm_before_replace_shortcodes', $html, $field, $errors, $form ); |
|
| 219 | 219 | |
| 220 | 220 | $defaults = array( |
| 221 | 221 | 'field_name' => 'item_meta[' . $field['id'] . ']', |
@@ -223,42 +223,42 @@ discard block |
||
| 223 | 223 | 'field_plus_id' => '', |
| 224 | 224 | 'section_id' => '', |
| 225 | 225 | ); |
| 226 | - $args = wp_parse_args($args, $defaults); |
|
| 226 | + $args = wp_parse_args( $args, $defaults ); |
|
| 227 | 227 | $field_name = $args['field_name']; |
| 228 | 228 | $field_id = $args['field_id']; |
| 229 | - $html_id = self::get_html_id($field, $args['field_plus_id']); |
|
| 229 | + $html_id = self::get_html_id( $field, $args['field_plus_id'] ); |
|
| 230 | 230 | |
| 231 | - if ( FrmField::is_multiple_select($field) ) { |
|
| 231 | + if ( FrmField::is_multiple_select( $field ) ) { |
|
| 232 | 232 | $field_name .= '[]'; |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | //replace [id] |
| 236 | - $html = str_replace('[id]', $field_id, $html); |
|
| 236 | + $html = str_replace( '[id]', $field_id, $html ); |
|
| 237 | 237 | |
| 238 | 238 | // Remove the for attribute for captcha |
| 239 | 239 | if ( $field['type'] == 'captcha' ) { |
| 240 | - $html = str_replace(' for="field_[key]"', '', $html); |
|
| 240 | + $html = str_replace( ' for="field_[key]"', '', $html ); |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | // set the label for |
| 244 | - $html = str_replace('field_[key]', $html_id, $html); |
|
| 244 | + $html = str_replace( 'field_[key]', $html_id, $html ); |
|
| 245 | 245 | |
| 246 | 246 | //replace [key] |
| 247 | - $html = str_replace('[key]', $field['field_key'], $html); |
|
| 247 | + $html = str_replace( '[key]', $field['field_key'], $html ); |
|
| 248 | 248 | |
| 249 | 249 | //replace [description] and [required_label] and [error] |
| 250 | 250 | $required = FrmField::is_required( $field ) ? $field['required_indicator'] : ''; |
| 251 | 251 | if ( ! is_array( $errors ) ) { |
| 252 | 252 | $errors = array(); |
| 253 | 253 | } |
| 254 | - $error = isset( $errors[ 'field' . $field_id ] ) ? $errors[ 'field' . $field_id ] : false; |
|
| 254 | + $error = isset( $errors['field' . $field_id] ) ? $errors['field' . $field_id] : false; |
|
| 255 | 255 | |
| 256 | 256 | //If field type is section heading, add class so a bottom margin can be added to either the h3 or description |
| 257 | 257 | if ( $field['type'] == 'divider' ) { |
| 258 | 258 | if ( FrmField::is_option_true( $field, 'description' ) ) { |
| 259 | 259 | $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html ); |
| 260 | 260 | } else { |
| 261 | - $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html); |
|
| 261 | + $html = str_replace( '[label_position]', '[label_position] frm_section_spacing', $html ); |
|
| 262 | 262 | } |
| 263 | 263 | } |
| 264 | 264 | |
@@ -268,48 +268,48 @@ discard block |
||
| 268 | 268 | |
| 269 | 269 | //replace [required_class] |
| 270 | 270 | $required_class = FrmField::is_required( $field ) ? ' frm_required_field' : ''; |
| 271 | - $html = str_replace('[required_class]', $required_class, $html); |
|
| 271 | + $html = str_replace( '[required_class]', $required_class, $html ); |
|
| 272 | 272 | |
| 273 | 273 | //replace [label_position] |
| 274 | - $field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form); |
|
| 274 | + $field['label'] = apply_filters( 'frm_html_label_position', $field['label'], $field, $form ); |
|
| 275 | 275 | $field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top'; |
| 276 | 276 | $html = str_replace( '[label_position]', ( ( in_array( $field['type'], array( 'divider', 'end_divider', 'break' ) ) ) ? $field['label'] : ' frm_primary_label' ), $html ); |
| 277 | 277 | |
| 278 | 278 | //replace [field_name] |
| 279 | - $html = str_replace('[field_name]', $field['name'], $html); |
|
| 279 | + $html = str_replace( '[field_name]', $field['name'], $html ); |
|
| 280 | 280 | |
| 281 | 281 | //replace [error_class] |
| 282 | - $error_class = isset( $errors[ 'field' . $field_id ] ) ? ' frm_blank_field' : ''; |
|
| 282 | + $error_class = isset( $errors['field' . $field_id] ) ? ' frm_blank_field' : ''; |
|
| 283 | 283 | self::get_more_field_classes( $error_class, $field, $field_id, $html ); |
| 284 | 284 | if ( $field['type'] == 'html' && strpos( $html, '[error_class]' ) === false ) { |
| 285 | 285 | // there is no error_class shortcode to use for addign fields |
| 286 | 286 | $html = str_replace( 'class="frm_form_field', 'class="frm_form_field ' . $error_class, $html ); |
| 287 | 287 | } |
| 288 | - $html = str_replace('[error_class]', $error_class, $html); |
|
| 288 | + $html = str_replace( '[error_class]', $error_class, $html ); |
|
| 289 | 289 | |
| 290 | 290 | //replace [entry_key] |
| 291 | 291 | $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' ); |
| 292 | - $html = str_replace('[entry_key]', $entry_key, $html); |
|
| 292 | + $html = str_replace( '[entry_key]', $entry_key, $html ); |
|
| 293 | 293 | |
| 294 | 294 | //replace [input] |
| 295 | - preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER); |
|
| 295 | + preg_match_all( "/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER ); |
|
| 296 | 296 | global $frm_vars; |
| 297 | 297 | $frm_settings = FrmAppHelper::get_settings(); |
| 298 | 298 | |
| 299 | 299 | foreach ( $shortcodes[0] as $short_key => $tag ) { |
| 300 | - $atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] ); |
|
| 300 | + $atts = shortcode_parse_atts( $shortcodes[2][$short_key] ); |
|
| 301 | 301 | $tag = self::get_shortcode_tag( $shortcodes, $short_key, array( 'conditional' => false, 'conditional_check' => false ) ); |
| 302 | 302 | |
| 303 | 303 | $replace_with = ''; |
| 304 | 304 | |
| 305 | 305 | if ( $tag == 'input' ) { |
| 306 | - if ( isset($atts['opt']) ) { |
|
| 307 | - $atts['opt']--; |
|
| 306 | + if ( isset( $atts['opt'] ) ) { |
|
| 307 | + $atts['opt'] --; |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | - $field['input_class'] = isset($atts['class']) ? $atts['class'] : ''; |
|
| 311 | - if ( isset($atts['class']) ) { |
|
| 312 | - unset($atts['class']); |
|
| 310 | + $field['input_class'] = isset( $atts['class'] ) ? $atts['class'] : ''; |
|
| 311 | + if ( isset( $atts['class'] ) ) { |
|
| 312 | + unset( $atts['class'] ); |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | $field['shortcodes'] = $atts; |
@@ -318,33 +318,33 @@ discard block |
||
| 318 | 318 | $replace_with = ob_get_contents(); |
| 319 | 319 | ob_end_clean(); |
| 320 | 320 | } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) { |
| 321 | - $replace_with = FrmProEntriesController::entry_delete_link($atts); |
|
| 321 | + $replace_with = FrmProEntriesController::entry_delete_link( $atts ); |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | - $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html ); |
|
| 324 | + $html = str_replace( $shortcodes[0][$short_key], $replace_with, $html ); |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | if ( $form ) { |
| 328 | 328 | $form = (array) $form; |
| 329 | 329 | |
| 330 | 330 | //replace [form_key] |
| 331 | - $html = str_replace('[form_key]', $form['form_key'], $html); |
|
| 331 | + $html = str_replace( '[form_key]', $form['form_key'], $html ); |
|
| 332 | 332 | |
| 333 | 333 | //replace [form_name] |
| 334 | - $html = str_replace('[form_name]', $form['name'], $html); |
|
| 334 | + $html = str_replace( '[form_name]', $form['name'], $html ); |
|
| 335 | 335 | } |
| 336 | 336 | $html .= "\n"; |
| 337 | 337 | |
| 338 | 338 | //Return html if conf_field to prevent loop |
| 339 | - if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) { |
|
| 339 | + if ( isset( $field['conf_field'] ) && $field['conf_field'] == 'stop' ) { |
|
| 340 | 340 | return $html; |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | //If field is in repeating section |
| 344 | 344 | if ( $args['section_id'] ) { |
| 345 | - $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] )); |
|
| 345 | + $html = apply_filters( 'frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] ) ); |
|
| 346 | 346 | } else { |
| 347 | - $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form )); |
|
| 347 | + $html = apply_filters( 'frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ) ); |
|
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | self::remove_collapse_shortcode( $html ); |
@@ -421,7 +421,7 @@ discard block |
||
| 421 | 421 | |
| 422 | 422 | //insert custom CSS classes |
| 423 | 423 | if ( ! empty( $field['classes'] ) ) { |
| 424 | - if ( ! strpos( $html, 'frm_form_field ') ) { |
|
| 424 | + if ( ! strpos( $html, 'frm_form_field ' ) ) { |
|
| 425 | 425 | $error_class .= ' frm_form_field'; |
| 426 | 426 | } |
| 427 | 427 | $error_class .= ' ' . $field['classes']; |
@@ -455,15 +455,15 @@ discard block |
||
| 455 | 455 | } |
| 456 | 456 | |
| 457 | 457 | $with_tags = $args['conditional_check'] ? 3 : 2; |
| 458 | - if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) { |
|
| 459 | - $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] ); |
|
| 460 | - $tag = str_replace(']', '', $tag); |
|
| 461 | - $tags = explode(' ', $tag); |
|
| 462 | - if ( is_array($tags) ) { |
|
| 458 | + if ( ! empty( $shortcodes[$with_tags][$short_key] ) ) { |
|
| 459 | + $tag = str_replace( '[' . $prefix, '', $shortcodes[0][$short_key] ); |
|
| 460 | + $tag = str_replace( ']', '', $tag ); |
|
| 461 | + $tags = explode( ' ', $tag ); |
|
| 462 | + if ( is_array( $tags ) ) { |
|
| 463 | 463 | $tag = $tags[0]; |
| 464 | 464 | } |
| 465 | 465 | } else { |
| 466 | - $tag = $shortcodes[ $with_tags - 1 ][ $short_key ]; |
|
| 466 | + $tag = $shortcodes[$with_tags - 1][$short_key]; |
|
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | return $tag; |
@@ -507,10 +507,10 @@ discard block |
||
| 507 | 507 | |
| 508 | 508 | public static function show_single_option( $field ) { |
| 509 | 509 | $field_name = $field['name']; |
| 510 | - $html_id = self::get_html_id($field); |
|
| 510 | + $html_id = self::get_html_id( $field ); |
|
| 511 | 511 | foreach ( $field['options'] as $opt_key => $opt ) { |
| 512 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 513 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 512 | + $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field ); |
|
| 513 | + $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field ); |
|
| 514 | 514 | |
| 515 | 515 | // If this is an "Other" option, get the HTML for it |
| 516 | 516 | if ( self::is_other_opt( $opt_key ) ) { |
@@ -525,7 +525,7 @@ discard block |
||
| 525 | 525 | |
| 526 | 526 | public static function dropdown_categories( $args ) { |
| 527 | 527 | $defaults = array( 'field' => false, 'name' => false, 'show_option_all' => ' ' ); |
| 528 | - $args = wp_parse_args($args, $defaults); |
|
| 528 | + $args = wp_parse_args( $args, $defaults ); |
|
| 529 | 529 | |
| 530 | 530 | if ( ! $args['field'] ) { |
| 531 | 531 | return; |
@@ -535,17 +535,17 @@ discard block |
||
| 535 | 535 | $args['name'] = 'item_meta[' . $args['field']['id'] . ']'; |
| 536 | 536 | } |
| 537 | 537 | |
| 538 | - $id = self::get_html_id($args['field']); |
|
| 538 | + $id = self::get_html_id( $args['field'] ); |
|
| 539 | 539 | $class = $args['field']['type']; |
| 540 | 540 | |
| 541 | - $exclude = (is_array($args['field']['exclude_cat'])) ? implode(',', $args['field']['exclude_cat']) : $args['field']['exclude_cat']; |
|
| 542 | - $exclude = apply_filters('frm_exclude_cats', $exclude, $args['field']); |
|
| 541 | + $exclude = ( is_array( $args['field']['exclude_cat'] ) ) ? implode( ',', $args['field']['exclude_cat'] ) : $args['field']['exclude_cat']; |
|
| 542 | + $exclude = apply_filters( 'frm_exclude_cats', $exclude, $args['field'] ); |
|
| 543 | 543 | |
| 544 | - if ( is_array($args['field']['value']) ) { |
|
| 545 | - if ( ! empty($exclude) ) { |
|
| 546 | - $args['field']['value'] = array_diff($args['field']['value'], explode(',', $exclude)); |
|
| 544 | + if ( is_array( $args['field']['value'] ) ) { |
|
| 545 | + if ( ! empty( $exclude ) ) { |
|
| 546 | + $args['field']['value'] = array_diff( $args['field']['value'], explode( ',', $exclude ) ); |
|
| 547 | 547 | } |
| 548 | - $selected = reset($args['field']['value']); |
|
| 548 | + $selected = reset( $args['field']['value'] ); |
|
| 549 | 549 | } else { |
| 550 | 550 | $selected = $args['field']['value']; |
| 551 | 551 | } |
@@ -556,40 +556,40 @@ discard block |
||
| 556 | 556 | 'hide_empty' => false, 'echo' => 0, 'orderby' => 'name', |
| 557 | 557 | ); |
| 558 | 558 | |
| 559 | - $tax_atts = apply_filters('frm_dropdown_cat', $tax_atts, $args['field']); |
|
| 559 | + $tax_atts = apply_filters( 'frm_dropdown_cat', $tax_atts, $args['field'] ); |
|
| 560 | 560 | |
| 561 | 561 | if ( FrmAppHelper::pro_is_installed() ) { |
| 562 | - $post_type = FrmProFormsHelper::post_type($args['field']['form_id']); |
|
| 563 | - $tax_atts['taxonomy'] = FrmProAppHelper::get_custom_taxonomy($post_type, $args['field']); |
|
| 562 | + $post_type = FrmProFormsHelper::post_type( $args['field']['form_id'] ); |
|
| 563 | + $tax_atts['taxonomy'] = FrmProAppHelper::get_custom_taxonomy( $post_type, $args['field'] ); |
|
| 564 | 564 | if ( ! $tax_atts['taxonomy'] ) { |
| 565 | 565 | return; |
| 566 | 566 | } |
| 567 | 567 | |
| 568 | 568 | // If field type is dropdown (not Dynamic), exclude children when parent is excluded |
| 569 | - if ( $args['field']['type'] != 'data' && is_taxonomy_hierarchical($tax_atts['taxonomy']) ) { |
|
| 569 | + if ( $args['field']['type'] != 'data' && is_taxonomy_hierarchical( $tax_atts['taxonomy'] ) ) { |
|
| 570 | 570 | $tax_atts['exclude_tree'] = $exclude; |
| 571 | 571 | } |
| 572 | 572 | } |
| 573 | 573 | |
| 574 | - $dropdown = wp_dropdown_categories($tax_atts); |
|
| 574 | + $dropdown = wp_dropdown_categories( $tax_atts ); |
|
| 575 | 575 | |
| 576 | - $add_html = FrmFieldsController::input_html($args['field'], false); |
|
| 576 | + $add_html = FrmFieldsController::input_html( $args['field'], false ); |
|
| 577 | 577 | |
| 578 | 578 | if ( FrmAppHelper::pro_is_installed() ) { |
| 579 | - $add_html .= FrmProFieldsController::input_html($args['field'], false); |
|
| 579 | + $add_html .= FrmProFieldsController::input_html( $args['field'], false ); |
|
| 580 | 580 | } |
| 581 | 581 | |
| 582 | 582 | $dropdown = str_replace( "<select name='" . esc_attr( $args['name'] ) . "' id='" . esc_attr( $id ) . "' class='" . esc_attr( $class ) . "'", "<select name='" . esc_attr( $args['name'] ) . "' id='" . esc_attr( $id ) . "' " . $add_html, $dropdown ); |
| 583 | 583 | |
| 584 | - if ( is_array($args['field']['value']) ) { |
|
| 584 | + if ( is_array( $args['field']['value'] ) ) { |
|
| 585 | 585 | $skip = true; |
| 586 | 586 | foreach ( $args['field']['value'] as $v ) { |
| 587 | 587 | if ( $skip ) { |
| 588 | 588 | $skip = false; |
| 589 | 589 | continue; |
| 590 | 590 | } |
| 591 | - $dropdown = str_replace(' value="' . esc_attr( $v ) . '"', ' value="' . esc_attr( $v ) . '" selected="selected"', $dropdown ); |
|
| 592 | - unset($v); |
|
| 591 | + $dropdown = str_replace( ' value="' . esc_attr( $v ) . '"', ' value="' . esc_attr( $v ) . '" selected="selected"', $dropdown ); |
|
| 592 | + unset( $v ); |
|
| 593 | 593 | } |
| 594 | 594 | } |
| 595 | 595 | |
@@ -597,7 +597,7 @@ discard block |
||
| 597 | 597 | } |
| 598 | 598 | |
| 599 | 599 | public static function get_term_link( $tax_id ) { |
| 600 | - $tax = get_taxonomy($tax_id); |
|
| 600 | + $tax = get_taxonomy( $tax_id ); |
|
| 601 | 601 | if ( ! $tax ) { |
| 602 | 602 | return; |
| 603 | 603 | } |
@@ -606,7 +606,7 @@ discard block |
||
| 606 | 606 | __( 'Please add options from the WordPress "%1$s" page', 'formidable' ), |
| 607 | 607 | '<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>' |
| 608 | 608 | ); |
| 609 | - unset($tax); |
|
| 609 | + unset( $tax ); |
|
| 610 | 610 | |
| 611 | 611 | return $link; |
| 612 | 612 | } |
@@ -617,8 +617,8 @@ discard block |
||
| 617 | 617 | $hide_opt = rtrim( $hide_opt ); |
| 618 | 618 | } |
| 619 | 619 | |
| 620 | - if ( is_array($observed_value) ) { |
|
| 621 | - return self::array_value_condition($observed_value, $cond, $hide_opt); |
|
| 620 | + if ( is_array( $observed_value ) ) { |
|
| 621 | + return self::array_value_condition( $observed_value, $cond, $hide_opt ); |
|
| 622 | 622 | } |
| 623 | 623 | |
| 624 | 624 | $m = false; |
@@ -631,7 +631,7 @@ discard block |
||
| 631 | 631 | } else if ( $cond == '<' ) { |
| 632 | 632 | $m = $observed_value < $hide_opt; |
| 633 | 633 | } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
| 634 | - $m = stripos($observed_value, $hide_opt); |
|
| 634 | + $m = stripos( $observed_value, $hide_opt ); |
|
| 635 | 635 | if ( $cond == 'not LIKE' ) { |
| 636 | 636 | $m = ( $m === false ) ? true : false; |
| 637 | 637 | } else { |
@@ -644,23 +644,23 @@ discard block |
||
| 644 | 644 | public static function array_value_condition( $observed_value, $cond, $hide_opt ) { |
| 645 | 645 | $m = false; |
| 646 | 646 | if ( $cond == '==' ) { |
| 647 | - if ( is_array($hide_opt) ) { |
|
| 648 | - $m = array_intersect($hide_opt, $observed_value); |
|
| 649 | - $m = empty($m) ? false : true; |
|
| 647 | + if ( is_array( $hide_opt ) ) { |
|
| 648 | + $m = array_intersect( $hide_opt, $observed_value ); |
|
| 649 | + $m = empty( $m ) ? false : true; |
|
| 650 | 650 | } else { |
| 651 | - $m = in_array($hide_opt, $observed_value); |
|
| 651 | + $m = in_array( $hide_opt, $observed_value ); |
|
| 652 | 652 | } |
| 653 | 653 | } else if ( $cond == '!=' ) { |
| 654 | - $m = ! in_array($hide_opt, $observed_value); |
|
| 654 | + $m = ! in_array( $hide_opt, $observed_value ); |
|
| 655 | 655 | } else if ( $cond == '>' ) { |
| 656 | - $min = min($observed_value); |
|
| 656 | + $min = min( $observed_value ); |
|
| 657 | 657 | $m = $min > $hide_opt; |
| 658 | 658 | } else if ( $cond == '<' ) { |
| 659 | - $max = max($observed_value); |
|
| 659 | + $max = max( $observed_value ); |
|
| 660 | 660 | $m = $max < $hide_opt; |
| 661 | 661 | } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
| 662 | 662 | foreach ( $observed_value as $ob ) { |
| 663 | - $m = strpos($ob, $hide_opt); |
|
| 663 | + $m = strpos( $ob, $hide_opt ); |
|
| 664 | 664 | if ( $m !== false ) { |
| 665 | 665 | $m = true; |
| 666 | 666 | break; |
@@ -681,27 +681,27 @@ discard block |
||
| 681 | 681 | * @return string |
| 682 | 682 | */ |
| 683 | 683 | public static function basic_replace_shortcodes( $value, $form, $entry ) { |
| 684 | - if ( strpos($value, '[sitename]') !== false ) { |
|
| 684 | + if ( strpos( $value, '[sitename]' ) !== false ) { |
|
| 685 | 685 | $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
| 686 | - $value = str_replace('[sitename]', $new_value, $value); |
|
| 686 | + $value = str_replace( '[sitename]', $new_value, $value ); |
|
| 687 | 687 | } |
| 688 | 688 | |
| 689 | - $value = apply_filters('frm_content', $value, $form, $entry); |
|
| 690 | - $value = do_shortcode($value); |
|
| 689 | + $value = apply_filters( 'frm_content', $value, $form, $entry ); |
|
| 690 | + $value = do_shortcode( $value ); |
|
| 691 | 691 | |
| 692 | 692 | return $value; |
| 693 | 693 | } |
| 694 | 694 | |
| 695 | 695 | public static function get_shortcodes( $content, $form_id ) { |
| 696 | 696 | if ( FrmAppHelper::pro_is_installed() ) { |
| 697 | - return FrmProDisplaysHelper::get_shortcodes($content, $form_id); |
|
| 697 | + return FrmProDisplaysHelper::get_shortcodes( $content, $form_id ); |
|
| 698 | 698 | } |
| 699 | 699 | |
| 700 | 700 | $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) ); |
| 701 | 701 | |
| 702 | - $tagregexp = self::allowed_shortcodes($fields); |
|
| 702 | + $tagregexp = self::allowed_shortcodes( $fields ); |
|
| 703 | 703 | |
| 704 | - preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER); |
|
| 704 | + preg_match_all( "/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER ); |
|
| 705 | 705 | |
| 706 | 706 | return $matches; |
| 707 | 707 | } |
@@ -719,7 +719,7 @@ discard block |
||
| 719 | 719 | $tagregexp[] = $field->field_key; |
| 720 | 720 | } |
| 721 | 721 | |
| 722 | - $tagregexp = implode('|', $tagregexp); |
|
| 722 | + $tagregexp = implode( '|', $tagregexp ); |
|
| 723 | 723 | return $tagregexp; |
| 724 | 724 | } |
| 725 | 725 | |
@@ -731,28 +731,28 @@ discard block |
||
| 731 | 731 | ); |
| 732 | 732 | |
| 733 | 733 | foreach ( $shortcodes[0] as $short_key => $tag ) { |
| 734 | - $atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] ); |
|
| 734 | + $atts = shortcode_parse_atts( $shortcodes[3][$short_key] ); |
|
| 735 | 735 | |
| 736 | - if ( ! empty( $shortcodes[3][ $short_key ] ) ) { |
|
| 737 | - $tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] ); |
|
| 738 | - $tags = explode(' ', $tag); |
|
| 739 | - if ( is_array($tags) ) { |
|
| 736 | + if ( ! empty( $shortcodes[3][$short_key] ) ) { |
|
| 737 | + $tag = str_replace( array( '[', ']' ), '', $shortcodes[0][$short_key] ); |
|
| 738 | + $tags = explode( ' ', $tag ); |
|
| 739 | + if ( is_array( $tags ) ) { |
|
| 740 | 740 | $tag = $tags[0]; |
| 741 | 741 | } |
| 742 | 742 | } else { |
| 743 | - $tag = $shortcodes[2][ $short_key ]; |
|
| 743 | + $tag = $shortcodes[2][$short_key]; |
|
| 744 | 744 | } |
| 745 | 745 | |
| 746 | 746 | switch ( $tag ) { |
| 747 | 747 | case 'id': |
| 748 | 748 | case 'key': |
| 749 | 749 | case 'ip': |
| 750 | - $replace_with = $shortcode_values[ $tag ]; |
|
| 750 | + $replace_with = $shortcode_values[$tag]; |
|
| 751 | 751 | break; |
| 752 | 752 | |
| 753 | 753 | case 'user_agent': |
| 754 | 754 | case 'user-agent': |
| 755 | - $entry->description = maybe_unserialize($entry->description); |
|
| 755 | + $entry->description = maybe_unserialize( $entry->description ); |
|
| 756 | 756 | $replace_with = FrmEntryFormat::get_browser( $entry->description['browser'] ); |
| 757 | 757 | break; |
| 758 | 758 | |
@@ -760,25 +760,25 @@ discard block |
||
| 760 | 760 | case 'created-at': |
| 761 | 761 | case 'updated_at': |
| 762 | 762 | case 'updated-at': |
| 763 | - if ( isset($atts['format']) ) { |
|
| 763 | + if ( isset( $atts['format'] ) ) { |
|
| 764 | 764 | $time_format = ' '; |
| 765 | 765 | } else { |
| 766 | - $atts['format'] = get_option('date_format'); |
|
| 766 | + $atts['format'] = get_option( 'date_format' ); |
|
| 767 | 767 | $time_format = ''; |
| 768 | 768 | } |
| 769 | 769 | |
| 770 | - $this_tag = str_replace('-', '_', $tag); |
|
| 771 | - $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format); |
|
| 772 | - unset($this_tag); |
|
| 770 | + $this_tag = str_replace( '-', '_', $tag ); |
|
| 771 | + $replace_with = FrmAppHelper::get_formatted_time( $entry->{$this_tag}, $atts['format'], $time_format ); |
|
| 772 | + unset( $this_tag ); |
|
| 773 | 773 | break; |
| 774 | 774 | |
| 775 | 775 | case 'created_by': |
| 776 | 776 | case 'created-by': |
| 777 | 777 | case 'updated_by': |
| 778 | 778 | case 'updated-by': |
| 779 | - $this_tag = str_replace('-', '_', $tag); |
|
| 779 | + $this_tag = str_replace( '-', '_', $tag ); |
|
| 780 | 780 | $replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts ); |
| 781 | - unset($this_tag); |
|
| 781 | + unset( $this_tag ); |
|
| 782 | 782 | break; |
| 783 | 783 | |
| 784 | 784 | case 'admin_email': |
@@ -795,16 +795,16 @@ discard block |
||
| 795 | 795 | break; |
| 796 | 796 | } |
| 797 | 797 | |
| 798 | - $sep = isset($atts['sep']) ? $atts['sep'] : ', '; |
|
| 798 | + $sep = isset( $atts['sep'] ) ? $atts['sep'] : ', '; |
|
| 799 | 799 | |
| 800 | 800 | $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id ); |
| 801 | 801 | |
| 802 | 802 | $atts['entry_id'] = $entry->id; |
| 803 | 803 | $atts['entry_key'] = $entry->item_key; |
| 804 | 804 | |
| 805 | - if ( isset($atts['show']) && $atts['show'] == 'field_label' ) { |
|
| 805 | + if ( isset( $atts['show'] ) && $atts['show'] == 'field_label' ) { |
|
| 806 | 806 | $replace_with = $field->name; |
| 807 | - } else if ( isset($atts['show']) && $atts['show'] == 'description' ) { |
|
| 807 | + } else if ( isset( $atts['show'] ) && $atts['show'] == 'description' ) { |
|
| 808 | 808 | $replace_with = $field->description; |
| 809 | 809 | } else { |
| 810 | 810 | $string_value = $replace_with; |
@@ -819,15 +819,15 @@ discard block |
||
| 819 | 819 | } |
| 820 | 820 | } |
| 821 | 821 | |
| 822 | - unset($field); |
|
| 822 | + unset( $field ); |
|
| 823 | 823 | break; |
| 824 | 824 | } |
| 825 | 825 | |
| 826 | - if ( isset($replace_with) ) { |
|
| 827 | - $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content ); |
|
| 826 | + if ( isset( $replace_with ) ) { |
|
| 827 | + $content = str_replace( $shortcodes[0][$short_key], $replace_with, $content ); |
|
| 828 | 828 | } |
| 829 | 829 | |
| 830 | - unset($atts, $conditional, $replace_with); |
|
| 830 | + unset( $atts, $conditional, $replace_with ); |
|
| 831 | 831 | } |
| 832 | 832 | |
| 833 | 833 | return $content; |
@@ -843,7 +843,7 @@ discard block |
||
| 843 | 843 | $new_value = ''; |
| 844 | 844 | switch ( $tag ) { |
| 845 | 845 | case 'admin_email': |
| 846 | - $new_value = get_option('admin_email'); |
|
| 846 | + $new_value = get_option( 'admin_email' ); |
|
| 847 | 847 | break; |
| 848 | 848 | case 'siteurl': |
| 849 | 849 | $new_value = FrmAppHelper::site_url(); |
@@ -869,28 +869,28 @@ discard block |
||
| 869 | 869 | * @return string|array |
| 870 | 870 | */ |
| 871 | 871 | public static function process_get_shortcode( $atts, $return_array = false ) { |
| 872 | - if ( ! isset($atts['param']) ) { |
|
| 872 | + if ( ! isset( $atts['param'] ) ) { |
|
| 873 | 873 | return ''; |
| 874 | 874 | } |
| 875 | 875 | |
| 876 | - if ( strpos($atts['param'], '[') ) { |
|
| 877 | - $atts['param'] = str_replace('[', '[', $atts['param']); |
|
| 878 | - $atts['param'] = str_replace(']', ']', $atts['param']); |
|
| 876 | + if ( strpos( $atts['param'], '[' ) ) { |
|
| 877 | + $atts['param'] = str_replace( '[', '[', $atts['param'] ); |
|
| 878 | + $atts['param'] = str_replace( ']', ']', $atts['param'] ); |
|
| 879 | 879 | } |
| 880 | 880 | |
| 881 | - $new_value = FrmAppHelper::get_param($atts['param'], ''); |
|
| 881 | + $new_value = FrmAppHelper::get_param( $atts['param'], '' ); |
|
| 882 | 882 | $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] ); |
| 883 | 883 | |
| 884 | 884 | if ( $new_value == '' ) { |
| 885 | - if ( ! isset($atts['prev_val']) ) { |
|
| 885 | + if ( ! isset( $atts['prev_val'] ) ) { |
|
| 886 | 886 | $atts['prev_val'] = ''; |
| 887 | 887 | } |
| 888 | 888 | |
| 889 | - $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val']; |
|
| 889 | + $new_value = isset( $atts['default'] ) ? $atts['default'] : $atts['prev_val']; |
|
| 890 | 890 | } |
| 891 | 891 | |
| 892 | - if ( is_array($new_value) && ! $return_array ) { |
|
| 893 | - $new_value = implode(', ', $new_value); |
|
| 892 | + if ( is_array( $new_value ) && ! $return_array ) { |
|
| 893 | + $new_value = implode( ', ', $new_value ); |
|
| 894 | 894 | } |
| 895 | 895 | |
| 896 | 896 | return $new_value; |
@@ -903,12 +903,12 @@ discard block |
||
| 903 | 903 | $replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts ); |
| 904 | 904 | |
| 905 | 905 | if ( $field->type == 'textarea' || $field->type == 'rte' ) { |
| 906 | - $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true; |
|
| 907 | - if ( apply_filters('frm_use_wpautop', $autop) ) { |
|
| 908 | - if ( is_array($replace_with) ) { |
|
| 909 | - $replace_with = implode("\n", $replace_with); |
|
| 906 | + $autop = isset( $atts['wpautop'] ) ? $atts['wpautop'] : true; |
|
| 907 | + if ( apply_filters( 'frm_use_wpautop', $autop ) ) { |
|
| 908 | + if ( is_array( $replace_with ) ) { |
|
| 909 | + $replace_with = implode( "\n", $replace_with ); |
|
| 910 | 910 | } |
| 911 | - $replace_with = wpautop($replace_with); |
|
| 911 | + $replace_with = wpautop( $replace_with ); |
|
| 912 | 912 | } |
| 913 | 913 | unset( $autop ); |
| 914 | 914 | } else if ( is_array( $replace_with ) ) { |
@@ -930,14 +930,14 @@ discard block |
||
| 930 | 930 | $field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() ); |
| 931 | 931 | |
| 932 | 932 | $field_types = array(); |
| 933 | - if ( in_array($type, $single_input) ) { |
|
| 933 | + if ( in_array( $type, $single_input ) ) { |
|
| 934 | 934 | self::field_types_for_input( $single_input, $field_selection, $field_types ); |
| 935 | - } else if ( in_array($type, $multiple_input) ) { |
|
| 935 | + } else if ( in_array( $type, $multiple_input ) ) { |
|
| 936 | 936 | self::field_types_for_input( $multiple_input, $field_selection, $field_types ); |
| 937 | - } else if ( in_array($type, $other_type) ) { |
|
| 937 | + } else if ( in_array( $type, $other_type ) ) { |
|
| 938 | 938 | self::field_types_for_input( $other_type, $field_selection, $field_types ); |
| 939 | - } else if ( isset( $field_selection[ $type ] ) ) { |
|
| 940 | - $field_types[ $type ] = $field_selection[ $type ]; |
|
| 939 | + } else if ( isset( $field_selection[$type] ) ) { |
|
| 940 | + $field_types[$type] = $field_selection[$type]; |
|
| 941 | 941 | } |
| 942 | 942 | |
| 943 | 943 | $field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) ); |
@@ -946,8 +946,8 @@ discard block |
||
| 946 | 946 | |
| 947 | 947 | private static function field_types_for_input( $inputs, $fields, &$field_types ) { |
| 948 | 948 | foreach ( $inputs as $input ) { |
| 949 | - $field_types[ $input ] = $fields[ $input ]; |
|
| 950 | - unset($input); |
|
| 949 | + $field_types[$input] = $fields[$input]; |
|
| 950 | + unset( $input ); |
|
| 951 | 951 | } |
| 952 | 952 | } |
| 953 | 953 | |
@@ -992,21 +992,21 @@ discard block |
||
| 992 | 992 | // Check posted vals before checking saved values |
| 993 | 993 | |
| 994 | 994 | // For fields inside repeating sections - note, don't check if $pointer is true because it will often be zero |
| 995 | - if ( $parent && isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ) { |
|
| 995 | + if ( $parent && isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] ) ) { |
|
| 996 | 996 | if ( FrmField::is_field_with_multiple_values( $field ) ) { |
| 997 | - $other_val = isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) : ''; |
|
| 997 | + $other_val = isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']][$opt_key] ) ? sanitize_text_field( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']][$opt_key] ) : ''; |
|
| 998 | 998 | } else { |
| 999 | - $other_val = sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ); |
|
| 999 | + $other_val = sanitize_text_field( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] ); |
|
| 1000 | 1000 | } |
| 1001 | 1001 | return $other_val; |
| 1002 | 1002 | |
| 1003 | - } else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][ $field['id'] ] ) ) { |
|
| 1003 | + } else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][$field['id']] ) ) { |
|
| 1004 | 1004 | // For normal fields |
| 1005 | 1005 | |
| 1006 | 1006 | if ( FrmField::is_field_with_multiple_values( $field ) ) { |
| 1007 | - $other_val = isset( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) : ''; |
|
| 1007 | + $other_val = isset( $_POST['item_meta']['other'][$field['id']][$opt_key] ) ? sanitize_text_field( $_POST['item_meta']['other'][$field['id']][$opt_key] ) : ''; |
|
| 1008 | 1008 | } else { |
| 1009 | - $other_val = sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ] ); |
|
| 1009 | + $other_val = sanitize_text_field( $_POST['item_meta']['other'][$field['id']] ); |
|
| 1010 | 1010 | } |
| 1011 | 1011 | return $other_val; |
| 1012 | 1012 | } |
@@ -1015,8 +1015,8 @@ discard block |
||
| 1015 | 1015 | if ( $field['type'] == 'checkbox' && is_array( $field['value'] ) ) { |
| 1016 | 1016 | // Check if there is an "other" val in saved value and make sure the |
| 1017 | 1017 | // "other" val is not equal to the Other checkbox option |
| 1018 | - if ( isset( $field['value'][ $opt_key ] ) && $field['options'][ $opt_key ] != $field['value'][ $opt_key ] ) { |
|
| 1019 | - $other_val = $field['value'][ $opt_key ]; |
|
| 1018 | + if ( isset( $field['value'][$opt_key] ) && $field['options'][$opt_key] != $field['value'][$opt_key] ) { |
|
| 1019 | + $other_val = $field['value'][$opt_key]; |
|
| 1020 | 1020 | } |
| 1021 | 1021 | } else { |
| 1022 | 1022 | /** |
@@ -1028,8 +1028,8 @@ discard block |
||
| 1028 | 1028 | // Multi-select dropdowns - key is not preserved |
| 1029 | 1029 | if ( is_array( $field['value'] ) ) { |
| 1030 | 1030 | $o_key = array_search( $temp_val, $field['value'] ); |
| 1031 | - if ( isset( $field['value'][ $o_key ] ) ) { |
|
| 1032 | - unset( $field['value'][ $o_key ], $o_key ); |
|
| 1031 | + if ( isset( $field['value'][$o_key] ) ) { |
|
| 1032 | + unset( $field['value'][$o_key], $o_key ); |
|
| 1033 | 1033 | } |
| 1034 | 1034 | } else if ( $temp_val == $field['value'] ) { |
| 1035 | 1035 | // For radio and regular dropdowns |
@@ -1086,7 +1086,7 @@ discard block |
||
| 1086 | 1086 | private static function set_other_name( $args, &$other_args ) { |
| 1087 | 1087 | //Set up name for other field |
| 1088 | 1088 | $other_args['name'] = str_replace( '[]', '', $args['field_name'] ); |
| 1089 | - $other_args['name'] = preg_replace('/\[' . $args['field']['id'] . '\]$/', '', $other_args['name']); |
|
| 1089 | + $other_args['name'] = preg_replace( '/\[' . $args['field']['id'] . '\]$/', '', $other_args['name'] ); |
|
| 1090 | 1090 | $other_args['name'] = $other_args['name'] . '[other]' . '[' . $args['field']['id'] . ']'; |
| 1091 | 1091 | |
| 1092 | 1092 | //Converts item_meta[field_id] => item_meta[other][field_id] and |
@@ -1112,7 +1112,7 @@ discard block |
||
| 1112 | 1112 | // Count should only be greater than 3 if inside of a repeating section |
| 1113 | 1113 | if ( count( $temp_array ) > 3 ) { |
| 1114 | 1114 | $parent = str_replace( ']', '', $temp_array[1] ); |
| 1115 | - $pointer = str_replace( ']', '', $temp_array[2]); |
|
| 1115 | + $pointer = str_replace( ']', '', $temp_array[2] ); |
|
| 1116 | 1116 | } |
| 1117 | 1117 | |
| 1118 | 1118 | // Get text for "other" text field |
@@ -1231,15 +1231,15 @@ discard block |
||
| 1231 | 1231 | $replace_with[] = '[' . $new . ']'; |
| 1232 | 1232 | $replace[] = '[' . $old . ' '; |
| 1233 | 1233 | $replace_with[] = '[' . $new . ' '; |
| 1234 | - unset($old, $new); |
|
| 1234 | + unset( $old, $new ); |
|
| 1235 | 1235 | } |
| 1236 | 1236 | if ( is_array( $val ) ) { |
| 1237 | 1237 | foreach ( $val as $k => $v ) { |
| 1238 | - $val[ $k ] = str_replace( $replace, $replace_with, $v ); |
|
| 1239 | - unset($k, $v); |
|
| 1238 | + $val[$k] = str_replace( $replace, $replace_with, $v ); |
|
| 1239 | + unset( $k, $v ); |
|
| 1240 | 1240 | } |
| 1241 | 1241 | } else { |
| 1242 | - $val = str_replace($replace, $replace_with, $val); |
|
| 1242 | + $val = str_replace( $replace, $replace_with, $val ); |
|
| 1243 | 1243 | } |
| 1244 | 1244 | |
| 1245 | 1245 | return $val; |
@@ -1252,7 +1252,7 @@ discard block |
||
| 1252 | 1252 | 'DC' => 'District of Columbia', |
| 1253 | 1253 | 'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho', |
| 1254 | 1254 | 'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas', |
| 1255 | - 'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland', |
|
| 1255 | + 'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine', 'MD' => 'Maryland', |
|
| 1256 | 1256 | 'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi', |
| 1257 | 1257 | 'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada', |
| 1258 | 1258 | 'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York', |
@@ -1343,35 +1343,35 @@ discard block |
||
| 1343 | 1343 | } |
| 1344 | 1344 | |
| 1345 | 1345 | public static function get_bulk_prefilled_opts( array &$prepop ) { |
| 1346 | - $prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries(); |
|
| 1346 | + $prepop[__( 'Countries', 'formidable' )] = FrmFieldsHelper::get_countries(); |
|
| 1347 | 1347 | |
| 1348 | 1348 | $states = FrmFieldsHelper::get_us_states(); |
| 1349 | - $state_abv = array_keys($states); |
|
| 1350 | - sort($state_abv); |
|
| 1351 | - $prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv; |
|
| 1349 | + $state_abv = array_keys( $states ); |
|
| 1350 | + sort( $state_abv ); |
|
| 1351 | + $prepop[__( 'U.S. State Abbreviations', 'formidable' )] = $state_abv; |
|
| 1352 | 1352 | |
| 1353 | - $states = array_values($states); |
|
| 1354 | - sort($states); |
|
| 1355 | - $prepop[ __( 'U.S. States', 'formidable' ) ] = $states; |
|
| 1356 | - unset($state_abv, $states); |
|
| 1353 | + $states = array_values( $states ); |
|
| 1354 | + sort( $states ); |
|
| 1355 | + $prepop[__( 'U.S. States', 'formidable' )] = $states; |
|
| 1356 | + unset( $state_abv, $states ); |
|
| 1357 | 1357 | |
| 1358 | - $prepop[ __( 'Age', 'formidable' ) ] = array( |
|
| 1358 | + $prepop[__( 'Age', 'formidable' )] = array( |
|
| 1359 | 1359 | __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ), |
| 1360 | 1360 | __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ), |
| 1361 | 1361 | __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ), |
| 1362 | 1362 | ); |
| 1363 | 1363 | |
| 1364 | - $prepop[ __( 'Satisfaction', 'formidable' ) ] = array( |
|
| 1364 | + $prepop[__( 'Satisfaction', 'formidable' )] = array( |
|
| 1365 | 1365 | __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ), |
| 1366 | 1366 | __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ), |
| 1367 | 1367 | ); |
| 1368 | 1368 | |
| 1369 | - $prepop[ __( 'Importance', 'formidable' ) ] = array( |
|
| 1369 | + $prepop[__( 'Importance', 'formidable' )] = array( |
|
| 1370 | 1370 | __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ), |
| 1371 | 1371 | __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ), |
| 1372 | 1372 | ); |
| 1373 | 1373 | |
| 1374 | - $prepop[ __( 'Agreement', 'formidable' ) ] = array( |
|
| 1374 | + $prepop[__( 'Agreement', 'formidable' )] = array( |
|
| 1375 | 1375 | __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ), |
| 1376 | 1376 | __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ), |
| 1377 | 1377 | ); |