Completed
Push — master ( 2c01cd...74f1ae )
by Jamie
04:01
created
classes/views/styles/_field-description.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <div class="field-group field-group-background clearfix frm-first-row">
2 2
 	<label><?php _e( 'Color', 'formidable' ) ?></label>
3
-	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('description_color') ) ?>" id="frm_description_color" class="hex" value="<?php echo esc_attr( $style->post_content['description_color'] ) ?>" />
3
+	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'description_color' ) ) ?>" id="frm_description_color" class="hex" value="<?php echo esc_attr( $style->post_content['description_color'] ) ?>" />
4 4
 </div>
5 5
 <div class="field-group clearfix frm-first-row">
6 6
 	<label><?php _e( 'Weight', 'formidable' ) ?></label>
7
-	<select name="<?php echo esc_attr( $frm_style->get_field_name('description_weight') ) ?>" id="frm_description_weight">
7
+	<select name="<?php echo esc_attr( $frm_style->get_field_name( 'description_weight' ) ) ?>" id="frm_description_weight">
8 8
 		<?php foreach ( FrmStyle::get_bold_options() as $value => $name ) { ?>
9 9
 		<option value="<?php echo esc_attr( $value ) ?>" <?php selected( $style->post_content['description_weight'], $value ) ?>><?php echo esc_html( $name ) ?></option>
10 10
 		<?php } ?>
@@ -12,25 +12,25 @@  discard block
 block discarded – undo
12 12
 </div>
13 13
 <div class="field-group clearfix frm-first-row">
14 14
 	<label><?php _e( 'Style', 'formidable' ) ?></label>
15
-	<select name="<?php echo esc_attr( $frm_style->get_field_name('description_style') ) ?>" id="frm_description_style">
16
-		<option value="normal" <?php selected($style->post_content['description_style'], 'normal') ?>><?php _e( 'normal', 'formidable' ) ?></option>
17
-		<option value="italic" <?php selected($style->post_content['description_style'], 'italic') ?>><?php _e( 'italic', 'formidable' ) ?></option>
15
+	<select name="<?php echo esc_attr( $frm_style->get_field_name( 'description_style' ) ) ?>" id="frm_description_style">
16
+		<option value="normal" <?php selected( $style->post_content['description_style'], 'normal' ) ?>><?php _e( 'normal', 'formidable' ) ?></option>
17
+		<option value="italic" <?php selected( $style->post_content['description_style'], 'italic' ) ?>><?php _e( 'italic', 'formidable' ) ?></option>
18 18
 	</select>
19 19
 </div>
20 20
 
21 21
 <div class="field-group clearfix">
22 22
 	<label><?php _e( 'Size', 'formidable' ) ?></label>
23
-	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('description_font_size') ) ?>" id="frm_description_font_size" value="<?php echo esc_attr( $style->post_content['description_font_size'] ) ?>"  size="3" />
23
+	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'description_font_size' ) ) ?>" id="frm_description_font_size" value="<?php echo esc_attr( $style->post_content['description_font_size'] ) ?>"  size="3" />
24 24
 </div>
25 25
 <div class="field-group clearfix">
26 26
 	<label><?php _e( 'Align', 'formidable' ) ?></label>
27
-	<select name="<?php echo esc_attr( $frm_style->get_field_name('description_align') ) ?>" id="frm_description_align">
28
-		<option value="left" <?php selected($style->post_content['description_align'], 'left') ?>><?php _e( 'left', 'formidable' ) ?></option>
29
-		<option value="right" <?php selected($style->post_content['description_align'], 'right') ?>><?php _e( 'right', 'formidable' ) ?></option>
27
+	<select name="<?php echo esc_attr( $frm_style->get_field_name( 'description_align' ) ) ?>" id="frm_description_align">
28
+		<option value="left" <?php selected( $style->post_content['description_align'], 'left' ) ?>><?php _e( 'left', 'formidable' ) ?></option>
29
+		<option value="right" <?php selected( $style->post_content['description_align'], 'right' ) ?>><?php _e( 'right', 'formidable' ) ?></option>
30 30
 	</select>
31 31
 </div>
32 32
 <div class="field-group clearfix">
33 33
 	<label><?php _e( 'Margin', 'formidable' ) ?></label>
34
-	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('description_margin') ) ?>" id="frm_description_margin" value="<?php echo esc_attr( $style->post_content['description_margin'] ) ?>"  size="3" />
34
+	<input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'description_margin' ) ) ?>" id="frm_description_margin" value="<?php echo esc_attr( $style->post_content['description_margin'] ) ?>"  size="3" />
35 35
 </div>
36 36
 <div class="clear"></div>
Please login to merge, or discard this patch.
classes/models/FrmDb.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -308,7 +308,7 @@
 block discarded – undo
308 308
 	 *
309 309
 	 * @since 2.02.05
310 310
 	 * @param string $key
311
-	 * @param int|string $value
311
+	 * @param string $value
312 312
 	 * @param string $where
313 313
 	 */
314 314
     private static function add_query_placeholder( $key, $value, &$where ) {
Please login to merge, or discard this patch.
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@  discard block
 block discarded – undo
7 7
     var $entry_metas;
8 8
 
9 9
     public function __construct() {
10
-        if ( ! defined('ABSPATH') ) {
11
-            die('You are not allowed to call this page directly.');
10
+        if ( ! defined( 'ABSPATH' ) ) {
11
+            die( 'You are not allowed to call this page directly.' );
12 12
         }
13 13
 
14 14
         global $wpdb;
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
         $frm_db_version = FrmAppHelper::$db_version;
25 25
         $old_db_version = (float) $old_db_version;
26 26
         if ( ! $old_db_version ) {
27
-            $old_db_version = get_option('frm_db_version');
27
+            $old_db_version = get_option( 'frm_db_version' );
28 28
         }
29 29
 
30 30
         if ( $frm_db_version != $old_db_version ) {
@@ -34,16 +34,16 @@  discard block
 block discarded – undo
34 34
 			require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
35 35
 
36 36
             $this->create_tables();
37
-            $this->migrate_data($frm_db_version, $old_db_version);
37
+            $this->migrate_data( $frm_db_version, $old_db_version );
38 38
 
39 39
             /***** SAVE DB VERSION *****/
40
-            update_option('frm_db_version', $frm_db_version);
40
+            update_option( 'frm_db_version', $frm_db_version );
41 41
 
42 42
             /**** ADD/UPDATE DEFAULT TEMPLATES ****/
43 43
             FrmXMLController::add_default_templates();
44 44
         }
45 45
 
46
-        do_action('frm_after_install');
46
+        do_action( 'frm_after_install' );
47 47
 
48 48
         /**** update the styling settings ****/
49 49
 		if ( is_admin() && function_exists( 'get_filesystem_method' ) ) {
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 				global $wpdb;
154 154
 				$wpdb->query( $q . $charset_collate );
155 155
 			}
156
-            unset($q);
156
+            unset( $q );
157 157
         }
158 158
     }
159 159
 
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 	 * @param string $starts_with
179 179
      */
180 180
     public static function get_where_clause_and_values( &$args, $starts_with = ' WHERE ' ) {
181
-        if ( empty($args) ) {
181
+        if ( empty( $args ) ) {
182 182
 			// add an arg to prevent prepare from failing
183 183
 			$args = array( 'where' => $starts_with . '1=%d', 'values' => array( 1 ) );
184 184
 			return;
@@ -238,8 +238,8 @@  discard block
 block discarded – undo
238 238
     private static function interpret_array_to_sql( $key, $value, &$where, &$values ) {
239 239
 		$key = trim( $key );
240 240
 
241
-        if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false  ) {
242
-            $k = explode(' ', $key);
241
+        if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false ) {
242
+            $k = explode( ' ', $key );
243 243
             $where .= ' DATE_FORMAT(' . reset( $k ) . ', %s) ' . str_replace( reset( $k ), '', $key );
244 244
             $values[] = '%Y-%m-%d %H:%i:%s';
245 245
         } else {
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
         if ( is_array( $value ) ) {
253 253
             // translate array of values to "in"
254 254
 			if ( strpos( $lowercase_key, 'like' ) !== false ) {
255
-				$where = preg_replace('/' . $key . '$/', '', $where);
255
+				$where = preg_replace( '/' . $key . '$/', '', $where );
256 256
 				$where .= '(';
257 257
 				$start = true;
258 258
 				foreach ( $value as $v ) {
@@ -403,8 +403,8 @@  discard block
 block discarded – undo
403 403
 		);
404 404
 
405 405
 		$where_is = strtolower( $where_is );
406
-		if ( isset( $switch_to[ $where_is ] ) ) {
407
-			return ' ' . $switch_to[ $where_is ];
406
+		if ( isset( $switch_to[$where_is] ) ) {
407
+			return ' ' . $switch_to[$where_is];
408 408
 		}
409 409
 
410 410
 		// > and < need a little more work since we don't want them switched to >= and <=
@@ -426,8 +426,8 @@  discard block
 block discarded – undo
426 426
     private static function get_group_and_table_name( &$table, &$group ) {
427 427
 		global $wpdb, $wpmuBaseTablePrefix;
428 428
 
429
-        $table_parts = explode(' ', $table);
430
-        $group = reset($table_parts);
429
+        $table_parts = explode( ' ', $table );
430
+        $group = reset( $table_parts );
431 431
         $group = str_replace( $wpdb->prefix, '', $group );
432 432
 
433 433
 		$prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix : $wpdb->base_prefix;
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
     }
443 443
 
444 444
     private static function convert_options_to_array( &$args, $order_by = '', $limit = '' ) {
445
-        if ( ! is_array($args) ) {
445
+        if ( ! is_array( $args ) ) {
446 446
 			$args = array( 'order_by' => $args );
447 447
         }
448 448
 
@@ -457,16 +457,16 @@  discard block
 block discarded – undo
457 457
         $temp_args = $args;
458 458
         foreach ( $temp_args as $k => $v ) {
459 459
             if ( $v == '' ) {
460
-				unset( $args[ $k ] );
460
+				unset( $args[$k] );
461 461
                 continue;
462 462
             }
463 463
 
464 464
             if ( $k == 'limit' ) {
465
-				$args[ $k ] = FrmAppHelper::esc_limit( $v );
465
+				$args[$k] = FrmAppHelper::esc_limit( $v );
466 466
             }
467 467
             $db_name = strtoupper( str_replace( '_', ' ', $k ) );
468 468
             if ( strpos( $v, $db_name ) === false ) {
469
-				$args[ $k ] = $db_name . ' ' . $v;
469
+				$args[$k] = $db_name . ' ' . $v;
470 470
             }
471 471
         }
472 472
 
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
 
494 494
 		$query = self::generate_query_string_from_pieces( $columns, $table, $where );
495 495
 
496
-		$cache_key = str_replace( array( ' ', ',' ), '_', trim( implode( '_', FrmAppHelper::array_flatten( $where ) ) . $columns . '_results_ARRAY_A' , ' WHERE' ) );
496
+		$cache_key = str_replace( array( ' ', ',' ), '_', trim( implode( '_', FrmAppHelper::array_flatten( $where ) ) . $columns . '_results_ARRAY_A', ' WHERE' ) );
497 497
 		$results = FrmAppHelper::check_cache( $cache_key, $group, $query, 'get_associative_results' );
498 498
 
499 499
 		return $results;
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
     public function uninstall() {
533 533
 		if ( ! current_user_can( 'administrator' ) ) {
534 534
             $frm_settings = FrmAppHelper::get_settings();
535
-            wp_die($frm_settings->admin_permission);
535
+            wp_die( $frm_settings->admin_permission );
536 536
         }
537 537
 
538 538
         global $wpdb, $wp_roles;
@@ -542,8 +542,8 @@  discard block
 block discarded – undo
542 542
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entries );
543 543
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entry_metas );
544 544
 
545
-        delete_option('frm_options');
546
-        delete_option('frm_db_version');
545
+        delete_option( 'frm_options' );
546
+        delete_option( 'frm_db_version' );
547 547
 
548 548
         //delete roles
549 549
         $frm_roles = FrmAppHelper::frm_capabilities();
@@ -551,11 +551,11 @@  discard block
 block discarded – undo
551 551
         foreach ( $frm_roles as $frm_role => $frm_role_description ) {
552 552
             foreach ( $roles as $role => $details ) {
553 553
                 $wp_roles->remove_cap( $role, $frm_role );
554
-                unset($role, $details);
554
+                unset( $role, $details );
555 555
     		}
556
-    		unset($frm_role, $frm_role_description);
556
+    		unset( $frm_role, $frm_role_description );
557 557
 		}
558
-		unset($roles, $frm_roles);
558
+		unset( $roles, $frm_roles );
559 559
 
560 560
 		// delete actions, views, and styles
561 561
 
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
 
578 578
 		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_%', '_transient_frm_form_fields_%' ) );
579 579
 
580
-        do_action('frm_after_uninstall');
580
+        do_action( 'frm_after_uninstall' );
581 581
         return true;
582 582
     }
583 583
 
@@ -634,8 +634,8 @@  discard block
 block discarded – undo
634 634
 
635 635
         $updated = 0;
636 636
         foreach ( $fields as $f ) {
637
-            $f->field_options = maybe_unserialize($f->field_options);
638
-            if ( empty($f->field_options['size']) || ! is_numeric($f->field_options['size']) ) {
637
+            $f->field_options = maybe_unserialize( $f->field_options );
638
+            if ( empty( $f->field_options['size'] ) || ! is_numeric( $f->field_options['size'] ) ) {
639 639
                 continue;
640 640
             }
641 641
 
@@ -643,27 +643,27 @@  discard block
 block discarded – undo
643 643
             $f->field_options['size'] .= 'px';
644 644
             $u = FrmField::update( $f->id, array( 'field_options' => $f->field_options ) );
645 645
             if ( $u ) {
646
-                $updated++;
646
+                $updated ++;
647 647
             }
648
-            unset($f);
648
+            unset( $f );
649 649
         }
650 650
 
651 651
         // Change the characters in widgets to pixels
652
-        $widgets = get_option('widget_frm_show_form');
653
-        if ( empty($widgets) ) {
652
+        $widgets = get_option( 'widget_frm_show_form' );
653
+        if ( empty( $widgets ) ) {
654 654
             return;
655 655
         }
656 656
 
657
-        $widgets = maybe_unserialize($widgets);
657
+        $widgets = maybe_unserialize( $widgets );
658 658
         foreach ( $widgets as $k => $widget ) {
659
-            if ( ! is_array($widget) || ! isset($widget['size']) ) {
659
+            if ( ! is_array( $widget ) || ! isset( $widget['size'] ) ) {
660 660
                 continue;
661 661
             }
662 662
 			$size = round( $pixel_conversion * (int) $widget['size'] );
663 663
             $size .= 'px';
664
-			$widgets[ $k ]['size'] = $size;
664
+			$widgets[$k]['size'] = $size;
665 665
         }
666
-        update_option('widget_frm_show_form', $widgets);
666
+        update_option( 'widget_frm_show_form', $widgets );
667 667
     }
668 668
 
669 669
     /**
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
 			}
713 713
 
714 714
             // Format form options
715
-            $form_options = maybe_unserialize($form->options);
715
+            $form_options = maybe_unserialize( $form->options );
716 716
 
717 717
             // Migrate settings to actions
718 718
             FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id );
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
     private function migrate_to_11() {
723 723
         global $wpdb;
724 724
 
725
-        $forms = FrmDb::get_results( $this->forms, array(), 'id, options');
725
+        $forms = FrmDb::get_results( $this->forms, array(), 'id, options' );
726 726
 
727 727
         $sending = __( 'Sending', 'formidable' );
728 728
 		$img = FrmAppHelper::plugin_url() . '/images/ajax_loader.gif';
@@ -733,13 +733,13 @@  discard block
 block discarded – undo
733 733
 <img class="frm_ajax_loading" src="$img" alt="$sending" style="visibility:hidden;" />
734 734
 </div>
735 735
 DEFAULT_HTML;
736
-        unset($sending, $img);
736
+        unset( $sending, $img );
737 737
 
738
-        $new_default_html = FrmFormsHelper::get_default_html('submit');
738
+        $new_default_html = FrmFormsHelper::get_default_html( 'submit' );
739 739
         $draft_link = FrmFormsHelper::get_draft_link();
740 740
 		foreach ( $forms as $form ) {
741
-            $form->options = maybe_unserialize($form->options);
742
-            if ( ! isset($form->options['submit_html']) || empty($form->options['submit_html']) ) {
741
+            $form->options = maybe_unserialize( $form->options );
742
+            if ( ! isset( $form->options['submit_html'] ) || empty( $form->options['submit_html'] ) ) {
743 743
                 continue;
744 744
             }
745 745
 
@@ -750,9 +750,9 @@  discard block
 block discarded – undo
750 750
 				$form->options['submit_html'] = preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $draft_link . "\r\n</div>", $form->options['submit_html'] );
751 751
 				$wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) );
752 752
             }
753
-            unset($form);
753
+            unset( $form );
754 754
         }
755
-        unset($forms);
755
+        unset( $forms );
756 756
     }
757 757
 
758 758
     private function migrate_to_6() {
@@ -781,16 +781,16 @@  discard block
 block discarded – undo
781 781
 </div>
782 782
 DEFAULT_HTML;
783 783
 
784
-        $new_default_html = FrmFieldsHelper::get_default_html('text');
784
+        $new_default_html = FrmFieldsHelper::get_default_html( 'text' );
785 785
         foreach ( $fields as $field ) {
786
-            $field->field_options = maybe_unserialize($field->field_options);
786
+            $field->field_options = maybe_unserialize( $field->field_options );
787 787
 			if ( ! FrmField::is_option_empty( $field, 'custom_html' ) || $field->field_options['custom_html'] == $default_html || $field->field_options['custom_html'] == $old_default_html ) {
788 788
                 $field->field_options['custom_html'] = $new_default_html;
789 789
 				$wpdb->update( $this->fields, array( 'field_options' => maybe_serialize( $field->field_options ) ), array( 'id' => $field->id ) );
790 790
             }
791
-            unset($field);
791
+            unset( $field );
792 792
         }
793
-        unset($default_html, $old_default_html, $fields);
793
+        unset( $default_html, $old_default_html, $fields );
794 794
     }
795 795
 
796 796
     private function migrate_to_4() {
@@ -808,6 +808,6 @@  discard block
 block discarded – undo
808 808
 
809 809
 	public static function get_records( $table, $args = array(), $order_by = '', $limit = '', $fields = '*' ) {
810 810
 		_deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_results' );
811
-		return self::get_results( $table, $args, $fields, compact('order_by', 'limit') );
811
+		return self::get_results( $table, $args, $fields, compact( 'order_by', 'limit' ) );
812 812
 	}
813 813
 }
Please login to merge, or discard this patch.
Indentation   +340 added lines, -340 removed lines patch added patch discarded remove patch
@@ -1,66 +1,66 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class FrmDb {
4
-    var $fields;
5
-    var $forms;
6
-    var $entries;
7
-    var $entry_metas;
8
-
9
-    public function __construct() {
10
-        if ( ! defined('ABSPATH') ) {
11
-            die('You are not allowed to call this page directly.');
12
-        }
13
-
14
-        global $wpdb;
15
-        $this->fields         = $wpdb->prefix . 'frm_fields';
16
-        $this->forms          = $wpdb->prefix . 'frm_forms';
17
-        $this->entries        = $wpdb->prefix . 'frm_items';
18
-        $this->entry_metas    = $wpdb->prefix . 'frm_item_metas';
19
-    }
20
-
21
-    public function upgrade( $old_db_version = false ) {
22
-	    do_action( 'frm_before_install' );
23
-
24
-        global $wpdb;
25
-        //$frm_db_version is the version of the database we're moving to
26
-        $frm_db_version = FrmAppHelper::$db_version;
27
-        $old_db_version = (float) $old_db_version;
28
-        if ( ! $old_db_version ) {
29
-            $old_db_version = get_option('frm_db_version');
30
-        }
31
-
32
-        if ( $frm_db_version != $old_db_version ) {
4
+	var $fields;
5
+	var $forms;
6
+	var $entries;
7
+	var $entry_metas;
8
+
9
+	public function __construct() {
10
+		if ( ! defined('ABSPATH') ) {
11
+			die('You are not allowed to call this page directly.');
12
+		}
13
+
14
+		global $wpdb;
15
+		$this->fields         = $wpdb->prefix . 'frm_fields';
16
+		$this->forms          = $wpdb->prefix . 'frm_forms';
17
+		$this->entries        = $wpdb->prefix . 'frm_items';
18
+		$this->entry_metas    = $wpdb->prefix . 'frm_item_metas';
19
+	}
20
+
21
+	public function upgrade( $old_db_version = false ) {
22
+		do_action( 'frm_before_install' );
23
+
24
+		global $wpdb;
25
+		//$frm_db_version is the version of the database we're moving to
26
+		$frm_db_version = FrmAppHelper::$db_version;
27
+		$old_db_version = (float) $old_db_version;
28
+		if ( ! $old_db_version ) {
29
+			$old_db_version = get_option('frm_db_version');
30
+		}
31
+
32
+		if ( $frm_db_version != $old_db_version ) {
33 33
 			// update rewrite rules for views and other custom post types
34 34
 			flush_rewrite_rules();
35 35
 
36 36
 			require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
37 37
 
38
-            $this->create_tables();
39
-            $this->migrate_data($frm_db_version, $old_db_version);
38
+			$this->create_tables();
39
+			$this->migrate_data($frm_db_version, $old_db_version);
40 40
 
41
-            /***** SAVE DB VERSION *****/
42
-            update_option('frm_db_version', $frm_db_version);
41
+			/***** SAVE DB VERSION *****/
42
+			update_option('frm_db_version', $frm_db_version);
43 43
 
44
-            /**** ADD/UPDATE DEFAULT TEMPLATES ****/
45
-            FrmXMLController::add_default_templates();
46
-        }
44
+			/**** ADD/UPDATE DEFAULT TEMPLATES ****/
45
+			FrmXMLController::add_default_templates();
46
+		}
47 47
 
48
-        do_action('frm_after_install');
48
+		do_action('frm_after_install');
49 49
 
50
-        /**** update the styling settings ****/
50
+		/**** update the styling settings ****/
51 51
 		if ( is_admin() && function_exists( 'get_filesystem_method' ) ) {
52 52
 			$frm_style = new FrmStyle();
53 53
 			$frm_style->update( 'default' );
54 54
 		}
55
-    }
55
+	}
56 56
 
57
-    public function collation() {
58
-        global $wpdb;
59
-        if ( ! $wpdb->has_cap( 'collation' ) ) {
60
-            return '';
61
-        }
57
+	public function collation() {
58
+		global $wpdb;
59
+		if ( ! $wpdb->has_cap( 'collation' ) ) {
60
+			return '';
61
+		}
62 62
 
63
-        $charset_collate = '';
63
+		$charset_collate = '';
64 64
 		if ( ! empty( $wpdb->charset ) ) {
65 65
 			$charset_collate .= ' DEFAULT CHARACTER SET ' . $wpdb->charset;
66 66
 		}
@@ -69,14 +69,14 @@  discard block
 block discarded – undo
69 69
 			$charset_collate .= ' COLLATE ' . $wpdb->collate;
70 70
 		}
71 71
 
72
-        return $charset_collate;
73
-    }
72
+		return $charset_collate;
73
+	}
74 74
 
75
-    private function create_tables() {
76
-        $charset_collate = $this->collation();
77
-        $sql = array();
75
+	private function create_tables() {
76
+		$charset_collate = $this->collation();
77
+		$sql = array();
78 78
 
79
-        /* Create/Upgrade Fields Table */
79
+		/* Create/Upgrade Fields Table */
80 80
 		$sql[] = 'CREATE TABLE ' . $this->fields . ' (
81 81
                 id int(11) NOT NULL auto_increment,
82 82
 				field_key varchar(100) default NULL,
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
                 UNIQUE KEY field_key (field_key)
96 96
         )';
97 97
 
98
-        /* Create/Upgrade Forms Table */
98
+		/* Create/Upgrade Forms Table */
99 99
 		$sql[] = 'CREATE TABLE ' . $this->forms . ' (
100 100
                 id int(11) NOT NULL auto_increment,
101 101
 				form_key varchar(100) default NULL,
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
                 UNIQUE KEY form_key (form_key)
114 114
         )';
115 115
 
116
-        /* Create/Upgrade Items Table */
116
+		/* Create/Upgrade Items Table */
117 117
 		$sql[] = 'CREATE TABLE ' . $this->entries . ' (
118 118
                 id int(11) NOT NULL auto_increment,
119 119
 				item_key varchar(100) default NULL,
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
                 UNIQUE KEY item_key (item_key)
137 137
         )';
138 138
 
139
-        /* Create/Upgrade Meta Table */
139
+		/* Create/Upgrade Meta Table */
140 140
 		$sql[] = 'CREATE TABLE ' . $this->entry_metas . ' (
141 141
                 id int(11) NOT NULL auto_increment,
142 142
                 meta_value longtext default NULL,
@@ -148,43 +148,43 @@  discard block
 block discarded – undo
148 148
                 KEY item_id (item_id)
149 149
         )';
150 150
 
151
-        foreach ( $sql as $q ) {
151
+		foreach ( $sql as $q ) {
152 152
 			if ( function_exists( 'dbDelta' ) ) {
153 153
 				dbDelta( $q . $charset_collate . ';' );
154 154
 			} else {
155 155
 				global $wpdb;
156 156
 				$wpdb->query( $q . $charset_collate );
157 157
 			}
158
-            unset($q);
159
-        }
160
-    }
158
+			unset($q);
159
+		}
160
+	}
161 161
 
162
-    /**
163
-     * @param integer $frm_db_version
162
+	/**
163
+	 * @param integer $frm_db_version
164 164
 	 * @param int $old_db_version
165
-     */
165
+	 */
166 166
 	private function migrate_data( $frm_db_version, $old_db_version ) {
167 167
 		$migrations = array( 4, 6, 11, 16, 17, 23, 25 );
168
-        foreach ( $migrations as $migration ) {
169
-            if ( $frm_db_version >= $migration && $old_db_version < $migration ) {
168
+		foreach ( $migrations as $migration ) {
169
+			if ( $frm_db_version >= $migration && $old_db_version < $migration ) {
170 170
 				$function_name = 'migrate_to_' . $migration;
171
-                $this->$function_name();
172
-            }
173
-        }
174
-    }
171
+				$this->$function_name();
172
+			}
173
+		}
174
+	}
175 175
 
176
-    /**
177
-     * Change array into format $wpdb->prepare can use
176
+	/**
177
+	 * Change array into format $wpdb->prepare can use
178 178
 	 *
179 179
 	 * @param array $args
180 180
 	 * @param string $starts_with
181
-     */
182
-    public static function get_where_clause_and_values( &$args, $starts_with = ' WHERE ' ) {
183
-        if ( empty($args) ) {
181
+	 */
182
+	public static function get_where_clause_and_values( &$args, $starts_with = ' WHERE ' ) {
183
+		if ( empty($args) ) {
184 184
 			// add an arg to prevent prepare from failing
185 185
 			$args = array( 'where' => $starts_with . '1=%d', 'values' => array( 1 ) );
186 186
 			return;
187
-        }
187
+		}
188 188
 
189 189
 		$where = '';
190 190
 		$values = array();
@@ -195,64 +195,64 @@  discard block
 block discarded – undo
195 195
 		}
196 196
 
197 197
 		$args = compact( 'where', 'values' );
198
-    }
198
+	}
199 199
 
200
-    /**
200
+	/**
201 201
 	 * @param array $args
202
-     * @param string $base_where
203
-     * @param string $where
202
+	 * @param string $base_where
203
+	 * @param string $where
204 204
 	 * @param array $values
205
-     */
206
-    public static function parse_where_from_array( $args, $base_where, &$where, &$values ) {
207
-        $condition = ' AND';
208
-        if ( isset( $args['or'] ) ) {
209
-            $condition = ' OR';
210
-            unset( $args['or'] );
211
-        }
212
-
213
-        foreach ( $args as $key => $value ) {
214
-            $where .= empty( $where ) ? $base_where : $condition;
215
-            $array_inc_null = ( ! is_numeric( $key ) && is_array( $value ) && in_array( null, $value ) );
216
-            if ( is_numeric( $key ) || $array_inc_null ) {
217
-                $where .= ' ( ';
218
-                $nested_where = '';
219
-                if ( $array_inc_null ) {
220
-                    foreach ( $value as $val ) {
221
-                        self::parse_where_from_array( array( $key => $val, 'or' => 1 ), '', $nested_where, $values );
222
-                    }
223
-                } else {
224
-                    self::parse_where_from_array( $value, '', $nested_where, $values );
225
-                }
226
-                $where .= $nested_where;
227
-                $where .= ' ) ';
228
-            } else {
229
-                self::interpret_array_to_sql( $key, $value, $where, $values );
230
-            }
231
-        }
232
-    }
233
-
234
-    /**
235
-     * @param string $key
205
+	 */
206
+	public static function parse_where_from_array( $args, $base_where, &$where, &$values ) {
207
+		$condition = ' AND';
208
+		if ( isset( $args['or'] ) ) {
209
+			$condition = ' OR';
210
+			unset( $args['or'] );
211
+		}
212
+
213
+		foreach ( $args as $key => $value ) {
214
+			$where .= empty( $where ) ? $base_where : $condition;
215
+			$array_inc_null = ( ! is_numeric( $key ) && is_array( $value ) && in_array( null, $value ) );
216
+			if ( is_numeric( $key ) || $array_inc_null ) {
217
+				$where .= ' ( ';
218
+				$nested_where = '';
219
+				if ( $array_inc_null ) {
220
+					foreach ( $value as $val ) {
221
+						self::parse_where_from_array( array( $key => $val, 'or' => 1 ), '', $nested_where, $values );
222
+					}
223
+				} else {
224
+					self::parse_where_from_array( $value, '', $nested_where, $values );
225
+				}
226
+				$where .= $nested_where;
227
+				$where .= ' ) ';
228
+			} else {
229
+				self::interpret_array_to_sql( $key, $value, $where, $values );
230
+			}
231
+		}
232
+	}
233
+
234
+	/**
235
+	 * @param string $key
236 236
 	 * @param string|array $value
237
-     * @param string $where
237
+	 * @param string $where
238 238
 	 * @param array $values
239
-     */
240
-    private static function interpret_array_to_sql( $key, $value, &$where, &$values ) {
239
+	 */
240
+	private static function interpret_array_to_sql( $key, $value, &$where, &$values ) {
241 241
 		$key = trim( $key );
242 242
 
243
-        if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false  ) {
244
-            $k = explode(' ', $key);
245
-            $where .= ' DATE_FORMAT(' . reset( $k ) . ', %s) ' . str_replace( reset( $k ), '', $key );
246
-            $values[] = '%Y-%m-%d %H:%i:%s';
247
-        } else {
243
+		if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false  ) {
244
+			$k = explode(' ', $key);
245
+			$where .= ' DATE_FORMAT(' . reset( $k ) . ', %s) ' . str_replace( reset( $k ), '', $key );
246
+			$values[] = '%Y-%m-%d %H:%i:%s';
247
+		} else {
248 248
 			$where .= ' ' . $key;
249
-        }
249
+		}
250 250
 
251 251
 		$lowercase_key = explode( ' ', strtolower( $key ) );
252 252
 		$lowercase_key = end( $lowercase_key );
253 253
 
254
-        if ( is_array( $value ) ) {
255
-            // translate array of values to "in"
254
+		if ( is_array( $value ) ) {
255
+			// translate array of values to "in"
256 256
 			if ( strpos( $lowercase_key, 'like' ) !== false ) {
257 257
 				$where = preg_replace('/' . $key . '$/', '', $where);
258 258
 				$where .= '(';
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 				$where .= ' in (' . FrmAppHelper::prepare_array_values( $value, '%s' ) . ')';
271 271
 				$values = array_merge( $values, $value );
272 272
 			}
273
-        } else if ( strpos( $lowercase_key, 'like' ) !== false ) {
273
+		} else if ( strpos( $lowercase_key, 'like' ) !== false ) {
274 274
 			/**
275 275
 			 * Allow string to start or end with the value
276 276
 			 * If the key is like% then skip the first % for starts with
@@ -289,9 +289,9 @@  discard block
 block discarded – undo
289 289
 			$where .= ' %s';
290 290
 			$values[] = $start . FrmAppHelper::esc_like( $value ) . $end;
291 291
 
292
-        } else if ( $value === null ) {
293
-            $where .= ' IS NULL';
294
-        } else {
292
+		} else if ( $value === null ) {
293
+			$where .= ' IS NULL';
294
+		} else {
295 295
 			// allow a - to prevent = from being added
296 296
 			if ( substr( $key, -1 ) == '-' ) {
297 297
 				$where = rtrim( $where, '-' );
@@ -301,9 +301,9 @@  discard block
 block discarded – undo
301 301
 
302 302
 			self::add_query_placeholder( $key, $value, $where );
303 303
 
304
-            $values[] = $value;
305
-        }
306
-    }
304
+			$values[] = $value;
305
+		}
306
+	}
307 307
 
308 308
 	/**
309 309
 	 * Add %d, or %s to query
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 	 * @param int|string $value
314 314
 	 * @param string $where
315 315
 	 */
316
-    private static function add_query_placeholder( $key, $value, &$where ) {
316
+	private static function add_query_placeholder( $key, $value, &$where ) {
317 317
 		if ( is_numeric( $value ) && strpos( $key, 'meta_value' ) === false ) {
318 318
 			$where .= '%d';
319 319
 		} else {
@@ -321,16 +321,16 @@  discard block
 block discarded – undo
321 321
 		}
322 322
 	}
323 323
 
324
-    /**
325
-     * @param string $table
324
+	/**
325
+	 * @param string $table
326 326
 	 * @param array $where
327 327
 	 * @param array $args
328 328
 	 * @return int
329
-     */
330
-    public static function get_count( $table, $where = array(), $args = array() ) {
331
-        $count = self::get_var( $table, $where, 'COUNT(*)', $args );
332
-        return $count;
333
-    }
329
+	 */
330
+	public static function get_count( $table, $where = array(), $args = array() ) {
331
+		$count = self::get_var( $table, $where, 'COUNT(*)', $args );
332
+		return $count;
333
+	}
334 334
 
335 335
 	/**
336 336
 	 * @param string $table
@@ -341,56 +341,56 @@  discard block
 block discarded – undo
341 341
 	 * @param string $type
342 342
 	 * @return array|null|string|object
343 343
 	 */
344
-    public static function get_var( $table, $where = array(), $field = 'id', $args = array(), $limit = '', $type = 'var' ) {
345
-        $group = '';
346
-        self::get_group_and_table_name( $table, $group );
344
+	public static function get_var( $table, $where = array(), $field = 'id', $args = array(), $limit = '', $type = 'var' ) {
345
+		$group = '';
346
+		self::get_group_and_table_name( $table, $group );
347 347
 		self::convert_options_to_array( $args, '', $limit );
348 348
 
349 349
 		$query = self::generate_query_string_from_pieces( $field, $table, $where, $args );
350 350
 
351 351
 		$cache_key = str_replace( array( ' ', ',' ), '_', trim( implode( '_', FrmAppHelper::array_flatten( $where ) ) . implode( '_', $args ) . $field . '_' . $type, ' WHERE' ) );
352 352
 		$results = FrmAppHelper::check_cache( $cache_key, $group, $query, 'get_' . $type );
353
-        return $results;
354
-    }
353
+		return $results;
354
+	}
355 355
 
356
-    /**
357
-     * @param string $table
358
-     * @param array $where
356
+	/**
357
+	 * @param string $table
358
+	 * @param array $where
359 359
 	 * @param string $field
360 360
 	 * @param array $args
361 361
 	 * @param string $limit
362 362
 	 * @return mixed
363
-     */
364
-    public static function get_col( $table, $where = array(), $field = 'id', $args = array(), $limit = '' ) {
365
-        return self::get_var( $table, $where, $field, $args, $limit, 'col' );
366
-    }
367
-
368
-    /**
369
-     * @since 2.0
370
-     * @param string $table
363
+	 */
364
+	public static function get_col( $table, $where = array(), $field = 'id', $args = array(), $limit = '' ) {
365
+		return self::get_var( $table, $where, $field, $args, $limit, 'col' );
366
+	}
367
+
368
+	/**
369
+	 * @since 2.0
370
+	 * @param string $table
371 371
 	 * @param array $where
372 372
 	 * @param string $fields
373 373
 	 * @param array $args
374 374
 	 * @return mixed
375
-     */
376
-    public static function get_row( $table, $where = array(), $fields = '*', $args = array() ) {
377
-        $args['limit'] = 1;
378
-        return self::get_var( $table, $where, $fields, $args, '', 'row' );
379
-    }
380
-
381
-    /**
382
-     * Prepare a key/value array before DB call
375
+	 */
376
+	public static function get_row( $table, $where = array(), $fields = '*', $args = array() ) {
377
+		$args['limit'] = 1;
378
+		return self::get_var( $table, $where, $fields, $args, '', 'row' );
379
+	}
380
+
381
+	/**
382
+	 * Prepare a key/value array before DB call
383 383
 	 *
384
-     * @since 2.0
385
-     * @param string $table
384
+	 * @since 2.0
385
+	 * @param string $table
386 386
 	 * @param array $where
387 387
 	 * @param string $fields
388 388
 	 * @param array $args
389 389
 	 * @return mixed
390
-     */
391
-    public static function get_results( $table, $where = array(), $fields = '*', $args = array() ) {
392
-        return self::get_var( $table, $where, $fields, $args, '', 'results' );
393
-    }
390
+	 */
391
+	public static function get_results( $table, $where = array(), $fields = '*', $args = array() ) {
392
+		return self::get_var( $table, $where, $fields, $args, '', 'results' );
393
+	}
394 394
 
395 395
 	/**
396 396
 	 * Check for like, not like, in, not in, =, !=, >, <, <=, >=
@@ -427,59 +427,59 @@  discard block
 block discarded – undo
427 427
 		return '';
428 428
 	}
429 429
 
430
-    /**
431
-     * Get 'frm_forms' from wp_frm_forms or a longer table param that includes a join
432
-     * Also add the wpdb->prefix to the table if it's missing
433
-     *
434
-     * @param string $table
435
-     * @param string $group
436
-     */
437
-    private static function get_group_and_table_name( &$table, &$group ) {
430
+	/**
431
+	 * Get 'frm_forms' from wp_frm_forms or a longer table param that includes a join
432
+	 * Also add the wpdb->prefix to the table if it's missing
433
+	 *
434
+	 * @param string $table
435
+	 * @param string $group
436
+	 */
437
+	private static function get_group_and_table_name( &$table, &$group ) {
438 438
 		global $wpdb, $wpmuBaseTablePrefix;
439 439
 
440
-        $table_parts = explode(' ', $table);
441
-        $group = reset($table_parts);
442
-        $group = str_replace( $wpdb->prefix, '', $group );
440
+		$table_parts = explode(' ', $table);
441
+		$group = reset($table_parts);
442
+		$group = str_replace( $wpdb->prefix, '', $group );
443 443
 
444 444
 		$prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix : $wpdb->base_prefix;
445 445
 		$group = str_replace( $prefix, '', $group );
446 446
 
447
-        if ( $group == $table ) {
448
-            $table = $wpdb->prefix . $table;
449
-        }
447
+		if ( $group == $table ) {
448
+			$table = $wpdb->prefix . $table;
449
+		}
450 450
 
451 451
 		// switch to singular group name
452 452
 		$group = rtrim( $group, 's' );
453
-    }
453
+	}
454 454
 
455
-    private static function convert_options_to_array( &$args, $order_by = '', $limit = '' ) {
456
-        if ( ! is_array($args) ) {
455
+	private static function convert_options_to_array( &$args, $order_by = '', $limit = '' ) {
456
+		if ( ! is_array($args) ) {
457 457
 			$args = array( 'order_by' => $args );
458
-        }
458
+		}
459 459
 
460
-        if ( ! empty( $order_by ) ) {
461
-            $args['order_by'] = $order_by;
462
-        }
460
+		if ( ! empty( $order_by ) ) {
461
+			$args['order_by'] = $order_by;
462
+		}
463 463
 
464
-        if ( ! empty( $limit ) ) {
465
-            $args['limit'] = $limit;
466
-        }
464
+		if ( ! empty( $limit ) ) {
465
+			$args['limit'] = $limit;
466
+		}
467 467
 
468
-        $temp_args = $args;
469
-        foreach ( $temp_args as $k => $v ) {
470
-            if ( $v == '' ) {
468
+		$temp_args = $args;
469
+		foreach ( $temp_args as $k => $v ) {
470
+			if ( $v == '' ) {
471 471
 				unset( $args[ $k ] );
472
-                continue;
473
-            }
472
+				continue;
473
+			}
474 474
 
475
-            if ( $k == 'limit' ) {
475
+			if ( $k == 'limit' ) {
476 476
 				$args[ $k ] = FrmAppHelper::esc_limit( $v );
477
-            }
478
-            $db_name = strtoupper( str_replace( '_', ' ', $k ) );
479
-            if ( strpos( $v, $db_name ) === false ) {
477
+			}
478
+			$db_name = strtoupper( str_replace( '_', ' ', $k ) );
479
+			if ( strpos( $v, $db_name ) === false ) {
480 480
 				$args[ $k ] = $db_name . ' ' . $v;
481
-            }
482
-        }
481
+			}
482
+		}
483 483
 
484 484
 		// Make sure LIMIT is the last argument
485 485
 		if ( isset( $args['order_by'] ) && isset( $args['limit'] ) ) {
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
 			unset( $args['limit'] );
488 488
 			$args['limit'] = $temp_limit;
489 489
 		}
490
-    }
490
+	}
491 491
 
492 492
 	/**
493 493
 	 * Get the associative array results for the given columns, table, and where query
@@ -540,31 +540,31 @@  discard block
 block discarded – undo
540 540
 		return $query;
541 541
 	}
542 542
 
543
-    public function uninstall() {
543
+	public function uninstall() {
544 544
 		if ( ! current_user_can( 'administrator' ) ) {
545
-            $frm_settings = FrmAppHelper::get_settings();
546
-            wp_die($frm_settings->admin_permission);
547
-        }
545
+			$frm_settings = FrmAppHelper::get_settings();
546
+			wp_die($frm_settings->admin_permission);
547
+		}
548 548
 
549
-        global $wpdb, $wp_roles;
549
+		global $wpdb, $wp_roles;
550 550
 
551 551
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->fields );
552 552
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->forms );
553 553
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entries );
554 554
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entry_metas );
555 555
 
556
-        delete_option('frm_options');
557
-        delete_option('frm_db_version');
556
+		delete_option('frm_options');
557
+		delete_option('frm_db_version');
558 558
 
559
-        //delete roles
560
-        $frm_roles = FrmAppHelper::frm_capabilities();
561
-        $roles = get_editable_roles();
562
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
563
-            foreach ( $roles as $role => $details ) {
564
-                $wp_roles->remove_cap( $role, $frm_role );
565
-                unset($role, $details);
566
-    		}
567
-    		unset($frm_role, $frm_role_description);
559
+		//delete roles
560
+		$frm_roles = FrmAppHelper::frm_capabilities();
561
+		$roles = get_editable_roles();
562
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
563
+			foreach ( $roles as $role => $details ) {
564
+				$wp_roles->remove_cap( $role, $frm_role );
565
+				unset($role, $details);
566
+			}
567
+			unset($frm_role, $frm_role_description);
568 568
 		}
569 569
 		unset($roles, $frm_roles);
570 570
 
@@ -588,9 +588,9 @@  discard block
 block discarded – undo
588 588
 
589 589
 		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_%', '_transient_frm_form_fields_%' ) );
590 590
 
591
-        do_action('frm_after_uninstall');
592
-        return true;
593
-    }
591
+		do_action('frm_after_uninstall');
592
+		return true;
593
+	}
594 594
 
595 595
 	/**
596 596
 	 * Migrate old styling settings. If sites are using the old
@@ -629,150 +629,150 @@  discard block
 block discarded – undo
629 629
 		}
630 630
 	}
631 631
 
632
-    /**
633
-     * Change field size from character to pixel -- Multiply by 9
634
-     */
635
-    private function migrate_to_17() {
636
-        global $wpdb;
632
+	/**
633
+	 * Change field size from character to pixel -- Multiply by 9
634
+	 */
635
+	private function migrate_to_17() {
636
+		global $wpdb;
637 637
 		$pixel_conversion = 9;
638 638
 
639
-        // Get query arguments
639
+		// Get query arguments
640 640
 		$field_types = array( 'textarea', 'text', 'number', 'email', 'url', 'rte', 'date', 'phone', 'password', 'image', 'tag', 'file' );
641 641
 		$query = array( 'type' => $field_types, 'field_options like' => 's:4:"size";', 'field_options not like' => 's:4:"size";s:0:' );
642 642
 
643
-        // Get results
643
+		// Get results
644 644
 		$fields = FrmDb::get_results( $this->fields, $query, 'id, field_options' );
645 645
 
646
-        $updated = 0;
647
-        foreach ( $fields as $f ) {
648
-            $f->field_options = maybe_unserialize($f->field_options);
649
-            if ( empty($f->field_options['size']) || ! is_numeric($f->field_options['size']) ) {
650
-                continue;
651
-            }
646
+		$updated = 0;
647
+		foreach ( $fields as $f ) {
648
+			$f->field_options = maybe_unserialize($f->field_options);
649
+			if ( empty($f->field_options['size']) || ! is_numeric($f->field_options['size']) ) {
650
+				continue;
651
+			}
652 652
 
653 653
 			$f->field_options['size'] = round( $pixel_conversion * (int) $f->field_options['size'] );
654
-            $f->field_options['size'] .= 'px';
655
-            $u = FrmField::update( $f->id, array( 'field_options' => $f->field_options ) );
656
-            if ( $u ) {
657
-                $updated++;
658
-            }
659
-            unset($f);
660
-        }
661
-
662
-        // Change the characters in widgets to pixels
663
-        $widgets = get_option('widget_frm_show_form');
664
-        if ( empty($widgets) ) {
665
-            return;
666
-        }
667
-
668
-        $widgets = maybe_unserialize($widgets);
669
-        foreach ( $widgets as $k => $widget ) {
670
-            if ( ! is_array($widget) || ! isset($widget['size']) ) {
671
-                continue;
672
-            }
654
+			$f->field_options['size'] .= 'px';
655
+			$u = FrmField::update( $f->id, array( 'field_options' => $f->field_options ) );
656
+			if ( $u ) {
657
+				$updated++;
658
+			}
659
+			unset($f);
660
+		}
661
+
662
+		// Change the characters in widgets to pixels
663
+		$widgets = get_option('widget_frm_show_form');
664
+		if ( empty($widgets) ) {
665
+			return;
666
+		}
667
+
668
+		$widgets = maybe_unserialize($widgets);
669
+		foreach ( $widgets as $k => $widget ) {
670
+			if ( ! is_array($widget) || ! isset($widget['size']) ) {
671
+				continue;
672
+			}
673 673
 			$size = round( $pixel_conversion * (int) $widget['size'] );
674
-            $size .= 'px';
674
+			$size .= 'px';
675 675
 			$widgets[ $k ]['size'] = $size;
676
-        }
677
-        update_option('widget_frm_show_form', $widgets);
678
-    }
679
-
680
-    /**
681
-     * Migrate post and email notification settings into actions
682
-     */
683
-    private function migrate_to_16() {
684
-        global $wpdb;
685
-
686
-        $forms = FrmDb::get_results( $this->forms, array(), 'id, options, is_template, default_template' );
687
-
688
-        /**
689
-        * Old email settings format:
690
-        * email_to: Email or field id
691
-        * also_email_to: array of fields ids
692
-        * reply_to: Email, field id, 'custom'
693
-        * cust_reply_to: string
694
-        * reply_to_name: field id, 'custom'
695
-        * cust_reply_to_name: string
696
-        * plain_text: 0|1
697
-        * email_message: string or ''
698
-        * email_subject: string or ''
699
-        * inc_user_info: 0|1
700
-        * update_email: 0, 1, 2
701
-        *
702
-        * Old autoresponder settings format:
703
-        * auto_responder: 0|1
704
-        * ar_email_message: string or ''
705
-        * ar_email_to: field id
706
-        * ar_plain_text: 0|1
707
-        * ar_reply_to_name: string
708
-        * ar_reply_to: string
709
-        * ar_email_subject: string
710
-        * ar_update_email: 0, 1, 2
711
-        *
712
-        * New email settings:
713
-        * post_content: json settings
714
-        * post_title: form id
715
-        * post_excerpt: message
716
-        *
717
-        */
718
-
719
-        foreach ( $forms as $form ) {
676
+		}
677
+		update_option('widget_frm_show_form', $widgets);
678
+	}
679
+
680
+	/**
681
+	 * Migrate post and email notification settings into actions
682
+	 */
683
+	private function migrate_to_16() {
684
+		global $wpdb;
685
+
686
+		$forms = FrmDb::get_results( $this->forms, array(), 'id, options, is_template, default_template' );
687
+
688
+		/**
689
+		 * Old email settings format:
690
+		 * email_to: Email or field id
691
+		 * also_email_to: array of fields ids
692
+		 * reply_to: Email, field id, 'custom'
693
+		 * cust_reply_to: string
694
+		 * reply_to_name: field id, 'custom'
695
+		 * cust_reply_to_name: string
696
+		 * plain_text: 0|1
697
+		 * email_message: string or ''
698
+		 * email_subject: string or ''
699
+		 * inc_user_info: 0|1
700
+		 * update_email: 0, 1, 2
701
+		 *
702
+		 * Old autoresponder settings format:
703
+		 * auto_responder: 0|1
704
+		 * ar_email_message: string or ''
705
+		 * ar_email_to: field id
706
+		 * ar_plain_text: 0|1
707
+		 * ar_reply_to_name: string
708
+		 * ar_reply_to: string
709
+		 * ar_email_subject: string
710
+		 * ar_update_email: 0, 1, 2
711
+		 *
712
+		 * New email settings:
713
+		 * post_content: json settings
714
+		 * post_title: form id
715
+		 * post_excerpt: message
716
+		 *
717
+		 */
718
+
719
+		foreach ( $forms as $form ) {
720 720
 			if ( $form->is_template && $form->default_template ) {
721 721
 				// don't migrate the default templates since the email will be added anyway
722 722
 				continue;
723 723
 			}
724 724
 
725
-            // Format form options
726
-            $form_options = maybe_unserialize($form->options);
725
+			// Format form options
726
+			$form_options = maybe_unserialize($form->options);
727 727
 
728
-            // Migrate settings to actions
729
-            FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id );
730
-        }
731
-    }
728
+			// Migrate settings to actions
729
+			FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id );
730
+		}
731
+	}
732 732
 
733
-    private function migrate_to_11() {
734
-        global $wpdb;
733
+	private function migrate_to_11() {
734
+		global $wpdb;
735 735
 
736
-        $forms = FrmDb::get_results( $this->forms, array(), 'id, options');
736
+		$forms = FrmDb::get_results( $this->forms, array(), 'id, options');
737 737
 
738
-        $sending = __( 'Sending', 'formidable' );
738
+		$sending = __( 'Sending', 'formidable' );
739 739
 		$img = FrmAppHelper::plugin_url() . '/images/ajax_loader.gif';
740
-        $old_default_html = <<<DEFAULT_HTML
740
+		$old_default_html = <<<DEFAULT_HTML
741 741
 <div class="frm_submit">
742 742
 [if back_button]<input type="submit" value="[back_label]" name="frm_prev_page" formnovalidate="formnovalidate" [back_hook] />[/if back_button]
743 743
 <input type="submit" value="[button_label]" [button_action] />
744 744
 <img class="frm_ajax_loading" src="$img" alt="$sending" style="visibility:hidden;" />
745 745
 </div>
746 746
 DEFAULT_HTML;
747
-        unset($sending, $img);
747
+		unset($sending, $img);
748 748
 
749
-        $new_default_html = FrmFormsHelper::get_default_html('submit');
750
-        $draft_link = FrmFormsHelper::get_draft_link();
749
+		$new_default_html = FrmFormsHelper::get_default_html('submit');
750
+		$draft_link = FrmFormsHelper::get_draft_link();
751 751
 		foreach ( $forms as $form ) {
752
-            $form->options = maybe_unserialize($form->options);
753
-            if ( ! isset($form->options['submit_html']) || empty($form->options['submit_html']) ) {
754
-                continue;
755
-            }
752
+			$form->options = maybe_unserialize($form->options);
753
+			if ( ! isset($form->options['submit_html']) || empty($form->options['submit_html']) ) {
754
+				continue;
755
+			}
756 756
 
757
-            if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) {
758
-                $form->options['submit_html'] = $new_default_html;
757
+			if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) {
758
+				$form->options['submit_html'] = $new_default_html;
759 759
 				$wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) );
760 760
 			} else if ( ! strpos( $form->options['submit_html'], 'save_draft' ) ) {
761 761
 				$form->options['submit_html'] = preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $draft_link . "\r\n</div>", $form->options['submit_html'] );
762 762
 				$wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) );
763
-            }
764
-            unset($form);
765
-        }
766
-        unset($forms);
767
-    }
763
+			}
764
+			unset($form);
765
+		}
766
+		unset($forms);
767
+	}
768 768
 
769
-    private function migrate_to_6() {
770
-        global $wpdb;
769
+	private function migrate_to_6() {
770
+		global $wpdb;
771 771
 
772 772
 		$no_save = array_merge( FrmField::no_save_fields(), array( 'form', 'hidden', 'user_id' ) );
773 773
 		$fields = FrmDb::get_results( $this->fields, array( 'type NOT' => $no_save ), 'id, field_options' );
774 774
 
775
-        $default_html = <<<DEFAULT_HTML
775
+		$default_html = <<<DEFAULT_HTML
776 776
 <div id="frm_field_[id]_container" class="form-field [required_class] [error_class]">
777 777
     <label class="frm_pos_[label_position]">[field_name]
778 778
         <span class="frm_required">[required_label]</span>
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
 </div>
783 783
 DEFAULT_HTML;
784 784
 
785
-        $old_default_html = <<<DEFAULT_HTML
785
+		$old_default_html = <<<DEFAULT_HTML
786 786
 <div id="frm_field_[id]_container" class="form-field [required_class] [error_class]">
787 787
     <label class="frm_pos_[label_position]">[field_name]
788 788
         <span class="frm_required">[required_label]</span>
@@ -792,25 +792,25 @@  discard block
 block discarded – undo
792 792
 </div>
793 793
 DEFAULT_HTML;
794 794
 
795
-        $new_default_html = FrmFieldsHelper::get_default_html('text');
796
-        foreach ( $fields as $field ) {
797
-            $field->field_options = maybe_unserialize($field->field_options);
795
+		$new_default_html = FrmFieldsHelper::get_default_html('text');
796
+		foreach ( $fields as $field ) {
797
+			$field->field_options = maybe_unserialize($field->field_options);
798 798
 			if ( ! FrmField::is_option_empty( $field, 'custom_html' ) || $field->field_options['custom_html'] == $default_html || $field->field_options['custom_html'] == $old_default_html ) {
799
-                $field->field_options['custom_html'] = $new_default_html;
799
+				$field->field_options['custom_html'] = $new_default_html;
800 800
 				$wpdb->update( $this->fields, array( 'field_options' => maybe_serialize( $field->field_options ) ), array( 'id' => $field->id ) );
801
-            }
802
-            unset($field);
803
-        }
804
-        unset($default_html, $old_default_html, $fields);
805
-    }
806
-
807
-    private function migrate_to_4() {
808
-        global $wpdb;
801
+			}
802
+			unset($field);
803
+		}
804
+		unset($default_html, $old_default_html, $fields);
805
+	}
806
+
807
+	private function migrate_to_4() {
808
+		global $wpdb;
809 809
 		$user_ids = FrmEntryMeta::getAll( array( 'fi.type' => 'user_id' ) );
810
-        foreach ( $user_ids as $user_id ) {
810
+		foreach ( $user_ids as $user_id ) {
811 811
 			$wpdb->update( $this->entries, array( 'user_id' => $user_id->meta_value ), array( 'id' => $user_id->item_id ) );
812
-        }
813
-    }
812
+		}
813
+	}
814 814
 
815 815
 	public static function get_one_record( $table, $args = array(), $fields = '*', $order_by = '' ) {
816 816
 		_deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_row' );
Please login to merge, or discard this patch.
classes/controllers/FrmFieldsController.php 2 patches
Spacing   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 class FrmFieldsController {
4 4
 
5 5
     public static function load_field() {
6
-		FrmAppHelper::permission_check('frm_edit_forms');
6
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
7 7
         check_ajax_referer( 'frm_ajax', 'nonce' );
8 8
 
9 9
         $fields = $_POST['field'];
@@ -34,17 +34,17 @@  discard block
 block discarded – undo
34 34
             }
35 35
 
36 36
 			$field_name = 'item_meta[' . $field_id . ']';
37
-            $html_id = FrmFieldsHelper::get_html_id($field);
37
+            $html_id = FrmFieldsHelper::get_html_id( $field );
38 38
 
39 39
             ob_start();
40 40
 			include( $path . '/classes/views/frm-forms/add_field.php' );
41
-            $field_html[ $field_id ] = ob_get_contents();
41
+            $field_html[$field_id] = ob_get_contents();
42 42
             ob_end_clean();
43 43
         }
44 44
 
45
-        unset($path);
45
+        unset( $path );
46 46
 
47
-        echo json_encode($field_html);
47
+        echo json_encode( $field_html );
48 48
 
49 49
         wp_die();
50 50
     }
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	 * Create a new field with ajax
54 54
 	 */
55 55
     public static function create() {
56
-		FrmAppHelper::permission_check('frm_edit_forms');
56
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
57 57
         check_ajax_referer( 'frm_ajax', 'nonce' );
58 58
 
59 59
 		$field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' );
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 		$field = self::include_new_field( $field_type, $form_id );
63 63
 
64 64
         // this hook will allow for multiple fields to be added at once
65
-        do_action('frm_after_field_created', $field, $form_id);
65
+        do_action( 'frm_after_field_created', $field, $form_id );
66 66
 
67 67
         wp_die();
68 68
     }
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	public static function include_new_field( $field_type, $form_id ) {
78 78
         $values = array();
79 79
         if ( FrmAppHelper::pro_is_installed() ) {
80
-            $values['post_type'] = FrmProFormsHelper::post_type($form_id);
80
+            $values['post_type'] = FrmProFormsHelper::post_type( $form_id );
81 81
         }
82 82
 
83 83
 		$field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id );
@@ -89,27 +89,27 @@  discard block
 block discarded – undo
89 89
             return false;
90 90
         }
91 91
 
92
-        $field = self::include_single_field($field_id, $values, $form_id);
92
+        $field = self::include_single_field( $field_id, $values, $form_id );
93 93
 
94 94
         return $field;
95 95
     }
96 96
 
97 97
 	public static function edit_name( $field = 'name', $id = '' ) {
98
-		FrmAppHelper::permission_check('frm_edit_forms');
98
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
99 99
         check_ajax_referer( 'frm_ajax', 'nonce' );
100 100
 
101
-        if ( empty($field) ) {
101
+        if ( empty( $field ) ) {
102 102
             $field = 'name';
103 103
         }
104 104
 
105
-        if ( empty($id) ) {
105
+        if ( empty( $id ) ) {
106 106
 			$id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
107 107
 			$id = str_replace( 'field_label_', '', $id );
108 108
         }
109 109
 
110 110
 		$value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' );
111 111
 		$value = trim( $value );
112
-        if ( trim(strip_tags($value)) == '' ) {
112
+        if ( trim( strip_tags( $value ) ) == '' ) {
113 113
             // set blank value if there is no content
114 114
             $value = '';
115 115
         }
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
     }
124 124
 
125 125
     public static function update_ajax_option() {
126
-		FrmAppHelper::permission_check('frm_edit_forms');
126
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
127 127
         check_ajax_referer( 'frm_ajax', 'nonce' );
128 128
 
129 129
 		$field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' );
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 		if ( isset( $_POST['separate_value'] ) ) {
137 137
 			$new_val = FrmField::is_option_true( $field, 'separate_value' ) ? 0 : 1;
138 138
 			$field->field_options['separate_value'] = $new_val;
139
-			unset($new_val);
139
+			unset( $new_val );
140 140
 		}
141 141
 
142 142
         FrmField::update( $field_id, array(
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
     }
148 148
 
149 149
     public static function duplicate() {
150
-		FrmAppHelper::permission_check('frm_edit_forms');
150
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
151 151
         check_ajax_referer( 'frm_ajax', 'nonce' );
152 152
 
153 153
         global $wpdb;
@@ -172,11 +172,11 @@  discard block
 block discarded – undo
172 172
 
173 173
 	    $values = apply_filters( 'frm_prepare_single_field_for_duplication', $values );
174 174
 
175
-        if ( ! $field_id = FrmField::create($values) ) {
175
+        if ( ! $field_id = FrmField::create( $values ) ) {
176 176
             wp_die();
177 177
         }
178 178
 
179
-        self::include_single_field($field_id, $values);
179
+        self::include_single_field( $field_id, $values );
180 180
 
181 181
         wp_die();
182 182
     }
@@ -185,9 +185,9 @@  discard block
 block discarded – undo
185 185
      * Load a single field in the form builder along with all needed variables
186 186
      */
187 187
     public static function include_single_field( $field_id, $values, $form_id = 0 ) {
188
-        $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id));
188
+        $field = FrmFieldsHelper::setup_edit_vars( FrmField::getOne( $field_id ) );
189 189
 		$field_name = 'item_meta[' . $field_id . ']';
190
-        $html_id = FrmFieldsHelper::get_html_id($field);
190
+        $html_id = FrmFieldsHelper::get_html_id( $field );
191 191
         $id = $form_id ? $form_id : $field['form_id'];
192 192
         if ( $field['type'] == 'html' ) {
193 193
             $field['stop_filter'] = true;
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
     }
200 200
 
201 201
     public static function destroy() {
202
-		FrmAppHelper::permission_check('frm_edit_forms');
202
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
203 203
         check_ajax_referer( 'frm_ajax', 'nonce' );
204 204
 
205 205
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
@@ -211,14 +211,14 @@  discard block
 block discarded – undo
211 211
 
212 212
     //Add Single Option or Other Option
213 213
     public static function add_option() {
214
-		FrmAppHelper::permission_check('frm_edit_forms');
214
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
215 215
         check_ajax_referer( 'frm_ajax', 'nonce' );
216 216
 
217 217
 		$id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
218 218
 		$opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' );
219 219
 
220 220
         //Get the field
221
-        $field = FrmField::getOne($id);
221
+        $field = FrmField::getOne( $id );
222 222
 
223 223
 		if ( ! empty( $field->options ) ) {
224 224
 			$keys = array_keys( $field->options );
@@ -241,13 +241,13 @@  discard block
 block discarded – undo
241 241
 			$first_opt = reset( $field->options );
242 242
 			$next_opt = count( $field->options );
243 243
             if ( $first_opt != '' ) {
244
-                $next_opt++;
244
+                $next_opt ++;
245 245
             }
246 246
 			$opt = esc_html__( 'Option', 'formidable' ) . ' ' . $next_opt;
247
-            unset($next_opt);
247
+            unset( $next_opt );
248 248
         }
249 249
         $field_val = $opt;
250
-		$field->options[ $opt_key ] = $opt;
250
+		$field->options[$opt_key] = $opt;
251 251
 
252 252
         //Update options in DB
253 253
 		FrmField::update( $id, array( 'options' => $field->options ) );
@@ -256,13 +256,13 @@  discard block
 block discarded – undo
256 256
         $field = array(
257 257
             'type'  => $field_data->type,
258 258
             'id'    => $id,
259
-            'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0,
259
+            'separate_value' => isset( $field_data->field_options['separate_value'] ) ? $field_data->field_options['separate_value'] : 0,
260 260
             'form_id' => $field_data->form_id,
261 261
             'field_key' => $field_data->field_key,
262 262
         );
263 263
 
264 264
 		$field_name = 'item_meta[' . $id . ']';
265
-        $html_id = FrmFieldsHelper::get_html_id($field);
265
+        $html_id = FrmFieldsHelper::get_html_id( $field );
266 266
         $checked = '';
267 267
 
268 268
         if ( 'other' == $opt_type ) {
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
     }
275 275
 
276 276
     public static function edit_option() {
277
-		FrmAppHelper::permission_check('frm_edit_forms');
277
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
278 278
         check_ajax_referer( 'frm_ajax', 'nonce' );
279 279
 
280 280
 		$element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
@@ -288,28 +288,28 @@  discard block
 block discarded – undo
288 288
             $new_label = $update_value;
289 289
         }
290 290
 
291
-        $field = FrmField::getOne($id);
291
+        $field = FrmField::getOne( $id );
292 292
         $separate_values = FrmField::is_option_true( $field, 'separate_value' );
293 293
 
294
-        $this_opt_id = end($ids);
295
-		$this_opt = (array) $field->options[ $this_opt_id ];
296
-		$other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false );
294
+        $this_opt_id = end( $ids );
295
+		$this_opt = (array) $field->options[$this_opt_id];
296
+		$other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other' ) !== false );
297 297
 
298
-        $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt);
299
-        $value = isset($this_opt['value']) ? $this_opt['value'] : '';
298
+        $label = isset( $this_opt['label'] ) ? $this_opt['label'] : reset( $this_opt );
299
+        $value = isset( $this_opt['value'] ) ? $this_opt['value'] : '';
300 300
 
301 301
         if ( ! isset( $new_label ) ) {
302 302
             $new_label = $label;
303 303
         }
304 304
 
305
-        if ( isset($new_value) || isset($value) ) {
306
-            $update_value = isset($new_value) ? $new_value : $value;
305
+        if ( isset( $new_value ) || isset( $value ) ) {
306
+            $update_value = isset( $new_value ) ? $new_value : $value;
307 307
         }
308 308
 
309 309
 		if ( $update_value != $new_label && $other_opt === false && $separate_values ) {
310
-			$field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label );
310
+			$field->options[$this_opt_id] = array( 'value' => $update_value, 'label' => $new_label );
311 311
         } else {
312
-			$field->options[ $this_opt_id ] = $orig_update_value;
312
+			$field->options[$this_opt_id] = $orig_update_value;
313 313
         }
314 314
 
315 315
 		FrmField::update( $field->id, array( 'options' => $field->options ) );
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
     }
319 319
 
320 320
     public static function delete_option() {
321
-		FrmAppHelper::permission_check('frm_edit_forms');
321
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
322 322
         check_ajax_referer( 'frm_ajax', 'nonce' );
323 323
 
324 324
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 		$opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' );
328 328
 
329 329
 		$options = $field->options;
330
-        unset( $options[ $opt_key ] );
330
+        unset( $options[$opt_key] );
331 331
         $response = array( 'other' => true );
332 332
 
333 333
         //If the deleted option is an "other" option
@@ -393,9 +393,9 @@  discard block
 block discarded – undo
393 393
 
394 394
         $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
395 395
         $prepop = array();
396
-        FrmFieldsHelper::get_bulk_prefilled_opts($prepop);
396
+        FrmFieldsHelper::get_bulk_prefilled_opts( $prepop );
397 397
 
398
-        $field = FrmField::getOne($field_id);
398
+        $field = FrmField::getOne( $field_id );
399 399
 
400 400
         wp_enqueue_script( 'utils' );
401 401
 		wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' );
@@ -406,35 +406,35 @@  discard block
 block discarded – undo
406 406
     }
407 407
 
408 408
     public static function import_options() {
409
-		FrmAppHelper::permission_check('frm_edit_forms');
409
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
410 410
         check_ajax_referer( 'frm_ajax', 'nonce' );
411 411
 
412
-        if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) {
412
+        if ( ! is_admin() || ! current_user_can( 'frm_edit_forms' ) ) {
413 413
             return;
414 414
         }
415 415
 
416 416
 		$field_id = absint( $_POST['field_id'] );
417
-        $field = FrmField::getOne($field_id);
417
+        $field = FrmField::getOne( $field_id );
418 418
 
419 419
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) {
420 420
             return;
421 421
         }
422 422
 
423
-        $field = FrmFieldsHelper::setup_edit_vars($field);
423
+        $field = FrmFieldsHelper::setup_edit_vars( $field );
424 424
 		$opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' );
425 425
 		$opts = explode( "\n", rtrim( $opts, "\n" ) );
426 426
 		$opts = array_map( 'trim', $opts );
427 427
 
428 428
         if ( $field['separate_value'] ) {
429 429
             foreach ( $opts as $opt_key => $opt ) {
430
-                if ( strpos($opt, '|') !== false ) {
431
-                    $vals = explode('|', $opt);
430
+                if ( strpos( $opt, '|' ) !== false ) {
431
+                    $vals = explode( '|', $opt );
432 432
                     if ( $vals[0] != $vals[1] ) {
433
-                        $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
433
+                        $opts[$opt_key] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
434 434
                     }
435
-                    unset($vals);
435
+                    unset( $vals );
436 436
                 }
437
-                unset($opt_key, $opt);
437
+                unset( $opt_key, $opt );
438 438
             }
439 439
         }
440 440
 
@@ -443,12 +443,12 @@  discard block
 block discarded – undo
443 443
             $other_array = array();
444 444
             foreach ( $field['options'] as $opt_key => $opt ) {
445 445
                 if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) {
446
-                    $other_array[ $opt_key ] = $opt;
446
+                    $other_array[$opt_key] = $opt;
447 447
                 }
448
-                unset($opt_key, $opt);
448
+                unset( $opt_key, $opt );
449 449
             }
450
-            if ( ! empty($other_array) ) {
451
-                $opts = array_merge( $opts, $other_array);
450
+            if ( ! empty( $other_array ) ) {
451
+                $opts = array_merge( $opts, $other_array );
452 452
             }
453 453
         }
454 454
 
@@ -463,14 +463,14 @@  discard block
 block discarded – undo
463 463
         if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
464 464
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' );
465 465
         } else {
466
-            FrmFieldsHelper::show_single_option($field);
466
+            FrmFieldsHelper::show_single_option( $field );
467 467
         }
468 468
 
469 469
         wp_die();
470 470
     }
471 471
 
472 472
     public static function update_order() {
473
-		FrmAppHelper::permission_check('frm_edit_forms');
473
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
474 474
         check_ajax_referer( 'frm_ajax', 'nonce' );
475 475
 
476 476
 		$fields = FrmAppHelper::get_post_param( 'frm_field_id' );
@@ -487,13 +487,13 @@  discard block
 block discarded – undo
487 487
             'rte'       => 'textarea',
488 488
             'website'   => 'url',
489 489
         );
490
-        if ( isset( $type_switch[ $type ] ) ) {
491
-            $type = $type_switch[ $type ];
490
+        if ( isset( $type_switch[$type] ) ) {
491
+            $type = $type_switch[$type];
492 492
         }
493 493
 
494 494
 		$frm_field_selection = FrmField::field_selection();
495
-        $types = array_keys($frm_field_selection);
496
-        if ( ! in_array($type, $types) && $type != 'captcha' ) {
495
+        $types = array_keys( $frm_field_selection );
496
+        if ( ! in_array( $type, $types ) && $type != 'captcha' ) {
497 497
             $type = 'text';
498 498
         }
499 499
 
@@ -532,19 +532,19 @@  discard block
 block discarded – undo
532 532
 
533 533
     public static function input_html( $field, $echo = true ) {
534 534
         $class = array(); //$field['type'];
535
-        self::add_input_classes($field, $class);
535
+        self::add_input_classes( $field, $class );
536 536
 
537 537
         $add_html = array();
538
-        self::add_html_size($field, $add_html);
539
-        self::add_html_length($field, $add_html);
540
-        self::add_html_placeholder($field, $add_html, $class);
538
+        self::add_html_size( $field, $add_html );
539
+        self::add_html_length( $field, $add_html );
540
+        self::add_html_placeholder( $field, $add_html, $class );
541 541
 		self::add_validation_messages( $field, $add_html );
542 542
 
543
-        $class = apply_filters('frm_field_classes', implode(' ', $class), $field);
543
+        $class = apply_filters( 'frm_field_classes', implode( ' ', $class ), $field );
544 544
 
545 545
 		FrmFormsHelper::add_html_attr( $class, 'class', $add_html );
546 546
 
547
-        self::add_shortcodes_to_html($field, $add_html);
547
+        self::add_shortcodes_to_html( $field, $add_html );
548 548
 
549 549
 		$add_html = apply_filters( 'frm_field_extra_html', $add_html, $field );
550 550
 		$add_html = ' ' . implode( ' ', $add_html ) . '  ';
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
     }
558 558
 
559 559
 	private static function add_input_classes( $field, array &$class ) {
560
-        if ( isset($field['input_class']) && ! empty($field['input_class']) ) {
560
+        if ( isset( $field['input_class'] ) && ! empty( $field['input_class'] ) ) {
561 561
             $class[] = $field['input_class'];
562 562
         }
563 563
 
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
             $class[] = 'dyn_default_value';
572 572
         }
573 573
 
574
-        if ( isset($field['size']) && $field['size'] > 0 ) {
574
+        if ( isset( $field['size'] ) && $field['size'] > 0 ) {
575 575
             $class[] = 'auto_width';
576 576
         }
577 577
     }
@@ -581,19 +581,19 @@  discard block
 block discarded – undo
581 581
             return;
582 582
         }
583 583
 
584
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
584
+        if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
585 585
             return;
586 586
         }
587 587
 
588
-        if ( is_numeric($field['size']) ) {
588
+        if ( is_numeric( $field['size'] ) ) {
589 589
             $field['size'] .= 'px';
590 590
         }
591 591
 
592
-        $important = apply_filters('frm_use_important_width', 1, $field);
592
+        $important = apply_filters( 'frm_use_important_width', 1, $field );
593 593
         // Note: This inline styling must stay since we cannot realistically set a class for every possible field size
594 594
 		$add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"';
595 595
 
596
-        self::add_html_cols($field, $add_html);
596
+        self::add_html_cols( $field, $add_html );
597 597
     }
598 598
 
599 599
 	private static function add_html_cols( $field, array &$add_html ) {
@@ -610,13 +610,13 @@  discard block
 block discarded – undo
610 610
         );
611 611
 
612 612
         // include "col" for valid html
613
-        $unit = trim(preg_replace('/[0-9]+/', '', $field['size']));
613
+        $unit = trim( preg_replace( '/[0-9]+/', '', $field['size'] ) );
614 614
 
615
-        if ( ! isset( $calc[ $unit ] ) ) {
615
+        if ( ! isset( $calc[$unit] ) ) {
616 616
             return;
617 617
         }
618 618
 
619
-        $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
619
+        $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[$unit];
620 620
 
621 621
 		$add_html['cols'] = 'cols="' . absint( $size ) . '"';
622 622
     }
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
             return;
628 628
         }
629 629
 
630
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
630
+        if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
631 631
             // don't load on form builder page
632 632
             return;
633 633
         }
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
 		if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) {
660 660
             // use HMTL5 placeholder with js fallback
661 661
 			$add_html['placeholder'] = 'placeholder="' . esc_attr( $field['default_value'] ) . '"';
662
-            wp_enqueue_script('jquery-placeholder');
662
+            wp_enqueue_script( 'jquery-placeholder' );
663 663
         } else if ( ! $frm_settings->use_html ) {
664 664
 			$val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( '&#039;', "'", esc_attr( $field['default_value'] ) ) ) );
665 665
 			$add_html['data-frmval'] = 'data-frmval="' . esc_attr( $val ) . '"';
@@ -693,15 +693,15 @@  discard block
 block discarded – undo
693 693
                 continue;
694 694
             }
695 695
 
696
-            if ( is_numeric($k) && strpos($v, '=') ) {
696
+            if ( is_numeric( $k ) && strpos( $v, '=' ) ) {
697 697
                 $add_html[] = $v;
698
-            } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
699
-				$add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] );
698
+            } else if ( ! empty( $k ) && isset( $add_html[$k] ) ) {
699
+				$add_html[$k] = str_replace( $k . '="', $k . '="' . $v, $add_html[$k] );
700 700
             } else {
701
-				$add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"';
701
+				$add_html[$k] = $k . '="' . esc_attr( $v ) . '"';
702 702
             }
703 703
 
704
-            unset($k, $v);
704
+            unset( $k, $v );
705 705
         }
706 706
     }
707 707
 
@@ -717,8 +717,8 @@  discard block
 block discarded – undo
717 717
     }
718 718
 
719 719
 	public static function check_label( $opt ) {
720
-        if ( is_array($opt) ) {
721
-            $opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
720
+        if ( is_array( $opt ) ) {
721
+            $opt = ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
722 722
         }
723 723
 
724 724
         return $opt;
Please login to merge, or discard this patch.
Indentation   +428 added lines, -428 removed lines patch added patch discarded remove patch
@@ -2,129 +2,129 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmFieldsController {
4 4
 
5
-    public static function load_field() {
5
+	public static function load_field() {
6 6
 		FrmAppHelper::permission_check('frm_edit_forms');
7
-        check_ajax_referer( 'frm_ajax', 'nonce' );
7
+		check_ajax_referer( 'frm_ajax', 'nonce' );
8 8
 
9
-        $fields = $_POST['field'];
10
-        if ( empty( $fields ) ) {
11
-            wp_die();
12
-        }
9
+		$fields = $_POST['field'];
10
+		if ( empty( $fields ) ) {
11
+			wp_die();
12
+		}
13 13
 
14
-        $_GET['page'] = 'formidable';
15
-        $fields = stripslashes_deep( $fields );
14
+		$_GET['page'] = 'formidable';
15
+		$fields = stripslashes_deep( $fields );
16 16
 
17
-        $ajax = true;
17
+		$ajax = true;
18 18
 		$values = array( 'id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ) );
19
-        $path = FrmAppHelper::plugin_path();
20
-        $field_html = array();
21
-
22
-        foreach ( $fields as $field ) {
23
-            $field = htmlspecialchars_decode( nl2br( $field ) );
24
-            $field = json_decode( $field, true );
25
-            if ( ! isset( $field['id'] ) ) {
26
-                // this field may have already been loaded
27
-                continue;
28
-            }
19
+		$path = FrmAppHelper::plugin_path();
20
+		$field_html = array();
21
+
22
+		foreach ( $fields as $field ) {
23
+			$field = htmlspecialchars_decode( nl2br( $field ) );
24
+			$field = json_decode( $field, true );
25
+			if ( ! isset( $field['id'] ) ) {
26
+				// this field may have already been loaded
27
+				continue;
28
+			}
29 29
 
30
-            $field_id = absint( $field['id'] );
30
+			$field_id = absint( $field['id'] );
31 31
 
32
-            if ( ! isset( $field['value'] ) ) {
33
-                $field['value'] = '';
34
-            }
32
+			if ( ! isset( $field['value'] ) ) {
33
+				$field['value'] = '';
34
+			}
35 35
 
36 36
 			$field_name = 'item_meta[' . $field_id . ']';
37
-            $html_id = FrmFieldsHelper::get_html_id($field);
37
+			$html_id = FrmFieldsHelper::get_html_id($field);
38 38
 
39
-            ob_start();
39
+			ob_start();
40 40
 			include( $path . '/classes/views/frm-forms/add_field.php' );
41
-            $field_html[ $field_id ] = ob_get_contents();
42
-            ob_end_clean();
43
-        }
41
+			$field_html[ $field_id ] = ob_get_contents();
42
+			ob_end_clean();
43
+		}
44 44
 
45
-        unset($path);
45
+		unset($path);
46 46
 
47
-        echo json_encode($field_html);
47
+		echo json_encode($field_html);
48 48
 
49
-        wp_die();
50
-    }
49
+		wp_die();
50
+	}
51 51
 
52 52
 	/**
53 53
 	 * Create a new field with ajax
54 54
 	 */
55
-    public static function create() {
55
+	public static function create() {
56 56
 		FrmAppHelper::permission_check('frm_edit_forms');
57
-        check_ajax_referer( 'frm_ajax', 'nonce' );
57
+		check_ajax_referer( 'frm_ajax', 'nonce' );
58 58
 
59 59
 		$field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' );
60 60
 		$form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
61 61
 
62 62
 		$field = self::include_new_field( $field_type, $form_id );
63 63
 
64
-        // this hook will allow for multiple fields to be added at once
65
-        do_action('frm_after_field_created', $field, $form_id);
64
+		// this hook will allow for multiple fields to be added at once
65
+		do_action('frm_after_field_created', $field, $form_id);
66 66
 
67
-        wp_die();
68
-    }
67
+		wp_die();
68
+	}
69 69
 
70
-    /**
71
-     * Set up and create a new field
72
-     *
73
-     * @param string $field_type
74
-     * @param integer $form_id
75
-     * @return array|bool
76
-     */
70
+	/**
71
+	 * Set up and create a new field
72
+	 *
73
+	 * @param string $field_type
74
+	 * @param integer $form_id
75
+	 * @return array|bool
76
+	 */
77 77
 	public static function include_new_field( $field_type, $form_id ) {
78
-        $values = array();
79
-        if ( FrmAppHelper::pro_is_installed() ) {
80
-            $values['post_type'] = FrmProFormsHelper::post_type($form_id);
81
-        }
78
+		$values = array();
79
+		if ( FrmAppHelper::pro_is_installed() ) {
80
+			$values['post_type'] = FrmProFormsHelper::post_type($form_id);
81
+		}
82 82
 
83 83
 		$field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id );
84
-        $field_values = apply_filters( 'frm_before_field_created', $field_values );
84
+		$field_values = apply_filters( 'frm_before_field_created', $field_values );
85 85
 
86
-        $field_id = FrmField::create( $field_values );
86
+		$field_id = FrmField::create( $field_values );
87 87
 
88
-        if ( ! $field_id ) {
89
-            return false;
90
-        }
88
+		if ( ! $field_id ) {
89
+			return false;
90
+		}
91 91
 
92
-        $field = self::include_single_field($field_id, $values, $form_id);
92
+		$field = self::include_single_field($field_id, $values, $form_id);
93 93
 
94
-        return $field;
95
-    }
94
+		return $field;
95
+	}
96 96
 
97 97
 	public static function edit_name( $field = 'name', $id = '' ) {
98 98
 		FrmAppHelper::permission_check('frm_edit_forms');
99
-        check_ajax_referer( 'frm_ajax', 'nonce' );
99
+		check_ajax_referer( 'frm_ajax', 'nonce' );
100 100
 
101
-        if ( empty($field) ) {
102
-            $field = 'name';
103
-        }
101
+		if ( empty($field) ) {
102
+			$field = 'name';
103
+		}
104 104
 
105
-        if ( empty($id) ) {
105
+		if ( empty($id) ) {
106 106
 			$id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
107 107
 			$id = str_replace( 'field_label_', '', $id );
108
-        }
108
+		}
109 109
 
110 110
 		$value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' );
111 111
 		$value = trim( $value );
112
-        if ( trim(strip_tags($value)) == '' ) {
113
-            // set blank value if there is no content
114
-            $value = '';
115
-        }
112
+		if ( trim(strip_tags($value)) == '' ) {
113
+			// set blank value if there is no content
114
+			$value = '';
115
+		}
116 116
 
117 117
 		FrmField::update( $id, array( $field => $value ) );
118 118
 
119 119
 		do_action( 'frm_after_update_field_' . $field, compact( 'id', 'value' ) );
120 120
 
121 121
 		echo stripslashes( wp_kses_post( $value ) );
122
-        wp_die();
123
-    }
122
+		wp_die();
123
+	}
124 124
 
125
-    public static function update_ajax_option() {
125
+	public static function update_ajax_option() {
126 126
 		FrmAppHelper::permission_check('frm_edit_forms');
127
-        check_ajax_referer( 'frm_ajax', 'nonce' );
127
+		check_ajax_referer( 'frm_ajax', 'nonce' );
128 128
 
129 129
 		$field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' );
130 130
 		if ( ! $field_id ) {
@@ -139,143 +139,143 @@  discard block
 block discarded – undo
139 139
 			unset($new_val);
140 140
 		}
141 141
 
142
-        FrmField::update( $field_id, array(
143
-            'field_options' => $field->field_options,
142
+		FrmField::update( $field_id, array(
143
+			'field_options' => $field->field_options,
144 144
 			'form_id'		=> $field->form_id,
145
-        ) );
146
-        wp_die();
147
-    }
145
+		) );
146
+		wp_die();
147
+	}
148 148
 
149
-    public static function duplicate() {
149
+	public static function duplicate() {
150 150
 		FrmAppHelper::permission_check('frm_edit_forms');
151
-        check_ajax_referer( 'frm_ajax', 'nonce' );
151
+		check_ajax_referer( 'frm_ajax', 'nonce' );
152 152
 
153
-        global $wpdb;
153
+		global $wpdb;
154 154
 
155 155
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
156 156
 		$form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
157 157
 
158 158
 		$copy_field = FrmField::getOne( $field_id );
159
-        if ( ! $copy_field ) {
160
-            wp_die();
161
-        }
159
+		if ( ! $copy_field ) {
160
+			wp_die();
161
+		}
162 162
 
163 163
 		do_action( 'frm_duplicate_field', $copy_field, $form_id );
164 164
 		do_action( 'frm_duplicate_field_' . $copy_field->type, $copy_field, $form_id );
165 165
 
166 166
 		$values = array();
167
-        FrmFieldsHelper::fill_field( $values, $copy_field, $form_id );
167
+		FrmFieldsHelper::fill_field( $values, $copy_field, $form_id );
168 168
 
169 169
 		$field_count = FrmDb::get_count( $wpdb->prefix . 'frm_fields fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id)', array( 'or' => 1, 'fr.id' => $form_id, 'fr.parent_form_id' => $form_id ) );
170 170
 
171
-        $values['field_order'] = $field_count + 1;
171
+		$values['field_order'] = $field_count + 1;
172 172
 
173
-	    $values = apply_filters( 'frm_prepare_single_field_for_duplication', $values );
173
+		$values = apply_filters( 'frm_prepare_single_field_for_duplication', $values );
174 174
 
175
-        if ( ! $field_id = FrmField::create($values) ) {
176
-            wp_die();
177
-        }
175
+		if ( ! $field_id = FrmField::create($values) ) {
176
+			wp_die();
177
+		}
178 178
 
179
-        self::include_single_field($field_id, $values);
179
+		self::include_single_field($field_id, $values);
180 180
 
181
-        wp_die();
182
-    }
181
+		wp_die();
182
+	}
183 183
 
184
-    /**
185
-     * Load a single field in the form builder along with all needed variables
186
-     */
187
-    public static function include_single_field( $field_id, $values, $form_id = 0 ) {
188
-        $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id));
184
+	/**
185
+	 * Load a single field in the form builder along with all needed variables
186
+	 */
187
+	public static function include_single_field( $field_id, $values, $form_id = 0 ) {
188
+		$field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id));
189 189
 		$field_name = 'item_meta[' . $field_id . ']';
190
-        $html_id = FrmFieldsHelper::get_html_id($field);
191
-        $id = $form_id ? $form_id : $field['form_id'];
192
-        if ( $field['type'] == 'html' ) {
193
-            $field['stop_filter'] = true;
194
-        }
190
+		$html_id = FrmFieldsHelper::get_html_id($field);
191
+		$id = $form_id ? $form_id : $field['form_id'];
192
+		if ( $field['type'] == 'html' ) {
193
+			$field['stop_filter'] = true;
194
+		}
195 195
 
196 196
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_field.php' );
197 197
 
198
-        return $field;
199
-    }
198
+		return $field;
199
+	}
200 200
 
201
-    public static function destroy() {
201
+	public static function destroy() {
202 202
 		FrmAppHelper::permission_check('frm_edit_forms');
203
-        check_ajax_referer( 'frm_ajax', 'nonce' );
203
+		check_ajax_referer( 'frm_ajax', 'nonce' );
204 204
 
205 205
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
206 206
 		FrmField::destroy( $field_id );
207
-        wp_die();
208
-    }
207
+		wp_die();
208
+	}
209 209
 
210
-    /* Field Options */
210
+	/* Field Options */
211 211
 
212
-    //Add Single Option or Other Option
213
-    public static function add_option() {
212
+	//Add Single Option or Other Option
213
+	public static function add_option() {
214 214
 		FrmAppHelper::permission_check('frm_edit_forms');
215
-        check_ajax_referer( 'frm_ajax', 'nonce' );
215
+		check_ajax_referer( 'frm_ajax', 'nonce' );
216 216
 
217 217
 		$id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
218 218
 		$opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' );
219 219
 
220
-        //Get the field
221
-        $field = FrmField::getOne($id);
220
+		//Get the field
221
+		$field = FrmField::getOne($id);
222 222
 
223 223
 		if ( ! empty( $field->options ) ) {
224 224
 			$keys = array_keys( $field->options );
225
-            $last = str_replace( 'other_', '', end( $keys ) );
226
-        } else {
227
-            $last = 0;
228
-        }
229
-        $opt_key = $last + 1;
225
+			$last = str_replace( 'other_', '', end( $keys ) );
226
+		} else {
227
+			$last = 0;
228
+		}
229
+		$opt_key = $last + 1;
230 230
 
231
-        if ( 'other' == $opt_type ) {
231
+		if ( 'other' == $opt_type ) {
232 232
 			$opt = esc_html__( 'Other', 'formidable' );
233
-            $other_val = '';
234
-            $opt_key = 'other_' . $opt_key;
235
-
236
-            //Update value of "other" in DB
237
-            $field_options = maybe_unserialize( $field->field_options );
238
-            $field_options['other'] = 1;
239
-            FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) );
240
-        } else {
233
+			$other_val = '';
234
+			$opt_key = 'other_' . $opt_key;
235
+
236
+			//Update value of "other" in DB
237
+			$field_options = maybe_unserialize( $field->field_options );
238
+			$field_options['other'] = 1;
239
+			FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) );
240
+		} else {
241 241
 			$first_opt = reset( $field->options );
242 242
 			$next_opt = count( $field->options );
243
-            if ( $first_opt != '' ) {
244
-                $next_opt++;
245
-            }
243
+			if ( $first_opt != '' ) {
244
+				$next_opt++;
245
+			}
246 246
 			$opt = esc_html__( 'Option', 'formidable' ) . ' ' . $next_opt;
247
-            unset($next_opt);
248
-        }
249
-        $field_val = $opt;
247
+			unset($next_opt);
248
+		}
249
+		$field_val = $opt;
250 250
 		$field->options[ $opt_key ] = $opt;
251 251
 
252
-        //Update options in DB
252
+		//Update options in DB
253 253
 		FrmField::update( $id, array( 'options' => $field->options ) );
254 254
 
255
-        $field_data = $field;
256
-        $field = array(
257
-            'type'  => $field_data->type,
258
-            'id'    => $id,
259
-            'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0,
260
-            'form_id' => $field_data->form_id,
261
-            'field_key' => $field_data->field_key,
262
-        );
255
+		$field_data = $field;
256
+		$field = array(
257
+			'type'  => $field_data->type,
258
+			'id'    => $id,
259
+			'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0,
260
+			'form_id' => $field_data->form_id,
261
+			'field_key' => $field_data->field_key,
262
+		);
263 263
 
264 264
 		$field_name = 'item_meta[' . $id . ']';
265
-        $html_id = FrmFieldsHelper::get_html_id($field);
266
-        $checked = '';
265
+		$html_id = FrmFieldsHelper::get_html_id($field);
266
+		$checked = '';
267 267
 
268
-        if ( 'other' == $opt_type ) {
268
+		if ( 'other' == $opt_type ) {
269 269
 			require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' );
270
-        } else {
270
+		} else {
271 271
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' );
272
-        }
273
-        wp_die();
274
-    }
272
+		}
273
+		wp_die();
274
+	}
275 275
 
276
-    public static function edit_option() {
276
+	public static function edit_option() {
277 277
 		FrmAppHelper::permission_check('frm_edit_forms');
278
-        check_ajax_referer( 'frm_ajax', 'nonce' );
278
+		check_ajax_referer( 'frm_ajax', 'nonce' );
279 279
 
280 280
 		$element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
281 281
 		$ids = explode( '-', $element_id );
@@ -283,43 +283,43 @@  discard block
 block discarded – undo
283 283
 
284 284
 		$orig_update_value = $update_value = trim( FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ) );
285 285
 		if ( strpos( $element_id, 'key_' ) ) {
286
-            $new_value = $update_value;
287
-        } else {
288
-            $new_label = $update_value;
289
-        }
286
+			$new_value = $update_value;
287
+		} else {
288
+			$new_label = $update_value;
289
+		}
290 290
 
291
-        $field = FrmField::getOne($id);
292
-        $separate_values = FrmField::is_option_true( $field, 'separate_value' );
291
+		$field = FrmField::getOne($id);
292
+		$separate_values = FrmField::is_option_true( $field, 'separate_value' );
293 293
 
294
-        $this_opt_id = end($ids);
294
+		$this_opt_id = end($ids);
295 295
 		$this_opt = (array) $field->options[ $this_opt_id ];
296 296
 		$other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false );
297 297
 
298
-        $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt);
299
-        $value = isset($this_opt['value']) ? $this_opt['value'] : '';
298
+		$label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt);
299
+		$value = isset($this_opt['value']) ? $this_opt['value'] : '';
300 300
 
301
-        if ( ! isset( $new_label ) ) {
302
-            $new_label = $label;
303
-        }
301
+		if ( ! isset( $new_label ) ) {
302
+			$new_label = $label;
303
+		}
304 304
 
305
-        if ( isset($new_value) || isset($value) ) {
306
-            $update_value = isset($new_value) ? $new_value : $value;
307
-        }
305
+		if ( isset($new_value) || isset($value) ) {
306
+			$update_value = isset($new_value) ? $new_value : $value;
307
+		}
308 308
 
309 309
 		if ( $update_value != $new_label && $other_opt === false && $separate_values ) {
310 310
 			$field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label );
311
-        } else {
311
+		} else {
312 312
 			$field->options[ $this_opt_id ] = $orig_update_value;
313
-        }
313
+		}
314 314
 
315 315
 		FrmField::update( $field->id, array( 'options' => $field->options ) );
316 316
 		echo ( $orig_update_value == '' ) ? esc_html__( '(Blank)', 'formidable' ) : stripslashes( $orig_update_value );
317
-        wp_die();
318
-    }
317
+		wp_die();
318
+	}
319 319
 
320
-    public static function delete_option() {
320
+	public static function delete_option() {
321 321
 		FrmAppHelper::permission_check('frm_edit_forms');
322
-        check_ajax_referer( 'frm_ajax', 'nonce' );
322
+		check_ajax_referer( 'frm_ajax', 'nonce' );
323 323
 
324 324
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
325 325
 		$field = FrmField::getOne( $field_id );
@@ -327,307 +327,307 @@  discard block
 block discarded – undo
327 327
 		$opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' );
328 328
 
329 329
 		$options = $field->options;
330
-        unset( $options[ $opt_key ] );
331
-        $response = array( 'other' => true );
330
+		unset( $options[ $opt_key ] );
331
+		$response = array( 'other' => true );
332 332
 
333
-        //If the deleted option is an "other" option
333
+		//If the deleted option is an "other" option
334 334
 		if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) {
335
-            //Assume all other options are gone, unless proven otherwise
336
-            $other = false;
335
+			//Assume all other options are gone, unless proven otherwise
336
+			$other = false;
337 337
 
338
-            //Check if all other options are really gone
339
-            foreach ( $options as $o_key => $o_val ) {
340
-                //If there is still an other option in the field, set other to true
338
+			//Check if all other options are really gone
339
+			foreach ( $options as $o_key => $o_val ) {
340
+				//If there is still an other option in the field, set other to true
341 341
 				if ( FrmFieldsHelper::is_other_opt( $o_key ) ) {
342
-                    $other = true;
343
-                    break;
344
-                }
345
-                unset( $o_key, $o_val );
346
-            }
347
-
348
-            //If all other options are gone
349
-            if ( false === $other ) {
350
-                $field_options = maybe_unserialize( $field->field_options );
351
-                $field_options['other'] = 0;
342
+					$other = true;
343
+					break;
344
+				}
345
+				unset( $o_key, $o_val );
346
+			}
347
+
348
+			//If all other options are gone
349
+			if ( false === $other ) {
350
+				$field_options = maybe_unserialize( $field->field_options );
351
+				$field_options['other'] = 0;
352 352
 				FrmField::update( $field_id, array( 'field_options' => maybe_serialize( $field_options ) ) );
353
-                $response = array( 'other' => false );
354
-            }
355
-        }
356
-        echo json_encode( $response );
353
+				$response = array( 'other' => false );
354
+			}
355
+		}
356
+		echo json_encode( $response );
357 357
 
358 358
 		FrmField::update( $field_id, array( 'options' => maybe_serialize( $options ) ) );
359 359
 
360
-        wp_die();
361
-    }
360
+		wp_die();
361
+	}
362 362
 
363
-    public static function import_choices() {
364
-        FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
363
+	public static function import_choices() {
364
+		FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
365 365
 
366 366
 		$field_id = absint( $_REQUEST['field_id'] );
367 367
 
368
-        global $current_screen, $hook_suffix;
368
+		global $current_screen, $hook_suffix;
369 369
 
370
-        // Catch plugins that include admin-header.php before admin.php completes.
371
-        if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) {
372
-            $hook_suffix = '';
373
-        	set_current_screen();
374
-        }
370
+		// Catch plugins that include admin-header.php before admin.php completes.
371
+		if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) {
372
+			$hook_suffix = '';
373
+			set_current_screen();
374
+		}
375 375
 
376
-        if ( function_exists( 'register_admin_color_schemes' ) ) {
377
-            register_admin_color_schemes();
378
-        }
376
+		if ( function_exists( 'register_admin_color_schemes' ) ) {
377
+			register_admin_color_schemes();
378
+		}
379 379
 
380
-        $hook_suffix = $admin_body_class = '';
380
+		$hook_suffix = $admin_body_class = '';
381 381
 
382
-        if ( get_user_setting( 'mfold' ) == 'f' ) {
383
-        	$admin_body_class .= ' folded';
384
-        }
382
+		if ( get_user_setting( 'mfold' ) == 'f' ) {
383
+			$admin_body_class .= ' folded';
384
+		}
385 385
 
386
-        if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) {
387
-        	$admin_body_class .= ' admin-bar';
388
-        }
386
+		if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) {
387
+			$admin_body_class .= ' admin-bar';
388
+		}
389 389
 
390
-        if ( is_rtl() ) {
391
-        	$admin_body_class .= ' rtl';
392
-        }
390
+		if ( is_rtl() ) {
391
+			$admin_body_class .= ' rtl';
392
+		}
393 393
 
394
-        $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
395
-        $prepop = array();
396
-        FrmFieldsHelper::get_bulk_prefilled_opts($prepop);
394
+		$admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
395
+		$prepop = array();
396
+		FrmFieldsHelper::get_bulk_prefilled_opts($prepop);
397 397
 
398
-        $field = FrmField::getOne($field_id);
398
+		$field = FrmField::getOne($field_id);
399 399
 
400
-        wp_enqueue_script( 'utils' );
400
+		wp_enqueue_script( 'utils' );
401 401
 		wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' );
402
-        FrmAppHelper::load_admin_wide_js();
402
+		FrmAppHelper::load_admin_wide_js();
403 403
 
404 404
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/import_choices.php' );
405
-        wp_die();
406
-    }
405
+		wp_die();
406
+	}
407 407
 
408
-    public static function import_options() {
408
+	public static function import_options() {
409 409
 		FrmAppHelper::permission_check('frm_edit_forms');
410
-        check_ajax_referer( 'frm_ajax', 'nonce' );
410
+		check_ajax_referer( 'frm_ajax', 'nonce' );
411 411
 
412
-        if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) {
413
-            return;
414
-        }
412
+		if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) {
413
+			return;
414
+		}
415 415
 
416 416
 		$field_id = absint( $_POST['field_id'] );
417
-        $field = FrmField::getOne($field_id);
417
+		$field = FrmField::getOne($field_id);
418 418
 
419 419
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) {
420
-            return;
421
-        }
420
+			return;
421
+		}
422 422
 
423
-        $field = FrmFieldsHelper::setup_edit_vars($field);
423
+		$field = FrmFieldsHelper::setup_edit_vars($field);
424 424
 		$opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' );
425 425
 		$opts = explode( "\n", rtrim( $opts, "\n" ) );
426 426
 		$opts = array_map( 'trim', $opts );
427 427
 
428
-        if ( $field['separate_value'] ) {
429
-            foreach ( $opts as $opt_key => $opt ) {
430
-                if ( strpos($opt, '|') !== false ) {
431
-                    $vals = explode('|', $opt);
432
-                    if ( $vals[0] != $vals[1] ) {
433
-                        $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
434
-                    }
435
-                    unset($vals);
436
-                }
437
-                unset($opt_key, $opt);
438
-            }
439
-        }
440
-
441
-        //Keep other options after bulk update
442
-        if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) {
443
-            $other_array = array();
444
-            foreach ( $field['options'] as $opt_key => $opt ) {
445
-                if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) {
446
-                    $other_array[ $opt_key ] = $opt;
447
-                }
448
-                unset($opt_key, $opt);
449
-            }
450
-            if ( ! empty($other_array) ) {
451
-                $opts = array_merge( $opts, $other_array);
452
-            }
453
-        }
454
-
455
-        FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) );
456
-
457
-        $field['options'] = $opts;
458
-        $field_name = $field['name'];
459
-
460
-        // Get html_id which will be used in single-option.php
461
-        $html_id = FrmFieldsHelper::get_html_id( $field );
462
-
463
-        if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
428
+		if ( $field['separate_value'] ) {
429
+			foreach ( $opts as $opt_key => $opt ) {
430
+				if ( strpos($opt, '|') !== false ) {
431
+					$vals = explode('|', $opt);
432
+					if ( $vals[0] != $vals[1] ) {
433
+						$opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
434
+					}
435
+					unset($vals);
436
+				}
437
+				unset($opt_key, $opt);
438
+			}
439
+		}
440
+
441
+		//Keep other options after bulk update
442
+		if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) {
443
+			$other_array = array();
444
+			foreach ( $field['options'] as $opt_key => $opt ) {
445
+				if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) {
446
+					$other_array[ $opt_key ] = $opt;
447
+				}
448
+				unset($opt_key, $opt);
449
+			}
450
+			if ( ! empty($other_array) ) {
451
+				$opts = array_merge( $opts, $other_array);
452
+			}
453
+		}
454
+
455
+		FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) );
456
+
457
+		$field['options'] = $opts;
458
+		$field_name = $field['name'];
459
+
460
+		// Get html_id which will be used in single-option.php
461
+		$html_id = FrmFieldsHelper::get_html_id( $field );
462
+
463
+		if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
464 464
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' );
465
-        } else {
466
-            FrmFieldsHelper::show_single_option($field);
467
-        }
465
+		} else {
466
+			FrmFieldsHelper::show_single_option($field);
467
+		}
468 468
 
469
-        wp_die();
470
-    }
469
+		wp_die();
470
+	}
471 471
 
472
-    public static function update_order() {
472
+	public static function update_order() {
473 473
 		FrmAppHelper::permission_check('frm_edit_forms');
474
-        check_ajax_referer( 'frm_ajax', 'nonce' );
474
+		check_ajax_referer( 'frm_ajax', 'nonce' );
475 475
 
476 476
 		$fields = FrmAppHelper::get_post_param( 'frm_field_id' );
477 477
 		foreach ( (array) $fields as $position => $item ) {
478 478
 			FrmField::update( absint( $item ), array( 'field_order' => absint( $position ) ) );
479 479
 		}
480
-        wp_die();
481
-    }
480
+		wp_die();
481
+	}
482 482
 
483 483
 	public static function change_type( $type ) {
484
-        $type_switch = array(
485
-            'scale'     => 'radio',
486
-            '10radio'   => 'radio',
487
-            'rte'       => 'textarea',
488
-            'website'   => 'url',
489
-        );
490
-        if ( isset( $type_switch[ $type ] ) ) {
491
-            $type = $type_switch[ $type ];
492
-        }
484
+		$type_switch = array(
485
+			'scale'     => 'radio',
486
+			'10radio'   => 'radio',
487
+			'rte'       => 'textarea',
488
+			'website'   => 'url',
489
+		);
490
+		if ( isset( $type_switch[ $type ] ) ) {
491
+			$type = $type_switch[ $type ];
492
+		}
493 493
 
494 494
 		$frm_field_selection = FrmField::field_selection();
495
-        $types = array_keys($frm_field_selection);
496
-        if ( ! in_array($type, $types) && $type != 'captcha' ) {
497
-            $type = 'text';
498
-        }
495
+		$types = array_keys($frm_field_selection);
496
+		if ( ! in_array($type, $types) && $type != 'captcha' ) {
497
+			$type = 'text';
498
+		}
499 499
 
500
-        return $type;
501
-    }
500
+		return $type;
501
+	}
502 502
 
503 503
 	public static function display_field_options( $display ) {
504 504
 		switch ( $display['type'] ) {
505
-            case 'captcha':
506
-                $display['required'] = false;
507
-                $display['invalid'] = true;
508
-                $display['default_blank'] = false;
505
+			case 'captcha':
506
+				$display['required'] = false;
507
+				$display['invalid'] = true;
508
+				$display['default_blank'] = false;
509 509
 				$display['captcha_size'] = true;
510
-            break;
511
-            case 'radio':
512
-                $display['default_blank'] = false;
513
-            break;
514
-            case 'text':
515
-            case 'textarea':
516
-                $display['size'] = true;
517
-                $display['clear_on_focus'] = true;
518
-            break;
519
-            case 'select':
520
-                $display['size'] = true;
521
-            break;
522
-            case 'url':
523
-            case 'website':
524
-            case 'email':
525
-                $display['size'] = true;
526
-                $display['clear_on_focus'] = true;
527
-                $display['invalid'] = true;
528
-        }
529
-
530
-        return $display;
531
-    }
532
-
533
-    public static function input_html( $field, $echo = true ) {
534
-        $class = array(); //$field['type'];
535
-        self::add_input_classes($field, $class);
536
-
537
-        $add_html = array();
538
-        self::add_html_size($field, $add_html);
539
-        self::add_html_length($field, $add_html);
540
-        self::add_html_placeholder($field, $add_html, $class);
510
+			break;
511
+			case 'radio':
512
+				$display['default_blank'] = false;
513
+			break;
514
+			case 'text':
515
+			case 'textarea':
516
+				$display['size'] = true;
517
+				$display['clear_on_focus'] = true;
518
+			break;
519
+			case 'select':
520
+				$display['size'] = true;
521
+			break;
522
+			case 'url':
523
+			case 'website':
524
+			case 'email':
525
+				$display['size'] = true;
526
+				$display['clear_on_focus'] = true;
527
+				$display['invalid'] = true;
528
+		}
529
+
530
+		return $display;
531
+	}
532
+
533
+	public static function input_html( $field, $echo = true ) {
534
+		$class = array(); //$field['type'];
535
+		self::add_input_classes($field, $class);
536
+
537
+		$add_html = array();
538
+		self::add_html_size($field, $add_html);
539
+		self::add_html_length($field, $add_html);
540
+		self::add_html_placeholder($field, $add_html, $class);
541 541
 		self::add_validation_messages( $field, $add_html );
542 542
 
543
-        $class = apply_filters('frm_field_classes', implode(' ', $class), $field);
543
+		$class = apply_filters('frm_field_classes', implode(' ', $class), $field);
544 544
 
545 545
 		FrmFormsHelper::add_html_attr( $class, 'class', $add_html );
546 546
 
547
-        self::add_shortcodes_to_html($field, $add_html);
547
+		self::add_shortcodes_to_html($field, $add_html);
548 548
 
549 549
 		$add_html = apply_filters( 'frm_field_extra_html', $add_html, $field );
550 550
 		$add_html = ' ' . implode( ' ', $add_html ) . '  ';
551 551
 
552
-        if ( $echo ) {
553
-            echo $add_html;
554
-        }
552
+		if ( $echo ) {
553
+			echo $add_html;
554
+		}
555 555
 
556
-        return $add_html;
557
-    }
556
+		return $add_html;
557
+	}
558 558
 
559 559
 	private static function add_input_classes( $field, array &$class ) {
560
-        if ( isset($field['input_class']) && ! empty($field['input_class']) ) {
561
-            $class[] = $field['input_class'];
562
-        }
560
+		if ( isset($field['input_class']) && ! empty($field['input_class']) ) {
561
+			$class[] = $field['input_class'];
562
+		}
563 563
 
564
-        if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) {
565
-            return;
566
-        }
564
+		if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) {
565
+			return;
566
+		}
567 567
 
568
-        if ( isset($field['size']) && $field['size'] > 0 ) {
569
-            $class[] = 'auto_width';
570
-        }
571
-    }
568
+		if ( isset($field['size']) && $field['size'] > 0 ) {
569
+			$class[] = 'auto_width';
570
+		}
571
+	}
572 572
 
573 573
 	private static function add_html_size( $field, array &$add_html ) {
574 574
 		if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], array( 'select', 'data', 'time', 'hidden', 'file', 'lookup' ) ) ) {
575
-            return;
576
-        }
575
+			return;
576
+		}
577 577
 
578
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
579
-            return;
580
-        }
578
+		if ( FrmAppHelper::is_admin_page('formidable' ) ) {
579
+			return;
580
+		}
581 581
 
582
-        if ( is_numeric($field['size']) ) {
583
-            $field['size'] .= 'px';
584
-        }
582
+		if ( is_numeric($field['size']) ) {
583
+			$field['size'] .= 'px';
584
+		}
585 585
 
586
-        $important = apply_filters('frm_use_important_width', 1, $field);
587
-        // Note: This inline styling must stay since we cannot realistically set a class for every possible field size
586
+		$important = apply_filters('frm_use_important_width', 1, $field);
587
+		// Note: This inline styling must stay since we cannot realistically set a class for every possible field size
588 588
 		$add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"';
589 589
 
590
-        self::add_html_cols($field, $add_html);
591
-    }
590
+		self::add_html_cols($field, $add_html);
591
+	}
592 592
 
593 593
 	private static function add_html_cols( $field, array &$add_html ) {
594 594
 		if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) {
595
-            return;
596
-        }
595
+			return;
596
+		}
597 597
 
598
-        // convert to cols for textareas
599
-        $calc = array(
600
-            ''      => 9,
601
-            'px'    => 9,
602
-            'rem'   => 0.444,
603
-            'em'    => 0.544,
604
-        );
598
+		// convert to cols for textareas
599
+		$calc = array(
600
+			''      => 9,
601
+			'px'    => 9,
602
+			'rem'   => 0.444,
603
+			'em'    => 0.544,
604
+		);
605 605
 
606
-        // include "col" for valid html
607
-        $unit = trim(preg_replace('/[0-9]+/', '', $field['size']));
606
+		// include "col" for valid html
607
+		$unit = trim(preg_replace('/[0-9]+/', '', $field['size']));
608 608
 
609
-        if ( ! isset( $calc[ $unit ] ) ) {
610
-            return;
611
-        }
609
+		if ( ! isset( $calc[ $unit ] ) ) {
610
+			return;
611
+		}
612 612
 
613
-        $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
613
+		$size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
614 614
 
615 615
 		$add_html['cols'] = 'cols="' . absint( $size ) . '"';
616
-    }
616
+	}
617 617
 
618 618
 	private static function add_html_length( $field, array &$add_html ) {
619
-        // check for max setting and if this field accepts maxlength
619
+		// check for max setting and if this field accepts maxlength
620 620
 		if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], array( 'textarea', 'rte', 'hidden', 'file' ) ) ) {
621
-            return;
622
-        }
621
+			return;
622
+		}
623 623
 
624
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
625
-            // don't load on form builder page
626
-            return;
627
-        }
624
+		if ( FrmAppHelper::is_admin_page('formidable' ) ) {
625
+			// don't load on form builder page
626
+			return;
627
+		}
628 628
 
629 629
 		$add_html['maxlength'] = 'maxlength="' . esc_attr( $field['max'] ) . '"';
630
-    }
630
+	}
631 631
 
632 632
 	private static function add_html_placeholder( $field, array &$add_html, array &$class ) {
633 633
 		if ( empty( $field['default_value'] ) || FrmAppHelper::is_admin_page( 'formidable' ) ) {
@@ -635,35 +635,35 @@  discard block
 block discarded – undo
635 635
 		}
636 636
 
637 637
 		$default_value_array = is_array( $field['default_value'] );
638
-        if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) {
638
+		if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) {
639 639
 			if ( $default_value_array ) {
640 640
 				$field['default_value'] = json_encode( $field['default_value'] );
641 641
 			}
642 642
 			$add_html['data-frmval'] = 'data-frmval="' . esc_attr( $field['default_value'] ) . '"';
643
-            return;
644
-        }
643
+			return;
644
+		}
645 645
 
646 646
 		if ( $default_value_array ) {
647 647
 			// don't include a json placeholder
648 648
 			return;
649 649
 		}
650 650
 
651
-        $frm_settings = FrmAppHelper::get_settings();
651
+		$frm_settings = FrmAppHelper::get_settings();
652 652
 
653 653
 		if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) {
654
-            // use HMTL5 placeholder with js fallback
654
+			// use HMTL5 placeholder with js fallback
655 655
 			$add_html['placeholder'] = 'placeholder="' . esc_attr( $field['default_value'] ) . '"';
656
-            wp_enqueue_script('jquery-placeholder');
657
-        } else if ( ! $frm_settings->use_html ) {
656
+			wp_enqueue_script('jquery-placeholder');
657
+		} else if ( ! $frm_settings->use_html ) {
658 658
 			$val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( '&#039;', "'", esc_attr( $field['default_value'] ) ) ) );
659 659
 			$add_html['data-frmval'] = 'data-frmval="' . esc_attr( $val ) . '"';
660
-            $class[] = 'frm_toggle_default';
660
+			$class[] = 'frm_toggle_default';
661 661
 
662
-            if ( $field['value'] == $field['default_value'] ) {
663
-                $class[] = 'frm_default';
664
-            }
665
-        }
666
-    }
662
+			if ( $field['value'] == $field['default_value'] ) {
663
+				$class[] = 'frm_default';
664
+			}
665
+		}
666
+	}
667 667
 
668 668
 	private static function add_validation_messages( $field, array &$add_html ) {
669 669
 		if ( FrmField::is_required( $field ) ) {
@@ -677,44 +677,44 @@  discard block
 block discarded – undo
677 677
 		}
678 678
 	}
679 679
 
680
-    private static function add_shortcodes_to_html( $field, array &$add_html ) {
681
-        if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
682
-            return;
683
-        }
680
+	private static function add_shortcodes_to_html( $field, array &$add_html ) {
681
+		if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
682
+			return;
683
+		}
684 684
 
685
-        foreach ( $field['shortcodes'] as $k => $v ) {
686
-            if ( 'opt' === $k ) {
687
-                continue;
688
-            }
685
+		foreach ( $field['shortcodes'] as $k => $v ) {
686
+			if ( 'opt' === $k ) {
687
+				continue;
688
+			}
689 689
 
690
-            if ( is_numeric($k) && strpos($v, '=') ) {
691
-                $add_html[] = $v;
692
-            } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
690
+			if ( is_numeric($k) && strpos($v, '=') ) {
691
+				$add_html[] = $v;
692
+			} else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
693 693
 				$add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] );
694
-            } else {
694
+			} else {
695 695
 				$add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"';
696
-            }
697
-
698
-            unset($k, $v);
699
-        }
700
-    }
701
-
702
-    public static function check_value( $opt, $opt_key, $field ) {
703
-        if ( is_array( $opt ) ) {
704
-            if ( FrmField::is_option_true( $field, 'separate_value' ) ) {
705
-                $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
706
-            } else {
707
-                $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
708
-            }
709
-        }
710
-        return $opt;
711
-    }
696
+			}
697
+
698
+			unset($k, $v);
699
+		}
700
+	}
701
+
702
+	public static function check_value( $opt, $opt_key, $field ) {
703
+		if ( is_array( $opt ) ) {
704
+			if ( FrmField::is_option_true( $field, 'separate_value' ) ) {
705
+				$opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
706
+			} else {
707
+				$opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
708
+			}
709
+		}
710
+		return $opt;
711
+	}
712 712
 
713 713
 	public static function check_label( $opt ) {
714
-        if ( is_array($opt) ) {
715
-            $opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
716
-        }
714
+		if ( is_array($opt) ) {
715
+			$opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
716
+		}
717 717
 
718
-        return $opt;
719
-    }
718
+		return $opt;
719
+	}
720 720
 }
Please login to merge, or discard this patch.
classes/models/FrmNotification.php 2 patches
Indentation   +256 added lines, -256 removed lines patch added patch discarded remove patch
@@ -2,160 +2,160 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmNotification {
4 4
 	public function __construct() {
5
-        if ( ! defined('ABSPATH') ) {
6
-            die('You are not allowed to call this page directly.');
7
-        }
8
-        add_action('frm_trigger_email_action', 'FrmNotification::trigger_email', 10, 3);
9
-    }
5
+		if ( ! defined('ABSPATH') ) {
6
+			die('You are not allowed to call this page directly.');
7
+		}
8
+		add_action('frm_trigger_email_action', 'FrmNotification::trigger_email', 10, 3);
9
+	}
10 10
 
11 11
 	public static function trigger_email( $action, $entry, $form ) {
12
-        $notification = $action->post_content;
13
-        $email_key = $action->ID;
14
-
15
-        // Set the subject
16
-        if ( empty($notification['email_subject']) ) {
17
-            $notification['email_subject'] = sprintf(__( '%1$s Form submitted on %2$s', 'formidable' ), $form->name, '[sitename]');
18
-        }
19
-
20
-        $plain_text = $notification['plain_text'] ? true : false;
21
-
22
-        //Filter these fields
23
-        $filter_fields = array(
24
-            'email_to', 'cc', 'bcc',
25
-            'reply_to', 'from',
26
-            'email_subject', 'email_message',
27
-        );
28
-
29
-        add_filter('frm_plain_text_email', ($plain_text ? '__return_true' : '__return_false'));
30
-
31
-        //Get all values in entry in order to get User ID field ID
32
-        $values = FrmEntryMeta::getAll( array( 'it.field_id !' => 0, 'it.item_id' => $entry->id ), ' ORDER BY fi.field_order' );
33
-        $user_id_field = $user_id_key = '';
34
-        foreach ( $values as $value ) {
35
-            if ( $value->field_type == 'user_id' ) {
36
-                $user_id_field = $value->field_id;
37
-                $user_id_key = $value->field_key;
38
-                break;
39
-            }
40
-            unset($value);
41
-        }
42
-
43
-        //Filter and prepare the email fields
44
-        foreach ( $filter_fields as $f ) {
45
-            //Don't allow empty From
12
+		$notification = $action->post_content;
13
+		$email_key = $action->ID;
14
+
15
+		// Set the subject
16
+		if ( empty($notification['email_subject']) ) {
17
+			$notification['email_subject'] = sprintf(__( '%1$s Form submitted on %2$s', 'formidable' ), $form->name, '[sitename]');
18
+		}
19
+
20
+		$plain_text = $notification['plain_text'] ? true : false;
21
+
22
+		//Filter these fields
23
+		$filter_fields = array(
24
+			'email_to', 'cc', 'bcc',
25
+			'reply_to', 'from',
26
+			'email_subject', 'email_message',
27
+		);
28
+
29
+		add_filter('frm_plain_text_email', ($plain_text ? '__return_true' : '__return_false'));
30
+
31
+		//Get all values in entry in order to get User ID field ID
32
+		$values = FrmEntryMeta::getAll( array( 'it.field_id !' => 0, 'it.item_id' => $entry->id ), ' ORDER BY fi.field_order' );
33
+		$user_id_field = $user_id_key = '';
34
+		foreach ( $values as $value ) {
35
+			if ( $value->field_type == 'user_id' ) {
36
+				$user_id_field = $value->field_id;
37
+				$user_id_key = $value->field_key;
38
+				break;
39
+			}
40
+			unset($value);
41
+		}
42
+
43
+		//Filter and prepare the email fields
44
+		foreach ( $filter_fields as $f ) {
45
+			//Don't allow empty From
46 46
 			if ( $f == 'from' && empty( $notification[ $f ] ) ) {
47 47
 				$notification[ $f ] = '[admin_email]';
48 48
 			} else if ( in_array( $f, array( 'email_to', 'cc', 'bcc', 'reply_to', 'from' ) ) ) {
49 49
 				//Remove brackets
50
-                //Add a space in case there isn't one
50
+				//Add a space in case there isn't one
51 51
 				$notification[ $f ] = str_replace( '<', ' ', $notification[ $f ] );
52 52
 				$notification[ $f ] = str_replace( array( '"', '>' ), '', $notification[ $f ] );
53 53
 
54
-                //Switch userID shortcode to email address
54
+				//Switch userID shortcode to email address
55 55
 				if ( strpos( $notification[ $f ], '[' . $user_id_field . ']' ) !== false || strpos( $notification[ $f ], '[' . $user_id_key . ']' ) !== false ) {
56 56
 					$user_data = get_userdata( $entry->metas[ $user_id_field ] );
57
-                    $user_email = $user_data->user_email;
57
+					$user_email = $user_data->user_email;
58 58
 					$notification[ $f ] = str_replace( array( '[' . $user_id_field . ']', '[' . $user_id_key . ']' ), $user_email, $notification[ $f ] );
59
-                }
60
-            }
59
+				}
60
+			}
61 61
 
62 62
 			$notification[ $f ] = FrmFieldsHelper::basic_replace_shortcodes( $notification[ $f ], $form, $entry );
63
-        }
63
+		}
64 64
 
65
-        //Put recipients, cc, and bcc into an array if they aren't empty
65
+		//Put recipients, cc, and bcc into an array if they aren't empty
66 66
 		$to_emails = self::explode_emails( $notification['email_to'] );
67 67
 		$cc = self::explode_emails( $notification['cc'] );
68 68
 		$bcc = self::explode_emails( $notification['bcc'] );
69 69
 
70
-        $to_emails = apply_filters('frm_to_email', $to_emails, $values, $form->id, compact('email_key', 'entry', 'form'));
70
+		$to_emails = apply_filters('frm_to_email', $to_emails, $values, $form->id, compact('email_key', 'entry', 'form'));
71 71
 
72
-        // Stop now if there aren't any recipients
73
-        if ( empty( $to_emails ) && empty( $cc ) && empty( $bcc ) ) {
74
-            return;
75
-        }
72
+		// Stop now if there aren't any recipients
73
+		if ( empty( $to_emails ) && empty( $cc ) && empty( $bcc ) ) {
74
+			return;
75
+		}
76 76
 
77
-        $to_emails = array_unique( (array) $to_emails );
77
+		$to_emails = array_unique( (array) $to_emails );
78 78
 
79
-        $prev_mail_body = $mail_body = $notification['email_message'];
80
-        $mail_body = FrmEntriesHelper::replace_default_message($mail_body, array(
81
-            'id' => $entry->id, 'entry' => $entry, 'plain_text' => $plain_text,
82
-            'user_info' => (isset($notification['inc_user_info']) ? $notification['inc_user_info'] : false),
83
-        ) );
79
+		$prev_mail_body = $mail_body = $notification['email_message'];
80
+		$mail_body = FrmEntriesHelper::replace_default_message($mail_body, array(
81
+			'id' => $entry->id, 'entry' => $entry, 'plain_text' => $plain_text,
82
+			'user_info' => (isset($notification['inc_user_info']) ? $notification['inc_user_info'] : false),
83
+		) );
84 84
 
85
-        // Add the user info if it isn't already included
86
-        if ( $notification['inc_user_info'] && $prev_mail_body == $mail_body ) {
87
-            $data = maybe_unserialize($entry->description);
85
+		// Add the user info if it isn't already included
86
+		if ( $notification['inc_user_info'] && $prev_mail_body == $mail_body ) {
87
+			$data = maybe_unserialize($entry->description);
88 88
 			$mail_body .= "\r\n\r\n" . __( 'User Information', 'formidable' ) . "\r\n";
89 89
 			$mail_body .= __( 'IP Address', 'formidable' ) . ': ' . $entry->ip . "\r\n";
90 90
 			$mail_body .= __( 'User-Agent (Browser/OS)', 'formidable' ) . ': ' . FrmEntryFormat::get_browser( $data['browser'] ) . "\r\n";
91 91
 			$mail_body .= __( 'Referrer', 'formidable' ) . ': ' . $data['referrer'] . "\r\n";
92
-        }
93
-        unset($prev_mail_body);
94
-
95
-        // Add attachments
96
-        $attachments = apply_filters('frm_notification_attachment', array(), $form, compact('entry', 'email_key') );
97
-
98
-        if ( ! empty($notification['email_subject']) ) {
99
-            $notification['email_subject'] = apply_filters('frm_email_subject', $notification['email_subject'], compact('form', 'entry', 'email_key'));
100
-        }
101
-
102
-        // check for a phone number
103
-        foreach ( (array) $to_emails as $email_key => $e ) {
104
-            if ( $e != '[admin_email]' && ! is_email($e) ) {
105
-                $e = explode(' ', $e);
106
-
107
-                //If to_email has name <[email protected]> format
108
-                if ( is_email(end($e)) ) {
109
-                    continue;
110
-                }
111
-
112
-                do_action('frm_send_to_not_email', array(
113
-                    'e'         => $e,
114
-                    'subject'   => $notification['email_subject'],
115
-                    'mail_body' => $mail_body,
116
-                    'reply_to'  => $notification['reply_to'],
117
-                    'from'      => $notification['from'],
118
-                    'plain_text' => $plain_text,
119
-                    'attachments' => $attachments,
120
-                    'form'      => $form,
121
-                    'email_key' => $email_key,
122
-                ) );
92
+		}
93
+		unset($prev_mail_body);
94
+
95
+		// Add attachments
96
+		$attachments = apply_filters('frm_notification_attachment', array(), $form, compact('entry', 'email_key') );
97
+
98
+		if ( ! empty($notification['email_subject']) ) {
99
+			$notification['email_subject'] = apply_filters('frm_email_subject', $notification['email_subject'], compact('form', 'entry', 'email_key'));
100
+		}
101
+
102
+		// check for a phone number
103
+		foreach ( (array) $to_emails as $email_key => $e ) {
104
+			if ( $e != '[admin_email]' && ! is_email($e) ) {
105
+				$e = explode(' ', $e);
106
+
107
+				//If to_email has name <[email protected]> format
108
+				if ( is_email(end($e)) ) {
109
+					continue;
110
+				}
111
+
112
+				do_action('frm_send_to_not_email', array(
113
+					'e'         => $e,
114
+					'subject'   => $notification['email_subject'],
115
+					'mail_body' => $mail_body,
116
+					'reply_to'  => $notification['reply_to'],
117
+					'from'      => $notification['from'],
118
+					'plain_text' => $plain_text,
119
+					'attachments' => $attachments,
120
+					'form'      => $form,
121
+					'email_key' => $email_key,
122
+				) );
123 123
 
124 124
 				unset( $to_emails[ $email_key ] );
125
-            }
126
-        }
127
-
128
-        // Send the email now
129
-        $sent_to = self::send_email( array(
130
-            'to_email'      => $to_emails,
131
-            'subject'       => $notification['email_subject'],
132
-            'message'       => $mail_body,
133
-            'from'          => $notification['from'],
134
-            'plain_text'    => $plain_text,
135
-            'reply_to'      => $notification['reply_to'],
136
-            'attachments'   => $attachments,
137
-            'cc'            => $cc,
138
-            'bcc'           => $bcc,
139
-        ) );
140
-
141
-        return $sent_to;
142
-    }
125
+			}
126
+		}
127
+
128
+		// Send the email now
129
+		$sent_to = self::send_email( array(
130
+			'to_email'      => $to_emails,
131
+			'subject'       => $notification['email_subject'],
132
+			'message'       => $mail_body,
133
+			'from'          => $notification['from'],
134
+			'plain_text'    => $plain_text,
135
+			'reply_to'      => $notification['reply_to'],
136
+			'attachments'   => $attachments,
137
+			'cc'            => $cc,
138
+			'bcc'           => $bcc,
139
+		) );
140
+
141
+		return $sent_to;
142
+	}
143 143
 
144 144
 	public function entry_created( $entry_id, $form_id ) {
145 145
 		$new_function = 'FrmFormActionsController::trigger_actions("create", ' . $form_id . ', ' . $entry_id . ', "email")';
146 146
 		_deprecated_function( __FUNCTION__, '2.0', $new_function );
147
-        FrmFormActionsController::trigger_actions('create', $form_id, $entry_id, 'email');
148
-    }
147
+		FrmFormActionsController::trigger_actions('create', $form_id, $entry_id, 'email');
148
+	}
149 149
 
150 150
 	public function send_notification_email( $to_email, $subject, $message, $from = '', $from_name = '', $plain_text = true, $attachments = array(), $reply_to = '' ) {
151
-        _deprecated_function( __FUNCTION__, '2.0', 'FrmNotification::send_email' );
151
+		_deprecated_function( __FUNCTION__, '2.0', 'FrmNotification::send_email' );
152 152
 
153
-        return self::send_email(compact(
154
-            'to_email', 'subject', 'message',
155
-            'from', 'from_name', 'plain_text',
156
-            'attachments', 'reply_to'
157
-        ));
158
-    }
153
+		return self::send_email(compact(
154
+			'to_email', 'subject', 'message',
155
+			'from', 'from_name', 'plain_text',
156
+			'attachments', 'reply_to'
157
+		));
158
+	}
159 159
 
160 160
 	/**
161 161
 	 * Extract the emails from cc and bcc. Allow separation by , or ;.
@@ -173,53 +173,53 @@  discard block
 block discarded – undo
173 173
 		return $emails;
174 174
 	}
175 175
 
176
-    /**
177
-    * Put To, BCC, CC, Reply To, and From fields in Name <[email protected]> format
178
-    * Formats that should work: Name, "Name", [email protected], <[email protected]>, Name <[email protected]>,
179
-    * "Name" <[email protected]>, Name [email protected], "Name" [email protected], Name<[email protected]>, "Name"<[email protected]>
180
-    * "First Last" <[email protected]>
181
-    *
182
-    * Things that won't work: First Last (with no email entered)
183
-    * @since 2.0
184
-    * @param array $atts array of email fields, pass by reference
185
-    * @param $admin_email
186
-    */
187
-    private static function format_email_fields( &$atts, $admin_email ) {
188
-
189
-        // If from is empty or is set to admin_email, set it now
190
-        $atts['from'] = ( empty($atts['from']) || $atts['from'] == '[admin_email]' ) ? $admin_email : $atts['from'];
191
-
192
-        // Filter values in these fields
176
+	/**
177
+	 * Put To, BCC, CC, Reply To, and From fields in Name <[email protected]> format
178
+	 * Formats that should work: Name, "Name", [email protected], <[email protected]>, Name <[email protected]>,
179
+	 * "Name" <[email protected]>, Name [email protected], "Name" [email protected], Name<[email protected]>, "Name"<[email protected]>
180
+	 * "First Last" <[email protected]>
181
+	 *
182
+	 * Things that won't work: First Last (with no email entered)
183
+	 * @since 2.0
184
+	 * @param array $atts array of email fields, pass by reference
185
+	 * @param $admin_email
186
+	 */
187
+	private static function format_email_fields( &$atts, $admin_email ) {
188
+
189
+		// If from is empty or is set to admin_email, set it now
190
+		$atts['from'] = ( empty($atts['from']) || $atts['from'] == '[admin_email]' ) ? $admin_email : $atts['from'];
191
+
192
+		// Filter values in these fields
193 193
 		$filter_fields = array( 'to_email', 'bcc', 'cc', 'from', 'reply_to' );
194 194
 
195
-        foreach ( $filter_fields as $f ) {
196
-            // If empty, just skip it
195
+		foreach ( $filter_fields as $f ) {
196
+			// If empty, just skip it
197 197
 			if ( empty( $atts[ $f ] ) ) {
198
-                continue;
199
-            }
198
+				continue;
199
+			}
200 200
 
201
-            // to_email, cc, and bcc can be an array
201
+			// to_email, cc, and bcc can be an array
202 202
 			if ( is_array( $atts[ $f ] ) ) {
203 203
 				foreach ( $atts[ $f ] as $key => $val ) {
204
-                    self::format_single_field( $atts, $f, $val, $key );
205
-                    unset( $key, $val );
206
-                }
207
-                unset($f);
208
-                continue;
209
-            }
204
+					self::format_single_field( $atts, $f, $val, $key );
205
+					unset( $key, $val );
206
+				}
207
+				unset($f);
208
+				continue;
209
+			}
210 210
 
211 211
 			self::format_single_field( $atts, $f, $atts[ $f ] );
212
-        }
212
+		}
213 213
 
214
-        // If reply-to isn't set, make it match the from settings
215
-        if ( empty( $atts['reply_to'] ) ) {
216
-            $atts['reply_to'] = self::get_email_from_formatted_string( $atts['from'] );
217
-        }
214
+		// If reply-to isn't set, make it match the from settings
215
+		if ( empty( $atts['reply_to'] ) ) {
216
+			$atts['reply_to'] = self::get_email_from_formatted_string( $atts['from'] );
217
+		}
218 218
 
219
-        if ( ! is_array($atts['to_email']) && '[admin_email]' == $atts['to_email'] ) {
220
-            $atts['to_email'] = $admin_email;
221
-        }
222
-    }
219
+		if ( ! is_array($atts['to_email']) && '[admin_email]' == $atts['to_email'] ) {
220
+			$atts['to_email'] = $admin_email;
221
+		}
222
+	}
223 223
 
224 224
 	private static function get_email_from_formatted_string( $value ) {
225 225
 		if ( strpos( $value, '<' ) !== false ) {
@@ -229,48 +229,48 @@  discard block
 block discarded – undo
229 229
 		return $value;
230 230
 	}
231 231
 
232
-    /**
233
-    * Format individual email fields
234
-    *
235
-    * @since 2.0
236
-    * @param array $atts pass by reference
237
-    * @param string $f (to, from, reply_to, etc)
238
-    * @param string $val value saved in field
239
-    * @param int $key if in array, this will be set
240
-    */
241
-    private static function format_single_field( &$atts, $f, $val, $key = false ) {
242
-        $val = trim($val);
243
-
244
-        // If just a plain email is used
245
-        if ( is_email($val) ) {
246
-            // add sender's name if not included in $from
247
-            if ( $f == 'from' ) {
232
+	/**
233
+	 * Format individual email fields
234
+	 *
235
+	 * @since 2.0
236
+	 * @param array $atts pass by reference
237
+	 * @param string $f (to, from, reply_to, etc)
238
+	 * @param string $val value saved in field
239
+	 * @param int $key if in array, this will be set
240
+	 */
241
+	private static function format_single_field( &$atts, $f, $val, $key = false ) {
242
+		$val = trim($val);
243
+
244
+		// If just a plain email is used
245
+		if ( is_email($val) ) {
246
+			// add sender's name if not included in $from
247
+			if ( $f == 'from' ) {
248 248
 				$part_2 = $atts[ $f ];
249
-                $part_1  = $atts['from_name'] ? $atts['from_name'] : wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
250
-            } else {
251
-                return;
252
-            }
253
-        } else {
254
-            $parts = explode(' ', $val);
255
-            $part_2 = end($parts);
256
-
257
-            // If inputted correcly, $part_2 should be an email
258
-            if ( is_email( $part_2 ) ) {
259
-                $part_1 = trim( str_replace( $part_2, '', $val ) );
260
-            } else if ( in_array( $f, array( 'from', 'reply_to' ) ) ) {
249
+				$part_1  = $atts['from_name'] ? $atts['from_name'] : wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
250
+			} else {
251
+				return;
252
+			}
253
+		} else {
254
+			$parts = explode(' ', $val);
255
+			$part_2 = end($parts);
256
+
257
+			// If inputted correcly, $part_2 should be an email
258
+			if ( is_email( $part_2 ) ) {
259
+				$part_1 = trim( str_replace( $part_2, '', $val ) );
260
+			} else if ( in_array( $f, array( 'from', 'reply_to' ) ) ) {
261 261
 				// In case someone just puts a name in the From or Reply To field
262 262
 				$part_1 = $val;
263
-                $part_2 = get_option('admin_email');
264
-            } else {
263
+				$part_2 = get_option('admin_email');
264
+			} else {
265 265
 				// In case someone just puts a name in any other email field
266
-                if ( false !== $key ) {
266
+				if ( false !== $key ) {
267 267
 					unset( $atts[ $f ][ $key ] );
268
-                    return;
269
-                }
268
+					return;
269
+				}
270 270
 				$atts[ $f ] = '';
271
-                return;
272
-            }
273
-        }
271
+				return;
272
+			}
273
+		}
274 274
 
275 275
 		// if sending the email from a yahoo address, change it to the WordPress default
276 276
 		if ( $f == 'from' && strpos( $part_2, '@yahoo.com' ) ) {
@@ -283,110 +283,110 @@  discard block
 block discarded – undo
283 283
 			$part_2 = 'wordpress@' . $sitename;
284 284
 		}
285 285
 
286
-        // Set up formatted value
286
+		// Set up formatted value
287 287
 		$final_val = str_replace( '"', '', $part_1 ) . ' <' . $part_2 . '>';
288 288
 
289
-        // If value is an array
290
-        if ( false !== $key ) {
289
+		// If value is an array
290
+		if ( false !== $key ) {
291 291
 			$atts[ $f ][ $key ] = $final_val;
292
-            return;
293
-        }
292
+			return;
293
+		}
294 294
 		$atts[ $f ] = $final_val;
295
-    }
295
+	}
296 296
 
297 297
 	public static function send_email( $atts ) {
298
-        $admin_email = get_option('admin_email');
299
-        $defaults = array(
300
-            'to_email'      => $admin_email,
301
-            'subject'       => '',
302
-            'message'       => '',
303
-            'from'          => $admin_email,
304
-            'from_name'     => '',
305
-            'cc'            => '',
306
-            'bcc'           => '',
307
-            'plain_text'    => true,
308
-            'reply_to'      => $admin_email,
309
-            'attachments'   => array(),
310
-        );
311
-        $atts = wp_parse_args($atts, $defaults);
312
-
313
-        // Put To, BCC, CC, Reply To, and From fields in the correct format
314
-        self::format_email_fields( $atts, $admin_email );
315
-
316
-        $recipient      = $atts['to_email']; //recipient
317
-        $header         = array();
318
-        $header[]       = 'From: ' . $atts['from'];
319
-
320
-        //Allow for cc and bcc arrays
298
+		$admin_email = get_option('admin_email');
299
+		$defaults = array(
300
+			'to_email'      => $admin_email,
301
+			'subject'       => '',
302
+			'message'       => '',
303
+			'from'          => $admin_email,
304
+			'from_name'     => '',
305
+			'cc'            => '',
306
+			'bcc'           => '',
307
+			'plain_text'    => true,
308
+			'reply_to'      => $admin_email,
309
+			'attachments'   => array(),
310
+		);
311
+		$atts = wp_parse_args($atts, $defaults);
312
+
313
+		// Put To, BCC, CC, Reply To, and From fields in the correct format
314
+		self::format_email_fields( $atts, $admin_email );
315
+
316
+		$recipient      = $atts['to_email']; //recipient
317
+		$header         = array();
318
+		$header[]       = 'From: ' . $atts['from'];
319
+
320
+		//Allow for cc and bcc arrays
321 321
 		$array_fields = array( 'CC' => $atts['cc'], 'BCC' => $atts['bcc'] );
322 322
 		$cc = array( 'CC' => array(), 'BCC' => array() );
323
-        foreach ( $array_fields as $key => $a_field ) {
324
-            if ( empty($a_field) ) {
325
-                continue;
326
-            }
323
+		foreach ( $array_fields as $key => $a_field ) {
324
+			if ( empty($a_field) ) {
325
+				continue;
326
+			}
327 327
 
328 328
 			foreach ( (array) $a_field as $email ) {
329 329
 				$cc[ $key ][] = $email;
330
-            }
331
-            unset($key, $a_field);
332
-        }
330
+			}
331
+			unset($key, $a_field);
332
+		}
333 333
 		$cc = array_filter( $cc ); // remove cc and bcc if they are empty
334 334
 
335 335
 		foreach ( $cc as $k => $v ) {
336 336
 			$header[] = $k . ': ' . implode( ',', $v );
337 337
 		}
338 338
 
339
-        $content_type   = $atts['plain_text'] ? 'text/plain' : 'text/html';
340
-        $charset        = get_option('blog_charset');
339
+		$content_type   = $atts['plain_text'] ? 'text/plain' : 'text/html';
340
+		$charset        = get_option('blog_charset');
341 341
 
342 342
 		$header[]       = 'Reply-To: ' . $atts['reply_to'];
343 343
 		$header[]       = 'Content-Type: ' . $content_type . '; charset="' . esc_attr( $charset ) . '"';
344
-        $atts['subject'] = wp_specialchars_decode(strip_tags(stripslashes($atts['subject'])), ENT_QUOTES );
344
+		$atts['subject'] = wp_specialchars_decode(strip_tags(stripslashes($atts['subject'])), ENT_QUOTES );
345 345
 
346
-        $message        = do_shortcode($atts['message']);
346
+		$message        = do_shortcode($atts['message']);
347 347
 
348
-        if ( $atts['plain_text'] ) {
349
-            //$message    = wordwrap($message, 70, "\r\n"); //in case any lines are longer than 70 chars
350
-            $message    = wp_specialchars_decode(strip_tags($message), ENT_QUOTES );
351
-        } else {
348
+		if ( $atts['plain_text'] ) {
349
+			//$message    = wordwrap($message, 70, "\r\n"); //in case any lines are longer than 70 chars
350
+			$message    = wp_specialchars_decode(strip_tags($message), ENT_QUOTES );
351
+		} else {
352 352
 			// remove line breaks in HTML emails to prevent conflicts with Mandrill
353
-        	add_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' );
354
-        }
353
+			add_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' );
354
+		}
355 355
 		$message = apply_filters( 'frm_email_message', $message, $atts );
356 356
 
357
-        $header         = apply_filters('frm_email_header', $header, array(
357
+		$header         = apply_filters('frm_email_header', $header, array(
358 358
 			'to_email' => $atts['to_email'], 'subject' => $atts['subject'],
359 359
 		) );
360 360
 
361
-        if ( apply_filters('frm_encode_subject', 1, $atts['subject'] ) ) {
361
+		if ( apply_filters('frm_encode_subject', 1, $atts['subject'] ) ) {
362 362
 			$atts['subject'] = '=?' . $charset . '?B?' . base64_encode( $atts['subject'] ) . '?=';
363
-        }
363
+		}
364 364
 
365
-        remove_filter('wp_mail_from', 'bp_core_email_from_address_filter' );
366
-        remove_filter('wp_mail_from_name', 'bp_core_email_from_name_filter');
365
+		remove_filter('wp_mail_from', 'bp_core_email_from_address_filter' );
366
+		remove_filter('wp_mail_from_name', 'bp_core_email_from_name_filter');
367 367
 
368
-        $sent = wp_mail($recipient, $atts['subject'], $message, $header, $atts['attachments']);
369
-        if ( ! $sent ) {
368
+		$sent = wp_mail($recipient, $atts['subject'], $message, $header, $atts['attachments']);
369
+		if ( ! $sent ) {
370 370
 			$header = 'From: ' . $atts['from'] . "\r\n";
371
-            $recipient = implode(',', (array) $recipient);
372
-            $sent = mail($recipient, $atts['subject'], $message, $header);
373
-        }
371
+			$recipient = implode(',', (array) $recipient);
372
+			$sent = mail($recipient, $atts['subject'], $message, $header);
373
+		}
374 374
 
375 375
 		// remove the filter now so other emails can still use it
376 376
 		remove_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' );
377 377
 
378
-        do_action('frm_notification', $recipient, $atts['subject'], $message);
378
+		do_action('frm_notification', $recipient, $atts['subject'], $message);
379 379
 
380
-        if ( $sent ) {
380
+		if ( $sent ) {
381 381
 			$sent_to = array_merge( (array) $atts['to_email'], (array) $atts['cc'], (array) $atts['bcc'] );
382
-            $sent_to = array_filter( $sent_to );
383
-            if ( apply_filters('frm_echo_emails', false) ) {
384
-                $temp = str_replace('<', '&lt;', $sent_to);
382
+			$sent_to = array_filter( $sent_to );
383
+			if ( apply_filters('frm_echo_emails', false) ) {
384
+				$temp = str_replace('<', '&lt;', $sent_to);
385 385
 				echo ' ' . FrmAppHelper::kses( implode(', ', (array) $temp ) );
386
-            }
387
-            return $sent_to;
388
-        }
389
-    }
386
+			}
387
+			return $sent_to;
388
+		}
389
+	}
390 390
 
391 391
 	/**
392 392
 	 * This function should only be fired when Mandrill is sending an HTML email
Please login to merge, or discard this patch.
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -2,10 +2,10 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmNotification {
4 4
 	public function __construct() {
5
-        if ( ! defined('ABSPATH') ) {
6
-            die('You are not allowed to call this page directly.');
5
+        if ( ! defined( 'ABSPATH' ) ) {
6
+            die( 'You are not allowed to call this page directly.' );
7 7
         }
8
-        add_action('frm_trigger_email_action', 'FrmNotification::trigger_email', 10, 3);
8
+        add_action( 'frm_trigger_email_action', 'FrmNotification::trigger_email', 10, 3 );
9 9
     }
10 10
 
11 11
 	public static function trigger_email( $action, $entry, $form ) {
@@ -13,8 +13,8 @@  discard block
 block discarded – undo
13 13
         $email_key = $action->ID;
14 14
 
15 15
         // Set the subject
16
-        if ( empty($notification['email_subject']) ) {
17
-            $notification['email_subject'] = sprintf(__( '%1$s Form submitted on %2$s', 'formidable' ), $form->name, '[sitename]');
16
+        if ( empty( $notification['email_subject'] ) ) {
17
+            $notification['email_subject'] = sprintf( __( '%1$s Form submitted on %2$s', 'formidable' ), $form->name, '[sitename]' );
18 18
         }
19 19
 
20 20
         $plain_text = $notification['plain_text'] ? true : false;
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
             'email_subject', 'email_message',
27 27
         );
28 28
 
29
-        add_filter('frm_plain_text_email', ($plain_text ? '__return_true' : '__return_false'));
29
+        add_filter( 'frm_plain_text_email', ( $plain_text ? '__return_true' : '__return_false' ) );
30 30
 
31 31
         //Get all values in entry in order to get User ID field ID
32 32
         $values = FrmEntryMeta::getAll( array( 'it.field_id !' => 0, 'it.item_id' => $entry->id ), ' ORDER BY fi.field_order' );
@@ -37,29 +37,29 @@  discard block
 block discarded – undo
37 37
                 $user_id_key = $value->field_key;
38 38
                 break;
39 39
             }
40
-            unset($value);
40
+            unset( $value );
41 41
         }
42 42
 
43 43
         //Filter and prepare the email fields
44 44
         foreach ( $filter_fields as $f ) {
45 45
             //Don't allow empty From
46
-			if ( $f == 'from' && empty( $notification[ $f ] ) ) {
47
-				$notification[ $f ] = '[admin_email]';
46
+			if ( $f == 'from' && empty( $notification[$f] ) ) {
47
+				$notification[$f] = '[admin_email]';
48 48
 			} else if ( in_array( $f, array( 'email_to', 'cc', 'bcc', 'reply_to', 'from' ) ) ) {
49 49
 				//Remove brackets
50 50
                 //Add a space in case there isn't one
51
-				$notification[ $f ] = str_replace( '<', ' ', $notification[ $f ] );
52
-				$notification[ $f ] = str_replace( array( '"', '>' ), '', $notification[ $f ] );
51
+				$notification[$f] = str_replace( '<', ' ', $notification[$f] );
52
+				$notification[$f] = str_replace( array( '"', '>' ), '', $notification[$f] );
53 53
 
54 54
                 //Switch userID shortcode to email address
55
-				if ( strpos( $notification[ $f ], '[' . $user_id_field . ']' ) !== false || strpos( $notification[ $f ], '[' . $user_id_key . ']' ) !== false ) {
56
-					$user_data = get_userdata( $entry->metas[ $user_id_field ] );
55
+				if ( strpos( $notification[$f], '[' . $user_id_field . ']' ) !== false || strpos( $notification[$f], '[' . $user_id_key . ']' ) !== false ) {
56
+					$user_data = get_userdata( $entry->metas[$user_id_field] );
57 57
                     $user_email = $user_data->user_email;
58
-					$notification[ $f ] = str_replace( array( '[' . $user_id_field . ']', '[' . $user_id_key . ']' ), $user_email, $notification[ $f ] );
58
+					$notification[$f] = str_replace( array( '[' . $user_id_field . ']', '[' . $user_id_key . ']' ), $user_email, $notification[$f] );
59 59
                 }
60 60
             }
61 61
 
62
-			$notification[ $f ] = FrmFieldsHelper::basic_replace_shortcodes( $notification[ $f ], $form, $entry );
62
+			$notification[$f] = FrmFieldsHelper::basic_replace_shortcodes( $notification[$f], $form, $entry );
63 63
         }
64 64
 
65 65
         //Put recipients, cc, and bcc into an array if they aren't empty
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 		$cc = self::explode_emails( $notification['cc'] );
68 68
 		$bcc = self::explode_emails( $notification['bcc'] );
69 69
 
70
-        $to_emails = apply_filters('frm_to_email', $to_emails, $values, $form->id, compact('email_key', 'entry', 'form'));
70
+        $to_emails = apply_filters( 'frm_to_email', $to_emails, $values, $form->id, compact( 'email_key', 'entry', 'form' ) );
71 71
 
72 72
         // Stop now if there aren't any recipients
73 73
         if ( empty( $to_emails ) && empty( $cc ) && empty( $bcc ) ) {
@@ -77,39 +77,39 @@  discard block
 block discarded – undo
77 77
         $to_emails = array_unique( (array) $to_emails );
78 78
 
79 79
         $prev_mail_body = $mail_body = $notification['email_message'];
80
-        $mail_body = FrmEntriesHelper::replace_default_message($mail_body, array(
80
+        $mail_body = FrmEntriesHelper::replace_default_message( $mail_body, array(
81 81
             'id' => $entry->id, 'entry' => $entry, 'plain_text' => $plain_text,
82
-            'user_info' => (isset($notification['inc_user_info']) ? $notification['inc_user_info'] : false),
82
+            'user_info' => ( isset( $notification['inc_user_info'] ) ? $notification['inc_user_info'] : false ),
83 83
         ) );
84 84
 
85 85
         // Add the user info if it isn't already included
86 86
         if ( $notification['inc_user_info'] && $prev_mail_body == $mail_body ) {
87
-            $data = maybe_unserialize($entry->description);
87
+            $data = maybe_unserialize( $entry->description );
88 88
 			$mail_body .= "\r\n\r\n" . __( 'User Information', 'formidable' ) . "\r\n";
89 89
 			$mail_body .= __( 'IP Address', 'formidable' ) . ': ' . $entry->ip . "\r\n";
90 90
 			$mail_body .= __( 'User-Agent (Browser/OS)', 'formidable' ) . ': ' . FrmEntryFormat::get_browser( $data['browser'] ) . "\r\n";
91 91
 			$mail_body .= __( 'Referrer', 'formidable' ) . ': ' . $data['referrer'] . "\r\n";
92 92
         }
93
-        unset($prev_mail_body);
93
+        unset( $prev_mail_body );
94 94
 
95 95
         // Add attachments
96
-        $attachments = apply_filters('frm_notification_attachment', array(), $form, compact('entry', 'email_key') );
96
+        $attachments = apply_filters( 'frm_notification_attachment', array(), $form, compact( 'entry', 'email_key' ) );
97 97
 
98
-        if ( ! empty($notification['email_subject']) ) {
99
-            $notification['email_subject'] = apply_filters('frm_email_subject', $notification['email_subject'], compact('form', 'entry', 'email_key'));
98
+        if ( ! empty( $notification['email_subject'] ) ) {
99
+            $notification['email_subject'] = apply_filters( 'frm_email_subject', $notification['email_subject'], compact( 'form', 'entry', 'email_key' ) );
100 100
         }
101 101
 
102 102
         // check for a phone number
103 103
         foreach ( (array) $to_emails as $email_key => $e ) {
104
-            if ( $e != '[admin_email]' && ! is_email($e) ) {
105
-                $e = explode(' ', $e);
104
+            if ( $e != '[admin_email]' && ! is_email( $e ) ) {
105
+                $e = explode( ' ', $e );
106 106
 
107 107
                 //If to_email has name <[email protected]> format
108
-                if ( is_email(end($e)) ) {
108
+                if ( is_email( end( $e ) ) ) {
109 109
                     continue;
110 110
                 }
111 111
 
112
-                do_action('frm_send_to_not_email', array(
112
+                do_action( 'frm_send_to_not_email', array(
113 113
                     'e'         => $e,
114 114
                     'subject'   => $notification['email_subject'],
115 115
                     'mail_body' => $mail_body,
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
                     'email_key' => $email_key,
122 122
                 ) );
123 123
 
124
-				unset( $to_emails[ $email_key ] );
124
+				unset( $to_emails[$email_key] );
125 125
             }
126 126
         }
127 127
 
@@ -144,17 +144,17 @@  discard block
 block discarded – undo
144 144
 	public function entry_created( $entry_id, $form_id ) {
145 145
 		$new_function = 'FrmFormActionsController::trigger_actions("create", ' . $form_id . ', ' . $entry_id . ', "email")';
146 146
 		_deprecated_function( __FUNCTION__, '2.0', $new_function );
147
-        FrmFormActionsController::trigger_actions('create', $form_id, $entry_id, 'email');
147
+        FrmFormActionsController::trigger_actions( 'create', $form_id, $entry_id, 'email' );
148 148
     }
149 149
 
150 150
 	public function send_notification_email( $to_email, $subject, $message, $from = '', $from_name = '', $plain_text = true, $attachments = array(), $reply_to = '' ) {
151 151
         _deprecated_function( __FUNCTION__, '2.0', 'FrmNotification::send_email' );
152 152
 
153
-        return self::send_email(compact(
153
+        return self::send_email( compact(
154 154
             'to_email', 'subject', 'message',
155 155
             'from', 'from_name', 'plain_text',
156 156
             'attachments', 'reply_to'
157
-        ));
157
+        ) );
158 158
     }
159 159
 
160 160
 	/**
@@ -187,28 +187,28 @@  discard block
 block discarded – undo
187 187
     private static function format_email_fields( &$atts, $admin_email ) {
188 188
 
189 189
         // If from is empty or is set to admin_email, set it now
190
-        $atts['from'] = ( empty($atts['from']) || $atts['from'] == '[admin_email]' ) ? $admin_email : $atts['from'];
190
+        $atts['from'] = ( empty( $atts['from'] ) || $atts['from'] == '[admin_email]' ) ? $admin_email : $atts['from'];
191 191
 
192 192
         // Filter values in these fields
193 193
 		$filter_fields = array( 'to_email', 'bcc', 'cc', 'from', 'reply_to' );
194 194
 
195 195
         foreach ( $filter_fields as $f ) {
196 196
             // If empty, just skip it
197
-			if ( empty( $atts[ $f ] ) ) {
197
+			if ( empty( $atts[$f] ) ) {
198 198
                 continue;
199 199
             }
200 200
 
201 201
             // to_email, cc, and bcc can be an array
202
-			if ( is_array( $atts[ $f ] ) ) {
203
-				foreach ( $atts[ $f ] as $key => $val ) {
202
+			if ( is_array( $atts[$f] ) ) {
203
+				foreach ( $atts[$f] as $key => $val ) {
204 204
                     self::format_single_field( $atts, $f, $val, $key );
205 205
                     unset( $key, $val );
206 206
                 }
207
-                unset($f);
207
+                unset( $f );
208 208
                 continue;
209 209
             }
210 210
 
211
-			self::format_single_field( $atts, $f, $atts[ $f ] );
211
+			self::format_single_field( $atts, $f, $atts[$f] );
212 212
         }
213 213
 
214 214
         // If reply-to isn't set, make it match the from settings
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
             $atts['reply_to'] = self::get_email_from_formatted_string( $atts['from'] );
217 217
         }
218 218
 
219
-        if ( ! is_array($atts['to_email']) && '[admin_email]' == $atts['to_email'] ) {
219
+        if ( ! is_array( $atts['to_email'] ) && '[admin_email]' == $atts['to_email'] ) {
220 220
             $atts['to_email'] = $admin_email;
221 221
         }
222 222
     }
@@ -239,20 +239,20 @@  discard block
 block discarded – undo
239 239
     * @param int $key if in array, this will be set
240 240
     */
241 241
     private static function format_single_field( &$atts, $f, $val, $key = false ) {
242
-        $val = trim($val);
242
+        $val = trim( $val );
243 243
 
244 244
         // If just a plain email is used
245
-        if ( is_email($val) ) {
245
+        if ( is_email( $val ) ) {
246 246
             // add sender's name if not included in $from
247 247
             if ( $f == 'from' ) {
248
-				$part_2 = $atts[ $f ];
249
-                $part_1  = $atts['from_name'] ? $atts['from_name'] : wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
248
+				$part_2 = $atts[$f];
249
+                $part_1 = $atts['from_name'] ? $atts['from_name'] : wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
250 250
             } else {
251 251
                 return;
252 252
             }
253 253
         } else {
254
-            $parts = explode(' ', $val);
255
-            $part_2 = end($parts);
254
+            $parts = explode( ' ', $val );
255
+            $part_2 = end( $parts );
256 256
 
257 257
             // If inputted correcly, $part_2 should be an email
258 258
             if ( is_email( $part_2 ) ) {
@@ -260,14 +260,14 @@  discard block
 block discarded – undo
260 260
             } else if ( in_array( $f, array( 'from', 'reply_to' ) ) ) {
261 261
 				// In case someone just puts a name in the From or Reply To field
262 262
 				$part_1 = $val;
263
-                $part_2 = get_option('admin_email');
263
+                $part_2 = get_option( 'admin_email' );
264 264
             } else {
265 265
 				// In case someone just puts a name in any other email field
266 266
                 if ( false !== $key ) {
267
-					unset( $atts[ $f ][ $key ] );
267
+					unset( $atts[$f][$key] );
268 268
                     return;
269 269
                 }
270
-				$atts[ $f ] = '';
270
+				$atts[$f] = '';
271 271
                 return;
272 272
             }
273 273
         }
@@ -288,14 +288,14 @@  discard block
 block discarded – undo
288 288
 
289 289
         // If value is an array
290 290
         if ( false !== $key ) {
291
-			$atts[ $f ][ $key ] = $final_val;
291
+			$atts[$f][$key] = $final_val;
292 292
             return;
293 293
         }
294
-		$atts[ $f ] = $final_val;
294
+		$atts[$f] = $final_val;
295 295
     }
296 296
 
297 297
 	public static function send_email( $atts ) {
298
-        $admin_email = get_option('admin_email');
298
+        $admin_email = get_option( 'admin_email' );
299 299
         $defaults = array(
300 300
             'to_email'      => $admin_email,
301 301
             'subject'       => '',
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
             'reply_to'      => $admin_email,
309 309
             'attachments'   => array(),
310 310
         );
311
-        $atts = wp_parse_args($atts, $defaults);
311
+        $atts = wp_parse_args( $atts, $defaults );
312 312
 
313 313
         // Put To, BCC, CC, Reply To, and From fields in the correct format
314 314
         self::format_email_fields( $atts, $admin_email );
@@ -321,14 +321,14 @@  discard block
 block discarded – undo
321 321
 		$array_fields = array( 'CC' => $atts['cc'], 'BCC' => $atts['bcc'] );
322 322
 		$cc = array( 'CC' => array(), 'BCC' => array() );
323 323
         foreach ( $array_fields as $key => $a_field ) {
324
-            if ( empty($a_field) ) {
324
+            if ( empty( $a_field ) ) {
325 325
                 continue;
326 326
             }
327 327
 
328 328
 			foreach ( (array) $a_field as $email ) {
329
-				$cc[ $key ][] = $email;
329
+				$cc[$key][] = $email;
330 330
             }
331
-            unset($key, $a_field);
331
+            unset( $key, $a_field );
332 332
         }
333 333
 		$cc = array_filter( $cc ); // remove cc and bcc if they are empty
334 334
 
@@ -337,52 +337,52 @@  discard block
 block discarded – undo
337 337
 		}
338 338
 
339 339
         $content_type   = $atts['plain_text'] ? 'text/plain' : 'text/html';
340
-        $charset        = get_option('blog_charset');
340
+        $charset        = get_option( 'blog_charset' );
341 341
 
342 342
 		$header[]       = 'Reply-To: ' . $atts['reply_to'];
343 343
 		$header[]       = 'Content-Type: ' . $content_type . '; charset="' . esc_attr( $charset ) . '"';
344
-        $atts['subject'] = wp_specialchars_decode(strip_tags(stripslashes($atts['subject'])), ENT_QUOTES );
344
+        $atts['subject'] = wp_specialchars_decode( strip_tags( stripslashes( $atts['subject'] ) ), ENT_QUOTES );
345 345
 
346
-        $message        = do_shortcode($atts['message']);
346
+        $message = do_shortcode( $atts['message'] );
347 347
 
348 348
         if ( $atts['plain_text'] ) {
349 349
             //$message    = wordwrap($message, 70, "\r\n"); //in case any lines are longer than 70 chars
350
-            $message    = wp_specialchars_decode(strip_tags($message), ENT_QUOTES );
350
+            $message = wp_specialchars_decode( strip_tags( $message ), ENT_QUOTES );
351 351
         } else {
352 352
 			// remove line breaks in HTML emails to prevent conflicts with Mandrill
353 353
         	add_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' );
354 354
         }
355 355
 		$message = apply_filters( 'frm_email_message', $message, $atts );
356 356
 
357
-        $header         = apply_filters('frm_email_header', $header, array(
357
+        $header = apply_filters( 'frm_email_header', $header, array(
358 358
 			'to_email' => $atts['to_email'], 'subject' => $atts['subject'],
359 359
 		) );
360 360
 
361
-        if ( apply_filters('frm_encode_subject', 1, $atts['subject'] ) ) {
361
+        if ( apply_filters( 'frm_encode_subject', 1, $atts['subject'] ) ) {
362 362
 			$atts['subject'] = '=?' . $charset . '?B?' . base64_encode( $atts['subject'] ) . '?=';
363 363
         }
364 364
 
365
-        remove_filter('wp_mail_from', 'bp_core_email_from_address_filter' );
366
-        remove_filter('wp_mail_from_name', 'bp_core_email_from_name_filter');
365
+        remove_filter( 'wp_mail_from', 'bp_core_email_from_address_filter' );
366
+        remove_filter( 'wp_mail_from_name', 'bp_core_email_from_name_filter' );
367 367
 
368
-        $sent = wp_mail($recipient, $atts['subject'], $message, $header, $atts['attachments']);
368
+        $sent = wp_mail( $recipient, $atts['subject'], $message, $header, $atts['attachments'] );
369 369
         if ( ! $sent ) {
370 370
 			$header = 'From: ' . $atts['from'] . "\r\n";
371
-            $recipient = implode(',', (array) $recipient);
372
-            $sent = mail($recipient, $atts['subject'], $message, $header);
371
+            $recipient = implode( ',', (array) $recipient );
372
+            $sent = mail( $recipient, $atts['subject'], $message, $header );
373 373
         }
374 374
 
375 375
 		// remove the filter now so other emails can still use it
376 376
 		remove_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' );
377 377
 
378
-        do_action('frm_notification', $recipient, $atts['subject'], $message);
378
+        do_action( 'frm_notification', $recipient, $atts['subject'], $message );
379 379
 
380 380
         if ( $sent ) {
381 381
 			$sent_to = array_merge( (array) $atts['to_email'], (array) $atts['cc'], (array) $atts['bcc'] );
382 382
             $sent_to = array_filter( $sent_to );
383
-            if ( apply_filters('frm_echo_emails', false) ) {
384
-                $temp = str_replace('<', '&lt;', $sent_to);
385
-				echo ' ' . FrmAppHelper::kses( implode(', ', (array) $temp ) );
383
+            if ( apply_filters( 'frm_echo_emails', false ) ) {
384
+                $temp = str_replace( '<', '&lt;', $sent_to );
385
+				echo ' ' . FrmAppHelper::kses( implode( ', ', (array) $temp ) );
386 386
             }
387 387
             return $sent_to;
388 388
         }
Please login to merge, or discard this patch.
classes/controllers/FrmXMLController.php 2 patches
Indentation   +172 added lines, -172 removed lines patch added patch discarded remove patch
@@ -2,109 +2,109 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmXMLController {
4 4
 
5
-    public static function menu() {
5
+	public static function menu() {
6 6
 		add_submenu_page( 'formidable', 'Formidable | ' . __( 'Import/Export', 'formidable' ), __( 'Import/Export', 'formidable' ), 'frm_edit_forms', 'formidable-import', 'FrmXMLController::route' );
7
-    }
7
+	}
8 8
 
9
-    public static function add_default_templates() {
9
+	public static function add_default_templates() {
10 10
 		if ( ! function_exists( 'libxml_disable_entity_loader' ) ) {
11
-    		// XML import is not enabled on your server
12
-    		return;
13
-    	}
11
+			// XML import is not enabled on your server
12
+			return;
13
+		}
14 14
 
15
-        $set_err = libxml_use_internal_errors(true);
16
-        $loader = libxml_disable_entity_loader( true );
15
+		$set_err = libxml_use_internal_errors(true);
16
+		$loader = libxml_disable_entity_loader( true );
17 17
 
18 18
 		$files = apply_filters( 'frm_default_templates_files', array( FrmAppHelper::plugin_path() . '/classes/views/xml/default-templates.xml' ) );
19 19
 
20
-        foreach ( (array) $files as $file ) {
21
-            FrmXMLHelper::import_xml($file);
22
-            unset($file);
23
-        }
24
-        /*
20
+		foreach ( (array) $files as $file ) {
21
+			FrmXMLHelper::import_xml($file);
22
+			unset($file);
23
+		}
24
+		/*
25 25
         if(is_wp_error($result))
26 26
             $errors[] = $result->get_error_message();
27 27
         else if($result)
28 28
             $message = $result;
29 29
         */
30 30
 
31
-        unset( $files );
31
+		unset( $files );
32 32
 
33
-        libxml_use_internal_errors( $set_err );
34
-    	libxml_disable_entity_loader( $loader );
35
-    }
33
+		libxml_use_internal_errors( $set_err );
34
+		libxml_disable_entity_loader( $loader );
35
+	}
36 36
 
37
-    public static function route() {
38
-        $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
37
+	public static function route() {
38
+		$action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
39 39
 		$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
40 40
 		if ( $action == 'import_xml' ) {
41
-            return self::import_xml();
41
+			return self::import_xml();
42 42
 		} else if ( $action == 'export_xml' ) {
43
-            return self::export_xml();
44
-        } else {
45
-            if ( apply_filters( 'frm_xml_route', true, $action ) ) {
46
-                return self::form();
47
-            }
48
-        }
49
-    }
50
-
51
-    public static function form( $errors = array(), $message = '' ) {
43
+			return self::export_xml();
44
+		} else {
45
+			if ( apply_filters( 'frm_xml_route', true, $action ) ) {
46
+				return self::form();
47
+			}
48
+		}
49
+	}
50
+
51
+	public static function form( $errors = array(), $message = '' ) {
52 52
 		$where = array(
53 53
 			'status' => array( null, '', 'published' ),
54 54
 		);
55 55
 		$forms = FrmForm::getAll( $where, 'name' );
56 56
 
57
-        $export_types = apply_filters( 'frm_xml_export_types',
58
-            array( 'forms' => __( 'Forms', 'formidable' ), 'items' => __( 'Entries', 'formidable' ) )
59
-        );
57
+		$export_types = apply_filters( 'frm_xml_export_types',
58
+			array( 'forms' => __( 'Forms', 'formidable' ), 'items' => __( 'Entries', 'formidable' ) )
59
+		);
60 60
 
61
-        $export_format = apply_filters( 'frm_export_formats', array(
62
-            'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ),
61
+		$export_format = apply_filters( 'frm_export_formats', array(
62
+			'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ),
63 63
 			'csv' => array( 'name' => 'CSV', 'support' => 'items', 'count' => 'single' ),
64
-        ) );
64
+		) );
65 65
 
66 66
 		include( FrmAppHelper::plugin_path() . '/classes/views/xml/import_form.php' );
67
-    }
67
+	}
68 68
 
69
-    public static function import_xml() {
70
-        $errors = array();
71
-        $message = '';
69
+	public static function import_xml() {
70
+		$errors = array();
71
+		$message = '';
72 72
 
73
-        $permission_error = FrmAppHelper::permission_nonce_error('frm_edit_forms', 'import-xml', 'import-xml-nonce');
74
-        if ( $permission_error !== false ) {
75
-            $errors[] = $permission_error;
76
-            self::form($errors);
77
-            return;
78
-        }
73
+		$permission_error = FrmAppHelper::permission_nonce_error('frm_edit_forms', 'import-xml', 'import-xml-nonce');
74
+		if ( $permission_error !== false ) {
75
+			$errors[] = $permission_error;
76
+			self::form($errors);
77
+			return;
78
+		}
79 79
 
80
-        if ( ! isset($_FILES) || ! isset($_FILES['frm_import_file']) || empty($_FILES['frm_import_file']['name']) || (int) $_FILES['frm_import_file']['size'] < 1 ) {
81
-            $errors[] = __( 'Oops, you didn\'t select a file.', 'formidable' );
82
-            self::form($errors);
83
-            return;
84
-        }
80
+		if ( ! isset($_FILES) || ! isset($_FILES['frm_import_file']) || empty($_FILES['frm_import_file']['name']) || (int) $_FILES['frm_import_file']['size'] < 1 ) {
81
+			$errors[] = __( 'Oops, you didn\'t select a file.', 'formidable' );
82
+			self::form($errors);
83
+			return;
84
+		}
85 85
 
86
-        $file = $_FILES['frm_import_file']['tmp_name'];
86
+		$file = $_FILES['frm_import_file']['tmp_name'];
87 87
 
88
-        if ( ! is_uploaded_file( $file ) ) {
89
-            unset($file);
90
-            $errors[] = __( 'The file does not exist, please try again.', 'formidable' );
91
-            self::form($errors);
92
-            return;
93
-        }
88
+		if ( ! is_uploaded_file( $file ) ) {
89
+			unset($file);
90
+			$errors[] = __( 'The file does not exist, please try again.', 'formidable' );
91
+			self::form($errors);
92
+			return;
93
+		}
94 94
 
95
-        //add_filter('upload_mimes', 'FrmXMLController::allow_mime');
95
+		//add_filter('upload_mimes', 'FrmXMLController::allow_mime');
96 96
 
97
-        $export_format = apply_filters('frm_export_formats', array(
97
+		$export_format = apply_filters('frm_export_formats', array(
98 98
 			'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ),
99 99
 		) );
100 100
 
101
-        $file_type = strtolower(pathinfo($_FILES['frm_import_file']['name'], PATHINFO_EXTENSION));
102
-        if ( $file_type != 'xml' && isset( $export_format[ $file_type ] ) ) {
103
-            // allow other file types to be imported
101
+		$file_type = strtolower(pathinfo($_FILES['frm_import_file']['name'], PATHINFO_EXTENSION));
102
+		if ( $file_type != 'xml' && isset( $export_format[ $file_type ] ) ) {
103
+			// allow other file types to be imported
104 104
 			do_action( 'frm_before_import_' . $file_type );
105
-            return;
106
-        }
107
-        unset($file_type);
105
+			return;
106
+		}
107
+		unset($file_type);
108 108
 
109 109
 		if ( ! function_exists( 'libxml_disable_entity_loader' ) ) {
110 110
 			$errors[] = __( 'XML import is not enabled on your server.', 'formidable' );
@@ -123,145 +123,145 @@  discard block
 block discarded – undo
123 123
 		libxml_use_internal_errors( $set_err );
124 124
 		libxml_disable_entity_loader( $loader );
125 125
 
126
-        self::form($errors, $message);
127
-    }
126
+		self::form($errors, $message);
127
+	}
128 128
 
129
-    public static function export_xml() {
130
-        $error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'export-xml', 'export-xml-nonce' );
131
-        if ( ! empty($error) ) {
132
-            wp_die( $error );
133
-        }
129
+	public static function export_xml() {
130
+		$error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'export-xml', 'export-xml-nonce' );
131
+		if ( ! empty($error) ) {
132
+			wp_die( $error );
133
+		}
134 134
 
135 135
 		$ids = FrmAppHelper::get_post_param( 'frm_export_forms', array() );
136 136
 		$type = FrmAppHelper::get_post_param( 'type', array() );
137 137
 		$format = FrmAppHelper::get_post_param( 'format', 'xml', 'sanitize_title' );
138 138
 
139
-        if ( ! headers_sent() && ! $type ) {
140
-            wp_redirect( esc_url_raw( admin_url( 'admin.php?page=formidable-import' ) ) );
141
-            die();
142
-        }
139
+		if ( ! headers_sent() && ! $type ) {
140
+			wp_redirect( esc_url_raw( admin_url( 'admin.php?page=formidable-import' ) ) );
141
+			die();
142
+		}
143 143
 
144
-        if ( $format == 'xml' ) {
145
-            self::generate_xml($type, compact('ids'));
144
+		if ( $format == 'xml' ) {
145
+			self::generate_xml($type, compact('ids'));
146 146
 		} if ( $format == 'csv' ) {
147 147
 			self::generate_csv( compact('ids') );
148
-        } else {
148
+		} else {
149 149
 			do_action( 'frm_export_format_' . $format, compact('ids') );
150
-        }
150
+		}
151 151
 
152
-        wp_die();
153
-    }
152
+		wp_die();
153
+	}
154 154
 
155 155
 	public static function generate_xml( $type, $args = array() ) {
156
-    	global $wpdb;
156
+		global $wpdb;
157 157
 
158
-	    self::prepare_types_array( $type );
158
+		self::prepare_types_array( $type );
159 159
 
160
-	    $tables = array(
160
+		$tables = array(
161 161
 			'items'     => $wpdb->prefix . 'frm_items',
162 162
 			'forms'     => $wpdb->prefix . 'frm_forms',
163
-	        'posts'     => $wpdb->posts,
164
-	        'styles'    => $wpdb->posts,
165
-	        'actions'   => $wpdb->posts,
166
-	    );
163
+			'posts'     => $wpdb->posts,
164
+			'styles'    => $wpdb->posts,
165
+			'actions'   => $wpdb->posts,
166
+		);
167 167
 
168 168
 		$defaults = array( 'ids' => false );
169
-	    $args = wp_parse_args( $args, $defaults );
169
+		$args = wp_parse_args( $args, $defaults );
170 170
 
171
-        $sitename = sanitize_key( get_bloginfo( 'name' ) );
171
+		$sitename = sanitize_key( get_bloginfo( 'name' ) );
172 172
 
173
-    	if ( ! empty( $sitename ) ) {
173
+		if ( ! empty( $sitename ) ) {
174 174
 			$sitename .= '.';
175 175
 		}
176
-    	$filename = $sitename . 'formidable.' . date( 'Y-m-d' ) . '.xml';
176
+		$filename = $sitename . 'formidable.' . date( 'Y-m-d' ) . '.xml';
177 177
 
178
-    	header( 'Content-Description: File Transfer' );
179
-    	header( 'Content-Disposition: attachment; filename=' . $filename );
180
-    	header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
178
+		header( 'Content-Description: File Transfer' );
179
+		header( 'Content-Disposition: attachment; filename=' . $filename );
180
+		header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
181 181
 
182
-        //make sure ids are numeric
183
-    	if ( is_array( $args['ids'] ) && ! empty( $args['ids'] ) ) {
184
-	        $args['ids'] = array_filter( $args['ids'], 'is_numeric' );
185
-	    }
182
+		//make sure ids are numeric
183
+		if ( is_array( $args['ids'] ) && ! empty( $args['ids'] ) ) {
184
+			$args['ids'] = array_filter( $args['ids'], 'is_numeric' );
185
+		}
186 186
 
187
-	    $records = array();
187
+		$records = array();
188 188
 
189 189
 		foreach ( $type as $tb_type ) {
190
-            $where = array();
190
+			$where = array();
191 191
 			$join = '';
192
-            $table = $tables[ $tb_type ];
192
+			$table = $tables[ $tb_type ];
193 193
 
194 194
 			$select = $table . '.id';
195
-            $query_vars = array();
195
+			$query_vars = array();
196 196
 
197
-            switch ( $tb_type ) {
198
-                case 'forms':
199
-                    //add forms
200
-                    if ( $args['ids'] ) {
197
+			switch ( $tb_type ) {
198
+				case 'forms':
199
+					//add forms
200
+					if ( $args['ids'] ) {
201 201
 						$where[] = array( 'or' => 1, $table . '.id' => $args['ids'], $table . '.parent_form_id' => $args['ids'] );
202
-                	} else {
202
+					} else {
203 203
 						$where[ $table . '.status !' ] = 'draft';
204
-                	}
205
-                break;
206
-                case 'actions':
204
+					}
205
+				break;
206
+				case 'actions':
207 207
 					$select = $table . '.ID';
208 208
 					$where['post_type'] = FrmFormActionsController::$action_post_type;
209
-                    if ( ! empty($args['ids']) ) {
209
+					if ( ! empty($args['ids']) ) {
210 210
 						$where['menu_order'] = $args['ids'];
211
-                    }
212
-                break;
213
-                case 'items':
214
-                    //$join = "INNER JOIN {$wpdb->prefix}frm_item_metas im ON ($table.id = im.item_id)";
215
-                    if ( $args['ids'] ) {
211
+					}
212
+				break;
213
+				case 'items':
214
+					//$join = "INNER JOIN {$wpdb->prefix}frm_item_metas im ON ($table.id = im.item_id)";
215
+					if ( $args['ids'] ) {
216 216
 						$where[ $table . '.form_id' ] = $args['ids'];
217
-                    }
218
-                break;
219
-                case 'styles':
220
-                    // Loop through all exported forms and get their selected style IDs
217
+					}
218
+				break;
219
+				case 'styles':
220
+					// Loop through all exported forms and get their selected style IDs
221 221
 					$frm_style = new FrmStyle();
222 222
 					$default_style = $frm_style->get_default_style();
223
-                    $form_ids = $args['ids'];
224
-                    $style_ids = array();
225
-                    foreach ( $form_ids as $form_id ) {
226
-                        $form_data = FrmForm::getOne( $form_id );
227
-                        // For forms that have not been updated while running 2.0, check if custom_style is set
228
-                        if ( isset( $form_data->options['custom_style'] ) ) {
223
+					$form_ids = $args['ids'];
224
+					$style_ids = array();
225
+					foreach ( $form_ids as $form_id ) {
226
+						$form_data = FrmForm::getOne( $form_id );
227
+						// For forms that have not been updated while running 2.0, check if custom_style is set
228
+						if ( isset( $form_data->options['custom_style'] ) ) {
229 229
 							if ( $form_data->options['custom_style'] == 1 ) {
230 230
 								$style_ids[] = $default_style->ID;
231 231
 							} else {
232 232
 								$style_ids[] = $form_data->options['custom_style'];
233 233
 							}
234
-                        }
235
-                        unset( $form_id, $form_data );
236
-                    }
234
+						}
235
+						unset( $form_id, $form_data );
236
+					}
237 237
 					$select = $table . '.ID';
238
-                    $where['post_type'] = 'frm_styles';
239
-
240
-                    // Only export selected styles
241
-                    if ( ! empty( $style_ids ) ) {
242
-                        $where['ID'] = $style_ids;
243
-                    }
244
-                break;
245
-                default:
238
+					$where['post_type'] = 'frm_styles';
239
+
240
+					// Only export selected styles
241
+					if ( ! empty( $style_ids ) ) {
242
+						$where['ID'] = $style_ids;
243
+					}
244
+				break;
245
+				default:
246 246
 					$select = $table . '.ID';
247
-                    $join = ' INNER JOIN ' . $wpdb->postmeta . ' pm ON (pm.post_id=' . $table . '.ID)';
248
-                    $where['pm.meta_key'] = 'frm_form_id';
249
-
250
-                    if ( empty($args['ids']) ) {
251
-                        $where['pm.meta_value >'] = 1;
252
-                    } else {
253
-                        $where['pm.meta_value'] = $args['ids'];
254
-                    }
255
-                break;
256
-            }
247
+					$join = ' INNER JOIN ' . $wpdb->postmeta . ' pm ON (pm.post_id=' . $table . '.ID)';
248
+					$where['pm.meta_key'] = 'frm_form_id';
249
+
250
+					if ( empty($args['ids']) ) {
251
+						$where['pm.meta_value >'] = 1;
252
+					} else {
253
+						$where['pm.meta_value'] = $args['ids'];
254
+					}
255
+				break;
256
+			}
257 257
 
258 258
 			$records[ $tb_type ] = FrmDb::get_col( $table . $join, $where, $select );
259
-            unset($tb_type);
260
-        }
259
+			unset($tb_type);
260
+		}
261 261
 
262 262
 		echo '<?xml version="1.0" encoding="' . esc_attr( get_bloginfo('charset') ) . "\" ?>\n";
263 263
 		include( FrmAppHelper::plugin_path() . '/classes/views/xml/xml.php' );
264
-    }
264
+	}
265 265
 
266 266
 	private static function prepare_types_array( &$type ) {
267 267
 		$type = (array) $type;
@@ -342,14 +342,14 @@  discard block
 block discarded – undo
342 342
 	}
343 343
 
344 344
 	/**
345
-	* Get the fields that should be included in the CSV export
346
-	*
347
-	* @since 2.0.19
348
-	*
349
-	* @param int $form_id
350
-	* @param object $form
351
-	* @return array $csv_fields
352
-	*/
345
+	 * Get the fields that should be included in the CSV export
346
+	 *
347
+	 * @since 2.0.19
348
+	 *
349
+	 * @param int $form_id
350
+	 * @param object $form
351
+	 * @return array $csv_fields
352
+	 */
353 353
 	private static function get_fields_for_csv_export( $form_id, $form ) {
354 354
 		// Phase frm_csv_field_ids out by 2.01.05
355 355
 		$csv_field_ids = apply_filters( 'frm_csv_field_ids', '', $form_id, array( 'form' => $form ) );
@@ -379,16 +379,16 @@  discard block
 block discarded – undo
379 379
 	}
380 380
 
381 381
 	public static function allow_mime( $mimes ) {
382
-        if ( ! isset( $mimes['csv'] ) ) {
383
-            // allow csv files
384
-            $mimes['csv'] = 'text/csv';
385
-        }
386
-
387
-        if ( ! isset( $mimes['xml'] ) ) {
388
-            // allow xml
389
-            $mimes['xml'] = 'text/xml';
390
-        }
391
-
392
-        return $mimes;
393
-    }
382
+		if ( ! isset( $mimes['csv'] ) ) {
383
+			// allow csv files
384
+			$mimes['csv'] = 'text/csv';
385
+		}
386
+
387
+		if ( ! isset( $mimes['xml'] ) ) {
388
+			// allow xml
389
+			$mimes['xml'] = 'text/xml';
390
+		}
391
+
392
+		return $mimes;
393
+	}
394 394
 }
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -12,14 +12,14 @@  discard block
 block discarded – undo
12 12
     		return;
13 13
     	}
14 14
 
15
-        $set_err = libxml_use_internal_errors(true);
15
+        $set_err = libxml_use_internal_errors( true );
16 16
         $loader = libxml_disable_entity_loader( true );
17 17
 
18 18
 		$files = apply_filters( 'frm_default_templates_files', array( FrmAppHelper::plugin_path() . '/classes/views/xml/default-templates.xml' ) );
19 19
 
20 20
         foreach ( (array) $files as $file ) {
21
-            FrmXMLHelper::import_xml($file);
22
-            unset($file);
21
+            FrmXMLHelper::import_xml( $file );
22
+            unset( $file );
23 23
         }
24 24
         /*
25 25
         if(is_wp_error($result))
@@ -70,41 +70,41 @@  discard block
 block discarded – undo
70 70
         $errors = array();
71 71
         $message = '';
72 72
 
73
-        $permission_error = FrmAppHelper::permission_nonce_error('frm_edit_forms', 'import-xml', 'import-xml-nonce');
73
+        $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'import-xml', 'import-xml-nonce' );
74 74
         if ( $permission_error !== false ) {
75 75
             $errors[] = $permission_error;
76
-            self::form($errors);
76
+            self::form( $errors );
77 77
             return;
78 78
         }
79 79
 
80
-        if ( ! isset($_FILES) || ! isset($_FILES['frm_import_file']) || empty($_FILES['frm_import_file']['name']) || (int) $_FILES['frm_import_file']['size'] < 1 ) {
80
+        if ( ! isset( $_FILES ) || ! isset( $_FILES['frm_import_file'] ) || empty( $_FILES['frm_import_file']['name'] ) || (int) $_FILES['frm_import_file']['size'] < 1 ) {
81 81
             $errors[] = __( 'Oops, you didn\'t select a file.', 'formidable' );
82
-            self::form($errors);
82
+            self::form( $errors );
83 83
             return;
84 84
         }
85 85
 
86 86
         $file = $_FILES['frm_import_file']['tmp_name'];
87 87
 
88 88
         if ( ! is_uploaded_file( $file ) ) {
89
-            unset($file);
89
+            unset( $file );
90 90
             $errors[] = __( 'The file does not exist, please try again.', 'formidable' );
91
-            self::form($errors);
91
+            self::form( $errors );
92 92
             return;
93 93
         }
94 94
 
95 95
         //add_filter('upload_mimes', 'FrmXMLController::allow_mime');
96 96
 
97
-        $export_format = apply_filters('frm_export_formats', array(
97
+        $export_format = apply_filters( 'frm_export_formats', array(
98 98
 			'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ),
99 99
 		) );
100 100
 
101
-        $file_type = strtolower(pathinfo($_FILES['frm_import_file']['name'], PATHINFO_EXTENSION));
102
-        if ( $file_type != 'xml' && isset( $export_format[ $file_type ] ) ) {
101
+        $file_type = strtolower( pathinfo( $_FILES['frm_import_file']['name'], PATHINFO_EXTENSION ) );
102
+        if ( $file_type != 'xml' && isset( $export_format[$file_type] ) ) {
103 103
             // allow other file types to be imported
104 104
 			do_action( 'frm_before_import_' . $file_type );
105 105
             return;
106 106
         }
107
-        unset($file_type);
107
+        unset( $file_type );
108 108
 
109 109
 		if ( ! function_exists( 'libxml_disable_entity_loader' ) ) {
110 110
 			$errors[] = __( 'XML import is not enabled on your server.', 'formidable' );
@@ -123,12 +123,12 @@  discard block
 block discarded – undo
123 123
 		libxml_use_internal_errors( $set_err );
124 124
 		libxml_disable_entity_loader( $loader );
125 125
 
126
-        self::form($errors, $message);
126
+        self::form( $errors, $message );
127 127
     }
128 128
 
129 129
     public static function export_xml() {
130 130
         $error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'export-xml', 'export-xml-nonce' );
131
-        if ( ! empty($error) ) {
131
+        if ( ! empty( $error ) ) {
132 132
             wp_die( $error );
133 133
         }
134 134
 
@@ -142,11 +142,11 @@  discard block
 block discarded – undo
142 142
         }
143 143
 
144 144
         if ( $format == 'xml' ) {
145
-            self::generate_xml($type, compact('ids'));
145
+            self::generate_xml( $type, compact( 'ids' ) );
146 146
 		} if ( $format == 'csv' ) {
147
-			self::generate_csv( compact('ids') );
147
+			self::generate_csv( compact( 'ids' ) );
148 148
         } else {
149
-			do_action( 'frm_export_format_' . $format, compact('ids') );
149
+			do_action( 'frm_export_format_' . $format, compact( 'ids' ) );
150 150
         }
151 151
 
152 152
         wp_die();
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 		foreach ( $type as $tb_type ) {
190 190
             $where = array();
191 191
 			$join = '';
192
-            $table = $tables[ $tb_type ];
192
+            $table = $tables[$tb_type];
193 193
 
194 194
 			$select = $table . '.id';
195 195
             $query_vars = array();
@@ -200,20 +200,20 @@  discard block
 block discarded – undo
200 200
                     if ( $args['ids'] ) {
201 201
 						$where[] = array( 'or' => 1, $table . '.id' => $args['ids'], $table . '.parent_form_id' => $args['ids'] );
202 202
                 	} else {
203
-						$where[ $table . '.status !' ] = 'draft';
203
+						$where[$table . '.status !'] = 'draft';
204 204
                 	}
205 205
                 break;
206 206
                 case 'actions':
207 207
 					$select = $table . '.ID';
208 208
 					$where['post_type'] = FrmFormActionsController::$action_post_type;
209
-                    if ( ! empty($args['ids']) ) {
209
+                    if ( ! empty( $args['ids'] ) ) {
210 210
 						$where['menu_order'] = $args['ids'];
211 211
                     }
212 212
                 break;
213 213
                 case 'items':
214 214
                     //$join = "INNER JOIN {$wpdb->prefix}frm_item_metas im ON ($table.id = im.item_id)";
215 215
                     if ( $args['ids'] ) {
216
-						$where[ $table . '.form_id' ] = $args['ids'];
216
+						$where[$table . '.form_id'] = $args['ids'];
217 217
                     }
218 218
                 break;
219 219
                 case 'styles':
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
                     $join = ' INNER JOIN ' . $wpdb->postmeta . ' pm ON (pm.post_id=' . $table . '.ID)';
248 248
                     $where['pm.meta_key'] = 'frm_form_id';
249 249
 
250
-                    if ( empty($args['ids']) ) {
250
+                    if ( empty( $args['ids'] ) ) {
251 251
                         $where['pm.meta_value >'] = 1;
252 252
                     } else {
253 253
                         $where['pm.meta_value'] = $args['ids'];
@@ -255,11 +255,11 @@  discard block
 block discarded – undo
255 255
                 break;
256 256
             }
257 257
 
258
-			$records[ $tb_type ] = FrmDb::get_col( $table . $join, $where, $select );
259
-            unset($tb_type);
258
+			$records[$tb_type] = FrmDb::get_col( $table . $join, $where, $select );
259
+            unset( $tb_type );
260 260
         }
261 261
 
262
-		echo '<?xml version="1.0" encoding="' . esc_attr( get_bloginfo('charset') ) . "\" ?>\n";
262
+		echo '<?xml version="1.0" encoding="' . esc_attr( get_bloginfo( 'charset' ) ) . "\" ?>\n";
263 263
 		include( FrmAppHelper::plugin_path() . '/classes/views/xml/xml.php' );
264 264
     }
265 265
 
@@ -297,10 +297,10 @@  discard block
 block discarded – undo
297 297
 			$fid = FrmAppHelper::get_param( 'fid', '', 'get', 'sanitize_text_field' );
298 298
 		}
299 299
 
300
-		set_time_limit(0); //Remove time limit to execute this function
301
-		$mem_limit = str_replace('M', '', ini_get('memory_limit'));
300
+		set_time_limit( 0 ); //Remove time limit to execute this function
301
+		$mem_limit = str_replace( 'M', '', ini_get( 'memory_limit' ) );
302 302
 		if ( (int) $mem_limit < 256 ) {
303
-			ini_set('memory_limit', '256M');
303
+			ini_set( 'memory_limit', '256M' );
304 304
 		}
305 305
 
306 306
 		global $wpdb;
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
 			$no_export_fields = FrmField::no_save_fields();
371 371
 			foreach ( $csv_fields as $k => $f ) {
372 372
 				if ( in_array( $f->type, $no_export_fields ) ) {
373
-					unset( $csv_fields[ $k ] );
373
+					unset( $csv_fields[$k] );
374 374
 				}
375 375
 			}
376 376
 		}
Please login to merge, or discard this patch.
classes/helpers/FrmFieldsHelper.php 2 patches
Spacing   +164 added lines, -164 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,41 +268,41 @@  discard block
 block discarded – undo
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
 		self::add_field_div_classes( $field_id, $field, $errors, $html );
282 282
 
283 283
         //replace [entry_key]
284 284
         $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' );
285
-        $html = str_replace('[entry_key]', $entry_key, $html);
285
+        $html = str_replace( '[entry_key]', $entry_key, $html );
286 286
 
287 287
         //replace [input]
288
-        preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER);
288
+        preg_match_all( "/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER );
289 289
         global $frm_vars;
290 290
         $frm_settings = FrmAppHelper::get_settings();
291 291
 
292 292
         foreach ( $shortcodes[0] as $short_key => $tag ) {
293
-            $atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
293
+            $atts = shortcode_parse_atts( $shortcodes[2][$short_key] );
294 294
 			$tag = self::get_shortcode_tag( $shortcodes, $short_key, array( 'conditional' => false, 'conditional_check' => false ) );
295 295
 
296 296
             $replace_with = '';
297 297
 
298 298
             if ( $tag == 'input' ) {
299
-                if ( isset($atts['opt']) ) {
300
-                    $atts['opt']--;
299
+                if ( isset( $atts['opt'] ) ) {
300
+                    $atts['opt'] --;
301 301
                 }
302 302
 
303
-                $field['input_class'] = isset($atts['class']) ? $atts['class'] : '';
304
-                if ( isset($atts['class']) ) {
305
-                    unset($atts['class']);
303
+                $field['input_class'] = isset( $atts['class'] ) ? $atts['class'] : '';
304
+                if ( isset( $atts['class'] ) ) {
305
+                    unset( $atts['class'] );
306 306
                 }
307 307
 
308 308
                 $field['shortcodes'] = $atts;
@@ -311,33 +311,33 @@  discard block
 block discarded – undo
311 311
                 $replace_with = ob_get_contents();
312 312
                 ob_end_clean();
313 313
             } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) {
314
-                $replace_with = FrmProEntriesController::entry_delete_link($atts);
314
+                $replace_with = FrmProEntriesController::entry_delete_link( $atts );
315 315
             }
316 316
 
317
-            $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html );
317
+            $html = str_replace( $shortcodes[0][$short_key], $replace_with, $html );
318 318
         }
319 319
 
320 320
 		if ( $form ) {
321 321
             $form = (array) $form;
322 322
 
323 323
             //replace [form_key]
324
-            $html = str_replace('[form_key]', $form['form_key'], $html);
324
+            $html = str_replace( '[form_key]', $form['form_key'], $html );
325 325
 
326 326
             //replace [form_name]
327
-            $html = str_replace('[form_name]', $form['name'], $html);
327
+            $html = str_replace( '[form_name]', $form['name'], $html );
328 328
         }
329 329
         $html .= "\n";
330 330
 
331 331
         //Return html if conf_field to prevent loop
332
-        if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) {
332
+        if ( isset( $field['conf_field'] ) && $field['conf_field'] == 'stop' ) {
333 333
             return $html;
334 334
         }
335 335
 
336 336
         //If field is in repeating section
337 337
         if ( $args['section_id'] ) {
338
-            $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'] ));
338
+            $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'] ) );
339 339
         } else {
340
-            $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ));
340
+            $html = apply_filters( 'frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ) );
341 341
         }
342 342
 
343 343
 		self::remove_collapse_shortcode( $html );
@@ -382,14 +382,14 @@  discard block
 block discarded – undo
382 382
 	 */
383 383
 	private static function get_field_div_classes( $field_id, $field, $errors, $html ) {
384 384
 		// Add error class
385
-		$classes = isset( $errors[ 'field' . $field_id ] ) ? ' frm_blank_field' : '';
385
+		$classes = isset( $errors['field' . $field_id] ) ? ' frm_blank_field' : '';
386 386
 
387 387
 		// Add label position class
388 388
 		$classes .= ' frm_' . $field['label'] . '_container';
389 389
 
390 390
 		// Add CSS layout classes
391 391
 		if ( ! empty( $field['classes'] ) ) {
392
-			if ( ! strpos( $html, 'frm_form_field ') ) {
392
+			if ( ! strpos( $html, 'frm_form_field ' ) ) {
393 393
 				$classes .= ' frm_form_field';
394 394
 			}
395 395
 			$classes .= ' ' . $field['classes'];
@@ -428,15 +428,15 @@  discard block
 block discarded – undo
428 428
         }
429 429
 
430 430
         $with_tags = $args['conditional_check'] ? 3 : 2;
431
-        if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
432
-            $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
433
-            $tag = str_replace(']', '', $tag);
434
-            $tags = explode(' ', $tag);
435
-            if ( is_array($tags) ) {
431
+        if ( ! empty( $shortcodes[$with_tags][$short_key] ) ) {
432
+            $tag = str_replace( '[' . $prefix, '', $shortcodes[0][$short_key] );
433
+            $tag = str_replace( ']', '', $tag );
434
+            $tags = explode( ' ', $tag );
435
+            if ( is_array( $tags ) ) {
436 436
                 $tag = $tags[0];
437 437
             }
438 438
         } else {
439
-            $tag = $shortcodes[ $with_tags - 1 ][ $short_key ];
439
+            $tag = $shortcodes[$with_tags - 1][$short_key];
440 440
         }
441 441
 
442 442
         return $tag;
@@ -480,10 +480,10 @@  discard block
 block discarded – undo
480 480
 
481 481
 	public static function show_single_option( $field ) {
482 482
         $field_name = $field['name'];
483
-        $html_id = self::get_html_id($field);
483
+        $html_id = self::get_html_id( $field );
484 484
         foreach ( $field['options'] as $opt_key => $opt ) {
485
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
486
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
485
+            $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field );
486
+            $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field );
487 487
 
488 488
             // If this is an "Other" option, get the HTML for it
489 489
 			if ( self::is_other_opt( $opt_key ) ) {
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
     }
498 498
 
499 499
 	public static function get_term_link( $tax_id ) {
500
-        $tax = get_taxonomy($tax_id);
500
+        $tax = get_taxonomy( $tax_id );
501 501
         if ( ! $tax ) {
502 502
             return;
503 503
         }
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
             __( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
507 507
 			'<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>'
508 508
         );
509
-        unset($tax);
509
+        unset( $tax );
510 510
 
511 511
         return $link;
512 512
     }
@@ -520,8 +520,8 @@  discard block
 block discarded – undo
520 520
 		$observed_value = wp_kses_post( $observed_value );
521 521
 		$hide_opt = wp_kses_post( $hide_opt );
522 522
 
523
-        if ( is_array($observed_value) ) {
524
-            return self::array_value_condition($observed_value, $cond, $hide_opt);
523
+        if ( is_array( $observed_value ) ) {
524
+            return self::array_value_condition( $observed_value, $cond, $hide_opt );
525 525
         }
526 526
 
527 527
         $m = false;
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
         } else if ( $cond == '<' ) {
535 535
             $m = $observed_value < $hide_opt;
536 536
         } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
537
-            $m = stripos($observed_value, $hide_opt);
537
+            $m = stripos( $observed_value, $hide_opt );
538 538
             if ( $cond == 'not LIKE' ) {
539 539
                 $m = ( $m === false ) ? true : false;
540 540
             } else {
@@ -547,23 +547,23 @@  discard block
 block discarded – undo
547 547
 	public static function array_value_condition( $observed_value, $cond, $hide_opt ) {
548 548
         $m = false;
549 549
         if ( $cond == '==' ) {
550
-            if ( is_array($hide_opt) ) {
551
-                $m = array_intersect($hide_opt, $observed_value);
552
-                $m = empty($m) ? false : true;
550
+            if ( is_array( $hide_opt ) ) {
551
+                $m = array_intersect( $hide_opt, $observed_value );
552
+                $m = empty( $m ) ? false : true;
553 553
             } else {
554
-                $m = in_array($hide_opt, $observed_value);
554
+                $m = in_array( $hide_opt, $observed_value );
555 555
             }
556 556
         } else if ( $cond == '!=' ) {
557
-            $m = ! in_array($hide_opt, $observed_value);
557
+            $m = ! in_array( $hide_opt, $observed_value );
558 558
         } else if ( $cond == '>' ) {
559
-            $min = min($observed_value);
559
+            $min = min( $observed_value );
560 560
             $m = $min > $hide_opt;
561 561
         } else if ( $cond == '<' ) {
562
-            $max = max($observed_value);
562
+            $max = max( $observed_value );
563 563
             $m = $max < $hide_opt;
564 564
         } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
565 565
             foreach ( $observed_value as $ob ) {
566
-                $m = strpos($ob, $hide_opt);
566
+                $m = strpos( $ob, $hide_opt );
567 567
                 if ( $m !== false ) {
568 568
                     $m = true;
569 569
                     break;
@@ -584,27 +584,27 @@  discard block
 block discarded – undo
584 584
      * @return string
585 585
      */
586 586
 	public static function basic_replace_shortcodes( $value, $form, $entry ) {
587
-        if ( strpos($value, '[sitename]') !== false ) {
587
+        if ( strpos( $value, '[sitename]' ) !== false ) {
588 588
             $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
589
-            $value = str_replace('[sitename]', $new_value, $value);
589
+            $value = str_replace( '[sitename]', $new_value, $value );
590 590
         }
591 591
 
592
-        $value = apply_filters('frm_content', $value, $form, $entry);
593
-        $value = do_shortcode($value);
592
+        $value = apply_filters( 'frm_content', $value, $form, $entry );
593
+        $value = do_shortcode( $value );
594 594
 
595 595
         return $value;
596 596
     }
597 597
 
598 598
 	public static function get_shortcodes( $content, $form_id ) {
599 599
         if ( FrmAppHelper::pro_is_installed() ) {
600
-            return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
600
+            return FrmProDisplaysHelper::get_shortcodes( $content, $form_id );
601 601
         }
602 602
 
603 603
         $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) );
604 604
 
605
-        $tagregexp = self::allowed_shortcodes($fields);
605
+        $tagregexp = self::allowed_shortcodes( $fields );
606 606
 
607
-        preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
607
+        preg_match_all( "/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER );
608 608
 
609 609
         return $matches;
610 610
     }
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
             $tagregexp[] = $field->field_key;
623 623
         }
624 624
 
625
-        $tagregexp = implode('|', $tagregexp);
625
+        $tagregexp = implode( '|', $tagregexp );
626 626
         return $tagregexp;
627 627
     }
628 628
 
@@ -634,28 +634,28 @@  discard block
 block discarded – undo
634 634
         );
635 635
 
636 636
         foreach ( $shortcodes[0] as $short_key => $tag ) {
637
-            $atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] );
637
+            $atts = shortcode_parse_atts( $shortcodes[3][$short_key] );
638 638
 
639
-            if ( ! empty( $shortcodes[3][ $short_key ] ) ) {
640
-				$tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] );
641
-                $tags = explode(' ', $tag);
642
-                if ( is_array($tags) ) {
639
+            if ( ! empty( $shortcodes[3][$short_key] ) ) {
640
+				$tag = str_replace( array( '[', ']' ), '', $shortcodes[0][$short_key] );
641
+                $tags = explode( ' ', $tag );
642
+                if ( is_array( $tags ) ) {
643 643
                     $tag = $tags[0];
644 644
                 }
645 645
             } else {
646
-                $tag = $shortcodes[2][ $short_key ];
646
+                $tag = $shortcodes[2][$short_key];
647 647
             }
648 648
 
649 649
             switch ( $tag ) {
650 650
                 case 'id':
651 651
                 case 'key':
652 652
                 case 'ip':
653
-                    $replace_with = $shortcode_values[ $tag ];
653
+                    $replace_with = $shortcode_values[$tag];
654 654
                 break;
655 655
 
656 656
                 case 'user_agent':
657 657
                 case 'user-agent':
658
-                    $entry->description = maybe_unserialize($entry->description);
658
+                    $entry->description = maybe_unserialize( $entry->description );
659 659
 					$replace_with = FrmEntryFormat::get_browser( $entry->description['browser'] );
660 660
                 break;
661 661
 
@@ -663,25 +663,25 @@  discard block
 block discarded – undo
663 663
                 case 'created-at':
664 664
                 case 'updated_at':
665 665
                 case 'updated-at':
666
-                    if ( isset($atts['format']) ) {
666
+                    if ( isset( $atts['format'] ) ) {
667 667
                         $time_format = ' ';
668 668
                     } else {
669
-                        $atts['format'] = get_option('date_format');
669
+                        $atts['format'] = get_option( 'date_format' );
670 670
                         $time_format = '';
671 671
                     }
672 672
 
673
-                    $this_tag = str_replace('-', '_', $tag);
674
-                    $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
675
-                    unset($this_tag);
673
+                    $this_tag = str_replace( '-', '_', $tag );
674
+                    $replace_with = FrmAppHelper::get_formatted_time( $entry->{$this_tag}, $atts['format'], $time_format );
675
+                    unset( $this_tag );
676 676
                 break;
677 677
 
678 678
                 case 'created_by':
679 679
                 case 'created-by':
680 680
                 case 'updated_by':
681 681
                 case 'updated-by':
682
-                    $this_tag = str_replace('-', '_', $tag);
682
+                    $this_tag = str_replace( '-', '_', $tag );
683 683
 					$replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts );
684
-                    unset($this_tag);
684
+                    unset( $this_tag );
685 685
                 break;
686 686
 
687 687
                 case 'admin_email':
@@ -698,16 +698,16 @@  discard block
 block discarded – undo
698 698
                         break;
699 699
                     }
700 700
 
701
-                    $sep = isset($atts['sep']) ? $atts['sep'] : ', ';
701
+                    $sep = isset( $atts['sep'] ) ? $atts['sep'] : ', ';
702 702
 
703 703
                     $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id );
704 704
 
705 705
                     $atts['entry_id'] = $entry->id;
706 706
                     $atts['entry_key'] = $entry->item_key;
707 707
 
708
-                    if ( isset($atts['show']) && $atts['show'] == 'field_label' ) {
708
+                    if ( isset( $atts['show'] ) && $atts['show'] == 'field_label' ) {
709 709
                         $replace_with = $field->name;
710
-                    } else if ( isset($atts['show']) && $atts['show'] == 'description' ) {
710
+                    } else if ( isset( $atts['show'] ) && $atts['show'] == 'description' ) {
711 711
                         $replace_with = $field->description;
712 712
 					} else {
713 713
 						$string_value = $replace_with;
@@ -722,15 +722,15 @@  discard block
 block discarded – undo
722 722
 						}
723 723
 					}
724 724
 
725
-                    unset($field);
725
+                    unset( $field );
726 726
                 break;
727 727
             }
728 728
 
729
-            if ( isset($replace_with) ) {
730
-                $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
729
+            if ( isset( $replace_with ) ) {
730
+                $content = str_replace( $shortcodes[0][$short_key], $replace_with, $content );
731 731
             }
732 732
 
733
-            unset($atts, $conditional, $replace_with);
733
+            unset( $atts, $conditional, $replace_with );
734 734
 		}
735 735
 
736 736
 		return $content;
@@ -746,7 +746,7 @@  discard block
 block discarded – undo
746 746
         $new_value = '';
747 747
         switch ( $tag ) {
748 748
             case 'admin_email':
749
-                $new_value = get_option('admin_email');
749
+                $new_value = get_option( 'admin_email' );
750 750
                 break;
751 751
             case 'siteurl':
752 752
                 $new_value = FrmAppHelper::site_url();
@@ -772,28 +772,28 @@  discard block
 block discarded – undo
772 772
      * @return string|array
773 773
      */
774 774
     public static function process_get_shortcode( $atts, $return_array = false ) {
775
-        if ( ! isset($atts['param']) ) {
775
+        if ( ! isset( $atts['param'] ) ) {
776 776
             return '';
777 777
         }
778 778
 
779
-        if ( strpos($atts['param'], '&#91;') ) {
780
-            $atts['param'] = str_replace('&#91;', '[', $atts['param']);
781
-            $atts['param'] = str_replace('&#93;', ']', $atts['param']);
779
+        if ( strpos( $atts['param'], '&#91;' ) ) {
780
+            $atts['param'] = str_replace( '&#91;', '[', $atts['param'] );
781
+            $atts['param'] = str_replace( '&#93;', ']', $atts['param'] );
782 782
         }
783 783
 
784
-        $new_value = FrmAppHelper::get_param($atts['param'], '');
784
+        $new_value = FrmAppHelper::get_param( $atts['param'], '' );
785 785
         $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
786 786
 
787 787
         if ( $new_value == '' ) {
788
-            if ( ! isset($atts['prev_val']) ) {
788
+            if ( ! isset( $atts['prev_val'] ) ) {
789 789
                 $atts['prev_val'] = '';
790 790
             }
791 791
 
792
-            $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
792
+            $new_value = isset( $atts['default'] ) ? $atts['default'] : $atts['prev_val'];
793 793
         }
794 794
 
795
-        if ( is_array($new_value) && ! $return_array ) {
796
-            $new_value = implode(', ', $new_value);
795
+        if ( is_array( $new_value ) && ! $return_array ) {
796
+            $new_value = implode( ', ', $new_value );
797 797
         }
798 798
 
799 799
         return $new_value;
@@ -806,12 +806,12 @@  discard block
 block discarded – undo
806 806
 		$replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts );
807 807
 
808 808
         if ( $field->type == 'textarea' || $field->type == 'rte' ) {
809
-            $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true;
810
-            if ( apply_filters('frm_use_wpautop', $autop) ) {
811
-                if ( is_array($replace_with) ) {
812
-                    $replace_with = implode("\n", $replace_with);
809
+            $autop = isset( $atts['wpautop'] ) ? $atts['wpautop'] : true;
810
+            if ( apply_filters( 'frm_use_wpautop', $autop ) ) {
811
+                if ( is_array( $replace_with ) ) {
812
+                    $replace_with = implode( "\n", $replace_with );
813 813
                 }
814
-                $replace_with = wpautop($replace_with);
814
+                $replace_with = wpautop( $replace_with );
815 815
             }
816 816
 			unset( $autop );
817 817
 		} else if ( is_array( $replace_with ) ) {
@@ -833,14 +833,14 @@  discard block
 block discarded – undo
833 833
 		$field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() );
834 834
 
835 835
         $field_types = array();
836
-        if ( in_array($type, $single_input) ) {
836
+        if ( in_array( $type, $single_input ) ) {
837 837
             self::field_types_for_input( $single_input, $field_selection, $field_types );
838
-        } else if ( in_array($type, $multiple_input) ) {
838
+        } else if ( in_array( $type, $multiple_input ) ) {
839 839
             self::field_types_for_input( $multiple_input, $field_selection, $field_types );
840
-        } else if ( in_array($type, $other_type) ) {
840
+        } else if ( in_array( $type, $other_type ) ) {
841 841
             self::field_types_for_input( $other_type, $field_selection, $field_types );
842
-		} else if ( isset( $field_selection[ $type ] ) ) {
843
-            $field_types[ $type ] = $field_selection[ $type ];
842
+		} else if ( isset( $field_selection[$type] ) ) {
843
+            $field_types[$type] = $field_selection[$type];
844 844
         }
845 845
 
846 846
 		$field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) );
@@ -849,8 +849,8 @@  discard block
 block discarded – undo
849 849
 
850 850
     private static function field_types_for_input( $inputs, $fields, &$field_types ) {
851 851
         foreach ( $inputs as $input ) {
852
-            $field_types[ $input ] = $fields[ $input ];
853
-            unset($input);
852
+            $field_types[$input] = $fields[$input];
853
+            unset( $input );
854 854
         }
855 855
     }
856 856
 
@@ -895,21 +895,21 @@  discard block
 block discarded – undo
895 895
 		// Check posted vals before checking saved values
896 896
 
897 897
 		// For fields inside repeating sections - note, don't check if $pointer is true because it will often be zero
898
-		if ( $parent && isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ) {
898
+		if ( $parent && isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] ) ) {
899 899
 			if ( FrmField::is_field_with_multiple_values( $field ) ) {
900
-				$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 ] ) : '';
900
+				$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] ) : '';
901 901
 			} else {
902
-				$other_val = sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] );
902
+				$other_val = sanitize_text_field( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] );
903 903
 			}
904 904
 			return $other_val;
905 905
 
906
-		} else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][ $field['id'] ] ) ) {
906
+		} else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][$field['id']] ) ) {
907 907
 			// For normal fields
908 908
 
909 909
 			if ( FrmField::is_field_with_multiple_values( $field ) ) {
910
-				$other_val = isset( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) : '';
910
+				$other_val = isset( $_POST['item_meta']['other'][$field['id']][$opt_key] ) ? sanitize_text_field( $_POST['item_meta']['other'][$field['id']][$opt_key] ) : '';
911 911
 			} else {
912
-				$other_val = sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ] );
912
+				$other_val = sanitize_text_field( $_POST['item_meta']['other'][$field['id']] );
913 913
 			}
914 914
 			return $other_val;
915 915
 		}
@@ -918,8 +918,8 @@  discard block
 block discarded – undo
918 918
 		if ( $field['type'] == 'checkbox' && is_array( $field['value'] ) ) {
919 919
 			// Check if there is an "other" val in saved value and make sure the
920 920
 			// "other" val is not equal to the Other checkbox option
921
-			if ( isset( $field['value'][ $opt_key ] ) && $field['options'][ $opt_key ] != $field['value'][ $opt_key ] ) {
922
-				$other_val = $field['value'][ $opt_key ];
921
+			if ( isset( $field['value'][$opt_key] ) && $field['options'][$opt_key] != $field['value'][$opt_key] ) {
922
+				$other_val = $field['value'][$opt_key];
923 923
 			}
924 924
 		} else {
925 925
 			/**
@@ -931,8 +931,8 @@  discard block
 block discarded – undo
931 931
 				// Multi-select dropdowns - key is not preserved
932 932
 				if ( is_array( $field['value'] ) ) {
933 933
 					$o_key = array_search( $temp_val, $field['value'] );
934
-					if ( isset( $field['value'][ $o_key ] ) ) {
935
-						unset( $field['value'][ $o_key ], $o_key );
934
+					if ( isset( $field['value'][$o_key] ) ) {
935
+						unset( $field['value'][$o_key], $o_key );
936 936
 					}
937 937
 				} else if ( $temp_val == $field['value'] ) {
938 938
 					// For radio and regular dropdowns
@@ -989,7 +989,7 @@  discard block
 block discarded – undo
989 989
 	private static function set_other_name( $args, &$other_args ) {
990 990
 		//Set up name for other field
991 991
 		$other_args['name'] = str_replace( '[]', '', $args['field_name'] );
992
-		$other_args['name'] = preg_replace('/\[' . $args['field']['id'] . '\]$/', '', $other_args['name']);
992
+		$other_args['name'] = preg_replace( '/\[' . $args['field']['id'] . '\]$/', '', $other_args['name'] );
993 993
 		$other_args['name'] = $other_args['name'] . '[other]' . '[' . $args['field']['id'] . ']';
994 994
 
995 995
 		//Converts item_meta[field_id] => item_meta[other][field_id] and
@@ -1015,7 +1015,7 @@  discard block
 block discarded – undo
1015 1015
 		// Count should only be greater than 3 if inside of a repeating section
1016 1016
 		if ( count( $temp_array ) > 3 ) {
1017 1017
 			$parent = str_replace( ']', '', $temp_array[1] );
1018
-			$pointer = str_replace( ']', '', $temp_array[2]);
1018
+			$pointer = str_replace( ']', '', $temp_array[2] );
1019 1019
 		}
1020 1020
 
1021 1021
 		// Get text for "other" text field
@@ -1134,15 +1134,15 @@  discard block
 block discarded – undo
1134 1134
 			$replace_with[] = '[' . $new . ']';
1135 1135
 			$replace[] = '[' . $old . ' ';
1136 1136
 			$replace_with[] = '[' . $new . ' ';
1137
-            unset($old, $new);
1137
+            unset( $old, $new );
1138 1138
         }
1139 1139
 		if ( is_array( $val ) ) {
1140 1140
 			foreach ( $val as $k => $v ) {
1141
-                $val[ $k ] = str_replace( $replace, $replace_with, $v );
1142
-                unset($k, $v);
1141
+                $val[$k] = str_replace( $replace, $replace_with, $v );
1142
+                unset( $k, $v );
1143 1143
             }
1144 1144
         } else {
1145
-            $val = str_replace($replace, $replace_with, $val);
1145
+            $val = str_replace( $replace, $replace_with, $val );
1146 1146
         }
1147 1147
 
1148 1148
         return $val;
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
             'DC' => 'District of Columbia',
1156 1156
             'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho',
1157 1157
             'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas',
1158
-            'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland',
1158
+            'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine', 'MD' => 'Maryland',
1159 1159
             'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
1160 1160
             'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada',
1161 1161
             'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York',
@@ -1246,35 +1246,35 @@  discard block
 block discarded – undo
1246 1246
     }
1247 1247
 
1248 1248
 	public static function get_bulk_prefilled_opts( array &$prepop ) {
1249
-		$prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries();
1249
+		$prepop[__( 'Countries', 'formidable' )] = FrmFieldsHelper::get_countries();
1250 1250
 
1251 1251
         $states = FrmFieldsHelper::get_us_states();
1252
-        $state_abv = array_keys($states);
1253
-        sort($state_abv);
1254
-		$prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv;
1252
+        $state_abv = array_keys( $states );
1253
+        sort( $state_abv );
1254
+		$prepop[__( 'U.S. State Abbreviations', 'formidable' )] = $state_abv;
1255 1255
 
1256
-        $states = array_values($states);
1257
-        sort($states);
1258
-		$prepop[ __( 'U.S. States', 'formidable' ) ] = $states;
1259
-        unset($state_abv, $states);
1256
+        $states = array_values( $states );
1257
+        sort( $states );
1258
+		$prepop[__( 'U.S. States', 'formidable' )] = $states;
1259
+        unset( $state_abv, $states );
1260 1260
 
1261
-		$prepop[ __( 'Age', 'formidable' ) ] = array(
1261
+		$prepop[__( 'Age', 'formidable' )] = array(
1262 1262
             __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1263 1263
             __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1264 1264
             __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1265 1265
         );
1266 1266
 
1267
-		$prepop[ __( 'Satisfaction', 'formidable' ) ] = array(
1267
+		$prepop[__( 'Satisfaction', 'formidable' )] = array(
1268 1268
             __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1269 1269
             __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1270 1270
         );
1271 1271
 
1272
-		$prepop[ __( 'Importance', 'formidable' ) ] = array(
1272
+		$prepop[__( 'Importance', 'formidable' )] = array(
1273 1273
             __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1274 1274
             __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1275 1275
         );
1276 1276
 
1277
-		$prepop[ __( 'Agreement', 'formidable' ) ] = array(
1277
+		$prepop[__( 'Agreement', 'formidable' )] = array(
1278 1278
             __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1279 1279
             __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1280 1280
         );
Please login to merge, or discard this patch.
Indentation   +712 added lines, -712 removed lines patch added patch discarded remove patch
@@ -7,71 +7,71 @@  discard block
 block discarded – undo
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);
12
-        }
13
-
14
-        $defaults = self::get_default_field_opts($type, $form_id);
15
-        $defaults['field_options']['custom_html'] = self::get_default_html($type);
16
-
17
-        $values = array();
18
-
19
-        foreach ( $defaults as $var => $default ) {
20
-            if ( $var == 'field_options' ) {
21
-                $values['field_options'] = array();
22
-                foreach ( $default as $opt_var => $opt_default ) {
23
-                    $values['field_options'][ $opt_var ] = $opt_default;
24
-                    unset($opt_var, $opt_default);
25
-                }
26
-            } else {
27
-                $values[ $var ] = $default;
28
-            }
29
-            unset($var, $default);
30
-        }
31
-
32
-        if ( isset( $setting ) && ! empty( $setting ) ) {
33
-            if ( in_array( $type, array( 'data', 'lookup' ) ) ) {
34
-                $values['field_options']['data_type'] = $setting;
35
-            } else {
36
-                $values['field_options'][ $setting ] = 1;
37
-            }
38
-        }
39
-
40
-        if ( $type == 'radio' || $type == 'checkbox' ) {
41
-            $values['options'] = serialize( array(
42
-                __( 'Option 1', 'formidable' ),
43
-                __( 'Option 2', 'formidable' ),
44
-            ) );
45
-        } else if ( $type == 'select' ) {
46
-            $values['options'] = serialize( array(
47
-                '', __( 'Option 1', 'formidable' ),
48
-            ) );
49
-        } else if ( $type == 'textarea' ) {
50
-            $values['field_options']['max'] = '5';
51
-        } else if ( $type == 'captcha' ) {
52
-            $frm_settings = FrmAppHelper::get_settings();
53
-            $values['invalid'] = $frm_settings->re_msg;
54
-        } else if ( 'url' == $type ) {
55
-            $values['name'] = __( 'Website', 'formidable' );
56
-        }
10
+		if ( strpos($type, '|') ) {
11
+			list($type, $setting) = explode('|', $type);
12
+		}
13
+
14
+		$defaults = self::get_default_field_opts($type, $form_id);
15
+		$defaults['field_options']['custom_html'] = self::get_default_html($type);
16
+
17
+		$values = array();
18
+
19
+		foreach ( $defaults as $var => $default ) {
20
+			if ( $var == 'field_options' ) {
21
+				$values['field_options'] = array();
22
+				foreach ( $default as $opt_var => $opt_default ) {
23
+					$values['field_options'][ $opt_var ] = $opt_default;
24
+					unset($opt_var, $opt_default);
25
+				}
26
+			} else {
27
+				$values[ $var ] = $default;
28
+			}
29
+			unset($var, $default);
30
+		}
31
+
32
+		if ( isset( $setting ) && ! empty( $setting ) ) {
33
+			if ( in_array( $type, array( 'data', 'lookup' ) ) ) {
34
+				$values['field_options']['data_type'] = $setting;
35
+			} else {
36
+				$values['field_options'][ $setting ] = 1;
37
+			}
38
+		}
39
+
40
+		if ( $type == 'radio' || $type == 'checkbox' ) {
41
+			$values['options'] = serialize( array(
42
+				__( 'Option 1', 'formidable' ),
43
+				__( 'Option 2', 'formidable' ),
44
+			) );
45
+		} else if ( $type == 'select' ) {
46
+			$values['options'] = serialize( array(
47
+				'', __( 'Option 1', 'formidable' ),
48
+			) );
49
+		} else if ( $type == 'textarea' ) {
50
+			$values['field_options']['max'] = '5';
51
+		} else if ( $type == 'captcha' ) {
52
+			$frm_settings = FrmAppHelper::get_settings();
53
+			$values['invalid'] = $frm_settings->re_msg;
54
+		} else if ( 'url' == $type ) {
55
+			$values['name'] = __( 'Website', 'formidable' );
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 ];
63
-        }
61
+		if ( isset( $fields[ $type ] ) ) {
62
+			$values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ];
63
+		}
64 64
 
65
-        unset($fields);
65
+		unset($fields);
66 66
 
67
-        return $values;
68
-    }
67
+		return $values;
68
+	}
69 69
 
70 70
 	public static function get_html_id( $field, $plus = '' ) {
71 71
 		return apply_filters( 'frm_field_html_id', 'field_' . $field['field_key'] . $plus, $field );
72
-    }
72
+	}
73 73
 
74
-    public static function setup_edit_vars( $record, $doing_ajax = false ) {
74
+	public static function setup_edit_vars( $record, $doing_ajax = false ) {
75 75
 		$values = array( 'id' => $record->id, 'form_id' => $record->form_id );
76 76
 		$defaults = array(
77 77
 			'name'          => $record->name,
@@ -84,86 +84,86 @@  discard block
 block discarded – undo
84 84
 		);
85 85
 
86 86
 		if ( $doing_ajax ) {
87
-            $values = $values + $defaults;
88
-            $values['form_name'] = '';
87
+			$values = $values + $defaults;
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);
93
-            }
91
+				$values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' );
92
+				unset($var, $default);
93
+			}
94 94
 
95 95
 			$values['form_name'] = $record->form_id ? FrmForm::getName( $record->form_id ) : '';
96
-        }
96
+		}
97 97
 
98 98
 		unset( $defaults );
99 99
 
100
-        $values['options'] = $record->options;
101
-        $values['field_options'] = $record->field_options;
100
+		$values['options'] = $record->options;
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
-            $frm_settings = FrmAppHelper::get_settings();
107
-            $defaults['invalid'] = $frm_settings->re_msg;
108
-        }
106
+			$frm_settings = FrmAppHelper::get_settings();
107
+			$defaults['invalid'] = $frm_settings->re_msg;
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);
113
-        }
111
+			$values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default;
112
+			unset($opt, $default);
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
+	}
119 119
 
120
-    public static function get_default_field_opts( $type, $field, $limit = false ) {
121
-        $field_options = array(
122
-            'size' => '', 'max' => '', 'label' => '', 'blank' => '',
123
-            'required_indicator' => '*', 'invalid' => '', 'separate_value' => 0,
124
-            'clear_on_focus' => 0, 'default_blank' => 0, 'classes' => '',
120
+	public static function get_default_field_opts( $type, $field, $limit = false ) {
121
+		$field_options = array(
122
+			'size' => '', 'max' => '', 'label' => '', 'blank' => '',
123
+			'required_indicator' => '*', 'invalid' => '', 'separate_value' => 0,
124
+			'clear_on_focus' => 0, 'default_blank' => 0, 'classes' => '',
125 125
 			'custom_html' => '', 'captcha_size' => 'default', 'captcha_theme' => 'light',
126
-        );
126
+		);
127 127
 
128 128
 		if ( $limit ) {
129
-            return $field_options;
129
+			return $field_options;
130 130
 		}
131 131
 
132
-        global $wpdb;
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
 
138
-        $field_count = FrmDb::get_var( 'frm_fields', array( 'form_id' => $form_id ), 'field_order', array( 'order_by' => 'field_order DESC' ) );
138
+		$field_count = FrmDb::get_var( 'frm_fields', array( 'form_id' => $form_id ), 'field_order', array( 'order_by' => 'field_order DESC' ) );
139 139
 
140
-        $frm_settings = FrmAppHelper::get_settings();
141
-        return array(
142
-            'name' => __( 'Untitled', 'formidable' ), 'description' => '',
140
+		$frm_settings = FrmAppHelper::get_settings();
141
+		return array(
142
+			'name' => __( 'Untitled', 'formidable' ), 'description' => '',
143 143
 			'field_key' => $key, 'type' => $type, 'options' => '', 'default_value' => '',
144 144
 			'field_order' => $field_count + 1, 'required' => false,
145
-            'blank' => $frm_settings->blank_msg, 'unique_msg' => $frm_settings->unique_msg,
146
-            'invalid' => __( 'This field is invalid', 'formidable' ), 'form_id' => $form_id,
145
+			'blank' => $frm_settings->blank_msg, 'unique_msg' => $frm_settings->unique_msg,
146
+			'invalid' => __( 'This field is invalid', 'formidable' ), 'form_id' => $form_id,
147 147
 			'field_options' => $field_options,
148
-        );
149
-    }
148
+		);
149
+	}
150 150
 
151
-    public static function fill_field( &$values, $field, $form_id, $new_key = '' ) {
152
-        global $wpdb;
151
+	public static function fill_field( &$values, $field, $form_id, $new_key = '' ) {
152
+		global $wpdb;
153 153
 
154 154
 		$values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' );
155
-        $values['form_id'] = $form_id;
156
-        $values['options'] = maybe_serialize($field->options);
157
-        $values['default_value'] = maybe_serialize($field->default_value);
158
-
159
-        foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
160
-            $values[ $col ] = $field->{$col};
161
-        }
162
-    }
163
-
164
-    /**
165
-     * @since 2.0
166
-     */
155
+		$values['form_id'] = $form_id;
156
+		$values['options'] = maybe_serialize($field->options);
157
+		$values['default_value'] = maybe_serialize($field->default_value);
158
+
159
+		foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
160
+			$values[ $col ] = $field->{$col};
161
+		}
162
+	}
163
+
164
+	/**
165
+	 * @since 2.0
166
+	 */
167 167
 	public static function get_error_msg( $field, $error ) {
168 168
 		$frm_settings = FrmAppHelper::get_settings();
169 169
 		$default_settings = $frm_settings->default_options();
@@ -183,21 +183,21 @@  discard block
 block discarded – undo
183 183
 		return $msg;
184 184
 	}
185 185
 
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);
189
-        return $fields;
190
-    }
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);
189
+		return $fields;
190
+	}
191 191
 
192 192
 	public static function get_default_html( $type = 'text' ) {
193 193
 		if ( apply_filters( 'frm_normal_field_type_html', true, $type ) ) {
194 194
 			$input = ( in_array( $type, array( 'radio', 'checkbox', 'data' ) ) ) ? '<div class="frm_opt_container">[input]</div>' : '[input]';
195
-            $for = '';
195
+			$for = '';
196 196
 			if ( ! in_array( $type, array( 'radio', 'checkbox', 'data', 'scale' ) ) ) {
197
-                $for = 'for="field_[key]"';
198
-            }
197
+				$for = 'for="field_[key]"';
198
+			}
199 199
 
200
-            $default_html = <<<DEFAULT_HTML
200
+			$default_html = <<<DEFAULT_HTML
201 201
 <div id="frm_field_[id]_container" class="frm_form_field form-field [required_class][error_class]">
202 202
     <label $for class="frm_primary_label">[field_name]
203 203
         <span class="frm_required">[required_label]</span>
@@ -207,138 +207,138 @@  discard block
 block discarded – undo
207 207
     [if error]<div class="frm_error">[error]</div>[/if error]
208 208
 </div>
209 209
 DEFAULT_HTML;
210
-        } else {
210
+		} else {
211 211
 			$default_html = apply_filters('frm_other_custom_html', '', $type);
212
-        }
212
+		}
213 213
 
214
-        return apply_filters('frm_custom_html', $default_html, $type);
215
-    }
214
+		return apply_filters('frm_custom_html', $default_html, $type);
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
-        $defaults = array(
220
+		$defaults = array(
221 221
 			'field_name'    => 'item_meta[' . $field['id'] . ']',
222 222
 			'field_id'      => $field['id'],
223
-            'field_plus_id' => '',
224
-            'section_id'    => '',
225
-        );
226
-        $args = wp_parse_args($args, $defaults);
227
-        $field_name = $args['field_name'];
228
-        $field_id = $args['field_id'];
229
-        $html_id = self::get_html_id($field, $args['field_plus_id']);
223
+			'field_plus_id' => '',
224
+			'section_id'    => '',
225
+		);
226
+		$args = wp_parse_args($args, $defaults);
227
+		$field_name = $args['field_name'];
228
+		$field_id = $args['field_id'];
229
+		$html_id = self::get_html_id($field, $args['field_plus_id']);
230 230
 
231
-        if ( FrmField::is_multiple_select($field) ) {
232
-            $field_name .= '[]';
233
-        }
231
+		if ( FrmField::is_multiple_select($field) ) {
232
+			$field_name .= '[]';
233
+		}
234 234
 
235
-        //replace [id]
236
-        $html = str_replace('[id]', $field_id, $html);
235
+		//replace [id]
236
+		$html = str_replace('[id]', $field_id, $html);
237 237
 
238
-        // Remove the for attribute for captcha
239
-        if ( $field['type'] == 'captcha' ) {
240
-            $html = str_replace(' for="field_[key]"', '', $html);
241
-        }
238
+		// Remove the for attribute for captcha
239
+		if ( $field['type'] == 'captcha' ) {
240
+			$html = str_replace(' for="field_[key]"', '', $html);
241
+		}
242 242
 
243
-        // set the label for
244
-        $html = str_replace('field_[key]', $html_id, $html);
243
+		// set the label for
244
+		$html = str_replace('field_[key]', $html_id, $html);
245 245
 
246
-        //replace [key]
247
-        $html = str_replace('[key]', $field['field_key'], $html);
246
+		//replace [key]
247
+		$html = str_replace('[key]', $field['field_key'], $html);
248 248
 
249
-        //replace [description] and [required_label] and [error]
249
+		//replace [description] and [required_label] and [error]
250 250
 		$required = FrmField::is_required( $field ) ? $field['required_indicator'] : '';
251
-        if ( ! is_array( $errors ) ) {
252
-            $errors = array();
253
-        }
251
+		if ( ! is_array( $errors ) ) {
252
+			$errors = array();
253
+		}
254 254
 		$error = isset( $errors[ 'field' . $field_id ] ) ? $errors[ 'field' . $field_id ] : false;
255 255
 
256
-        //If field type is section heading, add class so a bottom margin can be added to either the h3 or description
257
-        if ( $field['type'] == 'divider' ) {
258
-            if ( FrmField::is_option_true( $field, 'description' ) ) {
259
-                $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html );
260
-            } else {
261
-                $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html);
262
-            }
263
-        }
256
+		//If field type is section heading, add class so a bottom margin can be added to either the h3 or description
257
+		if ( $field['type'] == 'divider' ) {
258
+			if ( FrmField::is_option_true( $field, 'description' ) ) {
259
+				$html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html );
260
+			} else {
261
+				$html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html);
262
+			}
263
+		}
264 264
 
265 265
 		foreach ( array( 'description' => $field['description'], 'required_label' => $required, 'error' => $error ) as $code => $value ) {
266
-            self::remove_inline_conditions( ( $value && $value != '' ), $code, $value, $html );
267
-        }
266
+			self::remove_inline_conditions( ( $value && $value != '' ), $code, $value, $html );
267
+		}
268 268
 
269
-        //replace [required_class]
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
-        //replace [label_position]
274
-        $field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form);
275
-        $field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top';
273
+		//replace [label_position]
274
+		$field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form);
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
-        //replace [field_name]
279
-        $html = str_replace('[field_name]', $field['name'], $html);
278
+		//replace [field_name]
279
+		$html = str_replace('[field_name]', $field['name'], $html);
280 280
 
281 281
 		self::add_field_div_classes( $field_id, $field, $errors, $html );
282 282
 
283
-        //replace [entry_key]
284
-        $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' );
285
-        $html = str_replace('[entry_key]', $entry_key, $html);
283
+		//replace [entry_key]
284
+		$entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' );
285
+		$html = str_replace('[entry_key]', $entry_key, $html);
286 286
 
287
-        //replace [input]
288
-        preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER);
289
-        global $frm_vars;
290
-        $frm_settings = FrmAppHelper::get_settings();
287
+		//replace [input]
288
+		preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER);
289
+		global $frm_vars;
290
+		$frm_settings = FrmAppHelper::get_settings();
291 291
 
292
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
293
-            $atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
292
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
293
+			$atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
294 294
 			$tag = self::get_shortcode_tag( $shortcodes, $short_key, array( 'conditional' => false, 'conditional_check' => false ) );
295 295
 
296
-            $replace_with = '';
296
+			$replace_with = '';
297 297
 
298
-            if ( $tag == 'input' ) {
299
-                if ( isset($atts['opt']) ) {
300
-                    $atts['opt']--;
301
-                }
298
+			if ( $tag == 'input' ) {
299
+				if ( isset($atts['opt']) ) {
300
+					$atts['opt']--;
301
+				}
302 302
 
303
-                $field['input_class'] = isset($atts['class']) ? $atts['class'] : '';
304
-                if ( isset($atts['class']) ) {
305
-                    unset($atts['class']);
306
-                }
303
+				$field['input_class'] = isset($atts['class']) ? $atts['class'] : '';
304
+				if ( isset($atts['class']) ) {
305
+					unset($atts['class']);
306
+				}
307 307
 
308
-                $field['shortcodes'] = $atts;
309
-                ob_start();
308
+				$field['shortcodes'] = $atts;
309
+				ob_start();
310 310
 				include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/input.php' );
311
-                $replace_with = ob_get_contents();
312
-                ob_end_clean();
313
-            } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) {
314
-                $replace_with = FrmProEntriesController::entry_delete_link($atts);
315
-            }
311
+				$replace_with = ob_get_contents();
312
+				ob_end_clean();
313
+			} else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) {
314
+				$replace_with = FrmProEntriesController::entry_delete_link($atts);
315
+			}
316 316
 
317
-            $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html );
318
-        }
317
+			$html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html );
318
+		}
319 319
 
320 320
 		if ( $form ) {
321
-            $form = (array) $form;
321
+			$form = (array) $form;
322 322
 
323
-            //replace [form_key]
324
-            $html = str_replace('[form_key]', $form['form_key'], $html);
323
+			//replace [form_key]
324
+			$html = str_replace('[form_key]', $form['form_key'], $html);
325 325
 
326
-            //replace [form_name]
327
-            $html = str_replace('[form_name]', $form['name'], $html);
328
-        }
329
-        $html .= "\n";
326
+			//replace [form_name]
327
+			$html = str_replace('[form_name]', $form['name'], $html);
328
+		}
329
+		$html .= "\n";
330 330
 
331
-        //Return html if conf_field to prevent loop
332
-        if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) {
333
-            return $html;
334
-        }
331
+		//Return html if conf_field to prevent loop
332
+		if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) {
333
+			return $html;
334
+		}
335 335
 
336
-        //If field is in repeating section
337
-        if ( $args['section_id'] ) {
338
-            $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'] ));
339
-        } else {
340
-            $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ));
341
-        }
336
+		//If field is in repeating section
337
+		if ( $args['section_id'] ) {
338
+			$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'] ));
339
+		} else {
340
+			$html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ));
341
+		}
342 342
 
343 343
 		self::remove_collapse_shortcode( $html );
344 344
 
@@ -346,8 +346,8 @@  discard block
 block discarded – undo
346 346
 			$html = do_shortcode( $html );
347 347
 		}
348 348
 
349
-        return $html;
350
-    }
349
+		return $html;
350
+	}
351 351
 
352 352
 	/**
353 353
 	 * Add classes to a field div
@@ -401,46 +401,46 @@  discard block
 block discarded – undo
401 401
 		return $classes;
402 402
 	}
403 403
 
404
-    public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) {
405
-        if ( $no_vars ) {
404
+	public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) {
405
+		if ( $no_vars ) {
406 406
 			$html = str_replace( '[if ' . $code . ']', '', $html );
407 407
 			$html = str_replace( '[/if ' . $code . ']', '', $html );
408
-        } else {
408
+		} else {
409 409
 			$html = preg_replace( '/(\[if\s+' . $code . '\])(.*?)(\[\/if\s+' . $code . '\])/mis', '', $html );
410
-        }
410
+		}
411 411
 
412 412
 		$html = str_replace( '[' . $code . ']', $replace_with, $html );
413
-    }
413
+	}
414 414
 
415 415
 	public static function get_shortcode_tag( $shortcodes, $short_key, $args ) {
416 416
 		$args = wp_parse_args( $args, array( 'conditional' => false, 'conditional_check' => false, 'foreach' => false ) );
417
-        if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) {
418
-            $args['conditional_check'] = true;
419
-        }
420
-
421
-        $prefix = '';
422
-        if ( $args['conditional_check'] ) {
423
-            if ( $args['conditional'] ) {
424
-                $prefix = 'if ';
425
-            } else if ( $args['foreach'] ) {
426
-                $prefix = 'foreach ';
427
-            }
428
-        }
429
-
430
-        $with_tags = $args['conditional_check'] ? 3 : 2;
431
-        if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
432
-            $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
433
-            $tag = str_replace(']', '', $tag);
434
-            $tags = explode(' ', $tag);
435
-            if ( is_array($tags) ) {
436
-                $tag = $tags[0];
437
-            }
438
-        } else {
439
-            $tag = $shortcodes[ $with_tags - 1 ][ $short_key ];
440
-        }
441
-
442
-        return $tag;
443
-    }
417
+		if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) {
418
+			$args['conditional_check'] = true;
419
+		}
420
+
421
+		$prefix = '';
422
+		if ( $args['conditional_check'] ) {
423
+			if ( $args['conditional'] ) {
424
+				$prefix = 'if ';
425
+			} else if ( $args['foreach'] ) {
426
+				$prefix = 'foreach ';
427
+			}
428
+		}
429
+
430
+		$with_tags = $args['conditional_check'] ? 3 : 2;
431
+		if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
432
+			$tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
433
+			$tag = str_replace(']', '', $tag);
434
+			$tags = explode(' ', $tag);
435
+			if ( is_array($tags) ) {
436
+				$tag = $tags[0];
437
+			}
438
+		} else {
439
+			$tag = $shortcodes[ $with_tags - 1 ][ $short_key ];
440
+		}
441
+
442
+		return $tag;
443
+	}
444 444
 
445 445
 	/**
446 446
 	 * Remove [collapse_this] if it's still included after all processing
@@ -478,46 +478,46 @@  discard block
 block discarded – undo
478 478
 		}
479 479
 		$api_js_url = apply_filters( 'frm_recaptcha_js_url', $api_js_url );
480 480
 
481
-        wp_register_script( 'recaptcha-api', $api_js_url, '', true );
482
-        wp_enqueue_script( 'recaptcha-api' );
481
+		wp_register_script( 'recaptcha-api', $api_js_url, '', true );
482
+		wp_enqueue_script( 'recaptcha-api' );
483 483
 
484 484
 ?>
485 485
 <div id="field_<?php echo esc_attr( $field['field_key'] ) ?>" class="<?php echo esc_attr( $class_prefix ) ?>g-recaptcha" data-sitekey="<?php echo esc_attr( $frm_settings->pubkey ) ?>" data-size="<?php echo esc_attr( $field['captcha_size'] ) ?>" data-theme="<?php echo esc_attr( $field['captcha_theme'] ) ?>"></div>
486 486
 <?php
487
-    }
487
+	}
488 488
 
489 489
 	public static function show_single_option( $field ) {
490
-        $field_name = $field['name'];
491
-        $html_id = self::get_html_id($field);
492
-        foreach ( $field['options'] as $opt_key => $opt ) {
493
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
494
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
490
+		$field_name = $field['name'];
491
+		$html_id = self::get_html_id($field);
492
+		foreach ( $field['options'] as $opt_key => $opt ) {
493
+			$field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
494
+			$opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
495 495
 
496
-            // If this is an "Other" option, get the HTML for it
496
+			// If this is an "Other" option, get the HTML for it
497 497
 			if ( self::is_other_opt( $opt_key ) ) {
498
-                // Get string for Other text field, if needed
498
+				// Get string for Other text field, if needed
499 499
 				$other_val = self::get_other_val( compact( 'opt_key', 'field' ) );
500 500
 				require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' );
501
-            } else {
501
+			} else {
502 502
 				require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' );
503
-            }
504
-        }
505
-    }
503
+			}
504
+		}
505
+	}
506 506
 
507 507
 	public static function get_term_link( $tax_id ) {
508
-        $tax = get_taxonomy($tax_id);
509
-        if ( ! $tax ) {
510
-            return;
511
-        }
508
+		$tax = get_taxonomy($tax_id);
509
+		if ( ! $tax ) {
510
+			return;
511
+		}
512 512
 
513
-        $link = sprintf(
514
-            __( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
513
+		$link = sprintf(
514
+			__( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
515 515
 			'<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>'
516
-        );
517
-        unset($tax);
516
+		);
517
+		unset($tax);
518 518
 
519
-        return $link;
520
-    }
519
+		return $link;
520
+	}
521 521
 
522 522
 	public static function value_meets_condition( $observed_value, $cond, $hide_opt ) {
523 523
 		// Remove white space from hide_opt
@@ -528,195 +528,195 @@  discard block
 block discarded – undo
528 528
 		$observed_value = wp_kses_post( $observed_value );
529 529
 		$hide_opt = wp_kses_post( $hide_opt );
530 530
 
531
-        if ( is_array($observed_value) ) {
532
-            return self::array_value_condition($observed_value, $cond, $hide_opt);
533
-        }
534
-
535
-        $m = false;
536
-        if ( $cond == '==' ) {
537
-            $m = $observed_value == $hide_opt;
538
-        } else if ( $cond == '!=' ) {
539
-            $m = $observed_value != $hide_opt;
540
-        } else if ( $cond == '>' ) {
541
-            $m = $observed_value > $hide_opt;
542
-        } else if ( $cond == '<' ) {
543
-            $m = $observed_value < $hide_opt;
544
-        } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
545
-            $m = stripos($observed_value, $hide_opt);
546
-            if ( $cond == 'not LIKE' ) {
547
-                $m = ( $m === false ) ? true : false;
548
-            } else {
549
-                $m = ( $m === false ) ? false : true;
550
-            }
551
-        }
552
-        return $m;
553
-    }
531
+		if ( is_array($observed_value) ) {
532
+			return self::array_value_condition($observed_value, $cond, $hide_opt);
533
+		}
534
+
535
+		$m = false;
536
+		if ( $cond == '==' ) {
537
+			$m = $observed_value == $hide_opt;
538
+		} else if ( $cond == '!=' ) {
539
+			$m = $observed_value != $hide_opt;
540
+		} else if ( $cond == '>' ) {
541
+			$m = $observed_value > $hide_opt;
542
+		} else if ( $cond == '<' ) {
543
+			$m = $observed_value < $hide_opt;
544
+		} else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
545
+			$m = stripos($observed_value, $hide_opt);
546
+			if ( $cond == 'not LIKE' ) {
547
+				$m = ( $m === false ) ? true : false;
548
+			} else {
549
+				$m = ( $m === false ) ? false : true;
550
+			}
551
+		}
552
+		return $m;
553
+	}
554 554
 
555 555
 	public static function array_value_condition( $observed_value, $cond, $hide_opt ) {
556
-        $m = false;
557
-        if ( $cond == '==' ) {
558
-            if ( is_array($hide_opt) ) {
559
-                $m = array_intersect($hide_opt, $observed_value);
560
-                $m = empty($m) ? false : true;
561
-            } else {
562
-                $m = in_array($hide_opt, $observed_value);
563
-            }
564
-        } else if ( $cond == '!=' ) {
565
-            $m = ! in_array($hide_opt, $observed_value);
566
-        } else if ( $cond == '>' ) {
567
-            $min = min($observed_value);
568
-            $m = $min > $hide_opt;
569
-        } else if ( $cond == '<' ) {
570
-            $max = max($observed_value);
571
-            $m = $max < $hide_opt;
572
-        } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
573
-            foreach ( $observed_value as $ob ) {
574
-                $m = strpos($ob, $hide_opt);
575
-                if ( $m !== false ) {
576
-                    $m = true;
577
-                    break;
578
-                }
579
-            }
580
-
581
-            if ( $cond == 'not LIKE' ) {
582
-                $m = ( $m === false ) ? true : false;
583
-            }
584
-        }
585
-
586
-        return $m;
587
-    }
588
-
589
-    /**
590
-     * Replace a few basic shortcodes and field ids
591
-     * @since 2.0
592
-     * @return string
593
-     */
556
+		$m = false;
557
+		if ( $cond == '==' ) {
558
+			if ( is_array($hide_opt) ) {
559
+				$m = array_intersect($hide_opt, $observed_value);
560
+				$m = empty($m) ? false : true;
561
+			} else {
562
+				$m = in_array($hide_opt, $observed_value);
563
+			}
564
+		} else if ( $cond == '!=' ) {
565
+			$m = ! in_array($hide_opt, $observed_value);
566
+		} else if ( $cond == '>' ) {
567
+			$min = min($observed_value);
568
+			$m = $min > $hide_opt;
569
+		} else if ( $cond == '<' ) {
570
+			$max = max($observed_value);
571
+			$m = $max < $hide_opt;
572
+		} else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) {
573
+			foreach ( $observed_value as $ob ) {
574
+				$m = strpos($ob, $hide_opt);
575
+				if ( $m !== false ) {
576
+					$m = true;
577
+					break;
578
+				}
579
+			}
580
+
581
+			if ( $cond == 'not LIKE' ) {
582
+				$m = ( $m === false ) ? true : false;
583
+			}
584
+		}
585
+
586
+		return $m;
587
+	}
588
+
589
+	/**
590
+	 * Replace a few basic shortcodes and field ids
591
+	 * @since 2.0
592
+	 * @return string
593
+	 */
594 594
 	public static function basic_replace_shortcodes( $value, $form, $entry ) {
595
-        if ( strpos($value, '[sitename]') !== false ) {
596
-            $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
597
-            $value = str_replace('[sitename]', $new_value, $value);
598
-        }
595
+		if ( strpos($value, '[sitename]') !== false ) {
596
+			$new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
597
+			$value = str_replace('[sitename]', $new_value, $value);
598
+		}
599 599
 
600
-        $value = apply_filters('frm_content', $value, $form, $entry);
601
-        $value = do_shortcode($value);
600
+		$value = apply_filters('frm_content', $value, $form, $entry);
601
+		$value = do_shortcode($value);
602 602
 
603
-        return $value;
604
-    }
603
+		return $value;
604
+	}
605 605
 
606 606
 	public static function get_shortcodes( $content, $form_id ) {
607
-        if ( FrmAppHelper::pro_is_installed() ) {
608
-            return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
609
-        }
607
+		if ( FrmAppHelper::pro_is_installed() ) {
608
+			return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
609
+		}
610 610
 
611
-        $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) );
611
+		$fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) );
612 612
 
613
-        $tagregexp = self::allowed_shortcodes($fields);
613
+		$tagregexp = self::allowed_shortcodes($fields);
614 614
 
615
-        preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
615
+		preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
616 616
 
617
-        return $matches;
618
-    }
617
+		return $matches;
618
+	}
619 619
 
620 620
 	public static function allowed_shortcodes( $fields = array() ) {
621
-        $tagregexp = array(
622
-            'editlink', 'id', 'key', 'ip',
623
-            'siteurl', 'sitename', 'admin_email',
624
-            'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by',
621
+		$tagregexp = array(
622
+			'editlink', 'id', 'key', 'ip',
623
+			'siteurl', 'sitename', 'admin_email',
624
+			'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by',
625 625
 			'parent[-|_]id',
626
-        );
626
+		);
627 627
 
628
-        foreach ( $fields as $field ) {
629
-            $tagregexp[] = $field->id;
630
-            $tagregexp[] = $field->field_key;
631
-        }
628
+		foreach ( $fields as $field ) {
629
+			$tagregexp[] = $field->id;
630
+			$tagregexp[] = $field->field_key;
631
+		}
632 632
 
633
-        $tagregexp = implode('|', $tagregexp);
634
-        return $tagregexp;
635
-    }
633
+		$tagregexp = implode('|', $tagregexp);
634
+		return $tagregexp;
635
+	}
636 636
 
637 637
 	public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
638
-        $shortcode_values = array(
639
-           'id'     => $entry->id,
640
-           'key'    => $entry->item_key,
641
-           'ip'     => $entry->ip,
642
-        );
638
+		$shortcode_values = array(
639
+		   'id'     => $entry->id,
640
+		   'key'    => $entry->item_key,
641
+		   'ip'     => $entry->ip,
642
+		);
643 643
 
644
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
645
-            $atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] );
644
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
645
+			$atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] );
646 646
 
647
-            if ( ! empty( $shortcodes[3][ $short_key ] ) ) {
647
+			if ( ! empty( $shortcodes[3][ $short_key ] ) ) {
648 648
 				$tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] );
649
-                $tags = explode(' ', $tag);
650
-                if ( is_array($tags) ) {
651
-                    $tag = $tags[0];
652
-                }
653
-            } else {
654
-                $tag = $shortcodes[2][ $short_key ];
655
-            }
656
-
657
-            switch ( $tag ) {
658
-                case 'id':
659
-                case 'key':
660
-                case 'ip':
661
-                    $replace_with = $shortcode_values[ $tag ];
662
-                break;
663
-
664
-                case 'user_agent':
665
-                case 'user-agent':
666
-                    $entry->description = maybe_unserialize($entry->description);
649
+				$tags = explode(' ', $tag);
650
+				if ( is_array($tags) ) {
651
+					$tag = $tags[0];
652
+				}
653
+			} else {
654
+				$tag = $shortcodes[2][ $short_key ];
655
+			}
656
+
657
+			switch ( $tag ) {
658
+				case 'id':
659
+				case 'key':
660
+				case 'ip':
661
+					$replace_with = $shortcode_values[ $tag ];
662
+				break;
663
+
664
+				case 'user_agent':
665
+				case 'user-agent':
666
+					$entry->description = maybe_unserialize($entry->description);
667 667
 					$replace_with = FrmEntryFormat::get_browser( $entry->description['browser'] );
668
-                break;
669
-
670
-                case 'created_at':
671
-                case 'created-at':
672
-                case 'updated_at':
673
-                case 'updated-at':
674
-                    if ( isset($atts['format']) ) {
675
-                        $time_format = ' ';
676
-                    } else {
677
-                        $atts['format'] = get_option('date_format');
678
-                        $time_format = '';
679
-                    }
680
-
681
-                    $this_tag = str_replace('-', '_', $tag);
682
-                    $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
683
-                    unset($this_tag);
684
-                break;
685
-
686
-                case 'created_by':
687
-                case 'created-by':
688
-                case 'updated_by':
689
-                case 'updated-by':
690
-                    $this_tag = str_replace('-', '_', $tag);
668
+				break;
669
+
670
+				case 'created_at':
671
+				case 'created-at':
672
+				case 'updated_at':
673
+				case 'updated-at':
674
+					if ( isset($atts['format']) ) {
675
+						$time_format = ' ';
676
+					} else {
677
+						$atts['format'] = get_option('date_format');
678
+						$time_format = '';
679
+					}
680
+
681
+					$this_tag = str_replace('-', '_', $tag);
682
+					$replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
683
+					unset($this_tag);
684
+				break;
685
+
686
+				case 'created_by':
687
+				case 'created-by':
688
+				case 'updated_by':
689
+				case 'updated-by':
690
+					$this_tag = str_replace('-', '_', $tag);
691 691
 					$replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts );
692
-                    unset($this_tag);
693
-                break;
694
-
695
-                case 'admin_email':
696
-                case 'siteurl':
697
-                case 'frmurl':
698
-                case 'sitename':
699
-                case 'get':
700
-                    $replace_with = self::dynamic_default_values( $tag, $atts );
701
-                break;
702
-
703
-                default:
704
-                    $field = FrmField::getOne( $tag );
705
-                    if ( ! $field ) {
706
-                        break;
707
-                    }
708
-
709
-                    $sep = isset($atts['sep']) ? $atts['sep'] : ', ';
710
-
711
-                    $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id );
712
-
713
-                    $atts['entry_id'] = $entry->id;
714
-                    $atts['entry_key'] = $entry->item_key;
715
-
716
-                    if ( isset($atts['show']) && $atts['show'] == 'field_label' ) {
717
-                        $replace_with = $field->name;
718
-                    } else if ( isset($atts['show']) && $atts['show'] == 'description' ) {
719
-                        $replace_with = $field->description;
692
+					unset($this_tag);
693
+				break;
694
+
695
+				case 'admin_email':
696
+				case 'siteurl':
697
+				case 'frmurl':
698
+				case 'sitename':
699
+				case 'get':
700
+					$replace_with = self::dynamic_default_values( $tag, $atts );
701
+				break;
702
+
703
+				default:
704
+					$field = FrmField::getOne( $tag );
705
+					if ( ! $field ) {
706
+						break;
707
+					}
708
+
709
+					$sep = isset($atts['sep']) ? $atts['sep'] : ', ';
710
+
711
+					$replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id );
712
+
713
+					$atts['entry_id'] = $entry->id;
714
+					$atts['entry_key'] = $entry->item_key;
715
+
716
+					if ( isset($atts['show']) && $atts['show'] == 'field_label' ) {
717
+						$replace_with = $field->name;
718
+					} else if ( isset($atts['show']) && $atts['show'] == 'description' ) {
719
+						$replace_with = $field->description;
720 720
 					} else {
721 721
 						$string_value = $replace_with;
722 722
 						if ( is_array( $replace_with ) ) {
@@ -730,82 +730,82 @@  discard block
 block discarded – undo
730 730
 						}
731 731
 					}
732 732
 
733
-                    unset($field);
734
-                break;
735
-            }
733
+					unset($field);
734
+				break;
735
+			}
736 736
 
737
-            if ( isset($replace_with) ) {
738
-                $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
739
-            }
737
+			if ( isset($replace_with) ) {
738
+				$content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
739
+			}
740 740
 
741
-            unset($atts, $conditional, $replace_with);
741
+			unset($atts, $conditional, $replace_with);
742 742
 		}
743 743
 
744 744
 		return $content;
745
-    }
746
-
747
-    /**
748
-     * Get the value to replace a few standard shortcodes
749
-     *
750
-     * @since 2.0
751
-     * @return string
752
-     */
753
-    public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) {
754
-        $new_value = '';
755
-        switch ( $tag ) {
756
-            case 'admin_email':
757
-                $new_value = get_option('admin_email');
758
-                break;
759
-            case 'siteurl':
760
-                $new_value = FrmAppHelper::site_url();
761
-                break;
762
-            case 'frmurl':
763
-                $new_value = FrmAppHelper::plugin_url();
764
-                break;
765
-            case 'sitename':
766
-                $new_value = FrmAppHelper::site_name();
767
-                break;
768
-            case 'get':
769
-                $new_value = self::process_get_shortcode( $atts, $return_array );
770
-                break;
771
-        }
772
-
773
-        return $new_value;
774
-    }
775
-
776
-    /**
777
-     * Process the [get] shortcode
778
-     *
779
-     * @since 2.0
780
-     * @return string|array
781
-     */
782
-    public static function process_get_shortcode( $atts, $return_array = false ) {
783
-        if ( ! isset($atts['param']) ) {
784
-            return '';
785
-        }
786
-
787
-        if ( strpos($atts['param'], '&#91;') ) {
788
-            $atts['param'] = str_replace('&#91;', '[', $atts['param']);
789
-            $atts['param'] = str_replace('&#93;', ']', $atts['param']);
790
-        }
791
-
792
-        $new_value = FrmAppHelper::get_param($atts['param'], '');
793
-        $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
794
-
795
-        if ( $new_value == '' ) {
796
-            if ( ! isset($atts['prev_val']) ) {
797
-                $atts['prev_val'] = '';
798
-            }
799
-
800
-            $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
801
-        }
802
-
803
-        if ( is_array($new_value) && ! $return_array ) {
804
-            $new_value = implode(', ', $new_value);
805
-        }
806
-
807
-        return $new_value;
808
-    }
745
+	}
746
+
747
+	/**
748
+	 * Get the value to replace a few standard shortcodes
749
+	 *
750
+	 * @since 2.0
751
+	 * @return string
752
+	 */
753
+	public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) {
754
+		$new_value = '';
755
+		switch ( $tag ) {
756
+			case 'admin_email':
757
+				$new_value = get_option('admin_email');
758
+				break;
759
+			case 'siteurl':
760
+				$new_value = FrmAppHelper::site_url();
761
+				break;
762
+			case 'frmurl':
763
+				$new_value = FrmAppHelper::plugin_url();
764
+				break;
765
+			case 'sitename':
766
+				$new_value = FrmAppHelper::site_name();
767
+				break;
768
+			case 'get':
769
+				$new_value = self::process_get_shortcode( $atts, $return_array );
770
+				break;
771
+		}
772
+
773
+		return $new_value;
774
+	}
775
+
776
+	/**
777
+	 * Process the [get] shortcode
778
+	 *
779
+	 * @since 2.0
780
+	 * @return string|array
781
+	 */
782
+	public static function process_get_shortcode( $atts, $return_array = false ) {
783
+		if ( ! isset($atts['param']) ) {
784
+			return '';
785
+		}
786
+
787
+		if ( strpos($atts['param'], '&#91;') ) {
788
+			$atts['param'] = str_replace('&#91;', '[', $atts['param']);
789
+			$atts['param'] = str_replace('&#93;', ']', $atts['param']);
790
+		}
791
+
792
+		$new_value = FrmAppHelper::get_param($atts['param'], '');
793
+		$new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
794
+
795
+		if ( $new_value == '' ) {
796
+			if ( ! isset($atts['prev_val']) ) {
797
+				$atts['prev_val'] = '';
798
+			}
799
+
800
+			$new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val'];
801
+		}
802
+
803
+		if ( is_array($new_value) && ! $return_array ) {
804
+			$new_value = implode(', ', $new_value);
805
+		}
806
+
807
+		return $new_value;
808
+	}
809 809
 
810 810
 	public static function get_display_value( $replace_with, $field, $atts = array() ) {
811 811
 		$sep = isset( $atts['sep'] ) ? $atts['sep'] : ', ';
@@ -813,14 +813,14 @@  discard block
 block discarded – undo
813 813
 		$replace_with = apply_filters( 'frm_get_' . $field->type . '_display_value', $replace_with, $field, $atts );
814 814
 		$replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts );
815 815
 
816
-        if ( $field->type == 'textarea' || $field->type == 'rte' ) {
817
-            $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true;
818
-            if ( apply_filters('frm_use_wpautop', $autop) ) {
819
-                if ( is_array($replace_with) ) {
820
-                    $replace_with = implode("\n", $replace_with);
821
-                }
822
-                $replace_with = wpautop($replace_with);
823
-            }
816
+		if ( $field->type == 'textarea' || $field->type == 'rte' ) {
817
+			$autop = isset($atts['wpautop']) ? $atts['wpautop'] : true;
818
+			if ( apply_filters('frm_use_wpautop', $autop) ) {
819
+				if ( is_array($replace_with) ) {
820
+					$replace_with = implode("\n", $replace_with);
821
+				}
822
+				$replace_with = wpautop($replace_with);
823
+			}
824 824
 			unset( $autop );
825 825
 		} else if ( is_array( $replace_with ) ) {
826 826
 			$replace_with = implode( $sep, $replace_with );
@@ -830,58 +830,58 @@  discard block
 block discarded – undo
830 830
 	}
831 831
 
832 832
 	public static function get_field_types( $type ) {
833
-        $single_input = array(
834
-            'text', 'textarea', 'rte', 'number', 'email', 'url',
835
-            'image', 'file', 'date', 'phone', 'hidden', 'time',
836
-            'user_id', 'tag', 'password',
837
-        );
833
+		$single_input = array(
834
+			'text', 'textarea', 'rte', 'number', 'email', 'url',
835
+			'image', 'file', 'date', 'phone', 'hidden', 'time',
836
+			'user_id', 'tag', 'password',
837
+		);
838 838
 		$multiple_input = array( 'radio', 'checkbox', 'select', 'scale', 'lookup' );
839 839
 		$other_type = array( 'html', 'break' );
840 840
 
841 841
 		$field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() );
842 842
 
843
-        $field_types = array();
844
-        if ( in_array($type, $single_input) ) {
845
-            self::field_types_for_input( $single_input, $field_selection, $field_types );
846
-        } else if ( in_array($type, $multiple_input) ) {
847
-            self::field_types_for_input( $multiple_input, $field_selection, $field_types );
848
-        } else if ( in_array($type, $other_type) ) {
849
-            self::field_types_for_input( $other_type, $field_selection, $field_types );
843
+		$field_types = array();
844
+		if ( in_array($type, $single_input) ) {
845
+			self::field_types_for_input( $single_input, $field_selection, $field_types );
846
+		} else if ( in_array($type, $multiple_input) ) {
847
+			self::field_types_for_input( $multiple_input, $field_selection, $field_types );
848
+		} else if ( in_array($type, $other_type) ) {
849
+			self::field_types_for_input( $other_type, $field_selection, $field_types );
850 850
 		} else if ( isset( $field_selection[ $type ] ) ) {
851
-            $field_types[ $type ] = $field_selection[ $type ];
852
-        }
851
+			$field_types[ $type ] = $field_selection[ $type ];
852
+		}
853 853
 
854 854
 		$field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) );
855
-        return $field_types;
856
-    }
857
-
858
-    private static function field_types_for_input( $inputs, $fields, &$field_types ) {
859
-        foreach ( $inputs as $input ) {
860
-            $field_types[ $input ] = $fields[ $input ];
861
-            unset($input);
862
-        }
863
-    }
864
-
865
-    /**
866
-    * Check if current field option is an "other" option
867
-    *
868
-    * @since 2.0.6
869
-    *
870
-    * @param string $opt_key
871
-    * @return boolean Returns true if current field option is an "Other" option
872
-    */
873
-    public static function is_other_opt( $opt_key ) {
874
-        return $opt_key && strpos( $opt_key, 'other' ) !== false;
875
-    }
876
-
877
-    /**
878
-    * Get value that belongs in "Other" text box
879
-    *
880
-    * @since 2.0.6
881
-    *
882
-    * @param array $args
883
-    */
884
-    public static function get_other_val( $args ) {
855
+		return $field_types;
856
+	}
857
+
858
+	private static function field_types_for_input( $inputs, $fields, &$field_types ) {
859
+		foreach ( $inputs as $input ) {
860
+			$field_types[ $input ] = $fields[ $input ];
861
+			unset($input);
862
+		}
863
+	}
864
+
865
+	/**
866
+	 * Check if current field option is an "other" option
867
+	 *
868
+	 * @since 2.0.6
869
+	 *
870
+	 * @param string $opt_key
871
+	 * @return boolean Returns true if current field option is an "Other" option
872
+	 */
873
+	public static function is_other_opt( $opt_key ) {
874
+		return $opt_key && strpos( $opt_key, 'other' ) !== false;
875
+	}
876
+
877
+	/**
878
+	 * Get value that belongs in "Other" text box
879
+	 *
880
+	 * @since 2.0.6
881
+	 *
882
+	 * @param array $args
883
+	 */
884
+	public static function get_other_val( $args ) {
885 885
 		$defaults = array(
886 886
 			'opt_key' => 0, 'field' => array(),
887 887
 			'parent' => false, 'pointer' => false,
@@ -957,20 +957,20 @@  discard block
 block discarded – undo
957 957
 		}
958 958
 
959 959
 		return $other_val;
960
-    }
961
-
962
-    /**
963
-    * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
964
-    * Intended for front-end use
965
-    *
966
-    * @since 2.0.6
967
-    *
968
-    * @param array $args should include field, opt_key and field name
969
-    * @param boolean $other_opt
970
-    * @param string $checked
971
-    * @return string $other_val
972
-    */
973
-    public static function prepare_other_input( $args, &$other_opt, &$checked ) {
960
+	}
961
+
962
+	/**
963
+	 * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
964
+	 * Intended for front-end use
965
+	 *
966
+	 * @since 2.0.6
967
+	 *
968
+	 * @param array $args should include field, opt_key and field name
969
+	 * @param boolean $other_opt
970
+	 * @param string $checked
971
+	 * @return string $other_val
972
+	 */
973
+	public static function prepare_other_input( $args, &$other_opt, &$checked ) {
974 974
 		//Check if this is an "Other" option
975 975
 		if ( ! self::is_other_opt( $args['opt_key'] ) ) {
976 976
 			return;
@@ -986,8 +986,8 @@  discard block
 block discarded – undo
986 986
 			$checked = 'checked="checked" ';
987 987
 		}
988 988
 
989
-        return $other_args;
990
-    }
989
+		return $other_args;
990
+	}
991 991
 
992 992
 	/**
993 993
 	 * @param array $args
@@ -1036,8 +1036,8 @@  discard block
 block discarded – undo
1036 1036
 	 * @since 2.0.6
1037 1037
 	 */
1038 1038
 	public static function include_other_input( $args ) {
1039
-        if ( ! $args['other_opt'] ) {
1040
-        	return;
1039
+		if ( ! $args['other_opt'] ) {
1040
+			return;
1041 1041
 		}
1042 1042
 
1043 1043
 		$classes = array( 'frm_other_input' );
@@ -1058,15 +1058,15 @@  discard block
 block discarded – undo
1058 1058
 	}
1059 1059
 
1060 1060
 	/**
1061
-	* Get the HTML id for an "Other" text field
1062
-	* Note: This does not affect fields in repeating sections
1063
-	*
1064
-	* @since 2.0.08
1065
-	* @param string $type - field type
1066
-	* @param string $html_id
1067
-	* @param string|boolean $opt_key
1068
-	* @return string $other_id
1069
-	*/
1061
+	 * Get the HTML id for an "Other" text field
1062
+	 * Note: This does not affect fields in repeating sections
1063
+	 *
1064
+	 * @since 2.0.08
1065
+	 * @param string $type - field type
1066
+	 * @param string $html_id
1067
+	 * @param string|boolean $opt_key
1068
+	 * @return string $other_id
1069
+	 */
1070 1070
 	public static function get_other_field_html_id( $type, $html_id, $opt_key = false ) {
1071 1071
 		$other_id = $html_id;
1072 1072
 
@@ -1124,10 +1124,10 @@  discard block
 block discarded – undo
1124 1124
 	}
1125 1125
 
1126 1126
 	public static function switch_field_ids( $val ) {
1127
-        global $frm_duplicate_ids;
1128
-        $replace = array();
1129
-        $replace_with = array();
1130
-        foreach ( (array) $frm_duplicate_ids as $old => $new ) {
1127
+		global $frm_duplicate_ids;
1128
+		$replace = array();
1129
+		$replace_with = array();
1130
+		foreach ( (array) $frm_duplicate_ids as $old => $new ) {
1131 1131
 			$replace[] = '[if ' . $old . ']';
1132 1132
 			$replace_with[] = '[if ' . $new . ']';
1133 1133
 			$replace[] = '[if ' . $old . ' ';
@@ -1142,153 +1142,153 @@  discard block
 block discarded – undo
1142 1142
 			$replace_with[] = '[' . $new . ']';
1143 1143
 			$replace[] = '[' . $old . ' ';
1144 1144
 			$replace_with[] = '[' . $new . ' ';
1145
-            unset($old, $new);
1146
-        }
1145
+			unset($old, $new);
1146
+		}
1147 1147
 		if ( is_array( $val ) ) {
1148 1148
 			foreach ( $val as $k => $v ) {
1149
-                $val[ $k ] = str_replace( $replace, $replace_with, $v );
1150
-                unset($k, $v);
1151
-            }
1152
-        } else {
1153
-            $val = str_replace($replace, $replace_with, $val);
1154
-        }
1155
-
1156
-        return $val;
1157
-    }
1158
-
1159
-    public static function get_us_states() {
1160
-        return apply_filters( 'frm_us_states', array(
1161
-            'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona',
1162
-            'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware',
1163
-            'DC' => 'District of Columbia',
1164
-            'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho',
1165
-            'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas',
1166
-            'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland',
1167
-            'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
1168
-            'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada',
1169
-            'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York',
1170
-            'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma',
1171
-            'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina',
1172
-            'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah',
1173
-            'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia',
1174
-            'WI' => 'Wisconsin', 'WY' => 'Wyoming',
1175
-        ) );
1176
-    }
1177
-
1178
-    public static function get_countries() {
1179
-        return apply_filters( 'frm_countries', array(
1180
-            __( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ),
1181
-            __( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ),
1182
-            __( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ),
1183
-            __( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ),
1184
-            __( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ),
1185
-            __( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ),
1186
-            __( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ),
1187
-            __( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ),
1188
-            __( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ),
1189
-            __( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ),
1190
-            __( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ),
1191
-            __( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ),
1192
-            __( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ),
1193
-            __( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ),
1194
-            __( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ),
1195
-            __( 'Costa Rica', 'formidable' ), __( 'C&ocirc;te d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ),
1196
-            __( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ),
1197
-            __( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ),
1198
-            __( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ),
1199
-            __( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ),
1200
-            __( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ),
1201
-            __( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ),
1202
-            __( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ),
1203
-            __( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ),
1204
-            __( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ),
1205
-            __( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ),
1206
-            __( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ),
1207
-            __( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ),
1208
-            __( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ),
1209
-            __( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ),
1210
-            __( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ),
1211
-            __( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ),
1212
-            __( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ),
1213
-            __( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ),
1214
-            __( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ),
1215
-            __( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ),
1216
-            __( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ),
1217
-            __( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ),
1218
-            __( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ),
1219
-            __( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ),
1220
-            __( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ),
1221
-            __( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ),
1222
-            __( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ),
1223
-            __( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ),
1224
-            __( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ),
1225
-            __( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ),
1226
-            __( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ),
1227
-            __( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ),
1228
-            __( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ),
1229
-            __( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ),
1230
-            __( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ),
1231
-            __( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ),
1232
-            __( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ),
1233
-            __( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ),
1234
-            __( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ),
1235
-            __( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ),
1236
-            __( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ),
1237
-            __( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ),
1238
-            __( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ),
1239
-            __( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ),
1240
-            __( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ),
1241
-            __( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ),
1242
-            __( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ),
1243
-            __( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ),
1244
-            __( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ),
1245
-            __( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ),
1246
-            __( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ),
1247
-            __( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ),
1248
-            __( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ),
1249
-            __( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ),
1250
-            __( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ),
1251
-            __( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ),
1252
-            __( 'Zimbabwe', 'formidable' ),
1253
-        ) );
1254
-    }
1149
+				$val[ $k ] = str_replace( $replace, $replace_with, $v );
1150
+				unset($k, $v);
1151
+			}
1152
+		} else {
1153
+			$val = str_replace($replace, $replace_with, $val);
1154
+		}
1155
+
1156
+		return $val;
1157
+	}
1158
+
1159
+	public static function get_us_states() {
1160
+		return apply_filters( 'frm_us_states', array(
1161
+			'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona',
1162
+			'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware',
1163
+			'DC' => 'District of Columbia',
1164
+			'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho',
1165
+			'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas',
1166
+			'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland',
1167
+			'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
1168
+			'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada',
1169
+			'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York',
1170
+			'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma',
1171
+			'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina',
1172
+			'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah',
1173
+			'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia',
1174
+			'WI' => 'Wisconsin', 'WY' => 'Wyoming',
1175
+		) );
1176
+	}
1177
+
1178
+	public static function get_countries() {
1179
+		return apply_filters( 'frm_countries', array(
1180
+			__( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ),
1181
+			__( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ),
1182
+			__( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ),
1183
+			__( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ),
1184
+			__( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ),
1185
+			__( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ),
1186
+			__( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ),
1187
+			__( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ),
1188
+			__( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ),
1189
+			__( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ),
1190
+			__( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ),
1191
+			__( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ),
1192
+			__( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ),
1193
+			__( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ),
1194
+			__( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ),
1195
+			__( 'Costa Rica', 'formidable' ), __( 'C&ocirc;te d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ),
1196
+			__( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ),
1197
+			__( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ),
1198
+			__( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ),
1199
+			__( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ),
1200
+			__( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ),
1201
+			__( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ),
1202
+			__( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ),
1203
+			__( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ),
1204
+			__( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ),
1205
+			__( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ),
1206
+			__( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ),
1207
+			__( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ),
1208
+			__( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ),
1209
+			__( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ),
1210
+			__( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ),
1211
+			__( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ),
1212
+			__( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ),
1213
+			__( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ),
1214
+			__( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ),
1215
+			__( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ),
1216
+			__( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ),
1217
+			__( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ),
1218
+			__( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ),
1219
+			__( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ),
1220
+			__( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ),
1221
+			__( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ),
1222
+			__( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ),
1223
+			__( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ),
1224
+			__( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ),
1225
+			__( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ),
1226
+			__( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ),
1227
+			__( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ),
1228
+			__( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ),
1229
+			__( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ),
1230
+			__( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ),
1231
+			__( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ),
1232
+			__( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ),
1233
+			__( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ),
1234
+			__( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ),
1235
+			__( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ),
1236
+			__( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ),
1237
+			__( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ),
1238
+			__( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ),
1239
+			__( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ),
1240
+			__( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ),
1241
+			__( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ),
1242
+			__( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ),
1243
+			__( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ),
1244
+			__( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ),
1245
+			__( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ),
1246
+			__( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ),
1247
+			__( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ),
1248
+			__( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ),
1249
+			__( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ),
1250
+			__( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ),
1251
+			__( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ),
1252
+			__( 'Zimbabwe', 'formidable' ),
1253
+		) );
1254
+	}
1255 1255
 
1256 1256
 	public static function get_bulk_prefilled_opts( array &$prepop ) {
1257 1257
 		$prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries();
1258 1258
 
1259
-        $states = FrmFieldsHelper::get_us_states();
1260
-        $state_abv = array_keys($states);
1261
-        sort($state_abv);
1259
+		$states = FrmFieldsHelper::get_us_states();
1260
+		$state_abv = array_keys($states);
1261
+		sort($state_abv);
1262 1262
 		$prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv;
1263 1263
 
1264
-        $states = array_values($states);
1265
-        sort($states);
1264
+		$states = array_values($states);
1265
+		sort($states);
1266 1266
 		$prepop[ __( 'U.S. States', 'formidable' ) ] = $states;
1267
-        unset($state_abv, $states);
1267
+		unset($state_abv, $states);
1268 1268
 
1269 1269
 		$prepop[ __( 'Age', 'formidable' ) ] = array(
1270
-            __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1271
-            __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1272
-            __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1273
-        );
1270
+			__( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ),
1271
+			__( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ),
1272
+			__( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ),
1273
+		);
1274 1274
 
1275 1275
 		$prepop[ __( 'Satisfaction', 'formidable' ) ] = array(
1276
-            __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1277
-            __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1278
-        );
1276
+			__( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ),
1277
+			__( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ),
1278
+		);
1279 1279
 
1280 1280
 		$prepop[ __( 'Importance', 'formidable' ) ] = array(
1281
-            __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1282
-            __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1283
-        );
1281
+			__( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ),
1282
+			__( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ),
1283
+		);
1284 1284
 
1285 1285
 		$prepop[ __( 'Agreement', 'formidable' ) ] = array(
1286
-            __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1287
-            __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1288
-        );
1286
+			__( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ),
1287
+			__( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ),
1288
+		);
1289 1289
 
1290 1290
 		$prepop = apply_filters( 'frm_bulk_field_choices', $prepop );
1291
-    }
1291
+	}
1292 1292
 
1293 1293
 	public static function field_selection() {
1294 1294
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::field_selection' );
@@ -1325,10 +1325,10 @@  discard block
 block discarded – undo
1325 1325
 		return FrmField::is_required( $field );
1326 1326
 	}
1327 1327
 
1328
-    public static function maybe_get_field( &$field ) {
1328
+	public static function maybe_get_field( &$field ) {
1329 1329
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::maybe_get_field' );
1330 1330
 		FrmField::maybe_get_field( $field );
1331
-    }
1331
+	}
1332 1332
 
1333 1333
 	public static function dropdown_categories( $args ) {
1334 1334
 		_deprecated_function( __FUNCTION__, '2.02.07', 'FrmProPost::get_category_dropdown' );
Please login to merge, or discard this patch.
classes/views/frm-fields/input.php 2 patches
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -10,41 +10,41 @@  discard block
 block discarded – undo
10 10
 <?php
11 11
 
12 12
 } else if ( $field['type'] == 'radio' ) {
13
-    $read_only = false;
13
+	$read_only = false;
14 14
 	if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) {
15
-        $read_only = true; ?>
15
+		$read_only = true; ?>
16 16
 <input type="hidden" value="<?php echo esc_attr( $field['value'] ) ?>" name="<?php echo esc_attr( $field_name ) ?>" />
17 17
 <?php
18
-    }
18
+	}
19 19
 
20
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
20
+	if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
21 21
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
22
-    } else if ( is_array($field['options']) ) {
23
-        foreach ( $field['options'] as $opt_key => $opt ) {
22
+	} else if ( is_array($field['options']) ) {
23
+		foreach ( $field['options'] as $opt_key => $opt ) {
24 24
 			if ( isset( $atts ) && isset( $atts['opt'] ) && ( $atts['opt'] != $opt_key ) ) {
25
-                continue;
26
-            }
25
+				continue;
26
+			}
27 27
 
28
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
29
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); ?>
28
+			$field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
29
+			$opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); ?>
30 30
 			<div class="<?php echo esc_attr( apply_filters( 'frm_radio_class', 'frm_radio', $field, $field_val ) ) ?>"><?php
31 31
 
32 32
 			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
33 33
 				?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
34
-            }
35
-            $checked = FrmAppHelper::check_selected($field['value'], $field_val) ? 'checked="checked" ' : ' ';
34
+			}
35
+			$checked = FrmAppHelper::check_selected($field['value'], $field_val) ? 'checked="checked" ' : ' ';
36 36
 
37
-            $other_opt = false;
38
-            $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field_name', 'opt_key', 'field' ), $other_opt, $checked );
39
-            ?>
37
+			$other_opt = false;
38
+			$other_args = FrmFieldsHelper::prepare_other_input( compact( 'field_name', 'opt_key', 'field' ), $other_opt, $checked );
39
+			?>
40 40
             <input type="radio" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id . '-' . $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php
41
-            echo $checked;
42
-            do_action('frm_field_input_html', $field);
41
+			echo $checked;
42
+			do_action('frm_field_input_html', $field);
43 43
 ?>/><?php
44 44
 
45 45
 			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
46 46
 				echo ' ' . $opt . '</label>';
47
-            }
47
+			}
48 48
 
49 49
 			FrmFieldsHelper::include_other_input( array(
50 50
 				'other_opt' => $other_opt, 'read_only' => $read_only,
@@ -53,58 +53,58 @@  discard block
 block discarded – undo
53 53
 				'html_id' => $html_id, 'opt_key' => $opt_key,
54 54
 			) );
55 55
 
56
-            unset( $other_opt, $other_args );
56
+			unset( $other_opt, $other_args );
57 57
 ?></div>
58 58
 <?php
59
-        }
60
-    }
59
+		}
60
+	}
61 61
 } else if ( $field['type'] == 'select' ) {
62 62
 	include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/front-end/dropdown-field.php' );
63 63
 } else if ( $field['type'] == 'checkbox' ) {
64
-    $checked_values = $field['value'];
65
-    $read_only = false;
64
+	$checked_values = $field['value'];
65
+	$read_only = false;
66 66
 
67 67
 	if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) {
68
-        $read_only = true;
69
-        if ( $checked_values ) {
70
-            foreach ( (array) $checked_values as $checked_value ) { ?>
68
+		$read_only = true;
69
+		if ( $checked_values ) {
70
+			foreach ( (array) $checked_values as $checked_value ) { ?>
71 71
 <input type="hidden" value="<?php echo esc_attr( $checked_value ) ?>" name="<?php echo esc_attr( $field_name ) ?>[]" />
72 72
 <?php
73
-            }
74
-        } else { ?>
73
+			}
74
+		} else { ?>
75 75
 <input type="hidden" value="" name="<?php echo esc_attr( $field_name ) ?>[]" />
76 76
 <?php
77
-        }
78
-    }
77
+		}
78
+	}
79 79
 
80
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
80
+	if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
81 81
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
82
-    } else if ( $field['options'] ) {
83
-        foreach ( $field['options'] as $opt_key => $opt ) {
84
-            if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] != $opt_key) ) {
85
-                continue;
86
-            }
87
-
88
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
89
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
90
-            $checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : '';
91
-
92
-            // Check if other opt, and get values for other field if needed
93
-            $other_opt = false;
82
+	} else if ( $field['options'] ) {
83
+		foreach ( $field['options'] as $opt_key => $opt ) {
84
+			if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] != $opt_key) ) {
85
+				continue;
86
+			}
87
+
88
+			$field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
89
+			$opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
90
+			$checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : '';
91
+
92
+			// Check if other opt, and get values for other field if needed
93
+			$other_opt = false;
94 94
 			$other_args = FrmFieldsHelper::prepare_other_input( compact( 'field', 'field_name', 'opt_key' ), $other_opt, $checked );
95 95
 
96
-            ?>
96
+			?>
97 97
 			<div class="<?php echo esc_attr( apply_filters( 'frm_checkbox_class', 'frm_checkbox', $field, $field_val ) ) ?>" id="frm_checkbox_<?php echo esc_attr( $field['id'] ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
98 98
 
99
-            if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
100
-                ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
101
-            }
99
+			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
100
+				?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
101
+			}
102 102
 
103
-            ?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action('frm_field_input_html', $field) ?> /><?php
103
+			?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action('frm_field_input_html', $field) ?> /><?php
104 104
 
105
-            if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
105
+			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
106 106
 				echo ' ' . $opt . '</label>';
107
-            }
107
+			}
108 108
 
109 109
 			FrmFieldsHelper::include_other_input( array(
110 110
 				'other_opt' => $other_opt, 'read_only' => $read_only,
@@ -113,17 +113,17 @@  discard block
 block discarded – undo
113 113
 				'html_id' => $html_id, 'opt_key' => $opt_key,
114 114
 			) );
115 115
 
116
-            unset( $other_opt, $other_args, $checked );
116
+			unset( $other_opt, $other_args, $checked );
117 117
 
118
-            ?></div>
118
+			?></div>
119 119
 <?php
120
-        }
121
-    }
120
+		}
121
+	}
122 122
 } else if ( $field['type'] == 'captcha' && ! FrmAppHelper::is_admin() ) {
123
-    $frm_settings = FrmAppHelper::get_settings();
124
-    if ( ! empty($frm_settings->pubkey) ) {
125
-        FrmFieldsHelper::display_recaptcha($field);
126
-    }
123
+	$frm_settings = FrmAppHelper::get_settings();
124
+	if ( ! empty($frm_settings->pubkey) ) {
125
+		FrmFieldsHelper::display_recaptcha($field);
126
+	}
127 127
 } else {
128 128
 	do_action( 'frm_form_fields', $field, $field_name, compact( 'errors', 'html_id' ) );
129 129
 	do_action( 'frm_form_field_' . $field['type'], $field, $field_name, compact( 'errors', 'html_id' ) );
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
1 1
 <?php if ( in_array( $field['type'], array( 'email', 'url', 'text' ) ) ) { ?>
2
-<input type="<?php echo ( $frm_settings->use_html || $field['type'] == 'password' ) ? $field['type'] : 'text'; ?>" id="<?php echo esc_attr( $html_id ) ?>" name="<?php echo esc_attr( $field_name ) ?>" value="<?php echo esc_attr( $field['value'] ) ?>" <?php do_action('frm_field_input_html', $field) ?>/>
2
+<input type="<?php echo ( $frm_settings->use_html || $field['type'] == 'password' ) ? $field['type'] : 'text'; ?>" id="<?php echo esc_attr( $html_id ) ?>" name="<?php echo esc_attr( $field_name ) ?>" value="<?php echo esc_attr( $field['value'] ) ?>" <?php do_action( 'frm_field_input_html', $field ) ?>/>
3 3
 <?php } else if ( $field['type'] == 'textarea' ) { ?>
4 4
 <textarea name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" <?php
5 5
 if ( $field['max'] ) {
6 6
 	echo 'rows="' . esc_attr( $field['max'] ) . '" ';
7 7
 }
8
-do_action('frm_field_input_html', $field);
9
-?>><?php echo FrmAppHelper::esc_textarea($field['value']) ?></textarea>
8
+do_action( 'frm_field_input_html', $field );
9
+?>><?php echo FrmAppHelper::esc_textarea( $field['value'] ) ?></textarea>
10 10
 <?php
11 11
 
12 12
 } else if ( $field['type'] == 'radio' ) {
@@ -17,29 +17,29 @@  discard block
 block discarded – undo
17 17
 <?php
18 18
     }
19 19
 
20
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
20
+    if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) {
21 21
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
22
-    } else if ( is_array($field['options']) ) {
22
+    } else if ( is_array( $field['options'] ) ) {
23 23
         foreach ( $field['options'] as $opt_key => $opt ) {
24 24
 			if ( isset( $atts ) && isset( $atts['opt'] ) && ( $atts['opt'] != $opt_key ) ) {
25 25
                 continue;
26 26
             }
27 27
 
28
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
29
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); ?>
28
+            $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field );
29
+            $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field ); ?>
30 30
 			<div class="<?php echo esc_attr( apply_filters( 'frm_radio_class', 'frm_radio', $field, $field_val ) ) ?>"><?php
31 31
 
32 32
 			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
33 33
 				?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
34 34
             }
35
-            $checked = FrmAppHelper::check_selected($field['value'], $field_val) ? 'checked="checked" ' : ' ';
35
+            $checked = FrmAppHelper::check_selected( $field['value'], $field_val ) ? 'checked="checked" ' : ' ';
36 36
 
37 37
             $other_opt = false;
38 38
             $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field_name', 'opt_key', 'field' ), $other_opt, $checked );
39 39
             ?>
40 40
             <input type="radio" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id . '-' . $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php
41 41
             echo $checked;
42
-            do_action('frm_field_input_html', $field);
42
+            do_action( 'frm_field_input_html', $field );
43 43
 ?>/><?php
44 44
 
45 45
 			if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
@@ -77,17 +77,17 @@  discard block
 block discarded – undo
77 77
         }
78 78
     }
79 79
 
80
-    if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) {
80
+    if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) {
81 81
 		do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) );
82 82
     } else if ( $field['options'] ) {
83 83
         foreach ( $field['options'] as $opt_key => $opt ) {
84
-            if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] != $opt_key) ) {
84
+            if ( isset( $atts ) && isset( $atts['opt'] ) && ( $atts['opt'] != $opt_key ) ) {
85 85
                 continue;
86 86
             }
87 87
 
88
-            $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
89
-            $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
90
-            $checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : '';
88
+            $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field );
89
+            $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field );
90
+            $checked = FrmAppHelper::check_selected( $checked_values, $field_val ) ? ' checked="checked"' : '';
91 91
 
92 92
             // Check if other opt, and get values for other field if needed
93 93
             $other_opt = false;
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
                 ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php
101 101
             }
102 102
 
103
-            ?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action('frm_field_input_html', $field) ?> /><?php
103
+            ?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action( 'frm_field_input_html', $field ) ?> /><?php
104 104
 
105 105
             if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) {
106 106
 				echo ' ' . $opt . '</label>';
@@ -121,8 +121,8 @@  discard block
 block discarded – undo
121 121
     }
122 122
 } else if ( $field['type'] == 'captcha' && ! FrmAppHelper::is_admin() ) {
123 123
     $frm_settings = FrmAppHelper::get_settings();
124
-    if ( ! empty($frm_settings->pubkey) ) {
125
-        FrmFieldsHelper::display_recaptcha($field);
124
+    if ( ! empty( $frm_settings->pubkey ) ) {
125
+        FrmFieldsHelper::display_recaptcha( $field );
126 126
     }
127 127
 } else {
128 128
 	do_action( 'frm_form_fields', $field, $field_name, compact( 'errors', 'html_id' ) );
Please login to merge, or discard this patch.
classes/views/frm-fields/front-end/dropdown-field.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,17 +1,17 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 $read_only = false;
4
-if ( isset($field['post_field']) && $field['post_field'] == 'post_category' && FrmAppHelper::pro_is_installed() ) {
4
+if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' && FrmAppHelper::pro_is_installed() ) {
5 5
 	echo FrmProPost::get_category_dropdown( $field, array( 'location' => 'front', 'name' => $field_name, 'id' => $html_id ) );
6 6
 } else {
7 7
 	if ( FrmAppHelper::pro_is_installed() && FrmField::is_read_only( $field ) ) {
8 8
 		$read_only = true;
9 9
 
10 10
 		echo FrmProDropdownFieldsController::get_hidden_fields_with_readonly_values( $field, $field_name, $html_id ); ?>
11
-		<select <?php do_action('frm_field_input_html', $field) ?>> <?php
11
+		<select <?php do_action( 'frm_field_input_html', $field ) ?>> <?php
12 12
 
13 13
 	} else { ?>
14
-		<select name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" <?php do_action('frm_field_input_html', $field) ?>>
14
+		<select name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" <?php do_action( 'frm_field_input_html', $field ) ?>>
15 15
 	<?php   }
16 16
 
17 17
 	$other_opt = $other_checked = false;
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 			}
27 27
 		}
28 28
 		?>
29
-		<option value="<?php echo esc_attr($field_val) ?>" <?php echo $selected ? ' selected="selected"' : ''; ?><?php echo ( FrmFieldsHelper::is_other_opt( $opt_key ) ) ? ' class="frm_other_trigger"' : '';?>><?php echo esc_html( $opt == '' ? ' ' : $opt ); ?></option>
29
+		<option value="<?php echo esc_attr( $field_val ) ?>" <?php echo $selected ? ' selected="selected"' : ''; ?><?php echo ( FrmFieldsHelper::is_other_opt( $opt_key ) ) ? ' class="frm_other_trigger"' : ''; ?>><?php echo esc_html( $opt == '' ? ' ' : $opt ); ?></option>
30 30
 		<?php
31 31
 	} ?>
32 32
 	</select>
Please login to merge, or discard this patch.
classes/views/frm-fields/back-end/dropdown-field.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,14 +1,14 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( isset($field['post_field']) && $field['post_field'] == 'post_category' && FrmAppHelper::pro_is_installed() ) {
3
+if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' && FrmAppHelper::pro_is_installed() ) {
4 4
 	echo FrmProPost::get_category_dropdown( $field, array( 'name' => $field_name, 'id' => 'placeholder_id', 'location' => 'form_builder' ) );
5 5
 } else { ?>
6 6
 	<select name="<?php echo esc_attr( $field_name ) . ( FrmField::is_option_true( $field, 'multiple' ) ? '[]' : '' ); ?>" <?php
7 7
 	echo FrmField::is_option_true( $field, 'size' ) ? 'class="auto_width"' : '';
8 8
 	echo FrmField::is_option_true( $field, 'multiple' ) ? ' multiple="multiple"' : ''; ?> >
9 9
 		<?php foreach ( $field['options'] as $opt_key => $opt ) {
10
-			$field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
11
-			$opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
10
+			$field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field );
11
+			$opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field );
12 12
 			$selected = ( $field['default_value'] == $field_val || FrmFieldsHelper::get_other_val( array( 'opt_key', 'field' ) ) ) ? ' selected="selected"' : ''; ?>
13 13
 			<option value="<?php echo esc_attr( $field_val ) ?>"<?php echo $selected ?>><?php echo esc_html( $opt ) ?> </option>
14 14
 		<?php } ?>
@@ -26,9 +26,9 @@  discard block
 block discarded – undo
26 26
 	<?php
27 27
 
28 28
 	if ( ! isset( $field['post_field'] ) || ! in_array( $field['post_field'], array( 'post_category' ) ) ) { ?>
29
-		<?php do_action('frm_add_multiple_opts_labels', $field); ?>
30
-		<ul id="frm_field_<?php echo esc_attr( $field['id'] ) ?>_opts" class="frm_sortable_field_opts<?php echo ( count($field['options']) > 10 ) ? ' frm_field_opts_list' : ''; ?>">
31
-			<?php FrmFieldsHelper::show_single_option($field); ?>
29
+		<?php do_action( 'frm_add_multiple_opts_labels', $field ); ?>
30
+		<ul id="frm_field_<?php echo esc_attr( $field['id'] ) ?>_opts" class="frm_sortable_field_opts<?php echo ( count( $field['options'] ) > 10 ) ? ' frm_field_opts_list' : ''; ?>">
31
+			<?php FrmFieldsHelper::show_single_option( $field ); ?>
32 32
 		</ul>
33 33
 		<?php
34 34
 	} ?>
Please login to merge, or discard this patch.